lastlight 0.16.0 → 0.16.1

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 (385) hide show
  1. package/README.md +71 -692
  2. package/dist/cli-config.js.map +1 -0
  3. package/dist/cli-format.js.map +1 -0
  4. package/dist/{cli/cli-server.d.ts → cli-server.d.ts} +26 -1
  5. package/dist/{cli/cli-server.js → cli-server.js} +40 -5
  6. package/dist/cli-server.js.map +1 -0
  7. package/dist/cli-timeline.js.map +1 -0
  8. package/dist/{cli/cli.js → cli.js} +4 -3
  9. package/dist/cli.js.map +1 -0
  10. package/dist/{cli/fork-cli.d.ts → fork-cli.d.ts} +3 -3
  11. package/dist/{cli/fork-cli.js → fork-cli.js} +28 -27
  12. package/dist/fork-cli.js.map +1 -0
  13. package/dist/{cli/oauth-cli.js → oauth-cli.js} +1 -1
  14. package/dist/oauth-cli.js.map +1 -0
  15. package/dist/{cli/setup.js → setup.js} +10 -4
  16. package/dist/setup.js.map +1 -0
  17. package/dist/{cli/skills-install.d.ts → skills-install.d.ts} +6 -0
  18. package/dist/{cli/skills-install.js → skills-install.js} +6 -2
  19. package/dist/skills-install.js.map +1 -0
  20. package/package.json +20 -65
  21. package/plugins/lastlight/.claude-plugin/plugin.json +1 -1
  22. package/agent-context/rules.md +0 -80
  23. package/agent-context/security.md +0 -69
  24. package/agent-context/soul.md +0 -21
  25. package/config/default.yaml +0 -119
  26. package/deploy/.env.production.example +0 -100
  27. package/deploy/entrypoint.sh +0 -82
  28. package/deploy/native/README.md +0 -160
  29. package/deploy/native/install.sh +0 -110
  30. package/deploy/native/lastlight.env.example +0 -95
  31. package/deploy/native/lastlight.service +0 -50
  32. package/deploy/sandbox-entrypoint.sh +0 -93
  33. package/dist/admin/auth.d.ts +0 -51
  34. package/dist/admin/auth.js +0 -121
  35. package/dist/admin/auth.js.map +0 -1
  36. package/dist/admin/chat-session-reader.d.ts +0 -39
  37. package/dist/admin/chat-session-reader.js +0 -84
  38. package/dist/admin/chat-session-reader.js.map +0 -1
  39. package/dist/admin/docker.d.ts +0 -61
  40. package/dist/admin/docker.js +0 -187
  41. package/dist/admin/docker.js.map +0 -1
  42. package/dist/admin/index.d.ts +0 -9
  43. package/dist/admin/index.js +0 -59
  44. package/dist/admin/index.js.map +0 -1
  45. package/dist/admin/routes.d.ts +0 -81
  46. package/dist/admin/routes.js +0 -1381
  47. package/dist/admin/routes.js.map +0 -1
  48. package/dist/admin/sessions.d.ts +0 -89
  49. package/dist/admin/sessions.js +0 -204
  50. package/dist/admin/sessions.js.map +0 -1
  51. package/dist/admin/tail.d.ts +0 -12
  52. package/dist/admin/tail.js +0 -145
  53. package/dist/admin/tail.js.map +0 -1
  54. package/dist/admin/version.d.ts +0 -22
  55. package/dist/admin/version.js +0 -92
  56. package/dist/admin/version.js.map +0 -1
  57. package/dist/cli/cli-config.js.map +0 -1
  58. package/dist/cli/cli-format.js.map +0 -1
  59. package/dist/cli/cli-server.js.map +0 -1
  60. package/dist/cli/cli-timeline.js.map +0 -1
  61. package/dist/cli/cli.js.map +0 -1
  62. package/dist/cli/fork-cli.js.map +0 -1
  63. package/dist/cli/oauth-cli.js.map +0 -1
  64. package/dist/cli/setup.js.map +0 -1
  65. package/dist/cli/skills-install.js.map +0 -1
  66. package/dist/config/config-resolve.d.ts +0 -28
  67. package/dist/config/config-resolve.js +0 -47
  68. package/dist/config/config-resolve.js.map +0 -1
  69. package/dist/config/config.d.ts +0 -157
  70. package/dist/config/config.js +0 -581
  71. package/dist/config/config.js.map +0 -1
  72. package/dist/config/core-pin.d.ts +0 -16
  73. package/dist/config/core-pin.js +0 -85
  74. package/dist/config/core-pin.js.map +0 -1
  75. package/dist/config/overlay-assets.d.ts +0 -20
  76. package/dist/config/overlay-assets.js +0 -114
  77. package/dist/config/overlay-assets.js.map +0 -1
  78. package/dist/config/overlay-bootstrap.d.ts +0 -44
  79. package/dist/config/overlay-bootstrap.js +0 -304
  80. package/dist/config/overlay-bootstrap.js.map +0 -1
  81. package/dist/connectors/github-webhook.d.ts +0 -45
  82. package/dist/connectors/github-webhook.js +0 -321
  83. package/dist/connectors/github-webhook.js.map +0 -1
  84. package/dist/connectors/index.d.ts +0 -18
  85. package/dist/connectors/index.js +0 -41
  86. package/dist/connectors/index.js.map +0 -1
  87. package/dist/connectors/messaging/base.d.ts +0 -42
  88. package/dist/connectors/messaging/base.js +0 -139
  89. package/dist/connectors/messaging/base.js.map +0 -1
  90. package/dist/connectors/messaging/delivery.d.ts +0 -14
  91. package/dist/connectors/messaging/delivery.js +0 -38
  92. package/dist/connectors/messaging/delivery.js.map +0 -1
  93. package/dist/connectors/messaging/index.d.ts +0 -4
  94. package/dist/connectors/messaging/index.js +0 -4
  95. package/dist/connectors/messaging/index.js.map +0 -1
  96. package/dist/connectors/messaging/session-manager.d.ts +0 -53
  97. package/dist/connectors/messaging/session-manager.js +0 -255
  98. package/dist/connectors/messaging/session-manager.js.map +0 -1
  99. package/dist/connectors/messaging/types.d.ts +0 -58
  100. package/dist/connectors/messaging/types.js +0 -7
  101. package/dist/connectors/messaging/types.js.map +0 -1
  102. package/dist/connectors/slack/connector.d.ts +0 -142
  103. package/dist/connectors/slack/connector.js +0 -494
  104. package/dist/connectors/slack/connector.js.map +0 -1
  105. package/dist/connectors/slack/index.d.ts +0 -2
  106. package/dist/connectors/slack/index.js +0 -3
  107. package/dist/connectors/slack/index.js.map +0 -1
  108. package/dist/connectors/slack/mrkdwn.d.ts +0 -19
  109. package/dist/connectors/slack/mrkdwn.js +0 -240
  110. package/dist/connectors/slack/mrkdwn.js.map +0 -1
  111. package/dist/connectors/types.d.ts +0 -61
  112. package/dist/connectors/types.js +0 -2
  113. package/dist/connectors/types.js.map +0 -1
  114. package/dist/cron/fanout.d.ts +0 -33
  115. package/dist/cron/fanout.js +0 -55
  116. package/dist/cron/fanout.js.map +0 -1
  117. package/dist/cron/jobs.d.ts +0 -18
  118. package/dist/cron/jobs.js +0 -37
  119. package/dist/cron/jobs.js.map +0 -1
  120. package/dist/cron/scheduler.d.ts +0 -45
  121. package/dist/cron/scheduler.js +0 -105
  122. package/dist/cron/scheduler.js.map +0 -1
  123. package/dist/engine/agent-executor.d.ts +0 -34
  124. package/dist/engine/agent-executor.js +0 -246
  125. package/dist/engine/agent-executor.js.map +0 -1
  126. package/dist/engine/chat/chat-runner.d.ts +0 -132
  127. package/dist/engine/chat/chat-runner.js +0 -424
  128. package/dist/engine/chat/chat-runner.js.map +0 -1
  129. package/dist/engine/chat/chat-skills.d.ts +0 -45
  130. package/dist/engine/chat/chat-skills.js +0 -184
  131. package/dist/engine/chat/chat-skills.js.map +0 -1
  132. package/dist/engine/chat/chat.d.ts +0 -54
  133. package/dist/engine/chat/chat.js +0 -316
  134. package/dist/engine/chat/chat.js.map +0 -1
  135. package/dist/engine/chat/message-batcher.d.ts +0 -32
  136. package/dist/engine/chat/message-batcher.js +0 -109
  137. package/dist/engine/chat/message-batcher.js.map +0 -1
  138. package/dist/engine/dispatcher.d.ts +0 -73
  139. package/dist/engine/dispatcher.js +0 -663
  140. package/dist/engine/dispatcher.js.map +0 -1
  141. package/dist/engine/event-shim.d.ts +0 -117
  142. package/dist/engine/event-shim.js +0 -435
  143. package/dist/engine/event-shim.js.map +0 -1
  144. package/dist/engine/executors/orchestrator.d.ts +0 -81
  145. package/dist/engine/executors/orchestrator.js +0 -365
  146. package/dist/engine/executors/orchestrator.js.map +0 -1
  147. package/dist/engine/executors/shared.d.ts +0 -189
  148. package/dist/engine/executors/shared.js +0 -616
  149. package/dist/engine/executors/shared.js.map +0 -1
  150. package/dist/engine/github/git-auth.d.ts +0 -62
  151. package/dist/engine/github/git-auth.js +0 -161
  152. package/dist/engine/github/git-auth.js.map +0 -1
  153. package/dist/engine/github/github-app-client.d.ts +0 -23
  154. package/dist/engine/github/github-app-client.js +0 -33
  155. package/dist/engine/github/github-app-client.js.map +0 -1
  156. package/dist/engine/github/github-tools.d.ts +0 -18
  157. package/dist/engine/github/github-tools.js +0 -263
  158. package/dist/engine/github/github-tools.js.map +0 -1
  159. package/dist/engine/github/github.d.ts +0 -1193
  160. package/dist/engine/github/github.js +0 -357
  161. package/dist/engine/github/github.js.map +0 -1
  162. package/dist/engine/github/profiles.d.ts +0 -279
  163. package/dist/engine/github/profiles.js +0 -42
  164. package/dist/engine/github/profiles.js.map +0 -1
  165. package/dist/engine/github/review-poster.d.ts +0 -98
  166. package/dist/engine/github/review-poster.js +0 -177
  167. package/dist/engine/github/review-poster.js.map +0 -1
  168. package/dist/engine/llm.d.ts +0 -79
  169. package/dist/engine/llm.js +0 -269
  170. package/dist/engine/llm.js.map +0 -1
  171. package/dist/engine/oauth.d.ts +0 -43
  172. package/dist/engine/oauth.js +0 -103
  173. package/dist/engine/oauth.js.map +0 -1
  174. package/dist/engine/router.d.ts +0 -29
  175. package/dist/engine/router.js +0 -680
  176. package/dist/engine/router.js.map +0 -1
  177. package/dist/engine/screen/classifier.d.ts +0 -93
  178. package/dist/engine/screen/classifier.js +0 -215
  179. package/dist/engine/screen/classifier.js.map +0 -1
  180. package/dist/engine/screen/screen.d.ts +0 -41
  181. package/dist/engine/screen/screen.js +0 -93
  182. package/dist/engine/screen/screen.js.map +0 -1
  183. package/dist/evals-api.d.ts +0 -24
  184. package/dist/evals-api.js +0 -22
  185. package/dist/evals-api.js.map +0 -1
  186. package/dist/index.d.ts +0 -1
  187. package/dist/index.js +0 -940
  188. package/dist/index.js.map +0 -1
  189. package/dist/managed-repos.d.ts +0 -30
  190. package/dist/managed-repos.js +0 -72
  191. package/dist/managed-repos.js.map +0 -1
  192. package/dist/notify/blocks.d.ts +0 -23
  193. package/dist/notify/blocks.js +0 -118
  194. package/dist/notify/blocks.js.map +0 -1
  195. package/dist/notify/index.d.ts +0 -17
  196. package/dist/notify/index.js +0 -7
  197. package/dist/notify/index.js.map +0 -1
  198. package/dist/notify/model.d.ts +0 -57
  199. package/dist/notify/model.js +0 -89
  200. package/dist/notify/model.js.map +0 -1
  201. package/dist/notify/notifier.d.ts +0 -18
  202. package/dist/notify/notifier.js +0 -100
  203. package/dist/notify/notifier.js.map +0 -1
  204. package/dist/notify/render.d.ts +0 -21
  205. package/dist/notify/render.js +0 -59
  206. package/dist/notify/render.js.map +0 -1
  207. package/dist/notify/transports/github.d.ts +0 -26
  208. package/dist/notify/transports/github.js +0 -27
  209. package/dist/notify/transports/github.js.map +0 -1
  210. package/dist/notify/transports/slack.d.ts +0 -27
  211. package/dist/notify/transports/slack.js +0 -37
  212. package/dist/notify/transports/slack.js.map +0 -1
  213. package/dist/notify/types.d.ts +0 -119
  214. package/dist/notify/types.js +0 -16
  215. package/dist/notify/types.js.map +0 -1
  216. package/dist/providers.d.ts +0 -125
  217. package/dist/providers.js +0 -279
  218. package/dist/providers.js.map +0 -1
  219. package/dist/sandbox/docker.d.ts +0 -180
  220. package/dist/sandbox/docker.js +0 -517
  221. package/dist/sandbox/docker.js.map +0 -1
  222. package/dist/sandbox/egress-allowlist.d.ts +0 -74
  223. package/dist/sandbox/egress-allowlist.js +0 -164
  224. package/dist/sandbox/egress-allowlist.js.map +0 -1
  225. package/dist/sandbox/egress-firewall-config.d.ts +0 -127
  226. package/dist/sandbox/egress-firewall-config.js +0 -434
  227. package/dist/sandbox/egress-firewall-config.js.map +0 -1
  228. package/dist/sandbox/images.d.ts +0 -23
  229. package/dist/sandbox/images.js +0 -55
  230. package/dist/sandbox/images.js.map +0 -1
  231. package/dist/sandbox/index.d.ts +0 -112
  232. package/dist/sandbox/index.js +0 -332
  233. package/dist/sandbox/index.js.map +0 -1
  234. package/dist/sandbox/sandbox.d.ts +0 -214
  235. package/dist/sandbox/sandbox.js +0 -453
  236. package/dist/sandbox/sandbox.js.map +0 -1
  237. package/dist/sandbox/smol.d.ts +0 -162
  238. package/dist/sandbox/smol.js +0 -485
  239. package/dist/sandbox/smol.js.map +0 -1
  240. package/dist/session-log.d.ts +0 -63
  241. package/dist/session-log.js +0 -290
  242. package/dist/session-log.js.map +0 -1
  243. package/dist/state/approval-store.d.ts +0 -88
  244. package/dist/state/approval-store.js +0 -149
  245. package/dist/state/approval-store.js.map +0 -1
  246. package/dist/state/build-assets.d.ts +0 -50
  247. package/dist/state/build-assets.js +0 -154
  248. package/dist/state/build-assets.js.map +0 -1
  249. package/dist/state/db.d.ts +0 -81
  250. package/dist/state/db.js +0 -155
  251. package/dist/state/db.js.map +0 -1
  252. package/dist/state/execution-store.d.ts +0 -257
  253. package/dist/state/execution-store.js +0 -527
  254. package/dist/state/execution-store.js.map +0 -1
  255. package/dist/state/migrate.d.ts +0 -15
  256. package/dist/state/migrate.js +0 -175
  257. package/dist/state/migrate.js.map +0 -1
  258. package/dist/state/workflow-run-store.d.ts +0 -216
  259. package/dist/state/workflow-run-store.js +0 -403
  260. package/dist/state/workflow-run-store.js.map +0 -1
  261. package/dist/telemetry/index.d.ts +0 -38
  262. package/dist/telemetry/index.js +0 -253
  263. package/dist/telemetry/index.js.map +0 -1
  264. package/dist/telemetry/pi-events.d.ts +0 -12
  265. package/dist/telemetry/pi-events.js +0 -134
  266. package/dist/telemetry/pi-events.js.map +0 -1
  267. package/dist/workflows/dag.d.ts +0 -37
  268. package/dist/workflows/dag.js +0 -118
  269. package/dist/workflows/dag.js.map +0 -1
  270. package/dist/workflows/loader.d.ts +0 -53
  271. package/dist/workflows/loader.js +0 -421
  272. package/dist/workflows/loader.js.map +0 -1
  273. package/dist/workflows/loop-eval.d.ts +0 -28
  274. package/dist/workflows/loop-eval.js +0 -74
  275. package/dist/workflows/loop-eval.js.map +0 -1
  276. package/dist/workflows/phase-executor.d.ts +0 -222
  277. package/dist/workflows/phase-executor.js +0 -1153
  278. package/dist/workflows/phase-executor.js.map +0 -1
  279. package/dist/workflows/phase-ref.d.ts +0 -50
  280. package/dist/workflows/phase-ref.js +0 -91
  281. package/dist/workflows/phase-ref.js.map +0 -1
  282. package/dist/workflows/resume.d.ts +0 -58
  283. package/dist/workflows/resume.js +0 -313
  284. package/dist/workflows/resume.js.map +0 -1
  285. package/dist/workflows/runner.d.ts +0 -63
  286. package/dist/workflows/runner.js +0 -381
  287. package/dist/workflows/runner.js.map +0 -1
  288. package/dist/workflows/schema.d.ts +0 -344
  289. package/dist/workflows/schema.js +0 -460
  290. package/dist/workflows/schema.js.map +0 -1
  291. package/dist/workflows/simple.d.ts +0 -90
  292. package/dist/workflows/simple.js +0 -393
  293. package/dist/workflows/simple.js.map +0 -1
  294. package/dist/workflows/target-policy.d.ts +0 -74
  295. package/dist/workflows/target-policy.js +0 -80
  296. package/dist/workflows/target-policy.js.map +0 -1
  297. package/dist/workflows/templates.d.ts +0 -88
  298. package/dist/workflows/templates.js +0 -127
  299. package/dist/workflows/templates.js.map +0 -1
  300. package/dist/workflows/triggers.d.ts +0 -21
  301. package/dist/workflows/triggers.js +0 -45
  302. package/dist/workflows/triggers.js.map +0 -1
  303. package/dist/workflows/verdict.d.ts +0 -19
  304. package/dist/workflows/verdict.js +0 -30
  305. package/dist/workflows/verdict.js.map +0 -1
  306. package/dist/worktree/manager.d.ts +0 -43
  307. package/dist/worktree/manager.js +0 -127
  308. package/dist/worktree/manager.js.map +0 -1
  309. package/docker-compose.yml +0 -274
  310. package/sandbox.Dockerfile +0 -68
  311. package/skills/README.md +0 -42
  312. package/skills/browser-qa/SKILL.md +0 -208
  313. package/skills/browser-qa/scripts/agent-browser.mjs +0 -531
  314. package/skills/building/SKILL.md +0 -95
  315. package/skills/chat/SKILL.md +0 -36
  316. package/skills/code-review/SKILL.md +0 -82
  317. package/skills/debug-production/SKILL.md +0 -108
  318. package/skills/demo/SKILL.md +0 -228
  319. package/skills/demo/scripts/compose-demo.sh +0 -243
  320. package/skills/issue-answer/SKILL.md +0 -91
  321. package/skills/issue-comment/SKILL.md +0 -49
  322. package/skills/issue-triage/SKILL.md +0 -149
  323. package/skills/issue-triage/references/AGENT-BRIEF.md +0 -65
  324. package/skills/pr-comment/SKILL.md +0 -64
  325. package/skills/pr-review/SKILL.md +0 -148
  326. package/skills/pr-review/references/findings-schema.md +0 -89
  327. package/skills/qa-test/SKILL.md +0 -97
  328. package/skills/repo-health/SKILL.md +0 -67
  329. package/skills/security-feedback/SKILL.md +0 -173
  330. package/skills/security-feedback/references/templates.md +0 -77
  331. package/skills/security-review/SKILL.md +0 -215
  332. package/skills/security-review/references/issue-format.md +0 -302
  333. package/skills/verify/SKILL.md +0 -118
  334. package/workflows/answer.yaml +0 -44
  335. package/workflows/build.yaml +0 -129
  336. package/workflows/cron-health.yaml +0 -6
  337. package/workflows/cron-review.yaml +0 -8
  338. package/workflows/cron-security.yaml +0 -6
  339. package/workflows/cron-triage.yaml +0 -8
  340. package/workflows/demo.yaml +0 -62
  341. package/workflows/examples/bash-smoke.yaml +0 -41
  342. package/workflows/examples/parallel-review.yaml +0 -36
  343. package/workflows/examples/tdd-loop.yaml +0 -17
  344. package/workflows/explore.yaml +0 -80
  345. package/workflows/issue-comment.yaml +0 -15
  346. package/workflows/issue-triage.yaml +0 -22
  347. package/workflows/pr-comment.yaml +0 -16
  348. package/workflows/pr-fix.yaml +0 -17
  349. package/workflows/pr-review.yaml +0 -50
  350. package/workflows/prompts/answer.md +0 -68
  351. package/workflows/prompts/architect.md +0 -44
  352. package/workflows/prompts/classifier.md +0 -60
  353. package/workflows/prompts/classify-adds-info.md +0 -17
  354. package/workflows/prompts/demo.md +0 -125
  355. package/workflows/prompts/executor.md +0 -42
  356. package/workflows/prompts/explore-ask.md +0 -99
  357. package/workflows/prompts/explore-publish.md +0 -31
  358. package/workflows/prompts/explore-read.md +0 -120
  359. package/workflows/prompts/explore-synthesize.md +0 -88
  360. package/workflows/prompts/fix.md +0 -18
  361. package/workflows/prompts/guardrails.md +0 -96
  362. package/workflows/prompts/pr-fix.md +0 -26
  363. package/workflows/prompts/pr.md +0 -39
  364. package/workflows/prompts/qa-browser.md +0 -95
  365. package/workflows/prompts/qa-synth.md +0 -44
  366. package/workflows/prompts/qa-test.md +0 -60
  367. package/workflows/prompts/re-reviewer.md +0 -33
  368. package/workflows/prompts/reviewer.md +0 -60
  369. package/workflows/prompts/verify-browser.md +0 -93
  370. package/workflows/prompts/verify-synth.md +0 -44
  371. package/workflows/prompts/verify.md +0 -63
  372. package/workflows/qa-test.yaml +0 -94
  373. package/workflows/repo-health.yaml +0 -15
  374. package/workflows/security-feedback.yaml +0 -25
  375. package/workflows/security-review.yaml +0 -37
  376. package/workflows/verify.yaml +0 -93
  377. /package/dist/{cli/cli-config.d.ts → cli-config.d.ts} +0 -0
  378. /package/dist/{cli/cli-config.js → cli-config.js} +0 -0
  379. /package/dist/{cli/cli-format.d.ts → cli-format.d.ts} +0 -0
  380. /package/dist/{cli/cli-format.js → cli-format.js} +0 -0
  381. /package/dist/{cli/cli-timeline.d.ts → cli-timeline.d.ts} +0 -0
  382. /package/dist/{cli/cli-timeline.js → cli-timeline.js} +0 -0
  383. /package/dist/{cli/cli.d.ts → cli.d.ts} +0 -0
  384. /package/dist/{cli/oauth-cli.d.ts → oauth-cli.d.ts} +0 -0
  385. /package/dist/{cli/setup.d.ts → setup.d.ts} +0 -0
@@ -1,175 +0,0 @@
1
- /**
2
- * Apply the full SQLite schema for the harness state DB.
3
- *
4
- * Centralized here (rather than on a store) because the three stores
5
- * (`WorkflowRunStore` / `ApprovalStore` / `ExecutionStore`) all share a
6
- * single `Database` connection and assume the schema already exists. `StateDb`
7
- * is the construction root and calls this once at boot; tests that exercise a
8
- * store directly construct a raw `Database`, call `migrate()`, then build the
9
- * store on top.
10
- *
11
- * Every statement is idempotent (`IF NOT EXISTS` / additive `ALTER` guarded by
12
- * try/catch) so it is safe to run on an existing DB.
13
- */
14
- export function migrate(db) {
15
- db.exec(`
16
- CREATE TABLE IF NOT EXISTS executions (
17
- id TEXT PRIMARY KEY,
18
- trigger_type TEXT NOT NULL,
19
- trigger_id TEXT NOT NULL,
20
- skill TEXT NOT NULL,
21
- repo TEXT,
22
- issue_number INTEGER,
23
- started_at TEXT NOT NULL,
24
- finished_at TEXT,
25
- success INTEGER,
26
- error TEXT,
27
- turns INTEGER,
28
- duration_ms INTEGER
29
- );
30
-
31
- CREATE INDEX IF NOT EXISTS idx_executions_trigger ON executions(trigger_type, trigger_id);
32
- CREATE INDEX IF NOT EXISTS idx_executions_skill ON executions(skill, started_at);
33
-
34
- CREATE TABLE IF NOT EXISTS workflow_runs (
35
- id TEXT PRIMARY KEY,
36
- workflow_name TEXT NOT NULL,
37
- trigger_id TEXT NOT NULL,
38
- repo TEXT,
39
- issue_number INTEGER,
40
- current_phase TEXT NOT NULL,
41
- phase_history TEXT NOT NULL DEFAULT '[]',
42
- status TEXT NOT NULL DEFAULT 'running',
43
- context TEXT,
44
- started_at TEXT NOT NULL,
45
- updated_at TEXT NOT NULL,
46
- finished_at TEXT
47
- );
48
- CREATE INDEX IF NOT EXISTS idx_workflow_runs_trigger ON workflow_runs(trigger_id, status);
49
- CREATE INDEX IF NOT EXISTS idx_workflow_runs_status ON workflow_runs(status);
50
- -- Dashboard's workflow-runs list query is ORDER BY started_at DESC
51
- -- LIMIT 20, often with optional workflow_name / status filters and a
52
- -- companion COUNT(*). It polls every 5s, so it's worth a covering
53
- -- index — without one this is a full-table sort.
54
- CREATE INDEX IF NOT EXISTS idx_workflow_runs_started_at ON workflow_runs(started_at DESC);
55
- CREATE INDEX IF NOT EXISTS idx_workflow_runs_name_started ON workflow_runs(workflow_name, started_at DESC);
56
-
57
- CREATE TABLE IF NOT EXISTS cron_overrides (
58
- name TEXT PRIMARY KEY,
59
- enabled INTEGER NOT NULL DEFAULT 1,
60
- schedule TEXT,
61
- updated_at TEXT NOT NULL,
62
- updated_by TEXT
63
- );
64
-
65
- CREATE TABLE IF NOT EXISTS workflow_overrides (
66
- name TEXT PRIMARY KEY,
67
- enabled INTEGER NOT NULL DEFAULT 1,
68
- updated_at TEXT NOT NULL,
69
- updated_by TEXT
70
- );
71
-
72
- CREATE TABLE IF NOT EXISTS workflow_approvals (
73
- id TEXT PRIMARY KEY,
74
- workflow_run_id TEXT NOT NULL,
75
- gate TEXT NOT NULL,
76
- summary TEXT NOT NULL,
77
- status TEXT NOT NULL DEFAULT 'pending',
78
- requested_by TEXT,
79
- responded_by TEXT,
80
- response TEXT,
81
- responded_at TEXT,
82
- created_at TEXT NOT NULL
83
- );
84
- CREATE INDEX IF NOT EXISTS idx_approvals_workflow ON workflow_approvals(workflow_run_id);
85
- CREATE INDEX IF NOT EXISTS idx_approvals_status ON workflow_approvals(status);
86
- `);
87
- // Mutable phase-to-phase state for features like the socratic explore
88
- // loop that accumulate data across reply-gate pauses.
89
- try {
90
- db.exec(`ALTER TABLE workflow_runs ADD COLUMN scratch TEXT`);
91
- }
92
- catch {
93
- // Column already exists — ignore
94
- }
95
- // Restart attempt counter — bumped each time resumeOrphanedWorkflows
96
- // re-dispatches a still-'running' row at boot. Acts as a circuit
97
- // breaker so an OOM-on-restart loop can't churn forever.
98
- try {
99
- db.exec(`ALTER TABLE workflow_runs ADD COLUMN restart_count INTEGER NOT NULL DEFAULT 0`);
100
- }
101
- catch {
102
- // Column already exists — ignore
103
- }
104
- // Gate flavor: 'approve' (explicit approve/reject) vs 'reply' (resolves
105
- // on any free-form reply in the same thread — used by the socratic
106
- // explore loop).
107
- try {
108
- db.exec(`ALTER TABLE workflow_approvals ADD COLUMN kind TEXT NOT NULL DEFAULT 'approve'`);
109
- }
110
- catch {
111
- // Column already exists — ignore
112
- }
113
- // Artifact (handoff doc) filename a gate is asking the reviewer to approve,
114
- // e.g. 'architect-plan.md'. Lets the focused approval view open the right
115
- // doc. Nullable — most gates carry no artifact. Additive, safe on existing DBs.
116
- try {
117
- db.exec(`ALTER TABLE workflow_approvals ADD COLUMN artifact TEXT`);
118
- }
119
- catch {
120
- // Column already exists — ignore
121
- }
122
- // Add session_id column to executions so the dashboard can resolve a
123
- // phase click to its agent session log. Additive — safe on existing DBs.
124
- try {
125
- db.exec(`ALTER TABLE executions ADD COLUMN session_id TEXT`);
126
- }
127
- catch {
128
- // Column already exists — ignore
129
- }
130
- // Per-execution runtime usage metrics, captured from the OpenCode
131
- // step_finish events. Lets the dashboard show cost / tokens per phase
132
- // and lets us aggregate spend later. All additive, safe on existing DBs.
133
- for (const col of [
134
- "cost_usd REAL",
135
- "input_tokens INTEGER",
136
- "cache_creation_input_tokens INTEGER",
137
- "cache_read_input_tokens INTEGER",
138
- "output_tokens INTEGER",
139
- "api_duration_ms INTEGER",
140
- "stop_reason TEXT",
141
- // Links a phase execution to its owning workflow_run. Dedup and
142
- // "already running / done" checks scope to this column so a fresh
143
- // re-trigger of the same workflow on the same issue creates new
144
- // executions instead of reusing the old run's rows.
145
- "workflow_run_id TEXT",
146
- // Final assistant text for a phase execution. Populated only for
147
- // loop iterations whose output is referenced by `scratch.<key>
148
- // .lastOutputExecutionId` — keeps the inlined LLM output out of
149
- // `workflow_runs.scratch` (which is read on every list query)
150
- // while still being available to the runner's resume path.
151
- "output_text TEXT",
152
- // JSON map of agentic-pi extensions active for this execution
153
- // (file-search / github / web-search → {status, mode?, provider?,
154
- // toolCount?, reason?}). Surfaced in the dashboard phase-detail panel.
155
- "extension_status TEXT",
156
- // JSON object of agentic-pi's skill-loading status for this execution
157
- // ({status, discovered, skills[], mappedPaths, noSkills}). The skill-
158
- // loading counterpart to extension_status; surfaced in the same panel.
159
- "skills_status TEXT",
160
- ]) {
161
- try {
162
- db.exec(`ALTER TABLE executions ADD COLUMN ${col}`);
163
- }
164
- catch {
165
- // Column already exists — ignore
166
- }
167
- }
168
- try {
169
- db.exec(`CREATE INDEX IF NOT EXISTS idx_executions_workflow_run ON executions(workflow_run_id, skill)`);
170
- }
171
- catch {
172
- // Index already exists — ignore
173
- }
174
- }
175
- //# sourceMappingURL=migrate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/state/migrate.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,OAAO,CAAC,EAAqB;IAC3C,EAAE,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEP,CAAC,CAAC;IAEH,sEAAsE;IACtE,sDAAsD;IACtD,IAAI,CAAC;QACH,EAAE,CAAC,IAAI,CAAC,mDAAmD,CAAC,CAAC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,iCAAiC;IACnC,CAAC;IAED,qEAAqE;IACrE,iEAAiE;IACjE,yDAAyD;IACzD,IAAI,CAAC;QACH,EAAE,CAAC,IAAI,CAAC,+EAA+E,CAAC,CAAC;IAC3F,CAAC;IAAC,MAAM,CAAC;QACP,iCAAiC;IACnC,CAAC;IAED,wEAAwE;IACxE,mEAAmE;IACnE,iBAAiB;IACjB,IAAI,CAAC;QACH,EAAE,CAAC,IAAI,CAAC,gFAAgF,CAAC,CAAC;IAC5F,CAAC;IAAC,MAAM,CAAC;QACP,iCAAiC;IACnC,CAAC;IAED,4EAA4E;IAC5E,0EAA0E;IAC1E,gFAAgF;IAChF,IAAI,CAAC;QACH,EAAE,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAC;IACrE,CAAC;IAAC,MAAM,CAAC;QACP,iCAAiC;IACnC,CAAC;IAED,qEAAqE;IACrE,yEAAyE;IACzE,IAAI,CAAC;QACH,EAAE,CAAC,IAAI,CAAC,mDAAmD,CAAC,CAAC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,iCAAiC;IACnC,CAAC;IAED,kEAAkE;IAClE,sEAAsE;IACtE,yEAAyE;IACzE,KAAK,MAAM,GAAG,IAAI;QAChB,eAAe;QACf,sBAAsB;QACtB,qCAAqC;QACrC,iCAAiC;QACjC,uBAAuB;QACvB,yBAAyB;QACzB,kBAAkB;QAClB,gEAAgE;QAChE,kEAAkE;QAClE,gEAAgE;QAChE,oDAAoD;QACpD,sBAAsB;QACtB,iEAAiE;QACjE,+DAA+D;QAC/D,gEAAgE;QAChE,8DAA8D;QAC9D,2DAA2D;QAC3D,kBAAkB;QAClB,8DAA8D;QAC9D,kEAAkE;QAClE,uEAAuE;QACvE,uBAAuB;QACvB,sEAAsE;QACtE,sEAAsE;QACtE,uEAAuE;QACvE,oBAAoB;KACrB,EAAE,CAAC;QACF,IAAI,CAAC;YACH,EAAE,CAAC,IAAI,CAAC,qCAAqC,GAAG,EAAE,CAAC,CAAC;QACtD,CAAC;QAAC,MAAM,CAAC;YACP,iCAAiC;QACnC,CAAC;IACH,CAAC;IACD,IAAI,CAAC;QACH,EAAE,CAAC,IAAI,CACL,8FAA8F,CAC/F,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,gCAAgC;IAClC,CAAC;AACH,CAAC"}
@@ -1,216 +0,0 @@
1
- import type Database from "better-sqlite3";
2
- import type { ApprovalStore } from "./approval-store.js";
3
- export interface PhaseHistoryEntry {
4
- phase: string;
5
- timestamp: string;
6
- success: boolean;
7
- summary?: string;
8
- }
9
- export interface WorkflowRun {
10
- id: string;
11
- workflowName: string;
12
- triggerId: string;
13
- repo?: string;
14
- issueNumber?: number;
15
- currentPhase: string;
16
- phaseHistory: PhaseHistoryEntry[];
17
- status: "running" | "paused" | "succeeded" | "failed" | "cancelled";
18
- context?: Record<string, unknown>;
19
- /**
20
- * Mutable phase-to-phase state, merged at the top level by
21
- * `mergeScratch`. Distinct from `context` (which is the immutable trigger
22
- * input) — used by features like the socratic explore loop to accumulate
23
- * Q&A across reply-gate pauses.
24
- */
25
- scratch?: Record<string, unknown>;
26
- /**
27
- * Number of times `resumeOrphanedWorkflows` has re-dispatched this run
28
- * after a harness restart. Bounded by a small limit so a run that
29
- * crashes the host (e.g. agent OOM) is marked failed instead of
30
- * retried forever.
31
- */
32
- restartCount?: number;
33
- startedAt: string;
34
- updatedAt: string;
35
- finishedAt?: string;
36
- }
37
- /** A non-agent phase marker folded into an atomic lifecycle op. */
38
- export interface PhaseMarker {
39
- phase: string;
40
- summary?: string;
41
- }
42
- /**
43
- * Aggregate root for a workflow run's lifecycle. Owns the `workflow_runs`
44
- * table (including the `phase_history` JSON column) and the named, atomic
45
- * transitions a run moves through: create → pause-for-approval →
46
- * resume/finish, plus gate resolution and the socratic reply append.
47
- *
48
- * Carved out of the old `StateDb` god-class (issue #97). The deepening: every
49
- * multi-step mutation that previously lived as an un-guarded read-modify-write
50
- * chain in `index.ts` / `admin/routes.ts` / `phase-executor.ts` is now a
51
- * single named operation wrapped in ONE `better-sqlite3` transaction — a throw
52
- * partway through rolls the whole thing back, so a run can never be left
53
- * marked `running` with its gate unresolved (the hazard the issue calls out).
54
- *
55
- * Constructed with an injected {@link ApprovalStore}: an approval has no life
56
- * independent of its run, so the cross-table ops call the approval store's
57
- * single-table writes from inside this store's transaction. Both stores MUST
58
- * be built from the same `Database` — better-sqlite3 transactions are
59
- * per-connection.
60
- *
61
- * The long-running re-dispatch (`dispatchWorkflow`, which spawns a Docker
62
- * sandbox for minutes) is deliberately NOT part of any transaction here —
63
- * better-sqlite3 transactions are synchronous. The atomic boundary is the DB
64
- * mutations only; the caller dispatches after the transaction commits.
65
- */
66
- export declare class WorkflowRunStore {
67
- private db;
68
- private approvals;
69
- constructor(db: Database.Database, deps: {
70
- approvals: ApprovalStore;
71
- });
72
- /** Create a new workflow run record */
73
- createRun(run: Omit<WorkflowRun, "phaseHistory" | "updatedAt">): void;
74
- /**
75
- * Top-level merge of `patch` into the workflow run's scratch state.
76
- * Loop iterations can append to `scratch.socratic.qa` without clobbering
77
- * other keys.
78
- *
79
- * Throws if `patch` is not JSON-serializable (e.g. it contains a BigInt) —
80
- * which is exactly how the atomic ops prove their rollback: a poison patch
81
- * makes `JSON.stringify` throw mid-transaction.
82
- */
83
- mergeScratch(id: string, patch: Record<string, unknown>): void;
84
- /**
85
- * Update the current phase and append to phase history. This is the single
86
- * seam through which all phase-history writes flow (issue #97 defers the
87
- * full `phase_history`/`executions` reconciliation to a follow-up, but
88
- * routes every write through here so that future change touches one method
89
- * instead of ~10 call sites).
90
- */
91
- appendPhase(id: string, phase: string, entry: PhaseHistoryEntry): void;
92
- /** Get a single workflow run by ID */
93
- getRun(id: string): WorkflowRun | null;
94
- /** Find the most recent active (running or paused) workflow run for a trigger */
95
- getByTrigger(triggerId: string): WorkflowRun | null;
96
- /**
97
- * True if any run of `workflowName` exists for this trigger, in ANY status.
98
- * Unlike `getByTrigger` (active runs only), this also sees a build that has
99
- * already succeeded/failed/cancelled — the signal the router uses to gate
100
- * reporter-driven re-triage to the pre-build window.
101
- */
102
- hasRunForTrigger(triggerId: string, workflowName: string): boolean;
103
- /** List all active (running or paused) workflow runs */
104
- listActive(): WorkflowRun[];
105
- /** List recent workflow runs, ordered by start time descending */
106
- listRecent(limit?: number): WorkflowRun[];
107
- /**
108
- * List workflow runs with pagination + filters. Returns the page slice
109
- * AND the post-filter total so the dashboard knows how many remain.
110
- *
111
- * - sinceIso filters `started_at >= sinceIso` (used for the header date range).
112
- * - workflowName filters by exact `workflow_name`.
113
- * - statuses filters to one of the workflow statuses (`running`, `paused`,
114
- * `succeeded`, `failed`, `cancelled`). Used for the dashboard's "live"
115
- * filter, which maps to ['running','paused'].
116
- */
117
- list(opts?: {
118
- limit?: number;
119
- offset?: number;
120
- sinceIso?: string;
121
- workflowName?: string;
122
- statuses?: string[];
123
- }): {
124
- runs: WorkflowRun[];
125
- total: number;
126
- };
127
- /** Distinct workflow_name values, sorted alphabetically. */
128
- distinctNames(): string[];
129
- /**
130
- * Mark a workflow run as finished. Plain status flip when called with just
131
- * `{ error }`; when a `terminalMarker` is supplied (the runner's
132
- * `on_success.set_phase`), the phase-history append and the status flip
133
- * happen in ONE transaction so the dashboard never sees the terminal phase
134
- * without the finished status, or vice versa.
135
- */
136
- finishRun(id: string, status: "succeeded" | "failed" | "cancelled", opts?: {
137
- error?: string;
138
- terminalMarker?: PhaseMarker;
139
- }): void;
140
- private flipFinished;
141
- /** Cancel a workflow run */
142
- cancelRun(id: string): void;
143
- /** Pause a workflow run (waiting for approval) */
144
- setPaused(id: string): void;
145
- /** Resume a paused workflow run (set back to running) */
146
- setRunning(id: string): void;
147
- /**
148
- * Restart a FAILED run so it can be retried from the phase that failed.
149
- * Unlike {@link setRunning} this also clears the terminal markers a failure
150
- * left behind — `finished_at` and the `context.error` string `flipFinished`
151
- * wrote — so the row reads live again rather than "failed at …". The taskId,
152
- * branch, scratch and phase_history are all preserved, so the ledger-driven
153
- * re-dispatch (`resumeSimpleRun`) resumes from the failed phase with the same
154
- * context.
155
- *
156
- * Guarded by `WHERE status = 'failed'` and returns the changed-row count so
157
- * the caller can make retry a compare-and-set: a second concurrent retry
158
- * click sees 0 rows changed and does NOT dispatch again.
159
- */
160
- restartRun(id: string): number;
161
- /**
162
- * Increment the restart counter and return the new value. Used by
163
- * `resumeOrphanedWorkflows` to enforce a retry budget so a run that
164
- * crashes the host (agent OOM, etc.) eventually self-terminates instead
165
- * of being re-dispatched on every boot.
166
- */
167
- incrementRestartCount(id: string): number;
168
- private deserialize;
169
- /**
170
- * Resolve a socratic reply gate and resume the run, atomically: the reply
171
- * gate flips `pending → approved` (recording the reply text), the caller's
172
- * scratch patch merges in, and the run goes back to `running` — all in one
173
- * transaction. A throw anywhere rolls the whole thing back, so the run can
174
- * never be left `running` with its gate unresolved or its reply lost (the
175
- * hazard issue #97 calls out).
176
- *
177
- * The reply-gate resolve is guarded by `kind = 'reply' AND status = 'pending'`
178
- * (see {@link ApprovalStore.resolveReplyGate}); if it changes zero rows —
179
- * because a racing reply already resolved the gate — this throws and the
180
- * transaction aborts, which is the double-reply concurrency guard.
181
- *
182
- * The caller (`index.ts`) computes the explore-domain `scratch.socratic.qa`
183
- * patch and passes it in; the generic store stays ignorant of that shape.
184
- */
185
- /**
186
- * Pause a run for an approval gate, atomically: create the pending approval,
187
- * optionally merge a scratch patch (loops persist their iteration state
188
- * here), append the `waiting_approval` phase marker, and flip the run to
189
- * `paused` — all in one transaction. Covers the standard post-phase gate,
190
- * the reviewer-loop gate, and the interactive generic-loop gate.
191
- *
192
- * The marker is appended BEFORE the approval insert so that an insert
193
- * failure provably rolls back the phase-history write (the injected
194
- * ApprovalStore participates in the same transaction); ordering is invisible
195
- * outside the transaction.
196
- */
197
- pauseForApproval(runId: string, approval: Parameters<ApprovalStore["create"]>[0], marker: PhaseMarker, scratchPatch?: Record<string, unknown>): void;
198
- /**
199
- * Approve a gate and resume its run, atomically. Reads the approval to find
200
- * its run, records the `approved` response, and flips the run back to
201
- * `running` in one transaction; returns the run so the caller can dispatch.
202
- * Used by the GitHub/Slack path (`index.ts`), which validates the dispatch
203
- * target BEFORE calling this so the flip to `running` is always followed by a
204
- * dispatch. The dashboard path does NOT use this — it can't prove a dispatch
205
- * will follow before responding, so it records the approval and lets
206
- * `resumeWorkflow` flip the run only as part of an actual dispatch.
207
- */
208
- resolveGateAndResume(approvalId: string, responder: string): WorkflowRun | null;
209
- /**
210
- * Reject a gate and fail its run, atomically: record the `rejected` response
211
- * (with reason) and flip the run to `failed` in one transaction. Returns the
212
- * run (or null if the approval's run was already gone).
213
- */
214
- resolveGateAndFail(approvalId: string, responder: string, reason?: string): WorkflowRun | null;
215
- resolveReplyGateAndResume(runId: string, approvalId: string, replyText: string, responder: string, scratchPatch: Record<string, unknown>): WorkflowRun | null;
216
- }