@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.
- package/.env.example +53 -4
- package/README.md +52 -13
- package/dist/claude-coding-worker/driver.d.ts +6 -1
- package/dist/claude-coding-worker/driver.js +27 -1
- package/dist/claude-coding-worker/main.js +2 -0
- package/dist/claude-coding-worker/tool-socket.d.ts +9 -0
- package/dist/claude-coding-worker/tool-socket.js +26 -0
- package/dist/cli-help.d.ts +1 -1
- package/dist/cli-help.js +14 -4
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +284 -36
- package/dist/coding/base-commit.d.ts +6 -0
- package/dist/coding/base-commit.js +12 -0
- package/dist/coding/collect-exclude.d.ts +25 -0
- package/dist/coding/collect-exclude.js +76 -0
- package/dist/coding/profile.d.ts +67 -22
- package/dist/coding/profile.js +58 -25
- package/dist/coding/protected-path-wording.d.ts +24 -0
- package/dist/coding/protected-path-wording.js +55 -0
- package/dist/coding/protected-paths.d.ts +31 -0
- package/dist/coding/protected-paths.js +48 -0
- package/dist/coding/protocol.d.ts +91 -4
- package/dist/coding/protocol.js +123 -12
- package/dist/coding/provider.d.ts +6 -1
- package/dist/coding/provider.js +16 -9
- package/dist/coding/registry/adapters.d.ts +2 -0
- package/dist/coding/registry/adapters.js +9 -0
- package/dist/coding/registry/allowlist.d.ts +9 -0
- package/dist/coding/registry/allowlist.js +28 -0
- package/dist/coding/registry/json-scan.d.ts +55 -0
- package/dist/coding/registry/json-scan.js +191 -0
- package/dist/coding/registry/lockfiles.d.ts +6 -0
- package/dist/coding/registry/lockfiles.js +89 -0
- package/dist/coding/registry/npm-lockfile.d.ts +9 -0
- package/dist/coding/registry/npm-lockfile.js +73 -0
- package/dist/coding/registry/npm-plan.d.ts +29 -0
- package/dist/coding/registry/npm-plan.js +289 -0
- package/dist/coding/registry/npm.d.ts +7 -0
- package/dist/coding/registry/npm.js +252 -0
- package/dist/coding/registry/pypi.d.ts +4 -0
- package/dist/coding/registry/pypi.js +210 -0
- package/dist/coding/registry/report.d.ts +37 -0
- package/dist/coding/registry/report.js +31 -0
- package/dist/coding/registry/token.d.ts +4 -0
- package/dist/coding/registry/token.js +7 -0
- package/dist/coding/registry/types.d.ts +286 -0
- package/dist/coding/registry/types.js +19 -0
- package/dist/coding/registry/worker-config.d.ts +14 -0
- package/dist/coding/registry/worker-config.js +31 -0
- package/dist/coding/services/builtins.d.ts +22 -0
- package/dist/coding/services/builtins.js +85 -0
- package/dist/coding/services/catalog.d.ts +443 -0
- package/dist/coding/services/catalog.js +159 -0
- package/dist/coding/services/declaration.d.ts +11 -0
- package/dist/coding/services/declaration.js +114 -0
- package/dist/coding/services/note.d.ts +8 -0
- package/dist/coding/services/note.js +15 -0
- package/dist/coding/services/resolve.d.ts +25 -0
- package/dist/coding/services/resolve.js +50 -0
- package/dist/coding/services/wording.d.ts +25 -0
- package/dist/coding/services/wording.js +70 -0
- package/dist/coding-proxy/main.js +24 -4
- package/dist/coding-worker/artifact.d.ts +6 -0
- package/dist/coding-worker/debug-trace.d.ts +37 -0
- package/dist/coding-worker/debug-trace.js +117 -0
- package/dist/coding-worker/driver.d.ts +13 -1
- package/dist/coding-worker/driver.js +102 -13
- package/dist/coding-worker/errors.js +8 -0
- package/dist/coding-worker/main.js +10 -2
- package/dist/coding-worker/sdk.d.ts +2 -2
- package/dist/coding-worker/sdk.js +7 -2
- package/dist/coding-worker/types.d.ts +3 -0
- package/dist/config/providers.d.ts +66 -0
- package/dist/config/providers.js +137 -0
- package/dist/core/attribution.d.ts +101 -0
- package/dist/core/attribution.js +208 -0
- package/dist/core/budget-groups.d.ts +120 -10
- package/dist/core/budget-groups.js +133 -24
- package/dist/core/budget-wording.d.ts +22 -0
- package/dist/core/budget-wording.js +55 -0
- package/dist/core/coding-queue.d.ts +3 -0
- package/dist/core/coding-queue.js +6 -2
- package/dist/core/coding-service-status.d.ts +11 -0
- package/dist/core/coding-service-status.js +17 -0
- package/dist/core/cost-report.d.ts +88 -0
- package/dist/core/cost-report.js +248 -0
- package/dist/core/datastores.js +18 -2
- package/dist/core/db.d.ts +5 -1
- package/dist/core/db.js +8 -2
- package/dist/core/dispatch.d.ts +74 -7
- package/dist/core/dispatch.js +382 -47
- package/dist/core/engine-native.js +44 -14
- package/dist/core/glob.d.ts +10 -0
- package/dist/core/glob.js +33 -0
- package/dist/core/grants.d.ts +86 -0
- package/dist/core/grants.js +126 -0
- package/dist/core/host-events.d.ts +72 -0
- package/dist/core/host-events.js +597 -0
- package/dist/core/host-identity-links.d.ts +54 -0
- package/dist/core/host-identity-links.js +189 -0
- package/dist/core/host-status.d.ts +78 -0
- package/dist/core/host-status.js +228 -0
- package/dist/core/in-flight-runs.d.ts +8 -0
- package/dist/core/in-flight-runs.js +56 -0
- package/dist/core/issue-bridge.d.ts +60 -0
- package/dist/core/issue-bridge.js +189 -0
- package/dist/core/issue-dedupe.d.ts +70 -0
- package/dist/core/issue-dedupe.js +255 -0
- package/dist/core/issue-events.d.ts +42 -0
- package/dist/core/issue-events.js +155 -0
- package/dist/core/issue-status.d.ts +29 -0
- package/dist/core/issue-status.js +241 -0
- package/dist/core/issue-tracker-tools.d.ts +64 -0
- package/dist/core/issue-tracker-tools.js +850 -0
- package/dist/core/model-usage.d.ts +10 -0
- package/dist/core/model-usage.js +24 -0
- package/dist/core/provider-wording.d.ts +12 -0
- package/dist/core/provider-wording.js +44 -0
- package/dist/core/reconciler.d.ts +42 -2
- package/dist/core/reconciler.js +97 -2
- package/dist/core/repo-access.d.ts +99 -0
- package/dist/core/repo-access.js +136 -0
- package/dist/core/review-host-checks.d.ts +11 -0
- package/dist/core/review-host-checks.js +41 -0
- package/dist/core/review-host-tools.d.ts +47 -0
- package/dist/core/review-host-tools.js +354 -0
- package/dist/core/run-heartbeat.d.ts +27 -0
- package/dist/core/run-heartbeat.js +54 -0
- package/dist/core/run-pricing.d.ts +61 -0
- package/dist/core/run-pricing.js +56 -0
- package/dist/core/runner.d.ts +33 -8
- package/dist/core/runner.js +410 -62
- package/dist/core/scheduler.d.ts +4 -1
- package/dist/core/scheduler.js +3 -2
- package/dist/core/secrets.d.ts +11 -2
- package/dist/core/secrets.js +25 -6
- package/dist/core/self-defects.d.ts +80 -0
- package/dist/core/self-defects.js +180 -0
- package/dist/core/subagent-memory-tools.d.ts +1 -1
- package/dist/core/subagent-memory-tools.js +16 -3
- package/dist/core/tool-admin.d.ts +81 -0
- package/dist/core/tool-admin.js +129 -0
- package/dist/core/tool-names.d.ts +42 -0
- package/dist/core/tool-names.js +67 -0
- package/dist/core/untrusted-content.d.ts +32 -0
- package/dist/core/untrusted-content.js +72 -0
- package/dist/core/webhooks.d.ts +17 -2
- package/dist/core/webhooks.js +42 -3
- package/dist/generated/prisma/browser.d.ts +166 -0
- package/dist/generated/prisma/client.d.ts +166 -0
- package/dist/generated/prisma/commonInputTypes.d.ts +152 -52
- package/dist/generated/prisma/enums.d.ts +13 -0
- package/dist/generated/prisma/enums.js +12 -1
- package/dist/generated/prisma/internal/class.d.ts +242 -0
- package/dist/generated/prisma/internal/class.js +4 -4
- package/dist/generated/prisma/internal/prismaNamespace.d.ts +2571 -577
- package/dist/generated/prisma/internal/prismaNamespace.js +312 -6
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.d.ts +328 -0
- package/dist/generated/prisma/internal/prismaNamespaceBrowser.js +312 -6
- package/dist/generated/prisma/models/Agent.d.ts +682 -1
- package/dist/generated/prisma/models/AgentIssueProject.d.ts +1838 -0
- package/dist/generated/prisma/models/AgentIssueProject.js +1 -0
- package/dist/generated/prisma/models/AgentRepository.d.ts +1425 -0
- package/dist/generated/prisma/models/AgentRepository.js +1 -0
- package/dist/generated/prisma/models/AgentTool.d.ts +95 -1
- package/dist/generated/prisma/models/AuthUser.d.ts +56 -1
- package/dist/generated/prisma/models/CodingAgentProfile.d.ts +258 -7
- package/dist/generated/prisma/models/CodingProxySession.d.ts +195 -2
- package/dist/generated/prisma/models/CodingRun.d.ts +1405 -95
- package/dist/generated/prisma/models/CodingRunServiceStatus.d.ts +1404 -0
- package/dist/generated/prisma/models/CodingRunServiceStatus.js +1 -0
- package/dist/generated/prisma/models/CodingService.d.ts +1348 -0
- package/dist/generated/prisma/models/CodingService.js +1 -0
- package/dist/generated/prisma/models/HostEventDelivery.d.ts +946 -0
- package/dist/generated/prisma/models/HostEventDelivery.js +1 -0
- package/dist/generated/prisma/models/HostIdentity.d.ts +1232 -0
- package/dist/generated/prisma/models/HostIdentity.js +1 -0
- package/dist/generated/prisma/models/HostIdentityLinkRequest.d.ts +1473 -0
- package/dist/generated/prisma/models/HostIdentityLinkRequest.js +1 -0
- package/dist/generated/prisma/models/IssueFingerprint.d.ts +1183 -0
- package/dist/generated/prisma/models/IssueFingerprint.js +1 -0
- package/dist/generated/prisma/models/IssuePullRequest.d.ts +1255 -0
- package/dist/generated/prisma/models/IssuePullRequest.js +1 -0
- package/dist/generated/prisma/models/ModelCatalogEntry.d.ts +1322 -0
- package/dist/generated/prisma/models/ModelCatalogEntry.js +1 -0
- package/dist/generated/prisma/models/Principal.d.ts +455 -0
- package/dist/generated/prisma/models/RegistryAllowance.d.ts +1148 -0
- package/dist/generated/prisma/models/RegistryAllowance.js +1 -0
- package/dist/generated/prisma/models/RegistryApprovedVersion.d.ts +1219 -0
- package/dist/generated/prisma/models/RegistryApprovedVersion.js +1 -0
- package/dist/generated/prisma/models/RegistryFetch.d.ts +1428 -0
- package/dist/generated/prisma/models/RegistryFetch.js +1 -0
- package/dist/generated/prisma/models/RegistryPlanRefusal.d.ts +1294 -0
- package/dist/generated/prisma/models/RegistryPlanRefusal.js +1 -0
- package/dist/generated/prisma/models/RegistryVersionFact.d.ts +1085 -0
- package/dist/generated/prisma/models/RegistryVersionFact.js +1 -0
- package/dist/generated/prisma/models/ResourceGrant.d.ts +1437 -0
- package/dist/generated/prisma/models/ResourceGrant.js +1 -0
- package/dist/generated/prisma/models/Run.d.ts +1402 -82
- package/dist/generated/prisma/models/RunAttribution.d.ts +1259 -0
- package/dist/generated/prisma/models/RunAttribution.js +1 -0
- package/dist/generated/prisma/models/RunHostCheck.d.ts +1239 -0
- package/dist/generated/prisma/models/RunHostCheck.js +1 -0
- package/dist/generated/prisma/models/RunHostStatus.d.ts +1315 -0
- package/dist/generated/prisma/models/RunHostStatus.js +1 -0
- package/dist/generated/prisma/models/RunIssueStatus.d.ts +1199 -0
- package/dist/generated/prisma/models/RunIssueStatus.js +1 -0
- package/dist/generated/prisma/models/RunModelUsage.d.ts +1316 -0
- package/dist/generated/prisma/models/RunModelUsage.js +1 -0
- package/dist/generated/prisma/models/Tool.d.ts +15 -3
- package/dist/generated/prisma/models/WorkItem.d.ts +1408 -0
- package/dist/generated/prisma/models/WorkItem.js +1 -0
- package/dist/generated/prisma/models.d.ts +22 -0
- package/dist/help/build.d.ts +1 -0
- package/dist/help/build.js +9 -0
- package/dist/help/catalog.d.ts +24 -0
- package/dist/help/catalog.js +160 -0
- package/dist/help/cli.d.ts +2 -0
- package/dist/help/cli.js +65 -0
- package/dist/help/runtime.d.ts +3 -0
- package/dist/help/runtime.js +44 -0
- package/dist/help/search.d.ts +9 -0
- package/dist/help/search.js +104 -0
- package/dist/help-index.json +999 -0
- package/dist/import/cli-args.js +3 -2
- package/dist/import/create.d.ts +5 -0
- package/dist/import/create.js +67 -13
- package/dist/import/index.js +19 -9
- package/dist/import/neutral-schema.d.ts +18 -18
- package/dist/knowledge/check.d.ts +13 -0
- package/dist/knowledge/check.js +69 -0
- package/dist/knowledge/cli.d.ts +14 -0
- package/dist/knowledge/cli.js +67 -0
- package/dist/knowledge/concept.d.ts +54 -0
- package/dist/knowledge/concept.js +78 -0
- package/dist/knowledge/note.d.ts +11 -0
- package/dist/knowledge/note.js +39 -0
- package/dist/knowledge/relevance.d.ts +11 -0
- package/dist/knowledge/relevance.js +14 -0
- package/dist/knowledge/span-hash.d.ts +3 -0
- package/dist/knowledge/span-hash.js +16 -0
- package/dist/mcp/auth/access.d.ts +72 -0
- package/dist/mcp/auth/access.js +58 -0
- package/dist/mcp/auth/grants-cli.d.ts +149 -0
- package/dist/mcp/auth/grants-cli.js +518 -0
- package/dist/mcp/auth/host-account-cli.d.ts +2 -0
- package/dist/mcp/auth/host-account-cli.js +47 -0
- package/dist/mcp/auth/ownership.d.ts +25 -51
- package/dist/mcp/auth/ownership.js +19 -14
- package/dist/mcp/auth/repo-authorization.d.ts +22 -0
- package/dist/mcp/auth/repo-authorization.js +51 -0
- package/dist/mcp/auth/resource-server.d.ts +33 -2
- package/dist/mcp/auth/resource-server.js +99 -3
- package/dist/mcp/auth/self-hosted/browser.js +2 -2
- package/dist/mcp/auth/self-hosted/cli.js +47 -13
- package/dist/mcp/auth/self-hosted/credentials.d.ts +23 -5
- package/dist/mcp/auth/self-hosted/credentials.js +62 -4
- package/dist/mcp/auth/self-hosted/session.d.ts +7 -6
- package/dist/mcp/context.d.ts +30 -1
- package/dist/mcp/errors.d.ts +25 -6
- package/dist/mcp/errors.js +98 -0
- package/dist/mcp/host-events/deliveries.d.ts +9 -0
- package/dist/mcp/host-events/deliveries.js +17 -0
- package/dist/mcp/host-events/github-ingress.d.ts +38 -0
- package/dist/mcp/host-events/github-ingress.js +83 -0
- package/dist/mcp/host-events/github-user-callback.d.ts +18 -0
- package/dist/mcp/host-events/github-user-callback.js +50 -0
- package/dist/mcp/host-events/jira-ingress.d.ts +29 -0
- package/dist/mcp/host-events/jira-ingress.js +92 -0
- package/dist/mcp/index.d.ts +10 -1
- package/dist/mcp/index.js +187 -19
- package/dist/mcp/server.js +32 -11
- package/dist/mcp/tools/agents.js +519 -50
- package/dist/mcp/tools/budget-groups.js +3 -3
- package/dist/mcp/tools/cost-report.d.ts +8 -0
- package/dist/mcp/tools/cost-report.js +60 -0
- package/dist/mcp/tools/datastore.js +22 -15
- package/dist/mcp/tools/grants.d.ts +2 -0
- package/dist/mcp/tools/grants.js +239 -0
- package/dist/mcp/tools/help.d.ts +5 -0
- package/dist/mcp/tools/help.js +67 -0
- package/dist/mcp/tools/host-accounts.d.ts +2 -0
- package/dist/mcp/tools/host-accounts.js +114 -0
- package/dist/mcp/tools/issue-projects.d.ts +2 -0
- package/dist/mcp/tools/issue-projects.js +238 -0
- package/dist/mcp/tools/memory.d.ts +7 -1
- package/dist/mcp/tools/memory.js +5 -5
- package/dist/mcp/tools/model-catalog.d.ts +22 -0
- package/dist/mcp/tools/model-catalog.js +423 -0
- package/dist/mcp/tools/repositories.d.ts +2 -0
- package/dist/mcp/tools/repositories.js +182 -0
- package/dist/mcp/tools/runs.d.ts +6 -0
- package/dist/mcp/tools/runs.js +60 -6
- package/dist/mcp/tools/scheduling.js +3 -6
- package/dist/mcp/tools/secrets.js +18 -6
- package/dist/mcp/tools/services.d.ts +2 -0
- package/dist/mcp/tools/services.js +222 -0
- package/dist/mcp/tools/subagents.js +52 -16
- package/dist/mcp/tools/tools.d.ts +41 -0
- package/dist/mcp/tools/tools.js +201 -40
- package/dist/mcp/tools/trigger.js +65 -7
- package/dist/mcp/tools/webhooks.js +15 -4
- package/dist/mcp/transport/streamable-http.d.ts +15 -0
- package/dist/mcp/transport/streamable-http.js +55 -3
- package/dist/mcp/webhooks/ingress.d.ts +2 -1
- package/dist/mcp/webhooks/ingress.js +9 -2
- package/dist/providers/auth/delegating.d.ts +19 -0
- package/dist/providers/auth/delegating.js +71 -0
- package/dist/providers/auth/index.d.ts +2 -0
- package/dist/providers/auth/index.js +11 -0
- package/dist/providers/auth/self-hosted.d.ts +10 -2
- package/dist/providers/auth/self-hosted.js +55 -6
- package/dist/providers/auth/types.d.ts +6 -0
- package/dist/providers/coding-proxy/memory-ledger.d.ts +4 -1
- package/dist/providers/coding-proxy/memory-ledger.js +31 -3
- package/dist/providers/coding-proxy/metering.d.ts +6 -1
- package/dist/providers/coding-proxy/metering.js +41 -4
- package/dist/providers/coding-proxy/prisma-ledger.d.ts +17 -0
- package/dist/providers/coding-proxy/prisma-ledger.js +106 -8
- package/dist/providers/coding-proxy/proxy.d.ts +25 -2
- package/dist/providers/coding-proxy/proxy.js +561 -38
- package/dist/providers/coding-proxy/registry/audit.d.ts +131 -0
- package/dist/providers/coding-proxy/registry/audit.js +380 -0
- package/dist/providers/coding-proxy/registry/bounded-fetch.d.ts +16 -0
- package/dist/providers/coding-proxy/registry/bounded-fetch.js +77 -0
- package/dist/providers/coding-proxy/registry/plan.d.ts +58 -0
- package/dist/providers/coding-proxy/registry/plan.js +304 -0
- package/dist/providers/coding-proxy/registry/prisma-store.d.ts +34 -0
- package/dist/providers/coding-proxy/registry/prisma-store.js +151 -0
- package/dist/providers/coding-proxy/registry/service.d.ts +213 -0
- package/dist/providers/coding-proxy/registry/service.js +1137 -0
- package/dist/providers/coding-proxy/registry/store.d.ts +127 -0
- package/dist/providers/coding-proxy/registry/store.js +70 -0
- package/dist/providers/coding-proxy/runtime.d.ts +17 -0
- package/dist/providers/coding-proxy/runtime.js +63 -0
- package/dist/providers/coding-proxy/secure-fetch.js +0 -1
- package/dist/providers/coding-proxy/server.d.ts +11 -0
- package/dist/providers/coding-proxy/server.js +163 -0
- package/dist/providers/coding-proxy/types.d.ts +33 -1
- package/dist/providers/coding-proxy/types.js +12 -1
- package/dist/providers/engine/types.d.ts +29 -0
- package/dist/providers/executor/build.d.ts +2 -2
- package/dist/providers/executor/composition.d.ts +3 -0
- package/dist/providers/executor/composition.js +28 -1
- package/dist/providers/executor/container.d.ts +134 -4
- package/dist/providers/executor/container.js +394 -37
- package/dist/providers/executor/dbos.d.ts +4 -3
- package/dist/providers/executor/dbos.js +7 -5
- package/dist/providers/executor/in-process.d.ts +2 -3
- package/dist/providers/executor/routing.d.ts +13 -0
- package/dist/providers/executor/routing.js +18 -0
- package/dist/providers/executor/types.d.ts +34 -0
- package/dist/providers/issue-tracker/adf.d.ts +31 -0
- package/dist/providers/issue-tracker/adf.js +181 -0
- package/dist/providers/issue-tracker/index.d.ts +5 -0
- package/dist/providers/issue-tracker/index.js +12 -0
- package/dist/providers/issue-tracker/jira-client.d.ts +41 -0
- package/dist/providers/issue-tracker/jira-client.js +151 -0
- package/dist/providers/issue-tracker/jira-events.d.ts +3 -0
- package/dist/providers/issue-tracker/jira-events.js +98 -0
- package/dist/providers/issue-tracker/jira.d.ts +116 -0
- package/dist/providers/issue-tracker/jira.js +502 -0
- package/dist/providers/issue-tracker/types.d.ts +269 -0
- package/dist/providers/issue-tracker/types.js +16 -0
- package/dist/providers/jobs/claude-tool-setup.d.ts +23 -0
- package/dist/providers/jobs/claude-tool-setup.js +50 -0
- package/dist/providers/jobs/collect-prune.d.ts +7 -0
- package/dist/providers/jobs/collect-prune.js +27 -0
- package/dist/providers/jobs/docker-isolation.d.ts +48 -3
- package/dist/providers/jobs/docker-isolation.js +213 -22
- package/dist/providers/jobs/docker-services.d.ts +35 -0
- package/dist/providers/jobs/docker-services.js +191 -0
- package/dist/providers/jobs/docker.d.ts +53 -2
- package/dist/providers/jobs/docker.js +307 -32
- package/dist/providers/jobs/fake-kubernetes-api.d.ts +1 -0
- package/dist/providers/jobs/fake-kubernetes-api.js +12 -3
- package/dist/providers/jobs/kubernetes-isolation.d.ts +17 -2
- package/dist/providers/jobs/kubernetes-isolation.js +238 -57
- package/dist/providers/jobs/kubernetes-platform.d.ts +10 -4
- package/dist/providers/jobs/kubernetes-platform.js +11 -5
- package/dist/providers/jobs/kubernetes-preflight.js +3 -0
- package/dist/providers/jobs/kubernetes.d.ts +24 -2
- package/dist/providers/jobs/kubernetes.js +153 -22
- package/dist/providers/jobs/service-state.d.ts +22 -0
- package/dist/providers/jobs/service-state.js +17 -0
- package/dist/providers/jobs/types.d.ts +18 -0
- package/dist/providers/llm/anthropic.d.ts +3 -3
- package/dist/providers/llm/anthropic.js +3 -5
- package/dist/providers/llm/bedrock.d.ts +3 -3
- package/dist/providers/llm/bedrock.js +3 -8
- package/dist/providers/llm/catalog-lookup.d.ts +10 -0
- package/dist/providers/llm/catalog-lookup.js +15 -0
- package/dist/providers/llm/catalog-shipped.d.ts +18 -0
- package/dist/providers/llm/catalog-shipped.js +197 -0
- package/dist/providers/llm/catalog-store.d.ts +58 -0
- package/dist/providers/llm/catalog-store.js +138 -0
- package/dist/providers/llm/catalog-types.d.ts +66 -0
- package/dist/providers/llm/catalog-types.js +64 -0
- package/dist/providers/llm/catalog.d.ts +61 -0
- package/dist/providers/llm/catalog.js +147 -0
- package/dist/providers/llm/claude-messages.d.ts +5 -1
- package/dist/providers/llm/claude-messages.js +1 -0
- package/dist/providers/llm/claude-provider.d.ts +10 -12
- package/dist/providers/llm/claude-provider.js +15 -6
- package/dist/providers/llm/index.d.ts +9 -6
- package/dist/providers/llm/index.js +8 -5
- package/dist/providers/llm/openai.d.ts +14 -5
- package/dist/providers/llm/openai.js +24 -14
- package/dist/providers/llm/pricing-core.d.ts +5 -3
- package/dist/providers/llm/registration.js +8 -12
- package/dist/providers/llm/routing.d.ts +21 -11
- package/dist/providers/llm/routing.js +47 -13
- package/dist/providers/llm/types.d.ts +12 -0
- package/dist/providers/llm/types.js +8 -1
- package/dist/providers/review-host/diff-lines.d.ts +16 -0
- package/dist/providers/review-host/diff-lines.js +59 -0
- package/dist/providers/review-host/github-events.d.ts +6 -0
- package/dist/providers/review-host/github-events.js +226 -0
- package/dist/providers/review-host/github-user-auth.d.ts +38 -0
- package/dist/providers/review-host/github-user-auth.js +128 -0
- package/dist/providers/review-host/github.d.ts +57 -0
- package/dist/providers/review-host/github.js +568 -0
- package/dist/providers/review-host/index.d.ts +12 -0
- package/dist/providers/review-host/index.js +30 -0
- package/dist/providers/review-host/review-format.d.ts +19 -0
- package/dist/providers/review-host/review-format.js +59 -0
- package/dist/providers/review-host/types.d.ts +309 -0
- package/dist/providers/review-host/types.js +24 -0
- package/dist/providers/vcs/git.d.ts +16 -6
- package/dist/providers/vcs/git.js +78 -34
- package/dist/providers/vcs/github.d.ts +94 -3
- package/dist/providers/vcs/github.js +223 -17
- package/dist/providers/vcs/types.d.ts +48 -4
- package/dist/quickstart/index.d.ts +2 -0
- package/dist/quickstart/index.js +36 -8
- package/dist/sandbox/fetch-policy.d.ts +20 -2
- package/dist/sandbox/fetch-policy.js +64 -3
- package/dist/sandbox/host-functions.d.ts +9 -1
- package/dist/sandbox/host-functions.js +12 -5
- package/dist/serve.js +8 -2
- package/dist/viewer/api-schema.d.ts +2757 -0
- package/dist/viewer/api-schema.js +165 -0
- package/dist/viewer/build-schemas.d.ts +2 -0
- package/dist/viewer/build-schemas.js +18 -0
- package/dist/viewer/event-bus.d.ts +38 -0
- package/dist/viewer/event-bus.js +232 -0
- package/dist/viewer/graph.d.ts +40 -0
- package/dist/viewer/graph.js +243 -0
- package/dist/viewer/http.d.ts +30 -0
- package/dist/viewer/http.js +133 -0
- package/dist/viewer/run-detail.d.ts +4 -0
- package/dist/viewer/run-detail.js +61 -0
- package/dist/wardby-bin.js +11 -0
- package/docs/README.md +40 -0
- package/docs/agent-recipes.md +383 -0
- package/docs/architecture-runtime.md +90 -0
- package/docs/assets/brand/wardby-icon-512.png +0 -0
- package/docs/assets/brand/wardby-icon.svg +16 -0
- package/docs/assets/brand/wardby-mascot-profile-512.png +0 -0
- package/docs/assets/brand/wardby-mascot.png +0 -0
- package/docs/assets/brand/wardby-mascot.svg +5 -0
- package/docs/assets/wardby-workflow.svg +106 -0
- package/docs/code-review-agents.md +508 -0
- package/docs/coding-agent-setup.md +175 -0
- package/docs/coding-packages.md +455 -0
- package/docs/coding-services.md +300 -0
- package/docs/coding-worker-byo-images.md +98 -0
- package/docs/coding-worker-isolation.md +1068 -0
- package/docs/getting-started-gke.md +632 -0
- package/docs/getting-started-identity-provider.md +319 -0
- package/docs/getting-started.md +147 -0
- package/docs/jira-agents.md +649 -0
- package/docs/knowledge.md +387 -0
- package/docs/models.md +221 -0
- package/docs/observability.md +53 -0
- package/docs/release-verification.md +66 -0
- package/docs/security-deployment.md +667 -0
- package/docs/viewer-api.md +142 -0
- package/help/admin-viewer.md +39 -0
- package/help/agent-recipes.md +173 -0
- package/help/architecture-agent.md +189 -0
- package/help/builder-agent.md +80 -0
- package/help/code-review-agents.md +37 -0
- package/help/coding-packages.md +31 -0
- package/help/coding-services.md +71 -0
- package/help/cost-attribution.md +67 -0
- package/help/creating-agents.md +90 -0
- package/help/deploy-gke.md +45 -0
- package/help/deployment-targets.md +39 -0
- package/help/errors/budget-group-exhausted.md +25 -0
- package/help/errors/docker-isolation-unsupported.md +26 -0
- package/help/errors/model-unavailable.md +63 -0
- package/help/errors/protected-path.md +45 -0
- package/help/errors/repo-access.md +27 -0
- package/help/errors/service-declaration-invalid.md +27 -0
- package/help/errors/service-declaration-unavailable.md +25 -0
- package/help/errors/service-launcher-unsupported.md +30 -0
- package/help/errors/service-not-allowed.md +27 -0
- package/help/errors/service-unknown.md +23 -0
- package/help/errors/service-unready.md +49 -0
- package/help/getting-started.md +32 -0
- package/help/github.md +48 -0
- package/help/identity-and-access.md +44 -0
- package/help/jira.md +135 -0
- package/help/knowledge.md +47 -0
- package/help/mcp.md +30 -0
- package/help/models.md +90 -0
- package/help/native-capabilities.md +30 -0
- package/help/observability.md +41 -0
- package/help/operating-agents.md +36 -0
- package/help/security.md +27 -0
- package/help/troubleshooting/budgets.md +32 -0
- package/help/troubleshooting/coding-workers.md +47 -0
- package/help/troubleshooting/repository-access.md +27 -0
- package/package.json +14 -3
- package/prisma/migrations/20260925010000_coding_collect_exclude/migration.sql +8 -0
- package/prisma/migrations/20260925015000_allowed_egress_default/migration.sql +8 -0
- package/prisma/migrations/20260925020000_coding_package_registry/migration.sql +55 -0
- package/prisma/migrations/20260925030000_tool_name_per_owner/migration.sql +11 -0
- package/prisma/migrations/20260926010000_run_trigger_host_event/migration.sql +7 -0
- package/prisma/migrations/20260926020000_code_review_hosts/migration.sql +53 -0
- package/prisma/migrations/20260926030000_auth_user_roles/migration.sql +9 -0
- package/prisma/migrations/20260926040000_agent_effort/migration.sql +6 -0
- package/prisma/migrations/20260926050000_registry_lockfile_plan/migration.sql +32 -0
- package/prisma/migrations/20260926050000_repo_access_authorization/migration.sql +82 -0
- package/prisma/migrations/20260926060000_registry_plan_refusal/migration.sql +19 -0
- package/prisma/migrations/20260926100000_registry_plan_refusal_published_at/migration.sql +5 -0
- package/prisma/migrations/20260926190000_run_host_status/migration.sql +18 -0
- package/prisma/migrations/20260926210000_run_host_status_at_dispatch/migration.sql +5 -0
- package/prisma/migrations/20260927010000_resource_grants/migration.sql +72 -0
- package/prisma/migrations/20260927020000_proxy_session_budget_exhausted/migration.sql +3 -0
- package/prisma/migrations/20260927030000_coding_debug_trace/migration.sql +4 -0
- package/prisma/migrations/20260927040000_proxy_session_upstream_failure/migration.sql +3 -0
- package/prisma/migrations/20260927050000_coding_run_services/migration.sql +74 -0
- package/prisma/migrations/20260928000000_coding_run_tool_image/migration.sql +5 -0
- package/prisma/migrations/20260930000000_jira_issue_projects/migration.sql +34 -0
- package/prisma/migrations/20261001000000_jira_phase2_allowlists/migration.sql +3 -0
- package/prisma/migrations/20261001010000_jira_link_types_allowlist/migration.sql +2 -0
- package/prisma/migrations/20261002000000_jira_coding_bridge/migration.sql +28 -0
- package/prisma/migrations/20261002010000_jira_issue_creation/migration.sql +25 -0
- package/prisma/migrations/20261003000000_issue_cost_attribution/migration.sql +56 -0
- package/prisma/migrations/20261003010000_coding_run_service_status/migration.sql +23 -0
- package/prisma/migrations/20261003020000_viewer_notify/migration.sql +54 -0
- package/prisma/migrations/20261003030000_viewer_notify_fixes/migration.sql +47 -0
- package/prisma/migrations/20261003040000_viewer_indexes/migration.sql +12 -0
- package/prisma/migrations/20261004000000_model_catalog/migration.sql +26 -0
- package/prisma/schema.prisma +663 -21
- package/dist/mcp/tools/models.d.ts +0 -8
- package/dist/mcp/tools/models.js +0 -15
- package/dist/providers/llm/pricing-anthropic.d.ts +0 -4
- package/dist/providers/llm/pricing-anthropic.js +0 -30
- package/dist/providers/llm/pricing-bedrock-claude.d.ts +0 -12
- package/dist/providers/llm/pricing-bedrock-claude.js +0 -37
- package/dist/providers/llm/pricing.d.ts +0 -30
- package/dist/providers/llm/pricing.js +0 -74
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { parse as parseYaml } from "yaml";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export const DEFAULT_KNOWLEDGE_BUNDLE_PATH = "docs/knowledge";
|
|
4
|
+
export const RESERVED_BUNDLE_FILES = new Set(["index.md", "log.md"]);
|
|
5
|
+
const CitationSchema = z.object({
|
|
6
|
+
id: z.string().min(1).optional(),
|
|
7
|
+
repo: z.string().min(1),
|
|
8
|
+
path: z
|
|
9
|
+
.string()
|
|
10
|
+
.min(1)
|
|
11
|
+
.refine((p) => !p.startsWith("/") && !p.split("/").includes(".."), "path must be repo-relative"),
|
|
12
|
+
lines: z
|
|
13
|
+
.tuple([z.number().int().min(1), z.number().int().min(1)])
|
|
14
|
+
.refine(([a, b]) => b >= a, "lines must be [start, end] with end >= start")
|
|
15
|
+
.optional(),
|
|
16
|
+
symbol: z.string().min(1).optional(),
|
|
17
|
+
sha: z.string().regex(/^[0-9a-f]{40}$/, "sha must be a full 40-hex commit"),
|
|
18
|
+
spanHash: z.string().regex(/^sha256:[0-9a-f]{64}$/, "spanHash must be sha256:<64 hex>"),
|
|
19
|
+
});
|
|
20
|
+
const WardbyBlockSchema = z
|
|
21
|
+
.object({
|
|
22
|
+
schema: z.literal(1),
|
|
23
|
+
roles: z.array(z.enum(["builder", "reviewer", "planner"])).default([]),
|
|
24
|
+
affects: z.array(z.string().min(1)).default([]),
|
|
25
|
+
citations: z.array(CitationSchema).default([]),
|
|
26
|
+
supersedes: z.string().nullable().optional(),
|
|
27
|
+
confidence: z.enum(["low", "medium", "high"]).optional(),
|
|
28
|
+
})
|
|
29
|
+
.passthrough();
|
|
30
|
+
const FrontMatterSchema = z
|
|
31
|
+
.object({
|
|
32
|
+
type: z.string().trim().min(1),
|
|
33
|
+
title: z.string().optional(),
|
|
34
|
+
description: z.string().optional(),
|
|
35
|
+
status: z.enum(["draft", "stable", "deprecated"]).default("stable"),
|
|
36
|
+
wardby: WardbyBlockSchema.optional(),
|
|
37
|
+
})
|
|
38
|
+
.passthrough();
|
|
39
|
+
export function splitFrontMatter(text) {
|
|
40
|
+
const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/.exec(text);
|
|
41
|
+
return match ? { yaml: match[1], body: match[2] } : null;
|
|
42
|
+
}
|
|
43
|
+
export function parseConcept(path, text) {
|
|
44
|
+
const base = path.split("/").pop() ?? path;
|
|
45
|
+
if (RESERVED_BUNDLE_FILES.has(base))
|
|
46
|
+
return { ok: false, error: `${base} is reserved and cannot be a concept` };
|
|
47
|
+
const split = splitFrontMatter(text);
|
|
48
|
+
if (!split)
|
|
49
|
+
return { ok: false, error: "missing YAML front-matter (--- ... ---)" };
|
|
50
|
+
let raw;
|
|
51
|
+
try {
|
|
52
|
+
raw = parseYaml(split.yaml);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
return { ok: false, error: `invalid YAML: ${error instanceof Error ? error.message : String(error)}` };
|
|
56
|
+
}
|
|
57
|
+
const parsed = FrontMatterSchema.safeParse(raw);
|
|
58
|
+
if (!parsed.success) {
|
|
59
|
+
const issue = parsed.error.issues[0];
|
|
60
|
+
return { ok: false, error: `${issue.path.join(".") || "front-matter"}: ${issue.message}` };
|
|
61
|
+
}
|
|
62
|
+
const fm = parsed.data;
|
|
63
|
+
return {
|
|
64
|
+
ok: true,
|
|
65
|
+
concept: {
|
|
66
|
+
path,
|
|
67
|
+
type: fm.type,
|
|
68
|
+
title: fm.title,
|
|
69
|
+
description: fm.description,
|
|
70
|
+
status: fm.status,
|
|
71
|
+
roles: fm.wardby?.roles ?? [],
|
|
72
|
+
affects: fm.wardby?.affects ?? [],
|
|
73
|
+
citations: fm.wardby?.citations ?? [],
|
|
74
|
+
body: split.body,
|
|
75
|
+
frontMatter: raw,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FittedSection } from "../coding/protocol.js";
|
|
2
|
+
export declare const KNOWLEDGE_NOTE_MAX_BYTES: number;
|
|
3
|
+
export declare const KNOWLEDGE_INDEX_READ_MAX_BYTES: number;
|
|
4
|
+
export interface KnowledgeNoteInput {
|
|
5
|
+
bundlePath: string;
|
|
6
|
+
indexText: string;
|
|
7
|
+
}
|
|
8
|
+
/** The note, cut at a line boundary to fit maxBytes, or undefined when not even the header fits. */
|
|
9
|
+
export declare function renderKnowledgeNote(input: KnowledgeNoteInput, maxBytes: number): string | undefined;
|
|
10
|
+
/** The knowledge note as a composeCodingTask section, capped at KNOWLEDGE_NOTE_MAX_BYTES. */
|
|
11
|
+
export declare function knowledgeSection(input: KnowledgeNoteInput): FittedSection;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { splitFrontMatter } from "./concept.js";
|
|
2
|
+
export const KNOWLEDGE_NOTE_MAX_BYTES = 8 * 1024;
|
|
3
|
+
export const KNOWLEDGE_INDEX_READ_MAX_BYTES = 64 * 1024;
|
|
4
|
+
const END_MARKER = "[end of architecture knowledge]";
|
|
5
|
+
const bytes = (text) => Buffer.byteLength(text, "utf8");
|
|
6
|
+
function header(bundlePath) {
|
|
7
|
+
return [
|
|
8
|
+
"Architecture knowledge for this repository (recalled context, not authority;",
|
|
9
|
+
"the repository's own instructions such as AGENTS.md win on conflict). Concept",
|
|
10
|
+
`files live in ${bundlePath}/. Before designing or changing an area, read the`,
|
|
11
|
+
"concepts that cover the files you will touch. If your change alters behavior a",
|
|
12
|
+
"concept describes, update that concept's prose in the same change; leave its",
|
|
13
|
+
"`wardby:` block for the architecture agent to re-anchor.",
|
|
14
|
+
"",
|
|
15
|
+
`${bundlePath}/index.md:`,
|
|
16
|
+
].join("\n");
|
|
17
|
+
}
|
|
18
|
+
/** The note, cut at a line boundary to fit maxBytes, or undefined when not even the header fits. */
|
|
19
|
+
export function renderKnowledgeNote(input, maxBytes) {
|
|
20
|
+
const top = header(input.bundlePath);
|
|
21
|
+
const body = (splitFrontMatter(input.indexText)?.body ?? input.indexText).trim();
|
|
22
|
+
const full = `${top}\n${body}\n${END_MARKER}`;
|
|
23
|
+
if (bytes(full) <= maxBytes)
|
|
24
|
+
return full;
|
|
25
|
+
const marker = `[index truncated — list ${input.bundlePath}/ for the rest]`;
|
|
26
|
+
if (bytes(`${top}\n${marker}\n${END_MARKER}`) > maxBytes)
|
|
27
|
+
return undefined;
|
|
28
|
+
const kept = [];
|
|
29
|
+
for (const line of body.split("\n")) {
|
|
30
|
+
if (bytes(`${top}\n${[...kept, line, marker, END_MARKER].join("\n")}`) > maxBytes)
|
|
31
|
+
break;
|
|
32
|
+
kept.push(line);
|
|
33
|
+
}
|
|
34
|
+
return `${top}\n${[...kept, marker, END_MARKER].join("\n")}`;
|
|
35
|
+
}
|
|
36
|
+
/** The knowledge note as a composeCodingTask section, capped at KNOWLEDGE_NOTE_MAX_BYTES. */
|
|
37
|
+
export function knowledgeSection(input) {
|
|
38
|
+
return { render: (maxBytes) => renderKnowledgeNote(input, Math.min(maxBytes, KNOWLEDGE_NOTE_MAX_BYTES)) };
|
|
39
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ParsedConcept } from "./concept.js";
|
|
2
|
+
export interface DriftScope {
|
|
3
|
+
concepts: string[];
|
|
4
|
+
reason: "changed_files" | "bundle_edited" | "unknown_changes";
|
|
5
|
+
}
|
|
6
|
+
export declare function driftScope(input: {
|
|
7
|
+
changedPaths: string[];
|
|
8
|
+
changedPathsComplete: boolean;
|
|
9
|
+
bundlePath: string;
|
|
10
|
+
concepts: ParsedConcept[];
|
|
11
|
+
}): DriftScope | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { matchesGlob } from "../core/glob.js";
|
|
2
|
+
export function driftScope(input) {
|
|
3
|
+
const all = input.concepts.map((c) => c.path).sort();
|
|
4
|
+
if (!input.changedPathsComplete)
|
|
5
|
+
return all.length ? { concepts: all, reason: "unknown_changes" } : null;
|
|
6
|
+
const prefix = `${input.bundlePath}/`;
|
|
7
|
+
const bundleEdited = input.changedPaths.some((p) => p.startsWith(prefix));
|
|
8
|
+
const selected = input.concepts.filter((concept) => input.changedPaths.some((changed) => changed === prefix + concept.path ||
|
|
9
|
+
concept.citations.some((c) => c.path === changed) ||
|
|
10
|
+
concept.affects.some((glob) => matchesGlob(changed, glob))));
|
|
11
|
+
if (!selected.length)
|
|
12
|
+
return null;
|
|
13
|
+
return { concepts: selected.map((c) => c.path).sort(), reason: bundleEdited ? "bundle_edited" : "changed_files" };
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
/** sha256 of lines A..B (1-based, inclusive), each followed by "\n"
|
|
3
|
+
* (equals `sed -n 'A,Bp' FILE | sha256sum` when the last cited line ends with a newline). */
|
|
4
|
+
export function spanHash(fileText, lines) {
|
|
5
|
+
const digest = (text) => `sha256:${createHash("sha256").update(text, "utf8").digest("hex")}`;
|
|
6
|
+
if (!lines)
|
|
7
|
+
return digest(fileText);
|
|
8
|
+
const [start, end] = lines;
|
|
9
|
+
const all = fileText.endsWith("\n") ? fileText.slice(0, -1).split("\n") : fileText.split("\n");
|
|
10
|
+
if (start < 1 || end < start || end > all.length)
|
|
11
|
+
return null;
|
|
12
|
+
return digest(all
|
|
13
|
+
.slice(start - 1, end)
|
|
14
|
+
.map((line) => `${line}\n`)
|
|
15
|
+
.join(""));
|
|
16
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MCP seam for agent access (resource-sharing grants spec §3.3). Every
|
|
3
|
+
* agent tool routes through here instead of ownership.ts's owner-or-public
|
|
4
|
+
* rule, which no longer applies to agents: an owner-less agent is reachable
|
|
5
|
+
* only through its grants (the migration gives everyone execute).
|
|
6
|
+
*
|
|
7
|
+
* - Below read: 404 with the same text as a missing row, so existence never
|
|
8
|
+
* leaks. At read or above but below the level required: 403 naming both.
|
|
9
|
+
* - The helpers take a `db` argument so a Serializable transaction reads the
|
|
10
|
+
* grant rows through `tx`; a concurrent revoke then conflicts instead of
|
|
11
|
+
* racing.
|
|
12
|
+
* - `ctx.operator` (stdio's local operator, never an HTTP principal) is
|
|
13
|
+
* owner of every agent for access checks and sees every agent in
|
|
14
|
+
* listings, but does NOT bypass requireBindingOwner: one owner's secrets,
|
|
15
|
+
* datastores and repositories never reach another owner's agent.
|
|
16
|
+
*/
|
|
17
|
+
import type { Prisma, PrismaClient } from "#prisma";
|
|
18
|
+
import { type Access, type Level } from "../../core/grants.js";
|
|
19
|
+
import type { McpRequestContext } from "../context.js";
|
|
20
|
+
import { McpError } from "../errors.js";
|
|
21
|
+
export type AgentLevel = Level<"agent">;
|
|
22
|
+
export type AgentAccess = Access<"agent">;
|
|
23
|
+
type AgentRef = {
|
|
24
|
+
id: string;
|
|
25
|
+
ownerId: string | null;
|
|
26
|
+
};
|
|
27
|
+
type GrantDb = Pick<PrismaClient, "resourceGrant">;
|
|
28
|
+
export declare function agentNotFound(id: string): McpError;
|
|
29
|
+
export declare function insufficientAgentAccess(id: string, required: AgentLevel | "owner", held: AgentAccess): McpError;
|
|
30
|
+
/** The caller's access to an agent row already read. */
|
|
31
|
+
export declare function agentAccess(ctx: McpRequestContext, agent: AgentRef, db?: GrantDb): Promise<AgentAccess>;
|
|
32
|
+
/** For a row already read (inside a transaction, or with includes): 404 below read, 403 below `required`. */
|
|
33
|
+
export declare function assertAgentAccess<A extends AgentRef>(ctx: McpRequestContext, agent: A | null, id: string, required: AgentLevel | "owner", db?: GrantDb): Promise<{
|
|
34
|
+
agent: A;
|
|
35
|
+
access: AgentAccess;
|
|
36
|
+
}>;
|
|
37
|
+
/** 404 if missing or access < read; 403 if read <= access < required. Returns row + access. */
|
|
38
|
+
export declare function requireAgentAccess(ctx: McpRequestContext, id: string, required: AgentLevel | "owner", db?: Pick<PrismaClient, "agent" | "resourceGrant">): Promise<{
|
|
39
|
+
agent: {
|
|
40
|
+
name: string;
|
|
41
|
+
model: string;
|
|
42
|
+
budgetUsd: import("@prisma/client-runtime-utils").Decimal;
|
|
43
|
+
createdAt: Date;
|
|
44
|
+
updatedAt: Date;
|
|
45
|
+
kind: import("#prisma").AgentKind;
|
|
46
|
+
id: string;
|
|
47
|
+
ownerId: string | null;
|
|
48
|
+
systemPrompt: string;
|
|
49
|
+
schedule: string | null;
|
|
50
|
+
timezone: string;
|
|
51
|
+
scheduleEnabled: boolean;
|
|
52
|
+
lastScheduledAt: Date | null;
|
|
53
|
+
maxTurns: number;
|
|
54
|
+
defectProjectKey: string | null;
|
|
55
|
+
defectIssueType: string | null;
|
|
56
|
+
budgetGroupId: string | null;
|
|
57
|
+
memoryEnabled: boolean;
|
|
58
|
+
effort: string | null;
|
|
59
|
+
};
|
|
60
|
+
access: AgentAccess;
|
|
61
|
+
}>;
|
|
62
|
+
/**
|
|
63
|
+
* Bindings (secrets, datastores, repositories, capability grants): strict
|
|
64
|
+
* ownership, whatever the grants. The stdio operator does NOT bypass this:
|
|
65
|
+
* it can adopt the agent first (make_owner / grants adopt-public).
|
|
66
|
+
*/
|
|
67
|
+
export declare function requireBindingOwner(ctx: McpRequestContext, agent: AgentRef): void;
|
|
68
|
+
/** Prisma where for agent listings: own rows plus rows granted >= read; the operator sees all. */
|
|
69
|
+
export declare function readableAgentsWhere(ctx: McpRequestContext, db?: GrantDb): Promise<Prisma.AgentWhereInput>;
|
|
70
|
+
/** One grant lookup for a whole listing: returns agent -> the caller's access. */
|
|
71
|
+
export declare function agentAccessResolver(ctx: McpRequestContext, db?: GrantDb): Promise<(agent: AgentRef) => AgentAccess>;
|
|
72
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { atLeast, effectiveAccess, grantedAccessMap, grantedIds } from "../../core/grants.js";
|
|
2
|
+
import { McpError } from "../errors.js";
|
|
3
|
+
export function agentNotFound(id) {
|
|
4
|
+
return new McpError(404, `Agent "${id}" not found.`);
|
|
5
|
+
}
|
|
6
|
+
function describeLevel(level) {
|
|
7
|
+
return level === "owner" ? "the agent's owner" : `${level} access`;
|
|
8
|
+
}
|
|
9
|
+
export function insufficientAgentAccess(id, required, held) {
|
|
10
|
+
return new McpError(403, `Agent "${id}": this needs ${describeLevel(required)}; you have ${held === "owner" ? "owner" : held} access.`);
|
|
11
|
+
}
|
|
12
|
+
/** The caller's access to an agent row already read. */
|
|
13
|
+
export function agentAccess(ctx, agent, db = ctx.db) {
|
|
14
|
+
return effectiveAccess(db, "agent", agent, ctx.principal.id, { operator: ctx.operator === true });
|
|
15
|
+
}
|
|
16
|
+
/** For a row already read (inside a transaction, or with includes): 404 below read, 403 below `required`. */
|
|
17
|
+
export async function assertAgentAccess(ctx, agent, id, required, db = ctx.db) {
|
|
18
|
+
if (!agent)
|
|
19
|
+
throw agentNotFound(id);
|
|
20
|
+
const access = await agentAccess(ctx, agent, db);
|
|
21
|
+
if (!atLeast("agent", access, "read"))
|
|
22
|
+
throw agentNotFound(id);
|
|
23
|
+
if (!atLeast("agent", access, required))
|
|
24
|
+
throw insufficientAgentAccess(id, required, access);
|
|
25
|
+
return { agent, access };
|
|
26
|
+
}
|
|
27
|
+
/** 404 if missing or access < read; 403 if read <= access < required. Returns row + access. */
|
|
28
|
+
export async function requireAgentAccess(ctx, id, required, db = ctx.db) {
|
|
29
|
+
const agent = await db.agent.findUnique({ where: { id } });
|
|
30
|
+
return assertAgentAccess(ctx, agent, id, required, db);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Bindings (secrets, datastores, repositories, capability grants): strict
|
|
34
|
+
* ownership, whatever the grants. The stdio operator does NOT bypass this:
|
|
35
|
+
* it can adopt the agent first (make_owner / grants adopt-public).
|
|
36
|
+
*/
|
|
37
|
+
export function requireBindingOwner(ctx, agent) {
|
|
38
|
+
if (agent.ownerId === null) {
|
|
39
|
+
throw new McpError(403, `Agent "${agent.id}" has no owner, so nothing can be bound to it; an admin can assign one with make_owner.`);
|
|
40
|
+
}
|
|
41
|
+
if (agent.ownerId !== ctx.principal.id) {
|
|
42
|
+
throw new McpError(403, `Only the owner of agent "${agent.id}" can change its bindings.`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/** Prisma where for agent listings: own rows plus rows granted >= read; the operator sees all. */
|
|
46
|
+
export async function readableAgentsWhere(ctx, db = ctx.db) {
|
|
47
|
+
if (ctx.operator)
|
|
48
|
+
return {};
|
|
49
|
+
const ids = await grantedIds(db, "agent", ctx.principal.id, "read");
|
|
50
|
+
return { OR: [{ ownerId: ctx.principal.id }, { id: { in: ids } }] };
|
|
51
|
+
}
|
|
52
|
+
/** One grant lookup for a whole listing: returns agent -> the caller's access. */
|
|
53
|
+
export async function agentAccessResolver(ctx, db = ctx.db) {
|
|
54
|
+
if (ctx.operator)
|
|
55
|
+
return () => "owner";
|
|
56
|
+
const granted = await grantedAccessMap(db, "agent", ctx.principal.id);
|
|
57
|
+
return (agent) => agent.ownerId !== null && agent.ownerId === ctx.principal.id ? "owner" : (granted.get(agent.id) ?? "none");
|
|
58
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { type PrismaClient } from "#prisma";
|
|
2
|
+
/** The report needs only raw queries, so it can run on a schema the generated client doesn't match. */
|
|
3
|
+
export interface ReportDb {
|
|
4
|
+
$queryRaw<T = unknown>(query: TemplateStringsArray, ...values: unknown[]): PromiseLike<T>;
|
|
5
|
+
}
|
|
6
|
+
export declare const BEHAVIOUR_CHANGES: string[];
|
|
7
|
+
export interface MigrationReport {
|
|
8
|
+
grantsTable: boolean;
|
|
9
|
+
ownerlessAgents: {
|
|
10
|
+
agentId: string;
|
|
11
|
+
name: string;
|
|
12
|
+
everyoneGrant: string | null;
|
|
13
|
+
/** What adopting the agent as each principal would bring back into force (review I3). */
|
|
14
|
+
revivedByAdopter: {
|
|
15
|
+
principalId: string;
|
|
16
|
+
subject: string;
|
|
17
|
+
secrets: string[];
|
|
18
|
+
datastores: string[];
|
|
19
|
+
toolCapabilities: string[];
|
|
20
|
+
}[];
|
|
21
|
+
}[];
|
|
22
|
+
inertBindings: {
|
|
23
|
+
kind: "secret" | "datastore";
|
|
24
|
+
agentId: string;
|
|
25
|
+
agentName: string;
|
|
26
|
+
agentOwnerId: string | null;
|
|
27
|
+
boundName: string;
|
|
28
|
+
resourceId: string;
|
|
29
|
+
resourceOwnerId: string | null;
|
|
30
|
+
/** Removed by prune-bindings (owned agent); on an owner-less agent adopt-public decides. */
|
|
31
|
+
prunable: boolean;
|
|
32
|
+
}[];
|
|
33
|
+
suspendedCapabilities: {
|
|
34
|
+
agentId: string;
|
|
35
|
+
agentName: string;
|
|
36
|
+
toolId: string;
|
|
37
|
+
toolName: string;
|
|
38
|
+
regrant: string;
|
|
39
|
+
}[];
|
|
40
|
+
/**
|
|
41
|
+
* Capabilities the migration stamps with the current owner on owner-less
|
|
42
|
+
* tools: a previous owner may have set them before a make_owner (review
|
|
43
|
+
* M2). They stay in force; the owner should review them.
|
|
44
|
+
*/
|
|
45
|
+
reviewCapabilities: {
|
|
46
|
+
agentId: string;
|
|
47
|
+
agentName: string;
|
|
48
|
+
toolId: string;
|
|
49
|
+
toolName: string;
|
|
50
|
+
regrant: string;
|
|
51
|
+
}[];
|
|
52
|
+
failingEdges: {
|
|
53
|
+
parentAgentId: string;
|
|
54
|
+
parentOwnerId: string | null;
|
|
55
|
+
childAgentId: string;
|
|
56
|
+
childOwnerId: string | null;
|
|
57
|
+
boundName: string;
|
|
58
|
+
}[];
|
|
59
|
+
webhooks: {
|
|
60
|
+
onOwnerlessAgents: {
|
|
61
|
+
id: string;
|
|
62
|
+
agentId: string;
|
|
63
|
+
createdBy: string | null;
|
|
64
|
+
}[];
|
|
65
|
+
creatorLacksExecute: {
|
|
66
|
+
id: string;
|
|
67
|
+
agentId: string;
|
|
68
|
+
createdBy: string | null;
|
|
69
|
+
}[];
|
|
70
|
+
};
|
|
71
|
+
behaviourChanges: string[];
|
|
72
|
+
orphanGrants: {
|
|
73
|
+
id: string;
|
|
74
|
+
resourceType: string;
|
|
75
|
+
resourceId: string;
|
|
76
|
+
}[] | null;
|
|
77
|
+
}
|
|
78
|
+
export declare function migrationReport(db: ReportDb): Promise<MigrationReport>;
|
|
79
|
+
export declare function formatMigrationReport(report: MigrationReport): string;
|
|
80
|
+
export interface AdoptedAgent {
|
|
81
|
+
agentId: string;
|
|
82
|
+
name: string;
|
|
83
|
+
bindingsRemoved: {
|
|
84
|
+
kind: "secret" | "datastore";
|
|
85
|
+
boundName: string;
|
|
86
|
+
resourceId: string;
|
|
87
|
+
}[];
|
|
88
|
+
bindingsKept: {
|
|
89
|
+
kind: "secret" | "datastore";
|
|
90
|
+
boundName: string;
|
|
91
|
+
}[];
|
|
92
|
+
capabilitiesStamped: string[];
|
|
93
|
+
/** Every attached tool the new owner doesn't own (review M7); `regrant` only when it had capabilities. */
|
|
94
|
+
foreignTools: {
|
|
95
|
+
toolId: string;
|
|
96
|
+
toolName: string;
|
|
97
|
+
toolOwnerId: string | null;
|
|
98
|
+
regrant: string | null;
|
|
99
|
+
}[];
|
|
100
|
+
failingEdges: {
|
|
101
|
+
parentAgentId: string;
|
|
102
|
+
childAgentId: string;
|
|
103
|
+
boundName: string;
|
|
104
|
+
}[];
|
|
105
|
+
/** The everyone grant before and after adoption (null = none). */
|
|
106
|
+
everyoneGrant: {
|
|
107
|
+
before: string | null;
|
|
108
|
+
after: string | null;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
export interface AdoptResult {
|
|
112
|
+
owner: {
|
|
113
|
+
id: string;
|
|
114
|
+
subject: string;
|
|
115
|
+
};
|
|
116
|
+
dryRun: boolean;
|
|
117
|
+
agents: AdoptedAgent[];
|
|
118
|
+
}
|
|
119
|
+
/** Gives every owner-less agent `ownerSubject` as its owner. See the module header. */
|
|
120
|
+
export declare function adoptPublic(db: PrismaClient, opts: {
|
|
121
|
+
ownerSubject: string;
|
|
122
|
+
dryRun: boolean;
|
|
123
|
+
keepEveryoneExecute?: boolean;
|
|
124
|
+
}): Promise<AdoptResult>;
|
|
125
|
+
export declare function formatAdoptResult(result: AdoptResult): string;
|
|
126
|
+
export interface PruneResult {
|
|
127
|
+
dryRun: boolean;
|
|
128
|
+
removed: {
|
|
129
|
+
kind: "secret" | "datastore";
|
|
130
|
+
agentId: string;
|
|
131
|
+
agentName: string;
|
|
132
|
+
boundName: string;
|
|
133
|
+
resourceId: string;
|
|
134
|
+
resourceOwnerId: string | null;
|
|
135
|
+
}[];
|
|
136
|
+
}
|
|
137
|
+
/** Deletes cross-owner secret/datastore bindings on owned agents, in one transaction. */
|
|
138
|
+
export declare function pruneBindings(db: PrismaClient, opts: {
|
|
139
|
+
dryRun: boolean;
|
|
140
|
+
}): Promise<PruneResult>;
|
|
141
|
+
export declare function formatPruneResult(result: PruneResult): string;
|
|
142
|
+
/**
|
|
143
|
+
* The owner of an agent made with `wardby agent create` (resource-sharing
|
|
144
|
+
* grants spec §3.8): `--owner <subject>` must already exist (a typo never
|
|
145
|
+
* mints a principal), otherwise the local operator (LOCAL_PRINCIPAL),
|
|
146
|
+
* found or created exactly as stdio does.
|
|
147
|
+
*/
|
|
148
|
+
export declare function resolveCliAgentOwner(db: PrismaClient, ownerSubject: string | undefined, localPrincipal: string): Promise<string>;
|
|
149
|
+
export declare function grantsCommand(args: string[], db: PrismaClient, output?: (value: string) => void): Promise<void>;
|