@opencorelabs/lucidity 0.9.5 → 0.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (787) hide show
  1. package/README.md +46 -5
  2. package/bin/lucidity.js +9 -1
  3. package/dist/agentControls.d.ts +3 -3
  4. package/dist/agentControls.d.ts.map +1 -1
  5. package/dist/agentControls.js +9 -6
  6. package/dist/assets/speech/lucidity-speech +0 -0
  7. package/dist/automations/agent.d.ts.map +1 -1
  8. package/dist/automations/agent.js +8 -3
  9. package/dist/automations/githubIssues.d.ts +25 -0
  10. package/dist/automations/githubIssues.d.ts.map +1 -0
  11. package/dist/automations/githubIssues.js +48 -0
  12. package/dist/automations/service.d.ts +4 -0
  13. package/dist/automations/service.d.ts.map +1 -1
  14. package/dist/automations/service.js +24 -3
  15. package/dist/automations/skill.d.ts +1 -1
  16. package/dist/automations/skill.d.ts.map +1 -1
  17. package/dist/automations/skill.js +3 -25
  18. package/dist/automations/workflowCrash.integration.d.ts +2 -0
  19. package/dist/automations/workflowCrash.integration.d.ts.map +1 -0
  20. package/dist/automations/workflowCrash.integration.js +78 -0
  21. package/dist/chat/server.d.ts +18 -0
  22. package/dist/chat/server.d.ts.map +1 -1
  23. package/dist/chat/server.js +203 -84
  24. package/dist/coding/agentMessages.d.ts +37 -0
  25. package/dist/coding/agentMessages.d.ts.map +1 -0
  26. package/dist/coding/agentMessages.js +220 -0
  27. package/dist/coding/agentSettings.d.ts +9 -0
  28. package/dist/coding/agentSettings.d.ts.map +1 -0
  29. package/dist/coding/agentSettings.js +22 -0
  30. package/dist/coding/fileContext.d.ts +4 -0
  31. package/dist/coding/fileContext.d.ts.map +1 -0
  32. package/dist/coding/fileContext.js +61 -0
  33. package/dist/coding/listPrs.d.ts +4 -0
  34. package/dist/coding/listPrs.d.ts.map +1 -1
  35. package/dist/coding/listPrs.js +1 -1
  36. package/dist/coding/lucidRouting.d.ts +67 -0
  37. package/dist/coding/lucidRouting.d.ts.map +1 -0
  38. package/dist/coding/lucidRouting.js +216 -0
  39. package/dist/coding/overviewSources.d.ts +52 -0
  40. package/dist/coding/overviewSources.d.ts.map +1 -0
  41. package/dist/coding/overviewSources.js +78 -0
  42. package/dist/coding/progress.d.ts +27 -0
  43. package/dist/coding/progress.d.ts.map +1 -0
  44. package/dist/coding/progress.js +152 -0
  45. package/dist/coding/repositoryRequests.d.ts +38 -0
  46. package/dist/coding/repositoryRequests.d.ts.map +1 -0
  47. package/dist/coding/repositoryRequests.js +137 -0
  48. package/dist/coding/runCodeTurn.d.ts +25 -8
  49. package/dist/coding/runCodeTurn.d.ts.map +1 -1
  50. package/dist/coding/runCodeTurn.js +93 -77
  51. package/dist/coding/workspaceOverview.d.ts +106 -0
  52. package/dist/coding/workspaceOverview.d.ts.map +1 -0
  53. package/dist/coding/workspaceOverview.js +96 -0
  54. package/dist/coding/workspaceRegistry.d.ts +230 -4
  55. package/dist/coding/workspaceRegistry.d.ts.map +1 -1
  56. package/dist/coding/workspaceRegistry.js +827 -37
  57. package/dist/coding/workspaceTitle.d.ts +14 -0
  58. package/dist/coding/workspaceTitle.d.ts.map +1 -0
  59. package/dist/coding/workspaceTitle.js +8 -0
  60. package/dist/coding/worktree.d.ts +1 -1
  61. package/dist/coding/worktree.d.ts.map +1 -1
  62. package/dist/coding/worktree.js +3 -2
  63. package/dist/coding/worktreeSetup.d.ts +1 -1
  64. package/dist/coding/worktreeSetup.d.ts.map +1 -1
  65. package/dist/coding/worktreeSetup.js +43 -10
  66. package/dist/config.d.ts +5 -0
  67. package/dist/config.d.ts.map +1 -1
  68. package/dist/config.js +38 -3
  69. package/dist/editor/existingWorkspace.d.ts +3 -0
  70. package/dist/editor/existingWorkspace.d.ts.map +1 -0
  71. package/dist/editor/existingWorkspace.js +19 -0
  72. package/dist/editor/fileActions.d.ts +26 -0
  73. package/dist/editor/fileActions.d.ts.map +1 -0
  74. package/dist/editor/fileActions.js +134 -0
  75. package/dist/editor/files.d.ts +27 -0
  76. package/dist/editor/files.d.ts.map +1 -0
  77. package/dist/editor/files.js +279 -0
  78. package/dist/editor/gitActions.d.ts +18 -0
  79. package/dist/editor/gitActions.d.ts.map +1 -0
  80. package/dist/editor/gitActions.js +140 -0
  81. package/dist/editor/localEndpoint.d.ts +4 -0
  82. package/dist/editor/localEndpoint.d.ts.map +1 -0
  83. package/dist/editor/localEndpoint.js +35 -0
  84. package/dist/editor/service.d.ts +28 -0
  85. package/dist/editor/service.d.ts.map +1 -0
  86. package/dist/editor/service.js +101 -0
  87. package/dist/editor/shellCommands.d.ts +21 -0
  88. package/dist/editor/shellCommands.d.ts.map +1 -0
  89. package/dist/editor/shellCommands.js +165 -0
  90. package/dist/editor/terminals.d.ts +34 -0
  91. package/dist/editor/terminals.d.ts.map +1 -0
  92. package/dist/editor/terminals.js +161 -0
  93. package/dist/editor/types.d.ts +37 -0
  94. package/dist/editor/types.d.ts.map +1 -0
  95. package/dist/editor/types.js +1 -0
  96. package/dist/files/store.d.ts +13 -0
  97. package/dist/files/store.d.ts.map +1 -0
  98. package/dist/files/store.js +150 -0
  99. package/dist/goals/assessment.d.ts +6 -6
  100. package/dist/index.js +232 -56
  101. package/dist/install.d.ts +7 -0
  102. package/dist/install.d.ts.map +1 -1
  103. package/dist/install.js +5 -2
  104. package/dist/jobs/briefing.d.ts +1 -1
  105. package/dist/jobs/briefing.d.ts.map +1 -1
  106. package/dist/jobs/briefing.js +16 -33
  107. package/dist/jobs/extraction.d.ts +2 -1
  108. package/dist/jobs/extraction.d.ts.map +1 -1
  109. package/dist/jobs/extraction.js +2 -2
  110. package/dist/jobs/fastModeReview.d.ts +3 -1
  111. package/dist/jobs/fastModeReview.d.ts.map +1 -1
  112. package/dist/jobs/fastModeReview.js +20 -11
  113. package/dist/jobs/voiceReview.js +4 -4
  114. package/dist/jobs/weeklyReview.d.ts +1 -1
  115. package/dist/jobs/weeklyReview.d.ts.map +1 -1
  116. package/dist/jobs/weeklyReview.js +2 -5
  117. package/dist/lucidInvocations.d.ts +44 -0
  118. package/dist/lucidInvocations.d.ts.map +1 -0
  119. package/dist/lucidInvocations.js +164 -0
  120. package/dist/mcp/config.d.ts +8 -2
  121. package/dist/mcp/config.d.ts.map +1 -1
  122. package/dist/mcp/config.js +52 -10
  123. package/dist/mcp/paired.js +1 -0
  124. package/dist/providerFallbackContext.d.ts +5 -0
  125. package/dist/providerFallbackContext.d.ts.map +1 -0
  126. package/dist/providerFallbackContext.js +58 -0
  127. package/dist/providerRecovery.d.ts +18 -1
  128. package/dist/providerRecovery.d.ts.map +1 -1
  129. package/dist/providerRecovery.js +3 -1
  130. package/dist/providerRoles.d.ts +9 -0
  131. package/dist/providerRoles.d.ts.map +1 -0
  132. package/dist/providerRoles.js +25 -0
  133. package/dist/recall/command.d.ts +139 -0
  134. package/dist/recall/command.d.ts.map +1 -0
  135. package/dist/recall/command.js +35 -0
  136. package/dist/recall/context.d.ts +5 -0
  137. package/dist/recall/context.d.ts.map +1 -0
  138. package/dist/recall/context.js +66 -0
  139. package/dist/recall/conversations.d.ts +182 -0
  140. package/dist/recall/conversations.d.ts.map +1 -0
  141. package/dist/recall/conversations.js +58 -0
  142. package/dist/recall/documents.d.ts +76 -0
  143. package/dist/recall/documents.d.ts.map +1 -0
  144. package/dist/recall/documents.js +32 -0
  145. package/dist/recall/evaluation.d.ts +77 -0
  146. package/dist/recall/evaluation.d.ts.map +1 -0
  147. package/dist/recall/evaluation.js +88 -0
  148. package/dist/recall/factory.d.ts +6 -0
  149. package/dist/recall/factory.d.ts.map +1 -0
  150. package/dist/recall/factory.js +20 -0
  151. package/dist/recall/index.d.ts +13 -0
  152. package/dist/recall/index.d.ts.map +1 -0
  153. package/dist/recall/index.js +92 -0
  154. package/dist/recall/memories.d.ts +16 -0
  155. package/dist/recall/memories.d.ts.map +1 -0
  156. package/dist/recall/memories.js +136 -0
  157. package/dist/recall/memorySelection.d.ts +4 -0
  158. package/dist/recall/memorySelection.d.ts.map +1 -0
  159. package/dist/recall/memorySelection.js +16 -0
  160. package/dist/recall/memoryService.d.ts +22 -0
  161. package/dist/recall/memoryService.d.ts.map +1 -0
  162. package/dist/recall/memoryService.js +171 -0
  163. package/dist/recall/personal.d.ts +127 -0
  164. package/dist/recall/personal.d.ts.map +1 -0
  165. package/dist/recall/personal.js +125 -0
  166. package/dist/recall/projects.d.ts +67 -0
  167. package/dist/recall/projects.d.ts.map +1 -0
  168. package/dist/recall/projects.js +117 -0
  169. package/dist/recall/query.d.ts +5 -0
  170. package/dist/recall/query.d.ts.map +1 -0
  171. package/dist/recall/query.js +17 -0
  172. package/dist/recall/semanticEvaluation.d.ts +2 -0
  173. package/dist/recall/semanticEvaluation.d.ts.map +1 -0
  174. package/dist/recall/semanticEvaluation.js +123 -0
  175. package/dist/recall/service.d.ts +62 -0
  176. package/dist/recall/service.d.ts.map +1 -0
  177. package/dist/recall/service.js +94 -0
  178. package/dist/room/client.d.ts +41 -0
  179. package/dist/room/client.d.ts.map +1 -1
  180. package/dist/room/client.js +224 -25
  181. package/dist/room/codingActivity.d.ts +21 -0
  182. package/dist/room/codingActivity.d.ts.map +1 -0
  183. package/dist/room/codingActivity.js +86 -0
  184. package/dist/room/computer.d.ts.map +1 -1
  185. package/dist/room/computer.js +19 -3
  186. package/dist/room/context.d.ts +3 -2
  187. package/dist/room/context.d.ts.map +1 -1
  188. package/dist/room/context.js +5 -4
  189. package/dist/room/desktop-live.integration.d.ts +2 -0
  190. package/dist/room/desktop-live.integration.d.ts.map +1 -0
  191. package/dist/room/desktop-live.integration.js +219 -0
  192. package/dist/room/turnQueue.d.ts +24 -2
  193. package/dist/room/turnQueue.d.ts.map +1 -1
  194. package/dist/room/turnQueue.js +96 -30
  195. package/dist/runtimeStore.d.ts +17 -0
  196. package/dist/runtimeStore.d.ts.map +1 -1
  197. package/dist/runtimeStore.js +33 -4
  198. package/dist/setup/page.d.ts +1 -1
  199. package/dist/setup/page.d.ts.map +1 -1
  200. package/dist/setup/page.js +15 -2
  201. package/dist/setup/server.d.ts +5 -1
  202. package/dist/setup/server.d.ts.map +1 -1
  203. package/dist/setup/server.js +37 -13
  204. package/dist/skills/install.d.ts +8 -0
  205. package/dist/skills/install.d.ts.map +1 -0
  206. package/dist/skills/install.js +82 -0
  207. package/dist/skills/lucidity/SKILL.md +65 -0
  208. package/dist/skills/lucidity-task-handoff/SKILL.md +122 -0
  209. package/dist/speech/captures.d.ts +4 -0
  210. package/dist/speech/captures.d.ts.map +1 -1
  211. package/dist/speech/captures.js +53 -41
  212. package/dist/updateCli.d.ts +2 -0
  213. package/dist/updateCli.d.ts.map +1 -0
  214. package/dist/updateCli.js +40 -0
  215. package/dist/updateService.d.ts +3 -0
  216. package/dist/updateService.d.ts.map +1 -0
  217. package/dist/updateService.js +23 -0
  218. package/dist/updates/admission.d.ts +23 -0
  219. package/dist/updates/admission.d.ts.map +1 -0
  220. package/dist/updates/admission.js +76 -0
  221. package/dist/updates/bootstrap.d.ts +23 -0
  222. package/dist/updates/bootstrap.d.ts.map +1 -0
  223. package/dist/updates/bootstrap.js +95 -0
  224. package/dist/updates/bootstrapConfig.d.ts +34 -0
  225. package/dist/updates/bootstrapConfig.d.ts.map +1 -0
  226. package/dist/updates/bootstrapConfig.js +35 -0
  227. package/dist/updates/connection.d.ts +20 -0
  228. package/dist/updates/connection.d.ts.map +1 -0
  229. package/dist/updates/connection.js +111 -0
  230. package/dist/updates/developmentAdmission.d.ts +29 -0
  231. package/dist/updates/developmentAdmission.d.ts.map +1 -0
  232. package/dist/updates/developmentAdmission.js +73 -0
  233. package/dist/updates/developmentCli.d.ts +2 -0
  234. package/dist/updates/developmentCli.d.ts.map +1 -0
  235. package/dist/updates/developmentCli.js +61 -0
  236. package/dist/updates/developmentRefresh.d.ts +73 -0
  237. package/dist/updates/developmentRefresh.d.ts.map +1 -0
  238. package/dist/updates/developmentRefresh.js +157 -0
  239. package/dist/updates/developmentService.d.ts +13 -0
  240. package/dist/updates/developmentService.d.ts.map +1 -0
  241. package/dist/updates/developmentService.js +217 -0
  242. package/dist/updates/download.d.ts +7 -0
  243. package/dist/updates/download.d.ts.map +1 -0
  244. package/dist/updates/download.js +52 -0
  245. package/dist/updates/feed.d.ts +7 -0
  246. package/dist/updates/feed.d.ts.map +1 -0
  247. package/dist/updates/feed.js +37 -0
  248. package/dist/updates/installService.d.ts +3 -0
  249. package/dist/updates/installService.d.ts.map +1 -0
  250. package/dist/updates/installService.js +78 -0
  251. package/dist/updates/installationReferences.d.ts +17 -0
  252. package/dist/updates/installationReferences.d.ts.map +1 -0
  253. package/dist/updates/installationReferences.js +104 -0
  254. package/dist/updates/installationStore.d.ts +49 -0
  255. package/dist/updates/installationStore.d.ts.map +1 -0
  256. package/dist/updates/installationStore.js +237 -0
  257. package/dist/updates/installer.d.ts +29 -0
  258. package/dist/updates/installer.d.ts.map +1 -0
  259. package/dist/updates/installer.js +205 -0
  260. package/dist/updates/journal.d.ts +228 -0
  261. package/dist/updates/journal.d.ts.map +1 -0
  262. package/dist/updates/journal.js +249 -0
  263. package/dist/updates/managedLifecycle.d.ts +26 -0
  264. package/dist/updates/managedLifecycle.d.ts.map +1 -0
  265. package/dist/updates/managedLifecycle.js +60 -0
  266. package/dist/updates/migrateService.d.ts +2 -0
  267. package/dist/updates/migrateService.d.ts.map +1 -0
  268. package/dist/updates/migrateService.js +44 -0
  269. package/dist/updates/migration.d.ts +15 -0
  270. package/dist/updates/migration.d.ts.map +1 -0
  271. package/dist/updates/migration.js +108 -0
  272. package/dist/updates/processControl.d.ts +47 -0
  273. package/dist/updates/processControl.d.ts.map +1 -0
  274. package/dist/updates/processControl.js +98 -0
  275. package/dist/updates/processHost.d.ts +52 -0
  276. package/dist/updates/processHost.d.ts.map +1 -0
  277. package/dist/updates/processHost.js +165 -0
  278. package/dist/updates/registerService.d.ts +4 -0
  279. package/dist/updates/registerService.d.ts.map +1 -0
  280. package/dist/updates/registerService.js +34 -0
  281. package/dist/updates/releases.d.ts +84 -0
  282. package/dist/updates/releases.d.ts.map +1 -0
  283. package/dist/updates/releases.js +51 -0
  284. package/dist/updates/retention.d.ts +32 -0
  285. package/dist/updates/retention.d.ts.map +1 -0
  286. package/dist/updates/retention.js +188 -0
  287. package/dist/updates/runner.d.ts +6 -0
  288. package/dist/updates/runner.d.ts.map +1 -0
  289. package/dist/updates/runner.js +117 -0
  290. package/dist/updates/service.d.ts +53 -0
  291. package/dist/updates/service.d.ts.map +1 -0
  292. package/dist/updates/service.js +268 -0
  293. package/dist/updates/servicePlan.d.ts +29 -0
  294. package/dist/updates/servicePlan.d.ts.map +1 -0
  295. package/dist/updates/servicePlan.js +58 -0
  296. package/dist/updates/signCatalog.d.ts +10 -0
  297. package/dist/updates/signCatalog.d.ts.map +1 -0
  298. package/dist/updates/signCatalog.js +44 -0
  299. package/dist/updates/supervisor.d.ts +27 -0
  300. package/dist/updates/supervisor.d.ts.map +1 -0
  301. package/dist/updates/supervisor.js +137 -0
  302. package/dist/updates/windowsService.d.ts +12 -0
  303. package/dist/updates/windowsService.d.ts.map +1 -0
  304. package/dist/updates/windowsService.js +51 -0
  305. package/dist/video/context.d.ts +4 -0
  306. package/dist/video/context.d.ts.map +1 -0
  307. package/dist/video/context.js +74 -0
  308. package/dist/video/store.d.ts +22 -0
  309. package/dist/video/store.d.ts.map +1 -0
  310. package/dist/video/store.js +184 -0
  311. package/npm-shrinkwrap.json +1792 -0
  312. package/package.json +4 -1
  313. package/src/agentControls.ts +11 -7
  314. package/src/automations/agent.ts +11 -2
  315. package/src/automations/githubIssues.ts +63 -0
  316. package/src/automations/service.ts +25 -3
  317. package/src/automations/skill.ts +5 -37
  318. package/src/automations/workflowCrash.integration.ts +70 -0
  319. package/src/chat/server.ts +162 -89
  320. package/src/coding/agentMessages.ts +217 -0
  321. package/src/coding/agentSettings.ts +22 -0
  322. package/src/coding/fileContext.ts +72 -0
  323. package/src/coding/listPrs.ts +1 -1
  324. package/src/coding/lucidRouting.ts +211 -0
  325. package/src/coding/overviewSources.ts +86 -0
  326. package/src/coding/progress.ts +146 -0
  327. package/src/coding/repositoryRequests.ts +117 -0
  328. package/src/coding/runCodeTurn.ts +106 -92
  329. package/src/coding/workspaceOverview.ts +99 -0
  330. package/src/coding/workspaceRegistry.ts +762 -39
  331. package/src/coding/workspaceTitle.ts +10 -0
  332. package/src/coding/worktree.ts +3 -2
  333. package/src/coding/worktreeSetup.ts +33 -10
  334. package/src/config.ts +37 -2
  335. package/src/editor/existingWorkspace.ts +17 -0
  336. package/src/editor/fileActions.ts +162 -0
  337. package/src/editor/files.ts +276 -0
  338. package/src/editor/gitActions.ts +150 -0
  339. package/src/editor/localEndpoint.ts +28 -0
  340. package/src/editor/service.ts +93 -0
  341. package/src/editor/shellCommands.ts +132 -0
  342. package/src/editor/terminals.ts +129 -0
  343. package/src/editor/types.ts +32 -0
  344. package/src/files/store.ts +131 -0
  345. package/src/index.ts +224 -50
  346. package/src/install.ts +4 -2
  347. package/src/jobs/briefing.ts +18 -29
  348. package/src/jobs/extraction.ts +5 -4
  349. package/src/jobs/fastModeReview.ts +22 -11
  350. package/src/jobs/voiceReview.ts +4 -4
  351. package/src/jobs/weeklyReview.ts +2 -4
  352. package/src/lucidInvocations.ts +152 -0
  353. package/src/mcp/config.ts +48 -10
  354. package/src/mcp/paired.ts +1 -0
  355. package/src/providerFallbackContext.ts +48 -0
  356. package/src/providerRecovery.ts +3 -1
  357. package/src/providerRoles.ts +35 -0
  358. package/src/recall/command.ts +42 -0
  359. package/src/recall/context.ts +64 -0
  360. package/src/recall/conversations.ts +53 -0
  361. package/src/recall/documents.ts +32 -0
  362. package/src/recall/evaluation.ts +89 -0
  363. package/src/recall/factory.ts +21 -0
  364. package/src/recall/index.ts +87 -0
  365. package/src/recall/memories.ts +123 -0
  366. package/src/recall/memorySelection.ts +17 -0
  367. package/src/recall/memoryService.ts +138 -0
  368. package/src/recall/personal.ts +97 -0
  369. package/src/recall/projects.ts +98 -0
  370. package/src/recall/query.ts +21 -0
  371. package/src/recall/semanticEvaluation.ts +101 -0
  372. package/src/recall/service.ts +85 -0
  373. package/src/room/client.ts +238 -31
  374. package/src/room/codingActivity.ts +70 -0
  375. package/src/room/computer.ts +19 -3
  376. package/src/room/context.ts +7 -2
  377. package/src/room/desktop-live.integration.ts +203 -0
  378. package/src/room/turnQueue.ts +91 -34
  379. package/src/runtimeStore.ts +36 -4
  380. package/src/setup/page.ts +15 -2
  381. package/src/setup/server.ts +28 -5
  382. package/src/skills/install.ts +65 -0
  383. package/src/speech/captures.ts +56 -44
  384. package/src/updateCli.ts +37 -0
  385. package/src/updateService.ts +21 -0
  386. package/src/updates/admission.ts +70 -0
  387. package/src/updates/bootstrap.ts +77 -0
  388. package/src/updates/bootstrapConfig.ts +29 -0
  389. package/src/updates/connection.ts +84 -0
  390. package/src/updates/developmentAdmission.ts +56 -0
  391. package/src/updates/developmentCli.ts +47 -0
  392. package/src/updates/developmentRefresh.ts +130 -0
  393. package/src/updates/developmentService.ts +170 -0
  394. package/src/updates/download.ts +53 -0
  395. package/src/updates/feed.ts +34 -0
  396. package/src/updates/installService.ts +67 -0
  397. package/src/updates/installationReferences.ts +87 -0
  398. package/src/updates/installationStore.ts +196 -0
  399. package/src/updates/installer.ts +203 -0
  400. package/src/updates/journal.ts +250 -0
  401. package/src/updates/managedLifecycle.ts +64 -0
  402. package/src/updates/migrateService.ts +33 -0
  403. package/src/updates/migration.ts +92 -0
  404. package/src/updates/processControl.ts +96 -0
  405. package/src/updates/processHost.ts +159 -0
  406. package/src/updates/registerService.ts +27 -0
  407. package/src/updates/releases.ts +53 -0
  408. package/src/updates/retention.ts +154 -0
  409. package/src/updates/runner.ts +104 -0
  410. package/src/updates/service.ts +241 -0
  411. package/src/updates/servicePlan.ts +63 -0
  412. package/src/updates/signCatalog.ts +40 -0
  413. package/src/updates/supervisor.ts +114 -0
  414. package/src/updates/windowsService.ts +54 -0
  415. package/src/video/context.ts +101 -0
  416. package/src/video/store.ts +250 -0
  417. package/vendor/decisions/dist/followup.d.ts +14 -0
  418. package/vendor/decisions/dist/followup.js +86 -0
  419. package/vendor/decisions/dist/index.d.ts +3 -0
  420. package/vendor/decisions/dist/index.js +3 -0
  421. package/vendor/decisions/dist/repositoryReplay.d.ts +103 -0
  422. package/vendor/decisions/dist/repositoryReplay.js +177 -0
  423. package/vendor/decisions/dist/repositoryRouting.d.ts +21 -0
  424. package/vendor/decisions/dist/repositoryRouting.js +125 -0
  425. package/vendor/decisions/src/followup.ts +129 -0
  426. package/vendor/decisions/src/index.ts +3 -0
  427. package/vendor/decisions/src/repositoryReplay.ts +312 -0
  428. package/vendor/decisions/src/repositoryRouting.ts +167 -0
  429. package/vendor/mcp-server/README.md +6 -0
  430. package/vendor/mcp-server/dist/index.js +21 -7
  431. package/vendor/mcp-server/dist/localDaemon.d.ts +4 -0
  432. package/vendor/mcp-server/dist/localDaemon.d.ts.map +1 -0
  433. package/vendor/mcp-server/dist/localDaemon.js +41 -0
  434. package/vendor/mcp-server/dist/tools/agents.d.ts +3 -0
  435. package/vendor/mcp-server/dist/tools/agents.d.ts.map +1 -0
  436. package/vendor/mcp-server/dist/tools/agents.js +60 -0
  437. package/vendor/mcp-server/dist/tools/artifacts.d.ts +3 -0
  438. package/vendor/mcp-server/dist/tools/artifacts.d.ts.map +1 -0
  439. package/vendor/mcp-server/dist/tools/artifacts.js +22 -0
  440. package/vendor/mcp-server/dist/tools/automations.d.ts.map +1 -1
  441. package/vendor/mcp-server/dist/tools/automations.js +7 -32
  442. package/vendor/mcp-server/dist/tools/commandEventFormat.d.ts +1 -1
  443. package/vendor/mcp-server/dist/tools/commandEventFormat.js +2 -2
  444. package/vendor/mcp-server/dist/tools/commandEvents.js +1 -1
  445. package/vendor/mcp-server/dist/tools/comments.d.ts.map +1 -1
  446. package/vendor/mcp-server/dist/tools/comments.js +5 -1
  447. package/vendor/mcp-server/dist/tools/journal.d.ts.map +1 -1
  448. package/vendor/mcp-server/dist/tools/journal.js +1 -0
  449. package/vendor/mcp-server/dist/tools/memory.d.ts +0 -10
  450. package/vendor/mcp-server/dist/tools/memory.d.ts.map +1 -1
  451. package/vendor/mcp-server/dist/tools/memory.js +28 -102
  452. package/vendor/mcp-server/dist/tools/notes.d.ts.map +1 -1
  453. package/vendor/mcp-server/dist/tools/notes.js +38 -4
  454. package/vendor/mcp-server/dist/tools/recall.d.ts +6 -0
  455. package/vendor/mcp-server/dist/tools/recall.d.ts.map +1 -0
  456. package/vendor/mcp-server/dist/tools/recall.js +78 -0
  457. package/vendor/mcp-server/dist/tools/summary.d.ts +3 -0
  458. package/vendor/mcp-server/dist/tools/summary.d.ts.map +1 -0
  459. package/vendor/mcp-server/dist/tools/summary.js +22 -0
  460. package/vendor/mcp-server/dist/tools/taskSheet.d.ts +3 -0
  461. package/vendor/mcp-server/dist/tools/taskSheet.d.ts.map +1 -0
  462. package/vendor/mcp-server/dist/tools/taskSheet.js +32 -0
  463. package/vendor/mcp-server/dist/tools/tasks.d.ts.map +1 -1
  464. package/vendor/mcp-server/dist/tools/tasks.js +117 -24
  465. package/vendor/mcp-server/dist/tools/worktrees.d.ts +3 -0
  466. package/vendor/mcp-server/dist/tools/worktrees.d.ts.map +1 -0
  467. package/vendor/mcp-server/dist/tools/worktrees.js +51 -0
  468. package/vendor/mcp-server/package.json +1 -1
  469. package/vendor/mcp-server/src/index.ts +17 -7
  470. package/vendor/mcp-server/src/localDaemon.ts +56 -0
  471. package/vendor/mcp-server/src/tools/agents.ts +78 -0
  472. package/vendor/mcp-server/src/tools/artifacts.ts +26 -0
  473. package/vendor/mcp-server/src/tools/automations.ts +7 -47
  474. package/vendor/mcp-server/src/tools/commandEventFormat.ts +2 -2
  475. package/vendor/mcp-server/src/tools/commandEvents.ts +1 -1
  476. package/vendor/mcp-server/src/tools/comments.ts +4 -1
  477. package/vendor/mcp-server/src/tools/journal.ts +1 -0
  478. package/vendor/mcp-server/src/tools/memory.ts +37 -130
  479. package/vendor/mcp-server/src/tools/notes.ts +35 -5
  480. package/vendor/mcp-server/src/tools/recall.ts +89 -0
  481. package/vendor/mcp-server/src/tools/summary.ts +30 -0
  482. package/vendor/mcp-server/src/tools/taskSheet.ts +60 -0
  483. package/vendor/mcp-server/src/tools/tasks.ts +125 -24
  484. package/vendor/mcp-server/src/tools/worktrees.ts +61 -0
  485. package/vendor/notes/dist/artifacts.d.ts +8 -0
  486. package/vendor/notes/dist/artifacts.d.ts.map +1 -0
  487. package/vendor/notes/dist/artifacts.js +105 -0
  488. package/vendor/notes/dist/index.d.ts +1 -0
  489. package/vendor/notes/dist/index.d.ts.map +1 -1
  490. package/vendor/notes/dist/index.js +1 -0
  491. package/vendor/notes/dist/vault.d.ts.map +1 -1
  492. package/vendor/notes/dist/vault.js +2 -0
  493. package/vendor/notes/src/artifacts.ts +100 -0
  494. package/vendor/notes/src/index.ts +2 -0
  495. package/vendor/notes/src/vault.ts +1 -0
  496. package/vendor/runtime/README.md +8 -0
  497. package/vendor/runtime/dist/executor/claudeAgent.d.ts +18 -1
  498. package/vendor/runtime/dist/executor/claudeAgent.d.ts.map +1 -1
  499. package/vendor/runtime/dist/executor/claudeAgent.js +157 -39
  500. package/vendor/runtime/dist/executor/claudeCode.d.ts.map +1 -1
  501. package/vendor/runtime/dist/executor/claudeCode.js +19 -2
  502. package/vendor/runtime/dist/executor/claudeSession.d.ts +32 -0
  503. package/vendor/runtime/dist/executor/claudeSession.d.ts.map +1 -0
  504. package/vendor/runtime/dist/executor/claudeSession.js +154 -0
  505. package/vendor/runtime/dist/executor/codex.d.ts +18 -2
  506. package/vendor/runtime/dist/executor/codex.d.ts.map +1 -1
  507. package/vendor/runtime/dist/executor/codex.js +134 -18
  508. package/vendor/runtime/dist/executor/codexSessions.d.ts +5 -10
  509. package/vendor/runtime/dist/executor/codexSessions.d.ts.map +1 -1
  510. package/vendor/runtime/dist/executor/codexSessions.js +12 -78
  511. package/vendor/runtime/dist/executor/fallback.d.ts +27 -0
  512. package/vendor/runtime/dist/executor/fallback.d.ts.map +1 -0
  513. package/vendor/runtime/dist/executor/fallback.js +45 -0
  514. package/vendor/runtime/dist/executor/health.d.ts +19 -1
  515. package/vendor/runtime/dist/executor/health.d.ts.map +1 -1
  516. package/vendor/runtime/dist/executor/health.js +19 -2
  517. package/vendor/runtime/dist/executor/integrations.d.ts +4 -0
  518. package/vendor/runtime/dist/executor/integrations.d.ts.map +1 -0
  519. package/vendor/runtime/dist/executor/integrations.js +5 -0
  520. package/vendor/runtime/dist/executor/liveTurns.d.ts +2 -2
  521. package/vendor/runtime/dist/executor/liveTurns.d.ts.map +1 -1
  522. package/vendor/runtime/dist/executor/liveTurns.js +3 -3
  523. package/vendor/runtime/dist/executor/ownership.d.ts +18 -1
  524. package/vendor/runtime/dist/executor/ownership.d.ts.map +1 -1
  525. package/vendor/runtime/dist/executor/ownership.js +3 -1
  526. package/vendor/runtime/dist/executor/providerRouter.d.ts +13 -0
  527. package/vendor/runtime/dist/executor/providerRouter.d.ts.map +1 -1
  528. package/vendor/runtime/dist/executor/providerRouter.js +91 -5
  529. package/vendor/runtime/dist/executor/sessionRetention.d.ts +34 -0
  530. package/vendor/runtime/dist/executor/sessionRetention.d.ts.map +1 -0
  531. package/vendor/runtime/dist/executor/sessionRetention.js +126 -0
  532. package/vendor/runtime/dist/executor/types.d.ts +30 -7
  533. package/vendor/runtime/dist/executor/types.d.ts.map +1 -1
  534. package/vendor/runtime/dist/executor/usage.d.ts +5 -0
  535. package/vendor/runtime/dist/executor/usage.d.ts.map +1 -0
  536. package/vendor/runtime/dist/executor/usage.js +56 -0
  537. package/vendor/runtime/dist/harness/index.d.ts.map +1 -1
  538. package/vendor/runtime/dist/harness/index.js +2 -5
  539. package/vendor/runtime/dist/harness/types.d.ts +3 -1
  540. package/vendor/runtime/dist/harness/types.d.ts.map +1 -1
  541. package/vendor/runtime/dist/index.d.ts +6 -1
  542. package/vendor/runtime/dist/index.d.ts.map +1 -1
  543. package/vendor/runtime/dist/index.js +3 -0
  544. package/vendor/runtime/dist/prompts/recall.d.ts +15 -0
  545. package/vendor/runtime/dist/prompts/recall.d.ts.map +1 -0
  546. package/vendor/runtime/dist/prompts/recall.js +71 -0
  547. package/vendor/runtime/src/executor/claudeAgent.ts +149 -37
  548. package/vendor/runtime/src/executor/claudeCode.ts +17 -3
  549. package/vendor/runtime/src/executor/claudeSession.ts +180 -0
  550. package/vendor/runtime/src/executor/codex.ts +136 -21
  551. package/vendor/runtime/src/executor/codexSessions.ts +18 -82
  552. package/vendor/runtime/src/executor/fallback.ts +63 -0
  553. package/vendor/runtime/src/executor/health.ts +16 -2
  554. package/vendor/runtime/src/executor/integrations.ts +7 -0
  555. package/vendor/runtime/src/executor/liveTurns.ts +5 -5
  556. package/vendor/runtime/src/executor/ownership.ts +3 -1
  557. package/vendor/runtime/src/executor/providerRouter.ts +85 -4
  558. package/vendor/runtime/src/executor/sessionRetention.ts +166 -0
  559. package/vendor/runtime/src/executor/types.ts +27 -7
  560. package/vendor/runtime/src/executor/usage.ts +58 -0
  561. package/vendor/runtime/src/harness/index.ts +2 -5
  562. package/vendor/runtime/src/harness/types.ts +3 -1
  563. package/vendor/runtime/src/index.ts +7 -1
  564. package/vendor/runtime/src/prompts/recall.ts +72 -0
  565. package/vendor/shared/dist/accountDevices.d.ts +62 -0
  566. package/vendor/shared/dist/accountDevices.d.ts.map +1 -0
  567. package/vendor/shared/dist/accountDevices.js +25 -0
  568. package/vendor/shared/dist/activityRecovery.d.ts +37 -0
  569. package/vendor/shared/dist/activityRecovery.d.ts.map +1 -0
  570. package/vendor/shared/dist/activityRecovery.js +39 -0
  571. package/vendor/shared/dist/agentMessages.d.ts +187 -0
  572. package/vendor/shared/dist/agentMessages.d.ts.map +1 -0
  573. package/vendor/shared/dist/agentMessages.js +70 -0
  574. package/vendor/shared/dist/aiUsage.d.ts +30 -0
  575. package/vendor/shared/dist/aiUsage.d.ts.map +1 -0
  576. package/vendor/shared/dist/aiUsage.js +14 -0
  577. package/vendor/shared/dist/artifacts.d.ts +28 -0
  578. package/vendor/shared/dist/artifacts.d.ts.map +1 -0
  579. package/vendor/shared/dist/artifacts.js +47 -0
  580. package/vendor/shared/dist/automationTemplates.d.ts.map +1 -1
  581. package/vendor/shared/dist/automationTemplates.js +1 -0
  582. package/vendor/shared/dist/automations.d.ts +61 -14
  583. package/vendor/shared/dist/automations.d.ts.map +1 -1
  584. package/vendor/shared/dist/automations.js +10 -3
  585. package/vendor/shared/dist/cardStudio.d.ts +31 -31
  586. package/vendor/shared/dist/chatActivity.d.ts +17 -0
  587. package/vendor/shared/dist/chatActivity.d.ts.map +1 -0
  588. package/vendor/shared/dist/chatActivity.js +47 -0
  589. package/vendor/shared/dist/codingActivity.d.ts +60 -0
  590. package/vendor/shared/dist/codingActivity.d.ts.map +1 -0
  591. package/vendor/shared/dist/codingActivity.js +33 -0
  592. package/vendor/shared/dist/commandLocal.d.ts +1 -1
  593. package/vendor/shared/dist/commandLocal.d.ts.map +1 -1
  594. package/vendor/shared/dist/commands.d.ts +32 -32
  595. package/vendor/shared/dist/commands.d.ts.map +1 -1
  596. package/vendor/shared/dist/commands.js +1 -1
  597. package/vendor/shared/dist/commentMentions.d.ts +20 -0
  598. package/vendor/shared/dist/commentMentions.d.ts.map +1 -0
  599. package/vendor/shared/dist/commentMentions.js +14 -0
  600. package/vendor/shared/dist/computer.d.ts +48 -8
  601. package/vendor/shared/dist/computer.d.ts.map +1 -1
  602. package/vendor/shared/dist/computer.js +25 -0
  603. package/vendor/shared/dist/constants.d.ts +1 -1
  604. package/vendor/shared/dist/constants.d.ts.map +1 -1
  605. package/vendor/shared/dist/constants.js +5 -0
  606. package/vendor/shared/dist/daemonUpdates.d.ts +123 -0
  607. package/vendor/shared/dist/daemonUpdates.d.ts.map +1 -0
  608. package/vendor/shared/dist/daemonUpdates.js +106 -0
  609. package/vendor/shared/dist/deviceInteraction.d.ts +23 -0
  610. package/vendor/shared/dist/deviceInteraction.d.ts.map +1 -0
  611. package/vendor/shared/dist/deviceInteraction.js +32 -0
  612. package/vendor/shared/dist/doctor.d.ts +50 -0
  613. package/vendor/shared/dist/doctor.d.ts.map +1 -0
  614. package/vendor/shared/dist/doctor.js +15 -0
  615. package/vendor/shared/dist/fileUploads.d.ts +39 -0
  616. package/vendor/shared/dist/fileUploads.d.ts.map +1 -0
  617. package/vendor/shared/dist/fileUploads.js +24 -0
  618. package/vendor/shared/dist/files.d.ts +11 -0
  619. package/vendor/shared/dist/files.d.ts.map +1 -0
  620. package/vendor/shared/dist/files.js +19 -0
  621. package/vendor/shared/dist/githubContributions.d.ts +1 -1
  622. package/vendor/shared/dist/goals.d.ts +7 -7
  623. package/vendor/shared/dist/index.d.ts +29 -2
  624. package/vendor/shared/dist/index.d.ts.map +1 -1
  625. package/vendor/shared/dist/index.js +26 -1
  626. package/vendor/shared/dist/lucidFollowups.d.ts +95 -0
  627. package/vendor/shared/dist/lucidFollowups.d.ts.map +1 -0
  628. package/vendor/shared/dist/lucidFollowups.js +45 -0
  629. package/vendor/shared/dist/lucidInvocations.d.ts +82 -0
  630. package/vendor/shared/dist/lucidInvocations.d.ts.map +1 -0
  631. package/vendor/shared/dist/lucidInvocations.js +47 -0
  632. package/vendor/shared/dist/memory.d.ts +162 -0
  633. package/vendor/shared/dist/memory.d.ts.map +1 -0
  634. package/vendor/shared/dist/memory.js +26 -0
  635. package/vendor/shared/dist/messagingSafety.d.ts +43 -0
  636. package/vendor/shared/dist/messagingSafety.d.ts.map +1 -1
  637. package/vendor/shared/dist/messagingSafety.js +6 -0
  638. package/vendor/shared/dist/recall.d.ts +803 -0
  639. package/vendor/shared/dist/recall.d.ts.map +1 -0
  640. package/vendor/shared/dist/recall.js +56 -0
  641. package/vendor/shared/dist/releaseCompatibility.d.ts +228 -0
  642. package/vendor/shared/dist/releaseCompatibility.d.ts.map +1 -0
  643. package/vendor/shared/dist/releaseCompatibility.js +145 -0
  644. package/vendor/shared/dist/repositoryRequests.d.ts +173 -0
  645. package/vendor/shared/dist/repositoryRequests.d.ts.map +1 -0
  646. package/vendor/shared/dist/repositoryRequests.js +38 -0
  647. package/vendor/shared/dist/repositoryRouting.d.ts +169 -0
  648. package/vendor/shared/dist/repositoryRouting.d.ts.map +1 -0
  649. package/vendor/shared/dist/repositoryRouting.js +102 -0
  650. package/vendor/shared/dist/roomClient.d.ts +107 -0
  651. package/vendor/shared/dist/roomClient.d.ts.map +1 -0
  652. package/vendor/shared/dist/roomClient.js +371 -0
  653. package/vendor/shared/dist/schemas/comment.d.ts +46 -0
  654. package/vendor/shared/dist/schemas/comment.d.ts.map +1 -1
  655. package/vendor/shared/dist/schemas/comment.js +10 -0
  656. package/vendor/shared/dist/schemas/conversation.d.ts +80 -1
  657. package/vendor/shared/dist/schemas/conversation.d.ts.map +1 -1
  658. package/vendor/shared/dist/schemas/conversation.js +12 -1
  659. package/vendor/shared/dist/schemas/harness.d.ts +1631 -17
  660. package/vendor/shared/dist/schemas/harness.d.ts.map +1 -1
  661. package/vendor/shared/dist/schemas/harness.js +106 -3
  662. package/vendor/shared/dist/schemas/notification.d.ts +3 -1
  663. package/vendor/shared/dist/schemas/notification.d.ts.map +1 -1
  664. package/vendor/shared/dist/schemas/notification.js +2 -1
  665. package/vendor/shared/dist/schemas/organization.d.ts +2 -0
  666. package/vendor/shared/dist/schemas/organization.d.ts.map +1 -1
  667. package/vendor/shared/dist/schemas/organization.js +2 -0
  668. package/vendor/shared/dist/schemas/project.d.ts +2 -2
  669. package/vendor/shared/dist/schemas/request.d.ts +1 -1
  670. package/vendor/shared/dist/schemas/task.d.ts +1 -1
  671. package/vendor/shared/dist/smartCapture.js +1 -1
  672. package/vendor/shared/dist/spokenNames.d.ts +1 -1
  673. package/vendor/shared/dist/spokenNames.js +1 -1
  674. package/vendor/shared/dist/taskActivity.d.ts +5 -5
  675. package/vendor/shared/dist/taskSharing.d.ts +8 -0
  676. package/vendor/shared/dist/taskSharing.d.ts.map +1 -0
  677. package/vendor/shared/dist/taskSharing.js +9 -0
  678. package/vendor/shared/dist/thinking-orb/engine/core.d.ts +31 -0
  679. package/vendor/shared/dist/thinking-orb/engine/core.d.ts.map +1 -0
  680. package/vendor/shared/dist/thinking-orb/engine/core.js +62 -0
  681. package/vendor/shared/dist/thinking-orb/engine/ctx.d.ts +9 -0
  682. package/vendor/shared/dist/thinking-orb/engine/ctx.d.ts.map +1 -0
  683. package/vendor/shared/dist/thinking-orb/engine/ctx.js +1 -0
  684. package/vendor/shared/dist/thinking-orb/engine/lattice.d.ts +5 -0
  685. package/vendor/shared/dist/thinking-orb/engine/lattice.d.ts.map +1 -0
  686. package/vendor/shared/dist/thinking-orb/engine/lattice.js +184 -0
  687. package/vendor/shared/dist/thinking-orb/engine/morph.d.ts +3 -0
  688. package/vendor/shared/dist/thinking-orb/engine/morph.d.ts.map +1 -0
  689. package/vendor/shared/dist/thinking-orb/engine/morph.js +117 -0
  690. package/vendor/shared/dist/thinking-orb/engine/orbits.d.ts +3 -0
  691. package/vendor/shared/dist/thinking-orb/engine/orbits.d.ts.map +1 -0
  692. package/vendor/shared/dist/thinking-orb/engine/orbits.js +66 -0
  693. package/vendor/shared/dist/thinking-orb/engine/profiles.d.ts +8 -0
  694. package/vendor/shared/dist/thinking-orb/engine/profiles.d.ts.map +1 -0
  695. package/vendor/shared/dist/thinking-orb/engine/profiles.js +113 -0
  696. package/vendor/shared/dist/thinking-orb/engine/registry.d.ts +4 -0
  697. package/vendor/shared/dist/thinking-orb/engine/registry.d.ts.map +1 -0
  698. package/vendor/shared/dist/thinking-orb/engine/registry.js +14 -0
  699. package/vendor/shared/dist/thinking-orb/engine/ribbon.d.ts +3 -0
  700. package/vendor/shared/dist/thinking-orb/engine/ribbon.d.ts.map +1 -0
  701. package/vendor/shared/dist/thinking-orb/engine/ribbon.js +64 -0
  702. package/vendor/shared/dist/thinking-orb/engine/types.d.ts +6 -0
  703. package/vendor/shared/dist/thinking-orb/engine/types.d.ts.map +1 -0
  704. package/vendor/shared/dist/thinking-orb/engine/types.js +2 -0
  705. package/vendor/shared/dist/thinking-orb/index.d.ts +7 -0
  706. package/vendor/shared/dist/thinking-orb/index.d.ts.map +1 -0
  707. package/vendor/shared/dist/thinking-orb/index.js +2 -0
  708. package/vendor/shared/dist/thinking-orb/presets.d.ts +12 -0
  709. package/vendor/shared/dist/thinking-orb/presets.d.ts.map +1 -0
  710. package/vendor/shared/dist/thinking-orb/presets.js +67 -0
  711. package/vendor/shared/dist/thinking-orb/types.d.ts +24 -0
  712. package/vendor/shared/dist/thinking-orb/types.d.ts.map +1 -0
  713. package/vendor/shared/dist/thinking-orb/types.js +1 -0
  714. package/vendor/shared/dist/turnTiming.d.ts +13 -0
  715. package/vendor/shared/dist/turnTiming.d.ts.map +1 -0
  716. package/vendor/shared/dist/turnTiming.js +18 -0
  717. package/vendor/shared/dist/types.d.ts +3 -1
  718. package/vendor/shared/dist/types.d.ts.map +1 -1
  719. package/vendor/shared/dist/updateControl.d.ts +168 -0
  720. package/vendor/shared/dist/updateControl.d.ts.map +1 -0
  721. package/vendor/shared/dist/updateControl.js +43 -0
  722. package/vendor/shared/dist/videos.d.ts +31 -0
  723. package/vendor/shared/dist/videos.d.ts.map +1 -0
  724. package/vendor/shared/dist/videos.js +34 -0
  725. package/vendor/shared/dist/workspaceIO.d.ts +188 -0
  726. package/vendor/shared/dist/workspaceIO.d.ts.map +1 -0
  727. package/vendor/shared/dist/workspaceIO.js +50 -0
  728. package/vendor/shared/dist/workspaces.d.ts +740 -2
  729. package/vendor/shared/dist/workspaces.d.ts.map +1 -1
  730. package/vendor/shared/dist/workspaces.js +108 -2
  731. package/vendor/shared/package.json +12 -0
  732. package/vendor/shared/src/accountDevices.ts +28 -0
  733. package/vendor/shared/src/activityRecovery.ts +42 -0
  734. package/vendor/shared/src/agentMessages.ts +82 -0
  735. package/vendor/shared/src/aiUsage.ts +18 -0
  736. package/vendor/shared/src/artifacts.ts +48 -0
  737. package/vendor/shared/src/automationTemplates.ts +1 -0
  738. package/vendor/shared/src/automations.ts +10 -3
  739. package/vendor/shared/src/chatActivity.ts +56 -0
  740. package/vendor/shared/src/codingActivity.ts +40 -0
  741. package/vendor/shared/src/commandLocal.ts +1 -1
  742. package/vendor/shared/src/commands.ts +1 -1
  743. package/vendor/shared/src/commentMentions.ts +20 -0
  744. package/vendor/shared/src/computer.ts +40 -0
  745. package/vendor/shared/src/constants.ts +5 -0
  746. package/vendor/shared/src/daemonUpdates.ts +127 -0
  747. package/vendor/shared/src/deviceInteraction.ts +35 -0
  748. package/vendor/shared/src/doctor.ts +19 -0
  749. package/vendor/shared/src/fileUploads.ts +28 -0
  750. package/vendor/shared/src/files.ts +21 -0
  751. package/vendor/shared/src/index.ts +35 -1
  752. package/vendor/shared/src/lucidFollowups.ts +49 -0
  753. package/vendor/shared/src/lucidInvocations.ts +62 -0
  754. package/vendor/shared/src/memory.ts +30 -0
  755. package/vendor/shared/src/messagingSafety.ts +10 -0
  756. package/vendor/shared/src/recall.ts +69 -0
  757. package/vendor/shared/src/releaseCompatibility.ts +162 -0
  758. package/vendor/shared/src/repositoryRequests.ts +44 -0
  759. package/vendor/shared/src/repositoryRouting.ts +117 -0
  760. package/vendor/shared/src/roomClient.ts +351 -0
  761. package/vendor/shared/src/schemas/comment.ts +10 -0
  762. package/vendor/shared/src/schemas/conversation.ts +12 -1
  763. package/vendor/shared/src/schemas/harness.ts +120 -3
  764. package/vendor/shared/src/schemas/notification.ts +2 -1
  765. package/vendor/shared/src/schemas/organization.ts +2 -0
  766. package/vendor/shared/src/smartCapture.ts +1 -1
  767. package/vendor/shared/src/spokenNames.ts +1 -1
  768. package/vendor/shared/src/taskSharing.ts +13 -0
  769. package/vendor/shared/src/thinking-orb/ATTRIBUTION.md +36 -0
  770. package/vendor/shared/src/thinking-orb/engine/core.ts +81 -0
  771. package/vendor/shared/src/thinking-orb/engine/ctx.ts +15 -0
  772. package/vendor/shared/src/thinking-orb/engine/lattice.ts +205 -0
  773. package/vendor/shared/src/thinking-orb/engine/morph.ts +130 -0
  774. package/vendor/shared/src/thinking-orb/engine/orbits.ts +80 -0
  775. package/vendor/shared/src/thinking-orb/engine/profiles.ts +119 -0
  776. package/vendor/shared/src/thinking-orb/engine/registry.ts +18 -0
  777. package/vendor/shared/src/thinking-orb/engine/ribbon.ts +71 -0
  778. package/vendor/shared/src/thinking-orb/engine/types.ts +15 -0
  779. package/vendor/shared/src/thinking-orb/index.ts +6 -0
  780. package/vendor/shared/src/thinking-orb/presets.ts +88 -0
  781. package/vendor/shared/src/thinking-orb/types.ts +25 -0
  782. package/vendor/shared/src/turnTiming.ts +20 -0
  783. package/vendor/shared/src/types.ts +1 -1
  784. package/vendor/shared/src/updateControl.ts +45 -0
  785. package/vendor/shared/src/videos.ts +37 -0
  786. package/vendor/shared/src/workspaceIO.ts +61 -0
  787. package/vendor/shared/src/workspaces.ts +119 -2
@@ -0,0 +1,250 @@
1
+ // @ts-expect-error Node 22 runtime API; the repository's Node type baseline is 20.
2
+ import { DatabaseSync } from 'node:sqlite';
3
+ import { chmodSync, mkdirSync } from 'node:fs';
4
+ import { join } from 'node:path';
5
+ import { z } from 'zod';
6
+ import {
7
+ DaemonUpdatePolicySchema, DaemonReleaseSchema, DaemonUpdateChannelSchema, DaemonVersionSchema,
8
+ daemonVersionSupported, decideDaemonUpdate, type DaemonInstallation, type DaemonRelease,
9
+ ComputerClientSchema, catalogDaemonSupported, computerClientCompatibility, selectDaemonRelease, assertCatalogEvolution,
10
+ type ComputerClient, type CoordinatedUpdateDecision,
11
+ type ReleaseCatalog, DoctorProgressSchema, type DoctorProgress,
12
+ } from '@lucidity/shared';
13
+ import { DaemonLease } from '../daemonLease.js';
14
+ import { ManifestCheckpointSchema, verifyReleaseManifest } from './releases.js';
15
+
16
+ const InstalledSchema = z.object({ version: DaemonVersionSchema, stateEpoch: z.number().int().nonnegative() }).strict();
17
+ const JournalSchema = z.object({
18
+ schema: z.literal(1),
19
+ channel: DaemonUpdateChannelSchema,
20
+ current: InstalledSchema,
21
+ previous: InstalledSchema.nullable(),
22
+ policy: DaemonUpdatePolicySchema.nullable(),
23
+ clients: z.array(ComputerClientSchema).max(256).default([]),
24
+ checkpoint: ManifestCheckpointSchema.nullable(),
25
+ doctor: z.array(DoctorProgressSchema).max(256).default([]),
26
+ failedVersions: z.array(DaemonVersionSchema),
27
+ lastFailure: z.enum(['startup', 'recovery']).nullable(),
28
+ pending: z.object({
29
+ previous: InstalledSchema,
30
+ release: DaemonReleaseSchema,
31
+ phase: z.enum(['staged', 'activating', 'verifying', 'rolling_back', 'recovering', 'recovery_required']),
32
+ }).strict().nullable(),
33
+ }).strict().refine((value) => (value.policy === null && value.checkpoint === null) ||
34
+ (value.policy?.sequence === value.checkpoint?.sequence && value.policy?.channel === value.channel),
35
+ { message: 'Release policy and checkpoint must agree' });
36
+ export type UpdateJournalState = z.infer<typeof JournalSchema>;
37
+ type InstallationEnvironment = Omit<DaemonInstallation, 'version' | 'stateEpoch' | 'channel' | 'failedVersions'> & { requiredFeatures?: readonly string[] };
38
+
39
+ function latestClients(policy: ReleaseCatalog, clients: ComputerClient[]): ComputerClient[] {
40
+ const latest = new Map<string, ComputerClient>();
41
+ for (const client of clients) {
42
+ const release = policy.clients.find((entry) => entry.id === client.releaseId);
43
+ if (!release) throw new Error('Unknown mobile release; refresh the compatibility catalog');
44
+ const previous = latest.get(client.deviceId);
45
+ const oldRelease = previous && policy.clients.find((entry) => entry.id === previous.releaseId)!;
46
+ if (oldRelease && oldRelease.platform !== release.platform) throw new Error('Device platform cannot change');
47
+ if (!oldRelease || release.generation > oldRelease.generation) latest.set(client.deviceId, client);
48
+ }
49
+ return [...latest.values()];
50
+ }
51
+
52
+ /**
53
+ * Durable transaction journal only. The supervisor must close admissions and await
54
+ * all active work before beginActivation(), and confirm process death before switching.
55
+ * No constructor or journal transition starts, stops or installs a daemon.
56
+ */
57
+ export class UpdateJournal {
58
+ private db: InstanceType<typeof DatabaseSync>;
59
+ private lease: DaemonLease;
60
+ private closed = false;
61
+
62
+ constructor(directory: string, bootstrap: { version: string; stateEpoch: number; channel: DaemonInstallation['channel'] }) {
63
+ mkdirSync(directory, { recursive: true, mode: 0o700 });
64
+ this.lease = new DaemonLease(join(directory, 'owner'));
65
+ const path = join(directory, 'updates.sqlite');
66
+ try {
67
+ this.db = new DatabaseSync(path);
68
+ chmodSync(path, 0o600);
69
+ this.db.exec('PRAGMA journal_mode=WAL; PRAGMA synchronous=FULL; CREATE TABLE IF NOT EXISTS journal (id INTEGER PRIMARY KEY CHECK(id=1), value TEXT NOT NULL);');
70
+ if (!this.db.prepare('SELECT id FROM journal WHERE id=1').get()) {
71
+ this.write({ schema: 1, channel: bootstrap.channel, current: { version: bootstrap.version, stateEpoch: bootstrap.stateEpoch },
72
+ previous: null, policy: null, clients: [], doctor: [], checkpoint: null, failedVersions: [], lastFailure: null, pending: null });
73
+ }
74
+ const state = this.read();
75
+ if (state.channel !== bootstrap.channel) throw new Error('Changing the installed update channel requires explicit migration');
76
+ if (state.policy?.schema === 2) {
77
+ const clients = latestClients(state.policy, state.clients);
78
+ if (clients.length !== state.clients.length) this.write({ ...state, clients });
79
+ }
80
+ } catch (error) {
81
+ this.db?.close();
82
+ this.lease.close();
83
+ throw error;
84
+ }
85
+ }
86
+
87
+ read(): UpdateJournalState {
88
+ const row = this.db.prepare('SELECT value FROM journal WHERE id=1').get() as { value: string };
89
+ return JournalSchema.parse(JSON.parse(row.value));
90
+ }
91
+
92
+ private write(state: UpdateJournalState): void {
93
+ const value = JSON.stringify(JournalSchema.parse(state));
94
+ this.db.prepare('INSERT INTO journal(id,value) VALUES(1,?) ON CONFLICT(id) DO UPDATE SET value=excluded.value').run(value);
95
+ }
96
+
97
+ acceptManifest(raw: string, keys: Readonly<Record<string, string>>, now = Date.now()): void {
98
+ const state = this.read();
99
+ const accepted = verifyReleaseManifest(raw, { keys, channel: state.channel, checkpoint: state.checkpoint ?? undefined, now });
100
+ if (state.policy?.schema === 2) {
101
+ if (accepted.manifest.schema !== 2) throw new Error('Cannot downgrade the compatibility catalog');
102
+ assertCatalogEvolution(state.policy, accepted.manifest);
103
+ }
104
+ // One SQLite write commits both the replay protection and the enforced minimum.
105
+ this.write({ ...state, policy: accepted.manifest, checkpoint: accepted.checkpoint });
106
+ }
107
+
108
+ saveDoctor(input: DoctorProgress): void {
109
+ const repair = DoctorProgressSchema.parse(input), state = this.read();
110
+ const old = state.doctor.find(entry => entry.id === repair.id);
111
+ if (old && ['accountId', 'computerId', 'deviceId', 'releaseId', 'capability'].some(key =>
112
+ old[key as keyof DoctorProgress] !== repair[key as keyof DoctorProgress]))
113
+ throw new Error('Repair ID belongs to a different request');
114
+ const doctor = state.doctor.filter(entry => entry.id !== repair.id);
115
+ if (doctor.length >= 256) throw new Error('Too many saved repair requests');
116
+ this.write({ ...state, doctor: [...doctor, repair] });
117
+ }
118
+
119
+ /** Reports must come from the authenticated account's device, never a caller-selected account. */
120
+ recordClient(report: ComputerClient): boolean {
121
+ const device = ComputerClientSchema.parse(report);
122
+ const state = this.read();
123
+ const policy = state.policy;
124
+ if (policy?.schema !== 2 || !policy.clients.some((client) => client.id === device.releaseId))
125
+ throw new Error('Unknown mobile release; refresh the compatibility catalog');
126
+ const clients = latestClients(policy, [...state.clients, device]);
127
+ if (JSON.stringify(clients) === JSON.stringify(state.clients)) return false;
128
+ // One latest generation per installation. Other sleeping devices still constrain selection.
129
+ this.write({ ...state, clients });
130
+ return true;
131
+ }
132
+
133
+ /** Explicit device removal only. Disconnect, sleep and socket takeover must not call this. */
134
+ forgetClient(deviceId: string): void {
135
+ const state = this.read();
136
+ this.write({ ...state, clients: state.clients.filter((device) => device.deviceId !== deviceId) });
137
+ }
138
+
139
+ decision(environment: InstallationEnvironment, now = Date.now()): CoordinatedUpdateDecision {
140
+ const state = this.read();
141
+ if (!Number.isFinite(now) || !state.policy || Date.parse(state.policy.expiresAt) <= now) throw new Error('A fresh verified release policy is required');
142
+ const installed = { ...environment, ...state.current, channel: state.channel, failedVersions: state.failedVersions };
143
+ if (state.policy.schema === 2) return selectDaemonRelease(state.policy, installed, state.clients, environment.requiredFeatures);
144
+ const decision = decideDaemonUpdate(state.policy, installed);
145
+ return { ...decision, devices: [], target: decision.action === 'stage' ? state.policy.release : null };
146
+ }
147
+
148
+ /** Expiry or network failure never lifts a previously known mandatory block. */
149
+ allowNewWork(device?: ComputerClient): boolean {
150
+ const state = this.read();
151
+ if (state.pending && state.pending.phase !== 'staged') return false;
152
+ if (state.policy?.schema === 2) {
153
+ if (!catalogDaemonSupported(state.policy, state.current.version)) return false;
154
+ if (device) return state.clients.some((client) => client.deviceId === device.deviceId && client.releaseId === device.releaseId) &&
155
+ computerClientCompatibility(state.policy, state.current.version, [device])[0]?.state === 'ready';
156
+ return true;
157
+ }
158
+ return !state.policy || daemonVersionSupported(state.current.version, state.policy);
159
+ }
160
+
161
+ /** Record only after an isolated installation has been prepared and verified. */
162
+ recordStaged(prepared: DaemonRelease, environment: InstallationEnvironment, now = Date.now()): void {
163
+ const state = this.read();
164
+ if (state.pending) throw new Error('Another update transaction is pending');
165
+ const decision = this.decision(environment, now);
166
+ if (decision.action !== 'stage' || !decision.target) throw new Error('Release is not eligible for installation');
167
+ if (JSON.stringify(DaemonReleaseSchema.parse(prepared)) !== JSON.stringify(decision.target))
168
+ throw new Error('Prepared release differs from current policy');
169
+ this.write({ ...state, pending: { previous: state.current, release: decision.target, phase: 'staged' } });
170
+ }
171
+
172
+ /** The caller has closed admission and drained active work; persist before stopping it. */
173
+ beginActivation(environment: InstallationEnvironment, now = Date.now()): void {
174
+ const state = this.read();
175
+ if (state.pending?.phase !== 'staged') throw new Error('No staged update');
176
+ const decision = this.decision(environment, now);
177
+ if (decision.action !== 'stage' || JSON.stringify(decision.target) !== JSON.stringify(state.pending.release))
178
+ throw new Error('Staged release is no longer eligible');
179
+ this.write({ ...state, pending: { ...state.pending, phase: 'activating' } });
180
+ }
181
+
182
+ /** Call only after the previous process is confirmed stopped; start the candidate paused. */
183
+ selectCandidate(): void {
184
+ const state = this.read();
185
+ if (state.pending?.phase !== 'activating') throw new Error('Activation has not begun');
186
+ this.write({ ...state, current: { version: state.pending.release.version, stateEpoch: state.pending.release.stateEpoch },
187
+ pending: { ...state.pending, phase: 'verifying' } });
188
+ }
189
+
190
+ /** Readiness must prove this version's process and authenticated relay, before admission. */
191
+ commitHealthy(version: string): void {
192
+ const state = this.read();
193
+ if (state.pending?.phase !== 'verifying' || version !== state.current.version) throw new Error('Candidate readiness does not match this transaction');
194
+ if (state.policy?.schema === 1 && !daemonVersionSupported(version, state.policy))
195
+ throw new Error('Candidate no longer satisfies release policy');
196
+ if (state.policy?.schema === 2 && (!catalogDaemonSupported(state.policy, version) ||
197
+ computerClientCompatibility(state.policy, version, state.clients).some((device) => ['unknown_release', 'update_computer'].includes(device.state))))
198
+ throw new Error('Candidate no longer satisfies enrolled device compatibility');
199
+ this.write({ ...state, previous: state.pending.previous, pending: null, lastFailure: null });
200
+ }
201
+
202
+ /** Recovery after a crash is conservative; never rerun an unproven candidate. */
203
+ recoveryAction(): 'none' | 'discard_staged' | 'rollback' | 'manual_recovery' {
204
+ const pending = this.read().pending;
205
+ if (!pending) return 'none';
206
+ if (pending.phase === 'staged') return 'discard_staged';
207
+ if (pending.phase === 'recovery_required') return 'manual_recovery';
208
+ return 'rollback';
209
+ }
210
+
211
+ discardStaged(): void {
212
+ const state = this.read();
213
+ if (state.pending?.phase !== 'staged') throw new Error('Cannot discard an activated release');
214
+ this.write({ ...state, pending: null });
215
+ }
216
+
217
+ /** Persist before stopping any candidate process. This operation is restart-safe. */
218
+ beginRollback(): void {
219
+ const state = this.read();
220
+ if (!state.pending || state.pending.phase === 'staged' || state.pending.phase === 'recovery_required')
221
+ throw new Error('No automatically recoverable activation');
222
+ this.write({ ...state, lastFailure: 'startup', failedVersions: [...new Set([...state.failedVersions, state.pending.release.version])],
223
+ pending: { ...state.pending, phase: 'rolling_back' } });
224
+ }
225
+
226
+ /** Call only after candidate death is confirmed, then start the previous version paused. */
227
+ selectPrevious(): void {
228
+ const state = this.read();
229
+ if (state.pending?.phase !== 'rolling_back') throw new Error('Rollback has not begun');
230
+ this.write({ ...state, current: state.pending.previous, pending: { ...state.pending, phase: 'recovering' } });
231
+ }
232
+
233
+ completeRollback(version: string): void {
234
+ const state = this.read();
235
+ if (state.pending?.phase !== 'recovering' || version !== state.current.version) throw new Error('Rollback readiness does not match this transaction');
236
+ this.write({ ...state, pending: null });
237
+ }
238
+
239
+ recoveryFailed(): void {
240
+ const state = this.read();
241
+ if (!state.pending || !['rolling_back', 'recovering'].includes(state.pending.phase)) throw new Error('No rollback in progress');
242
+ this.write({ ...state, lastFailure: 'recovery', pending: { ...state.pending, phase: 'recovery_required' } });
243
+ }
244
+
245
+ close(): void {
246
+ if (this.closed) return;
247
+ this.closed = true;
248
+ try { this.db.close(); } finally { this.lease.close(); }
249
+ }
250
+ }
@@ -0,0 +1,64 @@
1
+ import { WorkAdmission } from './admission.js';
2
+ import { attachUpdateControl } from './processControl.js';
3
+
4
+ /** Owns the interval between boot, relay authentication, draining and store closure. */
5
+ export class ManagedDaemonLifecycle {
6
+ readonly admission = new WorkAdmission();
7
+ private relayReady = false;
8
+ private capabilities?: { computerId: string; features: string[] };
9
+ private initialized = false;
10
+ private announced = false;
11
+ private closing = false;
12
+ private cleanup?: () => Promise<void>;
13
+ private resolveInitialization!: () => void;
14
+ private initialization = new Promise<void>((resolve) => { this.resolveInitialization = resolve; });
15
+ private shutdownPromise?: Promise<void>;
16
+ private readonly control: ReturnType<typeof attachUpdateControl>;
17
+
18
+ constructor(version: string, attach = attachUpdateControl) {
19
+ this.control = attach({
20
+ version, capabilities: () => this.capabilities,
21
+ pause: () => this.admission.pause(),
22
+ resume: () => {
23
+ if (!this.initialized || !this.relayReady || this.closing)
24
+ throw new Error('Daemon has not established current relay readiness');
25
+ this.admission.resume();
26
+ },
27
+ shutdown: () => this.shutdown(),
28
+ });
29
+ }
30
+
31
+ relayChanged(ready: boolean, capabilities?: { computerId: string; features: string[] }): void {
32
+ this.capabilities = ready ? capabilities : undefined;
33
+ this.relayReady = ready;
34
+ this.announce();
35
+ }
36
+
37
+ /** Register cleanup only when startup recovery and local server startup finished. */
38
+ initialize(cleanup: () => Promise<void>): void {
39
+ if (this.initialized) throw new Error('Daemon initialization already completed');
40
+ this.cleanup = cleanup;
41
+ this.initialized = true;
42
+ this.resolveInitialization();
43
+ this.announce();
44
+ }
45
+
46
+ private announce(): void {
47
+ if (this.initialized && this.relayReady && !this.closing && !this.announced) {
48
+ this.control.announceReady();
49
+ this.announced = true;
50
+ }
51
+ }
52
+
53
+ shutdown(): Promise<void> {
54
+ if (this.shutdownPromise) return this.shutdownPromise;
55
+ this.closing = true;
56
+ const drained = this.admission.pause();
57
+ return this.shutdownPromise = (async () => {
58
+ await drained;
59
+ await this.initialization;
60
+ await this.cleanup!();
61
+ this.control.dispose();
62
+ })();
63
+ }
64
+ }
@@ -0,0 +1,33 @@
1
+ import { execFile } from 'node:child_process';
2
+ import { lstat } from 'node:fs/promises';
3
+ import { promisify } from 'node:util';
4
+ import { join, resolve } from 'node:path';
5
+ import { homedir } from 'node:os';
6
+ import { CONFIG_DIR } from '../config.js';
7
+ import { readUpdateBootstrap } from './bootstrapConfig.js';
8
+ import { prepareUpdateBootstrap } from './bootstrap.js';
9
+ import { installUpdateService } from './installService.js';
10
+ import { migrateStandalone } from './migration.js';
11
+
12
+ export async function migrateUpdateService(input: string) {
13
+ if (process.platform !== 'darwin') throw new Error('Standalone service migration currently supports macOS. Other platforms need their existing service stopped and reviewed before managed installation.');
14
+ const configPath = resolve(input), config = readUpdateBootstrap(configPath), uid = process.getuid!();
15
+ if (configPath !== join(resolve(config.directory), 'bootstrap.json')) throw new Error('Migrate from the prepared bootstrap.json');
16
+ const loaded = async (label: string) => {
17
+ try { await promisify(execFile)('launchctl', ['print', `gui/${uid}/${label}`], { timeout: 10_000 }); return true; }
18
+ catch (error) {
19
+ if (/Could not find service/i.test(String((error as { stderr?: string }).stderr))) return false;
20
+ throw error;
21
+ }
22
+ };
23
+ return migrateStandalone({ directory: config.directory, configPath,
24
+ legacyPath: join(homedir(), 'Library/LaunchAgents/my.lucidity.daemon.plist'), daemonDirectory: CONFIG_DIR,
25
+ legacyLoaded: () => loaded('my.lucidity.daemon'), managedLoaded: () => loaded('my.lucidity.updater'),
26
+ managedDefinitionExists: async () => {
27
+ try { await lstat(join(homedir(), 'Library/LaunchAgents/my.lucidity.updater.plist')); return true; }
28
+ catch (error) { if ((error as NodeJS.ErrnoException).code === 'ENOENT') return false; throw error; }
29
+ },
30
+ prepare: async () => { await prepareUpdateBootstrap(config); },
31
+ install: () => installUpdateService(configPath),
32
+ });
33
+ }
@@ -0,0 +1,92 @@
1
+ import { readFile, writeFile, rename, lstat, mkdir, copyFile, unlink } from 'node:fs/promises';
2
+ import { constants } from 'node:fs';
3
+ import { createHash } from 'node:crypto';
4
+ import { join } from 'node:path';
5
+ import { z } from 'zod';
6
+ import { DaemonLease } from '../daemonLease.js';
7
+
8
+ const MigrationSchema = z.object({
9
+ schema: z.literal(1), configPath: z.string(), legacyPath: z.string(), digest: z.string(),
10
+ phase: z.enum(['saved', 'detached', 'installing', 'registered', 'restored']),
11
+ }).strict();
12
+
13
+ /** A stopped standalone installation can migrate without discarding its service definition.
14
+ * A loaded legacy daemon has no authenticated drain contract, so it requires attention.
15
+ * Never infer idle from PID existence, an empty queue display or a health response. */
16
+ export async function migrateStandalone(options: {
17
+ directory: string; configPath: string; legacyPath: string; daemonDirectory: string;
18
+ legacyLoaded(): Promise<boolean>; managedLoaded(): Promise<boolean>;
19
+ managedDefinitionExists(): Promise<boolean>;
20
+ prepare(): Promise<void>; install(): Promise<string>;
21
+ }): Promise<string> {
22
+ await mkdir(options.directory, { recursive: true, mode: 0o700 });
23
+ const owner = new DaemonLease(join(options.directory, 'migration-owner'));
24
+ const journalPath = join(options.directory, 'migration.json'), backup = join(options.directory, 'standalone.plist');
25
+ const save = async (state: z.infer<typeof MigrationSchema>) => {
26
+ await writeFile(`${journalPath}.tmp`, JSON.stringify(state), { mode: 0o600, flush: true });
27
+ await rename(`${journalPath}.tmp`, journalPath);
28
+ };
29
+ try {
30
+ let state: z.infer<typeof MigrationSchema> | undefined;
31
+ try { state = MigrationSchema.parse(JSON.parse(await readFile(journalPath, 'utf8'))); }
32
+ catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error; }
33
+ if (state && (state.configPath !== options.configPath || state.legacyPath !== options.legacyPath))
34
+ throw new Error('Standalone migration belongs to another installation');
35
+ if (await options.legacyLoaded())
36
+ throw new Error('The standalone daemon cannot prove a safe drain boundary. Finish active work and stop its service, then retry migration. No service was stopped.');
37
+ if (await options.managedLoaded()) {
38
+ if (state?.phase === 'installing' || state?.phase === 'registered') {
39
+ await save({ ...state, phase: 'registered' });
40
+ return 'Managed service is registered. Check its live readiness before running saved commands.';
41
+ }
42
+ throw new Error('A managed service already owns this computer; inspect it before migrating');
43
+ }
44
+ if (await options.managedDefinitionExists() && (!state || !['installing', 'registered'].includes(state.phase)))
45
+ throw new Error('An unrelated managed service definition exists; inspect it before migrating');
46
+ // Verify published metadata and stage through the existing bootstrap, before detaching anything.
47
+ await options.prepare();
48
+ let lease: DaemonLease | undefined;
49
+ try {
50
+ lease = new DaemonLease(options.daemonDirectory);
51
+ const legacy = await lstat(options.legacyPath).catch(error => {
52
+ if (error.code === 'ENOENT' && state && ['saved', 'detached', 'installing'].includes(state.phase)) return undefined;
53
+ throw error;
54
+ });
55
+ if (legacy && (!legacy.isFile() || legacy.isSymbolicLink())) throw new Error('Expected a regular standalone service definition');
56
+ const contents = await readFile(legacy ? options.legacyPath : backup);
57
+ const digest = createHash('sha256').update(contents).digest('hex');
58
+ if (state && state.digest !== digest) throw new Error('Standalone service changed during migration');
59
+ state ??= { schema: 1, configPath: options.configPath, legacyPath: options.legacyPath, digest, phase: 'saved' };
60
+ try { await writeFile(backup, contents, { flag: 'wx', mode: 0o600, flush: true }); }
61
+ catch (error) {
62
+ if ((error as NodeJS.ErrnoException).code !== 'EEXIST' || !(await readFile(backup)).equals(contents)) throw error;
63
+ }
64
+ await save({ ...state, phase: 'saved' });
65
+ if (await options.legacyLoaded() || await options.managedLoaded()) throw new Error('Service ownership changed during migration');
66
+ if (legacy) await unlink(options.legacyPath);
67
+ await save({ ...state, phase: 'detached' });
68
+ } finally { lease?.close(); }
69
+ // installUpdateService reacquires the daemon lease and revalidates the signed catalog.
70
+ await save({ ...state!, phase: 'installing' });
71
+ try {
72
+ const result = await options.install();
73
+ await save({ ...state!, phase: 'registered' });
74
+ return result;
75
+ } catch (error) {
76
+ // Registration may have started a healthy service before the caller lost its reply.
77
+ // Never stop it or restore a competing service in that uncertain window.
78
+ // An unloaded definition can still start at the next login. Do not restore
79
+ // the standalone definition alongside a partially registered supervisor.
80
+ if (!await options.managedLoaded() && !await options.managedDefinitionExists()) {
81
+ const stopped = new DaemonLease(options.daemonDirectory);
82
+ try {
83
+ if (createHash('sha256').update(await readFile(backup)).digest('hex') !== state!.digest)
84
+ throw new Error('Saved standalone service changed; manual recovery required');
85
+ await copyFile(backup, options.legacyPath, constants.COPYFILE_EXCL); // Exclusive: preserve any concurrent replacement.
86
+ await save({ ...state!, phase: 'restored' });
87
+ } finally { stopped.close(); }
88
+ }
89
+ throw error;
90
+ }
91
+ } finally { owner.close(); }
92
+ }
@@ -0,0 +1,96 @@
1
+ import { z } from 'zod';
2
+ import { DaemonVersionSchema } from '@lucidity/shared';
3
+
4
+ // Local inherited IPC only. Do not expose this contract as a remote command API.
5
+ export const ControlCommandSchema = z.object({
6
+ protocol: z.literal(1), token: z.string().uuid(), id: z.string().uuid(),
7
+ command: z.enum(['quiesce', 'resume', 'shutdown']),
8
+ }).strict();
9
+ export const ControlReplySchema = z.object({
10
+ protocol: z.literal(1), token: z.string().uuid(), version: DaemonVersionSchema,
11
+ id: z.string().uuid().optional(),
12
+ event: z.enum(['ready', 'quiescent', 'resumed', 'error']),
13
+ message: z.string().max(500).optional(),
14
+ computerId: z.string().max(128).optional(), features: z.array(z.string().max(80)).max(64).optional(),
15
+ }).strict();
16
+ export type ControlReply = z.infer<typeof ControlReplySchema>;
17
+
18
+ /**
19
+ * Install before starting any work source. The caller starts with admission closed.
20
+ * announceReady is called only after this process authenticates to the relay.
21
+ * pause must synchronously stop new/queued starts, then await all active mutating work.
22
+ */
23
+ export function attachUpdateControl(options: {
24
+ version: string;
25
+ capabilities?: () => { computerId: string; features: string[] } | undefined;
26
+ pause: () => Promise<void>;
27
+ resume: () => void;
28
+ shutdown: () => Promise<void>;
29
+ fatal?: (error: unknown) => void;
30
+ }): { announceReady: () => void; dispose: () => void } {
31
+ const token = z.string().uuid().parse(process.env['LUCIDITY_SUPERVISOR_TOKEN']);
32
+ const version = DaemonVersionSchema.parse(options.version);
33
+ if (!process.send || !process.connected) throw new Error('Managed daemon requires inherited supervisor IPC');
34
+ let generation = 0;
35
+ let state: 'starting' | 'paused' | 'draining' | 'running' | 'stopping' = 'starting';
36
+ let announced = false;
37
+ let stopping: Promise<void> | undefined;
38
+ const shutdown = () => stopping ??= Promise.resolve().then(options.shutdown);
39
+ const fatal = options.fatal ?? ((error: unknown) => { console.error('[update-control]', error); process.exit(1); });
40
+ const send = (event: ControlReply['event'], id?: string, message?: string) => {
41
+ if (process.connected) process.send!({ protocol: 1, token, version, event, ...(event === 'ready' && process.env['LUCIDITY_SUPERVISOR_CAPABILITIES'] === '1' ? options.capabilities?.() : {}), ...(id ? { id } : {}), ...(message ? { message } : {}) },
42
+ (error: Error | null) => { if (error && process.connected) fatal(error); });
43
+ };
44
+ const handle = async (raw: unknown) => {
45
+ const parsed = ControlCommandSchema.safeParse(raw);
46
+ if (!parsed.success || parsed.data.token !== token) return;
47
+ const { command, id } = parsed.data;
48
+ if (state === 'stopping') return;
49
+ try {
50
+ if (command === 'quiesce') {
51
+ const request = ++generation;
52
+ state = 'draining';
53
+ await options.pause();
54
+ if (generation !== request) return; // A timed-out drain was cancelled by resume.
55
+ state = 'paused';
56
+ send('quiescent', id);
57
+ } else if (command === 'resume') {
58
+ if (!announced) throw new Error('Daemon has not established relay readiness');
59
+ ++generation;
60
+ options.resume();
61
+ state = 'running';
62
+ send('resumed', id);
63
+ } else {
64
+ if (state === 'running' || state === 'draining') throw new Error('Cannot stop before work has drained');
65
+ ++generation;
66
+ state = 'stopping';
67
+ await shutdown();
68
+ // shutdown must finish closing stores/providers before resolving.
69
+ process.exit(0);
70
+ }
71
+ } catch (error) {
72
+ send('error', id, error instanceof Error ? error.message.slice(0, 500) : 'Process control failed');
73
+ }
74
+ };
75
+ const onMessage = (raw: unknown) => { void handle(raw); };
76
+ const onDisconnect = () => {
77
+ ++generation;
78
+ state = 'stopping';
79
+ // Parent failure never kills active work. A replacement supervisor must prove
80
+ // that the daemon ownership lock is free before starting another process.
81
+ void Promise.resolve().then(options.pause).then(shutdown).then(() => process.exit(0)).catch(fatal);
82
+ };
83
+ process.on('message', onMessage);
84
+ process.on('disconnect', onDisconnect);
85
+ return {
86
+ announceReady() {
87
+ // Initialization may finish after the parent has requested shutdown or died.
88
+ if (announced || state === 'stopping') return;
89
+ if (state !== 'starting') throw new Error('Unexpected daemon readiness');
90
+ announced = true;
91
+ state = 'paused';
92
+ send('ready');
93
+ },
94
+ dispose() { process.off('message', onMessage); process.off('disconnect', onDisconnect); },
95
+ };
96
+ }