neckbeard
Neckbeard runs a Pi Durable harness in one of two places. Both placements return a session with a usable .conversation from agent.start(...). A sandbox agent reconnects to a running sandbox with agent.attach(sandboxId).
- Harness in the sandbox (
mode: "harness-inside-sandbox"). The image contains the harness and tools. Your worker uses a remote conversation over the provider’s private endpoint. Sandbox example
- Harness on the host (
mode: "harness-outside-sandbox"). Your worker owns the native Pi conversation and transactions. With the Archil adapters, a disk supplies the workspace and shell commands run from a tools image. Host example
An agent package
my-agent/
agent.ts # defineAgent(): the image, the sandbox, and the Pi session, used by both your process and the image
skills/ # skills you wrote, committed
skills-lock.json # third-party skills, pinned to commits (npx skills@1.8.1 add <repo>#<sha> --skill <name> --copy)
sandbox/Dockerfile # OS and Python packages; copies in what neckbeard build writes
Quickstart
npm install agent-neckbeard @earendil-works/{pi-durable,pi-ai,chord}@1.6.0
agent.ts defines the agent once. In the image it serves its Pi session, which lives as long as the sandbox, so each turn remembers the earlier ones; in your process it starts sandboxes and runs turns.
import { defineAgent } from "agent-neckbeard";
export const myAgent = defineAgent({
mode: 'harness-inside-sandbox',
name: "my-agent",
registry: "ghcr.io/acme", // the image is ghcr.io/acme/my-agent:<commit>
sandbox: { provider: "daytona", resources: { cpu: 2, memory: 4, disk: 8 } },
env: () => ({ OPENAI_API_KEY: process.env.OPENAI_API_KEY }),
pi: { model: "openai/gpt-6.1-sol", tools: ["read", "bash"], systemPrompt: "You are a helpful agent." },
});
neckbeard push, run from CI, bundles it with Pi's package.json and installs skills/ and the locked skills into the image's build context, builds the image with sandbox/Dockerfile (example), pushes it tagged with the commit, and creates its Daytona snapshot:
npx neckbeard push agent.ts --tag $GITHUB_SHA
Then run a turn from your process. A host deployed from the same commit runs that commit's image: it finds the commit in GITHUB_SHA, RENDER_GIT_COMMIT, VERCEL_GIT_COMMIT_SHA and the like, or NECKBEARD_IMAGE_TAG (image names).
import { BACKGROUND_CONTEXT as ctx } from '@earendil-works/chord/context';
import { answerFromEntry } from 'agent-neckbeard/durable';
import { myAgent } from './agent';
const { sandboxId, conversation } = await myAgent.start({ env: { API_TOKEN: shortLivedToken } });
try {
const submission = await conversation.submit({
type: 'input', content: 'Summarize the data room.', requestId: runId, whenBusy: 'reject',
}, ctx);
const record = await submission.wait(ctx);
if (record.type === 'input' && record.status === 'done') {
const result = answerFromEntry(await conversation.entry(record.answer, ctx));
console.log(result);
}
await conversation.waitForIdle(ctx);
} finally {
await myAgent.kill(sandboxId);
}
Sessions and events
Each sandbox serves one Pi Durable conversation. Use a stable request ID when submitting. A worker can look up an admitted submission by request ID, wait for its native result and read its answer entry. A remote watch exposes its current value and streams native callback values and operations over HTTP. Bash inherits the environment passed at sandbox launch across all submissions. Conversation operations and recovery
SandboxClient
SandboxClient gives provider-neutral file and command access to a sandbox, for staging inputs before a turn and reading results after one. myAgent.sandbox(sandboxId) returns one for an agent's sandbox; SandboxClient.create() and SandboxClient.connect({ provider, sandboxId }) work without an agent.
const sandbox = await myAgent.sandbox(sandboxId);
await sandbox.writeFile(`${sandbox.paths.homeDir}/input.csv`, "a,b\n1,2\n");
const { exitCode, stdout } = await sandbox.runCommand("wc -l input.csv", { cwd: sandbox.paths.homeDir, timeoutMs: 30_000 });
Its detached background commands are described in ARCHITECTURE.md.
Providers
| Provider |
Runs |
Host credentials |
Image |
Details |
| Daytona |
Agent, SandboxClient |
DAYTONA_API_KEY |
neckbeard push makes a snapshot; add the registry in the Daytona dashboard |
DAYTONA.md |
| Modal |
Agent, SandboxClient |
MODAL_TOKEN_ID, MODAL_TOKEN_SECRET; host Node.js 22+ |
Pulled directly; registrySecret names a Modal Secret |
MODAL.md |
| E2B |
Agent, SandboxClient |
E2B_API_KEY |
neckbeard push builds a template; registry credentials |
E2B.md |
| Docker |
SandboxClient, not Agent; local development only, not an isolation boundary |
none |
Any local image |
DOCKER.md |
The host needs Node.js >=20.18.1 <21 || >=22; see host requirements. Configuration is typed: AgentDefinition and PiSessionConfig in src/define.ts, AgentOptions, AgentSandbox, StartOptions, and TurnStreamOptions in src/agent.ts, ServeOptions in src/serve.ts, BuildAgentOptions in src/build.ts, and SandboxClientCreateOptions in src/index.ts.
LegacyBundledAgent and structured tasks are deprecated; see LEGACY.md.
Development
npm run check runs the local checks; see TESTING.md for live provider tests. MIT licensed.