minimal-agent 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (474) hide show
  1. package/README.md +6 -5
  2. package/package.json +60 -4
  3. package/plugins/computer_use/.claude-plugin/plugin.json +1 -1
  4. package/plugins/cron-runner/src/commands.js +4 -4
  5. package/plugins/cron-runner/src/commands.ts +4 -4
  6. package/plugins/workflow-runner/.claude-plugin/plugin.json +2 -2
  7. package/plugins/workflow-runner/commands/workflow.md +57 -90
  8. package/plugins/workflow-runner/commands/workflows.md +4 -4
  9. package/plugins/workflow-runner/plugin.js +24 -13
  10. package/plugins/workflow-runner/plugin.ts +28 -13
  11. package/plugins/workflow-runner/src/discovery.js +160 -0
  12. package/plugins/workflow-runner/src/discovery.ts +194 -0
  13. package/plugins/workflow-runner/src/goalAnchor.js +53 -0
  14. package/plugins/workflow-runner/src/goalAnchor.ts +59 -0
  15. package/plugins/workflow-runner/src/index.js +197 -206
  16. package/plugins/workflow-runner/src/index.ts +248 -249
  17. package/plugins/workflow-runner/src/inputCoercion.js +40 -0
  18. package/plugins/workflow-runner/src/inputCoercion.ts +43 -0
  19. package/plugins/workflow-runner/src/journal.js +224 -0
  20. package/plugins/workflow-runner/src/journal.ts +274 -0
  21. package/plugins/workflow-runner/src/jsonSchema.js +132 -0
  22. package/plugins/workflow-runner/src/jsonSchema.ts +162 -0
  23. package/plugins/workflow-runner/src/moduleResolution.js +64 -0
  24. package/plugins/workflow-runner/src/moduleResolution.ts +71 -0
  25. package/plugins/workflow-runner/src/resourceInputs.js +220 -0
  26. package/plugins/workflow-runner/src/resourceInputs.ts +300 -0
  27. package/plugins/workflow-runner/src/runner.js +400 -489
  28. package/plugins/workflow-runner/src/runner.ts +488 -560
  29. package/plugins/workflow-runner/src/runtime/config.js +46 -0
  30. package/plugins/workflow-runner/src/runtime/config.ts +69 -0
  31. package/plugins/workflow-runner/src/runtime/context.js +1304 -0
  32. package/plugins/workflow-runner/src/runtime/context.ts +1786 -0
  33. package/plugins/workflow-runner/src/runtime/exec.js +34 -0
  34. package/plugins/workflow-runner/src/runtime/exec.ts +53 -0
  35. package/plugins/workflow-runner/src/runtime/flow.js +8 -0
  36. package/plugins/workflow-runner/src/runtime/flow.ts +12 -0
  37. package/plugins/workflow-runner/src/runtime/fs.js +27 -0
  38. package/plugins/workflow-runner/src/runtime/fs.ts +41 -0
  39. package/plugins/workflow-runner/src/runtime/model.js +6 -0
  40. package/plugins/workflow-runner/src/runtime/model.ts +8 -0
  41. package/plugins/workflow-runner/src/runtime/output.js +7 -0
  42. package/plugins/workflow-runner/src/runtime/output.ts +21 -0
  43. package/plugins/workflow-runner/src/runtime/scheduler.js +141 -0
  44. package/plugins/workflow-runner/src/runtime/scheduler.ts +166 -0
  45. package/plugins/workflow-runner/src/runtime/state.js +16 -0
  46. package/plugins/workflow-runner/src/runtime/state.ts +19 -0
  47. package/plugins/workflow-runner/src/runtime/tools.js +3 -0
  48. package/plugins/workflow-runner/src/runtime/tools.ts +6 -0
  49. package/plugins/workflow-runner/src/sandbox.js +141 -0
  50. package/plugins/workflow-runner/src/sandbox.ts +182 -0
  51. package/plugins/workflow-runner/src/scriptGuard.d.mts +38 -0
  52. package/plugins/workflow-runner/src/scriptGuard.mjs +449 -0
  53. package/plugins/workflow-runner/src/taskIdentity.js +151 -307
  54. package/plugins/workflow-runner/src/taskIdentity.ts +207 -355
  55. package/plugins/workflow-runner/src/toolRuntime.js +29 -8
  56. package/plugins/workflow-runner/src/toolRuntime.ts +36 -11
  57. package/plugins/workflow-runner/src/types.js +7 -211
  58. package/plugins/workflow-runner/src/types.ts +154 -623
  59. package/plugins/workflow-runner/src/util.js +47 -0
  60. package/plugins/workflow-runner/src/util.ts +51 -0
  61. package/plugins/workflow-runner/src/workflowContext.js +20 -0
  62. package/plugins/workflow-runner/src/workflowContext.ts +58 -0
  63. package/plugins/workflow-runner/src/workflowDependencies.js +36 -0
  64. package/plugins/workflow-runner/src/workflowDependencies.ts +59 -0
  65. package/plugins/workflow-runner/src/workflowFingerprint.js +118 -0
  66. package/plugins/workflow-runner/src/workflowFingerprint.ts +122 -0
  67. package/plugins/workflow-runner/src/workflowState.js +474 -802
  68. package/plugins/workflow-runner/src/workflowState.ts +575 -970
  69. package/plugins/workflow-runner/test/api.test.ts +223 -0
  70. package/plugins/workflow-runner/test/apiCapabilities.test.ts +614 -0
  71. package/plugins/workflow-runner/test/apiConcurrencyGate.test.ts +104 -0
  72. package/plugins/workflow-runner/test/apiEcho.test.ts +210 -0
  73. package/plugins/workflow-runner/test/apiReadText.test.ts +178 -0
  74. package/plugins/workflow-runner/test/apiResourceLedger.test.ts +184 -0
  75. package/plugins/workflow-runner/test/childWorkflow.test.ts +304 -0
  76. package/plugins/workflow-runner/test/discovery.test.ts +234 -0
  77. package/plugins/workflow-runner/test/goalAnchor.test.ts +106 -0
  78. package/plugins/workflow-runner/test/goalController.test.ts +317 -0
  79. package/plugins/workflow-runner/test/journalLanes.test.ts +198 -0
  80. package/plugins/workflow-runner/test/listResources.test.ts +106 -0
  81. package/plugins/workflow-runner/test/resourceInputs.test.ts +294 -0
  82. package/plugins/workflow-runner/test/sandbox.test.ts +126 -0
  83. package/plugins/workflow-runner/test/scheduler.test.ts +70 -0
  84. package/plugins/workflow-runner/test/scriptGuard.test.ts +276 -0
  85. package/plugins/workflow-runner/test/skillDocSync.test.ts +78 -0
  86. package/plugins/workflow-runner/test/taskIdentity.test.ts +288 -179
  87. package/plugins/workflow-runner/test/workflowFingerprint.test.ts +106 -0
  88. package/plugins/workflow-runner/test/workflowState.test.ts +429 -0
  89. package/skills/pptx/examples/assets/cover-bg.svg +23 -0
  90. package/skills/pptx/examples/assets/icon-spark.svg +5 -0
  91. package/skills/ui-design/SKILL.md +5 -2
  92. package/skills/ui-design/references/layout-composition.md +1 -1
  93. package/skills/workflow-creator/SKILL.md +344 -0
  94. package/skills/workflow-creator/assets/template/workflow.mjs +48 -0
  95. package/skills/workflow-creator/references/api.md +216 -0
  96. package/skills/workflow-creator/references/migration.md +103 -0
  97. package/skills/workflow-creator/references/patterns.md +779 -0
  98. package/skills/workflow-creator/scripts/list-resources.mjs +205 -0
  99. package/skills/workflow-creator/scripts/scaffold.mjs +148 -0
  100. package/skills/workflow-creator/scripts/validate.mjs +275 -0
  101. package/skills/workflow-creator/scripts/workflow-creator.test.mjs +82 -0
  102. package/src/advisor/advisorCoordinator.js +536 -0
  103. package/src/advisor/advisorCoordinator.ts +693 -0
  104. package/src/cli/configMenu.tsx +0 -1
  105. package/src/cli/print.js +27 -6
  106. package/src/cli/print.ts +48 -4
  107. package/src/cli/quickModelSetup.js +12 -1
  108. package/src/cli/quickModelSetup.tsx +15 -3
  109. package/src/cli/streamJson.js +5 -6
  110. package/src/cli/streamJson.ts +8 -4
  111. package/src/cli/wizards/advisorWizard.js +4 -2
  112. package/src/cli/wizards/advisorWizard.tsx +8 -2
  113. package/src/cli/wizards/contextAdvisorWizard.js +5 -4
  114. package/src/cli/wizards/contextAdvisorWizard.tsx +7 -6
  115. package/src/cli/wizards/providerPresets.js +18 -8
  116. package/src/cli/wizards/providerPresets.ts +18 -8
  117. package/src/collaboration/taskFlow.js +115 -0
  118. package/src/collaboration/taskFlow.ts +169 -0
  119. package/src/config/configDefaults.js +41 -1
  120. package/src/config/configDefaults.ts +43 -1
  121. package/src/config/configDiagnostics.ts +2 -2
  122. package/src/config/configFile.js +40 -9
  123. package/src/config/configFile.ts +60 -11
  124. package/src/config/configService.js +419 -74
  125. package/src/config/configService.ts +703 -145
  126. package/src/config/numericLimits.js +22 -0
  127. package/src/config/numericLimits.ts +24 -0
  128. package/src/config.js +1 -0
  129. package/src/config.ts +3 -2
  130. package/src/context/budgetPlan.js +1 -1
  131. package/src/context/budgetPlan.ts +1 -1
  132. package/src/context/compact.js +7 -2
  133. package/src/context/compact.ts +9 -2
  134. package/src/context/microCompactLite.js +212 -13
  135. package/src/context/microCompactLite.ts +261 -12
  136. package/src/context/sessionRegistry.js +8 -1
  137. package/src/context/sessionRegistry.ts +18 -5
  138. package/src/context/toolResultArchive.js +72 -0
  139. package/src/context/toolResultArchive.ts +95 -0
  140. package/src/goal/errors.js +8 -0
  141. package/src/goal/errors.ts +18 -0
  142. package/src/goal/goalRuntime.js +344 -0
  143. package/src/goal/goalRuntime.ts +466 -0
  144. package/src/goal/goalStore.js +200 -0
  145. package/src/goal/goalStore.ts +219 -0
  146. package/src/goal/index.js +4 -0
  147. package/src/goal/index.ts +4 -0
  148. package/src/goal/statusMapping.js +71 -0
  149. package/src/goal/statusMapping.ts +95 -0
  150. package/src/goal/types.js +7 -0
  151. package/src/goal/types.ts +179 -0
  152. package/src/goal/workflowController.js +306 -0
  153. package/src/goal/workflowController.ts +360 -0
  154. package/src/harness/evidenceLedger.js +2 -0
  155. package/src/harness/evidenceLedger.ts +1 -0
  156. package/src/harness/stallGuard.js +9 -3
  157. package/src/harness/stallGuard.ts +7 -3
  158. package/src/images/imageResolver.js +161 -0
  159. package/src/images/imageResolver.ts +189 -0
  160. package/src/infra/verification.js +34 -5
  161. package/src/infra/verification.ts +39 -4
  162. package/src/llm/client.js +79 -21
  163. package/src/llm/client.ts +182 -35
  164. package/src/llm/gatewayClient.js +201 -0
  165. package/src/llm/gatewayClient.ts +299 -0
  166. package/src/llm/messageProvenance.js +46 -0
  167. package/src/llm/messageProvenance.ts +58 -0
  168. package/src/llm/modelProvider.js +1 -0
  169. package/src/llm/modelProvider.ts +22 -0
  170. package/src/llm/providers/anthropicFormat.js +108 -1
  171. package/src/llm/providers/anthropicFormat.ts +115 -4
  172. package/src/llm/providers/openaiFormat.js +9 -0
  173. package/src/llm/providers/openaiFormat.ts +12 -3
  174. package/src/loop.js +328 -55
  175. package/src/loop.ts +382 -58
  176. package/src/main.js +4 -1
  177. package/src/main.tsx +4 -1
  178. package/src/managedExecution/index.js +2 -0
  179. package/src/managedExecution/index.ts +2 -0
  180. package/src/managedExecution/registry.js +15 -0
  181. package/src/managedExecution/registry.ts +20 -0
  182. package/src/managedExecution/types.js +1 -0
  183. package/src/managedExecution/types.ts +86 -0
  184. package/src/modelRef.js +9 -0
  185. package/src/modelRef.ts +31 -0
  186. package/src/multimodal.js +14 -28
  187. package/src/multimodal.ts +17 -33
  188. package/src/net/lanDiscovery.js +65 -0
  189. package/src/net/lanDiscovery.ts +82 -0
  190. package/src/plugin-sdk.js +28 -3
  191. package/src/plugin-sdk.ts +39 -6
  192. package/src/plugins/pluginApi.ts +16 -1
  193. package/src/plugins/pluginLoader.js +4 -0
  194. package/src/plugins/pluginLoader.ts +6 -0
  195. package/src/plugins/pluginRunner.js +139 -7
  196. package/src/plugins/pluginRunner.ts +173 -9
  197. package/src/plugins/slashFallback.js +113 -0
  198. package/src/plugins/slashFallback.ts +137 -0
  199. package/src/prompts/policyRegistry.js +12 -32
  200. package/src/prompts/policyRegistry.ts +15 -32
  201. package/src/prompts/promptAssembly.js +103 -12
  202. package/src/prompts/promptAssembly.ts +114 -12
  203. package/src/prompts/skillList.js +21 -3
  204. package/src/prompts/skillList.ts +27 -2
  205. package/src/prompts/stableSystemPrompt.js +18 -0
  206. package/src/prompts/stableSystemPrompt.ts +33 -0
  207. package/src/runtime/agentRuntimeContext.js +8 -2
  208. package/src/runtime/agentRuntimeContext.ts +17 -4
  209. package/src/session/runAgentTurn.js +78 -12
  210. package/src/session/runAgentTurn.ts +105 -23
  211. package/src/session/runTurn.js +10 -9
  212. package/src/session/runTurn.ts +17 -8
  213. package/src/session/sessionState.ts +2 -0
  214. package/src/team/auth.js +186 -0
  215. package/src/team/auth.ts +298 -0
  216. package/src/team/cli.js +105 -0
  217. package/src/team/cli.ts +122 -0
  218. package/src/team/onlineToolContract.js +64 -0
  219. package/src/team/onlineToolContract.ts +109 -0
  220. package/src/team/toolPolicy.js +36 -0
  221. package/src/team/toolPolicy.ts +75 -0
  222. package/src/tools/advisor/advisor.js +115 -50
  223. package/src/tools/advisor/advisor.ts +124 -51
  224. package/src/tools/advisor/advisorDecision.js +71 -0
  225. package/src/tools/advisor/advisorDecision.ts +85 -0
  226. package/src/tools/agent/agent.js +18 -5
  227. package/src/tools/agent/agent.ts +21 -7
  228. package/src/tools/agent/agentControl.js +246 -0
  229. package/src/tools/agent/agentControl.ts +284 -0
  230. package/src/tools/agent/agentTaskService.js +40 -1
  231. package/src/tools/agent/agentTaskService.ts +44 -1
  232. package/src/tools/agent/agentTypes.js +14 -2
  233. package/src/tools/agent/agentTypes.ts +15 -2
  234. package/src/tools/applypatch/applyPatch.js +362 -0
  235. package/src/tools/applypatch/applyPatch.ts +428 -0
  236. package/src/tools/bash/bash.js +22 -15
  237. package/src/tools/bash/bash.ts +23 -17
  238. package/src/tools/capabilities.js +10 -5
  239. package/src/tools/capabilities.ts +10 -5
  240. package/src/tools/computeruse/computerIntent.js +32 -0
  241. package/src/tools/computeruse/computerIntent.ts +46 -0
  242. package/src/tools/computeruse/telemetryLog.js +12 -0
  243. package/src/tools/computeruse/telemetryLog.ts +16 -0
  244. package/src/tools/computeruse/vision/telemetry.js +1 -0
  245. package/src/tools/computeruse/vision/telemetry.ts +1 -0
  246. package/src/tools/effectiveToolSet.js +4 -0
  247. package/src/tools/effectiveToolSet.ts +4 -0
  248. package/src/tools/index.js +21 -2
  249. package/src/tools/index.ts +33 -2
  250. package/src/tools/presentresult/presentresult.js +6 -15
  251. package/src/tools/presentresult/presentresult.ts +6 -15
  252. package/src/tools/read/read.js +62 -9
  253. package/src/tools/read/read.ts +63 -9
  254. package/src/tools/shared/fileUtils.js +1 -2
  255. package/src/tools/shared/fileUtils.ts +1 -2
  256. package/src/tools/shared/toolOutputStore.js +23 -1
  257. package/src/tools/shared/toolOutputStore.ts +22 -1
  258. package/src/tools/skill/skill.js +9 -3
  259. package/src/tools/skill/skill.ts +8 -4
  260. package/src/tools/toolPromptGuides.js +125 -0
  261. package/src/tools/toolPromptGuides.ts +146 -0
  262. package/src/tools/webbrowser/agentBrowserPath.js +19 -9
  263. package/src/tools/webbrowser/agentBrowserPath.ts +70 -28
  264. package/src/tools/webbrowser/browser.js +27 -11
  265. package/src/tools/webbrowser/browser.ts +68 -24
  266. package/src/tools/webbrowser/browserAutomation.js +329 -0
  267. package/src/tools/webbrowser/browserAutomation.ts +467 -0
  268. package/src/tools/webbrowser/browserAxState.js +97 -0
  269. package/src/tools/webbrowser/browserAxState.ts +142 -0
  270. package/src/tools/webbrowser/browserBatch.js +1578 -0
  271. package/src/tools/webbrowser/browserBatch.ts +2382 -0
  272. package/src/tools/webbrowser/browserCdp.js +208 -0
  273. package/src/tools/webbrowser/browserCdp.ts +255 -0
  274. package/src/tools/webbrowser/browserConditions.js +24 -0
  275. package/src/tools/webbrowser/browserConditions.ts +45 -0
  276. package/src/tools/webbrowser/browserContent.js +281 -0
  277. package/src/tools/webbrowser/browserContent.ts +438 -0
  278. package/src/tools/webbrowser/browserControl.js +131 -34
  279. package/src/tools/webbrowser/browserControl.ts +210 -56
  280. package/src/tools/webbrowser/browserDaemon.js +22 -14
  281. package/src/tools/webbrowser/browserDaemon.ts +54 -21
  282. package/src/tools/webbrowser/browserFrames.js +47 -0
  283. package/src/tools/webbrowser/browserFrames.ts +54 -0
  284. package/src/tools/webbrowser/browserInteractionResolver.js +17 -0
  285. package/src/tools/webbrowser/browserInteractionResolver.ts +40 -0
  286. package/src/tools/webbrowser/browserLocator.js +140 -0
  287. package/src/tools/webbrowser/browserLocator.ts +194 -0
  288. package/src/tools/webbrowser/browserOutcome.js +10 -17
  289. package/src/tools/webbrowser/browserOutcome.ts +48 -31
  290. package/src/tools/webbrowser/browserRecovery.js +58 -0
  291. package/src/tools/webbrowser/browserRecovery.ts +83 -0
  292. package/src/tools/webbrowser/browserRunRegistry.js +35 -3
  293. package/src/tools/webbrowser/browserRunRegistry.ts +91 -15
  294. package/src/tools/webbrowser/browserService.js +28 -2
  295. package/src/tools/webbrowser/browserService.ts +49 -9
  296. package/src/tools/webbrowser/browserStream.js +132 -33
  297. package/src/tools/webbrowser/browserStream.ts +224 -50
  298. package/src/tools/webbrowser/browserTabs.js +48 -15
  299. package/src/tools/webbrowser/browserTabs.ts +178 -96
  300. package/src/tools/webbrowser/webbrowser.js +679 -144
  301. package/src/tools/webbrowser/webbrowser.ts +975 -236
  302. package/src/tools/webfetch/preapproved.js +0 -2
  303. package/src/tools/webfetch/preapproved.ts +0 -2
  304. package/src/tools/websearch/websearch.js +129 -8
  305. package/src/tools/websearch/websearch.ts +138 -6
  306. package/src/types.ts +459 -40
  307. package/src/ui/App.js +377 -58
  308. package/src/ui/App.tsx +576 -111
  309. package/src/ui/LiveArea.js +14 -8
  310. package/src/ui/LiveArea.tsx +14 -10
  311. package/src/ui/MessageList.js +63 -20
  312. package/src/ui/MessageList.tsx +101 -16
  313. package/src/ui/ModelPicker.js +7 -4
  314. package/src/ui/ModelPicker.tsx +55 -8
  315. package/src/ui/hooks/useChat.js +152 -163
  316. package/src/ui/hooks/useChat.ts +396 -334
  317. package/src/ui/loginCommand.js +56 -0
  318. package/src/ui/loginCommand.ts +63 -0
  319. package/src/ui/toolProgress.js +41 -0
  320. package/src/ui/toolProgress.ts +44 -0
  321. package/src/web/browserBridge.js +20 -2
  322. package/src/web/browserBridge.ts +20 -2
  323. package/src/web/protocol.ts +1897 -194
  324. package/workflows/adaptive-research/workflow.mjs +86 -0
  325. package/workflows/e2e-capabilities/workflow.mjs +102 -0
  326. package/workflows/e2e-llm/workflow.mjs +52 -0
  327. package/workflows/e2e-smoke/workflow.mjs +59 -0
  328. package/workflows/e2e-vision-schema/README.md +48 -0
  329. package/workflows/e2e-vision-schema/workflow.mjs +149 -0
  330. package/workflows/e2e-write-greet/workflow.mjs +37 -0
  331. package/workflows/file-census/README.md +14 -0
  332. package/workflows/file-census/scripts/.gitkeep +2 -0
  333. package/workflows/file-census/workflow.mjs +110 -0
  334. package/workflows/goal/README.md +166 -0
  335. package/workflows/goal/prompts/audit.md +57 -0
  336. package/workflows/goal/prompts/contract.md +56 -0
  337. package/workflows/goal/prompts/iterate.md +37 -0
  338. package/workflows/goal/workflow.mjs +501 -0
  339. package/workflows/illustrate/README.md +90 -0
  340. package/workflows/illustrate/assets/engines.json +20 -0
  341. package/workflows/illustrate/assets/extract-baidu.js +21 -0
  342. package/workflows/illustrate/assets/extract-bing.js +33 -0
  343. package/workflows/illustrate/assets/extract-google.js +31 -0
  344. package/workflows/illustrate/workflow.mjs +301 -0
  345. package/workflows/plan/workflow.mjs +389 -0
  346. package/workflows/question-crops/README.md +35 -0
  347. package/workflows/question-crops/prompts/inventory.md +23 -0
  348. package/workflows/question-crops/scripts/image-ops.mjs +305 -0
  349. package/workflows/question-crops/scripts/image-ops.test.mjs +95 -0
  350. package/workflows/question-crops/workflow.mjs +172 -0
  351. package/workflows/ralph-loop/workflow.mjs +162 -0
  352. package/workflows/research/README.md +74 -0
  353. package/workflows/research/prompts/s0-goal.md +43 -0
  354. package/workflows/research/prompts/s1-early-exit.md +22 -0
  355. package/workflows/research/prompts/s1-map.md +58 -0
  356. package/workflows/research/prompts/s2-options.md +53 -0
  357. package/workflows/research/prompts/s3-deep-dive.md +56 -0
  358. package/workflows/research/prompts/s4-verify.md +74 -0
  359. package/workflows/research/prompts/s5-synthesis.md +81 -0
  360. package/workflows/research/prompts/s5b-fill-gaps.md +32 -0
  361. package/workflows/research/prompts/s6-package.md +32 -0
  362. package/workflows/research/scripts/build-report.mjs +98 -0
  363. package/workflows/research/workflow.mjs +288 -0
  364. package/workflows/wechat-reading-shots/prompts/collect-params.md +16 -0
  365. package/workflows/wechat-reading-shots/prompts/evaluate.md +20 -0
  366. package/workflows/wechat-reading-shots/prompts/open-book.md +28 -0
  367. package/workflows/wechat-reading-shots/prompts/read-page.md +13 -0
  368. package/workflows/wechat-reading-shots/prompts/turn-batch.md +24 -0
  369. package/workflows/wechat-reading-shots/test/control-flow.test.ts +329 -0
  370. package/workflows/wechat-reading-shots/workflow.mjs +266 -0
  371. package/workflows/wrong-question-docx/README.md +55 -0
  372. package/workflows/wrong-question-docx/prompts/figure-qa.md +8 -0
  373. package/workflows/wrong-question-docx/prompts/transcribe.md +25 -0
  374. package/workflows/wrong-question-docx/scripts/workbook.mjs +857 -0
  375. package/workflows/wrong-question-docx/test/control-flow.test.ts +165 -0
  376. package/workflows/wrong-question-docx/test/workbook.test.mjs +303 -0
  377. package/workflows/wrong-question-docx/workflow.mjs +485 -0
  378. package/plugins/workflow-runner/src/agentCommon.js +0 -354
  379. package/plugins/workflow-runner/src/agentCommon.ts +0 -435
  380. package/plugins/workflow-runner/src/controlFlow/branch.js +0 -40
  381. package/plugins/workflow-runner/src/controlFlow/branch.ts +0 -46
  382. package/plugins/workflow-runner/src/controlFlow/loop.js +0 -211
  383. package/plugins/workflow-runner/src/controlFlow/loop.ts +0 -248
  384. package/plugins/workflow-runner/src/controlFlow/pause.js +0 -129
  385. package/plugins/workflow-runner/src/controlFlow/pause.ts +0 -141
  386. package/plugins/workflow-runner/src/controlFlow/signal.js +0 -21
  387. package/plugins/workflow-runner/src/controlFlow/signal.ts +0 -29
  388. package/plugins/workflow-runner/src/controlFlow/types.js +0 -18
  389. package/plugins/workflow-runner/src/controlFlow/types.ts +0 -63
  390. package/plugins/workflow-runner/src/dslManifest.js +0 -72
  391. package/plugins/workflow-runner/src/dslManifest.ts +0 -127
  392. package/plugins/workflow-runner/src/expressions.js +0 -639
  393. package/plugins/workflow-runner/src/expressions.ts +0 -640
  394. package/plugins/workflow-runner/src/loader.js +0 -573
  395. package/plugins/workflow-runner/src/loader.ts +0 -721
  396. package/plugins/workflow-runner/src/multimodal.js +0 -38
  397. package/plugins/workflow-runner/src/multimodal.ts +0 -64
  398. package/plugins/workflow-runner/src/recovery.js +0 -126
  399. package/plugins/workflow-runner/src/recovery.ts +0 -156
  400. package/plugins/workflow-runner/src/stepExecutors/agent.js +0 -173
  401. package/plugins/workflow-runner/src/stepExecutors/agent.ts +0 -234
  402. package/plugins/workflow-runner/src/stepExecutors/assert.js +0 -42
  403. package/plugins/workflow-runner/src/stepExecutors/assert.ts +0 -52
  404. package/plugins/workflow-runner/src/stepExecutors/echo.js +0 -31
  405. package/plugins/workflow-runner/src/stepExecutors/echo.ts +0 -38
  406. package/plugins/workflow-runner/src/stepExecutors/llm.js +0 -99
  407. package/plugins/workflow-runner/src/stepExecutors/llm.ts +0 -133
  408. package/plugins/workflow-runner/src/stepExecutors/set.js +0 -49
  409. package/plugins/workflow-runner/src/stepExecutors/set.ts +0 -56
  410. package/plugins/workflow-runner/src/stepExecutors/skill.js +0 -111
  411. package/plugins/workflow-runner/src/stepExecutors/skill.ts +0 -140
  412. package/plugins/workflow-runner/src/stepExecutors/tool.js +0 -227
  413. package/plugins/workflow-runner/src/stepExecutors/tool.ts +0 -274
  414. package/plugins/workflow-runner/src/stepExecutors/verify.js +0 -61
  415. package/plugins/workflow-runner/src/stepExecutors/verify.ts +0 -72
  416. package/plugins/workflow-runner/src/stepPipeline.js +0 -277
  417. package/plugins/workflow-runner/src/stepPipeline.ts +0 -366
  418. package/plugins/workflow-runner/test/agent.test.ts +0 -587
  419. package/plugins/workflow-runner/test/agentLlmError.test.ts +0 -373
  420. package/plugins/workflow-runner/test/bashBlacklist.sweep.test.ts +0 -65
  421. package/plugins/workflow-runner/test/captureMisbind.test.ts +0 -99
  422. package/plugins/workflow-runner/test/cli.e2e.test.ts +0 -167
  423. package/plugins/workflow-runner/test/context-files.test.ts +0 -320
  424. package/plugins/workflow-runner/test/e2e.test.ts +0 -370
  425. package/plugins/workflow-runner/test/e2eNewLayout.test.ts +0 -314
  426. package/plugins/workflow-runner/test/engineRobustness.test.ts +0 -234
  427. package/plugins/workflow-runner/test/expressions.test.ts +0 -439
  428. package/plugins/workflow-runner/test/foundation.test.ts +0 -126
  429. package/plugins/workflow-runner/test/graceful.test.ts +0 -139
  430. package/plugins/workflow-runner/test/greedyInputs.load.test.ts +0 -47
  431. package/plugins/workflow-runner/test/hostCapability.test.ts +0 -108
  432. package/plugins/workflow-runner/test/illustrate.load.test.ts +0 -183
  433. package/plugins/workflow-runner/test/jsonPayload.test.ts +0 -83
  434. package/plugins/workflow-runner/test/loader.test.ts +0 -617
  435. package/plugins/workflow-runner/test/maxTurnsRetryDelay.test.ts +0 -33
  436. package/plugins/workflow-runner/test/multimodal.test.ts +0 -342
  437. package/plugins/workflow-runner/test/output-schema.test.ts +0 -213
  438. package/plugins/workflow-runner/test/parseWorkflowArgs.test.ts +0 -106
  439. package/plugins/workflow-runner/test/pluginRunner.isolation.test.ts +0 -269
  440. package/plugins/workflow-runner/test/ppt.load.test.ts +0 -1220
  441. package/plugins/workflow-runner/test/ralphLoop.e2e.test.ts +0 -221
  442. package/plugins/workflow-runner/test/recovery.test.ts +0 -265
  443. package/plugins/workflow-runner/test/research.load.test.ts +0 -328
  444. package/plugins/workflow-runner/test/runner.test.ts +0 -911
  445. package/plugins/workflow-runner/test/runnerPreflight.test.ts +0 -436
  446. package/plugins/workflow-runner/test/skillTurnDone.test.ts +0 -71
  447. package/plugins/workflow-runner/test/stateLifecycle.test.ts +0 -198
  448. package/plugins/workflow-runner/test/stepPipeline.test.ts +0 -114
  449. package/plugins/workflow-runner/test/taskArbitration.test.ts +0 -354
  450. package/plugins/workflow-runner/test/taskLifecycle.test.ts +0 -324
  451. package/plugins/workflow-runner/test/toolArtifactOverwrite.test.ts +0 -221
  452. package/plugins/workflow-runner/test/toolCapabilityBoundary.test.ts +0 -29
  453. package/plugins/workflow-runner/test/toolRuntimeIntegration.test.ts +0 -168
  454. package/plugins/workflow-runner/test/webppt.load.test.ts +0 -250
  455. package/plugins/workflow-runner/test/word.load.test.ts +0 -208
  456. package/plugins/workflow-runner/test/workflows.smoke.test.ts +0 -76
  457. package/plugins/workflow-runner/test/yamlGuardConditions.test.ts +0 -207
  458. package/src/advisorState.js +0 -22
  459. package/src/cli/configWizard.js +0 -293
  460. package/src/tools/toolProgressBridge.js +0 -48
  461. package/workflows/adaptive-research.yaml +0 -50
  462. package/workflows/book-review-short.yaml +0 -125
  463. package/workflows/e2e-write-greet.yaml +0 -31
  464. package/workflows/illustrate.yaml +0 -227
  465. package/workflows/plan.yaml +0 -470
  466. package/workflows/ppt.yaml +0 -1670
  467. package/workflows/ralph-loop.yaml +0 -201
  468. package/workflows/research.yaml +0 -873
  469. package/workflows/schema.json +0 -176
  470. package/workflows/webppt.yaml +0 -496
  471. package/workflows/wechat-reading-shots.yaml +0 -315
  472. package/workflows/word.yaml +0 -720
  473. package/workflows/youtube-shorts.yaml +0 -202
  474. /package/workflows/{research.md → research/DESIGN.md} +0 -0
@@ -17,11 +17,46 @@
17
17
  * ============================================================
18
18
  */
19
19
 
20
- import type { AskAnswer, AskOption, AskQuestionSpec, AskSource } from '../askBridge.js';
21
- import type { PluginEvent } from '../plugins/pluginApi.js';
22
- import type { AgentResultMetadata, ConversationFilePurpose, DeliverableManifest, FileActivityMetadata, LoopEvent, Message, MessageAttachmentRef, MessageBrowserReference, ProgressStage, SubagentProgress, ToolCall, ToolProgressDetail, ToolResultMetadata } from '../types.js';
23
- import type { ConversationSearchResult, MemoryCategory, MemoryDiagnostic, MemoryEditablePatch, MemoryRecord, MemorySettings, MemoryUpdate, PersonaDocument } from '../memory/memoryService.js';
20
+ import type {
21
+ AskAnswer,
22
+ AskOption,
23
+ AskQuestionSpec,
24
+ AskSource,
25
+ } from '../askBridge.js';
24
26
  import type { HumanInterventionReason } from '../humanIntervention.js';
27
+ import type { ModelFallbackReason, ModelRef } from '../modelRef.js';
28
+ import type { OnlineModelAvailability } from '../team/onlineToolContract.js';
29
+ export type {
30
+ ModelFallbackReason,
31
+ ModelRef,
32
+ SessionModelPreference,
33
+ } from '../modelRef.js';
34
+ import type {
35
+ ConversationSearchResult,
36
+ MemoryCategory,
37
+ MemoryDiagnostic,
38
+ MemoryEditablePatch,
39
+ MemoryRecord,
40
+ MemorySettings,
41
+ MemoryUpdate,
42
+ PersonaDocument,
43
+ } from '../memory/memoryService.js';
44
+ import type { PluginEvent } from '../plugins/pluginApi.js';
45
+ import type {
46
+ AgentResultMetadata,
47
+ ConversationFilePurpose,
48
+ DeliverableManifest,
49
+ FileActivityMetadata,
50
+ LoopEvent,
51
+ Message,
52
+ MessageAttachmentRef,
53
+ MessageBrowserReference,
54
+ ProgressStage,
55
+ SubagentProgress,
56
+ ToolCall,
57
+ ToolProgressDetail,
58
+ ToolResultMetadata,
59
+ } from '../types.js';
25
60
 
26
61
  /**
27
62
  * 桌面控制的**线路观测形状**(协议自持,不 import 具体工具)。
@@ -60,7 +95,13 @@ export interface ComputerObservation {
60
95
  */
61
96
  export type BrowserControlState =
62
97
  | { owner: 'none'; status: 'idle' }
63
- | { owner: 'agent'; status: 'running'; runId: string; conversationKey?: string; action?: string }
98
+ | {
99
+ owner: 'agent';
100
+ status: 'running';
101
+ runId: string;
102
+ conversationKey?: string;
103
+ action?: string;
104
+ }
64
105
  | {
65
106
  owner: 'user';
66
107
  status: 'waiting_human';
@@ -71,7 +112,12 @@ export type BrowserControlState =
71
112
  resumeToken: string;
72
113
  ownerId: string;
73
114
  }
74
- | { owner: 'user'; status: 'interactive'; runId?: string; conversationKey?: string };
115
+ | {
116
+ owner: 'user';
117
+ status: 'interactive';
118
+ runId?: string;
119
+ conversationKey?: string;
120
+ };
75
121
 
76
122
  export type {
77
123
  ConversationFilePurpose,
@@ -90,12 +136,12 @@ export type {
90
136
  PersonaDocument,
91
137
  } from '../memory/memoryService.js';
92
138
  import type {
139
+ CronListFilter,
93
140
  CronMissedRecord,
94
141
  CronRunRecord,
95
142
  CronTask,
96
143
  CronTaskDraft,
97
144
  CronTaskPatch,
98
- CronListFilter,
99
145
  } from '../../plugins/cron-runner/src/types.js';
100
146
 
101
147
  export type AgentEvent = LoopEvent | PluginEvent;
@@ -253,10 +299,19 @@ export type ApiFormat = 'openai' | 'anthropic';
253
299
  /** 模型列表的一个条目(脱敏视图——apiKey 只给 configured 布尔位,不下发原文)。 */
254
300
  export interface ModelView {
255
301
  id: string;
302
+ /** 展示来源;本机模型省略此字段以兼容旧 Runtime。 */
303
+ source?: 'local' | 'gateway';
304
+ /** Server catalog only; local model lists leave this unset. */
305
+ isDefault?: boolean;
306
+ maxToolCategories?: string[];
307
+ defaultToolCategories?: string[];
308
+ capabilities?: { vision: boolean; tools: boolean; structuredOutput: boolean };
309
+ availability?: OnlineModelAvailability;
256
310
  apiFormat: ApiFormat;
257
311
  displayName?: string;
258
- baseURL: string;
259
- apiKeyConfigured: boolean;
312
+ /** Only local model views include provider endpoint metadata. */
313
+ baseURL?: string;
314
+ apiKeyConfigured?: boolean;
260
315
  model: string;
261
316
  contextWindow: number;
262
317
  maxTokens?: number;
@@ -392,7 +447,12 @@ export interface ToolConfigView {
392
447
  message?: string;
393
448
  }
394
449
 
395
- export type ToolConfigName = 'advisor' | 'webSearch' | 'imageGeneration' | 'openRouter' | 'textToSpeech';
450
+ export type ToolConfigName =
451
+ | 'advisor'
452
+ | 'webSearch'
453
+ | 'imageGeneration'
454
+ | 'openRouter'
455
+ | 'textToSpeech';
396
456
  /** 'provider' 分区已删除——models/baseModelId/advisor 都走立即生效的 config/update,不再自动保存。 */
397
457
  export type ConfigAutosaveSection = 'general' | 'tools' | 'browser';
398
458
 
@@ -406,7 +466,15 @@ export interface ArchiveEntry {
406
466
  export interface DirEntry {
407
467
  name: string;
408
468
  path: string;
409
- kind?: 'home' | 'desktop' | 'documents' | 'downloads' | 'cloud' | 'volume' | 'network' | 'root';
469
+ kind?:
470
+ | 'home'
471
+ | 'desktop'
472
+ | 'documents'
473
+ | 'downloads'
474
+ | 'cloud'
475
+ | 'volume'
476
+ | 'network'
477
+ | 'root';
410
478
  }
411
479
 
412
480
  export interface DirListing {
@@ -447,6 +515,11 @@ export interface SessionSummary {
447
515
  updatedAt: number;
448
516
  lastMessagePreview?: string;
449
517
  modelId?: string;
518
+ preferredModel?: ModelRef;
519
+ effectiveModel?: ModelRef;
520
+ fallbackReason?: ModelFallbackReason;
521
+ restoreWhenAvailable?: boolean;
522
+ onlineToolCategories?: string[];
450
523
  }
451
524
 
452
525
  export type ConversationTarget =
@@ -614,9 +687,13 @@ export interface UserProfile {
614
687
  /** 旧版账号兼容显示;新账号不再依赖 username 作为身份。 */
615
688
  username?: string;
616
689
  displayName: string;
690
+ /** Small user avatar stored as a validated image data URL. */
691
+ avatarData?: string;
617
692
  createdAt: number;
618
693
  /** 站长(首个注册用户):可操作服务器本地工作目录/配置/cron;普通用户经 Agent Node 挂自己的 agent。 */
619
694
  isAdmin?: boolean;
695
+ /** 初始引导密码或管理员重置密码后,必须先完成改密。 */
696
+ passwordChangeRequired?: boolean;
620
697
  }
621
698
 
622
699
  export interface FriendEntry {
@@ -684,7 +761,6 @@ export interface WorkspaceSessionAgent {
684
761
  ownerUserId: string;
685
762
  displayName: string;
686
763
  status: 'online' | 'offline' | 'busy';
687
- boundGroupId?: string;
688
764
  lastActiveAt?: number;
689
765
  }
690
766
 
@@ -752,9 +828,24 @@ export type ProjectStatus = 'active' | 'archived';
752
828
  export type ProjectProvider = 'github' | 'gitlab' | 'local-git';
753
829
  export type ParticipantKind = 'human' | 'agent';
754
830
  export type RoleScope = 'project' | 'task';
755
- export type WorkItemStatus = 'backlog' | 'ready' | 'in_progress' | 'review' | 'blocked' | 'done';
831
+ /**
832
+ * 任务卡状态。`proposed`=方案待审,是"人只对方案负责"的强制停顿点;
833
+ * `review`=待验收。流转规则与拍板权限的唯一真值在 `minimal-agent/task-flow`。
834
+ */
835
+ export type WorkItemStatus =
836
+ | 'backlog'
837
+ | 'ready'
838
+ | 'proposed'
839
+ | 'in_progress'
840
+ | 'review'
841
+ | 'blocked'
842
+ | 'done';
756
843
  export type CollaborationMode = 'parallel' | 'alternative' | 'pair' | 'review';
757
- export type HandoffStatus = 'offered' | 'accepted' | 'changes_requested' | 'completed';
844
+ export type HandoffStatus =
845
+ | 'offered'
846
+ | 'accepted'
847
+ | 'changes_requested'
848
+ | 'completed';
758
849
 
759
850
  export interface ProjectRepository {
760
851
  id: string;
@@ -921,7 +1012,15 @@ export interface ProjectArtifact {
921
1012
  id: string;
922
1013
  projectId: string;
923
1014
  workItemId?: string;
924
- kind: 'diff' | 'commit' | 'pull_request' | 'test_report' | 'document' | 'design' | 'database_script' | 'file';
1015
+ kind:
1016
+ | 'diff'
1017
+ | 'commit'
1018
+ | 'pull_request'
1019
+ | 'test_report'
1020
+ | 'document'
1021
+ | 'design'
1022
+ | 'database_script'
1023
+ | 'file';
925
1024
  title: string;
926
1025
  contentHash?: string;
927
1026
  attachmentId?: string;
@@ -976,15 +1075,56 @@ export type NodeClientFrame =
976
1075
  | { t: 'node/register'; token: string; name: string }
977
1076
  | { t: 'node/heartbeat' }
978
1077
  | { t: 'workspace/publish'; workspaceKey: string; displayName: string }
979
- | { t: 'session/publish'; workspaceAgentId: string; sessionKey: string; displayName: string }
1078
+ | {
1079
+ t: 'session/publish';
1080
+ workspaceAgentId: string;
1081
+ sessionKey: string;
1082
+ displayName: string;
1083
+ /** 由 session/create 触发时回带,服务端据此把新会话自动加进发起的那个群。 */
1084
+ requestId?: string;
1085
+ }
1086
+ | { t: 'session/createFailed'; requestId: string; error: string }
980
1087
  | { t: 'session/revoke'; workspaceSessionId: string }
981
1088
  | { t: 'workspace/revoke'; workspaceAgentId: string }
982
- | { t: 'workspace/status'; workspaceAgentId: string; status: WorkspaceRepositoryStatus }
1089
+ | {
1090
+ t: 'workspace/status';
1091
+ workspaceAgentId: string;
1092
+ status: WorkspaceRepositoryStatus;
1093
+ }
983
1094
  | { t: 'group/ack'; deliveryId: string }
984
1095
  | { t: 'agent/event'; requestId: string; event: AgentEvent }
985
- | { t: 'agent/question'; requestId: string; deliveryId: string; questions: AskQuestionSpec[]; source?: AskSource }
986
- | { t: 'agent/questionResolved'; requestId: string; deliveryId: string; state: 'answered' | 'cancelled' }
987
- | { t: 'agent/reply'; requestId: string; text: string; files?: AgentFileMetadata[]; error?: string }
1096
+ | {
1097
+ t: 'agent/question';
1098
+ requestId: string;
1099
+ deliveryId: string;
1100
+ questions: AskQuestionSpec[];
1101
+ source?: AskSource;
1102
+ }
1103
+ | {
1104
+ t: 'agent/questionResolved';
1105
+ requestId: string;
1106
+ deliveryId: string;
1107
+ state: 'answered' | 'cancelled';
1108
+ }
1109
+ | {
1110
+ t: 'agent/reply';
1111
+ requestId: string;
1112
+ text: string;
1113
+ files?: AgentFileMetadata[];
1114
+ error?: string;
1115
+ }
1116
+ | {
1117
+ t: 'agent/groupUpdate';
1118
+ requestId: string;
1119
+ deliveryId: string;
1120
+ update: GroupAgentUpdate;
1121
+ }
1122
+ | {
1123
+ t: 'agent/groupDelegate';
1124
+ requestId: string;
1125
+ deliveryId: string;
1126
+ delegation: GroupAgentDelegation;
1127
+ }
988
1128
  | {
989
1129
  /** 外部成员委托必须在 LLM 启动前获得主人批准。 */
990
1130
  t: 'agent/delegationRequest';
@@ -999,13 +1139,49 @@ export type NodeClientFrame =
999
1139
  deliveryId: string;
1000
1140
  toolName: string;
1001
1141
  argsPreview: string;
1142
+ }
1143
+ | {
1144
+ /** 取一条群消息里引用的附件(publicContext 里的 `[attachment:<fileId>]` 句柄)。
1145
+ * 服务端只回一次性下载票据,字节由节点自己走 HTTP GET —— 不把大二进制塞进这条
1146
+ * 「都是小 JSON 控制帧」的连接(base64 还膨胀 33%,且会队头阻塞)。 */
1147
+ t: 'attachment/fetch';
1148
+ requestId: string;
1149
+ deliveryId: string;
1150
+ fileId: string;
1151
+ }
1152
+ | {
1153
+ /** 请求把一个**交付物**上传成群附件的一次性票据(导出前的同意已在节点侧问过主人)。
1154
+ * 同样只发票据,字节由节点自己 PUT 上去。 */
1155
+ t: 'attachment/uploadRequest';
1156
+ requestId: string;
1157
+ deliveryId: string;
1158
+ name: string;
1159
+ mime: string;
1002
1160
  };
1003
1161
 
1004
1162
  export type NodeServerFrame =
1005
1163
  | { t: 'node/registered'; nodeId: string }
1006
1164
  | { t: 'workspace/published'; workspaceAgent: WorkspaceAgent }
1007
- | { t: 'session/published'; workspaceSession: WorkspaceSessionAgent; sessionKey: string }
1165
+ | {
1166
+ t: 'session/published';
1167
+ workspaceSession: WorkspaceSessionAgent;
1168
+ sessionKey: string;
1169
+ }
1008
1170
  | { t: 'node/error'; message: string }
1171
+ /** The server accepted and durably published this Agent reply. */
1172
+ | { t: 'agent/replyAck'; requestId: string }
1173
+ /** Server could no longer deliver a queued turn before its retention TTL. */
1174
+ | {
1175
+ t: 'agent/deliveryExpired';
1176
+ deliveryId: string;
1177
+ workspaceAgentId: string;
1178
+ workspaceSessionId?: string;
1179
+ eventId?: string;
1180
+ groupId?: string;
1181
+ agentMemberId?: string;
1182
+ displayName?: string;
1183
+ kind: 'group' | 'direct';
1184
+ }
1009
1185
  | {
1010
1186
  t: 'group/deliver';
1011
1187
  deliveryId: string;
@@ -1027,7 +1203,20 @@ export type NodeServerFrame =
1027
1203
  text: string;
1028
1204
  }
1029
1205
  | { t: 'agent/abort'; requestId: string }
1030
- | { t: 'agent/answer'; requestId: string; deliveryId: string; answers: AskAnswer[] }
1206
+ | {
1207
+ /** 请节点在某个工作目录下新建一个会话(用户按"工作目录"入群时由服务端发起)。
1208
+ * 节点建好后用 session/publish 回带同一个 requestId;失败发 session/createFailed。 */
1209
+ t: 'session/create';
1210
+ requestId: string;
1211
+ workspaceAgentId: string;
1212
+ title: string;
1213
+ }
1214
+ | {
1215
+ t: 'agent/answer';
1216
+ requestId: string;
1217
+ deliveryId: string;
1218
+ answers: AskAnswer[];
1219
+ }
1031
1220
  | { t: 'agent/questionCancel'; requestId: string; deliveryId: string }
1032
1221
  | {
1033
1222
  /** 节点侧同意请求的裁决下发(服务端 → 节点);节点据此 resolve 挂起的 toolGate。 */
@@ -1039,6 +1228,33 @@ export type NodeServerFrame =
1039
1228
  t: 'agent/delegationRespond';
1040
1229
  requestId: string;
1041
1230
  grant: DelegationGrant | null;
1231
+ }
1232
+ | {
1233
+ t: 'agent/groupActionResult';
1234
+ requestId: string;
1235
+ ok: boolean;
1236
+ referenceId?: string;
1237
+ error?: string;
1238
+ }
1239
+ | {
1240
+ /** attachment/fetch 的应答:一次性下载票据 + 文件元信息,或拒绝原因。
1241
+ * 节点拿 ticket 自己拼 `<serverUrl>/api/files/<fileId>?ticket=…` 去 GET
1242
+ * —— URL 由节点侧拼装,服务端因此不需要知道自己在反代后的对外地址。 */
1243
+ t: 'attachment/ticket';
1244
+ requestId: string;
1245
+ fileId: string;
1246
+ ticket?: string;
1247
+ name?: string;
1248
+ mime?: string;
1249
+ size?: number;
1250
+ error?: string;
1251
+ }
1252
+ | {
1253
+ /** attachment/uploadRequest 的应答:一次性上传票据,或拒绝原因。 */
1254
+ t: 'attachment/uploadTicket';
1255
+ requestId: string;
1256
+ ticket?: string;
1257
+ error?: string;
1042
1258
  };
1043
1259
 
1044
1260
  export interface GroupSummary {
@@ -1067,8 +1283,18 @@ export interface GroupMessageAttachment {
1067
1283
  size: number;
1068
1284
  }
1069
1285
 
1070
- export type ConversationFileKind = 'workspace-file' | 'user-attachment' | 'group-attachment' | 'agent-file';
1071
- export type ConversationFileActivity = 'referenced' | 'read' | 'created' | 'modified' | 'generated' | 'deleted';
1286
+ export type ConversationFileKind =
1287
+ | 'workspace-file'
1288
+ | 'user-attachment'
1289
+ | 'group-attachment'
1290
+ | 'agent-file';
1291
+ export type ConversationFileActivity =
1292
+ | 'referenced'
1293
+ | 'read'
1294
+ | 'created'
1295
+ | 'modified'
1296
+ | 'generated'
1297
+ | 'deleted';
1072
1298
 
1073
1299
  /** Safe metadata an Agent Node may publish to a group. Absolute paths and file bytes are forbidden. */
1074
1300
  export interface AgentFileMetadata {
@@ -1079,6 +1305,12 @@ export interface AgentFileMetadata {
1079
1305
  mime?: string;
1080
1306
  activity: ConversationFileActivity;
1081
1307
  purpose?: ConversationFilePurpose;
1308
+ /**
1309
+ * 该交付物已被导出为群附件时的 fileId(群成员据此下载)。
1310
+ * 只有 `purpose === 'deliverable'` 且经本机主人批准导出的文件才有;
1311
+ * 其余文件只有元信息,拿不到内容。
1312
+ */
1313
+ fileId?: string;
1082
1314
  lastSeenAt: number;
1083
1315
  }
1084
1316
 
@@ -1129,9 +1361,20 @@ export interface ConversationArtifactGroup {
1129
1361
  deliveries: ConversationDelivery[];
1130
1362
  }
1131
1363
 
1132
- export type ConversationAssetCategory = 'document' | 'code' | 'image' | 'link' | 'other';
1133
- export type ConversationAssetOrigin = 'user-upload' | 'user-reference' | 'ai-delivery';
1134
- export type ConversationAssetKind = 'workspace-file' | 'user-attachment' | 'web-link';
1364
+ export type ConversationAssetCategory =
1365
+ | 'document'
1366
+ | 'code'
1367
+ | 'image'
1368
+ | 'link'
1369
+ | 'other';
1370
+ export type ConversationAssetOrigin =
1371
+ | 'user-upload'
1372
+ | 'user-reference'
1373
+ | 'ai-delivery';
1374
+ export type ConversationAssetKind =
1375
+ | 'workspace-file'
1376
+ | 'user-attachment'
1377
+ | 'web-link';
1135
1378
 
1136
1379
  /** A durable, session-scoped item explicitly supplied by the user or formally delivered by the Agent. */
1137
1380
  export interface ConversationAsset {
@@ -1182,6 +1425,268 @@ export interface GroupChatMessage {
1182
1425
  kind?: 'system';
1183
1426
  }
1184
1427
 
1428
+ export type CollaborationEventVisibility = 'public' | 'owner-private';
1429
+ export type CollaborationConversationKind = 'group' | 'direct' | 'agent';
1430
+
1431
+ export interface CollaborationConversationRef {
1432
+ kind: CollaborationConversationKind;
1433
+ id: string;
1434
+ }
1435
+
1436
+ export interface CollaborationArtifactRef {
1437
+ id: string;
1438
+ name: string;
1439
+ mime: string;
1440
+ size: number;
1441
+ sha256?: string;
1442
+ version?: number;
1443
+ }
1444
+
1445
+ export interface CollaborationEventPayloads {
1446
+ 'message.created': {
1447
+ text: string;
1448
+ mentions: string[];
1449
+ attachments?: CollaborationArtifactRef[];
1450
+ senderKind: 'human' | 'agent' | 'system';
1451
+ };
1452
+ 'goal.drafted': {
1453
+ title: string;
1454
+ objective: string;
1455
+ deliverables: string[];
1456
+ acceptanceCriteria: string[];
1457
+ scope?: string;
1458
+ };
1459
+ 'goal.confirmed': {
1460
+ goalId: string;
1461
+ contractVersion?: number;
1462
+ contractHash?: string;
1463
+ };
1464
+ 'task.created': {
1465
+ title: string;
1466
+ objective: string;
1467
+ acceptanceCriteria: string[];
1468
+ parentTaskId?: string;
1469
+ assigneeIds?: string[];
1470
+ /** 目标确认后默认直接运行;保留 planned 只用于显式暂存。 */
1471
+ initialState?: 'planned' | 'running';
1472
+ };
1473
+ 'task.updated': {
1474
+ state:
1475
+ | 'planned'
1476
+ | 'running'
1477
+ | 'stopped'
1478
+ | 'blocked'
1479
+ | 'verifying'
1480
+ | 'awaiting_acceptance'
1481
+ | 'completed'
1482
+ | 'cancelled';
1483
+ summary?: string;
1484
+ reason?: string;
1485
+ assigneeIds?: string[];
1486
+ };
1487
+ 'decision.recorded': {
1488
+ title: string;
1489
+ conclusion: string;
1490
+ sourceIds: string[];
1491
+ };
1492
+ 'activity.recorded': {
1493
+ phase:
1494
+ | 'planning'
1495
+ | 'producing'
1496
+ | 'checking'
1497
+ | 'handoff'
1498
+ | 'waiting'
1499
+ | 'blocked';
1500
+ summary: string;
1501
+ agentMemberId?: string;
1502
+ };
1503
+ 'artifact.published': {
1504
+ artifact: CollaborationArtifactRef;
1505
+ summary?: string;
1506
+ };
1507
+ 'verification.recorded': {
1508
+ verifier: string;
1509
+ passed: boolean;
1510
+ summary: string;
1511
+ evidenceIds: string[];
1512
+ criterionResults?: Array<{
1513
+ criterion: string;
1514
+ passed: boolean;
1515
+ evidence?: string;
1516
+ }>;
1517
+ };
1518
+ 'acceptance.requested': {
1519
+ artifactIds: string[];
1520
+ selfCheck: Array<{ criterion: string; passed: boolean; evidence?: string }>;
1521
+ risks?: string[];
1522
+ };
1523
+ 'acceptance.resolved': {
1524
+ decision: 'accepted' | 'rework';
1525
+ reason?: string;
1526
+ };
1527
+ 'attention.raised': {
1528
+ reason:
1529
+ | 'business_ambiguity'
1530
+ | 'scope_exceeded'
1531
+ | 'irreversible_action'
1532
+ | 'sensitive_export'
1533
+ | 'execution_failed';
1534
+ summary: string;
1535
+ requestedFromUserId: string;
1536
+ };
1537
+ 'attention.resolved': { resolution: string };
1538
+ 'approval.requested': {
1539
+ requestId: string;
1540
+ agentMemberId: string;
1541
+ agentDisplayName?: string;
1542
+ reason: string;
1543
+ capability: string;
1544
+ argsPreview?: string;
1545
+ };
1546
+ 'approval.status': {
1547
+ requestId: string;
1548
+ agentMemberId: string;
1549
+ agentDisplayName?: string;
1550
+ state:
1551
+ | 'waiting'
1552
+ | 'approved'
1553
+ | 'denied'
1554
+ | 'expired'
1555
+ | 'revoked'
1556
+ | 'stopped';
1557
+ ownerDisplayName?: string;
1558
+ };
1559
+ 'membership.changed': {
1560
+ memberId: string;
1561
+ action: 'joined' | 'left' | 'removed';
1562
+ displayName: string;
1563
+ memberKind: 'human' | 'agent';
1564
+ };
1565
+ }
1566
+
1567
+ export type CollaborationEventType = keyof CollaborationEventPayloads;
1568
+
1569
+ interface CollaborationEventBase<T extends CollaborationEventType> {
1570
+ version: 1;
1571
+ id: string;
1572
+ type: T;
1573
+ conversation: CollaborationConversationRef;
1574
+ author: { id: string; name: string; kind: 'human' | 'agent' | 'system' };
1575
+ visibility: CollaborationEventVisibility;
1576
+ createdAt: number;
1577
+ causedBy: string[];
1578
+ taskId?: string;
1579
+ objectId?: string;
1580
+ revision?: number;
1581
+ /** Optional Goal Runtime correlation. Older clients treat a missing version as v1. */
1582
+ contractVersion?: number;
1583
+ contractHash?: string;
1584
+ attemptId?: string;
1585
+ agentMemberId?: string;
1586
+ payload: CollaborationEventPayloads[T];
1587
+ }
1588
+
1589
+ export type CollaborationEvent = {
1590
+ [T in CollaborationEventType]: CollaborationEventBase<T>;
1591
+ }[CollaborationEventType];
1592
+
1593
+ /** Client-authored events are always public; owner-private events are server-authored. */
1594
+ export type CollaborationEventDraft = {
1595
+ [T in CollaborationEventType]: Omit<
1596
+ CollaborationEventBase<T>,
1597
+ 'id' | 'author' | 'createdAt' | 'visibility'
1598
+ > & { clientEventId: string };
1599
+ }[CollaborationEventType];
1600
+
1601
+ /** Durable local-only batch awaiting a relay acknowledgement. */
1602
+ export interface CollaborationOutboxItem {
1603
+ id: string;
1604
+ serverUrl: string;
1605
+ userId: string;
1606
+ events: CollaborationEventDraft[];
1607
+ createdAt: number;
1608
+ }
1609
+
1610
+ export interface RelayDelivery {
1611
+ deliveryId: string;
1612
+ /** Device-local monotonic sequence. Required on the PostgreSQL relay path. */
1613
+ sequence?: number;
1614
+ /** Identifies which device continuity stream owns sequence. */
1615
+ deviceId?: string;
1616
+ event: CollaborationEvent;
1617
+ }
1618
+
1619
+ export interface RelayContinuityState {
1620
+ deviceId: string;
1621
+ highestAssignedSequence: number;
1622
+ /** More unacknowledged rows remain after this batch. */
1623
+ hasMore: boolean;
1624
+ }
1625
+
1626
+ export interface RelayMissingRange {
1627
+ from: number;
1628
+ to: number;
1629
+ }
1630
+
1631
+ /** Content-free metadata used to repair a settled device-local relay gap. */
1632
+ export interface RelayGapCandidate {
1633
+ eventId: string;
1634
+ sequence: number;
1635
+ conversationKind: 'group' | 'direct' | 'agent';
1636
+ conversationId: string;
1637
+ eventType: string;
1638
+ payloadHash: string;
1639
+ attachmentIds: string[];
1640
+ createdAt: number;
1641
+ /** Devices that originally received the same event and may have a local copy. */
1642
+ sourceDeviceIds: string[];
1643
+ }
1644
+
1645
+ export interface RelayGapRepairRequest {
1646
+ requestId: string;
1647
+ targetDeviceId: string;
1648
+ candidate: RelayGapCandidate;
1649
+ }
1650
+
1651
+ export interface LocalRelayContinuity {
1652
+ deviceId: string;
1653
+ highestStoredSequence: number;
1654
+ missing: RelayMissingRange[];
1655
+ /** False until the Server reports that all current rows have been pulled. */
1656
+ settled: boolean;
1657
+ }
1658
+
1659
+ export type GroupUpdateKind =
1660
+ | 'progress'
1661
+ | 'decision'
1662
+ | 'artifact'
1663
+ | 'verification'
1664
+ | 'handoff';
1665
+ export interface GroupAgentUpdate {
1666
+ kind: GroupUpdateKind;
1667
+ summary: string;
1668
+ parentTaskId?: string;
1669
+ references?: string[];
1670
+ /** Required for verification updates; omitted means the check did not pass. */
1671
+ passed?: boolean;
1672
+ /** Stable evidence/artifact ids supporting the check. */
1673
+ evidenceIds?: string[];
1674
+ }
1675
+
1676
+ export interface GroupAgentDelegation {
1677
+ /**
1678
+ * Optional: when omitted the server chooses an eligible Agent in the same
1679
+ * group. An explicit offline target may also be replaced by an eligible
1680
+ * online/busy Agent so a temporary device outage does not stop the parent
1681
+ * task.
1682
+ */
1683
+ targetAgentMemberId?: string;
1684
+ parentTaskId: string;
1685
+ objective: string;
1686
+ acceptanceCriteria?: string[];
1687
+ references?: string[];
1688
+ }
1689
+
1185
1690
  /** Local, read-only social snapshot. It never contains auth tokens, absolute paths or Agent private history. */
1186
1691
  export interface OfflineSocialCache {
1187
1692
  version: 1;
@@ -1193,6 +1698,35 @@ export interface OfflineSocialCache {
1193
1698
  groupMessages: Record<string, GroupChatMessage[]>;
1194
1699
  }
1195
1700
 
1701
+ /**
1702
+ * A durable, local-only social send waiting for a server acknowledgement.
1703
+ * The server never stores this queue; the stable id is used only for
1704
+ * at-least-once delivery and duplicate suppression.
1705
+ */
1706
+ export interface SocialOutboxItem {
1707
+ id: string;
1708
+ serverUrl: string;
1709
+ userId: string;
1710
+ kind: 'group' | 'direct';
1711
+ conversationId: string;
1712
+ text: string;
1713
+ mentions?: string[];
1714
+ attachments?: string[];
1715
+ createdAt: number;
1716
+ }
1717
+
1718
+ /**
1719
+ * A conversation read marker, owned entirely by Desktop. Under the relay-only server design
1720
+ * the server never persists message bodies, so it has no place to keep a per-user read cursor
1721
+ * either — `unreadCount`/`mentioned` on `GroupSummary`/`ConversationNavigation` are honestly `0`/
1722
+ * `false` from the server. Desktop derives the real values from its own local event replica plus
1723
+ * this cursor (see minimal-desktop's `runtime/unreadProjection.ts` / `runtime/readCursors.ts`).
1724
+ */
1725
+ export interface ReadCursor {
1726
+ eventId: string;
1727
+ at: number;
1728
+ }
1729
+
1196
1730
  /**
1197
1731
  * 用户级事件:不管用户当前打开哪个群都会推送(连接建立、解析出登录身份后订阅)。
1198
1732
  * 与 group/message(只推给"正打开该群"的连接)互补——未读徽标、被 @ 提醒、
@@ -1233,7 +1767,11 @@ export type UserSocialEvent =
1233
1767
  t: 'conversation/workspace/changed';
1234
1768
  conversation: ConversationRef;
1235
1769
  }
1236
- | { t: 'agent/directMessage'; workspaceSessionId: string; message: AgentDirectMessage }
1770
+ | {
1771
+ t: 'agent/directMessage';
1772
+ workspaceSessionId: string;
1773
+ message: AgentDirectMessage;
1774
+ }
1237
1775
  | { t: 'agent/directEvent'; workspaceSessionId: string; event: AgentEvent }
1238
1776
  | {
1239
1777
  /** 群 Agent 的完整运行事件,仅推送给该 Agent 所有者。 */
@@ -1250,7 +1788,15 @@ export type UserSocialEvent =
1250
1788
  agentMemberId: string;
1251
1789
  displayName: string;
1252
1790
  toolCallId: string;
1253
- phase: 'queued' | 'preparing' | 'analyzing' | 'using_tool' | 'drafting' | 'waiting_owner' | 'completed' | 'failed';
1791
+ phase:
1792
+ | 'queued'
1793
+ | 'preparing'
1794
+ | 'analyzing'
1795
+ | 'using_tool'
1796
+ | 'drafting'
1797
+ | 'waiting_owner'
1798
+ | 'completed'
1799
+ | 'failed';
1254
1800
  }
1255
1801
  | {
1256
1802
  t: 'agent/question';
@@ -1258,7 +1804,14 @@ export type UserSocialEvent =
1258
1804
  deliveryId: string;
1259
1805
  questions: AskQuestionSpec[];
1260
1806
  source?: AskSource;
1261
- context: { kind: 'group'; groupId: string; agentMemberId: string; agentDisplayName: string } | { kind: 'direct'; workspaceSessionId: string };
1807
+ context:
1808
+ | {
1809
+ kind: 'group';
1810
+ groupId: string;
1811
+ agentMemberId: string;
1812
+ agentDisplayName: string;
1813
+ }
1814
+ | { kind: 'direct'; workspaceSessionId: string };
1262
1815
  }
1263
1816
  | {
1264
1817
  t: 'agent/questionStatus';
@@ -1294,79 +1847,437 @@ export type UserSocialEvent =
1294
1847
 
1295
1848
  export type ClientFrame =
1296
1849
  | { t: 'runtime/hello' }
1297
- | { t: 'local/conversation/start'; requestId: string; target: ConversationTarget; text: string; attachments?: string[]; browserReferences?: BrowserElementReference[]; modelId?: string }
1850
+ | {
1851
+ t: 'goal/get';
1852
+ requestId: string;
1853
+ workspaceId: string;
1854
+ sessionId: string;
1855
+ }
1856
+ | {
1857
+ t: 'goal/control';
1858
+ requestId: string;
1859
+ workspaceId: string;
1860
+ sessionId: string;
1861
+ action:
1862
+ | 'start'
1863
+ | 'pause'
1864
+ | 'resume'
1865
+ | 'update'
1866
+ | 'cancel'
1867
+ | 'accept'
1868
+ | 'rework';
1869
+ actorId: string;
1870
+ objective?: string;
1871
+ deliverables?: string[];
1872
+ acceptanceCriteria?: string[];
1873
+ scope?: string;
1874
+ reason?: string;
1875
+ source?: import('../goal/types.js').GoalSource;
1876
+ acceptorHumanIds?: string[];
1877
+ }
1878
+ | {
1879
+ t: 'local/conversation/start';
1880
+ requestId: string;
1881
+ target: ConversationTarget;
1882
+ text: string;
1883
+ attachments?: string[];
1884
+ browserReferences?: BrowserElementReference[];
1885
+ modelId?: string;
1886
+ }
1298
1887
  | { t: 'plain/list' }
1299
1888
  | { t: 'plain/open'; sessionId: string; requestId?: string }
1300
- | { t: 'plain/send'; sessionId: string; text: string; attachments?: string[]; browserReferences?: BrowserElementReference[]; requestId?: string; modelId?: string }
1889
+ | {
1890
+ t: 'plain/send';
1891
+ sessionId: string;
1892
+ text: string;
1893
+ attachments?: string[];
1894
+ browserReferences?: BrowserElementReference[];
1895
+ requestId?: string;
1896
+ modelId?: string;
1897
+ }
1301
1898
  | { t: 'plain/clear'; sessionId: string }
1302
1899
  | { t: 'plain/compact'; sessionId: string; requestId?: string }
1303
1900
  | { t: 'plain/rename'; sessionId: string; title: string }
1304
1901
  | { t: 'plain/delete'; sessionId: string }
1305
1902
  | { t: 'resource/files/list'; dir: string; sessionId: string }
1306
- | { t: 'resource/assets/list'; requestId: string; target: ConversationTarget & { sessionId: string } }
1307
- | { t: 'resource/assets/pin'; requestId: string; target: ConversationTarget & { sessionId: string }; assetId: string; pinned: boolean }
1308
- | { t: 'resource/assets/open'; requestId: string; target: ConversationTarget & { sessionId: string }; assetId: string; source?: 'default' | 'original' | 'archive' }
1309
- | { t: 'resource/assets/reveal'; requestId: string; target: ConversationTarget & { sessionId: string }; assetId: string; source?: 'original' | 'archive' }
1310
- | { t: 'resource/files/open'; requestId: string; target: ConversationTarget & { sessionId: string }; relativePath: string }
1311
- | { t: 'resource/files/pin'; dir: string; sessionId: string; relativePath: string; pinned: boolean }
1312
- | { t: 'resource/files/reveal'; requestId?: string; dir?: string; target?: ConversationTarget & { sessionId: string }; relativePath: string }
1903
+ | {
1904
+ t: 'resource/assets/list';
1905
+ requestId: string;
1906
+ target: ConversationTarget & { sessionId: string };
1907
+ }
1908
+ | {
1909
+ t: 'resource/assets/pin';
1910
+ requestId: string;
1911
+ target: ConversationTarget & { sessionId: string };
1912
+ assetId: string;
1913
+ pinned: boolean;
1914
+ }
1915
+ | {
1916
+ t: 'resource/assets/open';
1917
+ requestId: string;
1918
+ target: ConversationTarget & { sessionId: string };
1919
+ assetId: string;
1920
+ source?: 'default' | 'original' | 'archive';
1921
+ }
1922
+ | {
1923
+ t: 'resource/assets/reveal';
1924
+ requestId: string;
1925
+ target: ConversationTarget & { sessionId: string };
1926
+ assetId: string;
1927
+ source?: 'original' | 'archive';
1928
+ }
1929
+ | {
1930
+ t: 'resource/files/open';
1931
+ requestId: string;
1932
+ target: ConversationTarget & { sessionId: string };
1933
+ relativePath: string;
1934
+ }
1935
+ | {
1936
+ t: 'resource/files/pin';
1937
+ dir: string;
1938
+ sessionId: string;
1939
+ relativePath: string;
1940
+ pinned: boolean;
1941
+ }
1942
+ | {
1943
+ t: 'resource/files/reveal';
1944
+ requestId?: string;
1945
+ dir?: string;
1946
+ target?: ConversationTarget & { sessionId: string };
1947
+ relativePath: string;
1948
+ }
1313
1949
  | { t: 'resource/memories/list'; workspaceId?: string; query?: string }
1314
- | { t: 'resource/memories/settings/update'; autoRemember: boolean; workspaceId?: string }
1315
- | { t: 'resource/memories/update'; id: string; scope: 'personal' | 'workspace'; expectedVersion: string; patch: MemoryUpdate; workspaceId?: string }
1316
- | { t: 'resource/memories/confirm'; id: string; scope: 'personal' | 'workspace'; expectedVersion: string; evidenceQuote: string; sourceSessionId: string; sourceMessageId: string; workspaceId?: string }
1317
- | { t: 'resource/memories/review'; scope?: 'personal' | 'workspace'; workspaceId?: string }
1318
- | { t: 'resource/memories/persona/set'; content: string; evidenceQuote: string; sourceSessionId: string; sourceMessageId: string }
1950
+ | {
1951
+ t: 'resource/memories/settings/update';
1952
+ autoRemember: boolean;
1953
+ workspaceId?: string;
1954
+ }
1955
+ | {
1956
+ t: 'resource/memories/update';
1957
+ id: string;
1958
+ scope: 'personal' | 'workspace';
1959
+ expectedVersion: string;
1960
+ patch: MemoryUpdate;
1961
+ workspaceId?: string;
1962
+ }
1963
+ | {
1964
+ t: 'resource/memories/confirm';
1965
+ id: string;
1966
+ scope: 'personal' | 'workspace';
1967
+ expectedVersion: string;
1968
+ evidenceQuote: string;
1969
+ sourceSessionId: string;
1970
+ sourceMessageId: string;
1971
+ workspaceId?: string;
1972
+ }
1973
+ | {
1974
+ t: 'resource/memories/review';
1975
+ scope?: 'personal' | 'workspace';
1976
+ workspaceId?: string;
1977
+ }
1978
+ | {
1979
+ t: 'resource/memories/persona/set';
1980
+ content: string;
1981
+ evidenceQuote: string;
1982
+ sourceSessionId: string;
1983
+ sourceMessageId: string;
1984
+ }
1319
1985
  | { t: 'resource/memories/persona/clear' }
1320
- | { t: 'resource/memories/conversations/search'; requestId: string; query: string; workspaceId: string; scope?: 'workspace' | 'all'; explicitCrossWorkspace?: boolean; limit?: number }
1321
- | { t: 'resource/memories/forget'; id: string; scope: 'personal' | 'workspace'; workspaceId?: string }
1322
- | { t: 'resource/memories/clear'; scope: 'personal' | 'workspace'; workspaceId?: string }
1986
+ | {
1987
+ t: 'resource/memories/conversations/search';
1988
+ requestId: string;
1989
+ query: string;
1990
+ workspaceId: string;
1991
+ scope?: 'workspace' | 'all';
1992
+ explicitCrossWorkspace?: boolean;
1993
+ limit?: number;
1994
+ }
1995
+ | {
1996
+ t: 'resource/memories/forget';
1997
+ id: string;
1998
+ scope: 'personal' | 'workspace';
1999
+ workspaceId?: string;
2000
+ }
2001
+ | {
2002
+ t: 'resource/memories/clear';
2003
+ scope: 'personal' | 'workspace';
2004
+ workspaceId?: string;
2005
+ }
1323
2006
  | { t: 'resource/memories/manage/load'; requestId: string }
1324
- | { t: 'resource/memories/manage/update'; requestId: string; id: string; scope: 'personal' | 'workspace'; workspaceId?: string; expectedVersion: string; patch: MemoryEditablePatch; includeState?: boolean }
1325
- | { t: 'resource/memories/manage/confirm'; requestId: string; id: string; scope: 'personal' | 'workspace'; workspaceId?: string; expectedVersion: string; includeState?: boolean }
1326
- | { t: 'resource/memories/manage/persona/update'; requestId: string; content: string; expectedVersion: string; includeState?: boolean }
1327
- | { t: 'resource/memories/manage/persona/clear'; requestId: string; expectedVersion: string; includeState?: boolean }
1328
- | { t: 'resource/memories/manage/settings/update'; requestId: string; patch: Partial<MemorySettings>; expectedVersion: string; includeState?: boolean }
1329
- | { t: 'resource/memories/manage/forget'; requestId: string; id: string; scope: 'personal' | 'workspace'; workspaceId?: string; expectedVersion: string; includeState?: boolean }
1330
- | { t: 'resource/memories/manage/clear'; requestId: string; scope: 'personal' | 'workspace'; workspaceId?: string; includeState?: boolean }
1331
- | { t: 'resource/memories/overview/load'; requestId: string; currentWorkspaceId?: string }
1332
- | { t: 'resource/memories/topics/list'; requestId: string; scope: 'personal' | 'workspace'; workspaceId?: string; query?: string; category?: MemoryCategory | 'all'; lifecycle?: MemoryLifecycleFilter; cursor?: string; limit?: number }
1333
- | { t: 'resource/memories/topic/detail'; requestId: string; scope: 'personal' | 'workspace'; workspaceId?: string; topicKey: string }
1334
- | { t: 'resource/context/status'; requestId: string; target: { kind: 'plain'; sessionId: string } | { kind: 'workspace'; dir: string; sessionId: string } }
1335
- | { t: 'resource/subagents/worktrees/diff'; requestId: string; dir: string; id: string }
1336
- | { t: 'resource/subagents/worktrees/apply'; requestId: string; dir: string; id: string }
1337
- | { t: 'resource/subagents/worktrees/discard'; requestId: string; dir: string; id: string }
1338
- | { t: 'open'; dir: string; sessionId?: string; requestId?: string }
1339
- | { t: 'send'; dir: string; text: string; sessionId?: string; attachments?: string[]; browserReferences?: BrowserElementReference[]; requestId?: string; modelId?: string }
1340
- | { t: 'session/model/set'; target: { kind: 'plain' } | { kind: 'workspace'; dir: string }; sessionId: string; modelId: string | null }
1341
- | { t: 'input/queue'; item: Omit<QueuedUserInput, 'id' | 'createdAt' | 'restored'> }
1342
- | { t: 'input/queue/update'; id: string; text?: string; attachmentIds?: string[]; browserReferences?: BrowserElementReference[]; priority?: 'next' | 'interrupt'; activate?: boolean }
1343
- | { t: 'input/queue/remove'; id: string }
1344
- | { t: 'input/queue/get' }
1345
- | { t: 'conversation/run/list' }
1346
2007
  | {
1347
- t: 'conversation/view/open';
2008
+ t: 'resource/memories/manage/update';
1348
2009
  requestId: string;
1349
- target:
1350
- | { kind: 'plain'; sessionId: string }
1351
- | { kind: 'workspace'; dir: string; sessionId: string };
2010
+ id: string;
2011
+ scope: 'personal' | 'workspace';
2012
+ workspaceId?: string;
2013
+ expectedVersion: string;
2014
+ patch: MemoryEditablePatch;
2015
+ includeState?: boolean;
1352
2016
  }
1353
- | { t: 'conversation/run/abort'; conversation: LocalConversationRef; runId: string }
1354
- | { t: 'conversation/run/answer'; conversation: LocalConversationRef; runId: string; requestId: string; answers: AskAnswer[] }
1355
- | { t: 'conversation/run/cancel-ask'; conversation: LocalConversationRef; runId: string; requestId: string }
1356
- | { t: 'conversation/result/mark-seen'; conversation: LocalConversationRef; runId?: string }
1357
- | { t: 'conversation/run/configure'; maxConcurrent: number }
1358
- | { t: 'answer'; requestId: string; answers: AskAnswer[] }
1359
- | { t: 'cancelAsk'; requestId: string }
1360
- | { t: 'abort' }
1361
- | { t: 'new'; dir: string; sessionId?: string }
1362
- | { t: 'compact'; dir: string; sessionId?: string; requestId?: string }
1363
- | { t: 'listDirs' }
1364
- | { t: 'workspace/index/get' }
1365
- | { t: 'workspace/recovery/preview' }
2017
+ | {
2018
+ t: 'resource/memories/manage/confirm';
2019
+ requestId: string;
2020
+ id: string;
2021
+ scope: 'personal' | 'workspace';
2022
+ workspaceId?: string;
2023
+ expectedVersion: string;
2024
+ includeState?: boolean;
2025
+ }
2026
+ | {
2027
+ t: 'resource/memories/manage/persona/update';
2028
+ requestId: string;
2029
+ content: string;
2030
+ expectedVersion: string;
2031
+ includeState?: boolean;
2032
+ }
2033
+ | {
2034
+ t: 'resource/memories/manage/persona/clear';
2035
+ requestId: string;
2036
+ expectedVersion: string;
2037
+ includeState?: boolean;
2038
+ }
2039
+ | {
2040
+ t: 'resource/memories/manage/settings/update';
2041
+ requestId: string;
2042
+ patch: Partial<MemorySettings>;
2043
+ expectedVersion: string;
2044
+ includeState?: boolean;
2045
+ }
2046
+ | {
2047
+ t: 'resource/memories/manage/forget';
2048
+ requestId: string;
2049
+ id: string;
2050
+ scope: 'personal' | 'workspace';
2051
+ workspaceId?: string;
2052
+ expectedVersion: string;
2053
+ includeState?: boolean;
2054
+ }
2055
+ | {
2056
+ t: 'resource/memories/manage/clear';
2057
+ requestId: string;
2058
+ scope: 'personal' | 'workspace';
2059
+ workspaceId?: string;
2060
+ includeState?: boolean;
2061
+ }
2062
+ | {
2063
+ t: 'resource/memories/overview/load';
2064
+ requestId: string;
2065
+ currentWorkspaceId?: string;
2066
+ }
2067
+ | {
2068
+ t: 'resource/memories/topics/list';
2069
+ requestId: string;
2070
+ scope: 'personal' | 'workspace';
2071
+ workspaceId?: string;
2072
+ query?: string;
2073
+ category?: MemoryCategory | 'all';
2074
+ lifecycle?: MemoryLifecycleFilter;
2075
+ cursor?: string;
2076
+ limit?: number;
2077
+ }
2078
+ | {
2079
+ t: 'resource/memories/topic/detail';
2080
+ requestId: string;
2081
+ scope: 'personal' | 'workspace';
2082
+ workspaceId?: string;
2083
+ topicKey: string;
2084
+ }
2085
+ | {
2086
+ t: 'resource/context/status';
2087
+ requestId: string;
2088
+ target:
2089
+ | { kind: 'plain'; sessionId: string }
2090
+ | { kind: 'workspace'; dir: string; sessionId: string };
2091
+ }
2092
+ | {
2093
+ t: 'resource/subagents/worktrees/diff';
2094
+ requestId: string;
2095
+ dir: string;
2096
+ id: string;
2097
+ }
2098
+ | {
2099
+ t: 'resource/subagents/worktrees/apply';
2100
+ requestId: string;
2101
+ dir: string;
2102
+ id: string;
2103
+ }
2104
+ | {
2105
+ t: 'resource/subagents/worktrees/discard';
2106
+ requestId: string;
2107
+ dir: string;
2108
+ id: string;
2109
+ }
2110
+ | { t: 'open'; dir: string; sessionId?: string; requestId?: string }
2111
+ | {
2112
+ t: 'send';
2113
+ dir: string;
2114
+ text: string;
2115
+ sessionId?: string;
2116
+ attachments?: string[];
2117
+ browserReferences?: BrowserElementReference[];
2118
+ requestId?: string;
2119
+ modelId?: string;
2120
+ }
2121
+ | {
2122
+ t: 'session/model/set';
2123
+ target: { kind: 'plain' } | { kind: 'workspace'; dir: string };
2124
+ sessionId: string;
2125
+ modelId: string | null;
2126
+ }
2127
+ | {
2128
+ t: 'session/tools/set';
2129
+ target: { kind: 'plain' } | { kind: 'workspace'; dir: string };
2130
+ sessionId: string;
2131
+ categories: string[];
2132
+ }
2133
+ | {
2134
+ t: 'input/queue';
2135
+ item: Omit<QueuedUserInput, 'id' | 'createdAt' | 'restored'>;
2136
+ }
2137
+ | {
2138
+ t: 'input/queue/update';
2139
+ id: string;
2140
+ text?: string;
2141
+ attachmentIds?: string[];
2142
+ browserReferences?: BrowserElementReference[];
2143
+ priority?: 'next' | 'interrupt';
2144
+ activate?: boolean;
2145
+ }
2146
+ | { t: 'input/queue/remove'; id: string }
2147
+ | { t: 'input/queue/get' }
2148
+ | { t: 'conversation/run/list' }
2149
+ | {
2150
+ t: 'conversation/view/open';
2151
+ requestId: string;
2152
+ target:
2153
+ | { kind: 'plain'; sessionId: string }
2154
+ | { kind: 'workspace'; dir: string; sessionId: string };
2155
+ }
2156
+ | {
2157
+ t: 'conversation/run/abort';
2158
+ conversation: LocalConversationRef;
2159
+ runId: string;
2160
+ }
2161
+ /** Retry the last persisted user turn in the same Session after a failed/interrupted run. */
2162
+ | {
2163
+ t: 'conversation/run/retry';
2164
+ conversation: LocalConversationRef;
2165
+ runId: string;
2166
+ }
2167
+ | {
2168
+ t: 'conversation/run/answer';
2169
+ conversation: LocalConversationRef;
2170
+ runId: string;
2171
+ requestId: string;
2172
+ answers: AskAnswer[];
2173
+ }
2174
+ | {
2175
+ t: 'conversation/run/cancel-ask';
2176
+ conversation: LocalConversationRef;
2177
+ runId: string;
2178
+ requestId: string;
2179
+ }
2180
+ | {
2181
+ t: 'conversation/result/mark-seen';
2182
+ conversation: LocalConversationRef;
2183
+ runId?: string;
2184
+ }
2185
+ | { t: 'conversation/run/configure'; maxConcurrent: number }
2186
+ | { t: 'answer'; requestId: string; answers: AskAnswer[] }
2187
+ | { t: 'cancelAsk'; requestId: string }
2188
+ | { t: 'abort' }
2189
+ | { t: 'new'; dir: string; sessionId?: string }
2190
+ | { t: 'compact'; dir: string; sessionId?: string; requestId?: string }
2191
+ | { t: 'listDirs' }
2192
+ /** 探测局域网内的 minimal-server(UDP 只能在本机 Runtime 里发,浏览器上下文发不了)。 */
2193
+ | { t: 'server/discover' }
2194
+ | { t: 'workspace/index/get' }
2195
+ | { t: 'workspace/recovery/preview' }
1366
2196
  | { t: 'workspace/recovery/apply' }
1367
2197
  | { t: 'social/cache/get'; serverUrl: string }
1368
2198
  | { t: 'social/cache/save'; cache: OfflineSocialCache }
1369
2199
  | { t: 'social/cache/clear'; serverUrl: string; userId?: string }
2200
+ | {
2201
+ t: 'social/outbox/get';
2202
+ requestId: string;
2203
+ serverUrl: string;
2204
+ userId: string;
2205
+ }
2206
+ | {
2207
+ t: 'social/outbox/save';
2208
+ requestId: string;
2209
+ serverUrl: string;
2210
+ userId: string;
2211
+ items: SocialOutboxItem[];
2212
+ }
2213
+ | {
2214
+ t: 'social/outbox/clear';
2215
+ requestId: string;
2216
+ serverUrl: string;
2217
+ userId?: string;
2218
+ }
2219
+ | {
2220
+ t: 'collaboration/outbox/get';
2221
+ requestId: string;
2222
+ serverUrl: string;
2223
+ userId: string;
2224
+ }
2225
+ | {
2226
+ t: 'collaboration/outbox/save';
2227
+ requestId: string;
2228
+ serverUrl: string;
2229
+ userId: string;
2230
+ items: CollaborationOutboxItem[];
2231
+ }
2232
+ | {
2233
+ t: 'collaboration/outbox/clear';
2234
+ requestId: string;
2235
+ serverUrl: string;
2236
+ userId?: string;
2237
+ }
2238
+ | {
2239
+ t: 'collaboration/read/get';
2240
+ requestId: string;
2241
+ serverUrl: string;
2242
+ userId: string;
2243
+ }
2244
+ /**
2245
+ * Fire-and-forget: Desktop advances its own read cursor (conversation opened, or a real-time
2246
+ * bump arrived while it was open). No reply — losing one on a crash just means one extra
2247
+ * unread badge next launch, never a false "read" state.
2248
+ */
2249
+ | {
2250
+ t: 'collaboration/read/mark';
2251
+ serverUrl: string;
2252
+ userId: string;
2253
+ conversationId: string;
2254
+ cursor: ReadCursor;
2255
+ }
2256
+ | { t: 'collaboration/device/get'; requestId: string }
2257
+ | {
2258
+ /** Local Runtime only: append before the social connection may ACK. */
2259
+ t: 'collaboration/events/append';
2260
+ requestId: string;
2261
+ serverUrl: string;
2262
+ userId: string;
2263
+ deliveries: RelayDelivery[];
2264
+ continuity?: RelayContinuityState;
2265
+ }
2266
+ | {
2267
+ /** Local Runtime only: rebuild UI projections from the durable event log. */
2268
+ t: 'collaboration/events/load';
2269
+ requestId: string;
2270
+ serverUrl: string;
2271
+ userId: string;
2272
+ conversation?: CollaborationConversationRef;
2273
+ }
2274
+ | {
2275
+ t: 'collaboration/events/find';
2276
+ requestId: string;
2277
+ serverUrl: string;
2278
+ userId: string;
2279
+ eventIds: string[];
2280
+ }
1370
2281
  | { t: 'workspace/register'; requestId: string; path: string }
1371
2282
  | { t: 'browseDir'; path?: string }
1372
2283
  | { t: 'file/browse'; requestId: string; path?: string }
@@ -1380,19 +2291,47 @@ export type ClientFrame =
1380
2291
  | { t: 'copySession'; dir: string; sessionId: string; title?: string }
1381
2292
  | { t: 'deleteSession'; dir: string; sessionId: string }
1382
2293
  | { t: 'config/get' }
1383
- | { t: 'config/update'; requestId: string; revision?: number; patch: WebchatConfigPatch }
1384
- | { t: 'config/autosave'; requestId: string; revision?: number; section: ConfigAutosaveSection; patch: WebchatConfigPatch }
2294
+ | {
2295
+ t: 'config/update';
2296
+ requestId: string;
2297
+ revision?: number;
2298
+ patch: WebchatConfigPatch;
2299
+ }
2300
+ | {
2301
+ t: 'config/autosave';
2302
+ requestId: string;
2303
+ revision?: number;
2304
+ section: ConfigAutosaveSection;
2305
+ patch: WebchatConfigPatch;
2306
+ }
1385
2307
  | { t: 'config/tool/test'; tool: ToolConfigName }
1386
2308
  /**
1387
2309
  * 模型列表条目的连通性测试——跟 config/tool/test 同一先例的延伸(测试从来不是配置变更,
1388
2310
  * 一直走独立于 patch 的姊妹帧),只是模型是开放式按 id 索引的动态集合,ToolConfigName
1389
2311
  * 的封闭枚举表达不了。modelId 测已保存条目;draft 测弹窗里还没提交的正在填写的值。
1390
2312
  */
1391
- | { t: 'config/model/test'; requestId: string; modelId?: string; draft?: { apiFormat: ApiFormat; baseURL: string; apiKey?: string; model: string } }
2313
+ | {
2314
+ t: 'config/model/test';
2315
+ requestId: string;
2316
+ modelId?: string;
2317
+ draft?: {
2318
+ apiFormat: ApiFormat;
2319
+ baseURL: string;
2320
+ apiKey?: string;
2321
+ model: string;
2322
+ };
2323
+ }
1392
2324
  | { t: 'getSkills'; dir?: string }
1393
2325
  | { t: 'resource/crons/list'; filter?: CronListFilter }
1394
2326
  | { t: 'resource/crons/show'; id: string }
1395
- | { t: 'resource/crons/draft'; requestId: string; text: string; cwd?: string; sessionId?: string; model?: string }
2327
+ | {
2328
+ t: 'resource/crons/draft';
2329
+ requestId: string;
2330
+ text: string;
2331
+ cwd?: string;
2332
+ sessionId?: string;
2333
+ model?: string;
2334
+ }
1396
2335
  | { t: 'resource/crons/create'; requestId: string; task: CronTaskDraft }
1397
2336
  | { t: 'resource/crons/update'; requestId: string; patch: CronTaskPatch }
1398
2337
  | { t: 'resource/crons/delete'; requestId: string; id: string }
@@ -1412,39 +2351,149 @@ export type ClientFrame =
1412
2351
  | { t: 'conversation/navigation/get' }
1413
2352
  | { t: 'conversation/open'; conversationId: string }
1414
2353
  | { t: 'conversation/start'; friendUserId: string }
1415
- | { t: 'conversation/send'; conversationId: string; text: string; attachments?: string[] }
1416
- | { t: 'conversation/history'; conversationId: string; beforeId?: string; limit?: number }
2354
+ | {
2355
+ t: 'conversation/send';
2356
+ conversationId: string;
2357
+ text: string;
2358
+ attachments?: string[];
2359
+ requestId?: string;
2360
+ }
2361
+ | {
2362
+ t: 'conversation/history';
2363
+ conversationId: string;
2364
+ beforeId?: string;
2365
+ limit?: number;
2366
+ }
1417
2367
  | { t: 'agent/direct/open'; workspaceSessionId: string }
1418
2368
  | { t: 'agent/direct/send'; workspaceSessionId: string; text: string }
1419
2369
  | { t: 'agent/direct/abort'; workspaceSessionId: string }
1420
- | { t: 'conversation/actions/suggest'; kind: 'group' | 'direct' | 'agent'; id: string }
2370
+ | {
2371
+ t: 'conversation/actions/suggest';
2372
+ kind: 'group' | 'direct' | 'agent';
2373
+ id: string;
2374
+ }
1421
2375
  | { t: 'node/pairing/create'; name: string }
1422
2376
  | { t: 'node/list' }
1423
2377
  | { t: 'workspace/list' }
1424
2378
  | { t: 'conversation/workspace/open'; conversation: ConversationRef }
1425
- | { t: 'conversation/task/save'; conversation: ConversationRef; task: Omit<WorkItemDraft, 'projectId'> }
1426
- | { t: 'conversation/task/delete'; conversation: ConversationRef; taskId: string }
1427
- | { t: 'conversation/decision/save'; conversation: ConversationRef; decision: Omit<ProjectDecision, 'id' | 'projectId' | 'createdAt' | 'updatedAt' | 'createdBy'> & { id?: string } }
1428
- | { t: 'conversation/handoff/save'; conversation: ConversationRef; handoff: Omit<ProjectHandoff, 'id' | 'projectId' | 'createdAt' | 'updatedAt'> & { id?: string } }
1429
- | { t: 'conversation/handoff/status'; conversation: ConversationRef; handoffId: string; status: HandoffStatus }
1430
- | { t: 'conversation/repository/add'; conversation: ConversationRef; provider: ProjectProvider; remoteUrl: string; defaultBranch: string; name?: string }
1431
- | { t: 'conversation/repository/remove'; conversation: ConversationRef; repositoryId: string }
1432
- | { t: 'conversation/artifact/save'; conversation: ConversationRef; artifact: Omit<ProjectArtifact, 'id' | 'projectId' | 'createdAt' | 'createdBy'> & { id?: string } }
1433
- | { t: 'conversation/artifact/delete'; conversation: ConversationRef; artifactId: string }
2379
+ | {
2380
+ t: 'conversation/task/save';
2381
+ conversation: ConversationRef;
2382
+ task: Omit<WorkItemDraft, 'projectId'>;
2383
+ }
2384
+ | {
2385
+ t: 'conversation/task/delete';
2386
+ conversation: ConversationRef;
2387
+ taskId: string;
2388
+ }
2389
+ | {
2390
+ t: 'conversation/decision/save';
2391
+ conversation: ConversationRef;
2392
+ decision: Omit<
2393
+ ProjectDecision,
2394
+ 'id' | 'projectId' | 'createdAt' | 'updatedAt' | 'createdBy'
2395
+ > & { id?: string };
2396
+ }
2397
+ | {
2398
+ t: 'conversation/handoff/save';
2399
+ conversation: ConversationRef;
2400
+ handoff: Omit<
2401
+ ProjectHandoff,
2402
+ 'id' | 'projectId' | 'createdAt' | 'updatedAt'
2403
+ > & { id?: string };
2404
+ }
2405
+ | {
2406
+ t: 'conversation/handoff/status';
2407
+ conversation: ConversationRef;
2408
+ handoffId: string;
2409
+ status: HandoffStatus;
2410
+ }
2411
+ | {
2412
+ t: 'conversation/repository/add';
2413
+ conversation: ConversationRef;
2414
+ provider: ProjectProvider;
2415
+ remoteUrl: string;
2416
+ defaultBranch: string;
2417
+ name?: string;
2418
+ }
2419
+ | {
2420
+ t: 'conversation/repository/remove';
2421
+ conversation: ConversationRef;
2422
+ repositoryId: string;
2423
+ }
2424
+ | {
2425
+ t: 'conversation/artifact/save';
2426
+ conversation: ConversationRef;
2427
+ artifact: Omit<
2428
+ ProjectArtifact,
2429
+ 'id' | 'projectId' | 'createdAt' | 'createdBy'
2430
+ > & { id?: string };
2431
+ }
2432
+ | {
2433
+ t: 'conversation/artifact/delete';
2434
+ conversation: ConversationRef;
2435
+ artifactId: string;
2436
+ }
1434
2437
  | { t: 'group/list' }
1435
- | { t: 'group/create'; name: string; memberIds?: string[]; workspaceSessionIds?: string[] }
2438
+ | {
2439
+ t: 'group/create';
2440
+ name: string;
2441
+ memberIds: string[];
2442
+ workspaceSessionIds?: string[];
2443
+ }
1436
2444
  | { t: 'group/rename'; groupId: string; name: string }
1437
2445
  | { t: 'group/setAnnouncement'; groupId: string; announcement: string }
1438
2446
  | { t: 'group/transferOwner'; groupId: string; newOwnerUserId: string }
1439
2447
  | { t: 'group/delete'; groupId: string }
1440
2448
  | { t: 'group/addHuman'; groupId: string; friendUserId: string }
1441
- | { t: 'group/addAgent'; groupId: string; workspaceSessionId: string }
1442
- | { t: 'group/setMemberPolicy'; groupId: string; memberId: string; policy: 'mention' | 'proactive' | 'all' | 'disabled' }
2449
+ /**
2450
+ * 把一个已有 Session Agent 拉进群。群聊和工作目录私聊共用同一 Session,
2451
+ * 只替换当前回合的会话模式提示词与可用工具集。
2452
+ * `workspaceAgentId` 仅保留给旧客户端兼容,不应再由新 UI 发出。
2453
+ */
2454
+ | {
2455
+ t: 'group/addAgent';
2456
+ groupId: string;
2457
+ workspaceSessionId?: string;
2458
+ workspaceAgentId?: string;
2459
+ }
2460
+ | {
2461
+ t: 'group/setMemberPolicy';
2462
+ groupId: string;
2463
+ memberId: string;
2464
+ policy: 'mention' | 'proactive' | 'all' | 'disabled';
2465
+ }
1443
2466
  | { t: 'group/removeMember'; groupId: string; memberId: string }
2467
+ /** 叫停某个 agent 成员当前的活(只停这一次,不改它以后是否响应)。 */
2468
+ | { t: 'group/abort'; groupId: string; memberId: string }
1444
2469
  | { t: 'group/open'; groupId: string }
1445
- | { t: 'group/send'; groupId: string; text: string; mentions?: string[]; attachments?: string[] }
2470
+ | {
2471
+ t: 'group/send';
2472
+ groupId: string;
2473
+ text: string;
2474
+ mentions?: string[];
2475
+ attachments?: string[];
2476
+ requestId?: string;
2477
+ }
1446
2478
  | { t: 'group/history'; groupId: string; beforeId?: string; limit?: number }
1447
2479
  | { t: 'group/read'; groupId: string; messageId: string }
2480
+ | { t: 'relay/device/register'; installationId: string; label?: string }
2481
+ | { t: 'relay/pull'; limit?: number }
2482
+ | { t: 'relay/ack'; eventId: string }
2483
+ | { t: 'relay/gap/request'; ranges: RelayMissingRange[] }
2484
+ | {
2485
+ t: 'relay/repair';
2486
+ requestId: string;
2487
+ targetDeviceId: string;
2488
+ event: CollaborationEvent;
2489
+ }
2490
+ | { t: 'relay/publish'; requestId: string; event: CollaborationEventDraft }
2491
+ /** Publish a small set of related facts atomically (goal/confirmation/task). */
2492
+ | {
2493
+ t: 'relay/publishBatch';
2494
+ requestId: string;
2495
+ events: CollaborationEventDraft[];
2496
+ }
1448
2497
  | {
1449
2498
  /** owner 对跨机指令同意请求的裁决;remember 记住信任(免以后再问)。 */
1450
2499
  t: 'group/consentRespond';
@@ -1455,9 +2504,19 @@ export type ClientFrame =
1455
2504
  readScopes?: string[];
1456
2505
  capabilities?: string[];
1457
2506
  }
2507
+ | {
2508
+ /** Agent 主人主动撤销一项已批准的授权,并停止仍在运行的对应投递。 */
2509
+ t: 'group/consentRevoke';
2510
+ requestId: string;
2511
+ }
1458
2512
  | { t: 'agent/answer'; requestId: string; answers: AskAnswer[] }
1459
2513
  | { t: 'agent/questionCancel'; requestId: string }
1460
- | { t: 'human-intervention/get'; requestId?: string; conversationKey?: string; runId?: string }
2514
+ | {
2515
+ t: 'human-intervention/get';
2516
+ requestId?: string;
2517
+ conversationKey?: string;
2518
+ runId?: string;
2519
+ }
1461
2520
  | {
1462
2521
  t: 'human-intervention/resume';
1463
2522
  requestId?: string;
@@ -1477,11 +2536,25 @@ export type ClientFrame =
1477
2536
  runId: string;
1478
2537
  }
1479
2538
  // ---- Browser automation frames (product-grade) ----
1480
- | { t: 'browser/context/set'; conversationKey: string; runId?: string; requestId?: string }
2539
+ | {
2540
+ t: 'browser/context/set';
2541
+ conversationKey: string;
2542
+ runId?: string;
2543
+ requestId?: string;
2544
+ }
1481
2545
  // Mode control
1482
- | { t: 'browser/start'; requestId?: string; headless?: boolean; viewport?: { width: number; height: number } }
2546
+ | {
2547
+ t: 'browser/start';
2548
+ requestId?: string;
2549
+ headless?: boolean;
2550
+ viewport?: { width: number; height: number };
2551
+ }
1483
2552
  | { t: 'browser/stop'; requestId?: string }
1484
- | { t: 'browser/mode'; mode: 'browse' | 'assist' | 'auto'; requestId?: string }
2553
+ | {
2554
+ t: 'browser/mode';
2555
+ mode: 'browse' | 'assist' | 'auto';
2556
+ requestId?: string;
2557
+ }
1485
2558
  | { t: 'browser/control/get'; requestId?: string }
1486
2559
  | { t: 'browser/control/takeover'; requestId?: string }
1487
2560
  | { t: 'browser/control/resume'; requestId?: string; resumeToken?: string }
@@ -1498,33 +2571,110 @@ export type ClientFrame =
1498
2571
  | { t: 'browser/reload'; requestId?: string }
1499
2572
  // AI interaction (Agent actions)
1500
2573
  | { t: 'browser/snapshot'; requestId?: string; interactive?: boolean }
1501
- | { t: 'browser/screenshot'; requestId?: string; annotate?: boolean; fullPage?: boolean; path?: string }
2574
+ | {
2575
+ t: 'browser/screenshot';
2576
+ requestId?: string;
2577
+ annotate?: boolean;
2578
+ fullPage?: boolean;
2579
+ path?: string;
2580
+ }
1502
2581
  | { t: 'browser/eval'; requestId?: string; js: string }
1503
- | { t: 'browser/click'; requestId?: string; selector: string; byRef?: boolean }
2582
+ | {
2583
+ t: 'browser/click';
2584
+ requestId?: string;
2585
+ selector: string;
2586
+ byRef?: boolean;
2587
+ }
1504
2588
  | { t: 'browser/fill'; requestId?: string; selector: string; value: string }
1505
2589
  | { t: 'browser/type'; requestId?: string; selector: string; value: string }
1506
2590
  | { t: 'browser/hover'; requestId?: string; selector: string }
1507
- | { t: 'browser/scroll'; requestId?: string; x?: number; y?: number; selector?: string; direction?: 'up' | 'down' | 'top' | 'bottom' }
1508
- | { t: 'browser/select'; requestId?: string; selector: string; value: string | string[] }
2591
+ | {
2592
+ t: 'browser/scroll';
2593
+ requestId?: string;
2594
+ x?: number;
2595
+ y?: number;
2596
+ selector?: string;
2597
+ direction?: 'up' | 'down' | 'top' | 'bottom';
2598
+ }
2599
+ | {
2600
+ t: 'browser/select';
2601
+ requestId?: string;
2602
+ selector: string;
2603
+ value: string | string[];
2604
+ }
1509
2605
  | { t: 'browser/press'; requestId?: string; key: string; selector?: string }
1510
- | { t: 'browser/wait'; requestId?: string; ms?: number; selector?: string; text?: string }
1511
- | { t: 'browser/upload'; requestId?: string; selector: string; files: string[] }
1512
- | { t: 'browser/drag'; requestId?: string; fromSelector: string; toSelector: string }
2606
+ | {
2607
+ t: 'browser/wait';
2608
+ requestId?: string;
2609
+ ms?: number;
2610
+ selector?: string;
2611
+ text?: string;
2612
+ }
2613
+ | {
2614
+ t: 'browser/upload';
2615
+ requestId?: string;
2616
+ selector: string;
2617
+ files: string[];
2618
+ }
2619
+ | {
2620
+ t: 'browser/drag';
2621
+ requestId?: string;
2622
+ fromSelector: string;
2623
+ toSelector: string;
2624
+ }
1513
2625
  // User input (browse mode - direct interaction via canvas)
1514
- | { t: 'browser/user/input'; eventType: 'mouseMoved' | 'mousePressed' | 'mouseReleased' | 'mouseWheel' | 'keyDown' | 'keyUp' | 'char'; x?: number; y?: number; button?: string; clickCount?: number; deltaX?: number; deltaY?: number; key?: string; code?: string; text?: string; modifiers?: number; windowsVirtualKeyCode?: number }
2626
+ | {
2627
+ t: 'browser/user/input';
2628
+ eventType:
2629
+ | 'mouseMoved'
2630
+ | 'mousePressed'
2631
+ | 'mouseReleased'
2632
+ | 'mouseWheel'
2633
+ | 'keyDown'
2634
+ | 'keyUp'
2635
+ | 'char';
2636
+ x?: number;
2637
+ y?: number;
2638
+ button?: string;
2639
+ clickCount?: number;
2640
+ deltaX?: number;
2641
+ deltaY?: number;
2642
+ key?: string;
2643
+ code?: string;
2644
+ text?: string;
2645
+ modifiers?: number;
2646
+ windowsVirtualKeyCode?: number;
2647
+ }
1515
2648
  // JS dialog handling (alert/confirm/prompt)
1516
2649
  | { t: 'browser/dialog/accept'; requestId?: string; text?: string }
1517
2650
  | { t: 'browser/dialog/dismiss'; requestId?: string }
1518
2651
  // Agent pointer visualization (sent FROM server to UI to show where AI is acting)
1519
2652
  // Element marking (UI markers / pick mode)
1520
2653
  | { t: 'browser/pick'; requestId?: string; x: number; y: number }
1521
- | { t: 'browser/mark/element'; requestId?: string; selector: string; label?: string; color?: string }
2654
+ | {
2655
+ t: 'browser/mark/element';
2656
+ requestId?: string;
2657
+ selector: string;
2658
+ label?: string;
2659
+ color?: string;
2660
+ }
1522
2661
  | { t: 'browser/mark/clear'; requestId?: string }
1523
2662
  | { t: 'browser/mark/mode'; enabled: boolean; requestId?: string }
1524
2663
  // Viewport & device
1525
2664
  | { t: 'browser/viewport'; width: number; height: number; requestId?: string }
1526
- | { t: 'browser/device'; preset?: string; width?: number; height?: number; requestId?: string }
1527
- | { t: 'browser/media'; scheme?: 'light' | 'dark' | 'no-preference'; offline?: boolean; requestId?: string }
2665
+ | {
2666
+ t: 'browser/device';
2667
+ preset?: string;
2668
+ width?: number;
2669
+ height?: number;
2670
+ requestId?: string;
2671
+ }
2672
+ | {
2673
+ t: 'browser/media';
2674
+ scheme?: 'light' | 'dark' | 'no-preference';
2675
+ offline?: boolean;
2676
+ requestId?: string;
2677
+ }
1528
2678
  // Recording
1529
2679
  | { t: 'browser/record/start'; requestId?: string; path?: string }
1530
2680
  | { t: 'browser/record/stop'; requestId?: string }
@@ -1533,7 +2683,16 @@ export type ClientFrame =
1533
2683
  | { t: 'browser/pdf'; requestId?: string; path?: string }
1534
2684
  // Cookies & auth
1535
2685
  | { t: 'browser/cookies/get'; requestId?: string }
1536
- | { t: 'browser/cookies/set'; requestId?: string; cookies: Array<{ name: string; value: string; domain?: string; path?: string }> }
2686
+ | {
2687
+ t: 'browser/cookies/set';
2688
+ requestId?: string;
2689
+ cookies: Array<{
2690
+ name: string;
2691
+ value: string;
2692
+ domain?: string;
2693
+ path?: string;
2694
+ }>;
2695
+ }
1537
2696
  | { t: 'browser/cookies/clear'; requestId?: string }
1538
2697
  | { t: 'browser/profile/clear'; requestId?: string }
1539
2698
  // Read-only developer diagnostics. Full CDP access remains a separate, disabled-by-default setting.
@@ -1545,21 +2704,70 @@ export type ClientFrame =
1545
2704
  | { t: 'browser/debug/trace/start'; requestId?: string }
1546
2705
  | { t: 'browser/debug/trace/stop'; requestId?: string; path?: string }
1547
2706
  // Agent pointer visualization control (sent to frontend to show agent cursor)
1548
- | { t: 'browser/agent/pointer'; x: number; y: number; visible: boolean; action?: 'move' | 'click' | 'type' | 'scroll' | 'idle' | 'hover'; elementRef?: string }
2707
+ | {
2708
+ t: 'browser/agent/pointer';
2709
+ x: number;
2710
+ y: number;
2711
+ visible: boolean;
2712
+ action?: 'move' | 'click' | 'type' | 'scroll' | 'idle' | 'hover';
2713
+ elementRef?: string;
2714
+ }
1549
2715
  // Native desktop Computer Use is controlled by the trusted host.
1550
- | { t: 'computer/status'; requestId?: string; conversationKey?: string; runId?: string }
2716
+ | {
2717
+ t: 'computer/status';
2718
+ requestId?: string;
2719
+ conversationKey?: string;
2720
+ runId?: string;
2721
+ }
1551
2722
  | { t: 'computer/permissions'; requestId?: string }
1552
- | { t: 'computer/observe'; requestId?: string; conversationKey: string; runId: string }
1553
- | { t: 'computer/control/takeover'; requestId?: string; conversationKey: string; runId: string }
1554
- | { t: 'computer/control/resume'; requestId?: string; conversationKey: string; runId: string; interventionId?: string; resumeToken?: string; ownerId?: string }
1555
- | { t: 'computer/control/stop'; requestId?: string; conversationKey: string; runId: string; interventionId?: string; resumeToken?: string; ownerId?: string }
2723
+ | {
2724
+ t: 'computer/observe';
2725
+ requestId?: string;
2726
+ conversationKey: string;
2727
+ runId: string;
2728
+ }
2729
+ | {
2730
+ t: 'computer/control/takeover';
2731
+ requestId?: string;
2732
+ conversationKey: string;
2733
+ runId: string;
2734
+ }
2735
+ | {
2736
+ t: 'computer/control/resume';
2737
+ requestId?: string;
2738
+ conversationKey: string;
2739
+ runId: string;
2740
+ interventionId?: string;
2741
+ resumeToken?: string;
2742
+ ownerId?: string;
2743
+ }
2744
+ | {
2745
+ t: 'computer/control/stop';
2746
+ requestId?: string;
2747
+ conversationKey: string;
2748
+ runId: string;
2749
+ interventionId?: string;
2750
+ resumeToken?: string;
2751
+ ownerId?: string;
2752
+ }
1556
2753
  | { t: 'computer/control/emergency-stop-all'; requestId?: string }
1557
2754
  // 终端不走 WS:改由 Tauri 原生真 PTY(minimal-desktop src-tauri/src/pty.rs)承载。
1558
2755
  // ---- 工作台任意路径文件预览(工作目录内) ----
1559
2756
  | { t: 'file/preview/open'; requestId: string; path: string };
1560
2757
 
1561
2758
  export type ServerFrame =
1562
- | { t: 'runtime/hello'; protocolVersion: number; runtimeVersion: string; capabilities: string[] }
2759
+ | {
2760
+ t: 'runtime/hello';
2761
+ protocolVersion: number;
2762
+ runtimeVersion: string;
2763
+ capabilities: string[];
2764
+ }
2765
+ | {
2766
+ t: 'goal/snapshot';
2767
+ requestId: string;
2768
+ goal?: import('../goal/types.js').Goal;
2769
+ error?: string;
2770
+ }
1563
2771
  | {
1564
2772
  t: 'human-intervention/started' | 'human-intervention/changed';
1565
2773
  intervention: PendingHumanInterventionSummary & {
@@ -1589,103 +2797,511 @@ export type ServerFrame =
1589
2797
  runSnapshot?: ConversationRunSnapshot;
1590
2798
  contextUsage?: Extract<LoopEvent, { type: 'context_usage' }>;
1591
2799
  }
1592
- | { t: 'conversation/delivery/changed'; conversationKey: string; delivery: ConversationDelivery }
1593
- | { t: 'conversation/assets/changed'; conversationKey: string; assets: ConversationAsset[] }
1594
- | { t: 'resource/files/list'; dir: string; sessionId: string; files: ConversationFileRef[] }
1595
- | { t: 'resource/assets/list'; requestId: string; conversationKey: string; assets?: ConversationAsset[]; error?: string }
1596
- | { t: 'resource/assets/pinned'; requestId: string; ok: boolean; error?: string }
1597
- | { t: 'resource/assets/opened'; requestId: string; ref?: ConversationFileRef; error?: string }
1598
- | { t: 'resource/assets/revealed'; requestId: string; ok: boolean; error?: string }
1599
- | { t: 'resource/files/opened'; requestId: string; ref?: ConversationFileRef; error?: string }
1600
- | { t: 'resource/files/revealed'; requestId: string; ok: boolean; error?: string }
1601
- | { t: 'resource/memories'; records: MemoryRecord[]; settings: MemorySettings; workspaceId?: string; reviewRecords?: MemoryRecord[]; persona?: PersonaDocument | null }
1602
- | { t: 'resource/memories/conversations'; requestId: string; results: ConversationSearchResult[]; error?: string }
1603
- | { t: 'resource/memories/manage/state'; requestId: string; state: MemoryManagementState }
1604
- | { t: 'resource/memories/manage/result'; requestId: string; action: MemoryManagementAction; ok: boolean; state?: MemoryManagementState; error?: string; conflict?: boolean }
1605
- | { t: 'resource/memories/overview'; requestId: string; overview?: MemoryCenterOverview; error?: string }
1606
- | { t: 'resource/memories/topics'; requestId: string; page?: MemoryTopicPage; error?: string; errorCode?: 'stale_cursor' }
1607
- | { t: 'resource/memories/topic'; requestId: string; detail?: MemoryTopicDetail; error?: string }
1608
- | { t: 'resource/context/status'; requestId: string; status?: ContextStatusView; error?: string }
1609
- | { t: 'resource/subagents/worktree/result'; requestId: string; action: 'diff' | 'apply' | 'discard'; ok: boolean; id: string; diff?: string; changedFiles?: string[]; error?: string }
1610
- | { t: 'ready'; dirs: RecentDir[]; workspaceIndex?: WorkspaceTreeEntry[]; defaultDir?: string; localAttachmentToken?: string }
2800
+ | {
2801
+ t: 'conversation/delivery/changed';
2802
+ conversationKey: string;
2803
+ delivery: ConversationDelivery;
2804
+ }
2805
+ | {
2806
+ t: 'conversation/assets/changed';
2807
+ conversationKey: string;
2808
+ assets: ConversationAsset[];
2809
+ }
2810
+ | {
2811
+ t: 'resource/files/list';
2812
+ dir: string;
2813
+ sessionId: string;
2814
+ files: ConversationFileRef[];
2815
+ }
2816
+ | {
2817
+ t: 'resource/assets/list';
2818
+ requestId: string;
2819
+ conversationKey: string;
2820
+ assets?: ConversationAsset[];
2821
+ error?: string;
2822
+ }
2823
+ | {
2824
+ t: 'resource/assets/pinned';
2825
+ requestId: string;
2826
+ ok: boolean;
2827
+ error?: string;
2828
+ }
2829
+ | {
2830
+ t: 'resource/assets/opened';
2831
+ requestId: string;
2832
+ ref?: ConversationFileRef;
2833
+ error?: string;
2834
+ }
2835
+ | {
2836
+ t: 'resource/assets/revealed';
2837
+ requestId: string;
2838
+ ok: boolean;
2839
+ error?: string;
2840
+ }
2841
+ | {
2842
+ t: 'resource/files/opened';
2843
+ requestId: string;
2844
+ ref?: ConversationFileRef;
2845
+ error?: string;
2846
+ }
2847
+ | {
2848
+ t: 'resource/files/revealed';
2849
+ requestId: string;
2850
+ ok: boolean;
2851
+ error?: string;
2852
+ }
2853
+ | {
2854
+ t: 'resource/memories';
2855
+ records: MemoryRecord[];
2856
+ settings: MemorySettings;
2857
+ workspaceId?: string;
2858
+ reviewRecords?: MemoryRecord[];
2859
+ persona?: PersonaDocument | null;
2860
+ }
2861
+ | {
2862
+ t: 'resource/memories/conversations';
2863
+ requestId: string;
2864
+ results: ConversationSearchResult[];
2865
+ error?: string;
2866
+ }
2867
+ | {
2868
+ t: 'resource/memories/manage/state';
2869
+ requestId: string;
2870
+ state: MemoryManagementState;
2871
+ }
2872
+ | {
2873
+ t: 'resource/memories/manage/result';
2874
+ requestId: string;
2875
+ action: MemoryManagementAction;
2876
+ ok: boolean;
2877
+ state?: MemoryManagementState;
2878
+ error?: string;
2879
+ conflict?: boolean;
2880
+ }
2881
+ | {
2882
+ t: 'resource/memories/overview';
2883
+ requestId: string;
2884
+ overview?: MemoryCenterOverview;
2885
+ error?: string;
2886
+ }
2887
+ | {
2888
+ t: 'resource/memories/topics';
2889
+ requestId: string;
2890
+ page?: MemoryTopicPage;
2891
+ error?: string;
2892
+ errorCode?: 'stale_cursor';
2893
+ }
2894
+ | {
2895
+ t: 'resource/memories/topic';
2896
+ requestId: string;
2897
+ detail?: MemoryTopicDetail;
2898
+ error?: string;
2899
+ }
2900
+ | {
2901
+ t: 'resource/context/status';
2902
+ requestId: string;
2903
+ status?: ContextStatusView;
2904
+ error?: string;
2905
+ }
2906
+ | {
2907
+ t: 'resource/subagents/worktree/result';
2908
+ requestId: string;
2909
+ action: 'diff' | 'apply' | 'discard';
2910
+ ok: boolean;
2911
+ id: string;
2912
+ diff?: string;
2913
+ changedFiles?: string[];
2914
+ error?: string;
2915
+ }
2916
+ | {
2917
+ t: 'ready';
2918
+ dirs: RecentDir[];
2919
+ workspaceIndex?: WorkspaceTreeEntry[];
2920
+ defaultDir?: string;
2921
+ localAttachmentToken?: string;
2922
+ }
1611
2923
  | { t: 'workspace/index'; workspaces: WorkspaceTreeEntry[] }
1612
2924
  | { t: 'workspace/index/changed'; workspaces: WorkspaceTreeEntry[] }
1613
- | { t: 'workspace/recovery'; applied: boolean; workspaces: number; sessions: number; recoverable: Array<{ fileName: string; reason: string; suggestedPath?: string }> }
2925
+ | {
2926
+ t: 'workspace/recovery';
2927
+ applied: boolean;
2928
+ workspaces: number;
2929
+ sessions: number;
2930
+ recoverable: Array<{
2931
+ fileName: string;
2932
+ reason: string;
2933
+ suggestedPath?: string;
2934
+ }>;
2935
+ }
1614
2936
  | { t: 'social/cache'; serverUrl: string; cache: OfflineSocialCache | null }
2937
+ | {
2938
+ t: 'social/outbox';
2939
+ requestId: string;
2940
+ serverUrl: string;
2941
+ userId: string;
2942
+ items: SocialOutboxItem[];
2943
+ }
2944
+ | {
2945
+ t: 'collaboration/outbox';
2946
+ requestId: string;
2947
+ serverUrl: string;
2948
+ userId: string;
2949
+ items: CollaborationOutboxItem[];
2950
+ }
2951
+ | {
2952
+ t: 'collaboration/read';
2953
+ requestId: string;
2954
+ cursors: Record<string, ReadCursor>;
2955
+ }
2956
+ | {
2957
+ t: 'collaboration/device';
2958
+ requestId: string;
2959
+ installationId: string;
2960
+ label: string;
2961
+ }
2962
+ | {
2963
+ t: 'collaboration/events/persisted';
2964
+ requestId: string;
2965
+ eventIds: string[];
2966
+ continuity?: LocalRelayContinuity;
2967
+ }
2968
+ | {
2969
+ t: 'collaboration/events';
2970
+ requestId: string;
2971
+ events: CollaborationEvent[];
2972
+ }
2973
+ | {
2974
+ t: 'collaboration/events/found';
2975
+ requestId: string;
2976
+ events: CollaborationEvent[];
2977
+ }
1615
2978
  | { t: 'dirs'; dirs: RecentDir[] }
1616
- | { t: 'workspace/registered'; requestId: string; dir?: RecentDir; dirs?: RecentDir[]; error?: string }
2979
+ /** 局域网发现结果;空数组 = 没找到(网络受限时也走这条,不是错误)。 */
2980
+ | {
2981
+ t: 'server/discovered';
2982
+ servers: Array<{
2983
+ url: string;
2984
+ version: string;
2985
+ protocolVersion: number;
2986
+ /** 同一台服务器的其它网卡地址;首选地址不通时可切换,不必重搜。 */
2987
+ alternativeUrls: string[];
2988
+ }>;
2989
+ }
2990
+ | {
2991
+ t: 'workspace/registered';
2992
+ requestId: string;
2993
+ dir?: RecentDir;
2994
+ dirs?: RecentDir[];
2995
+ error?: string;
2996
+ }
1617
2997
  | { t: 'dirListing'; listing: DirListing }
1618
2998
  | { t: 'archives'; dir: string; entries: ArchiveEntry[] }
1619
2999
  | { t: 'sessions'; dir: string; sessions: SessionSummary[] }
1620
3000
  | { t: 'history'; dir: string; sessionId?: string; messages: Message[] }
1621
- | { t: 'event'; event: AgentEvent; dir?: string; sessionId: string; runId: string; sequence?: number }
3001
+ | {
3002
+ t: 'event';
3003
+ event: AgentEvent;
3004
+ dir?: string;
3005
+ sessionId: string;
3006
+ runId: string;
3007
+ sequence?: number;
3008
+ }
1622
3009
  | { t: 'conversation/run/snapshot'; snapshot: ConversationRunSnapshot }
1623
- | { t: 'conversation/run/changed'; snapshots: ConversationRunSnapshot[]; maxConcurrent: number }
3010
+ | {
3011
+ t: 'conversation/run/changed';
3012
+ snapshots: ConversationRunSnapshot[];
3013
+ maxConcurrent: number;
3014
+ }
1624
3015
  | { t: 'input/queue/changed'; items: QueuedUserInput[] }
1625
3016
  | { t: 'input/queue/started'; item: QueuedUserInput }
1626
3017
  | { t: 'config'; config: WebchatConfig | null }
1627
- | { t: 'config/updated'; requestId: string; revision: number; config: WebchatConfig }
1628
- | { t: 'config/autosaved'; requestId: string; revision: number; state: 'applied' | 'draft'; config: WebchatConfig; draftFields?: string[] }
1629
- | { t: 'config/update-failed'; requestId: string; message: string; fieldErrors?: Record<string, string>; currentRevision?: number }
1630
- | { t: 'config/tool/tested'; tool: ToolConfigName; ok: boolean; message: string }
1631
- | { t: 'config/model/tested'; requestId: string; ok: boolean; message: string }
3018
+ | {
3019
+ t: 'config/updated';
3020
+ requestId: string;
3021
+ revision: number;
3022
+ config: WebchatConfig;
3023
+ }
3024
+ | {
3025
+ t: 'config/autosaved';
3026
+ requestId: string;
3027
+ revision: number;
3028
+ state: 'applied' | 'draft';
3029
+ config: WebchatConfig;
3030
+ draftFields?: string[];
3031
+ }
3032
+ | {
3033
+ t: 'config/update-failed';
3034
+ requestId: string;
3035
+ message: string;
3036
+ fieldErrors?: Record<string, string>;
3037
+ currentRevision?: number;
3038
+ }
3039
+ | {
3040
+ t: 'config/tool/tested';
3041
+ tool: ToolConfigName;
3042
+ ok: boolean;
3043
+ message: string;
3044
+ }
3045
+ | {
3046
+ t: 'config/model/tested';
3047
+ requestId: string;
3048
+ ok: boolean;
3049
+ message: string;
3050
+ }
1632
3051
  | { t: 'skills'; skills: SkillInfo[] }
1633
3052
  | { t: 'server_error'; message: string }
1634
3053
  | { t: 'resource/crons/list'; tasks: CronTaskWithRuns[]; missedCount: number }
1635
3054
  | { t: 'resource/crons/draft'; draft: CronDraftResult }
1636
3055
  | { t: 'resource/crons/show'; task: CronTaskWithRuns | null }
1637
3056
  | { t: 'resource/crons/missed'; missed: CronMissedRecord[] }
1638
- | { t: 'resource/crons/changed'; tasks: CronTaskWithRuns[]; missedCount: number }
3057
+ | {
3058
+ t: 'resource/crons/changed';
3059
+ tasks: CronTaskWithRuns[];
3060
+ missedCount: number;
3061
+ }
1639
3062
  | { t: 'resource/commands/list'; commands: CommandDescriptor[] }
1640
3063
  | { t: 'social/me'; user: UserProfile | null }
1641
3064
  | { t: 'social/friends'; friends: FriendEntry[] }
1642
3065
  | { t: 'social/searchResults'; users: UserProfile[] }
1643
- | { t: 'social/error'; message: string }
3066
+ | { t: 'social/error'; message: string; requestId?: string }
1644
3067
  | { t: 'conversation/list'; conversations: DirectConversationSummary[] }
1645
3068
  | { t: 'conversation/navigation'; navigation: ConversationNavigation }
1646
3069
  | { t: 'conversation/detail'; conversation: DirectConversationSummary }
1647
- | { t: 'conversation/message'; conversationId: string; message: DirectChatMessage }
1648
- | { t: 'conversation/history'; conversationId: string; messages: DirectChatMessage[]; hasMore: boolean }
1649
- | { t: 'agent/direct/history'; workspaceSessionId: string; messages: AgentDirectMessage[] }
1650
- | { t: 'agent/direct/message'; workspaceSessionId: string; message: AgentDirectMessage }
3070
+ | {
3071
+ t: 'conversation/message';
3072
+ conversationId: string;
3073
+ message: DirectChatMessage;
3074
+ }
3075
+ | {
3076
+ t: 'conversation/sent';
3077
+ requestId: string;
3078
+ conversationId: string;
3079
+ message: DirectChatMessage;
3080
+ }
3081
+ | {
3082
+ t: 'conversation/history';
3083
+ conversationId: string;
3084
+ messages: DirectChatMessage[];
3085
+ hasMore: boolean;
3086
+ }
3087
+ | {
3088
+ t: 'agent/direct/history';
3089
+ workspaceSessionId: string;
3090
+ messages: AgentDirectMessage[];
3091
+ }
3092
+ | {
3093
+ t: 'agent/direct/message';
3094
+ workspaceSessionId: string;
3095
+ message: AgentDirectMessage;
3096
+ }
1651
3097
  | { t: 'agent/direct/event'; workspaceSessionId: string; event: AgentEvent }
1652
3098
  | { t: 'agent/direct/error'; workspaceSessionId?: string; message: string }
1653
- | { t: 'conversation/actions'; kind: 'group' | 'direct' | 'agent'; id: string; actions: ConversationActionSuggestion[] }
3099
+ | {
3100
+ t: 'conversation/actions';
3101
+ kind: 'group' | 'direct' | 'agent';
3102
+ id: string;
3103
+ actions: ConversationActionSuggestion[];
3104
+ }
1654
3105
  | { t: 'node/pairing'; code: string; expiresAt: number }
1655
3106
  | { t: 'node/list'; nodes: AgentNodeSummary[] }
1656
- | { t: 'workspace/list'; agents: WorkspaceAgent[]; sessions: WorkspaceSessionAgent[] }
3107
+ | {
3108
+ t: 'workspace/list';
3109
+ agents: WorkspaceAgent[];
3110
+ sessions: WorkspaceSessionAgent[];
3111
+ }
1657
3112
  | { t: 'conversation/workspace'; workspace: ConversationWorkspace | null }
1658
3113
  | { t: 'conversation/workspace/error'; message: string }
1659
3114
  | { t: 'group/list'; groups: GroupSummary[] }
1660
3115
  | { t: 'group/detail'; group: GroupDetail }
1661
3116
  | { t: 'group/message'; groupId: string; message: GroupChatMessage }
1662
- | { t: 'group/history'; groupId: string; messages: GroupChatMessage[]; hasMore: boolean }
3117
+ | {
3118
+ t: 'group/sent';
3119
+ requestId: string;
3120
+ groupId: string;
3121
+ message: GroupChatMessage;
3122
+ }
3123
+ | {
3124
+ t: 'group/history';
3125
+ groupId: string;
3126
+ messages: GroupChatMessage[];
3127
+ hasMore: boolean;
3128
+ }
3129
+ | {
3130
+ t: 'relay/device/registered';
3131
+ deviceId: string;
3132
+ /** This device cannot receive relay history authored before this instant. */
3133
+ historyStartsAt: number;
3134
+ /** True only when this installation was first enrolled for the account. */
3135
+ newDevice: boolean;
3136
+ }
3137
+ | {
3138
+ t: 'relay/events';
3139
+ deliveries: RelayDelivery[];
3140
+ continuity?: RelayContinuityState;
3141
+ }
3142
+ | {
3143
+ t: 'relay/gap/candidates';
3144
+ targetDeviceId: string;
3145
+ candidates: RelayGapCandidate[];
3146
+ }
3147
+ | { t: 'relay/gap/requested'; request: RelayGapRepairRequest }
3148
+ | {
3149
+ t: 'relay/repaired';
3150
+ requestId: string;
3151
+ eventId: string;
3152
+ targetDeviceId: string;
3153
+ }
3154
+ | { t: 'relay/published'; requestId: string; eventId: string }
3155
+ | { t: 'relay/publishedBatch'; requestId: string; eventIds: string[] }
3156
+ | { t: 'relay/acked'; eventId: string }
3157
+ | {
3158
+ t: 'relay/error';
3159
+ code: string;
3160
+ message: string;
3161
+ retryable: boolean;
3162
+ requestId?: string;
3163
+ }
1663
3164
  /** agent 回合的流式预览增量(只推给正打开该群的连接);尽力而为,最终 group/message 是真值。 */
1664
- | { t: 'group/agentStream'; groupId: string; agentMemberId: string; displayName: string; delta: string }
3165
+ | {
3166
+ t: 'group/agentStream';
3167
+ groupId: string;
3168
+ agentMemberId: string;
3169
+ displayName: string;
3170
+ delta: string;
3171
+ }
1665
3172
  | UserSocialEvent
1666
3173
  // ---- Browser automation server frames (product-grade) ----
1667
- | { t: 'browser/context/changed'; requestId?: string; conversationKey: string; runId: string; tabId?: string }
1668
- | { t: 'browser/started'; requestId?: string; streamPort: number; pid?: number; sessionId?: string; conversationKey?: string; runId?: string }
3174
+ | {
3175
+ t: 'browser/context/changed';
3176
+ requestId?: string;
3177
+ conversationKey: string;
3178
+ runId: string;
3179
+ tabId?: string;
3180
+ }
3181
+ | {
3182
+ t: 'browser/started';
3183
+ requestId?: string;
3184
+ streamPort: number;
3185
+ pid?: number;
3186
+ sessionId?: string;
3187
+ conversationKey?: string;
3188
+ runId?: string;
3189
+ }
1669
3190
  | { t: 'browser/stopped'; requestId?: string }
1670
- | { t: 'browser/mode'; mode: 'browse' | 'assist' | 'auto'; requestId?: string }
1671
- | { t: 'browser/status'; connected: boolean; screencasting: boolean; viewportWidth: number; viewportHeight: number; engine: string; recording?: boolean; mode?: 'browse' | 'assist' | 'auto'; url?: string; title?: string }
1672
- | { t: 'browser/frame'; data: string; metadata?: Record<string, unknown>; sessionId?: string; tabId?: string; conversationKey?: string; runId?: string; frameWidth?: number; frameHeight?: number; viewportWidth?: number; viewportHeight?: number; deviceScaleFactor?: number; pageRevision?: string }
1673
- | { t: 'browser/tabs'; tabs: Array<{ id: string; url: string; title?: string; active: boolean; favicon?: string }>; timestamp?: number }
3191
+ | {
3192
+ t: 'browser/mode';
3193
+ mode: 'browse' | 'assist' | 'auto';
3194
+ requestId?: string;
3195
+ }
3196
+ | {
3197
+ t: 'browser/status';
3198
+ connected: boolean;
3199
+ screencasting: boolean;
3200
+ viewportWidth: number;
3201
+ viewportHeight: number;
3202
+ engine: string;
3203
+ recording?: boolean;
3204
+ mode?: 'browse' | 'assist' | 'auto';
3205
+ url?: string;
3206
+ title?: string;
3207
+ }
3208
+ | {
3209
+ t: 'browser/frame';
3210
+ data: string;
3211
+ metadata?: Record<string, unknown>;
3212
+ sessionId?: string;
3213
+ tabId?: string;
3214
+ conversationKey?: string;
3215
+ runId?: string;
3216
+ frameWidth?: number;
3217
+ frameHeight?: number;
3218
+ viewportWidth?: number;
3219
+ viewportHeight?: number;
3220
+ deviceScaleFactor?: number;
3221
+ pageRevision?: string;
3222
+ }
3223
+ | {
3224
+ t: 'browser/tabs';
3225
+ tabs: Array<{
3226
+ id: string;
3227
+ url: string;
3228
+ title?: string;
3229
+ active: boolean;
3230
+ favicon?: string;
3231
+ }>;
3232
+ timestamp?: number;
3233
+ }
1674
3234
  | { t: 'browser/tab/activated'; tabId: string }
1675
3235
  | { t: 'browser/url'; url: string; tabId?: string }
1676
3236
  | { t: 'browser/title'; title: string; tabId?: string }
1677
- | { t: 'browser/navigation'; url: string; state: 'start' | 'commit' | 'load' | 'domcontentloaded' }
3237
+ | {
3238
+ t: 'browser/navigation';
3239
+ url: string;
3240
+ state: 'start' | 'commit' | 'load' | 'domcontentloaded';
3241
+ }
1678
3242
  | { t: 'browser/console'; level?: string; text: string; source?: string }
1679
3243
  | { t: 'browser/page_error'; text: string }
1680
- | { t: 'browser/download'; url: string; filename?: string; path?: string; state: 'start' | 'progress' | 'complete' | 'canceled'; receivedBytes?: number; totalBytes?: number }
1681
- | { t: 'browser/dialog'; type: 'alert' | 'confirm' | 'prompt' | 'beforeunload'; message: string; defaultValue?: string }
3244
+ | {
3245
+ t: 'browser/download';
3246
+ url: string;
3247
+ filename?: string;
3248
+ path?: string;
3249
+ state: 'start' | 'progress' | 'complete' | 'failed' | 'canceled';
3250
+ id?: string;
3251
+ mime?: string;
3252
+ error?: string;
3253
+ receivedBytes?: number;
3254
+ totalBytes?: number;
3255
+ }
3256
+ | {
3257
+ t: 'browser/dialog';
3258
+ type: 'alert' | 'confirm' | 'prompt' | 'beforeunload';
3259
+ message: string;
3260
+ defaultValue?: string;
3261
+ }
1682
3262
  | { t: 'browser/snapshot'; requestId?: string; tree: string }
1683
- | { t: 'browser/screenshot'; requestId?: string; path?: string; data?: string; error?: string }
3263
+ | {
3264
+ t: 'browser/screenshot';
3265
+ requestId?: string;
3266
+ path?: string;
3267
+ data?: string;
3268
+ error?: string;
3269
+ }
1684
3270
  | { t: 'browser/content'; requestId?: string; text: string }
1685
- | { t: 'browser/picked'; requestId?: string; reference?: BrowserElementReference; ref?: string; tag?: string; text?: string; boundingBox?: { x: number; y: number; width: number; height: number }; attributes?: Record<string, string>; error?: string }
1686
- | { t: 'browser/marked/elements'; elements: Array<{ ref: string; tag: string; text?: string; boundingBox?: { x: number; y: number; width: number; height: number } }> }
1687
- | { t: 'browser/agent/pointer'; x: number; y: number; visible: boolean; action?: 'move' | 'click' | 'type' | 'scroll' | 'idle' | 'hover'; elementRef?: string }
1688
- | { t: 'browser/agent/acting'; acting: boolean; action?: string; target?: string }
3271
+ | {
3272
+ t: 'browser/picked';
3273
+ requestId?: string;
3274
+ reference?: BrowserElementReference;
3275
+ ref?: string;
3276
+ tag?: string;
3277
+ text?: string;
3278
+ boundingBox?: { x: number; y: number; width: number; height: number };
3279
+ attributes?: Record<string, string>;
3280
+ error?: string;
3281
+ }
3282
+ | {
3283
+ t: 'browser/marked/elements';
3284
+ elements: Array<{
3285
+ ref: string;
3286
+ tag: string;
3287
+ text?: string;
3288
+ boundingBox?: { x: number; y: number; width: number; height: number };
3289
+ }>;
3290
+ }
3291
+ | {
3292
+ t: 'browser/agent/pointer';
3293
+ x: number;
3294
+ y: number;
3295
+ visible: boolean;
3296
+ action?: 'move' | 'click' | 'type' | 'scroll' | 'idle' | 'hover';
3297
+ elementRef?: string;
3298
+ }
3299
+ | {
3300
+ t: 'browser/agent/acting';
3301
+ acting: boolean;
3302
+ action?: string;
3303
+ target?: string;
3304
+ }
1689
3305
  /**
1690
3306
  * 一次定位失败后,引擎从当前页面挑出的最像目标的元素。
1691
3307
  *
@@ -1717,26 +3333,85 @@ export type ServerFrame =
1717
3333
  | { t: 'browser/control/changed'; state: BrowserControlState }
1718
3334
  | {
1719
3335
  t: 'browser/challenge/detected';
1720
- reason: Exclude<import('../humanIntervention.js').HumanInterventionReason, 'manual'>;
3336
+ reason: Exclude<
3337
+ import('../humanIntervention.js').HumanInterventionReason,
3338
+ 'manual'
3339
+ >;
1721
3340
  summary: string;
1722
3341
  resumeToken: string;
1723
3342
  runId: string;
1724
3343
  conversationKey?: string;
1725
3344
  }
1726
- | { t: 'browser/result'; requestId?: string; action: string; ok: boolean; conversationKey?: string; runId?: string; tabId?: string; content?: string; error?: string; data?: unknown }
1727
- | { t: 'browser/cookies'; requestId?: string; cookies: Array<{ name: string; value: string; domain?: string; path?: string }> }
3345
+ | {
3346
+ t: 'browser/result';
3347
+ requestId?: string;
3348
+ action: string;
3349
+ ok: boolean;
3350
+ conversationKey?: string;
3351
+ runId?: string;
3352
+ tabId?: string;
3353
+ content?: string;
3354
+ error?: string;
3355
+ data?: unknown;
3356
+ }
3357
+ | {
3358
+ t: 'browser/cookies';
3359
+ requestId?: string;
3360
+ cookies: Array<{
3361
+ name: string;
3362
+ value: string;
3363
+ domain?: string;
3364
+ path?: string;
3365
+ }>;
3366
+ }
1728
3367
  | { t: 'browser/device'; preset?: string; width: number; height: number }
1729
- | { t: 'browser/profile/status'; configured: boolean; profileId: 'default'; developerMode: boolean; engine: string }
3368
+ | {
3369
+ t: 'browser/profile/status';
3370
+ configured: boolean;
3371
+ profileId: 'default';
3372
+ developerMode: boolean;
3373
+ engine: string;
3374
+ }
1730
3375
  | { t: 'browser/error'; message: string; code?: string }
1731
- | { t: 'computer/status'; requestId?: string; available: boolean; serviceVersion?: string; implementation?: string; capabilities?: string[]; error?: string }
1732
- | { t: 'computer/permissions'; requestId?: string; permissions?: unknown; error?: string }
1733
- | { t: 'computer/observed'; requestId?: string; conversationKey: string; runId: string; state?: ComputerObservation; data?: unknown; error?: string }
3376
+ | {
3377
+ t: 'computer/status';
3378
+ requestId?: string;
3379
+ available: boolean;
3380
+ serviceVersion?: string;
3381
+ implementation?: string;
3382
+ capabilities?: string[];
3383
+ error?: string;
3384
+ }
3385
+ | {
3386
+ t: 'computer/permissions';
3387
+ requestId?: string;
3388
+ permissions?: unknown;
3389
+ error?: string;
3390
+ }
3391
+ | {
3392
+ t: 'computer/observed';
3393
+ requestId?: string;
3394
+ conversationKey: string;
3395
+ runId: string;
3396
+ state?: ComputerObservation;
3397
+ data?: unknown;
3398
+ error?: string;
3399
+ }
1734
3400
  /**
1735
3401
  * A privacy-preserving live action cue for the supervised Computer Use
1736
3402
  * workbench. It intentionally carries neither typed text nor an absolute
1737
3403
  * screen coordinate: x/y stay in the existing 0-1000 display-relative space.
1738
3404
  */
1739
- | { t: 'computer/action'; conversationKey: string; runId: string; action: string; x?: number; y?: number; displayId?: string; occurredAt: number }
3405
+ | {
3406
+ t: 'computer/action';
3407
+ conversationKey: string;
3408
+ runId: string;
3409
+ action: string;
3410
+ x?: number;
3411
+ y?: number;
3412
+ displayId?: string;
3413
+ occurredAt: number;
3414
+ }
1740
3415
  | {
1741
3416
  t: 'computer/control/changed';
1742
3417
  /**
@@ -1750,9 +3425,26 @@ export type ServerFrame =
1750
3425
  * 真正全局的状态(服务不可用、helper 缺失)走 `computer/status`,不混进来。
1751
3426
  */
1752
3427
  state:
1753
- | { owner: 'none'; status: 'idle'; conversationKey: string; runId: string }
1754
- | { owner: 'agent'; status: 'running'; conversationKey: string; runId: string; action?: string; targetApp?: string }
1755
- | { owner: 'user'; status: 'interactive'; conversationKey: string; runId: string }
3428
+ | {
3429
+ owner: 'none';
3430
+ status: 'idle';
3431
+ conversationKey: string;
3432
+ runId: string;
3433
+ }
3434
+ | {
3435
+ owner: 'agent';
3436
+ status: 'running';
3437
+ conversationKey: string;
3438
+ runId: string;
3439
+ action?: string;
3440
+ targetApp?: string;
3441
+ }
3442
+ | {
3443
+ owner: 'user';
3444
+ status: 'interactive';
3445
+ conversationKey: string;
3446
+ runId: string;
3447
+ }
1756
3448
  | {
1757
3449
  owner: 'user';
1758
3450
  status: 'waiting_human';
@@ -1764,10 +3456,21 @@ export type ServerFrame =
1764
3456
  resumeToken: string;
1765
3457
  sanitizedSummary: string;
1766
3458
  }
1767
- | { owner: 'none'; status: 'error'; conversationKey: string; runId: string; message: string };
3459
+ | {
3460
+ owner: 'none';
3461
+ status: 'error';
3462
+ conversationKey: string;
3463
+ runId: string;
3464
+ message: string;
3465
+ };
1768
3466
  }
1769
3467
  // 终端不走 WS:改由 Tauri 原生真 PTY 承载(server 帧无 terminal/*)。
1770
- | { t: 'file/preview/opened'; requestId: string; ref?: ConversationFileRef; error?: string }
3468
+ | {
3469
+ t: 'file/preview/opened';
3470
+ requestId: string;
3471
+ ref?: ConversationFileRef;
3472
+ error?: string;
3473
+ }
1771
3474
  | { t: 'file/browse/result'; requestId: string; listing: FileBrowserListing };
1772
3475
 
1773
3476
  export interface CommandDescriptor {