Documentation
¶
Index ¶
- Constants
- Variables
- type Agent
- type AgentRun
- type AgentRunUpdate
- type ChatMsg
- type ChatSession
- type Conversation
- type ConversationContinuation
- type ConversationEvent
- type ConversationWake
- type ConversationWakePolicy
- type LogEntry
- type RunInventoryItem
- type RunInventoryPage
- type RunInventoryPosition
- type RunInventoryQuery
- type RunInventoryScope
- type Store
- func (s *Store) AdmitAgentRun(run *AgentRun, task *Task) (*AgentRun, bool, error)
- func (s *Store) AppendChatMessage(sessionID, role, content string) error
- func (s *Store) AppendLog(taskID, event string, detail *string) error
- func (s *Store) AppendThread(e *ThreadEntry) error
- func (s *Store) AppendThreadAt(e *ThreadEntry, ts time.Time) error
- func (s *Store) BindConversationWake(w *ConversationWake, session, provider, input string, now int64) error
- func (s *Store) CheckpointConversation(owner, id string, expected, after int64, checkpoint string) error
- func (s *Store) ClearTaskCron(id string) error
- func (s *Store) Close() error
- func (s *Store) ConversationEvents(owner, root string, after int64, limit int) ([]ConversationEvent, error)
- func (s *Store) ConversationExecutions(id string) ([]string, error)
- func (s *Store) ConversationForSession(session string) (*Conversation, error)
- func (s *Store) ConversationImportCursor(session string) (int64, error)
- func (s *Store) ConversationWakePolicy(root string) (ConversationWakePolicy, error)
- func (s *Store) ConversationWakeRoots(after string, limit int) ([]*Conversation, error)
- func (s *Store) CountConversationLaunchesSince(owner string, since time.Time) (int, error)
- func (s *Store) CreateChatSession(id, agent string) error
- func (s *Store) CreateTask(t *Task) error
- func (s *Store) DB() *sql.DB
- func (s *Store) DeleteChatSession(id string) error
- func (s *Store) DeleteThreadOlderThan(ts time.Time) (int64, error)
- func (s *Store) GetAgent(name string) (*Agent, error)
- func (s *Store) GetAgentRun(id string) (*AgentRun, error)
- func (s *Store) GetChatSession(id string) (*ChatSession, error)
- func (s *Store) GetConversation(owner, id string) (*Conversation, error)
- func (s *Store) GetConversationContinuation(owner, request string) (*ConversationContinuation, error)
- func (s *Store) GetTask(id string) (*Task, error)
- func (s *Store) ImportConversationStates(c *Conversation, events []ConversationEvent, cursor int64) error
- func (s *Store) IncrementRetryCount(taskID string) error
- func (s *Store) ListAgentRuns() ([]*AgentRun, error)
- func (s *Store) ListAgents() ([]*Agent, error)
- func (s *Store) ListChatMessages(sessionID string) ([]*ChatMsg, error)
- func (s *Store) ListChatSessions() ([]*ChatSession, error)
- func (s *Store) ListConversations(owner, root string) ([]*Conversation, error)
- func (s *Store) ListLogByTask(taskID string) ([]*LogEntry, error)
- func (s *Store) ListPending(now time.Time) ([]*Task, error)
- func (s *Store) ListReady(now time.Time) ([]*Task, error)
- func (s *Store) ListRecent(n int) ([]*Task, error)
- func (s *Store) ListRecentThread(n int) ([]*ThreadEntry, error)
- func (s *Store) ListRecurring() ([]*Task, error)
- func (s *Store) ListRunInventory(ctx context.Context, q RunInventoryQuery) (RunInventoryPage, error)
- func (s *Store) ListThreadByDate(date time.Time) ([]*ThreadEntry, error)
- func (s *Store) PendingConversationWake(root string) (*ConversationWake, error)
- func (s *Store) QueueConversationWake(root string) (*ConversationWake, error)
- func (s *Store) RecordConversationState(c *Conversation, cursor int64, state, source string) error
- func (s *Store) RecordConversationWake(w *ConversationWake, status, reason string, receipt, now int64) error
- func (s *Store) ReserveConversation(c Conversation) (*Conversation, bool, error)
- func (s *Store) ReserveConversationContinuation(c ConversationContinuation) (*ConversationContinuation, bool, error)
- func (s *Store) ResumeConversationExecution(source, target string) error
- func (s *Store) RetryNotSentConversationWake(owner, root string, now int64) error
- func (s *Store) SaveAgentRun(r *AgentRun, task *Task, event, detail string) error
- func (s *Store) SaveAgentRuns(updates []AgentRunUpdate) error
- func (s *Store) SetConversationContinuationLaunch(c *ConversationContinuation, state, detail string) error
- func (s *Store) SetConversationLaunch(id, state, detail string) error
- func (s *Store) SetConversationWake(owner, root string, enabled bool) error
- func (s *Store) SetTaskError(id, errMsg string) error
- func (s *Store) SetTaskOutput(id, output string) error
- func (s *Store) SetTaskResolved(id, agent, isolation string) error
- func (s *Store) SetTaskWhat(id, what string) error
- func (s *Store) SumTokensByDateRange(start, end time.Time) (int, error)
- func (s *Store) ThreadEntryExists(taskID *string, wingID string, timestamp time.Time) (bool, error)
- func (s *Store) ThreadEntryExistsBySummary(wingID string, timestamp time.Time, summary string) (bool, error)
- func (s *Store) UpdateAgentHealth(name string, healthy bool, checkedAt time.Time) error
- func (s *Store) UpdateTaskStatus(id, status string) error
- func (s *Store) UpsertAgent(a *Agent) error
- type Task
- type ThreadEntry
Constants ¶
const MaxConversationWakeAttempts = 12
Variables ¶
var ErrRunInventoryCursor = fmt.Errorf("run inventory cursor is invalid or expired; restart discovery: %w", fs.ErrInvalid)
Functions ¶
This section is empty.
Types ¶
type AgentRun ¶ added in v0.149.0
type AgentRun struct {
ID, SessionID, Principal, RequestKey, SpecHash string
Record json.RawMessage
Revision int64
}
AgentRun is the durable wing composition record. Record includes immutable launch provenance and the complete semantic outcome; tasks is its historical projection for existing conversation and CLI readers.
type AgentRunUpdate ¶ added in v0.149.0
SaveAgentRun atomically publishes full output, terminal metadata and a content-free event. Revision comparison prevents a stale observer replacing a stop intent or a terminal outcome after reconnect.
type ChatSession ¶
type Conversation ¶ added in v0.148.0
type Conversation struct {
ID string `json:"conversation_id"`
OwnerID string `json:"-"`
RootID string `json:"root_conversation_id"`
ParentID string `json:"parent_conversation_id,omitempty"`
Title string `json:"title"`
Agent string `json:"agent"`
CWD string `json:"cwd"`
WingID string `json:"wing_id"`
SessionID string `json:"session_id"`
LaunchKey string `json:"-"`
SpecDigest string `json:"-"`
LaunchState string `json:"launch_state"`
LaunchError string `json:"launch_error,omitempty"`
Checkpoint string `json:"checkpoint,omitempty"`
DeliveredCursor int64 `json:"delivered_cursor"`
Revision int64 `json:"revision"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Conversation is the durable personal task identity. SessionID identifies its latest execution; the execution table keeps earlier instances inspectable.
type ConversationContinuation ¶ added in v0.148.0
type ConversationEvent ¶ added in v0.148.0
type ConversationEvent struct {
Sequence int64 `json:"sequence"`
RootID string `json:"root_conversation_id"`
ConversationID string `json:"conversation_id"`
SessionID string `json:"session_id"`
SourceCursor int64 `json:"session_cursor"`
State string `json:"state"`
StateSource string `json:"state_source"`
Type string `json:"type"`
CreatedAt time.Time `json:"created_at"`
}
type ConversationWake ¶ added in v0.148.0
type ConversationWake struct {
RootID string `json:"root_conversation_id"`
EventSequence int64 `json:"event_cursor"`
Attempt int `json:"attempt"`
AttemptLimit int `json:"attempt_limit"`
RequestID string `json:"request_id,omitempty"`
SessionID string `json:"session_id,omitempty"`
ProviderSessionID string `json:"provider_session_id,omitempty"`
Input string `json:"-"`
Status string `json:"status"`
ReceiptCursor int64 `json:"receipt_cursor,omitempty"`
RetryAfter int64 `json:"retry_after,omitempty"`
Reason string `json:"reason,omitempty"`
Event ConversationEvent `json:"event"`
}
type ConversationWakePolicy ¶ added in v0.148.0
type RunInventoryItem ¶ added in v0.149.4
type RunInventoryItem struct {
ID string `json:"run_id"`
SessionID string `json:"session_id"`
Agent string `json:"agent"`
Model string `json:"model"`
Label string `json:"label,omitempty"`
CWD string `json:"cwd"`
Isolation string `json:"isolation"`
Status string `json:"status"`
Phase string `json:"phase"`
ParentID string `json:"parent_id,omitempty"`
RequestKey string `json:"idempotency_key,omitempty"`
CreatedAt string `json:"created_at"`
StartedAt string `json:"started_at,omitempty"`
FinishedAt string `json:"finished_at,omitempty"`
TimeoutSeconds int `json:"timeout_seconds"`
FailureKind string `json:"failure_kind,omitempty"`
Terminal bool `json:"terminal"`
Legacy bool `json:"legacy"`
Cleanup string `json:"cleanup"`
OutputAvailability string `json:"output_availability"`
}
type RunInventoryPage ¶ added in v0.149.4
type RunInventoryPage struct {
Runs []RunInventoryItem
Position RunInventoryPosition
More bool
}
type RunInventoryPosition ¶ added in v0.149.4
type RunInventoryQuery ¶ added in v0.149.4
type RunInventoryQuery struct {
Scope RunInventoryScope
Limit int
RequestKey string
TerminalSince time.Time
Position RunInventoryPosition
Continuing bool
}
type RunInventoryScope ¶ added in v0.149.4
type RunInventoryScope struct {
Principal, UserID string
LegacyLocalDefault, EnforcePaths bool
AllowedPaths []string
}
RunInventoryScope is supplied by the authenticated wing service, never tool arguments. Legacy tasks have no user identity, matching the known-ID path.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) AdmitAgentRun ¶ added in v0.149.0
AdmitAgentRun reserves both identifiers and the optional retry key in the same transaction as the legacy task projection, before any egg can launch.
func (*Store) AppendChatMessage ¶
func (*Store) AppendThread ¶
func (s *Store) AppendThread(e *ThreadEntry) error
func (*Store) AppendThreadAt ¶
func (s *Store) AppendThreadAt(e *ThreadEntry, ts time.Time) error
func (*Store) BindConversationWake ¶ added in v0.148.0
func (s *Store) BindConversationWake(w *ConversationWake, session, provider, input string, now int64) error
Only queued or explicitly proven-not-sent attempts may acquire a new ID or destination. Unknown delivery keeps its immutable request and provider binding.
func (*Store) CheckpointConversation ¶ added in v0.148.0
func (s *Store) CheckpointConversation(owner, id string, expected, after int64, checkpoint string) error
CheckpointConversation is compare-and-swap. A stale controller cannot overwrite newer intent or move a delivery cursor backwards or past evidence.
func (*Store) ClearTaskCron ¶
func (*Store) ConversationEvents ¶ added in v0.148.0
func (*Store) ConversationExecutions ¶ added in v0.148.0
func (*Store) ConversationForSession ¶ added in v0.148.0
func (s *Store) ConversationForSession(session string) (*Conversation, error)
func (*Store) ConversationImportCursor ¶ added in v0.148.0
func (*Store) ConversationWakePolicy ¶ added in v0.148.0
func (s *Store) ConversationWakePolicy(root string) (ConversationWakePolicy, error)
func (*Store) ConversationWakeRoots ¶ added in v0.148.0
func (s *Store) ConversationWakeRoots(after string, limit int) ([]*Conversation, error)
func (*Store) CountConversationLaunchesSince ¶ added in v0.148.0
CountConversationLaunchesSince counts an owner's linked launches reserved at or after since, excluding launches recorded as definitely failed. It gives host mailbox admission a spawn-rate bound that survives process restarts and is shared by every process using this state directory.
func (*Store) CreateChatSession ¶
func (*Store) CreateTask ¶
func (*Store) DeleteChatSession ¶
func (*Store) DeleteThreadOlderThan ¶
func (*Store) GetAgentRun ¶ added in v0.149.0
func (*Store) GetChatSession ¶
func (s *Store) GetChatSession(id string) (*ChatSession, error)
func (*Store) GetConversation ¶ added in v0.148.0
func (s *Store) GetConversation(owner, id string) (*Conversation, error)
func (*Store) GetConversationContinuation ¶ added in v0.148.0
func (s *Store) GetConversationContinuation(owner, request string) (*ConversationContinuation, error)
func (*Store) ImportConversationStates ¶ added in v0.148.0
func (s *Store) ImportConversationStates(c *Conversation, events []ConversationEvent, cursor int64) error
ImportConversationStates commits event deliveries and the session read cursor together, so reconnect replay never drops an attention or completion event.
func (*Store) IncrementRetryCount ¶
func (*Store) ListAgentRuns ¶ added in v0.149.0
func (*Store) ListAgents ¶
func (*Store) ListChatMessages ¶
func (*Store) ListChatSessions ¶
func (s *Store) ListChatSessions() ([]*ChatSession, error)
func (*Store) ListConversations ¶ added in v0.148.0
func (s *Store) ListConversations(owner, root string) ([]*Conversation, error)
func (*Store) ListReady ¶
ListReady returns pending tasks where all dependencies are done (or have no dependencies).
func (*Store) ListRecentThread ¶
func (s *Store) ListRecentThread(n int) ([]*ThreadEntry, error)
func (*Store) ListRecurring ¶
func (*Store) ListRunInventory ¶ added in v0.149.4
func (s *Store) ListRunInventory(ctx context.Context, q RunInventoryQuery) (RunInventoryPage, error)
ListRunInventory enumerates committed metadata in a read transaction. It does not load run output, touch eggs, reconcile state, or instantiate workers.
func (*Store) ListThreadByDate ¶
func (s *Store) ListThreadByDate(date time.Time) ([]*ThreadEntry, error)
func (*Store) PendingConversationWake ¶ added in v0.148.0
func (s *Store) PendingConversationWake(root string) (*ConversationWake, error)
func (*Store) QueueConversationWake ¶ added in v0.148.0
func (s *Store) QueueConversationWake(root string) (*ConversationWake, error)
At most one event is outstanding per root. Scanning and reservation commit together; reopening the store cannot create a second wake for that event.
func (*Store) RecordConversationState ¶ added in v0.148.0
func (s *Store) RecordConversationState(c *Conversation, cursor int64, state, source string) error
func (*Store) RecordConversationWake ¶ added in v0.148.0
func (s *Store) RecordConversationWake(w *ConversationWake, status, reason string, receipt, now int64) error
func (*Store) ReserveConversation ¶ added in v0.148.0
func (s *Store) ReserveConversation(c Conversation) (*Conversation, bool, error)
ReserveConversation atomically claims a caller-provided launch key before spawning. Replays return the same logical and execution IDs, even if a crash left the reservation in starting; callers must reconcile, never launch again.
func (*Store) ReserveConversationContinuation ¶ added in v0.148.0
func (s *Store) ReserveConversationContinuation(c ConversationContinuation) (*ConversationContinuation, bool, error)
ReserveConversationContinuation claims the retry key and links the execution before dispatch. A crash leaves starting evidence; replay never dispatches it.
func (*Store) ResumeConversationExecution ¶ added in v0.148.0
func (*Store) RetryNotSentConversationWake ¶ added in v0.148.0
Explicit recovery is permitted only by a retained known-no-input outcome. Attempt numbers and old request evidence never reset or become ambiguous.
func (*Store) SaveAgentRun ¶ added in v0.149.0
func (*Store) SaveAgentRuns ¶ added in v0.149.0
func (s *Store) SaveAgentRuns(updates []AgentRunUpdate) error
SaveAgentRuns commits a parent stop intent and every unstarted follow-up cancellation together, including their task projections and events.
func (*Store) SetConversationContinuationLaunch ¶ added in v0.148.0
func (s *Store) SetConversationContinuationLaunch(c *ConversationContinuation, state, detail string) error
func (*Store) SetConversationLaunch ¶ added in v0.148.0
func (*Store) SetConversationWake ¶ added in v0.148.0
func (*Store) SetTaskError ¶
func (*Store) SetTaskOutput ¶
func (*Store) SetTaskResolved ¶ added in v0.144.0
SetTaskResolved records the runtime choices made by the orchestrator. Tasks may be submitted without either field, so the stored values must be updated after skill/config precedence has been resolved if API clients are to see what actually ran.
func (*Store) SetTaskWhat ¶ added in v0.145.0
SetTaskWhat records the final prompt used to execute a task. Some task types, such as queued agent follow-ups, cannot assemble their complete prompt until a dependency has finished.
func (*Store) SumTokensByDateRange ¶
func (*Store) ThreadEntryExists ¶
ThreadEntryExists checks if a thread entry with the given task_id, wing_id, and timestamp exists.
func (*Store) ThreadEntryExistsBySummary ¶
func (s *Store) ThreadEntryExistsBySummary(wingID string, timestamp time.Time, summary string) (bool, error)
ThreadEntryExistsBySummary checks if a thread entry with the given wing_id, timestamp, and summary exists.
func (*Store) UpdateAgentHealth ¶
func (*Store) UpdateTaskStatus ¶
func (*Store) UpsertAgent ¶
type Task ¶
type Task struct {
ID string
Type string
What string
RunAt time.Time
Agent string
Model string
TimeoutSeconds int
Isolation string
Memory *string
ParentID *string
Status string
Cron *string
WingID *string
CreatedAt time.Time
StartedAt *time.Time
FinishedAt *time.Time
Output *string
Error *string
RetryCount int
MaxRetries int
DependsOn *string
CWD string
PromptName string
PromptRevision string
Principal string
RunnerPID int
EggConfigYAML string
}