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.
- package/CHANGELOG.md +7 -0
- package/README.md +25 -27
- package/dist/archil.d.ts +73 -0
- package/dist/archil.js +673 -0
- package/dist/build.cjs +129 -5315
- package/dist/build.d.cts +9 -5
- package/dist/build.d.ts +9 -5
- package/dist/build.js +4 -6
- package/dist/{chunk-BPXEIXPM.js → chunk-FHNQ5DNA.js} +3264 -564
- package/dist/{chunk-FSBTLBB5.js → chunk-I5GIWADK.js} +29 -7
- package/dist/chunk-I5NULOJP.js +129 -0
- package/dist/chunk-PKUGXECR.js +13 -0
- package/dist/chunk-QA4L7ZI2.js +72 -0
- package/dist/{chunk-KG6SJM74.js → chunk-VHBDBB3N.js} +8 -5
- package/dist/cli.cjs +124 -5309
- package/dist/cli.js +7 -8
- package/dist/define-gdmBe9RA.d.ts +227 -0
- package/dist/durable.d.ts +53 -0
- package/dist/durable.js +92 -0
- package/dist/index.cjs +720 -988
- package/dist/index.d.cts +139 -87
- package/dist/index.d.ts +139 -87
- package/dist/index.js +12 -11
- package/dist/inside.d.ts +15 -0
- package/dist/inside.js +530 -0
- package/dist/{invoke-client-P2CPBYTF.js → invoke-client-QB2NTZ3L.js} +1 -2
- package/dist/pi-watch-legacy.d.ts +4503 -0
- package/dist/serve.cjs +9 -439
- package/dist/serve.d.cts +14 -1
- package/dist/serve.d.ts +14 -1
- package/dist/serve.js +3 -5
- package/docs/AGENT.md +81 -77
- package/docs/DAYTONA.md +2 -0
- package/docs/DOCKER.md +0 -1
- package/docs/E2B.md +1 -1
- package/docs/LEGACY.md +1 -8
- package/docs/MODAL.md +1 -1
- package/package.json +57 -23
- package/types/pi-watch.d.cts +68 -0
- package/dist/chunk-33IXN6MM.js +0 -21
- package/dist/chunk-6P5I7ZCH.js +0 -2552
- package/dist/chunk-YFG4EKZM.js +0 -508
- package/dist/sandbox-capabilities-CFjnZ_kB.d.cts +0 -77
- package/dist/sandbox-capabilities-CFjnZ_kB.d.ts +0 -77
- package/dist/serve-Du2NCz9_.d.cts +0 -111
- package/dist/serve-Du2NCz9_.d.ts +0 -111
- package/dist/supervisor.cjs +0 -5731
- package/dist/supervisor.d.cts +0 -482
- package/dist/supervisor.d.ts +0 -482
- package/dist/supervisor.js +0 -3187
- 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
|
|
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-
|
|
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
|
|
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
|
-
|
|
34
|
-
pi: { model: "openai/gpt-6.1-sol", tools: ["read", "bash"
|
|
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
|
-
```
|
|
47
|
-
import {
|
|
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
|
|
52
|
-
|
|
53
|
-
});
|
|
54
|
-
|
|
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
|
-
|
|
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
|
|
97
|
+
`LegacyBundledAgent` and structured tasks are deprecated; see [LEGACY.md](docs/LEGACY.md).
|
|
100
98
|
|
|
101
99
|
## Development
|
|
102
100
|
|
package/dist/archil.d.ts
ADDED
|
@@ -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 };
|