@opencorelabs/lucidity 0.3.0 → 0.6.0

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 (512) hide show
  1. package/README.md +9 -2
  2. package/dist/assets/speech/licenses/FluidAudio/LICENSE +201 -0
  3. package/dist/assets/speech/licenses/FluidAudio/ThirdPartyLicenses/fastcluster-LICENSE.md +11 -0
  4. package/dist/assets/speech/licenses/FluidAudio/ThirdPartyLicenses/vbx-LICENSE.md +201 -0
  5. package/dist/assets/speech/lucidity-speech +0 -0
  6. package/dist/automations/agent.d.ts +16 -0
  7. package/dist/automations/agent.d.ts.map +1 -0
  8. package/dist/automations/agent.js +196 -0
  9. package/dist/automations/cli.d.ts +4 -0
  10. package/dist/automations/cli.d.ts.map +1 -0
  11. package/dist/automations/cli.js +44 -0
  12. package/dist/automations/connections.d.ts +11 -0
  13. package/dist/automations/connections.d.ts.map +1 -0
  14. package/dist/automations/connections.js +74 -0
  15. package/dist/automations/designer.d.ts +39 -0
  16. package/dist/automations/designer.d.ts.map +1 -0
  17. package/dist/automations/designer.js +450 -0
  18. package/dist/automations/history.d.ts +4 -0
  19. package/dist/automations/history.d.ts.map +1 -0
  20. package/dist/automations/history.js +57 -0
  21. package/dist/automations/learning.d.ts +19 -0
  22. package/dist/automations/learning.d.ts.map +1 -0
  23. package/dist/automations/learning.js +121 -0
  24. package/dist/automations/pinterest.d.ts +21 -0
  25. package/dist/automations/pinterest.d.ts.map +1 -0
  26. package/dist/automations/pinterest.js +113 -0
  27. package/dist/automations/service.d.ts +42 -0
  28. package/dist/automations/service.d.ts.map +1 -0
  29. package/dist/automations/service.js +406 -0
  30. package/dist/automations/setup.d.ts +3 -0
  31. package/dist/automations/setup.d.ts.map +1 -0
  32. package/dist/automations/setup.js +48 -0
  33. package/dist/automations/skill.d.ts +3 -0
  34. package/dist/automations/skill.d.ts.map +1 -0
  35. package/dist/automations/skill.js +29 -0
  36. package/dist/automations/store.d.ts +13 -0
  37. package/dist/automations/store.d.ts.map +1 -0
  38. package/dist/automations/store.js +46 -0
  39. package/dist/chat/server.d.ts +2 -0
  40. package/dist/chat/server.d.ts.map +1 -1
  41. package/dist/chat/server.js +46 -2
  42. package/dist/coding/commandContext.d.ts +6 -0
  43. package/dist/coding/commandContext.d.ts.map +1 -0
  44. package/dist/coding/commandContext.js +20 -0
  45. package/dist/coding/runCodeTurn.d.ts +12 -2
  46. package/dist/coding/runCodeTurn.d.ts.map +1 -1
  47. package/dist/coding/runCodeTurn.js +49 -19
  48. package/dist/coding/worktree.d.ts +3 -4
  49. package/dist/coding/worktree.d.ts.map +1 -1
  50. package/dist/coding/worktree.js +3 -4
  51. package/dist/config.d.ts +4 -0
  52. package/dist/config.d.ts.map +1 -1
  53. package/dist/config.js +20 -3
  54. package/dist/decisions/cli.d.ts +2 -0
  55. package/dist/decisions/cli.d.ts.map +1 -0
  56. package/dist/decisions/cli.js +106 -0
  57. package/dist/decisions/client.d.ts +20 -0
  58. package/dist/decisions/client.d.ts.map +1 -0
  59. package/dist/decisions/client.js +41 -0
  60. package/dist/handoff.d.ts +11 -0
  61. package/dist/handoff.d.ts.map +1 -0
  62. package/dist/handoff.js +21 -0
  63. package/dist/index.js +179 -40
  64. package/dist/jobs/briefing.js +1 -1
  65. package/dist/jobs/extraction.d.ts.map +1 -1
  66. package/dist/jobs/extraction.js +112 -22
  67. package/dist/jobs/fastModeReview.d.ts +39 -0
  68. package/dist/jobs/fastModeReview.d.ts.map +1 -0
  69. package/dist/jobs/fastModeReview.js +192 -0
  70. package/dist/jobs/voiceReview.d.ts +24 -0
  71. package/dist/jobs/voiceReview.d.ts.map +1 -0
  72. package/dist/jobs/voiceReview.js +128 -0
  73. package/dist/mcp/clients.d.ts +5 -0
  74. package/dist/mcp/clients.d.ts.map +1 -1
  75. package/dist/mcp/clients.js +1 -1
  76. package/dist/mcp/config.d.ts +3 -1
  77. package/dist/mcp/config.d.ts.map +1 -1
  78. package/dist/mcp/config.js +48 -6
  79. package/dist/mcp/paired.js +1 -0
  80. package/dist/notesContext.d.ts.map +1 -1
  81. package/dist/notesContext.js +3 -2
  82. package/dist/room/client.d.ts +20 -7
  83. package/dist/room/client.d.ts.map +1 -1
  84. package/dist/room/client.js +262 -45
  85. package/dist/room/computer.d.ts.map +1 -1
  86. package/dist/room/computer.js +8 -0
  87. package/dist/room/context.d.ts +3 -2
  88. package/dist/room/context.d.ts.map +1 -1
  89. package/dist/room/context.js +10 -3
  90. package/dist/room/turnQueue.d.ts +40 -0
  91. package/dist/room/turnQueue.d.ts.map +1 -0
  92. package/dist/room/turnQueue.js +301 -0
  93. package/dist/skills/lucidity-automations/SKILL.md +54 -0
  94. package/dist/speech/captures.d.ts +30 -0
  95. package/dist/speech/captures.d.ts.map +1 -0
  96. package/dist/speech/captures.js +209 -0
  97. package/dist/speech/fluidAudio.d.ts +28 -0
  98. package/dist/speech/fluidAudio.d.ts.map +1 -0
  99. package/dist/speech/fluidAudio.js +182 -0
  100. package/dist/speech/service.d.ts +14 -0
  101. package/dist/speech/service.d.ts.map +1 -0
  102. package/dist/speech/service.js +88 -0
  103. package/dist/speech/types.d.ts +19 -0
  104. package/dist/speech/types.d.ts.map +1 -0
  105. package/dist/speech/types.js +1 -0
  106. package/dist/turnLog.d.ts +1 -0
  107. package/dist/turnLog.d.ts.map +1 -1
  108. package/dist/turnLog.js +3 -0
  109. package/native/speech/Package.resolved +15 -0
  110. package/native/speech/Package.swift +16 -0
  111. package/native/speech/Sources/lucidity-speech/Speech.swift +81 -0
  112. package/package.json +6 -2
  113. package/src/automations/agent.ts +239 -0
  114. package/src/automations/cli.ts +52 -0
  115. package/src/automations/connections.ts +83 -0
  116. package/src/automations/designer.ts +594 -0
  117. package/src/automations/history.ts +59 -0
  118. package/src/automations/learning.ts +180 -0
  119. package/src/automations/pinterest.ts +146 -0
  120. package/src/automations/service.ts +505 -0
  121. package/src/automations/setup.ts +71 -0
  122. package/src/automations/skill.ts +40 -0
  123. package/src/automations/store.ts +63 -0
  124. package/src/chat/server.ts +62 -3
  125. package/src/coding/commandContext.ts +29 -0
  126. package/src/coding/runCodeTurn.ts +65 -21
  127. package/src/coding/worktree.ts +3 -4
  128. package/src/config.ts +29 -2
  129. package/src/decisions/cli.ts +136 -0
  130. package/src/decisions/client.ts +62 -0
  131. package/src/handoff.ts +28 -0
  132. package/src/index.ts +196 -67
  133. package/src/jobs/briefing.ts +1 -1
  134. package/src/jobs/extraction.ts +157 -32
  135. package/src/jobs/fastModeReview.ts +221 -0
  136. package/src/jobs/voiceReview.ts +156 -0
  137. package/src/mcp/clients.ts +1 -1
  138. package/src/mcp/config.ts +56 -6
  139. package/src/mcp/paired.ts +1 -0
  140. package/src/notesContext.ts +3 -2
  141. package/src/room/client.ts +316 -52
  142. package/src/room/computer.ts +8 -0
  143. package/src/room/context.ts +12 -3
  144. package/src/room/turnQueue.ts +358 -0
  145. package/src/speech/captures.ts +265 -0
  146. package/src/speech/fluidAudio.ts +242 -0
  147. package/src/speech/service.ts +108 -0
  148. package/src/speech/types.ts +13 -0
  149. package/src/turnLog.ts +4 -0
  150. package/vendor/decisions/LICENSE +662 -0
  151. package/vendor/decisions/dist/capture.d.ts +79 -0
  152. package/vendor/decisions/dist/capture.js +183 -0
  153. package/vendor/decisions/dist/command.d.ts +202 -0
  154. package/vendor/decisions/dist/command.js +750 -0
  155. package/vendor/decisions/dist/gate.d.ts +12 -0
  156. package/vendor/decisions/dist/gate.js +18 -0
  157. package/vendor/decisions/dist/index.d.ts +5 -0
  158. package/vendor/decisions/dist/index.js +5 -0
  159. package/vendor/decisions/dist/jev.d.ts +15 -0
  160. package/vendor/decisions/dist/jev.js +242 -0
  161. package/vendor/decisions/dist/types.d.ts +67 -0
  162. package/vendor/decisions/dist/types.js +1 -0
  163. package/vendor/decisions/package.json +22 -0
  164. package/vendor/decisions/src/capture.ts +199 -0
  165. package/vendor/decisions/src/command.ts +836 -0
  166. package/vendor/decisions/src/gate.ts +32 -0
  167. package/vendor/decisions/src/index.ts +5 -0
  168. package/vendor/decisions/src/jev.ts +293 -0
  169. package/vendor/decisions/src/types.ts +79 -0
  170. package/vendor/mcp-server/README.md +6 -1
  171. package/vendor/mcp-server/dist/client.d.ts +1 -0
  172. package/vendor/mcp-server/dist/client.d.ts.map +1 -1
  173. package/vendor/mcp-server/dist/client.js +8 -0
  174. package/vendor/mcp-server/dist/commentProvider.d.ts +3 -0
  175. package/vendor/mcp-server/dist/commentProvider.d.ts.map +1 -0
  176. package/vendor/mcp-server/dist/commentProvider.js +10 -0
  177. package/vendor/mcp-server/dist/index.js +21 -6
  178. package/vendor/mcp-server/dist/tools/automations.d.ts +6 -0
  179. package/vendor/mcp-server/dist/tools/automations.d.ts.map +1 -0
  180. package/vendor/mcp-server/dist/tools/automations.js +163 -0
  181. package/vendor/mcp-server/dist/tools/commandEventFormat.d.ts +52 -0
  182. package/vendor/mcp-server/dist/tools/commandEventFormat.d.ts.map +1 -0
  183. package/vendor/mcp-server/dist/tools/commandEventFormat.js +83 -0
  184. package/vendor/mcp-server/dist/tools/commandEvents.d.ts +3 -0
  185. package/vendor/mcp-server/dist/tools/commandEvents.d.ts.map +1 -0
  186. package/vendor/mcp-server/dist/tools/commandEvents.js +21 -0
  187. package/vendor/mcp-server/dist/tools/comments.d.ts.map +1 -1
  188. package/vendor/mcp-server/dist/tools/comments.js +25 -4
  189. package/vendor/mcp-server/dist/tools/index.d.ts +2 -0
  190. package/vendor/mcp-server/dist/tools/index.d.ts.map +1 -1
  191. package/vendor/mcp-server/dist/tools/index.js +2 -0
  192. package/vendor/mcp-server/dist/tools/journal.d.ts +3 -0
  193. package/vendor/mcp-server/dist/tools/journal.d.ts.map +1 -0
  194. package/vendor/mcp-server/dist/tools/journal.js +131 -0
  195. package/vendor/mcp-server/dist/tools/taskActivity.d.ts +3 -0
  196. package/vendor/mcp-server/dist/tools/taskActivity.d.ts.map +1 -0
  197. package/vendor/mcp-server/dist/tools/taskActivity.js +32 -0
  198. package/vendor/mcp-server/dist/tools/taskOccurrences.d.ts +3 -0
  199. package/vendor/mcp-server/dist/tools/taskOccurrences.d.ts.map +1 -0
  200. package/vendor/mcp-server/dist/tools/taskOccurrences.js +12 -0
  201. package/vendor/mcp-server/dist/tools/taskTrash.d.ts +3 -0
  202. package/vendor/mcp-server/dist/tools/taskTrash.d.ts.map +1 -0
  203. package/vendor/mcp-server/dist/tools/taskTrash.js +21 -0
  204. package/vendor/mcp-server/dist/tools/tasks.d.ts.map +1 -1
  205. package/vendor/mcp-server/dist/tools/tasks.js +67 -27
  206. package/vendor/mcp-server/package.json +5 -1
  207. package/vendor/mcp-server/src/client.ts +10 -0
  208. package/vendor/mcp-server/src/commentProvider.ts +9 -0
  209. package/vendor/mcp-server/src/index.ts +20 -6
  210. package/vendor/mcp-server/src/tools/automations.ts +199 -0
  211. package/vendor/mcp-server/src/tools/commandEventFormat.ts +108 -0
  212. package/vendor/mcp-server/src/tools/commandEvents.ts +27 -0
  213. package/vendor/mcp-server/src/tools/comments.ts +24 -3
  214. package/vendor/mcp-server/src/tools/index.ts +2 -0
  215. package/vendor/mcp-server/src/tools/journal.ts +168 -0
  216. package/vendor/mcp-server/src/tools/taskActivity.ts +55 -0
  217. package/vendor/mcp-server/src/tools/taskOccurrences.ts +26 -0
  218. package/vendor/mcp-server/src/tools/taskTrash.ts +23 -0
  219. package/vendor/mcp-server/src/tools/tasks.ts +66 -30
  220. package/vendor/notes/dist/index.d.ts +2 -0
  221. package/vendor/notes/dist/index.d.ts.map +1 -1
  222. package/vendor/notes/dist/index.js +2 -0
  223. package/vendor/notes/dist/journal-backend.d.ts +4 -0
  224. package/vendor/notes/dist/journal-backend.d.ts.map +1 -0
  225. package/vendor/notes/dist/journal-backend.js +33 -0
  226. package/vendor/notes/dist/journal.d.ts +7 -0
  227. package/vendor/notes/dist/journal.d.ts.map +1 -0
  228. package/vendor/notes/dist/journal.js +173 -0
  229. package/vendor/notes/dist/vault.d.ts.map +1 -1
  230. package/vendor/notes/dist/vault.js +6 -1
  231. package/vendor/notes/src/index.ts +2 -0
  232. package/vendor/notes/src/journal-backend.ts +53 -0
  233. package/vendor/notes/src/journal.ts +194 -0
  234. package/vendor/notes/src/vault.ts +9 -1
  235. package/vendor/runtime/README.md +4 -0
  236. package/vendor/runtime/dist/executor/claudeAgent.d.ts +2 -0
  237. package/vendor/runtime/dist/executor/claudeAgent.d.ts.map +1 -1
  238. package/vendor/runtime/dist/executor/claudeAgent.js +113 -8
  239. package/vendor/runtime/dist/executor/claudeCode.d.ts.map +1 -1
  240. package/vendor/runtime/dist/executor/claudeCode.js +8 -4
  241. package/vendor/runtime/dist/executor/codex.d.ts +2 -0
  242. package/vendor/runtime/dist/executor/codex.d.ts.map +1 -1
  243. package/vendor/runtime/dist/executor/codex.js +213 -11
  244. package/vendor/runtime/dist/executor/codexProtocol/PlanType.d.ts +2 -0
  245. package/vendor/runtime/dist/executor/codexProtocol/PlanType.d.ts.map +1 -0
  246. package/vendor/runtime/dist/executor/codexProtocol/PlanType.js +2 -0
  247. package/vendor/runtime/dist/executor/codexProtocol/v2/CreditsSnapshot.d.ts +6 -0
  248. package/vendor/runtime/dist/executor/codexProtocol/v2/CreditsSnapshot.d.ts.map +1 -0
  249. package/vendor/runtime/dist/executor/codexProtocol/v2/CreditsSnapshot.js +2 -0
  250. package/vendor/runtime/dist/executor/codexProtocol/v2/GetAccountRateLimitsResponse.d.ts +26 -0
  251. package/vendor/runtime/dist/executor/codexProtocol/v2/GetAccountRateLimitsResponse.d.ts.map +1 -0
  252. package/vendor/runtime/dist/executor/codexProtocol/v2/GetAccountRateLimitsResponse.js +2 -0
  253. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitReachedType.d.ts +2 -0
  254. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitReachedType.d.ts.map +1 -0
  255. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitReachedType.js +2 -0
  256. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCredit.d.ts +27 -0
  257. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCredit.d.ts.map +1 -0
  258. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCredit.js +2 -0
  259. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCreditStatus.d.ts +2 -0
  260. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCreditStatus.d.ts.map +1 -0
  261. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCreditStatus.js +2 -0
  262. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCreditsSummary.d.ts +13 -0
  263. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCreditsSummary.d.ts.map +1 -0
  264. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCreditsSummary.js +2 -0
  265. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetType.d.ts +2 -0
  266. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetType.d.ts.map +1 -0
  267. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetType.js +2 -0
  268. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitSnapshot.d.ts +20 -0
  269. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitSnapshot.d.ts.map +1 -0
  270. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitSnapshot.js +2 -0
  271. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitWindow.d.ts +6 -0
  272. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitWindow.d.ts.map +1 -0
  273. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitWindow.js +2 -0
  274. package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewDelivery.d.ts +2 -0
  275. package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewDelivery.d.ts.map +1 -0
  276. package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewDelivery.js +2 -0
  277. package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewStartParams.d.ts +12 -0
  278. package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewStartParams.d.ts.map +1 -0
  279. package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewStartParams.js +2 -0
  280. package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewTarget.d.ts +17 -0
  281. package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewTarget.d.ts.map +1 -0
  282. package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewTarget.js +2 -0
  283. package/vendor/runtime/dist/executor/codexProtocol/v2/SkillDependencies.d.ts +5 -0
  284. package/vendor/runtime/dist/executor/codexProtocol/v2/SkillDependencies.d.ts.map +1 -0
  285. package/vendor/runtime/dist/executor/codexProtocol/v2/SkillDependencies.js +2 -0
  286. package/vendor/runtime/dist/executor/codexProtocol/v2/SkillErrorInfo.d.ts +5 -0
  287. package/vendor/runtime/dist/executor/codexProtocol/v2/SkillErrorInfo.d.ts.map +1 -0
  288. package/vendor/runtime/dist/executor/codexProtocol/v2/SkillErrorInfo.js +2 -0
  289. package/vendor/runtime/dist/executor/codexProtocol/v2/SkillInterface.d.ts +18 -0
  290. package/vendor/runtime/dist/executor/codexProtocol/v2/SkillInterface.d.ts.map +1 -0
  291. package/vendor/runtime/dist/executor/codexProtocol/v2/SkillInterface.js +2 -0
  292. package/vendor/runtime/dist/executor/codexProtocol/v2/SkillMetadata.d.ts +22 -0
  293. package/vendor/runtime/dist/executor/codexProtocol/v2/SkillMetadata.d.ts.map +1 -0
  294. package/vendor/runtime/dist/executor/codexProtocol/v2/SkillMetadata.js +2 -0
  295. package/vendor/runtime/dist/executor/codexProtocol/v2/SkillScope.d.ts +2 -0
  296. package/vendor/runtime/dist/executor/codexProtocol/v2/SkillScope.d.ts.map +1 -0
  297. package/vendor/runtime/dist/executor/codexProtocol/v2/SkillScope.js +2 -0
  298. package/vendor/runtime/dist/executor/codexProtocol/v2/SkillToolDependency.d.ts +9 -0
  299. package/vendor/runtime/dist/executor/codexProtocol/v2/SkillToolDependency.d.ts.map +1 -0
  300. package/vendor/runtime/dist/executor/codexProtocol/v2/SkillToolDependency.js +2 -0
  301. package/vendor/runtime/dist/executor/codexProtocol/v2/SkillsListEntry.d.ts +8 -0
  302. package/vendor/runtime/dist/executor/codexProtocol/v2/SkillsListEntry.d.ts.map +1 -0
  303. package/vendor/runtime/dist/executor/codexProtocol/v2/SkillsListEntry.js +2 -0
  304. package/vendor/runtime/dist/executor/codexProtocol/v2/SkillsListResponse.d.ts +5 -0
  305. package/vendor/runtime/dist/executor/codexProtocol/v2/SkillsListResponse.d.ts.map +1 -0
  306. package/vendor/runtime/dist/executor/codexProtocol/v2/SkillsListResponse.js +2 -0
  307. package/vendor/runtime/dist/executor/codexProtocol/v2/SpendControlLimitSnapshot.d.ts +7 -0
  308. package/vendor/runtime/dist/executor/codexProtocol/v2/SpendControlLimitSnapshot.d.ts.map +1 -0
  309. package/vendor/runtime/dist/executor/codexProtocol/v2/SpendControlLimitSnapshot.js +2 -0
  310. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSetNameParams.d.ts +5 -0
  311. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSetNameParams.d.ts.map +1 -0
  312. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSetNameParams.js +2 -0
  313. package/vendor/runtime/dist/executor/health.d.ts +1 -0
  314. package/vendor/runtime/dist/executor/health.d.ts.map +1 -1
  315. package/vendor/runtime/dist/executor/health.js +3 -0
  316. package/vendor/runtime/dist/executor/liveTurns.d.ts.map +1 -1
  317. package/vendor/runtime/dist/executor/liveTurns.js +3 -0
  318. package/vendor/runtime/dist/executor/providerRouter.d.ts.map +1 -1
  319. package/vendor/runtime/dist/executor/providerRouter.js +2 -1
  320. package/vendor/runtime/dist/executor/types.d.ts +8 -0
  321. package/vendor/runtime/dist/executor/types.d.ts.map +1 -1
  322. package/vendor/runtime/dist/harness/index.d.ts +1 -0
  323. package/vendor/runtime/dist/harness/index.d.ts.map +1 -1
  324. package/vendor/runtime/dist/harness/index.js +35 -1
  325. package/vendor/runtime/dist/harness/types.d.ts +4 -1
  326. package/vendor/runtime/dist/harness/types.d.ts.map +1 -1
  327. package/vendor/runtime/dist/index.d.ts +2 -1
  328. package/vendor/runtime/dist/index.d.ts.map +1 -1
  329. package/vendor/runtime/dist/index.js +2 -0
  330. package/vendor/runtime/dist/journal/context.d.ts +18 -0
  331. package/vendor/runtime/dist/journal/context.d.ts.map +1 -1
  332. package/vendor/runtime/dist/journal/context.js +19 -5
  333. package/vendor/runtime/dist/prompts/briefing.d.ts +4 -7
  334. package/vendor/runtime/dist/prompts/briefing.d.ts.map +1 -1
  335. package/vendor/runtime/dist/prompts/briefing.js +61 -12
  336. package/vendor/runtime/dist/prompts/cardStatement.d.ts +7 -0
  337. package/vendor/runtime/dist/prompts/cardStatement.d.ts.map +1 -0
  338. package/vendor/runtime/dist/prompts/cardStatement.js +52 -0
  339. package/vendor/runtime/dist/prompts/chat.d.ts +1 -0
  340. package/vendor/runtime/dist/prompts/chat.d.ts.map +1 -1
  341. package/vendor/runtime/dist/prompts/chat.js +15 -1
  342. package/vendor/runtime/dist/prompts/projectCapture.d.ts +7 -0
  343. package/vendor/runtime/dist/prompts/projectCapture.d.ts.map +1 -0
  344. package/vendor/runtime/dist/prompts/projectCapture.js +31 -0
  345. package/vendor/runtime/src/executor/claudeAgent.ts +133 -7
  346. package/vendor/runtime/src/executor/claudeCode.ts +6 -4
  347. package/vendor/runtime/src/executor/codex.ts +280 -20
  348. package/vendor/runtime/src/executor/codexProtocol/PlanType.ts +5 -0
  349. package/vendor/runtime/src/executor/codexProtocol/v2/CreditsSnapshot.ts +5 -0
  350. package/vendor/runtime/src/executor/codexProtocol/v2/GetAccountRateLimitsResponse.ts +25 -0
  351. package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitReachedType.ts +5 -0
  352. package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitResetCredit.ts +27 -0
  353. package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitResetCreditStatus.ts +5 -0
  354. package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitResetCreditsSummary.ts +14 -0
  355. package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitResetType.ts +5 -0
  356. package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitSnapshot.ts +14 -0
  357. package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitWindow.ts +5 -0
  358. package/vendor/runtime/src/executor/codexProtocol/v2/ReviewDelivery.ts +5 -0
  359. package/vendor/runtime/src/executor/codexProtocol/v2/ReviewStartParams.ts +12 -0
  360. package/vendor/runtime/src/executor/codexProtocol/v2/ReviewTarget.ts +9 -0
  361. package/vendor/runtime/src/executor/codexProtocol/v2/SkillDependencies.ts +6 -0
  362. package/vendor/runtime/src/executor/codexProtocol/v2/SkillErrorInfo.ts +5 -0
  363. package/vendor/runtime/src/executor/codexProtocol/v2/SkillInterface.ts +14 -0
  364. package/vendor/runtime/src/executor/codexProtocol/v2/SkillMetadata.ts +17 -0
  365. package/vendor/runtime/src/executor/codexProtocol/v2/SkillScope.ts +5 -0
  366. package/vendor/runtime/src/executor/codexProtocol/v2/SkillToolDependency.ts +5 -0
  367. package/vendor/runtime/src/executor/codexProtocol/v2/SkillsListEntry.ts +7 -0
  368. package/vendor/runtime/src/executor/codexProtocol/v2/SkillsListResponse.ts +6 -0
  369. package/vendor/runtime/src/executor/codexProtocol/v2/SpendControlLimitSnapshot.ts +5 -0
  370. package/vendor/runtime/src/executor/codexProtocol/v2/ThreadSetNameParams.ts +5 -0
  371. package/vendor/runtime/src/executor/health.ts +3 -0
  372. package/vendor/runtime/src/executor/liveTurns.ts +3 -0
  373. package/vendor/runtime/src/executor/providerRouter.ts +2 -1
  374. package/vendor/runtime/src/executor/types.ts +8 -0
  375. package/vendor/runtime/src/harness/index.ts +40 -6
  376. package/vendor/runtime/src/harness/types.ts +4 -1
  377. package/vendor/runtime/src/index.ts +4 -1
  378. package/vendor/runtime/src/journal/context.ts +40 -7
  379. package/vendor/runtime/src/prompts/briefing.ts +62 -17
  380. package/vendor/runtime/src/prompts/cardStatement.ts +64 -0
  381. package/vendor/runtime/src/prompts/chat.ts +25 -3
  382. package/vendor/runtime/src/prompts/projectCapture.ts +51 -0
  383. package/vendor/shared/dist/agentCommands.d.ts +22 -0
  384. package/vendor/shared/dist/agentCommands.d.ts.map +1 -0
  385. package/vendor/shared/dist/agentCommands.js +11 -0
  386. package/vendor/shared/dist/automationTemplates.d.ts +37 -0
  387. package/vendor/shared/dist/automationTemplates.d.ts.map +1 -0
  388. package/vendor/shared/dist/automationTemplates.js +48 -0
  389. package/vendor/shared/dist/automations.d.ts +1052 -0
  390. package/vendor/shared/dist/automations.d.ts.map +1 -0
  391. package/vendor/shared/dist/automations.js +300 -0
  392. package/vendor/shared/dist/cardStatement.d.ts +28 -0
  393. package/vendor/shared/dist/cardStatement.d.ts.map +1 -0
  394. package/vendor/shared/dist/cardStatement.js +37 -0
  395. package/vendor/shared/dist/cardStudio.d.ts +756 -0
  396. package/vendor/shared/dist/cardStudio.d.ts.map +1 -0
  397. package/vendor/shared/dist/cardStudio.js +297 -0
  398. package/vendor/shared/dist/commandLocal.d.ts +218 -0
  399. package/vendor/shared/dist/commandLocal.d.ts.map +1 -0
  400. package/vendor/shared/dist/commandLocal.js +662 -0
  401. package/vendor/shared/dist/commandText.d.ts +12 -0
  402. package/vendor/shared/dist/commandText.d.ts.map +1 -0
  403. package/vendor/shared/dist/commandText.js +21 -0
  404. package/vendor/shared/dist/commands.d.ts +1516 -0
  405. package/vendor/shared/dist/commands.d.ts.map +1 -0
  406. package/vendor/shared/dist/commands.js +231 -0
  407. package/vendor/shared/dist/computer.d.ts +9 -9
  408. package/vendor/shared/dist/computer.d.ts.map +1 -1
  409. package/vendor/shared/dist/computer.js +11 -2
  410. package/vendor/shared/dist/constants.d.ts +3 -3
  411. package/vendor/shared/dist/constants.d.ts.map +1 -1
  412. package/vendor/shared/dist/constants.js +9 -2
  413. package/vendor/shared/dist/githubContributions.d.ts +93 -0
  414. package/vendor/shared/dist/githubContributions.d.ts.map +1 -0
  415. package/vendor/shared/dist/githubContributions.js +54 -0
  416. package/vendor/shared/dist/habitContributions.d.ts +26 -0
  417. package/vendor/shared/dist/habitContributions.d.ts.map +1 -0
  418. package/vendor/shared/dist/habitContributions.js +119 -0
  419. package/vendor/shared/dist/index.d.ts +26 -2
  420. package/vendor/shared/dist/index.d.ts.map +1 -1
  421. package/vendor/shared/dist/index.js +23 -2
  422. package/vendor/shared/dist/journal-migration.d.ts +29 -0
  423. package/vendor/shared/dist/journal-migration.d.ts.map +1 -0
  424. package/vendor/shared/dist/journal-migration.js +73 -0
  425. package/vendor/shared/dist/journal-vault.d.ts +414 -0
  426. package/vendor/shared/dist/journal-vault.d.ts.map +1 -0
  427. package/vendor/shared/dist/journal-vault.js +972 -0
  428. package/vendor/shared/dist/projectCapture.d.ts +73 -0
  429. package/vendor/shared/dist/projectCapture.d.ts.map +1 -0
  430. package/vendor/shared/dist/projectCapture.js +66 -0
  431. package/vendor/shared/dist/quickAdd.d.ts +90 -0
  432. package/vendor/shared/dist/quickAdd.d.ts.map +1 -0
  433. package/vendor/shared/dist/quickAdd.js +260 -0
  434. package/vendor/shared/dist/recurrence.d.ts +44 -0
  435. package/vendor/shared/dist/recurrence.d.ts.map +1 -0
  436. package/vendor/shared/dist/recurrence.js +37 -0
  437. package/vendor/shared/dist/reminderWords.d.ts +11 -0
  438. package/vendor/shared/dist/reminderWords.d.ts.map +1 -0
  439. package/vendor/shared/dist/reminderWords.js +63 -0
  440. package/vendor/shared/dist/schemas/comment.d.ts +13 -1
  441. package/vendor/shared/dist/schemas/comment.d.ts.map +1 -1
  442. package/vendor/shared/dist/schemas/comment.js +5 -0
  443. package/vendor/shared/dist/schemas/conversation.d.ts +3 -3
  444. package/vendor/shared/dist/schemas/harness.d.ts +922 -59
  445. package/vendor/shared/dist/schemas/harness.d.ts.map +1 -1
  446. package/vendor/shared/dist/schemas/harness.js +122 -3
  447. package/vendor/shared/dist/schemas/journal.d.ts +10 -0
  448. package/vendor/shared/dist/schemas/journal.d.ts.map +1 -1
  449. package/vendor/shared/dist/schemas/journal.js +10 -2
  450. package/vendor/shared/dist/schemas/notification.d.ts +1 -1
  451. package/vendor/shared/dist/schemas/organization.d.ts +3 -2
  452. package/vendor/shared/dist/schemas/organization.d.ts.map +1 -1
  453. package/vendor/shared/dist/schemas/organization.js +3 -2
  454. package/vendor/shared/dist/schemas/proposal.d.ts +7 -3
  455. package/vendor/shared/dist/schemas/proposal.d.ts.map +1 -1
  456. package/vendor/shared/dist/schemas/proposal.js +2 -1
  457. package/vendor/shared/dist/schemas/request.d.ts +44 -4
  458. package/vendor/shared/dist/schemas/request.d.ts.map +1 -1
  459. package/vendor/shared/dist/schemas/task.d.ts +83 -8
  460. package/vendor/shared/dist/schemas/task.d.ts.map +1 -1
  461. package/vendor/shared/dist/schemas/task.js +20 -2
  462. package/vendor/shared/dist/schemas/timeSession.d.ts +2 -2
  463. package/vendor/shared/dist/smartCapture.d.ts +60 -0
  464. package/vendor/shared/dist/smartCapture.d.ts.map +1 -0
  465. package/vendor/shared/dist/smartCapture.js +56 -0
  466. package/vendor/shared/dist/speech.d.ts +39 -0
  467. package/vendor/shared/dist/speech.d.ts.map +1 -0
  468. package/vendor/shared/dist/speech.js +36 -0
  469. package/vendor/shared/dist/spokenNames.d.ts +25 -0
  470. package/vendor/shared/dist/spokenNames.d.ts.map +1 -0
  471. package/vendor/shared/dist/spokenNames.js +120 -0
  472. package/vendor/shared/dist/taskActivity.d.ts +76 -0
  473. package/vendor/shared/dist/taskActivity.d.ts.map +1 -0
  474. package/vendor/shared/dist/taskActivity.js +27 -0
  475. package/vendor/shared/dist/vault-search.d.ts +50 -0
  476. package/vendor/shared/dist/vault-search.d.ts.map +1 -0
  477. package/vendor/shared/dist/vault-search.js +177 -0
  478. package/vendor/shared/dist/voiceCapture.d.ts +32 -0
  479. package/vendor/shared/dist/voiceCapture.d.ts.map +1 -0
  480. package/vendor/shared/dist/voiceCapture.js +29 -0
  481. package/vendor/shared/package.json +4 -0
  482. package/vendor/shared/src/agentCommands.ts +35 -0
  483. package/vendor/shared/src/automationTemplates.ts +54 -0
  484. package/vendor/shared/src/automations.ts +329 -0
  485. package/vendor/shared/src/cardStatement.ts +49 -0
  486. package/vendor/shared/src/cardStudio.ts +340 -0
  487. package/vendor/shared/src/commandLocal.ts +738 -0
  488. package/vendor/shared/src/commandText.ts +25 -0
  489. package/vendor/shared/src/commands.ts +253 -0
  490. package/vendor/shared/src/computer.ts +23 -6
  491. package/vendor/shared/src/constants.ts +9 -2
  492. package/vendor/shared/src/githubContributions.ts +70 -0
  493. package/vendor/shared/src/habitContributions.ts +144 -0
  494. package/vendor/shared/src/index.ts +42 -1
  495. package/vendor/shared/src/journal-migration.ts +130 -0
  496. package/vendor/shared/src/journal-vault.ts +1240 -0
  497. package/vendor/shared/src/projectCapture.ts +86 -0
  498. package/vendor/shared/src/quickAdd.ts +310 -0
  499. package/vendor/shared/src/recurrence.ts +37 -0
  500. package/vendor/shared/src/reminderWords.ts +54 -0
  501. package/vendor/shared/src/schemas/comment.ts +5 -0
  502. package/vendor/shared/src/schemas/harness.ts +144 -7
  503. package/vendor/shared/src/schemas/journal.ts +15 -6
  504. package/vendor/shared/src/schemas/organization.ts +3 -2
  505. package/vendor/shared/src/schemas/proposal.ts +6 -1
  506. package/vendor/shared/src/schemas/task.ts +20 -2
  507. package/vendor/shared/src/smartCapture.ts +67 -0
  508. package/vendor/shared/src/speech.ts +44 -0
  509. package/vendor/shared/src/spokenNames.ts +128 -0
  510. package/vendor/shared/src/taskActivity.ts +34 -0
  511. package/vendor/shared/src/vault-search.ts +243 -0
  512. package/vendor/shared/src/voiceCapture.ts +34 -0
@@ -0,0 +1,505 @@
1
+ import { Cron } from 'croner';
2
+ import { uuidv7 } from 'uuidv7';
3
+ import {
4
+ AutomationCommandSchema,
5
+ type AutomationCommand,
6
+ type AutomationJob,
7
+ type AutomationRun,
8
+ type AutomationSchedule,
9
+ type AutomationSnapshot,
10
+ type AutomationInput,
11
+ isDesignerInput,
12
+ } from '@lucidity/shared';
13
+ import { AutomationStore } from './store.js';
14
+
15
+ export function nextOccurrence(
16
+ schedule: AutomationSchedule,
17
+ after: Date,
18
+ ): string | null {
19
+ if (schedule.frequency === 'manual') return null;
20
+ const [hour, minute] = schedule.time.split(':');
21
+ const expression =
22
+ schedule.frequency === 'interval'
23
+ ? `0 */${schedule.everyHours} * * *`
24
+ : `${minute} ${hour} * * ${schedule.frequency === 'weekly' ? schedule.dayOfWeek : schedule.frequency === 'weekdays' ? '1-5' : '*'}`;
25
+ const cron = new Cron(expression, {
26
+ timezone: schedule.timezone,
27
+ paused: true,
28
+ });
29
+ try {
30
+ const next = cron.nextRun(after);
31
+ if (!next) throw new Error('This schedule has no next occurrence');
32
+ return next.toISOString();
33
+ } finally {
34
+ cron.stop();
35
+ }
36
+ }
37
+
38
+ export interface AutomationServiceDeps {
39
+ store: AutomationStore;
40
+ execute: (
41
+ job: AutomationJob,
42
+ run: AutomationRun,
43
+ signal: AbortSignal,
44
+ ) => Promise<Partial<AutomationRun>>;
45
+ validateRepo: (id: string) => void;
46
+ saveGuidance: (run: AutomationRun) => Promise<string | void>;
47
+ validateInput?: (input: AutomationInput) => void;
48
+ computerName?: string;
49
+ supportedSources?: () => AutomationSnapshot['supportedSources'];
50
+ connections: () => AutomationSnapshot['connections'];
51
+ scheduledWork: () => boolean;
52
+ now?: () => Date;
53
+ changed?: () => void;
54
+ logger?: (message: string) => void;
55
+ }
56
+
57
+ /** A single writer serializes admission; inference runs asynchronously and is always recorded. */
58
+ export class AutomationService {
59
+ private readonly active = new Map<
60
+ string,
61
+ { runId: string; controller: AbortController; done: Promise<void> }
62
+ >();
63
+ private timer?: ReturnType<typeof setInterval>;
64
+ private readonly now: () => Date;
65
+ constructor(private readonly deps: AutomationServiceDeps) {
66
+ this.now = deps.now ?? (() => new Date());
67
+ for (const run of deps.store.runs()) {
68
+ if (run.status === 'running')
69
+ this.finish(run, {
70
+ status: 'interrupted',
71
+ error:
72
+ 'The computer restarted before this run finished. Review any saved or external output before retrying.',
73
+ });
74
+ }
75
+ }
76
+ registerBuiltin(
77
+ id: string,
78
+ name: string,
79
+ schedule: AutomationSchedule,
80
+ enabled = true,
81
+ ) {
82
+ const previous = this.deps.store.jobs().find((job) => job.id === id);
83
+ const configSignature = JSON.stringify({ schedule, enabled });
84
+ if (previous?.configSignature === configSignature) return;
85
+ const now = this.now().toISOString();
86
+ this.deps.store.saveJob({
87
+ id,
88
+ kind: 'builtin',
89
+ name,
90
+ schedule,
91
+ enabled,
92
+ configSignature,
93
+ catchUp: 'skip',
94
+ nextRunAt: nextOccurrence(schedule, this.now()),
95
+ createdAt: previous?.createdAt ?? now,
96
+ updatedAt: now,
97
+ });
98
+ }
99
+ start() {
100
+ if (this.timer) return;
101
+ const tick = () => {
102
+ try {
103
+ this.tick();
104
+ } catch (error) {
105
+ this.deps.logger?.(`Automations: ${String(error)}`);
106
+ }
107
+ };
108
+ tick();
109
+ this.timer = setInterval(tick, 30_000);
110
+ this.timer.unref();
111
+ }
112
+ async stop() {
113
+ clearInterval(this.timer);
114
+ this.timer = undefined;
115
+ const active = [...this.active.values()];
116
+ for (const entry of active) entry.controller.abort();
117
+ await Promise.allSettled(active.map((entry) => entry.done));
118
+ }
119
+ snapshot(
120
+ options: {
121
+ jobId?: string;
122
+ runId?: string;
123
+ before?: string;
124
+ limit?: number;
125
+ } = {},
126
+ ): AutomationSnapshot {
127
+ const history = this.deps.store.runs();
128
+ const all = options.runId
129
+ ? [this.deps.store.run(options.runId)]
130
+ : history.filter(
131
+ (run) =>
132
+ (!options.jobId || run.jobId === options.jobId) &&
133
+ (!options.before || run.id < options.before),
134
+ );
135
+ const limit = Math.min(30, Math.max(1, options.limit ?? 20));
136
+ return {
137
+ jobs: this.deps.store.jobs(),
138
+ runs: all.slice(0, limit).map((run) =>
139
+ options.runId
140
+ ? run
141
+ : {
142
+ ...run,
143
+ guidance: undefined,
144
+ tasteDraft: undefined,
145
+ designDraft: undefined,
146
+ summary: run.summary.slice(0, 4000),
147
+ },
148
+ ),
149
+ pendingRuns: history.flatMap((run) =>
150
+ (run.status === 'running' ||
151
+ run.status === 'needs_review' ||
152
+ run.status === 'failed' ||
153
+ run.status === 'interrupted') &&
154
+ !run.acknowledgedAt
155
+ ? [
156
+ {
157
+ id: run.id,
158
+ jobName: run.jobName,
159
+ jobId: run.jobId,
160
+ status: run.status,
161
+ startedAt: run.startedAt,
162
+ },
163
+ ]
164
+ : [],
165
+ ),
166
+ ...(all.length > limit ? { nextBefore: all[limit - 1]!.id } : {}),
167
+ connections: this.deps.connections(),
168
+ scheduledWork: this.deps.scheduledWork(),
169
+ computerName: this.deps.computerName,
170
+ supportedSources: this.deps.supportedSources?.(),
171
+ };
172
+ }
173
+ private job(id: string) {
174
+ const job = this.deps.store.jobs().find((entry) => entry.id === id);
175
+ if (!job) throw new Error('Automation not found');
176
+ return job;
177
+ }
178
+ private saveJob(job: AutomationJob) {
179
+ this.deps.store.saveJob({ ...job, updatedAt: this.now().toISOString() });
180
+ this.deps.changed?.();
181
+ }
182
+ private assertIdle(jobId: string) {
183
+ if (this.active.has(jobId))
184
+ throw new Error(
185
+ 'This automation already has a running job. Open it or cancel it before starting another.',
186
+ );
187
+ }
188
+ async command(raw: AutomationCommand | unknown): Promise<AutomationSnapshot> {
189
+ const command = AutomationCommandSchema.parse(raw);
190
+ let runId: string | undefined,
191
+ jobId: string | undefined,
192
+ message: string | undefined;
193
+ if (command.action === 'save') {
194
+ if (command.input.repoId) this.deps.validateRepo(command.input.repoId);
195
+ const previous = command.jobId ? this.job(command.jobId) : undefined;
196
+ if (previous?.kind === 'builtin')
197
+ throw new Error('Use schedule controls to edit a built-in job.');
198
+ if (previous?.input && previous.input.workflow !== command.input.workflow)
199
+ throw new Error(
200
+ 'Create a separate automation to change workflow type.',
201
+ );
202
+ if (command.input.enabled) {
203
+ if (command.input.schedule.frequency === 'manual')
204
+ throw new Error('Choose a schedule before enabling recurring runs.');
205
+ this.deps.validateInput?.(command.input);
206
+ }
207
+ jobId = previous?.id ?? uuidv7();
208
+ const now = this.now().toISOString();
209
+ this.saveJob({
210
+ id: jobId,
211
+ kind: isDesignerInput(command.input) ? 'deck-designer' : 'agent',
212
+ name: command.input.name,
213
+ input: command.input,
214
+ enabled: command.input.enabled,
215
+ pausedUntil: command.input.enabled ? previous?.pausedUntil : undefined,
216
+ catchUp: command.input.catchUp,
217
+ schedule: command.input.schedule,
218
+ nextRunAt: nextOccurrence(
219
+ command.input.schedule,
220
+ new Date(
221
+ Math.max(
222
+ Date.parse(now),
223
+ command.input.enabled && previous?.pausedUntil
224
+ ? Date.parse(previous.pausedUntil)
225
+ : 0,
226
+ ),
227
+ ),
228
+ ),
229
+ createdAt: previous?.createdAt ?? now,
230
+ updatedAt: now,
231
+ });
232
+ } else if (command.action === 'enable' || command.action === 'schedule') {
233
+ const job = this.job(command.jobId);
234
+ if (command.action === 'schedule') {
235
+ job.schedule = command.schedule;
236
+ if (command.schedule.frequency === 'manual') {
237
+ job.enabled = false;
238
+ if (job.input) job.input.enabled = false;
239
+ }
240
+ if (job.input) job.input.schedule = command.schedule;
241
+ } else {
242
+ if (command.enabled && job.schedule.frequency === 'manual')
243
+ throw new Error(
244
+ 'Choose a schedule before turning this automation on. Run now is available anytime.',
245
+ );
246
+ if (command.enabled && job.input) this.deps.validateInput?.(job.input);
247
+ if (command.pausedUntil && new Date(command.pausedUntil) <= this.now())
248
+ throw new Error('Choose a pause end in the future');
249
+ job.enabled = command.enabled;
250
+ job.pausedUntil = command.pausedUntil;
251
+ if (job.input) job.input.enabled = command.enabled;
252
+ }
253
+ job.nextRunAt = nextOccurrence(
254
+ job.schedule,
255
+ new Date(
256
+ Math.max(
257
+ this.now().getTime(),
258
+ job.pausedUntil ? Date.parse(job.pausedUntil) : 0,
259
+ ),
260
+ ),
261
+ );
262
+ this.saveJob(job);
263
+ } else if (command.action === 'run') {
264
+ const job = this.job(command.jobId);
265
+ runId = this.launch(
266
+ job,
267
+ job.kind === 'builtin'
268
+ ? 'builtin'
269
+ : job.kind === 'agent'
270
+ ? 'agent'
271
+ : command.stage === 'agent'
272
+ ? 'design'
273
+ : command.stage,
274
+ 'manual',
275
+ );
276
+ } else if (command.action === 'cancel') {
277
+ const run = this.deps.store.run(command.runId);
278
+ const active = this.active.get(run.jobId);
279
+ if (!active || active.runId !== run.id)
280
+ throw new Error('This run has already ended');
281
+ active.controller.abort();
282
+ message =
283
+ 'Cancellation requested. Completed external edits remain available for review.';
284
+ } else {
285
+ const run = this.deps.store.run(command.runId);
286
+ if (run.status === 'running')
287
+ throw new Error('Wait for this run to finish before reviewing it');
288
+ if (command.action === 'acknowledge') {
289
+ run.acknowledgedAt = this.now().toISOString();
290
+ this.deps.store.saveRun(run);
291
+ } else if (command.action === 'review') {
292
+ if (command.decision === 'approve') {
293
+ if (!['needs_review', 'approved'].includes(run.status))
294
+ throw new Error('Only a completed proposal can be approved');
295
+ if (!['agent', 'design', 'revision'].includes(run.stage))
296
+ throw new Error(
297
+ 'Choose a design proposal to approve. Save accepted taste drafts with save-guidance.',
298
+ );
299
+ if (
300
+ run.stage !== 'agent' &&
301
+ !run.directions.some(
302
+ (direction) => direction.id === command.directionId,
303
+ )
304
+ )
305
+ throw new Error('Choose a direction from this run');
306
+ run.selectedDirectionId = command.directionId;
307
+ run.status = 'approved';
308
+ } else run.status = 'archived';
309
+ this.deps.store.saveRun(run);
310
+ } else if (command.action === 'save-guidance') {
311
+ if (
312
+ !run.tasteDraft ||
313
+ !run.designDraft ||
314
+ !['needs_review', 'approved'].includes(run.status)
315
+ )
316
+ throw new Error('This run has no guidance ready to save');
317
+ const saved = await this.deps.saveGuidance(run);
318
+ run.status = 'approved';
319
+ this.deps.store.saveRun(run);
320
+ message =
321
+ saved ??
322
+ 'Saved docs/taste.md and docs/design.md in the repository. Review and commit them so other worktrees can use them.';
323
+ } else {
324
+ const job = this.job(run.jobId);
325
+ if (!run.input || job.kind === 'builtin')
326
+ throw new Error('This action is available for custom automations');
327
+ this.assertIdle(job.id);
328
+ if (command.action === 'implement') {
329
+ if (!isDesignerInput(run.input) || !run.input.repoId)
330
+ throw new Error(
331
+ 'Implementation requires a UI design created with a selected project repository.',
332
+ );
333
+ if (run.status !== 'approved' || !run.selectedDirectionId)
334
+ throw new Error('Approve a design direction before implementation');
335
+ if (
336
+ this.deps.store
337
+ .runs()
338
+ .some(
339
+ (entry) =>
340
+ entry.parentRunId === run.id &&
341
+ entry.stage === 'implementation' &&
342
+ !['failed', 'cancelled', 'interrupted'].includes(
343
+ entry.status,
344
+ ),
345
+ )
346
+ )
347
+ throw new Error('This design already has an implementation run');
348
+ runId = this.launch(
349
+ { ...job, input: run.input },
350
+ 'implementation',
351
+ 'manual',
352
+ run,
353
+ );
354
+ } else {
355
+ if (run.stage === 'implementation')
356
+ throw new Error(
357
+ 'Continue implementation changes on its saved branch. Revise the parent design to create a new proposal.',
358
+ );
359
+ run.feedback.push({
360
+ at: this.now().toISOString(),
361
+ text: command.feedback,
362
+ });
363
+ this.deps.store.saveRun(run);
364
+ runId = this.launch(
365
+ { ...job, input: run.input },
366
+ run.stage === 'agent'
367
+ ? 'agent'
368
+ : run.stage === 'taste'
369
+ ? 'taste'
370
+ : 'revision',
371
+ 'manual',
372
+ run,
373
+ );
374
+ }
375
+ }
376
+ this.deps.changed?.();
377
+ }
378
+ return {
379
+ ...this.snapshot(),
380
+ ...(runId ? { runId } : {}),
381
+ ...(jobId ? { jobId } : {}),
382
+ ...(message ? { message } : {}),
383
+ };
384
+ }
385
+ tick() {
386
+ const now = this.now();
387
+ for (const job of this.deps.store.jobs()) {
388
+ if (!this.deps.scheduledWork() && job.id !== 'builtin:prune') continue;
389
+ if (!job.enabled || (job.pausedUntil && new Date(job.pausedUntil) > now))
390
+ continue;
391
+ if (job.schedule.frequency === 'manual') continue;
392
+ if (!job.nextRunAt) {
393
+ this.saveJob({ ...job, nextRunAt: nextOccurrence(job.schedule, now) });
394
+ continue;
395
+ }
396
+ if (new Date(job.nextRunAt) > now) continue;
397
+ const late = now.getTime() - Date.parse(job.nextRunAt) > 90_000;
398
+ // Claim the scheduled occurrence before inference. A crash never replays it.
399
+ this.saveJob({
400
+ ...job,
401
+ pausedUntil: undefined,
402
+ nextRunAt: nextOccurrence(job.schedule, now),
403
+ });
404
+ if (this.active.has(job.id) || (late && job.catchUp === 'skip')) {
405
+ const at = now.toISOString();
406
+ this.deps.store.saveRun({
407
+ id: uuidv7(),
408
+ jobId: job.id,
409
+ jobName: job.name,
410
+ stage:
411
+ job.kind === 'builtin'
412
+ ? 'builtin'
413
+ : job.kind === 'agent'
414
+ ? 'agent'
415
+ : 'design',
416
+ trigger: 'scheduled',
417
+ status: 'skipped',
418
+ startedAt: at,
419
+ finishedAt: at,
420
+ summary: this.active.has(job.id)
421
+ ? 'Previous run is still active.'
422
+ : 'Scheduled time was missed while the computer was unavailable. Catch-up is disabled.',
423
+ directions: [],
424
+ feedback: [],
425
+ });
426
+ } else
427
+ this.launch(
428
+ job,
429
+ job.kind === 'builtin'
430
+ ? 'builtin'
431
+ : job.kind === 'agent'
432
+ ? 'agent'
433
+ : 'design',
434
+ late ? 'catch-up' : 'scheduled',
435
+ );
436
+ }
437
+ }
438
+ private launch(
439
+ job: AutomationJob,
440
+ stage: AutomationRun['stage'],
441
+ trigger: AutomationRun['trigger'],
442
+ parent?: AutomationRun,
443
+ ): string {
444
+ this.assertIdle(job.id);
445
+ const run: AutomationRun = {
446
+ id: uuidv7(),
447
+ jobId: job.id,
448
+ jobName: job.name,
449
+ stage,
450
+ trigger,
451
+ status: 'running',
452
+ startedAt: this.now().toISOString(),
453
+ summary: 'Starting…',
454
+ input: job.input,
455
+ parentRunId: parent?.id,
456
+ feedback: parent?.feedback ?? [],
457
+ directions: stage === 'implementation' ? (parent?.directions ?? []) : [],
458
+ selectedDirectionId:
459
+ stage === 'implementation' ? parent?.selectedDirectionId : undefined,
460
+ };
461
+ this.deps.store.saveRun(run);
462
+ const controller = new AbortController();
463
+ // Microtask admission makes the active marker visible before any executor can finish.
464
+ const done = Promise.resolve()
465
+ .then(async () => {
466
+ try {
467
+ const result = await this.deps.execute(job, run, controller.signal);
468
+ this.finish(
469
+ run,
470
+ controller.signal.aborted
471
+ ? { ...result, status: 'cancelled' }
472
+ : result,
473
+ );
474
+ } catch (error) {
475
+ this.finish(run, {
476
+ status: controller.signal.aborted ? 'cancelled' : 'failed',
477
+ error: error instanceof Error ? error.message : String(error),
478
+ });
479
+ } finally {
480
+ this.active.delete(job.id);
481
+ this.deps.changed?.();
482
+ }
483
+ })
484
+ .catch((error) => {
485
+ this.deps.logger?.(
486
+ `Could not persist automation result ${run.id}: ${String(error)}`,
487
+ );
488
+ });
489
+ this.active.set(job.id, { runId: run.id, controller, done });
490
+ this.deps.changed?.();
491
+ return run.id;
492
+ }
493
+ private finish(run: AutomationRun, patch: Partial<AutomationRun>) {
494
+ const finishedAt = this.now().toISOString();
495
+ this.deps.store.saveRun({
496
+ ...run,
497
+ status: 'completed',
498
+ ...patch,
499
+ id: run.id,
500
+ jobId: run.jobId,
501
+ finishedAt,
502
+ durationMs: Date.parse(finishedAt) - Date.parse(run.startedAt),
503
+ });
504
+ }
505
+ }
@@ -0,0 +1,71 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import { clientCommand } from '../mcp/clients.js';
5
+ import { CONFIG_DIR } from '../config.js';
6
+
7
+ /** Explicit interactive setup; never launched by a scheduled job or the phone. */
8
+ export async function setupDesign(args: string[]) {
9
+ if (args.includes('--help')) {
10
+ process.stdout.write(
11
+ 'lucidity setup-design\nConnect Figma through the bundled Codex OAuth client and save the daemon’s design connection.\nFor Claude or an authenticated Pinterest server, see docs/deck-designer.md.\n',
12
+ );
13
+ return;
14
+ }
15
+ const path = join(CONFIG_DIR, 'design-mcp.json');
16
+ const config = existsSync(path)
17
+ ? JSON.parse(readFileSync(path, 'utf8'))
18
+ : { mcpServers: {} };
19
+ const server = config.mcpServers?.figma;
20
+ if (
21
+ server &&
22
+ (server.type !== 'http' || server.url !== 'https://mcp.figma.com/mcp')
23
+ )
24
+ throw new Error(
25
+ 'A custom Figma connection already exists. Keep it or edit design-mcp.json explicitly before using this setup.',
26
+ );
27
+ const cli = clientCommand('codex');
28
+ const run = (argv: string[], capture = false): Promise<string> =>
29
+ new Promise((resolve, reject) => {
30
+ const child = spawn(cli.command, [...cli.prefix, ...argv], {
31
+ stdio: capture ? ['ignore', 'pipe', 'pipe'] : 'inherit',
32
+ });
33
+ let output = '';
34
+ child.stdout?.on('data', (data) => {
35
+ output += data;
36
+ });
37
+ child.on('error', () =>
38
+ reject(new Error('Could not start the bundled Codex client')),
39
+ );
40
+ child.on('exit', (code) =>
41
+ code === 0
42
+ ? resolve(output)
43
+ : reject(
44
+ new Error(
45
+ 'Figma setup did not complete. Existing credentials and jobs were preserved.',
46
+ ),
47
+ ),
48
+ );
49
+ });
50
+ const servers = JSON.parse(await run(['mcp', 'list', '--json'], true)) as {
51
+ name: string;
52
+ transport?: { url?: string };
53
+ }[];
54
+ const existing = servers.find((entry) => entry.name === 'figma');
55
+ if (existing && existing.transport?.url !== 'https://mcp.figma.com/mcp')
56
+ throw new Error(
57
+ 'Codex already has a different server named figma. Resolve that name explicitly before connecting.',
58
+ );
59
+ if (!existing)
60
+ await run(['mcp', 'add', 'figma', '--url', 'https://mcp.figma.com/mcp']);
61
+ await run(['mcp', 'login', 'figma']);
62
+ mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
63
+ config.mcpServers = {
64
+ ...config.mcpServers,
65
+ figma: server ?? { type: 'http', url: 'https://mcp.figma.com/mcp' },
66
+ };
67
+ writeFileSync(path, JSON.stringify(config, null, 2) + '\n', { mode: 0o600 });
68
+ process.stdout.write(
69
+ 'Figma is configured for Codex design runs. In Lucidity, open Automations, save your board and Figma links, and run Study my taste.\n',
70
+ );
71
+ }
@@ -0,0 +1,40 @@
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
+ import { dirname, join } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+
5
+ /** Project-scoped installation is explicit and never replaces a customized skill. */
6
+ export function installAutomationSkill(
7
+ client: string = 'both',
8
+ root = process.cwd(),
9
+ ) {
10
+ if (!['claude', 'codex', 'both'].includes(client))
11
+ throw new Error(
12
+ 'Use lucidity automations install-skill [claude|codex|both] from your project directory.',
13
+ );
14
+ const directory = dirname(fileURLToPath(import.meta.url));
15
+ const source = [
16
+ join(directory, '../skills/lucidity-automations/SKILL.md'),
17
+ join(directory, '../../skills/lucidity-automations/SKILL.md'),
18
+ ].find(existsSync);
19
+ if (!source)
20
+ throw new Error(
21
+ 'This installation is missing the automation skill. Reinstall Lucidity.',
22
+ );
23
+ const content = readFileSync(source, 'utf8');
24
+ const targets = (
25
+ client === 'both'
26
+ ? ['.agents', '.claude']
27
+ : [client === 'codex' ? '.agents' : '.claude']
28
+ ).map((folder) => join(root, folder, 'skills/lucidity-automations/SKILL.md'));
29
+ for (const target of targets)
30
+ if (existsSync(target) && readFileSync(target, 'utf8') !== content)
31
+ throw new Error(
32
+ `A customized skill exists at ${target}. Keep it or update it explicitly; it was not replaced.`,
33
+ );
34
+ for (const target of targets) {
35
+ if (existsSync(target)) continue;
36
+ mkdirSync(dirname(target), { recursive: true });
37
+ writeFileSync(target, content, { flag: 'wx' });
38
+ }
39
+ return targets;
40
+ }
@@ -0,0 +1,63 @@
1
+ import {
2
+ existsSync,
3
+ mkdirSync,
4
+ readFileSync,
5
+ readdirSync,
6
+ renameSync,
7
+ writeFileSync,
8
+ } from 'node:fs';
9
+ import { join } from 'node:path';
10
+ import {
11
+ AutomationJobSchema,
12
+ AutomationRunSchema,
13
+ type AutomationJob,
14
+ type AutomationRun,
15
+ } from '@lucidity/shared';
16
+
17
+ /** Only the daemon writes this store; CLI and phone go through its authenticated gateway. */
18
+ export class AutomationStore {
19
+ constructor(readonly directory: string) {
20
+ mkdirSync(join(directory, 'runs'), { recursive: true, mode: 0o700 });
21
+ }
22
+ private write(path: string, value: unknown) {
23
+ const temporary = `${path}.tmp`;
24
+ writeFileSync(temporary, JSON.stringify(value, null, 2), { mode: 0o600 });
25
+ renameSync(temporary, path);
26
+ }
27
+ jobs(): AutomationJob[] {
28
+ const path = join(this.directory, 'jobs.json');
29
+ if (!existsSync(path)) return [];
30
+ // Corruption must be surfaced, never mistaken for an empty store and overwritten.
31
+ return AutomationJobSchema.array().parse(
32
+ JSON.parse(readFileSync(path, 'utf8')),
33
+ );
34
+ }
35
+ saveJob(job: AutomationJob) {
36
+ const jobs = this.jobs();
37
+ this.write(join(this.directory, 'jobs.json'), [
38
+ ...jobs.filter((row) => row.id !== job.id),
39
+ AutomationJobSchema.parse(job),
40
+ ]);
41
+ }
42
+ run(id: string): AutomationRun {
43
+ if (!/^[a-zA-Z0-9-]+$/.test(id)) throw new Error('Invalid run ID');
44
+ return AutomationRunSchema.parse(
45
+ JSON.parse(
46
+ readFileSync(join(this.directory, 'runs', `${id}.json`), 'utf8'),
47
+ ),
48
+ );
49
+ }
50
+ saveRun(run: AutomationRun) {
51
+ if (!/^[a-zA-Z0-9-]+$/.test(run.id)) throw new Error('Invalid run ID');
52
+ this.write(
53
+ join(this.directory, 'runs', `${run.id}.json`),
54
+ AutomationRunSchema.parse(run),
55
+ );
56
+ }
57
+ runs(): AutomationRun[] {
58
+ return readdirSync(join(this.directory, 'runs'))
59
+ .filter((name) => name.endsWith('.json'))
60
+ .map((name) => this.run(name.slice(0, -5)))
61
+ .sort((a, b) => b.id.localeCompare(a.id));
62
+ }
63
+ }