Files
stack/adapters
jason.woltje 88d9cf750f feat(sessions): sessionForkFrom - branch conversations from a common ancestor (#33)
- task schema: optional sessionForkFrom (source session name); requires
  session target; self-fork rejected
- runner: resolves source newest .jsonl (fail 4 if none/outside dataRoot);
  passes MOSAIC_SESSION_FORK + MOSAIC_SESSION_DIR; result records lineage
- pi adapter: --fork <source> --session-dir <target> when forking;
  ephemeral default unchanged; plain session resume unchanged
- compose passthrough; RELEASE -> 0.0.7 (adapter changed)
- suite +9 cases (58 total): plumbing via mock stderr, validation
  negatives, live fork - child recalls ancestor code word, ancestor
  session file untouched

Closes #33
2026-09-03 06:43:02 -05:00
..

Mosaic runtime adapters

An adapter is the entire harness-specific surface of the system. Everything upstream of an adapter — configuration, contracts, missions, tasks, run records — is harness-agnostic; everything inside an adapter may assume one specific agent runtime.

Contract

An adapter lives at:

/opt/mosaic/adapters/<name>/adapter.sh

and must be executable. The dispatcher (/opt/mosaic/src/run-agent.sh) selects it via MOSAIC_ADAPTER (default: pi) and execs it after the system prompt has been generated.

Inputs (environment):

Variable Meaning
MOSAIC_SYSTEM_PROMPT_FILE Absolute path to the generated system prompt (contracts + optional mission section). Read it; do not modify it.
MOSAIC_REQUEST The exact user request text (may contain newlines).
MOSAIC_PROVIDER Configured provider name.
MOSAIC_MODEL Configured model id.

Optional, adapter-specific (documented per adapter):

Variable Meaning
MOSAIC_MOCK_RESPONSE mock only: the verbatim response to emit

Outputs:

  • stdout: the model response text — the only channel the orchestrator captures
  • stderr: diagnostics (never credentials)
  • exit 0: success; nonzero: failure

Rules

  1. Adapters print ONLY the response on stdout. Status lines go to stderr.
  2. Adapters never read configuration files; the resolved settings arrive via environment.
  3. Adapters never write outside /var/lib/mosaic.
  4. Adding an adapter requires: a new directory, the contract implementation, and adding the name to the allowlist in scripts/mosaic-config.mjs.

Included adapters

  • pi — the pinned @earendil-works/pi-coding-agent CLI in noninteractive print mode (-p), ambient discovery disabled, stdin detached.
  • mock — deterministic echo of MOSAIC_MOCK_RESPONSE. Test-only: never use it where a real model response is required.