zidane 6.2.21 → 6.2.23

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 (78) hide show
  1. package/dist/{acp-BqnSn-gl.js → acp-B7wH6LhE.js} +3 -3
  2. package/dist/{acp-BqnSn-gl.js.map → acp-B7wH6LhE.js.map} +1 -1
  3. package/dist/acp-cli.js +2 -2
  4. package/dist/acp.d.ts +1 -1
  5. package/dist/acp.js +1 -1
  6. package/dist/{agent-BJLSgHAS.js → agent-BSIMsEtD.js} +126 -15
  7. package/dist/agent-BSIMsEtD.js.map +1 -0
  8. package/dist/agent.d.ts +1 -1
  9. package/dist/agent.js +1 -1
  10. package/dist/chat/pure.d.ts +3 -3
  11. package/dist/chat.d.ts +21 -5
  12. package/dist/chat.d.ts.map +1 -1
  13. package/dist/chat.js +3 -3
  14. package/dist/contexts/daytona.d.ts +1 -1
  15. package/dist/contexts/e2b.d.ts +1 -1
  16. package/dist/eval.d.ts +1 -1
  17. package/dist/eval.js +1 -1
  18. package/dist/extensions.d.ts +1 -1
  19. package/dist/extensions.js +1 -1
  20. package/dist/headless.d.ts +1 -1
  21. package/dist/headless.js +2 -2
  22. package/dist/{index-BRxJUFyo.d.ts → index-Bv9qhj4n.d.ts} +69 -1
  23. package/dist/index-Bv9qhj4n.d.ts.map +1 -0
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.js +5 -5
  26. package/dist/{login-BvGRBGaY.js → login-BkZ_d5sT.js} +2 -2
  27. package/dist/{login-BvGRBGaY.js.map → login-BkZ_d5sT.js.map} +1 -1
  28. package/dist/mcp.d.ts +1 -1
  29. package/dist/output/stream-json.d.ts +1 -1
  30. package/dist/output/terminal.d.ts +1 -1
  31. package/dist/presets.d.ts +1 -1
  32. package/dist/presets.js +1 -1
  33. package/dist/providers/anthropic.d.ts +1 -1
  34. package/dist/providers/arcee.d.ts +1 -1
  35. package/dist/providers/baseten.d.ts +1 -1
  36. package/dist/providers/cerebras.d.ts +1 -1
  37. package/dist/providers/local.d.ts +1 -1
  38. package/dist/providers/openai-compat.d.ts +1 -1
  39. package/dist/providers/openai.d.ts +1 -1
  40. package/dist/providers/openrouter.d.ts +1 -1
  41. package/dist/providers/xai.d.ts +1 -1
  42. package/dist/providers.d.ts +1 -1
  43. package/dist/{resolve-R3VDQMT3.js → resolve-x5mlFtLX.js} +4 -3
  44. package/dist/resolve-x5mlFtLX.js.map +1 -0
  45. package/dist/restate.d.ts +1 -1
  46. package/dist/session/sqlite.d.ts +1 -1
  47. package/dist/{session-DzrXKLw-.js → session-Dbvz1ZUE.js} +3 -2
  48. package/dist/session-Dbvz1ZUE.js.map +1 -0
  49. package/dist/session.d.ts +1 -1
  50. package/dist/session.js +1 -1
  51. package/dist/{skills-6_Z49T6p.js → skills-C1vGKbqv.js} +2 -2
  52. package/dist/{skills-6_Z49T6p.js.map → skills-C1vGKbqv.js.map} +1 -1
  53. package/dist/skills.d.ts +1 -1
  54. package/dist/skills.js +2 -2
  55. package/dist/{tool-formatters-Dokpl_jU.d.ts → tool-formatters-D9P6Znip.d.ts} +2 -2
  56. package/dist/{tool-formatters-Dokpl_jU.d.ts.map → tool-formatters-D9P6Znip.d.ts.map} +1 -1
  57. package/dist/tools/fetch-url.d.ts +1 -1
  58. package/dist/tools/web-search.d.ts +1 -1
  59. package/dist/tools.d.ts +1 -1
  60. package/dist/tools.js +1 -1
  61. package/dist/{transcript-anchors-5wRP7hln.d.ts → transcript-anchors-Ci5888xS.d.ts} +18 -4
  62. package/dist/{transcript-anchors-5wRP7hln.d.ts.map → transcript-anchors-Ci5888xS.d.ts.map} +1 -1
  63. package/dist/{transcript-anchors-QeMjbphJ.js → transcript-anchors-CqzIr74w.js} +260 -22
  64. package/dist/transcript-anchors-CqzIr74w.js.map +1 -0
  65. package/dist/tui.d.ts +11 -3
  66. package/dist/tui.d.ts.map +1 -1
  67. package/dist/tui.js +892 -106
  68. package/dist/tui.js.map +1 -1
  69. package/dist/{turn-operations-D96guhSq.d.ts → turn-operations-C3y6A82G.d.ts} +3 -3
  70. package/dist/{turn-operations-D96guhSq.d.ts.map → turn-operations-C3y6A82G.d.ts.map} +1 -1
  71. package/dist/types-BIarq1qE.js.map +1 -1
  72. package/dist/types.d.ts +1 -1
  73. package/package.json +1 -1
  74. package/dist/agent-BJLSgHAS.js.map +0 -1
  75. package/dist/index-BRxJUFyo.d.ts.map +0 -1
  76. package/dist/resolve-R3VDQMT3.js.map +0 -1
  77. package/dist/session-DzrXKLw-.js.map +0 -1
  78. package/dist/transcript-anchors-QeMjbphJ.js.map +0 -1
package/dist/acp-cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { Ft as resolveStorageDirs, lt as basic_default } from "./agent-BJLSgHAS.js";
2
+ import { Ft as resolveStorageDirs, lt as basic_default } from "./agent-BSIMsEtD.js";
3
3
  import { r as createProcessContext } from "./contexts-A4ep-iJs.js";
4
4
  import { createSandboxContext } from "./contexts/sandbox.js";
5
5
  import { m as openaiCompat } from "./openai-compat-pHI0kBWH.js";
@@ -10,7 +10,7 @@ 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-BqnSn-gl.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-B7wH6LhE.js";
14
14
  import { f as credKeyOf, i as readCredentials, l as BUILTIN_PROVIDERS, r as credentialsPath, t as detectAuth, y as modelsForDescriptor } from "./auth-CpdQebUy.js";
15
15
  import { createDaytonaProvider } from "./contexts/daytona.js";
16
16
  import { createDockerContext } from "./contexts/docker.js";
package/dist/acp.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $p as Provider, Li as AgentOptions, Md as AgentBehavior, Pf as TurnUsage, Pi as Agent, Tf as ToolResultContent, if as PromptPart, pf as SessionContentBlock, qd as McpServerConfig, rp as Session, sp as SessionStore, t as Preset, zf as ToolDef } from "./index-BRxJUFyo.js";
1
+ import { $p as Provider, Li as AgentOptions, Md as AgentBehavior, Pf as TurnUsage, Pi as Agent, Tf as ToolResultContent, if as PromptPart, pf as SessionContentBlock, qd as McpServerConfig, rp as Session, sp as SessionStore, t as Preset, zf as ToolDef } from "./index-Bv9qhj4n.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-BqnSn-gl.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-B7wH6LhE.js";
2
2
  export { AcpProtocolError, JsonRpcRemoteError, acpMcpServersToZidane, acpPromptToPromptParts, createAcpServer, createJsonRpcConnection, runAcpStdioServer, sessionBlocksToAcp, stopReasonFromRun, toolResultToAcpContent, withAcpDefaultTools, wrapToolsForAcpClient };
@@ -9,7 +9,7 @@ import { c as parseGitLsFiles, r as isOutputExceededMessage, s as GIT_LS_FILES_C
9
9
  import { n as alwaysQuote, r as shellQuote } from "./exec-file-size-PXkr-MGA.js";
10
10
  import { r as createProcessContext, t as resolveDetachedTasksCapability } from "./contexts-A4ep-iJs.js";
11
11
  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";
12
- 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-R3VDQMT3.js";
12
+ 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-x5mlFtLX.js";
13
13
  import { n as writeFileAtomicAsync, t as writeFileAtomic } from "./atomic-write-B7zr1ddF.js";
14
14
  import { r as createLogger, t as consoleSink } from "./logger-DBX9uYOw.js";
15
15
  import { n as reconcileImageMediaType } from "./media-sniff-Bn76JxAu.js";
@@ -18,7 +18,7 @@ import { n as flattenTurns, r as formatTokenUsage, t as effectiveInputFromTurn }
18
18
  import { C as canonicalizePrompt, S as buildPromptMessage } from "./openai-compat-pHI0kBWH.js";
19
19
  import { appendStaticSection, renderSystemForWire } from "./prompt.js";
20
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 withExtensionSession, n as currentExtensionSession, r as deleteExtensionSessionState, s as setExtensionSessionState } from "./session-DzrXKLw-.js";
21
+ import { a as getExtensionSessionState, c as withExtensionSession, n as currentExtensionSession, r as deleteExtensionSessionState, s as setExtensionSessionState } from "./session-Dbvz1ZUE.js";
22
22
  import { a as withInactivityTimeout, i as settleWithinTimeout, n as linkAbortSignal, o as withTimeout$1, r as resolveTimeoutMs, t as OperationTimeoutError } from "./timeout-BDetbuN6.js";
23
23
  import { createRequire } from "node:module";
24
24
  import { basename, delimiter, dirname, isAbsolute, join, resolve, sep } from "node:path";
@@ -4878,6 +4878,21 @@ const CHILD_MUTABLE_EVENT_NAME = {
4878
4878
  "tool:transform": "child:tool:transform"
4879
4879
  };
4880
4880
  const sessionChildCounters = /* @__PURE__ */ new WeakMap();
4881
+ /** Chronological child runs (depth > 0) — index + 1 is the `child-N` label. */
4882
+ function childRunsOf(session) {
4883
+ return session.runs.filter((r) => (r.depth ?? 0) > 0);
4884
+ }
4885
+ /**
4886
+ * Human/model-facing list of this session's child runs, labeled the same
4887
+ * way `reserveChildLabel` numbers them (chronological order of depth > 0
4888
+ * runs). Rendered into resume-rejection messages so the model can
4889
+ * self-correct with a valid label.
4890
+ */
4891
+ function describeChildRuns(session) {
4892
+ const childRuns = childRunsOf(session);
4893
+ if (childRuns.length === 0) return "No child runs exist in this session.";
4894
+ return childRuns.map((r, i) => `- child-${i + 1} · ${r.status} · ${r.prompt.slice(0, 80)}`).join("\n");
4895
+ }
4881
4896
  function reserveChildLabel(session) {
4882
4897
  let counter = sessionChildCounters.get(session);
4883
4898
  if (counter === void 0) counter = session.runs.filter((r) => (r.depth ?? 0) > 0).length;
@@ -4966,6 +4981,16 @@ function nonOwningMcpConnector(connection) {
4966
4981
  * would re-bootstrap every server and reopen the bypass this exists
4967
4982
  * to close. Instructions are trimmed to servers that still contribute
4968
4983
  * a tool.
4984
+ *
4985
+ * CONTRACT CAVEAT — configless parents: the child only invokes its
4986
+ * connector when its own `mcpServers` list is non-empty (`agent.ts` gates
4987
+ * every connect path on config count; pinned by `test/mcp.test.ts`
4988
+ * "connector + zero configs → no connect"). So a parent with a live
4989
+ * `ctx.mcpConnection` but an absent/empty `ctx.mcpServers` hands down a
4990
+ * connector that never fires — the child gets NO MCP tools, allowlisted
4991
+ * or not. Hosts sharing a connection must pass the matching transformed
4992
+ * config list alongside it (`agent.mcpServers` — see the command-spawn
4993
+ * seam in the TUI).
4969
4994
  */
4970
4995
  function inheritedMcpForSubagent(ctx, def) {
4971
4996
  const explicit = def?.tools;
@@ -5203,6 +5228,10 @@ function buildSpawnTool(options, state) {
5203
5228
  type: "string",
5204
5229
  description: buildModelFieldDescription(modelCatalog)
5205
5230
  } } : {};
5231
+ const resumeProperty = options.persist ? { resume: {
5232
+ type: "string",
5233
+ description: "Child label of a prior stopped/failed sub-agent to resume (e.g. \"child-2\", as reported in its result header). The new run is seeded with that child's full prior conversation; `task` becomes the continuation instruction instead of a fresh task. Only terminal children (aborted / timed out / errored / completed) can be resumed."
5234
+ } } : {};
5206
5235
  const tool = {
5207
5236
  maxConcurrent,
5208
5237
  get children() {
@@ -5235,7 +5264,7 @@ function buildSpawnTool(options, state) {
5235
5264
  isConcurrencySafe: true,
5236
5265
  spec: {
5237
5266
  name: "spawn",
5238
- description: `Spawn a sub-agent for a self-contained task that benefits from isolation (separate context window, separate retries) — for example, a deep research dive or a long codegen pass on a specific file. The sub-agent inherits your tool set (including \`spawn\` itself, depth-capped) and your system prompt unless overridden, runs independently, and returns its final response. Do NOT spawn for sequential steps you could do yourself.${modelCatalog ? " Children can run on a DIFFERENT model via the `model` field — cost-tier your delegation: mechanical, parallelizable, or high-volume search work belongs on cheaper/faster models, while synthesis and judgment stay on your own model." : ""}`,
5267
+ description: `Spawn a sub-agent for a self-contained task that benefits from isolation (separate context window, separate retries) — for example, a deep research dive or a long codegen pass on a specific file. The sub-agent inherits your tool set (including \`spawn\` itself, depth-capped) and your system prompt unless overridden, runs independently, and returns its final response. Do NOT spawn for sequential steps you could do yourself.${modelCatalog ? " Children can run on a DIFFERENT model via the `model` field — cost-tier your delegation: mechanical, parallelizable, or high-volume search work belongs on cheaper/faster models, while synthesis and judgment stay on your own model." : ""}${options.persist ? " A stopped or failed sub-agent can be CONTINUED instead of restarted: pass `resume` with its child label (e.g. \"child-2\") and put the continuation instruction in `task` — the child picks up with its prior conversation intact." : ""}`,
5239
5268
  inputSchema: {
5240
5269
  type: "object",
5241
5270
  properties: {
@@ -5248,7 +5277,8 @@ function buildSpawnTool(options, state) {
5248
5277
  description: "Optional system prompt override for this specific sub-agent. REPLACES the entire inherited system prompt — identity, doctrine, and environment info (cwd, platform, date) are all lost. Prefer omitting this and putting specialization in `task`; if you do override, restate the working directory and any constraints the child must keep."
5249
5278
  },
5250
5279
  ...subagentTypeProperty,
5251
- ...modelProperty
5280
+ ...modelProperty,
5281
+ ...resumeProperty
5252
5282
  },
5253
5283
  required: ["task"]
5254
5284
  }
@@ -5286,6 +5316,37 @@ function buildSpawnTool(options, state) {
5286
5316
  const inheritedModel = childProvider === ctx.provider ? ctx.model : void 0;
5287
5317
  const childModel = chosenModelId ?? inheritedModel;
5288
5318
  const announcedModel = childModel ?? childProvider.meta.defaultModel;
5319
+ let resumeRun;
5320
+ let resumeLabel;
5321
+ if (typeof input.resume === "string" && input.resume.trim() !== "") {
5322
+ const wanted = input.resume.trim();
5323
+ if (!options.persist || !ctx.session) return {
5324
+ status: "rejected",
5325
+ text: "",
5326
+ message: "Cannot resume: resuming a sub-agent requires the spawn tool to be configured with persist: true and the parent to have a session — no prior child turns are stored here."
5327
+ };
5328
+ const childRuns = childRunsOf(ctx.session);
5329
+ const labelMatch = /^child-(\d+)$/.exec(wanted);
5330
+ const index = labelMatch ? Number(labelMatch[1]) - 1 : childRuns.findIndex((r) => r.id === wanted);
5331
+ const run = index >= 0 ? childRuns[index] : void 0;
5332
+ if (!run) return {
5333
+ status: "rejected",
5334
+ text: "",
5335
+ message: `Cannot resume: no child run matches "${wanted}". Child runs in this session:\n${describeChildRuns(ctx.session)}`
5336
+ };
5337
+ if (run.status === "running") return {
5338
+ status: "rejected",
5339
+ text: "",
5340
+ message: `Cannot resume: child-${index + 1} is still running. Only terminal children (aborted / error / completed) can be resumed.`
5341
+ };
5342
+ if (!ctx.session.turns.some((t) => t.runId === run.id)) return {
5343
+ status: "rejected",
5344
+ text: "",
5345
+ message: `Cannot resume: child-${index + 1} has no persisted turns (it likely failed before producing anything). Spawn a fresh child with a full task instead.`
5346
+ };
5347
+ resumeRun = run;
5348
+ resumeLabel = `child-${index + 1}`;
5349
+ }
5289
5350
  const parentDepth = ctx.depth ?? 0;
5290
5351
  const childDepth = parentDepth + 1;
5291
5352
  if (childDepth > maxDepth) return {
@@ -5360,6 +5421,7 @@ function buildSpawnTool(options, state) {
5360
5421
  const spawnHookCtx = {
5361
5422
  id,
5362
5423
  task,
5424
+ ...resumeLabel !== void 0 ? { resumesChildId: resumeLabel } : {},
5363
5425
  depth: childDepth,
5364
5426
  model: announcedModel,
5365
5427
  provider: childProvider.name,
@@ -5376,6 +5438,7 @@ function buildSpawnTool(options, state) {
5376
5438
  signal: ctx.signal,
5377
5439
  depth: childDepth,
5378
5440
  ...options.persist && ctx.runId ? { parentRunId: ctx.runId } : {},
5441
+ ...resumeRun ? { resumeRunId: resumeRun.id } : {},
5379
5442
  ...propagatedTracing ? { tracingContext: propagatedTracing } : {}
5380
5443
  });
5381
5444
  try {
@@ -9892,6 +9955,23 @@ function applyMediaAgeout(messages, keep, options) {
9892
9955
  };
9893
9956
  }
9894
9957
  /**
9958
+ * Distinct `read_file` paths called inside the given turns (optionally
9959
+ * filtered to an id set). Canonical tool names — the alias rewrite is
9960
+ * wire-only, so session turns always carry `read_file` verbatim.
9961
+ */
9962
+ function readFilePathsInTurns(turns, ids) {
9963
+ const paths = /* @__PURE__ */ new Set();
9964
+ for (const turn of turns) {
9965
+ if (ids && !ids.has(turn.id)) continue;
9966
+ for (const block of turn.content) {
9967
+ if (block.type !== "tool_call" || block.name !== "read_file") continue;
9968
+ const path = block.input.path;
9969
+ if (typeof path === "string" && path.length > 0) paths.add(path);
9970
+ }
9971
+ }
9972
+ return [...paths];
9973
+ }
9974
+ /**
9895
9975
  * Build a call_id → file path map for `read_file` tool calls in `messages`.
9896
9976
  * Tail compaction uses it to learn which stubbed `tool_result`s were file
9897
9977
  * reads, so their read-state dedup can be invalidated. Resolve this from the
@@ -10536,8 +10616,9 @@ async function repairInvalidAnthropicThinkingHistory(ctx, streamOptions, repair)
10536
10616
  }
10537
10617
  return Math.max(removed, sessionRemoved);
10538
10618
  }
10539
- async function streamWithWatchdogs(ctx, options, callbacks, turnId) {
10540
- const { startTimeoutMs, totalTimeoutMs } = providerWatchdogTimeouts(ctx);
10619
+ async function streamWithWatchdogs(ctx, options, callbacks, turnId, opts) {
10620
+ let { startTimeoutMs, totalTimeoutMs } = providerWatchdogTimeouts(ctx);
10621
+ if (opts?.startTimeoutCapMs !== void 0 && startTimeoutMs > 0) startTimeoutMs = Math.min(startTimeoutMs, opts.startTimeoutCapMs);
10541
10622
  const callerHistoryRepair = callbacks.onHistoryRepair;
10542
10623
  callbacks = {
10543
10624
  ...callbacks,
@@ -10701,6 +10782,18 @@ const RETRY_DEFAULTS = {
10701
10782
  maxDelayMs: 3e4
10702
10783
  };
10703
10784
  /**
10785
+ * First-response watchdog cap for RETRY attempts (attempt ≥ 2). The first
10786
+ * attempt gets the full `providerStreamStartTimeoutMs` window (large-prompt
10787
+ * prefill legitimately takes a while on a cold request), but a healthy
10788
+ * re-issue — fired after backoff already waited out any declared
10789
+ * rate-limit window — either starts streaming quickly or is dead. Without
10790
+ * the cap, retrying watchdog timeouts multiplies worst-case silent latency
10791
+ * (3 × 5 min for the defaults) and a stuck provider blocks a whole /ticket
10792
+ * stage for that long. Only applied when the start watchdog is enabled —
10793
+ * an explicit `0` (disabled) stays disabled on retries too.
10794
+ */
10795
+ const RETRY_STREAM_START_TIMEOUT_CAP_MS = 12e4;
10796
+ /**
10704
10797
  * Reactive context-overflow recovery schedule. When a turn is rejected with
10705
10798
  * `context_exceeded` (pre-stream — the request was too big for the model's
10706
10799
  * window), the loop emergency-compacts older `tool_result` bodies via
@@ -10852,6 +10945,9 @@ async function maybeAutoCompact(ctx, turn, lastTurnUsage, state) {
10852
10945
  }
10853
10946
  ctx.turns.push(summaryTurn, ...restorationTurns);
10854
10947
  await ctx.persistTurns?.();
10948
+ const absorbedIds = /* @__PURE__ */ new Set([...result.summarizedTurnIds, ...result.droppedDueToPtl]);
10949
+ const onWireReads = new Set(readFilePathsInTurns(applyCompactSummaryCutoff(ctx.turns)));
10950
+ markReadStateForElidedPaths(ctx, ctx.handle.cwd, readFilePathsInTurns(ctx.turns, absorbedIds).filter((p) => !onWireReads.has(p)));
10855
10951
  const effectiveTokens = (result.usage.output ?? 0) + restorationTokens;
10856
10952
  state.lastCompactedInputTokens = effectiveTokens;
10857
10953
  state.consecutiveFailures = 0;
@@ -11141,7 +11237,7 @@ async function executeTurn(ctx, turn, priorUsage) {
11141
11237
  onOAuthRefresh(refreshCtx) {
11142
11238
  return ctx.hooks.callHook("oauth:refresh", refreshCtx);
11143
11239
  }
11144
- }, turnId);
11240
+ }, turnId, attempt > 1 ? { startTimeoutCapMs: RETRY_STREAM_START_TIMEOUT_CAP_MS } : void 0);
11145
11241
  break;
11146
11242
  } catch (caught) {
11147
11243
  let terminalErr = caught;
@@ -11149,7 +11245,8 @@ async function executeTurn(ctx, turn, priorUsage) {
11149
11245
  const classified = !wasAborted ? ctx.provider.classifyError?.(caught) : null;
11150
11246
  const isRetryable = classified?.kind === "provider_error" && classified.retryable === true;
11151
11247
  const cleanSlate = currentText === "" && currentThinking === "";
11152
- const canRetry = !wasAborted && isRetryable && cleanSlate && attempt < retryCfg.maxAttempts;
11248
+ const isStreamWatchdogTimeout = !wasAborted && caught instanceof OperationTimeoutError && (caught.operation === "provider first response" || caught.operation === "provider total stream");
11249
+ const canRetry = !wasAborted && (isRetryable || isStreamWatchdogTimeout) && cleanSlate && attempt < retryCfg.maxAttempts;
11153
11250
  const retryAfterMs = canRetry ? extractRetryAfterMs(caught) : void 0;
11154
11251
  const hasNextTarget = ctx.targets !== void 0 && (ctx.activeTargetIndex ?? 0) + 1 < ctx.targets.length;
11155
11252
  if (canRetry && !(retryAfterMs !== void 0 && retryAfterMs > LONG_RETRY_AFTER_FALLBACK_MS && hasNextTarget)) {
@@ -13841,6 +13938,11 @@ function createAgent(rawOptions) {
13841
13938
  const targets = resolveModelTargets(providers, options.model);
13842
13939
  const runProvider = targets[0].provider;
13843
13940
  const resumeFilteredTurns = validateAndPrepareResume(session, options.prompt, pendingTaskNotifications.size > 0);
13941
+ if (options.resumeRunId) {
13942
+ if (!session) throw new Error("resumeRunId requires a session (the prior run's turns live there)");
13943
+ if (!options.prompt) throw new Error("resumeRunId requires a prompt — pass the continuation instruction");
13944
+ if (!session.turns.some((t) => t.runId === options.resumeRunId)) throw new Error(`resumeRunId "${options.resumeRunId}" has no persisted turns in this session — nothing to resume`);
13945
+ }
13844
13946
  const clock = options.clock ?? agentClock ?? DEFAULT_AGENT_CLOCK;
13845
13947
  let externalAbortListener;
13846
13948
  const externalSignal = options.signal;
@@ -13860,7 +13962,8 @@ function createAgent(rawOptions) {
13860
13962
  const promptLabel = typeof options.prompt === "string" ? options.prompt : Array.isArray(options.prompt) ? options.prompt.filter((p) => p.type === "text").map((p) => p.text).join("\n") : "";
13861
13963
  session?.startRun(runId, promptLabel, {
13862
13964
  ...options.parentRunId ? { parentRunId: options.parentRunId } : {},
13863
- depth: typeof options.depth === "number" ? options.depth : 0
13965
+ depth: typeof options.depth === "number" ? options.depth : 0,
13966
+ ...options.resumeRunId ? { resumedFromRunId: options.resumeRunId } : {}
13864
13967
  });
13865
13968
  const sessionRun = session?.runs.find((r) => r.id === runId);
13866
13969
  if (sessionRun) sessionRun.startedAt = runStartedAt;
@@ -14086,15 +14189,20 @@ function createAgent(rawOptions) {
14086
14189
  });
14087
14190
  }
14088
14191
  const turns = [];
14089
- if (session && session.turns.length > 0 && (session.runs.length > 0 || !options.prompt) && !options.parentRunId) {
14192
+ const isResume = session && session.turns.length > 0 && (session.runs.length > 0 || !options.prompt) && !options.parentRunId && !options.resumeRunId;
14193
+ let seededTurns;
14194
+ if (options.resumeRunId && session) seededTurns = filterUnresolvedToolUses(session.turns.filter((t) => t.runId === options.resumeRunId));
14195
+ else if (isResume) {
14090
14196
  const childRunIds = childRunIdSet(session);
14091
14197
  const resumed = childRunIds.size === 0 ? session.turns : session.turns.filter((t) => !t.runId || !childRunIds.has(t.runId));
14092
- const filteredForRuntime = resumeFilteredTurns && resumed === session.turns ? resumeFilteredTurns : filterUnresolvedToolUses(resumed);
14093
- turns.push(...filteredForRuntime);
14198
+ seededTurns = resumeFilteredTurns && resumed === session.turns ? resumeFilteredTurns : filterUnresolvedToolUses(resumed);
14199
+ }
14200
+ if (seededTurns) {
14201
+ turns.push(...seededTurns);
14094
14202
  if (shouldInjectToolSearch && disclosure.lazyEntries.length > 0) {
14095
14203
  const resolvedCallIds = /* @__PURE__ */ new Set();
14096
- for (const turn of filteredForRuntime) for (const block of turn.content) if (block.type === "tool_result" && !block.isError) resolvedCallIds.add(block.callId);
14097
- for (const turn of filteredForRuntime) for (const block of turn.content) {
14204
+ for (const turn of seededTurns) for (const block of turn.content) if (block.type === "tool_result" && !block.isError) resolvedCallIds.add(block.callId);
14205
+ for (const turn of seededTurns) for (const block of turn.content) {
14098
14206
  if (block.type !== "tool_call") continue;
14099
14207
  if (block.name !== "tool_search") continue;
14100
14208
  if (!resolvedCallIds.has(block.id)) continue;
@@ -14933,6 +15041,9 @@ function createAgent(rawOptions) {
14933
15041
  get mcpConnection() {
14934
15042
  return mcpConnection;
14935
15043
  },
15044
+ get mcpServers() {
15045
+ return allMcpServers;
15046
+ },
14936
15047
  get turns() {
14937
15048
  return conversationTurns;
14938
15049
  },
@@ -14957,4 +15068,4 @@ function createAgent(rawOptions) {
14957
15068
  //#endregion
14958
15069
  export { composeExtensionPreset as $, discoverExtensions as $t, ANCHOR_PREVIEW_MAX_CHARS as A, createInteractionTool as At, ExtensionInstallError as B, ensureKeybindingsFile as Bt, NO_TOOLS_PREAMBLE as C, readFile$1 as Ct, buildFullCompactPrompt as D, formatModelLine as Dt, buildFromCompactPrompt as E, createModelSearchTool as Et, truncateHeadForPtlRetry as F, resolveStorageDirs as Ft, readExtensionInstallProvenance as G, mergeKeybindings as Gt, installExtensionFromSpec as H, groupBindings as Ht, CompactInvalidInputError as I, DEFAULT_KEYBINDINGS as It, createExtensionHud as J, readKeybindingsRaw as Jt, removeInstalledExtension as K, parseBindingSpec as Kt, CompactPromptTooLongError as L, KEYBINDING_DEFS as Lt, sliceForCompaction as M, glob as Mt, stripImagesFromTurns as N, edit as Nt, buildTailCompactPrompt as O, matchModelEntries as Ot, summaryToTurn as P, validateToolArgs as Pt, buildExtensionRegistry as Q, defaultExtensionScanPaths as Qt, EMPTY_EXTENSION_REGISTRY as R, KEYBINDING_DEF_BY_ACTION as Rt, BASE_INSTRUCTIONS as S, tailTruncate as St, buildCompactPrompt as T, multiEdit as Tt, listExtensionCandidates as U, keybindingsPath as Ut, fetchExtensionSource as V, formatBindingForDisplay as Vt, parseExtensionInstallSource as W, matchesBinding as Wt, discoverAndBuildExtensionRegistry as X, stripJsonComments as Xt, registerExtensionHostModules as Y, resolveExtensionKeybindings as Yt, buildExtensionPreset as Z, ENTRY_CANDIDATES as Zt, buildPostCompactAttachments as _, defaultRepeatGuardNormalize as _n, createSkillsRunScriptTool as _t, SHELL_CASCADE_CANCEL_MESSAGE as a, clampExtensionConfigNumber as an, createWorkspaceSurface as at, selectRecentFiles as b, stableStringify as bn, createShellTool as bt, applyCompactSummaryCutoff as c, isValidExtensionConfigValue as cn, basicTools as ct, buildPersistedStub as d, sanitizeExtensionConfigActionPatch as dn, WAIT_TASK_TIMED_OUT_PREFIX as dt, inlineLoadedExtension as en, disposeExtensionRegistry as et, cleanupPersistedSession as f, toWireConfigSchema as fn, waitTask as ft, resolveTasksDir as g, shouldAutoCompact as gn, createSkillsUseTool as gt, resolvePersistDir as h, effectiveContextWindow as hn, isSpawnTool as ht, INTERRUPT_MESSAGE_FOR_TOOL_USE as i, defineExtension as in, createExtensionHostRuntimeBridge as it, anchorPreviewFor as j, grep as jt, buildUpToCompactPrompt as k, listFiles as kt, PERSISTED_STUB_PREFIX as l, resolveExtensionConfig as ln, basic_default as lt, resolveMcpWarningsDir as m, OUTPUT_RESERVE_TOKENS as mn, createSpawnTool as mt, normalizeProviders as n, parseExtensionScanPathEnv as nn, mergeContributions as nt, TOOL_USE_CANCELLED_MESSAGE as o, coerceExtensionConfigInput as on, composePresets as ot, maybePersistToolResult as p, AUTO_COMPACT_MIN_GROWTH_FRACTION as pn, createToolSearchTool as pt, updateInstalledExtension as q, readKeybindings as qt, resolveModelTargets as r, scanExtensionDirectories as rn, partitionExtensionCatalog as rt, TOOL_USE_SKIPPED_MESSAGE as s, isValidExtensionConfigItem as sn, definePreset as st, createAgent as t, isExtensionDefinition as tn, filterExtensionRegistry as tt, PERSISTENCE_PREVIEW_BYTES as u, resolveExtensionConfigValue as un, writeFile$1 as ut, selectFilesFromReadState as v, defaultRepeatGuardTracked as vn, createSkillsReadTool as vt, TRAILER as w, looksBinary as wt, compactConversation as x, shell as xt, selectFilesFromSession as y, normalizeShellCommand as yn, shellKill as yt, createExtensionPromptBridge as z, KEYBINDING_KEY_COL_WIDTH as zt };
14959
15070
 
14960
- //# sourceMappingURL=agent-BJLSgHAS.js.map
15071
+ //# sourceMappingURL=agent-BSIMsEtD.js.map