@opencorelabs/lucidity 0.8.0 → 0.9.5

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 (371) hide show
  1. package/README.md +2 -2
  2. package/dist/assets/speech/lucidity-speech +0 -0
  3. package/dist/automations/service.d.ts +4 -0
  4. package/dist/automations/service.d.ts.map +1 -1
  5. package/dist/automations/service.js +60 -22
  6. package/dist/automations/store.d.ts +9 -3
  7. package/dist/automations/store.d.ts.map +1 -1
  8. package/dist/automations/store.js +45 -32
  9. package/dist/automations/workflow.d.ts +14 -0
  10. package/dist/automations/workflow.d.ts.map +1 -0
  11. package/dist/automations/workflow.js +57 -0
  12. package/dist/coding/listPrs.d.ts +2 -0
  13. package/dist/coding/listPrs.d.ts.map +1 -1
  14. package/dist/coding/listPrs.js +10 -0
  15. package/dist/coding/runCodeTurn.d.ts +3 -14
  16. package/dist/coding/runCodeTurn.d.ts.map +1 -1
  17. package/dist/coding/runCodeTurn.js +21 -86
  18. package/dist/coding/runReview.d.ts +10 -0
  19. package/dist/coding/runReview.d.ts.map +1 -0
  20. package/dist/coding/runReview.js +87 -0
  21. package/dist/coding/workspaceRegistry.d.ts +49 -1
  22. package/dist/coding/workspaceRegistry.d.ts.map +1 -1
  23. package/dist/coding/workspaceRegistry.js +208 -17
  24. package/dist/coding/worktree.d.ts +61 -18
  25. package/dist/coding/worktree.d.ts.map +1 -1
  26. package/dist/coding/worktree.js +149 -17
  27. package/dist/coding/worktreeSetup.d.ts +7 -0
  28. package/dist/coding/worktreeSetup.d.ts.map +1 -0
  29. package/dist/coding/worktreeSetup.js +49 -0
  30. package/dist/index.js +21 -28
  31. package/dist/jobs/briefing.d.ts +2 -16
  32. package/dist/jobs/briefing.d.ts.map +1 -1
  33. package/dist/jobs/briefing.js +65 -93
  34. package/dist/logTimestamps.d.ts +10 -0
  35. package/dist/logTimestamps.d.ts.map +1 -0
  36. package/dist/logTimestamps.js +12 -0
  37. package/dist/providerRecovery.d.ts +48 -0
  38. package/dist/providerRecovery.d.ts.map +1 -0
  39. package/dist/providerRecovery.js +100 -0
  40. package/dist/room/client.d.ts +2 -20
  41. package/dist/room/client.d.ts.map +1 -1
  42. package/dist/room/client.js +18 -29
  43. package/dist/room/computer.d.ts.map +1 -1
  44. package/dist/room/computer.js +1 -2
  45. package/dist/room/incidents.d.ts +3 -0
  46. package/dist/room/incidents.d.ts.map +1 -1
  47. package/dist/room/incidents.js +1 -0
  48. package/dist/room/turnQueue.d.ts.map +1 -1
  49. package/dist/room/turnQueue.js +28 -22
  50. package/dist/runtimeStore.d.ts +2 -0
  51. package/dist/runtimeStore.d.ts.map +1 -1
  52. package/dist/runtimeStore.js +17 -0
  53. package/dist/vault.d.ts +6 -3
  54. package/dist/vault.d.ts.map +1 -1
  55. package/dist/vault.js +18 -4
  56. package/package.json +1 -1
  57. package/src/automations/service.ts +47 -21
  58. package/src/automations/store.ts +41 -50
  59. package/src/automations/workflow.ts +49 -0
  60. package/src/coding/listPrs.ts +14 -0
  61. package/src/coding/runCodeTurn.ts +26 -95
  62. package/src/coding/runReview.ts +83 -0
  63. package/src/coding/workspaceRegistry.ts +186 -16
  64. package/src/coding/worktree.ts +161 -20
  65. package/src/coding/worktreeSetup.ts +50 -0
  66. package/src/index.ts +22 -31
  67. package/src/jobs/briefing.ts +62 -109
  68. package/src/logTimestamps.ts +14 -0
  69. package/src/providerRecovery.ts +99 -0
  70. package/src/room/client.ts +19 -54
  71. package/src/room/computer.ts +1 -2
  72. package/src/room/incidents.ts +4 -0
  73. package/src/room/turnQueue.ts +27 -29
  74. package/src/runtimeStore.ts +18 -1
  75. package/src/vault.ts +16 -7
  76. package/vendor/mcp-server/package.json +1 -1
  77. package/vendor/runtime/README.md +34 -0
  78. package/vendor/runtime/dist/executor/claudeAgent.d.ts +4 -0
  79. package/vendor/runtime/dist/executor/claudeAgent.d.ts.map +1 -1
  80. package/vendor/runtime/dist/executor/claudeAgent.js +57 -4
  81. package/vendor/runtime/dist/executor/codex.d.ts +7 -2
  82. package/vendor/runtime/dist/executor/codex.d.ts.map +1 -1
  83. package/vendor/runtime/dist/executor/codex.js +47 -4
  84. package/vendor/runtime/dist/executor/codexProtocol/AgentPath.d.ts +2 -0
  85. package/vendor/runtime/dist/executor/codexProtocol/AgentPath.d.ts.map +1 -0
  86. package/vendor/runtime/dist/executor/codexProtocol/AgentPath.js +2 -0
  87. package/vendor/runtime/dist/executor/codexProtocol/ImageGenerationFailure.d.ts +6 -0
  88. package/vendor/runtime/dist/executor/codexProtocol/ImageGenerationFailure.d.ts.map +1 -0
  89. package/vendor/runtime/dist/executor/codexProtocol/ImageGenerationFailure.js +2 -0
  90. package/vendor/runtime/dist/executor/codexProtocol/ImageGenerationItem.d.ts +12 -0
  91. package/vendor/runtime/dist/executor/codexProtocol/ImageGenerationItem.d.ts.map +1 -0
  92. package/vendor/runtime/dist/executor/codexProtocol/ImageGenerationItem.js +2 -0
  93. package/vendor/runtime/dist/executor/codexProtocol/LegacyAppPathString.d.ts +24 -0
  94. package/vendor/runtime/dist/executor/codexProtocol/LegacyAppPathString.d.ts.map +1 -0
  95. package/vendor/runtime/dist/executor/codexProtocol/LegacyAppPathString.js +2 -0
  96. package/vendor/runtime/dist/executor/codexProtocol/MessagePhase.d.ts +8 -0
  97. package/vendor/runtime/dist/executor/codexProtocol/MessagePhase.d.ts.map +1 -0
  98. package/vendor/runtime/dist/executor/codexProtocol/MessagePhase.js +2 -0
  99. package/vendor/runtime/dist/executor/codexProtocol/SleepItem.d.ts +8 -0
  100. package/vendor/runtime/dist/executor/codexProtocol/SleepItem.d.ts.map +1 -0
  101. package/vendor/runtime/dist/executor/codexProtocol/SleepItem.js +2 -0
  102. package/vendor/runtime/dist/executor/codexProtocol/SubAgentSource.d.ts +14 -0
  103. package/vendor/runtime/dist/executor/codexProtocol/SubAgentSource.d.ts.map +1 -0
  104. package/vendor/runtime/dist/executor/codexProtocol/SubAgentSource.js +2 -0
  105. package/vendor/runtime/dist/executor/codexProtocol/ThreadId.d.ts +7 -0
  106. package/vendor/runtime/dist/executor/codexProtocol/ThreadId.d.ts.map +1 -0
  107. package/vendor/runtime/dist/executor/codexProtocol/ThreadId.js +2 -0
  108. package/vendor/runtime/dist/executor/codexProtocol/WebSearchItem.d.ts +15 -0
  109. package/vendor/runtime/dist/executor/codexProtocol/WebSearchItem.d.ts.map +1 -0
  110. package/vendor/runtime/dist/executor/codexProtocol/WebSearchItem.js +2 -0
  111. package/vendor/runtime/dist/executor/codexProtocol/v2/AgentMessageDelivery.d.ts +2 -0
  112. package/vendor/runtime/dist/executor/codexProtocol/v2/AgentMessageDelivery.d.ts.map +1 -0
  113. package/vendor/runtime/dist/executor/codexProtocol/v2/AgentMessageDelivery.js +2 -0
  114. package/vendor/runtime/dist/executor/codexProtocol/v2/AsyncUserInputQuestion.d.ts +5 -0
  115. package/vendor/runtime/dist/executor/codexProtocol/v2/AsyncUserInputQuestion.d.ts.map +1 -0
  116. package/vendor/runtime/dist/executor/codexProtocol/v2/AsyncUserInputQuestion.js +2 -0
  117. package/vendor/runtime/dist/executor/codexProtocol/v2/CodexErrorInfo.d.ts +29 -0
  118. package/vendor/runtime/dist/executor/codexProtocol/v2/CodexErrorInfo.d.ts.map +1 -0
  119. package/vendor/runtime/dist/executor/codexProtocol/v2/CodexErrorInfo.js +2 -0
  120. package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentState.d.ts +6 -0
  121. package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentState.d.ts.map +1 -0
  122. package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentState.js +2 -0
  123. package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentStatus.d.ts +2 -0
  124. package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentStatus.d.ts.map +1 -0
  125. package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentStatus.js +2 -0
  126. package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentTool.d.ts +2 -0
  127. package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentTool.d.ts.map +1 -0
  128. package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentTool.js +2 -0
  129. package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentToolCallStatus.d.ts +2 -0
  130. package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentToolCallStatus.d.ts.map +1 -0
  131. package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentToolCallStatus.js +2 -0
  132. package/vendor/runtime/dist/executor/codexProtocol/v2/CommandAction.d.ts +20 -0
  133. package/vendor/runtime/dist/executor/codexProtocol/v2/CommandAction.d.ts.map +1 -0
  134. package/vendor/runtime/dist/executor/codexProtocol/v2/CommandAction.js +2 -0
  135. package/vendor/runtime/dist/executor/codexProtocol/v2/CommandExecutionSource.d.ts +2 -0
  136. package/vendor/runtime/dist/executor/codexProtocol/v2/CommandExecutionSource.d.ts.map +1 -0
  137. package/vendor/runtime/dist/executor/codexProtocol/v2/CommandExecutionSource.js +2 -0
  138. package/vendor/runtime/dist/executor/codexProtocol/v2/CommandExecutionStatus.d.ts +2 -0
  139. package/vendor/runtime/dist/executor/codexProtocol/v2/CommandExecutionStatus.d.ts.map +1 -0
  140. package/vendor/runtime/dist/executor/codexProtocol/v2/CommandExecutionStatus.js +2 -0
  141. package/vendor/runtime/dist/executor/codexProtocol/v2/DynamicToolCallOutputContentItem.d.ts +11 -0
  142. package/vendor/runtime/dist/executor/codexProtocol/v2/DynamicToolCallOutputContentItem.d.ts.map +1 -0
  143. package/vendor/runtime/dist/executor/codexProtocol/v2/DynamicToolCallOutputContentItem.js +2 -0
  144. package/vendor/runtime/dist/executor/codexProtocol/v2/DynamicToolCallStatus.d.ts +2 -0
  145. package/vendor/runtime/dist/executor/codexProtocol/v2/DynamicToolCallStatus.d.ts.map +1 -0
  146. package/vendor/runtime/dist/executor/codexProtocol/v2/DynamicToolCallStatus.js +2 -0
  147. package/vendor/runtime/dist/executor/codexProtocol/v2/FileUpdateChange.d.ts +7 -0
  148. package/vendor/runtime/dist/executor/codexProtocol/v2/FileUpdateChange.d.ts.map +1 -0
  149. package/vendor/runtime/dist/executor/codexProtocol/v2/FileUpdateChange.js +2 -0
  150. package/vendor/runtime/dist/executor/codexProtocol/v2/GitInfo.d.ts +6 -0
  151. package/vendor/runtime/dist/executor/codexProtocol/v2/GitInfo.d.ts.map +1 -0
  152. package/vendor/runtime/dist/executor/codexProtocol/v2/GitInfo.js +2 -0
  153. package/vendor/runtime/dist/executor/codexProtocol/v2/HookPromptFragment.d.ts +5 -0
  154. package/vendor/runtime/dist/executor/codexProtocol/v2/HookPromptFragment.d.ts.map +1 -0
  155. package/vendor/runtime/dist/executor/codexProtocol/v2/HookPromptFragment.js +2 -0
  156. package/vendor/runtime/dist/executor/codexProtocol/v2/McpAppDisplayMode.d.ts +2 -0
  157. package/vendor/runtime/dist/executor/codexProtocol/v2/McpAppDisplayMode.d.ts.map +1 -0
  158. package/vendor/runtime/dist/executor/codexProtocol/v2/McpAppDisplayMode.js +2 -0
  159. package/vendor/runtime/dist/executor/codexProtocol/v2/McpAppUi.d.ts +9 -0
  160. package/vendor/runtime/dist/executor/codexProtocol/v2/McpAppUi.d.ts.map +1 -0
  161. package/vendor/runtime/dist/executor/codexProtocol/v2/McpAppUi.js +2 -0
  162. package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallAppContext.d.ts +8 -0
  163. package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallAppContext.d.ts.map +1 -0
  164. package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallAppContext.js +2 -0
  165. package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallError.d.ts +4 -0
  166. package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallError.d.ts.map +1 -0
  167. package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallError.js +2 -0
  168. package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallResult.d.ts +7 -0
  169. package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallResult.d.ts.map +1 -0
  170. package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallResult.js +2 -0
  171. package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallStatus.d.ts +2 -0
  172. package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallStatus.d.ts.map +1 -0
  173. package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallStatus.js +2 -0
  174. package/vendor/runtime/dist/executor/codexProtocol/v2/MemoryCitation.d.ts +6 -0
  175. package/vendor/runtime/dist/executor/codexProtocol/v2/MemoryCitation.d.ts.map +1 -0
  176. package/vendor/runtime/dist/executor/codexProtocol/v2/MemoryCitation.js +2 -0
  177. package/vendor/runtime/dist/executor/codexProtocol/v2/MemoryCitationEntry.d.ts +7 -0
  178. package/vendor/runtime/dist/executor/codexProtocol/v2/MemoryCitationEntry.d.ts.map +1 -0
  179. package/vendor/runtime/dist/executor/codexProtocol/v2/MemoryCitationEntry.js +2 -0
  180. package/vendor/runtime/dist/executor/codexProtocol/v2/MisalignmentErrorDetails.d.ts +16 -0
  181. package/vendor/runtime/dist/executor/codexProtocol/v2/MisalignmentErrorDetails.d.ts.map +1 -0
  182. package/vendor/runtime/dist/executor/codexProtocol/v2/MisalignmentErrorDetails.js +2 -0
  183. package/vendor/runtime/dist/executor/codexProtocol/v2/MisalignmentSteer.d.ts +4 -0
  184. package/vendor/runtime/dist/executor/codexProtocol/v2/MisalignmentSteer.d.ts.map +1 -0
  185. package/vendor/runtime/dist/executor/codexProtocol/v2/MisalignmentSteer.js +2 -0
  186. package/vendor/runtime/dist/executor/codexProtocol/v2/NonSteerableTurnKind.d.ts +2 -0
  187. package/vendor/runtime/dist/executor/codexProtocol/v2/NonSteerableTurnKind.d.ts.map +1 -0
  188. package/vendor/runtime/dist/executor/codexProtocol/v2/NonSteerableTurnKind.js +2 -0
  189. package/vendor/runtime/dist/executor/codexProtocol/v2/PatchApplyStatus.d.ts +2 -0
  190. package/vendor/runtime/dist/executor/codexProtocol/v2/PatchApplyStatus.d.ts.map +1 -0
  191. package/vendor/runtime/dist/executor/codexProtocol/v2/PatchApplyStatus.js +2 -0
  192. package/vendor/runtime/dist/executor/codexProtocol/v2/PatchChangeKind.d.ts +9 -0
  193. package/vendor/runtime/dist/executor/codexProtocol/v2/PatchChangeKind.d.ts.map +1 -0
  194. package/vendor/runtime/dist/executor/codexProtocol/v2/PatchChangeKind.js +2 -0
  195. package/vendor/runtime/dist/executor/codexProtocol/v2/SessionSource.d.ts +7 -0
  196. package/vendor/runtime/dist/executor/codexProtocol/v2/SessionSource.d.ts.map +1 -0
  197. package/vendor/runtime/dist/executor/codexProtocol/v2/SessionSource.js +2 -0
  198. package/vendor/runtime/dist/executor/codexProtocol/v2/SubAgentActivityKind.d.ts +2 -0
  199. package/vendor/runtime/dist/executor/codexProtocol/v2/SubAgentActivityKind.d.ts.map +1 -0
  200. package/vendor/runtime/dist/executor/codexProtocol/v2/SubAgentActivityKind.js +2 -0
  201. package/vendor/runtime/dist/executor/codexProtocol/v2/Thread.d.ts +100 -0
  202. package/vendor/runtime/dist/executor/codexProtocol/v2/Thread.d.ts.map +1 -0
  203. package/vendor/runtime/dist/executor/codexProtocol/v2/Thread.js +2 -0
  204. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadActiveFlag.d.ts +2 -0
  205. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadActiveFlag.d.ts.map +1 -0
  206. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadActiveFlag.js +2 -0
  207. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadHistoryMode.d.ts +2 -0
  208. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadHistoryMode.d.ts.map +1 -0
  209. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadHistoryMode.js +2 -0
  210. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadItem.d.ts +216 -0
  211. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadItem.d.ts.map +1 -0
  212. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadItem.js +2 -0
  213. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadReadParams.d.ts +11 -0
  214. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadReadParams.d.ts.map +1 -0
  215. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadReadParams.js +2 -0
  216. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadReadResponse.d.ts +5 -0
  217. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadReadResponse.d.ts.map +1 -0
  218. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadReadResponse.js +2 -0
  219. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSection.d.ts +19 -0
  220. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSection.d.ts.map +1 -0
  221. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSection.js +2 -0
  222. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSectionAppearance.d.ts +8 -0
  223. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSectionAppearance.d.ts.map +1 -0
  224. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSectionAppearance.js +2 -0
  225. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadStatus.d.ts +12 -0
  226. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadStatus.d.ts.map +1 -0
  227. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadStatus.js +2 -0
  228. package/vendor/runtime/dist/executor/codexProtocol/v2/Turn.d.ts +36 -0
  229. package/vendor/runtime/dist/executor/codexProtocol/v2/Turn.d.ts.map +1 -0
  230. package/vendor/runtime/dist/executor/codexProtocol/v2/Turn.js +2 -0
  231. package/vendor/runtime/dist/executor/codexProtocol/v2/TurnError.d.ts +12 -0
  232. package/vendor/runtime/dist/executor/codexProtocol/v2/TurnError.d.ts.map +1 -0
  233. package/vendor/runtime/dist/executor/codexProtocol/v2/TurnError.js +2 -0
  234. package/vendor/runtime/dist/executor/codexProtocol/v2/TurnItemsView.d.ts +2 -0
  235. package/vendor/runtime/dist/executor/codexProtocol/v2/TurnItemsView.d.ts.map +1 -0
  236. package/vendor/runtime/dist/executor/codexProtocol/v2/TurnItemsView.js +2 -0
  237. package/vendor/runtime/dist/executor/codexProtocol/v2/TurnStatus.d.ts +2 -0
  238. package/vendor/runtime/dist/executor/codexProtocol/v2/TurnStatus.d.ts.map +1 -0
  239. package/vendor/runtime/dist/executor/codexProtocol/v2/TurnStatus.js +2 -0
  240. package/vendor/runtime/dist/executor/codexProtocol/v2/WebSearchAction.d.ts +15 -0
  241. package/vendor/runtime/dist/executor/codexProtocol/v2/WebSearchAction.d.ts.map +1 -0
  242. package/vendor/runtime/dist/executor/codexProtocol/v2/WebSearchAction.js +2 -0
  243. package/vendor/runtime/dist/executor/codexRpc.d.ts +3 -1
  244. package/vendor/runtime/dist/executor/codexRpc.d.ts.map +1 -1
  245. package/vendor/runtime/dist/executor/codexRpc.js +3 -2
  246. package/vendor/runtime/dist/executor/health.d.ts +6 -1
  247. package/vendor/runtime/dist/executor/health.d.ts.map +1 -1
  248. package/vendor/runtime/dist/executor/health.js +4 -0
  249. package/vendor/runtime/dist/executor/ownership.d.ts +6 -1
  250. package/vendor/runtime/dist/executor/ownership.d.ts.map +1 -1
  251. package/vendor/runtime/dist/executor/ownership.js +7 -0
  252. package/vendor/runtime/dist/executor/types.d.ts +25 -0
  253. package/vendor/runtime/dist/executor/types.d.ts.map +1 -1
  254. package/vendor/runtime/dist/harness/index.d.ts.map +1 -1
  255. package/vendor/runtime/dist/harness/index.js +1 -0
  256. package/vendor/runtime/dist/index.d.ts +1 -1
  257. package/vendor/runtime/dist/index.d.ts.map +1 -1
  258. package/vendor/runtime/src/executor/claudeAgent.ts +50 -4
  259. package/vendor/runtime/src/executor/codex.ts +51 -5
  260. package/vendor/runtime/src/executor/codexProtocol/AgentPath.ts +5 -0
  261. package/vendor/runtime/src/executor/codexProtocol/ImageGenerationFailure.ts +5 -0
  262. package/vendor/runtime/src/executor/codexProtocol/ImageGenerationItem.ts +7 -0
  263. package/vendor/runtime/src/executor/codexProtocol/LegacyAppPathString.ts +27 -0
  264. package/vendor/runtime/src/executor/codexProtocol/MessagePhase.ts +11 -0
  265. package/vendor/runtime/src/executor/codexProtocol/SleepItem.ts +8 -0
  266. package/vendor/runtime/src/executor/codexProtocol/SubAgentSource.ts +7 -0
  267. package/vendor/runtime/src/executor/codexProtocol/ThreadId.ts +10 -0
  268. package/vendor/runtime/src/executor/codexProtocol/WebSearchItem.ts +14 -0
  269. package/vendor/runtime/src/executor/codexProtocol/v2/AgentMessageDelivery.ts +5 -0
  270. package/vendor/runtime/src/executor/codexProtocol/v2/AsyncUserInputQuestion.ts +5 -0
  271. package/vendor/runtime/src/executor/codexProtocol/v2/CodexErrorInfo.ts +12 -0
  272. package/vendor/runtime/src/executor/codexProtocol/v2/CollabAgentState.ts +6 -0
  273. package/vendor/runtime/src/executor/codexProtocol/v2/CollabAgentStatus.ts +5 -0
  274. package/vendor/runtime/src/executor/codexProtocol/v2/CollabAgentTool.ts +5 -0
  275. package/vendor/runtime/src/executor/codexProtocol/v2/CollabAgentToolCallStatus.ts +5 -0
  276. package/vendor/runtime/src/executor/codexProtocol/v2/CommandAction.ts +6 -0
  277. package/vendor/runtime/src/executor/codexProtocol/v2/CommandExecutionSource.ts +5 -0
  278. package/vendor/runtime/src/executor/codexProtocol/v2/CommandExecutionStatus.ts +5 -0
  279. package/vendor/runtime/src/executor/codexProtocol/v2/DynamicToolCallOutputContentItem.ts +5 -0
  280. package/vendor/runtime/src/executor/codexProtocol/v2/DynamicToolCallStatus.ts +5 -0
  281. package/vendor/runtime/src/executor/codexProtocol/v2/FileUpdateChange.ts +6 -0
  282. package/vendor/runtime/src/executor/codexProtocol/v2/GitInfo.ts +5 -0
  283. package/vendor/runtime/src/executor/codexProtocol/v2/HookPromptFragment.ts +5 -0
  284. package/vendor/runtime/src/executor/codexProtocol/v2/McpAppDisplayMode.ts +5 -0
  285. package/vendor/runtime/src/executor/codexProtocol/v2/McpAppUi.ts +9 -0
  286. package/vendor/runtime/src/executor/codexProtocol/v2/McpToolCallAppContext.ts +5 -0
  287. package/vendor/runtime/src/executor/codexProtocol/v2/McpToolCallError.ts +5 -0
  288. package/vendor/runtime/src/executor/codexProtocol/v2/McpToolCallResult.ts +6 -0
  289. package/vendor/runtime/src/executor/codexProtocol/v2/McpToolCallStatus.ts +5 -0
  290. package/vendor/runtime/src/executor/codexProtocol/v2/MemoryCitation.ts +6 -0
  291. package/vendor/runtime/src/executor/codexProtocol/v2/MemoryCitationEntry.ts +5 -0
  292. package/vendor/runtime/src/executor/codexProtocol/v2/MisalignmentErrorDetails.ts +18 -0
  293. package/vendor/runtime/src/executor/codexProtocol/v2/MisalignmentSteer.ts +5 -0
  294. package/vendor/runtime/src/executor/codexProtocol/v2/NonSteerableTurnKind.ts +5 -0
  295. package/vendor/runtime/src/executor/codexProtocol/v2/PatchApplyStatus.ts +5 -0
  296. package/vendor/runtime/src/executor/codexProtocol/v2/PatchChangeKind.ts +5 -0
  297. package/vendor/runtime/src/executor/codexProtocol/v2/SessionSource.ts +6 -0
  298. package/vendor/runtime/src/executor/codexProtocol/v2/SubAgentActivityKind.ts +5 -0
  299. package/vendor/runtime/src/executor/codexProtocol/v2/Thread.ts +104 -0
  300. package/vendor/runtime/src/executor/codexProtocol/v2/ThreadActiveFlag.ts +5 -0
  301. package/vendor/runtime/src/executor/codexProtocol/v2/ThreadHistoryMode.ts +5 -0
  302. package/vendor/runtime/src/executor/codexProtocol/v2/ThreadItem.ts +125 -0
  303. package/vendor/runtime/src/executor/codexProtocol/v2/ThreadReadParams.ts +12 -0
  304. package/vendor/runtime/src/executor/codexProtocol/v2/ThreadReadResponse.ts +6 -0
  305. package/vendor/runtime/src/executor/codexProtocol/v2/ThreadSection.ts +21 -0
  306. package/vendor/runtime/src/executor/codexProtocol/v2/ThreadSectionAppearance.ts +8 -0
  307. package/vendor/runtime/src/executor/codexProtocol/v2/ThreadStatus.ts +6 -0
  308. package/vendor/runtime/src/executor/codexProtocol/v2/Turn.ts +37 -0
  309. package/vendor/runtime/src/executor/codexProtocol/v2/TurnError.ts +11 -0
  310. package/vendor/runtime/src/executor/codexProtocol/v2/TurnItemsView.ts +5 -0
  311. package/vendor/runtime/src/executor/codexProtocol/v2/TurnStatus.ts +5 -0
  312. package/vendor/runtime/src/executor/codexProtocol/v2/WebSearchAction.ts +5 -0
  313. package/vendor/runtime/src/executor/codexRpc.ts +4 -2
  314. package/vendor/runtime/src/executor/health.ts +5 -1
  315. package/vendor/runtime/src/executor/ownership.ts +8 -1
  316. package/vendor/runtime/src/executor/types.ts +18 -1
  317. package/vendor/runtime/src/harness/index.ts +1 -0
  318. package/vendor/runtime/src/index.ts +1 -1
  319. package/vendor/shared/dist/automations.d.ts +34 -0
  320. package/vendor/shared/dist/automations.d.ts.map +1 -1
  321. package/vendor/shared/dist/automations.js +12 -0
  322. package/vendor/shared/dist/computer.d.ts +1 -1
  323. package/vendor/shared/dist/computer.d.ts.map +1 -1
  324. package/vendor/shared/dist/computer.js +1 -2
  325. package/vendor/shared/dist/constants.d.ts +1 -1
  326. package/vendor/shared/dist/constants.d.ts.map +1 -1
  327. package/vendor/shared/dist/constants.js +3 -10
  328. package/vendor/shared/dist/index.d.ts +4 -2
  329. package/vendor/shared/dist/index.d.ts.map +1 -1
  330. package/vendor/shared/dist/index.js +3 -1
  331. package/vendor/shared/dist/journal-vault.d.ts +1 -1
  332. package/vendor/shared/dist/messagingSafety.d.ts +21 -0
  333. package/vendor/shared/dist/messagingSafety.d.ts.map +1 -0
  334. package/vendor/shared/dist/messagingSafety.js +8 -0
  335. package/vendor/shared/dist/schemas/harness.d.ts +98 -169
  336. package/vendor/shared/dist/schemas/harness.d.ts.map +1 -1
  337. package/vendor/shared/dist/schemas/harness.js +19 -124
  338. package/vendor/shared/dist/smartCapture.d.ts +24 -0
  339. package/vendor/shared/dist/smartCapture.d.ts.map +1 -1
  340. package/vendor/shared/dist/smartCapture.js +15 -0
  341. package/vendor/shared/dist/taskSync.d.ts +342 -0
  342. package/vendor/shared/dist/taskSync.d.ts.map +1 -0
  343. package/vendor/shared/dist/taskSync.js +111 -0
  344. package/vendor/shared/dist/types.d.ts +1 -4
  345. package/vendor/shared/dist/types.d.ts.map +1 -1
  346. package/vendor/shared/dist/voiceCapture.d.ts +1 -1
  347. package/vendor/shared/dist/workspaces.d.ts +117 -0
  348. package/vendor/shared/dist/workspaces.d.ts.map +1 -1
  349. package/vendor/shared/dist/workspaces.js +50 -1
  350. package/vendor/shared/src/automations.ts +12 -0
  351. package/vendor/shared/src/computer.ts +3 -3
  352. package/vendor/shared/src/constants.ts +3 -10
  353. package/vendor/shared/src/index.ts +3 -6
  354. package/vendor/shared/src/messagingSafety.ts +11 -0
  355. package/vendor/shared/src/schemas/harness.ts +18 -130
  356. package/vendor/shared/src/smartCapture.ts +27 -0
  357. package/vendor/shared/src/taskSync.ts +81 -0
  358. package/vendor/shared/src/types.ts +0 -6
  359. package/vendor/shared/src/workspaces.ts +56 -1
  360. package/dist/coding/conduct.d.ts +0 -48
  361. package/dist/coding/conduct.d.ts.map +0 -1
  362. package/dist/coding/conduct.js +0 -263
  363. package/dist/coding/fleetPlan.d.ts +0 -20
  364. package/dist/coding/fleetPlan.d.ts.map +0 -1
  365. package/dist/coding/fleetPlan.js +0 -125
  366. package/dist/coding/fleetTasks.d.ts +0 -33
  367. package/dist/coding/fleetTasks.d.ts.map +0 -1
  368. package/dist/coding/fleetTasks.js +0 -75
  369. package/src/coding/conduct.ts +0 -325
  370. package/src/coding/fleetPlan.ts +0 -135
  371. package/src/coding/fleetTasks.ts +0 -109
package/src/index.ts CHANGED
@@ -27,6 +27,7 @@ import {
27
27
  import { LaneQueue } from './queue.js';
28
28
  import { AutomationStore } from './automations/store.js';
29
29
  import { AutomationService } from './automations/service.js';
30
+ import { SavedWorkflow } from './automations/workflow.js';
30
31
  import { createDeckDesigner } from './automations/designer.js';
31
32
  import { createAgentAutomation } from './automations/agent.js';
32
33
  import { runAutomationsCli } from './automations/cli.js';
@@ -54,14 +55,16 @@ import { FluidAudioEngine } from './speech/fluidAudio.js';
54
55
  import { createSessionJournalSource } from './room/journalSource.js';
55
56
  import { TurnLogStore } from './turnLog.js';
56
57
  import { DaemonLease } from './daemonLease.js';
58
+ import { RecoveryExecutor, recoverProviderRuns } from './providerRecovery.js';
57
59
  import { commandContext } from './coding/commandContext.js';
58
60
  import { runCodeTurn } from './coding/runCodeTurn.js';
59
- import { runConductTurn } from './coding/conduct.js';
60
61
  import { cloneRepo } from './coding/cloneRepo.js';
61
62
  import { listAllowlist } from './coding/discover.js';
62
63
  import { resolveRepo } from './coding/repos.js';
63
64
  import { watchBranches } from './coding/branchWatch.js';
65
+ import { mergedPrHead } from './coding/listPrs.js';
64
66
  import { sweepStaleRequests } from './sweepStale.js';
67
+ import { stampLogs } from './logTimestamps.js';
65
68
  import { runSetup } from './setup/server.js';
66
69
  import { runClientSetup } from './mcp/clients.js';
67
70
  import { runDecisionsCli } from './decisions/cli.js';
@@ -156,6 +159,8 @@ async function main(): Promise<void> {
156
159
  process.exit(1);
157
160
  }
158
161
 
162
+ stampLogs();
163
+
159
164
  // The executor default is the Coding pair — the capable model. Every real-time turn
160
165
  // (ask/voice) passes the Chat pair explicitly, and coding turns pass the Coding pair
161
166
  // explicitly; this default catches only the batch jobs (briefing/weekly/attention),
@@ -163,11 +168,12 @@ async function main(): Promise<void> {
163
168
  const lease = args.runNow === undefined ? new DaemonLease(CONFIG_DIR) : undefined;
164
169
  process.once('exit', () => lease?.close());
165
170
  const ownership = new ExecutionOwnership();
171
+ const turnLogs = args.runNow === undefined ? new TurnLogStore() : undefined;
166
172
  const providers = {
167
173
  claude: new HealthAwareExecutor(
168
- new OwnedExecutor(new ClaudeAgentExecutor({ oauthToken: config.oauthToken }), 'claude', ownership),
174
+ new OwnedExecutor(new RecoveryExecutor(new ClaudeAgentExecutor({ oauthToken: config.oauthToken }), 'claude', turnLogs?.runtime), 'claude', ownership),
169
175
  ),
170
- codex: new HealthAwareExecutor(new OwnedExecutor(new CodexExecutor(), 'codex', ownership)),
176
+ codex: new HealthAwareExecutor(new OwnedExecutor(new RecoveryExecutor(new CodexExecutor(), 'codex', turnLogs?.runtime), 'codex', ownership)),
171
177
  };
172
178
  const controls = new AgentControls(Object.values(providers));
173
179
  const executor = new ProviderRouter(providers, () => ({
@@ -244,11 +250,12 @@ async function main(): Promise<void> {
244
250
  );
245
251
  }
246
252
 
247
- const turnLogs = new TurnLogStore();
253
+ if (!turnLogs) throw new Error('Daemon storage is unavailable.');
254
+ await recoverProviderRuns(turnLogs, providers);
248
255
  turnLogs.runtime.set('supervisor', 'current', lease!.owner);
249
256
  const workspaces = new WorkspaceRegistry(turnLogs.runtime, () => listAllowlist(config));
250
257
  turnLogs.prune();
251
- const automationStore = new AutomationStore(join(CONFIG_DIR, 'automations'));
258
+ const automationStore = new AutomationStore(join(CONFIG_DIR, 'automations'), turnLogs.runtime);
252
259
  const designer = createDeckDesigner({
253
260
  config,
254
261
  directory: CONFIG_DIR,
@@ -275,6 +282,7 @@ async function main(): Promise<void> {
275
282
  }
276
283
  },
277
284
  store: automationStore,
285
+ resumable: (job) => job.id === 'builtin:briefing',
278
286
  validateRepo: designer.validateRepo,
279
287
  saveGuidance: designer.saveGuidance,
280
288
  connections: designer.connections,
@@ -290,7 +298,7 @@ async function main(): Promise<void> {
290
298
  let result: import('./jobs/runner.js').JobResult | undefined;
291
299
  await runJob(job.id.replace('builtin:', ''), queue, async () => {
292
300
  if (job.id === 'builtin:briefing')
293
- result = await runBriefing(config, bounded, deliverer, attention);
301
+ result = await runBriefing(config, bounded, deliverer, attention, new SavedWorkflow(automationStore, run.id, signal));
294
302
  else if (job.id === 'builtin:weekly-review')
295
303
  result = await runWeeklyReview(config, bounded, deliverer);
296
304
  else if (job.id === 'builtin:goals')
@@ -487,31 +495,6 @@ async function main(): Promise<void> {
487
495
  allowInPlace: config.allowInPlace,
488
496
  })
489
497
  : undefined,
490
- // The fleet conductor (multi-worktree fan-out). Enabled wherever coding is; each fan-out's
491
- // workers become Lucidity subtasks via the same API key the daemon already holds, so the
492
- // task graph is the fleet's org chart. Tasks land in the Inbox for now (projectId null).
493
- conductHandler:
494
- config.repos.length || config.repoRoots.length
495
- ? (req, ctx) =>
496
- runConductTurn(req, {
497
- runWorker: ctx.runWorker,
498
- onWorkerApproval: (requestId, approval) =>
499
- controls.request(requestId, approval, ctx.signal, ctx.send),
500
- onEnd: (requestId) => controls.end(requestId),
501
- repos: listAllowlist(config),
502
- executor,
503
- send: ctx.send,
504
- signal: ctx.signal,
505
- model: config.codeModel,
506
- effort: config.codeEffort,
507
- api: config.apiKey
508
- ? createApiClient({
509
- apiUrl: config.apiUrl,
510
- apiKey: config.apiKey,
511
- })
512
- : undefined,
513
- })
514
- : undefined,
515
498
  // Phone-initiated clone (#78) is enabled when a workspace root is configured.
516
499
  cloneHandler: config.workspaceRoot
517
500
  ? (req, ctx) =>
@@ -568,6 +551,13 @@ async function main(): Promise<void> {
568
551
  })
569
552
  : null;
570
553
 
554
+ // Archive-on-merge has no event to hang on (the merge happens on GitHub), so look every few
555
+ // minutes. It asks gh only for worktrees in repositories that turned the setting on.
556
+ const mergedSweep = setInterval(() => {
557
+ void workspaces.archiveMerged(mergedPrHead).catch(() => {});
558
+ }, 5 * 60_000);
559
+ mergedSweep.unref();
560
+
571
561
  const tz = config.timezone ? ` ${config.timezone}` : '';
572
562
  const next = automationStore
573
563
  .jobs()
@@ -601,6 +591,7 @@ async function main(): Promise<void> {
601
591
  const stoppedAutomations = automations.stop();
602
592
  chatServer.close();
603
593
  branchWatcher?.stop();
594
+ clearInterval(mergedSweep);
604
595
  roomClient.stop();
605
596
  roomController.abort();
606
597
  shuttingDown = (async () => {
@@ -1,16 +1,12 @@
1
1
  import {
2
- buildBriefingPrompt,
3
- splitBriefingOutput,
4
- buildMemoryReflectionPrompt,
5
- createApiClient,
6
- mergeFacts,
7
- parseFacts,
8
- type AgentExecutor,
2
+ buildBriefingPrompt, splitBriefingOutput, buildMemoryReflectionPrompt,
3
+ createApiClient, mergeFacts, parseFacts, type AgentExecutor,
9
4
  } from '@lucidity/runtime';
10
5
  import type { Task, User } from '@lucidity/shared';
11
6
  import type { DaemonConfig } from '../config.js';
12
7
  import type { Deliverer } from '../delivery/index.js';
13
8
  import type { AttentionPublisher } from '../attention.js';
9
+ import type { SavedWorkflow } from '../automations/workflow.js';
14
10
  import { createVault } from '../vault.js';
15
11
  import { loadNotesContext } from '../notesContext.js';
16
12
  import { loadFlaggedTasks } from '../importantTasks.js';
@@ -19,135 +15,92 @@ export interface BriefingResult {
19
15
  text: string;
20
16
  costUsd?: number;
21
17
  sessionId?: string;
22
- /** Delivery channel used. */
23
18
  delivered: string;
24
- /** Present if the briefing succeeded but delivery failed. */
25
19
  deliveryError?: string;
26
- /** Number of new durable facts learned this run. */
27
20
  factsLearned: number;
28
- /** How many attention boards this run produced for the phone (#320). */
29
21
  boardsPublished: number;
30
22
  }
31
23
 
32
- /**
33
- * The daily briefing pipeline:
34
- * 1. fetch today's tasks + profile
35
- * 2. read persona (SOUL.md) + durable facts (MEMORY.md) from the vault
36
- * 3. assemble + run the briefing
37
- * 4. deliver (notification) — failure is a warning, not a run failure
38
- * 5. reflect → merge new facts into MEMORY.md (if config.reflect)
39
- * 6. write a session log
40
- * Returns metadata for the run log. stdout transcript + run-record timing are
41
- * handled by the caller.
42
- */
43
24
  export async function runBriefing(
44
25
  config: DaemonConfig,
45
26
  executor: AgentExecutor,
46
27
  deliverer: Deliverer,
47
28
  attention?: AttentionPublisher,
29
+ workflow?: SavedWorkflow,
48
30
  ): Promise<BriefingResult> {
49
- // Stamped once, up front: the board's age should read from when this run started reading the
50
- // day, not from whenever the model happened to finish writing about it.
51
- const startedAt = new Date();
52
- const api = createApiClient({ apiUrl: config.apiUrl, apiKey: config.apiKey });
53
- const [tasks, user, flagged] = await Promise.all([
54
- api.request<Task[]>('/api/tasks/today'),
55
- api.request<User>('/api/users/me'),
56
- loadFlaggedTasks(api),
57
- ]);
58
-
59
- const vault = createVault(config.vaultPath);
60
- const persona = vault.readPersona();
61
- const facts = vault.readMemoryFacts();
62
- const memory = facts.length
63
- ? facts.map((f) => `- ${f}`).join('\n')
64
- : undefined;
65
- const notes = loadNotesContext(config);
66
-
67
- // 1. Briefing — and, in the same turn, the phone's attention board (#320). One model call
68
- // producing both, so the two framings come from one reading of the day and can't disagree.
69
- const prompt = buildBriefingPrompt({
70
- user,
71
- tasks,
72
- persona,
73
- memory,
74
- notes,
75
- flagged,
76
- withBoard: attention != null,
77
- });
78
- const briefing = await executor.run({
79
- systemPrompt: prompt.systemPrompt,
80
- userPrompt: prompt.userPrompt,
81
- model: config.codeModel,
82
- effort: config.codeEffort,
31
+ const step = <T>(key: string, policy: 'retry' | 'effect', action: () => Promise<T> | T): Promise<T> =>
32
+ workflow ? workflow.step(key, policy, action) : Promise.resolve().then(action);
33
+ const context = await step('Collect context', 'retry', async () => {
34
+ const api = createApiClient({ apiUrl: config.apiUrl, apiKey: config.apiKey });
35
+ const [tasks, user, flagged] = await Promise.all([
36
+ api.request<Task[]>('/api/tasks/today'), api.request<User>('/api/users/me'), loadFlaggedTasks(api),
37
+ ]);
38
+ const vault = createVault(config.vaultPath);
39
+ const facts = vault.readMemoryFacts();
40
+ return {
41
+ tasks, user, flagged, persona: vault.readPersona(),
42
+ memory: facts.length ? facts.map((f) => `- ${f}`).join('\n') : undefined,
43
+ notes: loadNotesContext(config), startedAt: new Date().toISOString(),
44
+ model: config.codeModel, effort: config.codeEffort, provider: config.codeProvider,
45
+ reflect: config.reflect, vaultPath: config.vaultPath, delivery: deliverer.name,
46
+ withBoard: attention != null,
47
+ };
83
48
  });
84
- // Everything downstream — delivery, reflection, the session log — uses the briefing half only.
85
- // A board that failed to parse costs us the board, never the briefing.
86
- const split = attention
87
- ? splitBriefingOutput(briefing.text, [...tasks, ...flagged])
88
- : { briefing: briefing.text, boards: [] };
49
+ const { tasks, user, persona, memory, flagged } = context;
50
+ const vault = createVault(context.vaultPath);
51
+ const briefing = await step('Generate briefing', 'retry', () => executor.run({
52
+ ...buildBriefingPrompt({ user, tasks, persona, memory, notes: context.notes, flagged, withBoard: context.withBoard }),
53
+ model: context.model, effort: context.effort, provider: context.provider, noTools: true,
54
+ }));
55
+ const split = context.withBoard ? splitBriefingOutput(briefing.text, [...tasks, ...flagged]) : { briefing: briefing.text, boards: [] };
89
56
  const text = split.briefing;
90
57
  let costUsd = briefing.costUsd;
91
58
 
92
- if (attention && split.boards.length)
93
- attention.publish(split.boards, startedAt);
94
- else if (attention)
95
- console.error('[briefing] no attention boards in the model output');
59
+ // The local artifact has a stable identity and an exact-content receipt. Save before delivery.
60
+ if (workflow) await step('Save briefing', 'retry', () => vault.writeSessionLog({
61
+ startedAt: context.startedAt, body: text, deliveredVia: 'See automation run for delivery outcome', factsLearned: [],
62
+ }, { id: workflow.runId, strict: true }));
63
+
64
+ // Board publication replaces one dated value. Rehydrate it on resume without regressing a newer board.
65
+ if (attention && split.boards.length && (!attention.latest() || attention.latest()!.writtenAt <= context.startedAt))
66
+ attention.publish(split.boards, new Date(context.startedAt));
67
+ await step('Publish board', 'retry', () => ({ writtenAt: context.startedAt, boards: split.boards }));
96
68
 
97
- // 2. Deliver
98
69
  let deliveryError: string | undefined;
99
70
  try {
100
- await deliverer.deliver({ title: 'Lucidity', body: text });
101
- } catch (err) {
102
- deliveryError = err instanceof Error ? err.message : String(err);
103
- console.error(
104
- `[briefing] delivery via ${deliverer.name} failed: ${deliveryError}`,
105
- );
71
+ await step('Deliver notification', 'effect', async () => {
72
+ if (deliverer.name !== context.delivery) throw new Error('The delivery channel changed since this run started.');
73
+ await deliverer.deliver({ title: 'Lucidity', body: text });
74
+ return { delivered: deliverer.name };
75
+ });
76
+ } catch (error) {
77
+ if (workflow) throw error;
78
+ deliveryError = error instanceof Error ? error.message : String(error);
106
79
  }
107
80
 
108
- // 3. Reflect → update MEMORY.md (best-effort; never fails the run)
109
81
  let learned: string[] = [];
110
- if (config.reflect) {
82
+ if (context.reflect) {
111
83
  try {
112
- const rp = buildMemoryReflectionPrompt({
113
- persona,
114
- user,
115
- tasks,
116
- briefing: text,
117
- memory,
118
- });
119
- const reflection = await executor.run({
120
- systemPrompt: rp.systemPrompt,
121
- userPrompt: rp.userPrompt,
122
- model: config.codeModel,
123
- effort: config.codeEffort,
124
- });
125
- if (reflection.costUsd != null)
126
- costUsd = (costUsd ?? 0) + reflection.costUsd;
84
+ const reflection = await step('Reflect', 'retry', () => executor.run({
85
+ ...buildMemoryReflectionPrompt({ persona, user, tasks, briefing: text, memory }),
86
+ model: context.model, effort: context.effort, provider: context.provider, noTools: true,
87
+ }));
88
+ if (reflection.costUsd != null) costUsd = (costUsd ?? 0) + reflection.costUsd;
127
89
  learned = parseFacts(reflection.text);
128
- if (learned.length) vault.writeMemoryFacts(mergeFacts(facts, learned));
129
- } catch (err) {
130
- console.error(
131
- `[briefing] reflection failed: ${err instanceof Error ? err.message : String(err)}`,
132
- );
90
+ await step('Update memory', 'effect', () => {
91
+ // Read and merge synchronously at commit time, never reuse the initial facts snapshot.
92
+ if (learned.length) vault.writeMemoryFacts(mergeFacts(vault.readMemoryFacts(!!workflow), learned), !!workflow);
93
+ return { factsLearned: learned.length };
94
+ });
95
+ } catch (error) {
96
+ if (workflow) throw error;
97
+ console.error(`[briefing] reflection failed: ${String(error)}`);
133
98
  }
134
99
  }
135
-
136
- // 4. Session log
137
- vault.writeSessionLog({
138
- startedAt: new Date().toISOString(),
139
- body: text,
100
+ if (!workflow) vault.writeSessionLog({
101
+ startedAt: context.startedAt, body: text,
140
102
  deliveredVia: deliveryError ? `${deliverer.name} (failed)` : deliverer.name,
141
103
  factsLearned: learned,
142
104
  });
143
-
144
- return {
145
- text,
146
- costUsd,
147
- sessionId: briefing.sessionId,
148
- delivered: deliverer.name,
149
- deliveryError,
150
- factsLearned: learned.length,
151
- boardsPublished: attention ? split.boards.length : 0,
152
- };
105
+ return { text, costUsd, sessionId: briefing.sessionId, delivered: context.delivery, deliveryError, factsLearned: learned.length, boardsPublished: split.boards.length };
153
106
  }
@@ -0,0 +1,14 @@
1
+ type Level = 'log' | 'warn' | 'error';
2
+
3
+ /**
4
+ * Put the time on every line the daemon logs. launchd appends stdout and stderr to
5
+ * `daemon.out.log` and `daemon.err.log` with nothing added, so a relay 502 could not be placed
6
+ * against the turn it interrupted (#505). Only the daemon run mode calls this: the CLI commands
7
+ * print for a person and stay unstamped.
8
+ */
9
+ export function stampLogs(target: Pick<Console, Level> = console, now: () => Date = () => new Date()): void {
10
+ for (const level of ['log', 'warn', 'error'] as const) {
11
+ const write = target[level].bind(target);
12
+ target[level] = (...args: unknown[]) => write(now().toISOString(), ...args);
13
+ }
14
+ }
@@ -0,0 +1,99 @@
1
+ import {
2
+ encodeSession,
3
+ type AgentExecutor,
4
+ type AgentProvider,
5
+ type ExecutorRunInput,
6
+ type ExecutorResult,
7
+ type ExecutorStreamEvent,
8
+ type ProviderRunRef,
9
+ type ProviderInspection,
10
+ } from '@lucidity/runtime';
11
+ import type { RuntimeStore } from './runtimeStore.js';
12
+ import type { TurnLogStore } from './turnLog.js';
13
+
14
+ export interface SavedProviderRun extends ProviderRunRef {
15
+ version: 1;
16
+ requestId: string;
17
+ provider: AgentProvider;
18
+ ownerPid: number;
19
+ cwd?: string;
20
+ model?: string;
21
+ effort?: string;
22
+ result?: ExecutorResult;
23
+ }
24
+
25
+ /** Persist provider evidence before callers transform or publish their result. */
26
+ export class RecoveryExecutor implements AgentExecutor {
27
+ constructor(private readonly executor: AgentExecutor, private readonly provider: AgentProvider, private readonly store?: RuntimeStore) {}
28
+ get name() { return this.executor.name; }
29
+ get strictResume() { return this.executor.strictResume; }
30
+ get recoveryCapability() { return this.executor.recoveryCapability; }
31
+ inspect(ref: ProviderRunRef, options?: { cwd?: string; timeoutMs?: number }): Promise<ProviderInspection> {
32
+ return this.executor.inspect?.(ref, options) ?? Promise.resolve({ status: 'unsupported', reason: 'Provider history inspection is unavailable.' });
33
+ }
34
+ models() { return this.executor.models?.() ?? Promise.resolve([]); }
35
+ commands(input?: Pick<ExecutorRunInput, 'cwd' | 'permissionMode' | 'mcp'>) { return this.executor.commands?.(input) ?? Promise.resolve([]); }
36
+ steer(id: string, text: string) { return this.executor.steer?.(id, text) ?? Promise.reject(new Error('Steering is unavailable.')); }
37
+ interrupt(id: string) { return this.executor.interrupt?.(id) ?? Promise.resolve(false); }
38
+ async dispose() { await this.executor.dispose?.(); }
39
+ async run(input: ExecutorRunInput): Promise<ExecutorResult> {
40
+ // Non-streaming consumers may validate or transform structured results.
41
+ return this.executor.run(input);
42
+ }
43
+ async *runStream(input: ExecutorRunInput): AsyncIterable<ExecutorStreamEvent> {
44
+ if (!this.executor.runStream) throw new Error('Streaming is unavailable.');
45
+ const request = input.requestId && this.store?.command(input.requestId);
46
+ const recordable = request && (request.kind === 'code' || (request.kind === 'ask' && !request.dayPlan && !request.projectPlan));
47
+ if (!recordable) { yield* this.executor.runStream(input); return; }
48
+ let saved: SavedProviderRun = {
49
+ version: 1, requestId: input.requestId!, provider: this.provider, ownerPid: process.pid,
50
+ cwd: input.cwd, sessionId: input.resume ?? input.sessionId, model: input.model, effort: input.effort,
51
+ };
52
+ const persist = (patch: Partial<SavedProviderRun>) => {
53
+ saved = { ...saved, ...patch };
54
+ this.store!.set('provider-runs', saved.requestId, saved);
55
+ };
56
+ persist({});
57
+ for await (const event of this.executor.runStream({ ...input, onRecovery: (ref) => { persist(ref); input.onRecovery?.(ref); } })) {
58
+ if (event.type === 'session') persist({ sessionId: event.sessionId });
59
+ if (event.type === 'done') persist({ result: event, sessionId: event.sessionId ?? saved.sessionId });
60
+ yield event;
61
+ }
62
+ }
63
+ }
64
+
65
+ function processAlive(pid?: number): boolean {
66
+ if (!pid) return false;
67
+ try { process.kill(pid, 0); return true; }
68
+ catch (error) { return (error as NodeJS.ErrnoException).code !== 'ESRCH'; }
69
+ }
70
+
71
+ /** Called under DaemonLease, before constructing queues or starting any new work. */
72
+ export async function recoverProviderRuns(logs: TurnLogStore, providers: Record<AgentProvider, AgentExecutor>, alive = processAlive): Promise<void> {
73
+ for (const saved of logs.runtime.list<SavedProviderRun>('provider-runs')) {
74
+ const state = logs.read(saved.requestId);
75
+ const terminal = state.frames.at(-1);
76
+ if (state.terminated && terminal?.code !== 'interrupted_unknown') continue;
77
+ if (saved.version !== 1) continue;
78
+ // A surviving native child can still own a workspace even after its daemon died.
79
+ if (alive(saved.ownerPid) || alive(saved.pid))
80
+ throw new Error(`Cannot recover ${saved.requestId}: its prior provider owner is still running. Wait for it to exit before restarting Lucidity.`);
81
+ let evidence: ProviderInspection;
82
+ if (saved.result) evidence = { status: 'completed', result: saved.result };
83
+ else {
84
+ try {
85
+ evidence = await providers[saved.provider].inspect?.(saved, { cwd: saved.cwd, timeoutMs: 10_000 }) ??
86
+ { status: 'unsupported', reason: 'Provider history inspection is unavailable.' };
87
+ } catch { evidence = { status: 'unknown', reason: 'Provider history inspection failed.' }; }
88
+ }
89
+ const sessionId = saved.sessionId ? encodeSession({ provider: saved.provider, id: saved.sessionId, model: saved.model, effort: saved.effort }) : undefined;
90
+ const reconciliation = { requestId: saved.requestId, checkedAt: new Date().toISOString(), ...evidence,
91
+ ...(evidence.status === 'completed' ? { result: { ...evidence.result, sessionId } } : {}) };
92
+ // Already-terminal unknown runs retain their original event stream. Review reads this linked record.
93
+ logs.runtime.set('reconciliation', saved.requestId, reconciliation);
94
+ if (!state.terminated && evidence.status === 'completed') {
95
+ if (sessionId) logs.append(saved.requestId, { type: 'session', requestId: saved.requestId, sessionId });
96
+ logs.append(saved.requestId, { type: 'done', requestId: saved.requestId, ...evidence.result, sessionId, recovered: true });
97
+ }
98
+ }
99
+ }
@@ -17,7 +17,6 @@ import type {
17
17
  WorkspaceMode,
18
18
  PrInfo,
19
19
  HarnessImage,
20
- FleetPlan,
21
20
  DaemonConfigView,
22
21
  DaemonConfigPatch,
23
22
  } from '@lucidity/shared';
@@ -76,13 +75,6 @@ const STREAM_EVENT_TYPES = new Set([
76
75
  'clone_result',
77
76
  'error',
78
77
  'cancelled',
79
- // Conductor fleet events — logged + seq-stamped like any turn frame so a mid-fleet `pull`
80
- // replays the plan and the workers' progress instead of settling the turn as cut off.
81
- 'fleet_plan',
82
- 'worker_status',
83
- 'fleet_conflict',
84
- 'worker_pr',
85
- 'fleet_done',
86
78
  ]);
87
79
 
88
80
  /**
@@ -99,6 +91,7 @@ const STREAM_EVENT_TYPES = new Set([
99
91
 
100
92
  export type CodeHandler = (
101
93
  req: {
94
+ recoveryOf?: string;
102
95
  id: string;
103
96
  repoId: string;
104
97
  prompt: string;
@@ -118,21 +111,6 @@ export type CloneHandler = (
118
111
  ctx: { send: (obj: unknown) => void; signal?: AbortSignal },
119
112
  ) => Promise<void>;
120
113
 
121
- export type ConductHandler = (
122
- req: {
123
- id: string;
124
- repoId: string;
125
- phase: 'plan' | 'run' | 'setup' | 'integrate';
126
- prompt: string;
127
- images?: HarnessImage[];
128
- plan?: FleetPlan;
129
- resume?: string;
130
- /** A quick incremental spawn: skip the dogfood task graph (no parent task, no subtask). */
131
- ephemeral?: boolean;
132
- },
133
- ctx: { send: (obj: unknown) => void; signal?: AbortSignal; runWorker: NonNullable<import('../coding/conduct.js').RunConductTurnDeps['runWorker']> },
134
- ) => Promise<void>;
135
-
136
114
  /** One row of the phone's repo picker: which repo, what branch it sits on right now,
137
115
  * and whether this daemon will let a turn run in that checkout (#121). */
138
116
  export interface RepoInfo {
@@ -170,8 +148,6 @@ export interface DispatchDeps {
170
148
  signal?: AbortSignal;
171
149
  /** Handle a `code` turn (M7). Absent → coding stays disabled. */
172
150
  codeHandler?: CodeHandler;
173
- /** Handle a `conduct` turn (the fleet conductor). Absent → the conductor stays disabled. */
174
- conductHandler?: ConductHandler;
175
151
  /** Handle a `clone` turn (#78). Absent → phone cloning stays disabled. */
176
152
  cloneHandler?: CloneHandler;
177
153
  /** The phone's repo picker (`repos` request). A callback, not a value: resolving each
@@ -226,7 +202,7 @@ function sendStreamEvent(
226
202
  else if (ev.type === 'delta')
227
203
  send({ type: 'delta', requestId, text: ev.text });
228
204
  else if (ev.type === 'tool_call')
229
- send({ type: 'tool_call', requestId, name: ev.name, phase: ev.phase });
205
+ send({ ...ev, requestId });
230
206
  else
231
207
  send({
232
208
  type: 'done',
@@ -406,6 +382,7 @@ export async function dispatchRequest(
406
382
  reason: req.reason,
407
383
  snapshot: req.snapshot,
408
384
  diag: req.diag,
385
+ perf: req.perf,
409
386
  });
410
387
  const path = writeIncidentBundle(bundle, deps.incidentsDir);
411
388
  deps.telemetry?.record(
@@ -505,7 +482,10 @@ export async function dispatchRequest(
505
482
  // Completion can beat Stop while its terminal frame is lost in transit. Replay
506
483
  // the actual outcome so the phone settles without rewriting finished work.
507
484
  const state = deps.turnLogs.read(req.targetId);
508
- if (state.terminated) for (const frame of state.frames) deps.sendRaw(frame);
485
+ if (state.terminated) {
486
+ log(`stop for finished turn ${req.targetId}: replaying its ${state.frames.length} frames`);
487
+ for (const frame of state.frames) deps.sendRaw(frame);
488
+ }
509
489
  }
510
490
  return;
511
491
  }
@@ -525,6 +505,10 @@ export async function dispatchRequest(
525
505
  });
526
506
  return;
527
507
  }
508
+ // The phone is still waiting on a turn this computer already finished: its last frame was
509
+ // lost on the way. Worth a line, it is the only trace on this side of that failure (#505).
510
+ if (state.terminated && state.frames.some((frame) => frame.seq > req.sinceSeq))
511
+ log(`pull for finished turn ${req.targetId}: phone had seq ${req.sinceSeq} of ${state.frames.length}`);
528
512
  // Replay the gap verbatim (already logged; don't re-log).
529
513
  for (const frame of state.frames) {
530
514
  if (frame.seq > req.sinceSeq) sendRaw(frame);
@@ -555,7 +539,7 @@ export async function dispatchRequest(
555
539
 
556
540
  if (
557
541
  deps.recordAcceptance &&
558
- ['ask', 'code', 'conduct', 'briefing', 'attention', 'clone'].includes(
542
+ ['ask', 'code', 'briefing', 'attention', 'clone'].includes(
559
543
  req.kind,
560
544
  )
561
545
  ) {
@@ -733,6 +717,10 @@ export async function dispatchRequest(
733
717
  });
734
718
  } else if (req.kind === 'workspaces') {
735
719
  if (!deps.workspaces) throw new Error('Update Lucidity on the computer to use persistent workers.');
720
+ if (req.command.action === 'continue-run') {
721
+ if (!deps.turnQueue) throw new Error('The computer queue is unavailable.');
722
+ deps.turnQueue.enqueue(deps.workspaces.continuation(req.command));
723
+ }
736
724
  send({ requestId: req.id, kind: 'workspaces', snapshot: await deps.workspaces.command(req.command, req.id) });
737
725
  } else if (req.kind === 'repos') {
738
726
  send({
@@ -806,29 +794,9 @@ export async function dispatchRequest(
806
794
  });
807
795
  if (r.restarting) deps.requestRestart?.();
808
796
  }
809
- } else if (req.kind === 'conduct') {
810
- if (deps.conductHandler) {
811
- await deps.conductHandler(
812
- { id: req.id, repoId: req.repoId, phase: req.phase, prompt: req.prompt,
813
- images: req.images, plan: req.plan, resume: req.resume, ephemeral: req.ephemeral },
814
- {
815
- send, signal,
816
- runWorker: (worker, workerDeps) => dispatchRequest(
817
- JSON.stringify({ ...worker, kind: 'code', stream: true, mode: 'worktree' }),
818
- { ...deps, signal, send: workerDeps.send, recordAcceptance: true },
819
- ),
820
- },
821
- );
822
- } else {
823
- send({
824
- type: 'error',
825
- requestId: req.id,
826
- message: 'The conductor is not enabled on this daemon.',
827
- });
828
- }
829
797
  } else if (deps.codeHandler) {
830
798
  // Per-worktree lane: two turns sharing a worktree/cwd must serialize, but genuinely
831
- // independent work runs in parallel. The bare repo session and each conductor worker
799
+ // independent work runs in parallel. The bare repo session and each worktree
832
800
  // (`workerId`) own separate worktrees, so each gets its own lane — a phone turn drilled
833
801
  // into worker A can't collide with worker B, and a bare turn keeps today's exact key.
834
802
  const lane = req.workerId
@@ -847,6 +815,7 @@ export async function dispatchRequest(
847
815
  mode: req.mode,
848
816
  expectedBranch: req.expectedBranch,
849
817
  workerId: req.workerId,
818
+ ...(req.recoveryOf ? { recoveryOf: req.recoveryOf } : {}),
850
819
  },
851
820
  { send, signal },
852
821
  ),
@@ -895,8 +864,6 @@ export interface RoomClientOptions {
895
864
  logger?: (msg: string) => void;
896
865
  /** Handle `code` turns (M7). Absent → coding disabled. */
897
866
  codeHandler?: CodeHandler;
898
- /** Handle `conduct` turns (the fleet conductor). Absent → the conductor disabled. */
899
- conductHandler?: ConductHandler;
900
867
  /** Serialises room turns per lane — see `DispatchDeps.queue`. Share the daemon's one instance
901
868
  * so room turns also serialise against scheduled briefings and the local chat server. */
902
869
  queue?: LaneQueue;
@@ -1045,7 +1012,6 @@ export function startRoomClient(opts: RoomClientOptions): RoomClientHandle {
1045
1012
  vault,
1046
1013
  signal,
1047
1014
  codeHandler,
1048
- conductHandler,
1049
1015
  cloneHandler,
1050
1016
  queue,
1051
1017
  getConfig,
@@ -1193,8 +1159,7 @@ export function startRoomClient(opts: RoomClientOptions): RoomClientHandle {
1193
1159
  workspaces: opts.workspaces,
1194
1160
  signal,
1195
1161
  codeHandler,
1196
- conductHandler,
1197
- cloneHandler,
1162
+ cloneHandler,
1198
1163
  queue: executionLanes,
1199
1164
  inFlight,
1200
1165
  attention: opts.attention,
@@ -58,8 +58,7 @@ export function computerRuntime(opts: RoomClientOptions): ComputerRuntime {
58
58
  ...(opts.commands ? ['commands'] : []),
59
59
  ...(opts.controls ? ['permission', 'steer'] : []),
60
60
  ...(opts.codeHandler ? ['code'] : []),
61
- ...(opts.workspaces ? ['workspaces', 'checkout-history'] : []),
62
- ...(opts.conductHandler ? ['conduct'] : []),
61
+ ...(opts.workspaces ? ['workspaces', 'checkout-history', 'repo-settings', 'worktree-delete'] : []),
63
62
  ...(opts.cloneHandler ? ['clone'] : []),
64
63
  ...(opts.attention ? ['attention'] : []),
65
64
  ...(opts.getConfig ? ['getConfig'] : []),