Skip to main content
These commands exercise the runtime session machinery. bootstrap and turn-loop build stateful sessions against the mirrored inventories. The five remote-mode commands simulate different connection modes supported by the Claude Code agent harness.

bootstrap

Builds a full runtime-style session report from the mirrored inventories for a given prompt.
python3 -m src.main bootstrap <prompt> [--limit N]

Arguments

prompt
string
required
The prompt to use as the session seed. The runtime routes this prompt, executes matched command and tool shims, streams a turn event sequence, and persists the session.
--limit
integer
default:"5"
Maximum number of routed matches to consider when selecting commands and tools to execute.

Output sections

bootstrap prints the RuntimeSession.as_markdown() output, which contains the following sections:
SectionContents
ContextPython file count and archive availability flag from build_port_context()
SetupPython version, implementation, platform, and test command
Startup StepsSix-step prefetch and init sequence performed by WorkspaceSetup.startup_steps()
System InitSystem init message generated by build_system_init_message(trusted=True)
Routed MatchesEach match formatted as [kind] name (score) — source_hint
Command ExecutionOutput messages from each matched command shim’s execute() call
Tool ExecutionOutput messages from each matched tool shim’s execute() call
Stream EventsRaw stream event types emitted by stream_submit_message()
Turn ResultThe formatted output of the final submit_message() turn
Persisted session pathFile path where the session JSON was saved under .port_sessions/
History logTimestamped log of context, registry, routing, execution, and session store events

Example

python3 -m src.main bootstrap "read a configuration file" --limit 3
# Runtime Session

Prompt: read a configuration file

## Context
python_files=74, archive_available=False

## Setup
- Python: 3.12.2 (CPython)
- Platform: macOS-14.4-arm64-arm-64bit
- Test command: python3 -m unittest discover -s tests -v

## Startup Steps
- start top-level prefetch side effects
- build workspace context
- load mirrored command snapshot
- load mirrored tool snapshot
- prepare parity audit hooks
- apply trust-gated deferred init

## System Init
[system init message]

## Routed Matches
- [tool] Read (2) — tools/read.ts
- [command] /config (1) — commands/config.ts

## Command Execution
[/config] executed with prompt: read a configuration file

## Tool Execution
[Read] executed with payload: read a configuration file

## Stream Events
- message_start: {'type': 'message_start', ...}
- command_match: {'type': 'command_match', ...}
- tool_match: {'type': 'tool_match', ...}
- message_delta: {'type': 'message_delta', ...}
- message_stop: {'type': 'message_stop', ...}

## Turn Result
Prompt: read a configuration file
Matched commands: /config
Matched tools: Read
Permission denials: 0

Persisted session path: .port_sessions/a3f1c2d4e5b6.json

turn-loop

Runs a small stateful multi-turn loop against the mirrored runtime.
python3 -m src.main turn-loop <prompt> [--limit N] [--max-turns N] [--structured-output]

Arguments

prompt
string
required
The initial prompt. Turn 1 uses this prompt verbatim. Subsequent turns append [turn N] to form the turn prompt.
--limit
integer
default:"5"
Maximum number of routed matches to use when selecting commands and tools. Routing runs once before the loop begins; all turns share the same matched command and tool names.
--max-turns
integer
default:"3"
Number of turns to execute. The loop stops early if any turn’s stop_reason is not completed.
--structured-output
boolean
default:"false"
When set, each turn’s output is serialised as JSON instead of plain text.

Per-turn output format

Each turn is printed as:
## Turn N
<turn output>
stop_reason=<reason>
Stop reasons
ReasonDescription
completedTurn processed normally; the loop continues to the next turn
max_turns_reachedThe engine’s internal turn counter hit max_turns before the prompt was processed
max_budget_reachedProjected token usage exceeded the engine’s max_budget_tokens (default 2000)

Example

python3 -m src.main turn-loop "list files in the project" --max-turns 2
## Turn 1
Prompt: list files in the project
Matched commands: none
Matched tools: LS
Permission denials: 0
stop_reason=completed

## Turn 2
Prompt: list files in the project [turn 2]
Matched commands: none
Matched tools: LS
Permission denials: 0
stop_reason=completed
Use --structured-output when piping turn-loop output into another process that expects JSON, for example a test harness that validates the matched command and tool names.

remote-mode

Simulates remote-control runtime branching.
python3 -m src.main remote-mode <target>
target
string
required
Identifier for the remote control target (hostname, URL, or arbitrary label).
Example output
mode=remote
connected=True
detail=Remote control placeholder prepared for prod-machine-01

ssh-mode

Simulates SSH runtime branching.
python3 -m src.main ssh-mode <target>
target
string
required
SSH target string (e.g. user@hostname).
Example output
mode=ssh
connected=True
detail=SSH proxy placeholder prepared for user@prod-machine-01

teleport-mode

Simulates Teleport runtime branching (resume or create a Teleport session).
python3 -m src.main teleport-mode <target>
target
string
required
Teleport node name or session identifier.
Example output
mode=teleport
connected=True
detail=Teleport resume/create placeholder prepared for teleport-node-42

direct-connect-mode

Simulates direct-connect runtime branching.
python3 -m src.main direct-connect-mode <target>
target
string
required
Target label for the direct connection (e.g. a Unix socket path or named pipe).
Example output
mode=direct-connect
target=/tmp/claw.sock
active=True

Simulates deep-link runtime branching.
python3 -m src.main deep-link-mode <target>
target
string
required
Deep-link URI or target identifier (e.g. claude://open?session=abc123).
Example output
mode=deep-link
target=claude://open?session=abc123
active=True

Remote mode output format

remote-mode, ssh-mode, and teleport-mode return a RuntimeModeReport with three fields:
FieldTypeDescription
modestringOne of remote, ssh, teleport
connectedbooleanAlways True in the current placeholder implementation
detailstringHuman-readable description of the prepared connection
direct-connect-mode and deep-link-mode return a DirectModeReport:
FieldTypeDescription
modestringOne of direct-connect, deep-link
targetstringThe target argument as provided
activebooleanAlways True in the current placeholder implementation
All five remote mode commands are placeholder implementations. They return canned responses and do not establish real connections. They exist to mirror the mode-routing branch structure of the TypeScript runtime.

Build docs developers (and LLMs) love