Documentation
¶
Index ¶
- Constants
- Variables
- func ErrorMessage(err error, activeLimit int) string
- func HasDailyBudgetResumeAuthority(ctx context.Context, operator bool) bool
- func IntersectPermissions(a, b store.SessionPermissionPolicy) store.SessionPermissionPolicy
- func OperatorOnlyResume(reason string) bool
- func PickPromptText(p ProposalPayload, action *ActionSnapshot) (string, error)
- func WithAppBudgetResume(ctx context.Context) context.Context
- func WriteSkillDraft(root string, scanRoots []string, draft SkillDraft) (path, digest string, err error)
- type ActionSnapshot
- type Activity
- type ActivityCost
- type ActivityDay
- type ActivityHour
- type ActivityQuery
- type ActivityReader
- type Admission
- type AdoptRequest
- type Authority
- type Caller
- type CallerReader
- type CheckIn
- type CheckInProposalSummary
- type CheckInReader
- type CheckInToolCall
- type CheckInToolReader
- type CheckInToolSummary
- type CreateRequest
- type DailyBudgetAssessment
- type DailyBudgetLimits
- type DailyBudgetUsage
- type Instance
- type InstanceStore
- type LifecycleHooks
- type ListQuery
- type MainSessionRotator
- type MainSessionStarter
- type Metrics
- type Occurrence
- type Option
- func WithActiveLimit(limit int) Option
- func WithAdmission(admission Admission) Option
- func WithClock(now func() time.Time) Option
- func WithInstanceChanged(changed func(Instance)) Option
- func WithLifecycleHooks(dispatcher LifecycleHooks) Option
- func WithMainSessionRotator(rotator MainSessionRotator) Option
- func WithMainSessions(starter MainSessionStarter) Option
- func WithResumeCommit(commit func(context.Context, string, func(context.Context) error) error) Option
- func WithStateEffects(effects func(context.Context, Instance) error) Option
- func WithStore(store InstanceStore) Option
- type PauseResult
- type Pick
- type PickRequest
- type PickStore
- type ProjectionState
- type ProposalPayload
- type ReconciliationSessions
- type Report
- type ReportEventWriter
- type ReportInput
- type ReportPublication
- type ReportPublisher
- type ReportQuery
- type ReportStore
- type RotationDecision
- type RotationPublication
- type SeenResult
- type SeenStore
- type Service
- func (s *Service) Adopt(ctx context.Context, req AdoptRequest) (Instance, error)
- func (s *Service) AfterPause(ctx context.Context, trip store.InstancePauseTrip) error
- func (s *Service) ApplyPause(ctx context.Context, instance Instance) error
- func (s *Service) Archive(ctx context.Context, id string) error
- func (s *Service) Create(ctx context.Context, req CreateRequest) (Instance, bool, error)
- func (s *Service) EnsureMain(ctx context.Context, id string) (Instance, error)
- func (s *Service) List(ctx context.Context, q ListQuery) ([]Instance, error)
- func (s *Service) Pause(ctx context.Context, id, reason string) (Instance, error)
- func (s *Service) Reconcile(ctx context.Context) error
- func (s *Service) Resume(ctx context.Context, id string, actor workspaceaccess.ActorRef) (Instance, error)
- type SkillAutomaticContents
- type SkillDraft
- type SkillDraftFile
- type SkillProposalInput
- type SkillProposalService
- func (s *SkillProposalService) Approve(ctx context.Context, actor workspaceaccess.ActorRef, instance Instance, ...) (err error)
- func (s *SkillProposalService) Propose(ctx context.Context, actor workspaceaccess.ActorRef, instance Instance, ...) (SkillReview, error)
- func (s *SkillProposalService) Reject(ctx context.Context, actor workspaceaccess.ActorRef, instance Instance, ...) error
- func (s *SkillProposalService) Review(ctx context.Context, actor workspaceaccess.ActorRef, instance Instance, ...) (SkillReview, SkillDraft, error)
- func (s *SkillProposalService) Reviews(ctx context.Context, actor workspaceaccess.ActorRef, instance Instance, ...) ([]SkillReview, error)
- type SkillReview
- type SkillReviewQuery
- type SkillReviewStore
- type StartMainSession
- type StartOutcome
Constants ¶
const LocalOperator = "local-operator"
LocalOperator identifies the single authenticated human authority of the local daemon.
const ReportKindProposal = "proposal"
const SkillReviewPending = "pending"
Variables ¶
var ( ErrWorkspaceAccessDenied = errors.New("workspace_access_denied") ErrSessionNotRoot = errors.New("session_not_root") ErrPaused = errors.New("agent_instance_paused") ErrLimit = errors.New("agent_instance_limit") ErrExists = errors.New("agent_instance_exists") ErrStarting = errors.New("agent_instance_starting") ErrForbidden = errors.New("agent_instance_forbidden") ErrDepth = errors.New("agent_instance_depth") ErrNotAlwaysOn = errors.New("agent_not_always_on") ErrDefinitionMissing = errors.New("agent_definition_missing") ErrNotFound = errors.New("agent_instance_not_found") ErrScopeMismatch = errors.New("session_scope_mismatch") ErrBudgetHistoryUncertain = errors.New("agent_instance_budget_history_uncertain") )
var ( ErrReportNotFound = errors.New("report_not_found") ErrAlreadyPicked = errors.New("proposal_already_picked") ErrProposalRange = errors.New("proposal_out_of_range") ErrReportNotProposal = errors.New("report_not_proposal") ErrInstanceNotActive = errors.New("instance_not_active") ErrNoMainSession = errors.New("instance_no_main_session") )
var ( ErrSkillReviewLimit = errors.New("skill_review_limit") ErrSkillReviewStale = errors.New("skill_review_stale") // ErrSkillReviewInvalid means the reviewed digest still matches but the draft cannot be installed: // its bytes, name or file paths fail verification. Only rejection can settle such a review. ErrSkillReviewInvalid = errors.New("skill_review_invalid") ErrSkillReviewNotFound = errors.New("skill_review_not_found") ErrSkillReviewOperatorOnly = errors.New("skill_review_operator_only") )
var ErrRotationChanged = errors.New("agentinstance: rotation state changed")
var ErrSkillProposeUnverified = errors.New("skill_propose_unverified")
var ErrSkillReviewNoTarget = errors.New("skill_review_no_target")
Functions ¶
func ErrorMessage ¶
ErrorMessage describes a domain failure without changing its stable code.
func HasDailyBudgetResumeAuthority ¶
HasDailyBudgetResumeAuthority reserves budget resume for an operator without app credentials.
func IntersectPermissions ¶
func IntersectPermissions(a, b store.SessionPermissionPolicy) store.SessionPermissionPolicy
func OperatorOnlyResume ¶
OperatorOnlyResume keeps safety and unknown pauses under operator control.
func PickPromptText ¶
func PickPromptText(p ProposalPayload, action *ActionSnapshot) (string, error)
func WithAppBudgetResume ¶
WithAppBudgetResume marks application credentials while preserving existing lifecycle authority for pauses unrelated to the daily budget.
func WriteSkillDraft ¶
func WriteSkillDraft(root string, scanRoots []string, draft SkillDraft) (path, digest string, err error)
Types ¶
type ActionSnapshot ¶
type Activity ¶
type Activity struct {
ReportsByDay []ActivityDay `json:"reports_by_day"`
CostByProject []ActivityCost `json:"cost_by_project"`
BusyByHour []ActivityHour `json:"busy_by_hour"`
}
type ActivityCost ¶
type ActivityDay ¶
type ActivityHour ¶
type ActivityQuery ¶
type ActivityReader ¶
type ActivityReader interface {
ReadActivity(context.Context, ActivityQuery) (Activity, error)
ReadActivities(context.Context, []ActivityQuery) ([]Activity, error)
}
type Admission ¶
type Admission interface {
ResolveCreate(context.Context, CreateRequest) (Instance, error)
ValidateResume(context.Context, Instance) error
ResolveAdopt(context.Context, AdoptRequest) (Instance, error)
}
Admission resolves authenticated lineage, definition and intersected permissions at the daemon boundary.
type AdoptRequest ¶
type AdoptRequest struct {
CreateRequest
SessionID string
}
type Caller ¶
type Caller struct {
SessionID, AgentName, ProfileID, InstanceID string
InstanceDepth int
PermissionPolicy store.SessionPermissionPolicy
Grant string
}
type CallerReader ¶
type CheckIn ¶
type CheckIn struct {
Proposals CheckInProposalSummary
OccurrenceID string
ToolsStatus string
ToolCalls []CheckInToolCall
ID string
Result string
Detail string
Reason string
CreatedAt time.Time
}
type CheckInProposalSummary ¶
type CheckInReader ¶
type CheckInToolCall ¶
type CheckInToolCall struct {
Seq int64 `json:"seq"`
ToolID string `json:"tool_id"`
Backend string `json:"backend"`
MCPServer string `json:"mcp_server,omitempty"`
Access string `json:"access"`
Decision string `json:"decision"`
DenyReason string `json:"deny_reason,omitempty"`
Outcome string `json:"outcome"`
Effect string `json:"effect"`
ErrorCode string `json:"error_code,omitempty"`
ArgsPreview string `json:"args_preview,omitempty"`
DurationMS int64 `json:"duration_ms"`
}
type CheckInToolReader ¶
type CheckInToolSummary ¶
type CreateRequest ¶
type CreateRequest struct {
Agent, Workspace, Profile string
Actor workspaceaccess.ActorRef
}
type DailyBudgetAssessment ¶
type DailyBudgetAssessment struct {
Warn bool
Exhausted bool
TokensExhausted bool
USDExhausted bool
USDUnpriced bool
}
DailyBudgetAssessment describes whether the next turn is held and why.
func EvaluateDailyBudget ¶
func EvaluateDailyBudget( limits DailyBudgetLimits, used DailyBudgetUsage, previousWarning bool, ) (DailyBudgetAssessment, error)
EvaluateDailyBudget calculates one budget decision without changing notice or pause state. The caller must persist warning deduplication and pause atomically with its authoritative usage and admission state.
type DailyBudgetLimits ¶
type DailyBudgetLimits struct {
Tokens *int64 `json:"tokens,omitempty"`
USD *float64 `json:"usd,omitempty"`
}
DailyBudgetLimits holds optional operator caps. A nil cap leaves its dimension unrestricted, including when an observed provider has no USD pricing.
func (DailyBudgetLimits) Validate ¶
func (limits DailyBudgetLimits) Validate() error
Validate rejects caps that cannot be enforced with monotonic usage totals.
type DailyBudgetUsage ¶
DailyBudgetUsage represents consumption in one instance's local calendar day. USD retains the exact decimal cost subtotal even if some receipts have no price. HasUnpricedUsage records incomplete pricing separately from that subtotal.
func (*DailyBudgetUsage) AddReceipt ¶
func (usage *DailyBudgetUsage) AddReceipt(tokens int64, usd *float64) error
AddReceipt accumulates one priced or unpriced receipt. Invalid receipts fail without changing totals; unknown pricing never erases the known lower bound.
func (DailyBudgetUsage) Validate ¶
func (usage DailyBudgetUsage) Validate() error
Validate rejects invalid restored totals before they can affect admission or be combined with new receipts.
type Instance ¶
type Instance struct {
ID string
ProfileID string
AgentName string
WorkspaceID string
State string
PauseReason string
MainSessionID string
GrantCeiling string
PermissionCeiling string
ChecksEnabled bool
Depth int
CreatedByKind string
CreatedByID string
CreatedAt time.Time
UpdatedAt time.Time
ArchivedAt *time.Time
}
type InstanceStore ¶
type InstanceStore interface {
Get(context.Context, string) (Instance, error)
PublishMissingMain(context.Context, string, string) (Instance, error)
ReconciliationPage(context.Context, string, int) ([]Instance, error)
Adopt(context.Context, Instance, string, int) (Instance, error)
AdmitCreate(context.Context, Instance, int) (Instance, bool, error)
BindMain(context.Context, string, string) (Instance, error)
DeleteUnstarted(context.Context, string) error
Pause(context.Context, string, string) (PauseResult, error)
Resume(context.Context, string, int, bool) (Instance, error)
Archive(context.Context, string) (Instance, error)
List(context.Context, ListQuery) ([]Instance, error)
}
type LifecycleHooks ¶
type LifecycleHooks interface {
DispatchAgentInstance(context.Context, hooks.AgentInstancePayload) (hooks.AgentInstancePayload, error)
}
type MainSessionRotator ¶
type MainSessionStarter ¶
type Metrics ¶
type Metrics struct {
CheckInToolCalls map[string]map[string]int64 `json:"heartbeat_check_in_tool_calls_total"`
Picks map[string]int64 `json:"agent_instance_picks_total"`
PauseCounts map[string]int64 `json:"pause_counts"`
HeldInputCount int64 `json:"held_input_count"`
}
Metrics counts live paused instances and held inputs within one profile and workspace.
type Occurrence ¶
type Occurrence struct {
State, Result, Reason, ReportID string
}
type Option ¶
type Option func(*Service)
func WithActiveLimit ¶
func WithAdmission ¶
func WithInstanceChanged ¶
func WithLifecycleHooks ¶
func WithLifecycleHooks(dispatcher LifecycleHooks) Option
func WithMainSessionRotator ¶
func WithMainSessionRotator(rotator MainSessionRotator) Option
func WithMainSessions ¶
func WithMainSessions(starter MainSessionStarter) Option
func WithResumeCommit ¶
func WithResumeCommit(commit func(context.Context, string, func(context.Context) error) error) Option
WithResumeCommit lets the daemon serialize the durable resume with receipt recovery.
func WithStateEffects ¶
WithStateEffects reconciles durable pause/resume obligations through their owning services.
func WithStore ¶
func WithStore(store InstanceStore) Option
type PauseResult ¶
type Pick ¶
type Pick struct {
InstanceID string `json:"-"`
ReportID string `json:"report_id"`
ProposalIndex int `json:"proposal_index"`
ActionID string `json:"action_id,omitempty"`
Actor string `json:"actor"`
TargetSession string `json:"target_session_id"`
QueueEntryID string `json:"queue_entry_id"`
State string `json:"state"`
PickedAt time.Time `json:"picked_at"`
}
type PickRequest ¶
type PickRequest struct {
Actions []ActionSnapshot
InstanceID, ReportID, Actor string
ProposalIndex, QueueCap int
}
type PickStore ¶
type PickStore interface {
PickProposal(context.Context, PickRequest) (Pick, error)
}
type ProjectionState ¶
type ProjectionState struct {
CallerInstanceID, DirectInstanceID, InstanceID, OccurrenceID, MainSessionID string
Policy, Grant, LineageKind, SessionType string
ProfileID, WorkspaceID, AgentName string
State, PauseReason, PermissionCeiling string
Depth, ChecksEnabled int64
Archived bool
}
ProjectionState identifies the durable inputs a session's tool projection reads. Policy is the stored ceiling, compared in its serialized form without compiling it.
type ProposalPayload ¶
type ProposalPayload struct {
Title string `json:"title"`
Body string `json:"body"`
ItemKeys []string `json:"item_keys"`
Action *ActionSnapshot `json:"action,omitempty"`
AutoAcceptStatus string `json:"auto_accept_status"`
}
type ReconciliationSessions ¶
type ReportEventWriter ¶
Publish must durably deduplicate by (sessionID, Report.ID), including after restart.
type ReportInput ¶
func (ReportInput) Validate ¶
func (r ReportInput) Validate() error
type ReportPublication ¶
type ReportPublisher ¶
type ReportPublisher struct {
Store ReportStore
Writer ReportEventWriter
BatchSize int
}
type ReportQuery ¶
type ReportStore ¶
type ReportStore interface {
AppendReport(context.Context, string, ReportInput) (Report, error)
ListReports(context.Context, ReportQuery) ([]Report, error)
UnpublishedReports(context.Context, string, int) ([]ReportPublication, error)
MarkReportPublished(context.Context, string, string, int64) error
}
type RotationDecision ¶
type RotationDecision struct {
Publication RotationPublication
Eligible bool
}
type RotationPublication ¶
type SeenResult ¶
type SeenResult struct {
LastSeenAt time.Time
Interactions []store.SessionAttentionCommit
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) AfterPause ¶
func (*Service) ApplyPause ¶
func (*Service) EnsureMain ¶
type SkillAutomaticContents ¶
type SkillAutomaticContents struct{ Hooks, MCPServers, Scripts int }
SkillAutomaticContents inventories declarations for review; it never executes them.
type SkillDraft ¶
type SkillDraft struct {
Name string `json:"name"`
Files []SkillDraftFile `json:"files"`
}
func PrepareSkillDraft ¶
func PrepareSkillDraft(name, description, body string, files []SkillDraftFile) (SkillDraft, error)
func ReadSkillDraft ¶
func ReadSkillDraft(path, digest string) (SkillDraft, error)
func (SkillDraft) AutomaticContents ¶
func (draft SkillDraft) AutomaticContents() (SkillAutomaticContents, error)
type SkillDraftFile ¶
type SkillProposalInput ¶
type SkillProposalInput struct {
Name string
Description string
Body string
Files []SkillDraftFile
EvidenceSessionIDs []string
}
type SkillProposalService ¶
type SkillProposalService struct {
Store SkillReviewStore
Authority Authority
DraftRoot string
ScanRoots []string
}
func (*SkillProposalService) Approve ¶
func (s *SkillProposalService) Approve( ctx context.Context, actor workspaceaccess.ActorRef, instance Instance, id, digest, operator, targetRoot string, ) (err error)
func (*SkillProposalService) Propose ¶
func (s *SkillProposalService) Propose( ctx context.Context, actor workspaceaccess.ActorRef, instance Instance, targetRoot string, input SkillProposalInput, ) (SkillReview, error)
func (*SkillProposalService) Reject ¶
func (s *SkillProposalService) Reject( ctx context.Context, actor workspaceaccess.ActorRef, instance Instance, id, digest, operator string, ) error
func (*SkillProposalService) Review ¶
func (s *SkillProposalService) Review( ctx context.Context, actor workspaceaccess.ActorRef, instance Instance, id string, ) (SkillReview, SkillDraft, error)
func (*SkillProposalService) Reviews ¶
func (s *SkillProposalService) Reviews( ctx context.Context, actor workspaceaccess.ActorRef, instance Instance, query SkillReviewQuery, ) ([]SkillReview, error)
type SkillReview ¶
type SkillReviewQuery ¶
type SkillReviewStore ¶
type SkillReviewStore interface {
CreateReview(context.Context, SkillReview, ReportInput) (SkillReview, error)
GetReview(context.Context, string) (SkillReview, error)
ListReviews(context.Context, SkillReviewQuery) ([]SkillReview, error)
DecideReview(context.Context, string, string, string, string) error
}
type StartMainSession ¶
type StartMainSession struct{ Instance Instance }