@oh-my-pi/pi-coding-agent 17.2.3 → 17.2.5

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 (375) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/dist/{CHANGELOG-c5hpqt9r.md → CHANGELOG-q2w43aw3.md} +92 -0
  3. package/dist/cli.js +3979 -3548
  4. package/dist/{template-8vdv6xb4.js → template-c2hyaytt.js} +8 -26
  5. package/dist/types/advisor/advise-tool.d.ts +6 -0
  6. package/dist/types/advisor/runtime.d.ts +4 -4
  7. package/dist/types/capability/mcp.d.ts +9 -0
  8. package/dist/types/cli/args.d.ts +4 -1
  9. package/dist/types/cli/browser-relay-cli.d.ts +15 -0
  10. package/dist/types/cli/command-help.d.ts +99 -0
  11. package/dist/types/cli/help-extra.d.ts +2 -0
  12. package/dist/types/cli/models-cli.d.ts +1 -1
  13. package/dist/types/cli/thinking-levels.d.ts +5 -0
  14. package/dist/types/cli/update-cli.d.ts +13 -0
  15. package/dist/types/commands/browser-relay.d.ts +38 -0
  16. package/dist/types/commands/commit.d.ts +3 -0
  17. package/dist/types/commands/complete.d.ts +1 -1
  18. package/dist/types/commands/completions.d.ts +6 -0
  19. package/dist/types/commands/grep.d.ts +3 -0
  20. package/dist/types/commands/join.d.ts +4 -0
  21. package/dist/types/commands/launch-help.d.ts +171 -0
  22. package/dist/types/commands/launch.d.ts +5 -1
  23. package/dist/types/commands/models.d.ts +3 -0
  24. package/dist/types/commands/say.d.ts +10 -0
  25. package/dist/types/commands/worktree.d.ts +3 -0
  26. package/dist/types/config/keybindings.d.ts +6 -1
  27. package/dist/types/config/model-discovery.d.ts +2 -2
  28. package/dist/types/config/models-config-schema-bundle.d.ts +3 -0
  29. package/dist/types/config/models-config-schema.d.ts +2 -0
  30. package/dist/types/config/models-config.d.ts +1 -0
  31. package/dist/types/config/service-tier.d.ts +2 -0
  32. package/dist/types/config/settings-schema.d.ts +70 -22
  33. package/dist/types/cursor-bridge-tools.d.ts +1 -1
  34. package/dist/types/cursor.d.ts +7 -4
  35. package/dist/types/discovery/helpers.d.ts +6 -0
  36. package/dist/types/discovery/omp-extension-roots.d.ts +21 -2
  37. package/dist/types/edit/index.d.ts +3 -3
  38. package/dist/types/edit/modes/replace.d.ts +22 -15
  39. package/dist/types/edit/renderer.d.ts +1 -1
  40. package/dist/types/eval/py/kernel.d.ts +3 -1
  41. package/dist/types/eval/py/spawn-options.d.ts +12 -16
  42. package/dist/types/extensibility/extensions/loader.d.ts +6 -2
  43. package/dist/types/extensibility/legacy-pi-ai-shim.d.ts +8 -1
  44. package/dist/types/extensibility/legacy-pi-coding-agent-shim.d.ts +1 -1
  45. package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +2 -0
  46. package/dist/types/extensibility/plugins/marketplace/registry.d.ts +2 -2
  47. package/dist/types/launch/broker.d.ts +1 -1
  48. package/dist/types/launch/client.d.ts +6 -3
  49. package/dist/types/launch/ensure.d.ts +8 -0
  50. package/dist/types/launch/paths.d.ts +3 -2
  51. package/dist/types/launch/protocol.d.ts +2 -2
  52. package/dist/types/lsp/client.d.ts +2 -0
  53. package/dist/types/lsp/mux/daemon.d.ts +15 -0
  54. package/dist/types/lsp/mux/protocol.d.ts +57 -0
  55. package/dist/types/lsp/mux/server.d.ts +18 -0
  56. package/dist/types/lsp/types.d.ts +22 -2
  57. package/dist/types/main.d.ts +2 -0
  58. package/dist/types/mcp/request-id.d.ts +19 -0
  59. package/dist/types/mcp/types.d.ts +14 -0
  60. package/dist/types/memory-backend/index.d.ts +1 -0
  61. package/dist/types/memory-backend/messages.d.ts +15 -0
  62. package/dist/types/mnemopi/embed-client.d.ts +1 -1
  63. package/dist/types/mnemopi/state.d.ts +0 -23
  64. package/dist/types/modes/components/assistant-message.d.ts +2 -0
  65. package/dist/types/modes/components/custom-editor.d.ts +2 -1
  66. package/dist/types/modes/components/model-browser.d.ts +7 -5
  67. package/dist/types/modes/components/model-picker.d.ts +9 -3
  68. package/dist/types/modes/components/read-tool-group.d.ts +11 -0
  69. package/dist/types/modes/components/stripped-tool-calls-placeholder.d.ts +12 -0
  70. package/dist/types/modes/components/tool-execution.d.ts +2 -0
  71. package/dist/types/modes/controllers/input-controller.d.ts +1 -0
  72. package/dist/types/modes/interactive-mode.d.ts +1 -0
  73. package/dist/types/modes/types.d.ts +2 -1
  74. package/dist/types/modes/workflow.d.ts +2 -1
  75. package/dist/types/registry/agent-lifecycle.d.ts +14 -5
  76. package/dist/types/registry/agent-registry.d.ts +4 -3
  77. package/dist/types/sdk.d.ts +4 -2
  78. package/dist/types/secrets/index.d.ts +7 -9
  79. package/dist/types/session/agent-session-types.d.ts +3 -1
  80. package/dist/types/session/agent-session.d.ts +6 -1
  81. package/dist/types/session/indexed-session-storage.d.ts +1 -0
  82. package/dist/types/session/model-controls.d.ts +0 -1
  83. package/dist/types/session/session-advisors.d.ts +8 -1
  84. package/dist/types/session/session-context.d.ts +2 -1
  85. package/dist/types/session/session-maintenance.d.ts +2 -0
  86. package/dist/types/session/session-manager.d.ts +16 -5
  87. package/dist/types/session/session-stats.d.ts +10 -0
  88. package/dist/types/session/session-storage.d.ts +15 -3
  89. package/dist/types/system-prompt.d.ts +6 -1
  90. package/dist/types/task/index.d.ts +2 -1
  91. package/dist/types/task/spawn-policy.d.ts +5 -0
  92. package/dist/types/thinking.d.ts +1 -7
  93. package/dist/types/tools/ast-grep.d.ts +1 -1
  94. package/dist/types/tools/browser/registry.d.ts +2 -1
  95. package/dist/types/tools/browser/relay/bridge.d.ts +35 -0
  96. package/dist/types/tools/browser/relay/daemon.d.ts +16 -0
  97. package/dist/types/tools/browser/relay/kind.d.ts +19 -0
  98. package/dist/types/tools/browser/relay/protocol.d.ts +97 -0
  99. package/dist/types/tools/browser/relay/server.d.ts +35 -0
  100. package/dist/types/tools/browser/render.d.ts +1 -0
  101. package/dist/types/tools/browser.d.ts +3 -0
  102. package/dist/types/tools/computer/exposure.d.ts +9 -7
  103. package/dist/types/tools/computer/protocol.d.ts +70 -17
  104. package/dist/types/tools/computer/supervisor.d.ts +23 -10
  105. package/dist/types/tools/computer/worker-entry.d.ts +1 -0
  106. package/dist/types/tools/computer/worker.d.ts +42 -7
  107. package/dist/types/tools/computer-renderer.d.ts +7 -5
  108. package/dist/types/tools/computer.d.ts +25 -44
  109. package/dist/types/tools/context.d.ts +3 -0
  110. package/dist/types/tools/default-renderer.d.ts +3 -0
  111. package/dist/types/tools/glob.d.ts +1 -1
  112. package/dist/types/tools/grep.d.ts +1 -1
  113. package/dist/types/tools/render-utils.d.ts +2 -0
  114. package/dist/types/tools/{browser/run-cancellation.d.ts → run-scope.d.ts} +8 -8
  115. package/dist/types/tools/tool-timeouts.d.ts +5 -0
  116. package/dist/types/tools/xdev.d.ts +8 -0
  117. package/dist/types/utils/clipboard.d.ts +2 -2
  118. package/dist/types/web/kagi.d.ts +1 -0
  119. package/dist/types/web/search/index.d.ts +1 -1
  120. package/dist/types/web/search/providers/anthropic.d.ts +1 -0
  121. package/dist/types/web/search/providers/base.d.ts +2 -0
  122. package/dist/types/web/search/providers/brave.d.ts +1 -0
  123. package/dist/types/web/search/providers/browser-page.d.ts +1 -0
  124. package/dist/types/web/search/providers/codex.d.ts +1 -0
  125. package/dist/types/web/search/providers/exa.d.ts +1 -0
  126. package/dist/types/web/search/providers/firecrawl.d.ts +1 -0
  127. package/dist/types/web/search/providers/gemini.d.ts +1 -0
  128. package/dist/types/web/search/providers/jina.d.ts +1 -0
  129. package/dist/types/web/search/providers/kagi.d.ts +1 -0
  130. package/dist/types/web/search/providers/kimi.d.ts +1 -0
  131. package/dist/types/web/search/providers/parallel.d.ts +1 -0
  132. package/dist/types/web/search/providers/perplexity.d.ts +1 -0
  133. package/dist/types/web/search/providers/searxng.d.ts +1 -0
  134. package/dist/types/web/search/providers/tavily.d.ts +1 -0
  135. package/dist/types/web/search/providers/tinyfish.d.ts +1 -0
  136. package/dist/types/web/search/providers/utils.d.ts +6 -9
  137. package/dist/types/web/search/providers/zai.d.ts +1 -0
  138. package/dist/types/web/search/types.d.ts +4 -0
  139. package/package.json +12 -12
  140. package/scripts/legacy-pi-virtual-module.ts +12 -2
  141. package/src/advisor/advise-tool.ts +18 -0
  142. package/src/advisor/runtime.ts +6 -6
  143. package/src/capability/mcp.ts +7 -0
  144. package/src/cli/args.ts +7 -87
  145. package/src/cli/browser-relay-cli.ts +119 -0
  146. package/src/cli/command-help.ts +103 -0
  147. package/src/cli/completion-gen.ts +5 -5
  148. package/src/cli/flag-tables.ts +9 -0
  149. package/src/cli/help-extra.ts +89 -0
  150. package/src/cli/models-cli.ts +13 -16
  151. package/src/cli/setup-cli.ts +13 -21
  152. package/src/cli/thinking-levels.ts +7 -0
  153. package/src/cli/update-cli.ts +26 -7
  154. package/src/cli-commands.ts +170 -33
  155. package/src/cli.ts +17 -5
  156. package/src/collab/host.ts +1 -1
  157. package/src/commands/acp.ts +3 -1
  158. package/src/commands/agents.ts +3 -2
  159. package/src/commands/auth-broker.ts +3 -2
  160. package/src/commands/auth-gateway.ts +3 -2
  161. package/src/commands/bench.ts +2 -3
  162. package/src/commands/browser-relay.ts +53 -0
  163. package/src/commands/cleanse.ts +2 -2
  164. package/src/commands/commit.ts +3 -2
  165. package/src/commands/complete.ts +2 -1
  166. package/src/commands/completions.ts +3 -2
  167. package/src/commands/config.ts +3 -2
  168. package/src/commands/dry-balance.ts +2 -2
  169. package/src/commands/gallery.ts +3 -2
  170. package/src/commands/gc.ts +3 -2
  171. package/src/commands/grep.ts +3 -2
  172. package/src/commands/grievances.ts +3 -2
  173. package/src/commands/install.ts +2 -2
  174. package/src/commands/join.ts +3 -2
  175. package/src/commands/launch-help.ts +116 -0
  176. package/src/commands/launch.ts +7 -191
  177. package/src/commands/models.ts +3 -2
  178. package/src/commands/plugin.ts +3 -2
  179. package/src/commands/read.ts +3 -2
  180. package/src/commands/say.ts +3 -2
  181. package/src/commands/setup.ts +3 -2
  182. package/src/commands/shell.ts +3 -2
  183. package/src/commands/ssh.ts +3 -2
  184. package/src/commands/stats.ts +3 -2
  185. package/src/commands/tiny-models.ts +2 -2
  186. package/src/commands/token.ts +2 -2
  187. package/src/commands/ttsr.ts +2 -2
  188. package/src/commands/update.ts +3 -2
  189. package/src/commands/usage.ts +3 -2
  190. package/src/commands/web-search.ts +3 -2
  191. package/src/commands/worktree.ts +3 -2
  192. package/src/config/keybindings.ts +19 -9
  193. package/src/config/mcp-schema.json +5 -0
  194. package/src/config/model-discovery.ts +30 -13
  195. package/src/config/model-registry.ts +16 -6
  196. package/src/config/models-config-schema-bundle.ts +9 -0
  197. package/src/config/resolve-config-value.ts +2 -1
  198. package/src/config/service-tier.ts +5 -0
  199. package/src/config/settings-schema.ts +73 -21
  200. package/src/cursor-bridge-tools.ts +1 -1
  201. package/src/cursor.ts +10 -14
  202. package/src/discovery/builtin.ts +10 -0
  203. package/src/discovery/helpers.ts +10 -0
  204. package/src/discovery/mcp-json.ts +11 -1
  205. package/src/discovery/omp-extension-roots.ts +79 -20
  206. package/src/discovery/omp-plugins.ts +10 -1
  207. package/src/edit/diff.ts +17 -8
  208. package/src/edit/index.ts +20 -7
  209. package/src/edit/modes/replace.ts +93 -40
  210. package/src/edit/renderer.ts +1 -1
  211. package/src/edit/streaming.ts +14 -17
  212. package/src/eval/py/kernel.ts +2 -1
  213. package/src/eval/py/spawn-options.ts +24 -29
  214. package/src/export/html/template.js +8 -26
  215. package/src/extensibility/extensions/loader.ts +66 -28
  216. package/src/extensibility/extensions/wrapper.ts +1 -0
  217. package/src/extensibility/legacy-pi-ai-shim.ts +22 -1
  218. package/src/extensibility/legacy-pi-coding-agent-shim.ts +7 -6
  219. package/src/extensibility/plugins/legacy-pi-compat.ts +124 -57
  220. package/src/extensibility/plugins/marketplace/registry.ts +4 -8
  221. package/src/extensibility/skills.ts +11 -0
  222. package/src/extensibility/utils.ts +10 -2
  223. package/src/launch/broker.ts +1 -1
  224. package/src/launch/client.ts +32 -13
  225. package/src/launch/ensure.ts +73 -0
  226. package/src/launch/paths.ts +3 -6
  227. package/src/launch/protocol.ts +2 -2
  228. package/src/lsp/client.ts +23 -2
  229. package/src/lsp/index.ts +8 -0
  230. package/src/lsp/mux/daemon.ts +348 -0
  231. package/src/lsp/mux/protocol.ts +96 -0
  232. package/src/lsp/mux/server.ts +797 -0
  233. package/src/lsp/types.ts +28 -2
  234. package/src/main.ts +31 -24
  235. package/src/mcp/config.ts +1 -0
  236. package/src/mcp/oauth-flow.ts +11 -1
  237. package/src/mcp/request-id.ts +24 -0
  238. package/src/mcp/transports/http.ts +4 -2
  239. package/src/mcp/transports/sse.ts +4 -2
  240. package/src/mcp/transports/stdio.ts +4 -2
  241. package/src/mcp/types.ts +15 -0
  242. package/src/memory-backend/index.ts +1 -0
  243. package/src/memory-backend/messages.ts +19 -0
  244. package/src/mnemopi/embed-client.ts +49 -2
  245. package/src/mnemopi/state.ts +57 -23
  246. package/src/modes/components/agent-hub.ts +1 -1
  247. package/src/modes/components/assistant-message.ts +11 -0
  248. package/src/modes/components/chat-transcript-builder.ts +4 -0
  249. package/src/modes/components/custom-editor.ts +10 -1
  250. package/src/modes/components/model-browser.ts +25 -17
  251. package/src/modes/components/model-picker.ts +10 -6
  252. package/src/modes/components/read-tool-group.ts +36 -0
  253. package/src/modes/components/status-line/component.ts +1 -1
  254. package/src/modes/components/stripped-tool-calls-placeholder.ts +35 -0
  255. package/src/modes/components/tool-execution.ts +85 -20
  256. package/src/modes/components/tree-selector.ts +46 -48
  257. package/src/modes/controllers/command-controller.ts +2 -2
  258. package/src/modes/controllers/event-controller.ts +199 -10
  259. package/src/modes/controllers/input-controller.ts +39 -1
  260. package/src/modes/controllers/mcp-command-controller.ts +11 -5
  261. package/src/modes/controllers/selector-controller.ts +47 -6
  262. package/src/modes/interactive-mode.ts +2 -0
  263. package/src/modes/types.ts +6 -1
  264. package/src/modes/utils/hotkeys-markdown.ts +1 -0
  265. package/src/modes/utils/interactive-context-helpers.ts +1 -0
  266. package/src/modes/utils/ui-helpers.ts +6 -10
  267. package/src/modes/workflow.ts +8 -2
  268. package/src/prompts/agents/init.md +1 -1
  269. package/src/prompts/system/plan-mode-active.md +2 -2
  270. package/src/prompts/system/system-prompt.md +26 -52
  271. package/src/prompts/system/workflow-notice.md +3 -3
  272. package/src/prompts/tools/ast-grep.md +1 -1
  273. package/src/prompts/tools/bash.md +1 -1
  274. package/src/prompts/tools/browser.md +1 -0
  275. package/src/prompts/tools/computer.md +21 -21
  276. package/src/prompts/tools/glob.md +1 -1
  277. package/src/prompts/tools/grep.md +1 -1
  278. package/src/prompts/tools/replace.md +5 -4
  279. package/src/prompts/tools/task.md +4 -4
  280. package/src/registry/agent-lifecycle.ts +36 -11
  281. package/src/registry/agent-registry.ts +12 -5
  282. package/src/sdk.ts +102 -35
  283. package/src/secrets/index.ts +16 -18
  284. package/src/session/agent-session-types.ts +3 -1
  285. package/src/session/agent-session.ts +23 -2
  286. package/src/session/agent-storage.ts +6 -4
  287. package/src/session/history-storage.ts +4 -2
  288. package/src/session/indexed-session-storage.ts +9 -0
  289. package/src/session/messages.ts +31 -7
  290. package/src/session/model-controls.ts +0 -1
  291. package/src/session/prewalk.ts +24 -2
  292. package/src/session/session-advisors.ts +21 -3
  293. package/src/session/session-context.ts +16 -12
  294. package/src/session/session-dump-format.ts +1 -1
  295. package/src/session/session-maintenance.ts +41 -4
  296. package/src/session/session-manager.ts +181 -94
  297. package/src/session/session-paths.ts +118 -55
  298. package/src/session/session-stats.ts +48 -3
  299. package/src/session/session-storage.ts +30 -22
  300. package/src/session/session-tools.ts +25 -23
  301. package/src/session/stream-guards.ts +1 -1
  302. package/src/slash-commands/builtin-registry.ts +29 -26
  303. package/src/system-prompt.ts +14 -4
  304. package/src/task/executor.ts +8 -1
  305. package/src/task/index.ts +23 -8
  306. package/src/task/spawn-policy.ts +14 -0
  307. package/src/thinking.ts +2 -8
  308. package/src/tiny/text.ts +12 -0
  309. package/src/tools/ast-grep.ts +10 -4
  310. package/src/tools/browser/cmux/cmux-tab.ts +5 -10
  311. package/src/tools/browser/cmux/rpc.ts +2 -8
  312. package/src/tools/browser/registry.ts +53 -2
  313. package/src/tools/browser/relay/bridge.ts +945 -0
  314. package/src/tools/browser/relay/daemon.ts +117 -0
  315. package/src/tools/browser/relay/extension-assets/background.js.txt +242 -0
  316. package/src/tools/browser/relay/extension-assets/manifest.json.txt +14 -0
  317. package/src/tools/browser/relay/extension-assets/options.html.txt +53 -0
  318. package/src/tools/browser/relay/extension-assets/options.js.txt +23 -0
  319. package/src/tools/browser/relay/kind.ts +41 -0
  320. package/src/tools/browser/relay/protocol.ts +54 -0
  321. package/src/tools/browser/relay/server.ts +141 -0
  322. package/src/tools/browser/render.ts +4 -1
  323. package/src/tools/browser/shared-daemon.ts +7 -58
  324. package/src/tools/browser/tab-supervisor.ts +5 -4
  325. package/src/tools/browser/tab-worker.ts +33 -12
  326. package/src/tools/browser.ts +26 -1
  327. package/src/tools/computer/exposure.ts +11 -35
  328. package/src/tools/computer/protocol.ts +51 -10
  329. package/src/tools/computer/supervisor.ts +227 -124
  330. package/src/tools/computer/worker-entry.ts +11 -6
  331. package/src/tools/computer/worker.ts +695 -81
  332. package/src/tools/computer-renderer.ts +104 -65
  333. package/src/tools/computer.ts +134 -428
  334. package/src/tools/context.ts +3 -0
  335. package/src/tools/default-renderer.ts +19 -4
  336. package/src/tools/glob.ts +9 -2
  337. package/src/tools/grep.ts +12 -6
  338. package/src/tools/index.ts +10 -6
  339. package/src/tools/inspect-image.ts +32 -6
  340. package/src/tools/render-utils.ts +2 -0
  341. package/src/tools/{browser/run-cancellation.ts → run-scope.ts} +11 -11
  342. package/src/tools/tool-timeouts.ts +1 -0
  343. package/src/tools/xdev.ts +29 -2
  344. package/src/utils/clipboard.ts +40 -14
  345. package/src/utils/command-args.ts +26 -28
  346. package/src/utils/tool-choice.ts +0 -13
  347. package/src/web/kagi.ts +2 -1
  348. package/src/web/search/index.ts +18 -2
  349. package/src/web/search/providers/anthropic.ts +7 -2
  350. package/src/web/search/providers/base.ts +2 -0
  351. package/src/web/search/providers/brave.ts +3 -1
  352. package/src/web/search/providers/browser-page.ts +6 -4
  353. package/src/web/search/providers/codex.ts +4 -1
  354. package/src/web/search/providers/duckduckgo.ts +2 -1
  355. package/src/web/search/providers/ecosia.ts +2 -1
  356. package/src/web/search/providers/exa.ts +4 -2
  357. package/src/web/search/providers/firecrawl.ts +3 -1
  358. package/src/web/search/providers/gemini.ts +8 -2
  359. package/src/web/search/providers/google.ts +2 -1
  360. package/src/web/search/providers/jina.ts +12 -2
  361. package/src/web/search/providers/kagi.ts +3 -0
  362. package/src/web/search/providers/kimi.ts +5 -1
  363. package/src/web/search/providers/mojeek.ts +2 -1
  364. package/src/web/search/providers/parallel.ts +5 -1
  365. package/src/web/search/providers/perplexity.ts +6 -3
  366. package/src/web/search/providers/public.ts +1 -1
  367. package/src/web/search/providers/searxng.ts +11 -5
  368. package/src/web/search/providers/startpage.ts +10 -4
  369. package/src/web/search/providers/synthetic.ts +11 -5
  370. package/src/web/search/providers/tavily.ts +3 -1
  371. package/src/web/search/providers/tinyfish.ts +3 -1
  372. package/src/web/search/providers/utils.ts +12 -10
  373. package/src/web/search/providers/xai.ts +2 -2
  374. package/src/web/search/providers/zai.ts +18 -3
  375. package/src/web/search/types.ts +6 -0
@@ -56,6 +56,7 @@ declare class IndexedSessionStorageWriter implements SessionStorageWriter {
56
56
  flags?: "a" | "w";
57
57
  onError?: (err: Error) => void;
58
58
  });
59
+ appendSync(line: string): void;
59
60
  append(line: string): Promise<void>;
60
61
  flush(): Promise<void>;
61
62
  isOpen(): boolean;
@@ -71,7 +71,6 @@ export declare class ModelControls {
71
71
  selector?: string;
72
72
  thinkingLevel?: ThinkingLevel;
73
73
  persist?: boolean;
74
- currentContextTokens?: number;
75
74
  }): Promise<{
76
75
  switched: boolean;
77
76
  }>;
@@ -65,7 +65,7 @@ export interface SessionAdvisorsOptions {
65
65
  /**
66
66
  * Build the `replace`-mode `edit` a Cursor `pi_edit` frame needs. The
67
67
  * advisor's own instance follows the configured `edit.mode` (`hashline` by
68
- * default), whose schema the frame's `old_text`/`new_text` pairs do not
68
+ * default), whose schema the frame's `old_string`/`new_string` args do not
69
69
  * match, so without this every native advisor edit fails validation.
70
70
  */
71
71
  createEditTool?(): AgentTool | undefined;
@@ -227,6 +227,13 @@ export declare class SessionAdvisors {
227
227
  * @returns the number of advisors active after the rebuild.
228
228
  */
229
229
  applyAdvisorConfigs(advisors: AdvisorConfig[], sharedInstructions: string | undefined): number;
230
+ /**
231
+ * Swap the project context prompt handed to advisor sessions after context
232
+ * files change (`/reload-plugins` edit/disable). Rebuilds live runtimes in
233
+ * place so the next advisor turn evaluates against the current instructions;
234
+ * a no-op when the rendered prompt is unchanged.
235
+ */
236
+ setContextPrompt(contextPrompt: string | undefined): void;
230
237
  /**
231
238
  * Whether the advisor setting is enabled for this session.
232
239
  */
@@ -1,5 +1,5 @@
1
1
  import type { AgentMessage } from "@oh-my-pi/pi-agent-core";
2
- import { type ServiceTierByFamily } from "@oh-my-pi/pi-ai";
2
+ import { type ProviderPayload, type ServiceTierByFamily } from "@oh-my-pi/pi-ai";
3
3
  import { type CompactionEntry, type SessionEntry } from "./session-entries.js";
4
4
  export interface SessionContext {
5
5
  messages: AgentMessage[];
@@ -55,4 +55,5 @@ export interface BuildSessionContextOptions {
55
55
  export interface StrippedToolCallsMarker {
56
56
  strippedToolCalls?: number;
57
57
  }
58
+ export declare function getOpenAiRemoteCompactionPayload(compaction: CompactionEntry | null | undefined): ProviderPayload | undefined;
58
59
  export declare function buildSessionContext(entries: SessionEntry[], leafId?: string | null, byId?: Map<string, SessionEntry>, options?: BuildSessionContextOptions): SessionContext;
@@ -38,6 +38,7 @@ export interface SessionMaintenanceHost {
38
38
  extensionRunner: ExtensionRunner | undefined;
39
39
  sideStreamFn: StreamFn;
40
40
  providerSessionState: Map<string, ProviderSessionState>;
41
+ preferWebsockets: boolean | undefined;
41
42
  model(): Model | undefined;
42
43
  thinkingLevel(): ThinkingLevel | undefined;
43
44
  isDisposed(): boolean;
@@ -86,6 +87,7 @@ export interface SessionMaintenanceHost {
86
87
  syncTodoPhasesFromBranch(): void;
87
88
  resetAdvisorRuntimes(): void;
88
89
  rebaseAfterCompaction(): void;
90
+ recordAnchoredHistoryRewrite(tokensRemoved: number): void;
89
91
  getContextBreakdown(options?: {
90
92
  contextWindow?: number;
91
93
  pendingMessages?: AgentMessage[];
@@ -39,11 +39,22 @@ export declare class SessionPersistenceIndeterminateError extends AggregateError
39
39
  * tree by `(id, parentId)`, and the mutable leaf pointer selects which path is
40
40
  * active for future appends and for LLM context construction.
41
41
  *
42
- * Durability is software-crash safe but not power-loss safe: appends are handed
43
- * to the OS synchronously in-body (so an entry survives an OOM/SIGKILL the
44
- * instant `appendMessage` returns) but never `fsync`'d. Full-file rewrites go
45
- * through the storage layer's atomic temp-write+rename so a crash mid-rewrite
46
- * cannot truncate the prior good file.
42
+ * Durability is software-crash safe but not power-loss safe: completed entries
43
+ * (user/assistant/toolResult messages, tool_execution_start markers, custom
44
+ * entries) are handed to the OS synchronously in-body on append and never
45
+ * `fsync`'d. In-flight streaming text is intentionally not durable until
46
+ * `message_end` persists the finished message.
47
+ *
48
+ * While an in-place atomic rewrite is publishing, a concurrent completed append
49
+ * supersedes that publish with a synchronous full-body rewrite so the entry is
50
+ * software-crash durable before the append returns; the abandoned atomic's
51
+ * `commitGuard` then refuses to clobber the fresher body.
52
+ *
53
+ * During {@link moveTo}, appends write a full body to the live relocation path
54
+ * (source until rename, destination once the rename has landed) so a crash mid-
55
+ * move still preserves completed entries without recreating a vacated source.
56
+ * A trailing atomic rewrite still rewrites the header cwd after the path is
57
+ * repointed.
47
58
  */
48
59
  export declare class SessionManager {
49
60
  #private;
@@ -38,6 +38,16 @@ export declare class SessionStatsTracker {
38
38
  get revision(): number;
39
39
  /** Non-message token count captured for the active provider request. */
40
40
  get pendingNonMessageTokens(): number | undefined;
41
+ /**
42
+ * Apply an estimated prompt-prefix reduction to the current provider anchor.
43
+ *
44
+ * History after the anchor is estimated live by {@link getContextBreakdown};
45
+ * callers must pass only savings from entries already included in the
46
+ * anchor's provider-reported prompt. Persisting the correction on the
47
+ * assistant snapshot keeps reloads accurate, and the next successful
48
+ * assistant response naturally replaces it with a fresh provider anchor.
49
+ */
50
+ recordAnchoredHistoryRewrite(tokensRemoved: number): void;
41
51
  /** Sets or clears the in-flight context snapshot. */
42
52
  setPendingSnapshot(snapshot: PendingContextSnapshot | undefined): void;
43
53
  /** Recomputes an in-flight snapshot after history is compacted or rewritten. */
@@ -6,13 +6,25 @@ export interface SessionStorageStat {
6
6
  }
7
7
  export interface SessionStorageWriter {
8
8
  /**
9
- * Append one newline-terminated line. File storage batches same-turn appends
10
- * until its microtask boundary; memory storage updates in-body; indexed
11
- * backends queue in call order.
9
+ * Append one newline-terminated line.
10
+ *
11
+ * File and memory storage apply the line synchronously before the returned
12
+ * promise settles, so a software crash after `append` returns (or after a
13
+ * fire-and-forget call begins) still sees the entry on disk / in body. No
14
+ * `fsync` — power loss may still drop the last page. Indexed backends update
15
+ * the local index immediately and queue the remote publish in call order.
12
16
  *
13
17
  * `line` MUST include the trailing newline.
14
18
  */
15
19
  append(line: string): Promise<void>;
20
+ /**
21
+ * Synchronous append when the backend can apply the line before return.
22
+ * File and memory implement this so {@link SessionManager} can latch the
23
+ * first write failure before the appending call returns (surfaced by a later
24
+ * flushSync/close/next append — the turn loop does not throw from append).
25
+ * Indexed backends update the local index immediately and queue remote I/O.
26
+ */
27
+ appendSync?(line: string): void;
16
28
  /** Resolve once all queued appends complete. No fsync. */
17
29
  flush(): Promise<void>;
18
30
  /** Drain synchronously flushable queued work when the backend supports it. No fsync. */
@@ -19,6 +19,8 @@ export declare function resolvePromptInput(input: string | undefined, descriptio
19
19
  export interface LoadContextFilesOptions {
20
20
  /** Working directory to start walking up from. Default: getProjectDir() */
21
21
  cwd?: string;
22
+ /** Disabled extension IDs to honor instead of the process-global settings. */
23
+ disabledExtensions?: string[];
22
24
  }
23
25
  /**
24
26
  * Load all project context files using the capability API.
@@ -75,7 +77,8 @@ export interface BuildSystemPromptOptions {
75
77
  /**
76
78
  * Whether provider-native tool calling is active (no owned/in-band syntax).
77
79
  * When true and `inlineToolDescriptors` is false, the inventory renders as a
78
- * compact tool-name list; otherwise it renders full `# Tool:` sections. Default: true
80
+ * compact tool-name list; otherwise it renders the full Harmony-style
81
+ * `namespace functions { … }` catalog. Default: true
79
82
  */
80
83
  nativeTools?: boolean;
81
84
  /** Skills settings for discovery. */
@@ -111,6 +114,8 @@ export interface BuildSystemPromptOptions {
111
114
  taskMaxConcurrency?: number;
112
115
  /** Whether IRC-backed parallel coordination can be included in delegation policy. */
113
116
  taskIrcEnabled?: boolean;
117
+ /** Whether the read-only `scout` subagent is spawnable (not disabled, allowed by spawn policy). Defaults to true. */
118
+ scoutAvailable?: boolean;
114
119
  /** Rules with alwaysApply=true — their full content is injected into the prompt. */
115
120
  alwaysApplyRules?: AlwaysApplyRule[];
116
121
  /** Whether secret obfuscation is active. When true, explains the redaction format in the prompt. */
@@ -25,7 +25,7 @@ export declare function formatResultOutputFallback(result: Pick<SingleResult, "o
25
25
  * (DepthCapacity: it currently has the `task` tool). `agentNames` are the
26
26
  * per-item resolved agent types. Returns undefined when no nudge applies.
27
27
  */
28
- export declare function buildSpecializationAdvisory(agentNames: string[], depthCapacity: boolean): string | undefined;
28
+ export declare function buildSpecializationAdvisory(agentNames: string[], depthCapacity: boolean, scoutAvailable?: boolean): string | undefined;
29
29
  /**
30
30
  * Suggestion — never a rejection — nudging the spawner to coordinate via the
31
31
  * hub when one call creates ≥2 live siblings and it still holds spawn
@@ -48,6 +48,7 @@ export declare function composeSpawnAdvisory(args: {
48
48
  depthCapacity: boolean;
49
49
  ircEnabled: boolean;
50
50
  willRunAsync: boolean;
51
+ scoutAvailable?: boolean;
51
52
  }): string | undefined;
52
53
  /**
53
54
  * Task tool - Delegate tasks to specialized agents.
@@ -15,3 +15,8 @@ export interface ResolvedSpawnPolicy {
15
15
  }
16
16
  /** Resolves spawn frontmatter into the default and prompt/error surfaces. */
17
17
  export declare function resolveSpawnPolicy(parentSpawns: string | boolean | null | undefined): ResolvedSpawnPolicy;
18
+ /**
19
+ * Whether the `scout` agent is spawnable in a session: not disabled via
20
+ * `task.disabledAgents`, and permitted by the session spawn policy.
21
+ */
22
+ export declare function isScoutSpawnable(disabledAgents: readonly string[] | undefined, spawns: string | boolean | null | undefined): boolean;
@@ -1,5 +1,6 @@
1
1
  import { type ResolvedThinkingLevel, ThinkingLevel } from "@oh-my-pi/pi-agent-core";
2
2
  import { Effort, type Model } from "@oh-my-pi/pi-ai";
3
+ export { CLI_THINKING_LEVELS } from "./cli/thinking-levels.js";
3
4
  /**
4
5
  * Metadata used to render thinking selector values in the coding-agent UI.
5
6
  */
@@ -81,13 +82,6 @@ export interface ConfiguredThinkingLevelMetadata {
81
82
  export declare function parseConfiguredThinkingLevel(value: string | null | undefined): ConfiguredThinkingLevel | undefined;
82
83
  /** Returns display metadata for a configured selector, including `auto`. */
83
84
  export declare function getConfiguredThinkingLevelMetadata(level: ConfiguredThinkingLevel): ConfiguredThinkingLevelMetadata;
84
- /**
85
- * Thinking selectors accepted by the `--thinking` CLI flag, in display order:
86
- * `off`, every concrete effort (`minimal`..`max`), then `auto`. Single source
87
- * for the flag's `options` list, shell completions, and the "invalid level"
88
- * warning so all three stay in sync.
89
- */
90
- export declare const CLI_THINKING_LEVELS: readonly string[];
91
85
  /**
92
86
  * Parses a `--thinking` CLI value. Accepts every {@link parseConfiguredThinkingLevel}
93
87
  * selector (`off`, `auto`, `minimal`..`max`) but rejects
@@ -41,7 +41,7 @@ export declare class AstGrepTool implements AgentTool<typeof astGrepSchema, AstG
41
41
  readonly approval: "read";
42
42
  readonly label = "AST Grep";
43
43
  readonly summary = "Search code with AST patterns (structural grep)";
44
- readonly description: string;
44
+ get description(): string;
45
45
  readonly parameters: import("arktype/internal/variants/object.ts").ObjectType<{
46
46
  pat: string;
47
47
  path?: string | undefined;
@@ -3,6 +3,7 @@ import type { Browser, CDPSession } from "puppeteer-core";
3
3
  import type { CmuxKind } from "./cmux/rpc.js";
4
4
  import { CmuxSocketClient } from "./cmux/socket-client.js";
5
5
  import { type UserAgentOverride } from "./launch.js";
6
+ import type { RelayKind } from "./relay/kind.js";
6
7
  export type PuppeteerBrowserKind = {
7
8
  kind: "headless";
8
9
  headless: boolean;
@@ -12,7 +13,7 @@ export type PuppeteerBrowserKind = {
12
13
  } | {
13
14
  kind: "connected";
14
15
  cdpUrl: string;
15
- };
16
+ } | RelayKind;
16
17
  export type BrowserKind = PuppeteerBrowserKind | CmuxKind;
17
18
  export type BrowserKindTag = BrowserKind["kind"];
18
19
  interface BrowserHandleCommon {
@@ -0,0 +1,35 @@
1
+ /** Transport-agnostic websocket surface the bridge writes to. */
2
+ export interface RelaySocket {
3
+ send(text: string): void;
4
+ close(): void;
5
+ }
6
+ /**
7
+ * Multiplexing CDP bridge between downstream puppeteer connections and the
8
+ * relay extension. One instance per relay server; all state lives here so an
9
+ * extension service-worker restart only has to re-handshake.
10
+ */
11
+ export declare class RelayBridge {
12
+ #private;
13
+ constructor(opts?: {
14
+ log?: (message: string, data?: Record<string, unknown>) => void;
15
+ /** Group tabs the agent actively drives under one per-window Chrome tab group. */
16
+ group?: {
17
+ title: string;
18
+ color: string;
19
+ } | null;
20
+ });
21
+ /** True once the extension has completed its hello handshake. */
22
+ get ready(): boolean;
23
+ /** Payload for `GET /json/version`. */
24
+ versionInfo(wsUrl: string): Record<string, string>;
25
+ /** Payload for `GET /json/list` (debugging aid; per-target endpoints are not served). */
26
+ listTargets(): Array<Record<string, string>>;
27
+ /** A new extension socket connected; replaces any previous one. */
28
+ extConnected(socket: RelaySocket): void;
29
+ extClosed(socket: RelaySocket): void;
30
+ extMessage(socket: RelaySocket, raw: string): void;
31
+ /** Register a downstream CDP websocket; returns the connection id. */
32
+ cdpConnected(socket: RelaySocket): number;
33
+ cdpClosed(connId: number): void;
34
+ cdpMessage(connId: number, raw: string): void;
35
+ }
@@ -0,0 +1,16 @@
1
+ /** Stable broker daemon name for the relay server. */
2
+ export declare const RELAY_DAEMON_NAME = "omp.browser.relay";
3
+ /** True when the relay HTTP server answers /json/version at all (200 = extension connected, 503 = waiting for it). */
4
+ export declare function probeRelayServer(cdpUrl: string): Promise<boolean>;
5
+ /** Auto-start is only safe for endpoints this machine can own. */
6
+ export declare function isLoopbackRelayUrl(cdpUrl: string): boolean;
7
+ /**
8
+ * Ensure a relay server answers at `cdpUrl`, starting the broker-owned daemon
9
+ * when nothing is serving. Returns true once the HTTP endpoint responds — the
10
+ * extension handshake (503 → 200) is the caller's wait. False when the relay
11
+ * could not be started (broker unavailable or start rounds exhausted).
12
+ */
13
+ export declare function ensureRelayDaemon(opts: {
14
+ cdpUrl: string;
15
+ signal?: AbortSignal;
16
+ }): Promise<boolean>;
@@ -0,0 +1,19 @@
1
+ /** Browser kind selecting the omp browser relay. */
2
+ export interface RelayKind {
3
+ kind: "relay";
4
+ cdpUrl: string;
5
+ }
6
+ /** Default endpoint of the `omp-browser-relay` CLI. */
7
+ export declare const DEFAULT_RELAY_URL = "http://127.0.0.1:9224";
8
+ export interface ResolveRelayKindOptions {
9
+ /** `browser.relay` setting; `PI_BROWSER_RELAY=0|1` overrides it. */
10
+ settingEnabled?: boolean;
11
+ /** `browser.relayUrl` setting; falls back to {@link DEFAULT_RELAY_URL}. */
12
+ url?: string;
13
+ }
14
+ /**
15
+ * Resolve the relay browser kind, or null when relay mode is disabled.
16
+ * Mirrors `resolveCmuxKind`: the setting opts in, the env var is the final
17
+ * override in both directions.
18
+ */
19
+ export declare function resolveRelayKind(options?: ResolveRelayKindOptions | null, env?: Record<string, string | undefined>): RelayKind | null;
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Wire protocol between the relay server and the Chrome extension.
3
+ *
4
+ * The extension dials out to `ws://127.0.0.1:<port>/ext` and exchanges JSON
5
+ * messages. The relay drives the extension with numbered RPCs; the extension
6
+ * pushes tab lifecycle and `chrome.debugger` events as they happen.
7
+ */
8
+ /** Minimal view of a Chrome tab shared between extension and relay. */
9
+ export interface TabSnapshot {
10
+ tabId: number;
11
+ url: string;
12
+ title: string;
13
+ active: boolean;
14
+ windowId: number;
15
+ /** Pinned tabs are never grouped (Chrome would silently unpin them). */
16
+ pinned: boolean;
17
+ /** Chrome tab group id; -1 when ungrouped. */
18
+ groupId: number;
19
+ }
20
+ /** RPCs the relay may ask the extension to perform. */
21
+ export type RelayRpcRequest = {
22
+ op: "attach";
23
+ tabId: number;
24
+ } | {
25
+ op: "detach";
26
+ tabId: number;
27
+ } | {
28
+ op: "send";
29
+ tabId: number;
30
+ sessionId?: string;
31
+ method: string;
32
+ params?: Record<string, unknown>;
33
+ } | {
34
+ op: "createTab";
35
+ url: string;
36
+ } | {
37
+ op: "removeTab";
38
+ tabId: number;
39
+ } | {
40
+ op: "activateTab";
41
+ tabId: number;
42
+ }
43
+ /** Add tabs to the per-window omp group (created/reused by title), remembering prior membership. */
44
+ | {
45
+ op: "group";
46
+ tabIds: number[];
47
+ title: string;
48
+ color: string;
49
+ }
50
+ /** Return tabs to their pre-omp group (or ungroup); no-op for tabs the relay never grouped. */
51
+ | {
52
+ op: "ungroup";
53
+ tabIds: number[];
54
+ };
55
+ /** Messages sent relay → extension. */
56
+ export type RelayToExtMessage = ({
57
+ t: "rpc";
58
+ id: number;
59
+ } & RelayRpcRequest) | {
60
+ t: "pong";
61
+ };
62
+ /** Messages sent extension → relay. */
63
+ export type ExtToRelayMessage = {
64
+ t: "hello";
65
+ userAgent: string;
66
+ browserVersion: string;
67
+ tabs: TabSnapshot[];
68
+ /** Tabs that already have a `chrome.debugger` attachment (relay reconciles after a service-worker restart). */
69
+ attachedTabIds: number[];
70
+ } | {
71
+ t: "cdpEvent";
72
+ tabId: number;
73
+ sessionId?: string;
74
+ method: string;
75
+ params?: Record<string, unknown>;
76
+ } | {
77
+ t: "detached";
78
+ tabId: number;
79
+ reason: string;
80
+ } | {
81
+ t: "tabCreated";
82
+ tab: TabSnapshot;
83
+ } | {
84
+ t: "tabUpdated";
85
+ tab: TabSnapshot;
86
+ } | {
87
+ t: "tabRemoved";
88
+ tabId: number;
89
+ } | {
90
+ t: "rpcResult";
91
+ id: number;
92
+ ok: boolean;
93
+ result?: unknown;
94
+ error?: string;
95
+ } | {
96
+ t: "ping";
97
+ };
@@ -0,0 +1,35 @@
1
+ /**
2
+ * HTTP + WebSocket server for the browser relay.
3
+ *
4
+ * Impersonates Chrome's CDP discovery endpoint so the omp browser tool (and
5
+ * any puppeteer client) can connect with a plain `browserURL`:
6
+ * - `GET /json/version` → 200 with `webSocketDebuggerUrl` once the extension
7
+ * is connected, 503 before that (clients like `waitForCdp` keep polling).
8
+ * - `GET /json` / `/json/list` → attachable page targets (debugging aid).
9
+ * - `WS /cdp` → downstream CDP clients (puppeteer).
10
+ * - `WS /ext` → the Chrome extension (token-gated when configured).
11
+ *
12
+ * Binds loopback only: anything that can reach this port can drive the
13
+ * user's logged-in browser.
14
+ */
15
+ import { RelayBridge } from "./bridge.js";
16
+ /** Options for {@link startRelayServer}. */
17
+ export interface RelayServerOptions {
18
+ port: number;
19
+ /** Shared secret the extension must present as `?token=`; unset disables the check. */
20
+ token?: string;
21
+ /** Group tabs the agent actively drives under one per-window Chrome tab group (default on); `false` disables. */
22
+ group?: boolean | {
23
+ title: string;
24
+ color: string;
25
+ };
26
+ log?: (message: string, data?: Record<string, unknown>) => void;
27
+ }
28
+ /** A running relay server. */
29
+ export interface RelayServer {
30
+ bridge: RelayBridge;
31
+ port: number;
32
+ stop(): void;
33
+ }
34
+ /** Start the relay server on 127.0.0.1. Throws if the port is taken. */
35
+ export declare function startRelayServer(opts: RelayServerOptions): RelayServer;
@@ -19,6 +19,7 @@ interface BrowserRenderArgs {
19
19
  app?: {
20
20
  path?: string;
21
21
  cdp_url?: string;
22
+ relay?: boolean;
22
23
  target?: string;
23
24
  cmux?: boolean;
24
25
  surface?: string;
@@ -8,6 +8,7 @@ export { type AriaSnapshotOptions, buildAriaSnapshotScript, parseAriaRefSelector
8
8
  export { cmuxSnapshotToObservation, mapWaitUntil, resolveCmuxKind, serializeEval } from "./browser/cmux/rpc.js";
9
9
  export { CmuxSocketClient } from "./browser/cmux/socket-client.js";
10
10
  export { extractReadableFromHtml, type ReadableFormat, type ReadableResult } from "./browser/readable.js";
11
+ export { DEFAULT_RELAY_URL, type RelayKind, resolveRelayKind } from "./browser/relay/kind.js";
11
12
  export type { Observation, ObservationEntry } from "./browser/tab-protocol.js";
12
13
  declare const browserSchema: import("arktype/internal/variants/object.ts").ObjectType<{
13
14
  action: "close" | "open" | "run";
@@ -16,6 +17,7 @@ declare const browserSchema: import("arktype/internal/variants/object.ts").Objec
16
17
  app?: {
17
18
  path?: string | undefined;
18
19
  cdp_url?: string | undefined;
20
+ relay?: boolean | undefined;
19
21
  args?: string[] | undefined;
20
22
  target?: string | undefined;
21
23
  } | undefined;
@@ -71,6 +73,7 @@ export declare class BrowserTool implements AgentTool<typeof browserSchema, Brow
71
73
  app?: {
72
74
  path?: string | undefined;
73
75
  cdp_url?: string | undefined;
76
+ relay?: boolean | undefined;
74
77
  args?: string[] | undefined;
75
78
  target?: string | undefined;
76
79
  } | undefined;
@@ -1,8 +1,10 @@
1
1
  import type { Model } from "@oh-my-pi/pi-ai";
2
- export type ComputerExposureMode = "native" | "function" | "unavailable";
3
- export interface ComputerExposureOptions {
4
- azureBaseUrl?: string;
5
- azureResourceName?: string;
6
- }
7
- /** Match the provider transport's effective Computer Use tool representation. */
8
- export declare function computerExposureMode(model: Model | undefined, options?: ComputerExposureOptions): ComputerExposureMode;
2
+ /** How the computer tool is represented to the active model. */
3
+ export type ComputerExposureMode = "function" | "unavailable";
4
+ /**
5
+ * Report the computer tool's callable representation.
6
+ *
7
+ * Window selection is part of the tool's JSON schema, so even models with
8
+ * provider-native Computer Use support receive it as a function.
9
+ */
10
+ export declare function computerExposureMode(model: Model | undefined): ComputerExposureMode;
@@ -1,41 +1,94 @@
1
- import type { DesktopAction, DesktopCapabilities, DesktopCapture, DesktopSessionOptions } from "@oh-my-pi/pi-natives";
1
+ import type { ImageContent, TextContent } from "@oh-my-pi/pi-ai";
2
+ import type { DesktopCapabilities } from "@oh-my-pi/pi-natives";
3
+ /** Hidden CLI selector that re-enters the computer worker host. */
2
4
  export declare const COMPUTER_WORKER_ARG = "__omp_worker_computer";
5
+ /** Frozen run settings transferred from the tool session to the worker. */
6
+ export interface ComputerSessionSnapshot {
7
+ cwd: string;
8
+ sessionId: string;
9
+ captureMaxWidth: number;
10
+ captureMaxHeight: number;
11
+ display: string;
12
+ readOnly: boolean;
13
+ }
14
+ /** Reply envelope for a session tool invoked by desktop JavaScript. */
15
+ export type ToolReply = {
16
+ ok: true;
17
+ value: unknown;
18
+ } | {
19
+ ok: false;
20
+ error: RunErrorPayload;
21
+ };
22
+ /** Commands accepted by the persistent computer worker. */
3
23
  export type ComputerWorkerInbound = {
4
24
  type: "ping";
5
25
  id: string;
6
26
  } | {
7
- type: "init";
8
- options: DesktopSessionOptions;
27
+ type: "run";
28
+ id: string;
29
+ code: string;
30
+ timeoutMs: number;
31
+ session: ComputerSessionSnapshot;
32
+ } | {
33
+ type: "abort";
34
+ id: string;
9
35
  } | {
10
- type: "execute";
36
+ type: "tool-reply";
11
37
  id: string;
12
- actions: DesktopAction[];
38
+ reply: ToolReply;
13
39
  } | {
14
40
  type: "close";
15
41
  };
42
+ /** Successful computer run output returned to the tool supervisor. */
43
+ export interface ComputerRunOk {
44
+ displays: Array<TextContent | ImageContent>;
45
+ returnValue: unknown;
46
+ screenshots: ComputerScreenshot[];
47
+ capabilities?: DesktopCapabilities;
48
+ }
49
+ /** Full-resolution screenshot emitted during one computer run. */
50
+ export interface ComputerScreenshot {
51
+ path: string;
52
+ width: number;
53
+ height: number;
54
+ sourceWidth?: number;
55
+ sourceHeight?: number;
56
+ target: string;
57
+ }
58
+ /** Clone-safe error metadata returned across the worker boundary. */
59
+ export interface RunErrorPayload {
60
+ name: string;
61
+ message: string;
62
+ stack?: string;
63
+ isToolError: boolean;
64
+ isAbort: boolean;
65
+ }
66
+ /** Events emitted by the persistent computer worker. */
16
67
  export type ComputerWorkerOutbound = {
68
+ type: "ready";
69
+ } | {
17
70
  type: "pong";
18
71
  id: string;
19
72
  } | {
20
- type: "ready";
21
- capabilities: DesktopCapabilities;
73
+ type: "result";
74
+ id: string;
75
+ ok: true;
76
+ payload: ComputerRunOk;
22
77
  } | {
23
78
  type: "result";
24
79
  id: string;
25
- capture: DesktopCapture;
26
- capabilities: DesktopCapabilities;
80
+ ok: false;
81
+ error: RunErrorPayload;
27
82
  } | {
28
- type: "error";
29
- id?: string;
30
- error: ComputerWorkerError;
83
+ type: "tool-call";
84
+ id: string;
85
+ runId: string;
86
+ name: string;
87
+ args: unknown;
31
88
  } | {
32
89
  type: "closed";
33
90
  };
34
- export interface ComputerWorkerError {
35
- name: string;
36
- message: string;
37
- stack?: string;
38
- }
91
+ /** Transport used by the worker core in Bun workers and tests. */
39
92
  export interface ComputerWorkerTransport {
40
93
  send(message: ComputerWorkerOutbound, transfer?: Bun.Transferable[]): void;
41
94
  onMessage(handler: (message: ComputerWorkerInbound) => void): () => void;