api

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CapabilityAppHeartbeat enables a lightweight browser-compatible liveness
	// exchange. Native clients use WebSocket ping frames, while browsers cannot
	// originate protocol-level ping frames from JavaScript.
	CapabilityAppHeartbeat      = "app-heartbeat-v1"
	CapabilityRosterDelta       = "roster-delta"
	CapabilityAgentTimeline     = "agent-timeline-v1"
	CapabilityAgentInteractions = "agent-interactions-v1"
	CapabilityAgentInterrupt    = "agent-interrupt-v1"
	CapabilityAgentAttachments  = "agent-attachments-v1"
	CapabilityAgentGoals        = "agent-goals-v1"
)

Agent View capabilities are negotiated independently from protocol 4.0. Keep these strings stable: clients persist no capability state and may safely ignore names introduced by a newer Host.

View Source
const (
	HealthReady        = "ready"
	HealthUnavailable  = "unavailable"
	HealthUnconfigured = "unconfigured"
	HealthDisconnected = "disconnected"
	HealthConnected    = "connected"
	HealthError        = "error"
)
View Source
const (
	SessionScopeWorkspace     = "workspace"
	SessionScopeTerminalGroup = "terminalGroup"
)
View Source
const (
	GhostlineMigrationPreparing = "preparing"
	GhostlineMigrationPrepared  = "prepared"
	GhostlineMigrationCommitted = "committed"
	GhostlineMigrationRouted    = "routed"
	GhostlineMigrationRetired   = "retired"
)
View Source
const AttentionStreamID = "host:attention:v1"

AttentionStreamID is the reserved Host-wide stream carrying sanitized attention changes. It is not an AgentExecution ID.

View Source
const UsageIntervalBucketMinutes = 5

UsageIntervalBucketMinutes is the Host's durable intraday storage grain. Clients may aggregate these base buckets into a larger display interval.

Version is the logical protocol version. Sourced from protocol/warren.schema.json via internal/protocol; do not edit here.

Variables

View Source
var (
	// ErrAgentBlocked is returned when a prompt cannot be injected because
	// the terminal agent is currently awaiting human attention or approval.
	ErrAgentBlocked = errors.New("agent is blocked on attention")

	// ErrAgentBusy is returned when a prompt cannot be injected because
	// the agent is currently working on an active turn without queue support.
	ErrAgentBusy = errors.New("agent is currently working")
)

AgentViewCapabilities is the complete capability set implemented by this Host. A copy is returned so callers cannot mutate the process-wide list.

Functions

func AgentAttachmentChunkDigest added in v0.12.0

func AgentAttachmentChunkDigest(data []byte, length int, expectedSHA256 string) error

AgentAttachmentChunkDigest validates a chunk's declared length and digest. It is kept pure so Headless contract tests and alternate transports share exactly the same validation rules.

func HostCapabilities added in v0.12.0

func HostCapabilities() []string

HostCapabilities returns the capabilities understood by the Headless WebSocket endpoint. Keep the legacy roster-delta capability in the same negotiation list so a welcome message is a true intersection rather than a second, agent-only capability channel.

func NegotiateCapabilities added in v0.12.0

func NegotiateCapabilities(hostCapabilities, clientCapabilities []string) []string

NegotiateCapabilities returns the ordered intersection of the Host's capabilities and a client's declaration. Unknown and duplicate names are ignored. Ordering follows hostCapabilities, making welcome messages stable and easy to compare in contract tests.

func NormalizeCapabilityList added in v0.12.0

func NormalizeCapabilityList(values []string) []string

NormalizeCapabilityList provides deterministic values for tests and logs without changing the negotiated ordering used in the welcome message.

func StableAgentEventID added in v0.12.0

func StableAgentEventID(event AgentEvent) string

StableAgentEventID derives an idempotency identity for provider observations that do not carry a native message/call ID. The provider-local sequence is included as a tie breaker; the Host still owns the canonical stream sequence. Keep the input aligned with CanonicalAgentEventFromObservation: every provider field that can change the canonical payload must change this identity too.

func SupportsCapability added in v0.12.0

func SupportsCapability(capabilities []string, wanted string) bool

SupportsCapability reports whether a negotiated list contains capability.

Types

type AgentActivity

type AgentActivity string

AgentActivity is the lifecycle state of an agent conversation. Human attention is represented separately by AgentStatus.Attention.

const (
	AgentActivityReady   AgentActivity = "ready"
	AgentActivityWorking AgentActivity = "working"
	AgentActivityBlocked AgentActivity = "blocked"
	AgentActivityStalled AgentActivity = "stalled"
	AgentActivityFailed  AgentActivity = "failed"
	AgentActivityExited  AgentActivity = "exited"
)

type AgentAttachmentAbortCommand added in v0.12.0

type AgentAttachmentAbortCommand struct {
	AgentCommand
	UploadID string `json:"uploadId"`
}

type AgentAttachmentAbortRequest added in v0.12.0

type AgentAttachmentAbortRequest struct {
	Session  string `json:"session"`
	UploadID string `json:"uploadId"`
}

type AgentAttachmentChunkCommand added in v0.12.0

type AgentAttachmentChunkCommand struct {
	AgentCommand
	UploadID string `json:"uploadId"`
	Chunk    uint64 `json:"chunk"`
	Length   int    `json:"length"`
	SHA256   string `json:"sha256,omitempty"`
	Data     string `json:"data"`
}

type AgentAttachmentChunkRequest added in v0.12.0

type AgentAttachmentChunkRequest struct {
	Session  string `json:"session"`
	UploadID string `json:"uploadId"`
	Sequence uint64 `json:"sequence"`
	Length   int    `json:"length"`
	SHA256   string `json:"sha256,omitempty"`
	Data     string `json:"data"` // base64 for JSON transports; binary adapters may bypass this field.
}

type AgentAttachmentCompleteCommand added in v0.12.0

type AgentAttachmentCompleteCommand struct {
	AgentCommand
	UploadID string `json:"uploadId"`
	Length   int64  `json:"length"`
	SHA256   string `json:"sha256,omitempty"`
}

type AgentAttachmentCompleteRequest added in v0.12.0

type AgentAttachmentCompleteRequest struct {
	Session  string `json:"session"`
	UploadID string `json:"uploadId"`
	Length   int64  `json:"length"`
	SHA256   string `json:"sha256,omitempty"`
}

type AgentAttachmentPrepareCommand added in v0.12.0

type AgentAttachmentPrepareCommand struct {
	AgentCommand
	Name   string `json:"name"`
	MIME   string `json:"mime"`
	Size   int64  `json:"size"`
	SHA256 string `json:"sha256,omitempty"`
}

type AgentAttachmentPrepareRequest added in v0.12.0

type AgentAttachmentPrepareRequest struct {
	Session string `json:"session"`
	Name    string `json:"name"`
	MIME    string `json:"mime"`
	Size    int64  `json:"size"`
	SHA256  string `json:"sha256,omitempty"`
}

AgentAttachmentPrepareRequest starts an opaque upload session.

type AgentAttachmentPrepareResult added in v0.12.0

type AgentAttachmentPrepareResult struct {
	AttachmentID string    `json:"attachmentId"`
	UploadID     string    `json:"uploadId"`
	ChunkSize    int       `json:"chunkSize"`
	ExpiresAt    time.Time `json:"expiresAt"`
}

type AgentAttachmentRef added in v0.12.0

type AgentAttachmentRef struct {
	AttachmentID string `json:"attachmentId"`
	Name         string `json:"name,omitempty"`
	MIME         string `json:"mime,omitempty"`
	Size         int64  `json:"size,omitempty"`
}

type AgentAttachmentResult added in v0.12.0

type AgentAttachmentResult struct {
	Accepted     bool   `json:"accepted"`
	AttachmentID string `json:"attachmentId,omitempty"`
	UploadID     string `json:"uploadId,omitempty"`
	State        string `json:"state,omitempty"`
	Received     int64  `json:"received,omitempty"`
	Error        string `json:"error,omitempty"`
}

type AgentAttention

type AgentAttention struct {
	Kind      AgentAttentionKind `json:"kind"`
	Reason    string             `json:"reason"`
	RequestID string             `json:"requestId,omitempty"`
	Since     time.Time          `json:"since"`
}

AgentAttention is bounded, provider-neutral metadata. It must never carry transcript content, prompt text, command arguments, or secrets.

type AgentAttentionKind

type AgentAttentionKind string

AgentAttentionKind identifies why a person should inspect an agent session. A warning is intentionally less certain than an input or approval request; it describes an abnormal condition such as a stalled turn.

const (
	AgentAttentionInput    AgentAttentionKind = "input"
	AgentAttentionApproval AgentAttentionKind = "approval"
	AgentAttentionWarning  AgentAttentionKind = "warning"
)

type AgentCommand added in v0.12.0

type AgentCommand struct {
	CommandID       string `json:"commandId"`
	ExecutionID     string `json:"executionId"`
	ExpectedVersion uint64 `json:"expectedVersion,omitempty"`
	LeaseID         string `json:"leaseId,omitempty"`
}

AgentCommand is shared by all mutating Agent methods. ExpectedVersion is checked by Headless before the driver is invoked; CommandID makes retries idempotent across reconnects.

type AgentCommandReceipt added in v0.12.0

type AgentCommandReceipt struct {
	CommandID string `json:"commandId"`
	Accepted  bool   `json:"accepted"`
}

type AgentDiagnostic added in v0.12.0

type AgentDiagnostic struct {
	File      string `json:"file"`
	Line      int    `json:"line"`
	Column    int    `json:"column,omitempty"`
	EndLine   int    `json:"endLine,omitempty"`
	EndColumn int    `json:"endColumn,omitempty"`
	Severity  string `json:"severity"` // "error", "warning", "info", "hint"
	Message   string `json:"message"`
	Source    string `json:"source,omitempty"`
	Code      string `json:"code,omitempty"`
}

AgentDiagnostic carries normalized compiler or LSP diagnostics attached to file operations.

type AgentDiff added in v0.12.0

type AgentDiff struct {
	File      string   `json:"file,omitempty"`
	Files     []string `json:"files,omitempty"`
	Additions int      `json:"additions,omitempty"`
	Deletions int      `json:"deletions,omitempty"`
	Diff      string   `json:"diff,omitempty"`
	CallID    string   `json:"callId,omitempty"`
}

AgentDiff carries normalized metrics and content for a code patch or edit. Clients render a single-line summary card with a git badge and +/- stats (e.g. +11 -0 in green/red or blue/red), expandable to full unified diff.

type AgentEvent

type AgentEvent struct {
	Sequence uint64 `json:"seq"`
	Turn     uint64 `json:"turn,omitempty"`
	ID       string `json:"id,omitempty"`
	Provider string `json:"provider"`
	Type     string `json:"type"`
	// CanonicalType is local presentation metadata retained while projecting a
	// canonical history row back to the legacy AgentEvent shape. It is not part
	// of the AgentEvent wire representation.
	CanonicalType string `json:"-"`
	Role          string `json:"role,omitempty"`
	Content       string `json:"content,omitempty"`
	// ContentDelta marks content as an append-only delta to the previous event
	// with the same provider, type, and ID. It is used by providers such as
	// OpenCode whose mutable parts are projected into the append-only event
	// stream.
	ContentDelta bool   `json:"contentDelta,omitempty"`
	Model        string `json:"model,omitempty"`
	StopReason   string `json:"stopReason,omitempty"`
	ToolName     string `json:"toolName,omitempty"`
	// ToolKind is the provider-neutral action category used by clients for
	// compact rendering (for example "ran", "glob", or "read").
	ToolKind string `json:"toolKind,omitempty"`
	// ToolDetail is the bounded human-readable detail for a tool invocation,
	// such as a command, path, query, or URL. It is never a second raw tool log.
	ToolDetail string      `json:"toolDetail,omitempty"`
	ToolInput  any         `json:"toolInput,omitempty"`
	ToolStatus string      `json:"toolStatus,omitempty"`
	CallID     string      `json:"callId,omitempty"`
	Output     string      `json:"output,omitempty"`
	Files      []string    `json:"files,omitempty"`
	Error      string      `json:"error,omitempty"`
	Usage      *AgentUsage `json:"usage,omitempty"`
	DurationMs int64       `json:"durationMs,omitempty"`
	Sidechain  bool        `json:"sidechain,omitempty"`
	Timestamp  time.Time   `json:"timestamp,omitempty"`
	// Payload carries the optional structured object used by RFC 0010
	// interaction, plan, activity, plugin, subagent and attachment events.
	// A map keeps old clients source-compatible while unknown fields remain
	// safely ignored by decoders that do not render the event type.
	Payload map[string]any `json:"payload,omitempty"`
}

AgentEvent is one normalized message or tool transition from a Codex, Claude, or OpenCode transcript. It is a projection of the provider's own log; the terminal byte stream remains the source of truth for rendering.

type AgentEventOrigin added in v0.12.0

type AgentEventOrigin struct {
	Kind       string `json:"kind"`
	Provider   string `json:"provider,omitempty"`
	Driver     string `json:"driver,omitempty"`
	Channel    string `json:"channel,omitempty"`
	Confidence string `json:"confidence"`
}

type AgentEventsHistoryRequest added in v0.12.0

type AgentEventsHistoryRequest struct {
	StreamID       string `json:"streamId"`
	AfterSequence  uint64 `json:"afterSequence,omitempty"`
	BeforeSequence uint64 `json:"beforeSequence,omitempty"`
	Limit          uint32 `json:"limit,omitempty"`
}

type AgentEventsHistoryResult added in v0.12.0

type AgentEventsHistoryResult struct {
	StreamID          string                `json:"streamId"`
	ExecutionID       string                `json:"executionId,omitempty"`
	Events            []CanonicalAgentEvent `json:"events"`
	NextAfterSequence uint64                `json:"nextAfterSequence,omitempty"`
	HeadSequence      uint64                `json:"headSequence"`
	HasMore           bool                  `json:"hasMore"`
	RetainedFrom      uint64                `json:"retainedFromSequence,omitempty"`
}

type AgentEventsSubscriptionRequest added in v0.12.0

type AgentEventsSubscriptionRequest struct {
	StreamID      string `json:"streamId"`
	AfterSequence uint64 `json:"afterSequence,omitempty"`
	Limit         uint32 `json:"limit,omitempty"`
}

type AgentEventsSubscriptionResult added in v0.12.0

type AgentEventsSubscriptionResult struct {
	StreamID    string                    `json:"streamId"`
	ExecutionID string                    `json:"executionId,omitempty"`
	Checkpoint  AgentProjectionCheckpoint `json:"checkpoint"`
	Events      []CanonicalAgentEvent     `json:"events"`
	Live        bool                      `json:"live"`
	// Subscription delivery is deliberately paged. These fields let a client
	// continue the catch-up without treating the first response as a complete
	// transcript. They are additive so older clients can keep using `live`.
	NextAfterSequence uint64 `json:"nextAfterSequence,omitempty"`
	HeadSequence      uint64 `json:"headSequence"`
	HasMore           bool   `json:"hasMore"`
	RetainedFrom      uint64 `json:"retainedFromSequence,omitempty"`
}

type AgentExecution added in v0.12.0

type AgentExecution struct {
	ID           string                       `json:"id"`
	StreamID     string                       `json:"streamId"`
	Target       AgentTargetRef               `json:"target"`
	Provider     string                       `json:"provider"`
	Conversation AgentProviderConversationRef `json:"conversation,omitempty"`
	Driver       string                       `json:"driver"`
	Capabilities []string                     `json:"capabilities"`
	State        AgentExecutionState          `json:"state"`
	Status       AgentStatus                  `json:"status"`
	ActiveTurn   *AgentTurn                   `json:"activeTurn,omitempty"`
	Interactions []AgentInteraction           `json:"interactions,omitempty"`
	HeadSequence uint64                       `json:"headSequence"`
}

AgentExecution is the Host-owned identity used by the canonical Agent API. It is a projection and may be rebuilt from the execution event stream.

type AgentExecutionState added in v0.12.0

type AgentExecutionState string
const (
	AgentExecutionStarting  AgentExecutionState = "starting"
	AgentExecutionReady     AgentExecutionState = "ready"
	AgentExecutionWorking   AgentExecutionState = "working"
	AgentExecutionBlocked   AgentExecutionState = "blocked"
	AgentExecutionCompleted AgentExecutionState = "completed"
	AgentExecutionFailed    AgentExecutionState = "failed"
	AgentExecutionClosed    AgentExecutionState = "closed"
)

type AgentGoalClearCommand added in v0.12.0

type AgentGoalClearCommand struct {
	AgentCommand
}

type AgentGoalClearRequest added in v0.12.0

type AgentGoalClearRequest struct {
	CommandID string `json:"commandId,omitempty"`
	Session   string `json:"session"`
}

AgentGoalClearRequest removes the current goal for one Agent session.

type AgentGoalResult added in v0.12.0

type AgentGoalResult struct {
	Accepted  bool   `json:"accepted"`
	Session   string `json:"session"`
	Objective string `json:"objective,omitempty"`
}

type AgentGoalSetCommand added in v0.12.0

type AgentGoalSetCommand struct {
	AgentCommand
	Objective       string `json:"objective"`
	Status          string `json:"status,omitempty"`
	TokenBudget     *int64 `json:"tokenBudget,omitempty"`
	ReplaceExisting bool   `json:"replaceExisting,omitempty"`
}

AgentGoalSetCommand updates the provider-owned goal associated with an execution. Status and token budget are optional so editing an objective does not accidentally reset Codex's live accounting state. ReplaceExisting asks a PTY fallback to use Codex's dedicated edit prompt.

type AgentGoalSetRequest added in v0.12.0

type AgentGoalSetRequest struct {
	CommandID       string `json:"commandId,omitempty"`
	Session         string `json:"session"`
	Objective       string `json:"objective"`
	Status          string `json:"status,omitempty"`
	TokenBudget     *int64 `json:"tokenBudget,omitempty"`
	ReplaceExisting bool   `json:"replaceExisting,omitempty"`
}

AgentGoalSetRequest updates the current goal for one Agent session. The provider owns the goal identity (Codex uses its thread ID), so the Host only carries the Warren Session ID across this bridge. ReplaceExisting is set by the iOS editor to select Codex's dedicated edit prompt when using PTY.

type AgentInteraction added in v0.12.0

type AgentInteraction struct {
	ID      string                   `json:"id"`
	TurnID  string                   `json:"turnId,omitempty"`
	Kind    string                   `json:"kind"`
	Version uint64                   `json:"version"`
	Title   string                   `json:"title"`
	Schema  map[string]any           `json:"schema,omitempty"`
	Options []AgentInteractionOption `json:"options,omitempty"`
	State   string                   `json:"state"`
}

AgentInteraction is a typed, versioned interaction projected by the Host. Its schema and options are bounded by the adapter before they reach a client.

type AgentInteractionOption added in v0.12.0

type AgentInteractionOption struct {
	ID          string `json:"id"`
	Label       string `json:"label"`
	Description string `json:"description,omitempty"`
}

type AgentInteractionResolveCommand added in v0.12.0

type AgentInteractionResolveCommand struct {
	AgentCommand
	InteractionID string         `json:"interactionId"`
	Version       uint64         `json:"version"`
	Resolution    map[string]any `json:"resolution"`
}

type AgentInteractionResponse added in v0.12.0

type AgentInteractionResponse struct {
	CommandID string         `json:"commandId,omitempty"`
	Session   string         `json:"session"`
	RequestID string         `json:"requestId"`
	Kind      string         `json:"kind"`
	Response  map[string]any `json:"response"`
}

AgentInteractionResponse is the common response for question, permission, and confirmation cards. Response is intentionally JSON-shaped so a Host can add bounded option values without changing the wire envelope.

type AgentInteractionResult added in v0.12.0

type AgentInteractionResult struct {
	Accepted  bool   `json:"accepted"`
	Session   string `json:"session"`
	RequestID string `json:"requestId"`
	Kind      string `json:"kind"`
}

type AgentMessageSendRequest added in v0.12.0

type AgentMessageSendRequest struct {
	Session         string               `json:"session"`
	ClientMessageID string               `json:"clientMessageId"`
	Text            string               `json:"text"`
	Attachments     []AgentAttachmentRef `json:"attachments,omitempty"`
}

AgentMessageSendRequest is the structured send path. Attachments contain opaque references only; file content and local paths never cross this API.

type AgentMessageSendResult added in v0.12.0

type AgentMessageSendResult struct {
	Accepted        bool   `json:"accepted"`
	Session         string `json:"session"`
	ClientMessageID string `json:"clientMessageId"`
}

type AgentProjectionCheckpoint added in v0.12.0

type AgentProjectionCheckpoint struct {
	Sequence uint64         `json:"sequence"`
	State    map[string]any `json:"state"`
}

type AgentProviderConversationRef added in v0.12.0

type AgentProviderConversationRef struct {
	ID             string `json:"id,omitempty"`
	TranscriptPath string `json:"transcriptPath,omitempty"`
}

AgentProviderConversationRef is opaque metadata owned by Headless. Clients must not use the provider ID or transcript path as an event identity.

type AgentQueueItem added in v0.12.0

type AgentQueueItem struct {
	ID          string               `json:"id"`
	Action      string               `json:"action,omitempty"` // "enqueue", "dequeue", "remove"
	Content     string               `json:"content,omitempty"`
	Prompt      string               `json:"prompt,omitempty"`
	SessionID   string               `json:"sessionId,omitempty"`
	Order       int                  `json:"order,omitempty"`
	State       string               `json:"state,omitempty"` // "queued", "dequeued", "cancelled"
	Attachments []AgentAttachmentRef `json:"attachments,omitempty"`
	CreatedAt   time.Time            `json:"createdAt,omitempty"`
}

AgentQueueItem carries normalized data for a queued prompt or command buffered by an agent CLI waiting to be admitted into an execution turn.

type AgentStatus

type AgentStatus struct {
	Activity  AgentActivity   `json:"activity"`
	Attention *AgentAttention `json:"attention"`
}

AgentStatus is the complete live projection sent to clients. Attention is nil when the session has no outstanding human-facing condition.

func (AgentStatus) Equal

func (s AgentStatus) Equal(other AgentStatus) bool

Equal compares the complete status value, including attention metadata. Attention is a pointer so callers can mutate their own copy without changing the tracker; pointer identity must therefore never participate in status-change detection.

type AgentTargetRef added in v0.12.0

type AgentTargetRef struct {
	Kind string `json:"kind"`
	ID   string `json:"id"`
}

AgentTargetRef identifies the Warren resource that owns an AgentExecution. The target is deliberately separate from a Warren Terminal Session so a cloud run can have Agent semantics without allocating a PTY.

type AgentTurn

type AgentTurn struct {
	ID     uint64          `json:"id"`
	Status AgentTurnStatus `json:"status"`
}

AgentTurn is a monotonically numbered lifecycle transition within one agent epoch. The number resets when the transcript projection is replaced.

type AgentTurnCancelCommand added in v0.12.0

type AgentTurnCancelCommand struct {
	AgentCommand
	TurnID string `json:"turnId"`
	Reason string `json:"reason,omitempty"`
}

type AgentTurnInterruptRequest added in v0.12.0

type AgentTurnInterruptRequest struct {
	CommandID   string                   `json:"commandId,omitempty"`
	Session     string                   `json:"session"`
	Turn        uint64                   `json:"turn"`
	Reason      string                   `json:"reason"`
	Replacement *AgentMessageSendRequest `json:"replacement,omitempty"`
}

AgentTurnInterruptRequest represents a Host cancel request or an atomic Send now/steer request. A Provider/TUI interruption is an observation, not this request type. When Replacement is present the Host must accept it only as part of the same steer transaction.

type AgentTurnInterruptResult added in v0.12.0

type AgentTurnInterruptResult struct {
	Accepted        bool   `json:"accepted"`
	Session         string `json:"session"`
	Turn            uint64 `json:"turn"`
	ClientMessageID string `json:"clientMessageId,omitempty"`
	Status          string `json:"status,omitempty"`
}

type AgentTurnStartCommand added in v0.12.0

type AgentTurnStartCommand struct {
	AgentCommand
	Text        string               `json:"text"`
	Attachments []AgentAttachmentRef `json:"attachments,omitempty"`
}

type AgentTurnStatus

type AgentTurnStatus string

AgentTurnStatus describes one explicit turn boundary in an agent transcript. Idle is only used by snapshots before the first observed turn. Interrupted is a provider-observed stop (for example a TUI Ctrl-C); cancelled is the observed completion of a Host cancellation/steer request. Aborted is retained for replaying older canonical events that did not preserve that distinction.

const (
	AgentTurnIdle        AgentTurnStatus = "idle"
	AgentTurnStarted     AgentTurnStatus = "started"
	AgentTurnCompleted   AgentTurnStatus = "completed"
	AgentTurnFailed      AgentTurnStatus = "failed"
	AgentTurnInterrupted AgentTurnStatus = "interrupted"
	AgentTurnCancelled   AgentTurnStatus = "cancelled"
	AgentTurnAborted     AgentTurnStatus = "aborted"
)

type AgentTurnSteerCommand added in v0.12.0

type AgentTurnSteerCommand struct {
	AgentCommand
	TurnID      string               `json:"turnId"`
	Text        string               `json:"text"`
	Attachments []AgentAttachmentRef `json:"attachments,omitempty"`
}

type AgentUsage

type AgentUsage struct {
	InputTokens              int64 `json:"inputTokens,omitempty"`
	CacheCreationInputTokens int64 `json:"cacheCreationInputTokens,omitempty"`
	CacheReadInputTokens     int64 `json:"cacheReadInputTokens,omitempty"`
	OutputTokens             int64 `json:"outputTokens,omitempty"`
	ReasoningOutputTokens    int64 `json:"reasoningOutputTokens,omitempty"`
	TotalTokens              int64 `json:"totalTokens,omitempty"`
}

AgentUsage mirrors the token accounting both CLIs attach to their own transcript lines.

type AgentWaitResult

type AgentWaitResult struct {
	Session     string                `json:"session"`
	ExecutionID string                `json:"executionId"`
	Turn        uint64                `json:"turn"`
	Status      AgentTurnStatus       `json:"status"`
	Events      []CanonicalAgentEvent `json:"events"`
}

AgentWaitResult is printed after a canonical turn completion event.

type CanonicalAgentEvent added in v0.12.0

type CanonicalAgentEvent struct {
	EventID     string           `json:"eventId"`
	StreamID    string           `json:"streamId"`
	ExecutionID string           `json:"executionId"`
	Sequence    uint64           `json:"sequence"`
	TurnID      string           `json:"turnId,omitempty"`
	Type        string           `json:"type"`
	OccurredAt  time.Time        `json:"occurredAt"`
	RecordedAt  time.Time        `json:"recordedAt"`
	CausedBy    string           `json:"causedBy,omitempty"`
	Origin      AgentEventOrigin `json:"origin"`
	Payload     map[string]any   `json:"payload"`
}

CanonicalAgentEvent is the one semantic event envelope emitted by Headless. Payload is a discriminated object selected by Type; unknown fields are intentionally retained when the event is persisted.

func CanonicalAgentEventFromObservation added in v0.12.0

func CanonicalAgentEventFromObservation(event AgentEvent, streamID, executionID string, sequence uint64, recordedAt time.Time) CanonicalAgentEvent

CanonicalAgentEventFromObservation is the sole adapter from a provider observation to the canonical event envelope. Provider-specific parsing stays outside clients and the journal only receives canonical events.

type CanonicalAgentEventsMessage added in v0.12.0

type CanonicalAgentEventsMessage struct {
	Type        string                `json:"t"`
	StreamID    string                `json:"streamId"`
	ExecutionID string                `json:"executionId,omitempty"`
	Replay      bool                  `json:"replay,omitempty"`
	Events      []CanonicalAgentEvent `json:"events"`
}

type Envelope

type Envelope struct {
	Type         string   `json:"t"`
	ID           string   `json:"id,omitempty"`
	Token        string   `json:"token,omitempty"`
	Version      string   `json:"version,omitempty"`
	Capabilities []string `json:"capabilities,omitempty"`
	// TerminalStateFormats lists opaque terminal-state encodings the client
	// can install atomically. Protocol 4 requires at least one format shared
	// with the Host; protocol 1 clients are rejected during authentication.
	TerminalStateFormats []string       `json:"terminalStateFormats,omitempty"`
	Method               string         `json:"method,omitempty"`
	Params               map[string]any `json:"params,omitempty"`
	Session              string         `json:"session,omitempty"`
	Workspace            string         `json:"workspace,omitempty"`
	Project              string         `json:"project,omitempty"`
	Command              string         `json:"command,omitempty"`
	Kind                 string         `json:"kind,omitempty"`
	Title                string         `json:"title,omitempty"`
	Data                 string         `json:"data,omitempty"`
	Cols                 int            `json:"cols,omitempty"`
	Rows                 int            `json:"rows,omitempty"`
	Epoch                uint64         `json:"epoch,omitempty"`
	Sequence             uint64         `json:"sequence,omitempty"`
}

type GhostlineMigration added in v0.9.0

type GhostlineMigration struct {
	SessionID       string            `json:"sessionId"`
	SourceSocket    string            `json:"sourceSocket"`
	TargetSocket    string            `json:"targetSocket"`
	SourceProtocol  string            `json:"sourceProtocol"`
	HandoffVersion  string            `json:"handoffVersion,omitempty"`
	Phase           string            `json:"phase"`
	SkippedSessions []string          `json:"skippedSessions,omitempty"`
	SkipReasons     map[string]string `json:"skipReasons,omitempty"`
	CreatedAt       time.Time         `json:"createdAt"`
	UpdatedAt       time.Time         `json:"updatedAt"`
}

GhostlineMigration records one rolling handoff. SessionID identifies this migration transaction, not a terminal session. Socket paths are local-only control-plane data; clients attach through Warren's current route.

type GitBranch

type GitBranch struct {
	Name   string `json:"name"`
	Remote bool   `json:"remote"`
}

type GitChange

type GitChange struct {
	Path       string `json:"path"`
	Status     string `json:"status"`
	Staged     bool   `json:"staged,omitempty"`
	RenameFrom string `json:"renameFrom,omitempty"`
	Added      int    `json:"added,omitempty"`
	Deleted    int    `json:"deleted,omitempty"`
}

type GitCommandResult

type GitCommandResult struct {
	Message string `json:"message"`
}

type GitCommit

type GitCommit struct {
	Hash    string      `json:"hash"`
	Short   string      `json:"short"`
	Subject string      `json:"subject"`
	Author  string      `json:"author"`
	Email   string      `json:"email,omitempty"`
	Time    time.Time   `json:"time"`
	Files   []GitChange `json:"files"`
}

type GitDiff

type GitDiff struct {
	Diff             string `json:"diff"`
	Content          string `json:"content"`
	DiffTruncated    bool   `json:"diffTruncated,omitempty"`
	ContentTruncated bool   `json:"contentTruncated,omitempty"`
}

type GitPanel

type GitPanel struct {
	WorkspaceID      string          `json:"workspace"`
	Branch           string          `json:"branch"`
	Upstream         string          `json:"upstream,omitempty"`
	Ahead            int             `json:"ahead,omitempty"`
	Behind           int             `json:"behind,omitempty"`
	AheadOfMain      int             `json:"aheadOfMain,omitempty"`
	Remote           string          `json:"remote,omitempty"`
	MainBranch       string          `json:"mainBranch,omitempty"`
	Merged           bool            `json:"merged,omitempty"`
	Operation        string          `json:"operation,omitempty"`
	Changes          []GitChange     `json:"changes"`
	Commits          []GitCommit     `json:"commits"`
	UnmergedCommits  []GitCommit     `json:"unmergedCommits,omitempty"`
	Branches         []GitBranch     `json:"branches"`
	PullRequest      *GitPullRequest `json:"pullRequest,omitempty"`
	PullRequestError string          `json:"pullRequestError,omitempty"`
	Refreshing       bool            `json:"refreshing,omitempty"`
}

GitPanel is the aggregated Git projection for one workspace.

type GitPullRequest

type GitPullRequest struct {
	Number int    `json:"number,omitempty"`
	Title  string `json:"title"`
	Body   string `json:"body,omitempty"`
	State  string `json:"state,omitempty"`
	Draft  bool   `json:"draft,omitempty"`
	URL    string `json:"url,omitempty"`
	Author string `json:"author,omitempty"`
	Base   string `json:"base,omitempty"`
	Head   string `json:"head,omitempty"`
}

GitPullRequest is a hosted pull request (GitHub PR or GitLab MR) for the workspace's current branch.

type HealthStatus added in v0.12.0

type HealthStatus struct {
	OK      bool   `json:"ok"`
	Ready   bool   `json:"ready"`
	Version string `json:"version,omitempty"`
	Build   string `json:"build,omitempty"`
	// Subsystem fields, in the order a probe should check them.
	Status HealthSubsystems `json:"status"`
}

HealthStatus is the typed readiness payload returned by GET /healthz. Clients should treat "ok" as "the daemon is responding" and "ready" as "every subsystem is currently in working order". The two flags are kept separate so a degraded but-running daemon can be observed without flipping menu bar / probe liveness lights.

type HealthSubsystems added in v0.12.0

type HealthSubsystems struct {
	// Store is "ready" when the durable state is loaded and queryable,
	// "unavailable" when the Service or its Store have not finished wiring.
	Store string `json:"store"`
	// Relay is the supervised outbound connector state. Configured is
	// independent of Connected: a host can be configured but disconnected
	// while the daemon retries.
	Relay RelayHealth `json:"relay"`
}

type Host

type Host struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	User    string `json:"user,omitempty"`
	OS      string `json:"os,omitempty"`
	Version string `json:"version"`
}

type MergeState

type MergeState string

MergeState describes whether a worktree branch still carries changes that are not present on the project's default branch. The zero value means "not applicable or not yet known"; clients only render the merged state.

const (
	MergeStateMerged   MergeState = "merged"
	MergeStateUnmerged MergeState = "unmerged"
)

type OperationAudit

type OperationAudit struct {
	ID                    string     `json:"id"`
	Kind                  string     `json:"kind"`
	Resource              string     `json:"resource"`
	ResourceID            string     `json:"resourceId"`
	BeforeWorkspaceID     string     `json:"beforeWorkspace,omitempty"`
	BeforeTerminalGroupID string     `json:"beforeTerminalGroup,omitempty"`
	AfterWorkspaceID      string     `json:"afterWorkspace,omitempty"`
	AfterTerminalGroupID  string     `json:"afterTerminalGroup,omitempty"`
	AgentSessionID        string     `json:"agentSessionId,omitempty"`
	RevertsOperationID    string     `json:"revertsOperationId,omitempty"`
	CreatedAt             time.Time  `json:"createdAt"`
	RevertedAt            *time.Time `json:"revertedAt,omitempty"`
}

OperationAudit records a reversible session move (or its reversal). The before/after ownership fields are compared during undo so an unrelated change can never be silently overwritten.

type Project

type Project struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Path string `json:"path"`
	// SetupScript is an optional executable path, relative to Path unless
	// absolute. It runs in newly created managed worktrees only.
	SetupScript string `json:"setupScript,omitempty"`
	// AutoImportGitWorktrees controls whether this project imports every
	// existing Git worktree when the project is added or the setting is enabled.
	// It is deliberately project-scoped; one repository's worktree policy must
	// not silently change another repository's import behavior.
	AutoImportGitWorktrees bool      `json:"autoImportGitWorktrees"`
	Pinned                 bool      `json:"pinned,omitempty"`
	Order                  int       `json:"order,omitempty"`
	CreatedAt              time.Time `json:"createdAt"`
}

type PublicAccessEnableRequest

type PublicAccessEnableRequest struct {
	PublicHostname *string `json:"publicHostname,omitempty"`
	PathPrefix     *string `json:"pathPrefix,omitempty"`
}

PublicAccessEnableRequest configures the Relay-owned public route. Relay allocates a safe hostname and path when both values are omitted.

type PublicAccessStatus

type PublicAccessStatus struct {
	RelayURL       string `json:"relayUrl,omitempty"`
	HostID         string `json:"hostId,omitempty"`
	RouteID        string `json:"routeId,omitempty"`
	PublicHostname string `json:"publicHostname,omitempty"`
	PathPrefix     string `json:"pathPrefix,omitempty"`
	AuthMode       string `json:"authMode,omitempty"`
	Enabled        bool   `json:"enabled"`
	Authenticated  bool   `json:"authenticated"`
	Running        bool   `json:"running"`
	PublicEndpoint string `json:"publicEndpoint,omitempty"`
	Error          string `json:"error,omitempty"`
}

PublicAccessStatus is the credential-free projection of the Relay-owned public route. The Host Secret and any Relay access capability are never included in this type.

type PublicAccessTestRequest

type PublicAccessTestRequest struct {
	PublicHostname *string `json:"publicHostname,omitempty"`
	PathPrefix     *string `json:"pathPrefix,omitempty"`
}

PublicAccessTestRequest validates Relay connectivity and route metadata without enabling the public route.

type RelayHealth added in v0.12.0

type RelayHealth struct {
	Configured bool   `json:"configured"`
	Connected  bool   `json:"connected"`
	State      string `json:"state"`
	LastError  string `json:"lastError,omitempty"`
}

RelayHealth describes the supervised outbound connector. State is one of unconfigured, disconnected, connected, or error. LastError is non-empty only when State is "error" or "disconnected" after the last reconnect attempt failed.

type Response

type Response struct {
	Type    string `json:"t"`
	ID      string `json:"id,omitempty"`
	OK      bool   `json:"ok"`
	Result  any    `json:"result,omitempty"`
	Error   string `json:"error,omitempty"`
	Code    string `json:"code,omitempty"`
	Details any    `json:"details,omitempty"`
}

type ScreenLayout added in v0.14.0

type ScreenLayout struct {
	Position  int          `json:"position"`
	PaneCount int          `json:"paneCount"`
	Panes     []ScreenPane `json:"panes"`
}

ScreenLayout is one client screen that displays the queried Session. Position is that Session's 1-based place among PaneCount panes.

type ScreenPane added in v0.14.0

type ScreenPane struct {
	Index     int    `json:"index"`
	SessionID string `json:"sessionId"`
	Title     string `json:"title,omitempty"`
	// Current marks the Session the query asked about.
	Current bool `json:"current,omitempty"`
}

ScreenPane is one Session displayed on a client screen, in the order that client reported its panes.

type ScreenPanesResult added in v0.14.0

type ScreenPanesResult struct {
	SessionID string         `json:"sessionId"`
	Screens   []ScreenLayout `json:"screens,omitempty"`
}

ScreenPanesResult answers "which Sessions share a screen with this one". Screen state belongs to each connected client, and several clients may display one Session at the same time, so the answer is a list of screens ordered most recently reported first. It is empty when no connected client reports the Session as visible.

type Session

type Session struct {
	ID          string `json:"id"`
	WorkspaceID string `json:"workspace,omitempty"`
	// TerminalGroupID is set for standalone shell Sessions. WorkspaceID and
	// TerminalGroupID are mutually exclusive ownership fields.
	TerminalGroupID string `json:"terminalGroup,omitempty"`
	// Scope is explicit for new clients and derived from the ownership fields
	// for legacy records that predate Terminal Groups.
	Scope string `json:"scope,omitempty"`
	// Title is the generated default label (kind or command name) fixed at
	// session creation; it never changes after a user renames the session.
	Title string `json:"title"`
	// CustomTitle is the user-set display name. When non-empty it takes
	// precedence over Title in every client that renders a session name.
	CustomTitle string `json:"customTitle,omitempty"`
	Kind        string `json:"kind"`
	// AgentHandler selects the transport implementation inside an agent
	// family (for example tui or acp). It is optional so legacy Sessions keep
	// the provider's default handler.
	AgentHandler string `json:"agentHandler,omitempty"`
	// AgentProvider is the stable provider family bound to this Session. It is
	// separate from AgentHandler so clients can render the provider before a
	// live handler has been rehydrated after a Host restart.
	AgentProvider string `json:"agentProvider,omitempty"`
	Command       string `json:"command,omitempty"`
	// Process, CommandLine, and Directory are live runtime metadata overlaid
	// on roster snapshots only; they are never persisted with the session
	// record. Directory comes from the shell's OSC 7 report; Process and
	// CommandLine come from the runtime's foreground probe.
	Process     string `json:"process,omitempty"`
	CommandLine string `json:"commandLine,omitempty"`
	Directory   string `json:"directory,omitempty"`
	Runtime     string `json:"runtime"`
	RuntimeKind string `json:"runtimeKind,omitempty"`
	Lifecycle   string `json:"lifecycle"`
	Epoch       uint64 `json:"epoch,omitempty"`
	Sequence    uint64 `json:"sequence,omitempty"`
	// OutputCursor is the opaque Ghostline v1 position immediately after the
	// output durably reflected by Epoch and Sequence. It is never exposed to
	// terminal clients and must not be synthesized from a byte offset.
	OutputCursor string `json:"outputCursor,omitempty"`
	Pinned       bool   `json:"pinned,omitempty"`
	// AgentSessionID is the provider's own conversation ID (Codex thread ID,
	// Claude session ID, or OpenCode SQLite session ID) bound to this Warren
	// session.
	AgentSessionID string `json:"agentSessionId,omitempty"`
	// AgentExecutionID is the Host-owned execution identity. It is stable for
	// one provider conversation and changes when the conversation is replaced.
	// Clients use it as the semantic event stream ID; provider IDs remain opaque
	// metadata and are never used as the primary event key.
	AgentExecutionID string `json:"agentExecutionId,omitempty"`
	// TranscriptPath is the JSONL transcript projected by the agent watcher.
	TranscriptPath string `json:"transcriptPath,omitempty"`
	// AgentStatus is the live activity and human-attention projection of an
	// agent session. It is overlaid on roster snapshots only and is never
	// persisted with the session record.
	AgentStatus *AgentStatus `json:"agentStatus,omitempty"`
	// AgentTurn is the latest explicit lifecycle boundary for an agent. Like
	// AgentStatus, it is overlaid on roster snapshots only so clients can
	// distinguish a completed turn from an initially-ready agent.
	AgentTurn *AgentTurn `json:"agentTurn,omitempty"`
	// AgentCapabilities is the effective capability set for this Session,
	// after provider and transport negotiation. It is live projection data and
	// is never persisted in the durable Session record. An explicit empty array
	// means this agent is known but currently exposes no optional controls.
	AgentCapabilities []string   `json:"agentCapabilities"`
	CreatedAt         time.Time  `json:"createdAt"`
	EndedAt           *time.Time `json:"endedAt,omitempty"`
	// OperationID is returned by mutating session APIs for audit and safe
	// undo. It is intentionally not persisted in the session record.
	OperationID string `json:"operationId,omitempty"`
	// ScreenPosition is this Session's 1-based place on the client screen that
	// displays it, out of ScreenPaneCount panes. Both are zero when no connected
	// client reports the Session as visible. The sibling Session IDs are
	// deliberately absent from the Session record: knowing you are pane 2 of 3
	// is presentation context for your own output, while learning what else the
	// user has on screen is a separate question with its own method,
	// `screen.panes`.
	ScreenPosition  int `json:"screenPosition,omitempty"`
	ScreenPaneCount int `json:"screenPaneCount,omitempty"`
}

func (Session) ScopeKind

func (session Session) ScopeKind() string

type SessionMovePreflight

type SessionMovePreflight struct {
	Allowed                    bool    `json:"allowed"`
	Session                    Session `json:"session"`
	SourceWorkspaceID          string  `json:"sourceWorkspace,omitempty"`
	SourceTerminalGroupID      string  `json:"sourceTerminalGroup,omitempty"`
	DestinationWorkspaceID     string  `json:"destinationWorkspace,omitempty"`
	DestinationTerminalGroupID string  `json:"destinationTerminalGroup,omitempty"`
	ExpectedWorkspaceID        string  `json:"expectedWorkspace,omitempty"`
	ExpectedAgentSessionID     string  `json:"expectedAgentSessionId,omitempty"`
}

SessionMovePreflight describes the exact source and destination checked by the Host before a move. It contains IDs and context only, never transcript contents.

type State

type State struct {
	Schema int `json:"schema"`
	// Revision is a transient, non-zero roster token used by streaming clients
	// to validate deltas. It is populated only in observer snapshots and is
	// never written into the durable state file.
	Revision       uint64          `json:"revision,omitempty"`
	Host           Host            `json:"host"`
	Tasks          []Task          `json:"tasks"`
	Projects       []Project       `json:"projects"`
	Workspaces     []Workspace     `json:"workspaces"`
	TerminalGroups []TerminalGroup `json:"terminalGroups"`
	Sessions       []Session       `json:"sessions"`
	// GhostlineMigration records the durable handoff journal used while a new
	// Ghostline server adopts sessions from the previous server.
	GhostlineMigration *GhostlineMigration `json:"ghostlineMigration,omitempty"`
	// Operations is the bounded mutation audit trail. Entries are only added
	// for operations that have a safe, compare-and-swap undo representation.
	Operations []OperationAudit `json:"operations,omitempty"`
	// WorktreeOwnershipMigrated records that legacy workspace ownership has
	// been reconciled against the configured Warren worktree root.
	WorktreeOwnershipMigrated bool   `json:"worktreeOwnershipMigrated,omitempty"`
	WarrenVersion             string `json:"warrenVersion,omitempty"`
}

type Task added in v0.11.2

type Task struct {
	ID                  string    `json:"id"`
	Name                string    `json:"name"`
	Source              string    `json:"source,omitempty"`
	ExternalID          string    `json:"externalID,omitempty"`
	URL                 string    `json:"url,omitempty"`
	CreationRequestID   string    `json:"creationRequestId,omitempty"`
	CreationRequestHash string    `json:"creationRequestHash,omitempty"`
	Pinned              bool      `json:"pinned,omitempty"`
	Order               int       `json:"order,omitempty"`
	CreatedAt           time.Time `json:"createdAt"`
}

type TerminalGroup

type TerminalGroup struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Home      string    `json:"home,omitempty"`
	Order     int       `json:"order,omitempty"`
	CreatedAt time.Time `json:"createdAt"`
}

type UsageBuckets added in v0.14.0

type UsageBuckets struct {
	FreshInput int64 `json:"freshInput"`
	CacheWrite int64 `json:"cacheWrite"`
	CacheRead  int64 `json:"cacheRead"`
	Output     int64 `json:"output"`
	// Reasoning is the reasoning subset of Output, for display only. It is
	// already billed inside Output.
	Reasoning int64 `json:"reasoning,omitempty"`
}

UsageBuckets is one aggregate's token counts, split into disjoint classes that each carry their own unit price. They sum to the real total, so no separate total field is carried.

func (UsageBuckets) Total added in v0.14.0

func (b UsageBuckets) Total() int64

Total is the real token count.

type UsageCost added in v0.14.0

type UsageCost struct {
	// NanoUSD is integer nanodollars, which keeps sums exact.
	NanoUSD int64 `json:"nanoUsd"`
	// Calls is how many billable model calls the amount covers.
	Calls int64 `json:"calls"`
	// PricedCalls is how many of those had a fully known price. Below Calls, the
	// amount is a lower bound and must be presented as one.
	PricedCalls int64 `json:"pricedCalls"`
	// UnmeasuredProviders names providers active in this range that report no
	// token counts at all, so their spend is missing from every figure here.
	UnmeasuredProviders []string `json:"unmeasuredProviders,omitempty"`
}

UsageCost is a money amount plus how completely it could be derived.

Completeness travels with every amount deliberately. A client that renders only NanoUSD would show a total that looks whole while omitting spend whose price is unknown, so the counts needed to say "at least" are part of the wire shape rather than something a client has to infer.

func (UsageCost) Complete added in v0.14.0

func (c UsageCost) Complete() bool

Complete reports whether every call in the amount was priced.

type UsageDayStats added in v0.14.0

type UsageDayStats struct {
	Day     string       `json:"day"`
	Buckets UsageBuckets `json:"buckets"`
	Cost    UsageCost    `json:"cost"`
}

UsageDayStats is one local day, for the heatmap and trend.

type UsageGroupStats added in v0.14.0

type UsageGroupStats struct {
	Key string `json:"key"`
	// Label carries a display name when the key alone is not presentable, such
	// as a project id. Empty when the key is already the label.
	Label   string       `json:"label,omitempty"`
	Buckets UsageBuckets `json:"buckets"`
	Cost    UsageCost    `json:"cost"`
}

UsageGroupStats is one aggregate along a single dimension. Key is the provider id, normalized model id, or project id depending on which list it appears in; an empty key means unattributed.

type UsageIntervalStats added in v0.14.0

type UsageIntervalStats struct {
	Day     string       `json:"day"`
	Minute  int          `json:"minute"`
	Buckets UsageBuckets `json:"buckets"`
	Cost    UsageCost    `json:"cost"`
}

UsageIntervalStats is one local-day intraday bucket. Minute is the start of the bucket measured from local midnight (for example, 10:30 is 630). Keeping the day and minute separate avoids converting a Host-local bucket through a client's timezone and moving a point to the wrong calendar day.

type UsageRebuildResult added in v0.14.0

type UsageRebuildResult struct {
	Rebuilt bool  `json:"rebuilt"`
	Events  int64 `json:"events"`
	Calls   int64 `json:"calls"`
	Days    int64 `json:"days"`
}

UsageRebuildResult is returned by the explicit Usage maintenance action. Rebuilding replaces only derived Usage projections; the canonical Agent journal remains the source of truth and is never deleted.

type UsageStatsRequest added in v0.14.0

type UsageStatsRequest struct {
	FromDay string `json:"fromDay,omitempty"`
	ToDay   string `json:"toDay,omitempty"`
	// IntervalDay narrows the intraday payload to one local day. Clients show a
	// single day's curve at a time, so sending the whole range's five-minute
	// buckets would move data that is never drawn. Empty means "the most recent
	// day that has intraday data", which is what the client shows before the
	// person picks a day.
	IntervalDay string `json:"intervalDay,omitempty"`
}

UsageStatsRequest selects a local-day range of token accounting. Both bounds are YYYY-MM-DD in the Host's local time, inclusive, and an empty bound is unconstrained.

The range is expressed in days rather than instants because that is the grain the Host stores. A day is the Host's local day: the heatmap cell has to mean the day the person remembers working, and bucketing in UTC would shift every historical cell whenever the Host's timezone changed.

type UsageStatsResult added in v0.14.0

type UsageStatsResult struct {
	FromDay string `json:"fromDay"`
	ToDay   string `json:"toDay"`
	// Total is the range's aggregate across every dimension.
	Total UsageBuckets    `json:"total"`
	Cost  UsageCost       `json:"cost"`
	Days  []UsageDayStats `json:"days"`
	// DetailDay is the local day the intraday payload describes. When the
	// request named no IntervalDay this is the most recent day with data, so the
	// client can label the curve without a second round trip.
	DetailDay string `json:"detailDay,omitempty"`
	// Intervals are the canonical 5-minute buckets for DetailDay. Clients may
	// merge adjacent buckets for a coarser display without another Host request.
	Intervals             []UsageIntervalStats `json:"intervals"`
	IntervalBucketMinutes int                  `json:"intervalBucketMinutes"`
	Providers             []UsageGroupStats    `json:"providers"`
	Models                []UsageGroupStats    `json:"models"`
	Projects              []UsageGroupStats    `json:"projects"`
	// DayProviders, DayModels, and DayProjects break DetailDay down by the same
	// dimensions as the range, so selecting a day answers "what cost this day"
	// without shipping per-day rows for every day in the range.
	DayProviders []UsageGroupStats `json:"dayProviders,omitempty"`
	DayModels    []UsageGroupStats `json:"dayModels,omitempty"`
	DayProjects  []UsageGroupStats `json:"dayProjects,omitempty"`
	// PricesFetchedAt is when the unit prices behind Cost were retrieved. Zero
	// means no price table was available and every amount is zero.
	PricesFetchedAt string `json:"pricesFetchedAt,omitempty"`
}

UsageStatsResult is the whole panel payload for one range.

The Host aggregates rather than shipping rows for the client to fold, because a client's event replica is a bounded cache and summing it would under-report. Rates such as cache hit rate are intentionally absent: they are derived from these additive counts at render time, which keeps one definition of each rate.

type WelcomeMessage added in v0.12.0

type WelcomeMessage struct {
	Type          string   `json:"t"`
	Version       string   `json:"version"`
	Host          Host     `json:"host"`
	AccessScopeID string   `json:"accessScopeId"`
	Capabilities  []string `json:"capabilities"`
}

WelcomeMessage is emitted after authentication and is the only source of identity used by a client replica namespace.

type Workspace

type Workspace struct {
	ID                  string `json:"id"`
	ProjectID           string `json:"project"`
	TaskID              string `json:"task,omitempty"`
	Name                string `json:"name"`
	Path                string `json:"path"`
	Branch              string `json:"branch,omitempty"`
	Kind                string `json:"kind"`
	CreationRequestID   string `json:"creationRequestId,omitempty"`
	CreationRequestHash string `json:"creationRequestHash,omitempty"`
	// ManagedWorktree is true only for Git worktrees created by Warren. An
	// imported checkout remains on disk when its Warren record is removed.
	ManagedWorktree bool `json:"managedWorktree,omitempty"`
	// WorktreeLocked mirrors Git's lock marker. Locked worktrees are never
	// removed automatically, even when a caller asks to remove the directory.
	WorktreeLocked bool      `json:"worktreeLocked,omitempty"`
	Pinned         bool      `json:"pinned,omitempty"`
	Order          int       `json:"order,omitempty"`
	CreatedAt      time.Time `json:"createdAt"`
	// MergeState is the live merge projection of the workspace branch against
	// the project's default branch. It is overlaid on roster snapshots only
	// and is never persisted with the workspace record.
	MergeState MergeState `json:"mergeState,omitempty"`
}

type WorkspaceCreateResult

type WorkspaceCreateResult struct {
	Workspace
	Created     bool `json:"created"`
	GitWorktree bool `json:"gitWorktree"`
}

WorkspaceCreateResult reports a created workspace together with side effects the caller needs to know: whether the Warren record was created and whether a Git worktree was actually created on disk.

type WorktreeCandidate

type WorktreeCandidate struct {
	Path        string `json:"path"`
	Name        string `json:"name"`
	Branch      string `json:"branch,omitempty"`
	Locked      bool   `json:"locked,omitempty"`
	Imported    bool   `json:"imported"`
	WorkspaceID string `json:"workspace,omitempty"`
}

WorktreeCandidate describes an existing Git worktree that can be imported into a Project. Imported candidates remain in the list so clients can show them as disabled instead of hiding the one-time import state.

Jump to

Keyboard shortcuts

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