@wardby/cli 0.5.2 → 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 (411) hide show
  1. package/.env.example +33 -0
  2. package/README.md +25 -14
  3. package/dist/claude-coding-worker/context.d.ts +22 -0
  4. package/dist/claude-coding-worker/context.js +92 -0
  5. package/dist/claude-coding-worker/driver.d.ts +7 -1
  6. package/dist/claude-coding-worker/driver.js +38 -5
  7. package/dist/claude-coding-worker/sdk.js +13 -4
  8. package/dist/cli-help.d.ts +1 -1
  9. package/dist/cli-help.js +5 -2
  10. package/dist/cli-native-mode.d.ts +9 -0
  11. package/dist/cli-native-mode.js +20 -0
  12. package/dist/cli.d.ts +3 -1
  13. package/dist/cli.js +141 -5
  14. package/dist/coding/claude-context.d.ts +45 -0
  15. package/dist/coding/claude-context.js +434 -0
  16. package/dist/coding/local-git.js +9 -1
  17. package/dist/coding/profile.d.ts +12 -0
  18. package/dist/coding/profile.js +6 -0
  19. package/dist/coding/protocol.d.ts +104 -0
  20. package/dist/coding/protocol.js +87 -3
  21. package/dist/coding/registry/pypi.d.ts +25 -1
  22. package/dist/coding/registry/pypi.js +140 -16
  23. package/dist/coding/registry/types.d.ts +17 -3
  24. package/dist/coding-worker/artifact.d.ts +8 -0
  25. package/dist/coding-worker/artifact.js +2 -2
  26. package/dist/coding-worker/driver.js +2 -0
  27. package/dist/coding-worker/sdk.d.ts +6 -0
  28. package/dist/coding-worker/sdk.js +1 -0
  29. package/dist/coding-worker/skills.d.ts +23 -0
  30. package/dist/coding-worker/skills.js +117 -0
  31. package/dist/coding-worker/types.d.ts +2 -0
  32. package/dist/config/github-allowed-accounts.d.ts +15 -0
  33. package/dist/config/github-allowed-accounts.js +36 -0
  34. package/dist/config/low-power.d.ts +12 -0
  35. package/dist/config/low-power.js +18 -0
  36. package/dist/config/mobile.d.ts +12 -0
  37. package/dist/config/mobile.js +18 -0
  38. package/dist/config/providers.d.ts +56 -2
  39. package/dist/config/providers.js +92 -6
  40. package/dist/core/db.d.ts +16 -6
  41. package/dist/core/db.js +12 -10
  42. package/dist/core/dispatch.d.ts +11 -0
  43. package/dist/core/dispatch.js +36 -1
  44. package/dist/core/engine-native.js +9 -5
  45. package/dist/core/host-events.d.ts +49 -3
  46. package/dist/core/host-events.js +289 -15
  47. package/dist/core/http-runtime.js +13 -6
  48. package/dist/core/issue-bridge.js +42 -2
  49. package/dist/core/issue-events.js +12 -1
  50. package/dist/core/issue-status.js +14 -3
  51. package/dist/core/merge-order-check.d.ts +129 -0
  52. package/dist/core/merge-order-check.js +336 -0
  53. package/dist/core/notification-dispatcher.d.ts +70 -0
  54. package/dist/core/notification-dispatcher.js +368 -0
  55. package/dist/core/notification-templates.d.ts +25 -0
  56. package/dist/core/notification-templates.js +105 -0
  57. package/dist/core/notifications.d.ts +10 -0
  58. package/dist/core/notifications.js +38 -0
  59. package/dist/core/pg-auth.d.ts +22 -0
  60. package/dist/core/pg-auth.js +152 -0
  61. package/dist/core/power-composition.d.ts +16 -0
  62. package/dist/core/power-composition.js +37 -0
  63. package/dist/core/power-idle.d.ts +14 -0
  64. package/dist/core/power-idle.js +30 -0
  65. package/dist/core/power.d.ts +71 -0
  66. package/dist/core/power.js +202 -0
  67. package/dist/core/reconciler.d.ts +4 -2
  68. package/dist/core/reconciler.js +29 -5
  69. package/dist/core/related-pull-requests.d.ts +48 -4
  70. package/dist/core/related-pull-requests.js +113 -11
  71. package/dist/core/repo-access.d.ts +15 -0
  72. package/dist/core/repo-access.js +66 -0
  73. package/dist/core/review-fix.d.ts +37 -0
  74. package/dist/core/review-fix.js +207 -6
  75. package/dist/core/review-host-tools.d.ts +20 -0
  76. package/dist/core/review-host-tools.js +58 -2
  77. package/dist/core/runner.d.ts +336 -3
  78. package/dist/core/runner.js +894 -317
  79. package/dist/core/secret-broker-config.d.ts +103 -0
  80. package/dist/core/secret-broker-config.js +112 -0
  81. package/dist/core/secrets.d.ts +39 -4
  82. package/dist/core/secrets.js +148 -40
  83. package/dist/core/workflow-event-recorder.d.ts +14 -0
  84. package/dist/core/workflow-event-recorder.js +120 -0
  85. package/dist/core/workflow-events.d.ts +82 -0
  86. package/dist/core/workflow-events.js +44 -0
  87. package/dist/core/workflow-run-events.d.ts +16 -0
  88. package/dist/core/workflow-run-events.js +40 -0
  89. package/dist/generated/prisma/browser.d.ts +58 -0
  90. package/dist/generated/prisma/client.d.ts +58 -0
  91. package/dist/generated/prisma/commonInputTypes.d.ts +150 -0
  92. package/dist/generated/prisma/enums.d.ts +27 -0
  93. package/dist/generated/prisma/enums.js +23 -0
  94. package/dist/generated/prisma/internal/class.d.ts +88 -0
  95. package/dist/generated/prisma/internal/class.js +4 -4
  96. package/dist/generated/prisma/internal/prismaNamespace.d.ts +772 -1
  97. package/dist/generated/prisma/internal/prismaNamespace.js +135 -4
  98. package/dist/generated/prisma/internal/prismaNamespaceBrowser.d.ts +139 -0
  99. package/dist/generated/prisma/internal/prismaNamespaceBrowser.js +135 -4
  100. package/dist/generated/prisma/models/Agent.d.ts +360 -1
  101. package/dist/generated/prisma/models/CodingAgentProfile.d.ts +73 -1
  102. package/dist/generated/prisma/models/CodingRun.d.ts +205 -1
  103. package/dist/generated/prisma/models/DeferredReview.d.ts +78 -1
  104. package/dist/generated/prisma/models/NativeGatewayCall.d.ts +1675 -0
  105. package/dist/generated/prisma/models/NativeGatewayCall.js +1 -0
  106. package/dist/generated/prisma/models/NativeGatewaySession.d.ts +1517 -0
  107. package/dist/generated/prisma/models/NativeGatewaySession.js +1 -0
  108. package/dist/generated/prisma/models/NativeWarmWorker.d.ts +1296 -0
  109. package/dist/generated/prisma/models/NativeWarmWorker.js +1 -0
  110. package/dist/generated/prisma/models/NotificationChannel.d.ts +1543 -0
  111. package/dist/generated/prisma/models/NotificationChannel.js +1 -0
  112. package/dist/generated/prisma/models/NotificationDelivery.d.ts +1502 -0
  113. package/dist/generated/prisma/models/NotificationDelivery.js +1 -0
  114. package/dist/generated/prisma/models/NotificationThread.d.ts +1090 -0
  115. package/dist/generated/prisma/models/NotificationThread.js +1 -0
  116. package/dist/generated/prisma/models/Run.d.ts +826 -1
  117. package/dist/generated/prisma/models/RunHostCheck.d.ts +36 -1
  118. package/dist/generated/prisma/models/Secret.d.ts +37 -1
  119. package/dist/generated/prisma/models/SecretBrokerChange.d.ts +1101 -0
  120. package/dist/generated/prisma/models/SecretBrokerChange.js +1 -0
  121. package/dist/generated/prisma/models/WorkflowEvent.d.ts +1422 -0
  122. package/dist/generated/prisma/models/WorkflowEvent.js +1 -0
  123. package/dist/generated/prisma/models.d.ts +8 -0
  124. package/dist/help/build.js +4 -2
  125. package/dist/help/catalog.d.ts +1 -1
  126. package/dist/help/catalog.js +31 -6
  127. package/dist/help-index.json +1492 -113
  128. package/dist/import/create.js +17 -0
  129. package/dist/import/neutral-schema.d.ts +6 -2
  130. package/dist/import/neutral-schema.js +2 -0
  131. package/dist/mcp/auth/access.d.ts +1 -0
  132. package/dist/mcp/auth/ownership.d.ts +1 -1
  133. package/dist/mcp/auth/repo-authorization.js +14 -0
  134. package/dist/mcp/auth/resource-server.d.ts +2 -1
  135. package/dist/mcp/auth/resource-server.js +7 -2
  136. package/dist/mcp/auth/self-hosted/browser.d.ts +1 -1
  137. package/dist/mcp/auth/self-hosted/browser.js +19 -6
  138. package/dist/mcp/context.d.ts +6 -0
  139. package/dist/mcp/host-events/github-ingress.d.ts +23 -1
  140. package/dist/mcp/host-events/github-ingress.js +68 -0
  141. package/dist/mcp/index.d.ts +13 -0
  142. package/dist/mcp/index.js +59 -10
  143. package/dist/mcp/tools/agents.js +83 -12
  144. package/dist/mcp/tools/notification-channels.d.ts +2 -0
  145. package/dist/mcp/tools/notification-channels.js +293 -0
  146. package/dist/mcp/tools/power.d.ts +2 -0
  147. package/dist/mcp/tools/power.js +77 -0
  148. package/dist/mcp/tools/runs.d.ts +0 -6
  149. package/dist/mcp/tools/runs.js +7 -2
  150. package/dist/mcp/tools/secret-broker-compat.d.ts +12 -0
  151. package/dist/mcp/tools/secret-broker-compat.js +23 -0
  152. package/dist/mcp/tools/secret-elicitation-form.d.ts +22 -2
  153. package/dist/mcp/tools/secret-elicitation-form.js +200 -10
  154. package/dist/mcp/tools/secret-elicitation-server.js +8 -1
  155. package/dist/mcp/tools/secret-elicitation.d.ts +38 -3
  156. package/dist/mcp/tools/secret-elicitation.js +110 -12
  157. package/dist/mcp/tools/secrets.js +184 -7
  158. package/dist/mcp/tools/tools.d.ts +1 -1
  159. package/dist/mcp/tools/tools.js +22 -2
  160. package/dist/native-worker/composition.d.ts +23 -0
  161. package/dist/native-worker/composition.js +77 -0
  162. package/dist/native-worker/docker-isolation.d.ts +65 -0
  163. package/dist/native-worker/docker-isolation.js +183 -0
  164. package/dist/native-worker/docker-launcher.d.ts +74 -0
  165. package/dist/native-worker/docker-launcher.js +237 -0
  166. package/dist/native-worker/gateway-server.d.ts +39 -0
  167. package/dist/native-worker/gateway-server.js +315 -0
  168. package/dist/native-worker/gateway.d.ts +44 -0
  169. package/dist/native-worker/gateway.js +197 -0
  170. package/dist/native-worker/http-server.d.ts +22 -0
  171. package/dist/native-worker/http-server.js +109 -0
  172. package/dist/native-worker/http-transport.d.ts +17 -0
  173. package/dist/native-worker/http-transport.js +88 -0
  174. package/dist/native-worker/kubernetes-isolation.d.ts +90 -0
  175. package/dist/native-worker/kubernetes-isolation.js +218 -0
  176. package/dist/native-worker/kubernetes-launcher.d.ts +102 -0
  177. package/dist/native-worker/kubernetes-launcher.js +335 -0
  178. package/dist/native-worker/launch.d.ts +45 -0
  179. package/dist/native-worker/launch.js +44 -0
  180. package/dist/native-worker/ledger.d.ts +109 -0
  181. package/dist/native-worker/ledger.js +192 -0
  182. package/dist/native-worker/loopback.d.ts +12 -0
  183. package/dist/native-worker/loopback.js +49 -0
  184. package/dist/native-worker/main.d.ts +7 -0
  185. package/dist/native-worker/main.js +74 -0
  186. package/dist/native-worker/protocol.d.ts +744 -0
  187. package/dist/native-worker/protocol.js +200 -0
  188. package/dist/native-worker/sandbox-executor.d.ts +68 -0
  189. package/dist/native-worker/sandbox-executor.js +210 -0
  190. package/dist/native-worker/stdio.d.ts +29 -0
  191. package/dist/native-worker/stdio.js +188 -0
  192. package/dist/native-worker/warm-delivery.d.ts +16 -0
  193. package/dist/native-worker/warm-delivery.js +33 -0
  194. package/dist/native-worker/warm-pool-ledger.d.ts +39 -0
  195. package/dist/native-worker/warm-pool-ledger.js +73 -0
  196. package/dist/native-worker/warm-pool.d.ts +107 -0
  197. package/dist/native-worker/warm-pool.js +283 -0
  198. package/dist/native-worker/worker.d.ts +17 -0
  199. package/dist/native-worker/worker.js +115 -0
  200. package/dist/providers/auth/authorization-server.d.ts +3 -0
  201. package/dist/providers/auth/index.js +2 -0
  202. package/dist/providers/auth/self-hosted.d.ts +13 -1
  203. package/dist/providers/auth/self-hosted.js +54 -4
  204. package/dist/providers/chat/fake.d.ts +46 -0
  205. package/dist/providers/chat/fake.js +39 -0
  206. package/dist/providers/chat/index.d.ts +4 -0
  207. package/dist/providers/chat/index.js +8 -0
  208. package/dist/providers/chat/slack.d.ts +37 -0
  209. package/dist/providers/chat/slack.js +105 -0
  210. package/dist/providers/chat/types.d.ts +42 -0
  211. package/dist/providers/chat/types.js +19 -0
  212. package/dist/providers/coding-proxy/mock-upstream.d.ts +33 -0
  213. package/dist/providers/coding-proxy/mock-upstream.js +116 -0
  214. package/dist/providers/coding-proxy/registry/prisma-store.d.ts +3 -0
  215. package/dist/providers/coding-proxy/registry/prisma-store.js +17 -0
  216. package/dist/providers/coding-proxy/registry/service.d.ts +4 -0
  217. package/dist/providers/coding-proxy/registry/service.js +20 -3
  218. package/dist/providers/coding-proxy/registry/store.d.ts +18 -1
  219. package/dist/providers/coding-proxy/registry/store.js +33 -0
  220. package/dist/providers/coding-proxy/runtime.js +12 -1
  221. package/dist/providers/coding-proxy/types.d.ts +2 -0
  222. package/dist/providers/engine/types.d.ts +19 -0
  223. package/dist/providers/engine/types.js +22 -0
  224. package/dist/providers/executor/composition.d.ts +24 -1
  225. package/dist/providers/executor/composition.js +39 -6
  226. package/dist/providers/executor/container.d.ts +24 -1
  227. package/dist/providers/executor/container.js +101 -11
  228. package/dist/providers/executor/dbos.d.ts +42 -0
  229. package/dist/providers/executor/dbos.js +118 -12
  230. package/dist/providers/executor/deferred.d.ts +56 -0
  231. package/dist/providers/executor/deferred.js +119 -0
  232. package/dist/providers/executor/routing.d.ts +37 -10
  233. package/dist/providers/executor/routing.js +73 -32
  234. package/dist/providers/executor/types.d.ts +12 -0
  235. package/dist/providers/jobs/docker.js +3 -3
  236. package/dist/providers/jobs/fake-kubernetes-api.d.ts +21 -2
  237. package/dist/providers/jobs/fake-kubernetes-api.js +42 -1
  238. package/dist/providers/jobs/kubernetes-api.d.ts +17 -1
  239. package/dist/providers/jobs/kubernetes-api.js +7 -0
  240. package/dist/providers/jobs/kubernetes-client.d.ts +10 -1
  241. package/dist/providers/jobs/kubernetes-client.js +52 -3
  242. package/dist/providers/jobs/kubernetes-dry-run-fixture.d.ts +6 -1
  243. package/dist/providers/jobs/kubernetes-dry-run-fixture.js +6 -3
  244. package/dist/providers/jobs/kubernetes-isolation.d.ts +16 -1
  245. package/dist/providers/jobs/kubernetes-isolation.js +58 -5
  246. package/dist/providers/jobs/kubernetes-platform.d.ts +4 -1
  247. package/dist/providers/jobs/kubernetes-platform.js +38 -1
  248. package/dist/providers/jobs/kubernetes-preflight.d.ts +2 -1
  249. package/dist/providers/jobs/kubernetes-preflight.js +4 -2
  250. package/dist/providers/jobs/kubernetes.d.ts +56 -7
  251. package/dist/providers/jobs/kubernetes.js +117 -36
  252. package/dist/providers/jobs/metadata-probes.d.ts +11 -0
  253. package/dist/providers/jobs/metadata-probes.js +13 -0
  254. package/dist/providers/jobs/types.d.ts +9 -0
  255. package/dist/providers/llm/openai.js +0 -1
  256. package/dist/providers/review-host/github.d.ts +11 -1
  257. package/dist/providers/review-host/github.js +50 -0
  258. package/dist/providers/review-host/types.d.ts +23 -0
  259. package/dist/providers/vcs/github.d.ts +32 -6
  260. package/dist/providers/vcs/github.js +74 -16
  261. package/dist/quickstart/coding-db.js +14 -2
  262. package/dist/quickstart/coding-doctor.d.ts +3 -0
  263. package/dist/quickstart/coding-doctor.js +3 -0
  264. package/dist/quickstart/coding-images.d.ts +9 -0
  265. package/dist/quickstart/coding-images.js +39 -0
  266. package/dist/quickstart/coding-seed.d.ts +20 -1
  267. package/dist/quickstart/coding-seed.js +96 -7
  268. package/dist/quickstart/coding.d.ts +2 -0
  269. package/dist/quickstart/coding.js +75 -3
  270. package/dist/quickstart/config.d.ts +2 -0
  271. package/dist/quickstart/config.js +4 -0
  272. package/dist/quickstart/images.d.ts +13 -0
  273. package/dist/quickstart/images.js +80 -12
  274. package/dist/quickstart/index.d.ts +0 -2
  275. package/dist/quickstart/index.js +10 -14
  276. package/dist/quickstart/manifests.d.ts +56 -0
  277. package/dist/quickstart/manifests.js +523 -0
  278. package/dist/quickstart/python-detect.d.ts +10 -0
  279. package/dist/quickstart/python-detect.js +32 -0
  280. package/dist/quickstart/repo-packages.d.ts +10 -0
  281. package/dist/quickstart/repo-packages.js +132 -0
  282. package/dist/quickstart/reviewer-prompt.d.ts +12 -0
  283. package/dist/quickstart/reviewer-prompt.js +84 -0
  284. package/dist/quickstart/scenarios.d.ts +19 -0
  285. package/dist/quickstart/scenarios.js +28 -0
  286. package/dist/quickstart/sync-reviewer-prompt.d.ts +1 -0
  287. package/dist/quickstart/sync-reviewer-prompt.js +10 -0
  288. package/dist/quickstart-images.json +1 -1
  289. package/dist/sandbox/brokered-fetch.d.ts +23 -0
  290. package/dist/sandbox/brokered-fetch.js +37 -0
  291. package/dist/sandbox/host-functions.d.ts +34 -0
  292. package/dist/sandbox/host-functions.js +144 -80
  293. package/dist/sandbox/prelude.js +7 -1
  294. package/dist/sandbox/run-in-sandbox.d.ts +19 -0
  295. package/dist/sandbox/run-in-sandbox.js +28 -10
  296. package/dist/sandbox/safe-fetch.d.ts +2 -0
  297. package/dist/sandbox/safe-fetch.js +3 -1
  298. package/dist/sandbox/secret-broker-sigv4.d.ts +2 -0
  299. package/dist/sandbox/secret-broker-sigv4.js +49 -0
  300. package/dist/sandbox/secret-broker.d.ts +34 -0
  301. package/dist/sandbox/secret-broker.js +162 -0
  302. package/dist/sandbox/user-tool.d.ts +14 -0
  303. package/dist/sandbox/user-tool.js +32 -0
  304. package/dist/serve.js +18 -0
  305. package/dist/viewer/api-schema.d.ts +214 -18
  306. package/dist/viewer/api-schema.js +22 -0
  307. package/dist/viewer/build-schemas.js +4 -1
  308. package/dist/viewer/event-bus.d.ts +6 -0
  309. package/dist/viewer/event-bus.js +16 -7
  310. package/dist/viewer/graph.d.ts +5 -2
  311. package/dist/viewer/graph.js +7 -2
  312. package/dist/viewer/http.d.ts +0 -1
  313. package/dist/viewer/http.js +2 -2
  314. package/dist/viewer/infra.js +25 -2
  315. package/dist/viewer/limits.d.ts +4 -0
  316. package/dist/viewer/limits.js +4 -0
  317. package/dist/viewer/openapi.d.ts +15 -0
  318. package/dist/viewer/openapi.js +172 -0
  319. package/docs/README.md +7 -0
  320. package/docs/agent-recipes.md +57 -8
  321. package/docs/architecture-runtime.md +16 -1
  322. package/docs/code-review-agents.md +139 -5
  323. package/docs/coding-agent-setup.md +127 -2
  324. package/docs/coding-packages.md +105 -5
  325. package/docs/coding-services.md +3 -1
  326. package/docs/coding-worker-byo-images.md +239 -2
  327. package/docs/coding-worker-isolation.md +88 -23
  328. package/docs/getting-started-gke.md +225 -9
  329. package/docs/getting-started-identity-provider.md +21 -10
  330. package/docs/getting-started.md +140 -11
  331. package/docs/jira-agents.md +5 -1
  332. package/docs/knowledge.md +11 -0
  333. package/docs/native-sandbox.md +635 -0
  334. package/docs/release-verification.md +9 -0
  335. package/docs/security-deployment.md +113 -12
  336. package/docs/slack-notifications.md +252 -0
  337. package/docs/tool-secrets.md +252 -0
  338. package/docs/viewer-api.md +46 -5
  339. package/docs/viewer-api.openapi.yml +1404 -0
  340. package/help/admin-viewer.md +6 -2
  341. package/help/agent-recipes.md +27 -0
  342. package/help/architecture-agent.md +136 -0
  343. package/help/brokered-secrets.md +79 -0
  344. package/help/build-claude-code-image.md +131 -0
  345. package/help/build-worker-image.md +195 -0
  346. package/help/code-review-agents.md +68 -6
  347. package/help/coding-packages.md +31 -2
  348. package/help/creating-agents.md +14 -0
  349. package/help/deploy-gke.md +37 -6
  350. package/help/deployment-targets.md +24 -13
  351. package/help/errors/coding-provider-not-configured.md +2 -2
  352. package/help/errors/database-auth-invalid.md +28 -0
  353. package/help/errors/github-account-not-allowed.md +25 -0
  354. package/help/errors/low-power-disabled.md +29 -0
  355. package/help/errors/low-power-scale-forbidden.md +35 -0
  356. package/help/errors/low-power-wake-timeout.md +30 -0
  357. package/help/errors/mobile-disabled.md +31 -0
  358. package/help/errors/native-sandbox-capacity.md +22 -0
  359. package/help/errors/native-sandbox-deadline-exceeded.md +19 -0
  360. package/help/errors/native-sandbox-docker-failed.md +20 -0
  361. package/help/errors/native-sandbox-gateway-unavailable.md +21 -0
  362. package/help/errors/native-sandbox-image-not-pinned.md +19 -0
  363. package/help/errors/native-sandbox-isolation-mismatch.md +20 -0
  364. package/help/errors/native-sandbox-network-unenforced.md +22 -0
  365. package/help/errors/native-sandbox-requires-catalog.md +31 -0
  366. package/help/errors/native-sandbox-unavailable.md +19 -0
  367. package/help/errors/native-sandbox-warm-delivery-failed.md +21 -0
  368. package/help/errors/native-sandbox-worker-exited.md +20 -0
  369. package/help/errors/native-sandbox-worker-lost.md +20 -0
  370. package/help/errors/native-sandbox-worker-unready.md +22 -0
  371. package/help/errors/secret-broker-body-invalid.md +26 -0
  372. package/help/errors/secret-broker-changed.md +20 -0
  373. package/help/errors/secret-broker-config-invalid.md +30 -0
  374. package/help/errors/secret-broker-conflict.md +27 -0
  375. package/help/errors/secret-broker-destination-denied.md +28 -0
  376. package/help/errors/secret-broker-value-invalid.md +28 -0
  377. package/help/errors/secret-brokered.md +24 -0
  378. package/help/errors/secret-not-brokered.md +25 -0
  379. package/help/errors/slack-auth-failed.md +48 -0
  380. package/help/errors/slack-channel-unreachable.md +39 -0
  381. package/help/errors/slack-not-configured.md +33 -0
  382. package/help/getting-started.md +18 -0
  383. package/help/github.md +18 -1
  384. package/help/identity-and-access.md +5 -1
  385. package/help/local-repositories.md +35 -5
  386. package/help/low-power-mode.md +125 -0
  387. package/help/merge-order-check.md +117 -0
  388. package/help/mobile-app.md +54 -0
  389. package/help/native-sandbox.md +136 -0
  390. package/help/observability.md +8 -0
  391. package/help/related-pull-requests.md +70 -9
  392. package/help/repo-instructions-and-skills.md +91 -0
  393. package/help/review-fix-rounds.md +10 -0
  394. package/help/slack-notifications.md +62 -0
  395. package/help/troubleshooting/coding-workers.md +21 -0
  396. package/package.json +13 -5
  397. package/prisma/migrations/20261009000003_native_execution_mode/migration.sql +12 -0
  398. package/prisma/migrations/20261009000004_native_gateway_ledger/migration.sql +65 -0
  399. package/prisma/migrations/20261009000005_native_gateway_call_child_agent/migration.sql +5 -0
  400. package/prisma/migrations/20261009000006_run_deferred_start_stop/migration.sql +14 -0
  401. package/prisma/migrations/20261009000007_native_gateway_network_ready/migration.sql +5 -0
  402. package/prisma/migrations/20261010000001_workflow_notifications/migration.sql +99 -0
  403. package/prisma/migrations/20261011000001_native_gateway_session_status_index/migration.sql +2 -0
  404. package/prisma/migrations/20261012000001_native_warm_worker/migration.sql +32 -0
  405. package/prisma/migrations/20261013000001_coding_run_merge_order/migration.sql +2 -0
  406. package/prisma/migrations/20261013000001_secret_broker/migration.sql +17 -0
  407. package/prisma/migrations/20261013000002_deferred_review_request/migration.sql +4 -0
  408. package/prisma/migrations/20261014000000_repo_skills/migration.sql +15 -0
  409. package/prisma/migrations/20261015000001_coding_run_merge_order_index/migration.sql +2 -0
  410. package/prisma/migrations/20261015000002_no_change_rereview/migration.sql +2 -0
  411. package/prisma/schema.prisma +362 -91
@@ -39,25 +39,26 @@ model Agent {
39
39
  lastScheduledAt DateTime?
40
40
 
41
41
  // Phase 3: tools + multi-turn loop.
42
- tools AgentTool[]
43
- maxTurns Int @default(10)
42
+ tools AgentTool[]
43
+ maxTurns Int @default(10)
44
44
  /// Sub-agent delegations one run may make (delegate_to_*), each to a different sub-agent. 1 = route to exactly one.
45
- maxDelegationsPerRun Int @default(1)
45
+ maxDelegationsPerRun Int @default(1)
46
46
  /// Native leads: the delegate_to_* calls of one model turn run at the same time. False = one after another.
47
- parallelDelegations Boolean @default(false)
47
+ parallelDelegations Boolean @default(false)
48
48
 
49
49
  // Phase 4: ownership. Null = owner-less, a transition state only: access
50
50
  // then comes from ResourceGrant rows alone (the migration gives everyone
51
51
  // execute), and `wardby grants adopt-public` assigns an owner. See
52
52
  // ResourceGrant.
53
- ownerId String?
54
- owner Principal? @relation(fields: [ownerId], references: [id])
55
- secrets AgentSecret[]
56
- datastores AgentDatastore[]
57
- webhooks Webhook[]
58
- repositories AgentRepository[]
59
- deferredReviews DeferredReview[]
60
- issueProjects AgentIssueProject[]
53
+ ownerId String?
54
+ owner Principal? @relation(fields: [ownerId], references: [id])
55
+ secrets AgentSecret[]
56
+ datastores AgentDatastore[]
57
+ webhooks Webhook[]
58
+ repositories AgentRepository[]
59
+ deferredReviews DeferredReview[]
60
+ issueProjects AgentIssueProject[]
61
+ notificationChannels NotificationChannel[]
61
62
 
62
63
  /// Self-defects opt-in: the Jira project and issue type wardby files the agent's own failures into. Both or neither.
63
64
  defectProjectKey String?
@@ -78,6 +79,12 @@ model Agent {
78
79
  /// Null = the provider's default.
79
80
  effort String?
80
81
 
82
+ /// Native agents only: where their runs execute. control-plane (default) =
83
+ /// in this server process (in-process or DBOS); sandbox = an isolated,
84
+ /// single-use worker container/pod. Each Run snapshots this at creation
85
+ /// (Run.nativeExecutionMode), so a change reaches only later runs.
86
+ nativeExecutionMode NativeExecutionMode @default(control_plane)
87
+
81
88
  /// Un-phased: sub-agent composition edges (see AgentSubAgent below). An
82
89
  /// agent can be a parent (has children it can delegate to) and/or a
83
90
  /// child (is delegated to by others) independently.
@@ -134,6 +141,12 @@ enum AgentKind {
134
141
  coding
135
142
  }
136
143
 
144
+ /// Where a native agent's runs execute (Agent.nativeExecutionMode).
145
+ enum NativeExecutionMode {
146
+ control_plane @map("control-plane")
147
+ sandbox
148
+ }
149
+
137
150
  enum RunStatus {
138
151
  pending
139
152
  running
@@ -312,51 +325,67 @@ enum RunTrigger {
312
325
  }
313
326
 
314
327
  model Run {
315
- id String @id @default(cuid())
316
- agent Agent @relation(fields: [agentId], references: [id])
317
- agentId String
318
- status RunStatus @default(pending)
319
- trigger RunTrigger @default(manual)
320
- tokensIn Int @default(0)
321
- tokensOut Int @default(0)
322
- costUsd Decimal @default(0) @db.Decimal(10, 6)
323
- error String?
324
- startedAt DateTime @default(now())
325
- finishedAt DateTime?
328
+ id String @id @default(cuid())
329
+ agent Agent @relation(fields: [agentId], references: [id])
330
+ agentId String
331
+ status RunStatus @default(pending)
332
+ trigger RunTrigger @default(manual)
333
+ tokensIn Int @default(0)
334
+ tokensOut Int @default(0)
335
+ costUsd Decimal @default(0) @db.Decimal(10, 6)
336
+ error String?
337
+ startedAt DateTime @default(now())
338
+ finishedAt DateTime?
326
339
  /// Phase 2: beaten by the executor while running; a stale value past
327
340
  /// HEARTBEAT_TIMEOUT is how the reconciler finds an orphaned run.
328
- heartbeatAt DateTime?
341
+ heartbeatAt DateTime?
329
342
  /// Phase 4: EngineResult.finalText, persisted so a Task (MCP) or later
330
343
  /// inspection can read a completed run's answer. Previously only ever
331
344
  /// streamed live via onText and dropped — no durable place to read it
332
345
  /// from until this field existed.
333
- finalText String?
346
+ finalText String?
334
347
  /// Phase 4: EngineResult.turns, persisted for the same reason as
335
348
  /// finalText — MCP's list_runs/get_run need it and it was previously
336
349
  /// dropped after the engine returned.
337
- turns Int @default(0)
350
+ turns Int @default(0)
338
351
  /// The run's model catalog entry, recorded when it started (native: the
339
352
  /// runner's load step; coding: dispatch). The run is billed at these rates
340
353
  /// for its whole life, resumes included. Null on runs from before the
341
354
  /// model catalog.
342
- pricingVersion String?
343
- pricingSnapshot Json?
355
+ pricingVersion String?
356
+ pricingSnapshot Json?
344
357
  /// Detached executors are recovered by handle rather than inferred from trigger.
345
- executionManaged Boolean @default(false)
358
+ executionManaged Boolean @default(false)
346
359
  /// Phase 6: which durable executor backend holds this run, if any
347
360
  /// ("dbos" = a DBOS workflow whose id equals this run's id). Null for
348
361
  /// in-process runs. The reconciler consults the backend before declaring a
349
362
  /// stale run lost, and can adopt one orphaned by a dead instance.
350
- executionBackend String?
351
- codingRun CodingRun?
352
- hostCheck RunHostCheck?
353
- hostStatus RunHostStatus?
354
- issueStatus RunIssueStatus?
355
- attribution RunAttribution?
356
- modelUsage RunModelUsage[]
357
- serviceStatuses CodingRunServiceStatus[]
363
+ executionBackend String?
364
+ /// The agent's nativeExecutionMode when this run was created, fixed for the
365
+ /// run's life and what the executor routes on. Null for coding runs and for
366
+ /// native runs from before the field existed, which run in the control plane.
367
+ nativeExecutionMode NativeExecutionMode?
368
+ codingRun CodingRun?
369
+ hostCheck RunHostCheck?
370
+ hostStatus RunHostStatus?
371
+ issueStatus RunIssueStatus?
372
+ attribution RunAttribution?
373
+ modelUsage RunModelUsage[]
374
+ serviceStatuses CodingRunServiceStatus[]
358
375
  /// A manual review of a local branch: this run is the review run dispatched for it.
359
- localPullRequest LocalPullRequest?
376
+ localPullRequest LocalPullRequest?
377
+ /// A sandbox-mode native run's gateway session (native sandbox phase 3).
378
+ nativeGatewaySession NativeGatewaySession?
379
+ /// The warm pool worker this sandbox-mode run claimed (native sandbox phase 6).
380
+ nativeWarmWorker NativeWarmWorker?
381
+ /// Set when a process that may not start runs itself (the native sandbox
382
+ /// gateway, which holds no executor) dispatched this run: the scheduler
383
+ /// leader starts it through the server's executor and clears this.
384
+ startDeferredAt DateTime?
385
+ /// Likewise a stop that process asked for: the scheduler leader stops the
386
+ /// run through the server's executor and clears this.
387
+ stopRequestedAt DateTime?
388
+ stopRequestReason String?
360
389
 
361
390
  /// Un-phased: sub-agent dispatch (see AgentSubAgent). Null for a
362
391
  /// top-level run; set when this run was created by a parent run's
@@ -392,32 +421,34 @@ model Run {
392
421
  @@index([startedAt])
393
422
  @@index([status])
394
423
  @@index([parentRunId])
424
+ @@index([startDeferredAt])
425
+ @@index([stopRequestedAt])
395
426
  }
396
427
 
397
428
  /// Phase 5: owner-configured coding behavior. Runtime credentials and opaque
398
429
  /// launcher handles never live on the reusable profile.
399
430
  model CodingAgentProfile {
400
- agentId String @id
401
- agent Agent @relation(fields: [agentId], references: [id], onDelete: Cascade)
402
- provider String @default("codex")
431
+ agentId String @id
432
+ agent Agent @relation(fields: [agentId], references: [id], onDelete: Cascade)
433
+ provider String @default("codex")
403
434
  repository String
404
- baseRef String @default("main")
435
+ baseRef String @default("main")
405
436
  defaultTask String?
406
- allowWebhookTaskOverride Boolean @default(false)
407
- timeoutSec Int @default(1800)
437
+ allowWebhookTaskOverride Boolean @default(false)
438
+ timeoutSec Int @default(1800)
408
439
  /// Claude Code runs only: the most agent turns a run may take. Null = the worker default (200).
409
440
  maxTurns Int?
410
441
  /// Unused; dropped after rollout (see the package-registry plan, Task 14).
411
- allowedEgress Json @default("[]")
442
+ allowedEgress Json @default("[]")
412
443
  protectedPaths Json
413
- collectExclude Json @default("[]")
414
- toolchain String @default("node")
444
+ collectExclude Json @default("[]")
445
+ toolchain String @default("node")
415
446
  toolchainVersion String?
416
447
  workerImageRef String?
417
448
  /// Per-agent workspace size in MiB; null = CODING_DISK_MB.
418
449
  workspaceDiskMb Int?
419
- packageAllowlist Json @default("{}")
420
- packagePolicy Json @default("{}")
450
+ packageAllowlist Json @default("{}")
451
+ packagePolicy Json @default("{}")
421
452
  /// Admin-requested debug trace: while now < debugTraceUntil, every coding
422
453
  /// run of this agent is dispatched with CodingRun.debugTrace set. Null = off.
423
454
  debugTraceUntil DateTime?
@@ -425,6 +456,12 @@ model CodingAgentProfile {
425
456
  /// (CodingService.name) this agent's runs may start, any version the catalog
426
457
  /// has. Empty = none. Owner-set through update_agent.
427
458
  services Json @default("[]")
459
+ /// Load the repository's agent skills into coding runs (Codex: .agents/skills, .codex/skills;
460
+ /// Claude Code: .claude/skills). Repo instructions (AGENTS.md / CLAUDE.md) load regardless.
461
+ repoSkills Boolean @default(true)
462
+ /// Claude Code runs only: keep Claude Code's bare mode (CLAUDE_CODE_SIMPLE=1); wardby injects
463
+ /// repo instructions and the skill list into the system prompt. False = Claude Code's native loading.
464
+ claudeBareMode Boolean @default(true)
428
465
 
429
466
  /// How `repository` was authorized for this agent (see AgentRepository.authorizedVia):
430
467
  /// "host_permission", "admin", or "grandfathered". Null = never authorized; runs are refused.
@@ -475,6 +512,10 @@ model CodingRun {
475
512
  debugTrace Boolean @default(false)
476
513
  /// Fixed at dispatch from the profile's maxTurns: the Claude Code worker's turn limit. Null = the worker default.
477
514
  maxTurns Int?
515
+ /// Fixed at dispatch from the profile's repoSkills.
516
+ repoSkills Boolean @default(true)
517
+ /// Fixed at dispatch from the profile's claudeBareMode.
518
+ claudeBareMode Boolean @default(true)
478
519
  /// Coding-run services resolved at dispatch from the base branch's
479
520
  /// .wardby/services.yaml: one snapshot per service (the catalog entry minus
480
521
  /// kind), fixed for the run's lifetime. Empty = none.
@@ -486,6 +527,8 @@ model CodingRun {
486
527
  resultBranch String?
487
528
  /// The commit the run started from (the base ref's tip when the workspace was prepared).
488
529
  baseSha String?
530
+ /// Step in the request's merge order set by the delegating agent (1 = first); null = no order.
531
+ mergeOrder Int?
489
532
  createdAt DateTime @default(now())
490
533
  updatedAt DateTime @updatedAt
491
534
  proxySession CodingProxySession?
@@ -509,6 +552,7 @@ model CodingRun {
509
552
  @@index([failureCategory])
510
553
  @@index([queuedAt])
511
554
  @@index([rootCodingRunId])
555
+ @@index([mergeOrder])
512
556
  }
513
557
 
514
558
  /// Coding-run services (docs/coding-services.md): the catalog a repository's
@@ -590,25 +634,131 @@ enum CodingProxyRequestStatus {
590
634
  uncertain
591
635
  }
592
636
 
637
+ enum NativeGatewaySessionStatus {
638
+ active
639
+ finished
640
+ cancelled
641
+ }
642
+
643
+ enum NativeWarmWorkerStatus {
644
+ warming
645
+ idle
646
+ claimed
647
+ retiring
648
+ }
649
+
650
+ enum NativeGatewayCallStatus {
651
+ reserved
652
+ completed
653
+ released
654
+ uncertain
655
+ pending
656
+ waiting_budget
657
+ }
658
+
659
+ /// The trusted gateway's record of one sandbox-mode native run (native
660
+ /// sandbox phase 3): the worker authenticates with a capability whose hash is
661
+ /// stored here (the raw token is never persisted), and any control-plane
662
+ /// replica can serve it from this row. `snapshot` is what the run loaded --
663
+ /// the worker's input plus trusted-only capabilities and links -- and never
664
+ /// holds a secret value.
665
+ model NativeGatewaySession {
666
+ id String @id @default(cuid())
667
+ runId String @unique
668
+ run Run @relation(fields: [runId], references: [id], onDelete: Cascade)
669
+ capabilityHash String @unique
670
+ status NativeGatewaySessionStatus @default(active)
671
+ deadlineAt DateTime
672
+ budgetUsd Decimal @db.Decimal(18, 10)
673
+ snapshot Json
674
+ /// Set the first time the gateway refuses a model call for budget.
675
+ budgetExhaustedAt DateTime?
676
+ /// When the worker's network isolation was proven (a Kubernetes run's in-pod
677
+ /// probe; a Docker run's network exists before its container). The gateway
678
+ /// serves nothing before this is set.
679
+ networkReadyAt DateTime?
680
+ createdAt DateTime @default(now())
681
+ updatedAt DateTime @updatedAt
682
+ calls NativeGatewayCall[]
683
+
684
+ /// NATIVE_SANDBOX_MAX_CONCURRENT counts the active sessions on every start.
685
+ @@index([status])
686
+ }
687
+
688
+ /// One worker of the native sandbox warm pool (native sandbox phase 6): an
689
+ /// isolated worker started before any run exists, holding no run data or
690
+ /// capability. A run claims an idle one with a compare-and-swap on this row
691
+ /// (`runId` is set at the claim), its input is delivered only after, and the
692
+ /// worker is destroyed after that one run. The row is inserted before the
693
+ /// worker is created, so a worker with no row is an orphan.
694
+ model NativeWarmWorker {
695
+ /// The worker's random token; its container or pod name carries it.
696
+ id String @id
697
+ name String @unique
698
+ status NativeWarmWorkerStatus @default(warming)
699
+ /// What the worker was built from (image, limits, isolation settings): a
700
+ /// claim only takes a worker of the current spec.
701
+ specHash String
702
+ runId String? @unique
703
+ run Run? @relation(fields: [runId], references: [id], onDelete: SetNull)
704
+ /// When its isolation was proven and it became claimable.
705
+ readyAt DateTime?
706
+ claimedAt DateTime?
707
+ createdAt DateTime @default(now())
708
+ updatedAt DateTime @updatedAt
709
+
710
+ @@index([status, specHash])
711
+ }
712
+
713
+ /// One worker call through the gateway, keyed by its callId: model calls are
714
+ /// reserved before the provider is called and settled after; side-effecting
715
+ /// built-in and bridge calls keep their result so a retried callId replays it;
716
+ /// a delegation records the child run it started.
717
+ model NativeGatewayCall {
718
+ id String @id @default(cuid())
719
+ sessionId String
720
+ session NativeGatewaySession @relation(fields: [sessionId], references: [id], onDelete: Cascade)
721
+ callId String
722
+ method String
723
+ status NativeGatewayCallStatus
724
+ reservationUsd Decimal? @db.Decimal(18, 10)
725
+ actualCostUsd Decimal? @db.Decimal(18, 10)
726
+ inputTokens Int?
727
+ outputTokens Int?
728
+ cachedInputTokens Int?
729
+ cacheWriteTokens Int?
730
+ /// A replayable result. Never a secret value.
731
+ result Json?
732
+ childRunId String?
733
+ /// A delegation's sub-agent, recorded at admission (it holds a place while waiting for budget).
734
+ childAgentId String?
735
+ createdAt DateTime @default(now())
736
+ updatedAt DateTime @updatedAt
737
+ completedAt DateTime?
738
+
739
+ @@unique([sessionId, callId])
740
+ @@index([sessionId, status])
741
+ }
742
+
593
743
  /// Trusted-boundary state for one coding run. Only a capability digest and an
594
744
  /// upstream credential reference are persisted; neither secret value enters the DB.
595
745
  model CodingProxySession {
596
- id String @id @default(cuid())
597
- runId String @unique
598
- run CodingRun @relation(fields: [runId], references: [runId], onDelete: Cascade)
599
- capabilityHash String @unique
600
- credentialRef String
601
- protocol String @default("openai-responses")
602
- allowedModels Json
603
- deadlineAt DateTime
604
- budgetUsd Decimal @db.Decimal(18, 10)
605
- status CodingProxySessionStatus @default(active)
606
- createdAt DateTime @default(now())
607
- updatedAt DateTime @updatedAt
608
- requests CodingProxyRequest[]
746
+ id String @id @default(cuid())
747
+ runId String @unique
748
+ run CodingRun @relation(fields: [runId], references: [runId], onDelete: Cascade)
749
+ capabilityHash String @unique
750
+ credentialRef String
751
+ protocol String @default("openai-responses")
752
+ allowedModels Json
753
+ deadlineAt DateTime
754
+ budgetUsd Decimal @db.Decimal(18, 10)
755
+ status CodingProxySessionStatus @default(active)
756
+ createdAt DateTime @default(now())
757
+ updatedAt DateTime @updatedAt
758
+ requests CodingProxyRequest[]
609
759
  /// Hash of the derived registry-only token (see deriveRegistryToken); the
610
760
  /// token itself is never persisted.
611
- registryTokenHash String? @unique
761
+ registryTokenHash String? @unique
612
762
  /// Set the first time the proxy refuses a request of this session for
613
763
  /// budget; lets the executor report the run as out of budget.
614
764
  budgetExhaustedAt DateTime?
@@ -620,8 +770,8 @@ model CodingProxySession {
620
770
  /// is created; the proxy prices and shapes requests from it. Null on
621
771
  /// sessions from before the model catalog (the proxy falls back to the
622
772
  /// shipped catalog).
623
- pricingVersion String?
624
- catalogEntry Json?
773
+ pricingVersion String?
774
+ catalogEntry Json?
625
775
 
626
776
  @@index([deadlineAt])
627
777
  }
@@ -729,10 +879,10 @@ model RegistryApprovedVersion {
729
879
  /// published, no integrity, hosted elsewhere): a download of it is answered
730
880
  /// from here with the same code and reason, without a graph walk.
731
881
  model RegistryPlanRefusal {
732
- runId String
733
- ecosystem String
734
- name String
735
- version String
882
+ runId String
883
+ ecosystem String
884
+ name String
885
+ version String
736
886
  code String
737
887
  reason String
738
888
  /// Set for a too-new refusal: the answer re-checks the version's age
@@ -849,6 +999,8 @@ model Secret {
849
999
  name String
850
1000
  ciphertext String
851
1001
  keyId String
1002
+ /// Brokered-secret config (core/secret-broker-config.ts). Null = readable by attached tools.
1003
+ broker Json?
852
1004
  ownerId String?
853
1005
  owner Principal? @relation(fields: [ownerId], references: [id])
854
1006
  createdAt DateTime @default(now())
@@ -858,6 +1010,24 @@ model Secret {
858
1010
  @@unique([ownerId, name])
859
1011
  }
860
1012
 
1013
+ /// Audit trail of every change to a secret's broker config. No FK to Secret,
1014
+ /// so the history survives deleting the secret. Never holds a value.
1015
+ model SecretBrokerChange {
1016
+ id String @id @default(cuid())
1017
+ secretId String
1018
+ ownerId String
1019
+ secretName String
1020
+ actorId String
1021
+ before Json?
1022
+ after Json?
1023
+ /// "mcp" or "browser"
1024
+ via String
1025
+ createdAt DateTime @default(now())
1026
+
1027
+ @@index([secretId, createdAt])
1028
+ @@index([ownerId, createdAt])
1029
+ }
1030
+
861
1031
  /// Phase 4: attaches a secret to an agent, addressed at sandbox point-of-use
862
1032
  /// by `boundName` (secrets.get(boundName)). `boundName` defaults to the
863
1033
  /// secret's canonical name; it differs only when the agent binds the secret
@@ -1065,20 +1235,20 @@ model AuthRateLimit {
1065
1235
  /// and which host events trigger it. See
1066
1236
  /// docs/private/2026-09-25-code-review-host-design.md §4.1.
1067
1237
  model AgentRepository {
1068
- id String @id @default(cuid())
1069
- agentId String
1070
- agent Agent @relation(fields: [agentId], references: [id], onDelete: Cascade)
1238
+ id String @id @default(cuid())
1239
+ agentId String
1240
+ agent Agent @relation(fields: [agentId], references: [id], onDelete: Cascade)
1071
1241
  /// "github" today; validated in code so adding a host needs no enum migration.
1072
- provider String
1242
+ provider String
1073
1243
  /// Canonical lower-case owner/name for the provider.
1074
- repository String
1244
+ repository String
1075
1245
  /// "read" or "write".
1076
- access String
1246
+ access String
1077
1247
  /// Subset of "pull_request", "mention", "push", "review_fix".
1078
- triggers String[] @default([])
1248
+ triggers String[] @default([])
1079
1249
  /// Only with the "pull_request" trigger (required there); names the agent's
1080
1250
  /// check. Unique per repository across all links (NULLs are distinct).
1081
- checkName String?
1251
+ checkName String?
1082
1252
  /// Only with the "review_fix" trigger: how many automatic fix rounds a
1083
1253
  /// pull request gets before wardby stops. Null = the default (2).
1084
1254
  reviewFixMaxRounds Int?
@@ -1086,8 +1256,8 @@ model AgentRepository {
1086
1256
  /// pushed head until that head's own CI finishes (see DeferredReview),
1087
1257
  /// instead of racing it. Default off: existing links review immediately,
1088
1258
  /// exactly as today.
1089
- waitForCi Boolean @default(false)
1090
- createdAt DateTime @default(now())
1259
+ waitForCi Boolean @default(false)
1260
+ createdAt DateTime @default(now())
1091
1261
 
1092
1262
  /// How this link was authorized: "host_permission" (the agent owner's
1093
1263
  /// verified host identity had enough access), "admin" (a wardby admin
@@ -1122,38 +1292,46 @@ model DeferredReview {
1122
1292
  /// against the same check even if the link's checkName changes later.
1123
1293
  checkName String
1124
1294
  createdAt DateTime @default(now())
1295
+ /// Why the review waits: "ci" (until CI finishes) or "request" (until the
1296
+ /// delegating lead run finishes, then CI if the link waits for it).
1297
+ reason String @default("ci")
1298
+ /// The run-tree root a "request" row waits for.
1299
+ leadRunId String?
1125
1300
 
1126
1301
  @@unique([provider, repository, prNumber, headSha, agentId])
1127
1302
  @@index([provider, repository, headSha])
1128
1303
  @@index([createdAt])
1304
+ @@index([leadRunId])
1129
1305
  }
1130
1306
 
1131
1307
  /// The host check a run owns, so the review tool can complete it and the
1132
1308
  /// run finalizer can close it if the run ends without publishing.
1133
1309
  model RunHostCheck {
1134
- runId String @id
1135
- run Run @relation(fields: [runId], references: [id], onDelete: Cascade)
1136
- provider String
1137
- repository String
1138
- checkId String
1139
- headSha String
1310
+ runId String @id
1311
+ run Run @relation(fields: [runId], references: [id], onDelete: Cascade)
1312
+ provider String
1313
+ repository String
1314
+ checkId String
1315
+ headSha String
1140
1316
  /// The pull request the run was dispatched for. The review tool only
1141
1317
  /// completes or creates a check for this PR. Null on rows written before it
1142
1318
  /// existed: such a run publishes without a check.
1143
- prNumber Int?
1144
- completedAt DateTime?
1319
+ prNumber Int?
1320
+ completedAt DateTime?
1145
1321
  /// The verdict the run published on its own check ("APPROVE",
1146
1322
  /// "CHANGES_REQUESTED", "COMMENT"); null until then, or when the check was
1147
1323
  /// closed without one (superseded, or by the finalizer).
1148
- verdict String?
1324
+ verdict String?
1149
1325
  /// The published review's summary and body (capped), kept for an automatic
1150
1326
  /// fix round started when the run finishes.
1151
- reviewBody String?
1327
+ reviewBody String?
1152
1328
  /// The run published COMMENT while CI on its head was still running or had
1153
1329
  /// not reported yet. CI finishing on that head later re-runs the review.
1154
- ciPendingAtReview Boolean?
1330
+ ciPendingAtReview Boolean?
1155
1331
  /// When CI finishing on this head re-ran the review: at most once per head.
1156
- ciRereviewAt DateTime?
1332
+ ciRereviewAt DateTime?
1333
+ /// When a no-change review-fix round re-reviewed this CHANGES_REQUESTED review: at most once.
1334
+ noChangeRereviewAt DateTime?
1157
1335
  }
1158
1336
 
1159
1337
  /// De-duplicates host webhook redeliveries; pruned after 7 days.
@@ -1468,3 +1646,96 @@ model LocalReview {
1468
1646
 
1469
1647
  @@index([pullRequestId, createdAt])
1470
1648
  }
1649
+
1650
+ /// A Slack (chat) channel that receives workflow notifications for a Jira
1651
+ /// project or for one agent. Exactly one subject: (issueProvider, projectKey)
1652
+ /// or agentId (enforced in code and by a CHECK constraint). Admin-approved.
1653
+ /// See docs/slack-notifications.md.
1654
+ model NotificationChannel {
1655
+ id String @id @default(cuid())
1656
+ /// "slack" today; validated in code.
1657
+ provider String
1658
+ /// Slack channel id (C…/G…), upper-case.
1659
+ channelId String
1660
+ /// Last known channel name, display only.
1661
+ channelName String?
1662
+ issueProvider String?
1663
+ projectKey String?
1664
+ agentId String?
1665
+ agent Agent? @relation(fields: [agentId], references: [id], onDelete: Cascade)
1666
+ /// Subset of the workflow event kinds; empty = all.
1667
+ events String[] @default([])
1668
+ /// Append the run's spend line to messages.
1669
+ includeCost Boolean @default(false)
1670
+ /// Set by the dispatcher on a permanent channel error; cleared by re-linking.
1671
+ lastError String?
1672
+ lastErrorAt DateTime?
1673
+ authorizedById String
1674
+ authorizedAt DateTime @default(now())
1675
+ createdAt DateTime @default(now())
1676
+
1677
+ @@unique([provider, channelId, issueProvider, projectKey])
1678
+ @@unique([provider, channelId, agentId])
1679
+ @@index([issueProvider, projectKey])
1680
+ @@index([agentId])
1681
+ }
1682
+
1683
+ /// One workflow fact (a card picked up, a PR opened, ...). Written only when
1684
+ /// at least one channel matches. No FKs to Run/Agent: audit-style rows.
1685
+ model WorkflowEvent {
1686
+ id String @id @default(cuid())
1687
+ kind String
1688
+ /// Idempotency key: repeated recordings of the same fact are no-ops.
1689
+ dedupeKey String @unique
1690
+ runId String?
1691
+ agentId String?
1692
+ workItemProvider String?
1693
+ workItemKey String?
1694
+ codeProvider String?
1695
+ repository String?
1696
+ prNumber Int?
1697
+ /// Template inputs only: never secrets, code, review bodies or run output.
1698
+ payload Json
1699
+ createdAt DateTime @default(now())
1700
+ deliveries NotificationDelivery[]
1701
+
1702
+ @@index([createdAt])
1703
+ }
1704
+
1705
+ /// One event's delivery to one channel (the outbox row the dispatcher works).
1706
+ model NotificationDelivery {
1707
+ id String @id @default(cuid())
1708
+ eventId String
1709
+ event WorkflowEvent @relation(fields: [eventId], references: [id], onDelete: Cascade)
1710
+ provider String
1711
+ channelId String
1712
+ threadKey String
1713
+ includeCost Boolean @default(false)
1714
+ /// "pending" | "delivered" | "failed"
1715
+ state String @default("pending")
1716
+ attempts Int @default(0)
1717
+ nextAttemptAt DateTime @default(now())
1718
+ lastError String?
1719
+ messageTs String?
1720
+ deliveredAt DateTime?
1721
+ createdAt DateTime @default(now())
1722
+
1723
+ @@unique([eventId, provider, channelId])
1724
+ @@index([state, nextAttemptAt])
1725
+ @@index([provider, channelId, threadKey, createdAt])
1726
+ }
1727
+
1728
+ /// The parent message of a work item's (or PR's) thread in one channel.
1729
+ model NotificationThread {
1730
+ id String @id @default(cuid())
1731
+ provider String
1732
+ channelId String
1733
+ threadKey String
1734
+ parentTs String
1735
+ /// Current status line shown on the parent message.
1736
+ status String
1737
+ createdAt DateTime @default(now())
1738
+ updatedAt DateTime @updatedAt
1739
+
1740
+ @@unique([provider, channelId, threadKey])
1741
+ }