runner
runner
¶
High-level agent runner composing sandbox + agent config + container launch.
This is the core of terok-agent run — it builds the environment,
prepares agent config, and launches a hardened Podman container with
the requested AI agent. Three launch modes:
- Headless: fire-and-forget with a prompt (
run_headless) - Interactive: user logs in, agent is ready (
run_interactive) - Web: toad served over HTTP (
run_web)
All user config is runtime (env vars + volumes) — no L2 image build needed. Gate is on by default (safe-by-default egress control).
AgentRunner(*, sandbox=None, roster=None, base_image='ubuntu:24.04')
¶
Composes sandbox + agent config into a single container launch.
All three run methods follow the same flow:
- Ensure L0+L1 images exist (build if missing)
- Prepare agent-config directory (wrapper, instructions, prompt)
- Assemble environment variables and volume mounts
- Optionally set up gate (mirror repo, create token)
- Launch container via podman
Source code in src/terok_agent/runner.py
sandbox
property
¶
Lazy-init sandbox facade.
roster
property
¶
Lazy-init agent roster.
run_headless(provider, repo, *, prompt, branch=None, model=None, max_turns=None, timeout=1800, gate=True, name=None, follow=False, unrestricted=True, gpu=False, hooks=None)
¶
Launch a headless agent run. Returns container name.
The agent executes the prompt against repo (local path or git URL) and exits when done or when timeout is reached. Set follow=True to block until the agent finishes (the CLI does this by default).
Source code in src/terok_agent/runner.py
run_interactive(provider, repo, *, branch=None, gate=True, name=None, unrestricted=True, gpu=False, hooks=None)
¶
Launch an interactive container. Returns container name.
The container stays up after init; user logs in via podman exec.
Source code in src/terok_agent/runner.py
run_web(repo, *, port=None, branch=None, gate=True, name=None, public_url=None, unrestricted=True, gpu=False, hooks=None)
¶
Launch a toad web container. Returns container name.
If port is None, an available port is auto-allocated.
Source code in src/terok_agent/runner.py
run_tool(tool, repo, *, tool_args=(), branch=None, gate=True, name=None, follow=True, timeout=600)
¶
Launch a sidecar tool container. Returns container name.
Runs the named tool in a lightweight sidecar L1 image (no agent CLIs). The tool receives the real API key from the credential store — not a phantom token.