@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.
@@ -17714,7 +17714,7 @@ var init_dist2 = __esm({
17714
17714
  "ETIMEDOUT",
17715
17715
  "EPIPE"
17716
17716
  ];
17717
- VERSION = true ? "4.0.27" : "0.0.0-test";
17717
+ VERSION = true ? "4.0.28" : "0.0.0-test";
17718
17718
  suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
17719
17719
  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*:/;
17720
17720
  ignoreOverride = /* @__PURE__ */ Symbol(
@@ -25658,7 +25658,7 @@ var init_dist3 = __esm({
25658
25658
  schema: amazonBedrockEmbeddingModelOptionsSchema
25659
25659
  })) != null ? _a17 : {};
25660
25660
  const isNovaModel = this.modelId.startsWith("amazon.nova-") && this.modelId.includes("embed");
25661
- const isCohereModel = this.modelId.startsWith("cohere.embed-");
25661
+ const isCohereModel = this.modelId.includes("cohere.embed-");
25662
25662
  const args = isNovaModel ? {
25663
25663
  taskType: "SINGLE_EMBEDDING",
25664
25664
  singleEmbeddingParams: {
@@ -25682,7 +25682,7 @@ var init_dist3 = __esm({
25682
25682
  normalize: bedrockOptions.normalize
25683
25683
  };
25684
25684
  const url2 = this.getUrl(this.modelId);
25685
- const { value: response } = await postJsonToApi({
25685
+ const { value: response, responseHeaders } = await postJsonToApi({
25686
25686
  url: url2,
25687
25687
  headers: await resolve(
25688
25688
  combineHeaders(await resolve(this.config.headers), headers)
@@ -25711,7 +25711,10 @@ var init_dist3 = __esm({
25711
25711
  } else {
25712
25712
  embedding = response.embeddings.float[0];
25713
25713
  }
25714
- const tokens = "inputTextTokenCount" in response ? response.inputTextTokenCount : "inputTokenCount" in response ? (_f = response.inputTokenCount) != null ? _f : 0 : NaN;
25714
+ const headerTokenCount = Number(
25715
+ responseHeaders == null ? void 0 : responseHeaders["x-amzn-bedrock-input-token-count"]
25716
+ );
25717
+ const tokens = "inputTextTokenCount" in response ? response.inputTextTokenCount : "inputTokenCount" in response ? (_f = response.inputTokenCount) != null ? _f : 0 : headerTokenCount;
25715
25718
  return {
25716
25719
  embeddings: [embedding],
25717
25720
  usage: { tokens },
@@ -25934,7 +25937,7 @@ var init_dist3 = __esm({
25934
25937
  details: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
25935
25938
  preview: external_exports.unknown().optional()
25936
25939
  });
25937
- VERSION2 = true ? "4.0.112" : "0.0.0-test";
25940
+ VERSION2 = true ? "4.0.116" : "0.0.0-test";
25938
25941
  bedrockRerankingResponseSchema = lazySchema(
25939
25942
  () => zodSchema(
25940
25943
  external_exports.object({
@@ -39679,6 +39682,9 @@ var init_acorn = __esm({
39679
39682
  // Can be either `"script"`, `"module"` or `"commonjs"`. This influences global
39680
39683
  // strict mode and parsing of `import` and `export` declarations.
39681
39684
  sourceType: "script",
39685
+ // When set to true, enable strict parsing mode even if `sourceType`
39686
+ // is `"script"`.
39687
+ strict: false,
39682
39688
  // `onInsertedSemicolon` can be a callback that will be called when
39683
39689
  // a semicolon is automatically inserted. It will be passed the
39684
39690
  // position of the inserted semicolon as an offset, and if
@@ -39817,7 +39823,7 @@ var init_acorn = __esm({
39817
39823
  this.context = this.initialContext();
39818
39824
  this.exprAllowed = true;
39819
39825
  this.inModule = options.sourceType === "module";
39820
- this.strict = this.inModule || this.strictDirective(this.pos);
39826
+ this.strict = this.inModule || options.strict === true || this.strictDirective(this.pos);
39821
39827
  this.potentialArrowAt = -1;
39822
39828
  this.potentialArrowInForAwait = false;
39823
39829
  this.yieldPos = this.awaitPos = this.awaitIdentPos = 0;
@@ -39835,9 +39841,12 @@ var init_acorn = __esm({
39835
39841
  };
39836
39842
  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 } };
39837
39843
  Parser.prototype.parse = function parse3() {
39844
+ var this$1$1 = this;
39838
39845
  var node = this.options.program || this.startNode();
39839
39846
  this.nextToken();
39840
- return this.parseTopLevel(node);
39847
+ return this.catchStackOverflow(function() {
39848
+ return this$1$1.parseTopLevel(node);
39849
+ });
39841
39850
  };
39842
39851
  prototypeAccessors.inFunction.get = function() {
39843
39852
  return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0;
@@ -39971,6 +39980,17 @@ var init_acorn = __esm({
39971
39980
  this.next();
39972
39981
  return true;
39973
39982
  };
39983
+ pp$9.catchStackOverflow = function(f) {
39984
+ try {
39985
+ return f();
39986
+ } catch (e) {
39987
+ if (e instanceof Error && (/\bstack\b.*\b(exceeded|overflow)\b/i.test(e.message) || /\btoo much recursion\b/i.test(e.message))) {
39988
+ this.raise(this.start, "Not enough stack space to parse input");
39989
+ } else {
39990
+ throw e;
39991
+ }
39992
+ }
39993
+ };
39974
39994
  pp$9.expectContextual = function(name15) {
39975
39995
  if (!this.eatContextual(name15)) {
39976
39996
  this.unexpected();
@@ -40056,12 +40076,12 @@ var init_acorn = __esm({
40056
40076
  };
40057
40077
  pp$8 = Parser.prototype;
40058
40078
  pp$8.parseTopLevel = function(node) {
40059
- var exports2 = /* @__PURE__ */ Object.create(null);
40079
+ var exports$1 = /* @__PURE__ */ Object.create(null);
40060
40080
  if (!node.body) {
40061
40081
  node.body = [];
40062
40082
  }
40063
40083
  while (this.type !== types$1.eof) {
40064
- var stmt = this.parseStatement(null, true, exports2);
40084
+ var stmt = this.parseStatement(null, true, exports$1);
40065
40085
  node.body.push(stmt);
40066
40086
  }
40067
40087
  if (this.inModule) {
@@ -40151,9 +40171,18 @@ var init_acorn = __esm({
40151
40171
  return true;
40152
40172
  }
40153
40173
  var id = this.input.slice(idStart, next);
40154
- if (keywordRelationalOperator.test(id) || isFor && id === "of") {
40174
+ if (keywordRelationalOperator.test(id)) {
40155
40175
  return false;
40156
40176
  }
40177
+ if (isFor && !isAwaitUsing && id === "of") {
40178
+ skipWhiteSpace.lastIndex = next;
40179
+ var skipAfterOf = skipWhiteSpace.exec(this.input);
40180
+ next = next + skipAfterOf[0].length;
40181
+ if (this.input.charCodeAt(next) !== 61 || // Check for ==, === and => operators
40182
+ (ch = this.input.charCodeAt(next + 1)) === 61 || ch === 62) {
40183
+ return false;
40184
+ }
40185
+ }
40157
40186
  return true;
40158
40187
  };
40159
40188
  pp$8.isAwaitUsing = function(isFor) {
@@ -40162,7 +40191,7 @@ var init_acorn = __esm({
40162
40191
  pp$8.isUsing = function(isFor) {
40163
40192
  return this.isUsingKeyword(false, isFor);
40164
40193
  };
40165
- pp$8.parseStatement = function(context, topLevel, exports2) {
40194
+ pp$8.parseStatement = function(context, topLevel, exports$1) {
40166
40195
  var starttype = this.type, node = this.startNode(), kind;
40167
40196
  if (this.isLet(context)) {
40168
40197
  starttype = types$1._var;
@@ -40231,7 +40260,7 @@ var init_acorn = __esm({
40231
40260
  this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'");
40232
40261
  }
40233
40262
  }
40234
- return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports2);
40263
+ return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports$1);
40235
40264
  // If the statement does not start with a statement keyword or a
40236
40265
  // brace, it's an ExpressionStatement or LabeledStatement. We
40237
40266
  // simply start parsing an expression, and afterwards, if the
@@ -40250,6 +40279,9 @@ var init_acorn = __esm({
40250
40279
  if (!this.allowUsing) {
40251
40280
  this.raise(this.start, "Using declaration cannot appear in the top level when source type is `script` or in the bare case statement");
40252
40281
  }
40282
+ if (context) {
40283
+ this.raise(this.start, "Using declaration is not allowed in single-statement positions");
40284
+ }
40253
40285
  if (usingKind === "await using") {
40254
40286
  if (!this.canAwait) {
40255
40287
  this.raise(this.start, "Await using cannot appear outside of async function");
@@ -40384,14 +40416,15 @@ var init_acorn = __esm({
40384
40416
  };
40385
40417
  pp$8.parseForAfterInit = function(node, init, awaitAt) {
40386
40418
  if ((this.type === types$1._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) && init.declarations.length === 1) {
40387
- if (this.options.ecmaVersion >= 9) {
40388
- if (this.type === types$1._in) {
40389
- if (awaitAt > -1) {
40390
- this.unexpected(awaitAt);
40391
- }
40392
- } else {
40393
- node.await = awaitAt > -1;
40419
+ if (this.type === types$1._in) {
40420
+ if ((init.kind === "using" || init.kind === "await using") && !init.declarations[0].init) {
40421
+ this.raise(this.start, "Using declaration is not allowed in for-in loops");
40394
40422
  }
40423
+ if (this.options.ecmaVersion >= 9 && awaitAt > -1) {
40424
+ this.unexpected(awaitAt);
40425
+ }
40426
+ } else if (this.options.ecmaVersion >= 9) {
40427
+ node.await = awaitAt > -1;
40395
40428
  }
40396
40429
  return this.parseForIn(node, init);
40397
40430
  }
@@ -40887,11 +40920,11 @@ var init_acorn = __esm({
40887
40920
  }
40888
40921
  }
40889
40922
  };
40890
- pp$8.parseExportAllDeclaration = function(node, exports2) {
40923
+ pp$8.parseExportAllDeclaration = function(node, exports$1) {
40891
40924
  if (this.options.ecmaVersion >= 11) {
40892
40925
  if (this.eatContextual("as")) {
40893
40926
  node.exported = this.parseModuleExportName();
40894
- this.checkExport(exports2, node.exported, this.lastTokStart);
40927
+ this.checkExport(exports$1, node.exported, this.lastTokStart);
40895
40928
  } else {
40896
40929
  node.exported = null;
40897
40930
  }
@@ -40907,22 +40940,22 @@ var init_acorn = __esm({
40907
40940
  this.semicolon();
40908
40941
  return this.finishNode(node, "ExportAllDeclaration");
40909
40942
  };
40910
- pp$8.parseExport = function(node, exports2) {
40943
+ pp$8.parseExport = function(node, exports$1) {
40911
40944
  this.next();
40912
40945
  if (this.eat(types$1.star)) {
40913
- return this.parseExportAllDeclaration(node, exports2);
40946
+ return this.parseExportAllDeclaration(node, exports$1);
40914
40947
  }
40915
40948
  if (this.eat(types$1._default)) {
40916
- this.checkExport(exports2, "default", this.lastTokStart);
40949
+ this.checkExport(exports$1, "default", this.lastTokStart);
40917
40950
  node.declaration = this.parseExportDefaultDeclaration();
40918
40951
  return this.finishNode(node, "ExportDefaultDeclaration");
40919
40952
  }
40920
40953
  if (this.shouldParseExportStatement()) {
40921
40954
  node.declaration = this.parseExportDeclaration(node);
40922
40955
  if (node.declaration.type === "VariableDeclaration") {
40923
- this.checkVariableExport(exports2, node.declaration.declarations);
40956
+ this.checkVariableExport(exports$1, node.declaration.declarations);
40924
40957
  } else {
40925
- this.checkExport(exports2, node.declaration.id, node.declaration.id.start);
40958
+ this.checkExport(exports$1, node.declaration.id, node.declaration.id.start);
40926
40959
  }
40927
40960
  node.specifiers = [];
40928
40961
  node.source = null;
@@ -40931,7 +40964,7 @@ var init_acorn = __esm({
40931
40964
  }
40932
40965
  } else {
40933
40966
  node.declaration = null;
40934
- node.specifiers = this.parseExportSpecifiers(exports2);
40967
+ node.specifiers = this.parseExportSpecifiers(exports$1);
40935
40968
  if (this.eatContextual("from")) {
40936
40969
  if (this.type !== types$1.string) {
40937
40970
  this.unexpected();
@@ -40979,66 +41012,66 @@ var init_acorn = __esm({
40979
41012
  return declaration;
40980
41013
  }
40981
41014
  };
40982
- pp$8.checkExport = function(exports2, name15, pos) {
40983
- if (!exports2) {
41015
+ pp$8.checkExport = function(exports$1, name15, pos) {
41016
+ if (!exports$1) {
40984
41017
  return;
40985
41018
  }
40986
41019
  if (typeof name15 !== "string") {
40987
41020
  name15 = name15.type === "Identifier" ? name15.name : name15.value;
40988
41021
  }
40989
- if (hasOwn(exports2, name15)) {
41022
+ if (hasOwn(exports$1, name15)) {
40990
41023
  this.raiseRecoverable(pos, "Duplicate export '" + name15 + "'");
40991
41024
  }
40992
- exports2[name15] = true;
41025
+ exports$1[name15] = true;
40993
41026
  };
40994
- pp$8.checkPatternExport = function(exports2, pat) {
41027
+ pp$8.checkPatternExport = function(exports$1, pat) {
40995
41028
  var type = pat.type;
40996
41029
  if (type === "Identifier") {
40997
- this.checkExport(exports2, pat, pat.start);
41030
+ this.checkExport(exports$1, pat, pat.start);
40998
41031
  } else if (type === "ObjectPattern") {
40999
41032
  for (var i = 0, list = pat.properties; i < list.length; i += 1) {
41000
41033
  var prop = list[i];
41001
- this.checkPatternExport(exports2, prop);
41034
+ this.checkPatternExport(exports$1, prop);
41002
41035
  }
41003
41036
  } else if (type === "ArrayPattern") {
41004
41037
  for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
41005
41038
  var elt = list$1[i$1];
41006
41039
  if (elt) {
41007
- this.checkPatternExport(exports2, elt);
41040
+ this.checkPatternExport(exports$1, elt);
41008
41041
  }
41009
41042
  }
41010
41043
  } else if (type === "Property") {
41011
- this.checkPatternExport(exports2, pat.value);
41044
+ this.checkPatternExport(exports$1, pat.value);
41012
41045
  } else if (type === "AssignmentPattern") {
41013
- this.checkPatternExport(exports2, pat.left);
41046
+ this.checkPatternExport(exports$1, pat.left);
41014
41047
  } else if (type === "RestElement") {
41015
- this.checkPatternExport(exports2, pat.argument);
41048
+ this.checkPatternExport(exports$1, pat.argument);
41016
41049
  }
41017
41050
  };
41018
- pp$8.checkVariableExport = function(exports2, decls) {
41019
- if (!exports2) {
41051
+ pp$8.checkVariableExport = function(exports$1, decls) {
41052
+ if (!exports$1) {
41020
41053
  return;
41021
41054
  }
41022
41055
  for (var i = 0, list = decls; i < list.length; i += 1) {
41023
41056
  var decl = list[i];
41024
- this.checkPatternExport(exports2, decl.id);
41057
+ this.checkPatternExport(exports$1, decl.id);
41025
41058
  }
41026
41059
  };
41027
41060
  pp$8.shouldParseExportStatement = function() {
41028
41061
  return this.type.keyword === "var" || this.type.keyword === "const" || this.type.keyword === "class" || this.type.keyword === "function" || this.isLet() || this.isAsyncFunction();
41029
41062
  };
41030
- pp$8.parseExportSpecifier = function(exports2) {
41063
+ pp$8.parseExportSpecifier = function(exports$1) {
41031
41064
  var node = this.startNode();
41032
41065
  node.local = this.parseModuleExportName();
41033
41066
  node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local;
41034
41067
  this.checkExport(
41035
- exports2,
41068
+ exports$1,
41036
41069
  node.exported,
41037
41070
  node.exported.start
41038
41071
  );
41039
41072
  return this.finishNode(node, "ExportSpecifier");
41040
41073
  };
41041
- pp$8.parseExportSpecifiers = function(exports2) {
41074
+ pp$8.parseExportSpecifiers = function(exports$1) {
41042
41075
  var nodes = [], first2 = true;
41043
41076
  this.expect(types$1.braceL);
41044
41077
  while (!this.eat(types$1.braceR)) {
@@ -41050,7 +41083,7 @@ var init_acorn = __esm({
41050
41083
  } else {
41051
41084
  first2 = false;
41052
41085
  }
41053
- nodes.push(this.parseExportSpecifier(exports2));
41086
+ nodes.push(this.parseExportSpecifier(exports$1));
41054
41087
  }
41055
41088
  return nodes;
41056
41089
  };
@@ -41618,17 +41651,20 @@ var init_acorn = __esm({
41618
41651
  other[kind] = true;
41619
41652
  };
41620
41653
  pp$5.parseExpression = function(forInit, refDestructuringErrors) {
41621
- var startPos = this.start, startLoc = this.startLoc;
41622
- var expr = this.parseMaybeAssign(forInit, refDestructuringErrors);
41623
- if (this.type === types$1.comma) {
41624
- var node = this.startNodeAt(startPos, startLoc);
41625
- node.expressions = [expr];
41626
- while (this.eat(types$1.comma)) {
41627
- node.expressions.push(this.parseMaybeAssign(forInit, refDestructuringErrors));
41654
+ var this$1$1 = this;
41655
+ return this.catchStackOverflow(function() {
41656
+ var startPos = this$1$1.start, startLoc = this$1$1.startLoc;
41657
+ var expr = this$1$1.parseMaybeAssign(forInit, refDestructuringErrors);
41658
+ if (this$1$1.type === types$1.comma) {
41659
+ var node = this$1$1.startNodeAt(startPos, startLoc);
41660
+ node.expressions = [expr];
41661
+ while (this$1$1.eat(types$1.comma)) {
41662
+ node.expressions.push(this$1$1.parseMaybeAssign(forInit, refDestructuringErrors));
41663
+ }
41664
+ return this$1$1.finishNode(node, "SequenceExpression");
41628
41665
  }
41629
- return this.finishNode(node, "SequenceExpression");
41630
- }
41631
- return expr;
41666
+ return expr;
41667
+ });
41632
41668
  };
41633
41669
  pp$5.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse) {
41634
41670
  if (this.isContextual("yield")) {
@@ -41700,7 +41736,7 @@ var init_acorn = __esm({
41700
41736
  if (this.checkExpressionErrors(refDestructuringErrors)) {
41701
41737
  return expr;
41702
41738
  }
41703
- if (this.eat(types$1.question)) {
41739
+ if (!(expr.type === "ArrowFunctionExpression" && expr.start === startPos) && this.eat(types$1.question)) {
41704
41740
  var node = this.startNodeAt(startPos, startLoc);
41705
41741
  node.test = expr;
41706
41742
  node.consequent = this.parseMaybeAssign();
@@ -42193,6 +42229,9 @@ var init_acorn = __esm({
42193
42229
  }
42194
42230
  var startPos = this.start, startLoc = this.startLoc;
42195
42231
  node.callee = this.parseSubscripts(this.parseExprAtom(null, false, true), startPos, startLoc, true, false);
42232
+ if (node.callee.type === "Super") {
42233
+ this.raiseRecoverable(startPos, "Invalid use of 'super'");
42234
+ }
42196
42235
  if (this.eat(types$1.parenL)) {
42197
42236
  node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false);
42198
42237
  } else {
@@ -44845,7 +44884,7 @@ var init_acorn = __esm({
44845
44884
  }
44846
44885
  return this.finishToken(type, word);
44847
44886
  };
44848
- version2 = "8.16.0";
44887
+ version2 = "8.17.0";
44849
44888
  Parser.acorn = {
44850
44889
  Parser,
44851
44890
  version: version2,
@@ -102838,12 +102877,13 @@ function isRetryableError(error40, retryableErrors = DEFAULT_RETRYABLE_ERRORS) {
102838
102877
  if (!error40) return false;
102839
102878
  const errorString = error40.toString().toLowerCase();
102840
102879
  const errorMessage = (error40.message || "").toLowerCase();
102880
+ const errorName = (error40.name || error40.constructor?.name || "").toLowerCase();
102841
102881
  const errorCode = (error40.code || "").toLowerCase();
102842
102882
  const errorType = (error40.type || "").toLowerCase();
102843
102883
  const statusCode = error40.statusCode || error40.status;
102844
102884
  for (const pattern of retryableErrors) {
102845
102885
  const lowerPattern = pattern.toLowerCase();
102846
- if (errorString.includes(lowerPattern) || errorMessage.includes(lowerPattern) || errorCode.includes(lowerPattern) || errorType.includes(lowerPattern) || statusCode?.toString() === pattern) {
102886
+ if (errorString.includes(lowerPattern) || errorMessage.includes(lowerPattern) || errorName.includes(lowerPattern) || errorCode.includes(lowerPattern) || errorType.includes(lowerPattern) || statusCode?.toString() === pattern) {
102847
102887
  return true;
102848
102888
  }
102849
102889
  }
@@ -102880,7 +102920,9 @@ var init_RetryManager = __esm({
102880
102920
  "ECONNRESET",
102881
102921
  "ETIMEDOUT",
102882
102922
  "ENOTFOUND",
102883
- "api_error"
102923
+ "api_error",
102924
+ "No output generated",
102925
+ "AI_NoOutputGeneratedError"
102884
102926
  ];
102885
102927
  RetryManager = class {
102886
102928
  /**
@@ -102900,7 +102942,7 @@ var init_RetryManager = __esm({
102900
102942
  this.backoffFactor = this._validateNumber(options.backoffFactor, 2, "backoffFactor", 1, 10);
102901
102943
  this.retryableErrors = options.retryableErrors || DEFAULT_RETRYABLE_ERRORS;
102902
102944
  this.debug = options.debug ?? false;
102903
- this.jitter = options.jitter ?? true;
102945
+ this.jitter = typeof options.jitter === "boolean" ? options.jitter : true;
102904
102946
  if (this.maxDelay < this.initialDelay) {
102905
102947
  throw new Error("maxDelay must be greater than or equal to initialDelay");
102906
102948
  }
@@ -106272,27 +106314,41 @@ var init_ProbeAgent = __esm({
106272
106314
  timeoutState
106273
106315
  );
106274
106316
  }
106317
+ /**
106318
+ * Create a RetryManager from the agent's retry configuration.
106319
+ * @param {Object} [overrides={}] - Retry option overrides
106320
+ * @returns {RetryManager}
106321
+ * @private
106322
+ */
106323
+ _createRetryManager(overrides = {}) {
106324
+ return new RetryManager({
106325
+ maxRetries: overrides.maxRetries ?? this.retryConfig.maxRetries ?? 3,
106326
+ initialDelay: overrides.initialDelay ?? this.retryConfig.initialDelay ?? 1e3,
106327
+ maxDelay: overrides.maxDelay ?? this.retryConfig.maxDelay ?? 3e4,
106328
+ backoffFactor: overrides.backoffFactor ?? this.retryConfig.backoffFactor ?? 2,
106329
+ retryableErrors: overrides.retryableErrors ?? this.retryConfig.retryableErrors,
106330
+ jitter: overrides.jitter ?? this.retryConfig.jitter,
106331
+ debug: overrides.debug ?? this.debug
106332
+ });
106333
+ }
106275
106334
  /**
106276
106335
  * Execute streamText with Vercel AI SDK using retry/fallback logic
106277
106336
  * @param {Object} options - streamText options
106278
106337
  * @param {AbortController} controller - Abort controller for the operation
106338
+ * @param {Function} [consumeResult] - Optional callback to consume the stream result inside the same retry budget
106279
106339
  * @returns {Promise<Object>} - Stream result
106280
106340
  * @private
106281
106341
  */
106282
- async _executeWithVercelProvider(options, controller) {
106342
+ async _executeWithVercelProvider(options, controller, consumeResult) {
106283
106343
  if (!this.retryManager) {
106284
- this.retryManager = new RetryManager({
106285
- maxRetries: this.retryConfig.maxRetries ?? 3,
106286
- initialDelay: this.retryConfig.initialDelay ?? 1e3,
106287
- maxDelay: this.retryConfig.maxDelay ?? 3e4,
106288
- backoffFactor: this.retryConfig.backoffFactor ?? 2,
106289
- retryableErrors: this.retryConfig.retryableErrors,
106290
- debug: this.debug
106291
- });
106344
+ this.retryManager = this._createRetryManager();
106292
106345
  }
106293
106346
  if (!this.fallbackManager) {
106294
106347
  return await this.retryManager.executeWithRetry(
106295
- () => (0, import_ai6.streamText)({ ...options, abortSignal: controller.signal }),
106348
+ async () => {
106349
+ const result = (0, import_ai6.streamText)({ ...options, abortSignal: controller.signal });
106350
+ return consumeResult ? await consumeResult(result) : result;
106351
+ },
106296
106352
  {
106297
106353
  provider: this.apiType,
106298
106354
  model: this.model,
@@ -106317,16 +106373,14 @@ var init_ProbeAgent = __esm({
106317
106373
  console.error(`[DEBUG] Stripped Gemini built-in tools for fallback to ${config2.provider} provider`);
106318
106374
  }
106319
106375
  }
106320
- const providerRetryManager = new RetryManager({
106321
- maxRetries: config2.maxRetries ?? this.retryConfig.maxRetries ?? 3,
106322
- initialDelay: this.retryConfig.initialDelay ?? 1e3,
106323
- maxDelay: this.retryConfig.maxDelay ?? 3e4,
106324
- backoffFactor: this.retryConfig.backoffFactor ?? 2,
106325
- retryableErrors: this.retryConfig.retryableErrors,
106326
- debug: this.debug
106376
+ const providerRetryManager = this._createRetryManager({
106377
+ maxRetries: config2.maxRetries ?? this.retryConfig.maxRetries
106327
106378
  });
106328
106379
  return await providerRetryManager.executeWithRetry(
106329
- () => (0, import_ai6.streamText)(fallbackOptions),
106380
+ async () => {
106381
+ const result = (0, import_ai6.streamText)(fallbackOptions);
106382
+ return consumeResult ? await consumeResult(result) : result;
106383
+ },
106330
106384
  {
106331
106385
  provider: config2.provider,
106332
106386
  model,
@@ -106465,10 +106519,11 @@ var init_ProbeAgent = __esm({
106465
106519
  /**
106466
106520
  * Execute streamText with retry and fallback support
106467
106521
  * @param {Object} options - streamText options
106468
- * @returns {Promise<Object>} - streamText result
106522
+ * @param {Function} [consumeResult] - Optional callback to consume the result inside the same retry attempt
106523
+ * @returns {Promise<Object>} - streamText result or consumer result
106469
106524
  * @private
106470
106525
  */
106471
- async streamTextWithRetryAndFallback(options) {
106526
+ async streamTextWithRetryAndFallback(options, consumeResult) {
106472
106527
  const limiter = this.concurrencyLimiter;
106473
106528
  if (limiter && options.model) {
106474
106529
  options = { ...options, model: _ProbeAgent._wrapModelWithLimiter(options.model, limiter, this.debug) };
@@ -106500,6 +106555,7 @@ var init_ProbeAgent = __esm({
106500
106555
  const useClaudeCode = this.clientApiProvider === "claude-code" || process.env.USE_CLAUDE_CODE === "true";
106501
106556
  const useCodex = this.clientApiProvider === "codex" || process.env.USE_CODEX === "true";
106502
106557
  let result;
106558
+ let usedVercelProvider = false;
106503
106559
  if (useClaudeCode || useCodex) {
106504
106560
  try {
106505
106561
  result = await this._tryEngineStreamPath(options, controller, timeoutState);
@@ -106514,7 +106570,11 @@ var init_ProbeAgent = __esm({
106514
106570
  }
106515
106571
  }
106516
106572
  if (!result) {
106517
- result = await this._executeWithVercelProvider(options, controller);
106573
+ usedVercelProvider = true;
106574
+ result = await this._executeWithVercelProvider(options, controller, consumeResult);
106575
+ }
106576
+ if (!usedVercelProvider && result && consumeResult) {
106577
+ return await consumeResult(result);
106518
106578
  }
106519
106579
  return result;
106520
106580
  } finally {
@@ -108158,7 +108218,6 @@ You are working with a workspace. Available paths: ${workspaceDesc}
108158
108218
  activeTools.delete(key);
108159
108219
  }
108160
108220
  };
108161
- this.events.on("toolCall", onToolCall);
108162
108221
  const runTimeoutObserver = async () => {
108163
108222
  if (negotiatedTimeoutState.observerRunning) return;
108164
108223
  negotiatedTimeoutState.observerRunning = true;
@@ -108719,60 +108778,68 @@ Double-check your response based on the criteria above. If everything looks good
108719
108778
  streamOptions.providerOptions = providerOpts;
108720
108779
  }
108721
108780
  const executeAIRequest = async () => {
108722
- const result = await this.streamTextWithRetryAndFallback(streamOptions);
108723
- let gracefulTimeoutId = null;
108724
- let hardAbortTimeoutId = null;
108725
- if (this.timeoutBehavior === "graceful" && gracefulTimeoutState && this.maxOperationTimeout > 0) {
108726
- gracefulTimeoutId = setTimeout(() => {
108727
- gracefulTimeoutState.triggered = true;
108728
- if (this.debug) {
108729
- console.log(`[DEBUG] Soft timeout after ${this.maxOperationTimeout}ms \u2014 entering wind-down mode (${gracefulTimeoutState.bonusStepsMax} bonus steps)`);
108730
- }
108731
- hardAbortTimeoutId = setTimeout(() => {
108732
- if (this._abortController) {
108733
- this._abortController.abort();
108781
+ return await this.streamTextWithRetryAndFallback(streamOptions, async (result) => {
108782
+ this.events.on("toolCall", onToolCall);
108783
+ let gracefulTimeoutId = null;
108784
+ let hardAbortTimeoutId = null;
108785
+ if (this.timeoutBehavior === "graceful" && gracefulTimeoutState && this.maxOperationTimeout > 0) {
108786
+ gracefulTimeoutId = setTimeout(() => {
108787
+ gracefulTimeoutState.triggered = true;
108788
+ if (this.debug) {
108789
+ console.log(`[DEBUG] Soft timeout after ${this.maxOperationTimeout}ms \u2014 entering wind-down mode (${gracefulTimeoutState.bonusStepsMax} bonus steps)`);
108734
108790
  }
108791
+ hardAbortTimeoutId = setTimeout(() => {
108792
+ if (this._abortController) {
108793
+ this._abortController.abort();
108794
+ }
108795
+ if (this.debug) {
108796
+ console.log(`[DEBUG] Hard abort \u2014 wind-down safety net expired after 60s`);
108797
+ }
108798
+ }, 6e4);
108799
+ }, this.maxOperationTimeout);
108800
+ }
108801
+ if (this.timeoutBehavior === "negotiated" && this.maxOperationTimeout > 0) {
108802
+ negotiatedTimeoutState.softTimeoutId = setTimeout(() => {
108735
108803
  if (this.debug) {
108736
- console.log(`[DEBUG] Hard abort \u2014 wind-down safety net expired after 60s`);
108804
+ console.log(`[DEBUG] Soft timeout after ${this.maxOperationTimeout}ms \u2014 invoking timeout observer`);
108737
108805
  }
108738
- }, 6e4);
108739
- }, this.maxOperationTimeout);
108740
- }
108741
- if (this.timeoutBehavior === "negotiated" && this.maxOperationTimeout > 0) {
108742
- negotiatedTimeoutState.softTimeoutId = setTimeout(() => {
108806
+ runTimeoutObserver();
108807
+ }, this.maxOperationTimeout);
108808
+ }
108809
+ try {
108810
+ const steps = await result.steps;
108811
+ let finalText;
108812
+ if (steps && steps.length > 1) {
108813
+ const lastStepText = steps[steps.length - 1].text;
108814
+ finalText = lastStepText || await result.text;
108815
+ } else {
108816
+ finalText = await result.text;
108817
+ }
108818
+ if (!options.schema && (!steps || steps.length === 0) && (!finalText || !finalText.trim())) {
108819
+ throw Object.assign(
108820
+ new Error("No output generated. Check the stream for errors."),
108821
+ { name: "AI_NoOutputGeneratedError" }
108822
+ );
108823
+ }
108743
108824
  if (this.debug) {
108744
- console.log(`[DEBUG] Soft timeout after ${this.maxOperationTimeout}ms \u2014 invoking timeout observer`);
108825
+ console.log(`[DEBUG] streamText completed: ${steps?.length || 0} steps, finalText=${finalText?.length || 0} chars`);
108745
108826
  }
108746
- runTimeoutObserver();
108747
- }, this.maxOperationTimeout);
108748
- }
108749
- try {
108750
- const steps = await result.steps;
108751
- let finalText;
108752
- if (steps && steps.length > 1) {
108753
- const lastStepText = steps[steps.length - 1].text;
108754
- finalText = lastStepText || await result.text;
108755
- } else {
108756
- finalText = await result.text;
108757
- }
108758
- if (this.debug) {
108759
- console.log(`[DEBUG] streamText completed: ${steps?.length || 0} steps, finalText=${finalText?.length || 0} chars`);
108760
- }
108761
- const usage = await result.usage;
108762
- if (usage) {
108763
- this.tokenCounter.recordUsage(usage, result.experimental_providerMetadata);
108764
- }
108765
- return { finalText, result };
108766
- } finally {
108767
- if (gracefulTimeoutId) clearTimeout(gracefulTimeoutId);
108768
- if (hardAbortTimeoutId) clearTimeout(hardAbortTimeoutId);
108769
- if (negotiatedTimeoutState.softTimeoutId) clearTimeout(negotiatedTimeoutState.softTimeoutId);
108770
- if (this._gracefulStopHardAbortId) {
108771
- clearTimeout(this._gracefulStopHardAbortId);
108772
- this._gracefulStopHardAbortId = null;
108827
+ const usage = await result.usage;
108828
+ if (usage) {
108829
+ this.tokenCounter.recordUsage(usage, result.experimental_providerMetadata);
108830
+ }
108831
+ return { finalText, result };
108832
+ } finally {
108833
+ if (gracefulTimeoutId) clearTimeout(gracefulTimeoutId);
108834
+ if (hardAbortTimeoutId) clearTimeout(hardAbortTimeoutId);
108835
+ if (negotiatedTimeoutState.softTimeoutId) clearTimeout(negotiatedTimeoutState.softTimeoutId);
108836
+ if (this._gracefulStopHardAbortId) {
108837
+ clearTimeout(this._gracefulStopHardAbortId);
108838
+ this._gracefulStopHardAbortId = null;
108839
+ }
108840
+ this.events.removeListener("toolCall", onToolCall);
108773
108841
  }
108774
- this.events.removeListener("toolCall", onToolCall);
108775
- }
108842
+ });
108776
108843
  };
108777
108844
  let aiResult;
108778
108845
  if (this.tracer) {