@axlsdk/axl 0.24.2 → 0.24.3

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/dist/index.cjs CHANGED
@@ -343,6 +343,12 @@ function isEventStreamOverflowError(error) {
343
343
  function rethrowEventStreamOverflow(error) {
344
344
  if (isEventStreamOverflowError(error)) throw error;
345
345
  }
346
+ function isUnrecoverableError(error) {
347
+ return isEventStreamOverflowError(error) || isAdmissionDeniedError(error);
348
+ }
349
+ function rethrowUnrecoverable(error) {
350
+ if (isUnrecoverableError(error)) throw error;
351
+ }
346
352
  function preserveErrorCause(error, cause) {
347
353
  if (cause === void 0 || cause === error || "cause" in error) return error;
348
354
  Object.defineProperty(error, "cause", {
@@ -557,7 +563,7 @@ var sharedGuard = typeof installedGuard === "object" && installedGuard !== null
557
563
  var buildPath = typeof __AXL_BUILD_PATH__ === "string" ? __AXL_BUILD_PATH__ : "<source>";
558
564
  var thisCopy = {
559
565
  path: buildPath.startsWith("file:") ? (0, import_node_url.fileURLToPath)(buildPath) : buildPath,
560
- version: true ? "0.24.2" : "unknown"
566
+ version: true ? "0.24.3" : "unknown"
561
567
  };
562
568
  function warnCrossCopy(other, joined) {
563
569
  if (other === thisCopy) return;
@@ -1451,8 +1457,7 @@ function tool(config) {
1451
1457
  } catch (err) {
1452
1458
  if (options?.signal?.aborted) options.signal.throwIfAborted();
1453
1459
  if (isAbortError(err)) throw err;
1454
- if (isAdmissionDeniedError(err)) throw err;
1455
- rethrowEventStreamOverflow(err);
1460
+ rethrowUnrecoverable(err);
1456
1461
  lastError = err instanceof Error ? err : new Error(String(err));
1457
1462
  if (attempt === maxAttempts) break;
1458
1463
  if (retryPolicy.on && !retryPolicy.on(lastError)) {
@@ -12588,8 +12593,7 @@ async function executeAcceptedTool(options) {
12588
12593
  }
12589
12594
  }
12590
12595
  } catch (error) {
12591
- rethrowEventStreamOverflow(error);
12592
- if (isAdmissionDeniedError(error)) throw error;
12596
+ rethrowUnrecoverable(error);
12593
12597
  const abort = cancellationError(signal, error);
12594
12598
  if (abort !== void 0) return cancellation("handler", abort);
12595
12599
  return failed("handler", error, { attempts });
@@ -14855,7 +14859,8 @@ ${appendedSchemaText}`;
14855
14859
  metadata: this.metadata
14856
14860
  });
14857
14861
  } catch (err) {
14858
- rethrowEventStreamOverflow(err);
14862
+ rethrowUnrecoverable(err);
14863
+ if (this.currentSignal?.aborted) throw err;
14859
14864
  validateErr = err;
14860
14865
  const reason = err instanceof Error ? err.message : String(err);
14861
14866
  validateResult = { valid: false, reason: `Validator error: ${reason}` };
@@ -15446,15 +15451,13 @@ ${summaryResponse.content}`
15446
15451
  reject(new QuorumNotMet(quorum, successCount, results));
15447
15452
  }
15448
15453
  }).catch((err) => {
15449
- if (isEventStreamOverflowError(err)) {
15450
- if (!settled) {
15451
- settled = true;
15452
- controller.abort();
15453
- reject(err);
15454
- }
15454
+ if (settled) return;
15455
+ if (isUnrecoverableError(err) || parentSignal2?.aborted) {
15456
+ settled = true;
15457
+ controller.abort();
15458
+ reject(err);
15455
15459
  return;
15456
15460
  }
15457
- if (settled) return;
15458
15461
  const isAbort = err instanceof DOMException && err.name === "AbortError";
15459
15462
  if (isAbort) {
15460
15463
  completedCount++;
@@ -15477,7 +15480,8 @@ ${summaryResponse.content}`
15477
15480
  const parentSignal = this.currentSignal;
15478
15481
  const promises = Array.from({ length: n }, (_, i) => {
15479
15482
  const run = () => fn(i).then((value) => ({ ok: true, value })).catch((err) => {
15480
- rethrowEventStreamOverflow(err);
15483
+ rethrowUnrecoverable(err);
15484
+ if (parentSignal?.aborted) throw err;
15481
15485
  return {
15482
15486
  ok: false,
15483
15487
  error: err instanceof Error ? err.message : String(err)
@@ -15601,6 +15605,7 @@ ${summaryResponse.content}`
15601
15605
  async verify(fn, schema, options) {
15602
15606
  const maxRetries = options?.retries ?? 3;
15603
15607
  let lastRetry = void 0;
15608
+ const scopeSignal = this.currentSignal;
15604
15609
  const emitVerifyOutcome = (passed, attempts, lastError) => {
15605
15610
  this.emitEvent({
15606
15611
  type: "verify",
@@ -15623,25 +15628,24 @@ ${summaryResponse.content}`
15623
15628
  try {
15624
15629
  validateResult = await options.validate(parsed, { metadata: this.metadata });
15625
15630
  } catch (err) {
15626
- rethrowEventStreamOverflow(err);
15631
+ rethrowUnrecoverable(err);
15632
+ if (scopeSignal?.aborted) throw err;
15627
15633
  const reason = err instanceof Error ? err.message : String(err);
15628
15634
  validateResult = { valid: false, reason: `Validator error: ${reason}` };
15629
15635
  }
15630
15636
  if (!validateResult.valid) {
15637
+ scopeSignal?.throwIfAborted();
15631
15638
  const errorMsg = validateResult.reason ?? "Validation failed";
15632
15639
  lastRetry = { error: errorMsg, output: rawOutput, parsed };
15633
- if (attempt === maxRetries) {
15634
- emitVerifyOutcome(false, attempt + 1, errorMsg);
15635
- if (options?.fallback !== void 0) return options.fallback;
15636
- throw new ValidationError(parsed, errorMsg, maxRetries);
15637
- }
15640
+ if (attempt === maxRetries) throw new ValidationError(parsed, errorMsg, maxRetries);
15638
15641
  continue;
15639
15642
  }
15640
15643
  }
15641
15644
  emitVerifyOutcome(true, attempt + 1);
15642
15645
  return parsed;
15643
15646
  } catch (err) {
15644
- rethrowEventStreamOverflow(err);
15647
+ rethrowUnrecoverable(err);
15648
+ if (scopeSignal?.aborted) throw err;
15645
15649
  if (err instanceof ValidationError) {
15646
15650
  lastRetry = {
15647
15651
  error: err.reason,
@@ -15708,7 +15712,8 @@ ${summaryResponse.content}`
15708
15712
  const unpriced = this.budgetContext.unpriced;
15709
15713
  return { value, budgetExceeded: exceeded, totalCost, unpriced };
15710
15714
  } catch (err) {
15711
- rethrowEventStreamOverflow(err);
15715
+ rethrowUnrecoverable(err);
15716
+ if (parentSignal?.aborted) throw err;
15712
15717
  if (this.budgetContext.exceeded) {
15713
15718
  return {
15714
15719
  value: null,
@@ -15717,14 +15722,6 @@ ${summaryResponse.content}`
15717
15722
  unpriced: this.budgetContext.unpriced
15718
15723
  };
15719
15724
  }
15720
- if (err instanceof DOMException && err.name === "AbortError" && controller) {
15721
- return {
15722
- value: null,
15723
- budgetExceeded: true,
15724
- totalCost: this.budgetContext.totalCost,
15725
- unpriced: this.budgetContext.unpriced
15726
- };
15727
- }
15728
15725
  throw err;
15729
15726
  } finally {
15730
15727
  if (parentBudget) {
@@ -15840,7 +15837,8 @@ ${summaryResponse.content}`
15840
15837
  return;
15841
15838
  }
15842
15839
  } catch (err) {
15843
- rethrowEventStreamOverflow(err);
15840
+ rethrowUnrecoverable(err);
15841
+ if (parentSignal?.aborted) throw err;
15844
15842
  remaining--;
15845
15843
  lastError = err instanceof Error ? err : new Error(`Validator error: ${String(err)}`);
15846
15844
  if (remaining === 0 && !settled) {
@@ -15860,7 +15858,7 @@ ${summaryResponse.content}`
15860
15858
  controller.abort();
15861
15859
  resolve2(value);
15862
15860
  }).catch((err) => {
15863
- if (isEventStreamOverflowError(err)) {
15861
+ if (isUnrecoverableError(err)) {
15864
15862
  if (!settled) {
15865
15863
  settled = true;
15866
15864
  controller.abort();
@@ -15869,6 +15867,12 @@ ${summaryResponse.content}`
15869
15867
  throw err;
15870
15868
  }
15871
15869
  if (settled) return;
15870
+ if (parentSignal?.aborted) {
15871
+ settled = true;
15872
+ controller.abort();
15873
+ reject(err);
15874
+ return;
15875
+ }
15872
15876
  if (err instanceof DOMException && err.name === "AbortError") {
15873
15877
  remaining--;
15874
15878
  if (remaining === 0 && !settled) {
@@ -15927,7 +15931,7 @@ ${summaryResponse.content}`
15927
15931
  results[idx] = { ok: true, value };
15928
15932
  successCount++;
15929
15933
  } catch (err) {
15930
- if (isEventStreamOverflowError(err)) {
15934
+ if (isUnrecoverableError(err)) {
15931
15935
  settled = true;
15932
15936
  controller?.abort();
15933
15937
  reject(err);
@@ -15936,6 +15940,12 @@ ${summaryResponse.content}`
15936
15940
  if (settled) {
15937
15941
  return;
15938
15942
  }
15943
+ if (parentSignal?.aborted) {
15944
+ settled = true;
15945
+ controller?.abort();
15946
+ reject(err);
15947
+ return;
15948
+ }
15939
15949
  if (err instanceof DOMException && err.name === "AbortError" && controller?.signal.aborted) {
15940
15950
  completedCount++;
15941
15951
  return;