core

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ClientDeliveryTypeDaemonRestart = "daemon_restart"
	ClientDeliveryTypeAutomationRun = "automation_run"
)
View Source
const EstimatedImageTokens = 1_500

Variables

View Source
var (
	ErrNotFound                 = errors.New("not found")
	ErrBindingNotFound          = errors.New("binding not found")
	ErrSessionSelectionRequired = errors.New("session selection required")
	ErrInvalidInput             = errors.New("invalid input")
	ErrExecutionUnavailable     = errors.New("execution unavailable")
)
View Source
var ErrSessionRequired = errors.New("session_id is required")

Functions

func AssistantSystemPrompt

func AssistantSystemPrompt(profile AssistantProfile) string

func ContextClearedMessageContent added in v0.1.13

func ContextClearedMessageContent() string

func CoreSessionIsExternalAgent added in v0.1.12

func CoreSessionIsExternalAgent(session Session) bool

func DelegateTaskToolExecutor added in v0.1.12

func DelegateTaskToolExecutor(app *Core) tools.Executor

func EstimateMessageTokens

func EstimateMessageTokens(messages []Message) int

func EstimateProviderRequestTokens added in v0.1.10

func EstimateProviderRequestTokens(request providers.Request) int

func EstimateTextTokens

func EstimateTextTokens(text string) int

func FormatShortNumber

func FormatShortNumber(value int) string

func IsPlanRunPromptMessage added in v0.1.7

func IsPlanRunPromptMessage(message Message) bool

IsPlanRunPromptMessage reports whether message is an internal plan runner prompt. These prompts are stored so clients can audit local actions, but provider context already receives the current plan through sessionPlanPrompt.

func ListSubagentsToolExecutor added in v0.1.13

func ListSubagentsToolExecutor(app *Core) tools.Executor

func MemoryToolExecutors added in v0.1.12

func MemoryToolExecutors(app *Core) []tools.Executor

MemoryToolExecutors exposes session recall and persistent memory to models.

func PlanItemDepths added in v0.1.7

func PlanItemDepths(items []PlanItem) map[string]int

func PlanToolExecutors added in v0.1.7

func PlanToolExecutors(app *Core) []tools.Executor

PlanToolExecutors exposes session plan operations to models through the normal tool registry.

func ReadSubagentResultToolExecutor added in v0.1.13

func ReadSubagentResultToolExecutor(app *Core) tools.Executor

func SpawnSubagentToolExecutor added in v0.1.13

func SpawnSubagentToolExecutor(app *Core) tools.Executor

func SubagentToolExecutors added in v0.1.13

func SubagentToolExecutors(app *Core) []tools.Executor

Types

type AcceptRunErrorResponse

type AcceptRunErrorResponse struct {
	Error       string  `json:"error"`
	SessionID   string  `json:"session_id"`
	UserMessage Message `json:"user_message"`
	Run         Run     `json:"run"`
}

type AcceptRunResult

type AcceptRunResult struct {
	SessionID   string          `json:"session_id"`
	Status      AcceptRunStatus `json:"status,omitempty"`
	UserMessage 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 AddPlanItemRequest added in v0.1.7

type AddPlanItemRequest struct {
	Text     string `json:"text"`
	ParentID string `json:"parent_id,omitempty"`
}

type AdminRestartRequest

type AdminRestartRequest struct {
	Notification *ClientDeliveryTarget `json:"notification,omitempty"`
}

type Approval

type Approval struct {
	ID          string          `json:"id"`
	SessionID   string          `json:"session_id"`
	RunID       string          `json:"run_id,omitempty"`
	ToolCallRef string          `json:"tool_call_id,omitempty"`
	ToolName    string          `json:"tool_name,omitempty"`
	Description string          `json:"description,omitempty"`
	Action      string          `json:"action,omitempty"`
	Params      json.RawMessage `json:"params,omitempty"`
	Path        string          `json:"path,omitempty"`
	State       ApprovalState   `json:"state"`
	RequestedAt time.Time       `json:"requested_at"`
	DecidedAt   *time.Time      `json:"decided_at,omitempty"`
}

type ApprovalResolveRequest

type ApprovalResolveRequest struct {
	Approved bool `json:"approved"`
}

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)
	UpdateApproval(ctx context.Context, approval Approval) error
	ListApprovals(ctx context.Context, sessionID string, state ApprovalState) ([]Approval, error)
}

type ApprovalsResponse

type ApprovalsResponse struct {
	Approvals []Approval `json:"approvals"`
}

type AssistantProfile

type AssistantProfile struct {
	Name               string
	SystemPrompt       string
	CustomInstructions string
}

type AttachmentData

type AttachmentData struct {
	Data     []byte
	MIMEType string
	Name     string
	Size     int64
}

type AttachmentReader

type AttachmentReader interface {
	ReadAttachment(ctx context.Context, path string, temporary bool, maxBytes int64) (AttachmentData, error)
}

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 ClientBinding struct {
	Client      string    `json:"client"`
	ExternalKey string    `json:"external_key"`
	SessionID   string    `json:"session_id"`
	UpdatedAt   time.Time `json:"updated_at"`
}

type ClientBindingResponse

type ClientBindingResponse struct {
	Binding ClientBinding `json:"binding"`
}

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"`
	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 ClientDeliveryFilter

type ClientDeliveryFilter struct {
	Client       string
	ExternalKey  string
	SessionID    string
	RunID        string
	TaskID       string
	Type         string
	Status       ClientDeliveryStatus
	CreatedAfter time.Time
	Limit        int
}

type ClientDeliveryStatus

type ClientDeliveryStatus string
const (
	ClientDeliveryStatusPending ClientDeliveryStatus = "pending"
	ClientDeliveryStatusReady   ClientDeliveryStatus = "ready"
	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 {
	SessionID             string                   `json:"session_id"`
	Session               *Session                 `json:"session,omitempty"`
	Capabilities          *SessionCapabilities     `json:"capabilities,omitempty"`
	Context               *ContextReport           `json:"context,omitempty"`
	Plan                  *SessionPlan             `json:"plan,omitempty"`
	Messages              []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"`
	Files                 []FileSnapshot           `json:"files,omitempty"`
	Subagents             []SubagentTask           `json:"subagents,omitempty"`
	PendingInputs         []SessionInput           `json:"pending_inputs,omitempty"`
}

type ClientSnapshotResponse

type ClientSnapshotResponse struct {
	Snapshot ClientSnapshot `json:"snapshot"`
}

type CompactSessionResult

type CompactSessionResult struct {
	Message Message       `json:"message"`
	Context ContextReport `json:"context"`
}

type ContextBlock

type ContextBlock struct {
	ID             string           `json:"id"`
	Kind           ContextBlockKind `json:"kind"`
	Source         string           `json:"source"`
	TokenEstimate  int              `json:"token_estimate"`
	Included       bool             `json:"included"`
	Truncated      bool             `json:"truncated,omitempty"`
	CacheStability string           `json:"cache_stability,omitempty"`
}

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 ContextCompact struct {
	Recommended bool   `json:"recommended"`
	Reason      string `json:"reason,omitempty"`
}

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 *ProviderUsage `json:"last_provider_usage,omitempty"`
	Compact           ContextCompact `json:"compact"`
}

type Core

type Core struct {
	// contains filtered or unexported fields
}

func New

func New(store Store) *Core

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 (c *Core) AcknowledgeClientDelivery(ctx context.Context, deliveryID string) error

func (*Core) AddPlanItem added in v0.1.7

func (c *Core) AddPlanItem(ctx context.Context, sessionID string, text string, parentID string) (SessionPlan, error)

func (*Core) BindSessionPlanRunStep added in v0.1.7

func (c *Core) BindSessionPlanRunStep(ctx context.Context, sessionID string, runID string) error

func (*Core) CancelRun

func (c *Core) CancelRun(ctx context.Context, runID string) (Run, error)

func (*Core) ClearSessionPlan added in v0.1.7

func (c *Core) ClearSessionPlan(ctx context.Context, sessionID string) (SessionPlan, error)

func (*Core) ClientSnapshot

func (c *Core) ClientSnapshot(ctx context.Context, client string, externalKey string) (ClientSnapshot, error)

func (*Core) CompactSession

func (c *Core) CompactSession(ctx context.Context, sessionID string) (CompactSessionResult, error)

func (*Core) CompleteSessionPlanRunStep added in v0.1.7

func (c *Core) CompleteSessionPlanRunStep(ctx context.Context, run Run, assistantContent string) error

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 (c *Core) CreateSession(ctx context.Context, input CreateSessionInput) (Session, error)

func (*Core) CreateSystemMessage

func (c *Core) CreateSystemMessage(ctx context.Context, sessionID string, content string) (Message, error)

func (*Core) CurrentBinding

func (c *Core) CurrentBinding(ctx context.Context, client string, externalKey string) (ClientBinding, error)

func (*Core) DelegateTask added in v0.1.12

func (c *Core) DelegateTask(ctx context.Context, input DelegateTaskInput) (DelegateTaskResult, error)

func (*Core) DeleteMemory added in v0.1.12

func (c *Core) DeleteMemory(ctx context.Context, id string) error

func (*Core) DeleteSession

func (c *Core) DeleteSession(ctx context.Context, sessionID string) error

func (*Core) ExecuteRun

func (c *Core) ExecuteRun(ctx context.Context, runID string) error

func (*Core) ExecuteTool

func (c *Core) ExecuteTool(ctx context.Context, input ExecuteToolInput) (ExecuteToolResult, error)

func (*Core) ExternalAgents added in v0.1.4

func (c *Core) ExternalAgents(ctx context.Context) []ExternalAgentDescriptor

func (*Core) GetRun

func (c *Core) GetRun(ctx context.Context, runID string) (Run, error)

func (*Core) ListApprovals

func (c *Core) ListApprovals(ctx context.Context, sessionID string, state ApprovalState) ([]Approval, error)

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 (c *Core) ListMessages(ctx context.Context, sessionID string, limit int) ([]Message, error)

func (*Core) ListSessions

func (c *Core) ListSessions(ctx context.Context, filter SessionListFilter) ([]Session, error)

func (*Core) ListSubagents added in v0.1.13

func (c *Core) ListSubagents(ctx context.Context, parentSessionID string, includeRecent bool, limit int) ([]SubagentTask, error)

func (*Core) ListToolSpecs

func (c *Core) ListToolSpecs() []tools.Spec

func (*Core) MarkClientDeliveryFailed

func (c *Core) MarkClientDeliveryFailed(ctx context.Context, delivery ClientDelivery, deliveryErr error) error

func (*Core) MarkClientDeliveryReady

func (c *Core) MarkClientDeliveryReady(ctx context.Context, delivery ClientDelivery) error

func (*Core) MarkClientDeliverySent

func (c *Core) MarkClientDeliverySent(ctx context.Context, delivery ClientDelivery) error

func (*Core) MemoryPromptContext added in v0.1.12

func (c *Core) MemoryPromptContext(ctx context.Context, workingDir string) string

func (*Core) ModelsForSession

func (c *Core) ModelsForSession(ctx context.Context, sessionID string) (string, string, []string, error)

func (*Core) ReadSubagentResult added in v0.1.13

func (c *Core) ReadSubagentResult(ctx context.Context, parentSessionID string, taskID string, name string) (SubagentTask, string, error)

func (*Core) RecoverSessionInputs added in v0.1.13

func (c *Core) RecoverSessionInputs(ctx context.Context) error

func (*Core) RecoverSubagentTasks added in v0.1.13

func (c *Core) RecoverSubagentTasks(ctx context.Context) error

func (*Core) RenameSession

func (c *Core) RenameSession(ctx context.Context, input RenameSessionInput) (Session, error)

func (*Core) ResolveApproval

func (c *Core) ResolveApproval(ctx context.Context, approvalID string, approved bool) (Approval, error)

func (*Core) ResolveExternalAgentID added in v0.1.9

func (c *Core) ResolveExternalAgentID(id string) (string, bool)

func (*Core) Search added in v0.1.7

func (c *Core) Search(ctx context.Context, filter SearchFilter) (SearchReport, error)

func (*Core) SessionContext

func (c *Core) SessionContext(ctx context.Context, sessionID string) (ContextReport, error)

func (*Core) SessionPlan added in v0.1.7

func (c *Core) SessionPlan(ctx context.Context, sessionID string) (SessionPlan, error)

func (*Core) SessionPlanRun added in v0.1.7

func (c *Core) SessionPlanRun(ctx context.Context, sessionID string) (PlanRun, error)

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) SetAssistantProfile

func (c *Core) SetAssistantProfile(profile AssistantProfile)

func (*Core) SetSessionGoal added in v0.1.7

func (c *Core) SetSessionGoal(ctx context.Context, sessionID string, goal string) (SessionPlan, error)

func (*Core) SetSessionLLMs

func (c *Core) SetSessionLLMs(registry SessionLLMRegistry)

func (*Core) SpawnSubagent added in v0.1.13

func (c *Core) SpawnSubagent(ctx context.Context, input SpawnSubagentInput) (SpawnSubagentResult, error)

func (*Core) StartSessionPlanRun added in v0.1.7

func (c *Core) StartSessionPlanRun(ctx context.Context, sessionID string, reset bool) (PlanRun, SessionPlan, error)

func (*Core) SubscribeEvents

func (c *Core) SubscribeEvents(ctx context.Context, sessionID string) <-chan Event

func (*Core) SubscribeEventsAfter

func (c *Core) SubscribeEventsAfter(ctx context.Context, sessionID string, afterID uint64) <-chan Event

func (*Core) UpdateMemory added in v0.1.12

func (c *Core) UpdateMemory(ctx context.Context, entry MemoryEntry) (MemoryEntry, error)

func (*Core) UpdatePlanItem added in v0.1.7

func (c *Core) UpdatePlanItem(ctx context.Context, sessionID string, itemID string, status PlanItemStatus, text string) (SessionPlan, error)

func (*Core) UpdateSessionModel

func (c *Core) UpdateSessionModel(ctx context.Context, sessionID string, modelID string) (Session, error)

func (*Core) UpdateSessionPermissionMode

func (c *Core) UpdateSessionPermissionMode(ctx context.Context, input UpdateSessionPermissionModeInput) (Session, error)

func (*Core) UpdateSessionProvider

func (c *Core) UpdateSessionProvider(ctx context.Context, sessionID string, providerID string) (Session, error)

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) WithAttachmentReader

func (c *Core) WithAttachmentReader(reader 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).

func (*Core) WithClock

func (c *Core) WithClock(now func() time.Time) *Core

func (*Core) WithExternalAgents added in v0.1.4

func (c *Core) WithExternalAgents(registry *externalagents.Registry, store externalagents.AttachmentStore) *Core

func (*Core) WithHistoryLimit

func (c *Core) WithHistoryLimit(limit int) *Core

func (*Core) WithIDGenerator

func (c *Core) WithIDGenerator(newID func(prefix string) string) *Core

func (*Core) WithRunStarter added in v0.1.2

func (c *Core) WithRunStarter(starter RunStarter) *Core

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

func (*Core) WithWorkStore added in v0.1.14

func (c *Core) WithWorkStore(store work.Store) *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
}

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 DelegateTaskInput added in v0.1.12

type DelegateTaskInput struct {
	ParentSessionID  string
	ParentRunID      string
	ParentToolCallID string
	Goal             string
	Context          string
	Runtime          string
	Model            string
	WorkingDir       string
	Approved         bool
}

type DelegateTaskResult added in v0.1.12

type DelegateTaskResult struct {
	Task     SubagentTask
	Summary  string
	IsError  bool
	Approval *tools.ApprovalRequest
}

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 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"
	EventPlanUpdated     EventType = "plan.updated"
	EventToolUpdated     EventType = "tool.updated"
	EventApprovalRequest EventType = "approval.requested"
	EventApprovalResult  EventType = "approval.resolved"
	EventFileVersioned   EventType = "file.versioned"
	EventSubagentUpdated EventType = "subagent.updated"
	EventInputUpdated    EventType = "input.updated"
)

type ExecuteToolInput

type ExecuteToolInput struct {
	SessionID  string          `json:"session_id"`
	RunID      string          `json:"run_id,omitempty"`
	ToolName   string          `json:"tool_name"`
	ToolCallID string          `json:"tool_call_id,omitempty"`
	WorkingDir string          `json:"working_dir,omitempty"`
	Approved   bool            `json:"approved,omitempty"`
	Args       json.RawMessage `json:"args,omitempty"`
}

type ExecuteToolResult

type ExecuteToolResult struct {
	ToolCallMessage   Message   `json:"tool_call_message"`
	ToolResultMessage *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"`
	AuthState    string                      `json:"auth_state,omitempty"`
	Mode         string                      `json:"mode,omitempty"`
	Path         string                      `json:"path,omitempty"`
	Version      string                      `json:"version,omitempty"`
	Detail       string                      `json:"detail,omitempty"`
	Capabilities externalagents.Capabilities `json:"capabilities,omitempty"`
}

type ExternalAgentsResponse added in v0.1.4

type ExternalAgentsResponse struct {
	Agents []ExternalAgentDescriptor `json:"agents"`
}

type FileSnapshot

type FileSnapshot struct {
	ID        string    `json:"id"`
	SessionID string    `json:"session_id"`
	Path      string    `json:"path"`
	Content   string    `json:"content"`
	Version   int       `json:"version"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type FileSnapshotStore

type FileSnapshotStore interface {
	CreateFileSnapshot(ctx context.Context, snapshot FileSnapshot) (FileSnapshot, error)
	ListFileSnapshots(ctx context.Context, sessionID string) ([]FileSnapshot, error)
}

type FinishPart

type FinishPart struct {
	Reason  string          `json:"reason,omitempty"`
	Message string          `json:"message,omitempty"`
	Details json.RawMessage `json:"details,omitempty"`
}

type HandleMessageInput

type HandleMessageInput struct {
	Client           string        `json:"client"`
	ExternalKey      string        `json:"external_key"`
	SessionID        string        `json:"session_id"`
	Text             string        `json:"text"`
	Parts            []MessagePart `json:"parts,omitempty"`
	BusyMode         BusyInputMode `json:"busy_mode,omitempty"`
	WorkingDir       string        `json:"working_dir"`
	AllowAutoBindOne bool          `json:"allow_auto_bind_one"`
}

type HandleTriggeredRunInput

type HandleTriggeredRunInput struct {
	TriggerID   string
	Client      string
	ExternalKey string
	SessionID   string
	Text        string
	WorkingDir  string
}

type HealthResponse

type HealthResponse struct {
	OK      bool         `json:"ok"`
	Version version.Info `json:"version"`
}

type ImagePart

type ImagePart struct {
	MIMEType    string `json:"mime_type,omitempty"`
	DataBase64  string `json:"data_base64,omitempty"`
	Name        string `json:"name,omitempty"`
	StoragePath string `json:"storage_path,omitempty"`
	Temporary   bool   `json:"temporary,omitempty"`
	Size        int64  `json:"size,omitempty"`
}

type MemoryEntry added in v0.1.12

type MemoryEntry struct {
	ID         string      `json:"id"`
	Scope      MemoryScope `json:"scope"`
	Key        string      `json:"key,omitempty"`
	Content    string      `json:"content"`
	WorkingDir string      `json:"working_dir,omitempty"`
	CreatedAt  time.Time   `json:"created_at"`
	UpdatedAt  time.Time   `json:"updated_at"`
}

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 Message

type Message struct {
	ID        string        `json:"id"`
	SessionID string        `json:"session_id"`
	RunID     string        `json:"run_id"`
	Role      MessageRole   `json:"role"`
	Content   string        `json:"content"`
	Parts     []MessagePart `json:"parts,omitempty"`
	Model     string        `json:"model,omitempty"`
	Provider  string        `json:"provider,omitempty"`
	CreatedAt time.Time     `json:"created_at"`
	UpdatedAt time.Time     `json:"updated_at"`
}

type MessagePart

type MessagePart struct {
	Kind       MessagePartKind `json:"kind"`
	Text       *TextPart       `json:"text,omitempty"`
	Image      *ImagePart      `json:"image,omitempty"`
	Reasoning  *ReasoningPart  `json:"reasoning,omitempty"`
	ToolCall   *ToolCallPart   `json:"tool_call,omitempty"`
	ToolResult *ToolResultPart `json:"tool_result,omitempty"`
	Finish     *FinishPart     `json:"finish,omitempty"`
}

func NormalizeMessageParts

func NormalizeMessageParts(content string, parts []MessagePart) []MessagePart

type MessagePartKind

type MessagePartKind string
const (
	MessagePartKindText       MessagePartKind = "text"
	MessagePartKindImage      MessagePartKind = "image"
	MessagePartKindReasoning  MessagePartKind = "reasoning"
	MessagePartKindToolCall   MessagePartKind = "tool_call"
	MessagePartKindToolResult MessagePartKind = "tool_result"
	MessagePartKindFinish     MessagePartKind = "finish"
)

type MessageResponse

type MessageResponse struct {
	Message Message `json:"message"`
}

type MessageRole

type MessageRole string
const (
	MessageRoleUser      MessageRole = "user"
	MessageRoleAssistant MessageRole = "assistant"
	MessageRoleSystem    MessageRole = "system"
	MessageRoleTool      MessageRole = "tool"
)

type MessageStore

type MessageStore interface {
	SaveMessage(ctx context.Context, message Message) error
	UpdateMessage(ctx context.Context, message Message) error
	ListMessages(ctx context.Context, sessionID string, limit int) ([]Message, error)
}

type MessagesResponse

type MessagesResponse struct {
	Messages []Message `json:"messages"`
}

type OKResponse

type OKResponse struct {
	OK bool `json:"ok"`
}

type PermissionMode

type PermissionMode string
const (
	PermissionModeDefault     PermissionMode = "default"
	PermissionModeAcceptEdits PermissionMode = "accept_edits"
	PermissionModeFullAuto    PermissionMode = "full_auto"
)

func NormalizePermissionMode

func NormalizePermissionMode(mode string) PermissionMode

func PermissionModeForSessionApproval

func PermissionModeForSessionApproval(toolName string) (PermissionMode, bool)

type PermissionNotification

type PermissionNotification struct {
	ApprovalID string `json:"approval_id,omitempty"`
	ToolCallID string `json:"tool_call_id"`
	Granted    bool   `json:"granted,omitempty"`
	Denied     bool   `json:"denied,omitempty"`
}

type PermissionRequest

type PermissionRequest struct {
	ID          string          `json:"id"`
	SessionID   string          `json:"session_id"`
	ToolCallID  string          `json:"tool_call_id"`
	ToolName    string          `json:"tool_name"`
	Description string          `json:"description"`
	Action      string          `json:"action"`
	Params      json.RawMessage `json:"params,omitempty"`
	Path        string          `json:"path"`
}

type PlanItem added in v0.1.7

type PlanItem struct {
	ID        string         `json:"id"`
	SessionID string         `json:"session_id"`
	ParentID  string         `json:"parent_id,omitempty"`
	Text      string         `json:"text"`
	Status    PlanItemStatus `json:"status"`
	Position  int            `json:"position"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
}

func NextExecutablePlanItem added in v0.1.7

func NextExecutablePlanItem(plan SessionPlan) (PlanItem, bool)

type PlanItemStatus added in v0.1.7

type PlanItemStatus string
const (
	PlanItemPending PlanItemStatus = "pending"
	PlanItemActive  PlanItemStatus = "active"
	PlanItemDone    PlanItemStatus = "done"
	PlanItemSkipped PlanItemStatus = "skipped"
)

type PlanRun added in v0.1.7

type PlanRun struct {
	SessionID     string        `json:"session_id"`
	Status        PlanRunStatus `json:"status"`
	CurrentItemID string        `json:"current_item_id,omitempty"`
	LastRunID     string        `json:"last_run_id,omitempty"`
	LastError     string        `json:"last_error,omitempty"`
	StepNo        int           `json:"step_no,omitempty"`
	Attempt       int           `json:"attempt,omitempty"`
	CreatedAt     time.Time     `json:"created_at,omitempty"`
	UpdatedAt     time.Time     `json:"updated_at,omitempty"`
}

type PlanRunBindRequest added in v0.1.7

type PlanRunBindRequest struct {
	RunID string `json:"run_id"`
}

type PlanRunResponse added in v0.1.7

type PlanRunResponse struct {
	PlanRun PlanRun     `json:"plan_run"`
	Plan    SessionPlan `json:"plan"`
}

type PlanRunStartRequest added in v0.1.7

type PlanRunStartRequest struct {
	Reset bool `json:"reset,omitempty"`
}

type PlanRunStatus added in v0.1.7

type PlanRunStatus string
const (
	PlanRunIdle      PlanRunStatus = "idle"
	PlanRunRunning   PlanRunStatus = "running"
	PlanRunBlocked   PlanRunStatus = "blocked"
	PlanRunFailed    PlanRunStatus = "failed"
	PlanRunCompleted PlanRunStatus = "completed"
	PlanRunCanceled  PlanRunStatus = "canceled"
)

type PlanStore added in v0.1.7

type PlanStore interface {
	GetSessionPlan(ctx context.Context, sessionID string) (SessionPlan, error)
	SetSessionGoal(ctx context.Context, sessionID string, goal string, updatedAt time.Time) error
	ClearSessionPlan(ctx context.Context, sessionID string) error
	AddPlanItem(ctx context.Context, item PlanItem) error
	UpdatePlanItem(ctx context.Context, item PlanItem) error
	GetPlanItem(ctx context.Context, itemID string) (PlanItem, error)
	NextPlanItemPosition(ctx context.Context, sessionID string, parentID string) (int, error)
	GetPlanRun(ctx context.Context, sessionID string) (PlanRun, error)
	SavePlanRun(ctx context.Context, run PlanRun) error
	ClearPlanRun(ctx context.Context, sessionID string) error
}

type ProviderUsage

type ProviderUsage struct {
	InputTokens     int64           `json:"input_tokens,omitempty"`
	OutputTokens    int64           `json:"output_tokens,omitempty"`
	TotalTokens     int64           `json:"total_tokens,omitempty"`
	CachedTokens    int64           `json:"cached_tokens,omitempty"`
	ReasoningTokens int64           `json:"reasoning_tokens,omitempty"`
	Estimated       bool            `json:"estimated,omitempty"`
	ProviderRaw     json.RawMessage `json:"provider_raw,omitempty"`
}

type ReasoningPart

type ReasoningPart struct {
	Text             string          `json:"text"`
	Signature        string          `json:"signature,omitempty"`
	ThoughtSignature string          `json:"thought_signature,omitempty"`
	ToolID           string          `json:"tool_id,omitempty"`
	ResponsesData    json.RawMessage `json:"responses_data,omitempty"`
}

type RenameSessionInput

type RenameSessionInput struct {
	SessionID string
	Title     string
}

type RenameSessionRequest

type RenameSessionRequest struct {
	Title string `json:"title"`
}

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"`
	Status        RunStatus  `json:"status"`
	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 RunResponse

type RunResponse struct {
	Run Run `json:"run"`
}

type RunStarter added in v0.1.2

type RunStarter interface {
	StartRun(ctx context.Context, runID string) error
}

type RunStatus

type RunStatus string
const (
	RunStatusAccepted        RunStatus = "accepted"
	RunStatusRunning         RunStatus = "running"
	RunStatusWaitingApproval RunStatus = "waiting_approval"
	RunStatusCompleted       RunStatus = "completed"
	RunStatusCanceled        RunStatus = "canceled"
	RunStatusFailed          RunStatus = "failed"
)

type RunStore

type RunStore interface {
	CreateRun(ctx context.Context, run Run) error
	GetRun(ctx context.Context, runID string) (Run, error)
	GetActiveRunBySession(ctx context.Context, sessionID string) (Run, error)
	UpdateRun(ctx context.Context, run Run) error
	CompleteRun(ctx context.Context, assistantMessage Message, run Run) error

	AcceptMessage(ctx context.Context, message Message, run Run) error
}

type RunTiming

type RunTiming struct {
	TotalMillis    int64     `json:"total_ms,omitempty"`
	ModelMillis    int64     `json:"model_ms,omitempty"`
	ToolMillis     int64     `json:"tool_ms,omitempty"`
	ApprovalMillis int64     `json:"approval_ms,omitempty"`
	LastEventAt    time.Time `json:"last_event_at,omitempty"`
}

type SearchFilter added in v0.1.7

type SearchFilter struct {
	Query     string
	SessionID string
	Limit     int
}

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 SessionCapabilities added in v0.1.8

type SessionCapabilities struct {
	ProviderSelection bool `json:"provider_selection"`
	PermissionMode    bool `json:"permission_mode"`
	PlanningMode      bool `json:"planning_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         []MessagePart      `json:"parts,omitempty"`
	Client        string             `json:"client,omitempty"`
	ExternalKey   string             `json:"external_key,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)
}

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 SessionLLMContextWindowRegistry added in v0.1.10

type SessionLLMContextWindowRegistry interface {
	ContextWindowTokens(providerID string, modelID string) (int, bool)
}

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)
}

type SessionListFilter

type SessionListFilter struct {
	IncludeArchived bool
	IncludeHidden   bool
}

type SessionModelsResponse

type SessionModelsResponse struct {
	ProviderID string   `json:"provider_id"`
	ModelID    string   `json:"model_id"`
	Models     []string `json:"models"`
}

type SessionPlan added in v0.1.7

type SessionPlan struct {
	SessionID string     `json:"session_id"`
	Goal      string     `json:"goal,omitempty"`
	Items     []PlanItem `json:"items,omitempty"`
	UpdatedAt time.Time  `json:"updated_at,omitempty"`
}

type SessionPlanResponse added in v0.1.7

type SessionPlanResponse struct {
	Plan SessionPlan `json:"plan"`
}

type SessionProviderOption

type SessionProviderOption struct {
	ID           string `json:"id"`
	Label        string `json:"label"`
	Type         string `json:"type,omitempty"`
	DefaultModel string `json:"default_model,omitempty"`
	Configured   bool   `json:"configured"`
}

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 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 SkillsPromptMessage struct {
	Role    string
	Content string
}

type SpawnSubagentInput added in v0.1.13

type SpawnSubagentInput struct {
	ParentSessionID  string
	ParentRunID      string
	ParentToolCallID string
	Name             string
	Goal             string
	Context          string
	Runtime          string
	Model            string
	WorkingDir       string
	Isolation        string
}

type SpawnSubagentResult added in v0.1.13

type SpawnSubagentResult struct {
	Task     SubagentTask `json:"task"`
	Replayed bool         `json:"replayed,omitempty"`
}

type SubagentIsolation added in v0.1.13

type SubagentIsolation string
const (
	SubagentIsolationShared   SubagentIsolation = "shared"
	SubagentIsolationWorktree SubagentIsolation = "worktree"
)

type SubagentRuntime added in v0.1.12

type SubagentRuntime string
const (
	SubagentRuntimeMatrixClaw SubagentRuntime = "matrixclaw"
	SubagentRuntimeCodex      SubagentRuntime = "codex"
	SubagentRuntimeClaude     SubagentRuntime = "claude"
	SubagentRuntimeAuto       SubagentRuntime = "auto"
)

type SubagentTask added in v0.1.12

type SubagentTask struct {
	ID                        string             `json:"id"`
	AgentName                 string             `json:"agent_name,omitempty"`
	DisplayName               string             `json:"display_name,omitempty"`
	Mode                      SubagentTaskMode   `json:"mode"`
	Isolation                 SubagentIsolation  `json:"isolation"`
	ParentSessionID           string             `json:"parent_session_id"`
	ParentRunID               string             `json:"parent_run_id,omitempty"`
	ParentToolCallID          string             `json:"parent_tool_call_id,omitempty"`
	ChildSessionID            string             `json:"child_session_id,omitempty"`
	ChildRunID                string             `json:"child_run_id,omitempty"`
	Runtime                   string             `json:"runtime"`
	Goal                      string             `json:"goal"`
	Status                    SubagentTaskStatus `json:"status"`
	Summary                   string             `json:"summary,omitempty"`
	Error                     string             `json:"error,omitempty"`
	ResultMessageID           string             `json:"result_message_id,omitempty"`
	CompletionQueuedAt        *time.Time         `json:"completion_queued_at,omitempty"`
	CompletionDeliveredAt     *time.Time         `json:"completion_delivered_at,omitempty"`
	CompletionAutoResumeRunID string             `json:"completion_auto_resume_run_id,omitempty"`
	CreatedAt                 time.Time          `json:"created_at"`
	UpdatedAt                 time.Time          `json:"updated_at"`
	FinishedAt                *time.Time         `json:"finished_at,omitempty"`
}

type SubagentTaskFilter added in v0.1.13

type SubagentTaskFilter struct {
	ParentSessionID string
	Mode            SubagentTaskMode
	Statuses        []SubagentTaskStatus
	Limit           int
}

type SubagentTaskMode added in v0.1.13

type SubagentTaskMode string
const (
	SubagentTaskModeBlocking SubagentTaskMode = "blocking"
	SubagentTaskModeAsync    SubagentTaskMode = "async"
)

type SubagentTaskStatus added in v0.1.12

type SubagentTaskStatus string
const (
	SubagentTaskStatusPending         SubagentTaskStatus = "pending"
	SubagentTaskStatusRunning         SubagentTaskStatus = "running"
	SubagentTaskStatusWaitingApproval SubagentTaskStatus = "waiting_approval"
	SubagentTaskStatusCompleted       SubagentTaskStatus = "completed"
	SubagentTaskStatusFailed          SubagentTaskStatus = "failed"
	SubagentTaskStatusCanceled        SubagentTaskStatus = "canceled"
)

type SubagentTaskStore added in v0.1.12

type SubagentTaskStore interface {
	CreateSubagentTask(ctx context.Context, task SubagentTask) error
	UpdateSubagentTask(ctx context.Context, task SubagentTask) error
	GetSubagentTask(ctx context.Context, taskID string) (SubagentTask, error)
	GetSubagentTaskByParentToolCall(ctx context.Context, parentSessionID string, parentRunID string, parentToolCallID string) (SubagentTask, error)
	GetSubagentTaskByChildRun(ctx context.Context, childRunID string) (SubagentTask, error)
	ListSubagentTasks(ctx context.Context, filter SubagentTaskFilter) ([]SubagentTask, error)
	ListActiveSubagentTasksByParent(ctx context.Context, parentSessionID string) ([]SubagentTask, error)
	ListPendingSubagentCompletionTasks(ctx context.Context, limit int) ([]SubagentTask, error)
}

type TextPart

type TextPart struct {
	Text string `json:"text"`
}

type ToolCallPart

type ToolCallPart struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Input    string `json:"input"`
	Finished bool   `json:"finished,omitempty"`
}

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)
}

type ToolLifecycleState

type ToolLifecycleState string
const (
	ToolLifecycleRequested       ToolLifecycleState = "requested"
	ToolLifecycleWaitingApproval ToolLifecycleState = "waiting_approval"
	ToolLifecycleCompleted       ToolLifecycleState = "completed"
	ToolLifecycleFailed          ToolLifecycleState = "failed"
)

type ToolResultPart

type ToolResultPart struct {
	ToolCallID string          `json:"tool_call_id"`
	Name       string          `json:"name"`
	Content    string          `json:"content"`
	MIMEType   string          `json:"mime_type,omitempty"`
	Metadata   json.RawMessage `json:"metadata,omitempty"`
	Status     string          `json:"status,omitempty"`
	IsError    bool            `json:"is_error,omitempty"`
}

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 ToolsResponse struct {
	Tools []tools.Spec `json:"tools"`
}

type UpdateExternalAgentRequest added in v0.1.6

type UpdateExternalAgentRequest struct {
	Enabled *bool  `json:"enabled,omitempty"`
	Path    string `json:"path,omitempty"`
}

type UpdatePlanItemRequest added in v0.1.7

type UpdatePlanItemRequest struct {
	ItemID string `json:"item_id"`
	Status string `json:"status,omitempty"`
	Text   string `json:"text,omitempty"`
}

type UpdateSessionLLMRequest

type UpdateSessionLLMRequest struct {
	ProviderID string `json:"provider_id"`
	ModelID    string `json:"model_id"`
}

type UpdateSessionPermissionModeInput

type UpdateSessionPermissionModeInput struct {
	SessionID      string
	PermissionMode PermissionMode
}

type UpdateSessionPermissionModeRequest

type UpdateSessionPermissionModeRequest struct {
	PermissionMode string `json:"permission_mode"`
}

type UpdateSessionPlanRequest added in v0.1.7

type UpdateSessionPlanRequest struct {
	Goal  *string `json:"goal,omitempty"`
	Clear bool    `json:"clear,omitempty"`
}

type UsageFilter added in v0.1.7

type UsageFilter struct {
	SessionID string
	RunID     string
	Limit     int
}

type UsageRecord added in v0.1.7

type UsageRecord struct {
	ID              string    `json:"id"`
	SessionID       string    `json:"session_id"`
	RunID           string    `json:"run_id"`
	MessageID       string    `json:"message_id,omitempty"`
	Provider        string    `json:"provider,omitempty"`
	Model           string    `json:"model,omitempty"`
	InputTokens     int64     `json:"input_tokens,omitempty"`
	OutputTokens    int64     `json:"output_tokens,omitempty"`
	TotalTokens     int64     `json:"total_tokens,omitempty"`
	CachedTokens    int64     `json:"cached_tokens,omitempty"`
	ReasoningTokens int64     `json:"reasoning_tokens,omitempty"`
	Estimated       bool      `json:"estimated,omitempty"`
	ProviderRaw     string    `json:"provider_raw,omitempty"`
	CreatedAt       time.Time `json:"created_at"`
}

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 UsageStore interface {
	SaveUsageRecord(ctx context.Context, record UsageRecord) error
	ListUsageRecords(ctx context.Context, filter UsageFilter) ([]UsageRecord, error)
}

type UsageSummary added in v0.1.7

type UsageSummary struct {
	SessionID       string `json:"session_id,omitempty"`
	Runs            int    `json:"runs"`
	InputTokens     int64  `json:"input_tokens,omitempty"`
	OutputTokens    int64  `json:"output_tokens,omitempty"`
	TotalTokens     int64  `json:"total_tokens,omitempty"`
	CachedTokens    int64  `json:"cached_tokens,omitempty"`
	ReasoningTokens int64  `json:"reasoning_tokens,omitempty"`
}

type UseBindingInput

type UseBindingInput struct {
	Client      string `json:"client"`
	ExternalKey string `json:"external_key"`
	SessionID   string `json:"session_id"`
}

Jump to

Keyboard shortcuts

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