roster
roster
¶
YAML-driven agent and tool roster.
Loads per-agent definition files from bundled package resources and optional
user extensions, deserializes them into the existing dataclass types, and
provides the same query API that headless_providers and auth expose
today.
Directory layout::
resources/agents/claude.yaml (bundled, shipped in wheel)
resources/agents/codex.yaml
...
~/.config/terok/agent/agents/ (user overrides / additions)
MountDef(host_dir, container_path, label)
dataclass
¶
A shared directory mount derived from the agent roster.
CredentialProxyRoute(provider, route_prefix, upstream, auth_header='Authorization', auth_prefix='Bearer ', credential_type='api_key', credential_file='', phantom_env=dict(), oauth_phantom_env=dict(), base_url_env='', socket_path='', socket_env='', shared_config_patch=None, oauth_refresh=None)
dataclass
¶
Proxy route config parsed from a credential_proxy: YAML section.
Used to generate the routes.json that the credential proxy server reads.
provider
instance-attribute
¶
Agent/tool name (e.g. "claude").
route_prefix
instance-attribute
¶
Path prefix in the proxy (e.g. "claude" → /claude/v1/...).
upstream
instance-attribute
¶
Upstream API base URL (e.g. "https://api.anthropic.com").
auth_header = 'Authorization'
class-attribute
instance-attribute
¶
HTTP header name for the real credential.
auth_prefix = 'Bearer '
class-attribute
instance-attribute
¶
Prefix before the token value in the auth header.
credential_type = 'api_key'
class-attribute
instance-attribute
¶
Type of credential: "oauth", "api_key", "oauth_token", "pat".
credential_file = ''
class-attribute
instance-attribute
¶
Credential file path relative to the auth mount.
phantom_env = field(default_factory=dict)
class-attribute
instance-attribute
¶
Phantom env vars for API-key credentials (e.g. {"ANTHROPIC_API_KEY": true}).
oauth_phantom_env = field(default_factory=dict)
class-attribute
instance-attribute
¶
Phantom env vars for OAuth credentials (e.g. {"CLAUDE_CODE_OAUTH_TOKEN": true}).
When the stored credential type is "oauth" and this is non-empty, these
env vars are injected instead of :attr:phantom_env.
base_url_env = ''
class-attribute
instance-attribute
¶
Env var to override with proxy URL (e.g. "ANTHROPIC_BASE_URL").
socket_path = ''
class-attribute
instance-attribute
¶
Unix socket path for socat bridge (e.g. "/tmp/terok-claude-proxy.sock").
socket_env = ''
class-attribute
instance-attribute
¶
Env var that receives :attr:socket_path (e.g. "ANTHROPIC_UNIX_SOCKET").
shared_config_patch = None
class-attribute
instance-attribute
¶
Optional shared config patch applied after auth (e.g. Vibe's config.toml).
oauth_refresh = None
class-attribute
instance-attribute
¶
OAuth refresh config: {token_url, client_id, scope}.
SidecarSpec(tool_name, env_map=dict())
dataclass
¶
Sidecar container configuration parsed from a sidecar: YAML section.
Tools with sidecar specs run in a separate lightweight L1 image (no agent CLIs) and receive the real API key instead of phantom tokens.
tool_name
instance-attribute
¶
Tool identifier used to select the Jinja2 install block in the template.
env_map = field(default_factory=dict)
class-attribute
instance-attribute
¶
Maps container env var names to credential dict keys.
Example: {"CODERABBIT_API_KEY": "key"} reads cred["key"] and
injects it as CODERABBIT_API_KEY.
AgentRoster(_providers=dict(), _auth_providers=dict(), _proxy_routes=dict(), _sidecar_specs=dict(), _mounts=(), _agent_names=(), _all_names=())
dataclass
¶
Loaded roster of agents and tools from YAML definitions.
Provides the same query API as the legacy hardcoded dicts.
providers
property
¶
All headless agent providers (kind: agent only).
auth_providers
property
¶
All auth providers (agents + tools with auth: section).
agent_names
property
¶
Names of kind: agent entries (for CLI completion).
all_names
property
¶
Names of all entries (agents + tools).
mounts
property
¶
All shared directory mounts (auth dirs + explicit mounts: sections).
Deduplicated by host_dir — if auth and mounts define the same
directory, only one entry is returned.
sidecar_specs
property
¶
All sidecar tool specs, keyed by tool name.
proxy_routes
property
¶
All credential proxy routes, keyed by provider name.
get_provider(name, *, default_agent=None)
¶
Resolve a provider name to a HeadlessProvider.
Falls back to default_agent, then "claude".
Raises SystemExit if the resolved name is unknown.
Source code in src/terok_agent/roster.py
get_auth_provider(name)
¶
Look up an auth provider by name.
Raises SystemExit if the name is unknown.
Source code in src/terok_agent/roster.py
get_sidecar_spec(name)
¶
Look up a sidecar spec by tool name.
Raises SystemExit if the name has no sidecar configuration.
Source code in src/terok_agent/roster.py
generate_routes_json()
¶
Generate the routes.json content for the credential proxy server.
Returns a JSON string mapping route prefixes to upstream config.
Source code in src/terok_agent/roster.py
collect_all_auto_approve_env()
¶
Merge auto_approve.env from all providers into one dict.
Source code in src/terok_agent/roster.py
collect_opencode_provider_env()
¶
Collect env vars for all OpenCode-based providers.
Source code in src/terok_agent/roster.py
load_roster()
¶
Load the agent roster from bundled YAML + user overrides.
Bundled agents in resources/agents/*.yaml are loaded first, then
user files in ~/.config/terok/agent/agents/*.yaml are deep-merged
on top (allowing field-level overrides or entirely new agents).
Source code in src/terok_agent/roster.py
525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 | |
get_roster()
cached
¶
ensure_proxy_routes(cfg=None)
¶
Generate routes.json from the YAML roster and write it to disk.
The routes file is written to the path configured in
:class:~terok_sandbox.SandboxConfig (typically
~/.local/share/terok/proxy/routes.json).
When cfg is None, falls back to standalone defaults.
Returns the path to the written file.