@probelabs/probe 0.6.0-rc323 → 0.6.0-rc325

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/cjs/index.cjs CHANGED
@@ -19643,7 +19643,7 @@ var init_dist2 = __esm({
19643
19643
  "ETIMEDOUT",
19644
19644
  "EPIPE"
19645
19645
  ];
19646
- VERSION = true ? "4.0.27" : "0.0.0-test";
19646
+ VERSION = true ? "4.0.28" : "0.0.0-test";
19647
19647
  suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
19648
19648
  suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
19649
19649
  ignoreOverride = /* @__PURE__ */ Symbol(
@@ -27587,7 +27587,7 @@ var init_dist3 = __esm({
27587
27587
  schema: amazonBedrockEmbeddingModelOptionsSchema
27588
27588
  })) != null ? _a17 : {};
27589
27589
  const isNovaModel = this.modelId.startsWith("amazon.nova-") && this.modelId.includes("embed");
27590
- const isCohereModel = this.modelId.startsWith("cohere.embed-");
27590
+ const isCohereModel = this.modelId.includes("cohere.embed-");
27591
27591
  const args = isNovaModel ? {
27592
27592
  taskType: "SINGLE_EMBEDDING",
27593
27593
  singleEmbeddingParams: {
@@ -27611,7 +27611,7 @@ var init_dist3 = __esm({
27611
27611
  normalize: bedrockOptions.normalize
27612
27612
  };
27613
27613
  const url2 = this.getUrl(this.modelId);
27614
- const { value: response } = await postJsonToApi({
27614
+ const { value: response, responseHeaders } = await postJsonToApi({
27615
27615
  url: url2,
27616
27616
  headers: await resolve(
27617
27617
  combineHeaders(await resolve(this.config.headers), headers)
@@ -27640,7 +27640,10 @@ var init_dist3 = __esm({
27640
27640
  } else {
27641
27641
  embedding = response.embeddings.float[0];
27642
27642
  }
27643
- const tokens = "inputTextTokenCount" in response ? response.inputTextTokenCount : "inputTokenCount" in response ? (_f = response.inputTokenCount) != null ? _f : 0 : NaN;
27643
+ const headerTokenCount = Number(
27644
+ responseHeaders == null ? void 0 : responseHeaders["x-amzn-bedrock-input-token-count"]
27645
+ );
27646
+ const tokens = "inputTextTokenCount" in response ? response.inputTextTokenCount : "inputTokenCount" in response ? (_f = response.inputTokenCount) != null ? _f : 0 : headerTokenCount;
27644
27647
  return {
27645
27648
  embeddings: [embedding],
27646
27649
  usage: { tokens },
@@ -27863,7 +27866,7 @@ var init_dist3 = __esm({
27863
27866
  details: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
27864
27867
  preview: external_exports.unknown().optional()
27865
27868
  });
27866
- VERSION2 = true ? "4.0.112" : "0.0.0-test";
27869
+ VERSION2 = true ? "4.0.116" : "0.0.0-test";
27867
27870
  bedrockRerankingResponseSchema = lazySchema(
27868
27871
  () => zodSchema(
27869
27872
  external_exports.object({
@@ -86980,12 +86983,13 @@ function isRetryableError(error40, retryableErrors = DEFAULT_RETRYABLE_ERRORS) {
86980
86983
  if (!error40) return false;
86981
86984
  const errorString = error40.toString().toLowerCase();
86982
86985
  const errorMessage = (error40.message || "").toLowerCase();
86986
+ const errorName = (error40.name || error40.constructor?.name || "").toLowerCase();
86983
86987
  const errorCode = (error40.code || "").toLowerCase();
86984
86988
  const errorType = (error40.type || "").toLowerCase();
86985
86989
  const statusCode = error40.statusCode || error40.status;
86986
86990
  for (const pattern of retryableErrors) {
86987
86991
  const lowerPattern = pattern.toLowerCase();
86988
- if (errorString.includes(lowerPattern) || errorMessage.includes(lowerPattern) || errorCode.includes(lowerPattern) || errorType.includes(lowerPattern) || statusCode?.toString() === pattern) {
86992
+ if (errorString.includes(lowerPattern) || errorMessage.includes(lowerPattern) || errorName.includes(lowerPattern) || errorCode.includes(lowerPattern) || errorType.includes(lowerPattern) || statusCode?.toString() === pattern) {
86989
86993
  return true;
86990
86994
  }
86991
86995
  }
@@ -87022,7 +87026,9 @@ var init_RetryManager = __esm({
87022
87026
  "ECONNRESET",
87023
87027
  "ETIMEDOUT",
87024
87028
  "ENOTFOUND",
87025
- "api_error"
87029
+ "api_error",
87030
+ "No output generated",
87031
+ "AI_NoOutputGeneratedError"
87026
87032
  ];
87027
87033
  RetryManager = class {
87028
87034
  /**
@@ -87042,7 +87048,7 @@ var init_RetryManager = __esm({
87042
87048
  this.backoffFactor = this._validateNumber(options.backoffFactor, 2, "backoffFactor", 1, 10);
87043
87049
  this.retryableErrors = options.retryableErrors || DEFAULT_RETRYABLE_ERRORS;
87044
87050
  this.debug = options.debug ?? false;
87045
- this.jitter = options.jitter ?? true;
87051
+ this.jitter = typeof options.jitter === "boolean" ? options.jitter : true;
87046
87052
  if (this.maxDelay < this.initialDelay) {
87047
87053
  throw new Error("maxDelay must be greater than or equal to initialDelay");
87048
87054
  }
@@ -91424,6 +91430,9 @@ var init_acorn = __esm({
91424
91430
  // Can be either `"script"`, `"module"` or `"commonjs"`. This influences global
91425
91431
  // strict mode and parsing of `import` and `export` declarations.
91426
91432
  sourceType: "script",
91433
+ // When set to true, enable strict parsing mode even if `sourceType`
91434
+ // is `"script"`.
91435
+ strict: false,
91427
91436
  // `onInsertedSemicolon` can be a callback that will be called when
91428
91437
  // a semicolon is automatically inserted. It will be passed the
91429
91438
  // position of the inserted semicolon as an offset, and if
@@ -91562,7 +91571,7 @@ var init_acorn = __esm({
91562
91571
  this.context = this.initialContext();
91563
91572
  this.exprAllowed = true;
91564
91573
  this.inModule = options.sourceType === "module";
91565
- this.strict = this.inModule || this.strictDirective(this.pos);
91574
+ this.strict = this.inModule || options.strict === true || this.strictDirective(this.pos);
91566
91575
  this.potentialArrowAt = -1;
91567
91576
  this.potentialArrowInForAwait = false;
91568
91577
  this.yieldPos = this.awaitPos = this.awaitIdentPos = 0;
@@ -91580,9 +91589,12 @@ var init_acorn = __esm({
91580
91589
  };
91581
91590
  prototypeAccessors = { inFunction: { configurable: true }, inGenerator: { configurable: true }, inAsync: { configurable: true }, canAwait: { configurable: true }, allowReturn: { configurable: true }, allowSuper: { configurable: true }, allowDirectSuper: { configurable: true }, treatFunctionsAsVar: { configurable: true }, allowNewDotTarget: { configurable: true }, allowUsing: { configurable: true }, inClassStaticBlock: { configurable: true } };
91582
91591
  Parser2.prototype.parse = function parse8() {
91592
+ var this$1$1 = this;
91583
91593
  var node = this.options.program || this.startNode();
91584
91594
  this.nextToken();
91585
- return this.parseTopLevel(node);
91595
+ return this.catchStackOverflow(function() {
91596
+ return this$1$1.parseTopLevel(node);
91597
+ });
91586
91598
  };
91587
91599
  prototypeAccessors.inFunction.get = function() {
91588
91600
  return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0;
@@ -91716,6 +91728,17 @@ var init_acorn = __esm({
91716
91728
  this.next();
91717
91729
  return true;
91718
91730
  };
91731
+ pp$9.catchStackOverflow = function(f) {
91732
+ try {
91733
+ return f();
91734
+ } catch (e) {
91735
+ if (e instanceof Error && (/\bstack\b.*\b(exceeded|overflow)\b/i.test(e.message) || /\btoo much recursion\b/i.test(e.message))) {
91736
+ this.raise(this.start, "Not enough stack space to parse input");
91737
+ } else {
91738
+ throw e;
91739
+ }
91740
+ }
91741
+ };
91719
91742
  pp$9.expectContextual = function(name15) {
91720
91743
  if (!this.eatContextual(name15)) {
91721
91744
  this.unexpected();
@@ -91801,12 +91824,12 @@ var init_acorn = __esm({
91801
91824
  };
91802
91825
  pp$8 = Parser2.prototype;
91803
91826
  pp$8.parseTopLevel = function(node) {
91804
- var exports2 = /* @__PURE__ */ Object.create(null);
91827
+ var exports$1 = /* @__PURE__ */ Object.create(null);
91805
91828
  if (!node.body) {
91806
91829
  node.body = [];
91807
91830
  }
91808
91831
  while (this.type !== types$1.eof) {
91809
- var stmt = this.parseStatement(null, true, exports2);
91832
+ var stmt = this.parseStatement(null, true, exports$1);
91810
91833
  node.body.push(stmt);
91811
91834
  }
91812
91835
  if (this.inModule) {
@@ -91896,9 +91919,18 @@ var init_acorn = __esm({
91896
91919
  return true;
91897
91920
  }
91898
91921
  var id = this.input.slice(idStart, next);
91899
- if (keywordRelationalOperator.test(id) || isFor && id === "of") {
91922
+ if (keywordRelationalOperator.test(id)) {
91900
91923
  return false;
91901
91924
  }
91925
+ if (isFor && !isAwaitUsing && id === "of") {
91926
+ skipWhiteSpace.lastIndex = next;
91927
+ var skipAfterOf = skipWhiteSpace.exec(this.input);
91928
+ next = next + skipAfterOf[0].length;
91929
+ if (this.input.charCodeAt(next) !== 61 || // Check for ==, === and => operators
91930
+ (ch = this.input.charCodeAt(next + 1)) === 61 || ch === 62) {
91931
+ return false;
91932
+ }
91933
+ }
91902
91934
  return true;
91903
91935
  };
91904
91936
  pp$8.isAwaitUsing = function(isFor) {
@@ -91907,7 +91939,7 @@ var init_acorn = __esm({
91907
91939
  pp$8.isUsing = function(isFor) {
91908
91940
  return this.isUsingKeyword(false, isFor);
91909
91941
  };
91910
- pp$8.parseStatement = function(context, topLevel, exports2) {
91942
+ pp$8.parseStatement = function(context, topLevel, exports$1) {
91911
91943
  var starttype = this.type, node = this.startNode(), kind;
91912
91944
  if (this.isLet(context)) {
91913
91945
  starttype = types$1._var;
@@ -91976,7 +92008,7 @@ var init_acorn = __esm({
91976
92008
  this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'");
91977
92009
  }
91978
92010
  }
91979
- return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports2);
92011
+ return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports$1);
91980
92012
  // If the statement does not start with a statement keyword or a
91981
92013
  // brace, it's an ExpressionStatement or LabeledStatement. We
91982
92014
  // simply start parsing an expression, and afterwards, if the
@@ -91995,6 +92027,9 @@ var init_acorn = __esm({
91995
92027
  if (!this.allowUsing) {
91996
92028
  this.raise(this.start, "Using declaration cannot appear in the top level when source type is `script` or in the bare case statement");
91997
92029
  }
92030
+ if (context) {
92031
+ this.raise(this.start, "Using declaration is not allowed in single-statement positions");
92032
+ }
91998
92033
  if (usingKind === "await using") {
91999
92034
  if (!this.canAwait) {
92000
92035
  this.raise(this.start, "Await using cannot appear outside of async function");
@@ -92129,14 +92164,15 @@ var init_acorn = __esm({
92129
92164
  };
92130
92165
  pp$8.parseForAfterInit = function(node, init, awaitAt) {
92131
92166
  if ((this.type === types$1._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) && init.declarations.length === 1) {
92132
- if (this.options.ecmaVersion >= 9) {
92133
- if (this.type === types$1._in) {
92134
- if (awaitAt > -1) {
92135
- this.unexpected(awaitAt);
92136
- }
92137
- } else {
92138
- node.await = awaitAt > -1;
92167
+ if (this.type === types$1._in) {
92168
+ if ((init.kind === "using" || init.kind === "await using") && !init.declarations[0].init) {
92169
+ this.raise(this.start, "Using declaration is not allowed in for-in loops");
92139
92170
  }
92171
+ if (this.options.ecmaVersion >= 9 && awaitAt > -1) {
92172
+ this.unexpected(awaitAt);
92173
+ }
92174
+ } else if (this.options.ecmaVersion >= 9) {
92175
+ node.await = awaitAt > -1;
92140
92176
  }
92141
92177
  return this.parseForIn(node, init);
92142
92178
  }
@@ -92632,11 +92668,11 @@ var init_acorn = __esm({
92632
92668
  }
92633
92669
  }
92634
92670
  };
92635
- pp$8.parseExportAllDeclaration = function(node, exports2) {
92671
+ pp$8.parseExportAllDeclaration = function(node, exports$1) {
92636
92672
  if (this.options.ecmaVersion >= 11) {
92637
92673
  if (this.eatContextual("as")) {
92638
92674
  node.exported = this.parseModuleExportName();
92639
- this.checkExport(exports2, node.exported, this.lastTokStart);
92675
+ this.checkExport(exports$1, node.exported, this.lastTokStart);
92640
92676
  } else {
92641
92677
  node.exported = null;
92642
92678
  }
@@ -92652,22 +92688,22 @@ var init_acorn = __esm({
92652
92688
  this.semicolon();
92653
92689
  return this.finishNode(node, "ExportAllDeclaration");
92654
92690
  };
92655
- pp$8.parseExport = function(node, exports2) {
92691
+ pp$8.parseExport = function(node, exports$1) {
92656
92692
  this.next();
92657
92693
  if (this.eat(types$1.star)) {
92658
- return this.parseExportAllDeclaration(node, exports2);
92694
+ return this.parseExportAllDeclaration(node, exports$1);
92659
92695
  }
92660
92696
  if (this.eat(types$1._default)) {
92661
- this.checkExport(exports2, "default", this.lastTokStart);
92697
+ this.checkExport(exports$1, "default", this.lastTokStart);
92662
92698
  node.declaration = this.parseExportDefaultDeclaration();
92663
92699
  return this.finishNode(node, "ExportDefaultDeclaration");
92664
92700
  }
92665
92701
  if (this.shouldParseExportStatement()) {
92666
92702
  node.declaration = this.parseExportDeclaration(node);
92667
92703
  if (node.declaration.type === "VariableDeclaration") {
92668
- this.checkVariableExport(exports2, node.declaration.declarations);
92704
+ this.checkVariableExport(exports$1, node.declaration.declarations);
92669
92705
  } else {
92670
- this.checkExport(exports2, node.declaration.id, node.declaration.id.start);
92706
+ this.checkExport(exports$1, node.declaration.id, node.declaration.id.start);
92671
92707
  }
92672
92708
  node.specifiers = [];
92673
92709
  node.source = null;
@@ -92676,7 +92712,7 @@ var init_acorn = __esm({
92676
92712
  }
92677
92713
  } else {
92678
92714
  node.declaration = null;
92679
- node.specifiers = this.parseExportSpecifiers(exports2);
92715
+ node.specifiers = this.parseExportSpecifiers(exports$1);
92680
92716
  if (this.eatContextual("from")) {
92681
92717
  if (this.type !== types$1.string) {
92682
92718
  this.unexpected();
@@ -92724,66 +92760,66 @@ var init_acorn = __esm({
92724
92760
  return declaration;
92725
92761
  }
92726
92762
  };
92727
- pp$8.checkExport = function(exports2, name15, pos) {
92728
- if (!exports2) {
92763
+ pp$8.checkExport = function(exports$1, name15, pos) {
92764
+ if (!exports$1) {
92729
92765
  return;
92730
92766
  }
92731
92767
  if (typeof name15 !== "string") {
92732
92768
  name15 = name15.type === "Identifier" ? name15.name : name15.value;
92733
92769
  }
92734
- if (hasOwn(exports2, name15)) {
92770
+ if (hasOwn(exports$1, name15)) {
92735
92771
  this.raiseRecoverable(pos, "Duplicate export '" + name15 + "'");
92736
92772
  }
92737
- exports2[name15] = true;
92773
+ exports$1[name15] = true;
92738
92774
  };
92739
- pp$8.checkPatternExport = function(exports2, pat) {
92775
+ pp$8.checkPatternExport = function(exports$1, pat) {
92740
92776
  var type = pat.type;
92741
92777
  if (type === "Identifier") {
92742
- this.checkExport(exports2, pat, pat.start);
92778
+ this.checkExport(exports$1, pat, pat.start);
92743
92779
  } else if (type === "ObjectPattern") {
92744
92780
  for (var i = 0, list = pat.properties; i < list.length; i += 1) {
92745
92781
  var prop = list[i];
92746
- this.checkPatternExport(exports2, prop);
92782
+ this.checkPatternExport(exports$1, prop);
92747
92783
  }
92748
92784
  } else if (type === "ArrayPattern") {
92749
92785
  for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
92750
92786
  var elt = list$1[i$1];
92751
92787
  if (elt) {
92752
- this.checkPatternExport(exports2, elt);
92788
+ this.checkPatternExport(exports$1, elt);
92753
92789
  }
92754
92790
  }
92755
92791
  } else if (type === "Property") {
92756
- this.checkPatternExport(exports2, pat.value);
92792
+ this.checkPatternExport(exports$1, pat.value);
92757
92793
  } else if (type === "AssignmentPattern") {
92758
- this.checkPatternExport(exports2, pat.left);
92794
+ this.checkPatternExport(exports$1, pat.left);
92759
92795
  } else if (type === "RestElement") {
92760
- this.checkPatternExport(exports2, pat.argument);
92796
+ this.checkPatternExport(exports$1, pat.argument);
92761
92797
  }
92762
92798
  };
92763
- pp$8.checkVariableExport = function(exports2, decls) {
92764
- if (!exports2) {
92799
+ pp$8.checkVariableExport = function(exports$1, decls) {
92800
+ if (!exports$1) {
92765
92801
  return;
92766
92802
  }
92767
92803
  for (var i = 0, list = decls; i < list.length; i += 1) {
92768
92804
  var decl = list[i];
92769
- this.checkPatternExport(exports2, decl.id);
92805
+ this.checkPatternExport(exports$1, decl.id);
92770
92806
  }
92771
92807
  };
92772
92808
  pp$8.shouldParseExportStatement = function() {
92773
92809
  return this.type.keyword === "var" || this.type.keyword === "const" || this.type.keyword === "class" || this.type.keyword === "function" || this.isLet() || this.isAsyncFunction();
92774
92810
  };
92775
- pp$8.parseExportSpecifier = function(exports2) {
92811
+ pp$8.parseExportSpecifier = function(exports$1) {
92776
92812
  var node = this.startNode();
92777
92813
  node.local = this.parseModuleExportName();
92778
92814
  node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local;
92779
92815
  this.checkExport(
92780
- exports2,
92816
+ exports$1,
92781
92817
  node.exported,
92782
92818
  node.exported.start
92783
92819
  );
92784
92820
  return this.finishNode(node, "ExportSpecifier");
92785
92821
  };
92786
- pp$8.parseExportSpecifiers = function(exports2) {
92822
+ pp$8.parseExportSpecifiers = function(exports$1) {
92787
92823
  var nodes = [], first2 = true;
92788
92824
  this.expect(types$1.braceL);
92789
92825
  while (!this.eat(types$1.braceR)) {
@@ -92795,7 +92831,7 @@ var init_acorn = __esm({
92795
92831
  } else {
92796
92832
  first2 = false;
92797
92833
  }
92798
- nodes.push(this.parseExportSpecifier(exports2));
92834
+ nodes.push(this.parseExportSpecifier(exports$1));
92799
92835
  }
92800
92836
  return nodes;
92801
92837
  };
@@ -93363,17 +93399,20 @@ var init_acorn = __esm({
93363
93399
  other[kind] = true;
93364
93400
  };
93365
93401
  pp$5.parseExpression = function(forInit, refDestructuringErrors) {
93366
- var startPos = this.start, startLoc = this.startLoc;
93367
- var expr = this.parseMaybeAssign(forInit, refDestructuringErrors);
93368
- if (this.type === types$1.comma) {
93369
- var node = this.startNodeAt(startPos, startLoc);
93370
- node.expressions = [expr];
93371
- while (this.eat(types$1.comma)) {
93372
- node.expressions.push(this.parseMaybeAssign(forInit, refDestructuringErrors));
93402
+ var this$1$1 = this;
93403
+ return this.catchStackOverflow(function() {
93404
+ var startPos = this$1$1.start, startLoc = this$1$1.startLoc;
93405
+ var expr = this$1$1.parseMaybeAssign(forInit, refDestructuringErrors);
93406
+ if (this$1$1.type === types$1.comma) {
93407
+ var node = this$1$1.startNodeAt(startPos, startLoc);
93408
+ node.expressions = [expr];
93409
+ while (this$1$1.eat(types$1.comma)) {
93410
+ node.expressions.push(this$1$1.parseMaybeAssign(forInit, refDestructuringErrors));
93411
+ }
93412
+ return this$1$1.finishNode(node, "SequenceExpression");
93373
93413
  }
93374
- return this.finishNode(node, "SequenceExpression");
93375
- }
93376
- return expr;
93414
+ return expr;
93415
+ });
93377
93416
  };
93378
93417
  pp$5.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse) {
93379
93418
  if (this.isContextual("yield")) {
@@ -93445,7 +93484,7 @@ var init_acorn = __esm({
93445
93484
  if (this.checkExpressionErrors(refDestructuringErrors)) {
93446
93485
  return expr;
93447
93486
  }
93448
- if (this.eat(types$1.question)) {
93487
+ if (!(expr.type === "ArrowFunctionExpression" && expr.start === startPos) && this.eat(types$1.question)) {
93449
93488
  var node = this.startNodeAt(startPos, startLoc);
93450
93489
  node.test = expr;
93451
93490
  node.consequent = this.parseMaybeAssign();
@@ -93938,6 +93977,9 @@ var init_acorn = __esm({
93938
93977
  }
93939
93978
  var startPos = this.start, startLoc = this.startLoc;
93940
93979
  node.callee = this.parseSubscripts(this.parseExprAtom(null, false, true), startPos, startLoc, true, false);
93980
+ if (node.callee.type === "Super") {
93981
+ this.raiseRecoverable(startPos, "Invalid use of 'super'");
93982
+ }
93941
93983
  if (this.eat(types$1.parenL)) {
93942
93984
  node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false);
93943
93985
  } else {
@@ -96590,7 +96632,7 @@ var init_acorn = __esm({
96590
96632
  }
96591
96633
  return this.finishToken(type, word);
96592
96634
  };
96593
- version2 = "8.16.0";
96635
+ version2 = "8.17.0";
96594
96636
  Parser2.acorn = {
96595
96637
  Parser: Parser2,
96596
96638
  version: version2,
@@ -102761,27 +102803,41 @@ var init_ProbeAgent = __esm({
102761
102803
  timeoutState
102762
102804
  );
102763
102805
  }
102806
+ /**
102807
+ * Create a RetryManager from the agent's retry configuration.
102808
+ * @param {Object} [overrides={}] - Retry option overrides
102809
+ * @returns {RetryManager}
102810
+ * @private
102811
+ */
102812
+ _createRetryManager(overrides = {}) {
102813
+ return new RetryManager({
102814
+ maxRetries: overrides.maxRetries ?? this.retryConfig.maxRetries ?? 3,
102815
+ initialDelay: overrides.initialDelay ?? this.retryConfig.initialDelay ?? 1e3,
102816
+ maxDelay: overrides.maxDelay ?? this.retryConfig.maxDelay ?? 3e4,
102817
+ backoffFactor: overrides.backoffFactor ?? this.retryConfig.backoffFactor ?? 2,
102818
+ retryableErrors: overrides.retryableErrors ?? this.retryConfig.retryableErrors,
102819
+ jitter: overrides.jitter ?? this.retryConfig.jitter,
102820
+ debug: overrides.debug ?? this.debug
102821
+ });
102822
+ }
102764
102823
  /**
102765
102824
  * Execute streamText with Vercel AI SDK using retry/fallback logic
102766
102825
  * @param {Object} options - streamText options
102767
102826
  * @param {AbortController} controller - Abort controller for the operation
102827
+ * @param {Function} [consumeResult] - Optional callback to consume the stream result inside the same retry budget
102768
102828
  * @returns {Promise<Object>} - Stream result
102769
102829
  * @private
102770
102830
  */
102771
- async _executeWithVercelProvider(options, controller) {
102831
+ async _executeWithVercelProvider(options, controller, consumeResult) {
102772
102832
  if (!this.retryManager) {
102773
- this.retryManager = new RetryManager({
102774
- maxRetries: this.retryConfig.maxRetries ?? 3,
102775
- initialDelay: this.retryConfig.initialDelay ?? 1e3,
102776
- maxDelay: this.retryConfig.maxDelay ?? 3e4,
102777
- backoffFactor: this.retryConfig.backoffFactor ?? 2,
102778
- retryableErrors: this.retryConfig.retryableErrors,
102779
- debug: this.debug
102780
- });
102833
+ this.retryManager = this._createRetryManager();
102781
102834
  }
102782
102835
  if (!this.fallbackManager) {
102783
102836
  return await this.retryManager.executeWithRetry(
102784
- () => (0, import_ai4.streamText)({ ...options, abortSignal: controller.signal }),
102837
+ async () => {
102838
+ const result = (0, import_ai4.streamText)({ ...options, abortSignal: controller.signal });
102839
+ return consumeResult ? await consumeResult(result) : result;
102840
+ },
102785
102841
  {
102786
102842
  provider: this.apiType,
102787
102843
  model: this.model,
@@ -102806,16 +102862,14 @@ var init_ProbeAgent = __esm({
102806
102862
  console.error(`[DEBUG] Stripped Gemini built-in tools for fallback to ${config2.provider} provider`);
102807
102863
  }
102808
102864
  }
102809
- const providerRetryManager = new RetryManager({
102810
- maxRetries: config2.maxRetries ?? this.retryConfig.maxRetries ?? 3,
102811
- initialDelay: this.retryConfig.initialDelay ?? 1e3,
102812
- maxDelay: this.retryConfig.maxDelay ?? 3e4,
102813
- backoffFactor: this.retryConfig.backoffFactor ?? 2,
102814
- retryableErrors: this.retryConfig.retryableErrors,
102815
- debug: this.debug
102865
+ const providerRetryManager = this._createRetryManager({
102866
+ maxRetries: config2.maxRetries ?? this.retryConfig.maxRetries
102816
102867
  });
102817
102868
  return await providerRetryManager.executeWithRetry(
102818
- () => (0, import_ai4.streamText)(fallbackOptions),
102869
+ async () => {
102870
+ const result = (0, import_ai4.streamText)(fallbackOptions);
102871
+ return consumeResult ? await consumeResult(result) : result;
102872
+ },
102819
102873
  {
102820
102874
  provider: config2.provider,
102821
102875
  model,
@@ -102954,10 +103008,11 @@ var init_ProbeAgent = __esm({
102954
103008
  /**
102955
103009
  * Execute streamText with retry and fallback support
102956
103010
  * @param {Object} options - streamText options
102957
- * @returns {Promise<Object>} - streamText result
103011
+ * @param {Function} [consumeResult] - Optional callback to consume the result inside the same retry attempt
103012
+ * @returns {Promise<Object>} - streamText result or consumer result
102958
103013
  * @private
102959
103014
  */
102960
- async streamTextWithRetryAndFallback(options) {
103015
+ async streamTextWithRetryAndFallback(options, consumeResult) {
102961
103016
  const limiter = this.concurrencyLimiter;
102962
103017
  if (limiter && options.model) {
102963
103018
  options = { ...options, model: _ProbeAgent._wrapModelWithLimiter(options.model, limiter, this.debug) };
@@ -102989,6 +103044,7 @@ var init_ProbeAgent = __esm({
102989
103044
  const useClaudeCode = this.clientApiProvider === "claude-code" || process.env.USE_CLAUDE_CODE === "true";
102990
103045
  const useCodex = this.clientApiProvider === "codex" || process.env.USE_CODEX === "true";
102991
103046
  let result;
103047
+ let usedVercelProvider = false;
102992
103048
  if (useClaudeCode || useCodex) {
102993
103049
  try {
102994
103050
  result = await this._tryEngineStreamPath(options, controller, timeoutState);
@@ -103003,7 +103059,11 @@ var init_ProbeAgent = __esm({
103003
103059
  }
103004
103060
  }
103005
103061
  if (!result) {
103006
- result = await this._executeWithVercelProvider(options, controller);
103062
+ usedVercelProvider = true;
103063
+ result = await this._executeWithVercelProvider(options, controller, consumeResult);
103064
+ }
103065
+ if (!usedVercelProvider && result && consumeResult) {
103066
+ return await consumeResult(result);
103007
103067
  }
103008
103068
  return result;
103009
103069
  } finally {
@@ -104647,7 +104707,6 @@ You are working with a workspace. Available paths: ${workspaceDesc}
104647
104707
  activeTools.delete(key);
104648
104708
  }
104649
104709
  };
104650
- this.events.on("toolCall", onToolCall);
104651
104710
  const runTimeoutObserver = async () => {
104652
104711
  if (negotiatedTimeoutState.observerRunning) return;
104653
104712
  negotiatedTimeoutState.observerRunning = true;
@@ -105208,60 +105267,68 @@ Double-check your response based on the criteria above. If everything looks good
105208
105267
  streamOptions.providerOptions = providerOpts;
105209
105268
  }
105210
105269
  const executeAIRequest = async () => {
105211
- const result = await this.streamTextWithRetryAndFallback(streamOptions);
105212
- let gracefulTimeoutId = null;
105213
- let hardAbortTimeoutId = null;
105214
- if (this.timeoutBehavior === "graceful" && gracefulTimeoutState && this.maxOperationTimeout > 0) {
105215
- gracefulTimeoutId = setTimeout(() => {
105216
- gracefulTimeoutState.triggered = true;
105217
- if (this.debug) {
105218
- console.log(`[DEBUG] Soft timeout after ${this.maxOperationTimeout}ms \u2014 entering wind-down mode (${gracefulTimeoutState.bonusStepsMax} bonus steps)`);
105219
- }
105220
- hardAbortTimeoutId = setTimeout(() => {
105221
- if (this._abortController) {
105222
- this._abortController.abort();
105270
+ return await this.streamTextWithRetryAndFallback(streamOptions, async (result) => {
105271
+ this.events.on("toolCall", onToolCall);
105272
+ let gracefulTimeoutId = null;
105273
+ let hardAbortTimeoutId = null;
105274
+ if (this.timeoutBehavior === "graceful" && gracefulTimeoutState && this.maxOperationTimeout > 0) {
105275
+ gracefulTimeoutId = setTimeout(() => {
105276
+ gracefulTimeoutState.triggered = true;
105277
+ if (this.debug) {
105278
+ console.log(`[DEBUG] Soft timeout after ${this.maxOperationTimeout}ms \u2014 entering wind-down mode (${gracefulTimeoutState.bonusStepsMax} bonus steps)`);
105223
105279
  }
105280
+ hardAbortTimeoutId = setTimeout(() => {
105281
+ if (this._abortController) {
105282
+ this._abortController.abort();
105283
+ }
105284
+ if (this.debug) {
105285
+ console.log(`[DEBUG] Hard abort \u2014 wind-down safety net expired after 60s`);
105286
+ }
105287
+ }, 6e4);
105288
+ }, this.maxOperationTimeout);
105289
+ }
105290
+ if (this.timeoutBehavior === "negotiated" && this.maxOperationTimeout > 0) {
105291
+ negotiatedTimeoutState.softTimeoutId = setTimeout(() => {
105224
105292
  if (this.debug) {
105225
- console.log(`[DEBUG] Hard abort \u2014 wind-down safety net expired after 60s`);
105293
+ console.log(`[DEBUG] Soft timeout after ${this.maxOperationTimeout}ms \u2014 invoking timeout observer`);
105226
105294
  }
105227
- }, 6e4);
105228
- }, this.maxOperationTimeout);
105229
- }
105230
- if (this.timeoutBehavior === "negotiated" && this.maxOperationTimeout > 0) {
105231
- negotiatedTimeoutState.softTimeoutId = setTimeout(() => {
105295
+ runTimeoutObserver();
105296
+ }, this.maxOperationTimeout);
105297
+ }
105298
+ try {
105299
+ const steps = await result.steps;
105300
+ let finalText;
105301
+ if (steps && steps.length > 1) {
105302
+ const lastStepText = steps[steps.length - 1].text;
105303
+ finalText = lastStepText || await result.text;
105304
+ } else {
105305
+ finalText = await result.text;
105306
+ }
105307
+ if (!options.schema && (!steps || steps.length === 0) && (!finalText || !finalText.trim())) {
105308
+ throw Object.assign(
105309
+ new Error("No output generated. Check the stream for errors."),
105310
+ { name: "AI_NoOutputGeneratedError" }
105311
+ );
105312
+ }
105232
105313
  if (this.debug) {
105233
- console.log(`[DEBUG] Soft timeout after ${this.maxOperationTimeout}ms \u2014 invoking timeout observer`);
105314
+ console.log(`[DEBUG] streamText completed: ${steps?.length || 0} steps, finalText=${finalText?.length || 0} chars`);
105234
105315
  }
105235
- runTimeoutObserver();
105236
- }, this.maxOperationTimeout);
105237
- }
105238
- try {
105239
- const steps = await result.steps;
105240
- let finalText;
105241
- if (steps && steps.length > 1) {
105242
- const lastStepText = steps[steps.length - 1].text;
105243
- finalText = lastStepText || await result.text;
105244
- } else {
105245
- finalText = await result.text;
105246
- }
105247
- if (this.debug) {
105248
- console.log(`[DEBUG] streamText completed: ${steps?.length || 0} steps, finalText=${finalText?.length || 0} chars`);
105249
- }
105250
- const usage = await result.usage;
105251
- if (usage) {
105252
- this.tokenCounter.recordUsage(usage, result.experimental_providerMetadata);
105253
- }
105254
- return { finalText, result };
105255
- } finally {
105256
- if (gracefulTimeoutId) clearTimeout(gracefulTimeoutId);
105257
- if (hardAbortTimeoutId) clearTimeout(hardAbortTimeoutId);
105258
- if (negotiatedTimeoutState.softTimeoutId) clearTimeout(negotiatedTimeoutState.softTimeoutId);
105259
- if (this._gracefulStopHardAbortId) {
105260
- clearTimeout(this._gracefulStopHardAbortId);
105261
- this._gracefulStopHardAbortId = null;
105316
+ const usage = await result.usage;
105317
+ if (usage) {
105318
+ this.tokenCounter.recordUsage(usage, result.experimental_providerMetadata);
105319
+ }
105320
+ return { finalText, result };
105321
+ } finally {
105322
+ if (gracefulTimeoutId) clearTimeout(gracefulTimeoutId);
105323
+ if (hardAbortTimeoutId) clearTimeout(hardAbortTimeoutId);
105324
+ if (negotiatedTimeoutState.softTimeoutId) clearTimeout(negotiatedTimeoutState.softTimeoutId);
105325
+ if (this._gracefulStopHardAbortId) {
105326
+ clearTimeout(this._gracefulStopHardAbortId);
105327
+ this._gracefulStopHardAbortId = null;
105328
+ }
105329
+ this.events.removeListener("toolCall", onToolCall);
105262
105330
  }
105263
- this.events.removeListener("toolCall", onToolCall);
105264
- }
105331
+ });
105265
105332
  };
105266
105333
  let aiResult;
105267
105334
  if (this.tracer) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@probelabs/probe",
3
- "version": "0.6.0-rc323",
3
+ "version": "0.6.0-rc325",
4
4
  "description": "Node.js wrapper for the probe code search tool",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",