@opencorelabs/lucidity 0.7.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 (502) hide show
  1. package/README.md +9 -2
  2. package/dist/assets/speech/lucidity-speech +0 -0
  3. package/dist/automations/agent.d.ts.map +1 -1
  4. package/dist/automations/agent.js +2 -0
  5. package/dist/automations/designer.d.ts +1 -1
  6. package/dist/automations/service.d.ts +4 -0
  7. package/dist/automations/service.d.ts.map +1 -1
  8. package/dist/automations/service.js +60 -22
  9. package/dist/automations/store.d.ts +9 -3
  10. package/dist/automations/store.d.ts.map +1 -1
  11. package/dist/automations/store.js +45 -32
  12. package/dist/automations/workflow.d.ts +14 -0
  13. package/dist/automations/workflow.d.ts.map +1 -0
  14. package/dist/automations/workflow.js +57 -0
  15. package/dist/chat/server.d.ts +1 -0
  16. package/dist/chat/server.d.ts.map +1 -1
  17. package/dist/chat/server.js +6 -1
  18. package/dist/coding/listPrs.d.ts +2 -0
  19. package/dist/coding/listPrs.d.ts.map +1 -1
  20. package/dist/coding/listPrs.js +10 -0
  21. package/dist/coding/runCodeTurn.d.ts +6 -30
  22. package/dist/coding/runCodeTurn.d.ts.map +1 -1
  23. package/dist/coding/runCodeTurn.js +145 -218
  24. package/dist/coding/runReview.d.ts +10 -0
  25. package/dist/coding/runReview.d.ts.map +1 -0
  26. package/dist/coding/runReview.js +87 -0
  27. package/dist/coding/workspaceRegistry.d.ts +72 -0
  28. package/dist/coding/workspaceRegistry.d.ts.map +1 -0
  29. package/dist/coding/workspaceRegistry.js +421 -0
  30. package/dist/coding/worktree.d.ts +72 -32
  31. package/dist/coding/worktree.d.ts.map +1 -1
  32. package/dist/coding/worktree.js +190 -38
  33. package/dist/coding/worktreeSetup.d.ts +7 -0
  34. package/dist/coding/worktreeSetup.d.ts.map +1 -0
  35. package/dist/coding/worktreeSetup.js +49 -0
  36. package/dist/config.d.ts +2 -0
  37. package/dist/config.d.ts.map +1 -1
  38. package/dist/daemonLease.d.ts +12 -0
  39. package/dist/daemonLease.d.ts.map +1 -0
  40. package/dist/daemonLease.js +32 -0
  41. package/dist/goals/assessment.d.ts +115 -0
  42. package/dist/goals/assessment.d.ts.map +1 -0
  43. package/dist/goals/assessment.js +67 -0
  44. package/dist/goals/notes.d.ts +18 -0
  45. package/dist/goals/notes.d.ts.map +1 -0
  46. package/dist/goals/notes.js +72 -0
  47. package/dist/index.js +75 -40
  48. package/dist/jobs/briefing.d.ts +2 -16
  49. package/dist/jobs/briefing.d.ts.map +1 -1
  50. package/dist/jobs/briefing.js +65 -93
  51. package/dist/jobs/goals.d.ts +15 -0
  52. package/dist/jobs/goals.d.ts.map +1 -0
  53. package/dist/jobs/goals.js +286 -0
  54. package/dist/jobs/weeklyReview.d.ts.map +1 -1
  55. package/dist/jobs/weeklyReview.js +3 -2
  56. package/dist/logTimestamps.d.ts +10 -0
  57. package/dist/logTimestamps.d.ts.map +1 -0
  58. package/dist/logTimestamps.js +12 -0
  59. package/dist/providerRecovery.d.ts +48 -0
  60. package/dist/providerRecovery.d.ts.map +1 -0
  61. package/dist/providerRecovery.js +100 -0
  62. package/dist/queue.d.ts +1 -0
  63. package/dist/queue.d.ts.map +1 -1
  64. package/dist/queue.js +4 -0
  65. package/dist/room/client.d.ts +6 -19
  66. package/dist/room/client.d.ts.map +1 -1
  67. package/dist/room/client.js +127 -123
  68. package/dist/room/computer.js +1 -1
  69. package/dist/room/durablePublish.d.ts +6 -0
  70. package/dist/room/durablePublish.d.ts.map +1 -0
  71. package/dist/room/durablePublish.js +19 -0
  72. package/dist/room/incidents.d.ts +4 -1
  73. package/dist/room/incidents.d.ts.map +1 -1
  74. package/dist/room/incidents.js +15 -7
  75. package/dist/room/turnQueue.d.ts.map +1 -1
  76. package/dist/room/turnQueue.js +55 -46
  77. package/dist/runtimeStore.d.ts +46 -0
  78. package/dist/runtimeStore.d.ts.map +1 -0
  79. package/dist/runtimeStore.js +205 -0
  80. package/dist/setup/server.js +1 -1
  81. package/dist/turnLog.d.ts +10 -40
  82. package/dist/turnLog.d.ts.map +1 -1
  83. package/dist/turnLog.js +33 -56
  84. package/dist/vault.d.ts +6 -3
  85. package/dist/vault.d.ts.map +1 -1
  86. package/dist/vault.js +18 -4
  87. package/package.json +4 -4
  88. package/src/automations/agent.ts +2 -0
  89. package/src/automations/service.ts +47 -21
  90. package/src/automations/store.ts +41 -50
  91. package/src/automations/workflow.ts +49 -0
  92. package/src/chat/server.ts +7 -1
  93. package/src/coding/listPrs.ts +14 -0
  94. package/src/coding/runCodeTurn.ts +51 -139
  95. package/src/coding/runReview.ts +83 -0
  96. package/src/coding/workspaceRegistry.ts +380 -0
  97. package/src/coding/worktree.ts +205 -40
  98. package/src/coding/worktreeSetup.ts +50 -0
  99. package/src/config.ts +2 -0
  100. package/src/daemonLease.ts +33 -0
  101. package/src/goals/assessment.ts +106 -0
  102. package/src/goals/notes.ts +88 -0
  103. package/src/index.ts +76 -46
  104. package/src/jobs/briefing.ts +62 -109
  105. package/src/jobs/goals.ts +384 -0
  106. package/src/jobs/weeklyReview.ts +4 -3
  107. package/src/logTimestamps.ts +14 -0
  108. package/src/providerRecovery.ts +99 -0
  109. package/src/queue.ts +4 -0
  110. package/src/room/client.ts +84 -116
  111. package/src/room/computer.ts +1 -1
  112. package/src/room/durablePublish.ts +25 -0
  113. package/src/room/incidents.ts +20 -8
  114. package/src/room/turnQueue.ts +53 -56
  115. package/src/runtimeStore.ts +207 -0
  116. package/src/setup/server.ts +1 -1
  117. package/src/turnLog.ts +32 -75
  118. package/src/vault.ts +16 -7
  119. package/vendor/mcp-server/dist/index.js +2 -0
  120. package/vendor/mcp-server/dist/tools/goals.d.ts +4 -0
  121. package/vendor/mcp-server/dist/tools/goals.d.ts.map +1 -0
  122. package/vendor/mcp-server/dist/tools/goals.js +38 -0
  123. package/vendor/mcp-server/package.json +1 -1
  124. package/vendor/mcp-server/src/index.ts +2 -0
  125. package/vendor/mcp-server/src/tools/goals.ts +62 -0
  126. package/vendor/runtime/README.md +36 -2
  127. package/vendor/runtime/dist/executor/asyncQueue.d.ts +1 -0
  128. package/vendor/runtime/dist/executor/asyncQueue.d.ts.map +1 -1
  129. package/vendor/runtime/dist/executor/asyncQueue.js +3 -0
  130. package/vendor/runtime/dist/executor/claudeAgent.d.ts +5 -1
  131. package/vendor/runtime/dist/executor/claudeAgent.d.ts.map +1 -1
  132. package/vendor/runtime/dist/executor/claudeAgent.js +77 -13
  133. package/vendor/runtime/dist/executor/codex.d.ts +8 -2
  134. package/vendor/runtime/dist/executor/codex.d.ts.map +1 -1
  135. package/vendor/runtime/dist/executor/codex.js +113 -38
  136. package/vendor/runtime/dist/executor/codexProtocol/AgentPath.d.ts +2 -0
  137. package/vendor/runtime/dist/executor/codexProtocol/AgentPath.d.ts.map +1 -0
  138. package/vendor/runtime/dist/executor/codexProtocol/AgentPath.js +2 -0
  139. package/vendor/runtime/dist/executor/codexProtocol/FunctionCallOutputContentItem.d.ts +4 -1
  140. package/vendor/runtime/dist/executor/codexProtocol/FunctionCallOutputContentItem.d.ts.map +1 -1
  141. package/vendor/runtime/dist/executor/codexProtocol/ImageGenerationFailure.d.ts +6 -0
  142. package/vendor/runtime/dist/executor/codexProtocol/ImageGenerationFailure.d.ts.map +1 -0
  143. package/vendor/runtime/dist/executor/codexProtocol/ImageGenerationFailure.js +2 -0
  144. package/vendor/runtime/dist/executor/codexProtocol/ImageGenerationItem.d.ts +12 -0
  145. package/vendor/runtime/dist/executor/codexProtocol/ImageGenerationItem.d.ts.map +1 -0
  146. package/vendor/runtime/dist/executor/codexProtocol/ImageGenerationItem.js +2 -0
  147. package/vendor/runtime/dist/executor/codexProtocol/LegacyAppPathString.d.ts +24 -0
  148. package/vendor/runtime/dist/executor/codexProtocol/LegacyAppPathString.d.ts.map +1 -0
  149. package/vendor/runtime/dist/executor/codexProtocol/LegacyAppPathString.js +2 -0
  150. package/vendor/runtime/dist/executor/codexProtocol/MessagePhase.d.ts +8 -0
  151. package/vendor/runtime/dist/executor/codexProtocol/MessagePhase.d.ts.map +1 -0
  152. package/vendor/runtime/dist/executor/codexProtocol/MessagePhase.js +2 -0
  153. package/vendor/runtime/dist/executor/codexProtocol/Personality.d.ts +3 -0
  154. package/vendor/runtime/dist/executor/codexProtocol/Personality.d.ts.map +1 -1
  155. package/vendor/runtime/dist/executor/codexProtocol/PlanType.d.ts +1 -1
  156. package/vendor/runtime/dist/executor/codexProtocol/PlanType.d.ts.map +1 -1
  157. package/vendor/runtime/dist/executor/codexProtocol/SleepItem.d.ts +8 -0
  158. package/vendor/runtime/dist/executor/codexProtocol/SleepItem.d.ts.map +1 -0
  159. package/vendor/runtime/dist/executor/codexProtocol/SleepItem.js +2 -0
  160. package/vendor/runtime/dist/executor/codexProtocol/SubAgentSource.d.ts +14 -0
  161. package/vendor/runtime/dist/executor/codexProtocol/SubAgentSource.d.ts.map +1 -0
  162. package/vendor/runtime/dist/executor/codexProtocol/SubAgentSource.js +2 -0
  163. package/vendor/runtime/dist/executor/codexProtocol/ThreadId.d.ts +7 -0
  164. package/vendor/runtime/dist/executor/codexProtocol/ThreadId.d.ts.map +1 -0
  165. package/vendor/runtime/dist/executor/codexProtocol/ThreadId.js +2 -0
  166. package/vendor/runtime/dist/executor/codexProtocol/WebSearchItem.d.ts +15 -0
  167. package/vendor/runtime/dist/executor/codexProtocol/WebSearchItem.d.ts.map +1 -0
  168. package/vendor/runtime/dist/executor/codexProtocol/WebSearchItem.js +2 -0
  169. package/vendor/runtime/dist/executor/codexProtocol/v2/AgentMessageDelivery.d.ts +2 -0
  170. package/vendor/runtime/dist/executor/codexProtocol/v2/AgentMessageDelivery.d.ts.map +1 -0
  171. package/vendor/runtime/dist/executor/codexProtocol/v2/AgentMessageDelivery.js +2 -0
  172. package/vendor/runtime/dist/executor/codexProtocol/v2/AsyncUserInputQuestion.d.ts +5 -0
  173. package/vendor/runtime/dist/executor/codexProtocol/v2/AsyncUserInputQuestion.d.ts.map +1 -0
  174. package/vendor/runtime/dist/executor/codexProtocol/v2/AsyncUserInputQuestion.js +2 -0
  175. package/vendor/runtime/dist/executor/codexProtocol/v2/CodexErrorInfo.d.ts +29 -0
  176. package/vendor/runtime/dist/executor/codexProtocol/v2/CodexErrorInfo.d.ts.map +1 -0
  177. package/vendor/runtime/dist/executor/codexProtocol/v2/CodexErrorInfo.js +2 -0
  178. package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentState.d.ts +6 -0
  179. package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentState.d.ts.map +1 -0
  180. package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentState.js +2 -0
  181. package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentStatus.d.ts +2 -0
  182. package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentStatus.d.ts.map +1 -0
  183. package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentStatus.js +2 -0
  184. package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentTool.d.ts +2 -0
  185. package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentTool.d.ts.map +1 -0
  186. package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentTool.js +2 -0
  187. package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentToolCallStatus.d.ts +2 -0
  188. package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentToolCallStatus.d.ts.map +1 -0
  189. package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentToolCallStatus.js +2 -0
  190. package/vendor/runtime/dist/executor/codexProtocol/v2/CommandAction.d.ts +20 -0
  191. package/vendor/runtime/dist/executor/codexProtocol/v2/CommandAction.d.ts.map +1 -0
  192. package/vendor/runtime/dist/executor/codexProtocol/v2/CommandAction.js +2 -0
  193. package/vendor/runtime/dist/executor/codexProtocol/v2/CommandExecutionSource.d.ts +2 -0
  194. package/vendor/runtime/dist/executor/codexProtocol/v2/CommandExecutionSource.d.ts.map +1 -0
  195. package/vendor/runtime/dist/executor/codexProtocol/v2/CommandExecutionSource.js +2 -0
  196. package/vendor/runtime/dist/executor/codexProtocol/v2/CommandExecutionStatus.d.ts +2 -0
  197. package/vendor/runtime/dist/executor/codexProtocol/v2/CommandExecutionStatus.d.ts.map +1 -0
  198. package/vendor/runtime/dist/executor/codexProtocol/v2/CommandExecutionStatus.js +2 -0
  199. package/vendor/runtime/dist/executor/codexProtocol/v2/CyberAccessProgram.d.ts +6 -0
  200. package/vendor/runtime/dist/executor/codexProtocol/v2/CyberAccessProgram.d.ts.map +1 -0
  201. package/vendor/runtime/dist/executor/codexProtocol/v2/CyberAccessProgram.js +2 -0
  202. package/vendor/runtime/dist/executor/codexProtocol/v2/DynamicToolCallOutputContentItem.d.ts +11 -0
  203. package/vendor/runtime/dist/executor/codexProtocol/v2/DynamicToolCallOutputContentItem.d.ts.map +1 -0
  204. package/vendor/runtime/dist/executor/codexProtocol/v2/DynamicToolCallOutputContentItem.js +2 -0
  205. package/vendor/runtime/dist/executor/codexProtocol/v2/DynamicToolCallStatus.d.ts +2 -0
  206. package/vendor/runtime/dist/executor/codexProtocol/v2/DynamicToolCallStatus.d.ts.map +1 -0
  207. package/vendor/runtime/dist/executor/codexProtocol/v2/DynamicToolCallStatus.js +2 -0
  208. package/vendor/runtime/dist/executor/codexProtocol/v2/FileUpdateChange.d.ts +7 -0
  209. package/vendor/runtime/dist/executor/codexProtocol/v2/FileUpdateChange.d.ts.map +1 -0
  210. package/vendor/runtime/dist/executor/codexProtocol/v2/FileUpdateChange.js +2 -0
  211. package/vendor/runtime/dist/executor/codexProtocol/v2/GetAccountRateLimitsResponse.d.ts +5 -0
  212. package/vendor/runtime/dist/executor/codexProtocol/v2/GetAccountRateLimitsResponse.d.ts.map +1 -1
  213. package/vendor/runtime/dist/executor/codexProtocol/v2/GitInfo.d.ts +6 -0
  214. package/vendor/runtime/dist/executor/codexProtocol/v2/GitInfo.d.ts.map +1 -0
  215. package/vendor/runtime/dist/executor/codexProtocol/v2/GitInfo.js +2 -0
  216. package/vendor/runtime/dist/executor/codexProtocol/v2/HookPromptFragment.d.ts +5 -0
  217. package/vendor/runtime/dist/executor/codexProtocol/v2/HookPromptFragment.d.ts.map +1 -0
  218. package/vendor/runtime/dist/executor/codexProtocol/v2/HookPromptFragment.js +2 -0
  219. package/vendor/runtime/dist/executor/codexProtocol/v2/McpAppDisplayMode.d.ts +2 -0
  220. package/vendor/runtime/dist/executor/codexProtocol/v2/McpAppDisplayMode.d.ts.map +1 -0
  221. package/vendor/runtime/dist/executor/codexProtocol/v2/McpAppDisplayMode.js +2 -0
  222. package/vendor/runtime/dist/executor/codexProtocol/v2/McpAppUi.d.ts +9 -0
  223. package/vendor/runtime/dist/executor/codexProtocol/v2/McpAppUi.d.ts.map +1 -0
  224. package/vendor/runtime/dist/executor/codexProtocol/v2/McpAppUi.js +2 -0
  225. package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallAppContext.d.ts +8 -0
  226. package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallAppContext.d.ts.map +1 -0
  227. package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallAppContext.js +2 -0
  228. package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallError.d.ts +4 -0
  229. package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallError.d.ts.map +1 -0
  230. package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallError.js +2 -0
  231. package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallResult.d.ts +7 -0
  232. package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallResult.d.ts.map +1 -0
  233. package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallResult.js +2 -0
  234. package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallStatus.d.ts +2 -0
  235. package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallStatus.d.ts.map +1 -0
  236. package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallStatus.js +2 -0
  237. package/vendor/runtime/dist/executor/codexProtocol/v2/MemoryCitation.d.ts +6 -0
  238. package/vendor/runtime/dist/executor/codexProtocol/v2/MemoryCitation.d.ts.map +1 -0
  239. package/vendor/runtime/dist/executor/codexProtocol/v2/MemoryCitation.js +2 -0
  240. package/vendor/runtime/dist/executor/codexProtocol/v2/MemoryCitationEntry.d.ts +7 -0
  241. package/vendor/runtime/dist/executor/codexProtocol/v2/MemoryCitationEntry.d.ts.map +1 -0
  242. package/vendor/runtime/dist/executor/codexProtocol/v2/MemoryCitationEntry.js +2 -0
  243. package/vendor/runtime/dist/executor/codexProtocol/v2/MisalignmentErrorDetails.d.ts +16 -0
  244. package/vendor/runtime/dist/executor/codexProtocol/v2/MisalignmentErrorDetails.d.ts.map +1 -0
  245. package/vendor/runtime/dist/executor/codexProtocol/v2/MisalignmentErrorDetails.js +2 -0
  246. package/vendor/runtime/dist/executor/codexProtocol/v2/MisalignmentSteer.d.ts +4 -0
  247. package/vendor/runtime/dist/executor/codexProtocol/v2/MisalignmentSteer.d.ts.map +1 -0
  248. package/vendor/runtime/dist/executor/codexProtocol/v2/MisalignmentSteer.js +2 -0
  249. package/vendor/runtime/dist/executor/codexProtocol/v2/Model.d.ts +8 -0
  250. package/vendor/runtime/dist/executor/codexProtocol/v2/Model.d.ts.map +1 -1
  251. package/vendor/runtime/dist/executor/codexProtocol/v2/ModelAccessPrograms.d.ts +11 -0
  252. package/vendor/runtime/dist/executor/codexProtocol/v2/ModelAccessPrograms.d.ts.map +1 -0
  253. package/vendor/runtime/dist/executor/codexProtocol/v2/ModelAccessPrograms.js +2 -0
  254. package/vendor/runtime/dist/executor/codexProtocol/v2/NonSteerableTurnKind.d.ts +2 -0
  255. package/vendor/runtime/dist/executor/codexProtocol/v2/NonSteerableTurnKind.d.ts.map +1 -0
  256. package/vendor/runtime/dist/executor/codexProtocol/v2/NonSteerableTurnKind.js +2 -0
  257. package/vendor/runtime/dist/executor/codexProtocol/v2/PatchApplyStatus.d.ts +2 -0
  258. package/vendor/runtime/dist/executor/codexProtocol/v2/PatchApplyStatus.d.ts.map +1 -0
  259. package/vendor/runtime/dist/executor/codexProtocol/v2/PatchApplyStatus.js +2 -0
  260. package/vendor/runtime/dist/executor/codexProtocol/v2/PatchChangeKind.d.ts +9 -0
  261. package/vendor/runtime/dist/executor/codexProtocol/v2/PatchChangeKind.d.ts.map +1 -0
  262. package/vendor/runtime/dist/executor/codexProtocol/v2/PatchChangeKind.js +2 -0
  263. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitSnapshot.d.ts +4 -0
  264. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitSnapshot.d.ts.map +1 -1
  265. package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewStartParams.d.ts +2 -0
  266. package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewStartParams.d.ts.map +1 -1
  267. package/vendor/runtime/dist/executor/codexProtocol/v2/SessionSource.d.ts +7 -0
  268. package/vendor/runtime/dist/executor/codexProtocol/v2/SessionSource.d.ts.map +1 -0
  269. package/vendor/runtime/dist/executor/codexProtocol/v2/SessionSource.js +2 -0
  270. package/vendor/runtime/dist/executor/codexProtocol/v2/SubAgentActivityKind.d.ts +2 -0
  271. package/vendor/runtime/dist/executor/codexProtocol/v2/SubAgentActivityKind.d.ts.map +1 -0
  272. package/vendor/runtime/dist/executor/codexProtocol/v2/SubAgentActivityKind.js +2 -0
  273. package/vendor/runtime/dist/executor/codexProtocol/v2/Thread.d.ts +100 -0
  274. package/vendor/runtime/dist/executor/codexProtocol/v2/Thread.d.ts.map +1 -0
  275. package/vendor/runtime/dist/executor/codexProtocol/v2/Thread.js +2 -0
  276. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadActiveFlag.d.ts +2 -0
  277. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadActiveFlag.d.ts.map +1 -0
  278. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadActiveFlag.js +2 -0
  279. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadHistoryMode.d.ts +2 -0
  280. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadHistoryMode.d.ts.map +1 -0
  281. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadHistoryMode.js +2 -0
  282. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadItem.d.ts +216 -0
  283. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadItem.d.ts.map +1 -0
  284. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadItem.js +2 -0
  285. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadReadParams.d.ts +11 -0
  286. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadReadParams.d.ts.map +1 -0
  287. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadReadParams.js +2 -0
  288. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadReadResponse.d.ts +5 -0
  289. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadReadResponse.d.ts.map +1 -0
  290. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadReadResponse.js +2 -0
  291. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadResumeParams.d.ts +4 -1
  292. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadResumeParams.d.ts.map +1 -1
  293. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSection.d.ts +19 -0
  294. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSection.d.ts.map +1 -0
  295. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSection.js +2 -0
  296. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSectionAppearance.d.ts +8 -0
  297. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSectionAppearance.d.ts.map +1 -0
  298. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSectionAppearance.js +2 -0
  299. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadStartParams.d.ts +3 -1
  300. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadStartParams.d.ts.map +1 -1
  301. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadStatus.d.ts +12 -0
  302. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadStatus.d.ts.map +1 -0
  303. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadStatus.js +2 -0
  304. package/vendor/runtime/dist/executor/codexProtocol/v2/Turn.d.ts +36 -0
  305. package/vendor/runtime/dist/executor/codexProtocol/v2/Turn.d.ts.map +1 -0
  306. package/vendor/runtime/dist/executor/codexProtocol/v2/Turn.js +2 -0
  307. package/vendor/runtime/dist/executor/codexProtocol/v2/TurnError.d.ts +12 -0
  308. package/vendor/runtime/dist/executor/codexProtocol/v2/TurnError.d.ts.map +1 -0
  309. package/vendor/runtime/dist/executor/codexProtocol/v2/TurnError.js +2 -0
  310. package/vendor/runtime/dist/executor/codexProtocol/v2/TurnItemsView.d.ts +2 -0
  311. package/vendor/runtime/dist/executor/codexProtocol/v2/TurnItemsView.d.ts.map +1 -0
  312. package/vendor/runtime/dist/executor/codexProtocol/v2/TurnItemsView.js +2 -0
  313. package/vendor/runtime/dist/executor/codexProtocol/v2/TurnStartParams.d.ts +7 -2
  314. package/vendor/runtime/dist/executor/codexProtocol/v2/TurnStartParams.d.ts.map +1 -1
  315. package/vendor/runtime/dist/executor/codexProtocol/v2/TurnStatus.d.ts +2 -0
  316. package/vendor/runtime/dist/executor/codexProtocol/v2/TurnStatus.d.ts.map +1 -0
  317. package/vendor/runtime/dist/executor/codexProtocol/v2/TurnStatus.js +2 -0
  318. package/vendor/runtime/dist/executor/codexProtocol/v2/UserInput.d.ts +3 -0
  319. package/vendor/runtime/dist/executor/codexProtocol/v2/UserInput.d.ts.map +1 -1
  320. package/vendor/runtime/dist/executor/codexProtocol/v2/WebSearchAction.d.ts +15 -0
  321. package/vendor/runtime/dist/executor/codexProtocol/v2/WebSearchAction.d.ts.map +1 -0
  322. package/vendor/runtime/dist/executor/codexProtocol/v2/WebSearchAction.js +2 -0
  323. package/vendor/runtime/dist/executor/codexRpc.d.ts +13 -4
  324. package/vendor/runtime/dist/executor/codexRpc.d.ts.map +1 -1
  325. package/vendor/runtime/dist/executor/codexRpc.js +21 -5
  326. package/vendor/runtime/dist/executor/codexSessions.d.ts +30 -0
  327. package/vendor/runtime/dist/executor/codexSessions.d.ts.map +1 -0
  328. package/vendor/runtime/dist/executor/codexSessions.js +88 -0
  329. package/vendor/runtime/dist/executor/health.d.ts +8 -2
  330. package/vendor/runtime/dist/executor/health.d.ts.map +1 -1
  331. package/vendor/runtime/dist/executor/health.js +21 -5
  332. package/vendor/runtime/dist/executor/liveTurns.d.ts +2 -1
  333. package/vendor/runtime/dist/executor/liveTurns.d.ts.map +1 -1
  334. package/vendor/runtime/dist/executor/liveTurns.js +12 -5
  335. package/vendor/runtime/dist/executor/ownership.d.ts +40 -0
  336. package/vendor/runtime/dist/executor/ownership.d.ts.map +1 -0
  337. package/vendor/runtime/dist/executor/ownership.js +106 -0
  338. package/vendor/runtime/dist/executor/providerRouter.d.ts +1 -0
  339. package/vendor/runtime/dist/executor/providerRouter.d.ts.map +1 -1
  340. package/vendor/runtime/dist/executor/providerRouter.js +5 -0
  341. package/vendor/runtime/dist/executor/types.d.ts +27 -0
  342. package/vendor/runtime/dist/executor/types.d.ts.map +1 -1
  343. package/vendor/runtime/dist/harness/index.d.ts.map +1 -1
  344. package/vendor/runtime/dist/harness/index.js +1 -0
  345. package/vendor/runtime/dist/index.d.ts +2 -1
  346. package/vendor/runtime/dist/index.d.ts.map +1 -1
  347. package/vendor/runtime/dist/index.js +1 -0
  348. package/vendor/runtime/src/executor/asyncQueue.ts +3 -0
  349. package/vendor/runtime/src/executor/claudeAgent.ts +66 -13
  350. package/vendor/runtime/src/executor/codex.ts +124 -47
  351. package/vendor/runtime/src/executor/codexProtocol/AgentPath.ts +5 -0
  352. package/vendor/runtime/src/executor/codexProtocol/FunctionCallOutputContentItem.ts +1 -1
  353. package/vendor/runtime/src/executor/codexProtocol/ImageGenerationFailure.ts +5 -0
  354. package/vendor/runtime/src/executor/codexProtocol/ImageGenerationItem.ts +7 -0
  355. package/vendor/runtime/src/executor/codexProtocol/LegacyAppPathString.ts +27 -0
  356. package/vendor/runtime/src/executor/codexProtocol/MessagePhase.ts +11 -0
  357. package/vendor/runtime/src/executor/codexProtocol/Personality.ts +3 -0
  358. package/vendor/runtime/src/executor/codexProtocol/PlanType.ts +1 -1
  359. package/vendor/runtime/src/executor/codexProtocol/README.md +2 -2
  360. package/vendor/runtime/src/executor/codexProtocol/SleepItem.ts +8 -0
  361. package/vendor/runtime/src/executor/codexProtocol/SubAgentSource.ts +7 -0
  362. package/vendor/runtime/src/executor/codexProtocol/ThreadId.ts +10 -0
  363. package/vendor/runtime/src/executor/codexProtocol/WebSearchItem.ts +14 -0
  364. package/vendor/runtime/src/executor/codexProtocol/v2/AgentMessageDelivery.ts +5 -0
  365. package/vendor/runtime/src/executor/codexProtocol/v2/AsyncUserInputQuestion.ts +5 -0
  366. package/vendor/runtime/src/executor/codexProtocol/v2/CodexErrorInfo.ts +12 -0
  367. package/vendor/runtime/src/executor/codexProtocol/v2/CollabAgentState.ts +6 -0
  368. package/vendor/runtime/src/executor/codexProtocol/v2/CollabAgentStatus.ts +5 -0
  369. package/vendor/runtime/src/executor/codexProtocol/v2/CollabAgentTool.ts +5 -0
  370. package/vendor/runtime/src/executor/codexProtocol/v2/CollabAgentToolCallStatus.ts +5 -0
  371. package/vendor/runtime/src/executor/codexProtocol/v2/CommandAction.ts +6 -0
  372. package/vendor/runtime/src/executor/codexProtocol/v2/CommandExecutionSource.ts +5 -0
  373. package/vendor/runtime/src/executor/codexProtocol/v2/CommandExecutionStatus.ts +5 -0
  374. package/vendor/runtime/src/executor/codexProtocol/v2/CyberAccessProgram.ts +9 -0
  375. package/vendor/runtime/src/executor/codexProtocol/v2/DynamicToolCallOutputContentItem.ts +5 -0
  376. package/vendor/runtime/src/executor/codexProtocol/v2/DynamicToolCallStatus.ts +5 -0
  377. package/vendor/runtime/src/executor/codexProtocol/v2/FileUpdateChange.ts +6 -0
  378. package/vendor/runtime/src/executor/codexProtocol/v2/GetAccountRateLimitsResponse.ts +5 -0
  379. package/vendor/runtime/src/executor/codexProtocol/v2/GitInfo.ts +5 -0
  380. package/vendor/runtime/src/executor/codexProtocol/v2/HookPromptFragment.ts +5 -0
  381. package/vendor/runtime/src/executor/codexProtocol/v2/McpAppDisplayMode.ts +5 -0
  382. package/vendor/runtime/src/executor/codexProtocol/v2/McpAppUi.ts +9 -0
  383. package/vendor/runtime/src/executor/codexProtocol/v2/McpToolCallAppContext.ts +5 -0
  384. package/vendor/runtime/src/executor/codexProtocol/v2/McpToolCallError.ts +5 -0
  385. package/vendor/runtime/src/executor/codexProtocol/v2/McpToolCallResult.ts +6 -0
  386. package/vendor/runtime/src/executor/codexProtocol/v2/McpToolCallStatus.ts +5 -0
  387. package/vendor/runtime/src/executor/codexProtocol/v2/MemoryCitation.ts +6 -0
  388. package/vendor/runtime/src/executor/codexProtocol/v2/MemoryCitationEntry.ts +5 -0
  389. package/vendor/runtime/src/executor/codexProtocol/v2/MisalignmentErrorDetails.ts +18 -0
  390. package/vendor/runtime/src/executor/codexProtocol/v2/MisalignmentSteer.ts +5 -0
  391. package/vendor/runtime/src/executor/codexProtocol/v2/Model.ts +11 -2
  392. package/vendor/runtime/src/executor/codexProtocol/v2/ModelAccessPrograms.ts +13 -0
  393. package/vendor/runtime/src/executor/codexProtocol/v2/NonSteerableTurnKind.ts +5 -0
  394. package/vendor/runtime/src/executor/codexProtocol/v2/PatchApplyStatus.ts +5 -0
  395. package/vendor/runtime/src/executor/codexProtocol/v2/PatchChangeKind.ts +5 -0
  396. package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitSnapshot.ts +5 -1
  397. package/vendor/runtime/src/executor/codexProtocol/v2/ReviewStartParams.ts +2 -0
  398. package/vendor/runtime/src/executor/codexProtocol/v2/SessionSource.ts +6 -0
  399. package/vendor/runtime/src/executor/codexProtocol/v2/SubAgentActivityKind.ts +5 -0
  400. package/vendor/runtime/src/executor/codexProtocol/v2/Thread.ts +104 -0
  401. package/vendor/runtime/src/executor/codexProtocol/v2/ThreadActiveFlag.ts +5 -0
  402. package/vendor/runtime/src/executor/codexProtocol/v2/ThreadHistoryMode.ts +5 -0
  403. package/vendor/runtime/src/executor/codexProtocol/v2/ThreadItem.ts +125 -0
  404. package/vendor/runtime/src/executor/codexProtocol/v2/ThreadReadParams.ts +12 -0
  405. package/vendor/runtime/src/executor/codexProtocol/v2/ThreadReadResponse.ts +6 -0
  406. package/vendor/runtime/src/executor/codexProtocol/v2/ThreadResumeParams.ts +5 -1
  407. package/vendor/runtime/src/executor/codexProtocol/v2/ThreadSection.ts +21 -0
  408. package/vendor/runtime/src/executor/codexProtocol/v2/ThreadSectionAppearance.ts +8 -0
  409. package/vendor/runtime/src/executor/codexProtocol/v2/ThreadStartParams.ts +4 -1
  410. package/vendor/runtime/src/executor/codexProtocol/v2/ThreadStatus.ts +6 -0
  411. package/vendor/runtime/src/executor/codexProtocol/v2/Turn.ts +37 -0
  412. package/vendor/runtime/src/executor/codexProtocol/v2/TurnError.ts +11 -0
  413. package/vendor/runtime/src/executor/codexProtocol/v2/TurnItemsView.ts +5 -0
  414. package/vendor/runtime/src/executor/codexProtocol/v2/TurnStartParams.ts +7 -2
  415. package/vendor/runtime/src/executor/codexProtocol/v2/TurnStatus.ts +5 -0
  416. package/vendor/runtime/src/executor/codexProtocol/v2/UserInput.ts +1 -1
  417. package/vendor/runtime/src/executor/codexProtocol/v2/WebSearchAction.ts +5 -0
  418. package/vendor/runtime/src/executor/codexRpc.ts +26 -6
  419. package/vendor/runtime/src/executor/codexSessions.ts +108 -0
  420. package/vendor/runtime/src/executor/health.ts +21 -7
  421. package/vendor/runtime/src/executor/liveTurns.ts +12 -5
  422. package/vendor/runtime/src/executor/ownership.ts +83 -0
  423. package/vendor/runtime/src/executor/providerRouter.ts +6 -0
  424. package/vendor/runtime/src/executor/types.ts +20 -1
  425. package/vendor/runtime/src/harness/index.ts +1 -0
  426. package/vendor/runtime/src/index.ts +2 -1
  427. package/vendor/shared/dist/agentCommands.d.ts +1 -0
  428. package/vendor/shared/dist/agentCommands.d.ts.map +1 -1
  429. package/vendor/shared/dist/automations.d.ts +34 -0
  430. package/vendor/shared/dist/automations.d.ts.map +1 -1
  431. package/vendor/shared/dist/automations.js +12 -0
  432. package/vendor/shared/dist/cardStudio.d.ts +41 -0
  433. package/vendor/shared/dist/cardStudio.d.ts.map +1 -1
  434. package/vendor/shared/dist/cardStudio.js +13 -3
  435. package/vendor/shared/dist/computer.d.ts +7 -1
  436. package/vendor/shared/dist/computer.d.ts.map +1 -1
  437. package/vendor/shared/dist/computer.js +13 -4
  438. package/vendor/shared/dist/constants.d.ts +3 -3
  439. package/vendor/shared/dist/constants.d.ts.map +1 -1
  440. package/vendor/shared/dist/constants.js +8 -14
  441. package/vendor/shared/dist/goalNotes.d.ts +4 -0
  442. package/vendor/shared/dist/goalNotes.d.ts.map +1 -0
  443. package/vendor/shared/dist/goalNotes.js +23 -0
  444. package/vendor/shared/dist/goals.d.ts +835 -0
  445. package/vendor/shared/dist/goals.d.ts.map +1 -0
  446. package/vendor/shared/dist/goals.js +198 -0
  447. package/vendor/shared/dist/index.d.ts +7 -2
  448. package/vendor/shared/dist/index.d.ts.map +1 -1
  449. package/vendor/shared/dist/index.js +6 -1
  450. package/vendor/shared/dist/journal-vault.d.ts +1 -1
  451. package/vendor/shared/dist/messagingSafety.d.ts +21 -0
  452. package/vendor/shared/dist/messagingSafety.d.ts.map +1 -0
  453. package/vendor/shared/dist/messagingSafety.js +8 -0
  454. package/vendor/shared/dist/schemas/harness.d.ts +199 -169
  455. package/vendor/shared/dist/schemas/harness.d.ts.map +1 -1
  456. package/vendor/shared/dist/schemas/harness.js +25 -124
  457. package/vendor/shared/dist/smartCapture.d.ts +24 -0
  458. package/vendor/shared/dist/smartCapture.d.ts.map +1 -1
  459. package/vendor/shared/dist/smartCapture.js +15 -0
  460. package/vendor/shared/dist/taskSync.d.ts +342 -0
  461. package/vendor/shared/dist/taskSync.d.ts.map +1 -0
  462. package/vendor/shared/dist/taskSync.js +111 -0
  463. package/vendor/shared/dist/types.d.ts +1 -4
  464. package/vendor/shared/dist/types.d.ts.map +1 -1
  465. package/vendor/shared/dist/voiceCapture.d.ts +1 -1
  466. package/vendor/shared/dist/workspaces.d.ts +255 -0
  467. package/vendor/shared/dist/workspaces.d.ts.map +1 -0
  468. package/vendor/shared/dist/workspaces.js +89 -0
  469. package/vendor/shared/src/agentCommands.ts +1 -0
  470. package/vendor/shared/src/automations.ts +12 -0
  471. package/vendor/shared/src/cardStudio.ts +13 -3
  472. package/vendor/shared/src/computer.ts +19 -5
  473. package/vendor/shared/src/constants.ts +8 -14
  474. package/vendor/shared/src/goalNotes.ts +23 -0
  475. package/vendor/shared/src/goals.ts +237 -0
  476. package/vendor/shared/src/index.ts +7 -6
  477. package/vendor/shared/src/messagingSafety.ts +11 -0
  478. package/vendor/shared/src/schemas/harness.ts +24 -130
  479. package/vendor/shared/src/smartCapture.ts +27 -0
  480. package/vendor/shared/src/taskSync.ts +81 -0
  481. package/vendor/shared/src/types.ts +0 -6
  482. package/vendor/shared/src/workspaces.ts +103 -0
  483. package/dist/coding/conduct.d.ts +0 -69
  484. package/dist/coding/conduct.d.ts.map +0 -1
  485. package/dist/coding/conduct.js +0 -348
  486. package/dist/coding/fleetIntegrate.d.ts +0 -37
  487. package/dist/coding/fleetIntegrate.d.ts.map +0 -1
  488. package/dist/coding/fleetIntegrate.js +0 -64
  489. package/dist/coding/fleetPlan.d.ts +0 -20
  490. package/dist/coding/fleetPlan.d.ts.map +0 -1
  491. package/dist/coding/fleetPlan.js +0 -125
  492. package/dist/coding/fleetTasks.d.ts +0 -33
  493. package/dist/coding/fleetTasks.d.ts.map +0 -1
  494. package/dist/coding/fleetTasks.js +0 -75
  495. package/dist/coding/openFleetPr.d.ts +0 -41
  496. package/dist/coding/openFleetPr.d.ts.map +0 -1
  497. package/dist/coding/openFleetPr.js +0 -121
  498. package/src/coding/conduct.ts +0 -462
  499. package/src/coding/fleetIntegrate.ts +0 -95
  500. package/src/coding/fleetPlan.ts +0 -135
  501. package/src/coding/fleetTasks.ts +0 -109
  502. package/src/coding/openFleetPr.ts +0 -148
@@ -1,4 +1,4 @@
1
- import { mkdirSync, readFileSync, readdirSync, renameSync, writeFileSync, statSync, unlinkSync, } from 'node:fs';
1
+ import { mkdirSync, readFileSync, readdirSync, statSync, unlinkSync, } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { HarnessRequestSchema } from '@lucidity/shared';
4
4
  export function turnLane(req) {
@@ -17,6 +17,8 @@ export class DurableTurnQueue {
17
17
  constructor(deps) {
18
18
  this.deps = deps;
19
19
  mkdirSync(deps.dir, { recursive: true, mode: 0o700 });
20
+ for (const entry of deps.logs.runtime.list('queue'))
21
+ this.entries.set(entry.request.id, entry);
20
22
  for (const name of readdirSync(deps.dir)
21
23
  .filter((name) => name.endsWith('.json'))
22
24
  .sort()) {
@@ -26,6 +28,12 @@ export class DurableTurnQueue {
26
28
  unlinkSync(join(deps.dir, name));
27
29
  continue;
28
30
  }
31
+ if (this.entries.has(entry.request.id))
32
+ continue;
33
+ this.deps.logs.runtime.set('queue', entry.request.id, entry);
34
+ this.entries.set(entry.request.id, entry);
35
+ }
36
+ for (const entry of this.entries.values()) {
29
37
  const parsed = HarnessRequestSchema.parse(entry.request);
30
38
  if (parsed.kind !== 'ask' && parsed.kind !== 'code')
31
39
  throw new Error('Invalid queued turn');
@@ -41,7 +49,7 @@ export class DurableTurnQueue {
41
49
  });
42
50
  }
43
51
  else {
44
- this.fail(entry, 'Lucid restarted during this turn. It was not run again. Review the result before resending.');
52
+ this.fail(entry, 'Lucid restarted during this turn. It was not run again. Review its work before continuing.', 'interrupted_unknown');
45
53
  }
46
54
  }
47
55
  else if (entry.state === 'skipped' && !terminal) {
@@ -53,7 +61,7 @@ export class DurableTurnQueue {
53
61
  else if (entry.state === 'failed' && !terminal) {
54
62
  this.publish(parsed.id, {
55
63
  type: 'error',
56
- message: 'This queued turn could not finish. Review it before resending.',
64
+ ...(entry.failure ?? { message: 'This queued turn could not finish. Review it before resending.' }),
57
65
  });
58
66
  }
59
67
  }
@@ -67,12 +75,7 @@ export class DurableTurnQueue {
67
75
  }
68
76
  }
69
77
  save(entry) {
70
- const path = join(this.deps.dir, `${entry.request.id}.json`);
71
- writeFileSync(`${path}.tmp`, JSON.stringify(entry), {
72
- mode: 0o600,
73
- flush: true,
74
- });
75
- renameSync(`${path}.tmp`, path);
78
+ this.deps.logs.runtime.set('queue', entry.request.id, entry);
76
79
  this.entries.set(entry.request.id, entry);
77
80
  }
78
81
  publish(id, event) {
@@ -96,15 +99,16 @@ export class DurableTurnQueue {
96
99
  .find((frame) => typeof frame.sessionId === 'string')?.sessionId;
97
100
  return typeof value === 'string' ? value : undefined;
98
101
  }
99
- fail(entry, message) {
100
- this.save({ ...entry, state: 'failed' });
102
+ fail(entry, message, code) {
103
+ const failure = { message, ...(code ? { code } : {}) };
104
+ this.save({ ...entry, state: 'failed', failure });
101
105
  if (!this.deps.logs.read(entry.request.id).terminated)
102
- this.publish(entry.request.id, { type: 'error', message });
106
+ this.publish(entry.request.id, { type: 'error', ...failure });
103
107
  this.wake();
104
108
  }
105
109
  owns(id) {
106
110
  const state = this.entries.get(id)?.state;
107
- return state === 'queued' || state === 'running' || state === 'steering';
111
+ return state === 'queued' || state === 'held' || state === 'running' || state === 'steering';
108
112
  }
109
113
  confirm(id) {
110
114
  const entry = this.entries.get(id);
@@ -112,6 +116,7 @@ export class DurableTurnQueue {
112
116
  this.publish(id, {
113
117
  type: 'queue_state',
114
118
  state: entry.state === 'running' ? 'running' : 'queued',
119
+ ...(entry.blockedBy ? { blockedBy: entry.blockedBy, message: 'Held for review of the interrupted turn.' } : {}),
115
120
  });
116
121
  }
117
122
  enqueue(request) {
@@ -119,7 +124,7 @@ export class DurableTurnQueue {
119
124
  throw new Error('Queued turns require streaming replies.');
120
125
  const existing = this.entries.get(request.id);
121
126
  if (existing) {
122
- if (JSON.stringify(existing.request) !== JSON.stringify(request))
127
+ if (JSON.stringify(HarnessRequestSchema.parse(existing.request)) !== JSON.stringify(HarnessRequestSchema.parse(request)))
123
128
  throw new Error('Request ID already belongs to another message.');
124
129
  for (const frame of this.deps.logs.read(request.id).frames)
125
130
  this.deps.sendRaw(frame);
@@ -139,25 +144,18 @@ export class DurableTurnQueue {
139
144
  const same = scope &&
140
145
  (request.kind === 'ask'
141
146
  ? scope.kind === 'ask'
142
- : (scope.kind === 'code' &&
147
+ : scope.kind === 'code' &&
143
148
  scope.repoId === request.repoId &&
144
149
  scope.workerId === request.workerId &&
145
- (scope.mode ?? 'worktree') === (request.mode ?? 'worktree')) ||
146
- (scope.kind === 'conduct' &&
147
- scope.repoId === request.repoId &&
148
- !!request.workerId));
150
+ (scope.mode ?? 'worktree') === (request.mode ?? 'worktree'));
149
151
  if (!same)
150
152
  throw new Error('The preceding turn does not belong to this conversation. Refresh it before sending again.');
151
153
  }
152
154
  const entry = { request, state: 'queued' };
153
- this.save(entry);
154
- try {
155
- this.publish(request.id, { type: 'queue_state', state: 'queued' });
156
- }
157
- catch (error) {
158
- this.save({ ...entry, state: 'failed' });
159
- throw error;
160
- }
155
+ const accepted = this.deps.logs.runtime.accept(request, entry);
156
+ this.entries.set(request.id, entry);
157
+ for (const frame of accepted.frames)
158
+ this.deps.sendRaw(frame);
161
159
  this.wake();
162
160
  }
163
161
  /** Skipped queue entries inherit their predecessor, so removing B from A→B→C
@@ -170,6 +168,10 @@ export class DurableTurnQueue {
170
168
  if (previous) {
171
169
  if (previous.state === 'skipped')
172
170
  return this.predecessor(previous);
171
+ if (previous.state === 'held')
172
+ return { ready: false, blockedBy: previous.blockedBy ?? id };
173
+ if (previous.state === 'failed' && this.terminal(id)?.code === 'interrupted_unknown')
174
+ return { ready: false, blockedBy: id };
173
175
  if (previous.state === 'failed')
174
176
  throw new Error('The previous turn did not finish. Review it before resending this message.');
175
177
  if (previous.state !== 'done')
@@ -181,53 +183,56 @@ export class DurableTurnQueue {
181
183
  const terminal = this.terminal(id);
182
184
  if (!terminal)
183
185
  return { ready: false };
186
+ if (terminal.code === 'interrupted_unknown')
187
+ return { ready: false, blockedBy: id };
184
188
  if (terminal.type !== 'done')
185
189
  throw new Error('The previous turn did not finish. Review it before resending this message.');
186
- const receipt = this.deps.logs
187
- .read(id)
188
- .frames.find((frame) => frame.type === 'accepted');
189
- const scope = receipt?.scope;
190
- const source = scope?.kind === 'conduct' && entry.request.kind === 'code'
191
- ? entry.request.workerId
192
- : id;
193
- if (source !== id && this.terminal(source)?.type !== 'done')
194
- throw new Error('The worker did not finish. Review it before resending this message.');
195
- const resume = this.session(source);
190
+ const resume = this.session(id);
196
191
  if (!resume)
197
192
  throw new Error('The previous turn has no session to continue. Start a new conversation.');
198
193
  return { ready: true, resume };
199
194
  }
200
195
  wake() {
201
- if (this.stopped || this.pumping)
196
+ if (this.stopped || this.pumping || !this.deps.logs.runtime.writable)
202
197
  return;
203
198
  this.pumping = true;
204
199
  queueMicrotask(() => {
205
200
  this.pumping = false;
206
- if (this.stopped)
201
+ if (this.stopped || !this.deps.logs.runtime.writable)
207
202
  return;
208
203
  const occupied = new Set();
209
204
  for (const [id, entry] of this.entries) {
210
205
  const lane = turnLane(entry.request);
211
206
  if (!this.owns(id))
212
207
  continue;
208
+ if (entry.state === 'held')
209
+ continue;
213
210
  if (occupied.has(lane))
214
211
  continue;
215
- occupied.add(lane);
216
- if (entry.state !== 'queued' || this.scheduled.has(id))
212
+ if (entry.state !== 'queued' || this.scheduled.has(id)) {
213
+ occupied.add(lane);
217
214
  continue;
215
+ }
218
216
  try {
219
- if (!this.predecessor(entry).ready)
217
+ const previous = this.predecessor(entry);
218
+ if (!previous.ready) {
219
+ if (previous.blockedBy) {
220
+ this.save({ ...entry, state: 'held', blockedBy: previous.blockedBy });
221
+ this.confirm(id);
222
+ }
220
223
  continue;
224
+ }
221
225
  }
222
226
  catch (error) {
223
227
  this.fail(entry, String(error.message));
224
228
  continue;
225
229
  }
230
+ occupied.add(lane);
226
231
  this.scheduled.add(id);
227
232
  void this.deps.lanes
228
233
  .run(turnLane(entry.request), async () => {
229
234
  const current = this.entries.get(id);
230
- if (this.stopped || current.state !== 'queued')
235
+ if (this.stopped || !this.deps.logs.runtime.writable || current.state !== 'queued')
231
236
  return;
232
237
  const previous = this.predecessor(current);
233
238
  if (!previous.ready)
@@ -249,7 +254,10 @@ export class DurableTurnQueue {
249
254
  else
250
255
  this.fail(current, 'The turn ended before completion. Review it before resending.');
251
256
  })
252
- .catch((error) => this.fail(this.entries.get(id), String(error.message)))
257
+ .catch((error) => {
258
+ if (this.deps.logs.runtime.writable)
259
+ this.fail(this.entries.get(id), String(error.message));
260
+ })
253
261
  .finally(() => {
254
262
  this.scheduled.delete(id);
255
263
  this.wake();
@@ -267,15 +275,16 @@ export class DurableTurnQueue {
267
275
  this.deps.sendRaw(frame);
268
276
  return;
269
277
  }
270
- if (entry.state !== 'queued')
278
+ if (entry.state !== 'queued' && entry.state !== 'held')
271
279
  throw new Error('This message has already started or left the queue.');
272
280
  if (action === 'steer') {
281
+ if (entry.state === 'held')
282
+ throw new Error('Review the interrupted turn before using this follow-up.');
273
283
  if (entry.request.images?.length)
274
284
  throw new Error('Attachments must run as a separate turn.');
275
285
  if (!activeId || !this.deps.steer)
276
286
  throw new Error('There is no active turn to influence.');
277
287
  const active = this.entries.get(activeId);
278
- // For a spawned fleet worker, the active request uses the worker's own ID.
279
288
  if (active
280
289
  ? turnLane(active.request) !== turnLane(entry.request) ||
281
290
  active.state !== 'running'
@@ -0,0 +1,46 @@
1
+ import type { HarnessRequest } from '@lucidity/shared';
2
+ import type { TurnFrame, TurnState } from './turnLog.js';
3
+ export declare function conversationKey(request: {
4
+ kind: string;
5
+ repoId?: string;
6
+ workerId?: string;
7
+ mode?: string;
8
+ }): string;
9
+ /** Local execution authority. Transactions commit before their receipts reach the transport. */
10
+ export declare class RuntimeStore {
11
+ private db;
12
+ private storageError?;
13
+ get writable(): boolean;
14
+ private write;
15
+ constructor(path: string);
16
+ transaction<T>(action: () => T): T;
17
+ get<T>(bucket: string, id: string): T | undefined;
18
+ set(bucket: string, id: string, value: unknown): void;
19
+ delete(bucket: string, id: string): void;
20
+ list<T>(bucket: string): T[];
21
+ /** The command and its first replayable receipt are one durable operation. */
22
+ accept(request: HarnessRequest, queuedEntry?: unknown): {
23
+ duplicate: boolean;
24
+ frames: TurnFrame[];
25
+ };
26
+ private appendInside;
27
+ append(id: string, event: Record<string, unknown>): TurnFrame;
28
+ status(id: string): Omit<TurnState, 'frames'>;
29
+ read(id: string): TurnState;
30
+ importLog(id: string, state: TurnState): void;
31
+ commands(conversation: string, page?: {
32
+ before?: string;
33
+ after?: string;
34
+ limit: number;
35
+ }): {
36
+ request: HarnessRequest;
37
+ state: TurnState;
38
+ }[];
39
+ latestSession(conversation: string, after?: string): string | undefined;
40
+ lastCommand(conversation: string): string | undefined;
41
+ command(id: string): HarnessRequest | undefined;
42
+ unfinished(conversation: string): boolean;
43
+ reconcile(owns: (id: string) => boolean): void;
44
+ close(): void;
45
+ }
46
+ //# sourceMappingURL=runtimeStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeStore.d.ts","sourceRoot":"","sources":["../src/runtimeStore.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAa,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAWzD,wBAAgB,eAAe,CAAC,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAIpH;AAED,gGAAgG;AAChG,qBAAa,YAAY;IACvB,OAAO,CAAC,EAAE,CAAM;IAChB,OAAO,CAAC,YAAY,CAAC,CAAQ;IAC7B,IAAI,QAAQ,IAAI,OAAO,CAA+B;IACtD,OAAO,CAAC,KAAK;gBAUD,IAAI,EAAE,MAAM;IAyBxB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC;IAclC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAIjD,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAIrD,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI;IAGxC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,EAAE;IAK5B,8EAA8E;IAC9E,MAAM,CAAC,OAAO,EAAE,cAAc,EAAE,WAAW,CAAC,EAAE,OAAO,GAAG;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,SAAS,EAAE,CAAA;KAAE;IAkCnG,OAAO,CAAC,YAAY;IAiBpB,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;IAI7D,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC;IAI7C,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;IAQ3B,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI;IAW7C,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,OAAO,EAAE,cAAc,CAAC;QAAC,KAAK,EAAE,SAAS,CAAA;KAAE,EAAE;IAS1I,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAOvE,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAGrD,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAI/C,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;IAIzC,SAAS,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI;IAO9C,KAAK,IAAI,IAAI;CACd"}
@@ -0,0 +1,205 @@
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 { dirname } from 'node:path';
5
+ const terminalTypes = new Set(['done', 'error', 'cancelled']);
6
+ function canonical(value) {
7
+ if (Array.isArray(value))
8
+ return `[${value.map(canonical).join(',')}]`;
9
+ if (value && typeof value === 'object')
10
+ return `{${Object.entries(value).filter(([, v]) => v !== undefined).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => `${JSON.stringify(k)}:${canonical(v)}`).join(',')}}`;
11
+ return JSON.stringify(value);
12
+ }
13
+ export function conversationKey(request) {
14
+ return request.kind === 'code'
15
+ ? JSON.stringify(['code', request.repoId, request.workerId ?? request.mode ?? 'worktree'])
16
+ : request.kind;
17
+ }
18
+ /** Local execution authority. Transactions commit before their receipts reach the transport. */
19
+ export class RuntimeStore {
20
+ db;
21
+ storageError;
22
+ get writable() { return !this.storageError; }
23
+ write(action) {
24
+ if (this.storageError)
25
+ throw new Error(`Runtime storage is unavailable until restart: ${this.storageError.message}`);
26
+ try {
27
+ return action();
28
+ }
29
+ catch (error) {
30
+ const code = error?.code ?? '';
31
+ if (code.includes('SQLITE') || code === 'ERR_INVALID_STATE')
32
+ this.storageError = error instanceof Error ? error : new Error(String(error));
33
+ throw error;
34
+ }
35
+ }
36
+ constructor(path) {
37
+ mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
38
+ this.db = new DatabaseSync(path);
39
+ chmodSync(path, 0o600);
40
+ this.db.exec(`
41
+ PRAGMA journal_mode=WAL;
42
+ PRAGMA synchronous=FULL;
43
+ PRAGMA busy_timeout=5000;
44
+ CREATE TABLE IF NOT EXISTS runs (
45
+ id TEXT PRIMARY KEY, command TEXT, conversation TEXT,
46
+ state TEXT NOT NULL DEFAULT 'accepted', cursor INTEGER NOT NULL DEFAULT 0,
47
+ terminal TEXT, updated INTEGER NOT NULL
48
+ );
49
+ CREATE INDEX IF NOT EXISTS runs_conversation ON runs(conversation, updated);
50
+ CREATE TABLE IF NOT EXISTS events (
51
+ run_id TEXT NOT NULL, seq INTEGER NOT NULL, frame TEXT NOT NULL,
52
+ PRIMARY KEY(run_id, seq)
53
+ );
54
+ CREATE TABLE IF NOT EXISTS records (
55
+ bucket TEXT NOT NULL, id TEXT NOT NULL, value TEXT NOT NULL,
56
+ PRIMARY KEY(bucket, id)
57
+ );
58
+ `);
59
+ }
60
+ transaction(action) {
61
+ return this.write(() => {
62
+ this.db.exec('BEGIN IMMEDIATE');
63
+ try {
64
+ const result = action();
65
+ this.db.exec('COMMIT');
66
+ return result;
67
+ }
68
+ catch (error) {
69
+ try {
70
+ this.db.exec('ROLLBACK');
71
+ }
72
+ catch { /* preserve the original storage failure */ }
73
+ throw error;
74
+ }
75
+ });
76
+ }
77
+ get(bucket, id) {
78
+ const row = this.db.prepare('SELECT value FROM records WHERE bucket=? AND id=?').get(bucket, id);
79
+ return row ? JSON.parse(row.value) : undefined;
80
+ }
81
+ set(bucket, id, value) {
82
+ this.write(() => this.db.prepare('INSERT INTO records VALUES (?, ?, ?) ON CONFLICT(bucket,id) DO UPDATE SET value=excluded.value')
83
+ .run(bucket, id, JSON.stringify(value)));
84
+ }
85
+ delete(bucket, id) {
86
+ this.write(() => this.db.prepare('DELETE FROM records WHERE bucket=? AND id=?').run(bucket, id));
87
+ }
88
+ list(bucket) {
89
+ return this.db.prepare('SELECT value FROM records WHERE bucket=? ORDER BY rowid').all(bucket)
90
+ .map((row) => JSON.parse(row.value));
91
+ }
92
+ /** The command and its first replayable receipt are one durable operation. */
93
+ accept(request, queuedEntry) {
94
+ return this.transaction(() => {
95
+ const payload = canonical(request);
96
+ const old = this.db.prepare('SELECT command, cursor FROM runs WHERE id=?').get(request.id);
97
+ if (old?.command && old.command !== payload)
98
+ throw new Error('This request ID already belongs to different input.');
99
+ if (old)
100
+ return { duplicate: true, frames: this.read(request.id).frames };
101
+ if (request.kind === 'code' && request.recoveryOf) {
102
+ const review = this.get('run-reviews', request.recoveryOf);
103
+ const source = this.command(request.recoveryOf);
104
+ if (!review || review.reviewId !== request.recoveryReviewId || review.continuationId !== request.id ||
105
+ source?.kind !== 'code' || conversationKey(source) !== conversationKey(request) ||
106
+ this.read(source.id).frames.at(-1)?.code !== 'interrupted_unknown' ||
107
+ review.continuedAt || !request.prompt.trim() || request.prompt.trim().startsWith('/') || request.prompt.trim() === source.prompt.trim())
108
+ throw new Error('A current review is required before continuing this interrupted turn.');
109
+ this.set('run-reviews', source.id, { ...review, continuedAt: new Date().toISOString(), instruction: request.prompt });
110
+ }
111
+ this.db.prepare('INSERT INTO runs (id,command,conversation,updated) VALUES (?,?,?,?)')
112
+ .run(request.id, payload, conversationKey(request), Date.now());
113
+ const scope = {
114
+ kind: request.kind,
115
+ ...('repoId' in request ? { repoId: request.repoId } : {}),
116
+ ...('workerId' in request ? { workerId: request.workerId } : {}),
117
+ ...('mode' in request ? { mode: request.mode } : {}),
118
+ };
119
+ const frames = [this.appendInside(request.id, { type: 'accepted', requestId: request.id, scope })];
120
+ if (queuedEntry) {
121
+ this.set('queue', request.id, queuedEntry);
122
+ frames.push(this.appendInside(request.id, { type: 'queue_state', requestId: request.id, state: 'queued' }));
123
+ }
124
+ return { duplicate: false, frames };
125
+ });
126
+ }
127
+ appendInside(id, event) {
128
+ this.db.prepare('INSERT OR IGNORE INTO runs (id,updated) VALUES (?,?)').run(id, Date.now());
129
+ const run = this.db.prepare('SELECT cursor, terminal FROM runs WHERE id=?').get(id);
130
+ if (run.terminal) {
131
+ // Reconfirm the committed outcome, never continue a completed attempt.
132
+ this.set('protocol-fault', id, { type: event.type, at: new Date().toISOString() });
133
+ return JSON.parse(run.terminal);
134
+ }
135
+ const frame = { ...event, seq: run.cursor + 1 };
136
+ const serialized = JSON.stringify(frame);
137
+ const terminal = terminalTypes.has(String(event.type));
138
+ const state = terminal ? String(event.type) : event.type === 'accepted' ? 'accepted' : event.type === 'queue_state' ? String(event.state) : 'running';
139
+ this.db.prepare('INSERT INTO events VALUES (?,?,?)').run(id, frame.seq, serialized);
140
+ this.db.prepare('UPDATE runs SET cursor=?, terminal=?, state=?, updated=? WHERE id=?')
141
+ .run(frame.seq, terminal ? serialized : null, state, Date.now(), id);
142
+ return frame;
143
+ }
144
+ append(id, event) {
145
+ return this.transaction(() => this.appendInside(id, event));
146
+ }
147
+ status(id) {
148
+ const run = this.db.prepare('SELECT cursor, terminal FROM runs WHERE id=?').get(id);
149
+ return { exists: !!run, maxSeq: run?.cursor ?? 0, terminated: !!run?.terminal };
150
+ }
151
+ read(id) {
152
+ const status = this.status(id);
153
+ if (!status.exists)
154
+ return { ...status, frames: [] };
155
+ const frames = this.db.prepare('SELECT frame FROM events WHERE run_id=? ORDER BY seq').all(id)
156
+ .map((row) => JSON.parse(row.frame));
157
+ return { ...status, frames };
158
+ }
159
+ importLog(id, state) {
160
+ if (!state.exists || this.read(id).exists)
161
+ return;
162
+ this.transaction(() => {
163
+ const last = [...state.frames].reverse().find((f) => terminalTypes.has(String(f.type)));
164
+ this.db.prepare('INSERT OR IGNORE INTO runs (id,cursor,terminal,state,updated) VALUES (?,?,?,?,?)')
165
+ .run(id, state.maxSeq, last ? JSON.stringify(last) : null, last ? String(last.type) : 'interrupted_unknown', Date.now());
166
+ for (const frame of state.frames)
167
+ this.db.prepare('INSERT OR IGNORE INTO events VALUES (?,?,?)').run(id, frame.seq, JSON.stringify(frame));
168
+ });
169
+ }
170
+ commands(conversation, page) {
171
+ const rows = page
172
+ ? this.db.prepare(`SELECT id,command FROM runs WHERE conversation=? AND command IS NOT NULL
173
+ AND rowid < COALESCE((SELECT rowid FROM runs WHERE id=?), 9223372036854775807)
174
+ AND rowid > COALESCE((SELECT rowid FROM runs WHERE id=?), 0)
175
+ ORDER BY rowid DESC LIMIT ?`).all(conversation, page.before ?? '', page.after ?? '', page.limit).reverse()
176
+ : this.db.prepare('SELECT id,command FROM runs WHERE conversation=? AND command IS NOT NULL ORDER BY rowid').all(conversation);
177
+ return rows.map((row) => ({ request: JSON.parse(row.command), state: this.read(row.id) }));
178
+ }
179
+ latestSession(conversation, after) {
180
+ return this.db.prepare(`SELECT json_extract(events.frame, '$.sessionId') AS session
181
+ FROM runs JOIN events ON events.run_id=runs.id WHERE runs.conversation=?
182
+ AND json_type(events.frame, '$.sessionId')='text'
183
+ AND runs.rowid > COALESCE((SELECT rowid FROM runs WHERE id=?), 0)
184
+ ORDER BY runs.rowid DESC, events.seq DESC LIMIT 1`).get(conversation, after ?? '')?.session;
185
+ }
186
+ lastCommand(conversation) {
187
+ return this.db.prepare('SELECT id FROM runs WHERE conversation=? AND command IS NOT NULL ORDER BY rowid DESC LIMIT 1').get(conversation)?.id;
188
+ }
189
+ command(id) {
190
+ const row = this.db.prepare('SELECT command FROM runs WHERE id=?').get(id);
191
+ return row?.command ? JSON.parse(row.command) : undefined;
192
+ }
193
+ unfinished(conversation) {
194
+ return !!this.db.prepare('SELECT id FROM runs WHERE conversation=? AND terminal IS NULL LIMIT 1').get(conversation);
195
+ }
196
+ reconcile(owns) {
197
+ for (const row of this.db.prepare('SELECT id FROM runs WHERE terminal IS NULL').all()) {
198
+ if (owns(row.id))
199
+ continue;
200
+ this.append(row.id, { type: 'error', requestId: row.id, code: 'interrupted_unknown',
201
+ message: 'Lucid restarted before this turn settled. It was not run again. Review its work before continuing.' });
202
+ }
203
+ }
204
+ close() { this.db.close(); }
205
+ }
@@ -86,7 +86,7 @@ export async function checkSetupProviders() {
86
86
  };
87
87
  }
88
88
  catch (e) {
89
- const health = providerFailure(e);
89
+ const health = providerFailure(e) ?? { auth: 'unknown', problem: 'unavailable' };
90
90
  return {
91
91
  id,
92
92
  label: id === 'claude' ? 'Claude' : 'Codex',
package/dist/turnLog.d.ts CHANGED
@@ -1,19 +1,8 @@
1
+ import { RuntimeStore } from './runtimeStore.js';
1
2
  /**
2
- * Durable per-turn write-ahead log (WAL) so a dropped reply can be pulled back by the
3
- * phone instead of being lost. Each streamed turn gets one append-only file
4
- * `~/.lucidity/turns/<requestId>.jsonl`; every outgoing daemon→phone stream frame is
5
- * appended (with a monotonic `seq`) BEFORE it goes on the socket, so a frame produced
6
- * while the socket is down — or while the phone is away — survives on disk. The phone
7
- * recovers by sending a `pull` request; the daemon replays `readState().frames` after
8
- * the phone's `sinceSeq`.
9
- *
10
- * The daemon OWNS `seq` here (starting at 1, per requestId). This is the linchpin of the
11
- * whole recovery scheme: the same `seq` must appear on the live-forwarded frame, the
12
- * server's replay-on-rejoin, and a daemon pull, so the phone can de-dup across all three.
13
- * The relay forwards frames verbatim (it no longer stamps `seq`).
14
- *
15
- * Never throws — a logging or disk error must not take a turn down; it just makes that
16
- * turn unrecoverable (the live frame still goes out). Mirrors `runlog.ts`.
3
+ * SQLite owns command receipts and ordered run events. JSONL files remain bounded
4
+ * diagnostic exports and are imported once when opening an older installation.
5
+ * A storage failure rejects admission or propagates to the execution owner.
17
6
  */
18
7
  /** A logged frame: the exact wire frame plus its daemon-authored `seq`. */
19
8
  export type TurnFrame = Record<string, unknown> & {
@@ -35,34 +24,13 @@ export interface TurnState {
35
24
  export declare const MAX_TURN_LOG_BYTES: number;
36
25
  /** Default retention: prune turn logs untouched for 24h. */
37
26
  export declare const TURN_LOG_MAX_AGE_MS: number;
38
- /**
39
- * One turn's log. Owns the per-requestId `seq` counter (a shared handle, NOT a closure
40
- * local, so a concurrent `cancel`'s terminal frame gets the next `seq` on the same
41
- * counter). Seeds itself from any existing file so seq keeps climbing across a daemon
42
- * restart (a re-created handle resumes from the file's `maxSeq`).
43
- */
44
- export declare class TurnLog {
45
- private readonly path;
46
- private readonly maxBytes;
47
- private nextSeq;
48
- private bytes;
49
- private terminatedFlag;
50
- constructor(requestId: string, dir: string, maxBytes?: number);
51
- get terminated(): boolean;
52
- /** Stamp the next `seq`, append the frame (unless a droppable delta past the byte cap),
53
- * and return the stamped frame to put on the wire. */
54
- write(event: Record<string, unknown>): TurnFrame;
55
- }
56
- /**
57
- * All turn logs for this daemon. Keeps an in-memory {@link TurnLog} per in-flight turn
58
- * (the live seq counter), dropped once the turn terminates — the file lives on for 24h.
59
- * The file is the source of truth for replay ({@link read}).
60
- */
27
+ /** Compatibility reader/exporter around the transactional local runtime ledger. */
61
28
  export declare class TurnLogStore {
62
29
  private readonly dir;
63
30
  private readonly clock;
64
31
  private readonly maxBytes;
65
- private readonly logs;
32
+ private readonly exportBytes;
33
+ readonly runtime: RuntimeStore;
66
34
  queueDirectory(): string;
67
35
  constructor(opts?: {
68
36
  dir?: string;
@@ -71,8 +39,10 @@ export declare class TurnLogStore {
71
39
  });
72
40
  /** Log + stamp one outgoing stream frame; returns the stamped frame to send. */
73
41
  append(requestId: string, event: Record<string, unknown>): TurnFrame;
74
- /** The durable state of a turn, read from disk — for serving a `pull`. */
75
42
  read(requestId: string): TurnState;
43
+ /** Startup recovery is independent of whether a phone asks to replay a turn. */
44
+ reconcile(owns: (id: string) => boolean): void;
45
+ close(): void;
76
46
  /** Delete turn logs whose file hasn't been touched in `maxAgeMs`. Never throws. */
77
47
  prune(maxAgeMs?: number): void;
78
48
  }
@@ -1 +1 @@
1
- {"version":3,"file":"turnLog.d.ts","sourceRoot":"","sources":["../src/turnLog.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;;GAgBG;AAEH,2EAA2E;AAC3E,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAElE,MAAM,WAAW,SAAS;IACxB,kFAAkF;IAClF,MAAM,EAAE,OAAO,CAAC;IAChB,8CAA8C;IAC9C,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,UAAU,EAAE,OAAO,CAAC;CACrB;AAUD;;sFAEsF;AACtF,eAAO,MAAM,kBAAkB,QAAmB,CAAC;AAEnD,4DAA4D;AAC5D,eAAO,MAAM,mBAAmB,QAAsB,CAAC;AA0DvD;;;;;GAKG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,cAAc,CAAU;gBAEpB,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,SAAqB;IASzE,IAAI,UAAU,IAAI,OAAO,CAExB;IAED;2DACuD;IACvD,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;CAajD;AAED;;;;GAIG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;IACrC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA8B;IAEnD,cAAc,IAAI,MAAM;gBAKtB,IAAI,GAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAO;IAYpE,gFAAgF;IAChF,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;IAWpE,0EAA0E;IAC1E,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS;IAOlC,mFAAmF;IACnF,KAAK,CAAC,QAAQ,GAAE,MAA4B,GAAG,IAAI;CAkBpD"}
1
+ {"version":3,"file":"turnLog.d.ts","sourceRoot":"","sources":["../src/turnLog.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;;;GAIG;AAEH,2EAA2E;AAC3E,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAElE,MAAM,WAAW,SAAS;IACxB,kFAAkF;IAClF,MAAM,EAAE,OAAO,CAAC;IAChB,8CAA8C;IAC9C,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,UAAU,EAAE,OAAO,CAAC;CACrB;AAUD;;sFAEsF;AACtF,eAAO,MAAM,kBAAkB,QAAmB,CAAC;AAEnD,4DAA4D;AAC5D,eAAO,MAAM,mBAAmB,QAAsB,CAAC;AA0DvD,mFAAmF;AACnF,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;IACrC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA6B;IACzD,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAE/B,cAAc,IAAI,MAAM;gBAKtB,IAAI,GAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAO;IAapE,gFAAgF;IAChF,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;IAgBpE,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS;IAOlC,gFAAgF;IAChF,SAAS,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI;IAM9C,KAAK,IAAI,IAAI;IAEb,mFAAmF;IACnF,KAAK,CAAC,QAAQ,GAAE,MAA4B,GAAG,IAAI;CAkBpD"}