dal-code 1.0.49 → 1.0.51

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 (593) hide show
  1. package/CHANGELOG.md +1043 -5
  2. package/dist/bundle/chunks/anthropic-messages-2P3UGLIO.js +5 -0
  3. package/dist/bundle/chunks/anthropic.js +74 -0
  4. package/dist/bundle/chunks/azure-openai-responses-S4GNH2XC.js +1 -0
  5. package/dist/bundle/chunks/bedrock-converse-stream.js +88 -0
  6. package/dist/bundle/chunks/chunk-2KOJ4RNS.js +43 -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-567OJLS7.js +1 -0
  11. package/dist/bundle/chunks/chunk-5AGIVGSV.js +5 -0
  12. package/dist/bundle/chunks/chunk-6QGV3IWD.js +5 -0
  13. package/dist/bundle/chunks/chunk-723ZGEZ2.js +1 -0
  14. package/dist/bundle/chunks/chunk-7DDKXS2Q.js +1 -0
  15. package/dist/bundle/chunks/chunk-7ZC4UXSL.js +1 -0
  16. package/dist/bundle/chunks/chunk-AL7NZVPP.js +1 -0
  17. package/dist/bundle/chunks/chunk-ATQJO2OE.js +3 -0
  18. package/dist/bundle/chunks/chunk-B7NRFMLU.js +8 -0
  19. package/dist/bundle/chunks/chunk-BEDAM2M7.js +81 -0
  20. package/dist/bundle/chunks/chunk-CF5GWZHW.js +30 -0
  21. package/dist/bundle/chunks/chunk-CFPQOC7P.js +1 -0
  22. package/dist/bundle/chunks/chunk-D2WTLI2T.js +19 -0
  23. package/dist/bundle/chunks/chunk-EH7SFF47.js +129 -0
  24. package/dist/bundle/chunks/chunk-FCKLBLA4.js +1 -0
  25. package/dist/bundle/chunks/chunk-FFMDRXC4.js +9 -0
  26. package/dist/bundle/chunks/chunk-GSGE3ULF.js +15 -0
  27. package/dist/bundle/chunks/chunk-H5FHS6BV.js +1 -0
  28. package/dist/bundle/chunks/chunk-HXK5EFBE.js +1172 -0
  29. package/dist/bundle/chunks/chunk-IEBK4HQA.js +1 -0
  30. package/dist/bundle/chunks/chunk-JE6UXK35.js +30 -0
  31. package/dist/bundle/chunks/chunk-JXWJOIH4.js +1 -0
  32. package/dist/bundle/chunks/chunk-K7VBBYTT.js +1 -0
  33. package/dist/bundle/chunks/chunk-L2ZPNLYD.js +1 -0
  34. package/dist/bundle/chunks/chunk-LVVZS2NO.js +11 -0
  35. package/dist/bundle/chunks/chunk-ML5DIOWR.js +1 -0
  36. package/dist/bundle/chunks/chunk-NUIR7PPD.js +25 -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-PWZRJWNP.js +17 -0
  42. package/dist/bundle/chunks/chunk-R44HF4S5.js +9 -0
  43. package/dist/bundle/chunks/chunk-R47JBGS3.js +1 -0
  44. package/dist/bundle/chunks/chunk-RCVVRHMF.js +9 -0
  45. package/dist/bundle/chunks/chunk-RDZVAGPR.js +1 -0
  46. package/dist/bundle/chunks/chunk-RR3ZP63P.js +56 -0
  47. package/dist/bundle/chunks/chunk-SE42OS3U.js +21 -0
  48. package/dist/bundle/chunks/chunk-TMTOQ7H7.js +1 -0
  49. package/dist/bundle/chunks/chunk-UTB4DTYQ.js +1 -0
  50. package/dist/bundle/chunks/chunk-VNHNHA4V.js +1 -0
  51. package/dist/bundle/chunks/chunk-XJFQKN3N.js +2 -0
  52. package/dist/bundle/chunks/chunk-ZG74NES2.js +1 -0
  53. package/dist/bundle/chunks/cli-FWMQKBFA.js +30 -0
  54. package/dist/bundle/chunks/cli-ZEDY5U67.js +52 -0
  55. package/dist/bundle/chunks/cloudflare-workers-ai-system-one-E6TEENDO.js +1 -0
  56. package/dist/bundle/chunks/codemode-worker.js +480 -0
  57. package/dist/bundle/chunks/dist-D3WIBXB5.js +10 -0
  58. package/dist/bundle/chunks/easter-egg-3d-5TFBCTIS.js +1 -0
  59. package/dist/bundle/chunks/execute-62LDYHXA.js +506 -0
  60. package/dist/bundle/chunks/github-copilot.js +1 -0
  61. package/dist/bundle/chunks/google-generative-ai-V5DLXTF7.js +1 -0
  62. package/dist/bundle/chunks/google-vertex-K3KYGGLI.js +1 -0
  63. package/dist/bundle/chunks/http-proxy-KF35JLJN.js +1 -0
  64. package/dist/bundle/chunks/https-proxy-agent-LVOO5TPL.js +12 -0
  65. package/dist/bundle/chunks/image-resize-worker.js +1 -0
  66. package/dist/bundle/chunks/jiti-loader-GL4HJFAD.js +20 -0
  67. package/dist/bundle/chunks/jiti-static-loader-2RCDI6B4.js +1 -0
  68. package/dist/bundle/chunks/kimi-coding.js +1 -0
  69. package/dist/bundle/chunks/lib-4AVRLBHM.js +8 -0
  70. package/dist/bundle/chunks/llama-cpp-classify-JCTIEHTL.js +21 -0
  71. package/dist/bundle/chunks/mcp-VF7EY5WC.js +10 -0
  72. package/dist/bundle/chunks/meta.js +1 -0
  73. package/dist/bundle/chunks/mistral-conversations-LVBXTF6R.js +4 -0
  74. package/dist/bundle/chunks/multipart-parser-FMGQ7342.js +2 -0
  75. package/dist/bundle/chunks/node-AUOGOBCN.js +1 -0
  76. package/dist/bundle/chunks/node-ZTHARAQV.js +15 -0
  77. package/dist/bundle/chunks/office-PONBADQP.js +419 -0
  78. package/dist/bundle/chunks/openai-chatgpt.js +74 -0
  79. package/dist/bundle/chunks/openai-codex-responses-WBZKNYLX.js +9 -0
  80. package/dist/bundle/chunks/openai-codex.js +74 -0
  81. package/dist/bundle/chunks/openai-completions-HMHQRGX4.js +6 -0
  82. package/dist/bundle/chunks/openai-decisions-R7OFRKLL.js +4 -0
  83. package/dist/bundle/chunks/openai-responses-BHXRQFCI.js +3 -0
  84. package/dist/bundle/chunks/openrouter-images-BIMNIXQZ.js +1 -0
  85. package/dist/bundle/chunks/openrouter.js +74 -0
  86. package/dist/bundle/chunks/pi-messages-X5YTLXQJ.js +7 -0
  87. package/dist/bundle/chunks/radius.js +74 -0
  88. package/dist/bundle/chunks/review-WCGIBVLM.js +80 -0
  89. package/dist/bundle/chunks/rewind-2OYLDDHH.js +8 -0
  90. package/dist/bundle/chunks/router-7E5LU7US.js +3 -0
  91. package/dist/bundle/chunks/runtime-5PTUOEM2.js +1 -0
  92. package/dist/bundle/chunks/sdk-ZUFIGPSS.js +1 -0
  93. package/dist/bundle/chunks/src-QKGKDFSU.js +3 -0
  94. package/dist/bundle/chunks/sync-LOX6TIM6.js +4 -0
  95. package/dist/bundle/chunks/typesafe-system-one-KOIOG3HP.js +1 -0
  96. package/dist/bundle/chunks/usage-2EVEFGNI.js +1 -0
  97. package/dist/bundle/chunks/virtual-modules-MYMONT3Y.js +1 -0
  98. package/dist/bundle/chunks/xai.js +1 -0
  99. package/dist/bundle/cli-runtime.js +2 -0
  100. package/dist/bundle/cli.js +2 -0
  101. package/dist/bundle/index.js +1 -0
  102. package/dist/bundle/rpc-entry.js +2 -0
  103. package/dist/cli/args.js +1 -1
  104. package/dist/cli/auth-command.js +9 -6
  105. package/dist/cli/auth-login.js +2 -0
  106. package/dist/cli/auth-logout.js +1 -0
  107. package/dist/cli/auth-terminal.js +5 -0
  108. package/dist/cli/config-selector.js +1 -1
  109. package/dist/config.d.ts +5 -0
  110. package/dist/config.js +1 -1
  111. package/dist/core/agent-session-runtime.js +1 -1
  112. package/dist/core/agent-session-services.js +1 -1
  113. package/dist/core/agent-session.d.ts +8 -1
  114. package/dist/core/agent-session.js +12 -9
  115. package/dist/core/auth-storage.js +1 -1
  116. package/dist/core/bash-executor.js +1 -1
  117. package/dist/core/bug-report.js +3 -3
  118. package/dist/core/cache-warmer.d.ts +3 -15
  119. package/dist/core/cache-warmer.js +1 -1
  120. package/dist/core/compaction/branch-summarization.d.ts +3 -2
  121. package/dist/core/compaction/branch-summarization.js +5 -5
  122. package/dist/core/compaction/compaction.d.ts +1 -0
  123. package/dist/core/compaction/compaction.js +14 -14
  124. package/dist/core/compaction/tool-output-pruning.js +1 -1
  125. package/dist/core/compaction/utils.d.ts +0 -1
  126. package/dist/core/compaction/utils.js +8 -8
  127. package/dist/core/exec.d.ts +2 -0
  128. package/dist/core/exec.js +1 -1
  129. package/dist/core/export-html/template.css +9 -0
  130. package/dist/core/export-html/template.js +46 -39
  131. package/dist/core/export-html/tool-renderer.js +1 -1
  132. package/dist/core/extensions/index.d.ts +1 -1
  133. package/dist/core/extensions/loader.js +1 -1
  134. package/dist/core/extensions/pi-ai-extension-view.js +1 -0
  135. package/dist/core/extensions/runner.js +1 -1
  136. package/dist/core/extensions/types.d.ts +25 -7
  137. package/dist/core/extensions/virtual-modules.js +1 -1
  138. package/dist/core/keybindings.d.ts +1 -1
  139. package/dist/core/keybindings.js +1 -1
  140. package/dist/core/mcp-servers.d.ts +6 -17
  141. package/dist/core/mcp-servers.js +1 -1
  142. package/dist/core/model-config.d.ts +1912 -2211
  143. package/dist/core/model-config.js +4 -4
  144. package/dist/core/model-resolver.js +1 -1
  145. package/dist/core/model-runtime.d.ts +1 -0
  146. package/dist/core/model-runtime.js +1 -1
  147. package/dist/core/package-manager.d.ts +10 -1
  148. package/dist/core/package-manager.js +2 -2
  149. package/dist/core/pi-ai-schemas.js +1 -0
  150. package/dist/core/pi-manifest.js +1 -1
  151. package/dist/core/preferred-providers.js +1 -0
  152. package/dist/core/project-trust.js +2 -2
  153. package/dist/core/prompt-templates.js +2 -2
  154. package/dist/core/provider-composer.js +1 -1
  155. package/dist/core/provider-matching.js +1 -0
  156. package/dist/core/radius-mcp.js +1 -0
  157. package/dist/core/remote-catalog-provider.js +1 -1
  158. package/dist/core/resource-loader.d.ts +3 -1
  159. package/dist/core/resource-loader.js +1 -1
  160. package/dist/core/runtime-credentials.js +1 -1
  161. package/dist/core/sdk.js +1 -1
  162. package/dist/core/session-cwd.js +3 -7
  163. package/dist/core/session-manager.d.ts +1 -0
  164. package/dist/core/session-manager.js +12 -12
  165. package/dist/core/settings-defaults.js +1 -1
  166. package/dist/core/settings-manager.d.ts +4 -0
  167. package/dist/core/settings-manager.js +1 -1
  168. package/dist/core/settings-schema.d.ts +4 -2
  169. package/dist/core/settings-schema.js +1 -1
  170. package/dist/core/skills.js +3 -3
  171. package/dist/core/slash-commands.js +1 -1
  172. package/dist/core/source-info.d.ts +8 -0
  173. package/dist/core/source-info.js +1 -1
  174. package/dist/core/system-prompt.js +3 -3
  175. package/dist/core/tools/bash.d.ts +2 -2
  176. package/dist/core/tools/bash.js +15 -15
  177. package/dist/core/tools/edit-diff.d.ts +9 -4
  178. package/dist/core/tools/edit-diff.js +22 -15
  179. package/dist/core/tools/edit.d.ts +3 -3
  180. package/dist/core/tools/edit.js +3 -3
  181. package/dist/core/tools/find.d.ts +2 -2
  182. package/dist/core/tools/find.js +10 -11
  183. package/dist/core/tools/grep.d.ts +3 -3
  184. package/dist/core/tools/grep.js +8 -12
  185. package/dist/core/tools/ls.d.ts +2 -2
  186. package/dist/core/tools/ls.js +4 -4
  187. package/dist/core/tools/powershell.js +6 -2
  188. package/dist/core/tools/read.d.ts +5 -2
  189. package/dist/core/tools/read.js +20 -19
  190. package/dist/core/tools/render-utils.js +5 -5
  191. package/dist/core/tools/renderers/write.js +10 -10
  192. package/dist/core/tools/tool-definition-wrapper.d.ts +11 -0
  193. package/dist/core/tools/truncate.d.ts +2 -8
  194. package/dist/core/tools/truncate.js +10 -10
  195. package/dist/core/tools/write.d.ts +2 -2
  196. package/dist/core/trust-manager.js +2 -2
  197. package/dist/core/usage-totals.js +1 -1
  198. package/dist/extensions/codemode/execute.js +12 -12
  199. package/dist/extensions/codemode/renderer.js +6 -6
  200. package/dist/extensions/codemode/tool.d.ts +2 -1
  201. package/dist/extensions/codemode/tool.js +11 -10
  202. package/dist/extensions/llama/client.js +5 -5
  203. package/dist/extensions/llama/ui.js +2 -2
  204. package/dist/extensions/mcp/cli.js +21 -19
  205. package/dist/extensions/mcp/config.js +2 -2
  206. package/dist/extensions/mcp/index.js +7 -7
  207. package/dist/extensions/mcp/oauth.d.ts +3 -22
  208. package/dist/extensions/mcp/oauth.js +2 -2
  209. package/dist/extensions/mcp/resources.d.ts +1 -1
  210. package/dist/extensions/mcp/resources.js +1 -1
  211. package/dist/extensions/mcp/runtime.d.ts +2 -2
  212. package/dist/extensions/mcp/runtime.js +3 -3
  213. package/dist/extensions/mcp/tools.d.ts +1 -8
  214. package/dist/extensions/mcp/tools.js +4 -9
  215. package/dist/extensions/mcp/ui.js +1 -1
  216. package/dist/extensions/tool-search/tool.js +4 -4
  217. package/dist/index.d.ts +2 -2
  218. package/dist/main.js +4 -4
  219. package/dist/modes/interactive/components/assistant-message.d.ts +4 -1
  220. package/dist/modes/interactive/components/assistant-message.js +2 -2
  221. package/dist/modes/interactive/components/branch-summary-message.d.ts +5 -1
  222. package/dist/modes/interactive/components/branch-summary-message.js +2 -2
  223. package/dist/modes/interactive/components/compaction-summary-message.d.ts +5 -1
  224. package/dist/modes/interactive/components/compaction-summary-message.js +2 -2
  225. package/dist/modes/interactive/components/config-selector.js +1 -1
  226. package/dist/modes/interactive/components/custom-editor.js +1 -1
  227. package/dist/modes/interactive/components/custom-entry.js +1 -1
  228. package/dist/modes/interactive/components/custom-message.d.ts +5 -2
  229. package/dist/modes/interactive/components/custom-message.js +3 -3
  230. package/dist/modes/interactive/components/diff.js +3 -3
  231. package/dist/modes/interactive/components/extension-editor.d.ts +1 -0
  232. package/dist/modes/interactive/components/extension-editor.js +1 -1
  233. package/dist/modes/interactive/components/extension-selector.js +2 -2
  234. package/dist/modes/interactive/components/login-dialog.d.ts +5 -0
  235. package/dist/modes/interactive/components/login-dialog.js +1 -1
  236. package/dist/modes/interactive/components/markdown-transform.js +1 -1
  237. package/dist/modes/interactive/components/mermaid.js +4 -4
  238. package/dist/modes/interactive/components/model-selector.d.ts +1 -0
  239. package/dist/modes/interactive/components/model-selector.js +2 -2
  240. package/dist/modes/interactive/components/oauth-selector.d.ts +2 -1
  241. package/dist/modes/interactive/components/oauth-selector.js +1 -1
  242. package/dist/modes/interactive/components/provider-brand.js +1 -0
  243. package/dist/modes/interactive/components/radius-login-selector.js +1 -1
  244. package/dist/modes/interactive/components/scoped-models-selector.d.ts +1 -0
  245. package/dist/modes/interactive/components/scoped-models-selector.js +1 -1
  246. package/dist/modes/interactive/components/session-selector-search.js +1 -1
  247. package/dist/modes/interactive/components/session-selector.d.ts +2 -1
  248. package/dist/modes/interactive/components/session-selector.js +2 -2
  249. package/dist/modes/interactive/components/settings-submenu.js +1 -1
  250. package/dist/modes/interactive/components/skill-invocation-message.d.ts +5 -1
  251. package/dist/modes/interactive/components/skill-invocation-message.js +2 -2
  252. package/dist/modes/interactive/components/tool-execution.d.ts +1 -0
  253. package/dist/modes/interactive/components/tool-execution.js +3 -3
  254. package/dist/modes/interactive/components/tree-selector.d.ts +2 -0
  255. package/dist/modes/interactive/components/tree-selector.js +1 -1
  256. package/dist/modes/interactive/components/user-message-selector.d.ts +1 -0
  257. package/dist/modes/interactive/components/user-message-selector.js +1 -1
  258. package/dist/modes/interactive/components/user-message.d.ts +2 -1
  259. package/dist/modes/interactive/components/user-message.js +1 -1
  260. package/dist/modes/interactive/external-editor.js +3 -3
  261. package/dist/modes/interactive/interactive-mode.d.ts +10 -1
  262. package/dist/modes/interactive/interactive-mode.js +45 -40
  263. package/dist/modes/interactive/model-search.js +1 -1
  264. package/dist/modes/interactive/theme/theme.d.ts +4 -0
  265. package/dist/modes/interactive/theme/theme.js +3 -6
  266. package/dist/modes/print-mode.js +7 -7
  267. package/dist/modes/rpc/rpc-mode.js +1 -1
  268. package/dist/node_modules/@dalcode/dal-advisor/package.json +3 -3
  269. package/dist/node_modules/@dalcode/dal-awake/package.json +2 -2
  270. package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
  271. package/dist/node_modules/@dalcode/dal-capabilities/package.json +4 -4
  272. package/dist/node_modules/@dalcode/dal-codeindex/package.json +2 -2
  273. package/dist/node_modules/@dalcode/dal-compat/package.json +3 -3
  274. package/dist/node_modules/@dalcode/dal-dap/package.json +2 -2
  275. package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
  276. package/dist/node_modules/@dalcode/dal-goal/package.json +3 -3
  277. package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
  278. package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
  279. package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
  280. package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
  281. package/dist/node_modules/@dalcode/dal-learn/package.json +3 -2
  282. package/dist/node_modules/@dalcode/dal-learn/src/index.js +16 -16
  283. package/dist/node_modules/@dalcode/dal-learn/src/lesson-events.js +1 -0
  284. package/dist/node_modules/@dalcode/dal-lsp/package.json +4 -4
  285. package/dist/node_modules/@dalcode/dal-mcp/package.json +6 -6
  286. package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
  287. package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +4 -3
  288. package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
  289. package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +4 -3
  290. package/dist/node_modules/@dalcode/dal-plugins/package.json +4 -4
  291. package/dist/node_modules/@dalcode/dal-recall/package.json +2 -2
  292. package/dist/node_modules/@dalcode/dal-remote/package.json +2 -2
  293. package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
  294. package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
  295. package/dist/node_modules/@dalcode/dal-router/package.json +6 -6
  296. package/dist/node_modules/@dalcode/dal-rtk/package.json +2 -2
  297. package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
  298. package/dist/node_modules/@dalcode/dal-statusline/package.json +2 -2
  299. package/dist/node_modules/@dalcode/dal-structured/package.json +2 -2
  300. package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
  301. package/dist/node_modules/@dalcode/dal-sync/package.json +4 -4
  302. package/dist/node_modules/@dalcode/dal-telemetry/package.json +4 -4
  303. package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
  304. package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
  305. package/dist/node_modules/@dalcode/dal-usage/package.json +2 -2
  306. package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
  307. package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
  308. package/dist/node_modules/@dalcode/dal-workflow/src/image-budget.js +1 -0
  309. package/dist/node_modules/@dalcode/dal-workflow/src/index.js +4 -4
  310. package/dist/node_modules/@dalcode/dal-workflow/src/todo-snapshot.js +2 -2
  311. package/dist/node_modules/@dalcode/dal-workflow/src/todo.js +3 -3
  312. package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
  313. package/dist/node_modules/@earendil-works/pi-agent-core/README.md +8 -6
  314. package/dist/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts +1 -1
  315. package/dist/node_modules/@earendil-works/pi-agent-core/dist/proxy.js +2 -2
  316. package/dist/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +8 -5
  317. package/dist/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
  318. package/dist/node_modules/@earendil-works/pi-ai/README.md +58 -39
  319. package/dist/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +5 -5
  320. package/dist/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +1 -1
  321. package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +1 -1
  322. package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.lazy.d.ts +1 -0
  323. package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.lazy.js +1 -1
  324. package/dist/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js +1 -1
  325. package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js +1 -1
  326. package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js +2 -2
  327. package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js +1 -1
  328. package/dist/node_modules/@earendil-works/pi-ai/dist/api/lazy.d.ts +1 -1
  329. package/dist/node_modules/@earendil-works/pi-ai/dist/api/lazy.js +1 -1
  330. package/dist/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +4 -4
  331. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +1 -1
  332. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts +2 -1
  333. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +5 -5
  334. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +9 -9
  335. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +3 -3
  336. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js +1 -1
  337. package/dist/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts +2 -0
  338. package/dist/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +3 -3
  339. package/dist/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js +1 -1
  340. package/dist/node_modules/@earendil-works/pi-ai/dist/api/strict-tool-limits.js +1 -0
  341. package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/kimi-coding.js +1 -1
  342. package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.js +1 -1
  343. package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/meta.js +1 -1
  344. package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/radius.js +1 -1
  345. package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/trusted-url.js +1 -0
  346. package/dist/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts +2 -0
  347. package/dist/node_modules/@earendil-works/pi-ai/dist/cache-warming.d.ts +21 -0
  348. package/dist/node_modules/@earendil-works/pi-ai/dist/cache-warming.js +1 -0
  349. package/dist/node_modules/@earendil-works/pi-ai/dist/cli.js +5 -5
  350. package/dist/node_modules/@earendil-works/pi-ai/dist/compat/extension-oauth-types.d.ts +2 -0
  351. package/dist/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +1 -1
  352. package/dist/node_modules/@earendil-works/pi-ai/dist/index.d.ts +3 -3
  353. package/dist/node_modules/@earendil-works/pi-ai/dist/index.js +1 -1
  354. package/dist/node_modules/@earendil-works/pi-ai/dist/lazy-bedrock-provider.js +1 -0
  355. package/dist/node_modules/@earendil-works/pi-ai/dist/lazy-oauth.js +1 -0
  356. package/dist/node_modules/@earendil-works/pi-ai/dist/models.d.ts +1 -0
  357. package/dist/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +4 -0
  358. package/dist/node_modules/@earendil-works/pi-ai/dist/models.generated.js +1 -1
  359. package/dist/node_modules/@earendil-works/pi-ai/dist/models.js +1 -1
  360. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/all.js +1 -1
  361. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.d.ts +485 -498
  362. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.js +1 -1
  363. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  364. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
  365. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -1
  366. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/azure.json +1 -1
  367. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
  368. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  369. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
  370. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
  371. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  372. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/google-vertex.json +1 -1
  373. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
  374. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
  375. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/kimi-coding.json +1 -1
  376. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/meta.json +1 -1
  377. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
  378. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai-cn.json +1 -1
  379. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai.json +1 -1
  380. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
  381. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -1
  382. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
  383. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
  384. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  385. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  386. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-cn.json +1 -1
  387. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-individual-cn.json +1 -0
  388. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-individual.json +1 -1
  389. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.json +1 -1
  390. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
  391. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
  392. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  393. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xai.json +1 -1
  394. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-ams.json +1 -1
  395. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-cn.json +1 -1
  396. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-sgp.json +1 -1
  397. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi.json +1 -1
  398. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
  399. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
  400. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/faux.js +5 -5
  401. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.js +1 -1
  402. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.d.ts +65 -65
  403. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.js +1 -1
  404. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.js +1 -1
  405. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-individual-cn.js +1 -0
  406. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-individual-cn.models.d.ts +5 -0
  407. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-individual-cn.models.js +1 -0
  408. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/radius-config.js +1 -1
  409. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/schema-builders.js +1 -0
  410. package/dist/node_modules/@earendil-works/pi-ai/dist/telemetry.js +1 -1
  411. package/dist/node_modules/@earendil-works/pi-ai/dist/types.d.ts +4 -3
  412. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/error-body.js +1 -1
  413. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/openrouter-cost.js +1 -0
  414. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +1 -1
  415. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +1 -1
  416. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/streaming-json.d.ts +26 -0
  417. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/streaming-json.js +4 -0
  418. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/{typebox-helpers.d.ts → string-enum.d.ts} +2 -2
  419. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/string-enum.js +1 -0
  420. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/text.d.ts +1 -0
  421. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/text.js +2 -2
  422. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/validation.js +4 -4
  423. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.d.ts +1 -1
  424. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.js +1 -1
  425. package/dist/node_modules/@earendil-works/pi-ai/package.json +12 -5
  426. package/dist/node_modules/@earendil-works/pi-codemode/README.md +2 -2
  427. package/dist/node_modules/@earendil-works/pi-codemode/dist/declarations.d.ts +1 -0
  428. package/dist/node_modules/@earendil-works/pi-codemode/dist/declarations.js +4 -4
  429. package/dist/node_modules/@earendil-works/pi-codemode/dist/index.d.ts +1 -1
  430. package/dist/node_modules/@earendil-works/pi-codemode/dist/index.js +1 -1
  431. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/prelude-source.js +2 -0
  432. package/dist/node_modules/@earendil-works/pi-codemode/package.json +1 -1
  433. package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
  434. package/dist/node_modules/@earendil-works/pi-mcp/CHANGELOG.md +32 -0
  435. package/dist/node_modules/@earendil-works/pi-mcp/README.md +60 -5
  436. package/dist/node_modules/@earendil-works/pi-mcp/dist/config.d.ts +45 -0
  437. package/dist/node_modules/@earendil-works/pi-mcp/dist/config.js +1 -0
  438. package/dist/node_modules/@earendil-works/pi-mcp/dist/index.d.ts +5 -0
  439. package/dist/node_modules/@earendil-works/pi-mcp/dist/index.js +1 -1
  440. package/dist/node_modules/@earendil-works/pi-mcp/dist/input-schema.d.ts +1 -0
  441. package/dist/node_modules/@earendil-works/pi-mcp/dist/input-schema.js +1 -0
  442. package/dist/node_modules/@earendil-works/pi-mcp/dist/naming.d.ts +2 -0
  443. package/dist/node_modules/@earendil-works/pi-mcp/dist/naming.js +1 -0
  444. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/auth-provider.d.ts +18 -0
  445. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/auth-provider.js +1 -0
  446. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/callback.js +1 -1
  447. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/client-settings.d.ts +42 -0
  448. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/client-settings.js +1 -0
  449. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.d.ts +3 -0
  450. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.js +1 -1
  451. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/flow.d.ts +2 -0
  452. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/flow.js +1 -1
  453. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/index.d.ts +5 -1
  454. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/index.js +1 -1
  455. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/loopback.d.ts +22 -0
  456. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/loopback.js +1 -0
  457. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/sign-in.d.ts +28 -0
  458. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/sign-in.js +1 -0
  459. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/types.d.ts +1 -0
  460. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/types.js +1 -1
  461. package/dist/node_modules/@earendil-works/pi-mcp/dist/output-limit.d.ts +8 -0
  462. package/dist/node_modules/@earendil-works/pi-mcp/dist/output-limit.js +11 -0
  463. package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/lines.js +1 -0
  464. package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/pipe.d.ts +34 -0
  465. package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/pipe.js +2 -0
  466. package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/stdio.d.ts +1 -4
  467. package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/stdio.js +2 -2
  468. package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/streamable-http.js +6 -4
  469. package/dist/node_modules/@earendil-works/pi-mcp/package.json +2 -2
  470. package/dist/node_modules/@earendil-works/pi-schema/CHANGELOG.md +37 -0
  471. package/dist/node_modules/@earendil-works/pi-schema/LICENSE +21 -0
  472. package/dist/node_modules/@earendil-works/pi-schema/README.md +319 -0
  473. package/dist/node_modules/@earendil-works/pi-schema/THIRD_PARTY_NOTICES/typebox-LICENSE +23 -0
  474. package/dist/node_modules/@earendil-works/pi-schema/dist/annotations.js +1 -0
  475. package/dist/node_modules/@earendil-works/pi-schema/dist/builders.d.ts +89 -0
  476. package/dist/node_modules/@earendil-works/pi-schema/dist/builders.js +1 -0
  477. package/dist/node_modules/@earendil-works/pi-schema/dist/checks.d.ts +51 -0
  478. package/dist/node_modules/@earendil-works/pi-schema/dist/checks.js +1 -0
  479. package/dist/node_modules/@earendil-works/pi-schema/dist/coerce.js +1 -0
  480. package/dist/node_modules/@earendil-works/pi-schema/dist/compiler.js +1 -0
  481. package/dist/node_modules/@earendil-works/pi-schema/dist/explain.js +1 -0
  482. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/index.js +1 -0
  483. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/date.js +1 -0
  484. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/date_time.js +1 -0
  485. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/duration.js +1 -0
  486. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/email.js +1 -0
  487. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/hostname.js +1 -0
  488. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idn_email.js +1 -0
  489. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idn_hostname.js +1 -0
  490. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/format/bidi.js +1 -0
  491. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/format/puny.js +1 -0
  492. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/hostname.js +1 -0
  493. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/idn-hostname.js +1 -0
  494. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/index.js +1 -0
  495. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/label/ascii.js +1 -0
  496. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/label/puny.js +1 -0
  497. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/label/unicode.js +1 -0
  498. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/pattern/pattern.js +1 -0
  499. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/ipv4.js +1 -0
  500. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/ipv6.js +1 -0
  501. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/iri.js +1 -0
  502. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/iri_reference.js +1 -0
  503. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/json_pointer.js +1 -0
  504. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/json_pointer_uri_fragment.js +1 -0
  505. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/regex.js +1 -0
  506. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/relative_json_pointer.js +1 -0
  507. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/time.js +1 -0
  508. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/uri.js +1 -0
  509. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/uri_reference.js +1 -0
  510. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/uri_template.js +1 -0
  511. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/url.js +1 -0
  512. package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/uuid.js +1 -0
  513. package/dist/node_modules/@earendil-works/pi-schema/dist/index.d.ts +4 -0
  514. package/dist/node_modules/@earendil-works/pi-schema/dist/index.js +1 -0
  515. package/dist/node_modules/@earendil-works/pi-schema/dist/resolver.js +1 -0
  516. package/dist/node_modules/@earendil-works/pi-schema/dist/shared.js +1 -0
  517. package/dist/node_modules/@earendil-works/pi-schema/dist/typebox-static.d.ts +54 -0
  518. package/dist/node_modules/@earendil-works/pi-schema/dist/typebox-static.js +0 -0
  519. package/dist/node_modules/@earendil-works/pi-schema/dist/types.d.ts +25 -0
  520. package/dist/node_modules/@earendil-works/pi-schema/dist/types.js +0 -0
  521. package/dist/node_modules/@earendil-works/pi-schema/dist/validator.d.ts +20 -0
  522. package/dist/node_modules/@earendil-works/pi-schema/dist/validator.js +1 -0
  523. package/dist/node_modules/@earendil-works/pi-schema/package.json +43 -0
  524. package/dist/node_modules/@earendil-works/pi-telemetry/dist/index.d.ts +1 -1
  525. package/dist/node_modules/@earendil-works/pi-telemetry/dist/index.js +1 -1
  526. package/dist/node_modules/@earendil-works/pi-telemetry/dist/memory.d.ts +1 -0
  527. package/dist/node_modules/@earendil-works/pi-telemetry/dist/memory.js +1 -1
  528. package/dist/node_modules/@earendil-works/pi-telemetry/dist/render.js +2 -2
  529. package/dist/node_modules/@earendil-works/pi-telemetry/package.json +3 -1
  530. package/dist/node_modules/@earendil-works/pi-tui/README.md +2 -0
  531. package/dist/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts +1 -0
  532. package/dist/node_modules/@earendil-works/pi-tui/dist/components/editor.js +3 -3
  533. package/dist/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts +4 -0
  534. package/dist/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +11 -10
  535. package/dist/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts +1 -0
  536. package/dist/node_modules/@earendil-works/pi-tui/dist/components/select-list.js +1 -1
  537. package/dist/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts +1 -0
  538. package/dist/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js +1 -1
  539. package/dist/node_modules/@earendil-works/pi-tui/dist/components/text.js +1 -1
  540. package/dist/node_modules/@earendil-works/pi-tui/dist/fuzzy.js +1 -1
  541. package/dist/node_modules/@earendil-works/pi-tui/dist/index.d.ts +2 -2
  542. package/dist/node_modules/@earendil-works/pi-tui/dist/index.js +1 -1
  543. package/dist/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +1 -0
  544. package/dist/node_modules/@earendil-works/pi-tui/dist/keybindings.js +1 -1
  545. package/dist/node_modules/@earendil-works/pi-tui/dist/keys.js +5 -5
  546. package/dist/node_modules/@earendil-works/pi-tui/dist/layout.js +1 -1
  547. package/dist/node_modules/@earendil-works/pi-tui/dist/program-status.js +1 -1
  548. package/dist/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +1 -0
  549. package/dist/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +1 -1
  550. package/dist/node_modules/@earendil-works/pi-tui/dist/terminal.js +1 -1
  551. package/dist/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts +1 -1
  552. package/dist/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js +4 -4
  553. package/dist/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.js +13 -13
  554. package/dist/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +1 -0
  555. package/dist/node_modules/@earendil-works/pi-tui/dist/tui.js +2 -2
  556. package/dist/node_modules/@earendil-works/pi-tui/dist/utils.d.ts +1 -0
  557. package/dist/node_modules/@earendil-works/pi-tui/dist/utils.js +1 -1
  558. package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
  559. package/dist/package-manager-cli.js +17 -16
  560. package/dist/utils/ansi.js +1 -1
  561. package/dist/utils/changelog.js +3 -3
  562. package/dist/utils/clipboard-command.js +1 -1
  563. package/dist/utils/image-resize-core.js +1 -1
  564. package/dist/utils/image-resize.js +1 -1
  565. package/dist/utils/open-browser.js +1 -1
  566. package/dist/utils/paths.js +1 -1
  567. package/dist/utils/shell.js +3 -3
  568. package/dist/utils/syntax-highlight.js +4 -4
  569. package/dist/utils/terminal-question.js +1 -0
  570. package/dist/utils/tools-manager.js +1 -1
  571. package/dist/utils/web-url.js +1 -0
  572. package/examples/extensions/README.md +2 -1
  573. package/examples/extensions/custom-provider-gitlab-duo/package.json +14 -14
  574. package/examples/extensions/debug-provider.ts +2 -2
  575. package/examples/extensions/gondolin/package-lock.json +19 -29
  576. package/examples/extensions/gondolin/package.json +2 -2
  577. package/examples/extensions/plan-mode/index.ts +20 -9
  578. package/examples/extensions/plan-mode/utils.ts +42 -16
  579. package/examples/extensions/preset.ts +2 -0
  580. package/examples/extensions/reload-runtime.ts +17 -5
  581. package/examples/extensions/subagent/README.md +14 -11
  582. package/examples/extensions/subagent/index.ts +392 -171
  583. package/examples/extensions/todo.ts +7 -0
  584. package/examples/extensions/tools.ts +2 -0
  585. package/examples/extensions/with-deps/package-lock.json +2 -2
  586. package/examples/extensions/with-deps/package.json +20 -20
  587. package/examples/tsconfig.json +208 -0
  588. package/npm-shrinkwrap.json +407 -383
  589. package/package.json +6 -7
  590. package/examples/extensions/sandbox/index.ts +0 -327
  591. package/examples/extensions/sandbox/package-lock.json +0 -92
  592. package/examples/extensions/sandbox/package.json +0 -19
  593. /package/dist/node_modules/@earendil-works/pi-mcp/{LICENSES → THIRD_PARTY_NOTICES}/modelcontextprotocol-typescript-sdk.txt +0 -0
@@ -0,0 +1 @@
1
+ var M=Object.defineProperty;var t=(d,n)=>M(d,"name",{value:n,configurable:!0});const S=/^P((\d+Y(\d+M(\d+D)?)?|\d+M(\d+D)?|\d+D)(T(\d+H(\d+M(\d+S)?)?|\d+M(\d+S)?|\d+S))?|T(\d+H(\d+M(\d+S)?)?|\d+M(\d+S)?|\d+S)|\d+W)$/;function r(d){return S.test(d)}t(r,"IsDuration");export{r as IsDuration};
@@ -0,0 +1 @@
1
+ var e=Object.defineProperty;var z=(a,t)=>e(a,"name",{value:t,configurable:!0});const i=/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[^"\\]|\\[\x20-\x7e])*")@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*|\[(?:IPv6:[a-f0-9:]+|(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?:\.(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3})\])$/i;function o(a){return i.test(a)}z(o,"IsEmail");export{o as IsEmail};
@@ -0,0 +1 @@
1
+ var r=Object.defineProperty;var o=(n,t)=>r(n,"name",{value:t,configurable:!0});import*as s from"./idna/index.js";function e(n){return s.IsHostname(n)}o(e,"IsHostname");export{e as IsHostname};
@@ -0,0 +1 @@
1
+ var u=Object.defineProperty;var F=(p,n)=>u(p,"name",{value:n,configurable:!0});const t=/^(?:[A-Za-z0-9!#$%&'*+/=?^_`{|}~\u{0080}-\u{10FFFF}-]+(?:\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~\u{0080}-\u{10FFFF}-]+)*|"(?:[^"\\]|\\.)*")@[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-)(?:\.[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-))*$/iu;function i(p){return t.test(p.normalize("NFC"))}F(i,"IsIdnEmail");export{i as IsIdnEmail};
@@ -0,0 +1 @@
1
+ var r=Object.defineProperty;var o=(n,t)=>r(n,"name",{value:t,configurable:!0});import*as s from"./idna/index.js";function a(n){return s.IsIdnHostname(n)}o(a,"IsIdnHostname");export{a as IsIdnHostname};
@@ -0,0 +1 @@
1
+ var l=Object.defineProperty;var o=(e,t)=>l(e,"name",{value:t,configurable:!0});import*as s from"../pattern/pattern.js";import*as R from"./puny.js";const L=/^(?:R|AL|AN|EN|ES|CS|ET|ON|BN|NSM)$/,a=/^(?:L|EN|ES|CS|ET|ON|BN|NSM)$/,u=/^(?:R|AL|AN)$/;function C(e){if(R.IsAcePrefixed(e))try{return A(R.Decode(e.slice(4).toLowerCase()))}catch{return!1}return A(e)}o(C,"HasBidiChars");function N(e){const t=String.fromCodePoint(e);return s.RE_EUROPEAN_NUMBER.test(t)?"EN":s.RE_ARABIC_INDIC_DIGIT.test(t)?"AN":s.RE_MARK_NONSPACING.test(t)?"NSM":s.RE_SCRIPT_HEBREW.test(t)?"R":s.RE_SCRIPT_ARABIC_LETTER.test(t)?"AL":s.RE_LETTER.test(t)?"L":"ON"}o(N,"GetBidiClass");function A(e){for(const t of e)if(u.test(N(t.codePointAt(0))))return!0;return!1}o(A,"HasRightToLeftCharacters");function S(e){let t=!1,i=a,f=!1,n=!1,E=!0;for(const c of e){const r=N(c.codePointAt(0));if(E){if(r!=="L"&&r!=="R"&&r!=="AL")return!1;t=r==="R"||r==="AL",i=t?L:a,E=!1}if(!i.test(r))return!1;r==="EN"?f=!0:r==="AN"&&(n=!0)}return!(t&&f&&n)}o(S,"SatisfiesBidiRule");export{C as HasBidiChars,A as HasRightToLeftCharacters,S as SatisfiesBidiRule};
@@ -0,0 +1 @@
1
+ var d=Object.defineProperty;var a=(t,e)=>d(t,"name",{value:e,configurable:!0});import*as O from"../pattern/pattern.js";const f=36,A=1,E=26,w=38,M=700,P=72,p=128;function N(){throw null}a(N,"ThrowDontCare");function U(t){return t.toLowerCase().startsWith("xn--")}a(U,"IsAcePrefixed");function _(t,e,x){t=x?Math.floor(t/M):t>>1,t+=Math.floor(t/e);let o=0;for(;t>(f-A)*E>>1;)t=Math.floor(t/(f-A)),o+=f;return o+Math.floor((f-A+1)*t/(t+w))}a(_,"Adapt");function Y(t){const e=[];let x=p,o=0,I=P;const r=t.lastIndexOf("-");if(r>0)for(let c=0;c<r;c++){const i=t.charCodeAt(c);i>=128&&N(),e.push(i)}let l=r<0?0:r+1;for(;l<t.length;){const c=o;let i=1,s=f;for(;;){l>=t.length&&N();const n=t.charCodeAt(l++);let C;n>=97&&n<=122?C=n-97:n>=48&&n<=57?C=n-48+26:N(),o+=C*i;const u=s<=I?A:s>=I+E?E:s-I;if(C<u)break;i*=f-u,s+=f}const h=e.length+1;I=_(o-c,h,c===0),x+=Math.floor(o/h),o%=h,e.splice(o,0,x),o++}return String.fromCodePoint(...e)}a(Y,"Decode");function g(t){return t<26?String.fromCharCode(t+97):String.fromCharCode(t-26+48)}a(g,"DigitToChar");const m=new RegExp(O.RE_NON_ASCII.source,"gu");function b(t){const e=t.replace(m,""),x=e.length,o=x>0?[e,"-"]:[],I=Array.from(t,s=>s.codePointAt(0));let r=p,l=0,c=P,i=x;for(;i<I.length;){let s=1/0;for(const h of I)h>=r&&h<s&&(s=h);l+=(s-r)*(i+1),r=s;for(const h of I)if(h<r&&l++,h===r){let n=l;for(let C=f;;C+=f){const u=C<=c?A:C>=c+E?E:C-c;if(n<u)break;const D=u+(n-u)%(f-u);o.push(g(D)),n=Math.floor((n-u)/(f-u))}o.push(g(n)),c=_(l,i+1,i===x),l=0,i++}l++,r++}return o.join("")}a(b,"Encode");export{Y as Decode,b as Encode,U as IsAcePrefixed};
@@ -0,0 +1 @@
1
+ var r=Object.defineProperty;var t=(n,e)=>r(n,"name",{value:e,configurable:!0});import*as i from"./label/ascii.js";import*as s from"./label/puny.js";function o(n){return n.length>0&&n.length<=63}t(o,"IsValidLabelLength");function f(n){return o(n)&&(s.IsPunyLabel(n)||i.IsAsciiLabel(n))}t(f,"IsLabel");function h(n){return n.length===0||n.length>253||n.charCodeAt(n.length-1)===46?!1:n.split(".").every(e=>f(e))}t(h,"IsHostname");export{h as IsHostname};
@@ -0,0 +1 @@
1
+ var u=Object.defineProperty;var r=(e,n)=>u(e,"name",{value:n,configurable:!0});import*as o from"./format/bidi.js";import*as a from"./label/puny.js";import*as f from"./label/unicode.js";function l(e){return e.length>0&&e.length<=63}r(l,"IsValidLabelLength");function c(e){return l(e)&&(a.IsPunyLabel(e)||f.IsUnicodeLabel(e))}r(c,"IsLabel");function d(e){return e.replace(/[\uff01-\uff5e]/g,n=>String.fromCharCode(n.charCodeAt(0)-65248)).normalize("NFC").replace(/[\u00ad\u034f\u180b-\u180d\u200b\ufe00-\ufe0f\u{e0100}-\u{e01ef}]/gu,"").replace(/[\u002E\u3002\uFF0E\uFF61]/g,".")}r(d,"NormalizeHostname");function h(e){if(e.length===0||e.includes(" "))return!1;const n=d(e);if(n.length>253)return!1;const i=n.split("."),s=i.some(t=>o.HasBidiChars(t));return i.every(t=>c(t)&&(!s||o.SatisfiesBidiRule(t)))}r(h,"IsIdnHostname");export{h as IsIdnHostname};
@@ -0,0 +1 @@
1
+ export*from"./hostname.js";export*from"./idn-hostname.js";
@@ -0,0 +1 @@
1
+ var r=Object.defineProperty;var _=(t,R)=>r(t,"name",{value:R,configurable:!0});import*as E from"../pattern/pattern.js";function e(t){return E.RE_RULE_HYPHEN_PLACEMENT.test(t)&&E.RE_RULE_NOT_RESERVED_ACE.test(t)&&E.RE_ASCII_LDH.test(t)}_(e,"IsAsciiLabel");export{e as IsAsciiLabel};
@@ -0,0 +1 @@
1
+ var n=Object.defineProperty;var o=(e,r)=>n(e,"name",{value:r,configurable:!0});import*as s from"../format/puny.js";import*as a from"../pattern/pattern.js";import*as f from"./unicode.js";function i(e){if(!s.IsAcePrefixed(e))return!1;try{const r=e.slice(4).toLowerCase();if(r.lastIndexOf("-")===0)return!1;const t=s.Decode(r);return a.RE_NON_ASCII.test(t)?f.IsUnicodeLabel(t):!1}catch{return!1}}o(i,"IsPunyLabel");export{i as IsPunyLabel};
@@ -0,0 +1 @@
1
+ var l=Object.defineProperty;var f=(e,r)=>l(e,"name",{value:r,configurable:!0});import*as R from"../format/bidi.js";import*as _ from"../format/puny.js";import*as s from"../pattern/pattern.js";function x(e){return s.RE_NON_ASCII.test(e)&&_.Encode(e).length+4>63}f(x,"ExceedsMaxALabelLength");function I(e){return e[0]==="-"||e[e.length-1]==="-"?!0:e.slice(2).join("").startsWith("--")}f(I,"HasInvalidHyphens");function b(e){if(x(e)||R.HasRightToLeftCharacters(e)&&!R.SatisfiesBidiRule(e))return!1;const r=[...e],a=r.map(t=>t.codePointAt(0)),u=a.length;if(I(r)||s.RE_COMBINING_MARK.test(r[0]))return!1;let o=!1;for(let t=0;t<u;t++){const E=a[t],i=r[t];if(s.RE_RFC5892_DISALLOWED.test(i)||!s.RE_PERMITTED_CATEGORY.test(i))return!1;s.RE_SCRIPT_JAPANESE.test(i)&&(o=!0);const n=a[t-1],c=a[t+1];switch(E){case 183:if(n!==108||c!==108)return!1;break;case 885:if(!c||!s.RE_SCRIPT_GREEK.test(r[t+1]))return!1;break;case 1523:case 1524:if(!n||!s.RE_SCRIPT_HEBREW.test(r[t-1]))return!1;break;case 8204:if(!n||n<128&&!s.RE_VIRAMA.test(r[t-1]))return!1;break;case 8205:if(!n||!s.RE_VIRAMA.test(r[t-1]))return!1;break;case 12539:break}}return!(e.includes("\u30FB")&&!o)}f(b,"IsUnicodeLabel");export{b as IsUnicodeLabel};
@@ -0,0 +1 @@
1
+ const n=/^(?!-).*(?<!-)$/,A=/^(?!..--)/,s=/^[a-zA-Z0-9-]*$/,x=new RegExp("^\\p{ASCII}*$","u"),S=/[^\p{ASCII}]/u,C=/[\u{d800}-\u{dbff}]/u,N=/[\u{1f1e6}-\u{1f1ff}]/u,T=/[\u{fe00}-\u{fe0f}]/u,a=/\u{200d}/u,E=/[0-9]/,d=/[\u{0660}-\u{0669}]/u,R=/[\u{06f0}-\u{06f9}]/u,t=/[\u{002e}\u{002c}\u{003a}\u{002f}]/u,_=/[\u{002d}\u{002b}]/u,o=new RegExp("\\p{Mn}","u"),p=new RegExp("\\p{Mc}","u"),f=new RegExp("\\p{Me}","u"),O=/[\p{Mn}\p{Mc}\p{Me}]/u,c=new RegExp("\\p{L}","u"),I=new RegExp("\\p{Nd}","u"),M=new RegExp("\\p{Script=Greek}","u"),b=new RegExp("\\p{Script=Hebrew}","u"),P=/[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}]/u,i=/[\p{Script=Arabic}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Mandaic}]/u,D=/[\u{094d}\u{09cd}\u{0a4d}\u{0acd}\u{0b4d}\u{0bcd}\u{0c4d}\u{0ccd}\u{0d3b}\u{0d3c}\u{0d4d}\u{0dca}\u{1b44}\u{1baa}\u{1bab}\u{a9c0}\u{11046}\u{1107f}\u{110b9}\u{11133}\u{11134}\u{111c0}\u{11235}\u{1134d}\u{11442}\u{114c2}\u{115bf}\u{1163f}\u{116b6}\u{11c3f}\u{11d44}\u{11d45}]/u,G=/[\u{0640}\u{07fa}\u{302e}\u{302f}\u{3031}\u{3032}\u{3033}\u{3034}\u{3035}\u{303b}]/u,e=/[\u{00b7}\u{0375}\u{05f3}\u{05f4}\u{200c}\u{200d}\u{30fb}]/u,r=/[\u{00df}\u{03c2}\u{06fd}\u{06fe}\u{0f0b}\u{3007}]/u,L=new RegExp([E,R].map(u=>u.source).join("|"),"u"),H=new RegExp([c,_,t,I,o,p,e,r].map(u=>u.source).join("|"),"u");export{d as RE_ARABIC_INDIC_DIGIT,x as RE_ASCII,E as RE_ASCII_DIGIT,s as RE_ASCII_LDH,O as RE_COMBINING_MARK,t as RE_COMMON_SEPARATOR,e as RE_CONTEXTO_EXCEPTIONS,L as RE_EUROPEAN_NUMBER,_ as RE_EUROPEAN_SEPARATOR,R as RE_EXT_ARABIC_INDIC_DIGIT,C as RE_HIGH_SURROGATE,c as RE_LETTER,f as RE_MARK_ENCLOSING,o as RE_MARK_NONSPACING,p as RE_MARK_SPACING_COMBINING,S as RE_NON_ASCII,I as RE_NUMBER_DECIMAL,H as RE_PERMITTED_CATEGORY,r as RE_PVALID_EXCEPTIONS,N as RE_REGIONAL_INDICATOR,G as RE_RFC5892_DISALLOWED,n as RE_RULE_HYPHEN_PLACEMENT,A as RE_RULE_NOT_RESERVED_ACE,i as RE_SCRIPT_ARABIC_LETTER,M as RE_SCRIPT_GREEK,b as RE_SCRIPT_HEBREW,P as RE_SCRIPT_JAPANESE,T as RE_VARIATION_SELECTOR,D as RE_VIRAMA,a as RE_ZERO_WIDTH_JOINER};
@@ -0,0 +1 @@
1
+ var e=Object.defineProperty;var t=(d,n)=>e(d,"name",{value:n,configurable:!0});const o=/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;function s(d){return o.test(d)}t(s,"IsIPv4");export{s as IsIPv4};
@@ -0,0 +1 @@
1
+ var t=Object.defineProperty;var a=(f,d)=>t(f,"name",{value:d,configurable:!0});const n=/^(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:)?[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)$/i;function o(f){return n.test(f)}a(o,"IsIPv6");export{o as IsIPv6};
@@ -0,0 +1 @@
1
+ var e=Object.defineProperty;var n=(t,r)=>e(t,"name",{value:r,configurable:!0});const o=2048,c=/\[[vV][0-9a-fA-F]+\.[^\]]+\]/,a=/[\x00-\x20<>^`{|}\\]/,s=/%(?![0-9a-fA-F]{2})/;function u(t){return t.length<2048?t.replace(c,"[::1]"):t}n(u,"NarrowIpvFuture");function I(t){return a.test(t)||s.test(t)?!1:URL.canParse(u(t))}n(I,"IsIri");export{I as IsIri};
@@ -0,0 +1 @@
1
+ var n=Object.defineProperty;var t=(e,r)=>n(e,"name",{value:r,configurable:!0});const a=/[\x00-\x20\x7F\\]|%(?![0-9a-fA-F]{2})/,c=/^[a-zA-Z][a-zA-Z0-9+\-.]*\/\//;function o(e){return!a.test(e)&&!c.test(e)&&URL.canParse(e,"http://example.com")}t(o,"IsIriReference");export{o as IsIriReference};
@@ -0,0 +1 @@
1
+ var e=Object.defineProperty;var t=(n,o)=>e(n,"name",{value:o,configurable:!0});const r=/^(?:\/(?:[^~/]|~0|~1)*)*$/;function i(n){return r.test(n)}t(i,"IsJsonPointer");export{i as IsJsonPointer};
@@ -0,0 +1 @@
1
+ var e=Object.defineProperty;var t=(n,r)=>e(n,"name",{value:r,configurable:!0});const o=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;function s(n){return o.test(n)}t(s,"IsJsonPointerUriFragment");export{s as IsJsonPointerUriFragment};
@@ -0,0 +1 @@
1
+ var n=Object.defineProperty;var r=(e,t)=>n(e,"name",{value:t,configurable:!0});function c(e){try{return new RegExp(e,"u"),!0}catch{return!1}}r(c,"IsRegex");export{c as IsRegex};
@@ -0,0 +1 @@
1
+ var o=Object.defineProperty;var e=(t,n)=>o(t,"name",{value:n,configurable:!0});const i=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;function s(t){return i.test(t)}e(s,"IsRelativeJsonPointer");export{s as IsRelativeJsonPointer};
@@ -0,0 +1 @@
1
+ var l=Object.defineProperty;var o=(n,e)=>l(n,"name",{value:e,configurable:!0});const z=/^(\d\d):(\d\d):(\d\d)(?:\.\d+)?(?:([Zz])|([+-])(\d\d):(\d\d))?$/;function h(n,e=!0){const t=z.exec(n);if(!t||e&&!t[4]&&!t[5])return!1;const s=+t[1],c=+t[2],r=+t[3];if(s>23||c>59||r>60)return!1;if(t[5]){const u=+t[6],a=+t[7];if(u>23||a>59)return!1}if(r<60)return!0;const i=t[5]==="-"?-1:1,d=+(t[6]||0),f=+(t[7]||0);return((s*60+c-i*(d*60+f))%1440+1440)%1440===1439}o(h,"IsTime");export{h as IsTime};
@@ -0,0 +1 @@
1
+ var z=Object.defineProperty;var a=(d,f)=>z(d,"name",{value:f,configurable:!0});const $=/^[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function t(d){return $.test(d)}a(t,"IsUri");export{t as IsUri};
@@ -0,0 +1 @@
1
+ var z=Object.defineProperty;var a=(d,f)=>z(d,"name",{value:f,configurable:!0});const $=/^(?:[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?)(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function e(d){return $.test(d)}a(e,"IsUriReference");export{e as IsUriReference};
@@ -0,0 +1 @@
1
+ var f=Object.defineProperty;var t=(a,e)=>f(a,"name",{value:e,configurable:!0});const r=/^(?:(?:[^\x00-\x20"<>%\\^`{|}\x7f]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?)*\})*$/i;function n(a){return r.test(a)}t(n,"IsUriTemplate");export{n as IsUriTemplate};
@@ -0,0 +1 @@
1
+ var t=Object.defineProperty;var n=(r,e)=>t(r,"name",{value:e,configurable:!0});function c(r){return URL.canParse(r)}n(c,"IsUrl");export{c as IsUrl};
@@ -0,0 +1 @@
1
+ var n=Object.defineProperty;var f=(t,i)=>n(t,"name",{value:i,configurable:!0});const u=/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;function e(t){return u.test(t)}f(e,"IsUuid");export{e as IsUuid};
@@ -0,0 +1,4 @@
1
+ export { type Annotations, arr, type BigintBounds, bigint, bool, bytes, int, type LengthBounds, lit, map, type NumberBounds, nul, nullable, num, Optional, obj, oneOf, opt, type Properties, recursive, type Schema, type Static, type StaticObject, str, tuple, union, unknown, unsafe, } from "./builders.ts";
2
+ export { deepEqual as equal } from "./checks.ts";
3
+ export type { Check, CompileOptions, FormatCheck, JsonSchema, ParseResult, ValidationError } from "./types.ts";
4
+ export { CoercingValidator, compile, Validator } from "./validator.ts";
@@ -0,0 +1 @@
1
+ import{arr as n,bigint as r,bool as l,bytes as t,int as a,lit as i,map as u,nul as p,nullable as m,num as b,Optional as f,obj as s,oneOf as c,opt as d,recursive as x,str as g,tuple as q,union as O,unknown as V,unsafe as j}from"./builders.js";import{deepEqual as v}from"./checks.js";import{CoercingValidator as y,compile as C,Validator as E}from"./validator.js";export{y as CoercingValidator,f as Optional,E as Validator,n as arr,r as bigint,l as bool,t as bytes,C as compile,v as equal,a as int,i as lit,u as map,p as nul,m as nullable,b as num,s as obj,c as oneOf,d as opt,x as recursive,g as str,q as tuple,O as union,V as unknown,j as unsafe};
@@ -0,0 +1 @@
1
+ var l=Object.defineProperty;var a=(i,e)=>l(i,"name",{value:e,configurable:!0});const d="https://json-schema.invalid/root.json";class m{static{a(this,"Resolver")}draft;rootBase=d;baseOf=new Map;dynamicAnchors=new Map;root;options;registry=new Map;rejectUnresolved;unresolved=new Set;resources=new Map;anchors=new Map;indexed=!1;constructor(e,t){this.draft=t.draft==="7"?"7":"2020-12",this.root=e,this.options=t,this.rejectUnresolved=t.unresolvedRefs==="reject"}baseFor(e,t){let r=this.baseOf.get(e);if(r!==void 0)return r;const s=e.$id;return typeof s!="string"?t:!this.indexed&&(this.ensureIndexed(),r=this.baseOf.get(e),r!==void 0)?r:this.draft==="7"&&(typeof e.$ref=="string"||s.startsWith("#"))?t:f(c(s,t))}ensureIndexed(){if(!this.indexed){this.indexed=!0;for(const[e,t]of Object.entries(this.options.schemas??{}))this.registry.set(f(c(e,d)),t);this.resources.set(d,this.root),this.index(this.root,d)}}resolve(e,t){if(this.ensureIndexed(),!this.rejectUnresolved)return this.find(e,t);try{return this.find(e,t)}catch{return this.unresolved.add(c(e,t)),{node:!1,base:t}}}isUnresolved(e,t){return this.unresolved.has(c(e,t))}find(e,t){const r=c(e,t),s=f(r),n=r.length>s.length?decodeURIComponent(r.slice(s.length+1)):"",o=this.resources.has(s)?this.resources.get(s):this.load(s);if(o===void 0)throw new Error(`Unresolved $ref ${e} (no schema registered for ${s})`);if(n==="")return{node:o,base:s};if(n.startsWith("/"))return this.pointer(o,s,n);const h=this.anchors.get(`${s}#${n}`);if(h===void 0)throw new Error(`Unresolved $ref ${e} (no anchor ${n} in ${s})`);return{node:h,base:this.baseOf.get(h)??s}}isResource(e,t){return this.ensureIndexed(),this.resources.get(t)===e}index(e,t){if(!u(e)||this.baseOf.has(e))return;let r=t;const s=this.draft==="7"&&typeof e.$ref=="string";if(!s&&typeof e.$id=="string")if(this.draft==="7"&&e.$id.startsWith("#"))this.anchors.set(f(r)+e.$id,e);else{const n=c(e.$id,r);r=f(n),this.resources.set(r,e),n.length>r.length+1&&this.anchors.set(n,e)}if(this.baseOf.set(e,r),!s){this.draft!=="7"&&(typeof e.$anchor=="string"&&this.anchors.set(`${r}#${e.$anchor}`,e),typeof e.$dynamicAnchor=="string"&&(this.anchors.set(`${r}#${e.$dynamicAnchor}`,e),this.dynamicAnchors.set(`${r}#${e.$dynamicAnchor}`,e)));for(const n of p)this.index(e[n],r);for(const n of y){const o=e[n];if(u(o))for(const h of Object.keys(o))this.index(o[h],r)}for(const n of $){const o=e[n];if(Array.isArray(o))for(const h of o)this.index(h,r)}}}load(e){const t=this.registry.get(e);if(t!==void 0)return this.resources.set(e,t),this.index(t,e),t}pointer(e,t,r){let s=e,n=t;for(const o of r.split("/").slice(1)){const h=o.replace(/~1/g,"/").replace(/~0/g,"~");if(s=typeof s=="object"&&s!==null&&Object.hasOwn(s,h)?s[h]:void 0,s===void 0)throw new Error(`Unresolved $ref #${r} in ${t}`);typeof s=="object"&&s!==null&&(n=this.baseOf.get(s)??n)}return{node:s,base:n}}}const p=["additionalProperties","propertyNames","contains","not","if","then","else","unevaluatedProperties","unevaluatedItems","additionalItems","contentSchema","items"],y=["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"],$=["allOf","anyOf","oneOf","prefixItems","items"];function u(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}a(u,"isSchemaObject");function c(i,e){try{return new URL(i,e).href}catch{return i.startsWith("#")?f(e)+i:i}}a(c,"resolveUri");function f(i){const e=i.indexOf("#");return e<0?i:i.slice(0,e)}a(f,"documentOf");export{d as DEFAULT_BASE,m as Resolver,f as documentOf,u as isSchemaObject,c as resolveUri};
@@ -0,0 +1 @@
1
+ var g=Object.defineProperty;var i=(e,r)=>g(e,"name",{value:r,configurable:!0});function a(e){const r=t.get(e)?.deref();if(r!==void 0)return r;let n;try{n=new RegExp(e,"u")}catch{n=new RegExp(e)}return t.set(e,new WeakRef(n)),d.register(n,e),n}i(a,"sharedRegex");const t=new Map,d=new FinalizationRegistry(e=>{t.get(e)?.deref()===void 0&&t.delete(e)});function x(){return t.size}i(x,"sharedRegexCount");export{a as sharedRegex,x as sharedRegexCount};
@@ -0,0 +1,54 @@
1
+ import type { Static } from "./builders.ts";
2
+ export type TypeBoxStatic<S> = S extends {
3
+ readonly "~kind": infer K;
4
+ } ? KindStatic<S, K> : S extends {
5
+ readonly "~unsafe": infer T;
6
+ } ? T : unknown;
7
+ interface Primitives {
8
+ String: string;
9
+ Number: number;
10
+ Integer: number;
11
+ Boolean: boolean;
12
+ Null: null;
13
+ BigInt: bigint;
14
+ Undefined: undefined;
15
+ Unknown: unknown;
16
+ Any: any;
17
+ }
18
+ type KindStatic<S, K> = K extends keyof Primitives ? Primitives[K] : K extends "Literal" ? S extends {
19
+ readonly const: infer V;
20
+ } ? V : unknown : K extends "Array" ? S extends {
21
+ readonly items: infer I;
22
+ } ? Static<I>[] : unknown : K extends "Object" ? S extends {
23
+ readonly properties: infer P;
24
+ } ? ObjectStatic<P> : unknown : K extends "Union" ? S extends {
25
+ readonly anyOf: readonly (infer B)[];
26
+ } ? Static<B> : unknown : K extends "Record" ? S extends {
27
+ readonly patternProperties: infer P;
28
+ } ? Record<RecordKey<keyof P>, Static<P[keyof P]>> : unknown : K extends "Enum" ? S extends {
29
+ readonly enum: readonly (infer V)[];
30
+ } ? V : unknown : K extends "Tuple" ? S extends {
31
+ readonly items: infer I extends readonly unknown[];
32
+ } ? {
33
+ -readonly [N in keyof I]: Static<I[N]>;
34
+ } : unknown : unknown;
35
+ type Optional = {
36
+ readonly "~optional": true;
37
+ };
38
+ type Readonly = {
39
+ readonly "~readonly": true;
40
+ };
41
+ type ObjectStatic<P> = keyof P extends never ? object : Simplify<{
42
+ -readonly [K in keyof P as P[K] extends Optional | Readonly ? never : K]: Static<P[K]>;
43
+ } & {
44
+ -readonly [K in keyof P as P[K] extends Optional ? (P[K] extends Readonly ? never : K) : never]?: Static<P[K]>;
45
+ } & {
46
+ readonly [K in keyof P as P[K] extends Readonly ? (P[K] extends Optional ? never : K) : never]: Static<P[K]>;
47
+ } & {
48
+ readonly [K in keyof P as P[K] extends Optional ? (P[K] extends Readonly ? K : never) : never]?: Static<P[K]>;
49
+ }>;
50
+ type Simplify<T> = {
51
+ [K in keyof T]: T[K];
52
+ } & {};
53
+ type RecordKey<Pattern> = Pattern extends "^-?(?:0|[1-9][0-9]*)$" | "^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?$" ? number : string;
54
+ export {};
@@ -0,0 +1,25 @@
1
+ export type JsonSchema = boolean | object;
2
+ export type FormatCheck = (value: string) => boolean;
3
+ export interface CompileOptions {
4
+ readonly draft?: "2020-12" | "7";
5
+ readonly formats?: Readonly<Record<string, FormatCheck>>;
6
+ readonly schemas?: Readonly<Record<string, JsonSchema>>;
7
+ readonly coerce?: boolean;
8
+ readonly unresolvedRefs?: "throw" | "reject";
9
+ }
10
+ export type ParseResult<T> = {
11
+ readonly ok: true;
12
+ readonly value: T;
13
+ } | {
14
+ readonly ok: false;
15
+ readonly errors: ValidationError[];
16
+ };
17
+ export interface ValidationError {
18
+ readonly path: string;
19
+ readonly keyword: string;
20
+ readonly message: string;
21
+ }
22
+ export type SchemaObject = {
23
+ readonly [keyword: string]: unknown;
24
+ };
25
+ export type Check = (value: unknown) => boolean;
@@ -0,0 +1,20 @@
1
+ import type { Static } from "./builders.ts";
2
+ import type { Check, CompileOptions, JsonSchema, ParseResult, ValidationError } from "./types.ts";
3
+ export declare function compile<S extends JsonSchema>(schema: S, options: CompileOptions & {
4
+ readonly coerce: true;
5
+ }): CoercingValidator<Static<S>>;
6
+ export declare function compile<S extends JsonSchema>(schema: S, options?: CompileOptions): Validator<Static<S>>;
7
+ export declare class Validator<T = unknown> {
8
+ readonly check: (value: unknown) => value is T;
9
+ protected readonly schema: JsonSchema;
10
+ protected readonly options: CompileOptions;
11
+ private explainer;
12
+ constructor(schema: JsonSchema, options: CompileOptions, check: Check);
13
+ errors(value: unknown): ValidationError[];
14
+ validate(value: unknown): ParseResult<T>;
15
+ }
16
+ export declare class CoercingValidator<T = unknown> extends Validator<T> {
17
+ private coercer;
18
+ coerce(value: unknown): unknown;
19
+ parse(value: unknown): ParseResult<T>;
20
+ }
@@ -0,0 +1 @@
1
+ var h=Object.defineProperty;var c=(r,e)=>h(r,"name",{value:e,configurable:!0});import{Coercer as a}from"./coerce.js";import{Compiler as s,RESTART as p}from"./compiler.js";import{Explainer as u}from"./explain.js";function C(r,e=l){const t=m(r,e);return e.coerce===!0?new f(r,e,t):new n(r,e,t)}c(C,"compile");const l=Object.freeze({});class n{static{c(this,"Validator")}check;schema;options;explainer=void 0;constructor(e,t,o){this.check=o,this.schema=e,this.options=t}errors(e){return this.check(e)?[]:(this.explainer??=new u(i(this.schema,this.options),this.schema),this.explainer.errors(e))}validate(e){return this.check(e)?{ok:!0,value:e}:{ok:!1,errors:this.errors(e)}}}class f extends n{static{c(this,"CoercingValidator")}coercer=void 0;coerce(e){return this.coercer??=new a(i(this.schema,this.options),this.schema),this.coercer.coerce(e)}parse(e){return this.validate(this.coerce(e))}}function m(r,e){return i(r,e).root()}c(m,"compileCheck");function i(r,e){const t=new s(r,e,!1);try{return t.root(),t}catch(o){if(o!==p)throw o;return new s(r,e,!0)}}c(i,"compiler");export{f as CoercingValidator,n as Validator,C as compile};
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@earendil-works/pi-schema",
3
+ "version": "1.0.51",
4
+ "description": "JSON Schema validation without eval: drafts 2020-12 and 7, compiled into plain closures",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "source": "./src/index.ts",
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./formats": {
15
+ "source": "./src/formats/index.ts",
16
+ "types": "./dist/formats/index.d.ts",
17
+ "import": "./dist/formats/index.js"
18
+ }
19
+ },
20
+ "sideEffects": false,
21
+ "files": [
22
+ "dist",
23
+ "README.md",
24
+ "CHANGELOG.md",
25
+ "THIRD_PARTY_NOTICES"
26
+ ],
27
+ "keywords": [
28
+ "json-schema",
29
+ "validation",
30
+ "validator",
31
+ "csp"
32
+ ],
33
+ "author": "Earendil Works",
34
+ "license": "MIT",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/earendil-works/pi.git",
38
+ "directory": "packages/schema"
39
+ },
40
+ "engines": {
41
+ "node": ">=22.19.0"
42
+ }
43
+ }
@@ -259,4 +259,4 @@ export type TypedSpanStarter<Schemas extends TelemetrySchemaTuple> = UnionToInte
259
259
  }[SpanNameInSchemas<Schemas>]>;
260
260
  export declare function createTypedSpanStarter<const Schemas extends TelemetrySchemaTuple>(telemetryContext: TelemetryContext, _schemas: Schemas & UniqueTelemetrySchemas<Schemas>): TypedSpanStarter<Schemas>;
261
261
  export type { RecordedTelemetryEvent, RecordedTelemetryLink, RecordedTelemetryMeasurement, RecordedTelemetrySpan, } from "./memory.ts";
262
- export { InMemoryTelemetryContext } from "./memory.ts";
262
+ export { InMemoryTelemetryContext, telemetryNow } from "./memory.ts";
@@ -1 +1 @@
1
- var E=Object.defineProperty;var t=(e,r)=>E(e,"name",{value:r,configurable:!0});import{createTypedMetrics as _}from"./metrics.js";import{NOOP_TELEMETRY_CONTEXT as s,NOOP_TELEMETRY_METRICS as u,NOOP_TELEMETRY_PROPAGATION as x}from"./noop.js";function O(e){return e}t(O,"defineTelemetrySchema");function T(e){return t((o,a,p)=>e.startSpan({name:o,attributes:a},n=>p(n,T(n))),"startSpan")}t(T,"bindTypedSpanStarter");function S(e,r){return T(e)}t(S,"createTypedSpanStarter");import{InMemoryTelemetryContext as M}from"./memory.js";export{M as InMemoryTelemetryContext,s as NOOP_TELEMETRY_CONTEXT,u as NOOP_TELEMETRY_METRICS,x as NOOP_TELEMETRY_PROPAGATION,_ as createTypedMetrics,S as createTypedSpanStarter,O as defineTelemetrySchema};
1
+ var E=Object.defineProperty;var t=(e,r)=>E(e,"name",{value:r,configurable:!0});import{createTypedMetrics as y}from"./metrics.js";import{NOOP_TELEMETRY_CONTEXT as i,NOOP_TELEMETRY_METRICS as s,NOOP_TELEMETRY_PROPAGATION as u}from"./noop.js";function m(e){return e}t(m,"defineTelemetrySchema");function o(e){return t((T,a,p)=>e.startSpan({name:T,attributes:a},n=>p(n,o(n))),"startSpan")}t(o,"bindTypedSpanStarter");function O(e,r){return o(e)}t(O,"createTypedSpanStarter");import{InMemoryTelemetryContext as M,telemetryNow as N}from"./memory.js";export{M as InMemoryTelemetryContext,i as NOOP_TELEMETRY_CONTEXT,s as NOOP_TELEMETRY_METRICS,u as NOOP_TELEMETRY_PROPAGATION,y as createTypedMetrics,O as createTypedSpanStarter,m as defineTelemetrySchema,N as telemetryNow};
@@ -31,6 +31,7 @@ export interface RecordedTelemetryMeasurement {
31
31
  readonly attributes: Readonly<SpanAttributes>;
32
32
  readonly context: Readonly<TelemetryCarrier> | null;
33
33
  }
34
+ export declare function telemetryNow(): number;
34
35
  export declare class InMemoryTelemetryContext implements TelemetryContext, TelemetryPropagation, TelemetryMetrics, TelemetryStore {
35
36
  readonly metrics: TelemetryMetrics;
36
37
  readonly propagation: TelemetryPropagation;
@@ -1 +1 @@
1
- var y=Object.defineProperty;var u=(r,t)=>y(r,"name",{value:t,configurable:!0});import{NOOP_TELEMETRY_CONTEXT as k}from"./noop.js";function x(r){return`${r["pi-memory-scope"]}:${r["pi-memory-span"]}`}u(x,"carrierId");const f=new WeakMap;function p(r){return Object.fromEntries(Object.entries(r??{}).filter(([,t])=>t!==void 0).map(([t,e])=>[t,Array.isArray(e)?[...e]:e]))}u(p,"copyAttributes");function g(r){const t=f.get(r.context);return t?{context:{...t},attributes:p(r.attributes)}:void 0}u(g,"copyLink");function b(r){return r.status==="ok"?{status:"ok"}:r.error?{status:"error",error:{name:r.error.name,message:r.error.message}}:{status:"error"}}u(b,"copyStatus");function w(r,t,e){const s=e.name,n=p(e.attributes),o=[];for(const d of e.links??[]){const i=g(d);i&&o.push(i)}const a=r.nextSpanId++;return{startedMs:Date.now(),clock:performance.now(),id:a,parentId:t?.localId??null,context:{"pi-memory-scope":r.scope,"pi-memory-span":String(a),"pi-memory-trace":t?.context["pi-memory-trace"]??`${r.scope}:${a}`},parentContext:t?{...t.context}:null,links:o,name:s,attributes:n,events:[],status:{status:"ok"},explicitStatus:!1,settled:!1}}u(w,"createSpan");function S(r,t,e){return k.startSpan(t,s=>e({...s,metrics:r.metrics,propagation:r.propagation,startSpan:u((n,o)=>S(r,n,o),"startSpan")}))}u(S,"startInertSpan");async function M(r,t,e,s){if(t?.span?.settled)return S(r,e,s);const n=w(r,t,e);r.spans.push(n);const o={metrics:r.metrics,propagation:r.propagation,startSpan:u((a,d)=>M(r,{context:n.context,localId:n.id,span:n},a,d),"startSpan"),addLink(a){if(n.settled)return;const d=g(a);d&&n.links.push(d)},addEvent(a,d){n.settled||n.events.push({name:a,timeMs:performance.now()-n.clock,attributes:p(d)})},setAttributes(a){n.settled||(n.attributes={...n.attributes,...p(a)})},setStatus(a){n.settled||(n.status=b(a),n.explicitStatus=!0)}};f.set(o,n.context);try{return await s(o)}catch(a){throw n.explicitStatus||(n.status=a instanceof Error?{status:"error",error:{name:a.name,message:a.message}}:{status:"error"}),a}finally{n.settled=!0,n.endedMs=n.startedMs+performance.now()-n.clock,n.endSequence=r.nextEndSequence++}}u(M,"startInMemorySpan");function h(r,t,e,s){const n=s?.description,o=s?.unit,a=t==="histogram"&&s?.boundaries!==void 0?[...s.boundaries]:void 0,d={kind:t,name:e,...n===void 0?{}:{description:n},...o===void 0?{}:{unit:o},...a===void 0?{}:{boundaries:a}};return(i,c,m)=>{const l=m===void 0?void 0:f.get(m);r.measurements.push({intervalMs:Math.floor(Date.now()/1e4)*1e4,measurement:{...d,value:i,attributes:p(c),context:l?{...l}:null}})}}u(h,"createMeasurementRecorder");class O{static{u(this,"InMemoryTelemetryContext")}metrics=this;propagation=this;state={metrics:this,propagation:this,scope:crypto.randomUUID(),spans:[],measurements:[],nextSpanId:1,nextEndSequence:1};startSpan(t,e){return M(this.state,void 0,t,e)}inject(t){const e=f.get(t);return e?{...e}:void 0}extract(t){const e=t?.["pi-memory-scope"],s=t?.["pi-memory-span"],n=t?.["pi-memory-trace"];if(typeof e!="string"||typeof s!="string"||typeof n!="string")return this;const o={"pi-memory-scope":e,"pi-memory-span":s,"pi-memory-trace":n},a=e===this.state.scope?Number(s):null,d={metrics:this,propagation:this,startSpan:u((i,c)=>M(this.state,{context:o,localId:a},i,c),"startSpan")};return f.set(d,o),d}counter(t,e){return{add:h(this.state,"counter",t,e)}}upDownCounter(t,e){return{add:h(this.state,"upDownCounter",t,e)}}histogram(t,e){return{record:h(this.state,"histogram",t,e)}}storedSpans(){return this.state.spans.filter(t=>t.settled).map(t=>({id:x(t.context),traceId:t.context["pi-memory-trace"],...t.parentContext?{parentId:x(t.parentContext)}:{},name:t.name,startedMs:t.startedMs,endedMs:t.endedMs,attributes:p(t.attributes),events:t.events.map(e=>({name:e.name,timeMs:e.timeMs,attributes:p(e.attributes)})),links:t.links.map(e=>({traceId:e.context["pi-memory-trace"],spanId:x(e.context),attributes:p(e.attributes)})),status:b(t.status)})).sort((t,e)=>t.startedMs-e.startedMs||(t.id<e.id?-1:t.id>e.id?1:0))}async getTrace(t){const e=this.storedSpans().filter(s=>s.traceId===t);return e.length?{traceId:t,spans:e}:void 0}async findTraces(t={}){const e=t.limit??20,s=t.cursor===void 0?void 0:JSON.parse(t.cursor),n=new Map;for(const i of this.storedSpans()){let c=n.get(i.traceId);c||(c={traceId:i.traceId,spans:[]},n.set(i.traceId,c)),c.spans.push(i)}const o=[...n.values()].filter(i=>{const c=i.spans[0];return(t.name===void 0||c.name===t.name)&&(t.startMin===void 0||c.startedMs>=t.startMin)&&(t.startMax===void 0||c.startedMs<=t.startMax)&&(!s||c.startedMs<s[0]||c.startedMs===s[0]&&i.traceId>s[1])&&(!t.errors||i.spans.some(m=>m.status.status==="error"))&&(!t.attributes||i.spans.some(m=>Object.entries(t.attributes).every(([l,I])=>m.attributes[l]===I)))}).sort((i,c)=>c.spans[0].startedMs-i.spans[0].startedMs||(i.traceId<c.traceId?-1:i.traceId>c.traceId?1:0)),a=o.slice(0,e),d=a.at(-1);return{traces:a,...o.length>e?{cursor:JSON.stringify([d.spans[0].startedMs,d.traceId])}:{}}}async findMetrics(t){return this.state.measurements.filter(({intervalMs:e,measurement:s})=>s.name===t.name&&(t.startMin===void 0||e>=t.startMin)&&(t.startMax===void 0||e<=t.startMax)&&Object.entries(t.attributes??{}).every(([n,o])=>s.attributes[n]===o)).map(({intervalMs:e,measurement:s})=>({intervalMs:e,name:s.name,kind:s.kind,...s.unit===void 0?{}:{unit:s.unit},attributes:p(s.attributes),count:1,sum:s.value,min:s.value,max:s.value}))}getMetrics(){return this.state.measurements.map(({measurement:t})=>({...t,...t.boundaries===void 0?{}:{boundaries:[...t.boundaries]},attributes:p(t.attributes),context:t.context?{...t.context}:null}))}getSpans(){return this.state.spans.map(t=>({id:t.id,parentId:t.parentId,context:{...t.context},parentContext:t.parentContext?{...t.parentContext}:null,links:t.links.map(e=>({context:{...e.context},attributes:p(e.attributes)})),name:t.name,attributes:p(t.attributes),events:t.events.map(e=>({name:e.name,attributes:p(e.attributes)})),status:b(t.status),settled:t.settled,...t.endSequence===void 0?{}:{endSequence:t.endSequence}}))}}export{O as InMemoryTelemetryContext};
1
+ var w=Object.defineProperty;var u=(n,t)=>w(n,"name",{value:t,configurable:!0});import{NOOP_TELEMETRY_CONTEXT as C}from"./noop.js";function x(n){return`${n["pi-memory-scope"]}:${n["pi-memory-span"]}`}u(x,"carrierId");const E=10;let M=performance.timeOrigin;function O(){const n=performance.now(),t=Date.now();return Math.abs(M+n-t)>E&&(M=t-n),b(M+n)}u(O,"telemetryNow");function b(n){return Math.round(n*1e3)/1e3}u(b,"microseconds");const f=new WeakMap;function p(n){return Object.fromEntries(Object.entries(n??{}).filter(([,t])=>t!==void 0).map(([t,e])=>[t,Array.isArray(e)?[...e]:e]))}u(p,"copyAttributes");function I(n){const t=f.get(n.context);return t?{context:{...t},attributes:p(n.attributes)}:void 0}u(I,"copyLink");function h(n){return n.status==="ok"?{status:"ok"}:n.error?{status:"error",error:{name:n.error.name,message:n.error.message}}:{status:"error"}}u(h,"copyStatus");function v(n,t,e){const s=e.name,r=p(e.attributes),o=[];for(const d of e.links??[]){const i=I(d);i&&o.push(i)}const a=n.nextSpanId++;return{startedMs:O(),clock:performance.now(),id:a,parentId:t?.localId??null,context:{"pi-memory-scope":n.scope,"pi-memory-span":String(a),"pi-memory-trace":t?.context["pi-memory-trace"]??`${n.scope}:${a}`},parentContext:t?{...t.context}:null,links:o,name:s,attributes:r,events:[],status:{status:"ok"},explicitStatus:!1,settled:!1}}u(v,"createSpan");function y(n,t,e){return C.startSpan(t,s=>e({...s,metrics:n.metrics,propagation:n.propagation,startSpan:u((r,o)=>y(n,r,o),"startSpan")}))}u(y,"startInertSpan");async function g(n,t,e,s){if(t?.span?.settled)return y(n,e,s);const r=v(n,t,e);n.spans.push(r);const o={metrics:n.metrics,propagation:n.propagation,startSpan:u((a,d)=>g(n,{context:r.context,localId:r.id,span:r},a,d),"startSpan"),addLink(a){if(r.settled)return;const d=I(a);d&&r.links.push(d)},addEvent(a,d){r.settled||r.events.push({name:a,timeMs:b(performance.now()-r.clock),attributes:p(d)})},setAttributes(a){r.settled||(r.attributes={...r.attributes,...p(a)})},setStatus(a){r.settled||(r.status=h(a),r.explicitStatus=!0)}};f.set(o,r.context);try{return await s(o)}catch(a){throw r.explicitStatus||(r.status=a instanceof Error?{status:"error",error:{name:a.name,message:a.message}}:{status:"error"}),a}finally{r.settled=!0,r.endedMs=b(r.startedMs+performance.now()-r.clock),r.endSequence=n.nextEndSequence++}}u(g,"startInMemorySpan");function S(n,t,e,s){const r=s?.description,o=s?.unit,a=t==="histogram"&&s?.boundaries!==void 0?[...s.boundaries]:void 0,d={kind:t,name:e,...r===void 0?{}:{description:r},...o===void 0?{}:{unit:o},...a===void 0?{}:{boundaries:a}};return(i,c,m)=>{const l=m===void 0?void 0:f.get(m);n.measurements.push({intervalMs:Math.floor(Date.now()/1e4)*1e4,measurement:{...d,value:i,attributes:p(c),context:l?{...l}:null}})}}u(S,"createMeasurementRecorder");class j{static{u(this,"InMemoryTelemetryContext")}metrics=this;propagation=this;state={metrics:this,propagation:this,scope:crypto.randomUUID(),spans:[],measurements:[],nextSpanId:1,nextEndSequence:1};startSpan(t,e){return g(this.state,void 0,t,e)}inject(t){const e=f.get(t);return e?{...e}:void 0}extract(t){const e=t?.["pi-memory-scope"],s=t?.["pi-memory-span"],r=t?.["pi-memory-trace"];if(typeof e!="string"||typeof s!="string"||typeof r!="string")return this;const o={"pi-memory-scope":e,"pi-memory-span":s,"pi-memory-trace":r},a=e===this.state.scope?Number(s):null,d={metrics:this,propagation:this,startSpan:u((i,c)=>g(this.state,{context:o,localId:a},i,c),"startSpan")};return f.set(d,o),d}counter(t,e){return{add:S(this.state,"counter",t,e)}}upDownCounter(t,e){return{add:S(this.state,"upDownCounter",t,e)}}histogram(t,e){return{record:S(this.state,"histogram",t,e)}}storedSpans(){return this.state.spans.filter(t=>t.settled).map(t=>({id:x(t.context),traceId:t.context["pi-memory-trace"],...t.parentContext?{parentId:x(t.parentContext)}:{},name:t.name,startedMs:t.startedMs,endedMs:t.endedMs,attributes:p(t.attributes),events:t.events.map(e=>({name:e.name,timeMs:e.timeMs,attributes:p(e.attributes)})),links:t.links.map(e=>({traceId:e.context["pi-memory-trace"],spanId:x(e.context),attributes:p(e.attributes)})),status:h(t.status)})).sort((t,e)=>t.startedMs-e.startedMs||(t.id<e.id?-1:t.id>e.id?1:0))}async getTrace(t){const e=this.storedSpans().filter(s=>s.traceId===t);return e.length?{traceId:t,spans:e}:void 0}async findTraces(t={}){const e=t.limit??20,s=t.cursor===void 0?void 0:JSON.parse(t.cursor),r=new Map;for(const i of this.storedSpans()){let c=r.get(i.traceId);c||(c={traceId:i.traceId,spans:[]},r.set(i.traceId,c)),c.spans.push(i)}const o=[...r.values()].filter(i=>{const c=i.spans[0];return(t.name===void 0||c.name===t.name)&&(t.startMin===void 0||c.startedMs>=t.startMin)&&(t.startMax===void 0||c.startedMs<=t.startMax)&&(!s||c.startedMs<s[0]||c.startedMs===s[0]&&i.traceId>s[1])&&(!t.errors||i.spans.some(m=>m.status.status==="error"))&&(!t.attributes||i.spans.some(m=>Object.entries(t.attributes).every(([l,k])=>m.attributes[l]===k)))}).sort((i,c)=>c.spans[0].startedMs-i.spans[0].startedMs||(i.traceId<c.traceId?-1:i.traceId>c.traceId?1:0)),a=o.slice(0,e),d=a.at(-1);return{traces:a,...o.length>e?{cursor:JSON.stringify([d.spans[0].startedMs,d.traceId])}:{}}}async findMetrics(t){return this.state.measurements.filter(({intervalMs:e,measurement:s})=>s.name===t.name&&(t.startMin===void 0||e>=t.startMin)&&(t.startMax===void 0||e<=t.startMax)&&Object.entries(t.attributes??{}).every(([r,o])=>s.attributes[r]===o)).map(({intervalMs:e,measurement:s})=>({intervalMs:e,name:s.name,kind:s.kind,...s.unit===void 0?{}:{unit:s.unit},attributes:p(s.attributes),count:1,sum:s.value,min:s.value,max:s.value}))}getMetrics(){return this.state.measurements.map(({measurement:t})=>({...t,...t.boundaries===void 0?{}:{boundaries:[...t.boundaries]},attributes:p(t.attributes),context:t.context?{...t.context}:null}))}getSpans(){return this.state.spans.map(t=>({id:t.id,parentId:t.parentId,context:{...t.context},parentContext:t.parentContext?{...t.parentContext}:null,links:t.links.map(e=>({context:{...e.context},attributes:p(e.attributes)})),name:t.name,attributes:p(t.attributes),events:t.events.map(e=>({name:e.name,attributes:p(e.attributes)})),status:h(t.status),settled:t.settled,...t.endSequence===void 0?{}:{endSequence:t.endSequence}}))}}export{j as InMemoryTelemetryContext,O as telemetryNow};
@@ -1,2 +1,2 @@
1
- var h=Object.defineProperty;var c=(r,n)=>h(r,"name",{value:n,configurable:!0});function f(r={}){return Object.entries(r).map(([n,o])=>` ${n}=${JSON.stringify(o)}`).join("")}c(f,"formatAttributes");function m(r){const n=new Map(r.map(e=>[e.id,e])),o=[],d=new Map;for(const e of[...n.values()].sort((s,a)=>s.startedMs-a.startedMs))if(e.parentId===void 0||!n.has(e.parentId))o.push(e);else{const s=d.get(e.parentId);s===void 0?d.set(e.parentId,[e]):s.push(e)}const i=[],p=o.reverse().map(e=>({span:e,depth:0}));for(;p.length>0;){const{span:e,depth:s}=p.pop(),a=" ".repeat(s);let u="";e.status.status==="error"&&(u=" error",e.status.error!==void 0&&(u+=` ${e.status.error.name}: ${e.status.error.message}`)),i.push(`${a}${e.name}${f(e.attributes)} (${e.endedMs-e.startedMs}ms)${u}`);for(const t of e.events)i.push(`${a} \xB7 ${t.name}${f(t.attributes)} (+${t.timeMs}ms)`);for(const t of e.links)i.push(`${a} \u2192 link trace ${t.traceId} span ${t.spanId}${f(t.attributes)}`);const $=d.get(e.id)??[];for(let t=$.length-1;t>=0;t--)p.push({span:$[t],depth:s+1})}return i.join(`
2
- `)}c(m,"renderTrace");export{m as renderTrace};
1
+ var g=Object.defineProperty;var i=(n,s)=>g(n,"name",{value:s,configurable:!0});const M=/[\u0000-\u001f\u007f-\u009f]/g;function o(n){return n.replace(M,s=>`\\u${s.charCodeAt(0).toString(16).padStart(4,"0")}`)}i(o,"escaped");function l(n){return Math.round(n*1e3)/1e3}i(l,"microseconds");function $(n={}){return Object.entries(n).map(([s,d])=>` ${o(s)}=${JSON.stringify(d)}`).join("")}i($,"formatAttributes");function I(n){const s=new Map(n.map(t=>[t.id,t])),d=[],p=new Map;for(const t of[...s.values()].sort((r,a)=>r.startedMs-a.startedMs))if(t.parentId===void 0||!s.has(t.parentId))d.push(t);else{const r=p.get(t.parentId);r===void 0?p.set(t.parentId,[t]):r.push(t)}const u=[],c=d.reverse().map(t=>({span:t,depth:0}));for(;c.length>0;){const{span:t,depth:r}=c.pop(),a=" ".repeat(r);let f="";t.status.status==="error"&&(f=" error",t.status.error!==void 0&&(f+=` ${o(t.status.error.name)}: ${o(t.status.error.message)}`)),u.push(`${a}${o(t.name)}${$(t.attributes)} (${l(t.endedMs-t.startedMs)}ms)${f}`);for(const e of t.events)u.push(`${a} \xB7 ${o(e.name)}${$(e.attributes)} (+${l(e.timeMs)}ms)`);for(const e of t.links){const m=`trace ${o(e.traceId)} span ${o(e.spanId)}`;u.push(`${a} \u2192 link ${m}${$(e.attributes)}`)}const h=p.get(t.id)??[];for(let e=h.length-1;e>=0;e--)c.push({span:h[e],depth:r+1})}return u.join(`
2
+ `)}i(I,"renderTrace");export{I as renderTrace};
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@earendil-works/pi-telemetry",
3
- "version": "1.0.49",
3
+ "version": "1.0.51",
4
4
  "description": "Vendor-neutral telemetry contracts and typed schema utilities for pi",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
+ "source": "./src/index.ts",
10
11
  "types": "./dist/index.d.ts",
11
12
  "import": "./dist/index.js"
12
13
  },
@@ -16,6 +17,7 @@
16
17
  "import": "./dist/render.js"
17
18
  },
18
19
  "./testing": {
20
+ "source": "./src/testing/index.ts",
19
21
  "types": "./dist/testing/index.d.ts",
20
22
  "import": "./dist/testing/index.js"
21
23
  }
@@ -251,6 +251,7 @@ interface Component {
251
251
  render(width: number): string[];
252
252
  handleInput?(data: string): void;
253
253
  handleMouse?(event: TuiMouseEvent): TuiMouseEventResult | undefined;
254
+ capturesViewportInput?: boolean;
254
255
  invalidate(): void;
255
256
  }
256
257
  ```
@@ -260,6 +261,7 @@ interface Component {
260
261
  | `render(width)` | Returns an array of strings, one per line. Each line **must not exceed `width`** or the TUI will error. Use `truncateToWidth()` or manual wrapping to ensure this. |
261
262
  | `handleInput?(data)` | Called when the component has focus and receives keyboard input. The `data` string contains raw terminal input (may include ANSI escape sequences). |
262
263
  | `handleMouse?(event)` | Called by `TuiAltScreen` for normalized pointer input targeted at the component. |
264
+ | `capturesViewportInput?` | If true while the component has focus, `TuiAltScreen` passes its viewport scrolling and prompt-jump keys (`tui.altScreen.*` except search) to it instead of scrolling the viewport, as it does for a focused overlay. Set by `SelectList`, `SettingsList`, and `Editor` while autocomplete is open, so PageUp/PageDown move the selection. Only the focused component is checked: a wrapper that forwards input to a list must expose the list's value itself. Use `getSelectPageIndex(keybindings, data, selectedIndex, itemCount, pageSize)` to compute the new selection. |
263
265
  | `invalidate()` | Required. Clear any cached render state so the next `render()` starts from scratch. Components without cached render state can use an empty implementation. |
264
266
 
265
267
  The TUI appends a full SGR reset and OSC 8 reset at the end of each rendered line. Styles do not carry across lines. If you emit multi-line text with styling, reapply styles per line or use `wrapTextWithAnsi()` so styles are preserved for each wrapped line.
@@ -22,6 +22,7 @@ export interface EditorOptions {
22
22
  export declare class Editor implements Component, Focusable {
23
23
  private state;
24
24
  focused: boolean;
25
+ get capturesViewportInput(): boolean;
25
26
  protected tui: TUI;
26
27
  private theme;
27
28
  private paddingX;
@@ -1,5 +1,5 @@
1
- var tt=Object.defineProperty;var T=(a,t)=>tt(a,"name",{value:t,configurable:!0});import{getKeybindings as et}from"../keybindings.js";import{decodePrintableKey as j,matchesKey as W}from"../keys.js";import{KillRing as st}from"../kill-ring.js";import{CURSOR_MARKER as it,renderFakeCursor as D}from"../tui.js";import{UndoStack as rt}from"../undo-stack.js";import{autocompleteBoundaryRegex as ot,autocompleteSeparatorRegex as nt,cjkBreakRegex as O,getGraphemeSegmenter as lt,getWordSegmenter as ht,isWhitespaceChar as I,sliceByColumn as at,truncateToWidth as ct,visibleWidth as b}from"../utils.js";import{findWordBackward as ut,findWordForward as pt}from"../word-navigation.js";import{SelectList as dt}from"./select-list.js";const X=lt(),mt=ht(),N=/\[paste #(\d+)( (\+\d+ lines|\d+ chars))?\]/g,_=/^\[paste #(\d+)( (\+\d+ lines|\d+ chars))?\]$/;function M(a){return a.length>=10&&_.test(a)}T(M,"isPasteMarker");function ft(a,t,e){if(e.size===0||!a.includes("[paste #"))return t.segment(a);const s=[];for(const o of a.matchAll(N)){const l=Number.parseInt(o[1],10);e.has(l)&&s.push({start:o.index,end:o.index+o[0].length})}if(s.length===0)return t.segment(a);const i=t.segment(a),r=[];let n=0;for(const o of i){for(;n<s.length&&s[n].end<=o.index;)n++;const l=n<s.length?s[n]:null;if(l&&o.index>=l.start&&o.index<l.end){if(o.index===l.start){const h=a.slice(l.start,l.end);r.push({segment:h,index:l.start,input:a})}}else r.push(o)}return r}T(ft,"segmentWithMarkers");function E(a,t,e){if(!a||t<=0)return[{text:"",startIndex:0,endIndex:0}];if(b(a)<=t)return[{text:a,startIndex:0,endIndex:a.length}];const i=[],r=e??[...X.segment(a)];let n=0,o=0,l=-1,h=0;for(let c=0;c<r.length;c++){const u=r[c],d=u.segment,p=b(d),f=u.index,C=!M(d)&&I(d);if(n+p>t&&(l>=0&&n-h+p<=t?(i.push({text:a.slice(o,l),startIndex:o,endIndex:l}),o=l,n-=h):o<f&&(i.push({text:a.slice(o,f),startIndex:o,endIndex:f}),o=f,n=0),l=-1),p>t){const m=E(d,t);for(let L=0;L<m.length-1;L++){const w=m[L];i.push({text:w.text,startIndex:f+w.startIndex,endIndex:f+w.endIndex})}const A=m[m.length-1];o=f+A.startIndex,n=b(A.text),l=-1;continue}n+=p;const g=r[c+1];if(C&&g&&(M(g.segment)||!I(g.segment)))l=g.index,h=n;else if(!C&&g&&!I(g.segment)){const m=!M(d)&&O.test(d),A=!M(g.segment)&&O.test(g.segment);(m||A)&&(l=g.index,h=n)}}return i.push({text:a.slice(o),startIndex:o,endIndex:a.length}),i}T(E,"wordWrapLine");const gt={minPrimaryColumnWidth:12,maxPrimaryColumnWidth:32},Ct=20,G=["@","#"],$=new RegExp(`(?:(?!${nt.source}).)*`,"u"),z=`${ot.source}[([{<\`]*`;function K(a){return a.replace(/[\\^$.*+?()[\]{}|-]/g,"\\$&")}T(K,"escapeCharacterClass");function Y(a){return new RegExp(`${z}(?:@"[^"]*|[${a.map(K).join("")}]${$.source})$`,"u")}T(Y,"buildTriggerPattern");function Z(a){const t=a.filter(e=>e!=="@").map(K);return new RegExp(`${z}(?:@(?:"[^"]*|${$.source})|[${t.join("")}]${$.source})$`,"u")}T(Z,"buildDebouncePattern");function Lt(a,t,e){const s=Math.max(0,e),i=` ${a} ${t} more `,r=b(i);if(r+2<=s){const c=Math.floor((s-r)/2);return"\u2500".repeat(c)+i+"\u2500".repeat(s-c-r)}const n=`\u2500\u2500\u2500 ${a} ${t} more `,o=s-b(n);if(o>=0)return n+"\u2500".repeat(o);const l="...".slice(0,s),h=s-b(l);return at(n,0,h,!0)+l}T(Lt,"createScrollBorder");class It{static{T(this,"Editor")}state={lines:[""],cursorLine:0,cursorCol:0};focused=!1;tui;theme;paddingX=0;borderStyle="line";placeholder="";lastWidth=80;renderedVisibleLineCount=1;renderedAutocompleteHeight=0;scrollOffset=0;borderColor;autocompleteProvider;autocompleteTriggerCharacters=[...G];autocompleteTriggerPattern=Y(this.autocompleteTriggerCharacters);autocompleteDebouncePattern=Z(this.autocompleteTriggerCharacters);autocompleteList;autocompleteState=null;autocompletePrefix="";autocompleteMaxVisible=5;autocompleteAbort;autocompleteDebounceTimer;autocompleteRequestTask=Promise.resolve();autocompleteStartToken=0;autocompleteRequestId=0;pastes=new Map;pasteCounter=0;pasteBuffer="";isInPaste=!1;history=[];historyIndex=-1;historyDraft=null;killRing=new st;lastAction=null;jumpMode=null;preferredVisualCol=null;snappedFromCursorCol=null;undoStack=new rt;onSubmit;onChange;disableSubmit=!1;constructor(t,e,s={}){this.tui=t,this.theme=e,this.borderColor=e.borderColor,this.borderStyle=s.borderStyle==="box"?"box":"line",this.placeholder=s.placeholder??"";const i=s.paddingX??0;this.paddingX=Number.isFinite(i)?Math.max(0,Math.floor(i)):0;const r=s.autocompleteMaxVisible??5;this.autocompleteMaxVisible=Number.isFinite(r)?Math.max(3,Math.min(20,Math.floor(r))):5}validPasteIds(){return new Set(this.pastes.keys())}segment(t,e){return ft(t,e==="word"?mt:X,this.validPasteIds())}getPaddingX(){return this.paddingX}setPaddingX(t){const e=Number.isFinite(t)?Math.max(0,Math.floor(t)):0;this.paddingX!==e&&(this.paddingX=e,this.tui.requestRender())}setPlaceholder(t){const e=t??"";this.placeholder!==e&&(this.placeholder=e,this.tui.requestRender())}getAutocompleteMaxVisible(){return this.autocompleteMaxVisible}setAutocompleteMaxVisible(t){const e=Number.isFinite(t)?Math.max(3,Math.min(20,Math.floor(t))):5;this.autocompleteMaxVisible!==e&&(this.autocompleteMaxVisible=e,this.tui.requestRender())}setAutocompleteProvider(t){this.cancelAutocomplete(),this.autocompleteProvider=t,this.setAutocompleteTriggerCharacters(t.triggerCharacters??[])}addToHistory(t){const e=t.trim();e&&(this.history.length>0&&this.history[0]===e||(this.history.unshift(e),this.history.length>100&&this.history.pop()))}isEditorEmpty(){return this.state.lines.length===1&&this.state.lines[0]===""}isOnFirstVisualLine(){const t=this.buildVisualLineMap(this.lastWidth);return this.findCurrentVisualLine(t)===0}isOnLastVisualLine(){const t=this.buildVisualLineMap(this.lastWidth);return this.findCurrentVisualLine(t)===t.length-1}navigateHistory(t){if(this.lastAction=null,this.history.length===0)return;const e=this.historyIndex-t;if(!(e<-1||e>=this.history.length))if(this.historyIndex===-1&&e>=0&&(this.pushUndoSnapshot(),this.historyDraft=structuredClone(this.state)),this.historyIndex=e,this.historyIndex===-1){const s=this.historyDraft;this.historyDraft=null,s?(this.state=s,this.preferredVisualCol=null,this.snappedFromCursorCol=null,this.scrollOffset=0,this.onChange&&this.onChange(this.getText())):this.setTextInternal("")}else this.setTextInternal(this.history[this.historyIndex]||"",t===-1?"start":"end")}exitHistoryBrowsing(){this.historyIndex=-1,this.historyDraft=null}setTextInternal(t,e="end"){const s=t.split(`
2
- `);this.state.lines=s.length===0?[""]:s,this.state.cursorLine=e==="start"?0:this.state.lines.length-1,this.setCursorCol(e==="start"?0:this.state.lines[this.state.cursorLine]?.length||0),this.scrollOffset=0,this.onChange&&this.onChange(this.getText())}invalidate(){}renderHorizontalBorder(t,e,s){const i=this.borderStyle==="box",r=i?Math.max(0,e-2):e,n=t==="top"?"\u2191":"\u2193",o=s>0?Lt(n,s,r):"\u2500".repeat(r);if(!i)return this.borderColor(o);const l=t==="top"?"\u256D":"\u2570",h=t==="top"?"\u256E":"\u256F";return this.borderColor(`${l}${o}${h}`)}renderTopBorder(t,e){return this.renderHorizontalBorder("top",t,e)}renderBottomBorder(t,e){return this.renderHorizontalBorder("bottom",t,e)}render(t){const e=this.borderStyle==="box",i=Math.max(1,t-(e?1:0)*2),r=e?Math.max(1,this.paddingX):this.paddingX,n=Math.max(0,Math.floor((i-1)/2)),o=Math.min(r,n),l=Math.max(1,i-o*2),h=Math.max(1,l-(o?0:1));this.lastWidth=h;const c=T(x=>this.borderColor(x),"paintEdge"),u=this.layoutText(h),d=this.tui.terminal.rows,p=Math.max(5,Math.floor(d*.3));let f=u.findIndex(x=>x.hasCursor);f===-1&&(f=0),f<this.scrollOffset?this.scrollOffset=f:f>=this.scrollOffset+p&&(this.scrollOffset=f-p+1);const C=Math.max(0,u.length-p);this.scrollOffset=Math.max(0,Math.min(this.scrollOffset,C));const g=u.slice(this.scrollOffset,this.scrollOffset+p);this.renderedVisibleLineCount=g.length;const m=[],A=" ".repeat(o),L=A;m.push(this.renderTopBorder(t,this.scrollOffset));const w=this.focused;for(const x of g){let S=x.text,k=b(x.text),P=!1;if(x.hasCursor&&x.cursorPos!==void 0){const U=S.slice(0,x.cursorPos),v=S.slice(x.cursorPos),H=w?it:"";if(v.length>0){const B=[...this.segment(v,"grapheme")][0]?.segment||"",V=v.slice(B.length),y=D(B);S=U+H+y+V}else{const q=D(" ");if(S=U+H+q,k=k+1,k>l&&o>0&&(P=!0),this.placeholder&&this.getText().length===0){const B=this.theme.placeholder??(y=>y),V=Math.max(0,l-k);if(V>0){const y=ct(this.placeholder,V,"...");S+=B(y),k+=b(y)}}}}const R=" ".repeat(Math.max(0,l-k)),Q=P?L.slice(1):L,F=`${A}${S}${R}${Q}`;e?m.push(`${c("\u2502")}${F}${c("\u2502")}`):m.push(F)}const J=u.length-(this.scrollOffset+g.length);if(m.push(this.renderBottomBorder(t,J)),this.renderedAutocompleteHeight=0,this.autocompleteState&&this.autocompleteList){const x=this.autocompleteList.render(l);this.renderedAutocompleteHeight=x.length;for(const S of x){const k=b(S),P=" ".repeat(Math.max(0,l-k)),R=`${A}${S}${P}${L}`;e?m.push(`${c("\u2502")}${R}${c("\u2502")}`):m.push(R)}}return m}handleMouse(t){const e=this.renderedVisibleLineCount+2;if(this.autocompleteState&&this.autocompleteList&&t.y>=e&&t.y<e+this.renderedAutocompleteHeight){const g=Math.max(0,Math.floor((t.width-1)/2)),m=Math.min(this.paddingX,g),A=Math.max(1,t.width-m*2),L=this.autocompleteList.handleMouse?.({...t,x:t.x-m,y:t.y-e,width:A,height:this.renderedAutocompleteHeight});return L?{...L,focus:!0}:void 0}if(t.type!=="click"||t.button!=="left")return;if(t.y<=0||t.y>this.renderedVisibleLineCount)return{handled:!0,focus:!0};const s=this.buildVisualLineMap(this.lastWidth),i=this.scrollOffset+t.y-1,r=s[i];if(!r)return{handled:!0,focus:!0};const n=this.state.lines[r.logicalLine]??"",o=r.startCol+r.length,l=n.slice(r.startCol,o),h=Math.max(0,Math.floor((t.width-1)/2)),c=Math.min(this.paddingX,h),u=Math.max(0,t.x-c);let d=0,p=l.length,f=0;for(const g of this.segment(l,"grapheme")){const m=d+b(g.segment);if(f=g.index,u<m){p=g.index;break}d=m}return!(i===s.length-1||s[i+1]?.logicalLine!==r.logicalLine)&&p===l.length&&l.length>0&&(p=f),this.state.cursorLine=r.logicalLine,this.setCursorCol(r.startCol+p),this.lastAction=null,this.exitHistoryBrowsing(),this.autocompleteState&&this.updateAutocomplete(),{handled:!0,focus:!0}}handleInput(t){const e=et();if(this.jumpMode!==null){if(e.matches(t,"tui.editor.jumpForward")||e.matches(t,"tui.editor.jumpBackward")){this.jumpMode=null;return}const i=j(t)??(t.charCodeAt(0)>=32?t:void 0);if(i!==void 0){const r=this.jumpMode;this.jumpMode=null,this.jumpToChar(i,r);return}this.jumpMode=null}if(t.includes("\x1B[200~")&&(this.isInPaste=!0,this.pasteBuffer="",t=t.replace("\x1B[200~","")),this.isInPaste){this.pasteBuffer+=t;const i=this.pasteBuffer.indexOf("\x1B[201~");if(i!==-1){const r=this.pasteBuffer.substring(0,i);r.length>0&&this.handlePaste(r),this.isInPaste=!1;const n=this.pasteBuffer.substring(i+6);this.pasteBuffer="",n.length>0&&this.handleInput(n);return}return}if(e.matches(t,"tui.input.copy"))return;if(e.matches(t,"tui.editor.undo")){this.undo();return}if(this.autocompleteState&&this.autocompleteList){if(e.matches(t,"tui.select.cancel")){this.cancelAutocomplete();return}if(e.matches(t,"tui.select.up")||e.matches(t,"tui.select.down")){this.autocompleteList.handleInput(t);return}if(e.matches(t,"tui.input.tab")){const i=this.autocompleteList.getSelectedItem();if(i&&this.autocompleteProvider){this.pushUndoSnapshot(),this.lastAction=null;const r=this.autocompleteProvider.applyCompletion(this.state.lines,this.state.cursorLine,this.state.cursorCol,i,this.autocompletePrefix);this.state.lines=r.lines,this.state.cursorLine=r.cursorLine,this.setCursorCol(r.cursorCol),this.cancelAutocomplete(),this.onChange&&this.onChange(this.getText())}return}if(e.matches(t,"tui.select.confirm")){const i=this.autocompleteList.getSelectedItem();if(i&&this.autocompleteProvider){this.pushUndoSnapshot(),this.lastAction=null;const r=this.autocompleteProvider.applyCompletion(this.state.lines,this.state.cursorLine,this.state.cursorCol,i,this.autocompletePrefix);if(this.state.lines=r.lines,this.state.cursorLine=r.cursorLine,this.setCursorCol(r.cursorCol),this.autocompletePrefix.startsWith("/"))this.cancelAutocomplete();else{this.cancelAutocomplete(),this.onChange&&this.onChange(this.getText());return}}}}if(e.matches(t,"tui.input.tab")&&!this.autocompleteState){this.handleTabCompletion();return}if(e.matches(t,"tui.editor.deleteToLineEnd")){this.deleteToEndOfLine();return}if(e.matches(t,"tui.editor.deleteToLineStart")){this.deleteToStartOfLine();return}if(e.matches(t,"tui.editor.deleteWordBackward")){this.deleteWordBackwards();return}if(e.matches(t,"tui.editor.deleteWordForward")){this.deleteWordForward();return}if(e.matches(t,"tui.editor.deleteCharBackward")||W(t,"shift+backspace")){this.handleBackspace();return}if(e.matches(t,"tui.editor.deleteCharForward")||W(t,"shift+delete")){this.handleForwardDelete();return}if(e.matches(t,"tui.editor.yank")){this.yank();return}if(e.matches(t,"tui.editor.yankPop")){this.yankPop();return}if(e.matches(t,"tui.editor.historyPrevious")){this.cancelAutocomplete(),this.navigateHistory(-1);return}if(e.matches(t,"tui.editor.historyNext")){this.cancelAutocomplete(),this.navigateHistory(1);return}if(e.matches(t,"tui.editor.cursorLineStart")){this.moveToLineStart();return}if(e.matches(t,"tui.editor.cursorLineEnd")){this.moveToLineEnd();return}if(e.matches(t,"tui.editor.cursorWordLeft")){this.moveWordBackwards();return}if(e.matches(t,"tui.editor.cursorWordRight")){this.moveWordForwards();return}if(e.matches(t,"tui.input.newLine")||t.charCodeAt(0)===10&&t.length>1||t==="\x1B\r"||t==="\x1B[13;2~"||t.length>1&&t.includes("\x1B")&&t.includes("\r")||t===`
1
+ var tt=Object.defineProperty;var T=(a,t)=>tt(a,"name",{value:t,configurable:!0});import{getKeybindings as et}from"../keybindings.js";import{decodePrintableKey as j,matchesKey as W}from"../keys.js";import{KillRing as st}from"../kill-ring.js";import{CURSOR_MARKER as it,renderFakeCursor as D}from"../tui.js";import{UndoStack as rt}from"../undo-stack.js";import{autocompleteBoundaryRegex as ot,autocompleteSeparatorRegex as nt,cjkBreakRegex as O,getGraphemeSegmenter as lt,getWordSegmenter as ht,isWhitespaceChar as I,sliceByColumn as at,truncateToWidth as ct,visibleWidth as b}from"../utils.js";import{findWordBackward as ut,findWordForward as pt}from"../word-navigation.js";import{SelectList as dt}from"./select-list.js";const X=lt(),mt=ht(),N=/\[paste #(\d+)( (\+\d+ lines|\d+ chars))?\]/g,_=/^\[paste #(\d+)( (\+\d+ lines|\d+ chars))?\]$/;function M(a){return a.length>=10&&_.test(a)}T(M,"isPasteMarker");function ft(a,t,e){if(e.size===0||!a.includes("[paste #"))return t.segment(a);const s=[];for(const o of a.matchAll(N)){const l=Number.parseInt(o[1],10);e.has(l)&&s.push({start:o.index,end:o.index+o[0].length})}if(s.length===0)return t.segment(a);const i=t.segment(a),r=[];let n=0;for(const o of i){for(;n<s.length&&s[n].end<=o.index;)n++;const l=n<s.length?s[n]:null;if(l&&o.index>=l.start&&o.index<l.end){if(o.index===l.start){const h=a.slice(l.start,l.end);r.push({segment:h,index:l.start,input:a})}}else r.push(o)}return r}T(ft,"segmentWithMarkers");function E(a,t,e){if(!a||t<=0)return[{text:"",startIndex:0,endIndex:0}];if(b(a)<=t)return[{text:a,startIndex:0,endIndex:a.length}];const i=[],r=e??[...X.segment(a)];let n=0,o=0,l=-1,h=0;for(let c=0;c<r.length;c++){const u=r[c],d=u.segment,p=b(d),f=u.index,C=!M(d)&&I(d);if(n+p>t&&(l>=0&&n-h+p<=t?(i.push({text:a.slice(o,l),startIndex:o,endIndex:l}),o=l,n-=h):o<f&&(i.push({text:a.slice(o,f),startIndex:o,endIndex:f}),o=f,n=0),l=-1),p>t){const m=E(d,t);for(let L=0;L<m.length-1;L++){const w=m[L];i.push({text:w.text,startIndex:f+w.startIndex,endIndex:f+w.endIndex})}const A=m[m.length-1];o=f+A.startIndex,n=b(A.text),l=-1;continue}n+=p;const g=r[c+1];if(C&&g&&(M(g.segment)||!I(g.segment)))l=g.index,h=n;else if(!C&&g&&!I(g.segment)){const m=!M(d)&&O.test(d),A=!M(g.segment)&&O.test(g.segment);(m||A)&&(l=g.index,h=n)}}return i.push({text:a.slice(o),startIndex:o,endIndex:a.length}),i}T(E,"wordWrapLine");const gt={minPrimaryColumnWidth:12,maxPrimaryColumnWidth:32},Ct=20,G=["@","#"],$=new RegExp(`(?:(?!${nt.source}).)*`,"u"),z=`${ot.source}[([{<\`]*`;function K(a){return a.replace(/[\\^$.*+?()[\]{}|-]/g,"\\$&")}T(K,"escapeCharacterClass");function Y(a){return new RegExp(`${z}(?:@"[^"]*|[${a.map(K).join("")}]${$.source})$`,"u")}T(Y,"buildTriggerPattern");function Z(a){const t=a.filter(e=>e!=="@").map(K);return new RegExp(`${z}(?:@(?:"[^"]*|${$.source})|[${t.join("")}]${$.source})$`,"u")}T(Z,"buildDebouncePattern");function Lt(a,t,e){const s=Math.max(0,e),i=` ${a} ${t} more `,r=b(i);if(r+2<=s){const c=Math.floor((s-r)/2);return"\u2500".repeat(c)+i+"\u2500".repeat(s-c-r)}const n=`\u2500\u2500\u2500 ${a} ${t} more `,o=s-b(n);if(o>=0)return n+"\u2500".repeat(o);const l="...".slice(0,s),h=s-b(l);return at(n,0,h,!0)+l}T(Lt,"createScrollBorder");class It{static{T(this,"Editor")}state={lines:[""],cursorLine:0,cursorCol:0};focused=!1;get capturesViewportInput(){return this.autocompleteState!==null}tui;theme;paddingX=0;borderStyle="line";placeholder="";lastWidth=80;renderedVisibleLineCount=1;renderedAutocompleteHeight=0;scrollOffset=0;borderColor;autocompleteProvider;autocompleteTriggerCharacters=[...G];autocompleteTriggerPattern=Y(this.autocompleteTriggerCharacters);autocompleteDebouncePattern=Z(this.autocompleteTriggerCharacters);autocompleteList;autocompleteState=null;autocompletePrefix="";autocompleteMaxVisible=5;autocompleteAbort;autocompleteDebounceTimer;autocompleteRequestTask=Promise.resolve();autocompleteStartToken=0;autocompleteRequestId=0;pastes=new Map;pasteCounter=0;pasteBuffer="";isInPaste=!1;history=[];historyIndex=-1;historyDraft=null;killRing=new st;lastAction=null;jumpMode=null;preferredVisualCol=null;snappedFromCursorCol=null;undoStack=new rt;onSubmit;onChange;disableSubmit=!1;constructor(t,e,s={}){this.tui=t,this.theme=e,this.borderColor=e.borderColor,this.borderStyle=s.borderStyle==="box"?"box":"line",this.placeholder=s.placeholder??"";const i=s.paddingX??0;this.paddingX=Number.isFinite(i)?Math.max(0,Math.floor(i)):0;const r=s.autocompleteMaxVisible??5;this.autocompleteMaxVisible=Number.isFinite(r)?Math.max(3,Math.min(20,Math.floor(r))):5}validPasteIds(){return new Set(this.pastes.keys())}segment(t,e){return ft(t,e==="word"?mt:X,this.validPasteIds())}getPaddingX(){return this.paddingX}setPaddingX(t){const e=Number.isFinite(t)?Math.max(0,Math.floor(t)):0;this.paddingX!==e&&(this.paddingX=e,this.tui.requestRender())}setPlaceholder(t){const e=t??"";this.placeholder!==e&&(this.placeholder=e,this.tui.requestRender())}getAutocompleteMaxVisible(){return this.autocompleteMaxVisible}setAutocompleteMaxVisible(t){const e=Number.isFinite(t)?Math.max(3,Math.min(20,Math.floor(t))):5;this.autocompleteMaxVisible!==e&&(this.autocompleteMaxVisible=e,this.tui.requestRender())}setAutocompleteProvider(t){this.cancelAutocomplete(),this.autocompleteProvider=t,this.setAutocompleteTriggerCharacters(t.triggerCharacters??[])}addToHistory(t){const e=t.trim();e&&(this.history.length>0&&this.history[0]===e||(this.history.unshift(e),this.history.length>100&&this.history.pop()))}isEditorEmpty(){return this.state.lines.length===1&&this.state.lines[0]===""}isOnFirstVisualLine(){const t=this.buildVisualLineMap(this.lastWidth);return this.findCurrentVisualLine(t)===0}isOnLastVisualLine(){const t=this.buildVisualLineMap(this.lastWidth);return this.findCurrentVisualLine(t)===t.length-1}navigateHistory(t){if(this.lastAction=null,this.history.length===0)return;const e=this.historyIndex-t;if(!(e<-1||e>=this.history.length))if(this.historyIndex===-1&&e>=0&&(this.pushUndoSnapshot(),this.historyDraft=structuredClone(this.state)),this.historyIndex=e,this.historyIndex===-1){const s=this.historyDraft;this.historyDraft=null,s?(this.state=s,this.preferredVisualCol=null,this.snappedFromCursorCol=null,this.scrollOffset=0,this.onChange&&this.onChange(this.getText())):this.setTextInternal("")}else this.setTextInternal(this.history[this.historyIndex]||"",t===-1?"start":"end")}exitHistoryBrowsing(){this.historyIndex=-1,this.historyDraft=null}setTextInternal(t,e="end"){const s=t.split(`
2
+ `);this.state.lines=s.length===0?[""]:s,this.state.cursorLine=e==="start"?0:this.state.lines.length-1,this.setCursorCol(e==="start"?0:this.state.lines[this.state.cursorLine]?.length||0),this.scrollOffset=0,this.onChange&&this.onChange(this.getText())}invalidate(){}renderHorizontalBorder(t,e,s){const i=this.borderStyle==="box",r=i?Math.max(0,e-2):e,n=t==="top"?"\u2191":"\u2193",o=s>0?Lt(n,s,r):"\u2500".repeat(r);if(!i)return this.borderColor(o);const l=t==="top"?"\u256D":"\u2570",h=t==="top"?"\u256E":"\u256F";return this.borderColor(`${l}${o}${h}`)}renderTopBorder(t,e){return this.renderHorizontalBorder("top",t,e)}renderBottomBorder(t,e){return this.renderHorizontalBorder("bottom",t,e)}render(t){const e=this.borderStyle==="box",i=Math.max(1,t-(e?1:0)*2),r=e?Math.max(1,this.paddingX):this.paddingX,n=Math.max(0,Math.floor((i-1)/2)),o=Math.min(r,n),l=Math.max(1,i-o*2),h=Math.max(1,l-(o?0:1));this.lastWidth=h;const c=T(x=>this.borderColor(x),"paintEdge"),u=this.layoutText(h),d=this.tui.terminal.rows,p=Math.max(5,Math.floor(d*.3));let f=u.findIndex(x=>x.hasCursor);f===-1&&(f=0),f<this.scrollOffset?this.scrollOffset=f:f>=this.scrollOffset+p&&(this.scrollOffset=f-p+1);const C=Math.max(0,u.length-p);this.scrollOffset=Math.max(0,Math.min(this.scrollOffset,C));const g=u.slice(this.scrollOffset,this.scrollOffset+p);this.renderedVisibleLineCount=g.length;const m=[],A=" ".repeat(o),L=A;m.push(this.renderTopBorder(t,this.scrollOffset));const w=this.focused;for(const x of g){let S=x.text,k=b(x.text),P=!1;if(x.hasCursor&&x.cursorPos!==void 0){const U=S.slice(0,x.cursorPos),v=S.slice(x.cursorPos),H=w?it:"";if(v.length>0){const B=[...this.segment(v,"grapheme")][0]?.segment||"",V=v.slice(B.length),y=D(B);S=U+H+y+V}else{const q=D(" ");if(S=U+H+q,k=k+1,k>l&&o>0&&(P=!0),this.placeholder&&this.getText().length===0){const B=this.theme.placeholder??(y=>y),V=Math.max(0,l-k);if(V>0){const y=ct(this.placeholder,V,"...");S+=B(y),k+=b(y)}}}}const R=" ".repeat(Math.max(0,l-k)),Q=P?L.slice(1):L,F=`${A}${S}${R}${Q}`;e?m.push(`${c("\u2502")}${F}${c("\u2502")}`):m.push(F)}const J=u.length-(this.scrollOffset+g.length);if(m.push(this.renderBottomBorder(t,J)),this.renderedAutocompleteHeight=0,this.autocompleteState&&this.autocompleteList){const x=this.autocompleteList.render(l);this.renderedAutocompleteHeight=x.length;for(const S of x){const k=b(S),P=" ".repeat(Math.max(0,l-k)),R=`${A}${S}${P}${L}`;e?m.push(`${c("\u2502")}${R}${c("\u2502")}`):m.push(R)}}return m}handleMouse(t){const e=this.renderedVisibleLineCount+2;if(this.autocompleteState&&this.autocompleteList&&t.y>=e&&t.y<e+this.renderedAutocompleteHeight){const g=Math.max(0,Math.floor((t.width-1)/2)),m=Math.min(this.paddingX,g),A=Math.max(1,t.width-m*2),L=this.autocompleteList.handleMouse?.({...t,x:t.x-m,y:t.y-e,width:A,height:this.renderedAutocompleteHeight});return L?{...L,focus:!0}:void 0}if(t.type!=="click"||t.button!=="left")return;if(t.y<=0||t.y>this.renderedVisibleLineCount)return{handled:!0,focus:!0};const s=this.buildVisualLineMap(this.lastWidth),i=this.scrollOffset+t.y-1,r=s[i];if(!r)return{handled:!0,focus:!0};const n=this.state.lines[r.logicalLine]??"",o=r.startCol+r.length,l=n.slice(r.startCol,o),h=Math.max(0,Math.floor((t.width-1)/2)),c=Math.min(this.paddingX,h),u=Math.max(0,t.x-c);let d=0,p=l.length,f=0;for(const g of this.segment(l,"grapheme")){const m=d+b(g.segment);if(f=g.index,u<m){p=g.index;break}d=m}return!(i===s.length-1||s[i+1]?.logicalLine!==r.logicalLine)&&p===l.length&&l.length>0&&(p=f),this.state.cursorLine=r.logicalLine,this.setCursorCol(r.startCol+p),this.lastAction=null,this.exitHistoryBrowsing(),this.autocompleteState&&this.updateAutocomplete(),{handled:!0,focus:!0}}handleInput(t){const e=et();if(this.jumpMode!==null){if(e.matches(t,"tui.editor.jumpForward")||e.matches(t,"tui.editor.jumpBackward")){this.jumpMode=null;return}const i=j(t)??(t.charCodeAt(0)>=32?t:void 0);if(i!==void 0){const r=this.jumpMode;this.jumpMode=null,this.jumpToChar(i,r);return}this.jumpMode=null}if(t.includes("\x1B[200~")&&(this.isInPaste=!0,this.pasteBuffer="",t=t.replace("\x1B[200~","")),this.isInPaste){this.pasteBuffer+=t;const i=this.pasteBuffer.indexOf("\x1B[201~");if(i!==-1){const r=this.pasteBuffer.substring(0,i);r.length>0&&this.handlePaste(r),this.isInPaste=!1;const n=this.pasteBuffer.substring(i+6);this.pasteBuffer="",n.length>0&&this.handleInput(n);return}return}if(e.matches(t,"tui.input.copy"))return;if(e.matches(t,"tui.editor.undo")){this.undo();return}if(this.autocompleteState&&this.autocompleteList){if(e.matches(t,"tui.select.cancel")){this.cancelAutocomplete();return}if(e.matches(t,"tui.select.up")||e.matches(t,"tui.select.down")||e.matches(t,"tui.select.pageUp")||e.matches(t,"tui.select.pageDown")){this.autocompleteList.handleInput(t);return}if(e.matches(t,"tui.input.tab")){const i=this.autocompleteList.getSelectedItem();if(i&&this.autocompleteProvider){this.pushUndoSnapshot(),this.lastAction=null;const r=this.autocompleteProvider.applyCompletion(this.state.lines,this.state.cursorLine,this.state.cursorCol,i,this.autocompletePrefix);this.state.lines=r.lines,this.state.cursorLine=r.cursorLine,this.setCursorCol(r.cursorCol),this.cancelAutocomplete(),this.onChange&&this.onChange(this.getText())}return}if(e.matches(t,"tui.select.confirm")){const i=this.autocompleteList.getSelectedItem();if(i&&this.autocompleteProvider){this.pushUndoSnapshot(),this.lastAction=null;const r=this.autocompleteProvider.applyCompletion(this.state.lines,this.state.cursorLine,this.state.cursorCol,i,this.autocompletePrefix);if(this.state.lines=r.lines,this.state.cursorLine=r.cursorLine,this.setCursorCol(r.cursorCol),this.autocompletePrefix.startsWith("/"))this.cancelAutocomplete();else{this.cancelAutocomplete(),this.onChange&&this.onChange(this.getText());return}}}}if(e.matches(t,"tui.input.tab")&&!this.autocompleteState){this.handleTabCompletion();return}if(e.matches(t,"tui.editor.deleteToLineEnd")){this.deleteToEndOfLine();return}if(e.matches(t,"tui.editor.deleteToLineStart")){this.deleteToStartOfLine();return}if(e.matches(t,"tui.editor.deleteWordBackward")){this.deleteWordBackwards();return}if(e.matches(t,"tui.editor.deleteWordForward")){this.deleteWordForward();return}if(e.matches(t,"tui.editor.deleteCharBackward")||W(t,"shift+backspace")){this.handleBackspace();return}if(e.matches(t,"tui.editor.deleteCharForward")||W(t,"shift+delete")){this.handleForwardDelete();return}if(e.matches(t,"tui.editor.yank")){this.yank();return}if(e.matches(t,"tui.editor.yankPop")){this.yankPop();return}if(e.matches(t,"tui.editor.historyPrevious")){this.cancelAutocomplete(),this.navigateHistory(-1);return}if(e.matches(t,"tui.editor.historyNext")){this.cancelAutocomplete(),this.navigateHistory(1);return}if(e.matches(t,"tui.editor.cursorLineStart")){this.moveToLineStart();return}if(e.matches(t,"tui.editor.cursorLineEnd")){this.moveToLineEnd();return}if(e.matches(t,"tui.editor.cursorWordLeft")){this.moveWordBackwards();return}if(e.matches(t,"tui.editor.cursorWordRight")){this.moveWordForwards();return}if(e.matches(t,"tui.input.newLine")||t.charCodeAt(0)===10&&t.length>1||t==="\x1B\r"||t==="\x1B[13;2~"||t.length>1&&t.includes("\x1B")&&t.includes("\r")||t===`
3
3
  `&&t.length===1){if(this.shouldSubmitOnBackslashEnter(t,e)){this.handleBackspace(),this.submitValue();return}this.addNewLine();return}if(e.matches(t,"tui.input.submit")){if(this.disableSubmit)return;const i=this.state.lines[this.state.cursorLine]||"";if(this.state.cursorCol>0&&i[this.state.cursorCol-1]==="\\"){this.handleBackspace(),this.addNewLine();return}this.submitValue();return}if(e.matches(t,"tui.editor.cursorUp")){this.isOnFirstVisualLine()&&(this.isEditorEmpty()||this.historyIndex>-1||this.state.cursorCol===0)?this.navigateHistory(-1):this.isOnFirstVisualLine()?this.moveToLineStart():this.moveCursor(-1,0);return}if(e.matches(t,"tui.editor.cursorDown")){this.historyIndex>-1&&this.isOnLastVisualLine()?this.navigateHistory(1):this.isOnLastVisualLine()?this.moveToLineEnd():this.moveCursor(1,0);return}if(e.matches(t,"tui.editor.cursorRight")){this.moveCursor(0,1);return}if(e.matches(t,"tui.editor.cursorLeft")){this.moveCursor(0,-1);return}if(e.matches(t,"tui.editor.pageUp")){this.pageScroll(-1);return}if(e.matches(t,"tui.editor.pageDown")){this.pageScroll(1);return}if(e.matches(t,"tui.editor.jumpForward")){this.jumpMode="forward";return}if(e.matches(t,"tui.editor.jumpBackward")){this.jumpMode="backward";return}if(W(t,"shift+space")){this.insertCharacter(" ");return}const s=j(t);if(s!==void 0){this.insertCharacter(s);return}t.charCodeAt(0)>=32&&this.insertCharacter(t)}layoutText(t){const e=[];if(this.state.lines.length===0||this.state.lines.length===1&&this.state.lines[0]==="")return e.push({text:"",hasCursor:!0,cursorPos:0}),e;for(let s=0;s<this.state.lines.length;s++){const i=this.state.lines[s]||"",r=s===this.state.cursorLine;if(b(i)<=t)r?e.push({text:i,hasCursor:!0,cursorPos:this.state.cursorCol}):e.push({text:i,hasCursor:!1});else{const o=E(i,t,[...this.segment(i,"grapheme")]);for(let l=0;l<o.length;l++){const h=o[l];if(!h)continue;const c=this.state.cursorCol,u=l===o.length-1;let d=!1,p=0;r&&(u?(d=c>=h.startIndex,p=c-h.startIndex):(d=c>=h.startIndex&&c<h.endIndex,d&&(p=c-h.startIndex,p>h.text.length&&(p=h.text.length)))),d?e.push({text:h.text,hasCursor:!0,cursorPos:p}):e.push({text:h.text,hasCursor:!1})}}}return e}getText(){return this.state.lines.join(`
4
4
  `)}expandPasteMarkers(t){let e=t;for(const[s,i]of this.pastes){const r=new RegExp(`\\[paste #${s}( (\\+\\d+ lines|\\d+ chars))?\\]`,"g");e=e.replace(r,()=>i)}return e}getExpandedText(){return this.expandPasteMarkers(this.state.lines.join(`
5
5
  `))}getLines(){return[...this.state.lines]}getCursor(){return{line:this.state.cursorLine,col:this.state.cursorCol}}setText(t){this.cancelAutocomplete(),this.lastAction=null,this.exitHistoryBrowsing();const e=this.normalizeText(t);this.getText()!==e&&this.pushUndoSnapshot(),this.pastes.clear(),this.pasteCounter=0,this.setTextInternal(e)}insertTextAtCursor(t){t&&(this.cancelAutocomplete(),this.pushUndoSnapshot(),this.lastAction=null,this.exitHistoryBrowsing(),this.insertTextAtCursorInternal(t))}normalizeText(t){return t.replace(/\r\n/g,`
@@ -8,7 +8,7 @@ var tt=Object.defineProperty;var T=(a,t)=>tt(a,"name",{value:t,configurable:!0})
8
8
  `),i=this.state.lines[this.state.cursorLine]||"",r=i.slice(0,this.state.cursorCol),n=i.slice(this.state.cursorCol);s.length===1?(this.state.lines[this.state.cursorLine]=r+e+n,this.setCursorCol(this.state.cursorCol+e.length)):(this.state.lines=[...this.state.lines.slice(0,this.state.cursorLine),r+s[0],...s.slice(1,-1),s[s.length-1]+n,...this.state.lines.slice(this.state.cursorLine+1)],this.state.cursorLine+=s.length-1,this.setCursorCol((s[s.length-1]||"").length)),this.onChange&&this.onChange(this.getText())}insertCharacter(t,e){this.exitHistoryBrowsing(),e||((I(t)||this.lastAction!=="type-word")&&this.pushUndoSnapshot(),this.lastAction="type-word");const s=this.state.lines[this.state.cursorLine]||"",i=s.slice(0,this.state.cursorCol),r=s.slice(this.state.cursorCol);if(this.state.lines[this.state.cursorLine]=i+t+r,this.setCursorCol(this.state.cursorCol+t.length),this.onChange&&this.onChange(this.getText()),this.autocompleteState)this.updateAutocomplete();else if(t==="/"&&this.isAtStartOfMessage())this.tryTriggerAutocomplete();else if(this.autocompleteTriggerCharacters.includes(t)){const o=(this.state.lines[this.state.cursorLine]||"").slice(0,this.state.cursorCol);this.autocompleteTriggerPattern.test(o)&&this.tryTriggerAutocomplete()}else if(/[a-zA-Z0-9.\-_]/.test(t)||O.test(t)){const o=(this.state.lines[this.state.cursorLine]||"").slice(0,this.state.cursorCol);this.isInSlashCommandContext(o)?this.tryTriggerAutocomplete():this.autocompleteTriggerPattern.test(o)&&this.tryTriggerAutocomplete()}}handlePaste(t){this.cancelAutocomplete(),this.exitHistoryBrowsing(),this.lastAction=null,this.pushUndoSnapshot();const e=t.replace(/\x1b\[(\d+);5u/g,(o,l)=>{const h=Number(l);return h>=97&&h<=122?String.fromCharCode(h-96):h>=65&&h<=90?String.fromCharCode(h-64):o});let i=this.normalizeText(e).split("").filter(o=>o===`
9
9
  `||o.charCodeAt(0)>=32).join("");if(/^[/~.]/.test(i)){const o=this.state.lines[this.state.cursorLine]||"",l=this.state.cursorCol>0?o[this.state.cursorCol-1]:"";l&&/\w/.test(l)&&(i=` ${i}`)}const r=i.split(`
10
10
  `),n=i.length;if(r.length>10||n>1e3){this.pasteCounter++;const o=this.pasteCounter;this.pastes.set(o,i);const l=r.length>10?`[paste #${o} +${r.length} lines]`:`[paste #${o} ${n} chars]`;this.insertTextAtCursorInternal(l);return}if(r.length===1){this.insertTextAtCursorInternal(i);return}this.insertTextAtCursorInternal(i)}addNewLine(){this.cancelAutocomplete(),this.exitHistoryBrowsing(),this.lastAction=null,this.pushUndoSnapshot();const t=this.state.lines[this.state.cursorLine]||"",e=t.slice(0,this.state.cursorCol),s=t.slice(this.state.cursorCol);this.state.lines[this.state.cursorLine]=e,this.state.lines.splice(this.state.cursorLine+1,0,s),this.state.cursorLine++,this.setCursorCol(0),this.onChange&&this.onChange(this.getText())}shouldSubmitOnBackslashEnter(t,e){if(this.disableSubmit||!W(t,"enter"))return!1;const s=e.getKeys("tui.input.submit");if(!(s.includes("shift+enter")||s.includes("shift+return")))return!1;const r=this.state.lines[this.state.cursorLine]||"";return this.state.cursorCol>0&&r[this.state.cursorCol-1]==="\\"}submitValue(){this.cancelAutocomplete();const t=this.expandPasteMarkers(this.state.lines.join(`
11
- `)).trim();this.state={lines:[""],cursorLine:0,cursorCol:0},this.pastes.clear(),this.pasteCounter=0,this.exitHistoryBrowsing(),this.scrollOffset=0,this.undoStack.clear(),this.lastAction=null,this.onChange&&this.onChange(""),this.onSubmit&&this.onSubmit(t)}handleBackspace(){if(this.exitHistoryBrowsing(),this.lastAction=null,this.state.cursorCol>0){this.pushUndoSnapshot();let t=this.state.lines[this.state.cursorLine]||"";const e=t.slice(0,this.state.cursorCol),s=[...this.segment(e,"grapheme")],i=s[s.length-1],r=i?i.segment.length:1,n=_.exec(i.segment);if(n){const h=Number(n[1]);this.pastes.delete(h),this.pasteCounter--;const c=[...this.pastes.keys()].filter(u=>u>h).sort((u,d)=>u-d);for(const u of c)this.pastes.set(u-1,this.pastes.get(u)),this.pastes.delete(u);this.state.lines=this.state.lines.map(u=>u.replace(N,(d,p,f)=>{const C=Number(p);return C<=h?d:`[paste #${C-1}${f}]`}))}t=this.state.lines[this.state.cursorLine]||"";const o=t.slice(0,this.state.cursorCol-r),l=t.slice(this.state.cursorCol);this.state.lines[this.state.cursorLine]=o+l,this.setCursorCol(this.state.cursorCol-r)}else if(this.state.cursorLine>0){this.pushUndoSnapshot();const t=this.state.lines[this.state.cursorLine]||"",e=this.state.lines[this.state.cursorLine-1]||"";this.state.lines[this.state.cursorLine-1]=e+t,this.state.lines.splice(this.state.cursorLine,1),this.state.cursorLine--,this.setCursorCol(e.length)}if(this.onChange&&this.onChange(this.getText()),this.autocompleteState)this.updateAutocomplete();else{const e=(this.state.lines[this.state.cursorLine]||"").slice(0,this.state.cursorCol);this.isInSlashCommandContext(e)?this.tryTriggerAutocomplete():this.autocompleteTriggerPattern.test(e)&&this.tryTriggerAutocomplete()}}setCursorCol(t){this.state.cursorCol=t,this.preferredVisualCol=null,this.snappedFromCursorCol=null}moveToVisualLine(t,e,s){const i=t[e],r=t[s];if(!(i&&r))return;let n;if(this.snappedFromCursorCol!==null){const C=this.findVisualLineAt(t,i.logicalLine,this.snappedFromCursorCol);n=this.snappedFromCursorCol-t[C].startCol}else n=this.state.cursorCol-i.startCol;const l=e===t.length-1||t[e+1]?.logicalLine!==i.logicalLine?i.length:Math.max(0,i.length-1),c=s===t.length-1||t[s+1]?.logicalLine!==r.logicalLine?r.length:Math.max(0,r.length-1),u=this.computeVerticalMoveColumn(n,l,c);this.state.cursorLine=r.logicalLine;const d=r.startCol+u,p=this.state.lines[r.logicalLine]||"";this.state.cursorCol=Math.min(d,p.length);const f=[...this.segment(p,"grapheme")];for(const C of f){if(C.index>this.state.cursorCol)break;if(!(C.segment.length<=1)&&this.state.cursorCol<C.index+C.segment.length){const g=C.index<r.startCol,m=s>e;if(g&&m){const A=C.index+C.segment.length;let L=s+1;for(;L<t.length&&t[L].logicalLine===r.logicalLine&&t[L].startCol<A;)L++;if(L<t.length){this.moveToVisualLine(t,e,L);return}}this.snappedFromCursorCol=this.state.cursorCol,this.state.cursorCol=C.index;return}}this.snappedFromCursorCol=null}computeVerticalMoveColumn(t,e,s){const i=this.preferredVisualCol!==null,r=t<e,n=s<t;if(!i||r)return n?(this.preferredVisualCol=t,s):(this.preferredVisualCol=null,t);const o=s<this.preferredVisualCol;if(n||o)return s;const l=this.preferredVisualCol;return this.preferredVisualCol=null,l}moveToLineStart(){this.lastAction=null,this.setCursorCol(0)}moveToLineEnd(){this.lastAction=null;const t=this.state.lines[this.state.cursorLine]||"";this.setCursorCol(t.length)}deleteToStartOfLine(){this.exitHistoryBrowsing();const t=this.state.lines[this.state.cursorLine]||"";if(this.state.cursorCol>0){this.pushUndoSnapshot();const e=t.slice(0,this.state.cursorCol);this.killRing.push(e,{prepend:!0,accumulate:this.lastAction==="kill"}),this.lastAction="kill",this.state.lines[this.state.cursorLine]=t.slice(this.state.cursorCol),this.setCursorCol(0)}else if(this.state.cursorLine>0){this.pushUndoSnapshot(),this.killRing.push(`
11
+ `)).trim();this.state={lines:[""],cursorLine:0,cursorCol:0},this.pastes.clear(),this.pasteCounter=0,this.exitHistoryBrowsing(),this.scrollOffset=0,this.undoStack.clear(),this.lastAction=null,this.onChange&&this.onChange(""),this.onSubmit&&this.onSubmit(t)}handleBackspace(){if(this.exitHistoryBrowsing(),this.lastAction=null,this.state.cursorCol>0){this.pushUndoSnapshot();let t=this.state.lines[this.state.cursorLine]||"";const e=t.slice(0,this.state.cursorCol),s=[...this.segment(e,"grapheme")],i=s[s.length-1],r=i?i.segment.length:1,n=_.exec(i.segment);if(n){const h=Number(n[1]);this.pastes.delete(h),this.pasteCounter--;const c=[...this.pastes.keys()].filter(u=>u>h).sort((u,d)=>u-d);for(const u of c)this.pastes.set(u-1,this.pastes.get(u)),this.pastes.delete(u);this.state.lines=this.state.lines.map(u=>u.replace(N,(d,p,f)=>{const C=Number(p);return C<=h?d:`[paste #${C-1}${f??""}]`}))}t=this.state.lines[this.state.cursorLine]||"";const o=t.slice(0,this.state.cursorCol-r),l=t.slice(this.state.cursorCol);this.state.lines[this.state.cursorLine]=o+l,this.setCursorCol(this.state.cursorCol-r)}else if(this.state.cursorLine>0){this.pushUndoSnapshot();const t=this.state.lines[this.state.cursorLine]||"",e=this.state.lines[this.state.cursorLine-1]||"";this.state.lines[this.state.cursorLine-1]=e+t,this.state.lines.splice(this.state.cursorLine,1),this.state.cursorLine--,this.setCursorCol(e.length)}if(this.onChange&&this.onChange(this.getText()),this.autocompleteState)this.updateAutocomplete();else{const e=(this.state.lines[this.state.cursorLine]||"").slice(0,this.state.cursorCol);this.isInSlashCommandContext(e)?this.tryTriggerAutocomplete():this.autocompleteTriggerPattern.test(e)&&this.tryTriggerAutocomplete()}}setCursorCol(t){this.state.cursorCol=t,this.preferredVisualCol=null,this.snappedFromCursorCol=null}moveToVisualLine(t,e,s){const i=t[e],r=t[s];if(!(i&&r))return;let n;if(this.snappedFromCursorCol!==null){const C=this.findVisualLineAt(t,i.logicalLine,this.snappedFromCursorCol);n=this.snappedFromCursorCol-t[C].startCol}else n=this.state.cursorCol-i.startCol;const l=e===t.length-1||t[e+1]?.logicalLine!==i.logicalLine?i.length:Math.max(0,i.length-1),c=s===t.length-1||t[s+1]?.logicalLine!==r.logicalLine?r.length:Math.max(0,r.length-1),u=this.computeVerticalMoveColumn(n,l,c);this.state.cursorLine=r.logicalLine;const d=r.startCol+u,p=this.state.lines[r.logicalLine]||"";this.state.cursorCol=Math.min(d,p.length);const f=[...this.segment(p,"grapheme")];for(const C of f){if(C.index>this.state.cursorCol)break;if(!(C.segment.length<=1)&&this.state.cursorCol<C.index+C.segment.length){const g=C.index<r.startCol,m=s>e;if(g&&m){const A=C.index+C.segment.length;let L=s+1;for(;L<t.length&&t[L].logicalLine===r.logicalLine&&t[L].startCol<A;)L++;if(L<t.length){this.moveToVisualLine(t,e,L);return}}this.snappedFromCursorCol=this.state.cursorCol,this.state.cursorCol=C.index;return}}this.snappedFromCursorCol=null}computeVerticalMoveColumn(t,e,s){const i=this.preferredVisualCol!==null,r=t<e,n=s<t;if(!i||r)return n?(this.preferredVisualCol=t,s):(this.preferredVisualCol=null,t);const o=s<this.preferredVisualCol;if(n||o)return s;const l=this.preferredVisualCol;return this.preferredVisualCol=null,l}moveToLineStart(){this.lastAction=null,this.setCursorCol(0)}moveToLineEnd(){this.lastAction=null;const t=this.state.lines[this.state.cursorLine]||"";this.setCursorCol(t.length)}deleteToStartOfLine(){this.exitHistoryBrowsing();const t=this.state.lines[this.state.cursorLine]||"";if(this.state.cursorCol>0){this.pushUndoSnapshot();const e=t.slice(0,this.state.cursorCol);this.killRing.push(e,{prepend:!0,accumulate:this.lastAction==="kill"}),this.lastAction="kill",this.state.lines[this.state.cursorLine]=t.slice(this.state.cursorCol),this.setCursorCol(0)}else if(this.state.cursorLine>0){this.pushUndoSnapshot(),this.killRing.push(`
12
12
  `,{prepend:!0,accumulate:this.lastAction==="kill"}),this.lastAction="kill";const e=this.state.lines[this.state.cursorLine-1]||"";this.state.lines[this.state.cursorLine-1]=e+t,this.state.lines.splice(this.state.cursorLine,1),this.state.cursorLine--,this.setCursorCol(e.length)}this.onChange&&this.onChange(this.getText())}deleteToEndOfLine(){this.exitHistoryBrowsing();const t=this.state.lines[this.state.cursorLine]||"";if(this.state.cursorCol<t.length){this.pushUndoSnapshot();const e=t.slice(this.state.cursorCol);this.killRing.push(e,{prepend:!1,accumulate:this.lastAction==="kill"}),this.lastAction="kill",this.state.lines[this.state.cursorLine]=t.slice(0,this.state.cursorCol)}else if(this.state.cursorLine<this.state.lines.length-1){this.pushUndoSnapshot(),this.killRing.push(`
13
13
  `,{prepend:!1,accumulate:this.lastAction==="kill"}),this.lastAction="kill";const e=this.state.lines[this.state.cursorLine+1]||"";this.state.lines[this.state.cursorLine]=t+e,this.state.lines.splice(this.state.cursorLine+1,1)}this.onChange&&this.onChange(this.getText())}deleteWordBackwards(){this.exitHistoryBrowsing();const t=this.state.lines[this.state.cursorLine]||"";if(this.state.cursorCol===0){if(this.state.cursorLine>0){this.pushUndoSnapshot(),this.killRing.push(`
14
14
  `,{prepend:!0,accumulate:this.lastAction==="kill"}),this.lastAction="kill";const e=this.state.lines[this.state.cursorLine-1]||"";this.state.lines[this.state.cursorLine-1]=e+t,this.state.lines.splice(this.state.cursorLine,1),this.state.cursorLine--,this.setCursorCol(e.length)}}else{this.pushUndoSnapshot();const e=this.lastAction==="kill",s=this.state.cursorCol;this.moveWordBackwards();const i=this.state.cursorCol;this.setCursorCol(s);const r=t.slice(i,this.state.cursorCol);this.killRing.push(r,{prepend:!0,accumulate:e}),this.lastAction="kill",this.state.lines[this.state.cursorLine]=t.slice(0,i)+t.slice(this.state.cursorCol),this.setCursorCol(i)}this.onChange&&this.onChange(this.getText())}deleteWordForward(){this.exitHistoryBrowsing();const t=this.state.lines[this.state.cursorLine]||"";if(this.state.cursorCol>=t.length){if(this.state.cursorLine<this.state.lines.length-1){this.pushUndoSnapshot(),this.killRing.push(`
@@ -43,10 +43,14 @@ export declare class Markdown implements Component {
43
43
  private cachedWidth?;
44
44
  private cachedLines?;
45
45
  private cachedTokens?;
46
+ private blocks?;
47
+ private blockHighlightedCode?;
46
48
  constructor(text: string, paddingX: number, paddingY: number, theme: MarkdownTheme, defaultTextStyle?: DefaultTextStyle, options?: MarkdownOptions);
47
49
  setText(text: string): void;
48
50
  invalidate(): void;
51
+ private clearRenderCache;
49
52
  render(width: number): string[];
53
+ private renderBlock;
50
54
  private applyDefaultStyle;
51
55
  private getDefaultStylePrefix;
52
56
  private getStylePrefix;