zidane 8.2.2 → 8.2.4

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 (168) hide show
  1. package/dist/{acp-oYRjlh71.js → acp-BIInKhVI.js} +6 -6
  2. package/dist/{acp-oYRjlh71.js.map → acp-BIInKhVI.js.map} +1 -1
  3. package/dist/acp-cli.js +4 -4
  4. package/dist/acp.d.ts +2 -2
  5. package/dist/acp.js +1 -1
  6. package/dist/{agent-CBQglXtH.js → agent-CmhCOmyO.js} +10 -5
  7. package/dist/{agent-CBQglXtH.js.map → agent-CmhCOmyO.js.map} +1 -1
  8. package/dist/agent.d.ts +1 -1
  9. package/dist/agent.js +1 -1
  10. package/dist/chat/pure.d.ts +4 -4
  11. package/dist/chat/pure.js +7 -7
  12. package/dist/chat.d.ts +3 -3
  13. package/dist/chat.js +16 -16
  14. package/dist/{cli-shared-E5m_pI8A.js → cli-shared-GOehTeqk.js} +2 -2
  15. package/dist/{cli-shared-E5m_pI8A.js.map → cli-shared-GOehTeqk.js.map} +1 -1
  16. package/dist/{client-core-BdD20sOv.d.ts → client-core-Dz8hELs4.d.ts} +15 -5
  17. package/dist/client-core-Dz8hELs4.d.ts.map +1 -0
  18. package/dist/codemode-worker.js +1 -1
  19. package/dist/codemode.js +1 -1
  20. package/dist/{connection-loop-DTk82YVl.d.ts → connection-loop-dm_TN-QD.d.ts} +3 -3
  21. package/dist/{connection-loop-DTk82YVl.d.ts.map → connection-loop-dm_TN-QD.d.ts.map} +1 -1
  22. package/dist/contexts/daytona.d.ts +1 -1
  23. package/dist/contexts/e2b.d.ts +1 -1
  24. package/dist/{credentials-B9DfBJP9.js → credentials-DxOQmset.js} +2 -2
  25. package/dist/{credentials-B9DfBJP9.js.map → credentials-DxOQmset.js.map} +1 -1
  26. package/dist/daemon-cli.js +2 -2
  27. package/dist/{dispatcher-BICXFGiJ.js → dispatcher-Dclv6HXn.js} +22 -18
  28. package/dist/dispatcher-Dclv6HXn.js.map +1 -0
  29. package/dist/{engine-QCX3GV-i.js → engine-C_U6kDfA.js} +6 -6
  30. package/dist/{engine-QCX3GV-i.js.map → engine-C_U6kDfA.js.map} +1 -1
  31. package/dist/{eval-CfQlBR81.js → eval-CIHIF_Ns.js} +3 -3
  32. package/dist/{eval-CfQlBR81.js.map → eval-CIHIF_Ns.js.map} +1 -1
  33. package/dist/eval.d.ts +1 -1
  34. package/dist/eval.js +1 -1
  35. package/dist/{executor-B8GoXaaE.js → executor-BFaR2nfc.js} +3 -3
  36. package/dist/{executor-B8GoXaaE.js.map → executor-BFaR2nfc.js.map} +1 -1
  37. package/dist/{extensions-BeH3D-bq.js → extensions-DIbpUj5R.js} +3 -3
  38. package/dist/{extensions-BeH3D-bq.js.map → extensions-DIbpUj5R.js.map} +1 -1
  39. package/dist/extensions.d.ts +1 -1
  40. package/dist/extensions.js +1 -1
  41. package/dist/{fold-rules-DSypi36k.d.ts → fold-rules-CMpWNPqk.d.ts} +2 -2
  42. package/dist/{fold-rules-DSypi36k.d.ts.map → fold-rules-CMpWNPqk.d.ts.map} +1 -1
  43. package/dist/{headless-R4pbpTkm.js → headless-Bs9Lb4vs.js} +4 -4
  44. package/dist/{headless-R4pbpTkm.js.map → headless-Bs9Lb4vs.js.map} +1 -1
  45. package/dist/headless.d.ts +1 -1
  46. package/dist/headless.js +1 -1
  47. package/dist/history-worker.js +1 -1
  48. package/dist/{host-scoped-settings-CCnaBkCV.js → host-scoped-settings-DxxI_yRo.js} +2 -2
  49. package/dist/{host-scoped-settings-CCnaBkCV.js.map → host-scoped-settings-DxxI_yRo.js.map} +1 -1
  50. package/dist/{host-signals-DI9JQvR9.js → host-signals-CQ2jZR-2.js} +5 -5
  51. package/dist/{host-signals-DI9JQvR9.js.map → host-signals-CQ2jZR-2.js.map} +1 -1
  52. package/dist/{index-DyQyDLX1.d.ts → index-4mDRyTGJ.d.ts} +1722 -1691
  53. package/dist/index-4mDRyTGJ.d.ts.map +1 -0
  54. package/dist/{index-lcuvhQfF.d.ts → index-Dlmu8HnG.d.ts} +5 -5
  55. package/dist/{index-lcuvhQfF.d.ts.map → index-Dlmu8HnG.d.ts.map} +1 -1
  56. package/dist/{index-BkNeiJYI.d.ts → index-QsAN9yjZ.d.ts} +3 -3
  57. package/dist/{index-BkNeiJYI.d.ts.map → index-QsAN9yjZ.d.ts.map} +1 -1
  58. package/dist/index.d.ts +3 -3
  59. package/dist/index.js +8 -8
  60. package/dist/ipc/remote.d.ts +5 -5
  61. package/dist/ipc/remote.js +3 -3
  62. package/dist/ipc.d.ts +5 -5
  63. package/dist/ipc.js +9 -9
  64. package/dist/{links-CN5JFFde.js → links-D5itfH8P.js} +10 -10
  65. package/dist/{links-CN5JFFde.js.map → links-D5itfH8P.js.map} +1 -1
  66. package/dist/{mcp-allowlist-BQ5MvhHi.js → mcp-allowlist-BbnTBKNN.js} +15 -4
  67. package/dist/mcp-allowlist-BbnTBKNN.js.map +1 -0
  68. package/dist/mcp.d.ts +1 -1
  69. package/dist/{oauth-TVPPye84.js → oauth-Ck3wQX4Q.js} +133 -43
  70. package/dist/oauth-Ck3wQX4Q.js.map +1 -0
  71. package/dist/output/stream-json.d.ts +1 -1
  72. package/dist/output/terminal.d.ts +1 -1
  73. package/dist/plugins.d.ts +1 -1
  74. package/dist/{prelude-HzY_JEGq.js → prelude-qjPUkw4f.js} +26 -2
  75. package/dist/prelude-qjPUkw4f.js.map +1 -0
  76. package/dist/{presets-DXeHsd24.js → presets-C4hkykN-.js} +2 -2
  77. package/dist/{presets-DXeHsd24.js.map → presets-C4hkykN-.js.map} +1 -1
  78. package/dist/presets.d.ts +1 -1
  79. package/dist/presets.js +1 -1
  80. package/dist/{protocol-BIv1Yuvl.js → protocol-Do_i6Ras.js} +3 -1
  81. package/dist/protocol-Do_i6Ras.js.map +1 -0
  82. package/dist/providers/anthropic.d.ts +1 -1
  83. package/dist/providers/arcee.d.ts +1 -1
  84. package/dist/providers/baseten.d.ts +1 -1
  85. package/dist/providers/cerebras.d.ts +1 -1
  86. package/dist/providers/google.d.ts +1 -1
  87. package/dist/providers/local.d.ts +1 -1
  88. package/dist/providers/neuralwatt.d.ts +1 -1
  89. package/dist/providers/openai-compat.d.ts +1 -1
  90. package/dist/providers/openai.d.ts +1 -1
  91. package/dist/providers/openrouter.d.ts +1 -1
  92. package/dist/providers/xai.d.ts +1 -1
  93. package/dist/providers.d.ts +1 -1
  94. package/dist/{registry-PNi9rsGi.js → registry-DxPP_tAt.js} +3 -3
  95. package/dist/{registry-PNi9rsGi.js.map → registry-DxPP_tAt.js.map} +1 -1
  96. package/dist/{remote-hosts-b6Luwdhu.js → remote-hosts-BkOwRszu.js} +4 -4
  97. package/dist/{remote-hosts-b6Luwdhu.js.map → remote-hosts-BkOwRszu.js.map} +1 -1
  98. package/dist/restate.d.ts +1 -1
  99. package/dist/{secret-shapes-CEoGmfEE.js → secret-shapes-HvaYVzwc.js} +17 -4
  100. package/dist/secret-shapes-HvaYVzwc.js.map +1 -0
  101. package/dist/session/sqlite.d.ts +1 -1
  102. package/dist/{session-7TUHs42_.js → session-CCsKXID6.js} +6 -2
  103. package/dist/session-CCsKXID6.js.map +1 -0
  104. package/dist/{session-factory-CMwIXE-7.js → session-factory-Ct7J9CK1.js} +6 -6
  105. package/dist/{session-factory-CMwIXE-7.js.map → session-factory-Ct7J9CK1.js.map} +1 -1
  106. package/dist/session.d.ts +2 -2
  107. package/dist/session.js +1 -1
  108. package/dist/{settings-keys-DssjmqAV.js → settings-keys-QoGJ5n3e.js} +4 -4
  109. package/dist/{settings-keys-DssjmqAV.js.map → settings-keys-QoGJ5n3e.js.map} +1 -1
  110. package/dist/{shell-path-BUFwqU_A.js → shell-path-BXXtRmEA.js} +4 -4
  111. package/dist/{shell-path-BUFwqU_A.js.map → shell-path-BXXtRmEA.js.map} +1 -1
  112. package/dist/skills.d.ts +1 -1
  113. package/dist/{spaces-CyjMh5Zf.js → spaces-C_x2bvEl.js} +14 -4
  114. package/dist/spaces-C_x2bvEl.js.map +1 -0
  115. package/dist/{store-L01W0gGI.js → store-BpkWIaSH.js} +10 -30
  116. package/dist/store-BpkWIaSH.js.map +1 -0
  117. package/dist/{todo-edits-H77ROt6X.js → todo-edits-DKoxu7Ss.js} +3 -3
  118. package/dist/{todo-edits-H77ROt6X.js.map → todo-edits-DKoxu7Ss.js.map} +1 -1
  119. package/dist/tools/fetch-url.d.ts +1 -1
  120. package/dist/tools/web-search.d.ts +1 -1
  121. package/dist/{tools-pZVFIJ_K.js → tools-FHEIKGkh.js} +2 -2
  122. package/dist/{tools-pZVFIJ_K.js.map → tools-FHEIKGkh.js.map} +1 -1
  123. package/dist/tools.d.ts +1 -1
  124. package/dist/tools.js +2 -2
  125. package/dist/{transcript-anchors-s-yxh0jt.js → transcript-anchors-D8jWLpe5.js} +10 -10
  126. package/dist/{transcript-anchors-s-yxh0jt.js.map → transcript-anchors-D8jWLpe5.js.map} +1 -1
  127. package/dist/{transcript-cache-DXdgVuoy.js → transcript-cache-CdHKtx9y.js} +4 -4
  128. package/dist/{transcript-cache-DXdgVuoy.js.map → transcript-cache-CdHKtx9y.js.map} +1 -1
  129. package/dist/{transcript-reconcile-DeFLIQ14.js → transcript-reconcile-D_SWw6dX.js} +11 -3
  130. package/dist/transcript-reconcile-D_SWw6dX.js.map +1 -0
  131. package/dist/tui.d.ts +7 -7
  132. package/dist/tui.js +24 -23
  133. package/dist/tui.js.map +1 -1
  134. package/dist/{turn-operations-BbGJ-KSt.d.ts → turn-operations-Dbk3xPKu.d.ts} +19 -4
  135. package/dist/turn-operations-Dbk3xPKu.d.ts.map +1 -0
  136. package/dist/{types-C0PJmBaO.d.ts → types-CMXR7A0b.d.ts} +2 -2
  137. package/dist/{types-C0PJmBaO.d.ts.map → types-CMXR7A0b.d.ts.map} +1 -1
  138. package/dist/types-CzmghX7C.js.map +1 -1
  139. package/dist/types.d.ts +2 -2
  140. package/dist/{url-CLl0u4Z8.js → url-D4vG7lzO.js} +2 -2
  141. package/dist/{url-CLl0u4Z8.js.map → url-D4vG7lzO.js.map} +1 -1
  142. package/dist/{version-v77Y4A3C.js → version-DDRBX7K6.js} +2 -2
  143. package/dist/{version-v77Y4A3C.js.map → version-DDRBX7K6.js.map} +1 -1
  144. package/dist/{workspace-exec-stream-kqARO8iC.js → workspace-exec-stream-iHv9cooF.js} +5 -5
  145. package/dist/{workspace-exec-stream-kqARO8iC.js.map → workspace-exec-stream-iHv9cooF.js.map} +1 -1
  146. package/dist/{write-file-QYrcDdl3.js → write-file-ChtRPdEL.js} +3 -3
  147. package/dist/{write-file-QYrcDdl3.js.map → write-file-ChtRPdEL.js.map} +1 -1
  148. package/dist/{ws-BD9FN98u.js → ws-B2HB87nz.js} +6 -6
  149. package/dist/{ws-BD9FN98u.js.map → ws-B2HB87nz.js.map} +1 -1
  150. package/dist/{ws-client-D7eb2UbH.js → ws-client-DPC9ZJHr.js} +4 -4
  151. package/dist/{ws-client-D7eb2UbH.js.map → ws-client-DPC9ZJHr.js.map} +1 -1
  152. package/docs/CODEMODE.md +6 -0
  153. package/docs/IPC.md +2 -0
  154. package/docs/ONBOARDING.md +1 -1
  155. package/package.json +1 -1
  156. package/dist/client-core-BdD20sOv.d.ts.map +0 -1
  157. package/dist/dispatcher-BICXFGiJ.js.map +0 -1
  158. package/dist/index-DyQyDLX1.d.ts.map +0 -1
  159. package/dist/mcp-allowlist-BQ5MvhHi.js.map +0 -1
  160. package/dist/oauth-TVPPye84.js.map +0 -1
  161. package/dist/prelude-HzY_JEGq.js.map +0 -1
  162. package/dist/protocol-BIv1Yuvl.js.map +0 -1
  163. package/dist/secret-shapes-CEoGmfEE.js.map +0 -1
  164. package/dist/session-7TUHs42_.js.map +0 -1
  165. package/dist/spaces-CyjMh5Zf.js.map +0 -1
  166. package/dist/store-L01W0gGI.js.map +0 -1
  167. package/dist/transcript-reconcile-DeFLIQ14.js.map +0 -1
  168. package/dist/turn-operations-BbGJ-KSt.d.ts.map +0 -1
@@ -1,4 +1,4 @@
1
- import { Fa as Agent, ai as HeadlessResult, ei as FormattedHeadlessResult, ii as HeadlessOutputFormat, ri as HeadlessEvent, ti as FormattedHeadlessTurnEvent } from "../index-DyQyDLX1.js";
1
+ import { Fa as Agent, ai as HeadlessResult, ei as FormattedHeadlessResult, ii as HeadlessOutputFormat, ri as HeadlessEvent, ti as FormattedHeadlessTurnEvent } from "../index-4mDRyTGJ.js";
2
2
  //#region src/output/stream-json.d.ts
3
3
  /** Line shape: `zidane` event envelopes or raw `provider` messages. */
4
4
  type StreamJsonOutputFormat = HeadlessOutputFormat;
@@ -1,4 +1,4 @@
1
- import { Fa as Agent, Sa as Preset, nx as AgentHooks } from "../index-DyQyDLX1.js";
1
+ import { Fa as Agent, Sa as Preset, rx as AgentHooks } from "../index-4mDRyTGJ.js";
2
2
  //#region src/output/terminal.d.ts
3
3
  /** Options for {@link setupTerminalOutput}. */
4
4
  interface TerminalOutputOptions {
package/dist/plugins.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { Ad as PluginManifest, Cd as loadAgentPlugin, Dd as PluginAuthor, Ed as LoadedPlugin, Fd as parseSchemaId, Md as SUPPORTED_AGENT_PLUGINS_VERSIONS, Nd as agentPluginsSchemaId, Od as PluginComponentStatus, Pd as isSupportedAgentPluginsVersion, Sd as defaultPluginDataRoot, Td as LoadAgentPluginOptions, _d as expandPluginVars, bd as validatePluginManifest, gd as PLUGIN_MCP_FILE, hd as PLUGIN_SKILLS_DIR, jd as PluginSchemaKind, kd as PluginDiagnostic, vd as ManifestValidation, wd as AgentPluginsVersion, xd as PLUGIN_MANIFEST_FILE, yd as parsePluginManifest } from "./index-DyQyDLX1.js";
1
+ import { Ad as PluginManifest, Cd as loadAgentPlugin, Dd as PluginAuthor, Ed as LoadedPlugin, Fd as parseSchemaId, Md as SUPPORTED_AGENT_PLUGINS_VERSIONS, Nd as agentPluginsSchemaId, Od as PluginComponentStatus, Pd as isSupportedAgentPluginsVersion, Sd as defaultPluginDataRoot, Td as LoadAgentPluginOptions, _d as expandPluginVars, bd as validatePluginManifest, gd as PLUGIN_MCP_FILE, hd as PLUGIN_SKILLS_DIR, jd as PluginSchemaKind, kd as PluginDiagnostic, vd as ManifestValidation, wd as AgentPluginsVersion, xd as PLUGIN_MANIFEST_FILE, yd as parsePluginManifest } from "./index-4mDRyTGJ.js";
2
2
  export { type AgentPluginsVersion, type LoadAgentPluginOptions, type LoadedPlugin, type ManifestValidation, PLUGIN_MANIFEST_FILE, PLUGIN_MCP_FILE, PLUGIN_SKILLS_DIR, type PluginAuthor, type PluginComponentStatus, type PluginDiagnostic, type PluginManifest, type PluginSchemaKind, SUPPORTED_AGENT_PLUGINS_VERSIONS, agentPluginsSchemaId, defaultPluginDataRoot, expandPluginVars, isSupportedAgentPluginsVersion, loadAgentPlugin, parsePluginManifest, parseSchemaId, validatePluginManifest };
@@ -23,7 +23,7 @@ const IMAGE_HELPER_EXPECTS = "image expects a non-empty image URL string, an obj
23
23
  * as JSON strings and are parsed on this side.
24
24
  *
25
25
  * Output helpers: `text(value)` appends a text item (a tool result prints as the text a direct
26
- * call returns, other non-strings are JSON-stringified), `image(urlOrItem)` appends an image from a base64 `data:` URL, an
26
+ * call returns and attaches the images it holds, other non-strings are JSON-stringified), `image(urlOrItem)` appends an image from a base64 `data:` URL, an
27
27
  * `{ image_url }` object, or an MCP `ImageContent` block, and `exit()` ends the script
28
28
  * successfully. `console.*` appends text items marked as console output.
29
29
  *
@@ -152,6 +152,8 @@ const PRELUDE_SOURCE = `(function (bridge, toolsJson, globalsJson, storeJson, hi
152
152
  const pending = new Map();
153
153
  // What a tool result prints as (the text a direct call returns), keyed by the value the script got.
154
154
  const printedText = new WeakMap();
155
+ // Image blocks already attached, so printing a result twice (text(r) then return r) sends each once.
156
+ const emittedImages = new WeakSet();
155
157
  let nextId = 1;
156
158
  let finished = false;
157
159
  // Thrown by exit() to unwind the script after it already reported success.
@@ -178,6 +180,25 @@ const PRELUDE_SOURCE = `(function (bridge, toolsJson, globalsJson, storeJson, hi
178
180
  return [head, ...frames].join("\\n");
179
181
  }
180
182
 
183
+ // The images a printed tool result holds (MCP image blocks in its value), an array of results' in order.
184
+ function printedImages(value) {
185
+ if (value === null || typeof value !== "object" || !Array.isArray(value)) return [];
186
+ if (printedText.has(value)) {
187
+ return value.filter(
188
+ (item) => item !== null && typeof item === "object" && item.type === "image" && typeof item.data === "string",
189
+ );
190
+ }
191
+ return value.flatMap((item) => (item !== null && typeof item === "object" && printedText.has(item) ? printedImages(item) : []));
192
+ }
193
+
194
+ function outputImages(value) {
195
+ for (const block of printedImages(value)) {
196
+ if (emittedImages.has(block)) continue;
197
+ emittedImages.add(block);
198
+ output("image", block.data, block.mimeType);
199
+ }
200
+ }
201
+
181
202
  // A tool result prints as its text, an array holding tool results (and strings) as sections.
182
203
  function printable(value) {
183
204
  if (value === null || typeof value !== "object") return undefined;
@@ -428,6 +449,7 @@ const PRELUDE_SOURCE = `(function (bridge, toolsJson, globalsJson, storeJson, hi
428
449
  throw new TypeErrorCtor(error instanceof ErrorCtor ? error.message : String(error));
429
450
  }
430
451
  output("text", rendered);
452
+ outputImages(value);
431
453
  }
432
454
 
433
455
  function imageUrl(value) {
@@ -501,6 +523,7 @@ const PRELUDE_SOURCE = `(function (bridge, toolsJson, globalsJson, storeJson, hi
501
523
  for (const level of ["log", "info", "warn", "error", "debug"]) {
502
524
  console[level] = (...args) => {
503
525
  output("console", args.map(format).join(" "));
526
+ for (const arg of args) outputImages(arg);
504
527
  };
505
528
  }
506
529
  Object.freeze(console);
@@ -550,6 +573,7 @@ const PRELUDE_SOURCE = `(function (bridge, toolsJson, globalsJson, storeJson, hi
550
573
  try {
551
574
  const printed = printable(value);
552
575
  json = serialize(printed === undefined ? value : printed);
576
+ if (printed !== undefined) outputImages(value);
553
577
  } catch (error) {
554
578
  done(false, describeError(error));
555
579
  return;
@@ -578,4 +602,4 @@ const PRELUDE_SOURCE = `(function (bridge, toolsJson, globalsJson, storeJson, hi
578
602
  //#endregion
579
603
  export { PRELUDE_SOURCE as a, MAX_STORE_VALUE_CHARS as i, MAX_OUTPUT_ITEMS as n, MAX_STORE_TOTAL_CHARS as r, MAX_OUTPUT_CHARS as t };
580
604
 
581
- //# sourceMappingURL=prelude-HzY_JEGq.js.map
605
+ //# sourceMappingURL=prelude-qjPUkw4f.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prelude-qjPUkw4f.js","names":[],"sources":["../src/codemode/runtime/prelude.ts"],"sourcesContent":["// Ported from @earendil-works/pi-codemode (MIT, Earendil Works). Owned here so\n// it can diverge; keep behavior changes covered by test/codemode.\n/** Maximum size, in characters of JSON, of one value a script writes with `store()`. */\nexport const MAX_STORE_VALUE_CHARS = 256 * 1024\n/** Maximum total size, in characters of JSON, of all values a script writes with `store()` in one execution. */\nexport const MAX_STORE_TOTAL_CHARS = 1024 * 1024\n/**\n * Output one script may produce with `text()`, `image()`, and `console.*`: characters of text and\n * base64 image data, and items. The host keeps all output until the script ends, so without a\n * limit a script that prints in a loop grows the host's memory until it crashes. The item limit\n * covers loops that print empty strings.\n */\nexport const MAX_OUTPUT_CHARS = 16 * 1024 * 1024\n/** Maximum number of output items one script may produce. */\nexport const MAX_OUTPUT_ITEMS = 100_000\n\nconst IMAGE_HELPER_EXPECTS\n = 'image expects a non-empty image URL string, an object with image_url, or a raw MCP image block'\n\n/**\n * JavaScript evaluated inside the QuickJS VM before the script runs.\n *\n * The VM is its own wasm instance, so nothing here guards a realm boundary.\n * The prelude keeps the host bridge in a closure so the script cannot call it\n * directly, and builds `tools`, `ALL_TOOLS`, the output helpers (`text`, `image`,\n * `exit`, `console`), and globals on top of it. Tool arguments and results cross\n * as JSON strings and are parsed on this side.\n *\n * Output helpers: `text(value)` appends a text item (a tool result prints as the text a direct\n * call returns and attaches the images it holds, other non-strings are JSON-stringified), `image(urlOrItem)` appends an image from a base64 `data:` URL, an\n * `{ image_url }` object, or an MCP `ImageContent` block, and `exit()` ends the script\n * successfully. `console.*` appends text items marked as console output.\n *\n * `store(key, value)` and `load(key)` are synchronous: they work on a snapshot of\n * JSON text passed in as `storeJson`, and the keys the script wrote are reported\n * with a successful \"done\".\n *\n * Evaluates to a function `(bridge, toolsJson, globalsJson, storeJson, hintsJson, shortcutsJson) => { settle, run, stalled }`.\n * `toolsJson` lists `{ name, jsName, description, stringArg? }`: `tools[jsName]` and `tools[name]` call the\n * tool, a bare string argument fills `stringArg`, and `ALL_TOOLS` lists `{ name: jsName, description }`.\n * `shortcutsJson` maps global function names to tool names (`{ sh: \"shell\" }`).\n * `settle(id, ok, payload, text)` resolves a call; `text`, when given, is what printing the value shows.\n * `stalled()` reports a script that has not finished while no host call is pending: with no timers\n * or I/O in the VM, nothing can ever resume it.\n * `globalsJson` lists `{ name, spread }`; `a.b` names are grouped into a frozen `a` object.\n * `bridge(kind, a, b, c)` with kind \"call\" or \"global\" (id, name, argsJson),\n * \"output\" (\"text\" or \"console\", text) or (\"image\", data, mimeType), or \"done\" (ok, valueJsonOrErrorJson, writesJson).\n *\n * Calls get ids from one counter shared by tools and globals, in issue order: the host exposes\n * them as `CodemodeToolContext.seq`.\n *\n * Before anything else the prelude freezes the built-ins and makes the built-in globals read-only.\n * The prelude shares them with the script, so a script that patched one (for example\n * `Array.prototype.toJSON`) could otherwise corrupt what the prelude reports to the host.\n */\nexport const PRELUDE_SOURCE: string = `(function (bridge, toolsJson, globalsJson, storeJson, hintsJson, shortcutsJson) {\n \"use strict\";\n\n // Freeze every object reachable from the built-in globals, plus the intrinsics that are only\n // reachable from instances (iterator and generator prototypes, %TypedArray%).\n //\n // Freezing alone breaks ordinary code through the \"override mistake\": a data property that is\n // read-only on a prototype cannot be assigned on an instance either, so\n // this.name = \"MyError\" in an Error subclass would throw. Commonly overridden properties\n // become accessors whose setter defines an own property on the instance instead.\n (function lockdown() {\n const OVERRIDABLE = new Set([\"constructor\", \"name\", \"message\", \"toString\", \"toLocaleString\", \"valueOf\", \"toJSON\"]);\n const seen = new Set([globalThis]);\n const queue = [];\n const add = (value) => {\n if ((typeof value === \"object\" && value !== null) || typeof value === \"function\") {\n if (!seen.has(value)) {\n seen.add(value);\n queue.push(value);\n }\n }\n };\n\n // Accessors from an object literal have no own prototype object, unlike function expressions,\n // whose prototype.constructor would be converted again without end.\n function allowOverride(object, key, value, enumerable) {\n const { get, set } = Object.getOwnPropertyDescriptor(\n {\n get accessor() {\n return value;\n },\n set accessor(next) {\n if (this === object) {\n throw new TypeError(\"Cannot assign to read only property '\" + String(key) + \"' of a built-in\");\n }\n if ((typeof this !== \"object\" || this === null) && typeof this !== \"function\") return;\n Object.defineProperty(this, key, { value: next, writable: true, enumerable: true, configurable: true });\n },\n },\n \"accessor\",\n );\n Object.defineProperty(object, key, { get, set, enumerable, configurable: false });\n add(get);\n add(set);\n }\n\n for (const key of Reflect.ownKeys(globalThis)) {\n const descriptor = Object.getOwnPropertyDescriptor(globalThis, key);\n add(descriptor.value);\n add(descriptor.get);\n add(descriptor.set);\n if (\"value\" in descriptor && descriptor.configurable) {\n Object.defineProperty(globalThis, key, { writable: false, configurable: false });\n }\n }\n add(Object.getPrototypeOf(function* () {}));\n add(Object.getPrototypeOf(async function () {}));\n add(Object.getPrototypeOf(async function* () {}));\n add(Object.getPrototypeOf(Int8Array));\n add(Object.getPrototypeOf([][Symbol.iterator]()));\n add(Object.getPrototypeOf(new Map()[Symbol.iterator]()));\n add(Object.getPrototypeOf(new Set()[Symbol.iterator]()));\n add(Object.getPrototypeOf(\"\"[Symbol.iterator]()));\n add(Object.getPrototypeOf(/a/[Symbol.matchAll](\"\")));\n if (typeof Iterator === \"function\") {\n if (typeof Iterator.prototype.map === \"function\") add(Object.getPrototypeOf([].values().map((x) => x)));\n if (typeof Iterator.from === \"function\") add(Object.getPrototypeOf(Iterator.from({ next() {} })));\n }\n\n while (queue.length > 0) {\n const object = queue.pop();\n add(Object.getPrototypeOf(object));\n const descriptors = Object.getOwnPropertyDescriptors(object);\n for (const key of Reflect.ownKeys(descriptors)) {\n const descriptor = descriptors[key];\n if (\"value\" in descriptor) {\n add(descriptor.value);\n if (\n descriptor.writable &&\n descriptor.configurable &&\n (object === Object.prototype || OVERRIDABLE.has(key))\n ) {\n allowOverride(object, key, descriptor.value, descriptor.enumerable);\n }\n } else {\n add(descriptor.get);\n add(descriptor.set);\n }\n }\n Object.freeze(object);\n }\n })();\n const stringify = JSON.stringify;\n const parse = JSON.parse;\n const defineProperty = Object.defineProperty;\n const TO_PRIMITIVE = Symbol.toPrimitive;\n const promiseThen = Promise.prototype.then;\n const ErrorCtor = Error;\n const TypeErrorCtor = TypeError;\n const RangeErrorCtor = RangeError;\n const pending = new Map();\n // What a tool result prints as (the text a direct call returns), keyed by the value the script got.\n const printedText = new WeakMap();\n // Image blocks already attached, so printing a result twice (text(r) then return r) sends each once.\n const emittedImages = new WeakSet();\n let nextId = 1;\n let finished = false;\n // Thrown by exit() to unwind the script after it already reported success.\n const EXIT = Object.freeze({});\n\n function done(ok, payload, writes) {\n if (finished) return;\n finished = true;\n bridge(\"done\", ok, payload, writes);\n }\n\n function serialize(value) {\n return value === undefined ? undefined : stringify(value);\n }\n\n // QuickJS stacks list frames only. Prefix \"Name: message\" like V8 so the\n // text reads the same as a Node error, and drop this prelude's frames.\n function errorText(error) {\n const head = error.message ? error.name + \": \" + error.message : String(error.name);\n const frames =\n typeof error.stack === \"string\"\n ? error.stack.split(\"\\\\n\").filter((line) => line.trim() && !line.includes(\"codemode-prelude.js\"))\n : [];\n return [head, ...frames].join(\"\\\\n\");\n }\n\n // The images a printed tool result holds (MCP image blocks in its value), an array of results' in order.\n function printedImages(value) {\n if (value === null || typeof value !== \"object\" || !Array.isArray(value)) return [];\n if (printedText.has(value)) {\n return value.filter(\n (item) => item !== null && typeof item === \"object\" && item.type === \"image\" && typeof item.data === \"string\",\n );\n }\n return value.flatMap((item) => (item !== null && typeof item === \"object\" && printedText.has(item) ? printedImages(item) : []));\n }\n\n function outputImages(value) {\n for (const block of printedImages(value)) {\n if (emittedImages.has(block)) continue;\n emittedImages.add(block);\n output(\"image\", block.data, block.mimeType);\n }\n }\n\n // A tool result prints as its text, an array holding tool results (and strings) as sections.\n function printable(value) {\n if (value === null || typeof value !== \"object\") return undefined;\n if (printedText.has(value)) return printedText.get(value);\n if (!Array.isArray(value)) return undefined;\n const parts = [];\n let results = 0;\n for (const item of value) {\n if (typeof item === \"string\") {\n parts.push(item);\n } else if (item !== null && typeof item === \"object\" && printedText.has(item)) {\n parts.push(printedText.get(item));\n results++;\n } else {\n return undefined;\n }\n }\n return results > 0 ? parts.join(\"\\\\n\\\\n\") : undefined;\n }\n\n function format(value) {\n if (typeof value === \"string\") return value;\n if (value instanceof ErrorCtor) return errorText(value);\n const printed = printable(value);\n if (printed !== undefined) return printed;\n try {\n const json = stringify(value);\n return json === undefined ? String(value) : json;\n } catch {\n return String(value);\n }\n }\n\n // The host requires string fields. A script can set an error's name or message to anything, so\n // they are coerced, and a value whose coercion throws gets a placeholder.\n function describeError(error) {\n try {\n if (error instanceof ErrorCtor) {\n return stringify({ name: String(error.name), message: String(error.message), stack: errorText(error) });\n }\n return stringify({ message: String(format(error)) });\n } catch {\n return stringify({ message: \"The script threw a value that cannot be described\" });\n }\n }\n\n function caller(kind, name, spread) {\n return (...args) =>\n new Promise((resolve, reject) => {\n let json;\n try {\n json = serialize(spread ? args : args[0]);\n } catch (error) {\n reject(error);\n return;\n }\n const id = nextId++;\n pending.set(id, { resolve, reject });\n bridge(kind, id, name, json);\n });\n }\n\n const tools = Object.create(null);\n const allTools = [];\n // tools.shell(\"ls\", { timeout: 5000 }) is tools.shell({ timeout: 5000, command: \"ls\" }).\n function withStringArg(key, value, rest) {\n const input = {};\n if (rest !== null && typeof rest === \"object\" && !Array.isArray(rest)) {\n for (const restKey of Object.keys(rest)) input[restKey] = rest[restKey];\n }\n input[key] = value;\n return input;\n }\n\n for (const { name, jsName, description, stringArg } of parse(toolsJson)) {\n const call = caller(\"call\", name);\n const fn = stringArg === undefined\n ? call\n : (args, rest) => call(typeof args === \"string\" ? withStringArg(stringArg, args, rest) : args);\n // The first tool wins when two names normalize to the same identifier.\n if (!(jsName in tools)) {\n tools[jsName] = fn;\n allTools.push(Object.freeze({ name: jsName, description }));\n }\n if (!(name in tools)) tools[name] = fn;\n }\n Object.freeze(tools);\n Object.freeze(allTools);\n\n // Reading a member that does not exist throws an error that names the close matches, instead of\n // a later \"not a function\". \\`in\\` checks still work.\n const comparable = (name) => name.toLowerCase().replace(/[^a-z0-9]/g, \"\");\n function guard(target, label, names, hint, missingHints) {\n return new Proxy(target, {\n get(object, property, receiver) {\n if (typeof property !== \"string\" || property in object || property in Object.prototype || property === \"then\" || property === \"toJSON\") {\n return Reflect.get(object, property, receiver);\n }\n // A tool the host knows but keeps out of scripts (spawn, call_tool, ...): its own advice.\n if (missingHints && Object.prototype.hasOwnProperty.call(missingHints, property)) {\n throw new TypeErrorCtor(label + \".\" + property + \" is not available in scripts. \" + missingHints[property]);\n }\n const wanted = comparable(property);\n const exact = names.filter((name) => comparable(name) === wanted);\n const close = exact.length > 0 ? exact : names.filter((name) => wanted && (comparable(name).includes(wanted) || wanted.includes(comparable(name))));\n let message = label + \".\" + property + \" does not exist.\";\n if (close.length > 0) message += \" Did you mean \" + close.slice(0, 5).map((name) => label + \".\" + name).join(\", \") + \"?\";\n else if (names.length <= 20) message += \" Available: \" + names.join(\", \") + \".\";\n if (hint) message += \" \" + hint;\n message += ' Check for a member with \"' + property + '\" in ' + label + \".\";\n throw new TypeErrorCtor(message);\n },\n });\n }\n const toolsProxy = guard(\n tools,\n \"tools\",\n allTools.map((tool) => tool.name),\n \"ALL_TOOLS lists every tool; searchTools(query) finds tools by topic.\",\n hintsJson ? parse(hintsJson) : undefined,\n );\n\n const namespaces = new Map();\n for (const { name, spread } of parse(globalsJson)) {\n const fn = caller(\"global\", name, spread);\n const dot = name.indexOf(\".\");\n if (dot === -1) {\n Object.defineProperty(globalThis, name, { value: fn, enumerable: true });\n continue;\n }\n const namespace = name.slice(0, dot);\n if (!namespaces.has(namespace)) namespaces.set(namespace, Object.create(null));\n namespaces.get(namespace)[name.slice(dot + 1)] = fn;\n }\n for (const [namespace, members] of namespaces) {\n Object.freeze(members);\n const value = guard(members, namespace, Object.keys(members));\n Object.defineProperty(globalThis, namespace, { value, enumerable: true });\n }\n\n // sh(\"ls\") is tools.shell(\"ls\"): the same call, recorded the same way.\n for (const [alias, target] of Object.entries(parse(shortcutsJson || \"{}\"))) {\n if (!Object.prototype.hasOwnProperty.call(tools, target) || alias in globalThis) continue;\n const fn = tools[target];\n Object.defineProperty(globalThis, alias, { value: (...args) => fn(...args), enumerable: true });\n }\n\n // key -> JSON text. Sizes count key and JSON characters.\n const stored = new Map(Object.entries(parse(storeJson)));\n const writes = new Map();\n let storedChars = 0;\n for (const [key, json] of stored) storedChars += key.length + json.length;\n\n const STORE_HINT =\n \"store() is for small state such as IDs or summaries. Show images with image(), keep large data in variables, or write it to a file with a tool.\";\n\n function checkKey(name, key) {\n if (typeof key !== \"string\") throw new TypeError(name + \"() key must be a string\");\n }\n\n function store(key, value) {\n checkKey(\"store\", key);\n const previous = stored.has(key) ? key.length + stored.get(key).length : 0;\n if (value === undefined) {\n stored.delete(key);\n storedChars -= previous;\n writes.set(key, undefined);\n return;\n }\n let json;\n try {\n json = stringify(value);\n } catch (error) {\n throw new TypeError(\"store(\" + stringify(key) + \") value is not JSON-serializable: \" + format(error));\n }\n if (json === undefined) {\n throw new TypeError(\"store(\" + stringify(key) + \") value is not JSON-serializable\");\n }\n if (json.length > ${MAX_STORE_VALUE_CHARS}) {\n throw new RangeError(\n \"store(\" + stringify(key) + \") value has \" + json.length + \" characters of JSON, more than the limit of ${MAX_STORE_VALUE_CHARS}. \" +\n STORE_HINT,\n );\n }\n const next = storedChars - previous + key.length + json.length;\n if (next > ${MAX_STORE_TOTAL_CHARS}) {\n throw new RangeError(\n \"store is full: stored values would exceed ${MAX_STORE_TOTAL_CHARS} characters of JSON. Delete keys with store(key, undefined). \" +\n STORE_HINT,\n );\n }\n stored.set(key, json);\n storedChars = next;\n writes.set(key, json);\n }\n\n function load(key) {\n checkKey(\"load\", key);\n const json = stored.get(key);\n return json === undefined ? undefined : parse(json);\n }\n\n function serializeWrites() {\n const entries = [];\n for (const [key, json] of writes) entries.push(json === undefined ? [key] : [key, json]);\n return stringify(entries);\n }\n\n Object.defineProperty(globalThis, \"store\", { value: store, enumerable: true });\n Object.defineProperty(globalThis, \"load\", { value: load, enumerable: true });\n\n let outputChars = 0;\n let outputItems = 0;\n\n // Past the output limits the script fails: done() reports the error, so catching it does not\n // resume output, and the host ends the script.\n function output(kind, data, mimeType) {\n if (finished) return;\n outputChars += data.length;\n outputItems++;\n if (outputChars > ${MAX_OUTPUT_CHARS} || outputItems > ${MAX_OUTPUT_ITEMS}) {\n const error = new RangeErrorCtor(\n \"script output exceeded the limit of ${MAX_OUTPUT_CHARS} characters or ${MAX_OUTPUT_ITEMS} text(), image(), and console calls. \" +\n \"Print a summary instead, or write large data to a file with a tool.\",\n );\n done(false, describeError(error));\n throw error;\n }\n bridge(\"output\", kind, data, mimeType);\n }\n\n // Primitives become their string form, everything else JSON.\n function outputText(value) {\n if (value === undefined || value === null || typeof value !== \"object\" && typeof value !== \"function\") {\n return String(value);\n }\n const printed = printable(value);\n if (printed !== undefined) return printed;\n const json = stringify(value);\n return json === undefined ? String(value) : json;\n }\n\n function text(value) {\n let rendered;\n try {\n rendered = outputText(value);\n } catch (error) {\n throw new TypeErrorCtor(error instanceof ErrorCtor ? error.message : String(error));\n }\n output(\"text\", rendered);\n outputImages(value);\n }\n\n function imageUrl(value) {\n if (typeof value === \"string\") return value;\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n throw new TypeErrorCtor(${JSON.stringify(IMAGE_HELPER_EXPECTS)});\n }\n if (value.image_url !== undefined) {\n if (typeof value.image_url !== \"string\") throw new TypeErrorCtor(${JSON.stringify(IMAGE_HELPER_EXPECTS)});\n return value.image_url;\n }\n if (typeof value.type !== \"string\") throw new TypeErrorCtor(${JSON.stringify(IMAGE_HELPER_EXPECTS)});\n if (value.type !== \"image\") {\n throw new TypeErrorCtor('image only accepts MCP image blocks, got \"' + value.type + '\"');\n }\n if (typeof value.data !== \"string\" || value.data === \"\") throw new TypeErrorCtor(\"image expected MCP image data\");\n if (value.data.toLowerCase().startsWith(\"data:\")) return value.data;\n return \"data:;base64,\" + value.data;\n }\n\n // Base64 of the signatures of the formats providers accept inline (PNG, JPEG except\n // JPEG-LS, GIF, \"RIFF....WEBP\"). Signatures start at byte 0, so their encodings are prefixes.\n const IMAGE_SIGNATURES = [\n [\"image/png\", /^iVBORw0KGg/],\n [\"image/jpeg\", /^[/]9j[/](?!9)/],\n [\"image/gif\", /^R0lGOD[dl]h/],\n [\"image/webp\", /^UklG.{8}RUJQ/],\n ];\n\n function image(value) {\n const url = imageUrl(value);\n if (url === \"\") throw new TypeErrorCtor(${JSON.stringify(IMAGE_HELPER_EXPECTS)});\n const colon = url.indexOf(\":\");\n const scheme = colon === -1 ? \"\" : url.slice(0, colon).toLowerCase();\n if (scheme === \"http\" || scheme === \"https\") {\n throw new TypeErrorCtor(\"remote image URLs are not supported in tool outputs. Pass a base64 data URI instead\");\n }\n const comma = url.indexOf(\",\");\n const header = comma === -1 ? [] : url.slice(colon + 1, comma).split(\";\");\n if (scheme !== \"data\" || comma === -1 || header.slice(1).every((part) => part.toLowerCase() !== \"base64\")) {\n throw new TypeErrorCtor(\"invalid image output. Pass a base64 data URI instead\");\n }\n // Providers reject the whole request on a bad image, and a persisted image block would be\n // resent on every later turn. Line breaks from wrapped base64 are dropped. The declared type\n // is ignored in favor of the detected one, as providers also reject mismatches.\n const data = url.slice(comma + 1).replace(/\\\\s+/g, \"\");\n if (data.length % 4 !== 0 || !/^[A-Za-z0-9+/]+={0,2}$/.test(data)) {\n throw new TypeErrorCtor(\"invalid image output. The image data is not valid base64 (truncated or corrupted?)\");\n }\n const head = data.slice(0, 16);\n const signature = IMAGE_SIGNATURES.find(([, pattern]) => pattern.test(head));\n if (!signature) {\n throw new TypeErrorCtor(\"invalid image output. The image data is not a PNG, JPEG, GIF, or WebP image\");\n }\n output(\"image\", data, signature[0]);\n }\n\n function exit() {\n let writesJson;\n try {\n writesJson = serializeWrites();\n } catch (error) {\n done(false, describeError(error));\n throw EXIT;\n }\n done(true, undefined, writesJson);\n throw EXIT;\n }\n\n const console = {};\n for (const level of [\"log\", \"info\", \"warn\", \"error\", \"debug\"]) {\n console[level] = (...args) => {\n output(\"console\", args.map(format).join(\" \"));\n for (const arg of args) outputImages(arg);\n };\n }\n Object.freeze(console);\n\n Object.defineProperty(globalThis, \"tools\", { value: toolsProxy, enumerable: true });\n Object.defineProperty(globalThis, \"ALL_TOOLS\", { value: allTools, enumerable: true });\n Object.defineProperty(globalThis, \"console\", { value: console, enumerable: true });\n Object.defineProperty(globalThis, \"text\", { value: text, enumerable: true });\n Object.defineProperty(globalThis, \"image\", { value: image, enumerable: true });\n Object.defineProperty(globalThis, \"exit\", { value: exit, enumerable: true });\n\n return {\n settle(id, ok, payload, text) {\n const entry = pending.get(id);\n if (!entry) return;\n pending.delete(id);\n if (!ok) {\n entry.reject(new ErrorCtor(payload));\n return;\n }\n let value;\n try {\n value = payload === undefined ? undefined : parse(payload);\n } catch (error) {\n entry.reject(error);\n return;\n }\n if (text !== undefined && value !== null && typeof value === \"object\") {\n printedText.set(value, text);\n // Inside a string (\"\" + r, a template literal), a tool result reads as its text too.\n defineProperty(value, TO_PRIMITIVE, { value: () => text });\n }\n entry.resolve(value);\n },\n run(fn) {\n let promise;\n try {\n promise = fn();\n } catch (error) {\n done(false, describeError(error));\n return;\n }\n promiseThen.call(\n promise,\n (value) => {\n let json;\n try {\n const printed = printable(value);\n json = serialize(printed === undefined ? value : printed);\n if (printed !== undefined) outputImages(value);\n } catch (error) {\n done(false, describeError(error));\n return;\n }\n done(true, json, serializeWrites());\n },\n (error) => {\n done(false, describeError(error));\n },\n );\n },\n stalled() {\n if (finished || pending.size > 0) return false;\n done(\n false,\n stringify({\n name: \"Error\",\n message:\n \"The script is waiting on a promise that can never settle: no tool call is pending, and timers do not exist here.\",\n }),\n );\n return true;\n },\n };\n})`\n"],"mappings":";;AAGA,MAAa,wBAAwB;;AAErC,MAAa,wBAAwB;;;;;;;AAOrC,MAAa,mBAAmB;;AAEhC,MAAa,mBAAmB;AAEhC,MAAM,uBACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCJ,MAAa,iBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAwUd,sBAAsB;;kHAEoE,sBAAsB;;;;;iBAKvH,sBAAsB;;qDAEc,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAiCnD,iBAAiB,oBAAoB,iBAAiB;;+CAE/B,iBAAiB,iBAAiB,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAkClE,KAAK,UAAU,oBAAoB,EAAE;;;yEAGI,KAAK,UAAU,oBAAoB,EAAE;;;kEAG5C,KAAK,UAAU,oBAAoB,EAAE;;;;;;;;;;;;;;;;;;;;8CAoBzD,KAAK,UAAU,oBAAoB,EAAE"}
@@ -1,6 +1,6 @@
1
1
  import { n as definePreset } from "./compose-Db9ZMbyD.js";
2
2
  import { a as shell, n as waitTask, r as shellKill } from "./wait-task-BZiNOAcc.js";
3
- import { c as edit, d as recordArtifact, f as createSpawnTool, n as readFile, o as multiEdit, s as listFiles, t as writeFile } from "./write-file-QYrcDdl3.js";
3
+ import { c as edit, d as recordArtifact, f as createSpawnTool, n as readFile, o as multiEdit, s as listFiles, t as writeFile } from "./write-file-ChtRPdEL.js";
4
4
  import { p as createArtifactDetectHook, t as BUILTIN_ARTIFACT_DETECTORS } from "./builtin-artifact-kinds-BmorPkgz.js";
5
5
  //#region src/presets/artifacts.ts
6
6
  /**
@@ -62,4 +62,4 @@ var basic_default = definePreset({
62
62
  //#endregion
63
63
  export { basic_default as n, artifacts_default as r, basicTools as t };
64
64
 
65
- //# sourceMappingURL=presets-DXeHsd24.js.map
65
+ //# sourceMappingURL=presets-C4hkykN-.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"presets-DXeHsd24.js","names":[],"sources":["../src/presets/artifacts.ts","../src/presets/basic.ts"],"sourcesContent":["import type { AgentHooks } from '../agent'\nimport { definePreset } from '.'\nimport { createArtifactDetectHook } from '../extensions/artifact-detect'\nimport { BUILTIN_ARTIFACT_DETECTORS } from '../extensions/builtin-artifact-kinds'\nimport { recordArtifact } from '../tools/record-artifact'\n\n/**\n * Built-in artifact detection — records pull requests, branches, commits\n * a session produces — never files automatically (see `session/artifacts.ts`).\n *\n * Opt-in by composition, not baked into `basic`: SDK consumers who never\n * spread this preset see zero behavior change, while the TUI / daemon\n * hosts compose it under the profile preset so every chat session gets\n * detection. Extension-registered kinds ride the extension registry's\n * hooks instead; both paths share `createArtifactDetectHook`.\n *\n * Also contributes the `record_artifact` tool — the explicit path for\n * outputs detection can't see (background-shell PRs, deployments, issues).\n */\nconst detectHooks = BUILTIN_ARTIFACT_DETECTORS\n .map(kind => createArtifactDetectHook(kind, {\n warn: (message, fields) => {\n if (process.env.ZIDANE_DEBUG)\n process.stderr.write(`[zidane/artifacts] ${message} ${JSON.stringify(fields)}\\n`)\n },\n }))\n .filter((hook): hook is NonNullable<AgentHooks['tool:transform']> => hook !== undefined)\n\n/** Preset that detects pull requests, commits and branches in tool results (files are recorded by the loop, not by detection) and adds the `record_artifact` tool for outputs detection cannot see. Detection runs as `tool:transform` hooks, including those bubbled up from subagents. */\nexport default definePreset({\n tools: { [recordArtifact.spec.name]: recordArtifact },\n hooks: {\n 'tool:transform': detectHooks,\n // Subagents are built from the parent's preset WITHOUT hooks, so their\n // tool results only reach us as the same-ref `child:tool:transform`\n // bubble. Detecting there writes into the child's own metadata bag, and\n // the child's loop lifts it into the shared session under its runId.\n 'child:tool:transform': detectHooks,\n },\n})\n","import { definePreset } from '.'\n// Leaf modules, not the '../tools' barrel: the barrel reaches this file back\n// through spawn → agent → extensions → presets, and `basicTools` reads the\n// tools at load time.\nimport { edit } from '../tools/edit'\nimport { listFiles } from '../tools/list-files'\nimport { multiEdit } from '../tools/multi-edit'\nimport { readFile } from '../tools/read-file'\nimport { shell } from '../tools/shell'\nimport { shellKill } from '../tools/shell-kill'\nimport { createSpawnTool } from '../tools/spawn'\nimport { waitTask } from '../tools/wait-task'\nimport { writeFile } from '../tools/write-file'\n\n/**\n * Core tools available in every basic preset (without spawn).\n *\n * `edit` and `multi_edit` ship in the basic set because surgical edits are the\n * default modality for production agents — `write_file` is for full overwrites.\n * `glob` and `grep` are exported but opt-in: not every agent needs codebase\n * search, and shipping them by default would force `tool:gate` work onto\n * consumers that prefer the model to use `shell` + classic Unix tools.\n */\nexport const basicTools = { shell, shellKill, waitTask, readFile, writeFile, listFiles, edit, multiEdit }\n\n/** Default preset with the shell, file, edit and `spawn` tools and a general-purpose system prompt. The `spawn` tool is created fresh on every access, so each agent gets its own subagent state. */\nexport default definePreset({\n name: 'basic',\n system: 'You are a helpful assistant with access to shell, file reading, file writing, surgical and multi-edit tools, directory listing, and sub-agent spawning. Prefer `edit` / `multi_edit` for in-place changes and `write_file` for full file overwrites. Use them to accomplish tasks in the project directory.',\n // `tools` is a getter so each access (every `{ ...basic }` spread into\n // `createAgent`) mints a FRESH spawn tool. `createSpawnTool()` carries\n // per-instance state (running children, concurrency counter, child-stats\n // accumulator); a module-level singleton instance would be shared by every\n // agent in the process, breaking concurrent rollouts.\n //\n // `persist: true` shares the parent's session with every child agent — child\n // turns land in `session.turns` tagged with their own `runId`, and the run\n // itself is recorded in `session.runs` with `parentRunId` + `depth`. That's\n // what lets a reloaded TUI session reconstruct the full subagent tree (see\n // `eventsFromTurns` in `src/chat/store.ts`). Hosts that want children in-memory\n // only can construct their own preset with `createSpawnTool()`.\n get tools() {\n return { ...basicTools, spawn: createSpawnTool({ persist: true }) }\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,MAAM,cAAc,2BACjB,KAAI,SAAQ,yBAAyB,MAAM,EAC1C,OAAO,SAAS,WAAW;CACzB,IAAI,QAAQ,IAAI,cACd,QAAQ,OAAO,MAAM,sBAAsB,QAAQ,GAAG,KAAK,UAAU,MAAM,EAAE,GAAG;AACpF,EACF,CAAC,CAAC,CAAC,CACF,QAAQ,SAA4D,SAAS,KAAA,CAAS;;AAGzF,IAAA,oBAAe,aAAa;CAC1B,OAAO,GAAG,eAAe,KAAK,OAAO,eAAe;CACpD,OAAO;EACL,kBAAkB;EAKlB,wBAAwB;CAC1B;AACF,CAAC;;;;;;;;;;;;AChBD,MAAa,aAAa;CAAE;CAAO;CAAW;CAAU;CAAU;CAAW;CAAW;CAAM;AAAU;;AAGxG,IAAA,gBAAe,aAAa;CAC1B,MAAM;CACN,QAAQ;CAaR,IAAI,QAAQ;EACV,OAAO;GAAE,GAAG;GAAY,OAAO,gBAAgB,EAAE,SAAS,KAAK,CAAC;EAAE;CACpE;AACF,CAAC"}
1
+ {"version":3,"file":"presets-C4hkykN-.js","names":[],"sources":["../src/presets/artifacts.ts","../src/presets/basic.ts"],"sourcesContent":["import type { AgentHooks } from '../agent'\nimport { definePreset } from '.'\nimport { createArtifactDetectHook } from '../extensions/artifact-detect'\nimport { BUILTIN_ARTIFACT_DETECTORS } from '../extensions/builtin-artifact-kinds'\nimport { recordArtifact } from '../tools/record-artifact'\n\n/**\n * Built-in artifact detection — records pull requests, branches, commits\n * a session produces — never files automatically (see `session/artifacts.ts`).\n *\n * Opt-in by composition, not baked into `basic`: SDK consumers who never\n * spread this preset see zero behavior change, while the TUI / daemon\n * hosts compose it under the profile preset so every chat session gets\n * detection. Extension-registered kinds ride the extension registry's\n * hooks instead; both paths share `createArtifactDetectHook`.\n *\n * Also contributes the `record_artifact` tool — the explicit path for\n * outputs detection can't see (background-shell PRs, deployments, issues).\n */\nconst detectHooks = BUILTIN_ARTIFACT_DETECTORS\n .map(kind => createArtifactDetectHook(kind, {\n warn: (message, fields) => {\n if (process.env.ZIDANE_DEBUG)\n process.stderr.write(`[zidane/artifacts] ${message} ${JSON.stringify(fields)}\\n`)\n },\n }))\n .filter((hook): hook is NonNullable<AgentHooks['tool:transform']> => hook !== undefined)\n\n/** Preset that detects pull requests, commits and branches in tool results (files are recorded by the loop, not by detection) and adds the `record_artifact` tool for outputs detection cannot see. Detection runs as `tool:transform` hooks, including those bubbled up from subagents. */\nexport default definePreset({\n tools: { [recordArtifact.spec.name]: recordArtifact },\n hooks: {\n 'tool:transform': detectHooks,\n // Subagents are built from the parent's preset WITHOUT hooks, so their\n // tool results only reach us as the same-ref `child:tool:transform`\n // bubble. Detecting there writes into the child's own metadata bag, and\n // the child's loop lifts it into the shared session under its runId.\n 'child:tool:transform': detectHooks,\n },\n})\n","import { definePreset } from '.'\n// Leaf modules, not the '../tools' barrel: the barrel reaches this file back\n// through spawn → agent → extensions → presets, and `basicTools` reads the\n// tools at load time.\nimport { edit } from '../tools/edit'\nimport { listFiles } from '../tools/list-files'\nimport { multiEdit } from '../tools/multi-edit'\nimport { readFile } from '../tools/read-file'\nimport { shell } from '../tools/shell'\nimport { shellKill } from '../tools/shell-kill'\nimport { createSpawnTool } from '../tools/spawn'\nimport { waitTask } from '../tools/wait-task'\nimport { writeFile } from '../tools/write-file'\n\n/**\n * Core tools available in every basic preset (without spawn).\n *\n * `edit` and `multi_edit` ship in the basic set because surgical edits are the\n * default modality for production agents — `write_file` is for full overwrites.\n * `glob` and `grep` are exported but opt-in: not every agent needs codebase\n * search, and shipping them by default would force `tool:gate` work onto\n * consumers that prefer the model to use `shell` + classic Unix tools.\n */\nexport const basicTools = { shell, shellKill, waitTask, readFile, writeFile, listFiles, edit, multiEdit }\n\n/** Default preset with the shell, file, edit and `spawn` tools and a general-purpose system prompt. The `spawn` tool is created fresh on every access, so each agent gets its own subagent state. */\nexport default definePreset({\n name: 'basic',\n system: 'You are a helpful assistant with access to shell, file reading, file writing, surgical and multi-edit tools, directory listing, and sub-agent spawning. Prefer `edit` / `multi_edit` for in-place changes and `write_file` for full file overwrites. Use them to accomplish tasks in the project directory.',\n // `tools` is a getter so each access (every `{ ...basic }` spread into\n // `createAgent`) mints a FRESH spawn tool. `createSpawnTool()` carries\n // per-instance state (running children, concurrency counter, child-stats\n // accumulator); a module-level singleton instance would be shared by every\n // agent in the process, breaking concurrent rollouts.\n //\n // `persist: true` shares the parent's session with every child agent — child\n // turns land in `session.turns` tagged with their own `runId`, and the run\n // itself is recorded in `session.runs` with `parentRunId` + `depth`. That's\n // what lets a reloaded TUI session reconstruct the full subagent tree (see\n // `eventsFromTurns` in `src/chat/store.ts`). Hosts that want children in-memory\n // only can construct their own preset with `createSpawnTool()`.\n get tools() {\n return { ...basicTools, spawn: createSpawnTool({ persist: true }) }\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,MAAM,cAAc,2BACjB,KAAI,SAAQ,yBAAyB,MAAM,EAC1C,OAAO,SAAS,WAAW;CACzB,IAAI,QAAQ,IAAI,cACd,QAAQ,OAAO,MAAM,sBAAsB,QAAQ,GAAG,KAAK,UAAU,MAAM,EAAE,GAAG;AACpF,EACF,CAAC,CAAC,CAAC,CACF,QAAQ,SAA4D,SAAS,KAAA,CAAS;;AAGzF,IAAA,oBAAe,aAAa;CAC1B,OAAO,GAAG,eAAe,KAAK,OAAO,eAAe;CACpD,OAAO;EACL,kBAAkB;EAKlB,wBAAwB;CAC1B;AACF,CAAC;;;;;;;;;;;;AChBD,MAAa,aAAa;CAAE;CAAO;CAAW;CAAU;CAAU;CAAW;CAAW;CAAM;AAAU;;AAGxG,IAAA,gBAAe,aAAa;CAC1B,MAAM;CACN,QAAQ;CAaR,IAAI,QAAQ;EACV,OAAO;GAAE,GAAG;GAAY,OAAO,gBAAgB,EAAE,SAAS,KAAK,CAAC;EAAE;CACpE;AACF,CAAC"}
package/dist/presets.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { Ca as composePresets, Sa as Preset, n as basicTools, t as _default$1, tx as AgentHookMap, wa as definePreset, xa as _default } from "./index-DyQyDLX1.js";
1
+ import { Ca as composePresets, Sa as Preset, n as basicTools, nx as AgentHookMap, t as _default$1, wa as definePreset, xa as _default } from "./index-4mDRyTGJ.js";
2
2
  export { type AgentHookMap, Preset, _default as artifacts, _default$1 as basic, basicTools, composePresets, definePreset };
package/dist/presets.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import { n as definePreset, t as composePresets } from "./compose-Db9ZMbyD.js";
2
- import { n as basic_default, r as artifacts_default, t as basicTools } from "./presets-DXeHsd24.js";
2
+ import { n as basic_default, r as artifacts_default, t as basicTools } from "./presets-C4hkykN-.js";
3
3
  export { artifacts_default as artifacts, basic_default as basic, basicTools, composePresets, definePreset };
@@ -86,6 +86,8 @@ import { a as isMethodNotFound } from "./connection-BaHd3T-D.js";
86
86
  * - ADDITIVE (no version bump): `sessions.cacheImpact` and
87
87
  * `sessions.cacheReport`. An older host answers "method not found":
88
88
  * pickers show no cache estimate and session details no Cache section.
89
+ * - ADDITIVE (no version bump): `sessions.moveEnvironment`. An older host
90
+ * answers "method not found", shown as the move's error.
89
91
  */
90
92
  const IPC_PROTOCOL_VERSION = 13;
91
93
  /**
@@ -304,4 +306,4 @@ const REDACTED = "<redacted>";
304
306
  //#endregion
305
307
  export { PING_METHOD as a, SESSION_TURNS_PAGE as c, loadAllEvents as d, loadEventsPage as f, LOAD_EVENTS_PAGE_TURNS as i, SIGNAL_SEQ_FIELD as l, loadSessionDocument as m, IpcErrorCode as n, REDACTED as o, loadEventsTail as p, LOAD_EVENTS_MAX_PAGE_TURNS as r, SESSION_TURNS_MAX_PAGE as s, IPC_PROTOCOL_VERSION as t, hostRefOf as u };
306
308
 
307
- //# sourceMappingURL=protocol-BIv1Yuvl.js.map
309
+ //# sourceMappingURL=protocol-Do_i6Ras.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol-Do_i6Ras.js","names":[],"sources":["../src/ipc/protocol.ts"],"sourcesContent":["/**\n * zidane/ipc wire protocol — the transport-agnostic contract between a chat\n * host (the process that owns live `Agent` instances) and its clients (GUI\n * renderer, TUI window, `zidane attach`, …).\n *\n * The host-domain shapes (the `HostSignal` push union and everything it\n * carries) live in `src/chat/host/signals.ts` — the host must not depend on\n * `src/ipc/**`. This module re-exports them unchanged and adds the\n * transport-only contract: the typed JSON-RPC method map, session rows, and\n * the daemon handshake.\n *\n * Everything in this file is JSON-serializable: it must survive Electron's\n * structured clone AND a JSON-RPC socket hop unchanged. Canonical agent\n * types (`StreamEvent`, `InteractionRequest`, …) are re-used where they are\n * already wire-safe; host-only shapes (live `resolve` callbacks, `Map`s)\n * never appear here.\n *\n * Versioning: bump `IPC_PROTOCOL_VERSION` on any breaking change to the\n * signal union or the method map. The daemon handshake refuses mismatched\n * peers so a stale daemon never talks to an upgraded client (see\n * `daemon/lifecycle.ts`).\n */\nimport type { BrowserResponse } from '../chat/browser/protocol'\nimport type { CommandOutputBlock } from '../chat/commands'\nimport type { EnvironmentActionResult, EnvironmentActionSummary, EnvironmentRequest, EnvironmentTeardownResult, EnvironmentVerifyResult } from '../chat/environment'\nimport type { EnvironmentDescriptor, EnvironmentSettingsChange } from '../chat/environment-settings'\nimport type { CompactionReport } from '../chat/host/compaction'\nimport type { CacheImpact, CacheImpactChange, CacheReport, ContextSegmentsReport, WorkspaceListFilesOptions } from '../chat/host/engine'\nimport type { SessionLaunchOverrides } from '../chat/host/launch-overrides'\nimport type {\n CreateWorkerParams as OrchestrationCreateWorkerParams,\n WorkerRow as OrchestrationWorkerRow,\n WorkerSummary as OrchestrationWorkerSummary,\n} from '../chat/host/orchestration'\nimport type {\n CommandArgSuggestionSummary,\n CommandSummary,\n HostSettings,\n HostSignal,\n PendingInteraction,\n PromptAttachment,\n QueuedItem,\n RunningWorkItem,\n SendOptions,\n SessionPresence,\n TodosSnapshot,\n WireApprovalRequest,\n} from '../chat/host/signals'\nimport type {\n ApprovalDecision,\n ContextBreakdown,\n InteractionResponse,\n ProviderKey,\n SearchTurnResult,\n SessionEnvironmentSummary,\n SessionHeader,\n SessionHistoryMatch,\n SessionMeta,\n StreamEvent,\n SystemMdFile,\n TodoItem,\n} from '../chat/index'\nimport type { MachineInfo, MachineLinksStatus, MachineRegisterParams } from '../chat/machine-protocol'\nimport type { SyncCategory, SyncClaimResult, SyncPayload, SyncPushResult, SyncStatus } from '../chat/sync/types'\nimport type { TerminalAdoptResult, TerminalAttachResult, TerminalInfo, TerminalOpenInput, TerminalProjectOpenInput, TerminalProjectState, TerminalProjectStateInput, TerminalSessionState } from '../chat/terminal/protocol'\nimport type { ExecResult, ListFilesEntry } from '../contexts/types'\nimport type { SessionArtifact } from '../session/artifacts'\nimport type { SessionData } from '../session/index'\nimport type { JsonValue, McpServerConfig, SessionTurn, ThinkingLevel } from '../types'\nimport { isMethodNotFound } from '../chat/hosts/connection'\n\nexport type {\n ApprovalOriginator,\n CommandArgSuggestionSummary,\n CommandSummary,\n HostSettings,\n HostSignal,\n PendingInteraction,\n PromptAttachment,\n QueuedItem,\n RunningWorkItem,\n SendOptions,\n SerializedPreview,\n SessionPresence,\n TodosSnapshot,\n WireApprovalRequest,\n} from '../chat/host/signals'\n\n/** The machine protocol (`docs/MACHINES.md`), versioned on its own (`MACHINE_PROTOCOL_VERSION`). */\nexport {\n isValidMachineName,\n MACHINE_HOST_METHODS,\n MACHINE_IDEMPOTENT_METHODS,\n MACHINE_PROTOCOL_VERSION,\n MachineErrorCode,\n machineKind,\n parseMachineKind,\n} from '../chat/machine-protocol'\nexport type {\n MachineCapabilities,\n MachineHandleRef,\n MachineInfo,\n MachineMethodName,\n MachineMethods,\n MachineNotifications,\n MachineParams,\n MachineRegisterParams,\n MachineRegisterResult,\n MachineResult,\n MachineRoot,\n MachineStatusChange,\n} from '../chat/machine-protocol'\n\n/**\n * Changes since v5. Entries marked additive, or \"no version bump\", did\n * not raise the version. The current version is `IPC_PROTOCOL_VERSION`.\n *\n * - `event` signals carry an optional `echo` flag marking host-generated\n * SEND/STEER echoes of the user's own message.\n * - `chat.pushQueued` result gained the `'queued'` delivered variant.\n * - `sessions.setModel` now honors `fallbacks`: it persists the canonical\n * `metadata.modelChain` and CLEARS a previously persisted chain when\n * omitted/empty. It also accepts `effort` / `modelOptions` and resets\n * both when omitted (a pick is atomic — no stale per-model knobs).\n * - additive: `extension.emit` notification + `extension:signal` fan-out\n * (the permission-gated per-extension cross-window bus, `ctx.bus`).\n * Older daemons ignore the unknown notification; older clients drop the\n * unknown signal kind — no version bump needed.\n * - additive: `extension.emit` / `extension:signal` carry an optional\n * `nonce` (the emitter's per-process random id) so receivers dedupe on\n * `(extensionId, nonce, seq)` instead of the collision-prone\n * `(extensionId, seq)`. Older peers omit it and fall back to the\n * seq-only key — no version bump needed.\n * - `SessionRow.modelFallbacks` is now populated from the session's\n * persisted `metadata.modelChain`.\n * - Default socket path moved from `<stateDir>/daemon.sock` to the\n * dedicated `<stateDir>/daemon/daemon.sock` (dir chmod'd 0700) so the\n * daemon can harden its socket dir without touching shared state files.\n * - ADDITIVE (no version bump — older daemons answer \"method not\n * found\", clients degrade to local compute): `suggest.resolve` RPC\n * resolves inline ghost-text autocomplete daemon-side, and the\n * `suggest:changed` signal fans the result out to every OTHER peer\n * on the session so mirroring windows paint the same ghost without\n * recomputing.\n * - ADDITIVE (no version bump — optional field, older daemons simply\n * omit it and clients fall back to the single `suggestion`):\n * `suggest.resolve` results and `suggest:changed` signals carry the\n * resolver's full ordered `candidates` list so daemon mode keeps\n * ↑/↓ candidate rotation instead of degrading to one suggestion.\n * - ADDITIVE (no version bump — `optional()` swallows \"method not\n * found\" on an older daemon, which then simply keeps its stale\n * registries as before): `runtime.reload` RPC drops the daemon's\n * cached extension registries and retires live agents after a window\n * reloaded its extensions.\n * - ADDITIVE (no version bump): `terminal.registerViewer` /\n * `terminal.unregisterViewer`. The desktop app registers as a client that\n * can show terminals; agents only get terminal tools while one is\n * attached. An older daemon answers \"method not found\" (and keeps giving\n * every agent the tools, as before); an older desktop app on a newer\n * daemon never registers, so its agents run without terminal tools.\n * - ADDITIVE (no version bump): project / draft terminals\n * (docs/PROJECT-SCOPE-AUDIT.md): `terminal.projectState`,\n * `terminal.openInProject`, `terminal.adopt`, `terminal.releaseDraft`,\n * the `terminal:project-changed` signal, and `HelloResult.projectTerminals`.\n * An older daemon answers \"method not found\" and omits the flag; clients\n * then offer terminals only in sessions.\n * - ADDITIVE (no version bump): `queue.attachments` returns a queued\n * entry's attachments with their bytes, and `queue.update` accepts\n * `attachments` to replace them. An older daemon answers \"method not\n * found\" / ignores the field: the entry's attachments stay as queued.\n * - ADDITIVE (no version bump): `chat.steer` / `chat.followUp` resolve to\n * whether the message reached a live run. Older daemons resolve `null`,\n * which clients treat as delivered (the pre-existing behavior).\n * - ADDITIVE (no version bump): `sessions.fork`, `sessions.deleteTurn`,\n * `sessions.editTurnText`, `sessions.setFolder`, `sessions.appendTurns`,\n * `sessions.rewind`.\n * History and folder edits run in the host instead of being written to\n * the store by the client (then `sessions.touch` + `chat.rebuildAgent`).\n * Older clients keep the old path, which still works on a shared disk.\n * A newer client only meets an older daemon while it retires (the\n * release fence drains it otherwise), and then gets \"method not found\".\n * - ADDITIVE (no version bump): `sessions.listMeta`, `sessions.getMeta`,\n * `sessions.get`, `sessions.setExtensionState` serve a client the\n * session data it used to read and write in its own store, so a window\n * on another machine sees the host's sessions. `sessions.create` accepts `effort`, `modelOptions` and\n * `pinnedSkills`; `todos.set` accepts `persistIdle`. An older host answers\n * \"method not found\" / ignores the fields: a window falls back to the\n * store it shares with a local daemon, and refuses a remote host.\n * - ADDITIVE (no version bump): `daemon.info` reports `activeWork` (a run,\n * compaction, `/` command or background task in flight). An older host\n * omits it; `zidane server wait-idle` then says it can't tell.\n * - ADDITIVE (no version bump): `sessions.loadEvents` paging accepts\n * `beforeTurnId` (the page ends right before that turn, winning over\n * `before`; an unknown turn is invalid params) and the page echoes it.\n * An older host ignores the param and omits the echo, which is how a\n * client tells.\n * - ADDITIVE (no version bump): `sessions.cacheImpact` and\n * `sessions.cacheReport`. An older host answers \"method not found\":\n * pickers show no cache estimate and session details no Cache section.\n * - ADDITIVE (no version bump): `sessions.moveEnvironment`. An older host\n * answers \"method not found\", shown as the move's error.\n */\nexport const IPC_PROTOCOL_VERSION = 13\n\n/**\n * JSON-RPC error codes specific to the zidane daemon. Lives here (not in\n * `daemon/server.ts`) so clients can import the codes without pulling the\n * server's module graph.\n */\nexport const IpcErrorCode = {\n VersionMismatch: -32010,\n NotHandshaken: -32011,\n /** A network transport's per-connection request budget is spent; retry later. */\n RateLimited: -32012,\n /**\n * The reply would exceed the transport's message size: nothing was sent\n * but this error (the connection stays). Ask for less (a transcript: a\n * smaller page, see {@link loadAllEvents}).\n */\n ResponseTooLarge: -32013,\n /**\n * The handler threw: the host refused or failed the call (`message` says\n * why). Hosts before it answered -32000, which ACP uses for\n * `AuthenticationRequired`; clients treat both as a plain remote error.\n */\n HandlerFailed: -32014,\n} as const\n\n/**\n * Client heartbeat request (`{}` → `{}`), outside the method table: every\n * host answers it, before the handshake too. A host predating it answers\n * \"method not found\", which still proves it alive.\n */\nexport const PING_METHOD = '$/ping'\n\n/**\n * Session-scoped signals fanned out to every peer carry their number in\n * their session as this extra field on the `ipc.signal` params (clients\n * predating it ignore it; `IpcClient` strips it and hands it to listeners as\n * {@link SignalMeta}). Per session, from 1, gap-free within one host process.\n */\nexport const SIGNAL_SEQ_FIELD = '$seq'\n\n/** What a signal listener gets beside the signal: its number in its session, when it has one. */\nexport interface SignalMeta {\n /** Position of the signal in its session. Starts at 1 and has no gaps within one host process. */\n seq: number\n}\n\n/** A session signal with its position in the session, as kept in the host's replay log. */\nexport interface SequencedSignal {\n /** Position of the signal in its session. */\n seq: number\n /** The signal itself. */\n signal: HostSignal\n}\n\n/** Result of `sessions.resume`. On success, the signals the client missed after its last position. Otherwise the reason it must reload instead. */\nexport type SessionResumeResult\n = | { ok: true, signals: SequencedSignal[] }\n /** `epoch`: another host process numbered them. `gap`: the log no longer covers the position. */\n | { ok: false, reason: 'epoch' | 'gap' }\n\n/* -------------------------------------------------------------------------\n * Request/response methods (client → host)\n * ---------------------------------------------------------------------- */\n\n/**\n * Typed method map for the daemon transport. Keys are JSON-RPC method\n * names; each entry pins params/result so both the daemon dispatch table\n * and the client proxy are checked against the same contract.\n *\n * Scope: the chat core every client needs. Host-UI-specific surfaces\n * (folder pickers, themes, keybindings) intentionally stay client-local.\n */\nexport interface IpcMethods {\n /** `wake` is host-internal (see `SendOptions.wake`) — not accepted over the wire. */\n 'chat.send': { params: Omit<SendOptions, 'wake'>, result: { runId: string } }\n /** Aborts the session's live run. Does nothing when no run is live. */\n 'chat.interrupt': { params: { sessionId: string }, result: void }\n /** `true` when the message reached a live run; `false` when nothing was running (it was not delivered). */\n 'chat.steer': { params: { sessionId: string, message: string }, result: boolean }\n /** Adds a follow-up message to the live run. Resolves `true` when a run was live to take it, `false` when nothing was running and the message was dropped, not queued. */\n 'chat.followUp': { params: { sessionId: string, message: string }, result: boolean }\n /** Delivers a queued message. Steers a live run, otherwise starts a run or runs it as a command. `delivered` says which path it took. `keepDraft` keeps the shared composer draft instead of clearing it on the other clients. */\n 'chat.pushQueued': {\n params: { sessionId: string, message: string, activatedSkills?: string[], keepDraft?: boolean }\n result: { delivered: 'steer' | 'send' | 'command' | 'queued' }\n }\n /** Resolves `true` while the session has a live run. */\n 'chat.isRunning': { params: { sessionId: string }, result: boolean }\n /**\n * Retire the session's live agent so the next run rebuilds against\n * fresh config/credentials (MCP login, extension reload). Run-end\n * deferred when a run is in flight; HITL/queue state survives.\n */\n 'chat.rebuildAgent': { params: { sessionId: string }, result: void }\n /**\n * `zidane run --system / --mcp` for a host-backed window: launch overrides\n * for the session's agent (`ChatHost.setLaunchOverrides`), owned by the\n * calling client and dropped when it disconnects. A call with neither field clears them.\n */\n 'sessions.setLaunchOverrides': { params: { sessionId: string } & SessionLaunchOverrides, result: void }\n /**\n * Drop the daemon's cached runtime configs (extension registries, per\n * cwd) and retire every live agent so the next command or run rebuilds\n * against what is on disk now. Sent by a window after it reloaded its\n * own extensions (install, update, remove, `/reload`): extension `/`\n * commands execute daemon-side, so without this the daemon keeps\n * running the code it loaded at boot. Busy sessions rebuild at run end.\n */\n 'runtime.reload': { params: Record<string, never>, result: void }\n /**\n * Lists the tool calls and background tasks the session's live run tracks\n * and can cancel. Empty when no run is live. `children: true` adds the\n * subagents' running calls (`childId` set), for their starts: a\n * transcript read from disk times them too. Older hosts ignore it.\n */\n 'chat.listWork': { params: { sessionId: string, children?: boolean }, result: RunningWorkItem[] }\n /** Cancels one tracked work item by `id`, or every visible item with `\"all\"`. Resolves `true` when something was cancelled. `reason` is passed to a cancelled tool call. */\n 'chat.cancelWork': { params: { sessionId: string, id: string | 'all', reason?: string }, result: boolean }\n\n /** Lists session rows. `projectRoot` filters by project, `archive` picks active, archived or all sessions. */\n 'sessions.list': { params: { projectRoot?: string | null, archive?: 'active' | 'archived' | 'all' }, result: SessionRow[] }\n /**\n * The session list as a window renders it (`SessionMeta`: title, turn /\n * message / run counts, project, cwd, environment, artifact count, the\n * orchestration main flag), newest first. `projectRoot`: omitted = every\n * project, `null` = untagged sessions.\n */\n 'sessions.listMeta': { params: { projectRoot?: string | null }, result: SessionMeta[] }\n /** One `SessionMeta` by id (rows a filtered list can't return, e.g. the main); `null` when unknown. */\n 'sessions.getMeta': { params: { sessionId: string }, result: SessionMeta | null }\n /**\n * The whole session document as the host holds it: the live copy when an\n * agent is live (turns persisted mid-run, todos kept in memory), else the\n * stored one, a stale `running` marker demoted. `null` when unknown.\n */\n 'sessions.get': { params: { sessionId: string, turns?: boolean }, result: SessionDocumentHead | null }\n /**\n * A slice of a session's turns, `[from, from + limit)` (default from 0,\n * {@link SESSION_TURNS_PAGE} turns, at most {@link SESSION_TURNS_MAX_PAGE}),\n * from the same copy `sessions.get` reads, and how many turns it has: a\n * client reads a long session's document a page at a time\n * ({@link loadSessionDocument}) instead of in one reply. With\n * `sessions.get` `turns: false` (the document without its turns), what an\n * export needs. Pages and that head come from one snapshot of the\n * document per content version (read once, not per page), and name it\n * (`version`): a client that sees it change mid-load starts over rather\n * than mix two versions ({@link loadSessionDocument}). `null` when\n * unknown. Additive: an older host answers \"method not found\", ignores\n * `turns: false`, and names no version.\n */\n 'sessions.getTurns': { params: { sessionId: string, from?: number, limit?: number }, result: { turns: SessionTurn[], total: number, version?: string } | null }\n /**\n * The full text of one tool result (`callId`; `turnId`, when known, the\n * turn that holds it): what a clipped tool row shows on expand, without\n * the session crossing the wire. `null` when no such result. Additive.\n */\n 'sessions.getToolResult': { params: { sessionId: string, callId: string, turnId?: string }, result: string | null }\n /**\n * One session's header: its list row plus metadata, profile and status,\n * without turns or runs (the live copy when an agent holds it). What a\n * window re-reads on `sessions:changed`. Additive. `usage: true` adds the\n * footer's numbers, computed host-side from the turns and runs\n * (`contextTokens`, `costUsd`, and while the host runs the session\n * `runStartedAt` / `runOutputTokens`): a client needs no document for its\n * context gauge, cost pill or run readout. Older hosts ignore it.\n */\n 'sessions.getHeader': { params: { sessionId: string, usage?: boolean }, result: SessionHeader | null }\n /**\n * One key of an extension's per-session state (`metadata.extensions`, the\n * bag `ctx.session` and renderer `useSessionState` share), written by the\n * host into its copy of the session. `value` omitted deletes the key.\n */\n 'sessions.setExtensionState': { params: { sessionId: string, extension: string, key: string, value?: JsonValue }, result: void }\n /** Creates a session and resolves with its row. */\n 'sessions.create': { params: CreateSessionParams, result: SessionRow }\n /** Resolves with what happened to the session's environment (a provider may keep it). */\n 'sessions.delete': { params: { sessionId: string }, result: { environment?: EnvironmentTeardownResult } }\n /** Provision a failed (or restart-stranded) environment again. */\n 'sessions.retryEnvironment': { params: { sessionId: string }, result: void }\n /** Move a local session into a new environment (a worktree, …); provisioning continues in the background. */\n 'sessions.moveEnvironment': { params: { sessionId: string, environment: EnvironmentRequest }, result: void }\n /** The per-session commands the session's environment offers right now (push, open PR, …). */\n 'sessions.environmentActions': { params: { sessionId: string }, result: EnvironmentActionSummary[] }\n /** Run one of them in the session's environment (resumed when suspended). */\n 'sessions.runEnvironmentAction': { params: { sessionId: string, actionId: string }, result: EnvironmentActionResult }\n /**\n * The session's workspace (`ChatHost.workspace*`): its execution context,\n * rooted inside the environment when the files live there, else at the\n * session's cwd. Paths and exec `cwd` resolve against the root as the\n * execution context resolves them; containment is the context's own.\n * `cwd` / `env` on exec and the list / size methods are additive: an\n * older daemon ignores the former and answers \"method not found\" to the\n * latter (active clients are build-fenced, so this is a transient case).\n */\n 'sessions.workspaceExec': { params: { sessionId: string, command: string, cwd?: string, env?: Record<string, string>, timeoutSeconds?: number }, result: ExecResult }\n /**\n * The same command, streamed (`!` on a remote host): the reply names the\n * exec, its output follows as `workspace:exec:data` signals and ends with\n * one `workspace:exec:exit`, all to this connection only (signals may\n * precede the reply). Bounded per connection (concurrent commands, chunk\n * size, total output: past it the process is stopped and the exit says\n * `truncated`). A dropped connection kills what it started. Additive: an\n * older host answers \"method not found\" and clients use `workspaceExec`.\n */\n 'sessions.workspaceExecStream': { params: { sessionId: string, command: string, cwd?: string }, result: { execId: string } }\n /** Kill a streamed command's process group (this connection's only; `cancelled: false` otherwise or when it already ended). */\n 'sessions.workspaceExecCancel': { params: { execId: string }, result: { cancelled: boolean } }\n /** Reads a text file from the session's workspace. */\n 'sessions.workspaceReadFile': { params: { sessionId: string, path: string }, result: string }\n /** Writes a text file in the session's workspace. */\n 'sessions.workspaceWriteFile': { params: { sessionId: string, path: string, content: string }, result: void }\n /** Lists the entries under `path` in the session's workspace. */\n 'sessions.workspaceListFiles': { params: { sessionId: string, path: string, options?: WorkspaceListFilesOptions }, result: ListFilesEntry[] }\n /** Size in bytes of a file in the session's workspace, or `null` when it does not exist. */\n 'sessions.workspaceFileSize': { params: { sessionId: string, path: string }, result: number | null }\n /**\n * Every environment kind the host can create, described for a new session\n * in `cwd` (availability, default, branch suggestion, options — secrets\n * only as \"configured\"). What pickers and the Environments settings render.\n * `kind`: a machine kind (`local@laptop`) says `cwd` is that machine's\n * folder, checked against its roots instead of this host's\n * (`docs/MACHINES.md` § Folders); the same on `commands.*`, `catalog.*`\n * and `models.list`. Additive.\n */\n 'environments.list': { params: { cwd?: string, kind?: string }, result: EnvironmentDescriptor[] }\n /**\n * Apply one Environments-settings edit (enable, default, options,\n * secrets), validated against the kind's schema. Settings changes fan out\n * as `settings:changed`; secrets are stored host-side and never returned.\n */\n 'environments.update': { params: EnvironmentSettingsChange, result: void }\n /** \"Test connection\" for a kind with its current options. */\n 'environments.verify': { params: { kind: string }, result: EnvironmentVerifyResult }\n /** Renames a session. */\n 'sessions.setTitle': { params: { sessionId: string, title: string }, result: void }\n /**\n * Title the session ON the host: its providers and credentials (a server\n * session's transcript never goes to the window's provider), the same\n * generator (`generateSessionTitle`), written as `sessions.setTitle` does.\n * `providerKey` / `model`: the window's pick, used when the host has that\n * provider; otherwise the session's own provider and model. The Main\n * session is refused (it keeps its name). Additive: an older host answers\n * \"method not found\".\n */\n 'sessions.generateTitle': { params: { sessionId: string, providerKey?: string, model?: string }, result: { title: string } }\n /** Archives or restores a session. */\n 'sessions.setArchived': { params: { sessionId: string, archived: boolean }, result: void }\n /** Keep the session at the top of lists (`metadata.favorite`). Not activity: no recency bump. Additive. */\n 'sessions.setFavorite': { params: { sessionId: string, favorite: boolean }, result: void }\n /** Move the session to a space (`metadata.spaceId`); the Default space id clears it. See `chat/spaces`. */\n 'sessions.setSpace': { params: { sessionId: string, spaceId: string }, result: void }\n /** Switches the agent the session runs as. */\n 'sessions.setAgentId': { params: { sessionId: string, agentId: string }, result: void }\n /** Sets the thinking effort of the session. */\n 'sessions.setEffort': { params: { sessionId: string, effort: ThinkingLevel }, result: void }\n /**\n * The one model-swap contract (`ChatHost.setSessionModel`). A pick is a\n * whole: `fallbacks` (ordered, primary excluded) REPLACES the persisted\n * `metadata.modelChain` (omitted/empty clears it); `effort` and\n * `modelOptions` are reset to the supplied values (omitted clears them —\n * per-model knobs never leak onto the new model). The live agent is\n * retired so the next run rebuilds on the new pick (run-end deferred\n * while a run is in flight).\n */\n 'sessions.setModel': {\n params: {\n sessionId: string\n providerKey: ProviderKey\n modelId: string\n /** The stored account of the provider to run on (credential id); omitted = its active account. Additive. */\n account?: string\n fallbacks?: ModelFallbackRef[]\n effort?: ThinkingLevel\n modelOptions?: Record<string, boolean>\n }\n result: void\n }\n /** Replaces the model-specific boolean options of the session. */\n 'sessions.setModelOptions': { params: { sessionId: string, options: Record<string, boolean> }, result: void }\n /**\n * The session's transcript as canonical events. Without `before` / `limit`:\n * every turn, as a plain array (the shape every client predating paging\n * reads). With either: one page, `{ events, cursor? }`, the last `limit`\n * turns (default {@link LOAD_EVENTS_PAGE_TURNS}, at most\n * {@link LOAD_EVENTS_MAX_PAGE_TURNS}) before turn position `before`\n * (default: the end), its start moved back to an exchange boundary when one\n * is near so a tool call is never cut from its result. `cursor`: the\n * `before` of the previous page, absent at the first turn. Typed here as\n * the unpaged call every client makes; a paged call goes through\n * {@link loadEventsPage}. Paging is additive: an older host ignores the\n * fields and answers the whole array.\n */\n 'sessions.loadEvents': { params: { sessionId: string }, result: StreamEvent[] }\n /**\n * Reattach without a reload: the session's signals numbered after\n * `afterSeq` (see {@link SIGNAL_SEQ_FIELD}), in order, as long as this host\n * process (`epoch`, from `HelloResult.signalEpoch`) still holds them all.\n * Otherwise refused, and the client reloads with `sessions.loadEvents`.\n * Additive: an older host answers \"method not found\", same fallback.\n */\n 'sessions.resume': { params: { sessionId: string, epoch: string, afterSeq: number }, result: SessionResumeResult }\n /** One turn of a session by id, or `null` when unknown. */\n 'sessions.getTurn': { params: { sessionId: string, turnId: string }, result: SessionTurn | null }\n /** The session's context usage broken down by category, or `null` when unknown. */\n 'sessions.contextBreakdown': { params: { sessionId: string }, result: ContextBreakdown | null }\n /**\n * Artifacts one session recorded (PRs, branches, commits, files,\n * extension kinds — see `session/artifacts.ts`), newest first. Empty on\n * stores without artifact support. Additive; pre-artifact daemons\n * reject the method and clients treat that as empty.\n */\n 'sessions.artifacts': { params: { sessionId: string, kind?: string, limit?: number }, result: SessionArtifact[] }\n /**\n * Artifacts across sessions, filtered by project root (`null` = untagged\n * sessions, omitted = every project) and/or kind/uri (reverse lookup).\n */\n 'artifacts.list': { params: { projectRoot?: string | null, kind?: string, uri?: string, since?: number, limit?: number }, result: SessionArtifact[] }\n /** Remove one artifact. `false` when the store has no artifact support. Fans out `artifact:changed`. */\n 'artifacts.delete': { params: { sessionId: string, artifactId: string }, result: boolean }\n /**\n * Upsert an artifact — the lazy `resolve()` write-back (refreshed\n * `label` / `meta`). Same merge semantics as `SessionStore.upsertArtifact`;\n * `null` when the session is unknown or the store lacks support.\n */\n 'artifacts.upsert': { params: { artifact: SessionArtifact }, result: SessionArtifact | null }\n /**\n * Transcript search over ONE session, daemon-side. The daemon owns the\n * authoritative turns (live wrapper when an agent is active — fresh\n * mid-run, which a window's load-time snapshot is not) and an LRU index\n * cache shared by every window, so repeat queries pay match cost only.\n * Results come back in TURN ORDER (search is a transcript filter).\n */\n 'history.searchSession': {\n params: { sessionId: string, query: string, limit?: number }\n result: SearchTurnResult[]\n }\n /**\n * Cross-session content search, daemon-side. One RPC replaces a\n * window's per-session index/build/search round-trips — indexes are\n * built once in the daemon and shared by every window.\n */\n 'history.searchAll': {\n params: { query: string, sessionIds: string[], excerptLimit?: number }\n result: Record<string, SessionHistoryMatch>\n }\n /**\n * A window appended transcript content OUT-OF-BAND (local `/` command\n * output, `!` shell turns — written straight to the shared store, not\n * through a host run). The daemon fans out `sessions:changed` so every\n * window (issuer included) re-converges on the canonical replay NOW\n * instead of at the next run end. Sent as a notification.\n */\n 'sessions.touch': { params: { sessionId: string }, result: void }\n /** Fork at `turnId` into a new session (`ChatHost.forkSession`); announced as a `sessions:changed` create. */\n 'sessions.fork': { params: { sessionId: string, turnId: string, title?: string }, result: { id: string } }\n /** History edits (`ChatHost.deleteTurn` / `editTurnText`): refused while the session runs. */\n 'sessions.deleteTurn': { params: { sessionId: string, turnId: string }, result: void }\n /** Replaces the text of one turn. Refused while the session runs. */\n 'sessions.editTurnText': { params: { sessionId: string, turnId: string, text: string }, result: void }\n /** Cut the history at `turnId` in place (`ChatHost.rewindSession`); `inclusive` keeps the turn. Refused while the session runs. */\n 'sessions.rewind': { params: { sessionId: string, turnId: string, inclusive: boolean }, result: void }\n /** Bind to a folder, or back to a plain chat with `cwd: ''` (`ChatHost.setSessionFolder`). */\n 'sessions.setFolder': { params: { sessionId: string, cwd: string }, result: void }\n /** Turns written outside a run, e.g. `!` shell output (`ChatHost.appendTurns`). */\n 'sessions.appendTurns': { params: { sessionId: string, turns: SessionTurn[] }, result: void }\n /**\n * `ctx.appendNote` outside a run: a display-only note, rendered live and\n * persisted (`ChatHost.appendNote`). False for an unknown session or no blocks.\n */\n 'sessions.appendNote': { params: { sessionId: string, blocks: CommandOutputBlock[] }, result: boolean }\n /** Compact now (`ChatHost.compactSessionNow`): what was done, `null` when nothing was. Older daemons resolve `null`. */\n 'sessions.compact': { params: { sessionId: string }, result: CompactionReport | null }\n\n /** The session's todo list, or `null` when it has none. */\n 'todos.get': { params: { sessionId: string }, result: TodosSnapshot | null }\n /**\n * Apply a user todo edit (add / edit / remove / cycle / clear) to the\n * session the MODEL reads.\n *\n * Required because todos live in `session.metadata` and `todowrite` reads\n * them off the daemon agent's in-memory `Session`. A window writing its own\n * `Session` instance persisted an edit that the daemon never observed, so the\n * model's next `todowrite` silently overwrote it.\n *\n * Sends the whole list rather than a delta: the mutators in\n * `chat/todo-edits.ts` are already whole-list transforms, and a delta would\n * need conflict rules against a list the model rewrites concurrently.\n *\n * `null` = no live agent (or no run owns a todo slot), and the caller should\n * apply its own store-level write — race-free, since nothing is appending.\n *\n * `persistIdle`: with no live agent, the host applies the edit to the stored\n * session itself (the run the list belongs to must exist) instead of\n * answering `null`. Older hosts ignore it.\n */\n 'todos.set': { params: { sessionId: string, items: readonly TodoItem[], persistIdle?: boolean }, result: TodosSnapshot | null }\n\n /*\n * Orchestration — a pinned \"main\" session that drives other sessions\n * (\"workers\"). Feature-gated by `Settings.orchestration`; every method below\n * resolves to `null` / rejects when it is off — the main SURVIVES the toggle\n * as a persisted session, so the gate has to live on the verbs, not just on\n * discovery.\n *\n * `mainId` is load-bearing, not decorative: the host refuses any verb whose\n * `mainId` is not itself a main session. Targets are NOT limited to the\n * workers that main created — the main observes and drives the whole store —\n * but it may never target itself or another main (the depth cap).\n */\n /** The main session id, creating it (directory-less) when the setting is on and none exists. */\n 'orchestration.main': { params: Record<string, never>, result: string | null }\n /** Creates a worker session under a main session and resolves with its session id. */\n 'orchestration.createWorker': { params: { mainId: string } & OrchestrationCreateWorkerParams, result: string }\n /** Lists sessions with their live status, newest first, up to `limit`. The list can be partial. */\n 'orchestration.list': { params: { mainId: string, limit?: number }, result: OrchestrationWorkerRow[] }\n /** Summary of one session, or `null` when unknown. */\n 'orchestration.read': { params: { mainId: string, sessionId: string }, result: OrchestrationWorkerSummary | null }\n /** `wake` (default true): whether that run finishing wakes the main. */\n 'orchestration.send': { params: { mainId: string, sessionId: string, prompt: string, wake?: boolean }, result: void }\n /** Sends a steering message to a worker's live run. */\n 'orchestration.steer': { params: { mainId: string, sessionId: string, message: string }, result: void }\n /** Cancels a worker's run. */\n 'orchestration.cancel': { params: { mainId: string, sessionId: string }, result: void }\n /** The last `limit` turns of a session as plain text. */\n 'orchestration.transcript': { params: { mainId: string, sessionId: string, limit?: number }, result: string }\n\n /** Extension-contributed `/` commands discovered for `cwd`. */\n 'commands.list': { params: { cwd: string, kind?: string }, result: CommandSummary[] }\n /** Argument suggestions for `/name <prefix>` — best-effort, empty on failure. */\n 'commands.completeArgs': { params: { cwd: string, name: string, argsPrefix: string, kind?: string }, result: CommandArgSuggestionSummary[] }\n\n /** Lists pending interactions (questions and prompts the agent asked the user), optionally for one session. */\n 'interactions.list': { params: { sessionId?: string }, result: PendingInteraction[] }\n /** Answers a pending interaction. */\n 'interactions.respond': { params: { requestId: string, response: InteractionResponse }, result: { ok: boolean } }\n /** Cancels a pending interaction. `reason` is passed back to the agent. */\n 'interactions.cancel': { params: { requestId: string, reason?: string }, result: { ok: boolean } }\n /** Re-sends the session's pending interactions, for a client that connected after they were raised. */\n 'interactions.rehydrate': { params: { sessionId: string }, result: PendingInteraction[] }\n /**\n * Dev browser: a window offers to host the pages the agent's `browser_*`\n * tools drive (the GUI's main process). Released when the connection\n * drops. It then answers each `browser:request` signal addressed to it.\n */\n 'browser.registerHost': { params: { hostId: string }, result: { ok: boolean } }\n /** Withdraws a window as dev browser host. */\n 'browser.unregisterHost': { params: { hostId: string }, result: { ok: boolean } }\n /** Answers a `browser:request` signal with the host's result. */\n 'browser.respond': { params: { requestId: string, response: BrowserResponse }, result: { ok: boolean } }\n /**\n * Terminals, run by the host in the session's environment. `clientId`\n * names one view (a window's drawer or panel); views attached through a\n * connection are detached when it drops. Output arrives as\n * `terminal:output` signals; `ack` what was written to keep it flowing.\n */\n 'terminal.state': { params: { sessionId: string }, result: TerminalSessionState }\n /** Opens a terminal in a session's environment. */\n 'terminal.open': { params: TerminalOpenInput, result: TerminalInfo }\n /** Attaches a view (`clientId`) to a terminal and resolves with the output it can replay. */\n /** `maxLines` caps the history snapshot to the last lines a view can show (0 or absent: no cap). */\n 'terminal.attach': { params: { terminalId: string, clientId: string, maxLines?: number }, result: TerminalAttachResult }\n /** Detaches a view from a terminal. */\n 'terminal.detach': { params: { terminalId: string, clientId: string }, result: void }\n /** `clientId` + `response`: bytes the view's emulator generated (DSR/DA replies), dropped unless that view owns the size. */\n 'terminal.write': { params: { terminalId: string, data: string, clientId?: string, response?: boolean }, result: void }\n /** Resizes the terminal to a view's size. `claim` makes this view own the size. */\n 'terminal.resize': { params: { terminalId: string, clientId: string, cols: number, rows: number, claim?: boolean }, result: void }\n /** Acknowledges terminal output up to `offset`, so the host keeps it flowing. */\n 'terminal.ack': { params: { terminalId: string, clientId: string, offset: number }, result: void }\n /** Restarts a terminal's process and resolves with its info. */\n 'terminal.restart': { params: { terminalId: string }, result: TerminalInfo }\n /** Closes a terminal. */\n 'terminal.close': { params: { terminalId: string }, result: void }\n /** Hides a terminal from the agent, or shows it again. */\n 'terminal.setHidden': { params: { terminalId: string, hidden: boolean }, result: void }\n /**\n * This connection can show terminals (the desktop app). While at least one\n * viewer is attached, agents get the terminal tools; the registration is\n * dropped with the connection.\n */\n 'terminal.registerViewer': { params: { viewerId: string }, result: { ok: boolean } }\n /** Withdraws a viewer registered with `terminal.registerViewer`. */\n 'terminal.unregisterViewer': { params: { viewerId: string }, result: { ok: boolean } }\n /**\n * Terminals without a session: a shell on the host's machine in a\n * project's folder, or in a new-chat draft's (`draftId`). Agents never see\n * them. `terminal:project-changed` carries a scope's full list.\n */\n 'terminal.projectState': { params: TerminalProjectStateInput, result: TerminalProjectState }\n /** Opens a terminal bound to a project rather than a session. */\n 'terminal.openInProject': { params: TerminalProjectOpenInput, result: TerminalInfo }\n /** The draft became `sessionId`: its terminals move there in one pass (over the cap: back to the project). */\n 'terminal.adopt': { params: { draftId: string, sessionId: string }, result: TerminalAdoptResult }\n /** The draft was discarded (or became a server session): its terminals go back to the project. */\n 'terminal.releaseDraft': { params: { draftId: string }, result: void }\n\n /** Answers a pending approval request with a decision. */\n 'approvals.resolve': { params: { requestId: string, decision: ApprovalDecision }, result: void }\n /** Denies every pending approval, or only those of `sessionId` when given. */\n 'approvals.denyAll': { params: { sessionId?: string }, result: void }\n /** Lists the approval requests waiting for an answer. */\n 'approvals.listPending': { params: Record<string, never>, result: WireApprovalRequest[] }\n\n /**\n * Type-ahead queue, host-owned so every window sees and can manipulate\n * the same list. `queue.add` queues when a run is in flight and sends\n * immediately otherwise; the host auto-drains the queue FIFO at run end.\n */\n 'queue.list': { params: { sessionId: string }, result: QueuedItem[] }\n\n /**\n * Which `SYSTEM.md` override composes this session's prompt, for windows\n * attaching to an already-warm agent.\n *\n * The `system-md` signal fires once per agent BUILD and the daemon caches\n * agents, so the normal multi-window case (daemon already running, open a\n * second terminal or the GUI) would otherwise never learn that the built-in\n * safety and git doctrine has been replaced. `null` = no live agent yet, in\n * which case the next build broadcasts it.\n */\n 'sessions.systemMd': {\n params: { sessionId: string }\n result: { file: SystemMdFile | null, shadowed: readonly SystemMdFile[] } | null\n }\n /**\n * Every chunk of the session's system prompt with provenance — the\n * Instructions tab. Built from the live agent's assembly, so it reflects\n * MCP instructions, extension fragments and the resolved `SYSTEM.md`.\n */\n 'sessions.contextSegments': { params: { sessionId: string }, result: ContextSegmentsReport | null }\n /**\n * What a switch would cost the session's prompt cache, as the host applies\n * it (`ChatHost.cacheImpact`): what pickers show next to each option.\n * `null` without a live agent or for an empty change. Additive: an older\n * host answers \"method not found\", and clients show no estimate.\n */\n 'sessions.cacheImpact': { params: { sessionId: string, change: CacheImpactChange }, result: CacheImpact | null }\n /**\n * The session's last requests and what the cache did for each\n * (`ChatHost.cacheReport`): what `/cache` prints, for the GUI's session\n * details. `null` for an unknown session. Additive: an older host answers\n * \"method not found\".\n */\n 'sessions.cacheReport': { params: { sessionId: string, limit?: number }, result: CacheReport | null }\n /** Seed a user-scope `SYSTEM.md` from the session's doctrine; throws when an override could not apply. */\n 'sessions.createSystemOverride': { params: { sessionId: string }, result: { path: string, created: boolean } }\n /** Adds a message to the session's queue. `delivered` tells whether it was queued, sent right away, or used to steer a live run. */\n 'queue.add': {\n /**\n * `asCommand`: see `SendOptions.asCommand` — the host refuses when it cannot resolve it.\n * `keepDraft`: see `SendOptions.keepDraft` — a prompt from outside the composer.\n */\n params: { sessionId: string, text: string, activatedSkills?: string[], attachments?: PromptAttachment[], asCommand?: string, keepDraft?: boolean }\n result: { delivered: 'queued' | 'sent' | 'steer' }\n }\n /** Removes a queued entry by id. Resolves `true` when it was removed. */\n 'queue.remove': { params: { sessionId: string, id: string }, result: boolean }\n /**\n * Edit a queued entry in place; order is kept. `attachments` replaces the\n * entry's list when given. `false` when already sent / dropped.\n */\n 'queue.update': { params: { sessionId: string, id: string, text: string, attachments?: PromptAttachment[] }, result: boolean }\n /** A queued entry's attachments with their bytes; `null` when already sent / dropped. */\n 'queue.attachments': { params: { sessionId: string, id: string }, result: PromptAttachment[] | null }\n /** Steer a queued entry into the live run now (falls back to send when idle). */\n 'queue.pushNow': { params: { sessionId: string, id: string }, result: { delivered: 'steer' | 'send' | 'queued' | 'missing' } }\n\n /** Current shared draft for a session — backfill on window attach. */\n 'drafts.get': { params: { sessionId: string }, result: { text: string, shell?: boolean, attachments?: PromptAttachment[], search?: { active: boolean, query: string } } }\n /**\n * Replace the session's shared draft. Fans out `draft:changed` to every\n * OTHER peer. Ephemeral daemon state — drafts don't survive a daemon\n * restart and are cleared when any window submits the prompt.\n *\n * `shell` carries the prompt's shell mode OUT OF BAND — never encoded\n * into the text, so a literal leading `!` in a normal draft can't flip\n * other windows into shell-execution semantics.\n */\n 'drafts.set': { params: { sessionId: string, text: string, shell?: boolean }, result: void }\n /** Replace the shared draft's composing attachments (notification). */\n 'drafts.setAttachments': { params: { sessionId: string, attachments: PromptAttachment[] }, result: void }\n /** Replace the shared transcript-search state (notification, per keystroke). */\n 'search.set': { params: { sessionId: string, active: boolean, query: string }, result: void }\n /**\n * Extension bus emit from a wire client whose extensions run CLIENT-side\n * (TUI daemon mode — the extension has no host to broadcast through).\n * Sent as a notification. The daemon validates the extension id against\n * the session cwd's registry (boot registry when no `sessionId`) and the\n * `'ipc'` permission, re-validates the 64 KiB payload cap, delivers to\n * its own subscribers, and fans out `extension:signal` to every OTHER\n * peer (origin excluded — the emitter already delivered locally).\n */\n 'extension.emit': { params: { extensionId: string, sessionId?: string, payload: JsonValue, seq: number, nonce?: string }, result: void }\n /**\n * Resolve inline ghost-text autocomplete daemon-side (the typing\n * window's request IS the single computation): canonical resolver\n * against the session cwd's extension registry. Latest-wins per\n * session — a `seq` older than the newest seen returns\n * `{ suggestion: null }` without computing, and a newer request\n * aborts an in-flight compute. The result additionally fans out as\n * `suggest:changed` to every OTHER peer.\n */\n 'suggest.resolve': { params: { sessionId: string, text: string, caret: number, seq: number }, result: { suggestion: string | null, seq: number, candidates?: string[] } }\n\n /** Reads the host settings. */\n 'settings.get': { params: Record<string, never>, result: HostSettings }\n /** Applies a partial settings patch and resolves with the full settings after it. */\n 'settings.set': { params: { patch: Partial<HostSettings> }, result: HostSettings }\n\n /** Current presence snapshot — backfill for a freshly opened session list. */\n 'presence.list': { params: Record<string, never>, result: SessionPresence[] }\n /**\n * Tag the calling peer as watching a session (one per connection; the\n * TUI opens one connection per activated session). Sent as a\n * notification right after the handshake. Detach is implicit — the\n * daemon recomputes presence when the socket drops.\n */\n 'presence.watch': { params: { sessionId: string }, result: void }\n\n /**\n * Where this host lets a session's folder be: a server's workspace roots\n * (`confined`: `sessions.create` / `setFolder` refuse anything outside),\n * or the user's home on a local host (unconfined). Additive.\n */\n 'fs.roots': { params: Record<string, never>, result: FsRoots }\n /**\n * The folders in `path` (default: the first root), for a folder picker on\n * the host's machine. Only inside the roots (real paths: `..` and\n * symlinks out are refused), no dotfiles. Additive.\n */\n 'fs.listDirs': { params: { path?: string }, result: FsDirListing }\n\n /**\n * The host's provider credentials, as the host's agents use them (its\n * data dir's `credentials.json` and environment): per provider, whether\n * something is configured, its stored API key / OAuth accounts (labels,\n * which is active) and an env var it reads. Never a secret. Additive.\n */\n 'auth.status': { params: Record<string, never>, result: { providers: HostProviderAuth[] } }\n /**\n * Store an API key for one of the host's providers as its active\n * credential, apply it to the host's environment, and rebuild agents\n * (idle now, busy ones at run end). Returns the provider's new status.\n * OAuth sign-in goes through `auth.oauth.*`. Additive.\n */\n 'auth.setApiKey': { params: { provider: string, key: string }, result: HostProviderAuth }\n /**\n * Remove one stored credential (`account`: its key from `auth.status`) or,\n * without one, every stored credential of the provider; then as\n * `auth.setApiKey`. A key the host only has from its own environment is\n * left alone. Additive.\n */\n 'auth.remove': { params: { provider: string, account?: string }, result: { removed: boolean, provider: HostProviderAuth } }\n /**\n * OAuth sign-in with the browser on the CLIENT and the tokens on the host:\n * the host starts a provider's login (`provider`) or an MCP server's\n * (`mcpServer`, found in `cwd`'s catalog, as `catalog.mcps`), keeping the\n * PKCE verifier and `state`, and answers with the authorization URL.\n * `mode: 'loopback'`: the client listens at `redirectUri` (a provider's\n * fixed port; for an MCP server the loopback URI the client passed) and\n * forwards the code; `'browser'`: the client opens `url` (pasting a code if\n * the page shows one); `'device'`: shows `userCode`. The flow belongs to\n * this connection, is single-use and expires (`expiresAt`). Additive.\n */\n 'auth.oauth.begin': { params: { provider?: string, mcpServer?: string, cwd?: string, kind?: string, redirectUri?: string }, result: HostOAuthBegin }\n /**\n * Deliver the code (`code` + `state` from the loopback, or `input`: what\n * the user pasted) once, then wait for the host's token exchange; without\n * either, just wait (device and polling flows). A wrong `state` or another\n * connection's flow is refused. Tokens stay on the host: the result says\n * what changed, never a secret.\n */\n 'auth.oauth.complete': { params: { flowId: string, code?: string, state?: string, input?: string }, result: HostOAuthComplete }\n /**\n * Answer the step a flow is waiting on (`HostOAuthBegin.step` before its\n * URL, `HostOAuthComplete.step` after): a select's option id (none:\n * cancel), a prompt's text. Answers with where the flow is now: its URL, or\n * the next step. Then `complete` as before. Additive.\n */\n 'auth.oauth.respond': { params: { flowId: string, stepId: string, value?: string }, result: HostOAuthBegin }\n /** Abandon a flow of this connection. */\n 'auth.oauth.cancel': { params: { flowId: string }, result: { cancelled: boolean } }\n\n /**\n * What the host discovered for the settings tabs, each entry with whether\n * the host's settings enable it (an unset allowlist enables everything).\n * `cwd` adds the project scope of that folder (inside the workspace roots\n * on a server); without it, the user scope (the host user's home). The\n * enabled lists are written with `settings.set`. Installing, removing and\n * MCP sign-in stay on the host's machine. Additive.\n */\n 'catalog.skills': { params: { cwd?: string, kind?: string }, result: { skills: HostCatalogSkill[] } }\n /** MCP servers: `env` and `headers` values, URL credentials and query values are redacted. */\n 'catalog.mcps': { params: { cwd?: string, kind?: string }, result: { servers: HostCatalogMcp[], errors: HostCatalogError[] } }\n /** Extensions installed for `cwd`. */\n 'catalog.extensions': { params: { cwd?: string, kind?: string }, result: { extensions: HostCatalogExtension[] } }\n /** Plugins installed for `cwd`, with what each contributes. */\n 'catalog.plugins': { params: { cwd?: string, kind?: string }, result: { plugins: HostCatalogPlugin[] } }\n /**\n * Install a skill or an extension on the host, in its user's scope only\n * (`scope` may only be `'user'`): a GitHub (`owner/repo[#ref][:dir]`, a\n * GitHub URL, a skills.sh URL) or npm spec; paths are refused. `skills` /\n * `all` pick from a multi-skill source (the `multiple-candidates` error\n * lists them), `extension` from a multi-extension one. Runs the host's\n * package managers and fetches code there: a zidane-server's\n * `allowRemoteInstalls` gates it, every attempt is audited. Bounded in\n * time; the progress lines come back with the result. Every window gets\n * `catalog:changed`. Additive (`remoteInstalls` on `ipc.hello`).\n */\n 'catalog.install': { params: { kind: HostInstallKind, spec: string, scope?: 'user', skills?: string[], all?: boolean, extension?: string, overwrite?: boolean }, result: { installed: string[], message: string, progress: string[] } }\n /** Remove a user-scope skill or extension of the host by name (its directory). As `catalog.install`. */\n 'catalog.remove': { params: { kind: HostInstallKind, name: string }, result: { removed: string, message: string } }\n /** Update a user-scope extension installed from a source. As `catalog.install`. */\n 'catalog.update': { params: { kind: HostInstallKind, name: string }, result: { updated: string, upToDate: boolean, message: string } }\n /**\n * Add or replace an MCP server in the host user's `mcps.json`. Its `env` /\n * `headers` values are stored there and never come back (`catalog.mcps`\n * redacts them, the reply names the server only). As `catalog.install`.\n */\n 'mcp.upsert': { params: { config: McpServerConfig }, result: { name: string, created: boolean } }\n /** Remove an MCP server from the host user's `mcps.json`; `removed: false` when it has none. As `catalog.install`. */\n 'mcp.remove': { params: { name: string }, result: { removed: boolean } }\n /**\n * The host's credentialed providers (what its agents can run) and their\n * models, for a model picker of a session on that host. `cwd` adds the\n * providers its extensions contribute there. Additive.\n */\n 'models.list': { params: { cwd?: string, kind?: string }, result: { providers: HostModelProvider[] } }\n /**\n * Send one tiny decision with this host's credentials, to check a decision\n * model works. `model` is `\"providerKey/modelId\"`, tested exactly; omitted =\n * the host's `Settings.decisionModel` (or the first available). Never\n * fails: a broken model comes back as `ok: false` with a reason. Additive.\n */\n 'decisions.test': { params: { cwd?: string, kind?: string, model?: string }, result: HostDecisionTestResult }\n /**\n * Send one tiny prompt with this host's credentials, to check a chat model\n * answers. `model` is `\"providerKey[@account]/modelId\"`, tested exactly.\n * Never fails: a broken model comes back as `ok: false` with a reason.\n * Additive.\n */\n 'models.test': { params: { cwd?: string, kind?: string, model: string }, result: HostModelTestResult }\n\n /**\n * The machines this host knows (`docs/MACHINES.md`), online or not, and\n * forgetting one (it disconnects; its `local@` / `worktree@` kinds stop\n * resolving). Additive.\n */\n 'machines.list': { params: Record<string, never>, result: MachineInfo[] }\n /** Forgets a machine. It disconnects and its kinds stop resolving. */\n 'machines.forget': { params: { machineId: string }, result: { forgotten: boolean } }\n /**\n * Folders of a machine, for a client's folder picker: the host proxies a\n * listing to the machine (`fs.list`, confined to its roots there): the\n * folders in `path` (absent: its first root), and every root. Additive.\n */\n 'machines.listDirs': { params: { machineId: string, path?: string }, result: { path: string, dirs: string[], roots: string[] } }\n /**\n * A local host's machine links (`docs/MACHINES.md` § Client UI), behind\n * remote hosts: share this computer with a saved server (the machine agent\n * runs in this host's process, with the machine token `token` or the one\n * already stored for that server), stop sharing, use a saved server as a\n * machine (reverse direction), and read their state. Refused while remote\n * hosts are off. Additive.\n */\n 'machines.share.start': { params: { hostId: string, name: string, roots: string[], token?: string }, result: MachineLinksStatus }\n /** Stops sharing this computer with a server. */\n 'machines.share.stop': { params: { hostId: string }, result: MachineLinksStatus }\n /** Turns on or off using a server as this computer's linked server. */\n 'machines.useServer': { params: { hostId: string, enabled: boolean }, result: MachineLinksStatus }\n /** State of this host's machine links: the shares it offers and the servers it uses. */\n 'machines.links.status': { params: Record<string, never>, result: MachineLinksStatus }\n /**\n * Reverse direction (`docs/MACHINES.md` § Reverse direction): a client asks\n * this server to lend itself as a machine over this very connection\n * (`allowAsMachine` on, else refused). `hostId` names the asking host, so\n * a reconnect finds its tasks and terminals again. Then `machine.call`\n * carries each host→machine request (`MachineMethods`), answered by the\n * server's confined executor; machine notifications come back as\n * `machine:notification` signals on this connection only.\n */\n 'machine.attach': { params: { hostId: string }, result: MachineRegisterParams }\n /** Runs one machine-protocol method on this server's executor and resolves with its JSON result. Refused when the server does not lend itself as a machine. */\n 'machine.call': { params: { method: string, params?: JsonValue }, result: JsonValue }\n /** Ends this connection's machine attachment. `detached` is `false` when it had none. */\n 'machine.detach': { params: Record<string, never>, result: { detached: boolean } }\n /**\n * Mint a `machine`-scoped token on this server (a zidane-server only), so\n * a window can share its computer in one step. Any client may: in the\n * single-user model a client token is already an admin's. Audited.\n */\n 'tokens.createMachineToken': { params: { name: string }, result: { id: string, name: string, token: string } }\n\n /**\n * Settings sync, a client's computer → this server (`docs/SERVER.md`\n * § Settings sync). A zidane-server only; other hosts refuse. One source\n * device per server: `sync.claim` makes the caller it (or says who is,\n * unless `takeover`), `sync.push` applies one category's snapshot through\n * the host's own setters, skipping fields edited here since (overrides),\n * `sync.reset` drops an override, `sync.release` stops the source. Every\n * call is audited with its token. Additive.\n */\n 'sync.status': { params: Record<string, never>, result: SyncStatus }\n /** Makes the caller the settings source device. When another device is the source, the result says which, unless `takeover` is set. `categories` and `keys` narrow what it syncs. */\n 'sync.claim': { params: { deviceId: string, deviceName: string, takeover?: boolean, categories?: SyncCategory[], keys?: string[] }, result: SyncClaimResult }\n /** Applies one category's snapshot from the source device. */\n 'sync.push': { params: { deviceId: string, category: SyncCategory, payload: SyncPayload }, result: SyncPushResult }\n /** Drops the local override of one field so sync applies to it again. */\n 'sync.reset': { params: { field: string }, result: { reset: boolean } }\n /** Stops the source device's sync. */\n 'sync.release': { params: { deviceId: string }, result: { released: boolean } }\n\n /** Daemon identity and version: `protocolVersion`, `appVersion`, `pid`, `startedAt` and the host identity fields of the `hello` result. */\n 'daemon.info': { params: Record<string, never>, result: HelloResult }\n /**\n * Graceful drain: deny pending approvals, abort live runs, close the\n * socket. Used by clients that detect a protocol-version mismatch and\n * need the stale daemon gone before respawning.\n *\n * `whenIdle` (version-skew retirement): a daemon with active work does\n * NOT abort it. It answers `{ deferred: true }` and exits once idle.\n * Explicit stops (`zidane daemon stop`) omit it and drain immediately.\n * Daemons predating the flag ignore it and drain immediately.\n */\n 'daemon.shutdown': { params: { whenIdle?: boolean }, result: { deferred?: boolean } | void }\n}\n\n/**\n * The host's identity from a hello (or `daemon.info`) reply; `null` from a host that predates it.\n * @param hello - The `hello` or `daemon.info` result.\n * @returns The host reference, or `null` when the reply carries no host id or kind.\n */\nexport function hostRefOf(hello: HelloResult): HostRef | null {\n if (typeof hello.hostId !== 'string' || !hello.hostKind)\n return null\n return { id: hello.hostId, kind: hello.hostKind, name: hello.hostName ?? hello.hostId }\n}\n\n/** Name of any method in {@link IpcMethods}. */\nexport type IpcMethodName = keyof IpcMethods\n/** Params type of the method `M` in {@link IpcMethods}. */\nexport type IpcParams<M extends IpcMethodName> = IpcMethods[M]['params']\n/** Result type of the method `M` in {@link IpcMethods}. */\nexport type IpcResult<M extends IpcMethodName> = IpcMethods[M]['result']\n\n/** Turns per `sessions.loadEvents` page when only `before` is given. */\nexport const LOAD_EVENTS_PAGE_TURNS = 200\n/** Largest `limit` a host honors. */\nexport const LOAD_EVENTS_MAX_PAGE_TURNS = 1000\n\n/** Paging options of `sessions.loadEvents`. */\nexport interface LoadEventsPaging {\n /** Turn position (exclusive) the page ends at: a previous page's `cursor`. */\n before?: number\n /** Turns in the page. */\n limit?: number\n /**\n * The page ends right before the turn with this id (same alignment as\n * `before` at its position); wins over `before`. A turn the stored\n * transcript doesn't hold fails the request (invalid params, the message\n * names `beforeTurnId`). An older host ignores it: see\n * {@link SessionEventsPage.beforeTurnId}.\n */\n beforeTurnId?: string\n}\n\n/** One page of a session's stream events, as `sessions.loadEvents` answers it. */\nexport interface SessionEventsPage {\n /** Stream events of the page. */\n events: StreamEvent[]\n /** Pass as `before` for the page before this one; absent once the first turn is in. */\n cursor?: number\n /**\n * The events are this page's slice of the whole replay, so pages\n * concatenate to exactly one whole `loadEvents`. Absent from an older\n * host, whose pages replay on their own ({@link loadAllEvents} restores\n * the exchange separator at their joins).\n */\n exact?: true\n /**\n * With `exact`: how many events of the whole replay come before this\n * page. Lets a client open on the tail of a long transcript and still\n * say how much it left out ({@link loadEventsTail}). Absent from an\n * older host.\n */\n start?: number\n /**\n * The request's `beforeTurnId`, echoed: absent when the host ignored\n * the anchor (an older host, which then paged by `before` / from the end).\n */\n beforeTurnId?: string\n}\n\n/**\n * One page of `sessions.loadEvents` (see its paging). An older host answers\n * the whole transcript: it comes back as one page with no cursor.\n * @param request - Sends `sessions.loadEvents` to the host.\n * @param params - Session id and paging.\n * @returns The page, normalized from either host reply shape.\n */\nexport async function loadEventsPage(\n request: (method: 'sessions.loadEvents', params: { sessionId: string }) => Promise<StreamEvent[]>,\n params: { sessionId: string } & LoadEventsPaging,\n): Promise<SessionEventsPage> {\n const result = await request('sessions.loadEvents', params) as StreamEvent[] | SessionEventsPage\n return Array.isArray(result) ? { events: result } : result\n}\n\nfunction isResponseTooLarge(err: unknown): boolean {\n return typeof err === 'object' && err !== null && (err as { code?: unknown }).code === IpcErrorCode.ResponseTooLarge\n}\n\n/**\n * A session's whole transcript, loaded a page at a time from the end so no\n * single reply carries it all (a long session with images can outgrow a\n * transport's message size). A page refused as too large is asked again at\n * half the turns, down to one; a single turn that still doesn't fit fails\n * the load. An older host answers the whole transcript to the first call.\n * @param request - Sends `sessions.loadEvents` to the host.\n * @param sessionId - Session to load.\n * @param options - Paging options.\n * @param options.pageTurns - Turns per page to start with.\n * @returns Every stream event of the session.\n */\nexport async function loadAllEvents(\n request: (method: 'sessions.loadEvents', params: { sessionId: string }) => Promise<StreamEvent[]>,\n sessionId: string,\n options: { pageTurns?: number } = {},\n): Promise<StreamEvent[]> {\n return (await loadEventsFromEnd(request, sessionId, options.pageTurns ?? LOAD_EVENTS_PAGE_TURNS)).events\n}\n\n/**\n * The end of a session's transcript: pages from the end until `enough`\n * holds for what was loaded (or the first turn is in), and how many events\n * of the whole replay come before it (`earlier`). Only exact pages can stop\n * early, since only they say where they start: an older host's transcript\n * loads whole, with `earlier` 0.\n */\nexport async function loadEventsTail(\n request: (method: 'sessions.loadEvents', params: { sessionId: string }) => Promise<StreamEvent[]>,\n sessionId: string,\n enough: (events: readonly StreamEvent[]) => boolean,\n options: { pageTurns?: number } = {},\n): Promise<{ events: StreamEvent[], earlier: number }> {\n return loadEventsFromEnd(request, sessionId, options.pageTurns ?? LOAD_EVENTS_PAGE_TURNS, enough)\n}\n\nasync function loadEventsFromEnd(\n request: (method: 'sessions.loadEvents', params: { sessionId: string }) => Promise<StreamEvent[]>,\n sessionId: string,\n pageTurns: number,\n enough?: (events: readonly StreamEvent[]) => boolean,\n): Promise<{ events: StreamEvent[], earlier: number }> {\n let limit = pageTurns\n const pages: StreamEvent[][] = []\n let newerExact = false\n let allExact = true\n let before: number | undefined\n for (;;) {\n let page: SessionEventsPage\n try {\n page = await loadEventsPage(request, { sessionId, limit, ...(before !== undefined ? { before } : {}) })\n }\n catch (err) {\n if (isResponseTooLarge(err) && limit > 1) {\n limit = Math.max(1, Math.floor(limit / 2))\n continue\n }\n throw err\n }\n /*\n * An exact page is a slice of the whole replay: nothing to restore. An\n * older host's pages replay on their own, so the exchange separator a\n * whole replay puts before a prompt that follows an exchange is missing\n * where the newer page starts (its pages start at a prompt when they\n * can): put it back.\n */\n const newer = pages[0]\n if (newer && !newerExact && newer[0]?.kind === 'user-prompt' && page.events.length > 0)\n newer.unshift({ kind: 'separator', text: '' })\n newerExact = page.exact === true\n allExact &&= newerExact && page.start !== undefined\n pages.unshift(page.events)\n // Done at the first turn; a cursor that doesn't move back would loop.\n if (page.cursor === undefined || page.cursor <= 0 || (before !== undefined && page.cursor >= before))\n break\n if (enough && allExact) {\n const events = pages.flat()\n if (enough(events))\n return { events, earlier: page.start! }\n }\n before = page.cursor\n }\n return { events: pages.flat(), earlier: 0 }\n}\n\n/** Turns per `sessions.getTurns` page by default. */\nexport const SESSION_TURNS_PAGE = 200\n/** Largest `limit` a host honors for `sessions.getTurns`. */\nexport const SESSION_TURNS_MAX_PAGE = 1000\n\ntype SessionDocumentRequest = <M extends 'sessions.get' | 'sessions.getTurns'>(method: M, params: IpcParams<M>) => Promise<IpcResult<M>>\n\n/**\n * What `sessions.get` answers: the document; with `turns: false`, the\n * version of the snapshot it was cut from, the one `sessions.getTurns`\n * pages carry.\n */\nexport type SessionDocumentHead = SessionData & { version?: string }\n\n/** How many times a paged read starts over because the session changed under it, before it asks for the whole document in one reply. */\nconst SESSION_DOCUMENT_RESTARTS = 3\n\n/**\n * A session's whole document, read a page of turns at a time so no reply\n * carries it all (`sessions.getTurns` pages, then the `sessions.get`\n * `turns: false` head; a page refused as too large is asked again at half\n * the turns). Every page and the head name the snapshot they come from: a\n * version change mid-read (a turn appended, a compaction) starts the read\n * over, so the result is one version, never pages of two. After\n * {@link SESSION_DOCUMENT_RESTARTS} restarts (a session busier than the\n * read), the whole document comes in one reply. A host that predates\n * `sessions.getTurns` sends it that way too; one that names no version is\n * read as before. `null` when the host doesn't know the session.\n * @param request - Sends `sessions.get` and `sessions.getTurns` to the host.\n * @param sessionId - Session to read.\n * @param options - Paging options.\n * @param options.pageTurns - Turns per page to start with.\n * @returns The session document, or `null` when unknown.\n */\nexport async function loadSessionDocument(\n request: SessionDocumentRequest,\n sessionId: string,\n options: { pageTurns?: number } = {},\n): Promise<SessionData | null> {\n const paging = { limit: options.pageTurns ?? SESSION_TURNS_PAGE }\n for (let attempt = 0; attempt <= SESSION_DOCUMENT_RESTARTS; attempt++) {\n const read = await readSessionDocumentOnce(request, sessionId, paging)\n if (read !== 'changed')\n return read\n }\n return withoutVersion(await request('sessions.get', { sessionId }))\n}\n\nfunction withoutVersion(head: SessionDocumentHead | null): SessionData | null {\n if (!head)\n return null\n const { version: _version, ...data } = head\n return data\n}\n\n/** One paged read; `'changed'`: the version moved between two of its replies. */\nasync function readSessionDocumentOnce(request: SessionDocumentRequest, sessionId: string, paging: { limit: number }): Promise<SessionData | null | 'changed'> {\n const turns: SessionTurn[] = []\n let total = Infinity\n let version: { of?: string } | null = null\n while (turns.length < total) {\n let page: IpcResult<'sessions.getTurns'>\n try {\n page = await request('sessions.getTurns', { sessionId, from: turns.length, limit: paging.limit })\n }\n catch (err) {\n if (turns.length === 0 && isMethodNotFound(err))\n return withoutVersion(await request('sessions.get', { sessionId }))\n if (isResponseTooLarge(err) && paging.limit > 1) {\n paging.limit = Math.max(1, Math.floor(paging.limit / 2))\n continue\n }\n throw err\n }\n if (!page)\n return null\n if (version === null)\n version = { ...(page.version !== undefined ? { of: page.version } : {}) }\n else if (page.version !== version.of)\n return 'changed'\n total = page.total\n // A session that shrank meanwhile on a host that names no version ends the read where it is.\n if (page.turns.length === 0)\n break\n turns.push(...page.turns)\n }\n const head = await request('sessions.get', { sessionId, turns: false })\n if (!head)\n return null\n if (version !== null && head.version !== version.of)\n return 'changed'\n return { ...withoutVersion(head)!, turns }\n}\n\n/** A catalog entry's on/off state as the host's settings decide it. */\ninterface HostCatalogToggle {\n name: string\n /** The host's settings enable it (always `false` for an entry that cannot load). */\n enabled: boolean\n /**\n * Its own allowlist governs it (`enabledSkills`, …). `false`: contributed\n * by a plugin or extension (their toggle governs it), or broken.\n */\n toggleable: boolean\n}\n\n/** A skill in the host's catalog. */\nexport interface HostCatalogSkill extends HostCatalogToggle {\n /** What the skill is for. */\n description: string\n /** Where the skill was found. */\n source?: 'project' | 'user' | 'inline' | 'builtin'\n /** `SKILL.md` on the host's machine. */\n location?: string\n /** `disk`: a scan path; else the plugin or extension that contributes it (`contributedBy`). */\n origin: 'disk' | 'plugin' | 'extension'\n /** Name of the plugin or extension that contributes the skill, when `origin` is not `disk`. */\n contributedBy?: string\n}\n\n/** Every secret-bearing value of a catalog entry is replaced by this. */\nexport const REDACTED = '<redacted>'\n\n/** An MCP server in the host's catalog. Secret values are redacted. */\nexport interface HostCatalogMcp extends HostCatalogToggle {\n /** How the server is reached. */\n transport: 'stdio' | 'sse' | 'streamable-http'\n /** Whether the config is the project's or the user's. */\n source: 'project' | 'user'\n /** The config file on the host's machine. */\n path: string\n /** Command that starts a `stdio` server. */\n command?: string\n /** Arguments of the command. */\n args?: string[]\n /** Credentials and query values redacted. */\n url?: string\n /** Working directory of the command. */\n cwd?: string\n /** `context` runs the server in the agent's execution context. `host` runs it on the host. */\n scope?: 'host' | 'context'\n /** `oauth` when the server signs in with OAuth. */\n auth?: 'oauth'\n /** Names only: every value is {@link REDACTED}. */\n env?: Record<string, string>\n /** Header names. Every value is {@link REDACTED}. */\n headers?: Record<string, string>\n}\n\n/** A config file that failed to parse (or an informational skip). */\nexport interface HostCatalogError {\n /** Path of the config file. */\n path: string\n /** Whether the file is the project's or the user's. */\n source: 'project' | 'user'\n /** Why it failed or was skipped. */\n message: string\n /** `true` when the entry is a skip notice, not a failure. */\n informational?: boolean\n}\n\n/** An extension in the host's catalog. */\nexport interface HostCatalogExtension extends HostCatalogToggle {\n /** Where the extension was found. */\n source: 'user' | 'project' | 'inline' | 'builtin'\n /** Version from the extension manifest. */\n version?: string\n /** What the extension does. */\n description?: string\n /** Directory of the extension on the host's machine. */\n dir?: string\n /** Why it did not load. */\n error?: string\n /** What it contributes: `tools`, `skills`, `mcps`, `commands`, … */\n capabilities?: string[]\n}\n\n/** A plugin in the host's catalog. */\nexport interface HostCatalogPlugin extends HostCatalogToggle {\n /** Where the plugin comes from: a directory on disk, or an extension. */\n origin: { kind: 'disk', scope: 'project' | 'user', dir: string } | { kind: 'extension', extensionName: string, dir: string }\n /** `false`: the manifest was rejected (`error` says why). */\n ok: boolean\n /** Version from the plugin manifest. */\n version?: string\n /** What the plugin does. */\n description?: string\n /** Names of the skills the plugin contributes. */\n skills: string[]\n /** Names of the MCP servers the plugin contributes. */\n mcpServers: string[]\n /** Why the manifest was rejected, when `ok` is `false`. */\n error?: string\n}\n\n/** One provider a host can run, with its models (`models.list`). */\nexport interface HostModelProvider {\n /** Provider key. */\n key: string\n /** Display name. */\n label: string\n /** Models the provider offers on this host. */\n models: HostModelInfo[]\n /**\n * The host's stored accounts of the provider a session can be pinned to\n * (`ProviderAuth.accounts`), when it has several. Ids are the host's own:\n * a pick on a server names one of its accounts. Additive.\n */\n accounts?: Array<{ id: string, label: string, active: boolean }>\n /**\n * Decision models of the provider's Decisions endpoint, with whether this\n * host's credentials can use them. Absent on providers without one, and\n * from hosts that predate decisions. Additive.\n */\n decisionModels?: HostDecisionModel[]\n /**\n * Image models of the provider's image endpoint, with whether this host's\n * credentials can use them. Absent on providers without one, and from\n * hosts that predate image generation. Additive.\n */\n imageModels?: HostImageModel[]\n}\n\n/** One image model a host's provider serves (`HostModelProvider.imageModels`). */\nexport interface HostImageModel {\n id: string\n name: string\n /** The model takes reference images. */\n references: boolean\n /** The model can return a transparent background. */\n transparency: boolean\n available: boolean\n reason?: string\n /** The model `generate_image` uses while no image model is picked. Additive. */\n isDefault?: boolean\n}\n\n/** `decisions.test`: how the probe decision went. */\nexport interface HostDecisionTestResult {\n ok: boolean\n provider?: string\n model?: string\n durationMs: number\n reason?: string\n message?: string\n}\n\n/** `models.test`: how the probe prompt went, in the fields of `decisions.test`. */\nexport type HostModelTestResult = HostDecisionTestResult\n\n/** One decision model a host's provider serves (`models.list`). */\nexport interface HostDecisionModel {\n id: string\n available: boolean\n reason?: string\n}\n\n/** `ModelInfo` as it crosses the wire. */\nexport interface HostModelInfo {\n /** Model id. */\n id: string\n /** Display name. */\n name?: string\n /** Context window in tokens. */\n contextWindow: number\n /** Maximum output tokens. */\n maxTokens?: number\n /** Whether the model supports reasoning. */\n reasoning?: boolean\n /** Input kinds the model accepts. */\n input?: ('text' | 'image')[]\n /** Price per million tokens, by token kind. */\n cost?: { input: number, output: number, cacheRead?: number, cacheWrite?: number }\n /** Provider that serves the model. */\n provider?: string\n /** Model-specific boolean options, with an optional cost multiplier per token kind. */\n options?: { id: string, label: string, description?: string, costMultiplier?: { input?: number, output?: number, cacheRead?: number, cacheWrite?: number } }[]\n}\n\n/** One credential source of a host's provider (`auth.status`); no secret. */\nexport interface HostAuthMethod {\n /** Where the credential comes from: a stored API key, an OAuth login, or an environment variable. */\n source: 'apikey' | 'oauth' | 'env'\n /** A stored credential the provider resolves (`env` never is). */\n active: boolean\n /** Credentials-file key of a stored credential: the `account` of `auth.remove`. */\n key?: string\n /** OAuth account name. */\n label?: string\n /** Display detail: `credentials.json`, an OAuth account and its expiry, an env var name. */\n detail: string\n}\n\n/**\n * A question the provider's sign-in asks before (or after) its URL: a choice\n * between flows, or a free text. The client shows it and answers with\n * `auth.oauth.respond`; the host never picks for the user.\n */\nexport type HostOAuthStep\n = | { id: string, kind: 'select', message: string, options: Array<{ id: string, label: string }> }\n | { id: string, kind: 'prompt', message: string, placeholder?: string, allowEmpty?: boolean }\n\n/** Result of `auth.oauth.begin`. */\nexport interface HostOAuthBegin {\n /** Random, single-use, bound to the connection that began it. */\n flowId: string\n /** The authorization URL (a device flow: its verification URL); `''` while a `step` comes first. */\n url: string\n /** How the client gets the code back. `step`: answer `step` (`auth.oauth.respond`) before the URL exists. */\n mode: 'loopback' | 'browser' | 'device' | 'step'\n /** A question to answer before the URL exists. Set when `mode` is `step`. */\n step?: HostOAuthStep\n /** `loopback`: where the browser is sent back, on the client's machine. */\n redirectUri?: string\n /** `device`: the code to enter at `url`. */\n userCode?: string\n /** Text to show the user while they sign in. */\n instructions?: string\n /** Epoch ms: the host forgets the flow after it. */\n expiresAt: number\n}\n\n/** `auth.oauth.complete`: the outcome, never a token. */\nexport interface HostOAuthComplete {\n /** A provider sign-in: its new status. */\n provider?: HostProviderAuth\n /** An MCP server sign-in: its name. */\n mcpServer?: string\n /** Not finished: the sign-in asks this. Answer it (`auth.oauth.respond`), then `complete` again. */\n step?: HostOAuthStep\n}\n\n/** Sign-in state of one provider on a host, from `auth.status`. Holds no secret. */\nexport interface HostProviderAuth {\n /** Provider key. */\n key: string\n /** Display name. */\n label: string\n /** Some credential source is present. */\n configured: boolean\n /** The provider signs in with OAuth (on the host's machine only). */\n oauth: boolean\n /** The env var it reads, when it declares one. */\n envKey?: string\n /** Credential sources of the provider. */\n methods: HostAuthMethod[]\n}\n\n/** Folders a host lets clients browse, from `fs.roots`. */\nexport interface FsRoots {\n /** Real paths, the default first. */\n roots: string[]\n /** Session folders must be inside `roots` (a server). */\n confined: boolean\n}\n\n/** One folder in an {@link FsDirListing}. */\nexport interface FsDirEntry {\n /** Folder name. */\n name: string\n /** Real path (a symlink resolved). */\n path: string\n /** Holds a `.git`. */\n isGitRepo: boolean\n}\n\n/** A folder listing from `fs.listDirs`. */\nexport interface FsDirListing {\n /** Real paths of the browsable roots. */\n roots: string[]\n /** The listed folder, as a real path. */\n path: string\n /** The folder above, or `null` at a root. */\n parent: string | null\n /** Sorted by name. */\n entries: FsDirEntry[]\n /** More folders than the listing returns. */\n truncated?: boolean\n}\n\n/** One ordered model-fallback target (primary excluded). */\nexport interface ModelFallbackRef {\n /** Provider of the fallback model. */\n providerKey: ProviderKey\n /** Id of the fallback model. */\n modelId: string\n /** The stored account of the provider (credential id); omitted = its active account. Additive. */\n account?: string\n}\n\n/** One row of a cross-window session list. */\nexport interface SessionRow {\n /** Session id. */\n id: string\n /** Session title. */\n title: string\n /** Project the session belongs to, or `null` when it has none. */\n projectRoot: string | null\n /** Working directory of the session. */\n cwd: string\n /** Id of the agent the session runs as. */\n agentId?: string\n /** Run state of the session. */\n status: 'idle' | 'running' | 'completed' | 'error'\n /** Creation time, epoch ms. */\n createdAt: number\n /** Time of the last change, epoch ms. */\n updatedAt: number\n /** Whether the session is archived. */\n archived: boolean\n /** Listed first (`metadata.favorite`). Additive. */\n favorite?: boolean\n /** Orchestration main session — see `SessionMeta.isMain`. Additive. */\n isMain?: boolean\n /** The session's space when not Default — see `SessionMeta.spaceId`. Additive. */\n spaceId?: string\n /** Provider the session runs on. */\n providerKey?: ProviderKey\n /** Model the session runs on. */\n modelId?: string\n /** The pinned account of `providerKey` (credential id), when one is. Additive. */\n account?: string\n /** Thinking effort of the session. */\n effort?: ThinkingLevel\n /** Model-specific boolean options of the session. */\n modelOptions?: Record<string, boolean>\n /** Validated (head-matched) fallback chain tail, for pickers/badges. */\n modelFallbacks?: ModelFallbackRef[]\n /** Non-local environment summary (kind, state, branch, error). */\n environment?: SessionEnvironmentSummary\n /** The host serving this row (`HelloResult.hostId`). Additive: absent from older hosts. */\n hostId?: string\n /**\n * While `status` is `running`: when the run in progress began, epoch ms on\n * the host's clock, so a client that missed its `run:start` still shows how\n * long it has been going. Additive: absent from older hosts.\n */\n runStartedAt?: number\n}\n\n/** Params of `sessions.create`. */\nexport interface CreateSessionParams {\n /** Tool-execution directory — `projectRoot` is derived from it host-side. */\n cwd: string\n /** Title of the session. Omitted: the host picks one. */\n title?: string\n /** Id of the agent the session runs as. */\n agentId?: string\n /** Provider the session runs on. */\n providerKey?: ProviderKey\n /** Model the session runs on. */\n modelId?: string\n /** The stored account of `providerKey` to run on (credential id). Additive: older hosts ignore it. */\n account?: string\n /** Seed an ordered fallback chain alongside the model pick. */\n fallbacks?: ModelFallbackRef[]\n /** The model pick's reasoning effort and options, stamped with it. */\n effort?: ThinkingLevel\n /** Model-specific boolean options, stamped with the model pick. */\n modelOptions?: Record<string, boolean>\n /** Skills pinned from the first turn (an authoring session's docs skill). */\n pinnedSkills?: string[]\n /** Mark as an extension-authoring session (auto-activates the docs skill). */\n extensionEdit?: boolean\n /** Mark as a skill-authoring session for the named skill (dir = `cwd`). */\n skillEdit?: { name: string }\n /** Where the session's work happens. Omitted → local. */\n environment?: EnvironmentRequest\n /** The space the session belongs to. Omitted → Default. Additive: older hosts ignore it. */\n spaceId?: string\n /** Create it as a hidden `/side` session of this parent. Additive: older hosts ignore it. */\n sideOf?: string\n}\n\n/* -------------------------------------------------------------------------\n * Daemon handshake\n * ---------------------------------------------------------------------- */\n\n/** Params of the `hello` handshake. */\nexport interface HelloParams {\n /** Protocol version the client speaks. */\n protocolVersion: number\n /** Client's zidane version — surfaced in daemon diagnostics. */\n appVersion: string\n /** Process id of the client. */\n pid: number\n /**\n * Build fingerprint (module mtime; `'unknown'` in compiled binaries).\n * When BOTH sides report a real id and they differ, the daemon rejects\n * the handshake like a protocol-version mismatch — the client drains it\n * and respawns. Closes same-version code drift during development.\n */\n buildId?: string\n /**\n * Version of the zidane code the client runs (`ZIDANE_VERSION`, inlined at\n * build). Unlike `buildId` this survives compiled binaries, so it closes\n * the gap released builds had: same protocol version, older code. A\n * client STRICTLY NEWER than the daemon is rejected like a build mismatch\n * and the stale daemon is drained; an older client is accepted and\n * degrades via `optional()`.\n */\n codeVersion?: string\n}\n\n/**\n * What a host process is: a window's own (`in-process`), the local shared\n * daemon (`daemon`), or a remote `zidane-server` (`server`).\n */\nexport type HostKind = 'in-process' | 'daemon' | 'server'\n\n/** Which host a client is talking to, as clients keep it (from `hostRefOf`). */\nexport interface HostRef {\n /** Stable across restarts: persisted in the host's data dir. */\n id: string\n /** What kind of host it is. */\n kind: HostKind\n /** Display name: the machine's hostname by default. */\n name: string\n}\n\n/** Result of the `hello` handshake and of `daemon.info`. */\nexport interface HelloResult {\n /** Protocol version the host speaks. */\n protocolVersion: number\n /** zidane version of the host. */\n appVersion: string\n /** Process id of the host. */\n pid: number\n /** Start time of the host process, epoch ms. */\n startedAt: number\n /** Build fingerprint of the host code. `'unknown'` in compiled binaries. */\n buildId?: string\n /** Version of the zidane code the host runs. */\n codeVersion?: string\n /**\n * Host identity (additive). `hostId` is a UUID persisted once in the host's\n * data dir, so it survives restarts; the in-process host and the local\n * daemon share the data dir, and so the id: they are the same computer.\n */\n hostId?: string\n /** What kind of host this is. */\n hostKind?: HostKind\n /** Display name of the host. */\n hostName?: string\n /**\n * The daemon is older than a client that attached while it had active\n * work: it accepted the handshake instead of draining (which would abort\n * those runs) and exits once idle. Clients attach normally; their\n * reconnect path lands on a fresh daemon after the exit.\n */\n retiring?: boolean\n /**\n * Names this host process's signal numbering ({@link SIGNAL_SEQ_FIELD}):\n * a position from another epoch cannot be resumed. Additive.\n */\n signalEpoch?: string\n /**\n * This server lends itself as a machine to the hosts of its clients\n * (`machine.attach`, `allowAsMachine` on). Absent: it doesn't. Additive.\n */\n machineServe?: boolean\n /**\n * This server takes installs and removals from its clients (`catalog.install`\n * / `remove` / `update`, `mcp.upsert` / `remove`; `allowRemoteInstalls` on).\n * Absent: it doesn't (or predates them). Additive.\n */\n remoteInstalls?: boolean\n /** This server takes settings sync from a client's computer (`sync.*`). Absent: it doesn't. Additive. */\n sync?: boolean\n /**\n * This host runs terminals without a session (`terminal.openInProject` and\n * the other project / draft terminal methods). Absent: sessions only. Additive.\n */\n projectTerminals?: true\n /**\n * `daemon.info` only: a run, compaction, `/` command or background task is\n * in flight on this host (open terminals do not count). `zidane server\n * wait-idle` waits for `false` before a restart. Additive.\n */\n activeWork?: boolean\n}\n\n/** `catalog.install` / `remove` / `update`: what is installed from a client, in the host user's scope. */\nexport type HostInstallKind = 'skill' | 'extension'\n\n/** Which catalog a `catalog:changed` signal says to re-read. */\nexport type HostCatalogName = 'skills' | 'mcps' | 'extensions' | 'plugins'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0MA,MAAa,uBAAuB;;;;;;AAOpC,MAAa,eAAe;CAC1B,iBAAiB;CACjB,eAAe;;CAEf,aAAa;;;;;;CAMb,kBAAkB;;;;;;CAMlB,eAAe;AACjB;;;;;;AAOA,MAAa,cAAc;;;;;;;AAQ3B,MAAa,mBAAmB;;;;;;AA0xBhC,SAAgB,UAAU,OAAoC;CAC5D,IAAI,OAAO,MAAM,WAAW,YAAY,CAAC,MAAM,UAC7C,OAAO;CACT,OAAO;EAAE,IAAI,MAAM;EAAQ,MAAM,MAAM;EAAU,MAAM,MAAM,YAAY,MAAM;CAAO;AACxF;;AAUA,MAAa,yBAAyB;;AAEtC,MAAa,6BAA6B;;;;;;;;AAoD1C,eAAsB,eACpB,SACA,QAC4B;CAC5B,MAAM,SAAS,MAAM,QAAQ,uBAAuB,MAAM;CAC1D,OAAO,MAAM,QAAQ,MAAM,IAAI,EAAE,QAAQ,OAAO,IAAI;AACtD;AAEA,SAAS,mBAAmB,KAAuB;CACjD,OAAO,OAAO,QAAQ,YAAY,QAAQ,QAAS,IAA2B,SAAS,aAAa;AACtG;;;;;;;;;;;;;AAcA,eAAsB,cACpB,SACA,WACA,UAAkC,CAAC,GACX;CACxB,QAAQ,MAAM,kBAAkB,SAAS,WAAW,QAAQ,aAAA,GAAmC,EAAA,CAAG;AACpG;;;;;;;;AASA,eAAsB,eACpB,SACA,WACA,QACA,UAAkC,CAAC,GACkB;CACrD,OAAO,kBAAkB,SAAS,WAAW,QAAQ,aAAA,KAAqC,MAAM;AAClG;AAEA,eAAe,kBACb,SACA,WACA,WACA,QACqD;CACrD,IAAI,QAAQ;CACZ,MAAM,QAAyB,CAAC;CAChC,IAAI,aAAa;CACjB,IAAI,WAAW;CACf,IAAI;CACJ,SAAS;EACP,IAAI;EACJ,IAAI;GACF,OAAO,MAAM,eAAe,SAAS;IAAE;IAAW;IAAO,GAAI,WAAW,KAAA,IAAY,EAAE,OAAO,IAAI,CAAC;GAAG,CAAC;EACxG,SACO,KAAK;GACV,IAAI,mBAAmB,GAAG,KAAK,QAAQ,GAAG;IACxC,QAAQ,KAAK,IAAI,GAAG,KAAK,MAAM,QAAQ,CAAC,CAAC;IACzC;GACF;GACA,MAAM;EACR;EAQA,MAAM,QAAQ,MAAM;EACpB,IAAI,SAAS,CAAC,cAAc,MAAM,EAAE,EAAE,SAAS,iBAAiB,KAAK,OAAO,SAAS,GACnF,MAAM,QAAQ;GAAE,MAAM;GAAa,MAAM;EAAG,CAAC;EAC/C,aAAa,KAAK,UAAU;EAC5B,aAAa,cAAc,KAAK,UAAU,KAAA;EAC1C,MAAM,QAAQ,KAAK,MAAM;EAEzB,IAAI,KAAK,WAAW,KAAA,KAAa,KAAK,UAAU,KAAM,WAAW,KAAA,KAAa,KAAK,UAAU,QAC3F;EACF,IAAI,UAAU,UAAU;GACtB,MAAM,SAAS,MAAM,KAAK;GAC1B,IAAI,OAAO,MAAM,GACf,OAAO;IAAE;IAAQ,SAAS,KAAK;GAAO;EAC1C;EACA,SAAS,KAAK;CAChB;CACA,OAAO;EAAE,QAAQ,MAAM,KAAK;EAAG,SAAS;CAAE;AAC5C;;AAGA,MAAa,qBAAqB;;AAElC,MAAa,yBAAyB;;AAYtC,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;AAmBlC,eAAsB,oBACpB,SACA,WACA,UAAkC,CAAC,GACN;CAC7B,MAAM,SAAS,EAAE,OAAO,QAAQ,aAAA,IAAgC;CAChE,KAAK,IAAI,UAAU,GAAG,WAAW,2BAA2B,WAAW;EACrE,MAAM,OAAO,MAAM,wBAAwB,SAAS,WAAW,MAAM;EACrE,IAAI,SAAS,WACX,OAAO;CACX;CACA,OAAO,eAAe,MAAM,QAAQ,gBAAgB,EAAE,UAAU,CAAC,CAAC;AACpE;AAEA,SAAS,eAAe,MAAsD;CAC5E,IAAI,CAAC,MACH,OAAO;CACT,MAAM,EAAE,SAAS,UAAU,GAAG,SAAS;CACvC,OAAO;AACT;;AAGA,eAAe,wBAAwB,SAAiC,WAAmB,QAAoE;CAC7J,MAAM,QAAuB,CAAC;CAC9B,IAAI,QAAQ;CACZ,IAAI,UAAkC;CACtC,OAAO,MAAM,SAAS,OAAO;EAC3B,IAAI;EACJ,IAAI;GACF,OAAO,MAAM,QAAQ,qBAAqB;IAAE;IAAW,MAAM,MAAM;IAAQ,OAAO,OAAO;GAAM,CAAC;EAClG,SACO,KAAK;GACV,IAAI,MAAM,WAAW,KAAK,iBAAiB,GAAG,GAC5C,OAAO,eAAe,MAAM,QAAQ,gBAAgB,EAAE,UAAU,CAAC,CAAC;GACpE,IAAI,mBAAmB,GAAG,KAAK,OAAO,QAAQ,GAAG;IAC/C,OAAO,QAAQ,KAAK,IAAI,GAAG,KAAK,MAAM,OAAO,QAAQ,CAAC,CAAC;IACvD;GACF;GACA,MAAM;EACR;EACA,IAAI,CAAC,MACH,OAAO;EACT,IAAI,YAAY,MACd,UAAU,EAAE,GAAI,KAAK,YAAY,KAAA,IAAY,EAAE,IAAI,KAAK,QAAQ,IAAI,CAAC,EAAG;OACrE,IAAI,KAAK,YAAY,QAAQ,IAChC,OAAO;EACT,QAAQ,KAAK;EAEb,IAAI,KAAK,MAAM,WAAW,GACxB;EACF,MAAM,KAAK,GAAG,KAAK,KAAK;CAC1B;CACA,MAAM,OAAO,MAAM,QAAQ,gBAAgB;EAAE;EAAW,OAAO;CAAM,CAAC;CACtE,IAAI,CAAC,MACH,OAAO;CACT,IAAI,YAAY,QAAQ,KAAK,YAAY,QAAQ,IAC/C,OAAO;CACT,OAAO;EAAE,GAAG,eAAe,IAAI;EAAI;CAAM;AAC3C;;AA6BA,MAAa,WAAW"}
@@ -1,2 +1,2 @@
1
- import { CC as AnthropicBedrockConfig, GC as planAnthropicThinking, HC as AnthropicThinkingPlan, KC as resolveThinkingBinding, SC as applyAnthropicCacheBreakpoints, TC as AnthropicParams, UC as THINKING_BINDING_SETTING_ENV, WC as ThinkingBindingBehavior, _C as buildAnthropicClientOptions, bC as resolveAnthropicBetas, fC as anthropic, gC as classifyAnthropicError, hC as resolveAnthropicMaxOutput, mC as defaultAnthropicMaxTokens, pC as cacheWriteTtlMultiplier, vC as credentialIdentity, wC as AnthropicContextManagement, xC as EXTENDED_CACHE_TTL_BETA, yC as resolveAnthropicAuthShape } from "../index-DyQyDLX1.js";
1
+ import { CC as applyAnthropicCacheBreakpoints, EC as AnthropicParams, GC as ThinkingBindingBehavior, KC as planAnthropicThinking, SC as EXTENDED_CACHE_TTL_BETA, TC as AnthropicContextManagement, UC as AnthropicThinkingPlan, WC as THINKING_BINDING_SETTING_ENV, _C as classifyAnthropicError, bC as resolveAnthropicAuthShape, gC as resolveAnthropicMaxOutput, hC as defaultAnthropicMaxTokens, mC as cacheWriteTtlMultiplier, pC as anthropic, qC as resolveThinkingBinding, vC as buildAnthropicClientOptions, wC as AnthropicBedrockConfig, xC as resolveAnthropicBetas, yC as credentialIdentity } from "../index-4mDRyTGJ.js";
2
2
  export { type AnthropicBedrockConfig, type AnthropicContextManagement, type AnthropicParams, type AnthropicThinkingPlan, EXTENDED_CACHE_TTL_BETA, THINKING_BINDING_SETTING_ENV, type ThinkingBindingBehavior, anthropic, applyAnthropicCacheBreakpoints, buildAnthropicClientOptions, cacheWriteTtlMultiplier, classifyAnthropicError, credentialIdentity, defaultAnthropicMaxTokens, planAnthropicThinking, resolveAnthropicAuthShape, resolveAnthropicBetas, resolveAnthropicMaxOutput, resolveThinkingBinding };
@@ -1,2 +1,2 @@
1
- import { dC as arcee, uC as ArceeParams } from "../index-DyQyDLX1.js";
1
+ import { dC as ArceeParams, fC as arcee } from "../index-4mDRyTGJ.js";
2
2
  export { ArceeParams, arcee };
@@ -1,2 +1,2 @@
1
- import { cC as baseten, lC as planBasetenReasoning, sC as BasetenParams } from "../index-DyQyDLX1.js";
1
+ import { cC as BasetenParams, lC as baseten, uC as planBasetenReasoning } from "../index-4mDRyTGJ.js";
2
2
  export { BasetenParams, baseten, planBasetenReasoning };
@@ -1,2 +1,2 @@
1
- import { aC as CerebrasParams, oC as cerebras } from "../index-DyQyDLX1.js";
1
+ import { oC as CerebrasParams, sC as cerebras } from "../index-4mDRyTGJ.js";
2
2
  export { CerebrasParams, cerebras };
@@ -1,2 +1,2 @@
1
- import { $S as loadGoogleWireKit, BS as GoogleRouteName, FS as GOOGLE_EXTRA_MODELS, GS as GoogleVertexParams, HS as GoogleStreamFn, IS as GoogleCompatibleRoute, JS as classifyGoogleError, KS as GoogleWireKit, LS as GoogleExtraModel, PS as GOOGLE_DEFAULT_MODEL, QS as googleVertex, RS as GoogleParams, US as GoogleStreamOptions, VS as GoogleSharedParams, WS as GoogleStreams, XS as google, YS as fromGooglePiAssistantMessage, ZS as googleCompatible, eC as resolveGoogleModel, nC as toGooglePiMessages, qS as GoogleWireModel, tC as resolveVertexAuth, zS as GoogleRequestAuth } from "../index-DyQyDLX1.js";
1
+ import { $S as googleVertex, BS as GoogleRequestAuth, FS as GOOGLE_DEFAULT_MODEL, GS as GoogleStreams, HS as GoogleSharedParams, IS as GOOGLE_EXTRA_MODELS, JS as GoogleWireModel, KS as GoogleVertexParams, LS as GoogleCompatibleRoute, QS as googleCompatible, RS as GoogleExtraModel, US as GoogleStreamFn, VS as GoogleRouteName, WS as GoogleStreamOptions, XS as fromGooglePiAssistantMessage, YS as classifyGoogleError, ZS as google, eC as loadGoogleWireKit, nC as resolveVertexAuth, qS as GoogleWireKit, rC as toGooglePiMessages, tC as resolveGoogleModel, zS as GoogleParams } from "../index-4mDRyTGJ.js";
2
2
  export { GOOGLE_DEFAULT_MODEL, GOOGLE_EXTRA_MODELS, GoogleCompatibleRoute, GoogleExtraModel, GoogleParams, GoogleRequestAuth, GoogleRouteName, GoogleSharedParams, GoogleStreamFn, GoogleStreamOptions, GoogleStreams, GoogleVertexParams, GoogleWireKit, GoogleWireModel, classifyGoogleError, fromGooglePiAssistantMessage, google, googleCompatible, googleVertex, loadGoogleWireKit, resolveGoogleModel, resolveVertexAuth, toGooglePiMessages };
@@ -1,2 +1,2 @@
1
- import { MS as LocalParams, NS as local } from "../index-DyQyDLX1.js";
1
+ import { NS as LocalParams, PS as local } from "../index-4mDRyTGJ.js";
2
2
  export { LocalParams, local };
@@ -1,2 +1,2 @@
1
- import { DS as neuralwatt, ES as NeuralwattParams, OS as planNeuralwattReasoning, TS as NEURALWATT_DEFAULT_MODEL } from "../index-DyQyDLX1.js";
1
+ import { DS as NeuralwattParams, ES as NEURALWATT_DEFAULT_MODEL, OS as neuralwatt, kS as planNeuralwattReasoning } from "../index-4mDRyTGJ.js";
2
2
  export { NEURALWATT_DEFAULT_MODEL, NeuralwattParams, neuralwatt, planNeuralwattReasoning };
@@ -1,2 +1,2 @@
1
- import { $x as ASSISTANT_TOOL_CALLS_TAG, _S as userMessage, aS as TOOL_RESULTS_TAG, cS as assistantMessage, dS as formatTools, eS as OAIMessage, fS as mapOAIFinishReason, gS as toolResultsMessage, hS as toOAIMessages, iS as OpenAICompatParams, lS as buildAssistantContent, mS as openaiCompat, nS as OpenAICompatAuthHeader, oS as applyOAICacheBreakpoints, pS as openAICompatPromptMessage, rS as OpenAICompatHttpError, sS as applyOAIToolCacheBreakpoint, tS as OAITool, uS as classifyOpenAICompatError, vS as OpenAICompatStreamError, yS as consumeSSE } from "../index-DyQyDLX1.js";
1
+ import { _S as toolResultsMessage, aS as OpenAICompatParams, bS as consumeSSE, cS as applyOAIToolCacheBreakpoint, dS as classifyOpenAICompatError, eS as ASSISTANT_TOOL_CALLS_TAG, fS as formatTools, gS as toOAIMessages, hS as openaiCompat, iS as OpenAICompatHttpError, lS as assistantMessage, mS as openAICompatPromptMessage, nS as OAITool, oS as TOOL_RESULTS_TAG, pS as mapOAIFinishReason, rS as OpenAICompatAuthHeader, sS as applyOAICacheBreakpoints, tS as OAIMessage, uS as buildAssistantContent, vS as userMessage, yS as OpenAICompatStreamError } from "../index-4mDRyTGJ.js";
2
2
  export { ASSISTANT_TOOL_CALLS_TAG, OAIMessage, OAITool, OpenAICompatAuthHeader, OpenAICompatHttpError, OpenAICompatParams, OpenAICompatStreamError, TOOL_RESULTS_TAG, applyOAICacheBreakpoints, applyOAIToolCacheBreakpoint, assistantMessage, buildAssistantContent, classifyOpenAICompatError, consumeSSE, formatTools, mapOAIFinishReason, openAICompatPromptMessage, openaiCompat, toOAIMessages, toolResultsMessage, userMessage };
@@ -1,2 +1,2 @@
1
- import { CS as openai, SS as mapCodexStopReason, bS as OpenAIParams, wS as toPiMessages, xS as classifyOpenAIError } from "../index-DyQyDLX1.js";
1
+ import { CS as mapCodexStopReason, SS as classifyOpenAIError, TS as toPiMessages, wS as openai, xS as OpenAIParams } from "../index-4mDRyTGJ.js";
2
2
  export { OpenAIParams, classifyOpenAIError, mapCodexStopReason, openai, toPiMessages };
@@ -1,2 +1,2 @@
1
- import { Qx as openrouter, Xx as OpenRouterParams, Yx as OPENROUTER_DEFAULT_MODEL, Zx as normalizeOpenRouterModelId } from "../index-DyQyDLX1.js";
1
+ import { $x as openrouter, Qx as normalizeOpenRouterModelId, Xx as OPENROUTER_DEFAULT_MODEL, Zx as OpenRouterParams } from "../index-4mDRyTGJ.js";
2
2
  export { OPENROUTER_DEFAULT_MODEL, OpenRouterParams, normalizeOpenRouterModelId, openrouter };
@@ -1,2 +1,2 @@
1
- import { Hx as XaiParams, Ux as xai } from "../index-DyQyDLX1.js";
1
+ import { Ux as XaiParams, Wx as xai } from "../index-4mDRyTGJ.js";
2
2
  export { XaiParams, xai };
@@ -1,3 +1,3 @@
1
- import { $C as ImageData, $S as loadGoogleWireKit, AC as OAuthParams, AS as mistral, Ax as ProviderDecisions, BC as resolveOAuthApiKey, Bx as planZaiReasoning, CS as openai, Cx as HistoryRepair, DC as PromptCacheKeyOption, DS as neuralwatt, Dx as ProviderDecisionAvailability, EC as PromptCacheKeyContext, ES as NeuralwattParams, Ex as ProviderCapabilities, FC as isOAuthAccessToken, Fx as ToolCall, GS as GoogleVertexParams, Gx as SchemaSanitizeProfile, HS as GoogleStreamFn, Hx as XaiParams, IC as pinnedAccountMissingError, IS as GoogleCompatibleRoute, Ix as ToolResult, JC as openrouterImageModels, JS as classifyGoogleError, Jx as sanitizeToolSpecs, KS as GoogleWireKit, Kx as SchemaSanitizeResult, LC as readAccountOAuthCredential, Lx as ToolSpec, MC as credentialsFilePath, MS as LocalParams, Mx as StreamCallbacks, NC as credentialsFromParams, NS as local, Nx as StreamOptions, OC as derivePromptCacheKey, OS as planNeuralwattReasoning, Ox as ProviderDecisionRequest, PC as extractRuntimeCredentials, Px as TokenCountPayload, QC as ImageAspectRatio, QS as googleVertex, Qx as openrouter, RC as readOAuthCredentials, RS as GoogleParams, Rx as TurnResult, SC as applyAnthropicCacheBreakpoints, TC as AnthropicParams, TS as NEURALWATT_DEFAULT_MODEL, Tx as Provider, US as GoogleStreamOptions, Ux as xai, VC as writeOAuthCredentials, VS as GoogleSharedParams, Vx as zai, WS as GoogleStreams, Wx as SchemaSanitizeOptions, XC as GOOGLE_IMAGE_MODELS, XS as google, Xx as OpenRouterParams, YC as OPENAI_IMAGE_MODELS, ZC as IMAGE_ASPECT_RATIOS, ZS as googleCompatible, aC as CerebrasParams, aO as ModelCatalog, aw as ProviderImages, bS as OpenAIParams, cC as baseten, cO as ModelTier, dC as arcee, ew as ImageModelInfo, fC as anthropic, fS as mapOAIFinishReason, iC as cursor, iS as OpenAICompatParams, iw as ProviderImageResponse, jC as ResolveOAuthApiKeyOptions, jS as planMistralReasoning, jx as ProviderMeta, kC as resolvePromptCacheKey, kS as MistralParams, kx as ProviderDecisionResponse, lC as planBasetenReasoning, lO as getModelCatalog, mS as openaiCompat, nS as OpenAICompatAuthHeader, nw as ProviderImageAvailability, oC as cerebras, oO as ModelCatalogEntry, qC as XAI_IMAGE_MODELS, qS as GoogleWireModel, qx as sanitizeToolSchema, rC as CursorParams, rS as OpenAICompatHttpError, rw as ProviderImageRequest, sC as BasetenParams, sO as ModelCatalogSource, tw as MAX_IMAGES_PER_REQUEST, uC as ArceeParams, uO as setModelCatalog, uS as classifyOpenAICompatError, wx as InputTransformation, zC as registerCustomOAuthProvider, zS as GoogleRequestAuth, zx as ZaiParams } from "./index-DyQyDLX1.js";
1
+ import { $C as ImageAspectRatio, $E as ModelCatalogSource, $S as googleVertex, $x as openrouter, AC as resolvePromptCacheKey, AS as MistralParams, Ax as ProviderDecisionResponse, BC as registerCustomOAuthProvider, BS as GoogleRequestAuth, Bx as ZaiParams, CC as applyAnthropicCacheBreakpoints, DC as PromptCacheKeyContext, DS as NeuralwattParams, Dx as ProviderCapabilities, EC as AnthropicParams, ES as NEURALWATT_DEFAULT_MODEL, Ex as Provider, FC as extractRuntimeCredentials, Fx as TokenCountPayload, GS as GoogleStreams, Gx as SchemaSanitizeOptions, HC as writeOAuthCredentials, HS as GoogleSharedParams, Hx as zai, IC as isOAuthAccessToken, Ix as ToolCall, JC as XAI_IMAGE_MODELS, JS as GoogleWireModel, Jx as sanitizeToolSchema, KS as GoogleVertexParams, Kx as SchemaSanitizeProfile, LC as pinnedAccountMissingError, LS as GoogleCompatibleRoute, Lx as ToolResult, MC as ResolveOAuthApiKeyOptions, MS as planMistralReasoning, Mx as ProviderMeta, NC as credentialsFilePath, NS as LocalParams, Nx as StreamCallbacks, OC as PromptCacheKeyOption, OS as neuralwatt, Ox as ProviderDecisionAvailability, PC as credentialsFromParams, PS as local, Px as StreamOptions, QC as IMAGE_ASPECT_RATIOS, QE as ModelCatalogEntry, QS as googleCompatible, RC as readAccountOAuthCredential, Rx as ToolSpec, Tx as InputTransformation, US as GoogleStreamFn, Ux as XaiParams, VC as resolveOAuthApiKey, Vx as planZaiReasoning, WS as GoogleStreamOptions, Wx as xai, XC as OPENAI_IMAGE_MODELS, YC as openrouterImageModels, YS as classifyGoogleError, Yx as sanitizeToolSpecs, ZC as GOOGLE_IMAGE_MODELS, ZE as ModelCatalog, ZS as google, Zx as OpenRouterParams, aC as cursor, aS as OpenAICompatParams, aw as ProviderImageResponse, cC as BasetenParams, dC as ArceeParams, dS as classifyOpenAICompatError, eC as loadGoogleWireKit, eD as ModelTier, ew as ImageData, fC as arcee, hS as openaiCompat, iC as CursorParams, iS as OpenAICompatHttpError, iw as ProviderImageRequest, jC as OAuthParams, jS as mistral, jx as ProviderDecisions, kC as derivePromptCacheKey, kS as planNeuralwattReasoning, kx as ProviderDecisionRequest, lC as baseten, nD as setModelCatalog, nw as MAX_IMAGES_PER_REQUEST, oC as CerebrasParams, ow as ProviderImages, pC as anthropic, pS as mapOAIFinishReason, qS as GoogleWireKit, qx as SchemaSanitizeResult, rS as OpenAICompatAuthHeader, rw as ProviderImageAvailability, sC as cerebras, tD as getModelCatalog, tw as ImageModelInfo, uC as planBasetenReasoning, wS as openai, wx as HistoryRepair, xS as OpenAIParams, zC as readOAuthCredentials, zS as GoogleParams, zx as TurnResult } from "./index-4mDRyTGJ.js";
2
2
  import { a as getOAuthApiKey, c as refreshOpenAICodexToken, i as ensureBundledOAuthFlows, l as registerOAuthProvider, o as getOAuthProvider, r as OAuthProviderInterface, s as refreshAnthropicToken } from "./oauth-callback-page-B3Xo3X2J.js";
3
3
  export { type AnthropicParams, type ArceeParams, type BasetenParams, type CerebrasParams, type CursorParams, GOOGLE_IMAGE_MODELS, type GoogleCompatibleRoute, type GoogleParams, type GoogleRequestAuth, type GoogleSharedParams, type GoogleStreamFn, type GoogleStreamOptions, type GoogleStreams, type GoogleVertexParams, type GoogleWireKit, type GoogleWireModel, HistoryRepair, IMAGE_ASPECT_RATIOS, type ImageAspectRatio, type ImageData, type ImageModelInfo, InputTransformation, type LocalParams, MAX_IMAGES_PER_REQUEST, type MistralParams, type ModelCatalog, type ModelCatalogEntry, type ModelCatalogSource, type ModelTier, NEURALWATT_DEFAULT_MODEL, type NeuralwattParams, type OAuthParams, type OAuthProviderInterface, OPENAI_IMAGE_MODELS, type OpenAICompatAuthHeader, OpenAICompatHttpError, type OpenAICompatParams, type OpenAIParams, type OpenRouterParams, type PromptCacheKeyContext, type PromptCacheKeyOption, Provider, ProviderCapabilities, ProviderDecisionAvailability, ProviderDecisionRequest, ProviderDecisionResponse, ProviderDecisions, type ProviderImageAvailability, type ProviderImageRequest, type ProviderImageResponse, type ProviderImages, ProviderMeta, type ResolveOAuthApiKeyOptions, type SchemaSanitizeOptions, type SchemaSanitizeProfile, type SchemaSanitizeResult, StreamCallbacks, StreamOptions, TokenCountPayload, ToolCall, ToolResult, ToolSpec, TurnResult, XAI_IMAGE_MODELS, type XaiParams, type ZaiParams, anthropic, applyAnthropicCacheBreakpoints, arcee, baseten, cerebras, classifyGoogleError, classifyOpenAICompatError, credentialsFilePath, credentialsFromParams, cursor, derivePromptCacheKey, ensureBundledOAuthFlows, extractRuntimeCredentials, getModelCatalog, getOAuthApiKey, getOAuthProvider, google, googleCompatible, googleVertex, isOAuthAccessToken, loadGoogleWireKit, local, mapOAIFinishReason, mistral, neuralwatt, openai, openaiCompat, openrouter, openrouterImageModels, pinnedAccountMissingError, planBasetenReasoning, planMistralReasoning, planNeuralwattReasoning, planZaiReasoning, readAccountOAuthCredential, readOAuthCredentials, refreshAnthropicToken, refreshOpenAICodexToken, registerCustomOAuthProvider, registerOAuthProvider, resolveOAuthApiKey, resolvePromptCacheKey, sanitizeToolSchema, sanitizeToolSpecs, setModelCatalog, writeOAuthCredentials, xai, zai };