zidane 6.2.26 → 6.2.28

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 (93) hide show
  1. package/dist/{acp-CNZqD1Fw.js → acp-GV1rqO6S.js} +4 -4
  2. package/dist/{acp-CNZqD1Fw.js.map → acp-GV1rqO6S.js.map} +1 -1
  3. package/dist/acp-cli.js +5 -5
  4. package/dist/acp.d.ts +1 -1
  5. package/dist/acp.js +1 -1
  6. package/dist/{agent--VPMZ0nT.js → agent--qDjL0fH.js} +102 -27
  7. package/dist/{agent--VPMZ0nT.js.map → agent--qDjL0fH.js.map} +1 -1
  8. package/dist/agent.d.ts +1 -1
  9. package/dist/agent.js +1 -1
  10. package/dist/{anthropic-uKvj1yle.js → anthropic-BEYY0hVK.js} +66 -10
  11. package/dist/anthropic-BEYY0hVK.js.map +1 -0
  12. package/dist/{auth-DIT_DMwa.js → auth-C4YPRDN4.js} +2 -2
  13. package/dist/{auth-DIT_DMwa.js.map → auth-C4YPRDN4.js.map} +1 -1
  14. package/dist/chat/pure.d.ts +3 -3
  15. package/dist/chat.d.ts +4 -4
  16. package/dist/chat.js +3 -3
  17. package/dist/contexts/daytona.d.ts +1 -1
  18. package/dist/contexts/daytona.js +1 -1
  19. package/dist/contexts/docker.js +1 -1
  20. package/dist/contexts/e2b.d.ts +1 -1
  21. package/dist/contexts/e2b.js +1 -1
  22. package/dist/{contexts-0rmrBhTK.js → contexts-Bq904_Gm.js} +2 -2
  23. package/dist/{contexts-0rmrBhTK.js.map → contexts-Bq904_Gm.js.map} +1 -1
  24. package/dist/contexts.js +1 -1
  25. package/dist/eval.d.ts +1 -1
  26. package/dist/eval.js +2 -2
  27. package/dist/extensions.d.ts +1 -1
  28. package/dist/extensions.js +1 -1
  29. package/dist/headless.d.ts +1 -1
  30. package/dist/headless.js +4 -4
  31. package/dist/{index-AVZ6pYpi.d.ts → index-DzQyRZ8Q.d.ts} +148 -2
  32. package/dist/index-DzQyRZ8Q.d.ts.map +1 -0
  33. package/dist/index.d.ts +2 -2
  34. package/dist/index.js +8 -8
  35. package/dist/{login-afiadwf0.js → login-CEOlp1r6.js} +4 -3
  36. package/dist/{login-afiadwf0.js.map → login-CEOlp1r6.js.map} +1 -1
  37. package/dist/{mcp-H6bqyM94.js → mcp-Ct5tF4oj.js} +64 -3
  38. package/dist/mcp-Ct5tF4oj.js.map +1 -0
  39. package/dist/mcp.d.ts +2 -2
  40. package/dist/mcp.js +2 -2
  41. package/dist/{messages-CvHfYB7f.js → messages-Dy9t7DbQ.js} +97 -6
  42. package/dist/messages-Dy9t7DbQ.js.map +1 -0
  43. package/dist/output/stream-json.d.ts +1 -1
  44. package/dist/output/terminal.d.ts +1 -1
  45. package/dist/{output-cap-DM1HrgIp.js → output-cap-C9zukcCj.js} +2 -2
  46. package/dist/{output-cap-DM1HrgIp.js.map → output-cap-C9zukcCj.js.map} +1 -1
  47. package/dist/presets.d.ts +1 -1
  48. package/dist/presets.js +1 -1
  49. package/dist/providers/anthropic.d.ts +1 -1
  50. package/dist/providers/anthropic.js +1 -1
  51. package/dist/providers/arcee.d.ts +1 -1
  52. package/dist/providers/baseten.d.ts +1 -1
  53. package/dist/providers/cerebras.d.ts +1 -1
  54. package/dist/providers/local.d.ts +1 -1
  55. package/dist/providers/openai-compat.d.ts +1 -1
  56. package/dist/providers/openai.d.ts +1 -1
  57. package/dist/providers/openai.js +4 -3
  58. package/dist/providers/openai.js.map +1 -1
  59. package/dist/providers/openrouter.d.ts +1 -1
  60. package/dist/providers/xai.d.ts +1 -1
  61. package/dist/providers.d.ts +1 -1
  62. package/dist/providers.js +1 -1
  63. package/dist/restate.d.ts +1 -1
  64. package/dist/session/sqlite.d.ts +1 -1
  65. package/dist/{session-jLsc_kMH.js → session-DkVnYGm9.js} +2 -2
  66. package/dist/{session-jLsc_kMH.js.map → session-DkVnYGm9.js.map} +1 -1
  67. package/dist/session.d.ts +1 -1
  68. package/dist/session.js +2 -2
  69. package/dist/skills.d.ts +1 -1
  70. package/dist/{tool-formatters-Dual3Hdl.d.ts → tool-formatters-BI_Z-0eY.d.ts} +2 -2
  71. package/dist/{tool-formatters-Dual3Hdl.d.ts.map → tool-formatters-BI_Z-0eY.d.ts.map} +1 -1
  72. package/dist/tools/fetch-url.d.ts +1 -1
  73. package/dist/tools/web-search.d.ts +1 -1
  74. package/dist/tools.d.ts +1 -1
  75. package/dist/tools.js +1 -1
  76. package/dist/{transcript-anchors-CG85bieG.d.ts → transcript-anchors-CI398UQZ.d.ts} +2 -2
  77. package/dist/{transcript-anchors-CG85bieG.d.ts.map → transcript-anchors-CI398UQZ.d.ts.map} +1 -1
  78. package/dist/{transcript-anchors-CnmxZ8QR.js → transcript-anchors-CoAzFKmy.js} +4 -4
  79. package/dist/{transcript-anchors-CnmxZ8QR.js.map → transcript-anchors-CoAzFKmy.js.map} +1 -1
  80. package/dist/tui.d.ts +3 -3
  81. package/dist/tui.d.ts.map +1 -1
  82. package/dist/tui.js +162 -96
  83. package/dist/tui.js.map +1 -1
  84. package/dist/{turn-operations-BUYaSCL3.d.ts → turn-operations-Z3R0sjye.d.ts} +3 -3
  85. package/dist/{turn-operations-BUYaSCL3.d.ts.map → turn-operations-Z3R0sjye.d.ts.map} +1 -1
  86. package/dist/types-BIarq1qE.js.map +1 -1
  87. package/dist/types.d.ts +1 -1
  88. package/docs/CHAT.md +11 -0
  89. package/package.json +1 -1
  90. package/dist/anthropic-uKvj1yle.js.map +0 -1
  91. package/dist/index-AVZ6pYpi.d.ts.map +0 -1
  92. package/dist/mcp-H6bqyM94.js.map +0 -1
  93. package/dist/messages-CvHfYB7f.js.map +0 -1
package/dist/acp-cli.js CHANGED
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env node
2
- import { It as resolveStorageDirs, ut as basic_default } from "./agent--VPMZ0nT.js";
3
- import { r as createProcessContext } from "./contexts-0rmrBhTK.js";
2
+ import { It as resolveStorageDirs, ut as basic_default } from "./agent--qDjL0fH.js";
3
+ import { r as createProcessContext } from "./contexts-Bq904_Gm.js";
4
4
  import { createSandboxContext } from "./contexts/sandbox.js";
5
5
  import { m as openaiCompat } from "./openai-compat-pHI0kBWH.js";
6
- import { t as anthropic } from "./anthropic-uKvj1yle.js";
6
+ import { t as anthropic } from "./anthropic-BEYY0hVK.js";
7
7
  import { arcee } from "./providers/arcee.js";
8
8
  import { baseten } from "./providers/baseten.js";
9
9
  import { cerebras } from "./providers/cerebras.js";
10
10
  import { t as xai } from "./xai-BwhzoehX.js";
11
11
  import { openai } from "./providers/openai.js";
12
12
  import { openrouter } from "./providers/openrouter.js";
13
- import { d as StartUsageError, f as buildStartLocalOptions, h as startProviderNames, i as withAcpDefaultTools, m as startLocalArgOptions, p as parseStartArgValues, t as runAcpStdioServer } from "./acp-CNZqD1Fw.js";
14
- import { f as credKeyOf, i as readCredentials, l as BUILTIN_PROVIDERS, r as credentialsPath, t as detectAuth, y as modelsForDescriptor } from "./auth-DIT_DMwa.js";
13
+ import { d as StartUsageError, f as buildStartLocalOptions, h as startProviderNames, i as withAcpDefaultTools, m as startLocalArgOptions, p as parseStartArgValues, t as runAcpStdioServer } from "./acp-GV1rqO6S.js";
14
+ import { f as credKeyOf, i as readCredentials, l as BUILTIN_PROVIDERS, r as credentialsPath, t as detectAuth, y as modelsForDescriptor } from "./auth-C4YPRDN4.js";
15
15
  import { createDaytonaProvider } from "./contexts/daytona.js";
16
16
  import { createDockerContext } from "./contexts/docker.js";
17
17
  import { createE2BProvider } from "./contexts/e2b.js";
package/dist/acp.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Li as AgentOptions, Md as AgentBehavior, Pf as TurnUsage, Pi as Agent, Tf as ToolResultContent, em as Provider, if as PromptPart, pf as SessionContentBlock, qd as McpServerConfig, rp as Session, sp as SessionStore, t as Preset, zf as ToolDef } from "./index-AVZ6pYpi.js";
1
+ import { Li as AgentOptions, Md as AgentBehavior, Pf as TurnUsage, Pi as Agent, Tf as ToolResultContent, am as Provider, if as PromptPart, pf as SessionContentBlock, qd as McpServerConfig, rp as Session, sp as SessionStore, t as Preset, zf as ToolDef } from "./index-DzQyRZ8Q.js";
2
2
  import { c as ExecutionContext } from "./types-BDccavwj.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-CNZqD1Fw.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-GV1rqO6S.js";
2
2
  export { AcpProtocolError, JsonRpcRemoteError, acpMcpServersToZidane, acpPromptToPromptParts, createAcpServer, createJsonRpcConnection, runAcpStdioServer, sessionBlocksToAcp, stopReasonFromRun, toolResultToAcpContent, withAcpDefaultTools, wrapToolsForAcpClient };
@@ -7,18 +7,18 @@ import { t as buildContextBreakdown } from "./context-breakdown-Dzo25N45.js";
7
7
  import { a as formatDuration, c as previewLine, o as formatTaskStatus, s as formatTaskSummary } from "./format-BF745pLL.js";
8
8
  import { i as parseGitLsFiles, r as GIT_LS_FILES_COMMAND } from "./glob-DluQFSw1.js";
9
9
  import { n as alwaysQuote, r as shellQuote } from "./exec-file-size-PXkr-MGA.js";
10
- import { i as isOutputExceededMessage } from "./output-cap-DM1HrgIp.js";
11
- import { r as createProcessContext, t as resolveDetachedTasksCapability } from "./contexts-0rmrBhTK.js";
10
+ import { i as isOutputExceededMessage } from "./output-cap-C9zukcCj.js";
11
+ import { r as createProcessContext, t as resolveDetachedTasksCapability } from "./contexts-Bq904_Gm.js";
12
12
  import { i as AgentProviderError, l as errorMessage, m as toTypedError, n as AgentBudgetExceededError, o as AgentToolPairingError, t as AgentAbortedError, u as isAbortLikeError } from "./errors-DJUxZg9b.js";
13
13
  import { C as stripShellInterpolations, O as validateResourcePathReal, S as interpolateShellCommands, _ as lastLine, b as resolveSubdirRoot, d as installAllowedToolsGate, f as createSkillActivationState, g as fetchInstallSource, h as defaultWhich, j as projectUserPaths, l as buildCatalog, m as defaultExec, p as InstallSourceError, t as resolveSkills, v as parseInstallSource, x as escapeXml, y as resolveNpmVersion } from "./resolve-BPTA1RpX.js";
14
14
  import { n as writeFileAtomicAsync, t as writeFileAtomic } from "./atomic-write-B7zr1ddF.js";
15
15
  import { r as createLogger, t as consoleSink } from "./logger-DBX9uYOw.js";
16
16
  import { n as reconcileImageMediaType } from "./media-sniff-Bn76JxAu.js";
17
- import { c as wrapDiscoveredMcpTools, i as nonOwningMcpView, n as connectMcpServers, r as deriveMcpToolMeta } from "./mcp-H6bqyM94.js";
17
+ import { n as connectMcpServers, o as nonOwningMcpView, r as deriveMcpToolMeta, u as wrapDiscoveredMcpTools } from "./mcp-Ct5tF4oj.js";
18
18
  import { C as canonicalizePrompt, S as buildPromptMessage } from "./openai-compat-pHI0kBWH.js";
19
19
  import { appendStaticSection, renderSystemForWire } from "./prompt.js";
20
- import { a as detectTurnInterruption, c as filterUnresolvedToolUses, d as remintDuplicateToolCallIds, f as resolveContentRefsInMessages, n as SYNTHETIC_TOOL_RESULT_PLACEHOLDER, o as ensureEndsWithUserMessage, s as ensureToolResultPairing } from "./messages-CvHfYB7f.js";
21
- import { a as getExtensionSessionState, c as setExtensionSessionState, l as withExtensionSession, n as currentExtensionSession, r as deleteExtensionSessionState, s as resumeChainRunIds } from "./session-jLsc_kMH.js";
20
+ import { a as detectTurnInterruption, c as filterUnresolvedToolUses, f as remintDuplicateToolCallIds, n as SYNTHETIC_TOOL_RESULT_PLACEHOLDER, o as ensureEndsWithUserMessage, p as resolveContentRefsInMessages, s as ensureToolResultPairing } from "./messages-Dy9t7DbQ.js";
21
+ import { a as getExtensionSessionState, c as setExtensionSessionState, l as withExtensionSession, n as currentExtensionSession, r as deleteExtensionSessionState, s as resumeChainRunIds } from "./session-DkVnYGm9.js";
22
22
  import { n as flattenTurns, r as formatTokenUsage, t as effectiveInputFromTurn } from "./stats-DAKBEKjc.js";
23
23
  import { a as withInactivityTimeout, i as settleWithinTimeout, n as linkAbortSignal, o as withTimeout$1, r as resolveTimeoutMs, t as OperationTimeoutError } from "./timeout-BDetbuN6.js";
24
24
  import { createRequire } from "node:module";
@@ -9495,7 +9495,14 @@ async function releaseReplacedTurnContent(turns, replacedTurnIds, opts) {
9495
9495
  };
9496
9496
  if (replacedTurnIds.size === 0 || !isAbsolute(opts.persistDir)) return result;
9497
9497
  const minBytes = opts.minBytes ?? 2048;
9498
+ const maxDirBytes = opts.maxDirBytes ?? 268435456;
9498
9499
  const blobDir = join(opts.persistDir, RELEASED_BLOB_SUBDIR);
9500
+ let dirBytes = 0;
9501
+ try {
9502
+ for (const entry of await readdir(blobDir)) try {
9503
+ dirBytes += (await stat(join(blobDir, entry))).size;
9504
+ } catch {}
9505
+ } catch {}
9499
9506
  const replaced = turns.filter((t) => t.id !== void 0 && replacedTurnIds.has(t.id));
9500
9507
  const toolNameByCallId = /* @__PURE__ */ new Map();
9501
9508
  for (const turn of replaced) for (const block of turn.content) if (block.type === "tool_call") toolNameByCallId.set(block.id, block.name);
@@ -9517,10 +9524,14 @@ async function releaseReplacedTurnContent(turns, replacedTurnIds, opts) {
9517
9524
  } catch {
9518
9525
  exists = false;
9519
9526
  }
9520
- if (!exists) try {
9521
- await writeAtomic(persistedPath, text);
9522
- } catch {
9523
- continue;
9527
+ if (!exists) {
9528
+ if (dirBytes + bytes > maxDirBytes) continue;
9529
+ try {
9530
+ await writeAtomic(persistedPath, text);
9531
+ dirBytes += bytes;
9532
+ } catch {
9533
+ continue;
9534
+ }
9524
9535
  }
9525
9536
  turn.content[i] = {
9526
9537
  ...block,
@@ -10805,7 +10816,8 @@ function wrapProviderError(err, ctx) {
10805
10816
  function providerWatchdogTimeouts(ctx) {
10806
10817
  return {
10807
10818
  startTimeoutMs: resolveTimeoutMs(ctx.providerStreamStartTimeoutMs, DEFAULT_PROVIDER_STREAM_START_TIMEOUT_MS, ctx.maxWallMs),
10808
- totalTimeoutMs: resolveTimeoutMs(ctx.providerStreamTimeoutMs, DEFAULT_PROVIDER_STREAM_TIMEOUT_MS, ctx.maxWallMs)
10819
+ totalTimeoutMs: resolveTimeoutMs(ctx.providerStreamTimeoutMs, DEFAULT_PROVIDER_STREAM_TIMEOUT_MS, ctx.maxWallMs),
10820
+ idleTimeoutMs: resolveTimeoutMs(ctx.providerStreamIdleTimeoutMs, 0, ctx.maxWallMs)
10809
10821
  };
10810
10822
  }
10811
10823
  function stripInvalidAnthropicThinking(content) {
@@ -10830,10 +10842,15 @@ function stripInvalidAnthropicThinking(content) {
10830
10842
  };
10831
10843
  }
10832
10844
  /**
10833
- * Permanently quarantine historical Anthropic reasoning after the API proves
10834
- * its opaque signature is invalid. Runtime turns and the bound session are
10835
- * separate arrays on resume, so repair both; persist the session with its
10836
- * full turn set (including child runs invisible to the parent runtime).
10845
+ * Quarantine historical Anthropic reasoning after the API proves its opaque
10846
+ * signature is invalid. Runtime turns and the bound session are separate
10847
+ * arrays on resume, so repair both — IN MEMORY ONLY. Durable persistence
10848
+ * (`session.save()`) is deliberately deferred to the stream-settle boundary
10849
+ * in {@link streamWithWatchdogs}: this function runs inside the provider's
10850
+ * `stream()` call stack, where durable-execution hosts (e.g. Restate
10851
+ * journaling the provider call) cannot touch their context — an inline
10852
+ * save would silently no-op there and the session would re-poison on every
10853
+ * run.
10837
10854
  *
10838
10855
  * Turns minted by the CURRENT run are never touched: their signatures are
10839
10856
  * fresh (same account/model that is streaming right now), and Anthropic
@@ -10841,7 +10858,8 @@ function stripInvalidAnthropicThinking(content) {
10841
10858
  * stripping them would trade one 400 for another. An invalid signature is
10842
10859
  * by definition historical (prior run, prior account, or a session edit).
10843
10860
  */
10844
- async function repairInvalidAnthropicThinkingHistory(ctx, streamOptions, repair) {
10861
+ function repairInvalidAnthropicThinkingHistory(ctx, streamOptions, repair) {
10862
+ const turnIds = /* @__PURE__ */ new Set();
10845
10863
  let removed = 0;
10846
10864
  for (const turn of ctx.turns) {
10847
10865
  if (turn.runId === ctx.runId) continue;
@@ -10849,6 +10867,7 @@ async function repairInvalidAnthropicThinkingHistory(ctx, streamOptions, repair)
10849
10867
  if (scrubbed.removed === 0) continue;
10850
10868
  turn.content = scrubbed.content;
10851
10869
  removed += scrubbed.removed;
10870
+ if (turn.id !== void 0) turnIds.add(turn.id);
10852
10871
  }
10853
10872
  const limit = repair.wireMessageIndex;
10854
10873
  streamOptions.messages = streamOptions.messages.map((message, index) => {
@@ -10860,34 +10879,72 @@ async function repairInvalidAnthropicThinkingHistory(ctx, streamOptions, repair)
10860
10879
  } : message;
10861
10880
  });
10862
10881
  const session = ctx.session;
10863
- if (!session) return removed;
10882
+ if (!session) return {
10883
+ removed,
10884
+ turnIds
10885
+ };
10864
10886
  let sessionRemoved = 0;
10865
10887
  const sessionTurns = session.turns.map((turn) => {
10866
10888
  if (turn.runId === ctx.runId) return turn;
10867
10889
  const scrubbed = stripInvalidAnthropicThinking(turn.content);
10868
10890
  sessionRemoved += scrubbed.removed;
10891
+ if (scrubbed.removed > 0 && turn.id !== void 0) turnIds.add(turn.id);
10869
10892
  return scrubbed.removed > 0 ? {
10870
10893
  ...turn,
10871
10894
  content: scrubbed.content
10872
10895
  } : turn;
10873
10896
  });
10874
- if (sessionRemoved === 0 && removed === 0) return 0;
10897
+ if (sessionRemoved === 0 && removed === 0) return {
10898
+ removed: 0,
10899
+ turnIds
10900
+ };
10875
10901
  session.setTurns(sessionTurns);
10876
- try {
10877
- await session.save();
10902
+ return {
10903
+ removed: removed + sessionRemoved,
10904
+ turnIds
10905
+ };
10906
+ }
10907
+ /**
10908
+ * Flush a deferred thinking-signature repair at the stream-settle boundary:
10909
+ * persist the already-repaired session and fire the host-facing
10910
+ * `history:repair` hook. Runs OUTSIDE the provider call stack (safe for
10911
+ * journaled hosts) and on both stream outcomes — a scrubbed block is
10912
+ * invalid regardless of whether the retry ultimately succeeded, and
10913
+ * persisting prevents the next run from re-poisoning.
10914
+ */
10915
+ async function flushThinkingRepair(ctx, pending) {
10916
+ let persisted = false;
10917
+ if (ctx.session?.store) try {
10918
+ await ctx.session.save();
10919
+ persisted = true;
10878
10920
  } catch (err) {
10879
10921
  if (process.env.ZIDANE_DEBUG) process.stderr.write(`[zidane/loop] persisting thinking-signature repair failed: ${errorMessage(err)}\n`);
10880
10922
  }
10881
- return Math.max(removed, sessionRemoved);
10923
+ await settledHook(ctx, "hook history:repair", ctx.hooks.callHook("history:repair", {
10924
+ reason: "invalid-anthropic-thinking-signature",
10925
+ runId: ctx.runId,
10926
+ ...ctx.session ? { sessionId: ctx.session.id } : {},
10927
+ turnIds: [...pending.turnIds],
10928
+ removedBlocks: pending.removed,
10929
+ persisted
10930
+ }));
10882
10931
  }
10883
10932
  async function streamWithWatchdogs(ctx, options, callbacks, turnId, opts) {
10884
- let { startTimeoutMs, totalTimeoutMs } = providerWatchdogTimeouts(ctx);
10933
+ let { startTimeoutMs, totalTimeoutMs, idleTimeoutMs } = providerWatchdogTimeouts(ctx);
10885
10934
  if (opts?.startTimeoutCapMs !== void 0 && startTimeoutMs > 0) startTimeoutMs = Math.min(startTimeoutMs, opts.startTimeoutCapMs);
10886
10935
  const callerHistoryRepair = callbacks.onHistoryRepair;
10936
+ let pendingRepair;
10887
10937
  callbacks = {
10888
10938
  ...callbacks,
10889
10939
  async onHistoryRepair(repair) {
10890
- if (repair.type === "invalid-anthropic-thinking-signature") await repairInvalidAnthropicThinkingHistory(ctx, options, repair);
10940
+ if (repair.type === "invalid-anthropic-thinking-signature") {
10941
+ const result = repairInvalidAnthropicThinkingHistory(ctx, options, repair);
10942
+ if (result.removed > 0) if (pendingRepair === void 0) pendingRepair = result;
10943
+ else {
10944
+ pendingRepair.removed += result.removed;
10945
+ for (const id of result.turnIds) pendingRepair.turnIds.add(id);
10946
+ }
10947
+ }
10891
10948
  await callerHistoryRepair?.(repair);
10892
10949
  }
10893
10950
  };
@@ -10897,12 +10954,21 @@ async function streamWithWatchdogs(ctx, options, callbacks, turnId, opts) {
10897
10954
  let firstObserved = false;
10898
10955
  let startTimer;
10899
10956
  let totalTimer;
10957
+ let idleTimer;
10958
+ let onIdleTimeout;
10900
10959
  const cleanup = () => {
10901
10960
  if (startTimer) clearTimeout(startTimer);
10902
10961
  if (totalTimer) clearTimeout(totalTimer);
10962
+ if (idleTimer) clearTimeout(idleTimer);
10903
10963
  unlinkParentAbort();
10904
10964
  };
10965
+ const recordActivity = () => {
10966
+ if (idleTimeoutMs <= 0 || settled) return;
10967
+ if (idleTimer) clearTimeout(idleTimer);
10968
+ idleTimer = setTimeout(() => onIdleTimeout?.(), idleTimeoutMs);
10969
+ };
10905
10970
  const markFirstObserved = () => {
10971
+ recordActivity();
10906
10972
  if (firstObserved) return;
10907
10973
  firstObserved = true;
10908
10974
  if (startTimer) {
@@ -10948,11 +11014,11 @@ async function streamWithWatchdogs(ctx, options, callbacks, turnId, opts) {
10948
11014
  throw err;
10949
11015
  }
10950
11016
  streamPromise.catch(() => {});
10951
- return await new Promise((resolve, reject) => {
11017
+ const raced = new Promise((resolve, reject) => {
10952
11018
  const failTimeout = (kind, timeoutMs) => {
10953
11019
  if (settled) return;
10954
11020
  settled = true;
10955
- const err = new OperationTimeoutError(`provider ${kind}`, timeoutMs, `Provider stream timed out waiting for ${kind} after ${timeoutMs}ms (turn ${turnId}).`);
11021
+ const err = new OperationTimeoutError(`provider ${kind}`, timeoutMs, kind === "stream inactivity" ? `Provider stream timed out: no stream events for ${timeoutMs}ms (turn ${turnId}).` : `Provider stream timed out waiting for ${kind} after ${timeoutMs}ms (turn ${turnId}).`);
10956
11022
  attemptAbort.abort(err);
10957
11023
  cleanup();
10958
11024
  reject(err);
@@ -10961,6 +11027,7 @@ async function streamWithWatchdogs(ctx, options, callbacks, turnId, opts) {
10961
11027
  if (!firstObserved) failTimeout("first response", startTimeoutMs);
10962
11028
  }, startTimeoutMs);
10963
11029
  if (totalTimeoutMs > 0) totalTimer = setTimeout(failTimeout, totalTimeoutMs, "total stream", totalTimeoutMs);
11030
+ onIdleTimeout = () => failTimeout("stream inactivity", idleTimeoutMs);
10964
11031
  streamPromise.then((value) => {
10965
11032
  if (settled) return;
10966
11033
  settled = true;
@@ -10975,6 +11042,11 @@ async function streamWithWatchdogs(ctx, options, callbacks, turnId, opts) {
10975
11042
  reject(err);
10976
11043
  });
10977
11044
  });
11045
+ try {
11046
+ return await raced;
11047
+ } finally {
11048
+ if (pendingRepair !== void 0) await flushThinkingRepair(ctx, pendingRepair);
11049
+ }
10978
11050
  }
10979
11051
  /** Max bytes of provider error text inlined into the assistant turn placeholder. */
10980
11052
  const ERROR_PLACEHOLDER_MAX = 280;
@@ -11517,7 +11589,7 @@ async function executeTurn(ctx, turn, priorUsage) {
11517
11589
  const classified = !wasAborted ? ctx.provider.classifyError?.(caught) : null;
11518
11590
  const isRetryable = classified?.kind === "provider_error" && classified.retryable === true;
11519
11591
  const cleanSlate = currentText === "" && currentThinking === "";
11520
- const isStreamWatchdogTimeout = !wasAborted && caught instanceof OperationTimeoutError && (caught.operation === "provider first response" || caught.operation === "provider total stream");
11592
+ const isStreamWatchdogTimeout = !wasAborted && caught instanceof OperationTimeoutError && (caught.operation === "provider first response" || caught.operation === "provider total stream" || caught.operation === "provider stream inactivity");
11521
11593
  const canRetry = !wasAborted && (isRetryable || isStreamWatchdogTimeout) && cleanSlate && attempt < retryCfg.maxAttempts;
11522
11594
  const retryAfterMs = canRetry ? extractRetryAfterMs(caught) : void 0;
11523
11595
  const hasNextTarget = ctx.targets !== void 0 && (ctx.activeTargetIndex ?? 0) + 1 < ctx.targets.length;
@@ -13244,6 +13316,7 @@ const HOOK_EVENT_SET = /* @__PURE__ */ new Set([
13244
13316
  "compact:start",
13245
13317
  "compact:progress",
13246
13318
  "compact:end",
13319
+ "history:repair",
13247
13320
  "oauth:refresh",
13248
13321
  "content-ref:resolve",
13249
13322
  "tool:gate",
@@ -13402,6 +13475,7 @@ function resolveBehavior(agentBehavior, runBehavior) {
13402
13475
  maxWallMs: runBehavior?.maxWallMs ?? agentBehavior?.maxWallMs,
13403
13476
  providerStreamStartTimeoutMs: runBehavior?.providerStreamStartTimeoutMs ?? agentBehavior?.providerStreamStartTimeoutMs,
13404
13477
  providerStreamTimeoutMs: runBehavior?.providerStreamTimeoutMs ?? agentBehavior?.providerStreamTimeoutMs,
13478
+ providerStreamIdleTimeoutMs: runBehavior?.providerStreamIdleTimeoutMs ?? agentBehavior?.providerStreamIdleTimeoutMs,
13405
13479
  mcpConnectTimeoutMs: runBehavior?.mcpConnectTimeoutMs ?? agentBehavior?.mcpConnectTimeoutMs,
13406
13480
  hookTimeoutMs: runBehavior?.hookTimeoutMs ?? agentBehavior?.hookTimeoutMs,
13407
13481
  spawnTimeoutMs: runBehavior?.spawnTimeoutMs ?? agentBehavior?.spawnTimeoutMs,
@@ -14309,7 +14383,7 @@ function createAgent(rawOptions) {
14309
14383
  const thinking = options.thinking ?? "off";
14310
14384
  const model = targets[0].model;
14311
14385
  if (runProvider.meta?.clearsContextServerSide) resolvedBehavior.dedupReads = false;
14312
- const { maxConcurrentTools, toolBatchExecutor, toolBatchTimeoutMs, shouldRethrowToolError, maxTurns, maxTurnsWarning, maxTurnsWarningMessage, maxCostUsd, maxTotalTokens, maxWallMs, providerStreamStartTimeoutMs, providerStreamTimeoutMs, maxTokens, retry, thinkingBudget, taskBudget, thinkingOverrunPolicy, modelOptions: behaviorModelOptions, schema, cache, toolOutputBudget, toolOutputBudgetExcludeTools, compactStrategy, compactThreshold, compactKeepTurns, thinkingDecay, writeFileExistingPolicy, textToolCallRescue, unknownToolRecovery, progressNudges, dedupTools, toolBudgets, repeatGuard, elideStaleReads, mediaKeepTurns, autoCompact, toolDisclosure, mcpToolNameSeparator, toolSearch, surfaceMcpInstructions, persistThreshold, persistExcludeTools, persistDir, persistMaxBytes, strictToolPairing, maxPairingRepairsPerTurn, maxConsecutivePauseTurns, resumeOnMaxTokens, persistTurns } = resolvedBehavior;
14386
+ const { maxConcurrentTools, toolBatchExecutor, toolBatchTimeoutMs, shouldRethrowToolError, maxTurns, maxTurnsWarning, maxTurnsWarningMessage, maxCostUsd, maxTotalTokens, maxWallMs, providerStreamStartTimeoutMs, providerStreamTimeoutMs, providerStreamIdleTimeoutMs, maxTokens, retry, thinkingBudget, taskBudget, thinkingOverrunPolicy, modelOptions: behaviorModelOptions, schema, cache, toolOutputBudget, toolOutputBudgetExcludeTools, compactStrategy, compactThreshold, compactKeepTurns, thinkingDecay, writeFileExistingPolicy, textToolCallRescue, unknownToolRecovery, progressNudges, dedupTools, toolBudgets, repeatGuard, elideStaleReads, mediaKeepTurns, autoCompact, toolDisclosure, mcpToolNameSeparator, toolSearch, surfaceMcpInstructions, persistThreshold, persistExcludeTools, persistDir, persistMaxBytes, strictToolPairing, maxPairingRepairsPerTurn, maxConsecutivePauseTurns, resumeOnMaxTokens, persistTurns } = resolvedBehavior;
14313
14387
  const modelOptions = options.modelOptions ?? behaviorModelOptions;
14314
14388
  let system = options.system || agentSystem || "You are a helpful assistant.";
14315
14389
  const baseSystemForBreakdown = renderSystemForWire(system);
@@ -14735,6 +14809,7 @@ function createAgent(rawOptions) {
14735
14809
  ...maxWallMs !== void 0 ? { maxWallMs } : {},
14736
14810
  ...providerStreamStartTimeoutMs !== void 0 ? { providerStreamStartTimeoutMs } : {},
14737
14811
  ...providerStreamTimeoutMs !== void 0 ? { providerStreamTimeoutMs } : {},
14812
+ ...providerStreamIdleTimeoutMs !== void 0 ? { providerStreamIdleTimeoutMs } : {},
14738
14813
  ...resolvedBehavior.hookTimeoutMs !== void 0 ? { hookTimeoutMs: resolvedBehavior.hookTimeoutMs } : {},
14739
14814
  ...retry !== void 0 ? { retry } : {},
14740
14815
  maxTokens,
@@ -15353,4 +15428,4 @@ function createAgent(rawOptions) {
15353
15428
  //#endregion
15354
15429
  export { buildExtensionRegistry as $, defaultExtensionScanPaths as $t, buildUpToCompactPrompt as A, listFiles as At, createExtensionPromptBridge as B, KEYBINDING_KEY_COL_WIDTH as Bt, BASE_INSTRUCTIONS as C, tailTruncate as Ct, buildFromCompactPrompt as D, createModelSearchTool as Dt, buildCompactPrompt as E, multiEdit as Et, summaryToTurn as F, validateToolArgs as Ft, parseExtensionInstallSource as G, matchesBinding as Gt, fetchExtensionSource as H, formatBindingForDisplay as Ht, truncateHeadForPtlRetry as I, resolveStorageDirs as It, updateInstalledExtension as J, readKeybindings as Jt, readExtensionInstallProvenance as K, mergeKeybindings as Kt, CompactInvalidInputError as L, DEFAULT_KEYBINDINGS as Lt, anchorPreviewFor as M, grep as Mt, sliceForCompaction as N, glob as Nt, buildFullCompactPrompt as O, formatModelLine as Ot, stripImagesFromTurns as P, edit as Pt, buildExtensionPreset as Q, ENTRY_CANDIDATES as Qt, CompactPromptTooLongError as R, KEYBINDING_DEFS as Rt, compactConversation as S, shell as St, TRAILER as T, looksBinary as Tt, installExtensionFromSpec as U, groupBindings as Ut, ExtensionInstallError as V, ensureKeybindingsFile as Vt, listExtensionCandidates as W, keybindingsPath as Wt, registerExtensionHostModules as X, resolveExtensionKeybindings as Xt, createExtensionHud as Y, readKeybindingsRaw as Yt, discoverAndBuildExtensionRegistry as Z, stripJsonComments as Zt, resolveTasksDir as _, shouldAutoCompact as _n, createSkillsUseTool as _t, SHELL_CASCADE_CANCEL_MESSAGE as a, defineExtension as an, createExtensionHostRuntimeBridge as at, selectFilesFromSession as b, normalizeShellCommand as bn, shellKill as bt, applyCompactSummaryCutoff as c, isValidExtensionConfigItem as cn, definePreset as ct, buildPersistedStub as d, resolveExtensionConfigValue as dn, writeFile$1 as dt, discoverExtensions as en, composeExtensionPreset as et, cleanupPersistedSession as f, sanitizeExtensionConfigActionPatch as fn, WAIT_TASK_TIMED_OUT_PREFIX as ft, resolvePersistDir as g, effectiveContextWindow as gn, isSpawnTool as gt, resolveMcpWarningsDir as h, OUTPUT_RESERVE_TOKENS as hn, createSpawnTool as ht, INTERRUPT_MESSAGE_FOR_TOOL_USE as i, scanExtensionDirectories as in, partitionExtensionCatalog as it, ANCHOR_PREVIEW_MAX_CHARS as j, createInteractionTool as jt, buildTailCompactPrompt as k, matchModelEntries as kt, PERSISTED_STUB_PREFIX as l, isValidExtensionConfigValue as ln, basicTools as lt, rehomePersistedStubs as m, AUTO_COMPACT_MIN_GROWTH_FRACTION as mn, createToolSearchTool as mt, normalizeProviders as n, isExtensionDefinition as nn, filterExtensionRegistry as nt, TOOL_USE_CANCELLED_MESSAGE as o, clampExtensionConfigNumber as on, createWorkspaceSurface as ot, maybePersistToolResult as p, toWireConfigSchema as pn, waitTask as pt, removeInstalledExtension as q, parseBindingSpec as qt, resolveModelTargets as r, parseExtensionScanPathEnv as rn, mergeContributions as rt, TOOL_USE_SKIPPED_MESSAGE as s, coerceExtensionConfigInput as sn, composePresets as st, createAgent as t, inlineLoadedExtension as tn, disposeExtensionRegistry as tt, PERSISTENCE_PREVIEW_BYTES as u, resolveExtensionConfig as un, basic_default as ut, buildPostCompactAttachments as v, defaultRepeatGuardNormalize as vn, createSkillsRunScriptTool as vt, NO_TOOLS_PREAMBLE as w, readFile$1 as wt, selectRecentFiles as x, stableStringify as xn, createShellTool as xt, selectFilesFromReadState as y, defaultRepeatGuardTracked as yn, createSkillsReadTool as yt, EMPTY_EXTENSION_REGISTRY as z, KEYBINDING_DEF_BY_ACTION as zt };
15355
15430
 
15356
- //# sourceMappingURL=agent--VPMZ0nT.js.map
15431
+ //# sourceMappingURL=agent--qDjL0fH.js.map