Documentation
¶
Index ¶
- Constants
- Variables
- func AgentToolExecutors(app *Core) []tools.Executor
- func AwaitToolExecutors(app *Core) []tools.Executor
- func CoreSessionIsExternalAgent(session Session) bool
- func MemoryToolExecutors(app *Core) []tools.Executor
- func RunsUnattended(session Session) bool
- func TodoToolExecutors(app *Core) []tools.Executor
- type AcceptRunErrorResponse
- type AcceptRunResult
- type AcceptRunStatus
- type AdminRestartRequest
- type AgentInput
- type AgentResult
- type Approval
- type ApprovalDeliveryPayload
- type ApprovalResolveRequest
- type ApprovalResponse
- type ApprovalState
- type ApprovalStore
- type ApprovalsResponse
- type AssistantProfile
- type BindingStore
- type BusyInputMode
- type ClientBinding
- type ClientBindingResponse
- type ClientCapabilities
- type ClientDeliveriesResponse
- type ClientDelivery
- type ClientDeliveryFailRequest
- type ClientDeliveryFilter
- type ClientDeliveryStatus
- type ClientDeliveryTarget
- type ClientSnapshot
- type ClientSnapshotResponse
- type CommitRealtimeVoiceTurnInput
- type CommitRealtimeVoiceTurnResult
- type CompactSessionResult
- type ContextBlock
- type ContextBlockKind
- type ContextCompact
- type ContextReport
- type ContextUsage
- type Core
- func (c *Core) AcceptRun(ctx context.Context, input HandleMessageInput) (AcceptRunResult, error)
- func (c *Core) AcceptTriggeredRun(ctx context.Context, input HandleTriggeredRunInput) (AcceptRunResult, error)
- func (c *Core) AcknowledgeClientDelivery(ctx context.Context, deliveryID string) error
- func (c *Core) AddPermissionRule(ctx context.Context, sessionID string, request PermissionRuleRequest) (permission.Rule, error)
- func (c *Core) CancelRun(ctx context.Context, runID string) (Run, error)
- func (c *Core) CancelTask(ctx context.Context, taskID string) (Task, error)
- func (c *Core) ClearContext(ctx context.Context, sessionID string) (transcript.Message, error)
- func (c *Core) ClearSessionTodo(ctx context.Context, sessionID string) (todo.List, error)
- func (c *Core) ClientSnapshot(ctx context.Context, client string, externalKey string) (ClientSnapshot, error)
- func (c *Core) CommitRealtimeVoiceTurn(ctx context.Context, input CommitRealtimeVoiceTurnInput) (CommitRealtimeVoiceTurnResult, error)
- func (c *Core) CompactSession(ctx context.Context, sessionID string) (CompactSessionResult, error)
- func (c *Core) CreateClientDelivery(ctx context.Context, delivery ClientDelivery) (ClientDelivery, error)
- func (c *Core) CreateMemory(ctx context.Context, entry MemoryEntry) (MemoryEntry, error)
- func (c *Core) CreateSession(ctx context.Context, input CreateSessionInput) (Session, error)
- func (c *Core) CreateSystemMessage(ctx context.Context, sessionID string, content string) (transcript.Message, error)
- func (c *Core) CurrentBinding(ctx context.Context, client string, externalKey string) (ClientBinding, error)
- func (c *Core) DeleteMemory(ctx context.Context, id string) error
- func (c *Core) DeletePermissionRule(ctx context.Context, ruleID string) error
- func (c *Core) DeleteSession(ctx context.Context, sessionID string) error
- func (c *Core) ExecuteRun(ctx context.Context, runID string) error
- func (c *Core) ExecuteTool(ctx context.Context, input ExecuteToolInput) (ExecuteToolResult, error)
- func (c *Core) ExternalAgents(ctx context.Context) []ExternalAgentDescriptor
- func (c *Core) GetRun(ctx context.Context, runID string) (Run, error)
- func (c *Core) GetSession(ctx context.Context, sessionID string) (Session, error)
- func (c *Core) GlobalPermissionRules(ctx context.Context) ([]permission.Rule, error)
- func (c *Core) ListApprovals(ctx context.Context, sessionID string, state ApprovalState) ([]Approval, error)
- func (c *Core) ListClientDeliveries(ctx context.Context, filter ClientDeliveryFilter) ([]ClientDelivery, error)
- func (c *Core) ListMemories(ctx context.Context, filter MemoryFilter) ([]MemoryEntry, error)
- func (c *Core) ListMessages(ctx context.Context, sessionID string, limit int) ([]transcript.Message, error)
- func (c *Core) ListMessagesAfter(ctx context.Context, sessionID string, afterSeq int64, limit int) ([]transcript.Message, error)
- func (c *Core) ListSessionTasks(ctx context.Context, sessionID string) ([]Task, error)
- func (c *Core) ListSessions(ctx context.Context, filter SessionListFilter) ([]Session, error)
- func (c *Core) ListToolSpecs() []tools.Spec
- func (c *Core) MarkClientDeliveryFailed(ctx context.Context, delivery ClientDelivery, deliveryErr error) error
- func (c *Core) MarkClientDeliverySent(ctx context.Context, delivery ClientDelivery) error
- func (c *Core) MemoryPromptContext(ctx context.Context, workingDir string) string
- func (c *Core) ModelsForSession(ctx context.Context, sessionID string) (string, string, []string, error)
- func (c *Core) ReadTaskOutput(ctx context.Context, call tools.Call, read tools.TaskRead) (tools.TaskOutput, error)
- func (c *Core) Recover(ctx context.Context) error
- func (c *Core) ReleaseHeldClientDeliveries(ctx context.Context) error
- func (c *Core) RenameSession(ctx context.Context, input RenameSessionInput) (Session, error)
- func (c *Core) ResolveApproval(ctx context.Context, approvalID string, decision ApprovalResolveRequest) (Approval, error)
- func (c *Core) ResolveExternalAgentID(id string) (string, bool)
- func (c *Core) RunAgent(ctx context.Context, input AgentInput) (AgentResult, error)
- func (c *Core) RunCommand(ctx context.Context, call tools.Call, command tools.Command) (tools.CommandResult, error)
- func (c *Core) RunProgress(ctx context.Context, runID string) (RunProgress, error)
- func (c *Core) RunSteps(ctx context.Context, runID string) ([]RunStep, error)
- func (c *Core) RunWakeups(ctx context.Context)
- func (c *Core) Search(ctx context.Context, filter SearchFilter) (SearchReport, error)
- func (c *Core) SessionBudget(ctx context.Context, sessionID string) (SessionBudgetReport, error)
- func (c *Core) SessionContext(ctx context.Context, sessionID string) (ContextReport, error)
- func (c *Core) SessionPermissionRules(ctx context.Context, sessionID string) ([]permission.Rule, error)
- func (c *Core) SessionProviderOptions() []SessionProviderOption
- func (c *Core) SessionSearch(ctx context.Context, filter SearchFilter) (SessionSearchReport, error)
- func (c *Core) SessionTodo(ctx context.Context, sessionID string) (todo.List, error)
- func (c *Core) SetAssistantProfile(profile AssistantProfile)
- func (c *Core) SetExternalAgents(registry *externalagents.Registry)
- func (c *Core) SetSessionLLMs(registry SessionLLMRegistry)
- func (c *Core) StopTask(ctx context.Context, call tools.Call, taskID string) (tools.TaskInfo, error)
- func (c *Core) SubscribeEvents(ctx context.Context, sessionID string) <-chan Event
- func (c *Core) SubscribeEventsAfter(ctx context.Context, sessionID string, afterID uint64) <-chan Event
- func (c *Core) TaskDetail(ctx context.Context, taskID string) (TaskDetailResponse, error)
- func (c *Core) UpdateMemory(ctx context.Context, entry MemoryEntry) (MemoryEntry, error)
- func (c *Core) UpdateSessionBudget(ctx context.Context, sessionID string, budget SessionBudget) (SessionBudgetReport, error)
- func (c *Core) UpdateSessionModel(ctx context.Context, sessionID string, modelID string) (Session, error)
- func (c *Core) UpdateSessionPermissionMode(ctx context.Context, input UpdateSessionPermissionModeInput) (Session, error)
- func (c *Core) UpdateSessionProvider(ctx context.Context, sessionID string, providerID string) (Session, error)
- func (c *Core) Usage(ctx context.Context, filter UsageFilter) (UsageReport, error)
- func (c *Core) UseBinding(ctx context.Context, input UseBindingInput) (ClientBinding, error)
- func (c *Core) WaitRuns()
- func (c *Core) WakeDueRuns(ctx context.Context) error
- func (c *Core) WithAttachmentReader(reader agentcontext.AttachmentReader) *Core
- func (c *Core) WithBackgroundAgents(n int) *Core
- func (c *Core) WithBackgroundTaskLimit(n int) *Core
- func (c *Core) WithClock(now func() time.Time) *Core
- func (c *Core) WithCompactModel(providerID string, modelID string) *Core
- func (c *Core) WithContextWindowCap(tokens int) *Core
- func (c *Core) WithExternalAgents(registry *externalagents.Registry, store externalagents.AttachmentStore) *Core
- func (c *Core) WithLifetime(ctx context.Context) *Core
- func (c *Core) WithModelConcurrency(n int) *Core
- func (c *Core) WithRunBudgets(budgets RunBudgets) *Core
- func (c *Core) WithRunStarter(starter RunStarter) *Core
- func (c *Core) WithRuntimeStatusContext(provider RuntimeStatusContextProvider) *Core
- func (c *Core) WithSessionFiles(root string) *Core
- func (c *Core) WithSessionLLMs(registry SessionLLMRegistry) *Core
- func (c *Core) WithSkillsContext(provider SkillsPromptContextProvider) *Core
- func (c *Core) WithTools(toolExecutor ToolExecutor) *Core
- type CreateSessionInput
- type CreateSessionRequest
- type CreateSystemMessageRequest
- type DeliveryStore
- type DocumentDeliveryPayload
- type EngineStateStore
- type ErrorResponse
- type Event
- type EventType
- type ExecuteToolInput
- type ExecuteToolResult
- type ExternalAgentDescriptor
- type ExternalAgentsResponse
- type HandleMessageInput
- type HandleTriggeredRunInput
- type HealthResponse
- type MemoryEntry
- type MemoryFilter
- type MemoryResponse
- type MemoryScope
- type MemoryStore
- type MessageResponse
- type MessageStore
- type MessagesResponse
- type NoticeDeliveryPayload
- type OKResponse
- type PermissionMode
- type PermissionNotification
- type PermissionRequest
- type PermissionRuleRequest
- type PermissionRuleResponse
- type PermissionRuleStore
- type PermissionRulesResponse
- type RenameSessionInput
- type RenameSessionRequest
- type Role
- type Run
- type RunBudgets
- type RunCheckpoint
- type RunCheckpointStore
- type RunProgress
- type RunProgressResponse
- type RunResponse
- type RunStarter
- type RunStatus
- type RunStep
- type RunStepsResponse
- type RunStore
- type RunTiming
- type RunTrigger
- type RunWakeup
- type RunWakeupStore
- type RuntimeStatusContextProvider
- type RuntimeStatusContextRequest
- type SearchFilter
- type SearchReport
- type SearchResponse
- type SearchResult
- type SearchStore
- type ServerStatus
- type ServerStatusResponse
- type Session
- type SessionBudget
- type SessionBudgetReport
- type SessionBudgetResponse
- type SessionBudgetStore
- type SessionCapabilities
- type SessionCompactResponse
- type SessionContextResponse
- type SessionInput
- type SessionInputStatus
- type SessionInputStore
- type SessionKind
- type SessionLLMRegistry
- type SessionListFilter
- type SessionModelsResponse
- type SessionProviderOption
- type SessionProvidersResponse
- type SessionResponse
- type SessionRuntime
- type SessionSearchReport
- type SessionSearchResult
- type SessionStatus
- type SessionStore
- type SessionTasksResponse
- type SessionTodoResponse
- type SessionsResponse
- type SkillsPromptContextProvider
- type SkillsPromptContextRequest
- type SkillsPromptMessage
- type Store
- type SubagentIsolation
- type SubagentRuntime
- type Task
- type TaskDetailResponse
- type TaskEnd
- type TaskFilter
- type TaskKind
- type TaskResponse
- type TaskStatus
- type TaskStore
- type TodoStore
- type ToolExecuteResponse
- type ToolExecutor
- type ToolLifecycleState
- type ToolUpdate
- type ToolsResponse
- type UpdateExternalAgentRequest
- type UpdateSessionLLMRequest
- type UpdateSessionPermissionModeInput
- type UpdateSessionPermissionModeRequest
- type UsageFilter
- type UsageRecord
- type UsageReport
- type UsageResponse
- type UsageStore
- type UsageSummary
- type UseBindingInput
Constants ¶
const ( ClientDeliveryTypeRun = "run" ClientDeliveryTypeDocument = "document" // ClientDeliveryTypeNotice is a short text for the user outside any run. ClientDeliveryTypeNotice = "notice" // ClientDeliveryTypeApproval asks the user for a subagent's approval // outside the run that started it. ClientDeliveryTypeApproval = "approval" )
const DefaultBackgroundAgents = 4
DefaultBackgroundAgents is how many background subagents one session may run at once unless the daemon configures another limit.
const DefaultBackgroundTasks = 8
DefaultBackgroundTasks is how many background commands a session runs at once unless the daemon configures another limit.
const DefaultContextWindowCap = 200_000
DefaultContextWindowCap bounds every model's window unless the daemon configures another cap.
const DefaultModelConcurrency = 4
DefaultModelConcurrency is how many model requests native runs make at once unless the daemon configures another limit.
const RoleHeader = "X-Matrixclaw-Role"
Variables ¶
var ( ErrNotFound = errors.New("not found") ErrBindingNotFound = errors.New("binding not found") ErrSessionSelectionRequired = errors.New("session selection required") ErrInvalidInput = errors.New("invalid input") ErrRunActive = errors.New("run is active") ErrRunEnded = errors.New("run already ended") ErrSessionRestricted = errors.New("only the owner can use a session that runs tools without asking (external agent or full_auto)") ErrOwnerOnly = errors.New("only the owner can do this") )
var ErrSessionRequired = errors.New("session_id is required")
Functions ¶
func AgentToolExecutors ¶ added in v0.2.0
AgentToolExecutors returns the agent tool.
func AwaitToolExecutors ¶ added in v0.2.0
AwaitToolExecutors returns the await tool.
func CoreSessionIsExternalAgent ¶ added in v0.1.12
func MemoryToolExecutors ¶ added in v0.1.12
MemoryToolExecutors exposes session recall and persistent memory to models.
func RunsUnattended ¶ added in v0.2.0
RunsUnattended reports whether a session's tools run without asking: an external agent session or one in full_auto.
func TodoToolExecutors ¶ added in v0.2.0
TodoToolExecutors exposes the session's todo list to models.
Types ¶
type AcceptRunErrorResponse ¶
type AcceptRunErrorResponse struct {
Error string `json:"error"`
SessionID string `json:"session_id"`
UserMessage transcript.Message `json:"user_message"`
Run Run `json:"run"`
}
type AcceptRunResult ¶
type AcceptRunResult struct {
SessionID string `json:"session_id"`
Status AcceptRunStatus `json:"status,omitempty"`
UserMessage transcript.Message `json:"user_message"`
Run Run `json:"run"`
Input *SessionInput `json:"input,omitempty"`
}
type AcceptRunStatus ¶ added in v0.1.13
type AcceptRunStatus string
const ( AcceptRunStatusStarted AcceptRunStatus = "started" AcceptRunStatusQueued AcceptRunStatus = "queued" AcceptRunStatusSteered AcceptRunStatus = "steered" AcceptRunStatusInterrupting AcceptRunStatus = "interrupting" )
type AdminRestartRequest ¶
type AdminRestartRequest struct {
Notification *ClientDeliveryTarget `json:"notification,omitempty"`
}
type AgentInput ¶ added in v0.2.0
type AgentInput struct {
ParentSessionID string
ParentRunID string
ParentToolCallID string
Description string
Prompt string
Background bool
Isolation string
Readonly bool
Runtime string
Model string
}
AgentInput is one agent tool call: a child agent on a bounded task.
type AgentResult ¶ added in v0.2.0
AgentResult is how a blocking child ended, or the task a background child runs as.
type Approval ¶
type Approval struct {
ID string `json:"id"`
SessionID string `json:"session_id"`
RunID string `json:"run_id,omitempty"`
// TaskID names the subagent task whose child asked, AgentName its name;
// the approval is listed and announced in the parent's session.
TaskID string `json:"task_id,omitempty"`
AgentName string `json:"agent_name,omitempty"`
ToolCallRef string `json:"tool_call_id,omitempty"`
ToolName string `json:"tool_name,omitempty"`
Description string `json:"description,omitempty"`
Params json.RawMessage `json:"params,omitempty"`
Path string `json:"path,omitempty"`
State ApprovalState `json:"state"`
// Reason is why the user denied the call; the model reads it.
Reason string `json:"reason,omitempty"`
// Suggestion is the rule an "Always allow" answer keeps.
Suggestion *permission.Suggestion `json:"suggestion,omitempty"`
RequestedAt time.Time `json:"requested_at"`
DecidedAt *time.Time `json:"decided_at,omitempty"`
}
type ApprovalDeliveryPayload ¶ added in v0.2.0
type ApprovalDeliveryPayload struct {
ApprovalID string `json:"approval_id"`
}
ApprovalDeliveryPayload names the approval an approval delivery asks for.
type ApprovalResolveRequest ¶
type ApprovalResolveRequest struct {
Approved bool `json:"approved"`
Reason string `json:"reason,omitempty"`
Always permission.Scope `json:"always,omitempty"`
// Restricted marks a decision by someone other than the owner, who may
// not keep a rule for every session; the API sets it from the caller's role.
Restricted bool `json:"-"`
}
ApprovalResolveRequest is a user's decision on an approval; Reason explains a denial to the model, and Always keeps the approval's suggested rule in that scope.
type ApprovalResponse ¶
type ApprovalResponse struct {
Approval Approval `json:"approval"`
}
type ApprovalState ¶
type ApprovalState string
const ( ApprovalStatePending ApprovalState = "pending" ApprovalStateApproved ApprovalState = "approved" ApprovalStateRejected ApprovalState = "rejected" )
type ApprovalStore ¶
type ApprovalStore interface {
CreateApproval(ctx context.Context, approval Approval) error
GetApproval(ctx context.Context, approvalID string) (Approval, error)
DecideApproval(ctx context.Context, approval Approval) error
ListApprovals(ctx context.Context, sessionID string, state ApprovalState) ([]Approval, error)
ListRunApprovals(ctx context.Context, sessionID string, runID string) ([]Approval, error)
}
type ApprovalsResponse ¶
type ApprovalsResponse struct {
Approvals []Approval `json:"approvals"`
}
type AssistantProfile ¶
type BindingStore ¶
type BindingStore interface {
SaveBinding(ctx context.Context, binding ClientBinding) error
GetBinding(ctx context.Context, client string, externalKey string) (ClientBinding, error)
}
type BusyInputMode ¶ added in v0.1.13
type BusyInputMode string
const ( BusyInputModeQueue BusyInputMode = "queue" BusyInputModeSteer BusyInputMode = "steer" BusyInputModeInterrupt BusyInputMode = "interrupt" )
type ClientBinding ¶
type ClientBindingResponse ¶
type ClientBindingResponse struct {
Binding ClientBinding `json:"binding"`
}
type ClientCapabilities ¶ added in v0.1.17
type ClientCapabilities struct {
SupportsVoiceDelivery bool `json:"supports_voice_delivery,omitempty"`
SupportsDocumentDelivery bool `json:"supports_document_delivery,omitempty"`
// ReceivesDeliveries is a client that fetches its run replies from the
// delivery queue; others follow runs through events.
ReceivesDeliveries bool `json:"receives_deliveries,omitempty"`
}
type ClientDeliveriesResponse ¶
type ClientDeliveriesResponse struct {
Deliveries []ClientDelivery `json:"deliveries"`
}
type ClientDelivery ¶
type ClientDelivery struct {
ID string `json:"id"`
Type string `json:"type"`
Client string `json:"client"`
ExternalKey string `json:"external_key,omitempty"`
SessionID string `json:"session_id,omitempty"`
RunID string `json:"run_id,omitempty"`
TaskID string `json:"task_id,omitempty"`
Summary string `json:"summary,omitempty"`
Address json.RawMessage `json:"address,omitempty"`
// ReplyOnce is set when Address takes one reply only.
ReplyOnce bool `json:"reply_once,omitempty"`
Payload json.RawMessage `json:"payload,omitempty"`
Status ClientDeliveryStatus `json:"status"`
Error string `json:"error,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
}
type ClientDeliveryFailRequest ¶ added in v0.1.15
type ClientDeliveryFailRequest struct {
Error string `json:"error,omitempty"`
}
type ClientDeliveryFilter ¶
type ClientDeliveryStatus ¶
type ClientDeliveryStatus string
const ( ClientDeliveryStatusPending ClientDeliveryStatus = "pending" // ClientDeliveryStatusHeld waits for the next daemon start. ClientDeliveryStatusHeld ClientDeliveryStatus = "held" ClientDeliveryStatusSent ClientDeliveryStatus = "sent" ClientDeliveryStatusFailed ClientDeliveryStatus = "failed" )
type ClientDeliveryTarget ¶
type ClientDeliveryTarget struct {
Client string `json:"client,omitempty"`
ExternalKey string `json:"external_key,omitempty"`
SessionID string `json:"session_id,omitempty"`
RunID string `json:"run_id,omitempty"`
TaskID string `json:"task_id,omitempty"`
Summary string `json:"summary,omitempty"`
Address json.RawMessage `json:"address,omitempty"`
}
type ClientSnapshot ¶
type ClientSnapshot struct {
// EventID is the newest event published before the snapshot was read: every
// event up to it is already reflected here.
EventID uint64 `json:"event_id,omitempty"`
SessionID string `json:"session_id"`
Session *Session `json:"session,omitempty"`
Capabilities *SessionCapabilities `json:"capabilities,omitempty"`
Context *ContextReport `json:"context,omitempty"`
Todo *todo.List `json:"todo,omitempty"`
Messages []transcript.Message `json:"messages"`
Run *Run `json:"run,omitempty"`
Timing *RunTiming `json:"timing,omitempty"`
ToolUpdates []ToolUpdate `json:"tool_updates,omitempty"`
Approvals []Approval `json:"approvals,omitempty"`
ApprovalNotifications []PermissionNotification `json:"approval_notifications,omitempty"`
Subagents []Task `json:"subagents,omitempty"`
PendingInputs []SessionInput `json:"pending_inputs,omitempty"`
}
type ClientSnapshotResponse ¶
type ClientSnapshotResponse struct {
Snapshot ClientSnapshot `json:"snapshot"`
}
type CommitRealtimeVoiceTurnInput ¶ added in v0.1.16
type CommitRealtimeVoiceTurnResult ¶ added in v0.1.16
type CommitRealtimeVoiceTurnResult struct {
UserMessage *transcript.Message `json:"user_message,omitempty"`
AssistantMessage *transcript.Message `json:"assistant_message,omitempty"`
}
type CompactSessionResult ¶
type CompactSessionResult struct {
Message transcript.Message `json:"message"`
Context ContextReport `json:"context"`
}
type ContextBlock ¶
type ContextBlockKind ¶
type ContextBlockKind string
const ( ContextBlockSystemPrompt ContextBlockKind = "system_prompt" ContextBlockCustomInstructions ContextBlockKind = "custom_instructions" ContextBlockCompactSummary ContextBlockKind = "compact_summary" ContextBlockClearMarker ContextBlockKind = "clear_marker" ContextBlockMessages ContextBlockKind = "messages" ContextBlockToolSchemas ContextBlockKind = "tool_schemas" )
type ContextCompact ¶
type ContextReport ¶
type ContextReport struct {
SessionID string `json:"session_id"`
Estimated bool `json:"estimated"`
TokenEstimate int `json:"token_estimate"`
WindowTokens int `json:"window_tokens,omitempty"`
MessageCount int `json:"message_count"`
Blocks []ContextBlock `json:"blocks"`
LastProviderUsage *providers.Usage `json:"last_provider_usage,omitempty"`
Compact ContextCompact `json:"compact"`
}
type ContextUsage ¶ added in v0.2.0
type ContextUsage struct {
SessionID string `json:"session_id"`
TokenEstimate int `json:"token_estimate"`
WindowTokens int `json:"window_tokens,omitempty"`
}
ContextUsage is how much of the model's window a session's conversation fills, as measured after a run's latest step.
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
func (*Core) AcceptRun ¶
func (c *Core) AcceptRun(ctx context.Context, input HandleMessageInput) (AcceptRunResult, error)
func (*Core) AcceptTriggeredRun ¶
func (c *Core) AcceptTriggeredRun(ctx context.Context, input HandleTriggeredRunInput) (AcceptRunResult, error)
func (*Core) AcknowledgeClientDelivery ¶
func (*Core) AddPermissionRule ¶ added in v0.2.0
func (c *Core) AddPermissionRule(ctx context.Context, sessionID string, request PermissionRuleRequest) (permission.Rule, error)
AddPermissionRule saves a rule for the session, or for every session when its scope is global. File tool patterns become absolute against the session's working directory (so do path patterns of rules for every tool), domains are normalised, and a rule for one MCP tool names it as "server__tool".
func (*Core) CancelTask ¶ added in v0.2.0
CancelTask stops a task for the user; its session reads that at its next step.
func (*Core) ClearContext ¶ added in v0.2.0
ClearContext starts the session's model context afresh with a boundary that covers every message so far and an empty todo list; the transcript keeps the messages, but not the tool outputs kept in files for them.
func (*Core) ClearSessionTodo ¶ added in v0.2.0
ClearSessionTodo empties the session's todo list.
func (*Core) ClientSnapshot ¶
func (*Core) CommitRealtimeVoiceTurn ¶ added in v0.1.16
func (c *Core) CommitRealtimeVoiceTurn(ctx context.Context, input CommitRealtimeVoiceTurnInput) (CommitRealtimeVoiceTurnResult, error)
func (*Core) CompactSession ¶
CompactSession summarises what the model sees of the session into a boundary that covers all of it.
func (*Core) CreateClientDelivery ¶
func (c *Core) CreateClientDelivery(ctx context.Context, delivery ClientDelivery) (ClientDelivery, error)
func (*Core) CreateMemory ¶ added in v0.1.12
func (c *Core) CreateMemory(ctx context.Context, entry MemoryEntry) (MemoryEntry, error)
func (*Core) CreateSession ¶
func (*Core) CreateSystemMessage ¶
func (*Core) CurrentBinding ¶
func (*Core) DeleteMemory ¶ added in v0.1.12
func (*Core) DeletePermissionRule ¶ added in v0.2.0
DeletePermissionRule removes a rule.
func (*Core) DeleteSession ¶
func (*Core) ExecuteRun ¶
ExecuteRun claims a run and executes it with its external agent or the native engine.
func (*Core) ExecuteTool ¶
func (c *Core) ExecuteTool(ctx context.Context, input ExecuteToolInput) (ExecuteToolResult, error)
ExecuteTool runs one tool call outside the agent loop.
func (*Core) ExternalAgents ¶ added in v0.1.4
func (c *Core) ExternalAgents(ctx context.Context) []ExternalAgentDescriptor
func (*Core) GetSession ¶ added in v0.1.16
func (*Core) GlobalPermissionRules ¶ added in v0.2.0
GlobalPermissionRules lists the rules that apply to every session.
func (*Core) ListApprovals ¶
func (*Core) ListClientDeliveries ¶
func (c *Core) ListClientDeliveries(ctx context.Context, filter ClientDeliveryFilter) ([]ClientDelivery, error)
func (*Core) ListMemories ¶ added in v0.1.12
func (c *Core) ListMemories(ctx context.Context, filter MemoryFilter) ([]MemoryEntry, error)
func (*Core) ListMessages ¶
func (*Core) ListMessagesAfter ¶ added in v0.2.0
func (*Core) ListSessionTasks ¶ added in v0.2.0
ListSessionTasks lists the session's background tasks, newest first.
func (*Core) ListSessions ¶
func (*Core) ListToolSpecs ¶
func (*Core) MarkClientDeliveryFailed ¶
func (*Core) MarkClientDeliverySent ¶
func (c *Core) MarkClientDeliverySent(ctx context.Context, delivery ClientDelivery) error
func (*Core) MemoryPromptContext ¶ added in v0.1.12
func (*Core) ModelsForSession ¶
func (*Core) ReadTaskOutput ¶ added in v0.2.0
func (c *Core) ReadTaskOutput(ctx context.Context, call tools.Call, read tools.TaskRead) (tools.TaskOutput, error)
ReadTaskOutput returns a task's output since the call's session last read it; it waits up to read.Wait for a running task to finish.
func (*Core) Recover ¶ added in v0.2.0
Recover resumes what the previous daemon left, once, at daemon start: its shell tasks are lost; each run it left active resumes; a subagent task whose child run ended is told; an idle session starts its next queued message, or a run for background work that finished meanwhile.
func (*Core) ReleaseHeldClientDeliveries ¶ added in v0.2.0
ReleaseHeldClientDeliveries makes the deliveries held for the next daemon start, like the restart notice, pending for their clients.
func (*Core) RenameSession ¶
func (*Core) ResolveApproval ¶
func (c *Core) ResolveApproval(ctx context.Context, approvalID string, decision ApprovalResolveRequest) (Approval, error)
ResolveApproval records the user's decision on an approval. A run resumes once none of its approvals is pending and reads a denial as the call's result; a call made outside a run is replayed or answered here.
func (*Core) ResolveExternalAgentID ¶ added in v0.1.9
func (*Core) RunAgent ¶ added in v0.2.0
func (c *Core) RunAgent(ctx context.Context, input AgentInput) (AgentResult, error)
RunAgent runs a child agent for a parent's agent call. The call waits for a blocking child to end and returns its result; a background child is a task whose result reaches the parent as an event. A repeated call (after a restart) waits for the child it started again, or reports it.
func (*Core) RunCommand ¶ added in v0.2.0
func (c *Core) RunCommand(ctx context.Context, call tools.Call, command tools.Command) (tools.CommandResult, error)
RunCommand runs a bash call's command. A background command, or a foreground one still running after its AutoBackground delay, goes on as a task of the call's session while it runs fewer than its limit; a foreground one is stopped at its timeout or when ctx stops.
func (*Core) RunProgress ¶ added in v0.2.0
RunProgress counts the run's budget steps from run_steps (summaries use none), the step limit of its budget and its session's live background tasks.
func (*Core) RunWakeups ¶ added in v0.2.0
RunWakeups wakes due runs until ctx ends; timers stored before a restart fire on its first tick.
func (*Core) Search ¶ added in v0.1.7
func (c *Core) Search(ctx context.Context, filter SearchFilter) (SearchReport, error)
func (*Core) SessionBudget ¶ added in v0.2.0
SessionBudget reports the session's overrides and the budget of its next run.
func (*Core) SessionContext ¶
func (*Core) SessionPermissionRules ¶ added in v0.2.0
func (c *Core) SessionPermissionRules(ctx context.Context, sessionID string) ([]permission.Rule, error)
SessionPermissionRules lists the rules a session's calls follow: the global rules, its own and its parents'.
func (*Core) SessionProviderOptions ¶
func (c *Core) SessionProviderOptions() []SessionProviderOption
func (*Core) SessionSearch ¶ added in v0.1.12
func (c *Core) SessionSearch(ctx context.Context, filter SearchFilter) (SessionSearchReport, error)
func (*Core) SessionTodo ¶ added in v0.2.0
SessionTodo returns the session's todo list.
func (*Core) SetAssistantProfile ¶
func (c *Core) SetAssistantProfile(profile AssistantProfile)
func (*Core) SetExternalAgents ¶ added in v0.2.0
func (c *Core) SetExternalAgents(registry *externalagents.Registry)
SetExternalAgents swaps the external agent registry while the daemon serves.
func (*Core) SetSessionLLMs ¶
func (c *Core) SetSessionLLMs(registry SessionLLMRegistry)
func (*Core) StopTask ¶ added in v0.2.0
func (c *Core) StopTask(ctx context.Context, call tools.Call, taskID string) (tools.TaskInfo, error)
StopTask stops a task of the call's session for the model, which then needs no event about it.
func (*Core) SubscribeEvents ¶
func (*Core) SubscribeEventsAfter ¶
func (*Core) TaskDetail ¶ added in v0.2.0
TaskDetail returns a task and the end of its output.
func (*Core) UpdateMemory ¶ added in v0.1.12
func (c *Core) UpdateMemory(ctx context.Context, entry MemoryEntry) (MemoryEntry, error)
func (*Core) UpdateSessionBudget ¶ added in v0.2.0
func (c *Core) UpdateSessionBudget(ctx context.Context, sessionID string, budget SessionBudget) (SessionBudgetReport, error)
UpdateSessionBudget replaces the session's overrides; an empty budget restores the defaults.
func (*Core) UpdateSessionModel ¶
func (*Core) UpdateSessionPermissionMode ¶
func (*Core) UpdateSessionProvider ¶
func (*Core) Usage ¶ added in v0.1.7
func (c *Core) Usage(ctx context.Context, filter UsageFilter) (UsageReport, error)
func (*Core) UseBinding ¶
func (c *Core) UseBinding(ctx context.Context, input UseBindingInput) (ClientBinding, error)
func (*Core) WaitRuns ¶ added in v0.2.0
func (c *Core) WaitRuns()
WaitRuns stops starting runs and waits for the executing ones to return; the daemon calls it after its lifetime ended, so they stop at once.
func (*Core) WakeDueRuns ¶ added in v0.2.0
WakeDueRuns starts the waiting runs whose timer ran out.
func (*Core) WithAttachmentReader ¶
func (c *Core) WithAttachmentReader(reader agentcontext.AttachmentReader) *Core
The With* builder methods below configure a Core during single-threaded construction, before the daemon starts serving. Except for WithSessionLLMs, they mutate Core fields without holding c.mu and therefore MUST NOT be called after any run has started or after the Core is shared across goroutines — doing so races with the agent loop reading those fields. Post-construction mutation must go through the locked Set* methods (SetSessionLLMs, SetAssistantProfile, SetExternalAgents).
func (*Core) WithBackgroundAgents ¶ added in v0.2.0
WithBackgroundAgents bounds the background subagents one session runs at once; 0 or less keeps the default.
func (*Core) WithBackgroundTaskLimit ¶ added in v0.2.0
WithBackgroundTaskLimit bounds the background commands one session runs at once; 0 or less keeps the default.
func (*Core) WithCompactModel ¶ added in v0.2.0
WithCompactModel names the provider and model that write context summaries; empty keeps each run's own model.
func (*Core) WithContextWindowCap ¶ added in v0.2.0
WithContextWindowCap bounds the window runs and /context assume for any model; 0 or less keeps the default cap.
func (*Core) WithExternalAgents ¶ added in v0.1.4
func (c *Core) WithExternalAgents(registry *externalagents.Registry, store externalagents.AttachmentStore) *Core
func (*Core) WithLifetime ¶ added in v0.2.0
WithLifetime sets the daemon lifetime; interrupted runs are rescheduled only while it is alive.
func (*Core) WithModelConcurrency ¶ added in v0.2.0
WithModelConcurrency bounds the model requests all native runs, subagents included, make at once; 0 or less keeps the default.
func (*Core) WithRunBudgets ¶ added in v0.2.0
func (c *Core) WithRunBudgets(budgets RunBudgets) *Core
WithRunBudgets sets the default run budgets per trigger.
func (*Core) WithRunStarter ¶ added in v0.1.2
func (c *Core) WithRunStarter(starter RunStarter) *Core
func (*Core) WithRuntimeStatusContext ¶ added in v0.1.15
func (c *Core) WithRuntimeStatusContext(provider RuntimeStatusContextProvider) *Core
func (*Core) WithSessionFiles ¶ added in v0.2.0
WithSessionFiles sets the directory that holds per-session files such as full tool outputs; a session's files are removed with it.
func (*Core) WithSessionLLMs ¶
func (c *Core) WithSessionLLMs(registry SessionLLMRegistry) *Core
func (*Core) WithSkillsContext ¶ added in v0.1.11
func (c *Core) WithSkillsContext(provider SkillsPromptContextProvider) *Core
func (*Core) WithTools ¶
func (c *Core) WithTools(toolExecutor ToolExecutor) *Core
type CreateSessionInput ¶
type CreateSessionInput struct {
Title string
Kind SessionKind
RuntimeID SessionRuntime
ParentSessionID string
Hidden bool
WorkingDir string
ProviderID string
ModelID string
PermissionMode PermissionMode
ExternalAgentID string
// Readonly starts an external agent that never asks and cannot write.
Readonly bool
// Restricted refuses a session that would run tools without asking.
Restricted bool
}
type CreateSessionRequest ¶
type CreateSessionRequest struct {
Title string `json:"title"`
Kind string `json:"kind,omitempty"`
RuntimeID string `json:"runtime_id,omitempty"`
WorkingDir string `json:"working_dir"`
ProviderID string `json:"provider_id,omitempty"`
ModelID string `json:"model_id,omitempty"`
PermissionMode string `json:"permission_mode,omitempty"`
ExternalAgentID string `json:"external_agent_id,omitempty"`
}
type CreateSystemMessageRequest ¶
type CreateSystemMessageRequest struct {
Content string `json:"content"`
}
type DeliveryStore ¶
type DeliveryStore interface {
CreateClientDelivery(ctx context.Context, delivery ClientDelivery) error
ListClientDeliveries(ctx context.Context, filter ClientDeliveryFilter) ([]ClientDelivery, error)
UpdateClientDelivery(ctx context.Context, delivery ClientDelivery) error
}
type DocumentDeliveryPayload ¶ added in v0.1.15
type EngineStateStore ¶ added in v0.2.0
type EngineStateStore interface {
GetSessionEngineState(ctx context.Context, sessionID string) (json.RawMessage, error)
SaveSessionEngineState(ctx context.Context, sessionID string, state json.RawMessage, updatedAt time.Time) error
}
EngineStateStore keeps the engine counters a session's next run starts from.
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
}
type Event ¶
type Event struct {
ID uint64 `json:"id,omitempty"`
Type EventType `json:"type"`
SessionID string `json:"session_id"`
RunID string `json:"run_id,omitempty"`
Payload any `json:"payload,omitempty"`
At time.Time `json:"at"`
}
Event is the daemon-owned envelope for live fan-out.
type EventType ¶
type EventType string
const ( EventRunUpdated EventType = "run.updated" EventMessageCreated EventType = "message.created" EventMessageUpdated EventType = "message.updated" EventTodoUpdated EventType = "todo.updated" EventToolUpdated EventType = "tool.updated" EventApprovalRequest EventType = "approval.requested" EventApprovalResult EventType = "approval.resolved" EventInputUpdated EventType = "input.updated" EventTaskUpdated EventType = "task.updated" EventContextUpdated EventType = "context.updated" )
type ExecuteToolInput ¶
type ExecuteToolInput struct {
SessionID string `json:"session_id"`
ToolName string `json:"tool_name"`
Client string `json:"client,omitempty"`
ExternalKey string `json:"external_key,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
WorkingDir string `json:"working_dir,omitempty"`
Args json.RawMessage `json:"args,omitempty"`
}
ExecuteToolInput is a tool call made outside any run (the API, voice, the MCP server); a run's calls go through its engine.
type ExecuteToolResult ¶
type ExecuteToolResult struct {
ToolCallMessage transcript.Message `json:"tool_call_message"`
ToolResultMessage *transcript.Message `json:"tool_result_message,omitempty"`
Approval *Approval `json:"approval,omitempty"`
}
type ExternalAgentDescriptor ¶ added in v0.1.4
type ExternalAgentDescriptor struct {
ID string `json:"id"`
Aliases []string `json:"aliases,omitempty"`
DisplayName string `json:"display_name"`
Installed bool `json:"installed"`
Enabled bool `json:"enabled"`
Mode string `json:"mode,omitempty"`
Path string `json:"path,omitempty"`
Version string `json:"version,omitempty"`
Detail string `json:"detail,omitempty"`
}
type ExternalAgentsResponse ¶ added in v0.1.4
type ExternalAgentsResponse struct {
Agents []ExternalAgentDescriptor `json:"agents"`
}
type HandleMessageInput ¶
type HandleMessageInput struct {
Client string `json:"client"`
ExternalKey string `json:"external_key"`
ClientCapabilities ClientCapabilities `json:"client_capabilities,omitempty"`
SessionID string `json:"session_id"`
Text string `json:"text"`
Parts []transcript.MessagePart `json:"parts,omitempty"`
BusyMode BusyInputMode `json:"busy_mode,omitempty"`
WorkingDir string `json:"working_dir"`
DeliveryAddress json.RawMessage `json:"delivery_address,omitempty"`
// ReplyOnce marks a delivery address that takes one reply only (a Telegram
// guest query or inline message); the session never answers there on its own.
ReplyOnce bool `json:"reply_once,omitempty"`
AllowAutoBindOne bool `json:"allow_auto_bind_one"`
// Restricted keeps the client out of sessions that RunsUnattended; the API
// sets it from the caller's role.
Restricted bool `json:"-"`
// Continue starts a run that continues the session's latest run; Text is ignored.
Continue bool `json:"continue,omitempty"`
}
type HandleTriggeredRunInput ¶
type HealthResponse ¶
type MemoryEntry ¶ added in v0.1.12
type MemoryFilter ¶ added in v0.1.12
type MemoryFilter struct {
Scope MemoryScope
WorkingDir string
Limit int
}
type MemoryResponse ¶ added in v0.1.12
type MemoryResponse struct {
Memories []MemoryEntry `json:"memories"`
}
type MemoryScope ¶ added in v0.1.12
type MemoryScope string
const ( MemoryScopeGlobal MemoryScope = "global" MemoryScopeUser MemoryScope = "user" MemoryScopeProject MemoryScope = "project" )
type MemoryStore ¶ added in v0.1.12
type MemoryStore interface {
CreateMemory(ctx context.Context, entry MemoryEntry) error
UpdateMemory(ctx context.Context, entry MemoryEntry) error
DeleteMemory(ctx context.Context, id string) error
GetMemory(ctx context.Context, id string) (MemoryEntry, error)
ListMemories(ctx context.Context, filter MemoryFilter) ([]MemoryEntry, error)
}
type MessageResponse ¶
type MessageResponse struct {
Message transcript.Message `json:"message"`
}
type MessageStore ¶
type MessageStore interface {
AppendMessage(ctx context.Context, message transcript.Message) (int64, error)
UpdateMessage(ctx context.Context, message transcript.Message) error
// SaveMessageProgress and UpdateMessageProgress write streaming snapshots
// without indexing them for search; the final UpdateMessage does that once.
SaveMessageProgress(ctx context.Context, message transcript.Message) (int64, error)
UpdateMessageProgress(ctx context.Context, message transcript.Message) error
GetMessage(ctx context.Context, messageID string) (transcript.Message, error)
// HasToolResult reports whether the run has a result for the call; a call's
// result is always written by the call's own run.
HasToolResult(ctx context.Context, sessionID string, runID string, toolCallID string) (bool, error)
ListMessages(ctx context.Context, sessionID string, limit int) ([]transcript.Message, error)
ListRunMessages(ctx context.Context, sessionID string, runID string) ([]transcript.Message, error)
ListMessagesAfter(ctx context.Context, sessionID string, afterSeq int64, limit int) ([]transcript.Message, error)
LatestCompaction(ctx context.Context, sessionID string) (transcript.Message, error)
}
type MessagesResponse ¶
type MessagesResponse struct {
Messages []transcript.Message `json:"messages"`
}
type NoticeDeliveryPayload ¶ added in v0.2.0
type NoticeDeliveryPayload struct {
Replace bool `json:"replace,omitempty"`
}
NoticeDeliveryPayload is a notice's optional payload; Replace asks the client to replace the message at the address instead of sending a new one.
type OKResponse ¶
type OKResponse struct {
OK bool `json:"ok"`
}
type PermissionMode ¶
type PermissionMode string
const ( PermissionModeDefault PermissionMode = permission.ModeDefault PermissionModeAcceptEdits PermissionMode = permission.ModeAcceptEdits PermissionModeFullAuto PermissionMode = permission.ModeFullAuto )
func NormalizePermissionMode ¶
func NormalizePermissionMode(mode string) PermissionMode
type PermissionNotification ¶
type PermissionRequest ¶
type PermissionRequest struct {
ID string `json:"id"`
SessionID string `json:"session_id"`
TaskID string `json:"task_id,omitempty"`
AgentName string `json:"agent_name,omitempty"`
ToolCallID string `json:"tool_call_id"`
ToolName string `json:"tool_name"`
Description string `json:"description"`
Params json.RawMessage `json:"params,omitempty"`
Path string `json:"path"`
Suggestion *permission.Suggestion `json:"suggestion,omitempty"`
}
type PermissionRuleRequest ¶ added in v0.2.0
type PermissionRuleRequest struct {
Tool string `json:"tool"`
Pattern string `json:"pattern,omitempty"`
Effect permission.Effect `json:"effect"`
Scope permission.Scope `json:"scope"`
}
PermissionRuleRequest adds a rule. Pattern is a path glob, a command prefix such as "go test:*", a domain or an MCP "server__tool" name; empty is the whole tool.
type PermissionRuleResponse ¶ added in v0.2.0
type PermissionRuleResponse struct {
Rule permission.Rule `json:"rule"`
}
type PermissionRuleStore ¶ added in v0.2.0
type PermissionRuleStore interface {
CreatePermissionRule(ctx context.Context, rule permission.Rule) error
DeletePermissionRule(ctx context.Context, ruleID string) error
ListPermissionRules(ctx context.Context, sessionIDs []string) ([]permission.Rule, error)
}
PermissionRuleStore keeps permission rules; global rules belong to no session.
type PermissionRulesResponse ¶ added in v0.2.0
type PermissionRulesResponse struct {
Rules []permission.Rule `json:"rules"`
}
type RenameSessionInput ¶
type RenameSessionRequest ¶
type RenameSessionRequest struct {
Title string `json:"title"`
}
type Role ¶ added in v0.2.0
type Role string
Role is who a client acts for. A trusted local client (it holds the API token) asserts it in RoleHeader; a request without it acts as the owner.
type Run ¶
type Run struct {
ID string `json:"id"`
SessionID string `json:"session_id"`
UserMessageID string `json:"user_message_id"`
Client string `json:"client,omitempty"`
ExternalKey string `json:"external_key,omitempty"`
ClientCapabilities ClientCapabilities `json:"client_capabilities,omitempty"`
Trigger RunTrigger `json:"trigger,omitempty"`
ContinuesRunID string `json:"continues_run_id,omitempty"`
Status RunStatus `json:"status"`
StopReason agent.StopReason `json:"stop_reason,omitempty"`
Error string `json:"error,omitempty"`
StartedAt time.Time `json:"started_at"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
}
type RunBudgets ¶ added in v0.2.0
RunBudgets are the daemon's default run budgets per trigger.
func DefaultRunBudgets ¶ added in v0.2.0
func DefaultRunBudgets() RunBudgets
DefaultRunBudgets apply when the daemon configuration names none.
type RunCheckpoint ¶ added in v0.2.0
type RunCheckpoint struct {
RunID string `json:"run_id"`
// Batch is set in the engine's tool_batch phase.
Batch *agent.ToolBatch `json:"tool_batch,omitempty"`
// RecoveryCount counts the daemon restarts the run was recovered from.
RecoveryCount int `json:"recovery_count,omitempty"`
EngineState json.RawMessage `json:"engine_state,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
}
RunCheckpoint marks a run that passed an execution boundary; a run that has one when the daemon starts is recovered.
type RunCheckpointStore ¶ added in v0.2.0
type RunCheckpointStore interface {
SaveRunCheckpoint(ctx context.Context, checkpoint RunCheckpoint) error
GetRunCheckpoint(ctx context.Context, runID string) (RunCheckpoint, error)
DeleteRunCheckpoint(ctx context.Context, runID string) error
}
RunCheckpointStore keeps the execution boundaries crash recovery resumes from.
type RunProgress ¶ added in v0.2.0
type RunProgress struct {
Steps int `json:"steps"`
StepLimit int `json:"step_limit"`
Tasks int `json:"tasks"`
}
RunProgress is how far a run is: the budget steps it used, its step limit (0 is unlimited) and the background tasks of its session still running.
type RunProgressResponse ¶ added in v0.2.0
type RunProgressResponse struct {
Progress RunProgress `json:"progress"`
}
type RunResponse ¶
type RunResponse struct {
Run Run `json:"run"`
}
type RunStarter ¶ added in v0.1.2
RunStarter starts the execution of an accepted run; by default the core executes it in a goroutine of its own.
type RunStatus ¶
type RunStatus string
const ( RunStatusAccepted RunStatus = "accepted" RunStatusRunning RunStatus = "running" RunStatusWaitingApproval RunStatus = "waiting_approval" // RunStatusWaitingEvents is a run parked by await until a task it waits for // finishes, the user writes or its timer runs out. RunStatusWaitingEvents RunStatus = "waiting_events" RunStatusCompleted RunStatus = "completed" RunStatusCanceled RunStatus = "canceled" RunStatusFailed RunStatus = "failed" )
type RunStep ¶ added in v0.2.0
type RunStep struct {
RunID string `json:"run_id"`
Step int `json:"step"`
Model string `json:"model,omitempty"`
Provider string `json:"provider,omitempty"`
PromptTokens int64 `json:"prompt_tokens,omitempty"`
CacheReadTokens int64 `json:"cache_read_tokens,omitempty"`
CacheWriteTokens int64 `json:"cache_write_tokens,omitempty"`
OutputTokens int64 `json:"output_tokens,omitempty"`
ReasoningTokens int64 `json:"reasoning_tokens,omitempty"`
StopReason string `json:"stop_reason,omitempty"`
LatencyMillis int64 `json:"latency_ms,omitempty"`
ToolCalls int `json:"tool_calls,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
RunStep is one model generation of a run; SaveRunStep assigns Step.
type RunStepsResponse ¶ added in v0.2.0
type RunStepsResponse struct {
Steps []RunStep `json:"steps"`
}
type RunStore ¶
type RunStore interface {
GetRun(ctx context.Context, runID string) (Run, error)
GetActiveRunBySession(ctx context.Context, sessionID string) (Run, error)
GetLatestRunBySession(ctx context.Context, sessionID string) (Run, error)
// ListSessionRuns lists the session's newest runs first, ordered by their user message.
ListSessionRuns(ctx context.Context, sessionID string, limit int) ([]Run, error)
ListActiveRuns(ctx context.Context) ([]Run, error)
// SealRun writes the run with the reply it ends or parks with, if any, in
// one transaction; an ended run keeps how it ended (ErrRunEnded).
SealRun(ctx context.Context, run Run, reply *transcript.Message, replySaved bool) error
TouchRun(ctx context.Context, runID string, at time.Time) error
AcceptMessage(ctx context.Context, message transcript.Message, run Run, deliveries ...ClientDelivery) error
}
type RunTrigger ¶ added in v0.2.0
type RunTrigger string
RunTrigger is what started a run and selects its default budget; empty means a user message.
const ( // RunTriggerAutomation covers scheduled jobs. RunTriggerAutomation RunTrigger = "automation" // RunTriggerWake is a run an idle session started for background work that finished. RunTriggerWake RunTrigger = "wake" )
type RunWakeup ¶ added in v0.2.0
RunWakeup is when a run parked in waiting_events wakes at the latest, and the tasks it waits for; none means any background task of its session.
type RunWakeupStore ¶ added in v0.2.0
type RunWakeupStore interface {
SaveRunWakeup(ctx context.Context, wakeup RunWakeup) error
GetRunWakeup(ctx context.Context, runID string) (RunWakeup, error)
DeleteRunWakeup(ctx context.Context, runID string) error
ListDueRunWakeups(ctx context.Context, at time.Time) ([]RunWakeup, error)
}
RunWakeupStore keeps the timers of runs parked in waiting_events.
type RuntimeStatusContextProvider ¶ added in v0.1.15
type RuntimeStatusContextProvider interface {
RuntimeStatusPromptContext(context.Context, RuntimeStatusContextRequest) string
}
type RuntimeStatusContextRequest ¶ added in v0.1.15
type SearchFilter ¶ added in v0.1.7
type SearchReport ¶ added in v0.1.7
type SearchReport struct {
Query string `json:"query"`
Results []SearchResult `json:"results"`
}
type SearchResponse ¶ added in v0.1.7
type SearchResponse struct {
Search SearchReport `json:"search"`
}
type SearchResult ¶ added in v0.1.7
type SearchResult struct {
MessageID string `json:"message_id"`
SessionID string `json:"session_id"`
Role string `json:"role,omitempty"`
Snippet string `json:"snippet,omitempty"`
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
Rank float64 `json:"rank,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
}
type SearchStore ¶ added in v0.1.7
type SearchStore interface {
SearchMessages(ctx context.Context, filter SearchFilter) ([]SearchResult, error)
}
type ServerStatus ¶
type ServerStatus struct {
StartedAt time.Time `json:"started_at"`
UptimeSeconds int64 `json:"uptime_seconds"`
GoAllocBytes uint64 `json:"go_alloc_bytes"`
GoSysBytes uint64 `json:"go_sys_bytes"`
ProcessRSSBytes uint64 `json:"process_rss_bytes"`
MemoryTotalBytes uint64 `json:"memory_total_bytes"`
MemoryAvailableBytes uint64 `json:"memory_available_bytes"`
MemoryUsedBytes uint64 `json:"memory_used_bytes"`
CPUUsedPercent float64 `json:"cpu_used_percent"`
CPUKnown bool `json:"cpu_known"`
}
type ServerStatusResponse ¶
type ServerStatusResponse struct {
Status ServerStatus `json:"status"`
}
type Session ¶
type Session struct {
ID string `json:"id"`
Title string `json:"title"`
Kind SessionKind `json:"kind"`
RuntimeID SessionRuntime `json:"runtime_id,omitempty"`
ParentSessionID string `json:"parent_session_id,omitempty"`
Hidden bool `json:"hidden,omitempty"`
WorkingDir string `json:"working_dir,omitempty"`
ProviderID string `json:"provider_id,omitempty"`
ModelID string `json:"model_id,omitempty"`
ExternalAgentID string `json:"external_agent_id,omitempty"`
ExternalAgentName string `json:"external_agent_name,omitempty"`
PermissionMode PermissionMode `json:"permission_mode,omitempty"`
Status SessionStatus `json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type SessionBudget ¶ added in v0.2.0
type SessionBudget struct {
Steps *int `json:"steps,omitempty"`
ActiveSeconds *int64 `json:"active_seconds,omitempty"`
Tokens *int64 `json:"tokens,omitempty"`
}
SessionBudget overrides the daemon run budget for one session. A nil field inherits the default; Tokens 0 means unlimited.
func (SessionBudget) IsZero ¶ added in v0.2.0
func (b SessionBudget) IsZero() bool
IsZero reports whether the session overrides nothing.
type SessionBudgetReport ¶ added in v0.2.0
type SessionBudgetReport struct {
SessionID string `json:"session_id"`
Override SessionBudget `json:"override"`
Steps int `json:"steps"`
ActiveSeconds int64 `json:"active_seconds"`
Tokens int64 `json:"tokens"`
}
SessionBudgetReport is a session's overrides and the effective budget: the default for the session's kind (a subagent session gets the subagent default, others the user default) with the overrides applied.
type SessionBudgetResponse ¶ added in v0.2.0
type SessionBudgetResponse struct {
Budget SessionBudgetReport `json:"budget"`
}
type SessionBudgetStore ¶ added in v0.2.0
type SessionCapabilities ¶ added in v0.1.8
type SessionCapabilities struct {
ProviderSelection bool `json:"provider_selection"`
PermissionMode bool `json:"permission_mode"`
NativeTools bool `json:"native_tools"`
ExternalAgent bool `json:"external_agent"`
}
func CapabilitiesForSession ¶ added in v0.1.8
func CapabilitiesForSession(session Session) SessionCapabilities
type SessionCompactResponse ¶
type SessionCompactResponse struct {
Compact CompactSessionResult `json:"compact"`
}
type SessionContextResponse ¶
type SessionContextResponse struct {
Context ContextReport `json:"context"`
}
type SessionInput ¶ added in v0.1.13
type SessionInput struct {
ID string `json:"id"`
SessionID string `json:"session_id"`
TargetRunID string `json:"target_run_id,omitempty"`
Mode BusyInputMode `json:"mode"`
Status SessionInputStatus `json:"status"`
Text string `json:"text"`
Parts []transcript.MessagePart `json:"parts,omitempty"`
Client string `json:"client,omitempty"`
ExternalKey string `json:"external_key,omitempty"`
ClientCapabilities ClientCapabilities `json:"client_capabilities,omitempty"`
DeliveryAddress json.RawMessage `json:"delivery_address,omitempty"`
ReplyOnce bool `json:"reply_once,omitempty"`
WorkingDir string `json:"working_dir,omitempty"`
ConsumedRunID string `json:"consumed_run_id,omitempty"`
Error string `json:"error,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ConsumedAt *time.Time `json:"consumed_at,omitempty"`
}
type SessionInputStatus ¶ added in v0.1.13
type SessionInputStatus string
const ( SessionInputStatusPending SessionInputStatus = "pending" SessionInputStatusConsumed SessionInputStatus = "consumed" SessionInputStatusError SessionInputStatus = "error" )
type SessionInputStore ¶ added in v0.1.13
type SessionInputStore interface {
CreateSessionInput(ctx context.Context, input SessionInput) error
UpdateSessionInput(ctx context.Context, input SessionInput) error
ListPendingSessionInputs(ctx context.Context, sessionID string) ([]SessionInput, error)
NextPendingSessionInput(ctx context.Context, sessionID string) (SessionInput, error)
ListPendingSteerInputs(ctx context.Context, sessionID string, runID string) ([]SessionInput, error)
HasConsumedSessionInput(ctx context.Context, sessionID string, runID string) (bool, error)
}
type SessionKind ¶ added in v0.1.4
type SessionKind string
const ( SessionKindAssistant SessionKind = "assistant" SessionKindExternalAgent SessionKind = "external_agent" )
func NormalizeSessionKind ¶ added in v0.1.4
func NormalizeSessionKind(kind SessionKind) SessionKind
type SessionLLMRegistry ¶
type SessionLLMRegistry interface {
ActiveSelection() (providerID string, modelID string)
Providers() []SessionProviderOption
Normalize(providerID string, modelID string) (SessionProviderOption, string, error)
Models(ctx context.Context, providerID string) ([]string, error)
Resolve(ctx context.Context, providerID string, modelID string) (providers.Runtime, SessionProviderOption, string, error)
// ContextWindowTokens is the window the user set manually for the model, if any.
ContextWindowTokens(providerID string, modelID string) (int, bool)
}
type SessionListFilter ¶
type SessionModelsResponse ¶
type SessionProviderOption ¶
type SessionProvidersResponse ¶
type SessionProvidersResponse struct {
Providers []SessionProviderOption `json:"providers"`
}
type SessionResponse ¶
type SessionResponse struct {
Session Session `json:"session"`
}
type SessionRuntime ¶ added in v0.1.4
type SessionRuntime string
const ( SessionRuntimeMatrixClaw SessionRuntime = "matrixclaw" SessionRuntimeExternalAgent SessionRuntime = "external_agent" )
func NormalizeSessionRuntime ¶ added in v0.1.4
func NormalizeSessionRuntime(runtimeID SessionRuntime) SessionRuntime
type SessionSearchReport ¶ added in v0.1.12
type SessionSearchReport struct {
Query string `json:"query"`
Sessions []SessionSearchResult `json:"sessions"`
}
type SessionSearchResult ¶ added in v0.1.12
type SessionSearchResult struct {
Session Session `json:"session"`
Matches []SearchResult `json:"matches"`
}
type SessionStatus ¶
type SessionStatus string
const ( SessionStatusActive SessionStatus = "active" SessionStatusArchived SessionStatus = "archived" )
type SessionStore ¶
type SessionStore interface {
CreateSession(ctx context.Context, session Session) error
GetSession(ctx context.Context, sessionID string) (Session, error)
ListSessions(ctx context.Context, filter SessionListFilter) ([]Session, error)
UpdateSession(ctx context.Context, session Session) error
DeleteSession(ctx context.Context, sessionID string) error
}
type SessionTasksResponse ¶ added in v0.2.0
type SessionTasksResponse struct {
Tasks []Task `json:"tasks"`
}
SessionTasksResponse lists a session's background tasks.
type SessionTodoResponse ¶ added in v0.2.0
type SessionsResponse ¶
type SessionsResponse struct {
Sessions []Session `json:"sessions"`
}
type SkillsPromptContextProvider ¶ added in v0.1.11
type SkillsPromptContextProvider interface {
SkillsPromptContext(context.Context, SkillsPromptContextRequest) string
}
type SkillsPromptContextRequest ¶ added in v0.1.11
type SkillsPromptContextRequest struct {
SessionID string
RunID string
WorkingDir string
Messages []SkillsPromptMessage
}
type SkillsPromptMessage ¶ added in v0.1.11
type SubagentIsolation ¶ added in v0.1.13
type SubagentIsolation string
SubagentIsolation is where a subagent works: in its parent's directory or in a git worktree of its own.
const ( SubagentIsolationWorktree SubagentIsolation = "worktree" )
type SubagentRuntime ¶ added in v0.1.12
type SubagentRuntime string
SubagentRuntime runs a subagent: matrixclaw's own engine or an external agent.
const ( SubagentRuntimeMatrixClaw SubagentRuntime = "matrixclaw" SubagentRuntimeCodex SubagentRuntime = "codex" SubagentRuntimeClaude SubagentRuntime = "claude" SubagentRuntimeAuto SubagentRuntime = "auto" )
type Task ¶ added in v0.2.0
type Task struct {
ID string `json:"id"`
SessionID string `json:"session_id"`
RunID string `json:"run_id,omitempty"`
ParentToolCallID string `json:"parent_tool_call_id,omitempty"`
Kind TaskKind `json:"kind"`
Status TaskStatus `json:"status"`
Command string `json:"command"`
Description string `json:"description,omitempty"`
WorkingDir string `json:"working_dir,omitempty"`
Background bool `json:"background"`
AgentName string `json:"agent_name,omitempty"`
Runtime string `json:"runtime,omitempty"`
Model string `json:"model,omitempty"`
Isolation SubagentIsolation `json:"isolation,omitempty"`
// Readonly subagents get read-only tools only.
Readonly bool `json:"readonly,omitempty"`
PID int `json:"pid,omitempty"`
PGID int `json:"pgid,omitempty"`
LeaderStart string `json:"-"`
BootID string `json:"-"`
OutputPath string `json:"output_path,omitempty"`
ExitCode *int `json:"exit_code,omitempty"`
OutputCursor int64 `json:"output_cursor,omitempty"`
ChildSessionID string `json:"child_session_id,omitempty"`
ChildRunID string `json:"child_run_id,omitempty"`
Summary string `json:"summary,omitempty"`
Error string `json:"error,omitempty"`
DeliveredAt *time.Time `json:"delivered_at,omitempty"`
DeliveredRunID string `json:"delivered_run_id,omitempty"`
StartedAt time.Time `json:"started_at"`
UpdatedAt time.Time `json:"updated_at"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
}
Task is work a session runs besides its runs: a shell command or a subagent that SessionID's run RunID started with its call ParentToolCallID. Command is the shell command or the subagent's prompt, Description its label; a blocking subagent is not Background. A finished background task whose DeliveredAt is nil is an event its session has not seen yet.
type TaskDetailResponse ¶ added in v0.2.0
type TaskDetailResponse struct {
Task Task `json:"task"`
OutputTail string `json:"output_tail,omitempty"`
}
TaskDetailResponse is a task and the end of its output.
type TaskEnd ¶ added in v0.2.0
type TaskEnd struct {
Status TaskStatus
ExitCode *int
Summary string
Error string
Delivered bool
At time.Time
}
TaskEnd is how a task ended; a Delivered end is no event for its session.
type TaskFilter ¶ added in v0.2.0
type TaskFilter struct {
SessionID string
RunID string
ParentToolCallID string
ChildRunID string
ChildSessionID string
Kind TaskKind
Statuses []TaskStatus
Background bool
Undelivered bool
Limit int
}
TaskFilter selects tasks; Background keeps background tasks only and Undelivered finished background tasks their session has not seen.
type TaskResponse ¶ added in v0.2.0
type TaskResponse struct {
Task Task `json:"task"`
}
TaskResponse carries one task.
type TaskStatus ¶ added in v0.2.0
type TaskStatus string
TaskStatus is where a background task stands.
const ( TaskStatusPending TaskStatus = "pending" TaskStatusRunning TaskStatus = "running" TaskStatusWaitingApproval TaskStatus = "waiting_approval" TaskStatusCompleted TaskStatus = "completed" TaskStatusFailed TaskStatus = "failed" TaskStatusCanceled TaskStatus = "canceled" // TaskStatusLost is a shell task the daemon stopped when it restarted. TaskStatusLost TaskStatus = "lost" )
func (TaskStatus) Terminal ¶ added in v0.2.0
func (s TaskStatus) Terminal() bool
Terminal reports whether the task has ended.
type TaskStore ¶ added in v0.2.0
type TaskStore interface {
CreateTask(ctx context.Context, task Task) error
GetTask(ctx context.Context, taskID string) (Task, error)
ListTasks(ctx context.Context, filter TaskFilter) ([]Task, error)
FinishTask(ctx context.Context, taskID string, end TaskEnd) (bool, error)
SetTaskStatus(ctx context.Context, taskID string, status TaskStatus, at time.Time) error
SetTaskCursor(ctx context.Context, taskID string, cursor int64) error
MarkTasksDelivered(ctx context.Context, taskIDs []string, runID string, at time.Time) error
}
TaskStore keeps the shell and subagent tasks of sessions. FinishTask ends a task once and reports whether this call ended it; SetTaskStatus changes only a task that has not ended.
type TodoStore ¶ added in v0.2.0
type TodoStore interface {
GetSessionTodo(ctx context.Context, sessionID string) (todo.List, error)
SaveSessionTodo(ctx context.Context, list todo.List) error
}
TodoStore keeps each session's todo list.
type ToolExecuteResponse ¶
type ToolExecuteResponse struct {
Result ExecuteToolResult `json:"result"`
}
type ToolExecutor ¶
type ToolExecutor interface {
List() []tools.Spec
Spec(toolID string) (tools.Spec, bool)
Execute(ctx context.Context, toolID string, call tools.Call) (tools.Result, error)
// Preview is the approval a call shows, or the result that answers it instead.
Preview(ctx context.Context, toolID string, call tools.Call) (tools.ApprovalRequest, *tools.Result)
// Subject is what permission rules match of a call.
Subject(toolID string, call tools.Call) permission.Subject
// ConcurrencyKey names what the call must not share with a concurrent call.
ConcurrencyKey(toolID string, call tools.Call) string
}
type ToolLifecycleState ¶
type ToolLifecycleState string
const ( ToolLifecycleRequested ToolLifecycleState = "requested" ToolLifecycleWaitingApproval ToolLifecycleState = "waiting_approval" ToolLifecycleCompleted ToolLifecycleState = "completed" ToolLifecycleFailed ToolLifecycleState = "failed" )
type ToolUpdate ¶
type ToolUpdate struct {
ToolCallID string `json:"tool_call_id"`
ToolName string `json:"tool_name"`
State ToolLifecycleState `json:"state"`
ResultStatus string `json:"result_status,omitempty"`
RunID string `json:"run_id,omitempty"`
SessionID string `json:"session_id,omitempty"`
ApprovalID string `json:"approval_id,omitempty"`
ResultMessageID string `json:"result_message_id,omitempty"`
Error string `json:"error,omitempty"`
}
type ToolsResponse ¶
type UpdateExternalAgentRequest ¶ added in v0.1.6
type UpdateSessionLLMRequest ¶
type UpdateSessionPermissionModeInput ¶
type UpdateSessionPermissionModeInput struct {
SessionID string
PermissionMode PermissionMode
}
type UpdateSessionPermissionModeRequest ¶
type UpdateSessionPermissionModeRequest struct {
PermissionMode string `json:"permission_mode"`
}
type UsageFilter ¶ added in v0.1.7
type UsageRecord ¶ added in v0.1.7
type UsageRecord struct {
SessionID string `json:"session_id"`
RunID string `json:"run_id"`
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
Steps int `json:"steps"`
PromptTokens int64 `json:"prompt_tokens,omitempty"`
CacheReadTokens int64 `json:"cache_read_tokens,omitempty"`
CacheWriteTokens int64 `json:"cache_write_tokens,omitempty"`
OutputTokens int64 `json:"output_tokens,omitempty"`
ReasoningTokens int64 `json:"reasoning_tokens,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
}
UsageRecord sums the run_steps of one run; Provider and Model are the last step's.
type UsageReport ¶ added in v0.1.7
type UsageReport struct {
Summary UsageSummary `json:"summary"`
Records []UsageRecord `json:"records,omitempty"`
}
type UsageResponse ¶ added in v0.1.7
type UsageResponse struct {
Usage UsageReport `json:"usage"`
}
type UsageStore ¶ added in v0.1.7
type UsageSummary ¶ added in v0.1.7
type UsageSummary struct {
SessionID string `json:"session_id,omitempty"`
Runs int `json:"runs"`
Steps int `json:"steps"`
PromptTokens int64 `json:"prompt_tokens,omitempty"`
CacheReadTokens int64 `json:"cache_read_tokens,omitempty"`
CacheWriteTokens int64 `json:"cache_write_tokens,omitempty"`
OutputTokens int64 `json:"output_tokens,omitempty"`
ReasoningTokens int64 `json:"reasoning_tokens,omitempty"`
}
type UseBindingInput ¶
Source Files
¶
- agent_inbox.go
- agent_journal.go
- agent_prompts.go
- agent_sink.go
- agent_tools.go
- await.go
- bindings.go
- compact_model.go
- context_boundary.go
- contracts.go
- core.go
- deliveries.go
- errors.go
- events.go
- external_agent_execution.go
- external_agents.go
- memory.go
- memory_tools.go
- messages.go
- permission_rules.go
- permissions.go
- ports.go
- realtime_voice.go
- run_budget.go
- run_cancel.go
- run_checkpoint.go
- run_continue.go
- run_execute.go
- run_lifecycle.go
- run_recovery.go
- run_timing.go
- run_wakeups.go
- runs.go
- search.go
- session_context.go
- session_inputs.go
- session_titles.go
- sessions.go
- shell_tasks.go
- snapshot.go
- subagents.go
- subagents_presentation.go
- subagents_prompt.go
- subagents_runtime.go
- subagents_tasks.go
- subagents_tools.go
- subagents_worktree.go
- system_messages.go
- task_events.go
- task_wake.go
- tasks.go
- todo.go
- tool_approvals.go
- tool_call_approval.go
- tool_call_finish.go
- tool_call_prepare.go
- tool_call_run.go
- tool_helpers.go
- tool_output.go
- tool_permissions.go
- tool_specs.go
- tools.go
- types_approval.go
- types_budget.go
- types_delivery.go
- types_memory.go
- types_run.go
- types_search.go
- types_server.go
- types_session.go
- types_task.go
- types_usage.go
- usage.go