Documentation
¶
Index ¶
- Constants
- Variables
- func AgentToolExecutors(app *Core) []tools.Executor
- func AwaitToolExecutors(app *Core) []tools.Executor
- func CheckpointToolExecutors(app *Core) []tools.Executor
- func CoreSessionIsExternalAgent(session Session) bool
- func DiffStat(changes []checkpoint.Change) string
- func GoalToolExecutors(app *Core) []tools.Executor
- func NewSessionSearchTool(app *Core) tools.Executor
- func PlanModeToolExecutors(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 AgentProfile
- 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 Config
- 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) ChangeSessionGoal(ctx context.Context, sessionID string, action GoalAction) (GoalResponse, error)
- func (c *Core) ClearContext(ctx context.Context, sessionID string) (transcript.Message, error)
- func (c *Core) ClearSessionGoal(ctx context.Context, sessionID string) (GoalResponse, 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) 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) 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) FileCheckpoints(ctx context.Context, sessionID string) (FileCheckpointsResponse, error)
- func (c *Core) GetApproval(ctx context.Context, approvalID string) (Approval, error)
- func (c *Core) GetPermissionRule(ctx context.Context, ruleID string) (permission.Rule, error)
- 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) ListApprovals(ctx context.Context, sessionID string, state ApprovalState) ([]Approval, error)
- func (c *Core) ListClientDeliveries(ctx context.Context, filter ClientDeliveryFilter) ([]ClientDelivery, 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, deliveryID string, deliveryErr error) error
- func (c *Core) MessageSession(ctx context.Context, input HandleMessageInput) (Session, error)
- func (c *Core) ModelsForSession(ctx context.Context, sessionID string, providerID string) (SessionModelsResponse, 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) RestoreFileCheckpoint(ctx context.Context, sessionID, checkpointID string) (FileCheckpointRestoreResponse, error)
- 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) SandboxStatus() string
- 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) SessionGoal(ctx context.Context, sessionID string) (GoalResponse, error)
- func (c *Core) SessionHooks(ctx context.Context, sessionID string) (hooks.Listing, 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) SetRuntimeStatusContext(provider RuntimeStatusContextProvider)
- func (c *Core) SetSessionGoal(ctx context.Context, sessionID string, input GoalInput) (GoalResponse, error)
- func (c *Core) SetSessionLLMs(registry SessionLLMRegistry)
- func (c *Core) SetTools(tools ToolExecutor)
- func (c *Core) SetTuning(tuning Tuning)
- func (c *Core) SteerSubagent(ctx context.Context, parentSessionID string, taskID string, message string) (Task, error)
- func (c *Core) StopShellTasks()
- func (c *Core) StopTask(ctx context.Context, call tools.Call, taskID string) (tools.TaskInfo, error)
- func (c *Core) SubscribeEvents(ctx context.Context, sessionID string, afterID uint64) <-chan events.Event
- func (c *Core) TaskDetail(ctx context.Context, taskID string) (TaskDetailResponse, error)
- func (c *Core) TrustSessionHooks(ctx context.Context, sessionID string, sum string) (hooks.Listing, error)
- func (c *Core) Tuning() Tuning
- func (c *Core) UpdateSessionBudget(ctx context.Context, sessionID string, budget SessionBudget) (SessionBudgetReport, error)
- func (c *Core) UpdateSessionLLM(ctx context.Context, sessionID string, providerID string, modelID string) (Session, error)
- func (c *Core) UpdateSessionPermissionMode(ctx context.Context, input UpdateSessionPermissionModeInput) (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
- type CreateSessionInput
- type CreateSessionRequest
- type CreateSystemMessageRequest
- type DeliveryStore
- type DocumentDeliveryPayload
- type EngineStateStore
- type ErrorResponse
- type ExecuteToolInput
- type ExecuteToolResult
- type ExternalAgentDescriptor
- type ExternalAgentsResponse
- type FileCheckpoint
- type FileCheckpointRestoreResponse
- type FileCheckpointStore
- type FileCheckpointView
- type FileCheckpointsResponse
- type GoalAction
- type GoalInput
- type GoalResponse
- type GoalStatus
- type GoalStore
- type HandleMessageInput
- type HandleTriggeredRunInput
- type HealthResponse
- type Memory
- type MemoryResponse
- 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 PromptEnvironment
- type RenameSessionInput
- type RenameSessionRequest
- type ReviewedSkill
- 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 SessionGoal
- type SessionInput
- type SessionInputStatus
- type SessionInputStore
- type SessionKind
- type SessionLLMRegistry
- type SessionListFilter
- type SessionModelsResponse
- type SessionProviderOption
- type SessionProvidersResponse
- type SessionResponse
- type SessionReviewSettings
- type SessionSearchReport
- type SessionSearchResult
- type SessionStatus
- type SessionStore
- type SessionTasksResponse
- type SessionTodoResponse
- type SessionsResponse
- type SkillLearning
- type SkillProposal
- 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 TrustHooksRequest
- type Tuning
- 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 ( EventRunUpdated events.Type = "run.updated" EventMessageCreated events.Type = "message.created" EventMessageUpdated events.Type = "message.updated" EventTodoUpdated events.Type = "todo.updated" EventToolUpdated events.Type = "tool.updated" EventApprovalRequest events.Type = "approval.requested" EventApprovalResult events.Type = "approval.resolved" EventInputUpdated events.Type = "input.updated" EventTaskUpdated events.Type = "task.updated" EventContextUpdated events.Type = "context.updated" )
const ( // MaxGoalObjective bounds the objective, in bytes. MaxGoalObjective = 2000 // DefaultGoalRuns and MaxGoalRuns are the runs a goal may start on its own. DefaultGoalRuns = 10 MaxGoalRuns = 50 )
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 EventGoalUpdated events.Type = "goal.updated"
EventGoalUpdated carries a GoalResponse whenever a session goal changes.
const ReviewStopReason = "review"
ReviewStopReason marks a session review's generation in run_steps; it is recorded on the run the review followed and is no step of it.
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 and the tools that steer its background children and merge or drop its worktree children's work.
func AwaitToolExecutors ¶ added in v0.2.0
AwaitToolExecutors returns the await tool.
func CheckpointToolExecutors ¶ added in v0.2.1
CheckpointToolExecutors returns checkpoint_diff while file checkpoints are on.
func CoreSessionIsExternalAgent ¶ added in v0.1.12
func DiffStat ¶ added in v0.2.1
func DiffStat(changes []checkpoint.Change) string
DiffStat renders changes as one line per file and a total, like git's diffstat.
func GoalToolExecutors ¶ added in v0.2.1
GoalToolExecutors exposes the session goal to models. A goal is set by the user only, so there is no tool that creates one.
func NewSessionSearchTool ¶ added in v0.2.1
NewSessionSearchTool lets models recall earlier sessions with the user.
func PlanModeToolExecutors ¶ added in v0.2.1
PlanModeToolExecutors returns exit_plan_mode, offered only in plan mode.
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
// AgentType names the child's profile; "" is general.
AgentType string
// OutputSchema is the JSON schema the child's final answer must match.
OutputSchema json.RawMessage
}
AgentInput is one agent tool call: a child agent on a bounded task.
type AgentProfile ¶ added in v0.2.1
type AgentProfile struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Prompt string `json:"prompt,omitempty"`
Tools []string `json:"tools,omitempty"`
Readonly bool `json:"readonly,omitempty"`
Model string `json:"model,omitempty"`
BudgetSteps int `json:"budget_steps,omitempty"`
LeanContext bool `json:"lean_context,omitempty"`
// Source is "builtin" or the file the profile was read from.
Source string `json:"source,omitempty"`
}
AgentProfile is a kind of child agent, the builtin types and the user's agent files alike: the child's prompt, the tools it may use (none listed: every tool a child gets), whether it is read-only, its default model and step budget. LeanContext leaves large project instructions out.
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"`
}
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"`
Goal *SessionGoal `json:"goal,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 Config ¶ added in v0.2.1
type Config struct {
Store Store
// Clock defaults to time.Now.
Clock func() time.Time
// Lifetime is the daemon's; interrupted runs are rescheduled only while
// it is alive. It defaults to context.Background.
Lifetime context.Context
// RunStarter defaults to executing each run in a goroutine of its own.
RunStarter RunStarter
Attachments agentcontext.AttachmentReader
// ExternalAgents is the registry runs start with; SetExternalAgents swaps it.
ExternalAgents *externalagents.Registry
ExternalAgentStore externalagents.AttachmentStore
SkillsContext SkillsPromptContextProvider
// Memory is shown to native runs; nil shows none.
Memory Memory
// SkillLearning turns on session reviews, which file what they find with it.
SkillLearning SkillLearning
// PromptEnvironment is where native runs are told they work; without a
// timezone their clock reads in UTC.
PromptEnvironment PromptEnvironment
// SessionFiles holds per-session files such as full tool outputs; a
// session's files are removed with it.
SessionFiles string
// Worktrees holds the git worktrees of worktree subagents; without it
// worktree isolation is unavailable.
Worktrees string
// Checkpoints snapshots working directories before tool batches that
// change files; nil takes none.
Checkpoints *checkpoint.Store
// CommandEnvironment is read for every shell command; nil inherits the
// daemon's environment.
CommandEnvironment func() []string
// Sandbox is read for every shell command; nil leaves commands unconfined.
Sandbox func() sandbox.Settings
// Hooks runs the user's hooks and the checks after edits; nil runs none.
Hooks *hooks.Runner
// LSPAvailable says whether a language server serves a project; nil never
// offers the lsp tool.
LSPAvailable func(workingDir string) bool
}
Config holds what a Core is built with. Each field is read while runs execute, so a Core takes them once here; what changes while the daemon serves, or is built on the Core itself, goes through the Set* methods.
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) ChangeSessionGoal ¶ added in v0.2.1
func (c *Core) ChangeSessionGoal(ctx context.Context, sessionID string, action GoalAction) (GoalResponse, error)
ChangeSessionGoal pauses an active goal, or resumes a paused or blocked one with a fresh allowance of runs and tokens when it had used them up.
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) ClearSessionGoal ¶ added in v0.2.1
ClearSessionGoal removes the session's goal; a run working on it finishes, and no other starts for it.
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, the way a run does when its context fills up; usage is recorded on the session's latest run, whose request stays verbatim.
func (*Core) CreateClientDelivery ¶
func (c *Core) CreateClientDelivery(ctx context.Context, delivery ClientDelivery) (ClientDelivery, error)
func (*Core) CreateSession ¶
func (*Core) CreateSystemMessage ¶
func (*Core) CurrentBinding ¶
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) FileCheckpoints ¶ added in v0.2.1
func (c *Core) FileCheckpoints(ctx context.Context, sessionID string) (FileCheckpointsResponse, error)
FileCheckpoints lists the session's checkpoints, newest first, with what restoring each would change now.
func (*Core) GetApproval ¶ added in v0.2.1
GetApproval returns one approval.
func (*Core) GetPermissionRule ¶ added in v0.2.1
GetPermissionRule returns a rule; ErrNotFound when no rule has the ID.
func (*Core) GetSession ¶ added in v0.1.16
func (*Core) ListApprovals ¶
func (c *Core) ListApprovals(ctx context.Context, sessionID string, state ApprovalState) ([]Approval, error)
ListApprovals lists the approvals in state (any when empty) the session and its subagents asked for.
func (*Core) ListClientDeliveries ¶
func (c *Core) ListClientDeliveries(ctx context.Context, filter ClientDeliveryFilter) ([]ClientDelivery, 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) MessageSession ¶ added in v0.2.1
MessageSession is the session a message goes to: the one it names, the client's binding, or the only session when the client may bind to it.
func (*Core) ModelsForSession ¶
func (c *Core) ModelsForSession(ctx context.Context, sessionID string, providerID string) (SessionModelsResponse, error)
ModelsForSession lists the models provider offers the session (an empty provider is the session's own) with the one the session would use; a failed discovery is reported in ModelsError.
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; worktrees no task keeps are removed; an idle session starts its next queued message, a run for background work that finished meanwhile, or its goal's next run.
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) RestoreFileCheckpoint ¶ added in v0.2.1
func (c *Core) RestoreFileCheckpoint(ctx context.Context, sessionID, checkpointID string) (FileCheckpointRestoreResponse, error)
RestoreFileCheckpoint brings the session's working directory back to the checkpoint while no run is active. It first checkpoints the state it replaces, so a restore can be undone, and leaves the model a note naming the files it changed.
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) SandboxStatus ¶ added in v0.2.1
SandboxStatus says how this daemon confines shell commands.
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) SessionGoal ¶ added in v0.2.1
SessionGoal returns the session's goal, nil when it has none.
func (*Core) SessionHooks ¶ added in v0.2.1
SessionHooks lists the hooks the session's runs meet: setup.json's and those of its project's hooks file, with whether the owner trusted it.
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) SetRuntimeStatusContext ¶ added in v0.2.1
func (c *Core) SetRuntimeStatusContext(provider RuntimeStatusContextProvider)
SetRuntimeStatusContext wires the note on module state, whose provider is built on this Core; call it before the Core serves.
func (*Core) SetSessionGoal ¶ added in v0.1.7
func (c *Core) SetSessionGoal(ctx context.Context, sessionID string, input GoalInput) (GoalResponse, error)
SetSessionGoal gives the session a new goal in place of the one it had, and starts working on it when the session is idle.
func (*Core) SetSessionLLMs ¶
func (c *Core) SetSessionLLMs(registry SessionLLMRegistry)
func (*Core) SetTools ¶ added in v0.2.1
func (c *Core) SetTools(tools ToolExecutor)
SetTools wires the tool executor, which is built on this Core; call it before the Core serves.
func (*Core) SetTuning ¶ added in v0.2.1
SetTuning applies tuning at once and is safe at any time: runs read the limits as they go, and the model slots resize in place.
func (*Core) SteerSubagent ¶ added in v0.2.1
func (c *Core) SteerSubagent(ctx context.Context, parentSessionID string, taskID string, message string) (Task, error)
SteerSubagent sends a running background child of the parent session a message, as a steer its run reads before its next step.
func (*Core) StopShellTasks ¶ added in v0.2.1
func (c *Core) StopShellTasks()
StopShellTasks stops the background commands of this daemon, for its shutdown, and waits until they ended; their tasks stay running in the store, and the next start marks them lost.
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 (c *Core) SubscribeEvents(ctx context.Context, sessionID string, afterID uint64) <-chan events.Event
SubscribeEvents streams the session's events (every session's for an empty sessionID), first those after afterID the bus still holds.
func (*Core) TaskDetail ¶ added in v0.2.0
TaskDetail returns a task and the end of its output.
func (*Core) TrustSessionHooks ¶ added in v0.2.1
func (c *Core) TrustSessionHooks(ctx context.Context, sessionID string, sum string) (hooks.Listing, error)
TrustSessionHooks trusts the session's project hooks file while it has the SHA256 sum the owner was shown; only the owner may call it.
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) UpdateSessionLLM ¶ added in v0.2.1
func (c *Core) UpdateSessionLLM(ctx context.Context, sessionID string, providerID string, modelID string) (Session, error)
UpdateSessionLLM sets the provider and model of a session; an empty provider keeps the session's. An external agent session takes a model only.
func (*Core) UpdateSessionPermissionMode ¶
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)
type CreateSessionInput ¶
type CreateSessionInput struct {
Title string
// Kind is assistant or external_agent; an ExternalAgentID implies the latter.
Kind SessionKind
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
}
func (CreateSessionInput) KindAndMode ¶ added in v0.2.1
func (input CreateSessionInput) KindAndMode() (SessionKind, PermissionMode)
KindAndMode is the kind and permission mode of the session the input creates; an external agent runs full_auto unless a mode is given.
type CreateSessionRequest ¶
type CreateSessionRequest struct {
Title string `json:"title"`
Kind string `json:"kind,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)
// FinishClientDelivery ends a delivery with status at the given time.
FinishClientDelivery(ctx context.Context, id string, status ClientDeliveryStatus, errText string, at time.Time) error
// ReleaseHeldClientDeliveries makes every held delivery pending.
ReleaseHeldClientDeliveries(ctx context.Context, at time.Time) error
}
type DocumentDeliveryPayload ¶ added in v0.1.15
type DocumentDeliveryPayload struct {
StoragePath string `json:"storage_path"`
Temporary bool `json:"temporary,omitempty"`
FileName string `json:"file_name,omitempty"`
Caption string `json:"caption,omitempty"`
MIMEType string `json:"mime_type,omitempty"`
Size int64 `json:"size,omitempty"`
// Photo shows an image inline where the client can; else it is a document.
Photo bool `json:"photo,omitempty"`
}
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 state a session's next run starts from.
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
}
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 FileCheckpoint ¶ added in v0.2.1
type FileCheckpoint struct {
ID string `json:"id"`
SessionID string `json:"session_id"`
RunID string `json:"run_id,omitempty"`
Seq int64 `json:"seq"`
ToolName string `json:"tool_name,omitempty"`
WorkingDir string `json:"working_dir"`
Tree string `json:"tree"`
CreatedAt time.Time `json:"created_at"`
}
FileCheckpoint is a snapshot of a session's working directory taken before a tool batch changed files (RunID set) or before a restore (RunID empty). Seq is the session's newest message when it was taken.
type FileCheckpointRestoreResponse ¶ added in v0.2.1
type FileCheckpointRestoreResponse struct {
Checkpoint FileCheckpoint `json:"checkpoint"`
Changes []checkpoint.Change `json:"changes"`
Note *transcript.Message `json:"note,omitempty"`
}
FileCheckpointRestoreResponse is what a restore changed and the note it left for the model; Note is empty when nothing had to change.
type FileCheckpointStore ¶ added in v0.2.1
type FileCheckpointStore interface {
CreateFileCheckpoint(ctx context.Context, checkpoint FileCheckpoint) error
GetFileCheckpoint(ctx context.Context, id string) (FileCheckpoint, error)
// ListFileCheckpoints lists the session's checkpoints; limit 0 lists all.
ListFileCheckpoints(ctx context.Context, sessionID string, limit int) ([]FileCheckpoint, error)
// TrimFileCheckpoints keeps the newest keep checkpoints of the working
// directory and reports whether it deleted any.
TrimFileCheckpoints(ctx context.Context, workingDir string, keep int) (bool, error)
// FileCheckpointTrees lists the trees the working directory's checkpoints keep.
FileCheckpointTrees(ctx context.Context, workingDir string) ([]string, error)
}
FileCheckpointStore keeps file checkpoints; lists are newest first.
type FileCheckpointView ¶ added in v0.2.1
type FileCheckpointView struct {
FileCheckpoint
Changes []checkpoint.Change `json:"changes"`
}
FileCheckpointView is a checkpoint with what restoring it would change now.
type FileCheckpointsResponse ¶ added in v0.2.1
type FileCheckpointsResponse struct {
Checkpoints []FileCheckpointView `json:"checkpoints"`
}
FileCheckpointsResponse lists a session's checkpoints, newest first; Unavailable says why there are none to restore when checkpoints are off or the working directory is not snapshotted.
type GoalAction ¶ added in v0.2.1
type GoalAction string
GoalAction is a change of a goal's status by the user.
const ( GoalPause GoalAction = "pause" GoalResume GoalAction = "resume" )
type GoalInput ¶ added in v0.2.1
type GoalInput struct {
Objective string `json:"objective"`
CheckCommand string `json:"check_command,omitempty"`
MaxRuns int `json:"max_runs,omitempty"`
TokenBudget int64 `json:"token_budget,omitempty"`
Client string `json:"client,omitempty"`
ExternalKey string `json:"external_key,omitempty"`
ClientCapabilities ClientCapabilities `json:"client_capabilities,omitempty"`
}
GoalInput sets a session goal; zero MaxRuns takes DefaultGoalRuns and zero TokenBudget leaves tokens unlimited. Client, ExternalKey and ClientCapabilities name who sets it: a client that receives deliveries gets the goal's first run.
type GoalResponse ¶ added in v0.2.1
type GoalResponse struct {
Goal *SessionGoal `json:"goal"`
}
GoalResponse is a session's goal; nil when it has none.
type GoalStatus ¶ added in v0.2.1
type GoalStatus string
GoalStatus is where a session goal stands.
const ( // GoalActive keeps the session working on the goal run after run. GoalActive GoalStatus = "active" // GoalPaused waits for /goal resume: the user stopped it, a run failed or // its allowance of runs or tokens is used up. GoalPaused GoalStatus = "paused" // GoalBlocked cannot go on without the user. GoalBlocked GoalStatus = "blocked" // GoalComplete is done, with evidence and a passing check. GoalComplete GoalStatus = "complete" )
type GoalStore ¶ added in v0.2.1
type GoalStore interface {
GetSessionGoal(ctx context.Context, sessionID string) (SessionGoal, error)
SaveSessionGoal(ctx context.Context, goal SessionGoal) error
DeleteSessionGoal(ctx context.Context, sessionID string) error
ListActiveSessionGoals(ctx context.Context) ([]SessionGoal, error)
}
GoalStore keeps each session's goal, one at most.
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"`
// Continue starts a run that continues the session's latest run; Text is ignored.
Continue bool `json:"continue,omitempty"`
}
type HandleTriggeredRunInput ¶
type HealthResponse ¶
type Memory ¶ added in v0.2.1
type Memory interface {
List(ctx context.Context, filter memory.Filter) ([]memory.Entry, error)
Create(ctx context.Context, entry memory.Entry) (memory.Entry, error)
PromptContext(ctx context.Context, workingDir string) (string, error)
}
Memory is the persistent memory native runs are shown and session reviews suggest entries to.
type MemoryResponse ¶ added in v0.1.12
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 PermissionModePlan PermissionMode = permission.ModePlan )
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
GetPermissionRule(ctx context.Context, ruleID string) (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 PromptEnvironment ¶ added in v0.2.1
PromptEnvironment is what native runs are told about the daemon's place: the timezone their clock reads in, the user's global instruction file and the directory of the user's agent files.
type RenameSessionInput ¶
type RenameSessionRequest ¶
type RenameSessionRequest struct {
Title string `json:"title"`
}
type ReviewedSkill ¶ added in v0.2.1
type ReviewedSkill struct {
ID, Name, Description, Body string
}
ReviewedSkill is a skill the session uses, shown to its review.
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
// since it last finished a step.
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" )
const RunTriggerGoal RunTrigger = "goal"
RunTriggerGoal is a run the session started on its own to work on its goal.
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"`
// Sandbox says how shell commands are confined (docs/SANDBOX.md).
Sandbox string `json:"sandbox,omitempty"`
}
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"`
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 SessionGoal ¶ added in v0.2.1
type SessionGoal struct {
SessionID string `json:"session_id"`
Objective string `json:"objective"`
CheckCommand string `json:"check_command,omitempty"`
MaxRuns int `json:"max_runs"`
TokenBudget int64 `json:"token_budget,omitempty"`
Status GoalStatus `json:"status"`
Reason string `json:"reason,omitempty"`
RunsUsed int `json:"runs_used"`
TokensUsed int64 `json:"tokens_used,omitempty"`
LastRunID string `json:"last_run_id,omitempty"`
LastStop string `json:"last_stop,omitempty"`
LastCheck string `json:"last_check,omitempty"`
CheckFailure string `json:"-"`
CheckFailures int `json:"check_failures,omitempty"`
LastBlocker string `json:"last_blocker,omitempty"`
BlockerRepeats int `json:"blocker_repeats,omitempty"`
BlockerRunID string `json:"-"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
SessionGoal is a long objective the session works on across runs until it is verifiably done. Reason says why it is paused or blocked, or holds the evidence it was completed with. RunsUsed and TokensUsed count the runs the goal started; LastRunID and LastStop name the newest run that ended since the goal was set and how it ended. CheckFailure and CheckFailures identify the newest failed check output and how often in a row it repeated; LastBlocker, BlockerRepeats and BlockerRunID the blocker the model reported.
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" )
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)
// ContextWindow is the model's window: the manual setting for the provider's
// configured model, else the model catalog.
ContextWindow(providerID string, modelID string) int
}
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 SessionReviewSettings ¶ added in v0.2.1
SessionReviewSettings are the session review's settings: Enabled turns it on, MinToolSteps is the tool-calling steps a session needs since its last review, Interval the least time between two reviews of a session.
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 SkillLearning ¶ added in v0.2.1
type SkillLearning interface {
ReviewSettings() SessionReviewSettings
ReviewedSkills(ctx context.Context, sessionID string) ([]ReviewedSkill, error)
// DraftProposal files a proposal as a quarantined, disabled draft and
// returns its id.
DraftProposal(ctx context.Context, proposal SkillProposal) (string, error)
}
SkillLearning is the skills library as session reviews use it.
type SkillProposal ¶ added in v0.2.1
type SkillProposal struct {
Name, Description, Body, Updates string
}
SkillProposal is a skill a session review proposes: a new one, or a new version of the session's skill Updates.
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"`
// Agent is the profile a subagent runs with; OutputSchema the JSON schema
// its final answer must match, if any.
Agent AgentProfile `json:"-"`
OutputSchema json.RawMessage `json:"-"`
// WorktreeBase is the commit a worktree subagent's branch started from,
// kept while its worktree (WorkingDir) waits to be merged or discarded.
WorktreeBase string `json:"worktree_base,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, WorkingDir where it runs (a worktree subagent's worktree); 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
ClearTaskWorktree(ctx context.Context, taskID 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)
// Subjects is every subject permission rules match of a call.
Subjects(toolID string, call tools.Call) []permission.Subject
// ReadsOnly reports whether a call changes nothing.
ReadsOnly(toolID string, call tools.Call) bool
// 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 TrustHooksRequest ¶ added in v0.2.1
type TrustHooksRequest struct {
SHA256 string `json:"sha256"`
}
TrustHooksRequest trusts a session's project hooks file with the SHA256 sum the owner was shown.
type Tuning ¶ added in v0.2.1
type Tuning struct {
Budgets RunBudgets
// CompactProvider and CompactModel are the summary model; empty is the
// run's own model.
CompactProvider string
CompactModel string
WindowCap int
ModelConcurrency int
BackgroundTasks int
BackgroundAgents int
}
Tuning is the daemon's run limits from setup.json; a zero field keeps the default.
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_environment.go
- agent_inbox.go
- agent_ports.go
- agent_profiles.go
- agent_prompts.go
- agent_tools.go
- await.go
- bindings.go
- checkpoint_tool.go
- compact_model.go
- context_boundary.go
- contracts.go
- core.go
- deliveries.go
- errors.go
- events.go
- external_agent_execution.go
- external_agents.go
- file_checkpoints.go
- goal_check.go
- goal_tools.go
- goals.go
- hooks.go
- messages.go
- permission_rules.go
- permissions.go
- plan_mode.go
- ports.go
- realtime_voice.go
- run_budget.go
- run_checkpoint.go
- run_continue.go
- run_execute.go
- run_lifecycle.go
- run_recovery.go
- run_timing.go
- run_wakeups.go
- runs.go
- sandbox.go
- search.go
- session_context.go
- session_gate.go
- session_inputs.go
- session_review.go
- session_review_parse.go
- session_titles.go
- sessions.go
- shell_tasks.go
- snapshot.go
- subagents.go
- subagents_output.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_calls.go
- tool_output.go
- tool_permissions.go
- tuning.go
- types_approval.go
- types_budget.go
- types_checkpoint.go
- types_delivery.go
- types_goal.go
- types_run.go
- types_search.go
- types_server.go
- types_session.go
- types_task.go
- types_usage.go
- usage.go