Documentation
¶
Overview ¶
Package client provides a stateless HTTP and Server-Sent Events (SSE) client for communicating with the TaskSmith Brain Daemon over a Unix domain socket.
Session Operations ¶
Sessions support conversation turns and timeline inspection:
- Client.Send: submits user messages to `/v1/sessions/{id}/send`, triggering conversational turns in the background runtime.
- Client.Timeline: retrieves chronological session timeline entries (api.TimelineEntry) via `GET /v1/sessions/{id}/timeline`.
- Client.Cancel, and file mutation journal methods (Client.Changes, Client.DiffChange, Client.Revert).
MCP Server Operations ¶
Configured MCP servers are inspected and driven through the workspace-scoped `/v1/workspace/mcps` routes:
- Client.ListMCPs: lists each server's resolved transport, live status, and discovered tools, prompts, and resources (api.MCPServer).
- Client.RestartMCP and Client.AuthenticateMCP: reconnect a server or start its interactive authorization flow.
- Client.GetMCPPrompt and Client.ReadMCPResource: render a prompt or read a resource; items blocked by a server manifest's policies are rejected unless the request opts into a single user-authorized use.
- Client.AllowMCPPolicy: permit a blocked item by updating the manifest.
Real-Time Server-Sent Events (SSE) ¶
Clients stream typed real-time notifications (api.Event) from the daemon's internal event broker:
- Client.Events and Client.EventsWithReady: open a real-time SSE stream for arbitrary broker topics, supporting optional subscriber identity (api.HeaderSubscriberID) and receiving the assigned subscriber ID.
- Client.Subscribe and Client.Unsubscribe: dynamically adjust active subscriptions for a running SSE connection via `/v1/events/subscribe` and `/v1/events/unsubscribe`.
All SSE streams yield structured api.Event values whose typed payloads satisfy api.EventPayload.
Daemon Lifecycle ¶
Go consumers drive the whole daemon lifecycle through this package:
- ConnectOrStart: connect to a running daemon or spawn a detached one and wait for it to become healthy, surfacing version-skew as notices.
- SpawnDetached, WaitForSocketHealthy, WaitForSocketLockRelease, and the path helpers DefaultSocketPath, DefaultLockPath, and LockPathForSocket compose the same startup flow the `tasksmith` CLI uses.
This package depends on github.com/masterkeysrd/tasksmith/api, the Go standard library, and dependency-light shared utilities under `internal/core` (system, path, and version helpers), maintaining strict separation from the daemon and engine packages.
Index ¶
- Variables
- func DaemonVersionSkewed(h *api.HealthResponse) bool
- func DefaultLockPath() (string, error)
- func DefaultSocketPath() (string, error)
- func HasActiveSessions(sessions []api.Session) bool
- func IsCapabilityMismatch(err error) (*api.APIError, bool)
- func IsDaemonHealthy(ctx context.Context, c *Client) bool
- func IsNeedSync(err error) bool
- func LockPathForSocket(socketPath string) string
- func NewCursor() string
- func SpawnLogHint() string
- func WaitForSocketHealthy(ctx context.Context, socketPath string, spawned *SpawnedDaemon, ...) (*api.HealthResponse, error)
- func WaitForSocketLockRelease(ctx context.Context, socketPath string) error
- type Client
- func (c *Client) AddPermissionRule(ctx context.Context, req api.PermissionRuleRequest) (*api.PermissionsResponse, error)
- func (c *Client) AllowMCPPolicy(ctx context.Context, server string, req api.MCPAllowPolicyRequest) (api.MCPServer, error)
- func (c *Client) AssignModelAliases(ctx context.Context, req api.AssignModelAliasesRequest) (api.AssignModelAliasesResponse, error)
- func (c *Client) AuthenticateMCP(ctx context.Context, name string) (api.MCPAuthResponse, error)
- func (c *Client) CWD() string
- func (c *Client) Cancel(ctx context.Context, sessionID string) error
- func (c *Client) Changes(ctx context.Context, sessionID string) ([]api.FileChange, error)
- func (c *Client) CompleteMCPAuth(ctx context.Context, name string, req api.MCPAuthCallbackRequest) error
- func (c *Client) CompleteProviderAuth(ctx context.Context, provider string, req api.ProviderAuthCallbackRequest) (*api.ProviderAuthResponse, error)
- func (c *Client) CreateProvider(ctx context.Context, req api.CreateProviderRequest) (api.WorkspaceProvider, error)
- func (c *Client) CreateSession(ctx context.Context, req api.CreateSessionRequest) (*api.Session, error)
- func (c *Client) DeleteSession(ctx context.Context, sessionID string) error
- func (c *Client) DiffChange(ctx context.Context, sessionID, filePath, entryID string) (string, error)
- func (c *Client) Events(ctx context.Context, subscriberID, since string, topics ...string) iter.Seq2[api.Event, error]
- func (c *Client) EventsWithReady(ctx context.Context, subscriberID, since string, ...) iter.Seq2[api.Event, error]
- func (c *Client) ForkSession(ctx context.Context, sessionID string, req api.ForkSessionRequest) (*api.Session, error)
- func (c *Client) GetAgent(ctx context.Context, name string) (*api.Agent, error)
- func (c *Client) GetCommand(ctx context.Context, name string) (*api.Command, error)
- func (c *Client) GetMCPPrompt(ctx context.Context, server, prompt string, req api.MCPPromptRequest) (api.MCPPromptResponse, error)
- func (c *Client) GetModel(ctx context.Context, id string) (*api.Model, error)
- func (c *Client) GetModelQuota(ctx context.Context, model string) (*api.ModelQuota, error)
- func (c *Client) GetProviderAuthStatus(ctx context.Context, provider string) (*api.ProviderAuthResponse, error)
- func (c *Client) GetQuotaSnapshots(ctx context.Context) (*api.QuotaSnapshotResponse, error)
- func (c *Client) GetSandbox(ctx context.Context) (*api.SandboxResponse, error)
- func (c *Client) GetSession(ctx context.Context, sessionID string) (*api.Session, error)
- func (c *Client) GetSkill(ctx context.Context, name string) (*api.Skill, error)
- func (c *Client) GetTrustStatus(ctx context.Context) (*api.TrustStatus, error)
- func (c *Client) GetWorkspace(ctx context.Context) (*api.Workspace, error)
- func (c *Client) GetWorkspaceStatus(ctx context.Context) (*api.WorkspaceStatus, error)
- func (c *Client) Health(ctx context.Context) (*api.HealthResponse, error)
- func (c *Client) InitWorkspace(ctx context.Context, req api.InitWorkspaceRequest) error
- func (c *Client) InitWorkspaceWithResult(ctx context.Context, req api.InitWorkspaceRequest) (api.InitWorkspaceResponse, error)
- func (c *Client) KillTask(ctx context.Context, sessionID, taskID string) error
- func (c *Client) LatestSession(ctx context.Context) (*api.Session, error)
- func (c *Client) ListAgents(ctx context.Context) ([]api.Agent, error)
- func (c *Client) ListAliasAssignments(ctx context.Context) ([]api.AliasAssignment, error)
- func (c *Client) ListCommands(ctx context.Context) ([]api.Command, error)
- func (c *Client) ListMCPs(ctx context.Context) ([]api.MCPServer, error)
- func (c *Client) ListModels(ctx context.Context) ([]api.Model, error)
- func (c *Client) ListProviderCatalog(ctx context.Context, name string) ([]api.ProviderCatalogEntry, error)
- func (c *Client) ListProviders(ctx context.Context) ([]api.ProviderSummary, error)
- func (c *Client) ListRules(ctx context.Context) ([]api.Rule, error)
- func (c *Client) ListSessions(ctx context.Context) ([]api.Session, error)
- func (c *Client) ListSkills(ctx context.Context) ([]api.Skill, error)
- func (c *Client) ListTools(ctx context.Context, agent string) ([]api.Tool, error)
- func (c *Client) ListWorkspaceFiles(ctx context.Context, req api.ListFilesRequest) ([]api.WorkspaceFile, error)
- func (c *Client) ListWorkspaceProviders(ctx context.Context) ([]api.WorkspaceProvider, error)
- func (c *Client) LogoutProviderAuth(ctx context.Context, provider string) (*api.ProviderAuthResponse, error)
- func (c *Client) Permissions(ctx context.Context) (*api.PermissionsResponse, error)
- func (c *Client) PreviewSession(ctx context.Context, req api.PreviewSessionRequest) (*api.SessionPreview, error)
- func (c *Client) QueryMetrics(ctx context.Context, q api.MetricsQuery) (api.MetricsResult, error)
- func (c *Client) ReadMCPResource(ctx context.Context, server string, req api.MCPResourceRequest) (api.MCPResourceResponse, error)
- func (c *Client) ReloadWorkspace(ctx context.Context) error
- func (c *Client) RemovePermissionRule(ctx context.Context, req api.PermissionRuleRequest) (*api.PermissionsResponse, error)
- func (c *Client) RestartMCP(ctx context.Context, name string) (api.MCPServer, error)
- func (c *Client) Revert(ctx context.Context, sessionID string, req api.RevertRequest) error
- func (c *Client) RevokeTrust(ctx context.Context) error
- func (c *Client) Send(ctx context.Context, sessionID string, req api.SendRequest) error
- func (c *Client) SessionUsage(ctx context.Context, sessionID string) (api.SessionUsage, error)
- func (c *Client) SetMCPEnabled(ctx context.Context, name string, enabled bool) ([]api.MCPServer, error)
- func (c *Client) SetProviderEnabled(ctx context.Context, name string, enabled bool) ([]api.WorkspaceProvider, error)
- func (c *Client) SetToolEnabled(ctx context.Context, name string, enabled bool) ([]api.Tool, error)
- func (c *Client) Shutdown(ctx context.Context) error
- func (c *Client) SocketPath() string
- func (c *Client) StartProviderAuth(ctx context.Context, provider string) (*api.ProviderAuthResponse, error)
- func (c *Client) StreamTaskOutput(ctx context.Context, sessionID, taskID string) iter.Seq2[string, error]
- func (c *Client) Subscribe(ctx context.Context, subscriberID, since string, topics ...string) (*api.SubscriptionResponse, error)
- func (c *Client) Tasks(ctx context.Context, sessionID string) ([]api.Task, error)
- func (c *Client) Timeline(ctx context.Context, sessionID string) ([]api.TimelineEntry, error)
- func (c *Client) TrustWorkspace(ctx context.Context, scope string) error
- func (c *Client) Unsubscribe(ctx context.Context, subscriberID string, topics ...string) (*api.SubscriptionResponse, error)
- func (c *Client) UpdateProviderModels(ctx context.Context, name string, req api.UpdateProviderModelsRequest) ([]api.WorkspaceProvider, error)
- func (c *Client) UpdateSandbox(ctx context.Context, req api.UpdateSandboxRequest) (*api.SandboxResponse, error)
- func (c *Client) UpdateSession(ctx context.Context, sessionID string, req api.UpdateSessionRequest) (*api.Session, error)
- func (c *Client) UploadMedia(ctx context.Context, sessionID string, data []byte, mimeType, filename string) (*api.Media, error)
- func (c *Client) Usage(ctx context.Context, req api.UsageRequest) (api.UsageSummary, error)
- func (c *Client) VerifyProvider(ctx context.Context, req api.VerifyProviderRequest) (*api.VerifyProviderResponse, error)
- func (c *Client) Watch(ctx context.Context, since string, topics ...string) iter.Seq2[api.Event, error]
- func (c *Client) WithCWD(cwd string) *Client
- type Option
- type SpawnedDaemon
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidSocketPath = errors.New("client: socket path must not be empty") ErrEmptyWorkspace = errors.New("client: workspace path must not be empty") ErrEmptyCWD = ErrEmptyWorkspace ErrEmptySessionID = errors.New("client: session ID must not be empty") ErrEmptySubscriberID = errors.New("client: subscriber ID must not be empty") ErrNeedSync = errors.New("client: stream out of sync") ErrSSEIdle = errors.New("client: sse stream idle") )
Sentinel errors returned by the client package.
var SpawnWaitTimeout = 15 * time.Second
SpawnWaitTimeout bounds how long ConnectOrStart waits for a freshly spawned daemon to become healthy. It is a var so tests can shorten the bound.
Functions ¶
func DaemonVersionSkewed ¶
func DaemonVersionSkewed(h *api.HealthResponse) bool
DaemonVersionSkewed reports whether a healthy daemon's build version differs from this client's. Daemons that predate version reporting are treated as skewed so they get upgraded on the next client launch.
func DefaultLockPath ¶
DefaultLockPath returns the default XDG runtime lockfile path ("brain.lock") paired with DefaultSocketPath.
func DefaultSocketPath ¶
DefaultSocketPath returns the default XDG runtime Unix domain socket path ("brain.sock") the daemon serves.
func HasActiveSessions ¶
HasActiveSessions reports whether any session on the daemon is doing work that a restart would interrupt.
func IsCapabilityMismatch ¶
IsCapabilityMismatch reports whether err is a structured capability-mismatch error returned when switching models drops active session modalities.
func IsDaemonHealthy ¶
IsDaemonHealthy reports whether the daemon answers a bounded health ping.
func IsNeedSync ¶
IsNeedSync reports whether err represents a stream cursor desync requiring a full snapshot reload.
func LockPathForSocket ¶
LockPathForSocket returns the lockfile path paired with a socket path: the same directory and base name with a ".lock" extension. A socket that does not end in ".sock" gets ".lock" appended.
func NewCursor ¶
func NewCursor() string
NewCursor returns a fresh canonical UUIDv7 string cursor for event streaming.
func SpawnLogHint ¶
func SpawnLogHint() string
SpawnLogHint returns the daemon log directory for user-facing error messages, falling back to the documented default when it cannot be resolved.
func WaitForSocketHealthy ¶
func WaitForSocketHealthy(ctx context.Context, socketPath string, spawned *SpawnedDaemon, timeout time.Duration, health func(context.Context) (*api.HealthResponse, error)) (*api.HealthResponse, error)
WaitForSocketHealthy polls a health probe against a freshly spawned daemon until it answers, the spawned child exits (surfacing the failure immediately with a pointer to the daemon logs), or timeout elapses. health is injected so callers own their client plumbing without this package depending on the HTTP client; it returns the daemon's health payload when the probe succeeds (may be nil for callers that only track liveness).
func WaitForSocketLockRelease ¶
WaitForSocketLockRelease blocks until the lock paired with socketPath is free (the previous daemon finished teardown). It returns nil immediately when no lock file exists, and a timeout error when the holder never releases; the spawned daemon's own retry window may still recover such a handoff.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client communicates with the TaskSmith Brain Daemon over a Unix domain socket.
func ConnectOrStart ¶
func ConnectOrStart(ctx context.Context, socketPath string, spawnArgs ...string) (*Client, []string, error)
ConnectOrStart connects to an existing Brain Daemon at socketPath, or spawns a detached background daemon process (`os.Executable() daemon serve --socket <socketPath>`) and polls `/v1/health` until ready. An empty socketPath selects DefaultSocketPath.
When the running daemon was built from a different version than this client, ConnectOrStart restarts it only once every session is confirmed idle. In any other case — an active session or an unknown session state — the existing daemon is kept and the skew is returned as a user-facing notice so callers can surface it in their own UI; the user then restarts the daemon when it is safe instead of having work interrupted.
func (*Client) AddPermissionRule ¶
func (c *Client) AddPermissionRule(ctx context.Context, req api.PermissionRuleRequest) (*api.PermissionsResponse, error)
AddPermissionRule appends an allow or deny rule to project or global permissions.
func (*Client) AllowMCPPolicy ¶
func (c *Client) AllowMCPPolicy(ctx context.Context, server string, req api.MCPAllowPolicyRequest) (api.MCPServer, error)
AllowMCPPolicy updates the named server's manifest on disk so req.Value is permitted, reloads the server, and returns the updated state.
func (*Client) AssignModelAliases ¶
func (c *Client) AssignModelAliases(ctx context.Context, req api.AssignModelAliasesRequest) (api.AssignModelAliasesResponse, error)
AssignModelAliases binds req.Aliases to the named provider model. Aliases currently held by other models are moved atomically before the assignment is saved.
func (*Client) AuthenticateMCP ¶
AuthenticateMCP starts or resumes the interactive authorization flow for the named MCP server and returns the URL the user should open in a browser.
func (*Client) CompleteMCPAuth ¶
func (c *Client) CompleteMCPAuth(ctx context.Context, name string, req api.MCPAuthCallbackRequest) error
CompleteMCPAuth hands a redirect URL copied from the user's browser to the authorization flow in progress for the named MCP server. It is the fallback for browsers that cannot reach the daemon's loopback callback listener.
func (*Client) CompleteProviderAuth ¶
func (c *Client) CompleteProviderAuth(ctx context.Context, provider string, req api.ProviderAuthCallbackRequest) (*api.ProviderAuthResponse, error)
CompleteProviderAuth finishes an in-flight provider OAuth flow with a callback URL the user copied from their browser.
func (*Client) CreateProvider ¶
func (c *Client) CreateProvider(ctx context.Context, req api.CreateProviderRequest) (api.WorkspaceProvider, error)
CreateProvider writes a new provider manifest to the requested scope, stores any API key in the scope's .env file, reloads the workspace, and returns the created provider.
func (*Client) CreateSession ¶
func (c *Client) CreateSession(ctx context.Context, req api.CreateSessionRequest) (*api.Session, error)
CreateSession creates a new session in workspace.
func (*Client) DeleteSession ¶
DeleteSession deletes a session and its associated history and change journals.
func (*Client) DiffChange ¶
func (c *Client) DiffChange(ctx context.Context, sessionID, filePath, entryID string) (string, error)
DiffChange computes the unified diff for a specific journal entry on a path.
func (*Client) Events ¶
func (c *Client) Events(ctx context.Context, subscriberID, since string, topics ...string) iter.Seq2[api.Event, error]
Events opens a real-time Server-Sent Events (SSE) stream with optional subscriberID, since cursor, and initial topics.
func (*Client) EventsWithReady ¶
func (c *Client) EventsWithReady(ctx context.Context, subscriberID, since string, ready func(subscriberID string), topics ...string) iter.Seq2[api.Event, error]
EventsWithReady opens an SSE stream and invokes ready with the server-assigned (or echoed) subscriber ID once connected.
func (*Client) ForkSession ¶
func (c *Client) ForkSession(ctx context.Context, sessionID string, req api.ForkSessionRequest) (*api.Session, error)
ForkSession branches an existing session into a new top-level session that starts from the source's full conversation. An empty title derives one from the source session's title.
func (*Client) GetCommand ¶
GetCommand retrieves a command resource by name.
func (*Client) GetMCPPrompt ¶
func (c *Client) GetMCPPrompt(ctx context.Context, server, prompt string, req api.MCPPromptRequest) (api.MCPPromptResponse, error)
GetMCPPrompt renders a prompt discovered on an MCP server. Prohibited prompts are rejected by the daemon unless req.AllowProhibited is set.
func (*Client) GetModel ¶
GetModel retrieves a model by ID or qualified identifier (e.g. "ollama/qwen3.8").
func (*Client) GetModelQuota ¶
GetModelQuota reports the remaining quota for a quota-billed model. It returns (nil, nil) when the model's provider does not report quotas.
func (*Client) GetProviderAuthStatus ¶
func (c *Client) GetProviderAuthStatus(ctx context.Context, provider string) (*api.ProviderAuthResponse, error)
GetProviderAuthStatus checks the status of an ongoing or completed interactive OAuth flow.
func (*Client) GetQuotaSnapshots ¶
GetQuotaSnapshots returns the multi-bucket quota snapshots across all quota-capable providers in the workspace.
func (*Client) GetSandbox ¶
GetSandbox retrieves the workspace's sandbox posture: stored sandbox.json scopes, their effective merge, host kernel backend diagnostics, and the resolved path rules.
func (*Client) GetSession ¶
GetSession retrieves session metadata and live status by ID.
func (*Client) GetTrustStatus ¶
GetTrustStatus checks the trust and executable configuration status for the workspace.
func (*Client) GetWorkspace ¶
GetWorkspace retrieves the resolved configuration metadata for the workspace.
func (*Client) GetWorkspaceStatus ¶
GetWorkspaceStatus returns the onboarding, trust, and configuration status of the workspace.
func (*Client) InitWorkspace ¶
InitWorkspace initializes a workspace according to req.
func (*Client) InitWorkspaceWithResult ¶
func (c *Client) InitWorkspaceWithResult(ctx context.Context, req api.InitWorkspaceRequest) (api.InitWorkspaceResponse, error)
func (*Client) LatestSession ¶
LatestSession returns the workspace's most recently updated top-level session without hydrating any session runtime, backing quick resume (`-c` / `--continue`). It returns (nil, nil) when the workspace has no sessions.
func (*Client) ListAgents ¶
ListAgents returns all effective agents in the workspace scope.
func (*Client) ListAliasAssignments ¶
ListAliasAssignments returns the current standard and custom model alias assignments across all configured providers, flagging duplicates.
func (*Client) ListCommands ¶
ListCommands returns all effective command resources in the workspace.
func (*Client) ListMCPs ¶
ListMCPs returns every MCP server configured in the workspace sorted by name, including each server's live connection status and the tools, prompts, and resources discovered on it. Items blocked by a server manifest's policies are included with Allowed set to false.
func (*Client) ListModels ¶
ListModels returns all resolved models across providers in the workspace.
func (*Client) ListProviderCatalog ¶
func (c *Client) ListProviderCatalog(ctx context.Context, name string) ([]api.ProviderCatalogEntry, error)
ListProviderCatalog returns the models the named configured provider can offer, sourced from its static or live catalog when available.
func (*Client) ListProviders ¶
ListProviders returns the built-in provider presets with their current credential availability.
func (*Client) ListSessions ¶
ListSessions lists all sessions in workspace ordered by most recently updated.
func (*Client) ListSkills ¶
ListSkills returns all effective skill resources in the workspace.
func (*Client) ListTools ¶
ListTools returns all effective built-in and custom tool resources in the workspace. When agent is not empty, each tool's Status is classified for that agent (eager, deferred, denied, or inactive).
func (*Client) ListWorkspaceFiles ¶
func (c *Client) ListWorkspaceFiles(ctx context.Context, req api.ListFilesRequest) ([]api.WorkspaceFile, error)
ListWorkspaceFiles lists and searches files and directories in the workspace.
func (*Client) ListWorkspaceProviders ¶
ListWorkspaceProviders returns every configured model provider across the user and workspace scopes, with each provider's manifest path, enablement, auth availability, and declared models.
func (*Client) LogoutProviderAuth ¶
func (c *Client) LogoutProviderAuth(ctx context.Context, provider string) (*api.ProviderAuthResponse, error)
LogoutProviderAuth cancels any in-flight OAuth flow for provider and removes its persisted credentials.
func (*Client) Permissions ¶
Permissions retrieves configured project and global permission rules.
func (*Client) PreviewSession ¶
func (c *Client) PreviewSession(ctx context.Context, req api.PreviewSessionRequest) (*api.SessionPreview, error)
PreviewSession resolves a proposed draft session configuration without creating it.
func (*Client) QueryMetrics ¶
func (c *Client) QueryMetrics(ctx context.Context, q api.MetricsQuery) (api.MetricsResult, error)
QueryMetrics runs a generic metrics query.
func (*Client) ReadMCPResource ¶
func (c *Client) ReadMCPResource(ctx context.Context, server string, req api.MCPResourceRequest) (api.MCPResourceResponse, error)
ReadMCPResource reads a resource URI from an MCP server. Prohibited resources are rejected by the daemon unless req.AllowProhibited is set.
func (*Client) ReloadWorkspace ¶
ReloadWorkspace requests the daemon to reload workspace resources from disk.
func (*Client) RemovePermissionRule ¶
func (c *Client) RemovePermissionRule(ctx context.Context, req api.PermissionRuleRequest) (*api.PermissionsResponse, error)
RemovePermissionRule deletes a rule from project or global permissions.
func (*Client) RestartMCP ¶
RestartMCP reconnects the named MCP server and re-discovers its tools, prompts, and resources, returning the updated server state.
func (*Client) Revert ¶
Revert reverts a single journal entry, a single file to baseline, or all tracked files in the session.
func (*Client) RevokeTrust ¶
RevokeTrust removes the workspace from the trust store.
func (*Client) Send ¶
Send submits a user message to a session and triggers a conversational turn in the daemon's background runtime.
func (*Client) SessionUsage ¶
SessionUsage returns the token, cost and tool usage of a session.
func (*Client) SetMCPEnabled ¶
func (c *Client) SetMCPEnabled(ctx context.Context, name string, enabled bool) ([]api.MCPServer, error)
SetMCPEnabled patches availability for the named MCP server (its manifest's spec.enabled or a WORKSPACE.md MCPs policy exclusion), reloads the workspace, and returns the updated MCP listing.
func (*Client) SetProviderEnabled ¶
func (c *Client) SetProviderEnabled(ctx context.Context, name string, enabled bool) ([]api.WorkspaceProvider, error)
SetProviderEnabled patches the named provider manifest's spec.enabled flag, reloads the workspace, and returns the updated provider listing.
func (*Client) SetToolEnabled ¶
SetToolEnabled patches availability for the named tool (its manifest's spec.enabled or a WORKSPACE.md tools policy exclusion), reloads the workspace, and returns the updated tool listing.
func (*Client) SocketPath ¶
SocketPath returns the Unix domain socket path configured on the client.
func (*Client) StartProviderAuth ¶
func (c *Client) StartProviderAuth(ctx context.Context, provider string) (*api.ProviderAuthResponse, error)
StartProviderAuth initiates interactive OAuth for a provider.
func (*Client) StreamTaskOutput ¶
func (c *Client) StreamTaskOutput(ctx context.Context, sessionID, taskID string) iter.Seq2[string, error]
StreamTaskOutput streams live task output (both backlog and live updates) for a task.
func (*Client) Subscribe ¶
func (c *Client) Subscribe(ctx context.Context, subscriberID, since string, topics ...string) (*api.SubscriptionResponse, error)
Subscribe subscribes an active SSE stream (identified by subscriberID) to additional topics.
func (*Client) TrustWorkspace ¶
TrustWorkspace records a trust decision for the workspace.
func (*Client) Unsubscribe ¶
func (c *Client) Unsubscribe(ctx context.Context, subscriberID string, topics ...string) (*api.SubscriptionResponse, error)
Unsubscribe unsubscribes an active SSE stream (identified by subscriberID) from topics.
func (*Client) UpdateProviderModels ¶
func (c *Client) UpdateProviderModels(ctx context.Context, name string, req api.UpdateProviderModelsRequest) ([]api.WorkspaceProvider, error)
UpdateProviderModels rewrites the named provider manifest's declared models and optional default completion model, reloads the workspace, and returns the updated provider listing.
func (*Client) UpdateSandbox ¶
func (c *Client) UpdateSandbox(ctx context.Context, req api.UpdateSandboxRequest) (*api.SandboxResponse, error)
UpdateSandbox overwrites one scope's sandbox settings (global or project) and returns the refreshed sandbox posture.
func (*Client) UpdateSession ¶
func (c *Client) UpdateSession(ctx context.Context, sessionID string, req api.UpdateSessionRequest) (*api.Session, error)
UpdateSession modifies session metadata (title, agent, model) on an existing session.
func (*Client) UploadMedia ¶
func (c *Client) UploadMedia(ctx context.Context, sessionID string, data []byte, mimeType, filename string) (*api.Media, error)
UploadMedia stores raw media bytes in the session's content-addressed <session-dir>/media/<sha256> store and returns a lightweight descriptor.
func (*Client) Usage ¶
func (c *Client) Usage(ctx context.Context, req api.UsageRequest) (api.UsageSummary, error)
Usage returns the usage summary of the workspace or of all workspaces.
func (*Client) VerifyProvider ¶
func (c *Client) VerifyProvider(ctx context.Context, req api.VerifyProviderRequest) (*api.VerifyProviderResponse, error)
VerifyProvider tests credentials or endpoint reachability for a provider.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithCWD ¶
WithCWD configures the default client working directory sent via api.HeaderCWD.
func WithHTTPClient ¶
WithHTTPClient overrides the underlying *http.Client used by the client.
func WithSSEIdleTimeout ¶
WithSSEIdleTimeout overrides how long an SSE stream may stay silent before the client treats the connection as dead and fails the stream so callers reconnect. The daemon emits heartbeat comments every 15 seconds, so the default (4x that interval) only trips on genuinely half-open connections.
type SpawnedDaemon ¶
type SpawnedDaemon struct {
PID int
Done <-chan struct{}
}
SpawnedDaemon describes a detached daemon child process spawned by SpawnDetached. The process is reaped asynchronously; Done closes when the child exits for any reason, letting callers waiting on the socket notice an early startup failure immediately instead of polling until their deadline.
func SpawnDetached ¶
func SpawnDetached(socketPath string, spawnArgs ...string) (*SpawnedDaemon, error)
SpawnDetached resolves the current executable and spawns a background detached daemon process. If spawnArgs is empty, default arguments ["daemon", "serve", "--socket", <socketPath>] are used. The child process is detached with Setsid and reaped asynchronously in a goroutine.
func SpawnDetachedWithLog ¶
func SpawnDetachedWithLog(socketPath, stderrPath string, spawnArgs ...string) (*SpawnedDaemon, error)
SpawnDetachedWithLog behaves like SpawnDetached and additionally redirects the child's stderr to stderrPath when provided, so startup failures of a detached daemon are recoverable instead of silently discarded. If stderrPath is empty, a best-effort path inside the XDG logs directory is used; stderr is discarded when the log directory cannot be resolved.