agent-neckbeard 1.1.28 → 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 +12 -0
  2. package/README.md +28 -30
  3. package/dist/archil.d.ts +73 -0
  4. package/dist/archil.js +673 -0
  5. package/dist/build.cjs +129 -5160
  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-JF5YPOBY.js → chunk-FHNQ5DNA.js} +3235 -511
  10. package/dist/{chunk-M7XNBKG4.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 -5154
  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 -833
  21. package/dist/index.d.cts +139 -78
  22. package/dist/index.d.ts +139 -78
  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 -309
  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 +95 -59
  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-M3FISP7J.js +0 -377
  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-Dan1HQKN.d.cts +0 -89
  46. package/dist/serve-Dan1HQKN.d.ts +0 -89
  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/dist/cli.js CHANGED
@@ -2,18 +2,16 @@
2
2
  import {
3
3
  buildAgent,
4
4
  pushAgent
5
- } from "./chunk-M7XNBKG4.js";
6
- import "./chunk-JF5YPOBY.js";
7
- import "./chunk-6P5I7ZCH.js";
8
- import "./chunk-M3FISP7J.js";
9
- import "./chunk-KG6SJM74.js";
10
- import "./chunk-33IXN6MM.js";
5
+ } from "./chunk-I5GIWADK.js";
6
+ import "./chunk-FHNQ5DNA.js";
7
+ import "./chunk-PKUGXECR.js";
8
+ import "./chunk-VHBDBB3N.js";
11
9
 
12
10
  // src/cli.ts
13
11
  var USAGE = [
14
12
  "Usage:",
15
13
  " neckbeard build <module> [--export <name>] [--out <dir>]",
16
- " neckbeard push <module> [--export <name>] [--tag <tag>]... [--cache] [--dry-run]"
14
+ " neckbeard push <module> [--export <name>] [--tag <tag>]... [--cache] [--dry-run] [--archil-dockerfile <file>]"
17
15
  ].join("\n");
18
16
  function parse(args, valueOptions, flagOptions) {
19
17
  let module;
@@ -53,12 +51,13 @@ async function main([command, ...args]) {
53
51
  return;
54
52
  }
55
53
  if (command === "push") {
56
- const { module, values, flags } = parse(args, ["--export", "--tag"], ["--cache", "--dry-run"]);
54
+ const { module, values, flags } = parse(args, ["--export", "--tag", "--archil-dockerfile"], ["--cache", "--dry-run"]);
57
55
  const exportName = values.get("--export")?.[0];
58
56
  const result = await pushAgent({
59
57
  module,
60
58
  ...exportName ? { exportName } : {},
61
59
  tags: values.get("--tag") ?? [],
60
+ archilDockerfile: values.get("--archil-dockerfile")?.[0],
62
61
  cache: flags.has("--cache"),
63
62
  dryRun: flags.has("--dry-run"),
64
63
  onLog: (line) => console.log(line)
@@ -0,0 +1,227 @@
1
+ import * as agent_neckbeard_pi_watch from 'agent-neckbeard/pi-watch';
2
+
3
+ interface ModalSandboxConfig {
4
+ provider: 'modal';
5
+ /** Public Debian-compatible registry image; defaults to node:22-bookworm. */
6
+ template?: string;
7
+ /** Modal App name; created if missing. Defaults to agent-neckbeard. */
8
+ appName?: string;
9
+ environment?: string;
10
+ /** Fixed lifetime, whole-second milliseconds from 1000 to 86400000; defaults to one hour. */
11
+ timeoutMs?: number;
12
+ cpu?: number;
13
+ memoryMiB?: number;
14
+ /**
15
+ * Regions the sandbox may run in, such as `['us']` or `['us-east']`. Modal
16
+ * otherwise places it in any region worldwide, and every file and command
17
+ * call pays the round trip. Pinned regions cost more; see docs/MODAL.md.
18
+ */
19
+ regions?: string[];
20
+ /**
21
+ * Whether to block all sandbox network egress. Cannot be combined with
22
+ * non-empty allow lists.
23
+ */
24
+ networkBlockAll?: boolean;
25
+ /**
26
+ * Comma-separated CIDR allow list for sandbox egress, any protocol.
27
+ *
28
+ * Example: '203.0.113.0/24,198.51.100.10/32'
29
+ */
30
+ networkAllowList?: string;
31
+ /**
32
+ * Comma-separated domain allow list for sandbox egress. Modal matches the
33
+ * TLS SNI, so it only allows HTTPS (port 443) to these domains; when set, the
34
+ * image's apt sources are switched to HTTPS. Wildcards are supported with a
35
+ * leading `*.`. Traffic matching either allow list is allowed.
36
+ *
37
+ * Example: '*.example.com,api.openai.com'
38
+ */
39
+ domainAllowList?: string;
40
+ }
41
+ interface ModalClientCredentials {
42
+ tokenId?: string;
43
+ tokenSecret?: string;
44
+ environment?: string;
45
+ }
46
+ type ModalSandboxCreateOptions = ModalSandboxConfig & ModalClientCredentials & {
47
+ envs?: Record<string, string | undefined>;
48
+ /**
49
+ * Runs as the sandbox's main process, with `template` used as-is: no setup layer and no
50
+ * working directory override. For images that already contain everything, as `Agent` uses.
51
+ */
52
+ command?: string[];
53
+ /** Name of a Modal Secret with `REGISTRY_USERNAME` and `REGISTRY_PASSWORD`, to pull a private `template`. */
54
+ registrySecret?: string;
55
+ };
56
+
57
+ interface DockerSandboxConfig {
58
+ provider: 'docker';
59
+ /** Debian-compatible image with Node.js/npm for `Agent`; defaults to node:22-bookworm. */
60
+ template?: string;
61
+ /** Existing Docker network to join, e.g. a compose project network. */
62
+ network?: string;
63
+ /** Image platform such as linux/amd64; defaults to the daemon's native platform. */
64
+ platform?: string;
65
+ /** Fixed lifetime, whole-second milliseconds up to 24 hours; the container removes itself afterwards. Defaults to one hour. */
66
+ timeoutMs?: number;
67
+ cpu?: number;
68
+ memoryMiB?: number;
69
+ }
70
+ type DockerSandboxCreateOptions = DockerSandboxConfig & {
71
+ envs?: Record<string, string | undefined>;
72
+ };
73
+
74
+ /**
75
+ * agent-neckbeard - Deploy AI agents to sandboxes
76
+ */
77
+
78
+ interface DaytonaSandboxConfig {
79
+ provider: 'daytona';
80
+ /**
81
+ * Daytona snapshot name to use for the sandbox.
82
+ * This is the Daytona equivalent of choosing a base sandbox environment.
83
+ */
84
+ template: string;
85
+ /**
86
+ * Whether Daytona should block all sandbox network access by default.
87
+ *
88
+ * Daytona does not allow this to be combined with non-empty allow lists.
89
+ */
90
+ networkBlockAll?: boolean;
91
+ /**
92
+ * Comma-separated CIDR network allow list for Daytona sandbox egress.
93
+ *
94
+ * Example: '203.0.113.0/24,198.51.100.10/32'
95
+ */
96
+ networkAllowList?: string;
97
+ /**
98
+ * Comma-separated DNS domain allow list for Daytona sandbox egress.
99
+ *
100
+ * Wildcards are supported with a leading `*.`.
101
+ * Example: '*.example.com,api.openai.com'
102
+ */
103
+ domainAllowList?: string;
104
+ /**
105
+ * Minutes without activity before Daytona stops the sandbox. `0` disables
106
+ * auto-stop. Omit it to keep Daytona's default (15 minutes for standard
107
+ * sandbox classes). Applied only when the sandbox is created.
108
+ */
109
+ autoStopInterval?: number;
110
+ /**
111
+ * Minutes after the sandbox stops before Daytona deletes it. `0` deletes it
112
+ * as soon as it stops; `-1`, the default, never auto-deletes it. Applied
113
+ * only when the sandbox is created.
114
+ */
115
+ autoDeleteInterval?: number;
116
+ }
117
+ type SandboxClientCreateOptions = ModalSandboxCreateOptions | DockerSandboxCreateOptions | {
118
+ provider: 'e2b';
119
+ template?: string;
120
+ apiKey?: string;
121
+ envs?: Record<string, string | undefined>;
122
+ timeoutMs?: number;
123
+ requestTimeoutMs?: number;
124
+ allowPublicTraffic?: boolean;
125
+ } | {
126
+ provider: 'daytona';
127
+ template?: string;
128
+ apiKey?: string;
129
+ envs?: Record<string, string | undefined>;
130
+ createTimeoutSec?: number;
131
+ autoStopInterval?: number;
132
+ autoDeleteInterval?: number;
133
+ networkBlockAll?: boolean;
134
+ networkAllowList?: string;
135
+ domainAllowList?: string;
136
+ };
137
+
138
+ type DaytonaCreateOptions = Extract<SandboxClientCreateOptions, {
139
+ provider: 'daytona';
140
+ }>;
141
+ type E2bCreateOptions = Extract<SandboxClientCreateOptions, {
142
+ provider: 'e2b';
143
+ }>;
144
+ /** The Modal sandbox options `Agent` passes through; the image is its `template`. */
145
+ interface ModalAgentSandbox extends Pick<ModalSandboxCreateOptions, 'provider' | 'appName' | 'environment' | 'timeoutMs' | 'cpu' | 'memoryMiB' | 'regions' | 'networkBlockAll' | 'networkAllowList' | 'domainAllowList' | 'registrySecret'> {
146
+ }
147
+ interface DaytonaAgentSandbox extends Pick<DaytonaSandboxConfig, 'provider' | 'networkBlockAll' | 'networkAllowList' | 'domainAllowList' | 'autoStopInterval' | 'autoDeleteInterval'>, Pick<DaytonaCreateOptions, 'apiKey'> {
148
+ /** Snapshot resources: vCPUs, and memory and disk in GiB. */
149
+ resources?: {
150
+ cpu?: number;
151
+ memory?: number;
152
+ disk?: number;
153
+ };
154
+ }
155
+ interface E2bAgentSandbox extends Pick<E2bCreateOptions, 'provider' | 'apiKey' | 'timeoutMs'> {
156
+ /** Template resources. */
157
+ cpuCount?: number;
158
+ memoryMB?: number;
159
+ /** Credentials E2B uses to pull a private image when it builds the template. */
160
+ registry?: {
161
+ username: string;
162
+ password: string;
163
+ };
164
+ }
165
+ type AgentSandbox = ModalAgentSandbox | DaytonaAgentSandbox | E2bAgentSandbox;
166
+
167
+ type ThinkingLevel = 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
168
+ /** A Pi session for `defineAgent()` to create in the sandbox. */
169
+ interface PiSessionConfig {
170
+ /** `provider/model`, such as `openai/gpt-6.1-sol`. */
171
+ model: string;
172
+ thinkingLevel?: ThinkingLevel;
173
+ /** Pi's built-in tools to enable, such as `read` and `bash`. */
174
+ tools?: string[];
175
+ systemPrompt: string;
176
+ /**
177
+ * The working directory, relative to the sandbox user's home unless absolute. Created before the
178
+ * session, and exported to the agent's commands as `NECKBEARD_CWD`. Defaults to `workspace`.
179
+ */
180
+ cwd?: string;
181
+ /**
182
+ * Keeps the conversation in a file named for the `sessionId` passed to `start()`, so a restarted
183
+ * runtime, or a sandbox restored from a copy of the file, continues it. See `sessionFilePath()`.
184
+ * Otherwise the conversation lives in memory for the sandbox's life.
185
+ */
186
+ persist?: boolean;
187
+ }
188
+ /** An agent: its image, sandbox, and either a Pi session config or its own session factory. */
189
+ interface AgentDefinition {
190
+ mode: 'harness-inside-sandbox' | 'harness-outside-sandbox';
191
+ /** Names the image and the provider's snapshots or templates; lowercase letters, digits, and dashes. */
192
+ name: string;
193
+ /** Registry the image lives under, such as `ghcr.io/acme`; the image is `<registry>/<name>:<tag>`. */
194
+ registry?: string;
195
+ /** A full image reference instead of `registry`, such as one built elsewhere. */
196
+ image?: string;
197
+ /** The sandbox, or a function returning it, read only on the host. */
198
+ sandbox?: AgentSandbox | (() => AgentSandbox);
199
+ /**
200
+ * Environment of every sandbox, or a function returning it, read only on the host, so the image
201
+ * needs none of the host's configuration. Never secrets in the image. A `pi` agent is traced in
202
+ * Braintrust when this has BRAINTRUST_API_KEY and BRAINTRUST_PROJECT_NAME; see docs/AGENT.md#tracing.
203
+ */
204
+ env?: Record<string, string | undefined> | (() => Record<string, string | undefined>);
205
+ /** The image's main process. Defaults to `node /app/agent.mjs`, the entry point `neckbeard build` writes. */
206
+ command?: string[];
207
+ /** The port the runtime listens on, given to it as NECKBEARD_PORT. Defaults to 8080. */
208
+ port?: number;
209
+ /** How long `start()` waits for the runtime to answer. Defaults to two minutes. */
210
+ startTimeoutMs?: number;
211
+ /** How long `prepare()` may take to create a Daytona snapshot or E2B template. Defaults to 30 minutes. */
212
+ prepareTimeoutMs?: number;
213
+ /** Aborts an inside-sandbox Pi submission when it exceeds this duration. Host-side workers own native submission deadlines. */
214
+ maxTurnDurationMs?: number;
215
+ /** The agent's Pi session. */
216
+ pi?: PiSessionConfig;
217
+ /** Creates the session instead of `pi`, for one that config can't express. */
218
+ createSession?: () => Promise<agent_neckbeard_pi_watch.ServedConversation>;
219
+ build?: {
220
+ /** Packages the image installs instead of bundling; Pi's always are, and for a `pi` agent Braintrust when its package depends on it. */
221
+ external?: string[];
222
+ /** The Dockerfile `neckbeard push` builds the image with, relative to the package. Defaults to `sandbox/Dockerfile`. */
223
+ dockerfile?: string;
224
+ };
225
+ }
226
+
227
+ export type { AgentDefinition as A, PiSessionConfig as P };
@@ -0,0 +1,53 @@
1
+ import { Context } from '@earendil-works/chord/context';
2
+ import { HostStartOptions, HostSession } from 'agent-neckbeard/pi-watch';
3
+ import { P as PiSessionConfig, A as AgentDefinition } from './define-gdmBe9RA.js';
4
+ import * as _earendil_works_pi_durable from '@earendil-works/pi-durable';
5
+ import { Storage, ConversationInit, HarnessOptions, Harness, Conversation, Tx, ConversationId, SubmissionId, EntryRecord, SettledSubmissionRecord } from '@earendil-works/pi-durable';
6
+ import { ExecutionEnv } from '@earendil-works/pi-durable/env';
7
+
8
+ /**
9
+ * Wire contract between `Agent` on the host and `serve()` in the sandbox. See docs/AGENT.md.
10
+ */
11
+
12
+ type DurableTurnResult = {
13
+ outcome: 'completed';
14
+ answer: string | null;
15
+ } | {
16
+ outcome: 'aborted' | 'failed';
17
+ error: string;
18
+ };
19
+
20
+ declare function openDurableHarness({ definition, storage, executionEnv, models, onReport, init }: {
21
+ definition: {
22
+ pi?: PiSessionConfig;
23
+ };
24
+ storage: Storage;
25
+ init?: ConversationInit;
26
+ executionEnv: ExecutionEnv | NonNullable<HarnessOptions['env']>;
27
+ } & Pick<HarnessOptions, 'models' | 'onReport'>, context: Parameters<typeof Harness.open>[2]): Promise<{
28
+ harness: Harness;
29
+ root: Conversation;
30
+ }>;
31
+
32
+ declare const durableWatchWindow: {
33
+ readonly min: 1;
34
+ readonly max: 4;
35
+ };
36
+ /** Capture the generation containing this input and withdraw its abort-policy queue in the same commit. */
37
+ declare function prepareSubmissionStop(tx: Tx, conversationId: ConversationId, id: SubmissionId): Promise<_earendil_works_pi_durable.TaskId | undefined>;
38
+ declare function turnRequestId(turnId: string): string;
39
+ declare function steerRequestId(turnId: string, steerId: string): string;
40
+ declare function parseDurableRequestId(requestId?: string): {
41
+ turnId: string;
42
+ steerId?: string;
43
+ } | undefined;
44
+ declare function durableTurnResult(storage: Storage, submission: SettledSubmissionRecord, context: Context): Promise<DurableTurnResult>;
45
+ declare function answerFromEntry(entry: EntryRecord | undefined): DurableTurnResult;
46
+
47
+ /** The storage given to `start()` holds another agent's or another session's conversation. */
48
+ declare class SessionIdentityMismatch extends Error {
49
+ }
50
+
51
+ declare function hostSession(definition: AgentDefinition, options: HostStartOptions, context: Context): Promise<HostSession>;
52
+
53
+ export { type DurableTurnResult, SessionIdentityMismatch, answerFromEntry, durableTurnResult, durableWatchWindow, hostSession, openDurableHarness, parseDurableRequestId, prepareSubmissionStop, steerRequestId, turnRequestId };
@@ -0,0 +1,92 @@
1
+ import {
2
+ answerFromEntry,
3
+ closeDurableResources,
4
+ durableTurnResult,
5
+ durableWatchWindow,
6
+ openDurableHarness,
7
+ parseDurableRequestId,
8
+ prepareSubmissionStop,
9
+ steerRequestId,
10
+ turnRequestId
11
+ } from "./chunk-I5NULOJP.js";
12
+ import {
13
+ untilAborted
14
+ } from "./chunk-QA4L7ZI2.js";
15
+
16
+ // src/durable.ts
17
+ import { withoutAbortSignal } from "@earendil-works/chord/context";
18
+ import { defineDoc, ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
19
+ import { builtinModels } from "@earendil-works/pi-ai/providers/all";
20
+ var SessionIdentityMismatch = class extends Error {
21
+ };
22
+ var identity = defineDoc({
23
+ kind: "neckbeard.session",
24
+ version: 1,
25
+ scope: "conversation",
26
+ history: "latest",
27
+ fork: "initial",
28
+ initial: () => ({ agent: "", sessionId: "" }),
29
+ checkpointWhen: () => true
30
+ });
31
+ async function hostSession(definition, options, context) {
32
+ const { sessionId, storage, execution } = options;
33
+ const cleanup = withoutAbortSignal(context);
34
+ let executionEnv = typeof execution === "function" ? void 0 : execution;
35
+ let harness;
36
+ let closing;
37
+ const close = () => closing ??= closeDurableResources(harness, storage, executionEnv, cleanup);
38
+ try {
39
+ if (definition.maxTurnDurationMs !== void 0) {
40
+ throw new Error("maxTurnDurationMs requires an inside-sandbox runtime. The host worker owns deadlines.");
41
+ }
42
+ if (!sessionId?.trim()) throw new Error("Host startup requires a logical session ID.");
43
+ const root = await storage.conversation(ROOT_CONVERSATION_ID, context);
44
+ if (root) {
45
+ const scope = { kind: "conversation", conversationId: ROOT_CONVERSATION_ID };
46
+ const record = await storage.findDocument({ kind: identity.definition.kind, scope }, "current", context);
47
+ const stamp = record && await storage.document(record.id, "current", context);
48
+ if (stamp?.version !== identity.definition.version || stamp.value.agent !== definition.name || stamp.value.sessionId !== sessionId) {
49
+ throw new SessionIdentityMismatch("Session history does not match the requested agent and session ID.");
50
+ }
51
+ }
52
+ let adapter;
53
+ if (typeof execution === "function") {
54
+ const opening = execution({ sessionId, storage }, context);
55
+ try {
56
+ adapter = await untilAborted(() => opening, context.abortSignal);
57
+ } catch (error) {
58
+ opening.then((late) => late.executionEnv.cleanup(cleanup)).catch(() => void 0);
59
+ throw error;
60
+ }
61
+ } else adapter = { executionEnv: execution };
62
+ executionEnv = adapter.executionEnv;
63
+ const opened = await openDurableHarness({
64
+ definition,
65
+ storage,
66
+ models: builtinModels(),
67
+ init: !root ? async (tx, id) => {
68
+ const stamp = await tx.doc(identity, id);
69
+ stamp.agent = definition.name;
70
+ stamp.sessionId = sessionId;
71
+ } : void 0,
72
+ executionEnv: adapter.resolve ?? executionEnv
73
+ }, context);
74
+ harness = opened.harness;
75
+ return { executionEnv, storage, sessionId, harness, conversation: opened.root, close };
76
+ } catch (error) {
77
+ await close();
78
+ throw error;
79
+ }
80
+ }
81
+ export {
82
+ SessionIdentityMismatch,
83
+ answerFromEntry,
84
+ durableTurnResult,
85
+ durableWatchWindow,
86
+ hostSession,
87
+ openDurableHarness,
88
+ parseDurableRequestId,
89
+ prepareSubmissionStop,
90
+ steerRequestId,
91
+ turnRequestId
92
+ };