agentdiscover

package
v0.225.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

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

Documentation

Overview

Package 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

View Source
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.

func Discover

func Discover(opts Options) Result

Discover performs bounded opt-in local discovery of unregistered agent sessions matching known WB worktrees.

type WorktreeRef

type WorktreeRef struct {
	ID         string
	Repository string
	Task       string
	Path       string
}

WorktreeRef identifies one known WB worktree to correlate against a discovered session's working directory.

Jump to

Keyboard shortcuts

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