Documentation
¶
Index ¶
- Constants
- func CodexHomeFromEnv(home string) string
- func Find(codexHome string, sessionID string) (string, error)
- func FormatActiveBlock(st *SessionStatus) string
- func FormatBriefJSON(brief *SessionBrief) ([]byte, error)
- func FormatBriefText(brief *SessionBrief, home string) string
- func FormatInfoText(info *SessionInfo, home string, now time.Time) string
- func FormatListJSON(sessions []Session) ([]byte, error)
- func FormatListLiveTable(rows []LiveHostingRow) string
- func FormatListTable(sessions []Session, home string, now time.Time) string
- func FormatStatusJSON(st *SessionStatus) (string, error)
- func FormatStatusText(st *SessionStatus) string
- func NewestTimestamp(rolloutPath string) (time.Time, error)
- func PrintLog(path string, w io.Writer, tail int) error
- func RunListLive(args []string, stdout, stderr io.Writer, codexHome string, opts *ListLiveOpts) error
- func RunMessages(args []string, stdout, stderr io.Writer, codexHome string, opts *MessagesOpts) error
- func RunOpen(args []string, stdout, stderr io.Writer, codexHome string, opts *OpenOpts) error
- func RunResolve(args []string, opts *ResolveOpts) error
- func RunSend(args []string, stdout, stderr io.Writer, codexHome string, opts *SendOpts) error
- func RunSnapshot(args []string, stdout, stderr io.Writer, codexHome string, opts *SnapshotOpts) error
- func TipForSession(codexHome, sessionID string) (time.Time, error)
- type AgentRunOpenResult
- type AgentRunSnapshotResult
- type ChatMessage
- type DisplayEvent
- type FocusCandidate
- type FocusDiscovery
- type FocusFake
- type FocusOpts
- type FocusProc
- type ListLiveFake
- type ListLiveOpts
- type LiveHostingRow
- type LiveOptions
- type LivePID
- type LivePaneInfo
- type MessagesOpts
- type MessagesResult
- type OpenFake
- type OpenOpts
- type OpenResult
- type ResolveDetails
- type ResolveOpts
- type SendCall
- type SendFake
- type SendOpts
- type SendResult
- type Session
- type SessionBrief
- type SessionInfo
- type SessionSourceOpts
- type SessionStatus
- type SnapshotFake
- type SnapshotOpts
- type SnapshotResult
- type TabResolveOpts
- type TabResolveResult
- type TabSelKind
- type TabSelector
Constants ¶
const ( DefaultMessagesLimit = 32 MessagesCapUser = 4096 MessagesCapTool = 128 MessagesCapThinking = 512 MessagesCapResponse = 8192 MessageKindUser = "user" MessageKindThinking = "thinking" MessageKindTool = "tool" MessageKindResponse = "response" )
const ( OpenActionFocused = "focused" OpenActionResumed = "resumed" )
const ( // AgentRunOpenModeSend is live follow-up via agent-run send queue. AgentRunOpenModeSend = "send" // AgentRunOpenModeResume relaunches an exited bound session via agent-run. AgentRunOpenModeResume = "resume" // AgentRunOpenModeRun starts/rebinds via agent-run run. AgentRunOpenModeRun = "run" // AgentRunOpenModeFocus focuses a live agent-run host (open with empty prompt). AgentRunOpenModeFocus = "focus" )
const ( // SnapshotSourceITerm is Contents / CaptureByTTY capture. SnapshotSourceITerm = "iterm" // SnapshotSourceAgentRun is ttywatch.SnapshotText via an agent-run codex-tty. SnapshotSourceAgentRun = "agent-run" )
const DefaultSendOpenWait = 120 * time.Second
DefaultSendOpenWait is how long --open waits for a hosting tab after resume.
const ListLiveCommandHelpLine = ` list-live … list Codex ids hosted in iTerm tabs`
ListLiveCommandHelpLine is the parent `agent-pro codex session` help row.
const ListLiveHelp = `` /* 454-byte string literal not displayed */
ListLiveHelp is the text for `agent-pro codex session list-live --help`.
const MessagesCommandHelpLine = ` messages … print recent chat messages (--limit / --grep / --offset-from-end)`
const MessagesHelp = `` /* 1173-byte string literal not displayed */
MessagesHelp is the text for `agent-pro codex session messages --help`.
const OpenCommandHelpLine = ` open … focus hosting tab or resume (--tab / --tab-index / <id>)`
OpenCommandHelpLine is the parent `agent-pro codex session` help row.
const OpenHelp = `` /* 1253-byte string literal not displayed */
OpenHelp is the text for `agent-pro codex session open --help`.
const ResolveCommandHelpLine = ` resolve resolve Codex session id (ancestor walk or --tab)`
ResolveCommandHelpLine is the parent `agent-pro codex session` help row.
const ResolveHelp = `` /* 940-byte string literal not displayed */
ResolveHelp is the text for `agent-pro codex session resolve --help`.
const SendCommandHelpLine = ` send … type text into hosting pane (--session-id / --tab / --open)`
SendCommandHelpLine is the parent `agent-pro codex session` help row.
const SendHelp = `` /* 2220-byte string literal not displayed */
SendHelp is the text for `agent-pro codex session send --help`.
const SnapshotCommandHelpLine = ` snapshot … capture visible pane text (--tab / --tab-index / <id>)`
SnapshotCommandHelpLine is the parent `agent-pro codex session` help row.
const SnapshotHelp = `` /* 1338-byte string literal not displayed */
SnapshotHelp is the text for `agent-pro codex session snapshot --help`.
const StatusCommandHelpLine = ` status <session-id> show PID liveness + rollout path (File always no)`
StatusCommandHelpLine is the parent `agent-pro codex session` help row.
Variables ¶
This section is empty.
Functions ¶
func CodexHomeFromEnv ¶
func FormatActiveBlock ¶ added in v0.0.180
func FormatActiveBlock(st *SessionStatus) string
FormatActiveBlock renders the Active section for session info.
func FormatBriefJSON ¶
func FormatBriefJSON(brief *SessionBrief) ([]byte, error)
func FormatBriefText ¶
func FormatBriefText(brief *SessionBrief, home string) string
func FormatInfoText ¶ added in v0.0.43
func FormatInfoText(info *SessionInfo, home string, now time.Time) string
func FormatListJSON ¶
func FormatListLiveTable ¶ added in v0.0.180
func FormatListLiveTable(rows []LiveHostingRow) string
FormatListLiveTable renders the human table + footer.
func FormatStatusJSON ¶ added in v0.0.180
func FormatStatusJSON(st *SessionStatus) (string, error)
FormatStatusJSON renders status as a JSON object (no ANSI). path is the absolute rollout path (no tilde).
func FormatStatusText ¶ added in v0.0.180
func FormatStatusText(st *SessionStatus) string
FormatStatusText renders human-readable session status for CLI. Path is display-shortened with pathfmt.TildeHome (not for I/O).
func NewestTimestamp ¶ added in v0.0.165
NewestTimestamp returns the latest line-level "timestamp" in a Codex rollout JSONL file. Zero time if the file is missing, empty, or has no parseable stamps. This is the activity watermark for sink cursor / sinkability (not StartedAt, not mtime).
func RunListLive ¶ added in v0.0.180
func RunListLive(args []string, stdout, stderr io.Writer, codexHome string, opts *ListLiveOpts) error
RunListLive implements `agent-pro codex session list-live`.
func RunMessages ¶ added in v0.0.180
func RunMessages(args []string, stdout, stderr io.Writer, codexHome string, opts *MessagesOpts) error
RunMessages implements `agent-pro codex session messages`.
func RunOpen ¶ added in v0.0.180
RunOpen implements `agent-pro codex session open` with injectable writers/hooks.
func RunResolve ¶ added in v0.0.180
func RunResolve(args []string, opts *ResolveOpts) error
RunResolve implements `agent-pro codex session resolve`. It does not os.Exit and does not print an `Error:` / `agent-pro:` prefix.
func RunSend ¶ added in v0.0.180
RunSend implements `agent-pro codex session send` with injectable writers/hooks.
func RunSnapshot ¶ added in v0.0.180
func RunSnapshot(args []string, stdout, stderr io.Writer, codexHome string, opts *SnapshotOpts) error
RunSnapshot implements `agent-pro codex session snapshot` with injectable writers/hooks.
Types ¶
type AgentRunOpenResult ¶ added in v0.0.180
type AgentRunOpenResult struct {
AgentRunSessionID string
Mode string // send | resume | run | focus
Opened bool // true when a new window was (or would be) launched
Focused bool // true when an existing agent-run host was focused
Delivered bool // true when the prompt was already delivered
Command string // follow-up command for resume/run window (dry-run / ack)
CWD string
}
AgentRunOpenResult is a successful prefer-path open/deliver (or dry-run resolve).
type AgentRunSnapshotResult ¶ added in v0.0.180
AgentRunSnapshotResult is a successful prefer-path capture (or dry-run resolve).
type ChatMessage ¶ added in v0.0.180
type ChatMessage struct {
Kind string `json:"kind"`
Text string `json:"text"`
Truncated bool `json:"truncated"`
Tool string `json:"tool,omitempty"`
Timestamp time.Time `json:"-"`
}
ChatMessage is one coalesced transcript entry after kind caps.
type DisplayEvent ¶
type FocusCandidate ¶ added in v0.0.180
type FocusCandidate struct {
WindowID string
WindowTitle string
TabIndex int
SessionID string // iTerm session id
TTY string
PID int
}
FocusCandidate is one iTerm2 tab that hosts the Codex session. Order is the stable 0-based --index order.
type FocusDiscovery ¶ added in v0.0.180
type FocusDiscovery struct {
Candidates []FocusCandidate
LiveCount int
}
FocusDiscovery is the live-hosting probe result for a known Codex session.
func DiscoverFocusHosting ¶ added in v0.0.180
func DiscoverFocusHosting(sessionID string, opts *FocusOpts) (*FocusDiscovery, error)
DiscoverFocusHosting maps a known Codex session to iTerm tabs via live PID → TTY. It does not call Find and never focuses. Session existence is the caller's job.
type FocusFake ¶ added in v0.0.180
type FocusFake struct {
Procs []FocusProc
OpenFiles map[int][]string
ITerm []iterm2.SessionRef
Focused []string
ListProcsCalls int
LsofCalls int
ListITermCalls int
}
FocusFake is the deterministic injected process + iTerm boundary used by tests.
type FocusOpts ¶ added in v0.0.180
type FocusOpts struct {
Index *int
ListProcs func() []FocusProc
Lsof func(int) []string
ListITerm func() ([]iterm2.SessionRef, error)
FocusITerm func(iterm2.SessionRef) error
}
FocusOpts drives DiscoverFocusHosting. Nil hooks use production probes.
type FocusProc ¶ added in v0.0.180
type FocusProc struct {
PID int
PPID int
TTY string // e.g. /dev/ttys148, ttys148, "??", or ""
Cmd string
}
FocusProc is one process-table row used to walk from a live codex PID to a TTY.
type ListLiveFake ¶ added in v0.0.180
type ListLiveFake struct {
FocusFake
PaneByTTY map[string]LivePaneInfo
// CwdBySession overrides FindSession when set.
CwdBySession map[string]string
}
ListLiveFake is the deterministic injected boundary for list-live tests.
func (*ListLiveFake) ListLiveOpts ¶ added in v0.0.180
func (f *ListLiveFake) ListLiveOpts() *ListLiveOpts
ListLiveOpts returns ListLiveOpts wired to this fake.
type ListLiveOpts ¶ added in v0.0.180
type ListLiveOpts struct {
JSON bool
Limit int // 0 = unlimited
ListProcs func() []FocusProc
Lsof func(int) []string
ListITerm func() ([]iterm2.SessionRef, error)
// PaneByTTY supplies optional pane cwd for WORKSPACE (nil → path-derived summary).
PaneByTTY func() (map[string]LivePaneInfo, error)
// CaptureInventory, when both ListITerm and PaneByTTY are nil, runs once
// and feeds hosting refs + pane cwd. Nil → fast path: one ListITerm
// AppleScript and empty panes (title/cwd from open-file summary / FindSession).
CaptureInventory func() (panes map[string]LivePaneInfo, refs []iterm2.SessionRef, err error)
// FindSession resolves workspace when pane cwd and path-derived summary cwd are empty.
// Title/cwd normally come from summary.json beside the lsof hard-hit session dir.
FindSession func(sessionID string) (cwd string, ok bool)
CodexHome string
}
ListLiveOpts drives ListLive / RunListLive. Nil hooks use production probes.
type LiveHostingRow ¶ added in v0.0.180
type LiveHostingRow struct {
SessionID string
ITerm string // w=<id> t=<tab>(+N)
Title string // from summary.json generated_title; empty → "-"
Workspace string
Candidates []FocusCandidate
}
LiveHostingRow is one Codex session currently hosted in iTerm.
func ListLive ¶ added in v0.0.180
func ListLive(opts *ListLiveOpts) ([]LiveHostingRow, error)
ListLive returns Codex sessions that have at least one hosting iTerm tab. Order is sorted by session id. Rows without a resolved sid never appear.
External probes (ps / lsof / iTerm session list) run once per ListLive call and are reused across sid discovery and every DiscoverFocusHosting join. ListITerm is prefetched in parallel with sid discovery. TITLE/WORKSPACE come from summary.json beside the lsof hard-hit session dir (no WalkDir index).
type LiveOptions ¶ added in v0.0.180
type LiveOptions struct {
ListProcs func() []procresolve.Proc
Lsof func(int) []string
}
LiveOptions injects process listing and open-file probes for tests.
type LivePID ¶ added in v0.0.180
LivePID is one live process hard-hitting a session via open files.
func LivePIDsForSession ¶ added in v0.0.180
func LivePIDsForSession(sessionID string, opts *LiveOptions) ([]LivePID, error)
LivePIDsForSession scans ListProcs for codex runners only. For each runner, Lsof open paths are checked for a hard hit on sessionID (kind codex).
type LivePaneInfo ¶ added in v0.0.180
LivePaneInfo is optional iTerm pane metadata keyed by normalized TTY.
type MessagesOpts ¶ added in v0.0.180
type MessagesOpts struct {
Limit int
LimitSet bool
OffsetFromEnd int
JSON bool
Greps []string
ColorMode string // "auto" | "always" | "never"
Loc *time.Location
ListProcs func() []FocusProc
Lsof func(int) []string
ListITerm func() ([]iterm2.SessionRef, error)
CurrentSessionID func() string
ControllingTTY func() string
AncestorTTYs func() []string
}
MessagesOpts drives Messages / RunMessages.
type MessagesResult ¶ added in v0.0.180
type MessagesResult struct {
SessionID string
Total int
OffsetFromEnd int
Limit int
Messages []ChatMessage
Text string
}
MessagesResult is the outcome of Messages.
func Messages ¶ added in v0.0.180
func Messages(codexHome, sessionID string, opts *MessagesOpts) (*MessagesResult, error)
Messages loads coalesced chat messages for sessionID from the rollout JSONL.
type OpenFake ¶ added in v0.0.180
type OpenFake struct {
FocusFake
Opened []string // "dir|followUp" entries
CurrentSessionID string
ControllingTTY string
AgentRunByID map[string]*AgentRunOpenResult
AgentRunErr error
AgentRunCalls []string
}
OpenFake is the deterministic injected boundary used by open tests.
type OpenOpts ¶ added in v0.0.180
type OpenOpts struct {
Index *int
Dir string // optional workspace override for resume
DryRun bool
// NoAgentRun skips agent-run prefer (--no-agent-run).
NoAgentRun bool
// AgentRunHome overrides AGENT_RUN_HOME / ~/.agent-run for production prefer.
AgentRunHome string
// AgentRunBin overrides LookPath("agent-run") for resume/run window commands.
AgentRunBin string
// TabFrom, when set, short-circuits focus to this already-resolved tab
// (used by RunOpen after ResolveFromTab). Resume is skipped.
TabFrom *TabResolveResult
ListProcs func() []FocusProc
Lsof func(int) []string
ListITerm func() ([]iterm2.SessionRef, error)
FocusITerm func(iterm2.SessionRef) error
// Tab resolve hooks (nil → production). Used by RunOpen for --tab/--tab-index.
CurrentSessionID func() string
ControllingTTY func() string
AncestorTTYs func() []string
OpenInNewWindow func(dir, followUp string) error
CodexBin string
LookPath func(file string) (string, error)
Env []string
// AgentRunOpen replaces production agent-run prefer (tests).
AgentRunOpen func(codexSessionID, prompt string) (*AgentRunOpenResult, error)
Stderr io.Writer // warnings (live-but-no-iTerm); nil → os.Stderr
}
OpenOpts drives Open / RunOpen. Nil hooks use production probes and launchers.
type OpenResult ¶ added in v0.0.180
type OpenResult struct {
Action string // OpenActionFocused | OpenActionResumed
Candidate FocusCandidate
CWD string
Command string
ViaAgentRun bool
AgentRunSessionID string
AgentRunMode string
}
OpenResult is the outcome of a successful Open.
func Open ¶ added in v0.0.180
func Open(codexHome, sessionID string, opts *OpenOpts) (*OpenResult, error)
Open focuses an existing iTerm host tab for sessionID, or resumes the session in a new iTerm2 window when no hosting tab is found. When opts.TabFrom is set, focuses that tab directly (no rediscovery, no resume).
type ResolveDetails ¶ added in v0.0.180
type ResolveDetails struct {
SessionID string `json:"session_id"`
Mode string `json:"mode,omitempty"` // "ancestor" | "tab"
StartPID int `json:"start_pid,omitempty"`
AncestorPID int `json:"ancestor_pid,omitempty"`
RunnerPID int `json:"runner_pid"`
Source string `json:"source"`
Confidence string `json:"confidence"`
WindowID string `json:"window_id,omitempty"`
TabIndex int `json:"tab_index,omitempty"`
TTY string `json:"tty,omitempty"`
}
ResolveDetails is the machine-readable / verbose detail set for a hit.
type ResolveOpts ¶ added in v0.0.180
type ResolveOpts struct {
Stdout, Stderr io.Writer
PID int
ListProcs func() []procresolve.Proc
Lsof func(pid int) []string
CodexHome string
// Tab path hooks (nil → production probes used by ResolveFromTab).
ListFocusProcs func() []FocusProc
ListITerm func() ([]iterm2.SessionRef, error)
CurrentSessionID func() string
ControllingTTY func() string
AncestorTTYs func() []string
}
ResolveOpts drives RunResolve. Nil hooks use live process listing and lsof. PID is the default start pid when --pid is omitted (production: os.Getpid()).
type SendCall ¶ added in v0.0.180
type SendCall struct {
SessionID string
Text string
Opts iterm2.SendTextOptions
}
SendCall records one SendText invocation.
type SendFake ¶ added in v0.0.180
type SendFake struct {
FocusFake
CurrentSessionID string
ControllingTTY string
Opened []string // "dir|followUp"
SendCalls []SendCall
SendErr error
AfterOpen func(*SendFake) // mutate Procs/ITerm after resume (tests)
SleepCalls int
Clock time.Time // advanced by Sleep when non-zero start set via InitClock
// AgentRunByID maps codex session id → prefer hit. Missing key = soft miss.
AgentRunByID map[string]*AgentRunOpenResult
AgentRunErr error
AgentRunCalls []string
// contains filtered or unexported fields
}
SendFake is the deterministic injected boundary used by send tests.
type SendOpts ¶ added in v0.0.180
type SendOpts struct {
Index *int
Dir string
DryRun bool
Open bool
Focus bool
NoSubmit bool
NoCtrlU bool
// NoAgentRun skips agent-run prefer on --open (--no-agent-run).
NoAgentRun bool
// AgentRunHome overrides AGENT_RUN_HOME / ~/.agent-run for production prefer.
AgentRunHome string
// AgentRunBin overrides LookPath("agent-run") for resume/run window commands.
AgentRunBin string
// OpenWait caps how long --open polls for a hosting tab. Zero → DefaultSendOpenWait.
OpenWait time.Duration
// TabFrom, when set, short-circuits host discovery to this already-resolved tab.
TabFrom *TabResolveResult
ListProcs func() []FocusProc
Lsof func(int) []string
ListITerm func() ([]iterm2.SessionRef, error)
// Tab resolve hooks (nil → production). Used by RunSend for --tab/--tab-index.
CurrentSessionID func() string
ControllingTTY func() string
AncestorTTYs func() []string
// SendText writes into an iTerm session. Nil → iterm2.SendText.
SendText func(sessionID, text string, opts iterm2.SendTextOptions, cfg *iterm2.SendTextConfig) error
OpenInNewWindow func(dir, followUp string) error
CodexBin string
LookPath func(file string) (string, error)
Env []string
// AgentRunOpen replaces production agent-run prefer+deliver (tests).
// Return (nil, nil) soft miss; ambiguous error → warning + fall back.
AgentRunOpen func(codexSessionID, prompt string) (*AgentRunOpenResult, error)
// Sleep / Now inject the --open wait loop (tests). Nil → time.Sleep / time.Now.
Sleep func(d time.Duration)
Now func() time.Time
Stderr io.Writer // warnings (live-but-no-iTerm); nil → os.Stderr
}
SendOpts drives Send / RunSend. Nil hooks use production probes and SendText.
type SendResult ¶ added in v0.0.180
type SendResult struct {
SessionID string
ITermSessionID string
Text string
Opened bool // true when --open resumed a new window
ViaAgentRun bool
AgentRunSessionID string
AgentRunMode string // send | resume | run
Candidate FocusCandidate
CWD string
Command string
}
SendResult is the outcome of a successful Send resolve (and optional write).
func Send ¶ added in v0.0.180
func Send(codexHome, sessionID, text string, opts *SendOpts) (*SendResult, error)
Send resolves a live iTerm host for sessionID and types text into it. When opts.Open is set and no host exists, resumes like Open then waits for a host. When opts.TabFrom is set, uses that tab (no rediscovery, no --open resume).
type Session ¶
type SessionBrief ¶
type SessionBrief struct {
Session
Status string `json:"status"`
LineCount int `json:"line_count"`
RecentMessages []DisplayEvent `json:"recent_messages"`
}
type SessionInfo ¶ added in v0.0.43
type SessionInfo struct {
Session
Status string `json:"status"`
LineCount int `json:"line_count"`
NumDisplayEvents int `json:"num_display_events"`
RecentMessages []DisplayEvent `json:"recent_messages"`
TotalInputTokens int `json:"total_input_tokens"`
TotalOutputTokens int `json:"total_output_tokens"`
}
type SessionSourceOpts ¶ added in v0.0.180
type SessionSourceOpts struct {
ListProcs func() []FocusProc
Lsof func(int) []string
ListITerm func() ([]iterm2.SessionRef, error)
CurrentSessionID func() string
ControllingTTY func() string
AncestorTTYs func() []string
}
SessionSourceOpts drives ResolveSessionSource. Tab hooks mirror TabResolveOpts.
type SessionStatus ¶ added in v0.0.180
type SessionStatus struct {
SessionID string
Path string // absolute rollout path from Find (display via TildeHome)
FileActive bool
PIDs []LivePID
PIDChecked bool
State string // "running" | "inactive"
}
SessionStatus is liveness for one Codex session. FileActive is always false: Codex has no active_sessions.json equivalent. State is "running" | "inactive" (never "marked-active" without a file signal).
func Status ¶ added in v0.0.180
func Status(codexHome, sessionID string, checkPID bool, live *LiveOptions) (*SessionStatus, error)
Status returns liveness for a session. Finds the session first (unknown id → error). When checkPID, scans live PIDs. FileActive is always false.
type SnapshotFake ¶ added in v0.0.180
type SnapshotFake struct {
FocusFake
CurrentSessionID string
ControllingTTY string
ContentsByID map[string]iterm2.ContentsResult
ContentsErr error
ContentsCalls []string
AgentRunByID map[string]*AgentRunSnapshotResult
AgentRunErr error
AgentRunCalls []string
AgentRunEnabled bool
}
SnapshotFake is the deterministic injected boundary used by snapshot tests.
func (*SnapshotFake) SnapshotOpts ¶ added in v0.0.180
func (f *SnapshotFake) SnapshotOpts() *SnapshotOpts
SnapshotOpts returns SnapshotOpts wired to this fake.
type SnapshotOpts ¶ added in v0.0.180
type SnapshotOpts struct {
Index *int
DryRun bool
JSON bool
Output string // -o/--output path; empty → stdout
// ForceITerm skips the agent-run prefer path (--iterm).
ForceITerm bool
// AgentRunHome overrides AGENT_RUN_HOME / ~/.agent-run for production prefer.
AgentRunHome string
// TabFrom, when set, short-circuits host discovery to this already-resolved tab.
TabFrom *TabResolveResult
ListProcs func() []FocusProc
Lsof func(int) []string
ListITerm func() ([]iterm2.SessionRef, error)
// Tab resolve hooks (nil → production). Used by RunSnapshot for --tab/--tab-index.
CurrentSessionID func() string
ControllingTTY func() string
AncestorTTYs func() []string
// Contents dumps visible pane text. Nil → iterm2.Contents.
Contents func(sessionID string, cfg *iterm2.ContentsConfig) (iterm2.ContentsResult, error)
// AgentRunSnapshot, when set, is tried before iTerm (unless ForceITerm).
AgentRunSnapshot func(codexSessionID string) (*AgentRunSnapshotResult, error)
// Warning, when set, receives soft-fallback messages (e.g. ambiguous mapping).
Warning func(string)
}
SnapshotOpts drives Snapshot / RunSnapshot. Nil hooks use production probes.
type SnapshotResult ¶ added in v0.0.180
type SnapshotResult struct {
SessionID string // Codex session id
ITermSessionID string
App string
Contents string
Source string // SnapshotSourceAgentRun | SnapshotSourceITerm
AgentRunSessionID string
Candidate FocusCandidate
}
SnapshotResult is the outcome of a successful Snapshot resolve (and optional capture).
func Snapshot ¶ added in v0.0.180
func Snapshot(codexHome, sessionID string, opts *SnapshotOpts) (*SnapshotResult, error)
Snapshot resolves a live iTerm host for sessionID and captures visible pane text. When opts.TabFrom is set, uses that tab's iTerm session (no rediscovery). Unlike Open, missing hosts are a hard error (no resume).
type TabResolveOpts ¶ added in v0.0.180
type TabResolveOpts struct {
ListProcs func() []FocusProc
Lsof func(int) []string
ListITerm func() ([]iterm2.SessionRef, error)
CurrentSessionID func() string
ControllingTTY func() string
AncestorTTYs func() []string
}
TabResolveOpts injects probes for ResolveFromTab. Nil hooks use production.
type TabResolveResult ¶ added in v0.0.180
type TabResolveResult struct {
SessionID string
RunnerPID int
Source string
Confidence string
WindowID string
WindowName string
TabIndex int // 1-based iTerm index
TabListPos int // 0-based position in window tab list
TTY string
ITermSession string
}
TabResolveResult is a Codex session resolved from an iTerm tab.
func ResolveFromTab ¶ added in v0.0.180
func ResolveFromTab(sel TabSelector, opts *TabResolveOpts) (*TabResolveResult, error)
ResolveFromTab finds the target tab in the current iTerm window and resolves exactly one Codex session id from codex runners on that tab's TTY(s). Multiple unrelated Codex sessions on the same tab refuse (fail closed).
func ResolveSessionSource ¶ added in v0.0.180
func ResolveSessionSource(positional []string, tabFlag *string, tabIndexFlag *int, opts *SessionSourceOpts) (sessionID string, tabMeta *TabResolveResult, err error)
ResolveSessionSource picks exactly one of: positional session id, --tab, or --tab-index. Shared by snapshot (and future open/send) so tab→session always goes through ResolveFromTab.
type TabSelKind ¶ added in v0.0.180
type TabSelKind int
TabSelKind is how a tab selector was specified.
const ( // TabSelAbs1 is --tab N (1-based iTerm tab index, matches kool [N]). TabSelAbs1 TabSelKind = iota // TabSelAbs0 is --tab-index N (0-based into the window's ordered tab list). TabSelAbs0 // TabSelNext is --tab next (alias: right); no wrap. TabSelNext // TabSelLeft is --tab left; no wrap. TabSelLeft )
type TabSelector ¶ added in v0.0.180
type TabSelector struct {
Kind TabSelKind
N int // for TabSelAbs1 / TabSelAbs0
}
TabSelector identifies a tab in the current iTerm2 window.
func ParseTabFlag ¶ added in v0.0.180
func ParseTabFlag(raw string) (TabSelector, error)
ParseTabFlag parses --tab values: 1-based N, or next|right|left.
func ParseTabIndexFlag ¶ added in v0.0.180
func ParseTabIndexFlag(n int) (TabSelector, error)
ParseTabIndexFlag parses --tab-index N (0-based).