agent-neckbeard 1.1.29 → 1.1.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +25 -27
  3. package/dist/archil.d.ts +73 -0
  4. package/dist/archil.js +673 -0
  5. package/dist/build.cjs +129 -5315
  6. package/dist/build.d.cts +9 -5
  7. package/dist/build.d.ts +9 -5
  8. package/dist/build.js +4 -6
  9. package/dist/{chunk-BPXEIXPM.js → chunk-FHNQ5DNA.js} +3264 -564
  10. package/dist/{chunk-FSBTLBB5.js → chunk-I5GIWADK.js} +29 -7
  11. package/dist/chunk-I5NULOJP.js +129 -0
  12. package/dist/chunk-PKUGXECR.js +13 -0
  13. package/dist/chunk-QA4L7ZI2.js +72 -0
  14. package/dist/{chunk-KG6SJM74.js → chunk-VHBDBB3N.js} +8 -5
  15. package/dist/cli.cjs +124 -5309
  16. package/dist/cli.js +7 -8
  17. package/dist/define-gdmBe9RA.d.ts +227 -0
  18. package/dist/durable.d.ts +53 -0
  19. package/dist/durable.js +92 -0
  20. package/dist/index.cjs +720 -988
  21. package/dist/index.d.cts +139 -87
  22. package/dist/index.d.ts +139 -87
  23. package/dist/index.js +12 -11
  24. package/dist/inside.d.ts +15 -0
  25. package/dist/inside.js +530 -0
  26. package/dist/{invoke-client-P2CPBYTF.js → invoke-client-QB2NTZ3L.js} +1 -2
  27. package/dist/pi-watch-legacy.d.ts +4503 -0
  28. package/dist/serve.cjs +9 -439
  29. package/dist/serve.d.cts +14 -1
  30. package/dist/serve.d.ts +14 -1
  31. package/dist/serve.js +3 -5
  32. package/docs/AGENT.md +81 -77
  33. package/docs/DAYTONA.md +2 -0
  34. package/docs/DOCKER.md +0 -1
  35. package/docs/E2B.md +1 -1
  36. package/docs/LEGACY.md +1 -8
  37. package/docs/MODAL.md +1 -1
  38. package/package.json +57 -23
  39. package/types/pi-watch.d.cts +68 -0
  40. package/dist/chunk-33IXN6MM.js +0 -21
  41. package/dist/chunk-6P5I7ZCH.js +0 -2552
  42. package/dist/chunk-YFG4EKZM.js +0 -508
  43. package/dist/sandbox-capabilities-CFjnZ_kB.d.cts +0 -77
  44. package/dist/sandbox-capabilities-CFjnZ_kB.d.ts +0 -77
  45. package/dist/serve-Du2NCz9_.d.cts +0 -111
  46. package/dist/serve-Du2NCz9_.d.ts +0 -111
  47. package/dist/supervisor.cjs +0 -5731
  48. package/dist/supervisor.d.cts +0 -482
  49. package/dist/supervisor.d.ts +0 -482
  50. package/dist/supervisor.js +0 -3187
  51. package/docs/SUPERVISOR.md +0 -258
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ - **Breaking:** rebuild existing images for protocol 6. Modern definitions require `mode: "harness-inside-sandbox"` or `mode: "harness-outside-sandbox"`. Modern definitions and sandbox starts use `env` for process variables. Bash inherits them at startup. Call `submit(draft, ctx)` for each input. Replace modern run, prompt and steer helpers with the conversation returned by `agent.start()` or `agent.attach(sandboxId)`, native submission handles and watches. `attach()` never starts a stopped sandbox and throws `SandboxGoneError` when the provider reports it absent or not running. A `pi` agent’s `start()` requires a `sessionId` exactly when `pi.persist` is set. Persisted sessions now use SQLite. Legacy agents retain their existing API.
6
+
7
+ - Add the optional `agent-neckbeard/durable` host harness through `agent.start({ sessionId, storage, execution }, context)`, Archil session storage and tool environment from `agent-neckbeard/archil`, and commit-tagged tools images. See [the durable harness](docs/AGENT.md#host-side-pi-durable-harness).
8
+ - **Breaking:** remove the deprecated durable-session supervisor: the `agent-neckbeard/supervisor` entry point, its generated runtime and default Pi lock, and `docs/SUPERVISOR.md`. `LegacyBundledAgent` and its attached sessions are unchanged.
9
+
3
10
  ## 1.1.29 - 2026-11-19
4
11
 
5
12
  - Add `Agent.steer(sandboxId, turnId, { steerId, message })` and the runtime's `POST /turns/:turnId/steer`, which queue a message for a running turn with the session's `steer()`; Pi delivers it after its current tool calls. Each steer gets exactly one outcome: it is delivered into its turn, or the turn's end record names it in `undeliveredSteerIds`, and it never reaches a later turn. `steer()` returns `false` for a turn that can no longer take it, a repeated `steerId` shares the first request's outcome, and an abort takes back the steers still queued before stopping the session. See `docs/AGENT.md#steering`.
package/README.md CHANGED
@@ -2,7 +2,10 @@
2
2
 
3
3
  # neckbeard
4
4
 
5
- Neckbeard runs a [Pi](https://github.com/earendil-works/pi) agent in a Daytona, Modal, or E2B sandbox from a container image you build ahead of time, and streams its turns back to your code. Your production process never runs the agent: it starts a sandbox, sends each turn to the agent over a private endpoint, and reads Pi's events as they happen. A sandbox starts with nothing to install or upload, a turn keeps running if your process restarts, and its stream resumes where it left off. Use it when an agent needs its own filesystem, shell, and tools, from a Hatchet worker, a Trigger.dev task, or a Vercel Function (see [consumer environments](docs/CONSUMER_ENVIRONMENTS.md)).
5
+ 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)`.
6
+
7
+ - **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](#quickstart)
8
+ - **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](docs/AGENT.md#host-side-pi-durable-harness)
6
9
 
7
10
  ## An agent package
8
11
 
@@ -17,21 +20,21 @@ my-agent/
17
20
  ## Quickstart
18
21
 
19
22
  ```bash
20
- npm install agent-neckbeard @earendil-works/pi-coding-agent
23
+ npm install agent-neckbeard @earendil-works/{pi-durable,pi-ai,chord}@1.6.0
21
24
  ```
22
25
 
23
26
  `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.
24
27
 
25
28
  ```typescript
26
29
  import { defineAgent } from "agent-neckbeard";
27
- import type { JsonAgentSessionEvent } from "@earendil-works/pi-coding-agent";
28
30
 
29
- export const myAgent = defineAgent<JsonAgentSessionEvent>({
31
+ export const myAgent = defineAgent({
32
+ mode: 'harness-inside-sandbox',
30
33
  name: "my-agent",
31
34
  registry: "ghcr.io/acme", // the image is ghcr.io/acme/my-agent:<commit>
32
35
  sandbox: { provider: "daytona", resources: { cpu: 2, memory: 4, disk: 8 } },
33
- envs: () => ({ OPENAI_API_KEY: process.env.OPENAI_API_KEY }),
34
- pi: { model: "openai/gpt-6.1-sol", tools: ["read", "bash", "grep", "ls"], systemPrompt: "You are a helpful agent." },
36
+ env: () => ({ OPENAI_API_KEY: process.env.OPENAI_API_KEY }),
37
+ pi: { model: "openai/gpt-6.1-sol", tools: ["read", "bash"], systemPrompt: "You are a helpful agent." },
35
38
  });
36
39
  ```
37
40
 
@@ -43,15 +46,22 @@ npx neckbeard push agent.ts --tag $GITHUB_SHA
43
46
 
44
47
  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](docs/AGENT.md#image-names)).
45
48
 
46
- ```typescript
47
- import { myAgent } from "./agent";
49
+ ```ts
50
+ import { BACKGROUND_CONTEXT as ctx } from '@earendil-works/chord/context';
51
+ import { answerFromEntry } from 'agent-neckbeard/durable';
52
+ import { myAgent } from './agent';
48
53
 
49
- const sandboxId = await myAgent.start();
54
+ const { sandboxId, conversation } = await myAgent.start({ env: { API_TOKEN: shortLivedToken } });
50
55
  try {
51
- const text = await myAgent.run(sandboxId, { turnId: "run-1", message: "What is in my home directory?" }, {
52
- onRecord: (record) => {}, // stream these to your UI as they arrive
53
- });
54
- console.log(text);
56
+ const submission = await conversation.submit({
57
+ type: 'input', content: 'Summarize the data room.', requestId: runId, whenBusy: 'reject',
58
+ }, ctx);
59
+ const record = await submission.wait(ctx);
60
+ if (record.type === 'input' && record.status === 'done') {
61
+ const result = answerFromEntry(await conversation.entry(record.answer, ctx));
62
+ console.log(result);
63
+ }
64
+ await conversation.waitForIdle(ctx);
55
65
  } finally {
56
66
  await myAgent.kill(sandboxId);
57
67
  }
@@ -59,19 +69,7 @@ try {
59
69
 
60
70
  ## Sessions and events
61
71
 
62
- A sandbox holds one Pi session, and each `prompt()` or `run()` is a turn on it. The turn streams numbered records: `{ seq, type: "event", event }` for each Pi event, in the JSON form Pi's JSON mode writes (a `message_update` carries only its delta), then `{ seq, type: "end", outcome: "completed" | "aborted" | "failed", error? }`. The caller picks `turnId`: prompting again with the same ID resumes that turn instead of running it twice, and a different ID while a turn runs throws `RuntimeBusyError`. Disconnecting does not stop a turn; `myAgent.events(sandboxId, turnId, { after: seq })` resumes its stream, `myAgent.abort(sandboxId, turnId)` stops it, and `myAgent.waitForIdle(sandboxId)` waits until it has. `getPiTurnResult(records)` reads how a turn's records ended. See [AGENT.md](docs/AGENT.md) for the turn protocol.
63
-
64
- ## Tracing
65
-
66
- Give a `pi` agent's `envs` `BRAINTRUST_API_KEY` and `BRAINTRUST_PROJECT_NAME`, add `braintrust` to its package's dependencies, and each turn is traced in that Braintrust project. See [tracing](docs/AGENT.md#tracing).
67
-
68
- ## Per-turn credentials
69
-
70
- Secrets never go in the image. The definition's `envs` reach every sandbox, `start({ envs })` one sandbox, and a turn's `env` only that turn: the agent's `process.env` holds it while the turn runs, then it is restored. Use turn `env` for short-lived tokens tied to one user or request:
71
-
72
- ```typescript
73
- await myAgent.run(sandboxId, { turnId: "run-2", message: "Sync the account", env: { API_TOKEN: "user-scoped-token" } });
74
- ```
72
+ 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](docs/AGENT.md#conversation-operations)
75
73
 
76
74
  ## SandboxClient
77
75
 
@@ -96,7 +94,7 @@ Its detached background commands are described in [ARCHITECTURE.md](docs/ARCHITE
96
94
 
97
95
  The host needs Node.js `>=20.18.1 <21 || >=22`; see [host requirements](docs/CONSUMER_ENVIRONMENTS.md#host-requirements). Configuration is typed: `AgentDefinition` and `PiSessionConfig` in [`src/define.ts`](src/define.ts), `AgentOptions`, `AgentSandbox`, `StartOptions`, and `TurnStreamOptions` in [`src/agent.ts`](src/agent.ts), `ServeOptions` in [`src/serve.ts`](src/serve.ts), `BuildAgentOptions` in [`src/build.ts`](src/build.ts), and `SandboxClientCreateOptions` in [`src/index.ts`](src/index.ts).
98
96
 
99
- `LegacyBundledAgent`, structured tasks, and the durable-session supervisor are deprecated; see [LEGACY.md](docs/LEGACY.md).
97
+ `LegacyBundledAgent` and structured tasks are deprecated; see [LEGACY.md](docs/LEGACY.md).
100
98
 
101
99
  ## Development
102
100
 
@@ -0,0 +1,73 @@
1
+ import { Context as Context$1 } from '@earendil-works/chord/context';
2
+ import { Storage, SubmissionId } from '@earendil-works/pi-durable';
3
+ import { Disk, Archil } from 'disk';
4
+ import { HostExecutionFactory } from 'agent-neckbeard/pi-watch';
5
+ import { ExecutionEnv } from '@earendil-works/pi-durable/env';
6
+ import { MemoryStorage } from '@earendil-works/pi-durable/storage/memory';
7
+ import { A as AgentDefinition } from './define-gdmBe9RA.js';
8
+
9
+ type Context = Parameters<ExecutionEnv['cleanup']>[0];
10
+ type ArchilEnvOptions = {
11
+ disk: Disk;
12
+ imageId?: string;
13
+ client?: Pick<Archil, 'exec'>;
14
+ network?: Parameters<Archil['exec']>[0]['network'];
15
+ env?: Record<string, string>;
16
+ };
17
+ declare function createArchilExecutionEnv(options: ArchilEnvOptions, context?: Context): Promise<ExecutionEnv>;
18
+
19
+ /** `create: false` found no session log, or a log with no root conversation. */
20
+ declare class ArchilSessionNotFound extends Error {
21
+ }
22
+ /** `create: true` found a session log already on the disk. */
23
+ declare class ArchilSessionAlreadyExists extends Error {
24
+ }
25
+ /** One writer per disk. Reopen after an append with an unknown outcome. */
26
+ declare class ArchilStorage extends MemoryStorage {
27
+ private readonly disk;
28
+ private pending;
29
+ private constructor();
30
+ static open(disk: Pick<Disk, 'objectExists' | 'getObject' | 'putObject' | 'appendObject'>, operation?: 'start' | 'open', context?: Parameters<Storage['close']>[0]): Promise<Storage>;
31
+ commit(...[batches, receive, context]: Parameters<Storage['commit']>): Promise<{
32
+ stored: number;
33
+ refused?: undefined;
34
+ } | {
35
+ stored: number;
36
+ refused: {} | null;
37
+ }>;
38
+ close(...args: Parameters<Storage['close']>): Promise<void>;
39
+ }
40
+
41
+ type ImageDefinition = Pick<AgentDefinition, 'registry' | 'name'>;
42
+ /** Resolve the pushed commit to an OCI digest. Archil reuses an already prepared digest. */
43
+ declare function getArchilToolsImageId(definition: ImageDefinition, options?: {
44
+ tag?: string;
45
+ images?: Pick<Archil['images'], 'build'>;
46
+ }): Promise<string>;
47
+
48
+ /**
49
+ * Opens the session log on a disk, or starts one when the disk has none. `create: true` requires a
50
+ * disk with no log; `create: false` requires a log with a root conversation.
51
+ */
52
+ declare function archilStorage(disk: Disk, context: Context$1, options?: {
53
+ create?: boolean;
54
+ }): Promise<Storage>;
55
+ interface ArchilExecutionOptions {
56
+ disk: Disk;
57
+ imageId: string;
58
+ client?: Pick<Archil, 'exec'>;
59
+ network?: Parameters<Archil['exec']>[0]['network'];
60
+ env?: Record<string, string>;
61
+ dispatch?: (identity: Readonly<{
62
+ sessionId: string;
63
+ submissionId: SubmissionId;
64
+ requestId?: string;
65
+ cwd: string;
66
+ }>, ctx: Context$1) => Promise<{
67
+ env?: Record<string, string>;
68
+ network?: Parameters<Archil['exec']>[0]['network'];
69
+ }>;
70
+ }
71
+ declare function archilExecution(options: ArchilExecutionOptions): HostExecutionFactory;
72
+
73
+ export { type ArchilExecutionOptions, ArchilSessionAlreadyExists, ArchilSessionNotFound, ArchilStorage, archilExecution, archilStorage, createArchilExecutionEnv, getArchilToolsImageId };