arco-workbench 0.1.9 → 0.2.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 (761) hide show
  1. package/CONTRIBUTING.md +14 -12
  2. package/README.md +5 -3
  3. package/client/dist/THIRD_PARTY_LICENSES.txt +3912 -0
  4. package/client/dist/assets/{PhosphorBackdrop-DRu16-Is.js → PhosphorBackdrop-9jNRO1ZM.js} +1 -1
  5. package/client/dist/assets/{ThemedBackgroundShaderImpl-BLdwwQ4D.js → ThemedBackgroundShaderImpl-tUi3k54Y.js} +1 -1
  6. package/client/dist/assets/XtermView-B7BOSnVo.js +10 -0
  7. package/client/dist/assets/{galleryEditor-CI8ClzBa.js → galleryEditor-Ohc2h9cD.js} +1 -1
  8. package/client/dist/assets/index-CVJVD2Vn.css +1 -0
  9. package/client/dist/assets/index-ILGXWriO.js +638 -0
  10. package/client/dist/index.html +3 -3
  11. package/client/src/App.tsx +42 -9
  12. package/client/src/components/AskUserQuestionNotice.tsx +37 -10
  13. package/client/src/components/AttachmentPill.tsx +3 -2
  14. package/client/src/components/AuthReloginNotice.tsx +25 -6
  15. package/client/src/components/AutomaticMessage.tsx +3 -1
  16. package/client/src/components/CatchMeUp.tsx +4 -1
  17. package/client/src/components/ChatMessage.tsx +43 -5
  18. package/client/src/components/ChatModeView.tsx +20 -4
  19. package/client/src/components/ChatPanel.tsx +5 -0
  20. package/client/src/components/ClusterActivityTab.tsx +9 -3
  21. package/client/src/components/ClusterComposerButtons.tsx +5 -3
  22. package/client/src/components/ClusterPlanTab.tsx +55 -8
  23. package/client/src/components/ClusterRightPanel/AddWorkerSection.tsx +38 -99
  24. package/client/src/components/ClusterRightPanel/AutoPickupControl.tsx +36 -12
  25. package/client/src/components/ClusterRightPanel/MailboxModal.tsx +61 -8
  26. package/client/src/components/ClusterRightPanel/MemberRow.tsx +46 -14
  27. package/client/src/components/ClusterRightPanel/PhoneMemberList.tsx +56 -0
  28. package/client/src/components/ClusterRightPanel/ReplaceMemberDialog.tsx +38 -9
  29. package/client/src/components/ClusterRightPanel/SkillsControl.tsx +6 -5
  30. package/client/src/components/ClusterRightPanel/index.tsx +188 -39
  31. package/client/src/components/ClusterRightPanel/memberSettings.ts +2 -2
  32. package/client/src/components/ClusterRightPanel/panels.ts +1 -0
  33. package/client/src/components/ClusterRightPanel/types.ts +5 -1
  34. package/client/src/components/ClusterRightPanel/useFreshMemberPicker.ts +82 -0
  35. package/client/src/components/ClusterTab.tsx +76 -23
  36. package/client/src/components/ClusterTaskBoardTab.tsx +35 -6
  37. package/client/src/components/Connections/Connections.tsx +5 -8
  38. package/client/src/components/Connections/model.ts +2 -2
  39. package/client/src/components/DialogShell.tsx +4 -0
  40. package/client/src/components/DirectorContinuePrompt.tsx +56 -0
  41. package/client/src/components/FileExplorer.tsx +54 -1
  42. package/client/src/components/FileViewerModal.tsx +39 -7
  43. package/client/src/components/FirstRun.tsx +3 -2
  44. package/client/src/components/ForwardMessages.tsx +6 -3
  45. package/client/src/components/GateApprovalNotice.tsx +7 -4
  46. package/client/src/components/GeminiSkillNotice.tsx +12 -0
  47. package/client/src/components/GeminiSubagentLine.tsx +5 -0
  48. package/client/src/components/GitDialog.tsx +15 -6
  49. package/client/src/components/GitOtherWork.tsx +2 -1
  50. package/client/src/components/HandoffDialog.tsx +3 -2
  51. package/client/src/components/HeaderVersionBox.tsx +6 -2
  52. package/client/src/components/HistoryTab.tsx +127 -108
  53. package/client/src/components/Home/HomeView.tsx +14 -3
  54. package/client/src/components/Home/ResearchLibrary.tsx +107 -0
  55. package/client/src/components/Home/home.css +6 -0
  56. package/client/src/components/LoginFlow.tsx +12 -5
  57. package/client/src/components/MemberCard.tsx +8 -2
  58. package/client/src/components/MemberPane.tsx +12 -4
  59. package/client/src/components/MobileNotices.tsx +26 -0
  60. package/client/src/components/MobileQuestionBar.tsx +35 -0
  61. package/client/src/components/MobileShell.tsx +811 -0
  62. package/client/src/components/MobileTextSize.tsx +27 -0
  63. package/client/src/components/NativeSubagentControls.tsx +12 -1
  64. package/client/src/components/NorthStarBar.tsx +2 -0
  65. package/client/src/components/NotificationToasts.tsx +6 -2
  66. package/client/src/components/OperatorQuestionNotice.tsx +2 -2
  67. package/client/src/components/PendingQuestionsButton.tsx +44 -5
  68. package/client/src/components/PhoneUpload.tsx +4 -2
  69. package/client/src/components/PlanComposerDialog.tsx +7 -7
  70. package/client/src/components/ProjectsSettings.tsx +3 -0
  71. package/client/src/components/ProvidersPopover.tsx +9 -6
  72. package/client/src/components/PurgeConversationModal.tsx +1 -1
  73. package/client/src/components/QueuedMessagesIndicator.tsx +1 -1
  74. package/client/src/components/Recall/RecallView.tsx +31 -8
  75. package/client/src/components/ResearchFolderSetting.tsx +64 -0
  76. package/client/src/components/RightPanel/ActivityTab.tsx +9 -4
  77. package/client/src/components/RightPanel/BlastRadiusTab.tsx +6 -8
  78. package/client/src/components/RightPanel/ConfigTab.tsx +18 -10
  79. package/client/src/components/RightPanel/FilesTab.tsx +34 -19
  80. package/client/src/components/RightPanel/PlanTab.tsx +67 -24
  81. package/client/src/components/RightPanel/UsageTab.tsx +30 -3
  82. package/client/src/components/RightPanel/index.tsx +42 -3
  83. package/client/src/components/RuntimeStateBanner.tsx +8 -0
  84. package/client/src/components/ScratchCloseDialog.tsx +124 -0
  85. package/client/src/components/SettingsPanel.tsx +181 -69
  86. package/client/src/components/SkillActivityIndicator.tsx +93 -0
  87. package/client/src/components/SystemHeader.tsx +2 -7
  88. package/client/src/components/SystemModal.tsx +37 -45
  89. package/client/src/components/TabBar.tsx +52 -8
  90. package/client/src/components/TabContextMenu.tsx +12 -102
  91. package/client/src/components/TaskCard.tsx +13 -17
  92. package/client/src/components/TaskChildComposer.tsx +24 -0
  93. package/client/src/components/TasksPanel.tsx +7 -17
  94. package/client/src/components/Terminal/FloatingTerminalWindow.tsx +11 -3
  95. package/client/src/components/Terminal/FloatingWindow.tsx +36 -14
  96. package/client/src/components/Terminal/XtermView.tsx +19 -2
  97. package/client/src/components/Terminal/phoneKeys.ts +9 -0
  98. package/client/src/components/TerminalInput.tsx +149 -32
  99. package/client/src/components/TranscriptWorkerDialog.tsx +2 -2
  100. package/client/src/components/UpdateAction.tsx +9 -6
  101. package/client/src/components/UsageBar.tsx +118 -10
  102. package/client/src/components/UserManual/MobileManualContent.tsx +58 -0
  103. package/client/src/components/WorkflowCreator/ClusterMembersSection.tsx +8 -5
  104. package/client/src/components/WorkflowCreator/PastChatsList.tsx +3 -1
  105. package/client/src/components/WorkflowCreator/ProjectPicker.tsx +3 -3
  106. package/client/src/components/WorkflowCreator/ResearchStartForm.tsx +335 -0
  107. package/client/src/components/WorkflowCreator/index.tsx +124 -36
  108. package/client/src/components/WorkflowCreator/memberProviders.ts +20 -5
  109. package/client/src/components/WorkflowCreator/pendingTemplateApply.ts +20 -0
  110. package/client/src/components/WorkflowCreator/types.ts +18 -0
  111. package/client/src/components/WorkflowStatusChip.tsx +1 -0
  112. package/client/src/components/WorkflowView.tsx +51 -13
  113. package/client/src/components/chatMessageLabel.ts +4 -0
  114. package/client/src/components/clusterActivity.helpers.ts +5 -1
  115. package/client/src/components/clusterNeedsYou.ts +3 -8
  116. package/client/src/components/clusterSurface.helpers.ts +6 -1
  117. package/client/src/components/composer/submitComposer.ts +7 -1
  118. package/client/src/components/help/HelpBanner.tsx +10 -5
  119. package/client/src/components/help/HelpPopover.tsx +5 -0
  120. package/client/src/components/media/MediaModalHost.tsx +13 -8
  121. package/client/src/components/plans/PhonePlanView.tsx +66 -0
  122. package/client/src/components/plans/phonePlanChecklist.ts +45 -0
  123. package/client/src/components/providerIndicator.ts +83 -0
  124. package/client/src/components/research/AddResearcherSection.tsx +50 -0
  125. package/client/src/components/research/ExportResearchDialog.tsx +52 -0
  126. package/client/src/components/research/QuickResearchOverview.tsx +92 -0
  127. package/client/src/components/research/RerunResearchDialog.tsx +61 -0
  128. package/client/src/components/research/ResearchCloseDialog.tsx +98 -0
  129. package/client/src/components/research/ResearchRemoveDialog.tsx +37 -0
  130. package/client/src/components/research/ResearchReopenDialog.tsx +160 -0
  131. package/client/src/components/research/ResearchResultsTab.css +289 -0
  132. package/client/src/components/research/ResearchResultsTab.tsx +207 -0
  133. package/client/src/components/research/ResearchRoundsStrip.tsx +127 -0
  134. package/client/src/components/research/SavedQuickKeep.tsx +58 -0
  135. package/client/src/components/research/SendResearchDialog.tsx +126 -0
  136. package/client/src/components/research/StartResearchProjectDialog.tsx +108 -0
  137. package/client/src/components/research/researchExports.ts +26 -0
  138. package/client/src/components/research/researchLinks.tsx +30 -0
  139. package/client/src/components/research/researchView.ts +64 -0
  140. package/client/src/components/research/researcherRow.tsx +104 -0
  141. package/client/src/components/settings/AppVersionSection.tsx +2 -0
  142. package/client/src/components/settings/SettingsLayout.tsx +23 -4
  143. package/client/src/components/settings/navigation.ts +4 -4
  144. package/client/src/components/settings/settings.css +18 -0
  145. package/client/src/components/usageVisibility.ts +4 -6
  146. package/client/src/components/workSurface/WorkSurfaceControls.tsx +7 -0
  147. package/client/src/explorer/StorageLens.tsx +10 -3
  148. package/client/src/help/content/chat.tsx +5 -8
  149. package/client/src/help/content/cluster.tsx +70 -30
  150. package/client/src/help/content/composer.tsx +13 -8
  151. package/client/src/help/content/header.tsx +17 -24
  152. package/client/src/help/content/media.tsx +2 -2
  153. package/client/src/help/content/misc.tsx +174 -38
  154. package/client/src/help/content/recall.tsx +2 -2
  155. package/client/src/help/content/rightPanel.tsx +8 -8
  156. package/client/src/help/content/settings.tsx +48 -14
  157. package/client/src/help/content/tabbar.tsx +6 -2
  158. package/client/src/help/manualSections/actions.tsx +7 -2
  159. package/client/src/help/manualSections/chat.tsx +16 -15
  160. package/client/src/help/manualSections/clusters.tsx +348 -69
  161. package/client/src/help/manualSections/configuration.tsx +25 -18
  162. package/client/src/help/manualSections/deepseek.tsx +4 -5
  163. package/client/src/help/manualSections/gettingStarted.tsx +30 -26
  164. package/client/src/help/manualSections/maintenance.tsx +9 -5
  165. package/client/src/help/manualSections/plans.tsx +4 -4
  166. package/client/src/help/manualSections/powerFeatures.tsx +51 -18
  167. package/client/src/help/manualSections/providers.tsx +56 -21
  168. package/client/src/help/manualSections/reference.tsx +6 -6
  169. package/client/src/help/manualSections/strata.tsx +8 -8
  170. package/client/src/help/manualSections/workflows.tsx +3 -3
  171. package/client/src/help/manualSections/workspace.tsx +115 -39
  172. package/client/src/hooks/useWebSocket.ts +21 -4
  173. package/client/src/layout/PhoneBottomSheet.tsx +71 -0
  174. package/client/src/layout/PhonePage.tsx +71 -0
  175. package/client/src/layout/SlideOut.tsx +36 -9
  176. package/client/src/layout/layoutRange.ts +41 -4
  177. package/client/src/layout/phoneChip.ts +14 -0
  178. package/client/src/layout/phoneOverlay.ts +81 -0
  179. package/client/src/layout/phonePageActions.ts +40 -0
  180. package/client/src/stores/appStore.ts +36 -10
  181. package/client/src/stores/appStore.types.ts +29 -3
  182. package/client/src/stores/directorContinueStore.ts +22 -0
  183. package/client/src/stores/draftStore.ts +56 -2
  184. package/client/src/stores/phoneStore.ts +196 -0
  185. package/client/src/stores/terminalStore.ts +8 -0
  186. package/client/src/styles/contextual-help.css +10 -0
  187. package/client/src/styles/global.css +293 -0
  188. package/client/src/themes/apply.ts +9 -1
  189. package/client/src/themes/bootstrap.ts +21 -1
  190. package/client/src/themes/providerThemes.ts +1 -0
  191. package/client/src/utils/codexAccountHome.ts +9 -0
  192. package/client/src/utils/format.ts +8 -2
  193. package/client/src/utils/gitBranchMark.ts +3 -0
  194. package/client/src/utils/homeModel.ts +7 -0
  195. package/client/src/utils/longPress.ts +64 -0
  196. package/client/src/utils/modelCatalog.ts +4 -0
  197. package/client/src/utils/providerStatusCheck.ts +30 -0
  198. package/client/src/utils/startupGate.ts +6 -0
  199. package/client/src/ws/handleServerMessage.ts +106 -7
  200. package/docs/ARCHITECTURE.md +63 -37
  201. package/docs/ARCHITECTURE_REVIEW.md +1 -1
  202. package/docs/BACKUP.md +60 -9
  203. package/docs/CHAT.md +15 -11
  204. package/docs/CHECKPOINTS.md +2 -0
  205. package/docs/CLIENT.md +70 -36
  206. package/docs/DEEPSEEK.md +9 -10
  207. package/docs/DIAGNOSTICS.md +8 -7
  208. package/docs/DOCKER.md +16 -2
  209. package/docs/EXTENDING.md +10 -26
  210. package/docs/FEATURES.md +23 -15
  211. package/docs/GENESIS.md +3 -1
  212. package/docs/GETTING_STARTED.md +82 -16
  213. package/docs/GIT_WORKBENCH.md +5 -5
  214. package/docs/GLOSSARY.md +36 -23
  215. package/docs/GOTCHAS.md +102 -67
  216. package/docs/HTTP_API.md +182 -86
  217. package/docs/INDEX.md +1 -0
  218. package/docs/KNOWLEDGE.md +2 -2
  219. package/docs/LOCAL_SERVICES.md +9 -8
  220. package/docs/MCP_REGISTRY.md +18 -13
  221. package/docs/MEDIA_STUDIO.md +7 -11
  222. package/docs/OPERATIONS.md +101 -24
  223. package/docs/OPERATOR_ACTIONS.md +24 -22
  224. package/docs/PERSISTENCE.md +65 -24
  225. package/docs/PHOSPHOR_DEMO.md +1 -4
  226. package/docs/PLAN_OR_BOARD.md +2 -2
  227. package/docs/PRIMITIVES.md +17 -17
  228. package/docs/PROTOCOL.md +60 -9
  229. package/docs/PROTOCOL_CLUSTER.md +92 -22
  230. package/docs/PROTOCOL_PRIMITIVES.md +10 -4
  231. package/docs/PROVIDERS.md +291 -145
  232. package/docs/RECALL.md +40 -31
  233. package/docs/REMOTE_MANAGEMENT.md +27 -51
  234. package/docs/REPO_LAYOUT.md +4 -3
  235. package/docs/RESEARCH.md +189 -0
  236. package/docs/RESUME_INDEX.md +10 -19
  237. package/docs/SERVICE_MODE.md +11 -5
  238. package/docs/SETTINGS.md +18 -13
  239. package/docs/STORAGE_PLAN.md +3 -3
  240. package/docs/STRATA.md +14 -11
  241. package/docs/TASK_LEDGER.md +19 -8
  242. package/docs/TERMINAL.md +14 -10
  243. package/docs/THIRD_PARTY.md +21 -4
  244. package/docs/VOICE.md +16 -28
  245. package/native/linux-arm64/manifest.json +1 -1
  246. package/node_modules/@arco/shared/dist/clusterCoordination.d.ts +1 -0
  247. package/node_modules/@arco/shared/dist/clusterCoordination.js +9 -1
  248. package/node_modules/@arco/shared/dist/clusterRolePresets.js +13 -4
  249. package/node_modules/@arco/shared/dist/index.d.ts +1 -0
  250. package/node_modules/@arco/shared/dist/index.js +1 -0
  251. package/node_modules/@arco/shared/dist/protocol/autoPickup.d.ts +7 -0
  252. package/node_modules/@arco/shared/dist/protocol/autoPickup.js +22 -11
  253. package/node_modules/@arco/shared/dist/protocol/chat.d.ts +1 -1
  254. package/node_modules/@arco/shared/dist/protocol/checkpoints.d.ts +1 -0
  255. package/node_modules/@arco/shared/dist/protocol/clientMessages.d.ts +18 -3
  256. package/node_modules/@arco/shared/dist/protocol/clusters.d.ts +177 -4
  257. package/node_modules/@arco/shared/dist/protocol/clusters.js +48 -2
  258. package/node_modules/@arco/shared/dist/protocol/handoffs.d.ts +1 -0
  259. package/node_modules/@arco/shared/dist/protocol/models.d.ts +6 -1
  260. package/node_modules/@arco/shared/dist/protocol/models.js +4 -3
  261. package/node_modules/@arco/shared/dist/protocol/providers.d.ts +3 -2
  262. package/node_modules/@arco/shared/dist/protocol/providers.js +1 -1
  263. package/node_modules/@arco/shared/dist/protocol/serverMessages.d.ts +28 -3
  264. package/node_modules/@arco/shared/dist/protocol/settings.d.ts +4 -0
  265. package/node_modules/@arco/shared/dist/protocol/settings.js +3 -1
  266. package/node_modules/@arco/shared/dist/protocol/tasks.d.ts +42 -0
  267. package/node_modules/@arco/shared/dist/protocol/tasks.js +17 -0
  268. package/node_modules/@arco/shared/dist/protocol/workflows.d.ts +4 -0
  269. package/node_modules/@arco/shared/dist/protocol/workflows.js +2 -0
  270. package/node_modules/@arco/shared/dist/researchActivity.d.ts +4 -0
  271. package/node_modules/@arco/shared/dist/researchActivity.js +29 -0
  272. package/node_modules/@arco/shared/package.json +1 -1
  273. package/package.json +3 -2
  274. package/scripts/packaging/services.mjs +19 -2
  275. package/scripts/packaging/update.mjs +9 -0
  276. package/server/dist/arcoHome.js +19 -3
  277. package/server/dist/auth.d.ts +4 -2
  278. package/server/dist/auth.js +42 -4
  279. package/server/dist/authLoginSession.d.ts +2 -1
  280. package/server/dist/authLoginSession.js +13 -3
  281. package/server/dist/capabilities.d.ts +2 -2
  282. package/server/dist/capabilities.js +11 -6
  283. package/server/dist/chatMode.d.ts +3 -0
  284. package/server/dist/chatMode.js +25 -2
  285. package/server/dist/checkedFile.d.ts +1 -1
  286. package/server/dist/checkedFile.js +48 -41
  287. package/server/dist/cliUpdateDecision.js +1 -1
  288. package/server/dist/clusterAutoTurn.d.ts +4 -1
  289. package/server/dist/clusterAutoTurn.js +25 -4
  290. package/server/dist/clusterBusyReminder.js +2 -1
  291. package/server/dist/clusterDirector.js +5 -2
  292. package/server/dist/clusterMailTally.d.ts +11 -0
  293. package/server/dist/clusterMailTally.js +29 -0
  294. package/server/dist/clusterMailbox.d.ts +8 -1
  295. package/server/dist/clusterMailbox.js +53 -4
  296. package/server/dist/clusterOpenWork.d.ts +22 -0
  297. package/server/dist/clusterOpenWork.js +85 -0
  298. package/server/dist/clusterPeerOps.d.ts +32 -5
  299. package/server/dist/clusterPeerOps.js +253 -49
  300. package/server/dist/clusterPlanBridge.d.ts +7 -1
  301. package/server/dist/clusterPlanBridge.js +58 -0
  302. package/server/dist/clusterPlanStore.d.ts +6 -0
  303. package/server/dist/clusterPlanStore.js +58 -0
  304. package/server/dist/clusterPresets.js +23 -3
  305. package/server/dist/clusterProgress.js +2 -2
  306. package/server/dist/clusterSkills.js +2 -2
  307. package/server/dist/clusterSnapshots.d.ts +1 -0
  308. package/server/dist/clusterSnapshots.js +7 -1
  309. package/server/dist/clusterStore.d.ts +34 -1
  310. package/server/dist/clusterStore.js +194 -21
  311. package/server/dist/clusterTurnOrigin.d.ts +2 -0
  312. package/server/dist/clusterTurnOrigin.js +19 -0
  313. package/server/dist/connectionCatalog.js +1 -0
  314. package/server/dist/cursorUsage.js +3 -3
  315. package/server/dist/defaults/models.md +11 -14
  316. package/server/dist/directorContinue.d.ts +47 -0
  317. package/server/dist/directorContinue.js +311 -0
  318. package/server/dist/directorContinueHook.d.ts +3 -0
  319. package/server/dist/directorContinueHook.js +16 -0
  320. package/server/dist/effortValidation.d.ts +3 -0
  321. package/server/dist/effortValidation.js +34 -0
  322. package/server/dist/fileAccessPolicy.js +1 -0
  323. package/server/dist/fileFetch.d.ts +7 -1
  324. package/server/dist/fileFetch.js +50 -29
  325. package/server/dist/geminiMembers.d.ts +8 -0
  326. package/server/dist/geminiMembers.js +113 -0
  327. package/server/dist/git.d.ts +3 -0
  328. package/server/dist/git.js +17 -24
  329. package/server/dist/gitOtherWork.js +5 -4
  330. package/server/dist/gitSnapshots.js +66 -5
  331. package/server/dist/http/authLoginRoutes.js +1 -1
  332. package/server/dist/http/clusterRoutes.js +466 -4
  333. package/server/dist/http/diagnosticsRoutes.js +8 -0
  334. package/server/dist/http/fileWriteRoutes.js +11 -3
  335. package/server/dist/http/phoneUploadRoutes.js +2 -1
  336. package/server/dist/http/readConfinement.d.ts +11 -0
  337. package/server/dist/http/readConfinement.js +30 -0
  338. package/server/dist/http/recallRoutes.js +1 -1
  339. package/server/dist/http/router.js +48 -11
  340. package/server/dist/http/storageRoutes.js +114 -7
  341. package/server/dist/http/workflowDataRoutes.js +20 -0
  342. package/server/dist/http/writeConfinement.js +12 -1
  343. package/server/dist/index.d.ts +13 -0
  344. package/server/dist/index.js +353 -56
  345. package/server/dist/initialProviders.js +1 -1
  346. package/server/dist/manualCompactCapability.js +1 -1
  347. package/server/dist/mcp/clusterMcpLoopback.d.ts +1 -0
  348. package/server/dist/mcp/clusterMcpLoopback.js +1 -0
  349. package/server/dist/mcp/clusterMcpServer.js +3 -2
  350. package/server/dist/mcp/clusterMcpTools.d.ts +3 -0
  351. package/server/dist/mcp/clusterMcpTools.js +79 -25
  352. package/server/dist/mcp/mcpConfigWriter.d.ts +1 -0
  353. package/server/dist/mcp/mcpConfigWriter.js +2 -0
  354. package/server/dist/mcp/workerMailBridge.d.ts +17 -0
  355. package/server/dist/mcp/workerMailBridge.js +104 -0
  356. package/server/dist/planStore.js +1 -0
  357. package/server/dist/primitives/seedWorker.d.ts +10 -1
  358. package/server/dist/primitives/seedWorker.js +14 -15
  359. package/server/dist/project/taskLedger.d.ts +3 -0
  360. package/server/dist/project/taskLedger.js +16 -0
  361. package/server/dist/providers/{cursor → acp}/acpJsonRpc.js +1 -1
  362. package/server/dist/providers/acp/permissionGate.d.ts +3 -0
  363. package/server/dist/providers/acp/permissionGate.js +46 -0
  364. package/server/dist/providers/antigravity/index.d.ts +15 -0
  365. package/server/dist/providers/antigravity/index.js +251 -0
  366. package/server/dist/providers/antigravity/researchSignIn.d.ts +24 -0
  367. package/server/dist/providers/antigravity/researchSignIn.js +93 -0
  368. package/server/dist/providers/antigravity/status.d.ts +18 -0
  369. package/server/dist/providers/antigravity/status.js +28 -0
  370. package/server/dist/providers/antigravity/usage.d.ts +7 -0
  371. package/server/dist/providers/antigravity/usage.js +35 -0
  372. package/server/dist/providers/claude/researcherFence.d.ts +7 -0
  373. package/server/dist/providers/claude/researcherFence.js +27 -0
  374. package/server/dist/providers/claude-native/catalog.d.ts +2 -1
  375. package/server/dist/providers/claude-native/catalog.js +4 -0
  376. package/server/dist/providers/claude-native/index.d.ts +1 -0
  377. package/server/dist/providers/claude-native/index.js +9 -1
  378. package/server/dist/providers/claude-native/peerTools.d.ts +1 -0
  379. package/server/dist/providers/claude-native/peerTools.js +26 -4
  380. package/server/dist/providers/claude-native/taskAdmission.d.ts +7 -1
  381. package/server/dist/providers/claude-native/taskAdmission.js +30 -8
  382. package/server/dist/providers/claude-native/tools.d.ts +1 -0
  383. package/server/dist/providers/claude-native/tools.js +47 -18
  384. package/server/dist/providers/claude-native/worker.d.ts +22 -1
  385. package/server/dist/providers/claude-native/worker.js +281 -51
  386. package/server/dist/providers/claude-native/workerHelpers.d.ts +5 -0
  387. package/server/dist/providers/claude-native/workerHelpers.js +95 -5
  388. package/server/dist/providers/claude.d.ts +2 -0
  389. package/server/dist/providers/claude.js +194 -22
  390. package/server/dist/providers/clusterTaskToolDefinitions.js +2 -1
  391. package/server/dist/providers/codex-appserver/heldCommands.d.ts +2 -2
  392. package/server/dist/providers/codex-appserver/heldCommands.js +9 -3
  393. package/server/dist/providers/codex-appserver/index.d.ts +9 -0
  394. package/server/dist/providers/codex-appserver/index.js +106 -5
  395. package/server/dist/providers/codex-appserver/lateCommands.js +1 -0
  396. package/server/dist/providers/codex-appserver/modelAvailability.d.ts +20 -0
  397. package/server/dist/providers/codex-appserver/modelAvailability.js +34 -0
  398. package/server/dist/providers/codex-appserver/worker.d.ts +11 -0
  399. package/server/dist/providers/codex-appserver/worker.js +199 -25
  400. package/server/dist/providers/codex.js +1 -0
  401. package/server/dist/providers/codexVersion.d.ts +2 -0
  402. package/server/dist/providers/codexVersion.js +8 -0
  403. package/server/dist/providers/codexWebSearch.js +1 -1
  404. package/server/dist/providers/cursor/agentEnv.d.ts +20 -0
  405. package/server/dist/providers/cursor/agentEnv.js +93 -0
  406. package/server/dist/providers/cursor/authState.js +2 -1
  407. package/server/dist/providers/cursor/authToken.d.ts +25 -2
  408. package/server/dist/providers/cursor/authToken.js +118 -27
  409. package/server/dist/providers/cursor/catalog.d.ts +6 -0
  410. package/server/dist/providers/cursor/catalog.js +91 -1
  411. package/server/dist/providers/cursor/chatSandbox.d.ts +3 -1
  412. package/server/dist/providers/cursor/chatSandbox.js +24 -8
  413. package/server/dist/providers/cursor/isolated.d.ts +6 -0
  414. package/server/dist/providers/cursor/isolated.js +313 -0
  415. package/server/dist/providers/cursor/isolatedVersion.d.ts +6 -0
  416. package/server/dist/providers/cursor/isolatedVersion.js +35 -0
  417. package/server/dist/providers/cursor/modelMap.js +9 -5
  418. package/server/dist/providers/cursor/print.js +10 -8
  419. package/server/dist/providers/cursor/worker.js +8 -3
  420. package/server/dist/providers/index.js +10 -2
  421. package/server/dist/providers/llamacpp.js +3 -2
  422. package/server/dist/providers/ollama.d.ts +3 -2
  423. package/server/dist/providers/ollama.js +29 -10
  424. package/server/dist/providers/ollamaTools.d.ts +3 -0
  425. package/server/dist/providers/ollamaTools.js +31 -29
  426. package/server/dist/research/exportResults.d.ts +15 -0
  427. package/server/dist/research/exportResults.js +60 -0
  428. package/server/dist/research/isolatedArtifact.d.ts +4 -0
  429. package/server/dist/research/isolatedArtifact.js +56 -0
  430. package/server/dist/research/quickPromotion.d.ts +27 -0
  431. package/server/dist/research/quickPromotion.js +402 -0
  432. package/server/dist/research/quickResearchChat.d.ts +4 -0
  433. package/server/dist/research/quickResearchChat.js +187 -0
  434. package/server/dist/research/researchClose.d.ts +31 -0
  435. package/server/dist/research/researchClose.js +373 -0
  436. package/server/dist/research/researchCopy.d.ts +16 -0
  437. package/server/dist/research/researchCopy.js +180 -0
  438. package/server/dist/research/researchCreate.d.ts +40 -0
  439. package/server/dist/research/researchCreate.js +334 -0
  440. package/server/dist/research/researchDoctrine.d.ts +2 -0
  441. package/server/dist/research/researchDoctrine.js +26 -0
  442. package/server/dist/research/researchFolder.d.ts +23 -0
  443. package/server/dist/research/researchFolder.js +191 -0
  444. package/server/dist/research/researchLibrary.d.ts +54 -0
  445. package/server/dist/research/researchLibrary.js +281 -0
  446. package/server/dist/research/researchRetry.d.ts +25 -0
  447. package/server/dist/research/researchRetry.js +96 -0
  448. package/server/dist/research/researchRounds.d.ts +108 -0
  449. package/server/dist/research/researchRounds.js +996 -0
  450. package/server/dist/research/researchState.d.ts +112 -0
  451. package/server/dist/research/researchState.js +191 -0
  452. package/server/dist/research/researchTools.d.ts +57 -0
  453. package/server/dist/research/researchTools.js +57 -0
  454. package/server/dist/research/researchTripwires.d.ts +18 -0
  455. package/server/dist/research/researchTripwires.js +196 -0
  456. package/server/dist/research/resultSelection.d.ts +27 -0
  457. package/server/dist/research/resultSelection.js +161 -0
  458. package/server/dist/research/savedQuickPromotion.d.ts +19 -0
  459. package/server/dist/research/savedQuickPromotion.js +259 -0
  460. package/server/dist/research/sendToProject.d.ts +36 -0
  461. package/server/dist/research/sendToProject.js +293 -0
  462. package/server/dist/server/broadcast.d.ts +5 -1
  463. package/server/dist/server/broadcast.js +45 -5
  464. package/server/dist/server/updateCheck.js +1 -0
  465. package/server/dist/settings.js +27 -3
  466. package/server/dist/skillActivity.d.ts +11 -0
  467. package/server/dist/skillActivity.js +33 -0
  468. package/server/dist/smartPickup.d.ts +1 -0
  469. package/server/dist/smartPickup.js +12 -4
  470. package/server/dist/smartPickupAdapters.js +3 -2
  471. package/server/dist/smartPickupEvaluator.d.ts +1 -0
  472. package/server/dist/smartPickupObserver.js +47 -14
  473. package/server/dist/storageActions.d.ts +9 -0
  474. package/server/dist/storageActions.js +5 -0
  475. package/server/dist/storageOverview.d.ts +1 -0
  476. package/server/dist/storageOverview.js +12 -5
  477. package/server/dist/taskDispatcher.js +3 -2
  478. package/server/dist/toolboxWorkflow.js +2 -1
  479. package/server/dist/updateCheck.d.ts +3 -2
  480. package/server/dist/updateCheck.js +39 -1
  481. package/server/dist/workers/StreamParser.d.ts +1 -0
  482. package/server/dist/workers/StreamParser.js +23 -1
  483. package/server/dist/workers/WorkerManager.d.ts +4 -0
  484. package/server/dist/workers/WorkerManager.js +5 -1
  485. package/server/dist/workers/antigravityIsolatedLaunch.d.ts +25 -0
  486. package/server/dist/workers/antigravityIsolatedLaunch.js +88 -0
  487. package/server/dist/workers/checkedLinuxWorker.d.ts +38 -0
  488. package/server/dist/workers/checkedLinuxWorker.js +192 -0
  489. package/server/dist/workers/claudeAccessLease.d.ts +24 -0
  490. package/server/dist/workers/claudeAccessLease.js +157 -0
  491. package/server/dist/workers/claudeAccessSource.d.ts +2 -0
  492. package/server/dist/workers/claudeAccessSource.js +27 -0
  493. package/server/dist/workers/claudeIsolatedLaunch.d.ts +19 -0
  494. package/server/dist/workers/claudeIsolatedLaunch.js +104 -0
  495. package/server/dist/workers/cliResearcherDoctrine.d.ts +4 -0
  496. package/server/dist/workers/cliResearcherDoctrine.js +20 -0
  497. package/server/dist/workers/codexAccessLease.d.ts +26 -0
  498. package/server/dist/workers/codexAccessLease.js +208 -0
  499. package/server/dist/workers/codexIsolatedLaunch.d.ts +21 -0
  500. package/server/dist/workers/codexIsolatedLaunch.js +95 -0
  501. package/server/dist/workers/codexIsolatedPolicy.d.ts +5 -0
  502. package/server/dist/workers/codexIsolatedPolicy.js +49 -0
  503. package/server/dist/workers/cursorIsolatedLaunch.d.ts +37 -0
  504. package/server/dist/workers/cursorIsolatedLaunch.js +178 -0
  505. package/server/dist/workers/isolatedCliHome.d.ts +4 -0
  506. package/server/dist/workers/isolatedCliHome.js +107 -0
  507. package/server/dist/workers/limits.js +1 -1
  508. package/server/dist/workers/linuxWorkerSandbox.d.ts +48 -0
  509. package/server/dist/workers/linuxWorkerSandbox.js +192 -0
  510. package/server/dist/workers/processKill.d.ts +2 -0
  511. package/server/dist/workers/processKill.js +28 -2
  512. package/server/dist/workers/providerRuntimeDiscovery.d.ts +13 -0
  513. package/server/dist/workers/providerRuntimeDiscovery.js +126 -0
  514. package/server/dist/workers/researchSandboxAvailability.d.ts +3 -0
  515. package/server/dist/workers/researchSandboxAvailability.js +78 -0
  516. package/server/dist/workers/workerAccessPass.d.ts +12 -0
  517. package/server/dist/workers/workerAccessPass.js +123 -0
  518. package/server/dist/workers/workerHiddenDirectories.d.ts +3 -0
  519. package/server/dist/workers/workerHiddenDirectories.js +16 -0
  520. package/server/dist/workers/workerSocketDirectory.d.ts +2 -0
  521. package/server/dist/workers/workerSocketDirectory.js +16 -0
  522. package/server/dist/workers/workerWebProxy.d.ts +28 -0
  523. package/server/dist/workers/workerWebProxy.js +206 -0
  524. package/server/dist/workflowMeta.d.ts +5 -0
  525. package/server/dist/workflowMeta.js +7 -3
  526. package/server/dist/workflowStore.js +43 -25
  527. package/server/dist/workflows/purgeWorkflow.js +15 -0
  528. package/server/dist/workflows/types.d.ts +6 -0
  529. package/server/dist/workspace.d.ts +1 -0
  530. package/server/dist/workspace.js +8 -0
  531. package/server/dist/ws/clusterHandlers.d.ts +5 -0
  532. package/server/dist/ws/clusterHandlers.js +373 -26
  533. package/server/dist/ws/clusterMembers.d.ts +5 -0
  534. package/server/dist/ws/clusterMembers.js +15 -5
  535. package/server/dist/ws/compactHandlers.js +43 -8
  536. package/server/dist/ws/compareHandlers.d.ts +12 -0
  537. package/server/dist/ws/compareHandlers.js +32 -14
  538. package/server/dist/ws/handoffHandlers.js +39 -3
  539. package/server/dist/ws/operatorQuestionHandlers.d.ts +5 -0
  540. package/server/dist/ws/operatorQuestionHandlers.js +17 -2
  541. package/server/dist/ws/taskLedgerHandlers.js +1 -0
  542. package/server/dist/ws/taskLifecycle.d.ts +25 -1
  543. package/server/dist/ws/taskLifecycle.js +53 -1
  544. package/server/dist/ws/turnEngine.d.ts +18 -1
  545. package/server/dist/ws/turnEngine.js +281 -52
  546. package/server/dist/ws/turnPrompt.js +3 -1
  547. package/server/dist/ws/updatePrimaryConfig.js +11 -3
  548. package/server/dist/ws/workflowHandlers.js +17 -4
  549. package/server/package.json +1 -1
  550. package/server/src/arcoHome.ts +16 -3
  551. package/server/src/auth.ts +50 -6
  552. package/server/src/authLoginSession.ts +10 -5
  553. package/server/src/capabilities.ts +13 -8
  554. package/server/src/chatMode.ts +24 -2
  555. package/server/src/checkedFile.ts +42 -31
  556. package/server/src/cliUpdateDecision.ts +1 -1
  557. package/server/src/clusterAutoTurn.ts +29 -5
  558. package/server/src/clusterBusyReminder.ts +2 -1
  559. package/server/src/clusterDirector.ts +5 -2
  560. package/server/src/clusterMailTally.ts +28 -0
  561. package/server/src/clusterMailbox.ts +49 -4
  562. package/server/src/clusterOpenWork.ts +94 -0
  563. package/server/src/clusterPeerOps.ts +238 -52
  564. package/server/src/clusterPlanBridge.ts +54 -1
  565. package/server/src/clusterPlanStore.ts +59 -0
  566. package/server/src/clusterPresets.ts +17 -3
  567. package/server/src/clusterProgress.ts +2 -2
  568. package/server/src/clusterSkills.ts +2 -2
  569. package/server/src/clusterSnapshots.ts +7 -1
  570. package/server/src/clusterStore.ts +192 -20
  571. package/server/src/clusterTurnOrigin.ts +19 -0
  572. package/server/src/connectionCatalog.ts +1 -0
  573. package/server/src/cursorUsage.ts +3 -3
  574. package/server/src/defaults/models.md +11 -14
  575. package/server/src/directorContinue.ts +309 -0
  576. package/server/src/directorContinueHook.ts +15 -0
  577. package/server/src/effortValidation.ts +31 -0
  578. package/server/src/fileAccessPolicy.ts +1 -0
  579. package/server/src/fileFetch.ts +47 -29
  580. package/server/src/geminiMembers.ts +116 -0
  581. package/server/src/git.ts +20 -22
  582. package/server/src/gitOtherWork.ts +5 -4
  583. package/server/src/gitSnapshots.ts +53 -5
  584. package/server/src/http/authLoginRoutes.ts +2 -2
  585. package/server/src/http/clusterRoutes.ts +314 -6
  586. package/server/src/http/diagnosticsRoutes.ts +9 -0
  587. package/server/src/http/fileWriteRoutes.ts +13 -5
  588. package/server/src/http/phoneUploadRoutes.ts +2 -1
  589. package/server/src/http/readConfinement.ts +30 -0
  590. package/server/src/http/recallRoutes.ts +1 -1
  591. package/server/src/http/router.ts +43 -10
  592. package/server/src/http/storageRoutes.ts +86 -7
  593. package/server/src/http/workflowDataRoutes.ts +20 -0
  594. package/server/src/http/writeConfinement.ts +10 -1
  595. package/server/src/index.ts +295 -18
  596. package/server/src/initialProviders.ts +1 -1
  597. package/server/src/manualCompactCapability.ts +1 -1
  598. package/server/src/mcp/clusterMcpLoopback.ts +2 -0
  599. package/server/src/mcp/clusterMcpServer.ts +3 -2
  600. package/server/src/mcp/clusterMcpTools.ts +83 -27
  601. package/server/src/mcp/mcpConfigWriter.ts +4 -0
  602. package/server/src/mcp/workerMailBridge.ts +99 -0
  603. package/server/src/planStore.ts +1 -0
  604. package/server/src/primitives/seedWorker.ts +19 -14
  605. package/server/src/project/taskLedger.ts +23 -0
  606. package/server/src/providers/{cursor → acp}/acpJsonRpc.ts +3 -3
  607. package/server/src/providers/acp/permissionGate.ts +47 -0
  608. package/server/src/providers/antigravity/index.ts +187 -0
  609. package/server/src/providers/antigravity/researchSignIn.ts +76 -0
  610. package/server/src/providers/antigravity/status.ts +24 -0
  611. package/server/src/providers/antigravity/usage.ts +29 -0
  612. package/server/src/providers/claude/researcherFence.ts +25 -0
  613. package/server/src/providers/claude-native/catalog.ts +5 -0
  614. package/server/src/providers/claude-native/index.ts +8 -1
  615. package/server/src/providers/claude-native/peerTools.ts +24 -4
  616. package/server/src/providers/claude-native/taskAdmission.ts +35 -9
  617. package/server/src/providers/claude-native/tools.ts +39 -19
  618. package/server/src/providers/claude-native/worker.ts +270 -52
  619. package/server/src/providers/claude-native/workerHelpers.ts +88 -5
  620. package/server/src/providers/claude.ts +160 -22
  621. package/server/src/providers/clusterTaskToolDefinitions.ts +2 -1
  622. package/server/src/providers/codex-appserver/heldCommands.ts +7 -3
  623. package/server/src/providers/codex-appserver/index.ts +87 -3
  624. package/server/src/providers/codex-appserver/lateCommands.ts +1 -0
  625. package/server/src/providers/codex-appserver/modelAvailability.ts +40 -0
  626. package/server/src/providers/codex-appserver/worker.ts +155 -25
  627. package/server/src/providers/codex.ts +1 -0
  628. package/server/src/providers/codexVersion.ts +9 -0
  629. package/server/src/providers/codexWebSearch.ts +1 -1
  630. package/server/src/providers/cursor/agentEnv.ts +103 -0
  631. package/server/src/providers/cursor/authState.ts +2 -1
  632. package/server/src/providers/cursor/authToken.ts +137 -31
  633. package/server/src/providers/cursor/catalog.ts +89 -1
  634. package/server/src/providers/cursor/chatSandbox.ts +20 -8
  635. package/server/src/providers/cursor/isolated.ts +282 -0
  636. package/server/src/providers/cursor/isolatedVersion.ts +33 -0
  637. package/server/src/providers/cursor/modelMap.ts +9 -5
  638. package/server/src/providers/cursor/print.ts +10 -8
  639. package/server/src/providers/cursor/worker.ts +8 -3
  640. package/server/src/providers/index.ts +10 -2
  641. package/server/src/providers/llamacpp.ts +3 -1
  642. package/server/src/providers/ollama.ts +30 -11
  643. package/server/src/providers/ollamaTools.ts +33 -27
  644. package/server/src/research/exportResults.ts +47 -0
  645. package/server/src/research/isolatedArtifact.ts +48 -0
  646. package/server/src/research/quickPromotion.ts +325 -0
  647. package/server/src/research/quickResearchChat.ts +147 -0
  648. package/server/src/research/researchClose.ts +340 -0
  649. package/server/src/research/researchCopy.ts +170 -0
  650. package/server/src/research/researchCreate.ts +306 -0
  651. package/server/src/research/researchDoctrine.ts +27 -0
  652. package/server/src/research/researchFolder.ts +202 -0
  653. package/server/src/research/researchLibrary.ts +306 -0
  654. package/server/src/research/researchRetry.ts +86 -0
  655. package/server/src/research/researchRounds.ts +891 -0
  656. package/server/src/research/researchState.ts +309 -0
  657. package/server/src/research/researchTools.ts +59 -0
  658. package/server/src/research/researchTripwires.ts +158 -0
  659. package/server/src/research/resultSelection.ts +127 -0
  660. package/server/src/research/savedQuickPromotion.ts +174 -0
  661. package/server/src/research/sendToProject.ts +220 -0
  662. package/server/src/server/broadcast.ts +39 -5
  663. package/server/src/server/updateCheck.ts +1 -0
  664. package/server/src/settings.ts +22 -5
  665. package/server/src/skillActivity.ts +35 -0
  666. package/server/src/smartPickup.ts +14 -4
  667. package/server/src/smartPickupAdapters.ts +3 -2
  668. package/server/src/smartPickupEvaluator.ts +3 -0
  669. package/server/src/smartPickupObserver.ts +38 -12
  670. package/server/src/storageActions.ts +6 -0
  671. package/server/src/storageOverview.ts +13 -6
  672. package/server/src/taskDispatcher.ts +3 -1
  673. package/server/src/toolboxWorkflow.ts +2 -1
  674. package/server/src/updateCheck.ts +31 -3
  675. package/server/src/workers/StreamParser.ts +20 -1
  676. package/server/src/workers/WorkerManager.ts +10 -1
  677. package/server/src/workers/antigravityIsolatedLaunch.ts +82 -0
  678. package/server/src/workers/checkedLinuxWorker.ts +212 -0
  679. package/server/src/workers/claudeAccessLease.ts +122 -0
  680. package/server/src/workers/claudeAccessSource.ts +20 -0
  681. package/server/src/workers/claudeIsolatedLaunch.ts +91 -0
  682. package/server/src/workers/cliResearcherDoctrine.ts +20 -0
  683. package/server/src/workers/codexAccessLease.ts +146 -0
  684. package/server/src/workers/codexIsolatedLaunch.ts +72 -0
  685. package/server/src/workers/codexIsolatedPolicy.ts +38 -0
  686. package/server/src/workers/cursorIsolatedLaunch.ts +159 -0
  687. package/server/src/workers/isolatedCliHome.ts +75 -0
  688. package/server/src/workers/limits.ts +1 -1
  689. package/server/src/workers/linuxWorkerSandbox.ts +193 -0
  690. package/server/src/workers/processKill.ts +34 -2
  691. package/server/src/workers/providerRuntimeDiscovery.ts +108 -0
  692. package/server/src/workers/researchSandboxAvailability.ts +68 -0
  693. package/server/src/workers/workerAccessPass.ts +96 -0
  694. package/server/src/workers/workerHiddenDirectories.ts +16 -0
  695. package/server/src/workers/workerSocketDirectory.ts +13 -0
  696. package/server/src/workers/workerWebProxy.ts +194 -0
  697. package/server/src/workflowMeta.ts +10 -3
  698. package/server/src/workflowStore.ts +39 -26
  699. package/server/src/workflows/purgeWorkflow.ts +18 -0
  700. package/server/src/workflows/types.ts +13 -0
  701. package/server/src/workspace.ts +8 -0
  702. package/server/src/ws/clusterHandlers.ts +302 -26
  703. package/server/src/ws/clusterMembers.ts +15 -5
  704. package/server/src/ws/compactHandlers.ts +37 -5
  705. package/server/src/ws/compareHandlers.ts +34 -11
  706. package/server/src/ws/handoffHandlers.ts +36 -3
  707. package/server/src/ws/operatorQuestionHandlers.ts +14 -2
  708. package/server/src/ws/taskLedgerHandlers.ts +1 -0
  709. package/server/src/ws/taskLifecycle.ts +58 -4
  710. package/server/src/ws/turnEngine.ts +265 -49
  711. package/server/src/ws/turnPrompt.ts +3 -1
  712. package/server/src/ws/updatePrimaryConfig.ts +10 -3
  713. package/server/src/ws/workflowHandlers.ts +15 -4
  714. package/shared/dist/clusterCoordination.d.ts +1 -0
  715. package/shared/dist/clusterCoordination.js +9 -1
  716. package/shared/dist/clusterRolePresets.js +13 -4
  717. package/shared/dist/index.d.ts +1 -0
  718. package/shared/dist/index.js +1 -0
  719. package/shared/dist/protocol/autoPickup.d.ts +7 -0
  720. package/shared/dist/protocol/autoPickup.js +22 -11
  721. package/shared/dist/protocol/chat.d.ts +1 -1
  722. package/shared/dist/protocol/checkpoints.d.ts +1 -0
  723. package/shared/dist/protocol/clientMessages.d.ts +18 -3
  724. package/shared/dist/protocol/clusters.d.ts +177 -4
  725. package/shared/dist/protocol/clusters.js +48 -2
  726. package/shared/dist/protocol/handoffs.d.ts +1 -0
  727. package/shared/dist/protocol/models.d.ts +6 -1
  728. package/shared/dist/protocol/models.js +4 -3
  729. package/shared/dist/protocol/providers.d.ts +3 -2
  730. package/shared/dist/protocol/providers.js +1 -1
  731. package/shared/dist/protocol/serverMessages.d.ts +28 -3
  732. package/shared/dist/protocol/settings.d.ts +4 -0
  733. package/shared/dist/protocol/settings.js +3 -1
  734. package/shared/dist/protocol/tasks.d.ts +42 -0
  735. package/shared/dist/protocol/tasks.js +17 -0
  736. package/shared/dist/protocol/workflows.d.ts +4 -0
  737. package/shared/dist/protocol/workflows.js +2 -0
  738. package/shared/dist/researchActivity.d.ts +4 -0
  739. package/shared/dist/researchActivity.js +29 -0
  740. package/shared/src/clusterCoordination.ts +12 -1
  741. package/shared/src/clusterRolePresets.ts +13 -4
  742. package/shared/src/index.ts +2 -0
  743. package/shared/src/protocol/autoPickup.ts +28 -11
  744. package/shared/src/protocol/chat.ts +1 -1
  745. package/shared/src/protocol/checkpoints.ts +1 -0
  746. package/shared/src/protocol/clientMessages.ts +14 -0
  747. package/shared/src/protocol/clusters.ts +231 -5
  748. package/shared/src/protocol/handoffs.ts +1 -0
  749. package/shared/src/protocol/models.ts +11 -4
  750. package/shared/src/protocol/providers.ts +6 -3
  751. package/shared/src/protocol/reviews.ts +2 -2
  752. package/shared/src/protocol/serverMessages.ts +28 -3
  753. package/shared/src/protocol/settings.ts +14 -1
  754. package/shared/src/protocol/tasks.ts +73 -0
  755. package/shared/src/protocol/workflows.ts +8 -0
  756. package/shared/src/researchActivity.ts +23 -0
  757. package/client/dist/assets/XtermView-Xk7_9JaH.js +0 -10
  758. package/client/dist/assets/index-BEFgrUJJ.css +0 -1
  759. package/client/dist/assets/index-C7WzZfsr.js +0 -614
  760. package/client/src/components/HeaderAuthChip.tsx +0 -207
  761. /package/server/dist/providers/{cursor → acp}/acpJsonRpc.d.ts +0 -0
@@ -0,0 +1,147 @@
1
+ // Preserve a closed Quick research answer as an ordinary saved Chat. The
2
+ // source research workspace remains intact until the operator promotes or
3
+ // removes it; a failed snapshot never removes researcher files.
4
+ import { randomUUID } from 'node:crypto';
5
+ import { promises as fs } from 'node:fs';
6
+ import { basename, dirname, join, resolve } from 'node:path';
7
+ import type { ServerMessage } from '@arco/shared';
8
+ import { withFileLock } from '../atomicFile.js';
9
+ import { antigravityChatWorkspace, chatRootDir, chatStorageDir } from '../chatMode.js';
10
+ import { readLogLines } from '../eventLog.js';
11
+ import { ensureStorageRoot } from '../storageRoot.js';
12
+ import { readMeta, persistInitialMeta, updateMeta, workflowConfigFromMeta } from '../workflowMeta.js';
13
+ import { flushWorkflowBuffer, forgetWorkflowBuffer, initWorkflowStore, persistAndStampSeq } from '../workflowStore.js';
14
+ import type { ResearchState } from './researchState.js';
15
+
16
+ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
17
+
18
+ export async function saveQuickResearchChat(state: ResearchState, moved: string[]): Promise<string> {
19
+ if (!state.quick || !UUID.test(state.projectId)) throw new Error('Invalid Quick research record.');
20
+ const chatId = state.projectId;
21
+ const final = chatStorageDir(chatId);
22
+ return withFileLock(final, async () => {
23
+ const expected = [...moved].sort();
24
+ const marker = join(final, 'quick-research.json');
25
+ const existing = await fs.readFile(marker, 'utf8').then(text => JSON.parse(text) as { projectId?: string; files?: string[] }).catch(() => null);
26
+ if (existing) {
27
+ if (existing.projectId !== chatId || JSON.stringify(existing.files) !== JSON.stringify(expected)) throw new Error('The saved Quick research files changed. The researcher files remain available.');
28
+ return chatId;
29
+ }
30
+ const sourceMeta = await readMeta(state.folder, state.directorWorkflowId);
31
+ if (!sourceMeta) throw new Error('The Research Director conversation is missing.');
32
+ await flushWorkflowBuffer(state.folder, state.directorWorkflowId);
33
+ const root = await ensureStorageRoot(chatRootDir());
34
+ const stage = await fs.mkdtemp(join(root, 'quick-save-'));
35
+ let initialized = false;
36
+ let reserved = false;
37
+ try {
38
+ await initWorkflowStore(stage, chatId); initialized = true;
39
+ const config = { ...workflowConfigFromMeta(sourceMeta, final), name: state.name, kind: 'chat' as const, workingDirectory: final, incognito: false };
40
+ await persistInitialMeta(stage, chatId, config, { provider: sourceMeta.primaryProvider, model: sourceMeta.primaryModel, effort: sourceMeta.primaryEffort });
41
+ await updateMeta(stage, chatId, meta => { meta.cwd = final; meta.kind = 'chat'; meta.lastUserPreview = state.brief.replace(/\s+/g, ' ').trim().slice(0, 80); });
42
+ let retained = 0;
43
+ const log = join(state.folder, '.arco', 'workflows', state.directorWorkflowId);
44
+ for await (const line of readLogLines(log)) {
45
+ let event: ServerMessage;
46
+ try { event = JSON.parse(line) as ServerMessage; } catch { continue; }
47
+ if (event.type !== 'user_message_echo' && event.type !== 'primary_text' && event.type !== 'primary_complete') continue;
48
+ persistAndStampSeq(stage, chatId, { ...event, workflowId: chatId } as ServerMessage);
49
+ if (++retained % 100 === 0) await flushWorkflowBuffer(stage, chatId);
50
+ }
51
+ if (moved.length) {
52
+ const artifacts = join(stage, '.arco', 'workflows', chatId, 'artifacts');
53
+ const finalArtifacts = join(final, '.arco', 'workflows', chatId, 'artifacts');
54
+ const attachments: string[] = [];
55
+ for (const name of moved) {
56
+ const file = basename(name);
57
+ if (name !== `sources/${file}` || !file) throw new Error('Invalid researcher file name.');
58
+ const storedName = `${randomUUID().slice(0, 8)}-${file}`;
59
+ const target = join(artifacts, storedName);
60
+ const sourcePath = join(state.folder, 'sources', file);
61
+ if ((await fs.lstat(sourcePath)).isSymbolicLink()) throw new Error('A researcher file is a link.');
62
+ const source = await fs.open(sourcePath, fs.constants.O_RDONLY | (fs.constants.O_NOFOLLOW ?? 0));
63
+ let destination: Awaited<ReturnType<typeof fs.open>> | undefined;
64
+ try {
65
+ const stat = await source.stat();
66
+ if (!stat.isFile() || stat.nlink !== 1) throw new Error('A researcher file is no longer a regular file.');
67
+ destination = await fs.open(target, 'wx', 0o600);
68
+ const buffer = Buffer.allocUnsafe(64 * 1024);
69
+ for (let offset = 0; offset < stat.size;) {
70
+ const { bytesRead } = await source.read(buffer, 0, Math.min(buffer.length, stat.size - offset), offset);
71
+ if (!bytesRead) throw new Error('A researcher file changed while being saved.');
72
+ for (let written = 0; written < bytesRead;) {
73
+ const result = await destination.write(buffer, written, bytesRead - written, offset + written);
74
+ if (!result.bytesWritten) throw new Error('A researcher file could not be saved.');
75
+ written += result.bytesWritten;
76
+ }
77
+ offset += bytesRead;
78
+ }
79
+ const after = await source.stat();
80
+ if (after.size !== stat.size || after.mtimeMs !== stat.mtimeMs || after.ctimeMs !== stat.ctimeMs) throw new Error('A researcher file changed while being saved.');
81
+ } catch (error) {
82
+ await destination?.close().catch(() => undefined);
83
+ if (destination) await fs.rm(target, { force: true }).catch(() => undefined);
84
+ destination = undefined;
85
+ throw error;
86
+ } finally { await destination?.close().catch(() => undefined); await source.close().catch(() => undefined); }
87
+ attachments.push(join(finalArtifacts, storedName));
88
+ }
89
+ persistAndStampSeq(stage, chatId, { type: 'user_message_echo', workflowId: chatId, content: 'Files kept from researchers.', attachments, timestamp: Date.now() });
90
+ }
91
+ await flushWorkflowBuffer(stage, chatId);
92
+ forgetWorkflowBuffer(stage, chatId); initialized = false;
93
+ await fs.writeFile(join(stage, 'quick-research.json'), JSON.stringify({ projectId: chatId, files: expected }), { flag: 'wx', mode: 0o600 });
94
+ await fs.mkdir(final, { mode: 0o700 }); reserved = true;
95
+ // Windows cannot rename onto an existing directory, even an empty one.
96
+ await fs.rmdir(final); reserved = false;
97
+ await fs.rename(stage, final);
98
+ return chatId;
99
+ } catch (error) {
100
+ if (initialized) forgetWorkflowBuffer(stage, chatId);
101
+ if (reserved) await fs.rmdir(final).catch(() => undefined);
102
+ await fs.rm(stage, { recursive: true, force: true }).catch(() => undefined);
103
+ throw error;
104
+ }
105
+ });
106
+ }
107
+
108
+ // Called only by explicit Chat purge. The marker, closed record and managed
109
+ // workspace must all agree before any Quick research source is removed.
110
+ export async function deleteQuickResearchForChat(cwd: string, chatId: string): Promise<boolean> {
111
+ if (!UUID.test(chatId) || resolve(cwd) !== resolve(chatStorageDir(chatId))) return false;
112
+ const markerPath = join(cwd, 'quick-research.json');
113
+ let marker: { projectId?: string };
114
+ try { marker = JSON.parse(await fs.readFile(markerPath, 'utf8')) as { projectId?: string }; }
115
+ catch (error) { if ((error as NodeJS.ErrnoException).code === 'ENOENT') return false; throw error; }
116
+ if (marker.projectId !== chatId) throw new Error('The Quick research marker does not match this Chat.');
117
+ await (await import('./savedQuickPromotion.js')).cancelSavedQuickPromotion(chatId);
118
+ const { readClosedRecord, removeQuickLibraryEntry } = await import('./researchLibrary.js');
119
+ const { closedResearchRecordPath } = await import('./researchClose.js');
120
+ const record = await readClosedRecord(chatId);
121
+ if (!record) throw new Error('The Quick research record is missing; its files were not deleted.');
122
+ const workspace = antigravityChatWorkspace(chatId);
123
+ if (record.quick && resolve(record.folder) !== resolve(workspace)) throw new Error('The Quick research record points to another folder.');
124
+ await removeQuickWorkspace(chatId, workspace);
125
+ if (record.quick) {
126
+ await removeQuickLibraryEntry(chatId, workspace);
127
+ await fs.rm(closedResearchRecordPath(chatId), { force: true });
128
+ }
129
+ await (await import('./savedQuickPromotion.js')).removeSavedQuickPromotion(chatId);
130
+ await fs.rm(markerPath, { force: true });
131
+ return true;
132
+ }
133
+
134
+ // Only the matching managed workspace may be removed after a successful
135
+ // promotion or explicit deletion of its owning saved Chat.
136
+ export async function removeQuickWorkspace(projectId: string, workspace: string): Promise<void> {
137
+ if (!UUID.test(projectId) || resolve(workspace) !== resolve(antigravityChatWorkspace(projectId))) throw new Error('The Quick research workspace path does not match.');
138
+ const root = await fs.lstat(dirname(workspace)).catch((error: NodeJS.ErrnoException) => { if (error.code === 'ENOENT') return null; throw error; });
139
+ if (root?.isSymbolicLink()) throw new Error('The Quick research workspace root is a link.');
140
+ const info = await fs.lstat(workspace).catch((error: NodeJS.ErrnoException) => { if (error.code === 'ENOENT') return null; throw error; });
141
+ if (info) {
142
+ if (info.isSymbolicLink() || !info.isDirectory()) throw new Error('The Quick research workspace is not a real folder.');
143
+ const manifest = JSON.parse(await fs.readFile(join(workspace, 'research.json'), 'utf8')) as { projectId?: string };
144
+ if (manifest.projectId !== projectId) throw new Error('The Quick research workspace does not match this project.');
145
+ await fs.rm(workspace, { recursive: true });
146
+ }
147
+ }
@@ -0,0 +1,340 @@
1
+ // docs/RESEARCH.md - closing a research tab: the one moment of cleanup.
2
+ //
3
+ // The operator closes the tab; Arco writes a one-page log per researcher
4
+ // into the latest round.md, optionally moves files a researcher saved but
5
+ // never sent into sources/, then removes the researchers' workspaces and
6
+ // conversations. The research folder and the Research Director's
7
+ // conversation are kept. After a crash the startup sweep removes only the
8
+ // researcher folders of projects whose cluster no longer exists.
9
+ import { createHash } from 'node:crypto';
10
+ import { researchSearchDetails } from '@arco/shared';
11
+ import { saveQuickResearchChat } from './quickResearchChat.js';
12
+ import { promises as fs } from 'node:fs';
13
+ import { basename, dirname, join, relative, sep } from 'node:path';
14
+ import { clusterDir, isolatedWorkspaceFor, setBeforeClusterDelete } from '../clusterStore.js';
15
+ import { forgetResearchTripwires, RESEARCH_CANARY_FILE } from './researchTripwires.js';
16
+ import { atomicWriteFile } from '../atomicFile.js';
17
+ import { readLogLines } from '../eventLog.js';
18
+ import { flushWorkflowBuffer } from '../workflowStore.js';
19
+ import { researchMembersRoot } from './researchCreate.js';
20
+ import { roundDir, writeProjectFiles } from './researchFolder.js';
21
+ import { forgetResearch, loadResearch, researcherName, updateResearch, type ResearchResearcher, type ResearchState } from './researchState.js';
22
+
23
+ export interface UnsentFile { letter: string; path: string; bytes: number }
24
+
25
+ const MAX_LISTED_FILES = 200;
26
+ const LOG_LIST_LIMIT = 15;
27
+ const SWEEP_MIN_AGE_MS = 10 * 60_000;
28
+
29
+ async function hashFile(path: string): Promise<string> {
30
+ const hash = createHash('sha256');
31
+ const handle = await fs.open(path, 'r');
32
+ try {
33
+ for await (const chunk of handle.createReadStream()) hash.update(chunk as Buffer);
34
+ } finally {
35
+ await handle.close().catch(() => undefined);
36
+ }
37
+ return hash.digest('hex').slice(0, 12);
38
+ }
39
+
40
+ async function* walk(root: string, missingOk = false): AsyncGenerator<string> {
41
+ const entries = await fs.readdir(root, { withFileTypes: true }).catch(error => {
42
+ if (missingOk && (error as NodeJS.ErrnoException).code === 'ENOENT') return [];
43
+ throw error;
44
+ });
45
+ for (const entry of entries) {
46
+ const path = join(root, entry.name);
47
+ if (entry.isDirectory()) yield* walk(path);
48
+ else if (entry.isFile()) yield path;
49
+ }
50
+ }
51
+
52
+ function workspaceOf(state: ResearchState, r: ResearchResearcher): string {
53
+ return isolatedWorkspaceFor(state.clusterId, r.workflowId);
54
+ }
55
+
56
+ // Stream the full workspace for close. Only the dialog preview is capped.
57
+ async function* filesToKeep(state: ResearchState, letters?: string[]) {
58
+ const sources = join(state.folder, 'sources');
59
+ const entries = await fs.readdir(sources, { withFileTypes: true }).catch(error => {
60
+ if ((error as NodeJS.ErrnoException).code === 'ENOENT') return [];
61
+ throw error;
62
+ });
63
+ const sent = new Map<string, string[]>();
64
+ for (const entry of entries) {
65
+ if (!entry.isFile()) continue;
66
+ const hash = entry.name.slice(0, 12);
67
+ const names = sent.get(hash);
68
+ if (names) names.push(entry.name);
69
+ else sent.set(hash, [entry.name]);
70
+ }
71
+ for (const r of state.researchers) {
72
+ if (letters && !letters.includes(r.letter)) continue;
73
+ const root = workspaceOf(state, r);
74
+ for await (const from of walk(root, true)) {
75
+ if (state.isolationCanaries?.[r.workflowId] && from === join(root, RESEARCH_CANARY_FILE)) continue;
76
+ const hash = await hashFile(from);
77
+ const safe = basename(from).replace(/[^A-Za-z0-9._-]+/g, '_').replace(/^\.+/, '').slice(0, 80) || 'file';
78
+ const name = `${hash}-kept-${safe}`;
79
+ let alreadySent = false;
80
+ for (const candidate of sent.get(hash) ?? []) {
81
+ // Include copies from an earlier close attempt so a retried Quick
82
+ // research save still attaches the same files.
83
+ if (!candidate.startsWith(`${hash}-kept-`) && await hashFile(join(sources, candidate)) === hash) {
84
+ alreadySent = true;
85
+ break;
86
+ }
87
+ }
88
+ if (!alreadySent) yield { from, name, hash, letter: r.letter, path: relative(root, from).split(sep).join('/'), bytes: (await fs.stat(from)).size };
89
+ }
90
+ }
91
+ }
92
+
93
+ export async function unsentFiles(state: ResearchState, letters?: string[]): Promise<UnsentFile[]> {
94
+ const out: UnsentFile[] = [];
95
+ for await (const { letter, path, bytes } of filesToKeep(state, letters)) {
96
+ out.push({ letter, path, bytes });
97
+ if (out.length >= MAX_LISTED_FILES) break;
98
+ }
99
+ return out;
100
+ }
101
+
102
+ interface LogFacts { turns: number; searches: string[]; sources: string[]; failures: string[] }
103
+
104
+ function inputField(input: unknown, key: string): string | undefined {
105
+ if (typeof input !== 'string') return undefined;
106
+ try {
107
+ const parsed = JSON.parse(input) as Record<string, unknown>;
108
+ const value = parsed?.[key];
109
+ return typeof value === 'string' ? value : undefined;
110
+ } catch { return undefined; }
111
+ }
112
+
113
+ async function logFacts(workflowDir: string): Promise<LogFacts> {
114
+ const facts: LogFacts = { turns: 0, searches: [], sources: [], failures: [] };
115
+ const seen = new Set<string>();
116
+ for await (const line of readLogLines(workflowDir)) {
117
+ let e: Record<string, unknown>;
118
+ try { e = JSON.parse(line) as Record<string, unknown>; } catch { continue; }
119
+ if (e.type === 'primary_turn_started') facts.turns++;
120
+ else if (e.type === 'error' && typeof e.message === 'string') facts.failures.push(e.message.slice(0, 200));
121
+ else if (e.type === 'primary_tool_use' && typeof e.tool === 'string') {
122
+ const id = String(e.itemId ?? e.toolUseId ?? `${e.tool}:${e.input}`);
123
+ if (e.status === 'failed') facts.failures.push(`${e.tool} failed${typeof e.output === 'string' ? `: ${e.output.slice(0, 160)}` : ''}`);
124
+ if (seen.has(id)) continue;
125
+ seen.add(id);
126
+ // Cursor names the search text `searchTerm`.
127
+ const search = researchSearchDetails(e.tool, e.input);
128
+ if (search.search) facts.searches.push(search.query ?? '(query not recorded)');
129
+ else if (/^(web_fetch|WebFetch)$/.test(e.tool)) facts.sources.push(inputField(e.input, 'url') ?? '(address not recorded)');
130
+ }
131
+ }
132
+ return facts;
133
+ }
134
+
135
+ function list(items: string[]): string[] {
136
+ const shown = items.slice(0, LOG_LIST_LIMIT).map((item) => ` - ${item.replace(/\s+/g, ' ')}`);
137
+ return items.length > LOG_LIST_LIMIT ? [...shown, ` - and ${items.length - LOG_LIST_LIMIT} more`] : shown;
138
+ }
139
+
140
+ // One page per researcher: turns, searches made, sources opened, failures.
141
+ export async function researcherLogs(state: ResearchState, heading: '#' | '##' = '##'): Promise<string> {
142
+ const lines = [...(heading === '##' ? [''] : []), `${heading} Researcher logs`, '', 'Written when the research tab was closed; the researchers\' conversations were then removed.', ''];
143
+ // A reopened project's earlier panel was logged when it first closed.
144
+ for (const r of state.researchers.filter((x) => !(state.reopenedAt && x.removedAt && x.removedAt <= state.reopenedAt))) {
145
+ const f = await logFacts(join(state.membersCwd, '.arco', 'workflows', r.workflowId));
146
+ lines.push(`${heading}# ${researcherName(r.letter)}`, '',
147
+ `- Turns: ${f.turns}`,
148
+ `- Web searches: ${f.searches.length}`, ...list(f.searches),
149
+ `- Sources opened: ${new Set(f.sources).size}`, ...list([...new Set(f.sources)]),
150
+ `- Failed tool calls Arco recorded: ${f.failures.length}`, ...list(f.failures), '');
151
+ }
152
+ return lines.join('\n');
153
+ }
154
+
155
+ // The Arco-side record of a closed project: author mapping, rounds and
156
+ // dates. Kept in Arco's data, never in the research folder, so a resumed
157
+ // Director still cannot read who wrote which report. Never swept.
158
+ export function closedResearchRecordPath(projectId: string): string {
159
+ return join(researchMembersRoot(), 'closed', `${projectId}.json`);
160
+ }
161
+
162
+ async function keepClosedRecord(state: ResearchState): Promise<void> {
163
+ const path = closedResearchRecordPath(state.projectId);
164
+ await fs.mkdir(dirname(path), { recursive: true, mode: 0o700 });
165
+ await atomicWriteFile(path, JSON.stringify(state, null, 2) + '\n');
166
+ await fs.chmod(path, 0o600).catch(() => undefined);
167
+ }
168
+
169
+ export type CloseResult =
170
+ | { ok: true; logsWrittenTo: string; moved: string[]; removed: number }
171
+ | { ok: false; error: 'unknown_research' | 'researcher_busy' | 'director_busy'; letters?: string[] };
172
+
173
+ // Copies files researchers saved but never sent into sources/; returns
174
+ // their project-relative names.
175
+ export async function moveUnsentFiles(state: ResearchState, letters?: string[]): Promise<string[]> {
176
+ const moved = new Set<string>();
177
+ await fs.mkdir(join(state.folder, 'sources'), { recursive: true });
178
+ for await (const { from, name, hash } of filesToKeep(state, letters)) {
179
+ const target = join(state.folder, 'sources', name);
180
+ await fs.copyFile(from, target, fs.constants.COPYFILE_EXCL).catch((error: NodeJS.ErrnoException) => {
181
+ if (error.code !== 'EEXIST') throw error;
182
+ });
183
+ if (!(await fs.lstat(target)).isFile() || await hashFile(target) !== hash || await hashFile(from) !== hash) {
184
+ throw new Error('A researcher file could not be copied safely. Its workspace was kept.');
185
+ }
186
+ moved.add(`sources/${name}`);
187
+ }
188
+ return [...moved];
189
+ }
190
+
191
+ // A removed researcher's private workspace and provider home.
192
+ export async function removeResearcherWorkspace(state: ResearchState, workflowId: string): Promise<void> {
193
+ const r = state.researchers.find((x) => x.workflowId === workflowId);
194
+ if (r) await fs.rm(dirname(workspaceOf(state, r)), { recursive: true, force: true });
195
+ }
196
+
197
+ // `force` is a cluster deletion under the cluster lock. It refuses active
198
+ // work without waiting for a promotion that might need the same lock.
199
+ export async function closeResearch(clusterId: string, opts: { moveUnsent: boolean; isBusy: (workflowId: string) => boolean; now?: () => number; waitMs?: number; force?: boolean }): Promise<CloseResult> {
200
+ let current = await loadResearch(clusterId);
201
+ if (!current) return { ok: false, error: 'unknown_research' };
202
+ if (current.quick) {
203
+ const promotion = await import('./quickPromotion.js');
204
+ // A forced close runs under the cluster lock. Do not wait for a copy that
205
+ // might itself be waiting for that lock; leave the cluster intact instead.
206
+ if (opts.force) {
207
+ if (promotion.stopQuickPromotionTimer(clusterId)) return { ok: false, error: 'director_busy' };
208
+ } else {
209
+ await promotion.cancelQuickPromotion(clusterId);
210
+ current = await loadResearch(clusterId);
211
+ if (!current) return { ok: false, error: 'unknown_research' };
212
+ }
213
+ }
214
+ const state = current;
215
+ if (state.quick && opts.isBusy(state.directorWorkflowId)) return { ok: false, error: 'director_busy' };
216
+ if (state.closedAt) {
217
+ await keepClosedRecord(state);
218
+ return { ok: true, logsWrittenTo: '', moved: [], removed: await removeResearchWorkspaces(state) };
219
+ }
220
+ // The client closes the researcher tabs first, which cancels their turns;
221
+ // give a cancelled turn a moment to settle before touching its files.
222
+ const deadline = Date.now() + (opts.waitMs ?? 10_000);
223
+ let busy = state.researchers.filter((r) => opts.isBusy(r.workflowId));
224
+ while (busy.length && Date.now() < deadline) {
225
+ await new Promise((resolve) => setTimeout(resolve, 250));
226
+ busy = busy.filter((r) => opts.isBusy(r.workflowId));
227
+ }
228
+ if (busy.length) return { ok: false, error: 'researcher_busy', letters: busy.map((r) => r.letter) };
229
+
230
+ // Hold the sources idle while the logs and attachments are copied.
231
+ const releases: Array<() => void> = [];
232
+ const ids = state.researchers.map(r => r.workflowId);
233
+ if (state.quick) ids.push(state.directorWorkflowId);
234
+ const { workflows } = await import('../server/state.js');
235
+ const { reserveWorkflowMigration } = await import('../ws/turnEngine.js');
236
+ for (const id of ids) {
237
+ const wf = workflows.get(id);
238
+ if (!wf) continue;
239
+ try { releases.push(reserveWorkflowMigration(wf)); }
240
+ catch {
241
+ for (const release of releases.reverse()) release();
242
+ return id === state.directorWorkflowId
243
+ ? { ok: false, error: 'director_busy' }
244
+ : { ok: false, error: 'researcher_busy', letters: state.researchers.filter(r => r.workflowId === id).map(r => r.letter) };
245
+ }
246
+ }
247
+ try {
248
+ await Promise.all(state.researchers.map(r => flushWorkflowBuffer(state.membersCwd, r.workflowId)));
249
+ const moved = opts.moveUnsent ? await moveUnsentFiles(state) : [];
250
+ if (state.quick) await saveQuickResearchChat(state, moved);
251
+
252
+ const latest = state.rounds.at(-1);
253
+ const logsPath = latest ? join(roundDir(state.folder, latest.n), 'round.md') : join(state.folder, 'researcher-logs.md');
254
+ const moves = moved.length ? `\nFiles the researchers saved but never sent, moved on close:\n${moved.map((m) => `- ${m}`).join('\n')}\n` : '';
255
+ const logs = await researcherLogs(state, latest ? '##' : '#') + moves;
256
+ const previous = await fs.readFile(logsPath, 'utf8').catch(error => {
257
+ if ((error as NodeJS.ErrnoException).code === 'ENOENT') return '';
258
+ throw error;
259
+ });
260
+ if (!previous.endsWith(logs)) await atomicWriteFile(logsPath, previous + logs);
261
+
262
+ const closedAt = new Date((opts.now ?? Date.now)()).toISOString();
263
+ const closing = { ...state, closedAt };
264
+ await keepClosedRecord(closing);
265
+ await writeProjectFiles(closing);
266
+ if (!await updateResearch(clusterId, (s) => { s.closedAt = closedAt; })) throw new Error('The research state could not be closed.');
267
+ const removed = await removeResearchWorkspaces(state);
268
+ return { ok: true, logsWrittenTo: relative(state.folder, logsPath).split(sep).join('/'), moved, removed };
269
+ } finally { for (const release of releases.reverse()) release(); }
270
+ }
271
+
272
+ async function removeResearchWorkspaces(state: ResearchState): Promise<number> {
273
+ for (const r of state.researchers) await removeResearcherWorkspace(state, r.workflowId);
274
+ await fs.rm(state.membersCwd, { recursive: true, force: true });
275
+ return state.researchers.length;
276
+ }
277
+
278
+ // Startup: researcher conversation folders whose project has no cluster any
279
+ // more belong to a closed tab whose cleanup did not finish. Never touches a
280
+ // research folder. Recently changed folders are left for a project that is
281
+ // being created right now.
282
+ export async function sweepClosedResearch(liveProjectIds: Set<string>, nowMs = Date.now()): Promise<string[]> {
283
+ const root = researchMembersRoot();
284
+ const removed: string[] = [];
285
+ const entries = await fs.readdir(root, { withFileTypes: true }).catch(() => []);
286
+ for (const entry of entries) {
287
+ // Only project folders (uuid names); `closed/` holds the kept records.
288
+ if (!entry.isDirectory() || !/^[0-9a-f-]{36}$/.test(entry.name) || liveProjectIds.has(entry.name)) continue;
289
+ const path = join(root, entry.name);
290
+ const stat = await fs.stat(path).catch(() => null);
291
+ if (!stat || nowMs - stat.mtimeMs < SWEEP_MIN_AGE_MS) continue;
292
+ await fs.rm(path, { recursive: true, force: true });
293
+ removed.push(entry.name);
294
+ }
295
+ return removed;
296
+ }
297
+
298
+ // Project ids of every cluster folder that still holds research state. An
299
+ // unreadable research.json stops the sweep: a folder is kept when in doubt.
300
+ export async function researchProjectIdsOnDisk(): Promise<Set<string> | null> {
301
+ let clusterIds: string[];
302
+ try { clusterIds = await fs.readdir(dirname(clusterDir('probe'))); } catch (error) {
303
+ return (error as NodeJS.ErrnoException).code === 'ENOENT' ? new Set() : null;
304
+ }
305
+ const ids = new Set<string>();
306
+ for (const id of clusterIds) {
307
+ let raw: string;
308
+ try { raw = await fs.readFile(join(clusterDir(id), 'research.json'), 'utf8'); } catch (error) {
309
+ if ((error as NodeJS.ErrnoException).code === 'ENOENT') continue;
310
+ return null;
311
+ }
312
+ try {
313
+ const projectId = (JSON.parse(raw) as { projectId?: unknown }).projectId;
314
+ if (typeof projectId !== 'string') return null;
315
+ ids.add(projectId);
316
+ } catch { return null; }
317
+ }
318
+ return ids;
319
+ }
320
+
321
+ // docs/RESEARCH.md - every deletion of a research cluster (tab close, a
322
+ // dissolve, a delete from elsewhere) runs the same close first: logs, unsent
323
+ // files moved into sources/, the closed record kept. The tab close has
324
+ // already done it, so this is a no-op then.
325
+ export function installResearchCloseOnDelete(isBusy: (workflowId: string) => boolean): void {
326
+ setBeforeClusterDelete(async (cluster) => {
327
+ if (!cluster.research) return;
328
+ let quick = false;
329
+ try {
330
+ quick = (await loadResearch(cluster.clusterId))?.quick === true;
331
+ const result = await closeResearch(cluster.clusterId, { moveUnsent: true, isBusy, waitMs: 0, force: true });
332
+ if (!result.ok) throw new Error(result.error);
333
+ } catch (error) {
334
+ const label = quick ? 'Quick research' : 'Research';
335
+ throw Object.assign(new Error(`${label} could not be saved; the research tab remains open.`), { code: 'preserve_research', cause: error });
336
+ }
337
+ forgetResearch(cluster.clusterId);
338
+ forgetResearchTripwires(cluster.clusterId);
339
+ });
340
+ }
@@ -0,0 +1,170 @@
1
+ // docs/RESEARCH.md "Copied research layout" - how released research is laid
2
+ // out when it is copied into a project folder (Send to a project and Start a
3
+ // project). The research project's own folder is never changed; this only
4
+ // renames files in the copy and writes a README.md index.
5
+ import { promises as fs } from 'node:fs';
6
+ import { posix } from 'node:path';
7
+ import type { ResearchRound, ResearchState } from './researchState.js';
8
+ import { researcherName } from './researchState.js';
9
+ import { readChecked, selectResearchFiles, RESEARCH_COPY_LIMITS, type ResearchSelection, type SelectedResearchFile } from './resultSelection.js';
10
+ import { sourceFileName } from './researchFolder.js';
11
+
12
+ export interface ResearchCopyCounts { rounds: number; catchUps: number; reports: number; summaries: number; returnedFiles: number }
13
+ export interface ResearchCopy {
14
+ files: SelectedResearchFile[];
15
+ counts: ResearchCopyCounts;
16
+ // The copied summary the new project starts from, when there is one.
17
+ startSummary?: string;
18
+ }
19
+
20
+ // Start project and Start from summary copy the whole released project plus
21
+ // the chosen summary; Start from report copies that report with its brief.
22
+ export async function researchCopyForStart(state: ResearchState, selection: ResearchSelection): Promise<ResearchCopy> {
23
+ if (selection.kind === 'report') {
24
+ const files = await selectResearchFiles(state, selection);
25
+ const brief = await readChecked(await fs.realpath(state.folder), 'brief.md').then(bytes => [{ relativePath: 'brief.md', bytes }], () => []);
26
+ return layoutResearchCopy(state, [...brief, ...files], selection, false);
27
+ }
28
+ const whole = await selectResearchFiles(state, { kind: 'project' }, { releasedSoFar: true });
29
+ const chosen = selection.kind === 'synthesis' ? (await selectResearchFiles(state, selection)).find(file => /\.md$/.test(file.relativePath) && !file.relativePath.startsWith('sources/')) : undefined;
30
+ const paths = new Set(whole.map(file => file.relativePath));
31
+ return layoutResearchCopy(state, [...whole, ...(chosen && !paths.has(chosen.relativePath) ? [chosen] : [])], selection, true, chosen?.relativePath);
32
+ }
33
+
34
+ // Send to a project copies exactly the selection, in the same layout.
35
+ export async function researchCopyForSend(state: ResearchState, selection: ResearchSelection): Promise<ResearchCopy> {
36
+ return layoutResearchCopy(state, await selectResearchFiles(state, selection), selection, selection.kind === 'project');
37
+ }
38
+
39
+ const roundFolder = (round: ResearchRound) => round.catchUp ? `catch-up-${round.catchUp.toLowerCase()}` : `round-${round.n}`;
40
+
41
+ function splitName(name: string): [string, string] {
42
+ const dot = name.lastIndexOf('.');
43
+ return dot > 0 ? [name.slice(0, dot), name.slice(dot)] : [name, ''];
44
+ }
45
+
46
+ interface RoundIndex { round: ResearchRound; summary?: string; roundFile?: string; reports: Array<{ letter: string; path?: string; files: string[] }> }
47
+
48
+ function layoutResearchCopy(state: ResearchState, selected: SelectedResearchFile[], selection: ResearchSelection, whole: boolean, chosenSummary?: string): ResearchCopy {
49
+ const byPath = new Map(selected.map(file => [file.relativePath, file]));
50
+ const released = state.rounds.filter(round => !!round.releasedAt);
51
+ const catchUps = (state.catchUps ?? []).filter(round => !!round.releasedAt && !!round.catchUp && /^[A-Z]$/.test(round.catchUp));
52
+ // Old path in the research folder -> new paths in the copy.
53
+ const moves = new Map<string, string[]>();
54
+ const out: Array<{ path: string; from: string; preferSources?: string }> = [];
55
+ const add = (from: string, to: string, preferSources?: string): boolean => {
56
+ if (!byPath.has(from)) return false;
57
+ out.push({ path: to, from, ...(preferSources ? { preferSources } : {}) });
58
+ moves.set(from, [...(moves.get(from) ?? []), to]);
59
+ return true;
60
+ };
61
+ const counts: ResearchCopyCounts = { rounds: 0, catchUps: 0, reports: 0, summaries: 0, returnedFiles: 0 };
62
+ for (const name of ['brief.md', 'director-log.md', 'research.json']) add(name, name);
63
+ // The summary the copy starts from is also summary.md at the top.
64
+ let startSummary: string | undefined;
65
+ const top = chosenSummary ?? (byPath.has('synthesis.md') ? 'synthesis.md' : selection.kind === 'synthesis' ? selected.find(file => file.relativePath.startsWith('syntheses/'))?.relativePath : undefined);
66
+ if (top && add(top, 'summary.md')) startSummary = 'summary.md';
67
+ const rounds: RoundIndex[] = [];
68
+ for (const round of [...released, ...catchUps]) {
69
+ const dir = `rounds/${roundFolder(round)}`;
70
+ const entry: RoundIndex = { round, reports: [] };
71
+ if (add(`${dir}/round.md`, `${dir}/round.md`)) entry.roundFile = `${dir}/round.md`;
72
+ if (!round.catchUp && whole && add(`syntheses/round-${round.n}.md`, `${dir}/summary.md`)) entry.summary = `${dir}/summary.md`;
73
+ // synthesis.md is the latest round's summary until it is archived, as in RESULTS.
74
+ else if (!round.catchUp && whole && round === released.at(-1) && add('synthesis.md', `${dir}/summary.md`)) entry.summary = `${dir}/summary.md`;
75
+ for (const [letter, result] of Object.entries(round.entries)) {
76
+ if (!/^[A-Z]$/.test(letter)) continue;
77
+ const lower = letter.toLowerCase();
78
+ const filesDir = `${dir}/files/researcher-${lower}`;
79
+ const report = `${dir}/researcher-${lower}.md`;
80
+ const hasReport = add(`${dir}/report-${lower}.md`, report, `${filesDir}/`);
81
+ const taken = new Set<string>();
82
+ const seen = new Set<string>();
83
+ const files: string[] = [];
84
+ for (const artifact of result.artifacts ?? []) {
85
+ const from = `sources/${sourceFileName(artifact)}`;
86
+ if (seen.has(from) || !byPath.has(from)) continue;
87
+ seen.add(from);
88
+ // The original name, without the content-hash prefix.
89
+ const original = sourceFileName(artifact).slice(13);
90
+ const [stem, ext] = splitName(original);
91
+ let name = original;
92
+ for (let n = 2; taken.has(name.toLowerCase()); n++) name = `${stem}-${n}${ext}`;
93
+ taken.add(name.toLowerCase());
94
+ add(from, `${filesDir}/${name}`);
95
+ files.push(`${filesDir}/${name}`);
96
+ counts.returnedFiles++;
97
+ }
98
+ if (hasReport) counts.reports++;
99
+ if (hasReport || files.length) entry.reports.push({ letter, ...(hasReport ? { path: report } : {}), files });
100
+ }
101
+ if (entry.roundFile || entry.summary || entry.reports.length) {
102
+ rounds.push(entry);
103
+ if (round.catchUp) counts.catchUps++; else counts.rounds++;
104
+ }
105
+ }
106
+ counts.summaries = [...moves.keys()].filter(path => path === 'synthesis.md' || path.startsWith('syntheses/')).length;
107
+ // Anything not placed above keeps its research-folder path.
108
+ for (const file of selected) if (!moves.has(file.relativePath)) add(file.relativePath, file.relativePath);
109
+ // Links to copied files are rewritten in one pass, so a rewritten link is
110
+ // never rewritten again. A returned file kept by several researchers links
111
+ // to the copy beside the report that names it.
112
+ const olds = [...moves.keys()].sort((a, b) => b.length - a.length);
113
+ const pattern = olds.length ? new RegExp(`(?:\\.\\./)*(?:${olds.map(old => old.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|')})`, 'g') : null;
114
+ const files: SelectedResearchFile[] = out.map(item => {
115
+ let bytes = byPath.get(item.from)!.bytes;
116
+ if (pattern && /\.md$/i.test(item.from)) {
117
+ const here = posix.dirname(item.path);
118
+ bytes = Buffer.from(bytes.toString('utf8').replace(pattern, match => {
119
+ const targets = moves.get(match.replace(/^(?:\.\.\/)*/, ''))!;
120
+ const target = targets.find(path => !!item.preferSources && path.startsWith(item.preferSources)) ?? targets.find(path => path.startsWith(here + '/')) ?? targets[0]!;
121
+ return posix.relative(here, target);
122
+ }), 'utf8');
123
+ }
124
+ return { relativePath: item.path, bytes };
125
+ });
126
+ const latest = top !== 'synthesis.md' && moves.get('synthesis.md')?.find(path => path !== 'summary.md');
127
+ files.unshift({ relativePath: 'README.md', bytes: Buffer.from(renderReadme(state, selection, rounds, { startSummary, top, ...(latest ? { latest } : {}), brief: byPath.has('brief.md'), log: byPath.has('director-log.md') }), 'utf8') });
128
+ if (files.length > RESEARCH_COPY_LIMITS.files) throw new Error(`This research has ${files.length} files to copy; the limit is ${RESEARCH_COPY_LIMITS.files}.`);
129
+ const total = files.reduce((sum, file) => sum + file.bytes.length, 0);
130
+ if (total > RESEARCH_COPY_LIMITS.bytes) throw new Error(`This research is ${Math.ceil(total / 1048576)} MiB to copy; the limit is ${RESEARCH_COPY_LIMITS.bytes / 1048576} MiB.`);
131
+ return { files, counts, ...(startSummary ? { startSummary } : {}) };
132
+ }
133
+
134
+ function summaryName(path: string | undefined): string {
135
+ const match = path ? /^syntheses\/round-(\d+)\.md$/.exec(path) : null;
136
+ if (match) return `the summary of round ${match[1]}`;
137
+ return 'the latest summary';
138
+ }
139
+
140
+ function renderReadme(state: ResearchState, selection: ResearchSelection, rounds: RoundIndex[], index: { startSummary?: string; top?: string; latest?: string; brief: boolean; log: boolean }): string {
141
+ const oneLine = (text: string) => text.replace(/\s+/g, ' ').trim();
142
+ const authors = !state.blind || !!state.revealedAt;
143
+ const who = (letter: string) => {
144
+ const researcher = (state.researchers ?? []).find(r => r.letter === letter);
145
+ return `${researcherName(letter)}${authors && researcher ? ` (${researcher.provider}, ${researcher.model})` : ''}`;
146
+ };
147
+ const link = (path: string) => `[${path}](${path.split('/').map(encodeURIComponent).join('/')})`;
148
+ const briefText = oneLine(state.brief ?? '');
149
+ const lines = [`# Research: ${oneLine(state.name ?? '') || 'Research'}`, '',
150
+ `Copied from an Arco research project${state.createdAt ? ` started ${state.createdAt.slice(0, 10)}` : ''}. Only released research is included.`, ''];
151
+ if (briefText) lines.push('## Brief', '', briefText.length > 600 ? `${briefText.slice(0, 600)}...` : briefText, '');
152
+ lines.push('## Start here', '');
153
+ if (index.startSummary) lines.push(`- ${link(index.startSummary)}: ${summaryName(index.top)}, which this copy starts from.`);
154
+ else if (selection.kind === 'report') lines.push(`- This copy holds one report: ${rounds.flatMap(r => r.reports).flatMap(r => r.path ? [link(r.path)] : []).join(', ') || 'none'}.`);
155
+ if (index.latest) lines.push(`- ${link(index.latest)}: the latest summary.`);
156
+ if (index.brief) lines.push(`- ${link('brief.md')}: the full brief and the latest round's question.`);
157
+ if (index.log) lines.push(`- ${link('director-log.md')}: the conversation with the Research Director.`);
158
+ lines.push('');
159
+ for (const entry of rounds) {
160
+ lines.push(`## ${entry.round.catchUp ? `Catch-up, ${researcherName(entry.round.catchUp)}` : `Round ${entry.round.n}`}`, '');
161
+ if (entry.roundFile) lines.push(`- ${link(entry.roundFile)}: what was asked and how each researcher finished.`);
162
+ if (entry.summary) lines.push(`- ${link(entry.summary)}: the summary of this round.`);
163
+ for (const report of entry.reports) {
164
+ const files = report.files.length ? `; ${report.files.length} returned file${report.files.length === 1 ? '' : 's'} in ${link(posix.dirname(report.files[0]!) + '/')}` : '';
165
+ lines.push(`- ${who(report.letter)}: ${report.path ? link(report.path) : 'no report'}${files}`);
166
+ }
167
+ lines.push('');
168
+ }
169
+ return lines.join('\n');
170
+ }