@wardby/cli 0.7.0 → 0.9.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 (367) hide show
  1. package/.env.example +5 -5
  2. package/README.md +6 -1
  3. package/deploy/local/docker-compose.quickstart-coding.yml +11 -0
  4. package/dist/claude-coding-worker/driver.d.ts +12 -0
  5. package/dist/claude-coding-worker/driver.js +29 -7
  6. package/dist/claude-coding-worker/main.js +5 -1
  7. package/dist/claude-coding-worker/sdk.js +17 -1
  8. package/dist/claude-plugin/command.d.ts +64 -0
  9. package/dist/claude-plugin/command.js +379 -0
  10. package/dist/cli-help.d.ts +1 -1
  11. package/dist/cli-help.js +2 -1
  12. package/dist/cli.js +71 -3
  13. package/dist/coding/code-host.d.ts +16 -0
  14. package/dist/coding/code-host.js +60 -0
  15. package/dist/coding/mcp-token.d.ts +12 -0
  16. package/dist/coding/mcp-token.js +26 -0
  17. package/dist/coding/protocol.js +2 -0
  18. package/dist/coding/redact.js +6 -1
  19. package/dist/coding/transcript/recorder.d.ts +5 -4
  20. package/dist/coding/transcript/recorder.js +3 -9
  21. package/dist/coding-worker/debug-trace.d.ts +3 -1
  22. package/dist/coding-worker/debug-trace.js +4 -2
  23. package/dist/coding-worker/driver.js +8 -1
  24. package/dist/coding-worker/main.js +5 -1
  25. package/dist/coding-worker/mcp-config.d.ts +27 -0
  26. package/dist/coding-worker/mcp-config.js +32 -0
  27. package/dist/coding-worker/sdk.d.ts +36 -0
  28. package/dist/coding-worker/sdk.js +28 -1
  29. package/dist/coding-worker/types.d.ts +4 -0
  30. package/dist/config/mcp-call-limit.d.ts +8 -0
  31. package/dist/config/mcp-call-limit.js +18 -0
  32. package/dist/config/mcp-servers.d.ts +8 -0
  33. package/dist/config/mcp-servers.js +12 -0
  34. package/dist/config/test-simulators.d.ts +10 -0
  35. package/dist/config/test-simulators.js +28 -0
  36. package/dist/config/tool-timeout.d.ts +1 -0
  37. package/dist/config/tool-timeout.js +18 -0
  38. package/dist/core/coding-mcp.d.ts +36 -0
  39. package/dist/core/coding-mcp.js +253 -0
  40. package/dist/core/coding-repository.d.ts +46 -0
  41. package/dist/core/coding-repository.js +92 -0
  42. package/dist/core/delegation-slots.d.ts +27 -0
  43. package/dist/core/delegation-slots.js +44 -0
  44. package/dist/core/dispatch.d.ts +6 -2
  45. package/dist/core/dispatch.js +39 -11
  46. package/dist/core/engine-native.d.ts +2 -0
  47. package/dist/core/engine-native.js +13 -0
  48. package/dist/core/error-code.js +2 -0
  49. package/dist/core/grants.d.ts +28 -3
  50. package/dist/core/grants.js +46 -4
  51. package/dist/core/host-events.js +7 -3
  52. package/dist/core/host-status.js +2 -2
  53. package/dist/core/issue-status.js +4 -3
  54. package/dist/core/listen-address.d.ts +10 -0
  55. package/dist/core/listen-address.js +14 -0
  56. package/dist/core/mark-ready.d.ts +1 -1
  57. package/dist/core/mark-ready.js +1 -1
  58. package/dist/core/mcp-client/client.d.ts +47 -0
  59. package/dist/core/mcp-client/client.js +141 -0
  60. package/dist/core/mcp-client/jsonrpc.d.ts +15 -0
  61. package/dist/core/mcp-client/jsonrpc.js +54 -0
  62. package/dist/core/mcp-client/results.d.ts +13 -0
  63. package/dist/core/mcp-client/results.js +42 -0
  64. package/dist/core/mcp-servers.d.ts +90 -0
  65. package/dist/core/mcp-servers.js +230 -0
  66. package/dist/core/mcp-tools.d.ts +108 -0
  67. package/dist/core/mcp-tools.js +287 -0
  68. package/dist/core/merge-order-check.js +38 -19
  69. package/dist/core/notification-dispatcher.js +2 -1
  70. package/dist/core/power-idle.d.ts +8 -2
  71. package/dist/core/power-idle.js +17 -3
  72. package/dist/core/power.d.ts +5 -0
  73. package/dist/core/power.js +5 -0
  74. package/dist/core/related-pull-requests.js +26 -10
  75. package/dist/core/retention-days.d.ts +5 -0
  76. package/dist/core/retention-days.js +14 -0
  77. package/dist/core/review-fix.js +2 -2
  78. package/dist/core/review-host-tools.js +3 -1
  79. package/dist/core/run-steps/config.d.ts +25 -0
  80. package/dist/core/run-steps/config.js +40 -0
  81. package/dist/core/run-steps/control-chars.d.ts +16 -0
  82. package/dist/core/run-steps/control-chars.js +26 -0
  83. package/dist/core/run-steps/detail.d.ts +32 -0
  84. package/dist/core/run-steps/detail.js +240 -0
  85. package/dist/core/run-steps/extract.d.ts +52 -0
  86. package/dist/core/run-steps/extract.js +467 -0
  87. package/dist/core/run-steps/ingress.d.ts +51 -0
  88. package/dist/core/run-steps/ingress.js +160 -0
  89. package/dist/core/run-steps/last-step.d.ts +15 -0
  90. package/dist/core/run-steps/last-step.js +35 -0
  91. package/dist/core/run-steps/native.d.ts +48 -0
  92. package/dist/core/run-steps/native.js +164 -0
  93. package/dist/core/run-steps/seen.d.ts +16 -0
  94. package/dist/core/run-steps/seen.js +35 -0
  95. package/dist/core/run-steps/summarize.d.ts +57 -0
  96. package/dist/core/run-steps/summarize.js +304 -0
  97. package/dist/core/run-steps/sweep.d.ts +21 -0
  98. package/dist/core/run-steps/sweep.js +41 -0
  99. package/dist/core/run-steps/types.d.ts +89 -0
  100. package/dist/core/run-steps/types.js +39 -0
  101. package/dist/core/run-steps/wire.d.ts +35 -0
  102. package/dist/core/run-steps/wire.js +47 -0
  103. package/dist/core/run-steps/writer.d.ts +49 -0
  104. package/dist/core/run-steps/writer.js +279 -0
  105. package/dist/core/runner.d.ts +70 -16
  106. package/dist/core/runner.js +296 -74
  107. package/dist/core/secret-broker-config.d.ts +2 -0
  108. package/dist/core/secret-broker-config.js +1 -1
  109. package/dist/core/secret-guard.d.ts +5 -2
  110. package/dist/core/secret-guard.js +22 -7
  111. package/dist/core/secrets.d.ts +11 -1
  112. package/dist/core/secrets.js +27 -1
  113. package/dist/core/serializable-retry.d.ts +18 -0
  114. package/dist/core/serializable-retry.js +43 -0
  115. package/dist/core/tool-admin.d.ts +5 -1
  116. package/dist/core/tool-admin.js +7 -2
  117. package/dist/core/tool-names.d.ts +13 -0
  118. package/dist/core/tool-names.js +20 -0
  119. package/dist/core/webhooks.d.ts +4 -0
  120. package/dist/core/webhooks.js +68 -49
  121. package/dist/core/workflow-run-events.js +2 -1
  122. package/dist/generated/prisma/browser.d.ts +39 -0
  123. package/dist/generated/prisma/client.d.ts +39 -0
  124. package/dist/generated/prisma/commonInputTypes.d.ts +80 -50
  125. package/dist/generated/prisma/enums.d.ts +6 -0
  126. package/dist/generated/prisma/enums.js +5 -0
  127. package/dist/generated/prisma/internal/class.d.ts +77 -0
  128. package/dist/generated/prisma/internal/class.js +4 -4
  129. package/dist/generated/prisma/internal/prismaNamespace.d.ts +632 -1
  130. package/dist/generated/prisma/internal/prismaNamespace.js +94 -3
  131. package/dist/generated/prisma/internal/prismaNamespaceBrowser.d.ts +98 -0
  132. package/dist/generated/prisma/internal/prismaNamespaceBrowser.js +94 -3
  133. package/dist/generated/prisma/models/Agent.d.ts +372 -1
  134. package/dist/generated/prisma/models/AgentMcpServer.d.ts +1412 -0
  135. package/dist/generated/prisma/models/AgentMcpServer.js +1 -0
  136. package/dist/generated/prisma/models/AgentRepository.d.ts +40 -1
  137. package/dist/generated/prisma/models/AuthUser.d.ts +1 -1
  138. package/dist/generated/prisma/models/CodingAgentProfile.d.ts +0 -7
  139. package/dist/generated/prisma/models/CodingProxySession.d.ts +159 -2
  140. package/dist/generated/prisma/models/CodingRun.d.ts +76 -1
  141. package/dist/generated/prisma/models/HostProvider.d.ts +2176 -0
  142. package/dist/generated/prisma/models/HostProvider.js +1 -0
  143. package/dist/generated/prisma/models/HostProviderCredential.d.ts +1285 -0
  144. package/dist/generated/prisma/models/HostProviderCredential.js +1 -0
  145. package/dist/generated/prisma/models/HostProviderOperation.d.ts +1470 -0
  146. package/dist/generated/prisma/models/HostProviderOperation.js +1 -0
  147. package/dist/generated/prisma/models/HostProviderTrustedAccount.d.ts +1145 -0
  148. package/dist/generated/prisma/models/HostProviderTrustedAccount.js +1 -0
  149. package/dist/generated/prisma/models/McpServer.d.ts +1500 -0
  150. package/dist/generated/prisma/models/McpServer.js +1 -0
  151. package/dist/generated/prisma/models/NativeGatewayCall.d.ts +39 -1
  152. package/dist/generated/prisma/models/Principal.d.ts +167 -0
  153. package/dist/generated/prisma/models/ResourceGrant.d.ts +1 -1
  154. package/dist/generated/prisma/models/Run.d.ts +503 -1
  155. package/dist/generated/prisma/models/RunStep.d.ts +1453 -0
  156. package/dist/generated/prisma/models/RunStep.js +1 -0
  157. package/dist/generated/prisma/models/Secret.d.ts +387 -0
  158. package/dist/generated/prisma/models/Tool.d.ts +223 -1
  159. package/dist/generated/prisma/models.d.ts +7 -0
  160. package/dist/help/search.js +12 -3
  161. package/dist/help-index.json +812 -52
  162. package/dist/import/create.js +16 -1
  163. package/dist/import/neutral-schema.d.ts +1 -0
  164. package/dist/import/neutral-schema.js +2 -0
  165. package/dist/mcp/auth/access.d.ts +1 -0
  166. package/dist/mcp/auth/grants-cli.d.ts +6 -4
  167. package/dist/mcp/auth/grants-cli.js +42 -3
  168. package/dist/mcp/auth/resource-server.d.ts +3 -1
  169. package/dist/mcp/auth/resource-server.js +17 -2
  170. package/dist/mcp/context.d.ts +6 -0
  171. package/dist/mcp/index.js +21 -0
  172. package/dist/mcp/tools/agents.js +135 -20
  173. package/dist/mcp/tools/grants.js +66 -28
  174. package/dist/mcp/tools/host-providers.d.ts +2 -0
  175. package/dist/mcp/tools/host-providers.js +215 -0
  176. package/dist/mcp/tools/mcp-servers.d.ts +26 -0
  177. package/dist/mcp/tools/mcp-servers.js +481 -0
  178. package/dist/mcp/tools/power.js +2 -2
  179. package/dist/mcp/tools/repositories.js +50 -10
  180. package/dist/mcp/tools/run-access.d.ts +7 -0
  181. package/dist/mcp/tools/run-access.js +14 -0
  182. package/dist/mcp/tools/run-steps.d.ts +16 -0
  183. package/dist/mcp/tools/run-steps.js +85 -0
  184. package/dist/mcp/tools/runs.js +186 -18
  185. package/dist/mcp/tools/secret-elicitation.d.ts +2 -0
  186. package/dist/mcp/tools/secret-elicitation.js +25 -2
  187. package/dist/mcp/tools/secrets.js +38 -4
  188. package/dist/mcp/tools/tools.d.ts +6 -4
  189. package/dist/mcp/tools/tools.js +40 -8
  190. package/dist/mcp/tools/trigger.js +28 -6
  191. package/dist/mcp/transport/http-limits.d.ts +2 -0
  192. package/dist/mcp/transport/http-limits.js +6 -2
  193. package/dist/mcp/webhooks/ingress.js +10 -0
  194. package/dist/native-worker/gateway-server.d.ts +18 -1
  195. package/dist/native-worker/gateway-server.js +38 -9
  196. package/dist/native-worker/gateway.d.ts +5 -0
  197. package/dist/native-worker/gateway.js +13 -1
  198. package/dist/native-worker/http-server.d.ts +6 -4
  199. package/dist/native-worker/http-server.js +53 -8
  200. package/dist/native-worker/ledger.d.ts +6 -2
  201. package/dist/native-worker/ledger.js +5 -4
  202. package/dist/native-worker/protocol.d.ts +1 -0
  203. package/dist/native-worker/protocol.js +4 -1
  204. package/dist/providers/coding-proxy/capability-hash.d.ts +2 -0
  205. package/dist/providers/coding-proxy/capability-hash.js +5 -0
  206. package/dist/providers/coding-proxy/mcp-route.d.ts +34 -0
  207. package/dist/providers/coding-proxy/mcp-route.js +166 -0
  208. package/dist/providers/coding-proxy/memory-ledger.d.ts +2 -0
  209. package/dist/providers/coding-proxy/memory-ledger.js +16 -0
  210. package/dist/providers/coding-proxy/prisma-ledger.d.ts +1 -0
  211. package/dist/providers/coding-proxy/prisma-ledger.js +36 -2
  212. package/dist/providers/coding-proxy/proxy.d.ts +33 -1
  213. package/dist/providers/coding-proxy/proxy.js +266 -75
  214. package/dist/providers/coding-proxy/run-step-forwarder.d.ts +42 -0
  215. package/dist/providers/coding-proxy/run-step-forwarder.js +206 -0
  216. package/dist/providers/coding-proxy/runtime.d.ts +13 -0
  217. package/dist/providers/coding-proxy/runtime.js +87 -4
  218. package/dist/providers/coding-proxy/server.d.ts +3 -0
  219. package/dist/providers/coding-proxy/server.js +10 -0
  220. package/dist/providers/coding-proxy/types.d.ts +18 -0
  221. package/dist/providers/engine/types.d.ts +26 -0
  222. package/dist/providers/executor/composition.js +5 -0
  223. package/dist/providers/executor/container.d.ts +47 -1
  224. package/dist/providers/executor/container.js +84 -8
  225. package/dist/providers/host-tools/invoke.d.ts +37 -0
  226. package/dist/providers/host-tools/invoke.js +117 -0
  227. package/dist/providers/host-tools/operations.d.ts +65 -0
  228. package/dist/providers/host-tools/operations.js +149 -0
  229. package/dist/providers/host-tools/registry.d.ts +79 -0
  230. package/dist/providers/host-tools/registry.js +362 -0
  231. package/dist/providers/host-tools/request-guard.d.ts +17 -0
  232. package/dist/providers/host-tools/request-guard.js +99 -0
  233. package/dist/providers/host-tools/self-test.d.ts +64 -0
  234. package/dist/providers/host-tools/self-test.js +142 -0
  235. package/dist/providers/jobs/docker-isolation.d.ts +2 -2
  236. package/dist/providers/jobs/docker-isolation.js +30 -8
  237. package/dist/providers/jobs/docker.d.ts +8 -0
  238. package/dist/providers/jobs/docker.js +33 -9
  239. package/dist/providers/jobs/kubernetes-isolation.d.ts +3 -1
  240. package/dist/providers/jobs/kubernetes-isolation.js +15 -2
  241. package/dist/providers/jobs/kubernetes.d.ts +13 -0
  242. package/dist/providers/jobs/kubernetes.js +28 -5
  243. package/dist/providers/jobs/types.d.ts +6 -0
  244. package/dist/providers/review-host/types.d.ts +6 -4
  245. package/dist/providers/review-host/types.js +1 -1
  246. package/dist/providers/vcs/git.d.ts +6 -2
  247. package/dist/providers/vcs/git.js +15 -4
  248. package/dist/providers/vcs/github.d.ts +2 -71
  249. package/dist/providers/vcs/github.js +8 -11
  250. package/dist/providers/vcs/index.d.ts +1 -1
  251. package/dist/providers/vcs/index.js +1 -1
  252. package/dist/providers/vcs/remote.d.ts +4 -0
  253. package/dist/providers/vcs/remote.js +7 -1
  254. package/dist/providers/vcs/routing.d.ts +12 -6
  255. package/dist/providers/vcs/routing.js +21 -6
  256. package/dist/providers/vcs/types.d.ts +71 -3
  257. package/dist/quickstart/index.d.ts +5 -0
  258. package/dist/quickstart/index.js +21 -0
  259. package/dist/quickstart-images.json +1 -1
  260. package/dist/sandbox/eval-core.d.ts +12 -2
  261. package/dist/sandbox/eval-core.js +20 -4
  262. package/dist/sandbox/host-functions.d.ts +4 -0
  263. package/dist/sandbox/host-functions.js +7 -2
  264. package/dist/sandbox/limits.d.ts +4 -1
  265. package/dist/sandbox/limits.js +4 -1
  266. package/dist/sandbox/run-in-sandbox.d.ts +6 -0
  267. package/dist/sandbox/run-in-sandbox.js +14 -2
  268. package/dist/sandbox/safe-fetch.d.ts +2 -0
  269. package/dist/sandbox/safe-fetch.js +1 -1
  270. package/dist/sandbox/secret-broker.d.ts +1 -0
  271. package/dist/sandbox/secret-broker.js +1 -1
  272. package/dist/sandbox/tool-timeout.d.ts +32 -0
  273. package/dist/sandbox/tool-timeout.js +52 -0
  274. package/dist/sandbox/user-tool.d.ts +8 -1
  275. package/dist/sandbox/user-tool.js +9 -3
  276. package/dist/serve.js +26 -18
  277. package/dist/viewer/api-schema.d.ts +66 -0
  278. package/dist/viewer/api-schema.js +31 -0
  279. package/dist/viewer/graph.js +2 -1
  280. package/dist/viewer/openapi.js +2 -1
  281. package/dist/viewer/run-detail.d.ts +2 -0
  282. package/dist/viewer/run-detail.js +26 -1
  283. package/dist/wardby-bin.js +5 -0
  284. package/docs/README.md +11 -1
  285. package/docs/agent-recipes.md +37 -4
  286. package/docs/architecture-runtime.md +1 -1
  287. package/docs/claude-code-plugin.md +208 -0
  288. package/docs/code-review-agents.md +6 -0
  289. package/docs/coding-agent-setup.md +94 -1
  290. package/docs/coding-worker-byo-images.md +4 -2
  291. package/docs/coding-worker-isolation.md +94 -7
  292. package/docs/debugging-agent-runs.md +354 -0
  293. package/docs/getting-started-gke.md +33 -11
  294. package/docs/getting-started-identity-provider.md +43 -37
  295. package/docs/getting-started.md +8 -0
  296. package/docs/host-providers.md +294 -0
  297. package/docs/mcp-servers.md +263 -0
  298. package/docs/native-sandbox.md +31 -9
  299. package/docs/security-deployment.md +161 -31
  300. package/docs/tool-secrets.md +3 -0
  301. package/docs/viewer-api.md +27 -12
  302. package/docs/viewer-api.openapi.yml +78 -2
  303. package/help/admin-viewer.md +5 -0
  304. package/help/agent-recipes.md +33 -2
  305. package/help/brokered-secrets.md +3 -0
  306. package/help/build-claude-code-image.md +1 -1
  307. package/help/claude-code-run-pane.md +63 -0
  308. package/help/deploy-gke.md +5 -0
  309. package/help/errors/coding-mcp-gateway-unavailable.md +46 -0
  310. package/help/errors/coding-mcp-pins-unavailable.md +35 -0
  311. package/help/errors/database-auth-invalid.md +1 -1
  312. package/help/errors/host-provider-error.md +40 -0
  313. package/help/errors/host-tool-failed.md +36 -0
  314. package/help/errors/mcp-call-limit.md +22 -0
  315. package/help/errors/mcp-call-timeout.md +22 -0
  316. package/help/errors/mcp-server-auth-failed.md +22 -0
  317. package/help/errors/mcp-server-credentials-unavailable.md +45 -0
  318. package/help/errors/mcp-server-error.md +28 -0
  319. package/help/errors/mcp-server-unreachable.md +22 -0
  320. package/help/errors/mcp-servers-off.md +21 -0
  321. package/help/errors/mcp-tool-not-allowed.md +26 -0
  322. package/help/errors/mcp-tool-removed.md +22 -0
  323. package/help/errors/mcp-unavailable.md +25 -0
  324. package/help/errors/native-sandbox-capacity.md +1 -1
  325. package/help/errors/native-sandbox-deadline-exceeded.md +1 -1
  326. package/help/errors/native-sandbox-docker-failed.md +1 -1
  327. package/help/errors/native-sandbox-gateway-error.md +1 -1
  328. package/help/errors/native-sandbox-gateway-unavailable.md +1 -1
  329. package/help/errors/native-sandbox-image-not-pinned.md +1 -1
  330. package/help/errors/native-sandbox-isolation-mismatch.md +1 -1
  331. package/help/errors/native-sandbox-network-unenforced.md +1 -1
  332. package/help/errors/native-sandbox-requires-catalog.md +1 -1
  333. package/help/errors/native-sandbox-unavailable.md +1 -1
  334. package/help/errors/native-sandbox-warm-delivery-failed.md +1 -1
  335. package/help/errors/native-sandbox-worker-exited.md +1 -1
  336. package/help/errors/native-sandbox-worker-lost.md +1 -1
  337. package/help/errors/native-sandbox-worker-unready.md +1 -1
  338. package/help/errors/repository-not-listed.md +36 -0
  339. package/help/errors/repository-required.md +36 -0
  340. package/help/errors/tool-timeout.md +38 -0
  341. package/help/host-providers.md +40 -0
  342. package/help/identity-and-access.md +4 -1
  343. package/help/low-power-mode.md +19 -8
  344. package/help/mcp-servers.md +73 -0
  345. package/help/mcp.md +9 -2
  346. package/help/native-capabilities.md +27 -1
  347. package/help/native-sandbox.md +1 -1
  348. package/help/operating-agents.md +16 -0
  349. package/help/related-pull-requests.md +7 -3
  350. package/help/repo-instructions-and-skills.md +3 -1
  351. package/help/resume-runs-locally.md +7 -0
  352. package/help/run-steps.md +140 -0
  353. package/help/stop-run.md +1 -1
  354. package/help/troubleshooting/coding-workers.md +9 -1
  355. package/help/troubleshooting/debugging-agent-runs.md +29 -0
  356. package/package.json +2 -1
  357. package/prisma/migrations/20261102000000_host_providers/migration.sql +56 -0
  358. package/prisma/migrations/20261104000000_coding_agent_repository_list/migration.sql +5 -0
  359. package/prisma/migrations/20261106000000_tool_timeout/migration.sql +4 -0
  360. package/prisma/migrations/20261107000000_mcp_servers/migration.sql +33 -0
  361. package/prisma/migrations/20261108000000_coding_mcp/migration.sql +5 -0
  362. package/prisma/migrations/20261109000000_task_run_index/migration.sql +3 -0
  363. package/prisma/migrations/20261110000000_run_steps/migration.sql +26 -0
  364. package/prisma/migrations/20261111000000_run_steps_viewer_notify/migration.sql +59 -0
  365. package/prisma/migrations/20261112000000_run_steps_detail/migration.sql +9 -0
  366. package/prisma/schema.prisma +211 -14
  367. package/scripts/git-askpass.sh +1 -1
@@ -0,0 +1,15 @@
1
+ /** Each run's newest step, for get_run and cross-agent list_runs (the runs pane's one-line "now"). */
2
+ import { type PrismaClient } from "#prisma";
3
+ export interface LastStep {
4
+ seq: number;
5
+ at: string;
6
+ kind: string;
7
+ tool: string | null;
8
+ summary: string;
9
+ status: string | null;
10
+ /** "Bash: npm test (exit 1)", "said: Running the tests." */
11
+ line: string;
12
+ }
13
+ export declare function stepLine(step: Pick<LastStep, "kind" | "tool" | "summary" | "status">): string;
14
+ /** One indexed DISTINCT ON query. Best effort: a failure lists the runs without it, never an error. */
15
+ export declare function loadLastSteps(db: Pick<PrismaClient, "$queryRaw">, runIds: readonly string[]): Promise<Map<string, LastStep>>;
@@ -0,0 +1,35 @@
1
+ /** Each run's newest step, for get_run and cross-agent list_runs (the runs pane's one-line "now"). */
2
+ import { Prisma } from "#prisma";
3
+ import { logger } from "../logger.js";
4
+ const lastStepLog = logger.child({ module: "run-steps" });
5
+ export function stepLine(step) {
6
+ const head = step.kind === "tool" ? `${step.tool ?? "tool"}: ${step.summary}` : `said: ${step.summary}`;
7
+ return step.status && step.status !== "ok" ? `${head} (${step.status})` : head;
8
+ }
9
+ /** One indexed DISTINCT ON query. Best effort: a failure lists the runs without it, never an error. */
10
+ export async function loadLastSteps(db, runIds) {
11
+ if (runIds.length === 0)
12
+ return new Map();
13
+ try {
14
+ const rows = await db.$queryRaw `
15
+ SELECT DISTINCT ON ("runId") "runId", "seq", "at", "kind", "tool", "summary", "status"
16
+ FROM "RunStep" WHERE "runId" IN (${Prisma.join([...runIds])})
17
+ ORDER BY "runId", "seq" DESC`;
18
+ return new Map(rows.map((row) => [
19
+ row.runId,
20
+ {
21
+ seq: row.seq,
22
+ at: row.at.toISOString(),
23
+ kind: row.kind,
24
+ tool: row.tool,
25
+ summary: row.summary,
26
+ status: row.status,
27
+ line: stepLine(row),
28
+ },
29
+ ]));
30
+ }
31
+ catch (err) {
32
+ lastStepLog.warn({ event: "run_steps_last_step_failed", errorName: err instanceof Error ? err.name : typeof err }, "could not read runs' last steps; listing them without");
33
+ return new Map();
34
+ }
35
+ }
@@ -0,0 +1,48 @@
1
+ import type { EngineTurnEvent } from "../../providers/engine/types.js";
2
+ import type { LlmMessage, LlmStreamEvent } from "../../providers/llm/types.js";
3
+ import { type ExtractedResult, type ExtractedStep, type RunStepBatch, type RunStepSink, type StepStatus } from "./types.js";
4
+ export declare function nativeToolStatus(content: string): StepStatus;
5
+ /** A native tool result's text for the detail level: the untrusted-output wrapper removed, its end only. */
6
+ export declare function nativeResultOutput(content: string): {
7
+ output: string;
8
+ outputCut: boolean;
9
+ };
10
+ export declare function nativeTurnSteps(turnKey: string, text: string, toolCalls: readonly {
11
+ id: string;
12
+ name: string;
13
+ argsJson: string;
14
+ }[]): ExtractedStep[];
15
+ export declare function nativeToolResults(toolCalls: readonly {
16
+ id: string;
17
+ }[], results: readonly string[]): ExtractedResult[];
18
+ /** The results a model request carries for the previous turn: the `tool` messages after the last assistant one. */
19
+ export declare function nativeRequestResults(messages: readonly LlmMessage[]): ExtractedResult[];
20
+ /** How long a gateway's stream end waits for its steps to be written; past it the write goes on alone. */
21
+ export declare const STREAM_STEPS_BOUND_MS = 2000;
22
+ /**
23
+ * Collects one model call's steps from its events. The said step's id is a hash of `callId` (the
24
+ * worker-chosen request id), so no worker text is stored as an id.
25
+ */
26
+ export declare class NativeStreamSteps {
27
+ private text;
28
+ private truncated;
29
+ private readonly calls;
30
+ private readonly key;
31
+ constructor(callId: string);
32
+ observe(event: LlmStreamEvent): void;
33
+ steps(): ExtractedStep[];
34
+ }
35
+ /**
36
+ * A native gateway's stream end: records the call's steps and the results its request carries for
37
+ * the previous turn, so the next call's results find these steps. Never throws, and waits at most
38
+ * `boundMs`: past it the stream ends and the write finishes in the background (the writer logs its
39
+ * own failures, name only).
40
+ */
41
+ export declare function recordStreamSteps(sink: RunStepSink | undefined, runId: string, tap: Pick<NativeStreamSteps, "steps"> | undefined, messages: readonly LlmMessage[], extraSecretValues?: readonly string[], boundMs?: number): Promise<void>;
42
+ /** One engine turn event's batch: a turn's said and tool steps, or its tool calls' results. */
43
+ export declare function nativeTurnBatch(event: EngineTurnEvent): RunStepBatch;
44
+ /**
45
+ * The engine's `onTurn` for a run: hands each non-empty batch to the writer and does not wait for
46
+ * it. A throw here reaches the engine, which logs it by name and goes on.
47
+ */
48
+ export declare function runStepsHook(sink: RunStepSink | undefined, runId: string): ((event: EngineTurnEvent) => void) | undefined;
@@ -0,0 +1,164 @@
1
+ /**
2
+ * Steps of native runs. The in-process engine knows each call's result; the native gateways see
3
+ * the model's events and, in the next request, the trailing `role: "tool"` messages. A tool
4
+ * result's content is kept only as a bounded tail for the writer, which stores it only for a run
5
+ * at the detail level, redacted. Its status is whether it starts as the runner's JSON error.
6
+ */
7
+ import { createHash } from "node:crypto";
8
+ import { logger } from "../logger.js";
9
+ import { UNTRUSTED_TOOL_OUTPUT_TAG } from "../untrusted-content.js";
10
+ import { bounded, displayToolName, toolStepText } from "./summarize.js";
11
+ import { MAX_STEP_TEXT_CHARS, tailOf, } from "./types.js";
12
+ const stepsLog = logger.child({ module: "run-steps" });
13
+ const UNTRUSTED_OPEN = `<${UNTRUSTED_TOOL_OUTPUT_TAG}>\n`;
14
+ const UNTRUSTED_CLOSE = `\n</${UNTRUSTED_TOOL_OUTPUT_TAG}>`;
15
+ /** runSandboxTool's failure shape: `{"error": ...}` (src/providers/engine/types.ts). */
16
+ const ERROR_RESULT = /^\s*\{\s*"error"\s*:/;
17
+ export function nativeToolStatus(content) {
18
+ const raw = content.startsWith(UNTRUSTED_OPEN) ? content.slice(UNTRUSTED_OPEN.length) : content;
19
+ return ERROR_RESULT.test(raw.slice(0, 64)) ? "error" : "ok";
20
+ }
21
+ /** A native tool result's text for the detail level: the untrusted-output wrapper removed, its end only. */
22
+ export function nativeResultOutput(content) {
23
+ let raw = content.startsWith(UNTRUSTED_OPEN) ? content.slice(UNTRUSTED_OPEN.length) : content;
24
+ if (raw.endsWith(UNTRUSTED_CLOSE))
25
+ raw = raw.slice(0, -UNTRUSTED_CLOSE.length);
26
+ // Upstream caps (the MCP client's) keep a result's head and drop its end, after redacting the
27
+ // whole result (core/mcp-client/results.ts redacts before it cuts), so no secret is split
28
+ // there; only this cut drops a head, so only it sets outputCut.
29
+ const tail = tailOf(raw);
30
+ return { output: tail.text, outputCut: tail.cut };
31
+ }
32
+ export function nativeTurnSteps(turnKey, text, toolCalls) {
33
+ const steps = [];
34
+ if (text.trim())
35
+ steps.push({ kind: "said", callId: `said:${turnKey}`, ...bounded(text) });
36
+ for (const call of toolCalls) {
37
+ const tool = displayToolName(call.name);
38
+ steps.push({
39
+ kind: "tool",
40
+ callId: call.id,
41
+ tool,
42
+ ...toolStepText(tool, call.argsJson),
43
+ input: call.argsJson.slice(0, MAX_STEP_TEXT_CHARS),
44
+ inputTruncated: call.argsJson.length > MAX_STEP_TEXT_CHARS,
45
+ });
46
+ }
47
+ return steps;
48
+ }
49
+ export function nativeToolResults(toolCalls, results) {
50
+ return toolCalls.map((call, index) => {
51
+ const content = results[index] ?? "";
52
+ return { callId: call.id, status: nativeToolStatus(content), ...nativeResultOutput(content) };
53
+ });
54
+ }
55
+ /** The results a model request carries for the previous turn: the `tool` messages after the last assistant one. */
56
+ export function nativeRequestResults(messages) {
57
+ let lastAssistant = -1;
58
+ for (let index = messages.length - 1; index >= 0; index--) {
59
+ if (messages[index].role === "assistant") {
60
+ lastAssistant = index;
61
+ break;
62
+ }
63
+ }
64
+ const results = [];
65
+ // A trailing non-tool message (the engine's wind-down `user` message) does not hide the results.
66
+ for (const message of messages.slice(lastAssistant + 1)) {
67
+ if (message.role === "tool" && message.toolCallId) {
68
+ results.push({
69
+ callId: message.toolCallId,
70
+ status: nativeToolStatus(message.content),
71
+ ...nativeResultOutput(message.content),
72
+ });
73
+ }
74
+ }
75
+ return results;
76
+ }
77
+ /** How long a gateway's stream end waits for its steps to be written; past it the write goes on alone. */
78
+ export const STREAM_STEPS_BOUND_MS = 2_000;
79
+ /**
80
+ * Collects one model call's steps from its events. The said step's id is a hash of `callId` (the
81
+ * worker-chosen request id), so no worker text is stored as an id.
82
+ */
83
+ export class NativeStreamSteps {
84
+ text = "";
85
+ truncated = false;
86
+ calls = [];
87
+ key;
88
+ constructor(callId) {
89
+ this.key = createHash("sha256").update(callId).digest("hex").slice(0, 32);
90
+ }
91
+ observe(event) {
92
+ try {
93
+ if (event.type === "text") {
94
+ if (this.text.length + event.delta.length > MAX_STEP_TEXT_CHARS) {
95
+ this.text = (this.text + event.delta).slice(0, MAX_STEP_TEXT_CHARS);
96
+ this.truncated = true;
97
+ }
98
+ else
99
+ this.text += event.delta;
100
+ }
101
+ else if (event.type === "tool_call") {
102
+ this.calls.push({ id: event.id, name: event.name, argsJson: event.argsJson });
103
+ }
104
+ }
105
+ catch {
106
+ // A step is dropped, never the stream.
107
+ }
108
+ }
109
+ steps() {
110
+ const steps = nativeTurnSteps(this.key, this.text, this.calls);
111
+ if (this.truncated && steps[0]?.kind === "said")
112
+ steps[0] = { ...steps[0], truncated: true };
113
+ return steps;
114
+ }
115
+ }
116
+ /**
117
+ * A native gateway's stream end: records the call's steps and the results its request carries for
118
+ * the previous turn, so the next call's results find these steps. Never throws, and waits at most
119
+ * `boundMs`: past it the stream ends and the write finishes in the background (the writer logs its
120
+ * own failures, name only).
121
+ */
122
+ export async function recordStreamSteps(sink, runId, tap, messages, extraSecretValues = [], boundMs = STREAM_STEPS_BOUND_MS) {
123
+ if (!sink || !tap)
124
+ return;
125
+ let write;
126
+ try {
127
+ const batch = { steps: tap.steps(), results: nativeRequestResults(messages) };
128
+ write = Promise.resolve(sink.record(runId, batch, extraSecretValues)).catch(() => undefined);
129
+ }
130
+ catch (err) {
131
+ stepsLog.warn({ runId, event: "run_steps_write_failed", errorName: err instanceof Error ? err.name : typeof err }, "could not record a run's steps; they were dropped");
132
+ return;
133
+ }
134
+ let timer;
135
+ const bound = new Promise((resolve) => {
136
+ timer = setTimeout(resolve, boundMs);
137
+ });
138
+ try {
139
+ await Promise.race([write, bound]);
140
+ }
141
+ finally {
142
+ clearTimeout(timer);
143
+ }
144
+ }
145
+ /** One engine turn event's batch: a turn's said and tool steps, or its tool calls' results. */
146
+ export function nativeTurnBatch(event) {
147
+ return event.kind === "turn"
148
+ ? { steps: nativeTurnSteps(`turn:${event.turn}`, event.text, event.toolCalls), results: [] }
149
+ : { steps: [], results: nativeToolResults(event.toolCalls, event.results) };
150
+ }
151
+ /**
152
+ * The engine's `onTurn` for a run: hands each non-empty batch to the writer and does not wait for
153
+ * it. A throw here reaches the engine, which logs it by name and goes on.
154
+ */
155
+ export function runStepsHook(sink, runId) {
156
+ if (!sink)
157
+ return undefined;
158
+ return (event) => {
159
+ const batch = nativeTurnBatch(event);
160
+ if (batch.steps.length === 0 && batch.results.length === 0)
161
+ return;
162
+ void sink.record(runId, batch);
163
+ };
164
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The coding proxy's memory of which tool results it already handed over, per proxy session: every
3
+ * request resends the history, so the same result arrives many times. Bounded (oldest sessions and
4
+ * ids forgotten first); the control plane's writer ignores a repeat anyway (first status wins).
5
+ */
6
+ export declare class SeenIds {
7
+ private readonly maxSessions;
8
+ private readonly maxIdsPerSession;
9
+ private readonly bySession;
10
+ constructor(maxSessions?: number, maxIdsPerSession?: number);
11
+ fresh<T extends {
12
+ callId: string;
13
+ }>(sessionId: string, items: readonly T[]): T[];
14
+ /** Drops a session's ids: called when its proxy session has ended. */
15
+ forget(sessionId: string): void;
16
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The coding proxy's memory of which tool results it already handed over, per proxy session: every
3
+ * request resends the history, so the same result arrives many times. Bounded (oldest sessions and
4
+ * ids forgotten first); the control plane's writer ignores a repeat anyway (first status wins).
5
+ */
6
+ export class SeenIds {
7
+ maxSessions;
8
+ maxIdsPerSession;
9
+ bySession = new Map();
10
+ constructor(maxSessions = 512, maxIdsPerSession = 1024) {
11
+ this.maxSessions = maxSessions;
12
+ this.maxIdsPerSession = maxIdsPerSession;
13
+ }
14
+ fresh(sessionId, items) {
15
+ let seen = this.bySession.get(sessionId);
16
+ if (!seen) {
17
+ if (this.bySession.size >= this.maxSessions)
18
+ this.bySession.delete(this.bySession.keys().next().value);
19
+ seen = new Set();
20
+ this.bySession.set(sessionId, seen);
21
+ }
22
+ const ids = seen;
23
+ const out = items.filter((item) => !ids.has(item.callId));
24
+ for (const item of out) {
25
+ ids.add(item.callId);
26
+ if (ids.size > this.maxIdsPerSession)
27
+ ids.delete(ids.values().next().value);
28
+ }
29
+ return out;
30
+ }
31
+ /** Drops a session's ids: called when its proxy session has ended. */
32
+ forget(sessionId) {
33
+ this.bySession.delete(sessionId);
34
+ }
35
+ }
@@ -0,0 +1,57 @@
1
+ import { type ExtractedStep } from "./types.js";
2
+ /** Claude Code's one shell tool through the coding proxy (src/providers/coding-proxy/proxy.ts). */
3
+ export declare const CLAUDE_COMMAND_TOOL = "mcp__wardby_tools__run_command";
4
+ export declare function bounded(text: string): {
5
+ text: string;
6
+ truncated: boolean;
7
+ };
8
+ /** A tool's name as a step shows it; anything that isn't a plain name becomes "tool". */
9
+ export declare function displayToolName(name: string, namespace?: string): string;
10
+ /** The text a tool step's summary is cut from: the command, the path, the pattern, or the first argument. */
11
+ export declare function toolInputText(tool: string, input: unknown): string;
12
+ /** A tool step's text from its JSON arguments (complete or cut off). */
13
+ export declare function toolStepText(tool: string, argsJson: string): {
14
+ text: string;
15
+ truncated: boolean;
16
+ };
17
+ /** Claude Code's tool for a coding run's final answer (the coding proxy allows it by this name). */
18
+ export declare const CLAUDE_RESULT_TOOL = "StructuredOutput";
19
+ /** A final answer's step when it has no summary of its own. */
20
+ export declare const FINISHED_STEP_TEXT = "Finished";
21
+ /**
22
+ * A coding run's final structured answer (`{"schemaVersion":1,...,"summary":"..."}`: Claude Code's
23
+ * StructuredOutput input, Codex's last message) as the text of one said step: the answer's own
24
+ * summary, else a fixed Finished line. `undefined` when the text is not such an answer. A cut answer
25
+ * gives its summary as far as it goes, marked truncated. The text is redacted later, with every
26
+ * other step's, by stepSummarizer.
27
+ */
28
+ export declare function codingResultStepText(json: string): {
29
+ text: string;
30
+ truncated: boolean;
31
+ } | undefined;
32
+ export declare const collapseWhitespace: (text: string) => string;
33
+ /**
34
+ * Every form a secret value can take in a collapsed step text, longest first: each value as
35
+ * written and whitespace-collapsed (the model wrote it with other whitespace), each of those
36
+ * JSON-escaped (withEscapedForms: a value inside JSON text), and each of those collapsed.
37
+ */
38
+ export declare function secretForms(secretValues: readonly string[]): string[];
39
+ /**
40
+ * The longest proper prefix of any form (at least the minimum length) that `text` ends with, or
41
+ * "" if none. Linear in the text per form (a KMP scan), whatever the forms look like. `tables`
42
+ * holds each form's failure table, built the first time a cut text needs it.
43
+ */
44
+ export declare function secretTail(text: string, forms: readonly string[], tables: Map<string, Int32Array>): string;
45
+ /**
46
+ * Summaries for one batch, against every secret value delivered to the run (the agent's and the
47
+ * run's own, such as its capability). The forms are built once per batch. Each step's text (at
48
+ * most 16 KiB) is whitespace collapsed, then redacted once with the shared redactor
49
+ * (redactSecrets: the union of every occurrence of every form, then token shapes), then cut to 100
50
+ * characters (tool) or 120 (said). Any text may end in the start of a secret (it was cut, or a
51
+ * stream stopped early without saying so), so on every step the longest such start (secretTail,
52
+ * on the collapsed text before any masking) is redacted in the same pass as one more exact value,
53
+ * so it merges with any whole secret it overlaps.
54
+ */
55
+ export declare function stepSummarizer(secretValues: readonly string[]): (step: Pick<ExtractedStep, "kind" | "text" | "truncated">) => string;
56
+ /** One step's stored summary (stepSummarizer, for a single step). */
57
+ export declare function stepSummary(step: Pick<ExtractedStep, "kind" | "text" | "truncated">, secretValues: readonly string[]): string;