core

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 18 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"
)

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 EstimateMessageTokens

func EstimateMessageTokens(messages []Message) int

func EstimateTextTokens

func EstimateTextTokens(text string) int

func FormatShortNumber

func FormatShortNumber(value int) string

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"`
	UserMessage Message `json:"user_message"`
	Run         Run     `json:"run"`
}

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 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"`
	Context               *ContextReport           `json:"context,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 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"
	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) CancelRun

func (c *Core) CancelRun(ctx context.Context, runID string) (Run, 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) CreateClientDelivery

func (c *Core) CreateClientDelivery(ctx context.Context, delivery ClientDelivery) (ClientDelivery, 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) 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) 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) 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) ModelsForSession

func (c *Core) ModelsForSession(ctx context.Context, sessionID string) (string, string, []string, 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) SessionContext

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

func (*Core) SessionProviderOptions

func (c *Core) SessionProviderOptions() []SessionProviderOption

func (*Core) SetAssistantProfile

func (c *Core) SetAssistantProfile(profile AssistantProfile)

func (*Core) SetSessionLLMs

func (c *Core) SetSessionLLMs(registry SessionLLMRegistry)

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

func (c *Core) UseBinding(ctx context.Context, input UseBindingInput) (ClientBinding, error)

func (*Core) WithAttachmentReader

func (c *Core) WithAttachmentReader(reader AttachmentReader) *Core

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) 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"
	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 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"`
	Detail      string   `json:"detail,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"`
	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 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 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)
	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 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 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 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 SessionModelsResponse struct {
	ProviderID string   `json:"provider_id"`
	ModelID    string   `json:"model_id"`
	Models     []string `json:"models"`
}

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