Documentation
¶
Index ¶
- Variables
- func AuthMiddleware(cfg AuthConfig, next http.Handler) http.Handler
- func CORSMiddleware(cfg CORSConfig, next http.Handler) http.Handler
- func ConcurrencyMiddleware(maxConcurrent int, next http.Handler) http.Handler
- func LoggingMiddleware(next http.Handler) http.Handler
- func Run(opts RunOptions, version string) error
- type APISession
- type ActiveSessionInfo
- type AuthConfig
- type CORSConfig
- type CapabilityFeature
- type CapabilityOverview
- type ChatCompletionChoice
- type ChatCompletionChunk
- type ChatCompletionRequest
- type ChatCompletionResponse
- type CommandResult
- type CompletionUsage
- type Config
- type ErrorDetail
- type ErrorResponse
- type HealthResponse
- type ModelItem
- type ModelListResponse
- type PoolFullError
- type RequestContentPart
- type RequestImageData
- type RequestImageURL
- type RequestMessage
- type ResponseMessage
- type RunOptions
- type SSEWriter
- func (s *SSEWriter) WriteContentDelta(content string)
- func (s *SSEWriter) WriteDone(usage *CompletionUsage)
- func (s *SSEWriter) WriteError(errMsg string)
- func (s *SSEWriter) WriteRoleDelta()
- func (s *SSEWriter) WriteToolResult(tc *toolCallInfo, detail string)
- func (s *SSEWriter) WriteToolStatusContent(title, status string)
- func (s *SSEWriter) WriteToolStatusEvent(evt ToolStatusEvent)
- func (s *SSEWriter) WriteTranscriptEvent(evt TranscriptStreamEvent)
- type SandboxConfig
- type Server
- func (s *Server) ApplySettings(next *config.Settings) error
- func (s *Server) CapabilityOverview() CapabilityOverview
- func (s *Server) DeleteActiveSession(id string) (bool, error)
- func (s *Server) GetSessionCapabilities(id string) (*SessionCapabilities, error)
- func (s *Server) GetSessionCapabilityEvents(id string) ([]SessionCapabilityEventEntry, error)
- func (s *Server) GetSessionMessages(id string) ([]SessionMessageEntry, error)
- func (s *Server) GetSessionRunEvents(id string) ([]SessionRunEventEntry, error)
- func (s *Server) GetSessionSubAgentMessages(id, agentID string) ([]SessionMessageEntry, error)
- func (s *Server) GetSessionSubAgents(id string) ([]SessionSubAgentInfo, error)
- func (s *Server) GetSessionToolResult(id, toolCallID string) (*SessionToolResultDetail, error)
- func (s *Server) ListActiveSessions() []ActiveSessionInfo
- func (s *Server) PatchSessionCapabilities(id string, patch SessionCapabilityPatch) (*SessionCapabilities, error)
- func (s *Server) RefreshSkillHubSession(sessionID, requestedWorkDir, activate string) (*SkillHubSessionState, error)
- func (s *Server) ResolveSkillHubWorkDir(sessionID, requested string) (string, error)
- func (s *Server) SessionDir() string
- func (s *Server) SkillHubRuntime() SkillHubRuntime
- func (s *Server) StreamSession(w http.ResponseWriter, r *http.Request, id string)
- type SessionCapabilities
- type SessionCapabilityEventEntry
- type SessionCapabilityPatch
- type SessionConfig
- type SessionMessageEntry
- type SessionPlanStep
- type SessionPool
- func (p *SessionPool) Count() int
- func (p *SessionPool) Get(id string) *APISession
- func (p *SessionPool) GetForWorkDir(workDir, id string) *APISession
- func (p *SessionPool) List() []string
- func (p *SessionPool) ListForWorkDir(workDir string) []string
- func (p *SessionPool) Pin(s *APISession) bool
- func (p *SessionPool) Put(s *APISession) error
- func (p *SessionPool) Remove(id string)
- func (p *SessionPool) RemoveByWorkDir(workDir, id string)
- func (p *SessionPool) Replace(oldID string, s *APISession)
- func (p *SessionPool) ReplaceByWorkDir(workDir, oldID string, s *APISession)
- func (p *SessionPool) Stop()
- func (p *SessionPool) Unpin(s *APISession)
- type SessionRunEventEntry
- type SessionSubAgentInfo
- type SessionTaskPlan
- type SessionToolOptions
- type SessionToolResultDetail
- type SkillHubRuntime
- type SkillHubSessionState
- type ToolStatusEvent
- type ToolVisibilityConfig
- type TranscriptStreamEvent
- type XToolCall
Constants ¶
This section is empty.
Variables ¶
var ErrActiveSessionIDAmbiguous = errors.New("active session ID is ambiguous")
ErrActiveSessionIDAmbiguous is returned when a session ID matches multiple active workdirs.
var ErrInvalidCapability = errors.New("invalid capability value")
ErrInvalidCapability is returned when a capability patch contains an invalid value.
var ErrSessionNotFound = errors.New("session not found")
ErrSessionNotFound is returned when a session cannot be found in memory or persistence.
var ErrSessionToolResultNotFound = errors.New("session tool result not found")
ErrSessionToolResultNotFound is returned when a persisted tool result cannot be found.
var ErrSubAgentNotFound = errors.New("sub-agent not found")
ErrSubAgentNotFound is returned when a sub-agent cannot be found in an active session.
Functions ¶
func AuthMiddleware ¶
func AuthMiddleware(cfg AuthConfig, next http.Handler) http.Handler
AuthMiddleware returns an HTTP middleware that validates Bearer tokens. If auth is disabled, the handler is called directly.
func CORSMiddleware ¶
func CORSMiddleware(cfg CORSConfig, next http.Handler) http.Handler
CORSMiddleware adds CORS headers when enabled.
func ConcurrencyMiddleware ¶
ConcurrencyMiddleware limits the number of concurrent in-flight requests. If maxConcurrent <= 0, no limit is applied.
func LoggingMiddleware ¶
LoggingMiddleware logs each request.
func Run ¶
func Run(opts RunOptions, version string) error
Run starts the OpenAI-compatible API server.
Types ¶
type APISession ¶
type APISession struct {
ID string
WorkDir string
Manager *session.Manager
Registry *tools.Registry
AgentMgr *agent.AgentManager // nil unless sub-agents/delegate/workflows enabled
SkillsMgr *skills.Manager
ActiveSkills map[string]bool
ExtraContext string
RuleContent string
Mode string // session-level mode override
DelegateMode bool // session-level delegation mode
Workflows bool // session-level workflow mode
WebSearch bool // session-level hosted web search toggle
Browser bool // session-level browser tool toggle
A2AMaster bool // session-level A2A dispatch tool toggle
MultiAgent bool // session-level sub-agent tools toggle
LastUsed time.Time
// ForceCompact is a legacy/session flag consumed by the next agent run.
// The /compact command now executes compaction immediately.
ForceCompact bool
// contains filtered or unexported fields
}
APISession holds state for a single API session.
func (*APISession) IsRunning ¶
func (s *APISession) IsRunning() bool
IsRunning reports whether a chat run is currently active for this session.
func (*APISession) Lock ¶
func (s *APISession) Lock()
Lock acquires the session lock (one request at a time per session).
func (*APISession) SetRunning ¶
func (s *APISession) SetRunning(running bool)
SetRunning records whether a chat run is currently active for this session.
type ActiveSessionInfo ¶
type ActiveSessionInfo struct {
ID string `json:"id"`
WorkDir string `json:"workDir"`
Mode string `json:"mode,omitempty"`
DelegateMode bool `json:"delegateMode,omitempty"`
Workflows bool `json:"workflows,omitempty"`
WebSearch bool `json:"webSearch,omitempty"`
Browser bool `json:"browser,omitempty"`
A2AMaster bool `json:"a2aMaster,omitempty"`
MultiAgent bool `json:"multiAgent,omitempty"`
Active bool `json:"active"`
Running bool `json:"running,omitempty"`
LastUsed time.Time `json:"lastUsed"`
MessageCount int `json:"messageCount"`
Preview string `json:"preview,omitempty"`
Title string `json:"title,omitempty"`
}
ActiveSessionInfo is the management API view of an active API session.
type AuthConfig ¶
AuthConfig controls bearer token authentication.
type CORSConfig ¶
type CORSConfig struct {
Enabled bool `json:"enabled"`
AllowOrigins []string `json:"allowOrigins,omitempty"`
}
CORSConfig controls cross-origin resource sharing.
type CapabilityFeature ¶
type CapabilityFeature struct {
Available bool `json:"available"`
Default bool `json:"default"`
Locked bool `json:"locked,omitempty"`
Reason string `json:"reason,omitempty"`
}
CapabilityFeature describes serve-level capability availability and defaults.
type CapabilityOverview ¶
type CapabilityOverview struct {
Modes []string `json:"modes"`
Features map[string]CapabilityFeature `json:"features"`
Defaults SessionCapabilities `json:"defaults"`
}
CapabilityOverview is returned by GET /api/capabilities.
type ChatCompletionChoice ¶
type ChatCompletionChoice struct {
Index int `json:"index"`
Message *ResponseMessage `json:"message,omitempty"`
Delta *ResponseMessage `json:"delta,omitempty"`
FinishReason *string `json:"finish_reason"`
}
ChatCompletionChoice is a single choice in the response.
type ChatCompletionChunk ¶
type ChatCompletionChunk struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Model string `json:"model"`
Choices []ChatCompletionChoice `json:"choices"`
Usage *CompletionUsage `json:"usage,omitempty"`
// VibeCoding extensions
XSessionID string `json:"x_session_id,omitempty"`
}
ChatCompletionChunk is the streaming chunk response.
type ChatCompletionRequest ¶
type ChatCompletionRequest struct {
Model string `json:"model,omitempty"`
Messages []RequestMessage `json:"messages"`
Stream bool `json:"stream,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
// VibeCoding extensions
XSessionID string `json:"x_session_id,omitempty"`
XMode string `json:"x_mode,omitempty"`
XWorkingDir string `json:"x_working_dir,omitempty"`
XTools *SessionToolOptions `json:"x_tools,omitempty"`
XTranscript bool `json:"x_transcript,omitempty"`
}
ChatCompletionRequest represents the OpenAI chat completions request.
type ChatCompletionResponse ¶
type ChatCompletionResponse struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Model string `json:"model"`
Choices []ChatCompletionChoice `json:"choices"`
Usage *CompletionUsage `json:"usage,omitempty"`
// VibeCoding extensions
XSessionID string `json:"x_session_id,omitempty"`
XCommand string `json:"x_command,omitempty"`
XToolCalls []XToolCall `json:"x_tool_calls,omitempty"`
}
ChatCompletionResponse is the non-streaming response.
type CommandResult ¶
CommandResult holds the output of a slash command.
type CompletionUsage ¶
type CompletionUsage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
CacheReadTokens int `json:"cache_read_tokens,omitempty"`
CacheWriteTokens int `json:"cache_write_tokens,omitempty"`
}
CompletionUsage tracks token counts.
type Config ¶
type Config struct {
Listen string `json:"listen,omitempty"`
Auth AuthConfig `json:"auth"`
DefaultMode string `json:"defaultMode,omitempty"`
DefaultThinkingLevel string `json:"defaultThinkingLevel,omitempty"`
EnableSubAgents bool `json:"enableSubAgents,omitempty"`
EnableDelegate bool `json:"enableDelegate,omitempty"`
EnableWorkflows bool `json:"enableWorkflows,omitempty"`
EnableWebSearch bool `json:"enableWebSearch,omitempty"`
EnableBrowser bool `json:"enableBrowser,omitempty"`
EnableA2AMaster bool `json:"enableA2AMaster,omitempty"`
Sandbox SandboxConfig `json:"sandbox"`
AllowedWorkDirs *[]string `json:"allowedWorkDirs,omitempty"` // nil=no check, []=deny all overrides
Session SessionConfig `json:"session"`
DefaultWorkDir string `json:"defaultWorkDir,omitempty"`
WorkingDir string `json:"workingDir,omitempty"` // legacy alias for defaultWorkDir
CORS CORSConfig `json:"cors"`
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
ToolVisibility ToolVisibilityConfig `json:"toolVisibility"`
SystemPromptMode string `json:"systemPromptMode,omitempty"` // "append" (default), "ignore"
RequestTimeoutSecs int `json:"requestTimeoutSeconds,omitempty"`
MaxConcurrentReqs int `json:"maxConcurrentRequests,omitempty"`
LogLevel string `json:"logLevel,omitempty"`
}
Config holds the OpenAI-compatible API configuration used by serve.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default OpenAI-compatible API configuration.
func (*Config) ApplyUnsafeAccess ¶ added in v1.1.62
func (c *Config) ApplyUnsafeAccess()
ApplyUnsafeAccess disables API auth and exposes loopback/default listens on all interfaces.
func (*Config) GetListenAddr ¶
GetListenAddr returns the effective listen address.
func (*Config) GetToolDetail ¶
GetToolDetail returns the effective tool detail level.
func (*Config) GetWorkDir ¶
GetWorkDir returns the effective working directory.
func (*Config) ValidateWorkDir ¶
ValidateWorkDir checks if the given directory is allowed by the allowedWorkDirs whitelist. Returns nil if allowed, an error describing the violation otherwise.
type ErrorDetail ¶
type ErrorDetail struct {
Message string `json:"message"`
Type string `json:"type"`
Code string `json:"code,omitempty"`
}
ErrorDetail contains error information.
type ErrorResponse ¶
type ErrorResponse struct {
Error ErrorDetail `json:"error"`
}
ErrorResponse is the standard OpenAI error format.
type HealthResponse ¶
type HealthResponse struct {
Status string `json:"status"`
Version string `json:"version"`
Sessions int `json:"sessions"`
}
HealthResponse is the response for GET /health.
type ModelItem ¶
type ModelItem struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
OwnedBy string `json:"owned_by"`
Input []string `json:"input,omitempty"`
}
ModelItem represents one model in the list.
type ModelListResponse ¶
ModelListResponse is the response for GET /v1/models.
type PoolFullError ¶
type PoolFullError struct {
Max int
}
PoolFullError is returned when the session pool is at capacity.
func (*PoolFullError) Error ¶
func (e *PoolFullError) Error() string
type RequestContentPart ¶
type RequestContentPart struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
ImageURL *RequestImageURL `json:"image_url,omitempty"`
Image *RequestImageData `json:"image,omitempty"`
}
RequestContentPart represents one OpenAI-compatible multimodal content part.
type RequestImageData ¶
type RequestImageData struct {
Data string `json:"data"`
MimeType string `json:"mimeType"`
Detail string `json:"detail,omitempty"`
}
RequestImageData represents an internal image content part shape.
type RequestImageURL ¶
RequestImageURL represents an OpenAI image_url content part.
type RequestMessage ¶
type RequestMessage struct {
Role string `json:"role"`
Content string `json:"content"`
ContentParts []RequestContentPart `json:"-"`
Name string `json:"name,omitempty"`
}
RequestMessage represents a message in the OpenAI request.
func (*RequestMessage) UnmarshalJSON ¶
func (m *RequestMessage) UnmarshalJSON(data []byte) error
UnmarshalJSON accepts both classic string content and OpenAI-style content arrays.
type ResponseMessage ¶
type ResponseMessage struct {
Role string `json:"role,omitempty"`
Content string `json:"content,omitempty"`
}
ResponseMessage is the assistant's response message.
type RunOptions ¶
type RunOptions struct {
Config *Config
DisableAPI bool
Port string
Provider string
Model string
WorkDir string
Unsafe bool
Sandbox bool
MultiAgent bool
Delegate bool
Workflows bool
WebSearch bool
Browser bool
A2AMaster bool
CronStore cron.CronStore
CronScheduler *cron.Scheduler
Verbose bool
Debug bool
ExtraRoutes func(*Server, *http.ServeMux)
}
RunOptions controls the OpenAI-compatible API runtime used by serve.
type SSEWriter ¶
type SSEWriter struct {
// contains filtered or unexported fields
}
SSEWriter helps write Server-Sent Events to an HTTP response.
func NewSSEWriter ¶
func NewSSEWriter(w http.ResponseWriter, model, sessionID string) *SSEWriter
NewSSEWriter creates an SSE writer and sets the appropriate headers.
func (*SSEWriter) WriteContentDelta ¶
WriteContentDelta sends a text content delta chunk.
func (*SSEWriter) WriteDone ¶
func (s *SSEWriter) WriteDone(usage *CompletionUsage)
WriteDone sends the final chunk with finish_reason and usage, then [DONE].
func (*SSEWriter) WriteError ¶
WriteError sends an error as a final chunk.
func (*SSEWriter) WriteRoleDelta ¶
func (s *SSEWriter) WriteRoleDelta()
WriteRoleDelta sends the initial role delta.
func (*SSEWriter) WriteToolResult ¶
WriteToolResult sends formatted tool output based on detail level.
func (*SSEWriter) WriteToolStatusContent ¶
WriteToolStatusContent sends a tool status in content mode (text in content delta). Uses a compact title like "read: path=main.go" rather than dumping full args.
func (*SSEWriter) WriteToolStatusEvent ¶
func (s *SSEWriter) WriteToolStatusEvent(evt ToolStatusEvent)
WriteToolStatusEvent sends a tool status as an SSE event (sse_event mode).
func (*SSEWriter) WriteTranscriptEvent ¶
func (s *SSEWriter) WriteTranscriptEvent(evt TranscriptStreamEvent)
WriteTranscriptEvent sends a WebUI transcript event that can be rendered with the same components used for persisted session history.
type SandboxConfig ¶
type SandboxConfig struct {
Enabled bool `json:"enabled"`
Level string `json:"level,omitempty"` // "none", "standard", "strict"; empty=auto from mode
}
SandboxConfig controls sandbox behavior for API requests.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the OpenAI-compatible API HTTP server.
func (*Server) ApplySettings ¶
ApplySettings updates the runtime provider/model from a saved settings.json.
func (*Server) CapabilityOverview ¶
func (s *Server) CapabilityOverview() CapabilityOverview
CapabilityOverview returns serve-level capability defaults and availability.
func (*Server) DeleteActiveSession ¶
DeleteActiveSession deletes one active session from persistence and the runtime pool.
func (*Server) GetSessionCapabilities ¶
func (s *Server) GetSessionCapabilities(id string) (*SessionCapabilities, error)
GetSessionCapabilities returns runtime capabilities for an active or persisted session.
func (*Server) GetSessionCapabilityEvents ¶
func (s *Server) GetSessionCapabilityEvents(id string) ([]SessionCapabilityEventEntry, error)
GetSessionCapabilityEvents returns persisted capability transition events for a session.
func (*Server) GetSessionMessages ¶
func (s *Server) GetSessionMessages(id string) ([]SessionMessageEntry, error)
GetSessionMessages returns the message history for a persisted session.
func (*Server) GetSessionRunEvents ¶
func (s *Server) GetSessionRunEvents(id string) ([]SessionRunEventEntry, error)
GetSessionRunEvents returns persisted run lifecycle events for a session.
func (*Server) GetSessionSubAgentMessages ¶
func (s *Server) GetSessionSubAgentMessages(id, agentID string) ([]SessionMessageEntry, error)
GetSessionSubAgentMessages returns the in-memory transcript for a sub-agent.
func (*Server) GetSessionSubAgents ¶
func (s *Server) GetSessionSubAgents(id string) ([]SessionSubAgentInfo, error)
GetSessionSubAgents returns sub-agent statuses for an active session.
func (*Server) GetSessionToolResult ¶
func (s *Server) GetSessionToolResult(id, toolCallID string) (*SessionToolResultDetail, error)
GetSessionToolResult returns the full persisted result for a tool call.
func (*Server) ListActiveSessions ¶
func (s *Server) ListActiveSessions() []ActiveSessionInfo
ListActiveSessions returns persisted sessions from sessions.db, merged with currently active API runtime state.
func (*Server) PatchSessionCapabilities ¶
func (s *Server) PatchSessionCapabilities(id string, patch SessionCapabilityPatch) (*SessionCapabilities, error)
PatchSessionCapabilities activates a session if needed and updates mutable runtime capabilities.
func (*Server) RefreshSkillHubSession ¶ added in v1.1.66
func (s *Server) RefreshSkillHubSession(sessionID, requestedWorkDir, activate string) (*SkillHubSessionState, error)
RefreshSkillHubSession reloads local skills and optionally activates one skill.
func (*Server) ResolveSkillHubWorkDir ¶ added in v1.1.66
ResolveSkillHubWorkDir resolves a request workDir through the existing serve whitelist.
func (*Server) SessionDir ¶
SessionDir returns the configured root directory that contains sessions.db.
func (*Server) SkillHubRuntime ¶ added in v1.1.66
func (s *Server) SkillHubRuntime() SkillHubRuntime
SkillHubRuntime returns a snapshot of marketplace-related runtime settings.
func (*Server) StreamSession ¶
StreamSession streams persisted and live transcript/event updates for one WebUI session.
type SessionCapabilities ¶
type SessionCapabilities struct {
ID string `json:"id,omitempty"`
WorkDir string `json:"workDir,omitempty"`
Active bool `json:"active"`
Mode string `json:"mode"`
DelegateMode bool `json:"delegateMode"`
Delegate bool `json:"delegate"`
MultiAgent bool `json:"multiAgent"`
Workflows bool `json:"workflows"`
WebSearch bool `json:"webSearch"`
Browser bool `json:"browser"`
A2AMaster bool `json:"a2aMaster"`
Model string `json:"model,omitempty"`
ThinkingLevel string `json:"thinkingLevel,omitempty"`
Persisted bool `json:"persisted"`
RuntimeOnly bool `json:"runtimeOnly,omitempty"`
PersistenceNote string `json:"persistenceNote,omitempty"`
}
SessionCapabilities are the effective runtime capabilities for a session.
type SessionCapabilityEventEntry ¶
type SessionCapabilityEventEntry struct {
Seq int64 `json:"seq,omitempty"`
ID string `json:"id"`
SessionID string `json:"sessionId"`
RunID string `json:"runId,omitempty"`
EventType string `json:"eventType"`
Source string `json:"source,omitempty"`
Actor string `json:"actor,omitempty"`
Capability string `json:"capability"`
OldValue string `json:"oldValue"`
NewValue string `json:"newValue"`
Timestamp string `json:"timestamp"`
Data map[string]any `json:"data,omitempty"`
}
SessionCapabilityEventEntry is the Web/API view of a capability transition.
type SessionCapabilityPatch ¶
type SessionCapabilityPatch struct {
Mode *string `json:"mode,omitempty"`
DelegateMode *bool `json:"delegateMode,omitempty"`
Delegate *bool `json:"delegate,omitempty"`
MultiAgent *bool `json:"multiAgent,omitempty"`
Workflows *bool `json:"workflows,omitempty"`
WebSearch *bool `json:"webSearch,omitempty"`
Browser *bool `json:"browser,omitempty"`
A2AMaster *bool `json:"a2aMaster,omitempty"`
}
SessionCapabilityPatch updates mutable session runtime capabilities.
type SessionConfig ¶
type SessionConfig struct {
IdleTimeoutSeconds int `json:"idleTimeoutSeconds,omitempty"`
MaxSessions int `json:"maxSessions,omitempty"`
}
SessionConfig controls session pool behavior.
type SessionMessageEntry ¶
type SessionMessageEntry struct {
ID string `json:"id,omitempty"`
Seq int64 `json:"seq,omitempty"`
Role string `json:"role"`
Content string `json:"content,omitempty"`
Contents []provider.ContentBlock `json:"contents,omitempty"`
AgentID string `json:"agentId,omitempty"`
ToolCallID string `json:"toolCallId,omitempty"`
ToolName string `json:"toolName,omitempty"`
Arguments json.RawMessage `json:"arguments,omitempty"`
InvalidArgs string `json:"invalidArguments,omitempty"`
Plan *SessionTaskPlan `json:"plan,omitempty"`
IsError bool `json:"isError,omitempty"`
Summary string `json:"summary,omitempty"`
HasDetail bool `json:"hasDetail,omitempty"`
}
SessionMessageEntry is a simplified message for the WebUI.
type SessionPlanStep ¶
SessionPlanStep is one todo item in a plan tool call.
type SessionPool ¶
type SessionPool struct {
// contains filtered or unexported fields
}
SessionPool manages multiple concurrent API sessions.
func NewSessionPool ¶
func NewSessionPool(maxSessions int, idleTimeout time.Duration) *SessionPool
NewSessionPool creates a session pool.
func (*SessionPool) Count ¶
func (p *SessionPool) Count() int
Count returns the number of active sessions.
func (*SessionPool) Get ¶
func (p *SessionPool) Get(id string) *APISession
Get returns an existing session by ID, or nil.
func (*SessionPool) GetForWorkDir ¶
func (p *SessionPool) GetForWorkDir(workDir, id string) *APISession
GetForWorkDir returns a session by workDir and ID, or nil.
func (*SessionPool) ListForWorkDir ¶
func (p *SessionPool) ListForWorkDir(workDir string) []string
ListForWorkDir returns all session IDs for a specific workDir.
func (*SessionPool) Pin ¶ added in v1.1.62
func (p *SessionPool) Pin(s *APISession) bool
Pin keeps a session resident while a caller is about to use it. The pool lock closes the gap between lookup and session locking, so idle eviction cannot replace a live session with a second instance.
func (*SessionPool) Put ¶
func (p *SessionPool) Put(s *APISession) error
Put adds a session to the pool. Returns an error if the pool is at capacity.
func (*SessionPool) Remove ¶
func (p *SessionPool) Remove(id string)
Remove removes a session by ID.
func (*SessionPool) RemoveByWorkDir ¶
func (p *SessionPool) RemoveByWorkDir(workDir, id string)
RemoveByWorkDir removes a session by workDir and ID.
func (*SessionPool) Replace ¶
func (p *SessionPool) Replace(oldID string, s *APISession)
Replace swaps an existing session entry for a new one.
func (*SessionPool) ReplaceByWorkDir ¶
func (p *SessionPool) ReplaceByWorkDir(workDir, oldID string, s *APISession)
ReplaceByWorkDir swaps an existing session entry for a new one.
func (*SessionPool) Unpin ¶ added in v1.1.62
func (p *SessionPool) Unpin(s *APISession)
Unpin releases a residency reference acquired by Pin.
type SessionRunEventEntry ¶
type SessionRunEventEntry struct {
Seq int64 `json:"seq,omitempty"`
ID string `json:"id"`
SessionID string `json:"sessionId"`
RunID string `json:"runId"`
EventType string `json:"eventType"`
Source string `json:"source,omitempty"`
Status string `json:"status,omitempty"`
Model string `json:"model,omitempty"`
Mode string `json:"mode,omitempty"`
Timestamp string `json:"timestamp"`
Data map[string]any `json:"data,omitempty"`
}
SessionRunEventEntry is the Web/API view of a run lifecycle event.
type SessionSubAgentInfo ¶
type SessionSubAgentInfo struct {
ID string `json:"id"`
ParentID string `json:"parentId,omitempty"`
Status string `json:"status"`
Active bool `json:"active"`
MessageCount int `json:"messageCount"`
LastResponse string `json:"lastResponse,omitempty"`
Error string `json:"error,omitempty"`
StartedAt string `json:"startedAt,omitempty"`
UpdatedAt string `json:"updatedAt,omitempty"`
}
SessionSubAgentInfo is the WebUI view of a managed sub-agent.
type SessionTaskPlan ¶
type SessionTaskPlan struct {
Title string `json:"title,omitempty"`
Steps []SessionPlanStep `json:"steps,omitempty"`
Note string `json:"note,omitempty"`
}
SessionTaskPlan is the WebUI view of a plan tool call.
type SessionToolOptions ¶
type SessionToolOptions struct {
WebSearch *bool `json:"webSearch,omitempty"`
Browser *bool `json:"browser,omitempty"`
A2AMaster *bool `json:"a2aMaster,omitempty"`
Delegate *bool `json:"delegate,omitempty"`
MultiAgent *bool `json:"multiAgent,omitempty"`
Workflows *bool `json:"workflows,omitempty"`
}
SessionToolOptions are per-session runtime tool toggles supplied by WebUI.
type SessionToolResultDetail ¶
type SessionToolResultDetail struct {
ToolCallID string `json:"toolCallId"`
ToolName string `json:"toolName,omitempty"`
Content string `json:"content,omitempty"`
Contents []provider.ContentBlock `json:"contents,omitempty"`
IsError bool `json:"isError,omitempty"`
}
SessionToolResultDetail contains the full persisted result for one tool call.
type SkillHubRuntime ¶ added in v1.1.66
type SkillHubRuntime struct {
GlobalSkillsDir string
DefaultWorkDir string
DefaultMarket string
DefaultScope string
OfficialHandles []string
}
SkillHubRuntime contains the serve settings needed by marketplace handlers.
type SkillHubSessionState ¶ added in v1.1.66
type SkillHubSessionState struct {
SessionID string `json:"sessionId"`
WorkDir string `json:"workDir"`
ActiveSkills []string `json:"activeSkills"`
}
SkillHubSessionState reports marketplace activation state for one API session.
type ToolStatusEvent ¶
type ToolStatusEvent struct {
Tool string `json:"tool"`
ToolCallID string `json:"toolCallId,omitempty"`
AgentID string `json:"agentId,omitempty"`
Status string `json:"status"` // "running", "completed", "failed"
Args map[string]any `json:"args,omitempty"`
Summary string `json:"summary,omitempty"`
IsError bool `json:"isError,omitempty"`
HasDetail bool `json:"hasDetail,omitempty"`
}
ToolStatusEvent is sent via SSE event: tool_status.
type ToolVisibilityConfig ¶
type ToolVisibilityConfig struct {
// Mode controls the transport for tool status:
// "content" (default) — tool output mixed into content stream
// "sse_event" — tool output via separate SSE events
// "none" — no tool output
Mode string `json:"mode,omitempty"`
// Detail controls the verbosity of tool output in content mode:
// "collapsed" (default) — one-line summary: 🔧 `read` main.go
// edit always shows path + diff
// "expanded" — full output with code fences (Ctrl+O style)
Detail string `json:"detail,omitempty"`
}
ToolVisibilityConfig controls how tool calls are exposed to the client.
type TranscriptStreamEvent ¶
type TranscriptStreamEvent struct {
Type string `json:"type"` // "assistant_delta" or "message"
XSessionID string `json:"x_session_id,omitempty"`
Message *SessionMessageEntry `json:"message,omitempty"`
}
TranscriptStreamEvent is a WebUI-oriented SSE event that mirrors the /api/sessions/{id}/messages entry shape while the response is still running.