package copilot import "encoding/json" // ConnectionState represents the client connection state type ConnectionState string const ( StateDisconnected ConnectionState = "disconnected" StateConnecting ConnectionState = "connecting" StateConnected ConnectionState = "connected" StateError ConnectionState = "error" ) // ClientOptions configures the CopilotClient type ClientOptions struct { // CLIPath is the path to the Copilot CLI executable (default: "copilot") CLIPath string // CLIArgs are extra arguments to pass to the CLI executable (inserted before SDK-managed args) CLIArgs []string // Cwd is the working directory for the CLI process (default: "" = inherit from current process) Cwd string // Port for TCP transport (default: 0 = random port) Port int // UseStdio controls whether to use stdio transport instead of TCP. // Default: nil (use default = true, i.e. stdio). Use Bool(false) to explicitly select TCP. UseStdio *bool // CLIUrl is the URL of an existing Copilot CLI server to connect to over TCP // Format: "host:port", "http://host:port", or just "port" (defaults to localhost) // Examples: "localhost:8080", "http://127.0.0.1:9000", "8080" // Mutually exclusive with CLIPath, UseStdio CLIUrl string // LogLevel for the CLI server LogLevel string // AutoStart automatically starts the CLI server on first use (default: true). // Use Bool(false) to disable. AutoStart *bool // AutoRestart automatically restarts the CLI server if it crashes (default: true). // Use Bool(false) to disable. AutoRestart *bool // Env is the environment variables for the CLI process (default: inherits from current process). // Each entry is of the form "key=value". // If Env is nil, the new process uses the current process's environment. // If Env contains duplicate environment keys, only the last value in the // slice for each duplicate key is used. Env []string // GitHubToken is the GitHub token to use for authentication. // When provided, the token is passed to the CLI server via environment variable. // This takes priority over other authentication methods. GitHubToken string // UseLoggedInUser controls whether to use the logged-in user for authentication. // When true, the CLI server will attempt to use stored OAuth tokens or gh CLI auth. // When false, only explicit tokens (GitHubToken or environment variables) are used. // Default: true (but defaults to false when GitHubToken is provided). // Use Bool(false) to explicitly disable. UseLoggedInUser *bool } // Bool returns a pointer to the given bool value. // Use for setting AutoStart or AutoRestart: AutoStart: Bool(false) func Bool(v bool) *bool { return &v } // String returns a pointer to the given string value. // Use for setting optional string parameters in RPC calls. func String(v string) *string { return &v } // Float64 returns a pointer to the given float64 value. // Use for setting thresholds: BackgroundCompactionThreshold: Float64(0.80) func Float64(v float64) *float64 { return &v } // SystemMessageAppendConfig is append mode: use CLI foundation with optional appended content. type SystemMessageAppendConfig struct { // Mode is optional, defaults to "append" Mode string `json:"mode,omitempty"` // Content provides additional instructions appended after SDK-managed sections Content string `json:"content,omitempty"` } // SystemMessageReplaceConfig is replace mode: use caller-provided system message entirely. // Removes all SDK guardrails including security restrictions. type SystemMessageReplaceConfig struct { // Mode must be "replace" Mode string `json:"mode"` // Content is the complete system message (required) Content string `json:"content"` } // SystemMessageConfig represents system message configuration for session creation. // Use SystemMessageAppendConfig for default behavior, SystemMessageReplaceConfig for full control. // In Go, use one struct or the other based on your needs. type SystemMessageConfig struct { Mode string `json:"mode,omitempty"` Content string `json:"content,omitempty"` } // PermissionRequest represents a permission request from the server type PermissionRequest struct { Kind string `json:"kind"` ToolCallID string `json:"toolCallId,omitempty"` Extra map[string]any `json:"-"` // Additional fields vary by kind } // UnmarshalJSON implements custom JSON unmarshaling for PermissionRequest // to capture additional fields (varying by kind) into the Extra map. func (p *PermissionRequest) UnmarshalJSON(data []byte) error { // Unmarshal known fields via an alias to avoid infinite recursion type Alias PermissionRequest var alias Alias if err := json.Unmarshal(data, &alias); err != nil { return err } *p = PermissionRequest(alias) // Unmarshal all fields into a generic map var raw map[string]any if err := json.Unmarshal(data, &raw); err != nil { return err } // Remove known fields, keep the rest as Extra delete(raw, "kind") delete(raw, "toolCallId") if len(raw) > 0 { p.Extra = raw } return nil } // PermissionRequestResult represents the result of a permission request type PermissionRequestResult struct { Kind string `json:"kind"` Rules []any `json:"rules,omitempty"` } // PermissionHandlerFunc executes a permission request // The handler should return a PermissionRequestResult. Returning an error denies the permission. type PermissionHandlerFunc func(request PermissionRequest, invocation PermissionInvocation) (PermissionRequestResult, error) // PermissionInvocation provides context about a permission request type PermissionInvocation struct { SessionID string } // UserInputRequest represents a request for user input from the agent type UserInputRequest struct { Question string Choices []string AllowFreeform *bool } // UserInputResponse represents the user's response to an input request type UserInputResponse struct { Answer string WasFreeform bool } // UserInputHandler handles user input requests from the agent // The handler should return a UserInputResponse. Returning an error fails the request. type UserInputHandler func(request UserInputRequest, invocation UserInputInvocation) (UserInputResponse, error) // UserInputInvocation provides context about a user input request type UserInputInvocation struct { SessionID string } // PreToolUseHookInput is the input for a pre-tool-use hook type PreToolUseHookInput struct { Timestamp int64 `json:"timestamp"` Cwd string `json:"cwd"` ToolName string `json:"toolName"` ToolArgs any `json:"toolArgs"` } // PreToolUseHookOutput is the output for a pre-tool-use hook type PreToolUseHookOutput struct { PermissionDecision string `json:"permissionDecision,omitempty"` // "allow", "deny", "ask" PermissionDecisionReason string `json:"permissionDecisionReason,omitempty"` ModifiedArgs any `json:"modifiedArgs,omitempty"` AdditionalContext string `json:"additionalContext,omitempty"` SuppressOutput bool `json:"suppressOutput,omitempty"` } // PreToolUseHandler handles pre-tool-use hook invocations type PreToolUseHandler func(input PreToolUseHookInput, invocation HookInvocation) (*PreToolUseHookOutput, error) // PostToolUseHookInput is the input for a post-tool-use hook type PostToolUseHookInput struct { Timestamp int64 `json:"timestamp"` Cwd string `json:"cwd"` ToolName string `json:"toolName"` ToolArgs any `json:"toolArgs"` ToolResult any `json:"toolResult"` } // PostToolUseHookOutput is the output for a post-tool-use hook type PostToolUseHookOutput struct { ModifiedResult any `json:"modifiedResult,omitempty"` AdditionalContext string `json:"additionalContext,omitempty"` SuppressOutput bool `json:"suppressOutput,omitempty"` } // PostToolUseHandler handles post-tool-use hook invocations type PostToolUseHandler func(input PostToolUseHookInput, invocation HookInvocation) (*PostToolUseHookOutput, error) // UserPromptSubmittedHookInput is the input for a user-prompt-submitted hook type UserPromptSubmittedHookInput struct { Timestamp int64 `json:"timestamp"` Cwd string `json:"cwd"` Prompt string `json:"prompt"` } // UserPromptSubmittedHookOutput is the output for a user-prompt-submitted hook type UserPromptSubmittedHookOutput struct { ModifiedPrompt string `json:"modifiedPrompt,omitempty"` AdditionalContext string `json:"additionalContext,omitempty"` SuppressOutput bool `json:"suppressOutput,omitempty"` } // UserPromptSubmittedHandler handles user-prompt-submitted hook invocations type UserPromptSubmittedHandler func(input UserPromptSubmittedHookInput, invocation HookInvocation) (*UserPromptSubmittedHookOutput, error) // SessionStartHookInput is the input for a session-start hook type SessionStartHookInput struct { Timestamp int64 `json:"timestamp"` Cwd string `json:"cwd"` Source string `json:"source"` // "startup", "resume", "new" InitialPrompt string `json:"initialPrompt,omitempty"` } // SessionStartHookOutput is the output for a session-start hook type SessionStartHookOutput struct { AdditionalContext string `json:"additionalContext,omitempty"` ModifiedConfig map[string]any `json:"modifiedConfig,omitempty"` } // SessionStartHandler handles session-start hook invocations type SessionStartHandler func(input SessionStartHookInput, invocation HookInvocation) (*SessionStartHookOutput, error) // SessionEndHookInput is the input for a session-end hook type SessionEndHookInput struct { Timestamp int64 `json:"timestamp"` Cwd string `json:"cwd"` Reason string `json:"reason"` // "complete", "error", "abort", "timeout", "user_exit" FinalMessage string `json:"finalMessage,omitempty"` Error string `json:"error,omitempty"` } // SessionEndHookOutput is the output for a session-end hook type SessionEndHookOutput struct { SuppressOutput bool `json:"suppressOutput,omitempty"` CleanupActions []string `json:"cleanupActions,omitempty"` SessionSummary string `json:"sessionSummary,omitempty"` } // SessionEndHandler handles session-end hook invocations type SessionEndHandler func(input SessionEndHookInput, invocation HookInvocation) (*SessionEndHookOutput, error) // ErrorOccurredHookInput is the input for an error-occurred hook type ErrorOccurredHookInput struct { Timestamp int64 `json:"timestamp"` Cwd string `json:"cwd"` Error string `json:"error"` ErrorContext string `json:"errorContext"` // "model_call", "tool_execution", "system", "user_input" Recoverable bool `json:"recoverable"` } // ErrorOccurredHookOutput is the output for an error-occurred hook type ErrorOccurredHookOutput struct { SuppressOutput bool `json:"suppressOutput,omitempty"` ErrorHandling string `json:"errorHandling,omitempty"` // "retry", "skip", "abort" RetryCount int `json:"retryCount,omitempty"` UserNotification string `json:"userNotification,omitempty"` } // ErrorOccurredHandler handles error-occurred hook invocations type ErrorOccurredHandler func(input ErrorOccurredHookInput, invocation HookInvocation) (*ErrorOccurredHookOutput, error) // HookInvocation provides context about a hook invocation type HookInvocation struct { SessionID string } // SessionHooks configures hook handlers for a session type SessionHooks struct { OnPreToolUse PreToolUseHandler OnPostToolUse PostToolUseHandler OnUserPromptSubmitted UserPromptSubmittedHandler OnSessionStart SessionStartHandler OnSessionEnd SessionEndHandler OnErrorOccurred ErrorOccurredHandler } // MCPLocalServerConfig configures a local/stdio MCP server type MCPLocalServerConfig struct { Tools []string `json:"tools"` Type string `json:"type,omitempty"` // "local" or "stdio" Timeout int `json:"timeout,omitempty"` Command string `json:"command"` Args []string `json:"args"` Env map[string]string `json:"env,omitempty"` Cwd string `json:"cwd,omitempty"` } // MCPRemoteServerConfig configures a remote MCP server (HTTP or SSE) type MCPRemoteServerConfig struct { Tools []string `json:"tools"` Type string `json:"type"` // "http" or "sse" Timeout int `json:"timeout,omitempty"` URL string `json:"url"` Headers map[string]string `json:"headers,omitempty"` } // MCPServerConfig can be either MCPLocalServerConfig or MCPRemoteServerConfig // Use a map[string]any for flexibility, or create separate configs type MCPServerConfig map[string]any // CustomAgentConfig configures a custom agent type CustomAgentConfig struct { // Name is the unique name of the custom agent Name string `json:"name"` // DisplayName is the display name for UI purposes DisplayName string `json:"displayName,omitempty"` // Description of what the agent does Description string `json:"description,omitempty"` // Tools is the list of tool names the agent can use (nil for all tools) Tools []string `json:"tools,omitempty"` // Prompt is the prompt content for the agent Prompt string `json:"prompt"` // MCPServers are MCP servers specific to this agent MCPServers map[string]MCPServerConfig `json:"mcpServers,omitempty"` // Infer indicates whether the agent should be available for model inference Infer *bool `json:"infer,omitempty"` } // InfiniteSessionConfig configures infinite sessions with automatic context compaction // and workspace persistence. When enabled, sessions automatically manage context window // limits through background compaction and persist state to a workspace directory. type InfiniteSessionConfig struct { // Enabled controls whether infinite sessions are enabled (default: true) Enabled *bool `json:"enabled,omitempty"` // BackgroundCompactionThreshold is the context utilization (0.0-1.0) at which // background compaction starts. Default: 0.80 BackgroundCompactionThreshold *float64 `json:"backgroundCompactionThreshold,omitempty"` // BufferExhaustionThreshold is the context utilization (0.0-1.0) at which // the session blocks until compaction completes. Default: 0.95 BufferExhaustionThreshold *float64 `json:"bufferExhaustionThreshold,omitempty"` } // SessionConfig configures a new session type SessionConfig struct { // SessionID is an optional custom session ID SessionID string // ClientName identifies the application using the SDK. // Included in the User-Agent header for API requests. ClientName string // Model to use for this session Model string // ReasoningEffort level for models that support it. // Valid values: "low", "medium", "high", "xhigh" // Only applies to models where capabilities.supports.reasoningEffort is true. ReasoningEffort string // ConfigDir overrides the default configuration directory location. // When specified, the session will use this directory for storing config and state. ConfigDir string // Tools exposes caller-implemented tools to the CLI Tools []Tool // SystemMessage configures system message customization SystemMessage *SystemMessageConfig // AvailableTools is a list of tool names to allow. When specified, only these tools will be available. // Takes precedence over ExcludedTools. AvailableTools []string // ExcludedTools is a list of tool names to disable. All other tools remain available. // Ignored if AvailableTools is specified. ExcludedTools []string // OnPermissionRequest is a handler for permission requests from the server. // If nil, all permission requests are denied by default. // Provide a handler to approve operations (file writes, shell commands, URL fetches, etc.). OnPermissionRequest PermissionHandlerFunc // OnUserInputRequest is a handler for user input requests from the agent (enables ask_user tool) OnUserInputRequest UserInputHandler // Hooks configures hook handlers for session lifecycle events Hooks *SessionHooks // WorkingDirectory is the working directory for the session. // Tool operations will be relative to this directory. WorkingDirectory string // Streaming enables streaming of assistant message and reasoning chunks. // When true, assistant.message_delta and assistant.reasoning_delta events // with deltaContent are sent as the response is generated. Streaming bool // Provider configures a custom model provider (BYOK) Provider *ProviderConfig // MCPServers configures MCP servers for the session MCPServers map[string]MCPServerConfig // CustomAgents configures custom agents for the session CustomAgents []CustomAgentConfig // SkillDirectories is a list of directories to load skills from SkillDirectories []string // DisabledSkills is a list of skill names to disable DisabledSkills []string // InfiniteSessions configures infinite sessions for persistent workspaces and automatic compaction. // When enabled (default), sessions automatically manage context limits and persist state. InfiniteSessions *InfiniteSessionConfig } // Tool describes a caller-implemented tool that can be invoked by Copilot type Tool struct { Name string `json:"name"` Description string `json:"description,omitempty"` Parameters map[string]any `json:"parameters,omitempty"` Handler ToolHandler `json:"-"` } // ToolInvocation describes a tool call initiated by Copilot type ToolInvocation struct { SessionID string ToolCallID string ToolName string Arguments any } // ToolHandler executes a tool invocation. // The handler should return a ToolResult. Returning an error marks the tool execution as a failure. type ToolHandler func(invocation ToolInvocation) (ToolResult, error) // ToolResult represents the result of a tool invocation. type ToolResult struct { TextResultForLLM string `json:"textResultForLlm"` BinaryResultsForLLM []ToolBinaryResult `json:"binaryResultsForLlm,omitempty"` ResultType string `json:"resultType"` Error string `json:"error,omitempty"` SessionLog string `json:"sessionLog,omitempty"` ToolTelemetry map[string]any `json:"toolTelemetry,omitempty"` } // ResumeSessionConfig configures options when resuming a session type ResumeSessionConfig struct { // ClientName identifies the application using the SDK. // Included in the User-Agent header for API requests. ClientName string // Model to use for this session. Can change the model when resuming. Model string // Tools exposes caller-implemented tools to the CLI Tools []Tool // SystemMessage configures system message customization SystemMessage *SystemMessageConfig // AvailableTools is a list of tool names to allow. When specified, only these tools will be available. // Takes precedence over ExcludedTools. AvailableTools []string // ExcludedTools is a list of tool names to disable. All other tools remain available. // Ignored if AvailableTools is specified. ExcludedTools []string // Provider configures a custom model provider Provider *ProviderConfig // ReasoningEffort level for models that support it. // Valid values: "low", "medium", "high", "xhigh" ReasoningEffort string // OnPermissionRequest is a handler for permission requests from the server. // If nil, all permission requests are denied by default. // Provide a handler to approve operations (file writes, shell commands, URL fetches, etc.). OnPermissionRequest PermissionHandlerFunc // OnUserInputRequest is a handler for user input requests from the agent (enables ask_user tool) OnUserInputRequest UserInputHandler // Hooks configures hook handlers for session lifecycle events Hooks *SessionHooks // WorkingDirectory is the working directory for the session. // Tool operations will be relative to this directory. WorkingDirectory string // ConfigDir overrides the default configuration directory location. ConfigDir string // Streaming enables streaming of assistant message and reasoning chunks. // When true, assistant.message_delta and assistant.reasoning_delta events // with deltaContent are sent as the response is generated. Streaming bool // MCPServers configures MCP servers for the session MCPServers map[string]MCPServerConfig // CustomAgents configures custom agents for the session CustomAgents []CustomAgentConfig // SkillDirectories is a list of directories to load skills from SkillDirectories []string // DisabledSkills is a list of skill names to disable DisabledSkills []string // InfiniteSessions configures infinite sessions for persistent workspaces and automatic compaction. InfiniteSessions *InfiniteSessionConfig // DisableResume, when true, skips emitting the session.resume event. // Useful for reconnecting to a session without triggering resume-related side effects. DisableResume bool } // ProviderConfig configures a custom model provider type ProviderConfig struct { // Type is the provider type: "openai", "azure", or "anthropic". Defaults to "openai". Type string `json:"type,omitempty"` // WireApi is the API format (openai/azure only): "completions" or "responses". Defaults to "completions". WireApi string `json:"wireApi,omitempty"` // BaseURL is the API endpoint URL BaseURL string `json:"baseUrl"` // APIKey is the API key. Optional for local providers like Ollama. APIKey string `json:"apiKey,omitempty"` // BearerToken for authentication. Sets the Authorization header directly. // Use this for services requiring bearer token auth instead of API key. // Takes precedence over APIKey when both are set. BearerToken string `json:"bearerToken,omitempty"` // Azure contains Azure-specific options Azure *AzureProviderOptions `json:"azure,omitempty"` } // AzureProviderOptions contains Azure-specific provider configuration type AzureProviderOptions struct { // APIVersion is the Azure API version. Defaults to "2024-10-21". APIVersion string `json:"apiVersion,omitempty"` } // ToolBinaryResult represents binary payloads returned by tools. type ToolBinaryResult struct { Data string `json:"data"` MimeType string `json:"mimeType"` Type string `json:"type"` Description string `json:"description,omitempty"` } // MessageOptions configures a message to send type MessageOptions struct { // Prompt is the message to send Prompt string // Attachments are file or directory attachments Attachments []Attachment // Mode is the message delivery mode (default: "enqueue") Mode string } // SessionEventHandler is a callback for session events type SessionEventHandler func(event SessionEvent) // ModelVisionLimits contains vision-specific limits type ModelVisionLimits struct { SupportedMediaTypes []string `json:"supported_media_types"` MaxPromptImages int `json:"max_prompt_images"` MaxPromptImageSize int `json:"max_prompt_image_size"` } // ModelLimits contains model limits type ModelLimits struct { MaxPromptTokens *int `json:"max_prompt_tokens,omitempty"` MaxContextWindowTokens int `json:"max_context_window_tokens"` Vision *ModelVisionLimits `json:"vision,omitempty"` } // ModelSupports contains model support flags type ModelSupports struct { Vision bool `json:"vision"` ReasoningEffort bool `json:"reasoningEffort"` } // ModelCapabilities contains model capabilities and limits type ModelCapabilities struct { Supports ModelSupports `json:"supports"` Limits ModelLimits `json:"limits"` } // ModelPolicy contains model policy state type ModelPolicy struct { State string `json:"state"` Terms string `json:"terms"` } // ModelBilling contains model billing information type ModelBilling struct { Multiplier float64 `json:"multiplier"` } // ModelInfo contains information about an available model type ModelInfo struct { ID string `json:"id"` Name string `json:"name"` Capabilities ModelCapabilities `json:"capabilities"` Policy *ModelPolicy `json:"policy,omitempty"` Billing *ModelBilling `json:"billing,omitempty"` SupportedReasoningEfforts []string `json:"supportedReasoningEfforts,omitempty"` DefaultReasoningEffort string `json:"defaultReasoningEffort,omitempty"` } // SessionContext contains working directory context for a session type SessionContext struct { // Cwd is the working directory where the session was created Cwd string `json:"cwd"` // GitRoot is the git repository root (if in a git repo) GitRoot string `json:"gitRoot,omitempty"` // Repository is the GitHub repository in "owner/repo" format Repository string `json:"repository,omitempty"` // Branch is the current git branch Branch string `json:"branch,omitempty"` } // SessionListFilter contains filter options for listing sessions type SessionListFilter struct { // Cwd filters by exact working directory match Cwd string `json:"cwd,omitempty"` // GitRoot filters by git root GitRoot string `json:"gitRoot,omitempty"` // Repository filters by repository (owner/repo format) Repository string `json:"repository,omitempty"` // Branch filters by branch Branch string `json:"branch,omitempty"` } // SessionMetadata contains metadata about a session type SessionMetadata struct { SessionID string `json:"sessionId"` StartTime string `json:"startTime"` ModifiedTime string `json:"modifiedTime"` Summary *string `json:"summary,omitempty"` IsRemote bool `json:"isRemote"` Context *SessionContext `json:"context,omitempty"` } // SessionLifecycleEventType represents the type of session lifecycle event type SessionLifecycleEventType string const ( SessionLifecycleCreated SessionLifecycleEventType = "session.created" SessionLifecycleDeleted SessionLifecycleEventType = "session.deleted" SessionLifecycleUpdated SessionLifecycleEventType = "session.updated" SessionLifecycleForeground SessionLifecycleEventType = "session.foreground" SessionLifecycleBackground SessionLifecycleEventType = "session.background" ) // SessionLifecycleEvent represents a session lifecycle notification type SessionLifecycleEvent struct { Type SessionLifecycleEventType `json:"type"` SessionID string `json:"sessionId"` Metadata *SessionLifecycleEventMetadata `json:"metadata,omitempty"` } // SessionLifecycleEventMetadata contains optional metadata for lifecycle events type SessionLifecycleEventMetadata struct { StartTime string `json:"startTime"` ModifiedTime string `json:"modifiedTime"` Summary *string `json:"summary,omitempty"` } // SessionLifecycleHandler is a callback for session lifecycle events type SessionLifecycleHandler func(event SessionLifecycleEvent) // permissionRequestRequest represents the request data for a permission request type permissionRequestRequest struct { SessionID string `json:"sessionId"` Request PermissionRequest `json:"permissionRequest"` } // permissionRequestResponse represents the response to a permission request type permissionRequestResponse struct { Result PermissionRequestResult `json:"result"` } // createSessionRequest is the request for session.create type createSessionRequest struct { Model string `json:"model,omitempty"` SessionID string `json:"sessionId,omitempty"` ClientName string `json:"clientName,omitempty"` ReasoningEffort string `json:"reasoningEffort,omitempty"` Tools []Tool `json:"tools,omitempty"` SystemMessage *SystemMessageConfig `json:"systemMessage,omitempty"` AvailableTools []string `json:"availableTools"` ExcludedTools []string `json:"excludedTools,omitempty"` Provider *ProviderConfig `json:"provider,omitempty"` RequestPermission *bool `json:"requestPermission,omitempty"` RequestUserInput *bool `json:"requestUserInput,omitempty"` Hooks *bool `json:"hooks,omitempty"` WorkingDirectory string `json:"workingDirectory,omitempty"` Streaming *bool `json:"streaming,omitempty"` MCPServers map[string]MCPServerConfig `json:"mcpServers,omitempty"` EnvValueMode string `json:"envValueMode,omitempty"` CustomAgents []CustomAgentConfig `json:"customAgents,omitempty"` ConfigDir string `json:"configDir,omitempty"` SkillDirectories []string `json:"skillDirectories,omitempty"` DisabledSkills []string `json:"disabledSkills,omitempty"` InfiniteSessions *InfiniteSessionConfig `json:"infiniteSessions,omitempty"` } // createSessionResponse is the response from session.create type createSessionResponse struct { SessionID string `json:"sessionId"` WorkspacePath string `json:"workspacePath"` } // resumeSessionRequest is the request for session.resume type resumeSessionRequest struct { SessionID string `json:"sessionId"` ClientName string `json:"clientName,omitempty"` Model string `json:"model,omitempty"` ReasoningEffort string `json:"reasoningEffort,omitempty"` Tools []Tool `json:"tools,omitempty"` SystemMessage *SystemMessageConfig `json:"systemMessage,omitempty"` AvailableTools []string `json:"availableTools"` ExcludedTools []string `json:"excludedTools,omitempty"` Provider *ProviderConfig `json:"provider,omitempty"` RequestPermission *bool `json:"requestPermission,omitempty"` RequestUserInput *bool `json:"requestUserInput,omitempty"` Hooks *bool `json:"hooks,omitempty"` WorkingDirectory string `json:"workingDirectory,omitempty"` ConfigDir string `json:"configDir,omitempty"` DisableResume *bool `json:"disableResume,omitempty"` Streaming *bool `json:"streaming,omitempty"` MCPServers map[string]MCPServerConfig `json:"mcpServers,omitempty"` EnvValueMode string `json:"envValueMode,omitempty"` CustomAgents []CustomAgentConfig `json:"customAgents,omitempty"` SkillDirectories []string `json:"skillDirectories,omitempty"` DisabledSkills []string `json:"disabledSkills,omitempty"` InfiniteSessions *InfiniteSessionConfig `json:"infiniteSessions,omitempty"` } // resumeSessionResponse is the response from session.resume type resumeSessionResponse struct { SessionID string `json:"sessionId"` WorkspacePath string `json:"workspacePath"` } type hooksInvokeRequest struct { SessionID string `json:"sessionId"` Type string `json:"hookType"` Input json.RawMessage `json:"input"` } // listSessionsRequest is the request for session.list type listSessionsRequest struct { Filter *SessionListFilter `json:"filter,omitempty"` } // listSessionsResponse is the response from session.list type listSessionsResponse struct { Sessions []SessionMetadata `json:"sessions"` } // deleteSessionRequest is the request for session.delete type deleteSessionRequest struct { SessionID string `json:"sessionId"` } // deleteSessionResponse is the response from session.delete type deleteSessionResponse struct { Success bool `json:"success"` Error *string `json:"error,omitempty"` } // getForegroundSessionRequest is the request for session.getForeground type getForegroundSessionRequest struct{} // getForegroundSessionResponse is the response from session.getForeground type getForegroundSessionResponse struct { SessionID *string `json:"sessionId,omitempty"` WorkspacePath *string `json:"workspacePath,omitempty"` } // setForegroundSessionRequest is the request for session.setForeground type setForegroundSessionRequest struct { SessionID string `json:"sessionId"` } // setForegroundSessionResponse is the response from session.setForeground type setForegroundSessionResponse struct { Success bool `json:"success"` Error *string `json:"error,omitempty"` } type pingRequest struct { Message string `json:"message,omitempty"` } // PingResponse is the response from a ping request type PingResponse struct { Message string `json:"message"` Timestamp int64 `json:"timestamp"` ProtocolVersion *int `json:"protocolVersion,omitempty"` } // getStatusRequest is the request for status.get type getStatusRequest struct{} // GetStatusResponse is the response from status.get type GetStatusResponse struct { Version string `json:"version"` ProtocolVersion int `json:"protocolVersion"` } // getAuthStatusRequest is the request for auth.getStatus type getAuthStatusRequest struct{} // GetAuthStatusResponse is the response from auth.getStatus type GetAuthStatusResponse struct { IsAuthenticated bool `json:"isAuthenticated"` AuthType *string `json:"authType,omitempty"` Host *string `json:"host,omitempty"` Login *string `json:"login,omitempty"` StatusMessage *string `json:"statusMessage,omitempty"` } // listModelsRequest is the request for models.list type listModelsRequest struct{} // listModelsResponse is the response from models.list type listModelsResponse struct { Models []ModelInfo `json:"models"` } // sessionGetMessagesRequest is the request for session.getMessages type sessionGetMessagesRequest struct { SessionID string `json:"sessionId"` } // sessionGetMessagesResponse is the response from session.getMessages type sessionGetMessagesResponse struct { Events []SessionEvent `json:"events"` } // sessionDestroyRequest is the request for session.destroy type sessionDestroyRequest struct { SessionID string `json:"sessionId"` } // sessionAbortRequest is the request for session.abort type sessionAbortRequest struct { SessionID string `json:"sessionId"` } type sessionSendRequest struct { SessionID string `json:"sessionId"` Prompt string `json:"prompt"` Attachments []Attachment `json:"attachments,omitempty"` Mode string `json:"mode,omitempty"` } // sessionSendResponse is the response from session.send type sessionSendResponse struct { MessageID string `json:"messageId"` } // sessionEventRequest is the request for session event notifications type sessionEventRequest struct { SessionID string `json:"sessionId"` Event SessionEvent `json:"event"` } // toolCallRequest represents a tool call request from the server // to the client for execution. type toolCallRequest struct { SessionID string `json:"sessionId"` ToolCallID string `json:"toolCallId"` ToolName string `json:"toolName"` Arguments any `json:"arguments"` } // toolCallResponse represents the response to a tool call request // from the client back to the server. type toolCallResponse struct { Result ToolResult `json:"result"` } // userInputRequest represents a request for user input from the agent type userInputRequest struct { SessionID string `json:"sessionId"` Question string `json:"question"` Choices []string `json:"choices,omitempty"` AllowFreeform *bool `json:"allowFreeform,omitempty"` } // userInputResponse represents the user's response to an input request type userInputResponse struct { Answer string `json:"answer"` WasFreeform bool `json:"wasFreeform"` }