Documentation
¶
Overview ¶
Package agentdiscover provides bounded, opt-in local discovery of independently launched, unregistered coding-agent sessions (Effort 004b).
Privacy and determinism contract:
- Disabled by default (Options.Enabled must be explicitly true).
- Reads ONLY small allowlisted session-metadata JSON files for the three primary daily-driver runtimes (claude-code, codex, antigravity).
- NEVER reads prompt text, conversation transcripts (*.jsonl), command-line arguments, or environment variables.
- Maps each discovered session strictly to a known WB worktree via clean path boundary matching, skips already-registered PIDs and non-live PIDs, and tags every match with ProvenanceDiscoveredInferred.
Index ¶
Constants ¶
const ( // ProvenanceDiscoveredInferred explicitly marks every session surfaced by // this package so callers and UIs never confuse it with an explicitly // registered WB session. ProvenanceDiscoveredInferred = "discovered (inferred)" RuntimeClaudeCode = "claude-code" RuntimeCodex = "codex" RuntimeAntigravity = "antigravity" DefaultMaxFilesPerRuntime = 64 DefaultMaxSessions = 64 DefaultMaxMetadataBytes = 32 * 1024 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiscoveredSession ¶
type DiscoveredSession struct {
Runtime string `json:"runtime"`
Provenance string `json:"provenance"`
SessionID string `json:"session_id,omitempty"`
PID int `json:"pid"`
WorktreeID string `json:"worktree_id"`
Repository string `json:"repository"`
Task string `json:"task"`
Model string `json:"model,omitempty"`
StartedAt string `json:"started_at,omitempty"`
}
DiscoveredSession is the sanitized, privacy-safe summary of one unregistered agent session correlated to a WB worktree. It intentionally omits prompts, transcripts, environment variables, and raw host filesystem paths.
type Options ¶
type Options struct {
// Enabled must be true to perform any filesystem inspection.
Enabled bool
// HomeDir overrides the user's home directory; required when Enabled is true.
HomeDir string
// Worktrees is the set of discovered WB worktrees used for cwd matching.
Worktrees []WorktreeRef
// RegisteredPIDs lists PIDs already tracked by `wb session register` so they
// are never duplicated as inferred discoveries.
RegisteredPIDs map[int]bool
// IsPIDAlive optionally filters out stale session metadata files whose PID
// is no longer running. When nil, PID liveness filtering is skipped.
IsPIDAlive func(pid int) bool
// MaxFilesPerRuntime bounds metadata files read per runtime directory.
MaxFilesPerRuntime int
// MaxSessions bounds total discovered sessions returned.
MaxSessions int
// MaxMetadataBytes bounds bytes read from any single metadata file.
MaxMetadataBytes int64
}
Options controls bounded opt-in discovery.
type Result ¶
type Result struct {
Enabled bool `json:"enabled"`
Sessions []DiscoveredSession `json:"sessions,omitempty"`
Truncated bool `json:"truncated,omitempty"`
}
Result is the deterministic output of Discover.