Wrappers
wrappers
¶
Shell wrapper generation for agent CLI commands.
Produces per-provider bash functions (claude(), codex(), vibe(),
etc.) that record task-local agent history, set git identity, handle session
resume, and support both interactive and headless (--terok-timeout) modes.
The shell itself lives in the Jinja template
resources/templates/agent-wrappers.sh.j2; this module only prepares the
per-provider data the template renders. Keeping the shell in a template —
rather than assembling it from Python string fragments — lets the wrapper
logic be read as shell, with the vendor-specific blocks visible inline.
INITIAL_PROMPT_PATH = '/home/dev/.terok/input/initial-prompt.txt'
module-attribute
¶
Container path of the per-task initial prompt the TUI/CLI writes at launch.
INITIAL_PROMPT_CONSUMED_PATH = '/home/dev/.terok/events/initial-prompt.consumed'
module-attribute
¶
Shared empty marker created when an agent claims the immutable initial prompt.
INSTRUCTIONS_PATH = '/home/dev/.terok/input/instructions.md'
module-attribute
¶
Container path of the resolved terok per-task system instructions.
CONTAINER_WORKSPACE = '/workspace'
module-attribute
¶
Container path the host-side repo is bind-mounted at (see container/env.py).
OPENCODE_HARNESS = 'opencode'
module-attribute
¶
Agent whose wrapper the curated OpenCode providers delegate to.
Every provider in
OPENCODE_PROVIDERS is
driven by this harness: their one-word commands select a provider on it rather
than naming an agent of their own.
IDENTITY_NAME_ENV = 'TEROK_AGENT_IDENTITY_NAME'
module-attribute
¶
Env var a provider alias sets to override the harness wrapper's git author name.
IDENTITY_EMAIL_ENV = 'TEROK_AGENT_IDENTITY_EMAIL'
module-attribute
¶
Env var a provider alias sets to override the harness wrapper's git author email.
CLAUDE_OAUTH_UNROUTED_ENV = 'TEROK_CLAUDE_OAUTH_UNROUTED'
module-attribute
¶
Env var that marks Claude's default endpoint as having no route for the stored Claude login.
terok sets it, to
CLAUDE_OAUTH_UNROUTED_ON,
in one case only: the vault holds a Claude OAuth login that terok's
configuration neither routes to Claude (allow_oauth) nor exposes to it
(expose_oauth_token), terok's "skipped" mode. Never in the routed or the
exposed mode: there Claude's default endpoint reaches the provider, through the
vault or directly with the real token.
In the skipped mode terok removes Claude's own route to the provider but keeps
the login's TEROK_PROVIDER_<NAME>_* handle, on purpose: OpenCode, Pi and
Toad reach the provider through the vault with it. The handle alone would
therefore pass Claude's readiness check, and Claude would start on its default
endpoint, go straight to the provider's hosts and meet the egress firewall's
bare refusal. With the variable on, the claude wrapper and the
terok-claude-acp launcher refuse a launch on that endpoint up front
instead, naming the cause and the remedies. A provider selected in the shell
(--provider or TEROK_PROVIDER) that serves Claude's protocol still
routes the launch, Claude's default provider included: the wrapper sends
Claude through that provider's vault handle, not straight to its hosts. The
ACP launcher honours no selection, so it refuses whenever the variable is on.
Only Claude's entry points read it; any other value, or none, leaves them as
they were.
CLAUDE_OAUTH_UNROUTED_ON = '1'
module-attribute
¶
The value that turns Claude's routing refusal on.
The other half of the
CLAUDE_OAUTH_UNROUTED_ENV
contract: terok sets the variable to this value rather than spelling it, and
the rendered check compares against it, so the two cannot drift apart. The
check compares strings, so any other spelling, such as true, leaves
Claude's entry points as they were.
generate_all_wrappers()
¶
Render terok-executor.sh: a shell wrapper function for every agent.
The output file contains a shell function per agent (claude(),
codex(), vibe(), …), each with correct git env vars, timeout
support, and session-resume logic, plus the shared helper functions they
call. This lets interactive CLI users invoke any agent regardless of
which agent was configured as default.
Each curated OpenCode provider additionally gets a one-word alias
(blablador(), kisski(), …) that delegates to the harness wrapper, so
those commands inherit its feature set instead of reaching the launcher
symlink directly and losing it.
Source code in src/terok_executor/provider/wrappers.py
generate_agent_wrapper(agent)
¶
Render a single agent's wrapper function, without the shared helpers.
Used to inspect one agent's wrapper in isolation; the full file (with
the _terok_record_agent / _terok_wrapper_help / _terok_resume_hint /
_terok_trust_workspace_for_vibe helpers) is produced by
generate_all_wrappers.
Claude's render also carries _terok_claude_ready and
_terok_claude_routed, the default-provider pre-flight that belongs to
it alone (its ACP launcher calls it too).
Source code in src/terok_executor/provider/wrappers.py
generate_provider_shortcut(name)
¶
Render one curated provider's one-word alias, without the shared helpers.
Companion to
generate_agent_wrapper
for inspecting a single alias; the full file is produced by
generate_all_wrappers.