dal-code 1.0.50 → 1.0.52

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 (605) hide show
  1. package/CHANGELOG.md +1050 -5
  2. package/NOTICE +17 -1
  3. package/dist/bundle/chunks/anthropic-messages-NK5NGKAI.js +5 -0
  4. package/dist/bundle/chunks/anthropic.js +74 -0
  5. package/dist/bundle/chunks/azure-openai-responses-VEASENYL.js +1 -0
  6. package/dist/bundle/chunks/bedrock-converse-stream.js +88 -0
  7. package/dist/bundle/chunks/chunk-3YGHTGYM.js +7 -0
  8. package/dist/bundle/chunks/chunk-4LDEEFCY.js +1 -0
  9. package/dist/bundle/chunks/chunk-4UTLMBZZ.js +13 -0
  10. package/dist/bundle/chunks/chunk-4VJJ6NXH.js +8 -0
  11. package/dist/bundle/chunks/chunk-567OJLS7.js +1 -0
  12. package/dist/bundle/chunks/chunk-5AGIVGSV.js +5 -0
  13. package/dist/bundle/chunks/chunk-6EEJ4MZH.js +1 -0
  14. package/dist/bundle/chunks/chunk-6QGV3IWD.js +5 -0
  15. package/dist/bundle/chunks/chunk-723ZGEZ2.js +1 -0
  16. package/dist/bundle/chunks/chunk-7DDKXS2Q.js +1 -0
  17. package/dist/bundle/chunks/chunk-7ZC4UXSL.js +1 -0
  18. package/dist/bundle/chunks/chunk-A5CI3CVQ.js +1 -0
  19. package/dist/bundle/chunks/chunk-AAQZXQA7.js +1 -0
  20. package/dist/bundle/chunks/chunk-ANL2BCIQ.js +15 -0
  21. package/dist/bundle/chunks/chunk-CF5GWZHW.js +30 -0
  22. package/dist/bundle/chunks/chunk-CS4T4O5O.js +1 -0
  23. package/dist/bundle/chunks/chunk-D2WTLI2T.js +19 -0
  24. package/dist/bundle/chunks/chunk-DLKRCASW.js +17 -0
  25. package/dist/bundle/chunks/chunk-EH7SFF47.js +129 -0
  26. package/dist/bundle/chunks/chunk-FFMDRXC4.js +9 -0
  27. package/dist/bundle/chunks/chunk-HEFI7NO7.js +1 -0
  28. package/dist/bundle/chunks/chunk-IEBK4HQA.js +1 -0
  29. package/dist/bundle/chunks/chunk-JXWJOIH4.js +1 -0
  30. package/dist/bundle/chunks/chunk-K7VBBYTT.js +1 -0
  31. package/dist/bundle/chunks/chunk-KJW3E2CB.js +9 -0
  32. package/dist/bundle/chunks/chunk-L2ZPNLYD.js +1 -0
  33. package/dist/bundle/chunks/chunk-LVVZS2NO.js +11 -0
  34. package/dist/bundle/chunks/chunk-ML5DIOWR.js +1 -0
  35. package/dist/bundle/chunks/chunk-ON7ZX67F.js +30 -0
  36. package/dist/bundle/chunks/chunk-OQWPBJCS.js +81 -0
  37. package/dist/bundle/chunks/chunk-P7FPUEYA.js +1 -0
  38. package/dist/bundle/chunks/chunk-PGXDEOVV.js +1 -0
  39. package/dist/bundle/chunks/chunk-PJACZCIR.js +1 -0
  40. package/dist/bundle/chunks/chunk-PRRNXB7S.js +1 -0
  41. package/dist/bundle/chunks/chunk-R47JBGS3.js +1 -0
  42. package/dist/bundle/chunks/chunk-RDZVAGPR.js +1 -0
  43. package/dist/bundle/chunks/chunk-SE42OS3U.js +21 -0
  44. package/dist/bundle/chunks/chunk-TK2WJTRC.js +3 -0
  45. package/dist/bundle/chunks/chunk-TMTOQ7H7.js +1 -0
  46. package/dist/bundle/chunks/chunk-UTB4DTYQ.js +1 -0
  47. package/dist/bundle/chunks/chunk-UVKMBM5X.js +56 -0
  48. package/dist/bundle/chunks/chunk-WIZGOHKY.js +9 -0
  49. package/dist/bundle/chunks/chunk-XAS5HHBW.js +1180 -0
  50. package/dist/bundle/chunks/chunk-XDBGA662.js +43 -0
  51. package/dist/bundle/chunks/chunk-XJFQKN3N.js +2 -0
  52. package/dist/bundle/chunks/chunk-YWNDPXVM.js +25 -0
  53. package/dist/bundle/chunks/chunk-ZG74NES2.js +1 -0
  54. package/dist/bundle/chunks/cli-GXB5WYKG.js +52 -0
  55. package/dist/bundle/chunks/cli-YPE3BB5X.js +30 -0
  56. package/dist/bundle/chunks/cloudflare-workers-ai-system-one-B7WOBGWO.js +1 -0
  57. package/dist/bundle/chunks/codemode-worker.js +480 -0
  58. package/dist/bundle/chunks/dist-D3WIBXB5.js +10 -0
  59. package/dist/bundle/chunks/easter-egg-3d-5TFBCTIS.js +1 -0
  60. package/dist/bundle/chunks/execute-27QCJECT.js +506 -0
  61. package/dist/bundle/chunks/github-copilot.js +1 -0
  62. package/dist/bundle/chunks/google-generative-ai-MBMRBHSZ.js +1 -0
  63. package/dist/bundle/chunks/google-vertex-S2ZFBDPP.js +1 -0
  64. package/dist/bundle/chunks/http-proxy-KF35JLJN.js +1 -0
  65. package/dist/bundle/chunks/https-proxy-agent-LVOO5TPL.js +12 -0
  66. package/dist/bundle/chunks/image-resize-worker.js +1 -0
  67. package/dist/bundle/chunks/jiti-loader-GL4HJFAD.js +20 -0
  68. package/dist/bundle/chunks/jiti-static-loader-2RCDI6B4.js +1 -0
  69. package/dist/bundle/chunks/kimi-coding.js +1 -0
  70. package/dist/bundle/chunks/lib-4AVRLBHM.js +8 -0
  71. package/dist/bundle/chunks/llama-cpp-classify-S4LVGNNY.js +21 -0
  72. package/dist/bundle/chunks/mcp-6LJKGKJQ.js +10 -0
  73. package/dist/bundle/chunks/meta.js +1 -0
  74. package/dist/bundle/chunks/mistral-conversations-C7LUXIEY.js +4 -0
  75. package/dist/bundle/chunks/multipart-parser-FMGQ7342.js +2 -0
  76. package/dist/bundle/chunks/node-AUOGOBCN.js +1 -0
  77. package/dist/bundle/chunks/node-ZTHARAQV.js +15 -0
  78. package/dist/bundle/chunks/office-5OWKTZOA.js +419 -0
  79. package/dist/bundle/chunks/openai-chatgpt.js +74 -0
  80. package/dist/bundle/chunks/openai-codex-responses-YQQXJ24E.js +9 -0
  81. package/dist/bundle/chunks/openai-codex.js +74 -0
  82. package/dist/bundle/chunks/openai-completions-7CMH2FKD.js +6 -0
  83. package/dist/bundle/chunks/openai-decisions-AOGZTREY.js +4 -0
  84. package/dist/bundle/chunks/openai-responses-ZSOGZ3MK.js +3 -0
  85. package/dist/bundle/chunks/openrouter-images-AHXST2TH.js +1 -0
  86. package/dist/bundle/chunks/openrouter.js +74 -0
  87. package/dist/bundle/chunks/pi-messages-QERJLMZ6.js +7 -0
  88. package/dist/bundle/chunks/radius.js +74 -0
  89. package/dist/bundle/chunks/review-5G56KIWY.js +80 -0
  90. package/dist/bundle/chunks/rewind-2OYLDDHH.js +8 -0
  91. package/dist/bundle/chunks/router-776Z7G7G.js +3 -0
  92. package/dist/bundle/chunks/runtime-NKPT25KD.js +1 -0
  93. package/dist/bundle/chunks/sdk-TVC4GDUX.js +1 -0
  94. package/dist/bundle/chunks/src-QKGKDFSU.js +3 -0
  95. package/dist/bundle/chunks/sync-JBDC3YBK.js +7 -0
  96. package/dist/bundle/chunks/typesafe-system-one-MMNGGQ46.js +1 -0
  97. package/dist/bundle/chunks/usage-BDCIALHO.js +1 -0
  98. package/dist/bundle/chunks/virtual-modules-25RQ6XTV.js +1 -0
  99. package/dist/bundle/chunks/xai.js +1 -0
  100. package/dist/bundle/cli-runtime.js +2 -0
  101. package/dist/bundle/cli.js +2 -0
  102. package/dist/bundle/index.js +1 -0
  103. package/dist/bundle/rpc-entry.js +2 -0
  104. package/dist/cli/args.js +1 -1
  105. package/dist/cli/auth-command.js +9 -6
  106. package/dist/cli/auth-login.js +2 -0
  107. package/dist/cli/auth-logout.js +1 -0
  108. package/dist/cli/auth-terminal.js +5 -0
  109. package/dist/cli/config-selector.js +1 -1
  110. package/dist/config.d.ts +5 -0
  111. package/dist/config.js +1 -1
  112. package/dist/core/agent-session-runtime.js +1 -1
  113. package/dist/core/agent-session-services.js +1 -1
  114. package/dist/core/agent-session.d.ts +8 -1
  115. package/dist/core/agent-session.js +12 -9
  116. package/dist/core/auth-storage.js +1 -1
  117. package/dist/core/bash-executor.js +1 -1
  118. package/dist/core/bug-report.js +3 -3
  119. package/dist/core/cache-warmer.d.ts +3 -15
  120. package/dist/core/cache-warmer.js +1 -1
  121. package/dist/core/compaction/branch-summarization.d.ts +3 -2
  122. package/dist/core/compaction/branch-summarization.js +5 -5
  123. package/dist/core/compaction/compaction.d.ts +1 -0
  124. package/dist/core/compaction/compaction.js +14 -14
  125. package/dist/core/compaction/tool-output-pruning.js +1 -1
  126. package/dist/core/compaction/utils.d.ts +0 -1
  127. package/dist/core/compaction/utils.js +8 -8
  128. package/dist/core/exec.d.ts +2 -0
  129. package/dist/core/exec.js +1 -1
  130. package/dist/core/export-html/template.css +9 -0
  131. package/dist/core/export-html/template.js +46 -39
  132. package/dist/core/export-html/tool-renderer.js +1 -1
  133. package/dist/core/extensions/index.d.ts +1 -1
  134. package/dist/core/extensions/loader.js +1 -1
  135. package/dist/core/extensions/pi-ai-extension-view.js +1 -0
  136. package/dist/core/extensions/runner.js +1 -1
  137. package/dist/core/extensions/types.d.ts +25 -7
  138. package/dist/core/extensions/virtual-modules.js +1 -1
  139. package/dist/core/keybindings.d.ts +1 -1
  140. package/dist/core/keybindings.js +1 -1
  141. package/dist/core/mcp-servers.d.ts +6 -17
  142. package/dist/core/mcp-servers.js +1 -1
  143. package/dist/core/model-config.d.ts +1912 -2211
  144. package/dist/core/model-config.js +4 -4
  145. package/dist/core/model-resolver.js +1 -1
  146. package/dist/core/model-runtime.d.ts +1 -0
  147. package/dist/core/model-runtime.js +1 -1
  148. package/dist/core/package-manager.d.ts +10 -1
  149. package/dist/core/package-manager.js +2 -2
  150. package/dist/core/pi-ai-schemas.js +1 -0
  151. package/dist/core/pi-manifest.js +1 -1
  152. package/dist/core/preferred-providers.js +1 -0
  153. package/dist/core/project-trust.js +2 -2
  154. package/dist/core/prompt-templates.js +2 -2
  155. package/dist/core/provider-composer.js +1 -1
  156. package/dist/core/provider-matching.js +1 -0
  157. package/dist/core/radius-mcp.js +1 -0
  158. package/dist/core/remote-catalog-provider.js +1 -1
  159. package/dist/core/resource-loader.d.ts +3 -1
  160. package/dist/core/resource-loader.js +1 -1
  161. package/dist/core/runtime-credentials.js +1 -1
  162. package/dist/core/sdk.js +1 -1
  163. package/dist/core/session-cwd.js +3 -7
  164. package/dist/core/session-manager.d.ts +1 -0
  165. package/dist/core/session-manager.js +12 -12
  166. package/dist/core/settings-defaults.js +1 -1
  167. package/dist/core/settings-manager.d.ts +4 -0
  168. package/dist/core/settings-manager.js +1 -1
  169. package/dist/core/settings-schema.d.ts +4 -2
  170. package/dist/core/settings-schema.js +1 -1
  171. package/dist/core/skills.js +3 -3
  172. package/dist/core/slash-commands.js +1 -1
  173. package/dist/core/source-info.d.ts +8 -0
  174. package/dist/core/source-info.js +1 -1
  175. package/dist/core/system-prompt.js +3 -3
  176. package/dist/core/tools/bash.d.ts +2 -2
  177. package/dist/core/tools/bash.js +15 -15
  178. package/dist/core/tools/edit-diff.d.ts +9 -4
  179. package/dist/core/tools/edit-diff.js +22 -15
  180. package/dist/core/tools/edit.d.ts +3 -3
  181. package/dist/core/tools/edit.js +3 -3
  182. package/dist/core/tools/find.d.ts +2 -2
  183. package/dist/core/tools/find.js +10 -11
  184. package/dist/core/tools/grep.d.ts +3 -3
  185. package/dist/core/tools/grep.js +8 -12
  186. package/dist/core/tools/ls.d.ts +2 -2
  187. package/dist/core/tools/ls.js +4 -4
  188. package/dist/core/tools/powershell.js +6 -2
  189. package/dist/core/tools/read.d.ts +5 -2
  190. package/dist/core/tools/read.js +20 -19
  191. package/dist/core/tools/render-utils.js +5 -5
  192. package/dist/core/tools/renderers/write.js +10 -10
  193. package/dist/core/tools/tool-definition-wrapper.d.ts +11 -0
  194. package/dist/core/tools/truncate.d.ts +2 -8
  195. package/dist/core/tools/truncate.js +10 -10
  196. package/dist/core/tools/write.d.ts +2 -2
  197. package/dist/core/trust-manager.js +2 -2
  198. package/dist/core/usage-totals.js +1 -1
  199. package/dist/dal/builtins.js +2 -2
  200. package/dist/dal/manifest.d.ts +1 -0
  201. package/dist/dal/manifest.js +1 -1
  202. package/dist/dal/safety-net.js +11 -3
  203. package/dist/extensions/codemode/execute.js +12 -12
  204. package/dist/extensions/codemode/renderer.js +6 -6
  205. package/dist/extensions/codemode/tool.d.ts +2 -1
  206. package/dist/extensions/codemode/tool.js +11 -10
  207. package/dist/extensions/llama/client.js +5 -5
  208. package/dist/extensions/llama/ui.js +2 -2
  209. package/dist/extensions/mcp/cli.js +21 -19
  210. package/dist/extensions/mcp/config.js +2 -2
  211. package/dist/extensions/mcp/index.js +7 -7
  212. package/dist/extensions/mcp/oauth.d.ts +3 -22
  213. package/dist/extensions/mcp/oauth.js +2 -2
  214. package/dist/extensions/mcp/resources.d.ts +1 -1
  215. package/dist/extensions/mcp/resources.js +1 -1
  216. package/dist/extensions/mcp/runtime.d.ts +2 -2
  217. package/dist/extensions/mcp/runtime.js +3 -3
  218. package/dist/extensions/mcp/tools.d.ts +1 -8
  219. package/dist/extensions/mcp/tools.js +4 -9
  220. package/dist/extensions/mcp/ui.js +1 -1
  221. package/dist/extensions/tool-search/tool.js +4 -4
  222. package/dist/index.d.ts +2 -2
  223. package/dist/main.js +4 -4
  224. package/dist/modes/interactive/components/assistant-message.d.ts +4 -1
  225. package/dist/modes/interactive/components/assistant-message.js +2 -2
  226. package/dist/modes/interactive/components/branch-summary-message.d.ts +5 -1
  227. package/dist/modes/interactive/components/branch-summary-message.js +2 -2
  228. package/dist/modes/interactive/components/compaction-summary-message.d.ts +5 -1
  229. package/dist/modes/interactive/components/compaction-summary-message.js +2 -2
  230. package/dist/modes/interactive/components/config-selector.js +1 -1
  231. package/dist/modes/interactive/components/custom-editor.js +1 -1
  232. package/dist/modes/interactive/components/custom-entry.js +1 -1
  233. package/dist/modes/interactive/components/custom-message.d.ts +5 -2
  234. package/dist/modes/interactive/components/custom-message.js +3 -3
  235. package/dist/modes/interactive/components/diff.js +3 -3
  236. package/dist/modes/interactive/components/extension-editor.d.ts +1 -0
  237. package/dist/modes/interactive/components/extension-editor.js +1 -1
  238. package/dist/modes/interactive/components/extension-selector.js +2 -2
  239. package/dist/modes/interactive/components/login-dialog.d.ts +5 -0
  240. package/dist/modes/interactive/components/login-dialog.js +1 -1
  241. package/dist/modes/interactive/components/markdown-transform.js +1 -1
  242. package/dist/modes/interactive/components/mermaid.js +4 -4
  243. package/dist/modes/interactive/components/model-selector.d.ts +1 -0
  244. package/dist/modes/interactive/components/model-selector.js +2 -2
  245. package/dist/modes/interactive/components/oauth-selector.d.ts +2 -1
  246. package/dist/modes/interactive/components/oauth-selector.js +1 -1
  247. package/dist/modes/interactive/components/provider-brand.js +1 -0
  248. package/dist/modes/interactive/components/radius-login-selector.js +1 -1
  249. package/dist/modes/interactive/components/scoped-models-selector.d.ts +1 -0
  250. package/dist/modes/interactive/components/scoped-models-selector.js +1 -1
  251. package/dist/modes/interactive/components/session-selector-search.js +1 -1
  252. package/dist/modes/interactive/components/session-selector.d.ts +2 -1
  253. package/dist/modes/interactive/components/session-selector.js +2 -2
  254. package/dist/modes/interactive/components/settings-submenu.js +1 -1
  255. package/dist/modes/interactive/components/skill-invocation-message.d.ts +5 -1
  256. package/dist/modes/interactive/components/skill-invocation-message.js +2 -2
  257. package/dist/modes/interactive/components/tool-execution.d.ts +1 -0
  258. package/dist/modes/interactive/components/tool-execution.js +3 -3
  259. package/dist/modes/interactive/components/tree-selector.d.ts +2 -0
  260. package/dist/modes/interactive/components/tree-selector.js +1 -1
  261. package/dist/modes/interactive/components/user-message-selector.d.ts +1 -0
  262. package/dist/modes/interactive/components/user-message-selector.js +1 -1
  263. package/dist/modes/interactive/components/user-message.d.ts +2 -1
  264. package/dist/modes/interactive/components/user-message.js +1 -1
  265. package/dist/modes/interactive/external-editor.js +3 -3
  266. package/dist/modes/interactive/interactive-mode.d.ts +10 -1
  267. package/dist/modes/interactive/interactive-mode.js +45 -40
  268. package/dist/modes/interactive/model-search.js +1 -1
  269. package/dist/modes/interactive/theme/theme.d.ts +4 -0
  270. package/dist/modes/interactive/theme/theme.js +3 -6
  271. package/dist/modes/print-mode.js +7 -7
  272. package/dist/modes/rpc/rpc-mode.js +1 -1
  273. package/dist/node_modules/@dalcode/dal-advisor/package.json +3 -3
  274. package/dist/node_modules/@dalcode/dal-awake/package.json +2 -2
  275. package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
  276. package/dist/node_modules/@dalcode/dal-capabilities/package.json +4 -4
  277. package/dist/node_modules/@dalcode/dal-codeindex/package.json +2 -2
  278. package/dist/node_modules/@dalcode/dal-compat/package.json +3 -3
  279. package/dist/node_modules/@dalcode/dal-dap/package.json +2 -2
  280. package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
  281. package/dist/node_modules/@dalcode/dal-goal/package.json +3 -3
  282. package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
  283. package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
  284. package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
  285. package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
  286. package/dist/node_modules/@dalcode/dal-learn/package.json +5 -2
  287. package/dist/node_modules/@dalcode/dal-learn/src/engine.js +4 -4
  288. package/dist/node_modules/@dalcode/dal-learn/src/extract.js +31 -5
  289. package/dist/node_modules/@dalcode/dal-learn/src/index.js +16 -16
  290. package/dist/node_modules/@dalcode/dal-learn/src/learn-mode.js +1 -0
  291. package/dist/node_modules/@dalcode/dal-learn/src/lesson-events.js +1 -0
  292. package/dist/node_modules/@dalcode/dal-learn/src/lessons.js +4 -3
  293. package/dist/node_modules/@dalcode/dal-learn/src/project-map.js +2 -2
  294. package/dist/node_modules/@dalcode/dal-learn/src/safety.js +2 -2
  295. package/dist/node_modules/@dalcode/dal-learn/src/signals.js +6 -5
  296. package/dist/node_modules/@dalcode/dal-learn/src/store.js +3 -2
  297. package/dist/node_modules/@dalcode/dal-lsp/package.json +4 -4
  298. package/dist/node_modules/@dalcode/dal-mcp/package.json +6 -6
  299. package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
  300. package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +4 -3
  301. package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
  302. package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +4 -3
  303. package/dist/node_modules/@dalcode/dal-plugins/package.json +4 -4
  304. package/dist/node_modules/@dalcode/dal-recall/package.json +2 -2
  305. package/dist/node_modules/@dalcode/dal-remote/package.json +2 -2
  306. package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
  307. package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
  308. package/dist/node_modules/@dalcode/dal-router/package.json +6 -6
  309. package/dist/node_modules/@dalcode/dal-rtk/package.json +2 -2
  310. package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
  311. package/dist/node_modules/@dalcode/dal-statusline/package.json +2 -2
  312. package/dist/node_modules/@dalcode/dal-structured/package.json +2 -2
  313. package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
  314. package/dist/node_modules/@dalcode/dal-sync/package.json +4 -4
  315. package/dist/node_modules/@dalcode/dal-sync/src/core.js +2 -2
  316. package/dist/node_modules/@dalcode/dal-telemetry/package.json +4 -4
  317. package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
  318. package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
  319. package/dist/node_modules/@dalcode/dal-usage/package.json +2 -2
  320. package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
  321. package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
  322. package/dist/node_modules/@dalcode/dal-workflow/src/todo-snapshot.js +2 -2
  323. package/dist/node_modules/@dalcode/dal-workflow/src/todo.js +3 -3
  324. package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
  325. package/dist/node_modules/@earendil-works/pi-agent-core/README.md +8 -6
  326. package/dist/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts +1 -1
  327. package/dist/node_modules/@earendil-works/pi-agent-core/dist/proxy.js +2 -2
  328. package/dist/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +8 -5
  329. package/dist/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
  330. package/dist/node_modules/@earendil-works/pi-ai/README.md +58 -39
  331. package/dist/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +5 -5
  332. package/dist/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +1 -1
  333. package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +1 -1
  334. package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.lazy.d.ts +1 -0
  335. package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.lazy.js +1 -1
  336. package/dist/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js +1 -1
  337. package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js +1 -1
  338. package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js +2 -2
  339. package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js +1 -1
  340. package/dist/node_modules/@earendil-works/pi-ai/dist/api/lazy.d.ts +1 -1
  341. package/dist/node_modules/@earendil-works/pi-ai/dist/api/lazy.js +1 -1
  342. package/dist/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +4 -4
  343. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +1 -1
  344. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts +2 -1
  345. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +5 -5
  346. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +9 -9
  347. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +3 -3
  348. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js +1 -1
  349. package/dist/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts +2 -0
  350. package/dist/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +3 -3
  351. package/dist/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js +1 -1
  352. package/dist/node_modules/@earendil-works/pi-ai/dist/api/strict-tool-limits.js +1 -0
  353. package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/kimi-coding.js +1 -1
  354. package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.js +1 -1
  355. package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/meta.js +1 -1
  356. package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/radius.js +1 -1
  357. package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/trusted-url.js +1 -0
  358. package/dist/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts +2 -0
  359. package/dist/node_modules/@earendil-works/pi-ai/dist/cache-warming.d.ts +21 -0
  360. package/dist/node_modules/@earendil-works/pi-ai/dist/cache-warming.js +1 -0
  361. package/dist/node_modules/@earendil-works/pi-ai/dist/cli.js +5 -5
  362. package/dist/node_modules/@earendil-works/pi-ai/dist/compat/extension-oauth-types.d.ts +2 -0
  363. package/dist/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +1 -1
  364. package/dist/node_modules/@earendil-works/pi-ai/dist/index.d.ts +3 -3
  365. package/dist/node_modules/@earendil-works/pi-ai/dist/index.js +1 -1
  366. package/dist/node_modules/@earendil-works/pi-ai/dist/lazy-bedrock-provider.js +1 -0
  367. package/dist/node_modules/@earendil-works/pi-ai/dist/lazy-oauth.js +1 -0
  368. package/dist/node_modules/@earendil-works/pi-ai/dist/models.d.ts +1 -0
  369. package/dist/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +4 -0
  370. package/dist/node_modules/@earendil-works/pi-ai/dist/models.generated.js +1 -1
  371. package/dist/node_modules/@earendil-works/pi-ai/dist/models.js +1 -1
  372. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/all.js +1 -1
  373. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.d.ts +485 -498
  374. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.js +1 -1
  375. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  376. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
  377. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -1
  378. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/azure.json +1 -1
  379. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
  380. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  381. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
  382. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
  383. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  384. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/google-vertex.json +1 -1
  385. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
  386. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
  387. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/kimi-coding.json +1 -1
  388. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/meta.json +1 -1
  389. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
  390. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai-cn.json +1 -1
  391. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai.json +1 -1
  392. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
  393. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -1
  394. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
  395. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
  396. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  397. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  398. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-cn.json +1 -1
  399. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-individual-cn.json +1 -0
  400. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-individual.json +1 -1
  401. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.json +1 -1
  402. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
  403. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
  404. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  405. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xai.json +1 -1
  406. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-ams.json +1 -1
  407. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-cn.json +1 -1
  408. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-sgp.json +1 -1
  409. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi.json +1 -1
  410. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
  411. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
  412. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/faux.js +5 -5
  413. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.js +1 -1
  414. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.d.ts +65 -65
  415. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.js +1 -1
  416. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.js +1 -1
  417. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-individual-cn.js +1 -0
  418. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-individual-cn.models.d.ts +5 -0
  419. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-individual-cn.models.js +1 -0
  420. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/radius-config.js +1 -1
  421. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/schema-builders.js +1 -0
  422. package/dist/node_modules/@earendil-works/pi-ai/dist/telemetry.js +1 -1
  423. package/dist/node_modules/@earendil-works/pi-ai/dist/types.d.ts +4 -3
  424. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/error-body.js +1 -1
  425. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/openrouter-cost.js +1 -0
  426. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +1 -1
  427. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +1 -1
  428. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/streaming-json.d.ts +26 -0
  429. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/streaming-json.js +4 -0
  430. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/{typebox-helpers.d.ts → string-enum.d.ts} +2 -2
  431. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/string-enum.js +1 -0
  432. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/text.d.ts +1 -0
  433. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/text.js +2 -2
  434. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/validation.js +4 -4
  435. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.d.ts +1 -1
  436. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.js +1 -1
  437. package/dist/node_modules/@earendil-works/pi-ai/package.json +12 -5
  438. package/dist/node_modules/@earendil-works/pi-codemode/README.md +2 -2
  439. package/dist/node_modules/@earendil-works/pi-codemode/dist/declarations.d.ts +1 -0
  440. package/dist/node_modules/@earendil-works/pi-codemode/dist/declarations.js +4 -4
  441. package/dist/node_modules/@earendil-works/pi-codemode/dist/index.d.ts +1 -1
  442. package/dist/node_modules/@earendil-works/pi-codemode/dist/index.js +1 -1
  443. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/prelude-source.js +2 -0
  444. package/dist/node_modules/@earendil-works/pi-codemode/package.json +1 -1
  445. package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
  446. package/dist/node_modules/@earendil-works/pi-mcp/CHANGELOG.md +32 -0
  447. package/dist/node_modules/@earendil-works/pi-mcp/README.md +60 -5
  448. package/dist/node_modules/@earendil-works/pi-mcp/dist/config.d.ts +45 -0
  449. package/dist/node_modules/@earendil-works/pi-mcp/dist/config.js +1 -0
  450. package/dist/node_modules/@earendil-works/pi-mcp/dist/index.d.ts +5 -0
  451. package/dist/node_modules/@earendil-works/pi-mcp/dist/index.js +1 -1
  452. package/dist/node_modules/@earendil-works/pi-mcp/dist/input-schema.d.ts +1 -0
  453. package/dist/node_modules/@earendil-works/pi-mcp/dist/input-schema.js +1 -0
  454. package/dist/node_modules/@earendil-works/pi-mcp/dist/naming.d.ts +2 -0
  455. package/dist/node_modules/@earendil-works/pi-mcp/dist/naming.js +1 -0
  456. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/auth-provider.d.ts +18 -0
  457. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/auth-provider.js +1 -0
  458. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/callback.js +1 -1
  459. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/client-settings.d.ts +42 -0
  460. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/client-settings.js +1 -0
  461. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.d.ts +3 -0
  462. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.js +1 -1
  463. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/flow.d.ts +2 -0
  464. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/flow.js +1 -1
  465. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/index.d.ts +5 -1
  466. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/index.js +1 -1
  467. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/loopback.d.ts +22 -0
  468. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/loopback.js +1 -0
  469. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/sign-in.d.ts +28 -0
  470. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/sign-in.js +1 -0
  471. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/types.d.ts +1 -0
  472. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/types.js +1 -1
  473. package/dist/node_modules/@earendil-works/pi-mcp/dist/output-limit.d.ts +8 -0
  474. package/dist/node_modules/@earendil-works/pi-mcp/dist/output-limit.js +11 -0
  475. package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/lines.js +1 -0
  476. package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/pipe.d.ts +34 -0
  477. package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/pipe.js +2 -0
  478. package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/stdio.d.ts +1 -4
  479. package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/stdio.js +2 -2
  480. package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/streamable-http.js +6 -4
  481. package/dist/node_modules/@earendil-works/pi-mcp/package.json +2 -2
  482. package/dist/node_modules/@earendil-works/pi-schema/CHANGELOG.md +37 -0
  483. package/dist/node_modules/@earendil-works/pi-schema/LICENSE +21 -0
  484. package/dist/node_modules/@earendil-works/pi-schema/README.md +319 -0
  485. package/dist/node_modules/@earendil-works/pi-schema/THIRD_PARTY_NOTICES/typebox-LICENSE +23 -0
  486. package/dist/node_modules/@earendil-works/pi-schema/dist/annotations.js +1 -0
  487. package/dist/node_modules/@earendil-works/pi-schema/dist/builders.d.ts +89 -0
  488. package/dist/node_modules/@earendil-works/pi-schema/dist/builders.js +1 -0
  489. package/dist/node_modules/@earendil-works/pi-schema/dist/checks.d.ts +51 -0
  490. package/dist/node_modules/@earendil-works/pi-schema/dist/checks.js +1 -0
  491. package/dist/node_modules/@earendil-works/pi-schema/dist/coerce.js +1 -0
  492. package/dist/node_modules/@earendil-works/pi-schema/dist/compiler.js +1 -0
  493. package/dist/node_modules/@earendil-works/pi-schema/dist/explain.js +1 -0
  494. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/index.js +1 -0
  495. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/date.js +1 -0
  496. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/date_time.js +1 -0
  497. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/duration.js +1 -0
  498. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/email.js +1 -0
  499. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/hostname.js +1 -0
  500. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idn_email.js +1 -0
  501. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idn_hostname.js +1 -0
  502. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/format/bidi.js +1 -0
  503. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/format/puny.js +1 -0
  504. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/hostname.js +1 -0
  505. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/idn-hostname.js +1 -0
  506. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/index.js +1 -0
  507. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/label/ascii.js +1 -0
  508. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/label/puny.js +1 -0
  509. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/label/unicode.js +1 -0
  510. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/pattern/pattern.js +1 -0
  511. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/ipv4.js +1 -0
  512. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/ipv6.js +1 -0
  513. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/iri.js +1 -0
  514. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/iri_reference.js +1 -0
  515. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/json_pointer.js +1 -0
  516. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/json_pointer_uri_fragment.js +1 -0
  517. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/regex.js +1 -0
  518. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/relative_json_pointer.js +1 -0
  519. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/time.js +1 -0
  520. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/uri.js +1 -0
  521. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/uri_reference.js +1 -0
  522. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/uri_template.js +1 -0
  523. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/url.js +1 -0
  524. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/uuid.js +1 -0
  525. package/dist/node_modules/@earendil-works/pi-schema/dist/index.d.ts +4 -0
  526. package/dist/node_modules/@earendil-works/pi-schema/dist/index.js +1 -0
  527. package/dist/node_modules/@earendil-works/pi-schema/dist/resolver.js +1 -0
  528. package/dist/node_modules/@earendil-works/pi-schema/dist/shared.js +1 -0
  529. package/dist/node_modules/@earendil-works/pi-schema/dist/typebox-static.d.ts +54 -0
  530. package/dist/node_modules/@earendil-works/pi-schema/dist/typebox-static.js +0 -0
  531. package/dist/node_modules/@earendil-works/pi-schema/dist/types.d.ts +25 -0
  532. package/dist/node_modules/@earendil-works/pi-schema/dist/types.js +0 -0
  533. package/dist/node_modules/@earendil-works/pi-schema/dist/validator.d.ts +20 -0
  534. package/dist/node_modules/@earendil-works/pi-schema/dist/validator.js +1 -0
  535. package/dist/node_modules/@earendil-works/pi-schema/package.json +43 -0
  536. package/dist/node_modules/@earendil-works/pi-telemetry/dist/index.d.ts +1 -1
  537. package/dist/node_modules/@earendil-works/pi-telemetry/dist/index.js +1 -1
  538. package/dist/node_modules/@earendil-works/pi-telemetry/dist/memory.d.ts +1 -0
  539. package/dist/node_modules/@earendil-works/pi-telemetry/dist/memory.js +1 -1
  540. package/dist/node_modules/@earendil-works/pi-telemetry/dist/render.js +2 -2
  541. package/dist/node_modules/@earendil-works/pi-telemetry/package.json +3 -1
  542. package/dist/node_modules/@earendil-works/pi-tui/README.md +2 -0
  543. package/dist/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts +1 -0
  544. package/dist/node_modules/@earendil-works/pi-tui/dist/components/editor.js +3 -3
  545. package/dist/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts +4 -0
  546. package/dist/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +11 -10
  547. package/dist/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts +1 -0
  548. package/dist/node_modules/@earendil-works/pi-tui/dist/components/select-list.js +1 -1
  549. package/dist/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts +1 -0
  550. package/dist/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js +1 -1
  551. package/dist/node_modules/@earendil-works/pi-tui/dist/components/text.js +1 -1
  552. package/dist/node_modules/@earendil-works/pi-tui/dist/fuzzy.js +1 -1
  553. package/dist/node_modules/@earendil-works/pi-tui/dist/index.d.ts +2 -2
  554. package/dist/node_modules/@earendil-works/pi-tui/dist/index.js +1 -1
  555. package/dist/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +1 -0
  556. package/dist/node_modules/@earendil-works/pi-tui/dist/keybindings.js +1 -1
  557. package/dist/node_modules/@earendil-works/pi-tui/dist/keys.js +5 -5
  558. package/dist/node_modules/@earendil-works/pi-tui/dist/layout.js +1 -1
  559. package/dist/node_modules/@earendil-works/pi-tui/dist/program-status.js +1 -1
  560. package/dist/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +1 -0
  561. package/dist/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +1 -1
  562. package/dist/node_modules/@earendil-works/pi-tui/dist/terminal.js +1 -1
  563. package/dist/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts +1 -1
  564. package/dist/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js +4 -4
  565. package/dist/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.js +13 -13
  566. package/dist/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +1 -0
  567. package/dist/node_modules/@earendil-works/pi-tui/dist/tui.js +2 -2
  568. package/dist/node_modules/@earendil-works/pi-tui/dist/utils.d.ts +1 -0
  569. package/dist/node_modules/@earendil-works/pi-tui/dist/utils.js +1 -1
  570. package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
  571. package/dist/package-manager-cli.js +17 -16
  572. package/dist/utils/ansi.js +1 -1
  573. package/dist/utils/changelog.js +3 -3
  574. package/dist/utils/clipboard-command.js +1 -1
  575. package/dist/utils/image-resize-core.js +1 -1
  576. package/dist/utils/image-resize.js +1 -1
  577. package/dist/utils/open-browser.js +1 -1
  578. package/dist/utils/paths.js +1 -1
  579. package/dist/utils/shell.js +3 -3
  580. package/dist/utils/syntax-highlight.js +4 -4
  581. package/dist/utils/terminal-question.js +1 -0
  582. package/dist/utils/tools-manager.js +1 -1
  583. package/dist/utils/web-url.js +1 -0
  584. package/examples/extensions/README.md +2 -1
  585. package/examples/extensions/custom-provider-gitlab-duo/package.json +14 -14
  586. package/examples/extensions/debug-provider.ts +2 -2
  587. package/examples/extensions/gondolin/package-lock.json +19 -29
  588. package/examples/extensions/gondolin/package.json +2 -2
  589. package/examples/extensions/plan-mode/index.ts +20 -9
  590. package/examples/extensions/plan-mode/utils.ts +42 -16
  591. package/examples/extensions/preset.ts +2 -0
  592. package/examples/extensions/reload-runtime.ts +17 -5
  593. package/examples/extensions/subagent/README.md +14 -11
  594. package/examples/extensions/subagent/index.ts +392 -171
  595. package/examples/extensions/todo.ts +7 -0
  596. package/examples/extensions/tools.ts +2 -0
  597. package/examples/extensions/with-deps/package-lock.json +2 -2
  598. package/examples/extensions/with-deps/package.json +20 -20
  599. package/examples/tsconfig.json +208 -0
  600. package/npm-shrinkwrap.json +407 -383
  601. package/package.json +6 -7
  602. package/examples/extensions/sandbox/index.ts +0 -327
  603. package/examples/extensions/sandbox/package-lock.json +0 -92
  604. package/examples/extensions/sandbox/package.json +0 -19
  605. /package/dist/node_modules/@earendil-works/pi-mcp/{LICENSES → THIRD_PARTY_NOTICES}/modelcontextprotocol-typescript-sdk.txt +0 -0
@@ -1 +1 @@
1
- var D=Object.defineProperty;var d=(r,e)=>D(r,"name",{value:e,configurable:!0});import{DEFAULT_MAX_AGENT_RETRY_DELAY_MS as N}from"@earendil-works/pi-ai";import{randomUUID as R}from"crypto";import{existsSync as w,mkdirSync as W,readFileSync as _}from"fs";import{dirname as U,join as f}from"path";import $ from"proper-lockfile";import{CONFIG_DIR_NAME as C,getAgentDir as H}from"../config.js";import{normalizePath as x,resolvePath as p}from"../utils/paths.js";import{stripBom as T}from"../utils/text.js";import{DEFAULT_FIRST_TOKEN_TIMEOUT_MS as B,DEFAULT_HTTP_IDLE_TIMEOUT_MS as V,parseHttpIdleTimeoutMs as F}from"./http-dispatcher.js";import{SETTINGS_DEFAULTS as l}from"./settings-defaults.js";import{declaredDataFormat as S,reportNewerDataFormat as q,writeFileAtomicSync as G}from"./shared-data.js";import{DEFAULT_STALL_WATCHDOG_MS as K}from"./stall-watchdog.js";const X=8e4,z={reserveTokens:16384,keepRecentTokens:2e4,maxContextTokens:X},Q=32e3,J=5,Y=["off","streaming","idle"];function y(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}d(y,"isMergeableObject");function L(r,e){const t={...r};for(const s of Object.keys(e)){const i=e[s];if(i===void 0)continue;const o=r[s];t[s]=y(o)&&y(i)?L(o,i):i}return t}d(L,"deepMergeObjects");const Z=["read","bash","edit","write"];function b(r){return typeof r=="string"&&(r.startsWith("+")||r.startsWith("-"))}d(b,"isToolModifier");function ke(r){const e=r.filter(b);if(e.length===0)return;if(e.length<r.length)return"tool names cannot be mixed with +name or -name entries";const t=e.find(s=>s.includes("*"));if(t)return`+name and -name entries take exact tool names, not patterns: ${t}`}d(ke,"getToolListError");function ee(r,e){const t=[...r];for(const s of e){if(!b(s))continue;const i=s.slice(1),o=t.indexOf(i);s.startsWith("+")&&o===-1&&i?t.push(i):s.startsWith("-")&&o!==-1&&t.splice(o,1)}return t}d(ee,"applyToolModifiers");function te(r,e){return e===void 0?r:!Array.isArray(r)||!Array.isArray(e)||!e.every(b)?e:[...r,...e]}d(te,"mergeDefaultTools");function se(r){const e=r.filter(t=>!b(t));return ee(e.length>0||r.length===0?e:Z,r)}d(se,"resolveDefaultTools");function c(r,e){const t=L(r,e),s=te(r.defaultTools,e.defaultTools);return s===void 0?t:{...t,defaultTools:s}}d(c,"deepMergeSettings");function k(r,e){const t=F(r);if(t!==void 0)return t;if(r!==void 0)throw new Error(`Invalid ${e} setting: ${String(r)}`)}d(k,"parseTimeoutSetting");const M=1,v=["enableAnalytics","trackingId"];function ie(r){let e;try{e=JSON.parse(T(r))}catch{return}if(typeof e!="object"||e===null||Array.isArray(e))return;const t=e;if(!(S(t)>M)&&v.some(s=>s in t)){for(const s of v)delete t[s];return JSON.stringify(t,null,2)}}d(ie,"withoutRetiredKeys");function P(r,e,t){return{scope:r,...t?{path:t}:{},error:e instanceof Error?e:new Error(String(e))}}d(P,"toSettingsError");class re{static{d(this,"FileSettingsStorage")}globalSettingsPath;projectSettingsPath;constructor(e,t){const s=p(e),i=p(t);this.globalSettingsPath=f(i,"settings.json"),this.projectSettingsPath=f(s,C,"settings.json")}acquireLockSyncWithRetry(e){let i;for(let o=1;o<=100;o++)try{return $.lockSync(e,{realpath:!1})}catch(n){if((typeof n=="object"&&n!==null&&"code"in n?String(n.code):void 0)!=="ELOCKED"||o===100)throw n;i=n;const h=Date.now();for(;Date.now()-h<20;);}throw i??new Error("Failed to acquire settings lock")}withLock(e,t){const s=e==="global"?this.globalSettingsPath:this.projectSettingsPath,i=U(s);let o;try{const n=w(s);n&&(o=this.acquireLockSyncWithRetry(s));const a=n?_(s,"utf-8"):void 0,h=t(a);h!==void 0&&(w(i)||W(i,{recursive:!0}),o||(o=this.acquireLockSyncWithRetry(s)),G(s,h))}finally{o&&o()}}}class oe{static{d(this,"InMemorySettingsStorage")}global;project;withLock(e,t){const s=e==="global"?this.global:this.project,i=t(s);i!==void 0&&(e==="global"?this.global=i:this.project=i)}}class g{static{d(this,"SettingsManager")}storage;globalSettings;projectSettings;settings;projectTrusted;modifiedFields=new Set;modifiedNestedFields=new Map;modifiedProjectFields=new Set;modifiedProjectNestedFields=new Map;globalSettingsLoadError=null;projectSettingsLoadError=null;writeQueue=Promise.resolve();errors;settingsPaths;constructor(e,t,s,i=null,o=null,n=[],a=!0,h={}){this.storage=e,this.globalSettings=t,this.projectSettings=s,this.projectTrusted=a,this.globalSettingsLoadError=i,this.projectSettingsLoadError=o,this.errors=[...n],this.settingsPaths=h,this.settings=c(this.globalSettings,this.projectSettings),this.reportNewerFormatScopes()}static create(e,t=H(),s={}){const i=p(e),o=p(t),n=new re(i,o);return g.fromStorageWithPaths(n,s,{global:f(o,"settings.json"),project:f(i,C,"settings.json")})}static fromStorage(e,t={}){return g.fromStorageWithPaths(e,t)}static fromStorageWithPaths(e,t,s={}){const i=t.projectTrusted??!0,o=g.tryLoadFromStorage(e,"global"),n=g.tryLoadFromStorage(e,"project",i),a=[];return o.error&&a.push(P("global",o.error,s.global)),n.error&&a.push(P("project",n.error,s.project)),new g(e,o.settings,n.settings,o.error,n.error,a,i,s)}static inMemory(e={},t={}){const s=new oe,i=g.migrateSettings(structuredClone(e));return s.withLock("global",()=>JSON.stringify(i,null,2)),g.fromStorage(s,t)}static loadFromStorage(e,t,s=!0){if(t==="project"&&!s)return{};let i;if(e.withLock(t,n=>(i=n,t==="global"&&n?ie(n):void 0)),!i)return{};const o=JSON.parse(T(i));return g.migrateSettings(o)}static tryLoadFromStorage(e,t,s=!0){try{return{settings:g.loadFromStorage(e,t,s),error:null}}catch(i){return{settings:{},error:i}}}static migrateSettings(e){for(const t of v)delete e[t];if("queueMode"in e&&!("steeringMode"in e)&&(e.steeringMode=e.queueMode,delete e.queueMode),!("transport"in e)&&typeof e.websockets=="boolean"&&(e.transport=e.websockets?"websocket":"sse",delete e.websockets),"skills"in e&&typeof e.skills=="object"&&e.skills!==null&&!Array.isArray(e.skills)){const t=e.skills;t.enableSkillCommands!==void 0&&e.enableSkillCommands===void 0&&(e.enableSkillCommands=t.enableSkillCommands),Array.isArray(t.customDirectories)&&t.customDirectories.length>0?e.skills=t.customDirectories:delete e.skills}if("retry"in e&&typeof e.retry=="object"&&e.retry!==null&&!Array.isArray(e.retry)){const t=e.retry,s=typeof t.provider=="object"&&t.provider!==null?t.provider:void 0;typeof t.maxDelayMs=="number"&&(s?.maxRetryDelayMs===void 0||s?.maxRetryDelayMs===null)&&(t.provider={...s??{},maxRetryDelayMs:t.maxDelayMs}),delete t.maxDelayMs}return e}getSettings(){return structuredClone(this.settings)}getGlobalSettings(){return structuredClone(this.globalSettings)}getProjectSettings(){return structuredClone(this.projectSettings)}isProjectTrusted(){return this.projectTrusted}setProjectTrusted(e){if(this.projectTrusted===e)return;if(this.projectTrusted=e,this.modifiedProjectFields.clear(),this.modifiedProjectNestedFields.clear(),!e){this.projectSettings={},this.projectSettingsLoadError=null,this.settings=c(this.globalSettings,this.projectSettings);return}const t=g.tryLoadFromStorage(this.storage,"project",e);this.projectSettings=t.settings,this.projectSettingsLoadError=t.error,t.error&&this.recordError("project",t.error),this.settings=c(this.globalSettings,this.projectSettings)}async reload(){await this.writeQueue;const e=g.tryLoadFromStorage(this.storage,"global");e.error?(this.globalSettingsLoadError=e.error,this.recordError("global",e.error)):(this.globalSettings=e.settings,this.globalSettingsLoadError=null),this.modifiedFields.clear(),this.modifiedNestedFields.clear(),this.modifiedProjectFields.clear(),this.modifiedProjectNestedFields.clear();const t=g.tryLoadFromStorage(this.storage,"project",this.projectTrusted);t.error?(this.projectSettingsLoadError=t.error,this.recordError("project",t.error)):(this.projectSettings=t.settings,this.projectSettingsLoadError=null),this.settings=c(this.globalSettings,this.projectSettings),this.reportNewerFormatScopes()}applyOverrides(e){this.settings=c(this.settings,e)}markModified(e,t){this.modifiedFields.add(e),t&&(this.modifiedNestedFields.has(e)||this.modifiedNestedFields.set(e,new Set),this.modifiedNestedFields.get(e).add(t))}markProjectModified(e,t){this.modifiedProjectFields.add(e),t&&(this.modifiedProjectNestedFields.has(e)||this.modifiedProjectNestedFields.set(e,new Set),this.modifiedProjectNestedFields.get(e).add(t))}assertProjectTrustedForWrite(){if(!this.projectTrusted)throw new Error("Project is not trusted; refusing to write project settings")}reportNewerFormat(e){q(this.settingsPaths[e]??`${e} settings.json`)}reportNewerFormatScopes(){S(this.globalSettings)>M&&this.reportNewerFormat("global"),S(this.projectSettings)>M&&this.reportNewerFormat("project")}recordError(e,t){this.errors.push(P(e,t,this.settingsPaths[e]))}clearModifiedScope(e){if(e==="global"){this.modifiedFields.clear(),this.modifiedNestedFields.clear();return}this.modifiedProjectFields.clear(),this.modifiedProjectNestedFields.clear()}enqueueWrite(e,t){this.writeQueue=this.writeQueue.then(()=>{e==="project"&&this.assertProjectTrustedForWrite(),t(),this.clearModifiedScope(e)}).catch(s=>{this.recordError(e,s)})}cloneModifiedNestedFields(e){const t=new Map;for(const[s,i]of e.entries())t.set(s,new Set(i));return t}persistScopedSettings(e,t,s,i){this.storage.withLock(e,o=>{const n=o?JSON.parse(T(o)):{};if(S(n)>M){this.reportNewerFormat(e);return}const a=o?g.migrateSettings(n):{},h={...a};for(const u of s){const m=t[u];if(i.has(u)&&typeof m=="object"&&m!==null){const I=i.get(u),O=a[u]??{},A=m,j={...O};for(const E of I)j[E]=A[E];h[u]=j}else h[u]=m}return JSON.stringify(h,null,2)})}save(){if(this.settings=c(this.globalSettings,this.projectSettings),this.globalSettingsLoadError)return;const e=structuredClone(this.globalSettings),t=new Set(this.modifiedFields),s=this.cloneModifiedNestedFields(this.modifiedNestedFields);this.enqueueWrite("global",()=>{this.persistScopedSettings("global",e,t,s)})}saveProjectSettings(e){if(this.assertProjectTrustedForWrite(),this.projectSettings=structuredClone(e),this.settings=c(this.globalSettings,this.projectSettings),this.projectSettingsLoadError)return;const t=structuredClone(this.projectSettings),s=new Set(this.modifiedProjectFields),i=this.cloneModifiedNestedFields(this.modifiedProjectNestedFields);this.enqueueWrite("project",()=>{this.persistScopedSettings("project",t,s,i)})}updateProjectSettings(e,t){this.assertProjectTrustedForWrite();const s=structuredClone(this.projectSettings);t(s),this.markProjectModified(e),this.saveProjectSettings(s)}async flush(){await this.writeQueue}drainErrors(){const e=[...this.errors];return this.errors=[],e}getLastChangelogVersion(){return this.settings.lastChangelogVersion}setLastChangelogVersion(e){this.globalSettings.lastChangelogVersion=e,this.markModified("lastChangelogVersion"),this.save()}getSessionDir(){const e=this.settings.sessionDir;return e&&x(e)}getDefaultProvider(){return this.settings.defaultProvider}getDefaultModel(){return this.settings.defaultModel}setDefaultProvider(e){this.globalSettings.defaultProvider=e,this.markModified("defaultProvider"),this.save()}setDefaultModel(e){this.globalSettings.defaultModel=e,this.markModified("defaultModel"),this.save()}setDefaultModelAndProvider(e,t){this.globalSettings.defaultProvider=e,this.globalSettings.defaultModel=t,this.markModified("defaultProvider"),this.markModified("defaultModel"),this.save()}getSteeringMode(){return this.settings.steeringMode||l.steeringMode}setSteeringMode(e){this.globalSettings.steeringMode=e,this.markModified("steeringMode"),this.save()}getFollowUpMode(){return this.settings.followUpMode||l.followUpMode}setFollowUpMode(e){this.globalSettings.followUpMode=e,this.markModified("followUpMode"),this.save()}getThemeSetting(){const e=this.settings.theme;if(typeof e=="string")return e}getTheme(){const e=this.getThemeSetting();return e?.includes("/")?void 0:e}setTheme(e){this.globalSettings.theme=e,this.markModified("theme"),this.save()}getDefaultThinkingLevel(){return this.settings.defaultThinkingLevel}setDefaultThinkingLevel(e){this.globalSettings.defaultThinkingLevel=e,this.markModified("defaultThinkingLevel"),this.save()}getModelThinkingLevel(e,t){return this.settings.modelThinkingLevels?.[`${e}/${t}`]}getAllModelThinkingLevels(){return{...this.settings.modelThinkingLevels??{}}}setModelThinkingLevel(e,t,s){this.globalSettings.modelThinkingLevels||(this.globalSettings.modelThinkingLevels={}),this.globalSettings.modelThinkingLevels[`${e}/${t}`]=s,this.markModified("modelThinkingLevels"),this.save()}removeModelThinkingLevel(e,t){this.globalSettings.modelThinkingLevels&&(delete this.globalSettings.modelThinkingLevels[`${e}/${t}`],Object.keys(this.globalSettings.modelThinkingLevels).length===0&&delete this.globalSettings.modelThinkingLevels,this.markModified("modelThinkingLevels"),this.save())}getTransport(){return this.settings.transport??l.transport}setTransport(e){this.globalSettings.transport=e,this.markModified("transport"),this.save()}getSessionShareDestination(){const e=this.settings.sessionShareDestination;return e==="gist"||e==="radius"?e:l.sessionShareDestination}setSessionShareDestination(e){this.globalSettings.sessionShareDestination=e,this.markModified("sessionShareDestination"),this.save()}getCompactionEnabled(){return this.settings.compaction?.enabled??l.compaction.enabled}setCompactionEnabled(e){this.globalSettings.compaction||(this.globalSettings.compaction={}),this.globalSettings.compaction.enabled=e,this.markModified("compaction","enabled"),this.save()}getCompactionTokenSetting(e,t){const s=this.settings.compaction,i=s?.[e];if(i!==void 0&&(typeof i!="number"||!Number.isSafeInteger(i)||i<0))throw new Error(`Invalid compaction.${e} setting: ${String(i)}. Expected a non-negative safe integer.`);const o=t?`${t.provider}/${t.id}`:void 0,n=o!==void 0?s?.modelOverrides?.[o]:void 0;if(n!==void 0&&!y(n))throw new Error(`Invalid compaction.modelOverrides["${o}"] setting: ${String(n)}. Expected an object.`);const a=n?.[e];if(a!==void 0&&(typeof a!="number"||!Number.isSafeInteger(a)||a<0))throw new Error(`Invalid compaction.modelOverrides["${o}"].${e} setting: ${String(a)}. Expected a non-negative safe integer.`);return a??i??z[e]}getCompactionReserveTokens(e){return this.getCompactionTokenSetting("reserveTokens",e)}getCompactionKeepRecentTokens(e){return this.getCompactionTokenSetting("keepRecentTokens",e)}getCompactionSettings(e){return{enabled:this.getCompactionEnabled(),reserveTokens:this.getCompactionReserveTokens(e),keepRecentTokens:this.getCompactionKeepRecentTokens(e),maxContextTokens:this.getCompactionMaxContextTokens(e),pruneToolOutputs:this.getCompactionPruneToolOutputs()}}getCompactionMaxContextTokens(e){return this.getCompactionTokenSetting("maxContextTokens",e)}getCompactionPruneToolOutputs(){const e=this.settings.compaction?.pruneToolOutputs;if(e!==void 0&&typeof e!="boolean")throw new Error(`Invalid compaction.pruneToolOutputs setting: ${String(e)}. Expected a boolean.`);return e??!0}getCompactionSummaryModel(){const e=this.settings.compaction?.summaryModel;if(e===void 0||e==="")return;const t=typeof e=="string"?e.indexOf("/"):-1;if(typeof e!="string"||t<=0||t===e.length-1)throw new Error(`Invalid compaction.summaryModel setting: ${String(e)}. Expected "provider/modelId".`);return{provider:e.slice(0,t),modelId:e.slice(t+1)}}getBranchSummarySettings(){return{reserveTokens:this.settings.branchSummary?.reserveTokens??l.branchSummary.reserveTokens,skipPrompt:this.settings.branchSummary?.skipPrompt??l.branchSummary.skipPrompt}}getBranchSummarySkipPrompt(){return this.settings.branchSummary?.skipPrompt??l.branchSummary.skipPrompt}getRetryEnabled(){return this.settings.retry?.enabled??l.retry.enabled}setRetryEnabled(e){this.globalSettings.retry||(this.globalSettings.retry={}),this.globalSettings.retry.enabled=e,this.markModified("retry","enabled"),this.save()}getRetrySettings(){return{enabled:this.getRetryEnabled(),maxRetries:this.settings.retry?.maxRetries??J,baseDelayMs:this.settings.retry?.baseDelayMs??2e3,maxAgentDelayMs:this.settings.retry?.maxAgentDelayMs??N}}getMaxOutputTokens(){const e=this.settings.maxOutputTokens;if(e===void 0)return Q;if(typeof e!="number"||!Number.isSafeInteger(e)||e<0)throw new Error(`Invalid maxOutputTokens setting: ${String(e)}. Expected a non-negative safe integer.`);return e}getOutputTokenLimit(e){const t=this.getMaxOutputTokens();return t>0&&(e<=0||e>t)?t:e}getStallWatchdogMs(){const e=F(process.env.DAL_STALL_WATCHDOG_MS);return e!==void 0?e:k(this.settings.stallWatchdogMs,"stallWatchdogMs")??K}getHttpIdleTimeoutMs(){return k(this.settings.httpIdleTimeoutMs,"httpIdleTimeoutMs")??V}getFirstTokenTimeoutMs(){return k(this.settings.firstTokenTimeoutMs,"firstTokenTimeoutMs")??B}setHttpIdleTimeoutMs(e){if(!Number.isFinite(e)||e<0)throw new Error(`Invalid httpIdleTimeoutMs setting: ${String(e)}`);this.globalSettings.httpIdleTimeoutMs=Math.floor(e),this.markModified("httpIdleTimeoutMs"),this.save()}getCacheWarmingMode(){const e=this.globalSettings.cacheWarming;return e!==void 0&&Y.includes(e)?e:l.cacheWarming}setCacheWarmingMode(e){this.globalSettings.cacheWarming=e,this.markModified("cacheWarming"),this.save()}getProviderRetrySettings(){return{timeoutMs:this.settings.retry?.provider?.timeoutMs,maxRetries:this.settings.retry?.provider?.maxRetries,maxRetryDelayMs:this.settings.retry?.provider?.maxRetryDelayMs??l.retry.provider.maxRetryDelayMs}}getWebSocketConnectTimeoutMs(){return k(this.settings.websocketConnectTimeoutMs,"websocketConnectTimeoutMs")}getHideThinkingBlock(){return this.settings.hideThinkingBlock??!0}getShowCacheMissNotices(){return this.settings.showCacheMissNotices??l.showCacheMissNotices}getExternalEditorCommand(){const e=this.settings.externalEditor;if(typeof e=="string"&&e.trim()!=="")return e;const t=process.env.VISUAL||process.env.EDITOR;return t||(process.platform==="win32"?"notepad":"nano")}setHideThinkingBlock(e){this.globalSettings.hideThinkingBlock=e,this.markModified("hideThinkingBlock"),this.save()}setShowCacheMissNotices(e){this.globalSettings.showCacheMissNotices=e,this.markModified("showCacheMissNotices"),this.save()}getShellPath(){const e=this.settings.shellPath;return e&&x(e)}setShellPath(e){this.globalSettings.shellPath=e,this.markModified("shellPath"),this.save()}getQuietStartup(){const e=this.settings.quietStartup;return e===!1?!1:e==="header"?e:!0}setQuietStartup(e){this.globalSettings.quietStartup=e,this.markModified("quietStartup"),this.save()}getDefaultProjectTrust(){const e=this.globalSettings.defaultProjectTrust;return e==="always"||e==="never"?e:l.defaultProjectTrust}setDefaultProjectTrust(e){this.globalSettings.defaultProjectTrust=e,this.markModified("defaultProjectTrust"),this.save()}getShellCommandPrefix(){return this.settings.shellCommandPrefix}getShellEnvironmentPolicy(){const e=this.globalSettings.shellEnvironment??{},t=[...e.exclude??[],...this.projectSettings.shellEnvironment?.exclude??[]];return{...e.inherit!==void 0?{inherit:e.inherit}:{},...t.length>0?{exclude:t}:{},...e.include!==void 0?{include:[...e.include]}:{},...e.set!==void 0?{set:{...e.set}}:{}}}getPermissionRuleSources(){return{...this.globalSettings.permissions?{user:structuredClone(this.globalSettings.permissions)}:{},...this.projectSettings.permissions?{project:structuredClone(this.projectSettings.permissions)}:{}}}getSandboxSettingsSources(){return{...this.globalSettings.sandbox?{global:structuredClone(this.globalSettings.sandbox)}:{},...this.projectSettings.sandbox?{project:structuredClone(this.projectSettings.sandbox)}:{}}}setShellCommandPrefix(e){this.globalSettings.shellCommandPrefix=e,this.markModified("shellCommandPrefix"),this.save()}getNpmCommand(){return this.settings.npmCommand?[...this.settings.npmCommand]:void 0}setNpmCommand(e){this.globalSettings.npmCommand=e?[...e]:void 0,this.markModified("npmCommand"),this.save()}getCollapseChangelog(){return this.settings.collapseChangelog??!0}setCollapseChangelog(e){this.globalSettings.collapseChangelog=e,this.markModified("collapseChangelog"),this.save()}getEnableInstallTelemetry(){return this.settings.enableInstallTelemetry??l.enableInstallTelemetry}setEnableInstallTelemetry(e){this.globalSettings.enableInstallTelemetry=e,this.markModified("enableInstallTelemetry"),this.save()}getOrCreateDeviceId(){return this.globalSettings.deviceId||(this.globalSettings.deviceId=R(),this.markModified("deviceId"),this.save()),this.globalSettings.deviceId}getPackages(){return[...this.settings.packages??[]]}setPackages(e){this.globalSettings.packages=e,this.markModified("packages"),this.save()}setProjectPackages(e){this.updateProjectSettings("packages",t=>{t.packages=e})}getExtensionPaths(){return[...this.settings.extensions??[]]}setExtensionPaths(e){this.globalSettings.extensions=e,this.markModified("extensions"),this.save()}setProjectExtensionPaths(e){this.updateProjectSettings("extensions",t=>{t.extensions=e})}getSkillPaths(){return[...this.settings.skills??[]]}setSkillPaths(e){this.globalSettings.skills=e,this.markModified("skills"),this.save()}setProjectSkillPaths(e){this.updateProjectSettings("skills",t=>{t.skills=e})}getPromptTemplatePaths(){return[...this.settings.prompts??[]]}setPromptTemplatePaths(e){this.globalSettings.prompts=e,this.markModified("prompts"),this.save()}setProjectPromptTemplatePaths(e){this.updateProjectSettings("prompts",t=>{t.prompts=e})}getThemePaths(){return[...this.settings.themes??[]]}setThemePaths(e){this.globalSettings.themes=e,this.markModified("themes"),this.save()}setProjectThemePaths(e){this.updateProjectSettings("themes",t=>{t.themes=e})}getEnableSkillCommands(){return this.settings.enableSkillCommands??l.enableSkillCommands}setEnableSkillCommands(e){this.globalSettings.enableSkillCommands=e,this.markModified("enableSkillCommands"),this.save()}getFactoryEnabled(){return this.settings.factoryEnabled??!0}setFactoryEnabled(e){this.globalSettings.factoryEnabled=e,this.markModified("factoryEnabled"),this.save()}getThinkingBudgets(){return this.settings.thinkingBudgets}getTerminalCapabilityOverrides(){const e=this.settings.terminal,t=e?.images;return{...t==="kitty"||t==="iterm2"?{images:t}:t===!1?{images:null}:{},...typeof e?.trueColor=="boolean"?{trueColor:e.trueColor}:{},...typeof e?.hyperlinks=="boolean"?{hyperlinks:e.hyperlinks}:{}}}getShowImages(){return this.settings.terminal?.showImages??l.terminal.showImages}setShowImages(e){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.showImages=e,this.markModified("terminal","showImages"),this.save()}getImageWidthCells(){const e=this.settings.terminal?.imageWidthCells;return typeof e!="number"||!Number.isFinite(e)?l.terminal.imageWidthCells:Math.max(1,Math.floor(e))}setImageWidthCells(e){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.imageWidthCells=Math.max(1,Math.floor(e)),this.markModified("terminal","imageWidthCells"),this.save()}getClearOnShrink(){return this.settings.terminal?.clearOnShrink!==void 0?this.settings.terminal.clearOnShrink:process.env.PI_CLEAR_ON_SHRINK==="1"?!0:l.terminal.clearOnShrink}setClearOnShrink(e){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.clearOnShrink=e,this.markModified("terminal","clearOnShrink"),this.save()}getShowTerminalProgress(){return this.settings.terminal?.showTerminalProgress??l.terminal.showTerminalProgress}setShowTerminalProgress(e){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.showTerminalProgress=e,this.markModified("terminal","showTerminalProgress"),this.save()}getTuiMode(){return this.settings.tuiMode==="fullscreen"?"fullscreen":(this.settings.tuiMode==="regular"||this.settings.tuiMode,"regular")}setTuiMode(e){this.globalSettings.tuiMode=e,this.markModified("tuiMode"),this.save()}getFullscreenExitOutput(){return this.settings.fullscreenExitOutput==="resume-hint"?"resume-hint":l.fullscreenExitOutput}setFullscreenExitOutput(e){this.globalSettings.fullscreenExitOutput=e,this.markModified("fullscreenExitOutput"),this.save()}getFullscreenScrollbar(){const e=this.settings.fullscreenScrollbar;return e==="always"||e==="hidden"?e:l.fullscreenScrollbar}setFullscreenScrollbar(e){this.globalSettings.fullscreenScrollbar=e,this.markModified("fullscreenScrollbar"),this.save()}getFullscreenCopyOnSelect(){return this.settings.fullscreenCopyOnSelect??l.fullscreenCopyOnSelect}setFullscreenCopyOnSelect(e){this.globalSettings.fullscreenCopyOnSelect=e,this.markModified("fullscreenCopyOnSelect"),this.save()}getFullscreenWheelScrollLines(){const e=this.settings.fullscreenWheelScrollLines;return typeof e=="number"&&Number.isFinite(e)?Math.max(1,Math.min(100,Math.floor(e))):l.fullscreenWheelScrollLines}setFullscreenWheelScrollLines(e){this.globalSettings.fullscreenWheelScrollLines=e==="auto"?e:Math.max(1,Math.min(100,Math.floor(e))),this.markModified("fullscreenWheelScrollLines"),this.save()}getImageAutoResize(){return this.settings.images?.autoResize??l.images.autoResize}setImageAutoResize(e){this.globalSettings.images||(this.globalSettings.images={}),this.globalSettings.images.autoResize=e,this.markModified("images","autoResize"),this.save()}getBlockImages(){return this.settings.images?.blockImages??l.images.blockImages}setBlockImages(e){this.globalSettings.images||(this.globalSettings.images={}),this.globalSettings.images.blockImages=e,this.markModified("images","blockImages"),this.save()}getEnabledModels(){return this.settings.enabledModels}getDefaultTools(){const e=this.settings.defaultTools;if(e!==void 0)return se(Array.isArray(e)?e.filter(t=>typeof t=="string"):[])}setEnabledModels(e){this.globalSettings.enabledModels=e,this.markModified("enabledModels"),this.save()}getDoubleEscapeAction(){return this.settings.doubleEscapeAction??l.doubleEscapeAction}setDoubleEscapeAction(e){this.globalSettings.doubleEscapeAction=e,this.markModified("doubleEscapeAction"),this.save()}getTreeFilterMode(){const e=this.settings.treeFilterMode;return e&&["default","no-tools","user-only","labeled-only","all"].includes(e)?e:l.treeFilterMode}setTreeFilterMode(e){this.globalSettings.treeFilterMode=e,this.markModified("treeFilterMode"),this.save()}getShowHardwareCursor(){return this.settings.showHardwareCursor??process.env.PI_HARDWARE_CURSOR==="1"}setShowHardwareCursor(e){this.globalSettings.showHardwareCursor=e,this.markModified("showHardwareCursor"),this.save()}getEditorPaddingX(){return this.settings.editorPaddingX??1}setEditorPaddingX(e){this.globalSettings.editorPaddingX=Math.max(0,Math.min(3,Math.floor(e))),this.markModified("editorPaddingX"),this.save()}getOutputPad(){return this.settings.outputPad===1?1:0}setOutputPad(e){this.globalSettings.outputPad=e,this.markModified("outputPad"),this.save()}getAutocompleteMaxVisible(){return this.settings.autocompleteMaxVisible??l.autocompleteMaxVisible}setAutocompleteMaxVisible(e){this.globalSettings.autocompleteMaxVisible=Math.max(3,Math.min(20,Math.floor(e))),this.markModified("autocompleteMaxVisible"),this.save()}getCodeBlockIndent(){return this.settings.markdown?.codeBlockIndent??l.markdown.codeBlockIndent}getMermaidRenderingMode(){const e=this.settings.markdown?.mermaid;return e==="off"||e==="final"?e:l.markdown.mermaid}setMermaidRenderingMode(e){this.globalSettings.markdown??={},this.globalSettings.markdown.mermaid=e,this.markModified("markdown","mermaid"),this.save()}getWarnings(){return{...this.settings.warnings??{}}}setWarnings(e){this.globalSettings.warnings={...e},this.markModified("warnings"),this.save()}}export{Y as CACHE_WARMING_MODES,X as DEFAULT_COMPACTION_MAX_CONTEXT_TOKENS,Q as DEFAULT_MAX_OUTPUT_TOKENS,J as DEFAULT_MAX_RETRIES,Z as DEFAULT_TOOL_NAMES,re as FileSettingsStorage,oe as InMemorySettingsStorage,M as SETTINGS_FORMAT_VERSION,g as SettingsManager,ee as applyToolModifiers,ke as getToolListError,b as isToolModifier};
1
+ var D=Object.defineProperty;var d=(r,e)=>D(r,"name",{value:e,configurable:!0});import{DEFAULT_MAX_AGENT_RETRY_DELAY_MS as N}from"@earendil-works/pi-ai";import{randomUUID as R}from"crypto";import{existsSync as C,mkdirSync as W,readFileSync as _}from"fs";import{dirname as U,join as f}from"path";import $ from"proper-lockfile";import{CONFIG_DIR_NAME as w,getAgentDir as V}from"../config.js";import{normalizePath as x,resolvePath as p}from"../utils/paths.js";import{stripBom as T}from"../utils/text.js";import{DEFAULT_FIRST_TOKEN_TIMEOUT_MS as H,DEFAULT_HTTP_IDLE_TIMEOUT_MS as B,parseHttpIdleTimeoutMs as F}from"./http-dispatcher.js";import{SETTINGS_DEFAULTS as l}from"./settings-defaults.js";import{declaredDataFormat as S,reportNewerDataFormat as q,writeFileAtomicSync as G}from"./shared-data.js";import{DEFAULT_STALL_WATCHDOG_MS as K}from"./stall-watchdog.js";const X=8e4,z={reserveTokens:16384,keepRecentTokens:2e4,maxContextTokens:X},Q=32e3,J=5,Y=["off","streaming","idle"];function y(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}d(y,"isMergeableObject");function L(r,e){const t={...r};for(const s of Object.keys(e)){const i=e[s];if(i===void 0)continue;const o=r[s];t[s]=y(o)&&y(i)?L(o,i):i}return t}d(L,"deepMergeObjects");const Z=["read","bash","edit","write"];function b(r){return typeof r=="string"&&(r.startsWith("+")||r.startsWith("-"))}d(b,"isToolModifier");function ke(r){const e=r.filter(b);if(e.length===0)return;if(e.length<r.length)return"tool names cannot be mixed with +name or -name entries";const t=e.find(s=>s.includes("*"));if(t)return`+name and -name entries take exact tool names, not patterns: ${t}`}d(ke,"getToolListError");function ee(r,e){const t=[...r];for(const s of e){if(!b(s))continue;const i=s.slice(1),o=t.indexOf(i);s.startsWith("+")&&o===-1&&i?t.push(i):s.startsWith("-")&&o!==-1&&t.splice(o,1)}return t}d(ee,"applyToolModifiers");function te(r,e){return e===void 0?r:!Array.isArray(r)||!Array.isArray(e)||!e.every(b)?e:[...r,...e]}d(te,"mergeDefaultTools");function se(r){const e=r.filter(t=>!b(t));return ee(e.length>0||r.length===0?e:Z,r)}d(se,"resolveDefaultTools");function c(r,e){const t=L(r,e),s=te(r.defaultTools,e.defaultTools);return s===void 0?t:{...t,defaultTools:s}}d(c,"deepMergeSettings");function k(r,e){const t=F(r);if(t!==void 0)return t;if(r!==void 0)throw new Error(`Invalid ${e} setting: ${String(r)}`)}d(k,"parseTimeoutSetting");const M=1,v=["enableAnalytics","trackingId"];function ie(r){let e;try{e=JSON.parse(T(r))}catch{return}if(typeof e!="object"||e===null||Array.isArray(e))return;const t=e;if(!(S(t)>M)&&v.some(s=>s in t)){for(const s of v)delete t[s];return JSON.stringify(t,null,2)}}d(ie,"withoutRetiredKeys");function P(r,e,t){return{scope:r,...t?{path:t}:{},error:e instanceof Error?e:new Error(String(e))}}d(P,"toSettingsError");class re{static{d(this,"FileSettingsStorage")}globalSettingsPath;projectSettingsPath;constructor(e,t){const s=p(e),i=p(t);this.globalSettingsPath=f(i,"settings.json"),this.projectSettingsPath=f(s,w,"settings.json")}acquireLockSyncWithRetry(e){let i;for(let o=1;o<=100;o++)try{return $.lockSync(e,{realpath:!1})}catch(n){if((typeof n=="object"&&n!==null&&"code"in n?String(n.code):void 0)!=="ELOCKED"||o===100)throw n;i=n;const h=Date.now();for(;Date.now()-h<20;);}throw i??new Error("Failed to acquire settings lock")}withLock(e,t){const s=e==="global"?this.globalSettingsPath:this.projectSettingsPath,i=U(s);let o;try{const n=C(s);n&&(o=this.acquireLockSyncWithRetry(s));const a=n?_(s,"utf-8"):void 0,h=t(a);h!==void 0&&(C(i)||W(i,{recursive:!0}),o||(o=this.acquireLockSyncWithRetry(s)),G(s,h))}finally{o&&o()}}}class oe{static{d(this,"InMemorySettingsStorage")}global;project;withLock(e,t){const s=e==="global"?this.global:this.project,i=t(s);i!==void 0&&(e==="global"?this.global=i:this.project=i)}}class g{static{d(this,"SettingsManager")}storage;globalSettings;projectSettings;settings;projectTrusted;modifiedFields=new Set;modifiedNestedFields=new Map;modifiedProjectFields=new Set;modifiedProjectNestedFields=new Map;globalSettingsLoadError=null;projectSettingsLoadError=null;writeQueue=Promise.resolve();errors;settingsPaths;constructor(e,t,s,i=null,o=null,n=[],a=!0,h={}){this.storage=e,this.globalSettings=t,this.projectSettings=s,this.projectTrusted=a,this.globalSettingsLoadError=i,this.projectSettingsLoadError=o,this.errors=[...n],this.settingsPaths=h,this.settings=c(this.globalSettings,this.projectSettings),this.reportNewerFormatScopes()}static create(e,t=V(),s={}){const i=p(e),o=p(t),n=new re(i,o);return g.fromStorageWithPaths(n,s,{global:f(o,"settings.json"),project:f(i,w,"settings.json")})}static fromStorage(e,t={}){return g.fromStorageWithPaths(e,t)}static fromStorageWithPaths(e,t,s={}){const i=t.projectTrusted??!0,o=g.tryLoadFromStorage(e,"global"),n=g.tryLoadFromStorage(e,"project",i),a=[];return o.error&&a.push(P("global",o.error,s.global)),n.error&&a.push(P("project",n.error,s.project)),new g(e,o.settings,n.settings,o.error,n.error,a,i,s)}static inMemory(e={},t={}){const s=new oe,i=g.migrateSettings(structuredClone(e));return s.withLock("global",()=>JSON.stringify(i,null,2)),g.fromStorage(s,t)}static loadFromStorage(e,t,s=!0){if(t==="project"&&!s)return{};let i;if(e.withLock(t,n=>(i=n,t==="global"&&n?ie(n):void 0)),!i)return{};const o=JSON.parse(T(i));return g.migrateSettings(o)}static tryLoadFromStorage(e,t,s=!0){try{return{settings:g.loadFromStorage(e,t,s),error:null}}catch(i){return{settings:{},error:i}}}static migrateSettings(e){for(const t of v)delete e[t];if("queueMode"in e&&!("steeringMode"in e)&&(e.steeringMode=e.queueMode,delete e.queueMode),!("transport"in e)&&typeof e.websockets=="boolean"&&(e.transport=e.websockets?"websocket":"sse",delete e.websockets),"skills"in e&&typeof e.skills=="object"&&e.skills!==null&&!Array.isArray(e.skills)){const t=e.skills;t.enableSkillCommands!==void 0&&e.enableSkillCommands===void 0&&(e.enableSkillCommands=t.enableSkillCommands),Array.isArray(t.customDirectories)&&t.customDirectories.length>0?e.skills=t.customDirectories:delete e.skills}if("retry"in e&&typeof e.retry=="object"&&e.retry!==null&&!Array.isArray(e.retry)){const t=e.retry,s=typeof t.provider=="object"&&t.provider!==null?t.provider:void 0;typeof t.maxDelayMs=="number"&&(s?.maxRetryDelayMs===void 0||s?.maxRetryDelayMs===null)&&(t.provider={...s??{},maxRetryDelayMs:t.maxDelayMs}),delete t.maxDelayMs}return e}getSettings(){return structuredClone(this.settings)}getGlobalSettings(){return structuredClone(this.globalSettings)}getProjectSettings(){return structuredClone(this.projectSettings)}isProjectTrusted(){return this.projectTrusted}setProjectTrusted(e){if(this.projectTrusted===e)return;if(this.projectTrusted=e,this.modifiedProjectFields.clear(),this.modifiedProjectNestedFields.clear(),!e){this.projectSettings={},this.projectSettingsLoadError=null,this.settings=c(this.globalSettings,this.projectSettings);return}const t=g.tryLoadFromStorage(this.storage,"project",e);this.projectSettings=t.settings,this.projectSettingsLoadError=t.error,t.error&&this.recordError("project",t.error),this.settings=c(this.globalSettings,this.projectSettings)}async reload(){await this.writeQueue;const e=g.tryLoadFromStorage(this.storage,"global");e.error?(this.globalSettingsLoadError=e.error,this.recordError("global",e.error)):(this.globalSettings=e.settings,this.globalSettingsLoadError=null),this.modifiedFields.clear(),this.modifiedNestedFields.clear(),this.modifiedProjectFields.clear(),this.modifiedProjectNestedFields.clear();const t=g.tryLoadFromStorage(this.storage,"project",this.projectTrusted);t.error?(this.projectSettingsLoadError=t.error,this.recordError("project",t.error)):(this.projectSettings=t.settings,this.projectSettingsLoadError=null),this.settings=c(this.globalSettings,this.projectSettings),this.reportNewerFormatScopes()}applyOverrides(e){this.settings=c(this.settings,e)}markModified(e,t){this.modifiedFields.add(e),t&&(this.modifiedNestedFields.has(e)||this.modifiedNestedFields.set(e,new Set),this.modifiedNestedFields.get(e).add(t))}markProjectModified(e,t){this.modifiedProjectFields.add(e),t&&(this.modifiedProjectNestedFields.has(e)||this.modifiedProjectNestedFields.set(e,new Set),this.modifiedProjectNestedFields.get(e).add(t))}assertProjectTrustedForWrite(){if(!this.projectTrusted)throw new Error("Project is not trusted; refusing to write project settings")}reportNewerFormat(e){q(this.settingsPaths[e]??`${e} settings.json`)}reportNewerFormatScopes(){S(this.globalSettings)>M&&this.reportNewerFormat("global"),S(this.projectSettings)>M&&this.reportNewerFormat("project")}recordError(e,t){this.errors.push(P(e,t,this.settingsPaths[e]))}clearModifiedScope(e){if(e==="global"){this.modifiedFields.clear(),this.modifiedNestedFields.clear();return}this.modifiedProjectFields.clear(),this.modifiedProjectNestedFields.clear()}enqueueWrite(e,t){this.writeQueue=this.writeQueue.then(()=>{e==="project"&&this.assertProjectTrustedForWrite(),t(),this.clearModifiedScope(e)}).catch(s=>{this.recordError(e,s)})}cloneModifiedNestedFields(e){const t=new Map;for(const[s,i]of e.entries())t.set(s,new Set(i));return t}persistScopedSettings(e,t,s,i){this.storage.withLock(e,o=>{const n=o?JSON.parse(T(o)):{};if(S(n)>M){this.reportNewerFormat(e);return}const a=o?g.migrateSettings(n):{},h={...a};for(const u of s){const m=t[u];if(i.has(u)&&typeof m=="object"&&m!==null){const I=i.get(u),O=a[u]??{},A=m,E={...O};for(const j of I)E[j]=A[j];h[u]=E}else h[u]=m}return JSON.stringify(h,null,2)})}save(){if(this.settings=c(this.globalSettings,this.projectSettings),this.globalSettingsLoadError)return;const e=structuredClone(this.globalSettings),t=new Set(this.modifiedFields),s=this.cloneModifiedNestedFields(this.modifiedNestedFields);this.enqueueWrite("global",()=>{this.persistScopedSettings("global",e,t,s)})}saveProjectSettings(e){if(this.assertProjectTrustedForWrite(),this.projectSettings=structuredClone(e),this.settings=c(this.globalSettings,this.projectSettings),this.projectSettingsLoadError)return;const t=structuredClone(this.projectSettings),s=new Set(this.modifiedProjectFields),i=this.cloneModifiedNestedFields(this.modifiedProjectNestedFields);this.enqueueWrite("project",()=>{this.persistScopedSettings("project",t,s,i)})}updateProjectSettings(e,t){this.assertProjectTrustedForWrite();const s=structuredClone(this.projectSettings);t(s),this.markProjectModified(e),this.saveProjectSettings(s)}async flush(){await this.writeQueue}drainErrors(){const e=[...this.errors];return this.errors=[],e}getLastChangelogVersion(){return this.settings.lastChangelogVersion}setLastChangelogVersion(e){this.globalSettings.lastChangelogVersion=e,this.markModified("lastChangelogVersion"),this.save()}getExtensionChangelogVersion(e){return this.settings.extensionChangelogVersions?.[e]}setExtensionChangelogVersion(e,t){this.globalSettings.extensionChangelogVersions={...this.globalSettings.extensionChangelogVersions??{},[e]:t},this.markModified("extensionChangelogVersions",e),this.save()}getSessionDir(){const e=this.settings.sessionDir;return e&&x(e)}getDefaultProvider(){return this.settings.defaultProvider}getDefaultModel(){return this.settings.defaultModel}setDefaultProvider(e){this.globalSettings.defaultProvider=e,this.markModified("defaultProvider"),this.save()}setDefaultModel(e){this.globalSettings.defaultModel=e,this.markModified("defaultModel"),this.save()}setDefaultModelAndProvider(e,t){this.globalSettings.defaultProvider=e,this.globalSettings.defaultModel=t,this.markModified("defaultProvider"),this.markModified("defaultModel"),this.save()}getSteeringMode(){return this.settings.steeringMode||l.steeringMode}setSteeringMode(e){this.globalSettings.steeringMode=e,this.markModified("steeringMode"),this.save()}getFollowUpMode(){return this.settings.followUpMode||l.followUpMode}setFollowUpMode(e){this.globalSettings.followUpMode=e,this.markModified("followUpMode"),this.save()}getThemeSetting(){const e=this.settings.theme;if(typeof e=="string")return e}getTheme(){const e=this.getThemeSetting();return e?.includes("/")?void 0:e}setTheme(e){this.globalSettings.theme=e,this.markModified("theme"),this.save()}getDefaultThinkingLevel(){return this.settings.defaultThinkingLevel}setDefaultThinkingLevel(e){this.globalSettings.defaultThinkingLevel=e,this.markModified("defaultThinkingLevel"),this.save()}getModelThinkingLevel(e,t){return this.settings.modelThinkingLevels?.[`${e}/${t}`]}getAllModelThinkingLevels(){return{...this.settings.modelThinkingLevels??{}}}setModelThinkingLevel(e,t,s){this.globalSettings.modelThinkingLevels||(this.globalSettings.modelThinkingLevels={}),this.globalSettings.modelThinkingLevels[`${e}/${t}`]=s,this.markModified("modelThinkingLevels"),this.save()}removeModelThinkingLevel(e,t){this.globalSettings.modelThinkingLevels&&(delete this.globalSettings.modelThinkingLevels[`${e}/${t}`],Object.keys(this.globalSettings.modelThinkingLevels).length===0&&delete this.globalSettings.modelThinkingLevels,this.markModified("modelThinkingLevels"),this.save())}getTransport(){return this.settings.transport??l.transport}setTransport(e){this.globalSettings.transport=e,this.markModified("transport"),this.save()}getSessionShareDestination(){const e=this.settings.sessionShareDestination;return e==="gist"||e==="radius"?e:l.sessionShareDestination}setSessionShareDestination(e){this.globalSettings.sessionShareDestination=e,this.markModified("sessionShareDestination"),this.save()}getCompactionEnabled(){return this.settings.compaction?.enabled??l.compaction.enabled}setCompactionEnabled(e){this.globalSettings.compaction||(this.globalSettings.compaction={}),this.globalSettings.compaction.enabled=e,this.markModified("compaction","enabled"),this.save()}getCompactionTokenSetting(e,t){const s=this.settings.compaction,i=s?.[e];if(i!==void 0&&(typeof i!="number"||!Number.isSafeInteger(i)||i<0))throw new Error(`Invalid compaction.${e} setting: ${String(i)}. Expected a non-negative safe integer.`);const o=t?`${t.provider}/${t.id}`:void 0,n=o!==void 0?s?.modelOverrides?.[o]:void 0;if(n!==void 0&&!y(n))throw new Error(`Invalid compaction.modelOverrides["${o}"] setting: ${String(n)}. Expected an object.`);const a=n?.[e];if(a!==void 0&&(typeof a!="number"||!Number.isSafeInteger(a)||a<0))throw new Error(`Invalid compaction.modelOverrides["${o}"].${e} setting: ${String(a)}. Expected a non-negative safe integer.`);return a??i??z[e]}getCompactionReserveTokens(e){return this.getCompactionTokenSetting("reserveTokens",e)}getCompactionKeepRecentTokens(e){return this.getCompactionTokenSetting("keepRecentTokens",e)}getCompactionSettings(e){return{enabled:this.getCompactionEnabled(),reserveTokens:this.getCompactionReserveTokens(e),keepRecentTokens:this.getCompactionKeepRecentTokens(e),maxContextTokens:this.getCompactionMaxContextTokens(e),pruneToolOutputs:this.getCompactionPruneToolOutputs()}}getCompactionMaxContextTokens(e){return this.getCompactionTokenSetting("maxContextTokens",e)}getCompactionPruneToolOutputs(){const e=this.settings.compaction?.pruneToolOutputs;if(e!==void 0&&typeof e!="boolean")throw new Error(`Invalid compaction.pruneToolOutputs setting: ${String(e)}. Expected a boolean.`);return e??!0}getCompactionSummaryModel(){const e=this.settings.compaction?.summaryModel;if(e===void 0||e==="")return;const t=typeof e=="string"?e.indexOf("/"):-1;if(typeof e!="string"||t<=0||t===e.length-1)throw new Error(`Invalid compaction.summaryModel setting: ${String(e)}. Expected "provider/modelId".`);return{provider:e.slice(0,t),modelId:e.slice(t+1)}}getBranchSummarySettings(){return{reserveTokens:this.settings.branchSummary?.reserveTokens??l.branchSummary.reserveTokens,skipPrompt:this.settings.branchSummary?.skipPrompt??l.branchSummary.skipPrompt}}getBranchSummarySkipPrompt(){return this.settings.branchSummary?.skipPrompt??l.branchSummary.skipPrompt}getRetryEnabled(){return this.settings.retry?.enabled??l.retry.enabled}setRetryEnabled(e){this.globalSettings.retry||(this.globalSettings.retry={}),this.globalSettings.retry.enabled=e,this.markModified("retry","enabled"),this.save()}getRetrySettings(){return{enabled:this.getRetryEnabled(),maxRetries:this.settings.retry?.maxRetries??J,baseDelayMs:this.settings.retry?.baseDelayMs??2e3,maxAgentDelayMs:this.settings.retry?.maxAgentDelayMs??N}}getMaxOutputTokens(){const e=this.settings.maxOutputTokens;if(e===void 0)return Q;if(typeof e!="number"||!Number.isSafeInteger(e)||e<0)throw new Error(`Invalid maxOutputTokens setting: ${String(e)}. Expected a non-negative safe integer.`);return e}getOutputTokenLimit(e){const t=this.getMaxOutputTokens();return t>0&&(e<=0||e>t)?t:e}getStallWatchdogMs(){const e=F(process.env.DAL_STALL_WATCHDOG_MS);return e!==void 0?e:k(this.settings.stallWatchdogMs,"stallWatchdogMs")??K}getHttpIdleTimeoutMs(){return k(this.settings.httpIdleTimeoutMs,"httpIdleTimeoutMs")??B}getFirstTokenTimeoutMs(){return k(this.settings.firstTokenTimeoutMs,"firstTokenTimeoutMs")??H}setHttpIdleTimeoutMs(e){if(!Number.isFinite(e)||e<0)throw new Error(`Invalid httpIdleTimeoutMs setting: ${String(e)}`);this.globalSettings.httpIdleTimeoutMs=Math.floor(e),this.markModified("httpIdleTimeoutMs"),this.save()}getCacheWarmingMode(){const e=this.globalSettings.cacheWarming;return e!==void 0&&Y.includes(e)?e:l.cacheWarming}setCacheWarmingMode(e){this.globalSettings.cacheWarming=e,this.markModified("cacheWarming"),this.save()}getProviderRetrySettings(){return{timeoutMs:this.settings.retry?.provider?.timeoutMs,maxRetries:this.settings.retry?.provider?.maxRetries,maxRetryDelayMs:this.settings.retry?.provider?.maxRetryDelayMs??l.retry.provider.maxRetryDelayMs}}getWebSocketConnectTimeoutMs(){return k(this.settings.websocketConnectTimeoutMs,"websocketConnectTimeoutMs")}getHideThinkingBlock(){return this.settings.hideThinkingBlock??!0}getShowCacheMissNotices(){return this.settings.showCacheMissNotices??l.showCacheMissNotices}getExternalEditorCommand(){const e=this.settings.externalEditor;if(typeof e=="string"&&e.trim()!=="")return e;const t=process.env.VISUAL||process.env.EDITOR;return t||(process.platform==="win32"?"notepad":"nano")}setHideThinkingBlock(e){this.globalSettings.hideThinkingBlock=e,this.markModified("hideThinkingBlock"),this.save()}setShowCacheMissNotices(e){this.globalSettings.showCacheMissNotices=e,this.markModified("showCacheMissNotices"),this.save()}getShellPath(){const e=this.settings.shellPath;return e&&x(e)}setShellPath(e){this.globalSettings.shellPath=e,this.markModified("shellPath"),this.save()}getQuietStartup(){const e=this.settings.quietStartup;return e===!1?!1:e==="header"?e:!0}setQuietStartup(e){this.globalSettings.quietStartup=e,this.markModified("quietStartup"),this.save()}getDefaultProjectTrust(){const e=this.globalSettings.defaultProjectTrust;return e==="always"||e==="never"?e:l.defaultProjectTrust}setDefaultProjectTrust(e){this.globalSettings.defaultProjectTrust=e,this.markModified("defaultProjectTrust"),this.save()}getShellCommandPrefix(){return this.settings.shellCommandPrefix}getShellEnvironmentPolicy(){const e=this.globalSettings.shellEnvironment??{},t=[...e.exclude??[],...this.projectSettings.shellEnvironment?.exclude??[]];return{...e.inherit!==void 0?{inherit:e.inherit}:{},...t.length>0?{exclude:t}:{},...e.include!==void 0?{include:[...e.include]}:{},...e.set!==void 0?{set:{...e.set}}:{}}}getPermissionRuleSources(){return{...this.globalSettings.permissions?{user:structuredClone(this.globalSettings.permissions)}:{},...this.projectSettings.permissions?{project:structuredClone(this.projectSettings.permissions)}:{}}}getSandboxSettingsSources(){return{...this.globalSettings.sandbox?{global:structuredClone(this.globalSettings.sandbox)}:{},...this.projectSettings.sandbox?{project:structuredClone(this.projectSettings.sandbox)}:{}}}setShellCommandPrefix(e){this.globalSettings.shellCommandPrefix=e,this.markModified("shellCommandPrefix"),this.save()}getNpmCommand(){return this.settings.npmCommand?[...this.settings.npmCommand]:void 0}setNpmCommand(e){this.globalSettings.npmCommand=e?[...e]:void 0,this.markModified("npmCommand"),this.save()}getCollapseChangelog(){return this.settings.collapseChangelog??!0}setCollapseChangelog(e){this.globalSettings.collapseChangelog=e,this.markModified("collapseChangelog"),this.save()}getEnableInstallTelemetry(){return this.settings.enableInstallTelemetry??l.enableInstallTelemetry}setEnableInstallTelemetry(e){this.globalSettings.enableInstallTelemetry=e,this.markModified("enableInstallTelemetry"),this.save()}getOrCreateDeviceId(){return this.globalSettings.deviceId||(this.globalSettings.deviceId=R(),this.markModified("deviceId"),this.save()),this.globalSettings.deviceId}getPackages(){return[...this.settings.packages??[]]}setPackages(e){this.globalSettings.packages=e,this.markModified("packages"),this.save()}setProjectPackages(e){this.updateProjectSettings("packages",t=>{t.packages=e})}getExtensionPaths(){return[...this.settings.extensions??[]]}setExtensionPaths(e){this.globalSettings.extensions=e,this.markModified("extensions"),this.save()}setProjectExtensionPaths(e){this.updateProjectSettings("extensions",t=>{t.extensions=e})}getSkillPaths(){return[...this.settings.skills??[]]}setSkillPaths(e){this.globalSettings.skills=e,this.markModified("skills"),this.save()}setProjectSkillPaths(e){this.updateProjectSettings("skills",t=>{t.skills=e})}getPromptTemplatePaths(){return[...this.settings.prompts??[]]}setPromptTemplatePaths(e){this.globalSettings.prompts=e,this.markModified("prompts"),this.save()}setProjectPromptTemplatePaths(e){this.updateProjectSettings("prompts",t=>{t.prompts=e})}getThemePaths(){return[...this.settings.themes??[]]}setThemePaths(e){this.globalSettings.themes=e,this.markModified("themes"),this.save()}setProjectThemePaths(e){this.updateProjectSettings("themes",t=>{t.themes=e})}getEnableSkillCommands(){return this.settings.enableSkillCommands??l.enableSkillCommands}setEnableSkillCommands(e){this.globalSettings.enableSkillCommands=e,this.markModified("enableSkillCommands"),this.save()}getFactoryEnabled(){return this.settings.factoryEnabled??!0}setFactoryEnabled(e){this.globalSettings.factoryEnabled=e,this.markModified("factoryEnabled"),this.save()}getThinkingBudgets(){return this.settings.thinkingBudgets}getTerminalCapabilityOverrides(){const e=this.settings.terminal,t=e?.images;return{...t==="kitty"||t==="iterm2"?{images:t}:t===!1?{images:null}:{},...typeof e?.trueColor=="boolean"?{trueColor:e.trueColor}:{},...typeof e?.hyperlinks=="boolean"?{hyperlinks:e.hyperlinks}:{}}}getShowImages(){return this.settings.terminal?.showImages??l.terminal.showImages}setShowImages(e){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.showImages=e,this.markModified("terminal","showImages"),this.save()}getImageWidthCells(){const e=this.settings.terminal?.imageWidthCells;return typeof e!="number"||!Number.isFinite(e)?l.terminal.imageWidthCells:Math.max(1,Math.floor(e))}setImageWidthCells(e){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.imageWidthCells=Math.max(1,Math.floor(e)),this.markModified("terminal","imageWidthCells"),this.save()}getClearOnShrink(){return this.settings.terminal?.clearOnShrink!==void 0?this.settings.terminal.clearOnShrink:process.env.PI_CLEAR_ON_SHRINK==="1"?!0:l.terminal.clearOnShrink}setClearOnShrink(e){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.clearOnShrink=e,this.markModified("terminal","clearOnShrink"),this.save()}getShowTerminalProgress(){return this.settings.terminal?.showTerminalProgress??l.terminal.showTerminalProgress}setShowTerminalProgress(e){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.showTerminalProgress=e,this.markModified("terminal","showTerminalProgress"),this.save()}getTuiMode(){return this.settings.tuiMode==="fullscreen"?"fullscreen":(this.settings.tuiMode==="regular"||this.settings.tuiMode,"regular")}setTuiMode(e){this.globalSettings.tuiMode=e,this.markModified("tuiMode"),this.save()}getFullscreenExitOutput(){return this.settings.fullscreenExitOutput==="resume-hint"?"resume-hint":l.fullscreenExitOutput}setFullscreenExitOutput(e){this.globalSettings.fullscreenExitOutput=e,this.markModified("fullscreenExitOutput"),this.save()}getFullscreenScrollbar(){const e=this.settings.fullscreenScrollbar;return e==="always"||e==="hidden"?e:l.fullscreenScrollbar}setFullscreenScrollbar(e){this.globalSettings.fullscreenScrollbar=e,this.markModified("fullscreenScrollbar"),this.save()}getFullscreenCopyOnSelect(){return this.settings.fullscreenCopyOnSelect??l.fullscreenCopyOnSelect}setFullscreenCopyOnSelect(e){this.globalSettings.fullscreenCopyOnSelect=e,this.markModified("fullscreenCopyOnSelect"),this.save()}getFullscreenWheelScrollLines(){const e=this.settings.fullscreenWheelScrollLines;return typeof e=="number"&&Number.isFinite(e)?Math.max(1,Math.min(100,Math.floor(e))):l.fullscreenWheelScrollLines}setFullscreenWheelScrollLines(e){this.globalSettings.fullscreenWheelScrollLines=e==="auto"?e:Math.max(1,Math.min(100,Math.floor(e))),this.markModified("fullscreenWheelScrollLines"),this.save()}getImageAutoResize(){return this.settings.images?.autoResize??l.images.autoResize}setImageAutoResize(e){this.globalSettings.images||(this.globalSettings.images={}),this.globalSettings.images.autoResize=e,this.markModified("images","autoResize"),this.save()}getBlockImages(){return this.settings.images?.blockImages??l.images.blockImages}setBlockImages(e){this.globalSettings.images||(this.globalSettings.images={}),this.globalSettings.images.blockImages=e,this.markModified("images","blockImages"),this.save()}getEnabledModels(){return this.settings.enabledModels}getDefaultTools(){const e=this.settings.defaultTools;if(e!==void 0)return se(Array.isArray(e)?e.filter(t=>typeof t=="string"):[])}setEnabledModels(e){this.globalSettings.enabledModels=e,this.markModified("enabledModels"),this.save()}getDoubleEscapeAction(){return this.settings.doubleEscapeAction??l.doubleEscapeAction}setDoubleEscapeAction(e){this.globalSettings.doubleEscapeAction=e,this.markModified("doubleEscapeAction"),this.save()}getTreeFilterMode(){const e=this.settings.treeFilterMode;return e&&["default","no-tools","user-only","labeled-only","all"].includes(e)?e:l.treeFilterMode}setTreeFilterMode(e){this.globalSettings.treeFilterMode=e,this.markModified("treeFilterMode"),this.save()}getShowHardwareCursor(){return this.settings.showHardwareCursor??process.env.PI_HARDWARE_CURSOR==="1"}setShowHardwareCursor(e){this.globalSettings.showHardwareCursor=e,this.markModified("showHardwareCursor"),this.save()}getEditorPaddingX(){return this.settings.editorPaddingX??1}setEditorPaddingX(e){this.globalSettings.editorPaddingX=Math.max(0,Math.min(3,Math.floor(e))),this.markModified("editorPaddingX"),this.save()}getOutputPad(){return this.settings.outputPad===1?1:0}setOutputPad(e){this.globalSettings.outputPad=e,this.markModified("outputPad"),this.save()}getAutocompleteMaxVisible(){return this.settings.autocompleteMaxVisible??l.autocompleteMaxVisible}setAutocompleteMaxVisible(e){this.globalSettings.autocompleteMaxVisible=Math.max(3,Math.min(20,Math.floor(e))),this.markModified("autocompleteMaxVisible"),this.save()}getCodeBlockIndent(){return this.settings.markdown?.codeBlockIndent??l.markdown.codeBlockIndent}getMermaidRenderingMode(){const e=this.settings.markdown?.mermaid;return e==="off"||e==="final"?e:l.markdown.mermaid}setMermaidRenderingMode(e){this.globalSettings.markdown??={},this.globalSettings.markdown.mermaid=e,this.markModified("markdown","mermaid"),this.save()}getWarnings(){return{...this.settings.warnings??{}}}setWarnings(e){this.globalSettings.warnings={...e},this.markModified("warnings"),this.save()}}export{Y as CACHE_WARMING_MODES,X as DEFAULT_COMPACTION_MAX_CONTEXT_TOKENS,Q as DEFAULT_MAX_OUTPUT_TOKENS,J as DEFAULT_MAX_RETRIES,Z as DEFAULT_TOOL_NAMES,re as FileSettingsStorage,oe as InMemorySettingsStorage,M as SETTINGS_FORMAT_VERSION,g as SettingsManager,ee as applyToolModifiers,ke as getToolListError,b as isToolModifier};
@@ -75,10 +75,11 @@ declare const PackageSourceSchema: Type.TUnion<[Type.TString, Type.TObject<{
75
75
  export declare const SettingsSchema: Type.TObject<{
76
76
  $schema: Type.TOptional<Type.TString>;
77
77
  lastChangelogVersion: Type.TOptional<Type.TString>;
78
+ extensionChangelogVersions: Type.TOptional<Type.TRecord<"^.*$", Type.TString>>;
78
79
  defaultProvider: Type.TOptional<Type.TString>;
79
80
  defaultModel: Type.TOptional<Type.TString>;
80
- defaultThinkingLevel: Type.TOptional<Type.TEnum<["off", "minimal", "low", "medium", "high", "xhigh", "max"]>>;
81
- modelThinkingLevels: Type.TOptional<Type.TRecord<"^.*$", Type.TEnum<["off", "minimal", "low", "medium", "high", "xhigh", "max"]>>>;
81
+ defaultThinkingLevel: Type.TOptional<Type.TUnsafe<"off" | "high" | "low" | "max" | "medium" | "minimal" | "xhigh">>;
82
+ modelThinkingLevels: Type.TOptional<Type.TRecord<"^.*$", Type.TUnsafe<"off" | "high" | "low" | "max" | "medium" | "minimal" | "xhigh">>>;
82
83
  transport: Type.TOptional<Type.TUnion<[Type.TLiteral<"auto">, Type.TLiteral<"sse">, Type.TLiteral<"websocket">, Type.TLiteral<"websocket-cached">]>>;
83
84
  sessionShareDestination: Type.TOptional<Type.TUnion<[Type.TLiteral<"auto">, Type.TLiteral<"gist">, Type.TLiteral<"radius">]>>;
84
85
  steeringMode: Type.TOptional<Type.TUnion<[Type.TLiteral<"all">, Type.TLiteral<"one-at-a-time">]>>;
@@ -117,6 +118,7 @@ export declare const SettingsSchema: Type.TObject<{
117
118
  defaultProjectTrust: Type.TOptional<Type.TUnion<[Type.TLiteral<"ask">, Type.TLiteral<"always">, Type.TLiteral<"never">]>>;
118
119
  shellCommandPrefix: Type.TOptional<Type.TString>;
119
120
  npmCommand: Type.TOptional<Type.TArray<Type.TString>>;
121
+ selfUpdateCommand: Type.TOptional<Type.TArray<Type.TString>>;
120
122
  collapseChangelog: Type.TOptional<Type.TBoolean>;
121
123
  enableInstallTelemetry: Type.TOptional<Type.TBoolean>;
122
124
  enableAnalytics: Type.TOptional<Type.TBoolean>;
@@ -1 +1 @@
1
- var p=Object.defineProperty;var o=(i,c)=>p(i,"name",{value:c,configurable:!0});import{ModelThinkingLevelSchema as r}from"@earendil-works/pi-ai/providers/model-schema";import{Type as e}from"typebox";import{SETTINGS_DEFAULTS as t}from"./settings-defaults.js";function n(i={}){return e.Integer({minimum:0,maximum:Number.MAX_SAFE_INTEGER,...i})}o(n,"nonNegativeSafeInteger");function a(i){return e.Union([e.Number({minimum:0}),e.Literal("disabled")],i)}o(a,"timeoutSetting");const m=e.Object({reserveTokens:e.Optional(n()),keepRecentTokens:e.Optional(n())}),u=e.Object({enabled:e.Optional(e.Boolean({default:t.compaction.enabled})),reserveTokens:e.Optional(n({default:t.compaction.reserveTokens})),keepRecentTokens:e.Optional(n({default:t.compaction.keepRecentTokens})),modelOverrides:e.Optional(e.Record(e.String(),m,{description:'Per-model overrides keyed by exact "provider/modelId" strings.'}))}),g=e.Object({reserveTokens:e.Optional(e.Number({description:"Tokens reserved for the prompt and LLM response.",default:t.branchSummary.reserveTokens})),skipPrompt:e.Optional(e.Boolean({description:'When true, skips the "Summarize branch?" prompt and defaults to no summary.',default:t.branchSummary.skipPrompt}))}),h=e.Object({timeoutMs:e.Optional(e.Number({description:"SDK or provider request timeout in milliseconds."})),maxRetries:e.Optional(e.Number({description:"SDK or provider retry attempts."})),maxRetryDelayMs:e.Optional(e.Number({description:"Maximum server-requested delay before failing.",default:t.retry.provider.maxRetryDelayMs}))}),f=e.Object({enabled:e.Optional(e.Boolean({default:t.retry.enabled})),maxRetries:e.Optional(e.Number({default:t.retry.maxRetries})),baseDelayMs:e.Optional(e.Number({description:"Exponential backoff base delay in milliseconds: 2s, 4s, 8s.",default:t.retry.baseDelayMs})),maxAgentDelayMs:e.Optional(e.Number({default:t.retry.maxAgentDelayMs})),provider:e.Optional(h),maxDelayMs:e.Optional(e.Number({description:"Legacy retry delay setting. Use provider.maxRetryDelayMs instead.",deprecated:!0}))}),O=e.Object({showImages:e.Optional(e.Boolean({description:"Show images when the terminal supports them.",default:t.terminal.showImages})),imageWidthCells:e.Optional(e.Number({description:"Preferred inline image width in terminal cells.",default:t.terminal.imageWidthCells})),clearOnShrink:e.Optional(e.Boolean({description:"Clear empty rows when content shrinks.",default:t.terminal.clearOnShrink})),showTerminalProgress:e.Optional(e.Boolean({description:"Show OSC 9;4 terminal progress indicators.",default:t.terminal.showTerminalProgress})),hyperlinks:e.Optional(e.Union([e.Boolean(),e.Literal("auto")])),images:e.Optional(e.Union([e.Literal("kitty"),e.Literal("iterm2"),e.Literal("auto"),e.Literal(!1)])),trueColor:e.Optional(e.Union([e.Boolean(),e.Literal("auto")]))}),b=e.Object({autoResize:e.Optional(e.Boolean({description:"Resize images to 2000x2000 maximum for better model compatibility.",default:t.images.autoResize})),blockImages:e.Optional(e.Boolean({description:"When true, prevents all images from being sent to LLM providers.",default:t.images.blockImages}))});function l(i){return e.Object({minimal:e.Optional(e.Number()),low:e.Optional(e.Number()),medium:e.Optional(e.Number()),high:e.Optional(e.Number())},i)}o(l,"thinkingBudgetsSettings");const U=l(),S=e.Object({codeBlockIndent:e.Optional(e.String({default:t.markdown.codeBlockIndent})),mermaid:e.Optional(e.Union([e.Literal("off"),e.Literal("final"),e.Literal("streaming")],{default:t.markdown.mermaid}))}),y=e.Object({anthropicExtraUsage:e.Optional(e.Boolean({default:t.warnings.anthropicExtraUsage}))});function s(i){return e.Union([e.Literal("on"),e.Literal("only")],i)}o(s,"codemodeMode");const B=s(),k=e.Object({mode:e.Optional(s({description:'How codemode presents tools. "on" keeps direct tools declared and annotates tools callable from scripts; codemode lists only tools without direct exposure. "only" lists every script-callable tool in codemode and does not declare active direct tools.',default:t.codemode.mode})),inlineBudget:e.Optional(e.Number({minimum:0,description:"Estimated tokens available for inline codemode tool declarations.",default:t.codemode.inlineBudget}))}),L=e.Union([e.String({description:"Load all resources from the package."}),e.Object({source:e.String(),autoload:e.Optional(e.Boolean({description:"When false, start empty and only apply explicit resource patterns."})),extensions:e.Optional(e.Array(e.String())),skills:e.Optional(e.Array(e.String())),prompts:e.Optional(e.Array(e.String())),themes:e.Optional(e.Array(e.String()))})],{description:"Package source for npm or git packages. Use the string form to load all resources or the object form to filter resources."}),d=e.Array(e.String()),w=e.Union([d,e.Object({enableSkillCommands:e.Optional(e.Boolean()),customDirectories:e.Optional(d)},{deprecated:!0})],{description:"Local skill file paths or directories."}),C=e.Object({$schema:e.Optional(e.String({description:"JSON Schema reference."})),lastChangelogVersion:e.Optional(e.String()),defaultProvider:e.Optional(e.String()),defaultModel:e.Optional(e.String()),defaultThinkingLevel:e.Optional(r),modelThinkingLevels:e.Optional(e.Record(e.String(),r,{description:'Per-model default thinking level overrides keyed by "provider/modelId".'})),transport:e.Optional(e.Union([e.Literal("auto"),e.Literal("sse"),e.Literal("websocket"),e.Literal("websocket-cached")],{default:t.transport})),sessionShareDestination:e.Optional(e.Union([e.Literal("auto"),e.Literal("gist"),e.Literal("radius")],{description:'Destination used by /share. "auto" uses Radius when authenticated and otherwise creates a GitHub gist.',default:t.sessionShareDestination})),steeringMode:e.Optional(e.Union([e.Literal("all"),e.Literal("one-at-a-time")],{default:t.steeringMode})),followUpMode:e.Optional(e.Union([e.Literal("all"),e.Literal("one-at-a-time")],{default:t.followUpMode})),theme:e.Optional(e.String()),compaction:e.Optional(u),branchSummary:e.Optional(g),retry:e.Optional(f),hideThinkingBlock:e.Optional(e.Boolean({default:t.hideThinkingBlock})),showCacheMissNotices:e.Optional(e.Boolean({description:"Show cache cost and provider recovery notices.",default:t.showCacheMissNotices})),externalEditor:e.Optional(e.String({description:"Command for Ctrl+G external editor; takes precedence over VISUAL and EDITOR."})),shellPath:e.Optional(e.String({description:"Custom shell path, for example for Cygwin on Windows, with support for leading ~ expansion."})),quietStartup:e.Optional(e.Union([e.Boolean(),e.Literal("header")],{description:'When true, hide all startup output. When "header", keep only the startup header.',default:t.quietStartup})),defaultProjectTrust:e.Optional(e.Union([e.Literal("ask"),e.Literal("always"),e.Literal("never")],{description:"Global setting only.",default:t.defaultProjectTrust})),shellCommandPrefix:e.Optional(e.String({description:"Prefix prepended to every bash command, for example to enable shell aliases."})),npmCommand:e.Optional(e.Array(e.String(),{description:'Command used for npm package lookup and installation, in argv form such as ["mise", "exec", "node@20", "--", "npm"].'})),collapseChangelog:e.Optional(e.Boolean({description:"Show the condensed changelog after update; use /changelog for the full changelog.",default:t.collapseChangelog})),enableInstallTelemetry:e.Optional(e.Boolean({description:"Send an anonymous version and update ping after changelog-detected updates.",default:t.enableInstallTelemetry})),enableAnalytics:e.Optional(e.Boolean({description:"Opt in to analytics data sharing.",default:t.enableAnalytics})),trackingId:e.Optional(e.String({description:"Analytics tracking identifier, generated when analytics is enabled."})),packages:e.Optional(e.Array(L,{description:"npm or git package sources, as strings or objects with resource filtering."})),extensions:e.Optional(e.Array(e.String(),{description:"Local extension file paths or directories."})),deviceId:e.Optional(e.String({description:"Stable installation UUID, generated when authentication first needs it. Global only."})),skills:e.Optional(w),prompts:e.Optional(e.Array(e.String(),{description:"Local prompt template file paths or directories."})),themes:e.Optional(e.Array(e.String(),{description:"Local theme file paths or directories."})),enableSkillCommands:e.Optional(e.Boolean({description:"Register skills as /skill:name commands.",default:t.enableSkillCommands})),terminal:e.Optional(O),images:e.Optional(b),enabledModels:e.Optional(e.Array(e.String(),{description:"Model patterns for cycling, in the same format as the --models CLI flag."})),defaultTools:e.Optional(e.Array(e.String(),{description:"Initial tool selection. Plain names replace the inherited selection; +name and -name entries add or remove tools."})),doubleEscapeAction:e.Optional(e.Union([e.Literal("fork"),e.Literal("tree"),e.Literal("none")],{description:"Action for double-escape with an empty editor.",default:t.doubleEscapeAction})),treeFilterMode:e.Optional(e.Union([e.Literal("default"),e.Literal("no-tools"),e.Literal("user-only"),e.Literal("labeled-only"),e.Literal("all")],{description:"Default filter when opening /tree.",default:t.treeFilterMode})),thinkingBudgets:e.Optional(l({description:"Custom token budgets for thinking levels."})),editorPaddingX:e.Optional(e.Number({description:"Horizontal padding for the input editor.",default:t.editorPaddingX})),outputPad:e.Optional(e.Union([e.Literal(0),e.Literal(1)],{description:"Horizontal padding for transcript content.",default:t.outputPad})),autocompleteMaxVisible:e.Optional(e.Number({description:"Maximum visible items in the autocomplete dropdown.",default:t.autocompleteMaxVisible})),showHardwareCursor:e.Optional(e.Boolean({description:"Show the terminal cursor while still positioning it for IME."})),markdown:e.Optional(S),warnings:e.Optional(y),codemode:e.Optional(k),sessionDir:e.Optional(e.String({description:"Custom session storage directory, in the same format as the --session-dir CLI flag."})),httpProxy:e.Optional(e.String({description:"Proxy URL applied as HTTP_PROXY and HTTPS_PROXY for Pi-managed HTTP clients."})),httpIdleTimeoutMs:e.Optional(a({description:'HTTP header or body idle timeout in milliseconds; 0 or "disabled" disables it.'})),stallWatchdogMs:e.Optional(a({description:'Milliseconds a run may go without model output, tool output or a heartbeat before it reports where it is waiting (default 60000); 0 or "disabled" turns the report off.'})),firstTokenTimeoutMs:e.Optional(a({description:'Model requests with no output within this many milliseconds are cancelled and retried; 0 or "disabled" disables it. Default 45000.'})),cacheWarming:e.Optional(e.Union([e.Literal("off"),e.Literal("streaming"),e.Literal("idle")],{description:'Cache-warming profile. "idle" also warms between agent runs. Global only because each refresh costs money.',default:t.cacheWarming})),websocketConnectTimeoutMs:e.Optional(a({description:'WebSocket connect or open handshake timeout in milliseconds; 0 or "disabled" disables it.'})),tuiMode:e.Optional(e.Union([e.Literal("regular"),e.Literal("fullscreen")],{default:t.tuiMode})),fullscreenExitOutput:e.Optional(e.Union([e.Literal("transcript"),e.Literal("resume-hint")],{description:"No effect in regular TUI mode.",default:t.fullscreenExitOutput})),fullscreenScrollbar:e.Optional(e.Union([e.Literal("auto"),e.Literal("always"),e.Literal("hidden")],{description:"No effect in regular TUI mode.",default:t.fullscreenScrollbar})),fullscreenCopyOnSelect:e.Optional(e.Boolean({description:"No effect in regular TUI mode.",default:t.fullscreenCopyOnSelect})),fullscreenWheelScrollLines:e.Optional(e.Union([e.Number(),e.Literal("auto")],{description:"Lines scrolled per wheel event in fullscreen mode; numeric values are clamped from 1 to 100.",default:t.fullscreenWheelScrollLines})),queueMode:e.Optional(e.Union([e.Literal("all"),e.Literal("one-at-a-time")],{description:"Legacy setting migrated to steeringMode.",deprecated:!0})),websockets:e.Optional(e.Boolean({description:"Legacy setting migrated to transport.",deprecated:!0}))},{additionalProperties:!0});export{C as SettingsSchema};
1
+ var p=Object.defineProperty;var o=(i,c)=>p(i,"name",{value:c,configurable:!0});import{Type as e}from"typebox";import{ModelThinkingLevelSchema as r}from"./pi-ai-schemas.js";import{SETTINGS_DEFAULTS as t}from"./settings-defaults.js";function n(i={}){return e.Integer({minimum:0,maximum:Number.MAX_SAFE_INTEGER,...i})}o(n,"nonNegativeSafeInteger");function a(i){return e.Union([e.Number({minimum:0}),e.Literal("disabled")],i)}o(a,"timeoutSetting");const m=e.Object({reserveTokens:e.Optional(n()),keepRecentTokens:e.Optional(n())}),u=e.Object({enabled:e.Optional(e.Boolean({default:t.compaction.enabled})),reserveTokens:e.Optional(n({default:t.compaction.reserveTokens})),keepRecentTokens:e.Optional(n({default:t.compaction.keepRecentTokens})),modelOverrides:e.Optional(e.Record(e.String(),m,{description:'Per-model overrides keyed by exact "provider/modelId" strings.'}))}),g=e.Object({reserveTokens:e.Optional(e.Number({description:"Tokens reserved for the prompt and LLM response.",default:t.branchSummary.reserveTokens})),skipPrompt:e.Optional(e.Boolean({description:'When true, skips the "Summarize branch?" prompt and defaults to no summary.',default:t.branchSummary.skipPrompt}))}),h=e.Object({timeoutMs:e.Optional(e.Number({description:"SDK or provider request timeout in milliseconds."})),maxRetries:e.Optional(e.Number({description:"SDK or provider retry attempts."})),maxRetryDelayMs:e.Optional(e.Number({description:"Maximum server-requested delay before failing.",default:t.retry.provider.maxRetryDelayMs}))}),f=e.Object({enabled:e.Optional(e.Boolean({default:t.retry.enabled})),maxRetries:e.Optional(e.Number({default:t.retry.maxRetries})),baseDelayMs:e.Optional(e.Number({description:"Exponential backoff base delay in milliseconds: 2s, 4s, 8s.",default:t.retry.baseDelayMs})),maxAgentDelayMs:e.Optional(e.Number({default:t.retry.maxAgentDelayMs})),provider:e.Optional(h),maxDelayMs:e.Optional(e.Number({description:"Legacy retry delay setting. Use provider.maxRetryDelayMs instead.",deprecated:!0}))}),O=e.Object({showImages:e.Optional(e.Boolean({description:"Show images when the terminal supports them.",default:t.terminal.showImages})),imageWidthCells:e.Optional(e.Number({description:"Preferred inline image width in terminal cells.",default:t.terminal.imageWidthCells})),clearOnShrink:e.Optional(e.Boolean({description:"Clear empty rows when content shrinks.",default:t.terminal.clearOnShrink})),showTerminalProgress:e.Optional(e.Boolean({description:"Show OSC 9;4 terminal progress indicators.",default:t.terminal.showTerminalProgress})),hyperlinks:e.Optional(e.Union([e.Boolean(),e.Literal("auto")])),images:e.Optional(e.Union([e.Literal("kitty"),e.Literal("iterm2"),e.Literal("auto"),e.Literal(!1)])),trueColor:e.Optional(e.Union([e.Boolean(),e.Literal("auto")]))}),S=e.Object({autoResize:e.Optional(e.Boolean({description:"Resize images to 2000x2000 maximum for better model compatibility.",default:t.images.autoResize})),blockImages:e.Optional(e.Boolean({description:"When true, prevents all images from being sent to LLM providers.",default:t.images.blockImages}))});function l(i){return e.Object({minimal:e.Optional(e.Number()),low:e.Optional(e.Number()),medium:e.Optional(e.Number()),high:e.Optional(e.Number())},i)}o(l,"thinkingBudgetsSettings");const U=l(),b=e.Object({codeBlockIndent:e.Optional(e.String({default:t.markdown.codeBlockIndent})),mermaid:e.Optional(e.Union([e.Literal("off"),e.Literal("final"),e.Literal("streaming")],{default:t.markdown.mermaid}))}),y=e.Object({anthropicExtraUsage:e.Optional(e.Boolean({default:t.warnings.anthropicExtraUsage}))});function s(i){return e.Union([e.Literal("on"),e.Literal("only")],i)}o(s,"codemodeMode");const C=s(),k=e.Object({mode:e.Optional(s({description:'How codemode presents tools. "on" keeps direct tools declared and annotates tools callable from scripts; codemode lists only tools without direct exposure. "only" lists every script-callable tool in codemode and does not declare active direct tools.',default:t.codemode.mode})),inlineBudget:e.Optional(e.Number({minimum:0,description:"Estimated tokens available for inline codemode tool declarations.",default:t.codemode.inlineBudget}))}),L=e.Union([e.String({description:"Load all resources from the package."}),e.Object({source:e.String(),autoload:e.Optional(e.Boolean({description:"When false, start empty and only apply explicit resource patterns."})),extensions:e.Optional(e.Array(e.String())),skills:e.Optional(e.Array(e.String())),prompts:e.Optional(e.Array(e.String())),themes:e.Optional(e.Array(e.String()))})],{description:"Package source for npm or git packages. Use the string form to load all resources or the object form to filter resources."}),d=e.Array(e.String()),w=e.Union([d,e.Object({enableSkillCommands:e.Optional(e.Boolean()),customDirectories:e.Optional(d)},{deprecated:!0})],{description:"Local skill file paths or directories."}),P=e.Object({$schema:e.Optional(e.String({description:"JSON Schema reference."})),lastChangelogVersion:e.Optional(e.String()),extensionChangelogVersions:e.Optional(e.Record(e.String(),e.String(),{description:"Last seen changelog version per extension package."})),defaultProvider:e.Optional(e.String()),defaultModel:e.Optional(e.String()),defaultThinkingLevel:e.Optional(r),modelThinkingLevels:e.Optional(e.Record(e.String(),r,{description:'Per-model default thinking level overrides keyed by "provider/modelId".'})),transport:e.Optional(e.Union([e.Literal("auto"),e.Literal("sse"),e.Literal("websocket"),e.Literal("websocket-cached")],{default:t.transport})),sessionShareDestination:e.Optional(e.Union([e.Literal("auto"),e.Literal("gist"),e.Literal("radius")],{description:'Destination used by /share. "auto" uses Radius when authenticated and otherwise creates a GitHub gist.',default:t.sessionShareDestination})),steeringMode:e.Optional(e.Union([e.Literal("all"),e.Literal("one-at-a-time")],{default:t.steeringMode})),followUpMode:e.Optional(e.Union([e.Literal("all"),e.Literal("one-at-a-time")],{default:t.followUpMode})),theme:e.Optional(e.String()),compaction:e.Optional(u),branchSummary:e.Optional(g),retry:e.Optional(f),hideThinkingBlock:e.Optional(e.Boolean({default:t.hideThinkingBlock})),showCacheMissNotices:e.Optional(e.Boolean({description:"Show cache cost and provider recovery notices.",default:t.showCacheMissNotices})),externalEditor:e.Optional(e.String({description:"Command for Ctrl+G external editor; takes precedence over VISUAL and EDITOR."})),shellPath:e.Optional(e.String({description:"Custom shell path, for example for Cygwin on Windows, with support for leading ~ expansion."})),quietStartup:e.Optional(e.Union([e.Boolean(),e.Literal("header")],{description:'When true, hide all startup output. When "header", keep only the startup header.',default:t.quietStartup})),defaultProjectTrust:e.Optional(e.Union([e.Literal("ask"),e.Literal("always"),e.Literal("never")],{description:"Global setting only.",default:t.defaultProjectTrust})),shellCommandPrefix:e.Optional(e.String({description:"Prefix prepended to every bash command, for example to enable shell aliases."})),npmCommand:e.Optional(e.Array(e.String(),{description:'Command used for npm package lookup and installation, in argv form such as ["mise", "exec", "node@20", "--", "npm"].'})),selfUpdateCommand:e.Optional(e.Array(e.String(),{minItems:1,description:'Command `pi update` runs to update Pi itself, in argv form such as ["mise", "use", "-g", "npm:{packageName}@{version}"]. Placeholders: {packageName}, {version}, {installSpec}. PI_SELF_UPDATE_COMMAND takes precedence. Global setting only.'})),collapseChangelog:e.Optional(e.Boolean({description:"Show the condensed changelog after update; use /changelog for the full changelog.",default:t.collapseChangelog})),enableInstallTelemetry:e.Optional(e.Boolean({description:"Send an anonymous version and update ping after changelog-detected updates.",default:t.enableInstallTelemetry})),enableAnalytics:e.Optional(e.Boolean({description:"Opt in to analytics data sharing.",default:t.enableAnalytics})),trackingId:e.Optional(e.String({description:"Analytics tracking identifier, generated when analytics is enabled."})),packages:e.Optional(e.Array(L,{description:"npm or git package sources, as strings or objects with resource filtering."})),extensions:e.Optional(e.Array(e.String(),{description:"Local extension file paths or directories."})),deviceId:e.Optional(e.String({description:"Stable installation UUID, generated when authentication first needs it. Global only."})),skills:e.Optional(w),prompts:e.Optional(e.Array(e.String(),{description:"Local prompt template file paths or directories."})),themes:e.Optional(e.Array(e.String(),{description:"Local theme file paths or directories."})),enableSkillCommands:e.Optional(e.Boolean({description:"Register skills as /skill:name commands.",default:t.enableSkillCommands})),terminal:e.Optional(O),images:e.Optional(S),enabledModels:e.Optional(e.Array(e.String(),{description:"Model patterns for cycling, in the same format as the --models CLI flag."})),defaultTools:e.Optional(e.Array(e.String(),{description:"Initial tool selection. Plain names replace the inherited selection; +name and -name entries add or remove tools."})),doubleEscapeAction:e.Optional(e.Union([e.Literal("fork"),e.Literal("tree"),e.Literal("none")],{description:"Action for double-escape with an empty editor.",default:t.doubleEscapeAction})),treeFilterMode:e.Optional(e.Union([e.Literal("default"),e.Literal("no-tools"),e.Literal("user-only"),e.Literal("labeled-only"),e.Literal("all")],{description:"Default filter when opening /tree.",default:t.treeFilterMode})),thinkingBudgets:e.Optional(l({description:"Custom token budgets for thinking levels."})),editorPaddingX:e.Optional(e.Number({description:"Horizontal padding for the input editor.",default:t.editorPaddingX})),outputPad:e.Optional(e.Union([e.Literal(0),e.Literal(1)],{description:"Horizontal padding for transcript content.",default:t.outputPad})),autocompleteMaxVisible:e.Optional(e.Number({description:"Maximum visible items in the autocomplete dropdown.",default:t.autocompleteMaxVisible})),showHardwareCursor:e.Optional(e.Boolean({description:"Show the terminal cursor while still positioning it for IME."})),markdown:e.Optional(b),warnings:e.Optional(y),codemode:e.Optional(k),sessionDir:e.Optional(e.String({description:"Custom session storage directory, in the same format as the --session-dir CLI flag."})),httpProxy:e.Optional(e.String({description:"Proxy URL applied as HTTP_PROXY and HTTPS_PROXY for Pi-managed HTTP clients."})),httpIdleTimeoutMs:e.Optional(a({description:'HTTP header or body idle timeout in milliseconds; 0 or "disabled" disables it.'})),stallWatchdogMs:e.Optional(a({description:'Milliseconds a run may go without model output, tool output or a heartbeat before it reports where it is waiting (default 60000); 0 or "disabled" turns the report off.'})),firstTokenTimeoutMs:e.Optional(a({description:'Model requests with no output within this many milliseconds are cancelled and retried; 0 or "disabled" disables it. Default 45000.'})),cacheWarming:e.Optional(e.Union([e.Literal("off"),e.Literal("streaming"),e.Literal("idle")],{description:'Cache-warming profile. "idle" also warms between agent runs. Global only because each refresh costs money.',default:t.cacheWarming})),websocketConnectTimeoutMs:e.Optional(a({description:'WebSocket connect or open handshake timeout in milliseconds; 0 or "disabled" disables it.'})),tuiMode:e.Optional(e.Union([e.Literal("regular"),e.Literal("fullscreen")],{default:t.tuiMode})),fullscreenExitOutput:e.Optional(e.Union([e.Literal("transcript"),e.Literal("resume-hint")],{description:"No effect in regular TUI mode.",default:t.fullscreenExitOutput})),fullscreenScrollbar:e.Optional(e.Union([e.Literal("auto"),e.Literal("always"),e.Literal("hidden")],{description:"No effect in regular TUI mode.",default:t.fullscreenScrollbar})),fullscreenCopyOnSelect:e.Optional(e.Boolean({description:"No effect in regular TUI mode.",default:t.fullscreenCopyOnSelect})),fullscreenWheelScrollLines:e.Optional(e.Union([e.Number(),e.Literal("auto")],{description:"Lines scrolled per wheel event in fullscreen mode; numeric values are clamped from 1 to 100.",default:t.fullscreenWheelScrollLines})),queueMode:e.Optional(e.Union([e.Literal("all"),e.Literal("one-at-a-time")],{description:"Legacy setting migrated to steeringMode.",deprecated:!0})),websockets:e.Optional(e.Boolean({description:"Legacy setting migrated to transport.",deprecated:!0}))},{additionalProperties:!0});export{P as SettingsSchema};
@@ -1,4 +1,4 @@
1
- var R=Object.defineProperty;var h=(t,e)=>R(t,"name",{value:e,configurable:!0});import{existsSync as I,readdirSync as T,readFileSync as _,statSync as $}from"fs";import C from"ignore";import{basename as M,dirname as G,join as w,relative as P,resolve as E,sep as W}from"path";import{CONFIG_DIR_NAME as j,getAgentDir as K}from"../config.js";import{parseFrontmatter as O}from"../utils/frontmatter.js";import{canonicalizePath as U,resolvePath as b}from"../utils/paths.js";import{createSyntheticSourceInfo as F}from"./source-info.js";const A=64,z=1024,X=[".gitignore",".ignore",".fdignore"];function x(t){return t.split(W).join("/")}h(x,"toPosixPath");function q(t,e){const n=t.trim();if(!n||n.startsWith("#")&&!n.startsWith("\\#"))return null;let s=t,o=!1;s.startsWith("!")?(o=!0,s=s.slice(1)):s.startsWith("\\!")&&(s=s.slice(1)),s.startsWith("/")&&(s=s.slice(1));const r=e?`${e}${s}`:s;return o?`!${r}`:r}h(q,"prefixIgnorePattern");function H(t,e,n){const s=P(n,e),o=s?`${x(s)}/`:"";for(const r of X){const c=w(e,r);if(I(c))try{const u=_(c,"utf-8").split(/\r?\n/).map(d=>q(d,o)).filter(d=>!!d);u.length>0&&t.add(u)}catch{}}}h(H,"addIgnoreRules");function B(t){const e=[];return t.length>A&&e.push(`name exceeds ${A} characters (${t.length})`),/^[a-z0-9-]+$/.test(t)||e.push("name contains invalid characters (must be lowercase a-z, 0-9, hyphens only)"),(t.startsWith("-")||t.endsWith("-"))&&e.push("name must not start or end with a hyphen"),t.includes("--")&&e.push("name must not contain consecutive hyphens"),e}h(B,"validateName");function J(t){const e=[];return typeof t!="string"||t.trim()===""?e.push("description is required"):t.length>z&&e.push(`description exceeds ${z} characters (${t.length})`),e}h(J,"validateDescription");function Q(t,e,n){switch(n){case"user":return F(t,{source:"local",scope:"user",baseDir:e});case"project":return F(t,{source:"local",scope:"project",baseDir:e});case"path":return F(t,{source:"local",baseDir:e});default:return F(t,{source:n,baseDir:e})}}h(Q,"createSkillSourceInfo");function rt(t){const{dir:e,source:n}=t;return v(e,n,!0)}h(rt,"loadSkillsFromDir");function v(t,e,n,s,o){const r=[],c=[];if(!I(t))return{skills:r,diagnostics:c};const m=o??t,u=s??C();H(u,t,m);try{const d=T(t,{withFileTypes:!0});for(const l of d){if(l.name!=="SKILL.md")continue;const g=w(t,l.name);let k=l.isFile();if(l.isSymbolicLink())try{k=$(g).isFile()}catch{continue}const y=x(P(m,g));if(!k||u.ignores(y))continue;const f=L(g,e);return f.skill&&r.push(f.skill),c.push(...f.diagnostics),{skills:r,diagnostics:c}}for(const l of d){if(l.name.startsWith(".")||l.name==="node_modules")continue;const g=w(t,l.name);let k=l.isDirectory(),y=l.isFile();if(l.isSymbolicLink())try{const a=$(g);k=a.isDirectory(),y=a.isFile()}catch{continue}const f=x(P(m,g)),p=k?`${f}/`:f;if(u.ignores(p))continue;if(k){const a=v(g,e,!1,u,m);r.push(...a.skills),c.push(...a.diagnostics);continue}if(!y||!n||!l.name.endsWith(".md"))continue;const i=L(g,e);i.skill&&r.push(i.skill),c.push(...i.diagnostics)}}catch{}return{skills:r,diagnostics:c}}h(v,"loadSkillsFromDirInternal");function L(t,e){const n=[],s=M(t)==="SKILL.md";let o;try{o=_(t,"utf-8")}catch(f){const p=f instanceof Error?f.message:"failed to read skill file";return n.push({type:"warning",message:p,path:t}),{skill:null,diagnostics:n}}let r;try{({frontmatter:r}=O(o))}catch(f){if(s){const p=f instanceof Error?f.message:"failed to parse skill file";n.push({type:"warning",message:p,path:t})}return{skill:null,diagnostics:n}}const c=r.description,m=typeof c=="string"&&c.trim()!=="";if(!s&&!m)return{skill:null,diagnostics:n};const u=G(t),d=M(u),l=J(c);for(const f of l)n.push({type:"warning",message:f,path:t});const k=(typeof r.name=="string"?r.name:void 0)||d,y=B(k);for(const f of y)n.push({type:"warning",message:f,path:t});return m?{skill:{name:k,description:c,filePath:t,baseDir:u,sourceInfo:Q(t,u,e),disableModelInvocation:r["disable-model-invocation"]===!0},diagnostics:n}:{skill:null,diagnostics:n}}h(L,"loadSkillFromFile");function ot(t,e="read"){const n=t.filter(o=>!o.disableModelInvocation);if(n.length===0)return"";const s=[`
1
+ var R=Object.defineProperty;var f=(t,s)=>R(t,"name",{value:s,configurable:!0});import{existsSync as F,readdirSync as T,readFileSync as N,statSync as I}from"fs";import C from"ignore";import{basename as x,dirname as G,join as S,relative as P,resolve as W,sep as K}from"path";import{CONFIG_DIR_NAME as _,getAgentDir as z}from"../config.js";import{parseFrontmatter as O}from"../utils/frontmatter.js";import{isPathWithin as M,resolvePath as $}from"../utils/paths.js";import{createSyntheticSourceInfo as D,getResourcePathKey as U}from"./source-info.js";const j=64,A=1024,X=[".gitignore",".ignore",".fdignore"];function E(t){return t.split(K).join("/")}f(E,"toPosixPath");function q(t,s){const n=t.trim();if(!n||n.startsWith("#")&&!n.startsWith("\\#"))return null;let e=t,l=!1;e.startsWith("!")?(l=!0,e=e.slice(1)):e.startsWith("\\!")&&(e=e.slice(1)),e.startsWith("/")&&(e=e.slice(1));const r=s?`${s}${e}`:e;return l?`!${r}`:r}f(q,"prefixIgnorePattern");function H(t,s,n){const e=P(n,s),l=e?`${E(e)}/`:"";for(const r of X){const c=S(s,r);if(F(c))try{const u=N(c,"utf-8").split(/\r?\n/).map(d=>q(d,l)).filter(d=>!!d);u.length>0&&t.add(u)}catch{}}}f(H,"addIgnoreRules");function B(t){const s=[];return t.length>j&&s.push(`name exceeds ${j} characters (${t.length})`),/^[a-z0-9-]+$/.test(t)||s.push("name contains invalid characters (must be lowercase a-z, 0-9, hyphens only)"),(t.startsWith("-")||t.endsWith("-"))&&s.push("name must not start or end with a hyphen"),t.includes("--")&&s.push("name must not contain consecutive hyphens"),s}f(B,"validateName");function J(t){const s=[];return typeof t!="string"||t.trim()===""?s.push("description is required"):t.length>A&&s.push(`description exceeds ${A} characters (${t.length})`),s}f(J,"validateDescription");function Q(t,s,n){switch(n){case"user":return D(t,{source:"local",scope:"user",baseDir:s});case"project":return D(t,{source:"local",scope:"project",baseDir:s});case"path":return D(t,{source:"local",baseDir:s});default:return D(t,{source:n,baseDir:s})}}f(Q,"createSkillSourceInfo");function ot(t){const{dir:s,source:n}=t;return w(s,n,!0)}f(ot,"loadSkillsFromDir");function w(t,s,n,e,l){const r=[],c=[];if(!F(t))return{skills:r,diagnostics:c};const m=l??t,u=e??C();H(u,t,m);try{const d=T(t,{withFileTypes:!0});for(const a of d){if(a.name!=="SKILL.md")continue;const g=S(t,a.name);let k=a.isFile();if(a.isSymbolicLink())try{k=I(g).isFile()}catch{continue}const y=E(P(m,g));if(!k||u.ignores(y))continue;const i=b(g,s);return i.skill&&r.push(i.skill),c.push(...i.diagnostics),{skills:r,diagnostics:c}}for(const a of d){if(a.name.startsWith(".")||a.name==="node_modules")continue;const g=S(t,a.name);let k=a.isDirectory(),y=a.isFile();if(a.isSymbolicLink())try{const p=I(g);k=p.isDirectory(),y=p.isFile()}catch{continue}const i=E(P(m,g)),o=k?`${i}/`:i;if(u.ignores(o))continue;if(k){const p=w(g,s,!1,u,m);r.push(...p.skills),c.push(...p.diagnostics);continue}if(!y||!n||!a.name.endsWith(".md"))continue;const h=b(g,s);h.skill&&r.push(h.skill),c.push(...h.diagnostics)}}catch{}return{skills:r,diagnostics:c}}f(w,"loadSkillsFromDirInternal");function b(t,s){const n=[],e=x(t)==="SKILL.md";let l;try{l=N(t,"utf-8")}catch(i){const o=i instanceof Error?i.message:"failed to read skill file";return n.push({type:"warning",message:o,path:t}),{skill:null,diagnostics:n}}let r;try{({frontmatter:r}=O(l))}catch(i){if(e){const o=i instanceof Error?i.message:"failed to parse skill file";n.push({type:"warning",message:o,path:t})}return{skill:null,diagnostics:n}}const c=r.description,m=typeof c=="string"&&c.trim()!=="";if(!e&&!m)return{skill:null,diagnostics:n};const u=G(t),d=x(u),a=J(c);for(const i of a)n.push({type:"warning",message:i,path:t});const k=(typeof r.name=="string"?r.name:void 0)||d,y=B(k);for(const i of y)n.push({type:"warning",message:i,path:t});return m?{skill:{name:k,description:c,filePath:t,baseDir:u,sourceInfo:Q(t,u,s),disableModelInvocation:r["disable-model-invocation"]===!0},diagnostics:n}:{skill:null,diagnostics:n}}f(b,"loadSkillFromFile");function rt(t,s="read"){const n=t.filter(l=>!l.disableModelInvocation);if(n.length===0)return"";const e=[`
2
2
 
3
- The following skills provide specialized instructions for specific tasks.`,e==="read"?"Use the read tool to load a skill's file when the task matches its description.":e==="bash"?"Use bash to load a skill's file when the task matches its description.":"Load a skill's file when the task matches its description.","When a skill file references a relative path, resolve it against the skill directory (parent of SKILL.md / dirname of the path) and use that absolute path in tool commands.","","<available_skills>"];for(const o of n)s.push(" <skill>"),s.push(` <name>${N(o.name)}</name>`),s.push(` <description>${N(o.description)}</description>`),s.push(` <location>${N(o.filePath)}</location>`),s.push(" </skill>");return s.push("</available_skills>"),s.join(`
4
- `)}h(ot,"formatSkillsForPrompt");function N(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}h(N,"escapeXml");function lt(t){const{agentDir:e,skillPaths:n,includeDefaults:s}=t,o=b(t.cwd),r=b(e??K()),c=new Map,m=new Set,u=[],d=[];function l(p){u.push(...p.diagnostics);for(const i of p.skills){const a=U(i.filePath);if(m.has(a))continue;const S=c.get(i.name);S?d.push({type:"collision",message:`name "${i.name}" collision`,path:i.filePath,collision:{resourceType:"skill",name:i.name,winnerPath:S.filePath,loserPath:i.filePath}}):(c.set(i.name,i),m.add(a))}}h(l,"addSkills"),s&&(l(v(w(r,"skills"),"user",!0)),l(v(E(o,j,"skills"),"project",!0)));const g=w(r,"skills"),k=E(o,j,"skills"),y=h((p,i)=>{const a=E(i);if(p===a)return!0;const S=a.endsWith(W)?a:`${a}${W}`;return p.startsWith(S)},"isUnderPath"),f=h(p=>{if(!s){if(y(p,g))return"user";if(y(p,k))return"project"}return"path"},"getSource");for(const p of n){const i=b(p,o,{trim:!0});if(!I(i)){u.push({type:"warning",message:"skill path does not exist",path:i});continue}try{const a=$(i),S=f(i);if(a.isDirectory())l(v(i,S,!0));else if(a.isFile()&&i.endsWith(".md")){const D=L(i,S);D.skill?l({skills:[D.skill],diagnostics:D.diagnostics}):u.push(...D.diagnostics)}else u.push({type:"warning",message:"skill path is not a markdown file",path:i})}catch(a){const S=a instanceof Error?a.message:"failed to read skill path";u.push({type:"warning",message:S,path:i})}}return{skills:Array.from(c.values()),diagnostics:[...u,...d]}}h(lt,"loadSkills");export{ot as formatSkillsForPrompt,lt as loadSkills,rt as loadSkillsFromDir};
3
+ The following skills provide specialized instructions for specific tasks.`,s==="read"?"Use the read tool to load a skill's file when the task matches its description.":s==="bash"?"Use bash to load a skill's file when the task matches its description.":"Load a skill's file when the task matches its description.","Resolve relative paths against the skill's directory (parent of SKILL.md). Use absolute paths in tool calls.","","<available_skills>"];for(const l of n)e.push(" <skill>"),e.push(` <name>${L(l.name)}</name>`),e.push(` <description>${L(l.description)}</description>`),e.push(` <location>${L(l.filePath)}</location>`),e.push(" </skill>");return e.push("</available_skills>"),e.join(`
4
+ `)}f(rt,"formatSkillsForPrompt");function L(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}f(L,"escapeXml");function lt(t){const{agentDir:s,skillPaths:n,includeDefaults:e}=t,l=$(t.cwd),r=$(s??z()),c=new Map,m=new Set,u=[],d=[];function a(i){u.push(...i.diagnostics);for(const o of i.skills){const h=U(o.filePath);if(m.has(h))continue;const p=c.get(o.name);p?d.push({type:"collision",message:`name "${o.name}" collision`,path:o.filePath,collision:{resourceType:"skill",name:o.name,winnerPath:p.filePath,loserPath:o.filePath}}):(c.set(o.name,o),m.add(h))}}f(a,"addSkills"),e&&(a(w(S(r,"skills"),"user",!0)),a(w(W(l,_,"skills"),"project",!0)));const g=S(r,"skills"),k=W(l,_,"skills"),y=f(i=>{if(!e){if(M(g,i))return"user";if(M(k,i))return"project"}return"path"},"getSource");for(const i of n){const o=$(i,l,{trim:!0});if(!F(o)){u.push({type:"warning",message:"skill path does not exist",path:o});continue}try{const h=I(o),p=y(o);if(h.isDirectory())a(w(o,p,!0));else if(h.isFile()&&o.endsWith(".md")){const v=b(o,p);v.skill?a({skills:[v.skill],diagnostics:v.diagnostics}):u.push(...v.diagnostics)}else u.push({type:"warning",message:"skill path is not a markdown file",path:o})}catch(h){const p=h instanceof Error?h.message:"failed to read skill path";u.push({type:"warning",message:p,path:o})}}return{skills:Array.from(c.values()),diagnostics:[...u,...d]}}f(lt,"loadSkills");export{rt as formatSkillsForPrompt,lt as loadSkills,ot as loadSkillsFromDir};
@@ -1 +1 @@
1
- var p=Object.defineProperty;var n=(t,r)=>p(t,"name",{value:r,configurable:!0});import{APP_NAME as s}from"../config.js";import{fill as l,t as o}from"../dal/i18n.js";function e(t,r,i){return{name:t,get description(){return r()},...i&&{argumentHint:i}}}n(e,"builtin");const u=[e("settings",()=>o("\u6253\u5F00\u8BBE\u7F6E\u83DC\u5355")),e("extensions",()=>o("\u542F\u7528\u6216\u505C\u7528\u5DF2\u52A0\u8F7D\u7684\u6269\u5C55")),e("model",()=>o("\u9009\u62E9\u6A21\u578B\uFF08\u6253\u5F00\u9009\u62E9\u754C\u9762\uFF09"),"<provider/model>"),e("tree",()=>o("\u6D4F\u89C8\u4F1A\u8BDD\u6811\uFF0C\u5207\u6362\u5206\u652F")),e("thinking",()=>o("\u8BBE\u7F6E\u601D\u8003\u6DF1\u5EA6"),"<level>"),e("scoped-models",()=>o("\u9009\u62E9\u54EA\u4E9B\u6A21\u578B\u53C2\u4E0E Ctrl+P \u8F6E\u6362")),e("export",()=>o("\u5BFC\u51FA\u4F1A\u8BDD\uFF08\u9ED8\u8BA4 HTML\uFF0C\u4E5F\u53EF\u6307\u5B9A\u8DEF\u5F84\uFF1A.html/.jsonl\uFF09")),e("import",()=>o("\u4ECE JSONL \u6587\u4EF6\u5BFC\u5165\u4F1A\u8BDD\u5E76\u7EE7\u7EED")),e("share",()=>o("\u628A\u4F1A\u8BDD\u5206\u4EAB\u4E3A\u79C1\u5BC6 GitHub gist")),e("bug",()=>o("\u5BFC\u51FA\u95EE\u9898\u62A5\u544A\uFF08\u672C\u5730 zip\uFF09\uFF0C\u53D1\u7ED9\u6280\u672F\u652F\u6301"),"<description>"),e("copy",()=>o("\u590D\u5236\u6700\u540E\u4E00\u6761\u56DE\u590D\u5230\u526A\u8D34\u677F")),e("name",()=>o("\u8BBE\u7F6E\u4F1A\u8BDD\u663E\u793A\u540D\u79F0")),e("session",()=>o("\u67E5\u770B\u4F1A\u8BDD\u4FE1\u606F\u548C\u7EDF\u8BA1")),e("map",()=>o("\u67E5\u770B\u7CBE\u7B80\u7684\u9879\u76EE\u7ED3\u6784\u56FE")),e("changelog",()=>o("\u67E5\u770B\u66F4\u65B0\u65E5\u5FD7")),e("hotkeys",()=>o("\u67E5\u770B\u5168\u90E8\u5FEB\u6377\u952E")),e("fork",()=>o("\u4ECE\u4E4B\u524D\u7684\u67D0\u6761\u6D88\u606F\u5206\u53C9\u51FA\u65B0\u4F1A\u8BDD")),e("clone",()=>o("\u5728\u5F53\u524D\u4F4D\u7F6E\u590D\u5236\u4E00\u4EFD\u4F1A\u8BDD")),e("trust",()=>o("\u4FDD\u5B58\u9879\u76EE\u4FE1\u4EFB\u8BBE\u7F6E\uFF0C\u4EE5\u540E\u7684\u4F1A\u8BDD\u6CBF\u7528")),e("login",()=>o("\u914D\u7F6E\u6A21\u578B\u63D0\u4F9B\u65B9\u7684\u767B\u5F55"),"<provider>"),e("logout",()=>o("\u79FB\u9664\u6A21\u578B\u63D0\u4F9B\u65B9\u7684\u767B\u5F55\u4FE1\u606F")),e("new",()=>o("\u5F00\u59CB\u65B0\u4F1A\u8BDD")),e("compact",()=>o("\u624B\u52A8\u538B\u7F29\u4F1A\u8BDD\u4E0A\u4E0B\u6587")),e("resume",()=>o("\u6062\u590D\u4E4B\u524D\u7684\u4F1A\u8BDD")),e("reload",()=>o("\u91CD\u65B0\u52A0\u8F7D\u5FEB\u6377\u952E\u3001\u6269\u5C55\u3001\u6280\u80FD\u3001\u63D0\u793A\u8BCD\u3001\u4E3B\u9898\u548C\u4E0A\u4E0B\u6587\u6587\u4EF6")),e("quit",()=>l(o("\u9000\u51FA {app}"),{app:s}))];export{u as BUILTIN_SLASH_COMMANDS};
1
+ var p=Object.defineProperty;var n=(t,r)=>p(t,"name",{value:r,configurable:!0});import{APP_NAME as s}from"../config.js";import{fill as l,t as o}from"../dal/i18n.js";function e(t,r,i){return{name:t,get description(){return r()},...i&&{argumentHint:i}}}n(e,"builtin");const u=[e("settings",()=>o("\u6253\u5F00\u8BBE\u7F6E\u83DC\u5355")),e("extensions",()=>o("\u542F\u7528\u6216\u505C\u7528\u5DF2\u52A0\u8F7D\u7684\u6269\u5C55")),e("model",()=>o("\u9009\u62E9\u6A21\u578B\uFF08\u6253\u5F00\u9009\u62E9\u754C\u9762\uFF09"),"<provider/model>"),e("tree",()=>o("\u6D4F\u89C8\u4F1A\u8BDD\u6811\uFF0C\u5207\u6362\u5206\u652F")),e("thinking",()=>o("\u8BBE\u7F6E\u601D\u8003\u6DF1\u5EA6"),"<level>"),e("scoped-models",()=>o("\u9009\u62E9\u54EA\u4E9B\u6A21\u578B\u53C2\u4E0E Ctrl+P \u8F6E\u6362")),e("export",()=>o("\u5BFC\u51FA\u4F1A\u8BDD\uFF08\u9ED8\u8BA4 HTML\uFF0C\u4E5F\u53EF\u6307\u5B9A\u8DEF\u5F84\uFF1A.html/.jsonl\uFF09")),e("import",()=>o("\u5BFC\u5165 JSONL \u4F1A\u8BDD\uFF0C\u4FDD\u7559\u539F\u4F1A\u8BDD ID \u548C\u5DE5\u4F5C\u76EE\u5F55")),e("share",()=>o("\u628A\u4F1A\u8BDD\u5206\u4EAB\u4E3A\u79C1\u5BC6 GitHub gist")),e("bug",()=>o("\u5BFC\u51FA\u95EE\u9898\u62A5\u544A\uFF08\u672C\u5730 zip\uFF09\uFF0C\u53D1\u7ED9\u6280\u672F\u652F\u6301"),"<description>"),e("copy",()=>o("\u590D\u5236\u6700\u540E\u4E00\u6761\u56DE\u590D\u5230\u526A\u8D34\u677F")),e("name",()=>o("\u8BBE\u7F6E\u4F1A\u8BDD\u663E\u793A\u540D\u79F0")),e("session",()=>o("\u67E5\u770B\u4F1A\u8BDD\u4FE1\u606F\u548C\u7EDF\u8BA1")),e("map",()=>o("\u67E5\u770B\u7CBE\u7B80\u7684\u9879\u76EE\u7ED3\u6784\u56FE")),e("changelog",()=>o("\u67E5\u770B\u66F4\u65B0\u65E5\u5FD7")),e("hotkeys",()=>o("\u67E5\u770B\u5168\u90E8\u5FEB\u6377\u952E")),e("fork",()=>o("\u4ECE\u4E4B\u524D\u7684\u67D0\u6761\u6D88\u606F\u5206\u53C9\u51FA\u65B0\u4F1A\u8BDD")),e("clone",()=>o("\u5728\u5F53\u524D\u4F4D\u7F6E\u590D\u5236\u4E00\u4EFD\u4F1A\u8BDD")),e("trust",()=>o("\u4FDD\u5B58\u9879\u76EE\u4FE1\u4EFB\u8BBE\u7F6E\uFF0C\u4EE5\u540E\u7684\u4F1A\u8BDD\u6CBF\u7528")),e("login",()=>o("\u914D\u7F6E\u6A21\u578B\u63D0\u4F9B\u65B9\u7684\u767B\u5F55"),"<provider>"),e("logout",()=>o("\u79FB\u9664\u6A21\u578B\u63D0\u4F9B\u65B9\u7684\u767B\u5F55\u4FE1\u606F")),e("new",()=>o("\u5F00\u59CB\u65B0\u4F1A\u8BDD")),e("compact",()=>o("\u624B\u52A8\u538B\u7F29\u4F1A\u8BDD\u4E0A\u4E0B\u6587")),e("resume",()=>o("\u6062\u590D\u4E4B\u524D\u7684\u4F1A\u8BDD")),e("reload",()=>o("\u91CD\u65B0\u52A0\u8F7D\u5FEB\u6377\u952E\u3001\u6269\u5C55\u3001\u6280\u80FD\u3001\u63D0\u793A\u8BCD\u3001\u4E3B\u9898\u548C\u4E0A\u4E0B\u6587\u6587\u4EF6")),e("quit",()=>l(o("\u9000\u51FA {app}"),{app:s}))];export{u as BUILTIN_SLASH_COMMANDS};
@@ -8,14 +8,22 @@ export interface SourceInfo {
8
8
  origin: SourceOrigin;
9
9
  baseDir?: string;
10
10
  packageName?: string;
11
+ changelogPath?: string;
11
12
  }
13
+ export interface SourcePackageIdentity {
14
+ source: string;
15
+ scope: SourceScope;
16
+ }
17
+ export declare function getSourcePackageKey(identity: SourcePackageIdentity): string;
12
18
  export declare const BUILTIN_PATH_PREFIX = "builtin:";
13
19
  export declare function getSyntheticPathSource(path: string): string | undefined;
14
20
  export declare function isSyntheticPath(path: string): boolean;
21
+ export declare function getResourcePathKey(path: string): string;
15
22
  export declare function createSourceInfo(path: string, metadata: PathMetadata): SourceInfo;
16
23
  export declare function createSyntheticSourceInfo(path: string, options: {
17
24
  source: string;
18
25
  scope?: SourceScope;
19
26
  origin?: SourceOrigin;
20
27
  baseDir?: string;
28
+ changelogPath?: string;
21
29
  }): SourceInfo;
@@ -1 +1 @@
1
- var o=Object.defineProperty;var n=(e,r)=>o(e,"name",{value:r,configurable:!0});import{readFileSync as s}from"node:fs";import{join as u}from"node:path";const c="builtin:";function h(e){if(e.startsWith(c))return"builtin";if(e.startsWith("<")&&e.endsWith(">"))return e.slice(1,-1).split(":")[0]||"temporary"}n(h,"getSyntheticPathSource");function l(e){return e.startsWith(c)||e.startsWith("<")}n(l,"isSyntheticPath");const i=new Map;function a(e){if(!i.has(e)){let r;try{const t=JSON.parse(s(u(e,"package.json"),"utf8"));r=typeof t.name=="string"?t.name:void 0}catch{r=void 0}i.set(e,r)}return i.get(e)}n(a,"packageNameAt");function y(e,r){const t=r.packageRoot?a(r.packageRoot):void 0;return{path:e,source:r.source,scope:r.scope,origin:r.origin,baseDir:r.baseDir,...t?{packageName:t}:{}}}n(y,"createSourceInfo");function S(e,r){return{path:e,source:r.source,scope:r.scope??"temporary",origin:r.origin??"top-level",baseDir:r.baseDir}}n(S,"createSyntheticSourceInfo");export{c as BUILTIN_PATH_PREFIX,y as createSourceInfo,S as createSyntheticSourceInfo,h as getSyntheticPathSource,l as isSyntheticPath};
1
+ var i=Object.defineProperty;var n=(e,r)=>i(e,"name",{value:r,configurable:!0});import{readFileSync as s}from"node:fs";import{join as u}from"node:path";import{canonicalizePath as a,getPathComparisonKey as g}from"../utils/paths.js";function S(e){return JSON.stringify({source:e.source,scope:e.scope})}n(S,"getSourcePackageKey");const o="builtin:";function m(e){if(e.startsWith(o))return"builtin";if(e.startsWith("<")&&e.endsWith(">"))return e.slice(1,-1).split(":")[0]||"temporary"}n(m,"getSyntheticPathSource");function f(e){return e.startsWith(o)||e.startsWith("<")}n(f,"isSyntheticPath");const c=new Map;function h(e){if(!c.has(e)){let r;try{const t=JSON.parse(s(u(e,"package.json"),"utf8"));r=typeof t.name=="string"?t.name:void 0}catch{r=void 0}c.set(e,r)}return c.get(e)}n(h,"packageNameAt");function k(e){return f(e)?e:g(a(e))}n(k,"getResourcePathKey");function x(e,r){const t=r.packageRoot?h(r.packageRoot):void 0;return{path:e,source:r.source,scope:r.scope,origin:r.origin,baseDir:r.baseDir,...t?{packageName:t}:{},...r.changelogPath?{changelogPath:r.changelogPath}:{}}}n(x,"createSourceInfo");function b(e,r){return{path:e,source:r.source,scope:r.scope??"temporary",origin:r.origin??"top-level",baseDir:r.baseDir,...r.changelogPath?{changelogPath:r.changelogPath}:{}}}n(b,"createSyntheticSourceInfo");export{o as BUILTIN_PATH_PREFIX,x as createSourceInfo,b as createSyntheticSourceInfo,k as getResourcePathKey,S as getSourcePackageKey,m as getSyntheticPathSource,f as isSyntheticPath};
@@ -1,12 +1,12 @@
1
- var x=Object.defineProperty;var c=(e,t)=>x(e,"name",{value:t,configurable:!0});import{join as $}from"node:path";import{getSystemMessageText as j}from"@earendil-works/pi-ai";import{APP_NAME as v,APP_TITLE as p,getDalDocsPath as E,getDocsPath as T,getExamplesPath as O,getReadmePath as _,IS_WHITE_LABEL_BUILD as I}from"../config.js";import{describeGitState as N}from"./git-state.js";import{INJECTED_CONTEXT_TAG as R}from"./messages.js";import{describeProjectFacts as A}from"./project-facts.js";import{formatSkillsForPrompt as C}from"./skills.js";const F=/^[a-z][a-z0-9_-]*$/;function M(e){return{customPrompt:e.customPrompt,forceSystemPrompt:e.forceSystemPrompt,selectedTools:[...e.selectedTools??["read","bash","edit","write"]],hiddenTools:[...e.hiddenTools??[]],toolSnippets:{...e.toolSnippets??{}},toolGuidelines:Object.fromEntries(Object.entries(e.toolGuidelines??{}).map(([t,n])=>[t,[...n]])),promptGuidelines:[...e.promptGuidelines??[]],appendSystemPrompt:e.appendSystemPrompt??"",sections:{...e.sections??{}},cwd:e.cwd,gitState:e.gitState,projectFacts:e.projectFacts,contextFiles:(e.contextFiles??[]).map(t=>({...t})),skills:(e.skills??[]).map(t=>({...t}))}}c(M,"normalizeBuildSystemPromptOptions");function D(e){return["Project-specific instructions and guidelines:",...e.map(({path:t,content:n})=>`<project_instructions path="${t}">
1
+ var x=Object.defineProperty;var c=(e,t)=>x(e,"name",{value:t,configurable:!0});import{join as $}from"node:path";import{getSystemMessageText as j}from"@earendil-works/pi-ai";import{APP_NAME as v,APP_TITLE as p,getDalDocsPath as E,getDocsPath as T,getExamplesPath as O,getReadmePath as _,IS_WHITE_LABEL_BUILD as I}from"../config.js";import{describeGitState as N}from"./git-state.js";import{INJECTED_CONTEXT_TAG as A}from"./messages.js";import{describeProjectFacts as R}from"./project-facts.js";import{formatSkillsForPrompt as C}from"./skills.js";const F=/^[a-z][a-z0-9_-]*$/;function M(e){return{customPrompt:e.customPrompt,forceSystemPrompt:e.forceSystemPrompt,selectedTools:[...e.selectedTools??["read","bash","edit","write"]],hiddenTools:[...e.hiddenTools??[]],toolSnippets:{...e.toolSnippets??{}},toolGuidelines:Object.fromEntries(Object.entries(e.toolGuidelines??{}).map(([t,n])=>[t,[...n]])),promptGuidelines:[...e.promptGuidelines??[]],appendSystemPrompt:e.appendSystemPrompt??"",sections:{...e.sections??{}},cwd:e.cwd,gitState:e.gitState,projectFacts:e.projectFacts,contextFiles:(e.contextFiles??[]).map(t=>({...t})),skills:(e.skills??[]).map(t=>({...t}))}}c(M,"normalizeBuildSystemPromptOptions");function D(e){return["Project-specific instructions and guidelines:",...e.map(({path:t,content:n})=>`<project_instructions path="${t}">
2
2
  ${n}
3
3
  </project_instructions>`)].join(`
4
4
 
5
- `)}c(D,"renderProjectContext");function G(e,t,n){const i=[],d=new Set,o=c(l=>{const m=l.trim();!m||d.has(m)||(d.add(m),i.push(m))},"addRule"),h=e.includes("bash"),u=e.includes("powershell"),a=e.includes("grep"),f=e.includes("find"),y=e.includes("ls");(h||u)&&!a&&!f&&!y&&o(h&&u?"Use bash or PowerShell for file operations like listing, searching, and finding files":u?"Use PowerShell for file operations like listing, searching, and finding files":"Use bash for file operations like ls, rg, find");for(const l of e)for(const m of t[l]??[])o(m);for(const l of n)o(l);return e.length>0&&(o("Plan a step's lookups first, then make the independent calls (reads, searches, read-only commands) together in one response; they run in parallel"),o("Use paths relative to the working directory; do not begin commands with cd into it"),o("Finish the task in this turn; ask only to choose between approaches, or before push, deploy, delete, spend or send"),o("Reproduce a reported bug before changing code; if it does not reproduce, or the premise does not match what the code or tests show, say so plainly, give the evidence and change no product code, whatever a loaded skill assumes"),o("When a protection refuses a call, stop that step and say why; never reach the same data another way"),o(`You are ${p}: adapt instructions written for another agent, and sign commits "Co-Authored-By: ${p} <noreply@deepailab.ai>", never Claude, Codex or Copilot`)),o(`Text inside <${R} type="..."> tags comes from ${p}, not the user: follow it, but do not answer it as the user's words`),o("Reply in the language of the user's latest message, whatever language tool results, skills or injected notices use"),o("Be concise, and show file paths clearly"),i.map(l=>`- ${l}`).join(`
5
+ `)}c(D,"renderProjectContext");function G(e,t,n){const i=[],d=new Set,o=c(l=>{const m=l.trim();!m||d.has(m)||(d.add(m),i.push(m))},"addRule"),h=e.includes("bash"),u=e.includes("powershell"),a=e.includes("grep"),f=e.includes("find"),y=e.includes("ls");(h||u)&&!a&&!f&&!y&&o(h&&u?"Use bash or PowerShell for file operations like listing, searching, and finding files":u?"Use PowerShell for file operations like listing, searching, and finding files":"Use bash for file operations like ls, rg, find");for(const l of e)for(const m of t[l]??[])o(m);for(const l of n)o(l);return e.length>0&&(o("Plan a step's lookups first, then make the independent calls (reads, searches, read-only commands) together in one response; they run in parallel"),o("Use paths relative to the working directory; do not begin commands with cd into it"),o("Finish the task in this turn; ask only to choose between approaches, or before push, deploy, delete, spend or send"),o("Reproduce a reported bug before changing code; if it does not reproduce, or the premise does not match what the code or tests show, say so plainly, give the evidence and change no product code, whatever a loaded skill assumes"),o("When a protection refuses a call, stop that step and say why; never reach the same data another way"),o(`You are ${p}: adapt instructions written for another agent, and sign commits "Co-Authored-By: ${p} <noreply@deepailab.ai>", never Claude, Codex or Copilot`)),o(`Text inside <${A} type="..."> tags comes from ${p}, not the user: follow it, but do not answer it as the user's words`),o("Reply in the language of the user's latest message, whatever language tool results, skills or injected notices use"),o("Be concise, and show file paths clearly"),i.map(l=>`- ${l}`).join(`
6
6
  `)}c(G,"buildRules");function L(e){const t=M(e),{customPrompt:n,selectedTools:i,hiddenTools:d,toolSnippets:o,toolGuidelines:h,promptGuidelines:u,appendSystemPrompt:a,sections:f,cwd:y,contextFiles:l,skills:m}=t;for(const s of Object.keys(f))if(!F.test(s)||s==="preamble")throw new Error(`Invalid system prompt section name: ${s}`);const S=i.filter(s=>!d.includes(s)),r={};if(n)r.preamble=n;else{r.preamble=`You are an expert coding assistant operating inside ${p} (${v}). You help users by reading files, executing commands, editing code, and writing new files.`;const s=S.filter(b=>!!o[b]),g=s.length>0?s.map(b=>`- ${b}: ${o[b]}`).join(`
7
7
  `):"(none)";r.tools=`${g}
8
8
 
9
- In addition to the tools above, you may have access to other custom tools depending on the project.`,r.rules=G(S,h,u),r.docs=z()}a&&(r.addendum=a),l.length>0&&(r.project_context=D(l));const k=["read","bash"],w=k.find(s=>S.includes(s))??(k.some(s=>i.includes(s))?"indirect":void 0);if(f.skills)r.skills=f.skills;else if(w&&m.length>0){const s=C(m,w).trim();s&&(r.skills=s)}if(r.cwd=`Current working directory: ${y.replace(/\\/g,"/")}. Commands and relative paths start here; do not cd into it first.`,t.gitState&&!f.git_state&&(r.git=N(y)),t.projectFacts&&!f.project){const s=A(y);s&&(r.project=s)}for(const[s,g]of Object.entries(f))g&&(r[s]=g);const P={preamble:r.preamble};for(const[s,g]of Object.entries(r))s!=="preamble"&&(P[s]=`<${s}>
9
+ Additional tools may be available.`,r.rules=G(S,h,u),r.docs=z()}a&&(r.addendum=a),l.length>0&&(r.project_context=D(l));const k=["read","bash"],w=k.find(s=>S.includes(s))??(k.some(s=>i.includes(s))?"indirect":void 0);if(f.skills)r.skills=f.skills;else if(w&&m.length>0){const s=C(m,w).trim();s&&(r.skills=s)}if(r.cwd=`Current working directory: ${y.replace(/\\/g,"/")}. Commands and relative paths start here; do not cd into it first.`,t.gitState&&!f.git_state&&(r.git=N(y)),t.projectFacts&&!f.project){const s=R(y);s&&(r.project=s)}for(const[s,g]of Object.entries(f))g&&(r[s]=g);const P={preamble:r.preamble};for(const[s,g]of Object.entries(r))s!=="preamble"&&(P[s]=`<${s}>
10
10
  ${g}
11
11
  </${s}>`);return P}c(L,"buildSystemPromptSections");const U="cwd",B="Environment of this session, part of the system prompt. Later updates to these sections arrive as system prompt updates.";function Z(e){const t=e[0];if(!t||t.role!=="system"||!t.sections)return e;const n=Object.keys(t.sections),i=n.indexOf(U);if(i===-1)return e;const d=n.slice(i).map(a=>t.sections?.[a]).filter(a=>typeof a=="string"&&a.length>0),o=Object.fromEntries(n.slice(0,i).map(a=>[a,t.sections?.[a]??null])),h={...t,sections:o};if(d.length===0)return[h,...e.slice(1)];const u={role:"user",content:[{type:"text",text:`<session_environment>
12
12
  ${B}
@@ -1,10 +1,10 @@
1
- import { type AgentTool } from "@earendil-works/pi-agent-core";
2
1
  import { type ChildProcess } from "child_process";
3
2
  import { type Static, Type } from "typebox";
4
3
  import { type ShellConfig } from "../../utils/shell.ts";
5
4
  import type { BackgroundProcessInfo, BackgroundProcessManager } from "../background-processes.ts";
6
5
  import type { ToolDefinition } from "../extensions/types.ts";
7
6
  import { type SandboxRunDetails, type ShellSandbox } from "../sandbox/shell-sandbox.ts";
7
+ import { type TypeBoxAgentTool } from "./tool-definition-wrapper.ts";
8
8
  import { type TruncationResult } from "./truncate.ts";
9
9
  declare const bashSchema: Type.TObject<{
10
10
  command: Type.TString;
@@ -98,5 +98,5 @@ export interface ShellToolConfig {
98
98
  }
99
99
  export declare function createShellToolDefinition(cwd: string, config: ShellToolConfig, options?: BashToolOptions): ToolDefinition<typeof bashSchema, BashToolDetails | undefined, BashRenderState>;
100
100
  export declare function createBashToolDefinition(cwd: string, options?: BashToolOptions): ToolDefinition<typeof bashSchema, BashToolDetails | undefined, BashRenderState>;
101
- export declare function createBashTool(cwd: string, options?: BashToolOptions): AgentTool<typeof bashSchema>;
101
+ export declare function createBashTool(cwd: string, options?: BashToolOptions): TypeBoxAgentTool<typeof bashSchema>;
102
102
  export {};
@@ -1,20 +1,20 @@
1
- var $e=Object.defineProperty;var r=(t,e)=>$e(t,"name",{value:e,configurable:!0});import{constants as Le}from"node:fs";import{access as Te}from"node:fs/promises";import{constants as Ce}from"node:os";import{ToolExecutionError as le}from"@earendil-works/pi-agent-core";import{Container as Pe,Text as W,truncateToWidth as De}from"@earendil-works/pi-tui";import{spawn as ve}from"child_process";import{Type as l}from"typebox";import{fill as G,t as P}from"../../dal/i18n.js";import{keyHint as Ie}from"../../modes/interactive/components/keybinding-hints.js";import{truncateToVisualLines as Ae}from"../../modes/interactive/components/visual-truncate.js";import{theme as x}from"../../modes/interactive/theme/theme.js";import{waitForChildProcess as ke}from"../../utils/child-process.js";import{writeOutputFile as Me}from"../../utils/output-files.js";import{getShellConfig as ue,getShellEnv as ce,killProcessTree as me,trackDetachedChildPid as Fe,untrackDetachedChildPid as Ne}from"../../utils/shell.js";import{missingManagedToolHint as Be}from"../../utils/tools-manager.js";import{describeDenialForModel as Re}from"../sandbox/denial.js";import{getProcessShellSandbox as Ue}from"../sandbox/shell-sandbox.js";import{toolDenial as Ge,withToolDenial as He}from"../tool-denial.js";import{isReadOnlyBashCommand as je}from"./bash-read-only.js";import{OutputAccumulator as We}from"./output-accumulator.js";import{condenseShellOutput as Ve,outputCondenseDisabled as Ye}from"./output-condense.js";import{countOutputLines as Xe,formatCollapsedSummary as Ke,getTextOutput as pe,invalidArgText as qe,str as fe,truncateDisplay as ze}from"./render-utils.js";import{wrapToolDefinition as Je}from"./tool-definition-wrapper.js";import{DEFAULT_MAX_BYTES as Qe,formatSize as Ze,SHELL_OUTPUT_MAX_CHARS as ee,truncateHeadTail as et}from"./truncate.js";const he=2147483647,we=1024*1024,tt=8*1024*1024,nt=he/1e3,te=12e4,ne=30;function ot(t){if(t===void 0)return te;if(!Number.isFinite(t)||t<=0)throw new Error("Invalid timeout: must be a finite number of seconds");const e=t*1e3;if(e>he)throw new Error(`Invalid timeout: maximum is ${nt} seconds`);return e}r(ot,"resolveTimeoutMs");const Se=l.Object({command:l.String({description:"Shell command to execute"}),description:l.String({description:`What it does and why, 3-10 words in the user's language, shown instead of the command: "Find hardcoded key names", not "run grep"`}),timeout:l.Optional(l.Number({description:"Seconds to wait for the command (default in the tool description). Raise it for long builds."}))}),it=l.Optional(l.Object({mode:l.Union([l.Literal("allow"),l.Literal("unsandboxed")],{description:'"allow": stay sandboxed with the domains/paths below; "unsandboxed": run outside the sandbox'}),justification:l.String({description:"Why, in one sentence for the user, who must approve it"}),allow_domains:l.Optional(l.Array(l.String(),{description:"e.g. registry.npmjs.org"})),allow_write:l.Optional(l.Array(l.String(),{description:"Paths to make writable"}))},{description:"Only after the sandbox blocked this command: the access it needs. Never pre-emptively."})),st=l.Object({...Se.properties,sandbox_escalation:it}),be={snippet:"Execute bash commands (ls, grep, find, etc.)",guidelines:["You can inspect DAL_* environment variables for current model and session details."]},rt=l.Object({output:l.String({description:"Combined stdout and stderr, possibly truncated"}),truncated:l.Boolean(),full_output_path:l.Optional(l.String({description:"Full output, when truncated"})),exit_code:l.Number({description:"-1 while the command runs in the background"}),background_id:l.Optional(l.String({description:"Background process id, when it is still running"})),wall_time_seconds:l.Number()});function at(t,e){return{exec:r(async(n,o,{onData:u,signal:i,timeout:y,env:w,yieldTo:s})=>{const $=ot(y);if(i?.aborted)throw new Error("aborted");const S=e();try{await Te(o,Le.F_OK)}catch{throw new Error(`Working directory does not exist: ${o}
2
- Cannot execute ${t} commands.`)}const b=S.commandTransport==="stdin",c=ve(S.shell,b?S.args:[...S.args,n],{cwd:o,detached:process.platform!=="win32",env:w??ce(),stdio:[b?"pipe":"ignore","pipe","pipe"],windowsHide:!0});b&&(c.stdin?.on("error",()=>{}),c.stdin?.end(n)),c.pid&&Fe(c.pid);let a=!1,m=!1,h;const p=new Promise(A=>{h=r(()=>A("yielded"),"onYielded")});let f;const _=r(()=>{c.pid&&me(c.pid)},"onAbort");try{$!==void 0&&(f=setTimeout(()=>{if(s&&c.exitCode===null&&c.signalCode===null&&s(c)){m=!0,h?.();return}a=!0,c.pid&&me(c.pid)},$)),c.stdout?.on("data",u),c.stderr?.on("data",u),i&&(i.aborted?_():i.addEventListener("abort",_,{once:!0}));const A=ke(c),D=await Promise.race([A,p]);if(D==="yielded")return A.catch(()=>{}),{exitCode:null,yielded:!0};const H=D;if(i?.aborted)throw new Error("aborted");if(a)throw new Error(`timeout:${($??te)/1e3}`);const V=c.signalCode;return{exitCode:H??(V?128+(Ce.signals[V]??0):1)}}finally{c.pid&&!m&&Ne(c.pid),f&&clearTimeout(f),i&&i.removeEventListener("abort",_)}},"exec")}}r(at,"createLocalShellOperations");function dt(t){return at("bash",()=>ue(t?.shellPath))}r(dt,"createLocalBashOperations");const oe=Symbol.for("dal.shell.executionGuards"),ie=globalThis;ie[oe]instanceof Set||(ie[oe]=new Set);const se=ie[oe];function Xt(t){return se.add(t),()=>{se.delete(t)}}r(Xt,"registerShellExecutionGuard");async function lt(t){for(const e of se){let n;try{n=await e(t)}catch(o){return`Command refused: the safety check could not run (${o instanceof Error?o.message:String(o)}).`}if(n!==void 0)return n}}r(lt,"shellExecutionRefusal");const ut=["SESSION_ID","SESSION_FILE","PROVIDER","MODEL","REASONING_LEVEL"];function ct(t,e,n,o,u){const i={...ce()};if(delete i.PI_SESSION_ID,delete i.PI_SESSION_FILE,delete i.PI_PROVIDER,delete i.PI_MODEL,delete i.PI_REASONING_LEVEL,o&&u){const w=u.model;i.PI_SESSION_ID=u.sessionManager.getSessionId();const s=u.sessionManager.getSessionFile();s&&(i.PI_SESSION_FILE=s),w&&(i.PI_PROVIDER=w.provider,i.PI_MODEL=w.id),u.thinkingLevel&&(i.PI_REASONING_LEVEL=u.thinkingLevel)}for(const w of ut){delete i[`DAL_${w}`];const s=i[`PI_${w}`];s!==void 0&&(i[`DAL_${w}`]=s)}const y={command:t,cwd:e,env:i};return n?n(y):y}r(ct,"resolveSpawnContext");const mt=5,pt=100;class ft extends Pe{static{r(this,"BashResultRenderComponent")}state={cachedWidth:void 0,cachedLines:void 0,cachedSkipped:void 0}}function ht(t){const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const n=Math.floor(e),o=Math.floor(n/60),u=n%60;return o<60?`${o}m ${u}s`:`${Math.floor(o/60)}h ${o%60}m ${u}s`}r(ht,"formatDuration");function wt(t,e,n=!1){const o=fe(t?.command),u=fe(t?.description)?.trim(),i=t?.timeout,y=i?x.fg("muted",G(P(" (\u8D85\u65F6 {seconds} \u79D2)"),{seconds:i})):"";if(u){const s=x.fg("toolTitle",x.bold(u))+y;return!n||!o?s:`${s}
3
- ${x.fg("muted",` \u23BF ${e} ${o.trim()}`)}`}const w=o===null?qe(x):o?x.fg("dim",ze(o.replace(/\s+/g," ").trim(),42)):x.fg("dim","\u2026");return`${x.fg("toolTitle",x.bold(e))} ${w}${y}`}r(wt,"formatShellCall");function St(t,e,n,o,u,i,y,w){const s=t.state;t.clear();const $=bt(n,u,i,w);if(!n.expanded&&!y){const a=pe(e,o),m=Xe(a),h=[];m>0&&h.push(G(P("{count} \u884C"),{count:m})),$&&h.push($);const p=Ke(x,h);p&&t.addChild(new W(p,0,0));return}let S=pe(e,o).trim();const b=e.details?.truncation,c=e.details?.fullOutputPath;if(!n.isPartial&&b?.truncated&&c&&S.endsWith("]")){const a=S.lastIndexOf(`
1
+ var Le=Object.defineProperty;var s=(t,e)=>Le(t,"name",{value:e,configurable:!0});import{constants as Te}from"node:fs";import{access as Ce}from"node:fs/promises";import{constants as Pe}from"node:os";import{ToolExecutionError as ue}from"@earendil-works/pi-agent-core";import{Container as De,Text as Y,truncateToWidth as ve}from"@earendil-works/pi-tui";import{spawn as Ie}from"child_process";import{Type as u}from"typebox";import{fill as W,t as v}from"../../dal/i18n.js";import{keyHint as Ae}from"../../modes/interactive/components/keybinding-hints.js";import{truncateToVisualLines as ke}from"../../modes/interactive/components/visual-truncate.js";import{theme as E}from"../../modes/interactive/theme/theme.js";import{waitForChildProcess as Me}from"../../utils/child-process.js";import{writeOutputFile as Fe}from"../../utils/output-files.js";import{getShellConfig as ce,getShellEnv as me,killProcessTree as pe,trackDetachedChildPid as Ne,untrackDetachedChildPid as Be}from"../../utils/shell.js";import{missingManagedToolHint as Re}from"../../utils/tools-manager.js";import{describeDenialForModel as Ue}from"../sandbox/denial.js";import{getProcessShellSandbox as Ge}from"../sandbox/shell-sandbox.js";import{toolDenial as He,withToolDenial as je}from"../tool-denial.js";import{isReadOnlyBashCommand as We}from"./bash-read-only.js";import{OutputAccumulator as Ve}from"./output-accumulator.js";import{condenseShellOutput as Ye,outputCondenseDisabled as Xe}from"./output-condense.js";import{countOutputLines as Ke,formatCollapsedSummary as qe,getTextOutput as fe,invalidArgText as ze,str as he,truncateDisplay as Je}from"./render-utils.js";import{wrapToolDefinition as Qe}from"./tool-definition-wrapper.js";import{DEFAULT_MAX_BYTES as Ze,formatSize as et,SHELL_OUTPUT_MAX_CHARS as ee,truncateHeadTail as tt}from"./truncate.js";const we=2147483647,Se=1024*1024,nt=8*1024*1024,ot=we/1e3,te=12e4,ne=30;function it(t){if(t===void 0)return te;if(!Number.isFinite(t)||t<=0)throw new Error("Invalid timeout: must be a finite number of seconds");const e=t*1e3;if(e>we)throw new Error(`Invalid timeout: maximum is ${ot} seconds`);return e}s(it,"resolveTimeoutMs");const xe=u.Object({command:u.String({description:"Shell command to execute"}),description:u.String({description:`What it does and why, 3-10 words in the user's language, shown instead of the command: "Find hardcoded key names", not "run grep"`}),timeout:u.Optional(u.Number({description:"Seconds to wait for the command (default in the tool description). Raise it for long builds."}))}),st=u.Optional(u.Object({mode:u.Union([u.Literal("allow"),u.Literal("unsandboxed")],{description:'"allow": stay sandboxed with the domains/paths below; "unsandboxed": run outside the sandbox'}),justification:u.String({description:"Why, in one sentence for the user, who must approve it"}),allow_domains:u.Optional(u.Array(u.String(),{description:"e.g. registry.npmjs.org"})),allow_write:u.Optional(u.Array(u.String(),{description:"Paths to make writable"}))},{description:"Only after the sandbox blocked this command: the access it needs. Never pre-emptively."})),rt=u.Object({...xe.properties,sandbox_escalation:st}),be={snippet:"Execute bash commands (ls, grep, find, etc.)",guidelines:["You can inspect DAL_* environment variables for current model and session details."]},at=u.Object({output:u.String({description:"Combined stdout and stderr, possibly truncated"}),truncated:u.Boolean(),full_output_path:u.Optional(u.String({description:"Full output, when truncated"})),exit_code:u.Number({description:"-1 while the command runs in the background"}),background_id:u.Optional(u.String({description:"Background process id, when it is still running"})),wall_time_seconds:u.Number()});class Ee extends Error{static{s(this,"ShellTimeoutError")}shellExit;constructor(e,n){super(`timeout:${e}`),this.shellExit=n}}function dt(t,e){return{exec:s(async(n,o,{onData:c,signal:i,timeout:$,env:w,yieldTo:r})=>{const L=it($);if(i?.aborted)throw new Error("aborted");const S=e();try{await Ce(o,Te.F_OK)}catch{throw new Error(`Working directory does not exist: ${o}
2
+ Cannot execute ${t} commands.`)}const x=S.commandTransport==="stdin",a=Ie(S.shell,x?S.args:[...S.args,n],{cwd:o,detached:process.platform!=="win32",env:w??me(),stdio:[x?"pipe":"ignore","pipe","pipe"],windowsHide:!0});x&&(a.stdin?.on("error",()=>{}),a.stdin?.end(n)),a.pid&&Ne(a.pid);const d=performance.now();let p;a.once("exit",()=>{p=performance.now()-d});let h=!1,m=!1,f;const T=new Promise(U=>{f=s(()=>U("yielded"),"onYielded")});let R,D;const k=s(()=>{a.pid&&pe(a.pid)},"onAbort");try{L!==void 0&&(D=setTimeout(()=>{if(r&&a.exitCode===null&&a.signalCode===null&&r(a)){m=!0,f?.();return}h=!0,R=p,a.pid&&pe(a.pid)},L)),a.stdout?.on("data",c),a.stderr?.on("data",c),i&&(i.aborted?k():i.addEventListener("abort",k,{once:!0}));const U=Me(a),C=await Promise.race([U,T]);if(C==="yielded")return U.catch(()=>{}),{exitCode:null,yielded:!0};const O=C;if(i?.aborted)throw new Error("aborted");const g=a.signalCode,M=O??(g?128+(Pe.signals[g]??0):1);if(h)throw new Ee((L??te)/1e3,R!==void 0?{exitCode:M,afterSeconds:Math.round(R/100)/10}:void 0);return{exitCode:M}}finally{a.pid&&!m&&Be(a.pid),D&&clearTimeout(D),i&&i.removeEventListener("abort",k)}},"exec")}}s(dt,"createLocalShellOperations");function lt(t){return dt("bash",()=>ce(t?.shellPath))}s(lt,"createLocalBashOperations");const oe=Symbol.for("dal.shell.executionGuards"),ie=globalThis;ie[oe]instanceof Set||(ie[oe]=new Set);const se=ie[oe];function Kt(t){return se.add(t),()=>{se.delete(t)}}s(Kt,"registerShellExecutionGuard");async function ut(t){for(const e of se){let n;try{n=await e(t)}catch(o){return`Command refused: the safety check could not run (${o instanceof Error?o.message:String(o)}).`}if(n!==void 0)return n}}s(ut,"shellExecutionRefusal");const ct=["SESSION_ID","SESSION_FILE","PROVIDER","MODEL","REASONING_LEVEL"];function mt(t,e,n,o,c){const i={...me()};if(delete i.PI_SESSION_ID,delete i.PI_SESSION_FILE,delete i.PI_PROVIDER,delete i.PI_MODEL,delete i.PI_REASONING_LEVEL,o&&c){const w=c.model;i.PI_SESSION_ID=c.sessionManager.getSessionId();const r=c.sessionManager.getSessionFile();r&&(i.PI_SESSION_FILE=r),w&&(i.PI_PROVIDER=w.provider,i.PI_MODEL=w.id),c.thinkingLevel&&(i.PI_REASONING_LEVEL=c.thinkingLevel)}for(const w of ct){delete i[`DAL_${w}`];const r=i[`PI_${w}`];r!==void 0&&(i[`DAL_${w}`]=r)}const $={command:t,cwd:e,env:i};return n?n($):$}s(mt,"resolveSpawnContext");const pt=5,ft=100;class ht extends De{static{s(this,"BashResultRenderComponent")}state={cachedWidth:void 0,cachedLines:void 0,cachedSkipped:void 0}}function wt(t){const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const n=Math.floor(e),o=Math.floor(n/60),c=n%60;return o<60?`${o}m ${c}s`:`${Math.floor(o/60)}h ${o%60}m ${c}s`}s(wt,"formatDuration");function St(t,e,n=!1){const o=he(t?.command),c=he(t?.description)?.trim(),i=t?.timeout,$=i?E.fg("muted",W(v(" (\u8D85\u65F6 {seconds} \u79D2)"),{seconds:i})):"";if(c){const r=E.fg("toolTitle",E.bold(c))+$;return!n||!o?r:`${r}
3
+ ${E.fg("muted",` \u23BF ${e} ${o.trim()}`)}`}const w=o===null?ze(E):o?E.fg("dim",Je(o.replace(/\s+/g," ").trim(),42)):E.fg("dim","\u2026");return`${E.fg("toolTitle",E.bold(e))} ${w}${$}`}s(St,"formatShellCall");function xt(t,e,n,o,c,i,$,w){const r=t.state;t.clear();const L=bt(n,c,i,w);if(!n.expanded&&!$){const d=fe(e,o),p=Ke(d),h=[];p>0&&h.push(W(v("{count} \u884C"),{count:p})),L&&h.push(L);const m=qe(E,h);m&&t.addChild(new Y(m,0,0));return}let S=fe(e,o).trim();const x=e.details?.truncation,a=e.details?.fullOutputPath;if(!n.isPartial&&x?.truncated&&a&&S.endsWith("]")){const d=S.lastIndexOf(`
4
4
 
5
- [`);a!==-1&&S.slice(a).includes(c)&&(S=S.slice(0,a).trimEnd())}if(S){const a=S.split(`
6
- `).map(m=>x.fg("toolOutput",m)).join(`
7
- `);n.expanded?t.addChild(new W(`
8
- ${a}`,0,0)):t.addChild({render:r(m=>{if(s.cachedLines===void 0||s.cachedWidth!==m){const h=Ae(a,mt,m);s.cachedLines=h.visualLines,s.cachedSkipped=h.skippedCount,s.cachedWidth=m}if(s.cachedSkipped&&s.cachedSkipped>0){const h=x.fg("muted",G(P("... (\u524D\u9762\u8FD8\u6709 {count} \u884C\uFF0C"),{count:s.cachedSkipped}))+` ${Ie("app.tools.expand",P("\u5373\u53EF\u5C55\u5F00"))}${x.fg("muted",")")}`;return["",De(h,m,"..."),...s.cachedLines??[]]}return["",...s.cachedLines??[]]},"render"),invalidate:r(()=>{s.cachedWidth=void 0,s.cachedLines=void 0,s.cachedSkipped=void 0},"invalidate")})}if(b?.truncated||c){const a=[];c&&a.push(G(P("\u5B8C\u6574\u8F93\u51FA\uFF1A{path}"),{path:c})),b?.truncated&&(b.truncatedBy==="lines"?a.push(G(P("\u5DF2\u622A\u65AD\uFF1A\u663E\u793A {shown}/{total} \u884C"),{shown:b.outputLines,total:b.totalLines})):a.push(G(P("\u5DF2\u622A\u65AD\uFF1A\u663E\u793A\u4E86 {shown} \u884C\uFF08\u4E0A\u9650 {limit}\uFF09"),{shown:b.outputLines,limit:Ze(b.maxBytes??Qe)}))),t.addChild(new W(`
9
- ${x.fg("warning",`[${a.join(". ")}]`)}`,0,0))}$&&t.addChild(new W(`
10
- ${x.fg("muted",$)}`,0,0))}r(St,"rebuildBashResultRenderComponent");function bt(t,e,n,o){let u;if(!t.isPartial&&o!==void 0)u=o;else if(e!==void 0)u=(n??Date.now())-e;else return;if(!(!t.isPartial&&u<100))return`${t.isPartial?P("\u5DF2\u8FD0\u884C"):P("\u8017\u65F6")} ${ht(u)}`}r(bt,"bashTimingLabel");function xt(t,e,n){const o=n?.operations??e.defaultOperations?.()??dt({shellPath:n?.shellPath}),u=n?.commandPrefix,i=n?.exposeSessionEnvironment??!0,y=n?.spawnHook,w=n?.sandbox,s=n?.operations===void 0,$=w?.describeForModel(),S=n?.background;let b=!1;const c=r(a=>`Execute a ${e.shellName} command in the current working directory; returns stdout and stderr. Long output is cut to its start and end (error lines kept) and the full output saved to a file named in the result. ${a?`A command still running after \`timeout\` seconds (default ${ne}) keeps running in the background: you get its id and the output so far, then use the process tool to poll or kill it.`:`A command still running after \`timeout\` seconds (default ${te/1e3}) is killed.`}${$?` ${$}`:""}`,"describe");return{name:e.name,label:e.label,description:c(!1),prepareLoadout:S&&s?a=>(b=a.declared.some(m=>m.name==="process"),b?{descriptions:{[e.name]:c(!0)}}:void 0):void 0,promptSnippet:e.promptSnippet,promptGuidelines:i&&e.promptGuidelines?[...e.promptGuidelines]:void 0,executionMode:"sequential",executionModeFor:e.readOnlyCommand&&!u?a=>e.readOnlyCommand?.(a?.command)?"parallel":void 0:void 0,parameters:w?.active?st:Se,outputSchema:rt,constrainedSampling:{type:"json_schema",strict:"prefer"},async execute(a,m,h,p,f){const{command:_,timeout:A}=m;p&&p({content:[],details:void 0});const D=w??(s?Ue():void 0),H=await lt({toolName:e.name,command:_,cwd:f?.cwd||t,sessionFile:f?.sessionManager?.getSessionFile(),...D?.active?{tempDir:D.scratchDir()}:{}});if(H!==void 0)throw new le(H,He(void 0,Ge("dangerous-command",H)));const V=u?`${u}
11
- ${_}`:_,k=ct(V,f?.cwd||t,y,i,f);let L;if(D?.active){if(!e.sandboxShell)throw new Error(`Command refused: ${e.shellName} commands cannot run inside the OS sandbox yet, and the sandbox level is "${D.level}". Use the bash tool, or the user can opt out with \`dal --sandbox off\`.`);L=await D.prepare({command:k.command,cwd:k.cwd,shell:e.sandboxShell(n?.shellPath),shellKind:e.sandboxShellKind??"bash",env:k.env,toolCallId:a,toolName:e.name,escalation:m.sandbox_escalation,ctx:f,signal:h})}const C=new We({tempFilePrefix:e.tempFilePrefix,maxBytes:ee});let Y=!0,j,X=!1,re=0;const K=r(()=>{if(!p||!X)return;X=!1,re=Date.now();const d=C.snapshot({persistIfTruncated:!0});p({content:[{type:"text",text:d.content||""}],details:{truncation:d.truncation.truncated?d.truncation:void 0,fullOutputPath:d.fullOutputPath}})},"emitOutputUpdate"),q=r(()=>{j&&(clearTimeout(j),j=void 0)},"clearUpdateTimer"),xe=r(()=>{if(!p)return;X=!0;const d=pt-(Date.now()-re);if(d<=0){q(),K();return}j??=setTimeout(()=>{j=void 0,K()},d)},"scheduleOutputUpdate"),Ee=r(d=>{Y&&(C.append(d),xe())},"handleData"),_e=r(async()=>{Y=!1,C.finish(),q(),K();const d=C.snapshot({persistIfTruncated:!0});return await C.closeTempFile(),d},"finishOutput"),z=r(async(d="(no output)")=>{const O=await _e(),M=await C.readFullOutput(tt),T=Ye()?void 0:Ve(M.content),E=et(T?.text??M.content,ee);let I=O.fullOutputPath;(E.truncated||T)&&!I&&(I=await Me(e.tempFilePrefix,".log",M.content));let F=E.content||d,R;const U=O.truncation.totalLines;return E.truncated?(R={truncation:{content:E.content,truncated:!0,truncatedBy:"bytes",totalLines:U,totalBytes:O.truncation.totalBytes,outputLines:E.headLines+E.tailLines,outputBytes:Buffer.byteLength(E.content,"utf-8"),lastLinePartial:!1,firstLineExceedsLimit:!1,maxLines:U,maxBytes:ee},fullOutputPath:I},F+=`
5
+ [`);d!==-1&&S.slice(d).includes(a)&&(S=S.slice(0,d).trimEnd())}if(S){const d=S.split(`
6
+ `).map(p=>E.fg("toolOutput",p)).join(`
7
+ `);n.expanded?t.addChild(new Y(`
8
+ ${d}`,0,0)):t.addChild({render:s(p=>{if(r.cachedLines===void 0||r.cachedWidth!==p){const h=ke(d,pt,p);r.cachedLines=h.visualLines,r.cachedSkipped=h.skippedCount,r.cachedWidth=p}if(r.cachedSkipped&&r.cachedSkipped>0){const h=E.fg("muted",W(v("... (\u524D\u9762\u8FD8\u6709 {count} \u884C\uFF0C"),{count:r.cachedSkipped}))+` ${Ae("app.tools.expand",v("\u5373\u53EF\u5C55\u5F00"))}${E.fg("muted",")")}`;return["",ve(h,p,"..."),...r.cachedLines??[]]}return["",...r.cachedLines??[]]},"render"),invalidate:s(()=>{r.cachedWidth=void 0,r.cachedLines=void 0,r.cachedSkipped=void 0},"invalidate")})}if(x?.truncated||a){const d=[];a&&d.push(W(v("\u5B8C\u6574\u8F93\u51FA\uFF1A{path}"),{path:a})),x?.truncated&&(x.truncatedBy==="lines"?d.push(W(v("\u5DF2\u622A\u65AD\uFF1A\u663E\u793A {shown}/{total} \u884C"),{shown:x.outputLines,total:x.totalLines})):d.push(W(v("\u5DF2\u622A\u65AD\uFF1A\u663E\u793A\u4E86 {shown} \u884C\uFF08\u4E0A\u9650 {limit}\uFF09"),{shown:x.outputLines,limit:et(x.maxBytes??Ze)}))),t.addChild(new Y(`
9
+ ${E.fg("warning",`[${d.join(". ")}]`)}`,0,0))}L&&t.addChild(new Y(`
10
+ ${E.fg("muted",L)}`,0,0))}s(xt,"rebuildBashResultRenderComponent");function bt(t,e,n,o){let c;if(!t.isPartial&&o!==void 0)c=o;else if(e!==void 0)c=(n??Date.now())-e;else return;if(!(!t.isPartial&&c<100))return`${t.isPartial?v("\u5DF2\u8FD0\u884C"):v("\u8017\u65F6")} ${wt(c)}`}s(bt,"bashTimingLabel");function Et(t,e,n){const o=n?.operations??e.defaultOperations?.()??lt({shellPath:n?.shellPath}),c=n?.commandPrefix,i=n?.exposeSessionEnvironment??!0,$=n?.spawnHook,w=n?.sandbox,r=n?.operations===void 0,L=w?.describeForModel(),S=n?.background;let x=!1;const a=s(d=>`Execute a ${e.shellName} command in the current working directory; returns stdout and stderr. Long output is cut to its start and end (error lines kept) and the full output saved to a file named in the result. ${d?`A command still running after \`timeout\` seconds (default ${ne}) keeps running in the background: you get its id and the output so far, then use the process tool to poll or kill it.`:`A command still running after \`timeout\` seconds (default ${te/1e3}) is killed.`}${L?` ${L}`:""}`,"describe");return{name:e.name,label:e.label,description:a(!1),prepareLoadout:S&&r?d=>(x=d.declared.some(p=>p.name==="process"),x?{descriptions:{[e.name]:a(!0)}}:void 0):void 0,promptSnippet:e.promptSnippet,promptGuidelines:i&&e.promptGuidelines?[...e.promptGuidelines]:void 0,executionMode:"sequential",executionModeFor:e.readOnlyCommand&&!c?d=>e.readOnlyCommand?.(d?.command)?"parallel":void 0:void 0,parameters:w?.active?rt:xe,outputSchema:at,constrainedSampling:{type:"json_schema",strict:"prefer"},async execute(d,p,h,m,f){const{command:T,timeout:R}=p;m&&m({content:[],details:void 0});const D=w??(r?Ge():void 0),k=await ut({toolName:e.name,command:T,cwd:f?.cwd||t,sessionFile:f?.sessionManager?.getSessionFile(),...D?.active?{tempDir:D.scratchDir()}:{}});if(k!==void 0)throw new ue(k,je(void 0,He("dangerous-command",k)));const U=c?`${c}
11
+ ${T}`:T,C=mt(U,f?.cwd||t,$,i,f);let O;if(D?.active){if(!e.sandboxShell)throw new Error(`Command refused: ${e.shellName} commands cannot run inside the OS sandbox yet, and the sandbox level is "${D.level}". Use the bash tool, or the user can opt out with \`dal --sandbox off\`.`);O=await D.prepare({command:C.command,cwd:C.cwd,shell:e.sandboxShell(n?.shellPath),shellKind:e.sandboxShellKind??"bash",env:C.env,toolCallId:d,toolName:e.name,escalation:p.sandbox_escalation,ctx:f,signal:h})}const g=new Ve({tempFilePrefix:e.tempFilePrefix,maxBytes:ee});let M=!0,V,K=!1,re=0;const q=s(()=>{if(!m||!K)return;K=!1,re=Date.now();const l=g.snapshot({persistIfTruncated:!0});m({content:[{type:"text",text:l.content||""}],details:{truncation:l.truncation.truncated?l.truncation:void 0,fullOutputPath:l.fullOutputPath}})},"emitOutputUpdate"),z=s(()=>{V&&(clearTimeout(V),V=void 0)},"clearUpdateTimer"),_e=s(()=>{if(!m)return;K=!0;const l=ft-(Date.now()-re);if(l<=0){z(),q();return}V??=setTimeout(()=>{V=void 0,q()},l)},"scheduleOutputUpdate"),Oe=s(l=>{M&&(g.append(l),_e())},"handleData"),ge=s(async()=>{M=!1,g.finish(),z(),q();const l=g.snapshot({persistIfTruncated:!0});return await g.closeTempFile(),l},"finishOutput"),J=s(async(l="(no output)")=>{const y=await ge(),F=await g.readFullOutput(nt),P=Xe()?void 0:Ye(F.content),_=tt(P?.text??F.content,ee);let A=y.fullOutputPath;(_.truncated||P)&&!A&&(A=await Fe(e.tempFilePrefix,".log",F.content));let N=_.content||l,H;const j=y.truncation.totalLines;return _.truncated?(H={truncation:{content:_.content,truncated:!0,truncatedBy:"bytes",totalLines:j,totalBytes:y.truncation.totalBytes,outputLines:_.headLines+_.tailLines,outputBytes:Buffer.byteLength(_.content,"utf-8"),lastLinePartial:!1,firstLineExceedsLimit:!1,maxLines:j,maxBytes:ee},fullOutputPath:A},N+=`
12
12
 
13
- [Truncated: first ${E.headLines} and last ${E.tailLines} of ${E.totalLines} lines shown${T?`, after condensing ${U} lines (${T.summary})`:""}; read more with read (offset/limit) or grep. Full output: ${I}]`):T&&(R={fullOutputPath:I},F+=`
13
+ [Truncated: first ${_.headLines} and last ${_.tailLines} of ${_.totalLines} lines shown${P?`, after condensing ${j} lines (${P.summary})`:""}; read more with read (offset/limit) or grep. Full output: ${A}]`):P&&(H={fullOutputPath:A},N+=`
14
14
 
15
- [Condensed: ${T.summary}. Full output: ${I}]`),{text:F,details:R,snapshot:O}},"modelOutput"),B=r((d,O)=>`${d?`${d}
15
+ [Condensed: ${P.summary}. Full output: ${A}]`),{text:N,details:H,snapshot:y}},"modelOutput"),G=s((l,y)=>`${l?`${l}
16
16
 
17
- `:""}${O}`,"appendStatus"),ae=performance.now();let v;const J=S&&s&&b?d=>{Y=!1;try{return v=S.adopt({child:d,command:_,cwd:k.cwd,...L?{prepared:L}:{},...C.handOff()}),!0}catch{return Y=!0,!1}}:void 0;try{let d;try{const g=await o.exec(L?.command??k.command,k.cwd,{onData:Ee,signal:h,timeout:A??(J?ne:void 0),env:k.env,...J?{yieldTo:J}:{}});if(g.yielded&&v){const{text:N,details:Z}=await z(""),Oe=A??ne,ge=v.urls.length>0?` It printed ${v.urls.join(" ")}.`:"",ye=`[Still running after ${Oe}s, now in the background as ${v.id}.${ge} For new output and the exit code call process with action "poll" and id "${v.id}"; "kill" stops it.]`,de=await C.readFullOutput(we);return{content:[{type:"text",text:B(N,ye)}],details:{...Z,background:v},structuredContent:{output:de.content,truncated:de.truncated,exit_code:-1,background_id:v.id,wall_time_seconds:Math.round((performance.now()-ae)/100)/10}}}d=g.exitCode}catch(g){const{text:N}=await z("");if(await L?.finish(null,""),g instanceof Error&&g.message==="aborted")throw new Error(B(N,"Command aborted"));if(g instanceof Error&&g.message.startsWith("timeout:")){const Z=g.message.split(":")[1];throw new Error(B(N,`Command timed out after ${Z} seconds`))}throw g}const{text:O,details:M,snapshot:T}=await z(),E=await L?.finish(d,T.content||"");if(E&&L)throw new le(`${B(O,`Command exited with code ${d??"(none)"}`)}
17
+ `:""}${y}`,"appendStatus"),ae=performance.now();let I;const Q=S&&r&&x?l=>{M=!1;try{return I=S.adopt({child:l,command:T,cwd:C.cwd,...O?{prepared:O}:{},...g.handOff()}),!0}catch{return M=!0,!1}}:void 0;try{let l;try{const b=await o.exec(O?.command??C.command,C.cwd,{onData:Oe,signal:h,timeout:R??(Q?ne:void 0),env:C.env,...Q?{yieldTo:Q}:{}});if(b.yielded&&I){const{text:B,details:de}=await J(""),X=R??ne,ye=I.urls.length>0?` It printed ${I.urls.join(" ")}.`:"",$e=`[Still running after ${X}s, now in the background as ${I.id}.${ye} For new output and the exit code call process with action "poll" and id "${I.id}"; "kill" stops it.]`,le=await g.readFullOutput(Se);return{content:[{type:"text",text:G(B,$e)}],details:{...de,background:I},structuredContent:{output:le.content,truncated:le.truncated,exit_code:-1,background_id:I.id,wall_time_seconds:Math.round((performance.now()-ae)/100)/10}}}l=b.exitCode}catch(b){const{text:B}=await J("");if(await O?.finish(null,""),b instanceof Error&&b.message==="aborted")throw new Error(G(B,"Command aborted"));if(b instanceof Error&&b.message.startsWith("timeout:")){let X=`Command timed out after ${b.message.split(":")[1]} seconds`;throw b instanceof Ee&&b.shellExit&&(X+=`. The shell exited with code ${b.shellExit.exitCode} after ${b.shellExit.afterSeconds} seconds, but background processes it started kept writing output until the timeout.`),new Error(G(B,X))}throw b}const{text:y,details:F,snapshot:P}=await J(),_=await O?.finish(l,P.content||"");if(_&&O)throw new ue(`${G(y,`Command exited with code ${l??"(none)"}`)}
18
18
 
19
- ${Re(E)}`,{...M,sandbox:L.details});if(d===null)throw new Error(B(O,"Command terminated without an exit code"));const I=Math.round((performance.now()-ae)/100)/10,F=await C.readFullOutput(we),R={output:F.content,truncated:F.truncated,...F.truncated&&T.fullOutputPath?{full_output_path:T.fullOutputPath}:{},exit_code:d,wall_time_seconds:I},U=L?.details.escalation?L.details:void 0,Q=U?{...M,sandbox:U}:M;if(d!==0){const g=d===127?await Be(O):void 0,N=B(O,`Command exited with code ${d}`);return{content:[{type:"text",text:g?`${N}
20
- ${g}`:N}],details:Q,structuredContent:R,isError:!0}}return{content:[{type:"text",text:O}],details:Q,structuredContent:R}}finally{q()}},renderCall(a,m,h){const p=h.state;h.executionStarted&&p.startedAt===void 0&&(p.startedAt=Date.now(),p.endedAt=void 0);const f=h.lastComponent??new W("",0,0);return f.setText(wt(a,e.prompt,h.expanded===!0)),f},renderResult(a,m,h,p){const f=p.state;f.startedAt!==void 0&&m.isPartial&&!f.interval&&(f.interval=setInterval(()=>p.invalidate(),1e3)),(!m.isPartial||p.isError)&&(f.endedAt??=Date.now(),f.interval&&(clearInterval(f.interval),f.interval=void 0));const _=p.lastComponent??new ft;return St(_,a,m,p.showImages,f.startedAt,f.endedAt,p.isError,p.durationMs),_.invalidate(),_}}}r(xt,"createShellToolDefinition");const Et={name:"bash",label:"bash",shellName:"bash",prompt:"$",promptSnippet:be.snippet,promptGuidelines:be.guidelines,tempFilePrefix:"dal-bash",readOnlyCommand:je,sandboxShell:r(t=>ue(t).shell,"sandboxShell")};function _t(t,e){return xt(t,Et,e)}r(_t,"createBashToolDefinition");function Kt(t,e){const n=_t(t,e),o=Je(n);return Object.assign(o,{promptSnippet:n.promptSnippet,promptGuidelines:n.promptGuidelines}),o}r(Kt,"createBashTool");export{be as bashToolSystemPromptContribution,Kt as createBashTool,_t as createBashToolDefinition,dt as createLocalBashOperations,at as createLocalShellOperations,xt as createShellToolDefinition,Xt as registerShellExecutionGuard,it as sandboxEscalationSchema,lt as shellExecutionRefusal};
19
+ ${Ue(_)}`,{...F,sandbox:O.details});if(l===null)throw new Error(G(y,"Command terminated without an exit code"));const A=Math.round((performance.now()-ae)/100)/10,N=await g.readFullOutput(Se),H={output:N.content,truncated:N.truncated,...N.truncated&&P.fullOutputPath?{full_output_path:P.fullOutputPath}:{},exit_code:l,wall_time_seconds:A},j=O?.details.escalation?O.details:void 0,Z=j?{...F,sandbox:j}:F;if(l!==0){const b=l===127?await Re(y):void 0,B=G(y,`Command exited with code ${l}`);return{content:[{type:"text",text:b?`${B}
20
+ ${b}`:B}],details:Z,structuredContent:H,isError:!0}}return{content:[{type:"text",text:y}],details:Z,structuredContent:H}}finally{z()}},renderCall(d,p,h){const m=h.state;h.executionStarted&&m.startedAt===void 0&&(m.startedAt=Date.now(),m.endedAt=void 0);const f=h.lastComponent??new Y("",0,0);return f.setText(St(d,e.prompt,h.expanded===!0)),f},renderResult(d,p,h,m){const f=m.state;f.startedAt!==void 0&&p.isPartial&&!f.interval&&(f.interval=setInterval(()=>m.invalidate(),1e3)),(!p.isPartial||m.isError)&&(f.endedAt??=Date.now(),f.interval&&(clearInterval(f.interval),f.interval=void 0));const T=m.lastComponent??new ht;return xt(T,d,p,m.showImages,f.startedAt,f.endedAt,m.isError,m.durationMs),T.invalidate(),T}}}s(Et,"createShellToolDefinition");const _t={name:"bash",label:"bash",shellName:"bash",prompt:"$",promptSnippet:be.snippet,promptGuidelines:be.guidelines,tempFilePrefix:"dal-bash",readOnlyCommand:We,sandboxShell:s(t=>ce(t).shell,"sandboxShell")};function Ot(t,e){return Et(t,_t,e)}s(Ot,"createBashToolDefinition");function qt(t,e){const n=Ot(t,e),o=Qe(n);return Object.assign(o,{promptSnippet:n.promptSnippet,promptGuidelines:n.promptGuidelines}),o}s(qt,"createBashTool");export{be as bashToolSystemPromptContribution,qt as createBashTool,Ot as createBashToolDefinition,lt as createLocalBashOperations,dt as createLocalShellOperations,Et as createShellToolDefinition,Kt as registerShellExecutionGuard,st as sandboxEscalationSchema,ut as shellExecutionRefusal};
@@ -1,6 +1,5 @@
1
- export declare function detectLineEnding(content: string): "\r\n" | "\n";
2
1
  export declare function normalizeToLF(text: string): string;
3
- export declare function restoreLineEndings(text: string, ending: "\r\n" | "\n"): string;
2
+ export declare function applyReplacementsToOriginal(originalContent: string, replacements: TextReplacement[]): string;
4
3
  export declare function normalizeForFuzzyMatch(text: string): string;
5
4
  interface MatchedEdit {
6
5
  editIndex: number;
@@ -8,8 +7,7 @@ interface MatchedEdit {
8
7
  matchLength: number;
9
8
  newText: string;
10
9
  }
11
- type TextReplacement = Pick<MatchedEdit, "matchIndex" | "matchLength" | "newText">;
12
- export declare function applyReplacementsPreservingUnchangedLines(originalContent: string, baseContent: string, replacements: TextReplacement[]): string;
10
+ export type TextReplacement = Pick<MatchedEdit, "matchIndex" | "matchLength" | "newText">;
13
11
  export interface FuzzyMatchResult {
14
12
  found: boolean;
15
13
  index: number;
@@ -24,6 +22,7 @@ export interface Edit {
24
22
  export interface AppliedEditsResult {
25
23
  baseContent: string;
26
24
  newContent: string;
25
+ replacements: TextReplacement[];
27
26
  }
28
27
  export declare function fuzzyFindText(content: string, oldText: string): FuzzyMatchResult;
29
28
  export declare function applyEditsToNormalizedContent(normalizedContent: string, edits: Edit[], path: string): AppliedEditsResult;
@@ -32,6 +31,12 @@ export declare function generateDiffString(oldContent: string, newContent: strin
32
31
  diff: string;
33
32
  firstChangedLine: number | undefined;
34
33
  };
34
+ export interface EditDiff {
35
+ diff: string;
36
+ patch: string;
37
+ firstChangedLine: number | undefined;
38
+ }
39
+ export declare function generateEditDiff(path: string, baseContent: string, newContent: string, replacements: TextReplacement[], contextLines?: number): EditDiff;
35
40
  export interface EditDiffResult {
36
41
  diff: string;
37
42
  firstChangedLine: number | undefined;