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 c=Object.defineProperty;var r=(e,t)=>c(e,"name",{value:t,configurable:!0});const u=[/prompt (?:is )?too long/i,/prompt exceeds max length/i,/request_too_large/i,/input is too long for requested model/i,/exceeds the context window/i,/exceeds (?:the )?(?:model'?s )?maximum context length(?: of [\d,]+ tokens?|\s*\([\d,]+\))/i,/input token count.*exceeds the maximum/i,/maximum prompt length is \d+/i,/reduce the length of the messages/i,/maximum context length is \d+ tokens/i,/exceeds (?:the )?maximum allowed input length of [\d,]+ tokens?/i,/input \(\d+ tokens\) is longer than the model'?s context length \(\d+ tokens\)/i,/exceeds the limit of \d+/i,/exceeds the available context size/i,/greater than the context length/i,/context window exceeds limit/i,/exceeded model token limit/i,/too large for model with \d+ maximum context length/i,/prompt has [\d,]+ tokens?, but the configured context size is [\d,]+ tokens?/i,/model_context_window_exceeded/i,/prompt too long; exceeded (?:max )?context length/i,/range of input length should be/i,/context[_ ]length[_ ]exceeded/i,/too many tokens/i,/token limit exceeded/i,/^(?:[\w -]+ API error \(413\):|413(?:\s|:|$))/i],l=/^4(?:00|13)\s*(?:status code)?\s*\(no body\)/i,d=[/^(Throttling error|Service unavailable):/i,/rate limit/i,/too many requests/i];function f(e,t){return!!(e.stopReason==="error"&&e.errorMessage&&!d.some(n=>n.test(e.errorMessage))&&(u.some(n=>n.test(e.errorMessage))||e.provider==="cerebras"&&l.test(e.errorMessage))||t&&e.stopReason==="stop"&&e.usage.input+e.usage.cacheRead>t||t&&e.stopReason==="length"&&e.usage.output===0&&e.usage.input+e.usage.cacheRead>=t*.99)}r(f,"isContextOverflow");const a=4096,h=.9;function m(e,t,o){if(e.stopReason!=="length"||t<=0||e.usage.output>=t)return!1;if(o===void 0||o<=0||!e.content.some(s=>s.type==="text"&&s.text.trim()!==""||s.type==="toolCall"))return!0;const i=e.usage;return i.input+i.cacheRead+i.cacheWrite+i.output+a>=o*h}r(m,"isRecoverableLength");function g(){return[...u]}r(g,"getOverflowPatterns");export{g as getOverflowPatterns,f as isContextOverflow,m as isRecoverableLength};
1
+ var c=Object.defineProperty;var r=(e,t)=>c(e,"name",{value:t,configurable:!0});const u=[/prompt (?:is )?too long/i,/prompt exceeds max length/i,/request_too_large/i,/input is too long for requested model/i,/exceeds the context window/i,/exceeds (?:the )?(?:model'?s )?maximum context length(?: of [\d,]+ tokens?|\s*\([\d,]+\))/i,/context window exceeded/i,/input token count.*exceeds the maximum/i,/maximum prompt length is \d+/i,/reduce the length of the messages/i,/maximum context length is \d+ tokens/i,/exceeds (?:the )?maximum allowed input length of [\d,]+ tokens?/i,/input \(\d+ tokens\) is longer than the model'?s context length \(\d+ tokens\)/i,/exceeds the limit of \d+/i,/exceeds the available context size/i,/greater than the context length/i,/context window exceeds limit/i,/exceeded model token limit/i,/too large for model with \d+ maximum context length/i,/prompt has [\d,]+ tokens?, but the configured context size is [\d,]+ tokens?/i,/model_context_window_exceeded/i,/prompt too long; exceeded (?:max )?context length/i,/range of input length should be/i,/context[_ ]length[_ ]exceeded/i,/too many tokens/i,/token limit exceeded/i,/^(?:[\w -]+ API error \(413\):|413(?:\s|:|$))/i],d=/^4(?:00|13)\s*(?:status code)?\s*\(no body\)/i,l=[/^(Throttling error|Service unavailable):/i,/rate limit/i,/too many requests/i];function f(e,t){return!!(e.stopReason==="error"&&e.errorMessage&&!l.some(n=>n.test(e.errorMessage))&&(u.some(n=>n.test(e.errorMessage))||e.provider==="cerebras"&&d.test(e.errorMessage))||t&&e.stopReason==="stop"&&e.usage.input+e.usage.cacheRead>t||t&&e.stopReason==="length"&&e.usage.output===0&&e.usage.input+e.usage.cacheRead>=t*.99)}r(f,"isContextOverflow");const a=4096,h=.9;function m(e,t,o){if(e.stopReason!=="length"||t<=0||e.usage.output>=t)return!1;if(o===void 0||o<=0||!e.content.some(s=>s.type==="text"&&s.text.trim()!==""||s.type==="toolCall"))return!0;const i=e.usage;return i.input+i.cacheRead+i.cacheWrite+i.output+a>=o*h}r(m,"isRecoverableLength");function g(){return[...u]}r(g,"getOverflowPatterns");export{g as getOverflowPatterns,f as isContextOverflow,m as isRecoverableLength};
@@ -1 +1 @@
1
- var R=Object.defineProperty;var n=(e,r)=>R(e,"name",{value:r,configurable:!0});function c(e){return new RegExp(e.join("|"),"i")}n(c,"buildProviderErrorPattern");const d=c(["GoUsageLimitError","FreeUsageLimitError","Monthly usage limit reached","available balance","insufficient_quota","out of budget","quota exceeded","billing","^\\s*(?:error:?\\s*)?402\\b","\\b(?:status|http|code)\\W{0,3}402\\b","payment.?required","insufficient.?(?:balance|credits?|funds)","credit balance is too low","exceeded your current quota","quota.?exhausted","\u4F59\u989D\u4E0D\u8DB3","subscription_sharing_usage_limit_exceeded","subscription_sharing_workplace_individual_usage_limit_exceeded"]),m=c(["overloaded","server_busy","servers are currently busy","currently experiencing high demand","model is at capacity","rate.?limit","too many requests","(?<![a-z0-9])(?:429|500|502|503|504|520|524)(?![a-z0-9])","service.?(?:is.?)?(?:temporarily.?)?unavailable","server.?error","internal.?error","empty response","provider.?returned.?(?:an.?)?error","exceeded request buffer limit while retrying upstream","unable to forward upstream","upstream.?request.?failed","upstream_stream_read_error","stream was interrupted","http/?2 stream failed","network.?error","connection.?error","connection.?refused","connection.?lost","connection.?reset","ECONNRESET","ECONNREFUSED","ETIMEDOUT","EPIPE","ENETUNREACH","EHOSTUNREACH","premature close","other side closed","fetch failed","request to \\S+ failed, reason:","getaddrinfo","ENOTFOUND","EAI_AGAIN","upstream.?connect","reset before headers","socket hang up","socket connection was closed","timed? out","timeout","terminated","websocket.?closed","websocket.?error","ended without","stream ended before message_stop","stream ended before a terminal response event","http2 request did not get a response","stream disconnected before completion","pending stream has been canceled","retry delay","you can retry your request","try your request again","please retry your request","ResourceExhausted","subscription_sharing_usage_unavailable","subscription_sharing_user_unavailable"]),_=6e4;function b(e,r){const a=e.baseDelayMs*2**Math.max(0,r-1),t=Number.isSafeInteger(a)?a:Number.MAX_SAFE_INTEGER;return Math.min(t,e.maxAgentDelayMs??_)}n(b,"retryDelayMs");class E extends Error{static{n(this,"RetrySleepAbortError")}constructor(){super("Aborted")}}function y(e,r){return new Promise((a,t)=>{if(r?.aborted){t(new E);return}const u=setTimeout(a,e);r?.addEventListener("abort",()=>{clearTimeout(u),t(new E)},{once:!0})})}n(y,"sleep");async function w(e,r,a,t){const u=r?.enabled?r.maxRetries:0;let i=0,o;for(;;){const s=await e();if(s.stopReason==="aborted")return o&&await t?.onRetryFinished?.(!1,o.attempt),s;if(s.stopReason!=="error")return o&&await t?.onRetryFinished?.(!0,o.attempt),s;if(i>=u||!h(s))return o&&await t?.onRetryFinished?.(!1,o.attempt,s.errorMessage),s;i++,o={attempt:i,errorMessage:s.errorMessage||"Unknown error"};const l=b(r,i);await t?.onRetryScheduled?.(i,u,l,o.errorMessage);try{await y(l,a)}catch(f){if(await t?.onRetryFinished?.(!1,i,o.errorMessage),f instanceof E){const{errorMessage:A,...p}=s;return{...p,stopReason:"aborted"}}throw f}await t?.onRetryAttemptStart?.()}}n(w,"retryAssistantCall");function h(e){if(e.stopReason!=="error"||!e.errorMessage)return!1;const r=e.errorMessage;return d.test(r)?!1:m.test(r)}n(h,"isRetryableAssistantError");const g=c(["network.?error","connection.?error","connection.?refused","connection.?lost","connection.?reset","ECONNRESET","ECONNREFUSED","ETIMEDOUT","EPIPE","ENETUNREACH","EHOSTUNREACH","other side closed","fetch failed","getaddrinfo","ENOTFOUND","EAI_AGAIN","upstream.?connect","reset before headers","socket hang up","socket connection was closed","timed? out","timeout","terminated","premature close","websocket.?closed","websocket.?error","ended without","stream ended before"]);function M(e){return e.stopReason!=="error"||!e.errorMessage||d.test(e.errorMessage)?!1:g.test(e.errorMessage)}n(M,"isNetworkAssistantError");function T(e){return e.stopReason!=="error"||!e.errorMessage?!1:d.test(e.errorMessage)}n(T,"isAccountLimitAssistantError");export{_ as DEFAULT_MAX_AGENT_RETRY_DELAY_MS,T as isAccountLimitAssistantError,M as isNetworkAssistantError,h as isRetryableAssistantError,w as retryAssistantCall,b as retryDelayMs};
1
+ var R=Object.defineProperty;var n=(e,r)=>R(e,"name",{value:r,configurable:!0});function c(e){return new RegExp(e.join("|"),"i")}n(c,"buildProviderErrorPattern");const d=c(["GoUsageLimitError","FreeUsageLimitError","Monthly usage limit reached","available balance","insufficient_quota","out of budget","quota exceeded","billing","^\\s*(?:error:?\\s*)?402\\b","\\b(?:status|http|code)\\W{0,3}402\\b","payment.?required","insufficient.?(?:balance|credits?|funds)","credit balance is too low","exceeded your current quota","quota.?exhausted","\u4F59\u989D\u4E0D\u8DB3","subscription_sharing_usage_limit_exceeded","subscription_sharing_workplace_individual_usage_limit_exceeded",'"code"\\s*:\\s*"?1308(?![0-9])']),m=c(["overloaded","server_busy","servers are currently busy","currently experiencing high demand","model is at capacity","rate.?limit","too many requests","(?<![a-z0-9])(?:429|500|502|503|504|520|524)(?![a-z0-9])","service.?(?:is.?)?(?:temporarily.?)?unavailable","server.?error","internal.?error","empty response","provider.?returned.?(?:an.?)?error","exceeded request buffer limit while retrying upstream","unable to forward upstream","upstream.?request.?failed","upstream_stream_read_error","stream was interrupted","http/?2 stream failed","network.?error","connection.?error","connection.?refused","connection.?lost","connection.?reset","ECONNRESET","ECONNREFUSED","ETIMEDOUT","EPIPE","ENETUNREACH","EHOSTUNREACH","premature close","other side closed","fetch failed","request to \\S+ failed, reason:","getaddrinfo","ENOTFOUND","EAI_AGAIN","upstream.?connect","reset before headers","socket hang up","socket connection was closed","timed? out","timeout","terminated","websocket.?closed","websocket.?error","ended without","stream ended before message_stop","stream ended before a terminal response event","http2 request did not get a response","stream disconnected before completion","cut short after the reply had begun","pending stream has been canceled","retry delay","you can retry your request","try your request again","please retry your request","ResourceExhausted","subscription_sharing_usage_unavailable","subscription_sharing_user_unavailable"]),_=6e4;function b(e,r){const a=e.baseDelayMs*2**Math.max(0,r-1),t=Number.isSafeInteger(a)?a:Number.MAX_SAFE_INTEGER;return Math.min(t,e.maxAgentDelayMs??_)}n(b,"retryDelayMs");class E extends Error{static{n(this,"RetrySleepAbortError")}constructor(){super("Aborted")}}function y(e,r){return new Promise((a,t)=>{if(r?.aborted){t(new E);return}const u=setTimeout(a,e);r?.addEventListener("abort",()=>{clearTimeout(u),t(new E)},{once:!0})})}n(y,"sleep");async function w(e,r,a,t){const u=r?.enabled?r.maxRetries:0;let i=0,o;for(;;){const s=await e();if(s.stopReason==="aborted")return o&&await t?.onRetryFinished?.(!1,o.attempt),s;if(s.stopReason!=="error")return o&&await t?.onRetryFinished?.(!0,o.attempt),s;if(i>=u||!h(s))return o&&await t?.onRetryFinished?.(!1,o.attempt,s.errorMessage),s;i++,o={attempt:i,errorMessage:s.errorMessage||"Unknown error"};const l=b(r,i);await t?.onRetryScheduled?.(i,u,l,o.errorMessage);try{await y(l,a)}catch(f){if(await t?.onRetryFinished?.(!1,i,o.errorMessage),f instanceof E){const{errorMessage:A,...p}=s;return{...p,stopReason:"aborted"}}throw f}await t?.onRetryAttemptStart?.()}}n(w,"retryAssistantCall");function h(e){if(e.stopReason!=="error"||!e.errorMessage)return!1;const r=e.errorMessage;return d.test(r)?!1:m.test(r)}n(h,"isRetryableAssistantError");const g=c(["network.?error","connection.?error","connection.?refused","connection.?lost","connection.?reset","ECONNRESET","ECONNREFUSED","ETIMEDOUT","EPIPE","ENETUNREACH","EHOSTUNREACH","other side closed","fetch failed","getaddrinfo","ENOTFOUND","EAI_AGAIN","upstream.?connect","reset before headers","socket hang up","socket connection was closed","timed? out","timeout","terminated","premature close","websocket.?closed","websocket.?error","ended without","stream ended before"]);function M(e){return e.stopReason!=="error"||!e.errorMessage||d.test(e.errorMessage)?!1:g.test(e.errorMessage)}n(M,"isNetworkAssistantError");function T(e){return e.stopReason!=="error"||!e.errorMessage?!1:d.test(e.errorMessage)}n(T,"isAccountLimitAssistantError");export{_ as DEFAULT_MAX_AGENT_RETRY_DELAY_MS,T as isAccountLimitAssistantError,M as isNetworkAssistantError,h as isRetryableAssistantError,w as retryAssistantCall,b as retryDelayMs};
@@ -0,0 +1,26 @@
1
+ import type { JsonValue, ToolCall } from "../types.ts";
2
+ export type JsonPath = readonly (string | number)[];
3
+ export type JsonChange = {
4
+ readonly kind: "set";
5
+ readonly path: JsonPath;
6
+ readonly value: JsonValue;
7
+ } | {
8
+ readonly kind: "append";
9
+ readonly path: JsonPath;
10
+ readonly text: string;
11
+ };
12
+ export declare class StreamingJsonParser {
13
+ #private;
14
+ append(text: string): readonly JsonChange[];
15
+ snapshot(): JsonValue | undefined;
16
+ }
17
+ export declare class ToolCallArgumentsStream {
18
+ #private;
19
+ get text(): string;
20
+ append(delta: string): ToolCall["arguments"];
21
+ replace(text: string): {
22
+ readonly delta: string | undefined;
23
+ readonly arguments: ToolCall["arguments"];
24
+ };
25
+ finish(): Pick<ToolCall, "arguments" | "argumentsError">;
26
+ }
@@ -0,0 +1,4 @@
1
+ var o=Object.defineProperty;var u=(n,e)=>o(n,"name",{value:e,configurable:!0});import{parseToolCallArguments as p}from"./json-parse.js";const g=32,m={kind:"root"},y=256,A=8,k=64,d=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/,S=/^(-?(?:0|[1-9]\d*)(?:\.\d+)?)[eE][+-]?$/,h=[["true",!0],["false",!1],["null",null]],E=34,_=92;class f{static{u(this,"StreamingJsonParser")}#t=void 0;#u=!1;#e=[];#i=void 0;#n="";#a=void 0;#d=0;#o=0;#s=!1;#f=void 0;#c=[];append(e){this.#o+=y+A*e.length,this.#c=[],this.#i!==void 0&&(this.#i.change=void 0);let t=0;for(;t<e.length&&!this.#u;){const i=this.#i;i!==void 0?t=this.#y(i,e,t):this.#n!==""?t=this.#A(e,t):this.#k(e[t++])}return this.#c}snapshot(){if(!this.#s)return this.#f;const e=this.#T(),t=this.#d+(e===void 0?0:1);return t>this.#o?this.#f:(this.#o-=t,this.#s=!1,this.#f=this.#P(e),this.#f)}#y(e,t,i){let s=i;for(let r=i;r<t.length;r++){const a=t.charCodeAt(r);if(e.escape!==""){if(this.#E(e,t[r])){s=r+1;continue}s=r}if(a===E)return r>s&&this.#r(e,t.slice(s,r)),this.#_(e),r+1;a===_&&(r>s&&this.#r(e,t.slice(s,r)),e.escape="\\",s=r+1)}return t.length>s&&this.#r(e,t.slice(s)),t.length}#A(e,t){let i=t;for(;i<e.length&&!T(e[i]);)i++;return i>t&&(this.#n+=e.slice(t,i),this.#a!==void 0&&(this.#s=!0)),i<e.length&&this.#b(),i}#k(e){switch(e){case" ":case" ":case`
2
+ `:case"\r":return;case'"':this.#S();return;case"{":case"[":this.#v(e==="{"?{}:[]);return;case"}":case"]":this.#C();return;case":":{const t=this.#e.at(-1);t!==void 0&&!Array.isArray(t.container)&&t.phase==="colon"&&(t.phase="value");return}case",":{const t=this.#e.at(-1);t!==void 0&&(t.phase=Array.isArray(t.container)?"value":"key");return}default:this.#n=e,this.#a=this.#p(),this.#a!==void 0&&(this.#s=!0)}}#p(){const e=this.#e.at(-1);if(e===void 0)return this.#t===void 0?m:void 0;if(Array.isArray(e.container))return{kind:"element",index:e.container.length};if((e.phase==="value"||e.phase==="colon")&&e.key!==void 0)return{kind:"member",key:e.key}}#S(){const e=this.#e.at(-1);if(e!==void 0&&!Array.isArray(e.container)&&(e.phase==="key"||e.phase==="comma")){this.#i={target:"key",slot:void 0,text:"",escape:"",path:void 0,change:void 0};return}const t=this.#p(),i=this.#g(t);this.#i={target:"value",slot:t,text:"",escape:"",path:i,change:void 0},this.#l(t,""),i!==void 0&&(this.#i.change=this.#h({kind:"set",path:i,value:""}))}#g(e){if(e===void 0)return;if(e.kind==="root")return[];const t=this.#e.at(-1);if(t.reportsInside)return[...t.path,e.kind==="member"?e.key:e.index]}#h(e){return this.#c.push(e),e}#E(e,t){if(e.escape==="\\"){const s=b[t];return s!==void 0?(e.escape="",this.#r(e,s),!0):t==="u"?(e.escape="\\u",!0):(e.escape="",this.#r(e,"\\"),!1)}if(v(t)){if(e.escape+=t,e.escape.length<6)return!0;const s=String.fromCharCode(Number.parseInt(e.escape.slice(2),16));return e.escape="",this.#r(e,s),!0}const i=e.escape;return e.escape="",this.#r(e,i),!1}#r(e,t){if(e.text+=t,e.target!=="value"||(this.#l(e.slot,e.text),e.path===void 0))return;const i=e.change;if(i!==void 0&&this.#c.at(-1)===i){i.kind==="set"?i.value=i.value+t:i.text+=t;return}e.change=this.#h({kind:"append",path:e.path,text:t})}#_(e){this.#i=void 0;const t=this.#e.at(-1);if(e.target==="key"){if(t===void 0)return;t.key=e.text,t.phase="colon";return}this.#m(t)}#b(){const e=this.#n,t=this.#a;this.#n="",this.#a=void 0;const i=C(e);if(i!==void 0){this.#l(t,i);const s=this.#g(t);s!==void 0&&this.#h({kind:"set",path:s,value:i})}this.#m(this.#e.at(-1))}#T(){const e=this.#a,t=this.#n;if(e===void 0||t===""||t.length>k)return;const i=P(t);return i===void 0?void 0:{slot:e,value:i}}#v(e){const t=this.#p(),i=this.#g(t);this.#l(t,e),this.#e.push({container:e,slot:t,path:i,reportsInside:i!==void 0&&i.length<g,size:0,key:void 0,phase:Array.isArray(e)?"value":"key"}),this.#d+=1,this.#s=!0,i!==void 0&&this.#h({kind:"set",path:i,value:Array.isArray(e)?[]:{}})}#C(){const e=this.#e.pop();e!==void 0&&(this.#d-=e.size+1,this.#s=!0,e.path!==void 0&&!e.reportsInside&&this.#h({kind:"set",path:e.path,value:e.container}),this.#m(this.#e.at(-1)))}#m(e){if(e===void 0){this.#t!==void 0&&(this.#u=!0);return}e.phase="comma"}#l(e,t){if(e===void 0)return;if(this.#s=!0,e.kind==="root"){this.#t=t;return}const i=this.#e.at(-1);if(e.kind==="element"){const r=i.container;e.index===r.length&&(i.size++,this.#d++),r[e.index]=t;return}const s=i.container;Object.hasOwn(s,e.key)||(i.size++,this.#d++),l(s,e.key,t)}#P(e){if(this.#e.length===0)return e?.slot.kind==="root"?e.value:this.#t;let t,i;for(let s=this.#e.length-1;s>=0;s--){const r=this.#e[s],a=Array.isArray(r.container)?r.container.slice():{...r.container};s===this.#e.length-1&&e!==void 0&&c(a,e.slot,e.value),t!==void 0&&i!==void 0&&c(a,i,t),t=a,i=r.slot}return i?.kind==="root"?t:this.#t}}class N{static{u(this,"ToolCallArgumentsStream")}#t="";#u=new f;#e=void 0;#i={};get text(){return this.#t}append(e){return this.#t+=e,this.#u.append(e),this.#n()}replace(e){if(e.startsWith(this.#t)){const t=e.slice(this.#t.length);return{delta:t,arguments:t===""?this.#n():this.append(t)}}return this.#t="",this.#u=new f,{delta:void 0,arguments:this.append(e)}}finish(){return p(this.#t)}#n(){const e=this.#u.snapshot();return e===this.#e?this.#i:(this.#e=e,this.#i=typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{},this.#i)}}const b={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
3
+ `,r:"\r",t:" "};function T(n){return n===" "||n===" "||n===`
4
+ `||n==="\r"||n===","||n===":"||n==="{"||n==="}"||n==="["||n==="]"||n==='"'}u(T,"isDelimiter");function v(n){return n>="0"&&n<="9"||n>="a"&&n<="f"||n>="A"&&n<="F"}u(v,"isHexDigit");function C(n){for(const[e,t]of h)if(n===e)return t;return d.test(n)?Number(n):void 0}u(C,"scalarValue");function P(n){for(const[t,i]of h)if(t.startsWith(n))return i;if(d.test(n))return Number(n);const e=S.exec(n);return e===null?void 0:Number(e[1])}u(P,"pendingScalarValue");function c(n,e,t){e.kind==="element"?n[e.index]=t:e.kind==="member"&&l(n,e.key,t)}u(c,"setSlot");function l(n,e,t){e==="__proto__"?Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0}):n[e]=t}u(l,"setMember");export{f as StreamingJsonParser,N as ToolCallArgumentsStream};
@@ -1,5 +1,5 @@
1
- import { type TUnsafe } from "typebox";
1
+ import type { Schema } from "@earendil-works/pi-schema";
2
2
  export declare function StringEnum<T extends readonly string[]>(values: T, options?: {
3
3
  description?: string;
4
4
  default?: T[number];
5
- }): TUnsafe<T[number]>;
5
+ }): Schema<T[number]>;
@@ -0,0 +1 @@
1
+ var n=Object.defineProperty;var r=(t,e)=>n(t,"name",{value:e,configurable:!0});function d(t,e){return{type:"string",enum:t,...e?.description&&{description:e.description},...e?.default&&{default:e.default}}}r(d,"StringEnum");export{d as StringEnum};
@@ -3,4 +3,5 @@ type Content = TextContent | ImageContent | ThinkingContent | ToolCall;
3
3
  export declare function contentText(content: string | readonly Content[], separator?: string): string;
4
4
  export declare function getSystemMessageText(message: SystemMessage): string;
5
5
  export declare function renderSystemMessageUpdate(message: SystemMessage): string;
6
+ export declare function ownedSlice(text: string, start: number, end?: number): string;
6
7
  export {};
@@ -1,8 +1,8 @@
1
- var p=Object.defineProperty;var o=(t,n)=>p(t,"name",{value:n,configurable:!0});function i(t,n=`
1
+ var c=Object.defineProperty;var o=(t,n)=>c(t,"name",{value:n,configurable:!0});function i(t,n=`
2
2
  `){return typeof t=="string"?t:t.filter(e=>e.type==="text").map(e=>e.text).join(n)}o(i,"contentText");function u(t){const n=[i(t.content)];for(const e of Object.values(t.sections??{}))e!==null&&n.push(e);return n.filter(e=>e.length>0).join(`
3
3
 
4
4
  `)}o(u,"getSystemMessageText");function f(t){const n=[],e=i(t.content);e.length>0&&n.push(e);for(const[s,r]of Object.entries(t.sections??{}))n.push(r===null?`Removed system prompt section "${s}".`:`Updated system prompt section "${s}":
5
5
 
6
6
  ${r}`);return n.join(`
7
7
 
8
- `)}o(f,"renderSystemMessageUpdate");export{i as contentText,u as getSystemMessageText,f as renderSystemMessageUpdate};
8
+ `)}o(f,"renderSystemMessageUpdate");function l(t,n,e=t.length){return`${t.slice(n,e)} `.slice(0,-1)}o(l,"ownedSlice");export{i as contentText,u as getSystemMessageText,l as ownedSlice,f as renderSystemMessageUpdate};
@@ -1,6 +1,6 @@
1
- var b=Object.defineProperty;var f=(r,t)=>b(r,"name",{value:t,configurable:!0});import{Compile as g}from"typebox/compile";import{Value as l}from"typebox/value";const y=new WeakMap,A=Symbol.for("TypeBox.Kind");function j(r){return typeof r.type=="string"?[r.type]:Array.isArray(r.type)?r.type.filter(t=>typeof t=="string"):[]}f(j,"getSchemaTypes");function h(r,t){switch(t){case"number":return typeof r=="number";case"integer":return typeof r=="number"&&Number.isInteger(r);case"boolean":return typeof r=="boolean";case"string":return typeof r=="string";case"null":return r===null;case"array":return Array.isArray(r);case"object":return typeof r=="object"&&r!==null&&!Array.isArray(r);default:return!1}}f(h,"matchesJsonType");function p(r){try{return d(r)}catch{return}}f(p,"getSubSchemaValidator");function O(r,t){switch(t){case"number":{if(r===null)return 0;if(typeof r=="string"&&r.trim()!==""){const e=Number(r);if(Number.isFinite(e))return e}return typeof r=="boolean"?r?1:0:r}case"integer":{if(r===null)return 0;if(typeof r=="string"&&r.trim()!==""){const e=Number(r);if(Number.isInteger(e))return e}return typeof r=="boolean"?r?1:0:r}case"boolean":{if(r===null)return!1;if(typeof r=="string"){if(r==="true")return!0;if(r==="false")return!1}if(typeof r=="number"){if(r===1)return!0;if(r===0)return!1}return r}case"string":return r===null?"":typeof r=="number"||typeof r=="boolean"?String(r):r;case"null":return r===""||r===0||r===!1?null:r;default:return r}}f(O,"coercePrimitiveByType");function S(r,t){const e=t.properties,n=new Set(e?Object.keys(e):[]);if(e)for(const[i,o]of Object.entries(e))i in r&&(r[i]=c(r[i],o));if(t.additionalProperties&&typeof t.additionalProperties=="object")for(const[i,o]of Object.entries(r))n.has(i)||(r[i]=c(o,t.additionalProperties))}f(S,"applySchemaObjectCoercion");function k(r,t){if(Array.isArray(t.items)){for(let e=0;e<r.length;e++){const n=t.items[e];n&&(r[e]=c(r[e],n))}return}if(t.items&&typeof t.items=="object")for(let e=0;e<r.length;e++)r[e]=c(r[e],t.items)}f(k,"applySchemaArrayCoercion");function u(r,t){for(const e of t)if(p(e)?.Check(r))return r;for(const e of t){const n=structuredClone(r),i=c(n,e);if(p(e)?.Check(i))return i}return r}f(u,"coerceWithUnionSchema");function c(r,t){let e=r;if(Array.isArray(t.allOf))for(const o of t.allOf)e=c(e,o);Array.isArray(t.anyOf)&&(e=u(e,t.anyOf)),Array.isArray(t.oneOf)&&(e=u(e,t.oneOf));const n=j(t),i=n.length>1&&n.some(o=>h(e,o));if(n.length>0&&!i)for(const o of n){const s=O(e,o);if(s!==e){e=s;break}}return n.includes("object")&&typeof e=="object"&&e!==null&&!Array.isArray(e)&&S(e,t),n.includes("array")&&Array.isArray(e)&&k(e,t),e}f(c,"coerceWithJsonSchema");function a(r,t){if(Array.isArray(r)){if(Array.isArray(t.items))for(let i=0;i<r.length;i++){const o=t.items[i];o&&a(r[i],o)}else if(t.items)for(const i of r)a(i,t.items);return}if(typeof r!="object"||r===null||!t.properties)return;const e=r,n=new Set(t.required??[]);for(const[i,o]of Object.entries(t.properties))i in e&&(e[i]===null&&!n.has(i)&&typeof o.$ref!="string"&&p(o)?.Check(null)===!1?delete e[i]:a(e[i],o))}f(a,"normalizeOptionalNulls");function d(r){const t=r,e=y.get(t);if(e)return e;const n=g(r);return y.set(t,n),n}f(d,"getValidator");function w(r){if(r.keyword==="required"){const n=r.params.requiredProperties?.[0];if(n){const i=r.instancePath.replace(/^\//,"").replace(/\//g,".");return i?`${i}.${n}`:n}}return r.instancePath.replace(/^\//,"").replace(/\//g,".")||"root"}f(w,"formatValidationPath");function q(r,t){const e=r.find(n=>n.name===t.name);if(!e)throw new Error(`Tool "${t.name}" not found`);return P(e,t)}f(q,"validateToolCall");function P(r,t){if(t.argumentsError)throw new Error(`Invalid arguments for tool "${t.name}": ${t.argumentsError}`);const e=structuredClone(t.arguments);a(e,r.parameters),l.Convert(r.parameters,e);const n=d(r.parameters);if(!Object.getOwnPropertySymbols(r.parameters).includes(A)){const s=c(e,r.parameters);if(s!==e)if(typeof e=="object"&&e!==null&&typeof s=="object"&&s!==null){for(const m of Object.keys(e))delete e[m];Object.assign(e,s)}else return n.Check(s)?s:e}if(n.Check(e))return e;const i=n.Errors(e).map(s=>` - ${w(s)}: ${s.message}`).join(`
2
- `)||"Unknown validation error",o=`Validation failed for tool "${t.name}":
3
- ${i}
1
+ var u=Object.defineProperty;var t=(e,r)=>u(e,"name",{value:r,configurable:!0});import{compile as c}from"@earendil-works/pi-schema";import{formats as m}from"@earendil-works/pi-schema/formats";const i=new WeakMap;function f(e){const r=i.get(e);if(r)return r;const n=c(e,{formats:m,coerce:!0,unresolvedRefs:"reject"});return i.set(e,n),n}t(f,"getValidator");function d(e){return e===""?"root":e.slice(1).split("/").map(r=>r.replace(/~1/g,"/").replace(/~0/g,"~")).join(".")}t(d,"formatValidationPath");function l(e,r){const n=e.find(o=>o.name===r.name);if(!n)throw new Error(`Tool "${r.name}" not found`);return g(n,r)}t(l,"validateToolCall");function g(e,r){if(r.argumentsError)throw new Error(`Invalid arguments for tool "${r.name}": ${r.argumentsError}`);const n=f(e.parameters).parse(structuredClone(r.arguments));if(n.ok)return n.value;const o=n.errors.map(a=>` - ${d(a.path)}: ${a.message}`).join(`
2
+ `),s=`Validation failed for tool "${r.name}":
3
+ ${o}
4
4
 
5
5
  Received arguments:
6
- ${JSON.stringify(t.arguments,null,2)}`;throw new Error(o)}f(P,"validateToolArguments");export{P as validateToolArguments,q as validateToolCall};
6
+ ${JSON.stringify(r.arguments,null,2)}`;throw new Error(s)}t(g,"validateToolArguments");export{g as validateToolArguments,l as validateToolCall};
@@ -1 +1 @@
1
- export declare const PI_AI_VERSION = "1.0.50";
1
+ export declare const PI_AI_VERSION = "1.0.52";
@@ -1 +1 @@
1
- const I="1.0.50";export{I as PI_AI_VERSION};
1
+ const I="1.0.52";export{I as PI_AI_VERSION};
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earendil-works/pi-ai",
3
- "version": "1.0.50",
3
+ "version": "1.0.52",
4
4
  "description": "Unified LLM API with automatic model discovery and provider configuration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -42,6 +42,14 @@
42
42
  "./bedrock-provider": {
43
43
  "types": "./dist/bedrock-provider.d.ts",
44
44
  "import": "./dist/bedrock-provider.js"
45
+ },
46
+ "./lazy-bedrock-provider": {
47
+ "types": "./dist/lazy-bedrock-provider.d.ts",
48
+ "import": "./dist/lazy-bedrock-provider.js"
49
+ },
50
+ "./lazy-oauth": {
51
+ "types": "./dist/lazy-oauth.d.ts",
52
+ "import": "./dist/lazy-oauth.js"
45
53
  }
46
54
  },
47
55
  "bin": {
@@ -54,15 +62,14 @@
54
62
  "dependencies": {
55
63
  "@anthropic-ai/sdk": "0.129.0",
56
64
  "@aws-sdk/client-bedrock-runtime": "3.1127.0",
57
- "@earendil-works/pi-telemetry": "1.0.50",
65
+ "@earendil-works/pi-schema": "1.0.52",
66
+ "@earendil-works/pi-telemetry": "1.0.52",
58
67
  "@google/genai": "2.21.0",
59
- "@opentelemetry/api": "1.9.0",
60
68
  "@smithy/node-http-handler": "4.12.1",
61
69
  "http-proxy-agent": "9.1.0",
62
70
  "https-proxy-agent": "9.1.0",
63
71
  "openai": "7.19.0",
64
- "partial-json": "0.1.7",
65
- "typebox": "1.3.27"
72
+ "partial-json": "0.1.7"
66
73
  },
67
74
  "keywords": [
68
75
  "ai",
@@ -275,7 +275,7 @@ import {
275
275
  type CodemodeTool,
276
276
  renderDeclarations,
277
277
  } from "@earendil-works/pi-codemode";
278
- import { Type } from "typebox";
278
+ import { obj, str } from "@earendil-works/pi-schema";
279
279
 
280
280
  const sandboxTools: CodemodeTool[] = agentTools.map((tool) => ({
281
281
  name: tool.name,
@@ -293,7 +293,7 @@ const codemodeTool: AgentTool = {
293
293
  name: "codemode",
294
294
  label: "Codemode",
295
295
  description: `Run JavaScript that calls tools as \`await tools.<name>(args)\`. Output with text() or return.\n\n${renderDeclarations({ tools: sandboxTools })}`,
296
- parameters: Type.Object({ code: Type.String() }),
296
+ parameters: obj({ code: str() }),
297
297
  execute: async (_toolCallId, { code }, signal) => {
298
298
  const sandbox = new CodemodeSandbox({ tools: sandboxTools });
299
299
  try {
@@ -17,3 +17,4 @@ export declare function renderToolOutputType(schema: CodemodeJsonSchema | undefi
17
17
  export declare function schemaToType(schema: CodemodeJsonSchema, options?: {
18
18
  maxChars?: number;
19
19
  }): string;
20
+ export declare function resolveSchemaRef(ref: string, root: unknown): CodemodeJsonSchema | undefined;
@@ -1,4 +1,4 @@
1
- var j=Object.defineProperty;var s=(n,e)=>j(n,"name",{value:e,configurable:!0});import{toCodemodeIdentifier as S}from"./identifier.js";const v=/^[A-Za-z_$][A-Za-z0-9_$]*$/,m=" ",T=16e3,M=32,N=["minimum","exclusiveMinimum","maximum","exclusiveMaximum","multipleOf","minLength","maxLength","pattern","format","minItems","maxItems"],w=new Set(["minimum","exclusiveMinimum","minLength","minItems"]),_=new Set(["maximum","exclusiveMaximum","maxLength","maxItems"]),h=80,k=/[\r\n\u2028\u2029]/g;function U(n){const e=[],t=n.tools??[];if(t.length>0){const r=t.map(o=>`${A(o.description,m)}${m}${x(o)}`);e.push(`declare const tools: {
1
+ var j=Object.defineProperty;var s=(n,e)=>j(n,"name",{value:e,configurable:!0});import{toCodemodeIdentifier as S}from"./identifier.js";const v=/^[A-Za-z_$][A-Za-z0-9_$]*$/,m=" ",T=16e3,M=32,h=["minimum","exclusiveMinimum","maximum","exclusiveMaximum","multipleOf","minLength","maxLength","pattern","format","minItems","maxItems"],w=new Set(["minimum","exclusiveMinimum","minLength","minItems"]),N=new Set(["maximum","exclusiveMaximum","maxLength","maxItems"]),_=80,x=/[\r\n\u2028\u2029]/g;function U(n){const e=[],t=n.tools??[];if(t.length>0){const r=t.map(o=>`${A(o.description,m)}${m}${k(o)}`);e.push(`declare const tools: {
2
2
  ${r.join(`
3
3
  `)}
4
4
  };`)}const u=new Map;for(const r of n.globals??[]){const o=r.name.indexOf(".");if(o===-1){e.push(O(`declare function ${r.name}`,r,""));continue}const p=r.name.slice(0,o),f=u.get(p)??[];f.length===0&&u.set(p,f),f.push(O(r.name.slice(o+1),r,m))}for(const[r,o]of u)e.push(`declare const ${r}: {
@@ -6,7 +6,7 @@ ${o.join(`
6
6
  `)}
7
7
  };`);return e.join(`
8
8
 
9
- `)}s(U,"renderDeclarations");function x(n,e={}){const t=n.inputSchema===void 0?"unknown":y(n.inputSchema,{maxChars:e.inputMaxChars??T});return`${S(n.name)}(args: ${t}): Promise<${E(n.outputSchema)}>;`}s(x,"renderToolSignature");function B(n,e={}){const t=`declare const tools: { ${x(n,e)} };`;return`${n.description?.trim()??""}
9
+ `)}s(U,"renderDeclarations");function k(n,e={}){const t=n.inputSchema===void 0?"unknown":y(n.inputSchema,{maxChars:e.inputMaxChars??T});return`${S(n.name)}(args: ${t}): Promise<${E(n.outputSchema)}>;`}s(k,"renderToolSignature");function B(n,e={}){const t=`declare const tools: { ${k(n,e)} };`;return`${n.description?.trim()??""}
10
10
 
11
11
  codemode tool declaration:
12
12
  \`\`\`ts
@@ -16,7 +16,7 @@ ${t}
16
16
  ${u.map(r=>`${e} *${r?` ${r}`:""}`).join(`
17
17
  `)}
18
18
  ${e} */
19
- `}s(A,"docComment");function C(n){return v.test(n)?n:JSON.stringify(n)}s(C,"propertyKey");function g(n){const e=[...new Set(n)];return e.includes("unknown")?"unknown":e.length===0?"never":e.join(" | ")}s(g,"union");function y(n,e={}){const t=s(o=>c(n,{root:n,resolving:new Set,expansions:0,tags:o}),"render"),u=t(!0);if(e.maxChars===void 0||u.length<=e.maxChars)return u;const r=t(!1);return r.length<=e.maxChars?r:"unknown"}s(y,"schemaToType");function R(n,e){if(n!=="#"&&!n.startsWith("#/"))return;let t=e;for(const u of n.slice(2).split("/").filter(Boolean)){const r=decodeURIComponent(u).replaceAll("~1","/").replaceAll("~0","~");if(typeof t!="object"||t===null||Array.isArray(t)||!(r in t))return;t=t[r]}return typeof t=="boolean"||typeof t=="object"&&t!==null&&!Array.isArray(t)?t:void 0}s(R,"resolveRef");function c(n,e){if(n===!0)return"unknown";if(n===!1)return"never";if(typeof n!="object"||n===null||Array.isArray(n))return"unknown";if(typeof n.$ref=="string"){const r=n.$ref;if(e.resolving.has(r)||e.expansions>=M)return"unknown";const o=R(r,e.root);if(o===void 0)return"unknown";e.expansions++,e.resolving.add(r);try{return c(o,e)}finally{e.resolving.delete(r)}}if("const"in n)return JSON.stringify(n.const)??"unknown";if(Array.isArray(n.enum))return g(n.enum.map(r=>JSON.stringify(r)??"unknown"));const t=Array.isArray(n.anyOf)?n.anyOf:Array.isArray(n.oneOf)?n.oneOf:void 0;if(t)return g(t.map(r=>c(r,e)));if(Array.isArray(n.allOf)){const r=n.allOf.map(o=>c(o,e)).filter(o=>o!=="unknown");return r.length===0?"unknown":r.map(o=>o.includes(" | ")?`(${o})`:o).join(" & ")}const u=n.type;if(Array.isArray(u))return g(u.map(r=>c({...n,type:r},e)));switch(u){case"string":return"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"null":return"null";case"array":return b(n,e);case"object":return I(n,e);case void 0:return"properties"in n||"additionalProperties"in n||"required"in n?I(n,e):"items"in n||"prefixItems"in n?b(n,e):"unknown";default:return"unknown"}}s(c,"toType");function b(n,e){if(n.items!==void 0&&!Array.isArray(n.items))return`Array<${c(n.items,e)}>`;const t=Array.isArray(n.prefixItems)?n.prefixItems:Array.isArray(n.items)?n.items:[];return t.length>0?`[${t.map(u=>c(u,e)).join(", ")}]`:"unknown[]"}s(b,"arrayType");function P(n){const e=n?.description;return typeof e=="string"?e.trim():""}s(P,"descriptionOf");function q(n){if(typeof n!="object"||n===null||Array.isArray(n))return"";const e=n,t=Array.isArray(e.anyOf)?e.anyOf:e.oneOf,u=Array.isArray(t)?t.filter(i=>i?.type!=="null"):[],r=u.length===1?u[0]:void 0,p=(typeof r=="object"&&r!==null&&!Array.isArray(r)?[e,r]:[e]).map(i=>({...i,...i.exclusiveMinimum===!0?{minimum:void 0,exclusiveMinimum:i.minimum}:{},...i.exclusiveMaximum===!0?{maximum:void 0,exclusiveMaximum:i.maximum}:{}})),f=[],d=s(i=>i==="integer"||Array.isArray(i)&&i.includes("integer"),"isInteger");p.some(i=>d(i.type))&&f.push("@integer");for(const i of N){const l=p.map(a=>a[i]);if(w.has(i)||_.has(i)){const a=l.filter($=>typeof $=="number");if(a.length===0)continue;f.push(`@${i} ${w.has(i)?Math.max(...a):Math.min(...a)}`);continue}for(const a of new Set(l))(typeof a=="number"||typeof a=="string")&&f.push(`@${i} ${a}`)}return p.some(i=>i.uniqueItems===!0)&&f.push("@uniqueItems"),e.default!==void 0&&e.default!==null&&f.push(`@default ${JSON.stringify(e.default)}`),e.deprecated===!0&&f.push("@deprecated"),f.filter(i=>i.length<=h).map(i=>i.replace(k,l=>`\\u${l.charCodeAt(0).toString(16).padStart(4,"0")}`)).join(" ")}s(q,"constraintTags");function I(n,e){const t=typeof n.properties=="object"&&n.properties!==null&&!Array.isArray(n.properties)?n.properties:{},u=new Set(Array.isArray(n.required)?n.required:[]),r=Object.keys(t).sort(),o=r.map(i=>{const l=u.has(i)?"":"?";return`${C(i)}${l}: ${c(t[i],e)};`}),p=n.additionalProperties;if(p!==void 0&&p!==!1){const i=p===!0?"unknown":c(p,e);o.push(`[key: string]: ${i};`)}else p===void 0&&r.length===0&&o.push("[key: string]: unknown;");if(o.length===0)return"{}";const f=r.map(i=>{const l=P(t[i]).split(k).map($=>$.trim()).filter(Boolean),a=e.tags?q(t[i]):"";return a?[...l,a]:l});if(!f.some(i=>i.length>0))return`{ ${o.join(" ")} }`;const d=["{"];f.forEach((i,l)=>{for(const a of i)d.push(`${m}// ${a}`);d.push(`${m}${o[l].replaceAll(`
19
+ `}s(A,"docComment");function C(n){return v.test(n)?n:JSON.stringify(n)}s(C,"propertyKey");function g(n){const e=[...new Set(n)];return e.includes("unknown")?"unknown":e.length===0?"never":e.join(" | ")}s(g,"union");function y(n,e={}){const t=s(o=>c(n,{root:n,resolving:new Set,expansions:0,tags:o}),"render"),u=t(!0);if(e.maxChars===void 0||u.length<=e.maxChars)return u;const r=t(!1);return r.length<=e.maxChars?r:"unknown"}s(y,"schemaToType");function R(n,e){if(n!=="#"&&!n.startsWith("#/"))return;let t=e;for(const u of n.slice(2).split("/").filter(Boolean)){let r;try{r=decodeURIComponent(u)}catch{return}const o=r.replaceAll("~1","/").replaceAll("~0","~");if(typeof t!="object"||t===null||Array.isArray(t)||!(o in t))return;t=t[o]}return typeof t=="boolean"||typeof t=="object"&&t!==null&&!Array.isArray(t)?t:void 0}s(R,"resolveSchemaRef");function c(n,e){if(n===!0)return"unknown";if(n===!1)return"never";if(typeof n!="object"||n===null||Array.isArray(n))return"unknown";if(typeof n.$ref=="string"){const r=n.$ref;if(e.resolving.has(r)||e.expansions>=M)return"unknown";const o=R(r,e.root);if(o===void 0)return"unknown";e.expansions++,e.resolving.add(r);try{return c(o,e)}finally{e.resolving.delete(r)}}if("const"in n)return JSON.stringify(n.const)??"unknown";if(Array.isArray(n.enum))return g(n.enum.map(r=>JSON.stringify(r)??"unknown"));const t=Array.isArray(n.anyOf)?n.anyOf:Array.isArray(n.oneOf)?n.oneOf:void 0;if(t)return g(t.map(r=>c(r,e)));if(Array.isArray(n.allOf)){const r=n.allOf.map(o=>c(o,e)).filter(o=>o!=="unknown");return r.length===0?"unknown":r.map(o=>o.includes(" | ")?`(${o})`:o).join(" & ")}const u=n.type;if(Array.isArray(u))return g(u.map(r=>c({...n,type:r},e)));switch(u){case"string":return"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"null":return"null";case"array":return b(n,e);case"object":return I(n,e);case void 0:return"properties"in n||"additionalProperties"in n||"required"in n?I(n,e):"items"in n||"prefixItems"in n?b(n,e):"unknown";default:return"unknown"}}s(c,"toType");function b(n,e){if(n.items!==void 0&&!Array.isArray(n.items))return`Array<${c(n.items,e)}>`;const t=Array.isArray(n.prefixItems)?n.prefixItems:Array.isArray(n.items)?n.items:[];return t.length>0?`[${t.map(u=>c(u,e)).join(", ")}]`:"unknown[]"}s(b,"arrayType");function P(n){const e=n?.description;return typeof e=="string"?e.trim():""}s(P,"descriptionOf");function q(n){if(typeof n!="object"||n===null||Array.isArray(n))return"";const e=n,t=Array.isArray(e.anyOf)?e.anyOf:e.oneOf,u=Array.isArray(t)?t.filter(i=>i?.type!=="null"):[],r=u.length===1?u[0]:void 0,p=(typeof r=="object"&&r!==null&&!Array.isArray(r)?[e,r]:[e]).map(i=>({...i,...i.exclusiveMinimum===!0?{minimum:void 0,exclusiveMinimum:i.minimum}:{},...i.exclusiveMaximum===!0?{maximum:void 0,exclusiveMaximum:i.maximum}:{}})),f=[],d=s(i=>i==="integer"||Array.isArray(i)&&i.includes("integer"),"isInteger");p.some(i=>d(i.type))&&f.push("@integer");for(const i of h){const l=p.map(a=>a[i]);if(w.has(i)||N.has(i)){const a=l.filter($=>typeof $=="number");if(a.length===0)continue;f.push(`@${i} ${w.has(i)?Math.max(...a):Math.min(...a)}`);continue}for(const a of new Set(l))(typeof a=="number"||typeof a=="string")&&f.push(`@${i} ${a}`)}return p.some(i=>i.uniqueItems===!0)&&f.push("@uniqueItems"),e.default!==void 0&&e.default!==null&&f.push(`@default ${JSON.stringify(e.default)}`),e.deprecated===!0&&f.push("@deprecated"),f.filter(i=>i.length<=_).map(i=>i.replace(x,l=>`\\u${l.charCodeAt(0).toString(16).padStart(4,"0")}`)).join(" ")}s(q,"constraintTags");function I(n,e){const t=typeof n.properties=="object"&&n.properties!==null&&!Array.isArray(n.properties)?n.properties:{},u=new Set(Array.isArray(n.required)?n.required:[]),r=Object.keys(t).sort(),o=r.map(i=>{const l=u.has(i)?"":"?";return`${C(i)}${l}: ${c(t[i],e)};`}),p=n.additionalProperties;if(p!==void 0&&p!==!1){const i=p===!0?"unknown":c(p,e);o.push(`[key: string]: ${i};`)}else p===void 0&&r.length===0&&o.push("[key: string]: unknown;");if(o.length===0)return"{}";const f=r.map(i=>{const l=P(t[i]).split(x).map($=>$.trim()).filter(Boolean),a=e.tags?q(t[i]):"";return a?[...l,a]:l});if(!f.some(i=>i.length>0))return`{ ${o.join(" ")} }`;const d=["{"];f.forEach((i,l)=>{for(const a of i)d.push(`${m}// ${a}`);d.push(`${m}${o[l].replaceAll(`
20
20
  `,`
21
21
  ${m}`)}`)});for(const i of o.slice(r.length))d.push(`${m}${i}`);return d.push("}"),d.join(`
22
- `)}s(I,"objectType");export{T as DEFAULT_INPUT_SCHEMA_MAX_CHARS,U as renderDeclarations,E as renderToolOutputType,B as renderToolSample,x as renderToolSignature,y as schemaToType,S as toCodemodeIdentifier};
22
+ `)}s(I,"objectType");export{T as DEFAULT_INPUT_SCHEMA_MAX_CHARS,U as renderDeclarations,E as renderToolOutputType,B as renderToolSample,k as renderToolSignature,R as resolveSchemaRef,y as schemaToType,S as toCodemodeIdentifier};
@@ -1,4 +1,4 @@
1
- export { DEFAULT_INPUT_SCHEMA_MAX_CHARS, type RenderDeclarationsOptions, renderDeclarations, renderToolOutputType, renderToolSample, renderToolSignature, schemaToType, } from "./declarations.ts";
1
+ export { DEFAULT_INPUT_SCHEMA_MAX_CHARS, type RenderDeclarationsOptions, renderDeclarations, renderToolOutputType, renderToolSample, renderToolSignature, resolveSchemaRef, schemaToType, } from "./declarations.ts";
2
2
  export { toCodemodeIdentifier } from "./identifier.ts";
3
3
  export { CodemodeSandboxBase } from "./runtime/execution.ts";
4
4
  export { CodemodeSandbox } from "./runtime/host.ts";
@@ -1 +1 @@
1
- import{DEFAULT_INPUT_SCHEMA_MAX_CHARS as r,renderDeclarations as d,renderToolOutputType as m,renderToolSample as T,renderToolSignature as _,schemaToType as S}from"./declarations.js";import{toCodemodeIdentifier as A}from"./identifier.js";import{CodemodeSandboxBase as E}from"./runtime/execution.js";import{CodemodeSandbox as R}from"./runtime/host.js";import{DEFAULT_INTERRUPT_BUDGET as n,InlineCodemodeSandbox as x}from"./runtime/inline.js";import{MAX_OUTPUT_CHARS as M,MAX_OUTPUT_ITEMS as U,MAX_STORE_TOTAL_CHARS as f,MAX_STORE_VALUE_CHARS as D}from"./runtime/prelude-source.js";import{RemoteCodemodeSandbox as I,serveCodemodeRemote as i}from"./runtime/remote.js";import{CODEMODE_OPTIONS_PREFIX as u,CODEMODE_SOURCE_GRAMMAR as P,CodemodeSourceError as X,parseCodemodeSource as c}from"./source.js";import{loadQuickJSWasm as b}from"./wasm.js";export{u as CODEMODE_OPTIONS_PREFIX,P as CODEMODE_SOURCE_GRAMMAR,R as CodemodeSandbox,E as CodemodeSandboxBase,X as CodemodeSourceError,r as DEFAULT_INPUT_SCHEMA_MAX_CHARS,n as DEFAULT_INTERRUPT_BUDGET,x as InlineCodemodeSandbox,M as MAX_OUTPUT_CHARS,U as MAX_OUTPUT_ITEMS,f as MAX_STORE_TOTAL_CHARS,D as MAX_STORE_VALUE_CHARS,I as RemoteCodemodeSandbox,b as loadQuickJSWasm,c as parseCodemodeSource,d as renderDeclarations,m as renderToolOutputType,T as renderToolSample,_ as renderToolSignature,S as schemaToType,i as serveCodemodeRemote,A as toCodemodeIdentifier};
1
+ import{DEFAULT_INPUT_SCHEMA_MAX_CHARS as r,renderDeclarations as d,renderToolOutputType as m,renderToolSample as T,renderToolSignature as S,resolveSchemaRef as _,schemaToType as t}from"./declarations.js";import{toCodemodeIdentifier as C}from"./identifier.js";import{CodemodeSandboxBase as R}from"./runtime/execution.js";import{CodemodeSandbox as p}from"./runtime/host.js";import{DEFAULT_INTERRUPT_BUDGET as x,InlineCodemodeSandbox as O}from"./runtime/inline.js";import{MAX_OUTPUT_CHARS as M,MAX_OUTPUT_ITEMS as U,MAX_STORE_TOTAL_CHARS as l,MAX_STORE_VALUE_CHARS as D}from"./runtime/prelude-source.js";import{RemoteCodemodeSandbox as I,serveCodemodeRemote as c}from"./runtime/remote.js";import{CODEMODE_OPTIONS_PREFIX as u,CODEMODE_SOURCE_GRAMMAR as P,CodemodeSourceError as X,parseCodemodeSource as H}from"./source.js";import{loadQuickJSWasm as L}from"./wasm.js";export{u as CODEMODE_OPTIONS_PREFIX,P as CODEMODE_SOURCE_GRAMMAR,p as CodemodeSandbox,R as CodemodeSandboxBase,X as CodemodeSourceError,r as DEFAULT_INPUT_SCHEMA_MAX_CHARS,x as DEFAULT_INTERRUPT_BUDGET,O as InlineCodemodeSandbox,M as MAX_OUTPUT_CHARS,U as MAX_OUTPUT_ITEMS,l as MAX_STORE_TOTAL_CHARS,D as MAX_STORE_VALUE_CHARS,I as RemoteCodemodeSandbox,L as loadQuickJSWasm,H as parseCodemodeSource,d as renderDeclarations,m as renderToolOutputType,T as renderToolSample,S as renderToolSignature,_ as resolveSchemaRef,t as schemaToType,c as serveCodemodeRemote,C as toCodemodeIdentifier};
@@ -126,6 +126,8 @@ const r=262144,t=1048576,o=16777216,n=1e5,e='image expects a non-empty image URL
126
126
  function format(value) {
127
127
  if (typeof value === "string") return value;
128
128
  if (value instanceof ErrorCtor) return errorText(value);
129
+ // JSON.stringify turns NaN and Infinity into "null".
130
+ if (typeof value === "number") return String(value);
129
131
  try {
130
132
  const json = stringify(value);
131
133
  return json === undefined ? String(value) : json;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earendil-works/pi-codemode",
3
- "version": "1.0.50",
3
+ "version": "1.0.52",
4
4
  "description": "Sandboxed JavaScript execution where the only capability is calling injected tools",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earendil-works/pi-coding-agent",
3
- "version": "1.0.50",
3
+ "version": "1.0.52",
4
4
  "private": true,
5
5
  "description": "Self-reference to the package's own dist/index.js for the bundled extensions.",
6
6
  "license": "MIT",
@@ -1,5 +1,37 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.5.2] - 2026-11-10
4
+
5
+ ## [1.5.1] - 2026-11-09
6
+
7
+ ### Added
8
+
9
+ - Added `PipeTransport`, MCP's stdio transport over a program started by the caller through an `McpPipe` (`write`, `closeStdin`, `close`, `exited`), for example `@earendil-works/pi-env`'s `openProcess()` on another machine. `StdioTransport` and `PipeTransport` share the newline-delimited framing and the stderr tail.
10
+ - Added MCP OAuth sign-in in two halves (`@earendil-works/pi-mcp/oauth`), moved from pi's coding agent: `startMcpSignIn()` refreshes the stored tokens or returns the authorization URL, and `completeMcpSignIn()` exchanges the code later, possibly in another request with the same state store. The code comes from a loopback callback server (`listenForLoopbackSignIn()`, `waitForLoopbackSignIn()`), the application's own callback route, or a pasted redirect URL (`responseFromRedirectUrl()`). Client ID Metadata Documents (`clientMetadataDocuments`) and the client name are the caller's. Aborting a sign-in's `signal` also stops `startMcpSignIn()` while it waits for the refresh lock; a store's `withRefreshLock()` throws `McpRefreshLockBusyError` when another process holds the lock too long, which makes `startMcpSignIn()` skip the refresh, while any other lock failure fails the sign-in. Also added `createMcpAuthProvider()`, which refreshes tokens once across requests and, through `McpOAuthServerStore.withRefreshLock()`, across processes; its `redirectUrl` option names a redirect URI the application signs in with, so tokens from a Client ID Metadata Document that lists only an https callback route can be refreshed. Also added the `refreshOnly` option of `authorizeMcp()`, which refreshes without registering a client or replacing a pending authorization's `state` and PKCE verifier.
11
+ - Added helpers that let applications name and configure MCP tools like pi's coding agent, moved from it: `createMcpToolName()` (`mcp__<server>__<tool>`, sanitized, with a hash suffix for long or colliding names) and `mcpNamespace()`; `normalizeMcpInputSchema()`, which makes an input schema an object schema; `limitMcpContent()` and `MCP_OUTPUT_MAX_BYTES`, which cut model-facing text over 20KB in the middle and optionally save the full text through a caller's `McpOutputSaver`; and `validateMcpServerConfig()`, which validates one entry of the `mcpServers` configuration shape (stdio, Streamable HTTP, `oauth`, `enabled`, `description`, `timeout`), returns the entry tagged with its transport, and keeps the application's own fields for it to check afterwards. `isMcpServerOverride()` recognizes entries that only override a server defined elsewhere.
12
+
13
+ ### Fixed
14
+
15
+ - The third-party licenses are in `THIRD_PARTY_NOTICES/`, renamed from `LICENSES/`, which Vite's license notices read as the package's license file, failing browser builds that bundle the package.
16
+ - Fixed Streamable HTTP `application/json` responses bypassing `maxMessageBytes`; oversized JSON responses are now cancelled and rejected like oversized SSE events ([#11335](https://github.com/earendil-works/pi/issues/11335))
17
+ - Fixed Streamable HTTP errors reading the whole HTTP error body; only the first 8 KiB kept in the error is read, and the rest is cancelled
18
+ - Fixed `OAuthCallbackServer.close()` waiting for minutes when the browser kept an unused connection open to the callback port, for example a preconnect. It now closes the remaining connections ([#11311](https://github.com/earendil-works/pi/issues/11311))
19
+ - Fixed large MCP stdio messages being repeatedly copied and scanned as chunks arrived, causing slow tool responses ([#11761](https://github.com/earendil-works/pi/issues/11761))
20
+ - Fixed MCP Streamable HTTP SSE replies with CR-only line endings failing with "stream ended without a response" ([#11764](https://github.com/earendil-works/pi/issues/11764))
21
+ - Fixed oversized MCP SSE responses keeping their HTTP connections open after the message-size limit rejected them ([#11729](https://github.com/earendil-works/pi/issues/11729))
22
+ - Fixed MCP stdio server subprocesses surviving disconnect or pi exit on POSIX when the server's main process had already exited ([#11721](https://github.com/earendil-works/pi/issues/11721))
23
+
24
+ ## [1.5.0] - 2026-11-02
25
+
26
+ ### Changed
27
+
28
+ - README: the `AgentTool` wrapping example passes the MCP input schema as plain JSON Schema instead of through TypeBox's `Type.Unsafe`.
29
+
30
+ ### Fixed
31
+
32
+ - OAuth metadata parsing and `startAuthorization()` now accept only `http:` and `https:` URLs. Before, a server could supply a `file:` or custom protocol authorization endpoint (for example `search-ms:`), which the platform URL handler would launch on sign-in.
33
+ - Fixed the excerpt of an HTTP error body in Streamable HTTP errors keeping the whole response body alive ([#9265](https://github.com/earendil-works/pi/issues/9265))
34
+
3
35
  ## [1.4.0] - 2026-10-21
4
36
 
5
37
  ## [1.3.0] - 2026-10-15
@@ -2,7 +2,7 @@
2
2
 
3
3
  A small, standalone Model Context Protocol client. It does not depend on the official MCP SDK or other pi packages.
4
4
 
5
- The package provides a transport-neutral client core, stdio and Streamable HTTP transports, and an in-memory testing transport.
5
+ The package provides a transport-neutral client core, stdio and Streamable HTTP transports, a stdio transport over a pipe to a program started elsewhere, and an in-memory testing transport.
6
6
 
7
7
  ## Usage
8
8
 
@@ -27,6 +27,24 @@ await client.close();
27
27
 
28
28
  For a remote server, use `new StreamableHttpTransport({ url, headers })`. Fetch can be injected for proxying or custom networking.
29
29
 
30
+ An MCP transport owns framing and I/O. It delivers individual JSON-RPC messages to `McpClient`; the client owns request correlation, initialization, timeouts, cancellation, server requests, and protocol-level helpers.
31
+
32
+ ### Stdio servers started elsewhere
33
+
34
+ `PipeTransport` speaks MCP's stdio framing over a program that something else starts, for example on another machine. `open` starts the program, connects its stdout and stderr to the given handlers, and returns an `McpPipe` (`write`, `closeStdin`, `close` to kill, and an `exited` promise). `@earendil-works/pi-env`'s `openProcess()` returns one, without an adapter:
35
+
36
+ ```typescript
37
+ import { openProcess } from "@earendil-works/pi-env";
38
+ import { PipeTransport } from "@earendil-works/pi-mcp";
39
+
40
+ const transport = new PipeTransport({
41
+ open: (handlers) => openProcess(connection, { cwd, argv, ...handlers }),
42
+ });
43
+ await client.connect(transport);
44
+ ```
45
+
46
+ Closing the transport closes the program's stdin and kills it if it has not exited after `closeTimeoutMs` (default 2000). The transport closes when the program ends.
47
+
30
48
  ### Tools for an LLM
31
49
 
32
50
  `toLlmContent(result)` converts a `CallToolResult` to text and image content for a model, in the shape of `@earendil-works/pi-ai`'s `TextContent` and `ImageContent`. Text and images pass through, embedded text and image resources are unwrapped, and audio, resource links, and binary resources become short text placeholders. A result without content blocks but with `structuredContent` becomes its JSON.
@@ -36,7 +54,6 @@ Wrapping an MCP tool as a `pi-agent-core` `AgentTool`:
36
54
  ```typescript
37
55
  import type { AgentTool } from "@earendil-works/pi-agent-core";
38
56
  import { toLlmContent } from "@earendil-works/pi-mcp";
39
- import { Type } from "typebox";
40
57
 
41
58
  const tools: AgentTool[] = (await client.listTools()).map((tool) => ({
42
59
  // Providers allow at most 64 characters of [A-Za-z0-9_-].
@@ -44,7 +61,7 @@ const tools: AgentTool[] = (await client.listTools()).map((tool) => ({
44
61
  label: tool.title ?? tool.name,
45
62
  description: tool.description ?? tool.name,
46
63
  // Providers require an object schema, and some reject one without `properties`.
47
- parameters: Type.Unsafe({ ...tool.inputSchema, type: "object", properties: tool.inputSchema.properties ?? {} }),
64
+ parameters: { ...tool.inputSchema, type: "object", properties: tool.inputSchema.properties ?? {} },
48
65
  execute: async (_toolCallId, params, signal) => {
49
66
  const result = await client.callTool(tool.name, params as Record<string, unknown>, { signal });
50
67
  // MCP reports tool failures in the result instead of as a protocol error.
@@ -53,6 +70,8 @@ const tools: AgentTool[] = (await client.listTools()).map((tool) => ({
53
70
  }));
54
71
  ```
55
72
 
73
+ For applications that name tools like pi's coding agent: `createMcpToolName(server, tool, isTaken)` builds `mcp__<server>__<tool>`, limited to the characters and the 64-character length providers accept, with a hash suffix for long names and for names `isTaken` reports as used by another tool. `mcpNamespace(server)` is the prefix of a server's tool names. `normalizeMcpInputSchema()` turns an input schema into an object schema with `properties`, and `limitMcpContent(content, saveOutput)` keeps model-facing text within `MCP_OUTPUT_MAX_BYTES` (20KB) by cutting its middle; `saveOutput`, when given, stores the full text and returns the path the model can read it from.
74
+
56
75
  The [mcp-codemode example](https://github.com/earendil-works/pi/tree/main/packages/agent/examples/mcp-codemode) also forwards progress, passes `structuredContent` through, and lets `@earendil-works/pi-codemode` scripts call the tools.
57
76
 
58
77
  ### OAuth
@@ -109,9 +128,44 @@ await connected;
109
128
 
110
129
  Inject `McpOAuthStateStore` into `McpOAuthProvider` for durable credentials. The package does not open a browser or choose where credentials are stored.
111
130
 
112
- The OAuth implementation is adapted from the MIT-licensed Model Context Protocol TypeScript SDK v1.29.0. Its license is included under `LICENSES/`.
131
+ #### Sign-in in two halves
113
132
 
114
- An MCP transport owns framing and I/O. It delivers individual JSON-RPC messages to `McpClient`; the client owns request correlation, initialization, timeouts, cancellation, server requests, and protocol-level helpers.
133
+ `startMcpSignIn()` and `completeMcpSignIn()` run the sign-in pi uses, split so the second half can run in another request with the same state store (an `McpOAuthServerStore`: a state store with a refresh lock). The caller picks the redirect URI: a loopback one, or an https callback route of its own. `startMcpSignIn()` first tries to refresh the stored tokens under the store's refresh lock, so never call it while holding that lock; its `redirect` result is plain data the application can persist until the response arrives. Pass `completeMcpSignIn()` the same options, including the redirect URI you chose (not `started.redirectUrl`, which may be a variant specific to the MCP server).
134
+
135
+ ```typescript
136
+ import { completeMcpSignIn, responseFromRedirectUrl, startMcpSignIn } from "@earendil-works/pi-mcp/oauth";
137
+
138
+ const signIn = { serverUrl, store, settings: {}, redirectUrl: "https://app.example/mcp/callback", clientName: "My app" };
139
+ const started = await startMcpSignIn(signIn);
140
+ if (started.kind === "redirect") {
141
+ // Send the browser to started.authorizationUrl; keep `started` until the response arrives.
142
+ // Later, a callback route builds { code, state, iss } from its query; a pasted URL goes through:
143
+ const response = responseFromRedirectUrl(pastedUrl, started);
144
+ await completeMcpSignIn({ ...signIn, authorization: started, response });
145
+ }
146
+ ```
147
+
148
+ For a browser on the same machine, `listenForLoopbackSignIn()` starts a loopback callback server and returns its redirect URI, and `waitForLoopbackSignIn()` waits for the response on it or for a pasted redirect URL. `clientMetadataDocuments` lets authorization servers that support Client ID Metadata Documents identify the application by a document it publishes instead of registering a client. `createMcpAuthProvider()` is the matching `AuthProvider` for connections: it refreshes the stored tokens and throws `McpOAuthAuthorizationRequiredError` when the user has to sign in.
149
+
150
+ The OAuth implementation is adapted from the MIT-licensed Model Context Protocol TypeScript SDK v1.29.0. Its license is included under `THIRD_PARTY_NOTICES/`.
151
+
152
+ ### Configuration
153
+
154
+ `validateMcpServerConfig(name, entry, options)` validates one entry of the `mcpServers` shape that MCP clients share: stdio servers (`command`, `args`, `env`, `cwd`), Streamable HTTP servers (`url`, `headers`, `oauth`), and `enabled`, `description`, and `timeout`. It returns `{ kind: "stdio" | "http", config }` or `{ kind: "invalid", error }`. Fields it does not know stay in `config`, typed `unknown`, for the application to check afterwards, depending on `kind` where it matters. Resolving `${VAR}` references and relative paths is left to the application. `oauth.clientRegistration: "cimd"` is accepted only with `options.checkMetadataDocumentCallback`, which checks that the application's Client ID Metadata Documents list the callback.
155
+
156
+ ```typescript
157
+ import { validateMcpServerConfig } from "@earendil-works/pi-mcp";
158
+
159
+ for (const [name, entry] of Object.entries(file.mcpServers)) {
160
+ const result = validateMcpServerConfig(name, entry);
161
+ if (result.kind === "invalid") errors.push(result.error);
162
+ else if (result.config.shared !== undefined && typeof result.config.shared !== "boolean") {
163
+ errors.push(`server "${name}": shared must be a boolean`);
164
+ } else servers.set(name, result);
165
+ }
166
+ ```
167
+
168
+ `isMcpServerOverride(entry)` is true for entries without `command`, `url`, or `type`, which applications treat as overriding a few fields of a server defined in another file.
115
169
 
116
170
  ## Supported protocol surface
117
171
 
@@ -124,6 +178,7 @@ An MCP transport owns framing and I/O. It delivers individual JSON-RPC messages
124
178
  - request cancellation
125
179
  - Streamable HTTP sessions, the server-to-client GET stream with reconnection, and resumption of dropped response streams with `Last-Event-ID`
126
180
  - stdio shutdown per the spec (close stdin, then SIGTERM, then SIGKILL), applied to the server's whole process group
181
+ - stdio over a caller-provided pipe (`PipeTransport`)
127
182
  - server `ping` and `roots/list` requests
128
183
  - logging and tool-list-change notifications through the generic notification API
129
184
  - OAuth protected-resource and authorization-server discovery
@@ -0,0 +1,45 @@
1
+ interface McpServerConfigBase {
2
+ description?: string;
3
+ enabled?: boolean;
4
+ timeout?: number;
5
+ }
6
+ export interface McpStdioServerConfig extends McpServerConfigBase {
7
+ type?: "stdio";
8
+ command: string;
9
+ args?: string[];
10
+ env?: Record<string, string>;
11
+ cwd?: string;
12
+ }
13
+ export interface McpOAuthConfig {
14
+ clientId?: string;
15
+ clientSecret?: string;
16
+ callbackPort?: number;
17
+ callbackUrl?: string;
18
+ scope?: string;
19
+ clientName?: string;
20
+ clientRegistration?: "auto" | "dcr" | "cimd";
21
+ authServerMetadataUrl?: string;
22
+ }
23
+ export interface McpHttpServerConfig extends McpServerConfigBase {
24
+ type?: "http";
25
+ url: string;
26
+ headers?: Record<string, string>;
27
+ oauth?: McpOAuthConfig;
28
+ }
29
+ export type McpServerConfig = McpStdioServerConfig | McpHttpServerConfig;
30
+ export type McpServerConfigResult = {
31
+ kind: "stdio";
32
+ config: McpStdioServerConfig & Record<string, unknown>;
33
+ } | {
34
+ kind: "http";
35
+ config: McpHttpServerConfig & Record<string, unknown>;
36
+ } | {
37
+ kind: "invalid";
38
+ error: string;
39
+ };
40
+ export interface McpServerConfigOptions {
41
+ checkMetadataDocumentCallback?(callbackUrl: string | undefined): string | undefined;
42
+ }
43
+ export declare function validateMcpServerConfig(name: string, raw: unknown, options?: McpServerConfigOptions): McpServerConfigResult;
44
+ export declare function isMcpServerOverride(entry: Record<string, unknown>): boolean;
45
+ export {};
@@ -0,0 +1 @@
1
+ var p=Object.defineProperty;var o=(t,e)=>p(t,"name",{value:e,configurable:!0});const m=/^[A-Za-z0-9_-]+$/;function R(t,e,n={}){const r=o(c=>({kind:"invalid",error:c}),"invalid");if(!m.test(t))return r(`invalid server name "${t}" (use letters, digits, "_" and "-")`);if(!d(e))return r(`server "${t}" must be an object`);const s=b(e);if(s)return r(`server "${t}": ${s}`);const{type:i,url:a,command:l}=e;if(i==="sse")return r(`server "${t}": legacy SSE transport is not supported; use the streamable HTTP URL`);if(typeof a=="string"&&(i===void 0||i==="http"||i==="streamable-http")){const c=h(e,a,n);return c?r(`server "${t}": ${c}`):{kind:"http",config:e}}if(typeof l=="string"&&(i===void 0||i==="stdio")){const c=g(e);return c?r(`server "${t}": ${c}`):{kind:"stdio",config:e}}return r(`server "${t}" needs either "command" (stdio) or "url" (streamable HTTP)`)}o(R,"validateMcpServerConfig");function d(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}o(d,"isRecord");function b(t){const{enabled:e,timeout:n,description:r}=t;if(e!==void 0&&typeof e!="boolean")return"enabled must be a boolean";if(r!==void 0&&typeof r!="string")return"description must be a string";if(n!==void 0&&(typeof n!="number"||!(n>0)))return"timeout must be a positive number of seconds"}o(b,"validateBaseFields");function h(t,e,n){return!URL.canParse(e)||!/^https?:$/.test(new URL(e).protocol)?"url must be an http or https URL":t.headers!==void 0&&!u(t.headers)?"headers must map names to strings":y(t.oauth,n)}o(h,"validateHttpFields");function g(t){const{args:e,env:n,cwd:r}=t;if(e!==void 0&&!(Array.isArray(e)&&e.every(s=>typeof s=="string")))return"args must be an array of strings";if(n!==void 0&&!u(n))return"env must map names to strings";if(r!==void 0&&typeof r!="string")return"cwd must be a string"}o(g,"validateStdioFields");function u(t){return d(t)&&Object.values(t).every(e=>typeof e=="string")}o(u,"isStringRecord");const f=["localhost","127.0.0.1","[::1]"];function y(t,e){if(t===void 0)return;if(!d(t))return"oauth must be an object";if(t.clientId!==void 0&&typeof t.clientId!="string")return"oauth.clientId must be a string";if(t.clientSecret!==void 0&&typeof t.clientSecret!="string")return"oauth.clientSecret must be a string";const n=t.callbackPort;if(n!==void 0&&(typeof n!="number"||!Number.isInteger(n)||n<1||n>65535))return"oauth.callbackPort must be a port number";if(t.callbackUrl!==void 0){if(typeof t.callbackUrl!="string"||!U(t.callbackUrl))return"oauth.callbackUrl must be an http URI on localhost, 127.0.0.1, or [::1] without query or fragment";const i=new URL(t.callbackUrl).port;if(i&&n!==void 0&&Number(i)!==n)return"oauth.callbackUrl and oauth.callbackPort name different ports"}if(t.scope!==void 0&&typeof t.scope!="string")return"oauth.scope must be a string";if(t.clientName!==void 0&&(typeof t.clientName!="string"||!t.clientName.trim()))return"oauth.clientName must be a non-empty string";const r=t.clientRegistration;if(r!==void 0&&r!=="auto"&&r!=="dcr"){if(r!=="cimd")return'oauth.clientRegistration must be "auto", "dcr", or "cimd"';if(t.clientId!==void 0||t.clientName!==void 0)return'oauth.clientRegistration "cimd" cannot be combined with oauth.clientId or oauth.clientName';if(!e.checkMetadataDocumentCallback)return'oauth.clientRegistration "cimd" is not supported: there are no Client ID Metadata Documents';const i=e.checkMetadataDocumentCallback(typeof t.callbackUrl=="string"?t.callbackUrl:void 0);if(i)return i}const s=t.authServerMetadataUrl;if(s!==void 0){const i=typeof s=="string"&&URL.canParse(s)?new URL(s):void 0;if(!i||!(i.protocol==="https:"||i.protocol==="http:"&&f.includes(i.hostname)))return"oauth.authServerMetadataUrl must be an https URL, or http on localhost, 127.0.0.1, or [::1]"}}o(y,"validateOAuth");function U(t){if(!URL.canParse(t))return!1;const e=new URL(t);return e.protocol==="http:"&&f.includes(e.hostname)&&e.search===""&&e.hash===""}o(U,"isLoopbackRedirectUri");function S(t){return t.command===void 0&&t.url===void 0&&t.type===void 0}o(S,"isMcpServerOverride");export{S as isMcpServerOverride,R as validateMcpServerConfig};
@@ -1,8 +1,13 @@
1
1
  export type { AuthProvider, McpFetch, UnauthorizedContext } from "./auth-provider.ts";
2
2
  export { McpClient, type McpClientOptions, type McpRequestOptions } from "./client.ts";
3
+ export { isMcpServerOverride, type McpHttpServerConfig, type McpOAuthConfig, type McpServerConfig, type McpServerConfigOptions, type McpServerConfigResult, type McpStdioServerConfig, validateMcpServerConfig, } from "./config.ts";
4
+ export { normalizeMcpInputSchema } from "./input-schema.ts";
5
+ export { createMcpToolName, mcpNamespace } from "./naming.ts";
6
+ export { type LimitedMcpContent, limitMcpContent, MCP_OUTPUT_MAX_BYTES, type McpOutputSaver, } from "./output-limit.ts";
3
7
  export { type AudioContent, type BlobResourceContents, type CallToolResult, type ContentAnnotations, type ContentBlock, type EmbeddedResourceContent, type ImageContent, type LlmContent, type ResourceLinkContent, type TextContent, type TextResourceContents, toLlmContent, } from "./protocol/content.ts";
4
8
  export { isJsonRpcNotification, isJsonRpcRequest, isJsonRpcResponse, JSON_RPC_ERROR_CODES, type JsonRpcErrorObject, type JsonRpcErrorResponse, type JsonRpcId, type JsonRpcMessage, type JsonRpcNotification, type JsonRpcRequest, type JsonRpcResponse, type JsonRpcSuccessResponse, McpAbortError, McpConnectionClosedError, McpError, McpTimeoutError, parseJsonRpcMessage, } from "./protocol/jsonrpc.ts";
5
9
  export { type CancelledNotification, type ClientCapabilities, type Implementation, type InitializeParams, type InitializeResult, LATEST_PROTOCOL_VERSION, type ListResourcesResult, type ListResourceTemplatesResult, type ListToolsResult, type ProgressNotification, type ReadResourceResult, type Resource, type ResourceTemplate, type Root, type ServerCapabilities, SUPPORTED_PROTOCOL_VERSIONS, type SupportedProtocolVersion, type Tool, type ToolAnnotations, type ToolExecution, } from "./protocol/types.ts";
10
+ export { type McpPipe, type McpPipeHandlers, PipeTransport, type PipeTransportOptions, } from "./transports/pipe.ts";
6
11
  export { StdioTransport, type StdioTransportOptions } from "./transports/stdio.ts";
7
12
  export { McpAuthRequiredError, McpHttpError, McpSessionExpiredError, StreamableHttpTransport, type StreamableHttpTransportOptions, } from "./transports/streamable-http.ts";
8
13
  export type { McpTransport, McpTransportCloseListener, McpTransportErrorListener, McpTransportMessageListener, McpTransportSendOptions, } from "./transports/transport.ts";
@@ -1 +1 @@
1
- import{McpClient as p}from"./client.js";import{toLlmContent as e}from"./protocol/content.js";import{isJsonRpcNotification as R,isJsonRpcRequest as n,isJsonRpcResponse as c,JSON_RPC_ERROR_CODES as E,McpAbortError as i,McpConnectionClosedError as O,McpError as S,McpTimeoutError as m,parseJsonRpcMessage as M}from"./protocol/jsonrpc.js";import{LATEST_PROTOCOL_VERSION as T,SUPPORTED_PROTOCOL_VERSIONS as a}from"./protocol/types.js";import{StdioTransport as x}from"./transports/stdio.js";import{McpAuthRequiredError as J,McpHttpError as P,McpSessionExpiredError as d,StreamableHttpTransport as l}from"./transports/streamable-http.js";export{E as JSON_RPC_ERROR_CODES,T as LATEST_PROTOCOL_VERSION,i as McpAbortError,J as McpAuthRequiredError,p as McpClient,O as McpConnectionClosedError,S as McpError,P as McpHttpError,d as McpSessionExpiredError,m as McpTimeoutError,a as SUPPORTED_PROTOCOL_VERSIONS,x as StdioTransport,l as StreamableHttpTransport,R as isJsonRpcNotification,n as isJsonRpcRequest,c as isJsonRpcResponse,M as parseJsonRpcMessage,e as toLlmContent};
1
+ import{McpClient as e}from"./client.js";import{isMcpServerOverride as t,validateMcpServerConfig as c}from"./config.js";import{normalizeMcpInputSchema as n}from"./input-schema.js";import{createMcpToolName as m,mcpNamespace as a}from"./naming.js";import{limitMcpContent as R,MCP_OUTPUT_MAX_BYTES as E}from"./output-limit.js";import{toLlmContent as S}from"./protocol/content.js";import{isJsonRpcNotification as T,isJsonRpcRequest as x,isJsonRpcResponse as C,JSON_RPC_ERROR_CODES as _,McpAbortError as l,McpConnectionClosedError as P,McpError as d,McpTimeoutError as N,parseJsonRpcMessage as u}from"./protocol/jsonrpc.js";import{LATEST_PROTOCOL_VERSION as v,SUPPORTED_PROTOCOL_VERSIONS as A}from"./protocol/types.js";import{PipeTransport as I}from"./transports/pipe.js";import{StdioTransport as b}from"./transports/stdio.js";import{McpAuthRequiredError as h,McpHttpError as q,McpSessionExpiredError as D,StreamableHttpTransport as H}from"./transports/streamable-http.js";export{_ as JSON_RPC_ERROR_CODES,v as LATEST_PROTOCOL_VERSION,E as MCP_OUTPUT_MAX_BYTES,l as McpAbortError,h as McpAuthRequiredError,e as McpClient,P as McpConnectionClosedError,d as McpError,q as McpHttpError,D as McpSessionExpiredError,N as McpTimeoutError,I as PipeTransport,A as SUPPORTED_PROTOCOL_VERSIONS,b as StdioTransport,H as StreamableHttpTransport,m as createMcpToolName,T as isJsonRpcNotification,x as isJsonRpcRequest,C as isJsonRpcResponse,t as isMcpServerOverride,R as limitMcpContent,a as mcpNamespace,n as normalizeMcpInputSchema,u as parseJsonRpcMessage,S as toLlmContent,c as validateMcpServerConfig};
@@ -0,0 +1 @@
1
+ export declare function normalizeMcpInputSchema(schema: Record<string, unknown>): Record<string, unknown>;
@@ -0,0 +1 @@
1
+ var r=Object.defineProperty;var p=(e,t)=>r(e,"name",{value:t,configurable:!0});function o(e){return{...e,type:e.type??"object",...e.properties===void 0?{properties:{}}:{}}}p(o,"normalizeMcpInputSchema");export{o as normalizeMcpInputSchema};
@@ -0,0 +1,2 @@
1
+ export declare function createMcpToolName(server: string, tool: string, isTaken?: (name: string) => boolean): string;
2
+ export declare function mcpNamespace(server: string): string;
@@ -0,0 +1 @@
1
+ var p=Object.defineProperty;var a=(e,c)=>p(e,"name",{value:c,configurable:!0});import{createHash as s}from"node:crypto";const _=64;function h(e,c,r=()=>!1){const t=`mcp__${e}__${c}`.replace(/[^A-Za-z0-9_]/g,"_");if(t.length<=_&&!r(t))return t;const n=s("sha256").update(`${e}\0${c}`).digest("hex").slice(0,8);return`${t.slice(0,_-n.length-1)}_${n}`}a(h,"createMcpToolName");function i(e){return`mcp__${e.replace(/-/g,"_")}`}a(i,"mcpNamespace");export{h as createMcpToolName,i as mcpNamespace};