@kenkaiiii/gg-agent 5.76.0 → 5.78.0

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
@@ -502,7 +502,9 @@ function classifyOverload(err) {
502
502
  if (statusCode === 529 || msg.includes("overloaded") || msg.includes("529")) {
503
503
  return "overloaded";
504
504
  }
505
- if (statusCode === 500 || statusCode === 502 || statusCode === 503 || statusCode === 504 || statusCode === 507 || msg.includes("api_error") || msg.includes("server_error") || msg.includes("internal server error") || msg.includes("bad gateway") || msg.includes("service unavailable") || msg.includes("gateway timeout") || msg.includes("exceeded request buffer limit while retrying upstream")) {
505
+ if (statusCode === 500 || statusCode === 502 || statusCode === 503 || statusCode === 504 || statusCode === 507 || // Cloudflare edge errors (origin unreachable, timed out). api.anthropic.com
506
+ // returned a 520 HTML page mid-run in the 2026-10-09 arena; it is transient.
507
+ statusCode !== void 0 && statusCode >= 520 && statusCode <= 524 || msg.includes("api_error") || msg.includes("server_error") || msg.includes("internal server error") || msg.includes("bad gateway") || msg.includes("service unavailable") || msg.includes("gateway timeout") || msg.includes("exceeded request buffer limit while retrying upstream")) {
506
508
  return "provider_error";
507
509
  }
508
510
  return null;
@@ -862,6 +864,8 @@ async function* agentLoop(messages, options) {
862
864
  clearToolUses: options.clearToolUses,
863
865
  userAgent: options.userAgent,
864
866
  defaultHeaders: options.defaultHeaders,
867
+ providerOptions: options.providerOptions,
868
+ fetch: options.fetch,
865
869
  // Flip to non-streaming fallback after repeated stream stalls.
866
870
  ...useNonStreamingFallback ? { streaming: false } : {}
867
871
  });
@@ -1540,6 +1544,7 @@ async function* agentLoop(messages, options) {
1540
1544
  resolveTool: options.resolveTool,
1541
1545
  toolMap,
1542
1546
  invalidToolArgumentCounts,
1547
+ countedInvalidArguments: /* @__PURE__ */ new Set(),
1543
1548
  markFatalToolArgumentError,
1544
1549
  seenToolCalls: /* @__PURE__ */ new Set()
1545
1550
  };
@@ -1771,8 +1776,10 @@ async function executeSingleToolCall(toolCall, options, pushEvent) {
1771
1776
  if (err instanceof import_zod.ZodError) {
1772
1777
  const prettyError = (0, import_zod.prettifyError)(err);
1773
1778
  const failureKey = `${toolCall.name}:${prettyError}`;
1774
- const failureCount = (options.invalidToolArgumentCounts.get(failureKey) ?? 0) + 1;
1779
+ const alreadyCounted = options.countedInvalidArguments.has(failureKey);
1780
+ const failureCount = (options.invalidToolArgumentCounts.get(failureKey) ?? 0) + (alreadyCounted ? 0 : 1);
1775
1781
  options.invalidToolArgumentCounts.set(failureKey, failureCount);
1782
+ options.countedInvalidArguments.add(failureKey);
1776
1783
  invalidArgAttempt = failureCount;
1777
1784
  const hints = argumentHints(tool, toolCall.args);
1778
1785
  resultContent = `Invalid arguments for tool \`${toolCall.name}\`: