zidane 6.2.22 → 6.2.24

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 (81) hide show
  1. package/dist/{acp-Cwp_Y78H.js → acp-CTn1kFvP.js} +4 -4
  2. package/dist/{acp-Cwp_Y78H.js.map → acp-CTn1kFvP.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-IPshmLIF.js → agent-tLfGSSQw.js} +153 -21
  7. package/dist/agent-tLfGSSQw.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/pure.js +1 -1
  12. package/dist/chat.d.ts +4 -4
  13. package/dist/chat.d.ts.map +1 -1
  14. package/dist/chat.js +4 -4
  15. package/dist/contexts/daytona.d.ts +1 -1
  16. package/dist/contexts/e2b.d.ts +1 -1
  17. package/dist/eval.d.ts +1 -1
  18. package/dist/eval.js +1 -1
  19. package/dist/extensions.d.ts +1 -1
  20. package/dist/extensions.js +1 -1
  21. package/dist/headless.d.ts +1 -1
  22. package/dist/headless.js +2 -2
  23. package/dist/{index-BDtxt4FY.d.ts → index-8zm_hwdY.d.ts} +87 -3
  24. package/dist/index-8zm_hwdY.d.ts.map +1 -0
  25. package/dist/index.d.ts +1 -1
  26. package/dist/index.js +6 -6
  27. package/dist/{login-BkZ_d5sT.js → login-DfJGuHUj.js} +2 -2
  28. package/dist/{login-BkZ_d5sT.js.map → login-DfJGuHUj.js.map} +1 -1
  29. package/dist/mcp.d.ts +1 -1
  30. package/dist/output/stream-json.d.ts +1 -1
  31. package/dist/output/terminal.d.ts +1 -1
  32. package/dist/presets.d.ts +1 -1
  33. package/dist/presets.js +1 -1
  34. package/dist/providers/anthropic.d.ts +1 -1
  35. package/dist/providers/arcee.d.ts +1 -1
  36. package/dist/providers/baseten.d.ts +1 -1
  37. package/dist/providers/cerebras.d.ts +1 -1
  38. package/dist/providers/local.d.ts +1 -1
  39. package/dist/providers/openai-compat.d.ts +1 -1
  40. package/dist/providers/openai.d.ts +1 -1
  41. package/dist/providers/openrouter.d.ts +1 -1
  42. package/dist/providers/xai.d.ts +1 -1
  43. package/dist/providers.d.ts +1 -1
  44. package/dist/{resolve-x5mlFtLX.js → resolve-BPTA1RpX.js} +23 -3
  45. package/dist/resolve-BPTA1RpX.js.map +1 -0
  46. package/dist/restate.d.ts +1 -1
  47. package/dist/session/sqlite.d.ts +1 -1
  48. package/dist/{session-DzrXKLw-.js → session-jLsc_kMH.js} +23 -3
  49. package/dist/session-jLsc_kMH.js.map +1 -0
  50. package/dist/session.d.ts +2 -2
  51. package/dist/session.js +2 -2
  52. package/dist/{skills-C1vGKbqv.js → skills-C7eIjWYm.js} +2 -2
  53. package/dist/{skills-C1vGKbqv.js.map → skills-C7eIjWYm.js.map} +1 -1
  54. package/dist/skills.d.ts +1 -1
  55. package/dist/skills.js +2 -2
  56. package/dist/{tool-formatters-CMrkqO4q.d.ts → tool-formatters-CZJYzP4x.d.ts} +2 -2
  57. package/dist/{tool-formatters-CMrkqO4q.d.ts.map → tool-formatters-CZJYzP4x.d.ts.map} +1 -1
  58. package/dist/tools/fetch-url.d.ts +1 -1
  59. package/dist/tools/web-search.d.ts +1 -1
  60. package/dist/tools.d.ts +1 -1
  61. package/dist/tools.js +1 -1
  62. package/dist/{transcript-anchors-Bvb8iMiY.d.ts → transcript-anchors-CJ2dmpQk.d.ts} +12 -4
  63. package/dist/{transcript-anchors-Bvb8iMiY.d.ts.map → transcript-anchors-CJ2dmpQk.d.ts.map} +1 -1
  64. package/dist/{transcript-anchors-DvLIRYLz.js → transcript-anchors-Ded7iJjG.js} +56 -8
  65. package/dist/transcript-anchors-Ded7iJjG.js.map +1 -0
  66. package/dist/tui.d.ts +15 -5
  67. package/dist/tui.d.ts.map +1 -1
  68. package/dist/tui.js +757 -325
  69. package/dist/tui.js.map +1 -1
  70. package/dist/{turn-operations-CokV32wf.js → turn-operations-ClGa1vnb.js} +6 -2
  71. package/dist/{turn-operations-CokV32wf.js.map → turn-operations-ClGa1vnb.js.map} +1 -1
  72. package/dist/{turn-operations-BIw6n_H2.d.ts → turn-operations-DZYpXcU1.d.ts} +3 -3
  73. package/dist/{turn-operations-BIw6n_H2.d.ts.map → turn-operations-DZYpXcU1.d.ts.map} +1 -1
  74. package/dist/types-BIarq1qE.js.map +1 -1
  75. package/dist/types.d.ts +1 -1
  76. package/package.json +1 -1
  77. package/dist/agent-IPshmLIF.js.map +0 -1
  78. package/dist/index-BDtxt4FY.d.ts.map +0 -1
  79. package/dist/resolve-x5mlFtLX.js.map +0 -1
  80. package/dist/session-DzrXKLw-.js.map +0 -1
  81. package/dist/transcript-anchors-DvLIRYLz.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-IPshmLIF.js";
2
+ import { Ft as resolveStorageDirs, lt as basic_default } from "./agent-tLfGSSQw.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-Cwp_Y78H.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-CTn1kFvP.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-BDtxt4FY.js";
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-8zm_hwdY.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-Cwp_Y78H.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-CTn1kFvP.js";
2
2
  export { AcpProtocolError, JsonRpcRemoteError, acpMcpServersToZidane, acpPromptToPromptParts, createAcpServer, createJsonRpcConnection, runAcpStdioServer, sessionBlocksToAcp, stopReasonFromRun, toolResultToAcpContent, withAcpDefaultTools, wrapToolsForAcpClient };
@@ -9,16 +9,16 @@ 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-x5mlFtLX.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-BPTA1RpX.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";
16
16
  import { c as wrapDiscoveredMcpTools, i as nonOwningMcpView, n as connectMcpServers, r as deriveMcpToolMeta } from "./mcp-H6bqyM94.js";
17
- import { n as flattenTurns, r as formatTokenUsage, t as effectiveInputFromTurn } from "./stats-DAKBEKjc.js";
18
17
  import { C as canonicalizePrompt, S as buildPromptMessage } from "./openai-compat-pHI0kBWH.js";
19
18
  import { appendStaticSection, renderSystemForWire } from "./prompt.js";
20
19
  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";
20
+ import { a as getExtensionSessionState, c as setExtensionSessionState, l as withExtensionSession, n as currentExtensionSession, r as deleteExtensionSessionState, s as resumeChainRunIds } from "./session-jLsc_kMH.js";
21
+ import { n as flattenTurns, r as formatTokenUsage, t as effectiveInputFromTurn } from "./stats-DAKBEKjc.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";
@@ -4838,6 +4838,7 @@ const BUBBLED_EVENTS = [
4838
4838
  "stream:error",
4839
4839
  "stream:server_tool_use",
4840
4840
  "stream:server_tool_result",
4841
+ "stream:retry",
4841
4842
  "tool:dispatched",
4842
4843
  "tool:before",
4843
4844
  "tool:after",
@@ -4861,6 +4862,7 @@ const CHILD_EVENT_NAME = {
4861
4862
  "stream:error": "child:stream:error",
4862
4863
  "stream:server_tool_use": "child:stream:server_tool_use",
4863
4864
  "stream:server_tool_result": "child:stream:server_tool_result",
4865
+ "stream:retry": "child:stream:retry",
4864
4866
  "tool:dispatched": "child:tool:dispatched",
4865
4867
  "tool:before": "child:tool:before",
4866
4868
  "tool:after": "child:tool:after",
@@ -4878,9 +4880,32 @@ const CHILD_MUTABLE_EVENT_NAME = {
4878
4880
  "tool:transform": "child:tool:transform"
4879
4881
  };
4880
4882
  const sessionChildCounters = /* @__PURE__ */ new WeakMap();
4883
+ /** Chronological child runs (depth > 0) — index + 1 is the `child-N` label. */
4884
+ function childRunsOf(session) {
4885
+ return session.runs.filter((r) => (r.depth ?? 0) > 0);
4886
+ }
4887
+ /**
4888
+ * Human/model-facing list of this session's child runs. Prefers the label
4889
+ * persisted at `startRun` (`SessionRun.label`) and falls back to positional
4890
+ * numbering for legacy sessions recorded before labels were stored.
4891
+ * Rendered into resume-rejection messages so the model can self-correct
4892
+ * with a valid label.
4893
+ */
4894
+ function describeChildRuns(session) {
4895
+ const childRuns = childRunsOf(session);
4896
+ if (childRuns.length === 0) return "No child runs exist in this session.";
4897
+ return childRuns.map((r, i) => `- ${r.label ?? `child-${i + 1}`} · ${r.status} · ${r.prompt.slice(0, 80)}`).join("\n");
4898
+ }
4881
4899
  function reserveChildLabel(session) {
4882
4900
  let counter = sessionChildCounters.get(session);
4883
- if (counter === void 0) counter = session.runs.filter((r) => (r.depth ?? 0) > 0).length;
4901
+ if (counter === void 0) {
4902
+ const childRuns = childRunsOf(session);
4903
+ counter = childRuns.length;
4904
+ for (const r of childRuns) {
4905
+ const m = r.label ? /^child-(\d+)$/.exec(r.label) : null;
4906
+ if (m) counter = Math.max(counter, Number(m[1]));
4907
+ }
4908
+ }
4884
4909
  counter += 1;
4885
4910
  sessionChildCounters.set(session, counter);
4886
4911
  return `child-${counter}`;
@@ -5213,6 +5238,10 @@ function buildSpawnTool(options, state) {
5213
5238
  type: "string",
5214
5239
  description: buildModelFieldDescription(modelCatalog)
5215
5240
  } } : {};
5241
+ const resumeProperty = options.persist ? { resume: {
5242
+ type: "string",
5243
+ 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."
5244
+ } } : {};
5216
5245
  const tool = {
5217
5246
  maxConcurrent,
5218
5247
  get children() {
@@ -5245,7 +5274,7 @@ function buildSpawnTool(options, state) {
5245
5274
  isConcurrencySafe: true,
5246
5275
  spec: {
5247
5276
  name: "spawn",
5248
- 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." : ""}`,
5277
+ 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." : ""}`,
5249
5278
  inputSchema: {
5250
5279
  type: "object",
5251
5280
  properties: {
@@ -5258,7 +5287,8 @@ function buildSpawnTool(options, state) {
5258
5287
  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."
5259
5288
  },
5260
5289
  ...subagentTypeProperty,
5261
- ...modelProperty
5290
+ ...modelProperty,
5291
+ ...resumeProperty
5262
5292
  },
5263
5293
  required: ["task"]
5264
5294
  }
@@ -5296,6 +5326,47 @@ function buildSpawnTool(options, state) {
5296
5326
  const inheritedModel = childProvider === ctx.provider ? ctx.model : void 0;
5297
5327
  const childModel = chosenModelId ?? inheritedModel;
5298
5328
  const announcedModel = childModel ?? childProvider.meta.defaultModel;
5329
+ let resumeRun;
5330
+ let resumeLabel;
5331
+ if (input.resume !== void 0 && input.resume !== null) {
5332
+ if (typeof input.resume !== "string" || input.resume.trim() === "") return {
5333
+ status: "rejected",
5334
+ text: "",
5335
+ message: `Cannot resume: invalid resume value ${JSON.stringify(input.resume)} — pass a child label like "child-2".`
5336
+ };
5337
+ const wanted = input.resume.trim();
5338
+ if (!options.persist || !ctx.session) return {
5339
+ status: "rejected",
5340
+ text: "",
5341
+ 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."
5342
+ };
5343
+ const childRuns = childRunsOf(ctx.session);
5344
+ let index = childRuns.findIndex((r) => r.label === wanted);
5345
+ if (index < 0) {
5346
+ const labelMatch = /^child-(\d+)$/.exec(wanted);
5347
+ index = labelMatch ? Number(labelMatch[1]) - 1 : childRuns.findIndex((r) => r.id === wanted);
5348
+ }
5349
+ const run = index >= 0 ? childRuns[index] : void 0;
5350
+ if (!run) return {
5351
+ status: "rejected",
5352
+ text: "",
5353
+ message: `Cannot resume: no child run matches "${wanted}". Child runs in this session:\n${describeChildRuns(ctx.session)}`
5354
+ };
5355
+ const runLabel = run.label ?? `child-${index + 1}`;
5356
+ if (run.status === "running") return {
5357
+ status: "rejected",
5358
+ text: "",
5359
+ message: `Cannot resume: ${runLabel} is still running. Only terminal children (aborted / error / completed) can be resumed.`
5360
+ };
5361
+ const chain = resumeChainRunIds(ctx.session.runs, run.id);
5362
+ if (!ctx.session.turns.some((t) => t.runId !== void 0 && chain.has(t.runId))) return {
5363
+ status: "rejected",
5364
+ text: "",
5365
+ message: `Cannot resume: ${runLabel} has no persisted turns (it likely failed before producing anything). Spawn a fresh child with a full task instead.`
5366
+ };
5367
+ resumeRun = run;
5368
+ resumeLabel = runLabel;
5369
+ }
5299
5370
  const parentDepth = ctx.depth ?? 0;
5300
5371
  const childDepth = parentDepth + 1;
5301
5372
  if (childDepth > maxDepth) return {
@@ -5370,6 +5441,7 @@ function buildSpawnTool(options, state) {
5370
5441
  const spawnHookCtx = {
5371
5442
  id,
5372
5443
  task,
5444
+ ...resumeLabel !== void 0 ? { resumesChildId: resumeLabel } : {},
5373
5445
  depth: childDepth,
5374
5446
  model: announcedModel,
5375
5447
  provider: childProvider.name,
@@ -5386,6 +5458,8 @@ function buildSpawnTool(options, state) {
5386
5458
  signal: ctx.signal,
5387
5459
  depth: childDepth,
5388
5460
  ...options.persist && ctx.runId ? { parentRunId: ctx.runId } : {},
5461
+ ...options.persist && ctx.session ? { runLabel: id } : {},
5462
+ ...resumeRun ? { resumeRunId: resumeRun.id } : {},
5389
5463
  ...propagatedTracing ? { tracingContext: propagatedTracing } : {}
5390
5464
  });
5391
5465
  try {
@@ -9902,6 +9976,23 @@ function applyMediaAgeout(messages, keep, options) {
9902
9976
  };
9903
9977
  }
9904
9978
  /**
9979
+ * Distinct `read_file` paths called inside the given turns (optionally
9980
+ * filtered to an id set). Canonical tool names — the alias rewrite is
9981
+ * wire-only, so session turns always carry `read_file` verbatim.
9982
+ */
9983
+ function readFilePathsInTurns(turns, ids) {
9984
+ const paths = /* @__PURE__ */ new Set();
9985
+ for (const turn of turns) {
9986
+ if (ids && !ids.has(turn.id)) continue;
9987
+ for (const block of turn.content) {
9988
+ if (block.type !== "tool_call" || block.name !== "read_file") continue;
9989
+ const path = block.input.path;
9990
+ if (typeof path === "string" && path.length > 0) paths.add(path);
9991
+ }
9992
+ }
9993
+ return [...paths];
9994
+ }
9995
+ /**
9905
9996
  * Build a call_id → file path map for `read_file` tool calls in `messages`.
9906
9997
  * Tail compaction uses it to learn which stubbed `tool_result`s were file
9907
9998
  * reads, so their read-state dedup can be invalidated. Resolve this from the
@@ -10546,8 +10637,9 @@ async function repairInvalidAnthropicThinkingHistory(ctx, streamOptions, repair)
10546
10637
  }
10547
10638
  return Math.max(removed, sessionRemoved);
10548
10639
  }
10549
- async function streamWithWatchdogs(ctx, options, callbacks, turnId) {
10550
- const { startTimeoutMs, totalTimeoutMs } = providerWatchdogTimeouts(ctx);
10640
+ async function streamWithWatchdogs(ctx, options, callbacks, turnId, opts) {
10641
+ let { startTimeoutMs, totalTimeoutMs } = providerWatchdogTimeouts(ctx);
10642
+ if (opts?.startTimeoutCapMs !== void 0 && startTimeoutMs > 0) startTimeoutMs = Math.min(startTimeoutMs, opts.startTimeoutCapMs);
10551
10643
  const callerHistoryRepair = callbacks.onHistoryRepair;
10552
10644
  callbacks = {
10553
10645
  ...callbacks,
@@ -10711,6 +10803,18 @@ const RETRY_DEFAULTS = {
10711
10803
  maxDelayMs: 3e4
10712
10804
  };
10713
10805
  /**
10806
+ * First-response watchdog cap for RETRY attempts (attempt ≥ 2). The first
10807
+ * attempt gets the full `providerStreamStartTimeoutMs` window (large-prompt
10808
+ * prefill legitimately takes a while on a cold request), but a healthy
10809
+ * re-issue — fired after backoff already waited out any declared
10810
+ * rate-limit window — either starts streaming quickly or is dead. Without
10811
+ * the cap, retrying watchdog timeouts multiplies worst-case silent latency
10812
+ * (3 × 5 min for the defaults) and a stuck provider blocks a whole /ticket
10813
+ * stage for that long. Only applied when the start watchdog is enabled —
10814
+ * an explicit `0` (disabled) stays disabled on retries too.
10815
+ */
10816
+ const RETRY_STREAM_START_TIMEOUT_CAP_MS = 12e4;
10817
+ /**
10714
10818
  * Reactive context-overflow recovery schedule. When a turn is rejected with
10715
10819
  * `context_exceeded` (pre-stream — the request was too big for the model's
10716
10820
  * window), the loop emergency-compacts older `tool_result` bodies via
@@ -10862,6 +10966,9 @@ async function maybeAutoCompact(ctx, turn, lastTurnUsage, state) {
10862
10966
  }
10863
10967
  ctx.turns.push(summaryTurn, ...restorationTurns);
10864
10968
  await ctx.persistTurns?.();
10969
+ const absorbedIds = /* @__PURE__ */ new Set([...result.summarizedTurnIds, ...result.droppedDueToPtl]);
10970
+ const onWireReads = new Set(readFilePathsInTurns(applyCompactSummaryCutoff(ctx.turns)));
10971
+ markReadStateForElidedPaths(ctx, ctx.handle.cwd, readFilePathsInTurns(ctx.turns, absorbedIds).filter((p) => !onWireReads.has(p)));
10865
10972
  const effectiveTokens = (result.usage.output ?? 0) + restorationTokens;
10866
10973
  state.lastCompactedInputTokens = effectiveTokens;
10867
10974
  state.consecutiveFailures = 0;
@@ -11151,7 +11258,7 @@ async function executeTurn(ctx, turn, priorUsage) {
11151
11258
  onOAuthRefresh(refreshCtx) {
11152
11259
  return ctx.hooks.callHook("oauth:refresh", refreshCtx);
11153
11260
  }
11154
- }, turnId);
11261
+ }, turnId, attempt > 1 ? { startTimeoutCapMs: RETRY_STREAM_START_TIMEOUT_CAP_MS } : void 0);
11155
11262
  break;
11156
11263
  } catch (caught) {
11157
11264
  let terminalErr = caught;
@@ -11159,7 +11266,8 @@ async function executeTurn(ctx, turn, priorUsage) {
11159
11266
  const classified = !wasAborted ? ctx.provider.classifyError?.(caught) : null;
11160
11267
  const isRetryable = classified?.kind === "provider_error" && classified.retryable === true;
11161
11268
  const cleanSlate = currentText === "" && currentThinking === "";
11162
- const canRetry = !wasAborted && isRetryable && cleanSlate && attempt < retryCfg.maxAttempts;
11269
+ const isStreamWatchdogTimeout = !wasAborted && caught instanceof OperationTimeoutError && (caught.operation === "provider first response" || caught.operation === "provider total stream");
11270
+ const canRetry = !wasAborted && (isRetryable || isStreamWatchdogTimeout) && cleanSlate && attempt < retryCfg.maxAttempts;
11163
11271
  const retryAfterMs = canRetry ? extractRetryAfterMs(caught) : void 0;
11164
11272
  const hasNextTarget = ctx.targets !== void 0 && (ctx.activeTargetIndex ?? 0) + 1 < ctx.targets.length;
11165
11273
  if (canRetry && !(retryAfterMs !== void 0 && retryAfterMs > LONG_RETRY_AFTER_FALLBACK_MS && hasNextTarget)) {
@@ -11169,6 +11277,7 @@ async function executeTurn(ctx, turn, priorUsage) {
11169
11277
  turnId,
11170
11278
  attempt,
11171
11279
  nextAttempt: attempt + 1,
11280
+ maxAttempts: retryCfg.maxAttempts,
11172
11281
  delayMs,
11173
11282
  err: caught,
11174
11283
  ...meta
@@ -12908,6 +13017,7 @@ const HOOK_EVENT_SET = /* @__PURE__ */ new Set([
12908
13017
  "child:stream:server_tool_use",
12909
13018
  "child:stream:server_tool_result",
12910
13019
  "child:stream:error",
13020
+ "child:stream:retry",
12911
13021
  "child:tool:gate",
12912
13022
  "child:mcp:tool:gate",
12913
13023
  "child:tool:dispatched",
@@ -13387,10 +13497,10 @@ function installLazyDisclosureGate(hooks, lazyCanonicalNames, unlocked, discover
13387
13497
  * (`via: 'resume'`) for skills it newly activates. Shared by the run-start
13388
13498
  * resume rehydration and the mid-loop durable-replay gate below.
13389
13499
  */
13390
- async function rehydrateActiveSkillsFromTurns(session, resolvedSkills, state, hooks) {
13500
+ async function rehydrateActiveSkillsFromTurns(turns, resolvedSkills, state, hooks) {
13391
13501
  const skillsByName = new Map(resolvedSkills.map((s) => [s.name, s]));
13392
13502
  const lastModeBySkill = /* @__PURE__ */ new Map();
13393
- for (const turn of session.turns) {
13503
+ for (const turn of turns) {
13394
13504
  if (turn.role !== "assistant") continue;
13395
13505
  for (const block of turn.content) {
13396
13506
  if (block.type !== "tool_call" || block.name !== "skills_use") continue;
@@ -13436,7 +13546,7 @@ function installSkillsActivationHydrationGate(hooks, deps) {
13436
13546
  const skillName = typeof ctx.input?.name === "string" ? ctx.input.name : void 0;
13437
13547
  if (!skillName || deps.state.isActive(skillName)) return;
13438
13548
  try {
13439
- await rehydrateActiveSkillsFromTurns(session, resolvedSkills, deps.state, hooks);
13549
+ await rehydrateActiveSkillsFromTurns(session.turns, resolvedSkills, deps.state, hooks);
13440
13550
  } catch {}
13441
13551
  });
13442
13552
  }
@@ -13851,6 +13961,12 @@ function createAgent(rawOptions) {
13851
13961
  const targets = resolveModelTargets(providers, options.model);
13852
13962
  const runProvider = targets[0].provider;
13853
13963
  const resumeFilteredTurns = validateAndPrepareResume(session, options.prompt, pendingTaskNotifications.size > 0);
13964
+ if (options.resumeRunId) {
13965
+ if (!session) throw new Error("resumeRunId requires a session (the prior run's turns live there)");
13966
+ if (!options.prompt) throw new Error("resumeRunId requires a prompt — pass the continuation instruction");
13967
+ const chain = resumeChainRunIds(session.runs, options.resumeRunId);
13968
+ if (!session.turns.some((t) => t.runId !== void 0 && chain.has(t.runId))) throw new Error(`resumeRunId "${options.resumeRunId}" has no persisted turns in this session — nothing to resume`);
13969
+ }
13854
13970
  const clock = options.clock ?? agentClock ?? DEFAULT_AGENT_CLOCK;
13855
13971
  let externalAbortListener;
13856
13972
  const externalSignal = options.signal;
@@ -13870,7 +13986,9 @@ function createAgent(rawOptions) {
13870
13986
  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") : "";
13871
13987
  session?.startRun(runId, promptLabel, {
13872
13988
  ...options.parentRunId ? { parentRunId: options.parentRunId } : {},
13873
- depth: typeof options.depth === "number" ? options.depth : 0
13989
+ depth: typeof options.depth === "number" ? options.depth : 0,
13990
+ ...options.resumeRunId ? { resumedFromRunId: options.resumeRunId } : {},
13991
+ ...options.runLabel ? { label: options.runLabel } : {}
13874
13992
  });
13875
13993
  const sessionRun = session?.runs.find((r) => r.id === runId);
13876
13994
  if (sessionRun) sessionRun.startedAt = runStartedAt;
@@ -13929,7 +14047,14 @@ function createAgent(rawOptions) {
13929
14047
  });
13930
14048
  }
13931
14049
  });
13932
- if (resolvedSkills && session && session.turns.length > 0 && skillActivationState.active().length === 0) await rehydrateActiveSkillsFromTurns(session, resolvedSkills, skillActivationState, hooks);
14050
+ if (resolvedSkills && session && session.turns.length > 0 && skillActivationState.active().length === 0) {
14051
+ let rehydrationTurns = session.turns;
14052
+ if (options.resumeRunId) {
14053
+ const chain = resumeChainRunIds(session.runs, options.resumeRunId);
14054
+ rehydrationTurns = session.turns.filter((t) => t.runId !== void 0 && chain.has(t.runId));
14055
+ }
14056
+ await rehydrateActiveSkillsFromTurns(rehydrationTurns, resolvedSkills, skillActivationState, hooks);
14057
+ }
13933
14058
  const thinking = options.thinking ?? "off";
13934
14059
  const model = targets[0].model;
13935
14060
  if (runProvider.meta?.clearsContextServerSide) resolvedBehavior.dedupReads = false;
@@ -14096,15 +14221,22 @@ function createAgent(rawOptions) {
14096
14221
  });
14097
14222
  }
14098
14223
  const turns = [];
14099
- if (session && session.turns.length > 0 && (session.runs.length > 0 || !options.prompt) && !options.parentRunId) {
14224
+ const isResume = session && session.turns.length > 0 && (session.runs.length > 0 || !options.prompt) && !options.parentRunId && !options.resumeRunId;
14225
+ let seededTurns;
14226
+ if (options.resumeRunId && session) {
14227
+ const chain = resumeChainRunIds(session.runs, options.resumeRunId);
14228
+ seededTurns = filterUnresolvedToolUses(session.turns.filter((t) => t.runId !== void 0 && chain.has(t.runId)));
14229
+ } else if (isResume) {
14100
14230
  const childRunIds = childRunIdSet(session);
14101
14231
  const resumed = childRunIds.size === 0 ? session.turns : session.turns.filter((t) => !t.runId || !childRunIds.has(t.runId));
14102
- const filteredForRuntime = resumeFilteredTurns && resumed === session.turns ? resumeFilteredTurns : filterUnresolvedToolUses(resumed);
14103
- turns.push(...filteredForRuntime);
14232
+ seededTurns = resumeFilteredTurns && resumed === session.turns ? resumeFilteredTurns : filterUnresolvedToolUses(resumed);
14233
+ }
14234
+ if (seededTurns) {
14235
+ turns.push(...seededTurns);
14104
14236
  if (shouldInjectToolSearch && disclosure.lazyEntries.length > 0) {
14105
14237
  const resolvedCallIds = /* @__PURE__ */ new Set();
14106
- for (const turn of filteredForRuntime) for (const block of turn.content) if (block.type === "tool_result" && !block.isError) resolvedCallIds.add(block.callId);
14107
- for (const turn of filteredForRuntime) for (const block of turn.content) {
14238
+ for (const turn of seededTurns) for (const block of turn.content) if (block.type === "tool_result" && !block.isError) resolvedCallIds.add(block.callId);
14239
+ for (const turn of seededTurns) for (const block of turn.content) {
14108
14240
  if (block.type !== "tool_call") continue;
14109
14241
  if (block.name !== "tool_search") continue;
14110
14242
  if (!resolvedCallIds.has(block.id)) continue;
@@ -14970,4 +15102,4 @@ function createAgent(rawOptions) {
14970
15102
  //#endregion
14971
15103
  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 };
14972
15104
 
14973
- //# sourceMappingURL=agent-IPshmLIF.js.map
15105
+ //# sourceMappingURL=agent-tLfGSSQw.js.map