agents

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: AGPL-3.0 Imports: 2 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 agents is the single source of truth for the agent CLIs PANDA can delegate to. It maps each agent's registry key to its adapter script, the binary names to probe on PATH, install/update guidance (download link + install command), and the agent's credential manifest (which env vars and config files prove the agent brings its own model, and how PANDA's model config maps onto the agent's env contract). The CLI (`panda agents`), the capability-card generator (`panda detect`), the web settings API (webui/panel), the commander's availability probe, and the commander's credential probe/injection all read from here instead of each hardcoding their own table, so adding an agent (with credentials) is a single-entry change.

Index

Constants

View Source
const GenericAdapter = "generic.py"

GenericAdapter is the script name of the template-driven adapter (adapters/generic.py). Any card agent may point at it, so an adapter-script lookup cannot identify WHICH agent a generic run belongs to — the card's agent name is the identity there, not the adapter.

View Source
const GenericNativeAdapter = "generic"

GenericNativeAdapter is the Python-free twin of GenericAdapter: a card declaring adapter: "generic" (no .py) gets the identical argv-template expansion implemented inside the commander itself. It exists for nodes where a Python runtime cannot be assumed (bare Windows/macOS, minimal containers, embedded boards) — the place where "any device can serve" would otherwise die on a missing interpreter. Same identity rule: an unknown card name on it resolves to no manifest.

View Source
const TierAutoApproved = defense.TierReversible

TierAutoApproved is the tier a generated capability card declares for an agent. It equals defense.TierReversible on purpose: delegating to an agent is the product's purpose, so a detected node runs unattended. An operator who wants an agent to ask before it acts declares `tier: 2` on that agent in capabilities.yaml, and commander.Route lets that declaration win.

It is bound to the defense constant rather than written as 1 so the two cannot drift: carddetect used to write a literal 2 here, which silently contradicted commander.Route's documented "undeclared defaults to 1" and parked every agent task in review on every detected node.

Variables

This section is empty.

Functions

This section is empty.

Types

type Capabilities added in v0.0.7

type Capabilities struct {
	// SupportsSkills means the agent has a native skill/library concept
	// reachable when the tool whitelist is lifted (extended policy).
	SupportsSkills bool
	// SupportsMCP means the agent can consume MCP servers in some form
	// (its own config files, flags, or project discovery). This is the
	// broad capability; DiscoversProjectMCP is the specific mechanism the
	// commander's .mcp.json passthrough requires.
	SupportsMCP bool
	// SupportsSubagents means the agent can spawn its own child agents
	// (e.g. Claude's Task tool); the orchestration layer records the
	// delegation events when the extended policy lifts the whitelist.
	SupportsSubagents bool
	// SupportsRestricted means the adapter can express a read-only tool
	// face (no shell, no writes) for unconsented remote tasks. Adapters
	// without the flag must never be asked for one — a restricted request
	// sent to a full-power CLI would silently run unconfined, so the
	// scheduler refuses the attempt instead of degrading (fail closed).
	SupportsRestricted bool
	// DiscoversProjectMCP means the agent CLI auto-discovers a project-level
	// MCP config in its working directory, so the commander can materialize
	// the configured passthrough servers for one run.
	DiscoversProjectMCP bool
	// MCPProjectFile names the project-level config path the CLI discovers
	// (".mcp.json" for claude-style CLIs, ".pi/mcp.json" for pi). Empty
	// defaults to ".mcp.json" — only read when DiscoversProjectMCP is set.
	MCPProjectFile string
	// SupportsStructuredOutput means the adapter's CLI accepts a result
	// schema (claude --json-schema): the run's final reply validates
	// against it, so the protocol fields (status/question/delegate_requests)
	// arrive parsed rather than as text markers.
	SupportsStructuredOutput bool
	// SupportsSession means the adapter can keep the agent CLI alive across
	// turns (claude --input-format stream-json): a supervision "continue"
	// costs a message write instead of a process spawn + session reload.
	SupportsSession bool
	// MCPConfigFlag names the CLI flag that accepts an MCP config document
	// (e.g. claude's "--mcp-config"). When set, the commander passes the
	// passthrough servers on the request instead of writing .mcp.json into
	// the task's work dir.
	MCPConfigFlag string
}

Capabilities describes the native feature surface one agent CLI exposes. Each flag is true when the agent's documented CLI surface includes the corresponding feature; the commander reads them instead of hard-coding per-adapter tables (the restricted-mode and MCP-passthrough allowlists used to live in their own maps and drifted out of sync with this one).

type Known

type Known struct {
	// Name is the registry key (also the capability-card agent key), e.g.
	// "grok_build". It is stable and used for routing.
	Name string
	// Adapter is the adapter script under adapters/, e.g. "grok_build.py".
	Adapter string
	// Command is the argv template the generic adapter (generic.py) expands
	// when this agent's card entry declares it — e.g. "zcode --prompt
	// {prompt}". It is the card's agents.<name>.command field verbatim;
	// {prompt} substitutes as one literal argv element. Only meaningful when
	// Adapter is generic.py — bespoke adapters carry their own command line.
	Command string
	// Endpoint is the provider base URL this harness talks to when it runs on
	// its own credentials or its self-contained model ("" when unknown). The
	// pre-dispatch reachability probe hits it so a harness whose provider is
	// down is skipped before the task can block inside the adapter. When the
	// run would inject PANDA's model instead, the injected model's base URL
	// wins; an env override in the agent's own ModelEnv mapping wins over the
	// registry default.
	Endpoint string
	// Binaries are the CLI binary names to probe, in preference order. The
	// first one is the canonical probe binary (also the availability probe
	// fallback when a card declares no install_check).
	Binaries []string
	// DisplayName is the human-readable label shown in the CLI/Web UI.
	DisplayName string
	// InstallHint is a one-line shell command to install/update the CLI.
	// Empty when the agent has no public installer (self-hosted/custom CLIs).
	InstallHint string
	// InstallURL is the documentation or download page. Empty when unknown.
	InstallURL string
	// InitHint is a one-line command to initialize an installed-but-unconfigured
	// agent CLI (e.g. accepting terms, generating project files). Empty when the
	// agent needs no initialization beyond installation. `panda agents` and
	// `panda detect` surface this when the binary is present but credentials
	// or state files are missing, so the operator can distinguish "not installed"
	// from "installed but not initialized".
	InitHint string
	// CredentialEnvVars is the probe side of the agent's credential
	// manifest: env var names that prove the agent carries model
	// credentials of its own (e.g. claude's ANTHROPIC_API_KEY /
	// ANTHROPIC_AUTH_TOKEN). When one is set, the commander leaves the
	// agent's native model alone and only forwards these vars through the
	// sandbox. Empty means "unknown" — probes fall back to the union of
	// common provider keys.
	CredentialEnvVars []string
	// CredentialFiles lists home-relative files whose presence (non-empty)
	// proves the agent is logged in / configured with its own provider —
	// e.g. codex stores its auth and provider sections in ~/.codex.
	CredentialFiles []string
	// CredentialFileFields narrows selected CredentialFiles to the fields
	// whose (non-empty) presence marks real credentials. A file listed here
	// counts only when at least one named field is set — some agents keep a
	// state file that exists long before any login (Claude Code writes
	// ~/.claude.json on first run; dsh writes ~/.dsh/.credentials.yaml with
	// an empty refs block), and treating its mere existence as credentials
	// would wrongly disable model injection. Field names are dotted paths;
	// the probe reads JSON files as objects and YAML files by indentation.
	CredentialFileFields map[string][]string
	// ModelEnv is the injection side of the credential manifest: the env
	// vars the agent CLI reads for its model endpoint. Nil means model
	// injection is not safely supported for this agent (its env contract
	// is ambiguous or it always brings its own key), so PANDA never
	// overrides its endpoint.
	ModelEnv *ModelEnvMapping
	// Capabilities declares what the agent's CLI natively supports.
	// `panda agents` displays these flags today; the routing layer and
	// prompt builder are planned to read them instead of each hard-coding
	// per-adapter knowledge. An agent that supports Skills can reach its
	// native skill library when the tools policy is extended; an agent
	// that supports MCP can discover project .mcp.json servers; an agent
	// that supports Subagents can delegate work to its own child agents.
	Capabilities Capabilities
	// SelfContainedModel is true when the agent ships with its own built-in
	// free or local model provider (e.g. OpenCode's opencode/deepseek-v4-flash-free),
	// requiring no external API keys or configuration to be viable.
	SelfContainedModel bool
	// DefaultCapabilities are the task capabilities this agent provides when
	// generating capability cards (panda detect).
	DefaultCapabilities []string
	// DefaultBestAt are the specialized task tags this agent excels at.
	DefaultBestAt []string
	// DefaultCostTier is the routing cost tier ("low", "low_medium", "medium", "medium_high", "high").
	DefaultCostTier string
	// DefaultTier is the capability tier written into a generated card.
	// It is TierAutoApproved: delegating to an agent is what the product is
	// for, so a detected node must run unattended. An operator who wants an
	// agent to ask first sets `tier: 2` on it in capabilities.yaml, and that
	// declaration still wins in commander.Route.
	DefaultTier int
}

Known describes one agent CLI PANDA recognises. It is deliberately static data with no I/O: probes, adapter names and guidance are derived from it by the consumers that need them.

func ByAdapter

func ByAdapter(adapter string) (Known, bool)

ByAdapter returns the agent whose adapter script is adapter, or ok=false. Used by the commander to derive a probe binary when a card declares no install_check.

func ByName

func ByName(name string) (Known, bool)

ByName returns the agent with the given registry key, or ok=false.

func Lookup added in v0.0.10

func Lookup(name, adapter string) (Known, bool)

Lookup resolves a card agent entry (name + adapter) to its registry record.

The card's own agent name wins, but only when the entry's adapter agrees with the registry record's — a card naming an agent "codex" while pointing at claude_code.py must not inherit codex's credential manifest. For bespoke adapters the adapter script alone identifies the contract, so a renamed card entry still resolves (a card may call the claude adapter anything).

GenericAdapter is the exception that makes the name lookup load-bearing: any number of unrelated CLIs share the script, so an unknown name on it resolves to nothing rather than to whichever registry agent happens to use generic.py. GenericNativeAdapter follows the same rule — an unknown name resolves to nothing rather than borrowing a manifest. Without this rule every custom CLI silently inherited zcode's binaries, credential manifest and endpoint.

func Registry

func Registry() []Known

Registry returns every known agent in deterministic (name-sorted) order. The slice is a copy, so callers may reorder or filter freely.

func (Known) PrimaryBinary

func (k Known) PrimaryBinary() string

PrimaryBinary returns the canonical CLI binary to probe, or "" if none.

type ModelEnvMapping added in v0.0.4

type ModelEnvMapping struct {
	// APIType is the protocol the agent expects: "anthropic" | "openai".
	// Empty matches any configured protocol — a polyglot agent (pi, which
	// selects the wire dialect per-provider) speaks whatever the model
	// config speaks, so the effective api type is the model's own.
	APIType string
	BaseURL string // env var carrying the provider base URL, e.g. ANTHROPIC_BASE_URL / OPENAI_BASE_URL
	APIKey  string // env var carrying the API key, e.g. ANTHROPIC_API_KEY / OPENAI_API_KEY
	Model   string // env var carrying the model name, e.g. ANTHROPIC_MODEL / OPENAI_MODEL
}

ModelEnvMapping names the env vars one agent CLI reads for its model endpoint. It is data, not code: the commander translates its model config through the mapping, so a new agent in the registry gets credential probing and (when a mapping is declared) injection without any commander change.

Jump to

Keyboard shortcuts

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