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