zidane 5.13.13 → 5.13.16

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 (121) hide show
  1. package/dist/acp-cli.js +8 -7
  2. package/dist/acp-cli.js.map +1 -1
  3. package/dist/{acp-CqXcM2Km.js → acp-eGzYbNGF.js} +8 -8
  4. package/dist/{acp-CqXcM2Km.js.map → acp-eGzYbNGF.js.map} +1 -1
  5. package/dist/acp.d.ts +2 -2
  6. package/dist/acp.js +1 -1
  7. package/dist/{agent-NkKgz5Dh.d.ts → agent-CNIOsTUg.d.ts} +44 -2
  8. package/dist/agent-CNIOsTUg.d.ts.map +1 -0
  9. package/dist/{auth-CGTf8v1_.js → auth-D9rP8khI.js} +2 -2
  10. package/dist/{auth-CGTf8v1_.js.map → auth-D9rP8khI.js.map} +1 -1
  11. package/dist/chat/pure.d.ts +3 -3
  12. package/dist/chat.d.ts +6 -6
  13. package/dist/chat.js +3 -3
  14. package/dist/contexts/daytona.d.ts +22 -4
  15. package/dist/contexts/daytona.d.ts.map +1 -1
  16. package/dist/contexts/daytona.js +6 -5
  17. package/dist/contexts/daytona.js.map +1 -1
  18. package/dist/contexts/docker.js +2 -1
  19. package/dist/contexts/docker.js.map +1 -1
  20. package/dist/contexts/e2b.d.ts +2 -2
  21. package/dist/contexts/sandbox.d.ts +2 -0
  22. package/dist/contexts/sandbox.js +55 -0
  23. package/dist/contexts/sandbox.js.map +1 -0
  24. package/dist/{contexts-DHi8LPCp.js → contexts-BebciJyQ.js} +3 -53
  25. package/dist/contexts-BebciJyQ.js.map +1 -0
  26. package/dist/contexts.d.ts +2 -1
  27. package/dist/contexts.js +2 -1
  28. package/dist/{errors-BpPfMo_4.js → errors-DJUxZg9b.js} +3 -2
  29. package/dist/{errors-BpPfMo_4.js.map → errors-DJUxZg9b.js.map} +1 -1
  30. package/dist/eval.d.ts +1 -1
  31. package/dist/eval.js +3 -3
  32. package/dist/{fetch-url-Cgbq-HYx.js → fetch-url-CWE8X5OD.js} +2 -2
  33. package/dist/{fetch-url-Cgbq-HYx.js.map → fetch-url-CWE8X5OD.js.map} +1 -1
  34. package/dist/{glob-DCWXy_tr.js → glob-D56-KpBp.js} +2 -12
  35. package/dist/glob-D56-KpBp.js.map +1 -0
  36. package/dist/glob-shell-rJMoCIGb.js +21 -0
  37. package/dist/glob-shell-rJMoCIGb.js.map +1 -0
  38. package/dist/{headless-C6Idunwh.js → headless-HAFnYaDY.js} +6 -6
  39. package/dist/{headless-C6Idunwh.js.map → headless-HAFnYaDY.js.map} +1 -1
  40. package/dist/headless.d.ts +1 -1
  41. package/dist/headless.js +1 -1
  42. package/dist/{index-BgB_425D.d.ts → index-Bzh-W2RD.d.ts} +26 -8
  43. package/dist/index-Bzh-W2RD.d.ts.map +1 -0
  44. package/dist/{index-BFY7mcar.d.ts → index-DuB7Cf02.d.ts} +2 -2
  45. package/dist/{index-BFY7mcar.d.ts.map → index-DuB7Cf02.d.ts.map} +1 -1
  46. package/dist/index-HQJDOWvo.d.ts +7 -0
  47. package/dist/index-HQJDOWvo.d.ts.map +1 -0
  48. package/dist/index.d.ts +6 -5
  49. package/dist/index.js +12 -11
  50. package/dist/index.js.map +1 -1
  51. package/dist/{interpolate-ConAiXGy.js → interpolate-BtIgcCuz.js} +2 -2
  52. package/dist/{interpolate-ConAiXGy.js.map → interpolate-BtIgcCuz.js.map} +1 -1
  53. package/dist/{logger-LQmSBfD_.d.ts → logger-HOG4EGv6.d.ts} +2 -2
  54. package/dist/{logger-LQmSBfD_.d.ts.map → logger-HOG4EGv6.d.ts.map} +1 -1
  55. package/dist/{login-DE-_d045.js → login-CCA-1lgK.js} +2 -2
  56. package/dist/{login-DE-_d045.js.map → login-CCA-1lgK.js.map} +1 -1
  57. package/dist/{mcp-2OGi_NQu.js → mcp-Dn5W65Lv.js} +2 -2
  58. package/dist/{mcp-2OGi_NQu.js.map → mcp-Dn5W65Lv.js.map} +1 -1
  59. package/dist/mcp.d.ts +1 -1
  60. package/dist/mcp.js +1 -1
  61. package/dist/{messages-U_87Z7GH.js → messages-FUqY3pci.js} +2 -2
  62. package/dist/{messages-U_87Z7GH.js.map → messages-FUqY3pci.js.map} +1 -1
  63. package/dist/output/stream-json.d.ts +2 -2
  64. package/dist/output/stream-json.js +1 -1
  65. package/dist/output/terminal.d.ts +2 -2
  66. package/dist/{presets-eC4VwuHh.js → presets-DDRkelUs.js} +2 -2
  67. package/dist/{presets-eC4VwuHh.js.map → presets-DDRkelUs.js.map} +1 -1
  68. package/dist/presets.d.ts +2 -2
  69. package/dist/presets.js +1 -1
  70. package/dist/{providers-DyMPTo51.js → providers-BPVOGmde.js} +13 -5
  71. package/dist/providers-BPVOGmde.js.map +1 -0
  72. package/dist/providers.d.ts +1 -1
  73. package/dist/providers.js +2 -2
  74. package/dist/restate.d.ts +38 -2
  75. package/dist/restate.d.ts.map +1 -1
  76. package/dist/restate.js +22 -0
  77. package/dist/restate.js.map +1 -1
  78. package/dist/{index-CF15aqlk.d.ts → sandbox-B-bMq3K6.d.ts} +2 -5
  79. package/dist/sandbox-B-bMq3K6.d.ts.map +1 -0
  80. package/dist/session/sqlite.d.ts +1 -1
  81. package/dist/session/sqlite.js +1 -1
  82. package/dist/{session-DQ4bEncf.js → session-C0D4p0Gy.js} +2 -2
  83. package/dist/{session-DQ4bEncf.js.map → session-C0D4p0Gy.js.map} +1 -1
  84. package/dist/session.d.ts +1 -1
  85. package/dist/session.js +2 -2
  86. package/dist/skills.d.ts +2 -2
  87. package/dist/skills.js +1 -1
  88. package/dist/{tool-formatters-DvtGhbJN.d.ts → tool-formatters-B4Ll4Xpz.d.ts} +2 -2
  89. package/dist/{tool-formatters-DvtGhbJN.d.ts.map → tool-formatters-B4Ll4Xpz.d.ts.map} +1 -1
  90. package/dist/tools/fetch-url.d.ts +1 -1
  91. package/dist/tools/fetch-url.js +1 -1
  92. package/dist/tools/web-search.d.ts +1 -1
  93. package/dist/tools/web-search.js +2 -2
  94. package/dist/{tools-BvATiiCO.js → tools-BwqbsLcJ.js} +83 -26
  95. package/dist/tools-BwqbsLcJ.js.map +1 -0
  96. package/dist/tools.d.ts +2 -2
  97. package/dist/tools.js +1 -1
  98. package/dist/{transcript-anchors-DFmfOesU.d.ts → transcript-anchors-CRnGrkTd.d.ts} +4 -4
  99. package/dist/{transcript-anchors-DFmfOesU.d.ts.map → transcript-anchors-CRnGrkTd.d.ts.map} +1 -1
  100. package/dist/{transcript-anchors-Cn1Unhn-.js → transcript-anchors-dPvyuqmU.js} +9 -9
  101. package/dist/{transcript-anchors-Cn1Unhn-.js.map → transcript-anchors-dPvyuqmU.js.map} +1 -1
  102. package/dist/tui.d.ts +3 -3
  103. package/dist/tui.js +10 -10
  104. package/dist/tui.js.map +1 -1
  105. package/dist/{turn-operations-DWUN8cHo.d.ts → turn-operations-DYbhKmSu.d.ts} +3 -3
  106. package/dist/{turn-operations-DWUN8cHo.d.ts.map → turn-operations-DYbhKmSu.d.ts.map} +1 -1
  107. package/dist/types.d.ts +3 -3
  108. package/dist/types.js +1 -1
  109. package/docs/ARCHITECTURE.md +2 -0
  110. package/docs/CHAT.md +3 -3
  111. package/docs/RESTATE.md +58 -0
  112. package/docs/SKILL.md +1 -0
  113. package/docs/TUI.md +1 -1
  114. package/package.json +6 -1
  115. package/dist/agent-NkKgz5Dh.d.ts.map +0 -1
  116. package/dist/contexts-DHi8LPCp.js.map +0 -1
  117. package/dist/glob-DCWXy_tr.js.map +0 -1
  118. package/dist/index-BgB_425D.d.ts.map +0 -1
  119. package/dist/index-CF15aqlk.d.ts.map +0 -1
  120. package/dist/providers-DyMPTo51.js.map +0 -1
  121. package/dist/tools-BvATiiCO.js.map +0 -1
@@ -1,17 +1,17 @@
1
- import { F as canonicalizePrompt, O as appendStaticSection, P as buildPromptMessage, R as fnv1aBase36, a as detectTurnInterruption, c as filterUnresolvedToolUses, d as remintDuplicateToolCallIds, f as resolveContentRefsInMessages, j as renderSystemForWire, n as SYNTHETIC_TOOL_RESULT_PLACEHOLDER, o as ensureEndsWithUserMessage, s as ensureToolResultPairing } from "./messages-U_87Z7GH.js";
1
+ import { F as canonicalizePrompt, O as appendStaticSection, P as buildPromptMessage, R as fnv1aBase36, a as detectTurnInterruption, c as filterUnresolvedToolUses, d as remintDuplicateToolCallIds, f as resolveContentRefsInMessages, j as renderSystemForWire, n as SYNTHETIC_TOOL_RESULT_PLACEHOLDER, o as ensureEndsWithUserMessage, s as ensureToolResultPairing } from "./messages-FUqY3pci.js";
2
2
  import { n as estimateTokens, r as utf8ByteLength } from "./utils-ngQzYzZD.js";
3
3
  import { t as buildContextBreakdown } from "./context-breakdown-kO-pDsay.js";
4
4
  import { a as formatTaskStatus, i as formatDuration, o as formatTaskSummary, s as previewLine } from "./format-BNOXpl-1.js";
5
- import { r as createProcessContext, t as resolveDetachedTasksCapability } from "./contexts-DHi8LPCp.js";
5
+ import { n as createProcessContext, t as resolveDetachedTasksCapability } from "./contexts-BebciJyQ.js";
6
6
  import { a as toolOutputBudgetByteLength, i as documentBlockMarker, o as toolOutputByteLength, s as toolResultToText, t as DEFAULT_AGENT_CLOCK } from "./types-CyVGdbia.js";
7
7
  import { i as styleReplacementForVia, n as resolveOldString, r as stripLineNumberPrefixes, t as describeVia } from "./edit-utils-EGosADZq.js";
8
8
  import { a as markReadStateElided, n as getToolDedupState, o as readStateKey, r as hashContent, s as resolveReadStateMap, t as getReadState } from "./read-state-CLK9yVpm.js";
9
- import { i as AgentProviderError, l as errorMessage, m as toTypedError, n as AgentBudgetExceededError, o as AgentToolPairingError, t as AgentAbortedError, u as isAbortLikeError } from "./errors-BpPfMo_4.js";
9
+ 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";
10
10
  import { n as reconcileImageMediaType } from "./media-sniff-Bn76JxAu.js";
11
11
  import { n as writeFileAtomicAsync } from "./atomic-write-Bgtr5JPu.js";
12
- import { S as escapeXml, d as buildCatalog, n as stripShellInterpolations, p as installAllowedToolsGate, r as resolveSkills, t as interpolateShellCommands, v as validateResourcePathReal, x as createSkillActivationState } from "./interpolate-ConAiXGy.js";
12
+ import { S as escapeXml, d as buildCatalog, n as stripShellInterpolations, p as installAllowedToolsGate, r as resolveSkills, t as interpolateShellCommands, v as validateResourcePathReal, x as createSkillActivationState } from "./interpolate-BtIgcCuz.js";
13
13
  import { n as flattenTurns, r as formatTokenUsage, t as effectiveInputFromTurn } from "./stats-DAKBEKjc.js";
14
- import { n as connectMcpServers, s as wrapDiscoveredMcpTools } from "./mcp-2OGi_NQu.js";
14
+ import { n as connectMcpServers, s as wrapDiscoveredMcpTools } from "./mcp-Dn5W65Lv.js";
15
15
  import { n as shellQuote, t as alwaysQuote } from "./shell-quote-BmnhZmdM.js";
16
16
  import { isAbsolute, join, resolve } from "node:path";
17
17
  import { createHooks } from "hookable";
@@ -927,8 +927,8 @@ function anchorPreviewFor(turn) {
927
927
  *
928
928
  * The turn's role is `'user'` so it sits at a conversational boundary
929
929
  * the way the model expects. The caller is responsible for
930
- * `session.appendTurns([turn])`. The id is freshly generated via
931
- * `crypto.randomUUID()` so collisions are statistically impossible.
930
+ * `session.appendTurns([turn])`. The id defaults to `crypto.randomUUID()`
931
+ * (override via `input.id` for durable-execution replay stability).
932
932
  *
933
933
  * Typical use after running `compactConversation`:
934
934
  *
@@ -946,7 +946,7 @@ function anchorPreviewFor(turn) {
946
946
  function summaryToTurn(input) {
947
947
  const compactedAt = input.compactedAt ?? Date.now();
948
948
  return {
949
- id: crypto.randomUUID(),
949
+ id: input.id ?? crypto.randomUUID(),
950
950
  role: "user",
951
951
  content: [{
952
952
  type: "compact-summary",
@@ -1653,17 +1653,18 @@ async function buildPostCompactAttachments(opts) {
1653
1653
  output: sc.body
1654
1654
  });
1655
1655
  }
1656
- const now = Date.now();
1656
+ const clock = opts.clock ?? DEFAULT_AGENT_CLOCK;
1657
+ const now = await clock.now();
1657
1658
  const tag = opts.runId ? { runId: opts.runId } : {};
1658
1659
  return {
1659
1660
  turns: [{
1660
- id: crypto.randomUUID(),
1661
+ id: clock.randomUUID(),
1661
1662
  role: "assistant",
1662
1663
  content: assistantBlocks,
1663
1664
  createdAt: now,
1664
1665
  ...tag
1665
1666
  }, {
1666
- id: crypto.randomUUID(),
1667
+ id: clock.randomUUID(),
1667
1668
  role: "user",
1668
1669
  content: userBlocks,
1669
1670
  createdAt: now + 1,
@@ -1676,6 +1677,8 @@ async function buildPostCompactAttachments(opts) {
1676
1677
  }
1677
1678
  //#endregion
1678
1679
  //#region src/loop-persistence.ts
1680
+ /** Upper bound on the error message embedded in a persistence-failure stub. */
1681
+ const MAX_PERSIST_ERROR_CHARS = 500;
1679
1682
  /**
1680
1683
  * Bytes of head content included in the inline preview block. 2 KiB matches
1681
1684
  * Claude Code's `PREVIEW_SIZE_BYTES` — enough for the model to identify the
@@ -1767,10 +1770,10 @@ function resolveMcpWarningsDir(opts) {
1767
1770
  * routed write (`input.writeBlob`, e.g. a sandbox `writeFile`) is not atomic;
1768
1771
  * see the field doc for why that's safe here.
1769
1772
  *
1770
- * `ToolResultContent[]` results (images, structured blocks) currently bypass
1771
- * persistence the inline image bytes are the point of the call, and a
1772
- * mixed text/image array isn't representable as a single `.txt` file. We
1773
- * may revisit if a tool starts returning very large text-only arrays.
1773
+ * Text-only `ToolResultContent[]` results are flattened and persisted as
1774
+ * text. Mixed structured content still bypasses persistence because the inline
1775
+ * image/document bytes are the point of the call and a mixed result is not
1776
+ * representable as a single `.txt` file without dropping media.
1774
1777
  */
1775
1778
  async function maybePersistToolResult(input) {
1776
1779
  if (!input.threshold || input.threshold <= 0) return {
@@ -1781,7 +1784,8 @@ async function maybePersistToolResult(input) {
1781
1784
  kind: "skip",
1782
1785
  reason: "excluded"
1783
1786
  };
1784
- if (typeof input.output !== "string") return {
1787
+ const persistableOutput = textForPersistence(input.output);
1788
+ if (persistableOutput === null) return {
1785
1789
  kind: "skip",
1786
1790
  reason: "unsupported-shape"
1787
1791
  };
@@ -1793,26 +1797,34 @@ async function maybePersistToolResult(input) {
1793
1797
  kind: "skip",
1794
1798
  reason: "unsafe-call-id"
1795
1799
  };
1796
- const originalBytes = toolOutputByteLength(input.output);
1800
+ const originalBytes = toolOutputByteLength(persistableOutput);
1797
1801
  if (originalBytes <= input.threshold) return {
1798
1802
  kind: "skip",
1799
1803
  reason: "under-threshold"
1800
1804
  };
1801
1805
  const persistedPath = join(input.persistDir, `${input.callId}.txt`);
1802
1806
  try {
1803
- await (input.writeBlob ?? writeAtomic)(persistedPath, input.output);
1807
+ await (input.writeBlob ?? writeAtomic)(persistedPath, persistableOutput);
1804
1808
  } catch (err) {
1809
+ const error = err instanceof Error ? err : new Error(String(err));
1805
1810
  return {
1806
1811
  kind: "error",
1807
1812
  reason: "write-failed",
1808
- error: err instanceof Error ? err : new Error(String(err))
1813
+ error,
1814
+ originalBytes,
1815
+ output: buildPersistenceUnavailableStub({
1816
+ toolName: input.toolName,
1817
+ originalBytes,
1818
+ output: persistableOutput,
1819
+ error
1820
+ })
1809
1821
  };
1810
1822
  }
1811
1823
  const stub = buildPersistedStub({
1812
1824
  toolName: input.toolName,
1813
1825
  originalBytes,
1814
1826
  persistedPath,
1815
- output: input.output
1827
+ output: persistableOutput
1816
1828
  });
1817
1829
  let evicted;
1818
1830
  if (!input.writeBlob && typeof input.maxBytes === "number" && Number.isFinite(input.maxBytes) && input.maxBytes > 0) evicted = await enforcePersistDirCap(input.persistDir, input.maxBytes);
@@ -1937,6 +1949,25 @@ function buildPersistedStub(input) {
1937
1949
  ].join("\n");
1938
1950
  }
1939
1951
  /**
1952
+ * Render a bounded fallback when persistence was enabled but the blob write
1953
+ * failed. The full output is intentionally NOT kept inline: when this path
1954
+ * fires, preserving the context-window guarantee is more important than
1955
+ * recoverability of a failed best-effort spill.
1956
+ */
1957
+ function buildPersistenceUnavailableStub(input) {
1958
+ const { slice: previewSlice, bytes: previewBytes } = sliceFirstBytes(input.output, PERSISTENCE_PREVIEW_BYTES);
1959
+ const previewMarker = previewSlice.length < input.output.length ? `\n…(${input.originalBytes - previewBytes} more bytes omitted because persistence failed)` : "";
1960
+ const reason = input.error.message.length > MAX_PERSIST_ERROR_CHARS ? `${input.error.message.slice(0, MAX_PERSIST_ERROR_CHARS)}…` : input.error.message;
1961
+ return [
1962
+ `<persisted-output-unavailable tool="${escapeXml(input.toolName)}" bytes="${input.originalBytes}" reason="write-failed">`,
1963
+ `Full output could not be saved to disk, so it was omitted from inline context. Error: ${escapeXml(reason)}`,
1964
+ "",
1965
+ "Preview:",
1966
+ `${previewSlice}${previewMarker}`,
1967
+ "</persisted-output-unavailable>"
1968
+ ].join("\n");
1969
+ }
1970
+ /**
1940
1971
  * Remove every persisted blob belonging to a session. Called by the chat
1941
1972
  * layer from its session-delete path so closing a session frees the disk
1942
1973
  * footprint alongside the SQLite row.
@@ -2074,6 +2105,15 @@ function sliceFirstBytes(text, cap) {
2074
2105
  bytes
2075
2106
  };
2076
2107
  }
2108
+ function textForPersistence(output) {
2109
+ if (typeof output === "string") return output;
2110
+ const parts = [];
2111
+ for (const block of output) {
2112
+ if (block.type !== "text") return null;
2113
+ parts.push(block.text);
2114
+ }
2115
+ return parts.join("\n");
2116
+ }
2077
2117
  //#endregion
2078
2118
  //#region src/tools/validation.ts
2079
2119
  const TRUE_STRINGS = new Set([
@@ -3688,7 +3728,9 @@ async function maybeAutoCompact(ctx, turn, lastTurnUsage, state) {
3688
3728
  summary: result.summary,
3689
3729
  replacesTurnIds: result.summarizedTurnIds,
3690
3730
  model: result.model,
3691
- usage: result.usage
3731
+ usage: result.usage,
3732
+ compactedAt: await ctx.clock.now(),
3733
+ id: ctx.clock.randomUUID()
3692
3734
  });
3693
3735
  let restoredFiles = 0;
3694
3736
  let restoredSkills = 0;
@@ -3701,6 +3743,7 @@ async function maybeAutoCompact(ctx, turn, lastTurnUsage, state) {
3701
3743
  execution: ctx.execution,
3702
3744
  handle: ctx.handle,
3703
3745
  signal: ctx.signal,
3746
+ clock: ctx.clock,
3704
3747
  ...ctx.runId ? { runId: ctx.runId } : {}
3705
3748
  });
3706
3749
  restorationTurns = built.turns;
@@ -4705,7 +4748,10 @@ async function emitToolResult(ctx, params) {
4705
4748
  writeBlob: executionBlobWriter(ctx)
4706
4749
  });
4707
4750
  if (outcome.kind === "persisted") output = outcome.output;
4708
- else if (outcome.kind === "error" && process.env.ZIDANE_DEBUG) process.stderr.write(`[zidane/loop] persistence write failed for ${name}/${callId}: ${outcome.error.message}\n`);
4751
+ else if (outcome.kind === "error") {
4752
+ if (process.env.ZIDANE_DEBUG) process.stderr.write(`[zidane/loop] persistence write failed for ${name}/${callId}: ${outcome.error.message}\n`);
4753
+ output = outcome.output;
4754
+ }
4709
4755
  }
4710
4756
  output = stripImagesForNonVision(ctx.provider, output);
4711
4757
  await ctx.hooks.callHook("tool:after", {
@@ -7026,6 +7072,7 @@ const HOOK_EVENT_SET = new Set([
7026
7072
  "background:reassign",
7027
7073
  "background:stall",
7028
7074
  "background:reconcile",
7075
+ "execution:ready",
7029
7076
  "skills:resolve",
7030
7077
  "skills:catalog",
7031
7078
  "skills:activate",
@@ -7390,7 +7437,7 @@ function validateAndPrepareResume(session, prompt, hasPendingTaskNotifications =
7390
7437
  }
7391
7438
  return resumeFilteredTurns;
7392
7439
  }
7393
- function createAgent({ provider, name: agentName, system: agentSystem, tools: agentTools, toolAliases, behavior: agentBehavior, execution, mcpServers, session, readState: agentReadState, skills: agentSkills, mcpConnector, mcpToolWrap, eager, hooks: initialHooks, clock: agentClock, toolKill }) {
7440
+ function createAgent({ provider, name: agentName, system: agentSystem, tools: agentTools, toolAliases, behavior: agentBehavior, execution, handle: injectedHandle, mcpServers, session, readState: agentReadState, skills: agentSkills, mcpConnector, mcpToolWrap, eager, hooks: initialHooks, clock: agentClock, toolKill }) {
7394
7441
  const hooks = createHooks();
7395
7442
  const executionContext = execution ?? createProcessContext();
7396
7443
  const sourceTools = agentTools ?? {};
@@ -7417,7 +7464,9 @@ function createAgent({ provider, name: agentName, system: agentSystem, tools: ag
7417
7464
  const pendingStallNotifications = /* @__PURE__ */ new Map();
7418
7465
  const notifiedTaskIds = /* @__PURE__ */ new Set();
7419
7466
  const toolCancels = createToolCancelRegistry(toolKill?.defaultMessage !== void 0 ? { defaultMessage: toolKill.defaultMessage } : {});
7420
- let executionHandle = null;
7467
+ let executionHandle = injectedHandle ?? null;
7468
+ const executionHandleInjected = injectedHandle !== void 0;
7469
+ let executionReadyFired = false;
7421
7470
  let mcpConnection = null;
7422
7471
  let lastContextAssembly = null;
7423
7472
  let mcpWarmupPromise = null;
@@ -7548,6 +7597,7 @@ function createAgent({ provider, name: agentName, system: agentSystem, tools: ag
7548
7597
  perRunUnregisters.push(hooks.hook(event, fn));
7549
7598
  }
7550
7599
  }
7600
+ const spawnedThisCall = !executionHandle;
7551
7601
  if (!executionHandle) {
7552
7602
  const spawnTimeoutMs = resolveTimeoutMs(resolvedBehavior.spawnTimeoutMs, DEFAULT_SPAWN_TIMEOUT_MS, resolvedBehavior.maxWallMs);
7553
7603
  executionHandle = await withTimeout(executionContext.spawn(), {
@@ -7556,6 +7606,13 @@ function createAgent({ provider, name: agentName, system: agentSystem, tools: ag
7556
7606
  message: `Execution context spawn timed out after ${spawnTimeoutMs}ms (configurable via \`spawnTimeoutMs\`).`
7557
7607
  });
7558
7608
  }
7609
+ if (!executionReadyFired) {
7610
+ executionReadyFired = true;
7611
+ await hooks.callHook("execution:ready", {
7612
+ handle: executionHandle,
7613
+ spawned: spawnedThisCall
7614
+ });
7615
+ }
7559
7616
  if (allMcpServers.length > 0 && !mcpConnection) await warmup({
7560
7617
  mcpConnectTimeoutMs: resolvedBehavior.mcpConnectTimeoutMs,
7561
7618
  maxWallMs: resolvedBehavior.maxWallMs
@@ -8318,7 +8375,7 @@ function createAgent({ provider, name: agentName, system: agentSystem, tools: ag
8318
8375
  await settleWithinTimeout("destroy: mcp close", mcpConnection.close(), destroyTimeoutMs);
8319
8376
  mcpConnection = null;
8320
8377
  }
8321
- if (executionHandle) {
8378
+ if (executionHandle && !executionHandleInjected) {
8322
8379
  await settleWithinTimeout("destroy: execution destroy", executionContext.destroy(executionHandle), destroyTimeoutMs);
8323
8380
  executionHandle = null;
8324
8381
  }
@@ -10199,4 +10256,4 @@ const writeFile$1 = {
10199
10256
  //#endregion
10200
10257
  export { sliceForCompaction as $, PERSISTED_STUB_PREFIX as A, selectFilesFromSession as B, normalizeShellCommand as C, TOOL_USE_CANCELLED_MESSAGE as D, SHELL_CASCADE_CANCEL_MESSAGE as E, resolveMcpWarningsDir as F, TRAILER as G, compactConversation as H, resolvePersistDir as I, buildFullCompactPrompt as J, buildCompactPrompt as K, resolveTasksDir as L, buildPersistedStub as M, cleanupPersistedSession as N, TOOL_USE_SKIPPED_MESSAGE as O, maybePersistToolResult as P, anchorPreviewFor as Q, buildPostCompactAttachments as R, defaultRepeatGuardTracked as S, INTERRUPT_MESSAGE_FOR_TOOL_USE as T, BASE_INSTRUCTIONS as U, selectRecentFiles as V, NO_TOOLS_PREAMBLE as W, buildUpToCompactPrompt as X, buildTailCompactPrompt as Y, ANCHOR_PREVIEW_MAX_CHARS as Z, createSkillsReadTool as _, multiEdit as a, OperationTimeoutError as at, tailTruncate as b, grep as c, OUTPUT_RESERVE_TOKENS as ct, createAgent as d, stripImagesFromTurns as et, WAIT_TASK_TIMED_OUT_PREFIX as f, createSkillsRunScriptTool as g, createSkillsUseTool as h, readFile$1 as i, CompactPromptTooLongError as it, PERSISTENCE_PREVIEW_BYTES as j, validateToolArgs as k, glob as l, effectiveContextWindow as lt, createToolSearchTool as m, createSpawnTool as n, truncateHeadForPtlRetry as nt, listFiles as o, withTimeout as ot, waitTask as p, buildFromCompactPrompt as q, shellKill as r, CompactInvalidInputError as rt, createInteractionTool as s, AUTO_COMPACT_MIN_GROWTH_FRACTION as st, writeFile$1 as t, summaryToTurn as tt, edit as u, shouldAutoCompact as ut, createShellTool as v, stableStringify as w, defaultRepeatGuardNormalize as x, shell as y, selectFilesFromReadState as z };
10201
10258
 
10202
- //# sourceMappingURL=tools-BvATiiCO.js.map
10259
+ //# sourceMappingURL=tools-BwqbsLcJ.js.map