sdk

package module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

README

Agent Runtime Go SDK

Licensed under Apache-2.0. Third-party material retains its own licenses and notices, including the OpenAI Codex attribution in chatgptauth/NOTICE.

Public Go contracts and HTTP client for Agent Runtime hosts.

This package contains only wire contracts, event helpers, host callback DTOs, and a small /v1 HTTP client. Product lifecycle policy such as billing, projection, finalizers, automations, and UI persistence belongs in the host application.

Install

go get github.com/helpin-ai/agent-runtime-go@latest

HTTP client

client, err := sdk.NewClient(
    "https://agent-runtime.internal",
    sdk.WithAppID("host_app"),
    sdk.WithServiceToken("service-token"),
)
if err != nil {
    return err
}

page, err := client.SearchRuns(ctx, sdk.RunSearchRequest{
    Status: sdk.RunStatusRunning,
    Limit:  25,
})

The client covers runtime capabilities and app health, agents, runs, persisted event history, execution details, run tools, and live Server-Sent Events.

Apps can attach workspace-selected remote MCP servers to an individual run. The app owns MCP installation and OAuth; the optional mcpauth package handles the reusable discovery, PKCE, registration, exchange, and refresh protocol. The app supplies workspace/user authorization, browser routes, encrypted state and refresh-token storage, provider/tool policy, and notifications.

import "github.com/helpin-ai/agent-runtime-go/mcpauth"

oauthClient, err := mcpauth.NewClient(
    installation.EndpointURL,
    mcpauth.WithAllowedHosts("login.provider.example"),
)
configuration, err := oauthClient.Discover(ctx)
registration, err := oauthClient.Register(ctx, configuration.Authorization.RegistrationEndpoint, callbackURL)
authorization, err := oauthClient.NewAuthorizationRequest(configuration, registration.ClientID, callbackURL, installation.Scopes)

// Store mcpauth.HashState(authorization.State), an encrypted verifier, and the
// user/workspace/server binding before redirecting to authorization.URL.

At callback, atomically consume that state and call ExchangeCode. Call Refresh under an installation lock before runs when needed, persist a rotated refresh token, and send only the access token to Runtime.

run, err := client.StartRun(ctx, sdk.StartRunRequest{
    AgentID: "agent_123",
    Target: sdk.TargetRef{Type: "workspace", ID: "workspace_123"},
    MCPServers: []sdk.RunMCPServer{{
        ServerID:   "workspace_mcp_456",
        ServerName: "github",
        Transport:  sdk.MCPTransportStreamableHTTP,
        URL:        "https://mcp.example.com/mcp",
        Tools: []sdk.RunMCPTool{
            {Name: "get_issue", Access: sdk.MCPToolAccessRead},
            {Name: "create_issue", Access: sdk.MCPToolAccessWrite},
        },
        Skills: []sdk.SkillRef{{Key: "github_triage"}},
        Credential: &sdk.RunMCPCredential{
            Type:        sdk.MCPCredentialBearerToken,
            AccessToken: shortLivedAccessToken,
            ExpiresAt:   &expiresAt,
        },
    }},
})

Credentials are request-only and are not included in the returned run.

Before resuming a run paused for MCP authentication, rotate only its run-scoped access credential; keep refresh tokens in the host app:

_, err := client.UpdateRunMCPCredential(ctx, run.ID, "workspace_mcp_456", sdk.UpdateRunMCPCredentialRequest{
    Credential: sdk.RunMCPCredential{
        Type: sdk.MCPCredentialBearerToken, AccessToken: accessToken, ExpiresAt: &expiresAt,
    },
})
err = client.StreamRunEvents(ctx, runID, func(ctx context.Context, event sdk.EventEnvelope) error {
    log.Printf("%d %s", event.SequenceNo, event.Type)
    return nil
})

NATS / JetStream events

NATSConsumer provides durable pull consumption with explicit acknowledgements, bounded progressive retries, and the runtime's default stream/subject conventions.

consumer := sdk.NewNATSConsumer(sdk.NATSConsumerConfig{
    URL:     "nats://nats.internal:4222",
    AppID:   "host_app",
    Durable: "host-app-agent-runtime",
})
err := consumer.Run(ctx, handleEvent)

Test

go vet ./...
go test ./...
Optional app-owned credentials

Existing calls keep using the runtime's configured provider key. To override it for one run, send credentials from your backend only:

run, err := client.StartRun(ctx, sdk.StartRunRequest{
    AgentID: agentID,
    Target: sdk.TargetRef{Type: "workspace", ID: workspaceID},
    Model: &sdk.RunModel{Provider: "openai", Model: "gpt-5.6-luna"},
    ModelCredential: &sdk.ModelCredential{
        Type: "api_key", APIKey: apiKey, ConnectionID: connectionID,
    },
})

The runtime must configure AGENT_RUNTIME_MODEL_CREDENTIAL_ENCRYPTION_KEY. Credentials are encrypted per run, excluded from public run data, and cleared on terminal outcomes. An invalid supplied key never falls back to the runtime key. UpdateRunModelCredential replaces a credential on an active run; RevokeRunModelCredential prevents subsequent model requests. Replacement cannot change the connection or ChatGPT account identity.

chatgptauth implements optional device authentication without a Codex process:

auth, err := chatgptauth.NewClient(chatgptauth.Config{})
if err != nil { return err }
session, err := auth.StartDeviceLogin(ctx)
if err != nil { return err }
// Show session.VerificationURL and session.UserCode to the connecting user.
// Encrypt the session in your app database and serialize each poll with a row lock.
result, err := auth.PollDeviceLogin(ctx, session)
if err != nil { return err }
if result.Pending { /* persist session.NextPollAt; poll later */ }
if result.Token != nil { /* encrypt and save the whole token in the app */ }

For inference use provider: "openai_chatgpt" and a credential with Type: "oauth", AccessToken, ExpiresAt, ConnectionID, and AccountID. Never send the refresh token to the runtime. The app implements a service-authenticated refresh callback accepting ModelCredentialRefreshRequest and returning UpdateRunModelCredentialRequest. Verify the owning app/user/workspace and active run; lock the connection, refresh with auth.Refresh, save the rotated refresh token atomically, then return only the access credential. Compare CredentialFingerprint with SHA-256 of your current access token to avoid repeated refreshes for concurrent 401 callbacks. Account changes require a new connection.

Device polling is one call at a time, respects the stored polling interval, and expires after 15 minutes. Pending/429 updates must be saved. Transient failures can be retried; expired, denied, revoked, or account-changed sessions need reconnection. Errors and Go string formatting redact tokens. JWT account extraction reads routing metadata from the trusted exchange; it is not JWT verification or user authorization.

Subscription support is opt-in and must be validated with an eligible account in the intended deployment before enabling it. Device authentication support does not establish a generally supported third-party hosted subscription API. The SDK owns no connection database, refresh scheduler, credential file, or billing policy.

Compatible Chat Completions endpoints

RunModel{Provider: "openai_compatible", Model: "your-model", Endpoint: ...} uses the Chat Completions transport. Copy the ModelEndpoint binding from the app's advertised model_endpoints: ID, canonical base URL and authentication mode must all match Runtime's trusted app configuration. The endpoint cannot be supplied for a fixed provider such as openai or anthropic.

Always send a ModelCredential: use Type: "api_key" with the key, or explicitly Type: "none" for an approved no-auth endpoint. No-auth is not omission of run credentials and never invokes environment defaults. Local HTTP requires explicit administrator permission in Runtime; ValidateModelEndpoint checks structure only. Compatible routes support transcript continuation, not lossless Responses state, and do not accept provider-specific reasoning/service-tier controls.

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

View Source
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"
)
View Source
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"
)
View Source
const (
	RiskLevelRead        = "read"
	RiskLevelRoutine     = "routine_mutation"
	RiskLevelSensitive   = "sensitive_mutation"
	RiskLevelDestructive = "destructive_mutation"
)

Tool risk levels classify a tool independently from its mutation flag.

View Source
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}"
)
View Source
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"
)
View Source
const EventProtocolHeader = "X-Agent-Runtime-Event-Protocol"

Variables

View Source
var (
	ErrRetryEvent = errors.New("retry agent-runtime event")
	ErrDropEvent  = errors.New("drop agent-runtime event")
)

Functions

func AppEventSubject

func AppEventSubject(appID string) string

func EnsureNATSStream

func EnsureNATSStream(js nats.JetStreamContext, stream string, subjects []string) error

func NATSAppToken

func NATSAppToken(value string) string

func NATSToken

func NATSToken(value string) string

func NormalizeServiceTier

func NormalizeServiceTier(value string) string

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

func V2AppEventSubject(appID string) string

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

func ValidateRunModel(model *RunModel) error

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 AppendArtifactRequest struct {
	ArtifactType  string          `json:"artifact_type"`
	Format        string          `json:"format,omitempty"`
	StorageMode   string          `json:"storage_mode,omitempty"`
	InlineContent string          `json:"inline_content,omitempty"`
	Metadata      json.RawMessage `json:"metadata,omitempty"`
}

type AppendMessageRequest

type AppendMessageRequest struct {
	Role            string `json:"role"`
	Content         string `json:"content"`
	ExternalActorID string `json:"external_actor_id,omitempty"`
}

type AssistantMessageEventData

type AssistantMessageEventData struct {
	MessageID string `json:"message_id"`
	Text      string `json:"text,omitempty"`
	Content   string `json:"content,omitempty"`
}

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 NewClient

func NewClient(baseURL string, opts ...ClientOption) (*Client, error)

func (*Client) AppID

func (c *Client) AppID() string

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 (c *Client) ApproveRun(ctx context.Context, runID string, externalActorID ...string) (*AgentRun, error)

func (*Client) CallRunTool

func (c *Client) CallRunTool(ctx context.Context, runID string, req RunToolCallRequest) (*ToolCallResult, error)

func (*Client) CancelRun

func (c *Client) CancelRun(ctx context.Context, runID string) (*AgentRun, error)

func (*Client) CreateAgent

func (c *Client) CreateAgent(ctx context.Context, agent Agent) (*Agent, error)

func (*Client) GetAgent

func (c *Client) GetAgent(ctx context.Context, agentID string) (*Agent, error)

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) GetRun

func (c *Client) GetRun(ctx context.Context, runID string) (*AgentRun, error)

func (*Client) GetRunExecution

func (c *Client) GetRunExecution(ctx context.Context, runID string) (*RunExecutionInfo, error)

func (*Client) GetV2StreamState

func (c *Client) GetV2StreamState(ctx context.Context, runID string) (*StreamStateSnapshot, error)

GetV2StreamState returns the authoritative materialized stream snapshot.

func (*Client) Health

func (c *Client) Health(ctx context.Context) (map[string]string, error)

func (*Client) ListAgents

func (c *Client) ListAgents(ctx context.Context) ([]Agent, error)

func (*Client) ListArtifacts

func (c *Client) ListArtifacts(ctx context.Context, runID string) ([]AgentRunArtifact, error)

func (*Client) ListInteractions

func (c *Client) ListInteractions(ctx context.Context, runID string) ([]AgentRunInteraction, error)

func (*Client) ListMessages

func (c *Client) ListMessages(ctx context.Context, runID string) ([]AgentRunMessage, error)

func (*Client) ListRunEvents

func (c *Client) ListRunEvents(ctx context.Context, runID string) ([]EventEnvelope, error)

func (*Client) ListRunTools

func (c *Client) ListRunTools(ctx context.Context, runID string) ([]Tool, error)

func (*Client) ListRuns

func (c *Client) ListRuns(ctx context.Context) ([]AgentRun, error)

func (*Client) ListToolCalls

func (c *Client) ListToolCalls(ctx context.Context, runID string) ([]ToolCall, error)

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

func (c *Client) PauseRun(ctx context.Context, runID string) (*AgentRun, error)

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 (c *Client) RequestChanges(ctx context.Context, runID, content string, externalActorID ...string) (*AgentRun, error)

func (*Client) ResumeRun

func (c *Client) ResumeRun(ctx context.Context, runID string, req ResumeRunRequest) (*AgentRun, error)

func (*Client) RevokeRunModelCredential

func (c *Client) RevokeRunModelCredential(ctx context.Context, runID string) error

RevokeRunModelCredential prevents further model requests on this run.

func (*Client) SearchRuns

func (c *Client) SearchRuns(ctx context.Context, search RunSearchRequest) (*RunPage, error)

func (*Client) StartRun

func (c *Client) StartRun(ctx context.Context, req StartRunRequest) (*AgentRun, error)

func (*Client) StreamRunEvents

func (c *Client) StreamRunEvents(ctx context.Context, runID string, handler EventHandler) error

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 (c *Client) UpdateAgent(ctx context.Context, agentID string, agent Agent) (*Agent, error)

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)

func (*Client) UpsertAgent

func (c *Client) UpsertAgent(ctx context.Context, agent Agent) (*Agent, 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 ContentItem struct {
	Type string `json:"type"`
	Text string `json:"text,omitempty"`
}

type DurableInfo

type DurableInfo struct {
	Enabled         bool   `json:"enabled"`
	TemporalAddress string `json:"temporal_address,omitempty"`
	Namespace       string `json:"namespace,omitempty"`
}

type Event

type Event struct {
	AppID     string                 `json:"app_id"`
	RunID     string                 `json:"run_id"`
	HostRunID string                 `json:"host_run_id,omitempty"`
	Type      string                 `json:"type"`
	Data      map[string]interface{} `json:"data,omitempty"`
}

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 GitIdentity struct {
	Name  string `json:"name,omitempty"`
	Email string `json:"email,omitempty"`
}

type HTTPStatusError

type HTTPStatusError struct {
	Method     string
	Path       string
	StatusCode int
	Body       string
}

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 ReasoningMessageEventData

type ReasoningMessageEventData struct {
	MessageID      string `json:"message_id"`
	Text           string `json:"text,omitempty"`
	Content        string `json:"content,omitempty"`
	EncryptedValue string `json:"encrypted_value,omitempty"`
}

type RepositoryAuth

type RepositoryAuth struct {
	Type        string            `json:"type,omitempty"`
	Token       string            `json:"token,omitempty"`
	Username    string            `json:"username,omitempty"`
	Password    string            `json:"password,omitempty"`
	ExtraHeader string            `json:"extra_header,omitempty"`
	Env         map[string]string `json:"env,omitempty"`
}

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 RunMCPCapability struct {
	Supported                      bool     `json:"supported"`
	Transports                     []string `json:"transports"`
	CredentialEncryptionConfigured bool     `json:"credential_encryption_configured"`
}

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

type RunMCPTool struct {
	Name   string `json:"name"`
	Access string `json:"access"`
}

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 RunModelCredentialUpdate

type RunModelCredentialUpdate struct {
	RunID     string     `json:"run_id"`
	ExpiresAt *time.Time `json:"expires_at,omitempty"`
}

type RunPage

type RunPage struct {
	Items  []AgentRun `json:"items"`
	Total  int64      `json:"total"`
	Limit  int        `json:"limit"`
	Offset int        `json:"offset"`
}

type RunPlanStep

type RunPlanStep struct {
	Step   string `json:"step"`
	Status string `json:"status"`
}

type RunSearchRequest

type RunSearchRequest struct {
	Query  string
	Status string
	Limit  int
	Offset int
}

type RunToolCallRequest

type RunToolCallRequest struct {
	ToolName string          `json:"tool_name"`
	Input    json.RawMessage `json:"input"`
}

type SkillInfo

type SkillInfo struct {
	Key         string `json:"key"`
	Title       string `json:"title,omitempty"`
	Description string `json:"description,omitempty"`
}

type SkillRef

type SkillRef struct {
	SkillID    string          `json:"skill_id,omitempty"`
	Key        string          `json:"key,omitempty"`
	Version    string          `json:"version,omitempty"`
	VersionKey string          `json:"version_key,omitempty"`
	Config     json.RawMessage `json:"config,omitempty"`
}

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 StoreInfo

type StoreInfo struct {
	Driver   string `json:"driver"`
	InMemory bool   `json:"in_memory"`
}

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 TargetContext struct {
	Target  TargetRef              `json:"target"`
	Summary string                 `json:"summary,omitempty"`
	Data    map[string]interface{} `json:"data,omitempty"`
}

type TargetContextRequest

type TargetContextRequest struct {
	AppID    string                 `json:"app_id"`
	RunID    string                 `json:"run_id,omitempty"`
	AgentID  string                 `json:"agent_id,omitempty"`
	Target   TargetRef              `json:"target"`
	Trigger  map[string]interface{} `json:"trigger,omitempty"`
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

type TargetDisplay

type TargetDisplay struct {
	Title string `json:"title,omitempty"`
	URL   string `json:"url,omitempty"`
}

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"`
}

type UsageCheckpointEventData

type UsageCheckpointEventData struct {
	Usage         Usage  `json:"usage"`
	UsageSemantic string `json:"usage_semantic,omitempty"`
}

type WorkspaceLease

type WorkspaceLease struct {
	ID            string                 `json:"id"`
	Provider      string                 `json:"provider,omitempty"`
	RootPath      string                 `json:"root_path"`
	CleanupPolicy string                 `json:"cleanup_policy,omitempty"`
	Metadata      map[string]interface{} `json:"metadata,omitempty"`
}

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.

Jump to

Keyboard shortcuts

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