@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
@@ -152,6 +152,8 @@ export interface IncidentBundle {
152
152
  snapshot?: IncidentSnapshot;
153
153
  /** The tail of the phone's diag ring, when the frame carried it. */
154
154
  phoneDiag?: IncidentDiagEvent[];
155
+ /** The phone's stutter-meter reading, when the frame carried one. */
156
+ perf?: Record<string, unknown>;
155
157
  }
156
158
 
157
159
  /** Severity for picking which turn a bundle headlines. Higher = worse. */
@@ -282,6 +284,7 @@ export interface BuildIncidentOptions {
282
284
  /** The phone socket snapshot + diag ring, when the frame carried them — feeds the detectors. */
283
285
  snapshot?: IncidentSnapshot;
284
286
  diag?: IncidentDiagEvent[];
287
+ perf?: Record<string, unknown>;
285
288
  now?: () => number;
286
289
  }
287
290
 
@@ -408,6 +411,7 @@ export function buildIncidentBundle(
408
411
  timeline: opts.timeline,
409
412
  ...(opts.snapshot ? { snapshot: opts.snapshot } : {}),
410
413
  ...(opts.diag ? { phoneDiag: opts.diag } : {}),
414
+ ...(opts.perf ? { perf: opts.perf } : {}),
411
415
  };
412
416
  }
413
417
 
@@ -13,7 +13,8 @@ import { LaneQueue } from '../queue.js';
13
13
  type Request = Extract<HarnessRequest, { kind: 'ask' | 'code' }>;
14
14
  type Entry = {
15
15
  request: Request;
16
- state: 'queued' | 'running' | 'steering' | 'done' | 'failed' | 'skipped';
16
+ state: 'queued' | 'held' | 'running' | 'steering' | 'done' | 'failed' | 'skipped';
17
+ blockedBy?: string;
17
18
  action?: 'cancel' | 'steer';
18
19
  resume?: string;
19
20
  failure?: { message: string; code?: string };
@@ -148,7 +149,7 @@ export class DurableTurnQueue {
148
149
  }
149
150
  owns(id: string): boolean {
150
151
  const state = this.entries.get(id)?.state;
151
- return state === 'queued' || state === 'running' || state === 'steering';
152
+ return state === 'queued' || state === 'held' || state === 'running' || state === 'steering';
152
153
  }
153
154
  confirm(id: string): void {
154
155
  const entry = this.entries.get(id);
@@ -156,6 +157,7 @@ export class DurableTurnQueue {
156
157
  this.publish(id, {
157
158
  type: 'queue_state',
158
159
  state: entry.state === 'running' ? 'running' : 'queued',
160
+ ...(entry.blockedBy ? { blockedBy: entry.blockedBy, message: 'Held for review of the interrupted turn.' } : {}),
159
161
  });
160
162
  }
161
163
  enqueue(request: Request): void {
@@ -163,7 +165,7 @@ export class DurableTurnQueue {
163
165
  throw new Error('Queued turns require streaming replies.');
164
166
  const existing = this.entries.get(request.id);
165
167
  if (existing) {
166
- if (JSON.stringify(existing.request) !== JSON.stringify(request))
168
+ if (JSON.stringify(HarnessRequestSchema.parse(existing.request)) !== JSON.stringify(HarnessRequestSchema.parse(request)))
167
169
  throw new Error('Request ID already belongs to another message.');
168
170
  for (const frame of this.deps.logs.read(request.id).frames)
169
171
  this.deps.sendRaw(frame);
@@ -189,13 +191,10 @@ export class DurableTurnQueue {
189
191
  scope &&
190
192
  (request.kind === 'ask'
191
193
  ? scope.kind === 'ask'
192
- : (scope.kind === 'code' &&
193
- scope.repoId === request.repoId &&
194
- scope.workerId === request.workerId &&
195
- (scope.mode ?? 'worktree') === (request.mode ?? 'worktree')) ||
196
- (scope.kind === 'conduct' &&
197
- scope.repoId === request.repoId &&
198
- !!request.workerId));
194
+ : scope.kind === 'code' &&
195
+ scope.repoId === request.repoId &&
196
+ scope.workerId === request.workerId &&
197
+ (scope.mode ?? 'worktree') === (request.mode ?? 'worktree'));
199
198
  if (!same)
200
199
  throw new Error(
201
200
  'The preceding turn does not belong to this conversation. Refresh it before sending again.',
@@ -210,12 +209,14 @@ export class DurableTurnQueue {
210
209
 
211
210
  /** Skipped queue entries inherit their predecessor, so removing B from A→B→C
212
211
  * never starts a new conversation or strands C. Failed executions stop dependants. */
213
- private predecessor(entry: Entry): { ready: boolean; resume?: string } {
212
+ private predecessor(entry: Entry): { ready: boolean; resume?: string; blockedBy?: string } {
214
213
  const id = entry.request.afterRequestId;
215
214
  if (!id) return { ready: true, resume: entry.request.resume };
216
215
  const previous = this.entries.get(id);
217
216
  if (previous) {
218
217
  if (previous.state === 'skipped') return this.predecessor(previous);
218
+ if (previous.state === 'held') return { ready: false, blockedBy: previous.blockedBy ?? id };
219
+ if (previous.state === 'failed' && this.terminal(id)?.code === 'interrupted_unknown') return { ready: false, blockedBy: id };
219
220
  if (previous.state === 'failed')
220
221
  throw new Error(
221
222
  'The previous turn did not finish. Review it before resending this message.',
@@ -229,23 +230,12 @@ export class DurableTurnQueue {
229
230
  }
230
231
  const terminal = this.terminal(id);
231
232
  if (!terminal) return { ready: false };
233
+ if (terminal.code === 'interrupted_unknown') return { ready: false, blockedBy: id };
232
234
  if (terminal.type !== 'done')
233
235
  throw new Error(
234
236
  'The previous turn did not finish. Review it before resending this message.',
235
237
  );
236
- const receipt = this.deps.logs
237
- .read(id)
238
- .frames.find((frame) => frame.type === 'accepted');
239
- const scope = receipt?.scope as Record<string, unknown> | undefined;
240
- const source =
241
- scope?.kind === 'conduct' && entry.request.kind === 'code'
242
- ? entry.request.workerId!
243
- : id;
244
- if (source !== id && this.terminal(source)?.type !== 'done')
245
- throw new Error(
246
- 'The worker did not finish. Review it before resending this message.',
247
- );
248
- const resume = this.session(source);
238
+ const resume = this.session(id);
249
239
  if (!resume)
250
240
  throw new Error(
251
241
  'The previous turn has no session to continue. Start a new conversation.',
@@ -262,15 +252,23 @@ export class DurableTurnQueue {
262
252
  for (const [id, entry] of this.entries) {
263
253
  const lane = turnLane(entry.request);
264
254
  if (!this.owns(id)) continue;
255
+ if (entry.state === 'held') continue;
265
256
  if (occupied.has(lane)) continue;
266
- occupied.add(lane);
267
- if (entry.state !== 'queued' || this.scheduled.has(id)) continue;
257
+ if (entry.state !== 'queued' || this.scheduled.has(id)) { occupied.add(lane); continue; }
268
258
  try {
269
- if (!this.predecessor(entry).ready) continue;
259
+ const previous = this.predecessor(entry);
260
+ if (!previous.ready) {
261
+ if (previous.blockedBy) {
262
+ this.save({ ...entry, state: 'held', blockedBy: previous.blockedBy });
263
+ this.confirm(id);
264
+ }
265
+ continue;
266
+ }
270
267
  } catch (error) {
271
268
  this.fail(entry, String((error as Error).message));
272
269
  continue;
273
270
  }
271
+ occupied.add(lane);
274
272
  this.scheduled.add(id);
275
273
  void this.deps.lanes
276
274
  .run(turnLane(entry.request), async () => {
@@ -320,15 +318,15 @@ export class DurableTurnQueue {
320
318
  if (frame) this.deps.sendRaw(frame);
321
319
  return;
322
320
  }
323
- if (entry.state !== 'queued')
321
+ if (entry.state !== 'queued' && entry.state !== 'held')
324
322
  throw new Error('This message has already started or left the queue.');
325
323
  if (action === 'steer') {
324
+ if (entry.state === 'held') throw new Error('Review the interrupted turn before using this follow-up.');
326
325
  if (entry.request.images?.length)
327
326
  throw new Error('Attachments must run as a separate turn.');
328
327
  if (!activeId || !this.deps.steer)
329
328
  throw new Error('There is no active turn to influence.');
330
329
  const active = this.entries.get(activeId);
331
- // For a spawned fleet worker, the active request uses the worker's own ID.
332
330
  if (
333
331
  active
334
332
  ? turnLane(active.request) !== turnLane(entry.request) ||
@@ -2,7 +2,7 @@
2
2
  import { DatabaseSync } from 'node:sqlite';
3
3
  import { chmodSync, mkdirSync } from 'node:fs';
4
4
  import { dirname } from 'node:path';
5
- import type { HarnessRequest } from '@lucidity/shared';
5
+ import type { HarnessRequest, RunReview } from '@lucidity/shared';
6
6
  import type { TurnFrame, TurnState } from './turnLog.js';
7
7
 
8
8
  const terminalTypes = new Set(['done', 'error', 'cancelled']);
@@ -82,6 +82,9 @@ export class RuntimeStore {
82
82
  this.write(() => this.db.prepare('INSERT INTO records VALUES (?, ?, ?) ON CONFLICT(bucket,id) DO UPDATE SET value=excluded.value')
83
83
  .run(bucket, id, JSON.stringify(value)));
84
84
  }
85
+ delete(bucket: string, id: string): void {
86
+ this.write(() => this.db.prepare('DELETE FROM records WHERE bucket=? AND id=?').run(bucket, id));
87
+ }
85
88
  list<T>(bucket: string): T[] {
86
89
  return this.db.prepare('SELECT value FROM records WHERE bucket=? ORDER BY rowid').all(bucket)
87
90
  .map((row: { value: string }) => JSON.parse(row.value) as T);
@@ -95,6 +98,16 @@ export class RuntimeStore {
95
98
  if (old?.command && old.command !== payload)
96
99
  throw new Error('This request ID already belongs to different input.');
97
100
  if (old) return { duplicate: true, frames: this.read(request.id).frames };
101
+ if (request.kind === 'code' && request.recoveryOf) {
102
+ const review = this.get<RunReview>('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
+ }
98
111
  this.db.prepare('INSERT INTO runs (id,command,conversation,updated) VALUES (?,?,?,?)')
99
112
  .run(request.id, payload, conversationKey(request), Date.now());
100
113
  const scope = {
@@ -175,6 +188,10 @@ export class RuntimeStore {
175
188
  lastCommand(conversation: string): string | undefined {
176
189
  return this.db.prepare('SELECT id FROM runs WHERE conversation=? AND command IS NOT NULL ORDER BY rowid DESC LIMIT 1').get(conversation)?.id;
177
190
  }
191
+ command(id: string): HarnessRequest | undefined {
192
+ const row = this.db.prepare('SELECT command FROM runs WHERE id=?').get(id);
193
+ return row?.command ? JSON.parse(row.command) : undefined;
194
+ }
178
195
  unfinished(conversation: string): boolean {
179
196
  return !!this.db.prepare('SELECT id FROM runs WHERE conversation=? AND terminal IS NULL LIMIT 1').get(conversation);
180
197
  }
package/src/vault.ts CHANGED
@@ -24,9 +24,9 @@ export interface Vault {
24
24
  /** SOUL.md if present (and non-empty), else the packaged default — seeding SOUL.md so it's editable. */
25
25
  readPersona(): string;
26
26
  /** Durable facts from MEMORY.md (empty if absent/malformed). */
27
- readMemoryFacts(): string[];
28
- writeMemoryFacts(facts: string[]): void;
29
- writeSessionLog(entry: SessionEntry): void;
27
+ readMemoryFacts(strict?: boolean): string[];
28
+ writeMemoryFacts(facts: string[], strict?: boolean): void;
29
+ writeSessionLog(entry: SessionEntry, receipt?: { id: string; strict: boolean }): void;
30
30
  }
31
31
 
32
32
  function msg(err: unknown): string {
@@ -56,26 +56,28 @@ export function createVault(vaultPath: string): Vault {
56
56
  return def;
57
57
  },
58
58
 
59
- readMemoryFacts(): string[] {
59
+ readMemoryFacts(strict = false): string[] {
60
60
  if (!existsSync(memoryPath)) return [];
61
61
  try {
62
62
  return parseFacts(readFileSync(memoryPath, 'utf8'));
63
63
  } catch (err) {
64
+ if (strict) throw err;
64
65
  console.error(`[vault] could not read MEMORY.md: ${msg(err)}`);
65
66
  return [];
66
67
  }
67
68
  },
68
69
 
69
- writeMemoryFacts(facts: string[]): void {
70
+ writeMemoryFacts(facts: string[], strict = false): void {
70
71
  try {
71
72
  mkdirSync(vaultPath, { recursive: true });
72
73
  writeFileSync(memoryPath, renderMemoryFile(facts), 'utf8');
73
74
  } catch (err) {
75
+ if (strict) throw err;
74
76
  console.error(`[vault] could not write MEMORY.md: ${msg(err)}`);
75
77
  }
76
78
  },
77
79
 
78
- writeSessionLog(entry: SessionEntry): void {
80
+ writeSessionLog(entry: SessionEntry, receipt?: { id: string; strict: boolean }): void {
79
81
  try {
80
82
  mkdirSync(sessionsDir, { recursive: true });
81
83
  const kind = entry.kind ?? 'briefing';
@@ -88,8 +90,15 @@ export function createVault(vaultPath: string): Vault {
88
90
  `Delivered via: ${entry.deliveredVia}\n\n` +
89
91
  `## Message\n\n${entry.body.trim()}\n\n` +
90
92
  `## Facts learned\n\n${facts}\n`;
91
- writeFileSync(join(sessionsDir, `${stamp}-${kind}.md`), content, 'utf8');
93
+ if (receipt && !/^[a-zA-Z0-9-]+$/.test(receipt.id)) throw new Error('Invalid session receipt ID');
94
+ const path = join(sessionsDir, `${receipt?.id ?? stamp}-${kind}.md`);
95
+ if (receipt && existsSync(path)) {
96
+ if (readFileSync(path, 'utf8') !== content) throw new Error('The saved briefing was changed outside this run.');
97
+ return;
98
+ }
99
+ writeFileSync(path, content, { encoding: 'utf8', flag: receipt ? 'wx' : 'w' });
92
100
  } catch (err) {
101
+ if (receipt?.strict) throw err;
93
102
  console.error(`[vault] could not write session log: ${msg(err)}`);
94
103
  }
95
104
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucidity/mcp-server",
3
- "version": "0.8.0",
3
+ "version": "0.9.5",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "bin": {
@@ -71,3 +71,37 @@ regenerate with `node scripts/generate-codex-protocol.mjs`, and run the pin chec
71
71
  and authenticated provider smoke checks. Keep changes reviewable in one PR. Never regenerate
72
72
  against a PATH-selected Codex. Model availability, shared login state, and provider-side behavior
73
73
  can still change independently of the local package pin.
74
+
75
+ ## Restart inspection
76
+
77
+ Adapters expose `recoveryCapability`, `inspect(ref, { cwd, timeoutMs })`, and a
78
+ synchronous `onRecovery` callback on executions. The callback persists native
79
+ session/thread, turn and process identifiers before execution continues. Tool
80
+ events retain native item IDs and outcomes when the provider supplies them.
81
+ `inspect` never starts inference or runs a tool.
82
+
83
+ - Codex 0.160.0 supports `native-turn`: a fresh App Server connection uses
84
+ `thread/read`, matches the exact saved thread and turn, requires a completed
85
+ turn with full items, and recovers its final answer. An active thread, partial
86
+ items, missing turn, timeout, authentication problem or unreadable history stays
87
+ unknown. Native command turns are excluded from this recovery path.
88
+ - Claude Agent SDK 0.3.287 supports `completion-receipt`: Lucidity persists the
89
+ successful native result before publishing it. The pinned SDK's session-message
90
+ history does not expose a durable terminal run result, so native history alone
91
+ cannot recover the gap before this receipt. Its inspector explicitly reports
92
+ that limitation. A session ID or partial assistant message is never completion
93
+ evidence.
94
+
95
+ The daemon wraps ordinary streaming Ask and Code turns in `RecoveryExecutor`.
96
+ Structured planning results still require their normal consumer validation, and
97
+ host-controlled briefing steps use `SavedWorkflow`. Startup reconciliation happens
98
+ under the daemon lease before queue admission. A surviving prior owner/native
99
+ process prevents a replacement from starting work. Proven answers flow through the
100
+ ordered event log once. Already-terminal uncertain runs retain their original
101
+ terminal and receive a linked reconciliation record for review.
102
+
103
+ Verification on 6 October 2026: runtime regressions and process-kill fixtures cover
104
+ both capabilities; live Codex inspection recovered a native answer without a new
105
+ inference. Live Claude validation was blocked because `claude auth status` reported
106
+ `loggedIn: false` and no configured OAuth token authenticated the SDK. Rerun that
107
+ live check after subscription sign-in; this does not authorize API-key billing.
@@ -11,10 +11,14 @@ export declare class ClaudeAgentExecutor implements AgentExecutor {
11
11
  private readonly options;
12
12
  readonly name = "claude-agent-sdk";
13
13
  readonly strictResume = true;
14
+ readonly recoveryCapability = "completion-receipt";
15
+ inspect(): Promise<import('./types.js').ProviderInspection>;
14
16
  private readonly turns;
15
17
  constructor(options?: {
16
18
  oauthToken?: string;
17
19
  query?: typeof query;
20
+ /** How long to wait for a closing loop after the last background task ends. */
21
+ backgroundGraceMs?: number;
18
22
  });
19
23
  steer(requestId: string, text: string): Promise<void>;
20
24
  interrupt(requestId: string): Promise<boolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"claudeAgent.d.ts","sourceRoot":"","sources":["../../src/executor/claudeAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,KAAK,EACL,KAAK,OAAO,EAGZ,KAAK,WAAW,EACjB,MAAM,gCAAgC,CAAC;AAIxC,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,wBAAwB,YAAY,CAAC;AAIlD,wBAAgB,qBAAqB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,UAAU,CAa5E;AA4BD,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,gBAAgB,EACvB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CA8ET;AAED,oFAAoF;AACpF,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAuBpE;AAmBD,mFAAmF;AACnF,qBAAa,mBAAoB,YAAW,aAAa;IAKrD,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJ1B,QAAQ,CAAC,IAAI,sBAAsB;IACnC,QAAQ,CAAC,YAAY,QAAQ;IAC7B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmB;gBAEtB,OAAO,GAAE;QACxB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;KACjB;IAGR,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAG/B,SAAS,CAAC,SAAS,EAAE,MAAM;IAG3B,OAAO;IAIb,gFAAgF;IAC1E,MAAM,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IA2ClC,QAAQ,CAAC,KAAK,GAAE,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,gBAAgB,GAAG,KAAK,CAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAiC7G,GAAG,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,cAAc,CAAC;IAMpD,SAAS,CACd,KAAK,EAAE,gBAAgB,GACtB,aAAa,CAAC,mBAAmB,CAAC;CA4JtC"}
1
+ {"version":3,"file":"claudeAgent.d.ts","sourceRoot":"","sources":["../../src/executor/claudeAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EACL,KAAK,EACL,KAAK,OAAO,EAGZ,KAAK,WAAW,EACjB,MAAM,gCAAgC,CAAC;AAIxC,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,wBAAwB,YAAY,CAAC;AAIlD,wBAAgB,qBAAqB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,UAAU,CAa5E;AA4BD,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,gBAAgB,EACvB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CA8ET;AAED,oFAAoF;AACpF,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAuBpE;AAmBD,mFAAmF;AACnF,qBAAa,mBAAoB,YAAW,aAAa;IASrD,OAAO,CAAC,QAAQ,CAAC,OAAO;IAR1B,QAAQ,CAAC,IAAI,sBAAsB;IACnC,QAAQ,CAAC,YAAY,QAAQ;IAC7B,QAAQ,CAAC,kBAAkB,wBAAwB;IAC7C,OAAO,IAAI,OAAO,CAAC,OAAO,YAAY,EAAE,kBAAkB,CAAC;IAGjE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmB;gBAEtB,OAAO,GAAE;QACxB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;QACrB,+EAA+E;QAC/E,iBAAiB,CAAC,EAAE,MAAM,CAAC;KACvB;IAGR,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAG/B,SAAS,CAAC,SAAS,EAAE,MAAM;IAG3B,OAAO;IAIb,gFAAgF;IAC1E,MAAM,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IA2ClC,QAAQ,CAAC,KAAK,GAAE,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,gBAAgB,GAAG,KAAK,CAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAiC7G,GAAG,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,cAAc,CAAC;IAMpD,SAAS,CACd,KAAK,EAAE,gBAAgB,GACtB,aAAa,CAAC,mBAAmB,CAAC;CAmMtC"}
@@ -1,5 +1,6 @@
1
1
  import { findAgentCommand, parseAgentCommand, } from '@lucidity/shared';
2
2
  import { randomUUID } from 'node:crypto';
3
+ import { spawn } from 'node:child_process';
3
4
  import { readFileSync } from 'node:fs';
4
5
  import { query, } from '@anthropic-ai/claude-agent-sdk';
5
6
  import { stripUnsafeEnv } from './claudeCode.js';
@@ -54,7 +55,7 @@ export function claudeAgentOptions(input, oauthToken) {
54
55
  : {};
55
56
  return {
56
57
  cwd: input.cwd,
57
- env: claudeSubscriptionEnv(oauthToken),
58
+ env: { ...claudeSubscriptionEnv(oauthToken), ...input.env },
58
59
  model: input.model,
59
60
  effort: input.effort,
60
61
  outputFormat: input.outputSchema ? { type: 'json_schema', schema: input.outputSchema } : undefined,
@@ -152,6 +153,10 @@ export class ClaudeAgentExecutor {
152
153
  options;
153
154
  name = 'claude-agent-sdk';
154
155
  strictResume = true;
156
+ recoveryCapability = 'completion-receipt';
157
+ async inspect() {
158
+ return { status: 'unsupported', reason: 'Claude SDK 0.3.287 history contains messages, not a durable run-completion receipt. Partial text cannot establish completion.' };
159
+ }
155
160
  turns = new LiveTurns();
156
161
  constructor(options = {}) {
157
162
  this.options = options;
@@ -256,6 +261,12 @@ export class ClaudeAgentExecutor {
256
261
  let ended = false;
257
262
  let ready = false;
258
263
  const pending = new Set();
264
+ // Sub-agents and background commands outlive the loop that started them. The turn stays
265
+ // open while any are live, and `carried` holds what Claude said before they reported back.
266
+ let background = 0;
267
+ const carried = [];
268
+ let carriedSession = '';
269
+ let grace;
259
270
  const owner = this.turns.open(input, async (text) => {
260
271
  if (command)
261
272
  throw new Error('Wait for the command to finish before sending a message.');
@@ -274,6 +285,18 @@ export class ClaudeAgentExecutor {
274
285
  options: {
275
286
  ...claudeAgentOptions(input, this.options.oauthToken),
276
287
  abortController: owner.controller,
288
+ ...(input.onRecovery ? { spawnClaudeCodeProcess: (options) => {
289
+ const child = spawn(options.command, options.args, { cwd: options.cwd, env: options.env, signal: options.signal, stdio: ['pipe', 'pipe', 'pipe'] });
290
+ child.stderr.on('data', () => { });
291
+ try {
292
+ input.onRecovery({ pid: child.pid });
293
+ }
294
+ catch (error) {
295
+ child.kill('SIGKILL');
296
+ throw error;
297
+ }
298
+ return child;
299
+ } } : {}),
277
300
  },
278
301
  });
279
302
  requireClaudeSubscription(await active.accountInfo());
@@ -289,12 +312,27 @@ export class ClaudeAgentExecutor {
289
312
  });
290
313
  yield { type: 'tool_call', name: `/${commandName}`, phase: 'start' };
291
314
  }
315
+ input.onRecovery?.({ turnId: initial.uuid, inspectionDisabled: !!command });
292
316
  incoming.push(initial);
293
317
  ready = true;
294
318
  for await (const event of active) {
295
319
  owner.check();
296
- if (event.type === 'system' && event.subtype === 'init')
320
+ if (event.type === 'system' && event.subtype === 'background_tasks_changed') {
321
+ background = event.tasks.filter((task) => !task.ambient).length;
322
+ // Finished work normally starts another loop. If none follows (a task was stopped,
323
+ // say), close the input so the query ends and the turn settles with what it has.
324
+ if (!background && carried.length && !grace)
325
+ grace = setTimeout(() => incoming.end(), this.options.backgroundGraceMs ?? 90_000);
326
+ continue;
327
+ }
328
+ if (grace) {
329
+ clearTimeout(grace);
330
+ grace = undefined;
331
+ }
332
+ if (event.type === 'system' && event.subtype === 'init') {
333
+ input.onRecovery?.({ sessionId: event.session_id });
297
334
  yield { type: 'session', sessionId: event.session_id };
335
+ }
298
336
  if (event.type === 'system' &&
299
337
  event.subtype === 'local_command_output' &&
300
338
  command) {
@@ -318,6 +356,7 @@ export class ClaudeAgentExecutor {
318
356
  type: 'tool_call',
319
357
  name: e.content_block.name,
320
358
  phase: 'start',
359
+ itemId: e.content_block.id,
321
360
  };
322
361
  }
323
362
  }
@@ -327,7 +366,7 @@ export class ClaudeAgentExecutor {
327
366
  if (block.type === 'tool_result') {
328
367
  const name = toolNames.get(block.tool_use_id);
329
368
  if (name) {
330
- yield { type: 'tool_call', name, phase: 'end' };
369
+ yield { type: 'tool_call', name, phase: 'end', itemId: block.tool_use_id, outcome: block.is_error ? 'failed' : 'completed' };
331
370
  toolNames.delete(block.tool_use_id);
332
371
  }
333
372
  }
@@ -348,6 +387,14 @@ export class ClaudeAgentExecutor {
348
387
  // query. Keep consuming until its echoed user message and result arrive.
349
388
  if (pending.size)
350
389
  continue;
390
+ // Closing the query now would kill the work still running, and its report would
391
+ // never reach the phone. Claude continues in a later loop of this same query.
392
+ if (background > 0 && !input.outputSchema && !command) {
393
+ if (event.result.trim())
394
+ carried.push(event.result.trim());
395
+ carriedSession = event.session_id;
396
+ continue;
397
+ }
351
398
  if (input.outputSchema && event.structured_output === undefined)
352
399
  throw new Error('Claude did not return the requested structured result.');
353
400
  ended = true;
@@ -356,7 +403,7 @@ export class ClaudeAgentExecutor {
356
403
  yield {
357
404
  type: 'done',
358
405
  text: (input.outputSchema ? JSON.stringify(event.structured_output) : '') ||
359
- event.result.trim() ||
406
+ [...carried, event.result.trim()].filter(Boolean).join('\n\n') ||
360
407
  commandOutput.trim() ||
361
408
  (compacted
362
409
  ? 'Conversation compacted. You can continue here.'
@@ -372,6 +419,11 @@ export class ClaudeAgentExecutor {
372
419
  }
373
420
  }
374
421
  owner.check();
422
+ if (carried.length) {
423
+ ended = true;
424
+ yield { type: 'done', text: carried.join('\n\n'), sessionId: carriedSession };
425
+ return;
426
+ }
375
427
  throw new Error('Claude disconnected before completing the turn.');
376
428
  }
377
429
  catch (error) {
@@ -382,6 +434,7 @@ export class ClaudeAgentExecutor {
382
434
  }
383
435
  finally {
384
436
  ended = true;
437
+ clearTimeout(grace);
385
438
  incoming.end();
386
439
  try {
387
440
  active?.close();
@@ -1,6 +1,6 @@
1
1
  import { type AgentCommandOption } from '@lucidity/shared';
2
2
  import { type CodexConnection } from './codexRpc.js';
3
- import type { AgentExecutor, ExecutorRunInput, ExecutorStreamEvent, ExecutorModel, ExecutorResult } from './types.js';
3
+ import type { AgentExecutor, ExecutorRunInput, ExecutorStreamEvent, ExecutorModel, ExecutorResult, ProviderRunRef, ProviderInspection } from './types.js';
4
4
  import type { ThreadStartParams } from './codexProtocol/v2/ThreadStartParams.js';
5
5
  /** Override inherited tool integrations before starting any thread. */
6
6
  export declare function codexRunConfig(input: ExecutorRunInput, inherited: Record<string, unknown>): NonNullable<ThreadStartParams['config']>;
@@ -8,13 +8,18 @@ export declare class CodexExecutor implements AgentExecutor {
8
8
  private readonly options;
9
9
  readonly name = "codex-app-server";
10
10
  readonly strictResume = true;
11
+ readonly recoveryCapability = "native-turn";
11
12
  private readonly turns;
12
13
  private readonly sessions;
13
14
  constructor(options?: {
14
15
  command?: string;
15
- connect?: (cwd?: string) => CodexConnection;
16
+ connect?: (cwd?: string, env?: Record<string, string>) => CodexConnection;
16
17
  });
17
18
  private connect;
19
+ inspect(ref: ProviderRunRef, options?: {
20
+ cwd?: string;
21
+ timeoutMs?: number;
22
+ }): Promise<ProviderInspection>;
18
23
  steer(requestId: string, text: string): Promise<void>;
19
24
  interrupt(requestId: string): Promise<boolean>;
20
25
  dispose(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../src/executor/codex.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAGL,KAAK,eAAe,EAErB,MAAM,eAAe,CAAC;AAOvB,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,cAAc,EACf,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AA6BjF,uEAAuE;AACvE,wBAAgB,cAAc,CAC5B,KAAK,EAAE,gBAAgB,EACvB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,WAAW,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAmG1C;AAED,qBAAa,aAAc,YAAW,aAAa;IAM/C,OAAO,CAAC,QAAQ,CAAC,OAAO;IAL1B,QAAQ,CAAC,IAAI,sBAAsB;IACnC,QAAQ,CAAC,YAAY,QAAQ;IAC7B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmB;IACzC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAuB;gBAE7B,OAAO,GAAE;QACxB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,KAAK,eAAe,CAAC;KACxC;IAER,OAAO,CAAC,OAAO;IAKf,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAG/B,SAAS,CAAC,SAAS,EAAE,MAAM;IAG3B,OAAO;IAIP,MAAM,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAgClC,QAAQ,CACZ,KAAK,GAAE,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,gBAAgB,CAAM,GAC3D,OAAO,CAAC,kBAAkB,EAAE,CAAC;IA2C1B,GAAG,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,cAAc,CAAC;IAMpD,SAAS,CACd,KAAK,EAAE,gBAAgB,GACtB,aAAa,CAAC,mBAAmB,CAAC;CA6YtC"}
1
+ {"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../src/executor/codex.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAGL,KAAK,eAAe,EAErB,MAAM,eAAe,CAAC;AAOvB,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,cAAc,EACd,kBAAkB,EACnB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AA+BjF,uEAAuE;AACvE,wBAAgB,cAAc,CAC5B,KAAK,EAAE,gBAAgB,EACvB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,WAAW,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAmG1C;AAED,qBAAa,aAAc,YAAW,aAAa;IAO/C,OAAO,CAAC,QAAQ,CAAC,OAAO;IAN1B,QAAQ,CAAC,IAAI,sBAAsB;IACnC,QAAQ,CAAC,YAAY,QAAQ;IAC7B,QAAQ,CAAC,kBAAkB,iBAAiB;IAC5C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmB;IACzC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAuB;gBAE7B,OAAO,GAAE;QACxB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,eAAe,CAAC;KACtE;IAER,OAAO,CAAC,OAAO;IAKT,OAAO,CAAC,GAAG,EAAE,cAAc,EAAE,OAAO,GAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAiCnH,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAG/B,SAAS,CAAC,SAAS,EAAE,MAAM;IAG3B,OAAO;IAIP,MAAM,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAgClC,QAAQ,CACZ,KAAK,GAAE,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,gBAAgB,CAAM,GAC3D,OAAO,CAAC,kBAAkB,EAAE,CAAC;IA2C1B,GAAG,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,cAAc,CAAC;IAMpD,SAAS,CACd,KAAK,EAAE,gBAAgB,GACtB,aAAa,CAAC,mBAAmB,CAAC;CAqZtC"}
@@ -101,13 +101,49 @@ export class CodexExecutor {
101
101
  options;
102
102
  name = 'codex-app-server';
103
103
  strictResume = true;
104
+ recoveryCapability = 'native-turn';
104
105
  turns = new LiveTurns();
105
106
  sessions = new CodexSessions();
106
107
  constructor(options = {}) {
107
108
  this.options = options;
108
109
  }
109
- connect(cwd) {
110
- return (this.options.connect?.(cwd) ?? new CodexRpc(this.options.command, cwd));
110
+ connect(cwd, env) {
111
+ return (this.options.connect?.(cwd, env) ?? new CodexRpc(this.options.command, cwd, env));
112
+ }
113
+ async inspect(ref, options = {}) {
114
+ if (!ref.sessionId || !ref.turnId || ref.inspectionDisabled)
115
+ return { status: 'unsupported', reason: 'No inspectable native Codex turn was recorded.' };
116
+ const rpc = this.connect(options.cwd);
117
+ let timer;
118
+ try {
119
+ return await Promise.race([
120
+ (async () => {
121
+ await initializeCodex(rpc);
122
+ const { thread } = await rpc.request('thread/read', {
123
+ threadId: ref.sessionId, includeTurns: true,
124
+ });
125
+ if (thread.id !== ref.sessionId || thread.status?.type === 'active')
126
+ return { status: 'unknown', reason: 'Codex history does not identify an inactive matching thread.' };
127
+ const turn = thread.turns?.find((turn) => turn.id === ref.turnId);
128
+ if (!turn || turn.status !== 'completed' || turn.itemsView !== 'full')
129
+ return { status: 'unknown', reason: 'Codex has no complete result for this exact turn.' };
130
+ const answer = [...turn.items].reverse().find((item) => item.type === 'agentMessage' && item.phase !== 'commentary');
131
+ if (!answer || answer.type !== 'agentMessage' || typeof answer.text !== 'string')
132
+ return { status: 'unknown', reason: 'The completed turn has no retained final answer.' };
133
+ return { status: 'completed', result: { text: answer.text.trim(), sessionId: thread.id } };
134
+ })(),
135
+ new Promise((resolve) => {
136
+ timer = setTimeout(() => resolve({ status: 'unknown', reason: 'Codex history inspection timed out.' }), Math.min(options.timeoutMs ?? 10_000, 30_000));
137
+ }),
138
+ ]);
139
+ }
140
+ catch {
141
+ return { status: 'unknown', reason: 'Codex history is unavailable or unreadable with the installed runtime.' };
142
+ }
143
+ finally {
144
+ clearTimeout(timer);
145
+ await rpc.close();
146
+ }
111
147
  }
112
148
  steer(requestId, text) {
113
149
  return this.turns.steer(requestId, text);
@@ -302,7 +338,8 @@ export class CodexExecutor {
302
338
  try {
303
339
  owner.check();
304
340
  const pooled = await this.sessions.take(input.resume);
305
- rpc = pooled?.rpc ?? this.connect(input.cwd);
341
+ rpc = pooled?.rpc ?? this.connect(input.cwd, input.env);
342
+ input.onRecovery?.({ pid: rpc.pid, inspectionDisabled: !!command });
306
343
  rpc.onRequest = onRequest;
307
344
  owner.check();
308
345
  if (!pooled)
@@ -339,7 +376,8 @@ export class CodexExecutor {
339
376
  // resumes only after the old owner has fully exited.
340
377
  await rpc.close();
341
378
  owner.check();
342
- rpc = this.connect(input.cwd);
379
+ rpc = this.connect(input.cwd, input.env);
380
+ input.onRecovery?.({ pid: rpc.pid });
343
381
  rpc.onRequest = onRequest;
344
382
  await initializeCodex(rpc);
345
383
  }
@@ -353,6 +391,7 @@ export class CodexExecutor {
353
391
  })
354
392
  : await rpc.request('thread/start', params);
355
393
  threadId = thread.thread.id;
394
+ input.onRecovery?.({ sessionId: threadId });
356
395
  const sessionId = isEmptySession(input.resume) &&
357
396
  command &&
358
397
  ['status', 'skills'].includes(command.name)
@@ -438,6 +477,8 @@ export class CodexExecutor {
438
477
  const turn = await rpc.request('turn/start', start);
439
478
  turnId = turn.turn.id;
440
479
  }
480
+ if (turnId)
481
+ input.onRecovery?.({ turnId });
441
482
  let finalText = '';
442
483
  let streamedText = '';
443
484
  for await (const event of rpc.events) {
@@ -485,6 +526,8 @@ export class CodexExecutor {
485
526
  yield {
486
527
  type: 'tool_call',
487
528
  name,
529
+ ...(item.id ? { itemId: item.id } : {}),
530
+ ...(item.status ? { outcome: item.status } : {}),
488
531
  phase: event.method === 'item/started' ? 'start' : 'end',
489
532
  };
490
533
  }
@@ -0,0 +1,2 @@
1
+ export type AgentPath = string;
2
+ //# sourceMappingURL=AgentPath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentPath.d.ts","sourceRoot":"","sources":["../../../src/executor/codexProtocol/AgentPath.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC"}
@@ -0,0 +1,2 @@
1
+ // GENERATED CODE! DO NOT MODIFY BY HAND!
2
+ export {};
@@ -0,0 +1,6 @@
1
+ export type ImageGenerationFailure = {
2
+ "type": "usageLimitExceeded";
3
+ limitId: string;
4
+ resetsAt: number | null;
5
+ };
6
+ //# sourceMappingURL=ImageGenerationFailure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageGenerationFailure.d.ts","sourceRoot":"","sources":["../../../src/executor/codexProtocol/ImageGenerationFailure.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,sBAAsB,GAAG;IAAE,MAAM,EAAE,oBAAoB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAAE,CAAC"}