Documentation
¶
Overview ¶
Package agents holds what the coding agents the runtime drives (Claude Code in internal/agents/claude, Codex in internal/agents/codex) have in common: the session a pane runs, the work-state events their hooks translate to, the snapshot of a transcript's tail, the stats of a finished turn, and the pieces of a launch line.
Index ¶
- Constants
- Variables
- func AnyShellQuote(s string) string
- func AppendArgs(line, args string) string
- func ArgvNames(argv []string, word string) bool
- func AsStr(v any) string
- func BareAgentArgs(content, panelType string) (string, bool)
- func CheckLaunch(l *Launch) error
- func ClaudeSubscriptionToken(v string) bool
- func Decode(data []byte) (any, error)
- func DisplayName(provider string) string
- func EnvFile(dir, scope string) string
- func EnvSourcePrefix(dir, provider string) string
- func FindBinary(name string) string
- func ForAnyShell(line string) string
- func FormatStartEnv(env []EnvVar, keyPrefix string) (string, error)
- func InitialPromptText(prompt string) string
- func IsKnownEffort(e string) bool
- func IsLaunchModelID(profile, model string) bool
- func IsProfileModelID(s string) bool
- func IsUUID(s string) bool
- func JSString(v any) string
- func LauncherModel(l *Launch) string
- func Lines(b []byte) [][]byte
- func LiveDirs(p proc.Procs, binary, env string) []string
- func MillisSince(now, t time.Time) float64
- func NotificationNeedsInput(notificationType string) bool
- func PanelOf(provider string) string
- func PrintfQuote(s string) string
- func PromptFromFile(file string) string
- func ProviderOfPanel(panelType string) string
- func ReadTail(f *os.File, size, n int64) ([]byte, error)
- func ResolvePromptFiles(provider string, files []string, dataDir, dataDirDisplay string) ([]string, error)
- func Sections(out string) map[string]string
- func SessionIDFromTranscript(jsonlPath string) string
- func SetLineDir(dir string)
- func ShellQuote(s string) string
- func SplitLauncherModel(s string) (profile, model string)
- func Stringify(v any) string
- func Truthy(v any) bool
- func UnwrapAnyShell(line string) (string, bool)
- func WithInitialPrompt(provider, command, prompt, promptFile string) string
- func WriteLongPrompt(dir, text string) (string, error)
- type ActiveApps
- type AgentState
- type AppLauncher
- type AppsDropper
- type ClaudeApps
- type CodexAppServer
- type CodexApps
- type CodexProfile
- type Counts
- type CurrentAction
- type EnvVar
- type Event
- type EventKind
- type HistoryEntry
- type HistoryStats
- type HostMCPLauncher
- type LRU
- type Launch
- func ReadLaunchShape(model, effort any) (*Launch, bool)
- func ReadProfileLaunchShape(profile string, model, effort any) (*Launch, bool)
- func WithActiveApps(l *Launch, apps AppLauncher) *Launch
- func WithLaunchableApps(l *Launch, apps AppLauncher) *Launch
- func WithoutApps(l *Launch, apps AppLauncher, why error) *Launch
- type LaunchableApps
- type LoginRunner
- type Match
- type Obj
- type ProfileLauncher
- type Recovered
- type RecoveryDeps
- type SessionInfo
- type SessionStatus
- type Snapshot
- type TabAgent
- type TabReader
- type Unavailable
Constants ¶
const ( Claude = "claude" Codex = "codex" ClaudePanel = "claude-code" CodexPanel = "codex-cli" )
Provider ids and panel types.
const ( // EnvScopeAll is for every agent: delivered secrets, an all-agents proxy. EnvScopeAll = "all" // EnvDirName is the folder in the agent's data folder. EnvDirName = "agent-env" )
The env files the machine agent keeps for the agent CLIs (docs/hub/machine.md): keys and secrets the person gave through the hub, and the proxy. A launch line sources them first, so the CLI sees them and nothing else needs the person's shell profile.
const ( // MaxInitialPrompt caps an initial prompt, in UTF-16 units. MaxInitialPrompt = 20_000 // InlinePromptMax: a longer prompt is not typed into the shell (a 16 KB typed line stalled zsh) but read from a file. InlinePromptMax = 2_000 )
const MaxProfileModelID = 128
MaxProfileModelID caps a profile model id.
const StartEnvLimit = 8
StartEnvLimit is the most entries a launch's environment prefix may have.
const StartPromptFilesLimit = 4
StartPromptFilesLimit is the most instruction files a launch may add.
Variables ¶
var ( ErrLaunchModel = errors.New("Invalid launch model") ErrLaunchEffort = errors.New("Invalid launch effort") ErrLaunchProfile = errors.New("Invalid launch profile") ErrLaunchApps = errors.New("Invalid launch apps") ErrLaunchMode = errors.New("Invalid launch permission mode") )
var AppIDRe = regexp.MustCompile(`^[a-z0-9][a-z0-9-]{0,39}\.[a-z0-9][a-z0-9-]{0,39}$`)
AppIDRe: an app id goes into file names and the launch line, so it stays this strict (internal/apps checks the same).
var Efforts = []string{"none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra", "ultracode"}
Efforts are every reasoning level the CLIs know, weakest first.
var ErrNoApps = errors.New("Apps are not available on this machine")
ErrNoApps: a launch names apps and this machine has none.
var HookEventKinds = []EventKind{SessionStart, PromptSubmit, Notification, Stop, StopFailure, Interrupt, PreCompact, PostCompact}
HookEventKinds are the events a hook may name: the state machine maps session-start → idle, prompt-submit → busy, notification → needs-input (when NotificationNeedsInput), stop and stop-failure → ready-for-review, interrupt → idle, the compact pair → the compacting flag only.
var ModelIDRe = regexp.MustCompile(`^[a-z0-9][a-z0-9._-]{0,63}(\[1m\])?$`)
ModelIDRe: a model id is typed into a shell, so it stays this strict (aliases, full ids, the [1m] suffix).
var ProfileIDRe = regexp.MustCompile(`^[a-z][a-z0-9-]{0,31}$`)
ProfileIDRe: a profile id is typed into a shell too.
var ProfileModelIDRe = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}(/[A-Za-z0-9][A-Za-z0-9._:-]{0,63}){0,3}(\[1m\])?$`)
ProfileModelIDRe is a model of a vendor profile: routed backends name their models «vendor/model» («zai/glm-5.3», «openrouter/moonshotai/Kimi-K2»), with capitals and an «:tag». Still no shell metacharacter: up to four parts of [A-Za-z0-9._:-] joined by «/», each starting with a letter or a digit, and every launch line single-quotes it (ShellQuote) or passes it as one argv entry. A catalog model (no profile) stays ModelIDRe.
Functions ¶
func AnyShellQuote ¶ added in v0.16.15
AnyShellQuote quotes s as one word that sh, bash, zsh and fish all read back as s: single-quoted runs, with each `'` and `\` outside the quotes as `\'` and `\\` (fish reads `\'` and `\\` inside single quotes as escapes, sh does not). s must have no control characters: a newline would end the typed line.
func AppendArgs ¶ added in v0.16.15
AppendArgs puts args (sh words) at the end of the command of a launch line, wrapped by ForAnyShell or not.
func ArgvNames ¶
ArgvNames tells whether word is in the program's file name or the interpreted script's path.
func AsStr ¶
AsStr is v when it is a string, else "" (JavaScript's `typeof v === 'string' ? v : ”`).
func BareAgentArgs ¶
BareAgentArgs: text sent to an agent tab that is a bare `claude …` (`codex …`) for the tab's own agent is replaced by the platform's launch line plus these arguments. False when the text is not such a command.
func CheckLaunch ¶
CheckLaunch re-checks a stored choice right before it becomes shell text: a bad value stops the launch.
func ClaudeSubscriptionToken ¶
ClaudeSubscriptionToken says whether a value is the token of a Claude subscription's sign-in and not a key of the API. A machine has one sign-in by a subscription, the CLI's own: such a token is never taken as the key or a variable of a provider, which would be a second one. It is told by its shape, whatever address the provider has: an address may be a proxy's.
func Decode ¶
Decode parses one JSON text as JSON.parse does (whitespace around it allowed, nothing else), objects as *Obj, numbers as float64.
func DisplayName ¶
DisplayName is how the platform names an agent CLI.
func EnvFile ¶ added in v0.16.5
EnvFile is the path of a scope's env file in dir: all.env, claude.env, codex.env.
func EnvSourcePrefix ¶ added in v0.16.5
EnvSourcePrefix is what goes before a launch line so the CLI starts with the env files of dir: `set -a; . 'all.env'; . 'claude.env'; set +a; `, for the files that exist; "" when none does (or dir is empty), so a machine that never met the hub starts its agents exactly as before. Later files win, so an agent's own proxy beats the shared one.
func FindBinary ¶ added in v0.16.5
FindBinary is the sh snippet that sets $bin to the agent CLI: on the PATH, else where the installers put it (~/.local/bin). Empty when there is none.
func ForAnyShell ¶ added in v0.16.15
ForAnyShell is a launch line written for sh (an optional EnvSourcePrefix, then `VAR=value… command args`) as a line any interactive shell runs the same way: `sh -c '…; exec env VAR=value… command args'`. The command is exec'd, so the pane's foreground process is the agent's CLI (what tells a running agent, #{pane_current_command}) and not sh, and the person's shell is back when the agent exits.
func FormatStartEnv ¶
FormatStartEnv renders `KEY='value' ` per entry, in order. Keys must be keyPrefix followed by 1-40 of [A-Z_]; values need no quoting. The error is the message for the caller (a 400).
func InitialPromptText ¶
InitialPromptText is the prompt as it is passed: trimmed and capped.
func IsLaunchModelID ¶
IsLaunchModelID is the model check of a launch: a profile's model may be namespaced, a catalog model may not.
func IsProfileModelID ¶
IsProfileModelID is a model id a vendor profile may name.
func IsUUID ¶
IsUUID: session ids the CLIs accept for a resume (and the only ones typed into a shell).
func LauncherModel ¶ added in v0.15.46
LauncherModel is the model of a launch as the Codex launcher script is told it. The script forwards `--model` to the runtime whatever it is, and the one a platform ships does not know of profiles, so a chat on a backend profile names the profile in front of the model («xai/grok-build-0.1»); SplitLauncherModel reads it back where the runtime builds Codex's arguments. A model on the CLI's own account is told as it is.
func Lines ¶
Lines splits text read from a transcript into its non-blank lines (JavaScript's split('\n') kept where trim() leaves something); invalid UTF-8 reads as U+FFFD as Node's decoder makes it.
func LiveDirs ¶ added in v0.16.123
LiveDirs are the folders the running processes of the CLI named binary were told to keep their state in by the variable env (CLAUDE_CONFIG_DIR, CODEX_HOME): what the runtime's or the agent's own environment says need not be what the person's shell gave the CLI. Processes of other accounts do not show their environment and are skipped.
func MillisSince ¶
MillisSince is the age of t in milliseconds as Date.now() - mtimeMs counts it.
func NotificationNeedsInput ¶
NotificationNeedsInput: only a notification asking for permission (or one without a type) needs the person; the others (idle reminders, auth, elicitation…) change nothing.
func PrintfQuote ¶ added in v0.16.15
PrintfQuote is s as one sh word that keeps every character, newlines and control characters too, on one typed line: `"$(printf %b '…')"` with the escapes printf's %b reads. ($'…' would do in bash and zsh, but not in dash or fish.) $(…) drops trailing newlines, so s is a trimmed prompt.
func PromptFromFile ¶
PromptFromFile is the shell argument that reads a prompt file once and deletes it.
func ProviderOfPanel ¶
ProviderOfPanel is the agent a tab's panel type runs, "" for a panel that runs none (a terminal).
func ResolvePromptFiles ¶
func ResolvePromptFiles(provider string, files []string, dataDir, dataDirDisplay string) ([]string, error)
ResolvePromptFiles checks instruction files for a launch: Claude only, at most StartPromptFilesLimit, each an absolute path that resolves (symlinks followed) to a regular file inside dataDir. dataDirDisplay names dataDir in the messages (`~/.<name>`). The error is the message for the caller (a 400).
func Sections ¶ added in v0.16.5
Sections splits what a probe script printed into the parts it labelled: a line that starts with "HL-" begins a part, named by that word (without the "HL-"), whose body is what follows up to the next label, trimmed. Text before the first label is dropped.
func SessionIDFromTranscript ¶
SessionIDFromTranscript is the session a Claude transcript belongs to: its file name, when that is a UUID. A tab that lost its stored id but kept its transcript path still knows its session.
func SetLineDir ¶ added in v0.16.86
func SetLineDir(dir string)
SetLineDir names the folder long launch lines wait in. It must be one the wall of a chat with apps hides (the data folder's own, off the seal's list, internal/apps/seal.go): an agent that could write a waiting line would run outside its wall. Without it long lines are typed whole.
func SplitLauncherModel ¶ added in v0.15.46
SplitLauncherModel is the profile and the model of a model as the launcher script sent it; a plain model has no profile.
func UnwrapAnyShell ¶ added in v0.16.15
UnwrapAnyShell is the sh line ForAnyShell wrapped; false when line is not one it wrote.
func WithInitialPrompt ¶
WithInitialPrompt appends the initial prompt to a launch line: `-- <arg>` for Claude, `--prompt <arg>` for the Codex launcher. promptFile, when set, is where WriteLongPrompt put a long prompt.
func WriteLongPrompt ¶
WriteLongPrompt writes a prompt too long to type (over InlinePromptMax units of the text InitialPromptText gives) to a private file initial-<uuid>.txt in dir; "" when the prompt goes inline.
Types ¶
type ActiveApps ¶
ActiveApps is what a launcher may say about the apps a launch names: which of them are installed and on now. A chat whose app was removed, or one started in safe mode, starts with what is left — with none left, as a chat with no apps at all, wall included.
type AgentState ¶
type AgentState struct {
ProviderID string `json:"providerId"`
SessionID *string `json:"sessionId"`
JSONLPath *string `json:"jsonlPath"`
Summary *string `json:"summary"`
}
AgentState is the agent part of a layout tab (`tab.agentState`).
type AppLauncher ¶ added in v0.16.42
type AppLauncher interface {
// Claude is what a Claude Code chat with the apps adds: settingsPath is the `--settings` file the launch would use
// without them, which the apps' file extends.
Claude(ids []string, settingsPath string) (ClaudeApps, error)
// ClaudeFor is Claude for the launch of a known chat: the launch's record names it.
ClaudeFor(conversation string, ids []string, settingsPath string) (ClaudeApps, error)
// Codex is what a Codex chat with the apps adds: the same rules and wall as Claude's, given the way Codex takes
// them (`-c` flags on the launch line, never a file the agent could edit).
Codex(conversation string, ids []string) (CodexApps, error)
}
AppLauncher gives a launch with apps what it needs of them. Nil on a machine without apps: such a launch fails.
type AppsDropper ¶
AppsDropper is told of the apps a chat starts without, and why: the app's log and the machine's journal say so.
type ClaudeApps ¶ added in v0.16.42
type ClaudeApps struct {
// Settings replaces the --settings file: the one the launch had, with the app-guard hook.
Settings string
// PluginDirs are the apps' packages, each loaded with --plugin-dir (skills, commands, .mcp.json).
PluginDirs []string
// PromptFile is the apps' instructions joined, appended to the system prompt; "" for none.
PromptFile string
// MCPConfig is a second --mcp-config file: the host's app tools as the server harnessly-app; "" for none.
MCPConfig string
// RuntimeMCPConfig replaces the runtime's own --mcp-config: the same server with the launch's token in place of
// the person's; "" keeps the runtime's.
RuntimeMCPConfig string
// Wrap are shell words the CLI runs under (the operating system's wall around the apps, internal/apps/boundary.go),
// put between the launch's environment and the CLI; "" runs it as it is.
Wrap string
// Env are `VAR='value'` shell words the CLI gets after the launch's own environment (the agent's token file,
// HARNESSLY_CLI_TOKEN_FILE); "" for none.
Env string
// Retoken copies an MCP config of the runtime's (one that carries the person's token in its headers) with the
// launch's token in its place, and gives the copy's path; nil when the launch has no token of its own.
Retoken func(mcpConfigPath string) (string, error)
}
ClaudeApps is what the apps of a Claude Code chat add to its launch.
type CodexAppServer ¶ added in v0.16.154
type CodexAppServer struct {
// Name is the server's name in Codex's config (plugin_<plugin>_<server>, the name the rules read from a tool).
Name string
// URL is a remote server's address; Command, Args and Env a local one's process.
URL, Command string
Args []string
Env, Headers map[string]string
// TokenHeaders are headers that carry the launch's token: they read it from the CLI's environment, so it is on no
// command line.
TokenHeaders []string
}
CodexAppServer is one MCP server of an app as Codex is told about it.
type CodexApps ¶ added in v0.16.154
type CodexApps struct {
// Guard is the PreToolUse hook command line (`harnessly hook app-guard --policy <file> --agent codex`); it goes first
// among the event's hooks.
Guard string
// Servers are the apps' MCP servers, each a `-c mcp_servers.<name>.*` set.
Servers []CodexAppServer
// Instructions are the apps' instructions and the list of their skills, joined; "" for none. They go with the
// workspace's developer instructions.
Instructions string
// TokenFile holds the launch's own token; the CLI gets it in place of the person's in the variable the runtime's MCP
// config names ("" keeps the person's, a test).
TokenFile string
// Env are `VAR='value'` shell words the CLI gets, Wrap the shell words it runs under (the wall); both "" for none.
Env, Wrap string
}
CodexApps is what the apps of a Codex chat add to its launch.
type CodexProfile ¶ added in v0.15.46
type CodexProfile struct {
// Args are the `-c` flags that make the profile Codex's model provider.
Args []string
// KeyEnv is the variable Codex reads the key from, KeyFile the file the key is in. The pane's shell fills the variable
// from the file (`VAR="$(cat file)"`), so the key is not in the line that is typed.
KeyEnv, KeyFile string
// Home, when set, is the CODEX_HOME the chat runs with: another sign-in of the CLI (internal/codexaccounts). The
// launch line sets it for this one command.
Home string
}
CodexProfile is what a Codex chat on a profile adds to the launch.
type Counts ¶
type Counts struct {
// contains filtered or unexported fields
}
Counts are counts by name, written in the order the names were first counted (JavaScript's object order).
func (Counts) MarshalJSON ¶
MarshalJSON writes {name: count} in order.
func (*Counts) UnmarshalJSON ¶
UnmarshalJSON reads {name: count}, keeping the order.
type CurrentAction ¶
CurrentAction is what the agent is doing now: a tool call (ToolName set) or the text it is writing.
func Tool ¶
func Tool(name, summary string) *CurrentAction
Tool is a current action for a tool call.
type EnvVar ¶
type EnvVar struct{ Key, Value string }
EnvVar is one entry of a launch's environment prefix.
type Event ¶
type Event struct {
Kind EventKind `json:"kind"`
// NotificationType of a notification, "" when the hook gave none.
NotificationType string `json:"notificationType,omitempty"`
// Summary of a summary-update (nil clears it); Message of a last-user-message.
Summary *string `json:"summary,omitempty"`
Message string `json:"message,omitempty"`
// AgentSession is the agent's own session id a hook named, "" when it named none (a hook script of an older
// runtime). A Claude run from the tab's terminal (a script, or the agent itself calling `claude -p`) inherits the
// tab's tmux session and hooks: only this tells its hooks from those of the tab's agent.
AgentSession string `json:"-"`
// PromptHash of a prompt-submit names the prompt the agent took (screen.MessageHash), "" when the hook did not say
// (Codex, a Claude started before its hook carried it).
PromptHash string `json:"-"`
}
Event is one work-state event.
type EventKind ¶
type EventKind string
EventKind is a work-state event an agent's hooks (or the runtime's own watchers) report.
const ( SessionStart EventKind = "session-start" PromptSubmit EventKind = "prompt-submit" Notification EventKind = "notification" Stop EventKind = "stop" StopFailure EventKind = "stop-failure" Interrupt EventKind = "interrupt" PreCompact EventKind = "pre-compact" PostCompact EventKind = "post-compact" SummaryUpdate EventKind = "summary-update" LastUserMsg EventKind = "last-user-message" )
type HistoryEntry ¶
type HistoryEntry struct {
TabID string
ProviderID string
AgentSessionID *string
ClaudeSessionID *string
CompletedAt float64
}
HistoryEntry is the part of a session-history entry recovery reads.
type HistoryStats ¶
type HistoryStats struct {
ToolUsage Counts `json:"toolUsage"`
TouchedFiles []string `json:"touchedFiles"`
LastAssistantText *string `json:"lastAssistantText"`
LastUserText *string `json:"lastUserText"`
FirstUserTs *float64 `json:"firstUserTs"`
LastAssistantTs *float64 `json:"lastAssistantTs"`
TurnDurationMs *float64 `json:"turnDurationMs"`
}
HistoryStats is what a finished turn's transcript tail gives the session history.
func EmptyHistoryStats ¶
func EmptyHistoryStats() HistoryStats
EmptyHistoryStats is the stats of an unreadable or empty transcript.
type HostMCPLauncher ¶
type HostMCPLauncher interface {
// HostMCP is the server's --mcp-config file; "" for none.
HostMCP() (string, error)
}
HostMCPLauncher is an AppLauncher that gives a Claude Code chat without apps the host's app server all the same quiet until an app turns on in the chat, then the app's tools come to the running agent.
type LRU ¶
LRU is a small cache keyed by path: insertion order is eviction order and a hit moves the entry to the end.
type Launch ¶
type Launch struct {
Model *string `json:"model"`
Effort *string `json:"effort"`
// Ultracode starts Claude Code in its ultracode mode, beside the effort (the `ultracode` settings key).
Ultracode bool `json:"ultracode,omitempty"`
// Fast starts the CLI in its fast mode: Claude Code's `fastMode` setting, Codex's `service_tier = "fast"`; on a
// profile, the vendor's fast tier, asked for by the profile's proxy on each request (the gpt profile's relay).
Fast bool `json:"fast,omitempty"`
// Permission is how the agent asks before it acts (wire.PermissionMode); "" leaves it to the machine's default
// (the runtime's dangerouslySkipPermissions, then the CLI's own settings).
Permission wire.PermissionMode `json:"permission,omitempty"`
// Profile starts the agent on a backend profile (another vendor's models behind the CLI, see ProfileLauncher). It
// is set when the conversation starts and stays on the tab, so every later launch of it (resume, fork, rewind)
// goes to the same vendor. Empty: the CLI's own account.
Profile string `json:"profile,omitempty"`
// Apps are the installed apps on in the conversation (internal/apps): the launch gives the agent their plugins,
// instructions and tool policy. They stay on the tab and change when the person turns one on or off; the agent
// takes the change when it starts next.
Apps []string `json:"apps,omitempty"`
// Conversation is the chat this launch is for. The runtime sets it when it starts or resumes the agent, and it is not
// kept on the tab: the apps' launch records it in the launch's own folder (internal/apps), where the guard's journal
// reads which chat a launch belongs to. Empty when the runtime does not know the chat at that point.
Conversation string `json:"-"`
// Input is the chat whose structured input channel this launch may start (Codex's app-server beside the terminal).
// The runtime sets it for a new chat when that channel is on; "" starts the agent as ever. Not kept with the tab.
Input string `json:"-"`
// Lean starts Claude Code with less context: no memory index, no plugins of the person's that only bring MCP
// servers and skills (claude.LeanSettings). The runtime sets it for a delegated chat; not kept with the tab.
Lean bool `json:"-"`
}
Launch is the model and reasoning effort a conversation starts with; nil means the CLI's own default ("Auto"). Same shape as catalog.Choice, so either converts to the other.
func ReadLaunchShape ¶
ReadLaunchShape reads a choice from request or stored values by shape only (model, effort as decoded from JSON). nil, true when both are absent; false when one is malformed.
func ReadProfileLaunchShape ¶
ReadProfileLaunchShape is ReadLaunchShape of a launch on profile: its model may be namespaced (ProfileModelIDRe). The profile is not set on the result; the caller that knows it does.
func WithActiveApps ¶
func WithActiveApps(l *Launch, apps AppLauncher) *Launch
WithActiveApps is the launch with only the apps the launcher says are on; the launch itself when it names none or the launcher cannot say.
func WithLaunchableApps ¶
func WithLaunchableApps(l *Launch, apps AppLauncher) *Launch
WithLaunchableApps is the launch with only the apps that can be readied; the others are reported to the launcher and left out, so one broken app does not keep the chat from starting.
func WithoutApps ¶
func WithoutApps(l *Launch, apps AppLauncher, why error) *Launch
WithoutApps is the launch with none of its apps: what readied them failed (the guard did not answer, the wall or the token could not be made), and the chat starts all the same, plain, rather than not at all. The launcher is told why; the apps can be turned on again in the running chat.
type LaunchableApps ¶
LaunchableApps says which of a launch's apps can be readied for an agent now (installed, for a chat, its files readable) and why each other one cannot. A launch goes on with the ones that can.
type LoginRunner ¶ added in v0.16.5
type LoginRunner interface {
RunLogin(ctx context.Context, script string, extraEnv ...string) (preflight.LoginResult, error)
}
LoginRunner runs an sh script the way a tab's login shell would see the machine: the PATH and variables of the account's profile. preflight.Checker is one.
type Match ¶
type Match int
Match is how a process is recognised as an agent's.
const ( // MatchSubstring: the agent's name anywhere in the command line, as the previous runtime did. `vim CLAUDE.md` does // not match (case), but `less ~/.claude/x` or a shell the agent started under ~/.claude does. MatchSubstring Match = iota // MatchArgv: the agent's name in the program's file name, or, for an interpreter (node, python…), in the script's // path. Covers the CLIs, their versioned binaries, an npm install's cli.js, a launcher script and `exec -a claude`; // a file argument of another program (an editor, a pager, a shell's script) does not count. MatchArgv )
type Obj ¶
type Obj struct {
// contains filtered or unexported fields
}
Obj is a JSON object that remembers the order its keys came in: a transcript line's tool input is summarised by its first key, and counts keyed by tool name are written in the order the tools were met, as JavaScript does.
func (*Obj) Keys ¶
Keys are the keys in JavaScript's order: array indices ascending, then the rest as they came.
func (*Obj) MarshalJSON ¶
MarshalJSON writes the object in its key order.
type ProfileLauncher ¶ added in v0.15.46
type ProfileLauncher interface {
// ClaudeSettings is the `--settings` file of a Claude Code chat on a profile and a model; hooksPath is the settings
// file of harnessly's hooks, which the file extends.
ClaudeSettings(profile, model, hooksPath string) (string, error)
// Codex is what a Codex chat on a profile adds to the launch.
Codex(profile string) (CodexProfile, error)
// Model is the capability record the launch checks its effort against.
Model(profile, model string) (wire.AgentModel, bool)
}
ProfileLauncher gives a launch on a backend profile what it needs of the profile: the Claude Code settings file that points the CLI at the vendor, or the arguments that point Codex at it. It never gives a key: the CLI reads it from a file the profile names.
type Recovered ¶
Recovered is a session found for a tab.
func RecoverTabSession ¶
func RecoverTabSession(t TabAgent, p TabReader, deps RecoveryDeps) *Recovered
RecoverTabSession is the session a tab stands for, from the first source with a transcript on disk: the transcript path the tab kept (its file name is the id), the session id it kept, the newest session of its own history. Nil when the tab never had one; an unreadable history is not an error.
type RecoveryDeps ¶
type RecoveryDeps struct {
Exists func(path string) bool
// FindTranscript is a session's transcript in whatever project folder holds it, "" when none.
FindTranscript func(sessionID string) string
History func() ([]HistoryEntry, error)
}
RecoveryDeps is what recovery looks at on disk.
type SessionInfo ¶
type SessionInfo struct {
Status SessionStatus
// SessionID is the conversation's id, "" when not known.
SessionID string
// RawSessionID is the id exactly as the agent recorded it (a JSON value, a string in practice); nil when none.
RawSessionID any
// JSONLPath is the transcript, "" when it is not on disk (yet).
JSONLPath string
PID int
// StartedAt is the session's start in epoch milliseconds, when the agent recorded it.
StartedAt *float64
Cwd string
// Dir is the agent's own folder (Claude's $CLAUDE_CONFIG_DIR or ~/.claude, Codex's $CODEX_HOME or ~/.codex) as
// the running process was given it; "" when not known.
Dir string
}
SessionInfo is the agent session a pane runs.
func (SessionInfo) MarshalJSON ¶
func (s SessionInfo) MarshalJSON() ([]byte, error)
MarshalJSON writes the session as the timeline reads it: {status, sessionId, jsonlPath, pid, startedAt, cwd}.
type SessionStatus ¶
type SessionStatus string
SessionStatus is what detection found in a pane.
const ( Running SessionStatus = "running" NotRunning SessionStatus = "not-running" NotInstalled SessionStatus = "not-installed" NotInitialized SessionStatus = "not-initialized" )
type Snapshot ¶
type Snapshot struct {
// Idle: the turn is over (or the agent has been quiet for longer than StaleMs while waiting).
Idle bool `json:"idle"`
// Stale: the last entry leaves the turn open, so Idle is a guess from the file's age.
Stale bool `json:"stale"`
LastAssistantSnippet *string `json:"lastAssistantSnippet"`
CurrentAction *CurrentAction `json:"currentAction"`
// Reset: a prompt is newer than the last answer, so the answer shown belongs to an older turn.
Reset bool `json:"reset"`
// LastEntryTs is the deciding (Claude) or newest (Codex) entry's time in epoch ms.
LastEntryTs *float64 `json:"lastEntryTs"`
StaleMs int64 `json:"staleMs"`
Interrupted bool `json:"interrupted"`
}
Snapshot is what the tail of a transcript says about the agent's turn.
type TabAgent ¶
type TabAgent struct {
ID string
AgentState *AgentState
ClaudeSessionID *string
ClaudeJSONLPath *string
ClaudeSummary *string
}
TabAgent is what a layout tab holds about its agent: the provider-neutral state and the fields older layouts kept for Claude.
type TabReader ¶
type TabReader interface {
ProviderID() string
ReadSessionID(t TabAgent) string
ReadJSONLPath(t TabAgent) string
}
TabReader reads a tab's stored session the way one provider does.
type Unavailable ¶
type Unavailable struct {
Unavailable is why an agent CLI cannot start (answered with 409).
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agentstest is a rig for tests of what the agent does through the login shell: a home folder, a folder of fake agent CLIs that comes first on the PATH, and a stand-in login shell.
|
Package agentstest is a rig for tests of what the agent does through the login shell: a home folder, a folder of fake agent CLIs that comes first on the PATH, and a stand-in login shell. |
|
Package claude is the runtime's side of Claude Code: whether it runs in a pane and which conversation, what its transcript says about the turn, what its hooks mean, and the command line that starts or resumes it.
|
Package claude is the runtime's side of Claude Code: whether it runs in a pane and which conversation, what its transcript says about the turn, what its hooks mean, and the command line that starts or resumes it. |
|
Package cliupdate keeps the agent CLIs of the machine (Claude Code, Codex) up to date in the background.
|
Package cliupdate keeps the agent CLIs of the machine (Claude Code, Codex) up to date in the background. |
|
Package codex is the runtime's side of the OpenAI Codex CLI: whether it runs in a pane and which session, what its rollout transcript says about the turn, what its hook payloads mean, and the launcher line and arguments that start or resume it.
|
Package codex is the runtime's side of the OpenAI Codex CLI: whether it runs in a pane and which session, what its rollout transcript says about the turn, what its hook payloads mean, and the launcher line and arguments that start or resume it. |
|
Package install puts Claude Code or Codex on the machine as a job of five steps the hub's UI shows live: the system is checked, the provider's servers are reached, the CLI is downloaded, installed, and started once to see it runs.
|
Package install puts Claude Code or Codex on the machine as a job of five steps the hub's UI shows live: the system is checked, the provider's servers are reached, the CLI is downloaded, installed, and started once to see it runs. |
|
Package roots names the folders the agents' transcripts may be in: the ones under the home, the ones the runtime's CLAUDE_CONFIG_DIR and CODEX_HOME name, and the ones the detectors saw a running Claude or Codex use.
|
Package roots names the folders the agents' transcripts may be in: the ones under the home, the ones the runtime's CLAUDE_CONFIG_DIR and CODEX_HOME name, and the ones the detectors saw a running Claude or Codex use. |