agent-neckbeard 1.1.23 → 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 CHANGED
@@ -2,6 +2,10 @@
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
+
5
9
  ## 1.1.23 - 2026-10-18
6
10
 
7
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.
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
 
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) return;
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) return;
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));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-neckbeard",
3
- "version": "1.1.23",
3
+ "version": "1.1.24",
4
4
  "description": "Deploy AI agents to E2B, Daytona, and Modal sandboxes, or local Docker containers",
5
5
  "type": "module",
6
6
  "exports": {