Documentation
¶
Overview ¶
Package sdk contains Agent Runtime's public wire contracts and HTTP client.
Hosts should use this package for runtime DTOs, event parsing, and callback payloads. Product lifecycle policy such as billing, projection, finalizers, automations, and UI persistence belongs in the host application.
Index ¶
- Constants
- Variables
- func AppEventSubject(appID string) string
- func EnsureNATSStream(js nats.JetStreamContext, stream string, subjects []string) error
- func NATSAppToken(value string) string
- func NATSToken(value string) string
- func NormalizeServiceTier(value string) string
- func ReasoningEfforts() []string
- func RenderNATSSubject(template string, event EventEnvelope) string
- func RenderNATSV2Subject(event EventEnvelope) string
- func ServiceTiers() []string
- func V2AppEventSubject(appID string) string
- func ValidateModelControls(provider string, controls ModelControls) error
- func ValidateModelEndpoint(endpoint *ModelEndpoint) error
- func ValidateRunModel(model *RunModel) error
- type Agent
- type AgentRun
- type AgentRunArtifact
- type AgentRunInteraction
- type AgentRunMessage
- type AppComponent
- type AppSummary
- type AppendArtifactRequest
- type AppendMessageRequest
- type AssistantMessageEventData
- type Capabilities
- type CleanupWorkspaceRequest
- type Client
- func (c *Client) AppID() string
- func (c *Client) AppendArtifact(ctx context.Context, runID string, req AppendArtifactRequest) (*AgentRunArtifact, error)
- func (c *Client) AppendMessage(ctx context.Context, runID string, req AppendMessageRequest) (*AgentRunMessage, error)
- func (c *Client) ApproveRun(ctx context.Context, runID string, externalActorID ...string) (*AgentRun, error)
- func (c *Client) CallRunTool(ctx context.Context, runID string, req RunToolCallRequest) (*ToolCallResult, error)
- func (c *Client) CancelRun(ctx context.Context, runID string) (*AgentRun, error)
- func (c *Client) CreateAgent(ctx context.Context, agent Agent) (*Agent, error)
- func (c *Client) GetAgent(ctx context.Context, agentID string) (*Agent, error)
- func (c *Client) GetAppHealth(ctx context.Context) (*AppSummary, error)
- func (c *Client) GetCapabilities(ctx context.Context) (*Capabilities, error)
- func (c *Client) GetRun(ctx context.Context, runID string) (*AgentRun, error)
- func (c *Client) GetRunExecution(ctx context.Context, runID string) (*RunExecutionInfo, error)
- func (c *Client) GetV2StreamState(ctx context.Context, runID string) (*StreamStateSnapshot, error)
- func (c *Client) Health(ctx context.Context) (map[string]string, error)
- func (c *Client) ListAgents(ctx context.Context) ([]Agent, error)
- func (c *Client) ListArtifacts(ctx context.Context, runID string) ([]AgentRunArtifact, error)
- func (c *Client) ListInteractions(ctx context.Context, runID string) ([]AgentRunInteraction, error)
- func (c *Client) ListMessages(ctx context.Context, runID string) ([]AgentRunMessage, error)
- func (c *Client) ListRunEvents(ctx context.Context, runID string) ([]EventEnvelope, error)
- func (c *Client) ListRunTools(ctx context.Context, runID string) ([]Tool, error)
- func (c *Client) ListRuns(ctx context.Context) ([]AgentRun, error)
- func (c *Client) ListToolCalls(ctx context.Context, runID string) ([]ToolCall, error)
- func (c *Client) ListV2Events(ctx context.Context, runID string, afterSequence int64) (*EventListResponse, error)
- func (c *Client) PauseRun(ctx context.Context, runID string) (*AgentRun, error)
- func (c *Client) RequestChanges(ctx context.Context, runID, content string, externalActorID ...string) (*AgentRun, error)
- func (c *Client) ResumeRun(ctx context.Context, runID string, req ResumeRunRequest) (*AgentRun, error)
- func (c *Client) RevokeRunModelCredential(ctx context.Context, runID string) error
- func (c *Client) SearchRuns(ctx context.Context, search RunSearchRequest) (*RunPage, error)
- func (c *Client) StartRun(ctx context.Context, req StartRunRequest) (*AgentRun, error)
- func (c *Client) StreamRunEvents(ctx context.Context, runID string, handler EventHandler) error
- func (c *Client) UpdateAgent(ctx context.Context, agentID string, agent Agent) (*Agent, error)
- func (c *Client) UpdateRunMCPCredential(ctx context.Context, runID, serverID string, req UpdateRunMCPCredentialRequest) (*RunMCPCredentialUpdate, error)
- func (c *Client) UpdateRunModelCredential(ctx context.Context, runID string, req UpdateRunModelCredentialRequest) (*RunModelCredentialUpdate, error)
- func (c *Client) UpsertAgent(ctx context.Context, agent Agent) (*Agent, error)
- type ClientOption
- type CodexAuthState
- type CodexAuthStateEventData
- type CommandExecutionContext
- type CommandExecutionRequest
- type CommandExecutionResponse
- type ContentItem
- type DurableInfo
- type Event
- type EventEnvelope
- func (e EventEnvelope) AssistantMessage() (AssistantMessageEventData, bool, error)
- func (e EventEnvelope) CodexAuthState() (CodexAuthStateEventData, bool, error)
- func (e EventEnvelope) DecodeData(out interface{}) error
- func (e EventEnvelope) ToolCall() (ToolCallEventData, bool, error)
- func (e EventEnvelope) UsageCheckpoint() (UsageCheckpointEventData, bool, error)
- type EventHandler
- type EventListResponse
- type FinalizeWorkspaceRequest
- type FinalizeWorkspaceResult
- type GitIdentity
- type HTTPStatusError
- type ModelControls
- type ModelCredential
- type ModelCredentialRefreshRequest
- type ModelEndpoint
- type NATSConsumer
- type NATSConsumerConfig
- type NATSEventHandler
- type OpenRouterModelControls
- type OpenRouterProviderPreferences
- type PlanUpdatedEventData
- type PrepareWorkspaceRequest
- type ProviderCapability
- type ProviderToolCallRequest
- type ReasoningMessageEventData
- type RepositoryAuth
- type RepositoryWorkspaceSpec
- type ResumeRunRequest
- type RunExecutionInfo
- type RunInput
- type RunMCPCapability
- type RunMCPCredential
- type RunMCPCredentialUpdate
- type RunMCPServer
- type RunMCPTool
- type RunModel
- type RunModelCredentialUpdate
- type RunPage
- type RunPlanStep
- type RunSearchRequest
- type RunToolCallRequest
- type SkillInfo
- type SkillRef
- type StartRunRequest
- type StoreInfo
- type StreamStateSnapshot
- type TargetContext
- type TargetContextRequest
- type TargetDisplay
- type TargetRef
- type Tool
- type ToolCall
- type ToolCallEventData
- type ToolCallResult
- type TurnPolicy
- type UpdateRunMCPCredentialRequest
- type UpdateRunModelCredentialRequest
- type Usage
- type UsageCheckpointEventData
- type WorkspaceLease
Constants ¶
const ( EventSchemaVersionV2 = "2" EventRunQueued = "run.queued" EventRunStarted = "run.started" EventRunResumed = "run.resumed" EventRunPaused = "run.paused" EventRunCompleted = "run.completed" EventRunFailed = "run.failed" EventRunCancelled = "run.cancelled" EventUsageCheckpoint = "usage.checkpoint" EventCodexAuthStateChanged = "codex_auth.state_changed" EventAssistantMessageStarted = "assistant_message_started" EventAssistantMessageDelta = "assistant_message_delta" EventAssistantMessageCompleted = "assistant_message_completed" EventReasoningMessageStarted = "reasoning_message_started" EventReasoningMessageDelta = "reasoning_message_delta" EventReasoningMessageCompleted = "reasoning_message_completed" EventToolCallStarted = "tool_call_started" EventToolCallArgsDelta = "tool_call_args_delta" EventToolCallResult = "tool_call_result" EventToolCallFinished = "tool_call_finished" EventPlanUpdated = "plan_updated" EventActivitySnapshot = "activity_snapshot" EventActivityDelta = "activity_delta" UsageSemanticCumulative = "cumulative" UsageSemanticDelta = "delta" )
const ( WorkspaceModeHostPrepared = "host_prepared" WorkspaceModeRepository = "repository" WorkspaceAccessReadOnly = "read_only" WorkspaceAccessReadWrite = "read_write" CleanupAlways = "always" CleanupOnTerminal = "on_terminal" CleanupManual = "manual" RepositoryFinalizeNone = "none" RepositoryFinalizeLocalCommit = "local_commit" RepositoryFinalizePushBranch = "push_branch" RepositoryFinalizeOpenPR = "open_pr" )
const ( RiskLevelRead = "read" RiskLevelRoutine = "routine_mutation" RiskLevelSensitive = "sensitive_mutation" RiskLevelDestructive = "destructive_mutation" )
Tool risk levels classify a tool independently from its mutation flag.
const ( DefaultNATSStreamName = "AGENT_RUNTIME_EVENTS" DefaultNATSStreamSubject = "agent-runtime.events.>" DefaultNATSSubjectTemplate = "agent-runtime.events.{app_id}.{run_id}.{event_type}" DefaultNATSV2SubjectTemplate = "agent-runtime.events.v2.{app_id}.{run_id}.{event_type}" )
const ( RuntimeNativeSDK = "native_sdk" RuntimeCodex = "codex" RuntimeOpenCode = "opencode" InvocationAutonomous = "autonomous" InvocationInteractive = "interactive" ApprovalModeNever = "never" ApprovalModeMutatingTools = "mutating_tools" ApprovalModeAlways = "always" ExecutionModeLightweight = "lightweight" ExecutionModeDurable = "durable" RunStatusQueued = "queued" RunStatusRunning = "running" RunStatusPaused = "paused" RunStatusCompleted = "completed" RunStatusFailed = "failed" RunStatusCancelled = "cancelled" PauseReasonNone = "none" PauseReasonHumanInput = "human_input" PauseReasonHumanApproval = "human_approval" PauseReasonAuth = "authentication" PauseReasonUserMessage = "awaiting_user_message" PauseReasonManual = "manual" TurnPolicyCompleteOnFinish = "complete_on_finish" TurnPolicyPauseAfterAssist = "pause_after_assistant" TurnCompletionImplicit = "implicit" TurnCompletionExplicit = "explicit_finish" ApprovalNotRequired = "not_required" ApprovalPending = "pending" ApprovalApproved = "approved" ApprovalRejected = "rejected" ResumeIntentReply = "reply" ResumeIntentContinue = "continue" ResumeIntentApprove = "approve" ResumeIntentRequestChanges = "request_changes" ResumeIntentAuthCompleted = "auth_completed" CodexAuthStateRequired = "required" CodexAuthStatePending = "pending" CodexAuthStateConnected = "connected" CodexAuthStateFailed = "failed" CodexAuthStateCancelled = "cancelled" MCPTransportStreamableHTTP = "streamable_http" MCPCredentialBearerToken = "bearer_token" MCPCredentialHeaders = "headers" MCPToolAccessRead = "read" MCPToolAccessWrite = "write" )
const EventProtocolHeader = "X-Agent-Runtime-Event-Protocol"
Variables ¶
var ( ErrRetryEvent = errors.New("retry agent-runtime event") ErrDropEvent = errors.New("drop agent-runtime event") )
Functions ¶
func AppEventSubject ¶
func EnsureNATSStream ¶
func EnsureNATSStream(js nats.JetStreamContext, stream string, subjects []string) error
func NATSAppToken ¶
func NormalizeServiceTier ¶
NormalizeServiceTier maps provider-native aliases to canonical control names.
func ReasoningEfforts ¶
func ReasoningEfforts() []string
ReasoningEfforts returns the structurally supported values. Runtime capability validation still decides whether a particular execution path supports them.
func RenderNATSSubject ¶
func RenderNATSSubject(template string, event EventEnvelope) string
func RenderNATSV2Subject ¶
func RenderNATSV2Subject(event EventEnvelope) string
RenderNATSV2Subject renders an event on the versioned v2 subject family.
func ServiceTiers ¶
func ServiceTiers() []string
ServiceTiers returns canonical user-facing values. Provider-native aliases default and priority remain accepted through NormalizeServiceTier.
func V2AppEventSubject ¶
V2AppEventSubject returns the isolated v2 subject for one host app.
func ValidateModelControls ¶
func ValidateModelControls(provider string, controls ModelControls) error
ValidateModelControls is the shared host/runtime validator for request controls.
func ValidateModelEndpoint ¶
func ValidateModelEndpoint(endpoint *ModelEndpoint) error
ValidateModelEndpoint checks structure only. Approval and permission for HTTP must come from trusted Runtime app configuration, never from a run flag.
func ValidateRunModel ¶
ValidateRunModel checks a concrete route and any explicit model controls. Hosts may represent custom model names; price catalogs do not belong here.
Types ¶
type Agent ¶
type Agent struct {
ID string `json:"id"`
AppID string `json:"app_id"`
Name string `json:"name"`
RuntimeKind string `json:"runtime_kind"`
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
SystemPrompt string `json:"system_prompt,omitempty"`
Skills []SkillRef `json:"skills,omitempty"`
AllowedTools []string `json:"allowed_tools,omitempty"`
AllowedTargets []string `json:"allowed_targets,omitempty"`
ApprovalMode string `json:"approval_mode"`
DefaultInvocationMode string `json:"default_invocation_mode"`
ExecutionConfig json.RawMessage `json:"execution_config,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type AgentRun ¶
type AgentRun struct {
ID string `json:"id"`
AppID string `json:"app_id"`
HostRunID string `json:"host_run_id,omitempty"`
AgentID string `json:"agent_id"`
Target TargetRef `json:"target"`
RuntimeKind string `json:"runtime_kind"`
ExecutionMode string `json:"execution_mode"`
InvocationMode string `json:"invocation_mode"`
ExternalActorID string `json:"external_actor_id,omitempty"`
Status string `json:"status"`
PauseReason string `json:"pause_reason"`
ApprovalState string `json:"approval_state"`
Input RunInput `json:"input"`
OutputSummary json.RawMessage `json:"output_summary,omitempty"`
WorkspaceLease *WorkspaceLease `json:"workspace_lease,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
StartedAt *time.Time `json:"started_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type AgentRunArtifact ¶
type AgentRunArtifact struct {
ID string `json:"id"`
AppID string `json:"app_id"`
RunID string `json:"run_id"`
ArtifactType string `json:"artifact_type"`
Format string `json:"format"`
StorageMode string `json:"storage_mode"`
InlineContent string `json:"inline_content,omitempty"`
Metadata json.RawMessage `json:"metadata,omitempty"`
SequenceNo int `json:"sequence_no"`
CreatedAt time.Time `json:"created_at"`
}
type AgentRunInteraction ¶
type AgentRunInteraction struct {
ID string `json:"id"`
AppID string `json:"app_id"`
RunID string `json:"run_id"`
RuntimeKind string `json:"runtime_kind"`
InteractionKind string `json:"interaction_kind"`
Status string `json:"status"`
Title string `json:"title,omitempty"`
Summary string `json:"summary,omitempty"`
RequestPayload json.RawMessage `json:"request_payload,omitempty"`
ResponsePayload json.RawMessage `json:"response_payload,omitempty"`
ResolvedByExternalID string `json:"resolved_by_external_id,omitempty"`
ResolvedAt *time.Time `json:"resolved_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type AgentRunMessage ¶
type AgentRunMessage struct {
ID string `json:"id"`
AppID string `json:"app_id"`
RunID string `json:"run_id"`
RuntimeMessageID string `json:"runtime_message_id,omitempty"`
Role string `json:"role"`
Content string `json:"content"`
MessageType string `json:"message_type"`
ContentBlocks json.RawMessage `json:"content_blocks,omitempty"`
ToolInvocations json.RawMessage `json:"tool_invocations,omitempty"`
SequenceNo int `json:"sequence_no"`
CreatedAt time.Time `json:"created_at"`
}
type AppComponent ¶
type AppComponent struct {
Name string `json:"name,omitempty"`
Kind string `json:"kind,omitempty"`
Configured bool `json:"configured"`
URL string `json:"url,omitempty"`
Transport string `json:"transport,omitempty"`
AuthConfigured bool `json:"auth_configured"`
Status string `json:"status,omitempty"`
HTTPStatus int `json:"http_status,omitempty"`
Error string `json:"error,omitempty"`
}
type AppSummary ¶
type AppSummary struct {
ModelEndpoints []ModelEndpoint `json:"model_endpoints,omitempty"`
RequireRunModelCredentials bool `json:"require_run_model_credentials"`
AppID string `json:"app_id"`
Components []AppComponent `json:"components,omitempty"`
}
type AppendArtifactRequest ¶
type AppendMessageRequest ¶
type Capabilities ¶
type Capabilities struct {
RuntimeKinds []string `json:"runtime_kinds"`
Providers []ProviderCapability `json:"providers"`
Store StoreInfo `json:"store"`
Durable DurableInfo `json:"durable"`
Skills []SkillInfo `json:"skills,omitempty"`
Apps []AppSummary `json:"apps,omitempty"`
ServiceAuthEnabled bool `json:"service_auth_enabled"`
Tools []Tool `json:"tools"`
RunMCP RunMCPCapability `json:"run_mcp"`
}
type CleanupWorkspaceRequest ¶
type CleanupWorkspaceRequest struct {
AppID string `json:"app_id"`
RunID string `json:"run_id"`
AgentID string `json:"agent_id"`
RuntimeKind string `json:"runtime_kind"`
Target TargetRef `json:"target"`
Lease WorkspaceLease `json:"lease"`
Repository *RepositoryWorkspaceSpec `json:"repository,omitempty"`
Reason string `json:"reason,omitempty"`
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) AppendArtifact ¶
func (c *Client) AppendArtifact(ctx context.Context, runID string, req AppendArtifactRequest) (*AgentRunArtifact, error)
func (*Client) AppendMessage ¶
func (c *Client) AppendMessage(ctx context.Context, runID string, req AppendMessageRequest) (*AgentRunMessage, error)
func (*Client) ApproveRun ¶
func (*Client) CallRunTool ¶
func (c *Client) CallRunTool(ctx context.Context, runID string, req RunToolCallRequest) (*ToolCallResult, error)
func (*Client) CreateAgent ¶
func (*Client) GetAppHealth ¶
func (c *Client) GetAppHealth(ctx context.Context) (*AppSummary, error)
func (*Client) GetCapabilities ¶
func (c *Client) GetCapabilities(ctx context.Context) (*Capabilities, error)
func (*Client) GetRunExecution ¶
func (*Client) GetV2StreamState ¶
GetV2StreamState returns the authoritative materialized stream snapshot.
func (*Client) ListArtifacts ¶
func (*Client) ListInteractions ¶
func (*Client) ListMessages ¶
func (*Client) ListRunEvents ¶
func (*Client) ListRunTools ¶
func (*Client) ListToolCalls ¶
func (*Client) ListV2Events ¶
func (c *Client) ListV2Events(ctx context.Context, runID string, afterSequence int64) (*EventListResponse, error)
ListV2Events returns durable ordered events after the supplied per-run sequence. The v1 client surface remains unchanged for existing consumers.
func (*Client) PauseRun ¶
PauseRun requests a durable run to stop at its current execution checkpoint. The returned run may still be running until its worker acknowledges the pause.
func (*Client) RequestChanges ¶
func (*Client) RevokeRunModelCredential ¶
RevokeRunModelCredential prevents further model requests on this run.
func (*Client) SearchRuns ¶
func (*Client) StreamRunEvents ¶
StreamRunEvents consumes the runtime's Server-Sent Events endpoint until the context is cancelled, the server closes the stream, or the handler returns an error.
func (*Client) UpdateAgent ¶
func (*Client) UpdateRunMCPCredential ¶
func (c *Client) UpdateRunMCPCredential( ctx context.Context, runID, serverID string, req UpdateRunMCPCredentialRequest, ) (*RunMCPCredentialUpdate, error)
UpdateRunMCPCredential rotates only the credential for an MCP server that was attached when the run started. Host apps should call this before resuming a run paused for authentication.
func (*Client) UpdateRunModelCredential ¶
func (c *Client) UpdateRunModelCredential(ctx context.Context, runID string, req UpdateRunModelCredentialRequest) (*RunModelCredentialUpdate, error)
type ClientOption ¶
type ClientOption func(*Client)
func WithAppID ¶
func WithAppID(appID string) ClientOption
func WithEventProtocol ¶
func WithEventProtocol(protocol string) ClientOption
WithEventProtocol declares the host projection contract expected for new runs. Older clients omit the header and continue to use the runtime's v1 compatibility behavior.
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
func WithServiceToken ¶
func WithServiceToken(token string) ClientOption
type CodexAuthState ¶
type CodexAuthState struct {
Provider string `json:"provider,omitempty"`
AuthMode string `json:"auth_mode,omitempty"`
State string `json:"state"`
LoginID *string `json:"login_id,omitempty"`
AuthURL *string `json:"auth_url,omitempty"`
VerificationURL *string `json:"verification_url,omitempty"`
UserCode *string `json:"user_code,omitempty"`
PlanType *string `json:"plan_type,omitempty"`
Error *string `json:"error,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
}
type CodexAuthStateEventData ¶
type CodexAuthStateEventData struct {
Provider string `json:"provider,omitempty"`
AuthMode string `json:"auth_mode,omitempty"`
State string `json:"state"`
LoginID string `json:"login_id,omitempty"`
AuthURL string `json:"auth_url,omitempty"`
VerificationURL string `json:"verification_url,omitempty"`
UserCode string `json:"user_code,omitempty"`
PlanType string `json:"plan_type,omitempty"`
Error string `json:"error,omitempty"`
}
type CommandExecutionContext ¶
type CommandExecutionContext struct {
AppID string `json:"app_id"`
RunID string `json:"run_id,omitempty"`
AgentID string `json:"agent_id,omitempty"`
ExternalActorID string `json:"external_actor_id,omitempty"`
WorkspaceID string `json:"workspace_id,omitempty"`
TargetType string `json:"target_type,omitempty"`
TargetID string `json:"target_id,omitempty"`
Target TargetRef `json:"target"`
RunInputMetadata map[string]interface{} `json:"run_input_metadata,omitempty"`
TargetMetadata map[string]interface{} `json:"target_metadata,omitempty"`
WorkspaceMetadata map[string]interface{} `json:"workspace_metadata,omitempty"`
}
type CommandExecutionRequest ¶
type CommandExecutionRequest struct {
Meta CommandExecutionContext `json:"meta"`
CommandName string `json:"command_name"`
Input json.RawMessage `json:"input,omitempty"`
}
type CommandExecutionResponse ¶
type CommandExecutionResponse struct {
Output json.RawMessage `json:"output,omitempty"`
Error string `json:"error,omitempty"`
}
type ContentItem ¶
type DurableInfo ¶
type EventEnvelope ¶
type EventEnvelope struct {
EventID string `json:"event_id"`
SentAt time.Time `json:"sent_at"`
SequenceNo int64 `json:"sequence_no"`
AppID string `json:"app_id"`
RunID string `json:"run_id"`
HostRunID string `json:"host_run_id,omitempty"`
SchemaVersion string `json:"schema_version,omitempty"`
TurnID string `json:"turn_id,omitempty"`
SegmentID string `json:"segment_id,omitempty"`
Revision int64 `json:"revision,omitempty"`
BaseRevision int64 `json:"base_revision,omitempty"`
Type string `json:"type"`
Data map[string]interface{} `json:"data,omitempty"`
}
func ParseEventEnvelope ¶
func ParseEventEnvelope(payload []byte) (*EventEnvelope, error)
func (EventEnvelope) AssistantMessage ¶
func (e EventEnvelope) AssistantMessage() (AssistantMessageEventData, bool, error)
func (EventEnvelope) CodexAuthState ¶
func (e EventEnvelope) CodexAuthState() (CodexAuthStateEventData, bool, error)
func (EventEnvelope) DecodeData ¶
func (e EventEnvelope) DecodeData(out interface{}) error
func (EventEnvelope) ToolCall ¶
func (e EventEnvelope) ToolCall() (ToolCallEventData, bool, error)
func (EventEnvelope) UsageCheckpoint ¶
func (e EventEnvelope) UsageCheckpoint() (UsageCheckpointEventData, bool, error)
type EventHandler ¶
type EventHandler func(ctx context.Context, event EventEnvelope) error
type EventListResponse ¶
type EventListResponse struct {
Events []EventEnvelope `json:"events"`
NextSequenceNo int64 `json:"next_sequence_no"`
StreamStateSnapshot *StreamStateSnapshot `json:"stream_state_snapshot,omitempty"`
}
EventListResponse is the replay response returned by the v2 events API.
type FinalizeWorkspaceRequest ¶
type FinalizeWorkspaceRequest struct {
AppID string `json:"app_id"`
RunID string `json:"run_id"`
AgentID string `json:"agent_id"`
RuntimeKind string `json:"runtime_kind"`
Target TargetRef `json:"target"`
Lease WorkspaceLease `json:"lease"`
Repository *RepositoryWorkspaceSpec `json:"repository,omitempty"`
Outcome string `json:"outcome"`
ErrorMessage string `json:"error_message,omitempty"`
OutputSummary json.RawMessage `json:"output_summary,omitempty"`
}
type FinalizeWorkspaceResult ¶
type FinalizeWorkspaceResult struct {
OutputSummary json.RawMessage `json:"output_summary,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
type GitIdentity ¶
type HTTPStatusError ¶
func (*HTTPStatusError) ClientError ¶
func (e *HTTPStatusError) ClientError() bool
func (*HTTPStatusError) Error ¶
func (e *HTTPStatusError) Error() string
type ModelControls ¶
type ModelControls struct {
ReasoningEffort *string `json:"reasoning_effort,omitempty"`
ServiceTier *string `json:"service_tier,omitempty"`
OpenRouter *OpenRouterModelControls `json:"openrouter,omitempty"`
}
ModelControls contains only model request options, not execution or tool limits.
type ModelCredential ¶
type ModelCredential struct {
Type string `json:"type"`
APIKey string `json:"api_key,omitempty"`
AccessToken string `json:"access_token,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
ConnectionID string `json:"connection_id,omitempty"`
AccountID string `json:"account_id,omitempty"`
}
ModelCredential is request-only. Send from your backend, never place it in run metadata or transcripts. Refresh tokens remain in the host application.
func (ModelCredential) GoString ¶
func (ModelCredential) GoString() string
func (ModelCredential) String ¶
func (ModelCredential) String() string
type ModelCredentialRefreshRequest ¶
type ModelCredentialRefreshRequest struct {
CredentialFingerprint string `json:"credential_fingerprint,omitempty"`
AppID string `json:"app_id"`
RunID string `json:"run_id"`
HostRunID string `json:"host_run_id,omitempty"`
ConnectionID string `json:"connection_id"`
Provider string `json:"provider"`
AccountID string `json:"account_id,omitempty"`
Reason string `json:"reason"`
}
type ModelEndpoint ¶
type ModelEndpoint struct {
ID string `json:"id" yaml:"id"`
BaseURL string `json:"base_url" yaml:"base_url"`
AuthMode string `json:"auth_mode" yaml:"auth_mode"`
}
ModelEndpoint pins an administrator-approved Chat Completions destination. Runtime verifies the complete binding against trusted app configuration.
type NATSConsumer ¶
type NATSConsumer struct {
// contains filtered or unexported fields
}
func NewNATSConsumer ¶
func NewNATSConsumer(cfg NATSConsumerConfig) *NATSConsumer
func (*NATSConsumer) Run ¶
func (c *NATSConsumer) Run(ctx context.Context, handler NATSEventHandler) error
type NATSConsumerConfig ¶
type NATSConsumerConfig struct {
URL string
ClientName string
JetStream nats.JetStreamContext
Stream string
StreamSubjects []string
AppID string
Durable string
Subject string
FetchBatch int
MaxWait time.Duration
AckWait time.Duration
MaxDeliver int
BackOff []time.Duration
MaxAckPending int
EnsureStream bool
Logger *slog.Logger
}
type NATSEventHandler ¶
type NATSEventHandler = EventHandler
type OpenRouterModelControls ¶
type OpenRouterModelControls struct {
Provider *OpenRouterProviderPreferences `json:"provider,omitempty"`
}
OpenRouterModelControls selects provider routing preferences.
type OpenRouterProviderPreferences ¶
type OpenRouterProviderPreferences struct {
Quantizations []string `json:"quantizations,omitempty"`
}
OpenRouterProviderPreferences restricts the selected provider's quantization.
type PlanUpdatedEventData ¶
type PlanUpdatedEventData struct {
Content string `json:"content,omitempty"`
Plan []RunPlanStep `json:"plan,omitempty"`
Note string `json:"note,omitempty"`
Data map[string]interface{} `json:"data,omitempty"`
}
type PrepareWorkspaceRequest ¶
type PrepareWorkspaceRequest struct {
AppID string `json:"app_id"`
RunID string `json:"run_id"`
AgentID string `json:"agent_id"`
RuntimeKind string `json:"runtime_kind"`
Target TargetRef `json:"target"`
TargetContext *TargetContext `json:"target_context,omitempty"`
Instructions string `json:"instructions,omitempty"`
Trigger map[string]interface{} `json:"trigger,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
WorkspaceMode string `json:"workspace_mode"`
ExecutionConfig json.RawMessage `json:"execution_config,omitempty"`
}
type ProviderCapability ¶
type ProviderCapability struct {
Protocols []string `json:"protocols,omitempty"`
Controls []string `json:"controls,omitempty"`
TranscriptContinuation bool `json:"transcript_continuation"`
LosslessResponseReplay bool `json:"lossless_response_replay"`
AuthModes []string `json:"auth_modes,omitempty"`
RunCredentialsConfigured bool `json:"run_credentials_configured"`
Name string `json:"name"`
Configured bool `json:"configured"`
DefaultModel string `json:"default_model,omitempty"`
BaseURLOverridden bool `json:"base_url_overridden"`
}
type ProviderToolCallRequest ¶
type ProviderToolCallRequest struct {
ToolName string `json:"tool_name"`
Input json.RawMessage `json:"input"`
Meta CommandExecutionContext `json:"meta"`
}
type RepositoryAuth ¶
type RepositoryWorkspaceSpec ¶
type RepositoryWorkspaceSpec struct {
Provider string `json:"provider,omitempty"`
CloneURL string `json:"clone_url"`
Auth *RepositoryAuth `json:"auth,omitempty"`
BaseBranch string `json:"base_branch,omitempty"`
WorkBranch string `json:"work_branch,omitempty"`
CommitIdentity *GitIdentity `json:"commit_identity,omitempty"`
FinalizePolicy string `json:"finalize_policy,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
type ResumeRunRequest ¶
type ResumeRunRequest struct {
MessageProvenance string `json:"message_provenance,omitempty"`
Intent string `json:"intent"`
Content string `json:"content,omitempty"`
ResponsePayload json.RawMessage `json:"response_payload,omitempty"`
ExternalActorID string `json:"external_actor_id,omitempty"`
ResumeID string `json:"resume_id,omitempty"`
InteractionID string `json:"interaction_id,omitempty"`
TurnPolicy *TurnPolicy `json:"turn_policy,omitempty"`
}
type RunExecutionInfo ¶
type RunExecutionInfo struct {
ExecutionMode string `json:"execution_mode"`
State string `json:"state"`
WorkflowID string `json:"workflow_id,omitempty"`
TemporalRunID string `json:"temporal_run_id,omitempty"`
TaskQueue string `json:"task_queue,omitempty"`
HistoryLength int64 `json:"history_length,omitempty"`
HistorySizeBytes int64 `json:"history_size_bytes,omitempty"`
StateTransitionCount int64 `json:"state_transition_count,omitempty"`
StartedAt *time.Time `json:"started_at,omitempty"`
ClosedAt *time.Time `json:"closed_at,omitempty"`
}
type RunInput ¶
type RunInput struct {
Model *RunModel `json:"model,omitempty"`
CredentialSource string `json:"credential_source,omitempty"`
Instructions string `json:"instructions,omitempty"`
AllowedTools []string `json:"allowed_tools,omitempty"`
Trigger map[string]interface{} `json:"trigger,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
ContextSummary string `json:"context_summary,omitempty"`
TurnPolicy TurnPolicy `json:"turn_policy,omitempty"`
}
type RunMCPCapability ¶
type RunMCPCredential ¶
type RunMCPCredential struct {
Type string `json:"type"`
AccessToken string `json:"access_token,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
}
RunMCPCredential carries credentials for one run. BearerToken uses AccessToken. Headers uses Headers. ExpiresAt is checked before execution.
type RunMCPCredentialUpdate ¶
type RunMCPCredentialUpdate struct {
RunID string `json:"run_id"`
ServerID string `json:"server_id"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
}
RunMCPCredentialUpdate acknowledges a credential rotation without echoing any secret material.
type RunMCPServer ¶
type RunMCPServer struct {
ServerID string `json:"server_id"`
ServerName string `json:"server_name"`
Transport string `json:"transport"`
URL string `json:"url"`
Tools []RunMCPTool `json:"tools"`
Skills []SkillRef `json:"skills,omitempty"`
Credential *RunMCPCredential `json:"credential,omitempty"`
}
RunMCPServer attaches an app-managed remote MCP server to one agent run. The host app remains responsible for server discovery, workspace policy, OAuth/browser consent, token refresh, and revocation. Credentials are request-only and are never returned as part of AgentRun.
type RunMCPTool ¶
RunMCPTool is the exact host-authorized tool policy for one MCP server. Access controls whether Agent Runtime treats a call as mutating for approval.
type RunModel ¶
type RunModel struct {
Provider string `json:"provider"`
Model string `json:"model"`
Endpoint *ModelEndpoint `json:"endpoint,omitempty"`
// Controls replaces legacy agent model controls when present, even if empty.
Controls *ModelControls `json:"controls,omitempty"`
}
RunModel pins an execution route without modifying the reusable agent.
type RunPlanStep ¶
type RunSearchRequest ¶
type RunToolCallRequest ¶
type RunToolCallRequest struct {
ToolName string `json:"tool_name"`
Input json.RawMessage `json:"input"`
}
type StartRunRequest ¶
type StartRunRequest struct {
Model *RunModel `json:"model,omitempty"`
ModelCredential *ModelCredential `json:"model_credential,omitempty"`
AppID string `json:"app_id"`
HostRunID string `json:"host_run_id,omitempty"`
AgentID string `json:"agent_id"`
Target TargetRef `json:"target"`
Instructions string `json:"instructions,omitempty"`
AllowedTools []string `json:"allowed_tools,omitempty"`
ExternalActorID string `json:"external_actor_id,omitempty"`
Mode string `json:"mode,omitempty"`
ExecutionMode string `json:"execution_mode,omitempty"`
Trigger map[string]interface{} `json:"trigger,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
TurnPolicy TurnPolicy `json:"turn_policy,omitempty"`
MCPServers []RunMCPServer `json:"mcp_servers,omitempty"`
}
type StreamStateSnapshot ¶
type StreamStateSnapshot struct {
SchemaVersion string `json:"schema_version"`
RunID string `json:"run_id"`
ThroughSequence int64 `json:"through_sequence"`
State map[string]interface{} `json:"state"`
}
StreamStateSnapshot is the authoritative materialized state of a v2 run stream through ThroughSequence. State is intentionally JSON-shaped so hosts can project provider-neutral turns without importing runtime internals.
type TargetContext ¶
type TargetContextRequest ¶
type TargetDisplay ¶
type TargetRef ¶
type TargetRef struct {
Type string `json:"type"`
ID string `json:"id"`
Display *TargetDisplay `json:"display,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
type Tool ¶
type Tool struct {
Name string `json:"name"`
Description string `json:"description"`
Category string `json:"category,omitempty"`
InputSchema json.RawMessage `json:"input_schema"`
Mutating bool `json:"mutating,omitempty"`
RiskLevel string `json:"risk_level,omitempty"`
SupportedTargetTypes []string `json:"supported_target_types,omitempty"`
}
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
AppID string `json:"app_id"`
RunID string `json:"run_id"`
ToolName string `json:"tool_name"`
Input json.RawMessage `json:"input"`
Output json.RawMessage `json:"output,omitempty"`
Error string `json:"error,omitempty"`
Mutating bool `json:"mutating"`
ApprovalRequired bool `json:"approval_required"`
CreatedAt time.Time `json:"created_at"`
}
type ToolCallEventData ¶
type ToolCallEventData struct {
ToolCallID string `json:"tool_call_id"`
ToolName string `json:"tool_name,omitempty"`
ToolInput string `json:"tool_input,omitempty"`
ParentMessageID string `json:"parent_message_id,omitempty"`
ResultMessageID string `json:"result_message_id,omitempty"`
ArgsDelta string `json:"args_delta,omitempty"`
ArgsText string `json:"args_text,omitempty"`
Content string `json:"content,omitempty"`
OutputSummary string `json:"output_summary,omitempty"`
DurationMS int64 `json:"duration_ms,omitempty"`
Error string `json:"error,omitempty"`
}
type ToolCallResult ¶
type ToolCallResult struct {
Content []ContentItem `json:"content"`
StructuredContent json.RawMessage `json:"structured_content,omitempty"`
IsError bool `json:"is_error,omitempty"`
ApprovalRequired bool `json:"approval_required,omitempty"`
InteractionID string `json:"interaction_id,omitempty"`
}
type TurnPolicy ¶
type TurnPolicy struct {
Mode string `json:"mode,omitempty"`
IdleTimeoutSeconds int `json:"idle_timeout_seconds,omitempty"`
ExpiredResumeStrategy string `json:"expired_resume_strategy,omitempty"`
CompletionMode string `json:"completion_mode,omitempty"`
MaxCompletionCorrections int `json:"max_completion_corrections,omitempty"`
}
type UpdateRunMCPCredentialRequest ¶
type UpdateRunMCPCredentialRequest struct {
Credential RunMCPCredential `json:"credential"`
}
UpdateRunMCPCredentialRequest replaces the credential for one MCP server already attached to a non-terminal run. It cannot change server or tool configuration.
type UpdateRunModelCredentialRequest ¶
type UpdateRunModelCredentialRequest struct {
Credential ModelCredential `json:"credential"`
}
type Usage ¶
type Usage struct {
TotalTokens int64 `json:"total_tokens,omitempty"`
InputTokens int64 `json:"input_tokens,omitempty"`
CachedInputTokens int64 `json:"cached_input_tokens,omitempty"`
OutputTokens int64 `json:"output_tokens,omitempty"`
ReasoningOutputTokens int64 `json:"reasoning_output_tokens,omitempty"`
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package chatgptauth implements app-side ChatGPT device authentication.
|
Package chatgptauth implements app-side ChatGPT device authentication. |
|
Package mcpauth provides headless, app-side OAuth helpers for remote MCP installations.
|
Package mcpauth provides headless, app-side OAuth helpers for remote MCP installations. |