acpserver

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package acpserver implements the JSON-RPC agent control protocol server.

Package acpserver implements Codog's line-delimited JSON-RPC ACP bridge.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(ctx context.Context, in io.Reader, out io.Writer, handlers Handlers, opts Options) error

Serve processes line-delimited JSON-RPC ACP requests from in and writes responses to out.

Types

type AgentRunHeartbeatRequest

type AgentRunHeartbeatRequest struct {
	ID             string                     `json:"id"`
	Status         string                     `json:"status,omitempty"`
	TransportAlive *bool                      `json:"transport_alive,omitempty"`
	ObservedAt     *time.Time                 `json:"observed_at,omitempty"`
	Provenance     background.EventProvenance `json:"provenance,omitempty"`
	SourceKind     string                     `json:"source_kind,omitempty"`
	Environment    string                     `json:"environment,omitempty"`
	Channel        string                     `json:"channel,omitempty"`
	Emitter        string                     `json:"emitter,omitempty"`
	Confidence     string                     `json:"confidence,omitempty"`
}

AgentRunHeartbeatRequest updates an agent run heartbeat.

type AgentRunIDRequest

type AgentRunIDRequest struct {
	ID string `json:"id"`
}

AgentRunIDRequest identifies one agent run.

type AgentRunLogsRequest

type AgentRunLogsRequest struct {
	ID    string `json:"id"`
	Limit int64  `json:"limit,omitempty"`
}

AgentRunLogsRequest reads logs for an agent run.

type AgentRunsBoardRequest

type AgentRunsBoardRequest struct {
	Agent               string `json:"agent,omitempty"`
	SessionID           string `json:"session_id,omitempty"`
	StalledAfterSeconds int    `json:"stalled_after_seconds,omitempty"`
	StalledAfterMS      int    `json:"stalled_after_ms,omitempty"`
}

AgentRunsBoardRequest controls agent run lane board rendering.

type AgentRunsListRequest

type AgentRunsListRequest struct {
	Agent     string `json:"agent,omitempty"`
	SessionID string `json:"session_id,omitempty"`
}

AgentRunsListRequest filters agent run listing.

type AgentRunsPruneRequest

type AgentRunsPruneRequest struct {
	OlderThanSeconds int  `json:"older_than_seconds,omitempty"`
	OlderThanDays    int  `json:"older_than_days,omitempty"`
	Keep             *int `json:"keep,omitempty"`
}

AgentRunsPruneRequest controls agent run cleanup.

type BackgroundBoardRequest

type BackgroundBoardRequest struct {
	StalledAfterSeconds int `json:"stalled_after_seconds,omitempty"`
	StalledAfterMS      int `json:"stalled_after_ms,omitempty"`
}

BackgroundBoardRequest controls background lane board rendering.

type BackgroundHeartbeatRequest

type BackgroundHeartbeatRequest struct {
	ID             string                     `json:"id"`
	Status         string                     `json:"status,omitempty"`
	TransportAlive *bool                      `json:"transport_alive,omitempty"`
	ObservedAt     *time.Time                 `json:"observed_at,omitempty"`
	Provenance     background.EventProvenance `json:"provenance,omitempty"`
	SourceKind     string                     `json:"source_kind,omitempty"`
	Environment    string                     `json:"environment,omitempty"`
	Channel        string                     `json:"channel,omitempty"`
	Emitter        string                     `json:"emitter,omitempty"`
	Confidence     string                     `json:"confidence,omitempty"`
}

BackgroundHeartbeatRequest updates task heartbeat state.

type BackgroundIDRequest

type BackgroundIDRequest struct {
	ID string `json:"id"`
}

BackgroundIDRequest identifies a background task.

type BackgroundListRequest

type BackgroundListRequest struct {
	SessionID string `json:"session_id,omitempty"`
	Kind      string `json:"kind,omitempty"`
}

BackgroundListRequest filters background task listing.

type BackgroundLogsRequest

type BackgroundLogsRequest struct {
	ID    string `json:"id"`
	Limit int64  `json:"limit,omitempty"`
}

BackgroundLogsRequest reads bounded task logs.

type BackgroundPruneRequest

type BackgroundPruneRequest struct {
	OlderThanSeconds int  `json:"older_than_seconds,omitempty"`
	OlderThanDays    int  `json:"older_than_days,omitempty"`
	Keep             *int `json:"keep,omitempty"`
}

BackgroundPruneRequest controls background task cleanup.

type BackgroundRunRequest

type BackgroundRunRequest struct {
	Command       string                    `json:"command"`
	Kind          string                    `json:"kind,omitempty"`
	SessionID     string                    `json:"session_id,omitempty"`
	RestartPolicy *background.RestartPolicy `json:"restart_policy,omitempty"`
	ScopeBinding  background.ScopeBinding   `json:"scope_binding,omitempty"`
	Owner         string                    `json:"owner,omitempty"`
	WorkflowScope string                    `json:"workflow_scope,omitempty"`
	WatcherAction string                    `json:"watcher_action,omitempty"`
}

BackgroundRunRequest starts a background task.

type BackgroundSuperviseRequest

type BackgroundSuperviseRequest struct {
	Now *time.Time `json:"now,omitempty"`
}

BackgroundSuperviseRequest runs one background supervision pass.

type BackgroundWatchRequest

type BackgroundWatchRequest struct {
	ID         string `json:"id"`
	Offset     int64  `json:"offset,omitempty"`
	IntervalMS int    `json:"interval_ms,omitempty"`
	MaxEvents  int    `json:"max_events,omitempty"`
}

BackgroundWatchRequest streams background task events.

type BridgeFaultRecordRequest

type BridgeFaultRecordRequest struct {
	Action string   `json:"action"`
	Args   []string `json:"args,omitempty"`
}

BridgeFaultRecordRequest records an editor bridge diagnostic fault.

type CodeCompletionRequest

type CodeCompletionRequest struct {
	Query string `json:"query"`
	Limit int    `json:"limit,omitempty"`
}

CodeCompletionRequest controls code completion suggestions.

type CodeDefinitionRequest

type CodeDefinitionRequest struct {
	Symbol string `json:"symbol"`
}

CodeDefinitionRequest controls definition lookup.

type CodeFormatRequest

type CodeFormatRequest struct {
	Path  string `json:"path"`
	Write bool   `json:"write,omitempty"`
}

CodeFormatRequest controls code formatting.

type CodeHoverRequest

type CodeHoverRequest struct {
	Symbol       string `json:"symbol"`
	ContextLines int    `json:"context_lines,omitempty"`
}

CodeHoverRequest controls hover information lookup.

type CodeReferencesRequest

type CodeReferencesRequest struct {
	Symbol string `json:"symbol"`
	Limit  int    `json:"limit,omitempty"`
}

CodeReferencesRequest controls reference lookup.

type CodeSymbolsRequest

type CodeSymbolsRequest struct {
	Path string `json:"path,omitempty"`
}

CodeSymbolsRequest controls symbol discovery.

type DiagnosticsRequest

type DiagnosticsRequest struct {
	Patterns []string `json:"patterns,omitempty"`
}

DiagnosticsRequest controls Go diagnostics.

type EditorIdentifyRequest

type EditorIdentifyRequest struct {
	Editor    string `json:"editor"`
	Version   string `json:"version,omitempty"`
	Workspace string `json:"workspace,omitempty"`
	Token     string `json:"token,omitempty"`
}

EditorIdentifyRequest establishes a trusted editor bridge identity.

type EditorOpenRequest

type EditorOpenRequest struct {
	Path string `json:"path"`
}

EditorOpenRequest records the active editor file.

type EditorSelectionRequest

type EditorSelectionRequest struct {
	Path        string `json:"path,omitempty"`
	StartLine   int    `json:"start_line"`
	StartColumn int    `json:"start_column,omitempty"`
	EndLine     int    `json:"end_line,omitempty"`
	EndColumn   int    `json:"end_column,omitempty"`
	Text        string `json:"text,omitempty"`
}

EditorSelectionRequest records an editor selection.

type Handlers

type Handlers struct {
	NewSession           func(context.Context) (SessionInfo, error)
	OpenSession          func(context.Context, SessionOpenRequest) (SessionDetail, error)
	ListSessions         func(context.Context) (SessionList, error)
	GetSession           func(context.Context, SessionLookupRequest) (SessionDetail, error)
	History              func(context.Context, SessionHistoryRequest) (SessionHistory, error)
	AppendMessage        func(context.Context, SessionAppendMessageRequest) (SessionMutationResult, error)
	AppendInput          func(context.Context, SessionAppendInputRequest) (SessionMutationResult, error)
	RewindSession        func(context.Context, SessionRewindRequest) (SessionRewindResult, error)
	ForkSession          func(context.Context, SessionForkRequest) (SessionMutationResult, error)
	RenameSession        func(context.Context, SessionRenameRequest) (SessionMutationResult, error)
	DeleteSession        func(context.Context, SessionLookupRequest) (SessionMutationResult, error)
	PruneSessions        func(context.Context, SessionPruneRequest) (any, error)
	Prompt               func(context.Context, PromptRequest) (PromptResult, error)
	Status               func(context.Context) (any, error)
	WorkspaceInfo        func(context.Context) (workspaceops.InfoResult, error)
	WorkspaceFiles       func(context.Context, workspaceops.FilesOptions) (workspaceops.FilesResult, error)
	WorkspaceSearch      func(context.Context, workspaceops.SearchOptions) (workspaceops.SearchResult, error)
	FileRead             func(context.Context, workspaceops.ReadOptions) (workspaceops.ReadResult, error)
	FileWrite            func(context.Context, workspaceops.WriteOptions) (workspaceops.WriteResult, error)
	FileEdit             func(context.Context, workspaceops.EditOptions) (workspaceops.EditResult, error)
	FileDiff             func(context.Context, workspaceops.DiffOptions) (workspaceops.DiffResult, error)
	DiagnosticsGo        func(context.Context, DiagnosticsRequest) (any, error)
	CodeSymbols          func(context.Context, CodeSymbolsRequest) (any, error)
	CodeReferences       func(context.Context, CodeReferencesRequest) (any, error)
	CodeDefinition       func(context.Context, CodeDefinitionRequest) (any, error)
	CodeHover            func(context.Context, CodeHoverRequest) (any, error)
	CodeCompletion       func(context.Context, CodeCompletionRequest) (any, error)
	CodeFormat           func(context.Context, CodeFormatRequest) (any, error)
	NotebookRead         func(context.Context, NotebookReadRequest) (any, error)
	NotebookEdit         func(context.Context, NotebookEditRequest) (any, error)
	LSPActions           func(context.Context) (any, error)
	LSPDiscover          func(context.Context) (any, error)
	LSPList              func(context.Context) (any, error)
	LSPStart             func(context.Context, LSPStartRequest) (any, error)
	LSPStatus            func(context.Context, LSPStatusRequest) (any, error)
	LSPStop              func(context.Context, LSPStopRequest) (any, error)
	LSPQuery             func(context.Context, LSPQueryRequest) (any, error)
	BackgroundList       func(context.Context, BackgroundListRequest) (any, error)
	BackgroundRun        func(context.Context, BackgroundRunRequest) (any, error)
	BackgroundGet        func(context.Context, BackgroundIDRequest) (any, error)
	BackgroundLogs       func(context.Context, BackgroundLogsRequest) (any, error)
	BackgroundBoard      func(context.Context, BackgroundBoardRequest) (any, error)
	BackgroundHeartbeat  func(context.Context, BackgroundHeartbeatRequest) (any, error)
	BackgroundStop       func(context.Context, BackgroundIDRequest) (any, error)
	BackgroundRestart    func(context.Context, BackgroundIDRequest) (any, error)
	BackgroundPrune      func(context.Context, BackgroundPruneRequest) (any, error)
	BackgroundSupervise  func(context.Context, BackgroundSuperviseRequest) (any, error)
	BackgroundWatch      func(context.Context, BackgroundWatchRequest, func(background.WatchEvent) error) (any, error)
	AgentRunsList        func(context.Context, AgentRunsListRequest) (any, error)
	AgentRunsGet         func(context.Context, AgentRunIDRequest) (any, error)
	AgentRunsLogs        func(context.Context, AgentRunLogsRequest) (any, error)
	AgentRunsBoard       func(context.Context, AgentRunsBoardRequest) (any, error)
	AgentRunsHeartbeat   func(context.Context, AgentRunHeartbeatRequest) (any, error)
	AgentRunsStop        func(context.Context, AgentRunIDRequest) (any, error)
	AgentRunsPrune       func(context.Context, AgentRunsPruneRequest) (any, error)
	MCPList              func(context.Context, MCPListRequest) (any, error)
	MCPShow              func(context.Context, MCPServerRequest) (any, error)
	MCPAuth              func(context.Context, MCPServerRequest) (any, error)
	MCPTools             func(context.Context, MCPServerRequest) (any, error)
	MCPCall              func(context.Context, MCPCallRequest) (any, error)
	MCPResources         func(context.Context, MCPServerRequest) (any, error)
	MCPResourceTemplates func(context.Context, MCPServerRequest) (any, error)
	MCPRead              func(context.Context, MCPReadRequest) (any, error)
	MCPPrompts           func(context.Context, MCPServerRequest) (any, error)
	MCPPrompt            func(context.Context, MCPPromptRequest) (any, error)
	EditorIdentify       func(context.Context, EditorIdentifyRequest) (any, error)
	EditorState          func(context.Context) (any, error)
	EditorOpen           func(context.Context, EditorOpenRequest) (any, error)
	EditorSelection      func(context.Context, EditorSelectionRequest) (any, error)
	BridgeFaultsList     func(context.Context) (any, error)
	BridgeFaultsRecord   func(context.Context, BridgeFaultRecordRequest) (any, error)
	BridgeFaultsClear    func(context.Context) (any, error)
}

Handlers contains application callbacks for each ACP method.

type LSPQueryRequest

type LSPQueryRequest struct {
	Language        string `json:"language"`
	Action          string `json:"action"`
	Path            string `json:"path,omitempty"`
	FilePath        string `json:"file_path,omitempty"`
	Query           string `json:"query,omitempty"`
	Arguments       []any  `json:"arguments,omitempty"`
	Line            int    `json:"line,omitempty"`
	Character       int    `json:"character,omitempty"`
	NewName         string `json:"new_name,omitempty"`
	CodeActionTitle string `json:"code_action_title,omitempty"`
	Apply           bool   `json:"apply,omitempty"`
	Write           bool   `json:"write,omitempty"`
	TimeoutMS       int    `json:"timeout_ms,omitempty"`
}

LSPQueryRequest sends a typed request to a language server.

type LSPStartRequest

type LSPStartRequest struct {
	Language    string   `json:"language"`
	CommandArgs []string `json:"command_args,omitempty"`
}

LSPStartRequest starts a language server process.

type LSPStatusRequest

type LSPStatusRequest struct {
	Language string `json:"language"`
}

LSPStatusRequest identifies a language server status query.

type LSPStopRequest

type LSPStopRequest struct {
	Language string `json:"language"`
}

LSPStopRequest identifies a language server stop request.

type MCPCallRequest

type MCPCallRequest struct {
	Server    string          `json:"server,omitempty"`
	Tool      string          `json:"tool"`
	Arguments json.RawMessage `json:"arguments,omitempty"`
}

MCPCallRequest invokes an MCP tool.

type MCPListRequest

type MCPListRequest struct {
	Inspect *bool `json:"inspect,omitempty"`
}

MCPListRequest controls MCP server listing.

type MCPPromptRequest

type MCPPromptRequest struct {
	Server    string          `json:"server,omitempty"`
	Prompt    string          `json:"prompt,omitempty"`
	Name      string          `json:"name,omitempty"`
	Arguments json.RawMessage `json:"arguments,omitempty"`
}

MCPPromptRequest renders an MCP prompt.

type MCPReadRequest

type MCPReadRequest struct {
	Server string `json:"server,omitempty"`
	URI    string `json:"uri"`
}

MCPReadRequest reads an MCP resource.

type MCPServerRequest

type MCPServerRequest struct {
	Server string `json:"server,omitempty"`
	Name   string `json:"name,omitempty"`
}

MCPServerRequest identifies an MCP server by server or name.

type NotebookEditRequest

type NotebookEditRequest struct {
	Path         string  `json:"path,omitempty"`
	NotebookPath string  `json:"notebook_path,omitempty"`
	Mode         string  `json:"mode,omitempty"`
	EditMode     string  `json:"edit_mode,omitempty"`
	CellIndex    *int    `json:"cell_index,omitempty"`
	Index        *int    `json:"index,omitempty"`
	CellID       string  `json:"cell_id,omitempty"`
	CellType     string  `json:"cell_type,omitempty"`
	Type         string  `json:"type,omitempty"`
	Source       *string `json:"source,omitempty"`
	NewSource    *string `json:"new_source,omitempty"`
}

NotebookEditRequest controls notebook cell mutations.

type NotebookReadRequest

type NotebookReadRequest struct {
	Path           string `json:"path,omitempty"`
	NotebookPath   string `json:"notebook_path,omitempty"`
	CellIndex      *int   `json:"cell_index,omitempty"`
	Index          *int   `json:"index,omitempty"`
	Limit          int    `json:"limit,omitempty"`
	IncludeOutputs bool   `json:"include_outputs,omitempty"`
	Outputs        *bool  `json:"outputs,omitempty"`
}

NotebookReadRequest controls notebook cell reads.

type Options

type Options struct {
	Version   string
	Workspace string
}

Options configures server metadata returned by initialize and status calls.

type PromptRequest

type PromptRequest struct {
	SessionID string `json:"session_id,omitempty"`
	Prompt    string `json:"prompt"`
}

PromptRequest sends one prompt to the agent runtime.

type PromptResult

type PromptResult struct {
	SessionID string `json:"session_id"`
	Output    string `json:"output"`
}

PromptResult contains the assistant output for a prompt call.

type SessionAppendInputRequest

type SessionAppendInputRequest struct {
	SessionID string `json:"session_id"`
	Input     string `json:"input"`
}

SessionAppendInputRequest appends user input to a session.

type SessionAppendMessageRequest

type SessionAppendMessageRequest struct {
	SessionID string             `json:"session_id"`
	Message   *anthropic.Message `json:"message,omitempty"`
	Role      string             `json:"role,omitempty"`
	Text      string             `json:"text,omitempty"`
}

SessionAppendMessageRequest appends a structured or text message.

type SessionDetail

type SessionDetail struct {
	SessionID           string           `json:"session_id"`
	Workspace           string           `json:"workspace,omitempty"`
	Path                string           `json:"path,omitempty"`
	MessageCount        int              `json:"message_count"`
	CreatedAtMS         int64            `json:"created_at_ms,omitempty"`
	UpdatedAtMS         int64            `json:"updated_at_ms,omitempty"`
	ModifiedEpochMillis int64            `json:"modified_epoch_millis,omitempty"`
	ParentSessionID     string           `json:"parent_session_id,omitempty"`
	BranchName          string           `json:"branch_name,omitempty"`
	Lifecycle           SessionLifecycle `json:"lifecycle"`
	Messages            any              `json:"messages,omitempty"`
}

SessionDetail contains session metadata and optional message history.

type SessionForkRequest

type SessionForkRequest struct {
	SessionID  string `json:"session_id"`
	BranchName string `json:"branch_name,omitempty"`
}

SessionForkRequest creates a session branch from an existing session.

type SessionHistory

type SessionHistory struct {
	Kind      string `json:"kind"`
	SessionID string `json:"session_id"`
	Count     int    `json:"count"`
	Entries   any    `json:"entries"`
}

SessionHistory contains normalized history entries for a session.

type SessionHistoryRequest

type SessionHistoryRequest struct {
	SessionID string `json:"session_id,omitempty"`
	Limit     int    `json:"limit,omitempty"`
}

SessionHistoryRequest controls a bounded history lookup.

type SessionInfo

type SessionInfo struct {
	SessionID string `json:"session_id"`
	Workspace string `json:"workspace,omitempty"`
}

SessionInfo describes a newly opened or created session.

type SessionLifecycle

type SessionLifecycle struct {
	Kind      string `json:"kind"`
	Signal    string `json:"signal"`
	Saved     bool   `json:"saved"`
	Abandoned bool   `json:"abandoned"`
}

SessionLifecycle describes the persistence state of a session.

type SessionList

type SessionList struct {
	Kind      string           `json:"kind"`
	Count     int              `json:"count"`
	Sessions  []SessionSummary `json:"sessions"`
	Workspace string           `json:"workspace,omitempty"`
}

SessionList contains sessions visible to the ACP client.

type SessionLookupRequest

type SessionLookupRequest struct {
	SessionID string `json:"session_id,omitempty"`
}

SessionLookupRequest identifies one session.

type SessionMutationResult

type SessionMutationResult struct {
	Kind         string `json:"kind"`
	Action       string `json:"action"`
	Status       string `json:"status"`
	SessionID    string `json:"session_id,omitempty"`
	NewSessionID string `json:"new_session_id,omitempty"`
	Path         string `json:"path,omitempty"`
	MessageCount int    `json:"message_count,omitempty"`
}

SessionMutationResult reports a session mutation.

type SessionOpenRequest

type SessionOpenRequest struct {
	SessionID string `json:"session_id,omitempty"`
}

SessionOpenRequest identifies a session to open or resume.

type SessionPruneRequest

type SessionPruneRequest struct {
	Keep      int    `json:"keep,omitempty"`
	EmptyOnly *bool  `json:"empty_only,omitempty"`
	Confirm   bool   `json:"confirm,omitempty"`
	ExcludeID string `json:"exclude_id,omitempty"`
}

SessionPruneRequest controls session retention cleanup.

type SessionRenameRequest

type SessionRenameRequest struct {
	SessionID    string `json:"session_id"`
	NewSessionID string `json:"new_session_id"`
}

SessionRenameRequest renames an existing session.

type SessionRewindRequest

type SessionRewindRequest struct {
	SessionID      string `json:"session_id"`
	RemoveMessages int    `json:"remove_messages"`
}

SessionRewindRequest removes recent messages from a session.

type SessionRewindResult

type SessionRewindResult struct {
	Kind              string `json:"kind"`
	Action            string `json:"action"`
	Status            string `json:"status"`
	SessionID         string `json:"session_id"`
	Path              string `json:"path,omitempty"`
	OriginalMessages  int    `json:"original_messages"`
	RemainingMessages int    `json:"remaining_messages"`
	RemovedMessages   int    `json:"removed_messages"`
}

SessionRewindResult reports a completed rewind mutation.

type SessionSummary

type SessionSummary struct {
	SessionID           string           `json:"session_id"`
	Workspace           string           `json:"workspace,omitempty"`
	Path                string           `json:"path,omitempty"`
	MessageCount        int              `json:"message_count"`
	CreatedAtMS         int64            `json:"created_at_ms,omitempty"`
	UpdatedAtMS         int64            `json:"updated_at_ms,omitempty"`
	ModifiedEpochMillis int64            `json:"modified_epoch_millis,omitempty"`
	ParentSessionID     string           `json:"parent_session_id,omitempty"`
	BranchName          string           `json:"branch_name,omitempty"`
	Lifecycle           SessionLifecycle `json:"lifecycle"`
}

SessionSummary is a compact session record for list responses.

Jump to

Keyboard shortcuts

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