nexus-agents 2.173.1 → 2.173.2

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.
@@ -21,7 +21,7 @@ import {
21
21
  DEFAULT_TASK_TTL_MS,
22
22
  DEFAULT_TOOL_RATE_LIMITS,
23
23
  clampTaskTtl
24
- } from "./chunk-OKZ72FVJ.js";
24
+ } from "./chunk-H63X54TU.js";
25
25
  import {
26
26
  executeExpert
27
27
  } from "./chunk-MBTEWGZK.js";
@@ -12400,6 +12400,9 @@ INDICATORS FOUND: ${ctx.failure.indicators.join("; ")}
12400
12400
  };
12401
12401
 
12402
12402
  // src/agents/experts/expert-recovery.ts
12403
+ var EXPERT_ERROR_TEXT_CONFIDENCE_THRESHOLD = 0.4;
12404
+ var EXPERT_RECOVERY_DEFAULT_MAX_RETRIES = 1;
12405
+ var MAX_CAUSE_DEPTH = 10;
12403
12406
  var RECOVERABLE_ACTIONS = /* @__PURE__ */ new Set([
12404
12407
  "retry_with_inspection",
12405
12408
  "tool_validation",
@@ -12408,7 +12411,7 @@ var RECOVERABLE_ACTIONS = /* @__PURE__ */ new Set([
12408
12411
  function isRetryableErrorChain(error) {
12409
12412
  let current = error;
12410
12413
  const seen = /* @__PURE__ */ new Set();
12411
- for (let depth = 0; current !== null && current !== void 0 && depth < 10; depth++) {
12414
+ for (let depth = 0; current !== null && current !== void 0 && depth < MAX_CAUSE_DEPTH; depth++) {
12412
12415
  if (seen.has(current)) break;
12413
12416
  seen.add(current);
12414
12417
  if (isRetryableError(current)) return true;
@@ -12420,7 +12423,7 @@ function extractErrorMessage(error) {
12420
12423
  const parts = [];
12421
12424
  let current = error;
12422
12425
  const seen = /* @__PURE__ */ new Set();
12423
- for (let depth = 0; current !== null && current !== void 0 && depth < 10; depth++) {
12426
+ for (let depth = 0; current !== null && current !== void 0 && depth < MAX_CAUSE_DEPTH; depth++) {
12424
12427
  if (seen.has(current)) break;
12425
12428
  seen.add(current);
12426
12429
  parts.push(getErrorMessage(current));
@@ -12461,7 +12464,7 @@ function classifyExpertFailure(error, detector, taskDescription, signal) {
12461
12464
  }
12462
12465
  function mergeRecoveryConfig(policy) {
12463
12466
  return {
12464
- maxRetries: policy.maxRetries ?? DEFAULT_RETRY_CONFIG.maxRetries,
12467
+ maxRetries: policy.maxRetries ?? EXPERT_RECOVERY_DEFAULT_MAX_RETRIES,
12465
12468
  baseDelayMs: policy.baseDelayMs ?? DEFAULT_RETRY_CONFIG.baseDelayMs,
12466
12469
  maxDelayMs: policy.maxDelayMs ?? DEFAULT_RETRY_CONFIG.maxDelayMs,
12467
12470
  jitterFactor: policy.jitterFactor ?? DEFAULT_RETRY_CONFIG.jitterFactor
@@ -12470,10 +12473,10 @@ function mergeRecoveryConfig(policy) {
12470
12473
  function buildRecoveryTrace(exhausted, classification) {
12471
12474
  const recovery = {
12472
12475
  attempts: exhausted.attempts,
12473
- classification: classification?.kind ?? "permanent"
12476
+ classification: classification.kind,
12477
+ source: classification.source
12474
12478
  };
12475
- if (classification?.source !== void 0) recovery.source = classification.source;
12476
- if (classification?.archetype !== void 0) recovery.archetype = classification.archetype;
12479
+ if (classification.archetype !== void 0) recovery.archetype = classification.archetype;
12477
12480
  return recovery;
12478
12481
  }
12479
12482
  function resolveRecoveryCause(base, lastError) {
@@ -12500,7 +12503,10 @@ var RecoverableExpert = class extends Expert {
12500
12503
  recoveryLogger;
12501
12504
  constructor(options, config, policy) {
12502
12505
  super(options, config);
12503
- this.detector = new FailureDetector(policy.detectorConfig ?? {});
12506
+ this.detector = new FailureDetector({
12507
+ confidenceThreshold: EXPERT_ERROR_TEXT_CONFIDENCE_THRESHOLD,
12508
+ ...policy.detectorConfig
12509
+ });
12504
12510
  this.recoveryManager = new RecoveryManager();
12505
12511
  this.recoveryConfig = mergeRecoveryConfig(policy);
12506
12512
  this.recoveryLogger = options.logger ?? createLogger({ component: "RecoverableExpert", expert: config.id });
@@ -12546,7 +12552,22 @@ var RecoverableExpert = class extends Expert {
12546
12552
  }
12547
12553
  );
12548
12554
  if (outcome.ok) return ok(outcome.value);
12549
- return err(annotateRecoveryFailure(outcome.error, lastClassification, this.expertConfig.id));
12555
+ return err(this.annotateExhausted(outcome.error, currentTask, signal));
12556
+ }
12557
+ /**
12558
+ * Builds the annotated failure returned when recovery is exhausted. withRetry
12559
+ * skips isRetryable on the final attempt, so the per-attempt `lastClassification`
12560
+ * can be stale (or undefined for maxRetries:0). Re-classify the actual `lastError`
12561
+ * so the recovery trace labels the failure that was truly returned.
12562
+ */
12563
+ annotateExhausted(exhausted, currentTask, signal) {
12564
+ const finalClassification = classifyExpertFailure(
12565
+ exhausted.lastError,
12566
+ this.detector,
12567
+ currentTask.description,
12568
+ signal
12569
+ );
12570
+ return annotateRecoveryFailure(exhausted, finalClassification, this.expertConfig.id);
12550
12571
  }
12551
12572
  /** Appends archetype recovery guidance to a mutable copy of the task. */
12552
12573
  injectRecoveryGuidance(task, archetype, info) {
@@ -12579,7 +12600,7 @@ var RecoverableExpert = class extends Expert {
12579
12600
  severity: "medium",
12580
12601
  description: DEFAULT_RECOVERY_STRATEGIES[archetype].instructions,
12581
12602
  indicators: [],
12582
- confidence: DEFAULT_DETECTOR_CONFIG.confidenceThreshold,
12603
+ confidence: EXPERT_ERROR_TEXT_CONFIDENCE_THRESHOLD,
12583
12604
  timestamp: getTimeProvider().now()
12584
12605
  };
12585
12606
  }
@@ -54000,4 +54021,4 @@ export {
54000
54021
  shutdownFeedbackSubscriber,
54001
54022
  createEventBusBridge
54002
54023
  };
54003
- //# sourceMappingURL=chunk-CC3H5XJR.js.map
54024
+ //# sourceMappingURL=chunk-5UKKGPRS.js.map