@wardby/cli 0.5.3 → 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 (370) 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/profile.d.ts +12 -0
  17. package/dist/coding/profile.js +6 -0
  18. package/dist/coding/protocol.d.ts +104 -0
  19. package/dist/coding/protocol.js +87 -3
  20. package/dist/coding-worker/artifact.d.ts +8 -0
  21. package/dist/coding-worker/artifact.js +2 -2
  22. package/dist/coding-worker/driver.js +2 -0
  23. package/dist/coding-worker/sdk.d.ts +6 -0
  24. package/dist/coding-worker/sdk.js +1 -0
  25. package/dist/coding-worker/skills.d.ts +23 -0
  26. package/dist/coding-worker/skills.js +117 -0
  27. package/dist/coding-worker/types.d.ts +2 -0
  28. package/dist/config/github-allowed-accounts.d.ts +15 -0
  29. package/dist/config/github-allowed-accounts.js +36 -0
  30. package/dist/config/low-power.d.ts +12 -0
  31. package/dist/config/low-power.js +18 -0
  32. package/dist/config/mobile.d.ts +12 -0
  33. package/dist/config/mobile.js +18 -0
  34. package/dist/config/providers.d.ts +53 -0
  35. package/dist/config/providers.js +92 -6
  36. package/dist/core/db.d.ts +16 -6
  37. package/dist/core/db.js +12 -10
  38. package/dist/core/dispatch.d.ts +11 -0
  39. package/dist/core/dispatch.js +36 -1
  40. package/dist/core/engine-native.js +9 -5
  41. package/dist/core/host-events.d.ts +49 -3
  42. package/dist/core/host-events.js +289 -15
  43. package/dist/core/issue-bridge.js +42 -2
  44. package/dist/core/issue-events.js +12 -1
  45. package/dist/core/issue-status.js +14 -3
  46. package/dist/core/merge-order-check.d.ts +129 -0
  47. package/dist/core/merge-order-check.js +336 -0
  48. package/dist/core/notification-dispatcher.d.ts +70 -0
  49. package/dist/core/notification-dispatcher.js +368 -0
  50. package/dist/core/notification-templates.d.ts +25 -0
  51. package/dist/core/notification-templates.js +105 -0
  52. package/dist/core/notifications.d.ts +10 -0
  53. package/dist/core/notifications.js +38 -0
  54. package/dist/core/pg-auth.d.ts +22 -0
  55. package/dist/core/pg-auth.js +152 -0
  56. package/dist/core/power-composition.d.ts +16 -0
  57. package/dist/core/power-composition.js +37 -0
  58. package/dist/core/power-idle.d.ts +14 -0
  59. package/dist/core/power-idle.js +30 -0
  60. package/dist/core/power.d.ts +71 -0
  61. package/dist/core/power.js +202 -0
  62. package/dist/core/reconciler.d.ts +4 -2
  63. package/dist/core/reconciler.js +29 -5
  64. package/dist/core/related-pull-requests.d.ts +48 -4
  65. package/dist/core/related-pull-requests.js +113 -11
  66. package/dist/core/repo-access.d.ts +15 -0
  67. package/dist/core/repo-access.js +66 -0
  68. package/dist/core/review-fix.d.ts +37 -0
  69. package/dist/core/review-fix.js +207 -6
  70. package/dist/core/review-host-tools.d.ts +20 -0
  71. package/dist/core/review-host-tools.js +58 -2
  72. package/dist/core/runner.d.ts +336 -3
  73. package/dist/core/runner.js +894 -317
  74. package/dist/core/secret-broker-config.d.ts +103 -0
  75. package/dist/core/secret-broker-config.js +112 -0
  76. package/dist/core/secrets.d.ts +39 -4
  77. package/dist/core/secrets.js +148 -40
  78. package/dist/core/workflow-event-recorder.d.ts +14 -0
  79. package/dist/core/workflow-event-recorder.js +120 -0
  80. package/dist/core/workflow-events.d.ts +82 -0
  81. package/dist/core/workflow-events.js +44 -0
  82. package/dist/core/workflow-run-events.d.ts +16 -0
  83. package/dist/core/workflow-run-events.js +40 -0
  84. package/dist/generated/prisma/browser.d.ts +58 -0
  85. package/dist/generated/prisma/client.d.ts +58 -0
  86. package/dist/generated/prisma/commonInputTypes.d.ts +150 -0
  87. package/dist/generated/prisma/enums.d.ts +27 -0
  88. package/dist/generated/prisma/enums.js +23 -0
  89. package/dist/generated/prisma/internal/class.d.ts +88 -0
  90. package/dist/generated/prisma/internal/class.js +4 -4
  91. package/dist/generated/prisma/internal/prismaNamespace.d.ts +772 -1
  92. package/dist/generated/prisma/internal/prismaNamespace.js +135 -4
  93. package/dist/generated/prisma/internal/prismaNamespaceBrowser.d.ts +139 -0
  94. package/dist/generated/prisma/internal/prismaNamespaceBrowser.js +135 -4
  95. package/dist/generated/prisma/models/Agent.d.ts +360 -1
  96. package/dist/generated/prisma/models/CodingAgentProfile.d.ts +73 -1
  97. package/dist/generated/prisma/models/CodingRun.d.ts +205 -1
  98. package/dist/generated/prisma/models/DeferredReview.d.ts +78 -1
  99. package/dist/generated/prisma/models/NativeGatewayCall.d.ts +1675 -0
  100. package/dist/generated/prisma/models/NativeGatewayCall.js +1 -0
  101. package/dist/generated/prisma/models/NativeGatewaySession.d.ts +1517 -0
  102. package/dist/generated/prisma/models/NativeGatewaySession.js +1 -0
  103. package/dist/generated/prisma/models/NativeWarmWorker.d.ts +1296 -0
  104. package/dist/generated/prisma/models/NativeWarmWorker.js +1 -0
  105. package/dist/generated/prisma/models/NotificationChannel.d.ts +1543 -0
  106. package/dist/generated/prisma/models/NotificationChannel.js +1 -0
  107. package/dist/generated/prisma/models/NotificationDelivery.d.ts +1502 -0
  108. package/dist/generated/prisma/models/NotificationDelivery.js +1 -0
  109. package/dist/generated/prisma/models/NotificationThread.d.ts +1090 -0
  110. package/dist/generated/prisma/models/NotificationThread.js +1 -0
  111. package/dist/generated/prisma/models/Run.d.ts +826 -1
  112. package/dist/generated/prisma/models/RunHostCheck.d.ts +36 -1
  113. package/dist/generated/prisma/models/Secret.d.ts +37 -1
  114. package/dist/generated/prisma/models/SecretBrokerChange.d.ts +1101 -0
  115. package/dist/generated/prisma/models/SecretBrokerChange.js +1 -0
  116. package/dist/generated/prisma/models/WorkflowEvent.d.ts +1422 -0
  117. package/dist/generated/prisma/models/WorkflowEvent.js +1 -0
  118. package/dist/generated/prisma/models.d.ts +8 -0
  119. package/dist/help/build.js +4 -2
  120. package/dist/help/catalog.d.ts +1 -1
  121. package/dist/help/catalog.js +31 -6
  122. package/dist/help-index.json +1363 -176
  123. package/dist/import/create.js +17 -0
  124. package/dist/import/neutral-schema.d.ts +6 -2
  125. package/dist/import/neutral-schema.js +2 -0
  126. package/dist/mcp/auth/access.d.ts +1 -0
  127. package/dist/mcp/auth/repo-authorization.js +14 -0
  128. package/dist/mcp/auth/resource-server.d.ts +2 -1
  129. package/dist/mcp/auth/resource-server.js +7 -2
  130. package/dist/mcp/auth/self-hosted/browser.d.ts +1 -1
  131. package/dist/mcp/auth/self-hosted/browser.js +19 -6
  132. package/dist/mcp/context.d.ts +6 -0
  133. package/dist/mcp/host-events/github-ingress.d.ts +23 -1
  134. package/dist/mcp/host-events/github-ingress.js +68 -0
  135. package/dist/mcp/index.d.ts +13 -0
  136. package/dist/mcp/index.js +59 -10
  137. package/dist/mcp/tools/agents.js +82 -11
  138. package/dist/mcp/tools/notification-channels.d.ts +2 -0
  139. package/dist/mcp/tools/notification-channels.js +293 -0
  140. package/dist/mcp/tools/power.d.ts +2 -0
  141. package/dist/mcp/tools/power.js +77 -0
  142. package/dist/mcp/tools/runs.d.ts +0 -6
  143. package/dist/mcp/tools/runs.js +7 -2
  144. package/dist/mcp/tools/secret-broker-compat.d.ts +12 -0
  145. package/dist/mcp/tools/secret-broker-compat.js +23 -0
  146. package/dist/mcp/tools/secret-elicitation-form.d.ts +22 -2
  147. package/dist/mcp/tools/secret-elicitation-form.js +200 -10
  148. package/dist/mcp/tools/secret-elicitation-server.js +8 -1
  149. package/dist/mcp/tools/secret-elicitation.d.ts +38 -3
  150. package/dist/mcp/tools/secret-elicitation.js +110 -12
  151. package/dist/mcp/tools/secrets.js +184 -7
  152. package/dist/mcp/tools/tools.d.ts +1 -1
  153. package/dist/mcp/tools/tools.js +22 -2
  154. package/dist/native-worker/composition.d.ts +23 -0
  155. package/dist/native-worker/composition.js +77 -0
  156. package/dist/native-worker/docker-isolation.d.ts +65 -0
  157. package/dist/native-worker/docker-isolation.js +183 -0
  158. package/dist/native-worker/docker-launcher.d.ts +74 -0
  159. package/dist/native-worker/docker-launcher.js +237 -0
  160. package/dist/native-worker/gateway-server.d.ts +39 -0
  161. package/dist/native-worker/gateway-server.js +315 -0
  162. package/dist/native-worker/gateway.d.ts +44 -0
  163. package/dist/native-worker/gateway.js +197 -0
  164. package/dist/native-worker/http-server.d.ts +22 -0
  165. package/dist/native-worker/http-server.js +109 -0
  166. package/dist/native-worker/http-transport.d.ts +17 -0
  167. package/dist/native-worker/http-transport.js +88 -0
  168. package/dist/native-worker/kubernetes-isolation.d.ts +90 -0
  169. package/dist/native-worker/kubernetes-isolation.js +218 -0
  170. package/dist/native-worker/kubernetes-launcher.d.ts +102 -0
  171. package/dist/native-worker/kubernetes-launcher.js +335 -0
  172. package/dist/native-worker/launch.d.ts +45 -0
  173. package/dist/native-worker/launch.js +44 -0
  174. package/dist/native-worker/ledger.d.ts +109 -0
  175. package/dist/native-worker/ledger.js +192 -0
  176. package/dist/native-worker/loopback.d.ts +12 -0
  177. package/dist/native-worker/loopback.js +49 -0
  178. package/dist/native-worker/main.d.ts +7 -0
  179. package/dist/native-worker/main.js +74 -0
  180. package/dist/native-worker/protocol.d.ts +744 -0
  181. package/dist/native-worker/protocol.js +200 -0
  182. package/dist/native-worker/sandbox-executor.d.ts +68 -0
  183. package/dist/native-worker/sandbox-executor.js +210 -0
  184. package/dist/native-worker/stdio.d.ts +29 -0
  185. package/dist/native-worker/stdio.js +188 -0
  186. package/dist/native-worker/warm-delivery.d.ts +16 -0
  187. package/dist/native-worker/warm-delivery.js +33 -0
  188. package/dist/native-worker/warm-pool-ledger.d.ts +39 -0
  189. package/dist/native-worker/warm-pool-ledger.js +73 -0
  190. package/dist/native-worker/warm-pool.d.ts +107 -0
  191. package/dist/native-worker/warm-pool.js +283 -0
  192. package/dist/native-worker/worker.d.ts +17 -0
  193. package/dist/native-worker/worker.js +115 -0
  194. package/dist/providers/auth/authorization-server.d.ts +3 -0
  195. package/dist/providers/auth/index.js +2 -0
  196. package/dist/providers/auth/self-hosted.d.ts +13 -1
  197. package/dist/providers/auth/self-hosted.js +54 -4
  198. package/dist/providers/chat/fake.d.ts +46 -0
  199. package/dist/providers/chat/fake.js +39 -0
  200. package/dist/providers/chat/index.d.ts +4 -0
  201. package/dist/providers/chat/index.js +8 -0
  202. package/dist/providers/chat/slack.d.ts +37 -0
  203. package/dist/providers/chat/slack.js +105 -0
  204. package/dist/providers/chat/types.d.ts +42 -0
  205. package/dist/providers/chat/types.js +19 -0
  206. package/dist/providers/engine/types.d.ts +19 -0
  207. package/dist/providers/engine/types.js +22 -0
  208. package/dist/providers/executor/composition.d.ts +24 -1
  209. package/dist/providers/executor/composition.js +39 -6
  210. package/dist/providers/executor/container.d.ts +24 -1
  211. package/dist/providers/executor/container.js +101 -11
  212. package/dist/providers/executor/dbos.d.ts +42 -0
  213. package/dist/providers/executor/dbos.js +118 -12
  214. package/dist/providers/executor/deferred.d.ts +56 -0
  215. package/dist/providers/executor/deferred.js +119 -0
  216. package/dist/providers/executor/routing.d.ts +37 -10
  217. package/dist/providers/executor/routing.js +73 -32
  218. package/dist/providers/executor/types.d.ts +12 -0
  219. package/dist/providers/jobs/docker.js +3 -3
  220. package/dist/providers/jobs/fake-kubernetes-api.d.ts +21 -2
  221. package/dist/providers/jobs/fake-kubernetes-api.js +42 -1
  222. package/dist/providers/jobs/kubernetes-api.d.ts +17 -1
  223. package/dist/providers/jobs/kubernetes-api.js +7 -0
  224. package/dist/providers/jobs/kubernetes-client.d.ts +10 -1
  225. package/dist/providers/jobs/kubernetes-client.js +52 -3
  226. package/dist/providers/jobs/kubernetes-dry-run-fixture.d.ts +6 -1
  227. package/dist/providers/jobs/kubernetes-dry-run-fixture.js +6 -3
  228. package/dist/providers/jobs/kubernetes-isolation.d.ts +3 -1
  229. package/dist/providers/jobs/kubernetes-isolation.js +6 -0
  230. package/dist/providers/jobs/kubernetes-platform.d.ts +4 -1
  231. package/dist/providers/jobs/kubernetes-platform.js +38 -1
  232. package/dist/providers/jobs/kubernetes-preflight.d.ts +2 -1
  233. package/dist/providers/jobs/kubernetes-preflight.js +4 -2
  234. package/dist/providers/jobs/kubernetes.d.ts +36 -1
  235. package/dist/providers/jobs/kubernetes.js +74 -4
  236. package/dist/providers/jobs/metadata-probes.d.ts +11 -0
  237. package/dist/providers/jobs/metadata-probes.js +13 -0
  238. package/dist/providers/jobs/types.d.ts +9 -0
  239. package/dist/providers/review-host/github.d.ts +11 -1
  240. package/dist/providers/review-host/github.js +50 -0
  241. package/dist/providers/review-host/types.d.ts +23 -0
  242. package/dist/providers/vcs/github.d.ts +32 -6
  243. package/dist/providers/vcs/github.js +74 -16
  244. package/dist/quickstart/coding-seed.d.ts +10 -3
  245. package/dist/quickstart/coding-seed.js +74 -3
  246. package/dist/quickstart/images.d.ts +2 -0
  247. package/dist/quickstart/images.js +7 -1
  248. package/dist/quickstart/reviewer-prompt.d.ts +1 -1
  249. package/dist/quickstart/reviewer-prompt.js +1 -1
  250. package/dist/quickstart-images.json +1 -1
  251. package/dist/sandbox/brokered-fetch.d.ts +23 -0
  252. package/dist/sandbox/brokered-fetch.js +37 -0
  253. package/dist/sandbox/host-functions.d.ts +34 -0
  254. package/dist/sandbox/host-functions.js +144 -80
  255. package/dist/sandbox/prelude.js +7 -1
  256. package/dist/sandbox/run-in-sandbox.d.ts +19 -0
  257. package/dist/sandbox/run-in-sandbox.js +28 -10
  258. package/dist/sandbox/safe-fetch.d.ts +2 -0
  259. package/dist/sandbox/safe-fetch.js +3 -1
  260. package/dist/sandbox/secret-broker-sigv4.d.ts +2 -0
  261. package/dist/sandbox/secret-broker-sigv4.js +49 -0
  262. package/dist/sandbox/secret-broker.d.ts +34 -0
  263. package/dist/sandbox/secret-broker.js +162 -0
  264. package/dist/sandbox/user-tool.d.ts +14 -0
  265. package/dist/sandbox/user-tool.js +32 -0
  266. package/dist/serve.js +18 -0
  267. package/dist/viewer/api-schema.d.ts +210 -14
  268. package/dist/viewer/api-schema.js +22 -0
  269. package/dist/viewer/build-schemas.js +4 -1
  270. package/dist/viewer/event-bus.d.ts +6 -0
  271. package/dist/viewer/event-bus.js +16 -7
  272. package/dist/viewer/graph.d.ts +5 -2
  273. package/dist/viewer/graph.js +7 -2
  274. package/dist/viewer/http.d.ts +0 -1
  275. package/dist/viewer/http.js +2 -2
  276. package/dist/viewer/infra.js +25 -2
  277. package/dist/viewer/limits.d.ts +4 -0
  278. package/dist/viewer/limits.js +4 -0
  279. package/dist/viewer/openapi.d.ts +15 -0
  280. package/dist/viewer/openapi.js +172 -0
  281. package/docs/README.md +7 -0
  282. package/docs/agent-recipes.md +57 -8
  283. package/docs/architecture-runtime.md +16 -1
  284. package/docs/code-review-agents.md +139 -5
  285. package/docs/coding-agent-setup.md +113 -5
  286. package/docs/coding-packages.md +4 -2
  287. package/docs/coding-services.md +3 -1
  288. package/docs/coding-worker-byo-images.md +198 -6
  289. package/docs/coding-worker-isolation.md +68 -14
  290. package/docs/getting-started-gke.md +225 -9
  291. package/docs/getting-started-identity-provider.md +21 -10
  292. package/docs/getting-started.md +5 -4
  293. package/docs/jira-agents.md +5 -1
  294. package/docs/native-sandbox.md +635 -0
  295. package/docs/release-verification.md +9 -0
  296. package/docs/security-deployment.md +113 -12
  297. package/docs/slack-notifications.md +252 -0
  298. package/docs/tool-secrets.md +252 -0
  299. package/docs/viewer-api.md +46 -5
  300. package/docs/viewer-api.openapi.yml +1404 -0
  301. package/help/admin-viewer.md +6 -2
  302. package/help/agent-recipes.md +27 -0
  303. package/help/architecture-agent.md +1 -1
  304. package/help/brokered-secrets.md +79 -0
  305. package/help/build-claude-code-image.md +131 -0
  306. package/help/build-worker-image.md +3 -6
  307. package/help/code-review-agents.md +68 -6
  308. package/help/deploy-gke.md +8 -1
  309. package/help/deployment-targets.md +25 -14
  310. package/help/errors/coding-provider-not-configured.md +2 -2
  311. package/help/errors/database-auth-invalid.md +28 -0
  312. package/help/errors/github-account-not-allowed.md +25 -0
  313. package/help/errors/low-power-disabled.md +29 -0
  314. package/help/errors/low-power-scale-forbidden.md +35 -0
  315. package/help/errors/low-power-wake-timeout.md +30 -0
  316. package/help/errors/mobile-disabled.md +31 -0
  317. package/help/errors/native-sandbox-capacity.md +22 -0
  318. package/help/errors/native-sandbox-deadline-exceeded.md +19 -0
  319. package/help/errors/native-sandbox-docker-failed.md +20 -0
  320. package/help/errors/native-sandbox-gateway-unavailable.md +21 -0
  321. package/help/errors/native-sandbox-image-not-pinned.md +19 -0
  322. package/help/errors/native-sandbox-isolation-mismatch.md +20 -0
  323. package/help/errors/native-sandbox-network-unenforced.md +22 -0
  324. package/help/errors/native-sandbox-requires-catalog.md +31 -0
  325. package/help/errors/native-sandbox-unavailable.md +19 -0
  326. package/help/errors/native-sandbox-warm-delivery-failed.md +21 -0
  327. package/help/errors/native-sandbox-worker-exited.md +20 -0
  328. package/help/errors/native-sandbox-worker-lost.md +20 -0
  329. package/help/errors/native-sandbox-worker-unready.md +22 -0
  330. package/help/errors/secret-broker-body-invalid.md +26 -0
  331. package/help/errors/secret-broker-changed.md +20 -0
  332. package/help/errors/secret-broker-config-invalid.md +30 -0
  333. package/help/errors/secret-broker-conflict.md +27 -0
  334. package/help/errors/secret-broker-destination-denied.md +28 -0
  335. package/help/errors/secret-broker-value-invalid.md +28 -0
  336. package/help/errors/secret-brokered.md +24 -0
  337. package/help/errors/secret-not-brokered.md +25 -0
  338. package/help/errors/slack-auth-failed.md +48 -0
  339. package/help/errors/slack-channel-unreachable.md +39 -0
  340. package/help/errors/slack-not-configured.md +33 -0
  341. package/help/getting-started.md +4 -5
  342. package/help/github.md +18 -1
  343. package/help/identity-and-access.md +5 -1
  344. package/help/local-repositories.md +2 -3
  345. package/help/low-power-mode.md +125 -0
  346. package/help/merge-order-check.md +117 -0
  347. package/help/mobile-app.md +54 -0
  348. package/help/native-sandbox.md +136 -0
  349. package/help/observability.md +8 -0
  350. package/help/related-pull-requests.md +70 -9
  351. package/help/repo-instructions-and-skills.md +91 -0
  352. package/help/review-fix-rounds.md +10 -0
  353. package/help/slack-notifications.md +62 -0
  354. package/help/troubleshooting/coding-workers.md +21 -0
  355. package/package.json +11 -4
  356. package/prisma/migrations/20261009000003_native_execution_mode/migration.sql +12 -0
  357. package/prisma/migrations/20261009000004_native_gateway_ledger/migration.sql +65 -0
  358. package/prisma/migrations/20261009000005_native_gateway_call_child_agent/migration.sql +5 -0
  359. package/prisma/migrations/20261009000006_run_deferred_start_stop/migration.sql +14 -0
  360. package/prisma/migrations/20261009000007_native_gateway_network_ready/migration.sql +5 -0
  361. package/prisma/migrations/20261010000001_workflow_notifications/migration.sql +99 -0
  362. package/prisma/migrations/20261011000001_native_gateway_session_status_index/migration.sql +2 -0
  363. package/prisma/migrations/20261012000001_native_warm_worker/migration.sql +32 -0
  364. package/prisma/migrations/20261013000001_coding_run_merge_order/migration.sql +2 -0
  365. package/prisma/migrations/20261013000001_secret_broker/migration.sql +17 -0
  366. package/prisma/migrations/20261013000002_deferred_review_request/migration.sql +4 -0
  367. package/prisma/migrations/20261014000000_repo_skills/migration.sql +15 -0
  368. package/prisma/migrations/20261015000001_coding_run_merge_order_index/migration.sql +2 -0
  369. package/prisma/migrations/20261015000002_no_change_rereview/migration.sql +2 -0
  370. package/prisma/schema.prisma +362 -91
@@ -0,0 +1,32 @@
1
+ /**
2
+ * One user-tool call, end to end: parse the model's arguments, validate them
3
+ * against the tool's Zod schema (in its own sandbox), run the body, and format
4
+ * the result string fed back to the model. Never throws — every failure is a
5
+ * JSON error result. Worker-safe: it touches no database or provider, only the
6
+ * privileged host it is given, so the native sandbox worker runs it as is.
7
+ */
8
+ import { runToolCode } from "./run-in-sandbox.js";
9
+ import { validateParams } from "./zod-params.js";
10
+ export async function runUserToolCall(tool, argsJson, privileged, limits) {
11
+ let parsedArgs;
12
+ try {
13
+ // Some providers stream no JSON delta at all for a zero-parameter
14
+ // tool call, yielding an empty argsJson rather than "{}".
15
+ parsedArgs = JSON.parse(argsJson || "{}");
16
+ }
17
+ catch (err) {
18
+ return JSON.stringify({
19
+ error: "invalid_arguments_json",
20
+ message: err instanceof Error ? err.message : String(err),
21
+ });
22
+ }
23
+ const validation = await validateParams(tool.paramsZod, parsedArgs);
24
+ if (!validation.ok) {
25
+ return JSON.stringify({ error: "validation_failed", message: validation.errorMessage });
26
+ }
27
+ const result = await runToolCode({ code: tool.code, params: validation.value, limits, privileged });
28
+ if (!result.ok) {
29
+ return JSON.stringify({ error: result.errorKind, message: result.errorMessage });
30
+ }
31
+ return JSON.stringify(result.value);
32
+ }
package/dist/serve.js CHANGED
@@ -19,10 +19,15 @@
19
19
  import { loadCodingConcurrencyConfig, loadMcpConfig } from "./config/providers.js";
20
20
  import { drainCodingQueue } from "./core/coding-queue.js";
21
21
  import { prisma } from "./core/db.js";
22
+ import { logger } from "./core/logger.js";
23
+ import { DISABLED_POWER } from "./core/power.js";
24
+ import { startNotifications } from "./core/notifications.js";
22
25
  import { startReconciler } from "./core/reconciler.js";
23
26
  import { createRepoAccessGate } from "./core/repo-access.js";
24
27
  import { startScheduler } from "./core/scheduler.js";
28
+ import { drainDeferredRuns } from "./providers/executor/deferred.js";
25
29
  import { buildMcpProviders, startMcp } from "./mcp/index.js";
30
+ const serveLog = logger.child({ module: "serve" });
26
31
  export async function startServe(options = {}) {
27
32
  const transport = loadMcpConfig().transport;
28
33
  if (transport !== "http") {
@@ -33,6 +38,13 @@ export async function startServe(options = {}) {
33
38
  // CODING_QUEUE_TIMEOUT_SEC fails fast instead of after HTTP is listening.
34
39
  const concurrency = loadCodingConcurrencyConfig();
35
40
  const providers = options.providers ?? buildMcpProviders().providers;
41
+ const power = providers.power ?? DISABLED_POWER;
42
+ if (power.enabled) {
43
+ void power.checkAccess().then((missing) => {
44
+ if (missing.length)
45
+ serveLog.warn(`low_power_scale_forbidden: missing ${missing.join(", ")}`);
46
+ }, (err) => serveLog.warn({ err }, "low_power_access_check_failed"));
47
+ }
36
48
  const mcp = await startMcp({ providers, schedulerAttached: true });
37
49
  const reviewHosts = providers.reviewHosts;
38
50
  const reconciler = startReconciler({
@@ -51,6 +63,7 @@ export async function startServe(options = {}) {
51
63
  }
52
64
  : {}),
53
65
  });
66
+ const notifications = await startNotifications({ db: prisma, chat: providers.chat ?? {} });
54
67
  const selfDefects = { db: prisma, issueTrackers: providers.issueTrackers };
55
68
  const scheduler = startScheduler({
56
69
  executor: providers.executor,
@@ -58,6 +71,10 @@ export async function startServe(options = {}) {
58
71
  selfDefects,
59
72
  onLeaderTick: async () => {
60
73
  await drainCodingQueue({ db: prisma, executor: providers.executor, ...concurrency, selfDefects });
74
+ // Runs the native sandbox gateway dispatched (or asked to stop): it holds no executor of its own.
75
+ await drainDeferredRuns({ db: prisma, executor: providers.executor });
76
+ // Scale idle coding-proxy/native-gateway Deployments to zero (no-op unless WARDBY_LOW_POWER=1).
77
+ await power.sleepIfIdle().catch((err) => serveLog.warn({ err }, "power_sleep_failed"));
61
78
  },
62
79
  });
63
80
  return {
@@ -67,6 +84,7 @@ export async function startServe(options = {}) {
67
84
  // stop reaping, then let startMcp close HTTP and drain the executor.
68
85
  scheduler.stop();
69
86
  reconciler.stop();
87
+ notifications.stop();
70
88
  await mcp.close();
71
89
  },
72
90
  };
@@ -192,6 +192,10 @@ export declare const GraphRunSchema: z.ZodObject<{
192
192
  model: z.ZodString;
193
193
  /** The coding worker (e.g. `codex`, `claude-code`); null for native runs. */
194
194
  codingProvider: z.ZodNullable<z.ZodString>;
195
+ /** Where a native run executed, snapshotted at start; null for coding runs and runs from before the field existed. */
196
+ nativeExecutionMode: z.ZodNullable<z.ZodEnum<["control-plane", "sandbox"]>>;
197
+ /** The warm pool worker (container or pod name) a sandbox run claimed, while its record lasts; null otherwise. */
198
+ warmWorkerName: z.ZodNullable<z.ZodString>;
195
199
  status: z.ZodEnum<["pending", "running", "succeeded", "failed", "refused", "lost", "budget_exhausted", "cancelled"]>;
196
200
  trigger: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
197
201
  kind: z.ZodLiteral<"manual">;
@@ -432,10 +436,12 @@ export declare const GraphRunSchema: z.ZodObject<{
432
436
  finishedAt: string | null;
433
437
  heartbeatAt: string | null;
434
438
  turns: number;
439
+ nativeExecutionMode: "sandbox" | "control-plane" | null;
435
440
  parentRunId: string | null;
436
- agentKind: "native" | "coding";
437
441
  agentName: string;
442
+ agentKind: "native" | "coding";
438
443
  codingProvider: string | null;
444
+ warmWorkerName: string | null;
439
445
  outcomes: ({
440
446
  number: number;
441
447
  at: string | null;
@@ -513,10 +519,12 @@ export declare const GraphRunSchema: z.ZodObject<{
513
519
  finishedAt: string | null;
514
520
  heartbeatAt: string | null;
515
521
  turns: number;
522
+ nativeExecutionMode: "sandbox" | "control-plane" | null;
516
523
  parentRunId: string | null;
517
- agentKind: "native" | "coding";
518
524
  agentName: string;
525
+ agentKind: "native" | "coding";
519
526
  codingProvider: string | null;
527
+ warmWorkerName: string | null;
520
528
  outcomes: ({
521
529
  number: number;
522
530
  at: string | null;
@@ -581,6 +589,10 @@ export declare const GraphSnapshotSchema: z.ZodObject<{
581
589
  model: z.ZodString;
582
590
  /** The coding worker (e.g. `codex`, `claude-code`); null for native runs. */
583
591
  codingProvider: z.ZodNullable<z.ZodString>;
592
+ /** Where a native run executed, snapshotted at start; null for coding runs and runs from before the field existed. */
593
+ nativeExecutionMode: z.ZodNullable<z.ZodEnum<["control-plane", "sandbox"]>>;
594
+ /** The warm pool worker (container or pod name) a sandbox run claimed, while its record lasts; null otherwise. */
595
+ warmWorkerName: z.ZodNullable<z.ZodString>;
584
596
  status: z.ZodEnum<["pending", "running", "succeeded", "failed", "refused", "lost", "budget_exhausted", "cancelled"]>;
585
597
  trigger: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
586
598
  kind: z.ZodLiteral<"manual">;
@@ -821,10 +833,12 @@ export declare const GraphSnapshotSchema: z.ZodObject<{
821
833
  finishedAt: string | null;
822
834
  heartbeatAt: string | null;
823
835
  turns: number;
836
+ nativeExecutionMode: "sandbox" | "control-plane" | null;
824
837
  parentRunId: string | null;
825
- agentKind: "native" | "coding";
826
838
  agentName: string;
839
+ agentKind: "native" | "coding";
827
840
  codingProvider: string | null;
841
+ warmWorkerName: string | null;
828
842
  outcomes: ({
829
843
  number: number;
830
844
  at: string | null;
@@ -902,10 +916,12 @@ export declare const GraphSnapshotSchema: z.ZodObject<{
902
916
  finishedAt: string | null;
903
917
  heartbeatAt: string | null;
904
918
  turns: number;
919
+ nativeExecutionMode: "sandbox" | "control-plane" | null;
905
920
  parentRunId: string | null;
906
- agentKind: "native" | "coding";
907
921
  agentName: string;
922
+ agentKind: "native" | "coding";
908
923
  codingProvider: string | null;
924
+ warmWorkerName: string | null;
909
925
  outcomes: ({
910
926
  number: number;
911
927
  at: string | null;
@@ -1020,10 +1036,12 @@ export declare const GraphSnapshotSchema: z.ZodObject<{
1020
1036
  finishedAt: string | null;
1021
1037
  heartbeatAt: string | null;
1022
1038
  turns: number;
1039
+ nativeExecutionMode: "sandbox" | "control-plane" | null;
1023
1040
  parentRunId: string | null;
1024
- agentKind: "native" | "coding";
1025
1041
  agentName: string;
1042
+ agentKind: "native" | "coding";
1026
1043
  codingProvider: string | null;
1044
+ warmWorkerName: string | null;
1027
1045
  outcomes: ({
1028
1046
  number: number;
1029
1047
  at: string | null;
@@ -1116,10 +1134,12 @@ export declare const GraphSnapshotSchema: z.ZodObject<{
1116
1134
  finishedAt: string | null;
1117
1135
  heartbeatAt: string | null;
1118
1136
  turns: number;
1137
+ nativeExecutionMode: "sandbox" | "control-plane" | null;
1119
1138
  parentRunId: string | null;
1120
- agentKind: "native" | "coding";
1121
1139
  agentName: string;
1140
+ agentKind: "native" | "coding";
1122
1141
  codingProvider: string | null;
1142
+ warmWorkerName: string | null;
1123
1143
  outcomes: ({
1124
1144
  number: number;
1125
1145
  at: string | null;
@@ -1177,6 +1197,10 @@ export declare const RunDetailSchema: z.ZodObject<{
1177
1197
  model: z.ZodString;
1178
1198
  /** The coding worker (e.g. `codex`, `claude-code`); null for native runs. */
1179
1199
  codingProvider: z.ZodNullable<z.ZodString>;
1200
+ /** Where a native run executed, snapshotted at start; null for coding runs and runs from before the field existed. */
1201
+ nativeExecutionMode: z.ZodNullable<z.ZodEnum<["control-plane", "sandbox"]>>;
1202
+ /** The warm pool worker (container or pod name) a sandbox run claimed, while its record lasts; null otherwise. */
1203
+ warmWorkerName: z.ZodNullable<z.ZodString>;
1180
1204
  status: z.ZodEnum<["pending", "running", "succeeded", "failed", "refused", "lost", "budget_exhausted", "cancelled"]>;
1181
1205
  trigger: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
1182
1206
  kind: z.ZodLiteral<"manual">;
@@ -1473,6 +1497,7 @@ export declare const RunDetailSchema: z.ZodObject<{
1473
1497
  heartbeatAt: string | null;
1474
1498
  finalText: string | null;
1475
1499
  turns: number;
1500
+ nativeExecutionMode: "sandbox" | "control-plane" | null;
1476
1501
  parentRunId: string | null;
1477
1502
  coding: {
1478
1503
  repository: string;
@@ -1488,9 +1513,10 @@ export declare const RunDetailSchema: z.ZodObject<{
1488
1513
  failureCategory: string | null;
1489
1514
  queuedAt: string | null;
1490
1515
  } | null;
1491
- agentKind: "native" | "coding";
1492
1516
  agentName: string;
1517
+ agentKind: "native" | "coding";
1493
1518
  codingProvider: string | null;
1519
+ warmWorkerName: string | null;
1494
1520
  outcomes: ({
1495
1521
  number: number;
1496
1522
  at: string | null;
@@ -1571,6 +1597,7 @@ export declare const RunDetailSchema: z.ZodObject<{
1571
1597
  heartbeatAt: string | null;
1572
1598
  finalText: string | null;
1573
1599
  turns: number;
1600
+ nativeExecutionMode: "sandbox" | "control-plane" | null;
1574
1601
  parentRunId: string | null;
1575
1602
  coding: {
1576
1603
  repository: string;
@@ -1586,9 +1613,10 @@ export declare const RunDetailSchema: z.ZodObject<{
1586
1613
  failureCategory: string | null;
1587
1614
  queuedAt: string | null;
1588
1615
  } | null;
1589
- agentKind: "native" | "coding";
1590
1616
  agentName: string;
1617
+ agentKind: "native" | "coding";
1591
1618
  codingProvider: string | null;
1619
+ warmWorkerName: string | null;
1592
1620
  outcomes: ({
1593
1621
  number: number;
1594
1622
  at: string | null;
@@ -1726,6 +1754,56 @@ export declare const InfraInfoSchema: z.ZodObject<{
1726
1754
  componentLabel: Record<string, string>;
1727
1755
  managedByLabel: Record<string, string>;
1728
1756
  }>>;
1757
+ /** How sandbox-mode native agents run; null when NATIVE_SANDBOX_LAUNCHER is unset. */
1758
+ native: z.ZodNullable<z.ZodObject<{
1759
+ launcher: z.ZodEnum<["docker", "kubernetes"]>;
1760
+ /** Idle workers kept ready for runs to claim (0 = no pool). */
1761
+ warmPoolSize: z.ZodNumber;
1762
+ kubernetes: z.ZodNullable<z.ZodObject<{
1763
+ namespace: z.ZodString;
1764
+ runtimeClass: z.ZodNullable<z.ZodString>;
1765
+ runLabel: z.ZodString;
1766
+ componentLabel: z.ZodRecord<z.ZodString, z.ZodString>;
1767
+ warmPoolLabel: z.ZodRecord<z.ZodString, z.ZodString>;
1768
+ warmWorkerLabel: z.ZodString;
1769
+ }, "strip", z.ZodTypeAny, {
1770
+ namespace: string;
1771
+ runtimeClass: string | null;
1772
+ runLabel: string;
1773
+ componentLabel: Record<string, string>;
1774
+ warmPoolLabel: Record<string, string>;
1775
+ warmWorkerLabel: string;
1776
+ }, {
1777
+ namespace: string;
1778
+ runtimeClass: string | null;
1779
+ runLabel: string;
1780
+ componentLabel: Record<string, string>;
1781
+ warmPoolLabel: Record<string, string>;
1782
+ warmWorkerLabel: string;
1783
+ }>>;
1784
+ }, "strip", z.ZodTypeAny, {
1785
+ kubernetes: {
1786
+ namespace: string;
1787
+ runtimeClass: string | null;
1788
+ runLabel: string;
1789
+ componentLabel: Record<string, string>;
1790
+ warmPoolLabel: Record<string, string>;
1791
+ warmWorkerLabel: string;
1792
+ } | null;
1793
+ launcher: "docker" | "kubernetes";
1794
+ warmPoolSize: number;
1795
+ }, {
1796
+ kubernetes: {
1797
+ namespace: string;
1798
+ runtimeClass: string | null;
1799
+ runLabel: string;
1800
+ componentLabel: Record<string, string>;
1801
+ warmPoolLabel: Record<string, string>;
1802
+ warmWorkerLabel: string;
1803
+ } | null;
1804
+ launcher: "docker" | "kubernetes";
1805
+ warmPoolSize: number;
1806
+ }>>;
1729
1807
  }, "strip", z.ZodTypeAny, {
1730
1808
  kubernetes: {
1731
1809
  namespace: string;
@@ -1737,6 +1815,18 @@ export declare const InfraInfoSchema: z.ZodObject<{
1737
1815
  componentLabel: Record<string, string>;
1738
1816
  managedByLabel: Record<string, string>;
1739
1817
  } | null;
1818
+ native: {
1819
+ kubernetes: {
1820
+ namespace: string;
1821
+ runtimeClass: string | null;
1822
+ runLabel: string;
1823
+ componentLabel: Record<string, string>;
1824
+ warmPoolLabel: Record<string, string>;
1825
+ warmWorkerLabel: string;
1826
+ } | null;
1827
+ launcher: "docker" | "kubernetes";
1828
+ warmPoolSize: number;
1829
+ } | null;
1740
1830
  launcher: "local" | "docker" | "kubernetes";
1741
1831
  }, {
1742
1832
  kubernetes: {
@@ -1749,6 +1839,18 @@ export declare const InfraInfoSchema: z.ZodObject<{
1749
1839
  componentLabel: Record<string, string>;
1750
1840
  managedByLabel: Record<string, string>;
1751
1841
  } | null;
1842
+ native: {
1843
+ kubernetes: {
1844
+ namespace: string;
1845
+ runtimeClass: string | null;
1846
+ runLabel: string;
1847
+ componentLabel: Record<string, string>;
1848
+ warmPoolLabel: Record<string, string>;
1849
+ warmWorkerLabel: string;
1850
+ } | null;
1851
+ launcher: "docker" | "kubernetes";
1852
+ warmPoolSize: number;
1853
+ } | null;
1752
1854
  launcher: "local" | "docker" | "kubernetes";
1753
1855
  }>;
1754
1856
  export type InfraInfo = z.infer<typeof InfraInfoSchema>;
@@ -1768,6 +1870,10 @@ export declare const VIEWER_SCHEMAS: {
1768
1870
  model: z.ZodString;
1769
1871
  /** The coding worker (e.g. `codex`, `claude-code`); null for native runs. */
1770
1872
  codingProvider: z.ZodNullable<z.ZodString>;
1873
+ /** Where a native run executed, snapshotted at start; null for coding runs and runs from before the field existed. */
1874
+ nativeExecutionMode: z.ZodNullable<z.ZodEnum<["control-plane", "sandbox"]>>;
1875
+ /** The warm pool worker (container or pod name) a sandbox run claimed, while its record lasts; null otherwise. */
1876
+ warmWorkerName: z.ZodNullable<z.ZodString>;
1771
1877
  status: z.ZodEnum<["pending", "running", "succeeded", "failed", "refused", "lost", "budget_exhausted", "cancelled"]>;
1772
1878
  trigger: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
1773
1879
  kind: z.ZodLiteral<"manual">;
@@ -2008,10 +2114,12 @@ export declare const VIEWER_SCHEMAS: {
2008
2114
  finishedAt: string | null;
2009
2115
  heartbeatAt: string | null;
2010
2116
  turns: number;
2117
+ nativeExecutionMode: "sandbox" | "control-plane" | null;
2011
2118
  parentRunId: string | null;
2012
- agentKind: "native" | "coding";
2013
2119
  agentName: string;
2120
+ agentKind: "native" | "coding";
2014
2121
  codingProvider: string | null;
2122
+ warmWorkerName: string | null;
2015
2123
  outcomes: ({
2016
2124
  number: number;
2017
2125
  at: string | null;
@@ -2089,10 +2197,12 @@ export declare const VIEWER_SCHEMAS: {
2089
2197
  finishedAt: string | null;
2090
2198
  heartbeatAt: string | null;
2091
2199
  turns: number;
2200
+ nativeExecutionMode: "sandbox" | "control-plane" | null;
2092
2201
  parentRunId: string | null;
2093
- agentKind: "native" | "coding";
2094
2202
  agentName: string;
2203
+ agentKind: "native" | "coding";
2095
2204
  codingProvider: string | null;
2205
+ warmWorkerName: string | null;
2096
2206
  outcomes: ({
2097
2207
  number: number;
2098
2208
  at: string | null;
@@ -2207,10 +2317,12 @@ export declare const VIEWER_SCHEMAS: {
2207
2317
  finishedAt: string | null;
2208
2318
  heartbeatAt: string | null;
2209
2319
  turns: number;
2320
+ nativeExecutionMode: "sandbox" | "control-plane" | null;
2210
2321
  parentRunId: string | null;
2211
- agentKind: "native" | "coding";
2212
2322
  agentName: string;
2323
+ agentKind: "native" | "coding";
2213
2324
  codingProvider: string | null;
2325
+ warmWorkerName: string | null;
2214
2326
  outcomes: ({
2215
2327
  number: number;
2216
2328
  at: string | null;
@@ -2303,10 +2415,12 @@ export declare const VIEWER_SCHEMAS: {
2303
2415
  finishedAt: string | null;
2304
2416
  heartbeatAt: string | null;
2305
2417
  turns: number;
2418
+ nativeExecutionMode: "sandbox" | "control-plane" | null;
2306
2419
  parentRunId: string | null;
2307
- agentKind: "native" | "coding";
2308
2420
  agentName: string;
2421
+ agentKind: "native" | "coding";
2309
2422
  codingProvider: string | null;
2423
+ warmWorkerName: string | null;
2310
2424
  outcomes: ({
2311
2425
  number: number;
2312
2426
  at: string | null;
@@ -2364,6 +2478,10 @@ export declare const VIEWER_SCHEMAS: {
2364
2478
  model: z.ZodString;
2365
2479
  /** The coding worker (e.g. `codex`, `claude-code`); null for native runs. */
2366
2480
  codingProvider: z.ZodNullable<z.ZodString>;
2481
+ /** Where a native run executed, snapshotted at start; null for coding runs and runs from before the field existed. */
2482
+ nativeExecutionMode: z.ZodNullable<z.ZodEnum<["control-plane", "sandbox"]>>;
2483
+ /** The warm pool worker (container or pod name) a sandbox run claimed, while its record lasts; null otherwise. */
2484
+ warmWorkerName: z.ZodNullable<z.ZodString>;
2367
2485
  status: z.ZodEnum<["pending", "running", "succeeded", "failed", "refused", "lost", "budget_exhausted", "cancelled"]>;
2368
2486
  trigger: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
2369
2487
  kind: z.ZodLiteral<"manual">;
@@ -2660,6 +2778,7 @@ export declare const VIEWER_SCHEMAS: {
2660
2778
  heartbeatAt: string | null;
2661
2779
  finalText: string | null;
2662
2780
  turns: number;
2781
+ nativeExecutionMode: "sandbox" | "control-plane" | null;
2663
2782
  parentRunId: string | null;
2664
2783
  coding: {
2665
2784
  repository: string;
@@ -2675,9 +2794,10 @@ export declare const VIEWER_SCHEMAS: {
2675
2794
  failureCategory: string | null;
2676
2795
  queuedAt: string | null;
2677
2796
  } | null;
2678
- agentKind: "native" | "coding";
2679
2797
  agentName: string;
2798
+ agentKind: "native" | "coding";
2680
2799
  codingProvider: string | null;
2800
+ warmWorkerName: string | null;
2681
2801
  outcomes: ({
2682
2802
  number: number;
2683
2803
  at: string | null;
@@ -2758,6 +2878,7 @@ export declare const VIEWER_SCHEMAS: {
2758
2878
  heartbeatAt: string | null;
2759
2879
  finalText: string | null;
2760
2880
  turns: number;
2881
+ nativeExecutionMode: "sandbox" | "control-plane" | null;
2761
2882
  parentRunId: string | null;
2762
2883
  coding: {
2763
2884
  repository: string;
@@ -2773,9 +2894,10 @@ export declare const VIEWER_SCHEMAS: {
2773
2894
  failureCategory: string | null;
2774
2895
  queuedAt: string | null;
2775
2896
  } | null;
2776
- agentKind: "native" | "coding";
2777
2897
  agentName: string;
2898
+ agentKind: "native" | "coding";
2778
2899
  codingProvider: string | null;
2900
+ warmWorkerName: string | null;
2779
2901
  outcomes: ({
2780
2902
  number: number;
2781
2903
  at: string | null;
@@ -2905,6 +3027,56 @@ export declare const VIEWER_SCHEMAS: {
2905
3027
  componentLabel: Record<string, string>;
2906
3028
  managedByLabel: Record<string, string>;
2907
3029
  }>>;
3030
+ /** How sandbox-mode native agents run; null when NATIVE_SANDBOX_LAUNCHER is unset. */
3031
+ native: z.ZodNullable<z.ZodObject<{
3032
+ launcher: z.ZodEnum<["docker", "kubernetes"]>;
3033
+ /** Idle workers kept ready for runs to claim (0 = no pool). */
3034
+ warmPoolSize: z.ZodNumber;
3035
+ kubernetes: z.ZodNullable<z.ZodObject<{
3036
+ namespace: z.ZodString;
3037
+ runtimeClass: z.ZodNullable<z.ZodString>;
3038
+ runLabel: z.ZodString;
3039
+ componentLabel: z.ZodRecord<z.ZodString, z.ZodString>;
3040
+ warmPoolLabel: z.ZodRecord<z.ZodString, z.ZodString>;
3041
+ warmWorkerLabel: z.ZodString;
3042
+ }, "strip", z.ZodTypeAny, {
3043
+ namespace: string;
3044
+ runtimeClass: string | null;
3045
+ runLabel: string;
3046
+ componentLabel: Record<string, string>;
3047
+ warmPoolLabel: Record<string, string>;
3048
+ warmWorkerLabel: string;
3049
+ }, {
3050
+ namespace: string;
3051
+ runtimeClass: string | null;
3052
+ runLabel: string;
3053
+ componentLabel: Record<string, string>;
3054
+ warmPoolLabel: Record<string, string>;
3055
+ warmWorkerLabel: string;
3056
+ }>>;
3057
+ }, "strip", z.ZodTypeAny, {
3058
+ kubernetes: {
3059
+ namespace: string;
3060
+ runtimeClass: string | null;
3061
+ runLabel: string;
3062
+ componentLabel: Record<string, string>;
3063
+ warmPoolLabel: Record<string, string>;
3064
+ warmWorkerLabel: string;
3065
+ } | null;
3066
+ launcher: "docker" | "kubernetes";
3067
+ warmPoolSize: number;
3068
+ }, {
3069
+ kubernetes: {
3070
+ namespace: string;
3071
+ runtimeClass: string | null;
3072
+ runLabel: string;
3073
+ componentLabel: Record<string, string>;
3074
+ warmPoolLabel: Record<string, string>;
3075
+ warmWorkerLabel: string;
3076
+ } | null;
3077
+ launcher: "docker" | "kubernetes";
3078
+ warmPoolSize: number;
3079
+ }>>;
2908
3080
  }, "strip", z.ZodTypeAny, {
2909
3081
  kubernetes: {
2910
3082
  namespace: string;
@@ -2916,6 +3088,18 @@ export declare const VIEWER_SCHEMAS: {
2916
3088
  componentLabel: Record<string, string>;
2917
3089
  managedByLabel: Record<string, string>;
2918
3090
  } | null;
3091
+ native: {
3092
+ kubernetes: {
3093
+ namespace: string;
3094
+ runtimeClass: string | null;
3095
+ runLabel: string;
3096
+ componentLabel: Record<string, string>;
3097
+ warmPoolLabel: Record<string, string>;
3098
+ warmWorkerLabel: string;
3099
+ } | null;
3100
+ launcher: "docker" | "kubernetes";
3101
+ warmPoolSize: number;
3102
+ } | null;
2919
3103
  launcher: "local" | "docker" | "kubernetes";
2920
3104
  }, {
2921
3105
  kubernetes: {
@@ -2928,6 +3112,18 @@ export declare const VIEWER_SCHEMAS: {
2928
3112
  componentLabel: Record<string, string>;
2929
3113
  managedByLabel: Record<string, string>;
2930
3114
  } | null;
3115
+ native: {
3116
+ kubernetes: {
3117
+ namespace: string;
3118
+ runtimeClass: string | null;
3119
+ runLabel: string;
3120
+ componentLabel: Record<string, string>;
3121
+ warmPoolLabel: Record<string, string>;
3122
+ warmWorkerLabel: string;
3123
+ } | null;
3124
+ launcher: "docker" | "kubernetes";
3125
+ warmPoolSize: number;
3126
+ } | null;
2931
3127
  launcher: "local" | "docker" | "kubernetes";
2932
3128
  }>;
2933
3129
  };
@@ -88,6 +88,10 @@ export const GraphRunSchema = z.object({
88
88
  model: z.string(),
89
89
  /** The coding worker (e.g. `codex`, `claude-code`); null for native runs. */
90
90
  codingProvider: z.string().nullable(),
91
+ /** Where a native run executed, snapshotted at start; null for coding runs and runs from before the field existed. */
92
+ nativeExecutionMode: z.enum(["control-plane", "sandbox"]).nullable(),
93
+ /** The warm pool worker (container or pod name) a sandbox run claimed, while its record lasts; null otherwise. */
94
+ warmWorkerName: z.string().nullable(),
91
95
  status: RunStatusSchema,
92
96
  trigger: RunTriggerSchema,
93
97
  turns: z.number().int(),
@@ -181,6 +185,24 @@ export const InfraInfoSchema = z.object({
181
185
  managedByLabel: z.record(z.string(), z.string()),
182
186
  })
183
187
  .nullable(),
188
+ /** How sandbox-mode native agents run; null when NATIVE_SANDBOX_LAUNCHER is unset. */
189
+ native: z
190
+ .object({
191
+ launcher: z.enum(["docker", "kubernetes"]),
192
+ /** Idle workers kept ready for runs to claim (0 = no pool). */
193
+ warmPoolSize: z.number().int(),
194
+ kubernetes: z
195
+ .object({
196
+ namespace: z.string(),
197
+ runtimeClass: z.string().nullable(),
198
+ runLabel: z.string(),
199
+ componentLabel: z.record(z.string(), z.string()),
200
+ warmPoolLabel: z.record(z.string(), z.string()),
201
+ warmWorkerLabel: z.string(),
202
+ })
203
+ .nullable(),
204
+ })
205
+ .nullable(),
184
206
  });
185
207
  export const VIEWER_SCHEMAS = {
186
208
  "graph-snapshot": GraphSnapshotSchema,
@@ -1,9 +1,10 @@
1
1
  /** Writes src/viewer/schemas/<name>.schema.json from VIEWER_SCHEMAS (npm run build:viewer-schemas). */
2
- import { mkdir, writeFile } from "node:fs/promises";
2
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
3
3
  import { dirname, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { zodToJsonSchema } from "zod-to-json-schema";
6
6
  import { VIEWER_SCHEMAS } from "./api-schema.js";
7
+ import { OPENAPI_PATH, renderViewerOpenApi } from "./openapi.js";
7
8
  export const SCHEMA_DIR = join(dirname(fileURLToPath(import.meta.url)), "schemas");
8
9
  export function renderSchemas() {
9
10
  return Object.fromEntries(Object.entries(VIEWER_SCHEMAS).map(([name, schema]) => [
@@ -15,4 +16,6 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
15
16
  await mkdir(SCHEMA_DIR, { recursive: true });
16
17
  for (const [file, text] of Object.entries(renderSchemas()))
17
18
  await writeFile(join(SCHEMA_DIR, file), text);
19
+ const pkg = JSON.parse(await readFile(new URL("../../package.json", import.meta.url), "utf8"));
20
+ await writeFile(OPENAPI_PATH, renderViewerOpenApi(pkg.version));
18
21
  }
@@ -14,6 +14,7 @@
14
14
  * layer can tell its clients to refetch whatever they may have missed.
15
15
  */
16
16
  import pg from "pg";
17
+ import { type DatabaseAuth, type PgAuthOptions } from "../core/pg-auth.js";
17
18
  import { type ViewerEvent } from "./api-schema.js";
18
19
  export declare const VIEWER_CHANNEL = "wardby_viewer";
19
20
  export interface ViewerEventBus {
@@ -29,8 +30,13 @@ export interface ViewerEventBus {
29
30
  onState(listener: (live: boolean) => void): () => void;
30
31
  close(): Promise<void>;
31
32
  }
33
+ /** The LISTEN client's config: auth (pg-auth.ts) plus keepAlive and the pool's connect timeout. */
34
+ export declare function eventBusClientConfig(connectionString: string, auth: DatabaseAuth, pgAuth?: PgAuthOptions): pg.ClientConfig;
32
35
  export declare function createViewerEventBus(options: {
33
36
  connectionString: string;
37
+ /** Defaults to DATABASE_AUTH. */
38
+ auth?: DatabaseAuth;
39
+ pgAuth?: PgAuthOptions;
34
40
  connect?: (connectionString: string) => pg.Client;
35
41
  reconnectDelaysMs?: readonly number[];
36
42
  healthCheckIntervalMs?: number;
@@ -16,6 +16,7 @@
16
16
  import pg from "pg";
17
17
  import { poolSettings } from "../core/db.js";
18
18
  import { logger } from "../core/logger.js";
19
+ import { databaseAuthFromEnv, pgConnectionConfig } from "../core/pg-auth.js";
19
20
  import { ViewerEventSchema } from "./api-schema.js";
20
21
  export const VIEWER_CHANNEL = "wardby_viewer";
21
22
  const DEFAULT_RECONNECT_DELAYS_MS = [500, 1000, 2000, 5000, 10_000];
@@ -25,17 +26,25 @@ const DEFAULT_HEALTH_CHECK_INTERVAL_MS = 60_000;
25
26
  const DEFAULT_HEALTH_CHECK_TIMEOUT_MS = 10_000;
26
27
  /** Upper bound on waiting for a graceful disconnect (a half-open socket never answers). */
27
28
  const END_TIMEOUT_MS = 2_000;
29
+ /** The LISTEN client's config: auth (pg-auth.ts) plus keepAlive and the pool's connect timeout. */
30
+ export function eventBusClientConfig(connectionString, auth, pgAuth) {
31
+ return {
32
+ ...pgConnectionConfig(connectionString, auth, pgAuth),
33
+ keepAlive: true,
34
+ keepAliveInitialDelayMillis: KEEPALIVE_INITIAL_DELAY_MS,
35
+ connectionTimeoutMillis: poolSettings(connectionString).connectionTimeoutMillis,
36
+ };
37
+ }
28
38
  export function createViewerEventBus(options) {
29
39
  const healthIntervalMs = options.healthCheckIntervalMs ?? DEFAULT_HEALTH_CHECK_INTERVAL_MS;
30
40
  const healthTimeoutMs = options.healthCheckTimeoutMs ?? DEFAULT_HEALTH_CHECK_TIMEOUT_MS;
31
41
  const delays = options.reconnectDelaysMs?.length ? options.reconnectDelaysMs : DEFAULT_RECONNECT_DELAYS_MS;
32
- const makeClient = options.connect ??
33
- ((connectionString) => new pg.Client({
34
- connectionString,
35
- keepAlive: true,
36
- keepAliveInitialDelayMillis: KEEPALIVE_INITIAL_DELAY_MS,
37
- connectionTimeoutMillis: poolSettings(connectionString).connectionTimeoutMillis,
38
- }));
42
+ // Built once, up front: a misconfigured DATABASE_AUTH fails here rather than on every reconnect,
43
+ // and under rds-iam every reconnect shares one token cache.
44
+ const clientConfig = options.connect
45
+ ? undefined
46
+ : eventBusClientConfig(options.connectionString, options.auth ?? databaseAuthFromEnv(), options.pgAuth);
47
+ const makeClient = options.connect ?? (() => new pg.Client({ ...clientConfig }));
39
48
  const listeners = new Set();
40
49
  const stateListeners = new Set();
41
50
  let client = null; // the current attempt/connection