lastlight-core 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 (345) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +10 -0
  3. package/agent-context/rules.md +80 -0
  4. package/agent-context/security.md +69 -0
  5. package/agent-context/soul.md +21 -0
  6. package/config/default.yaml +119 -0
  7. package/deploy/.env.production.example +100 -0
  8. package/deploy/entrypoint.sh +82 -0
  9. package/deploy/native/README.md +160 -0
  10. package/deploy/native/install.sh +110 -0
  11. package/deploy/native/lastlight.env.example +95 -0
  12. package/deploy/native/lastlight.service +50 -0
  13. package/deploy/sandbox-entrypoint.sh +93 -0
  14. package/deploy/slack/README.md +92 -0
  15. package/deploy/slack/slack-manifest.json +55 -0
  16. package/dist/admin/auth.d.ts +51 -0
  17. package/dist/admin/auth.js +121 -0
  18. package/dist/admin/auth.js.map +1 -0
  19. package/dist/admin/chat-session-reader.d.ts +39 -0
  20. package/dist/admin/chat-session-reader.js +84 -0
  21. package/dist/admin/chat-session-reader.js.map +1 -0
  22. package/dist/admin/docker.d.ts +61 -0
  23. package/dist/admin/docker.js +187 -0
  24. package/dist/admin/docker.js.map +1 -0
  25. package/dist/admin/index.d.ts +9 -0
  26. package/dist/admin/index.js +59 -0
  27. package/dist/admin/index.js.map +1 -0
  28. package/dist/admin/routes.d.ts +81 -0
  29. package/dist/admin/routes.js +1381 -0
  30. package/dist/admin/routes.js.map +1 -0
  31. package/dist/admin/sessions.d.ts +89 -0
  32. package/dist/admin/sessions.js +204 -0
  33. package/dist/admin/sessions.js.map +1 -0
  34. package/dist/admin/tail.d.ts +12 -0
  35. package/dist/admin/tail.js +145 -0
  36. package/dist/admin/tail.js.map +1 -0
  37. package/dist/admin/version.d.ts +22 -0
  38. package/dist/admin/version.js +92 -0
  39. package/dist/admin/version.js.map +1 -0
  40. package/dist/config/config-resolve.d.ts +28 -0
  41. package/dist/config/config-resolve.js +47 -0
  42. package/dist/config/config-resolve.js.map +1 -0
  43. package/dist/config/config.d.ts +140 -0
  44. package/dist/config/config.js +581 -0
  45. package/dist/config/config.js.map +1 -0
  46. package/dist/connectors/github-webhook.d.ts +45 -0
  47. package/dist/connectors/github-webhook.js +321 -0
  48. package/dist/connectors/github-webhook.js.map +1 -0
  49. package/dist/connectors/index.d.ts +18 -0
  50. package/dist/connectors/index.js +41 -0
  51. package/dist/connectors/index.js.map +1 -0
  52. package/dist/connectors/messaging/base.d.ts +42 -0
  53. package/dist/connectors/messaging/base.js +139 -0
  54. package/dist/connectors/messaging/base.js.map +1 -0
  55. package/dist/connectors/messaging/delivery.d.ts +14 -0
  56. package/dist/connectors/messaging/delivery.js +38 -0
  57. package/dist/connectors/messaging/delivery.js.map +1 -0
  58. package/dist/connectors/messaging/index.d.ts +4 -0
  59. package/dist/connectors/messaging/index.js +4 -0
  60. package/dist/connectors/messaging/index.js.map +1 -0
  61. package/dist/connectors/messaging/session-manager.d.ts +53 -0
  62. package/dist/connectors/messaging/session-manager.js +255 -0
  63. package/dist/connectors/messaging/session-manager.js.map +1 -0
  64. package/dist/connectors/messaging/types.d.ts +58 -0
  65. package/dist/connectors/messaging/types.js +7 -0
  66. package/dist/connectors/messaging/types.js.map +1 -0
  67. package/dist/connectors/slack/connector.d.ts +142 -0
  68. package/dist/connectors/slack/connector.js +494 -0
  69. package/dist/connectors/slack/connector.js.map +1 -0
  70. package/dist/connectors/slack/index.d.ts +2 -0
  71. package/dist/connectors/slack/index.js +3 -0
  72. package/dist/connectors/slack/index.js.map +1 -0
  73. package/dist/connectors/slack/mrkdwn.d.ts +19 -0
  74. package/dist/connectors/slack/mrkdwn.js +240 -0
  75. package/dist/connectors/slack/mrkdwn.js.map +1 -0
  76. package/dist/connectors/types.d.ts +61 -0
  77. package/dist/connectors/types.js +2 -0
  78. package/dist/connectors/types.js.map +1 -0
  79. package/dist/cron/fanout.d.ts +33 -0
  80. package/dist/cron/fanout.js +55 -0
  81. package/dist/cron/fanout.js.map +1 -0
  82. package/dist/cron/jobs.d.ts +18 -0
  83. package/dist/cron/jobs.js +37 -0
  84. package/dist/cron/jobs.js.map +1 -0
  85. package/dist/cron/scheduler.d.ts +45 -0
  86. package/dist/cron/scheduler.js +105 -0
  87. package/dist/cron/scheduler.js.map +1 -0
  88. package/dist/engine/agent-executor.d.ts +34 -0
  89. package/dist/engine/agent-executor.js +246 -0
  90. package/dist/engine/agent-executor.js.map +1 -0
  91. package/dist/engine/chat/chat-runner.d.ts +132 -0
  92. package/dist/engine/chat/chat-runner.js +424 -0
  93. package/dist/engine/chat/chat-runner.js.map +1 -0
  94. package/dist/engine/chat/chat-skills.d.ts +45 -0
  95. package/dist/engine/chat/chat-skills.js +184 -0
  96. package/dist/engine/chat/chat-skills.js.map +1 -0
  97. package/dist/engine/chat/chat.d.ts +54 -0
  98. package/dist/engine/chat/chat.js +316 -0
  99. package/dist/engine/chat/chat.js.map +1 -0
  100. package/dist/engine/chat/message-batcher.d.ts +32 -0
  101. package/dist/engine/chat/message-batcher.js +109 -0
  102. package/dist/engine/chat/message-batcher.js.map +1 -0
  103. package/dist/engine/dispatcher.d.ts +73 -0
  104. package/dist/engine/dispatcher.js +663 -0
  105. package/dist/engine/dispatcher.js.map +1 -0
  106. package/dist/engine/event-shim.d.ts +117 -0
  107. package/dist/engine/event-shim.js +435 -0
  108. package/dist/engine/event-shim.js.map +1 -0
  109. package/dist/engine/executors/orchestrator.d.ts +74 -0
  110. package/dist/engine/executors/orchestrator.js +365 -0
  111. package/dist/engine/executors/orchestrator.js.map +1 -0
  112. package/dist/engine/executors/shared.d.ts +189 -0
  113. package/dist/engine/executors/shared.js +616 -0
  114. package/dist/engine/executors/shared.js.map +1 -0
  115. package/dist/engine/github/git-auth.d.ts +62 -0
  116. package/dist/engine/github/git-auth.js +161 -0
  117. package/dist/engine/github/git-auth.js.map +1 -0
  118. package/dist/engine/github/github-app-client.d.ts +23 -0
  119. package/dist/engine/github/github-app-client.js +33 -0
  120. package/dist/engine/github/github-app-client.js.map +1 -0
  121. package/dist/engine/github/github-tools.d.ts +18 -0
  122. package/dist/engine/github/github-tools.js +263 -0
  123. package/dist/engine/github/github-tools.js.map +1 -0
  124. package/dist/engine/github/github.d.ts +1193 -0
  125. package/dist/engine/github/github.js +357 -0
  126. package/dist/engine/github/github.js.map +1 -0
  127. package/dist/engine/github/profiles.d.ts +11 -0
  128. package/dist/engine/github/profiles.js +42 -0
  129. package/dist/engine/github/profiles.js.map +1 -0
  130. package/dist/engine/github/review-poster.d.ts +98 -0
  131. package/dist/engine/github/review-poster.js +177 -0
  132. package/dist/engine/github/review-poster.js.map +1 -0
  133. package/dist/engine/llm.d.ts +79 -0
  134. package/dist/engine/llm.js +269 -0
  135. package/dist/engine/llm.js.map +1 -0
  136. package/dist/engine/oauth.d.ts +8 -0
  137. package/dist/engine/oauth.js +9 -0
  138. package/dist/engine/oauth.js.map +1 -0
  139. package/dist/engine/router.d.ts +29 -0
  140. package/dist/engine/router.js +680 -0
  141. package/dist/engine/router.js.map +1 -0
  142. package/dist/engine/screen/classifier.d.ts +93 -0
  143. package/dist/engine/screen/classifier.js +215 -0
  144. package/dist/engine/screen/classifier.js.map +1 -0
  145. package/dist/engine/screen/screen.d.ts +41 -0
  146. package/dist/engine/screen/screen.js +93 -0
  147. package/dist/engine/screen/screen.js.map +1 -0
  148. package/dist/evals-api.d.ts +24 -0
  149. package/dist/evals-api.js +22 -0
  150. package/dist/evals-api.js.map +1 -0
  151. package/dist/index.d.ts +1 -0
  152. package/dist/index.js +940 -0
  153. package/dist/index.js.map +1 -0
  154. package/dist/managed-repos.d.ts +30 -0
  155. package/dist/managed-repos.js +72 -0
  156. package/dist/managed-repos.js.map +1 -0
  157. package/dist/notify/blocks.d.ts +23 -0
  158. package/dist/notify/blocks.js +118 -0
  159. package/dist/notify/blocks.js.map +1 -0
  160. package/dist/notify/index.d.ts +17 -0
  161. package/dist/notify/index.js +7 -0
  162. package/dist/notify/index.js.map +1 -0
  163. package/dist/notify/model.d.ts +57 -0
  164. package/dist/notify/model.js +89 -0
  165. package/dist/notify/model.js.map +1 -0
  166. package/dist/notify/notifier.d.ts +18 -0
  167. package/dist/notify/notifier.js +100 -0
  168. package/dist/notify/notifier.js.map +1 -0
  169. package/dist/notify/render.d.ts +21 -0
  170. package/dist/notify/render.js +59 -0
  171. package/dist/notify/render.js.map +1 -0
  172. package/dist/notify/transports/github.d.ts +26 -0
  173. package/dist/notify/transports/github.js +27 -0
  174. package/dist/notify/transports/github.js.map +1 -0
  175. package/dist/notify/transports/slack.d.ts +27 -0
  176. package/dist/notify/transports/slack.js +37 -0
  177. package/dist/notify/transports/slack.js.map +1 -0
  178. package/dist/notify/types.d.ts +111 -0
  179. package/dist/notify/types.js +16 -0
  180. package/dist/notify/types.js.map +1 -0
  181. package/dist/sandbox/docker.d.ts +180 -0
  182. package/dist/sandbox/docker.js +517 -0
  183. package/dist/sandbox/docker.js.map +1 -0
  184. package/dist/sandbox/egress-allowlist.d.ts +74 -0
  185. package/dist/sandbox/egress-allowlist.js +164 -0
  186. package/dist/sandbox/egress-allowlist.js.map +1 -0
  187. package/dist/sandbox/egress-firewall-config.d.ts +127 -0
  188. package/dist/sandbox/egress-firewall-config.js +434 -0
  189. package/dist/sandbox/egress-firewall-config.js.map +1 -0
  190. package/dist/sandbox/images.d.ts +23 -0
  191. package/dist/sandbox/images.js +55 -0
  192. package/dist/sandbox/images.js.map +1 -0
  193. package/dist/sandbox/index.d.ts +112 -0
  194. package/dist/sandbox/index.js +332 -0
  195. package/dist/sandbox/index.js.map +1 -0
  196. package/dist/sandbox/sandbox.d.ts +214 -0
  197. package/dist/sandbox/sandbox.js +453 -0
  198. package/dist/sandbox/sandbox.js.map +1 -0
  199. package/dist/sandbox/smol.d.ts +162 -0
  200. package/dist/sandbox/smol.js +485 -0
  201. package/dist/sandbox/smol.js.map +1 -0
  202. package/dist/session-log.d.ts +63 -0
  203. package/dist/session-log.js +290 -0
  204. package/dist/session-log.js.map +1 -0
  205. package/dist/state/approval-store.d.ts +88 -0
  206. package/dist/state/approval-store.js +149 -0
  207. package/dist/state/approval-store.js.map +1 -0
  208. package/dist/state/build-assets.d.ts +50 -0
  209. package/dist/state/build-assets.js +154 -0
  210. package/dist/state/build-assets.js.map +1 -0
  211. package/dist/state/db.d.ts +81 -0
  212. package/dist/state/db.js +155 -0
  213. package/dist/state/db.js.map +1 -0
  214. package/dist/state/execution-store.d.ts +257 -0
  215. package/dist/state/execution-store.js +527 -0
  216. package/dist/state/execution-store.js.map +1 -0
  217. package/dist/state/migrate.d.ts +15 -0
  218. package/dist/state/migrate.js +175 -0
  219. package/dist/state/migrate.js.map +1 -0
  220. package/dist/state/workflow-run-store.d.ts +216 -0
  221. package/dist/state/workflow-run-store.js +403 -0
  222. package/dist/state/workflow-run-store.js.map +1 -0
  223. package/dist/telemetry/index.d.ts +38 -0
  224. package/dist/telemetry/index.js +253 -0
  225. package/dist/telemetry/index.js.map +1 -0
  226. package/dist/telemetry/pi-events.d.ts +12 -0
  227. package/dist/telemetry/pi-events.js +134 -0
  228. package/dist/telemetry/pi-events.js.map +1 -0
  229. package/dist/workflows/dag.d.ts +1 -0
  230. package/dist/workflows/dag.js +2 -0
  231. package/dist/workflows/dag.js.map +1 -0
  232. package/dist/workflows/handlers/post-review.d.ts +45 -0
  233. package/dist/workflows/handlers/post-review.js +220 -0
  234. package/dist/workflows/handlers/post-review.js.map +1 -0
  235. package/dist/workflows/handlers/verdict-reader.d.ts +14 -0
  236. package/dist/workflows/handlers/verdict-reader.js +55 -0
  237. package/dist/workflows/handlers/verdict-reader.js.map +1 -0
  238. package/dist/workflows/loader.d.ts +9 -0
  239. package/dist/workflows/loader.js +10 -0
  240. package/dist/workflows/loader.js.map +1 -0
  241. package/dist/workflows/loop-eval.d.ts +1 -0
  242. package/dist/workflows/loop-eval.js +2 -0
  243. package/dist/workflows/loop-eval.js.map +1 -0
  244. package/dist/workflows/phase-executor.d.ts +1 -0
  245. package/dist/workflows/phase-executor.js +6 -0
  246. package/dist/workflows/phase-executor.js.map +1 -0
  247. package/dist/workflows/phase-ref.d.ts +1 -0
  248. package/dist/workflows/phase-ref.js +2 -0
  249. package/dist/workflows/phase-ref.js.map +1 -0
  250. package/dist/workflows/resume.d.ts +58 -0
  251. package/dist/workflows/resume.js +313 -0
  252. package/dist/workflows/resume.js.map +1 -0
  253. package/dist/workflows/runner.d.ts +47 -0
  254. package/dist/workflows/runner.js +278 -0
  255. package/dist/workflows/runner.js.map +1 -0
  256. package/dist/workflows/schema.d.ts +1 -0
  257. package/dist/workflows/schema.js +2 -0
  258. package/dist/workflows/schema.js.map +1 -0
  259. package/dist/workflows/simple.d.ts +90 -0
  260. package/dist/workflows/simple.js +393 -0
  261. package/dist/workflows/simple.js.map +1 -0
  262. package/dist/workflows/target-policy.d.ts +74 -0
  263. package/dist/workflows/target-policy.js +80 -0
  264. package/dist/workflows/target-policy.js.map +1 -0
  265. package/dist/workflows/templates.d.ts +1 -0
  266. package/dist/workflows/templates.js +2 -0
  267. package/dist/workflows/templates.js.map +1 -0
  268. package/dist/workflows/triggers.d.ts +21 -0
  269. package/dist/workflows/triggers.js +45 -0
  270. package/dist/workflows/triggers.js.map +1 -0
  271. package/dist/workflows/verdict.d.ts +1 -0
  272. package/dist/workflows/verdict.js +2 -0
  273. package/dist/workflows/verdict.js.map +1 -0
  274. package/dist/worktree/manager.d.ts +43 -0
  275. package/dist/worktree/manager.js +127 -0
  276. package/dist/worktree/manager.js.map +1 -0
  277. package/docker-compose.yml +280 -0
  278. package/package.json +93 -0
  279. package/sandbox.Dockerfile +68 -0
  280. package/skills/README.md +42 -0
  281. package/skills/browser-qa/SKILL.md +208 -0
  282. package/skills/browser-qa/scripts/agent-browser.mjs +531 -0
  283. package/skills/building/SKILL.md +95 -0
  284. package/skills/chat/SKILL.md +36 -0
  285. package/skills/code-review/SKILL.md +82 -0
  286. package/skills/debug-production/SKILL.md +108 -0
  287. package/skills/demo/SKILL.md +228 -0
  288. package/skills/demo/scripts/compose-demo.sh +243 -0
  289. package/skills/issue-answer/SKILL.md +91 -0
  290. package/skills/issue-comment/SKILL.md +49 -0
  291. package/skills/issue-triage/SKILL.md +149 -0
  292. package/skills/issue-triage/references/AGENT-BRIEF.md +65 -0
  293. package/skills/pr-comment/SKILL.md +64 -0
  294. package/skills/pr-review/SKILL.md +148 -0
  295. package/skills/pr-review/references/findings-schema.md +89 -0
  296. package/skills/qa-test/SKILL.md +97 -0
  297. package/skills/repo-health/SKILL.md +67 -0
  298. package/skills/security-feedback/SKILL.md +173 -0
  299. package/skills/security-feedback/references/templates.md +77 -0
  300. package/skills/security-review/SKILL.md +215 -0
  301. package/skills/security-review/references/issue-format.md +302 -0
  302. package/skills/verify/SKILL.md +118 -0
  303. package/workflows/answer.yaml +44 -0
  304. package/workflows/build.yaml +129 -0
  305. package/workflows/cron-health.yaml +6 -0
  306. package/workflows/cron-review.yaml +8 -0
  307. package/workflows/cron-security.yaml +6 -0
  308. package/workflows/cron-triage.yaml +8 -0
  309. package/workflows/demo.yaml +62 -0
  310. package/workflows/examples/bash-smoke.yaml +41 -0
  311. package/workflows/examples/parallel-review.yaml +36 -0
  312. package/workflows/examples/tdd-loop.yaml +17 -0
  313. package/workflows/explore.yaml +80 -0
  314. package/workflows/issue-comment.yaml +15 -0
  315. package/workflows/issue-triage.yaml +22 -0
  316. package/workflows/pr-comment.yaml +16 -0
  317. package/workflows/pr-fix.yaml +17 -0
  318. package/workflows/pr-review.yaml +50 -0
  319. package/workflows/prompts/answer.md +68 -0
  320. package/workflows/prompts/architect.md +44 -0
  321. package/workflows/prompts/classifier.md +60 -0
  322. package/workflows/prompts/classify-adds-info.md +17 -0
  323. package/workflows/prompts/demo.md +125 -0
  324. package/workflows/prompts/executor.md +42 -0
  325. package/workflows/prompts/explore-ask.md +99 -0
  326. package/workflows/prompts/explore-publish.md +31 -0
  327. package/workflows/prompts/explore-read.md +120 -0
  328. package/workflows/prompts/explore-synthesize.md +88 -0
  329. package/workflows/prompts/fix.md +18 -0
  330. package/workflows/prompts/guardrails.md +96 -0
  331. package/workflows/prompts/pr-fix.md +26 -0
  332. package/workflows/prompts/pr.md +39 -0
  333. package/workflows/prompts/qa-browser.md +95 -0
  334. package/workflows/prompts/qa-synth.md +44 -0
  335. package/workflows/prompts/qa-test.md +60 -0
  336. package/workflows/prompts/re-reviewer.md +33 -0
  337. package/workflows/prompts/reviewer.md +60 -0
  338. package/workflows/prompts/verify-browser.md +93 -0
  339. package/workflows/prompts/verify-synth.md +44 -0
  340. package/workflows/prompts/verify.md +63 -0
  341. package/workflows/qa-test.yaml +94 -0
  342. package/workflows/repo-health.yaml +15 -0
  343. package/workflows/security-feedback.yaml +25 -0
  344. package/workflows/security-review.yaml +37 -0
  345. package/workflows/verify.yaml +93 -0
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Per-target sandbox-workspace provisioning policy — which workflows key their
3
+ * workspace by (repo, issue/PR) and how a re-run treats an existing checkout.
4
+ *
5
+ * This is a leaf module (no imports of the runner or the simple entrypoint) so
6
+ * both `simple.ts` (taskId keying) and `runner.ts` (`gitSandboxAccessForWorkflow`)
7
+ * can read the same source of truth without an import cycle. `simple.ts`
8
+ * re-exports these for existing callers (e.g. `src/index.ts`).
9
+ */
10
+ /**
11
+ * Workflows whose workspace is keyed by **(repo, PR)** rather than per-run.
12
+ * For these the taskId drops the run-id suffix so re-reviews of the same PR
13
+ * (push → `synchronize`, cron PR-review fanout) reuse one sandbox dir — a
14
+ * warm `node_modules` + an incremental `git fetch` instead of a fresh
15
+ * 1.3G clone + full install each time, and N dirs/PR collapse to 1 (issue
16
+ * #107, cutting the #106 churn at its source). Concurrency is held off by
17
+ * the dispatcher's `isRunning(skill, triggerId)` guard plus
18
+ * `runs.getByTrigger` reuse — two runs never share the dir live; the
19
+ * cross-run refresh in `prePopulateWorkspace` resets it cleanly between them.
20
+ * `build` is handled by `PER_TARGET_RECREATE_WORKFLOWS` instead — it must not
21
+ * *refresh* a stale checkout (that would reset onto the old feature branch);
22
+ * it recreates the workspace from the default branch.
23
+ */
24
+ export const PER_TARGET_REUSE_WORKFLOWS = new Set(["pr-review", "pr-fix"]);
25
+ /**
26
+ * Workflows whose per-target workspace is **recreated from the default branch**
27
+ * on a fresh run rather than refreshed onto an existing feature branch. Like
28
+ * `PER_TARGET_REUSE_WORKFLOWS`, these key the taskId by (repo, issue) only (no
29
+ * run-id suffix) so a re-run lands on the same dir — but a *different*-run
30
+ * marker triggers a delete + fresh clone off the default branch, not a
31
+ * `git fetch`/reset of the (stale) feature branch. This makes an incomplete
32
+ * `build` disposable: re-triggering it starts again from current `main`
33
+ * (issue #153). A genuine *resume* of the same run (approval gate) still
34
+ * preserves the workspace via the same-run marker — the architect's `plan.md`
35
+ * survives. Concurrency is held off by the dispatcher's
36
+ * `isRunning(skill, triggerId)` guard, so the delete only ever hits a leftover
37
+ * from a finished/abandoned run.
38
+ */
39
+ export const PER_TARGET_RECREATE_WORKFLOWS = new Set(["build"]);
40
+ /**
41
+ * Workflows that synthesize their own `lastlight/N-slug` branch (which doesn't
42
+ * exist on the remote at dispatch time) yet should still pre-populate the
43
+ * sandbox: the agent's cwd becomes the repo root (no `git clone`/`cd`), and —
44
+ * for the read-only `verify`/`qa-test` runs — server-mode artifacts the agent
45
+ * writes to `.lastlight/<key>/` (e.g. browser-QA screenshots) land where
46
+ * `serverArtifacts()` harvests them instead of being orphaned a level up.
47
+ * `build` was the original member; verify/qa-test were added for the harvest
48
+ * fix, and `demo` for the same reason (its `demo.mp4` is written under
49
+ * `.lastlight/<key>/` and harvested into the Artifacts store). For a fresh
50
+ * (issue-scoped) dispatch the dispatcher leaves `prePopulateBranch` unset and
51
+ * the missing-branch fallback in `prePopulateWorkspace` clones the default
52
+ * branch — correct for `build`/`demo`, which *create* the synth branch off the
53
+ * default. But when the *same* workflow runs against an existing PR, the synth
54
+ * `lastlight/<prNumber>-<title-slug>` name won't match the PR's real head ref
55
+ * (named after the originating issue), so the fallback would clone the default
56
+ * branch and test/demo code that lacks the PR — see
57
+ * `PR_HEADREF_PREPOPULATE_WORKFLOWS`.
58
+ */
59
+ export const PREPOPULATE_SYNTH_WORKFLOWS = new Set(["build", "verify", "qa-test", "demo"]);
60
+ /**
61
+ * The subset of PR-scoped read workflows the dispatcher pins to the PR's *real*
62
+ * head ref (via `getPullRequest(...).head.ref`) before pre-populating, instead
63
+ * of letting them fall back to the synthesized `lastlight/N-<title-slug>` name.
64
+ * Each of these is meaningful only against an existing PR, and the synth name
65
+ * never matches the PR's actual branch (which is named after the originating
66
+ * issue, e.g. `lastlight/14-…` for a PR #15). Without this pinning:
67
+ * - `qa-test` / `verify` QA the *base* branch and report the PR's feature
68
+ * missing — a false-negative result.
69
+ * - `demo`'s "after" collapses onto the default branch, matching "before".
70
+ * `pr-fix` is handled separately (it plumbs `branch` through context for the
71
+ * architect/executor to push to). See the resolution block in
72
+ * `dispatchWorkflow` (src/index.ts).
73
+ */
74
+ export const PR_HEADREF_PREPOPULATE_WORKFLOWS = new Set([
75
+ "pr-review",
76
+ "demo",
77
+ "qa-test",
78
+ "verify",
79
+ ]);
80
+ //# sourceMappingURL=target-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"target-policy.js","sourceRoot":"","sources":["../../src/workflows/target-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE3E;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AAEhE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;AAE3F;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,IAAI,GAAG,CAAC;IACtD,WAAW;IACX,MAAM;IACN,SAAS;IACT,QAAQ;CACT,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "lastlight-workflow-engine";
@@ -0,0 +1,2 @@
1
+ export * from "lastlight-workflow-engine";
2
+ //# sourceMappingURL=templates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/workflows/templates.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,21 @@
1
+ export type TriggerInfo = {
2
+ kind: "cron";
3
+ name: string;
4
+ schedule: string;
5
+ } | {
6
+ kind: "github";
7
+ event: string;
8
+ description: string;
9
+ } | {
10
+ kind: "slack";
11
+ command: string;
12
+ description: string;
13
+ } | {
14
+ kind: "mention";
15
+ description: string;
16
+ } | {
17
+ kind: "internal";
18
+ description: string;
19
+ };
20
+ export declare function getWorkflowTriggers(workflowName: string): TriggerInfo[];
21
+ export declare function getWorkflowTriggerKinds(workflowName: string): TriggerInfo["kind"][];
@@ -0,0 +1,45 @@
1
+ import { getCronWorkflows } from "./loader.js";
2
+ import { getRoutes, getBotName } from "../config/config.js";
3
+ function add(map, name, info) {
4
+ if (!name)
5
+ return;
6
+ const effectiveName = name === "github-orchestrator" ? "build" : name;
7
+ map.set(effectiveName, [...(map.get(effectiveName) || []), info]);
8
+ }
9
+ function routeTriggers() {
10
+ const routes = getRoutes();
11
+ const bot = `@${getBotName()}`;
12
+ const map = new Map();
13
+ add(map, routes.github.issue_opened, { kind: "github", event: "issue.opened", description: "An issue is opened" });
14
+ add(map, routes.github.issue_reopened, { kind: "github", event: "issue.reopened", description: "An issue is reopened" });
15
+ add(map, routes.github.pr_opened, { kind: "github", event: "pr.opened", description: "A PR is opened" });
16
+ add(map, routes.github.pr_synchronize, { kind: "github", event: "pr.synchronize", description: "A PR is updated" });
17
+ add(map, routes.github.pr_reopened, { kind: "github", event: "pr.reopened", description: "A PR is reopened" });
18
+ add(map, routes.github.pr_fix, { kind: "mention", description: `\`${bot} build …\` on a PR comment (maintainers only)` });
19
+ add(map, routes.github.pr_comment, { kind: "mention", description: `\`${bot} <message>\` on a PR comment / review` });
20
+ add(map, routes.github.issue_build, { kind: "mention", description: `\`${bot} build …\` on an issue comment (maintainers only)` });
21
+ add(map, routes.github.issue_explore, { kind: "mention", description: `\`${bot} explore …\` on an issue comment` });
22
+ add(map, routes.github.issue_comment, { kind: "mention", description: `\`${bot} <message>\` on an issue comment` });
23
+ add(map, routes.github.security_feedback, { kind: "internal", description: "Chained from `security-review` when issues are found" });
24
+ add(map, routes.slack.build, { kind: "slack", command: "build", description: "Slack: `build <repo>#<n>`" });
25
+ add(map, routes.slack.triage, { kind: "slack", command: "triage", description: "Slack: `triage <repo>`" });
26
+ add(map, routes.slack.review, { kind: "slack", command: "review", description: "Slack: `review <repo>`" });
27
+ add(map, routes.slack.security, { kind: "slack", command: "security", description: "Slack: `security <repo>`" });
28
+ add(map, routes.slack.explore, { kind: "slack", command: "explore", description: "Slack: `explore <repo>#<n>`" });
29
+ return map;
30
+ }
31
+ export function getWorkflowTriggers(workflowName) {
32
+ const cronTriggers = getCronWorkflows()
33
+ .filter((c) => c.workflow === workflowName)
34
+ .map((c) => ({ kind: "cron", name: c.name, schedule: c.schedule }));
35
+ return [...cronTriggers, ...(routeTriggers().get(workflowName) ?? [])];
36
+ }
37
+ export function getWorkflowTriggerKinds(workflowName) {
38
+ const triggers = getWorkflowTriggers(workflowName);
39
+ const seen = new Set();
40
+ for (const t of triggers)
41
+ seen.add(t.kind);
42
+ const order = ["cron", "github", "mention", "slack", "internal"];
43
+ return order.filter((k) => seen.has(k));
44
+ }
45
+ //# sourceMappingURL=triggers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"triggers.js","sourceRoot":"","sources":["../../src/workflows/triggers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,C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IAAI,GAAG,EAAuB,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,QAAQ;QAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,KAAK,GAA0B,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IACxF,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1C,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "lastlight-workflow-engine";
@@ -0,0 +1,2 @@
1
+ export * from "lastlight-workflow-engine";
2
+ //# sourceMappingURL=verdict.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verdict.js","sourceRoot":"","sources":["../../src/workflows/verdict.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,43 @@
1
+ export interface WorktreeInfo {
2
+ taskId: string;
3
+ path: string;
4
+ branch: string;
5
+ repo: string;
6
+ createdAt: Date;
7
+ }
8
+ /**
9
+ * Manages git worktrees for per-task isolation.
10
+ * Each build task gets its own worktree (isolated working directory + branch).
11
+ * The Docker container the harness runs in IS the sandbox — worktrees provide
12
+ * per-task isolation within that sandbox.
13
+ */
14
+ export declare class WorktreeManager {
15
+ private baseDir;
16
+ private active;
17
+ constructor(baseDir?: string);
18
+ private execGit;
19
+ /**
20
+ * Create a new worktree for a task.
21
+ * Clones the repo first (if not already cloned), then creates a worktree.
22
+ */
23
+ create(opts: {
24
+ taskId: string;
25
+ repoUrl: string;
26
+ branch: string;
27
+ baseBranch?: string;
28
+ }): Promise<WorktreeInfo>;
29
+ /**
30
+ * Get the path for an active worktree.
31
+ */
32
+ getPath(taskId: string): string | null;
33
+ /**
34
+ * Cleanup a worktree. Removes the worktree and optionally the branch.
35
+ */
36
+ cleanup(taskId: string, opts?: {
37
+ deleteBranch?: boolean;
38
+ }): Promise<void>;
39
+ /**
40
+ * List all active worktrees.
41
+ */
42
+ listActive(): WorktreeInfo[];
43
+ }
@@ -0,0 +1,127 @@
1
+ import { execFileSync } from "child_process";
2
+ import { existsSync, mkdirSync, rmSync } from "fs";
3
+ import { join, resolve } from "path";
4
+ const WORKTREE_DIR = ".worktrees";
5
+ /**
6
+ * Manages git worktrees for per-task isolation.
7
+ * Each build task gets its own worktree (isolated working directory + branch).
8
+ * The Docker container the harness runs in IS the sandbox — worktrees provide
9
+ * per-task isolation within that sandbox.
10
+ */
11
+ export class WorktreeManager {
12
+ baseDir;
13
+ active = new Map();
14
+ constructor(baseDir) {
15
+ this.baseDir = baseDir || resolve(WORKTREE_DIR);
16
+ }
17
+ execGit(args, opts) {
18
+ return execFileSync("git", args, { encoding: "utf-8", stdio: "pipe", ...opts });
19
+ }
20
+ /**
21
+ * Create a new worktree for a task.
22
+ * Clones the repo first (if not already cloned), then creates a worktree.
23
+ */
24
+ async create(opts) {
25
+ const { taskId, repoUrl, branch, baseBranch } = opts;
26
+ if (this.active.has(taskId)) {
27
+ return this.active.get(taskId);
28
+ }
29
+ const worktreePath = join(this.baseDir, taskId);
30
+ // Ensure base directory exists
31
+ if (!existsSync(this.baseDir)) {
32
+ mkdirSync(this.baseDir, { recursive: true });
33
+ }
34
+ // We need a bare/normal repo to create worktrees from.
35
+ // Use a shared bare clone per repo to avoid re-cloning each time.
36
+ const repoName = repoUrl.replace(/.*\/([^/]+?)(?:\.git)?$/, "$1");
37
+ const bareDir = join(this.baseDir, `.bare-${repoName}`);
38
+ if (!existsSync(bareDir)) {
39
+ console.log(`[worktree] Bare clone: ${repoUrl}`);
40
+ this.execGit(["clone", "--bare", repoUrl, bareDir]);
41
+ }
42
+ else {
43
+ // Fetch latest
44
+ this.execGit(["-C", bareDir, "fetch", "--all", "--prune"]);
45
+ }
46
+ // Create worktree with new branch from base
47
+ const base = baseBranch || "main";
48
+ const baseRef = `origin/${base}`;
49
+ // Check if branch already exists remotely
50
+ let branchExists = false;
51
+ try {
52
+ this.execGit(["-C", bareDir, "rev-parse", "--verify", `origin/${branch}`]);
53
+ branchExists = true;
54
+ }
55
+ catch {
56
+ // Branch doesn't exist remotely — that's fine
57
+ }
58
+ if (branchExists) {
59
+ // Resume existing branch
60
+ console.log(`[worktree] Resuming branch: ${branch}`);
61
+ this.execGit(["-C", bareDir, "worktree", "add", worktreePath, `origin/${branch}`]);
62
+ this.execGit(["-C", worktreePath, "checkout", "-B", branch, `origin/${branch}`]);
63
+ }
64
+ else {
65
+ // Create new branch from base
66
+ console.log(`[worktree] New branch: ${branch} from ${baseRef}`);
67
+ this.execGit(["-C", bareDir, "worktree", "add", "-b", branch, worktreePath, baseRef]);
68
+ }
69
+ const info = {
70
+ taskId,
71
+ path: worktreePath,
72
+ branch,
73
+ repo: repoUrl,
74
+ createdAt: new Date(),
75
+ };
76
+ this.active.set(taskId, info);
77
+ return info;
78
+ }
79
+ /**
80
+ * Get the path for an active worktree.
81
+ */
82
+ getPath(taskId) {
83
+ return this.active.get(taskId)?.path || null;
84
+ }
85
+ /**
86
+ * Cleanup a worktree. Removes the worktree and optionally the branch.
87
+ */
88
+ async cleanup(taskId, opts) {
89
+ const info = this.active.get(taskId);
90
+ if (!info)
91
+ return;
92
+ const repoName = info.repo.replace(/.*\/([^/]+?)(?:\.git)?$/, "$1");
93
+ const bareDir = join(this.baseDir, `.bare-${repoName}`);
94
+ try {
95
+ // Remove worktree
96
+ if (existsSync(info.path)) {
97
+ this.execGit(["-C", bareDir, "worktree", "remove", "--force", info.path]);
98
+ }
99
+ }
100
+ catch (err) {
101
+ // Force cleanup if git worktree remove fails
102
+ if (existsSync(info.path)) {
103
+ rmSync(info.path, { recursive: true, force: true });
104
+ try {
105
+ this.execGit(["-C", bareDir, "worktree", "prune"]);
106
+ }
107
+ catch { /* best effort */ }
108
+ }
109
+ }
110
+ // Optionally delete the branch
111
+ if (opts?.deleteBranch) {
112
+ try {
113
+ this.execGit(["-C", bareDir, "branch", "-D", info.branch]);
114
+ }
115
+ catch { /* branch may not exist locally */ }
116
+ }
117
+ this.active.delete(taskId);
118
+ console.log(`[worktree] Cleaned up: ${taskId}`);
119
+ }
120
+ /**
121
+ * List all active worktrees.
122
+ */
123
+ listActive() {
124
+ return Array.from(this.active.values());
125
+ }
126
+ }
127
+ //# sourceMappingURL=manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.js","sourceRoot":"","sources":["../../src/worktree/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwB,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAErC,MAAM,YAAY,GAAG,YAAY,CAAC;AAUlC;;;;;GAKG;AACH,MAAM,OAAO,eAAe;IAClB,OAAO,CAAS;IAChB,MAAM,GAA8B,IAAI,GAAG,EAAE,CAAC;IAEtD,YAAY,OAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IAClD,CAAC;IAEO,OAAO,CAAC,IAAc,EAAE,IAAsB;QACpD,OAAO,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAW,CAAC;IAC5F,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,IAKZ;QACC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;QAErD,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC;QAClC,CAAC;QAED,MAAM,YAAY,GAAG,IAA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CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1C,CAAC;CACF"}
@@ -0,0 +1,280 @@
1
+ # MONOREPO (Phase 2): this file lives at apps/server/ but is always invoked
2
+ # with `--project-directory <repo root>` (see src/cli/cli-server.ts
3
+ # composeFileArgs), so every ./-relative path below — build contexts,
4
+ # ./instance, ./apps/server/Caddyfile — resolves against the REPO ROOT.
5
+ services:
6
+ agent:
7
+ build:
8
+ context: .
9
+ dockerfile: apps/server/Dockerfile
10
+ # Pin the built image tag so it's independent of the compose project name
11
+ # (which otherwise defaults to the checkout directory's basename). The
12
+ # `egress-init` service references this exact tag, so without the pin the
13
+ # stack only worked when the directory happened to be named `lastlight`.
14
+ image: lastlight-agent
15
+ restart: unless-stopped
16
+ ports:
17
+ - "127.0.0.1:8644:8644"
18
+ dns:
19
+ - 8.8.8.8
20
+ - 1.1.1.1
21
+ volumes:
22
+ # Single private deployment folder: overlay config.yaml + asset overrides
23
+ # plus a gitignored secrets/ subdir (.env, *.pem). LASTLIGHT_OVERLAY_DIR
24
+ # points the harness at /app/instance; the entrypoint reads secrets from
25
+ # /app/instance/secrets. This is the only deployment-specific input, read
26
+ # at startup — no image rebuild. To APPLY an edit: `config.yaml` and
27
+ # adding/changing an `.env` value apply on `docker compose restart agent`
28
+ # (the entrypoint re-sources .env). REMOVING an `.env` value needs a
29
+ # RECREATE — `docker compose up -d agent` (or `lastlight server start
30
+ # agent`) — because compose injects env_file vars at container creation
31
+ # and a restart can't unset them. Built-in assets (config/, workflows/,
32
+ # skills/, agent-context/) stay baked into the image; they're lastlight
33
+ # source and change via a normal rebuild.
34
+ - ./instance:/app/instance:ro
35
+ - agent-data:/app/data
36
+ - /var/run/docker.sock:/var/run/docker.sock # spawn sandbox containers
37
+ # Env comes from the consolidated overlay (instance/secrets/.env). The
38
+ # entrypoint also sources it inside the container; this env_file is the
39
+ # belt-and-suspenders copy. required: false so a fresh checkout (no
40
+ # instance/ yet) doesn't error. No repo-root .env is needed.
41
+ env_file:
42
+ - path: ./instance/secrets/.env
43
+ required: false
44
+ environment:
45
+ # V8's default old-space cap (~1.5 GB on 64-bit) is well below the 2g
46
+ # cgroup limit, so Node would OOM before docker did. Raise it close to
47
+ # the container limit so transient bursts have somewhere to land.
48
+ - NODE_OPTIONS=--max-old-space-size=1800
49
+ # Steady-state ~150 MB; bursts during webhook fan-out, the in-process
50
+ # chat skill (full Agent SDK), and the dispatch screening call. 2 GB
51
+ # gives headroom for those bursts while still preventing a runaway leak
52
+ # from taking the host down.
53
+ mem_limit: 2g
54
+ memswap_limit: 2g
55
+ networks:
56
+ - internal
57
+
58
+ # Shared heavy base for the sandbox images (fnm + Node + semgrep/gitleaks + uv
59
+ # + the agent user). Both sandbox and sandbox-qa build FROM it, so it must be
60
+ # built FIRST:
61
+ # docker compose --profile build-only build sandbox-base sandbox sandbox-qa
62
+ # Split out so the frequently-changing agentic-pi/agent-context tail (and, in
63
+ # sandbox-qa, ~300 MB of Chromium) stays cached across ordinary releases.
64
+ sandbox-base:
65
+ build:
66
+ context: .
67
+ dockerfile: apps/server/sandbox-base.Dockerfile
68
+ image: lastlight-sandbox-base:latest
69
+ profiles:
70
+ - build-only # never started as a service, just built
71
+
72
+ # Build the sandbox image (used by the harness to spawn per-task containers).
73
+ # FROM lastlight-sandbox-base:latest — build sandbox-base first.
74
+ sandbox:
75
+ build:
76
+ context: .
77
+ dockerfile: apps/server/sandbox.Dockerfile
78
+ image: lastlight-sandbox:latest
79
+ profiles:
80
+ - build-only # never started as a service, just built
81
+
82
+ # Build the enriched browser-QA sandbox image (Tier B). Separate + heavier
83
+ # (Playwright + a baked Chromium), built only when QA is enabled. Its FROM
84
+ # depends on lastlight-sandbox-base:latest existing first, so build in that order:
85
+ # docker compose --profile build-only build sandbox-base sandbox-qa
86
+ sandbox-qa:
87
+ build:
88
+ context: .
89
+ dockerfile: apps/server/sandbox-qa.Dockerfile
90
+ image: lastlight-sandbox-qa:latest
91
+ profiles:
92
+ - build-only # never started as a service, just built
93
+
94
+ # ── Egress firewall (replaces the earlier tinyproxy CONNECT-proxy) ────
95
+ #
96
+ # See src/sandbox/egress-firewall-config.ts for the architecture rationale.
97
+ # Two pairs: (coredns-strict + nginx-egress-strict) and
98
+ # (coredns-open + nginx-egress-open). Sandbox containers spawn with
99
+ # `--dns <coredns-ip>` and dial allowlisted hosts directly — coredns
100
+ # resolves the hostname to the nginx IP, nginx peeks SNI and tunnels.
101
+ #
102
+ # The sandbox sees no proxy at all. Works for any SDK regardless of
103
+ # whether it honours HTTP(S)_PROXY env vars.
104
+
105
+ # One-shot init that writes nginx-strict.conf / nginx-open.conf /
106
+ # Corefile.strict / Corefile.open into the agent-data volume before
107
+ # coredns + nginx try to read them. Without this, the firewall
108
+ # services boot first, fail to find the configs, and run with empty
109
+ # state (returning NXDOMAIN for everything) — even after the harness
110
+ # later writes the files, the running processes never re-read them.
111
+ # `condition: service_completed_successfully` on the firewalls below
112
+ # makes them wait for this to exit 0.
113
+ egress-init:
114
+ image: lastlight-agent
115
+ restart: "no"
116
+ # Mounts the same overlay + secrets the agent does and runs the SAME
117
+ # config loader, so the collector config it pre-writes is computed from
118
+ # the effective config (env AND instance/config.yaml) — identical to what
119
+ # the harness writes at boot. This is what keeps the running collector's
120
+ # forwarding gate from diverging from the harness when OTEL is enabled via
121
+ # YAML rather than env.
122
+ env_file:
123
+ - path: ./instance/secrets/.env
124
+ required: false
125
+ volumes:
126
+ - ./instance:/app/instance:ro
127
+ - agent-data:/app/data
128
+ command:
129
+ ["node", "-e",
130
+ "const c=require('/app/dist/config/config.js').loadConfig();const m=require('/app/dist/sandbox/egress-firewall-config.js');const d=c.stateDir;m.writeEgressFirewallConfigs(d);m.writeOtelCollectorConfig(d,{active:c.otel.enabled&&c.otel.forwardToSandbox})"]
131
+ depends_on:
132
+ - agent # ensures the image has been built when init runs
133
+
134
+ coredns-strict:
135
+ image: coredns/coredns:1.11.3
136
+ restart: unless-stopped
137
+ command: ["-conf", "/app/data/proxy/Corefile.strict"]
138
+ volumes:
139
+ - agent-data:/app/data:ro
140
+ depends_on:
141
+ egress-init:
142
+ condition: service_completed_successfully
143
+ networks:
144
+ sandbox-egress:
145
+ ipv4_address: 172.30.0.10
146
+
147
+ coredns-open:
148
+ image: coredns/coredns:1.11.3
149
+ restart: unless-stopped
150
+ command: ["-conf", "/app/data/proxy/Corefile.open"]
151
+ volumes:
152
+ - agent-data:/app/data:ro
153
+ depends_on:
154
+ egress-init:
155
+ condition: service_completed_successfully
156
+ networks:
157
+ sandbox-egress:
158
+ ipv4_address: 172.30.0.11
159
+
160
+ nginx-egress-strict:
161
+ image: nginx:alpine
162
+ restart: unless-stopped
163
+ command:
164
+ ["nginx", "-c", "/app/data/proxy/nginx-strict.conf", "-g", "daemon off;"]
165
+ volumes:
166
+ - agent-data:/app/data:ro
167
+ depends_on:
168
+ egress-init:
169
+ condition: service_completed_successfully
170
+ # Deliberately NOT on `internal`. Splitting ingress (sandbox-egress)
171
+ # and egress (proxy-egress) onto separate networks that don't include
172
+ # harness services keeps compose-internal hostnames unresolvable to
173
+ # the firewall — so an `unrestricted_egress` phase can't ask nginx to
174
+ # tunnel to `agent:8644` or similar.
175
+ networks:
176
+ sandbox-egress:
177
+ ipv4_address: 172.30.0.20
178
+ proxy-egress: {}
179
+
180
+ nginx-egress-open:
181
+ image: nginx:alpine
182
+ restart: unless-stopped
183
+ command:
184
+ ["nginx", "-c", "/app/data/proxy/nginx-open.conf", "-g", "daemon off;"]
185
+ volumes:
186
+ - agent-data:/app/data:ro
187
+ depends_on:
188
+ egress-init:
189
+ condition: service_completed_successfully
190
+ networks:
191
+ sandbox-egress:
192
+ ipv4_address: 172.30.0.21
193
+ proxy-egress: {}
194
+
195
+ # In-network OTEL collector. Sandboxes export telemetry here (by IP, on
196
+ # sandbox-egress) and it re-exports to the configured backend over
197
+ # proxy-egress. This is why the strict SNI firewall doesn't need to know
198
+ # about collector hosts or non-443 ports: the sandbox only ever dials this
199
+ # fixed internal endpoint, and the backend hop runs from a trusted,
200
+ # harness-controlled service that can use any port/scheme/headers. Backend
201
+ # auth headers live in the generated config (mode 0600 on the host volume)
202
+ # and are never forwarded into a sandbox.
203
+ #
204
+ # Dual-homed like the nginx firewalls — sandbox-egress (ingress) +
205
+ # proxy-egress (outbound). Deliberately NOT on `internal`, so it can't
206
+ # bridge a sandbox into harness services.
207
+ otel-collector:
208
+ image: otel/opentelemetry-collector:0.115.0
209
+ restart: unless-stopped
210
+ # Runs as the image's default non-root UID (10001). The harness `lastlight`
211
+ # user is pinned to that same UID (Dockerfile `useradd -u 10001`), so the
212
+ # collector reads the mode-0600 config the harness writes as its owner —
213
+ # no root, no world-readable secret. The image tag and that pinned UID must
214
+ # move together if a future image changes its user.
215
+ command: ["--config=/app/data/proxy/otel-collector.yaml"]
216
+ volumes:
217
+ - agent-data:/app/data:ro
218
+ depends_on:
219
+ egress-init:
220
+ condition: service_completed_successfully
221
+ networks:
222
+ sandbox-egress:
223
+ ipv4_address: 172.30.0.30
224
+ proxy-egress: {}
225
+
226
+ caddy:
227
+ image: caddy:2-alpine
228
+ restart: unless-stopped
229
+ ports:
230
+ - "80:80"
231
+ - "443:443"
232
+ volumes:
233
+ - ./apps/server/Caddyfile:/etc/caddy/Caddyfile:ro
234
+ - caddy-data:/data
235
+ - caddy-config:/config
236
+ # Caddyfile uses `{$DOMAIN:localhost}` (Caddy's own env substitution), so
237
+ # DOMAIN just needs to be in the container env. Read it from the overlay
238
+ # secrets file directly — no repo-root .env / ${DOMAIN} interpolation.
239
+ env_file:
240
+ - path: ./instance/secrets/.env
241
+ required: false
242
+ # Caddy's memory footprint is tiny (typically <50 MB even under load).
243
+ mem_limit: 256m
244
+ memswap_limit: 256m
245
+ networks:
246
+ - internal
247
+
248
+ volumes:
249
+ agent-data: # contains: lastlight.db, agent-sessions/, sandboxes/, secrets/, logs/, proxy/
250
+ # Shared package-manager download cache (npm/pnpm/yarn), mounted at /cache in
251
+ # every dynamically-created sandbox container by src/sandbox/docker.ts so
252
+ # repeated installs reuse already-fetched tarballs (issue #107). Declared
253
+ # here so the stack manages its lifecycle; the agent service does not mount
254
+ # it. Override the name with LASTLIGHT_PKG_CACHE_VOLUME (defaults to the
255
+ # compose-prefixed `lastlight_pkg-cache`).
256
+ pkg-cache:
257
+ caddy-data:
258
+ caddy-config:
259
+
260
+ networks:
261
+ internal:
262
+ # Sandbox containers (created dynamically by src/sandbox/docker.ts) attach
263
+ # to this network only with `--dns 172.30.0.10` (or .11 for open mode).
264
+ # `internal: true` disables direct host egress, so the only path to the
265
+ # public internet is through the nginx firewalls, which receive sandbox
266
+ # traffic on this network. Static subnet so the coredns + nginx IPs
267
+ # baked into the generated configs are stable.
268
+ sandbox-egress:
269
+ internal: true
270
+ ipam:
271
+ config:
272
+ - subnet: 172.30.0.0/24
273
+ # Egress-only network for the nginx firewalls. Regular bridge (has a
274
+ # default route to the host's network, so nginx can reach the public
275
+ # internet). Critically: NO other compose services attach here. That way
276
+ # docker's embedded DNS on this network resolves only public names — the
277
+ # harness service names (`agent`, `caddy`) are not reachable from the
278
+ # firewall's perspective, so an unrestricted sandbox can't ask nginx to
279
+ # bridge into the compose-internal services.
280
+ proxy-egress: