Documentation
¶
Index ¶
- Constants
- type AgentActivity
- type AgentAttention
- type AgentAttentionKind
- type AgentEvent
- type AgentHistoryResult
- type AgentMessage
- type AgentSnapshotResult
- type AgentStatus
- type AgentStatusMessage
- type AgentSubscriptionResult
- type AgentTurn
- type AgentTurnMessage
- type AgentTurnStatus
- type AgentUsage
- type AgentWaitResult
- type Envelope
- type GitBranch
- type GitChange
- type GitCommandResult
- type GitCommit
- type GitDiff
- type GitPanel
- type GitPullRequest
- type Host
- type MergeState
- type OperationAudit
- type Project
- type PublicAccessEnableRequest
- type PublicAccessStatus
- type PublicAccessTestRequest
- type Response
- type Session
- type SessionMovePreflight
- type State
- type TerminalGroup
- type Workspace
- type WorkspaceCreateResult
- type WorktreeCandidate
Constants ¶
const ( SessionScopeWorkspace = "workspace" SessionScopeTerminalGroup = "terminalGroup" )
const Version = "1.0"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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 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 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"`
Role string `json:"role,omitempty"`
Content string `json:"content,omitempty"`
Model string `json:"model,omitempty"`
StopReason string `json:"stopReason,omitempty"`
ToolName string `json:"toolName,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"`
}
AgentEvent is one normalized message or tool transition from a Codex or Claude transcript. It is a projection of the TUI process's own JSONL log; the terminal byte stream remains the source of truth for rendering.
type AgentHistoryResult ¶
type AgentHistoryResult struct {
Epoch uint64 `json:"epoch,omitempty"`
Events []AgentEvent `json:"events"`
Cursor uint64 `json:"cursor,omitempty"`
HasMore bool `json:"hasMore"`
}
AgentHistoryResult is one page of the agent event history. Cursor is the sequence of the first event in the page and can be passed back as `before` to load the previous page; HasMore reports whether older events exist.
type AgentMessage ¶
type AgentMessage struct {
Type string `json:"t"`
Session string `json:"session"`
// Epoch identifies one Host process's agent projection. Clients reset
// their event history when the epoch changes after a daemon restart.
Epoch uint64 `json:"epoch,omitempty"`
Events []AgentEvent `json:"events"`
}
AgentMessage carries a live batch of normalized agent events for one session. Batches are bounded so a single WebSocket message stays well below client message-size limits; full history is fetched separately via the agent.history request.
type AgentSnapshotResult ¶
type AgentSnapshotResult struct {
Epoch uint64 `json:"epoch"`
Turn AgentTurn `json:"turn"`
Sequence uint64 `json:"sequence"`
}
AgentSnapshotResult is the subscription baseline used before a caller sends input or starts waiting. Event sequence is included for diagnostics.
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 AgentStatusMessage ¶
type AgentStatusMessage struct {
Type string `json:"t"`
Session string `json:"session"`
Epoch uint64 `json:"epoch,omitempty"`
Status AgentStatus `json:"status"`
}
AgentStatusMessage is the lightweight live status update for one session. It is deliberately a small standalone message so clients that only render the status light never have to receive full event batches.
type AgentSubscriptionResult ¶
type AgentSubscriptionResult struct {
Session Session `json:"session"`
Snapshot AgentSnapshotResult `json:"snapshot"`
}
AgentSubscriptionResult binds a read-only subscriber to a session and returns the turn baseline established before live boundaries can interleave.
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 AgentTurnMessage ¶
type AgentTurnMessage struct {
Type string `json:"t"`
Session string `json:"session"`
Epoch uint64 `json:"epoch,omitempty"`
Turn uint64 `json:"turn"`
Status AgentTurnStatus `json:"status"`
}
AgentTurnMessage carries explicit turn boundaries for blocking clients. Activity remains presentation state; callers must use this message instead of treating the ambiguous ready state as proof that a new turn completed.
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.
const ( AgentTurnIdle AgentTurnStatus = "idle" AgentTurnStarted AgentTurnStatus = "started" AgentTurnCompleted AgentTurnStatus = "completed" AgentTurnFailed AgentTurnStatus = "failed" AgentTurnAborted AgentTurnStatus = "aborted" )
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"`
Epoch uint64 `json:"epoch"`
Turn uint64 `json:"turn"`
Status AgentTurnStatus `json:"status"`
Events []AgentEvent `json:"events"`
}
AgentWaitResult is printed by the blocking CLI once a turn reaches a terminal state.
type Envelope ¶
type Envelope struct {
Type string `json:"t"`
ID string `json:"id,omitempty"`
Token string `json:"token,omitempty"`
Version string `json:"version,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 GitCommandResult ¶
type GitCommandResult struct {
Message string `json:"message"`
}
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 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"`
// 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 {
// A nil EdgeURL keeps the existing configured override. An explicit empty
// string clears that override and selects the release/launcher default.
EdgeURL *string `json:"edgeUrl,omitempty"`
AccountName *string `json:"accountName,omitempty"`
InviteKey string `json:"inviteKey,omitempty"`
ApprovalKey string `json:"approvalKey,omitempty"`
EnrollmentKey string `json:"enrollmentKey,omitempty"`
}
PublicAccessEnableRequest contains the one-time bootstrap input for a self-hosted gnar Edge. InviteKey and ApprovalKey are consumed in memory and are never persisted or included in a URL or command-line argument. ApprovalKey takes precedence when both are supplied. EnrollmentKey remains as a deprecated approval-key alias for older clients.
type PublicAccessStatus ¶
type PublicAccessStatus struct {
// EdgeURL is the effective Edge currently selected after applying the
// release default, launcher override, and user override.
EdgeURL string `json:"edgeUrl"`
// ConfiguredEdgeURL is the user's persisted override. It is empty when the
// release/launcher default is in use.
ConfiguredEdgeURL string `json:"configuredEdgeUrl"`
// DefaultEdgeURL is the non-secret fallback shipped by the release or
// supplied by the launcher.
DefaultEdgeURL string `json:"defaultEdgeUrl"`
UsingDefaultEdge bool `json:"usingDefaultEdge"`
// AccountName is the effective non-secret account label, including the
// system-name default used when no override is configured.
AccountName string `json:"accountName"`
ConfiguredAccountName string `json:"configuredAccountName,omitempty"`
UsingDefaultAccount bool `json:"usingDefaultAccount"`
Enabled bool `json:"enabled"`
// Authenticated reports that Warren has completed a gnar login or a
// successful token-backed connection test in this daemon lifetime. It is a
// credential-free presentation hint; gnar remains the source of truth for
// its persisted account token.
Authenticated bool `json:"authenticated"`
Running bool `json:"running"`
PublicEndpoint string `json:"publicEndpoint"`
Error string `json:"error"`
}
PublicAccessStatus is the credential-free projection of the self-hosted gnar Edge lifecycle. Invite/Approval Keys, gnar account tokens, and the Warren daemon token are deliberately absent from this type.
type PublicAccessTestRequest ¶
type PublicAccessTestRequest struct {
EdgeURL *string `json:"edgeUrl,omitempty"`
AccountName *string `json:"accountName,omitempty"`
InviteKey string `json:"inviteKey,omitempty"`
ApprovalKey string `json:"approvalKey,omitempty"`
EnrollmentKey string `json:"enrollmentKey,omitempty"`
}
PublicAccessTestRequest saves the non-secret Public Access configuration and verifies the gnar Edge connection. Keys are bootstrap-only and are consumed from memory; they are never persisted or returned.
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"`
Command string `json:"command,omitempty"`
// Process and Directory are live runtime metadata overlaid on roster
// snapshots only; they are never persisted with the session record.
Process string `json:"process,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"`
Pinned bool `json:"pinned,omitempty"`
// AgentSessionID is the CLI's own conversation ID (Codex thread ID or
// Claude session ID) bound to this Warren session.
AgentSessionID string `json:"agentSessionId,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"`
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"`
}
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"`
Host Host `json:"host"`
Projects []Project `json:"projects"`
Workspaces []Workspace `json:"workspaces"`
TerminalGroups []TerminalGroup `json:"terminalGroups"`
Sessions []Session `json:"sessions"`
// 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"`
}
type TerminalGroup ¶
type Workspace ¶
type Workspace struct {
ID string `json:"id"`
ProjectID string `json:"project"`
Name string `json:"name"`
Path string `json:"path"`
Branch string `json:"branch,omitempty"`
Kind string `json:"kind"`
// 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.