@evandu/super-pi-server 0.0.0-stage → 0.1.259

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 (370) hide show
  1. package/README.md +248 -3
  2. package/agents/code-auditor.md +64 -0
  3. package/agents/code-designer.md +64 -0
  4. package/agents/coder.md +24 -0
  5. package/agents/critic.md +24 -0
  6. package/agents/document-organizer.md +48 -0
  7. package/agents/patcher.md +27 -0
  8. package/agents/planner.md +30 -0
  9. package/agents/project-leader.md +28 -0
  10. package/agents/reviewer.md +27 -0
  11. package/agents/scout.md +27 -0
  12. package/agents/solution-designer.md +62 -0
  13. package/agents/super-pi-documents/index.ts +92 -0
  14. package/agents/super-pi-feishu/index.ts +88 -0
  15. package/agents/super-pi-knowledge/index.ts +70 -0
  16. package/agents/super-pi-managed-model/index.ts +9 -0
  17. package/agents/super-pi-memory/index.ts +75 -0
  18. package/agents/super-pi-native-tools/index.ts +1 -0
  19. package/agents/super-pi-task/core.ts +2262 -0
  20. package/agents/super-pi-task/index.ts +814 -0
  21. package/agents/super-pi-task/workflow-schema.ts +34 -0
  22. package/agents/super-pi-web/index.ts +32 -0
  23. package/agents/verifier.md +25 -0
  24. package/assets/fonts/LICENSE +92 -0
  25. package/assets/fonts/NotoSansSC-Bold.otf +0 -0
  26. package/assets/fonts/NotoSansSC-Regular.otf +0 -0
  27. package/assets/knowledge-model/README.md +37 -0
  28. package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/config.json +31 -0
  29. package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/onnx/model_quantized.onnx +0 -0
  30. package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/special_tokens_map.json +7 -0
  31. package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/tokenizer.json +21278 -0
  32. package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/tokenizer_config.json +15 -0
  33. package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/vocab.txt +21128 -0
  34. package/bin/npm-prefix.d.ts +1 -0
  35. package/bin/npm-prefix.js +10 -0
  36. package/bin/super-pi.js +349 -0
  37. package/dist/client/.super-pi-client-sources.json +82 -0
  38. package/dist/client/assets/CodeMirrorEditor-mi9rGUce.js +2 -0
  39. package/dist/client/assets/GitDiffEditor-CpoDDQrA.css +1 -0
  40. package/dist/client/assets/GitDiffEditor-FQBfGxOY.js +29 -0
  41. package/dist/client/assets/diff-ChtP43wD.js +1 -0
  42. package/dist/client/assets/dist-AW5lyI3I.js +1 -0
  43. package/dist/client/assets/dist-B3-a6uF0.js +7 -0
  44. package/dist/client/assets/dist-BGxkyh6e.js +1 -0
  45. package/dist/client/assets/dist-BJxfd7yb.js +11 -0
  46. package/dist/client/assets/dist-BRVQKlcp.js +1 -0
  47. package/dist/client/assets/dist-BV64A9Ji.js +1 -0
  48. package/dist/client/assets/dist-BXAOrsjq.js +1 -0
  49. package/dist/client/assets/dist-CKF2Jksy.js +1 -0
  50. package/dist/client/assets/dist-CX_Hm4GS.js +1 -0
  51. package/dist/client/assets/dist-Cus6_oaF.js +2 -0
  52. package/dist/client/assets/dist-Cx00EZKR.js +23 -0
  53. package/dist/client/assets/dist-D71y2EI1.js +1 -0
  54. package/dist/client/assets/dist-D978o95T.js +5 -0
  55. package/dist/client/assets/dist-Dc1MBGAG.js +1 -0
  56. package/dist/client/assets/dist-Dds-qLxY.js +9 -0
  57. package/dist/client/assets/dist-DeD9copn.js +1 -0
  58. package/dist/client/assets/dist-DuvGReu-.js +6 -0
  59. package/dist/client/assets/dist-Dvb0SqcK.js +2 -0
  60. package/dist/client/assets/dist-J6XWqRpB.js +3 -0
  61. package/dist/client/assets/dist-QzbOCAU6.js +1 -0
  62. package/dist/client/assets/dist-moiMRpw_.js +1 -0
  63. package/dist/client/assets/dist-scBkrwv-.js +2 -0
  64. package/dist/client/assets/dockerfile-BDePf5PZ.js +1 -0
  65. package/dist/client/assets/index-Cn7hdrDw.js +350 -0
  66. package/dist/client/assets/index-UfzqdECL.css +1 -0
  67. package/dist/client/assets/powershell-D8WpQPaX.js +1 -0
  68. package/dist/client/assets/properties-C357ku5U.js +1 -0
  69. package/dist/client/assets/rolldown-runtime-XKyaHtl9.js +1 -0
  70. package/dist/client/assets/ruby-ChfNwlCY.js +1 -0
  71. package/dist/client/assets/shell-DwuoZtxw.js +1 -0
  72. package/dist/client/assets/swift-DKB6_1j6.js +1 -0
  73. package/dist/client/assets/toml-BPTmHmyx.js +1 -0
  74. package/dist/client/favicon.ico +0 -0
  75. package/dist/client/favicon.png +0 -0
  76. package/dist/client/favicon.svg +10 -0
  77. package/dist/client/index.html +18 -0
  78. package/dist/extension.d.ts +15 -0
  79. package/dist/extension.js +126 -0
  80. package/dist/server/active-memory.d.ts +247 -0
  81. package/dist/server/active-memory.js +669 -0
  82. package/dist/server/agents.d.ts +245 -0
  83. package/dist/server/agents.js +701 -0
  84. package/dist/server/application/catalog-service.d.ts +98 -0
  85. package/dist/server/application/catalog-service.js +245 -0
  86. package/dist/server/application/conversation-service.d.ts +245 -0
  87. package/dist/server/application/conversation-service.js +654 -0
  88. package/dist/server/application/document-service.d.ts +68 -0
  89. package/dist/server/application/document-service.js +120 -0
  90. package/dist/server/application/extension-ui-service.d.ts +44 -0
  91. package/dist/server/application/extension-ui-service.js +135 -0
  92. package/dist/server/application/feishu-service.d.ts +179 -0
  93. package/dist/server/application/feishu-service.js +358 -0
  94. package/dist/server/application/group-chat-service.d.ts +75 -0
  95. package/dist/server/application/group-chat-service.js +953 -0
  96. package/dist/server/application/group-execution.d.ts +15 -0
  97. package/dist/server/application/group-execution.js +77 -0
  98. package/dist/server/application/project-service.d.ts +464 -0
  99. package/dist/server/application/project-service.js +2523 -0
  100. package/dist/server/application/provider-service.d.ts +174 -0
  101. package/dist/server/application/provider-service.js +510 -0
  102. package/dist/server/application/run-service.d.ts +547 -0
  103. package/dist/server/application/run-service.js +2683 -0
  104. package/dist/server/application/scheduled-task-service.d.ts +184 -0
  105. package/dist/server/application/scheduled-task-service.js +391 -0
  106. package/dist/server/application/session-orchestrator-service.d.ts +388 -0
  107. package/dist/server/application/session-orchestrator-service.js +1146 -0
  108. package/dist/server/application/session-reminder-service.d.ts +59 -0
  109. package/dist/server/application/session-reminder-service.js +141 -0
  110. package/dist/server/application/session-watchdog.d.ts +171 -0
  111. package/dist/server/application/session-watchdog.js +284 -0
  112. package/dist/server/application/workspace-service.d.ts +52 -0
  113. package/dist/server/application/workspace-service.js +186 -0
  114. package/dist/server/application/worktree-service.d.ts +13 -0
  115. package/dist/server/application/worktree-service.js +76 -0
  116. package/dist/server/browser-access.d.ts +34 -0
  117. package/dist/server/browser-access.js +89 -0
  118. package/dist/server/capability.d.ts +105 -0
  119. package/dist/server/capability.js +170 -0
  120. package/dist/server/command-handler.d.ts +93 -0
  121. package/dist/server/command-handler.js +540 -0
  122. package/dist/server/content-search.d.ts +16 -0
  123. package/dist/server/content-search.js +235 -0
  124. package/dist/server/conversation-usage.d.ts +22 -0
  125. package/dist/server/conversation-usage.js +43 -0
  126. package/dist/server/documents.d.ts +152 -0
  127. package/dist/server/documents.js +998 -0
  128. package/dist/server/engineering-learning.d.ts +30 -0
  129. package/dist/server/engineering-learning.js +106 -0
  130. package/dist/server/exec-service.d.ts +45 -0
  131. package/dist/server/exec-service.js +167 -0
  132. package/dist/server/explicit-file-open.d.ts +34 -0
  133. package/dist/server/explicit-file-open.js +105 -0
  134. package/dist/server/failure-text.d.ts +18 -0
  135. package/dist/server/failure-text.js +44 -0
  136. package/dist/server/feishu-cli.d.ts +223 -0
  137. package/dist/server/feishu-cli.js +464 -0
  138. package/dist/server/file-changes.d.ts +119 -0
  139. package/dist/server/file-changes.js +280 -0
  140. package/dist/server/file-diff.d.ts +41 -0
  141. package/dist/server/file-diff.js +97 -0
  142. package/dist/server/file-index.d.ts +100 -0
  143. package/dist/server/file-index.js +296 -0
  144. package/dist/server/file-name-index.d.ts +160 -0
  145. package/dist/server/file-name-index.js +411 -0
  146. package/dist/server/files.d.ts +269 -0
  147. package/dist/server/files.js +748 -0
  148. package/dist/server/git.d.ts +245 -0
  149. package/dist/server/git.js +903 -0
  150. package/dist/server/http-server.d.ts +45 -0
  151. package/dist/server/http-server.js +3830 -0
  152. package/dist/server/index.d.ts +1 -0
  153. package/dist/server/index.js +485 -0
  154. package/dist/server/inline-thinking.d.ts +90 -0
  155. package/dist/server/inline-thinking.js +181 -0
  156. package/dist/server/json-comments.d.ts +14 -0
  157. package/dist/server/json-comments.js +71 -0
  158. package/dist/server/knowledge-embedding-worker.d.ts +1 -0
  159. package/dist/server/knowledge-embedding-worker.js +27 -0
  160. package/dist/server/knowledge-vectors.d.ts +150 -0
  161. package/dist/server/knowledge-vectors.js +385 -0
  162. package/dist/server/knowledge.d.ts +273 -0
  163. package/dist/server/knowledge.js +848 -0
  164. package/dist/server/length-continuation.d.ts +83 -0
  165. package/dist/server/length-continuation.js +118 -0
  166. package/dist/server/logging.d.ts +32 -0
  167. package/dist/server/logging.js +185 -0
  168. package/dist/server/managed-http-tunnel.d.ts +6 -0
  169. package/dist/server/managed-http-tunnel.js +85 -0
  170. package/dist/server/managed-http.d.ts +4 -0
  171. package/dist/server/managed-http.js +85 -0
  172. package/dist/server/managed-model-adapter.d.ts +17 -0
  173. package/dist/server/managed-model-adapter.js +75 -0
  174. package/dist/server/managed-model-gateway.d.ts +49 -0
  175. package/dist/server/managed-model-gateway.js +73 -0
  176. package/dist/server/managed-servers.d.ts +55 -0
  177. package/dist/server/managed-servers.js +392 -0
  178. package/dist/server/managed-ssh.d.ts +26 -0
  179. package/dist/server/managed-ssh.js +73 -0
  180. package/dist/server/manager-vault.d.ts +11 -0
  181. package/dist/server/manager-vault.js +67 -0
  182. package/dist/server/memory-recall.d.ts +25 -0
  183. package/dist/server/memory-recall.js +45 -0
  184. package/dist/server/memory.d.ts +67 -0
  185. package/dist/server/memory.js +216 -0
  186. package/dist/server/message-media.d.ts +7 -0
  187. package/dist/server/message-media.js +54 -0
  188. package/dist/server/model-context-window.d.ts +186 -0
  189. package/dist/server/model-context-window.js +444 -0
  190. package/dist/server/model-filter.d.ts +23 -0
  191. package/dist/server/model-filter.js +48 -0
  192. package/dist/server/models-store.d.ts +36 -0
  193. package/dist/server/models-store.js +132 -0
  194. package/dist/server/native-tool-settings.d.ts +25 -0
  195. package/dist/server/native-tool-settings.js +41 -0
  196. package/dist/server/native-tools-extension.d.ts +2 -0
  197. package/dist/server/native-tools-extension.js +39 -0
  198. package/dist/server/native-tools-service.d.ts +39 -0
  199. package/dist/server/native-tools-service.js +240 -0
  200. package/dist/server/persistence/app-state-repository.d.ts +65 -0
  201. package/dist/server/persistence/app-state-repository.js +1 -0
  202. package/dist/server/persistence/json-state-repository.d.ts +14 -0
  203. package/dist/server/persistence/json-state-repository.js +43 -0
  204. package/dist/server/persistence/open-state-store.d.ts +3 -0
  205. package/dist/server/persistence/open-state-store.js +35 -0
  206. package/dist/server/persistence/rename.d.ts +22 -0
  207. package/dist/server/persistence/rename.js +44 -0
  208. package/dist/server/persistence/sqlite-state-repository.d.ts +12 -0
  209. package/dist/server/persistence/sqlite-state-repository.js +264 -0
  210. package/dist/server/pi-command.d.ts +94 -0
  211. package/dist/server/pi-command.js +265 -0
  212. package/dist/server/pi-native.d.ts +12 -0
  213. package/dist/server/pi-native.js +16 -0
  214. package/dist/server/pi-session-events.d.ts +158 -0
  215. package/dist/server/pi-session-events.js +373 -0
  216. package/dist/server/pi-session-pool.d.ts +233 -0
  217. package/dist/server/pi-session-pool.js +382 -0
  218. package/dist/server/pi-session.d.ts +642 -0
  219. package/dist/server/pi-session.js +655 -0
  220. package/dist/server/presentations/schema.d.ts +120 -0
  221. package/dist/server/presentations/schema.js +128 -0
  222. package/dist/server/provider-network.d.ts +16 -0
  223. package/dist/server/provider-network.js +106 -0
  224. package/dist/server/provider-proxy.d.ts +18 -0
  225. package/dist/server/provider-proxy.js +200 -0
  226. package/dist/server/providers.d.ts +333 -0
  227. package/dist/server/providers.js +989 -0
  228. package/dist/server/remote-bootstrap.d.ts +17 -0
  229. package/dist/server/remote-bootstrap.js +119 -0
  230. package/dist/server/rpc-channel.d.ts +131 -0
  231. package/dist/server/rpc-channel.js +135 -0
  232. package/dist/server/runtime.d.ts +1393 -0
  233. package/dist/server/runtime.js +3286 -0
  234. package/dist/server/scheduled-tasks.d.ts +101 -0
  235. package/dist/server/scheduled-tasks.js +138 -0
  236. package/dist/server/server-context.d.ts +119 -0
  237. package/dist/server/server-context.js +1 -0
  238. package/dist/server/session-cwd.d.ts +19 -0
  239. package/dist/server/session-cwd.js +58 -0
  240. package/dist/server/session-ledger.d.ts +67 -0
  241. package/dist/server/session-ledger.js +76 -0
  242. package/dist/server/session-memory-scope.d.ts +4 -0
  243. package/dist/server/session-memory-scope.js +30 -0
  244. package/dist/server/session-repository.d.ts +100 -0
  245. package/dist/server/session-repository.js +246 -0
  246. package/dist/server/session-tree-scope.d.ts +125 -0
  247. package/dist/server/session-tree-scope.js +337 -0
  248. package/dist/server/skills.d.ts +23 -0
  249. package/dist/server/skills.js +190 -0
  250. package/dist/server/store.d.ts +1062 -0
  251. package/dist/server/store.js +3305 -0
  252. package/dist/server/subagent-runs.d.ts +185 -0
  253. package/dist/server/subagent-runs.js +383 -0
  254. package/dist/server/subagents.d.ts +200 -0
  255. package/dist/server/subagents.js +619 -0
  256. package/dist/server/task-tool.d.ts +282 -0
  257. package/dist/server/task-tool.js +507 -0
  258. package/dist/server/tavily.d.ts +32 -0
  259. package/dist/server/tavily.js +136 -0
  260. package/dist/server/team-context.d.ts +12 -0
  261. package/dist/server/team-context.js +180 -0
  262. package/dist/server/terminal.d.ts +163 -0
  263. package/dist/server/terminal.js +557 -0
  264. package/dist/server/thinking-level-discovery.d.ts +38 -0
  265. package/dist/server/thinking-level-discovery.js +183 -0
  266. package/dist/server/time-zone.d.ts +20 -0
  267. package/dist/server/time-zone.js +32 -0
  268. package/dist/server/tool-calls.d.ts +130 -0
  269. package/dist/server/tool-calls.js +341 -0
  270. package/dist/server/tool-llm.d.ts +72 -0
  271. package/dist/server/tool-llm.js +146 -0
  272. package/dist/server/tool-registry.d.ts +129 -0
  273. package/dist/server/tool-registry.js +249 -0
  274. package/dist/server/tool-runner.d.ts +112 -0
  275. package/dist/server/tool-runner.js +306 -0
  276. package/dist/server/turn-failure.d.ts +48 -0
  277. package/dist/server/turn-failure.js +148 -0
  278. package/dist/server/types.d.ts +2315 -0
  279. package/dist/server/types.js +11 -0
  280. package/dist/server/update-status.d.ts +14 -0
  281. package/dist/server/update-status.js +69 -0
  282. package/dist/server/update.d.ts +46 -0
  283. package/dist/server/update.js +104 -0
  284. package/dist/server/upload.d.ts +35 -0
  285. package/dist/server/upload.js +177 -0
  286. package/dist/server/version.d.ts +33 -0
  287. package/dist/server/version.js +111 -0
  288. package/dist/server/web.d.ts +27 -0
  289. package/dist/server/web.js +183 -0
  290. package/dist/server/workflow-engine.d.ts +47 -0
  291. package/dist/server/workflow-engine.js +255 -0
  292. package/dist/server/workflow.d.ts +329 -0
  293. package/dist/server/workflow.js +469 -0
  294. package/dist/server/workspace-file-indexes.d.ts +2 -0
  295. package/dist/server/workspace-file-indexes.js +61 -0
  296. package/dist/server/workspace-file-operations.d.ts +36 -0
  297. package/dist/server/workspace-file-operations.js +281 -0
  298. package/dist/server/workspace-file-response.d.ts +7 -0
  299. package/dist/server/workspace-file-response.js +79 -0
  300. package/dist/server/ws-server.d.ts +149 -0
  301. package/dist/server/ws-server.js +640 -0
  302. package/dist/shared/agent-order.d.ts +44 -0
  303. package/dist/shared/agent-order.js +50 -0
  304. package/dist/shared/archive-decisions.d.ts +44 -0
  305. package/dist/shared/archive-decisions.js +98 -0
  306. package/dist/shared/background-task.d.ts +25 -0
  307. package/dist/shared/background-task.js +183 -0
  308. package/dist/shared/child-session-lock.d.ts +37 -0
  309. package/dist/shared/child-session-lock.js +59 -0
  310. package/dist/shared/content-search.d.ts +22 -0
  311. package/dist/shared/content-search.js +1 -0
  312. package/dist/shared/conversation-title.d.ts +4 -0
  313. package/dist/shared/conversation-title.js +4 -0
  314. package/dist/shared/file-mentions.d.ts +17 -0
  315. package/dist/shared/file-mentions.js +91 -0
  316. package/dist/shared/git-commit.d.ts +11 -0
  317. package/dist/shared/git-commit.js +1 -0
  318. package/dist/shared/git-graph.d.ts +42 -0
  319. package/dist/shared/git-graph.js +30 -0
  320. package/dist/shared/group-chat.d.ts +132 -0
  321. package/dist/shared/group-chat.js +6 -0
  322. package/dist/shared/managed-servers.d.ts +36 -0
  323. package/dist/shared/managed-servers.js +1 -0
  324. package/dist/shared/message-media.d.ts +12 -0
  325. package/dist/shared/message-media.js +27 -0
  326. package/dist/shared/model-window-label.d.ts +39 -0
  327. package/dist/shared/model-window-label.js +55 -0
  328. package/dist/shared/native-tools.d.ts +43 -0
  329. package/dist/shared/native-tools.js +1 -0
  330. package/dist/shared/pi-cache-warming.d.ts +9 -0
  331. package/dist/shared/pi-cache-warming.js +4 -0
  332. package/dist/shared/project-overview.d.ts +107 -0
  333. package/dist/shared/project-overview.js +92 -0
  334. package/dist/shared/project-presentation.d.ts +55 -0
  335. package/dist/shared/project-presentation.js +111 -0
  336. package/dist/shared/provider-network.d.ts +30 -0
  337. package/dist/shared/provider-network.js +1 -0
  338. package/dist/shared/session-reporting.d.ts +40 -0
  339. package/dist/shared/session-reporting.js +97 -0
  340. package/dist/shared/session-search.d.ts +14 -0
  341. package/dist/shared/session-search.js +1 -0
  342. package/dist/shared/team-context-view.d.ts +33 -0
  343. package/dist/shared/team-context-view.js +49 -0
  344. package/dist/shared/team-context.d.ts +59 -0
  345. package/dist/shared/team-context.js +3 -0
  346. package/dist/shared/terminal-protocol.d.ts +71 -0
  347. package/dist/shared/terminal-protocol.js +1 -0
  348. package/dist/shared/thinking-levels.d.ts +53 -0
  349. package/dist/shared/thinking-levels.js +85 -0
  350. package/dist/shared/tool-glyph.d.ts +7 -0
  351. package/dist/shared/tool-glyph.js +19 -0
  352. package/dist/shared/transcript-order.d.ts +7 -0
  353. package/dist/shared/transcript-order.js +12 -0
  354. package/dist/shared/update-status.d.ts +28 -0
  355. package/dist/shared/update-status.js +1 -0
  356. package/dist/shared/workspace-file-preview.d.ts +4 -0
  357. package/dist/shared/workspace-file-preview.js +28 -0
  358. package/package.json +448 -4
  359. package/scripts/diagnose.mjs +603 -0
  360. package/scripts/patch-brace-expansion.mjs +260 -0
  361. package/scripts/restart-server.mjs +104 -0
  362. package/skills/presentation/SKILL.md +30 -0
  363. package/skills/presentation/references/data.md +10 -0
  364. package/skills/presentation/references/quality.md +12 -0
  365. package/skills/presentation/references/story.md +12 -0
  366. package/skills/presentation/references/templates-and-editing.md +11 -0
  367. package/skills/presentation/references/visual-system.md +10 -0
  368. package/skills/super-pi-agent-development/SKILL.md +25 -0
  369. package/skills/super-pi-development/SKILL.md +31 -0
  370. package/skills/super-pi-tool-development/SKILL.md +39 -0
@@ -0,0 +1,547 @@
1
+ import type { Store } from "../store.js";
2
+ import { type AgentRuntime } from "../runtime.js";
3
+ import type { SubagentRunRecorder } from "../subagent-runs.js";
4
+ import type { Conversation, Message, MessageDeliveryMode, MessageImage, PiQueueSnapshot, QuestionAnswer, Workspace } from "../types.js";
5
+ import type { EventBroadcaster } from "../server-context.js";
6
+ import type { ExtensionUiService } from "./extension-ui-service.js";
7
+ import type { WorkflowEngine } from "../workflow-engine.js";
8
+ import { FileChangeTracker } from "../file-changes.js";
9
+ import type { ExecCompletion } from "../exec-service.js";
10
+ /**
11
+ * Validates a caller-supplied delivery mode without silently falling back on bogus values.
12
+ * Undefined defaults to `"queue"`; any other value is rejected explicitly.
13
+ */
14
+ export declare function parseMessageDeliveryMode(mode: unknown): MessageDeliveryMode;
15
+ export interface SubagentDispatchRequestBody {
16
+ conversationId?: string;
17
+ subagent_type?: string;
18
+ prompt?: string;
19
+ depth?: number;
20
+ parentRunId?: string;
21
+ background?: boolean;
22
+ description?: string;
23
+ loopId?: string;
24
+ role?: string;
25
+ /** The per-turn dispatch capability, presented by the primary agent's extension. See `capability.ts`. */
26
+ capability?: string;
27
+ /**
28
+ * Pi's id for the tool call that asked for this dispatch, which the extension already receives as
29
+ * `execute`'s first argument and previously discarded. The server resolves it to a position in the
30
+ * dispatching message so the card renders AT THE CALL rather than at a point in time.
31
+ *
32
+ * UNVERIFIED AND THEREFORE INERT: it is a claim about which row a card belongs in, not a credential,
33
+ * so it is checked against nothing. An id that resolves to no call is simply no anchor. That is
34
+ * deliberate - this field crosses a boundary a model can reach, and a sub-agent inventing an id to park
35
+ * its card inside somebody else's tool call would be a way to make a run look like it belongs to work it
36
+ * never did. A position is not a permission, and it grants none.
37
+ */
38
+ toolCallId?: string;
39
+ }
40
+ /**
41
+ * A whole orchestrated plan, as it arrives over the wire.
42
+ *
43
+ * Deliberately NOT a `WorkflowPlan`: the plan type is what validation PRODUces, and accepting it as an
44
+ * input would let a caller assert that its steps were already checked. This is the untrusted shape, and
45
+ * `validateWorkflowPlan` is what turns one into a plan.
46
+ */
47
+ export interface WorkflowRunRequestBody {
48
+ conversationId?: string;
49
+ summary?: string;
50
+ onFailure?: string;
51
+ steps?: unknown;
52
+ nodes?: unknown;
53
+ /** The per-turn dispatch capability, presented by the primary agent's extension. See `capability.ts`. */
54
+ capability?: string;
55
+ /** Pi's id for the tool call that asked for this, and resolved the same inert way as a sub-agent
56
+ * dispatch's - a position in the transcript, never a permission. */
57
+ toolCallId?: string;
58
+ }
59
+ /**
60
+ * Service managing execution of conversation turns, message queueing,
61
+ * follow-ups, and sub-agent dispatching.
62
+ */
63
+ export declare class RunService {
64
+ private readonly store;
65
+ private readonly runtime;
66
+ private readonly subagents;
67
+ private readonly broadcaster;
68
+ private readonly extensionUiService;
69
+ private agentsDir;
70
+ private readonly workflows;
71
+ private readonly questionWaiters;
72
+ /** A stop can race a late question callback; remember the stopped turn so it cannot park forever. */
73
+ private readonly cancelledQuestionConversations;
74
+ private memory?;
75
+ setMemory(memory: import("../active-memory.js").ActiveMemory): void;
76
+ private recordCodingStandards;
77
+ /**
78
+ * WHAT THE AGENT CHANGED, and what each file looked like before.
79
+ *
80
+ * The tracker is a SETTER rather than a constructor argument, for the same reason `memory` is: it is
81
+ * optional, and a service that must be handed one cannot be built before the thing that builds it.
82
+ */
83
+ private fileChanges?;
84
+ private fileIndexes?;
85
+ /**
86
+ * The NAME indexes, for the same reason the content-search ones are here: the agent's writes have to
87
+ * reach the index a filename search reads, or a file the agent just created would be invisible to the
88
+ * person looking for it.
89
+ */
90
+ private nameIndexes?;
91
+ setFileChanges(tracker: FileChangeTracker): void;
92
+ setFileIndexes(indexes: Map<string, import("../file-index.js").FileIndex>): void;
93
+ setNameIndexes(indexes: Map<string, import("../file-name-index.js").FileNameIndex>): void;
94
+ reviewMemoryBoundary(conversationId: string): void;
95
+ private readonly activeRuns;
96
+ stoppingConversationIds(): string[];
97
+ private readonly acceptingSends;
98
+ private readonly lengthContinuations;
99
+ private readonly turnEventScopes;
100
+ private readonly historyCutClaims;
101
+ holdHistoryCut(conversationId: string): void;
102
+ releaseHistoryCut(conversationId: string): void;
103
+ private assertHistoryAvailable;
104
+ /**
105
+ * Whether a conversation is a child session with an active (unarchived) parent.
106
+ *
107
+ * Reuses the canonical judgement in `src/shared/child-session-lock.ts`: child sessions
108
+ * must report upwards via `session_report` rather than asking the user directly.
109
+ */
110
+ private isChildConversation;
111
+ /**
112
+ * The completion of the run currently holding a conversation's slot.
113
+ *
114
+ * The slot and the promise are two halves of one fact - "this conversation has a run" and "that run is
115
+ * over" - and they are claimed and released together. A waiter that needs the slot (an interrupt, a
116
+ * send-now) AWAITS the promise rather than polling the map: polling samples a flag on a 10ms clock and
117
+ * has to guess at the state around it, while the promise IS the event, fired by the run's own `finally`.
118
+ */
119
+ private readonly runCompletions;
120
+ /** A selected interrupt owns the next free run slot, even while the old child exits. */
121
+ private readonly interruptTargets;
122
+ private readonly pendingBackgroundWakeups;
123
+ private shuttingDown;
124
+ /** Preserve incoming background results as waiting messages while the server drains its producers. */
125
+ beginShutdown(): void;
126
+ /** Claims the run slot and arms its completion promise. Call sites release with `releaseRunSlot`. */
127
+ private claimRunSlot;
128
+ /** Releases the run slot and settles its completion promise, so a waiter wakes on the SAME instruction. */
129
+ private releaseRunSlot;
130
+ /**
131
+ * WHERE EACH TOOL CALL LANDED, per conversation, for as long as the turn that made it is still running.
132
+ *
133
+ * Keyed by Pi's own `toolCallId` - the id the model sees, which Pi also hands to the tool as `execute`'s
134
+ * first argument. That is the only handle shared by the two halves of a dispatch: the server learns the
135
+ * call exists while streaming the turn, and learns it was a sub-agent only when the child, running in a
136
+ * SEPARATE process, posts back over HTTP. `rowByToolCallId` already maps the same key to a row, but it is
137
+ * a local of `streamTurn` and the dispatch arrives in `dispatchTask` - a different closure, reached by an
138
+ * HTTP request. Without a bridge between them the server could only stamp a card with a start time, and
139
+ * a card sorted by start time lands BELOW every message still streaming after the call that asked for it.
140
+ *
141
+ * The outer map is per conversation rather than global so two conversations cannot read each other's
142
+ * positions, and it is dropped when the turn ends because that is when the fact stops being true: a
143
+ * dispatch that arrives after its turn has finished gets no anchor, which renders as it always did.
144
+ */
145
+ private readonly toolCallLanes;
146
+ private readonly toolCallWaiters;
147
+ private readonly toolCallSites;
148
+ /** Records that Pi's `toolCallId` became row `row` of `messageId`. */
149
+ private noteToolCallSite;
150
+ /**
151
+ * The call a dispatch belongs to, as the two fields a card carries. Absent - rather than row zero - when
152
+ * there is no call to point at: a person pressing 派子智能体 has no tool call, a dispatch from an older
153
+ * extension has no id, and a dispatch that landed after its turn ended has outlived the map.
154
+ */
155
+ originForToolCall(conversationId: string, toolCallId: string | undefined): {
156
+ originMessageId: string;
157
+ originCallRow: number;
158
+ } | undefined;
159
+ waitForToolCall(conversationId: string, toolCallId: string | undefined): Promise<ReturnType<RunService["originForToolCall"]>>;
160
+ private execService;
161
+ private backgroundLogDirectory?;
162
+ private readonly execSettlements;
163
+ setExecService(execService: import("../exec-service.js").ExecService, logDirectory?: string): void;
164
+ /**
165
+ * Called by the exec completion handler in index.ts when a background exec session ends.
166
+ * Injects the result into the conversation and cleans up the background task record.
167
+ *
168
+ * The result is now a REAL queue item, not a one-way notice the model never gets to read: it lands
169
+ * with `delivery: "waiting"` (so the dock shows it), at the front of the waiting set (so any pending
170
+ * user sends wait behind it), and the conversation auto-starts a turn for the agent to handle it
171
+ * when nothing else is busy. The render stays as a 后台回传 block throughout - in dock and in
172
+ * transcript - so a `role: "user"` is never impersonated.
173
+ */
174
+ enqueueExecResult(sessionId: string, exitCode: number, stdout: string, stderr: string, completion?: ExecCompletion): void;
175
+ failBackgroundTaskStart(taskId: string, reason: string, cancelled?: boolean): Promise<void>;
176
+ private finishBackgroundResult;
177
+ private startBackgroundResult;
178
+ /**
179
+ * Delivers an orchestrated child session's final output to its direct parent. This intentionally uses
180
+ * the same waiting-queue contract as background sub-agent results: one result per turn, ahead of
181
+ * unclaimed user messages, with an automatic follow-up turn only when the parent is idle.
182
+ */
183
+ enqueueSessionResult(input: {
184
+ conversationId: string;
185
+ parentConversationId?: string;
186
+ output: string;
187
+ resultPath: string;
188
+ error?: string;
189
+ }): Promise<void>;
190
+ private dispatchBackgroundResult;
191
+ private wakeWaitingBackgroundResult;
192
+ stopBackgroundTask(taskId: string): Promise<void>;
193
+ hasActiveBackgroundTasks(conversationId: string): boolean;
194
+ settleBackgroundStatus(conversationId: string): Promise<void>;
195
+ /** Per-conversation command lane. All queue mutations and run claims use the same lane, so
196
+ * two browser tabs cannot both observe an idle conversation and start duplicate turns. */
197
+ private readonly conversationOps;
198
+ /** Detached work (human and background sub-agents) which shutdown must still await. */
199
+ private readonly detached;
200
+ constructor(store: Store, runtime: AgentRuntime, subagents: SubagentRunRecorder, broadcaster: EventBroadcaster, extensionUiService: ExtensionUiService, agentsDir: string | string[], workflows: WorkflowEngine);
201
+ setAgentsDir(dir: string | string[]): void;
202
+ /**
203
+ * TELLS THE BROWSER WHICH FILES THE AGENT CHANGED.
204
+ *
205
+ * The whole list goes every time rather than just the newest file, because the event is a SNAPSHOT
206
+ * (like `state` and `subagent.event`): a browser that missed one rebuilds the list from the next
207
+ * one, instead of holding a list assembled from a partial sequence of deltas.
208
+ */
209
+ broadcastFileChanges(workspaceId: string): void;
210
+ /**
211
+ * RECORDS WHAT THE PERSON CHOSE, ON THE `question` CALL THAT ASKED.
212
+ *
213
+ * The call is addressed by its index in the message's `toolCalls`, which is the same addressing every
214
+ * other tool update uses - and the client can only get that index from the row it is already rendering.
215
+ */
216
+ answerQuestion(command: {
217
+ conversationId: string;
218
+ messageId: string;
219
+ callIndex: number;
220
+ answers?: QuestionAnswer[];
221
+ cancelled?: boolean;
222
+ }): Promise<void>;
223
+ private questionKey;
224
+ private answerPayload;
225
+ private settleQuestion;
226
+ private cancelQuestionWaiters;
227
+ /**
228
+ * THE `question` TOOL BLOCKS HERE, ON THE CALL THAT ASKED IT.
229
+ *
230
+ * It used to APPEND A BLOCK TO THE MESSAGE and poll the store for an answer, which meant the question
231
+ * had no position in the answer at all: the card rendered after everything the model said, so the text
232
+ * streamed in response to the answer appeared ABOVE the card it was answering. The call is already on
233
+ * screen, already positioned by its `at`, already persisted, already reloads - so the pending wait is
234
+ * registered against it and nothing else is created.
235
+ *
236
+ * A DISMISSAL FAILS THE CALL. It used to resolve with `{cancelled:true}` and let the run continue, so
237
+ * closing a card handed the model a turn it would answer as though it had been told something. OpenCode
238
+ * is unambiguous about this and is the reference here: rejecting a question fails the deferred, the tool
239
+ * dies and the run is interrupted (`packages/core/src/question.ts:128-141`). Nothing is invented to fill
240
+ * the gap - the same rule the Extension UI path already follows, where a cancelled method is never
241
+ * backfilled with `options[0]`.
242
+ */
243
+ askQuestion(conversationId: string): Promise<unknown>;
244
+ /**
245
+ * Resolves the conversation and workspace synchronously for a run.
246
+ *
247
+ * TWO CLONES, NOT TWO SNAPSHOTS. This used to call `store.snapshot()` twice - once for the
248
+ * conversation and once for the workspace - and a snapshot deep-clones the ENTIRE application
249
+ * state: every other conversation, every message in it, every tool result. It runs a handful of
250
+ * times per turn, twice of them before the frame that tells the browser a turn has started, so the
251
+ * size of the whole state was part of the wait between clicking 发送 and seeing 等待 LLM 返回.
252
+ */
253
+ turnContext(conversationId: string): {
254
+ conversation: Conversation;
255
+ workspace: Workspace;
256
+ };
257
+ /**
258
+ * Resolves conversation and workspace working directory for subagent dispatch.
259
+ */
260
+ dispatchContext(conversationId: string): Promise<{
261
+ conversation: Conversation;
262
+ cwd: string;
263
+ }>;
264
+ /**
265
+ * Checks whether a conversation has an active turn running.
266
+ */
267
+ isRunning(conversationId: string): boolean;
268
+ /** Waits for this conversation's current producer, without waiting for unrelated sessions. */
269
+ waitForConversationIdle(conversationId: string): Promise<void>;
270
+ /** Returns true while a stop has been requested and the old producer is still unwinding. */
271
+ private isStopping;
272
+ /**
273
+ * Checks the session credential together with the application-level turn truth.
274
+ *
275
+ * `activeRuns` is set synchronously before `runtime.answer()` is entered and cleared in that same
276
+ * turn's finally block. It is therefore the authoritative answer to "is there a primary turn to act
277
+ * for?". Keeping a second set in the runtime made correctness depend on two lifecycles agreeing and
278
+ * left HTTP-only paths with no owner at all.
279
+ */
280
+ verifyPrimaryCapability(conversationId: string, capability: unknown): import("../capability.js").CapabilityVerdict;
281
+ foregroundSignal(conversationId: string): AbortSignal | undefined;
282
+ canAdmitBackgroundTask(signal?: AbortSignal): boolean;
283
+ /**
284
+ * Aborts all active conversation runs and sub-agents.
285
+ */
286
+ abortAll(): void;
287
+ /**
288
+ * Waits for conversation turns and detached dispatches to run their finally blocks.
289
+ * The recorder has its own wait because workflow steps can reach it without being
290
+ * represented by a detached promise here.
291
+ */
292
+ waitForIdle(): Promise<void>;
293
+ private trackDetached;
294
+ private serializeConversation;
295
+ /** Priority begins immediately after messages already handed to Pi, in their FIFO order. */
296
+ private moveAheadOfUnclaimed;
297
+ /**
298
+ * Stops an active turn run for a conversation.
299
+ */
300
+ stopRun(conversationId: string, options?: {
301
+ foregroundOnly?: boolean;
302
+ }): Promise<void>;
303
+ /** Releases waits that can prevent Pi's abort from reaching its idle state. Idempotent by design. */
304
+ private cancelPendingRunInteractions;
305
+ private stopRunUnsafe;
306
+ /**
307
+ * Handles queue snapshot updates from Pi RPC.
308
+ *
309
+ * NOW PURELY OBSERVATIONAL, and that is the fix rather than a simplification. It used to INFER a
310
+ * delivery from a drop in `steering.length` and act on it by deleting the oldest `sending` row - which is
311
+ * how a steered message could reach the model, be answered at length, and leave no trace in the
312
+ * transcript the user was reading. A count also cannot say WHICH row, so a snapshot arriving out of
313
+ * order could delete a message that had not been delivered at all.
314
+ *
315
+ * Delivery is now announced by Pi itself, through `onSteerDelivered`, and applied by `streamTurn`. What
316
+ * is left here is the one thing this event is genuinely good for: telling the browser what Pi holds, at
317
+ * the moment Pi holds it.
318
+ */
319
+ onPiQueue(conversationId: string, snapshot: PiQueueSnapshot): void;
320
+ /** Ordinary waiting rows belong to Super Pi and cannot be delivered by a Pi event. */
321
+ private matchDeliveredMessage;
322
+ /**
323
+ * Empties Pi's steering and follow-up queues for a conversation.
324
+ *
325
+ * WHY A HOST HAS TO DO THIS. Pi delivers whatever is left in those queues when the run ends, and it
326
+ * cannot take back a single message - `clear_queue` is the only queue command it has. So whenever
327
+ * Super Pi takes a message back, the queues have to be emptied, or Pi answers words the user believes
328
+ * they took back.
329
+ *
330
+ * NOTHING IS LOST. Every message Pi was holding is still in Super Pi's own waiting list, and the run's
331
+ * loop answers those as turns of their own.
332
+ *
333
+ * THE STEERS COME BACK. Emptying the queues also empties the steering queue, and a steer is a message
334
+ * the user asked to be answered NOW - so the ones Pi had not delivered go back in, and clearing the
335
+ * queues for one message does not silently un-steer another.
336
+ */
337
+ /**
338
+ * Empties Pi's steering and follow-up queues for a conversation, returning any steering message
339
+ * IDs that were intentionally withheld because they appear in `excludeMessageIds`.
340
+ *
341
+ * Remaining steering messages not in `excludeMessageIds` are put back into Pi's steering queue
342
+ * in FIFO order (matching at most once per message ID even when two messages share identical text).
343
+ */
344
+ private clearPiQueues;
345
+ /**
346
+ * Opens a turn on a message that is ALREADY IN THE TRANSCRIPT.
347
+ *
348
+ * It creates no user message. The words were written when the user pressed send - that is the whole
349
+ * promise the client is making - so opening a turn can only mark that message as no longer waiting and
350
+ * put the answer beneath it. `store.openTurnOnMessage` does both in one write, and splices the assistant
351
+ * message in directly AFTER rather than appending it, which is what keeps a second waiting message below
352
+ * the reply to the first.
353
+ */
354
+ openTurn(conversationId: string, messageId: string): Promise<{
355
+ user: Message;
356
+ assistant: Message;
357
+ }>;
358
+ /**
359
+ * Streams a turn via AgentRuntime.
360
+ *
361
+ * A TURN CAN CONTAIN MORE THAN ONE ANSWER. When Pi delivers a steered message it announces the
362
+ * boundary (`message_start`), and everything streamed after it is the answer to THAT message rather than
363
+ * more of the same one. So this function can be handed a different `assistant` mid-flight: `assistant`
364
+ * is a parameter rather than a const precisely so one assignment redirects every handler below, each of
365
+ * which closes over the binding rather than over the value it saw when it was made.
366
+ *
367
+ * Before this, a delivered steer's answer was appended to the message that was already streaming. The
368
+ * model was answering words that existed in no message at all, and the transcript showed a reply with
369
+ * nothing above it - the user could not find what they had typed, while the agent quoted it back.
370
+ */
371
+ streamTurn(conversation: Conversation, workspace: Workspace, prompt: string, assistantMessage: Message, controller: AbortController, userMessageId: string, images?: MessageImage[], agentIdentity?: Message["agentIdentity"]): Promise<void>;
372
+ /**
373
+ * Loops running turns for as long as waiting messages exist.
374
+ *
375
+ * The FIRST message is passed in rather than opened here, because it was written into the transcript
376
+ * before this method was called: the user pressed send, and their words were on screen in that frame. The
377
+ * loop then does the same thing for each message after it - take the next waiting one, open its turn,
378
+ * stream it - which is why the two cases are expressed identically and cannot drift apart.
379
+ */
380
+ runConversationTurns(conversation: Conversation, workspace: Workspace, prompt: string, controller: AbortController, firstMessageId: string, initialImages?: MessageImage[]): Promise<void>;
381
+ /**
382
+ * Refuses a turn when the selected model cannot accept image input, either because the incoming
383
+ * message carries images or because previous messages in the conversation contain images.
384
+ */
385
+ private assertModelSupportsImages;
386
+ /** Keep admission owned through final persistence and recheck the durable queue before releasing. */
387
+ private runUntilDrained;
388
+ /**
389
+ * Enqueues or starts execution for a user message.
390
+ */
391
+ /**
392
+ * STARTS A TURN FROM A SENDER THAT IS NOT THE READER.
393
+ *
394
+ * `enqueueAndRun` below is the person's path: it writes the words under the reader's own name, in
395
+ * the reader's bubble, so the reader can see that they said it. The orchestrator's path is the
396
+ * same machinery with a different speaker - a primary agent handing a task to a child session -
397
+ * and writing THAT under the reader's name was the bug the reader reported: the child's
398
+ * transcript showed an instruction they never typed, wearing their avatar.
399
+ *
400
+ * So the write goes through `addAgentMessage` instead, which records the words as the system's,
401
+ * and the turn runs on them exactly as before. `composePrompt` is what tells the model who is
402
+ * speaking, so the model is addressed in the same words.
403
+ */
404
+ enqueueAndRunAsAgent(conversationId: string, content: string, options?: {
405
+ mode?: MessageDeliveryMode;
406
+ onAccepted?: (messageId: string) => void;
407
+ }): Promise<void>;
408
+ acknowledgeAcceptedSend(conversationId: string, clientId: string | undefined): Promise<boolean>;
409
+ enqueueAndRun(conversationId: string, content: string, images?: MessageImage[], attachments?: Message["attachments"], clientId?: string, mode?: MessageDeliveryMode, onAccepted?: () => void): Promise<void>;
410
+ enqueueReminder(conversationId: string, note: string): Promise<void>;
411
+ private enqueueMessage;
412
+ /**
413
+ * Steers a queued message into the in-flight turn.
414
+ */
415
+ steer(conversationId: string, messageId: string): Promise<void>;
416
+ /** Starts a chosen waiting message as the next turn, only when the conversation is idle. */
417
+ sendQueued(conversationId: string, messageId: string): Promise<void>;
418
+ /**
419
+ * Waits for the run holding a conversation's slot to release it, by AWAITING ITS COMPLETION rather
420
+ * than polling a flag.
421
+ *
422
+ * Bounded, because a wedged run must not hang the message the user just asked for: after the deadline
423
+ * the caller proceeds to `processWaitingMessage`, whose slot check then refuses in words. With the
424
+ * session path the wait is short by construction - `runtime.stop()` has already awaited Pi going idle,
425
+ * so what is left is the old run's `finally` unwinding, which is local bookkeeping.
426
+ *
427
+ * `onlyWhileStopped` is `sendQueued`'s contract: it waits out the stop-clearing window after a stop,
428
+ * and nothing more. Waiting out an arbitrarily long RUNNING turn would turn "send now" into "send
429
+ * whenever the current answer finishes", which is what the queue is for.
430
+ */
431
+ private awaitRunSlotReleased;
432
+ /**
433
+ * Stops the current turn and immediately gives one waiting message its own fresh turn.
434
+ *
435
+ * `steer` cannot provide this meaning: Pi only reads its steering queue after the current tool batch
436
+ * finishes. Stopping first is what makes a long-running tool give way now.
437
+ *
438
+ * THE HAND-OFF IS AN AWAITED HAND-OFF, not a poll. `stopRun` aborts the turn and - on the session
439
+ * path - `runtime.stop()` has already awaited Pi going idle, so what remains is the old run's own
440
+ * `finally` unwinding. `awaitRunSlotReleased` waits for exactly that event (the run's completion
441
+ * promise), then the selected message opens its turn ON THE SAME SESSION: the pool's fingerprint has
442
+ * not changed, so no process is spawned and no history is replayed.
443
+ */
444
+ interruptQueued(conversationId: string, messageId: string): Promise<void>;
445
+ /**
446
+ * The lower-level "wait for run slot, open the turn on a specific waiting message, run it" sequence.
447
+ *
448
+ * Automatic callers leave the row waiting if another producer owns the conversation.
449
+ * Explicit actions report a conflict if their selected message cannot start.
450
+ *
451
+ * `runConversationTurns` owns opening the first turn. It must be the ONLY opener: opening here and
452
+ * then asking that loop to run the same message used to splice two assistant placeholders under one
453
+ * queued item. The first got no deltas, which rendered as a stray avatar before the real response.
454
+ *
455
+ * `composePrompt` is what makes the `role: "tool"` path real - the `<task>` envelope stays in the
456
+ * transcript, but the prose form of the same fact is what reaches Pi.
457
+ */
458
+ private processWaitingMessage;
459
+ private steerUnsafe;
460
+ /**
461
+ * Steers a newly queued message into the running turn at the next turn boundary.
462
+ * Starts a fresh turn if the active run ends before the conversation lane is entered.
463
+ */
464
+ private steerWaitingMessageOnBusyRun;
465
+ /**
466
+ * Withdraws a waiting message.
467
+ */
468
+ cancelQueued(conversationId: string, messageId: string): Promise<void>;
469
+ private cancelQueuedUnsafe;
470
+ /**
471
+ * Selectively withdraws a specific subset of queued/steered messages by id while preserving
472
+ * all remaining waiting and steered messages.
473
+ */
474
+ cancelQueuedMany(conversationId: string, messageIds: string[], options?: {
475
+ actor?: "user" | "agent";
476
+ }): Promise<{
477
+ withdrawn: {
478
+ id: string;
479
+ content: string;
480
+ role: "user" | "tool";
481
+ }[];
482
+ missingIds: string[];
483
+ }>;
484
+ /**
485
+ * Rewrites a waiting message, in place, where the user can see it change.
486
+ */
487
+ editQueued(conversationId: string, messageId: string, content: string): Promise<void>;
488
+ /**
489
+ * Moves a waiting message within the waiting set.
490
+ */
491
+ reorderQueued(conversationId: string, messageId: string, toIndex: number): Promise<void>;
492
+ /**
493
+ * Dispatches a subagent from client command (human dispatch).
494
+ */
495
+ dispatchSubagent(params: {
496
+ conversationId: string;
497
+ agentId: string;
498
+ task: string;
499
+ }): Promise<void>;
500
+ /**
501
+ * Dispatches a subagent task requested by the task tool HTTP endpoint.
502
+ */
503
+ dispatchTask(body: SubagentDispatchRequestBody): Promise<{
504
+ mode: "sync";
505
+ status: number;
506
+ body: unknown;
507
+ } | {
508
+ mode: "async";
509
+ status: number;
510
+ body: unknown;
511
+ }>;
512
+ /**
513
+ * Validates and executes one orchestrated plan to its end.
514
+ *
515
+ * BLOCKS, unlike `dispatchTask`'s background path, and that asymmetry is the whole design. A background
516
+ * dispatch returns immediately because the model is expected to keep working meanwhile; a plan is the
517
+ * model handing the work over and wanting the chain back, so the request stays open until the last step
518
+ * settles. The cost is a long-held connection - a three-step pipeline is minutes - which is the same
519
+ * cost `task` already carries, and is bounded by the same AbortSignal the extension already forwards,
520
+ * plus the wall-clock cap below.
521
+ *
522
+ * 200 FOR A PLAN THAT RAN, 422 FOR ONE THAT SETTLED AS SOMETHING ELSE - `completed` including deliberate
523
+ * skips, and anything else the terminal status can be. Same rule `dispatchTask` applies to a single run,
524
+ * applied to a whole plan: the transport reports whether the work concluded, and the body says how.
525
+ */
526
+ runWorkflow(body: WorkflowRunRequestBody): Promise<{
527
+ status: number;
528
+ body: unknown;
529
+ }>;
530
+ /**
531
+ * Stops a specific subagent run by runId.
532
+ */
533
+ stopSubagent(runId: string): void;
534
+ /**
535
+ * Stops one orchestrated plan, and says whether there was anything to stop.
536
+ *
537
+ * REACHES THE CHILD, not just the loop: the engine dispatches every step under one controller's signal,
538
+ * so aborting it reaches the child Pi and `killTree`s it exactly as the run recorder's stop does. A stop
539
+ * that only ended the loop would leave the sub-agent still running and still holding the workspace
540
+ * directory, which is the precise gap the run card's own stop button was added to close.
541
+ */
542
+ stopWorkflow(workflowId: string): boolean;
543
+ /**
544
+ * Stops all subagent runs belonging to a conversation.
545
+ */
546
+ stopConversationSubagents(conversationId: string): number;
547
+ }