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
- Variables
- func AgentArgv(argv []string) []string
- func NewSessionID() string
- func ProgramName(argv0 string) string
- func ValidExited(v string) bool
- func ValidLang(lang string) bool
- type Approval
- type ApprovalResolvedData
- type ApprovalsListResult
- type AttachParams
- type AttachResult
- type Blocked
- type ChatConfig
- type ClosedParams
- type Codec
- func (c *Codec) Encode(v any) error
- func (c *Codec) Notify(method string, params any) error
- func (c *Codec) Read() (*Msg, error)
- func (c *Codec) ReadLine() ([]byte, error)
- func (c *Codec) Reply(id *int64, result any) error
- func (c *Codec) ReplyError(id *int64, e *Error) error
- func (c *Codec) Request(id int64, method string, params any) error
- func (c *Codec) Write(m *Msg) error
- type Config
- type ConfigResult
- type ConfigSetParams
- type Conversation
- type ConversationsListParams
- type ConversationsListResult
- type DaemonStatus
- type Error
- type Event
- type GitHubActivityParams
- type GitHubActivityResult
- type GitHubRepo
- type GitHubReposResult
- type GitHubStatusItem
- type GitHubStatusParams
- type GitHubStatusQuery
- type GitHubStatusResult
- type HelloParams
- type HelloResult
- type HolderNotifyParams
- type HolderPromptGoneParams
- type HolderPromptWatchParams
- type HolderRegisterResult
- type HookEventParams
- type HostScreenAckParams
- type HostScreenBrowserItem
- type HostScreenEmulatorItem
- type HostScreenFrame
- type HostScreenInput
- type HostScreenInputResult
- type HostScreenListParams
- type HostScreenMissing
- type HostScreenNote
- type HostScreenPage
- type HostScreenPoint
- type HostScreenSection
- type HostScreenSimulatorItem
- type HostScreenStartParams
- type HostScreenState
- type HostScreenTarget
- type InputParams
- type Message
- type Msg
- type NotificationData
- type NotifyConfig
- type NotifyFailure
- type NotifyReasons
- type NotifyStatus
- type NotifyTestParams
- type NtfyConfig
- type OutputParams
- type PresenceSetParams
- type RepoConfig
- type ResizeParams
- type RetentionConfig
- type ScrollbackParams
- type ScrollbackResult
- type Session
- type SessionEndedData
- type SessionPatch
- type SessionRef
- type SessionStartedData
- type SessionsListResult
- type SignalParams
- type SpawnParams
- type SpawnResult
- type StateChangedData
- type Task
- type TaskCopy
- type TaskCreateParams
- type TaskCreateResult
- type TaskLink
- type TaskListResult
- type TaskPreviewParams
- type TaskPreviewResult
- type TaskProgressParams
- type TaskRef
- type TaskRegisterParams
- type TaskRegisterResult
- type TaskRemoveParams
- type TaskRemoveResult
- type TaskRemoved
- type TaskSkip
- type TranscriptGetParams
- type TranscriptGetResult
- type TranscriptParams
- type TranscriptSubscribeParams
- type UnwrappedLaunch
- type UnwrappedUpdatedParams
- type WatchParams
- type WatchResult
- type WebhookConfig
Constants ¶
const ( ErrBadRequest = "bad_request" ErrUnknownMethod = "unknown_method" ErrNotFound = "not_found" ErrUnsupported = "unsupported" ErrInternal = "internal" 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. ErrBusy = "busy" // 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" )
Stable error codes.
const ( MethodGitHubRepos = "github.repos" MethodGitHubActivity = "github.activity" MethodGitHubStatus = "github.status" // CapGitHub (Windows only): the github.* methods. CapGitHub = "github" )
const ( GHReady = "ready" GHMissing = "missing" GHUnauthenticated = "unauthenticated" )
gh states of GitHubActivityResult.
const ( GitHubKindIssue = "issue" GitHubKindPR = "pr" )
Kinds of github.status items.
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 )
const ( HostScreenBrowser = "browser" HostScreenAndroid = "android" HostScreenIOS = "ios" )
Target kinds of HostScreenTarget and keys of host_screen.list's result.
const ( HostScreenLive = "live" HostScreenGone = "gone" )
host_screen.state values.
const ( ToolAgentBrowser = "agent-browser" ToolPlaywrightMCP = "playwright-mcp" ToolChromeDevToolsMCP = "chrome-devtools-mcp" ToolPlaywright = "playwright" )
Tool names of HostScreenBrowserItem, told apart by the profile path.
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.
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.
const ( InputTap = "tap" InputDrag = "drag" InputScroll = "scroll" InputText = "text" InputKey = "key" )
HostScreenInput types (host_screen.input's type).
const ( KeyBack = "back" KeyHome = "home" KeyRecents = "recents" )
HostScreenInput keys (type key): Android's and iOS's buttons.
const ( )
HostScreenInput actions (type navigate): a browser's.
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).
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 )
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.
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.
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.
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" // 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). MethodHookEvent = "hook.event" // HookEventParams → {} // 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 a claude or Codex approval of // the session is pending (on), 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. MethodHolderPromptWatch = "holder.prompt_watch" )
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 // 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" // Notifications (daemon → app), like unwrapped.updated. NotifyTaskUpdated = "task.updated" // Task: added or changed NotifyTaskRemoved = "task.removed" // TaskRemoved )
Task methods (see PROTOCOL.md).
const ( TaskKindIssue = "issue" TaskKindPR = "pr" TaskKindName = "name" // tied to Task.Name, no Issue or PR; never in_place )
Task kinds.
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 TaskRemoving = "removing" // task.remove is under way )
Task states.
const ( TaskStageFetch = "fetch" TaskStageBranch = "branch" TaskStageWorktree = "worktree" TaskStageCopy = "copy" TaskStageSetup = "setup" TaskStageAgent = "agent" TaskStageStop = "stop" TaskStageArchive = "archive" )
Task stages: fetch … agent while preparing, stop … branch while removing (worktree and branch name a step of both).
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.
const ( TaskSourceInclude = "include" // the source checkout's .worktreeinclude TaskSourceApp = "app" // config.json repos.<repo>.worktree_include )
Where a copy comes from.
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.
const ( StateWorking = "working" StateIdle = "idle" StateWaitingInput = "waiting_input" StateNeedsApproval = "needs_approval" StateExited = "exited" )
Session states.
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.
const ( HarnessClaude = "claude" HarnessCodex = "codex" HarnessOmp = "omp" HarnessOther = "other" )
Harness ids. The harnesses stagent knows are listed by the harness registry (internal/harness); HarnessOther is any other program.
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.
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.
const ( EventSessionStarted = "session_started" EventSessionEnded = "session_ended" EventStateChanged = "state_changed" EventNotification = "notification" EventApprovalRequested = "approval_requested" EventApprovalResolved = "approval_resolved" )
Event kinds.
const ( LevelInfo = "info" LevelWarn = "warn" )
Notification levels.
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).
const ( ExitedOff = "off" ExitedError = "error" ExitedAll = "all" )
NotifyReasons.Exited values.
const ( LangEn = "en" LangJa = "ja" LangKo = "ko" LangZh = "zh" )
Languages of notify.lang.
const ( ChannelNtfy = "ntfy" ChannelWebhook = "webhook" ChannelChat = "chat" )
Push channel names (keys of NotifyStatus.LastError, notify.test's channels).
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.
const CapHostScreenIOS = "host_screen_ios"
CapHostScreenIOS (macOS only): host_screen.list has an ios section and host_screen.start serves the ios kind.
const EnvSessionID = "STAGENT_SESSION_ID"
EnvSessionID is exported to the agent process so hooks can name the PTY session they belong to.
const EnvShellWrapper = "STAGENT_SHELL_WRAPPER"
EnvShellWrapper is the marker the shell wrapper's rc block exports.
const HostScreenPipeOnly = "pipe_only"
HostScreenPipeOnly is the Reason of a browser started with --remote-debugging-pipe only: it opened no port to connect to.
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.
const NoteWSL = "wsl"
NoteWSL: the host is a Linux inside Windows' WSL, which sees neither the browsers nor the emulators on the Windows side.
const TaskErrInterrupted = "interrupted"
TaskErrInterrupted is Task.Error of a task whose prepared session went away (or never registered) before it got ready.
const TaskPreviewRows = 500
TaskPreviewRows caps TaskPreviewResult.Copies and Skipped.
const TaskRemoveChangesMax = 200
TaskRemoveChangesMax caps TaskRemoveResult.Changes.
Variables ¶
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, }
DaemonMethods are forwarded by the bridge to the daemon.
var ErrTooLong = errors.New("wire: message exceeds MaxLine")
ErrTooLong is returned by Read for a line over MaxLine.
var GitHubMethods = map[string]bool{ MethodGitHubRepos: true, MethodGitHubActivity: true, MethodGitHubStatus: true, }
GitHubMethods are served by the bridge on hosts announcing CapGitHub.
var HolderMethods = map[string]bool{ MethodSessionAttach: true, MethodSessionDetach: true, MethodSessionInput: true, MethodSessionResize: true, MethodSessionScrollback: true, MethodSessionSignal: true, MethodSessionInfo: true, }
HolderMethods are forwarded by the bridge to the session's holder.
var HostScreenMethods = map[string]bool{ MethodHostScreenList: true, MethodHostScreenStart: true, MethodHostScreenAck: true, MethodHostScreenStop: true, MethodHostScreenPause: true, MethodHostScreenResume: true, MethodHostScreenInput: true, }
HostScreenMethods are served by the bridge itself.
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.
Functions ¶
func AgentArgv ¶ added in v0.10.0
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; argv itself otherwise.
func NewSessionID ¶
func NewSessionID() string
NewSessionID returns a random 16-hex-char id (paths.sessionIDLen).
func ProgramName ¶ added in v0.15.0
ProgramName is the lower-case base name of argv0 without a Windows program extension.
func ValidExited ¶ added in v0.4.0
ValidExited reports whether v is a notify.reasons.exited value ("" = 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 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
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 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 (*Codec) Encode ¶
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) Read ¶
Read decodes the next message. Blank lines are skipped. A trailing '\r' is tolerated so CRLF-translating transports still work.
func (*Codec) ReadLine ¶
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) ReplyError ¶
ReplyError answers request id with an error.
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"`
}
Config is the daemon configuration. Zero values mean "default".
func (Config) WithDefaults ¶
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"`
}
Conversation is one stored conversation of a harness (conversations.list).
type ConversationsListParams ¶
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 ¶
Error is a protocol-level failure. Code is a stable machine-readable string (see the Err* constants); Message is for humans.
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 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
HolderPromptGoneParams reports that the permission menu watch Gen saw is no longer on the screen: the prompt was answered somewhere.
type HolderPromptWatchParams ¶ added in v0.4.0
type HolderPromptWatchParams struct {
ID string `json:"id"`
Gen int64 `json:"gen"`
On bool `json:"on"`
}
HolderPromptWatchParams starts (on) or ends a prompt watch. Gen names the watch; a new one starts with every claude or Codex approval registered.
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 (claude -p / --print; codex exec / e; omp -p /
// --print or --mode other than text). 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 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
HostScreenMissing tells why a section cannot list anything.
type HostScreenNote ¶ added in v0.12.0
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
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
}
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) IsResponse ¶
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".
Reason string `json:"reason"`
// Count > 1 for a digest folding several notifications together.
Count int `json:"count,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:"-"`
}
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
}
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 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 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 ScrollbackParams ¶
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"`
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
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"`
// 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"`
}
Session is one PTY session held by a `stagent run` process.
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"`
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 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 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 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"`
}
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 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 ¶ added in v0.10.0
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.
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"`
}
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 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 {
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 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
TaskRemoved is task.forget's params and the task.removed notification. KeptBranch is the task's branch that task.remove left: not merged, or gh could not tell (omitted: deleted, or none).
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 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 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 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"`
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"`
}