@mindistryx/pi-arabic-runtime 0.0.0-stage → 1.0.0-beta.2

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 (451) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +26 -2
  3. package/THIRD-PARTY-NOTICES.md +17 -0
  4. package/arguments.mjs +20 -0
  5. package/extension/command.mjs +31 -0
  6. package/extension/extension.mjs +32 -0
  7. package/extension/mode.mjs +48 -0
  8. package/extension/reader.mjs +33 -0
  9. package/launcher.mjs +34 -0
  10. package/licenses/Apache-2.0.txt +201 -0
  11. package/licenses/Unicode-3.0.txt +39 -0
  12. package/licenses/_anthropic-ai_sdk-0.129.0-LICENSE +8 -0
  13. package/licenses/_aws-sdk_client-bedrock-runtime-3.1127.0-LICENSE +201 -0
  14. package/licenses/_aws-sdk_core-3.977.9-LICENSE +201 -0
  15. package/licenses/_aws-sdk_credential-provider-env-3.972.70-LICENSE +201 -0
  16. package/licenses/_aws-sdk_credential-provider-ini-3.973.15-LICENSE +201 -0
  17. package/licenses/_aws-sdk_credential-provider-node-3.972.82-LICENSE +201 -0
  18. package/licenses/_aws-sdk_credential-provider-process-3.972.70-LICENSE +201 -0
  19. package/licenses/_aws-sdk_credential-provider-sso-3.973.14-LICENSE +201 -0
  20. package/licenses/_aws-sdk_credential-provider-web-identity-3.972.76-LICENSE +201 -0
  21. package/licenses/_aws-sdk_eventstream-handler-node-3.972.34-LICENSE +201 -0
  22. package/licenses/_aws-sdk_middleware-eventstream-3.972.29-LICENSE +201 -0
  23. package/licenses/_aws-sdk_middleware-websocket-3.972.52-LICENSE +201 -0
  24. package/licenses/_aws-sdk_signature-v4-multi-region-3.996.46-LICENSE +201 -0
  25. package/licenses/_aws-sdk_token-providers-3.1116.0-LICENSE +201 -0
  26. package/licenses/_aws-sdk_token-providers-3.1127.0-LICENSE +201 -0
  27. package/licenses/_aws-sdk_types-3.974.5-LICENSE +201 -0
  28. package/licenses/_aws-sdk_xml-builder-3.972.40-LICENSE +201 -0
  29. package/licenses/_aws_lambda-invoke-store-0.3.0-LICENSE +175 -0
  30. package/licenses/_babel_runtime-7.29.10-LICENSE +22 -0
  31. package/licenses/_google_genai-3.6.1-LICENSE +202 -0
  32. package/licenses/_isaacs_nonrecursive-glob-match-1.1.0-LICENSE.md +55 -0
  33. package/licenses/_protobufjs_aspromise-1.1.2-LICENSE +26 -0
  34. package/licenses/_protobufjs_base64-1.1.2-LICENSE +26 -0
  35. package/licenses/_protobufjs_codegen-2.0.5-LICENSE +26 -0
  36. package/licenses/_protobufjs_eventemitter-1.1.1-LICENSE +26 -0
  37. package/licenses/_protobufjs_fetch-1.1.1-LICENSE +26 -0
  38. package/licenses/_protobufjs_float-1.0.2-LICENSE +26 -0
  39. package/licenses/_protobufjs_path-1.1.2-LICENSE +26 -0
  40. package/licenses/_protobufjs_pool-1.1.0-LICENSE +26 -0
  41. package/licenses/_protobufjs_utf8-1.1.1-LICENSE +26 -0
  42. package/licenses/_silvia-odwyer_photon-node-0.3.4-LICENSE.md +201 -0
  43. package/licenses/_smithy_core-3.33.3-LICENSE +201 -0
  44. package/licenses/_smithy_credential-provider-imds-4.5.2-LICENSE +201 -0
  45. package/licenses/_smithy_fetch-http-handler-5.8.0-LICENSE +201 -0
  46. package/licenses/_smithy_node-http-handler-4.12.1-LICENSE +201 -0
  47. package/licenses/_smithy_signature-v4-5.7.3-LICENSE +201 -0
  48. package/licenses/_smithy_types-4.18.0-LICENSE +201 -0
  49. package/licenses/_stablelib_base64-1.0.1-LICENSE +21 -0
  50. package/licenses/_types_node-22.19.19-LICENSE +21 -0
  51. package/licenses/_types_retry-0.12.0-LICENSE +21 -0
  52. package/licenses/agent-base-7.1.4-LICENSE +22 -0
  53. package/licenses/agent-base-9.0.0-LICENSE +22 -0
  54. package/licenses/balanced-match-4.0.4-LICENSE.md +23 -0
  55. package/licenses/base64-js-1.5.1-LICENSE +21 -0
  56. package/licenses/bidi-js-1.1.0-LICENSE.txt +22 -0
  57. package/licenses/bignumber.js-9.3.1-LICENCE.md +26 -0
  58. package/licenses/bowser-2.14.1-LICENSE +39 -0
  59. package/licenses/brace-expansion-5.0.12-LICENSE +23 -0
  60. package/licenses/buffer-equal-constant-time-1.0.1-LICENSE.txt +12 -0
  61. package/licenses/chalk-6.0.0-license +9 -0
  62. package/licenses/cross-spawn-7.1.2-LICENSE +21 -0
  63. package/licenses/data-uri-to-buffer-4.0.1-LICENSE.generated.txt +22 -0
  64. package/licenses/debug-4.4.3-LICENSE +20 -0
  65. package/licenses/dependency-index.json +994 -0
  66. package/licenses/diff-8.0.4-LICENSE +29 -0
  67. package/licenses/ecdsa-sig-formatter-1.0.11-LICENSE +201 -0
  68. package/licenses/extend-3.0.2-LICENSE +23 -0
  69. package/licenses/fast-sha256-1.3.0-LICENSE +24 -0
  70. package/licenses/fetch-blob-3.2.0-LICENSE +21 -0
  71. package/licenses/formdata-polyfill-4.0.10-LICENSE +21 -0
  72. package/licenses/gaxios-7.1.4-LICENSE +202 -0
  73. package/licenses/gcp-metadata-8.1.2-LICENSE +202 -0
  74. package/licenses/get-east-asian-width-1.6.0-license +9 -0
  75. package/licenses/google-auth-library-10.6.2-LICENSE +202 -0
  76. package/licenses/google-logging-utils-1.1.3-LICENSE +202 -0
  77. package/licenses/graceful-fs-4.2.11-LICENSE +15 -0
  78. package/licenses/highlight.js-10.7.3-LICENSE +29 -0
  79. package/licenses/hosted-git-info-9.0.3-LICENSE +13 -0
  80. package/licenses/http-proxy-agent-9.1.0-LICENSE +22 -0
  81. package/licenses/https-proxy-agent-7.0.6-LICENSE +22 -0
  82. package/licenses/https-proxy-agent-9.1.0-LICENSE +22 -0
  83. package/licenses/ignore-7.0.8-LICENSE-MIT +21 -0
  84. package/licenses/isexe-2.0.0-LICENSE +15 -0
  85. package/licenses/jiti-2.7.0-LICENSE +21 -0
  86. package/licenses/json-bigint-1.0.0-LICENSE +20 -0
  87. package/licenses/json-schema-to-ts-3.1.1-LICENSE +21 -0
  88. package/licenses/jwa-2.0.1-LICENSE +17 -0
  89. package/licenses/jws-4.0.1-LICENSE +17 -0
  90. package/licenses/long-5.3.2-LICENSE +202 -0
  91. package/licenses/lovely-mermaid-0.3.3-LICENSE +205 -0
  92. package/licenses/lru-cache-11.4.0-LICENSE.md +55 -0
  93. package/licenses/marked-18.0.11-LICENSE +44 -0
  94. package/licenses/marked-cjk-friendly-0.1.2-LICENSE +22 -0
  95. package/licenses/mcp/modelcontextprotocol-typescript-sdk.txt +21 -0
  96. package/licenses/minimatch-11.0.9-LICENSE.md +55 -0
  97. package/licenses/ms-2.1.3-license.md +21 -0
  98. package/licenses/node-domexception-1.0.0-LICENSE +21 -0
  99. package/licenses/node-fetch-3.3.2-LICENSE.md +22 -0
  100. package/licenses/openai-7.59.0-LICENSE +201 -0
  101. package/licenses/p-retry-4.6.2-license +9 -0
  102. package/licenses/partial-json-0.1.7-LICENSE +21 -0
  103. package/licenses/path-key-3.1.1-license +9 -0
  104. package/licenses/proper-lockfile-4.1.2-LICENSE +21 -0
  105. package/licenses/protobufjs-7.6.6-LICENSE +39 -0
  106. package/licenses/proxy-agent-negotiate-1.1.0-LICENSE.generated.txt +22 -0
  107. package/licenses/quickjs-wasi-3.6.2-LICENSE +21 -0
  108. package/licenses/require-from-string-2.0.2-license +21 -0
  109. package/licenses/retry-0.12.0-License +21 -0
  110. package/licenses/retry-0.13.1-License +21 -0
  111. package/licenses/safe-buffer-5.2.1-LICENSE +21 -0
  112. package/licenses/schema/typebox-LICENSE +23 -0
  113. package/licenses/semver-7.8.5-LICENSE +15 -0
  114. package/licenses/shebang-command-2.0.0-license +9 -0
  115. package/licenses/shebang-regex-3.0.0-license +9 -0
  116. package/licenses/signal-exit-3.0.7-LICENSE.txt +16 -0
  117. package/licenses/standardwebhooks-1.1.1-LICENSE.generated.txt +22 -0
  118. package/licenses/ts-algebra-2.0.0-LICENSE +21 -0
  119. package/licenses/tslib-2.8.1-LICENSE.txt +12 -0
  120. package/licenses/typebox-1.3.27-license +23 -0
  121. package/licenses/undici-8.12.4-LICENSE +21 -0
  122. package/licenses/undici-types-6.21.0-LICENSE +21 -0
  123. package/licenses/upstream-pi.MIT.txt +21 -0
  124. package/licenses/web-streams-polyfill-3.3.3-LICENSE +22 -0
  125. package/licenses/which-2.0.2-LICENSE +15 -0
  126. package/licenses/ws-8.23.1-LICENSE +20 -0
  127. package/licenses/yaml-2.9.0-LICENSE +13 -0
  128. package/package.json +46 -4
  129. package/pi/CHANGELOG.md +6869 -0
  130. package/pi/README.md +95 -0
  131. package/pi/dist/bundle/chunks/anthropic-messages-TZF4LOZ3.js +3 -0
  132. package/pi/dist/bundle/chunks/anthropic.js +75 -0
  133. package/pi/dist/bundle/chunks/azure-openai-responses-OPCDWPFL.js +2 -0
  134. package/pi/dist/bundle/chunks/bedrock-converse-stream.js +89 -0
  135. package/pi/dist/bundle/chunks/chunk-2BKJ4UF2.js +6 -0
  136. package/pi/dist/bundle/chunks/chunk-3TDGKLEK.js +4 -0
  137. package/pi/dist/bundle/chunks/chunk-4L3MQGA6.js +2 -0
  138. package/pi/dist/bundle/chunks/chunk-4MIF4MCH.js +2 -0
  139. package/pi/dist/bundle/chunks/chunk-4OXX5KPU.js +1237 -0
  140. package/pi/dist/bundle/chunks/chunk-5AGIVGSV.js +6 -0
  141. package/pi/dist/bundle/chunks/chunk-6F2YCHJI.js +55 -0
  142. package/pi/dist/bundle/chunks/chunk-6MVVCNIJ.js +2 -0
  143. package/pi/dist/bundle/chunks/chunk-6QGV3IWD.js +6 -0
  144. package/pi/dist/bundle/chunks/chunk-7CBJINYJ.js +20 -0
  145. package/pi/dist/bundle/chunks/chunk-7DDKXS2Q.js +2 -0
  146. package/pi/dist/bundle/chunks/chunk-7ZC4UXSL.js +2 -0
  147. package/pi/dist/bundle/chunks/chunk-BSRKXBKS.js +2 -0
  148. package/pi/dist/bundle/chunks/chunk-BXIXP3HJ.js +16 -0
  149. package/pi/dist/bundle/chunks/chunk-E3JXGAHC.js +2 -0
  150. package/pi/dist/bundle/chunks/chunk-EANOEWGP.js +2 -0
  151. package/pi/dist/bundle/chunks/chunk-FFMDRXC4.js +10 -0
  152. package/pi/dist/bundle/chunks/chunk-H5S7TE7A.js +20 -0
  153. package/pi/dist/bundle/chunks/chunk-IEBK4HQA.js +2 -0
  154. package/pi/dist/bundle/chunks/chunk-IKKTFUAW.js +82 -0
  155. package/pi/dist/bundle/chunks/chunk-INODY4DR.js +2 -0
  156. package/pi/dist/bundle/chunks/chunk-JCDBIE47.js +131 -0
  157. package/pi/dist/bundle/chunks/chunk-JXWJOIH4.js +2 -0
  158. package/pi/dist/bundle/chunks/chunk-KBNQNV33.js +8 -0
  159. package/pi/dist/bundle/chunks/chunk-L2ZPNLYD.js +2 -0
  160. package/pi/dist/bundle/chunks/chunk-L6EYYEJG.js +2 -0
  161. package/pi/dist/bundle/chunks/chunk-LPXNMA2W.js +2 -0
  162. package/pi/dist/bundle/chunks/chunk-LVVZS2NO.js +12 -0
  163. package/pi/dist/bundle/chunks/chunk-LWG2CUTI.js +31 -0
  164. package/pi/dist/bundle/chunks/chunk-OVXT2WQH.js +2 -0
  165. package/pi/dist/bundle/chunks/chunk-P7FPUEYA.js +2 -0
  166. package/pi/dist/bundle/chunks/chunk-PGXDEOVV.js +2 -0
  167. package/pi/dist/bundle/chunks/chunk-PHM5C7IG.js +9 -0
  168. package/pi/dist/bundle/chunks/chunk-PJACZCIR.js +2 -0
  169. package/pi/dist/bundle/chunks/chunk-PRRNXB7S.js +2 -0
  170. package/pi/dist/bundle/chunks/chunk-QGY2QT6O.js +30 -0
  171. package/pi/dist/bundle/chunks/chunk-QLVTCW2U.js +2 -0
  172. package/pi/dist/bundle/chunks/chunk-RDZVAGPR.js +2 -0
  173. package/pi/dist/bundle/chunks/chunk-SSLDNFEJ.js +2 -0
  174. package/pi/dist/bundle/chunks/chunk-TMTOQ7H7.js +2 -0
  175. package/pi/dist/bundle/chunks/chunk-UTB4DTYQ.js +2 -0
  176. package/pi/dist/bundle/chunks/chunk-WHLWHMLX.js +14 -0
  177. package/pi/dist/bundle/chunks/chunk-YMIUSQL3.js +44 -0
  178. package/pi/dist/bundle/chunks/chunk-ZFO73KYQ.js +2 -0
  179. package/pi/dist/bundle/chunks/chunk-ZG74NES2.js +2 -0
  180. package/pi/dist/bundle/chunks/cli-66VDVHXA.js +53 -0
  181. package/pi/dist/bundle/chunks/cloudflare-workers-ai-system-one-BCB6I5BD.js +2 -0
  182. package/pi/dist/bundle/chunks/codemode-worker.js +480 -0
  183. package/pi/dist/bundle/chunks/easter-egg-3d-2XVDERXF.js +2 -0
  184. package/pi/dist/bundle/chunks/execute-CLOD3DVG.js +507 -0
  185. package/pi/dist/bundle/chunks/github-copilot.js +2 -0
  186. package/pi/dist/bundle/chunks/google-generative-ai-YXFPI4IA.js +2 -0
  187. package/pi/dist/bundle/chunks/google-vertex-SI54R6EC.js +2 -0
  188. package/pi/dist/bundle/chunks/https-proxy-agent-LVOO5TPL.js +13 -0
  189. package/pi/dist/bundle/chunks/image-resize-worker.js +2 -0
  190. package/pi/dist/bundle/chunks/jiti-loader-GL4HJFAD.js +21 -0
  191. package/pi/dist/bundle/chunks/jiti-static-loader-2RCDI6B4.js +2 -0
  192. package/pi/dist/bundle/chunks/kimi-coding.js +2 -0
  193. package/pi/dist/bundle/chunks/lib-4AVRLBHM.js +9 -0
  194. package/pi/dist/bundle/chunks/llama-cpp-classify-PRGRPOMM.js +22 -0
  195. package/pi/dist/bundle/chunks/meta.js +2 -0
  196. package/pi/dist/bundle/chunks/mistral-conversations-D5VW6GSS.js +4 -0
  197. package/pi/dist/bundle/chunks/multipart-parser-FMGQ7342.js +3 -0
  198. package/pi/dist/bundle/chunks/node-AUOGOBCN.js +2 -0
  199. package/pi/dist/bundle/chunks/node-KCMANYC2.js +16 -0
  200. package/pi/dist/bundle/chunks/openai-chatgpt.js +75 -0
  201. package/pi/dist/bundle/chunks/openai-codex-responses-NM5HSETG.js +2 -0
  202. package/pi/dist/bundle/chunks/openai-codex.js +75 -0
  203. package/pi/dist/bundle/chunks/openai-completions-QZF567FN.js +7 -0
  204. package/pi/dist/bundle/chunks/openai-decisions-YJYDQHYN.js +5 -0
  205. package/pi/dist/bundle/chunks/openai-responses-AVMLOXIQ.js +4 -0
  206. package/pi/dist/bundle/chunks/openrouter-chat-images-3V4TR7TT.js +2 -0
  207. package/pi/dist/bundle/chunks/openrouter-images-UBTJFBR6.js +4 -0
  208. package/pi/dist/bundle/chunks/openrouter.js +75 -0
  209. package/pi/dist/bundle/chunks/pi-decision-XC3CEYXE.js +2 -0
  210. package/pi/dist/bundle/chunks/pi-image-GRYH565R.js +2 -0
  211. package/pi/dist/bundle/chunks/pi-messages-5Z2U3PEK.js +2 -0
  212. package/pi/dist/bundle/chunks/radius.js +75 -0
  213. package/pi/dist/bundle/chunks/runtime-PSL6AEOU.js +2 -0
  214. package/pi/dist/bundle/chunks/src-QKGKDFSU.js +4 -0
  215. package/pi/dist/bundle/chunks/typesafe-system-one-3JC45JJT.js +2 -0
  216. package/pi/dist/bundle/chunks/virtual-modules-AG72WCIK.js +2 -0
  217. package/pi/dist/bundle/chunks/xai.js +2 -0
  218. package/pi/dist/bundle/cli-runtime.js +3 -0
  219. package/pi/dist/bundle/cli.js +5 -0
  220. package/pi/dist/bundle/index.js +2 -0
  221. package/pi/dist/bundle/native/darwin/prebuilds/darwin-arm64/darwin-platform.node +0 -0
  222. package/pi/dist/bundle/native/darwin/prebuilds/darwin-x64/darwin-platform.node +0 -0
  223. package/pi/dist/bundle/native/linux/prebuilds/linux-arm64/linux-platform-x11.node +0 -0
  224. package/pi/dist/bundle/native/linux/prebuilds/linux-x64/linux-platform-x11.node +0 -0
  225. package/pi/dist/bundle/native/win32/prebuilds/win32-arm64/win32-platform.node +0 -0
  226. package/pi/dist/bundle/native/win32/prebuilds/win32-x64/win32-platform.node +0 -0
  227. package/pi/dist/bundle/rpc-entry.js +3 -0
  228. package/pi/dist/core/export-html/ansi-to-html.d.ts +27 -0
  229. package/pi/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
  230. package/pi/dist/core/export-html/ansi-to-html.js +286 -0
  231. package/pi/dist/core/export-html/ansi-to-html.js.map +1 -0
  232. package/pi/dist/core/export-html/index.d.ts +37 -0
  233. package/pi/dist/core/export-html/index.d.ts.map +1 -0
  234. package/pi/dist/core/export-html/index.js +230 -0
  235. package/pi/dist/core/export-html/index.js.map +1 -0
  236. package/pi/dist/core/export-html/template.css +1085 -0
  237. package/pi/dist/core/export-html/template.html +56 -0
  238. package/pi/dist/core/export-html/template.js +2044 -0
  239. package/pi/dist/core/export-html/tool-renderer.d.ts +34 -0
  240. package/pi/dist/core/export-html/tool-renderer.d.ts.map +1 -0
  241. package/pi/dist/core/export-html/tool-renderer.js +112 -0
  242. package/pi/dist/core/export-html/tool-renderer.js.map +1 -0
  243. package/pi/dist/core/export-html/vendor/highlight.min.js +1213 -0
  244. package/pi/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
  245. package/pi/dist/core/export-html/vendor/marked.min.js +79 -0
  246. package/pi/dist/modes/interactive/assets/clankolas.png +0 -0
  247. package/pi/dist/modes/interactive/theme/dark.json +78 -0
  248. package/pi/dist/modes/interactive/theme/light.json +78 -0
  249. package/pi/dist/modes/interactive/theme/system-theme.d.ts +55 -0
  250. package/pi/dist/modes/interactive/theme/system-theme.d.ts.map +1 -0
  251. package/pi/dist/modes/interactive/theme/system-theme.js +546 -0
  252. package/pi/dist/modes/interactive/theme/system-theme.js.map +1 -0
  253. package/pi/dist/modes/interactive/theme/theme-controller.d.ts +81 -0
  254. package/pi/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -0
  255. package/pi/dist/modes/interactive/theme/theme-controller.js +210 -0
  256. package/pi/dist/modes/interactive/theme/theme-controller.js.map +1 -0
  257. package/pi/dist/modes/interactive/theme/theme-schema.d.ts +28 -0
  258. package/pi/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -0
  259. package/pi/dist/modes/interactive/theme/theme-schema.js +105 -0
  260. package/pi/dist/modes/interactive/theme/theme-schema.js.map +1 -0
  261. package/pi/dist/modes/interactive/theme/theme-tokens.d.ts +257 -0
  262. package/pi/dist/modes/interactive/theme/theme-tokens.d.ts.map +1 -0
  263. package/pi/dist/modes/interactive/theme/theme-tokens.js +94 -0
  264. package/pi/dist/modes/interactive/theme/theme-tokens.js.map +1 -0
  265. package/pi/dist/modes/interactive/theme/theme.d.ts +165 -0
  266. package/pi/dist/modes/interactive/theme/theme.d.ts.map +1 -0
  267. package/pi/dist/modes/interactive/theme/theme.js +918 -0
  268. package/pi/dist/modes/interactive/theme/theme.js.map +1 -0
  269. package/pi/docs/cli-integration.md +106 -0
  270. package/pi/docs/cli.md +358 -0
  271. package/pi/docs/codemode.md +241 -0
  272. package/pi/docs/compaction.md +463 -0
  273. package/pi/docs/configuration.md +47 -0
  274. package/pi/docs/containerization.md +183 -0
  275. package/pi/docs/custom-provider.md +227 -0
  276. package/pi/docs/docs.json +224 -0
  277. package/pi/docs/environment-variables.md +104 -0
  278. package/pi/docs/extensions.md +3394 -0
  279. package/pi/docs/how-pi-works.md +49 -0
  280. package/pi/docs/images/doom-extension.png +0 -0
  281. package/pi/docs/images/exy.png +0 -0
  282. package/pi/docs/images/interactive-mode.png +0 -0
  283. package/pi/docs/images/tree-view.png +0 -0
  284. package/pi/docs/index.md +39 -0
  285. package/pi/docs/json.md +226 -0
  286. package/pi/docs/keybindings.md +195 -0
  287. package/pi/docs/llama-cpp.md +138 -0
  288. package/pi/docs/mcp.md +301 -0
  289. package/pi/docs/message-types.md +280 -0
  290. package/pi/docs/models-configuration.md +213 -0
  291. package/pi/docs/models.md +248 -0
  292. package/pi/docs/nvidia-rtx-llama-cpp.md +96 -0
  293. package/pi/docs/packages.md +153 -0
  294. package/pi/docs/prompt-templates.md +59 -0
  295. package/pi/docs/providers.md +251 -0
  296. package/pi/docs/quickstart.md +140 -0
  297. package/pi/docs/rpc-commands.md +860 -0
  298. package/pi/docs/rpc-extension-ui.md +200 -0
  299. package/pi/docs/rpc.md +195 -0
  300. package/pi/docs/sdk.md +147 -0
  301. package/pi/docs/security.md +99 -0
  302. package/pi/docs/session-format.md +293 -0
  303. package/pi/docs/sessions.md +82 -0
  304. package/pi/docs/settings.md +175 -0
  305. package/pi/docs/shell-aliases.md +93 -0
  306. package/pi/docs/skills.md +93 -0
  307. package/pi/docs/slash-commands.md +61 -0
  308. package/pi/docs/subscriptions.md +96 -0
  309. package/pi/docs/terminal-setup.md +298 -0
  310. package/pi/docs/termux.md +117 -0
  311. package/pi/docs/themes.md +138 -0
  312. package/pi/docs/tmux.md +61 -0
  313. package/pi/docs/tui.md +199 -0
  314. package/pi/docs/usage.md +94 -0
  315. package/pi/docs/virtual-models.md +114 -0
  316. package/pi/docs/windows.md +109 -0
  317. package/pi/examples/README.md +36 -0
  318. package/pi/examples/extensions/README.md +215 -0
  319. package/pi/examples/extensions/auto-commit-on-exit.ts +49 -0
  320. package/pi/examples/extensions/bash-spawn-hook.ts +30 -0
  321. package/pi/examples/extensions/bookmark.ts +50 -0
  322. package/pi/examples/extensions/border-status-editor.ts +150 -0
  323. package/pi/examples/extensions/built-in-tool-renderer.ts +225 -0
  324. package/pi/examples/extensions/claude-rules.ts +86 -0
  325. package/pi/examples/extensions/commands.ts +72 -0
  326. package/pi/examples/extensions/confirm-destructive.ts +59 -0
  327. package/pi/examples/extensions/custom-compaction.ts +117 -0
  328. package/pi/examples/extensions/custom-footer.ts +64 -0
  329. package/pi/examples/extensions/custom-header.ts +73 -0
  330. package/pi/examples/extensions/custom-provider-anthropic/index.ts +613 -0
  331. package/pi/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
  332. package/pi/examples/extensions/custom-provider-anthropic/package.json +19 -0
  333. package/pi/examples/extensions/custom-provider-gitlab-duo/index.ts +405 -0
  334. package/pi/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
  335. package/pi/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
  336. package/pi/examples/extensions/debug-provider.ts +90 -0
  337. package/pi/examples/extensions/dirty-repo-guard.ts +56 -0
  338. package/pi/examples/extensions/doom-overlay/README.md +46 -0
  339. package/pi/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
  340. package/pi/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
  341. package/pi/examples/extensions/doom-overlay/doom/build.sh +152 -0
  342. package/pi/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
  343. package/pi/examples/extensions/doom-overlay/doom-component.ts +132 -0
  344. package/pi/examples/extensions/doom-overlay/doom-engine.ts +173 -0
  345. package/pi/examples/extensions/doom-overlay/doom-keys.ts +104 -0
  346. package/pi/examples/extensions/doom-overlay/index.ts +74 -0
  347. package/pi/examples/extensions/doom-overlay/wad-finder.ts +55 -0
  348. package/pi/examples/extensions/dynamic-resources/SKILL.md +8 -0
  349. package/pi/examples/extensions/dynamic-resources/dynamic.json +81 -0
  350. package/pi/examples/extensions/dynamic-resources/dynamic.md +5 -0
  351. package/pi/examples/extensions/dynamic-resources/index.ts +15 -0
  352. package/pi/examples/extensions/dynamic-tools.ts +74 -0
  353. package/pi/examples/extensions/entry-renderer.ts +41 -0
  354. package/pi/examples/extensions/event-bus.ts +43 -0
  355. package/pi/examples/extensions/file-trigger.ts +41 -0
  356. package/pi/examples/extensions/git-checkpoint.ts +53 -0
  357. package/pi/examples/extensions/git-merge-and-resolve.ts +115 -0
  358. package/pi/examples/extensions/github-issue-autocomplete.ts +185 -0
  359. package/pi/examples/extensions/gondolin/index.ts +528 -0
  360. package/pi/examples/extensions/gondolin/package-lock.json +175 -0
  361. package/pi/examples/extensions/gondolin/package.json +19 -0
  362. package/pi/examples/extensions/handoff.ts +190 -0
  363. package/pi/examples/extensions/hello.ts +26 -0
  364. package/pi/examples/extensions/hidden-thinking-label.ts +53 -0
  365. package/pi/examples/extensions/inline-bash.ts +94 -0
  366. package/pi/examples/extensions/input-transform-streaming.ts +39 -0
  367. package/pi/examples/extensions/input-transform.ts +43 -0
  368. package/pi/examples/extensions/interactive-shell.ts +196 -0
  369. package/pi/examples/extensions/jev-router.ts +113 -0
  370. package/pi/examples/extensions/mac-system-theme.ts +47 -0
  371. package/pi/examples/extensions/message-renderer.ts +59 -0
  372. package/pi/examples/extensions/minimal-mode.ts +353 -0
  373. package/pi/examples/extensions/modal-editor.ts +85 -0
  374. package/pi/examples/extensions/model-status.ts +31 -0
  375. package/pi/examples/extensions/notify.ts +57 -0
  376. package/pi/examples/extensions/overlay-qa-tests.ts +1456 -0
  377. package/pi/examples/extensions/overlay-test.ts +165 -0
  378. package/pi/examples/extensions/permission-gate.ts +34 -0
  379. package/pi/examples/extensions/pirate.ts +47 -0
  380. package/pi/examples/extensions/plan-mode/README.md +66 -0
  381. package/pi/examples/extensions/plan-mode/index.ts +404 -0
  382. package/pi/examples/extensions/plan-mode/utils.ts +194 -0
  383. package/pi/examples/extensions/preset.ts +438 -0
  384. package/pi/examples/extensions/project-trust.ts +64 -0
  385. package/pi/examples/extensions/prompt-customizer.ts +49 -0
  386. package/pi/examples/extensions/protected-paths.ts +30 -0
  387. package/pi/examples/extensions/provider-payload.ts +18 -0
  388. package/pi/examples/extensions/qna.ts +118 -0
  389. package/pi/examples/extensions/question.ts +286 -0
  390. package/pi/examples/extensions/questionnaire.ts +448 -0
  391. package/pi/examples/extensions/rainbow-editor.ts +88 -0
  392. package/pi/examples/extensions/reload-runtime.ts +49 -0
  393. package/pi/examples/extensions/rpc-demo.ts +118 -0
  394. package/pi/examples/extensions/send-user-message.ts +97 -0
  395. package/pi/examples/extensions/session-name.ts +27 -0
  396. package/pi/examples/extensions/shutdown-command.ts +63 -0
  397. package/pi/examples/extensions/snake.ts +343 -0
  398. package/pi/examples/extensions/space-invaders.ts +560 -0
  399. package/pi/examples/extensions/ssh.ts +220 -0
  400. package/pi/examples/extensions/status-line.ts +32 -0
  401. package/pi/examples/extensions/structured-output.ts +65 -0
  402. package/pi/examples/extensions/subagent/README.md +180 -0
  403. package/pi/examples/extensions/subagent/agents/planner.md +37 -0
  404. package/pi/examples/extensions/subagent/agents/reviewer.md +35 -0
  405. package/pi/examples/extensions/subagent/agents/scout.md +50 -0
  406. package/pi/examples/extensions/subagent/agents/worker.md +24 -0
  407. package/pi/examples/extensions/subagent/agents.ts +157 -0
  408. package/pi/examples/extensions/subagent/index.ts +1258 -0
  409. package/pi/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
  410. package/pi/examples/extensions/subagent/prompts/implement.md +10 -0
  411. package/pi/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
  412. package/pi/examples/extensions/summarize.ts +199 -0
  413. package/pi/examples/extensions/system-prompt-header.ts +17 -0
  414. package/pi/examples/extensions/tic-tac-toe.ts +1008 -0
  415. package/pi/examples/extensions/timed-confirm.ts +70 -0
  416. package/pi/examples/extensions/titlebar-spinner.ts +58 -0
  417. package/pi/examples/extensions/todo.ts +304 -0
  418. package/pi/examples/extensions/tool-override.ts +144 -0
  419. package/pi/examples/extensions/tools.ts +148 -0
  420. package/pi/examples/extensions/trigger-compact.ts +50 -0
  421. package/pi/examples/extensions/truncated-tool.ts +195 -0
  422. package/pi/examples/extensions/widget-placement.ts +9 -0
  423. package/pi/examples/extensions/with-deps/index.ts +32 -0
  424. package/pi/examples/extensions/with-deps/package-lock.json +31 -0
  425. package/pi/examples/extensions/with-deps/package.json +22 -0
  426. package/pi/examples/extensions/working-indicator.ts +123 -0
  427. package/pi/examples/extensions/working-message-test.ts +25 -0
  428. package/pi/examples/rpc-client.ts +35 -0
  429. package/pi/examples/rpc-extension-ui.ts +662 -0
  430. package/pi/examples/sdk/01-minimal.ts +26 -0
  431. package/pi/examples/sdk/02-custom-model.ts +49 -0
  432. package/pi/examples/sdk/03-custom-prompt.ts +75 -0
  433. package/pi/examples/sdk/04-skills.ts +55 -0
  434. package/pi/examples/sdk/05-tools.ts +48 -0
  435. package/pi/examples/sdk/06-extensions.ts +99 -0
  436. package/pi/examples/sdk/07-context-files.ts +47 -0
  437. package/pi/examples/sdk/08-prompt-templates.ts +51 -0
  438. package/pi/examples/sdk/09-api-keys-and-oauth.ts +34 -0
  439. package/pi/examples/sdk/10-settings.ts +53 -0
  440. package/pi/examples/sdk/11-sessions.ts +52 -0
  441. package/pi/examples/sdk/12-full-control.ts +74 -0
  442. package/pi/examples/sdk/13-session-runtime.ts +67 -0
  443. package/pi/examples/sdk/14-codemode-mcp.ts +61 -0
  444. package/pi/examples/sdk/README.md +141 -0
  445. package/pi/examples/tsconfig.json +208 -0
  446. package/pi/package.json +5 -0
  447. package/pi/schemas/keybindings.schema.json +393 -0
  448. package/pi/schemas/mcp.schema.json +306 -0
  449. package/pi/schemas/models.schema.json +1253 -0
  450. package/pi/schemas/settings.schema.json +820 -0
  451. package/pi/schemas/theme.schema.json +365 -0
@@ -0,0 +1,2 @@
1
+ import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
+ import{AgentSession,AgentSessionRuntime,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CURRENT_SESSION_VERSION,CompactionSummaryMessageComponent,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DefaultPackageManager,DefaultResourceLoader,DynamicBorder,ExtensionEditorComponent,ExtensionInputComponent,ExtensionRunner,ExtensionSelectorComponent,FooterComponent,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelSelectorComponent,OAuthSelectorComponent,RpcClient,SessionManager,SessionSelectorComponent,SettingsManager,SettingsSelectorComponent,SkillInvocationMessageComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UserMessageComponent,UserMessageSelectorComponent,buildContextEntries,buildSessionContext,buildSessionProjection,calculateContextTokens,collectEntriesForBranchSummary,compact,convertToLlm,convertToPng,copyToClipboard,createAgentSession,createAgentSessionFromServices,createAgentSessionRuntime,createAgentSessionServices,createBashTool,createBashToolDefinition,createCodemodeExtension,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createLocalBashOperations,createLocalPowerShellOperations,createLsTool,createLsToolDefinition,createMcpExtension,createPowerShellTool,createPowerShellToolDefinition,createReadOnlyTools,createReadTool,createReadToolDefinition,createSyntheticSourceInfo,createToolSearchExtension,createWriteTool,createWriteToolDefinition,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,estimateTokens,findCutPoint,findTurnStartIndex,formatDimensionNote,formatSkillsForPrompt,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getLastAssistantUsage,getLatestCompactionEntry,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isPowerShellToolResult,isReadToolResult,isToolCallEventType,isWriteToolResult,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,migrateSessionEntries,parseArgs,parseFrontmatter,parseSessionEntries,parseSkillBlock,prepareBranchEntries,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runPrintMode,runRpcMode,serializeConversation,sessionEntryToContextMessages,shouldCompact,stripFrontmatter,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools}from"./chunk-4OXX5KPU.js";import{CredentialSynchronizationError,ModelRuntime,ProjectTrustStore,VIRTUAL_MODEL_STATE_ENTRY,hasTrustRequiringProjectResources}from"./chunk-QGY2QT6O.js";import{formatReadLineRange,truncateToVisualLines}from"./chunk-6F2YCHJI.js";import{readStoredCredential}from"./chunk-H5S7TE7A.js";import{DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,SHELL_COMMAND_ENV_VAR,formatSize,getPowerShellConfig,getShellConfig,truncateHead,truncateLine,truncateTail}from"./chunk-WHLWHMLX.js";import{ArminComponent}from"./chunk-4MIF4MCH.js";import{Container,SelectList,Theme,getAvailableThemes,getLanguageFromPath,getMarkdownTheme,getSelectListTheme,getSettingsListTheme,highlightCode,initTheme,keyHint,keyText,rawKeyHint}from"./chunk-JCDBIE47.js";import{CONFIG_DIR_NAME,VERSION,getAgentDir,getDocsPath,getExamplesPath,getPackageDir,getReadmePath}from"./chunk-EANOEWGP.js";import{__export}from"./chunk-JXWJOIH4.js";var dist_exports={};__export(dist_exports,{AgentSession:()=>AgentSession,AgentSessionRuntime:()=>AgentSessionRuntime,ArminComponent:()=>ArminComponent,AssistantMessageComponent:()=>AssistantMessageComponent,BashExecutionComponent:()=>BashExecutionComponent,BorderedLoader:()=>BorderedLoader,BranchSummaryMessageComponent:()=>BranchSummaryMessageComponent,CONFIG_DIR_NAME:()=>CONFIG_DIR_NAME,CURRENT_SESSION_VERSION:()=>CURRENT_SESSION_VERSION,CompactionSummaryMessageComponent:()=>CompactionSummaryMessageComponent,CredentialSynchronizationError:()=>CredentialSynchronizationError,CustomEditor:()=>CustomEditor,CustomMessageComponent:()=>CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS:()=>DEFAULT_COMPACTION_SETTINGS,DEFAULT_MAX_BYTES:()=>DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES:()=>DEFAULT_MAX_LINES,DefaultPackageManager:()=>DefaultPackageManager,DefaultResourceLoader:()=>DefaultResourceLoader,DynamicBorder:()=>DynamicBorder,ExtensionEditorComponent:()=>ExtensionEditorComponent,ExtensionInputComponent:()=>ExtensionInputComponent,ExtensionRunner:()=>ExtensionRunner,ExtensionSelectorComponent:()=>ExtensionSelectorComponent,FooterComponent:()=>FooterComponent,InteractiveMode:()=>InteractiveMode,LoginDialogComponent:()=>LoginDialogComponent,ModelRegistry:()=>ModelRegistry,ModelRuntime:()=>ModelRuntime,ModelSelectorComponent:()=>ModelSelectorComponent,OAuthSelectorComponent:()=>OAuthSelectorComponent,ProjectTrustStore:()=>ProjectTrustStore,RpcClient:()=>RpcClient,SHELL_COMMAND_ENV_VAR:()=>SHELL_COMMAND_ENV_VAR,SessionManager:()=>SessionManager,SessionSelectorComponent:()=>SessionSelectorComponent,SettingsManager:()=>SettingsManager,SettingsSelectorComponent:()=>SettingsSelectorComponent,ShowImagesSelectorComponent:()=>ShowImagesSelectorComponent,SkillInvocationMessageComponent:()=>SkillInvocationMessageComponent,Theme:()=>Theme,ThemeSelectorComponent:()=>ThemeSelectorComponent,ThinkingSelectorComponent:()=>ThinkingSelectorComponent,ToolExecutionComponent:()=>ToolExecutionComponent,TreeSelectorComponent:()=>TreeSelectorComponent,UserMessageComponent:()=>UserMessageComponent,UserMessageSelectorComponent:()=>UserMessageSelectorComponent,VERSION:()=>VERSION,VIRTUAL_MODEL_STATE_ENTRY:()=>VIRTUAL_MODEL_STATE_ENTRY,buildContextEntries:()=>buildContextEntries,buildSessionContext:()=>buildSessionContext,buildSessionProjection:()=>buildSessionProjection,calculateContextTokens:()=>calculateContextTokens,collectEntriesForBranchSummary:()=>collectEntriesForBranchSummary,compact:()=>compact,convertToLlm:()=>convertToLlm,convertToPng:()=>convertToPng,copyToClipboard:()=>copyToClipboard,createAgentSession:()=>createAgentSession,createAgentSessionFromServices:()=>createAgentSessionFromServices,createAgentSessionRuntime:()=>createAgentSessionRuntime,createAgentSessionServices:()=>createAgentSessionServices,createBashTool:()=>createBashTool,createBashToolDefinition:()=>createBashToolDefinition,createCodemodeExtension:()=>createCodemodeExtension,createCodingTools:()=>createCodingTools,createEditTool:()=>createEditTool,createEditToolDefinition:()=>createEditToolDefinition,createEventBus:()=>createEventBus,createExtensionRuntime:()=>createExtensionRuntime,createFindTool:()=>createFindTool,createFindToolDefinition:()=>createFindToolDefinition,createGrepTool:()=>createGrepTool,createGrepToolDefinition:()=>createGrepToolDefinition,createLocalBashOperations:()=>createLocalBashOperations,createLocalPowerShellOperations:()=>createLocalPowerShellOperations,createLsTool:()=>createLsTool,createLsToolDefinition:()=>createLsToolDefinition,createMcpExtension:()=>createMcpExtension,createPowerShellTool:()=>createPowerShellTool,createPowerShellToolDefinition:()=>createPowerShellToolDefinition,createReadOnlyTools:()=>createReadOnlyTools,createReadTool:()=>createReadTool,createReadToolDefinition:()=>createReadToolDefinition,createSyntheticSourceInfo:()=>createSyntheticSourceInfo,createToolSearchExtension:()=>createToolSearchExtension,createWriteTool:()=>createWriteTool,createWriteToolDefinition:()=>createWriteToolDefinition,defineTool:()=>defineTool,detectSupportedImageMimeTypeFromFile:()=>detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions:()=>discoverAndLoadExtensions,estimateTokens:()=>estimateTokens,findCutPoint:()=>findCutPoint,findTurnStartIndex:()=>findTurnStartIndex,formatDimensionNote:()=>formatDimensionNote,formatReadLineRange:()=>formatReadLineRange,formatSize:()=>formatSize,formatSkillsForPrompt:()=>formatSkillsForPrompt,generateBranchSummary:()=>generateBranchSummary,generateDiffString:()=>generateDiffString,generateSummary:()=>generateSummary,generateSummaryWithUsage:()=>generateSummaryWithUsage,generateUnifiedPatch:()=>generateUnifiedPatch,getAgentDir:()=>getAgentDir,getDocsPath:()=>getDocsPath,getExamplesPath:()=>getExamplesPath,getLanguageFromPath:()=>getLanguageFromPath,getLastAssistantUsage:()=>getLastAssistantUsage,getLatestCompactionEntry:()=>getLatestCompactionEntry,getMarkdownTheme:()=>getMarkdownTheme,getPackageDir:()=>getPackageDir,getPowerShellConfig:()=>getPowerShellConfig,getReadmePath:()=>getReadmePath,getSelectListTheme:()=>getSelectListTheme,getSettingsListTheme:()=>getSettingsListTheme,getShellConfig:()=>getShellConfig,hasTrustRequiringProjectResources:()=>hasTrustRequiringProjectResources,highlightCode:()=>highlightCode,initTheme:()=>initTheme,isBashToolResult:()=>isBashToolResult,isEditToolResult:()=>isEditToolResult,isFindToolResult:()=>isFindToolResult,isGrepToolResult:()=>isGrepToolResult,isLsToolResult:()=>isLsToolResult,isPowerShellToolResult:()=>isPowerShellToolResult,isReadToolResult:()=>isReadToolResult,isToolCallEventType:()=>isToolCallEventType,isWriteToolResult:()=>isWriteToolResult,keyHint:()=>keyHint,keyText:()=>keyText,loadProjectContextFiles:()=>loadProjectContextFiles,loadSkills:()=>loadSkills,loadSkillsFromDir:()=>loadSkillsFromDir,main:()=>main,migrateSessionEntries:()=>migrateSessionEntries,parseArgs:()=>parseArgs,parseFrontmatter:()=>parseFrontmatter,parseSessionEntries:()=>parseSessionEntries,parseSkillBlock:()=>parseSkillBlock,prepareBranchEntries:()=>prepareBranchEntries,rawKeyHint:()=>rawKeyHint,readStoredCredential:()=>readStoredCredential,renderDiff:()=>renderDiff,resizeImage:()=>resizeImage,resolveCliModel:()=>resolveCliModel,resolveModelScopeWithDiagnostics:()=>resolveModelScopeWithDiagnostics,runPrintMode:()=>runPrintMode,runRpcMode:()=>runRpcMode,serializeConversation:()=>serializeConversation,sessionEntryToContextMessages:()=>sessionEntryToContextMessages,shouldCompact:()=>shouldCompact,stripFrontmatter:()=>stripFrontmatter,truncateHead:()=>truncateHead,truncateLine:()=>truncateLine,truncateTail:()=>truncateTail,truncateToVisualLines:()=>truncateToVisualLines,withFileMutationQueue:()=>withFileMutationQueue,wrapRegisteredTool:()=>wrapRegisteredTool,wrapRegisteredTools:()=>wrapRegisteredTools});var SHOW_IMAGES_SELECT_LIST_LAYOUT={minPrimaryColumnWidth:12,maxPrimaryColumnWidth:32},ShowImagesSelectorComponent=class extends Container{selectList;constructor(currentValue,onSelect,onCancel){super();let items=[{value:"yes",label:"Yes",description:"Show images inline in terminal"},{value:"no",label:"No",description:"Show text placeholder instead"}];this.addChild(new DynamicBorder),this.selectList=new SelectList(items,5,getSelectListTheme(),SHOW_IMAGES_SELECT_LIST_LAYOUT),this.selectList.setSelectedIndex(currentValue?0:1),this.selectList.onSelect=item=>{onSelect(item.value==="yes")},this.selectList.onCancel=()=>{onCancel()},this.addChild(this.selectList),this.addChild(new DynamicBorder)}getSelectList(){return this.selectList}};var THEME_SELECT_LIST_LAYOUT={minPrimaryColumnWidth:12,maxPrimaryColumnWidth:32},ThemeSelectorComponent=class extends Container{selectList;onPreview;constructor(currentTheme,onSelect,onCancel,onPreview){super(),this.onPreview=onPreview;let themes=getAvailableThemes(),themeItems=themes.map(name=>({value:name,label:name,description:name===currentTheme?"(current)":void 0}));this.addChild(new DynamicBorder),this.selectList=new SelectList(themeItems,10,getSelectListTheme(),THEME_SELECT_LIST_LAYOUT);let currentIndex=themes.indexOf(currentTheme);currentIndex!==-1&&this.selectList.setSelectedIndex(currentIndex),this.selectList.onSelect=item=>{onSelect(item.value)},this.selectList.onCancel=()=>{onCancel()},this.selectList.onSelectionChange=item=>{this.onPreview(item.value)},this.addChild(this.selectList),this.addChild(new DynamicBorder)}getSelectList(){return this.selectList}};export{ShowImagesSelectorComponent,ThemeSelectorComponent,dist_exports};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
+ function combineAbortSignals(signals){let activeSignals=signals.filter(signal=>signal!==void 0);if(activeSignals.length===0)return{cleanup:()=>{}};if(activeSignals.length===1)return{signal:activeSignals[0],cleanup:()=>{}};let controller=new AbortController,listeners=[],abort=signal=>{controller.signal.aborted||controller.abort(signal.reason)};for(let signal of activeSignals){if(signal.aborted){abort(signal);break}let listener=()=>abort(signal);signal.addEventListener("abort",listener,{once:!0}),listeners.push({signal,listener})}return{signal:controller.signal,cleanup:()=>{for(let{signal,listener}of listeners)signal.removeEventListener("abort",listener)}}}export{combineAbortSignals};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
+ import{clampThinkingLevel}from"./chunk-3TDGKLEK.js";import{getSystemMessageText}from"./chunk-PHM5C7IG.js";var UnsupportedStrictJsonSchemaError=class extends Error{},UNSUPPORTED_STRICT_SCHEMA_KEYS=["$ref","$defs","definitions","allOf","oneOf","patternProperties","dependentSchemas","dependencies","unevaluatedProperties","propertyNames","contains","prefixItems","not","if","then","else"];function isJsonSchemaObject(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)}function isStructuredSchema(schema){if(!isJsonSchemaObject(schema))return!1;let types=typeof schema.type=="string"?[schema.type]:Array.isArray(schema.type)?schema.type:[];return types.includes("object")||types.includes("array")||schema.properties!==void 0||schema.items!==void 0}function schemaAllowsNull(schema){return isJsonSchemaObject(schema)?schema.type==="null"||Array.isArray(schema.type)&&schema.type.includes("null")||schema.const===null||Array.isArray(schema.enum)&&schema.enum.includes(null)?!0:Array.isArray(schema.anyOf)&&schema.anyOf.some(variant=>schemaAllowsNull(variant)):!1}function makeJsonSchemaNodeStrict(schema,isUnsupportedKeyword){if(!isJsonSchemaObject(schema))throw new UnsupportedStrictJsonSchemaError("boolean schemas are unsupported");for(let key of UNSUPPORTED_STRICT_SCHEMA_KEYS)if(schema[key]!==void 0)throw new UnsupportedStrictJsonSchemaError(`${key} schemas are unsupported`);if(isUnsupportedKeyword){for(let[key,value]of Object.entries(schema))if(isUnsupportedKeyword(key,value))throw new UnsupportedStrictJsonSchemaError(`${key}: ${JSON.stringify(value)} is unsupported`)}if(schema.type===void 0&&schema.anyOf===void 0&&schema.enum===void 0)throw new UnsupportedStrictJsonSchemaError("schemas without a type are unsupported");if(schema.anyOf!==void 0){if(!Array.isArray(schema.anyOf)||schema.anyOf.length===0)throw new UnsupportedStrictJsonSchemaError("anyOf must contain at least one schema");for(let variant of schema.anyOf){if(isStructuredSchema(variant))throw new UnsupportedStrictJsonSchemaError("object and array unions are unsupported");makeJsonSchemaNodeStrict(variant,isUnsupportedKeyword)}}if(schema.items!==void 0){if(Array.isArray(schema.items))throw new UnsupportedStrictJsonSchemaError("tuple schemas are unsupported");makeJsonSchemaNodeStrict(schema.items,isUnsupportedKeyword)}let isObjectSchema=schema.type==="object";if(schema.properties!==void 0&&!isObjectSchema)throw new UnsupportedStrictJsonSchemaError("properties require type object");if(!isObjectSchema)return;if(schema.additionalProperties!==void 0&&schema.additionalProperties!==!1)throw new UnsupportedStrictJsonSchemaError("schema-valued or true additionalProperties is unsupported");if(schema.properties!==void 0&&!isJsonSchemaObject(schema.properties))throw new UnsupportedStrictJsonSchemaError("object properties must be a schema map");if(schema.required!==void 0&&(!Array.isArray(schema.required)||schema.required.some(key=>typeof key!="string")))throw new UnsupportedStrictJsonSchemaError("object required must be a string array");let properties=schema.properties??{},propertyNames=Object.keys(properties),required=new Set(Array.isArray(schema.required)?schema.required:[]);if([...required].some(key=>!propertyNames.includes(key)))throw new UnsupportedStrictJsonSchemaError("required contains an unknown property");for(let[key,property]of Object.entries(properties))makeJsonSchemaNodeStrict(property,isUnsupportedKeyword),!required.has(key)&&!schemaAllowsNull(property)&&(properties[key]={anyOf:[property,{type:"null"}]});schema.required=propertyNames,schema.additionalProperties=!1}function makeStrictJsonSchema(schema,isUnsupportedKeyword){let cloned=structuredClone(schema);if(!isJsonSchemaObject(cloned))throw new UnsupportedStrictJsonSchemaError("root schema must have type object");if(makeJsonSchemaNodeStrict(cloned,isUnsupportedKeyword),cloned.type!=="object")throw new UnsupportedStrictJsonSchemaError("root schema must have type object");return cloned}function prefersJsonSchemaStrictSampling(tool){let config=tool.constrainedSampling;return!!config&&config.type==="json_schema"&&config.strict==="prefer"}function getJsonSchemaToolParameters(tool,strict){return strict===!0?makeStrictJsonSchema(tool.parameters):tool.parameters}function getGrammarToolInput(toolName,arguments_,inputProperty){let input=arguments_[inputProperty];if(typeof input!="string")throw new Error(`Grammar tool call "${toolName}" requires argument "${inputProperty}" to be a string.`);return input}function appendGrammarToolInputJsonDelta(buffer,inputProperty,inputDelta){if(buffer.closed)throw new Error(`grammar tool input for property "${inputProperty}" changed after it was closed`);if(inputDelta.length!==0)return buffer.input+=inputDelta,grammarToolInputJsonStart(buffer,inputProperty)+JSON.stringify(inputDelta).slice(1,-1)}function closeGrammarToolInputJson(buffer,inputProperty,finalInput){if(buffer.closed){if(finalInput===void 0||finalInput===buffer.input)return;throw new Error(`grammar tool input for property "${inputProperty}" changed after it was closed`)}if(finalInput!==void 0&&!finalInput.startsWith(buffer.input))throw new Error(`grammar tool input for property "${inputProperty}" changed non-monotonically`);let rest=finalInput===void 0?"":finalInput.slice(buffer.input.length);return finalInput!==void 0&&(buffer.input=finalInput),buffer.closed=!0,`${grammarToolInputJsonStart(buffer,inputProperty)}${JSON.stringify(rest).slice(1,-1)}"}`}function grammarToolInputJsonStart(buffer,inputProperty){return buffer.started?"":(buffer.started=!0,`{${JSON.stringify(inputProperty)}:"`)}function inferGrammarInputProperty(tool){let schema=tool.parameters;if(schema.type!=="object")throw new Error("grammar constrained sampling requires an object parameter schema");if(!Array.isArray(schema.required)||schema.required.length!==1||typeof schema.required[0]!="string")throw new Error("grammar constrained sampling requires exactly one required string property");let inputProperty=schema.required[0];if(!schema.properties?.[inputProperty])throw new Error(`grammar constrained sampling requires a properties entry for ${inputProperty}`);if(schema.properties[inputProperty]?.type!=="string")throw new Error(`grammar constrained sampling property ${inputProperty} must have type string`);return inputProperty}function resolveJsonSchemaStrictSampling(tool,supportsStrictMode,isUnsupportedKeyword){let config=tool.constrainedSampling;if(!(!config||config.type!=="json_schema")){if(supportsStrictMode)try{return makeStrictJsonSchema(tool.parameters,isUnsupportedKeyword),!0}catch(error){if(!(error instanceof UnsupportedStrictJsonSchemaError))throw error;if(config.strict!=="require")return;throw new Error(`Tool "${tool.name}" requires JSON-schema constrained sampling, but ${error.message}.`)}if(config.strict==="require")throw new Error(`Tool "${tool.name}" requires JSON-schema constrained sampling, but strict tools are unsupported.`)}}function resolveGrammarConstrainedSampling(tool,supportsOpenAIGrammarTools){let config=tool.constrainedSampling;if(!config||config.type!=="grammar"||!supportsOpenAIGrammarTools)return;let larkDefinition=config.variants.openai_lark,regexDefinition=config.variants.openai_regex,hasLarkDefinition=typeof larkDefinition=="string"&&larkDefinition.trim().length>0,hasRegexDefinition=typeof regexDefinition=="string"&&regexDefinition.trim().length>0;if(!hasLarkDefinition&&!hasRegexDefinition)throw new Error(`Tool "${tool.name}" cannot use grammar constrained sampling: no supported grammar variant was provided.`);try{return{format:hasLarkDefinition?"lark":"regex",definition:hasLarkDefinition?larkDefinition:regexDefinition,inputProperty:inferGrammarInputProperty(tool)}}catch(error){let message=error instanceof Error?error.message:String(error);throw new Error(`Tool "${tool.name}" cannot use grammar constrained sampling: ${message}.`)}}function createGrammarToolInputProperties(tools,supportsOpenAIGrammarTools){let properties=new Map;for(let tool of tools??[]){let grammar=resolveGrammarConstrainedSampling(tool,supportsOpenAIGrammarTools);grammar&&properties.set(tool.name,grammar.inputProperty)}return properties}var CHARS_PER_TOKEN=3.5,ESTIMATED_IMAGE_CHARS=4800;function calculateContextTokens(usage){return usage.totalTokens||usage.input+usage.output+usage.cacheRead+usage.cacheWrite}function safeJsonStringify(value){try{return JSON.stringify(value)??"undefined"}catch{return"[unserializable]"}}function estimateTextAndImageContentChars(content){if(typeof content=="string")return content.length;let chars=0;for(let block of content)chars+=block.type==="text"?block.text.length:ESTIMATED_IMAGE_CHARS;return chars}function estimateTextTokens(text){return Math.ceil(text.length/CHARS_PER_TOKEN)}function estimateTextAndImageContentTokens(content){return Math.ceil(estimateTextAndImageContentChars(content)/CHARS_PER_TOKEN)}function estimateMessageTokens(message){let chars=0;if(message.role==="system")return estimateTextTokens(getSystemMessageText(message))+estimateToolsTokens(message.toolsAdded)+estimateToolsTokens(message.toolsRemoved);if(message.role==="user"||message.role==="toolResult")return estimateTextAndImageContentTokens(message.content);for(let block of message.content)block.type==="text"?chars+=block.text.length:block.type==="thinking"?chars+=block.thinking.length:chars+=block.name.length+safeJsonStringify(block.arguments).length;return Math.ceil(chars/CHARS_PER_TOKEN)}function getLastAssistantUsageInfo(messages){let latestPrefixTimestamp=Number.NEGATIVE_INFINITY,usageInfo;for(let i=0;i<messages.length;i++){let message=messages[i];if(message.role==="assistant"){let assistant=message;assistant.timestamp>=latestPrefixTimestamp&&assistant.stopReason!=="aborted"&&assistant.stopReason!=="error"&&calculateContextTokens(assistant.usage)>0&&(usageInfo={usage:assistant.usage,index:i})}latestPrefixTimestamp=Math.max(latestPrefixTimestamp,message.timestamp)}return usageInfo}function estimateContextTokens(context){let messages="messages"in context?context.messages:context,usageInfo=getLastAssistantUsageInfo(messages);if(usageInfo){let usageTokens=calculateContextTokens(usageInfo.usage),trailingTokens=0;for(let i=usageInfo.index+1;i<messages.length;i++)trailingTokens+=estimateMessageTokens(messages[i]);return{tokens:usageTokens+trailingTokens,usageTokens,trailingTokens,lastUsageIndex:usageInfo.index}}let tokens=0;for(let message of messages)tokens+=estimateMessageTokens(message);return{tokens,usageTokens:0,trailingTokens:tokens,lastUsageIndex:null}}function estimateToolsTokens(tools){return!tools||tools.length===0?0:estimateTextTokens(safeJsonStringify(tools))}var CONTEXT_SAFETY_TOKENS=4096,CONTEXT_SAFETY_RATIO=.15,MIN_OUTPUT_WITH_RATIO_MARGIN=32768,MIN_MAX_TOKENS=1;function clampMaxTokensToContext(model,context,maxTokens){if(model.contextWindow<=0)return Math.max(MIN_MAX_TOKENS,maxTokens);let input=estimateContextTokens(context).tokens,margin=Math.max(CONTEXT_SAFETY_TOKENS,Math.ceil(input*CONTEXT_SAFETY_RATIO)),room=model.contextWindow-input-margin;return room<MIN_OUTPUT_WITH_RATIO_MARGIN&&(room=Math.min(MIN_OUTPUT_WITH_RATIO_MARGIN,model.contextWindow-input-CONTEXT_SAFETY_TOKENS)),Math.min(maxTokens,Math.max(MIN_MAX_TOKENS,room))}function resolveSamplingParams(model,thinkingLevel,requestParams){let effectiveThinkingLevel=clampThinkingLevel(model,thinkingLevel),thinkingLevelParams=model.samplingParamsByThinkingLevel?.[effectiveThinkingLevel];return model.samplingParams||thinkingLevelParams||requestParams?{...model.samplingParams,...thinkingLevelParams,...requestParams}:void 0}function buildBaseOptions(model,context,options,apiKey){let samplingParams=resolveSamplingParams(model,options?.reasoning??"off",options?.samplingParams);return{temperature:options?.temperature,samplingParams,maxTokens:clampMaxTokensToContext(model,context,options?.maxTokens??model.maxTokens),signal:options?.signal,telemetry:options?.telemetry,apiKey:apiKey||options?.apiKey,fetch:options?.fetch,transport:options?.transport,cacheRetention:options?.cacheRetention,sessionId:options?.sessionId,disableContinuation:options?.disableContinuation,headers:options?.headers,identity:options?.identity,onPayload:options?.onPayload,onResponse:options?.onResponse,onProviderStreamEvent:options?.onProviderStreamEvent,timeoutMs:options?.timeoutMs,websocketConnectTimeoutMs:options?.websocketConnectTimeoutMs,maxRetries:options?.maxRetries,maxRetryDelayMs:options?.maxRetryDelayMs,metadata:options?.metadata,env:options?.env}}var MIN_ANSWER_TOKENS=1024,DEFAULT_THINKING_BUDGETS={minimal:1024,low:2048,medium:8192,high:16384};function clampReasoning(effort){return effort==="xhigh"||effort==="max"?"high":effort}function thinkingBudgetForLevel(reasoningLevel,customBudgets){let budgets={...DEFAULT_THINKING_BUDGETS,...customBudgets},level=clampReasoning(reasoningLevel);return budgets[level]}function clampThinkingBudgetToAnswerRoom(thinkingBudget,ceiling){return Math.min(thinkingBudget,Math.max(0,ceiling-MIN_ANSWER_TOKENS))}function adjustMaxTokensForThinking(baseMaxTokens,modelMaxTokens,reasoningLevel,customBudgets){let thinkingBudget=thinkingBudgetForLevel(reasoningLevel,customBudgets),maxTokens=baseMaxTokens===void 0?modelMaxTokens:Math.min(baseMaxTokens+thinkingBudget,modelMaxTokens);return maxTokens<=thinkingBudget&&(thinkingBudget=clampThinkingBudgetToAnswerRoom(thinkingBudget,maxTokens)),{maxTokens,thinkingBudget}}var NON_VISION_USER_IMAGE_PLACEHOLDER="(image omitted: model does not support images)",NON_VISION_TOOL_IMAGE_PLACEHOLDER="(tool image omitted: model does not support images)",ERROR_TOOL_IMAGE_PLACEHOLDER="(image attached after the tool results)";function splitErrorToolResultImages(msg){if(!msg.isError)return;let images=msg.content.filter(block=>block.type==="image");if(images.length!==0)return{content:replaceImagesWithPlaceholder(msg.content,ERROR_TOOL_IMAGE_PLACEHOLDER),caption:`Images from the error result of tool call ${msg.toolCallId} (${msg.toolName}):`,images}}function replaceImagesWithPlaceholder(content,placeholder){let result=[],previousWasPlaceholder=!1;for(let block of content){if(block.type==="image"){previousWasPlaceholder||result.push({type:"text",text:placeholder}),previousWasPlaceholder=!0;continue}result.push(block),previousWasPlaceholder=block.text===placeholder}return result}function downgradeUnsupportedImages(messages,model){return model.input.includes("image")?messages:messages.map(msg=>msg.role==="user"&&Array.isArray(msg.content)?{...msg,content:replaceImagesWithPlaceholder(msg.content,NON_VISION_USER_IMAGE_PLACEHOLDER)}:msg.role==="toolResult"?{...msg,content:replaceImagesWithPlaceholder(msg.content,NON_VISION_TOOL_IMAGE_PLACEHOLDER)}:msg)}function transformMessages(messages,model,normalizeToolCallId){let toolCallIdMap=new Map,normalizedMessages=messages.map(msg=>msg.content==null?{...msg,content:[]}:msg),transformed=downgradeUnsupportedImages(normalizedMessages,model).map(msg=>{if(msg.role==="system"||msg.role==="user")return msg;if(msg.role==="toolResult"){let normalizedId=toolCallIdMap.get(msg.toolCallId);return normalizedId&&normalizedId!==msg.toolCallId?{...msg,toolCallId:normalizedId}:msg}if(msg.role==="assistant"){let assistantMsg=msg,isSameModel=assistantMsg.provider===model.provider&&assistantMsg.api===model.api&&assistantMsg.model===model.id,transformedContent=assistantMsg.content.flatMap(block=>{if(block.type==="thinking")return isSameModel?block.redacted||block.thinkingSignature?block:!block.thinking||block.thinking.trim()===""?[]:block:[];if(block.type==="text")return isSameModel?block:{type:"text",text:block.text};if(block.type==="toolCall"){let toolCall=block,normalizedToolCall=toolCall;if(!isSameModel&&toolCall.thoughtSignature&&(normalizedToolCall={...toolCall},delete normalizedToolCall.thoughtSignature),!isSameModel&&normalizeToolCallId){let normalizedId=normalizeToolCallId(toolCall.id,model,assistantMsg);normalizedId!==toolCall.id&&(toolCallIdMap.set(toolCall.id,normalizedId),normalizedToolCall={...normalizedToolCall,id:normalizedId})}return normalizedToolCall}return block});return{...assistantMsg,content:transformedContent}}return msg}),result=[],pendingToolCalls=[],existingToolResultIds=new Set,heldSystemMessages=[],closePendingToolCalls=()=>{if(pendingToolCalls.length>0){for(let tc of pendingToolCalls)existingToolResultIds.has(tc.id)||result.push({role:"toolResult",toolCallId:tc.id,toolName:tc.name,content:[{type:"text",text:"No result provided"}],isError:!0,timestamp:Date.now()});pendingToolCalls=[],existingToolResultIds=new Set}result.push(...heldSystemMessages),heldSystemMessages.length=0};for(let i=0;i<transformed.length;i++){let msg=transformed[i];if(msg.role==="assistant"){closePendingToolCalls();let assistantMsg=msg;if(assistantMsg.stopReason==="error"||assistantMsg.stopReason==="aborted")continue;let toolCalls=assistantMsg.content.filter(b=>b.type==="toolCall");toolCalls.length>0&&(pendingToolCalls=toolCalls,existingToolResultIds=new Set),result.push(msg)}else msg.role==="toolResult"?(existingToolResultIds.add(msg.toolCallId),result.push(msg)):msg.role==="system"?pendingToolCalls.length>0?heldSystemMessages.push(msg):result.push(msg):(msg.role==="user"&&closePendingToolCalls(),result.push(msg))}return closePendingToolCalls(),result}export{prefersJsonSchemaStrictSampling,getJsonSchemaToolParameters,getGrammarToolInput,appendGrammarToolInputJsonDelta,closeGrammarToolInputJson,resolveJsonSchemaStrictSampling,resolveGrammarConstrainedSampling,createGrammarToolInputProperties,clampMaxTokensToContext,resolveSamplingParams,buildBaseOptions,thinkingBudgetForLevel,clampThinkingBudgetToAnswerRoom,adjustMaxTokensForThinking,splitErrorToolResultImages,transformMessages};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
+ import{getProviderEnvValue}from"./chunk-7DDKXS2Q.js";var DEFAULT_AZURE_API_VERSION="v1";function parseDeploymentNameMap(value){let map=new Map;if(!value)return map;for(let entry of value.split(",")){let trimmed=entry.trim();if(!trimmed)continue;let[modelId,deploymentName]=trimmed.split("=",2);!modelId||!deploymentName||map.set(modelId.trim(),deploymentName.trim())}return map}function resolveDeploymentName(model,options){return options?.azureDeploymentName?options.azureDeploymentName:parseDeploymentNameMap(getProviderEnvValue("AZURE_OPENAI_DEPLOYMENT_NAME_MAP",options?.env)).get(model.id)||model.id}function normalizeAzureBaseUrl(baseUrl){let trimmed=baseUrl.trim().replace(/\/+$/,""),url;try{url=new URL(trimmed)}catch{throw new Error(`Invalid Azure OpenAI base URL: ${baseUrl}`)}let isAzureHost=url.hostname.endsWith(".openai.azure.com")||url.hostname.endsWith(".cognitiveservices.azure.com")||url.hostname.endsWith(".ai.azure.com"),normalizedPath=url.pathname.replace(/\/+$/,"");return isAzureHost&&(normalizedPath===""||normalizedPath==="/"||normalizedPath==="/openai"||normalizedPath==="/openai/v1/responses")&&(url.pathname="/openai/v1",url.search=""),url.toString().replace(/\/+$/,"")}function buildDefaultBaseUrl(resourceName){return`https://${resourceName}.openai.azure.com/openai/v1`}function resolveAzureBaseUrl(model,options){let baseUrl=options?.azureBaseUrl?.trim()||getProviderEnvValue("AZURE_OPENAI_BASE_URL",options?.env)?.trim()||void 0,resourceName=options?.azureResourceName||getProviderEnvValue("AZURE_OPENAI_RESOURCE_NAME",options?.env),resolvedBaseUrl=baseUrl;if(!resolvedBaseUrl&&resourceName&&(resolvedBaseUrl=buildDefaultBaseUrl(resourceName)),!resolvedBaseUrl&&model.baseUrl&&(resolvedBaseUrl=model.baseUrl),!resolvedBaseUrl)throw new Error("Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.");return normalizeAzureBaseUrl(resolvedBaseUrl)}function resolveAzureConfig(model,options){return{baseUrl:resolveAzureBaseUrl(model,options),apiVersion:options?.azureApiVersion||getProviderEnvValue("AZURE_OPENAI_API_VERSION",options?.env)||DEFAULT_AZURE_API_VERSION}}export{resolveDeploymentName,resolveAzureBaseUrl,resolveAzureConfig};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
+ function headersToRecord(headers){let result={};for(let[key,value]of headers.entries())result[key]=value;return result}function providerHeadersToRecord(...headerSources){let merged=new Map;for(let source of headerSources)for(let[name,value]of Object.entries(source??{})){let normalizedName=name.toLowerCase();merged.delete(normalizedName),value!==null&&merged.set(normalizedName,[name,value])}return merged.size>0?Object.fromEntries(merged.values()):void 0}export{headersToRecord,providerHeadersToRecord};
@@ -0,0 +1,14 @@
1
+ import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
+ import{getBinDir}from"./chunk-EANOEWGP.js";import{accessSync,constants}from"node:fs";import{delimiter,join,win32}from"node:path";import{spawn,spawnSync}from"child_process";var SHELL_COMMAND_ENV_VAR="PI_BASH_COMMAND";function isLegacyWslBashPath(path){let normalized=win32.normalize(path).toLowerCase(),systemRoot=process.env.SystemRoot;return systemRoot?/^[a-z]:[\\/]/i.test(systemRoot)?["System32","Sysnative"].some(directory=>normalized===win32.join(systemRoot,directory,"bash.exe").toLowerCase()):!1:/^[a-z]:\\windows\\(?:system32|sysnative)\\bash\.exe$/.test(normalized)}var WINDOWS_ENV_COMMAND_RUNNER=`: "\${${SHELL_COMMAND_ENV_VAR}?pi: the command was not passed in ${SHELL_COMMAND_ENV_VAR}}"; eval -- "unset ${SHELL_COMMAND_ENV_VAR}; $${SHELL_COMMAND_ENV_VAR}"`;function getBashShellConfig(shell){return isLegacyWslBashPath(shell)?{shell,args:["-s"],commandTransport:"stdin"}:process.platform==="win32"&&isWindowsBashPath(shell)?{shell,args:["-c",WINDOWS_ENV_COMMAND_RUNNER],commandTransport:"env"}:{shell,args:["-c"]}}function isWindowsBashPath(path){let segments=win32.normalize(path).toLowerCase().split("\\"),name=segments.pop();return(name==="bash.exe"||name==="bash")&&!segments.includes("windowsapps")}function shellPathExists(path){try{return accessSync(path,constants.F_OK),!0}catch{return!1}}function findExecutableOnPath(executable){if(process.platform==="win32"){try{let result=spawnSync("where",[executable],{encoding:"utf-8",timeout:5e3,windowsHide:!0});if(result.status===0&&result.stdout){let firstMatch=result.stdout.trim().split(/\r?\n/)[0];if(firstMatch&&shellPathExists(firstMatch))return firstMatch}}catch{}return null}try{let result=spawnSync("which",[executable],{encoding:"utf-8",timeout:5e3});if(result.status===0&&result.stdout){let firstMatch=result.stdout.trim().split(/\r?\n/)[0];if(firstMatch)return firstMatch}}catch{}return null}var GIT_FOR_WINDOWS_SHELL_SUFFIX=win32.join("usr","bin","sh.exe");function findGitBashOfGitOnPath(){let git=findExecutableOnPath("git.exe");if(!git)return null;let result=spawnSync(git,["var","GIT_SHELL_PATH"],{encoding:"utf-8",timeout:5e3,windowsHide:!0});if(result.status!==0)return null;let gitShell=win32.normalize(result.stdout.trim());if(!gitShell.toLowerCase().endsWith(`\\${GIT_FOR_WINDOWS_SHELL_SUFFIX}`))return null;let bash=win32.join(gitShell.slice(0,-GIT_FOR_WINDOWS_SHELL_SUFFIX.length),"bin","bash.exe");return shellPathExists(bash)?bash:null}function getShellConfig(customShellPath){if(customShellPath){if(shellPathExists(customShellPath))return getBashShellConfig(customShellPath);throw new Error(`Custom shell path not found: ${customShellPath}`)}if(process.platform==="win32"){let paths=[],programFiles=process.env.ProgramFiles;programFiles&&paths.push(`${programFiles}\\Git\\bin\\bash.exe`);let programFilesX86=process.env["ProgramFiles(x86)"];programFilesX86&&paths.push(`${programFilesX86}\\Git\\bin\\bash.exe`);for(let path of paths)if(shellPathExists(path))return getBashShellConfig(path);let gitBash=findGitBashOfGitOnPath();if(gitBash)return getBashShellConfig(gitBash);let bashOnPath2=findExecutableOnPath("bash.exe");if(bashOnPath2)return getBashShellConfig(bashOnPath2);throw new Error(`No bash shell found. Options:
3
+ 1. Install Git for Windows: https://git-scm.com/download/win
4
+ 2. Add your bash to PATH (Cygwin, MSYS2, etc.)
5
+ 3. Set shellPath in settings.json
6
+
7
+ Searched Git Bash in:
8
+ ${paths.map(p=>` ${p}`).join(`
9
+ `)}
10
+ the Git for Windows installation of git.exe on PATH`)}if(shellPathExists("/bin/bash"))return getBashShellConfig("/bin/bash");let bashOnPath=findExecutableOnPath("bash");return bashOnPath?getBashShellConfig(bashOnPath):{shell:"sh",args:["-c"]}}var POWERSHELL_ARGS=["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-Command"];function getPowerShellConfig(){if(process.platform!=="win32")throw new Error("The powershell tool is only available on Windows.");let shell=findExecutableOnPath("pwsh.exe"),programFiles=process.env.ProgramFiles;if(!shell&&programFiles){let pwsh7=win32.join(programFiles,"PowerShell","7","pwsh.exe");shellPathExists(pwsh7)&&(shell=pwsh7)}shell??=findExecutableOnPath("powershell.exe");let systemRoot=process.env.SystemRoot;if(!shell&&systemRoot){let windowsPowerShell=win32.join(systemRoot,"System32","WindowsPowerShell","v1.0","powershell.exe");shellPathExists(windowsPowerShell)&&(shell=windowsPowerShell)}if(!shell)throw new Error("No PowerShell executable found. Install PowerShell or add powershell.exe/pwsh.exe to PATH.");return{shell,args:[...POWERSHELL_ARGS]}}function getShellEnv(){let binDir=getBinDir(),pathKey=Object.keys(process.env).find(key=>key.toLowerCase()==="path")??"PATH",currentPath=process.env[pathKey]??"",updatedPath=currentPath.split(delimiter).filter(Boolean).includes(binDir)?currentPath:[binDir,currentPath].filter(Boolean).join(delimiter);return{...process.env,[pathKey]:updatedPath}}function sanitizeBinaryOutput(str){return str.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\uFFF9-\uFFFB]/g,"")}var trackedDetachedChildPids=new Set;function trackDetachedChildPid(pid){trackedDetachedChildPids.add(pid)}function untrackDetachedChildPid(pid){trackedDetachedChildPids.delete(pid)}function killTrackedDetachedChildren(){if(trackedDetachedChildPids.size!==0){if(process.platform==="win32"){let pidArgs=[...trackedDetachedChildPids].flatMap(pid=>["/PID",String(pid)]);spawnSync(getTaskkillPath(),["/F","/T",...pidArgs],{stdio:"ignore",timeout:2e3,windowsHide:!0})}else for(let pid of trackedDetachedChildPids)killProcessTree(pid);trackedDetachedChildPids.clear()}}function getTaskkillPath(){return join(process.env.SystemRoot||"C:\\Windows","System32","taskkill.exe")}function killProcessTree(pid){if(process.platform==="win32")try{spawn(getTaskkillPath(),["/F","/T","/PID",String(pid)],{stdio:"ignore",detached:!0,windowsHide:!0}).once("error",()=>{})}catch{}else{if(process.platform==="darwin")try{process.kill(-pid,"SIGSTOP")}catch{}try{process.kill(-pid,"SIGKILL")}catch{try{process.kill(pid,"SIGKILL")}catch{}}}}var DEFAULT_MAX_LINES=2e3,DEFAULT_MAX_BYTES=51200;function splitLinesForCounting(content){if(content.length===0)return[];let lines=content.split(`
11
+ `);return content.endsWith(`
12
+ `)&&lines.pop(),lines}function isBlankLine(line){return line.trim().length===0}function formatSize(bytes){return bytes<1024?`${bytes}B`:bytes<1024*1024?`${(bytes/1024).toFixed(1)}KB`:`${(bytes/(1024*1024)).toFixed(1)}MB`}function truncateHead(content,options={}){let maxLines=options.maxLines??2e3,maxBytes=options.maxBytes??51200,totalBytes=Buffer.byteLength(content,"utf-8"),lines=splitLinesForCounting(content),totalLines=lines.length;if(totalLines<=maxLines&&totalBytes<=maxBytes)return{content,truncated:!1,truncatedBy:null,totalLines,totalBytes,outputLines:totalLines,outputBytes:totalBytes,lastLinePartial:!1,firstLineExceedsLimit:!1,maxLines,maxBytes};if(Buffer.byteLength(lines[0],"utf-8")>maxBytes)return{content:"",truncated:!0,truncatedBy:"bytes",totalLines,totalBytes,outputLines:0,outputBytes:0,lastLinePartial:!1,firstLineExceedsLimit:!0,maxLines,maxBytes};let outputLinesArr=[],outputBytesCount=0,truncatedBy="lines";for(let i=0;i<lines.length&&i<maxLines;i++){let line=lines[i],lineBytes=Buffer.byteLength(line,"utf-8")+(i>0?1:0);if(outputBytesCount+lineBytes>maxBytes){truncatedBy="bytes";break}outputLinesArr.push(line),outputBytesCount+=lineBytes}outputLinesArr.length>=maxLines&&outputBytesCount<=maxBytes&&(truncatedBy="lines");let outputContent=outputLinesArr.join(`
13
+ `),finalOutputBytes=Buffer.byteLength(outputContent,"utf-8");return{content:outputContent,truncated:!0,truncatedBy,totalLines,totalBytes,outputLines:outputLinesArr.length,outputBytes:finalOutputBytes,lastLinePartial:!1,firstLineExceedsLimit:!1,maxLines,maxBytes}}function truncateTail(content,options={}){let maxLines=options.maxLines??2e3,maxBytes=options.maxBytes??51200,totalBytes=Buffer.byteLength(content,"utf-8"),lines=splitLinesForCounting(content),totalLines=lines.length;if(totalLines<=maxLines&&totalBytes<=maxBytes)return{content,truncated:!1,truncatedBy:null,totalLines,totalBytes,outputLines:totalLines,outputBytes:totalBytes,lastLinePartial:!1,firstLineExceedsLimit:!1,maxLines,maxBytes};let outputLinesArr=[],outputBytesCount=0,truncatedBy="lines",lastLinePartial=!1;for(let i=lines.length-1;i>=0&&outputLinesArr.length<maxLines;i--){let line=lines[i],lineBytes=Buffer.byteLength(line,"utf-8")+(outputLinesArr.length>0?1:0);if(outputBytesCount+lineBytes>maxBytes){truncatedBy="bytes";let remainingBytes=maxBytes-outputBytesCount-(outputLinesArr.length>0?1:0);if(outputLinesArr.length===0||!isBlankLine(line)&&outputLinesArr.every(isBlankLine)&&remainingBytes>0){let truncatedLine=truncateStringToBytesFromEnd(line,remainingBytes);outputLinesArr.unshift(truncatedLine),outputBytesCount+=lineBytes-Buffer.byteLength(line,"utf-8")+Buffer.byteLength(truncatedLine,"utf-8"),lastLinePartial=!0}break}outputLinesArr.unshift(line),outputBytesCount+=lineBytes}outputLinesArr.length>=maxLines&&outputBytesCount<=maxBytes&&(truncatedBy="lines");let outputContent=outputLinesArr.join(`
14
+ `),finalOutputBytes=Buffer.byteLength(outputContent,"utf-8");return{content:outputContent,truncated:!0,truncatedBy,totalLines,totalBytes,outputLines:outputLinesArr.length,outputBytes:finalOutputBytes,lastLinePartial,firstLineExceedsLimit:!1,maxLines,maxBytes}}function truncateStringToBytesFromEnd(str,maxBytes){let buf=Buffer.from(str,"utf-8");if(buf.length<=maxBytes)return str;let start=buf.length-maxBytes;for(;start<buf.length&&(buf[start]&192)===128;)start++;return buf.slice(start).toString("utf-8")}function truncateLine(line,maxChars=500){return line.length<=maxChars?{text:line,wasTruncated:!1}:{text:`${sliceHead(line,maxChars)}... [truncated]`,wasTruncated:!0}}function sliceHead(text,maxUnits){let end=Math.max(0,maxUnits);return isHighSurrogate(text.charCodeAt(end-1))&&isLowSurrogate(text.charCodeAt(end))?text.slice(0,end-1):text.slice(0,end)}function sliceTail(text,maxUnits){if(maxUnits<=0)return"";let start=Math.max(0,text.length-maxUnits);return isLowSurrogate(text.charCodeAt(start))&&isHighSurrogate(text.charCodeAt(start-1))?text.slice(start+1):text.slice(start)}function isHighSurrogate(code){return code>=55296&&code<=56319}function isLowSurrogate(code){return code>=56320&&code<=57343}export{SHELL_COMMAND_ENV_VAR,getShellConfig,getPowerShellConfig,getShellEnv,sanitizeBinaryOutput,trackDetachedChildPid,untrackDetachedChildPid,killTrackedDetachedChildren,killProcessTree,DEFAULT_MAX_LINES,DEFAULT_MAX_BYTES,formatSize,truncateHead,truncateTail,truncateLine,sliceHead,sliceTail};