mirror of
https://github.com/netbirdio/netbird.git
synced 2026-08-04 19:55:09 -04:00
Surface the caller-scoped Agent Network setup on the CLI. Both commands dial management directly with the active profile's WireGuard key — the same path foreground login uses — so no daemon proto or engine wiring is needed for the proof of concept. netbird agent-network ls prints the proxy endpoint, the authorized providers, and the allowed models (--json for the raw response). netbird agent-network env prints POSIX export lines for Anthropic-compatible tools such as Claude Code, applied with eval "$(netbird agent-network env)": ANTHROPIC_BASE_URL points at the account's proxy endpoint and ANTHROPIC_AUTH_TOKEN carries a placeholder (the proxy authenticates by tunnel peer and injects the real upstream credentials). A model is never guessed: ANTHROPIC_MODEL is exported only when exactly one model is allowed or --model pins one; anything ambiguous is printed as comment lines instead. "Not available for this peer" is an answer, not an error: both commands exit 0 with a plain message (on stderr for env, keeping the eval a harmless no-op). Linear: NET-1399
42 lines
2.0 KiB
Go
42 lines
2.0 KiB
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
|
|
"github.com/netbirdio/netbird/client/system"
|
|
"github.com/netbirdio/netbird/shared/management/domain"
|
|
"github.com/netbirdio/netbird/shared/management/proto"
|
|
)
|
|
|
|
// Client is the interface for the management service client.
|
|
type Client interface {
|
|
io.Closer
|
|
Sync(ctx context.Context, sysInfo *system.Info, msgHandler func(msg *proto.SyncResponse) error) error
|
|
Job(ctx context.Context, msgHandler func(msg *proto.JobRequest) *proto.JobResponse) error
|
|
Register(setupKey string, jwtToken string, sysInfo *system.Info, sshKey []byte, dnsLabels domain.List) (*proto.LoginResponse, error)
|
|
Login(sysInfo *system.Info, sshKey []byte, dnsLabels domain.List) (*proto.LoginResponse, error)
|
|
// ExtendAuthSession refreshes the peer's SSO session deadline using a fresh JWT.
|
|
// Returns the new absolute deadline; zero time when the server reports the peer
|
|
// is not eligible for session extension.
|
|
ExtendAuthSession(sysInfo *system.Info, jwtToken string) (*proto.ExtendAuthSessionResponse, error)
|
|
GetDeviceAuthorizationFlow() (*proto.DeviceAuthorizationFlow, error)
|
|
GetPKCEAuthorizationFlow() (*proto.PKCEAuthorizationFlow, error)
|
|
GetServerURL() string
|
|
// IsHealthy returns the current connection status without blocking.
|
|
// Used by the engine to monitor connectivity in the background.
|
|
IsHealthy() bool
|
|
// HealthCheck actively probes the management server and returns an error if unreachable.
|
|
// Used to validate connectivity before committing configuration changes.
|
|
HealthCheck() error
|
|
SyncMeta(sysInfo *system.Info) error
|
|
Logout() error
|
|
CreateExpose(ctx context.Context, req ExposeRequest) (*ExposeResponse, error)
|
|
RenewExpose(ctx context.Context, domain string) error
|
|
StopExpose(ctx context.Context, domain string) error
|
|
// GetAgentNetworkSetup returns the Agent Network connection info the
|
|
// calling peer's groups authorize: proxy endpoint plus effective
|
|
// providers and models.
|
|
GetAgentNetworkSetup(ctx context.Context) (*proto.AgentNetworkSetupResponse, error)
|
|
}
|