@celljs/ta 0.0.0-stage → 4.5.0

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 (276) hide show
  1. package/README.md +92 -2
  2. package/bin/ta.mjs +10 -0
  3. package/dist/pi/CHANGELOG.md +26 -0
  4. package/dist/pi/dist/bundle/chunks/anthropic-messages-BWGCKOF4.js +6 -0
  5. package/dist/pi/dist/bundle/chunks/anthropic.js +75 -0
  6. package/dist/pi/dist/bundle/chunks/azure-openai-responses-FSC6BAW3.js +2 -0
  7. package/dist/pi/dist/bundle/chunks/bedrock-converse-stream.js +89 -0
  8. package/dist/pi/dist/bundle/chunks/chunk-36QC74V4.js +2 -0
  9. package/dist/pi/dist/bundle/chunks/chunk-3TGLJEWK.js +2 -0
  10. package/dist/pi/dist/bundle/chunks/chunk-44DLKSKE.js +1232 -0
  11. package/dist/pi/dist/bundle/chunks/chunk-4EYXVSA5.js +129 -0
  12. package/dist/pi/dist/bundle/chunks/chunk-5AGIVGSV.js +6 -0
  13. package/dist/pi/dist/bundle/chunks/chunk-62VOPMLK.js +65 -0
  14. package/dist/pi/dist/bundle/chunks/chunk-6QGV3IWD.js +6 -0
  15. package/dist/pi/dist/bundle/chunks/chunk-7CBJINYJ.js +20 -0
  16. package/dist/pi/dist/bundle/chunks/chunk-7DDKXS2Q.js +2 -0
  17. package/dist/pi/dist/bundle/chunks/chunk-7O7QKK6A.js +2 -0
  18. package/dist/pi/dist/bundle/chunks/chunk-7ZC4UXSL.js +2 -0
  19. package/dist/pi/dist/bundle/chunks/chunk-B46VJEHW.js +44 -0
  20. package/dist/pi/dist/bundle/chunks/chunk-C2WU32PX.js +2 -0
  21. package/dist/pi/dist/bundle/chunks/chunk-CF5GWZHW.js +31 -0
  22. package/dist/pi/dist/bundle/chunks/chunk-CHWNPHIS.js +82 -0
  23. package/dist/pi/dist/bundle/chunks/chunk-EBFHJFEE.js +2 -0
  24. package/dist/pi/dist/bundle/chunks/chunk-EOO47QGR.js +2 -0
  25. package/dist/pi/dist/bundle/chunks/chunk-FFMDRXC4.js +10 -0
  26. package/dist/pi/dist/bundle/chunks/chunk-GN3QYODH.js +16 -0
  27. package/dist/pi/dist/bundle/chunks/chunk-JXWJOIH4.js +2 -0
  28. package/dist/pi/dist/bundle/chunks/chunk-L2ZPNLYD.js +2 -0
  29. package/dist/pi/dist/bundle/chunks/chunk-LPXNMA2W.js +2 -0
  30. package/dist/pi/dist/bundle/chunks/chunk-LVVZS2NO.js +12 -0
  31. package/dist/pi/dist/bundle/chunks/chunk-NL4X6LBY.js +4 -0
  32. package/dist/pi/dist/bundle/chunks/chunk-NZY7EIPA.js +4 -0
  33. package/dist/pi/dist/bundle/chunks/chunk-P7FPUEYA.js +2 -0
  34. package/dist/pi/dist/bundle/chunks/chunk-PGXDEOVV.js +2 -0
  35. package/dist/pi/dist/bundle/chunks/chunk-PJACZCIR.js +2 -0
  36. package/dist/pi/dist/bundle/chunks/chunk-PMRZO46Y.js +2 -0
  37. package/dist/pi/dist/bundle/chunks/chunk-PRRNXB7S.js +2 -0
  38. package/dist/pi/dist/bundle/chunks/chunk-R2EGYMOO.js +7 -0
  39. package/dist/pi/dist/bundle/chunks/chunk-RDZVAGPR.js +2 -0
  40. package/dist/pi/dist/bundle/chunks/chunk-TMTOQ7H7.js +2 -0
  41. package/dist/pi/dist/bundle/chunks/chunk-UKVNB6C4.js +2 -0
  42. package/dist/pi/dist/bundle/chunks/chunk-USJZMAIR.js +2 -0
  43. package/dist/pi/dist/bundle/chunks/chunk-UTB4DTYQ.js +2 -0
  44. package/dist/pi/dist/bundle/chunks/chunk-V6KH5QG4.js +9 -0
  45. package/dist/pi/dist/bundle/chunks/chunk-VOLAXWGI.js +2 -0
  46. package/dist/pi/dist/bundle/chunks/chunk-YZKQS34S.js +9 -0
  47. package/dist/pi/dist/bundle/chunks/cli-MCOUW5WS.js +53 -0
  48. package/dist/pi/dist/bundle/chunks/cloudflare-workers-ai-system-one-WLAFJSP6.js +2 -0
  49. package/dist/pi/dist/bundle/chunks/codemode-worker.js +478 -0
  50. package/dist/pi/dist/bundle/chunks/easter-egg-3d-WMBNSJ4M.js +2 -0
  51. package/dist/pi/dist/bundle/chunks/execute-4CEBORGZ.js +505 -0
  52. package/dist/pi/dist/bundle/chunks/github-copilot.js +2 -0
  53. package/dist/pi/dist/bundle/chunks/google-generative-ai-INGKNW72.js +2 -0
  54. package/dist/pi/dist/bundle/chunks/google-vertex-IBTX6MBF.js +2 -0
  55. package/dist/pi/dist/bundle/chunks/https-proxy-agent-LVOO5TPL.js +13 -0
  56. package/dist/pi/dist/bundle/chunks/image-resize-worker.js +2 -0
  57. package/dist/pi/dist/bundle/chunks/jiti-loader-GL4HJFAD.js +21 -0
  58. package/dist/pi/dist/bundle/chunks/jiti-static-loader-2RCDI6B4.js +2 -0
  59. package/dist/pi/dist/bundle/chunks/kimi-coding.js +2 -0
  60. package/dist/pi/dist/bundle/chunks/lib-4AVRLBHM.js +9 -0
  61. package/dist/pi/dist/bundle/chunks/llama-cpp-classify-V5U3QKXI.js +22 -0
  62. package/dist/pi/dist/bundle/chunks/meta.js +2 -0
  63. package/dist/pi/dist/bundle/chunks/mistral-conversations-S4OWXIXQ.js +5 -0
  64. package/dist/pi/dist/bundle/chunks/multipart-parser-FMGQ7342.js +3 -0
  65. package/dist/pi/dist/bundle/chunks/node-AUOGOBCN.js +2 -0
  66. package/dist/pi/dist/bundle/chunks/node-KCMANYC2.js +16 -0
  67. package/dist/pi/dist/bundle/chunks/openai-chatgpt.js +75 -0
  68. package/dist/pi/dist/bundle/chunks/openai-codex-responses-QAWLOQSN.js +10 -0
  69. package/dist/pi/dist/bundle/chunks/openai-codex.js +75 -0
  70. package/dist/pi/dist/bundle/chunks/openai-completions-EJNYB6IX.js +7 -0
  71. package/dist/pi/dist/bundle/chunks/openai-decisions-IXI34BYG.js +5 -0
  72. package/dist/pi/dist/bundle/chunks/openai-responses-MD3562FB.js +4 -0
  73. package/dist/pi/dist/bundle/chunks/openrouter-images-PISKSFMS.js +2 -0
  74. package/dist/pi/dist/bundle/chunks/openrouter.js +75 -0
  75. package/dist/pi/dist/bundle/chunks/pi-messages-NORUKF4E.js +8 -0
  76. package/dist/pi/dist/bundle/chunks/radius.js +75 -0
  77. package/dist/pi/dist/bundle/chunks/runtime-FQB7RU7U.js +2 -0
  78. package/dist/pi/dist/bundle/chunks/src-QKGKDFSU.js +4 -0
  79. package/dist/pi/dist/bundle/chunks/typesafe-system-one-CHVC2UUI.js +2 -0
  80. package/dist/pi/dist/bundle/chunks/virtual-modules-O76XM3OB.js +2 -0
  81. package/dist/pi/dist/bundle/chunks/xai.js +2 -0
  82. package/dist/pi/dist/bundle/cli-runtime.js +3 -0
  83. package/dist/pi/dist/bundle/cli.js +5 -0
  84. package/dist/pi/dist/bundle/index.js +2 -0
  85. package/dist/pi/dist/bundle/rpc-entry.js +3 -0
  86. package/dist/pi/dist/core/export-html/ansi-to-html.js +249 -0
  87. package/dist/pi/dist/core/export-html/index.js +228 -0
  88. package/dist/pi/dist/core/export-html/template.css +1085 -0
  89. package/dist/pi/dist/core/export-html/template.html +56 -0
  90. package/dist/pi/dist/core/export-html/template.js +2044 -0
  91. package/dist/pi/dist/core/export-html/tool-renderer.js +113 -0
  92. package/dist/pi/dist/core/export-html/vendor/highlight.min.js +1213 -0
  93. package/dist/pi/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
  94. package/dist/pi/dist/core/export-html/vendor/marked.min.js +79 -0
  95. package/dist/pi/dist/modes/interactive/assets/clankolas.png +0 -0
  96. package/dist/pi/dist/modes/interactive/theme/dark.json +78 -0
  97. package/dist/pi/dist/modes/interactive/theme/light.json +78 -0
  98. package/dist/pi/docs/cli-integration.md +106 -0
  99. package/dist/pi/docs/cli.md +343 -0
  100. package/dist/pi/docs/codemode.md +230 -0
  101. package/dist/pi/docs/compaction.md +463 -0
  102. package/dist/pi/docs/configuration.md +47 -0
  103. package/dist/pi/docs/containerization.md +183 -0
  104. package/dist/pi/docs/custom-provider.md +227 -0
  105. package/dist/pi/docs/docs.json +220 -0
  106. package/dist/pi/docs/environment-variables.md +103 -0
  107. package/dist/pi/docs/extensions.md +3347 -0
  108. package/dist/pi/docs/how-pi-works.md +49 -0
  109. package/dist/pi/docs/images/doom-extension.png +0 -0
  110. package/dist/pi/docs/images/exy.png +0 -0
  111. package/dist/pi/docs/images/interactive-mode.png +0 -0
  112. package/dist/pi/docs/images/tree-view.png +0 -0
  113. package/dist/pi/docs/index.md +39 -0
  114. package/dist/pi/docs/json.md +226 -0
  115. package/dist/pi/docs/keybindings.md +195 -0
  116. package/dist/pi/docs/llama-cpp.md +132 -0
  117. package/dist/pi/docs/mcp.md +274 -0
  118. package/dist/pi/docs/message-types.md +279 -0
  119. package/dist/pi/docs/models-configuration.md +196 -0
  120. package/dist/pi/docs/models.md +225 -0
  121. package/dist/pi/docs/nvidia-rtx-llama-cpp.md +96 -0
  122. package/dist/pi/docs/packages.md +153 -0
  123. package/dist/pi/docs/prompt-templates.md +59 -0
  124. package/dist/pi/docs/providers.md +247 -0
  125. package/dist/pi/docs/quickstart.md +140 -0
  126. package/dist/pi/docs/rpc-commands.md +860 -0
  127. package/dist/pi/docs/rpc-extension-ui.md +200 -0
  128. package/dist/pi/docs/rpc.md +193 -0
  129. package/dist/pi/docs/sdk.md +147 -0
  130. package/dist/pi/docs/security.md +99 -0
  131. package/dist/pi/docs/session-format.md +293 -0
  132. package/dist/pi/docs/sessions.md +74 -0
  133. package/dist/pi/docs/settings.md +173 -0
  134. package/dist/pi/docs/shell-aliases.md +93 -0
  135. package/dist/pi/docs/skills.md +93 -0
  136. package/dist/pi/docs/slash-commands.md +61 -0
  137. package/dist/pi/docs/terminal-setup.md +235 -0
  138. package/dist/pi/docs/termux.md +117 -0
  139. package/dist/pi/docs/themes.md +138 -0
  140. package/dist/pi/docs/tmux.md +61 -0
  141. package/dist/pi/docs/tui.md +197 -0
  142. package/dist/pi/docs/usage.md +94 -0
  143. package/dist/pi/docs/virtual-models.md +114 -0
  144. package/dist/pi/docs/windows.md +108 -0
  145. package/dist/pi/examples/README.md +36 -0
  146. package/dist/pi/examples/extensions/README.md +215 -0
  147. package/dist/pi/examples/extensions/auto-commit-on-exit.ts +49 -0
  148. package/dist/pi/examples/extensions/bash-spawn-hook.ts +30 -0
  149. package/dist/pi/examples/extensions/bookmark.ts +50 -0
  150. package/dist/pi/examples/extensions/border-status-editor.ts +150 -0
  151. package/dist/pi/examples/extensions/built-in-tool-renderer.ts +225 -0
  152. package/dist/pi/examples/extensions/claude-rules.ts +86 -0
  153. package/dist/pi/examples/extensions/commands.ts +72 -0
  154. package/dist/pi/examples/extensions/confirm-destructive.ts +59 -0
  155. package/dist/pi/examples/extensions/custom-compaction.ts +117 -0
  156. package/dist/pi/examples/extensions/custom-footer.ts +64 -0
  157. package/dist/pi/examples/extensions/custom-header.ts +73 -0
  158. package/dist/pi/examples/extensions/custom-provider-anthropic/index.ts +613 -0
  159. package/dist/pi/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
  160. package/dist/pi/examples/extensions/custom-provider-anthropic/package.json +19 -0
  161. package/dist/pi/examples/extensions/custom-provider-gitlab-duo/index.ts +405 -0
  162. package/dist/pi/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
  163. package/dist/pi/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
  164. package/dist/pi/examples/extensions/debug-provider.ts +90 -0
  165. package/dist/pi/examples/extensions/dirty-repo-guard.ts +56 -0
  166. package/dist/pi/examples/extensions/doom-overlay/README.md +46 -0
  167. package/dist/pi/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
  168. package/dist/pi/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
  169. package/dist/pi/examples/extensions/doom-overlay/doom/build.sh +152 -0
  170. package/dist/pi/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
  171. package/dist/pi/examples/extensions/doom-overlay/doom-component.ts +132 -0
  172. package/dist/pi/examples/extensions/doom-overlay/doom-engine.ts +173 -0
  173. package/dist/pi/examples/extensions/doom-overlay/doom-keys.ts +104 -0
  174. package/dist/pi/examples/extensions/doom-overlay/index.ts +74 -0
  175. package/dist/pi/examples/extensions/doom-overlay/wad-finder.ts +55 -0
  176. package/dist/pi/examples/extensions/dynamic-resources/SKILL.md +8 -0
  177. package/dist/pi/examples/extensions/dynamic-resources/dynamic.json +81 -0
  178. package/dist/pi/examples/extensions/dynamic-resources/dynamic.md +5 -0
  179. package/dist/pi/examples/extensions/dynamic-resources/index.ts +15 -0
  180. package/dist/pi/examples/extensions/dynamic-tools.ts +74 -0
  181. package/dist/pi/examples/extensions/entry-renderer.ts +41 -0
  182. package/dist/pi/examples/extensions/event-bus.ts +43 -0
  183. package/dist/pi/examples/extensions/file-trigger.ts +41 -0
  184. package/dist/pi/examples/extensions/git-checkpoint.ts +53 -0
  185. package/dist/pi/examples/extensions/git-merge-and-resolve.ts +115 -0
  186. package/dist/pi/examples/extensions/github-issue-autocomplete.ts +185 -0
  187. package/dist/pi/examples/extensions/gondolin/index.ts +531 -0
  188. package/dist/pi/examples/extensions/gondolin/package-lock.json +175 -0
  189. package/dist/pi/examples/extensions/gondolin/package.json +19 -0
  190. package/dist/pi/examples/extensions/handoff.ts +190 -0
  191. package/dist/pi/examples/extensions/hello.ts +26 -0
  192. package/dist/pi/examples/extensions/hidden-thinking-label.ts +53 -0
  193. package/dist/pi/examples/extensions/inline-bash.ts +94 -0
  194. package/dist/pi/examples/extensions/input-transform-streaming.ts +39 -0
  195. package/dist/pi/examples/extensions/input-transform.ts +43 -0
  196. package/dist/pi/examples/extensions/interactive-shell.ts +196 -0
  197. package/dist/pi/examples/extensions/jev-router.ts +113 -0
  198. package/dist/pi/examples/extensions/mac-system-theme.ts +47 -0
  199. package/dist/pi/examples/extensions/message-renderer.ts +59 -0
  200. package/dist/pi/examples/extensions/minimal-mode.ts +353 -0
  201. package/dist/pi/examples/extensions/modal-editor.ts +85 -0
  202. package/dist/pi/examples/extensions/model-status.ts +31 -0
  203. package/dist/pi/examples/extensions/notify.ts +57 -0
  204. package/dist/pi/examples/extensions/overlay-qa-tests.ts +1450 -0
  205. package/dist/pi/examples/extensions/overlay-test.ts +153 -0
  206. package/dist/pi/examples/extensions/permission-gate.ts +34 -0
  207. package/dist/pi/examples/extensions/pirate.ts +47 -0
  208. package/dist/pi/examples/extensions/plan-mode/README.md +66 -0
  209. package/dist/pi/examples/extensions/plan-mode/index.ts +394 -0
  210. package/dist/pi/examples/extensions/plan-mode/utils.ts +168 -0
  211. package/dist/pi/examples/extensions/preset.ts +438 -0
  212. package/dist/pi/examples/extensions/project-trust.ts +64 -0
  213. package/dist/pi/examples/extensions/prompt-customizer.ts +49 -0
  214. package/dist/pi/examples/extensions/protected-paths.ts +30 -0
  215. package/dist/pi/examples/extensions/provider-payload.ts +18 -0
  216. package/dist/pi/examples/extensions/qna.ts +118 -0
  217. package/dist/pi/examples/extensions/question.ts +286 -0
  218. package/dist/pi/examples/extensions/questionnaire.ts +448 -0
  219. package/dist/pi/examples/extensions/rainbow-editor.ts +88 -0
  220. package/dist/pi/examples/extensions/reload-runtime.ts +49 -0
  221. package/dist/pi/examples/extensions/rpc-demo.ts +118 -0
  222. package/dist/pi/examples/extensions/send-user-message.ts +97 -0
  223. package/dist/pi/examples/extensions/session-name.ts +27 -0
  224. package/dist/pi/examples/extensions/shutdown-command.ts +63 -0
  225. package/dist/pi/examples/extensions/snake.ts +343 -0
  226. package/dist/pi/examples/extensions/space-invaders.ts +560 -0
  227. package/dist/pi/examples/extensions/ssh.ts +220 -0
  228. package/dist/pi/examples/extensions/status-line.ts +32 -0
  229. package/dist/pi/examples/extensions/structured-output.ts +65 -0
  230. package/dist/pi/examples/extensions/subagent/README.md +177 -0
  231. package/dist/pi/examples/extensions/subagent/agents/planner.md +37 -0
  232. package/dist/pi/examples/extensions/subagent/agents/reviewer.md +35 -0
  233. package/dist/pi/examples/extensions/subagent/agents/scout.md +50 -0
  234. package/dist/pi/examples/extensions/subagent/agents/worker.md +24 -0
  235. package/dist/pi/examples/extensions/subagent/agents.ts +157 -0
  236. package/dist/pi/examples/extensions/subagent/index.ts +1036 -0
  237. package/dist/pi/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
  238. package/dist/pi/examples/extensions/subagent/prompts/implement.md +10 -0
  239. package/dist/pi/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
  240. package/dist/pi/examples/extensions/summarize.ts +199 -0
  241. package/dist/pi/examples/extensions/system-prompt-header.ts +17 -0
  242. package/dist/pi/examples/extensions/tic-tac-toe.ts +1008 -0
  243. package/dist/pi/examples/extensions/timed-confirm.ts +70 -0
  244. package/dist/pi/examples/extensions/titlebar-spinner.ts +58 -0
  245. package/dist/pi/examples/extensions/todo.ts +304 -0
  246. package/dist/pi/examples/extensions/tool-override.ts +144 -0
  247. package/dist/pi/examples/extensions/tools.ts +148 -0
  248. package/dist/pi/examples/extensions/trigger-compact.ts +50 -0
  249. package/dist/pi/examples/extensions/truncated-tool.ts +195 -0
  250. package/dist/pi/examples/extensions/widget-placement.ts +9 -0
  251. package/dist/pi/examples/extensions/with-deps/index.ts +32 -0
  252. package/dist/pi/examples/extensions/with-deps/package-lock.json +31 -0
  253. package/dist/pi/examples/extensions/with-deps/package.json +22 -0
  254. package/dist/pi/examples/extensions/working-indicator.ts +123 -0
  255. package/dist/pi/examples/extensions/working-message-test.ts +25 -0
  256. package/dist/pi/examples/rpc-client.ts +35 -0
  257. package/dist/pi/examples/rpc-extension-ui.ts +661 -0
  258. package/dist/pi/examples/sdk/01-minimal.ts +26 -0
  259. package/dist/pi/examples/sdk/02-custom-model.ts +49 -0
  260. package/dist/pi/examples/sdk/03-custom-prompt.ts +75 -0
  261. package/dist/pi/examples/sdk/04-skills.ts +55 -0
  262. package/dist/pi/examples/sdk/05-tools.ts +48 -0
  263. package/dist/pi/examples/sdk/06-extensions.ts +99 -0
  264. package/dist/pi/examples/sdk/07-context-files.ts +47 -0
  265. package/dist/pi/examples/sdk/08-prompt-templates.ts +51 -0
  266. package/dist/pi/examples/sdk/09-api-keys-and-oauth.ts +34 -0
  267. package/dist/pi/examples/sdk/10-settings.ts +53 -0
  268. package/dist/pi/examples/sdk/11-sessions.ts +52 -0
  269. package/dist/pi/examples/sdk/12-full-control.ts +74 -0
  270. package/dist/pi/examples/sdk/13-session-runtime.ts +67 -0
  271. package/dist/pi/examples/sdk/14-codemode-mcp.ts +61 -0
  272. package/dist/pi/examples/sdk/README.md +141 -0
  273. package/dist/pi/examples/tsconfig.json +180 -0
  274. package/dist/pi/package.json +9 -0
  275. package/dist/serve/index.mjs +16495 -0
  276. package/package.json +58 -4
@@ -0,0 +1,2 @@
1
+ import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
+ import{dist_exports as dist_exports3}from"./chunk-EBFHJFEE.js";import{all_exports,anthropicMessagesApi,azureOpenAIResponsesApi,bedrockConverseStreamApi,compile_exports,complete,completeSimple,createFauxCore,dist_exports as dist_exports2,envApiKeyAuth,fauxAssistantMessage,fauxProvider,fauxText,fauxThinking,fauxToolCall,generateImages,generateImagesOpenRouter,getApiProvider,getApiProviders,getImageModel,getImageModels,getImageProviders,getImagesApiProvider,getModel,getModels,getOverflowPatterns,getProviders,googleGenerativeAIApi,googleVertexApi,isContextOverflow,isRecoverableLength,lazyOAuth,mistralConversationsApi,openAICodexResponsesApi,openAICompletionsApi,openAIResponsesApi,piMessagesApi,registerApiProvider,registerBuiltInApiProviders,registerBuiltInImagesApiProviders,registerFauxProvider,registerImagesApiProvider,resetApiProviders,setBedrockProviderModule,stream,streamAnthropic,streamAzureOpenAIResponses,streamGoogle,streamGoogleVertex,streamMistral,streamOpenAICodexResponses,streamOpenAICompletions,streamOpenAIResponses,streamSimple,streamSimpleAnthropic,streamSimpleAzureOpenAIResponses,streamSimpleGoogle,streamSimpleGoogleVertex,streamSimpleMistral,streamSimpleOpenAICodexResponses,streamSimpleOpenAICompletions,streamSimpleOpenAIResponses,unregisterApiProviders,validateToolArguments,validateToolCall,value_exports}from"./chunk-44DLKSKE.js";import{DEFAULT_MAX_AGENT_RETRY_DELAY_MS,build_exports,isRetryableAssistantError,retryAssistantCall,retryDelayMs,typebox_exports}from"./chunk-62VOPMLK.js";import"./chunk-3TGLJEWK.js";import{dist_exports}from"./chunk-4EYXVSA5.js";import"./chunk-NZY7EIPA.js";import"./chunk-R2EGYMOO.js";import"./chunk-YZKQS34S.js";import"./chunk-6QGV3IWD.js";import"./chunk-36QC74V4.js";import{cleanupSessionResources,registerSessionResourceCleanup,uuidv7}from"./chunk-USJZMAIR.js";import"./chunk-5AGIVGSV.js";import{ANTHROPIC_API_KEY_ENV,ANTHROPIC_AUTH_TOKEN_ENV,ANTHROPIC_FEDERATION_RULE_ID_ENV,ANTHROPIC_IDENTITY_TOKEN_FILE_ENV,ANTHROPIC_OAUTH_TOKEN_ENV,ANTHROPIC_ORGANIZATION_ID_ENV,ANTHROPIC_SERVICE_ACCOUNT_ID_ENV,ANTHROPIC_WORKSPACE_ID_ENV,findEnvKeys,getEnvApiKey}from"./chunk-UKVNB6C4.js";import"./chunk-TMTOQ7H7.js";import"./chunk-7DDKXS2Q.js";import{StreamingJsonParser,ToolCallArgumentsStream,parseJsonWithRepair,parseStreamingJson,parseToolCallArguments,repairJson}from"./chunk-FFMDRXC4.js";import{AI_TELEMETRY_SCHEMA,InMemoryCredentialStore,InMemoryModelsStore,ModelsError,calculateCost,clampThinkingLevel,collapseSystemMessages,createInitialSystemMessage,createModels,createProvider,declarationsEqual,defaultProviderAuthContext,getCurrentSystemMessage,getCurrentSystemPrompt,getCurrentTools,getDeclaredTools,getInitialSystemMessage,getModelType,getSupportedThinkingLevels,getToolStateChanges,hasApi,hasNonAdditiveToolChanges,hasToolRedefinitions,isModelType,lazyApi,lazyStream,modelsAreEqual,models_exports,normalizeContext,resolveTranscript,resolveTranscriptTools,toToolDeclaration,withoutInitialSystemMessage}from"./chunk-NL4X6LBY.js";import{AssistantMessageEventStream,EventStream,appendAssistantMessageDiagnostic,createAssistantMessageDiagnostic,createAssistantMessageEventStream,extractDiagnosticError,formatThrownValue}from"./chunk-LPXNMA2W.js";import{PI_AI_VERSION,PI_ATTRIBUTION,contentText,formatUserAgent,getAttributionHeaders,getClientVersion,getIdentityHeaders,getOpenCodeSessionHeaders,getSystemMessageText,mergeClientIdentity,renderSystemMessageUpdate,withClientIdentity}from"./chunk-V6KH5QG4.js";import{__export}from"./chunk-JXWJOIH4.js";var oauth_exports={};var pi_ai_extension_view_exports={};__export(pi_ai_extension_view_exports,{AI_TELEMETRY_SCHEMA:()=>AI_TELEMETRY_SCHEMA,ANTHROPIC_API_KEY_ENV:()=>ANTHROPIC_API_KEY_ENV,ANTHROPIC_AUTH_TOKEN_ENV:()=>ANTHROPIC_AUTH_TOKEN_ENV,ANTHROPIC_FEDERATION_RULE_ID_ENV:()=>ANTHROPIC_FEDERATION_RULE_ID_ENV,ANTHROPIC_IDENTITY_TOKEN_FILE_ENV:()=>ANTHROPIC_IDENTITY_TOKEN_FILE_ENV,ANTHROPIC_OAUTH_TOKEN_ENV:()=>ANTHROPIC_OAUTH_TOKEN_ENV,ANTHROPIC_ORGANIZATION_ID_ENV:()=>ANTHROPIC_ORGANIZATION_ID_ENV,ANTHROPIC_SERVICE_ACCOUNT_ID_ENV:()=>ANTHROPIC_SERVICE_ACCOUNT_ID_ENV,ANTHROPIC_WORKSPACE_ID_ENV:()=>ANTHROPIC_WORKSPACE_ID_ENV,AssistantMessageEventStream:()=>AssistantMessageEventStream,DEFAULT_MAX_AGENT_RETRY_DELAY_MS:()=>DEFAULT_MAX_AGENT_RETRY_DELAY_MS,EventStream:()=>EventStream,InMemoryCredentialStore:()=>InMemoryCredentialStore,InMemoryModelsStore:()=>InMemoryModelsStore,ModelsError:()=>ModelsError,PI_AI_VERSION:()=>PI_AI_VERSION,PI_ATTRIBUTION:()=>PI_ATTRIBUTION,StreamingJsonParser:()=>StreamingJsonParser,StringEnum:()=>StringEnum,ToolCallArgumentsStream:()=>ToolCallArgumentsStream,Type:()=>typebox_exports,anthropicMessagesApi:()=>anthropicMessagesApi,appendAssistantMessageDiagnostic:()=>appendAssistantMessageDiagnostic,azureOpenAIResponsesApi:()=>azureOpenAIResponsesApi,bedrockConverseStreamApi:()=>bedrockConverseStreamApi,calculateCost:()=>calculateCost,clampThinkingLevel:()=>clampThinkingLevel,cleanupSessionResources:()=>cleanupSessionResources,collapseSystemMessages:()=>collapseSystemMessages,complete:()=>complete,completeSimple:()=>completeSimple,contentText:()=>contentText,createAssistantMessageDiagnostic:()=>createAssistantMessageDiagnostic,createAssistantMessageEventStream:()=>createAssistantMessageEventStream,createFauxCore:()=>createFauxCore,createInitialSystemMessage:()=>createInitialSystemMessage,createModels:()=>createModels,createProvider:()=>createProvider,declarationsEqual:()=>declarationsEqual,defaultProviderAuthContext:()=>defaultProviderAuthContext,envApiKeyAuth:()=>envApiKeyAuth,extractDiagnosticError:()=>extractDiagnosticError,fauxAssistantMessage:()=>fauxAssistantMessage,fauxProvider:()=>fauxProvider,fauxText:()=>fauxText,fauxThinking:()=>fauxThinking,fauxToolCall:()=>fauxToolCall,findEnvKeys:()=>findEnvKeys,formatThrownValue:()=>formatThrownValue,formatUserAgent:()=>formatUserAgent,generateImages:()=>generateImages,generateImagesOpenRouter:()=>generateImagesOpenRouter,getApiProvider:()=>getApiProvider,getApiProviders:()=>getApiProviders,getAttributionHeaders:()=>getAttributionHeaders,getClientVersion:()=>getClientVersion,getCurrentSystemMessage:()=>getCurrentSystemMessage,getCurrentSystemPrompt:()=>getCurrentSystemPrompt,getCurrentTools:()=>getCurrentTools,getDeclaredTools:()=>getDeclaredTools,getEnvApiKey:()=>getEnvApiKey,getIdentityHeaders:()=>getIdentityHeaders,getImageModel:()=>getImageModel,getImageModels:()=>getImageModels,getImageProviders:()=>getImageProviders,getImagesApiProvider:()=>getImagesApiProvider,getInitialSystemMessage:()=>getInitialSystemMessage,getModel:()=>getModel,getModelType:()=>getModelType,getModels:()=>getModels,getOpenCodeSessionHeaders:()=>getOpenCodeSessionHeaders,getOverflowPatterns:()=>getOverflowPatterns,getProviders:()=>getProviders,getSupportedThinkingLevels:()=>getSupportedThinkingLevels,getSystemMessageText:()=>getSystemMessageText,getToolStateChanges:()=>getToolStateChanges,googleGenerativeAIApi:()=>googleGenerativeAIApi,googleVertexApi:()=>googleVertexApi,hasApi:()=>hasApi,hasNonAdditiveToolChanges:()=>hasNonAdditiveToolChanges,hasToolRedefinitions:()=>hasToolRedefinitions,isContextOverflow:()=>isContextOverflow,isModelType:()=>isModelType,isRecoverableLength:()=>isRecoverableLength,isRetryableAssistantError:()=>isRetryableAssistantError,lazyApi:()=>lazyApi,lazyOAuth:()=>lazyOAuth,lazyStream:()=>lazyStream,mergeClientIdentity:()=>mergeClientIdentity,mistralConversationsApi:()=>mistralConversationsApi,modelsAreEqual:()=>modelsAreEqual,normalizeContext:()=>normalizeContext,openAICodexResponsesApi:()=>openAICodexResponsesApi,openAICompletionsApi:()=>openAICompletionsApi,openAIResponsesApi:()=>openAIResponsesApi,parseJsonWithRepair:()=>parseJsonWithRepair,parseStreamingJson:()=>parseStreamingJson,parseToolCallArguments:()=>parseToolCallArguments,piMessagesApi:()=>piMessagesApi,registerApiProvider:()=>registerApiProvider,registerBuiltInApiProviders:()=>registerBuiltInApiProviders,registerBuiltInImagesApiProviders:()=>registerBuiltInImagesApiProviders,registerFauxProvider:()=>registerFauxProvider,registerImagesApiProvider:()=>registerImagesApiProvider,registerSessionResourceCleanup:()=>registerSessionResourceCleanup,renderSystemMessageUpdate:()=>renderSystemMessageUpdate,repairJson:()=>repairJson,resetApiProviders:()=>resetApiProviders,resolveTranscript:()=>resolveTranscript,resolveTranscriptTools:()=>resolveTranscriptTools,retryAssistantCall:()=>retryAssistantCall,retryDelayMs:()=>retryDelayMs,setBedrockProviderModule:()=>setBedrockProviderModule,stream:()=>stream,streamAnthropic:()=>streamAnthropic,streamAzureOpenAIResponses:()=>streamAzureOpenAIResponses,streamGoogle:()=>streamGoogle,streamGoogleVertex:()=>streamGoogleVertex,streamMistral:()=>streamMistral,streamOpenAICodexResponses:()=>streamOpenAICodexResponses,streamOpenAICompletions:()=>streamOpenAICompletions,streamOpenAIResponses:()=>streamOpenAIResponses,streamSimple:()=>streamSimple,streamSimpleAnthropic:()=>streamSimpleAnthropic,streamSimpleAzureOpenAIResponses:()=>streamSimpleAzureOpenAIResponses,streamSimpleGoogle:()=>streamSimpleGoogle,streamSimpleGoogleVertex:()=>streamSimpleGoogleVertex,streamSimpleMistral:()=>streamSimpleMistral,streamSimpleOpenAICodexResponses:()=>streamSimpleOpenAICodexResponses,streamSimpleOpenAICompletions:()=>streamSimpleOpenAICompletions,streamSimpleOpenAIResponses:()=>streamSimpleOpenAIResponses,toToolDeclaration:()=>toToolDeclaration,unregisterApiProviders:()=>unregisterApiProviders,uuidv7:()=>uuidv7,validateToolArguments:()=>validateToolArguments,validateToolCall:()=>validateToolCall,withClientIdentity:()=>withClientIdentity,withoutInitialSystemMessage:()=>withoutInitialSystemMessage});function StringEnum(values,options){return typebox_exports.Unsafe({type:"string",enum:values,...options?.description&&{description:options.description},...options?.default&&{default:options.default}})}var VIRTUAL_MODULES={typebox:build_exports,"typebox/compile":compile_exports,"typebox/value":value_exports,"@sinclair/typebox":build_exports,"@sinclair/typebox/compile":compile_exports,"@sinclair/typebox/value":value_exports,"@earendil-works/pi-agent-core":dist_exports2,"@earendil-works/pi-tui":dist_exports,"@earendil-works/pi-ai":pi_ai_extension_view_exports,"@earendil-works/pi-ai/compat":pi_ai_extension_view_exports,"@earendil-works/pi-ai/models":models_exports,"@earendil-works/pi-ai/oauth":oauth_exports,"@earendil-works/pi-ai/providers/all":all_exports,"@earendil-works/pi-coding-agent":dist_exports3,"@mariozechner/pi-agent-core":dist_exports2,"@mariozechner/pi-tui":dist_exports,"@mariozechner/pi-ai":pi_ai_extension_view_exports,"@mariozechner/pi-ai/compat":pi_ai_extension_view_exports,"@mariozechner/pi-ai/models":models_exports,"@mariozechner/pi-ai/oauth":oauth_exports,"@mariozechner/pi-ai/providers/all":all_exports,"@mariozechner/pi-coding-agent":dist_exports3};export{VIRTUAL_MODULES};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
+ var CANCEL_MESSAGE="Login cancelled",TIMEOUT_MESSAGE="Device flow timed out",SLOW_DOWN_TIMEOUT_MESSAGE="Device flow timed out after one or more slow_down responses. This is often caused by clock drift in WSL or VM environments. Please sync or restart the VM clock and try again.";function abortableSleep(ms,signal,cancelMessage){return new Promise((resolve,reject)=>{if(signal.aborted){reject(new Error(cancelMessage));return}let onAbort=()=>{clearTimeout(timeout),reject(new Error(cancelMessage))},timeout=setTimeout(()=>{signal.removeEventListener("abort",onAbort),resolve()},ms);signal.addEventListener("abort",onAbort,{once:!0})})}async function pollOAuthDeviceCodeFlow(options){let deadline=typeof options.expiresInSeconds=="number"?Date.now()+options.expiresInSeconds*1e3:Number.POSITIVE_INFINITY,intervalMs=Math.max(1e3,Math.floor((options.intervalSeconds??5)*1e3)),slowDownResponses=0;if(options.waitBeforeFirstPoll){let remainingMs=deadline-Date.now();remainingMs>0&&await abortableSleep(Math.min(intervalMs,remainingMs),options.signal,CANCEL_MESSAGE)}for(;Date.now()<deadline;){if(options.signal.aborted)throw new Error(CANCEL_MESSAGE);let result=await options.poll();if(result.status==="complete")return result.value;if(result.status==="failed")throw new Error(result.message);result.status==="slow_down"&&(slowDownResponses+=1,intervalMs=typeof result.intervalSeconds=="number"&&Number.isFinite(result.intervalSeconds)&&result.intervalSeconds>0?Math.max(1e3,Math.floor(result.intervalSeconds*1e3)):Math.max(1e3,intervalMs+5e3));let remainingMs=deadline-Date.now();if(remainingMs<=0)break;await abortableSleep(Math.min(intervalMs,remainingMs),options.signal,CANCEL_MESSAGE)}throw new Error(slowDownResponses>0?SLOW_DOWN_TIMEOUT_MESSAGE:TIMEOUT_MESSAGE)}var XAI_CLIENT_ID="b1a00492-073a-47ea-816f-4c329264a828",XAI_SCOPE="openid profile email offline_access grok-cli:access api:access",XAI_DEVICE_CODE_URL="https://auth.x.ai/oauth2/device/code",XAI_TOKEN_URL="https://auth.x.ai/oauth2/token",REFRESH_SKEW_MS=300*1e3,DEFAULT_TOKEN_LIFETIME_SECONDS=3600;function requiredString(body,field){let value=body[field];if(typeof value!="string"||value.length===0)throw new Error(`Invalid xAI OAuth response field: ${field}`);return value}function positiveNumber(body,field){let value=body[field];if(typeof value!="number"||!Number.isFinite(value)||value<=0)throw new Error(`Invalid xAI OAuth response field: ${field}`);return value}function validateVerificationUri(raw){let url;try{url=new URL(raw)}catch{throw new Error("Untrusted verification URI in xAI OAuth response")}if(url.protocol!=="https:")throw new Error("Untrusted verification URI in xAI OAuth response");return url.href}async function postForm(url,fields,signal){let response;try{response=await fetch(url,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(fields),signal})}catch(error){throw signal.aborted?new Error("Login cancelled"):error}let body;try{let parsed=await response.json();body=parsed&&typeof parsed=="object"&&!Array.isArray(parsed)?parsed:{}}catch{throw signal.aborted?new Error("Login cancelled"):new Error(`xAI OAuth returned invalid JSON (HTTP ${response.status})`)}return{ok:response.ok,status:response.status,body}}function requestFailure(action,response){let error=typeof response.body.error=="string"?response.body.error:void 0,description=typeof response.body.error_description=="string"?response.body.error_description:void 0,detail=[error,description].filter(Boolean).join(": ");return new Error(`xAI OAuth ${action} failed (HTTP ${response.status})${detail?`: ${detail}`:""}`)}function parseDeviceCode(body){let interval=body.interval,intervalSeconds=typeof interval=="number"&&Number.isFinite(interval)&&interval>0?interval:void 0,verificationUriComplete=typeof body.verification_uri_complete=="string"&&body.verification_uri_complete.length>0?validateVerificationUri(body.verification_uri_complete):void 0;return{deviceCode:requiredString(body,"device_code"),userCode:requiredString(body,"user_code"),verificationUri:validateVerificationUri(requiredString(body,"verification_uri")),verificationUriComplete,intervalSeconds,expiresInSeconds:positiveNumber(body,"expires_in")}}function credentialsFromTokenResponse(body,previousRefreshToken){let access=requiredString(body,"access_token"),refresh=body.refresh_token===void 0&&previousRefreshToken?previousRefreshToken:requiredString(body,"refresh_token"),expiresInSeconds=body.expires_in===void 0?DEFAULT_TOKEN_LIFETIME_SECONDS:positiveNumber(body,"expires_in");return{type:"oauth",access,refresh,expires:Date.now()+expiresInSeconds*1e3-REFRESH_SKEW_MS}}async function requestDeviceCode(signal){let response=await postForm(XAI_DEVICE_CODE_URL,{client_id:XAI_CLIENT_ID,scope:XAI_SCOPE,referrer:"pi"},signal);if(!response.ok)throw requestFailure("device authorization",response);return parseDeviceCode(response.body)}async function pollForTokens(device,signal){return pollOAuthDeviceCodeFlow({intervalSeconds:device.intervalSeconds,expiresInSeconds:device.expiresInSeconds,waitBeforeFirstPoll:!0,signal,poll:async()=>{let response=await postForm(XAI_TOKEN_URL,{grant_type:"urn:ietf:params:oauth:grant-type:device_code",client_id:XAI_CLIENT_ID,device_code:device.deviceCode},signal);if(response.ok)return{status:"complete",value:credentialsFromTokenResponse(response.body)};let error=response.body.error;if(error==="authorization_pending")return{status:"pending"};if(error==="slow_down"){let interval=response.body.interval;return{status:"slow_down",intervalSeconds:typeof interval=="number"?interval:void 0}}return error==="access_denied"||error==="authorization_denied"?{status:"failed",message:"xAI device authorization was denied"}:error==="expired_token"?{status:"failed",message:"xAI device code expired"}:{status:"failed",message:requestFailure("device token polling",response).message}}})}async function loginXai(interaction){let device=await requestDeviceCode(interaction.signal);return interaction.notify({type:"device_code",userCode:device.userCode,verificationUri:device.verificationUriComplete??device.verificationUri,intervalSeconds:device.intervalSeconds,expiresInSeconds:device.expiresInSeconds}),pollForTokens(device,interaction.signal)}async function refreshXaiToken(refreshToken,signal){let response=await postForm(XAI_TOKEN_URL,{grant_type:"refresh_token",client_id:XAI_CLIENT_ID,refresh_token:refreshToken},signal);if(!response.ok)throw requestFailure("token refresh",response);return credentialsFromTokenResponse(response.body,refreshToken)}var xaiOAuth={name:"xAI (Grok/X subscription)",isSubscription:!0,loginLabel:"Sign in with SuperGrok or X Premium",login:loginXai,refresh:(credential,signal)=>refreshXaiToken(credential.refresh,signal),async toAuth(credential){return{apiKey:credential.access}}};export{xaiOAuth};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
3
+ import{configureHttpDispatcher,main}from"./chunks/chunk-44DLKSKE.js";import"./chunks/chunk-62VOPMLK.js";import"./chunks/chunk-3TGLJEWK.js";import"./chunks/chunk-4EYXVSA5.js";import"./chunks/chunk-NZY7EIPA.js";import"./chunks/chunk-R2EGYMOO.js";import"./chunks/chunk-YZKQS34S.js";import"./chunks/chunk-6QGV3IWD.js";import{APP_NAME}from"./chunks/chunk-36QC74V4.js";import"./chunks/chunk-USJZMAIR.js";import"./chunks/chunk-5AGIVGSV.js";import"./chunks/chunk-UKVNB6C4.js";import"./chunks/chunk-TMTOQ7H7.js";import"./chunks/chunk-7DDKXS2Q.js";import"./chunks/chunk-FFMDRXC4.js";import"./chunks/chunk-NL4X6LBY.js";import"./chunks/chunk-LPXNMA2W.js";import"./chunks/chunk-V6KH5QG4.js";import"./chunks/chunk-JXWJOIH4.js";function setupCli(){process.title=APP_NAME,process.env.PI_CODING_AGENT="true",process.env.AI_AGENT="pi",process.emitWarning=(()=>{}),configureHttpDispatcher()}setupCli();main(process.argv.slice(2));
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire, enableCompileCache } from "node:module";
3
+
4
+ enableCompileCache();
5
+ createRequire(import.meta.url)("./cli-runtime.js");
@@ -0,0 +1,2 @@
1
+ import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
+ import{ShowImagesSelectorComponent,ThemeSelectorComponent}from"./chunks/chunk-EBFHJFEE.js";import{AgentSession,AgentSessionRuntime,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CURRENT_SESSION_VERSION,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DefaultPackageManager,DefaultResourceLoader,DynamicBorder,ExtensionEditorComponent,ExtensionInputComponent,ExtensionRunner,ExtensionSelectorComponent,FooterComponent,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,RpcClient,SessionManager,SessionSelectorComponent,SettingsManager,SettingsSelectorComponent,SkillInvocationMessageComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UserMessageComponent,UserMessageSelectorComponent,VIRTUAL_MODEL_STATE_ENTRY,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"./chunks/chunk-44DLKSKE.js";import{DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,formatReadLineRange,formatSize,truncateHead,truncateLine,truncateTail,truncateToVisualLines}from"./chunks/chunk-62VOPMLK.js";import{ArminComponent}from"./chunks/chunk-3TGLJEWK.js";import{Theme,getLanguageFromPath,getMarkdownTheme,getSelectListTheme,getSettingsListTheme,highlightCode,initTheme,keyHint,keyText,rawKeyHint}from"./chunks/chunk-4EYXVSA5.js";import{ProjectTrustStore,hasTrustRequiringProjectResources}from"./chunks/chunk-NZY7EIPA.js";import{readStoredCredential}from"./chunks/chunk-R2EGYMOO.js";import{getPowerShellConfig,getShellConfig}from"./chunks/chunk-YZKQS34S.js";import"./chunks/chunk-6QGV3IWD.js";import{CONFIG_DIR_NAME,VERSION,getAgentDir,getDocsPath,getExamplesPath,getPackageDir,getReadmePath}from"./chunks/chunk-36QC74V4.js";import"./chunks/chunk-USJZMAIR.js";import"./chunks/chunk-5AGIVGSV.js";import"./chunks/chunk-UKVNB6C4.js";import"./chunks/chunk-TMTOQ7H7.js";import"./chunks/chunk-7DDKXS2Q.js";import"./chunks/chunk-FFMDRXC4.js";import"./chunks/chunk-NL4X6LBY.js";import"./chunks/chunk-LPXNMA2W.js";import"./chunks/chunk-V6KH5QG4.js";import"./chunks/chunk-JXWJOIH4.js";export{AgentSession,AgentSessionRuntime,ArminComponent,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CONFIG_DIR_NAME,CURRENT_SESSION_VERSION,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,DefaultPackageManager,DefaultResourceLoader,DynamicBorder,ExtensionEditorComponent,ExtensionInputComponent,ExtensionRunner,ExtensionSelectorComponent,FooterComponent,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,ProjectTrustStore,RpcClient,SessionManager,SessionSelectorComponent,SettingsManager,SettingsSelectorComponent,ShowImagesSelectorComponent,SkillInvocationMessageComponent,Theme,ThemeSelectorComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UserMessageComponent,UserMessageSelectorComponent,VERSION,VIRTUAL_MODEL_STATE_ENTRY,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,formatReadLineRange,formatSize,formatSkillsForPrompt,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getAgentDir,getDocsPath,getExamplesPath,getLanguageFromPath,getLastAssistantUsage,getLatestCompactionEntry,getMarkdownTheme,getPackageDir,getPowerShellConfig,getReadmePath,getSelectListTheme,getSettingsListTheme,getShellConfig,hasTrustRequiringProjectResources,highlightCode,initTheme,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isPowerShellToolResult,isReadToolResult,isToolCallEventType,isWriteToolResult,keyHint,keyText,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,migrateSessionEntries,parseArgs,parseFrontmatter,parseSessionEntries,parseSkillBlock,prepareBranchEntries,rawKeyHint,readStoredCredential,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runPrintMode,runRpcMode,serializeConversation,sessionEntryToContextMessages,shouldCompact,stripFrontmatter,truncateHead,truncateLine,truncateTail,truncateToVisualLines,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
3
+ import{configureHttpDispatcher,main}from"./chunks/chunk-44DLKSKE.js";import"./chunks/chunk-62VOPMLK.js";import"./chunks/chunk-3TGLJEWK.js";import"./chunks/chunk-4EYXVSA5.js";import"./chunks/chunk-NZY7EIPA.js";import"./chunks/chunk-R2EGYMOO.js";import"./chunks/chunk-YZKQS34S.js";import"./chunks/chunk-6QGV3IWD.js";import{APP_NAME}from"./chunks/chunk-36QC74V4.js";import"./chunks/chunk-USJZMAIR.js";import"./chunks/chunk-5AGIVGSV.js";import"./chunks/chunk-UKVNB6C4.js";import"./chunks/chunk-TMTOQ7H7.js";import"./chunks/chunk-7DDKXS2Q.js";import"./chunks/chunk-FFMDRXC4.js";import"./chunks/chunk-NL4X6LBY.js";import"./chunks/chunk-LPXNMA2W.js";import"./chunks/chunk-V6KH5QG4.js";import"./chunks/chunk-JXWJOIH4.js";process.title=`${APP_NAME}-rpc`;process.env.PI_CODING_AGENT="true";process.env.AI_AGENT="pi";process.emitWarning=(()=>{});configureHttpDispatcher();main(["--mode","rpc",...process.argv.slice(2)]);
@@ -0,0 +1,249 @@
1
+ /**
2
+ * ANSI escape code to HTML converter.
3
+ *
4
+ * Converts terminal ANSI color/style codes to HTML with inline styles.
5
+ * Supports:
6
+ * - Standard foreground colors (30-37) and bright variants (90-97)
7
+ * - Standard background colors (40-47) and bright variants (100-107)
8
+ * - 256-color palette (38;5;N and 48;5;N)
9
+ * - RGB true color (38;2;R;G;B and 48;2;R;G;B)
10
+ * - Text styles: bold (1), dim (2), italic (3), underline (4)
11
+ * - Reset (0)
12
+ */
13
+ // Standard ANSI color palette (0-15)
14
+ const ANSI_COLORS = [
15
+ "#000000", // 0: black
16
+ "#800000", // 1: red
17
+ "#008000", // 2: green
18
+ "#808000", // 3: yellow
19
+ "#000080", // 4: blue
20
+ "#800080", // 5: magenta
21
+ "#008080", // 6: cyan
22
+ "#c0c0c0", // 7: white
23
+ "#808080", // 8: bright black
24
+ "#ff0000", // 9: bright red
25
+ "#00ff00", // 10: bright green
26
+ "#ffff00", // 11: bright yellow
27
+ "#0000ff", // 12: bright blue
28
+ "#ff00ff", // 13: bright magenta
29
+ "#00ffff", // 14: bright cyan
30
+ "#ffffff", // 15: bright white
31
+ ];
32
+ /**
33
+ * Convert 256-color index to hex.
34
+ */
35
+ function color256ToHex(index) {
36
+ // Standard colors (0-15)
37
+ if (index < 16) {
38
+ return ANSI_COLORS[index];
39
+ }
40
+ // Color cube (16-231): 6x6x6 = 216 colors
41
+ if (index < 232) {
42
+ const cubeIndex = index - 16;
43
+ const r = Math.floor(cubeIndex / 36);
44
+ const g = Math.floor((cubeIndex % 36) / 6);
45
+ const b = cubeIndex % 6;
46
+ const toComponent = (n) => (n === 0 ? 0 : 55 + n * 40);
47
+ const toHex = (n) => toComponent(n).toString(16).padStart(2, "0");
48
+ return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
49
+ }
50
+ // Grayscale (232-255): 24 shades
51
+ const gray = 8 + (index - 232) * 10;
52
+ const grayHex = gray.toString(16).padStart(2, "0");
53
+ return `#${grayHex}${grayHex}${grayHex}`;
54
+ }
55
+ /**
56
+ * Escape HTML special characters.
57
+ */
58
+ function escapeHtml(text) {
59
+ return text
60
+ .replace(/&/g, "&amp;")
61
+ .replace(/</g, "&lt;")
62
+ .replace(/>/g, "&gt;")
63
+ .replace(/"/g, "&quot;")
64
+ .replace(/'/g, "&#039;");
65
+ }
66
+ function createEmptyStyle() {
67
+ return {
68
+ fg: null,
69
+ bg: null,
70
+ bold: false,
71
+ dim: false,
72
+ italic: false,
73
+ underline: false,
74
+ };
75
+ }
76
+ function styleToInlineCSS(style) {
77
+ const parts = [];
78
+ if (style.fg)
79
+ parts.push(`color:${style.fg}`);
80
+ if (style.bg)
81
+ parts.push(`background-color:${style.bg}`);
82
+ if (style.bold)
83
+ parts.push("font-weight:bold");
84
+ if (style.dim)
85
+ parts.push("opacity:0.6");
86
+ if (style.italic)
87
+ parts.push("font-style:italic");
88
+ if (style.underline)
89
+ parts.push("text-decoration:underline");
90
+ return parts.join(";");
91
+ }
92
+ function hasStyle(style) {
93
+ return style.fg !== null || style.bg !== null || style.bold || style.dim || style.italic || style.underline;
94
+ }
95
+ /**
96
+ * Parse ANSI SGR (Select Graphic Rendition) codes and update style.
97
+ */
98
+ function applySgrCode(params, style) {
99
+ let i = 0;
100
+ while (i < params.length) {
101
+ const code = params[i];
102
+ if (code === 0) {
103
+ // Reset all
104
+ style.fg = null;
105
+ style.bg = null;
106
+ style.bold = false;
107
+ style.dim = false;
108
+ style.italic = false;
109
+ style.underline = false;
110
+ }
111
+ else if (code === 1) {
112
+ style.bold = true;
113
+ }
114
+ else if (code === 2) {
115
+ style.dim = true;
116
+ }
117
+ else if (code === 3) {
118
+ style.italic = true;
119
+ }
120
+ else if (code === 4) {
121
+ style.underline = true;
122
+ }
123
+ else if (code === 22) {
124
+ // Reset bold/dim
125
+ style.bold = false;
126
+ style.dim = false;
127
+ }
128
+ else if (code === 23) {
129
+ style.italic = false;
130
+ }
131
+ else if (code === 24) {
132
+ style.underline = false;
133
+ }
134
+ else if (code >= 30 && code <= 37) {
135
+ // Standard foreground colors
136
+ style.fg = ANSI_COLORS[code - 30];
137
+ }
138
+ else if (code === 38) {
139
+ // Extended foreground color
140
+ if (params[i + 1] === 5 && params.length > i + 2) {
141
+ // 256-color: 38;5;N
142
+ style.fg = color256ToHex(params[i + 2]);
143
+ i += 2;
144
+ }
145
+ else if (params[i + 1] === 2 && params.length > i + 4) {
146
+ // RGB: 38;2;R;G;B
147
+ const r = params[i + 2];
148
+ const g = params[i + 3];
149
+ const b = params[i + 4];
150
+ style.fg = `rgb(${r},${g},${b})`;
151
+ i += 4;
152
+ }
153
+ }
154
+ else if (code === 39) {
155
+ // Default foreground
156
+ style.fg = null;
157
+ }
158
+ else if (code >= 40 && code <= 47) {
159
+ // Standard background colors
160
+ style.bg = ANSI_COLORS[code - 40];
161
+ }
162
+ else if (code === 48) {
163
+ // Extended background color
164
+ if (params[i + 1] === 5 && params.length > i + 2) {
165
+ // 256-color: 48;5;N
166
+ style.bg = color256ToHex(params[i + 2]);
167
+ i += 2;
168
+ }
169
+ else if (params[i + 1] === 2 && params.length > i + 4) {
170
+ // RGB: 48;2;R;G;B
171
+ const r = params[i + 2];
172
+ const g = params[i + 3];
173
+ const b = params[i + 4];
174
+ style.bg = `rgb(${r},${g},${b})`;
175
+ i += 4;
176
+ }
177
+ }
178
+ else if (code === 49) {
179
+ // Default background
180
+ style.bg = null;
181
+ }
182
+ else if (code >= 90 && code <= 97) {
183
+ // Bright foreground colors
184
+ style.fg = ANSI_COLORS[code - 90 + 8];
185
+ }
186
+ else if (code >= 100 && code <= 107) {
187
+ // Bright background colors
188
+ style.bg = ANSI_COLORS[code - 100 + 8];
189
+ }
190
+ // Ignore unrecognized codes
191
+ i++;
192
+ }
193
+ }
194
+ // Match ANSI escape sequences: ESC[ followed by params and ending with 'm'
195
+ const ANSI_REGEX = /\x1b\[([\d;]*)m/g;
196
+ /**
197
+ * Convert ANSI-escaped text to HTML with inline styles.
198
+ */
199
+ export function ansiToHtml(text) {
200
+ const style = createEmptyStyle();
201
+ let result = "";
202
+ let lastIndex = 0;
203
+ let inSpan = false;
204
+ // Reset regex state
205
+ ANSI_REGEX.lastIndex = 0;
206
+ let match = ANSI_REGEX.exec(text);
207
+ while (match !== null) {
208
+ // Add text before this escape sequence
209
+ const beforeText = text.slice(lastIndex, match.index);
210
+ if (beforeText) {
211
+ result += escapeHtml(beforeText);
212
+ }
213
+ // Parse SGR parameters
214
+ const paramStr = match[1];
215
+ const params = paramStr ? paramStr.split(";").map((p) => parseInt(p, 10) || 0) : [0];
216
+ // Close existing span if we have one
217
+ if (inSpan) {
218
+ result += "</span>";
219
+ inSpan = false;
220
+ }
221
+ // Apply the codes
222
+ applySgrCode(params, style);
223
+ // Open new span if we have any styling
224
+ if (hasStyle(style)) {
225
+ result += `<span style="${styleToInlineCSS(style)}">`;
226
+ inSpan = true;
227
+ }
228
+ lastIndex = match.index + match[0].length;
229
+ match = ANSI_REGEX.exec(text);
230
+ }
231
+ // Add remaining text
232
+ const remainingText = text.slice(lastIndex);
233
+ if (remainingText) {
234
+ result += escapeHtml(remainingText);
235
+ }
236
+ // Close any open span
237
+ if (inSpan) {
238
+ result += "</span>";
239
+ }
240
+ return result;
241
+ }
242
+ /**
243
+ * Convert array of ANSI-escaped lines to HTML.
244
+ * Each line is wrapped in a div element.
245
+ */
246
+ export function ansiLinesToHtml(lines) {
247
+ return lines.map((line) => `<div class="ansi-line">${ansiToHtml(line) || "&nbsp;"}</div>`).join("");
248
+ }
249
+ //# sourceMappingURL=ansi-to-html.js.map
@@ -0,0 +1,228 @@
1
+ import { existsSync, readFileSync, writeFileSync } from "fs";
2
+ import { basename, join } from "path";
3
+ import { APP_NAME, getExportTemplateDir } from "../../config.js";
4
+ import { getResolvedThemeColors, getThemeExportColors } from "../../modes/interactive/theme/theme.js";
5
+ import { normalizePath, resolvePath } from "../../utils/paths.js";
6
+ import { SessionManager } from "../session-manager.js";
7
+ /** Parse a color string to RGB values. Supports hex (#RRGGBB) and rgb(r,g,b) formats. */
8
+ function parseColor(color) {
9
+ const hexMatch = color.match(/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/);
10
+ if (hexMatch) {
11
+ return {
12
+ r: Number.parseInt(hexMatch[1], 16),
13
+ g: Number.parseInt(hexMatch[2], 16),
14
+ b: Number.parseInt(hexMatch[3], 16),
15
+ };
16
+ }
17
+ const rgbMatch = color.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);
18
+ if (rgbMatch) {
19
+ return {
20
+ r: Number.parseInt(rgbMatch[1], 10),
21
+ g: Number.parseInt(rgbMatch[2], 10),
22
+ b: Number.parseInt(rgbMatch[3], 10),
23
+ };
24
+ }
25
+ return undefined;
26
+ }
27
+ /** Calculate relative luminance of a color (0-1, higher = lighter). */
28
+ function getLuminance(r, g, b) {
29
+ const toLinear = (c) => {
30
+ const s = c / 255;
31
+ return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
32
+ };
33
+ return 0.2126 * toLinear(r) + 0.7152 * toLinear(g) + 0.0722 * toLinear(b);
34
+ }
35
+ /** Adjust color brightness. Factor > 1 lightens, < 1 darkens. */
36
+ function adjustBrightness(color, factor) {
37
+ const parsed = parseColor(color);
38
+ if (!parsed)
39
+ return color;
40
+ const adjust = (c) => Math.min(255, Math.max(0, Math.round(c * factor)));
41
+ return `rgb(${adjust(parsed.r)}, ${adjust(parsed.g)}, ${adjust(parsed.b)})`;
42
+ }
43
+ /** Derive export background colors from a base color (e.g., userMessageBg). */
44
+ function deriveExportColors(baseColor) {
45
+ const parsed = parseColor(baseColor);
46
+ if (!parsed) {
47
+ return {
48
+ pageBg: "rgb(24, 24, 30)",
49
+ cardBg: "rgb(30, 30, 36)",
50
+ infoBg: "rgb(60, 55, 40)",
51
+ };
52
+ }
53
+ const luminance = getLuminance(parsed.r, parsed.g, parsed.b);
54
+ const isLight = luminance > 0.5;
55
+ if (isLight) {
56
+ return {
57
+ pageBg: adjustBrightness(baseColor, 0.96),
58
+ cardBg: baseColor,
59
+ infoBg: `rgb(${Math.min(255, parsed.r + 10)}, ${Math.min(255, parsed.g + 5)}, ${Math.max(0, parsed.b - 20)})`,
60
+ };
61
+ }
62
+ return {
63
+ pageBg: adjustBrightness(baseColor, 0.7),
64
+ cardBg: adjustBrightness(baseColor, 0.85),
65
+ infoBg: `rgb(${Math.min(255, parsed.r + 20)}, ${Math.min(255, parsed.g + 15)}, ${parsed.b})`,
66
+ };
67
+ }
68
+ /**
69
+ * Generate CSS custom property declarations from theme colors.
70
+ */
71
+ function generateThemeVars(themeName) {
72
+ const colors = getResolvedThemeColors(themeName);
73
+ const lines = [];
74
+ for (const [key, value] of Object.entries(colors)) {
75
+ lines.push(`--${key}: ${value};`);
76
+ }
77
+ // Use explicit theme export colors if available, otherwise derive from userMessageBg
78
+ const themeExport = getThemeExportColors(themeName);
79
+ const userMessageBg = colors.userMessageBg || "#343541";
80
+ const derivedColors = deriveExportColors(userMessageBg);
81
+ lines.push(`--exportPageBg: ${themeExport.pageBg ?? derivedColors.pageBg};`);
82
+ lines.push(`--exportCardBg: ${themeExport.cardBg ?? derivedColors.cardBg};`);
83
+ lines.push(`--exportInfoBg: ${themeExport.infoBg ?? derivedColors.infoBg};`);
84
+ return lines.join("\n ");
85
+ }
86
+ /**
87
+ * Core HTML generation logic shared by both export functions.
88
+ */
89
+ function generateHtml(sessionData, themeName) {
90
+ const templateDir = getExportTemplateDir();
91
+ const template = readFileSync(join(templateDir, "template.html"), "utf-8");
92
+ const templateCss = readFileSync(join(templateDir, "template.css"), "utf-8");
93
+ const templateJs = readFileSync(join(templateDir, "template.js"), "utf-8");
94
+ const markedJs = readFileSync(join(templateDir, "vendor", "marked.min.js"), "utf-8");
95
+ const markedCjkFriendlyJs = readFileSync(join(templateDir, "vendor", "marked-cjk-friendly.min.js"), "utf-8");
96
+ const hljsJs = readFileSync(join(templateDir, "vendor", "highlight.min.js"), "utf-8");
97
+ const themeVars = generateThemeVars(themeName);
98
+ const colors = getResolvedThemeColors(themeName);
99
+ const themeExport = getThemeExportColors(themeName);
100
+ const derivedExportColors = deriveExportColors(colors.userMessageBg || "#343541");
101
+ const bodyBg = themeExport.pageBg ?? derivedExportColors.pageBg;
102
+ const containerBg = themeExport.cardBg ?? derivedExportColors.cardBg;
103
+ const infoBg = themeExport.infoBg ?? derivedExportColors.infoBg;
104
+ // Base64 encode session data to avoid escaping issues
105
+ const sessionDataBase64 = Buffer.from(JSON.stringify(sessionData)).toString("base64");
106
+ // Build the CSS with theme variables injected
107
+ const css = templateCss
108
+ .replace("{{THEME_VARS}}", themeVars)
109
+ .replace("{{BODY_BG}}", bodyBg)
110
+ .replace("{{CONTAINER_BG}}", containerBg)
111
+ .replace("{{INFO_BG}}", infoBg);
112
+ return template
113
+ .replace("{{CSS}}", css)
114
+ .replace("{{JS}}", templateJs)
115
+ .replace("{{SESSION_DATA}}", sessionDataBase64)
116
+ .replace("{{MARKED_JS}}", markedJs)
117
+ .replace("{{MARKED_CJK_FRIENDLY_JS}}", markedCjkFriendlyJs)
118
+ .replace("{{HIGHLIGHT_JS}}", hljsJs);
119
+ }
120
+ /** Tools rendered directly by the HTML template (not pre-rendered via TUI→ANSI→HTML pipeline) */
121
+ const TEMPLATE_RENDERED_TOOLS = new Set(["bash", "read", "write", "edit", "ls"]);
122
+ /**
123
+ * Pre-render custom tools to HTML using their TUI renderers.
124
+ */
125
+ function preRenderCustomTools(entries, toolRenderer) {
126
+ const renderedTools = {};
127
+ for (const entry of entries) {
128
+ if (entry.type !== "message")
129
+ continue;
130
+ const msg = entry.message;
131
+ // Find tool calls in assistant messages
132
+ if (msg.role === "assistant" && Array.isArray(msg.content)) {
133
+ for (const block of msg.content) {
134
+ if (block.type === "toolCall" && !TEMPLATE_RENDERED_TOOLS.has(block.name)) {
135
+ const callHtml = toolRenderer.renderCall(block.id, block.name, block.arguments);
136
+ if (callHtml) {
137
+ renderedTools[block.id] = { callHtml };
138
+ }
139
+ }
140
+ }
141
+ }
142
+ // Find tool results
143
+ if (msg.role === "toolResult" && msg.toolCallId) {
144
+ const toolName = msg.toolName || "";
145
+ // Only render if we have a pre-rendered call OR it's not template-rendered
146
+ const existing = renderedTools[msg.toolCallId];
147
+ if (existing || !TEMPLATE_RENDERED_TOOLS.has(toolName)) {
148
+ const rendered = toolRenderer.renderResult(msg.toolCallId, toolName, msg.content, msg.details, msg.isError || false);
149
+ if (rendered) {
150
+ renderedTools[msg.toolCallId] = {
151
+ ...existing,
152
+ resultHtmlCollapsed: rendered.collapsed,
153
+ resultHtmlExpanded: rendered.expanded,
154
+ };
155
+ }
156
+ }
157
+ }
158
+ }
159
+ return renderedTools;
160
+ }
161
+ /**
162
+ * Export session to HTML using SessionManager and AgentState.
163
+ * Used by TUI's /export command.
164
+ */
165
+ export async function exportSessionToHtml(sm, state, options) {
166
+ const opts = typeof options === "string" ? { outputPath: options } : options || {};
167
+ const sessionFile = sm.getSessionFile();
168
+ if (!sessionFile) {
169
+ throw new Error("Cannot export in-memory session to HTML");
170
+ }
171
+ if (!existsSync(sessionFile)) {
172
+ throw new Error("Nothing to export yet - start a conversation first");
173
+ }
174
+ const entries = sm.getEntries();
175
+ // Pre-render custom tools if a tool renderer is provided
176
+ let renderedTools;
177
+ if (opts.toolRenderer) {
178
+ renderedTools = preRenderCustomTools(entries, opts.toolRenderer);
179
+ // Only include if we actually rendered something
180
+ if (Object.keys(renderedTools).length === 0) {
181
+ renderedTools = undefined;
182
+ }
183
+ }
184
+ const sessionData = {
185
+ header: sm.getHeader(),
186
+ entries,
187
+ leafId: sm.getLeafId(),
188
+ systemPrompt: state?.systemPrompt,
189
+ tools: state?.tools?.map((t) => ({ name: t.name, description: t.description, parameters: t.parameters })),
190
+ renderedTools,
191
+ };
192
+ const html = generateHtml(sessionData, opts.themeName);
193
+ let outputPath = opts.outputPath ? normalizePath(opts.outputPath) : undefined;
194
+ if (!outputPath) {
195
+ const sessionBasename = basename(sessionFile, ".jsonl");
196
+ outputPath = `${APP_NAME}-session-${sessionBasename}.html`;
197
+ }
198
+ writeFileSync(outputPath, html, "utf8");
199
+ return outputPath;
200
+ }
201
+ /**
202
+ * Export session file to HTML (standalone, without AgentState).
203
+ * Used by CLI for exporting arbitrary session files.
204
+ */
205
+ export async function exportFromFile(inputPath, options) {
206
+ const opts = typeof options === "string" ? { outputPath: options } : options || {};
207
+ const resolvedInputPath = resolvePath(inputPath);
208
+ if (!existsSync(resolvedInputPath)) {
209
+ throw new Error(`File not found: ${resolvedInputPath}`);
210
+ }
211
+ const sm = SessionManager.open(resolvedInputPath);
212
+ const sessionData = {
213
+ header: sm.getHeader(),
214
+ entries: sm.getEntries(),
215
+ leafId: sm.getLeafId(),
216
+ systemPrompt: undefined,
217
+ tools: undefined,
218
+ };
219
+ const html = generateHtml(sessionData, opts.themeName);
220
+ let outputPath = opts.outputPath ? normalizePath(opts.outputPath) : undefined;
221
+ if (!outputPath) {
222
+ const inputBasename = basename(resolvedInputPath, ".jsonl");
223
+ outputPath = `${APP_NAME}-session-${inputBasename}.html`;
224
+ }
225
+ writeFileSync(outputPath, html, "utf8");
226
+ return outputPath;
227
+ }
228
+ //# sourceMappingURL=index.js.map