dal-code 1.0.24 → 1.0.26

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 (591) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/NOTICE +7 -0
  3. package/dal-docs/README.md +109 -0
  4. package/dal-docs/extensions.md +98 -0
  5. package/dal-docs/keybindings.md +40 -0
  6. package/dal-docs/packages.md +62 -0
  7. package/dal-docs/prompt-templates.md +42 -0
  8. package/dal-docs/settings.md +86 -0
  9. package/dal-docs/skills.md +65 -0
  10. package/dal-docs/themes.md +44 -0
  11. package/dist/cli/args.d.ts +59 -0
  12. package/dist/cli/args.js +14 -14
  13. package/dist/config.d.ts +63 -0
  14. package/dist/config.js +1 -1
  15. package/dist/core/agent-session-runtime.d.ts +74 -0
  16. package/dist/core/agent-session-services.d.ts +50 -0
  17. package/dist/core/agent-session-services.js +1 -1
  18. package/dist/core/agent-session.d.ts +422 -0
  19. package/dist/core/agent-session.js +8 -7
  20. package/dist/core/auth-storage.d.ts +56 -0
  21. package/dist/core/background-processes.d.ts +73 -0
  22. package/dist/core/background-processes.js +7 -0
  23. package/dist/core/bash-executor.d.ts +13 -0
  24. package/dist/core/cache-warmer.d.ts +60 -0
  25. package/dist/core/compaction/branch-summarization.d.ts +43 -0
  26. package/dist/core/compaction/compaction.d.ts +62 -0
  27. package/dist/core/compaction/index.d.ts +3 -0
  28. package/dist/core/compaction/utils.d.ts +16 -0
  29. package/dist/core/diagnostics.d.ts +14 -0
  30. package/dist/core/event-bus.d.ts +8 -0
  31. package/dist/core/exec.d.ts +12 -0
  32. package/dist/core/extensions/index.d.ts +8 -0
  33. package/dist/core/extensions/loader.d.ts +13 -0
  34. package/dist/core/extensions/loader.js +1 -1
  35. package/dist/core/extensions/permission-surface.js +1 -1
  36. package/dist/core/extensions/runner.d.ts +165 -0
  37. package/dist/core/extensions/runner.js +1 -1
  38. package/dist/core/extensions/types.d.ts +1003 -0
  39. package/dist/core/extensions/wrapper.d.ts +5 -0
  40. package/dist/core/footer-data-provider.d.ts +46 -0
  41. package/dist/core/host-capabilities.d.ts +50 -0
  42. package/dist/core/host-capabilities.js +2 -0
  43. package/dist/core/keybindings.d.ts +525 -0
  44. package/dist/core/messages.d.ts +50 -0
  45. package/dist/core/model-config.d.ts +1212 -0
  46. package/dist/core/model-registry.d.ts +41 -0
  47. package/dist/core/model-resolver.d.ts +67 -0
  48. package/dist/core/model-resolver.js +1 -1
  49. package/dist/core/model-runtime.d.ts +101 -0
  50. package/dist/core/model-runtime.js +2 -2
  51. package/dist/core/package-manager.d.ts +213 -0
  52. package/dist/core/package-manager.js +2 -2
  53. package/dist/core/permissions/rules.d.ts +45 -0
  54. package/dist/core/permissions/rules.js +1 -0
  55. package/dist/core/permissions/shell-words.js +2 -0
  56. package/dist/core/permissions/tool-policy.d.ts +46 -0
  57. package/dist/core/permissions/tool-policy.js +1 -0
  58. package/dist/core/project-map.d.ts +18 -0
  59. package/dist/core/prompt-templates.d.ts +24 -0
  60. package/dist/core/provider-composer.d.ts +55 -0
  61. package/dist/core/remote-catalog-provider.js +1 -1
  62. package/dist/core/resolve-config-value.d.ts +11 -0
  63. package/dist/core/resource-loader.d.ts +220 -0
  64. package/dist/core/resource-loader.js +1 -1
  65. package/dist/core/sandbox/availability.d.ts +9 -0
  66. package/dist/core/sandbox/availability.js +1 -0
  67. package/dist/core/sandbox/denial.d.ts +25 -0
  68. package/dist/core/sandbox/denial.js +3 -0
  69. package/dist/core/sandbox/index.d.ts +5 -0
  70. package/dist/core/sandbox/index.js +1 -0
  71. package/dist/core/sandbox/policy.d.ts +66 -0
  72. package/dist/core/sandbox/policy.js +1 -0
  73. package/dist/core/sandbox/runtime.d.ts +31 -0
  74. package/dist/core/sandbox/runtime.js +1 -0
  75. package/dist/core/sandbox/shell-sandbox.d.ts +119 -0
  76. package/dist/core/sandbox/shell-sandbox.js +5 -0
  77. package/dist/core/sdk.d.ts +43 -0
  78. package/dist/core/sdk.js +1 -1
  79. package/dist/core/session-manager.d.ts +208 -0
  80. package/dist/core/settings-manager.d.ts +368 -0
  81. package/dist/core/settings-manager.js +1 -1
  82. package/dist/core/skills.d.ts +33 -0
  83. package/dist/core/slash-commands.d.ts +14 -0
  84. package/dist/core/source-info.d.ts +17 -0
  85. package/dist/core/system-prompt.d.ts +39 -0
  86. package/dist/core/system-prompt.js +15 -11
  87. package/dist/core/tools/bash.d.ts +89 -0
  88. package/dist/core/tools/bash.js +16 -14
  89. package/dist/core/tools/edit-diff.d.ts +44 -0
  90. package/dist/core/tools/edit.d.ts +48 -0
  91. package/dist/core/tools/file-mutation-queue.d.ts +1 -0
  92. package/dist/core/tools/find.d.ts +34 -0
  93. package/dist/core/tools/find.js +11 -11
  94. package/dist/core/tools/grep.d.ts +34 -0
  95. package/dist/core/tools/grep.js +10 -10
  96. package/dist/core/tools/index.d.ts +43 -0
  97. package/dist/core/tools/index.js +1 -1
  98. package/dist/core/tools/ls.d.ts +33 -0
  99. package/dist/core/tools/ls.js +6 -6
  100. package/dist/core/tools/powershell.d.ts +17 -0
  101. package/dist/core/tools/powershell.js +2 -2
  102. package/dist/core/tools/process.d.ts +26 -0
  103. package/dist/core/tools/process.js +22 -0
  104. package/dist/core/tools/read.d.ts +33 -0
  105. package/dist/core/tools/read.js +15 -15
  106. package/dist/core/tools/renderers/bash.d.ts +3 -0
  107. package/dist/core/tools/renderers/edit.d.ts +15 -0
  108. package/dist/core/tools/renderers/find.d.ts +2 -0
  109. package/dist/core/tools/renderers/grep.d.ts +2 -0
  110. package/dist/core/tools/renderers/index.d.ts +13 -0
  111. package/dist/core/tools/renderers/ls.d.ts +2 -0
  112. package/dist/core/tools/renderers/read.d.ts +3 -0
  113. package/dist/core/tools/renderers/read.js +8 -8
  114. package/dist/core/tools/renderers/write.d.ts +2 -0
  115. package/dist/core/tools/truncate.d.ts +27 -0
  116. package/dist/core/tools/write.d.ts +24 -0
  117. package/dist/core/trust-manager.d.ts +28 -0
  118. package/dist/core/trust-manager.js +2 -2
  119. package/dist/dal/builtins.js +2 -2
  120. package/dist/dal/child-env.d.ts +12 -0
  121. package/dist/dal/child-env.js +1 -0
  122. package/dist/dal/hooks/activity.d.ts +17 -0
  123. package/dist/dal/hooks/activity.js +1 -0
  124. package/dist/dal/hooks/config.d.ts +47 -0
  125. package/dist/dal/hooks/config.js +1 -0
  126. package/dist/dal/hooks/events.d.ts +43 -0
  127. package/dist/dal/hooks/events.js +4 -0
  128. package/dist/dal/hooks/extension.d.ts +3 -0
  129. package/dist/dal/hooks/extension.js +4 -0
  130. package/dist/dal/hooks/index.d.ts +5 -0
  131. package/dist/dal/hooks/index.js +1 -0
  132. package/dist/dal/hooks/runner.d.ts +57 -0
  133. package/dist/dal/hooks/runner.js +1 -0
  134. package/dist/dal/manifest.d.ts +32 -0
  135. package/dist/dal/manifest.js +1 -0
  136. package/dist/dal/safety-net.js +1 -0
  137. package/dist/index.d.ts +44 -0
  138. package/dist/index.js +1 -1
  139. package/dist/main.d.ts +9 -0
  140. package/dist/main.js +4 -4
  141. package/dist/modes/acp/acp-mode.d.ts +2 -0
  142. package/dist/modes/index.d.ts +7 -0
  143. package/dist/modes/interactive/components/armin.d.ts +30 -0
  144. package/dist/modes/interactive/components/assistant-message.d.ts +26 -0
  145. package/dist/modes/interactive/components/bash-execution.d.ts +22 -0
  146. package/dist/modes/interactive/components/bordered-loader.d.ts +14 -0
  147. package/dist/modes/interactive/components/branch-summary-message.d.ts +11 -0
  148. package/dist/modes/interactive/components/compaction-summary-message.d.ts +11 -0
  149. package/dist/modes/interactive/components/config-selector.js +1 -1
  150. package/dist/modes/interactive/components/custom-editor.d.ts +21 -0
  151. package/dist/modes/interactive/components/custom-message.d.ts +17 -0
  152. package/dist/modes/interactive/components/daxnuts.d.ts +17 -0
  153. package/dist/modes/interactive/components/diff.d.ts +4 -0
  154. package/dist/modes/interactive/components/dynamic-border.d.ts +12 -0
  155. package/dist/modes/interactive/components/extension-editor.d.ts +19 -0
  156. package/dist/modes/interactive/components/extension-input.d.ts +21 -0
  157. package/dist/modes/interactive/components/extension-selector.d.ts +22 -0
  158. package/dist/modes/interactive/components/first-time-setup.d.ts +23 -0
  159. package/dist/modes/interactive/components/footer.d.ts +18 -0
  160. package/dist/modes/interactive/components/footer.js +1 -1
  161. package/dist/modes/interactive/components/index.d.ts +33 -0
  162. package/dist/modes/interactive/components/keybinding-hints.d.ts +9 -0
  163. package/dist/modes/interactive/components/login-dialog.d.ts +27 -0
  164. package/dist/modes/interactive/components/model-selector.d.ts +81 -0
  165. package/dist/modes/interactive/components/oauth-selector.d.ts +29 -0
  166. package/dist/modes/interactive/components/scoped-models-selector.d.ts +39 -0
  167. package/dist/modes/interactive/components/session-selector-search.d.ts +20 -0
  168. package/dist/modes/interactive/components/session-selector.d.ts +88 -0
  169. package/dist/modes/interactive/components/settings-selector.d.ts +92 -0
  170. package/dist/modes/interactive/components/show-images-selector.d.ts +6 -0
  171. package/dist/modes/interactive/components/skill-invocation-message.d.ts +11 -0
  172. package/dist/modes/interactive/components/status-indicator.d.ts +44 -0
  173. package/dist/modes/interactive/components/theme-selector.d.ts +7 -0
  174. package/dist/modes/interactive/components/thinking-selector.d.ts +19 -0
  175. package/dist/modes/interactive/components/tool-execution.d.ts +76 -0
  176. package/dist/modes/interactive/components/tree-selector.d.ts +65 -0
  177. package/dist/modes/interactive/components/trust-selector.d.ts +22 -0
  178. package/dist/modes/interactive/components/user-message-selector.d.ts +23 -0
  179. package/dist/modes/interactive/components/user-message.d.ts +14 -0
  180. package/dist/modes/interactive/components/visual-truncate.d.ts +5 -0
  181. package/dist/modes/interactive/interactive-mode.d.ts +326 -0
  182. package/dist/modes/interactive/theme/theme-json.d.ts +257 -0
  183. package/dist/modes/interactive/theme/theme.d.ts +106 -0
  184. package/dist/modes/interactive/tui-renderer.d.ts +18 -0
  185. package/dist/modes/json-event.d.ts +26 -0
  186. package/dist/modes/print-mode.d.ts +9 -0
  187. package/dist/modes/print-mode.js +6 -4
  188. package/dist/modes/rpc/rpc-client.d.ts +142 -0
  189. package/dist/modes/rpc/rpc-client.js +4 -1
  190. package/dist/modes/rpc/rpc-mode.d.ts +3 -0
  191. package/dist/modes/rpc/rpc-mode.js +1 -1
  192. package/dist/modes/rpc/rpc-types.d.ts +565 -0
  193. package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
  194. package/dist/node_modules/@dalcode/dal-bridge/src/ask-user.js +12 -0
  195. package/dist/node_modules/@dalcode/dal-bridge/src/client.js +1 -1
  196. package/dist/node_modules/@dalcode/dal-bridge/src/index.js +1 -1
  197. package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
  198. package/dist/node_modules/@dalcode/dal-gateway/src/index.js +1 -1
  199. package/dist/node_modules/@dalcode/dal-guard/package.json +5 -4
  200. package/dist/node_modules/@dalcode/dal-guard/src/hooks.js +1 -0
  201. package/dist/node_modules/@dalcode/dal-guard/src/index.js +1 -1
  202. package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
  203. package/dist/node_modules/@dalcode/dal-interactive/LICENSE +21 -0
  204. package/dist/node_modules/@dalcode/dal-interactive/package.json +33 -0
  205. package/dist/node_modules/@dalcode/dal-interactive/src/handoff.js +28 -0
  206. package/dist/node_modules/@dalcode/dal-interactive/src/index.js +1 -0
  207. package/dist/node_modules/@dalcode/dal-interactive/src/interactive-shell.js +1 -0
  208. package/dist/node_modules/@dalcode/dal-interactive/src/questionnaire.js +3 -0
  209. package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
  210. package/dist/node_modules/@dalcode/dal-lsp/package.json +3 -3
  211. package/dist/node_modules/@dalcode/dal-lsp/src/client.js +3 -3
  212. package/dist/node_modules/@dalcode/dal-mcp/package.json +5 -5
  213. package/dist/node_modules/@dalcode/dal-mcp/src/command-parser.d.ts +19 -0
  214. package/dist/node_modules/@dalcode/dal-mcp/src/config-edit.d.ts +19 -0
  215. package/dist/node_modules/@dalcode/dal-mcp/src/config.d.ts +9 -0
  216. package/dist/node_modules/@dalcode/dal-mcp/src/http-client.d.ts +16 -0
  217. package/dist/node_modules/@dalcode/dal-mcp/src/stdio-client.d.ts +22 -0
  218. package/dist/node_modules/@dalcode/dal-mcp/src/stdio-client.js +2 -2
  219. package/dist/node_modules/@dalcode/dal-mcp/src/types.d.ts +30 -0
  220. package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
  221. package/dist/node_modules/@dalcode/dal-office/src/extract/csv.d.ts +3 -0
  222. package/dist/node_modules/@dalcode/dal-office/src/extract/csv.js +1 -1
  223. package/dist/node_modules/@dalcode/dal-office/src/extract/ooxml.js +1 -1
  224. package/dist/node_modules/@dalcode/dal-office/src/index.d.ts +11 -0
  225. package/dist/node_modules/@dalcode/dal-office/src/index.js +1 -1
  226. package/dist/node_modules/@dalcode/dal-office/src/paths.d.ts +3 -0
  227. package/dist/node_modules/@dalcode/dal-office/src/render/chart.js +1 -1
  228. package/dist/node_modules/@dalcode/dal-office/src/render/docx.d.ts +19 -0
  229. package/dist/node_modules/@dalcode/dal-office/src/render/pptx.d.ts +40 -0
  230. package/dist/node_modules/@dalcode/dal-office/src/render/pptx.js +2 -2
  231. package/dist/node_modules/@dalcode/dal-office/src/render/thumbnails.d.ts +19 -0
  232. package/dist/node_modules/@dalcode/dal-office/src/render/thumbnails.js +1 -0
  233. package/dist/node_modules/@dalcode/dal-office/src/render/xlsx.d.ts +14 -0
  234. package/dist/node_modules/@dalcode/dal-office/src/scratchpad.d.ts +16 -0
  235. package/dist/node_modules/@dalcode/dal-office/src/themes.d.ts +13 -0
  236. package/dist/node_modules/@dalcode/dal-office/src/tools/docx-edit.js +10 -0
  237. package/dist/node_modules/@dalcode/dal-office/src/tools/edit-shared.js +1 -0
  238. package/dist/node_modules/@dalcode/dal-office/src/tools/pptx-edit.js +9 -0
  239. package/dist/node_modules/@dalcode/dal-office/src/tools/read-file.js +4 -2
  240. package/dist/node_modules/@dalcode/dal-office/src/tools/xlsx-edit.js +5 -0
  241. package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +2 -2
  242. package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
  243. package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +2 -2
  244. package/dist/node_modules/@dalcode/dal-plugins/package.json +2 -2
  245. package/dist/node_modules/@dalcode/dal-review/LICENSE +21 -0
  246. package/dist/node_modules/@dalcode/dal-review/package.json +34 -0
  247. package/dist/node_modules/@dalcode/dal-review/src/args.d.ts +13 -0
  248. package/dist/node_modules/@dalcode/dal-review/src/args.js +1 -0
  249. package/dist/node_modules/@dalcode/dal-review/src/core.d.ts +6 -0
  250. package/dist/node_modules/@dalcode/dal-review/src/core.js +1 -0
  251. package/dist/node_modules/@dalcode/dal-review/src/findings.d.ts +23 -0
  252. package/dist/node_modules/@dalcode/dal-review/src/findings.js +4 -0
  253. package/dist/node_modules/@dalcode/dal-review/src/index.js +1 -0
  254. package/dist/node_modules/@dalcode/dal-review/src/prompt.d.ts +3 -0
  255. package/dist/node_modules/@dalcode/dal-review/src/prompt.js +29 -0
  256. package/dist/node_modules/@dalcode/dal-review/src/runner.d.ts +91 -0
  257. package/dist/node_modules/@dalcode/dal-review/src/runner.js +2 -0
  258. package/dist/node_modules/@dalcode/dal-review/src/targets.d.ts +33 -0
  259. package/dist/node_modules/@dalcode/dal-review/src/targets.js +17 -0
  260. package/dist/node_modules/@dalcode/dal-review/src/types.d.ts +94 -0
  261. package/dist/node_modules/@dalcode/dal-review/src/types.js +1 -0
  262. package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
  263. package/dist/node_modules/@dalcode/dal-rewind/src/core.d.ts +61 -0
  264. package/dist/node_modules/@dalcode/dal-router/package.json +4 -4
  265. package/dist/node_modules/@dalcode/dal-router/src/config.d.ts +50 -0
  266. package/dist/node_modules/@dalcode/dal-router/src/jev.d.ts +51 -0
  267. package/dist/node_modules/@dalcode/dal-router/src/pool.d.ts +6 -0
  268. package/dist/node_modules/@dalcode/dal-router/src/router.d.ts +32 -0
  269. package/dist/node_modules/@dalcode/dal-router/src/runtime.d.ts +37 -0
  270. package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
  271. package/dist/node_modules/@dalcode/dal-skills/src/discover.js +4 -4
  272. package/dist/node_modules/@dalcode/dal-skills/src/index.js +9 -9
  273. package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
  274. package/dist/node_modules/@dalcode/dal-subagent/src/agents.js +2 -2
  275. package/dist/node_modules/@dalcode/dal-subagent/src/index.js +12 -12
  276. package/dist/node_modules/@dalcode/dal-subagent/src/process-runner.js +3 -3
  277. package/dist/node_modules/@dalcode/dal-telemetry/package.json +2 -2
  278. package/dist/node_modules/@dalcode/dal-terminal/LICENSE +21 -0
  279. package/dist/node_modules/@dalcode/dal-terminal/package.json +33 -0
  280. package/dist/node_modules/@dalcode/dal-terminal/src/contract.d.ts +60 -0
  281. package/dist/node_modules/@dalcode/dal-terminal/src/contract.js +7 -0
  282. package/dist/node_modules/@dalcode/dal-terminal/src/index.js +6 -0
  283. package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
  284. package/dist/node_modules/@dalcode/dal-tool-catalog/src/groups.js +1 -1
  285. package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
  286. package/dist/node_modules/@dalcode/dal-web/src/config.js +2 -2
  287. package/dist/node_modules/@dalcode/dal-web/src/index.js +4 -4
  288. package/dist/node_modules/@dalcode/dal-web/src/search.js +4 -4
  289. package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
  290. package/dist/node_modules/@dalcode/dal-workflow/src/index.js +4 -4
  291. package/dist/node_modules/@dalcode/dal-workflow/src/plan-mode.js +13 -13
  292. package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
  293. package/dist/node_modules/@dalcode/deepailab/src/index.js +3 -3
  294. package/dist/node_modules/@dalcode/deepailab/src/model-defaults.js +1 -1
  295. package/dist/node_modules/@earendil-works/chord/dist/api.d.ts +21 -0
  296. package/dist/node_modules/@earendil-works/chord/dist/context/index.d.ts +12 -0
  297. package/dist/node_modules/@earendil-works/chord/dist/delta/index.d.ts +127 -0
  298. package/dist/node_modules/@earendil-works/chord/dist/index.d.ts +8 -0
  299. package/dist/node_modules/@earendil-works/chord/dist/json.d.ts +2 -0
  300. package/dist/node_modules/@earendil-works/chord/dist/services/errors.d.ts +16 -0
  301. package/dist/node_modules/@earendil-works/chord/dist/services/provider.d.ts +32 -0
  302. package/dist/node_modules/@earendil-works/chord/dist/services/state-codec.d.ts +12 -0
  303. package/dist/node_modules/@earendil-works/chord/dist/services/wire.d.ts +59 -0
  304. package/dist/node_modules/@earendil-works/chord/dist/state/draft.d.ts +13 -0
  305. package/dist/node_modules/@earendil-works/chord/dist/types.d.ts +188 -0
  306. package/dist/node_modules/@earendil-works/chord/package.json +1 -1
  307. package/dist/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts +11 -0
  308. package/dist/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +1 -1
  309. package/dist/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts +80 -0
  310. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts +711 -0
  311. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.d.ts +44 -0
  312. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.d.ts +80 -0
  313. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.d.ts +15 -0
  314. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/context.d.ts +6 -0
  315. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/events.d.ts +22 -0
  316. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/execution/effect-gate.d.ts +17 -0
  317. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/hooks.d.ts +34 -0
  318. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.d.ts +50 -0
  319. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/prompt-templates.d.ts +28 -0
  320. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/result.d.ts +132 -0
  321. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/harness.d.ts +56 -0
  322. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/lane.d.ts +94 -0
  323. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/reducer.d.ts +3 -0
  324. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/types.d.ts +99 -0
  325. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/commit.d.ts +52 -0
  326. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork-policy.d.ts +19 -0
  327. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork.d.ts +13 -0
  328. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/index.d.ts +10 -0
  329. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/index.d.ts +3 -0
  330. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/repo.d.ts +33 -0
  331. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/storage.d.ts +37 -0
  332. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/types.d.ts +36 -0
  333. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory.d.ts +46 -0
  334. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/mutation-line.d.ts +6 -0
  335. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts +75 -0
  336. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/types.d.ts +473 -0
  337. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/values.d.ts +94 -0
  338. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.d.ts +26 -0
  339. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/system-prompt.d.ts +2 -0
  340. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/telemetry.d.ts +1495 -0
  341. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/bash.d.ts +26 -0
  342. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.d.ts +18 -0
  343. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/index.d.ts +5 -0
  344. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/read.d.ts +32 -0
  345. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/tool-context.d.ts +4 -0
  346. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.d.ts +10 -0
  347. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts +185 -0
  348. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/output-capture.d.ts +22 -0
  349. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.d.ts +22 -0
  350. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.d.ts +28 -0
  351. package/dist/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts +27 -0
  352. package/dist/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts +61 -0
  353. package/dist/node_modules/@earendil-works/pi-agent-core/dist/search/index.d.ts +28 -0
  354. package/dist/node_modules/@earendil-works/pi-agent-core/dist/stream-fn.d.ts +3 -0
  355. package/dist/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +150 -0
  356. package/dist/node_modules/@earendil-works/pi-agent-core/package.json +4 -4
  357. package/dist/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts +18 -0
  358. package/dist/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.lazy.d.ts +2 -0
  359. package/dist/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.d.ts +13 -0
  360. package/dist/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.lazy.d.ts +2 -0
  361. package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.d.ts +18 -0
  362. package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.lazy.d.ts +3 -0
  363. package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.d.ts +12 -0
  364. package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.lazy.d.ts +2 -0
  365. package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-shared.d.ts +24 -0
  366. package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.d.ts +14 -0
  367. package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.lazy.d.ts +2 -0
  368. package/dist/node_modules/@earendil-works/pi-ai/dist/api/lazy.d.ts +8 -0
  369. package/dist/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.d.ts +15 -0
  370. package/dist/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.lazy.d.ts +2 -0
  371. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts +30 -0
  372. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.lazy.d.ts +2 -0
  373. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts +24 -0
  374. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.lazy.d.ts +2 -0
  375. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts +10 -0
  376. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.lazy.d.ts +2 -0
  377. package/dist/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts +85 -0
  378. package/dist/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.lazy.d.ts +2 -0
  379. package/dist/node_modules/@earendil-works/pi-ai/dist/auth/context.d.ts +2 -0
  380. package/dist/node_modules/@earendil-works/pi-ai/dist/auth/credential-store.d.ts +10 -0
  381. package/dist/node_modules/@earendil-works/pi-ai/dist/auth/helpers.d.ts +8 -0
  382. package/dist/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts +20 -0
  383. package/dist/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts +127 -0
  384. package/dist/node_modules/@earendil-works/pi-ai/dist/cli.js +0 -0
  385. package/dist/node_modules/@earendil-works/pi-ai/dist/compat/extension-oauth-types.d.ts +34 -0
  386. package/dist/node_modules/@earendil-works/pi-ai/dist/compat.d.ts +47 -0
  387. package/dist/node_modules/@earendil-works/pi-ai/dist/env-api-keys.d.ts +9 -0
  388. package/dist/node_modules/@earendil-works/pi-ai/dist/image-models.d.ts +9 -0
  389. package/dist/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts +829 -0
  390. package/dist/node_modules/@earendil-works/pi-ai/dist/images-api-registry.d.ts +13 -0
  391. package/dist/node_modules/@earendil-works/pi-ai/dist/images-models.d.ts +37 -0
  392. package/dist/node_modules/@earendil-works/pi-ai/dist/images.d.ts +3 -0
  393. package/dist/node_modules/@earendil-works/pi-ai/dist/index.d.ts +38 -0
  394. package/dist/node_modules/@earendil-works/pi-ai/dist/legacy-api-aliases.d.ts +25 -0
  395. package/dist/node_modules/@earendil-works/pi-ai/dist/model-catalog.d.ts +16 -0
  396. package/dist/node_modules/@earendil-works/pi-ai/dist/models-store.d.ts +21 -0
  397. package/dist/node_modules/@earendil-works/pi-ai/dist/models.d.ts +97 -0
  398. package/dist/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +84 -0
  399. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/all.d.ts +18 -0
  400. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.d.ts +3 -0
  401. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.d.ts +3 -0
  402. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.d.ts +3 -0
  403. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts +3 -0
  404. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/baseten.models.d.ts +3 -0
  405. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.d.ts +3 -0
  406. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.d.ts +3 -0
  407. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.d.ts +3 -0
  408. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  409. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/azure-openai-responses.json +1 -1
  410. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
  411. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
  412. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  413. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
  414. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.d.ts +3 -0
  415. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/faux.d.ts +100 -0
  416. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.d.ts +3 -0
  417. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts +3 -0
  418. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.d.ts +3 -0
  419. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/google.models.d.ts +3 -0
  420. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.d.ts +3 -0
  421. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.d.ts +3 -0
  422. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.d.ts +3 -0
  423. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.d.ts +3 -0
  424. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/meta.models.d.ts +3 -0
  425. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.d.ts +3 -0
  426. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.d.ts +3 -0
  427. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.d.ts +3 -0
  428. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.d.ts +3 -0
  429. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.d.ts +3 -0
  430. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.d.ts +3 -0
  431. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.d.ts +3 -0
  432. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.d.ts +3 -0
  433. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts +3 -0
  434. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts +3 -0
  435. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts +3 -0
  436. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.models.d.ts +3 -0
  437. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-individual.models.d.ts +3 -0
  438. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.models.d.ts +3 -0
  439. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/radius.d.ts +7 -0
  440. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/radius.models.d.ts +3 -0
  441. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/together.models.d.ts +3 -0
  442. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts +3 -0
  443. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.d.ts +3 -0
  444. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.d.ts +3 -0
  445. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.d.ts +3 -0
  446. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.d.ts +3 -0
  447. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.d.ts +3 -0
  448. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.d.ts +3 -0
  449. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.d.ts +3 -0
  450. package/dist/node_modules/@earendil-works/pi-ai/dist/session-resources.d.ts +3 -0
  451. package/dist/node_modules/@earendil-works/pi-ai/dist/types.d.ts +502 -0
  452. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/assistant-message-frame.d.ts +63 -0
  453. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/diagnostics.d.ts +19 -0
  454. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.d.ts +19 -0
  455. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/json-parse.d.ts +3 -0
  456. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts +4 -0
  457. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts +16 -0
  458. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/text.d.ts +6 -0
  459. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/transcript.d.ts +29 -0
  460. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/typebox-helpers.d.ts +5 -0
  461. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/uuid.d.ts +1 -0
  462. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/validation.d.ts +3 -0
  463. package/dist/node_modules/@earendil-works/pi-ai/package.json +2 -2
  464. package/dist/node_modules/@earendil-works/pi-client/package.json +3 -3
  465. package/dist/node_modules/@earendil-works/pi-coding-agent/LICENSE +21 -0
  466. package/dist/node_modules/@earendil-works/pi-coding-agent/index.d.ts +1 -0
  467. package/dist/node_modules/@earendil-works/pi-coding-agent/index.js +1 -0
  468. package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +15 -0
  469. package/dist/node_modules/@earendil-works/pi-protocol/package.json +2 -2
  470. package/dist/node_modules/@earendil-works/pi-server/package.json +5 -5
  471. package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/package.json +3 -3
  472. package/dist/node_modules/@earendil-works/pi-telemetry/dist/index.d.ts +200 -0
  473. package/dist/node_modules/@earendil-works/pi-telemetry/dist/memory.d.ts +20 -0
  474. package/dist/node_modules/@earendil-works/pi-telemetry/dist/noop.d.ts +2 -0
  475. package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  476. package/dist/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts +55 -0
  477. package/dist/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts +20 -0
  478. package/dist/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.d.ts +9 -0
  479. package/dist/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts +151 -0
  480. package/dist/node_modules/@earendil-works/pi-tui/dist/components/h-stack.d.ts +6 -0
  481. package/dist/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts +25 -0
  482. package/dist/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts +43 -0
  483. package/dist/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts +28 -0
  484. package/dist/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts +61 -0
  485. package/dist/node_modules/@earendil-works/pi-tui/dist/components/mouse-region.d.ts +10 -0
  486. package/dist/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.d.ts +61 -0
  487. package/dist/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts +52 -0
  488. package/dist/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts +50 -0
  489. package/dist/node_modules/@earendil-works/pi-tui/dist/components/spacer.d.ts +8 -0
  490. package/dist/node_modules/@earendil-works/pi-tui/dist/components/stack.d.ts +35 -0
  491. package/dist/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts +15 -0
  492. package/dist/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.d.ts +9 -0
  493. package/dist/node_modules/@earendil-works/pi-tui/dist/components/v-stack.d.ts +7 -0
  494. package/dist/node_modules/@earendil-works/pi-tui/dist/editor-component.d.ts +17 -0
  495. package/dist/node_modules/@earendil-works/pi-tui/dist/fuzzy.d.ts +6 -0
  496. package/dist/node_modules/@earendil-works/pi-tui/dist/index.d.ts +32 -0
  497. package/dist/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +329 -0
  498. package/dist/node_modules/@earendil-works/pi-tui/dist/keys.d.ts +101 -0
  499. package/dist/node_modules/@earendil-works/pi-tui/dist/latex.d.ts +4 -0
  500. package/dist/node_modules/@earendil-works/pi-tui/dist/layout-node.d.ts +41 -0
  501. package/dist/node_modules/@earendil-works/pi-tui/dist/native-platform.d.ts +13 -0
  502. package/dist/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts +30 -0
  503. package/dist/node_modules/@earendil-works/pi-tui/dist/terminal-colors.d.ts +9 -0
  504. package/dist/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +82 -0
  505. package/dist/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts +76 -0
  506. package/dist/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts +138 -0
  507. package/dist/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.d.ts +32 -0
  508. package/dist/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +252 -0
  509. package/dist/node_modules/@earendil-works/pi-tui/dist/utils.d.ts +38 -0
  510. package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
  511. package/dist/package-manager-cli.js +32 -32
  512. package/dist/sdk/index.d.ts +18 -0
  513. package/dist/sdk/index.js +1 -0
  514. package/dist/sdk/mcp.d.ts +8 -0
  515. package/dist/sdk/mcp.js +1 -0
  516. package/dist/sdk/office.d.ts +1 -0
  517. package/dist/sdk/office.js +1 -0
  518. package/dist/sdk/review.d.ts +1 -0
  519. package/dist/sdk/review.js +1 -0
  520. package/dist/sdk/rewind.d.ts +1 -0
  521. package/dist/sdk/rewind.js +1 -0
  522. package/dist/sdk/router.d.ts +6 -0
  523. package/dist/sdk/router.js +1 -0
  524. package/dist/sdk/subagents.d.ts +8 -0
  525. package/dist/sdk/subagents.js +1 -0
  526. package/dist/utils/clipboard.d.ts +2 -0
  527. package/dist/utils/frontmatter.d.ts +7 -0
  528. package/dist/utils/image-convert.d.ts +5 -0
  529. package/dist/utils/image-resize-core.d.ts +16 -0
  530. package/dist/utils/image-resize.d.ts +4 -0
  531. package/dist/utils/mime.d.ts +2 -0
  532. package/dist/utils/shell.d.ts +20 -0
  533. package/dist/utils/shell.js +3 -3
  534. package/dist/utils/version-check.d.ts +20 -0
  535. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  536. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  537. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  538. package/examples/extensions/gondolin/package-lock.json +2 -2
  539. package/examples/extensions/gondolin/package.json +1 -1
  540. package/examples/extensions/sandbox/index.ts +6 -0
  541. package/examples/extensions/sandbox/package-lock.json +2 -2
  542. package/examples/extensions/sandbox/package.json +1 -1
  543. package/examples/extensions/with-deps/package-lock.json +2 -2
  544. package/examples/extensions/with-deps/package.json +1 -1
  545. package/npm-shrinkwrap.json +75 -5
  546. package/package.json +27 -1
  547. package/dist/bun/register-bedrock.js +0 -1
  548. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/reducer.js +0 -1
  549. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/errors.js +0 -1
  550. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.js +0 -1
  551. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js +0 -5
  552. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl.js +0 -1
  553. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.js +0 -1
  554. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js +0 -1
  555. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js +0 -1
  556. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/state.js +0 -1
  557. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/conformance.js +0 -1
  558. package/dist/node_modules/@earendil-works/pi-agent-core/dist/search/scanning.js +0 -1
  559. package/dist/node_modules/@earendil-works/pi-ai/dist/api/cloudflare-gateway-binding.js +0 -1
  560. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/deferred-tools.js +0 -1
  561. package/dist/node_modules/@earendil-works/pi-client/dist/session-handle.js +0 -1
  562. package/dist/node_modules/@earendil-works/pi-client/dist/state.js +0 -1
  563. package/dist/node_modules/@earendil-works/pi-server/dist/cli.js +0 -16
  564. package/dist/node_modules/@earendil-works/pi-server/dist/config.js +0 -1
  565. package/dist/node_modules/@earendil-works/pi-server/dist/handler.js +0 -1
  566. package/dist/node_modules/@earendil-works/pi-server/dist/ipc/client.js +0 -2
  567. package/dist/node_modules/@earendil-works/pi-server/dist/ipc/protocol.js +0 -2
  568. package/dist/node_modules/@earendil-works/pi-server/dist/ipc/server.js +0 -3
  569. package/dist/node_modules/@earendil-works/pi-server/dist/protocol.js +0 -1
  570. package/dist/node_modules/@earendil-works/pi-server/dist/radius.js +0 -1
  571. package/dist/node_modules/@earendil-works/pi-server/dist/rpc-process.js +0 -4
  572. package/dist/node_modules/@earendil-works/pi-server/dist/serve.js +0 -1
  573. package/dist/node_modules/@earendil-works/pi-server/dist/sessions.js +0 -1
  574. package/dist/node_modules/@earendil-works/pi-server/dist/snapshots.js +0 -1
  575. package/dist/node_modules/@earendil-works/pi-server/dist/storage.js +0 -1
  576. package/dist/node_modules/@earendil-works/pi-server/dist/supervisor.js +0 -1
  577. package/dist/node_modules/@earendil-works/pi-server/dist/testing/service.js +0 -1
  578. package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/branch-cache.js +0 -7
  579. package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/search-backend.js +0 -36
  580. package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/branch-entries.js +0 -25
  581. package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/branch-tips.js +0 -2
  582. package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/entries.js +0 -7
  583. package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/facts.js +0 -20
  584. package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/lanes.js +0 -26
  585. package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/records.js +0 -9
  586. package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/session-sequences.js +0 -1
  587. package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/session-stats.js +0 -10
  588. package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/sessions.js +0 -29
  589. package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/writer-leases.js +0 -14
  590. package/dist/server/create-harness.js +0 -1
  591. package/dist/utils/clipboard-native.js +0 -1
@@ -0,0 +1,257 @@
1
+ import { type Static, Type } from "typebox";
2
+ declare const ColorValueSchema: Type.TUnion<[
3
+ Type.TString,
4
+ Type.TInteger
5
+ ]>;
6
+ declare const ThemeJsonSchema: Type.TObject<{
7
+ $schema: Type.TOptional<Type.TString>;
8
+ name: Type.TString;
9
+ vars: Type.TOptional<Type.TRecord<"^.*$", Type.TUnion<[
10
+ Type.TString,
11
+ Type.TInteger
12
+ ]>>>;
13
+ colors: Type.TObject<{
14
+ accent: Type.TUnion<[
15
+ Type.TString,
16
+ Type.TInteger
17
+ ]>;
18
+ border: Type.TUnion<[
19
+ Type.TString,
20
+ Type.TInteger
21
+ ]>;
22
+ borderAccent: Type.TUnion<[
23
+ Type.TString,
24
+ Type.TInteger
25
+ ]>;
26
+ borderMuted: Type.TUnion<[
27
+ Type.TString,
28
+ Type.TInteger
29
+ ]>;
30
+ success: Type.TUnion<[
31
+ Type.TString,
32
+ Type.TInteger
33
+ ]>;
34
+ error: Type.TUnion<[
35
+ Type.TString,
36
+ Type.TInteger
37
+ ]>;
38
+ warning: Type.TUnion<[
39
+ Type.TString,
40
+ Type.TInteger
41
+ ]>;
42
+ muted: Type.TUnion<[
43
+ Type.TString,
44
+ Type.TInteger
45
+ ]>;
46
+ dim: Type.TUnion<[
47
+ Type.TString,
48
+ Type.TInteger
49
+ ]>;
50
+ text: Type.TUnion<[
51
+ Type.TString,
52
+ Type.TInteger
53
+ ]>;
54
+ thinkingText: Type.TUnion<[
55
+ Type.TString,
56
+ Type.TInteger
57
+ ]>;
58
+ scrollbarTrack: Type.TOptional<Type.TUnion<[
59
+ Type.TString,
60
+ Type.TInteger
61
+ ]>>;
62
+ scrollbarThumb: Type.TOptional<Type.TUnion<[
63
+ Type.TString,
64
+ Type.TInteger
65
+ ]>>;
66
+ selectedBg: Type.TUnion<[
67
+ Type.TString,
68
+ Type.TInteger
69
+ ]>;
70
+ searchMatchBg: Type.TOptional<Type.TUnion<[
71
+ Type.TString,
72
+ Type.TInteger
73
+ ]>>;
74
+ searchMatchText: Type.TOptional<Type.TUnion<[
75
+ Type.TString,
76
+ Type.TInteger
77
+ ]>>;
78
+ userMessageBg: Type.TUnion<[
79
+ Type.TString,
80
+ Type.TInteger
81
+ ]>;
82
+ userMessageText: Type.TUnion<[
83
+ Type.TString,
84
+ Type.TInteger
85
+ ]>;
86
+ customMessageBg: Type.TUnion<[
87
+ Type.TString,
88
+ Type.TInteger
89
+ ]>;
90
+ customMessageText: Type.TUnion<[
91
+ Type.TString,
92
+ Type.TInteger
93
+ ]>;
94
+ customMessageLabel: Type.TUnion<[
95
+ Type.TString,
96
+ Type.TInteger
97
+ ]>;
98
+ toolPendingBg: Type.TUnion<[
99
+ Type.TString,
100
+ Type.TInteger
101
+ ]>;
102
+ toolSuccessBg: Type.TUnion<[
103
+ Type.TString,
104
+ Type.TInteger
105
+ ]>;
106
+ toolErrorBg: Type.TUnion<[
107
+ Type.TString,
108
+ Type.TInteger
109
+ ]>;
110
+ toolTitle: Type.TUnion<[
111
+ Type.TString,
112
+ Type.TInteger
113
+ ]>;
114
+ toolOutput: Type.TUnion<[
115
+ Type.TString,
116
+ Type.TInteger
117
+ ]>;
118
+ mdHeading: Type.TUnion<[
119
+ Type.TString,
120
+ Type.TInteger
121
+ ]>;
122
+ mdLink: Type.TUnion<[
123
+ Type.TString,
124
+ Type.TInteger
125
+ ]>;
126
+ mdLinkUrl: Type.TUnion<[
127
+ Type.TString,
128
+ Type.TInteger
129
+ ]>;
130
+ mdCode: Type.TUnion<[
131
+ Type.TString,
132
+ Type.TInteger
133
+ ]>;
134
+ mdCodeBlock: Type.TUnion<[
135
+ Type.TString,
136
+ Type.TInteger
137
+ ]>;
138
+ mdCodeBlockBorder: Type.TUnion<[
139
+ Type.TString,
140
+ Type.TInteger
141
+ ]>;
142
+ mdQuote: Type.TUnion<[
143
+ Type.TString,
144
+ Type.TInteger
145
+ ]>;
146
+ mdQuoteBorder: Type.TUnion<[
147
+ Type.TString,
148
+ Type.TInteger
149
+ ]>;
150
+ mdHr: Type.TUnion<[
151
+ Type.TString,
152
+ Type.TInteger
153
+ ]>;
154
+ mdListBullet: Type.TUnion<[
155
+ Type.TString,
156
+ Type.TInteger
157
+ ]>;
158
+ toolDiffAdded: Type.TUnion<[
159
+ Type.TString,
160
+ Type.TInteger
161
+ ]>;
162
+ toolDiffRemoved: Type.TUnion<[
163
+ Type.TString,
164
+ Type.TInteger
165
+ ]>;
166
+ toolDiffContext: Type.TUnion<[
167
+ Type.TString,
168
+ Type.TInteger
169
+ ]>;
170
+ syntaxComment: Type.TUnion<[
171
+ Type.TString,
172
+ Type.TInteger
173
+ ]>;
174
+ syntaxKeyword: Type.TUnion<[
175
+ Type.TString,
176
+ Type.TInteger
177
+ ]>;
178
+ syntaxFunction: Type.TUnion<[
179
+ Type.TString,
180
+ Type.TInteger
181
+ ]>;
182
+ syntaxVariable: Type.TUnion<[
183
+ Type.TString,
184
+ Type.TInteger
185
+ ]>;
186
+ syntaxString: Type.TUnion<[
187
+ Type.TString,
188
+ Type.TInteger
189
+ ]>;
190
+ syntaxNumber: Type.TUnion<[
191
+ Type.TString,
192
+ Type.TInteger
193
+ ]>;
194
+ syntaxType: Type.TUnion<[
195
+ Type.TString,
196
+ Type.TInteger
197
+ ]>;
198
+ syntaxOperator: Type.TUnion<[
199
+ Type.TString,
200
+ Type.TInteger
201
+ ]>;
202
+ syntaxPunctuation: Type.TUnion<[
203
+ Type.TString,
204
+ Type.TInteger
205
+ ]>;
206
+ thinkingOff: Type.TUnion<[
207
+ Type.TString,
208
+ Type.TInteger
209
+ ]>;
210
+ thinkingMinimal: Type.TUnion<[
211
+ Type.TString,
212
+ Type.TInteger
213
+ ]>;
214
+ thinkingLow: Type.TUnion<[
215
+ Type.TString,
216
+ Type.TInteger
217
+ ]>;
218
+ thinkingMedium: Type.TUnion<[
219
+ Type.TString,
220
+ Type.TInteger
221
+ ]>;
222
+ thinkingHigh: Type.TUnion<[
223
+ Type.TString,
224
+ Type.TInteger
225
+ ]>;
226
+ thinkingXhigh: Type.TUnion<[
227
+ Type.TString,
228
+ Type.TInteger
229
+ ]>;
230
+ thinkingMax: Type.TOptional<Type.TUnion<[
231
+ Type.TString,
232
+ Type.TInteger
233
+ ]>>;
234
+ bashMode: Type.TUnion<[
235
+ Type.TString,
236
+ Type.TInteger
237
+ ]>;
238
+ }>;
239
+ export: Type.TOptional<Type.TObject<{
240
+ pageBg: Type.TOptional<Type.TUnion<[
241
+ Type.TString,
242
+ Type.TInteger
243
+ ]>>;
244
+ cardBg: Type.TOptional<Type.TUnion<[
245
+ Type.TString,
246
+ Type.TInteger
247
+ ]>>;
248
+ infoBg: Type.TOptional<Type.TUnion<[
249
+ Type.TString,
250
+ Type.TInteger
251
+ ]>>;
252
+ }>>;
253
+ }>;
254
+ export type ThemeColorValue = Static<typeof ColorValueSchema>;
255
+ export type ValidatedThemeJson = Static<typeof ThemeJsonSchema>;
256
+ export declare function validateThemeJson(label: string, json: unknown): ValidatedThemeJson;
257
+ export {};
@@ -0,0 +1,106 @@
1
+ import type { ThinkingLevel } from "@earendil-works/pi-agent-core";
2
+ import { type EditorTheme, type MarkdownTheme, type RgbColor, type SelectListTheme, type SettingsListTheme } from "@earendil-works/pi-tui";
3
+ import type { SourceInfo } from "../../../core/source-info.ts";
4
+ import type { ValidatedThemeJson as ThemeJson } from "./theme-json.ts";
5
+ export type { ValidatedThemeJson as ThemeJson } from "./theme-json.ts";
6
+ export type ThemeJsonValidator = (label: string, json: unknown) => ThemeJson;
7
+ export declare function setThemeJsonValidator(validator: ThemeJsonValidator): void;
8
+ export type ThemeColor = "accent" | "border" | "borderAccent" | "borderMuted" | "success" | "error" | "warning" | "muted" | "dim" | "text" | "thinkingText" | "scrollbarTrack" | "scrollbarThumb" | "searchMatchText" | "userMessageText" | "customMessageText" | "customMessageLabel" | "toolTitle" | "toolOutput" | "mdHeading" | "mdLink" | "mdLinkUrl" | "mdCode" | "mdCodeBlock" | "mdCodeBlockBorder" | "mdQuote" | "mdQuoteBorder" | "mdHr" | "mdListBullet" | "toolDiffAdded" | "toolDiffRemoved" | "toolDiffContext" | "syntaxComment" | "syntaxKeyword" | "syntaxFunction" | "syntaxVariable" | "syntaxString" | "syntaxNumber" | "syntaxType" | "syntaxOperator" | "syntaxPunctuation" | "thinkingOff" | "thinkingMinimal" | "thinkingLow" | "thinkingMedium" | "thinkingHigh" | "thinkingXhigh" | "thinkingMax" | "bashMode";
9
+ export type ThemeBg = "selectedBg" | "searchMatchBg" | "userMessageBg" | "customMessageBg" | "toolPendingBg" | "toolSuccessBg" | "toolErrorBg";
10
+ type OptionalThemeColor = "scrollbarTrack" | "scrollbarThumb" | "thinkingMax" | "searchMatchText";
11
+ type OptionalThemeBg = "searchMatchBg";
12
+ type ColorMode = "truecolor" | "256color";
13
+ export declare class Theme {
14
+ readonly name?: string;
15
+ readonly sourcePath?: string;
16
+ sourceInfo?: SourceInfo;
17
+ private fgColors;
18
+ private bgColors;
19
+ private mode;
20
+ constructor(fgColors: Record<Exclude<ThemeColor, OptionalThemeColor>, string | number> & Partial<Record<OptionalThemeColor, string | number>>, bgColors: Record<Exclude<ThemeBg, OptionalThemeBg>, string | number> & Partial<Record<OptionalThemeBg, string | number>>, mode: ColorMode, options?: {
21
+ name?: string;
22
+ sourcePath?: string;
23
+ sourceInfo?: SourceInfo;
24
+ });
25
+ fg(color: ThemeColor, text: string): string;
26
+ bg(color: ThemeBg, text: string): string;
27
+ bold(text: string): string;
28
+ italic(text: string): string;
29
+ underline(text: string): string;
30
+ inverse(text: string): string;
31
+ strikethrough(text: string): string;
32
+ getFgAnsi(color: ThemeColor): string;
33
+ getBgAnsi(color: ThemeBg): string;
34
+ getColorMode(): ColorMode;
35
+ getThinkingBorderColor(level: ThinkingLevel): (str: string) => string;
36
+ getBashModeBorderColor(): (str: string) => string;
37
+ }
38
+ export declare function getAvailableThemes(): string[];
39
+ export interface ThemeInfo {
40
+ name: string;
41
+ path: string | undefined;
42
+ }
43
+ export declare function getAvailableThemesWithPaths(): ThemeInfo[];
44
+ export declare function loadThemeFromPath(themePath: string, mode?: ColorMode): Theme;
45
+ export declare function getThemeByName(name: string): Theme | undefined;
46
+ export type TerminalTheme = "dark" | "light";
47
+ export declare function parseAutoThemeSetting(themeSetting: string | undefined): {
48
+ lightTheme: string;
49
+ darkTheme: string;
50
+ } | undefined;
51
+ export declare function resolveThemeSetting(themeSetting: string | undefined, terminalTheme: TerminalTheme): string | undefined;
52
+ export interface TerminalThemeDetection {
53
+ theme: TerminalTheme;
54
+ source: "terminal background" | "COLORFGBG" | "fallback";
55
+ detail: string;
56
+ confidence: "high" | "low";
57
+ }
58
+ export interface TerminalThemeDetectionOptions {
59
+ env?: NodeJS.ProcessEnv;
60
+ }
61
+ export interface TerminalBackgroundThemeDetector {
62
+ queryTerminalBackgroundColor({ timeoutMs }: {
63
+ timeoutMs: number;
64
+ }): Promise<RgbColor | undefined>;
65
+ }
66
+ export interface TerminalAutoThemeDetector extends TerminalBackgroundThemeDetector {
67
+ queryTerminalColorScheme?({ timeoutMs }: {
68
+ timeoutMs: number;
69
+ }): Promise<TerminalTheme | undefined>;
70
+ }
71
+ export interface TerminalBackgroundThemeDetectionOptions extends TerminalThemeDetectionOptions {
72
+ ui: TerminalBackgroundThemeDetector;
73
+ timeoutMs: number;
74
+ }
75
+ export interface TerminalAutoThemeDetectionOptions extends TerminalThemeDetectionOptions {
76
+ ui: TerminalAutoThemeDetector;
77
+ timeoutMs: number;
78
+ }
79
+ export declare function getThemeForRgbColor(rgb: RgbColor): TerminalTheme;
80
+ export declare function detectTerminalBackgroundFromEnv(options?: TerminalThemeDetectionOptions): TerminalThemeDetection;
81
+ export declare function detectTerminalBackgroundTheme({ ui, timeoutMs, env }: TerminalBackgroundThemeDetectionOptions): Promise<TerminalThemeDetection>;
82
+ export declare function detectTerminalThemeForAuto({ ui, timeoutMs, env }: TerminalAutoThemeDetectionOptions): Promise<TerminalTheme>;
83
+ export declare function getDefaultTheme(): string;
84
+ export declare const theme: Theme;
85
+ export declare function setRegisteredThemes(themes: Theme[]): void;
86
+ export declare function initTheme(themeName?: string, enableWatcher?: boolean): void;
87
+ export declare function setTheme(name: string, enableWatcher?: boolean): {
88
+ success: boolean;
89
+ error?: string;
90
+ };
91
+ export declare function setThemeInstance(themeInstance: Theme): void;
92
+ export declare function onThemeChange(callback: () => void): void;
93
+ export declare function stopThemeWatcher(): void;
94
+ export declare function getResolvedThemeColors(themeName?: string): Record<string, string>;
95
+ export declare function isLightTheme(themeName?: string): boolean;
96
+ export declare function getThemeExportColors(themeName?: string): {
97
+ pageBg?: string;
98
+ cardBg?: string;
99
+ infoBg?: string;
100
+ };
101
+ export declare function highlightCode(code: string, lang?: string): string[];
102
+ export declare function getLanguageFromPath(filePath: string): string | undefined;
103
+ export declare function getMarkdownTheme(): MarkdownTheme;
104
+ export declare function getSelectListTheme(): SelectListTheme;
105
+ export declare function getEditorTheme(): EditorTheme;
106
+ export declare function getSettingsListTheme(): SettingsListTheme;
@@ -0,0 +1,18 @@
1
+ import type { Terminal } from "@earendil-works/pi-tui";
2
+ import { type TUI, TuiAltScreen, TuiMainScreen } from "@earendil-works/pi-tui";
3
+ export interface InteractiveTuiOptions {
4
+ readonly tuiMode: "regular" | "fullscreen";
5
+ readonly showHardwareCursor: boolean;
6
+ readonly logDirectory: string;
7
+ readonly terminal?: Terminal;
8
+ readonly onRightClickPaste?: () => void;
9
+ readonly fullscreenCopyOnSelect?: boolean;
10
+ }
11
+ export declare function createInteractiveTui(options: InteractiveTuiOptions & {
12
+ readonly tuiMode: "fullscreen";
13
+ }): TuiAltScreen;
14
+ export declare function createInteractiveTui(options: InteractiveTuiOptions & {
15
+ readonly tuiMode: "regular";
16
+ }): TuiMainScreen;
17
+ export declare function createInteractiveTui(options: InteractiveTuiOptions): TuiMainScreen | TuiAltScreen;
18
+ export declare function createInteractiveTuiReference(getTui: () => TUI): TUI;
@@ -0,0 +1,26 @@
1
+ import type { Usage } from "@earendil-works/pi-ai";
2
+ import type { AgentSessionEvent } from "../core/agent-session.ts";
3
+ type WithoutPartial<T> = T extends {
4
+ partial: unknown;
5
+ } ? Omit<T, "partial"> : T;
6
+ type ToJsonAssistantMessageEvent<T> = T extends {
7
+ type: "toolcall_start";
8
+ partial: unknown;
9
+ } ? WithoutPartial<T> & {
10
+ id: string;
11
+ toolName: string;
12
+ } : WithoutPartial<T>;
13
+ type MessageUpdateEvent = Extract<AgentSessionEvent, {
14
+ type: "message_update";
15
+ }>;
16
+ type JsonMessageUpdateEvent = {
17
+ type: "message_update";
18
+ usage: Usage;
19
+ assistantMessageEvent: ToJsonAssistantMessageEvent<MessageUpdateEvent["assistantMessageEvent"]>;
20
+ };
21
+ export type JsonAgentSessionEvent = Exclude<AgentSessionEvent, {
22
+ type: "message_update";
23
+ }> | JsonMessageUpdateEvent;
24
+ export declare function toJsonEvent(event: MessageUpdateEvent): JsonMessageUpdateEvent;
25
+ export declare function toJsonEvent(event: AgentSessionEvent): JsonAgentSessionEvent;
26
+ export {};
@@ -0,0 +1,9 @@
1
+ import type { ImageContent } from "@earendil-works/pi-ai";
2
+ import type { AgentSessionRuntime } from "../core/agent-session-runtime.ts";
3
+ export interface PrintModeOptions {
4
+ mode: "text" | "json";
5
+ messages?: string[];
6
+ initialMessage?: string;
7
+ initialImages?: ImageContent[];
8
+ }
9
+ export declare function runPrintMode(runtimeHost: AgentSessionRuntime, options: PrintModeOptions): Promise<number>;
@@ -1,4 +1,6 @@
1
- var I=Object.defineProperty;var n=(o,i)=>I(o,"name",{value:i,configurable:!0});import{flushRawStdout as x,waitForRawStdoutBackpressure as R,writeRawStdout as d}from"../core/output-guard.js";import{fill as M,t as f}from"../dal/i18n.js";import{killTrackedDetachedChildren as k}from"../utils/shell.js";import{toJsonEvent as j}from"./json-event.js";async function J(o,i){const{mode:a,messages:b=[],initialMessage:u,initialImages:h}=i;let p=0,t=o.session,c,l,g=!1;const w=[],m=n(async()=>{g||(g=!0,c?.(),l?.(),await o.dispose())},"disposeRuntime");n(()=>{const s=["SIGTERM"];process.platform!=="win32"&&s.push("SIGHUP");for(const e of s){const r=n(()=>{k(),m().finally(()=>{process.exit(e==="SIGHUP"?129:143)})},"handler");process.on(e,r),w.push(()=>process.off(e,r))}},"registerSignalHandlers")(),o.setRebindSession(async()=>{await S()});const S=n(async()=>{t=o.session,await t.bindExtensions({mode:a==="json"?"json":"print",commandContextActions:{waitForIdle:n(()=>t.waitForIdle(),"waitForIdle"),newSession:n(async s=>o.newSession(s),"newSession"),fork:n(async(s,e)=>({cancelled:(await o.fork(s,e)).cancelled}),"fork"),navigateTree:n(async(s,e)=>({cancelled:(await t.navigateTree(s,{summarize:e?.summarize,customInstructions:e?.customInstructions,replaceInstructions:e?.replaceInstructions,label:e?.label})).cancelled}),"navigateTree"),switchSession:n(async(s,e)=>o.switchSession(s,e),"switchSession"),reload:n(async()=>{await t.reload()},"reload")},onError:n(s=>{console.error(M(f("\u6269\u5C55\u51FA\u9519\uFF08{path}\uFF09\uFF1A{error}"),{path:s.extensionPath,error:String(s.error)}))},"onError")}),c?.(),l?.(),c=t.subscribe(s=>{a==="json"&&d(`${JSON.stringify(j(s))}
2
- `)}),l=a==="json"?t.agent.subscribe(async()=>{await R()}):void 0},"rebindSession");try{if(a==="json"){const s=t.sessionManager.getHeader();s&&d(`${JSON.stringify(s)}
3
- `)}await S(),u&&await t.prompt(u,{images:h});for(const s of b)await t.prompt(s);if(a==="text"){const s=t.state,e=s.messages[s.messages.length-1];if(e?.role==="assistant"){const r=e;if(r.stopReason==="error"||r.stopReason==="aborted")console.error(r.errorMessage||(r.stopReason==="aborted"?f("\u8BF7\u6C42\u5DF2\u4E2D\u6B62"):f("\u8BF7\u6C42\u51FA\u9519"))),p=1;else for(const y of r.content)y.type==="text"&&d(`${y.text}
4
- `)}}return p}catch(s){return console.error(s instanceof Error?s.message:String(s)),1}finally{for(const s of w)s();await m(),await x()}}n(J,"runPrintMode");export{J as runPrintMode};
1
+ var x=Object.defineProperty;var n=(r,l)=>x(r,"name",{value:l,configurable:!0});import{flushRawStdout as I,waitForRawStdoutBackpressure as R,writeRawStdout as c}from"../core/output-guard.js";import{fill as M,t as u}from"../dal/i18n.js";import{killTrackedDetachedChildren as j}from"../utils/shell.js";import{toJsonEvent as k}from"./json-event.js";async function G(r,l){const{mode:i,messages:b=[],initialMessage:p,initialImages:h}=l;let g=0,o=r.session,f,d,m=!1;const w=[],y=n(async()=>{m||(m=!0,f?.(),d?.(),await r.dispose())},"disposeRuntime");n(()=>{const e=["SIGTERM"];process.platform!=="win32"&&e.push("SIGHUP");for(const s of e){const t=n(()=>{j(),y().finally(()=>{process.exit(s==="SIGHUP"?129:143)})},"handler");process.on(s,t),w.push(()=>process.off(s,t))}},"registerSignalHandlers")(),r.setRebindSession(async()=>{await S()});const S=n(async()=>{o=r.session,await o.bindExtensions({mode:i==="json"?"json":"print",commandContextActions:{waitForIdle:n(()=>o.waitForIdle(),"waitForIdle"),newSession:n(async e=>r.newSession(e),"newSession"),fork:n(async(e,s)=>({cancelled:(await r.fork(e,s)).cancelled}),"fork"),navigateTree:n(async(e,s)=>({cancelled:(await o.navigateTree(e,{summarize:s?.summarize,customInstructions:s?.customInstructions,replaceInstructions:s?.replaceInstructions,label:s?.label})).cancelled}),"navigateTree"),switchSession:n(async(e,s)=>r.switchSession(e,s),"switchSession"),reload:n(async()=>{await o.reload()},"reload")},onError:n(e=>{console.error(M(u("\u6269\u5C55\u51FA\u9519\uFF08{path}\uFF09\uFF1A{error}"),{path:e.extensionPath,error:String(e.error)}))},"onError")}),f?.(),d?.(),f=o.subscribe(e=>{i==="json"&&c(`${JSON.stringify(k(e))}
2
+ `)}),d=i==="json"?o.agent.subscribe(async()=>{await R()}):void 0},"rebindSession");try{if(i==="json"){const e=o.sessionManager.getHeader();e&&c(`${JSON.stringify(e)}
3
+ `)}await S(),p&&await o.prompt(p,{images:h});for(const e of b)await o.prompt(e);if(i==="text"){const e=o.state,s=e.messages[e.messages.length-1];if(s?.role==="custom"&&s.display){const t=typeof s.content=="string"?s.content:s.content.filter(a=>a.type==="text").map(a=>a.text).join(`
4
+ `);t&&c(`${t}
5
+ `)}else if(s?.role==="assistant"){const t=s;if(t.stopReason==="error"||t.stopReason==="aborted")console.error(t.errorMessage||(t.stopReason==="aborted"?u("\u8BF7\u6C42\u5DF2\u4E2D\u6B62"):u("\u8BF7\u6C42\u51FA\u9519"))),g=1;else for(const a of t.content)a.type==="text"&&c(`${a.text}
6
+ `)}}return g}catch(e){return console.error(e instanceof Error?e.message:String(e)),1}finally{for(const e of w)e();await y(),await I()}}n(G,"runPrintMode");export{G as runPrintMode};
@@ -0,0 +1,142 @@
1
+ import type { AgentMessage, ThinkingLevel } from "@earendil-works/pi-agent-core";
2
+ import type { ImageContent } from "@earendil-works/pi-ai";
3
+ import type { SessionStats } from "../../core/agent-session.ts";
4
+ import type { BashResult } from "../../core/bash-executor.ts";
5
+ import type { CompactionResult } from "../../core/compaction/index.ts";
6
+ import type { HostCapability } from "../../core/host-capabilities.ts";
7
+ import type { SessionEntry, SessionTreeNode } from "../../core/session-manager.ts";
8
+ import type { JsonAgentSessionEvent } from "../json-event.ts";
9
+ import type { RpcExtensionUIRequest, RpcExtensionUIResponse, RpcHostRequest, RpcSessionState, RpcSlashCommand } from "./rpc-types.ts";
10
+ export interface RpcClientOptions {
11
+ cliPath?: string;
12
+ cwd?: string;
13
+ env?: Record<string, string>;
14
+ inheritEnv?: boolean;
15
+ provider?: string;
16
+ model?: string;
17
+ args?: string[];
18
+ }
19
+ export interface ModelInfo {
20
+ provider: string;
21
+ id: string;
22
+ contextWindow: number;
23
+ reasoning: boolean;
24
+ }
25
+ export type RpcEventListener = (event: JsonAgentSessionEvent) => void;
26
+ export interface RpcProcessExit {
27
+ code: number | null;
28
+ signal: NodeJS.Signals | null;
29
+ stderrTail: string;
30
+ expected: boolean;
31
+ turnInFlight: boolean;
32
+ error?: string;
33
+ }
34
+ export type RpcExitListener = (exit: RpcProcessExit) => void;
35
+ export declare function rpcStderrTail(stderr: string): string;
36
+ export type RpcExtensionUIHandler = (request: RpcExtensionUIRequest) => Promise<RpcExtensionUIResponse | undefined> | RpcExtensionUIResponse | undefined;
37
+ export type RpcHostRequestHandler = (request: RpcHostRequest) => Promise<unknown> | unknown;
38
+ export declare class RpcClient {
39
+ private process;
40
+ private stopReadingStdout;
41
+ private eventListeners;
42
+ private pendingRequests;
43
+ private requestId;
44
+ private extensionUIHandler;
45
+ private hostRequestHandler;
46
+ private stderr;
47
+ private exitError;
48
+ private options;
49
+ private exitListeners;
50
+ private exitInfo;
51
+ private stopping;
52
+ private turnInFlight;
53
+ constructor(options?: RpcClientOptions);
54
+ start(): Promise<void>;
55
+ stop(): Promise<void>;
56
+ onExit(listener: RpcExitListener): () => void;
57
+ getExit(): RpcProcessExit | undefined;
58
+ onEvent(listener: RpcEventListener): () => void;
59
+ setExtensionUIHandler(handler: RpcExtensionUIHandler | null): void;
60
+ getStderr(): string;
61
+ prompt(message: string, images?: ImageContent[]): Promise<void>;
62
+ steer(message: string, images?: ImageContent[]): Promise<void>;
63
+ followUp(message: string, images?: ImageContent[]): Promise<void>;
64
+ abort(): Promise<void>;
65
+ clearQueue(): Promise<{
66
+ steering: string[];
67
+ followUp: string[];
68
+ }>;
69
+ newSession(parentSession?: string): Promise<{
70
+ cancelled: boolean;
71
+ }>;
72
+ getState(): Promise<RpcSessionState>;
73
+ setModel(provider: string, modelId: string): Promise<{
74
+ provider: string;
75
+ id: string;
76
+ }>;
77
+ cycleModel(): Promise<{
78
+ model: {
79
+ provider: string;
80
+ id: string;
81
+ };
82
+ thinkingLevel: ThinkingLevel;
83
+ isScoped: boolean;
84
+ } | null>;
85
+ getAvailableModels(): Promise<ModelInfo[]>;
86
+ setThinkingLevel(level: ThinkingLevel): Promise<void>;
87
+ cycleThinkingLevel(): Promise<{
88
+ level: ThinkingLevel;
89
+ } | null>;
90
+ getAvailableThinkingLevels(): Promise<ThinkingLevel[]>;
91
+ setSteeringMode(mode: "all" | "one-at-a-time"): Promise<void>;
92
+ setFollowUpMode(mode: "all" | "one-at-a-time"): Promise<void>;
93
+ compact(customInstructions?: string): Promise<CompactionResult>;
94
+ setAutoCompaction(enabled: boolean): Promise<void>;
95
+ setAutoRetry(enabled: boolean): Promise<void>;
96
+ abortRetry(): Promise<void>;
97
+ bash(command: string): Promise<BashResult>;
98
+ abortBash(): Promise<void>;
99
+ getSessionStats(): Promise<SessionStats>;
100
+ exportHtml(outputPath?: string): Promise<{
101
+ path: string;
102
+ }>;
103
+ switchSession(sessionPath: string): Promise<{
104
+ cancelled: boolean;
105
+ }>;
106
+ fork(entryId: string): Promise<{
107
+ text: string;
108
+ cancelled: boolean;
109
+ }>;
110
+ clone(): Promise<{
111
+ cancelled: boolean;
112
+ }>;
113
+ getForkMessages(): Promise<Array<{
114
+ entryId: string;
115
+ text: string;
116
+ }>>;
117
+ getEntries(since?: string): Promise<{
118
+ entries: SessionEntry[];
119
+ leafId: string | null;
120
+ }>;
121
+ getTree(): Promise<{
122
+ tree: SessionTreeNode[];
123
+ leafId: string | null;
124
+ }>;
125
+ getLastAssistantText(): Promise<string | null>;
126
+ setSessionName(name: string): Promise<void>;
127
+ getMessages(): Promise<AgentMessage[]>;
128
+ getCommands(): Promise<RpcSlashCommand[]>;
129
+ setHostCapabilities(capabilities: HostCapability[], handler: RpcHostRequestHandler | null): Promise<HostCapability[]>;
130
+ waitForIdle(timeout?: number): Promise<void>;
131
+ collectEvents(timeout?: number): Promise<JsonAgentSessionEvent[]>;
132
+ promptAndWait(message: string, images?: ImageContent[], timeout?: number): Promise<JsonAgentSessionEvent[]>;
133
+ private handleLine;
134
+ private answerExtensionUIRequest;
135
+ private answerHostRequest;
136
+ private reportExit;
137
+ private createExitWhileWaitingError;
138
+ private createProcessExitError;
139
+ private rejectPendingRequests;
140
+ private send;
141
+ private getData;
142
+ }
@@ -1 +1,4 @@
1
- var g=Object.defineProperty;var c=(h,e)=>g(h,"name",{value:e,configurable:!0});import{spawn as y}from"node:child_process";import{attachJsonlLineReader as w,serializeJsonLine as p}from"./jsonl.js";const m=new Set(["select","confirm","input","editor","requestInput","requestChoice"]);class f{static{c(this,"RpcClient")}process=null;stopReadingStdout=null;eventListeners=[];pendingRequests=new Map;requestId=0;extensionUIHandler=null;stderr="";exitError=null;options;constructor(e={}){this.options=e}async start(){if(this.process)throw new Error("Client already started");this.exitError=null;const e=this.options.cliPath??"dist/cli.js",t=["--mode","rpc"];this.options.provider&&t.push("--provider",this.options.provider),this.options.model&&t.push("--model",this.options.model),this.options.args&&t.push(...this.options.args);const r=y(process.execPath,[e,...t],{cwd:this.options.cwd,env:{...process.env,...this.options.env},stdio:["pipe","pipe","pipe"]});if(this.process=r,r.stderr?.on("data",s=>{this.stderr+=s.toString(),process.stderr.write(s)}),r.once("exit",(s,i)=>{if(this.process!==r)return;const n=this.createProcessExitError(s,i);this.exitError=n,this.rejectPendingRequests(n)}),r.once("error",s=>{if(this.process!==r)return;const i=new Error(`Agent process error: ${s.message}. Stderr: ${this.stderr}`);this.exitError=i,this.rejectPendingRequests(i)}),r.stdin?.on("error",s=>{if(this.process!==r)return;const i=this.exitError??new Error(`Agent process stdin error: ${s.message}. Stderr: ${this.stderr}`);this.exitError=i,this.rejectPendingRequests(i)}),this.stopReadingStdout=w(r.stdout,s=>{this.handleLine(s)}),await new Promise(s=>setTimeout(s,100)),this.process.exitCode!==null){const s=this.exitError??this.createProcessExitError(this.process.exitCode,this.process.signalCode);throw this.exitError=s,s}}async stop(){this.process&&(this.stopReadingStdout?.(),this.stopReadingStdout=null,this.process.kill("SIGTERM"),await new Promise(e=>{const t=setTimeout(()=>{this.process?.kill("SIGKILL"),e()},1e3);this.process?.on("exit",()=>{clearTimeout(t),e()})}),this.process=null,this.pendingRequests.clear())}onEvent(e){return this.eventListeners.push(e),()=>{const t=this.eventListeners.indexOf(e);t!==-1&&this.eventListeners.splice(t,1)}}setExtensionUIHandler(e){this.extensionUIHandler=e}getStderr(){return this.stderr}async prompt(e,t){await this.send({type:"prompt",message:e,images:t})}async steer(e,t){await this.send({type:"steer",message:e,images:t})}async followUp(e,t){await this.send({type:"follow_up",message:e,images:t})}async abort(){await this.send({type:"abort"})}async clearQueue(){const e=await this.send({type:"clear_queue"});return this.getData(e)}async newSession(e){const t=await this.send({type:"new_session",parentSession:e});return this.getData(t)}async getState(){const e=await this.send({type:"get_state"});return this.getData(e)}async setModel(e,t){const r=await this.send({type:"set_model",provider:e,modelId:t});return this.getData(r)}async cycleModel(){const e=await this.send({type:"cycle_model"});return this.getData(e)}async getAvailableModels(){const e=await this.send({type:"get_available_models"});return this.getData(e).models}async setThinkingLevel(e){await this.send({type:"set_thinking_level",level:e})}async cycleThinkingLevel(){const e=await this.send({type:"cycle_thinking_level"});return this.getData(e)}async getAvailableThinkingLevels(){const e=await this.send({type:"get_available_thinking_levels"});return this.getData(e).levels}async setSteeringMode(e){await this.send({type:"set_steering_mode",mode:e})}async setFollowUpMode(e){await this.send({type:"set_follow_up_mode",mode:e})}async compact(e){const t=await this.send({type:"compact",customInstructions:e});return this.getData(t)}async setAutoCompaction(e){await this.send({type:"set_auto_compaction",enabled:e})}async setAutoRetry(e){await this.send({type:"set_auto_retry",enabled:e})}async abortRetry(){await this.send({type:"abort_retry"})}async bash(e){const t=await this.send({type:"bash",command:e});return this.getData(t)}async abortBash(){await this.send({type:"abort_bash"})}async getSessionStats(){const e=await this.send({type:"get_session_stats"});return this.getData(e)}async exportHtml(e){const t=await this.send({type:"export_html",outputPath:e});return this.getData(t)}async switchSession(e){const t=await this.send({type:"switch_session",sessionPath:e});return this.getData(t)}async fork(e){const t=await this.send({type:"fork",entryId:e});return this.getData(t)}async clone(){const e=await this.send({type:"clone"});return this.getData(e)}async getForkMessages(){const e=await this.send({type:"get_fork_messages"});return this.getData(e).messages}async getEntries(e){const t=await this.send({type:"get_entries",since:e});return this.getData(t)}async getTree(){const e=await this.send({type:"get_tree"});return this.getData(e)}async getLastAssistantText(){const e=await this.send({type:"get_last_assistant_text"});return this.getData(e).text}async setSessionName(e){await this.send({type:"set_session_name",name:e})}async getMessages(){const e=await this.send({type:"get_messages"});return this.getData(e).messages}async getCommands(){const e=await this.send({type:"get_commands"});return this.getData(e).commands}waitForIdle(e=6e4){return new Promise((t,r)=>{const s=setTimeout(()=>{i(),r(new Error(`Timeout waiting for agent to become idle. Stderr: ${this.stderr}`))},e),i=this.onEvent(n=>{n.type==="agent_settled"&&(clearTimeout(s),i(),t())})})}collectEvents(e=6e4){return new Promise((t,r)=>{const s=[],i=setTimeout(()=>{n(),r(new Error(`Timeout collecting events. Stderr: ${this.stderr}`))},e),n=this.onEvent(a=>{s.push(a),a.type==="agent_settled"&&(clearTimeout(i),n(),t(s))})})}async promptAndWait(e,t,r=6e4){const s=this.collectEvents(r);return await this.prompt(e,t),s}handleLine(e){try{const t=JSON.parse(e);if(t.type==="response"&&t.id&&this.pendingRequests.has(t.id)){const r=this.pendingRequests.get(t.id);this.pendingRequests.delete(t.id),r.resolve(t);return}t.type==="extension_ui_request"&&m.has(t.method)&&this.answerExtensionUIRequest(t);for(const r of this.eventListeners)r(t)}catch{}}async answerExtensionUIRequest(e){const t={type:"extension_ui_response",id:e.id,cancelled:!0};let r=t;if(this.extensionUIHandler)try{r=await this.extensionUIHandler(e)??t}catch{r=t}const s=this.process?.stdin;if(!(!s||s.destroyed||!s.writable))try{s.write(p({...r,id:e.id}))}catch{}}createProcessExitError(e,t){return new Error(`Agent process exited (code=${e} signal=${t}). Stderr: ${this.stderr}`)}rejectPendingRequests(e){for(const t of this.pendingRequests.values())t.reject(e);this.pendingRequests.clear()}async send(e){const t=this.process,r=t?.stdin;if(!t||!r)throw new Error("Client not started");if(this.exitError)throw this.exitError;if(t.exitCode!==null){const n=this.createProcessExitError(t.exitCode,t.signalCode);throw this.exitError=n,n}if(r.destroyed||!r.writable){const n=new Error(`Agent process stdin is not writable. Stderr: ${this.stderr}`);throw this.exitError=n,n}const s=`req_${++this.requestId}`,i={...e,id:s};return new Promise((n,a)=>{const d=setTimeout(()=>{this.pendingRequests.delete(s),a(new Error(`Timeout waiting for response to ${e.type}. Stderr: ${this.stderr}`))},3e4);this.pendingRequests.set(s,{resolve:c(o=>{clearTimeout(d),n(o)},"resolve"),reject:c(o=>{clearTimeout(d),a(o)},"reject")});try{r.write(p(i))}catch(o){const l=o instanceof Error?o:new Error(String(o)),u=this.pendingRequests.get(s);this.pendingRequests.delete(s),u?.reject(l)}})}getData(e){if(!e.success){const r=e;throw new Error(r.error)}return e.data}}export{f as RpcClient};
1
+ var y=Object.defineProperty;var h=(d,t)=>y(d,"name",{value:t,configurable:!0});import{spawn as w}from"node:child_process";import{attachJsonlLineReader as f,serializeJsonLine as p}from"./jsonl.js";const m=20,l=2e3;function E(d){const e=d.split(/\r?\n/u).filter(s=>s.trim().length>0).slice(-m).join(`
2
+ `);return e.length>l?e.slice(-l):e}h(E,"rpcStderrTail");const _=new Set(["select","confirm","input","editor","requestInput","requestChoice"]);class I{static{h(this,"RpcClient")}process=null;stopReadingStdout=null;eventListeners=[];pendingRequests=new Map;requestId=0;extensionUIHandler=null;hostRequestHandler=null;stderr="";exitError=null;options;exitListeners=new Set;exitInfo;stopping=!1;turnInFlight=!1;constructor(t={}){this.options=t}async start(){if(this.process)throw new Error("Client already started");this.exitError=null,this.exitInfo=void 0,this.stopping=!1,this.turnInFlight=!1;const t=this.options.cliPath??"dist/cli.js",e=["--mode","rpc"];this.options.provider&&e.push("--provider",this.options.provider),this.options.model&&e.push("--model",this.options.model),this.options.args&&e.push(...this.options.args);const s=w(process.execPath,[t,...e],{cwd:this.options.cwd,env:{...this.options.inheritEnv===!1?{}:process.env,...this.options.env},stdio:["pipe","pipe","pipe"]});if(this.process=s,s.stderr?.on("data",r=>{this.stderr+=r.toString(),process.stderr.write(r)}),s.once("exit",(r,i)=>{if(this.process!==s)return;this.reportExit({code:r,signal:i});const n=this.createProcessExitError(r,i);this.exitError=n,this.rejectPendingRequests(n)}),s.once("error",r=>{if(this.process!==s)return;const i=new Error(`Agent process error: ${r.message}. Stderr: ${this.stderr}`);s.exitCode===null&&s.signalCode===null&&this.reportExit({code:null,signal:null,error:r.message}),this.exitError=i,this.rejectPendingRequests(i)}),s.stdin?.on("error",r=>{if(this.process!==s)return;const i=this.exitError??new Error(`Agent process stdin error: ${r.message}. Stderr: ${this.stderr}`);this.exitError=i,this.rejectPendingRequests(i)}),this.stopReadingStdout=f(s.stdout,r=>{this.handleLine(r)}),await new Promise(r=>setTimeout(r,100)),this.process.exitCode!==null){const r=this.exitError??this.createProcessExitError(this.process.exitCode,this.process.signalCode);throw this.exitError=r,r}}async stop(){this.process&&(this.stopReadingStdout?.(),this.stopReadingStdout=null,this.stopping=!0,this.process.kill("SIGTERM"),await new Promise(t=>{const e=setTimeout(()=>{this.process?.kill("SIGKILL"),t()},1e3);this.process?.on("exit",()=>{clearTimeout(e),t()})}),this.process=null,this.pendingRequests.clear())}onExit(t){const e=this.exitInfo;return e?(queueMicrotask(()=>t(e)),()=>{}):(this.exitListeners.add(t),()=>{this.exitListeners.delete(t)})}getExit(){return this.exitInfo}onEvent(t){return this.eventListeners.push(t),()=>{const e=this.eventListeners.indexOf(t);e!==-1&&this.eventListeners.splice(e,1)}}setExtensionUIHandler(t){this.extensionUIHandler=t}getStderr(){return this.stderr}async prompt(t,e){(await this.send({type:"prompt",message:t,images:e})).success&&(this.turnInFlight=!0)}async steer(t,e){await this.send({type:"steer",message:t,images:e})}async followUp(t,e){await this.send({type:"follow_up",message:t,images:e})}async abort(){await this.send({type:"abort"})}async clearQueue(){const t=await this.send({type:"clear_queue"});return this.getData(t)}async newSession(t){const e=await this.send({type:"new_session",parentSession:t});return this.getData(e)}async getState(){const t=await this.send({type:"get_state"});return this.getData(t)}async setModel(t,e){const s=await this.send({type:"set_model",provider:t,modelId:e});return this.getData(s)}async cycleModel(){const t=await this.send({type:"cycle_model"});return this.getData(t)}async getAvailableModels(){const t=await this.send({type:"get_available_models"});return this.getData(t).models}async setThinkingLevel(t){await this.send({type:"set_thinking_level",level:t})}async cycleThinkingLevel(){const t=await this.send({type:"cycle_thinking_level"});return this.getData(t)}async getAvailableThinkingLevels(){const t=await this.send({type:"get_available_thinking_levels"});return this.getData(t).levels}async setSteeringMode(t){await this.send({type:"set_steering_mode",mode:t})}async setFollowUpMode(t){await this.send({type:"set_follow_up_mode",mode:t})}async compact(t){const e=await this.send({type:"compact",customInstructions:t});return this.getData(e)}async setAutoCompaction(t){await this.send({type:"set_auto_compaction",enabled:t})}async setAutoRetry(t){await this.send({type:"set_auto_retry",enabled:t})}async abortRetry(){await this.send({type:"abort_retry"})}async bash(t){const e=await this.send({type:"bash",command:t});return this.getData(e)}async abortBash(){await this.send({type:"abort_bash"})}async getSessionStats(){const t=await this.send({type:"get_session_stats"});return this.getData(t)}async exportHtml(t){const e=await this.send({type:"export_html",outputPath:t});return this.getData(e)}async switchSession(t){const e=await this.send({type:"switch_session",sessionPath:t});return this.getData(e)}async fork(t){const e=await this.send({type:"fork",entryId:t});return this.getData(e)}async clone(){const t=await this.send({type:"clone"});return this.getData(t)}async getForkMessages(){const t=await this.send({type:"get_fork_messages"});return this.getData(t).messages}async getEntries(t){const e=await this.send({type:"get_entries",since:t});return this.getData(e)}async getTree(){const t=await this.send({type:"get_tree"});return this.getData(t)}async getLastAssistantText(){const t=await this.send({type:"get_last_assistant_text"});return this.getData(t).text}async setSessionName(t){await this.send({type:"set_session_name",name:t})}async getMessages(){const t=await this.send({type:"get_messages"});return this.getData(t).messages}async getCommands(){const t=await this.send({type:"get_commands"});return this.getData(t).commands}async setHostCapabilities(t,e){this.hostRequestHandler=e;const s=await this.send({type:"set_host_capabilities",capabilities:t});return this.getData(s).capabilities}waitForIdle(t=6e4){return new Promise((e,s)=>{const r=setTimeout(()=>{i(),n(),s(new Error(`Timeout waiting for agent to become idle. Stderr: ${this.stderr}`))},t),i=this.onEvent(o=>{o.type==="agent_settled"&&(clearTimeout(r),i(),n(),e())}),n=this.onExit(o=>{clearTimeout(r),i(),s(this.createExitWhileWaitingError(o))})})}collectEvents(t=6e4){return new Promise((e,s)=>{const r=[],i=setTimeout(()=>{n(),o(),s(new Error(`Timeout collecting events. Stderr: ${this.stderr}`))},t),n=this.onEvent(a=>{r.push(a),a.type==="agent_settled"&&(clearTimeout(i),n(),o(),e(r))}),o=this.onExit(a=>{clearTimeout(i),n(),s(this.createExitWhileWaitingError(a))})})}async promptAndWait(t,e,s=6e4){const r=this.collectEvents(s);return await this.prompt(t,e),r}handleLine(t){try{const e=JSON.parse(t);if(e.type==="agent_start"?this.turnInFlight=!0:e.type==="agent_settled"&&(this.turnInFlight=!1),e.type==="response"&&e.id&&this.pendingRequests.has(e.id)){const s=this.pendingRequests.get(e.id);this.pendingRequests.delete(e.id),s.resolve(e);return}if(e.type==="extension_ui_request"&&_.has(e.method)&&this.answerExtensionUIRequest(e),e.type==="host_request"){this.answerHostRequest(e);return}for(const s of this.eventListeners)s(e)}catch{}}async answerExtensionUIRequest(t){const e={type:"extension_ui_response",id:t.id,cancelled:!0};let s=e;if(this.extensionUIHandler)try{s=await this.extensionUIHandler(t)??e}catch{s=e}const r=this.process?.stdin;if(!(!r||r.destroyed||!r.writable))try{r.write(p({...s,id:t.id}))}catch{}}async answerHostRequest(t){let e;if(!this.hostRequestHandler)e={type:"host_response",id:t.id,error:"host has no handler for host requests"};else try{const r=await this.hostRequestHandler(t);e={type:"host_response",id:t.id,result:r??null}}catch(r){e={type:"host_response",id:t.id,error:r instanceof Error?r.message:String(r)}}const s=this.process?.stdin;if(!(!s||s.destroyed||!s.writable))try{s.write(p(e))}catch{}}reportExit(t){if(this.exitInfo)return;const e={code:t.code,signal:t.signal,stderrTail:E(this.stderr),expected:this.stopping,turnInFlight:this.turnInFlight,...t.error?{error:t.error}:{}};this.exitInfo=e,this.turnInFlight=!1;const s=[...this.exitListeners];this.exitListeners.clear();for(const r of s)try{r(e)}catch{}}createExitWhileWaitingError(t){const e=t.signal?`signal ${t.signal}`:`code ${t.code??"unknown"}`,s=t.stderrTail?`
3
+ Last stderr output:
4
+ ${t.stderrTail}`:"";return new Error(`Agent process exited (${e}) before the turn finished.${s}`)}createProcessExitError(t,e){return new Error(`Agent process exited (code=${t} signal=${e}). Stderr: ${this.stderr}`)}rejectPendingRequests(t){for(const e of this.pendingRequests.values())e.reject(t);this.pendingRequests.clear()}async send(t){const e=this.process,s=e?.stdin;if(!e||!s)throw new Error("Client not started");if(this.exitError)throw this.exitError;if(e.exitCode!==null){const n=this.createProcessExitError(e.exitCode,e.signalCode);throw this.exitError=n,n}if(s.destroyed||!s.writable){const n=new Error(`Agent process stdin is not writable. Stderr: ${this.stderr}`);throw this.exitError=n,n}const r=`req_${++this.requestId}`,i={...t,id:r};return new Promise((n,o)=>{const a=setTimeout(()=>{this.pendingRequests.delete(r),o(new Error(`Timeout waiting for response to ${t.type}. Stderr: ${this.stderr}`))},3e4);this.pendingRequests.set(r,{resolve:h(c=>{clearTimeout(a),n(c)},"resolve"),reject:h(c=>{clearTimeout(a),o(c)},"reject")});try{s.write(p(i))}catch(c){const u=c instanceof Error?c:new Error(String(c)),g=this.pendingRequests.get(r);this.pendingRequests.delete(r),g?.reject(u)}})}getData(t){if(!t.success){const s=t;throw new Error(s.error)}return t.data}}export{I as RpcClient,E as rpcStderrTail};
@@ -0,0 +1,3 @@
1
+ import type { AgentSessionRuntime } from "../../core/agent-session-runtime.ts";
2
+ export type { RpcCommand, RpcExtensionUIRequest, RpcExtensionUIResponse, RpcResponse, RpcSessionState, } from "./rpc-types.ts";
3
+ export declare function runRpcMode(runtimeHost: AgentSessionRuntime): Promise<never>;