Container Runtime
Primary files:
src/container-runtime.tssrc/container-runner.tssrc/apple-container.tscontainer/Dockerfilecontainer/agent-runner/src/index.ts
Runtime Selection
From getContainerRuntime():
CONTAINER_RUNTIME=apple|docker|autoautobehavior:- macOS +
containercommand present ->apple - else
dockerif present - else fallback to
containerif present - else throw hard startup error
- macOS +
Mount Model
Mount construction in buildVolumeMounts(group, isMain):
Main group:
- host project root ->
/workspace/project(rw) - main workspace (
~/nanoby default) ->/workspace/group(rw)
Non-main group:
groups/<group-folder>->/workspace/group(rw)groups/global->/workspace/global(ro when exists)
Common mounts:
- per-group pi home
data/pi/<group>/.pi->/home/node/.pi - per-group IPC dir
data/ipc/<group>->/workspace/ipc - optional farm-state, dashboard dirs
- env passthrough dir ->
/workspace/env-dir(ro)
Env Passthrough Policy
Only allowlisted vars are exported into /workspace/env-dir/env.
Examples:
- provider/runtime:
PI_API,PI_MODEL,OPENAI_API_KEY,ANTHROPIC_API_KEY, ... - farm bridge:
HA_URL,HA_TOKEN - debug:
FFT_NANO_DRY_RUN
Additional compatibility behavior:
- if
PI_BASE_URLis set andOPENAI_BASE_URLmissing, host writesOPENAI_BASE_URL=PI_BASE_URL.
Additional Mount Security
If group has containerConfig.additionalMounts, mounts are validated through validateAdditionalMounts:
- allowlist file outside project:
~/.config/fft_nano/mount-allowlist.json - blocked-pattern checks (
.ssh,.env, tokens, credentials, etc.) - root-prefix checks against allowlisted roots
- non-main read-only enforcement when configured
- target path constrained to
/workspace/extra/<relative-path>
Container Execution
runContainerAgent(...):
- Optionally builds retrieval-gated memory context.
- Spawns runtime command (
containerordocker) with generated args. - Sends JSON input to stdin.
- Enforces timeout (
CONTAINER_TIMEOUTor group override). - Captures stdout/stderr with size limits (
CONTAINER_MAX_OUTPUT_SIZE). - Parses JSON output between markers:
---FFT_NANO_OUTPUT_START------FFT_NANO_OUTPUT_END---
- Writes per-run logs under
groups/<group>/logs/container-*.log.
Abort behavior:
SIGTERM, escalate toSIGKILLafter 750ms if process still alive.
Apple Container Self-Heal
If runtime is Apple Container and output error looks like network timeout, host may:
container system stopcontainer system start- Retry one container run
Guardrails:
- single-flight restart lock
- 60s cooldown between restarts
In-Container Runtime
Container entrypoint:
- sources
/workspace/env-dir/envif present - runs
/app/dist/index.js(compiled agent-runner)
Agent-runner responsibilities:
- normalize input options
- assemble system prompt and workspace context
- invoke
piwith JSON mode - return structured output markers to host