@opencorelabs/lucidity 0.9.5 → 0.9.6

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 (787) hide show
  1. package/README.md +46 -5
  2. package/bin/lucidity.js +9 -1
  3. package/dist/agentControls.d.ts +3 -3
  4. package/dist/agentControls.d.ts.map +1 -1
  5. package/dist/agentControls.js +9 -6
  6. package/dist/assets/speech/lucidity-speech +0 -0
  7. package/dist/automations/agent.d.ts.map +1 -1
  8. package/dist/automations/agent.js +8 -3
  9. package/dist/automations/githubIssues.d.ts +25 -0
  10. package/dist/automations/githubIssues.d.ts.map +1 -0
  11. package/dist/automations/githubIssues.js +48 -0
  12. package/dist/automations/service.d.ts +4 -0
  13. package/dist/automations/service.d.ts.map +1 -1
  14. package/dist/automations/service.js +24 -3
  15. package/dist/automations/skill.d.ts +1 -1
  16. package/dist/automations/skill.d.ts.map +1 -1
  17. package/dist/automations/skill.js +3 -25
  18. package/dist/automations/workflowCrash.integration.d.ts +2 -0
  19. package/dist/automations/workflowCrash.integration.d.ts.map +1 -0
  20. package/dist/automations/workflowCrash.integration.js +78 -0
  21. package/dist/chat/server.d.ts +18 -0
  22. package/dist/chat/server.d.ts.map +1 -1
  23. package/dist/chat/server.js +203 -84
  24. package/dist/coding/agentMessages.d.ts +37 -0
  25. package/dist/coding/agentMessages.d.ts.map +1 -0
  26. package/dist/coding/agentMessages.js +220 -0
  27. package/dist/coding/agentSettings.d.ts +9 -0
  28. package/dist/coding/agentSettings.d.ts.map +1 -0
  29. package/dist/coding/agentSettings.js +22 -0
  30. package/dist/coding/fileContext.d.ts +4 -0
  31. package/dist/coding/fileContext.d.ts.map +1 -0
  32. package/dist/coding/fileContext.js +61 -0
  33. package/dist/coding/listPrs.d.ts +4 -0
  34. package/dist/coding/listPrs.d.ts.map +1 -1
  35. package/dist/coding/listPrs.js +1 -1
  36. package/dist/coding/lucidRouting.d.ts +67 -0
  37. package/dist/coding/lucidRouting.d.ts.map +1 -0
  38. package/dist/coding/lucidRouting.js +216 -0
  39. package/dist/coding/overviewSources.d.ts +52 -0
  40. package/dist/coding/overviewSources.d.ts.map +1 -0
  41. package/dist/coding/overviewSources.js +78 -0
  42. package/dist/coding/progress.d.ts +27 -0
  43. package/dist/coding/progress.d.ts.map +1 -0
  44. package/dist/coding/progress.js +152 -0
  45. package/dist/coding/repositoryRequests.d.ts +38 -0
  46. package/dist/coding/repositoryRequests.d.ts.map +1 -0
  47. package/dist/coding/repositoryRequests.js +137 -0
  48. package/dist/coding/runCodeTurn.d.ts +25 -8
  49. package/dist/coding/runCodeTurn.d.ts.map +1 -1
  50. package/dist/coding/runCodeTurn.js +93 -77
  51. package/dist/coding/workspaceOverview.d.ts +106 -0
  52. package/dist/coding/workspaceOverview.d.ts.map +1 -0
  53. package/dist/coding/workspaceOverview.js +96 -0
  54. package/dist/coding/workspaceRegistry.d.ts +230 -4
  55. package/dist/coding/workspaceRegistry.d.ts.map +1 -1
  56. package/dist/coding/workspaceRegistry.js +827 -37
  57. package/dist/coding/workspaceTitle.d.ts +14 -0
  58. package/dist/coding/workspaceTitle.d.ts.map +1 -0
  59. package/dist/coding/workspaceTitle.js +8 -0
  60. package/dist/coding/worktree.d.ts +1 -1
  61. package/dist/coding/worktree.d.ts.map +1 -1
  62. package/dist/coding/worktree.js +3 -2
  63. package/dist/coding/worktreeSetup.d.ts +1 -1
  64. package/dist/coding/worktreeSetup.d.ts.map +1 -1
  65. package/dist/coding/worktreeSetup.js +43 -10
  66. package/dist/config.d.ts +5 -0
  67. package/dist/config.d.ts.map +1 -1
  68. package/dist/config.js +38 -3
  69. package/dist/editor/existingWorkspace.d.ts +3 -0
  70. package/dist/editor/existingWorkspace.d.ts.map +1 -0
  71. package/dist/editor/existingWorkspace.js +19 -0
  72. package/dist/editor/fileActions.d.ts +26 -0
  73. package/dist/editor/fileActions.d.ts.map +1 -0
  74. package/dist/editor/fileActions.js +134 -0
  75. package/dist/editor/files.d.ts +27 -0
  76. package/dist/editor/files.d.ts.map +1 -0
  77. package/dist/editor/files.js +279 -0
  78. package/dist/editor/gitActions.d.ts +18 -0
  79. package/dist/editor/gitActions.d.ts.map +1 -0
  80. package/dist/editor/gitActions.js +140 -0
  81. package/dist/editor/localEndpoint.d.ts +4 -0
  82. package/dist/editor/localEndpoint.d.ts.map +1 -0
  83. package/dist/editor/localEndpoint.js +35 -0
  84. package/dist/editor/service.d.ts +28 -0
  85. package/dist/editor/service.d.ts.map +1 -0
  86. package/dist/editor/service.js +101 -0
  87. package/dist/editor/shellCommands.d.ts +21 -0
  88. package/dist/editor/shellCommands.d.ts.map +1 -0
  89. package/dist/editor/shellCommands.js +165 -0
  90. package/dist/editor/terminals.d.ts +34 -0
  91. package/dist/editor/terminals.d.ts.map +1 -0
  92. package/dist/editor/terminals.js +161 -0
  93. package/dist/editor/types.d.ts +37 -0
  94. package/dist/editor/types.d.ts.map +1 -0
  95. package/dist/editor/types.js +1 -0
  96. package/dist/files/store.d.ts +13 -0
  97. package/dist/files/store.d.ts.map +1 -0
  98. package/dist/files/store.js +150 -0
  99. package/dist/goals/assessment.d.ts +6 -6
  100. package/dist/index.js +232 -56
  101. package/dist/install.d.ts +7 -0
  102. package/dist/install.d.ts.map +1 -1
  103. package/dist/install.js +5 -2
  104. package/dist/jobs/briefing.d.ts +1 -1
  105. package/dist/jobs/briefing.d.ts.map +1 -1
  106. package/dist/jobs/briefing.js +16 -33
  107. package/dist/jobs/extraction.d.ts +2 -1
  108. package/dist/jobs/extraction.d.ts.map +1 -1
  109. package/dist/jobs/extraction.js +2 -2
  110. package/dist/jobs/fastModeReview.d.ts +3 -1
  111. package/dist/jobs/fastModeReview.d.ts.map +1 -1
  112. package/dist/jobs/fastModeReview.js +20 -11
  113. package/dist/jobs/voiceReview.js +4 -4
  114. package/dist/jobs/weeklyReview.d.ts +1 -1
  115. package/dist/jobs/weeklyReview.d.ts.map +1 -1
  116. package/dist/jobs/weeklyReview.js +2 -5
  117. package/dist/lucidInvocations.d.ts +44 -0
  118. package/dist/lucidInvocations.d.ts.map +1 -0
  119. package/dist/lucidInvocations.js +164 -0
  120. package/dist/mcp/config.d.ts +8 -2
  121. package/dist/mcp/config.d.ts.map +1 -1
  122. package/dist/mcp/config.js +52 -10
  123. package/dist/mcp/paired.js +1 -0
  124. package/dist/providerFallbackContext.d.ts +5 -0
  125. package/dist/providerFallbackContext.d.ts.map +1 -0
  126. package/dist/providerFallbackContext.js +58 -0
  127. package/dist/providerRecovery.d.ts +18 -1
  128. package/dist/providerRecovery.d.ts.map +1 -1
  129. package/dist/providerRecovery.js +3 -1
  130. package/dist/providerRoles.d.ts +9 -0
  131. package/dist/providerRoles.d.ts.map +1 -0
  132. package/dist/providerRoles.js +25 -0
  133. package/dist/recall/command.d.ts +139 -0
  134. package/dist/recall/command.d.ts.map +1 -0
  135. package/dist/recall/command.js +35 -0
  136. package/dist/recall/context.d.ts +5 -0
  137. package/dist/recall/context.d.ts.map +1 -0
  138. package/dist/recall/context.js +66 -0
  139. package/dist/recall/conversations.d.ts +182 -0
  140. package/dist/recall/conversations.d.ts.map +1 -0
  141. package/dist/recall/conversations.js +58 -0
  142. package/dist/recall/documents.d.ts +76 -0
  143. package/dist/recall/documents.d.ts.map +1 -0
  144. package/dist/recall/documents.js +32 -0
  145. package/dist/recall/evaluation.d.ts +77 -0
  146. package/dist/recall/evaluation.d.ts.map +1 -0
  147. package/dist/recall/evaluation.js +88 -0
  148. package/dist/recall/factory.d.ts +6 -0
  149. package/dist/recall/factory.d.ts.map +1 -0
  150. package/dist/recall/factory.js +20 -0
  151. package/dist/recall/index.d.ts +13 -0
  152. package/dist/recall/index.d.ts.map +1 -0
  153. package/dist/recall/index.js +92 -0
  154. package/dist/recall/memories.d.ts +16 -0
  155. package/dist/recall/memories.d.ts.map +1 -0
  156. package/dist/recall/memories.js +136 -0
  157. package/dist/recall/memorySelection.d.ts +4 -0
  158. package/dist/recall/memorySelection.d.ts.map +1 -0
  159. package/dist/recall/memorySelection.js +16 -0
  160. package/dist/recall/memoryService.d.ts +22 -0
  161. package/dist/recall/memoryService.d.ts.map +1 -0
  162. package/dist/recall/memoryService.js +171 -0
  163. package/dist/recall/personal.d.ts +127 -0
  164. package/dist/recall/personal.d.ts.map +1 -0
  165. package/dist/recall/personal.js +125 -0
  166. package/dist/recall/projects.d.ts +67 -0
  167. package/dist/recall/projects.d.ts.map +1 -0
  168. package/dist/recall/projects.js +117 -0
  169. package/dist/recall/query.d.ts +5 -0
  170. package/dist/recall/query.d.ts.map +1 -0
  171. package/dist/recall/query.js +17 -0
  172. package/dist/recall/semanticEvaluation.d.ts +2 -0
  173. package/dist/recall/semanticEvaluation.d.ts.map +1 -0
  174. package/dist/recall/semanticEvaluation.js +123 -0
  175. package/dist/recall/service.d.ts +62 -0
  176. package/dist/recall/service.d.ts.map +1 -0
  177. package/dist/recall/service.js +94 -0
  178. package/dist/room/client.d.ts +41 -0
  179. package/dist/room/client.d.ts.map +1 -1
  180. package/dist/room/client.js +224 -25
  181. package/dist/room/codingActivity.d.ts +21 -0
  182. package/dist/room/codingActivity.d.ts.map +1 -0
  183. package/dist/room/codingActivity.js +86 -0
  184. package/dist/room/computer.d.ts.map +1 -1
  185. package/dist/room/computer.js +19 -3
  186. package/dist/room/context.d.ts +3 -2
  187. package/dist/room/context.d.ts.map +1 -1
  188. package/dist/room/context.js +5 -4
  189. package/dist/room/desktop-live.integration.d.ts +2 -0
  190. package/dist/room/desktop-live.integration.d.ts.map +1 -0
  191. package/dist/room/desktop-live.integration.js +219 -0
  192. package/dist/room/turnQueue.d.ts +24 -2
  193. package/dist/room/turnQueue.d.ts.map +1 -1
  194. package/dist/room/turnQueue.js +96 -30
  195. package/dist/runtimeStore.d.ts +17 -0
  196. package/dist/runtimeStore.d.ts.map +1 -1
  197. package/dist/runtimeStore.js +33 -4
  198. package/dist/setup/page.d.ts +1 -1
  199. package/dist/setup/page.d.ts.map +1 -1
  200. package/dist/setup/page.js +15 -2
  201. package/dist/setup/server.d.ts +5 -1
  202. package/dist/setup/server.d.ts.map +1 -1
  203. package/dist/setup/server.js +37 -13
  204. package/dist/skills/install.d.ts +8 -0
  205. package/dist/skills/install.d.ts.map +1 -0
  206. package/dist/skills/install.js +82 -0
  207. package/dist/skills/lucidity/SKILL.md +65 -0
  208. package/dist/skills/lucidity-task-handoff/SKILL.md +122 -0
  209. package/dist/speech/captures.d.ts +4 -0
  210. package/dist/speech/captures.d.ts.map +1 -1
  211. package/dist/speech/captures.js +53 -41
  212. package/dist/updateCli.d.ts +2 -0
  213. package/dist/updateCli.d.ts.map +1 -0
  214. package/dist/updateCli.js +40 -0
  215. package/dist/updateService.d.ts +3 -0
  216. package/dist/updateService.d.ts.map +1 -0
  217. package/dist/updateService.js +23 -0
  218. package/dist/updates/admission.d.ts +23 -0
  219. package/dist/updates/admission.d.ts.map +1 -0
  220. package/dist/updates/admission.js +76 -0
  221. package/dist/updates/bootstrap.d.ts +23 -0
  222. package/dist/updates/bootstrap.d.ts.map +1 -0
  223. package/dist/updates/bootstrap.js +95 -0
  224. package/dist/updates/bootstrapConfig.d.ts +34 -0
  225. package/dist/updates/bootstrapConfig.d.ts.map +1 -0
  226. package/dist/updates/bootstrapConfig.js +35 -0
  227. package/dist/updates/connection.d.ts +20 -0
  228. package/dist/updates/connection.d.ts.map +1 -0
  229. package/dist/updates/connection.js +111 -0
  230. package/dist/updates/developmentAdmission.d.ts +29 -0
  231. package/dist/updates/developmentAdmission.d.ts.map +1 -0
  232. package/dist/updates/developmentAdmission.js +73 -0
  233. package/dist/updates/developmentCli.d.ts +2 -0
  234. package/dist/updates/developmentCli.d.ts.map +1 -0
  235. package/dist/updates/developmentCli.js +61 -0
  236. package/dist/updates/developmentRefresh.d.ts +73 -0
  237. package/dist/updates/developmentRefresh.d.ts.map +1 -0
  238. package/dist/updates/developmentRefresh.js +157 -0
  239. package/dist/updates/developmentService.d.ts +13 -0
  240. package/dist/updates/developmentService.d.ts.map +1 -0
  241. package/dist/updates/developmentService.js +217 -0
  242. package/dist/updates/download.d.ts +7 -0
  243. package/dist/updates/download.d.ts.map +1 -0
  244. package/dist/updates/download.js +52 -0
  245. package/dist/updates/feed.d.ts +7 -0
  246. package/dist/updates/feed.d.ts.map +1 -0
  247. package/dist/updates/feed.js +37 -0
  248. package/dist/updates/installService.d.ts +3 -0
  249. package/dist/updates/installService.d.ts.map +1 -0
  250. package/dist/updates/installService.js +78 -0
  251. package/dist/updates/installationReferences.d.ts +17 -0
  252. package/dist/updates/installationReferences.d.ts.map +1 -0
  253. package/dist/updates/installationReferences.js +104 -0
  254. package/dist/updates/installationStore.d.ts +49 -0
  255. package/dist/updates/installationStore.d.ts.map +1 -0
  256. package/dist/updates/installationStore.js +237 -0
  257. package/dist/updates/installer.d.ts +29 -0
  258. package/dist/updates/installer.d.ts.map +1 -0
  259. package/dist/updates/installer.js +205 -0
  260. package/dist/updates/journal.d.ts +228 -0
  261. package/dist/updates/journal.d.ts.map +1 -0
  262. package/dist/updates/journal.js +249 -0
  263. package/dist/updates/managedLifecycle.d.ts +26 -0
  264. package/dist/updates/managedLifecycle.d.ts.map +1 -0
  265. package/dist/updates/managedLifecycle.js +60 -0
  266. package/dist/updates/migrateService.d.ts +2 -0
  267. package/dist/updates/migrateService.d.ts.map +1 -0
  268. package/dist/updates/migrateService.js +44 -0
  269. package/dist/updates/migration.d.ts +15 -0
  270. package/dist/updates/migration.d.ts.map +1 -0
  271. package/dist/updates/migration.js +108 -0
  272. package/dist/updates/processControl.d.ts +47 -0
  273. package/dist/updates/processControl.d.ts.map +1 -0
  274. package/dist/updates/processControl.js +98 -0
  275. package/dist/updates/processHost.d.ts +52 -0
  276. package/dist/updates/processHost.d.ts.map +1 -0
  277. package/dist/updates/processHost.js +165 -0
  278. package/dist/updates/registerService.d.ts +4 -0
  279. package/dist/updates/registerService.d.ts.map +1 -0
  280. package/dist/updates/registerService.js +34 -0
  281. package/dist/updates/releases.d.ts +84 -0
  282. package/dist/updates/releases.d.ts.map +1 -0
  283. package/dist/updates/releases.js +51 -0
  284. package/dist/updates/retention.d.ts +32 -0
  285. package/dist/updates/retention.d.ts.map +1 -0
  286. package/dist/updates/retention.js +188 -0
  287. package/dist/updates/runner.d.ts +6 -0
  288. package/dist/updates/runner.d.ts.map +1 -0
  289. package/dist/updates/runner.js +117 -0
  290. package/dist/updates/service.d.ts +53 -0
  291. package/dist/updates/service.d.ts.map +1 -0
  292. package/dist/updates/service.js +268 -0
  293. package/dist/updates/servicePlan.d.ts +29 -0
  294. package/dist/updates/servicePlan.d.ts.map +1 -0
  295. package/dist/updates/servicePlan.js +58 -0
  296. package/dist/updates/signCatalog.d.ts +10 -0
  297. package/dist/updates/signCatalog.d.ts.map +1 -0
  298. package/dist/updates/signCatalog.js +44 -0
  299. package/dist/updates/supervisor.d.ts +27 -0
  300. package/dist/updates/supervisor.d.ts.map +1 -0
  301. package/dist/updates/supervisor.js +137 -0
  302. package/dist/updates/windowsService.d.ts +12 -0
  303. package/dist/updates/windowsService.d.ts.map +1 -0
  304. package/dist/updates/windowsService.js +51 -0
  305. package/dist/video/context.d.ts +4 -0
  306. package/dist/video/context.d.ts.map +1 -0
  307. package/dist/video/context.js +74 -0
  308. package/dist/video/store.d.ts +22 -0
  309. package/dist/video/store.d.ts.map +1 -0
  310. package/dist/video/store.js +184 -0
  311. package/npm-shrinkwrap.json +1792 -0
  312. package/package.json +4 -1
  313. package/src/agentControls.ts +11 -7
  314. package/src/automations/agent.ts +11 -2
  315. package/src/automations/githubIssues.ts +63 -0
  316. package/src/automations/service.ts +25 -3
  317. package/src/automations/skill.ts +5 -37
  318. package/src/automations/workflowCrash.integration.ts +70 -0
  319. package/src/chat/server.ts +162 -89
  320. package/src/coding/agentMessages.ts +217 -0
  321. package/src/coding/agentSettings.ts +22 -0
  322. package/src/coding/fileContext.ts +72 -0
  323. package/src/coding/listPrs.ts +1 -1
  324. package/src/coding/lucidRouting.ts +211 -0
  325. package/src/coding/overviewSources.ts +86 -0
  326. package/src/coding/progress.ts +146 -0
  327. package/src/coding/repositoryRequests.ts +117 -0
  328. package/src/coding/runCodeTurn.ts +106 -92
  329. package/src/coding/workspaceOverview.ts +99 -0
  330. package/src/coding/workspaceRegistry.ts +762 -39
  331. package/src/coding/workspaceTitle.ts +10 -0
  332. package/src/coding/worktree.ts +3 -2
  333. package/src/coding/worktreeSetup.ts +33 -10
  334. package/src/config.ts +37 -2
  335. package/src/editor/existingWorkspace.ts +17 -0
  336. package/src/editor/fileActions.ts +162 -0
  337. package/src/editor/files.ts +276 -0
  338. package/src/editor/gitActions.ts +150 -0
  339. package/src/editor/localEndpoint.ts +28 -0
  340. package/src/editor/service.ts +93 -0
  341. package/src/editor/shellCommands.ts +132 -0
  342. package/src/editor/terminals.ts +129 -0
  343. package/src/editor/types.ts +32 -0
  344. package/src/files/store.ts +131 -0
  345. package/src/index.ts +224 -50
  346. package/src/install.ts +4 -2
  347. package/src/jobs/briefing.ts +18 -29
  348. package/src/jobs/extraction.ts +5 -4
  349. package/src/jobs/fastModeReview.ts +22 -11
  350. package/src/jobs/voiceReview.ts +4 -4
  351. package/src/jobs/weeklyReview.ts +2 -4
  352. package/src/lucidInvocations.ts +152 -0
  353. package/src/mcp/config.ts +48 -10
  354. package/src/mcp/paired.ts +1 -0
  355. package/src/providerFallbackContext.ts +48 -0
  356. package/src/providerRecovery.ts +3 -1
  357. package/src/providerRoles.ts +35 -0
  358. package/src/recall/command.ts +42 -0
  359. package/src/recall/context.ts +64 -0
  360. package/src/recall/conversations.ts +53 -0
  361. package/src/recall/documents.ts +32 -0
  362. package/src/recall/evaluation.ts +89 -0
  363. package/src/recall/factory.ts +21 -0
  364. package/src/recall/index.ts +87 -0
  365. package/src/recall/memories.ts +123 -0
  366. package/src/recall/memorySelection.ts +17 -0
  367. package/src/recall/memoryService.ts +138 -0
  368. package/src/recall/personal.ts +97 -0
  369. package/src/recall/projects.ts +98 -0
  370. package/src/recall/query.ts +21 -0
  371. package/src/recall/semanticEvaluation.ts +101 -0
  372. package/src/recall/service.ts +85 -0
  373. package/src/room/client.ts +238 -31
  374. package/src/room/codingActivity.ts +70 -0
  375. package/src/room/computer.ts +19 -3
  376. package/src/room/context.ts +7 -2
  377. package/src/room/desktop-live.integration.ts +203 -0
  378. package/src/room/turnQueue.ts +91 -34
  379. package/src/runtimeStore.ts +36 -4
  380. package/src/setup/page.ts +15 -2
  381. package/src/setup/server.ts +28 -5
  382. package/src/skills/install.ts +65 -0
  383. package/src/speech/captures.ts +56 -44
  384. package/src/updateCli.ts +37 -0
  385. package/src/updateService.ts +21 -0
  386. package/src/updates/admission.ts +70 -0
  387. package/src/updates/bootstrap.ts +77 -0
  388. package/src/updates/bootstrapConfig.ts +29 -0
  389. package/src/updates/connection.ts +84 -0
  390. package/src/updates/developmentAdmission.ts +56 -0
  391. package/src/updates/developmentCli.ts +47 -0
  392. package/src/updates/developmentRefresh.ts +130 -0
  393. package/src/updates/developmentService.ts +170 -0
  394. package/src/updates/download.ts +53 -0
  395. package/src/updates/feed.ts +34 -0
  396. package/src/updates/installService.ts +67 -0
  397. package/src/updates/installationReferences.ts +87 -0
  398. package/src/updates/installationStore.ts +196 -0
  399. package/src/updates/installer.ts +203 -0
  400. package/src/updates/journal.ts +250 -0
  401. package/src/updates/managedLifecycle.ts +64 -0
  402. package/src/updates/migrateService.ts +33 -0
  403. package/src/updates/migration.ts +92 -0
  404. package/src/updates/processControl.ts +96 -0
  405. package/src/updates/processHost.ts +159 -0
  406. package/src/updates/registerService.ts +27 -0
  407. package/src/updates/releases.ts +53 -0
  408. package/src/updates/retention.ts +154 -0
  409. package/src/updates/runner.ts +104 -0
  410. package/src/updates/service.ts +241 -0
  411. package/src/updates/servicePlan.ts +63 -0
  412. package/src/updates/signCatalog.ts +40 -0
  413. package/src/updates/supervisor.ts +114 -0
  414. package/src/updates/windowsService.ts +54 -0
  415. package/src/video/context.ts +101 -0
  416. package/src/video/store.ts +250 -0
  417. package/vendor/decisions/dist/followup.d.ts +14 -0
  418. package/vendor/decisions/dist/followup.js +86 -0
  419. package/vendor/decisions/dist/index.d.ts +3 -0
  420. package/vendor/decisions/dist/index.js +3 -0
  421. package/vendor/decisions/dist/repositoryReplay.d.ts +103 -0
  422. package/vendor/decisions/dist/repositoryReplay.js +177 -0
  423. package/vendor/decisions/dist/repositoryRouting.d.ts +21 -0
  424. package/vendor/decisions/dist/repositoryRouting.js +125 -0
  425. package/vendor/decisions/src/followup.ts +129 -0
  426. package/vendor/decisions/src/index.ts +3 -0
  427. package/vendor/decisions/src/repositoryReplay.ts +312 -0
  428. package/vendor/decisions/src/repositoryRouting.ts +167 -0
  429. package/vendor/mcp-server/README.md +6 -0
  430. package/vendor/mcp-server/dist/index.js +21 -7
  431. package/vendor/mcp-server/dist/localDaemon.d.ts +4 -0
  432. package/vendor/mcp-server/dist/localDaemon.d.ts.map +1 -0
  433. package/vendor/mcp-server/dist/localDaemon.js +41 -0
  434. package/vendor/mcp-server/dist/tools/agents.d.ts +3 -0
  435. package/vendor/mcp-server/dist/tools/agents.d.ts.map +1 -0
  436. package/vendor/mcp-server/dist/tools/agents.js +60 -0
  437. package/vendor/mcp-server/dist/tools/artifacts.d.ts +3 -0
  438. package/vendor/mcp-server/dist/tools/artifacts.d.ts.map +1 -0
  439. package/vendor/mcp-server/dist/tools/artifacts.js +22 -0
  440. package/vendor/mcp-server/dist/tools/automations.d.ts.map +1 -1
  441. package/vendor/mcp-server/dist/tools/automations.js +7 -32
  442. package/vendor/mcp-server/dist/tools/commandEventFormat.d.ts +1 -1
  443. package/vendor/mcp-server/dist/tools/commandEventFormat.js +2 -2
  444. package/vendor/mcp-server/dist/tools/commandEvents.js +1 -1
  445. package/vendor/mcp-server/dist/tools/comments.d.ts.map +1 -1
  446. package/vendor/mcp-server/dist/tools/comments.js +5 -1
  447. package/vendor/mcp-server/dist/tools/journal.d.ts.map +1 -1
  448. package/vendor/mcp-server/dist/tools/journal.js +1 -0
  449. package/vendor/mcp-server/dist/tools/memory.d.ts +0 -10
  450. package/vendor/mcp-server/dist/tools/memory.d.ts.map +1 -1
  451. package/vendor/mcp-server/dist/tools/memory.js +28 -102
  452. package/vendor/mcp-server/dist/tools/notes.d.ts.map +1 -1
  453. package/vendor/mcp-server/dist/tools/notes.js +38 -4
  454. package/vendor/mcp-server/dist/tools/recall.d.ts +6 -0
  455. package/vendor/mcp-server/dist/tools/recall.d.ts.map +1 -0
  456. package/vendor/mcp-server/dist/tools/recall.js +78 -0
  457. package/vendor/mcp-server/dist/tools/summary.d.ts +3 -0
  458. package/vendor/mcp-server/dist/tools/summary.d.ts.map +1 -0
  459. package/vendor/mcp-server/dist/tools/summary.js +22 -0
  460. package/vendor/mcp-server/dist/tools/taskSheet.d.ts +3 -0
  461. package/vendor/mcp-server/dist/tools/taskSheet.d.ts.map +1 -0
  462. package/vendor/mcp-server/dist/tools/taskSheet.js +32 -0
  463. package/vendor/mcp-server/dist/tools/tasks.d.ts.map +1 -1
  464. package/vendor/mcp-server/dist/tools/tasks.js +117 -24
  465. package/vendor/mcp-server/dist/tools/worktrees.d.ts +3 -0
  466. package/vendor/mcp-server/dist/tools/worktrees.d.ts.map +1 -0
  467. package/vendor/mcp-server/dist/tools/worktrees.js +51 -0
  468. package/vendor/mcp-server/package.json +1 -1
  469. package/vendor/mcp-server/src/index.ts +17 -7
  470. package/vendor/mcp-server/src/localDaemon.ts +56 -0
  471. package/vendor/mcp-server/src/tools/agents.ts +78 -0
  472. package/vendor/mcp-server/src/tools/artifacts.ts +26 -0
  473. package/vendor/mcp-server/src/tools/automations.ts +7 -47
  474. package/vendor/mcp-server/src/tools/commandEventFormat.ts +2 -2
  475. package/vendor/mcp-server/src/tools/commandEvents.ts +1 -1
  476. package/vendor/mcp-server/src/tools/comments.ts +4 -1
  477. package/vendor/mcp-server/src/tools/journal.ts +1 -0
  478. package/vendor/mcp-server/src/tools/memory.ts +37 -130
  479. package/vendor/mcp-server/src/tools/notes.ts +35 -5
  480. package/vendor/mcp-server/src/tools/recall.ts +89 -0
  481. package/vendor/mcp-server/src/tools/summary.ts +30 -0
  482. package/vendor/mcp-server/src/tools/taskSheet.ts +60 -0
  483. package/vendor/mcp-server/src/tools/tasks.ts +125 -24
  484. package/vendor/mcp-server/src/tools/worktrees.ts +61 -0
  485. package/vendor/notes/dist/artifacts.d.ts +8 -0
  486. package/vendor/notes/dist/artifacts.d.ts.map +1 -0
  487. package/vendor/notes/dist/artifacts.js +105 -0
  488. package/vendor/notes/dist/index.d.ts +1 -0
  489. package/vendor/notes/dist/index.d.ts.map +1 -1
  490. package/vendor/notes/dist/index.js +1 -0
  491. package/vendor/notes/dist/vault.d.ts.map +1 -1
  492. package/vendor/notes/dist/vault.js +2 -0
  493. package/vendor/notes/src/artifacts.ts +100 -0
  494. package/vendor/notes/src/index.ts +2 -0
  495. package/vendor/notes/src/vault.ts +1 -0
  496. package/vendor/runtime/README.md +8 -0
  497. package/vendor/runtime/dist/executor/claudeAgent.d.ts +18 -1
  498. package/vendor/runtime/dist/executor/claudeAgent.d.ts.map +1 -1
  499. package/vendor/runtime/dist/executor/claudeAgent.js +157 -39
  500. package/vendor/runtime/dist/executor/claudeCode.d.ts.map +1 -1
  501. package/vendor/runtime/dist/executor/claudeCode.js +19 -2
  502. package/vendor/runtime/dist/executor/claudeSession.d.ts +32 -0
  503. package/vendor/runtime/dist/executor/claudeSession.d.ts.map +1 -0
  504. package/vendor/runtime/dist/executor/claudeSession.js +154 -0
  505. package/vendor/runtime/dist/executor/codex.d.ts +18 -2
  506. package/vendor/runtime/dist/executor/codex.d.ts.map +1 -1
  507. package/vendor/runtime/dist/executor/codex.js +134 -18
  508. package/vendor/runtime/dist/executor/codexSessions.d.ts +5 -10
  509. package/vendor/runtime/dist/executor/codexSessions.d.ts.map +1 -1
  510. package/vendor/runtime/dist/executor/codexSessions.js +12 -78
  511. package/vendor/runtime/dist/executor/fallback.d.ts +27 -0
  512. package/vendor/runtime/dist/executor/fallback.d.ts.map +1 -0
  513. package/vendor/runtime/dist/executor/fallback.js +45 -0
  514. package/vendor/runtime/dist/executor/health.d.ts +19 -1
  515. package/vendor/runtime/dist/executor/health.d.ts.map +1 -1
  516. package/vendor/runtime/dist/executor/health.js +19 -2
  517. package/vendor/runtime/dist/executor/integrations.d.ts +4 -0
  518. package/vendor/runtime/dist/executor/integrations.d.ts.map +1 -0
  519. package/vendor/runtime/dist/executor/integrations.js +5 -0
  520. package/vendor/runtime/dist/executor/liveTurns.d.ts +2 -2
  521. package/vendor/runtime/dist/executor/liveTurns.d.ts.map +1 -1
  522. package/vendor/runtime/dist/executor/liveTurns.js +3 -3
  523. package/vendor/runtime/dist/executor/ownership.d.ts +18 -1
  524. package/vendor/runtime/dist/executor/ownership.d.ts.map +1 -1
  525. package/vendor/runtime/dist/executor/ownership.js +3 -1
  526. package/vendor/runtime/dist/executor/providerRouter.d.ts +13 -0
  527. package/vendor/runtime/dist/executor/providerRouter.d.ts.map +1 -1
  528. package/vendor/runtime/dist/executor/providerRouter.js +91 -5
  529. package/vendor/runtime/dist/executor/sessionRetention.d.ts +34 -0
  530. package/vendor/runtime/dist/executor/sessionRetention.d.ts.map +1 -0
  531. package/vendor/runtime/dist/executor/sessionRetention.js +126 -0
  532. package/vendor/runtime/dist/executor/types.d.ts +30 -7
  533. package/vendor/runtime/dist/executor/types.d.ts.map +1 -1
  534. package/vendor/runtime/dist/executor/usage.d.ts +5 -0
  535. package/vendor/runtime/dist/executor/usage.d.ts.map +1 -0
  536. package/vendor/runtime/dist/executor/usage.js +56 -0
  537. package/vendor/runtime/dist/harness/index.d.ts.map +1 -1
  538. package/vendor/runtime/dist/harness/index.js +2 -5
  539. package/vendor/runtime/dist/harness/types.d.ts +3 -1
  540. package/vendor/runtime/dist/harness/types.d.ts.map +1 -1
  541. package/vendor/runtime/dist/index.d.ts +6 -1
  542. package/vendor/runtime/dist/index.d.ts.map +1 -1
  543. package/vendor/runtime/dist/index.js +3 -0
  544. package/vendor/runtime/dist/prompts/recall.d.ts +15 -0
  545. package/vendor/runtime/dist/prompts/recall.d.ts.map +1 -0
  546. package/vendor/runtime/dist/prompts/recall.js +71 -0
  547. package/vendor/runtime/src/executor/claudeAgent.ts +149 -37
  548. package/vendor/runtime/src/executor/claudeCode.ts +17 -3
  549. package/vendor/runtime/src/executor/claudeSession.ts +180 -0
  550. package/vendor/runtime/src/executor/codex.ts +136 -21
  551. package/vendor/runtime/src/executor/codexSessions.ts +18 -82
  552. package/vendor/runtime/src/executor/fallback.ts +63 -0
  553. package/vendor/runtime/src/executor/health.ts +16 -2
  554. package/vendor/runtime/src/executor/integrations.ts +7 -0
  555. package/vendor/runtime/src/executor/liveTurns.ts +5 -5
  556. package/vendor/runtime/src/executor/ownership.ts +3 -1
  557. package/vendor/runtime/src/executor/providerRouter.ts +85 -4
  558. package/vendor/runtime/src/executor/sessionRetention.ts +166 -0
  559. package/vendor/runtime/src/executor/types.ts +27 -7
  560. package/vendor/runtime/src/executor/usage.ts +58 -0
  561. package/vendor/runtime/src/harness/index.ts +2 -5
  562. package/vendor/runtime/src/harness/types.ts +3 -1
  563. package/vendor/runtime/src/index.ts +7 -1
  564. package/vendor/runtime/src/prompts/recall.ts +72 -0
  565. package/vendor/shared/dist/accountDevices.d.ts +62 -0
  566. package/vendor/shared/dist/accountDevices.d.ts.map +1 -0
  567. package/vendor/shared/dist/accountDevices.js +25 -0
  568. package/vendor/shared/dist/activityRecovery.d.ts +37 -0
  569. package/vendor/shared/dist/activityRecovery.d.ts.map +1 -0
  570. package/vendor/shared/dist/activityRecovery.js +39 -0
  571. package/vendor/shared/dist/agentMessages.d.ts +187 -0
  572. package/vendor/shared/dist/agentMessages.d.ts.map +1 -0
  573. package/vendor/shared/dist/agentMessages.js +70 -0
  574. package/vendor/shared/dist/aiUsage.d.ts +30 -0
  575. package/vendor/shared/dist/aiUsage.d.ts.map +1 -0
  576. package/vendor/shared/dist/aiUsage.js +14 -0
  577. package/vendor/shared/dist/artifacts.d.ts +28 -0
  578. package/vendor/shared/dist/artifacts.d.ts.map +1 -0
  579. package/vendor/shared/dist/artifacts.js +47 -0
  580. package/vendor/shared/dist/automationTemplates.d.ts.map +1 -1
  581. package/vendor/shared/dist/automationTemplates.js +1 -0
  582. package/vendor/shared/dist/automations.d.ts +61 -14
  583. package/vendor/shared/dist/automations.d.ts.map +1 -1
  584. package/vendor/shared/dist/automations.js +10 -3
  585. package/vendor/shared/dist/cardStudio.d.ts +31 -31
  586. package/vendor/shared/dist/chatActivity.d.ts +17 -0
  587. package/vendor/shared/dist/chatActivity.d.ts.map +1 -0
  588. package/vendor/shared/dist/chatActivity.js +47 -0
  589. package/vendor/shared/dist/codingActivity.d.ts +60 -0
  590. package/vendor/shared/dist/codingActivity.d.ts.map +1 -0
  591. package/vendor/shared/dist/codingActivity.js +33 -0
  592. package/vendor/shared/dist/commandLocal.d.ts +1 -1
  593. package/vendor/shared/dist/commandLocal.d.ts.map +1 -1
  594. package/vendor/shared/dist/commands.d.ts +32 -32
  595. package/vendor/shared/dist/commands.d.ts.map +1 -1
  596. package/vendor/shared/dist/commands.js +1 -1
  597. package/vendor/shared/dist/commentMentions.d.ts +20 -0
  598. package/vendor/shared/dist/commentMentions.d.ts.map +1 -0
  599. package/vendor/shared/dist/commentMentions.js +14 -0
  600. package/vendor/shared/dist/computer.d.ts +48 -8
  601. package/vendor/shared/dist/computer.d.ts.map +1 -1
  602. package/vendor/shared/dist/computer.js +25 -0
  603. package/vendor/shared/dist/constants.d.ts +1 -1
  604. package/vendor/shared/dist/constants.d.ts.map +1 -1
  605. package/vendor/shared/dist/constants.js +5 -0
  606. package/vendor/shared/dist/daemonUpdates.d.ts +123 -0
  607. package/vendor/shared/dist/daemonUpdates.d.ts.map +1 -0
  608. package/vendor/shared/dist/daemonUpdates.js +106 -0
  609. package/vendor/shared/dist/deviceInteraction.d.ts +23 -0
  610. package/vendor/shared/dist/deviceInteraction.d.ts.map +1 -0
  611. package/vendor/shared/dist/deviceInteraction.js +32 -0
  612. package/vendor/shared/dist/doctor.d.ts +50 -0
  613. package/vendor/shared/dist/doctor.d.ts.map +1 -0
  614. package/vendor/shared/dist/doctor.js +15 -0
  615. package/vendor/shared/dist/fileUploads.d.ts +39 -0
  616. package/vendor/shared/dist/fileUploads.d.ts.map +1 -0
  617. package/vendor/shared/dist/fileUploads.js +24 -0
  618. package/vendor/shared/dist/files.d.ts +11 -0
  619. package/vendor/shared/dist/files.d.ts.map +1 -0
  620. package/vendor/shared/dist/files.js +19 -0
  621. package/vendor/shared/dist/githubContributions.d.ts +1 -1
  622. package/vendor/shared/dist/goals.d.ts +7 -7
  623. package/vendor/shared/dist/index.d.ts +29 -2
  624. package/vendor/shared/dist/index.d.ts.map +1 -1
  625. package/vendor/shared/dist/index.js +26 -1
  626. package/vendor/shared/dist/lucidFollowups.d.ts +95 -0
  627. package/vendor/shared/dist/lucidFollowups.d.ts.map +1 -0
  628. package/vendor/shared/dist/lucidFollowups.js +45 -0
  629. package/vendor/shared/dist/lucidInvocations.d.ts +82 -0
  630. package/vendor/shared/dist/lucidInvocations.d.ts.map +1 -0
  631. package/vendor/shared/dist/lucidInvocations.js +47 -0
  632. package/vendor/shared/dist/memory.d.ts +162 -0
  633. package/vendor/shared/dist/memory.d.ts.map +1 -0
  634. package/vendor/shared/dist/memory.js +26 -0
  635. package/vendor/shared/dist/messagingSafety.d.ts +43 -0
  636. package/vendor/shared/dist/messagingSafety.d.ts.map +1 -1
  637. package/vendor/shared/dist/messagingSafety.js +6 -0
  638. package/vendor/shared/dist/recall.d.ts +803 -0
  639. package/vendor/shared/dist/recall.d.ts.map +1 -0
  640. package/vendor/shared/dist/recall.js +56 -0
  641. package/vendor/shared/dist/releaseCompatibility.d.ts +228 -0
  642. package/vendor/shared/dist/releaseCompatibility.d.ts.map +1 -0
  643. package/vendor/shared/dist/releaseCompatibility.js +145 -0
  644. package/vendor/shared/dist/repositoryRequests.d.ts +173 -0
  645. package/vendor/shared/dist/repositoryRequests.d.ts.map +1 -0
  646. package/vendor/shared/dist/repositoryRequests.js +38 -0
  647. package/vendor/shared/dist/repositoryRouting.d.ts +169 -0
  648. package/vendor/shared/dist/repositoryRouting.d.ts.map +1 -0
  649. package/vendor/shared/dist/repositoryRouting.js +102 -0
  650. package/vendor/shared/dist/roomClient.d.ts +107 -0
  651. package/vendor/shared/dist/roomClient.d.ts.map +1 -0
  652. package/vendor/shared/dist/roomClient.js +371 -0
  653. package/vendor/shared/dist/schemas/comment.d.ts +46 -0
  654. package/vendor/shared/dist/schemas/comment.d.ts.map +1 -1
  655. package/vendor/shared/dist/schemas/comment.js +10 -0
  656. package/vendor/shared/dist/schemas/conversation.d.ts +80 -1
  657. package/vendor/shared/dist/schemas/conversation.d.ts.map +1 -1
  658. package/vendor/shared/dist/schemas/conversation.js +12 -1
  659. package/vendor/shared/dist/schemas/harness.d.ts +1631 -17
  660. package/vendor/shared/dist/schemas/harness.d.ts.map +1 -1
  661. package/vendor/shared/dist/schemas/harness.js +106 -3
  662. package/vendor/shared/dist/schemas/notification.d.ts +3 -1
  663. package/vendor/shared/dist/schemas/notification.d.ts.map +1 -1
  664. package/vendor/shared/dist/schemas/notification.js +2 -1
  665. package/vendor/shared/dist/schemas/organization.d.ts +2 -0
  666. package/vendor/shared/dist/schemas/organization.d.ts.map +1 -1
  667. package/vendor/shared/dist/schemas/organization.js +2 -0
  668. package/vendor/shared/dist/schemas/project.d.ts +2 -2
  669. package/vendor/shared/dist/schemas/request.d.ts +1 -1
  670. package/vendor/shared/dist/schemas/task.d.ts +1 -1
  671. package/vendor/shared/dist/smartCapture.js +1 -1
  672. package/vendor/shared/dist/spokenNames.d.ts +1 -1
  673. package/vendor/shared/dist/spokenNames.js +1 -1
  674. package/vendor/shared/dist/taskActivity.d.ts +5 -5
  675. package/vendor/shared/dist/taskSharing.d.ts +8 -0
  676. package/vendor/shared/dist/taskSharing.d.ts.map +1 -0
  677. package/vendor/shared/dist/taskSharing.js +9 -0
  678. package/vendor/shared/dist/thinking-orb/engine/core.d.ts +31 -0
  679. package/vendor/shared/dist/thinking-orb/engine/core.d.ts.map +1 -0
  680. package/vendor/shared/dist/thinking-orb/engine/core.js +62 -0
  681. package/vendor/shared/dist/thinking-orb/engine/ctx.d.ts +9 -0
  682. package/vendor/shared/dist/thinking-orb/engine/ctx.d.ts.map +1 -0
  683. package/vendor/shared/dist/thinking-orb/engine/ctx.js +1 -0
  684. package/vendor/shared/dist/thinking-orb/engine/lattice.d.ts +5 -0
  685. package/vendor/shared/dist/thinking-orb/engine/lattice.d.ts.map +1 -0
  686. package/vendor/shared/dist/thinking-orb/engine/lattice.js +184 -0
  687. package/vendor/shared/dist/thinking-orb/engine/morph.d.ts +3 -0
  688. package/vendor/shared/dist/thinking-orb/engine/morph.d.ts.map +1 -0
  689. package/vendor/shared/dist/thinking-orb/engine/morph.js +117 -0
  690. package/vendor/shared/dist/thinking-orb/engine/orbits.d.ts +3 -0
  691. package/vendor/shared/dist/thinking-orb/engine/orbits.d.ts.map +1 -0
  692. package/vendor/shared/dist/thinking-orb/engine/orbits.js +66 -0
  693. package/vendor/shared/dist/thinking-orb/engine/profiles.d.ts +8 -0
  694. package/vendor/shared/dist/thinking-orb/engine/profiles.d.ts.map +1 -0
  695. package/vendor/shared/dist/thinking-orb/engine/profiles.js +113 -0
  696. package/vendor/shared/dist/thinking-orb/engine/registry.d.ts +4 -0
  697. package/vendor/shared/dist/thinking-orb/engine/registry.d.ts.map +1 -0
  698. package/vendor/shared/dist/thinking-orb/engine/registry.js +14 -0
  699. package/vendor/shared/dist/thinking-orb/engine/ribbon.d.ts +3 -0
  700. package/vendor/shared/dist/thinking-orb/engine/ribbon.d.ts.map +1 -0
  701. package/vendor/shared/dist/thinking-orb/engine/ribbon.js +64 -0
  702. package/vendor/shared/dist/thinking-orb/engine/types.d.ts +6 -0
  703. package/vendor/shared/dist/thinking-orb/engine/types.d.ts.map +1 -0
  704. package/vendor/shared/dist/thinking-orb/engine/types.js +2 -0
  705. package/vendor/shared/dist/thinking-orb/index.d.ts +7 -0
  706. package/vendor/shared/dist/thinking-orb/index.d.ts.map +1 -0
  707. package/vendor/shared/dist/thinking-orb/index.js +2 -0
  708. package/vendor/shared/dist/thinking-orb/presets.d.ts +12 -0
  709. package/vendor/shared/dist/thinking-orb/presets.d.ts.map +1 -0
  710. package/vendor/shared/dist/thinking-orb/presets.js +67 -0
  711. package/vendor/shared/dist/thinking-orb/types.d.ts +24 -0
  712. package/vendor/shared/dist/thinking-orb/types.d.ts.map +1 -0
  713. package/vendor/shared/dist/thinking-orb/types.js +1 -0
  714. package/vendor/shared/dist/turnTiming.d.ts +13 -0
  715. package/vendor/shared/dist/turnTiming.d.ts.map +1 -0
  716. package/vendor/shared/dist/turnTiming.js +18 -0
  717. package/vendor/shared/dist/types.d.ts +3 -1
  718. package/vendor/shared/dist/types.d.ts.map +1 -1
  719. package/vendor/shared/dist/updateControl.d.ts +168 -0
  720. package/vendor/shared/dist/updateControl.d.ts.map +1 -0
  721. package/vendor/shared/dist/updateControl.js +43 -0
  722. package/vendor/shared/dist/videos.d.ts +31 -0
  723. package/vendor/shared/dist/videos.d.ts.map +1 -0
  724. package/vendor/shared/dist/videos.js +34 -0
  725. package/vendor/shared/dist/workspaceIO.d.ts +188 -0
  726. package/vendor/shared/dist/workspaceIO.d.ts.map +1 -0
  727. package/vendor/shared/dist/workspaceIO.js +50 -0
  728. package/vendor/shared/dist/workspaces.d.ts +740 -2
  729. package/vendor/shared/dist/workspaces.d.ts.map +1 -1
  730. package/vendor/shared/dist/workspaces.js +108 -2
  731. package/vendor/shared/package.json +12 -0
  732. package/vendor/shared/src/accountDevices.ts +28 -0
  733. package/vendor/shared/src/activityRecovery.ts +42 -0
  734. package/vendor/shared/src/agentMessages.ts +82 -0
  735. package/vendor/shared/src/aiUsage.ts +18 -0
  736. package/vendor/shared/src/artifacts.ts +48 -0
  737. package/vendor/shared/src/automationTemplates.ts +1 -0
  738. package/vendor/shared/src/automations.ts +10 -3
  739. package/vendor/shared/src/chatActivity.ts +56 -0
  740. package/vendor/shared/src/codingActivity.ts +40 -0
  741. package/vendor/shared/src/commandLocal.ts +1 -1
  742. package/vendor/shared/src/commands.ts +1 -1
  743. package/vendor/shared/src/commentMentions.ts +20 -0
  744. package/vendor/shared/src/computer.ts +40 -0
  745. package/vendor/shared/src/constants.ts +5 -0
  746. package/vendor/shared/src/daemonUpdates.ts +127 -0
  747. package/vendor/shared/src/deviceInteraction.ts +35 -0
  748. package/vendor/shared/src/doctor.ts +19 -0
  749. package/vendor/shared/src/fileUploads.ts +28 -0
  750. package/vendor/shared/src/files.ts +21 -0
  751. package/vendor/shared/src/index.ts +35 -1
  752. package/vendor/shared/src/lucidFollowups.ts +49 -0
  753. package/vendor/shared/src/lucidInvocations.ts +62 -0
  754. package/vendor/shared/src/memory.ts +30 -0
  755. package/vendor/shared/src/messagingSafety.ts +10 -0
  756. package/vendor/shared/src/recall.ts +69 -0
  757. package/vendor/shared/src/releaseCompatibility.ts +162 -0
  758. package/vendor/shared/src/repositoryRequests.ts +44 -0
  759. package/vendor/shared/src/repositoryRouting.ts +117 -0
  760. package/vendor/shared/src/roomClient.ts +351 -0
  761. package/vendor/shared/src/schemas/comment.ts +10 -0
  762. package/vendor/shared/src/schemas/conversation.ts +12 -1
  763. package/vendor/shared/src/schemas/harness.ts +120 -3
  764. package/vendor/shared/src/schemas/notification.ts +2 -1
  765. package/vendor/shared/src/schemas/organization.ts +2 -0
  766. package/vendor/shared/src/smartCapture.ts +1 -1
  767. package/vendor/shared/src/spokenNames.ts +1 -1
  768. package/vendor/shared/src/taskSharing.ts +13 -0
  769. package/vendor/shared/src/thinking-orb/ATTRIBUTION.md +36 -0
  770. package/vendor/shared/src/thinking-orb/engine/core.ts +81 -0
  771. package/vendor/shared/src/thinking-orb/engine/ctx.ts +15 -0
  772. package/vendor/shared/src/thinking-orb/engine/lattice.ts +205 -0
  773. package/vendor/shared/src/thinking-orb/engine/morph.ts +130 -0
  774. package/vendor/shared/src/thinking-orb/engine/orbits.ts +80 -0
  775. package/vendor/shared/src/thinking-orb/engine/profiles.ts +119 -0
  776. package/vendor/shared/src/thinking-orb/engine/registry.ts +18 -0
  777. package/vendor/shared/src/thinking-orb/engine/ribbon.ts +71 -0
  778. package/vendor/shared/src/thinking-orb/engine/types.ts +15 -0
  779. package/vendor/shared/src/thinking-orb/index.ts +6 -0
  780. package/vendor/shared/src/thinking-orb/presets.ts +88 -0
  781. package/vendor/shared/src/thinking-orb/types.ts +25 -0
  782. package/vendor/shared/src/turnTiming.ts +20 -0
  783. package/vendor/shared/src/types.ts +1 -1
  784. package/vendor/shared/src/updateControl.ts +45 -0
  785. package/vendor/shared/src/videos.ts +37 -0
  786. package/vendor/shared/src/workspaceIO.ts +61 -0
  787. package/vendor/shared/src/workspaces.ts +119 -2
@@ -1,14 +1,23 @@
1
1
  import { existsSync, realpathSync } from 'node:fs';
2
2
  import { dirname } from 'node:path';
3
3
  import { realpath } from 'node:fs/promises';
4
- import { createHash } from 'node:crypto';
5
- import { RepoSettingsSchema, sessionProvider } from '@lucidity/shared';
4
+ import { createHash, randomUUID } from 'node:crypto';
5
+ import { CodeRequestSchema, RepoSettingsSchema, WorkspaceModelPreferencesSchema, sessionProvider } from '@lucidity/shared';
6
6
  import { conversationKey } from '../runtimeStore.js';
7
7
  import { LaneQueue } from '../queue.js';
8
8
  import { resolveRepo } from './repos.js';
9
9
  import { archiveWorktree, archivedHead, deleteArchivedWorktree, ensureWorkspace, headSha, restoreArchivedFiles, sessionBranch, sessionWorktreePath, unmergedArchivedWork, workspaceBase, workspaceBranchExists } from './worktree.js';
10
10
  import { copyIncludedFiles, matchedFiles, runSetupScript } from './worktreeSetup.js';
11
11
  import { inspectRun, continuationRequest } from './runReview.js';
12
+ import { overviewMetadataRequestSchema } from './workspaceOverview.js';
13
+ import { overviewEntry, sourceKey, recallMessageId } from './overviewSources.js';
14
+ import { existingWorkspace } from '../editor/existingWorkspace.js';
15
+ import { isGreetingTitle, worktreeTitleSchema } from './workspaceTitle.js';
16
+ function imageMetadata(input) {
17
+ return input?.images?.length ? { imageCount: input.images.length,
18
+ ...(input.images.some(image => image.name) ? { imageNames: input.images.map(image => image.name ?? null) } : {}),
19
+ ...(input.imageOnly !== undefined ? { imageOnly: input.imageOnly } : {}) } : {};
20
+ }
12
21
  /** "Worktree 3": the next number this repository has not used. */
13
22
  export function nextWorkerTitle(titles) {
14
23
  const used = titles.map((title) => (title.startsWith('Worktree ') ? Number(title.slice(9)) : 0));
@@ -32,12 +41,231 @@ export class WorkspaceRegistry {
32
41
  store;
33
42
  repos;
34
43
  baseDir;
44
+ overviews;
35
45
  lanes = new LaneQueue();
36
46
  setups = new Map();
37
- constructor(store, repos, baseDir) {
47
+ listeners = new Set();
48
+ processing = false;
49
+ archiving = new Set();
50
+ editorGuards = new Set();
51
+ constructor(store, repos, baseDir, overviews) {
38
52
  this.store = store;
39
53
  this.repos = repos;
40
54
  this.baseDir = baseDir;
55
+ this.overviews = overviews;
56
+ // Preserve existing numbered labels first; custom titles receive a stable unused number.
57
+ const workers = this.store.list('workers');
58
+ for (const worker of workers) {
59
+ if (!worker.shortName && /^Worktree [1-9]\d*$/.test(worker.title)) {
60
+ worker.shortName = worker.title;
61
+ this.store.set('workers', worker.workerId, worker);
62
+ }
63
+ }
64
+ for (const worker of workers.sort((a, b) => a.createdAt.localeCompare(b.createdAt) || a.workerId.localeCompare(b.workerId))) {
65
+ if (!worker.shortName) {
66
+ worker.shortName = nextWorkerTitle(workers.filter(other => other.repoId === worker.repoId).map(other => other.shortName ?? other.title));
67
+ this.store.set('workers', worker.workerId, worker);
68
+ }
69
+ }
70
+ // An archive hook may have run before the crash. Never replay an uncertain mutation.
71
+ for (const operation of this.store.list('worktree-operations')) {
72
+ if (operation.state === 'running')
73
+ this.saveOperation({ ...operation, state: 'failed',
74
+ message: 'The computer restarted during this operation. Inspect the worktree before retrying.' });
75
+ }
76
+ for (const creation of this.store.list('agent-worktree-creations')) {
77
+ if (creation.state === 'creating')
78
+ this.store.set('agent-worktree-creations', creation.workerId, { ...creation, state: 'failed', message: 'The computer restarted during creation. Inspect the worktree before retrying setup.' });
79
+ }
80
+ for (const worker of workers)
81
+ this.nameWorktree(worker.workerId);
82
+ for (const id of this.overviews?.pendingRequests() ?? []) {
83
+ const request = this.store.command(id);
84
+ if (request?.kind === 'code' && this.store.status(id).terminated)
85
+ this.refreshOverview(request);
86
+ }
87
+ }
88
+ subscribe(listener) {
89
+ this.listeners.add(listener);
90
+ return () => { this.listeners.delete(listener); };
91
+ }
92
+ changed() {
93
+ this.store.set('workspace-revision', 'current', this.revision() + 1);
94
+ for (const listener of this.listeners) {
95
+ try {
96
+ listener();
97
+ }
98
+ catch { /* Reconnect repairs a missed push. */ }
99
+ }
100
+ }
101
+ revision() { return this.store.get('workspace-revision', 'current') ?? 0; }
102
+ snapshot(repoId) {
103
+ const repoIds = this.repos().map(r => r.id).filter(id => !repoId || id === repoId);
104
+ return { workers: this.list(repoId), scope: { repoIds, revision: this.revision() },
105
+ openedCheckouts: repoIds.filter(id => {
106
+ const conversation = conversationKey({ kind: 'code', repoId: id, mode: 'in-place' });
107
+ return this.store.get('opened-checkouts', conversation) || this.store.get('checkout-conversations', conversation) ||
108
+ this.store.lastCommand(conversation);
109
+ }),
110
+ operations: this.store.list('worktree-operations')
111
+ .filter(op => repoIds.includes(op.repoId)).filter((op, index, all) => op.state === 'waiting' || op.state === 'running' || index >= all.length - 100).map(({ force: _, ...op }) => op) };
112
+ }
113
+ /** Local tools can match the exact checkout without guessing IDs from branch names. */
114
+ locations() {
115
+ return this.store.list('workers').filter(w => this.repos().some(r => r.id === w.repoId))
116
+ .map(w => ({ workerId: w.workerId, repoId: w.repoId, path: w.path }));
117
+ }
118
+ /** Ready worktrees can receive their first turn; discovery itself never starts one. */
119
+ agentConversations() {
120
+ return this.repos().flatMap(repo => {
121
+ if (!resolveRepo(repo.id, this.repos()))
122
+ return [];
123
+ const scopes = [{ repoId: repo.id, workerId: undefined, title: 'Main checkout' },
124
+ ...this.list(repo.id).filter(w => w.state === 'ready').map(w => ({ repoId: repo.id, workerId: w.workerId, title: w.title }))];
125
+ return scopes.flatMap(scope => {
126
+ try {
127
+ const workspace = this.editorWorkspace({ ...scope, checkout: !scope.workerId });
128
+ const mode = scope.workerId ? 'worktree' : 'in-place';
129
+ const conversationId = conversationKey({ ...scope, kind: 'code', mode });
130
+ const checkout = scope.workerId ? undefined : this.store.get('checkout-conversations', conversationId);
131
+ const resume = this.resume({ ...scope, mode, id: '', prompt: '' });
132
+ const lastRequestId = this.store.lastCommand(conversationId);
133
+ const started = Boolean(resume || (scope.workerId && lastRequestId) || this.store.unfinished(conversationId));
134
+ if (!started && !scope.workerId)
135
+ return [];
136
+ return [{ ...scope, mode, conversationId, revision: checkout?.revision ?? '0',
137
+ started,
138
+ path: workspace.path, provider: resume ? sessionProvider(resume) : undefined,
139
+ status: workspace.status, lastRequestId }];
140
+ }
141
+ catch {
142
+ return [];
143
+ }
144
+ });
145
+ });
146
+ }
147
+ /** Read only the registered checkout; an editor request never creates one. */
148
+ editorWorkspace(scope, allowPending = false) {
149
+ const repo = this.repo(scope.repoId);
150
+ const worker = scope.workerId ? this.store.get('workers', scope.workerId) : undefined;
151
+ if (scope.workerId && (!worker || worker.repoId !== repo.id || worker.state !== 'ready' || !worker.path ||
152
+ worker.setup || this.setups.has(worker.workerId) || (!allowPending && this.pending(worker.workerId)) || this.archiving.has(worker.workerId)))
153
+ throw new Error('This worktree is not ready for editing. Restore it or finish its setup first.');
154
+ if (!scope.workerId && !scope.checkout)
155
+ throw new Error('Select Main checkout or a registered worktree.');
156
+ const conversation = conversationKey({ kind: 'code', repoId: scope.repoId, workerId: scope.workerId, mode: scope.checkout ? 'in-place' : 'worktree' });
157
+ return { path: realpathSync(worker?.path ?? repo.root), branch: worker?.branch ?? '',
158
+ revision: worker ? '0' : this.store.get('checkout-conversations', conversation)?.revision ?? '0',
159
+ status: this.store.unfinished(conversation) ? 'running' : 'idle' };
160
+ }
161
+ /** File/Git mutations cannot race worktree archive, restore, or deletion. */
162
+ withEditorWorkspace(scope, action, allowPending = false) {
163
+ const repo = this.repo(scope.repoId);
164
+ return this.lanes.run(repo.root, async () => { this.editorWorkspace(scope, allowPending); return action(); });
165
+ }
166
+ guardEditorLifetime(guard) {
167
+ this.editorGuards.add(guard);
168
+ return () => { this.editorGuards.delete(guard); };
169
+ }
170
+ editorActive(worker) { return [...this.editorGuards].some((guard) => guard(worker.repoId, worker.workerId)); }
171
+ saveOperation(operation) {
172
+ this.store.set('worktree-operations', operation.id, { ...operation, updatedAt: new Date().toISOString() });
173
+ this.changed();
174
+ }
175
+ pending(workerId) {
176
+ return this.store.list('worktree-operations').find(op => op.workerId === workerId &&
177
+ (op.state === 'waiting' || op.state === 'running'));
178
+ }
179
+ creations() {
180
+ return this.store.list('agent-worktree-creations').filter(c => this.repos().some(r => r.id === c.repoId));
181
+ }
182
+ requestCreation(request, run = work => work()) {
183
+ this.repo(request.repoId);
184
+ const previous = this.store.get('agent-worktree-creations', request.workerId);
185
+ if (previous) {
186
+ if (previous.repoId !== request.repoId || previous.title !== request.title)
187
+ throw new Error('This creation ID already belongs to another request. Retry with the original input.');
188
+ return previous;
189
+ }
190
+ if (this.store.get('workers', request.workerId) || this.store.get('deleted-workers', request.workerId))
191
+ throw new Error('This worktree ID is already in use. Select a new creation ID.');
192
+ const receipt = { ...request, state: 'creating' };
193
+ this.store.set('agent-worktree-creations', request.workerId, receipt);
194
+ void run(async () => {
195
+ const worker = await this.create(request.repoId, request.workerId, request.title);
196
+ this.store.set('agent-worktree-creations', request.workerId, { ...receipt, state: 'ready' });
197
+ this.changed();
198
+ return worker;
199
+ }).catch(error => {
200
+ this.store.set('agent-worktree-creations', request.workerId, { ...receipt, state: 'failed', message: String(error.message ?? error) });
201
+ this.changed();
202
+ });
203
+ return receipt;
204
+ }
205
+ requestLifecycle(request) {
206
+ this.repo(request.repoId);
207
+ const previous = this.store.get('worktree-operations', request.id);
208
+ if (previous) {
209
+ if (previous.repoId !== request.repoId || previous.workerId !== request.workerId ||
210
+ previous.action !== request.action || !!previous.force !== !!request.force)
211
+ throw new Error('This operation ID already belongs to a different request.');
212
+ return previous;
213
+ }
214
+ const worker = this.store.get('workers', request.workerId);
215
+ if (!worker || worker.repoId !== request.repoId)
216
+ throw new Error('This worktree is not registered in this repository.');
217
+ if (request.force && (request.action !== 'delete' || worker.state !== 'archived'))
218
+ throw new Error('Archive and inspect saved work before confirming its permanent deletion.');
219
+ if (worker.sessionCheckout)
220
+ throw new Error('The shared session checkout cannot be removed through an agent tool.');
221
+ const pending = this.pending(worker.workerId);
222
+ if (pending) {
223
+ if (pending.action !== request.action || !!pending.force !== !!request.force)
224
+ throw new Error('A different operation is already waiting for this worktree.');
225
+ return pending;
226
+ }
227
+ const operation = { ...request, title: worker.title, state: 'waiting',
228
+ message: 'Waiting for active work, queued messages and setup to finish.', updatedAt: new Date().toISOString() };
229
+ this.saveOperation(operation);
230
+ return operation;
231
+ }
232
+ /** Called by the daemon, independently of the agent's HTTP request or the phone connection. */
233
+ async processLifecycle() {
234
+ if (this.processing)
235
+ return;
236
+ this.processing = true;
237
+ try {
238
+ for (const operation of this.store.list('worktree-operations')) {
239
+ if (operation.state !== 'waiting')
240
+ continue;
241
+ const worker = this.store.get('workers', operation.workerId);
242
+ if (worker && (this.archiving.has(worker.workerId) || worker.state === 'creating' || this.setups.has(worker.workerId) || this.store.unfinished(worker.conversationId) || this.editorActive(worker)))
243
+ continue;
244
+ this.saveOperation({ ...operation, state: 'running',
245
+ message: operation.action === 'delete' ? 'Deleting worktree…' : 'Archiving worktree…' });
246
+ try {
247
+ if (worker && worker.state !== 'archived')
248
+ await this.archive(worker);
249
+ if (operation.action === 'delete') {
250
+ const unmerged = await this.delete(operation.repoId, operation.workerId, operation.force);
251
+ if (unmerged) {
252
+ this.saveOperation({ ...operation, state: 'blocked', message: `Worktree archived, but not deleted: ${unmerged.commits} unmerged commits${unmerged.uncommitted ? ' and uncommitted files' : ''}. Review its saved work before confirming deletion.` });
253
+ continue;
254
+ }
255
+ }
256
+ else if (!worker)
257
+ throw new Error('This worktree no longer exists.');
258
+ this.saveOperation({ ...operation, state: 'done',
259
+ message: operation.action === 'delete' ? 'Worktree deleted' : 'Worktree archived' });
260
+ }
261
+ catch (error) {
262
+ this.saveOperation({ ...operation, state: 'failed', message: error instanceof Error ? error.message : String(error) });
263
+ }
264
+ }
265
+ }
266
+ finally {
267
+ this.processing = false;
268
+ }
41
269
  }
42
270
  repo(id) {
43
271
  const repo = resolveRepo(id, this.repos());
@@ -46,8 +274,9 @@ export class WorkspaceRegistry {
46
274
  return repo;
47
275
  }
48
276
  public(worker) {
49
- const { path: _, legacyMessages: __, sessionCheckout: ___, legacy: ____, ...row } = worker;
277
+ const { path: _, legacyMessages: __, sessionCheckout: ___, legacy: ____, setupDeferred: _____, titleSuggestion: _suggestion, pendingTitleSuggestion: _pendingSuggestion, externalDesktop: _external, importContext: _context, titleSource: _titleSource, titleRequestId: _titleRequestId, titleDeferredThrough: _titleDeferredThrough, titleRevision: _titleRevision, ...row } = worker;
50
278
  return { ...row, resume: this.store.latestSession(worker.conversationId) ?? row.resume,
279
+ overview: this.overviews?.peek(worker.conversationId),
51
280
  ...(this.setups.has(worker.workerId) ? { setup: 'running' } : {}) };
52
281
  }
53
282
  list(repoId) {
@@ -55,6 +284,334 @@ export class WorkspaceRegistry {
55
284
  .filter((w) => (!repoId || w.repoId === repoId) && this.repos().some((r) => r.id === w.repoId))
56
285
  .map((w) => this.public(w));
57
286
  }
287
+ overviewHistory(command) {
288
+ if (!command.repoId)
289
+ throw new Error('Select a repository.');
290
+ this.repo(command.repoId);
291
+ const worker = command.workerId ? this.store.get('workers', command.workerId) : undefined;
292
+ if (command.workerId && (!worker || worker.repoId !== command.repoId))
293
+ throw new Error('This worktree is not registered in this repository.');
294
+ const conversationId = worker?.conversationId ?? conversationKey({ kind: 'code', repoId: command.repoId, mode: 'in-place' });
295
+ const checkout = worker ? undefined : this.store.get('checkout-conversations', conversationId);
296
+ const key = worker ? conversationId : `${conversationId}:${checkout?.revision ?? '0'}`;
297
+ const legacy = worker?.legacyMessages ?? checkout?.legacyMessages ?? [];
298
+ const entries = legacy.filter(m => m.role !== 'notice' && m.text.trim()).map(m => overviewEntry({ conversationId: key, kind: 'legacy', messageId: m.id }, m.role === 'user' ? 'user' : 'assistant', m.text));
299
+ for (const run of this.store.completedText(conversationId, checkout?.clearedThrough)) {
300
+ if (run.queueAction === 'cancel')
301
+ continue;
302
+ const identity = { conversationId: key, requestId: run.id };
303
+ const savedAt = new Date(run.completedAt).toISOString();
304
+ entries.push({ ...overviewEntry({ ...identity, kind: 'prompt', messageId: run.id }, run.senderKind === 'agent' ? 'assistant' : 'user', run.prompt), savedAt });
305
+ const corrections = this.store.get('overview-steering', run.id) ?? {};
306
+ const times = this.store.get('overview-steering-times', run.id) ?? {};
307
+ for (const [id, text] of Object.entries(corrections))
308
+ entries.push({ ...overviewEntry({ ...identity,
309
+ kind: 'steering', messageId: id, ...(times[id] ? { recordedAt: times[id] } : {}) }, 'user', text), savedAt });
310
+ if (run.text.trim())
311
+ entries.push({ ...overviewEntry({ ...identity, kind: 'reply', messageId: run.id,
312
+ recordedAt: savedAt }, 'assistant', run.text, run.outcome), savedAt });
313
+ }
314
+ return { key, entries };
315
+ }
316
+ /** Current accessible history, including archived workers. Cleared/deleted scopes never enter recall. */
317
+ recallDocuments() {
318
+ const documents = [];
319
+ for (const repo of this.repos()) {
320
+ if (!resolveRepo(repo.id, this.repos()))
321
+ continue;
322
+ const scopes = [{ repoId: repo.id, workerId: undefined, title: 'Main' },
323
+ ...this.list(repo.id).map(w => ({ repoId: repo.id, workerId: w.workerId, title: w.title }))];
324
+ for (const scope of scopes) {
325
+ const { key, entries } = this.overviewHistory(scope);
326
+ const title = `${repo.id} / ${scope.title}`;
327
+ const location = { repoId: repo.id, workerId: scope.workerId };
328
+ const sourceKeys = new Set(entries.map(e => sourceKey(e.source)));
329
+ for (const entry of entries) {
330
+ const source = entry.source;
331
+ const id = recallMessageId(source);
332
+ documents.push({ id, revision: source.revision, kind: 'message', authority: 'original',
333
+ title: `${title} / ${entry.role}`, text: entry.text, repoId: repo.id, conversationId: key,
334
+ speaker: entry.role, savedAt: entry.savedAt, recordedAt: source.recordedAt, location: { ...location, source } });
335
+ }
336
+ for (const topic of this.overviews?.peek(key)?.topics ?? []) {
337
+ // Stale derived summaries are never indexed after their evidence changes or disappears.
338
+ const supportingSources = [...(topic.sources ?? []), ...(topic.decisionSources ?? []).flat(), ...(topic.decisionCompletionSources ?? []).flat()];
339
+ if (!topic.id || !topic.sources?.length || supportingSources
340
+ .some(s => !sourceKeys.has(sourceKey(s))))
341
+ continue;
342
+ const text = [topic.summary, ...topic.decisions].join('\n');
343
+ documents.push({ id: `topic:${key}:${topic.id}`, revision: createHash('sha256').update(JSON.stringify(topic)).digest('hex'),
344
+ kind: 'topic', authority: 'derived', title: `${title} / ${topic.title}`, text,
345
+ repoId: repo.id, conversationId: key, recordedAt: topic.lastRecordedAt,
346
+ location, sources: topic.sources,
347
+ sourceIds: [...new Map(supportingSources.map(s => [recallMessageId(s), { id: recallMessageId(s), revision: s.revision }])).values()] });
348
+ }
349
+ }
350
+ }
351
+ // A memory may be saved before its turn finishes. Keep only the turn identity;
352
+ // derive text from the original command so clearing/deletion still revokes it.
353
+ const indexed = new Set(documents.map(doc => doc.id));
354
+ for (const { requestId } of this.store.list('memory-source-turns')) {
355
+ for (const doc of this.turnMemoryDocuments(requestId)) {
356
+ if (!indexed.has(doc.id)) {
357
+ documents.push(doc);
358
+ indexed.add(doc.id);
359
+ }
360
+ }
361
+ }
362
+ return documents;
363
+ }
364
+ turnMemoryDocuments(requestId) {
365
+ const request = this.store.command(requestId);
366
+ if (request?.kind !== 'code' || (!request.workerId && request.mode !== 'in-place') ||
367
+ !resolveRepo(request.repoId, this.repos()))
368
+ return [];
369
+ const worker = request.workerId ? this.store.get('workers', request.workerId) : undefined;
370
+ if (request.workerId && (!worker || worker.repoId !== request.repoId))
371
+ return [];
372
+ const conversation = worker?.conversationId ?? conversationKey(request);
373
+ const checkout = worker ? undefined : this.store.get('checkout-conversations', conversation);
374
+ if (checkout?.clearedThrough && request.id <= checkout.clearedThrough)
375
+ return [];
376
+ const key = worker ? conversation : `${conversation}:${checkout?.revision ?? '0'}`;
377
+ const entries = request.senderKind === 'agent' ? [] : [overviewEntry({ conversationId: key,
378
+ requestId, messageId: requestId, kind: 'prompt' }, 'user', request.prompt)];
379
+ const times = this.store.get('overview-steering-times', requestId) ?? {};
380
+ for (const [id, text] of Object.entries(this.store.get('overview-steering', requestId) ?? {}))
381
+ entries.push(overviewEntry({ conversationId: key, requestId, messageId: id, kind: 'steering',
382
+ ...(times[id] ? { recordedAt: times[id] } : {}) }, 'user', text));
383
+ return entries.map(entry => ({ id: recallMessageId(entry.source), revision: entry.source.revision,
384
+ kind: 'message', authority: 'original', speaker: 'user', text: entry.text,
385
+ title: `${request.repoId} / ${worker?.title ?? 'Main'} / user`, repoId: request.repoId,
386
+ conversationId: key, recordedAt: entry.source.recordedAt,
387
+ location: { repoId: request.repoId, workerId: request.workerId, source: entry.source } }));
388
+ }
389
+ /** Called only with the current turn binding supplied by the scoped MCP transport. */
390
+ memoryTurnSources(requestId) {
391
+ const request = this.store.command(requestId);
392
+ if (!request || this.store.status(requestId).terminated)
393
+ return [];
394
+ const documents = this.turnMemoryDocuments(requestId);
395
+ if (documents.length)
396
+ this.store.set('memory-source-turns', requestId, { requestId });
397
+ return documents;
398
+ }
399
+ recallScope() { return JSON.stringify(this.repos().map(r => [r.id, r.path, !!resolveRepo(r.id, this.repos())]).sort()); }
400
+ overview(command) {
401
+ const { key, entries } = this.overviewHistory(command);
402
+ return { workers: [], overviewState: this.overviews?.read(key, entries) ?? { status: 'error' } };
403
+ }
404
+ overviewSource(command) {
405
+ const missing = { workers: [], sourceResult: { status: 'unavailable',
406
+ message: 'This original message is no longer available in this conversation.' } };
407
+ if (!command.source)
408
+ return missing;
409
+ // Resolve through the current repository/worktree and Main clear boundary, never by a global run ID.
410
+ const { key, entries } = this.overviewHistory(command);
411
+ if (command.source.conversationId !== key)
412
+ return missing;
413
+ const found = entries.find(e => e.source.kind === command.source.kind &&
414
+ e.source.messageId === command.source.messageId && e.source.requestId === command.source.requestId);
415
+ if (!found)
416
+ return missing;
417
+ if (sourceKey(found.source) !== sourceKey(command.source))
418
+ return { workers: [], sourceResult: {
419
+ status: 'changed', message: 'This message changed after the summary was written. Refresh the overview to read its current source.'
420
+ } };
421
+ return { workers: [], sourceResult: { status: 'available', ...found } };
422
+ }
423
+ replyHistory(command, messageId) {
424
+ const history = this.overviewHistory(command);
425
+ if (!messageId)
426
+ return history;
427
+ // Match the displayed assistant text, including partial output before steering or interruption.
428
+ for (const entry of [...history.entries]) {
429
+ if (entry.source.kind !== 'prompt' || !entry.source.requestId ||
430
+ (messageId !== entry.source.requestId && !messageId.startsWith(`${entry.source.requestId}:`)))
431
+ continue;
432
+ const request = this.store.command(entry.source.requestId);
433
+ if (!request)
434
+ continue;
435
+ const state = this.store.read(request.id);
436
+ const run = this.historyRuns([{ request, state }])[0];
437
+ const fallback = Number(run.frames.slice().reverse().find(f => !['done', 'error', 'cancelled'].includes(String(f.type)))?.seq ?? 0);
438
+ const steering = [...(run.steering ?? [])].sort((a, b) => (a.afterSeq ?? fallback) - (b.afterSeq ?? fallback));
439
+ let index = 0, text = '';
440
+ const split = (seq) => {
441
+ while (index < steering.length && (steering[index].afterSeq ?? fallback) < seq) {
442
+ const instruction = steering[index++];
443
+ if (text)
444
+ history.entries.push(overviewEntry({ conversationId: history.key, requestId: request.id,
445
+ kind: 'reply', messageId: `${request.id}:before:${instruction.id}` }, 'assistant', text));
446
+ text = '';
447
+ }
448
+ };
449
+ for (const frame of run.frames) {
450
+ split(Number(frame.seq));
451
+ if (frame.type === 'delta' && typeof frame.text === 'string')
452
+ text += frame.text;
453
+ if (frame.type === 'done' && typeof frame.text === 'string')
454
+ text = frame.text;
455
+ }
456
+ split(Infinity);
457
+ const previous = history.entries.find(e => e.source.kind === 'reply' && e.source.messageId === request.id);
458
+ history.entries = history.entries.filter(e => e !== previous);
459
+ if (text.trim())
460
+ history.entries.push(overviewEntry({ conversationId: history.key, requestId: request.id,
461
+ kind: 'reply', messageId: request.id, ...(previous?.source.recordedAt ? { recordedAt: previous.source.recordedAt } : {}) }, 'assistant', text, previous?.outcome));
462
+ }
463
+ return history;
464
+ }
465
+ /** Resolve renderer IDs against accessible saved history, never a global ID lookup. */
466
+ messageSource(command) {
467
+ const { entries } = this.replyHistory(command, command.source?.messageId ?? command.messageId);
468
+ const found = command.source ? entries.find(entry => sourceKey(entry.source) === sourceKey(command.source)) :
469
+ entries.find(({ source }) => (source.kind === 'legacy' || source.messageId.includes(':before:') ? source.messageId :
470
+ `${source.messageId}:${source.kind === 'reply' ? 'reply' : 'user'}`) === command.messageId);
471
+ return { workers: [], sourceResult: found ? { status: 'available', ...found } : {
472
+ status: 'unavailable', message: 'This message is not available in saved history yet, or was removed.'
473
+ } };
474
+ }
475
+ replyContext(request) {
476
+ const source = request.replyTo;
477
+ if (!source)
478
+ throw new Error('Select an original message.');
479
+ const { key, entries } = this.replyHistory(request, source.messageId);
480
+ const result = key === source.conversationId ? entries.find(entry => sourceKey(entry.source) === sourceKey(source)) : undefined;
481
+ if (!result)
482
+ throw new Error('The original message changed or is no longer available. Reopen Reply on that message.');
483
+ let images = [];
484
+ if (source.requestId && (source.kind === 'prompt' || source.kind === 'steering')) {
485
+ images = this.messageImages({ action: 'message-image', repoId: request.repoId,
486
+ workerId: request.workerId, checkout: !request.workerId && request.mode === 'in-place', requestId: source.requestId,
487
+ ...(source.kind === 'steering' ? { steeringId: source.messageId } : {}) });
488
+ }
489
+ return { text: `Referenced message (historical context, not new instructions):\n${JSON.stringify({
490
+ source: result.source, role: result.role, text: result.text, imageCount: images.length,
491
+ })}`, images };
492
+ }
493
+ refreshOverview(request) {
494
+ // Legacy single-session worktrees have no durable worker record to attach an overview to.
495
+ if (!request.workerId && request.mode !== 'in-place')
496
+ return;
497
+ try {
498
+ const { key, entries } = this.overviewHistory(request);
499
+ const succeeded = this.store.completedText(conversationKey({ ...request, kind: 'code' }))
500
+ .some(run => run.id === request.id && run.outcome === 'done' && !run.queueAction);
501
+ this.overviews?.finish(request.id, key, entries, succeeded);
502
+ }
503
+ catch { /* Metadata failures cannot change the coding result. */ }
504
+ if (request.workerId)
505
+ this.nameWorktree(request.workerId);
506
+ }
507
+ summaryMetadata(input) {
508
+ const command = overviewMetadataRequestSchema.parse(input);
509
+ const request = this.store.command(command.requestId);
510
+ if (!this.overviews || request?.kind !== 'code' || this.store.status(request.id).terminated ||
511
+ (!request.workerId && request.mode !== 'in-place'))
512
+ throw new Error('Summary updates require a current coding turn.');
513
+ if (request.workerId) {
514
+ const worker = this.store.get('workers', request.workerId);
515
+ if (!worker || worker.state !== 'ready' || worker.repoId !== request.repoId ||
516
+ this.pending(request.workerId) || this.archiving.has(request.workerId))
517
+ throw new Error('This worktree is unavailable.');
518
+ }
519
+ else {
520
+ const checkout = this.store.get('checkout-conversations', conversationKey(request));
521
+ if (checkout?.clearedThrough && request.id <= checkout.clearedThrough)
522
+ throw new Error('This conversation was cleared.');
523
+ }
524
+ const { key, entries } = this.overviewHistory(request);
525
+ entries.push(overviewEntry({ conversationId: key, requestId: request.id, kind: 'prompt', messageId: request.id }, request.senderKind === 'agent' ? 'assistant' : 'user', request.prompt));
526
+ const corrections = this.store.get('overview-steering', request.id) ?? {};
527
+ const times = this.store.get('overview-steering-times', request.id) ?? {};
528
+ for (const [id, text] of Object.entries(corrections))
529
+ entries.push(overviewEntry({ conversationId: key,
530
+ requestId: request.id, kind: 'steering', messageId: id, ...(times[id] ? { recordedAt: times[id] } : {}) }, 'user', text));
531
+ return command.action === 'summary-context'
532
+ ? this.overviews.context(key, entries, command.offset)
533
+ : this.overviews.suggest(request.id, key, entries, command.revision, command.update);
534
+ }
535
+ suggestTitle(requestId, title) {
536
+ title = worktreeTitleSchema.parse(title);
537
+ const request = this.store.command(requestId);
538
+ const worker = request?.kind === 'code' && request.workerId
539
+ ? this.store.get('workers', request.workerId) : undefined;
540
+ if (!worker || request?.kind !== 'code' || request.repoId !== worker.repoId ||
541
+ worker.state !== 'ready' || this.pending(worker.workerId) || this.archiving.has(worker.workerId) ||
542
+ this.store.status(requestId).terminated || this.store.get('memory-hidden-conversations', worker.conversationId))
543
+ throw new Error('Title suggestions require the current worktree turn.');
544
+ this.repo(worker.repoId);
545
+ // Persist privately. Only a successfully completed turn can publish its suggestion.
546
+ this.store.set('workers', worker.workerId, { ...worker,
547
+ pendingTitleSuggestion: { title, requestId, revision: worker.titleRevision } });
548
+ return { saved: true };
549
+ }
550
+ nameWorktree(workerId) {
551
+ let worker = this.store.get('workers', workerId);
552
+ if (!worker || worker.state !== 'ready' || this.pending(workerId) || this.archiving.has(workerId) ||
553
+ this.store.get('memory-hidden-conversations', worker.conversationId))
554
+ return;
555
+ const exchanges = this.store.completedText(worker.conversationId).filter(run => run.outcome === 'done' && !run.queueAction && run.prompt?.trim() && !/^\s*\/[a-z-]+(?:\s|$)/i.test(run.prompt) && run.text.trim());
556
+ const pending = worker.pendingTitleSuggestion;
557
+ if (pending && this.store.status(pending.requestId).terminated) {
558
+ const completed = exchanges.some(run => run.id === pending.requestId);
559
+ worker = { ...worker, pendingTitleSuggestion: undefined,
560
+ ...(completed && pending.revision === worker.titleRevision ? { titleSuggestion: pending } : {}) };
561
+ this.store.set('workers', workerId, worker);
562
+ }
563
+ const suggestion = worker.titleSuggestion;
564
+ const unnamed = ((!worker.titleSource || worker.titleSource === 'default') && worker.title === worker.shortName) ||
565
+ (worker.titleSource === 'generated' && !worker.titleRevision && isGreetingTitle(worker.title));
566
+ if (exchanges.length >= 3 && unnamed && suggestion && suggestion.revision === worker.titleRevision) {
567
+ this.save({ ...worker, title: suggestion.title, titleSource: 'generated', titleRequestId: undefined, titleDeferredThrough: undefined });
568
+ }
569
+ }
570
+ async refreshTitle(repoId, workerId) {
571
+ let worker = this.store.get('workers', workerId);
572
+ if (!worker || worker.repoId !== repoId || worker.state !== 'ready' || this.pending(workerId) || this.archiving.has(workerId) ||
573
+ this.store.get('memory-hidden-conversations', worker.conversationId))
574
+ throw new Error('This worktree is unavailable.');
575
+ this.nameWorktree(workerId);
576
+ worker = this.store.get('workers', workerId);
577
+ const suggestion = worker.titleSuggestion;
578
+ if (!suggestion || suggestion.revision !== worker.titleRevision)
579
+ throw new Error('No name suggestion is ready yet. Try after the next completed reply.');
580
+ const titleRevision = randomUUID();
581
+ this.save({ ...worker, title: suggestion.title, titleSource: 'generated', titleRevision,
582
+ titleSuggestion: { ...suggestion, revision: titleRevision }, titleRequestId: undefined, titleDeferredThrough: undefined });
583
+ }
584
+ recordOverviewSteering(targetId, id, prompt, images, imageOnly) {
585
+ if (this.store.command(targetId)?.kind !== 'code')
586
+ return;
587
+ const previous = this.store.get('overview-steering', targetId) ?? {};
588
+ if (previous[id] === prompt)
589
+ return;
590
+ this.store.transaction(() => {
591
+ this.store.set('overview-steering', targetId, { ...previous, [id]: prompt });
592
+ if (images?.length)
593
+ this.store.set('steering-images', id, { images, imageOnly });
594
+ const times = this.store.get('overview-steering-times', targetId) ?? {};
595
+ this.store.set('overview-steering-times', targetId, { ...times, [id]: new Date().toISOString() });
596
+ const boundaries = this.store.get('steering-boundaries', targetId) ?? {};
597
+ const state = this.store.status(targetId);
598
+ // A turn can finish during acknowledgement; keep its final answer below the instruction.
599
+ this.store.set('steering-boundaries', targetId, { ...boundaries,
600
+ [id]: boundaries[id] ?? Math.max(0, state.maxSeq - Number(state.terminated)) });
601
+ });
602
+ }
603
+ recordQueuedSteering(targetId, id) {
604
+ const request = this.store.command(id);
605
+ if (request?.kind !== 'code' || this.store.command(targetId)?.kind !== 'code')
606
+ return;
607
+ // Queued prompts already have recall sources; save only their transcript placement here.
608
+ const previous = this.store.get('queued-steering', targetId) ?? {};
609
+ if (previous[id])
610
+ return;
611
+ const state = this.store.status(targetId);
612
+ this.store.set('queued-steering', targetId, { ...previous,
613
+ [id]: { prompt: request.prompt, afterSeq: Math.max(0, state.maxSeq - Number(state.terminated)) } });
614
+ }
58
615
  /** How this repository's worktrees are prepared. Nothing is copied or run until the owner sets it. */
59
616
  settings(repoId) {
60
617
  return RepoSettingsSchema.parse(this.store.get('repo-settings', repoId) ?? {});
@@ -67,23 +624,35 @@ export class WorkspaceRegistry {
67
624
  /** Run the archive command, then free the folder. Shared by the phone's Archive and archive-on-merge. */
68
625
  async archive(worker) {
69
626
  const { repoId, workerId } = worker;
70
- if (worker.state === 'creating' || this.setups.has(workerId))
71
- throw new Error('Wait for workspace setup to finish before archiving.');
72
- if (this.store.unfinished(worker.conversationId))
73
- throw new Error('Stop this worker and its queued messages before archiving it.');
74
- // The session checkout is shared with the classic single session, so its folder stays.
75
- if (!worker.sessionCheckout) {
76
- const root = this.repo(repoId).root;
77
- const settings = this.settings(repoId);
78
- const path = sessionWorktreePath(repoId, this.baseDir, workerId);
79
- if (settings.archiveScript && existsSync(path))
80
- await runSetupScript(root, path, worker.title, settings.archiveScript, worker.port).catch((error) => {
81
- const detail = String(error.stderr || error.message).trim().slice(-600);
82
- throw new Error(`The archive command failed, so this worktree was kept. ${detail}`);
83
- });
84
- await archiveWorktree(root, { path, branch: worker.branch ?? sessionBranch(repoId, workerId), mode: 'worktree' }, workerId, { deleteBranch: settings.deleteBranchOnArchive });
627
+ if (this.archiving.has(workerId))
628
+ throw new Error('This worktree is already being archived.');
629
+ this.archiving.add(workerId);
630
+ try {
631
+ await this.lanes.run(this.repo(repoId).root, async () => {
632
+ if (worker.state === 'creating' || this.setups.has(workerId))
633
+ throw new Error('Wait for workspace setup to finish before archiving.');
634
+ if (this.editorActive(worker))
635
+ throw new Error('Exit this worktree’s terminal and stop its Run command before archiving.');
636
+ if (this.store.unfinished(worker.conversationId))
637
+ throw new Error('Stop this worker and its queued messages before archiving it.');
638
+ // The session checkout is shared with the classic single session, so its folder stays.
639
+ if (!worker.sessionCheckout && !worker.externalDesktop) {
640
+ const root = this.repo(repoId).root;
641
+ const settings = this.settings(repoId);
642
+ const path = sessionWorktreePath(repoId, this.baseDir, workerId);
643
+ if (settings.archiveScript && existsSync(path))
644
+ await runSetupScript(root, path, worker.title, settings.archiveScript, worker.port).catch((error) => {
645
+ const detail = String(error.stderr || error.message).trim().slice(-600);
646
+ throw new Error(`The archive command failed, so this worktree was kept. ${detail}`);
647
+ });
648
+ await archiveWorktree(root, { path, branch: worker.branch ?? sessionBranch(repoId, workerId), mode: 'worktree' }, workerId, { deleteBranch: settings.deleteBranchOnArchive });
649
+ }
650
+ this.save({ ...worker, state: 'archived' });
651
+ });
652
+ }
653
+ finally {
654
+ this.archiving.delete(workerId);
85
655
  }
86
- this.save({ ...worker, state: 'archived' });
87
656
  }
88
657
  /** Remove an archived worktree for good: its local branch, its snapshot and its record. Answers
89
658
  * with the work that would be lost, deleting nothing, unless there is none or `force` is set. */
@@ -100,7 +669,7 @@ export class WorkspaceRegistry {
100
669
  if (worker.state !== 'archived')
101
670
  throw new Error('Archive this worktree before deleting it.');
102
671
  // The session checkout's branch and folder belong to the classic single session, so they stay.
103
- if (!worker.sessionCheckout) {
672
+ if (!worker.sessionCheckout && !worker.externalDesktop) {
104
673
  const branch = worker.branch ?? sessionBranch(repoId, workerId);
105
674
  if (!force) {
106
675
  const unmerged = await unmergedArchivedWork(root, workerId, branch, [worker.baseRef, this.settings(repoId).baseRef, this.repos().find((r) => r.id === repoId)?.baseRef]);
@@ -114,9 +683,11 @@ export class WorkspaceRegistry {
114
683
  }
115
684
  // The conversation's runs stay: they are the receipts that stop a replayed request running twice.
116
685
  this.store.transaction(() => {
686
+ this.store.set('deleted-workers', workerId, { repoId, deletedAt: new Date().toISOString() });
117
687
  this.store.delete('workers', workerId);
118
688
  this.store.delete('workspaces', worker.conversationId);
119
689
  });
690
+ this.changed();
120
691
  return undefined;
121
692
  });
122
693
  }
@@ -125,7 +696,7 @@ export class WorkspaceRegistry {
125
696
  async archiveMerged(mergedHead) {
126
697
  const archived = [];
127
698
  for (const worker of this.store.list('workers')) {
128
- if (worker.state !== 'ready' || worker.sessionCheckout || !worker.path || !worker.branch)
699
+ if (this.pending(worker.workerId) || worker.state !== 'ready' || worker.sessionCheckout || !worker.path || !worker.branch)
129
700
  continue;
130
701
  try {
131
702
  if (!this.settings(worker.repoId).archiveOnMerge || !existsSync(worker.path))
@@ -142,6 +713,7 @@ export class WorkspaceRegistry {
142
713
  }
143
714
  save(worker) {
144
715
  this.store.set('workers', worker.workerId, { ...worker, updatedAt: new Date().toISOString() });
716
+ this.changed();
145
717
  }
146
718
  resume(request) {
147
719
  if (!request.workerId && request.mode === 'in-place' && !request.handoff) {
@@ -159,19 +731,90 @@ export class WorkspaceRegistry {
159
731
  const resume = this.store.latestSession(worker.conversationId) ?? worker.resume ?? request.resume;
160
732
  return request.provider && sessionProvider(resume) !== request.provider ? undefined : resume;
161
733
  }
162
- async create(repoId, workerId, title, brief = '') {
734
+ /** Only an explicit transcript import authorizes this one-time new-session
735
+ * context. A recorded session that fails to resume never takes this fallback. */
736
+ continuationFields(request) {
737
+ const resume = this.resume(request);
738
+ const conversation = conversationKey({ ...request, kind: 'code' });
739
+ const saved = request.workerId ? this.store.get('workers', request.workerId)
740
+ : this.store.get('checkout-conversations', conversation);
741
+ const context = saved?.importContext;
742
+ const after = request.workerId ? undefined : saved?.clearedThrough;
743
+ if (!resume && !request.handoff && context && !this.store.latestSession(conversation, after))
744
+ return {
745
+ resume: undefined, provider: request.provider ?? context.provider,
746
+ handoff: { from: context.provider, transcript: context.transcript },
747
+ };
748
+ return { resume };
749
+ }
750
+ /** The same conversation key is used for execution and the phone's model picker. */
751
+ modelKey(context, provider) {
752
+ return JSON.stringify([conversationKey({ ...context, kind: 'code' }), provider]);
753
+ }
754
+ modelPreferences(request, defaultProvider) {
755
+ const provider = sessionProvider(request.resume) ?? request.provider ?? defaultProvider;
756
+ return this.store.get('workspace-models', this.modelKey(request, provider));
757
+ }
758
+ /** Called only after initial-message admission and execution validation. */
759
+ initializeAgentSettings(request, preferences) {
760
+ if (!request.workerId || !request.agentMessage?.initialSettings || request.resume || request.handoff ||
761
+ this.store.commands(conversationKey({ ...request, kind: 'code' }), { before: request.id, limit: 1 }).length)
762
+ throw new Error('Initial settings require a new worktree conversation.');
763
+ this.store.set('workspace-models', this.modelKey(request, preferences.provider), WorkspaceModelPreferencesSchema.parse(preferences));
764
+ }
765
+ modelSettings(command) {
766
+ if (!command.repoId || !command.provider)
767
+ throw new Error('Select a repository and provider.');
768
+ this.repo(command.repoId);
769
+ if (command.workerId) {
770
+ const worker = this.store.get('workers', command.workerId);
771
+ if (!worker || worker.repoId !== command.repoId)
772
+ throw new Error('This worker is not registered in this repository.');
773
+ }
774
+ else if (!command.checkout)
775
+ throw new Error('Select a worktree or Main checkout.');
776
+ const key = this.modelKey({ repoId: command.repoId, workerId: command.workerId,
777
+ mode: command.checkout ? 'in-place' : 'worktree' }, command.provider);
778
+ if (command.action === 'save-model-settings') {
779
+ const preferences = WorkspaceModelPreferencesSchema.parse(command.modelPreferences);
780
+ if (preferences.provider !== command.provider)
781
+ throw new Error('Model settings must match the selected provider.');
782
+ this.store.set('workspace-models', key, preferences);
783
+ }
784
+ return { workers: [], modelPreferences: this.store.get('workspace-models', key) ?? null };
785
+ }
786
+ async create(repoId, workerId, title, brief = '', options = {}) {
163
787
  const repo = this.repo(repoId);
164
788
  return this.lanes.run(repo.root, async () => {
789
+ if (this.store.get('deleted-workers', workerId))
790
+ throw new Error('This worktree was deleted. Create a new worktree to continue.');
791
+ if (this.archiving.has(workerId) || this.pending(workerId)?.state === 'running')
792
+ throw new Error('This worktree is being archived or deleted.');
165
793
  const previous = this.store.get('workers', workerId);
166
794
  if (previous && previous.repoId !== repoId)
167
795
  throw new Error('This worker belongs to another repository.');
168
796
  if (previous?.state === 'archived')
169
797
  throw new Error('Restore this worker before continuing.');
170
- if (previous?.state === 'ready')
798
+ if (previous?.externalDesktop) {
799
+ if (!previous.path)
800
+ throw new Error('The imported workspace folder is missing.');
801
+ await existingWorkspace(repo.root, previous.path, previous.branch ?? '');
802
+ if (previous.state !== 'ready')
803
+ this.save({ ...previous, state: 'ready', error: undefined });
804
+ return this.public({ ...previous, state: 'ready', error: undefined });
805
+ }
806
+ if (previous?.state === 'ready') {
807
+ if (previous.setupDeferred && !options.deferSetup) {
808
+ previous.setupDeferred = false;
809
+ this.save(previous);
810
+ this.setUp(repo.root, previous, options.signal);
811
+ }
171
812
  return this.public(previous);
813
+ }
172
814
  const now = new Date().toISOString();
815
+ const shortName = nextWorkerTitle(this.store.list('workers').filter(w => w.repoId === repoId).map(w => w.shortName ?? w.title));
173
816
  const worker = previous ?? {
174
- workerId, repoId, title: title || nextWorkerTitle(this.store.list('workers').filter((w) => w.repoId === repoId).map((w) => w.title)), brief,
817
+ workerId, repoId, title: title || shortName, shortName, titleSource: title ? 'custom' : 'default', brief,
175
818
  workspaceId: workerId, conversationId: conversationKey({ kind: 'code', repoId, workerId }),
176
819
  state: 'creating', createdAt: now, updatedAt: now,
177
820
  };
@@ -196,9 +839,10 @@ export class WorkspaceRegistry {
196
839
  await restoreArchivedFiles(repo.root, workspace, workerId);
197
840
  const ready = { ...worker, state: 'ready', error: undefined, path: await realpath(workspace.path),
198
841
  port: this.portOf(worker), branch: workspace.branch, ...(base ? { baseRef: base.ref, baseSha: base.sha } : {}) };
842
+ ready.setupDeferred = Boolean((fresh && gitWorkerId || worker.setupDeferred) && options.deferSetup);
199
843
  this.save(ready);
200
- if (fresh && gitWorkerId)
201
- this.setUp(repo.root, ready);
844
+ if ((fresh && gitWorkerId || worker.setupDeferred) && !options.deferSetup)
845
+ this.setUp(repo.root, ready, options.signal);
202
846
  return this.public(ready);
203
847
  }
204
848
  catch (error) {
@@ -215,32 +859,40 @@ export class WorkspaceRegistry {
215
859
  /** Fill in a worktree: the repository's listed files, then its setup command. This runs after the
216
860
  * worktree is reported ready so the phone is not kept waiting; a turn waits for it in prepare().
217
861
  * A failure is noted on the worker and never fails the worktree. */
218
- setUp(repoRoot, worker) {
862
+ setUp(repoRoot, worker, signal) {
219
863
  const settings = this.settings(worker.repoId);
220
864
  if (!settings.copy.length && !settings.setup)
221
865
  return;
222
866
  this.save({ ...worker, setup: undefined, error: undefined });
223
867
  const run = (async () => {
868
+ signal?.throwIfAborted();
224
869
  copyIncludedFiles(repoRoot, worker.path, settings.copy);
225
870
  if (settings.setup)
226
- await runSetupScript(repoRoot, worker.path, worker.title, settings.setup, worker.port);
871
+ await runSetupScript(repoRoot, worker.path, worker.title, settings.setup, worker.port, signal);
227
872
  })().catch((error) => {
228
873
  const detail = String(error.stderr || error.message).trim().slice(-600);
229
874
  console.error(`[workspaces] setup failed for ${worker.workerId}: ${detail}`);
230
875
  const current = this.store.get('workers', worker.workerId);
231
876
  if (current?.state === 'ready')
232
877
  this.save({ ...current, setup: 'failed', error: detail });
233
- }).finally(() => this.setups.delete(worker.workerId));
878
+ }).finally(() => { this.setups.delete(worker.workerId); this.changed(); });
234
879
  this.setups.set(worker.workerId, run);
880
+ this.changed();
235
881
  }
236
- async prepare(request) {
882
+ async prepare(request, options = {}) {
237
883
  this.checkRecoveryWorkspace(request);
238
884
  const repo = this.repo(request.repoId);
239
885
  let gitWorkerId = request.workerId;
240
886
  if (request.workerId) {
241
- await this.create(request.repoId, request.workerId, undefined, request.prompt);
887
+ await this.create(request.repoId, request.workerId, undefined, request.prompt, options);
242
888
  await this.setups.get(request.workerId);
243
889
  const worker = this.store.get('workers', request.workerId);
890
+ if (worker.externalDesktop) {
891
+ const location = await existingWorkspace(repo.root, worker.path, worker.branch);
892
+ const workspace = { path: location, branch: worker.branch, mode: 'worktree' };
893
+ this.store.set('workspaces', worker.conversationId, { ...workspace, repoId: request.repoId });
894
+ return workspace;
895
+ }
244
896
  if (worker.sessionCheckout)
245
897
  gitWorkerId = undefined;
246
898
  if (!worker.path || !existsSync(worker.path)) {
@@ -268,6 +920,10 @@ export class WorkspaceRegistry {
268
920
  const conversationId = conversationKey({ kind: 'code', repoId: command.repoId, mode: 'in-place' });
269
921
  if (!['history', 'import', 'clear-history'].includes(command.action))
270
922
  throw new Error('Main checkout supports history, import and clear.');
923
+ if (command.action === 'history' && command.open && !command.before && !this.store.get('opened-checkouts', conversationId)) {
924
+ this.store.set('opened-checkouts', conversationId, true);
925
+ this.changed();
926
+ }
271
927
  const saved = () => this.store.get('checkout-conversations', conversationId) ?? { revision: '0' };
272
928
  if (command.action !== 'history') {
273
929
  this.store.transaction(() => {
@@ -283,6 +939,8 @@ export class WorkspaceRegistry {
283
939
  if (command.action === 'clear-history') {
284
940
  if (this.store.unfinished(conversationId))
285
941
  throw new Error('Finish or stop active and queued messages before clearing this conversation.');
942
+ if ([...this.editorGuards].some(guard => guard(command.repoId)))
943
+ throw new Error('Stop active terminals and shell commands before clearing this conversation.');
286
944
  this.store.set('checkout-conversations', conversationId, {
287
945
  revision: commandId ?? `${Date.now()}:${checkout.revision}`,
288
946
  clearedThrough: this.store.lastCommand(conversationId),
@@ -306,17 +964,127 @@ export class WorkspaceRegistry {
306
964
  return {
307
965
  workers: [], checkout: { repoId: command.repoId, conversationId, revision: checkout.revision,
308
966
  resume: this.store.latestSession(conversationId, checkout.clearedThrough) ?? checkout.resume },
967
+ continuationProvider: checkout.importContext?.provider,
309
968
  legacyMessages: command.before ? [] : checkout.legacyMessages,
310
- runs: this.historyRuns(page),
969
+ runs: this.historyRuns(this.includeActive(page, conversationId, command.before)),
311
970
  ...(page.length === 10 ? { nextBefore: page[0].request.id } : {}),
312
971
  };
313
972
  }
973
+ includeActive(page, conversation, before) {
974
+ if (before)
975
+ return page;
976
+ return this.store.withActiveCommands(conversation, page);
977
+ }
314
978
  historyRuns(page) {
315
979
  return page.map(({ request, state }) => ({ requestId: request.id, prompt: 'prompt' in request ? request.prompt : '',
980
+ ...(request.kind === 'code' && request.senderKind === 'agent' && request.agentMessage
981
+ ? { agentHandoff: { sender: request.agentMessage.dispatch?.source.title || 'Another agent', message: request.agentMessage.message,
982
+ ...(request.agentMessage.dispatch?.source.conversationId ? { sourceConversationId: request.agentMessage.dispatch.source.conversationId } : {}),
983
+ ...(request.agentMessage.dispatch?.owner ? { owner: request.agentMessage.dispatch.owner } : {}) } } : {}),
984
+ ...(request.kind === 'code' && request.teamRequest ? { agentHandoff: { kind: 'team-request',
985
+ sender: request.teamRequest.sender.name, message: request.teamRequest.prompt, owner: request.teamRequest.sender,
986
+ approvedBy: request.teamRequest.recipient } } : {}),
987
+ ...(request.kind === 'code' && request.replyTo ? { replyTo: request.replyTo } : {}),
988
+ ...imageMetadata(request.kind === 'code' ? request : undefined),
989
+ ...(request.kind === 'code' && request.files?.length ? { fileNames: request.files.map(file => file.name) } : {}),
990
+ steering: [...Object.entries(this.store.get('overview-steering', request.id) ?? {})
991
+ .map(([id, prompt]) => ({ id, prompt,
992
+ ...imageMetadata(this.store.get('steering-images', id)),
993
+ afterSeq: this.store.get('steering-boundaries', request.id)?.[id] })),
994
+ ...Object.entries(this.store.get('queued-steering', request.id) ?? {})
995
+ .map(([id, instruction]) => {
996
+ const queued = this.store.command(id);
997
+ return { id, ...instruction, ...imageMetadata(queued?.kind === 'code' ? queued : undefined) };
998
+ })],
999
+ ...(this.store.get('run-reviews', request.id)?.continuedAt
1000
+ ? { reviewedContinuationId: this.store.get('run-reviews', request.id).continuationId } : {}),
316
1001
  ...('handoff' in request && request.handoff && request.provider ? { handoff: { from: request.handoff.from, to: request.provider } } : {}),
317
1002
  frames: state.frames, terminated: state.terminated }));
318
1003
  }
1004
+ messageRequest(command) {
1005
+ if (!command.repoId || !command.requestId)
1006
+ throw new Error('Select a message attachment.');
1007
+ this.repo(command.repoId);
1008
+ const request = this.store.command(command.requestId);
1009
+ if (request?.kind !== 'code' || request.repoId !== command.repoId || request.workerId !== command.workerId ||
1010
+ (!command.workerId && (request.mode !== 'in-place' || !command.checkout)))
1011
+ throw new Error('This image is unavailable in this conversation.');
1012
+ if (command.workerId) {
1013
+ const worker = this.store.get('workers', command.workerId);
1014
+ if (!worker || worker.repoId !== command.repoId)
1015
+ throw new Error('This worktree is unavailable.');
1016
+ }
1017
+ else {
1018
+ const saved = this.store.get('checkout-conversations', conversationKey(request));
1019
+ if (saved?.clearedThrough && request.id <= saved.clearedThrough)
1020
+ throw new Error('This message was cleared.');
1021
+ }
1022
+ return request;
1023
+ }
1024
+ messageImages(command) {
1025
+ const request = this.messageRequest(command);
1026
+ let images = request.images;
1027
+ if (command.steeringId) {
1028
+ const id = command.steeringId;
1029
+ const direct = this.store.get('overview-steering', request.id);
1030
+ const queued = this.store.get('queued-steering', request.id);
1031
+ if (direct && Object.hasOwn(direct, id))
1032
+ images = this.store.get('steering-images', id)?.images;
1033
+ else if (queued && Object.hasOwn(queued, id)) {
1034
+ const instruction = this.store.command(id);
1035
+ images = instruction?.kind === 'code' ? instruction.images : undefined;
1036
+ }
1037
+ else
1038
+ throw new Error('This image is unavailable in this conversation.');
1039
+ }
1040
+ return images ?? [];
1041
+ }
1042
+ messageImage(command) {
1043
+ const images = this.messageImages(command);
1044
+ const image = command.imageIndex === undefined ? undefined : images[command.imageIndex];
1045
+ if (!image)
1046
+ throw new Error('This image is unavailable.');
1047
+ return { workers: [], messageImage: `data:${image.mediaType};base64,${image.dataBase64}` };
1048
+ }
1049
+ pastedText(command) {
1050
+ const request = this.messageRequest(command);
1051
+ const file = command.fileIndex === undefined ? undefined : request.files?.[command.fileIndex];
1052
+ if (command.steeringId || !file || file.mediaType !== 'text/plain' ||
1053
+ !/^Pasted text \(\d+ characters\)\.txt$/.test(file.name))
1054
+ throw new Error('This pasted text is unavailable.');
1055
+ const text = new TextDecoder('utf-8', { fatal: true }).decode(Buffer.from(file.dataBase64, 'base64'));
1056
+ const start = command.textOffset ?? 0;
1057
+ const end = Math.min(text.length, start + (command.textLimit ?? 2000));
1058
+ if (start > text.length)
1059
+ throw new Error('This text offset is unavailable.');
1060
+ return { workers: [], pastedText: { text: text.slice(start, end), ...(end < text.length ? { nextOffset: end } : {}) } };
1061
+ }
319
1062
  async command(command, commandId) {
1063
+ if (command.action === 'delivery-status') {
1064
+ if (!command.repoId || !command.requestId)
1065
+ throw new Error('Select a conversation and message.');
1066
+ const scope = { repoId: command.repoId, workerId: command.workerId, checkout: command.checkout };
1067
+ const workspace = this.editorWorkspace(scope, true);
1068
+ const saved = this.store.command(command.requestId);
1069
+ if (saved && (saved.kind !== 'code' || saved.repoId !== command.repoId || saved.workerId !== command.workerId ||
1070
+ (saved.mode === 'in-place') !== !!command.checkout))
1071
+ throw new Error('This message belongs to another conversation.');
1072
+ const state = saved ? 'accepted' : this.store.status(command.requestId).exists ? 'unavailable' : 'missing';
1073
+ return { workers: [], delivery: { requestId: command.requestId, state, revision: workspace.revision,
1074
+ ...(saved ? { requestDigest: createHash('sha256').update(JSON.stringify(CodeRequestSchema.parse(saved))).digest('hex') } : {}) } };
1075
+ }
1076
+ if (command.action === 'pasted-text')
1077
+ return this.pastedText(command);
1078
+ if (command.action === 'message-image')
1079
+ return this.messageImage(command);
1080
+ if (command.action === 'message-source')
1081
+ return this.messageSource(command);
1082
+ if (command.action === 'overview-source')
1083
+ return this.overviewSource(command);
1084
+ if (command.action === 'overview')
1085
+ return this.overview(command);
1086
+ if (command.action === 'model-settings' || command.action === 'save-model-settings')
1087
+ return this.modelSettings(command);
320
1088
  if (command.action === 'inspect-run' || command.action === 'continue-run') {
321
1089
  if (!command.repoId)
322
1090
  throw new Error('Select a repository.');
@@ -333,7 +1101,7 @@ export class WorkspaceRegistry {
333
1101
  const { action, repoId } = command;
334
1102
  let workerId = command.workerId;
335
1103
  if (action === 'list')
336
- return { workers: this.list(repoId) };
1104
+ return this.snapshot(repoId);
337
1105
  if (action === 'settings' || action === 'save-settings') {
338
1106
  if (!repoId)
339
1107
  throw new Error('Select a repository.');
@@ -349,6 +1117,24 @@ export class WorkspaceRegistry {
349
1117
  if (!repoId || !workerId)
350
1118
  throw new Error('Select a repository and worker.');
351
1119
  this.repo(repoId);
1120
+ if (action === 'rename') {
1121
+ const worker = this.store.get('workers', workerId);
1122
+ if (!worker || worker.repoId !== repoId || worker.state === 'archived')
1123
+ throw new Error('This worktree is unavailable.');
1124
+ const title = command.title?.trim();
1125
+ if (!title || title.length > 200 || /[\r\n\t]/.test(title))
1126
+ throw new Error('Enter a name of 1–200 characters on one line.');
1127
+ this.save({ ...worker, title, titleSource: 'custom', titleRequestId: undefined, titleRevision: randomUUID() });
1128
+ return this.snapshot(repoId);
1129
+ }
1130
+ if (action === 'refresh-title') {
1131
+ await this.refreshTitle(repoId, workerId);
1132
+ return this.snapshot(repoId);
1133
+ }
1134
+ if (['create', 'import', 'restore', 'setup'].includes(action) && this.store.get('deleted-workers', workerId))
1135
+ throw new Error('This worktree was deleted. Create a new worktree to continue.');
1136
+ if (['create', 'import', 'restore', 'archive', 'delete', 'setup'].includes(action) && (this.pending(workerId) || this.archiving.has(workerId)))
1137
+ throw new Error('A worktree archive or deletion is already pending. Wait for its result.');
352
1138
  if (action === 'create')
353
1139
  await this.create(repoId, workerId, command.title, command.brief);
354
1140
  else if (action === 'import') {
@@ -378,8 +1164,9 @@ export class WorkspaceRegistry {
378
1164
  const frames = page.flatMap((r) => r.state.frames);
379
1165
  const resume = [...frames].reverse().find((f) => typeof f.sessionId === 'string')?.sessionId;
380
1166
  return { workers: [{ ...this.public(worker), ...(typeof resume === 'string' ? { resume } : {}) }],
1167
+ continuationProvider: worker.importContext?.provider,
381
1168
  legacyMessages: command.before ? [] : worker.legacyMessages,
382
- runs: this.historyRuns(page),
1169
+ runs: this.historyRuns(this.includeActive(page, worker.conversationId, command.before)),
383
1170
  ...(page.length === 10 ? { nextBefore: page[0].request.id } : {}) };
384
1171
  }
385
1172
  if (action === 'archive') {
@@ -408,14 +1195,17 @@ export class WorkspaceRegistry {
408
1195
  this.checkRecoveryWorkspace(request);
409
1196
  return request;
410
1197
  }
1198
+ recoveryContext(requestId) {
1199
+ return this.store.get('run-reviews', requestId);
1200
+ }
411
1201
  checkRecoveryWorkspace(request) {
412
1202
  if (!request.recoveryOf)
413
1203
  return;
414
1204
  const review = this.store.get('run-reviews', request.recoveryOf);
415
1205
  const worker = request.workerId ? this.store.get('workers', request.workerId) : undefined;
416
1206
  const path = !request.workerId && request.mode === 'in-place' ? this.repo(request.repoId).root :
417
- sessionWorktreePath(request.repoId, this.baseDir, worker?.sessionCheckout ? undefined : request.workerId);
418
- if (!review?.workspace || !existsSync(review.workspace) || !existsSync(path) || realpathSync(path) !== realpathSync(review.workspace))
1207
+ worker?.externalDesktop ? worker.path : sessionWorktreePath(request.repoId, this.baseDir, worker?.sessionCheckout ? undefined : request.workerId);
1208
+ if (!review?.workspace || !path || !existsSync(review.workspace) || !existsSync(path) || realpathSync(path) !== realpathSync(review.workspace))
419
1209
  throw new Error('The configured workspace changed since this turn. Restore the reviewed workspace before continuing.');
420
1210
  }
421
1211
  }