dal-code 1.0.54 → 1.0.56

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 (342) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/NOTICE +11 -0
  3. package/dist/bundle/chunks/{anthropic-messages-UHE6F2IE.js → anthropic-messages-HHQLDDZH.js} +1 -1
  4. package/dist/bundle/chunks/{azure-openai-responses-EK4W2MKL.js → azure-openai-responses-S7VKEJTH.js} +1 -1
  5. package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
  6. package/dist/bundle/chunks/{chunk-3ZHZINH3.js → chunk-3HGUIN22.js} +2 -2
  7. package/dist/bundle/chunks/{chunk-FE533CCR.js → chunk-3XMZ5UC3.js} +1 -1
  8. package/dist/bundle/chunks/{chunk-EH7SFF47.js → chunk-AL3DFAIM.js} +2 -2
  9. package/dist/bundle/chunks/{chunk-IDZ3QKHZ.js → chunk-BCFLC6CK.js} +1 -1
  10. package/dist/bundle/chunks/{chunk-K4B5ABCQ.js → chunk-BIY5HTFI.js} +1 -1
  11. package/dist/bundle/chunks/{chunk-SCYK4XNE.js → chunk-F37JXTCY.js} +1 -1
  12. package/dist/bundle/chunks/{chunk-K7VBBYTT.js → chunk-F5SIUTR7.js} +1 -1
  13. package/dist/bundle/chunks/{chunk-356BFRU3.js → chunk-MKMLENQD.js} +1 -1
  14. package/dist/bundle/chunks/{chunk-4DMD6C65.js → chunk-P4IBZA6D.js} +1 -1
  15. package/dist/bundle/chunks/{chunk-B5GJW7C2.js → chunk-PH42AQ66.js} +1 -1
  16. package/dist/bundle/chunks/{chunk-O7G23ELK.js → chunk-QCT6OHUR.js} +1 -1
  17. package/dist/bundle/chunks/{chunk-RKLUP6JT.js → chunk-RX6CC5RH.js} +463 -460
  18. package/dist/bundle/chunks/{chunk-XRF4A4KI.js → chunk-SZZVJTVX.js} +3 -3
  19. package/dist/bundle/chunks/chunk-T3TEURLR.js +30 -0
  20. package/dist/bundle/chunks/{chunk-VIS5PYQO.js → chunk-UULAEZ3H.js} +1 -1
  21. package/dist/bundle/chunks/{chunk-2C7JTP5O.js → chunk-VGMP27KM.js} +1 -1
  22. package/dist/bundle/chunks/chunk-XTN2LDU3.js +9 -0
  23. package/dist/bundle/chunks/{chunk-CSZTBJOE.js → chunk-Z64M4Q7A.js} +1 -1
  24. package/dist/bundle/chunks/{chunk-33MCYYJ3.js → chunk-ZR6PGIL7.js} +1 -1
  25. package/dist/bundle/chunks/{cli-YJV3WN2N.js → cli-NGGC23SK.js} +1 -1
  26. package/dist/bundle/chunks/{cli-XOLEGZVC.js → cli-TVPE43YN.js} +1 -1
  27. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-KNGB64NR.js → cloudflare-workers-ai-system-one-RK2YCJXC.js} +1 -1
  28. package/dist/bundle/chunks/{easter-egg-3d-5TFBCTIS.js → easter-egg-3d-W2F3ROZ6.js} +1 -1
  29. package/dist/bundle/chunks/{execute-6PNQ63VS.js → execute-MGTKJB44.js} +1 -1
  30. package/dist/bundle/chunks/github-copilot.js +1 -1
  31. package/dist/bundle/chunks/{google-generative-ai-YJN7TGWU.js → google-generative-ai-ZPA4VBXP.js} +1 -1
  32. package/dist/bundle/chunks/{google-vertex-3BVJFMMZ.js → google-vertex-IWHW2RX7.js} +1 -1
  33. package/dist/bundle/chunks/{llama-cpp-classify-JVUWNG3E.js → llama-cpp-classify-FXJM52Q3.js} +1 -1
  34. package/dist/bundle/chunks/mcp-RLFUDVHN.js +10 -0
  35. package/dist/bundle/chunks/{mistral-conversations-O6YIQAS5.js → mistral-conversations-JXVPTO5Y.js} +1 -1
  36. package/dist/bundle/chunks/{office-AXLGVCMO.js → office-RTREQQ7W.js} +1 -1
  37. package/dist/bundle/chunks/{openai-codex-responses-YQ5NNPTG.js → openai-codex-responses-EYW27UUE.js} +1 -1
  38. package/dist/bundle/chunks/{openai-completions-R4I3PKBD.js → openai-completions-ROBKXDOC.js} +1 -1
  39. package/dist/bundle/chunks/{openai-decisions-IUHMKKHZ.js → openai-decisions-4T5LPJRA.js} +1 -1
  40. package/dist/bundle/chunks/{openai-responses-E2PHOQF4.js → openai-responses-ZVFZ75QW.js} +1 -1
  41. package/dist/bundle/chunks/{openrouter-images-NCMLTKZW.js → openrouter-images-6VJYTLAX.js} +1 -1
  42. package/dist/bundle/chunks/{pi-messages-GLTSGLSO.js → pi-messages-Y6HBOGKH.js} +1 -1
  43. package/dist/bundle/chunks/{review-KXWT7T3V.js → review-USSKCVWP.js} +1 -1
  44. package/dist/bundle/chunks/{router-26PXJ7YH.js → router-4JLK3BTT.js} +1 -1
  45. package/dist/bundle/chunks/{runtime-LJBCO7CX.js → runtime-G7F6UQLA.js} +1 -1
  46. package/dist/bundle/chunks/{sdk-6GP346VB.js → sdk-CEIRR6KD.js} +1 -1
  47. package/dist/bundle/chunks/sync-UCHKAOUU.js +21 -0
  48. package/dist/bundle/chunks/{typesafe-system-one-GQFHU7SQ.js → typesafe-system-one-XPDE7VYD.js} +1 -1
  49. package/dist/bundle/chunks/{usage-MY7HTXQB.js → usage-3ACOJWR3.js} +1 -1
  50. package/dist/bundle/chunks/{virtual-modules-BEBLHRXC.js → virtual-modules-P4JE2EA6.js} +1 -1
  51. package/dist/bundle/cli-runtime.js +1 -1
  52. package/dist/bundle/index.js +1 -1
  53. package/dist/bundle/rpc-entry.js +1 -1
  54. package/dist/core/agent-session-runtime.d.ts +1 -0
  55. package/dist/core/agent-session-runtime.js +1 -1
  56. package/dist/core/extensions/index.d.ts +1 -1
  57. package/dist/core/extensions/types.d.ts +9 -5
  58. package/dist/core/headless-approver.d.ts +3 -0
  59. package/dist/core/headless-approver.js +1 -0
  60. package/dist/core/tools/bash.js +1 -1
  61. package/dist/core/tools/edit.js +2 -3
  62. package/dist/core/tools/renderers/bash.js +1 -1
  63. package/dist/core/tools/renderers/edit.js +2 -2
  64. package/dist/dal/manifest.js +1 -1
  65. package/dist/index.d.ts +2 -1
  66. package/dist/index.js +1 -1
  67. package/dist/main.js +3 -3
  68. package/dist/modes/acp/acp-mapping.js +3 -2
  69. package/dist/modes/acp/acp-mode.js +1 -1
  70. package/dist/modes/acp/acp-permissions.js +1 -0
  71. package/dist/modes/acp/acp-session-options.d.ts +24 -0
  72. package/dist/modes/acp/acp-session-options.js +3 -0
  73. package/dist/modes/index.d.ts +1 -0
  74. package/dist/modes/index.js +1 -1
  75. package/dist/modes/interactive/components/assistant-message.d.ts +3 -0
  76. package/dist/modes/interactive/components/assistant-message.js +2 -2
  77. package/dist/modes/interactive/components/diff.d.ts +22 -0
  78. package/dist/modes/interactive/components/diff.js +4 -3
  79. package/dist/modes/interactive/components/keybinding-hints.js +1 -1
  80. package/dist/modes/interactive/components/panel-line.js +1 -0
  81. package/dist/modes/interactive/components/status-indicator.d.ts +23 -1
  82. package/dist/modes/interactive/components/status-indicator.js +1 -1
  83. package/dist/modes/interactive/components/tool-execution.d.ts +2 -2
  84. package/dist/modes/interactive/components/tool-execution.js +5 -5
  85. package/dist/modes/interactive/interactive-mode.d.ts +3 -0
  86. package/dist/modes/interactive/interactive-mode.js +18 -18
  87. package/dist/modes/interactive/theme/dark.json +4 -0
  88. package/dist/modes/interactive/theme/light.json +4 -0
  89. package/dist/modes/interactive/theme/system-theme.js +1 -1
  90. package/dist/modes/interactive/theme/theme-tokens.d.ts +10 -0
  91. package/dist/modes/interactive/theme/theme-tokens.js +1 -1
  92. package/dist/modes/rpc/rpc-types.d.ts +2 -6
  93. package/dist/node_modules/@dalcode/dal-advisor/package.json +3 -3
  94. package/dist/node_modules/@dalcode/dal-awake/package.json +2 -2
  95. package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
  96. package/dist/node_modules/@dalcode/dal-capabilities/package.json +4 -4
  97. package/dist/node_modules/@dalcode/dal-codeindex/package.json +2 -2
  98. package/dist/node_modules/@dalcode/dal-compat/package.json +2 -2
  99. package/dist/node_modules/@dalcode/dal-dap/package.json +2 -2
  100. package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
  101. package/dist/node_modules/@dalcode/dal-goal/package.json +3 -3
  102. package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
  103. package/dist/node_modules/@dalcode/dal-guard/src/index.js +4 -4
  104. package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
  105. package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
  106. package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
  107. package/dist/node_modules/@dalcode/dal-learn/package.json +2 -2
  108. package/dist/node_modules/@dalcode/dal-learn/src/engine.js +2 -2
  109. package/dist/node_modules/@dalcode/dal-learn/src/index.js +14 -14
  110. package/dist/node_modules/@dalcode/dal-learn/src/lessons.js +4 -4
  111. package/dist/node_modules/@dalcode/dal-learn/src/safety.js +2 -2
  112. package/dist/node_modules/@dalcode/dal-lsp/package.json +4 -4
  113. package/dist/node_modules/@dalcode/dal-mcp/package.json +6 -6
  114. package/dist/node_modules/@dalcode/dal-mcp/src/config.js +1 -1
  115. package/dist/node_modules/@dalcode/dal-mcp/src/index.js +16 -16
  116. package/dist/node_modules/@dalcode/dal-mcp/src/types.d.ts +2 -0
  117. package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
  118. package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +3 -3
  119. package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
  120. package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +3 -3
  121. package/dist/node_modules/@dalcode/dal-plugins/package.json +4 -4
  122. package/dist/node_modules/@dalcode/dal-recall/package.json +2 -2
  123. package/dist/node_modules/@dalcode/dal-remote/package.json +2 -2
  124. package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
  125. package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
  126. package/dist/node_modules/@dalcode/dal-router/package.json +6 -6
  127. package/dist/node_modules/@dalcode/dal-rtk/package.json +2 -2
  128. package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
  129. package/dist/node_modules/@dalcode/dal-statusline/package.json +2 -2
  130. package/dist/node_modules/@dalcode/dal-structured/package.json +2 -2
  131. package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
  132. package/dist/node_modules/@dalcode/dal-sync/package.json +7 -5
  133. package/dist/node_modules/@dalcode/dal-sync/src/client.d.ts +2 -0
  134. package/dist/node_modules/@dalcode/dal-sync/src/client.js +1 -1
  135. package/dist/node_modules/@dalcode/dal-sync/src/host.d.ts +11 -1
  136. package/dist/node_modules/@dalcode/dal-sync/src/host.js +2 -2
  137. package/dist/node_modules/@dalcode/dal-sync/src/index.js +3 -3
  138. package/dist/node_modules/@dalcode/dal-sync/src/sessions.d.ts +153 -0
  139. package/dist/node_modules/@dalcode/dal-sync/src/sessions.js +15 -0
  140. package/dist/node_modules/@dalcode/dal-telemetry/package.json +4 -4
  141. package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
  142. package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
  143. package/dist/node_modules/@dalcode/dal-usage/package.json +2 -2
  144. package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
  145. package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
  146. package/dist/node_modules/@dalcode/dal-workflow/src/todo.js +4 -4
  147. package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
  148. package/dist/node_modules/@dalcode/deepailab/src/index.js +3 -3
  149. package/dist/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
  150. package/dist/node_modules/@earendil-works/pi-ai/dist/cli.js +0 -0
  151. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  152. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/azure.json +1 -1
  153. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
  154. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
  155. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  156. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
  157. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
  158. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
  159. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
  160. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
  161. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
  162. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  163. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  164. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-cn.json +1 -1
  165. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.json +1 -1
  166. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
  167. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
  168. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  169. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
  170. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
  171. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.d.ts +1 -1
  172. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.js +1 -1
  173. package/dist/node_modules/@earendil-works/pi-ai/package.json +3 -3
  174. package/dist/node_modules/@earendil-works/pi-codemode/package.json +1 -1
  175. package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
  176. package/dist/node_modules/@earendil-works/pi-mcp/package.json +1 -1
  177. package/dist/node_modules/@earendil-works/pi-schema/package.json +1 -1
  178. package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  179. package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
  180. package/dist/sdk/sync.d.ts +8 -1
  181. package/dist/sdk/sync.js +1 -1
  182. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  183. package/examples/extensions/gondolin/package-lock.json +2 -2
  184. package/examples/extensions/gondolin/package.json +1 -1
  185. package/examples/extensions/with-deps/package-lock.json +2 -2
  186. package/examples/extensions/with-deps/package.json +1 -1
  187. package/npm-shrinkwrap.json +2 -2
  188. package/package.json +1 -1
  189. package/dist/bun/register-bedrock.js +0 -1
  190. package/dist/bundle/chunks/chunk-L3RBW36Y.js +0 -9
  191. package/dist/bundle/chunks/chunk-R7FBN5UP.js +0 -30
  192. package/dist/bundle/chunks/mcp-PC3Y3FBI.js +0 -10
  193. package/dist/bundle/chunks/sync-ONQZCAYG.js +0 -7
  194. package/dist/cli/experimental/auth.js +0 -1
  195. package/dist/cli/experimental/cli.js +0 -1
  196. package/dist/cli/experimental/command-options.js +0 -1
  197. package/dist/cli/experimental/command.js +0 -1
  198. package/dist/cli/experimental/commands/client.js +0 -1
  199. package/dist/cli/experimental/commands/pi.js +0 -1
  200. package/dist/cli/experimental/commands/server.js +0 -1
  201. package/dist/cli/experimental/transport-address.js +0 -1
  202. package/dist/client/index.js +0 -1
  203. package/dist/client/remote-session.js +0 -1
  204. package/dist/client/transcript.js +0 -1
  205. package/dist/core/provider-attribution.js +0 -1
  206. package/dist/modes/interactive/components/daxnuts.js +0 -1
  207. package/dist/modes/interactive/theme/theme-json.js +0 -12
  208. package/dist/modes/interactive/theme/theme-schema.json +0 -356
  209. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js +0 -1
  210. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.js +0 -37
  211. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js +0 -104
  212. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.js +0 -16
  213. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/config.js +0 -1
  214. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/context.js +0 -1
  215. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js +0 -10
  216. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/events.js +0 -1
  217. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/execution/assistant.js +0 -1
  218. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/execution/effect-gate.js +0 -1
  219. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/execution/tools.js +0 -1
  220. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/hooks.js +0 -1
  221. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.js +0 -17
  222. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/bash.js +0 -1
  223. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/bounded.js +0 -1
  224. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/chord.js +0 -1
  225. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/context.js +0 -1
  226. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/harness.js +0 -1
  227. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/hooks.js +0 -1
  228. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/index.js +0 -1
  229. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/jsonl.js +0 -4
  230. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/collapse.js +0 -3
  231. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/entries.js +0 -1
  232. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/frames.js +0 -1
  233. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/generation.js +0 -1
  234. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/job.js +0 -1
  235. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/plugin.js +0 -1
  236. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/post-tools.js +0 -1
  237. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/task-api.js +0 -1
  238. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/tool.js +0 -3
  239. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/membrane.js +0 -1
  240. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/memory.js +0 -1
  241. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/scheduler.js +0 -1
  242. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/session.js +0 -1
  243. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/system.js +0 -8
  244. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/types.js +0 -1
  245. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/view.js +0 -1
  246. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/prompt-templates.js +0 -5
  247. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/reducer.js +0 -1
  248. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/result.js +0 -1
  249. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/boundary.js +0 -1
  250. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/checkpoint.js +0 -1
  251. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/deferred.js +0 -1
  252. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/generation.js +0 -1
  253. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/reconcile.js +0 -1
  254. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/recovery.js +0 -1
  255. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/response.js +0 -1
  256. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/retry.js +0 -1
  257. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/structural.js +0 -1
  258. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/terminal.js +0 -1
  259. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/tool-placement.js +0 -1
  260. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/tools.js +0 -1
  261. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive.js +0 -1
  262. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/harness.js +0 -1
  263. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/index.js +0 -1
  264. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/lane.js +0 -1
  265. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/progress.js +0 -1
  266. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/reducer.js +0 -1
  267. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/restore.js +0 -1
  268. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/transcript.js +0 -1
  269. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/types.js +0 -1
  270. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/commit.js +0 -1
  271. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/context.js +0 -1
  272. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork-policy.js +0 -1
  273. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork.js +0 -1
  274. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/in-memory-storage-state.js +0 -1
  275. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/index.js +0 -1
  276. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/codec.js +0 -1
  277. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/errors.js +0 -1
  278. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/fork.js +0 -1
  279. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/index.js +0 -1
  280. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/io.js +0 -3
  281. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/legacy-v3.js +0 -1
  282. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/repo.js +0 -1
  283. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/storage.js +0 -8
  284. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/types.js +0 -1
  285. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.js +0 -1
  286. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js +0 -5
  287. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl.js +0 -1
  288. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.js +0 -1
  289. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js +0 -1
  290. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory.js +0 -1
  291. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/mutation-line.js +0 -1
  292. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js +0 -1
  293. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js +0 -1
  294. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/state.js +0 -1
  295. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/benchmark/datasets.js +0 -1
  296. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/benchmark/session-repo.js +0 -1
  297. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/benchmark/storage.js +0 -1
  298. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/conformance/session-repo.js +0 -1
  299. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/conformance/storage.js +0 -1
  300. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/conformance.js +0 -1
  301. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/gating-storage.js +0 -1
  302. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/index.js +0 -1
  303. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/instrumented-storage.js +0 -1
  304. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/storage-decorator.js +0 -1
  305. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/types.js +0 -0
  306. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/types.js +0 -1
  307. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/values.js +0 -1
  308. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.js +0 -10
  309. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/system-prompt.js +0 -2
  310. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/telemetry.js +0 -1
  311. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/bash.js +0 -12
  312. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit-diff.js +0 -16
  313. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.js +0 -1
  314. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/file-mutation-queue.js +0 -1
  315. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/image.js +0 -1
  316. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/index.js +0 -1
  317. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/path-utils.js +0 -1
  318. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/read.js +0 -14
  319. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/tool-context.js +0 -0
  320. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.js +0 -1
  321. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js +0 -1
  322. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/adaptive-publisher.js +0 -1
  323. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/output-capture.js +0 -5
  324. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js +0 -1
  325. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.js +0 -5
  326. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/usage.js +0 -1
  327. package/dist/node_modules/@earendil-works/pi-agent-core/dist/node.js +0 -1
  328. package/dist/node_modules/@earendil-works/pi-agent-core/dist/search/index.js +0 -0
  329. package/dist/node_modules/@earendil-works/pi-agent-core/dist/search/scanning.js +0 -1
  330. package/dist/node_modules/@earendil-works/pi-ai/dist/api/cloudflare-gateway-binding.js +0 -1
  331. package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/oauth-page.js +0 -74
  332. package/dist/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +0 -1
  333. package/dist/node_modules/@earendil-works/pi-ai/dist/images-models.js +0 -1
  334. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js +0 -1
  335. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js +0 -1
  336. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-images.js +0 -1
  337. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/assistant-message-frame.js +0 -1
  338. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/deferred-tools.js +0 -1
  339. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/pi-user-agent.js +0 -1
  340. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/typebox-helpers.js +0 -1
  341. package/dist/server/create-harness.js +0 -1
  342. package/dist/utils/clipboard-native.js +0 -1
package/CHANGELOG.md CHANGED
@@ -8,6 +8,24 @@ DAL Code 的发布说明。这里只写用户看得见的变化。
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [1.0.56] - 2026-11-25
12
+
13
+ - 对话记录跟随 DeepAILab 账户:登录后,对话会同步到你的账户,换一台电脑登录、打开同一个项目,就能在 `/resume` 里找到并接着聊;两台电脑在同一段对话里各自继续,也会自动合并。上传前会去掉密钥、密码和主目录路径,图片不上传,临时目录里的对话不同步。默认开启,`/sync off` 关闭;在 deepailab.ai/dal-sync 查看和删除,在那里删除的对话不会再被上传。
14
+ - `/sync status` 显示已同步的对话数;首次同步大量历史时会分几次在后台完成。
15
+ - `dal --mode acp`(Agent Client Protocol)可以作为其他应用的工作引擎:新建会话时可指定工作目录、要接入的 MCP 服务器、模型、思考强度、附加的系统提示和会话名称;之前的会话可以按编号恢复并重放历史;需要批准的操作会向调用方发出确认请求(只有“仅本次允许”和“拒绝”,2 分钟没有回应按拒绝处理);每条回答都带上 token 用量、费用和所用模型;工具调用会报告名称、状态和输出(超过 32KB 的部分截断)。
16
+ - 用环境变量 `DAL_API_BASE` 和 `DAL_VK` 指定网关和密钥时,不登录也能读取模型列表并正常对话,包括只接受标准 `Authorization` 头的网关。
17
+ - MCP 服务器配置为 `"exposure": "direct"` 时,它的工具始终以自己的名称直接提供给模型,不会被合并进通用的 MCP 工具或延后加载。
18
+
19
+ ## [1.0.55] - 2026-11-22
20
+
21
+ - 修改文件时的改动显示更清楚:新增行和删除行带整行底色,相距较远的改动用“⋮”隔开,标题写明增删了几行。
22
+ - 工作中的状态行显示已用时间、已生成的 token 数和中断按键。
23
+ - 工具调用前显示状态点:成功与失败用不同颜色区分,展开后结果挂在“⎿”下。
24
+ - 待办清单:已完成的划掉并打勾,进行中的高亮,不再显示编号。
25
+ - 隐藏思考过程时,回答前留一行“已思考 N 秒”,可以展开查看。
26
+ - 自我进化不再空转:新学到的经验会在相关任务里先试用,经独立判定帮上忙就自动启用,帮倒忙或一直没用就自动停用,不再等同样的问题第二次出现。
27
+ - 只提醒“不要这样做”的经验(例如不要使用找到的密钥)不再被当成高风险而卡在等待确认;真正教人删除、使用凭据或发布的经验仍需确认。
28
+
11
29
  ## [1.0.54] - 2026-11-22
12
30
 
13
31
  - 长任务里不再频繁整理上下文:较早对话整理为摘要的频率减半,整理后只显示一行“较早的对话已整理为摘要”,不再显示 token 数。
package/NOTICE CHANGED
@@ -427,6 +427,17 @@ office_read_file (@dalcode/dal-office) extracts PDF text with pdf.js, unmodified
427
427
  to endorse or promote derived products without written permission; the maps
428
428
  are provided "as is", without warranty of any kind.
429
429
 
430
+ The tool diff display (packages/coding-agent, modes/interactive/components/diff.ts)
431
+ follows the diff presentation of pi-ext-code-cards 0.2.3 — whole-line
432
+ backgrounds on added and removed lines, a `⋮` between distant change regions
433
+ and the added/removed totals — reimplemented, not copied:
434
+
435
+ @hex4c59/pi-ext-code-cards (https://www.npmjs.com/package/@hex4c59/pi-ext-code-cards)
436
+ Licensed under the Apache License, Version 2.0. Its NOTICE reads, in part:
437
+ "The single-column file diff presentation strategy was informed by OpenAI
438
+ Codex, commit 481cb038c25d1c2dabcdfffcbdb6d9cb1ab73f8e, licensed under
439
+ Apache-2.0."
440
+
430
441
  Third-party dependencies are installed from the public npm registry and carry
431
442
  their own licenses in their own package directories. A few that a vendored
432
443
  component needs at a version the rest of the package does not use ship inside
@@ -1,4 +1,4 @@
1
- var oe=Object.defineProperty;var l=(e,r)=>oe(e,"name",{value:r,configurable:!0});import{createRequire as ie}from"node:module";const St=ie(import.meta.url);import{ANTHROPIC_FEDERATION_RULE_ID_ENV as le,ANTHROPIC_IDENTITY_TOKEN_FILE_ENV as ue,ANTHROPIC_ORGANIZATION_ID_ENV as ce,ANTHROPIC_SERVICE_ACCOUNT_ID_ENV as pe,ANTHROPIC_WORKSPACE_ID_ENV as de}from"./chunk-723ZGEZ2.js";import{registerSessionResourceCleanup as W}from"./chunk-ZG74NES2.js";import{applyOpenRouterReportedCost as he,isOpenRouterModel as ge}from"./chunk-P7FPUEYA.js";import{buildCopilotDynamicHeaders as fe,hasCopilotVisionInput as me}from"./chunk-PGXDEOVV.js";import{shortHash as _e}from"./chunk-PJACZCIR.js";import{adjustMaxTokensForThinking as ye,buildBaseOptions as ke,clampMaxTokensToContext as Te,getJsonSchemaToolParameters as ve,prefersJsonSchemaStrictSampling as V,resolveJsonSchemaStrictSampling as xe,splitErrorToolResultImages as Se,transformMessages as z}from"./chunk-FE533CCR.js";import{sanitizeSurrogates as b}from"./chunk-L2ZPNLYD.js";import{retryProviderRequest as be}from"./chunk-ML5DIOWR.js";import{withCauseDetail as Re}from"./chunk-33MCYYJ3.js";import{headersToRecord as Ee}from"./chunk-UTB4DTYQ.js";import{getProviderEnvValue as C}from"./chunk-7DDKXS2Q.js";import{ToolCallArgumentsStream as we,parseJsonWithRepair as Ie}from"./chunk-FFMDRXC4.js";import{calculateCost as G,getCurrentTools as K,getInitialSystemMessage as Ae,resolveTranscript as Ce}from"./chunk-K4B5ABCQ.js";import{AssistantMessageEventStream as Me,appendAssistantMessageDiagnostic as P}from"./chunk-4LDEEFCY.js";import{getIdentityHeaders as B,getSystemMessageText as Oe,renderSystemMessageUpdate as Ne}from"./chunk-SCYK4XNE.js";import{Anthropic as H}from"./chunk-D2WTLI2T.js";import"./chunk-JXWJOIH4.js";var Le=["The compiled grammar is too large","Too many strict tools (","Schemas contains too many parameters with union types ("];function De(e){return Le.some(r=>e.includes(r))}l(De,"isStrictToolLimitErrorMessage");var I=new Set,Pe=1e4;function Be(e){if(e!==void 0&&(I.add(e),I.size>Pe)){let r=I.values().next().value;r!==void 0&&I.delete(r)}}l(Be,"markStrictToolLimitsExceeded");function He(e){return e!==void 0&&I.has(e)}l(He,"hasExceededStrictToolLimits"),W(e=>{e?I.delete(e):I.clear()});function $(e,r){return e||(C("PI_CACHE_RETENTION",r)==="long"?"long":"short")}l($,"resolveCacheRetention");function Ue(e,r,t){let s=$(r,t);if(s==="none")return{retention:s};let i=s==="long"&&M(e).supportsLongCacheRetention?"1h":void 0;return{retention:s,cacheControl:{type:"ephemeral",...i&&{ttl:i}}}}l(Ue,"getCacheControl");function U(e){return{type:"image",source:{type:"base64",media_type:e.mimeType,data:e.data}}}l(U,"convertImageBlock");function Fe(e){if(!e.some(t=>t.type==="image"))return b(e.map(t=>t.text).join(`
1
+ var oe=Object.defineProperty;var l=(e,r)=>oe(e,"name",{value:r,configurable:!0});import{createRequire as ie}from"node:module";const St=ie(import.meta.url);import{ANTHROPIC_FEDERATION_RULE_ID_ENV as le,ANTHROPIC_IDENTITY_TOKEN_FILE_ENV as ue,ANTHROPIC_ORGANIZATION_ID_ENV as ce,ANTHROPIC_SERVICE_ACCOUNT_ID_ENV as pe,ANTHROPIC_WORKSPACE_ID_ENV as de}from"./chunk-723ZGEZ2.js";import{registerSessionResourceCleanup as W}from"./chunk-ZG74NES2.js";import{applyOpenRouterReportedCost as he,isOpenRouterModel as ge}from"./chunk-P7FPUEYA.js";import{buildCopilotDynamicHeaders as fe,hasCopilotVisionInput as me}from"./chunk-PGXDEOVV.js";import{shortHash as _e}from"./chunk-PJACZCIR.js";import{adjustMaxTokensForThinking as ye,buildBaseOptions as ke,clampMaxTokensToContext as Te,getJsonSchemaToolParameters as ve,prefersJsonSchemaStrictSampling as V,resolveJsonSchemaStrictSampling as xe,splitErrorToolResultImages as Se,transformMessages as z}from"./chunk-3XMZ5UC3.js";import{sanitizeSurrogates as b}from"./chunk-L2ZPNLYD.js";import{retryProviderRequest as be}from"./chunk-ML5DIOWR.js";import{withCauseDetail as Re}from"./chunk-ZR6PGIL7.js";import{headersToRecord as Ee}from"./chunk-UTB4DTYQ.js";import{getProviderEnvValue as C}from"./chunk-7DDKXS2Q.js";import{ToolCallArgumentsStream as we,parseJsonWithRepair as Ie}from"./chunk-FFMDRXC4.js";import{calculateCost as G,getCurrentTools as K,getInitialSystemMessage as Ae,resolveTranscript as Ce}from"./chunk-BIY5HTFI.js";import{AssistantMessageEventStream as Me,appendAssistantMessageDiagnostic as P}from"./chunk-4LDEEFCY.js";import{getIdentityHeaders as B,getSystemMessageText as Oe,renderSystemMessageUpdate as Ne}from"./chunk-F37JXTCY.js";import{Anthropic as H}from"./chunk-D2WTLI2T.js";import"./chunk-JXWJOIH4.js";var Le=["The compiled grammar is too large","Too many strict tools (","Schemas contains too many parameters with union types ("];function De(e){return Le.some(r=>e.includes(r))}l(De,"isStrictToolLimitErrorMessage");var I=new Set,Pe=1e4;function Be(e){if(e!==void 0&&(I.add(e),I.size>Pe)){let r=I.values().next().value;r!==void 0&&I.delete(r)}}l(Be,"markStrictToolLimitsExceeded");function He(e){return e!==void 0&&I.has(e)}l(He,"hasExceededStrictToolLimits"),W(e=>{e?I.delete(e):I.clear()});function $(e,r){return e||(C("PI_CACHE_RETENTION",r)==="long"?"long":"short")}l($,"resolveCacheRetention");function Ue(e,r,t){let s=$(r,t);if(s==="none")return{retention:s};let i=s==="long"&&M(e).supportsLongCacheRetention?"1h":void 0;return{retention:s,cacheControl:{type:"ephemeral",...i&&{ttl:i}}}}l(Ue,"getCacheControl");function U(e){return{type:"image",source:{type:"base64",media_type:e.mimeType,data:e.data}}}l(U,"convertImageBlock");function Fe(e){if(!e.some(t=>t.type==="image"))return b(e.map(t=>t.text).join(`
2
2
  `));let r=e.map(t=>t.type==="text"?{type:"text",text:b(t.text)}:U(t));return r.some(t=>t.type==="text")||r.unshift({type:"text",text:"(see attached image)"}),r}l(Fe,"convertContentBlocks");var qe="fine-grained-tool-streaming-2025-05-14",je="interleaved-thinking-2025-05-14",We="server-side-fallback-2026-07-01",Ve="mid-conversation-output-config-2026-07-01",ze="thinking-binding-controls-2026-08-01",Ge="inline-tools-2026-09-15",Ke="message-threads-2026-08-12",$e={name:"__pi_deferred_placeholder__",description:"Reserved placeholder. Never available. Never call this.",input_schema:{type:"object",properties:{},required:[]},defer_loading:!0};function Je(e){return(e.compat?.allowedFallbackModels?.length??0)>0}l(Je,"shouldUseServerSideFallbackBeta");function M(e){let r=e.provider==="openrouter"||e.baseUrl.includes("openrouter.ai");return{supportsEagerToolInputStreaming:e.compat?.supportsEagerToolInputStreaming??!0,supportsLongCacheRetention:e.compat?.supportsLongCacheRetention??!0,sendSessionAffinityHeaders:e.compat?.sendSessionAffinityHeaders??r,sessionAffinityFormat:e.compat?.sessionAffinityFormat??(r?"openrouter":void 0),supportsCacheControlOnTools:e.compat?.supportsCacheControlOnTools??!0,supportsTemperature:e.compat?.supportsTemperature??!0,allowEmptySignature:e.compat?.allowEmptySignature??!1,supportsStrictTools:e.compat?.supportsStrictTools??!1,supportsMidConvoSystemMessages:e.compat?.supportsMidConvoSystemMessages??!1,supportsMidConvoToolChanges:e.compat?.supportsMidConvoToolChanges??!1,supportsMessageThreads:e.compat?.supportsMessageThreads??(e.provider==="anthropic"&&e.baseUrl.includes("api.anthropic.com"))}}l(M,"getAnthropicCompat");var E=new Map,Xe=1e4,Ye=new Set(["thread_not_found","thread_already_continued","thread_continue_in_flight","thread_fingerprint_mismatch"]);function J(e,r){if(E.delete(e),E.set(e,r),E.size>Xe){let t=E.keys().next().value;t!==void 0&&E.delete(t)}}l(J,"setThreadState"),W(e=>{e?E.delete(e):E.clear()});function X(e,r,t){let{system:s,tools:i,thinking:o,output_config:n,tool_choice:u,betas:g,fallbacks:_}=r,p=JSON.stringify([e.provider,e.baseUrl,r.model,s,i,o,n,u,g,_]),c=JSON.stringify(t,(m,y)=>{if(m!=="cache_control")return m==="content"&&typeof y=="string"?[{type:"text",text:y}]:y});return _e(p+c)}l(X,"hashThreadPrefix");function Y(e,r){return{sessionId:e,body:{...r,thread:{type:"create"}}}}l(Y,"createThreadRequest");function Ze(e,r,t){let s=E.get(r);if(s!=="off"){if(s!==void 0&&t.messages.length>s.prefixCount&&X(e,t,t.messages.slice(0,s.prefixCount))===s.prefixHash){E.delete(r);let{system:i,tools:o,...n}=t;return{body:{...n,messages:t.messages.slice(s.prefixCount),thread:{type:"continue",previous_message_id:s.replyId}},sessionId:r}}return Y(r,t)}}l(Ze,"prepareThreadRequest");function Qe(e){let r=e.error?.error?.details?.error_code;return typeof r=="string"?r:void 0}l(Qe,"getThreadErrorCode");async function et(e,r,t,s,i){try{return{response:await t(e.body),thread:e}}catch(o){if(i?.aborted||!(o instanceof H.APIError))throw o;let n=Qe(o),u=n!==void 0&&Ye.has(n),g=n==="thread_unsupported_request"||n===void 0&&o.status===400&&o.message.includes("thread");if(!u&&!g)throw o;if(P(s,{type:"anthropic_thread_fallback",timestamp:Date.now(),error:{message:o.message},details:{reason:n??String(o.status)}}),u){let p=Y(e.sessionId,r);return{response:await t(p.body),thread:p}}let _=await t(r);return J(e.sessionId,"off"),{response:_,thread:void 0}}}l(et,"sendThreadRequest");function tt(e,r,t,s,i,o){if(s.responseId===void 0||s.responseModel!==void 0)return;let n=re(z([s],e,ne),i,void 0,o).messages.filter(g=>g.role==="assistant"),u=[...t.messages,...n];J(r.sessionId,{prefixCount:u.length,prefixHash:X(e,t,u),replyId:s.responseId})}l(tt,"recordThreadReply");function F(...e){let r={};for(let t of e)t&&Object.assign(r,t);return r}l(F,"mergeHeaders");function q(e,r){if(!e)return!1;let t=r.toLowerCase();for(let[s,i]of Object.entries(e))if(s.toLowerCase()===t&&i!==null&&i.trim().length>0)return!0;return!1}l(q,"hasHeader");function Z(e,r){return!!e||q(r,"authorization")||q(r,"x-api-key")||q(r,"cf-aig-authorization")}l(Z,"hasRequestAuth");function Q(e,r,t){if(!Z(r,t))throw new Error(`No API key for provider: ${e}`)}l(Q,"assertRequestAuth");var O=class extends H{static{l(this,"PiAnthropic")}_shouldResolveDefaultCredentials(){return!1}};function ee(e,r,t,s){if(e.provider!=="anthropic"||Z(r,t))return;let i=C(le,s),o=C(ce,s),n=C(ue,s);if(!(!i||!o||!n))return{organization_id:o,workspace_id:C(de,s),authentication:{type:"oidc_federation",federation_rule_id:i,service_account_id:C(pe,s),identity_token:{source:"file",path:n}}}}l(ee,"getAnthropicFederation");var N,nt=new Set(["message_start","message_delta","message_stop","content_block_start","content_block_delta","content_block_stop"]);function te(e){if(!e.event&&e.data.length===0)return null;let r={event:e.event,data:e.data.join(`
3
3
  `),raw:[...e.raw]};return e.event=null,e.data=[],e.raw=[],r}l(te,"flushSseEvent");function j(e,r){if(e==="")return te(r);if(r.raw.push(e),e.startsWith(":"))return null;let t=e.indexOf(":"),s=t===-1?e:e.slice(0,t),i=t===-1?"":e.slice(t+1);return i.startsWith(" ")&&(i=i.slice(1)),s==="event"?r.event=i:s==="data"&&r.data.push(i),null}l(j,"decodeSseLine");function rt(e){let r=e.indexOf("\r"),t=e.indexOf(`
4
4
  `);return r===-1?t:t===-1?r:Math.min(r,t)}l(rt,"nextLineBreakIndex");function L(e){let r=rt(e);if(r===-1)return null;let t=r+1;return e[r]==="\r"&&e[t]===`
@@ -1 +1 @@
1
- var R=Object.defineProperty;var u=(r,t)=>R(r,"name",{value:t,configurable:!0});import{createRequire as T}from"node:module";const Z=T(import.meta.url);import{convertResponsesMessages as M,convertResponsesTools as A,getResponsesToolSupport as S,processResponsesStream as w}from"./chunk-B5GJW7C2.js";import{resolveAzureConfig as E,resolveDeploymentName as O}from"./chunk-TMTOQ7H7.js";import{clampOpenAIPromptCacheKey as I}from"./chunk-PRRNXB7S.js";import{AzureOpenAI as P}from"./chunk-CF5GWZHW.js";import"./chunk-PJACZCIR.js";import{buildBaseOptions as C,createGrammarToolInputProperties as d,resolveSamplingParams as _}from"./chunk-FE533CCR.js";import"./chunk-L2ZPNLYD.js";import{retryProviderRequest as b}from"./chunk-ML5DIOWR.js";import{formatProviderError as k,normalizeProviderError as x}from"./chunk-33MCYYJ3.js";import{headersToRecord as z}from"./chunk-UTB4DTYQ.js";import"./chunk-7DDKXS2Q.js";import"./chunk-FFMDRXC4.js";import{clampThinkingLevel as q,getDeclaredTools as h,resolveTranscript as L,resolveTranscriptTools as N}from"./chunk-K4B5ABCQ.js";import{AssistantMessageEventStream as G}from"./chunk-4LDEEFCY.js";import{getIdentityHeaders as K}from"./chunk-SCYK4XNE.js";import"./chunk-JXWJOIH4.js";var D=new Set(["openai","openai-codex","opencode","azure"]),U=16;function j(r){return k(x(r),"Azure OpenAI API error")}u(j,"formatAzureOpenAIError");var v=u((r,t,e)=>{let a=new G,p=L(t,r.compat?.supportsMidConvoSystemMessages);return(async()=>{let n=O(r,e),s={role:"assistant",content:[],api:"azure-openai-responses",provider:r.provider,model:r.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"pending",timestamp:Date.now()};try{let i=e?.apiKey;if(!i)throw new Error(`No API key for provider: ${r.provider}`);let l=H(r,i,e),o=d(h(p.messages),r.compat?.supportsOpenAIGrammarTools??!1),m=V(r,p,e,n,o),c=await e?.onPayload?.(m,r);c!==void 0&&(m=c);let g={...e?.signal?{signal:e.signal}:{},...e?.timeoutMs!==void 0?{timeout:e.timeoutMs}:{},maxRetries:0},{data:y,response:f}=await b(()=>l.responses.create(m,g).withResponse(),{maxRetries:e?.maxRetries,maxRetryDelayMs:e?.maxRetryDelayMs,signal:e?.signal});if(await e?.onResponse?.({status:f.status,headers:z(f.headers)},r),a.push({type:"start",partial:s}),await w(y,s,a,r,{onProviderStreamEvent:e?.onProviderStreamEvent,grammarToolInputProperties:o}),e?.signal?.aborted)throw new Error("Request was aborted");if(s.stopReason==="pending")throw new Error("Azure OpenAI Responses stream ended without a stop reason");if(s.stopReason==="aborted"||s.stopReason==="error")throw new Error(s.errorMessage||"An unknown error occurred");a.push({type:"done",reason:s.stopReason,message:s}),a.end()}catch(i){s.stopReason=e?.signal?.aborted?"aborted":"error",s.errorMessage=j(i),a.push({type:"error",reason:s.stopReason,error:s}),a.end()}})(),a},"stream"),B=u((r,t,e)=>{let a=e?.apiKey;if(!a)throw new Error(`No API key for provider: ${r.provider}`);let p={...C(r,t,e,a),toolChoice:e?.toolChoice},n=e?.reasoning?q(r,e.reasoning):void 0;return v(r,t,{...p,reasoningEffort:n==="off"?void 0:n})},"streamSimple");function H(r,t,e){let a={...K(r,e?.identity),...r.headers};e?.headers&&Object.assign(a,e.headers);let{baseUrl:p,apiVersion:n}=E(r,e);return new P({apiKey:t,apiVersion:n,dangerouslyAllowBrowser:!0,fetch:e?.fetch,defaultHeaders:a,baseURL:p})}u(H,"createClient");function V(r,t,e,a,p=d(h(t.messages),r.compat?.supportsOpenAIGrammarTools??!1)){let n=r.compat?.supportsAdditionalTools??!1,s=r.compat?.supportsToolSearch??!1,i=N(t.messages,S({supportsMidConvoSystemMessages:r.compat?.supportsMidConvoSystemMessages??!1,supportsAdditionalTools:n,supportsToolSearch:s})),l=M(r,t,D,{grammarToolInputProperties:p,supportsMidConvoSystemMessages:r.compat?.supportsMidConvoSystemMessages??!1,supportsAdditionalTools:n,supportsToolSearch:s,toolOptions:{supportsStrictMode:r.compat?.supportsStrictMode??!0,supportsOpenAIGrammarTools:r.compat?.supportsOpenAIGrammarTools??!1}}),o={model:a,input:l,stream:!0,prompt_cache_key:r.compat?.promptCacheKeyMode==="disabled"?void 0:I(e?.sessionId),store:!1};e?.maxTokens&&(o.max_output_tokens=Math.max(e.maxTokens,U)),e?.temperature!==void 0&&(o.temperature=e?.temperature),i.requestTools.length>0&&(o.tools=A(i.requestTools,{supportsStrictMode:r.compat?.supportsStrictMode??!0,supportsOpenAIGrammarTools:r.compat?.supportsOpenAIGrammarTools??!1})),e?.toolChoice!==void 0&&(o.tool_choice=e.toolChoice);let m=e?.reasoningEffort??(e?.reasoningSummary?"medium":void 0);if(r.reasoning)if(m){let g=e?.reasoningEffort?r.thinkingLevelMap?.[e.reasoningEffort]??e.reasoningEffort:m;o.reasoning={effort:g,summary:e?.reasoningSummary||"auto"},o.include=["reasoning.encrypted_content"]}else r.thinkingLevelMap?.off!==null&&(o.reasoning={effort:r.thinkingLevelMap?.off??"none"});let c=_(r,m??"off",e?.samplingParams);return c&&Object.assign(o,c),o}u(V,"buildParams");export{v as stream,B as streamSimple};
1
+ var R=Object.defineProperty;var u=(r,t)=>R(r,"name",{value:t,configurable:!0});import{createRequire as T}from"node:module";const Z=T(import.meta.url);import{convertResponsesMessages as M,convertResponsesTools as A,getResponsesToolSupport as S,processResponsesStream as w}from"./chunk-PH42AQ66.js";import{resolveAzureConfig as E,resolveDeploymentName as O}from"./chunk-TMTOQ7H7.js";import{clampOpenAIPromptCacheKey as I}from"./chunk-PRRNXB7S.js";import{AzureOpenAI as P}from"./chunk-CF5GWZHW.js";import"./chunk-PJACZCIR.js";import{buildBaseOptions as C,createGrammarToolInputProperties as d,resolveSamplingParams as _}from"./chunk-3XMZ5UC3.js";import"./chunk-L2ZPNLYD.js";import{retryProviderRequest as b}from"./chunk-ML5DIOWR.js";import{formatProviderError as k,normalizeProviderError as x}from"./chunk-ZR6PGIL7.js";import{headersToRecord as z}from"./chunk-UTB4DTYQ.js";import"./chunk-7DDKXS2Q.js";import"./chunk-FFMDRXC4.js";import{clampThinkingLevel as q,getDeclaredTools as h,resolveTranscript as L,resolveTranscriptTools as N}from"./chunk-BIY5HTFI.js";import{AssistantMessageEventStream as G}from"./chunk-4LDEEFCY.js";import{getIdentityHeaders as K}from"./chunk-F37JXTCY.js";import"./chunk-JXWJOIH4.js";var D=new Set(["openai","openai-codex","opencode","azure"]),U=16;function j(r){return k(x(r),"Azure OpenAI API error")}u(j,"formatAzureOpenAIError");var v=u((r,t,e)=>{let a=new G,p=L(t,r.compat?.supportsMidConvoSystemMessages);return(async()=>{let n=O(r,e),s={role:"assistant",content:[],api:"azure-openai-responses",provider:r.provider,model:r.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"pending",timestamp:Date.now()};try{let i=e?.apiKey;if(!i)throw new Error(`No API key for provider: ${r.provider}`);let l=H(r,i,e),o=d(h(p.messages),r.compat?.supportsOpenAIGrammarTools??!1),m=V(r,p,e,n,o),c=await e?.onPayload?.(m,r);c!==void 0&&(m=c);let g={...e?.signal?{signal:e.signal}:{},...e?.timeoutMs!==void 0?{timeout:e.timeoutMs}:{},maxRetries:0},{data:y,response:f}=await b(()=>l.responses.create(m,g).withResponse(),{maxRetries:e?.maxRetries,maxRetryDelayMs:e?.maxRetryDelayMs,signal:e?.signal});if(await e?.onResponse?.({status:f.status,headers:z(f.headers)},r),a.push({type:"start",partial:s}),await w(y,s,a,r,{onProviderStreamEvent:e?.onProviderStreamEvent,grammarToolInputProperties:o}),e?.signal?.aborted)throw new Error("Request was aborted");if(s.stopReason==="pending")throw new Error("Azure OpenAI Responses stream ended without a stop reason");if(s.stopReason==="aborted"||s.stopReason==="error")throw new Error(s.errorMessage||"An unknown error occurred");a.push({type:"done",reason:s.stopReason,message:s}),a.end()}catch(i){s.stopReason=e?.signal?.aborted?"aborted":"error",s.errorMessage=j(i),a.push({type:"error",reason:s.stopReason,error:s}),a.end()}})(),a},"stream"),B=u((r,t,e)=>{let a=e?.apiKey;if(!a)throw new Error(`No API key for provider: ${r.provider}`);let p={...C(r,t,e,a),toolChoice:e?.toolChoice},n=e?.reasoning?q(r,e.reasoning):void 0;return v(r,t,{...p,reasoningEffort:n==="off"?void 0:n})},"streamSimple");function H(r,t,e){let a={...K(r,e?.identity),...r.headers};e?.headers&&Object.assign(a,e.headers);let{baseUrl:p,apiVersion:n}=E(r,e);return new P({apiKey:t,apiVersion:n,dangerouslyAllowBrowser:!0,fetch:e?.fetch,defaultHeaders:a,baseURL:p})}u(H,"createClient");function V(r,t,e,a,p=d(h(t.messages),r.compat?.supportsOpenAIGrammarTools??!1)){let n=r.compat?.supportsAdditionalTools??!1,s=r.compat?.supportsToolSearch??!1,i=N(t.messages,S({supportsMidConvoSystemMessages:r.compat?.supportsMidConvoSystemMessages??!1,supportsAdditionalTools:n,supportsToolSearch:s})),l=M(r,t,D,{grammarToolInputProperties:p,supportsMidConvoSystemMessages:r.compat?.supportsMidConvoSystemMessages??!1,supportsAdditionalTools:n,supportsToolSearch:s,toolOptions:{supportsStrictMode:r.compat?.supportsStrictMode??!0,supportsOpenAIGrammarTools:r.compat?.supportsOpenAIGrammarTools??!1}}),o={model:a,input:l,stream:!0,prompt_cache_key:r.compat?.promptCacheKeyMode==="disabled"?void 0:I(e?.sessionId),store:!1};e?.maxTokens&&(o.max_output_tokens=Math.max(e.maxTokens,U)),e?.temperature!==void 0&&(o.temperature=e?.temperature),i.requestTools.length>0&&(o.tools=A(i.requestTools,{supportsStrictMode:r.compat?.supportsStrictMode??!0,supportsOpenAIGrammarTools:r.compat?.supportsOpenAIGrammarTools??!1})),e?.toolChoice!==void 0&&(o.tool_choice=e.toolChoice);let m=e?.reasoningEffort??(e?.reasoningSummary?"medium":void 0);if(r.reasoning)if(m){let g=e?.reasoningEffort?r.thinkingLevelMap?.[e.reasoningEffort]??e.reasoningEffort:m;o.reasoning={effort:g,summary:e?.reasoningSummary||"auto"},o.include=["reasoning.encrypted_content"]}else r.thinkingLevelMap?.off!==null&&(o.reasoning={effort:r.thinkingLevelMap?.off??"none"});let c=_(r,m??"off",e?.samplingParams);return c&&Object.assign(o,c),o}u(V,"buildParams");export{v as stream,B as streamSimple};
@@ -76,7 +76,7 @@ Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.ht
76
76
  `);let{connect:d}=await h;if(e.emit("proxyConnect",d),this.emit("proxyConnect",d,e),d.statusCode===200)return e.once("socket",tD),t.secureEndpoint?(ns("Upgrading socket connection to TLS"),Vd.connect({...US(Kd(t),"host","path","port"),socket:n})):n;throw n.destroy(),new Error(`Proxy authentication failed with status ${d.statusCode} after retry`)}};eD.protocols=["http","https"];function tD(e){setImmediate(()=>{e.resume()})}i(tD,"resume");function US(e,...t){let r={},s;for(s in e)t.includes(s)||(r[s]=e[s]);return r}i(US,"omit2");var rD=class{static{i(this,"FifoQueue")}incoming=[];outgoing=[];get length(){return this.incoming.length+this.outgoing.length}enqueue(e){this.incoming.push(e)}dequeue(){if(this.outgoing.length===0)for(;this.incoming.length>0;)this.outgoing.push(this.incoming.pop());return this.outgoing.pop()}},jq=class{static{i(this,"EventStream")}queue=new rD;waiting=new rD;done=!1;finalResultPromise;resolveFinalResult;isComplete;extractResult;constructor(e,t){this.isComplete=e,this.extractResult=t,this.finalResultPromise=new Promise(r=>{this.resolveFinalResult=r})}push(e){if(this.done)return;this.isComplete(e)&&(this.done=!0,this.resolveFinalResult(this.extractResult(e)));let t=this.waiting.dequeue();t?t({value:e,done:!1}):this.queue.enqueue(e)}end(e){for(this.done=!0,e!==void 0&&this.resolveFinalResult(e);this.waiting.length>0;)this.waiting.dequeue()({value:void 0,done:!0})}async*[Symbol.asyncIterator](){for(;;)if(this.queue.length>0)yield this.queue.dequeue();else{if(this.done)return;{let e=await new Promise(t=>this.waiting.enqueue(t));if(e.done)return;yield e.value}}}result(){return this.finalResultPromise}},Gq=class extends jq{static{i(this,"AssistantMessageEventStream")}#t=Date.now();#s=performance.now();#e;constructor(){super(e=>e.type==="done"||e.type==="error",e=>{if(e.type==="done")return e.message;if(e.type==="error")return e.error;throw new Error("Unexpected event type for final result")})}push(e){this.#e===void 0&&(e.type==="text_delta"||e.type==="thinking_delta"||e.type==="toolcall_delta")&&(this.#e=this.#r()),e.type==="done"?this.#i(e.message):e.type==="error"&&this.#i(e.error),super.push(e)}end(e){e!==void 0&&this.#i(e),super.end(e)}#r(){return Math.max(0,Math.round(performance.now()-this.#s))}#i(e){this.done||e.timestamp<this.#t||(this.#e!==void 0&&e.timing?.firstTokenMs===void 0&&(e.timing={...e.timing,firstTokenMs:this.#e}),e.durationMs===void 0&&(e.durationMs=this.#r()))}};function iD(e,t){e.diagnostics=[...e.diagnostics??[],t]}i(iD,"appendAssistantMessageDiagnostic");function sD(e,t=`
77
77
  `){return typeof e=="string"?e:e.filter(r=>r.type==="text").map(r=>r.text).join(t)}i(sD,"contentText");function nD(e){let t=[sD(e.content)];for(let r of Object.values(e.sections??{}))r!==null&&t.push(r);return t.filter(r=>r.length>0).join(`
78
78
 
79
- `)}i(nD,"getSystemMessageText");function Hq(e,t,r=e.length){return`${e.slice(t,r)} `.slice(0,-1)}i(Hq,"ownedSlice");var zq="1.0.54";function Wq(e){return e?.version??zq}i(Wq,"getClientVersion");function jS(e){return e.role==="system"}i(jS,"isSystemMessage");function oD(e){let t=e[0];return t&&jS(t)?t:void 0}i(oD,"getInitialSystemMessage");function Vq(e){return oD(e)?e.slice(1):e}i(Vq,"withoutInitialSystemMessage");function aD(e){let t=new Map;for(let r of e)if(jS(r)){for(let s of r.toolsRemoved??[])t.delete(s.name);for(let s of r.toolsAdded??[])t.set(s.name,s)}return[...t.values()]}i(aD,"getCurrentTools");function qq(e){let t=[],r=new Map,s;for(let o of e){if(!jS(o))continue;s??=o.timestamp;let a=sD(o.content);a.length>0&&t.push(a);for(let[l,h]of Object.entries(o.sections??{}))h===null?r.delete(l):r.set(l,h)}let n=aD(e);if(!(s===void 0&&n.length===0))return{role:"system",content:t.join(`
79
+ `)}i(nD,"getSystemMessageText");function Hq(e,t,r=e.length){return`${e.slice(t,r)} `.slice(0,-1)}i(Hq,"ownedSlice");var zq="1.0.56";function Wq(e){return e?.version??zq}i(Wq,"getClientVersion");function jS(e){return e.role==="system"}i(jS,"isSystemMessage");function oD(e){let t=e[0];return t&&jS(t)?t:void 0}i(oD,"getInitialSystemMessage");function Vq(e){return oD(e)?e.slice(1):e}i(Vq,"withoutInitialSystemMessage");function aD(e){let t=new Map;for(let r of e)if(jS(r)){for(let s of r.toolsRemoved??[])t.delete(s.name);for(let s of r.toolsAdded??[])t.set(s.name,s)}return[...t.values()]}i(aD,"getCurrentTools");function qq(e){let t=[],r=new Map,s;for(let o of e){if(!jS(o))continue;s??=o.timestamp;let a=sD(o.content);a.length>0&&t.push(a);for(let[l,h]of Object.entries(o.sections??{}))h===null?r.delete(l):r.set(l,h)}let n=aD(e);if(!(s===void 0&&n.length===0))return{role:"system",content:t.join(`
80
80
 
81
81
  `),...r.size>0?{sections:Object.fromEntries(r)}:{},...n.length>0?{toolsAdded:n}:{},timestamp:s??0}}i(qq,"getCurrentSystemMessage");function Kq(e){let t=qq(e.messages),r=e.messages.filter(s=>s.role!=="system");return{messages:t?[t,...r]:r}}i(Kq,"collapseSystemMessages");function Jq(e,t){let r=t.input+t.cacheRead+t.cacheWrite,s=e.cost,n=-1;for(let l of e.cost.tiers??[])r>l.inputTokensAbove&&l.inputTokensAbove>n&&(s=l,n=l.inputTokensAbove);let o=t.cacheWrite1h??0,a=t.cacheWrite-o;return t.cost.input=s.input/1e6*t.input,t.cost.output=s.output/1e6*t.output,t.cost.cacheRead=s.cacheRead/1e6*t.cacheRead,t.cost.cacheWrite=(s.cacheWrite*a+s.input*2*o)/1e6,t.cost.total=t.cost.input+t.cost.output+t.cost.cacheRead+t.cost.cacheWrite,t.cost.totalFromProvider=!1,t.cost}i(Jq,"calculateCost");var Yo=["off","minimal","low","medium","high","xhigh","max"];function Xq(e){return e.reasoning?Yo.filter(t=>{let r=e.thinkingLevelMap?.[t];return r===null?!1:t==="xhigh"||t==="max"?r!==void 0:!0}):["off"]}i(Xq,"getSupportedThinkingLevels");function Yq(e,t){let r=Xq(e);if(r.includes(t))return t;let s=Yo.indexOf(t);if(s===-1)return r[0]??"off";for(let n=s;n<Yo.length;n++){let o=Yo[n];if(r.includes(o))return o}for(let n=s-1;n>=0;n--){let o=Yo[n];if(r.includes(o))return o}return r[0]??"off"}i(Yq,"clampThinkingLevel");var Qq=4e3;function Zq(e){if(!(e instanceof Error))return{message:GS(e),messageCarriesBody:!1};let t=e,r=r9(t),s=i9(t),n=s===void 0||e.message.includes(s),o=r===void 0&&s===void 0?t9(e):e.message;return{status:r,body:s,message:o,messageCarriesBody:n}}i(Zq,"normalizeProviderError");var e9=5;function t9(e){let t,r=e.cause;for(let o=0;o<e9&&r instanceof Error;o++)t=r,r=r.cause;if(!t)return e.message;let s=(t.message||t.name).trim(),n=t.code;return(typeof n=="string"||typeof n=="number")&&!s.includes(String(n))&&(s=s?`${s} (${n})`:String(n)),!s||e.message.includes(s)?e.message:e.message?`${e.message}: ${s}`:s}i(t9,"withCauseDetail");function r9(e){if(typeof e.statusCode=="number")return e.statusCode;if(typeof e.status=="number")return e.status;if(typeof e.$metadata?.httpStatusCode=="number")return e.$metadata.httpStatusCode;if(typeof e.$response?.statusCode=="number")return e.$response.statusCode}i(r9,"extractStatus");function i9(e){let t=s9(e);if(t===void 0)return;let r=t.trim();if(r.length!==0)return o9(r,Qq)}i(i9,"extractBody");function s9(e){if(typeof e.body=="string")return e.body;if(lD(e.error))return GS(e.error);let t=e.$response?.body;if(typeof t=="string")return t;if(!n9(t)&&lD(t))return GS(t)}i(s9,"pickBodyText");function n9(e){return typeof e=="object"&&e!==null&&"pipe"in e&&typeof e.pipe=="function"}i(n9,"isReadableStreamLike");function lD(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return t!==Object.prototype&&t!==null?!1:Object.keys(e).length>0}i(lD,"isPlainNonEmptyObject");function o9(e,t){return e.length<=t?e:`${Hq(e,0,t)}... [truncated ${e.length-t} chars]`}i(o9,"truncateErrorText");function GS(e){try{let t=JSON.stringify(e);return t===void 0?String(e):t}catch{return String(e)}}i(GS,"safeJsonStringify");function a9(...e){let t=new Map;for(let r of e)for(let[s,n]of Object.entries(r??{})){let o=s.toLowerCase();t.delete(o),n!==null&&t.set(o,[s,n])}return t.size>0?Object.fromEntries(t.values()):void 0}i(a9,"providerHeadersToRecord");var Jd=null;function l9(e){if(!(typeof process>"u"||!process.versions?.bun||Object.keys(process.env).length>0)){if(Jd===null){Jd=new Map;try{let{readFileSync:t}=je("node:fs"),r=t("/proc/self/environ","utf-8");for(let s of r.split("\0")){let n=s.indexOf("=");n>0&&Jd.set(s.slice(0,n),s.slice(n+1))}}catch{}}return Jd.get(e)}}i(l9,"getBunSandboxEnvValue");function Rt(e,t){return t?.[e]||(typeof process<"u"?process.env[e]:void 0)||l9(e)||void 0}i(Rt,"getProviderEnvValue");var d9={ftp:21,gopher:70,http:80,https:443,ws:80,wss:443};function HS(e,t){let r=e.toLowerCase(),s=e.toUpperCase();return t?.[r]||t?.[s]||Rt(r)||Rt(s)||""}i(HS,"getProxyEnv");function c9(e){if(e instanceof URL)return e;try{return new URL(e)}catch{return}}i(c9,"parseProxyTargetUrl");function zS(e){return e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e}i(zS,"stripBrackets");function u9(e){let t=e.trim().toLowerCase();if(!t)return;if(t.startsWith("[")){let s=t.indexOf("]");if(s!==-1){let n=t.slice(1,s),o=t.slice(s+1);if(o.startsWith(":")){let a=Number.parseInt(o.slice(1),10);return{host:n,port:Number.isNaN(a)?0:a}}return{host:n,port:0}}}if(t.includes(":")&&t.split(":").length>2)return{host:t,port:0};let r=t.lastIndexOf(":");if(r!==-1&&r===t.indexOf(":")){let s=t.slice(0,r),n=Number.parseInt(t.slice(r+1),10);if(!Number.isNaN(n))return{host:s,port:n}}return{host:t,port:0}}i(u9,"parseNoProxyEntry");function h9(e,t,r){let s=HS("no_proxy",r).toLowerCase();if(!s)return!0;if(s==="*")return!1;let n=zS(e.toLowerCase());return s.split(/[,\s]/).every(o=>{let a=u9(o);if(!a||a.port&&a.port!==t)return!0;let l=zS(a.host);return l.startsWith("*.")?l=l.slice(2):(l.startsWith(".")||l.startsWith("*"))&&(l=l.slice(1)),l?!(n===l||n.endsWith(`.${l}`)):!0})}i(h9,"shouldProxyHostname");function m9(e,t){let r=c9(e);if(!r?.protocol||!r.host)return"";let s=r.protocol.split(":",1)[0],n=zS(r.hostname||r.host.replace(/:\d*$/,"")),o=Number.parseInt(r.port,10)||d9[s]||0;if(!h9(n,o,t))return"";let a=HS(`${s}_proxy`,t)||HS("all_proxy",t);return a&&!a.includes("://")&&(a=`${s}://${a}`),a}i(m9,"getProxyForUrl");var f9="Unsupported proxy protocol. SOCKS and PAC proxy URLs are not supported; use an HTTP or HTTPS proxy URL.";function p9(e,t){let r=m9(e,t);if(!r)return;let s;try{s=new URL(r)}catch(n){throw new Error(`Invalid proxy URL ${JSON.stringify(r)}: ${n instanceof Error?n.message:String(n)}`)}if(s.protocol!=="http:"&&s.protocol!=="https:")throw new Error(`${f9} Got ${s.protocol}`);return s}i(p9,"resolveHttpProxyUrlForTarget");function WS(e){return e.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,"")}i(WS,"sanitizeSurrogates");var L7=ve(Cq(),1),g9=new Set(['"',"\\","/","b","f","n","r","t"]);function y9(e){let t=e.codePointAt(0);return t!==void 0&&t>=0&&t<=31}i(y9,"isControlCharacter");function S9(e){switch(e){case"\b":return"\\b";case"\f":return"\\f";case`
82
82
  `:return"\\n";case"\r":return"\\r";case" ":return"\\t";default:return`\\u${e.codePointAt(0)?.toString(16).padStart(4,"0")??"0000"}`}}i(S9,"escapeControlCharacter");function _9(e){let t="",r=!1;for(let s=0;s<e.length;s++){let n=e[s];if(!r){t+=n,n==='"'&&(r=!0);continue}if(n==='"'){t+=n,r=!1;continue}if(n==="\\"){let o=e[s+1];if(o===void 0){t+="\\\\";continue}if(o==="u"){let a=e.slice(s+2,s+6);if(/^[0-9a-fA-F]{4}$/.test(a)){t+=`\\u${a}`,s+=5;continue}}if(g9.has(o)){t+=`\\${o}`,s+=1;continue}t+="\\\\";continue}t+=y9(n)?S9(n):n}return t}i(_9,"repairJson");function E9(e){try{return JSON.parse(e)}catch(t){let r=_9(e);if(r!==e)return JSON.parse(r);throw t}}i(E9,"parseJsonWithRepair");function w9(e){if(!e?.trim())return{arguments:{}};try{let t=E9(e);if(typeof t!="object"||t===null||Array.isArray(t))throw new Error("Tool arguments must be a JSON object");return{arguments:t}}catch(t){return{arguments:{},argumentsError:`${t instanceof Error?t.message:String(t)}
@@ -1,4 +1,4 @@
1
- var Le=Object.defineProperty;var a=(e,t)=>Le(e,"name",{value:t,configurable:!0});import{createRequire as Ie}from"node:module";const Dr=Ie(import.meta.url);import{DEFAULT_MAX_AGENT_RETRY_DELAY_MS as De,typebox_exports as T}from"./chunk-3YGHTGYM.js";import{fill as E,sanitizeBinaryOutput as Pe}from"./chunk-SE42OS3U.js";import{CodeHighlighter as Fe,Container as V,Spacer as I,Text as $,getCapabilities as Y,getImageDimensions as je,hyperlink as We,imageFallback as Be,keyHint as K,truncateToWidth as Ue}from"./chunk-EH7SFF47.js";import{getDocsPath as He,resolvePath as Ge,shortenHomePath as Je}from"./chunk-R47JBGS3.js";import{t as g}from"./chunk-XRF4A4KI.js";import{createWriteStream as ze}from"node:fs";import{writeFile as qe}from"node:fs/promises";import{randomBytes as Xe}from"node:crypto";import{lstatSync as Ze,mkdtempSync as Ve,readdirSync as Ye,rmSync as Q}from"node:fs";import{tmpdir as D}from"node:os";import{join as P}from"node:path";var Ke=1440*60*1e3,Qe=10080*60*1e3,et=/^(?:dal-(?:sandbox|bg|bash|powershell|output|mxc)|pi-codemode|pi-mcp)-(\d+)-/,tt=/^(?:dal-(?:sandbox|mxc)-[A-Za-z0-9]{6}|(?:dal-(?:bash|powershell|output)|pi-codemode|pi-mcp)-[0-9a-f]{16}(?:\.[A-Za-z0-9]+)?)$/,O=new Set,ee=!1;function te(e){try{Q(e,{recursive:!0,force:!0})}catch{}}a(te,"removePath");function rt(){for(let e of O)te(e);O.clear()}a(rt,"cleanupOwnedTempFiles");function nt(){ee||(ee=!0,process.on("exit",rt))}a(nt,"installExitHook");function F(e){nt(),O.add(e)}a(F,"registerTempPath");function it(e){O.delete(e),te(e)}a(it,"removeTempPath");function ot(e){let t=Ve(P(D(),`dal-${e}-${process.pid}-`));return F(t),t}a(ot,"createTempDir");function at(e,t,r=D()){return P(r,`${e}-${process.pid}-${Xe(8).toString("hex")}${t}`)}a(at,"tempFilePath");function st(e){if(e===process.pid)return!0;try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}a(st,"processExists");function lt(e={}){let t=e.dir??D(),r=e.now??Date.now(),n=e.maxAgeMs??Ke,i=e.legacyMaxAgeMs??Qe,o=e.exists??st,s=process.getuid?.(),c={removed:[],kept:0},l;try{l=Ye(t)}catch{return c}for(let p of l){let d=et.exec(p),u=!d&&tt.test(p);if(!d&&!u)continue;let m=P(t,p);try{let f=Ze(m);if(s!==void 0&&f.uid!==s)continue;if(!(r-f.mtimeMs>=(d?n:i))||d&&o(Number(d[1]))){c.kept++;continue}Q(m,{recursive:!0,force:!0}),c.removed.push(m)}catch{}}return c}a(lt,"sweepStaleTempFiles");var re=384,C;function ut(e){return C=e,()=>{C===e&&(C=void 0)}}a(ut,"setOutputFileDirectory");function ne(e,t){let r=C?.(),n=at(e,t,r);return r||F(n),n}a(ne,"createOutputFilePath");async function ct(e,t,r){let n=ne(e,t);return await qe(n,r,{mode:re,flag:"wx"}),n}a(ct,"writeOutputFile");function dt(e,t){let r=ne(e,t);return{path:r,stream:ze(r,{mode:re,flags:"wx"})}}a(dt,"createOutputFileStream");function ie(){return{input:0,output:0,cacheRead:0,cacheWrite:0,cost:0}}a(ie,"createUsageTotals");function oe(e,t){e.input+=t.input,e.output+=t.output,e.cacheRead+=t.cacheRead,e.cacheWrite+=t.cacheWrite,e.cost+=t.cost.total}a(oe,"addUsageToTotals");function pt(e,t){return{input:e.input+t.input,output:e.output+t.output,cacheRead:e.cacheRead+t.cacheRead,cacheWrite:e.cacheWrite+t.cacheWrite,...e.cacheWrite1h!==void 0||t.cacheWrite1h!==void 0?{cacheWrite1h:(e.cacheWrite1h??0)+(t.cacheWrite1h??0)}:{},...e.reasoning!==void 0||t.reasoning!==void 0?{reasoning:(e.reasoning??0)+(t.reasoning??0)}:{},totalTokens:e.totalTokens+t.totalTokens,cost:{input:e.cost.input+t.cost.input,output:e.cost.output+t.cost.output,cacheRead:e.cost.cacheRead+t.cost.cacheRead,cacheWrite:e.cost.cacheWrite+t.cost.cacheWrite,total:e.cost.total+t.cost.total,totalFromProvider:e.cost.totalFromProvider===!0&&t.cost.totalFromProvider===!0}}}a(pt,"combineUsage");function mt(e){let t=new Map;for(let r of e){let n,i;if(r.type==="message"&&r.message.role==="assistant"?(n=`${r.message.provider}/${r.message.responseModel??r.message.model}`,i=r.message.usage):r.type==="usage"?(n=`${r.provider}/${r.model}`,i=r.usage):r.type==="message"&&r.message.role==="toolResult"&&r.message.usage?(n="Tools/summaries",i=r.message.usage):(r.type==="branch_summary"||r.type==="compaction")&&r.usage&&(n="Tools/summaries",i=r.usage),!n||!i)continue;let o=t.get(n);o||(o=ie(),t.set(n,o)),oe(o,i)}return Array.from(t,([r,n])=>({key:r,cost:n.cost,tokens:n.input+n.output+n.cacheRead+n.cacheWrite})).filter(r=>r.cost>0||r.tokens>0).sort((r,n)=>n.cost-r.cost)}a(mt,"getUsageCostBreakdown");function ae(e,t,r,n=0,i="end"){if(!e)return{visualLines:[],skippedCount:0};let o=new $(e,n,0).render(r);if(o.length<=t)return{visualLines:o,skippedCount:0};let s=i==="start"?o.slice(0,t):o.slice(-t),c=o.length-t;return{visualLines:s,skippedCount:c}}a(ae,"truncateToVisualLines");var j=class{static{a(this,"VisualLinePreview")}options;cachedWidth;cachedLines;constructor(e){this.options=e}render(e){if(this.cachedLines===void 0||this.cachedWidth!==e){let{text:t,maxVisualLines:r,keep:n,formatHint:i}=this.options,o=ae(t,r,e,0,n),s=o.visualLines;if(o.skippedCount>0){let c=Ue(i(o.skippedCount),e,"...");this.cachedLines=n==="start"?[...s,c]:[c,...s]}else this.cachedLines=s;this.cachedWidth=e}return this.cachedLines}invalidate(){this.cachedWidth=void 0,this.cachedLines=void 0}};import{pathToFileURL as ft}from"node:url";var gt="(?:\\u0007|\\u001B\\u005C|\\u009C)",se="\\u001B\\]",le="(?:(?:\\u001B\\[|\\u009B)[<=>]|[\\u001B\\u009B][[\\]()#;?]*)(?:\\d{1,4}(?:[;:]\\d{0,4})*)?",ht="[\\dA-PR-TZcf-nq-uy=><~]",yt=new RegExp(`(?:${se}[\\s\\S]*?${gt})|${le}${ht}`,"g"),St=new RegExp(`(?:${se}(?:[^\\u0007\\u009C\\u001B]|\\u001B(?!\\\\))*|${le})$`),At=256;function $t(e){if(!e.includes("\x1B")&&!e.includes("\x9B"))return{complete:e,pending:""};let t=Math.max(0,e.length-At),r=St.exec(e.slice(t));if(!r)return{complete:e,pending:""};let n=t+r.index;return{complete:e.slice(0,n),pending:e.slice(n)}}a($t,"splitIncompleteAnsiSuffix");function ue(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return!e.includes("\x1B")&&!e.includes("\x9B")?e:e.replace(yt,"")}a(ue,"stripAnsi");function ce(e){return typeof e!="string"?"":Je(e)}a(ce,"shortenPath");function Tt(e,t,r){if(!Y().hyperlinks)return e;let n=Ge(t,r);return We(e,ft(n).href)}a(Tt,"linkPath");function de(e){return typeof e=="string"?e:e==null?"":null}a(de,"str");function pe(e){return typeof e=="string"&&e.trim()!==""&&(e=Number(e)),typeof e=="number"&&Number.isFinite(e)?e:void 0}a(pe,"parseLineNumber");function wt(e,t){if(e==null&&t==null)return"";let r=e==null?1:pe(e);if(r===void 0)return"";if(t==null)return`:${r}`;let n=pe(t);if(n===void 0)return"";let i=r+n-1;return`:${r}${i?`-${i}`:""}`}a(wt,"formatReadLineRange");function k(e){return e.replace(/\t/g," ")}a(k,"replaceTabs");function vt(e){return e.replace(/\r/g,"")}a(vt,"normalizeDisplayText");function me(e,t){if(!e)return"";let r=e.content.filter(s=>s.type==="text"),n=e.content.filter(s=>s.type==="image"),i=r.map(s=>Pe(ue(s.text||"")).replace(/\r/g,"")).join(`
1
+ var Le=Object.defineProperty;var a=(e,t)=>Le(e,"name",{value:t,configurable:!0});import{createRequire as Ie}from"node:module";const Dr=Ie(import.meta.url);import{DEFAULT_MAX_AGENT_RETRY_DELAY_MS as De,typebox_exports as T}from"./chunk-3YGHTGYM.js";import{fill as E,sanitizeBinaryOutput as Pe}from"./chunk-SE42OS3U.js";import{CodeHighlighter as Fe,Container as V,Spacer as I,Text as $,getCapabilities as Y,getImageDimensions as je,hyperlink as We,imageFallback as Be,keyHint as K,truncateToWidth as Ue}from"./chunk-AL3DFAIM.js";import{getDocsPath as He,resolvePath as Ge,shortenHomePath as Je}from"./chunk-R47JBGS3.js";import{t as g}from"./chunk-SZZVJTVX.js";import{createWriteStream as ze}from"node:fs";import{writeFile as qe}from"node:fs/promises";import{randomBytes as Xe}from"node:crypto";import{lstatSync as Ze,mkdtempSync as Ve,readdirSync as Ye,rmSync as Q}from"node:fs";import{tmpdir as D}from"node:os";import{join as P}from"node:path";var Ke=1440*60*1e3,Qe=10080*60*1e3,et=/^(?:dal-(?:sandbox|bg|bash|powershell|output|mxc)|pi-codemode|pi-mcp)-(\d+)-/,tt=/^(?:dal-(?:sandbox|mxc)-[A-Za-z0-9]{6}|(?:dal-(?:bash|powershell|output)|pi-codemode|pi-mcp)-[0-9a-f]{16}(?:\.[A-Za-z0-9]+)?)$/,O=new Set,ee=!1;function te(e){try{Q(e,{recursive:!0,force:!0})}catch{}}a(te,"removePath");function rt(){for(let e of O)te(e);O.clear()}a(rt,"cleanupOwnedTempFiles");function nt(){ee||(ee=!0,process.on("exit",rt))}a(nt,"installExitHook");function F(e){nt(),O.add(e)}a(F,"registerTempPath");function it(e){O.delete(e),te(e)}a(it,"removeTempPath");function ot(e){let t=Ve(P(D(),`dal-${e}-${process.pid}-`));return F(t),t}a(ot,"createTempDir");function at(e,t,r=D()){return P(r,`${e}-${process.pid}-${Xe(8).toString("hex")}${t}`)}a(at,"tempFilePath");function st(e){if(e===process.pid)return!0;try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}a(st,"processExists");function lt(e={}){let t=e.dir??D(),r=e.now??Date.now(),n=e.maxAgeMs??Ke,i=e.legacyMaxAgeMs??Qe,o=e.exists??st,s=process.getuid?.(),c={removed:[],kept:0},l;try{l=Ye(t)}catch{return c}for(let p of l){let d=et.exec(p),u=!d&&tt.test(p);if(!d&&!u)continue;let m=P(t,p);try{let f=Ze(m);if(s!==void 0&&f.uid!==s)continue;if(!(r-f.mtimeMs>=(d?n:i))||d&&o(Number(d[1]))){c.kept++;continue}Q(m,{recursive:!0,force:!0}),c.removed.push(m)}catch{}}return c}a(lt,"sweepStaleTempFiles");var re=384,C;function ut(e){return C=e,()=>{C===e&&(C=void 0)}}a(ut,"setOutputFileDirectory");function ne(e,t){let r=C?.(),n=at(e,t,r);return r||F(n),n}a(ne,"createOutputFilePath");async function ct(e,t,r){let n=ne(e,t);return await qe(n,r,{mode:re,flag:"wx"}),n}a(ct,"writeOutputFile");function dt(e,t){let r=ne(e,t);return{path:r,stream:ze(r,{mode:re,flags:"wx"})}}a(dt,"createOutputFileStream");function ie(){return{input:0,output:0,cacheRead:0,cacheWrite:0,cost:0}}a(ie,"createUsageTotals");function oe(e,t){e.input+=t.input,e.output+=t.output,e.cacheRead+=t.cacheRead,e.cacheWrite+=t.cacheWrite,e.cost+=t.cost.total}a(oe,"addUsageToTotals");function pt(e,t){return{input:e.input+t.input,output:e.output+t.output,cacheRead:e.cacheRead+t.cacheRead,cacheWrite:e.cacheWrite+t.cacheWrite,...e.cacheWrite1h!==void 0||t.cacheWrite1h!==void 0?{cacheWrite1h:(e.cacheWrite1h??0)+(t.cacheWrite1h??0)}:{},...e.reasoning!==void 0||t.reasoning!==void 0?{reasoning:(e.reasoning??0)+(t.reasoning??0)}:{},totalTokens:e.totalTokens+t.totalTokens,cost:{input:e.cost.input+t.cost.input,output:e.cost.output+t.cost.output,cacheRead:e.cost.cacheRead+t.cost.cacheRead,cacheWrite:e.cost.cacheWrite+t.cost.cacheWrite,total:e.cost.total+t.cost.total,totalFromProvider:e.cost.totalFromProvider===!0&&t.cost.totalFromProvider===!0}}}a(pt,"combineUsage");function mt(e){let t=new Map;for(let r of e){let n,i;if(r.type==="message"&&r.message.role==="assistant"?(n=`${r.message.provider}/${r.message.responseModel??r.message.model}`,i=r.message.usage):r.type==="usage"?(n=`${r.provider}/${r.model}`,i=r.usage):r.type==="message"&&r.message.role==="toolResult"&&r.message.usage?(n="Tools/summaries",i=r.message.usage):(r.type==="branch_summary"||r.type==="compaction")&&r.usage&&(n="Tools/summaries",i=r.usage),!n||!i)continue;let o=t.get(n);o||(o=ie(),t.set(n,o)),oe(o,i)}return Array.from(t,([r,n])=>({key:r,cost:n.cost,tokens:n.input+n.output+n.cacheRead+n.cacheWrite})).filter(r=>r.cost>0||r.tokens>0).sort((r,n)=>n.cost-r.cost)}a(mt,"getUsageCostBreakdown");function ae(e,t,r,n=0,i="end"){if(!e)return{visualLines:[],skippedCount:0};let o=new $(e,n,0).render(r);if(o.length<=t)return{visualLines:o,skippedCount:0};let s=i==="start"?o.slice(0,t):o.slice(-t),c=o.length-t;return{visualLines:s,skippedCount:c}}a(ae,"truncateToVisualLines");var j=class{static{a(this,"VisualLinePreview")}options;cachedWidth;cachedLines;constructor(e){this.options=e}render(e){if(this.cachedLines===void 0||this.cachedWidth!==e){let{text:t,maxVisualLines:r,keep:n,formatHint:i}=this.options,o=ae(t,r,e,0,n),s=o.visualLines;if(o.skippedCount>0){let c=Ue(i(o.skippedCount),e,"...");this.cachedLines=n==="start"?[...s,c]:[c,...s]}else this.cachedLines=s;this.cachedWidth=e}return this.cachedLines}invalidate(){this.cachedWidth=void 0,this.cachedLines=void 0}};import{pathToFileURL as ft}from"node:url";var gt="(?:\\u0007|\\u001B\\u005C|\\u009C)",se="\\u001B\\]",le="(?:(?:\\u001B\\[|\\u009B)[<=>]|[\\u001B\\u009B][[\\]()#;?]*)(?:\\d{1,4}(?:[;:]\\d{0,4})*)?",ht="[\\dA-PR-TZcf-nq-uy=><~]",yt=new RegExp(`(?:${se}[\\s\\S]*?${gt})|${le}${ht}`,"g"),St=new RegExp(`(?:${se}(?:[^\\u0007\\u009C\\u001B]|\\u001B(?!\\\\))*|${le})$`),At=256;function $t(e){if(!e.includes("\x1B")&&!e.includes("\x9B"))return{complete:e,pending:""};let t=Math.max(0,e.length-At),r=St.exec(e.slice(t));if(!r)return{complete:e,pending:""};let n=t+r.index;return{complete:e.slice(0,n),pending:e.slice(n)}}a($t,"splitIncompleteAnsiSuffix");function ue(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return!e.includes("\x1B")&&!e.includes("\x9B")?e:e.replace(yt,"")}a(ue,"stripAnsi");function ce(e){return typeof e!="string"?"":Je(e)}a(ce,"shortenPath");function Tt(e,t,r){if(!Y().hyperlinks)return e;let n=Ge(t,r);return We(e,ft(n).href)}a(Tt,"linkPath");function de(e){return typeof e=="string"?e:e==null?"":null}a(de,"str");function pe(e){return typeof e=="string"&&e.trim()!==""&&(e=Number(e)),typeof e=="number"&&Number.isFinite(e)?e:void 0}a(pe,"parseLineNumber");function wt(e,t){if(e==null&&t==null)return"";let r=e==null?1:pe(e);if(r===void 0)return"";if(t==null)return`:${r}`;let n=pe(t);if(n===void 0)return"";let i=r+n-1;return`:${r}${i?`-${i}`:""}`}a(wt,"formatReadLineRange");function k(e){return e.replace(/\t/g," ")}a(k,"replaceTabs");function vt(e){return e.replace(/\r/g,"")}a(vt,"normalizeDisplayText");function me(e,t){if(!e)return"";let r=e.content.filter(s=>s.type==="text"),n=e.content.filter(s=>s.type==="image"),i=r.map(s=>Pe(ue(s.text||"")).replace(/\r/g,"")).join(`
2
2
  `),o=Y();if(n.length>0&&(!o.images||!t)){let s=n.map(c=>{let l=c.mimeType??"image/unknown",p=c.data&&c.mimeType?je(c.data,c.mimeType)??void 0:void 0;return Be(l,p)}).join(`
3
3
  `);i=i?`${i}
4
4
  ${s}`:s}return i}a(me,"getTextOutput");var fe=100;function _t(e,t,r,n){let i=r.fg("toolTitle",r.bold(e));if(t==null)return i;let o=typeof t=="object"&&!Array.isArray(t)?Object.entries(t):[["args",t]];if(o.length===0)return i;if(n){let l=o.map(([p,d])=>{let u=typeof d=="string"?d:JSON.stringify(d,null,2)??String(d);return` ${p}: ${k(u).replace(/\r/g,"").split(`
@@ -31,7 +31,7 @@ Searches over deferred tool metadata with BM25 and exposes matching tools for th
31
31
 
32
32
  Some of the tools, such as tools of MCP servers, may not have been provided to you upfront, and you should use this tool (\`${w}\`) to search for the required tools. For MCP tool discovery, always use \`${w}\`.`;function or(e={}){return{name:w,label:w,description:ir,promptSnippet:"Search for tools that are not loaded yet and load the matches",parameters:tr,exposure:"model-only",reachesTools:a(()=>"all","reachesTools"),async execute(t,{query:r,limit:n}){if(r.trim()==="")throw new Error("query must not be empty");let i=n??U;if(!Number.isInteger(i)||i<=0)throw new Error("limit must be a positive integer");let o=e.tools?nr(e.tools,r,i):[];return{content:[{type:"text",text:o.length===0?"No matching tools found.":`Loaded ${o.length} tool${o.length===1?"":"s"}. They are available from your next call:
33
33
  ${o.map(s=>`- ${s.name}: ${s.description.trim().split(/\r?\n/)[0]}`).join(`
34
- `)}`}],details:{loaded:o.map(s=>s.name)}}}}}a(or,"createToolSearchToolDefinition");import{join as ar}from"node:path";var G={transport:"auto",sessionShareDestination:"auto",steeringMode:"one-at-a-time",followUpMode:"one-at-a-time",compaction:{enabled:!0,reserveTokens:16384,keepRecentTokens:2e4},branchSummary:{reserveTokens:16384,skipPrompt:!1},retry:{enabled:!0,maxRetries:3,baseDelayMs:2e3,maxAgentDelayMs:De,provider:{maxRetryDelayMs:6e4}},hideThinkingBlock:!1,showCacheMissNotices:!1,quietStartup:!1,defaultProjectTrust:"ask",collapseChangelog:!1,enableInstallTelemetry:!0,enableAnalytics:!1,enableSkillCommands:!0,terminal:{showImages:!0,imageWidthCells:60,clearOnShrink:!1,showTerminalProgress:!1},images:{autoResize:!0,blockImages:!1},doubleEscapeAction:"tree",treeFilterMode:"default",editorPaddingX:0,outputPad:1,autocompleteMaxVisible:5,markdown:{codeBlockIndent:" ",mermaid:"streaming"},warnings:{anthropicExtraUsage:!0},codemode:{mode:"on",inlineBudget:3e3},cacheWarming:"idle",tuiMode:"fullscreen",fullscreenExitOutput:"transcript",fullscreenScrollbar:"auto",fullscreenCopyOnSelect:!0,fullscreenWheelScrollLines:"auto"};function sr(e,t){return{name:e.name,label:e.label,description:e.description,parameters:e.parameters,outputSchema:e.outputSchema,constrainedSampling:e.constrainedSampling,prepareArguments:e.prepareArguments,executionMode:e.executionMode,executionModeFor:e.executionModeFor,execute:a((r,n,i,o,s)=>e.execute(r,n,i,o,s??t?.(r,i)),"execute")}}a(sr,"wrapToolDefinition");function lr(e){return{name:e.name,label:e.label,description:e.description,parameters:e.parameters,outputSchema:e.outputSchema,constrainedSampling:e.constrainedSampling,prepareArguments:e.prepareArguments,executionMode:e.executionMode,executionModeFor:e.executionModeFor,execute:a(async(t,r,n,i)=>e.execute(t,r,n,i),"execute")}}a(lr,"createToolDefinitionFromAgentTool");var ur=a(()=>import("./execute-6PNQ63VS.js"),"loadCodemodeExecutor"),cr=10,dr=8,pr=5,Oe=80,mr=/^Script (completed|failed)\nWall time [\d.]+ seconds\nOutput:\n$/;function Ce(e,t){return`${e.fg("muted",E(g("\u2026\uFF08\u8FD8\u6709 {count} \u884C\uFF0C"),{count:t}))}${K("app.tools.expand",g("\u5C55\u5F00"))}${e.fg("muted",g("\uFF09"))}`}a(Ce,"expandHint");function fr(e){return e===void 0?"":e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}a(fr,"formatDuration");function ke(e){return`$${e>=.01?e.toFixed(2):e.toPrecision(2)}`}a(ke,"formatCost");function gr(e,t){switch(e.status){case"running":return t.fg("warning","\u2026");case"ok":return t.fg("success","\u2713");case"error":return t.fg("error","\u2717");case"cancelled":return t.fg("muted","\u2298")}}a(gr,"statusIcon");function hr(e,t,r){let n=!r&&e.args.length>Oe?`${e.args.slice(0,Oe-3)}...`:e.args,i=fr(e.durationMs),o=`${gr(e,t)} ${t.fg("toolTitle",e.name)}`;return n&&(o+=` ${t.fg("muted",n)}`),i&&(o+=` ${t.fg("dim",i)}`),e.cost&&(o+=` ${t.fg("dim",ke(e.cost))}`),r&&e.error&&(o+=`
34
+ `)}`}],details:{loaded:o.map(s=>s.name)}}}}}a(or,"createToolSearchToolDefinition");import{join as ar}from"node:path";var G={transport:"auto",sessionShareDestination:"auto",steeringMode:"one-at-a-time",followUpMode:"one-at-a-time",compaction:{enabled:!0,reserveTokens:16384,keepRecentTokens:2e4},branchSummary:{reserveTokens:16384,skipPrompt:!1},retry:{enabled:!0,maxRetries:3,baseDelayMs:2e3,maxAgentDelayMs:De,provider:{maxRetryDelayMs:6e4}},hideThinkingBlock:!1,showCacheMissNotices:!1,quietStartup:!1,defaultProjectTrust:"ask",collapseChangelog:!1,enableInstallTelemetry:!0,enableAnalytics:!1,enableSkillCommands:!0,terminal:{showImages:!0,imageWidthCells:60,clearOnShrink:!1,showTerminalProgress:!1},images:{autoResize:!0,blockImages:!1},doubleEscapeAction:"tree",treeFilterMode:"default",editorPaddingX:0,outputPad:1,autocompleteMaxVisible:5,markdown:{codeBlockIndent:" ",mermaid:"streaming"},warnings:{anthropicExtraUsage:!0},codemode:{mode:"on",inlineBudget:3e3},cacheWarming:"idle",tuiMode:"fullscreen",fullscreenExitOutput:"transcript",fullscreenScrollbar:"auto",fullscreenCopyOnSelect:!0,fullscreenWheelScrollLines:"auto"};function sr(e,t){return{name:e.name,label:e.label,description:e.description,parameters:e.parameters,outputSchema:e.outputSchema,constrainedSampling:e.constrainedSampling,prepareArguments:e.prepareArguments,executionMode:e.executionMode,executionModeFor:e.executionModeFor,execute:a((r,n,i,o,s)=>e.execute(r,n,i,o,s??t?.(r,i)),"execute")}}a(sr,"wrapToolDefinition");function lr(e){return{name:e.name,label:e.label,description:e.description,parameters:e.parameters,outputSchema:e.outputSchema,constrainedSampling:e.constrainedSampling,prepareArguments:e.prepareArguments,executionMode:e.executionMode,executionModeFor:e.executionModeFor,execute:a(async(t,r,n,i)=>e.execute(t,r,n,i),"execute")}}a(lr,"createToolDefinitionFromAgentTool");var ur=a(()=>import("./execute-MGTKJB44.js"),"loadCodemodeExecutor"),cr=10,dr=8,pr=5,Oe=80,mr=/^Script (completed|failed)\nWall time [\d.]+ seconds\nOutput:\n$/;function Ce(e,t){return`${e.fg("muted",E(g("\u2026\uFF08\u8FD8\u6709 {count} \u884C\uFF0C"),{count:t}))}${K("app.tools.expand",g("\u5C55\u5F00"))}${e.fg("muted",g("\uFF09"))}`}a(Ce,"expandHint");function fr(e){return e===void 0?"":e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}a(fr,"formatDuration");function ke(e){return`$${e>=.01?e.toFixed(2):e.toPrecision(2)}`}a(ke,"formatCost");function gr(e,t){switch(e.status){case"running":return t.fg("warning","\u2026");case"ok":return t.fg("success","\u2713");case"error":return t.fg("error","\u2717");case"cancelled":return t.fg("muted","\u2298")}}a(gr,"statusIcon");function hr(e,t,r){let n=!r&&e.args.length>Oe?`${e.args.slice(0,Oe-3)}...`:e.args,i=fr(e.durationMs),o=`${gr(e,t)} ${t.fg("toolTitle",e.name)}`;return n&&(o+=` ${t.fg("muted",n)}`),i&&(o+=` ${t.fg("dim",i)}`),e.cost&&(o+=` ${t.fg("dim",ke(e.cost))}`),r&&e.error&&(o+=`
35
35
  ${t.fg("error",e.error.split(`
36
36
  `).join(`
37
37
  `))}`),o}a(hr,"formatCall");var yr={renderCall(e,t,r){bt(r);let n=de(e?.code),i=t.fg("toolTitle",t.bold("codemode")),o=r.lastComponent??new V;if(o.clear(),n===null)return o.addChild(new $(`${i} ${t.fg("error",g("[\u53C2\u6570\u65E0\u6548]"))}`,0,0)),o;if(o.addChild(new $(i,0,0)),n){let s=r.state;s.scriptHighlighter??=new Fe;let c=s.scriptHighlighter.highlight(k(n.replace(/\r/g,"").trimEnd()),"javascript").join(`
@@ -1 +1 @@
1
- var H=Object.defineProperty;var o=(e,r)=>H(e,"name",{value:r,configurable:!0});import{createRequire as U}from"node:module";const xe=U(import.meta.url);import{clampThinkingLevel as B}from"./chunk-K4B5ABCQ.js";import{getSystemMessageText as F}from"./chunk-SCYK4XNE.js";var d=class extends Error{static{o(this,"UnsupportedStrictJsonSchemaError")}},z=["$ref","$defs","definitions","allOf","oneOf","patternProperties","dependentSchemas","dependencies","unevaluatedProperties","propertyNames","contains","prefixItems","not","if","then","else"];function w(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}o(w,"isJsonSchemaObject");function K(e){if(!w(e))return!1;let r=typeof e.type=="string"?[e.type]:Array.isArray(e.type)?e.type:[];return r.includes("object")||r.includes("array")||e.properties!==void 0||e.items!==void 0}o(K,"isStructuredSchema");function O(e){return w(e)?e.type==="null"||Array.isArray(e.type)&&e.type.includes("null")||e.const===null||Array.isArray(e.enum)&&e.enum.includes(null)?!0:Array.isArray(e.anyOf)&&e.anyOf.some(r=>O(r)):!1}o(O,"schemaAllowsNull");function v(e,r){if(!w(e))throw new d("boolean schemas are unsupported");for(let s of z)if(e[s]!==void 0)throw new d(`${s} schemas are unsupported`);if(r){for(let[s,m]of Object.entries(e))if(r(s,m))throw new d(`${s}: ${JSON.stringify(m)} is unsupported`)}if(e.anyOf!==void 0){if(!Array.isArray(e.anyOf)||e.anyOf.length===0)throw new d("anyOf must contain at least one schema");for(let s of e.anyOf){if(K(s))throw new d("object and array unions are unsupported");v(s,r)}}if(e.items!==void 0){if(Array.isArray(e.items))throw new d("tuple schemas are unsupported");v(e.items,r)}let t=e.type==="object";if(e.properties!==void 0&&!t)throw new d("properties require type object");if(!t)return;if(e.additionalProperties!==void 0&&e.additionalProperties!==!1)throw new d("schema-valued or true additionalProperties is unsupported");if(e.properties!==void 0&&!w(e.properties))throw new d("object properties must be a schema map");if(e.required!==void 0&&(!Array.isArray(e.required)||e.required.some(s=>typeof s!="string")))throw new d("object required must be a string array");let n=e.properties??{},i=Object.keys(n),a=new Set(Array.isArray(e.required)?e.required:[]);if([...a].some(s=>!i.includes(s)))throw new d("required contains an unknown property");for(let[s,m]of Object.entries(n))v(m,r),!a.has(s)&&!O(m)&&(n[s]={anyOf:[m,{type:"null"}]});e.required=i,e.additionalProperties=!1}o(v,"makeJsonSchemaNodeStrict");function R(e,r){let t=structuredClone(e);if(!w(t))throw new d("root schema must have type object");if(v(t,r),t.type!=="object")throw new d("root schema must have type object");return t}o(R,"makeStrictJsonSchema");function Y(e){let r=e.constrainedSampling;return!!r&&r.type==="json_schema"&&r.strict==="prefer"}o(Y,"prefersJsonSchemaStrictSampling");function V(e,r){return r===!0?R(e.parameters):e.parameters}o(V,"getJsonSchemaToolParameters");function X(e,r,t){let n=r[t];if(typeof n!="string")throw new Error(`Grammar tool call "${e}" requires argument "${t}" to be a string.`);return n}o(X,"getGrammarToolInput");function Q(e,r,t){if(e.closed)throw new Error(`grammar tool input for property "${r}" changed after it was closed`);if(t.length!==0)return e.input+=t,_(e,r)+JSON.stringify(t).slice(1,-1)}o(Q,"appendGrammarToolInputJsonDelta");function Z(e,r,t){if(e.closed){if(t===void 0||t===e.input)return;throw new Error(`grammar tool input for property "${r}" changed after it was closed`)}if(t!==void 0&&!t.startsWith(e.input))throw new Error(`grammar tool input for property "${r}" changed non-monotonically`);let n=t===void 0?"":t.slice(e.input.length);return t!==void 0&&(e.input=t),e.closed=!0,`${_(e,r)}${JSON.stringify(n).slice(1,-1)}"}`}o(Z,"closeGrammarToolInputJson");function _(e,r){return e.started?"":(e.started=!0,`{${JSON.stringify(r)}:"`)}o(_,"grammarToolInputJsonStart");function ee(e){let r=e.parameters;if(r.type!=="object")throw new Error("grammar constrained sampling requires an object parameter schema");if(!Array.isArray(r.required)||r.required.length!==1||typeof r.required[0]!="string")throw new Error("grammar constrained sampling requires exactly one required string property");let t=r.required[0];if(!r.properties?.[t])throw new Error(`grammar constrained sampling requires a properties entry for ${t}`);if(r.properties[t]?.type!=="string")throw new Error(`grammar constrained sampling property ${t} must have type string`);return t}o(ee,"inferGrammarInputProperty");function te(e,r,t){let n=e.constrainedSampling;if(!(!n||n.type!=="json_schema")){if(r)try{return R(e.parameters,t),!0}catch(i){if(!(i instanceof d))throw i;if(n.strict!=="require")return;throw new Error(`Tool "${e.name}" requires JSON-schema constrained sampling, but ${i.message}.`)}if(n.strict==="require")throw new Error(`Tool "${e.name}" requires JSON-schema constrained sampling, but strict tools are unsupported.`)}}o(te,"resolveJsonSchemaStrictSampling");function N(e,r){let t=e.constrainedSampling;if(!t||t.type!=="grammar"||!r)return;let n=t.variants.openai_lark,i=t.variants.openai_regex,a=typeof n=="string"&&n.trim().length>0,s=typeof i=="string"&&i.trim().length>0;if(!a&&!s)throw new Error(`Tool "${e.name}" cannot use grammar constrained sampling: no supported grammar variant was provided.`);try{return{format:a?"lark":"regex",definition:a?n:i,inputProperty:ee(e)}}catch(m){let f=m instanceof Error?m.message:String(m);throw new Error(`Tool "${e.name}" cannot use grammar constrained sampling: ${f}.`)}}o(N,"resolveGrammarConstrainedSampling");function re(e,r){let t=new Map;for(let n of e??[]){let i=N(n,r);i&&t.set(n.name,i.inputProperty)}return t}o(re,"createGrammarToolInputProperties");var M=3.5,ne=4800;function C(e){return e.totalTokens||e.input+e.output+e.cacheRead+e.cacheWrite}o(C,"calculateContextTokens");function k(e){try{return JSON.stringify(e)??"undefined"}catch{return"[unserializable]"}}o(k,"safeJsonStringify");function ie(e){if(typeof e=="string")return e.length;let r=0;for(let t of e)r+=t.type==="text"?t.text.length:ne;return r}o(ie,"estimateTextAndImageContentChars");function P(e){return Math.ceil(e.length/M)}o(P,"estimateTextTokens");function oe(e){return Math.ceil(ie(e)/M)}o(oe,"estimateTextAndImageContentTokens");function q(e){let r=0;if(e.role==="system")return P(F(e))+$(e.toolsAdded)+$(e.toolsRemoved);if(e.role==="user"||e.role==="toolResult")return oe(e.content);for(let t of e.content)t.type==="text"?r+=t.text.length:t.type==="thinking"?r+=t.thinking.length:r+=t.name.length+k(t.arguments).length;return Math.ceil(r/M)}o(q,"estimateMessageTokens");function ae(e){let r=Number.NEGATIVE_INFINITY,t;for(let n=0;n<e.length;n++){let i=e[n];if(i.role==="assistant"){let a=i;a.timestamp>=r&&a.stopReason!=="aborted"&&a.stopReason!=="error"&&C(a.usage)>0&&(t={usage:a.usage,index:n})}r=Math.max(r,i.timestamp)}return t}o(ae,"getLastAssistantUsageInfo");function se(e){let r="messages"in e?e.messages:e,t=ae(r);if(t){let i=C(t.usage),a=0;for(let s=t.index+1;s<r.length;s++)a+=q(r[s]);return{tokens:i+a,usageTokens:i,trailingTokens:a,lastUsageIndex:t.index}}let n=0;for(let i of r)n+=q(i);return{tokens:n,usageTokens:0,trailingTokens:n,lastUsageIndex:null}}o(se,"estimateContextTokens");function $(e){return!e||e.length===0?0:P(k(e))}o($,"estimateToolsTokens");var j=4096,le=.15,J=32768,L=1;function b(e,r,t){if(e.contextWindow<=0)return Math.max(L,t);let n=se(r).tokens,i=Math.max(j,Math.ceil(n*le)),a=e.contextWindow-n-i;return a<J&&(a=Math.min(J,e.contextWindow-n-j)),Math.min(t,Math.max(L,a))}o(b,"clampMaxTokensToContext");function G(e,r,t){let n=B(e,r),i=e.samplingParamsByThinkingLevel?.[n];return e.samplingParams||i||t?{...e.samplingParams,...i,...t}:void 0}o(G,"resolveSamplingParams");function ue(e,r,t,n){let i=G(e,t?.reasoning??"off",t?.samplingParams);return{temperature:t?.temperature,samplingParams:i,maxTokens:b(e,r,t?.maxTokens??e.maxTokens),signal:t?.signal,telemetry:t?.telemetry,apiKey:n||t?.apiKey,fetch:t?.fetch,transport:t?.transport,cacheRetention:t?.cacheRetention,sessionId:t?.sessionId,disableContinuation:t?.disableContinuation,headers:t?.headers,identity:t?.identity,onPayload:t?.onPayload,onResponse:t?.onResponse,onProviderStreamEvent:t?.onProviderStreamEvent,timeoutMs:t?.timeoutMs,websocketConnectTimeoutMs:t?.websocketConnectTimeoutMs,maxRetries:t?.maxRetries,maxRetryDelayMs:t?.maxRetryDelayMs,metadata:t?.metadata,env:t?.env}}o(ue,"buildBaseOptions");var pe=1024,de={minimal:1024,low:2048,medium:8192,high:16384};function me(e){return e==="xhigh"||e==="max"?"high":e}o(me,"clampReasoning");function D(e,r){let t={...de,...r},n=me(e);return t[n]}o(D,"thinkingBudgetForLevel");function W(e,r){return Math.min(e,Math.max(0,r-pe))}o(W,"clampThinkingBudgetToAnswerRoom");function fe(e,r,t,n){let i=D(t,n),a=e===void 0?r:Math.min(e+i,r);return a<=i&&(i=W(i,a)),{maxTokens:a,thinkingBudget:i}}o(fe,"adjustMaxTokensForThinking");var ce="(image omitted: model does not support images)",ge="(tool image omitted: model does not support images)",he="(image attached after the tool results)";function ye(e){if(!e.isError)return;let r=e.content.filter(t=>t.type==="image");if(r.length!==0)return{content:I(e.content,he),caption:`Images from the error result of tool call ${e.toolCallId} (${e.toolName}):`,images:r}}o(ye,"splitErrorToolResultImages");function I(e,r){let t=[],n=!1;for(let i of e){if(i.type==="image"){n||t.push({type:"text",text:r}),n=!0;continue}t.push(i),n=i.text===r}return t}o(I,"replaceImagesWithPlaceholder");function we(e,r){return r.input.includes("image")?e:e.map(t=>t.role==="user"&&Array.isArray(t.content)?{...t,content:I(t.content,ce)}:t.role==="toolResult"?{...t,content:I(t.content,ge)}:t)}o(we,"downgradeUnsupportedImages");function Te(e,r){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.role==="assistant"&&!(n.provider!==r.provider||n.api!==r.api||n.model!==r.id)&&!(n.stopReason==="error"||n.stopReason==="aborted"))return n.responseModel}}o(Te,"latestAnsweringModel");function Se(e,r,t){let n=new Map,i=e.map(u=>u.content==null?{...u,content:[]}:u),a=we(i,r),s=Te(a,r),m=a.map(u=>{if(u.role==="system"||u.role==="user")return u;if(u.role==="toolResult"){let l=n.get(u.toolCallId);return l&&l!==u.toolCallId?{...u,toolCallId:l}:u}if(u.role==="assistant"){let l=u,c=l.provider===r.provider&&l.api===r.api&&l.model===r.id&&(s===void 0||l.responseModel===void 0||l.responseModel===s),S=l.content.flatMap(p=>{if(p.type==="thinking")return c?p.redacted||p.thinkingSignature?p:!p.thinking||p.thinking.trim()===""?[]:p:[];if(p.type==="text")return c?p:{type:"text",text:p.text};if(p.type==="toolCall"){let g=p,y=g;if(!c&&g.thoughtSignature&&(y={...g},delete y.thoughtSignature),!c&&t){let A=t(g.id,r,l);A!==g.id&&(n.set(g.id,A),y={...y,id:A})}return y}return p});return{...l,content:S}}return u}),f=[],h=[],T=new Set,E=[],x=o(()=>{if(h.length>0){for(let u of h)T.has(u.id)||f.push({role:"toolResult",toolCallId:u.id,toolName:u.name,content:[{type:"text",text:"No result provided"}],isError:!0,timestamp:Date.now()});h=[],T=new Set}f.push(...E),E.length=0},"closePendingToolCalls");for(let u=0;u<m.length;u++){let l=m[u];if(l.role==="assistant"){x();let c=l;if(c.stopReason==="error"||c.stopReason==="aborted")continue;let S=c.content.filter(p=>p.type==="toolCall");S.length>0&&(h=S,T=new Set),f.push(l)}else l.role==="toolResult"?(T.add(l.toolCallId),f.push(l)):l.role==="system"?h.length>0?E.push(l):f.push(l):(l.role==="user"&&x(),f.push(l))}return x(),f}o(Se,"transformMessages");export{fe as adjustMaxTokensForThinking,Q as appendGrammarToolInputJsonDelta,ue as buildBaseOptions,b as clampMaxTokensToContext,W as clampThinkingBudgetToAnswerRoom,Z as closeGrammarToolInputJson,re as createGrammarToolInputProperties,X as getGrammarToolInput,V as getJsonSchemaToolParameters,Y as prefersJsonSchemaStrictSampling,N as resolveGrammarConstrainedSampling,te as resolveJsonSchemaStrictSampling,G as resolveSamplingParams,ye as splitErrorToolResultImages,D as thinkingBudgetForLevel,Se as transformMessages};
1
+ var H=Object.defineProperty;var o=(e,r)=>H(e,"name",{value:r,configurable:!0});import{createRequire as U}from"node:module";const xe=U(import.meta.url);import{clampThinkingLevel as B}from"./chunk-BIY5HTFI.js";import{getSystemMessageText as F}from"./chunk-F37JXTCY.js";var d=class extends Error{static{o(this,"UnsupportedStrictJsonSchemaError")}},z=["$ref","$defs","definitions","allOf","oneOf","patternProperties","dependentSchemas","dependencies","unevaluatedProperties","propertyNames","contains","prefixItems","not","if","then","else"];function w(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}o(w,"isJsonSchemaObject");function K(e){if(!w(e))return!1;let r=typeof e.type=="string"?[e.type]:Array.isArray(e.type)?e.type:[];return r.includes("object")||r.includes("array")||e.properties!==void 0||e.items!==void 0}o(K,"isStructuredSchema");function O(e){return w(e)?e.type==="null"||Array.isArray(e.type)&&e.type.includes("null")||e.const===null||Array.isArray(e.enum)&&e.enum.includes(null)?!0:Array.isArray(e.anyOf)&&e.anyOf.some(r=>O(r)):!1}o(O,"schemaAllowsNull");function v(e,r){if(!w(e))throw new d("boolean schemas are unsupported");for(let s of z)if(e[s]!==void 0)throw new d(`${s} schemas are unsupported`);if(r){for(let[s,m]of Object.entries(e))if(r(s,m))throw new d(`${s}: ${JSON.stringify(m)} is unsupported`)}if(e.anyOf!==void 0){if(!Array.isArray(e.anyOf)||e.anyOf.length===0)throw new d("anyOf must contain at least one schema");for(let s of e.anyOf){if(K(s))throw new d("object and array unions are unsupported");v(s,r)}}if(e.items!==void 0){if(Array.isArray(e.items))throw new d("tuple schemas are unsupported");v(e.items,r)}let t=e.type==="object";if(e.properties!==void 0&&!t)throw new d("properties require type object");if(!t)return;if(e.additionalProperties!==void 0&&e.additionalProperties!==!1)throw new d("schema-valued or true additionalProperties is unsupported");if(e.properties!==void 0&&!w(e.properties))throw new d("object properties must be a schema map");if(e.required!==void 0&&(!Array.isArray(e.required)||e.required.some(s=>typeof s!="string")))throw new d("object required must be a string array");let n=e.properties??{},i=Object.keys(n),a=new Set(Array.isArray(e.required)?e.required:[]);if([...a].some(s=>!i.includes(s)))throw new d("required contains an unknown property");for(let[s,m]of Object.entries(n))v(m,r),!a.has(s)&&!O(m)&&(n[s]={anyOf:[m,{type:"null"}]});e.required=i,e.additionalProperties=!1}o(v,"makeJsonSchemaNodeStrict");function R(e,r){let t=structuredClone(e);if(!w(t))throw new d("root schema must have type object");if(v(t,r),t.type!=="object")throw new d("root schema must have type object");return t}o(R,"makeStrictJsonSchema");function Y(e){let r=e.constrainedSampling;return!!r&&r.type==="json_schema"&&r.strict==="prefer"}o(Y,"prefersJsonSchemaStrictSampling");function V(e,r){return r===!0?R(e.parameters):e.parameters}o(V,"getJsonSchemaToolParameters");function X(e,r,t){let n=r[t];if(typeof n!="string")throw new Error(`Grammar tool call "${e}" requires argument "${t}" to be a string.`);return n}o(X,"getGrammarToolInput");function Q(e,r,t){if(e.closed)throw new Error(`grammar tool input for property "${r}" changed after it was closed`);if(t.length!==0)return e.input+=t,_(e,r)+JSON.stringify(t).slice(1,-1)}o(Q,"appendGrammarToolInputJsonDelta");function Z(e,r,t){if(e.closed){if(t===void 0||t===e.input)return;throw new Error(`grammar tool input for property "${r}" changed after it was closed`)}if(t!==void 0&&!t.startsWith(e.input))throw new Error(`grammar tool input for property "${r}" changed non-monotonically`);let n=t===void 0?"":t.slice(e.input.length);return t!==void 0&&(e.input=t),e.closed=!0,`${_(e,r)}${JSON.stringify(n).slice(1,-1)}"}`}o(Z,"closeGrammarToolInputJson");function _(e,r){return e.started?"":(e.started=!0,`{${JSON.stringify(r)}:"`)}o(_,"grammarToolInputJsonStart");function ee(e){let r=e.parameters;if(r.type!=="object")throw new Error("grammar constrained sampling requires an object parameter schema");if(!Array.isArray(r.required)||r.required.length!==1||typeof r.required[0]!="string")throw new Error("grammar constrained sampling requires exactly one required string property");let t=r.required[0];if(!r.properties?.[t])throw new Error(`grammar constrained sampling requires a properties entry for ${t}`);if(r.properties[t]?.type!=="string")throw new Error(`grammar constrained sampling property ${t} must have type string`);return t}o(ee,"inferGrammarInputProperty");function te(e,r,t){let n=e.constrainedSampling;if(!(!n||n.type!=="json_schema")){if(r)try{return R(e.parameters,t),!0}catch(i){if(!(i instanceof d))throw i;if(n.strict!=="require")return;throw new Error(`Tool "${e.name}" requires JSON-schema constrained sampling, but ${i.message}.`)}if(n.strict==="require")throw new Error(`Tool "${e.name}" requires JSON-schema constrained sampling, but strict tools are unsupported.`)}}o(te,"resolveJsonSchemaStrictSampling");function N(e,r){let t=e.constrainedSampling;if(!t||t.type!=="grammar"||!r)return;let n=t.variants.openai_lark,i=t.variants.openai_regex,a=typeof n=="string"&&n.trim().length>0,s=typeof i=="string"&&i.trim().length>0;if(!a&&!s)throw new Error(`Tool "${e.name}" cannot use grammar constrained sampling: no supported grammar variant was provided.`);try{return{format:a?"lark":"regex",definition:a?n:i,inputProperty:ee(e)}}catch(m){let f=m instanceof Error?m.message:String(m);throw new Error(`Tool "${e.name}" cannot use grammar constrained sampling: ${f}.`)}}o(N,"resolveGrammarConstrainedSampling");function re(e,r){let t=new Map;for(let n of e??[]){let i=N(n,r);i&&t.set(n.name,i.inputProperty)}return t}o(re,"createGrammarToolInputProperties");var M=3.5,ne=4800;function C(e){return e.totalTokens||e.input+e.output+e.cacheRead+e.cacheWrite}o(C,"calculateContextTokens");function k(e){try{return JSON.stringify(e)??"undefined"}catch{return"[unserializable]"}}o(k,"safeJsonStringify");function ie(e){if(typeof e=="string")return e.length;let r=0;for(let t of e)r+=t.type==="text"?t.text.length:ne;return r}o(ie,"estimateTextAndImageContentChars");function P(e){return Math.ceil(e.length/M)}o(P,"estimateTextTokens");function oe(e){return Math.ceil(ie(e)/M)}o(oe,"estimateTextAndImageContentTokens");function q(e){let r=0;if(e.role==="system")return P(F(e))+$(e.toolsAdded)+$(e.toolsRemoved);if(e.role==="user"||e.role==="toolResult")return oe(e.content);for(let t of e.content)t.type==="text"?r+=t.text.length:t.type==="thinking"?r+=t.thinking.length:r+=t.name.length+k(t.arguments).length;return Math.ceil(r/M)}o(q,"estimateMessageTokens");function ae(e){let r=Number.NEGATIVE_INFINITY,t;for(let n=0;n<e.length;n++){let i=e[n];if(i.role==="assistant"){let a=i;a.timestamp>=r&&a.stopReason!=="aborted"&&a.stopReason!=="error"&&C(a.usage)>0&&(t={usage:a.usage,index:n})}r=Math.max(r,i.timestamp)}return t}o(ae,"getLastAssistantUsageInfo");function se(e){let r="messages"in e?e.messages:e,t=ae(r);if(t){let i=C(t.usage),a=0;for(let s=t.index+1;s<r.length;s++)a+=q(r[s]);return{tokens:i+a,usageTokens:i,trailingTokens:a,lastUsageIndex:t.index}}let n=0;for(let i of r)n+=q(i);return{tokens:n,usageTokens:0,trailingTokens:n,lastUsageIndex:null}}o(se,"estimateContextTokens");function $(e){return!e||e.length===0?0:P(k(e))}o($,"estimateToolsTokens");var j=4096,le=.15,J=32768,L=1;function b(e,r,t){if(e.contextWindow<=0)return Math.max(L,t);let n=se(r).tokens,i=Math.max(j,Math.ceil(n*le)),a=e.contextWindow-n-i;return a<J&&(a=Math.min(J,e.contextWindow-n-j)),Math.min(t,Math.max(L,a))}o(b,"clampMaxTokensToContext");function G(e,r,t){let n=B(e,r),i=e.samplingParamsByThinkingLevel?.[n];return e.samplingParams||i||t?{...e.samplingParams,...i,...t}:void 0}o(G,"resolveSamplingParams");function ue(e,r,t,n){let i=G(e,t?.reasoning??"off",t?.samplingParams);return{temperature:t?.temperature,samplingParams:i,maxTokens:b(e,r,t?.maxTokens??e.maxTokens),signal:t?.signal,telemetry:t?.telemetry,apiKey:n||t?.apiKey,fetch:t?.fetch,transport:t?.transport,cacheRetention:t?.cacheRetention,sessionId:t?.sessionId,disableContinuation:t?.disableContinuation,headers:t?.headers,identity:t?.identity,onPayload:t?.onPayload,onResponse:t?.onResponse,onProviderStreamEvent:t?.onProviderStreamEvent,timeoutMs:t?.timeoutMs,websocketConnectTimeoutMs:t?.websocketConnectTimeoutMs,maxRetries:t?.maxRetries,maxRetryDelayMs:t?.maxRetryDelayMs,metadata:t?.metadata,env:t?.env}}o(ue,"buildBaseOptions");var pe=1024,de={minimal:1024,low:2048,medium:8192,high:16384};function me(e){return e==="xhigh"||e==="max"?"high":e}o(me,"clampReasoning");function D(e,r){let t={...de,...r},n=me(e);return t[n]}o(D,"thinkingBudgetForLevel");function W(e,r){return Math.min(e,Math.max(0,r-pe))}o(W,"clampThinkingBudgetToAnswerRoom");function fe(e,r,t,n){let i=D(t,n),a=e===void 0?r:Math.min(e+i,r);return a<=i&&(i=W(i,a)),{maxTokens:a,thinkingBudget:i}}o(fe,"adjustMaxTokensForThinking");var ce="(image omitted: model does not support images)",ge="(tool image omitted: model does not support images)",he="(image attached after the tool results)";function ye(e){if(!e.isError)return;let r=e.content.filter(t=>t.type==="image");if(r.length!==0)return{content:I(e.content,he),caption:`Images from the error result of tool call ${e.toolCallId} (${e.toolName}):`,images:r}}o(ye,"splitErrorToolResultImages");function I(e,r){let t=[],n=!1;for(let i of e){if(i.type==="image"){n||t.push({type:"text",text:r}),n=!0;continue}t.push(i),n=i.text===r}return t}o(I,"replaceImagesWithPlaceholder");function we(e,r){return r.input.includes("image")?e:e.map(t=>t.role==="user"&&Array.isArray(t.content)?{...t,content:I(t.content,ce)}:t.role==="toolResult"?{...t,content:I(t.content,ge)}:t)}o(we,"downgradeUnsupportedImages");function Te(e,r){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.role==="assistant"&&!(n.provider!==r.provider||n.api!==r.api||n.model!==r.id)&&!(n.stopReason==="error"||n.stopReason==="aborted"))return n.responseModel}}o(Te,"latestAnsweringModel");function Se(e,r,t){let n=new Map,i=e.map(u=>u.content==null?{...u,content:[]}:u),a=we(i,r),s=Te(a,r),m=a.map(u=>{if(u.role==="system"||u.role==="user")return u;if(u.role==="toolResult"){let l=n.get(u.toolCallId);return l&&l!==u.toolCallId?{...u,toolCallId:l}:u}if(u.role==="assistant"){let l=u,c=l.provider===r.provider&&l.api===r.api&&l.model===r.id&&(s===void 0||l.responseModel===void 0||l.responseModel===s),S=l.content.flatMap(p=>{if(p.type==="thinking")return c?p.redacted||p.thinkingSignature?p:!p.thinking||p.thinking.trim()===""?[]:p:[];if(p.type==="text")return c?p:{type:"text",text:p.text};if(p.type==="toolCall"){let g=p,y=g;if(!c&&g.thoughtSignature&&(y={...g},delete y.thoughtSignature),!c&&t){let A=t(g.id,r,l);A!==g.id&&(n.set(g.id,A),y={...y,id:A})}return y}return p});return{...l,content:S}}return u}),f=[],h=[],T=new Set,E=[],x=o(()=>{if(h.length>0){for(let u of h)T.has(u.id)||f.push({role:"toolResult",toolCallId:u.id,toolName:u.name,content:[{type:"text",text:"No result provided"}],isError:!0,timestamp:Date.now()});h=[],T=new Set}f.push(...E),E.length=0},"closePendingToolCalls");for(let u=0;u<m.length;u++){let l=m[u];if(l.role==="assistant"){x();let c=l;if(c.stopReason==="error"||c.stopReason==="aborted")continue;let S=c.content.filter(p=>p.type==="toolCall");S.length>0&&(h=S,T=new Set),f.push(l)}else l.role==="toolResult"?(T.add(l.toolCallId),f.push(l)):l.role==="system"?h.length>0?E.push(l):f.push(l):(l.role==="user"&&x(),f.push(l))}return x(),f}o(Se,"transformMessages");export{fe as adjustMaxTokensForThinking,Q as appendGrammarToolInputJsonDelta,ue as buildBaseOptions,b as clampMaxTokensToContext,W as clampThinkingBudgetToAnswerRoom,Z as closeGrammarToolInputJson,re as createGrammarToolInputProperties,X as getGrammarToolInput,V as getJsonSchemaToolParameters,Y as prefersJsonSchemaStrictSampling,N as resolveGrammarConstrainedSampling,te as resolveJsonSchemaStrictSampling,G as resolveSamplingParams,ye as splitErrorToolResultImages,D as thinkingBudgetForLevel,Se as transformMessages};
@@ -123,7 +123,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error
123
123
  `);ut.writeFileSync(M,P)}T.flush(),this.cursorRow=Math.max(0,u.length-1),this.hardwareCursorRow=A,this.maxLinesRendered=Math.max(this.maxLinesRendered,u.length),this.previousViewportTop=Math.max(n,A-t+1),this.positionHardwareCursor(d,u.length),this.previousLines=u,this.previousKittyImageIds=this.collectKittyImageIds(u),this.previousWidth=e,this.previousHeight=t}positionHardwareCursor(e,t){if(!e||t<=0){this.terminal.hideCursor();return}let i=Math.max(0,Math.min(e.row,t-1)),r=Math.max(0,e.col),s=i-this.hardwareCursorRow,n="";s>0?n+=`\x1B[${s}B`:s<0&&(n+=`\x1B[${-s}A`),n+=`\x1B[${r+1}G`,n&&this.terminal.write(n),this.hardwareCursorRow=i,this.getShowHardwareCursor()?this.terminal.showCursor():this.terminal.hideCursor()}};import*as fe from"node:fs";import*as dt from"node:path";import{watch as Gp}from"node:fs";var Yp=5e3;function Qr(e){if(e)try{e.close()}catch{}}h(Qr,"closeWatcher");function Bo(e,t,i){try{let r=Gp(e,t);return r.on("error",i),r}catch{return i(),null}}h(Bo,"watchWithErrorHandler");var Ht=W(la(),1),Xp=W(sa(),1),Qp=W(na(),1),Zp=W(oa(),1),Jp=W(aa(),1),ef=W(ha(),1),tf=W(ua(),1),rf=W(ca(),1),sf=W(da(),1),nf=W(pa(),1),lf=W(fa(),1),of=W(ga(),1),af=W(ma(),1),hf=W(xa(),1),uf=W(ba(),1),cf=W(ya(),1),df=W(ka(),1),pf=W(wa(),1),ff=W(Sa(),1),gf=W(Ca(),1),mf=W(va(),1),xf=W(Ta(),1);function Io(e){if(!(!Number.isInteger(e)||e<0||e>1114111))return String.fromCodePoint(e)}h(Io,"decodeCodePoint");function bf(e){switch(e){case"amp":return"&";case"lt":return"<";case"gt":return">";case"quot":return'"';case"apos":return"'"}if(e.startsWith("#x")||e.startsWith("#X"))return Io(Number.parseInt(e.slice(2),16));if(e.startsWith("#"))return Io(Number.parseInt(e.slice(1),10))}h(bf,"decodeHtmlEntity");function yf(e,t){let i=e.indexOf(";",t+1);if(i===-1||i-t>16)return;let r=e.slice(t+1,i),s=bf(r);if(s!==void 0)return{text:s,length:i-t+1}}h(yf,"decodeHtmlEntityAt");var kf={python:df.default,java:sf.default,go:tf.default,javascript:nf.default,json:lf.default,cpp:Zp.default,typescript:xf.default,php:cf.default,ruby:pf.default,c:Qp.default,csharp:Jp.default,nix:hf.default,bash:Xp.default,rust:ff.default,scala:gf.default,kotlin:of.default,swift:mf.default,dart:ef.default,groovy:rf.default,perl:uf.default,lua:af.default};for(let[e,t]of Object.entries(kf))Ht.default.registerLanguage(e,t);var Zr;function wf(){return Zr||(Zr=new Promise(e=>{setImmediate(()=>{import("./lib-4AVRLBHM.js").then(()=>e(),()=>{e()})})})),Zr}h(wf,"loadAllHighlightLanguages");var Ro="</span>",Lo="hljs-";function Sf(e){let t=/\sclass\s*=\s*(?:"([^"]*)"|'([^']*)')/.exec(e),i=t?.[1]??t?.[2];if(i){for(let r of i.split(/\s+/))if(r.startsWith(Lo))return r.slice(Lo.length)}}h(Sf,"getScopeFromSpanTag");function Cf(e,t){let i=t[e];if(i)return i;let r=e.indexOf(".");if(r!==-1){let n=t[e.slice(0,r)];if(n)return n}let s=e.indexOf("-");if(s!==-1){let n=t[e.slice(0,s)];if(n)return n}}h(Cf,"getScopeFormatter");function vf(e,t){for(let i=e.length-1;i>=0;i--){let r=e[i];if(!r)continue;let s=Cf(r,t);if(s)return s}return t.default}h(vf,"getActiveFormatter");function Tf(e,t){if(!e.startsWith("<span",t))return!1;let i=e[t+5];return i===">"||i===" "||i===" "||i===`
124
124
  `||i==="\r"}h(Tf,"isSpanOpenTagStart");function Mf(e,t={}){let i="",r="",s=[],n=h(()=>{if(!r)return;let o=vf(s,t);i+=o?r.split(`
125
125
  `).map(a=>a&&o(a)).join(`
126
- `):r,r=""},"flushText"),l=0;for(;l<e.length;){if(Tf(e,l)){let o=e.indexOf(">",l+5);if(o!==-1){n();let a=e.slice(l,o+1),u=Sf(a);s.push(u),l=o+1;continue}}if(e.startsWith(Ro,l)){n(),s.length>0&&s.pop(),l+=Ro.length;continue}if(e[l]==="&"){let o=yf(e,l);if(o){r+=o.text,l+=o.length;continue}}r+=e[l],l++}return n(),i}h(Mf,"renderHighlightedHtml");function Af(e,t={}){let i=t.language?Ht.default.highlight(e,{language:t.language,ignoreIllegals:t.ignoreIllegals}).value:Ht.default.highlightAuto(e,t.languageSubset).value;return Mf(i,t.theme)}h(Af,"highlight");function Bf(e){return Ht.default.getLanguage(e)!==void 0}h(Bf,"supportsLanguage");function If(){return Ht.default.listLanguages().length}h(If,"getHighlightLanguageCount");var X="system",Rf="light/dark",Jr={neutral:{hue:231.49,saturation:{min:.02,max:.08},slot:8},blue:{hue:231.49,saturation:{min:.1,max:.68},slot:4},green:{hue:158.68,saturation:{min:.1,max:.76},slot:2},red:{hue:20,saturation:{min:.1,max:.92},slot:1},yellow:{hue:82.36,saturation:{min:.5,max:1},slot:3},orange:{hue:52,saturation:{min:.12,max:.85},slot:3},violet:{hue:295,saturation:{min:.2,max:.6},slot:5},calamine:{hue:202.43,saturation:{min:.1,max:.74},slot:6},thinkingSlate:{hue:231.49,saturation:{min:.08,max:.2},slot:4},thinkingBlue:{hue:231.49,saturation:{min:.2,max:.45},slot:4},thinkingPeriwinkle:{hue:263.25,saturation:{min:.3,max:.6},slot:6},thinkingViolet:{hue:295,saturation:{min:.4,max:.75},slot:5},thinkingMagenta:{hue:337.5,saturation:{min:.5,max:.85},slot:13},thinkingRed:{hue:20,saturation:{min:.95,max:1},slot:1}},es={selectedBg:"blue",searchMatchBg:"orange",userMessageBg:"blue",customMessageBg:"violet",toolPendingBg:"neutral",toolSuccessBg:"green",toolErrorBg:"red",text:"neutral",userMessageText:"neutral",customMessageText:"neutral",toolTitle:"neutral",syntaxOperator:"neutral",syntaxPunctuation:"neutral",muted:"neutral",dim:"neutral",thinkingText:"neutral",toolOutput:"neutral",mdLinkUrl:"neutral",mdQuote:"neutral",mdQuoteBorder:"neutral",mdHr:"neutral",mdCodeBlockBorder:"neutral",toolDiffContext:"neutral",syntaxComment:"neutral",scrollbarTrack:"neutral",scrollbarThumb:"neutral",searchMatchText:"neutral",borderMuted:"neutral",accent:"violet",borderAccent:"violet",customMessageLabel:"violet",mdCode:"violet",mdListBullet:"violet",syntaxType:"violet",border:"blue",mdLink:"blue",syntaxKeyword:"blue",syntaxVariable:"calamine",success:"green",mdCodeBlock:"green",toolDiffAdded:"green",bashMode:"green",syntaxNumber:"green",error:"red",toolDiffRemoved:"red",warning:"yellow",mdHeading:"yellow",syntaxFunction:"yellow",syntaxString:"orange",thinkingOff:"neutral",thinkingMinimal:"thinkingSlate",thinkingLow:"thinkingBlue",thinkingMedium:"thinkingPeriwinkle",thinkingHigh:"thinkingViolet",thinkingXhigh:"thinkingMagenta",thinkingMax:"thinkingRed"},Eo={syntaxString:2,syntaxNumber:5,searchMatchBg:3},Lf={panel:{dark:{coefficients:[.29131,-.39746,2.33185,-.85524,-1.2076,.86276],reachable:[0,.979]},light:{coefficients:[-3.74073,27.94549,-78.44258,112.6798,-79.60015,22.11277],reachable:[.348,1]}},track:{dark:{coefficients:[.39028,-.23015,.83573,2.43829,-4.38292,2.01582],reachable:[0,.946]},light:{coefficients:[-5.24921,38.37322,-107.28833,152.10005,-106.17127,29.18061],reachable:[.368,1]}},thinking0:{dark:{coefficients:[.52988,-.05809,-.30924,4.63567,-6.52933,2.89108],reachable:[0,.873]},light:{coefficients:[-28.27749,182.85284,-469.62416,603.15916,-384.59976,97.35147],reachable:[.51,1]}},thinking1:{dark:{coefficients:[.55278,-.03667,-.45659,4.95347,-6.90265,3.0706],reachable:[0,.858]},light:{coefficients:[-37.10484,235.86282,-596.62344,754.3633,-474.00763,118.3551],reachable:[.535,1]}},thinking2:{dark:{coefficients:[.57486,-.01765,-.58987,5.25227,-7.27175,3.25532],reachable:[0,.842]},light:{coefficients:[-59.89653,377.05024,-945.07843,1182.03145,-734.96375,181.68658],reachable:[.556,1]}},thinking3:{dark:{coefficients:[.59621,-62e-5,-.71148,5.53588,-7.6392,3.44606],reachable:[0,.827]},light:{coefficients:[-72.07122,445.84082,-1099.57352,1353.88793,-829.53392,202.26164],reachable:[.58,1]}},thinking4:{dark:{coefficients:[.61691,.01462,-.82288,5.80651,-8.00641,3.64333],reachable:[0,.811]},light:{coefficients:[-110.14338,674.21488,-1645.75941,2004.32367,-1215.15899,293.3183],reachable:[.6,1]}},thinking5:{dark:{coefficients:[.63702,.02826,-.92498,6.06465,-8.37246,3.84651],reachable:[0,.795]},light:{coefficients:[-175.47701,1063.54495,-2570.70594,3098.80776,-1860.15527,444.76392],reachable:[.62,1]}},thinking6:{dark:{coefficients:[.65658,.04044,-1.01835,6.30989,-8.73529,4.05439],reachable:[0,.779]},light:{coefficients:[-183.81712,1094.70055,-2602.68539,3088.71276,-1826.91131,430.75931],reachable:[.643,1]}},subtle:{dark:{coefficients:[.56762,-.02475,-.5383,5.12628,-7.10931,3.17324],reachable:[0,.848]},light:{coefficients:[-232.85459,1376.54473,-3249.11801,3827.91186,-2248.29472,526.55751],reachable:[.657,1]}},thumb:{dark:{coefficients:[.60323,.00278,-.73328,5.57157,-7.68067,3.46933],reachable:[0,.823]},light:{coefficients:[-82.89897,511.01355,-1255.98095,1540.76821,-940.68087,228.58523],reachable:[.586,1]}},readable:{dark:{coefficients:[.66937,.04704,-1.06871,6.43941,-8.9332,4.17229],reachable:[0,.77]},light:{coefficients:[-1554.52576,8733.56817,-19604.93507,21977.72696,-12300.99599,2749.81288],reachable:[.751,1]}},emphasis:{dark:{coefficients:[.7303,.07695,-1.31626,7.1681,-10.14436,4.92846],reachable:[0,.712]},light:{coefficients:[-4948.31942,26870.91986,-58334.48399,63280.17197,-34298.01053,7430.30146],reachable:[.811,1]}},textOnPanel:{dark:{coefficients:[.86713,.05232,-.89428,4.79014,-5.5432,1.75023],reachable:[0,.542]},light:{coefficients:[-8570.89457,43954.60805,-90084.00702,92220.6791,-47152.15802,9632.27113],reachable:[.867,1]}},text:{dark:{coefficients:[.89242,.02311,-.44862,2.34417,-.06084,-2.63844],reachable:[0,.5]},light:{coefficients:[-2004.67048,6664.47299,-6060.70202,-1792.61209,5133.82359,-1939.85583],reachable:[.894,1]}}},ue=["toolPendingBg","toolSuccessBg","toolErrorBg"],Pi=["userMessageBg","customMessageBg"],ts=["userMessageBg","toolPendingBg","toolSuccessBg","toolErrorBg","selectedBg","searchMatchBg","customMessageBg"],Ef=["thinkingOff","thinkingMinimal","thinkingLow","thinkingMedium","thinkingHigh","thinkingXhigh","thinkingMax"],Pf=["thinking0","thinking1","thinking2","thinking3","thinking4","thinking5","thinking6"],Ke=h((e,t,i)=>e.map(r=>({token:r,on:t,level:i})),"each"),$i=[...Ke(ts,["background"],"panel"),{token:"text",on:["background"],level:"text"},{token:"text",on:["selectedBg"],level:"textOnPanel"},{token:"userMessageText",on:["userMessageBg"],level:"textOnPanel"},{token:"toolTitle",on:ue,level:"textOnPanel"},...Ke(["accent","success","error","warning"],["background","selectedBg",...ue],"readable"),{token:"muted",on:["background","selectedBg","customMessageBg",...ue],level:"readable"},{token:"dim",on:["background","selectedBg","customMessageBg",...ue],level:"subtle"},{token:"thinkingText",on:["background"],level:"readable"},{token:"customMessageText",on:["customMessageBg",...ue],level:"readable"},{token:"customMessageLabel",on:["background","customMessageBg","selectedBg",...ue],level:"readable"},{token:"toolOutput",on:["background",...ue],level:"readable"},...Ke(["mdHeading","mdLink","mdLinkUrl","mdCode","mdQuote","mdCodeBlockBorder","mdListBullet"],["background",...Pi],"readable"),{token:"mdCodeBlock",on:["background",...Pi,...ue],level:"readable"},...Ke(["toolDiffAdded","toolDiffRemoved","toolDiffContext"],["background",...ue],"readable"),...Ke(["syntaxComment","syntaxKeyword","syntaxFunction","syntaxVariable","syntaxString","syntaxNumber","syntaxType","syntaxOperator","syntaxPunctuation"],["background",...Pi,...ue],"readable"),{token:"searchMatchText",on:["searchMatchBg"],level:"readable"},...Ke(["bashMode","border","borderAccent"],["background"],"readable"),{token:"borderMuted",on:["background"],level:"subtle"},...Ke(["mdQuoteBorder","mdHr"],["background",...Pi,...ue],"readable"),{token:"scrollbarTrack",on:["background"],level:"track"},{token:"scrollbarThumb",on:["scrollbarTrack"],level:"thumb"},...Ef.map((e,t)=>({token:e,on:["background"],level:Pf[t]}))],$f={dark:"readable",light:"subtle"},_f="emphasis",Po=["text","userMessageText","toolTitle"],is=4.5,Of=(()=>{let e=[],t=h(i=>{if(!e.includes(i)){for(let r of $i)if(r.token===i)for(let s of r.on)s!=="background"&&t(s);e.push(i)}},"visit");for(let i of $i)t(i.token);return e})();function pt(e){return Le(xe(e.r,e.g,e.b)).l}h(pt,"oklabLightness");function $o({r:e,g:t,b:i}){let r=h(s=>{let n=s/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4},"linear");return .2126*r(e)+.7152*r(t)+.0722*r(i)}h($o,"relativeLuminance");function _i(e,t){let i=$o(e),r=$o(t);return(Math.max(i,r)+.05)/(Math.min(i,r)+.05)}h(_i,"wcagContrast");function _o(e,t){let i={r:255,g:255,b:255},r={r:0,g:0,b:0},s=_i(i,e),n=_i(r,e);if(t){let l=pt(t),o=pt(e);if(Math.abs(l-o)>.05){let a=l>o?"dark":"light";if((a==="dark"?s:n)>=is)return a}}return s>=n?"dark":"light"}h(_o,"terminalAppearance");var Df=h((e,t,i)=>Math.min(i,Math.max(t,e)),"clamp2");function Oo({r:e,g:t,b:i}){return`#${[e,t,i].map(r=>Math.round(r).toString(16).padStart(2,"0")).join("")}`}h(Oo,"hexOf");function Do(e){let t=h(i=>Math.exp(-((i-.5)**2)/.125),"gaussian");return(t(e)-t(0))/(1-t(0))}h(Do,"bellWeight");function Fo({saturation:{min:e,max:t}},i){let r=t>0?e/t:1;return r+(1-r)*Do(i)}h(Fo,"saturationCurve");function No(e,t,i){let r=Lf[e][t];if(!(i<r.reachable[0]||i>r.reachable[1]))return r.coefficients.reduce((s,n,l)=>s+n*i**l,0)}h(No,"levelTarget");function Ff(e){let t=Df(e.saturation??1,0,1),{background:i,foreground:r}=e;if(!i)return Wf(t,e.appearanceHint);let s=e.palette?.length===16?e.palette.map(Ho):void 0,n=_o(i,r),l=n==="dark",o=l?1:0,a=pt(i),u=h((y,w)=>{let S=ei(w),B=Jr[es[y]];if(!s){let{min:A,max:k}=B.saturation;return kt(B.hue,(A+(k-A)*Do(S))*t,S)}return Vo(s[Eo[y]??B.slot],B,S,t)},"paint"),d=h((y,w,S)=>{let B=No(y,n,w);if(B===void 0&&S===0)return;let A=(B??o)-w,k=(No($f[n],n,w)??o)-w,M=Math.abs(A)>Math.abs(k)?A-(A-k)*Math.min(S,1):A;return w+M*(1-Math.max(0,S-1))},"target"),c=l?{r:255,g:255,b:255}:{r:0,g:0,b:0},p=h(y=>_i(c,y)>=is,"readable"),f=h((y,w)=>{let S=u(y,w);if(p(S))return S;let[B,A]=[a,w];for(let k=0;k<20;k++){let M=(B+A)/2;p(u(y,M))?B=M:A=M}return u(y,B)},"limitPanel"),g=h(y=>{let w=new Map([["background",i]]);for(let S of Of){let B=[];for(let k of $i)if(k.token===S)for(let M of k.on){let P=d(k.level,pt(w.get(M)??i),y);if(P===void 0||P<0||P>1)return;B.push(P)}let A=l?Math.max(...B):Math.min(...B);w.set(S,ts.includes(S)?f(S,A):u(S,A))}return w},"solve"),m=0,x=g(0);if(!x){let[y,w]=[0,2];x=g(w);for(let S=0;S<20;S++){let B=(y+w)/2,A=g(B);A?[w,x]=[B,A]:y=B}m=w}let b=x??new Map,v=h(y=>$i.filter(w=>w.token===y).flatMap(w=>w.on.map(S=>b.get(S)??i)),"surfacesOf"),T={};for(let y of Object.keys(es)){let w=b.get(y);T[y]=w?Oo(w):""}for(let y of Po){let w=v(y),S=b.get(y);if(r){let B=w.map(A=>d(_f,pt(A),m));if(B.every(A=>A!==void 0&&A>=0&&A<=1)){let A=l?Math.max(...B):Math.min(...B),k=pt(r);if(l?k>=A:k<=A){T[y]="";continue}S=Vo(Ho(r),Jr.neutral,ei(A),t)}}S&&(T[y]=Oo(Nf(S,w,l)))}return{colors:T,dim:[],appearance:n}}h(Ff,"generateSystemThemeColors");function Wo({r:e,g:t,b:i}){return Ns(xe(e,t,i))}h(Wo,"okhslOf");function Ho(e){return{...Wo(e),chroma:Le(xe(e.r,e.g,e.b)).c}}h(Ho,"sourceOf");function Vo(e,t,i,r){let s=Fo(t,e.l),n=s>0?Math.min(1,Fo(t,i)/s):1,l=kt(e.h,e.s*n*r,i),o=e.chroma*n*r,{l:a,c:u}=Le(l);return u<=o?l:ye(ii(a,o,e.h))}h(Vo,"anchored");function Nf(e,t,i){let r=h(c=>t.every(p=>_i(c,p)>=is),"meets");if(r(e))return e;let{h:s,s:n,l}=Wo(e),o=h(c=>kt(s,n,c),"at2"),a=i?1:0;if(!r(o(a)))return o(a);let[u,d]=[l,a];for(let c=0;c<20;c++){let p=(u+d)/2;r(o(p))?d=p:u=p}return o(d)}h(Nf,"withTextContrast");function Wf(e,t){let i={},r=[];for(let[s,n]of Object.entries(es)){if(ts.includes(s)){i[s]="";continue}let l=n==="neutral";i[s]=!l&&e>0?Eo[s]??Jr[n].slot:"",l&&!Po.includes(s)&&r.push(s)}return{colors:i,dim:r,appearance:t}}h(Wf,"indexedColors");function Hf(e){for(let[t,i]of Object.entries(e)){if(i.fallback===void 0)continue;let r=e[i.fallback];if(r===void 0)throw new Error(`Theme token ${t} has unknown fallback ${i.fallback}`);if(r.slot!==i.slot)throw new Error(`Theme token ${t} has fallback ${i.fallback} in a different color slot`)}return e}h(Hf,"defineThemeTokens");var rs=Hf({accent:{slot:"foreground",description:"Primary accent color (logo, selected items, cursor)"},border:{slot:"foreground",description:"Normal borders"},borderAccent:{slot:"foreground",description:"Highlighted borders"},borderMuted:{slot:"foreground",description:"Subtle borders"},success:{slot:"foreground",description:"Success states"},error:{slot:"foreground",description:"Error states"},warning:{slot:"foreground",description:"Warning states"},muted:{slot:"foreground",description:"Secondary/dimmed text"},dim:{slot:"foreground",description:"Very dimmed text (more subtle than muted)"},text:{slot:"foreground",description:"Default text color (usually empty string)"},thinkingText:{slot:"foreground",description:"Thinking block text color"},scrollbarTrack:{slot:"foreground",description:"Fullscreen scrollbar track foreground (falls back to muted when omitted)",fallback:"muted"},scrollbarThumb:{slot:"foreground",description:"Fullscreen scrollbar thumb foreground (falls back to text when omitted)",fallback:"text"},selectedBg:{slot:"background",description:"Selected item background"},searchMatchBg:{slot:"background",description:"Transcript search match background and current-match text (falls back to selectedBg when omitted)",fallback:"selectedBg"},searchMatchText:{slot:"foreground",description:"Transcript search match text and current-match background (falls back to text when omitted)",fallback:"text"},userMessageBg:{slot:"background",description:"User message background"},userMessageText:{slot:"foreground",description:"User message text color"},customMessageBg:{slot:"background",description:"Custom message background (hook-injected messages)"},customMessageText:{slot:"foreground",description:"Custom message text color"},customMessageLabel:{slot:"foreground",description:"Custom message type label color"},toolPendingBg:{slot:"background",description:"Tool execution box (pending state)"},toolSuccessBg:{slot:"background",description:"Tool execution box (success state)"},toolErrorBg:{slot:"background",description:"Tool execution box (error state)"},toolTitle:{slot:"foreground",description:"Tool execution box title color"},toolOutput:{slot:"foreground",description:"Tool execution box output text color"},mdHeading:{slot:"foreground",description:"Markdown heading text"},mdLink:{slot:"foreground",description:"Markdown link text"},mdLinkUrl:{slot:"foreground",description:"Markdown link URL"},mdCode:{slot:"foreground",description:"Markdown inline code"},mdCodeBlock:{slot:"foreground",description:"Markdown code block content"},mdCodeBlockBorder:{slot:"foreground",description:"Markdown code block fences"},mdQuote:{slot:"foreground",description:"Markdown blockquote text"},mdQuoteBorder:{slot:"foreground",description:"Markdown blockquote border"},mdHr:{slot:"foreground",description:"Markdown horizontal rule"},mdListBullet:{slot:"foreground",description:"Markdown list bullets/numbers"},toolDiffAdded:{slot:"foreground",description:"Added lines in tool diffs"},toolDiffRemoved:{slot:"foreground",description:"Removed lines in tool diffs"},toolDiffContext:{slot:"foreground",description:"Context lines in tool diffs"},syntaxComment:{slot:"foreground",description:"Syntax highlighting: comments"},syntaxKeyword:{slot:"foreground",description:"Syntax highlighting: keywords"},syntaxFunction:{slot:"foreground",description:"Syntax highlighting: function names"},syntaxVariable:{slot:"foreground",description:"Syntax highlighting: variable names"},syntaxString:{slot:"foreground",description:"Syntax highlighting: string literals"},syntaxNumber:{slot:"foreground",description:"Syntax highlighting: number literals"},syntaxType:{slot:"foreground",description:"Syntax highlighting: type names"},syntaxOperator:{slot:"foreground",description:"Syntax highlighting: operators"},syntaxPunctuation:{slot:"foreground",description:"Syntax highlighting: punctuation"},thinkingOff:{slot:"foreground",description:"Thinking level border: off"},thinkingMinimal:{slot:"foreground",description:"Thinking level border: minimal"},thinkingLow:{slot:"foreground",description:"Thinking level border: low"},thinkingMedium:{slot:"foreground",description:"Thinking level border: medium"},thinkingHigh:{slot:"foreground",description:"Thinking level border: high"},thinkingXhigh:{slot:"foreground",description:"Thinking level border: xhigh"},thinkingMax:{slot:"foreground",description:"Thinking level border: max (falls back to thinkingXhigh when omitted)",fallback:"thinkingXhigh"},bashMode:{slot:"foreground",description:"Editor border color in bash mode"}}),ss;function Vf(e){ss=e}h(Vf,"setThemeJsonValidator");function ns(e,t,i=new Set){if(typeof e=="number"||e===""||e.startsWith("#")||/^ok(lch|hsl)\(/i.test(e))return e;if(i.has(e))throw new Error(`Circular variable reference detected: ${e}`);if(!(e in t))throw new Error(`Variable reference not found: ${e}`);return i.add(e),ns(t[e],t,i)}h(ns,"resolveVarRefs");function Kf(e,t={}){let i={};for(let[r,s]of Object.entries(e))i[r]=ns(s,t);return i}h(Kf,"resolveThemeColors");function ls(e){let t={...e};for(let[i,r]of Object.entries(rs)){if(!("fallback"in r))continue;let s=i;if(t[s]!==void 0)continue;let n=r.fallback,l=t[n];if(l===void 0)throw new Error(`Theme token ${i} has unresolved fallback ${r.fallback}`);t[s]=l}return t}h(ls,"withThemeTokenFallbacks");var Oi={},os=!1,Ko;function qf(e){Oi={...e},os=!1}h(qf,"setTerminalColors");function Uf(e){Ko=e}h(Uf,"setTerminalColorScheme");function zf(){os=!0}h(zf,"markTerminalColorsPending");var jf={dark:{foreground:ve("#e5e5e7"),background:ve("#000000")},light:{foreground:ve("#000000"),background:ve("#ffffff")}};function qo(e){let t=e.filter(i=>i.kind!=="indexed"||i.index>=16);if(t.length!==0)return t.reduce((i,r)=>i+Le(r).l,0)/t.length}h(qo,"averageLightness");function Gf(e,t){let i=qo(e),r=qo(t);if(i!==void 0&&r!==void 0)return r<i?"dark":"light";if(r!==void 0)return r<.5?"dark":"light";if(i!==void 0)return i>.5?"dark":"light"}h(Gf,"detectAppearance");var as=class{static{h(this,"Theme")}name;sourcePath;sourceInfo;mode;fgAnsi=new Map;bgAnsi=new Map;concreteColors={};defaultForegroundTokens=[];defaultBackgroundTokens=[];dimTokens;ownAppearance;resolvedColors;constructor(e,t,i,r={}){this.name=r.name,this.sourcePath=r.sourcePath,this.sourceInfo=r.sourceInfo,this.mode=i,this.dimTokens=new Set(r.dim);let{fgColors:s,bgColors:n}=cs(ls({...e,...t})),l=[],o=[],a=h((u,d,c)=>{if(d==="")return(c?this.defaultBackgroundTokens:this.defaultForegroundTokens).push(u),c?"\x1B[49m":"\x1B[39m";let p=ve(d);return this.concreteColors[u]=p,(c?o:l).push(p),c?St(p,i):wt(p,i)},"addToken");for(let[u,d]of Object.entries(s))this.fgAnsi.set(u,a(u,d,!1));for(let[u,d]of Object.entries(n))this.bgAnsi.set(u,a(u,d,!0));this.ownAppearance=r.appearance??Gf(l,o)}get appearance(){return this.ownAppearance??ps()}get colors(){let e=Oi;if(this.resolvedColors?.terminal!==e){let t=jf[this.appearance],i=h((l,o)=>l?xe(l.r,l.g,l.b):o,"toColor"),r=i(e.foreground,t.foreground),s=i(e.background,t.background),n={...this.concreteColors};for(let l of this.defaultForegroundTokens)n[l]=r;for(let l of this.defaultBackgroundTokens)n[l]=s;for(let l of this.dimTokens){let o=n[l];o&&(n[l]=Qi(o,s,.4))}this.resolvedColors={terminal:e,colors:Object.freeze(n)}}return this.resolvedColors.colors}style(e,t){let{fg:i,bg:r}=t;return typeof i=="string"&&this.dimTokens.has(i)&&(t={...t,dim:!0}),Zi(e,i===void 0?void 0:typeof i=="string"?this.tokenAnsi(this.fgAnsi,i):wt(i,this.mode),r===void 0?void 0:typeof r=="string"?this.tokenAnsi(this.bgAnsi,r):St(r,this.mode),t)}fg(e,t){let i=this.tokenAnsi(this.fgAnsi,e);return this.dimTokens.has(e)?`${i}\x1B[2m${t}\x1B[22;39m`:`${i}${t}\x1B[39m`}bg(e,t){return`${this.tokenAnsi(this.bgAnsi,e)}${t}\x1B[49m`}tokenAnsi(e,t){let i=e.get(t);if(i===void 0)throw new Error(`Unknown theme color: ${t}`);return i}bold(e){return xt.bold(e)}italic(e){return xt.italic(e)}underline(e){return xt.underline(e)}inverse(e){return xt.inverse(e)}strikethrough(e){return xt.strikethrough(e)}getFgAnsi(e){let t=this.tokenAnsi(this.fgAnsi,e);return this.dimTokens.has(e)?`${t}\x1B[2m`:t}getBgAnsi(e){return this.tokenAnsi(this.bgAnsi,e)}getColorMode(){return this.mode}getThinkingBorderColor(e){switch(e){case"off":return t=>this.fg("thinkingOff",t);case"minimal":return t=>this.fg("thinkingMinimal",t);case"low":return t=>this.fg("thinkingLow",t);case"medium":return t=>this.fg("thinkingMedium",t);case"high":return t=>this.fg("thinkingHigh",t);case"xhigh":return t=>this.fg("thinkingXhigh",t);case"max":return t=>this.fg("thinkingMax",t);default:return t=>this.fg("thinkingOff",t)}}getBashModeBorderColor(){return e=>this.fg("bashMode",e)}},hs;function Uo(){if(!hs){let e=ws(),t=dt.join(e,"dark.json"),i=dt.join(e,"light.json");hs={dark:JSON.parse(Ni(fe.readFileSync(t,"utf-8"))),light:JSON.parse(Ni(fe.readFileSync(i,"utf-8")))}}return hs}h(Uo,"getBuiltinThemes");function Yf(){return zo().map(({name:e})=>e)}h(Yf,"getAvailableThemes");function zo(){let e=ws(),t=[],i=new Set,r=h(s=>{i.has(s.name)||(i.add(s.name),t.push(s))},"addTheme");r({name:X,path:void 0});for(let s of Object.keys(Uo()))r({name:s,path:dt.join(e,`${s}.json`)});for(let s of Xf())r(s);for(let[s,n]of mt.entries())r({name:s,path:n.sourcePath});return t.sort((s,n)=>s.name===X?-1:n.name===X?1:s.name.localeCompare(n.name))}h(zo,"getAvailableThemesWithPaths");function Xf(){let e=Fi(),t=[];if(!fe.existsSync(e))return t;for(let i of fe.readdirSync(e)){if(!i.endsWith(".json"))continue;let r=dt.join(e,i);try{let s=ds(r);s.name&&t.push({name:s.name,path:r})}catch{}}return t}h(Xf,"getCustomThemeInfos");function Qf(e){if(e.includes("/"))throw new Error(`Invalid theme name "${e}": theme names cannot contain "/" because it is reserved for automatic light/dark theme settings.`)}h(Qf,"assertThemeNameIsValid");function Zf(e,t){if(ss)return ss(e,t);if(typeof t!="object"||t===null||!("colors"in t))throw new Error(`Invalid theme "${e}": expected an object with a "colors" map.`);return t}h(Zf,"parseThemeJson");function us(e,t){let i;try{i=JSON.parse(Ni(t))}catch(r){throw new Error(`Failed to parse theme ${e}: ${r}`)}return Zf(e,i)}h(us,"parseThemeJsonContent");function jo(e){let t=Uo();if(e in t)return t[e];let i=mt.get(e);if(i?.sourcePath){let l=fe.readFileSync(i.sourcePath,"utf-8");return us(i.sourcePath,l)}if(i)throw new Error(`Theme "${e}" does not have a source path for export`);let r=Fi(),s=dt.join(r,`${e}.json`);if(!fe.existsSync(s))throw new Error(`Theme not found: ${e}`);let n=fe.readFileSync(s,"utf-8");return us(e,n)}h(jo,"loadThemeJson");function cs(e){let t={},i={};for(let[r,s]of Object.entries(e))rs[r].slot==="background"?i[r]=s:t[r]=s;return{fgColors:t,bgColors:i}}h(cs,"splitThemeColors");function Go(e,t,i){let r=t??mi(),s=ls(Kf(e.colors,e.vars)),{fgColors:n,bgColors:l}=cs(s);return new as(n,l,r,{name:e.name,sourcePath:i,appearance:e.appearance})}h(Go,"createTheme");function Jf(e){let t=Ff({...Oi,saturation:os?0:1,appearanceHint:ps()}),{fgColors:i,bgColors:r}=cs(ls(t.colors));return new as(i,r,e??mi(),{name:X,appearance:t.appearance,dim:t.dim})}h(Jf,"createSystemTheme");function ds(e,t){let i=fe.readFileSync(e,"utf-8"),r=us(e,i);return Go(r,t,e)}h(ds,"loadThemeFromPath");function ft(e,t){if(e===X)return Jf(t);let i=mt.get(e);if(i)return i;let r=jo(e);return Go(r,t)}h(ft,"loadTheme");function eg(e){try{return ft(e)}catch{return}}h(eg,"getThemeByName");function Yo(e){if(!e)return;let t=e.indexOf("/");if(t===-1||e.indexOf("/",t+1)!==-1)return;let i=e.slice(0,t).trim(),r=e.slice(t+1).trim();if(!(!i||!r))return{lightTheme:i,darkTheme:r}}h(Yo,"parseAutoThemeSetting");function tg(e,t){let i=Yo(e);if(i)return t==="light"?i.lightTheme:i.darkTheme;if(!e?.includes("/")&&typeof e=="string")return e}h(tg,"resolveThemeSetting");function ig(e=process.env){let t=e.COLORFGBG?.split(";").at(-1)?.trim();if(!t||!/^\d{1,2}$/.test(t))return;let i=Number(t);if(!(i>15))return i<=6||i===8?"dark":"light"}h(ig,"detectColorFgBgTheme");function rg(e={},t,i=process.env){let{background:r,foreground:s}=e;return r?_o(r,s):t??ig(i)??"dark"}h(rg,"detectTerminalTheme");function ps(){return rg(Oi,Ko)}h(ps,"getTerminalTheme");var fs=Symbol.for("@earendil-works/pi-coding-agent:theme"),sg=Symbol.for("@mariozechner/pi-coding-agent:theme"),O=new Proxy({},{get(e,t){let i=globalThis[fs];if(!i)throw new Error("Theme not initialized. Call initTheme() first.");return i[t]}});function ng(){return globalThis[fs]}h(ng,"getGlobalTheme");function gt(e){globalThis[fs]=e,globalThis[sg]=e}h(gt,"setGlobalTheme");var Z,Vt,qe,Ue,mt=new Map;function lg(e){mt.clear();for(let t of e)t.name&&(Qf(t.name),mt.set(t.name,t))}h(lg,"setRegisteredThemes");function og(e,t=!1){let i=e??X;Z=i;try{gt(ft(i)),t&&Xo()}catch{Z=X,gt(ft(X))}}h(og,"initTheme");function ag(e,t=!1){Z=e;try{return gt(ft(e)),t&&Xo(),Ue&&Ue(),{success:!0}}catch(i){return Z=X,gt(ft(X)),{success:!1,error:i instanceof Error?i.message:String(i)}}}h(ag,"setTheme");function hg(e){gt(e),Z="<in-memory>",gs(),Ue&&Ue()}h(hg,"setThemeInstance");function ug(e){Ue=e}h(ug,"onThemeChange");function Xo(){if(gs(),!Z||Z==="dark"||Z==="light"||Z===X)return;let e=Fi(),t=Z,i=`${t}.json`,r=dt.join(e,i);if(!fe.existsSync(r))return;let s=h(()=>{qe&&clearTimeout(qe),qe=setTimeout(()=>{if(qe=void 0,Z===t&&fe.existsSync(r))try{let n=ds(r);mt.set(t,n),gt(n),Ue&&Ue()}catch{}},100)},"scheduleReload");Vt=Bo(e,(n,l)=>{if(Z===t){if(!l){s();return}l===i&&s()}},()=>{Qr(Vt),Vt=void 0})??void 0}h(Xo,"startThemeWatcher");function gs(){qe&&(clearTimeout(qe),qe=void 0),Qr(Vt),Vt=void 0}h(gs,"stopThemeWatcher");function cg(e){let t=ft(e??Z??X).colors;return Object.fromEntries(Object.entries(t).map(([i,r])=>[i,ri(r)]))}h(cg,"getResolvedThemeColors");function dg(e){let t=e??Z??X;if(t===X)return{};try{let i=jo(t),r=i.export;if(!r)return{};let s=i.vars??{},n=h(l=>{if(l===void 0)return;let o=ns(l,s);if(typeof o=="number")return ri(ti(o));if(o!=="")return/^okhsl\(/i.test(o)?ri(ve(o)):o},"resolve");return{pageBg:n(r.pageBg),cardBg:n(r.cardBg),infoBg:n(r.infoBg)}}catch{return{}}}h(dg,"getThemeExportColors");var Qo,ms;function pg(e){return{keyword:h(t=>e.fg("syntaxKeyword",t),"keyword"),built_in:h(t=>e.fg("syntaxType",t),"built_in"),literal:h(t=>e.fg("syntaxNumber",t),"literal"),number:h(t=>e.fg("syntaxNumber",t),"number"),regexp:h(t=>e.fg("syntaxString",t),"regexp"),string:h(t=>e.fg("syntaxString",t),"string"),subst:h(t=>e.fg("text",t),"subst"),comment:h(t=>e.fg("syntaxComment",t),"comment"),doctag:h(t=>e.fg("syntaxComment",t),"doctag"),meta:h(t=>e.fg("muted",t),"meta"),function:h(t=>e.fg("syntaxFunction",t),"function"),title:h(t=>e.fg("syntaxFunction",t),"title"),class:h(t=>e.fg("syntaxType",t),"class"),type:h(t=>e.fg("syntaxType",t),"type"),tag:h(t=>e.fg("syntaxPunctuation",t),"tag"),name:h(t=>e.fg("syntaxKeyword",t),"name"),attr:h(t=>e.fg("syntaxVariable",t),"attr"),variable:h(t=>e.fg("syntaxVariable",t),"variable"),params:h(t=>e.fg("syntaxVariable",t),"params"),operator:h(t=>e.fg("syntaxOperator",t),"operator"),punctuation:h(t=>e.fg("syntaxPunctuation",t),"punctuation"),emphasis:h(t=>e.italic(t),"emphasis"),strong:h(t=>e.bold(t),"strong"),link:h(t=>e.underline(t),"link"),addition:h(t=>e.fg("toolDiffAdded",t),"addition"),deletion:h(t=>e.fg("toolDiffRemoved",t),"deletion")}}h(pg,"buildCliHighlightTheme");function fg(e){return(Qo!==e||!ms)&&(Qo=e,ms=pg(e)),ms}h(fg,"getCliHighlightTheme");function xs(e,t){let i=t&&Bf(t)?t:void 0;if(!i)return e.split(`
126
+ `):r,r=""},"flushText"),l=0;for(;l<e.length;){if(Tf(e,l)){let o=e.indexOf(">",l+5);if(o!==-1){n();let a=e.slice(l,o+1),u=Sf(a);s.push(u),l=o+1;continue}}if(e.startsWith(Ro,l)){n(),s.length>0&&s.pop(),l+=Ro.length;continue}if(e[l]==="&"){let o=yf(e,l);if(o){r+=o.text,l+=o.length;continue}}r+=e[l],l++}return n(),i}h(Mf,"renderHighlightedHtml");function Af(e,t={}){let i=t.language?Ht.default.highlight(e,{language:t.language,ignoreIllegals:t.ignoreIllegals}).value:Ht.default.highlightAuto(e,t.languageSubset).value;return Mf(i,t.theme)}h(Af,"highlight");function Bf(e){return Ht.default.getLanguage(e)!==void 0}h(Bf,"supportsLanguage");function If(){return Ht.default.listLanguages().length}h(If,"getHighlightLanguageCount");var X="system",Rf="light/dark",Jr={neutral:{hue:231.49,saturation:{min:.02,max:.08},slot:8},blue:{hue:231.49,saturation:{min:.1,max:.68},slot:4},green:{hue:158.68,saturation:{min:.1,max:.76},slot:2},red:{hue:20,saturation:{min:.1,max:.92},slot:1},yellow:{hue:82.36,saturation:{min:.5,max:1},slot:3},orange:{hue:52,saturation:{min:.12,max:.85},slot:3},violet:{hue:295,saturation:{min:.2,max:.6},slot:5},calamine:{hue:202.43,saturation:{min:.1,max:.74},slot:6},thinkingSlate:{hue:231.49,saturation:{min:.08,max:.2},slot:4},thinkingBlue:{hue:231.49,saturation:{min:.2,max:.45},slot:4},thinkingPeriwinkle:{hue:263.25,saturation:{min:.3,max:.6},slot:6},thinkingViolet:{hue:295,saturation:{min:.4,max:.75},slot:5},thinkingMagenta:{hue:337.5,saturation:{min:.5,max:.85},slot:13},thinkingRed:{hue:20,saturation:{min:.95,max:1},slot:1}},es={selectedBg:"blue",searchMatchBg:"orange",userMessageBg:"blue",customMessageBg:"violet",toolPendingBg:"neutral",toolSuccessBg:"green",toolErrorBg:"red",toolDiffAddedBg:"green",toolDiffRemovedBg:"red",text:"neutral",userMessageText:"neutral",customMessageText:"neutral",toolTitle:"neutral",syntaxOperator:"neutral",syntaxPunctuation:"neutral",muted:"neutral",dim:"neutral",thinkingText:"neutral",toolOutput:"neutral",mdLinkUrl:"neutral",mdQuote:"neutral",mdQuoteBorder:"neutral",mdHr:"neutral",mdCodeBlockBorder:"neutral",toolDiffContext:"neutral",syntaxComment:"neutral",scrollbarTrack:"neutral",scrollbarThumb:"neutral",searchMatchText:"neutral",borderMuted:"neutral",accent:"violet",borderAccent:"violet",customMessageLabel:"violet",mdCode:"violet",mdListBullet:"violet",syntaxType:"violet",border:"blue",mdLink:"blue",syntaxKeyword:"blue",syntaxVariable:"calamine",success:"green",mdCodeBlock:"green",toolDiffAdded:"green",bashMode:"green",syntaxNumber:"green",error:"red",toolDiffRemoved:"red",warning:"yellow",mdHeading:"yellow",syntaxFunction:"yellow",syntaxString:"orange",thinkingOff:"neutral",thinkingMinimal:"thinkingSlate",thinkingLow:"thinkingBlue",thinkingMedium:"thinkingPeriwinkle",thinkingHigh:"thinkingViolet",thinkingXhigh:"thinkingMagenta",thinkingMax:"thinkingRed"},Eo={syntaxString:2,syntaxNumber:5,searchMatchBg:3},Lf={panel:{dark:{coefficients:[.29131,-.39746,2.33185,-.85524,-1.2076,.86276],reachable:[0,.979]},light:{coefficients:[-3.74073,27.94549,-78.44258,112.6798,-79.60015,22.11277],reachable:[.348,1]}},track:{dark:{coefficients:[.39028,-.23015,.83573,2.43829,-4.38292,2.01582],reachable:[0,.946]},light:{coefficients:[-5.24921,38.37322,-107.28833,152.10005,-106.17127,29.18061],reachable:[.368,1]}},thinking0:{dark:{coefficients:[.52988,-.05809,-.30924,4.63567,-6.52933,2.89108],reachable:[0,.873]},light:{coefficients:[-28.27749,182.85284,-469.62416,603.15916,-384.59976,97.35147],reachable:[.51,1]}},thinking1:{dark:{coefficients:[.55278,-.03667,-.45659,4.95347,-6.90265,3.0706],reachable:[0,.858]},light:{coefficients:[-37.10484,235.86282,-596.62344,754.3633,-474.00763,118.3551],reachable:[.535,1]}},thinking2:{dark:{coefficients:[.57486,-.01765,-.58987,5.25227,-7.27175,3.25532],reachable:[0,.842]},light:{coefficients:[-59.89653,377.05024,-945.07843,1182.03145,-734.96375,181.68658],reachable:[.556,1]}},thinking3:{dark:{coefficients:[.59621,-62e-5,-.71148,5.53588,-7.6392,3.44606],reachable:[0,.827]},light:{coefficients:[-72.07122,445.84082,-1099.57352,1353.88793,-829.53392,202.26164],reachable:[.58,1]}},thinking4:{dark:{coefficients:[.61691,.01462,-.82288,5.80651,-8.00641,3.64333],reachable:[0,.811]},light:{coefficients:[-110.14338,674.21488,-1645.75941,2004.32367,-1215.15899,293.3183],reachable:[.6,1]}},thinking5:{dark:{coefficients:[.63702,.02826,-.92498,6.06465,-8.37246,3.84651],reachable:[0,.795]},light:{coefficients:[-175.47701,1063.54495,-2570.70594,3098.80776,-1860.15527,444.76392],reachable:[.62,1]}},thinking6:{dark:{coefficients:[.65658,.04044,-1.01835,6.30989,-8.73529,4.05439],reachable:[0,.779]},light:{coefficients:[-183.81712,1094.70055,-2602.68539,3088.71276,-1826.91131,430.75931],reachable:[.643,1]}},subtle:{dark:{coefficients:[.56762,-.02475,-.5383,5.12628,-7.10931,3.17324],reachable:[0,.848]},light:{coefficients:[-232.85459,1376.54473,-3249.11801,3827.91186,-2248.29472,526.55751],reachable:[.657,1]}},thumb:{dark:{coefficients:[.60323,.00278,-.73328,5.57157,-7.68067,3.46933],reachable:[0,.823]},light:{coefficients:[-82.89897,511.01355,-1255.98095,1540.76821,-940.68087,228.58523],reachable:[.586,1]}},readable:{dark:{coefficients:[.66937,.04704,-1.06871,6.43941,-8.9332,4.17229],reachable:[0,.77]},light:{coefficients:[-1554.52576,8733.56817,-19604.93507,21977.72696,-12300.99599,2749.81288],reachable:[.751,1]}},emphasis:{dark:{coefficients:[.7303,.07695,-1.31626,7.1681,-10.14436,4.92846],reachable:[0,.712]},light:{coefficients:[-4948.31942,26870.91986,-58334.48399,63280.17197,-34298.01053,7430.30146],reachable:[.811,1]}},textOnPanel:{dark:{coefficients:[.86713,.05232,-.89428,4.79014,-5.5432,1.75023],reachable:[0,.542]},light:{coefficients:[-8570.89457,43954.60805,-90084.00702,92220.6791,-47152.15802,9632.27113],reachable:[.867,1]}},text:{dark:{coefficients:[.89242,.02311,-.44862,2.34417,-.06084,-2.63844],reachable:[0,.5]},light:{coefficients:[-2004.67048,6664.47299,-6060.70202,-1792.61209,5133.82359,-1939.85583],reachable:[.894,1]}}},ue=["toolPendingBg","toolSuccessBg","toolErrorBg"],Pi=["userMessageBg","customMessageBg"],ts=["userMessageBg","toolPendingBg","toolSuccessBg","toolErrorBg","selectedBg","searchMatchBg","customMessageBg","toolDiffAddedBg","toolDiffRemovedBg"],Ef=["thinkingOff","thinkingMinimal","thinkingLow","thinkingMedium","thinkingHigh","thinkingXhigh","thinkingMax"],Pf=["thinking0","thinking1","thinking2","thinking3","thinking4","thinking5","thinking6"],Ke=h((e,t,i)=>e.map(r=>({token:r,on:t,level:i})),"each"),$i=[...Ke(ts,["background"],"panel"),{token:"text",on:["background"],level:"text"},{token:"text",on:["selectedBg"],level:"textOnPanel"},{token:"userMessageText",on:["userMessageBg"],level:"textOnPanel"},{token:"toolTitle",on:ue,level:"textOnPanel"},...Ke(["accent","success","error","warning"],["background","selectedBg",...ue],"readable"),{token:"muted",on:["background","selectedBg","customMessageBg",...ue],level:"readable"},{token:"dim",on:["background","selectedBg","customMessageBg",...ue],level:"subtle"},{token:"thinkingText",on:["background"],level:"readable"},{token:"customMessageText",on:["customMessageBg",...ue],level:"readable"},{token:"customMessageLabel",on:["background","customMessageBg","selectedBg",...ue],level:"readable"},{token:"toolOutput",on:["background",...ue],level:"readable"},...Ke(["mdHeading","mdLink","mdLinkUrl","mdCode","mdQuote","mdCodeBlockBorder","mdListBullet"],["background",...Pi],"readable"),{token:"mdCodeBlock",on:["background",...Pi,...ue],level:"readable"},...Ke(["toolDiffAdded","toolDiffRemoved","toolDiffContext"],["background",...ue],"readable"),{token:"toolDiffAdded",on:["toolDiffAddedBg"],level:"readable"},{token:"toolDiffRemoved",on:["toolDiffRemovedBg"],level:"readable"},...Ke(["syntaxComment","syntaxKeyword","syntaxFunction","syntaxVariable","syntaxString","syntaxNumber","syntaxType","syntaxOperator","syntaxPunctuation"],["background",...Pi,...ue],"readable"),{token:"searchMatchText",on:["searchMatchBg"],level:"readable"},...Ke(["bashMode","border","borderAccent"],["background"],"readable"),{token:"borderMuted",on:["background"],level:"subtle"},...Ke(["mdQuoteBorder","mdHr"],["background",...Pi,...ue],"readable"),{token:"scrollbarTrack",on:["background"],level:"track"},{token:"scrollbarThumb",on:["scrollbarTrack"],level:"thumb"},...Ef.map((e,t)=>({token:e,on:["background"],level:Pf[t]}))],$f={dark:"readable",light:"subtle"},_f="emphasis",Po=["text","userMessageText","toolTitle"],is=4.5,Of=(()=>{let e=[],t=h(i=>{if(!e.includes(i)){for(let r of $i)if(r.token===i)for(let s of r.on)s!=="background"&&t(s);e.push(i)}},"visit");for(let i of $i)t(i.token);return e})();function pt(e){return Le(xe(e.r,e.g,e.b)).l}h(pt,"oklabLightness");function $o({r:e,g:t,b:i}){let r=h(s=>{let n=s/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4},"linear");return .2126*r(e)+.7152*r(t)+.0722*r(i)}h($o,"relativeLuminance");function _i(e,t){let i=$o(e),r=$o(t);return(Math.max(i,r)+.05)/(Math.min(i,r)+.05)}h(_i,"wcagContrast");function _o(e,t){let i={r:255,g:255,b:255},r={r:0,g:0,b:0},s=_i(i,e),n=_i(r,e);if(t){let l=pt(t),o=pt(e);if(Math.abs(l-o)>.05){let a=l>o?"dark":"light";if((a==="dark"?s:n)>=is)return a}}return s>=n?"dark":"light"}h(_o,"terminalAppearance");var Df=h((e,t,i)=>Math.min(i,Math.max(t,e)),"clamp2");function Oo({r:e,g:t,b:i}){return`#${[e,t,i].map(r=>Math.round(r).toString(16).padStart(2,"0")).join("")}`}h(Oo,"hexOf");function Do(e){let t=h(i=>Math.exp(-((i-.5)**2)/.125),"gaussian");return(t(e)-t(0))/(1-t(0))}h(Do,"bellWeight");function Fo({saturation:{min:e,max:t}},i){let r=t>0?e/t:1;return r+(1-r)*Do(i)}h(Fo,"saturationCurve");function No(e,t,i){let r=Lf[e][t];if(!(i<r.reachable[0]||i>r.reachable[1]))return r.coefficients.reduce((s,n,l)=>s+n*i**l,0)}h(No,"levelTarget");function Ff(e){let t=Df(e.saturation??1,0,1),{background:i,foreground:r}=e;if(!i)return Wf(t,e.appearanceHint);let s=e.palette?.length===16?e.palette.map(Ho):void 0,n=_o(i,r),l=n==="dark",o=l?1:0,a=pt(i),u=h((y,w)=>{let S=ei(w),B=Jr[es[y]];if(!s){let{min:A,max:k}=B.saturation;return kt(B.hue,(A+(k-A)*Do(S))*t,S)}return Vo(s[Eo[y]??B.slot],B,S,t)},"paint"),d=h((y,w,S)=>{let B=No(y,n,w);if(B===void 0&&S===0)return;let A=(B??o)-w,k=(No($f[n],n,w)??o)-w,M=Math.abs(A)>Math.abs(k)?A-(A-k)*Math.min(S,1):A;return w+M*(1-Math.max(0,S-1))},"target"),c=l?{r:255,g:255,b:255}:{r:0,g:0,b:0},p=h(y=>_i(c,y)>=is,"readable"),f=h((y,w)=>{let S=u(y,w);if(p(S))return S;let[B,A]=[a,w];for(let k=0;k<20;k++){let M=(B+A)/2;p(u(y,M))?B=M:A=M}return u(y,B)},"limitPanel"),g=h(y=>{let w=new Map([["background",i]]);for(let S of Of){let B=[];for(let k of $i)if(k.token===S)for(let M of k.on){let P=d(k.level,pt(w.get(M)??i),y);if(P===void 0||P<0||P>1)return;B.push(P)}let A=l?Math.max(...B):Math.min(...B);w.set(S,ts.includes(S)?f(S,A):u(S,A))}return w},"solve"),m=0,x=g(0);if(!x){let[y,w]=[0,2];x=g(w);for(let S=0;S<20;S++){let B=(y+w)/2,A=g(B);A?[w,x]=[B,A]:y=B}m=w}let b=x??new Map,v=h(y=>$i.filter(w=>w.token===y).flatMap(w=>w.on.map(S=>b.get(S)??i)),"surfacesOf"),T={};for(let y of Object.keys(es)){let w=b.get(y);T[y]=w?Oo(w):""}for(let y of Po){let w=v(y),S=b.get(y);if(r){let B=w.map(A=>d(_f,pt(A),m));if(B.every(A=>A!==void 0&&A>=0&&A<=1)){let A=l?Math.max(...B):Math.min(...B),k=pt(r);if(l?k>=A:k<=A){T[y]="";continue}S=Vo(Ho(r),Jr.neutral,ei(A),t)}}S&&(T[y]=Oo(Nf(S,w,l)))}return{colors:T,dim:[],appearance:n}}h(Ff,"generateSystemThemeColors");function Wo({r:e,g:t,b:i}){return Ns(xe(e,t,i))}h(Wo,"okhslOf");function Ho(e){return{...Wo(e),chroma:Le(xe(e.r,e.g,e.b)).c}}h(Ho,"sourceOf");function Vo(e,t,i,r){let s=Fo(t,e.l),n=s>0?Math.min(1,Fo(t,i)/s):1,l=kt(e.h,e.s*n*r,i),o=e.chroma*n*r,{l:a,c:u}=Le(l);return u<=o?l:ye(ii(a,o,e.h))}h(Vo,"anchored");function Nf(e,t,i){let r=h(c=>t.every(p=>_i(c,p)>=is),"meets");if(r(e))return e;let{h:s,s:n,l}=Wo(e),o=h(c=>kt(s,n,c),"at2"),a=i?1:0;if(!r(o(a)))return o(a);let[u,d]=[l,a];for(let c=0;c<20;c++){let p=(u+d)/2;r(o(p))?d=p:u=p}return o(d)}h(Nf,"withTextContrast");function Wf(e,t){let i={},r=[];for(let[s,n]of Object.entries(es)){if(ts.includes(s)){i[s]="";continue}let l=n==="neutral";i[s]=!l&&e>0?Eo[s]??Jr[n].slot:"",l&&!Po.includes(s)&&r.push(s)}return{colors:i,dim:r,appearance:t}}h(Wf,"indexedColors");function Hf(e){for(let[t,i]of Object.entries(e)){if(i.fallback===void 0)continue;let r=e[i.fallback];if(r===void 0)throw new Error(`Theme token ${t} has unknown fallback ${i.fallback}`);if(r.slot!==i.slot)throw new Error(`Theme token ${t} has fallback ${i.fallback} in a different color slot`)}return e}h(Hf,"defineThemeTokens");var rs=Hf({accent:{slot:"foreground",description:"Primary accent color (logo, selected items, cursor)"},border:{slot:"foreground",description:"Normal borders"},borderAccent:{slot:"foreground",description:"Highlighted borders"},borderMuted:{slot:"foreground",description:"Subtle borders"},success:{slot:"foreground",description:"Success states"},error:{slot:"foreground",description:"Error states"},warning:{slot:"foreground",description:"Warning states"},muted:{slot:"foreground",description:"Secondary/dimmed text"},dim:{slot:"foreground",description:"Very dimmed text (more subtle than muted)"},text:{slot:"foreground",description:"Default text color (usually empty string)"},thinkingText:{slot:"foreground",description:"Thinking block text color"},scrollbarTrack:{slot:"foreground",description:"Fullscreen scrollbar track foreground (falls back to muted when omitted)",fallback:"muted"},scrollbarThumb:{slot:"foreground",description:"Fullscreen scrollbar thumb foreground (falls back to text when omitted)",fallback:"text"},selectedBg:{slot:"background",description:"Selected item background"},searchMatchBg:{slot:"background",description:"Transcript search match background and current-match text (falls back to selectedBg when omitted)",fallback:"selectedBg"},searchMatchText:{slot:"foreground",description:"Transcript search match text and current-match background (falls back to text when omitted)",fallback:"text"},userMessageBg:{slot:"background",description:"User message background"},userMessageText:{slot:"foreground",description:"User message text color"},customMessageBg:{slot:"background",description:"Custom message background (hook-injected messages)"},customMessageText:{slot:"foreground",description:"Custom message text color"},customMessageLabel:{slot:"foreground",description:"Custom message type label color"},toolPendingBg:{slot:"background",description:"Tool execution box (pending state)"},toolSuccessBg:{slot:"background",description:"Tool execution box (success state)"},toolErrorBg:{slot:"background",description:"Tool execution box (error state)"},toolTitle:{slot:"foreground",description:"Tool execution box title color"},toolOutput:{slot:"foreground",description:"Tool execution box output text color"},mdHeading:{slot:"foreground",description:"Markdown heading text"},mdLink:{slot:"foreground",description:"Markdown link text"},mdLinkUrl:{slot:"foreground",description:"Markdown link URL"},mdCode:{slot:"foreground",description:"Markdown inline code"},mdCodeBlock:{slot:"foreground",description:"Markdown code block content"},mdCodeBlockBorder:{slot:"foreground",description:"Markdown code block fences"},mdQuote:{slot:"foreground",description:"Markdown blockquote text"},mdQuoteBorder:{slot:"foreground",description:"Markdown blockquote border"},mdHr:{slot:"foreground",description:"Markdown horizontal rule"},mdListBullet:{slot:"foreground",description:"Markdown list bullets/numbers"},toolDiffAdded:{slot:"foreground",description:"Added lines in tool diffs"},toolDiffRemoved:{slot:"foreground",description:"Removed lines in tool diffs"},toolDiffContext:{slot:"foreground",description:"Context lines in tool diffs"},toolDiffAddedBg:{slot:"background",description:"Whole-line background of added lines in tool diffs (falls back to toolSuccessBg when omitted)",fallback:"toolSuccessBg"},toolDiffRemovedBg:{slot:"background",description:"Whole-line background of removed lines in tool diffs (falls back to toolErrorBg when omitted)",fallback:"toolErrorBg"},syntaxComment:{slot:"foreground",description:"Syntax highlighting: comments"},syntaxKeyword:{slot:"foreground",description:"Syntax highlighting: keywords"},syntaxFunction:{slot:"foreground",description:"Syntax highlighting: function names"},syntaxVariable:{slot:"foreground",description:"Syntax highlighting: variable names"},syntaxString:{slot:"foreground",description:"Syntax highlighting: string literals"},syntaxNumber:{slot:"foreground",description:"Syntax highlighting: number literals"},syntaxType:{slot:"foreground",description:"Syntax highlighting: type names"},syntaxOperator:{slot:"foreground",description:"Syntax highlighting: operators"},syntaxPunctuation:{slot:"foreground",description:"Syntax highlighting: punctuation"},thinkingOff:{slot:"foreground",description:"Thinking level border: off"},thinkingMinimal:{slot:"foreground",description:"Thinking level border: minimal"},thinkingLow:{slot:"foreground",description:"Thinking level border: low"},thinkingMedium:{slot:"foreground",description:"Thinking level border: medium"},thinkingHigh:{slot:"foreground",description:"Thinking level border: high"},thinkingXhigh:{slot:"foreground",description:"Thinking level border: xhigh"},thinkingMax:{slot:"foreground",description:"Thinking level border: max (falls back to thinkingXhigh when omitted)",fallback:"thinkingXhigh"},bashMode:{slot:"foreground",description:"Editor border color in bash mode"}}),ss;function Vf(e){ss=e}h(Vf,"setThemeJsonValidator");function ns(e,t,i=new Set){if(typeof e=="number"||e===""||e.startsWith("#")||/^ok(lch|hsl)\(/i.test(e))return e;if(i.has(e))throw new Error(`Circular variable reference detected: ${e}`);if(!(e in t))throw new Error(`Variable reference not found: ${e}`);return i.add(e),ns(t[e],t,i)}h(ns,"resolveVarRefs");function Kf(e,t={}){let i={};for(let[r,s]of Object.entries(e))i[r]=ns(s,t);return i}h(Kf,"resolveThemeColors");function ls(e){let t={...e};for(let[i,r]of Object.entries(rs)){if(!("fallback"in r))continue;let s=i;if(t[s]!==void 0)continue;let n=r.fallback,l=t[n];if(l===void 0)throw new Error(`Theme token ${i} has unresolved fallback ${r.fallback}`);t[s]=l}return t}h(ls,"withThemeTokenFallbacks");var Oi={},os=!1,Ko;function qf(e){Oi={...e},os=!1}h(qf,"setTerminalColors");function Uf(e){Ko=e}h(Uf,"setTerminalColorScheme");function zf(){os=!0}h(zf,"markTerminalColorsPending");var jf={dark:{foreground:ve("#e5e5e7"),background:ve("#000000")},light:{foreground:ve("#000000"),background:ve("#ffffff")}};function qo(e){let t=e.filter(i=>i.kind!=="indexed"||i.index>=16);if(t.length!==0)return t.reduce((i,r)=>i+Le(r).l,0)/t.length}h(qo,"averageLightness");function Gf(e,t){let i=qo(e),r=qo(t);if(i!==void 0&&r!==void 0)return r<i?"dark":"light";if(r!==void 0)return r<.5?"dark":"light";if(i!==void 0)return i>.5?"dark":"light"}h(Gf,"detectAppearance");var as=class{static{h(this,"Theme")}name;sourcePath;sourceInfo;mode;fgAnsi=new Map;bgAnsi=new Map;concreteColors={};defaultForegroundTokens=[];defaultBackgroundTokens=[];dimTokens;ownAppearance;resolvedColors;constructor(e,t,i,r={}){this.name=r.name,this.sourcePath=r.sourcePath,this.sourceInfo=r.sourceInfo,this.mode=i,this.dimTokens=new Set(r.dim);let{fgColors:s,bgColors:n}=cs(ls({...e,...t})),l=[],o=[],a=h((u,d,c)=>{if(d==="")return(c?this.defaultBackgroundTokens:this.defaultForegroundTokens).push(u),c?"\x1B[49m":"\x1B[39m";let p=ve(d);return this.concreteColors[u]=p,(c?o:l).push(p),c?St(p,i):wt(p,i)},"addToken");for(let[u,d]of Object.entries(s))this.fgAnsi.set(u,a(u,d,!1));for(let[u,d]of Object.entries(n))this.bgAnsi.set(u,a(u,d,!0));this.ownAppearance=r.appearance??Gf(l,o)}get appearance(){return this.ownAppearance??ps()}get colors(){let e=Oi;if(this.resolvedColors?.terminal!==e){let t=jf[this.appearance],i=h((l,o)=>l?xe(l.r,l.g,l.b):o,"toColor"),r=i(e.foreground,t.foreground),s=i(e.background,t.background),n={...this.concreteColors};for(let l of this.defaultForegroundTokens)n[l]=r;for(let l of this.defaultBackgroundTokens)n[l]=s;for(let l of this.dimTokens){let o=n[l];o&&(n[l]=Qi(o,s,.4))}this.resolvedColors={terminal:e,colors:Object.freeze(n)}}return this.resolvedColors.colors}style(e,t){let{fg:i,bg:r}=t;return typeof i=="string"&&this.dimTokens.has(i)&&(t={...t,dim:!0}),Zi(e,i===void 0?void 0:typeof i=="string"?this.tokenAnsi(this.fgAnsi,i):wt(i,this.mode),r===void 0?void 0:typeof r=="string"?this.tokenAnsi(this.bgAnsi,r):St(r,this.mode),t)}fg(e,t){let i=this.tokenAnsi(this.fgAnsi,e);return this.dimTokens.has(e)?`${i}\x1B[2m${t}\x1B[22;39m`:`${i}${t}\x1B[39m`}bg(e,t){return`${this.tokenAnsi(this.bgAnsi,e)}${t}\x1B[49m`}tokenAnsi(e,t){let i=e.get(t);if(i===void 0)throw new Error(`Unknown theme color: ${t}`);return i}bold(e){return xt.bold(e)}italic(e){return xt.italic(e)}underline(e){return xt.underline(e)}inverse(e){return xt.inverse(e)}strikethrough(e){return xt.strikethrough(e)}getFgAnsi(e){let t=this.tokenAnsi(this.fgAnsi,e);return this.dimTokens.has(e)?`${t}\x1B[2m`:t}getBgAnsi(e){return this.tokenAnsi(this.bgAnsi,e)}getColorMode(){return this.mode}getThinkingBorderColor(e){switch(e){case"off":return t=>this.fg("thinkingOff",t);case"minimal":return t=>this.fg("thinkingMinimal",t);case"low":return t=>this.fg("thinkingLow",t);case"medium":return t=>this.fg("thinkingMedium",t);case"high":return t=>this.fg("thinkingHigh",t);case"xhigh":return t=>this.fg("thinkingXhigh",t);case"max":return t=>this.fg("thinkingMax",t);default:return t=>this.fg("thinkingOff",t)}}getBashModeBorderColor(){return e=>this.fg("bashMode",e)}},hs;function Uo(){if(!hs){let e=ws(),t=dt.join(e,"dark.json"),i=dt.join(e,"light.json");hs={dark:JSON.parse(Ni(fe.readFileSync(t,"utf-8"))),light:JSON.parse(Ni(fe.readFileSync(i,"utf-8")))}}return hs}h(Uo,"getBuiltinThemes");function Yf(){return zo().map(({name:e})=>e)}h(Yf,"getAvailableThemes");function zo(){let e=ws(),t=[],i=new Set,r=h(s=>{i.has(s.name)||(i.add(s.name),t.push(s))},"addTheme");r({name:X,path:void 0});for(let s of Object.keys(Uo()))r({name:s,path:dt.join(e,`${s}.json`)});for(let s of Xf())r(s);for(let[s,n]of mt.entries())r({name:s,path:n.sourcePath});return t.sort((s,n)=>s.name===X?-1:n.name===X?1:s.name.localeCompare(n.name))}h(zo,"getAvailableThemesWithPaths");function Xf(){let e=Fi(),t=[];if(!fe.existsSync(e))return t;for(let i of fe.readdirSync(e)){if(!i.endsWith(".json"))continue;let r=dt.join(e,i);try{let s=ds(r);s.name&&t.push({name:s.name,path:r})}catch{}}return t}h(Xf,"getCustomThemeInfos");function Qf(e){if(e.includes("/"))throw new Error(`Invalid theme name "${e}": theme names cannot contain "/" because it is reserved for automatic light/dark theme settings.`)}h(Qf,"assertThemeNameIsValid");function Zf(e,t){if(ss)return ss(e,t);if(typeof t!="object"||t===null||!("colors"in t))throw new Error(`Invalid theme "${e}": expected an object with a "colors" map.`);return t}h(Zf,"parseThemeJson");function us(e,t){let i;try{i=JSON.parse(Ni(t))}catch(r){throw new Error(`Failed to parse theme ${e}: ${r}`)}return Zf(e,i)}h(us,"parseThemeJsonContent");function jo(e){let t=Uo();if(e in t)return t[e];let i=mt.get(e);if(i?.sourcePath){let l=fe.readFileSync(i.sourcePath,"utf-8");return us(i.sourcePath,l)}if(i)throw new Error(`Theme "${e}" does not have a source path for export`);let r=Fi(),s=dt.join(r,`${e}.json`);if(!fe.existsSync(s))throw new Error(`Theme not found: ${e}`);let n=fe.readFileSync(s,"utf-8");return us(e,n)}h(jo,"loadThemeJson");function cs(e){let t={},i={};for(let[r,s]of Object.entries(e))rs[r].slot==="background"?i[r]=s:t[r]=s;return{fgColors:t,bgColors:i}}h(cs,"splitThemeColors");function Go(e,t,i){let r=t??mi(),s=ls(Kf(e.colors,e.vars)),{fgColors:n,bgColors:l}=cs(s);return new as(n,l,r,{name:e.name,sourcePath:i,appearance:e.appearance})}h(Go,"createTheme");function Jf(e){let t=Ff({...Oi,saturation:os?0:1,appearanceHint:ps()}),{fgColors:i,bgColors:r}=cs(ls(t.colors));return new as(i,r,e??mi(),{name:X,appearance:t.appearance,dim:t.dim})}h(Jf,"createSystemTheme");function ds(e,t){let i=fe.readFileSync(e,"utf-8"),r=us(e,i);return Go(r,t,e)}h(ds,"loadThemeFromPath");function ft(e,t){if(e===X)return Jf(t);let i=mt.get(e);if(i)return i;let r=jo(e);return Go(r,t)}h(ft,"loadTheme");function eg(e){try{return ft(e)}catch{return}}h(eg,"getThemeByName");function Yo(e){if(!e)return;let t=e.indexOf("/");if(t===-1||e.indexOf("/",t+1)!==-1)return;let i=e.slice(0,t).trim(),r=e.slice(t+1).trim();if(!(!i||!r))return{lightTheme:i,darkTheme:r}}h(Yo,"parseAutoThemeSetting");function tg(e,t){let i=Yo(e);if(i)return t==="light"?i.lightTheme:i.darkTheme;if(!e?.includes("/")&&typeof e=="string")return e}h(tg,"resolveThemeSetting");function ig(e=process.env){let t=e.COLORFGBG?.split(";").at(-1)?.trim();if(!t||!/^\d{1,2}$/.test(t))return;let i=Number(t);if(!(i>15))return i<=6||i===8?"dark":"light"}h(ig,"detectColorFgBgTheme");function rg(e={},t,i=process.env){let{background:r,foreground:s}=e;return r?_o(r,s):t??ig(i)??"dark"}h(rg,"detectTerminalTheme");function ps(){return rg(Oi,Ko)}h(ps,"getTerminalTheme");var fs=Symbol.for("@earendil-works/pi-coding-agent:theme"),sg=Symbol.for("@mariozechner/pi-coding-agent:theme"),O=new Proxy({},{get(e,t){let i=globalThis[fs];if(!i)throw new Error("Theme not initialized. Call initTheme() first.");return i[t]}});function ng(){return globalThis[fs]}h(ng,"getGlobalTheme");function gt(e){globalThis[fs]=e,globalThis[sg]=e}h(gt,"setGlobalTheme");var Z,Vt,qe,Ue,mt=new Map;function lg(e){mt.clear();for(let t of e)t.name&&(Qf(t.name),mt.set(t.name,t))}h(lg,"setRegisteredThemes");function og(e,t=!1){let i=e??X;Z=i;try{gt(ft(i)),t&&Xo()}catch{Z=X,gt(ft(X))}}h(og,"initTheme");function ag(e,t=!1){Z=e;try{return gt(ft(e)),t&&Xo(),Ue&&Ue(),{success:!0}}catch(i){return Z=X,gt(ft(X)),{success:!1,error:i instanceof Error?i.message:String(i)}}}h(ag,"setTheme");function hg(e){gt(e),Z="<in-memory>",gs(),Ue&&Ue()}h(hg,"setThemeInstance");function ug(e){Ue=e}h(ug,"onThemeChange");function Xo(){if(gs(),!Z||Z==="dark"||Z==="light"||Z===X)return;let e=Fi(),t=Z,i=`${t}.json`,r=dt.join(e,i);if(!fe.existsSync(r))return;let s=h(()=>{qe&&clearTimeout(qe),qe=setTimeout(()=>{if(qe=void 0,Z===t&&fe.existsSync(r))try{let n=ds(r);mt.set(t,n),gt(n),Ue&&Ue()}catch{}},100)},"scheduleReload");Vt=Bo(e,(n,l)=>{if(Z===t){if(!l){s();return}l===i&&s()}},()=>{Qr(Vt),Vt=void 0})??void 0}h(Xo,"startThemeWatcher");function gs(){qe&&(clearTimeout(qe),qe=void 0),Qr(Vt),Vt=void 0}h(gs,"stopThemeWatcher");function cg(e){let t=ft(e??Z??X).colors;return Object.fromEntries(Object.entries(t).map(([i,r])=>[i,ri(r)]))}h(cg,"getResolvedThemeColors");function dg(e){let t=e??Z??X;if(t===X)return{};try{let i=jo(t),r=i.export;if(!r)return{};let s=i.vars??{},n=h(l=>{if(l===void 0)return;let o=ns(l,s);if(typeof o=="number")return ri(ti(o));if(o!=="")return/^okhsl\(/i.test(o)?ri(ve(o)):o},"resolve");return{pageBg:n(r.pageBg),cardBg:n(r.cardBg),infoBg:n(r.infoBg)}}catch{return{}}}h(dg,"getThemeExportColors");var Qo,ms;function pg(e){return{keyword:h(t=>e.fg("syntaxKeyword",t),"keyword"),built_in:h(t=>e.fg("syntaxType",t),"built_in"),literal:h(t=>e.fg("syntaxNumber",t),"literal"),number:h(t=>e.fg("syntaxNumber",t),"number"),regexp:h(t=>e.fg("syntaxString",t),"regexp"),string:h(t=>e.fg("syntaxString",t),"string"),subst:h(t=>e.fg("text",t),"subst"),comment:h(t=>e.fg("syntaxComment",t),"comment"),doctag:h(t=>e.fg("syntaxComment",t),"doctag"),meta:h(t=>e.fg("muted",t),"meta"),function:h(t=>e.fg("syntaxFunction",t),"function"),title:h(t=>e.fg("syntaxFunction",t),"title"),class:h(t=>e.fg("syntaxType",t),"class"),type:h(t=>e.fg("syntaxType",t),"type"),tag:h(t=>e.fg("syntaxPunctuation",t),"tag"),name:h(t=>e.fg("syntaxKeyword",t),"name"),attr:h(t=>e.fg("syntaxVariable",t),"attr"),variable:h(t=>e.fg("syntaxVariable",t),"variable"),params:h(t=>e.fg("syntaxVariable",t),"params"),operator:h(t=>e.fg("syntaxOperator",t),"operator"),punctuation:h(t=>e.fg("syntaxPunctuation",t),"punctuation"),emphasis:h(t=>e.italic(t),"emphasis"),strong:h(t=>e.bold(t),"strong"),link:h(t=>e.underline(t),"link"),addition:h(t=>e.fg("toolDiffAdded",t),"addition"),deletion:h(t=>e.fg("toolDiffRemoved",t),"deletion")}}h(pg,"buildCliHighlightTheme");function fg(e){return(Qo!==e||!ms)&&(Qo=e,ms=pg(e)),ms}h(fg,"getCliHighlightTheme");function xs(e,t){let i=t&&Bf(t)?t:void 0;if(!i)return e.split(`
127
127
  `).map(s=>O.fg("mdCodeBlock",s));let r={language:i,ignoreIllegals:!0,theme:fg(O)};try{return Af(e,r).split(`
128
128
  `)}catch{return e.split(`
129
- `).map(s=>O.fg("mdCodeBlock",s))}}h(xs,"highlightCode");var gg=class{static{h(this,"CodeHighlighter")}last;highlight(e,t){let i=ng(),r=If(),s=this.last;if(s?.code===e&&s.lang===t&&s.theme===i&&s.languageCount===r)return s.lines;let n=xs(e,t);return this.last={code:e,lang:t,theme:i,languageCount:r,lines:n},n}};function mg(e){let t=e.split(".").pop()?.toLowerCase();return t?{ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",py:"python",rb:"ruby",rs:"rust",go:"go",java:"java",kt:"kotlin",swift:"swift",dart:"dart",groovy:"groovy",gradle:"groovy",nix:"nix",c:"c",h:"c",cpp:"cpp",cc:"cpp",cxx:"cpp",hpp:"cpp",cs:"csharp",php:"php",sh:"bash",bash:"bash",zsh:"bash",fish:"fish",ps1:"powershell",sql:"sql",html:"html",htm:"html",css:"css",scss:"scss",sass:"sass",less:"less",json:"json",yaml:"yaml",yml:"yaml",toml:"toml",xml:"xml",md:"markdown",markdown:"markdown",dockerfile:"dockerfile",makefile:"makefile",cmake:"cmake",lua:"lua",perl:"perl",r:"r",scala:"scala",clj:"clojure",ex:"elixir",exs:"elixir",erl:"erlang",hs:"haskell",ml:"ocaml",vim:"vim",graphql:"graphql",proto:"protobuf",tf:"hcl",hcl:"hcl"}[t]:void 0}h(mg,"getLanguageFromPath");function xg(){return{heading:h(e=>O.fg("mdHeading",e),"heading"),link:h(e=>O.fg("mdLink",e),"link"),linkUrl:h(e=>O.fg("mdLinkUrl",e),"linkUrl"),code:h(e=>O.fg("mdCode",e),"code"),codeBlock:h(e=>O.fg("mdCodeBlock",e),"codeBlock"),codeBlockBorder:h(e=>O.fg("mdCodeBlockBorder",e),"codeBlockBorder"),quote:h(e=>O.fg("mdQuote",e),"quote"),quoteBorder:h(e=>O.fg("mdQuoteBorder",e),"quoteBorder"),hr:h(e=>O.fg("mdHr",e),"hr"),listBullet:h(e=>O.fg("mdListBullet",e),"listBullet"),bold:h(e=>O.bold(e),"bold"),italic:h(e=>O.italic(e),"italic"),underline:h(e=>O.underline(e),"underline"),strikethrough:h(e=>O.strikethrough(e),"strikethrough"),highlightCode:xs}}h(xg,"getMarkdownTheme");function Zo(){return{selectedPrefix:h(e=>O.fg("accent",e),"selectedPrefix"),selectedText:h(e=>O.fg("accent",e),"selectedText"),description:h(e=>O.fg("muted",e),"description"),scrollInfo:h(e=>O.fg("muted",e),"scrollInfo"),noMatch:h(e=>O.fg("muted",e),"noMatch")}}h(Zo,"getSelectListTheme");function bg(){return{borderColor:h(e=>O.fg("border",e),"borderColor"),selectList:Zo(),placeholder:h(e=>O.fg("dim",e),"placeholder")}}h(bg,"getEditorTheme");function yg(){return{label:h((e,t)=>t?O.fg("accent",e):e,"label"),value:h((e,t)=>t?O.fg("accent",e):O.fg("muted",e),"value"),description:h(e=>O.fg("dim",e),"description"),cursor:O.fg("accent","\u2192 "),hint:h(e=>O.fg("dim",e),"hint")}}h(yg,"getSettingsListTheme");function kg(e,t){let i=process.platform==="darwin"&&e.toLowerCase()==="alt"?"option":e;return t.capitalize?i.charAt(0).toUpperCase()+i.slice(1):i}h(kg,"formatKeyPart");function bs(e,t={}){return e.split("/").map(i=>i.split("+").map(r=>kg(r,t)).join("+")).join("/")}h(bs,"formatKeyText");function Jo(e,t={}){return e.length===0?"":bs(e.join("/"),t)}h(Jo,"formatKeys");function ea(e){return Jo(se().getKeys(e))}h(ea,"keyText");function wg(e){return Jo(se().getKeys(e),{capitalize:!0})}h(wg,"keyDisplayText");function Sg(e,t){return O.fg("dim",ea(e))+O.fg("muted",` ${t}`)}h(Sg,"keyHint");function Cg(e,t){return O.fg("dim",bs(e))+O.fg("muted",` ${t}`)}h(Cg,"rawKeyHint");export{ll as Box,pe as CURSOR_MARKER,hl as CancellableLoader,gg as CodeHighlighter,$n as CombinedAutocompleteProvider,Ie as Container,Rf as DEFAULT_THEME_SETTING,Tl as Editor,Yp as FS_WATCH_RETRY_DELAY_MS,Il as Image,Ci as Input,qs as Key,ir as KeybindingsManager,Ar as Loader,Vl as Markdown,Kl as MouseRegion,lo as ProcessTerminal,X as SYSTEM_THEME_NAME,Nr as ScrollView,Br as SelectList,ql as SettingsList,Ul as Spacer,rs as THEME_TOKENS,tr as TUI_KEYBINDINGS,Mr as Text,as as Theme,zl as TruncatedText,So as TuiAltScreen,Ao as TuiMainScreen,jl as VStack,fi as Z,St as backgroundAnsi,Qr as closeWatcher,ye as colorToRgb,gr as detectCapabilities,en as dist_exports,wt as foregroundAnsi,bs as formatKeyText,Et as fuzzyFilter,pr as fuzzyMatch,Yf as getAvailableThemes,zo as getAvailableThemesWithPaths,oe as getCapabilities,bg as getEditorTheme,Sr as getImageDimensions,se as getKeybindings,mg as getLanguageFromPath,xg as getMarkdownTheme,Yl as getNativeClipboard,cg as getResolvedThemeColors,Zo as getSelectListTheme,hi as getSelectPageIndex,yg as getSettingsListTheme,mi as getTerminalColorMode,ps as getTerminalTheme,eg as getThemeByName,dg as getThemeExportColors,xs as highlightCode,xi as hyperlink,bi as imageFallback,ti as indexedColor,og as initTheme,sl as isViewportTUI,wg as keyDisplayText,Sg as keyHint,ea as keyText,wf as loadAllHighlightLanguages,ds as loadThemeFromPath,zf as markTerminalColorsPending,Me as matchesKey,Qi as mixColors,ug as onThemeChange,Yo as parseAutoThemeSetting,ve as parseColor,Cg as rawKeyHint,Ut as replaceControlCharacters,tg as resolveThemeSetting,xe as rgbColor,Nn as setCapabilityOverrides,Bl as setImageTranscoder,Js as setKeybindings,lg as setRegisteredThemes,Uf as setTerminalColorScheme,qf as setTerminalColors,ag as setTheme,hg as setThemeInstance,Vf as setThemeJsonValidator,z as sliceByColumn,gs as stopThemeWatcher,O as theme,H as truncateToWidth,C as visibleWidth,Bo as watchWithErrorHandler,me as wrapTextWithAnsi};
129
+ `).map(s=>O.fg("mdCodeBlock",s))}}h(xs,"highlightCode");var gg=class{static{h(this,"CodeHighlighter")}last;highlight(e,t){let i=ng(),r=If(),s=this.last;if(s?.code===e&&s.lang===t&&s.theme===i&&s.languageCount===r)return s.lines;let n=xs(e,t);return this.last={code:e,lang:t,theme:i,languageCount:r,lines:n},n}};function mg(e){let t=e.split(".").pop()?.toLowerCase();return t?{ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",py:"python",rb:"ruby",rs:"rust",go:"go",java:"java",kt:"kotlin",swift:"swift",dart:"dart",groovy:"groovy",gradle:"groovy",nix:"nix",c:"c",h:"c",cpp:"cpp",cc:"cpp",cxx:"cpp",hpp:"cpp",cs:"csharp",php:"php",sh:"bash",bash:"bash",zsh:"bash",fish:"fish",ps1:"powershell",sql:"sql",html:"html",htm:"html",css:"css",scss:"scss",sass:"sass",less:"less",json:"json",yaml:"yaml",yml:"yaml",toml:"toml",xml:"xml",md:"markdown",markdown:"markdown",dockerfile:"dockerfile",makefile:"makefile",cmake:"cmake",lua:"lua",perl:"perl",r:"r",scala:"scala",clj:"clojure",ex:"elixir",exs:"elixir",erl:"erlang",hs:"haskell",ml:"ocaml",vim:"vim",graphql:"graphql",proto:"protobuf",tf:"hcl",hcl:"hcl"}[t]:void 0}h(mg,"getLanguageFromPath");function xg(){return{heading:h(e=>O.fg("mdHeading",e),"heading"),link:h(e=>O.fg("mdLink",e),"link"),linkUrl:h(e=>O.fg("mdLinkUrl",e),"linkUrl"),code:h(e=>O.fg("mdCode",e),"code"),codeBlock:h(e=>O.fg("mdCodeBlock",e),"codeBlock"),codeBlockBorder:h(e=>O.fg("mdCodeBlockBorder",e),"codeBlockBorder"),quote:h(e=>O.fg("mdQuote",e),"quote"),quoteBorder:h(e=>O.fg("mdQuoteBorder",e),"quoteBorder"),hr:h(e=>O.fg("mdHr",e),"hr"),listBullet:h(e=>O.fg("mdListBullet",e),"listBullet"),bold:h(e=>O.bold(e),"bold"),italic:h(e=>O.italic(e),"italic"),underline:h(e=>O.underline(e),"underline"),strikethrough:h(e=>O.strikethrough(e),"strikethrough"),highlightCode:xs}}h(xg,"getMarkdownTheme");function Zo(){return{selectedPrefix:h(e=>O.fg("accent",e),"selectedPrefix"),selectedText:h(e=>O.fg("accent",e),"selectedText"),description:h(e=>O.fg("muted",e),"description"),scrollInfo:h(e=>O.fg("muted",e),"scrollInfo"),noMatch:h(e=>O.fg("muted",e),"noMatch")}}h(Zo,"getSelectListTheme");function bg(){return{borderColor:h(e=>O.fg("border",e),"borderColor"),selectList:Zo(),placeholder:h(e=>O.fg("dim",e),"placeholder")}}h(bg,"getEditorTheme");function yg(){return{label:h((e,t)=>t?O.fg("accent",e):e,"label"),value:h((e,t)=>t?O.fg("accent",e):O.fg("muted",e),"value"),description:h(e=>O.fg("dim",e),"description"),cursor:O.fg("accent","\u2192 "),hint:h(e=>O.fg("dim",e),"hint")}}h(yg,"getSettingsListTheme");function kg(e,t){let i=process.platform==="darwin"&&e.toLowerCase()==="alt"?"option":e;return t.capitalize?i.toLowerCase()==="escape"?"Esc":i.charAt(0).toUpperCase()+i.slice(1):i}h(kg,"formatKeyPart");function bs(e,t={}){return e.split("/").map(i=>i.split("+").map(r=>kg(r,t)).join("+")).join("/")}h(bs,"formatKeyText");function Jo(e,t={}){return e.length===0?"":bs(e.join("/"),t)}h(Jo,"formatKeys");function ea(e){return Jo(se().getKeys(e))}h(ea,"keyText");function wg(e){return Jo(se().getKeys(e),{capitalize:!0})}h(wg,"keyDisplayText");function Sg(e,t){return O.fg("dim",ea(e))+O.fg("muted",` ${t}`)}h(Sg,"keyHint");function Cg(e,t){return O.fg("dim",bs(e))+O.fg("muted",` ${t}`)}h(Cg,"rawKeyHint");export{ll as Box,pe as CURSOR_MARKER,hl as CancellableLoader,gg as CodeHighlighter,$n as CombinedAutocompleteProvider,Ie as Container,Rf as DEFAULT_THEME_SETTING,Tl as Editor,Yp as FS_WATCH_RETRY_DELAY_MS,Il as Image,Ci as Input,qs as Key,ir as KeybindingsManager,Ar as Loader,Vl as Markdown,Kl as MouseRegion,lo as ProcessTerminal,X as SYSTEM_THEME_NAME,Nr as ScrollView,Br as SelectList,ql as SettingsList,Ul as Spacer,rs as THEME_TOKENS,tr as TUI_KEYBINDINGS,Mr as Text,as as Theme,zl as TruncatedText,So as TuiAltScreen,Ao as TuiMainScreen,jl as VStack,fi as Z,St as backgroundAnsi,Qr as closeWatcher,ye as colorToRgb,gr as detectCapabilities,en as dist_exports,wt as foregroundAnsi,bs as formatKeyText,Et as fuzzyFilter,pr as fuzzyMatch,Yf as getAvailableThemes,zo as getAvailableThemesWithPaths,oe as getCapabilities,bg as getEditorTheme,Sr as getImageDimensions,se as getKeybindings,mg as getLanguageFromPath,xg as getMarkdownTheme,Yl as getNativeClipboard,cg as getResolvedThemeColors,Zo as getSelectListTheme,hi as getSelectPageIndex,yg as getSettingsListTheme,mi as getTerminalColorMode,ps as getTerminalTheme,eg as getThemeByName,dg as getThemeExportColors,xs as highlightCode,xi as hyperlink,bi as imageFallback,ti as indexedColor,og as initTheme,sl as isViewportTUI,wg as keyDisplayText,Sg as keyHint,ea as keyText,wf as loadAllHighlightLanguages,ds as loadThemeFromPath,zf as markTerminalColorsPending,Me as matchesKey,Qi as mixColors,ug as onThemeChange,Yo as parseAutoThemeSetting,ve as parseColor,Cg as rawKeyHint,Ut as replaceControlCharacters,tg as resolveThemeSetting,xe as rgbColor,Nn as setCapabilityOverrides,Bl as setImageTranscoder,Js as setKeybindings,lg as setRegisteredThemes,Uf as setTerminalColorScheme,qf as setTerminalColors,ag as setTheme,hg as setThemeInstance,Vf as setThemeJsonValidator,z as sliceByColumn,gs as stopThemeWatcher,O as theme,H as truncateToWidth,C as visibleWidth,Bo as watchWithErrorHandler,me as wrapTextWithAnsi};
@@ -1 +1 @@
1
- var R=Object.defineProperty;var o=(e,r)=>R(e,"name",{value:r,configurable:!0});import{createRequire as b}from"node:module";const S=b(import.meta.url);import{retryProviderRequest as w}from"./chunk-ML5DIOWR.js";import{headersToRecord as q,providerHeadersToRecord as k}from"./chunk-UTB4DTYQ.js";import{calculateCost as x}from"./chunk-K4B5ABCQ.js";import{getIdentityHeaders as E}from"./chunk-SCYK4XNE.js";function $(e,r,a){let i=new Error(`${e} returned ${r.status}`);return i.status=r.status,i.headers=r.headers,i.body=a,i}o($,"httpError");function T(e){let r=new Error(`Request timed out after ${e}ms`);return r.name="TimeoutError",r.status=void 0,r.headers=void 0,r.body="",r}o(T,"timeoutError");function m(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}o(m,"isRecord");function _(e,r,a){if(typeof r!="number"||!Number.isFinite(r))throw new Error(`${e} returned an invalid ${a}`);return r}o(_,"requiredNumber");function j(e,r,a,i){return k(E(e,i),{authorization:`Bearer ${r}`,"content-type":"application/json"},e.headers,a)??{}}o(j,"requestHeaders");async function A(e,r,a,i,t,y){if(!t?.apiKey)throw new Error(`No API key for provider: ${a.provider}`);let h=t.apiKey,u=i,d=await t.onPayload?.(u,a);d!==void 0&&(u=d);let l=t.fetch??globalThis.fetch,{response:c,json:p}=await w(async()=>{let s=t.timeoutMs!==void 0?AbortSignal.timeout(t.timeoutMs):void 0,g=t.signal&&s?AbortSignal.any([t.signal,s]):t.signal??s;try{let n=await l(r,{method:"POST",headers:j(a,h,t.headers,t.identity),body:JSON.stringify(u),signal:g});if(!n.ok)throw $(e,n,await n.text());return{response:n,json:await n.json()}}catch(n){throw s?.aborted&&!t.signal?.aborted?T(t.timeoutMs):n}},{maxRetries:t.maxRetries??2,maxRetryDelayMs:t.maxRetryDelayMs,signal:t.signal,noRetryStatuses:y});return await t.onResponse?.({status:c.status,headers:q(c.headers)},a),p}o(A,"postClassifierRequest");function f(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:0}o(f,"tokenCount");function C(e,r){if(!m(e)||e.input_tokens===void 0&&e.output_tokens===void 0)return;let a=f(e.input_tokens),i=f(e.output_tokens),t={input:a,output:i,cacheRead:0,cacheWrite:0,totalTokens:a+i,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}};return x(r,t),t}o(C,"parseClassifierUsage");export{m as isRecord,C as parseClassifierUsage,A as postClassifierRequest,_ as requiredNumber};
1
+ var R=Object.defineProperty;var o=(e,r)=>R(e,"name",{value:r,configurable:!0});import{createRequire as b}from"node:module";const S=b(import.meta.url);import{retryProviderRequest as w}from"./chunk-ML5DIOWR.js";import{headersToRecord as q,providerHeadersToRecord as k}from"./chunk-UTB4DTYQ.js";import{calculateCost as x}from"./chunk-BIY5HTFI.js";import{getIdentityHeaders as E}from"./chunk-F37JXTCY.js";function $(e,r,a){let i=new Error(`${e} returned ${r.status}`);return i.status=r.status,i.headers=r.headers,i.body=a,i}o($,"httpError");function T(e){let r=new Error(`Request timed out after ${e}ms`);return r.name="TimeoutError",r.status=void 0,r.headers=void 0,r.body="",r}o(T,"timeoutError");function m(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}o(m,"isRecord");function _(e,r,a){if(typeof r!="number"||!Number.isFinite(r))throw new Error(`${e} returned an invalid ${a}`);return r}o(_,"requiredNumber");function j(e,r,a,i){return k(E(e,i),{authorization:`Bearer ${r}`,"content-type":"application/json"},e.headers,a)??{}}o(j,"requestHeaders");async function A(e,r,a,i,t,y){if(!t?.apiKey)throw new Error(`No API key for provider: ${a.provider}`);let h=t.apiKey,u=i,d=await t.onPayload?.(u,a);d!==void 0&&(u=d);let l=t.fetch??globalThis.fetch,{response:c,json:p}=await w(async()=>{let s=t.timeoutMs!==void 0?AbortSignal.timeout(t.timeoutMs):void 0,g=t.signal&&s?AbortSignal.any([t.signal,s]):t.signal??s;try{let n=await l(r,{method:"POST",headers:j(a,h,t.headers,t.identity),body:JSON.stringify(u),signal:g});if(!n.ok)throw $(e,n,await n.text());return{response:n,json:await n.json()}}catch(n){throw s?.aborted&&!t.signal?.aborted?T(t.timeoutMs):n}},{maxRetries:t.maxRetries??2,maxRetryDelayMs:t.maxRetryDelayMs,signal:t.signal,noRetryStatuses:y});return await t.onResponse?.({status:c.status,headers:q(c.headers)},a),p}o(A,"postClassifierRequest");function f(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:0}o(f,"tokenCount");function C(e,r){if(!m(e)||e.input_tokens===void 0&&e.output_tokens===void 0)return;let a=f(e.input_tokens),i=f(e.output_tokens),t={input:a,output:i,cacheRead:0,cacheWrite:0,totalTokens:a+i,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}};return x(r,t),t}o(C,"parseClassifierUsage");export{m as isRecord,C as parseClassifierUsage,A as postClassifierRequest,_ as requiredNumber};