@tangle-network/agent-app 0.63.4 → 0.63.6

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.
@@ -3228,6 +3228,7 @@ async function* detachedSandboxPromptEvents(box, prompt, options, backend) {
3228
3228
  if (!sessionId || !executionId) {
3229
3229
  throw new Error("streamSandboxPrompt detach requires stable sessionId and executionId");
3230
3230
  }
3231
+ options.signal?.throwIfAborted();
3231
3232
  const lastEventId = options.lastEventId?.trim() || void 0;
3232
3233
  const turnId = options.turnId?.trim() || executionId;
3233
3234
  const admission = lastEventId ? null : await box.dispatchPrompt(prompt, {
@@ -3242,20 +3243,24 @@ async function* detachedSandboxPromptEvents(box, prompt, options, backend) {
3242
3243
  ...options.ttlMs !== void 0 ? { ttlMs: options.ttlMs } : {},
3243
3244
  ...options.trace ? { traceId: options.trace.traceId } : {}
3244
3245
  });
3245
- const admittedExecutionId = admission?.executionId ?? executionId;
3246
- if (!admittedExecutionId) {
3247
- throw new Error(`detached Sandbox dispatch for ${sessionId} returned no executionId`);
3248
- }
3246
+ options.signal?.throwIfAborted();
3249
3247
  if (admission?.dispatched === false) {
3250
3248
  const cached = await box.findCompletedTurn(turnId, { sessionId });
3249
+ options.signal?.throwIfAborted();
3251
3250
  if (cached) {
3252
- yield* cachedSandboxPromptEvents(cached, admittedExecutionId);
3251
+ if (cached.turnId !== turnId || cached.sessionId !== sessionId) {
3252
+ throw new Error("sandbox.detached_completed_turn_identity_mismatch");
3253
+ }
3254
+ yield* cachedSandboxPromptEvents(cached, executionId);
3253
3255
  return;
3254
3256
  }
3255
3257
  }
3258
+ if (admission && (admission.sessionId !== sessionId || admission.executionId !== executionId)) {
3259
+ throw new Error("sandbox.detached_admission_identity_mismatch");
3260
+ }
3256
3261
  yield* box.streamPrompt("", {
3257
- sessionId: admission?.sessionId ?? sessionId,
3258
- executionId: admittedExecutionId,
3262
+ sessionId,
3263
+ executionId,
3259
3264
  lastEventId: lastEventId || "0",
3260
3265
  ...options.trace ? { traceId: options.trace.traceId } : {},
3261
3266
  ...options.signal ? { signal: options.signal } : {}
@@ -3418,6 +3423,7 @@ async function* resendRefusedDispatch(dispatch, signal) {
3418
3423
  let firstSeenAt;
3419
3424
  for (let attempts = 1; ; attempts += 1) {
3420
3425
  try {
3426
+ signal?.throwIfAborted();
3421
3427
  for await (const event of dispatch()) {
3422
3428
  delivered = true;
3423
3429
  yield event;
@@ -3445,7 +3451,9 @@ async function* resendRefusedDispatch(dispatch, signal) {
3445
3451
  }
3446
3452
  }
3447
3453
  async function* streamSandboxPrompt(shell, box, message, options) {
3454
+ options?.signal?.throwIfAborted();
3448
3455
  const backend = await resolveSandboxPromptBackend(shell, options ?? {}, "streamSandboxPrompt");
3456
+ options?.signal?.throwIfAborted();
3449
3457
  const prompt = typeof message === "string" ? flattenHistory(message, options?.history) : mergeHistoryIntoParts(message, options?.history);
3450
3458
  const dispatch = () => options?.detach ? detachedSandboxPromptEvents(box, prompt, options, backend) : box.streamPrompt(prompt, {
3451
3459
  sessionId: options?.sessionId,
@@ -3748,4 +3756,4 @@ export {
3748
3756
  sandboxPromptRunner,
3749
3757
  createSandboxRunTool
3750
3758
  };
3751
- //# sourceMappingURL=chunk-72ASTUPN.js.map
3759
+ //# sourceMappingURL=chunk-OCR36QGZ.js.map