platformapi

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const PlatformAuthRequiredMessage = "" /* 234-byte string literal not displayed */

PlatformAuthRequiredMessage tells users how to use the platform-backed CLI path.

Variables

This section is empty.

Functions

func AuthRequiredError

func AuthRequiredError(err error) error

AuthRequiredError wraps platform credential errors with user-facing mode guidance.

func HasPlatformClient

func HasPlatformClient() bool

func NormalizeBaseURL

func NormalizeBaseURL(raw string) string

NormalizeBaseURL trims whitespace, trailing slashes, and an optional trailing /api suffix from a platform base URL.

Types

type AdapterCertificate

type AdapterCertificate struct {
	Certificate string    `json:"certificate"`
	CABundle    string    `json:"caBundle"`
	SPIFFEID    string    `json:"spiffeID"`
	ExpiresAt   time.Time `json:"expiresAt"`
}

type AdapterCertificateRequest

type AdapterCertificateRequest struct {
	Namespace string `json:"namespace"`
	Session   string `json:"session"`
	CSR       string `json:"csr"`
}

type AdapterPreflight

type AdapterPreflight struct {
	Ready               bool   `json:"ready"`
	AdapterCertificates bool   `json:"adapterCertificatesEnabled"`
	Issuer              string `json:"issuer,omitempty"`
	IssuerReady         bool   `json:"issuerReady"`
	TrustDomain         string `json:"trustDomain,omitempty"`
	RouteEligible       bool   `json:"routeEligible"`
	RouteReady          bool   `json:"routeReady"`
	Reason              string `json:"reason,omitempty"`
}

type AdapterPreflightRequest

type AdapterPreflightRequest struct {
	ServerName string `json:"serverName"`
	Namespace  string `json:"namespace,omitempty"`
	AgentID    string `json:"agentID"`
}

AdapterPreflightRequest asks whether the selected server is ready for session-bound client-certificate enrollment. It has no side effects.

type AdapterSession

type AdapterSession struct {
	Name           string    `json:"name"`
	Namespace      string    `json:"namespace"`
	HumanID        string    `json:"humanID"`
	AgentID        string    `json:"agentID"`
	TeamID         string    `json:"teamID,omitempty"`
	ServerName     string    `json:"serverName"`
	ConsentedTrust string    `json:"consentedTrust"`
	PolicyVersion  string    `json:"policyVersion"`
	ExpiresAt      time.Time `json:"expiresAt"`
	Reused         bool      `json:"reused"`
	TrustDomain    string    `json:"trustDomain,omitempty"`
}

AdapterSession captures the identity the adapter must inject into runtime requests. ExpiresAt is absolute (server-side time); callers should refresh before it elapses.

type AdapterSessionRequest

type AdapterSessionRequest struct {
	ServerName     string `json:"serverName"`
	Namespace      string `json:"namespace,omitempty"`
	AgentID        string `json:"agentID"`
	RequestedTrust string `json:"requestedTrust,omitempty"`
	RequestedTTL   string `json:"requestedTTL,omitempty"`
}

AdapterSessionRequest is the input contract for the platform API endpoint POST /api/v1/runtime/adapter/sessions. RequestedTTL/Trust are optional; empty values fall back to platform-side defaults.

type Agent

type Agent struct {
	ID        string `json:"id"`
	TeamID    string `json:"team_id"`
	TeamSlug  string `json:"team_slug"`
	Name      string `json:"name"`
	Status    string `json:"status"`
	CreatedAt string `json:"created_at,omitempty"`
	UpdatedAt string `json:"updated_at,omitempty"`
}

type AgentPage

type AgentPage struct {
	Agents     []Agent `json:"agents"`
	NextCursor string  `json:"next_cursor,omitempty"`
}

type ImagePublishRecord

type ImagePublishRecord struct {
	ImageRef    string `json:"image_ref"`
	SourceImage string `json:"source_image,omitempty"`
	Mode        string `json:"mode,omitempty"`
}

type LiveInventory

type LiveInventory struct {
	FetchedAt       string         `json:"fetchedAt"`
	ProtocolVersion string         `json:"protocolVersion,omitempty"`
	Tools           []LiveTool     `json:"tools"`
	Prompts         []LivePrompt   `json:"prompts"`
	Resources       []LiveResource `json:"resources"`
	// Extensions are the protocol extensions the server advertised, keyed by
	// identifier, with their settings.
	Extensions map[string]json.RawMessage `json:"extensions,omitempty"`
}

LiveInventory is the latest tools/list, prompts/list and resources/list result observed by the platform runtime API. It is cached and may be absent until the first probe completes.

type LivePrompt

type LivePrompt struct {
	Name        string               `json:"name"`
	Description string               `json:"description,omitempty"`
	Arguments   []LivePromptArgument `json:"arguments,omitempty"`
}

type LivePromptArgument

type LivePromptArgument struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Required    bool   `json:"required,omitempty"`
}

type LiveResource

type LiveResource struct {
	URI         string `json:"uri,omitempty"`
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	MIMEType    string `json:"mimeType,omitempty"`
}

type LiveTool

type LiveTool struct {
	Name        string          `json:"name"`
	Description string          `json:"description,omitempty"`
	InputSchema json.RawMessage `json:"inputSchema,omitempty"`
}

type PlatformClient

type PlatformClient struct {
	// contains filtered or unexported fields
}

PlatformClient calls the platform API with an API key.

func NewCredentialClient

func NewCredentialClient(baseURL, token string) (*PlatformClient, error)

NewCredentialClient binds a client to one explicitly selected identity. Unlike NewPlatformClient it never reads or changes process-wide login selection.

func NewPlatformClient

func NewPlatformClient() (*PlatformClient, error)

NewPlatformClient returns a client when platform credentials and API base URL are configured. If the user is not logged in, returns authfile.ErrNotFound.

func NewPlatformClientWithAPIKey

func NewPlatformClientWithAPIKey(baseURL, apiKey string) (*PlatformClient, error)

NewPlatformClientWithAPIKey returns a client for setup-time administration that authenticates with a cluster-held service key instead of a CLI login. The base URL must be an HTTPS origin without credentials, query, or fragment.

func ResolvePlatformOrKube

func ResolvePlatformOrKube(useKube bool) (*PlatformClient, bool, error)

ResolvePlatformOrKube returns direct Kubernetes mode only when useKube is explicit. Otherwise it requires platform API credentials and does not fall back to kubeconfig.

func (*PlatformClient) ApplyAccessFromYAMLFile

func (c *PlatformClient) ApplyAccessFromYAMLFile(ctx context.Context, path string) error

func (*PlatformClient) ApplyRuntimeServer

func (c *PlatformClient) ApplyRuntimeServer(ctx context.Context, name, namespace string, spec mcpv1alpha1.MCPServerSpec) (ServerListItem, error)

func (*PlatformClient) ApplyRuntimeServerWithScope

func (c *PlatformClient) ApplyRuntimeServerWithScope(ctx context.Context, name, namespace, scope string, spec mcpv1alpha1.MCPServerSpec) (ServerListItem, error)

func (*PlatformClient) ApplyRuntimeServerWithScopeUpdate

func (c *PlatformClient) ApplyRuntimeServerWithScopeUpdate(ctx context.Context, name, namespace, scope string, spec mcpv1alpha1.MCPServerSpec, update bool) (ServerListItem, error)

func (*PlatformClient) CheckRegistryAdmin

func (c *PlatformClient) CheckRegistryAdmin(ctx context.Context) error

func (*PlatformClient) CleanupAdapterSession

func (c *PlatformClient) CleanupAdapterSession(ctx context.Context, namespace, session string) error

CleanupAdapterSession deletes a newly-created, still-pending enrollment session after certificate issuance fails. The server verifies ownership and refuses to delete reused or completed sessions.

func (*PlatformClient) CreateAdapterSession

func (c *PlatformClient) CreateAdapterSession(ctx context.Context, req AdapterSessionRequest) (AdapterSession, error)

CreateAdapterSession asks the platform to issue (or reuse) an MCPAgentSession for the calling principal. The returned session.Name doubles as the SessionID the adapter forwards on every runtime request.

func (*PlatformClient) CreateAgent

func (c *PlatformClient) CreateAgent(ctx context.Context, teamSlug, name string) (Agent, error)

func (*PlatformClient) CreateRegistryPullCredential

func (c *PlatformClient) CreateRegistryPullCredential(ctx context.Context, scope registryauth.PullScope) (RegistryPullCredential, error)

func (*PlatformClient) CreateTeam

func (c *PlatformClient) CreateTeam(ctx context.Context, slug, name string) (Team, error)

func (*PlatformClient) CreateTeamUser

func (c *PlatformClient) CreateTeamUser(ctx context.Context, slug, email, password, role string) (TeamMembership, error)

func (*PlatformClient) CreateUser

func (c *PlatformClient) CreateUser(ctx context.Context, email, password, role string) (PlatformUser, error)

func (*PlatformClient) CredentialMetadata

func (c *PlatformClient) CredentialMetadata(ctx context.Context, method, namespace, kind, name string, body json.RawMessage, revision int64) (json.RawMessage, error)

func (*PlatformClient) CurrentPrincipal

func (c *PlatformClient) CurrentPrincipal(ctx context.Context) (Principal, error)

func (*PlatformClient) DeactivateUser

func (c *PlatformClient) DeactivateUser(ctx context.Context, userID string) (apikit.UserDeactivationResult, error)

func (*PlatformClient) DeleteGrant

func (c *PlatformClient) DeleteGrant(ctx context.Context, namespace, name string) error

func (*PlatformClient) DeleteRuntimeServer

func (c *PlatformClient) DeleteRuntimeServer(ctx context.Context, namespace, name string) error

func (*PlatformClient) DeleteSession

func (c *PlatformClient) DeleteSession(ctx context.Context, namespace, name string) error

func (*PlatformClient) DeleteTeamMember

func (c *PlatformClient) DeleteTeamMember(ctx context.Context, slug, userID string) error

func (*PlatformClient) GetAgent

func (c *PlatformClient) GetAgent(ctx context.Context, id string) (Agent, error)

func (*PlatformClient) GetGrant

func (c *PlatformClient) GetGrant(ctx context.Context, namespace, name string) (mcpaccess.GrantSummary, error)

func (*PlatformClient) GetRuntimePolicy

func (c *PlatformClient) GetRuntimePolicy(ctx context.Context, namespace, server string) ([]byte, error)

func (*PlatformClient) GetRuntimeServer

func (c *PlatformClient) GetRuntimeServer(ctx context.Context, namespace, name string) (ServerListItem, error)

GetRuntimeServer returns one server with its runtime inventory and scoped last-session observation when the caller may inspect server activity.

func (*PlatformClient) GetSession

func (c *PlatformClient) GetSession(ctx context.Context, namespace, name string) (mcpaccess.SessionSummary, error)

func (*PlatformClient) GetTeam

func (c *PlatformClient) GetTeam(ctx context.Context, slug string) (Team, error)

func (*PlatformClient) IssueAdapterCertificate

func (c *PlatformClient) IssueAdapterCertificate(ctx context.Context, req AdapterCertificateRequest) (AdapterCertificate, error)

func (*PlatformClient) ListAgents

func (c *PlatformClient) ListAgents(ctx context.Context, teamSlug, status, query, cursor string, limit int) (AgentPage, error)

func (*PlatformClient) ListGrants

func (c *PlatformClient) ListGrants(ctx context.Context, namespace string) ([]mcpaccess.GrantSummary, error)

func (*PlatformClient) ListNamespaces

func (c *PlatformClient) ListNamespaces(ctx context.Context) ([]namespaceListItem, error)

func (*PlatformClient) ListRuntimeServers

func (c *PlatformClient) ListRuntimeServers(ctx context.Context, namespace string) ([]ServerListItem, error)

func (*PlatformClient) ListRuntimeTools

func (c *PlatformClient) ListRuntimeTools(ctx context.Context, filters map[string]string) ([]RuntimeToolRow, error)

func (*PlatformClient) ListSessions

func (c *PlatformClient) ListSessions(ctx context.Context, namespace string) ([]mcpaccess.SessionSummary, error)

func (*PlatformClient) ListTeamMembers

func (c *PlatformClient) ListTeamMembers(ctx context.Context, slug string) ([]TeamMembership, error)

func (*PlatformClient) ListTeams

func (c *PlatformClient) ListTeams(ctx context.Context) ([]Team, error)

func (*PlatformClient) PatchGrant

func (c *PlatformClient) PatchGrant(ctx context.Context, namespace, name string, disabled bool) error

func (*PlatformClient) PatchSession

func (c *PlatformClient) PatchSession(ctx context.Context, namespace, name string, revoked bool) error

func (*PlatformClient) PreflightAdapter

func (*PlatformClient) PushRegistryImage

func (c *PlatformClient) PushRegistryImage(ctx context.Context, tarPath, target, scope string) error

PushRegistryImage uploads a docker save tar and asks the platform API to push it to the configured registry from inside the cluster.

func (*PlatformClient) RecordImagePublish

func (c *PlatformClient) RecordImagePublish(ctx context.Context, record ImagePublishRecord) error

func (*PlatformClient) RenameAgent

func (c *PlatformClient) RenameAgent(ctx context.Context, id, name string) (Agent, error)

func (*PlatformClient) RevokeGrantSessions

func (c *PlatformClient) RevokeGrantSessions(ctx context.Context, namespace, name string) (int, error)

func (*PlatformClient) SetAgentActive

func (c *PlatformClient) SetAgentActive(ctx context.Context, id string, active bool) (Agent, error)

func (*PlatformClient) UpsertTeamMember

func (c *PlatformClient) UpsertTeamMember(ctx context.Context, slug, userID, role string) (TeamMembership, error)

func (*PlatformClient) ValidateCredentials

func (c *PlatformClient) ValidateCredentials(ctx context.Context) error

func (*PlatformClient) WaitRegistryAdminReady

func (c *PlatformClient) WaitRegistryAdminReady(ctx context.Context, onRetry func(reason string)) error

WaitRegistryAdminReady polls the registry administration preflight until it succeeds registryReadyStreak times in a row. Ingress gateway errors (502, 503, 504) and transport failures are transient right after a platform-api rollout and restart the streak; any other unexpected status (401, 403, 404) fails immediately. Credential creation is deliberately not retried: every POST mints a new credential, so an ambiguous failure could orphan one. onRetry, when non-nil, is told why the wait continues.

type PlatformUser

type PlatformUser struct {
	ID        string `json:"id"`
	Email     string `json:"email"`
	Role      string `json:"role"`
	Namespace string `json:"namespace,omitempty"`
}

type Principal

type Principal struct {
	Role              string   `json:"role"`
	Subject           string   `json:"subject,omitempty"`
	Email             string   `json:"email,omitempty"`
	Namespace         string   `json:"namespace,omitempty"`
	AllowedNamespaces []string `json:"allowedNamespaces,omitempty"`
	Teams             []Team   `json:"teams,omitempty"`
}

type RegistryPullCredential

type RegistryPullCredential struct {
	ID        string    `json:"id"`
	Username  string    `json:"username"`
	Password  string    `json:"password"`
	ExpiresAt time.Time `json:"expires_at"`
}

type RuntimeToolRow

type RuntimeToolRow struct {
	ToolName      string            `json:"tool_name"`
	Description   string            `json:"description,omitempty"`
	ServerName    string            `json:"server_name"`
	Namespace     string            `json:"namespace"`
	TeamID        string            `json:"team_id,omitempty"`
	EndpointURL   string            `json:"endpoint_url,omitempty"`
	Declared      bool              `json:"declared"`
	Live          bool              `json:"live"`
	DriftStatus   string            `json:"drift_status"`
	RequiredTrust string            `json:"required_trust,omitempty"`
	SideEffect    string            `json:"side_effect,omitempty"`
	RiskLevel     string            `json:"risk_level,omitempty"`
	Labels        map[string]string `json:"labels,omitempty"`
	ConnectConfig map[string]any    `json:"connect_config,omitempty"`
}

type ServerListItem

type ServerListItem struct {
	Name               string                           `json:"name"`
	Namespace          string                           `json:"namespace"`
	UID                string                           `json:"uid,omitempty"`
	TeamID             string                           `json:"team_id,omitempty"`
	Image              string                           `json:"image,omitempty"`
	ImageTag           string                           `json:"imageTag,omitempty"`
	Description        string                           `json:"description,omitempty"`
	Ready              string                           `json:"ready"`
	Status             string                           `json:"status"`
	Message            string                           `json:"message,omitempty"`
	Conditions         []metav1.Condition               `json:"conditions,omitempty"`
	Generation         int64                            `json:"generation,omitempty"`
	Labels             map[string]string                `json:"labels"`
	Age                string                           `json:"age"`
	Endpoint           string                           `json:"endpoint,omitempty"`
	AuthMode           string                           `json:"authMode,omitempty"`
	AuthHeaders        []string                         `json:"authHeaders,omitempty"`
	CredentialPresence string                           `json:"credentialPresence,omitempty"`
	GatewayEnabled     bool                             `json:"gatewayEnabled"`
	ServicePort        int32                            `json:"servicePort,omitempty"`
	Tools              []ToolConfig                     `json:"tools,omitempty"`
	Prompts            []mcpv1alpha1.InventoryItem      `json:"prompts,omitempty"`
	Resources          []mcpv1alpha1.InventoryItem      `json:"resources,omitempty"`
	Tasks              []mcpv1alpha1.InventoryItem      `json:"tasks,omitempty"`
	LiveInventory      *LiveInventory                   `json:"liveInventory,omitempty"`
	LiveInventoryError string                           `json:"liveInventoryError,omitempty"`
	AccessJSON         map[string]any                   `json:"access_json,omitempty"`
	RuntimeStatus      controlplane.ServerRuntimeStatus `json:"runtimeStatus"`
	Egress             *controlplane.ServerEgressInfo   `json:"egress,omitempty"`
}

ServerListItem is one row from the platform API runtime servers list.

type Team

type Team struct {
	ID        string    `json:"id"`
	Slug      string    `json:"slug"`
	Name      string    `json:"name"`
	Namespace string    `json:"namespace"`
	CreatedAt time.Time `json:"created_at"`
}

type TeamMembership

type TeamMembership = apikit.TeamMembership

type ToolConfig

type ToolConfig struct {
	Name          string            `json:"name"`
	Description   string            `json:"description,omitempty"`
	RequiredTrust string            `json:"requiredTrust,omitempty"`
	SideEffect    string            `json:"sideEffect,omitempty"`
	RiskLevel     string            `json:"riskLevel,omitempty"`
	Labels        map[string]string `json:"labels,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL