Documentation
¶
Index ¶
- Constants
- Variables
- func AssistantSystemPrompt(profile AssistantProfile) string
- func EstimateMessageTokens(messages []Message) int
- func EstimateProviderRequestTokens(request providers.Request) int
- func EstimateTextTokens(text string) int
- func FormatShortNumber(value int) string
- func IsPlanRunPromptMessage(message Message) bool
- func PlanItemDepths(items []PlanItem) map[string]int
- func PlanToolExecutors(app *Core) []tools.Executor
- type AcceptRunErrorResponse
- type AcceptRunResult
- type AddPlanItemRequest
- type AdminRestartRequest
- type Approval
- type ApprovalResolveRequest
- type ApprovalResponse
- type ApprovalState
- type ApprovalStore
- type ApprovalsResponse
- type AssistantProfile
- type AttachmentData
- type AttachmentReader
- type BindingStore
- type ClientBinding
- type ClientBindingResponse
- type ClientDeliveriesResponse
- type ClientDelivery
- type ClientDeliveryFilter
- type ClientDeliveryStatus
- type ClientDeliveryTarget
- type ClientSnapshot
- type ClientSnapshotResponse
- type CompactSessionResult
- type ContextBlock
- type ContextBlockKind
- type ContextCompact
- type ContextReport
- 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) AddPlanItem(ctx context.Context, sessionID string, text string, parentID string) (SessionPlan, error)
- func (c *Core) BindSessionPlanRunStep(ctx context.Context, sessionID string, runID string) error
- func (c *Core) CancelRun(ctx context.Context, runID string) (Run, error)
- func (c *Core) ClearSessionPlan(ctx context.Context, sessionID string) (SessionPlan, error)
- func (c *Core) ClientSnapshot(ctx context.Context, client string, externalKey string) (ClientSnapshot, error)
- func (c *Core) CompactSession(ctx context.Context, sessionID string) (CompactSessionResult, error)
- func (c *Core) CompleteSessionPlanRunStep(ctx context.Context, run Run, assistantContent string) 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) (Message, error)
- func (c *Core) CurrentBinding(ctx context.Context, client string, externalKey string) (ClientBinding, error)
- func (c *Core) DeleteSession(ctx context.Context, sessionID string) error
- func (c *Core) ExecuteRun(ctx context.Context, runID string) error
- func (c *Core) ExecuteTool(ctx context.Context, input ExecuteToolInput) (ExecuteToolResult, error)
- func (c *Core) ExternalAgents(ctx context.Context) []ExternalAgentDescriptor
- func (c *Core) GetRun(ctx context.Context, runID string) (Run, error)
- func (c *Core) 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) ([]Message, error)
- func (c *Core) ListSessions(ctx context.Context, filter SessionListFilter) ([]Session, error)
- func (c *Core) ListToolSpecs() []tools.Spec
- func (c *Core) MarkClientDeliveryFailed(ctx context.Context, delivery ClientDelivery, deliveryErr error) error
- func (c *Core) MarkClientDeliveryReady(ctx context.Context, delivery ClientDelivery) error
- func (c *Core) MarkClientDeliverySent(ctx context.Context, delivery ClientDelivery) error
- func (c *Core) ModelsForSession(ctx context.Context, sessionID string) (string, string, []string, error)
- func (c *Core) RenameSession(ctx context.Context, input RenameSessionInput) (Session, error)
- func (c *Core) ResolveApproval(ctx context.Context, approvalID string, approved bool) (Approval, error)
- func (c *Core) ResolveExternalAgentID(id string) (string, bool)
- func (c *Core) Search(ctx context.Context, filter SearchFilter) (SearchReport, error)
- func (c *Core) SessionContext(ctx context.Context, sessionID string) (ContextReport, error)
- func (c *Core) SessionPlan(ctx context.Context, sessionID string) (SessionPlan, error)
- func (c *Core) SessionPlanRun(ctx context.Context, sessionID string) (PlanRun, error)
- func (c *Core) SessionProviderOptions() []SessionProviderOption
- func (c *Core) SetAssistantProfile(profile AssistantProfile)
- func (c *Core) SetSessionGoal(ctx context.Context, sessionID string, goal string) (SessionPlan, error)
- func (c *Core) SetSessionLLMs(registry SessionLLMRegistry)
- func (c *Core) StartSessionPlanRun(ctx context.Context, sessionID string, reset bool) (PlanRun, SessionPlan, error)
- func (c *Core) SubscribeEvents(ctx context.Context, sessionID string) <-chan Event
- func (c *Core) SubscribeEventsAfter(ctx context.Context, sessionID string, afterID uint64) <-chan Event
- func (c *Core) UpdatePlanItem(ctx context.Context, sessionID string, itemID string, status PlanItemStatus, ...) (SessionPlan, error)
- func (c *Core) UpdateSessionModel(ctx context.Context, sessionID string, modelID string) (Session, error)
- func (c *Core) UpdateSessionPermissionMode(ctx context.Context, input UpdateSessionPermissionModeInput) (Session, error)
- func (c *Core) UpdateSessionProvider(ctx context.Context, sessionID string, providerID string) (Session, error)
- func (c *Core) Usage(ctx context.Context, filter UsageFilter) (UsageReport, error)
- func (c *Core) UseBinding(ctx context.Context, input UseBindingInput) (ClientBinding, error)
- func (c *Core) WithAttachmentReader(reader AttachmentReader) *Core
- func (c *Core) WithClock(now func() time.Time) *Core
- func (c *Core) WithExternalAgents(registry *externalagents.Registry, store externalagents.AttachmentStore) *Core
- func (c *Core) WithHistoryLimit(limit int) *Core
- func (c *Core) WithIDGenerator(newID func(prefix string) string) *Core
- func (c *Core) WithRunStarter(starter RunStarter) *Core
- func (c *Core) WithSessionLLMs(registry SessionLLMRegistry) *Core
- func (c *Core) WithTools(toolExecutor ToolExecutor) *Core
- type CreateSessionInput
- type CreateSessionRequest
- type CreateSystemMessageRequest
- type DeliveryStore
- type ErrorResponse
- type Event
- type EventType
- type ExecuteToolInput
- type ExecuteToolResult
- type ExternalAgentDescriptor
- type ExternalAgentsResponse
- type FileSnapshot
- type FileSnapshotStore
- type FinishPart
- type HandleMessageInput
- type HandleTriggeredRunInput
- type HealthResponse
- type ImagePart
- type Message
- type MessagePart
- type MessagePartKind
- type MessageResponse
- type MessageRole
- type MessageStore
- type MessagesResponse
- type OKResponse
- type PermissionMode
- type PermissionNotification
- type PermissionRequest
- type PlanItem
- type PlanItemStatus
- type PlanRun
- type PlanRunBindRequest
- type PlanRunResponse
- type PlanRunStartRequest
- type PlanRunStatus
- type PlanStore
- type ProviderUsage
- type ReasoningPart
- type RenameSessionInput
- type RenameSessionRequest
- type Run
- type RunResponse
- type RunStarter
- type RunStatus
- type RunStore
- type RunTiming
- type SearchFilter
- type SearchReport
- type SearchResponse
- type SearchResult
- type SearchStore
- type ServerStatus
- type ServerStatusResponse
- type Session
- type SessionCapabilities
- type SessionCompactResponse
- type SessionContextResponse
- type SessionKind
- type SessionLLMContextWindowRegistry
- type SessionLLMRegistry
- type SessionListFilter
- type SessionModelsResponse
- type SessionPlan
- type SessionPlanResponse
- type SessionProviderOption
- type SessionProvidersResponse
- type SessionResponse
- type SessionRuntime
- type SessionStatus
- type SessionStore
- type SessionsResponse
- type Store
- type TextPart
- type ToolCallPart
- type ToolExecuteResponse
- type ToolExecutor
- type ToolLifecycleState
- type ToolResultPart
- type ToolUpdate
- type ToolsResponse
- type UpdateExternalAgentRequest
- type UpdatePlanItemRequest
- type UpdateSessionLLMRequest
- type UpdateSessionPermissionModeInput
- type UpdateSessionPermissionModeRequest
- type UpdateSessionPlanRequest
- type UsageFilter
- type UsageRecord
- type UsageReport
- type UsageResponse
- type UsageStore
- type UsageSummary
- type UseBindingInput
Constants ¶
const ( ClientDeliveryTypeDaemonRestart = "daemon_restart" ClientDeliveryTypeAutomationRun = "automation_run" )
const EstimatedImageTokens = 1_500
Variables ¶
var ( ErrNotFound = errors.New("not found") ErrBindingNotFound = errors.New("binding not found") ErrSessionSelectionRequired = errors.New("session selection required") ErrInvalidInput = errors.New("invalid input") )
var ErrSessionRequired = errors.New("session_id is required")
Functions ¶
func AssistantSystemPrompt ¶
func AssistantSystemPrompt(profile AssistantProfile) string
func EstimateMessageTokens ¶
func EstimateProviderRequestTokens ¶ added in v0.1.10
func EstimateTextTokens ¶
func FormatShortNumber ¶
func IsPlanRunPromptMessage ¶ added in v0.1.7
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 PlanItemDepths ¶ added in v0.1.7
func PlanToolExecutors ¶ added in v0.1.7
PlanToolExecutors exposes session plan operations to models through the normal tool registry.
Types ¶
type AcceptRunErrorResponse ¶
type AcceptRunResult ¶
type AddPlanItemRequest ¶ added in v0.1.7
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 AttachmentData ¶
type AttachmentReader ¶
type BindingStore ¶
type BindingStore interface {
SaveBinding(ctx context.Context, binding ClientBinding) error
GetBinding(ctx context.Context, client string, externalKey string) (ClientBinding, error)
}
type ClientBinding ¶
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 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"`
}
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 ContextBlockKind ¶
type ContextBlockKind string
const ( ContextBlockSystemPrompt ContextBlockKind = "system_prompt" ContextBlockCustomInstructions ContextBlockKind = "custom_instructions" ContextBlockCompactSummary ContextBlockKind = "compact_summary" 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 *ProviderUsage `json:"last_provider_usage,omitempty"`
Compact ContextCompact `json:"compact"`
}
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) AddPlanItem ¶ added in v0.1.7
func (*Core) BindSessionPlanRunStep ¶ added in v0.1.7
func (*Core) ClearSessionPlan ¶ added in v0.1.7
func (*Core) ClientSnapshot ¶
func (*Core) CompactSession ¶
func (*Core) CompleteSessionPlanRunStep ¶ added in v0.1.7
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) DeleteSession ¶
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) ListApprovals ¶
func (*Core) ListClientDeliveries ¶
func (c *Core) ListClientDeliveries(ctx context.Context, filter ClientDeliveryFilter) ([]ClientDelivery, error)
func (*Core) ListMessages ¶
func (*Core) ListSessions ¶
func (*Core) ListToolSpecs ¶
func (*Core) MarkClientDeliveryFailed ¶
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) ModelsForSession ¶
func (*Core) RenameSession ¶
func (*Core) ResolveApproval ¶
func (*Core) ResolveExternalAgentID ¶ added in v0.1.9
func (*Core) Search ¶ added in v0.1.7
func (c *Core) Search(ctx context.Context, filter SearchFilter) (SearchReport, error)
func (*Core) SessionContext ¶
func (*Core) SessionPlan ¶ added in v0.1.7
func (*Core) SessionPlanRun ¶ added in v0.1.7
func (*Core) SessionProviderOptions ¶
func (c *Core) SessionProviderOptions() []SessionProviderOption
func (*Core) SetAssistantProfile ¶
func (c *Core) SetAssistantProfile(profile AssistantProfile)
func (*Core) SetSessionGoal ¶ added in v0.1.7
func (*Core) SetSessionLLMs ¶
func (c *Core) SetSessionLLMs(registry SessionLLMRegistry)
func (*Core) StartSessionPlanRun ¶ added in v0.1.7
func (*Core) SubscribeEvents ¶
func (*Core) SubscribeEventsAfter ¶
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 (*Core) UpdateSessionPermissionMode ¶
func (*Core) UpdateSessionProvider ¶
func (*Core) Usage ¶ added in v0.1.7
func (c *Core) Usage(ctx context.Context, filter UsageFilter) (UsageReport, error)
func (*Core) UseBinding ¶
func (c *Core) UseBinding(ctx context.Context, input UseBindingInput) (ClientBinding, error)
func (*Core) WithAttachmentReader ¶
func (c *Core) WithAttachmentReader(reader AttachmentReader) *Core
func (*Core) WithExternalAgents ¶ added in v0.1.4
func (c *Core) WithExternalAgents(registry *externalagents.Registry, store externalagents.AttachmentStore) *Core
func (*Core) WithHistoryLimit ¶
func (*Core) WithIDGenerator ¶
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) WithTools ¶
func (c *Core) WithTools(toolExecutor ToolExecutor) *Core
type CreateSessionInput ¶
type CreateSessionInput struct {
Title string
Kind SessionKind
RuntimeID SessionRuntime
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 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" )
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 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 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"`
WorkingDir string `json:"working_dir"`
AllowAutoBindOne bool `json:"allow_auto_bind_one"`
}
type HandleTriggeredRunInput ¶
type HealthResponse ¶
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 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 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 RenameSessionInput ¶
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 RunStore ¶
type RunStore interface {
CreateRun(ctx context.Context, run Run) error
GetRun(ctx context.Context, runID 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 SearchFilter ¶ added in v0.1.7
type SearchReport ¶ added in v0.1.7
type SearchReport struct {
Query string `json:"query"`
Results []SearchResult `json:"results"`
}
type SearchResponse ¶ added in v0.1.7
type SearchResponse struct {
Search SearchReport `json:"search"`
}
type SearchResult ¶ added in v0.1.7
type SearchResult struct {
MessageID string `json:"message_id"`
SessionID string `json:"session_id"`
Role string `json:"role,omitempty"`
Snippet string `json:"snippet,omitempty"`
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
Rank float64 `json:"rank,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
}
type SearchStore ¶ added in v0.1.7
type SearchStore interface {
SearchMessages(ctx context.Context, filter SearchFilter) ([]SearchResult, error)
}
type ServerStatus ¶
type ServerStatus struct {
StartedAt time.Time `json:"started_at"`
UptimeSeconds int64 `json:"uptime_seconds"`
GoAllocBytes uint64 `json:"go_alloc_bytes"`
GoSysBytes uint64 `json:"go_sys_bytes"`
ProcessRSSBytes uint64 `json:"process_rss_bytes"`
MemoryTotalBytes uint64 `json:"memory_total_bytes"`
MemoryAvailableBytes uint64 `json:"memory_available_bytes"`
MemoryUsedBytes uint64 `json:"memory_used_bytes"`
CPUUsedPercent float64 `json:"cpu_used_percent"`
CPUKnown bool `json:"cpu_known"`
}
type ServerStatusResponse ¶
type ServerStatusResponse struct {
Status ServerStatus `json:"status"`
}
type Session ¶
type Session struct {
ID string `json:"id"`
Title string `json:"title"`
Kind SessionKind `json:"kind"`
RuntimeID SessionRuntime `json:"runtime_id,omitempty"`
WorkingDir string `json:"working_dir,omitempty"`
ProviderID string `json:"provider_id,omitempty"`
ModelID string `json:"model_id,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 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 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
}
type SessionModelsResponse ¶
type SessionPlan ¶ added in v0.1.7
type SessionPlanResponse ¶ added in v0.1.7
type SessionPlanResponse struct {
Plan SessionPlan `json:"plan"`
}
type SessionProviderOption ¶
type SessionProvidersResponse ¶
type SessionProvidersResponse struct {
Providers []SessionProviderOption `json:"providers"`
}
type SessionResponse ¶
type SessionResponse struct {
Session Session `json:"session"`
}
type SessionRuntime ¶ added in v0.1.4
type SessionRuntime string
const ( SessionRuntimeMatrixClaw SessionRuntime = "matrixclaw" SessionRuntimeExternalAgent SessionRuntime = "external_agent" )
func NormalizeSessionRuntime ¶ added in v0.1.4
func NormalizeSessionRuntime(runtimeID SessionRuntime) SessionRuntime
type 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 Store ¶
type Store interface {
SessionStore
BindingStore
DeliveryStore
MessageStore
RunStore
UsageStore
PlanStore
SearchStore
ApprovalStore
FileSnapshotStore
}
type ToolCallPart ¶
type ToolExecuteResponse ¶
type ToolExecuteResponse struct {
Result ExecuteToolResult `json:"result"`
}
type ToolExecutor ¶
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 UpdateExternalAgentRequest ¶ added in v0.1.6
type UpdatePlanItemRequest ¶ added in v0.1.7
type UpdateSessionLLMRequest ¶
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 UsageFilter ¶ added in v0.1.7
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 ¶
Source Files
¶
- assistant_sanitize.go
- bindings.go
- context.go
- context_errors.go
- contracts.go
- core.go
- deliveries.go
- errors.go
- events.go
- execution.go
- execution_provider.go
- execution_status.go
- execution_turn.go
- external_agent_execution.go
- external_agents.go
- messages.go
- permissions.go
- plan.go
- plan_tools.go
- ports.go
- run_cancel.go
- run_timing.go
- runs.go
- search.go
- sessions.go
- snapshot.go
- system_messages.go
- tool_approvals.go
- tool_call_approval.go
- tool_call_finish.go
- tool_call_prepare.go
- tool_call_run.go
- tool_helpers.go
- tool_permissions.go
- tool_specs.go
- tools.go
- types.go
- usage.go