zidane 6.5.3 → 6.5.5

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.
Files changed (137) hide show
  1. package/dist/{acp-CIpD8UIw.js → acp-BPJbXS2J.js} +6 -6
  2. package/dist/{acp-CIpD8UIw.js.map → acp-BPJbXS2J.js.map} +1 -1
  3. package/dist/acp-cli.js +6 -6
  4. package/dist/acp.d.ts +1 -1
  5. package/dist/acp.js +1 -1
  6. package/dist/{agent-8kfGIDb_.js → agent-gZjHsUft.js} +176 -166
  7. package/dist/agent-gZjHsUft.js.map +1 -0
  8. package/dist/agent.d.ts +1 -1
  9. package/dist/agent.js +1 -1
  10. package/dist/{anthropic-_Hn1YiWr.js → anthropic-D3le2d-s.js} +75 -14
  11. package/dist/anthropic-D3le2d-s.js.map +1 -0
  12. package/dist/{auth-CS_e8ng1.js → auth-DCiXCwGa.js} +8 -6
  13. package/dist/{auth-CS_e8ng1.js.map → auth-DCiXCwGa.js.map} +1 -1
  14. package/dist/chat/pure.d.ts +3 -3
  15. package/dist/chat/pure.js +2 -2
  16. package/dist/chat.d.ts +29 -8
  17. package/dist/chat.d.ts.map +1 -1
  18. package/dist/chat.js +8 -8
  19. package/dist/{context-segments-1mcqSCM3.js → context-segments-CJCtJ9sU.js} +16 -3
  20. package/dist/{context-segments-1mcqSCM3.js.map → context-segments-CJCtJ9sU.js.map} +1 -1
  21. package/dist/{context-transport-Bco9Wo0b.js → context-transport-D8yeGdpd.js} +2 -2
  22. package/dist/{context-transport-Bco9Wo0b.js.map → context-transport-D8yeGdpd.js.map} +1 -1
  23. package/dist/contexts/daytona.d.ts +1 -1
  24. package/dist/contexts/daytona.js +1 -1
  25. package/dist/contexts/e2b.d.ts +1 -1
  26. package/dist/cursor-iojRXHF9.js +139 -0
  27. package/dist/cursor-iojRXHF9.js.map +1 -0
  28. package/dist/{errors-BwBxu3zD.js → errors-DKiMrOKq.js} +61 -2
  29. package/dist/{errors-BwBxu3zD.js.map → errors-DKiMrOKq.js.map} +1 -1
  30. package/dist/errors.js +2 -2
  31. package/dist/eval.d.ts +1 -1
  32. package/dist/eval.js +1 -1
  33. package/dist/extensions.d.ts +1 -1
  34. package/dist/extensions.js +1 -1
  35. package/dist/{fetch-url-B7aSg6Bp.js → fetch-url-ma-5_p0p.js} +2 -2
  36. package/dist/{fetch-url-B7aSg6Bp.js.map → fetch-url-ma-5_p0p.js.map} +1 -1
  37. package/dist/headless.d.ts +1 -1
  38. package/dist/headless.js +3 -3
  39. package/dist/{index-BKyWhILQ.d.ts → index-BYKzzYzi.d.ts} +85 -22
  40. package/dist/index-BYKzzYzi.d.ts.map +1 -0
  41. package/dist/index.d.ts +2 -2
  42. package/dist/index.js +14 -14
  43. package/dist/{login-D3CKhgbI.js → login-CB23LyI1.js} +3 -3
  44. package/dist/{login-D3CKhgbI.js.map → login-CB23LyI1.js.map} +1 -1
  45. package/dist/{mcp-D9fqOQo5.js → mcp-CVtSQTWg.js} +3 -3
  46. package/dist/{mcp-D9fqOQo5.js.map → mcp-CVtSQTWg.js.map} +1 -1
  47. package/dist/mcp.d.ts +1 -1
  48. package/dist/mcp.js +1 -1
  49. package/dist/{messages-C_H9soi5.js → messages-CVVg5jUL.js} +2 -2
  50. package/dist/{messages-C_H9soi5.js.map → messages-CVVg5jUL.js.map} +1 -1
  51. package/dist/{oauth-BYjlFR-J.js → oauth-C4GvY_p1.js} +50 -11
  52. package/dist/oauth-C4GvY_p1.js.map +1 -0
  53. package/dist/{openai-compat-CnHeo4Lz.js → openai-compat-hmZzpDrB.js} +2 -2
  54. package/dist/{openai-compat-CnHeo4Lz.js.map → openai-compat-hmZzpDrB.js.map} +1 -1
  55. package/dist/output/stream-json.d.ts +1 -1
  56. package/dist/output/terminal.d.ts +1 -1
  57. package/dist/pkce-t8BcPyEi.js +30 -0
  58. package/dist/pkce-t8BcPyEi.js.map +1 -0
  59. package/dist/{plugins-2PMTVcp-.js → plugins-onDvTHEm.js} +2 -2
  60. package/dist/{plugins-2PMTVcp-.js.map → plugins-onDvTHEm.js.map} +1 -1
  61. package/dist/plugins.d.ts +1 -1
  62. package/dist/plugins.js +1 -1
  63. package/dist/presets.d.ts +1 -1
  64. package/dist/presets.js +1 -1
  65. package/dist/providers/anthropic.d.ts +1 -1
  66. package/dist/providers/anthropic.js +1 -1
  67. package/dist/providers/arcee.d.ts +1 -1
  68. package/dist/providers/arcee.js +1 -1
  69. package/dist/providers/baseten.d.ts +1 -1
  70. package/dist/providers/baseten.js +1 -1
  71. package/dist/providers/cerebras.d.ts +1 -1
  72. package/dist/providers/cerebras.js +1 -1
  73. package/dist/providers/local.d.ts +1 -1
  74. package/dist/providers/local.js +1 -1
  75. package/dist/providers/openai-compat.d.ts +1 -1
  76. package/dist/providers/openai-compat.js +1 -1
  77. package/dist/providers/openai.d.ts +1 -1
  78. package/dist/providers/openai.js +4 -4
  79. package/dist/providers/openrouter.d.ts +1 -1
  80. package/dist/providers/openrouter.js +1 -1
  81. package/dist/providers/xai.d.ts +1 -1
  82. package/dist/providers/xai.js +3 -3
  83. package/dist/providers-Cf0AXIIZ.js +137 -0
  84. package/dist/providers-Cf0AXIIZ.js.map +1 -0
  85. package/dist/providers.d.ts +2 -2
  86. package/dist/providers.js +5 -5
  87. package/dist/restate.d.ts +1 -1
  88. package/dist/restate.js +2 -2
  89. package/dist/session/sqlite.d.ts +1 -1
  90. package/dist/session/sqlite.js +1 -1
  91. package/dist/{session-VpLrNaFQ.js → session-cqN5NbO-.js} +2 -2
  92. package/dist/{session-VpLrNaFQ.js.map → session-cqN5NbO-.js.map} +1 -1
  93. package/dist/session.d.ts +1 -1
  94. package/dist/session.js +2 -2
  95. package/dist/{skills-Cp9vnBwd.js → skills-BMGH_KK1.js} +2 -2
  96. package/dist/{skills-Cp9vnBwd.js.map → skills-BMGH_KK1.js.map} +1 -1
  97. package/dist/skills.d.ts +1 -1
  98. package/dist/skills.js +1 -1
  99. package/dist/{timeout-BDetbuN6.js → timeout-CjOG2mea.js} +29 -2
  100. package/dist/timeout-CjOG2mea.js.map +1 -0
  101. package/dist/timeout-DEaqslLO.d.ts.map +1 -1
  102. package/dist/{tool-formatters-DMr62Hpy.d.ts → tool-formatters-B5WSHMCU.d.ts} +2 -2
  103. package/dist/{tool-formatters-DMr62Hpy.d.ts.map → tool-formatters-B5WSHMCU.d.ts.map} +1 -1
  104. package/dist/tools/fetch-url.d.ts +1 -1
  105. package/dist/tools/fetch-url.js +1 -1
  106. package/dist/tools/web-search.d.ts +1 -1
  107. package/dist/tools/web-search.js +2 -2
  108. package/dist/tools.d.ts +1 -1
  109. package/dist/tools.js +1 -1
  110. package/dist/{transcript-anchors-BHihk9nf.d.ts → transcript-anchors-BPnWHLyr.d.ts} +2 -2
  111. package/dist/{transcript-anchors-BHihk9nf.d.ts.map → transcript-anchors-BPnWHLyr.d.ts.map} +1 -1
  112. package/dist/{transcript-anchors-uU_KZLsp.js → transcript-anchors-BvC8t7dt.js} +177 -63
  113. package/dist/transcript-anchors-BvC8t7dt.js.map +1 -0
  114. package/dist/tui.d.ts +18 -29
  115. package/dist/tui.d.ts.map +1 -1
  116. package/dist/tui.js +737 -236
  117. package/dist/tui.js.map +1 -1
  118. package/dist/{turn-operations-iGu5J08j.js → turn-operations-7_Ff7INF.js} +2 -2
  119. package/dist/{turn-operations-iGu5J08j.js.map → turn-operations-7_Ff7INF.js.map} +1 -1
  120. package/dist/{turn-operations-BgqVUjtl.d.ts → turn-operations-BvP3_HsU.d.ts} +3 -3
  121. package/dist/{turn-operations-BgqVUjtl.d.ts.map → turn-operations-BvP3_HsU.d.ts.map} +1 -1
  122. package/dist/types.d.ts +1 -1
  123. package/dist/types.js +1 -1
  124. package/dist/{xai-CfmI5Y5k.js → xai-DILdFGzN.js} +3 -29
  125. package/dist/xai-DILdFGzN.js.map +1 -0
  126. package/docs/CHAT.md +1 -1
  127. package/docs/TUI.md +4 -4
  128. package/package.json +2 -1
  129. package/dist/agent-8kfGIDb_.js.map +0 -1
  130. package/dist/anthropic-_Hn1YiWr.js.map +0 -1
  131. package/dist/index-BKyWhILQ.d.ts.map +0 -1
  132. package/dist/oauth-BYjlFR-J.js.map +0 -1
  133. package/dist/providers-VypZh7rD.js +0 -264
  134. package/dist/providers-VypZh7rD.js.map +0 -1
  135. package/dist/timeout-BDetbuN6.js.map +0 -1
  136. package/dist/transcript-anchors-uU_KZLsp.js.map +0 -1
  137. package/dist/xai-CfmI5Y5k.js.map +0 -1
package/dist/acp-cli.js CHANGED
@@ -1,18 +1,18 @@
1
1
  #!/usr/bin/env node
2
- import { m as openaiCompat } from "./openai-compat-CnHeo4Lz.js";
3
- import { bt as basic_default } from "./agent-8kfGIDb_.js";
2
+ import { m as openaiCompat } from "./openai-compat-hmZzpDrB.js";
3
+ import { bt as basic_default } from "./agent-gZjHsUft.js";
4
4
  import { r as createProcessContext } from "./contexts-DWVt7MvF.js";
5
5
  import { createSandboxContext } from "./contexts/sandbox.js";
6
- import { p as resolveStorageDirs } from "./plugins-2PMTVcp-.js";
7
- import { n as anthropic } from "./anthropic-_Hn1YiWr.js";
6
+ import { p as resolveStorageDirs } from "./plugins-onDvTHEm.js";
7
+ import { n as anthropic } from "./anthropic-D3le2d-s.js";
8
8
  import { arcee } from "./providers/arcee.js";
9
9
  import { baseten } from "./providers/baseten.js";
10
10
  import { cerebras } from "./providers/cerebras.js";
11
11
  import { openai } from "./providers/openai.js";
12
12
  import { openrouter } from "./providers/openrouter.js";
13
13
  import { xai } from "./providers/xai.js";
14
- import { d as StartUsageError, f as buildStartLocalOptions, h as startProviderNames, i as withAcpDefaultTools, m as startLocalArgOptions, p as parseStartArgValues, t as runAcpStdioServer } from "./acp-CIpD8UIw.js";
15
- import { f as credKeyOf, i as readCredentials, l as BUILTIN_PROVIDERS, r as credentialsPath, t as detectAuth, y as modelsForDescriptor } from "./auth-CS_e8ng1.js";
14
+ import { d as StartUsageError, f as buildStartLocalOptions, h as startProviderNames, i as withAcpDefaultTools, m as startLocalArgOptions, p as parseStartArgValues, t as runAcpStdioServer } from "./acp-BPJbXS2J.js";
15
+ import { f as credKeyOf, i as readCredentials, l as BUILTIN_PROVIDERS, r as credentialsPath, t as detectAuth, y as modelsForDescriptor } from "./auth-DCiXCwGa.js";
16
16
  import { createDaytonaProvider } from "./contexts/daytona.js";
17
17
  import { createDockerContext } from "./contexts/docker.js";
18
18
  import { createE2BProvider } from "./contexts/e2b.js";
package/dist/acp.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Lf as Provider, Ph as ToolDef, Sm as AgentBehavior, Wi as Agent, Xm as PromptPart, ah as SessionContentBlock, bh as ToolResultContent, cg as Session, fg as SessionStore, kh as TurnUsage, qi as AgentOptions, t as Preset, zm as McpServerConfig } from "./index-BKyWhILQ.js";
1
+ import { Bh as TurnUsage, Cg as SessionStore, Gh as ToolDef, Nm as AgentBehavior, Uf as Provider, Wi as Agent, Xm as McpServerConfig, gh as SessionContentBlock, jh as ToolResultContent, qi as AgentOptions, sh as PromptPart, t as Preset, yg as Session } from "./index-BYKzzYzi.js";
2
2
  import { c as ExecutionContext } from "./types-M2DauK2D.js";
3
3
  import { Readable, Writable } from "node:stream";
4
4
 
package/dist/acp.js CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as createJsonRpcConnection, a as wrapToolsForAcpClient, c as sessionBlocksToAcp, g as JsonRpcRemoteError, i as withAcpDefaultTools, l as stopReasonFromRun, n as AcpProtocolError, o as acpMcpServersToZidane, r as createAcpServer, s as acpPromptToPromptParts, t as runAcpStdioServer, u as toolResultToAcpContent } from "./acp-CIpD8UIw.js";
1
+ import { _ as createJsonRpcConnection, a as wrapToolsForAcpClient, c as sessionBlocksToAcp, g as JsonRpcRemoteError, i as withAcpDefaultTools, l as stopReasonFromRun, n as AcpProtocolError, o as acpMcpServersToZidane, r as createAcpServer, s as acpPromptToPromptParts, t as runAcpStdioServer, u as toolResultToAcpContent } from "./acp-BPJbXS2J.js";
2
2
  export { AcpProtocolError, JsonRpcRemoteError, acpMcpServersToZidane, acpPromptToPromptParts, createAcpServer, createJsonRpcConnection, runAcpStdioServer, sessionBlocksToAcp, stopReasonFromRun, toolResultToAcpContent, withAcpDefaultTools, wrapToolsForAcpClient };
@@ -1,24 +1,24 @@
1
- import { B as rewriteMessagesToWire, H as toWireName, I as augmentMcpDoubleUnderscoreAliases, L as buildAliasMaps, M as buildPromptMessage, N as canonicalizePrompt, R as buildSanitizedWireAliases, V as toCanonicalName, z as rewriteContentToCanonical } from "./openai-compat-CnHeo4Lz.js";
1
+ import { B as rewriteMessagesToWire, H as toWireName, I as augmentMcpDoubleUnderscoreAliases, L as buildAliasMaps, M as buildPromptMessage, N as canonicalizePrompt, R as buildSanitizedWireAliases, V as toCanonicalName, z as rewriteContentToCanonical } from "./openai-compat-hmZzpDrB.js";
2
2
  import { a as isWireTurn, c as toolOutputByteLength, i as documentBlockMarker, l as toolResultToText, o as sanitizeToolResultMetadata, s as toolOutputBudgetByteLength, t as DEFAULT_AGENT_CLOCK } from "./types-BIarq1qE.js";
3
- import { a as stripLineNumberPrefixes, i as resolveOldString, n as buildContextBreakdown, o as styleReplacementForVia, r as describeVia, t as buildContextSegments } from "./context-segments-1mcqSCM3.js";
3
+ import { a as stripLineNumberPrefixes, i as resolveOldString, n as buildContextBreakdown, o as styleReplacementForVia, r as describeVia, t as buildContextSegments } from "./context-segments-CJCtJ9sU.js";
4
4
  import { n as estimateTokens, r as utf8ByteLength } from "./utils-ngQzYzZD.js";
5
5
  import { a as formatDuration, c as previewLine, o as formatTaskStatus, s as formatTaskSummary } from "./format-BF745pLL.js";
6
6
  import { i as parseGitLsFiles, r as GIT_LS_FILES_COMMAND } from "./glob-DluQFSw1.js";
7
7
  import { i as isOutputExceededMessage } from "./output-cap-C9zukcCj.js";
8
8
  import { r as createProcessContext, t as resolveDetachedTasksCapability } from "./contexts-DWVt7MvF.js";
9
9
  import { n as shellQuote, t as alwaysQuote } from "./shell-quote-BmnhZmdM.js";
10
- import { a as AgentProviderError, d as isAbortLikeError, h as toTypedError, i as AgentLengthResumeExhaustedError, n as AgentBudgetExceededError, s as AgentToolPairingError, t as AgentAbortedError, u as errorMessage } from "./errors-BwBxu3zD.js";
11
- import { A as createSkillActivationState, D as escapeXml, E as buildCatalog, F as validateResourcePathReal, R as projectUserPaths, _ as lastLine, a as interpolateShellCommands, b as resolveSubdirRoot, g as fetchInstallSource, h as defaultWhich, k as installAllowedToolsGate, m as defaultExec, n as resolveSkills, o as stripShellInterpolations, p as InstallSourceError, v as parseInstallSource, y as resolveNpmVersion } from "./skills-Cp9vnBwd.js";
10
+ import { a as AgentProviderError, d as isAbortLikeError, g as toTypedError, i as AgentLengthResumeExhaustedError, n as AgentBudgetExceededError, p as isTransientTransportError, s as AgentToolPairingError, t as AgentAbortedError, u as errorMessage } from "./errors-DKiMrOKq.js";
11
+ import { A as createSkillActivationState, D as escapeXml, E as buildCatalog, F as validateResourcePathReal, R as projectUserPaths, _ as lastLine, a as interpolateShellCommands, b as resolveSubdirRoot, g as fetchInstallSource, h as defaultWhich, k as installAllowedToolsGate, m as defaultExec, n as resolveSkills, o as stripShellInterpolations, p as InstallSourceError, v as parseInstallSource, y as resolveNpmVersion } from "./skills-BMGH_KK1.js";
12
12
  import { n as writeFileAtomicAsync, t as writeFileAtomic } from "./atomic-write-B7zr1ddF.js";
13
- import { p as resolveStorageDirs, r as loadAgentPlugin } from "./plugins-2PMTVcp-.js";
13
+ import { p as resolveStorageDirs, r as loadAgentPlugin } from "./plugins-onDvTHEm.js";
14
14
  import { r as createLogger, t as consoleSink } from "./logger-DBX9uYOw.js";
15
15
  import { n as reconcileImageMediaType } from "./media-sniff-UKijEaiQ.js";
16
- import { f as wrapDiscoveredMcpTools, i as deriveMcpToolMeta, n as connectMcpServers, s as nonOwningMcpView } from "./mcp-D9fqOQo5.js";
16
+ import { f as wrapDiscoveredMcpTools, i as deriveMcpToolMeta, n as connectMcpServers, s as nonOwningMcpView } from "./mcp-CVtSQTWg.js";
17
17
  import { appendStaticSection, renderSystemForWire } from "./prompt.js";
18
- import { a as detectTurnInterruption, c as ensureToolResultPairing, l as filterUnresolvedToolUses, m as resolveContentRefsInMessages, n as SYNTHETIC_TOOL_RESULT_PLACEHOLDER, p as remintDuplicateToolCallIds, s as ensureEndsWithUserMessage } from "./messages-C_H9soi5.js";
19
- import { a as getExtensionSessionState, c as setExtensionSessionState, l as withExtensionSession, n as currentExtensionSession, r as deleteExtensionSessionState, s as resumeChainRunIds } from "./session-VpLrNaFQ.js";
18
+ import { a as detectTurnInterruption, c as ensureToolResultPairing, l as filterUnresolvedToolUses, m as resolveContentRefsInMessages, n as SYNTHETIC_TOOL_RESULT_PLACEHOLDER, p as remintDuplicateToolCallIds, s as ensureEndsWithUserMessage } from "./messages-CVVg5jUL.js";
19
+ import { a as getExtensionSessionState, c as setExtensionSessionState, l as withExtensionSession, n as currentExtensionSession, r as deleteExtensionSessionState, s as resumeChainRunIds } from "./session-cqN5NbO-.js";
20
20
  import { n as flattenTurns, r as formatTokenUsage, t as effectiveInputFromTurn } from "./stats-DAKBEKjc.js";
21
- import { a as withInactivityTimeout, i as settleWithinTimeout, n as linkAbortSignal, o as withTimeout$1, r as resolveTimeoutMs, t as OperationTimeoutError } from "./timeout-BDetbuN6.js";
21
+ import { a as settleWithinTimeout, i as resolveTimeoutMs, n as abortableSleep, o as withInactivityTimeout, r as linkAbortSignal, s as withTimeout$1, t as OperationTimeoutError } from "./timeout-CjOG2mea.js";
22
22
  import { createRequire } from "node:module";
23
23
  import { basename, delimiter, dirname, isAbsolute, join, resolve, sep } from "node:path";
24
24
  import { createHooks } from "hookable";
@@ -2281,8 +2281,8 @@ const KEYBINDING_DEFS = [
2281
2281
  {
2282
2282
  action: "attachClipboardImage",
2283
2283
  default: "ctrl+v",
2284
- label: "paste image",
2285
- description: "attach an image from the OS clipboard to the prompt (needs a platform helper: pngpaste on macOS, wl-clipboard/xclip on Linux)",
2284
+ label: "paste clipboard",
2285
+ description: "paste text or attach an image directly from the OS clipboard, bypassing the terminal paste path",
2286
2286
  group: "Global"
2287
2287
  },
2288
2288
  {
@@ -8583,6 +8583,139 @@ const EMPTY_EXTENSION_REGISTRY = Object.freeze({
8583
8583
  dispose: async () => {}
8584
8584
  });
8585
8585
  //#endregion
8586
+ //#region src/loop-recovery.ts
8587
+ /**
8588
+ * Operation labels used by the provider-stream watchdogs.
8589
+ *
8590
+ * Single source of truth for the strings so `withTimeout` callers and the
8591
+ * failure classifier can never drift: the classifier matches on exactly the
8592
+ * label the watchdog emits.
8593
+ */
8594
+ const PROVIDER_WATCHDOG_OPERATIONS = {
8595
+ "first response": "provider first response",
8596
+ "total stream": "provider total stream",
8597
+ "stream inactivity": "provider stream inactivity"
8598
+ };
8599
+ /** Watchdog operation names that count as provider-stream failures. */
8600
+ const PROVIDER_WATCHDOG_OPERATION_SET = new Set(Object.values(PROVIDER_WATCHDOG_OPERATIONS));
8601
+ const RETRY_DEFAULTS = {
8602
+ maxAttempts: 3,
8603
+ initialDelayMs: 1e3,
8604
+ maxDelayMs: 3e4
8605
+ };
8606
+ /**
8607
+ * Normalize a user-supplied `RetryConfig` (any field may be missing or invalid)
8608
+ * into a fully-populated config the retry loop can use without per-field guards.
8609
+ *
8610
+ * Invalid values (non-finite, < 1 for `maxAttempts`, < 0 for delays) fall back
8611
+ * to defaults rather than throwing — this is a behavior knob, not a validation
8612
+ * boundary, and a bad value here shouldn't crash a run.
8613
+ */
8614
+ function resolveRetryConfig(cfg) {
8615
+ return {
8616
+ maxAttempts: Number.isFinite(cfg?.maxAttempts) && cfg.maxAttempts >= 1 ? Math.floor(cfg.maxAttempts) : RETRY_DEFAULTS.maxAttempts,
8617
+ initialDelayMs: Number.isFinite(cfg?.initialDelayMs) && cfg.initialDelayMs >= 0 ? cfg.initialDelayMs : RETRY_DEFAULTS.initialDelayMs,
8618
+ maxDelayMs: Number.isFinite(cfg?.maxDelayMs) && cfg.maxDelayMs >= 0 ? cfg.maxDelayMs : RETRY_DEFAULTS.maxDelayMs
8619
+ };
8620
+ }
8621
+ /**
8622
+ * Classify a failed stream attempt.
8623
+ *
8624
+ * Retry eligibility covers three sources: an error the provider's own classifier
8625
+ * marked retryable, a provider-stream watchdog timeout, and a transport-level
8626
+ * failure. The latter two are retryable BY CONSTRUCTION for the first-response
8627
+ * watchdog and for any dropped connection — zero observable events arrived, so
8628
+ * re-issuing is at least as safe as the mid-stream `overloaded_error` retries
8629
+ * the classifier opts into. The total-stream and inactivity watchdogs ride the
8630
+ * same carve-out but lean on `cleanSlate` for their safety.
8631
+ *
8632
+ * Transport failures need their own source because they happen BELOW the API:
8633
+ * they carry no status and no error body, so `classifyError` returns `null` and
8634
+ * the classifier-driven branch can never fire for them.
8635
+ *
8636
+ * Fallback excludes two classifications:
8637
+ * - `context_exceeded` — owned by overflow recovery; the transcript is the
8638
+ * problem, not the provider.
8639
+ * - `tool_pairing_corruption` — transcript-level corruption fails identically
8640
+ * on every provider.
8641
+ *
8642
+ * Everything else (rate limit, overload, 5xx, auth/billing, even unclassified
8643
+ * network failures) is provider-side: a sibling target may well succeed, and a
8644
+ * genuinely broken request just exhausts the chain and surfaces the last error.
8645
+ */
8646
+ function assessStreamFailure(input) {
8647
+ const { err, runAborted, classifyError, progress, attempt, retry, hasNextTarget } = input;
8648
+ const wasAborted = runAborted || err instanceof Error && err.name === "AbortError";
8649
+ const classified = !wasAborted ? classifyError?.(err) ?? null : null;
8650
+ const cleanSlate = progress.text === "" && progress.thinking === "" && !progress.serverToolActivity;
8651
+ const isRetryable = classified?.kind === "provider_error" && classified.retryable === true;
8652
+ const isStreamWatchdogTimeout = !wasAborted && err instanceof OperationTimeoutError && PROVIDER_WATCHDOG_OPERATION_SET.has(err.operation);
8653
+ const isTransportFailure = !wasAborted && isTransientTransportError(err);
8654
+ const canRetry = !wasAborted && (isRetryable || isStreamWatchdogTimeout || isTransportFailure) && cleanSlate && attempt < retry.maxAttempts;
8655
+ const retryAfterMs = canRetry ? extractRetryAfterMs(err) : void 0;
8656
+ return {
8657
+ wasAborted,
8658
+ classified,
8659
+ cleanSlate,
8660
+ retryAfterMs,
8661
+ canRetry,
8662
+ preferFallbackOverRetry: retryAfterMs !== void 0 && retryAfterMs > 15e3 && hasNextTarget,
8663
+ canRecoverOverflow: !wasAborted && classified?.kind === "context_exceeded" && cleanSlate,
8664
+ canFallback: !wasAborted && cleanSlate && hasNextTarget && classified?.kind !== "context_exceeded" && classified?.kind !== "tool_pairing_corruption"
8665
+ };
8666
+ }
8667
+ /**
8668
+ * Backoff delay for the next attempt.
8669
+ *
8670
+ * A server-declared `retry-after` wins (capped at `maxDelayMs`); otherwise
8671
+ * full-jitter exponential backoff — a uniform draw from `[0, capped)` rather
8672
+ * than a fixed `capped`, so a fleet of clients retrying the same overloaded
8673
+ * endpoint spreads out instead of stampeding in lockstep.
8674
+ */
8675
+ function computeRetryDelayMs(attempt, cfg, retryAfterMs) {
8676
+ if (retryAfterMs !== void 0 && retryAfterMs >= 0) return Math.min(retryAfterMs, cfg.maxDelayMs);
8677
+ const exponential = cfg.initialDelayMs * 2 ** (attempt - 1);
8678
+ const capped = Math.min(exponential, cfg.maxDelayMs);
8679
+ return Math.floor(Math.random() * capped);
8680
+ }
8681
+ /**
8682
+ * Extract a `retry-after` value (in milliseconds) from an error's `.headers`, if any.
8683
+ *
8684
+ * Supports both `retry-after-ms` (non-standard but Stainless-emitted; already in ms,
8685
+ * always integer) and the standard `retry-after` header (integer seconds, RFC 7231).
8686
+ * Returns `undefined` when neither is present, non-numeric, or negative.
8687
+ *
8688
+ * `parseInt` over `parseFloat` here matches the actual contract — Stainless emits
8689
+ * `retry-after-ms` as an integer and RFC 7231 specifies a non-negative integer for
8690
+ * the seconds form. The HTTP-date form of `retry-after` is deliberately unsupported
8691
+ * (Anthropic + OpenAI both emit numeric seconds; supporting dates invites clock-skew
8692
+ * concerns for negligible benefit).
8693
+ */
8694
+ function extractRetryAfterMs(err) {
8695
+ if (!err || typeof err !== "object") return void 0;
8696
+ const headers = err.headers;
8697
+ if (!headers || typeof headers !== "object") return void 0;
8698
+ const get = (key) => {
8699
+ const h = headers;
8700
+ if (typeof h.get === "function") {
8701
+ const v = h.get(key);
8702
+ return typeof v === "string" ? v : void 0;
8703
+ }
8704
+ const v = h[key];
8705
+ return typeof v === "string" ? v : void 0;
8706
+ };
8707
+ const ms = get("retry-after-ms");
8708
+ if (ms !== void 0) {
8709
+ const parsed = Number.parseInt(ms, 10);
8710
+ if (Number.isFinite(parsed) && parsed >= 0) return parsed;
8711
+ }
8712
+ const seconds = get("retry-after");
8713
+ if (seconds !== void 0) {
8714
+ const parsed = Number.parseInt(seconds, 10);
8715
+ if (Number.isFinite(parsed) && parsed >= 0) return parsed * 1e3;
8716
+ }
8717
+ }
8718
+ //#endregion
8586
8719
  //#region src/compact/errors.ts
8587
8720
  /**
8588
8721
  * Typed errors thrown by the compaction helper.
@@ -9142,6 +9275,24 @@ const DEFAULT_MAX_OUTPUT_TOKENS = 2e4;
9142
9275
  const DEFAULT_MAX_PTL_RETRIES = 3;
9143
9276
  /** Maximum transient-error retries before giving up. Independent of PTL. */
9144
9277
  const TRANSIENT_RETRY_BUDGET = 2;
9278
+ /**
9279
+ * Backoff for transient retries. Shares the turn loop's policy
9280
+ * ({@link computeRetryDelayMs}: a server-declared `retry-after` wins, otherwise
9281
+ * exponential with full jitter) but keeps its own constants — the budget here is
9282
+ * 2 rather than 3, and a summarize call is cheap to re-issue, so waiting out the
9283
+ * loop's multi-second defaults would cost more than it buys.
9284
+ *
9285
+ * The jittered curve is FULL jitter — a uniform draw from `[0, capped)` — so it
9286
+ * raises the expected gap between re-dials (125ms, then 250ms on average) rather
9287
+ * than guaranteeing a floor; a near-zero wait is still a normal draw. Spreading
9288
+ * the retries out is the point, and an immediate re-dial of a socket that just
9289
+ * dropped is only the least promising single timing, not a disaster.
9290
+ */
9291
+ const TRANSIENT_RETRY_BACKOFF = {
9292
+ maxAttempts: TRANSIENT_RETRY_BUDGET,
9293
+ initialDelayMs: 250,
9294
+ maxDelayMs: 2e3
9295
+ };
9145
9296
  async function compactConversation(opts) {
9146
9297
  const slice = sliceForCompaction(opts.turns, opts.scope ?? "tail", opts.keepTurns ?? DEFAULT_KEEP_TURNS);
9147
9298
  const scope = opts.scope ?? "tail";
@@ -9223,6 +9374,7 @@ async function compactConversation(opts) {
9223
9374
  }
9224
9375
  if (isTransientError(err) && transientRetries < TRANSIENT_RETRY_BUDGET) {
9225
9376
  transientRetries++;
9377
+ await abortableSleep(computeRetryDelayMs(transientRetries, TRANSIENT_RETRY_BACKOFF, extractRetryAfterMs(err)), opts.signal ?? new AbortController().signal);
9226
9378
  continue;
9227
9379
  }
9228
9380
  throw err;
@@ -9462,14 +9614,23 @@ function isPromptTooLongError(err) {
9462
9614
  }
9463
9615
  /**
9464
9616
  * Transient network / 5xx errors worth retrying once or twice.
9617
+ *
9618
+ * The 5xx test stays local and deliberately plain (`>= 500 && < 600`, where
9619
+ * `isRetryableHttpStatus` exempts 501 and adds 429) — see the note in
9620
+ * `errors.ts`. Re-summarizing has no side effects, so this leans further toward
9621
+ * retrying than the turn loop does.
9622
+ *
9623
+ * The transport half is NOT local: socket teardowns spell themselves a dozen
9624
+ * ways across runtimes, and keeping a second private list here is exactly how
9625
+ * this one came to miss Bun's wording entirely. Sharing also drops a hazard the
9626
+ * local list carried — its message test ignored `status`, so a 401 whose body
9627
+ * happened to say "terminated" was retried as if the socket had dropped.
9465
9628
  */
9466
9629
  function isTransientError(err) {
9467
9630
  if (!err || typeof err !== "object") return false;
9468
9631
  const e = err;
9469
9632
  if (typeof e.status === "number" && e.status >= 500 && e.status < 600) return true;
9470
- if (typeof e.code === "string" && /ECONNRESET|ETIMEDOUT|ENETUNREACH|EAI_AGAIN|fetch failed/i.test(e.code)) return true;
9471
- if (typeof e.message === "string" && /socket hang up|fetch failed|network error|terminated|ECONNRESET|read ETIMEDOUT/i.test(e.message)) return true;
9472
- return false;
9633
+ return isTransientTransportError(err);
9473
9634
  }
9474
9635
  function isAbortError(err, signal) {
9475
9636
  if (signal?.aborted) return true;
@@ -10542,134 +10703,6 @@ function textForPersistence(output) {
10542
10703
  return parts.join("\n");
10543
10704
  }
10544
10705
  //#endregion
10545
- //#region src/loop-recovery.ts
10546
- /**
10547
- * Operation labels used by the provider-stream watchdogs.
10548
- *
10549
- * Single source of truth for the strings so `withTimeout` callers and the
10550
- * failure classifier can never drift: the classifier matches on exactly the
10551
- * label the watchdog emits.
10552
- */
10553
- const PROVIDER_WATCHDOG_OPERATIONS = {
10554
- "first response": "provider first response",
10555
- "total stream": "provider total stream",
10556
- "stream inactivity": "provider stream inactivity"
10557
- };
10558
- /** Watchdog operation names that count as provider-stream failures. */
10559
- const PROVIDER_WATCHDOG_OPERATION_SET = new Set(Object.values(PROVIDER_WATCHDOG_OPERATIONS));
10560
- const RETRY_DEFAULTS = {
10561
- maxAttempts: 3,
10562
- initialDelayMs: 1e3,
10563
- maxDelayMs: 3e4
10564
- };
10565
- /**
10566
- * Normalize a user-supplied `RetryConfig` (any field may be missing or invalid)
10567
- * into a fully-populated config the retry loop can use without per-field guards.
10568
- *
10569
- * Invalid values (non-finite, < 1 for `maxAttempts`, < 0 for delays) fall back
10570
- * to defaults rather than throwing — this is a behavior knob, not a validation
10571
- * boundary, and a bad value here shouldn't crash a run.
10572
- */
10573
- function resolveRetryConfig(cfg) {
10574
- return {
10575
- maxAttempts: Number.isFinite(cfg?.maxAttempts) && cfg.maxAttempts >= 1 ? Math.floor(cfg.maxAttempts) : RETRY_DEFAULTS.maxAttempts,
10576
- initialDelayMs: Number.isFinite(cfg?.initialDelayMs) && cfg.initialDelayMs >= 0 ? cfg.initialDelayMs : RETRY_DEFAULTS.initialDelayMs,
10577
- maxDelayMs: Number.isFinite(cfg?.maxDelayMs) && cfg.maxDelayMs >= 0 ? cfg.maxDelayMs : RETRY_DEFAULTS.maxDelayMs
10578
- };
10579
- }
10580
- /**
10581
- * Classify a failed stream attempt.
10582
- *
10583
- * Retry eligibility covers two sources: an error the provider's own classifier
10584
- * marked retryable, and a provider-stream watchdog timeout. The latter is
10585
- * retryable BY CONSTRUCTION for the first-response watchdog — zero observable
10586
- * events arrived, so re-issuing is at least as safe as the mid-stream
10587
- * `overloaded_error` retries the classifier opts into. The total-stream and
10588
- * inactivity watchdogs ride the same carve-out but lean on `cleanSlate` for
10589
- * their safety.
10590
- *
10591
- * Fallback excludes two classifications:
10592
- * - `context_exceeded` — owned by overflow recovery; the transcript is the
10593
- * problem, not the provider.
10594
- * - `tool_pairing_corruption` — transcript-level corruption fails identically
10595
- * on every provider.
10596
- *
10597
- * Everything else (rate limit, overload, 5xx, auth/billing, even unclassified
10598
- * network failures) is provider-side: a sibling target may well succeed, and a
10599
- * genuinely broken request just exhausts the chain and surfaces the last error.
10600
- */
10601
- function assessStreamFailure(input) {
10602
- const { err, runAborted, classifyError, progress, attempt, retry, hasNextTarget } = input;
10603
- const wasAborted = runAborted || err instanceof Error && err.name === "AbortError";
10604
- const classified = !wasAborted ? classifyError?.(err) ?? null : null;
10605
- const cleanSlate = progress.text === "" && progress.thinking === "" && !progress.serverToolActivity;
10606
- const isRetryable = classified?.kind === "provider_error" && classified.retryable === true;
10607
- const isStreamWatchdogTimeout = !wasAborted && err instanceof OperationTimeoutError && PROVIDER_WATCHDOG_OPERATION_SET.has(err.operation);
10608
- const canRetry = !wasAborted && (isRetryable || isStreamWatchdogTimeout) && cleanSlate && attempt < retry.maxAttempts;
10609
- const retryAfterMs = canRetry ? extractRetryAfterMs(err) : void 0;
10610
- return {
10611
- wasAborted,
10612
- classified,
10613
- cleanSlate,
10614
- retryAfterMs,
10615
- canRetry,
10616
- preferFallbackOverRetry: retryAfterMs !== void 0 && retryAfterMs > 15e3 && hasNextTarget,
10617
- canRecoverOverflow: !wasAborted && classified?.kind === "context_exceeded" && cleanSlate,
10618
- canFallback: !wasAborted && cleanSlate && hasNextTarget && classified?.kind !== "context_exceeded" && classified?.kind !== "tool_pairing_corruption"
10619
- };
10620
- }
10621
- /**
10622
- * Backoff delay for the next attempt.
10623
- *
10624
- * A server-declared `retry-after` wins (capped at `maxDelayMs`); otherwise
10625
- * full-jitter exponential backoff — a uniform draw from `[0, capped)` rather
10626
- * than a fixed `capped`, so a fleet of clients retrying the same overloaded
10627
- * endpoint spreads out instead of stampeding in lockstep.
10628
- */
10629
- function computeRetryDelayMs(attempt, cfg, retryAfterMs) {
10630
- if (retryAfterMs !== void 0 && retryAfterMs >= 0) return Math.min(retryAfterMs, cfg.maxDelayMs);
10631
- const exponential = cfg.initialDelayMs * 2 ** (attempt - 1);
10632
- const capped = Math.min(exponential, cfg.maxDelayMs);
10633
- return Math.floor(Math.random() * capped);
10634
- }
10635
- /**
10636
- * Extract a `retry-after` value (in milliseconds) from an error's `.headers`, if any.
10637
- *
10638
- * Supports both `retry-after-ms` (non-standard but Stainless-emitted; already in ms,
10639
- * always integer) and the standard `retry-after` header (integer seconds, RFC 7231).
10640
- * Returns `undefined` when neither is present, non-numeric, or negative.
10641
- *
10642
- * `parseInt` over `parseFloat` here matches the actual contract — Stainless emits
10643
- * `retry-after-ms` as an integer and RFC 7231 specifies a non-negative integer for
10644
- * the seconds form. The HTTP-date form of `retry-after` is deliberately unsupported
10645
- * (Anthropic + OpenAI both emit numeric seconds; supporting dates invites clock-skew
10646
- * concerns for negligible benefit).
10647
- */
10648
- function extractRetryAfterMs(err) {
10649
- if (!err || typeof err !== "object") return void 0;
10650
- const headers = err.headers;
10651
- if (!headers || typeof headers !== "object") return void 0;
10652
- const get = (key) => {
10653
- const h = headers;
10654
- if (typeof h.get === "function") {
10655
- const v = h.get(key);
10656
- return typeof v === "string" ? v : void 0;
10657
- }
10658
- const v = h[key];
10659
- return typeof v === "string" ? v : void 0;
10660
- };
10661
- const ms = get("retry-after-ms");
10662
- if (ms !== void 0) {
10663
- const parsed = Number.parseInt(ms, 10);
10664
- if (Number.isFinite(parsed) && parsed >= 0) return parsed;
10665
- }
10666
- const seconds = get("retry-after");
10667
- if (seconds !== void 0) {
10668
- const parsed = Number.parseInt(seconds, 10);
10669
- if (Number.isFinite(parsed) && parsed >= 0) return parsed * 1e3;
10670
- }
10671
- }
10672
- //#endregion
10673
10706
  //#region src/loop.ts
10674
10707
  const DEFAULT_PROVIDER_STREAM_START_TIMEOUT_MS = 300 * 1e3;
10675
10708
  const DEFAULT_PROVIDER_STREAM_TIMEOUT_MS = 1800 * 1e3;
@@ -12465,29 +12498,6 @@ async function maybeAutoCompact(ctx, turn, lastTurnUsage, state) {
12465
12498
  }
12466
12499
  }
12467
12500
  /**
12468
- * `setTimeout` that rejects if the given signal aborts before the timer fires.
12469
- *
12470
- * Resolves with `undefined` on normal completion. Rejects with the signal's
12471
- * `reason` (or a generic AbortError when no reason is set) on abort. Cleans
12472
- * up its `abort` listener in both paths so callers don't leak handlers.
12473
- */
12474
- function abortableSleep(ms, signal) {
12475
- if (signal.aborted) return Promise.reject(signal.reason ?? new DOMException("Aborted", "AbortError"));
12476
- return new Promise((resolve, reject) => {
12477
- let timer;
12478
- const onAbort = () => {
12479
- clearTimeout(timer);
12480
- signal.removeEventListener("abort", onAbort);
12481
- reject(signal.reason ?? new DOMException("Aborted", "AbortError"));
12482
- };
12483
- timer = setTimeout(() => {
12484
- signal.removeEventListener("abort", onAbort);
12485
- resolve();
12486
- }, ms);
12487
- signal.addEventListener("abort", onAbort, { once: true });
12488
- });
12489
- }
12490
- /**
12491
12501
  * Advance the run to the next provider+model target and rebind the prepared
12492
12502
  * request to it.
12493
12503
  *
@@ -16968,4 +16978,4 @@ function createAgent(rawOptions) {
16968
16978
  //#endregion
16969
16979
  export { installExtensionFromSpec as $, groupBindings as $t, selectFilesFromSession as A, defaultRepeatGuardNormalize as An, createSkillsReadTool as At, buildUpToCompactPrompt as B, matchModelEntries as Bt, resolveLegacySessionDir as C, resolveExtensionConfigValue as Cn, waitTask as Ct, resolveTasksDir as D, OUTPUT_RESERVE_TOKENS as Dn, reserveChildLabel as Dt, resolveSessionDir as E, AUTO_COMPACT_MIN_GROWTH_FRACTION as En, isSpawnTool as Et, TRAILER as F, hashContent as Fn, readFile$1 as Ft, summaryToTurn as G, edit as Gt, anchorPreviewFor as H, createInteractionTool as Ht, buildCompactPrompt as I, hydrateReadStateFromSession as In, looksBinary as It, CompactPromptTooLongError as J, KEYBINDING_DEFS as Jt, truncateHeadForPtlRetry as K, validateToolArgs as Kt, buildFromCompactPrompt as L, hydrateReadStateFromSessionAsync as Ln, multiEdit as Lt, compactConversation as M, normalizeShellCommand as Mn, createShellTool as Mt, BASE_INSTRUCTIONS as N, stableStringify as Nn, shell as Nt, buildPostCompactAttachments as O, effectiveContextWindow as On, createSkillsUseTool as Ot, NO_TOOLS_PREAMBLE as P, getReadState as Pn, tailTruncate as Pt, fetchExtensionSource as Q, formatBindingForDisplay as Qt, buildFullCompactPrompt as R, readStateKey as Rn, createModelSearchTool as Rt, resolveLegacyPersistDir as S, resolveExtensionConfig as Sn, WAIT_TASK_TIMED_OUT_PREFIX as St, resolvePersistDir as T, toWireConfigSchema as Tn, createSpawnTool as Tt, sliceForCompaction as U, grep as Ut, ANCHOR_PREVIEW_MAX_CHARS as V, listFiles as Vt, stripImagesFromTurns as W, glob as Wt, createExtensionPromptBridge as X, KEYBINDING_KEY_COL_WIDTH as Xt, EMPTY_EXTENSION_REGISTRY as Y, KEYBINDING_DEF_BY_ACTION as Yt, ExtensionInstallError as Z, ensureKeybindingsFile as Zt, buildPersistedStub as _, defineExtension as _n, composePresets as _t, stagedToolState as a, readKeybindingsRaw as an, createExtensionHud as at, migrateSessionArtifactDirs as b, isValidExtensionConfigItem as bn, basic_default as bt, INTERRUPT_MESSAGE_FOR_TOOL_USE as c, registerExtensionHostModules as cn, buildExtensionRegistry as ct, TOOL_USE_SKIPPED_MESSAGE as d, discoverExtensions as dn, filterExtensionRegistry as dt, keybindingsPath as en, listExtensionCandidates as et, applyCompactSummaryCutoff as f, inlineLoadedExtension as fn, filterRegistryPlugins as ft, PERSISTENCE_PREVIEW_BYTES as g, createDebugLog as gn, createWorkspaceSurface as gt, PERSISTED_STUB_PREFIX as h, scanExtensionDirectories as hn, createExtensionHostRuntimeBridge as ht, isToolStateOps as i, readKeybindings as in, updateInstalledExtension as it, selectRecentFiles as j, defaultRepeatGuardTracked as jn, shellKill as jt, selectFilesFromReadState as k, shouldAutoCompact as kn, createSkillsRunScriptTool as kt, SHELL_CASCADE_CANCEL_MESSAGE as l, ENTRY_CANDIDATES as ln, composeExtensionPreset as lt, renderStaleReadNotice as m, parseExtensionScanPathEnv as mn, partitionExtensionCatalog as mt, DEFAULT_MAX_VALUE_BYTES as n, mergeKeybindings as nn, readExtensionInstallProvenance as nt, normalizeProviders as o, resolveExtensionKeybindings as on, discoverAndBuildExtensionRegistry as ot, collectNewlyStaleReadPaths as p, isExtensionDefinition as pn, mergeContributions as pt, CompactInvalidInputError as q, DEFAULT_KEYBINDINGS as qt, createToolStateController as r, parseBindingSpec as rn, removeInstalledExtension as rt, resolveModelTargets as s, stripJsonComments as sn, buildExtensionPreset as st, createAgent as t, matchesBinding as tn, parseExtensionInstallSource as tt, TOOL_USE_CANCELLED_MESSAGE as u, defaultExtensionScanPaths as un, disposeExtensionRegistry as ut, cleanupPersistedSession as v, clampExtensionConfigNumber as vn, definePreset as vt, resolveMcpWarningsDir as w, sanitizeExtensionConfigActionPatch as wn, createToolSearchTool as wt, rehomePersistedStubs as x, isValidExtensionConfigValue as xn, writeFile$1 as xt, maybePersistToolResult as y, coerceExtensionConfigInput as yn, basicTools as yt, buildTailCompactPrompt as z, resolveReadStateMap as zn, formatModelLine as zt };
16970
16980
 
16971
- //# sourceMappingURL=agent-8kfGIDb_.js.map
16981
+ //# sourceMappingURL=agent-gZjHsUft.js.map