Expand description
Harness construction + session-storage wiring. Mirrors the Rust-side
equivalent of the TS packages/coding-agent/src/core/sdk.ts
(createAgentSession) — build the env, tools, durable session storage, and
AgentHarnessOptions, then AgentHarness::create.
v1 scope cuts vs the TS SDK (tracked in docs/m6-cli-open-questions.md):
- No extension / skill / prompt-template / theme / context-file discovery.
The harness
resourcesstay empty; the system prompt is either the caller’s--system-promptor the built-in default (default_system_prompt). - No
--modelscycling, noModelRuntime/multi-provider. One model, one provider (Anthropic), resolved up-front bycrate::provider. - Built-in tools:
read,bash,edit,writeplus the read-onlygrep/find/ls(the TScreateCodingToolsdefault set).grep/finduse an in-processFileSystem+regex/globsetimplementation (documented divergence from the TSrg/fdshell-out; seedocs/m4-tools-open-questions.md). - Session restore (
-c/-r/--session) is partially supported: a fresh session is always created. The harness’screaterejects sessions that already have records (restore not implemented — M5f divergence #3), so-c/-r/--sessioncurrently surface a clear “not implemented” message rather than silently starting fresh. SeeSessionSelection.
Enums§
- Build
Error - A harness-build error.
- Session
Selection - How the user asked to select a session. v1 only honors
NoSession(ephemeralInMemorySessionStorage) andNew(a fresh JSONL file). The continue/resume/specific-session paths are recognized but not wired (the harness rejects restore — see module docs).
Constants§
- BUILTIN_
TOOL_ NAMES - The built-in tool names v1 ships, in the order the TS
createCodingToolsregisters them: the mutating set (read/bash/edit/write) followed by the read-only search set (grep/find/ls).
Functions§
- build
- Build the
AgentHarnessfrom the resolved model + parsed args + cwd. - default_
session_ dir - The default session directory:
<cwd>/.pi/sessions. Mirrors the TSgetDefaultSessionDir(.pi/agent/sessionsin TS; v1 uses.pi/sessionsunder the project — a documented divergence). - default_
system_ prompt - The default coding system prompt. A condensed port of the TS
packages/coding-agent/src/core/system-prompt.tsbase prompt — the pi-internal docs/skills/context-file sections are omitted (v1 has none of that machinery), leaving the role + tools + guidelines core. - select_
session - Decide the session selection from parsed args + the resolved cwd.