Documentation
¶
Index ¶
- Constants
- type AgentInfo
- type AgentSpec
- type Connection
- type ContentBlock
- type ContextPolicy
- type Error
- type Event
- type EventPolicy
- type HistoryEvent
- type HistoryReplay
- type InitializeResult
- type Interaction
- type InteractionPolicy
- type InteractionStatus
- type Manager
- func (m *Manager) AgentInfo(ctx context.Context) (InitializeResult, error)
- func (m *Manager) AttachRemoteSession(remote RemoteSession) (SessionRecord, error)
- func (m *Manager) Authenticate(ctx context.Context, methodID string) error
- func (m *Manager) CancelPrompt(_ context.Context, sessionID, runID string) error
- func (m *Manager) Close() error
- func (m *Manager) CloseSession(ctx context.Context, id string) (SessionRecord, error)
- func (m *Manager) DeleteRemoteSession(ctx context.Context, remoteSessionID string) error
- func (m *Manager) DeleteSession(ctx context.Context, id string) error
- func (m *Manager) EnsureSessionActive(ctx context.Context, id string) (SessionResult, error)
- func (m *Manager) FindRemoteSession(ctx context.Context, remoteSessionID string) (RemoteSession, error)
- func (m *Manager) ForkSession(ctx context.Context, id, cwd string, additionalDirectories []string) (SessionResult, error)
- func (m *Manager) InspectInteraction(id string) (Interaction, error)
- func (m *Manager) InspectSession(id string) (SessionRecord, error)
- func (m *Manager) ListInteractions(sessionID string, pendingOnly bool) []Interaction
- func (m *Manager) ListManagedSessions() ([]SessionRecord, error)
- func (m *Manager) ListRemoteSessions(ctx context.Context, cwd, cursor string) (RemoteSessionPage, error)
- func (m *Manager) ListSessions() ([]SessionRecord, error)
- func (m *Manager) LoadSession(ctx context.Context, id string) (SessionResult, error)
- func (m *Manager) ManagedSessionForRemote(remoteSessionID string) (SessionRecord, bool)
- func (m *Manager) NewSession(ctx context.Context, cwd string, additionalDirectories []string) (SessionResult, error)
- func (m *Manager) OpenSession(ctx context.Context, sessionID, remoteSessionID string) (SessionResult, bool, error)
- func (m *Manager) PromptEvents(ctx context.Context, runID string, after uint64, limit int, wait time.Duration) (PromptEventsResult, error)
- func (m *Manager) ReadRemoteHistory(ctx context.Context, remoteSessionID, cwd string, ...) (HistoryReplay, sessionLifecycleResponse, error)
- func (m *Manager) RespondInteraction(id, optionID string, cancelled bool) (Interaction, error)
- func (m *Manager) ResumeSession(ctx context.Context, id string) (SessionResult, error)
- func (m *Manager) SessionProjection(sessionID string) (SessionProjection, error)
- func (m *Manager) SetSessionConfigOption(ctx context.Context, id, configID string, value any) (any, error)
- func (m *Manager) SetSessionMode(ctx context.Context, id, modeID string) error
- func (m *Manager) StartPrompt(ctx context.Context, sessionID, text string) (PromptStartResult, error)
- func (m *Manager) StartPromptBlocks(ctx context.Context, sessionID string, blocks []ContentBlock) (PromptStartResult, error)
- func (m *Manager) Steer(ctx context.Context, sessionID, text string) (map[string]any, error)
- func (m *Manager) SubmitPrompt(ctx context.Context, sessionID string, blocks []ContentBlock) (PromptStartResult, error)
- type NotificationHandler
- type Options
- type PermissionOption
- type PromptEventsResult
- type PromptStartResult
- type RemoteSession
- type RemoteSessionPage
- type RequestHandler
- type Run
- type RunStatus
- type RuntimePolicies
- type SessionProjection
- type SessionRecord
- type SessionResult
- type SessionStatus
- type SteeringPolicy
Constants ¶
const (
ProtocolVersion = 1
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func NewConnection ¶
func NewConnection(reader io.ReadCloser, writer io.WriteCloser, requestHandler RequestHandler, notificationHandler NotificationHandler) *Connection
func (*Connection) Close ¶
func (c *Connection) Close() error
func (*Connection) Closed ¶
func (c *Connection) Closed() <-chan struct{}
type ContentBlock ¶ added in v0.9.0
ContentBlock 保留 ACP/MCP ContentBlock 的开放字段,但在进入协议层前按 type 与 initialize.promptCapabilities 做严格能力校验。动态 map 只停留在协议边界。
func TextBlock ¶ added in v0.9.0
func TextBlock(text string) ContentBlock
type ContextPolicy ¶
type ContextPolicy struct {
HistoryOwner string `json:"history_owner"`
AgentDockPersistsTranscript bool `json:"agentdock_persists_transcript"`
AgentDockReplaysTranscript bool `json:"agentdock_replays_transcript"`
ManagedSessionAutoReactivates bool `json:"managed_session_auto_reactivates"`
HistoryReadUsesAdapterLoad bool `json:"history_read_uses_adapter_load"`
}
type Event ¶
type Event struct {
Seq uint64 `json:"seq"`
Source string `json:"source"`
Type string `json:"type"`
SessionID string `json:"session_id"`
RunID string `json:"run_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
Update json.RawMessage `json:"update,omitempty"`
UpdateTruncated bool `json:"update_truncated,omitempty"`
OriginalUpdateBytes int `json:"original_update_bytes,omitempty"`
StopReason string `json:"stop_reason,omitempty"`
ErrorCode string `json:"error_code,omitempty"`
Message string `json:"message,omitempty"`
}
type EventPolicy ¶
type EventPolicy struct {
Incremental bool `json:"incremental"`
Cursor string `json:"cursor"`
MaxEventsPerPage int `json:"max_events_per_page"`
MaxRetainedEvents int `json:"max_retained_events"`
MaxRetainedBytes int `json:"max_retained_bytes"`
MaxUpdateBytes int `json:"max_update_bytes"`
PrivateReasoningFiltered bool `json:"private_reasoning_filtered"`
}
type HistoryEvent ¶ added in v0.9.0
type HistoryEvent struct {
Source string `json:"source"`
Type string `json:"type"`
Update json.RawMessage `json:"update"`
UpdateTruncated bool `json:"update_truncated,omitempty"`
OriginalUpdateBytes int `json:"original_update_bytes,omitempty"`
}
HistoryEvent 是一次 session/load 期间由 Adapter 回放的原生会话事件。 AgentDock 只在当前调用内暂存这些事件,不把 transcript 写入本地 SessionRecord。
type HistoryReplay ¶ added in v0.9.0
type HistoryReplay struct {
Events []HistoryEvent `json:"events"`
Truncated bool `json:"truncated"`
}
type InitializeResult ¶
type Interaction ¶
type Interaction struct {
ID string `json:"id"`
SessionID string `json:"session_id"`
Kind string `json:"kind"`
Status InteractionStatus `json:"status"`
ToolCall map[string]any `json:"tool_call,omitempty"`
Options []PermissionOption `json:"options,omitempty"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
// contains filtered or unexported fields
}
type InteractionPolicy ¶
type InteractionPolicy struct {
MemoryOnly bool `json:"memory_only"`
MaxOptions int `json:"max_options"`
MaxToolCallBytes int `json:"max_tool_call_bytes"`
MaxPendingGlobal int `json:"max_pending_global"`
MaxPendingPerSession int `json:"max_pending_per_session"`
AlwaysOptionsFiltered bool `json:"always_options_filtered"`
ElicitationAdvertised bool `json:"elicitation_advertised"`
}
type InteractionStatus ¶
type InteractionStatus string
const ( InteractionPending InteractionStatus = "pending" InteractionResponded InteractionStatus = "responded" InteractionCancelled InteractionStatus = "cancelled" InteractionExpired InteractionStatus = "expired" )
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) AgentInfo ¶
func (m *Manager) AgentInfo(ctx context.Context) (InitializeResult, error)
func (*Manager) AttachRemoteSession ¶ added in v0.9.0
func (m *Manager) AttachRemoteSession(remote RemoteSession) (SessionRecord, error)
func (*Manager) Authenticate ¶
func (*Manager) CancelPrompt ¶
func (*Manager) CloseSession ¶
func (*Manager) DeleteRemoteSession ¶ added in v0.9.0
DeleteRemoteSession 删除 Adapter 原生会话。若该 remote session 已经被 AgentDock 管理,则复用 DeleteSession 保证本地映射与持久化记录同步清理;否则只调用标准 session/delete。该方法绝不把“Adapter 不支持 delete”静默降级为本地解绑。
func (*Manager) DeleteSession ¶
func (*Manager) EnsureSessionActive ¶ added in v0.9.0
EnsureSessionActive 只负责让已 managed 的会话可继续执行,不要求调用方理解 ACP 的 load/resume 差异。优先使用 resume 避免无意义的历史回放;仅当 Adapter 没有 resume 时才退回标准 session/load。
func (*Manager) FindRemoteSession ¶ added in v0.9.0
func (*Manager) ForkSession ¶
func (*Manager) InspectInteraction ¶
func (m *Manager) InspectInteraction(id string) (Interaction, error)
func (*Manager) InspectSession ¶
func (m *Manager) InspectSession(id string) (SessionRecord, error)
func (*Manager) ListInteractions ¶
func (m *Manager) ListInteractions(sessionID string, pendingOnly bool) []Interaction
func (*Manager) ListManagedSessions ¶ added in v0.9.0
func (m *Manager) ListManagedSessions() ([]SessionRecord, error)
func (*Manager) ListRemoteSessions ¶ added in v0.9.0
func (*Manager) ListSessions ¶
func (m *Manager) ListSessions() ([]SessionRecord, error)
ListSessions 保留为内部兼容别名。工具层的 list 已经不再把它误认为 ACP session/list。
func (*Manager) LoadSession ¶
func (*Manager) ManagedSessionForRemote ¶ added in v0.9.0
func (m *Manager) ManagedSessionForRemote(remoteSessionID string) (SessionRecord, bool)
func (*Manager) NewSession ¶
func (*Manager) OpenSession ¶ added in v0.9.0
func (m *Manager) OpenSession(ctx context.Context, sessionID, remoteSessionID string) (SessionResult, bool, error)
OpenSession 接受 AgentDock session id 或 Adapter 原生 remote id。 对 remote id,AgentDock 只建立轻量映射,不复制 transcript,再自动选择 resume/load 激活。
func (*Manager) PromptEvents ¶
func (*Manager) ReadRemoteHistory ¶ added in v0.9.0
func (m *Manager) ReadRemoteHistory(ctx context.Context, remoteSessionID, cwd string, additionalDirectories []string) (HistoryReplay, sessionLifecycleResponse, error)
ReadRemoteHistory 显式调用标准 session/load,并只收集该调用期间 Adapter 回放的 session/update。它不会创建 acps_* 映射,也不会把历史写入 AgentDock 持久化状态。
func (*Manager) RespondInteraction ¶
func (m *Manager) RespondInteraction(id, optionID string, cancelled bool) (Interaction, error)
func (*Manager) ResumeSession ¶
func (*Manager) SessionProjection ¶ added in v0.9.0
func (m *Manager) SessionProjection(sessionID string) (SessionProjection, error)
func (*Manager) SetSessionConfigOption ¶
func (*Manager) SetSessionMode ¶
func (*Manager) StartPrompt ¶
func (*Manager) StartPromptBlocks ¶ added in v0.9.0
func (m *Manager) StartPromptBlocks(ctx context.Context, sessionID string, blocks []ContentBlock) (PromptStartResult, error)
func (*Manager) SubmitPrompt ¶ added in v0.9.0
func (m *Manager) SubmitPrompt(ctx context.Context, sessionID string, blocks []ContentBlock) (PromptStartResult, error)
SubmitPrompt 是工具层唯一的 prompt 入口:空闲时启动新的 session/prompt;已有 active Run 时仅在 Adapter 广告 steering 扩展且输入为纯文本时自动注入当前 Run。
type NotificationHandler ¶
type NotificationHandler func(string, json.RawMessage)
type PermissionOption ¶
type PromptEventsResult ¶
type PromptEventsResult struct {
RunID string `json:"run_id"`
SessionID string `json:"session_id"`
Status RunStatus `json:"status"`
Events []Event `json:"events"`
NextSeq uint64 `json:"next_seq"`
FirstSeq uint64 `json:"first_seq"`
LatestSeq uint64 `json:"latest_seq"`
DroppedCount uint64 `json:"dropped_count"`
HasMore bool `json:"has_more"`
Truncated bool `json:"truncated"`
StartedAt time.Time `json:"started_at"`
EndedAt *time.Time `json:"ended_at,omitempty"`
StopReason string `json:"stop_reason,omitempty"`
ErrorCode string `json:"error_code,omitempty"`
Message string `json:"message,omitempty"`
CancelRequested bool `json:"cancel_requested"`
}
type PromptStartResult ¶
type RemoteSession ¶ added in v0.9.0
type RemoteSession struct {
RemoteSessionID string `json:"remote_session_id"`
CWD string `json:"cwd"`
AdditionalDirectories []string `json:"additional_directories,omitempty"`
Title string `json:"title,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
Meta map[string]any `json:"_meta,omitempty"`
Managed bool `json:"managed"`
SessionID string `json:"session_id,omitempty"`
}
RemoteSession 描述 Adapter 通过标准 session/list 暴露的原生会话。 SessionID 只有在该 remote session 已经被 AgentDock 管理时才会出现。
type RemoteSessionPage ¶ added in v0.9.0
type RemoteSessionPage struct {
Sessions []RemoteSession `json:"sessions"`
NextCursor string `json:"next_cursor,omitempty"`
}
type RequestHandler ¶
type RuntimePolicies ¶
type RuntimePolicies struct {
Context ContextPolicy `json:"context_policy"`
Events EventPolicy `json:"event_policy"`
Interactions InteractionPolicy `json:"interaction_policy"`
Steering SteeringPolicy `json:"steering_policy"`
}
RuntimePolicies is the machine-readable contract returned by acp_session info. Values are derived from the same constants that enforce the runtime, keeping client guidance and server behavior in one source of truth.
func CurrentPolicies ¶
func CurrentPolicies() RuntimePolicies
type SessionProjection ¶ added in v0.9.0
type SessionProjection struct {
ModeID string `json:"mode_id,omitempty"`
ConfigOptions any `json:"config_options,omitempty"`
AvailableCommands any `json:"available_commands,omitempty"`
SessionInfo map[string]any `json:"session_info,omitempty"`
Usage map[string]any `json:"usage,omitempty"`
}
SessionProjection is bounded, process-local Adapter state derived from standard session/update notifications. It is not a transcript and is never treated as a second source of truth for conversation history.
type SessionRecord ¶
type SessionRecord struct {
SchemaVersion int `json:"schema_version"`
ID string `json:"id"`
Agent string `json:"agent"`
RemoteSessionID string `json:"remote_session_id"`
CWD string `json:"cwd"`
AdditionalDirectories []string `json:"additional_directories,omitempty"`
ModeID string `json:"mode_id,omitempty"`
Status SessionStatus `json:"status"`
LastStopReason string `json:"last_stop_reason,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ClosedAt *time.Time `json:"closed_at,omitempty"`
}
type SessionResult ¶
type SessionResult struct {
Session SessionRecord `json:"session"`
Modes any `json:"modes,omitempty"`
ConfigOptions any `json:"config_options,omitempty"`
History HistoryReplay `json:"history,omitempty"`
Agent AgentInfo `json:"agent"`
}
type SessionStatus ¶
type SessionStatus string
const ( SessionReady SessionStatus = "ready" SessionRunning SessionStatus = "running" SessionInterrupted SessionStatus = "interrupted" SessionClosed SessionStatus = "closed" SessionError SessionStatus = "error" )
type SteeringPolicy ¶
Source Files
¶
- capabilities.go
- compatibility.go
- connection.go
- history.go
- interactions.go
- manager.go
- notifications.go
- path.go
- policies.go
- process.go
- process_start_unix.go
- prompt_content.go
- prompt_recovery.go
- prompt_settle.go
- prompts.go
- session_catalog.go
- session_delete.go
- session_open.go
- session_projection.go
- sessions.go
- store.go
- types.go