wire

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package wire is the message envelope and codec shared by every stagent connection: app ↔ bridge (over the SSH exec channel) and the local IPC links (holder, daemon, hook, bridge). One JSON object per line.

Index

Constants

View Source
const (
	ErrBadRequest    = "bad_request"
	ErrUnknownMethod = "unknown_method"
	ErrNotFound      = "not_found"
	ErrUnsupported   = "unsupported"
	ErrInternal      = "internal"
	ErrUnavailable   = "unavailable"
	ErrVersion       = "version_mismatch"
	ErrSessionEnded  = "session_ended"
	ErrNotSizeOwner  = "not_size_owner"
	ErrNotConfigured = "not_configured"
	// ErrAgentRefused: the connection comes from a coding agent's process
	// tree or, on macOS, a sandbox (ADR 0004); the holder refuses every
	// method, the daemon the ones that change settings or stop it.
	ErrAgentRefused = "agent_refused"
	// ErrMenuOpen: session.input with paste and submit was not written
	// because a menu (an approval or any other) is on the screen.
	ErrMenuOpen = "menu_open"
	// ErrForeignOwner: the stagent location (socket, run directory, named
	// pipe) belongs to another user; nothing was sent to it.
	ErrForeignOwner = "foreign_owner"
	// ErrNotClean: task.remove found uncommitted changes and force was
	// not given.
	ErrNotClean = "not_clean"
	// ErrBusy: task.remove found live sessions of the task it was not
	// asked to stop, or could not stop them.
	// schedule.run_now: the schedule's previous run is still running;
	// schedule.remove: its running run did not stop. stopped.resume
	// (stopped.claim): another resume of the stopped agent is starting.
	ErrBusy = "busy"
	// ErrRefused: task.remove or worktree.remove found a refusal reason
	// (RemoveRefusal), which neither force nor stop_sessions overrides;
	// the message names it.
	ErrRefused = "refused"
	// ErrInUse: another number's in_place task uses that source checkout.
	ErrInUse = "in_use"
	// ErrPasteByHand: host_screen.input could not paste a text into an
	// iOS simulator (its edit menu's Paste was not found); the text is on
	// the simulator's clipboard for the user to paste.
	ErrPasteByHand = "paste_by_hand"
	// ErrRepoMissing: relay.start found no source checkout whose remote
	// is the package's remote_url (and was given neither repo nor clone).
	ErrRepoMissing = "repo_missing"
	// ErrTooLarge: relay.prepare's package would pass RelayPackageMax.
	ErrTooLarge = "too_large"
)

Stable error codes.

View Source
const (
	MethodGitHubRepos    = "github.repos"
	MethodGitHubActivity = "github.activity"
	MethodGitHubStatus   = "github.status"

	// CapGitHub (Windows only): the github.* methods.
	CapGitHub = "github"
)
View Source
const (
	GHReady           = "ready"
	GHMissing         = "missing"
	GHUnauthenticated = "unauthenticated"
)

gh states of GitHubActivityResult.

View Source
const (
	GitHubKindIssue = "issue"
	GitHubKindPR    = "pr"
)

Kinds of github.status items.

View Source
const (
	MethodHostScreenList   = "host_screen.list"
	MethodHostScreenStart  = "host_screen.start"
	MethodHostScreenAck    = "host_screen.ack"
	MethodHostScreenPause  = "host_screen.pause"
	MethodHostScreenResume = "host_screen.resume"
	MethodHostScreenStop   = "host_screen.stop"
	MethodHostScreenInput  = "host_screen.input"

	NotifyHostScreenFrame = "host_screen.frame" // HostScreenFrame
	NotifyHostScreenState = "host_screen.state" // HostScreenState
)
View Source
const (
	HostScreenBrowser = "browser"
	HostScreenAndroid = "android"
	HostScreenIOS     = "ios"
)

Target kinds of HostScreenTarget and keys of host_screen.list's result.

View Source
const (
	HostScreenLive = "live"
	HostScreenGone = "gone"
)

host_screen.state values.

View Source
const (
	ToolAgentBrowser      = "agent-browser"
	ToolPlaywrightMCP     = "playwright-mcp"
	ToolChromeDevToolsMCP = "chrome-devtools-mcp"
	ToolPlaywright        = "playwright"
)

Tool names of HostScreenBrowserItem, told apart by the profile path.

View Source
const (
	// MissingXcodeNotFound: xcrun cannot find simctl (no Xcode selected).
	MissingXcodeNotFound = "xcode_not_found"
	// MissingSimctlFailed: simctl is there but failed (its error is the
	// message), e.g. Xcode's license is not accepted yet.
	MissingSimctlFailed = "simctl_failed"
	// ReasonCompanionNotFound: idb_companion, which shows a simulator, is
	// not installed.
	ReasonCompanionNotFound = "companion_not_found"
)

Codes of HostScreenMissing and reasons of HostScreenSimulatorItem.

View Source
const (
	// HostScreenADBNotFound is the android section's missing code: adb is
	// not installed.
	HostScreenADBNotFound = "adb_not_found"
	// HostScreenNoGRPC is the reason of an emulator without a gRPC port
	// (started with -port only, say).
	HostScreenNoGRPC = "no_grpc"
)

Codes and reasons of the android section.

View Source
const (
	InputTap      = "tap"
	InputDrag     = "drag"
	InputScroll   = "scroll"
	InputText     = "text"
	InputKey      = "key"
	InputNavigate = "navigate"
)

HostScreenInput types (host_screen.input's type).

View Source
const (
	KeyBack    = "back"
	KeyHome    = "home"
	KeyRecents = "recents"
)

HostScreenInput keys (type key): Android's and iOS's buttons.

View Source
const (
	NavigateBack    = "back"
	NavigateForward = "forward"
	NavigateReload  = "reload"
	NavigateURL     = "url"
)

HostScreenInput actions (type navigate): a browser's.

View Source
const (
	// InputViaCmdV: pasted with ⌘V into an app allowed to paste from other
	// apps; keys wait about 3 s after it.
	InputViaCmdV = "cmd_v"
	// InputViaEditMenu: pasted by tapping the edit menu's Paste at the
	// cursor; the app is not allowed to paste from other apps.
	InputViaEditMenu = "edit_menu"
	// InputViaKeys: typed as keys (ASCII only), after the 英数 key.
	InputViaKeys = "keys"
)

HostScreenInput vias (HostScreenInputResult.Via): how an iOS simulator took a text (#649).

View Source
const (
	MethodHello = "hello"
	MethodPing  = "ping"

	// Served by the holder (bridge forwards to Layout.HolderAddr(id)).
	MethodSessionAttach     = "session.attach"
	MethodSessionDetach     = "session.detach"
	MethodSessionInput      = "session.input"
	MethodSessionResize     = "session.resize"
	MethodSessionScrollback = "session.scrollback"
	MethodSessionSignal     = "session.signal"
	MethodSessionInfo       = "session.info"

	// Served by the bridge itself (spawns a detached holder).
	MethodSessionSpawn = "session.spawn"

	// Served by the daemon.
	MethodWatch                 = "watch"
	MethodSessionsList          = "sessions.list"
	MethodConversationsList     = "conversations.list"
	MethodTranscriptGet         = "transcript.get"
	MethodTranscriptSubscribe   = "transcript.subscribe"
	MethodTranscriptUnsubscribe = "transcript.unsubscribe"
	MethodApprovalsList         = "approvals.list"
	MethodConfigGet             = "config.get"
	MethodConfigSet             = "config.set"
	MethodNotifyTest            = "notify.test"
	MethodPresenceSet           = "presence.set"

	// Notifications (server → app).
	NotifyEvent          = "event"           // Event
	NotifySessionUpdated = "session.updated" // Session
	NotifySessionRemoved = "session.removed" // SessionRef
	NotifyOutput         = "output"          // OutputParams
	NotifyResize         = "resize"          // ResizeParams
	NotifyClosed         = "closed"          // ClosedParams
	NotifyTranscript     = "transcript"      // TranscriptParams
	// NotifyUnwrappedUpdated carries the whole current list.
	NotifyUnwrappedUpdated = "unwrapped.updated" // UnwrappedUpdatedParams
)
View Source
const (
	CapScreenMode = "screen_mode" // session.attach mode "screen"
	CapSpawn      = "spawn"
	CapHooks      = "hooks" // approvals / hook-derived state
	CapTranscript = "transcript"
	CapPush       = "push" // ntfy / webhook
	// CapPushChat: notify.chat (Discord, Slack, Telegram) and notify.test
	// channels. Older stagent versions store notify.chat without sending.
	CapPushChat = "push_chat"
	// CapPersist: session.spawn shell, attach resume (since/offset/end),
	// signal hangup, runtime mode changes (handoff).
	CapPersist = "persist"
	// CapPersistShell (Windows only): session.spawn shell works there.
	// Windows bridges before it announced CapPersist but refused shells.
	CapPersistShell = "persist_shell"
)

Capabilities advertised in HelloResult.

View Source
const (
	AttachRaw    = "raw"    // PTY bytes as produced, resynced by snapshot on overflow
	AttachScreen = "screen" // ANSI diffs of changed rows, at most FPS per second
)

Attach modes.

View Source
const (
	SignalInterrupt = "interrupt" // Ctrl-C to the PTY
	SignalTerminate = "terminate" // SIGTERM; Windows: ^C, TerminateProcess after 3 s
	SignalKill      = "kill"      // SIGKILL / TerminateProcess
	SignalHangup    = "hangup"    // SIGHUP, as when a terminal closes; Windows: like terminate
)

Signals for session.signal.

View Source
const (
	// holder → daemon (persistent connection opened by the holder)
	MethodHolderRegister = "holder.register" // Session → HolderRegisterResult
	MethodHolderUpdate   = "holder.update"   // notification, SessionPatch
	MethodHolderNotify   = "holder.notify"   // notification, HolderNotifyParams
	MethodHolderEnded    = "holder.ended"    // notification, ClosedParams
	// notification, HolderPromptGoneParams: the claude or Codex permission
	// menu the daemon asked to watch for (holder.prompt_watch) left the
	// screen.
	MethodHolderPromptGone = "holder.prompt_gone"
	// notification, HolderPromptGoneParams (since 0.20.0): the question UI
	// the daemon asked to watch for (holder.question_watch) left the
	// screen: the question was answered or cancelled there.
	MethodHolderQuestionGone = "holder.question_gone"
	// notification, HolderPromptGoneParams: the permission menu a watch
	// started with shown (HolderPromptWatchParams.Shown) looks for came on
	// the screen. Its watch goes on, to report when it leaves.
	MethodHolderPromptShown = "holder.prompt_shown"

	// hook → daemon (one request per connection)
	// Answers {} once the daemon applied the event; a PermissionRequest of a
	// claude running in a stagent session is answered only when its approval
	// closes (the hook stays open until then, with no decision), except one
	// naming its question tool, which is answered at once.
	MethodHookEvent = "hook.event" // HookEventParams → {}

	// bridge → daemon (since 0.21.1), SessionEndParams → {}: end a session
	// its holder does not answer for — its socket is gone, nothing accepts
	// on it, or the holder went away or stayed silent on session.signal.
	// The daemon signals the session's program (and kills it and the
	// holder when they outlast the grace) and records the end; a session it
	// does not list as live is already over. Refused to coding agents'
	// process trees.
	MethodSessionEnd = "session.end"

	// install / doctor → daemon
	MethodDaemonStatus   = "daemon.status"   // → DaemonStatus
	MethodDaemonShutdown = "daemon.shutdown" // → {}
	// daemon → holder notification sent before a deliberate shutdown
	// (daemon.shutdown, SIGTERM): holders keep retrying but stop
	// auto-starting the daemon, so `uninstall --level stop` sticks.
	MethodDaemonStopping = "daemon.stopping"
	// daemon → holder notification, HolderPromptWatchParams: watch the
	// screen for the permission menu while an approval of the session from
	// a harness whose menu is watched is pending (on), or while such a
	// harness checks a tool call's permission and may show its menu with
	// no hook (Shown), or stop (off). Holders before 0.4.0 ignore it, like
	// any notification they do not know; 0.5.0 and earlier know only
	// claude's menu, 0.15.0 and earlier no Copilot CLI menu, 0.21.1 and
	// earlier no Qwen Code menu, 0.22.1 and earlier neither Antigravity
	// CLI's menu nor Shown.
	MethodHolderPromptWatch = "holder.prompt_watch"
	// daemon → holder notification, HolderPromptWatchParams (since
	// 0.20.0): watch the screen for the question UI of the harness while a
	// question of the session is in force (on), or stop (off); Gen names
	// the watch (one per question in force). Holders before 0.20.0 ignore
	// it: their sessions' questions go with the next hook only.
	MethodHolderQuestionWatch = "holder.question_watch"

	// `stagent explain --session` → holder, ScreenExplainParams →
	// ScreenExplain: the holder reads its screen with the screen rules it
	// started with and says which of them matched. Holders that predate it
	// answer unknown_method.
	MethodSessionExplain = "session.explain"
)
View Source
const (
	// CheckMenu: a menu of any harness, on which a chat message is
	// refused (menu_open).
	CheckMenu = "menu"
	// CheckPermission: the permission menu a prompt watch looks for.
	CheckPermission = "permission"
	// CheckQuestion: the question UI a question watch looks for.
	CheckQuestion = "question"
)

Checks of ScreenCheck.

View Source
const (
	// Served by the bridge (queue "relay"), refused to coding agents'
	// process trees (ADR 0004): build the package of a conversation
	// (RelayPrepareParams → RelayPrepareResult), with relay.progress
	// notifications while it runs.
	MethodRelayPrepare = "relay.prepare"
	// Served by the bridge (queue "relay"), refused to coding agents'
	// process trees: one chunk of a prepared package (RelayReadParams →
	// RelayReadResult).
	MethodRelayRead = "relay.read"
	// Served by the bridge at once (no queue), refused to coding agents'
	// process trees: remove what a relay left on this host but a started
	// relay's document (RelayRef → {}); cancels a relay.prepare of it
	// still running. Idempotent.
	MethodRelayDiscard = "relay.discard"
	// Served by the bridge (queue "relay"), refused to coding agents'
	// process trees: get ready to take a package, or say how much of it
	// is here already (RelayReceiveParams → RelayReceiveResult).
	MethodRelayReceive = "relay.receive"
	// Served by the bridge (queue "relay"), refused to coding agents'
	// process trees: write one chunk of a package (RelayWriteParams →
	// RelayWriteResult).
	MethodRelayWrite = "relay.write"
	// Served by the bridge (queue "relay"; its session through the spawn
	// queue), refused to coding agents' process trees: unpack the
	// package, prepare the place to work and start the agent
	// (RelayStartParams → RelayStartResult), with relay.progress
	// notifications while it runs.
	MethodRelayStart = "relay.start"
	// Served by the bridge (queue "relay"), refused to coding agents'
	// process trees: undo a relay.start that failed (RelayRef → {}).
	MethodRelayAbort = "relay.abort"
	// Served by the daemon (the bridge forwards it; the bridge's
	// relay.start calls it too), refused to coding agents' process trees:
	// record one end of a relay's trace (RelayRecordParams → {}).
	MethodRelayRecord = "relay.record"
	// MethodRelayForget (bridge → daemon only, never forwarded from the app;
	// refused to coding agents' process trees): forget the trace this daemon
	// recorded for a relay (RelayRef → {}); relay.abort calls it. Unknown: {}.
	MethodRelayForget = "relay.forget"

	// NotifyRelayProgress (bridge → app, on the connection that sent the
	// request): a stage of relay.prepare or relay.start began or moved
	// on (RelayProgressParams).
	NotifyRelayProgress = "relay.progress"
)

Relay methods.

View Source
const (
	// RelayTargetSameHost: the target is this host; relay.start takes the
	// package on the same host, nothing is read or written.
	RelayTargetSameHost = "same_host"
	// RelayTargetOtherHost: the client carries the package to another
	// host's stagent.
	RelayTargetOtherHost = "other_host"
)

Where the relay target is (RelayPrepareParams.Target).

View Source
const (
	RelaySourceKeep = "keep" // keeps running
	RelaySourceEnd  = "end"  // will be ended
)

What becomes of the source agent (RelayPrepareParams.SourceAgent). The client ends it itself (session.signal hangup) once the target is up.

View Source
const (
	RelayStageTranscript = "transcript" // reading the conversation, writing the document
	RelayStageMemo       = "memo"       // waiting for the source agent's hand-off memo
	RelayStageBundle     = "bundle"     // git bundle of the commits no remote has
	RelayStageDiff       = "diff"       // the uncommitted changes (staged, unstaged)
	RelayStageUntracked  = "untracked"  // the untracked files
	RelayStagePack       = "pack"       // writing the package

	RelayStageReceive = "receive" // relay.receive / relay.write
	RelayStageUnpack  = "unpack"  // checking and unpacking the package
	RelayStageRepo    = "repo"    // finding the source checkout
	RelayStageClone   = "clone"   // cloning the remote (RelayStartParams.Clone)
	RelayStageTask    = "task"    // registering the task, starting its session
	RelayStageSpawn   = "spawn"   // starting the agent's session (no task)
)

Stages of relay.prepare (relay source) and relay.start (relay target): relay.progress names them, and an error of either method starts with the stage it failed at and ": ". The stages a relay target's task goes through after its session started are Task.Stage (TaskStage*, with TaskStageRelay).

View Source
const (
	RelayMemoIncluded = "included" // the memo is in the package
	RelayMemoTimeout  = "timeout"  // the agent did not finish within the limit; not included
	RelayMemoSkipped  = "skipped"  // not asked for (RelayMemo.Reason)
)

Memo states (RelayMemo.Status).

View Source
const (
	RelayMemoNotLive = "not_live" // the conversation has no live session
	RelayMemoBusy    = "busy"     // the agent was not idle: working, an approval or a question
)

Why no memo was asked for (RelayMemo.Reason).

View Source
const (
	RelayRoleSource = "source" // it was relayed to Peer
	RelayRoleTarget = "target" // it was relayed from Peer
)

Roles of a relay's end (RelayRecordParams.Role): what the conversation on the recording host is.

View Source
const (
	// RelayPackageMax bounds a package (relay.prepare: too_large).
	RelayPackageMax = 512 << 20
	// RelayChunkDefault and RelayChunkMax bound one relay.read chunk;
	// relay.write takes chunks up to RelayChunkMax.
	RelayChunkDefault = 1 << 20
	RelayChunkMax     = 4 << 20
	// RelayToolTextMax bounds one tool call's input and one tool output
	// in the document: longer ones keep their first RelayToolTextHead
	// bytes and their last RelayToolTextMax-RelayToolTextHead.
	RelayToolTextMax  = 8 << 10
	RelayToolTextHead = 6 << 10
	// RelayLastTurns is how many of the last turns the document's summary
	// repeats.
	RelayLastTurns = 3
	// RelayMemoTimeoutDefault and RelayMemoTimeoutMax bound the wait for
	// the hand-off memo, in ms.
	RelayMemoTimeoutDefault = 300_000
	RelayMemoTimeoutMax     = 900_000
)

Limits of a relay (PROTOCOL.md "Relay").

View Source
const (
	// EnvRelayDocument is the absolute path of the relay document.
	EnvRelayDocument = "STAGENT_RELAY_DOCUMENT"
	// EnvRelayID is the relay's id.
	EnvRelayID = "STAGENT_RELAY_ID"
)

Environment variables of a relay target's agent session.

View Source
const (
	MethodScheduleList   = "schedule.list"   // {} → ScheduleListResult
	MethodScheduleCreate = "schedule.create" // ScheduleCreateParams → ScheduleEntry; refused to coding agents
	MethodScheduleRuns   = "schedule.runs"   // ScheduleRunsParams → ScheduleRunsResult
	// schedule.preview: what a schedule would run and when, without
	// saving it (ScheduleCreateParams → SchedulePreview).
	MethodSchedulePreview = "schedule.preview"
	// schedule.update, schedule.remove, schedule.pause, schedule.resume
	// and schedule.run_now change a schedule; all are refused to coding
	// agents.
	MethodScheduleUpdate = "schedule.update"  // ScheduleUpdateParams → ScheduleEntry
	MethodScheduleRemove = "schedule.remove"  // ScheduleRemoveParams → {}
	MethodSchedulePause  = "schedule.pause"   // ScheduleRef → ScheduleEntry
	MethodScheduleResume = "schedule.resume"  // ScheduleRef → ScheduleEntry
	MethodScheduleRunNow = "schedule.run_now" // ScheduleRef → ScheduleRun

	// NotifyScheduleChanged (daemon → app): a schedule or its newest run
	// changed, or it was removed (ScheduleChanged).
	NotifyScheduleChanged = "schedule.changed"
)

Schedule methods (see PROTOCOL.md). Served by the daemon (the bridge forwards them); Linux and macOS only (CapSchedules).

View Source
const (
	ScheduleKindCommand = "command" // Schedule.Command through $SHELL -c
	// ScheduleKindAgent: a coding agent (Schedule.Harness) given
	// Schedule.Prompt, run non-interactively by `stagent schedule agent`.
	ScheduleKindAgent = "agent"
)

Schedule kinds.

View Source
const (
	PermissionRead  = "read"  // read only (the default)
	PermissionWrite = "write" // change files in its directory
	PermissionAll   = "all"   // anything, without asking
)

Schedule.Permission values: how much an agent schedule's agent may do with nobody watching (#1083). Each maps to the harness's own flags (schedagent.Argv).

View Source
const (
	ScheduleActive = "active"
	// SchedulePaused: its times pass without running it (schedule.pause);
	// schedule.resume runs it again from its next time on.
	SchedulePaused = "paused"
)

Schedule states.

View Source
const (
	EveryDaily    = "daily"    // every day at Time
	EveryWeekdays = "weekdays" // Monday to Friday at Time
	EveryWeekly   = "weekly"   // on Days at Time
	EveryHours    = "hours"    // at Minute past every hour h of the day with h % Hours == 0
)

ScheduleWhen.Every values: when a schedule runs, on the wall clock of its time zone (Schedule.TZ).

View Source
const (
	// ScheduleNotifyProblems: a problem (failed, timed out, denied,
	// undetermined or unjudged, skipped for an overlap, stopped after
	// failures); while problems go on, only the first and the stop, then
	// the first success as fixed. The default.
	ScheduleNotifyProblems = "problems"
	// ScheduleNotifyAlways: every time's last result.
	ScheduleNotifyAlways = "always"
	ScheduleNotifyOff    = "off"
)

Schedule.Notify values.

View Source
const (
	RunTriggerScheduled = "scheduled" // its time came
	RunTriggerNow       = "now"       // schedule.run_now
)

Run triggers (a retry goes on in its time's line, ScheduleTry.Retry).

View Source
const (
	RunRunning   = "running"
	RunSucceeded = "succeeded" // a command run's exit code was 0
	// RunFailed: a non-zero exit code (ExitCode), or no exit code at all
	// (the run could not start, or its session was lost; Error says).
	RunFailed = "failed"
	// RunUndetermined: the run's end is not known (it ended while the
	// daemon was not running).
	RunUndetermined = "undetermined"
	// RunSkippedOverlap: its time came while the schedule's previous run
	// was still running, so it did not run.
	RunSkippedOverlap = "skipped_overlap"
	// RunDenied: an agent run went to its end, but some of what its agent
	// tried was refused (ScheduleRun.Denials).
	RunDenied = "denied"
	// RunTimedOut: still running at its schedule's time limit
	// (Schedule.TimeoutMin), so it was stopped.
	RunTimedOut = "timed_out"
)

Run results.

View Source
const (
	// WarnCwdMissing: the directory is not there (schedule.create refuses
	// it).
	WarnCwdMissing = "cwd_missing"
	// WarnCodexOutsideGit: a codex schedule's directory is outside any Git
	// work tree; its runs pass --skip-git-repo-check.
	WarnCodexOutsideGit = "codex_outside_git"
	// WarnWritesCheckout: an agent schedule that may write runs in a
	// checkout the user works in, not a task's worktree.
	WarnWritesCheckout = "writes_checkout"
	// WarnClaudeGUILogin: a claude schedule on a macOS host without
	// ~/.claude/.credentials.json: claude reads its login from the
	// keychain, which its runs cannot while nobody is logged in to the
	// desktop.
	WarnClaudeGUILogin = "claude_gui_login"
)

Schedule warning codes.

View Source
const (
	CwdKindTask      = "task"      // a task's worktree (not an in_place task)
	CwdKindCheckout  = "checkout"  // a Git work tree that is no task's
	CwdKindDirectory = "directory" // outside Git
)

SchedulePreview.CwdKind values.

View Source
const (
	// Served by the bridge (spawn queue): resume one in a new session
	// (StoppedResumeParams → StoppedResumeResult); refused to coding
	// agents' process trees (ADR 0004).
	MethodStoppedResume = "stopped.resume"
	// Served by the daemon (the bridge forwards it), refused to coding
	// agents' process trees: take one off the list (StoppedRef → {}).
	MethodStoppedRemove = "stopped.remove"

	// Local IPC only (daemon), refused to coding agents' process trees.
	//
	// stopped.claim is the bridge's stopped.resume reserving a stopped
	// agent for the session it is about to start (StoppedClaimParams →
	// StoppedClaimResult): the live session that already carries its
	// conversation, or the agent to resume.
	MethodStoppedClaim = "stopped.claim"
	// stopped.unclaim releases a claim whose session did not start
	// (StoppedClaimParams → {}).
	MethodStoppedUnclaim = "stopped.unclaim"

	// NotifyStoppedUpdated carries the whole current list
	// (StoppedUpdatedParams), like unwrapped.updated.
	NotifyStoppedUpdated = "stopped.updated"
)
View Source
const (
	StoppedReboot = "reboot" // the host restarted
	StoppedLost   = "lost"   // its holder went away otherwise
)

Why an agent stopped (StoppedAgent.Reason).

View Source
const (
	// Served by the bridge (spawn queue): register, prepare and start.
	MethodTaskCreate = "task.create"
	// Served by the bridge (login-shell environment): what would be copied.
	MethodTaskPreview = "task.preview"
	// Served by the bridge (its own queue): 片付け.
	MethodTaskRemove = "task.remove"
	// Served by the daemon: every task, in the order they were created.
	MethodTaskList = "task.list" // → TaskListResult
	// Served by the daemon, refused to coding agents' process trees (ADR
	// 0004): run or skip the scripts.setup a preparing task waits on
	// (TaskSetupParams → {}); running it approves that content for the
	// source checkout (ADR 0023).
	MethodTaskSetup = "task.setup"

	// Local IPC only (daemon), refused to coding agents' process trees
	// (ADR 0004).
	//
	// task.progress reports a stage of `stagent task run` / `stagent task
	// remove` (TaskProgressParams → {}).
	MethodTaskProgress = "task.progress"
	// task.register adds a task by its key (source checkout + number, or
	// + name), or answers the existing one (TaskRegisterParams →
	// TaskRegisterResult).
	// The bridge's task.create calls it before preparing anything.
	MethodTaskRegister = "task.register"
	// task.forget deletes a task's record (TaskRemoved → {}): its sessions
	// lose their task_id. The last step of task.remove.
	MethodTaskForget = "task.forget"
	// task.await_setup is `stagent task run` waiting for the app to run
	// or skip a scripts.setup that is neither the source checkout's nor
	// approved (TaskAwaitSetupParams → TaskAwaitSetupResult, answered once
	// task.setup decides).
	MethodTaskAwaitSetup = "task.await_setup"

	// Notifications (daemon → app), like unwrapped.updated.
	NotifyTaskUpdated = "task.updated" // Task: added or changed
	NotifyTaskRemoved = "task.removed" // TaskRemoved
)

Task methods (see PROTOCOL.md).

View Source
const (
	TaskKindIssue = "issue"
	TaskKindPR    = "pr"
	TaskKindName  = "name" // tied to Task.Name, no Issue or PR; never in_place
)

Task kinds.

View Source
const (
	TaskPreparing = "preparing" // `stagent task run` is preparing it
	TaskReady     = "ready"     // its agent (or terminal) was started
	TaskFailed    = "failed"    // a stage failed, or the prepared session went away (interrupted)
	TaskMissing   = "missing"   // its worktree directory or git's registration of it is gone; ready again when both are back
	TaskRemoving  = "removing"  // task.remove is under way
)

Task states.

View Source
const (
	TaskStageFetch    = "fetch"
	TaskStageBranch   = "branch"
	TaskStageWorktree = "worktree"
	TaskStageCopy     = "copy"
	TaskStageSetup    = "setup"
	TaskStageAgent    = "agent"
	TaskStageStop     = "stop"
	TaskStageArchive  = "archive"
	// TaskStageRelay (a relay target's task, after worktree): the
	// package's uncommitted changes and untracked files applied.
	TaskStageRelay = "relay"
)

Task stages: fetch … agent while preparing, stop … branch while removing (worktree and branch name a step of both).

View Source
const (
	// RefusalNestedWorktrees: other worktrees git lists lie inside it
	// (`claude --worktree`'s .claude/worktrees/*), Paths; removing it
	// would take them, their changes included, even when ignored.
	RefusalNestedWorktrees = "nested_worktrees"
	// RefusalSubmodules: it has submodules (Paths, those in its index),
	// which git worktree remove refuses whatever the flags; the user
	// removes them (or the worktree) by hand.
	RefusalSubmodules = "submodules"
	// RefusalLocked: the user locked it (git worktree lock); the lock of
	// a killed git worktree add is none. They unlock it first.
	RefusalLocked = "locked"
)

Refusal kinds.

View Source
const (
	TaskNameInvalid  = "invalid"   // not a valid name (task.ValidName)
	TaskNameTask     = "task"      // a task of the repo has that name
	TaskNameFolder   = "folder"    // <worktree_folder>/<repo name>/<name> exists
	TaskNameBranch   = "branch"    // the local branch (Branch, else Name) exists
	TaskNameNoFolder = "no_folder" // config.json has no worktree_folder
)

Why a named task cannot take a name, checked in this order.

View Source
const (
	TaskSourceInclude = "include" // the source checkout's .worktreeinclude
	TaskSourceApp     = "app"     // config.json repos.<repo>.worktree_include
)

Where a copy comes from.

View Source
const (
	TaskSkipTracked    = "tracked"     // git tracks it: the worktree has it
	TaskSkipNotIgnored = "not_ignored" // untracked but not gitignored
	TaskSkipMissing    = "missing"     // a .worktreeinclude path that does not exist
	TaskSkipNoMatch    = "no_match"    // an app pattern that selects nothing
	TaskSkipUnderLink  = "under_link"  // inside a shared directory, which is linked
	TaskSkipInvalid    = "invalid"     // a line or pattern stagent does not take
	TaskSkipLimit      = "limit"       // past 2 GiB or 50,000 entries
)

Why something is not copied.

View Source
const (
	StateWorking       = "working"
	StateIdle          = "idle"
	StateWaitingInput  = "waiting_input"
	StateNeedsApproval = "needs_approval"
	StateExited        = "exited"
)

Session states.

View Source
const (
	SourceHook     = "hook"     // harness hook (structured)
	SourceTerminal = "terminal" // OSC 9/99/777 notification, BEL
	SourceActivity = "activity" // output activity / quiescence
	SourceProcess  = "process"  // child process exit
)

Where a state came from, highest priority first.

View Source
const (
	HarnessClaude      = "claude"
	HarnessCodex       = "codex"
	HarnessOmp         = "omp"
	HarnessPi          = "pi"
	HarnessCopilot     = "copilot"
	HarnessQwen        = "qwen"
	HarnessOpenCode    = "opencode"
	HarnessGrok        = "grok"
	HarnessAntigravity = "antigravity"
	HarnessOther       = "other"
)

Harness ids. The harnesses stagent knows are listed by the harness registry (internal/harness); HarnessOther is any other program.

View Source
const (
	ModePassthrough = "passthrough" // runs in a local terminal; that terminal owns the size
	ModeDetached    = "detached"    // no local terminal; the app owns the size
)

Session modes.

View Source
const (
	EnvClaudeBridgeSessionID = "CLAUDE_CODE_BRIDGE_SESSION_ID"
	EnvClaudePresenceFile    = "CLAUDE_CLIENT_PRESENCE_FILE"
)

Environment variables claude sets (stagent only reads them): the session's Remote Control connection, seen by its hooks, and a file whose existence says that a client is at the session.

View Source
const (
	EventSessionStarted    = "session_started"
	EventSessionEnded      = "session_ended"
	EventStateChanged      = "state_changed"
	EventNotification      = "notification"
	EventApprovalRequested = "approval_requested"
	EventApprovalResolved  = "approval_resolved"
)

Event kinds.

View Source
const (
	LevelInfo = "info"
	LevelWarn = "warn"
	// LevelError: a limit window (上限の枠) used up (since 0.19.0).
	LevelError = "error"
)

Notification levels.

View Source
const (
	// UnwrappedOldTerminal: the shell lacks the wrapper's marker, i.e. a
	// terminal opened before the wrapper was installed (or one that does
	// not read the shell's rc files).
	UnwrappedOldTerminal = "old_terminal"
	// UnwrappedBypassed: the shell has the wrapper but it was bypassed
	// (`command claude`, a full path).
	UnwrappedBypassed = "bypassed"
	// UnwrappedIDE: an IDE extension or a desktop app (Claude Code's
	// CLAUDE_CODE_ENTRYPOINT is neither cli nor sdk-*; a Codex originator
	// other than its terminal UI and its batch runs).
	UnwrappedIDE = "ide"
	// UnwrappedSSH (Windows): started in an SSH session, where the
	// PowerShell wrapper does not wrap (not UserInteractive) and the agent
	// ends with the connection.
	UnwrappedSSH = "ssh"
	// UnwrappedNoTerminal (Windows): no wrapper's marker and no shell above
	// the harness, i.e. a program started it without a terminal.
	UnwrappedNoTerminal = "no_terminal"
)

Why a launch has no stagent session (UnwrappedLaunch.Reason).

View Source
const (
	// AskQuestion: the question row, a tool row whose text is the
	// questions.
	AskQuestion = "question"
	// AskAnswer: the answer row, a user row whose text is the answers, or a
	// system row when the question was closed without one (Declined).
	AskAnswer = "answer"
)

Kinds of Ask.

View Source
const (
	ExitedOff   = "off"
	ExitedError = "error"
	ExitedAll   = "all"
)

NotifyReasons.Exited values.

View Source
const (
	LangEn = "en"
	LangJa = "ja"
	LangKo = "ko"
	LangZh = "zh"
)

Languages of notify.lang.

View Source
const (
	ChannelNtfy    = "ntfy"
	ChannelWebhook = "webhook"
	ChannelChat    = "chat"
)

Push channel names (keys of NotifyStatus.LastError, notify.test's channels).

View Source
const (
	FailureRevoked     = "revoked"      // the service disabled the destination (webhook deleted, bot token revoked)
	FailureUnreachable = "unreachable"  // the destination cannot be reached (bot blocked, channel gone or archived)
	FailureRateLimited = "rate_limited" // 429
	FailureRejected    = "rejected"     // any other 4xx: the message stagent built was refused
	FailureServer      = "server"       // 5xx
	FailureNetwork     = "network"      // no status line: the request did not get an answer
)

Kinds of a failed push to the chat destination (NotifyFailure.Kind). A client shows Error for a kind it does not know.

View Source
const (
	// MethodUsageGet returns the usage counted so far (UsageGetParams →
	// UsageGetResult). A reader: served to coding agents too.
	MethodUsageGet = "usage.get"

	// NotifyUsageChanged (daemon → app): new usage was counted, or the
	// first scan finished (UsageChanged). Sent at most once per 30 s;
	// the app calls usage.get for the numbers.
	NotifyUsageChanged = "usage.changed"
)
View Source
const (
	UsageWindowFiveHour = "five_hour"
	UsageWindowSevenDay = "seven_day"
)

Limit window ids (UsageLimitWindow.Window). A window of another length is "<minutes>m" (Codex: "1440m").

View Source
const (
	// UsageSourceStatusLine: Claude Code's statusLine input (rate_limits),
	// relayed by `stagent statusline claude`.
	UsageSourceStatusLine = "statusline"
	// UsageSourceCodexRollout: the rate_limits of Codex's token_count
	// events, read from its rollouts by the usage scan.
	UsageSourceCodexRollout = "codex_rollout"
	// UsageSourcePrivateAPI: the harness's undocumented usage API
	// (Claude /api/oauth/usage, Codex wham/usage), called with the login
	// token the harness keeps when usage.private_api is on for it.
	UsageSourcePrivateAPI = "private_api"
	// UsageSourceOmpUsage: what omp (oh-my-pi) tells with `omp usage
	// --json` and records in its hourly snapshots (`omp usage --history
	// --json`), when omp is installed (omp の記録).
	UsageSourceOmpUsage = "omp_usage"
	// UsageSourceAntigravityUsage: what Antigravity CLI tells with `agy -p
	// /usage --output-format json`, when agy is installed (Antigravity
	// usage).
	UsageSourceAntigravityUsage = "antigravity_usage"
)

Ways a limit window was measured (UsageLimitWindow.Source).

View Source
const (
	// UsageErrRateLimited: the API answered 429; it is not called again
	// before RetryAt (its Retry-After).
	UsageErrRateLimited = "rate_limited"
	// UsageErrUnauthorized: the API refused the token (401) or the token
	// has expired; starting the harness renews the login. Not called again
	// for an hour.
	UsageErrUnauthorized = "unauthorized"
	// UsageErrForbidden: the API answered 403 (the token lacks the scope):
	// it cannot be measured this way. Not called again for an hour.
	UsageErrForbidden = "forbidden"
	// UsageErrNoCredentials: the harness keeps no login token to call the
	// API with. Not called again for an hour.
	UsageErrNoCredentials = "no_credentials"
	// UsageErrServer: the API answered another status (5xx).
	UsageErrServer = "server"
	// UsageErrNetwork: the API could not be reached in 10 s.
	UsageErrNetwork = "network"
	// UsageErrBadResponse: the API's answer was not the JSON expected.
	UsageErrBadResponse = "bad_response"
	// UsageErrCommand: `omp usage` or `agy -p /usage` failed (exit status,
	// timeout).
	UsageErrCommand = "command_failed"
)

Why the private API could not measure (UsageLimitError.Code).

View Source
const (
	// worktree.list ({} → WorktreeListResult) changes nothing on the host
	// but config.json's worktree_repos (queue "worktree").
	MethodWorktreeList = "worktree.list"
	// worktree.sizes ({} → WorktreeSizesResult): disk usage (queue
	// "worktree.sizes").
	MethodWorktreeSizes = "worktree.sizes"
	// worktree.prs ({} → WorktreePRsResult): gh's pull requests of the
	// worktrees' branches (queue "worktree.prs").
	MethodWorktreePRs = "worktree.prs"
	// worktree.watch (WorktreeWatchParams → WorktreeWatchResult) adds or
	// removes a watch folder (見るフォルダ); refused to coding agents'
	// process trees (queue "worktree").
	MethodWorktreeWatch = "worktree.watch"
	// worktree.remove (WorktreeRemoveParams → WorktreeRemoveResult) removes
	// one worktree or folder (worktree を消す); refused to coding agents'
	// process trees (task.remove's queue).
	MethodWorktreeRemove = "worktree.remove"
)

Worktree methods (capability CapWorktrees).

View Source
const CapHostScreenIOS = "host_screen_ios"

CapHostScreenIOS (macOS only): host_screen.list has an ios section and host_screen.start serves the ios kind.

View Source
const CapRelay = "relay"

CapRelay: the bridge serves relay.* and the daemon relay.record; Session and Conversation carry relay (every OS, since 0.26.0).

View Source
const CapSchedules = "schedules"

CapSchedules: the daemon serves schedule.* (Linux and macOS hosts).

View Source
const CapStoppedAgents = "stopped_agents"

CapStoppedAgents: the daemon keeps stopped agents (watch's stopped, stopped.updated, stopped.remove) and the bridge serves stopped.resume.

View Source
const CapWorktrees = "worktrees"

CapWorktrees: the bridge serves worktree.* (every OS, since 0.18.0).

View Source
const EnvSessionID = "STAGENT_SESSION_ID"

EnvSessionID is exported to the agent process so hooks can name the PTY session they belong to.

View Source
const EnvShellWrapper = "STAGENT_SHELL_WRAPPER"

EnvShellWrapper is the marker the shell wrapper's rc block exports.

View Source
const EveryCron = "cron"

EveryCron: at the times the cron expression Cron (ScheduleWhen) names, five fields: minute, hour, day of month, month, weekday.

View Source
const EveryOnce = "once"

EveryOnce: once, at Date Time (ScheduleWhen); after that the schedule has no next time and stays.

View Source
const HostScreenPipeOnly = "pipe_only"

HostScreenPipeOnly is the Reason of a browser started with --remote-debugging-pipe only: it opened no port to connect to.

View Source
const MaxLine = 16 << 20

MaxLine bounds a single message. Output chunks are capped well below this by their producers; anything larger is a protocol violation.

View Source
const MethodScheduleOutput = "schedule.output"

schedule.output: the output of a schedule's run, read by the daemon from what the run's session left on disk (its scrollback), so it is there after the session's holder has exited (session.scrollback is the holder's). Coding agents may read it.

View Source
const MethodUsageReport = "usage.report"

MethodUsageReport (statusline → daemon, a notification: no reply) brings the limit windows `stagent statusline claude` read from Claude Code's statusLine input. Served to coding agents: it runs under claude (ADR 0004), so the daemon takes it only for a configuration directory the relay is installed in and within bounds (PROTOCOL.md "Limit windows").

View Source
const NoteWSL = "wsl"

NoteWSL: the host is a Linux inside Windows' WSL, which sees neither the browsers nor the emulators on the Windows side.

View Source
const ReasonUsageLimit = "usage_limit"

ReasonUsageLimit is the NotificationData.Reason of a limit window's notifications (80%, 100%, reset).

View Source
const RunSkippedPaused = "skipped_paused"

RunSkippedPaused: a once schedule's time passed while it was paused, so it did not run.

View Source
const RunTriggerLate = "late"

RunTriggerLate: its time (the newest of the times missed while the host slept or the daemon was not running) came over a minute before it started.

View Source
const ScheduleSummaryMax = 8 << 10

ScheduleSummaryMax bounds ScheduleTry.Summary (bytes).

View Source
const TaskErrInterrupted = "interrupted"

TaskErrInterrupted is Task.Error of a task whose prepared session went away (or never registered) before it got ready.

View Source
const TaskPreviewRows = 500

TaskPreviewRows caps TaskPreviewResult.Copies and Skipped.

View Source
const TaskRemoveChangesMax = 200

TaskRemoveChangesMax caps TaskRemoveResult.Changes.

View Source
const UsageTopSessions = 20

UsageTopSessions is how many sessions usage.get returns.

View Source
const (
	UsageWindowExtraUsage = "extra_usage"
)

More limit window ids the private API brings: Claude's weekly window of one model ("seven_day_opus", "seven_day_sonnet": UsageWindowSevenDay + "_" + the model, see UsageWindowModel) and its extra usage (超過の課金, a monthly spend limit whose reset time is not told: ResetsAt 0). Antigravity's quota groups other than its own models bring the scoped windows "five_hour_<scope>" (UsageWindowFiveHourScope) and "seven_day_<scope>" (the same family as a model's week), labelled with the group's name (UsageLimitWindow.Label).

View Source
const WorktreeRemoveTop = 5

WorktreeRemoveTop caps WorktreeRemoveResult.Entries.

Variables

View Source
var DaemonMethods = map[string]bool{
	MethodWatch: true, MethodSessionsList: true, MethodConversationsList: true,
	MethodTranscriptGet: true, MethodTranscriptSubscribe: true, MethodTranscriptUnsubscribe: true,
	MethodApprovalsList: true,
	MethodConfigGet:     true, MethodConfigSet: true, MethodNotifyTest: true,
	MethodPresenceSet: true, MethodTaskList: true, MethodTaskSetup: true,
	MethodScheduleList: true, MethodScheduleCreate: true, MethodScheduleRuns: true, MethodSchedulePreview: true,
	MethodScheduleUpdate: true, MethodScheduleRemove: true, MethodSchedulePause: true, MethodScheduleResume: true,
	MethodScheduleRunNow: true,
	MethodScheduleOutput: true,
	MethodUsageGet:       true,
	MethodStoppedRemove:  true,
	MethodRelayRecord:    true,
}

DaemonMethods are forwarded by the bridge to the daemon.

View Source
var ErrTooLong = errors.New("wire: message exceeds MaxLine")

ErrTooLong is returned by Read for a line over MaxLine.

GitHubMethods are served by the bridge on hosts announcing CapGitHub.

HolderMethods are forwarded by the bridge to the session's holder.

HostScreenMethods are served by the bridge itself.

View Source
var KeySequences = map[string]string{
	"enter": "\r", "esc": "\x1b", "tab": "\t", "shift-tab": "\x1b[Z",
	"backspace": "\x7f", "delete": "\x1b[3~", "space": " ",
	"up": "\x1b[A", "down": "\x1b[B", "right": "\x1b[C", "left": "\x1b[D",
	"home": "\x1b[H", "end": "\x1b[F", "pageup": "\x1b[5~", "pagedown": "\x1b[6~",
	"ctrl-c": "\x03", "ctrl-d": "\x04", "ctrl-z": "\x1a", "ctrl-l": "\x0c",
	"ctrl-r": "\x12", "ctrl-u": "\x15", "ctrl-o": "\x0f", "ctrl-t": "\x14",
}

KeySequences maps session.input key names to the bytes sent to the PTY.

View Source
var ScheduleHarnesses = []string{HarnessClaude, HarnessCodex, HarnessOmp}

ScheduleHarnesses are the coding agents an agent schedule can run (Schedule.Harness).

View Source
var UsageLongContextThresholds = [...]int64{100_000, 200_000, 272_000}

UsageLongContextThresholds are the prompt sizes (tokens) usage is also counted above, so long-context prices can be applied: the app keeps the price table and picks the threshold of each model (Claude Haiku 5.5: 100K; Claude's earlier long-context prices: 200K; OpenAI: 272K). A request's prompt is its input, cache reads and cache writes.

Functions

func AgentArgv added in v0.10.0

func AgentArgv(argv []string) []string

AgentArgv is the program a command runs in the end: for `stagent task run [flags] <id> -- <command…>` (a task's prepared session) the command after "--", which that one becomes, and for `stagent schedule agent [flags] -- <command…>` (an agent schedule's run) the agent it runs; argv itself otherwise.

func NewRelayID added in v0.26.0

func NewRelayID() string

NewRelayID returns a random relay id (RelayRef.RelayID).

func NewSessionID

func NewSessionID() string

NewSessionID returns a random 16-hex-char id (paths.sessionIDLen).

func ProgramName added in v0.15.0

func ProgramName(argv0 string) string

ProgramName is the lower-case base name of argv0 without a Windows program extension.

func ScheduleHarnessNames added in v0.17.0

func ScheduleHarnessNames() string

ScheduleHarnessNames names ScheduleHarnesses as a sentence does ("claude, codex or omp").

func SchedulesServedOn added in v0.17.0

func SchedulesServedOn(goos string) bool

SchedulesServedOn reports whether a host of goos (runtime.GOOS) serves schedules: Linux and macOS (a login shell and $SHELL -c), as the daemon serves them and the bridge announces CapSchedules.

func StoppedAgentsServedOn added in v0.21.0

func StoppedAgentsServedOn(goos string) bool

StoppedAgentsServedOn reports whether a host of goos (runtime.GOOS) keeps stopped agents: Linux and macOS, as the daemon records them and the bridge announces CapStoppedAgents.

func UsageWindowFiveHourScope added in v0.25.0

func UsageWindowFiveHourScope(id string) (scope string, ok bool)

UsageWindowFiveHourScope is the scope of a five-hour window of one quota group ("3p" of "five_hour_3p": lowercase letters and digits); ok is false for any other id.

func UsageWindowLength added in v0.19.0

func UsageWindowLength(id string) (minutes int64, ok bool)

UsageWindowLength is how long window id lasts, in minutes: 300 for five_hour, 10080 for seven_day, N for "<N>m"; ok is false for any other id.

func UsageWindowModel added in v0.19.0

func UsageWindowModel(id string) (model string, ok bool)

UsageWindowModel is the model (or scope) of a weekly window of one model or quota group ("opus" of "seven_day_opus": lowercase letters and digits); ok is false for any other id.

func UsageWindowOfLength added in v0.19.0

func UsageWindowOfLength(minutes float64) string

UsageWindowOfLength is the id of a window lasting minutes: five_hour for 300 (±1), seven_day for 10080 (±1), any other length "<minutes>m".

func UsageWindowRank added in v0.19.0

func UsageWindowRank(id string) int

UsageWindowRank orders window ids the way usage.get lists them: five_hour, seven_day, the windows of one model or quota group (among themselves in the order they were measured), the others (by id), then extra_usage.

func UsageWindowScoped added in v0.25.0

func UsageWindowScoped(id string) bool

UsageWindowScoped reports whether id is a window of one model or quota group (seven_day_<x> or five_hour_<x>).

func ValidExited added in v0.4.0

func ValidExited(v string) bool

ValidExited reports whether v is a notify.reasons.exited value ("" = default).

func ValidLang added in v0.4.0

func ValidLang(lang string) bool

ValidLang reports whether lang is a notify.lang value ("" = default).

func ValidRelayID added in v0.26.0

func ValidRelayID(id string) bool

ValidRelayID accepts the 32 lowercase hex chars of NewRelayID, which also keeps ids from escaping the relay directories.

func ValidScheduleNotify added in v0.17.0

func ValidScheduleNotify(v string) bool

ValidScheduleNotify reports whether v is a Schedule.Notify ("" = default).

Types

type Approval

type Approval struct {
	RequestID string `json:"request_id"`
	SessionID string `json:"session_id,omitempty"`
	Harness   string `json:"harness"`
	ToolName  string `json:"tool_name,omitempty"`
	Summary   string `json:"summary"` // human readable, e.g. the command line
	CreatedAt int64  `json:"created_at"`
}

Approval is a pending permission request reported by a harness hook. It is answered on the program's own screen; stagent only tracks it.

type ApprovalResolvedData

type ApprovalResolvedData struct {
	RequestID string `json:"request_id"`
	By        string `json:"by"` // always "cancelled": answered on screen or the turn moved on
}

ApprovalResolvedData is Event.Data for approval_resolved.

type ApprovalsListResult

type ApprovalsListResult struct {
	Approvals []Approval `json:"approvals"`
}

type Ask added in v0.20.0

type Ask struct {
	ID   string `json:"id"`   // the tool call's id, shared by both rows
	Kind string `json:"kind"` // AskQuestion | AskAnswer
	// Questions in the order asked; an answer row's carry the answers.
	// Codex records the answers by question id only.
	Questions []QuestionItem `json:"questions,omitempty"`
	// Declined: the answer row of a question closed without an answer.
	// Codex's interrupted calls name no tool, so any of its function calls
	// the user interrupted gets one: a reader shows it only under the
	// question row of its ID.
	Declined bool `json:"declined,omitempty"`
}

Ask links the question row of an agent's question and its answer row. A question row no answer row follows is waiting for the user, as long as nothing else follows it either.

type AttachParams

type AttachParams struct {
	ID   string `json:"id"`
	Mode string `json:"mode"`          // default raw
	FPS  int    `json:"fps,omitempty"` // screen mode cap, default 15, max 30
	// Since is the stream position the client consumed up to (the last
	// `end` it saw); raw mode resumes from there when possible. nil = no
	// resume.
	Since *int64 `json:"since,omitempty"`
}

type AttachResult

type AttachResult struct {
	Cols int    `json:"cols"`
	Rows int    `json:"rows"`
	Mode string `json:"mode"`
	// Offset is the stream position right after the first output item,
	// where live output continues.
	Offset int64 `json:"offset"`
	// Resumed: the first output item is the missed range [since, offset)
	// (reset false) instead of a snapshot.
	Resumed bool `json:"resumed"`
}

type Blocked added in v0.7.0

type Blocked struct {
	Path  string `json:"path"`  // e.g. /tmp/stagent-1000, \\.\pipe\stagent-<SID>
	Owner string `json:"owner"` // user name when known, else uid / SID
}

Blocked names a stagent location another user owns.

type ChatConfig added in v0.8.0

type ChatConfig struct {
	Enabled bool   `json:"enabled"`
	URL     string `json:"url"`
}

ChatConfig sends to a chat service in its own message format (chat destination). URL names the service and is a secret: Discord (https://discord.com/api/webhooks/<id>/<token>, also discordapp.com, or discord://<id>/<token>), Slack Incoming Webhooks (https://hooks.slack.com/services/<a>/<b>/<c> or slack://<a>/<b>/<c>) or Telegram (tgram://<bot token>/<chat id>).

type ClosedParams

type ClosedParams struct {
	ID       string `json:"id"`
	ExitCode int    `json:"exit_code"`
	// HungUp (holder.ended only): the program ended after a client's
	// session.signal hangup or (Windows) its passthrough console closed.
	HungUp bool `json:"hung_up,omitempty"`
}

type Codec

type Codec struct {
	// contains filtered or unexported fields
}

Codec reads and writes newline-delimited JSON messages. Write is safe for concurrent use; Read must be called from one goroutine.

func NewCodec

func NewCodec(r io.Reader, w io.Writer) *Codec

NewCodec wraps a reader and writer (often the same net.Conn).

func (*Codec) Encode

func (c *Codec) Encode(v any) error

Encode writes v as one JSON line. The output is pure ASCII (non-ASCII runes are \u-escaped) so shells or consoles that re-encode stdout — PowerShell on Windows — cannot corrupt it.

func (*Codec) Notify

func (c *Codec) Notify(method string, params any) error

Notify sends a notification.

func (*Codec) Read

func (c *Codec) Read() (*Msg, error)

Read decodes the next message. Blank lines are skipped. A trailing '\r' is tolerated so CRLF-translating transports still work.

func (*Codec) ReadLine

func (c *Codec) ReadLine() ([]byte, error)

ReadLine returns the next non-blank line without its line ending, for line protocols whose objects are not Msg envelopes (`stagent follow`). Blank lines are skipped and a trailing '\r' is removed, as for Read.

func (*Codec) Reply

func (c *Codec) Reply(id *int64, result any) error

Reply answers request id with result (nil → {}).

func (*Codec) ReplyError

func (c *Codec) ReplyError(id *int64, e *Error) error

ReplyError answers request id with an error.

func (*Codec) Request

func (c *Codec) Request(id int64, method string, params any) error

Request sends a request with the given id.

func (*Codec) Write

func (c *Codec) Write(m *Msg) error

Write encodes m as one line.

type Config

type Config struct {
	Notify    NotifyConfig    `json:"notify"`
	Retention RetentionConfig `json:"retention"`
	// IdleAfterMs: quiet time after which output activity counts as idle.
	IdleAfterMs int `json:"idle_after_ms"`
	// DisableHandoff makes `stagent run --handoff=auto` (the shell
	// wrappers) end the program with its terminal unless STAGENT_HANDOFF
	// says otherwise.
	DisableHandoff bool `json:"disable_handoff"`
	// Repos holds settings per source checkout (元のチェックアウト), keyed
	// by its canonical path (task.Canonical).
	Repos map[string]RepoConfig `json:"repos,omitempty"`
	// WorktreeFolder is the worktree folder (worktree の置き場): an
	// absolute, clean path under which task worktrees go,
	// <folder>/<checkout name>/<name or number-slug>. Unset: issue and PR
	// tasks go next to their checkout, named tasks cannot be made.
	WorktreeFolder string `json:"worktree_folder,omitempty"`
	// WorktreeWatch are the watch folders (見るフォルダ): absolute, clean
	// paths (config.set expands a leading ~) whose direct subdirectories
	// that are worktrees lead worktree.list to their repositories.
	WorktreeWatch []string `json:"worktree_watch,omitempty"`
	// WorktreeRepos are the source checkouts worktree.list found
	// (canonical, sorted); the bridge rewrites them when that changes, a
	// checkout that is gone dropped.
	WorktreeRepos []string `json:"worktree_repos,omitempty"`
	// Usage configures how the limit windows (上限の枠) are measured.
	Usage UsageConfig `json:"usage"`
}

Config is the daemon configuration. Zero values mean "default".

func (Config) WithDefaults

func (c Config) WithDefaults() Config

WithDefaults fills zero fields with the documented defaults.

type ConfigResult

type ConfigResult struct {
	Config Config       `json:"config"`
	Notify NotifyStatus `json:"notify"`
}

type ConfigSetParams

type ConfigSetParams struct {
	Config json.RawMessage `json:"config"`
}

ConfigSetParams carries a JSON Merge Patch (RFC 7396) for config.json: only the keys it names change, null deletes a key.

type Conversation

type Conversation struct {
	Harness       string `json:"harness"`
	ID            string `json:"id"`
	Cwd           string `json:"cwd"`
	Title         string `json:"title"`
	UpdatedAt     int64  `json:"updated_at"` // unix ms (file mtime)
	Path          string `json:"path"`
	LiveSessionID string `json:"live_session_id,omitempty"`
	// Relay is the conversation's relay trace (omitted: none; CapRelay).
	Relay *RelayLinks `json:"relay,omitempty"`
}

Conversation is one stored conversation of a harness (conversations.list).

type ConversationsListParams

type ConversationsListParams struct {
	Harness []string `json:"harness,omitempty"` // empty = all
	Limit   int      `json:"limit,omitempty"`   // default 50 per harness
}

type ConversationsListResult

type ConversationsListResult struct {
	Conversations []Conversation `json:"conversations"`
}

type DaemonStatus

type DaemonStatus struct {
	PID       int               `json:"pid"`
	Version   string            `json:"version"`
	StartedAt int64             `json:"started_at"`
	Sessions  int               `json:"sessions"`
	Bridges   int               `json:"bridges"`
	Unwrapped []UnwrappedLaunch `json:"unwrapped"`
	// BootstrapSwapped (macOS only; absent elsewhere): the daemon moved
	// itself to the user's per-user bootstrap port at start, so it and what
	// it starts reach the network after the user logs out of the GUI.
	BootstrapSwapped *bool `json:"bootstrap_swapped,omitempty"`
	// BootstrapError is why that failed.
	BootstrapError string `json:"bootstrap_error,omitempty"`
}

type Error

type Error struct {
	Code    string          `json:"code"`
	Message string          `json:"message"`
	Data    json.RawMessage `json:"data,omitempty"`
}

Error is a protocol-level failure. Code is a stable machine-readable string (see the Err* constants); Message is for humans. Data, when a method documents it, carries what the client needs to act on the failure (relay.prepare: RelayErrorData).

func Errorf

func Errorf(code, format string, args ...any) *Error

Errorf builds an *Error.

func (*Error) Error

func (e *Error) Error() string

type Event

type Event struct {
	Seq       int64           `json:"seq"`
	Time      int64           `json:"time"` // unix ms
	SessionID string          `json:"session_id,omitempty"`
	Kind      string          `json:"kind"`
	Data      json.RawMessage `json:"data,omitempty"`
}

Event is one entry of the daemon's event log.

type GitHubActivityParams added in v0.9.0

type GitHubActivityParams struct {
	Path   string `json:"path"`
	Host   string `json:"host"`
	Repo   string `json:"repo"`
	Branch string `json:"branch,omitempty"`
}

GitHubActivityParams: Repo is gh's -R value (OWNER/REPO, HOST/OWNER/REPO on GitHub Enterprise), Host the host gh must be signed in to, Branch the working tree's feature branch whose pull request is wanted.

type GitHubActivityResult added in v0.9.0

type GitHubActivityResult struct {
	GH             string          `json:"gh"`
	AuthMessage    string          `json:"auth_message,omitempty"`
	PackageManager string          `json:"package_manager,omitempty"`
	Description    string          `json:"description,omitempty"`
	IsPrivate      bool            `json:"is_private"`
	Pulls          json.RawMessage `json:"pulls,omitempty"`
	PullsError     string          `json:"pulls_error,omitempty"`
	Issues         json.RawMessage `json:"issues,omitempty"`
	IssuesError    string          `json:"issues_error,omitempty"`
	Current        json.RawMessage `json:"current,omitempty"`
}

GitHubActivityResult is what gh reported for one repository. Pulls, Issues and Current are gh's JSON as is.

type GitHubRepo added in v0.9.0

type GitHubRepo struct {
	Path      string `json:"path"` // top-level directory
	RemoteURL string `json:"remote_url"`
	// SSHHost is the real host name of an ssh remote (`ssh -G`), which may
	// name an ~/.ssh/config alias.
	SSHHost string `json:"ssh_host,omitempty"`
	// Branch is the abbreviated commit when Detached.
	Branch        string `json:"branch"`
	Detached      bool   `json:"detached"`
	DefaultBranch string `json:"default_branch,omitempty"` // from origin/HEAD
	Changes       int    `json:"changes"`                  // changed and untracked files
	// Ahead and Behind count commits against the upstream branch; nil
	// without one.
	Ahead        *int   `json:"ahead,omitempty"`
	Behind       *int   `json:"behind,omitempty"`
	LastActiveAt string `json:"last_active_at,omitempty"` // RFC 3339
}

GitHubRepo is one working tree, with the fields of the app's sh script (`@@REPO`).

type GitHubReposResult added in v0.9.0

type GitHubReposResult struct {
	Repos []GitHubRepo `json:"repos"`
	// GitMissing: git is not installed (not on the bridge's PATH).
	GitMissing bool `json:"git_missing"`
}

GitHubReposResult is github.repos: the git working trees the user worked in last, newest first.

type GitHubStatusItem added in v0.10.0

type GitHubStatusItem struct {
	Repo    string `json:"repo"`
	Kind    string `json:"kind"`
	Number  int    `json:"number"`
	Branch  string `json:"branch,omitempty"`
	State   string `json:"state"`
	PRState string `json:"pr_state,omitempty"`
}

GitHubStatusItem: State and PRState as gh reports them (OPEN, CLOSED, MERGED). Branch is the query's branch of an issue item, PRState that branch's pull request.

type GitHubStatusParams added in v0.10.0

type GitHubStatusParams struct {
	Items []GitHubStatusQuery `json:"items"`
}

type GitHubStatusQuery added in v0.10.0

type GitHubStatusQuery struct {
	Repo   string `json:"repo"`
	Kind   string `json:"kind"`
	Number int    `json:"number"`
	Branch string `json:"branch,omitempty"`
}

GitHubStatusQuery names an issue or pull request; Repo is gh's -R value. Branch (issues only) asks for the state of that branch's pull request too.

type GitHubStatusResult added in v0.10.0

type GitHubStatusResult struct {
	Items []GitHubStatusItem `json:"items"`
}

type HelloParams

type HelloParams struct {
	Protocol int    `json:"protocol"`
	Client   string `json:"client"` // e.g. "ssh-term/2.38.0"
}

type HelloResult

type HelloResult struct {
	Protocol     int      `json:"protocol"`
	Version      string   `json:"version"`
	OS           string   `json:"os"`   // linux | darwin | windows
	Arch         string   `json:"arch"` // amd64 | arm64
	Home         string   `json:"home"`
	Capabilities []string `json:"capabilities"`
	// HostID is the host's random id (hostid); absent when it could not be
	// read or created. Older stagent versions never send it.
	HostID string `json:"host_id,omitempty"`
	// Blocked is set when another user owns this host's stagent location
	// (the run directory, a socket or the daemon's named pipe), so no kept
	// shell can work until the host's administrator removes it. Older
	// stagent versions never send it.
	Blocked *Blocked `json:"blocked,omitempty"`
}

type HolderNotifyParams

type HolderNotifyParams struct {
	ID    string `json:"id"`
	Title string `json:"title,omitempty"`
	Body  string `json:"body,omitempty"`
	Bell  bool   `json:"bell,omitempty"`
}

HolderNotifyParams is a notification the program itself emitted (OSC 9 / 99 / 777, or BEL).

type HolderPromptGoneParams added in v0.4.0

type HolderPromptGoneParams struct {
	ID  string `json:"id"`
	Gen int64  `json:"gen"`
}

HolderPromptGoneParams reports that the permission menu watch Gen saw is no longer on the screen: the prompt was answered somewhere (holder.prompt_gone); or that it came on the screen (holder.prompt_shown).

type HolderPromptWatchParams added in v0.4.0

type HolderPromptWatchParams struct {
	ID      string `json:"id"`
	Gen     int64  `json:"gen"`
	On      bool   `json:"on"`
	Harness string `json:"harness,omitempty"`
	Shown   bool   `json:"shown,omitempty"`
}

HolderPromptWatchParams starts (on) or ends a prompt watch. Gen names the watch; a new one starts with every approval registered of a harness whose menu is watched, and with every permission check of one whose menu comes with no hook (Antigravity CLI). Harness (since 0.16.0, with on) is the harness whose menu the approval brings: Copilot CLI's menu has claude's cursor (❯), so the holder reads the screen as that harness draws it. Empty from older daemons: every harness's menus are looked for. Shown (with on): no approval is registered yet; the holder also reports when the menu comes on the screen (holder.prompt_shown), which registers it.

type HolderRegisterResult

type HolderRegisterResult struct {
	IdleAfterMs int `json:"idle_after_ms"`
}

type HookEventParams

type HookEventParams struct {
	Harness   string          `json:"harness"`
	Event     string          `json:"event"`                // harness-native event name
	SessionID string          `json:"session_id,omitempty"` // $STAGENT_SESSION_ID
	Payload   json.RawMessage `json:"payload,omitempty"`    // hook stdin (or notify argv JSON)
	// RemoteControl: the hook ran with $CLAUDE_CODE_BRIDGE_SESSION_ID, set
	// while claude is connected to Remote Control.
	RemoteControl bool `json:"remote_control,omitempty"`

	// How the agent was started, sent when SessionID is empty (see
	// UnwrappedLaunch). ShellWrapper: $STAGENT_SHELL_WRAPPER is set.
	// Entrypoint: $CLAUDE_CODE_ENTRYPOINT. ParentTTY: the harness (the
	// hook's nearest ancestor that is not a shell) reads a terminal — its
	// stdin on Linux, its controlling terminal on macOS; nil when unknown
	// (Windows). ParentBatch:
	// the harness's command line asks for a non-interactive run, by the
	// shell wrapper's rule (the harness's Batch in the registry, e.g.
	// claude -p / --print, codex exec). SSH: $SSH_CONNECTION is set.
	// TerminalAncestor (Windows; nil elsewhere or unknown): a shell
	// (PowerShell, pwsh, cmd, bash, sh) runs above the harness. Originator
	// (codex): session_meta.originator of the conversation's rollout file
	// (codex-tui, codex_exec, "Codex Desktop", …); Subagent: that
	// conversation is a subagent thread of another one.
	ShellWrapper     bool   `json:"shell_wrapper,omitempty"`
	Entrypoint       string `json:"entrypoint,omitempty"`
	ParentTTY        *bool  `json:"parent_tty,omitempty"`
	ParentBatch      bool   `json:"parent_batch,omitempty"`
	SSH              bool   `json:"ssh,omitempty"`
	TerminalAncestor *bool  `json:"terminal_ancestor,omitempty"`
	Originator       string `json:"originator,omitempty"`
	Subagent         bool   `json:"subagent,omitempty"`
}

type HostClock added in v0.17.0

type HostClock struct {
	TZ       string `json:"tz"`
	At       int64  `json:"at"`
	Offset   int    `json:"offset"`
	TZOffset int    `json:"tz_offset"`
}

HostClock is the host's own clock at a time of a schedule (At, unix ms, its next) when it is not the clock of the schedule's tz: the host's zone (TZ: its IANA name, else its abbreviation, "UTC") and the UTC offsets in seconds of the host (Offset) and of the schedule's tz (TZOffset) then. The app says it once (#1085: "this host is on UTC; 9:00 is its 0:00").

type HostScreenAckParams added in v0.11.0

type HostScreenAckParams struct {
	Seq int64 `json:"seq"`
}

type HostScreenBrowserItem added in v0.11.0

type HostScreenBrowserItem struct {
	PID int `json:"pid,omitempty"`
	// Tool is null when the profile path names none of the known tools.
	Tool     *string `json:"tool"`
	Headless *bool   `json:"headless,omitempty"`
	Port     int     `json:"port,omitempty"`
	// Manual: Port is one of HostScreenListParams.CDPPorts.
	Manual      bool             `json:"manual,omitempty"`
	Connectable bool             `json:"connectable"`
	Reason      string           `json:"reason,omitempty"`
	Pages       []HostScreenPage `json:"pages"`
}

HostScreenBrowserItem is one browser with an open CDP port, or one that cannot be connected to (Connectable false, Reason says why).

type HostScreenEmulatorItem added in v0.11.0

type HostScreenEmulatorItem struct {
	Serial      string `json:"serial"`
	AVD         string `json:"avd"`
	Connectable bool   `json:"connectable"`
	Reason      string `json:"reason,omitempty"`
}

HostScreenEmulatorItem is one running Android emulator: Serial is adb's (emulator-<console port>), AVD the virtual device's name.

type HostScreenFrame added in v0.11.0

type HostScreenFrame struct {
	Seq    int64  `json:"seq"`
	Data   string `json:"data"`
	Width  int    `json:"width"`
	Height int    `json:"height"`
}

HostScreenFrame is one JPEG; Data is its base64 (kept encoded end to end: CDP sends it so). Width and Height are the target's size in its own coordinates (CSS px for a browser, px for an Android emulator, pt for an iOS simulator).

type HostScreenInput added in v0.11.0

type HostScreenInput struct {
	Type       string            `json:"type"`
	X          float64           `json:"x,omitempty"`
	Y          float64           `json:"y,omitempty"`
	Points     []HostScreenPoint `json:"points,omitempty"`
	DurationMS int               `json:"duration_ms,omitempty"`
	DX         float64           `json:"dx,omitempty"`
	DY         float64           `json:"dy,omitempty"`
	Text       string            `json:"text,omitempty"`
	Enter      bool              `json:"enter,omitempty"`
	Key        string            `json:"key,omitempty"`
	Action     string            `json:"action,omitempty"`
	URL        string            `json:"url,omitempty"`
}

HostScreenInput is the params of host_screen.input: one operation on the target being shown. Points are fractions of the frame (0 at its left and top edge, 1 at its right and bottom one); stagent turns them into the target's coordinates. Which fields count depends on Type:

tap      X, Y
drag     Points (in order), DurationMS
scroll   X, Y, DX, DY (how far the fingers moved, fractions of the
         frame's width and height)
text     Text, Enter; X, Y the cursor (iOS opens the edit menu there)
key      Key
navigate Action, URL (for NavigateURL)

type HostScreenInputResult added in v0.13.0

type HostScreenInputResult struct {
	Via string `json:"via,omitempty"`
	App string `json:"app,omitempty"`
}

HostScreenInputResult is the result of host_screen.input: empty but for a text an iOS simulator took, which tells how (Via) and the name of the app in front (App, when known).

type HostScreenListParams added in v0.11.0

type HostScreenListParams struct {
	CDPPorts []int `json:"cdp_ports,omitempty"`
}

HostScreenListParams: CDPPorts are ports on 127.0.0.1 the app names by hand (each 1–65535), listed when they answer as CDP.

type HostScreenMissing added in v0.11.0

type HostScreenMissing struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

HostScreenMissing tells why a section cannot list anything.

type HostScreenNote added in v0.12.0

type HostScreenNote struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

HostScreenNote is a remark on a section, whatever it lists.

type HostScreenPage added in v0.11.0

type HostScreenPage struct {
	TargetID string `json:"target_id"`
	Title    string `json:"title"`
	URL      string `json:"url"`
}

HostScreenPage is one page target of a browser.

type HostScreenPoint added in v0.11.0

type HostScreenPoint struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
}

HostScreenPoint is a point of a drag, in fractions of the frame.

type HostScreenSection added in v0.11.0

type HostScreenSection[T any] struct {
	Items []T `json:"items"`
	// Missing: the tool that finds this kind is not installed, or failed.
	Missing *HostScreenMissing `json:"missing,omitempty"`
	// Note: why the section may lack targets the person sees running,
	// told even with items.
	Note *HostScreenNote `json:"note,omitempty"`
}

HostScreenSection is one kind's part of host_screen.list's result.

type HostScreenSimulatorItem added in v0.11.0

type HostScreenSimulatorItem struct {
	UDID string `json:"udid"`
	Name string `json:"name"`
	// Runtime is the readable runtime, e.g. "iOS 26.2".
	Runtime     string `json:"runtime"`
	Connectable bool   `json:"connectable"`
	Reason      string `json:"reason,omitempty"`
}

HostScreenSimulatorItem is one booted iOS simulator.

type HostScreenStartParams added in v0.11.0

type HostScreenStartParams struct {
	Target HostScreenTarget `json:"target"`
}

type HostScreenState added in v0.11.0

type HostScreenState struct {
	State string `json:"state"`
	Title string `json:"title,omitempty"`
	URL   string `json:"url,omitempty"`
}

HostScreenState: State is HostScreenLive or HostScreenGone; Title and URL are a page's.

type HostScreenTarget added in v0.11.0

type HostScreenTarget struct {
	Kind     string `json:"kind"`
	Port     int    `json:"port,omitempty"`
	TargetID string `json:"target_id,omitempty"`
	Serial   string `json:"serial,omitempty"`
	AVD      string `json:"avd,omitempty"`
	UDID     string `json:"udid,omitempty"`
}

HostScreenTarget names what host_screen.start shows: for a browser Port and TargetID, for an Android emulator Serial (and AVD, which tells the emulator again after a restart changed its serial), for an iOS simulator UDID.

type InputParams

type InputParams struct {
	ID     string   `json:"id"`
	Text   string   `json:"text,omitempty"`
	Paste  string   `json:"paste,omitempty"`
	Keys   []string `json:"keys,omitempty"` // names from KeySequences
	Submit bool     `json:"submit,omitempty"`
	// Local marks keyboard input of a terminal on the host (`stagent
	// attach`): it counts as Session.LastLocalInputAt and its focus
	// reports set Session.Focused. The app never sets it.
	Local bool `json:"local,omitempty"`
}

InputParams is applied in order: Text (raw), Paste (bracketed when the program enabled bracketed paste), Keys, then a CR if Submit.

type Message

type Message struct {
	Role     string `json:"role"` // user | assistant | tool | system
	Text     string `json:"text"`
	ToolName string `json:"tool_name,omitempty"`
	Time     int64  `json:"time,omitempty"` // unix ms
	// Ask is set on the rows of an agent's question to the user (Claude
	// Code's AskUserQuestion, omp's ask, Codex's request_user_input).
	Ask *Ask `json:"ask,omitempty"`
}

Message is one normalized conversation entry.

type Msg

type Msg struct {
	ID     *int64          `json:"id,omitempty"`
	Method string          `json:"method,omitempty"`
	Params json.RawMessage `json:"params,omitempty"`
	Result json.RawMessage `json:"result,omitempty"`
	Error  *Error          `json:"error,omitempty"`
}

Msg is the envelope. Requests carry ID+Method(+Params), responses ID and Result or Error, notifications Method(+Params) without ID.

func (*Msg) IsRequest

func (m *Msg) IsRequest() bool

IsRequest reports whether m expects a response.

func (*Msg) IsResponse

func (m *Msg) IsResponse() bool

IsResponse reports whether m answers an earlier request.

type NotificationData

type NotificationData struct {
	Title string `json:"title"`
	Body  string `json:"body"`
	Level string `json:"level"`
	// Reason: "waiting_input" | "needs_approval" | "turn_complete" |
	// "exited" | "terminal" (OSC/BEL from the program) | "test" | "digest" |
	// "schedule" (a run of a schedule: ScheduleID, RunID) | "usage_limit"
	// (a limit window: Harness, Window, ResetsAt).
	Reason string `json:"reason"`
	// Count > 1 for a digest folding several notifications together.
	Count int `json:"count,omitempty"`
	// Question: a waiting_input notification about a question the agent
	// asked (Session.Question); Body is its first question, with the
	// number of questions when there are several.
	Question bool `json:"question,omitempty"`
	// SessionID is the session the notification is about; absent for a
	// digest, notify.test and approvals of no session. ntfy's sequence ID
	// and the s= of the Click link are both made from it.
	SessionID string `json:"session_id,omitempty"`
	// TaskLabel names the session's task: "#N", or a named task's name
	// ("": none). Not part of the event: pushes title the notification
	// "<label> <title>" (see notify's labelled), a digest of several never.
	TaskLabel string `json:"-"`
	// ScheduleID and RunID: a notification of reason "schedule" is about
	// that run of that schedule (RunID absent when about the schedule:
	// stopped after failures). It has no SessionID; ntfy's sequence ID
	// and the chat message it replaces are the schedule's, and the links
	// carry sc=<schedule id> and r=<run id>.
	ScheduleID string `json:"schedule_id,omitempty"`
	RunID      string `json:"run_id,omitempty"`
	// Schedules: a digest folding some schedule's notification; its links
	// carry an empty sc= (the host's schedules). Not part of the event.
	Schedules bool `json:"-"`
	// Harness, Window and ResetsAt: a notification of reason
	// "usage_limit" is about that limit window (上限の枠, a UsageWindow*
	// id or "<minutes>m") of that agent's account (ConfigDir, not part of
	// the event), the window ending at ResetsAt (unix ms). It has no
	// SessionID; ntfy's sequence ID and the chat message it replaces are
	// the window's with its reset time, and the links carry u=<harness>.
	Harness   string `json:"harness,omitempty"`
	Window    string `json:"window,omitempty"`
	ResetsAt  int64  `json:"resets_at,omitempty"`
	ConfigDir string `json:"-"`
	// Usage: a digest folding some usage_limit notification; its links
	// carry an empty u= (the host's usage screen). Not part of the event.
	Usage bool `json:"-"`
}

NotificationData is Event.Data for notification — what the app shows and what offline push channels send. Body never contains terminal output.

type NotifyConfig

type NotifyConfig struct {
	Ntfy    NtfyConfig    `json:"ntfy"`
	Webhook WebhookConfig `json:"webhook"`
	Chat    ChatConfig    `json:"chat"`
	// DebounceMs: minimum stable time of a state before it notifies.
	DebounceMs int `json:"debounce_ms"`
	// DigestWindowMs: notifications within this window fold into one digest.
	DigestWindowMs int `json:"digest_window_ms"`
	// HostLabel prefixes the title of every push so the user can tell the
	// hosts apart; empty means the host name (no default is filled in).
	HostLabel string `json:"host_label"`
	// ClickBase is the link an ntfy push opens when tapped (ntfy's Click),
	// with h=<host_id> and, for one session, s=<session id> added to its
	// query; empty means no link. The app sets it; stagent knows no app
	// scheme.
	ClickBase string `json:"click_base"`
	// ClickPage is the open page (開くページ) the chat destination and the
	// generic webhook link to: an https URL, h=<host_id> and, for one
	// session, s=<session id> go into its fragment; empty means no link.
	ClickPage string `json:"click_page"`
	// Reasons selects what is pushed; in-app notification events are not
	// affected. Missing keys take the defaults (WithDefaults).
	Reasons NotifyReasons `json:"reasons"`
	// Lang is the language of the fixed phrases and digest titles that
	// stagent writes: en | ja | ko | zh (default en). Reasons stay as they
	// are.
	Lang string `json:"lang"`
	// SkipWhenClaudeAppNotifies: no pushes for a session whose latest hook
	// ran with CLAUDE_CODE_BRIDGE_SESSION_ID (the claude is connected to
	// Remote Control, so the Claude app notifies too).
	SkipWhenClaudeAppNotifies bool `json:"skip_when_claude_app_notifies"`
}

NotifyConfig configures offline push channels.

type NotifyFailure added in v0.4.0

type NotifyFailure struct {
	At     int64  `json:"at"`               // unix ms
	Status int    `json:"status,omitempty"` // HTTP status; 0 for a transport error
	Error  string `json:"error"`
	Kind   string `json:"kind,omitempty"` // Failure*, the chat destination only
}

NotifyFailure is the last failed push to one channel. Error never contains the ntfy topic, the webhook URL or the chat URL; for the chat destination it is the status line followed by the service's short reason (`404 Not Found: Unknown Webhook (10015)`).

type NotifyReasons added in v0.4.0

type NotifyReasons struct {
	NeedsApproval *bool `json:"needs_approval,omitempty"` // default true
	WaitingInput  *bool `json:"waiting_input,omitempty"`  // default true
	TurnComplete  *bool `json:"turn_complete,omitempty"`  // default true
	// Exited: off | error (only abnormal exits: a code other than 0 or a
	// lost session; default) | all.
	Exited   string `json:"exited,omitempty"`
	Terminal *bool  `json:"terminal,omitempty"` // default false
	// Schedule: the runs of schedules (default true), each as its
	// Schedule.Notify says.
	Schedule *bool `json:"schedule,omitempty"`
	// UsageLimit: a limit window (上限の枠) passing 80% and 100%, and
	// resetting after 100% (default true).
	UsageLimit *bool `json:"usage_limit,omitempty"`
}

NotifyReasons selects the notification reasons that are pushed. A nil bool or an empty Exited means the default.

type NotifyStatus added in v0.4.0

type NotifyStatus struct {
	// LastError holds, per channel ("ntfy", "webhook", "chat"), the last
	// failed push; a successful push to the channel removes it. Never null.
	LastError map[string]NotifyFailure `json:"last_error"`
}

NotifyStatus reports the push channels' health (config.get / config.set, `stagent doctor`).

type NotifyTestParams added in v0.8.0

type NotifyTestParams struct {
	Channels []string `json:"channels,omitempty"`
}

NotifyTestParams picks the channels notify.test pushes to (Channel*); none means every enabled channel.

type NtfyConfig

type NtfyConfig struct {
	Enabled bool   `json:"enabled"`
	Server  string `json:"server"` // default https://ntfy.sh
	Topic   string `json:"topic"`
	Token   string `json:"token,omitempty"`
}

NtfyConfig is an ntfy.sh (or self-hosted ntfy) topic.

type OutputParams

type OutputParams struct {
	ID    string `json:"id"`
	Data  []byte `json:"data"` // base64 in JSON
	Reset bool   `json:"reset,omitempty"`
	// End is the stream position after this chunk (raw mode; for a reset
	// snapshot the position the snapshot was taken at).
	End int64 `json:"end,omitempty"`
}

OutputParams carries terminal bytes to an attached client. When Reset is true the client must clear its terminal (screen + scrollback) and then write Data, which is a full ANSI snapshot of the current screen.

type PresenceSetParams added in v0.4.0

type PresenceSetParams struct {
	Foreground bool `json:"foreground"`
}

PresenceSetParams tells the daemon whether the app is in the foreground. While a connection with a live watch says so, the host pushes nothing (the app shows the events itself); a closed connection is not in the foreground.

type Question added in v0.20.0

type Question struct {
	// Tool is the harness's question tool, e.g. "AskUserQuestion".
	Tool      string         `json:"tool"`
	Questions []QuestionItem `json:"questions"`
}

Question is a choice question an agent asked through its question tool (claude's AskUserQuestion, Codex's request_user_input, omp's ask), read from the tool's input in the hook.

type QuestionItem added in v0.20.0

type QuestionItem struct {
	ID       string `json:"id,omitempty"` // the agent's id for it (omp, Codex)
	Header   string `json:"header,omitempty"`
	Question string `json:"question"`        // empty on a Codex answer (by id only)
	Multi    bool   `json:"multi,omitempty"` // several options may be chosen
	// Options are the option labels, as asked (Question, and an Ask's
	// question row where the transcript records them).
	Options []string `json:"options,omitempty"`
	// Answers: the options chosen and the text typed, in order (an Ask's
	// answer row only).
	Answers []string `json:"answers,omitempty"`
}

QuestionItem is one question of an agent's question tool call: of a Question (the live question, from the hook's tool input) and of an Ask (the transcript's question and answer rows, which add the answers).

type RelayClone added in v0.26.0

type RelayClone struct {
	Dir string `json:"dir,omitempty"`
}

RelayClone clones the package's RemoteURL into Dir ("" = the default place) before the task is made.

type RelayEnd added in v0.26.0

type RelayEnd struct {
	Host           *RelayHost `json:"host,omitempty"`
	Harness        string     `json:"harness"`
	ConversationID string     `json:"conversation_id,omitempty"`
	SessionID      string     `json:"session_id,omitempty"`
}

RelayEnd is a conversation at one end of a relay: its host (Peer only), harness, conversation id (empty until known) and session id.

type RelayErrorData added in v0.26.0

type RelayErrorData struct {
	RelayID string `json:"relay_id"`
}

RelayErrorData is the data of a relay.prepare error once the relay's id was made: the client sends relay.discard with it.

type RelayHost added in v0.26.0

type RelayHost struct {
	HostID string `json:"host_id,omitempty"`
	Label  string `json:"label"`
}

RelayHost names a host as the client knows it: HostID is its hello host_id (empty when it sent none), Label the name the client shows for it (its saved connection's).

type RelayLink struct {
	RelayID        string    `json:"relay_id"`
	At             int64     `json:"at"` // unix ms, when it was recorded
	Host           RelayHost `json:"host"`
	Harness        string    `json:"harness"`
	ConversationID string    `json:"conversation_id,omitempty"`
	SessionID      string    `json:"session_id,omitempty"`
}

RelayLink is the conversation at the other end of a relay, as Session and Conversation carry it.

type RelayLinks struct {
	Source *RelayLink `json:"source,omitempty"`
	Target *RelayLink `json:"target,omitempty"`
}

RelayLinks is a conversation's relay trace, one step each way: Source the conversation it was relayed from, Target the one it was last relayed to.

type RelayMemo added in v0.26.0

type RelayMemo struct {
	Status string `json:"status,omitempty"`
	Reason string `json:"reason,omitempty"`
}

RelayMemo says what came of the hand-off memo: Status RelayMemo*, Reason (skipped) RelayMemoNotLive or RelayMemoBusy. Not asked for: Status "".

type RelayParts added in v0.26.0

type RelayParts struct {
	DocumentBytes  int64 `json:"document_bytes"`
	Messages       int   `json:"messages"`
	Images         int   `json:"images"`
	ImageBytes     int64 `json:"image_bytes"`
	BundleCommits  int   `json:"bundle_commits"`
	BundleBytes    int64 `json:"bundle_bytes"`
	PatchBytes     int64 `json:"patch_bytes"`
	UntrackedFiles int   `json:"untracked_files"`
	UntrackedBytes int64 `json:"untracked_bytes"`
}

RelayParts is what a package holds, for the client to show: the document's bytes and messages, its images, the bundle's commits and bytes (0: nothing unpushed, or same_host), the patches' bytes and the untracked files' count and bytes.

type RelayPrepareParams added in v0.26.0

type RelayPrepareParams struct {
	SessionID      string    `json:"session_id,omitempty"`
	Harness        string    `json:"harness,omitempty"`
	ConversationID string    `json:"conversation_id,omitempty"`
	Target         string    `json:"target"`       // RelayTarget*
	SourceAgent    string    `json:"source_agent"` // RelaySource*
	SourceHost     RelayHost `json:"source_host"`
	Memo           bool      `json:"memo,omitempty"`
	MemoTimeoutMS  int       `json:"memo_timeout_ms,omitempty"`
	Instruction    string    `json:"instruction,omitempty"`
	Lang           string    `json:"lang,omitempty"`
}

RelayPrepareParams is relay.prepare on the relay source. The conversation is the live session SessionID's, else Harness's ConversationID. SourceHost is this host as the client names it (the document and the target's trace show Label). Memo asks the source agent for a hand-off memo, waiting MemoTimeoutMS at most (default RelayMemoTimeoutDefault, max RelayMemoTimeoutMax). Instruction is the target agent's first instruction ("" = the default one in Lang). Lang is the document's language (LangJa or LangEn; others and "" are LangEn).

type RelayPrepareResult added in v0.26.0

type RelayPrepareResult struct {
	RelayID string      `json:"relay_id"`
	Size    int64       `json:"size,omitempty"`
	SHA256  string      `json:"sha256,omitempty"`
	Source  RelaySource `json:"source"`
	Parts   RelayParts  `json:"parts"`
	Memo    RelayMemo   `json:"memo"`
}

RelayPrepareResult describes the package. Size and SHA256 (hex) are the package file's, for relay.read and relay.receive; both are absent for a same_host relay, whose package is never read. Parts tells what it holds.

type RelayProgressParams added in v0.26.0

type RelayProgressParams struct {
	RelayID string `json:"relay_id"`
	Stage   string `json:"stage"`
	Done    int64  `json:"done,omitempty"`
	Total   int64  `json:"total,omitempty"`
}

RelayProgressParams is the relay.progress notification: Stage (RelayStage*) began; Done and Total (bytes or items, both 0 when not counted) say how far it is.

type RelayReadParams added in v0.26.0

type RelayReadParams struct {
	RelayID  string `json:"relay_id"`
	Offset   int64  `json:"offset"`
	MaxBytes int    `json:"max_bytes,omitempty"`
}

RelayReadParams reads MaxBytes (default RelayChunkDefault, at most RelayChunkMax) of a prepared package from Offset.

type RelayReadResult added in v0.26.0

type RelayReadResult struct {
	Data []byte `json:"data"`
	EOF  bool   `json:"eof,omitempty"`
}

RelayReadResult: EOF is set when Data reaches the package's end.

type RelayReceiveParams added in v0.26.0

type RelayReceiveParams struct {
	RelayID string `json:"relay_id"`
	Size    int64  `json:"size"`
	SHA256  string `json:"sha256"`
}

RelayReceiveParams starts (or continues) taking a package of Size bytes whose SHA-256 is SHA256 (hex), as relay.prepare answered.

type RelayReceiveResult added in v0.26.0

type RelayReceiveResult struct {
	Received int64 `json:"received"`
}

RelayReceiveResult: Received is how many bytes are here already; the next relay.write starts there.

type RelayRecordParams added in v0.26.0

type RelayRecordParams struct {
	RelayID string   `json:"relay_id"`
	Role    string   `json:"role"` // RelayRole*
	Local   RelayEnd `json:"local"`
	Peer    RelayEnd `json:"peer"`
}

RelayRecordParams records one end of relay RelayID on this host's daemon: Local is the conversation here, which is the relay's Role, Peer the conversation at the other end. Recording the same RelayID and Role again fills in what was empty (a conversation id learned later).

type RelayRef added in v0.26.0

type RelayRef struct {
	RelayID string `json:"relay_id"`
}

RelayRef names a relay: RelayID is 32 lowercase hex chars, made by the source's relay.prepare and the same on both hosts.

type RelaySource added in v0.26.0

type RelaySource struct {
	Host           RelayHost `json:"host"`
	Harness        string    `json:"harness"`
	ConversationID string    `json:"conversation_id"`
	SessionID      string    `json:"session_id,omitempty"`
	Title          string    `json:"title,omitempty"`
	State          string    `json:"state,omitempty"` // the session's state when the conversation was read
	Cwd            string    `json:"cwd"`
	Repo           string    `json:"repo,omitempty"`
	CwdRel         string    `json:"cwd_rel,omitempty"`
	Remote         string    `json:"remote,omitempty"`
	RemoteURL      string    `json:"remote_url,omitempty"`
	Branch         string    `json:"branch,omitempty"`
	Head           string    `json:"head,omitempty"`
	Base           string    `json:"base,omitempty"`
	TaskID         string    `json:"task_id,omitempty"`
	Target         string    `json:"target"`       // RelayTarget*
	SourceAgent    string    `json:"source_agent"` // RelaySource*
	PreparedAt     int64     `json:"prepared_at"`  // unix ms
}

RelaySource is the relay source as the package's manifest records it. Repo is the source checkout (元のチェックアウト) of the repository Cwd is in: its main working tree (the first of `git worktree list`; the worktree Cwd is in when the main one is bare), canonical; "" when Cwd is no git checkout, and then the git members are empty. CwdRel is Cwd relative to the root of the worktree it is in ("" at the root, "/" separated). Remote names the remote RemoteURL is (the branch's upstream remote, else origin, else the first one; both "" without a remote). Branch is "" on a detached HEAD. Head is HEAD's commit; Base the newest commit of HEAD's history a remote-tracking ref has (Head when nothing is unpushed, "" when no remote has any of it). TaskID is the session's task on the source host.

type RelayStartParams added in v0.26.0

type RelayStartParams struct {
	RelayID    string            `json:"relay_id"`
	Harness    string            `json:"harness"`
	Model      string            `json:"model,omitempty"`
	Repo       string            `json:"repo,omitempty"`
	Clone      *RelayClone       `json:"clone,omitempty"`
	Name       string            `json:"name,omitempty"`
	Branch     string            `json:"branch,omitempty"`
	Cwd        string            `json:"cwd,omitempty"`
	TargetHost RelayHost         `json:"target_host"`
	Cols       int               `json:"cols"`
	Rows       int               `json:"rows"`
	Env        map[string]string `json:"env,omitempty"`
}

RelayStartParams is relay.start on the relay target. Harness is the agent to start, Model its model ("" = the harness's default). Repo is the source checkout to work from ("" = the one whose remote is the package's RemoteURL); Clone, sent after repo_missing, clones the remote first. Name and Branch are the new task's (default from the package's branch). Cwd is where the agent starts when the package has no git checkout ("" = home). TargetHost is this host as the client names it, for the source's trace.

type RelayStartResult added in v0.26.0

type RelayStartResult struct {
	Task     *Task   `json:"task,omitempty"`
	Session  Session `json:"session"`
	Document string  `json:"document"`
	Cloned   string  `json:"cloned,omitempty"`
}

RelayStartResult: Task is the task made for the relay (absent when the agent works in the source's own place or in Cwd), Session the agent's session (a task's prepared session), Document the relay document's absolute path, Cloned the clone made (Clone).

type RelayWriteParams added in v0.26.0

type RelayWriteParams struct {
	RelayID string `json:"relay_id"`
	Offset  int64  `json:"offset"`
	Data    []byte `json:"data"`
}

RelayWriteParams writes Data at Offset, which must be the bytes received so far.

type RelayWriteResult added in v0.26.0

type RelayWriteResult struct {
	Received int64 `json:"received"`
}

RelayWriteResult: Received is the bytes received so far.

type RemoveRefusal added in v0.19.0

type RemoveRefusal struct {
	Kind  string   `json:"kind"`
	Paths []string `json:"paths,omitempty"`
}

RemoveRefusal is one reason a worktree is not removed (確認に並ぶ断る 理由): unlike changes and sessions neither force nor stop_sessions overrides it; the user deals with it first. Kind says which (a RefusalKind; an app shows one it does not know by name, still refused), Paths what it is about (canonical).

type RepoConfig added in v0.10.0

type RepoConfig struct {
	// WorktreeInclude: git pathspec globs (`:(glob)`, from the checkout's
	// root) of gitignored files a new task worktree gets a copy of, on top
	// of the checkout's .worktreeinclude (コピーするファイル).
	WorktreeInclude []string `json:"worktree_include,omitempty"`
}

RepoConfig is one source checkout's settings.

type ResizeParams

type ResizeParams struct {
	ID   string `json:"id"`
	Cols int    `json:"cols"`
	Rows int    `json:"rows"`
	// Force lets the app take the size of a passthrough session.
	Force bool `json:"force,omitempty"`
}

type RetentionConfig

type RetentionConfig struct {
	EventsDays         int `json:"events_days"`
	EventsMax          int `json:"events_max"`
	ScrollbackDays     int `json:"scrollback_days"`
	ScrollbackTotalMiB int `json:"scrollback_total_mib"`
	// ScrollbackSessionMiB caps one session (segments of 1 MiB).
	ScrollbackSessionMiB int `json:"scrollback_session_mib"`
}

RetentionConfig bounds on-disk data.

type Schedule added in v0.17.0

type Schedule struct {
	ID   string `json:"id"` // 16 lowercase hex chars, given by the daemon
	Name string `json:"name"`
	Kind string `json:"kind"`
	// Command is the shell string a command schedule runs ($SHELL -c).
	Command string       `json:"command,omitempty"`
	Cwd     string       `json:"cwd"` // absolute
	When    ScheduleWhen `json:"when"`
	// TZ is the IANA time zone (Asia/Tokyo) the times are on.
	TZ        string `json:"tz"`
	State     string `json:"state"`
	CreatedAt int64  `json:"created_at"` // unix ms
	// Harness (claude, codex, omp), Prompt and Permission (Permission*;
	// "" is read) of an agent schedule.
	Harness    string `json:"harness,omitempty"`
	Prompt     string `json:"prompt,omitempty"`
	Permission string `json:"permission,omitempty"`
	// TimeoutMin is a run's time limit in minutes (omitted: 60; 0: none).
	// At it the run is sent terminate, kill 10 seconds later, and is
	// recorded as RunTimedOut.
	TimeoutMin *int `json:"timeout_min,omitempty"`
	// Retries (0–3) is how many times a run that failed or timed out is
	// run again, RetryDelayMin (1–60, omitted: 5) minutes after it ended.
	Retries       int `json:"retries,omitempty"`
	RetryDelayMin int `json:"retry_delay_min,omitempty"`
	// StopAfterFailures (0: never) pauses the schedule when that many of
	// its times in a row failed, their retries included.
	StopAfterFailures int `json:"stop_after_failures,omitempty"`
	// FailedInRow (how many of its times in a row failed) and AutoStopped
	// (it was paused for StopAfterFailures) are the daemon's: create and
	// update ignore them, resume clears them.
	FailedInRow int  `json:"failed_in_row,omitempty"`
	AutoStopped bool `json:"auto_stopped,omitempty"`
	// LastAt (unix ms) is the newest of its times the daemon dealt with
	// (ran, ran late, skipped), or when the times before stopped counting
	// (created, updated, resumed). Times of When after it that have come
	// are missed: the daemon runs them once, late. The daemon's alone.
	LastAt int64 `json:"last_at,omitempty"`
	// Notify is which of its runs are notified (ScheduleNotify*; "" is
	// problems), with reason "schedule"; notify.reasons.schedule off
	// notifies none of any schedule.
	Notify string `json:"notify,omitempty"`
	// ProblemSent: a problem of it was notified and no success since (the
	// next success is notified as fixed). The daemon's, like FailedInRow.
	ProblemSent bool `json:"problem_sent,omitempty"`
	// Extra holds the members this version does not know.
	Extra map[string]json.RawMessage `json:"-"`
}

Schedule is one schedule (定め) as schedules.json keeps it.

func (Schedule) MarshalJSON added in v0.17.0

func (s Schedule) MarshalJSON() ([]byte, error)

func (*Schedule) UnmarshalJSON added in v0.17.0

func (s *Schedule) UnmarshalJSON(b []byte) error

type ScheduleChanged added in v0.17.0

type ScheduleChanged struct {
	ID    string         `json:"id"`
	Entry *ScheduleEntry `json:"entry,omitempty"`
}

ScheduleChanged is schedule.changed: Entry is the schedule as schedule.list has it now, omitted when it was removed.

type ScheduleCreateParams added in v0.17.0

type ScheduleCreateParams struct {
	Schedule Schedule `json:"schedule"`
}

ScheduleCreateParams carries the schedule to create (schedule.create; id, state and created_at are the daemon's) or to preview.

type ScheduleEntry added in v0.17.0

type ScheduleEntry struct {
	Schedule Schedule `json:"schedule"`
	// NextAt is when it runs next, unix ms (omitted: never), NextOffset
	// the UTC offset in seconds of its tz then (omitted with NextAt).
	NextAt     int64 `json:"next_at,omitempty"`
	NextOffset *int  `json:"next_offset,omitempty"`
	// TZOffset is the UTC offset in seconds (east positive) of its tz now:
	// the app tells today from tomorrow on that wall clock.
	TZOffset int `json:"tz_offset"`
	// LastRun is its newest run (omitted: none yet).
	LastRun *ScheduleRun `json:"last_run,omitempty"`
	// RetryAt is when its newest run is run again (omitted: no retry
	// waits), unix ms.
	RetryAt int64 `json:"retry_at,omitempty"`
	// HostClock is the host's own clock at its next time, omitted when it
	// is its tz's.
	HostClock *HostClock `json:"host_clock,omitempty"`
}

ScheduleEntry is a schedule as schedule.list and schedule.create answer it.

type ScheduleListResult added in v0.17.0

type ScheduleListResult struct {
	Schedules []ScheduleEntry `json:"schedules"` // in the order they were created
}

type ScheduleOutputParams added in v0.17.0

type ScheduleOutputParams struct {
	ID        string `json:"id"`
	RunID     string `json:"run_id"`
	SessionID string `json:"session_id,omitempty"`
	// Before is an exclusive byte offset into the run's output stream;
	// 0 means "up to the latest byte".
	Before   int64 `json:"before,omitempty"`
	MaxBytes int   `json:"max_bytes,omitempty"` // default 256 KiB, max 1 MiB
}

ScheduleOutputParams names the run (ID: its schedule), which of its tries (SessionID: the try's session; omitted: its newest try) and the page of its output, as ScrollbackParams does.

type ScheduleOutputResult added in v0.17.0

type ScheduleOutputResult struct {
	ScrollbackResult
	Gone bool `json:"gone,omitempty"`
}

ScheduleOutputResult is a page of a run's output as session.scrollback answers it. Gone: the run's output is not kept (any more): retention deleted it, or the run had no session; Data is then empty, and the run's summary is what is left.

type SchedulePreview added in v0.17.0

type SchedulePreview struct {
	Argv []string `json:"argv"`
	Cwd  string   `json:"cwd"`
	Next []int64  `json:"next"` // the next three times, unix ms
	// NextOffsets are the UTC offsets in seconds of the tz at each of Next
	// (as long as Next), TZOffset the one now.
	NextOffsets []int             `json:"next_offsets"`
	TZOffset    int               `json:"tz_offset"`
	Warnings    []ScheduleWarning `json:"warnings"`
	// CwdKind is what Cwd is (CwdKind*; omitted when it is not there);
	// TaskID the task whose worktree it is.
	CwdKind string `json:"cwd_kind,omitempty"`
	TaskID  string `json:"task_id,omitempty"`
	// HostClock is the host's own clock at the first of Next, omitted
	// when it is the schedule's tz's.
	HostClock *HostClock `json:"host_clock,omitempty"`
}

SchedulePreview is what a schedule would run and when (schedule.preview).

type ScheduleRef added in v0.17.0

type ScheduleRef struct {
	ID string `json:"id"`
}

ScheduleRef names a schedule (schedule.pause, schedule.resume, schedule.run_now).

type ScheduleRemoveParams added in v0.17.0

type ScheduleRemoveParams struct {
	ID      string `json:"id"`
	StopRun bool   `json:"stop_run,omitempty"`
}

ScheduleRemoveParams: StopRun stops the schedule's running run (its session) before the schedule and its runs are removed; without it the run goes on, no longer recorded.

type ScheduleRun added in v0.17.0

type ScheduleRun struct {
	// RunID stays the same over the time's retries (the holder's --run).
	RunID       string `json:"run_id"`
	ScheduledAt int64  `json:"scheduled_at"` // unix ms: the time it was due
	Trigger     string `json:"trigger"`
	// Harness of an agent run.
	Harness string `json:"harness,omitempty"`
	// Cwd is the schedule's directory when the time started (absolute):
	// its runs and "continue this conversation" use it.
	Cwd string `json:"cwd,omitempty"`
	// Retries is the schedule's Retries when the time started (the m of
	// "retry n/m"; omitted: 0).
	Retries int `json:"retries,omitempty"`
	// TZOffset is the UTC offset in seconds (east positive) of the
	// schedule's tz at ScheduledAt; the app shows the run's times on that
	// wall clock.
	TZOffset int `json:"tz_offset"`
	// AutoStopped is how many of its times in a row had failed when this
	// one failing stopped the schedule (StopAfterFailures; omitted or 0:
	// it did not stop it).
	AutoStopped int `json:"auto_stopped,omitempty"`
	ScheduleTry
	// Tries are the tries before the newest, oldest first.
	Tries []ScheduleTry `json:"tries,omitempty"`
	// Extra holds the members this version does not know.
	Extra map[string]json.RawMessage `json:"-"`
}

ScheduleRun is one time of a schedule (a time that came, or run_now): one line of its schedule-runs/<id>.jsonl. Its retries go on in the same line: the newest try is ScheduleTry (its members flat in the line), the ones before it are Tries.

func (ScheduleRun) HasSession added in v0.17.0

func (r ScheduleRun) HasSession(sessionID string) bool

HasSession reports whether a try of r ran in session sessionID.

func (ScheduleRun) MarshalJSON added in v0.17.0

func (r ScheduleRun) MarshalJSON() ([]byte, error)

func (*ScheduleRun) UnmarshalJSON added in v0.17.0

func (r *ScheduleRun) UnmarshalJSON(b []byte) error

type ScheduleRunsParams added in v0.17.0

type ScheduleRunsParams struct {
	ID string `json:"id"`
}

type ScheduleRunsResult added in v0.17.0

type ScheduleRunsResult struct {
	Runs []ScheduleRun `json:"runs"` // newest first
}

type ScheduleTry added in v0.17.0

type ScheduleTry struct {
	// Retry is which retry (1…) of ScheduleRun.Retries it is (0: the first
	// try).
	Retry     int    `json:"retry,omitempty"`
	StartedAt int64  `json:"started_at"`
	EndedAt   int64  `json:"ended_at,omitempty"`
	Result    string `json:"result"`
	ExitCode  *int   `json:"exit_code,omitempty"`
	SessionID string `json:"session_id,omitempty"`
	// Error says why a try failed without an exit code (one line).
	Error string `json:"error,omitempty"`
	// Summary is the end of a try's output as plain text, kept for when
	// the output is gone: a command run's last 50 lines, an agent run's
	// last reply; at most 8 KiB.
	Summary string `json:"summary,omitempty"`
	// The agent's conversation (ConversationID) and how many of its
	// operations were refused (Denials) of an agent run. Unjudged: its
	// output could not be read, so the result is the exit code's alone.
	ConversationID string `json:"conversation_id,omitempty"`
	Denials        int    `json:"denials,omitempty"`
	Unjudged       bool   `json:"unjudged,omitempty"`
	// OutsideGUI: the try's holder was started outside the GUI login
	// session (macOS with nobody logged in to the desktop: launchd refused
	// the job in gui/<uid>), where claude cannot read its login from the
	// keychain. AuthFailed: the try failed because its agent could not log
	// in.
	OutsideGUI bool `json:"outside_gui,omitempty"`
	AuthFailed bool `json:"auth_failed,omitempty"`
}

ScheduleTry is one try of a time of a schedule: the first one, or a retry of it.

type ScheduleUpdateParams added in v0.17.0

type ScheduleUpdateParams struct {
	ID       string   `json:"id"`
	Schedule Schedule `json:"schedule"`
}

ScheduleUpdateParams replaces what schedule ID runs and when (schedule.update): name, kind, command, cwd, when and tz as Schedule carries them; its id, state and created_at stay. The last update wins.

type ScheduleWarning added in v0.17.0

type ScheduleWarning struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

type ScheduleWhen added in v0.17.0

type ScheduleWhen struct {
	Every string `json:"every"`
	// Time is "HH:MM" (daily, weekdays, weekly).
	Time string `json:"time,omitempty"`
	// Days are the weekdays of a weekly schedule, 0 Sunday … 6 Saturday.
	Days []int `json:"days,omitempty"`
	// Date is "YYYY-MM-DD" (once).
	Date string `json:"date,omitempty"`
	// Hours (1–23) and Minute (0–59) of an hours schedule.
	Hours  int `json:"hours,omitempty"`
	Minute int `json:"minute,omitempty"`
	// Cron is a cron schedule's expression ("0 3 1 * *").
	Cron string `json:"cron,omitempty"`
	// Extra holds the members this version does not know.
	Extra map[string]json.RawMessage `json:"-"`
}

ScheduleWhen is when a schedule runs (ScheduleWhen.Every).

func (ScheduleWhen) MarshalJSON added in v0.17.0

func (w ScheduleWhen) MarshalJSON() ([]byte, error)

func (*ScheduleWhen) UnmarshalJSON added in v0.17.0

func (w *ScheduleWhen) UnmarshalJSON(b []byte) error

type ScreenCheck added in v0.22.0

type ScreenCheck struct {
	Check     string          `json:"check"`
	Harness   string          `json:"harness"`
	Matched   bool            `json:"matched"`
	Rules     []ScreenRuleUse `json:"rules"`
	Lines     []ScreenLine    `json:"lines"`
	Signature string          `json:"signature,omitempty"`
}

ScreenCheck is one check of a screen as Harness draws it ("" any harness). Rules are the rules that matched, or for no match the rules of Harness that were tried; Lines the lines that matched (the options of a menu, a question UI's header and hint or its box's edges). Signature is a permission menu's (holder.prompt_watch).

type ScreenExplain added in v0.22.0

type ScreenExplain struct {
	Harness  string            `json:"harness"`
	RulesDir string            `json:"rules_dir"`
	Files    []ScreenRulesFile `json:"files"`
	Checks   []ScreenCheck     `json:"checks"`
}

ScreenExplain is what `stagent explain` reports: the checks the holder makes on a screen, read as Harness ("" for no harness in particular), with the rules that matched, and the override files of RulesDir.

type ScreenExplainParams added in v0.22.0

type ScreenExplainParams struct {
	ID      string `json:"id"`
	Harness string `json:"harness,omitempty"`
}

ScreenExplainParams asks a holder to explain its screen, read as Harness ("": as the harness the session runs).

type ScreenLine added in v0.22.0

type ScreenLine struct {
	Line int    `json:"line"`
	Text string `json:"text"`
}

ScreenLine is a line of the screen; Line 1 is the top row.

type ScreenRuleUse added in v0.22.0

type ScreenRuleUse struct {
	ID     string          `json:"id"`
	Origin string          `json:"origin"` // "builtin" or "override"
	File   string          `json:"file,omitempty"`
	Rule   json.RawMessage `json:"rule"`
}

ScreenRuleUse is one rule, "<name>.<rule>" (codex.question, common.menu), as Rule has it: built-in, or from the override File.

type ScreenRulesFile added in v0.22.0

type ScreenRulesFile struct {
	Path  string `json:"path"`
	Name  string `json:"name"`
	Used  bool   `json:"used"`
	Error string `json:"error,omitempty"`
}

ScreenRulesFile is an override file of the screen rules (`stagent explain`, `stagent doctor`): Name is the rules it overrides (common or a harness id); a file that is not Used keeps the built-in rules, Error says why.

type ScrollbackParams

type ScrollbackParams struct {
	ID string `json:"id"`
	// Before is an exclusive byte offset into the session's output stream;
	// 0 means "up to the latest byte".
	Before   int64 `json:"before,omitempty"`
	MaxBytes int   `json:"max_bytes,omitempty"` // default 256 KiB, max 1 MiB
}

type ScrollbackResult

type ScrollbackResult struct {
	Data  []byte `json:"data"`  // raw PTY bytes [Start, End)
	Start int64  `json:"start"` // stream offset of Data[0]
	End   int64  `json:"end"`
	// First is the oldest offset still retained; Start == First means the
	// client has reached the beginning.
	First int64 `json:"first"`
}

type Session

type Session struct {
	ID      string `json:"id"`
	Harness string `json:"harness"`
	// CommandHarness is the harness the session's command runs by itself
	// (harness.Command: for `stagent task run … -- <command>` the command
	// after "--"), HarnessOther for any other program. It differs from
	// Harness when hooks reassigned the session, e.g. an agent started
	// inside a kept shell.
	CommandHarness string   `json:"command_harness"`
	Command        []string `json:"command"`
	Cwd            string   `json:"cwd"`
	PID            int      `json:"pid"` // child (agent) pid
	HolderPID      int      `json:"holder_pid"`
	Mode           string   `json:"mode"`
	Attached       bool     `json:"attached"` // a session.attach client is attached (not passthrough's own terminal)
	State          string   `json:"state"`
	StateSource    string   `json:"state_source"`
	// StateSince is when the session entered its state (unix ms, host
	// clock), set by the daemon; omitted by daemons before it.
	StateSince     int64  `json:"state_since,omitempty"`
	Title          string `json:"title,omitempty"` // OSC 0/2 window title
	ConversationID string `json:"conversation_id,omitempty"`
	TranscriptPath string `json:"transcript_path,omitempty"`
	LastMessage    string `json:"last_message,omitempty"` // short, single line
	// Question is the choice question the agent waits on (omitted: none),
	// set with state waiting_input by the agent's question hook (claude's
	// AskUserQuestion, Codex's request_user_input, omp's ask) and dropped with that state: answered, the turn
	// moved on, or output activity took over.
	Question       *Question `json:"question,omitempty"`
	Cols           int       `json:"cols"`
	Rows           int       `json:"rows"`
	StartedAt      int64     `json:"started_at"`       // unix ms
	LastActivityAt int64     `json:"last_activity_at"` // unix ms, last PTY output
	// LastLocalInputAt is when a terminal on the host last typed anything
	// into the session, unix ms: the passthrough session's own terminal or
	// a `stagent attach` (session.input with local); 0 (omitted) until one
	// has. Terminal replies, focus and mouse reports do not count, nor does
	// the app's session.input.
	LastLocalInputAt int64 `json:"last_local_input_at,omitempty"`
	// LastInputAt is when input was last written to the program, unix ms:
	// any client's session.input or a terminal on the host; 0 (omitted)
	// until any was. Terminal replies, focus and mouse reports do not
	// count. Output activity ends a hook-derived needs_approval or
	// waiting_input only after it.
	LastInputAt int64 `json:"last_input_at,omitempty"`
	// Focused: one of those terminals last reported focus in (ESC [ I,
	// sent once the program enabled focus reporting) and not focus out
	// since. Terminals that report no focus leave it false.
	Focused bool `json:"focused,omitempty"`
	// PresenceFile is the holder's $CLAUDE_CLIENT_PRESENCE_FILE (omitted
	// when unset): while that file exists, someone is at the session.
	PresenceFile string `json:"presence_file,omitempty"`
	ExitCode     *int   `json:"exit_code,omitempty"`
	// TaskID is the task the session belongs to (omitted: none). The
	// daemon decides it: a worktree task's sessions are those whose cwd is
	// in its worktree; an in_place task's are its prepared session and the
	// ones session.spawn started with its task_id. A holder registers with
	// the task_id it was started with (`stagent run --task`).
	TaskID string `json:"task_id,omitempty"`
	// ScheduleID and RunID name the schedule run the session is (omitted:
	// none): the daemon started it (`stagent run --schedule --run`). The
	// app lists it under the schedule only, not among the kept shells or
	// the host's agents, and it belongs to no task.
	ScheduleID string `json:"schedule_id,omitempty"`
	RunID      string `json:"run_id,omitempty"`
	// Relay is the relay trace of the session's conversation (omitted:
	// none; CapRelay).
	Relay *RelayLinks `json:"relay,omitempty"`
}

Session is one PTY session held by a `stagent run` process.

type SessionEndParams added in v0.21.1

type SessionEndParams struct {
	ID     string `json:"id"`
	Signal string `json:"signal"`
}

SessionEndParams names the session session.end ends and the signal (SignalHangup, SignalTerminate or SignalKill) its program gets first.

type SessionEndedData

type SessionEndedData struct {
	ExitCode int `json:"exit_code"`
	// HungUp: the program ended after a client's session.signal hangup
	// (the app ending a kept shell) or, on Windows, after the console of a
	// passthrough session closed; not an abnormal exit.
	HungUp bool `json:"hung_up,omitempty"`
}

SessionEndedData is Event.Data for session_ended.

type SessionPatch

type SessionPatch struct {
	ID             string  `json:"id"`
	State          *string `json:"state,omitempty"`
	StateSource    *string `json:"state_source,omitempty"`
	Title          *string `json:"title,omitempty"`
	LastActivityAt *int64  `json:"last_activity_at,omitempty"`
	// LastLocalInputAt is pushed to watchers at once (the holder sends it at
	// most once per second), unlike last_activity_at.
	LastLocalInputAt *int64 `json:"last_local_input_at,omitempty"`
	// LastInputAt rides along with the next update; the holder sets it
	// before the input reaches the program, so it never comes after the
	// state that input's output brings.
	LastInputAt *int64  `json:"last_input_at,omitempty"`
	Cols        *int    `json:"cols,omitempty"`
	Rows        *int    `json:"rows,omitempty"`
	Mode        *string `json:"mode,omitempty"` // passthrough → detached on handoff
	Attached    *bool   `json:"attached,omitempty"`
	Focused     *bool   `json:"focused,omitempty"`
}

SessionPatch updates a registered session; nil fields are unchanged.

type SessionRef

type SessionRef struct {
	ID string `json:"id"`
}

SessionRef names a session.

type SessionStartedData

type SessionStartedData struct {
	Harness string   `json:"harness"`
	Command []string `json:"command"`
	Cwd     string   `json:"cwd"`
	Mode    string   `json:"mode"`
}

SessionStartedData is Event.Data for session_started.

type SessionsListResult

type SessionsListResult struct {
	Sessions []Session `json:"sessions"`
}

type SignalParams

type SignalParams struct {
	ID     string `json:"id"`
	Signal string `json:"signal"`
}

type SpawnParams

type SpawnParams struct {
	Command []string `json:"command"`
	// Shell runs the user's login shell instead of Command (which must then
	// be empty).
	Shell bool              `json:"shell,omitempty"`
	Cwd   string            `json:"cwd,omitempty"` // default home
	Cols  int               `json:"cols"`
	Rows  int               `json:"rows"`
	Env   map[string]string `json:"env,omitempty"`
	// TaskID ties the session to that task: the way to add a session to
	// an in_place task (a worktree task's sessions are those in its
	// worktree anyway). Unknown ids tie nothing.
	TaskID string `json:"task_id,omitempty"`
}

type SpawnResult

type SpawnResult struct {
	Session Session `json:"session"`
}

type StateChangedData

type StateChangedData struct {
	From   string `json:"from"`
	To     string `json:"to"`
	Source string `json:"source"`
}

StateChangedData is Event.Data for state_changed.

type StoppedAgent added in v0.21.0

type StoppedAgent struct {
	ID             string `json:"id"` // the old session's id
	Harness        string `json:"harness"`
	ConversationID string `json:"conversation_id"`
	Cwd            string `json:"cwd"`
	Title          string `json:"title,omitempty"`
	TaskID         string `json:"task_id,omitempty"`
	StartedAt      int64  `json:"started_at"` // unix ms, the old session's
	FoundAt        int64  `json:"found_at"`   // unix ms, when the daemon found it stopped
	Reason         string `json:"reason"`     // Stopped* above
}

StoppedAgent is an agent whose session went away under it. The list is ordered newest found_at first, then newest started_at.

type StoppedClaimParams added in v0.21.0

type StoppedClaimParams struct {
	ID        string `json:"id"`
	SessionID string `json:"session_id"`
}

StoppedClaimParams: SessionID is the id of the session the bridge is about to start.

type StoppedClaimResult added in v0.21.0

type StoppedClaimResult struct {
	Agent   *StoppedAgent `json:"agent,omitempty"`
	Session *Session      `json:"session,omitempty"`
}

StoppedClaimResult has Session when a live session already carries the conversation (start nothing), else Agent, now claimed for SessionID.

type StoppedRef added in v0.21.0

type StoppedRef struct {
	ID string `json:"id"`
}

StoppedRef names a stopped agent.

type StoppedResumeParams added in v0.21.0

type StoppedResumeParams struct {
	ID   string            `json:"id"`
	Cols int               `json:"cols"`
	Rows int               `json:"rows"`
	Env  map[string]string `json:"env,omitempty"`
}

type StoppedResumeResult added in v0.21.0

type StoppedResumeResult struct {
	Session Session `json:"session"`
	Existed bool    `json:"existed"`
}

StoppedResumeResult: Existed is set when a live session already carried the conversation (or an earlier resume of it started one) and nothing was started.

type StoppedUpdatedParams added in v0.21.0

type StoppedUpdatedParams struct {
	Stopped []StoppedAgent `json:"stopped"`
}

StoppedUpdatedParams is the stopped.updated notification.

type Task added in v0.10.0

type Task struct {
	ID     string `json:"id"`
	Repo   string `json:"repo"`
	Kind   string `json:"kind"` // TaskKind*
	Number int    `json:"number"`
	Name   string `json:"name,omitempty"` // kind name only (task.ValidName)
	Title  string `json:"title"`
	URL    string `json:"url"`
	Branch string `json:"branch"`
	Base   string `json:"base"`
	// Worktree is where the task is worked on; Repo itself when InPlace.
	Worktree string `json:"worktree"`
	// InPlace: the task uses the source checkout, no worktree of its own.
	InPlace   bool      `json:"in_place"`
	CreatedAt time.Time `json:"created_at"` // RFC 3339, whole seconds
	State     string    `json:"state"`      // Task* states
	Stage     string    `json:"stage,omitempty"`
	Error     string    `json:"error,omitempty"` // one line
	// SessionID is the session that prepares the task. Sessions are tied
	// to tasks by Session.TaskID, not by this.
	SessionID string `json:"session_id,omitempty"`
	// SetupPending (preparing, stage setup): the worktree's scripts.setup
	// is neither the source checkout's nor approved, and preparation waits
	// for task.setup to run or skip it (ADR 0023).
	SetupPending *TaskSetup `json:"setup_pending,omitempty"`
	// RelayID is the relay that made the task (relay.start; omitted:
	// none). relay.abort removes such a task while it is not ready.
	RelayID string `json:"relay_id,omitempty"`
}

Task is one task. Repo is the canonical path of the source checkout (task.Canonical); with Number (issue, pr) or Name (name) it is the task's key (task.SameKey). A named task has Number 0 and no Title or URL.

type TaskAwaitSetupParams added in v0.19.0

type TaskAwaitSetupParams struct {
	ID     string `json:"id"`
	Script string `json:"script"`
}

TaskAwaitSetupParams is the scripts.setup `stagent task run` waits on.

type TaskAwaitSetupResult added in v0.19.0

type TaskAwaitSetupResult struct {
	Run bool `json:"run"`
}

TaskAwaitSetupResult: Run, run the script; else skip it.

type TaskCopy added in v0.10.0

type TaskCopy struct {
	Path   string `json:"path"`
	Source string `json:"source"` // TaskSource*
	Bytes  int64  `json:"bytes"`
}

TaskCopy is a file or directory copied into the worktree. Path is relative to the checkout's root, with / separators.

type TaskCreateParams added in v0.10.0

type TaskCreateParams struct {
	Repo         string            `json:"repo"`
	Kind         string            `json:"kind"`
	Number       int               `json:"number"`
	Name         string            `json:"name,omitempty"`
	Title        string            `json:"title"`
	URL          string            `json:"url"`
	Base         string            `json:"base,omitempty"`
	Branch       string            `json:"branch,omitempty"`
	Command      []string          `json:"command,omitempty"`
	Cols         int               `json:"cols"`
	Rows         int               `json:"rows"`
	Env          map[string]string `json:"env,omitempty"`
	InPlace      bool              `json:"in_place,omitempty"`
	SwitchBranch bool              `json:"switch_branch,omitempty"`
	Setup        bool              `json:"setup,omitempty"`
}

TaskCreateParams is task.create: register the task (task.register) and start its prepared session, `stagent task run <id> -- <command…>`, in the task's place. Branch overrides an issue's default branch (<number>-<slug>) and a named task's (Name); a PR's is its head branch. Base defaults to the repository's default branch. Kind name takes Name instead of Number, Title and URL, needs config.json's worktree_folder and is never InPlace. An empty Command opens a terminal (the login shell; cmd.exe on Windows). SwitchBranch and Setup apply to in_place tasks only: a worktree task always gets its branch and setup.

type TaskCreateResult added in v0.10.0

type TaskCreateResult struct {
	Task    Task     `json:"task"`
	Session *Session `json:"session,omitempty"`
	Existed bool     `json:"existed"`
}

TaskCreateResult: Session is the prepared session started now (not Existed), or the live one of a task still preparing (Existed).

type TaskLink struct {
	Path string `json:"path"`
}

TaskLink is a shared directory: linked, not copied.

type TaskListResult added in v0.10.0

type TaskListResult struct {
	Tasks []Task `json:"tasks"`
}

type TaskPreviewParams added in v0.10.0

type TaskPreviewParams struct {
	Repo            string   `json:"repo"`
	WorktreeInclude []string `json:"worktree_include"`
	Name            string   `json:"name,omitempty"`
	Branch          string   `json:"branch,omitempty"`
}

TaskPreviewParams is task.preview. WorktreeInclude, when present (an empty list included), replaces the patterns saved in config.json for repo: an unsaved trial. Absent (null) uses the saved ones. Name, when not empty, asks whether a named task of repo could take it (and Branch, default Name, as its branch): TaskPreviewResult.NameProblem.

type TaskPreviewResult added in v0.10.0

type TaskPreviewResult struct {
	Repo        string     `json:"repo"`
	Copies      []TaskCopy `json:"copies"`
	Links       []TaskLink `json:"links"`
	Skipped     []TaskSkip `json:"skipped"`
	TotalBytes  int64      `json:"total_bytes"`
	Truncated   bool       `json:"truncated"`
	Setup       string     `json:"setup,omitempty"`
	OrcaError   string     `json:"orca_error,omitempty"`
	NameProblem string     `json:"name_problem,omitempty"`
}

TaskPreviewResult: what a new worktree of Repo (canonical) would get. Copies holds at most TaskPreviewRows rows (Truncated then), Skipped too; TotalBytes counts every copy. Setup is the source checkout's orca.yaml scripts.setup; OrcaError, one line, says that orca.yaml is unusable. NameProblem (TaskName*) is the first reason TaskPreviewParams.Name cannot be taken, omitted when it can or none was asked.

type TaskProgressParams added in v0.10.0

type TaskProgressParams struct {
	ID        string `json:"id"`
	Stage     string `json:"stage"`
	Error     string `json:"error,omitempty"`
	SessionID string `json:"session_id,omitempty"`
}

TaskProgressParams reports a stage. While preparing, stage agent without an error makes the task ready; an error makes it failed. Stage agent with an error from the task's prepared session (SessionID) fails a ready task too: the agent did not start. Stage stop or archive starts removing it (stop again while removing: busy); an error while removing takes it back to where it was, keeping the error and the stage. The connection that starts a removal carries it on until a removal stage with SessionID hands it to that session; when the one carrying it goes first, the task is back where it was with error interrupted.

type TaskRef added in v0.10.0

type TaskRef struct {
	ID string `json:"id"`
}

TaskRef names a task.

type TaskRegisterParams added in v0.10.0

type TaskRegisterParams struct {
	Repo      string `json:"repo"`
	Kind      string `json:"kind"`
	Number    int    `json:"number"`
	Name      string `json:"name,omitempty"`
	Title     string `json:"title"`
	URL       string `json:"url"`
	Branch    string `json:"branch"`
	Base      string `json:"base"`
	Worktree  string `json:"worktree"`
	InPlace   bool   `json:"in_place,omitempty"`
	SessionID string `json:"session_id"`
	// RelayID: the task is a relay's (relay.start), as Task.RelayID.
	RelayID string `json:"relay_id,omitempty"`
}

TaskRegisterParams adds a task (task.register). Repo and Worktree are canonical paths (task.Canonical, task.CanonicalPath); Worktree is ignored (Repo) when InPlace. SessionID is the session the caller starts to prepare the task unless the result says it existed.

type TaskRegisterResult added in v0.10.0

type TaskRegisterResult struct {
	Task    Task     `json:"task"`
	Existed bool     `json:"existed"`
	Session *Session `json:"session,omitempty"`
}

TaskRegisterResult: without Existed the caller starts the prepared session (TaskRegisterParams.SessionID) now — the task is new, or a failed or interrupted one is prepared again. With Existed nothing is to be started; Session is the live prepared session of a task still preparing, if any.

type TaskRemoveParams added in v0.10.0

type TaskRemoveParams struct {
	ID           string `json:"id"`
	Force        bool   `json:"force,omitempty"`
	StopSessions bool   `json:"stop_sessions,omitempty"`
	SkipArchive  bool   `json:"skip_archive,omitempty"`
	DryRun       bool   `json:"dry_run,omitempty"`
}

TaskRemoveParams is task.remove (片付け). DryRun only reports what is in the way; otherwise a refusal reason refuses it whatever the flags (refused), uncommitted changes need Force (not_clean) and live sessions StopSessions (busy). SkipArchive leaves scripts.archive out.

type TaskRemoveResult added in v0.10.0

type TaskRemoveResult struct {
	Refusals         []RemoveRefusal `json:"refusals,omitempty"`
	Changes          []string        `json:"changes,omitempty"`
	ChangesTruncated bool            `json:"changes_truncated,omitempty"`
	Unpushed         int             `json:"unpushed,omitempty"`
	Sessions         []string        `json:"sessions,omitempty"`
	KeptBranch       string          `json:"kept_branch,omitempty"`
}

TaskRemoveResult: a dry run reports Refusals (why it cannot be removed at all), Changes (the worktree's `git status --porcelain` lines: tracked changes and untracked files not ignored, at most TaskRemoveChangesMax, then ChangesTruncated), Unpushed (commits of the branch on no remote) and Sessions (ids of the task's live sessions). A removal reports KeptBranch.

type TaskRemoved added in v0.10.0

type TaskRemoved struct {
	ID         string `json:"id"`
	KeptBranch string `json:"kept_branch,omitempty"`
}

TaskRemoved is task.forget's params and the task.removed notification. KeptBranch is the task's branch that task.remove left: neither git nor gh found it merged, it moved after they did, or no git could run in its source checkout (omitted: deleted, or none).

type TaskSetup added in v0.19.0

type TaskSetup struct {
	Script string `json:"script"`
	Hash   string `json:"hash"`
}

TaskSetup is a scripts.setup waiting for the user: its text and its hash (hex SHA-256 of the text), which task.setup names.

type TaskSetupParams added in v0.19.0

type TaskSetupParams struct {
	ID   string `json:"id"`
	Hash string `json:"hash"`
	Run  bool   `json:"run,omitempty"`
}

TaskSetupParams decides the scripts.setup task ID waits on, named by its Hash: Run runs it (and approves that content for the task's source checkout, kept in <root>/state/setup-approvals.json), else it is skipped and the agent starts without it.

type TaskSkip added in v0.10.0

type TaskSkip struct {
	Entry  string `json:"entry"`
	Source string `json:"source"` // TaskSource*
	Reason string `json:"reason"` // TaskSkip*
}

TaskSkip is what is not copied, and why. Entry is the .worktreeinclude line or app pattern, or a path one of them selects.

type TranscriptGetParams

type TranscriptGetParams struct {
	SessionID      string `json:"session_id,omitempty"`
	Harness        string `json:"harness,omitempty"`
	ConversationID string `json:"conversation_id,omitempty"`
	Path           string `json:"path,omitempty"`
	Limit          int    `json:"limit,omitempty"` // default 50
	// Before is the cursor returned by a previous call (byte offset); 0 =
	// newest messages.
	Before int64 `json:"before,omitempty"`
}

TranscriptParams selects a transcript by live session, by conversation, or by path (in that order of precedence).

type TranscriptGetResult

type TranscriptGetResult struct {
	Path     string    `json:"path"`
	Harness  string    `json:"harness"`
	Messages []Message `json:"messages"` // oldest first
	// Cursor to pass as Before for older messages; 0 = beginning reached.
	Cursor int64 `json:"cursor"`
}

type TranscriptParams

type TranscriptParams struct {
	SessionID string    `json:"session_id,omitempty"`
	Path      string    `json:"path"`
	Messages  []Message `json:"messages"`
}

TranscriptParams is the "transcript" notification: new messages appended.

type TranscriptSubscribeParams

type TranscriptSubscribeParams struct {
	SessionID string `json:"session_id,omitempty"`
	Path      string `json:"path,omitempty"`
}

type UnwrappedLaunch added in v0.4.0

type UnwrappedLaunch struct {
	ConversationID string `json:"conversation_id"`
	Harness        string `json:"harness"`
	Cwd            string `json:"cwd"`
	Reason         string `json:"reason"`           // Unwrapped* below
	FirstSeenAt    int64  `json:"first_seen_at"`    // unix ms, the first hook
	LastActivityAt int64  `json:"last_activity_at"` // unix ms, the latest hook
}

UnwrappedLaunch is an agent started interactively on this host without a stagent session (GLOSSARY: このホストの agent に出ない起動), seen through its hooks. The daemon keeps these in memory only, one per conversation.

type UnwrappedUpdatedParams added in v0.4.0

type UnwrappedUpdatedParams struct {
	Unwrapped []UnwrappedLaunch `json:"unwrapped"`
}

UnwrappedUpdatedParams is the unwrapped.updated notification.

type UsageChanged added in v0.19.0

type UsageChanged struct {
	Scanning  bool  `json:"scanning"`
	ScannedAt int64 `json:"scanned_at,omitempty"`
}

UsageChanged is the usage.changed notification.

type UsageConfig added in v0.19.0

type UsageConfig struct {
	// PrivateAPI: also call the harness's undocumented usage API (非公開
	// API) for its limit windows (default off for both).
	PrivateAPI UsagePrivateAPI `json:"private_api"`
}

UsageConfig configures the measuring of the limit windows.

type UsageConversations added in v0.24.0

type UsageConversations struct {
	Date  string `json:"date"` // YYYY-MM-DD in UsageGetParams.TZ
	Count int    `json:"count"`
}

UsageConversations is the number of conversations of one calendar day.

type UsageDailyRow added in v0.24.0

type UsageDailyRow struct {
	Date    string `json:"date"` // YYYY-MM-DD in UsageGetParams.TZ
	Harness string `json:"harness"`
	UsageTokens
}

UsageDailyRow is the usage of one calendar day by one harness.

type UsageDay added in v0.19.0

type UsageDay struct {
	Date    string `json:"date"` // YYYY-MM-DD in UsageGetParams.TZ
	Harness string `json:"harness"`
	Model   string `json:"model"`
	Project string `json:"project"`
	UsageTokens
	// LongContext: the part of UsageTokens whose requests had a prompt
	// over each threshold of UsageLongContextThresholds, smallest first;
	// thresholds no request was over are left out.
	LongContext []UsageLongContext `json:"long_context,omitempty"`
}

UsageDay is the usage of one calendar day by one harness, model and project (the working directory the agent ran in).

type UsageGetParams added in v0.19.0

type UsageGetParams struct {
	// TZ is the IANA time zone whose calendar days the usage is summed
	// by ("Asia/Tokyo"; empty: UTC).
	TZ string `json:"tz,omitempty"`
	// From and To are the first and last calendar day (YYYY-MM-DD, in TZ)
	// to report, both included; empty leaves that end open.
	From string `json:"from,omitempty"`
	To   string `json:"to,omitempty"`
	// RefreshLimits: the usage screen (使用量の画面) was opened, so the
	// private API is called for the limit windows of each harness it is on
	// for (usage.private_api) unless it was called within the last
	// 5 minutes or has to wait (PROTOCOL.md "Private API"). Ignored from a
	// coding agent's process tree.
	RefreshLimits bool `json:"refresh_limits,omitempty"`
	// Daily: return Daily (one row per day and harness) instead of Days
	// and Sessions, which come back empty, so even all time stays small.
	Daily bool `json:"daily,omitempty"`
}

UsageGetParams selects the days usage.get reports.

type UsageGetResult added in v0.19.0

type UsageGetResult struct {
	// Scanning: the first scan since the daemon started has not finished,
	// so the numbers can still grow.
	Scanning bool `json:"scanning"`
	// ScannedAt is when the last scan finished (unix ms; 0: never).
	ScannedAt int64 `json:"scanned_at,omitempty"`
	// Counted are the harnesses whose usage is counted; the others' are
	// not counted yet.
	Counted []string `json:"counted"`
	// Days: one row per day, harness, model and project with any usage,
	// oldest day first.
	Days []UsageDay `json:"days"`
	// Sessions: the conversations that spent the most tokens in the days
	// asked for, at most UsageTopSessions, most first.
	Sessions []UsageSession `json:"sessions"`
	// Limits are the limit windows measured so far, one item per account
	// (harness order of the registry, then ConfigDir).
	Limits []UsageLimits `json:"limits"`
	// Conversations: per day, how many conversations (a harness and a
	// non-empty session id) spent tokens that day, oldest first; days
	// with none are left out. Always present (empty: []).
	Conversations []UsageConversations `json:"conversations"`
	// Daily: only for UsageGetParams.Daily, one row per day and harness
	// summed over models and projects, oldest day first.
	Daily []UsageDailyRow `json:"daily,omitempty"`
}

UsageGetResult is the usage counted so far.

type UsageLimitError added in v0.19.0

type UsageLimitError struct {
	Code    string `json:"code"`    // UsageErr*
	Message string `json:"message"` // English, for logs; never holds a token
	At      int64  `json:"at"`      // when it failed (unix ms)
	// RetryAt is when the API is called again at the earliest (unix ms).
	RetryAt int64 `json:"retry_at,omitempty"`
}

UsageLimitError is the last failed private API call for a limit window.

type UsageLimitWindow added in v0.19.0

type UsageLimitWindow struct {
	Window string `json:"window"` // UsageWindow*
	// Label names the quota group of a scoped window as the harness wrote
	// it (Antigravity's "Claude and GPT models"); absent otherwise.
	Label string `json:"label,omitempty"`
	// UsedPercent is the share of the window's limit used (0–100); absent
	// when Reset.
	UsedPercent *float64 `json:"used_percent,omitempty"`
	// ResetsAt is when the window starts over (unix ms).
	ResetsAt int64 `json:"resets_at"`
	// Source is how it was measured (UsageSource*).
	Source string `json:"source"`
	// MeasuredAt is when the value was measured (unix ms): when the daemon
	// received it (statusline), or the time of the event (codex_rollout).
	MeasuredAt int64 `json:"measured_at"`
	// Reset: ResetsAt has passed, so the value measured before it no longer
	// holds and is not returned.
	Reset bool `json:"reset,omitempty"`
	// Error is the last failure of the private API for this window's
	// account, while usage.private_api is on for it and no call succeeded
	// since; the value above (if any) is the last one measured. A window
	// with only an error has no UsedPercent, ResetsAt 0, MeasuredAt 0.
	Error *UsageLimitError `json:"error,omitempty"`
}

UsageLimitWindow is the last measurement of one limit window.

type UsageLimits added in v0.19.0

type UsageLimits struct {
	Harness   string `json:"harness"`
	ConfigDir string `json:"config_dir"`
	// Plan is the account's plan when the harness tells it (Codex
	// plan_type: "plus", "pro").
	Plan    string             `json:"plan,omitempty"`
	Windows []UsageLimitWindow `json:"windows"`
}

UsageLimits are the limit windows of one account: a harness and its configuration directory.

type UsageLongContext added in v0.19.0

type UsageLongContext struct {
	Over int64 `json:"over"`
	UsageTokens
}

UsageLongContext is the usage of the requests whose prompt was over Over tokens (a request over a larger threshold is in every smaller one too).

type UsagePrivateAPI added in v0.19.0

type UsagePrivateAPI struct {
	Claude bool `json:"claude"`
	Codex  bool `json:"codex"`
}

UsagePrivateAPI says which harnesses' private API is called.

func (UsagePrivateAPI) On added in v0.19.0

func (p UsagePrivateAPI) On(h string) bool

On reports whether the private API is on for harness h.

type UsageReportParams added in v0.19.0

type UsageReportParams struct {
	// ConfigDir is the account the windows belong to: Claude Code's
	// configuration directory ($CLAUDE_CONFIG_DIR, else ~/.claude) as a
	// clean absolute path.
	ConfigDir      string `json:"config_dir"`
	SessionID      string `json:"session_id,omitempty"`
	TranscriptPath string `json:"transcript_path,omitempty"`
	// RateLimits is the statusLine input's rate_limits object, verbatim.
	RateLimits json.RawMessage `json:"rate_limits"`
}

UsageReportParams is usage.report: what one run of Claude Code's statusLine gave, as it gave it (harness claude, source statusline).

type UsageSession added in v0.19.0

type UsageSession struct {
	Harness   string `json:"harness"`
	SessionID string `json:"session_id"`
	// Project is the working directory most of its tokens were spent in.
	Project string `json:"project"`
	// First and Last are the times of its first and last counted request
	// (unix ms).
	First  int64    `json:"first"`
	Last   int64    `json:"last"`
	Models []string `json:"models"`
	UsageTokens
	Total int64 `json:"total"` // UsageTokens.Total
}

UsageSession is the usage of one conversation within the days asked for.

type UsageTokens added in v0.19.0

type UsageTokens struct {
	Input     int64 `json:"input"`
	Output    int64 `json:"output"`
	CacheRead int64 `json:"cache_read"`
	// CacheWrite5m and CacheWrite1h are the tokens written to the prompt
	// cache with a 5-minute and a 1-hour lifetime.
	CacheWrite5m int64 `json:"cache_write_5m"`
	CacheWrite1h int64 `json:"cache_write_1h"`
	Requests     int64 `json:"requests"`
	// AgentCost is the cost in US dollars the agent itself wrote for these
	// requests (omp and pi: each message's cost.total; 0 for the others,
	// which write none).
	AgentCost float64 `json:"agent_cost,omitempty"`
}

UsageTokens are the counts of one row: the tokens of each kind and the model requests they came from.

func (UsageTokens) Total added in v0.19.0

func (t UsageTokens) Total() int64

Total is every token of t: input, output, cache reads and cache writes.

type WatchParams

type WatchParams struct {
	// Since is the last event seq the client has seen; events after it are
	// returned in Missed. 0 replays nothing.
	Since int64 `json:"since"`
}

type WatchResult

type WatchResult struct {
	Sessions  []Session  `json:"sessions"`
	Approvals []Approval `json:"approvals"`
	// Unwrapped: agents started without a stagent session, newest
	// last_activity_at first; unwrapped.updated replaces the list.
	Unwrapped []UnwrappedLaunch `json:"unwrapped"`
	// Tasks: every task, in the order they were created; task.updated and
	// task.removed follow the changes.
	Tasks []Task `json:"tasks"`
	// Stopped: the stopped agents (Linux and macOS; empty elsewhere),
	// newest found_at first; stopped.updated replaces the list. Older
	// stagent versions omit it.
	Stopped []StoppedAgent `json:"stopped"`
	Seq     int64          `json:"seq"` // latest seq at subscription time
	Missed  []Event        `json:"missed"`
	// Truncated: events between Since and Missed[0] were dropped by retention.
	Truncated bool `json:"truncated"`
}

type WebhookConfig

type WebhookConfig struct {
	Enabled bool              `json:"enabled"`
	URL     string            `json:"url"`
	Headers map[string]string `json:"headers,omitempty"`
}

WebhookConfig posts NotificationData JSON to a URL.

type WorktreeEntry added in v0.18.0

type WorktreeEntry struct {
	Path   string `json:"path"`             // canonical
	Branch string `json:"branch,omitempty"` // absent: detached
	Head   string `json:"head,omitempty"`   // the commit checked out
	// Missing: its directory is gone (git's prunable). Listing never
	// prunes it.
	Missing    bool   `json:"missing,omitempty"`
	Locked     bool   `json:"locked,omitempty"`
	LockReason string `json:"lock_reason,omitempty"`
	// TaskID: the task (not in_place) whose worktree this is.
	TaskID string `json:"task_id,omitempty"`
	// Sessions: ids of the live sessions whose cwd is inside it, or of
	// TaskID's task.
	Sessions []string `json:"sessions,omitempty"`
	// Changes counts task.Changes' lines (0 when Missing); Unpushed is
	// task.Unpushed of Branch.
	Changes  int `json:"changes"`
	Unpushed int `json:"unpushed"`
	// Merged: git finds Head merged into its task's base or the default
	// branch (task.Merged: squash and rebase merges too).
	Merged bool `json:"merged"`
	// Refusals: why worktree.remove would refuse it whatever the flags,
	// as its dry run lists them (nested_worktrees).
	Refusals []RemoveRefusal `json:"refusals,omitempty"`
}

WorktreeEntry is one linked worktree.

type WorktreeFolder added in v0.18.0

type WorktreeFolder struct {
	Path string `json:"path"`
	Repo string `json:"repo"`
}

WorktreeFolder is a folder of the worktree folder that is no worktree (置き場のほかのフォルダ): <folder>/<x>, or <folder>/<repo name>/<y> with Repo that name.

type WorktreeFolderTop added in v0.18.0

type WorktreeFolderTop struct {
	Name  string `json:"name"`
	Bytes int64  `json:"bytes"`
	Dir   bool   `json:"dir"`
}

WorktreeFolderTop is one entry directly in a folder, by disk usage.

type WorktreeListResult added in v0.18.0

type WorktreeListResult struct {
	// WorktreeFolder is config.json's worktree_folder (canonical); absent
	// when none is set.
	WorktreeFolder string           `json:"worktree_folder,omitempty"`
	WatchFolders   []string         `json:"watch_folders"`
	Repos          []WorktreeRepo   `json:"repos"`
	Folders        []WorktreeFolder `json:"folders"`
}

WorktreeListResult is the host's inventory (目録). Repos are in the order of their source checkout's path, Folders in path order.

type WorktreePR added in v0.18.0

type WorktreePR struct {
	Path   string `json:"path"`
	Number int    `json:"number"`
	State  string `json:"state"` // MERGED | OPEN | CLOSED
	URL    string `json:"url"`
	Merged bool   `json:"merged"`
}

WorktreePR is the pull request of a worktree's branch. Merged: State MERGED with the pull request's head the worktree's own commit (the rule task.remove deletes a branch by).

type WorktreePRsResult added in v0.18.0

type WorktreePRsResult struct {
	PRs []WorktreePR `json:"prs"`
}

WorktreePRsResult lists the pull requests gh found for the worktrees' branches of the repositories with a GitHub remote.

type WorktreeRemoveParams added in v0.18.0

type WorktreeRemoveParams struct {
	Path         string `json:"path"`
	Force        bool   `json:"force,omitempty"`
	StopSessions bool   `json:"stop_sessions,omitempty"`
	DryRun       bool   `json:"dry_run,omitempty"`
}

WorktreeRemoveParams is worktree.remove. DryRun only reports; otherwise a worktree's refusal reasons refuse it whatever the flags (refused), its uncommitted changes need Force (not_clean) and its live sessions StopSessions (busy).

type WorktreeRemoveResult added in v0.18.0

type WorktreeRemoveResult struct {
	Refusals         []RemoveRefusal     `json:"refusals,omitempty"`
	Changes          []string            `json:"changes,omitempty"`
	ChangesTruncated bool                `json:"changes_truncated,omitempty"`
	Unpushed         int                 `json:"unpushed,omitempty"`
	Sessions         []string            `json:"sessions,omitempty"`
	KeptBranch       string              `json:"kept_branch,omitempty"`
	Bytes            int64               `json:"bytes,omitempty"`
	Entries          []WorktreeFolderTop `json:"entries,omitempty"`
	RemovedParent    string              `json:"removed_parent,omitempty"`
}

WorktreeRemoveResult: a worktree's dry run reports Refusals, Changes (at most TaskRemoveChangesMax, then ChangesTruncated), Unpushed and Sessions, as task.remove's; a folder's, Bytes and its largest Entries. A removal reports KeptBranch, and RemovedParent when <worktree folder>/<repo name> was left empty and went too.

type WorktreeRepo added in v0.18.0

type WorktreeRepo struct {
	Path string `json:"path"` // canonical
	Name string `json:"name"` // base name of Path
	// DefaultBranch: absent when it cannot be told (task.DefaultBranch).
	DefaultBranch string `json:"default_branch,omitempty"`
	// GitHub: a remote's URL is on github.com; worktree.prs asks gh.
	GitHub    bool            `json:"github"`
	Worktrees []WorktreeEntry `json:"worktrees"`
}

WorktreeRepo is one repository: its source checkout (元のチェックアウト, the main worktree) and its linked worktrees in git's order (the source checkout itself is not one of them).

type WorktreeSize added in v0.18.0

type WorktreeSize struct {
	Path       string    `json:"path"`
	Bytes      int64     `json:"bytes"`
	ModifiedAt time.Time `json:"modified_at,omitzero"`
}

WorktreeSize is the disk usage of one of them, a worktree or source checkout inside it excluded, and its newest modification time (UTC, whole seconds; absent when nothing could be read).

type WorktreeSizesResult added in v0.18.0

type WorktreeSizesResult struct {
	Entries []WorktreeSize `json:"entries"`
	Total   int64          `json:"total"`
}

WorktreeSizesResult measures the source checkouts, the worktrees whose directory is there and the folders. Total adds the worktrees' and the folders' bytes, not the source checkouts'.

type WorktreeWatchParams added in v0.18.0

type WorktreeWatchParams struct {
	Add    string `json:"add,omitempty"`
	Remove string `json:"remove,omitempty"`
}

WorktreeWatchParams adds a watch folder (Add: ~ expanded, an existing directory) or removes one (Remove).

type WorktreeWatchResult added in v0.18.0

type WorktreeWatchResult struct {
	WatchFolders []string `json:"watch_folders"`
}

WorktreeWatchResult is config.json's worktree_watch afterwards.

Jump to

Keyboard shortcuts

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