Documentation
¶
Index ¶
- Variables
- func ArchiveAgent(ctx context.Context, agentID string, opts AgentOperationOptions, ...) error
- func AssistantText(msg SDKMessage) string
- func CancelRun(ctx context.Context, runID, agentID string, clientOpts ...ClientOption) error
- func CloseDefaultClient() error
- func Configure(opts ConfigureOptions)
- func DeleteAgent(ctx context.Context, agentID string, opts AgentOperationOptions, ...) error
- func EnsureBridgeInstalled(ctx context.Context) error
- func IsAgentBusy(err error) bool
- func IsAuthentication(err error) bool
- func IsConfiguration(err error) bool
- func IsIntegrationNotConnected(err error) bool
- func IsNotFound(err error) bool
- func IsRateLimit(err error) bool
- func IsUnsupportedRunOperation(err error) bool
- func McpServerFromMap(m map[string]any) map[string]any
- func Setup(ctx context.Context, opts SetupOptions) error
- func UnarchiveAgent(ctx context.Context, agentID string, opts AgentOperationOptions, ...) error
- type APITimeoutError
- type Agent
- func (a *Agent) Archive(ctx context.Context, opts AgentOperationOptions) error
- func (a *Agent) Close(ctx context.Context) error
- func (a *Agent) Delete(ctx context.Context, opts AgentOperationOptions) error
- func (a *Agent) DownloadArtifact(ctx context.Context, path string) ([]byte, error)
- func (a *Agent) ListArtifacts(ctx context.Context) ([]SdkArtifact, error)
- func (a *Agent) ListMessages(ctx context.Context) ([]AgentMessage, error)
- func (a *Agent) Reload(ctx context.Context) error
- func (a *Agent) Send(ctx context.Context, message any, opts SendOptions) (*Run, error)
- func (a *Agent) Unarchive(ctx context.Context, opts AgentOperationOptions) error
- type AgentBusyError
- type AgentDefinition
- type AgentError
- type AgentMessage
- type AgentMode
- type AgentNotFoundError
- type AgentOperationOptions
- type AgentOptions
- type AgentsResource
- func (r *AgentsResource) Archive(ctx context.Context, agentID string, opts AgentOperationOptions) error
- func (r *AgentsResource) CancelRun(ctx context.Context, runID, agentID string) error
- func (r *AgentsResource) Create(ctx context.Context, opts AgentOptions) (*Agent, error)
- func (r *AgentsResource) Delete(ctx context.Context, agentID string, opts AgentOperationOptions) error
- func (r *AgentsResource) Get(ctx context.Context, agentID string, opts GetAgentOptions) (SDKAgentInfo, error)
- func (r *AgentsResource) GetRun(ctx context.Context, runID string, opts GetRunOptions) (*Run, error)
- func (r *AgentsResource) List(ctx context.Context, opts ListAgentsOptions) (ListResult[SDKAgentInfo], error)
- func (r *AgentsResource) ListRuns(ctx context.Context, agentID string, opts ListRunsOptions) (ListResult[*Run], error)
- func (r *AgentsResource) Resume(ctx context.Context, agentID string, opts AgentOptions) (*Agent, error)
- func (r *AgentsResource) Unarchive(ctx context.Context, agentID string, opts AgentOperationOptions) error
- type AuthenticationError
- type BadRequestError
- type Client
- func (c *Client) Close() error
- func (c *Client) GetVersion(ctx context.Context) (map[string]any, error)
- func (c *Client) Ping(ctx context.Context) (string, error)
- func (c *Client) Shutdown(ctx context.Context, graceSeconds int) error
- func (c *Client) WithOptions(opts ...ClientOption) (*Client, error)
- type ClientOption
- type CloudAgentOptions
- type CloudEnvironment
- type CloudRepository
- type ConfigurationError
- type ConfigureLocalOptions
- type ConfigureOptions
- type ConversationStep
- type ConversationTurn
- type CursorAgentError
- type CursorClient
- type CursorRequestOptions
- type CustomTool
- type CustomToolContext
- type DeltaCallback
- type FlatMcpServer
- type GetAgentOptions
- type GetRunOptions
- type HttpMcpServerConfig
- type IntegrationNotConnectedError
- type InteractionUpdate
- type InternalServerError
- type ListAgentsOptions
- type ListResult
- type ListRunsOptions
- type LocalAgentOptions
- type LocalAgentStoreConfig
- type LocalSendOptions
- type McpAuth
- type McpServer
- type ModelParameterDefinition
- type ModelParameterDefinitionValue
- type ModelParameterValue
- type ModelSelection
- type ModelVariant
- type ModelsResource
- type NetworkError
- type NotFoundError
- type PermissionDeniedError
- type RateLimitError
- type RepositoriesResource
- type Run
- func (r *Run) Cancel(ctx context.Context) error
- func (r *Run) Conversation(ctx context.Context) ([]ConversationTurn, error)
- func (r *Run) ConversationJSON(ctx context.Context) (string, error)
- func (r *Run) Events(ctx context.Context) iter.Seq2[RunStreamEvent, error]
- func (r *Run) IterText(ctx context.Context) iter.Seq2[string, error]
- func (r *Run) Messages(ctx context.Context) iter.Seq2[SDKMessage, error]
- func (r *Run) Observe(ctx context.Context, afterOffset string) iter.Seq2[RunStreamEvent, error]
- func (r *Run) OnDidChangeStatus(fn func(RunStatus)) func()
- func (r *Run) OnStatusChange(fn func(RunStatus)) func()
- func (r *Run) Stream(ctx context.Context) iter.Seq2[SDKMessage, error]
- func (r *Run) Supports(op RunOperation) bool
- func (r *Run) SupportsString(op string) bool
- func (r *Run) Text(ctx context.Context) (string, error)
- func (r *Run) UnsupportedReason(op RunOperation) string
- func (r *Run) UnsupportedReasonString(op string) string
- func (r *Run) Wait(ctx context.Context) (RunResult, error)
- type RunGitBranchInfo
- type RunGitInfo
- type RunOperation
- type RunResult
- type RunResultStatus
- type RunSnapshot
- type RunStatus
- type RunStreamEvent
- type SDKAgentInfo
- type SDKArtifact
- type SDKError
- type SDKImage
- type SDKImageDimension
- type SDKMessage
- type SDKModel
- type SDKRepository
- type SDKUser
- type SDKUserMessage
- type SandboxOptions
- type SdkArtifact
- type SendOptions
- type SettingSource
- type SetupOptions
- type StdioMcpServerConfig
- type StepCallback
- type TextBlock
- type ToolCallbackServer
- type ToolUseBlock
- type UnknownAgentError
- type UnsupportedRunOperationError
- type UserMessage
Constants ¶
This section is empty.
Variables ¶
var Cursor = cursorNamespace{}
Cursor provides account-level SDK operations.
var Models = modelsNamespace{}
Models exposes model listing.
var Repositories = repositoriesNamespace{}
Repositories exposes connected repository listing.
Functions ¶
func ArchiveAgent ¶
func ArchiveAgent(ctx context.Context, agentID string, opts AgentOperationOptions, clientOpts ...ClientOption) error
ArchiveAgent archives a cloud agent by ID.
func AssistantText ¶
func AssistantText(msg SDKMessage) string
AssistantText extracts text from an assistant SDKMessage.
func CancelRun ¶
func CancelRun(ctx context.Context, runID, agentID string, clientOpts ...ClientOption) error
CancelRun cancels a run by ID.
func CloseDefaultClient ¶
func CloseDefaultClient() error
CloseDefaultClient closes the process-wide default client and bridge.
func Configure ¶
func Configure(opts ConfigureOptions)
Configure sets process-wide SDK defaults matching Cursor.configure() in TypeScript.
func DeleteAgent ¶
func DeleteAgent(ctx context.Context, agentID string, opts AgentOperationOptions, clientOpts ...ClientOption) error
DeleteAgent permanently deletes a cloud agent.
func EnsureBridgeInstalled ¶
EnsureBridgeInstalled reports whether cursor-sdk-bridge is installed (npm global/link or env).
func IsAuthentication ¶
IsAuthentication reports authentication/permission errors.
func IsConfiguration ¶
IsConfiguration reports configuration errors.
func IsIntegrationNotConnected ¶
IsIntegrationNotConnected reports integration connection errors.
func IsUnsupportedRunOperation ¶
IsUnsupportedRunOperation reports unsupported run operation errors.
func McpServerFromMap ¶
McpServerFromMap normalizes a flat MCP server config map to wire format. Accepts both nested ({http: ...}, {stdio: ...}) and flat ({type, url, command}) shapes.
func Setup ¶
func Setup(ctx context.Context, opts SetupOptions) error
Setup installs runtime prerequisites (cursor-sdk-bridge via npm). If ResolvePath succeeds (bridge on PATH at the required version), Setup is a no-op.
func UnarchiveAgent ¶
func UnarchiveAgent(ctx context.Context, agentID string, opts AgentOperationOptions, clientOpts ...ClientOption) error
UnarchiveAgent restores an archived cloud agent.
Types ¶
type APITimeoutError ¶
type APITimeoutError struct{ *AgentError }
type Agent ¶
type Agent struct {
AgentID string
Model *ModelSelection
// contains filtered or unexported fields
}
Agent is a durable handle for multi-turn agent conversations.
func CreateAgent ¶
func CreateAgent(ctx context.Context, opts AgentOptions, clientOpts ...ClientOption) (*Agent, error)
CreateAgent creates a new agent with the given options.
func ResumeAgent ¶
func ResumeAgent(ctx context.Context, agentID string, opts AgentOptions, clientOpts ...ClientOption) (*Agent, error)
ResumeAgent resumes an existing agent by ID.
func (*Agent) Archive ¶
func (a *Agent) Archive(ctx context.Context, opts AgentOperationOptions) error
Archive archives the agent.
func (*Agent) Delete ¶
func (a *Agent) Delete(ctx context.Context, opts AgentOperationOptions) error
Delete permanently deletes the agent.
func (*Agent) DownloadArtifact ¶
DownloadArtifact downloads an artifact by path.
func (*Agent) ListArtifacts ¶
func (a *Agent) ListArtifacts(ctx context.Context) ([]SdkArtifact, error)
ListArtifacts lists files produced by the agent.
func (*Agent) ListMessages ¶
func (a *Agent) ListMessages(ctx context.Context) ([]AgentMessage, error)
ListMessages returns persisted agent messages.
type AgentBusyError ¶
type AgentBusyError struct{ *AgentError }
type AgentDefinition ¶
type AgentDefinition struct {
Description string
Prompt string
Model any // string, ModelSelection, or "inherit"
McpServers []any // string names or inline configs
}
AgentDefinition describes a sub-agent available to the main agent.
func (AgentDefinition) ToWire ¶
func (d AgentDefinition) ToWire() map[string]any
type AgentError ¶
type AgentError struct {
Message string
Code string
Status int
Details []map[string]any
IsRetryable bool
ProtoErrorCode string
RequestID string
Headers map[string]string
RetryAfter string
}
AgentError is the base error type for Cursor SDK failures.
func AsAgentError ¶
func AsAgentError(err error) (*AgentError, bool)
AsAgentError reports whether err is an *AgentError (including typed wrappers).
func (*AgentError) Error ¶
func (e *AgentError) Error() string
type AgentMessage ¶
type AgentMessage struct {
Type string `json:"type"`
UUID string `json:"uuid"`
AgentID string `json:"agentId"`
Message any `json:"message"`
}
AgentMessage is a persisted agent message.
type AgentNotFoundError ¶
type AgentNotFoundError struct{ *AgentError }
type AgentOperationOptions ¶
AgentOperationOptions configures archive/unarchive/delete operations.
func (AgentOperationOptions) ToWire ¶
func (o AgentOperationOptions) ToWire() map[string]any
type AgentOptions ¶
type AgentOptions struct {
Model any // string or ModelSelection
APIKey string
Name string
Local *LocalAgentOptions
Cloud *CloudAgentOptions
McpServers map[string]McpServer
Agents map[string]AgentDefinition
AgentID string
IdempotencyKey string
Mode AgentMode
}
AgentOptions configures agent creation or resume.
func (AgentOptions) ToWire ¶
func (o AgentOptions) ToWire() map[string]any
type AgentsResource ¶
type AgentsResource struct {
// contains filtered or unexported fields
}
AgentsResource groups agent operations on a client.
func (*AgentsResource) Archive ¶
func (r *AgentsResource) Archive(ctx context.Context, agentID string, opts AgentOperationOptions) error
func (*AgentsResource) CancelRun ¶
func (r *AgentsResource) CancelRun(ctx context.Context, runID, agentID string) error
func (*AgentsResource) Create ¶
func (r *AgentsResource) Create(ctx context.Context, opts AgentOptions) (*Agent, error)
func (*AgentsResource) Delete ¶
func (r *AgentsResource) Delete(ctx context.Context, agentID string, opts AgentOperationOptions) error
func (*AgentsResource) Get ¶
func (r *AgentsResource) Get(ctx context.Context, agentID string, opts GetAgentOptions) (SDKAgentInfo, error)
func (*AgentsResource) GetRun ¶
func (r *AgentsResource) GetRun(ctx context.Context, runID string, opts GetRunOptions) (*Run, error)
func (*AgentsResource) List ¶
func (r *AgentsResource) List(ctx context.Context, opts ListAgentsOptions) (ListResult[SDKAgentInfo], error)
func (*AgentsResource) ListRuns ¶
func (r *AgentsResource) ListRuns(ctx context.Context, agentID string, opts ListRunsOptions) (ListResult[*Run], error)
func (*AgentsResource) Resume ¶
func (r *AgentsResource) Resume(ctx context.Context, agentID string, opts AgentOptions) (*Agent, error)
func (*AgentsResource) Unarchive ¶
func (r *AgentsResource) Unarchive(ctx context.Context, agentID string, opts AgentOperationOptions) error
type AuthenticationError ¶
type AuthenticationError struct{ *AgentError }
type BadRequestError ¶
type BadRequestError struct{ *AgentError }
type Client ¶
type Client struct {
Agents *AgentsResource
Models *ModelsResource
Repositories *RepositoriesResource
// contains filtered or unexported fields
}
Client talks to the Cursor SDK bridge.
func Connect ¶
func Connect(baseURL, authToken string, opts ...ClientOption) (*Client, error)
Connect returns a client attached to an existing bridge.
func DefaultClient ¶
DefaultClient returns the process-wide default client, launching a bridge if needed.
func LaunchBridge ¶
func LaunchBridge(ctx context.Context, opts ...ClientOption) (*Client, error)
LaunchBridge starts a local bridge and returns a client.
func (*Client) GetVersion ¶
GetVersion returns bridge version metadata.
func (*Client) WithOptions ¶
func (c *Client) WithOptions(opts ...ClientOption) (*Client, error)
WithOptions returns a client sharing the transport with overridden timeouts.
type ClientOption ¶
type ClientOption func(*clientConfig)
ClientOption configures a Client.
func WithAllowAPIKeyEnvFallback ¶
func WithAllowAPIKeyEnvFallback(allow bool) ClientOption
WithAllowAPIKeyEnvFallback allows reading CURSOR_API_KEY from the environment.
func WithMaxRetries ¶
func WithMaxRetries(n int) ClientOption
WithMaxRetries sets retry count for idempotent unary RPCs.
func WithStreamTimeout ¶
func WithStreamTimeout(d time.Duration) ClientOption
WithStreamTimeout sets streaming RPC timeout.
func WithUnaryTimeout ¶
func WithUnaryTimeout(d time.Duration) ClientOption
WithUnaryTimeout sets unary RPC timeout.
func WithWorkspace ¶
func WithWorkspace(path string) ClientOption
WithWorkspace sets the bridge workspace directory.
type CloudAgentOptions ¶
type CloudAgentOptions struct {
Env *CloudEnvironment
Repos []CloudRepository
WorkOnCurrentBranch *bool
AutoCreatePR *bool
SkipReviewerRequest *bool
EnvVars map[string]string
}
CloudAgentOptions configures a cloud agent runtime.
func (CloudAgentOptions) ToWire ¶
func (o CloudAgentOptions) ToWire() map[string]any
type CloudEnvironment ¶
CloudEnvironment selects cloud vs self-hosted pool.
func (CloudEnvironment) ToWire ¶
func (e CloudEnvironment) ToWire() map[string]any
type CloudRepository ¶
type CloudRepository struct {
URL string `json:"url"`
StartingRef string `json:"startingRef,omitempty"`
PRURL string `json:"prUrl,omitempty"`
}
CloudRepository identifies a repo for cloud agents.
func (CloudRepository) ToWire ¶
func (r CloudRepository) ToWire() map[string]any
type ConfigurationError ¶
type ConfigurationError struct{ *AgentError }
type ConfigureLocalOptions ¶
type ConfigureLocalOptions struct {
Store *LocalAgentStoreConfig
}
ConfigureLocalOptions configures local agent defaults.
type ConfigureOptions ¶
type ConfigureOptions struct {
Local *ConfigureLocalOptions
}
ConfigureOptions sets process-wide SDK defaults for later Agent calls. Per-call options override these values.
type ConversationStep ¶
ConversationStep is one step in a run conversation.
func ParseConversationStep ¶
func ParseConversationStep(m map[string]any) ConversationStep
ParseConversationStep parses a conversation step envelope.
type ConversationTurn ¶
ConversationTurn is a turn in run conversation history.
func ConversationFromJSON ¶
func ConversationFromJSON(raw string) ([]ConversationTurn, error)
ConversationFromJSON parses conversation JSON returned by GetRunConversation.
func ParseConversationTurn ¶
func ParseConversationTurn(m map[string]any) ConversationTurn
ParseConversationTurn parses a conversation turn from JSON bytes.
type CursorAgentError ¶
type CursorAgentError = AgentError
CursorAgentError is a backward-compatible alias matching TypeScript.
type CursorClient ¶
type CursorClient = Client
CursorClient is an alias for Client matching the Python SDK name.
type CursorRequestOptions ¶
type CursorRequestOptions struct {
APIKey string
}
CursorRequestOptions carries optional apiKey for Cursor namespace reads.
type CustomTool ¶
type CustomTool struct {
Description string
InputSchema map[string]any
Execute func(args map[string]any, ctx CustomToolContext) (any, error)
}
CustomTool defines a host-executed tool for local agents.
type CustomToolContext ¶
type CustomToolContext struct {
ToolCallID string
}
CustomToolContext carries per-invocation metadata.
type DeltaCallback ¶
type DeltaCallback func(InteractionUpdate)
DeltaCallback receives raw interaction updates during streaming.
type FlatMcpServer ¶
FlatMcpServer implements McpServer for map-based configs.
func (FlatMcpServer) ToWire ¶
func (f FlatMcpServer) ToWire() map[string]any
type GetAgentOptions ¶
GetAgentOptions configures Agent.get lookups.
func (GetAgentOptions) ToWire ¶
func (o GetAgentOptions) ToWire() map[string]any
type GetRunOptions ¶
GetRunOptions configures Agent.getRun lookups.
func (GetRunOptions) ToWire ¶
func (o GetRunOptions) ToWire() map[string]any
type HttpMcpServerConfig ¶
type HttpMcpServerConfig struct {
URL string
Type string // "http" or "sse"
Headers map[string]string
Auth *McpAuth
}
HttpMcpServerConfig configures an HTTP or SSE MCP server.
func (HttpMcpServerConfig) ToWire ¶
func (c HttpMcpServerConfig) ToWire() map[string]any
type IntegrationNotConnectedError ¶
type IntegrationNotConnectedError struct {
*AgentError
Provider string
HelpURL string
}
type InteractionUpdate ¶
type InteractionUpdate struct {
Type string
Text string
ThinkingDurationMS int
CallID string
ToolCall map[string]any
ModelCallID string
Tokens int
StepID int
StepDurationMS int
Usage map[string]any
UserMessage map[string]any
Summary string
Event map[string]any
Raw map[string]any
}
InteractionUpdate is a delta event during streaming.
func ParseInteractionUpdate ¶
func ParseInteractionUpdate(m map[string]any) InteractionUpdate
ParseInteractionUpdate parses a wire interaction update.
type InternalServerError ¶
type InternalServerError struct{ *AgentError }
type ListAgentsOptions ¶
type ListAgentsOptions struct {
Runtime string
CWD string
IncludeArchived *bool
PRURL string
Limit int
APIKey string
Cursor string
}
ListAgentsOptions configures agent listing.
func (ListAgentsOptions) ToWire ¶
func (o ListAgentsOptions) ToWire() map[string]any
type ListResult ¶
type ListResult[T any] struct { Items []T NextCursor string // contains filtered or unexported fields }
ListResult is a paginated list response.
func ListAgents ¶
func ListAgents(ctx context.Context, opts ListAgentsOptions, clientOpts ...ClientOption) (ListResult[SDKAgentInfo], error)
ListAgents lists agents with optional filters.
func ListRuns ¶
func ListRuns(ctx context.Context, agentID string, opts ListRunsOptions, clientOpts ...ClientOption) (ListResult[*Run], error)
ListRuns lists runs for an agent.
func (ListResult[T]) AllPages ¶
func (l ListResult[T]) AllPages() ([]T, error)
AllPages iterates all items across pages.
func (ListResult[T]) HasNextPage ¶
func (l ListResult[T]) HasNextPage() bool
func (ListResult[T]) NextPage ¶
func (l ListResult[T]) NextPage() (ListResult[T], error)
func (ListResult[T]) NextPageInfo ¶
func (l ListResult[T]) NextPageInfo() map[string]string
NextPageInfo returns pagination metadata for the next page.
type ListRunsOptions ¶
ListRunsOptions configures run listing.
func (ListRunsOptions) ToWire ¶
func (o ListRunsOptions) ToWire() map[string]any
type LocalAgentOptions ¶
type LocalAgentOptions struct {
CWD []string
SettingSources []SettingSource
SandboxOptions *SandboxOptions
Store *LocalAgentStoreConfig
AutoReview *bool
CustomTools map[string]CustomTool
}
LocalAgentOptions configures a local agent runtime.
func LocalOptions ¶
func LocalOptions(cwd ...string) *LocalAgentOptions
LocalOptions builds LocalAgentOptions from one or more workspace paths.
func (LocalAgentOptions) ToWire ¶
func (o LocalAgentOptions) ToWire() map[string]any
type LocalAgentStoreConfig ¶
type LocalAgentStoreConfig struct {
Type string `json:"type"`
RootDir string `json:"rootDir,omitempty"`
}
LocalAgentStoreConfig configures a custom local store.
func (LocalAgentStoreConfig) ToWire ¶
func (c LocalAgentStoreConfig) ToWire() map[string]any
type LocalSendOptions ¶
type LocalSendOptions struct {
Force *bool
CustomTools map[string]CustomTool
}
LocalSendOptions configures local-only send overrides.
func (LocalSendOptions) ToWire ¶
func (o LocalSendOptions) ToWire() map[string]any
type McpAuth ¶
type McpAuth struct {
ClientID string `json:"clientId"`
ClientSecret string `json:"clientSecret,omitempty"`
Scopes []string `json:"scopes,omitempty"`
}
McpAuth holds OAuth2 client credentials for HTTP MCP servers.
type ModelParameterDefinition ¶
type ModelParameterDefinition struct {
ID string
DisplayName string
Values []ModelParameterDefinitionValue
}
ModelParameterDefinition describes a configurable model parameter.
type ModelParameterDefinitionValue ¶
ModelParameterDefinitionValue is one allowed value for a model parameter.
type ModelParameterValue ¶
ModelParameterValue is a per-model option such as reasoning effort.
func (ModelParameterValue) ToWire ¶
func (p ModelParameterValue) ToWire() map[string]any
type ModelSelection ¶
type ModelSelection struct {
ID string `json:"id"`
Params []ModelParameterValue `json:"params,omitempty"`
}
ModelSelection identifies a model and optional parameters.
func ModelFromString ¶
func ModelFromString(id string) ModelSelection
func (ModelSelection) ToWire ¶
func (m ModelSelection) ToWire() map[string]any
type ModelVariant ¶
type ModelVariant struct {
Params []ModelParameterValue
DisplayName string
Description string
IsDefault bool
}
ModelVariant is a preset parameter combination for a model.
type ModelsResource ¶
type ModelsResource struct {
// contains filtered or unexported fields
}
ModelsResource lists models through a client.
func (*ModelsResource) List ¶
func (r *ModelsResource) List(ctx context.Context, opts CursorRequestOptions) ([]SDKModel, error)
type NetworkError ¶
type NetworkError struct{ *AgentError }
type NotFoundError ¶
type NotFoundError struct{ *AgentError }
type PermissionDeniedError ¶
type PermissionDeniedError struct{ *AgentError }
type RateLimitError ¶
type RateLimitError struct{ *AgentError }
type RepositoriesResource ¶
type RepositoriesResource struct {
// contains filtered or unexported fields
}
RepositoriesResource lists repositories through a client.
func (*RepositoriesResource) List ¶
func (r *RepositoriesResource) List(ctx context.Context, opts CursorRequestOptions) ([]SDKRepository, error)
type Run ¶
type Run struct {
ID string
RequestID string
AgentID string
Status RunStatus
Result string
Model *ModelSelection
DurationMS int
Git *RunGitInfo
CreatedAt string
// contains filtered or unexported fields
}
Run is a handle for one prompt submission and its stream.
func GetRun ¶
func GetRun(ctx context.Context, runID string, opts GetRunOptions, clientOpts ...ClientOption) (*Run, error)
GetRun fetches a run by ID.
func (*Run) Conversation ¶
func (r *Run) Conversation(ctx context.Context) ([]ConversationTurn, error)
Conversation returns parsed conversation turns.
func (*Run) ConversationJSON ¶
ConversationJSON returns the raw conversation JSON from the bridge.
func (*Run) OnDidChangeStatus ¶
OnDidChangeStatus registers a listener for status transitions (TypeScript alias).
func (*Run) OnStatusChange ¶
OnStatusChange registers a listener for status transitions.
func (*Run) Supports ¶
func (r *Run) Supports(op RunOperation) bool
Supports reports whether an operation is available on this run handle.
func (*Run) SupportsString ¶
SupportsString reports whether a named operation is available.
func (*Run) UnsupportedReason ¶
func (r *Run) UnsupportedReason(op RunOperation) string
UnsupportedReason explains why an operation is unavailable.
func (*Run) UnsupportedReasonString ¶
UnsupportedReasonString explains why a named operation is unavailable.
type RunGitBranchInfo ¶
type RunGitBranchInfo struct {
RepoURL string `json:"repoUrl"`
Branch string `json:"branch"`
PRURL string `json:"prUrl"`
}
RunGitBranchInfo describes a branch touched by a run.
type RunGitInfo ¶
type RunGitInfo struct {
Branches []RunGitBranchInfo `json:"branches"`
}
RunGitInfo aggregates git metadata from a run.
type RunOperation ¶
type RunOperation string
RunOperation names a run capability.
const ( RunOpStream RunOperation = "stream" RunOpWait RunOperation = "wait" RunOpCancel RunOperation = "cancel" RunOpConversation RunOperation = "conversation" )
type RunResult ¶
type RunResult struct {
ID string `json:"runId"`
RequestID string `json:"requestId,omitempty"`
AgentID string `json:"agentId"`
Status RunStatus `json:"status"`
Result string `json:"result"`
Model *ModelSelection `json:"model,omitempty"`
DurationMS int `json:"durationMs"`
Git *RunGitInfo `json:"git,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
}
RunResult is the terminal outcome of a run.
func Prompt ¶
func Prompt(ctx context.Context, message any, opts AgentOptions, clientOpts ...ClientOption) (RunResult, error)
Prompt is a one-shot helper: create agent, send, wait, and close.
type RunResultStatus ¶
type RunResultStatus = RunStatus
RunResultStatus is the terminal status returned by Wait.
type RunStreamEvent ¶
type RunStreamEvent struct {
Kind string
Offset string
SDKMessage SDKMessage
InteractionUpdate InteractionUpdate
Step ConversationStep
Result map[string]any
Done map[string]any
ResultIsFull bool
}
RunStreamEvent is a low-level stream envelope.
func ParseRunStreamEvent ¶
func ParseRunStreamEvent(m map[string]any) RunStreamEvent
ParseRunStreamEvent parses a stream envelope.
type SDKAgentInfo ¶
type SDKAgentInfo struct {
AgentID string `json:"agentId"`
Name string `json:"name"`
Summary string `json:"summary"`
LastModified string `json:"lastModified,omitempty"`
Status string `json:"status,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
Archived bool `json:"archived"`
Runtime string `json:"runtime,omitempty"`
CWD string `json:"cwd,omitempty"`
Env *CloudEnvironment `json:"env,omitempty"`
Repos []string `json:"repos,omitempty"`
}
SDKAgentInfo describes a known agent.
func GetAgent ¶
func GetAgent(ctx context.Context, agentID string, opts GetAgentOptions, clientOpts ...ClientOption) (SDKAgentInfo, error)
GetAgent fetches agent metadata by ID.
type SDKArtifact ¶
type SDKArtifact = SdkArtifact
SDKArtifact is an alias matching the TypeScript export name.
type SDKImage ¶
type SDKImage struct {
URL string
Data string
MimeType string
Dimension *SDKImageDimension
}
SDKImage is an image attachment for user messages.
func ImageFromFile ¶
func ImageFromFile(path string, mimeType string, dim *SDKImageDimension) (SDKImage, error)
func ImageFromURL ¶
func ImageFromURL(url string, dim *SDKImageDimension) SDKImage
type SDKImageDimension ¶
SDKImageDimension describes image size metadata.
type SDKMessage ¶
type SDKMessage struct {
Type string
AgentID string
RunID string
Subtype string
Model *ModelSelection
Tools []string
UserContent []TextBlock
AssistantContent []any
ThinkingText string
ThinkingDurationMS *int
ToolCallID string
ToolName string
ToolStatus string
ToolArgs any
ToolResult any
Status string
StatusMessage string
TaskStatus string
TaskText string
RequestID string
Raw map[string]any
}
SDKMessage is a typed stream message during a run.
func SDKMessageFromJSON ¶
func SDKMessageFromJSON(m map[string]any) SDKMessage
SDKMessageFromJSON parses a wire SDK message.
type SDKModel ¶
type SDKModel struct {
ID string `json:"id"`
DisplayName string `json:"displayName"`
Description string `json:"description"`
Parameters []ModelParameterDefinition `json:"parameters,omitempty"`
Variants []ModelVariant `json:"variants,omitempty"`
}
SDKModel describes an available model.
type SDKRepository ¶
type SDKRepository struct {
URL string `json:"url"`
}
SDKRepository is a connected repository.
type SDKUser ¶
type SDKUser struct {
APIKeyName string `json:"apiKeyName"`
CreatedAt string `json:"createdAt"`
UserID *int `json:"userId,omitempty"`
UserEmail string `json:"userEmail"`
UserFirstName string `json:"userFirstName"`
UserLastName string `json:"userLastName"`
}
SDKUser is the authenticated API key owner.
type SDKUserMessage ¶
type SDKUserMessage = UserMessage
SDKUserMessage is the structured send message type (alias for UserMessage).
type SandboxOptions ¶
type SandboxOptions struct {
Enabled *bool `json:"enabled,omitempty"`
}
SandboxOptions configures local sandbox behavior.
func (SandboxOptions) ToWire ¶
func (s SandboxOptions) ToWire() map[string]any
type SdkArtifact ¶
type SdkArtifact struct {
Path string `json:"path"`
SizeBytes int `json:"sizeBytes"`
UpdatedAt string `json:"updatedAt"`
}
SdkArtifact is a file produced by an agent run.
type SendOptions ¶
type SendOptions struct {
Model any
McpServers map[string]McpServer
Local *LocalSendOptions
IdempotencyKey string
Mode AgentMode
OnDelta DeltaCallback
OnStep StepCallback
}
SendOptions configures a single prompt submission.
func (SendOptions) ToWire ¶
func (o SendOptions) ToWire() map[string]any
type SettingSource ¶
type SettingSource string
SettingSource controls which ambient settings are loaded for local agents.
const ( SettingSourceProject SettingSource = "project" SettingSourceUser SettingSource = "user" SettingSourceTeam SettingSource = "team" SettingSourceMDM SettingSource = "mdm" SettingSourcePlugins SettingSource = "plugins" SettingSourceAll SettingSource = "all" )
type SetupOptions ¶
SetupOptions configures prerequisite installation for the Go SDK.
type StdioMcpServerConfig ¶
StdioMcpServerConfig configures a stdio MCP server.
func (StdioMcpServerConfig) ToWire ¶
func (c StdioMcpServerConfig) ToWire() map[string]any
type StepCallback ¶
type StepCallback func(ConversationStep)
StepCallback receives completed conversation steps during streaming.
type ToolCallbackServer ¶
type ToolCallbackServer struct {
URL string
Token string
// contains filtered or unexported fields
}
ToolCallbackServer hosts custom tool execute handlers for the bridge.
func NewToolCallbackServer ¶
func NewToolCallbackServer() *ToolCallbackServer
NewToolCallbackServer starts a loopback Connect/JSON server for custom tools.
func (*ToolCallbackServer) Close ¶
func (s *ToolCallbackServer) Close()
Close stops the callback server.
func (*ToolCallbackServer) RegisterAgent ¶
func (s *ToolCallbackServer) RegisterAgent(agentID string, tools map[string]CustomTool)
RegisterAgent registers custom tools for an agent ID.
func (*ToolCallbackServer) UnregisterAgent ¶
func (s *ToolCallbackServer) UnregisterAgent(agentID string)
UnregisterAgent removes custom tools for an agent ID.
type ToolUseBlock ¶
type ToolUseBlock struct {
Type string `json:"type"`
ID string `json:"id"`
Name string `json:"name"`
Input any `json:"input,omitempty"`
}
ToolUseBlock is a tool invocation in assistant content.
type UnknownAgentError ¶
type UnknownAgentError struct{ *AgentError }
type UnsupportedRunOperationError ¶
type UnsupportedRunOperationError struct {
*AgentError
Operation string
}
type UserMessage ¶
UserMessage is a prompt with optional images.
func UserMessageFromText ¶
func UserMessageFromText(text string) UserMessage
func (UserMessage) ToWire ¶
func (m UserMessage) ToWire() map[string]any