@wardby/cli 0.2.1 → 0.4.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 (555) hide show
  1. package/.env.example +53 -4
  2. package/README.md +52 -13
  3. package/dist/claude-coding-worker/driver.d.ts +6 -1
  4. package/dist/claude-coding-worker/driver.js +27 -1
  5. package/dist/claude-coding-worker/main.js +2 -0
  6. package/dist/claude-coding-worker/tool-socket.d.ts +9 -0
  7. package/dist/claude-coding-worker/tool-socket.js +26 -0
  8. package/dist/cli-help.d.ts +1 -1
  9. package/dist/cli-help.js +14 -4
  10. package/dist/cli.d.ts +1 -1
  11. package/dist/cli.js +284 -36
  12. package/dist/coding/base-commit.d.ts +6 -0
  13. package/dist/coding/base-commit.js +12 -0
  14. package/dist/coding/collect-exclude.d.ts +25 -0
  15. package/dist/coding/collect-exclude.js +76 -0
  16. package/dist/coding/profile.d.ts +67 -22
  17. package/dist/coding/profile.js +58 -25
  18. package/dist/coding/protected-path-wording.d.ts +24 -0
  19. package/dist/coding/protected-path-wording.js +55 -0
  20. package/dist/coding/protected-paths.d.ts +31 -0
  21. package/dist/coding/protected-paths.js +48 -0
  22. package/dist/coding/protocol.d.ts +91 -4
  23. package/dist/coding/protocol.js +123 -12
  24. package/dist/coding/provider.d.ts +6 -1
  25. package/dist/coding/provider.js +16 -9
  26. package/dist/coding/registry/adapters.d.ts +2 -0
  27. package/dist/coding/registry/adapters.js +9 -0
  28. package/dist/coding/registry/allowlist.d.ts +9 -0
  29. package/dist/coding/registry/allowlist.js +28 -0
  30. package/dist/coding/registry/json-scan.d.ts +55 -0
  31. package/dist/coding/registry/json-scan.js +191 -0
  32. package/dist/coding/registry/lockfiles.d.ts +6 -0
  33. package/dist/coding/registry/lockfiles.js +89 -0
  34. package/dist/coding/registry/npm-lockfile.d.ts +9 -0
  35. package/dist/coding/registry/npm-lockfile.js +73 -0
  36. package/dist/coding/registry/npm-plan.d.ts +29 -0
  37. package/dist/coding/registry/npm-plan.js +289 -0
  38. package/dist/coding/registry/npm.d.ts +7 -0
  39. package/dist/coding/registry/npm.js +252 -0
  40. package/dist/coding/registry/pypi.d.ts +4 -0
  41. package/dist/coding/registry/pypi.js +210 -0
  42. package/dist/coding/registry/report.d.ts +37 -0
  43. package/dist/coding/registry/report.js +31 -0
  44. package/dist/coding/registry/token.d.ts +4 -0
  45. package/dist/coding/registry/token.js +7 -0
  46. package/dist/coding/registry/types.d.ts +286 -0
  47. package/dist/coding/registry/types.js +19 -0
  48. package/dist/coding/registry/worker-config.d.ts +14 -0
  49. package/dist/coding/registry/worker-config.js +31 -0
  50. package/dist/coding/services/builtins.d.ts +22 -0
  51. package/dist/coding/services/builtins.js +85 -0
  52. package/dist/coding/services/catalog.d.ts +443 -0
  53. package/dist/coding/services/catalog.js +159 -0
  54. package/dist/coding/services/declaration.d.ts +11 -0
  55. package/dist/coding/services/declaration.js +114 -0
  56. package/dist/coding/services/note.d.ts +8 -0
  57. package/dist/coding/services/note.js +15 -0
  58. package/dist/coding/services/resolve.d.ts +25 -0
  59. package/dist/coding/services/resolve.js +50 -0
  60. package/dist/coding/services/wording.d.ts +25 -0
  61. package/dist/coding/services/wording.js +70 -0
  62. package/dist/coding-proxy/main.js +24 -4
  63. package/dist/coding-worker/artifact.d.ts +6 -0
  64. package/dist/coding-worker/debug-trace.d.ts +37 -0
  65. package/dist/coding-worker/debug-trace.js +117 -0
  66. package/dist/coding-worker/driver.d.ts +13 -1
  67. package/dist/coding-worker/driver.js +102 -13
  68. package/dist/coding-worker/errors.js +8 -0
  69. package/dist/coding-worker/main.js +10 -2
  70. package/dist/coding-worker/sdk.d.ts +2 -2
  71. package/dist/coding-worker/sdk.js +7 -2
  72. package/dist/coding-worker/types.d.ts +3 -0
  73. package/dist/config/providers.d.ts +66 -0
  74. package/dist/config/providers.js +137 -0
  75. package/dist/core/attribution.d.ts +101 -0
  76. package/dist/core/attribution.js +208 -0
  77. package/dist/core/budget-groups.d.ts +120 -10
  78. package/dist/core/budget-groups.js +133 -24
  79. package/dist/core/budget-wording.d.ts +22 -0
  80. package/dist/core/budget-wording.js +55 -0
  81. package/dist/core/coding-queue.d.ts +3 -0
  82. package/dist/core/coding-queue.js +6 -2
  83. package/dist/core/coding-service-status.d.ts +11 -0
  84. package/dist/core/coding-service-status.js +17 -0
  85. package/dist/core/cost-report.d.ts +88 -0
  86. package/dist/core/cost-report.js +248 -0
  87. package/dist/core/datastores.js +18 -2
  88. package/dist/core/db.d.ts +5 -1
  89. package/dist/core/db.js +8 -2
  90. package/dist/core/dispatch.d.ts +74 -7
  91. package/dist/core/dispatch.js +382 -47
  92. package/dist/core/engine-native.js +44 -14
  93. package/dist/core/glob.d.ts +10 -0
  94. package/dist/core/glob.js +33 -0
  95. package/dist/core/grants.d.ts +86 -0
  96. package/dist/core/grants.js +126 -0
  97. package/dist/core/host-events.d.ts +72 -0
  98. package/dist/core/host-events.js +597 -0
  99. package/dist/core/host-identity-links.d.ts +54 -0
  100. package/dist/core/host-identity-links.js +189 -0
  101. package/dist/core/host-status.d.ts +78 -0
  102. package/dist/core/host-status.js +228 -0
  103. package/dist/core/in-flight-runs.d.ts +8 -0
  104. package/dist/core/in-flight-runs.js +56 -0
  105. package/dist/core/issue-bridge.d.ts +60 -0
  106. package/dist/core/issue-bridge.js +189 -0
  107. package/dist/core/issue-dedupe.d.ts +70 -0
  108. package/dist/core/issue-dedupe.js +255 -0
  109. package/dist/core/issue-events.d.ts +42 -0
  110. package/dist/core/issue-events.js +155 -0
  111. package/dist/core/issue-status.d.ts +29 -0
  112. package/dist/core/issue-status.js +241 -0
  113. package/dist/core/issue-tracker-tools.d.ts +64 -0
  114. package/dist/core/issue-tracker-tools.js +850 -0
  115. package/dist/core/model-usage.d.ts +10 -0
  116. package/dist/core/model-usage.js +24 -0
  117. package/dist/core/provider-wording.d.ts +12 -0
  118. package/dist/core/provider-wording.js +44 -0
  119. package/dist/core/reconciler.d.ts +42 -2
  120. package/dist/core/reconciler.js +97 -2
  121. package/dist/core/repo-access.d.ts +99 -0
  122. package/dist/core/repo-access.js +136 -0
  123. package/dist/core/review-host-checks.d.ts +11 -0
  124. package/dist/core/review-host-checks.js +41 -0
  125. package/dist/core/review-host-tools.d.ts +47 -0
  126. package/dist/core/review-host-tools.js +354 -0
  127. package/dist/core/run-heartbeat.d.ts +27 -0
  128. package/dist/core/run-heartbeat.js +54 -0
  129. package/dist/core/run-pricing.d.ts +61 -0
  130. package/dist/core/run-pricing.js +56 -0
  131. package/dist/core/runner.d.ts +33 -8
  132. package/dist/core/runner.js +410 -62
  133. package/dist/core/scheduler.d.ts +4 -1
  134. package/dist/core/scheduler.js +3 -2
  135. package/dist/core/secrets.d.ts +11 -2
  136. package/dist/core/secrets.js +25 -6
  137. package/dist/core/self-defects.d.ts +80 -0
  138. package/dist/core/self-defects.js +180 -0
  139. package/dist/core/subagent-memory-tools.d.ts +1 -1
  140. package/dist/core/subagent-memory-tools.js +16 -3
  141. package/dist/core/tool-admin.d.ts +81 -0
  142. package/dist/core/tool-admin.js +129 -0
  143. package/dist/core/tool-names.d.ts +42 -0
  144. package/dist/core/tool-names.js +67 -0
  145. package/dist/core/untrusted-content.d.ts +32 -0
  146. package/dist/core/untrusted-content.js +72 -0
  147. package/dist/core/webhooks.d.ts +17 -2
  148. package/dist/core/webhooks.js +42 -3
  149. package/dist/generated/prisma/browser.d.ts +166 -0
  150. package/dist/generated/prisma/client.d.ts +166 -0
  151. package/dist/generated/prisma/commonInputTypes.d.ts +152 -52
  152. package/dist/generated/prisma/enums.d.ts +13 -0
  153. package/dist/generated/prisma/enums.js +12 -1
  154. package/dist/generated/prisma/internal/class.d.ts +242 -0
  155. package/dist/generated/prisma/internal/class.js +4 -4
  156. package/dist/generated/prisma/internal/prismaNamespace.d.ts +2571 -577
  157. package/dist/generated/prisma/internal/prismaNamespace.js +312 -6
  158. package/dist/generated/prisma/internal/prismaNamespaceBrowser.d.ts +328 -0
  159. package/dist/generated/prisma/internal/prismaNamespaceBrowser.js +312 -6
  160. package/dist/generated/prisma/models/Agent.d.ts +682 -1
  161. package/dist/generated/prisma/models/AgentIssueProject.d.ts +1838 -0
  162. package/dist/generated/prisma/models/AgentIssueProject.js +1 -0
  163. package/dist/generated/prisma/models/AgentRepository.d.ts +1425 -0
  164. package/dist/generated/prisma/models/AgentRepository.js +1 -0
  165. package/dist/generated/prisma/models/AgentTool.d.ts +95 -1
  166. package/dist/generated/prisma/models/AuthUser.d.ts +56 -1
  167. package/dist/generated/prisma/models/CodingAgentProfile.d.ts +258 -7
  168. package/dist/generated/prisma/models/CodingProxySession.d.ts +195 -2
  169. package/dist/generated/prisma/models/CodingRun.d.ts +1405 -95
  170. package/dist/generated/prisma/models/CodingRunServiceStatus.d.ts +1404 -0
  171. package/dist/generated/prisma/models/CodingRunServiceStatus.js +1 -0
  172. package/dist/generated/prisma/models/CodingService.d.ts +1348 -0
  173. package/dist/generated/prisma/models/CodingService.js +1 -0
  174. package/dist/generated/prisma/models/HostEventDelivery.d.ts +946 -0
  175. package/dist/generated/prisma/models/HostEventDelivery.js +1 -0
  176. package/dist/generated/prisma/models/HostIdentity.d.ts +1232 -0
  177. package/dist/generated/prisma/models/HostIdentity.js +1 -0
  178. package/dist/generated/prisma/models/HostIdentityLinkRequest.d.ts +1473 -0
  179. package/dist/generated/prisma/models/HostIdentityLinkRequest.js +1 -0
  180. package/dist/generated/prisma/models/IssueFingerprint.d.ts +1183 -0
  181. package/dist/generated/prisma/models/IssueFingerprint.js +1 -0
  182. package/dist/generated/prisma/models/IssuePullRequest.d.ts +1255 -0
  183. package/dist/generated/prisma/models/IssuePullRequest.js +1 -0
  184. package/dist/generated/prisma/models/ModelCatalogEntry.d.ts +1322 -0
  185. package/dist/generated/prisma/models/ModelCatalogEntry.js +1 -0
  186. package/dist/generated/prisma/models/Principal.d.ts +455 -0
  187. package/dist/generated/prisma/models/RegistryAllowance.d.ts +1148 -0
  188. package/dist/generated/prisma/models/RegistryAllowance.js +1 -0
  189. package/dist/generated/prisma/models/RegistryApprovedVersion.d.ts +1219 -0
  190. package/dist/generated/prisma/models/RegistryApprovedVersion.js +1 -0
  191. package/dist/generated/prisma/models/RegistryFetch.d.ts +1428 -0
  192. package/dist/generated/prisma/models/RegistryFetch.js +1 -0
  193. package/dist/generated/prisma/models/RegistryPlanRefusal.d.ts +1294 -0
  194. package/dist/generated/prisma/models/RegistryPlanRefusal.js +1 -0
  195. package/dist/generated/prisma/models/RegistryVersionFact.d.ts +1085 -0
  196. package/dist/generated/prisma/models/RegistryVersionFact.js +1 -0
  197. package/dist/generated/prisma/models/ResourceGrant.d.ts +1437 -0
  198. package/dist/generated/prisma/models/ResourceGrant.js +1 -0
  199. package/dist/generated/prisma/models/Run.d.ts +1402 -82
  200. package/dist/generated/prisma/models/RunAttribution.d.ts +1259 -0
  201. package/dist/generated/prisma/models/RunAttribution.js +1 -0
  202. package/dist/generated/prisma/models/RunHostCheck.d.ts +1239 -0
  203. package/dist/generated/prisma/models/RunHostCheck.js +1 -0
  204. package/dist/generated/prisma/models/RunHostStatus.d.ts +1315 -0
  205. package/dist/generated/prisma/models/RunHostStatus.js +1 -0
  206. package/dist/generated/prisma/models/RunIssueStatus.d.ts +1199 -0
  207. package/dist/generated/prisma/models/RunIssueStatus.js +1 -0
  208. package/dist/generated/prisma/models/RunModelUsage.d.ts +1316 -0
  209. package/dist/generated/prisma/models/RunModelUsage.js +1 -0
  210. package/dist/generated/prisma/models/Tool.d.ts +15 -3
  211. package/dist/generated/prisma/models/WorkItem.d.ts +1408 -0
  212. package/dist/generated/prisma/models/WorkItem.js +1 -0
  213. package/dist/generated/prisma/models.d.ts +22 -0
  214. package/dist/help/build.d.ts +1 -0
  215. package/dist/help/build.js +9 -0
  216. package/dist/help/catalog.d.ts +24 -0
  217. package/dist/help/catalog.js +160 -0
  218. package/dist/help/cli.d.ts +2 -0
  219. package/dist/help/cli.js +65 -0
  220. package/dist/help/runtime.d.ts +3 -0
  221. package/dist/help/runtime.js +44 -0
  222. package/dist/help/search.d.ts +9 -0
  223. package/dist/help/search.js +104 -0
  224. package/dist/help-index.json +999 -0
  225. package/dist/import/cli-args.js +3 -2
  226. package/dist/import/create.d.ts +5 -0
  227. package/dist/import/create.js +67 -13
  228. package/dist/import/index.js +19 -9
  229. package/dist/import/neutral-schema.d.ts +18 -18
  230. package/dist/knowledge/check.d.ts +13 -0
  231. package/dist/knowledge/check.js +69 -0
  232. package/dist/knowledge/cli.d.ts +14 -0
  233. package/dist/knowledge/cli.js +67 -0
  234. package/dist/knowledge/concept.d.ts +54 -0
  235. package/dist/knowledge/concept.js +78 -0
  236. package/dist/knowledge/note.d.ts +11 -0
  237. package/dist/knowledge/note.js +39 -0
  238. package/dist/knowledge/relevance.d.ts +11 -0
  239. package/dist/knowledge/relevance.js +14 -0
  240. package/dist/knowledge/span-hash.d.ts +3 -0
  241. package/dist/knowledge/span-hash.js +16 -0
  242. package/dist/mcp/auth/access.d.ts +72 -0
  243. package/dist/mcp/auth/access.js +58 -0
  244. package/dist/mcp/auth/grants-cli.d.ts +149 -0
  245. package/dist/mcp/auth/grants-cli.js +518 -0
  246. package/dist/mcp/auth/host-account-cli.d.ts +2 -0
  247. package/dist/mcp/auth/host-account-cli.js +47 -0
  248. package/dist/mcp/auth/ownership.d.ts +25 -51
  249. package/dist/mcp/auth/ownership.js +19 -14
  250. package/dist/mcp/auth/repo-authorization.d.ts +22 -0
  251. package/dist/mcp/auth/repo-authorization.js +51 -0
  252. package/dist/mcp/auth/resource-server.d.ts +33 -2
  253. package/dist/mcp/auth/resource-server.js +99 -3
  254. package/dist/mcp/auth/self-hosted/browser.js +2 -2
  255. package/dist/mcp/auth/self-hosted/cli.js +47 -13
  256. package/dist/mcp/auth/self-hosted/credentials.d.ts +23 -5
  257. package/dist/mcp/auth/self-hosted/credentials.js +62 -4
  258. package/dist/mcp/auth/self-hosted/session.d.ts +7 -6
  259. package/dist/mcp/context.d.ts +30 -1
  260. package/dist/mcp/errors.d.ts +25 -6
  261. package/dist/mcp/errors.js +98 -0
  262. package/dist/mcp/host-events/deliveries.d.ts +9 -0
  263. package/dist/mcp/host-events/deliveries.js +17 -0
  264. package/dist/mcp/host-events/github-ingress.d.ts +38 -0
  265. package/dist/mcp/host-events/github-ingress.js +83 -0
  266. package/dist/mcp/host-events/github-user-callback.d.ts +18 -0
  267. package/dist/mcp/host-events/github-user-callback.js +50 -0
  268. package/dist/mcp/host-events/jira-ingress.d.ts +29 -0
  269. package/dist/mcp/host-events/jira-ingress.js +92 -0
  270. package/dist/mcp/index.d.ts +10 -1
  271. package/dist/mcp/index.js +187 -19
  272. package/dist/mcp/server.js +32 -11
  273. package/dist/mcp/tools/agents.js +519 -50
  274. package/dist/mcp/tools/budget-groups.js +3 -3
  275. package/dist/mcp/tools/cost-report.d.ts +8 -0
  276. package/dist/mcp/tools/cost-report.js +60 -0
  277. package/dist/mcp/tools/datastore.js +22 -15
  278. package/dist/mcp/tools/grants.d.ts +2 -0
  279. package/dist/mcp/tools/grants.js +239 -0
  280. package/dist/mcp/tools/help.d.ts +5 -0
  281. package/dist/mcp/tools/help.js +67 -0
  282. package/dist/mcp/tools/host-accounts.d.ts +2 -0
  283. package/dist/mcp/tools/host-accounts.js +114 -0
  284. package/dist/mcp/tools/issue-projects.d.ts +2 -0
  285. package/dist/mcp/tools/issue-projects.js +238 -0
  286. package/dist/mcp/tools/memory.d.ts +7 -1
  287. package/dist/mcp/tools/memory.js +5 -5
  288. package/dist/mcp/tools/model-catalog.d.ts +22 -0
  289. package/dist/mcp/tools/model-catalog.js +423 -0
  290. package/dist/mcp/tools/repositories.d.ts +2 -0
  291. package/dist/mcp/tools/repositories.js +182 -0
  292. package/dist/mcp/tools/runs.d.ts +6 -0
  293. package/dist/mcp/tools/runs.js +60 -6
  294. package/dist/mcp/tools/scheduling.js +3 -6
  295. package/dist/mcp/tools/secrets.js +18 -6
  296. package/dist/mcp/tools/services.d.ts +2 -0
  297. package/dist/mcp/tools/services.js +222 -0
  298. package/dist/mcp/tools/subagents.js +52 -16
  299. package/dist/mcp/tools/tools.d.ts +41 -0
  300. package/dist/mcp/tools/tools.js +201 -40
  301. package/dist/mcp/tools/trigger.js +65 -7
  302. package/dist/mcp/tools/webhooks.js +15 -4
  303. package/dist/mcp/transport/streamable-http.d.ts +15 -0
  304. package/dist/mcp/transport/streamable-http.js +55 -3
  305. package/dist/mcp/webhooks/ingress.d.ts +2 -1
  306. package/dist/mcp/webhooks/ingress.js +9 -2
  307. package/dist/providers/auth/delegating.d.ts +19 -0
  308. package/dist/providers/auth/delegating.js +71 -0
  309. package/dist/providers/auth/index.d.ts +2 -0
  310. package/dist/providers/auth/index.js +11 -0
  311. package/dist/providers/auth/self-hosted.d.ts +10 -2
  312. package/dist/providers/auth/self-hosted.js +55 -6
  313. package/dist/providers/auth/types.d.ts +6 -0
  314. package/dist/providers/coding-proxy/memory-ledger.d.ts +4 -1
  315. package/dist/providers/coding-proxy/memory-ledger.js +31 -3
  316. package/dist/providers/coding-proxy/metering.d.ts +6 -1
  317. package/dist/providers/coding-proxy/metering.js +41 -4
  318. package/dist/providers/coding-proxy/prisma-ledger.d.ts +17 -0
  319. package/dist/providers/coding-proxy/prisma-ledger.js +106 -8
  320. package/dist/providers/coding-proxy/proxy.d.ts +25 -2
  321. package/dist/providers/coding-proxy/proxy.js +561 -38
  322. package/dist/providers/coding-proxy/registry/audit.d.ts +131 -0
  323. package/dist/providers/coding-proxy/registry/audit.js +380 -0
  324. package/dist/providers/coding-proxy/registry/bounded-fetch.d.ts +16 -0
  325. package/dist/providers/coding-proxy/registry/bounded-fetch.js +77 -0
  326. package/dist/providers/coding-proxy/registry/plan.d.ts +58 -0
  327. package/dist/providers/coding-proxy/registry/plan.js +304 -0
  328. package/dist/providers/coding-proxy/registry/prisma-store.d.ts +34 -0
  329. package/dist/providers/coding-proxy/registry/prisma-store.js +151 -0
  330. package/dist/providers/coding-proxy/registry/service.d.ts +213 -0
  331. package/dist/providers/coding-proxy/registry/service.js +1137 -0
  332. package/dist/providers/coding-proxy/registry/store.d.ts +127 -0
  333. package/dist/providers/coding-proxy/registry/store.js +70 -0
  334. package/dist/providers/coding-proxy/runtime.d.ts +17 -0
  335. package/dist/providers/coding-proxy/runtime.js +63 -0
  336. package/dist/providers/coding-proxy/secure-fetch.js +0 -1
  337. package/dist/providers/coding-proxy/server.d.ts +11 -0
  338. package/dist/providers/coding-proxy/server.js +163 -0
  339. package/dist/providers/coding-proxy/types.d.ts +33 -1
  340. package/dist/providers/coding-proxy/types.js +12 -1
  341. package/dist/providers/engine/types.d.ts +29 -0
  342. package/dist/providers/executor/build.d.ts +2 -2
  343. package/dist/providers/executor/composition.d.ts +3 -0
  344. package/dist/providers/executor/composition.js +28 -1
  345. package/dist/providers/executor/container.d.ts +134 -4
  346. package/dist/providers/executor/container.js +394 -37
  347. package/dist/providers/executor/dbos.d.ts +4 -3
  348. package/dist/providers/executor/dbos.js +7 -5
  349. package/dist/providers/executor/in-process.d.ts +2 -3
  350. package/dist/providers/executor/routing.d.ts +13 -0
  351. package/dist/providers/executor/routing.js +18 -0
  352. package/dist/providers/executor/types.d.ts +34 -0
  353. package/dist/providers/issue-tracker/adf.d.ts +31 -0
  354. package/dist/providers/issue-tracker/adf.js +181 -0
  355. package/dist/providers/issue-tracker/index.d.ts +5 -0
  356. package/dist/providers/issue-tracker/index.js +12 -0
  357. package/dist/providers/issue-tracker/jira-client.d.ts +41 -0
  358. package/dist/providers/issue-tracker/jira-client.js +151 -0
  359. package/dist/providers/issue-tracker/jira-events.d.ts +3 -0
  360. package/dist/providers/issue-tracker/jira-events.js +98 -0
  361. package/dist/providers/issue-tracker/jira.d.ts +116 -0
  362. package/dist/providers/issue-tracker/jira.js +502 -0
  363. package/dist/providers/issue-tracker/types.d.ts +269 -0
  364. package/dist/providers/issue-tracker/types.js +16 -0
  365. package/dist/providers/jobs/claude-tool-setup.d.ts +23 -0
  366. package/dist/providers/jobs/claude-tool-setup.js +50 -0
  367. package/dist/providers/jobs/collect-prune.d.ts +7 -0
  368. package/dist/providers/jobs/collect-prune.js +27 -0
  369. package/dist/providers/jobs/docker-isolation.d.ts +48 -3
  370. package/dist/providers/jobs/docker-isolation.js +213 -22
  371. package/dist/providers/jobs/docker-services.d.ts +35 -0
  372. package/dist/providers/jobs/docker-services.js +191 -0
  373. package/dist/providers/jobs/docker.d.ts +53 -2
  374. package/dist/providers/jobs/docker.js +307 -32
  375. package/dist/providers/jobs/fake-kubernetes-api.d.ts +1 -0
  376. package/dist/providers/jobs/fake-kubernetes-api.js +12 -3
  377. package/dist/providers/jobs/kubernetes-isolation.d.ts +17 -2
  378. package/dist/providers/jobs/kubernetes-isolation.js +238 -57
  379. package/dist/providers/jobs/kubernetes-platform.d.ts +10 -4
  380. package/dist/providers/jobs/kubernetes-platform.js +11 -5
  381. package/dist/providers/jobs/kubernetes-preflight.js +3 -0
  382. package/dist/providers/jobs/kubernetes.d.ts +24 -2
  383. package/dist/providers/jobs/kubernetes.js +153 -22
  384. package/dist/providers/jobs/service-state.d.ts +22 -0
  385. package/dist/providers/jobs/service-state.js +17 -0
  386. package/dist/providers/jobs/types.d.ts +18 -0
  387. package/dist/providers/llm/anthropic.d.ts +3 -3
  388. package/dist/providers/llm/anthropic.js +3 -5
  389. package/dist/providers/llm/bedrock.d.ts +3 -3
  390. package/dist/providers/llm/bedrock.js +3 -8
  391. package/dist/providers/llm/catalog-lookup.d.ts +10 -0
  392. package/dist/providers/llm/catalog-lookup.js +15 -0
  393. package/dist/providers/llm/catalog-shipped.d.ts +18 -0
  394. package/dist/providers/llm/catalog-shipped.js +197 -0
  395. package/dist/providers/llm/catalog-store.d.ts +58 -0
  396. package/dist/providers/llm/catalog-store.js +138 -0
  397. package/dist/providers/llm/catalog-types.d.ts +66 -0
  398. package/dist/providers/llm/catalog-types.js +64 -0
  399. package/dist/providers/llm/catalog.d.ts +61 -0
  400. package/dist/providers/llm/catalog.js +147 -0
  401. package/dist/providers/llm/claude-messages.d.ts +5 -1
  402. package/dist/providers/llm/claude-messages.js +1 -0
  403. package/dist/providers/llm/claude-provider.d.ts +10 -12
  404. package/dist/providers/llm/claude-provider.js +15 -6
  405. package/dist/providers/llm/index.d.ts +9 -6
  406. package/dist/providers/llm/index.js +8 -5
  407. package/dist/providers/llm/openai.d.ts +14 -5
  408. package/dist/providers/llm/openai.js +24 -14
  409. package/dist/providers/llm/pricing-core.d.ts +5 -3
  410. package/dist/providers/llm/registration.js +8 -12
  411. package/dist/providers/llm/routing.d.ts +21 -11
  412. package/dist/providers/llm/routing.js +47 -13
  413. package/dist/providers/llm/types.d.ts +12 -0
  414. package/dist/providers/llm/types.js +8 -1
  415. package/dist/providers/review-host/diff-lines.d.ts +16 -0
  416. package/dist/providers/review-host/diff-lines.js +59 -0
  417. package/dist/providers/review-host/github-events.d.ts +6 -0
  418. package/dist/providers/review-host/github-events.js +226 -0
  419. package/dist/providers/review-host/github-user-auth.d.ts +38 -0
  420. package/dist/providers/review-host/github-user-auth.js +128 -0
  421. package/dist/providers/review-host/github.d.ts +57 -0
  422. package/dist/providers/review-host/github.js +568 -0
  423. package/dist/providers/review-host/index.d.ts +12 -0
  424. package/dist/providers/review-host/index.js +30 -0
  425. package/dist/providers/review-host/review-format.d.ts +19 -0
  426. package/dist/providers/review-host/review-format.js +59 -0
  427. package/dist/providers/review-host/types.d.ts +309 -0
  428. package/dist/providers/review-host/types.js +24 -0
  429. package/dist/providers/vcs/git.d.ts +16 -6
  430. package/dist/providers/vcs/git.js +78 -34
  431. package/dist/providers/vcs/github.d.ts +94 -3
  432. package/dist/providers/vcs/github.js +223 -17
  433. package/dist/providers/vcs/types.d.ts +48 -4
  434. package/dist/quickstart/index.d.ts +2 -0
  435. package/dist/quickstart/index.js +36 -8
  436. package/dist/sandbox/fetch-policy.d.ts +20 -2
  437. package/dist/sandbox/fetch-policy.js +64 -3
  438. package/dist/sandbox/host-functions.d.ts +9 -1
  439. package/dist/sandbox/host-functions.js +12 -5
  440. package/dist/serve.js +8 -2
  441. package/dist/viewer/api-schema.d.ts +2757 -0
  442. package/dist/viewer/api-schema.js +165 -0
  443. package/dist/viewer/build-schemas.d.ts +2 -0
  444. package/dist/viewer/build-schemas.js +18 -0
  445. package/dist/viewer/event-bus.d.ts +38 -0
  446. package/dist/viewer/event-bus.js +232 -0
  447. package/dist/viewer/graph.d.ts +40 -0
  448. package/dist/viewer/graph.js +243 -0
  449. package/dist/viewer/http.d.ts +30 -0
  450. package/dist/viewer/http.js +133 -0
  451. package/dist/viewer/run-detail.d.ts +4 -0
  452. package/dist/viewer/run-detail.js +61 -0
  453. package/dist/wardby-bin.js +11 -0
  454. package/docs/README.md +40 -0
  455. package/docs/agent-recipes.md +383 -0
  456. package/docs/architecture-runtime.md +90 -0
  457. package/docs/assets/brand/wardby-icon-512.png +0 -0
  458. package/docs/assets/brand/wardby-icon.svg +16 -0
  459. package/docs/assets/brand/wardby-mascot-profile-512.png +0 -0
  460. package/docs/assets/brand/wardby-mascot.png +0 -0
  461. package/docs/assets/brand/wardby-mascot.svg +5 -0
  462. package/docs/assets/wardby-workflow.svg +106 -0
  463. package/docs/code-review-agents.md +508 -0
  464. package/docs/coding-agent-setup.md +175 -0
  465. package/docs/coding-packages.md +455 -0
  466. package/docs/coding-services.md +300 -0
  467. package/docs/coding-worker-byo-images.md +98 -0
  468. package/docs/coding-worker-isolation.md +1068 -0
  469. package/docs/getting-started-gke.md +632 -0
  470. package/docs/getting-started-identity-provider.md +319 -0
  471. package/docs/getting-started.md +147 -0
  472. package/docs/jira-agents.md +649 -0
  473. package/docs/knowledge.md +387 -0
  474. package/docs/models.md +221 -0
  475. package/docs/observability.md +53 -0
  476. package/docs/release-verification.md +66 -0
  477. package/docs/security-deployment.md +667 -0
  478. package/docs/viewer-api.md +142 -0
  479. package/help/admin-viewer.md +39 -0
  480. package/help/agent-recipes.md +173 -0
  481. package/help/architecture-agent.md +189 -0
  482. package/help/builder-agent.md +80 -0
  483. package/help/code-review-agents.md +37 -0
  484. package/help/coding-packages.md +31 -0
  485. package/help/coding-services.md +71 -0
  486. package/help/cost-attribution.md +67 -0
  487. package/help/creating-agents.md +90 -0
  488. package/help/deploy-gke.md +45 -0
  489. package/help/deployment-targets.md +39 -0
  490. package/help/errors/budget-group-exhausted.md +25 -0
  491. package/help/errors/docker-isolation-unsupported.md +26 -0
  492. package/help/errors/model-unavailable.md +63 -0
  493. package/help/errors/protected-path.md +45 -0
  494. package/help/errors/repo-access.md +27 -0
  495. package/help/errors/service-declaration-invalid.md +27 -0
  496. package/help/errors/service-declaration-unavailable.md +25 -0
  497. package/help/errors/service-launcher-unsupported.md +30 -0
  498. package/help/errors/service-not-allowed.md +27 -0
  499. package/help/errors/service-unknown.md +23 -0
  500. package/help/errors/service-unready.md +49 -0
  501. package/help/getting-started.md +32 -0
  502. package/help/github.md +48 -0
  503. package/help/identity-and-access.md +44 -0
  504. package/help/jira.md +135 -0
  505. package/help/knowledge.md +47 -0
  506. package/help/mcp.md +30 -0
  507. package/help/models.md +90 -0
  508. package/help/native-capabilities.md +30 -0
  509. package/help/observability.md +41 -0
  510. package/help/operating-agents.md +36 -0
  511. package/help/security.md +27 -0
  512. package/help/troubleshooting/budgets.md +32 -0
  513. package/help/troubleshooting/coding-workers.md +47 -0
  514. package/help/troubleshooting/repository-access.md +27 -0
  515. package/package.json +14 -3
  516. package/prisma/migrations/20260925010000_coding_collect_exclude/migration.sql +8 -0
  517. package/prisma/migrations/20260925015000_allowed_egress_default/migration.sql +8 -0
  518. package/prisma/migrations/20260925020000_coding_package_registry/migration.sql +55 -0
  519. package/prisma/migrations/20260925030000_tool_name_per_owner/migration.sql +11 -0
  520. package/prisma/migrations/20260926010000_run_trigger_host_event/migration.sql +7 -0
  521. package/prisma/migrations/20260926020000_code_review_hosts/migration.sql +53 -0
  522. package/prisma/migrations/20260926030000_auth_user_roles/migration.sql +9 -0
  523. package/prisma/migrations/20260926040000_agent_effort/migration.sql +6 -0
  524. package/prisma/migrations/20260926050000_registry_lockfile_plan/migration.sql +32 -0
  525. package/prisma/migrations/20260926050000_repo_access_authorization/migration.sql +82 -0
  526. package/prisma/migrations/20260926060000_registry_plan_refusal/migration.sql +19 -0
  527. package/prisma/migrations/20260926100000_registry_plan_refusal_published_at/migration.sql +5 -0
  528. package/prisma/migrations/20260926190000_run_host_status/migration.sql +18 -0
  529. package/prisma/migrations/20260926210000_run_host_status_at_dispatch/migration.sql +5 -0
  530. package/prisma/migrations/20260927010000_resource_grants/migration.sql +72 -0
  531. package/prisma/migrations/20260927020000_proxy_session_budget_exhausted/migration.sql +3 -0
  532. package/prisma/migrations/20260927030000_coding_debug_trace/migration.sql +4 -0
  533. package/prisma/migrations/20260927040000_proxy_session_upstream_failure/migration.sql +3 -0
  534. package/prisma/migrations/20260927050000_coding_run_services/migration.sql +74 -0
  535. package/prisma/migrations/20260928000000_coding_run_tool_image/migration.sql +5 -0
  536. package/prisma/migrations/20260930000000_jira_issue_projects/migration.sql +34 -0
  537. package/prisma/migrations/20261001000000_jira_phase2_allowlists/migration.sql +3 -0
  538. package/prisma/migrations/20261001010000_jira_link_types_allowlist/migration.sql +2 -0
  539. package/prisma/migrations/20261002000000_jira_coding_bridge/migration.sql +28 -0
  540. package/prisma/migrations/20261002010000_jira_issue_creation/migration.sql +25 -0
  541. package/prisma/migrations/20261003000000_issue_cost_attribution/migration.sql +56 -0
  542. package/prisma/migrations/20261003010000_coding_run_service_status/migration.sql +23 -0
  543. package/prisma/migrations/20261003020000_viewer_notify/migration.sql +54 -0
  544. package/prisma/migrations/20261003030000_viewer_notify_fixes/migration.sql +47 -0
  545. package/prisma/migrations/20261003040000_viewer_indexes/migration.sql +12 -0
  546. package/prisma/migrations/20261004000000_model_catalog/migration.sql +26 -0
  547. package/prisma/schema.prisma +663 -21
  548. package/dist/mcp/tools/models.d.ts +0 -8
  549. package/dist/mcp/tools/models.js +0 -15
  550. package/dist/providers/llm/pricing-anthropic.d.ts +0 -4
  551. package/dist/providers/llm/pricing-anthropic.js +0 -30
  552. package/dist/providers/llm/pricing-bedrock-claude.d.ts +0 -12
  553. package/dist/providers/llm/pricing-bedrock-claude.js +0 -37
  554. package/dist/providers/llm/pricing.d.ts +0 -30
  555. package/dist/providers/llm/pricing.js +0 -74
@@ -21,9 +21,10 @@ export function parseImportArgs(args) {
21
21
  throw new Error("Missing bundle directory positional argument");
22
22
  }
23
23
  const dir = positionals[0];
24
- // Parse owner/public
24
+ // Parse owner/public: --public may be combined with --owner (the owner of
25
+ // the imported agents, which --public then shares with everyone).
25
26
  const isPublic = values.public ?? false;
26
- const owner = isPublic ? null : (values.owner ?? null);
27
+ const owner = values.owner ?? null;
27
28
  // Validate on-conflict
28
29
  const onConflict = (values["on-conflict"] ?? "fail");
29
30
  if (!VALID_CONFLICT_POLICIES.includes(onConflict)) {
@@ -11,7 +11,12 @@ import type { SecretCipher } from "../providers/secrets/types.js";
11
11
  export interface CreateOptions {
12
12
  db: PrismaClient;
13
13
  cipher: SecretCipher;
14
+ /** Owner of the imported tools, secrets, datastores, webhooks and budget groups; null in --public mode. */
14
15
  ownerId: string | null;
16
+ /** Owner of the imported agents (defaults to ownerId): never null for a real import. */
17
+ agentOwnerId?: string | null;
18
+ /** --public: share each imported agent with everyone at execute. */
19
+ publicAgents?: boolean;
15
20
  defaultBudget: string;
16
21
  secretMode: "references" | "envelope";
17
22
  transferPrivateKey?: KeyObject;
@@ -8,12 +8,15 @@ import { createSecret, attachSecret } from "../core/secrets.js";
8
8
  import { createDatastore, attachDatastore } from "../core/datastores.js";
9
9
  import { createWebhook } from "../core/webhooks.js";
10
10
  import { deriveJsonSchema } from "../sandbox/zod-params.js";
11
+ import { findSameNamedAttachedTool, reservedToolNameReason } from "../core/tool-names.js";
11
12
  import { ToolCapabilitiesPatchSchema, FETCH_WILDCARD } from "../sandbox/tool-capabilities.js";
12
13
  import { PostgresDatastore } from "../providers/datastore/postgres.js";
13
14
  import { decryptTransferEnvelope } from "../providers/secrets/transfer-envelope.js";
14
15
  import { mapBudget } from "./budgets.js";
16
+ import { EVERYONE_KEY, everyoneGrantData } from "../core/grants.js";
15
17
  export async function createFromBundle(bundle, recon, opts) {
16
18
  const { db, cipher, ownerId, secretMode, transferPrivateKey, allowOpenFetch } = opts;
19
+ const agentOwnerId = opts.agentOwnerId === undefined ? ownerId : opts.agentOwnerId;
17
20
  const warnings = [];
18
21
  const webhookSecrets = [];
19
22
  const pendingSecretReentry = [];
@@ -37,28 +40,41 @@ export async function createFromBundle(bundle, recon, opts) {
37
40
  for (const t of bundle.readTools()) {
38
41
  if (toolRejected(t.name) || toolSkipped(t.name))
39
42
  continue;
43
+ // A built-in dispatched before user tools would shadow it, so the tool
44
+ // could be created but never called (see core/tool-names.ts).
45
+ const reserved = reservedToolNameReason(eff(t.name));
46
+ if (reserved) {
47
+ warnings.push(`tool ${t.name}: skipped — ${reserved}`);
48
+ continue;
49
+ }
40
50
  const schema = await deriveJsonSchema(t.paramsZod);
41
51
  if (!schema.ok) {
42
52
  warnings.push(`tool ${t.name}: failed to derive JSON schema, skipping`);
43
53
  continue;
44
54
  }
45
- const tool = await db.tool.upsert({
46
- where: { name: eff(t.name) },
47
- create: {
48
- name: eff(t.name),
49
- description: t.description,
50
- paramsZod: t.paramsZod,
51
- code: t.code,
52
- jsonSchema: schema.value,
53
- ownerId,
54
- },
55
- update: {},
56
- });
55
+ // Names are unique per owner: reuse the target owner's own same-named
56
+ // tool (what upsert-by-name used to do), never another owner's. A
57
+ // compound unique with a nullable column can't key an upsert, hence
58
+ // findFirst + create.
59
+ const tool = (await db.tool.findFirst({ where: { ownerId, name: eff(t.name) } })) ??
60
+ (await db.tool.create({
61
+ data: {
62
+ name: eff(t.name),
63
+ description: t.description,
64
+ paramsZod: t.paramsZod,
65
+ code: t.code,
66
+ jsonSchema: schema.value,
67
+ ownerId,
68
+ },
69
+ }));
57
70
  toolIdMap.set(t.name, tool.id);
58
71
  toolsCreated++;
59
72
  }
60
73
  // Step 2: Agents
61
74
  const agentIdMap = new Map();
75
+ // Agents this import owns (created now, or already the import owner's):
76
+ // only their attachments are stamped with the owner's consent below.
77
+ const ownedAgentIds = new Set();
62
78
  for (const a of bundle.readAgents()) {
63
79
  if (agentSkipped(a.name))
64
80
  continue;
@@ -74,11 +90,27 @@ export async function createFromBundle(bundle, recon, opts) {
74
90
  timezone: a.timezone,
75
91
  maxTurns: a.maxTurns,
76
92
  scheduleEnabled,
77
- ownerId,
93
+ ownerId: agentOwnerId,
78
94
  },
79
95
  update: {},
80
96
  });
81
97
  agentIdMap.set(a.name, agent.id);
98
+ if (agentOwnerId !== null && agent.ownerId === agentOwnerId) {
99
+ ownedAgentIds.add(agent.id);
100
+ if (opts.publicAgents) {
101
+ await db.resourceGrant.upsert({
102
+ where: {
103
+ resourceType_resourceId_granteeKey: {
104
+ resourceType: "agent",
105
+ resourceId: agent.id,
106
+ granteeKey: EVERYONE_KEY,
107
+ },
108
+ },
109
+ create: everyoneGrantData("agent", agent.id, "execute", "import"),
110
+ update: {},
111
+ });
112
+ }
113
+ }
82
114
  agentsCreated++;
83
115
  }
84
116
  // Step 3: Attach tools
@@ -105,7 +137,26 @@ export async function createFromBundle(bundle, recon, opts) {
105
137
  warnings.push(`agent-tool ${at.agentName}/${at.toolName}: invalid capabilities, skipping attachment`);
106
138
  continue;
107
139
  }
140
+ // Same guard as MCP attach_tool: an existing agent reused by name may
141
+ // already hold a different tool under this name (say a public one), and
142
+ // the runtime dispatches by name. Unlike attach_tool this check-then-
143
+ // upsert is not one Serializable transaction: the importer is an
144
+ // operator-only path, so a concurrent attach racing it is not defended
145
+ // against here (the runner's load-time duplicate check still is).
146
+ const clash = await findSameNamedAttachedTool(db, agentId, { id: toolId, name: eff(at.toolName) });
147
+ if (clash) {
148
+ warnings.push(`agent-tool ${at.agentName}/${at.toolName}: skipped — the agent already has a different tool with the same name (${clash.id})`);
149
+ continue;
150
+ }
108
151
  const caps = capsPatch.data;
152
+ // The importing operator is trusted with the database, so on an agent
153
+ // this import owns it grants the bundle's capabilities in the owner's
154
+ // name (the runner honours them only with that stamp). An existing
155
+ // agent owned by someone else keeps an unstamped, inert attachment.
156
+ const consent = ownedAgentIds.has(agentId) ? agentOwnerId : null;
157
+ if (consent === null) {
158
+ warnings.push(`agent-tool ${at.agentName}/${at.toolName}: attached without capabilities in force — the agent belongs to another owner, who must re-grant them with attach_tool`);
159
+ }
109
160
  await db.agentTool.upsert({
110
161
  where: { agentId_toolId: { agentId, toolId } },
111
162
  create: {
@@ -115,12 +166,15 @@ export async function createFromBundle(bundle, recon, opts) {
115
166
  allowedDatastorePrefixes: caps.allowedDatastorePrefixes ?? [],
116
167
  allowedHosts: caps.allowedHosts ?? [],
117
168
  allowedSharedDatastorePrefixes: caps.allowedSharedDatastorePrefixes ?? {},
169
+ attachedById: agentOwnerId,
170
+ capabilitiesGrantedById: consent,
118
171
  },
119
172
  update: {
120
173
  allowedSecrets: caps.allowedSecrets ?? [],
121
174
  allowedDatastorePrefixes: caps.allowedDatastorePrefixes ?? [],
122
175
  allowedHosts: caps.allowedHosts ?? [],
123
176
  allowedSharedDatastorePrefixes: caps.allowedSharedDatastorePrefixes ?? {},
177
+ capabilitiesGrantedById: consent,
124
178
  },
125
179
  });
126
180
  }
@@ -10,19 +10,19 @@ import { supportedGlobalsFromPrelude } from "./tool-scan.js";
10
10
  import { SANDBOX_PRELUDE } from "../sandbox/prelude.js";
11
11
  import { resolveLlmRegistrations } from "../providers/llm/registration.js";
12
12
  import { RoutingLlmProvider } from "../providers/llm/routing.js";
13
- import { loadProviderConfig } from "../config/providers.js";
13
+ import { loadMcpConfig, loadProviderConfig } from "../config/providers.js";
14
14
  import { buildSecretCipher } from "../providers/secrets/index.js";
15
15
  import { resolvePrincipal } from "../mcp/auth/principal.js";
16
16
  import { loadTransferPrivateKey, transferKeyIdOf } from "../providers/secrets/transfer-envelope.js";
17
17
  import { readFileSync } from "node:fs";
18
18
  export async function runImport(opts) {
19
19
  const env = opts.env ?? process.env;
20
- // Guard: owner XOR public
20
+ // Guard: --owner or --public (or both). --public no longer means
21
+ // owner-less: the imported agents are owned by --owner, or by the
22
+ // importing operator (LOCAL_PRINCIPAL), and shared with everyone at
23
+ // execute (resource-sharing grants spec §3.8).
21
24
  if (opts.owner === null && !opts.isPublic) {
22
- throw new Error("Must specify either --owner or --public (not neither)");
23
- }
24
- if (opts.owner !== null && opts.isPublic) {
25
- throw new Error("Cannot specify both --owner and --public");
25
+ throw new Error("Must specify --owner, --public, or both");
26
26
  }
27
27
  // Open bundle
28
28
  const bundle = openBundle(opts.dir);
@@ -36,10 +36,13 @@ export async function runImport(opts) {
36
36
  // Load existing names from db
37
37
  const existingAgents = await opts.db.agent.findMany({ select: { name: true } });
38
38
  const existingAgentNames = new Set(existingAgents.map((a) => a.name));
39
- const existingTools = await opts.db.tool.findMany({ select: { name: true } });
40
- const existingToolNames = new Set(existingTools.map((t) => t.name));
41
- // For owner-scoped entities (secrets, budgets), load only if we have an owner
39
+ // For owner-scoped entities (tools, secrets, budgets), load only if we have an owner
42
40
  const ownerId = opts.owner !== null && !opts.isPublic ? (await resolvePrincipal(opts.owner, opts.db)).id : null;
41
+ // Tool names are unique per owner (null = the public namespace), so only
42
+ // the target owner's tools can collide; another owner's same-named tool
43
+ // is no conflict.
44
+ const existingTools = await opts.db.tool.findMany({ where: { ownerId }, select: { name: true } });
45
+ const existingToolNames = new Set(existingTools.map((t) => t.name));
43
46
  // Tier-1 capabilities: "budgets" and "shared-datastores" are implemented
44
47
  const capabilitiesSupported = new Set(["budgets", "shared-datastores"]);
45
48
  // Run preflight reconciliation
@@ -84,11 +87,18 @@ export async function runImport(opts) {
84
87
  // Build secret cipher
85
88
  const providerConfig = loadProviderConfig(env);
86
89
  const cipher = buildSecretCipher(providerConfig, env);
90
+ // The imported agents' owner: --owner, or in --public mode the importing
91
+ // operator. Resolved only for a real import (never on --dry-run).
92
+ const agentOwnerId = opts.isPublic
93
+ ? (await resolvePrincipal(opts.owner ?? loadMcpConfig(env).localPrincipal, opts.db)).id
94
+ : ownerId;
87
95
  // Run create
88
96
  const result = await createFromBundle(bundle, recon, {
89
97
  db: opts.db,
90
98
  cipher,
91
99
  ownerId,
100
+ agentOwnerId,
101
+ publicAgents: opts.isPublic,
92
102
  defaultBudget: opts.defaultBudget ?? "10.00",
93
103
  secretMode: effectiveSecretMode,
94
104
  transferPrivateKey,
@@ -8,15 +8,15 @@ export declare const CiphertextSchema: z.ZodObject<{
8
8
  tag: z.ZodString;
9
9
  }, "strip", z.ZodTypeAny, {
10
10
  tag: string;
11
- v: number;
12
11
  alg: string;
12
+ v: number;
13
13
  epk: string;
14
14
  nonce: string;
15
15
  ct: string;
16
16
  }, {
17
17
  tag: string;
18
- v: number;
19
18
  alg: string;
19
+ v: number;
20
20
  epk: string;
21
21
  nonce: string;
22
22
  ct: string;
@@ -46,13 +46,13 @@ export declare const ManifestSchema: z.ZodObject<{
46
46
  capabilities: z.ZodArray<z.ZodString, "many">;
47
47
  counts: z.ZodRecord<z.ZodString, z.ZodNumber>;
48
48
  }, "strip", z.ZodTypeAny, {
49
- capabilities: string[];
50
- bundleVersion: number;
51
49
  source: {
52
50
  product: string;
53
51
  exporterVersion: string;
54
52
  exportedAt: string;
55
53
  };
54
+ capabilities: string[];
55
+ bundleVersion: number;
56
56
  secretMode: "references" | "envelope";
57
57
  transferKeyId: string | null;
58
58
  contentWindowDays: number | null;
@@ -62,13 +62,13 @@ export declare const ManifestSchema: z.ZodObject<{
62
62
  runAuditSince: string | null;
63
63
  counts: Record<string, number>;
64
64
  }, {
65
- capabilities: string[];
66
- bundleVersion: number;
67
65
  source: {
68
66
  product: string;
69
67
  exporterVersion: string;
70
68
  exportedAt: string;
71
69
  };
70
+ capabilities: string[];
71
+ bundleVersion: number;
72
72
  secretMode: "references" | "envelope";
73
73
  counts: Record<string, number>;
74
74
  transferKeyId?: string | null | undefined;
@@ -110,14 +110,14 @@ export declare const NeutralAgentSchema: z.ZodObject<{
110
110
  name: string;
111
111
  model: string;
112
112
  budgetUsd: string;
113
- systemPrompt: string;
113
+ provider: "openai" | "bedrock";
114
114
  kind: "native";
115
+ systemPrompt: string;
115
116
  schedule: string | null;
116
117
  timezone: string;
117
118
  scheduleEnabled: boolean;
118
119
  maxTurns: number;
119
120
  memoryEnabled: boolean;
120
- provider: "openai" | "bedrock";
121
121
  region: string | null;
122
122
  ownerEmail: string | null;
123
123
  unmodeled: {
@@ -129,10 +129,10 @@ export declare const NeutralAgentSchema: z.ZodObject<{
129
129
  name: string;
130
130
  model: string;
131
131
  budgetUsd: string;
132
+ provider: "openai" | "bedrock";
132
133
  systemPrompt: string;
133
134
  scheduleEnabled: boolean;
134
135
  maxTurns: number;
135
- provider: "openai" | "bedrock";
136
136
  kind?: "native" | undefined;
137
137
  schedule?: string | null | undefined;
138
138
  timezone?: string | undefined;
@@ -208,15 +208,15 @@ export declare const NeutralSecretSchema: z.ZodObject<{
208
208
  tag: z.ZodString;
209
209
  }, "strip", z.ZodTypeAny, {
210
210
  tag: string;
211
- v: number;
212
211
  alg: string;
212
+ v: number;
213
213
  epk: string;
214
214
  nonce: string;
215
215
  ct: string;
216
216
  }, {
217
217
  tag: string;
218
- v: number;
219
218
  alg: string;
219
+ v: number;
220
220
  epk: string;
221
221
  nonce: string;
222
222
  ct: string;
@@ -227,23 +227,23 @@ export declare const NeutralSecretSchema: z.ZodObject<{
227
227
  ownerEmail: string | null;
228
228
  ciphertext?: {
229
229
  tag: string;
230
- v: number;
231
230
  alg: string;
231
+ v: number;
232
232
  epk: string;
233
233
  nonce: string;
234
234
  ct: string;
235
235
  } | undefined;
236
236
  }, {
237
237
  name: string;
238
+ description?: string | null | undefined;
238
239
  ciphertext?: {
239
240
  tag: string;
240
- v: number;
241
241
  alg: string;
242
+ v: number;
242
243
  epk: string;
243
244
  nonce: string;
244
245
  ct: string;
245
246
  } | undefined;
246
- description?: string | null | undefined;
247
247
  ownerEmail?: string | null | undefined;
248
248
  }>;
249
249
  export type NeutralSecret = z.infer<typeof NeutralSecretSchema>;
@@ -331,11 +331,11 @@ export declare const NeutralWebhookSchema: z.ZodObject<{
331
331
  agentName: z.ZodString;
332
332
  enabled: z.ZodBoolean;
333
333
  }, "strip", z.ZodTypeAny, {
334
- agentName: string;
335
334
  enabled: boolean;
336
- }, {
337
335
  agentName: string;
336
+ }, {
338
337
  enabled: boolean;
338
+ agentName: string;
339
339
  }>;
340
340
  export type NeutralWebhook = z.infer<typeof NeutralWebhookSchema>;
341
341
  export declare const NeutralBudgetSchema: z.ZodObject<{
@@ -349,8 +349,8 @@ export declare const NeutralBudgetSchema: z.ZodObject<{
349
349
  attachedAgentNames: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
350
350
  }, "strip", z.ZodTypeAny, {
351
351
  name: string;
352
- period: "daily" | "weekly" | "monthly";
353
352
  enabled: boolean;
353
+ period: "daily" | "weekly" | "monthly";
354
354
  ownerEmail: string | null;
355
355
  attachedAgentNames: string[];
356
356
  alertThreshold: string;
@@ -358,8 +358,8 @@ export declare const NeutralBudgetSchema: z.ZodObject<{
358
358
  alertEmails: string[];
359
359
  }, {
360
360
  name: string;
361
- period: "daily" | "weekly" | "monthly";
362
361
  enabled: boolean;
362
+ period: "daily" | "weekly" | "monthly";
363
363
  alertThreshold: string;
364
364
  blockThreshold: string;
365
365
  ownerEmail?: string | null | undefined;
@@ -0,0 +1,13 @@
1
+ export type CheckSeverity = "error" | "warning";
2
+ export type CheckCode = "concept_invalid" | "concept_secret" | "index_missing" | "index_link_broken" | "concept_not_indexed" | "citation_unverifiable" | "citation_stale";
3
+ export interface CheckIssue {
4
+ severity: CheckSeverity;
5
+ code: CheckCode;
6
+ file: string;
7
+ message: string;
8
+ }
9
+ export interface BundleFiles {
10
+ files: Map<string, string>;
11
+ }
12
+ export type RepoFileReader = (repoRelativePath: string) => string | null;
13
+ export declare function checkBundle(bundle: BundleFiles, readRepoFile: RepoFileReader): CheckIssue[];
@@ -0,0 +1,69 @@
1
+ import { redactTokenShapedValues } from "../coding/protocol.js";
2
+ import { parseConcept, RESERVED_BUNDLE_FILES } from "./concept.js";
3
+ import { spanHash } from "./span-hash.js";
4
+ const LINK = /\]\(([^)#\s]+\.md)(?:#[^)\s]*)?\)/g;
5
+ const URL_SCHEME = /^[a-z][a-z0-9+.-]*:/i;
6
+ const baseName = (path) => path.split("/").pop() ?? path;
7
+ function dirOf(path) {
8
+ const cut = path.lastIndexOf("/");
9
+ return cut < 0 ? "" : path.slice(0, cut + 1);
10
+ }
11
+ function normalize(path) {
12
+ const parts = [];
13
+ for (const part of path.split("/")) {
14
+ if (part === "..")
15
+ parts.pop();
16
+ else if (part !== "." && part !== "")
17
+ parts.push(part);
18
+ }
19
+ return parts.join("/");
20
+ }
21
+ export function checkBundle(bundle, readRepoFile) {
22
+ const issues = [];
23
+ const add = (severity, code, file, message) => issues.push({ severity, code, file, message });
24
+ if (!bundle.files.has("index.md"))
25
+ add("error", "index_missing", "index.md", "the bundle has no root index.md");
26
+ const linked = new Set();
27
+ for (const [path, text] of bundle.files) {
28
+ if (redactTokenShapedValues(text) !== text)
29
+ add("error", "concept_secret", path, "contains a secret-shaped value");
30
+ if (baseName(path) !== "index.md")
31
+ continue;
32
+ for (const match of text.matchAll(LINK)) {
33
+ if (URL_SCHEME.test(match[1]))
34
+ continue;
35
+ const target = normalize(match[1].startsWith("/") ? match[1].slice(1) : dirOf(path) + match[1]);
36
+ linked.add(target);
37
+ if (!bundle.files.has(target))
38
+ add("error", "index_link_broken", path, `links to missing ${target}`);
39
+ }
40
+ }
41
+ const fileCache = new Map();
42
+ const read = (p) => {
43
+ if (!fileCache.has(p))
44
+ fileCache.set(p, readRepoFile(p));
45
+ return fileCache.get(p) ?? null;
46
+ };
47
+ for (const [path, text] of bundle.files) {
48
+ const base = path.split("/").pop() ?? path;
49
+ if (!path.endsWith(".md") || RESERVED_BUNDLE_FILES.has(base))
50
+ continue;
51
+ const parsed = parseConcept(path, text);
52
+ if (!parsed.ok) {
53
+ add("error", "concept_invalid", path, parsed.error);
54
+ continue;
55
+ }
56
+ if (!linked.has(path))
57
+ add("warning", "concept_not_indexed", path, "not linked from an index.md");
58
+ for (const citation of parsed.concept.citations) {
59
+ const where = `${citation.path}${citation.lines ? `#L${citation.lines[0]}-L${citation.lines[1]}` : ""}`;
60
+ const source = read(citation.path);
61
+ const actual = source === null ? null : spanHash(source, citation.lines);
62
+ if (actual === null)
63
+ add("warning", "citation_unverifiable", path, `${where} is missing or out of range`);
64
+ else if (actual !== citation.spanHash)
65
+ add("warning", "citation_stale", path, `${where} changed since it was cited`);
66
+ }
67
+ }
68
+ return issues;
69
+ }
@@ -0,0 +1,14 @@
1
+ export declare function parseKnowledgeArgs(args: string[]): {
2
+ dir: string;
3
+ root: string;
4
+ strict: boolean;
5
+ json: boolean;
6
+ };
7
+ /**
8
+ * Every `.md` file under `dir`, keyed by bundle-relative POSIX path. Entry
9
+ * types come from the directory listing itself (no separate stat, so nothing
10
+ * can change between the check and the read), and symbolic links are skipped:
11
+ * a bundle is plain files, and following links could loop or leave the bundle.
12
+ */
13
+ export declare function loadBundle(dir: string): Map<string, string>;
14
+ export declare function knowledgeCommand(args: string[]): Promise<void>;
@@ -0,0 +1,67 @@
1
+ import { readdirSync, readFileSync } from "node:fs";
2
+ import { join, relative, resolve, sep } from "node:path";
3
+ import { parseArgs } from "node:util";
4
+ import { checkBundle } from "./check.js";
5
+ import { DEFAULT_KNOWLEDGE_BUNDLE_PATH } from "./concept.js";
6
+ const USAGE = "usage: wardby knowledge check [dir] [--root <repo root>] [--strict] [--json]";
7
+ export function parseKnowledgeArgs(args) {
8
+ const [sub, ...rest] = args;
9
+ if (sub !== "check")
10
+ throw new Error(USAGE);
11
+ const { values, positionals } = parseArgs({
12
+ args: rest,
13
+ allowPositionals: true,
14
+ options: { root: { type: "string" }, strict: { type: "boolean" }, json: { type: "boolean" } },
15
+ });
16
+ if (positionals.length > 1)
17
+ throw new Error(USAGE);
18
+ return {
19
+ dir: positionals[0] ?? DEFAULT_KNOWLEDGE_BUNDLE_PATH,
20
+ root: values.root ?? ".",
21
+ strict: values.strict ?? false,
22
+ json: values.json ?? false,
23
+ };
24
+ }
25
+ /**
26
+ * Every `.md` file under `dir`, keyed by bundle-relative POSIX path. Entry
27
+ * types come from the directory listing itself (no separate stat, so nothing
28
+ * can change between the check and the read), and symbolic links are skipped:
29
+ * a bundle is plain files, and following links could loop or leave the bundle.
30
+ */
31
+ export function loadBundle(dir) {
32
+ const files = new Map();
33
+ const walk = (current) => {
34
+ for (const entry of readdirSync(current, { withFileTypes: true })) {
35
+ const full = join(current, entry.name);
36
+ if (entry.isDirectory())
37
+ walk(full);
38
+ else if (entry.isFile() && entry.name.endsWith(".md")) {
39
+ files.set(relative(dir, full).split(sep).join("/"), readFileSync(full, "utf8"));
40
+ }
41
+ }
42
+ };
43
+ walk(dir);
44
+ return files;
45
+ }
46
+ export async function knowledgeCommand(args) {
47
+ const options = parseKnowledgeArgs(args);
48
+ const root = resolve(options.root);
49
+ const files = loadBundle(resolve(root, options.dir));
50
+ const issues = checkBundle({ files }, (path) => {
51
+ try {
52
+ return readFileSync(join(root, path), "utf8");
53
+ }
54
+ catch {
55
+ return null;
56
+ }
57
+ });
58
+ if (options.json)
59
+ process.stdout.write(`${JSON.stringify({ issues }, null, 2)}\n`);
60
+ else {
61
+ for (const issue of issues)
62
+ process.stdout.write(`${issue.severity} ${issue.code} ${options.dir}/${issue.file}: ${issue.message}\n`);
63
+ process.stdout.write(`${files.size} files checked, ${issues.filter((i) => i.severity === "error").length} errors, ${issues.filter((i) => i.severity === "warning").length} warnings\n`);
64
+ }
65
+ if (issues.some((i) => i.severity === "error" || (options.strict && i.severity === "warning")))
66
+ process.exitCode = 1;
67
+ }
@@ -0,0 +1,54 @@
1
+ import { z } from "zod";
2
+ export declare const DEFAULT_KNOWLEDGE_BUNDLE_PATH = "docs/knowledge";
3
+ export declare const RESERVED_BUNDLE_FILES: Set<string>;
4
+ declare const CitationSchema: z.ZodObject<{
5
+ id: z.ZodOptional<z.ZodString>;
6
+ repo: z.ZodString;
7
+ path: z.ZodEffects<z.ZodString, string, string>;
8
+ lines: z.ZodOptional<z.ZodEffects<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, [number, number], [number, number]>>;
9
+ symbol: z.ZodOptional<z.ZodString>;
10
+ sha: z.ZodString;
11
+ spanHash: z.ZodString;
12
+ }, "strip", z.ZodTypeAny, {
13
+ path: string;
14
+ repo: string;
15
+ sha: string;
16
+ spanHash: string;
17
+ symbol?: string | undefined;
18
+ id?: string | undefined;
19
+ lines?: [number, number] | undefined;
20
+ }, {
21
+ path: string;
22
+ repo: string;
23
+ sha: string;
24
+ spanHash: string;
25
+ symbol?: string | undefined;
26
+ id?: string | undefined;
27
+ lines?: [number, number] | undefined;
28
+ }>;
29
+ export type KnowledgeCitation = z.infer<typeof CitationSchema>;
30
+ export interface ParsedConcept {
31
+ path: string;
32
+ type: string;
33
+ title?: string;
34
+ description?: string;
35
+ status: "draft" | "stable" | "deprecated";
36
+ roles: string[];
37
+ affects: string[];
38
+ citations: KnowledgeCitation[];
39
+ body: string;
40
+ frontMatter: Record<string, unknown>;
41
+ }
42
+ export type ParseResult = {
43
+ ok: true;
44
+ concept: ParsedConcept;
45
+ } | {
46
+ ok: false;
47
+ error: string;
48
+ };
49
+ export declare function splitFrontMatter(text: string): {
50
+ yaml: string;
51
+ body: string;
52
+ } | null;
53
+ export declare function parseConcept(path: string, text: string): ParseResult;
54
+ export {};