agent-neckbeard 1.1.22 → 1.1.24
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 +8 -0
- package/README.md +2 -2
- package/dist/index.cjs +15 -2
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +15 -2
- package/dist/supervisor.cjs +568 -916
- package/dist/supervisor.d.cts +1 -1
- package/dist/supervisor.d.ts +1 -1
- package/dist/supervisor.js +568 -916
- package/docs/SUPERVISOR.md +11 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 1.1.24 - 2026-10-22
|
|
6
|
+
|
|
7
|
+
- Make an attached turn's iterator complete only after the runtime's `done` event. A stream that ends without it now throws `ExecutionError`, and a turn cancelled by the session signal, `stop()`, or `close()` rejects with the cancellation reason instead of ending as if the turn had finished.
|
|
8
|
+
|
|
9
|
+
## 1.1.23 - 2026-10-18
|
|
10
|
+
|
|
11
|
+
- Upgrade the default Pi supervisor SDK to `@earendil-works/pi-coding-agent` 1.3.0. Callers that pin an older Pi SDK with `pi.expectedVersion` and `pi.packageLock` keep their prompt-rejection behavior.
|
|
12
|
+
|
|
5
13
|
## 1.1.22 - 2026-09-19
|
|
6
14
|
|
|
7
15
|
- Add a `modal` sandbox provider with private Connect Token HTTP auth and the shared managed detached controller; requires host Node.js 22+. See `docs/MODAL.md`.
|
package/README.md
CHANGED
|
@@ -224,7 +224,7 @@ try {
|
|
|
224
224
|
}
|
|
225
225
|
```
|
|
226
226
|
|
|
227
|
-
An attached session is a local handle over the sandbox HTTP/SSE runtime. It supports sequential `prompt()` calls, one active turn at a time, `stop()` for the active turn, and `close()` for the local handle. Closing it does not destroy the reusable sandbox. Pass `{ signal }` to `createSession()` to bind the complete local session lifetime to an external abort signal.
|
|
227
|
+
An attached session is a local handle over the sandbox HTTP/SSE runtime. It supports sequential `prompt()` calls, one active turn at a time, `stop()` for the active turn, and `close()` for the local handle. Closing it does not destroy the reusable sandbox. Pass `{ signal }` to `createSession()` to bind the complete local session lifetime to an external abort signal. A turn's iterator completes only after the runtime reports that the handler finished; a stream that ends early throws `ExecutionError`, and a turn cancelled by `stop()`, `close()`, or the session signal rejects with that cancellation reason.
|
|
228
228
|
|
|
229
229
|
The previous `server: { frameSchema, handler }` configuration remains as a deprecated alias for `session`. Likewise, `invoke(input, options)` remains as a deprecated compatibility wrapper: it creates one attached session, streams one prompt, and closes the local handle afterward.
|
|
230
230
|
|
|
@@ -352,7 +352,7 @@ try {
|
|
|
352
352
|
|
|
353
353
|
The artifact uses `attemptId` as its stable launch identity. The attempt credential must be an opaque 256-bit CSPRNG token encoded as canonical unpadded base64url (43 characters), matching Mission Control's credential generator; arbitrary passwords are rejected. Persist the sandbox ID and prepared process identity in the idempotent `beforeRelease` callback; returning from that callback is the authorization for the process to run. Replacing an exited generation invokes the callback with a new exact identity, which must replace the prior persisted identity; stale handles remain exactly fenced for stop, while diagnostic reads use before/after identity checks and may fail empty during replacement. A revision keyed by that high-entropy credential binds every replacement generation to the canonical launch environment without placing a dictionary-checkable value hash in lifecycle state, so rotating any value requires a replacement attempt instead of silently relaunching the old attempt with new credentials or configuration. A persistence failure is reported through the fixed, credential-safe `Supervisor prepared identity persistence failed.` message unless subsequent cleanup confirms that cancellation won. A confirmed cancellation proves the prepared generation cannot run and instead throws `SupervisorLaunchCancelledError` with stable code `NECKBEARD_SUPERVISOR_LAUNCH_CANCELLED`; its enumerable `name` and `code` remain usable when serialization preserves enumerable fields. A lost cleanup response is not classified as cancelled and remains safe to retry with the same attempt. If release already won, cancellation adopts the released identity instead of reporting a cancelled outcome. Terminal reconciliation must stop that persisted process identity and either delete the sandbox explicitly, as above, or apply an explicitly configured provider stop/delete policy. The supervisor embeds the pinned `@earendil-works/pi-coding-agent` SDK in-process, uses an outbound resumable WebSocket, attempt fencing, monotonic event IDs, a fsynced disk outbox, cumulative acknowledgments, command write-ahead deduplication, verified attachment materialization, normalized turn lifecycle, turn-boundary steering, heartbeat/reconnect, and idempotent interrupted-turn recovery. Its Daytona snapshot must provide Node.js 22.19.0 or newer. The artifact uploads graph-addressed staging files, then under one sandbox `flock` verifies their hashes, atomically publishes and fsyncs the final runtime/config/dependency files, and runs `npm ci`. After npm's graph and version checks, bootstrap creates a deterministic bounded manifest of every directory, regular file, and safe relative symlink in `node_modules`; it fsyncs regular files and directories bottom-up before atomically publishing and fsyncing that manifest, then re-verifies the finals and publishes the fsynced graph marker. The bootstrap lock remains necessary because a provider timeout does not prove the remote `npm ci` stopped; a retry may overlap the same shared installation. Bootstrap runs with an empty inherited environment, neutral npm user/global configuration, and no project `.npmrc`; failures expose only a bounded exit-code summary, never raw provider or install output. A marked retry skips `npm ci` only after verifying the final files and exact dependency graph plus a descriptor-bound read and full recomputation of the installed-tree manifest. An absent, malformed, unsafe, oversized, or content-mismatched manifest enters the existing locked repair path, while another graph fails without replacing it. Custom Pi coordinates require a caller-supplied matching credential-free lock. Credentials are never embedded in generated files or install commands; the gateway credential is removed before Pi loads, and the provider credential is moved into Pi's in-memory model runtime before tools run.
|
|
354
354
|
|
|
355
|
-
Each attempt's Pi JSONL history has a hard 64 MiB ceiling. Startup rejects a larger file or a legacy session version before the SDK parses or migrates it, and new prompts or steers are refused at 56 MiB so an already accepted turn has 8 MiB of logical headroom. Admission finishes with a synchronous retained-descriptor size check immediately before the Pi side effect. The pinned Pi 0
|
|
355
|
+
Each attempt's Pi JSONL history has a hard 64 MiB ceiling. Startup rejects a larger file or a legacy session version before the SDK parses or migrates it, and new prompts or steers are refused at 56 MiB so an already accepted turn has 8 MiB of logical headroom. Admission finishes with a synchronous retained-descriptor size check immediately before the Pi side effect. The pinned Pi 1.3.0 manager must remain in the append-only state established by the explicit session-file open; the guard serializes each pending JSONL line once, refuses a line that would cross the ceiling, writes those exact bytes through the retained descriptor, and verifies the exact size delta afterward. An unexpected private full-rewrite state fails before any write instead of estimating Pi's private in-memory history. Empty-file initialization is the only supported open-time rewrite; non-empty history must already use Pi session format version 3. Any append guard or postcondition failure terminally fails the attempt because Pi advances its in-memory tree before calling the persistence hook. Terminal history is file-fsynced plus parent-fsynced only while the canonical private leaf still matches the retained descriptor before and after that durability boundary. The 8 MiB margin is budgeting headroom for an accepted turn, not filesystem preallocation or a promise that every future record will fit; terminal/restart facts use the supervisor outbox's separate recovery reserve. Replace the attempt when prompt admission reaches this boundary.
|
|
356
356
|
|
|
357
357
|
For that cancellation outcome, `JSON.parse(JSON.stringify(error))` retains the public `name` and `code`. Arbitrary error serializers are not part of the contract.
|
|
358
358
|
|
package/dist/index.cjs
CHANGED
|
@@ -429,6 +429,7 @@ var AttachedAgentSessionImpl = class {
|
|
|
429
429
|
lifetime = new AbortController();
|
|
430
430
|
runPrompt;
|
|
431
431
|
configurationError;
|
|
432
|
+
abortError;
|
|
432
433
|
activeTurn = null;
|
|
433
434
|
externalSignal = null;
|
|
434
435
|
externalAbortListener = null;
|
|
@@ -438,6 +439,7 @@ var AttachedAgentSessionImpl = class {
|
|
|
438
439
|
this.sandboxId = options.sandboxId;
|
|
439
440
|
this.runPrompt = options.runPrompt;
|
|
440
441
|
this.configurationError = options.configurationError;
|
|
442
|
+
this.abortError = options.abortError;
|
|
441
443
|
const { externalSignal } = options;
|
|
442
444
|
if (externalSignal?.aborted) {
|
|
443
445
|
this.isClosed = true;
|
|
@@ -481,7 +483,10 @@ var AttachedAgentSessionImpl = class {
|
|
|
481
483
|
try {
|
|
482
484
|
while (true) {
|
|
483
485
|
const next = await iterator.next();
|
|
484
|
-
if (next.done)
|
|
486
|
+
if (next.done) {
|
|
487
|
+
if (linked.signal.aborted) throw this.abortError(linked.signal);
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
485
490
|
yield next.value;
|
|
486
491
|
}
|
|
487
492
|
} finally {
|
|
@@ -5850,7 +5855,8 @@ var require = __neckbeard_createRequire(import.meta.url);
|
|
|
5850
5855
|
sandboxId,
|
|
5851
5856
|
runPrompt: (input, signal2) => this.streamSessionPrompt(input, sandboxId, signal2),
|
|
5852
5857
|
...signal === void 0 ? {} : { externalSignal: signal },
|
|
5853
|
-
configurationError: (message) => new ConfigurationError(message)
|
|
5858
|
+
configurationError: (message) => new ConfigurationError(message),
|
|
5859
|
+
abortError: abortSignalError
|
|
5854
5860
|
});
|
|
5855
5861
|
}
|
|
5856
5862
|
async *streamSessionPrompt(input, sandboxId, signal) {
|
|
@@ -5866,6 +5872,7 @@ var require = __neckbeard_createRequire(import.meta.url);
|
|
|
5866
5872
|
throw new ValidationError("Input validation failed.", asError(error));
|
|
5867
5873
|
}
|
|
5868
5874
|
try {
|
|
5875
|
+
let finished = false;
|
|
5869
5876
|
for await (const frame of invokeServer2(validated, {
|
|
5870
5877
|
serverUrl: connection.serverUrl,
|
|
5871
5878
|
provider: connection.provider,
|
|
@@ -5879,8 +5886,14 @@ var require = __neckbeard_createRequire(import.meta.url);
|
|
|
5879
5886
|
const err = new ExecutionError(frame.error.message);
|
|
5880
5887
|
err.stack = frame.error.stack;
|
|
5881
5888
|
throw err;
|
|
5889
|
+
} else if (frame.kind === "done") {
|
|
5890
|
+
finished = true;
|
|
5882
5891
|
}
|
|
5883
5892
|
}
|
|
5893
|
+
if (!finished) {
|
|
5894
|
+
throwIfAborted(signal);
|
|
5895
|
+
throw new ExecutionError("Runtime stream ended before the turn finished.");
|
|
5896
|
+
}
|
|
5884
5897
|
} catch (error) {
|
|
5885
5898
|
if (error instanceof ExecutionError) throw error;
|
|
5886
5899
|
throw error instanceof Error ? error : new Error(String(error));
|
package/dist/index.d.cts
CHANGED
|
@@ -33,7 +33,9 @@ interface AttachedAgentSession<TInput, TFrame> {
|
|
|
33
33
|
readonly closed: boolean;
|
|
34
34
|
/**
|
|
35
35
|
* Starts one attached turn. Turns may be issued sequentially against the
|
|
36
|
-
* same sandbox runtime; only one turn may be active at a time.
|
|
36
|
+
* same sandbox runtime; only one turn may be active at a time. The iterator
|
|
37
|
+
* completes only after the runtime finishes the turn; a turn cancelled by
|
|
38
|
+
* `stop()`, `close()` or the session signal rejects with that reason.
|
|
37
39
|
*/
|
|
38
40
|
prompt(input: TInput): AsyncGenerator<TFrame>;
|
|
39
41
|
/** Cancels the active turn without destroying the reusable sandbox. */
|
package/dist/index.d.ts
CHANGED
|
@@ -33,7 +33,9 @@ interface AttachedAgentSession<TInput, TFrame> {
|
|
|
33
33
|
readonly closed: boolean;
|
|
34
34
|
/**
|
|
35
35
|
* Starts one attached turn. Turns may be issued sequentially against the
|
|
36
|
-
* same sandbox runtime; only one turn may be active at a time.
|
|
36
|
+
* same sandbox runtime; only one turn may be active at a time. The iterator
|
|
37
|
+
* completes only after the runtime finishes the turn; a turn cancelled by
|
|
38
|
+
* `stop()`, `close()` or the session signal rejects with that reason.
|
|
37
39
|
*/
|
|
38
40
|
prompt(input: TInput): AsyncGenerator<TFrame>;
|
|
39
41
|
/** Cancels the active turn without destroying the reusable sandbox. */
|
package/dist/index.js
CHANGED
|
@@ -79,6 +79,7 @@ var AttachedAgentSessionImpl = class {
|
|
|
79
79
|
lifetime = new AbortController();
|
|
80
80
|
runPrompt;
|
|
81
81
|
configurationError;
|
|
82
|
+
abortError;
|
|
82
83
|
activeTurn = null;
|
|
83
84
|
externalSignal = null;
|
|
84
85
|
externalAbortListener = null;
|
|
@@ -88,6 +89,7 @@ var AttachedAgentSessionImpl = class {
|
|
|
88
89
|
this.sandboxId = options.sandboxId;
|
|
89
90
|
this.runPrompt = options.runPrompt;
|
|
90
91
|
this.configurationError = options.configurationError;
|
|
92
|
+
this.abortError = options.abortError;
|
|
91
93
|
const { externalSignal } = options;
|
|
92
94
|
if (externalSignal?.aborted) {
|
|
93
95
|
this.isClosed = true;
|
|
@@ -131,7 +133,10 @@ var AttachedAgentSessionImpl = class {
|
|
|
131
133
|
try {
|
|
132
134
|
while (true) {
|
|
133
135
|
const next = await iterator.next();
|
|
134
|
-
if (next.done)
|
|
136
|
+
if (next.done) {
|
|
137
|
+
if (linked.signal.aborted) throw this.abortError(linked.signal);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
135
140
|
yield next.value;
|
|
136
141
|
}
|
|
137
142
|
} finally {
|
|
@@ -3141,7 +3146,8 @@ var require = __neckbeard_createRequire(import.meta.url);
|
|
|
3141
3146
|
sandboxId,
|
|
3142
3147
|
runPrompt: (input, signal2) => this.streamSessionPrompt(input, sandboxId, signal2),
|
|
3143
3148
|
...signal === void 0 ? {} : { externalSignal: signal },
|
|
3144
|
-
configurationError: (message) => new ConfigurationError(message)
|
|
3149
|
+
configurationError: (message) => new ConfigurationError(message),
|
|
3150
|
+
abortError: abortSignalError
|
|
3145
3151
|
});
|
|
3146
3152
|
}
|
|
3147
3153
|
async *streamSessionPrompt(input, sandboxId, signal) {
|
|
@@ -3157,6 +3163,7 @@ var require = __neckbeard_createRequire(import.meta.url);
|
|
|
3157
3163
|
throw new ValidationError("Input validation failed.", asError(error));
|
|
3158
3164
|
}
|
|
3159
3165
|
try {
|
|
3166
|
+
let finished = false;
|
|
3160
3167
|
for await (const frame of invokeServer(validated, {
|
|
3161
3168
|
serverUrl: connection.serverUrl,
|
|
3162
3169
|
provider: connection.provider,
|
|
@@ -3170,8 +3177,14 @@ var require = __neckbeard_createRequire(import.meta.url);
|
|
|
3170
3177
|
const err = new ExecutionError(frame.error.message);
|
|
3171
3178
|
err.stack = frame.error.stack;
|
|
3172
3179
|
throw err;
|
|
3180
|
+
} else if (frame.kind === "done") {
|
|
3181
|
+
finished = true;
|
|
3173
3182
|
}
|
|
3174
3183
|
}
|
|
3184
|
+
if (!finished) {
|
|
3185
|
+
throwIfAborted(signal);
|
|
3186
|
+
throw new ExecutionError("Runtime stream ended before the turn finished.");
|
|
3187
|
+
}
|
|
3175
3188
|
} catch (error) {
|
|
3176
3189
|
if (error instanceof ExecutionError) throw error;
|
|
3177
3190
|
throw error instanceof Error ? error : new Error(String(error));
|