@bevel-software/platform-core-backend 0.22.0 → 0.24.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/dist/core/core-ports.d.ts +11 -1
- package/dist/core/core-ports.d.ts.map +1 -1
- package/dist/core/core-ports.js.map +1 -1
- package/dist/core/create-core-server.d.ts +3 -3
- package/dist/core/create-core-server.d.ts.map +1 -1
- package/dist/core/create-core-server.js +46 -13
- package/dist/core/create-core-server.js.map +1 -1
- package/dist/core/create-core-services.d.ts +12 -2
- package/dist/core/create-core-services.d.ts.map +1 -1
- package/dist/core/create-core-services.js +137 -24
- package/dist/core/create-core-services.js.map +1 -1
- package/dist/core/lifecycle.d.ts +46 -1
- package/dist/core/lifecycle.d.ts.map +1 -1
- package/dist/core/lifecycle.js +99 -13
- package/dist/core/lifecycle.js.map +1 -1
- package/dist/core-config.d.ts +16 -12
- package/dist/core-config.d.ts.map +1 -1
- package/dist/core-config.js +28 -13
- package/dist/core-config.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/modules/access/access-control.interface.d.ts +42 -12
- package/dist/modules/access/access-control.interface.d.ts.map +1 -1
- package/dist/modules/access/access-control.service.d.ts +67 -10
- package/dist/modules/access/access-control.service.d.ts.map +1 -1
- package/dist/modules/access/access-control.service.js +214 -35
- package/dist/modules/access/access-control.service.js.map +1 -1
- package/dist/modules/access/access.routes.d.ts.map +1 -1
- package/dist/modules/access/access.routes.js +17 -16
- package/dist/modules/access/access.routes.js.map +1 -1
- package/dist/modules/access/directory-sync-bot.d.ts.map +1 -1
- package/dist/modules/access/directory-sync-bot.js +7 -3
- package/dist/modules/access/directory-sync-bot.js.map +1 -1
- package/dist/modules/agent-instructions/agent-instructions.routes.d.ts +8 -1
- package/dist/modules/agent-instructions/agent-instructions.routes.d.ts.map +1 -1
- package/dist/modules/agent-instructions/agent-instructions.routes.js +8 -2
- package/dist/modules/agent-instructions/agent-instructions.routes.js.map +1 -1
- package/dist/modules/agent-instructions/compose.d.ts +38 -6
- package/dist/modules/agent-instructions/compose.d.ts.map +1 -1
- package/dist/modules/agent-instructions/compose.js +39 -6
- package/dist/modules/agent-instructions/compose.js.map +1 -1
- package/dist/modules/agent-instructions/index.d.ts +2 -1
- package/dist/modules/agent-instructions/index.d.ts.map +1 -1
- package/dist/modules/agent-instructions/index.js +2 -1
- package/dist/modules/agent-instructions/index.js.map +1 -1
- package/dist/modules/agent-instructions/shared-file-rules.d.ts +115 -0
- package/dist/modules/agent-instructions/shared-file-rules.d.ts.map +1 -0
- package/dist/modules/agent-instructions/shared-file-rules.js +272 -0
- package/dist/modules/agent-instructions/shared-file-rules.js.map +1 -0
- package/dist/modules/audit/agent-audit.service.d.ts.map +1 -1
- package/dist/modules/audit/agent-audit.service.js +4 -2
- package/dist/modules/audit/agent-audit.service.js.map +1 -1
- package/dist/modules/auth/account-admission.d.ts +58 -7
- package/dist/modules/auth/account-admission.d.ts.map +1 -1
- package/dist/modules/auth/account-admission.js +44 -1
- package/dist/modules/auth/account-admission.js.map +1 -1
- package/dist/modules/auth/account-erasure.service.d.ts.map +1 -1
- package/dist/modules/auth/account-erasure.service.js +57 -16
- package/dist/modules/auth/account-erasure.service.js.map +1 -1
- package/dist/modules/auth/account.routes.d.ts +1 -1
- package/dist/modules/auth/account.routes.d.ts.map +1 -1
- package/dist/modules/auth/account.routes.js +61 -5
- package/dist/modules/auth/account.routes.js.map +1 -1
- package/dist/modules/auth/auth.middleware.d.ts +1 -1
- package/dist/modules/auth/auth.middleware.d.ts.map +1 -1
- package/dist/modules/auth/auth.middleware.js +18 -7
- package/dist/modules/auth/auth.middleware.js.map +1 -1
- package/dist/modules/auth/auth.routes.d.ts.map +1 -1
- package/dist/modules/auth/auth.routes.js +8 -0
- package/dist/modules/auth/auth.routes.js.map +1 -1
- package/dist/modules/auth/auth.service.d.ts +70 -2
- package/dist/modules/auth/auth.service.d.ts.map +1 -1
- package/dist/modules/auth/auth.service.js +197 -18
- package/dist/modules/auth/auth.service.js.map +1 -1
- package/dist/modules/auth/oidc-auth-provider.d.ts.map +1 -1
- package/dist/modules/auth/oidc-auth-provider.js +7 -2
- package/dist/modules/auth/oidc-auth-provider.js.map +1 -1
- package/dist/modules/code-mode/code-mode.tool.d.ts +20 -2
- package/dist/modules/code-mode/code-mode.tool.d.ts.map +1 -1
- package/dist/modules/code-mode/code-mode.tool.js +66 -35
- package/dist/modules/code-mode/code-mode.tool.js.map +1 -1
- package/dist/modules/database/connection.d.ts +16 -0
- package/dist/modules/database/connection.d.ts.map +1 -1
- package/dist/modules/database/connection.js +117 -0
- package/dist/modules/database/connection.js.map +1 -1
- package/dist/modules/database/core-schema.d.ts +337 -120
- package/dist/modules/database/core-schema.d.ts.map +1 -1
- package/dist/modules/database/core-schema.js +116 -58
- package/dist/modules/database/core-schema.js.map +1 -1
- package/dist/modules/database/migrate.d.ts +8 -0
- package/dist/modules/database/migrate.d.ts.map +1 -1
- package/dist/modules/database/migrate.js +271 -1
- package/dist/modules/database/migrate.js.map +1 -1
- package/dist/modules/kb-fs/branch-name.d.ts.map +1 -1
- package/dist/modules/kb-fs/branch-name.js +12 -2
- package/dist/modules/kb-fs/branch-name.js.map +1 -1
- package/dist/modules/kb-fs/repo-path.d.ts +11 -16
- package/dist/modules/kb-fs/repo-path.d.ts.map +1 -1
- package/dist/modules/kb-fs/repo-path.js +79 -0
- package/dist/modules/kb-fs/repo-path.js.map +1 -1
- package/dist/modules/kb-sync/kb-sync.routes.d.ts +2 -2
- package/dist/modules/kb-sync/kb-sync.routes.d.ts.map +1 -1
- package/dist/modules/kb-sync/kb-sync.routes.js +14 -3
- package/dist/modules/kb-sync/kb-sync.routes.js.map +1 -1
- package/dist/modules/kb-sync/sync-auth.d.ts +3 -1
- package/dist/modules/kb-sync/sync-auth.d.ts.map +1 -1
- package/dist/modules/kb-sync/sync-auth.js +1 -1
- package/dist/modules/kb-sync/sync-auth.js.map +1 -1
- package/dist/modules/mcp/mcp-auth.middleware.d.ts.map +1 -1
- package/dist/modules/mcp/mcp-auth.middleware.js +21 -6
- package/dist/modules/mcp/mcp-auth.middleware.js.map +1 -1
- package/dist/modules/mcp/mcp.service.d.ts +8 -0
- package/dist/modules/mcp/mcp.service.d.ts.map +1 -1
- package/dist/modules/mcp/mcp.service.js +38 -8
- package/dist/modules/mcp/mcp.service.js.map +1 -1
- package/dist/modules/mcp/oauth/bevel-oauth-provider.d.ts.map +1 -1
- package/dist/modules/mcp/oauth/bevel-oauth-provider.js +3 -2
- package/dist/modules/mcp/oauth/bevel-oauth-provider.js.map +1 -1
- package/dist/modules/plugins/join-request-records.store.d.ts.map +1 -1
- package/dist/modules/plugins/join-request-records.store.js +7 -4
- package/dist/modules/plugins/join-request-records.store.js.map +1 -1
- package/dist/modules/settings/deployment-settings.service.d.ts.map +1 -1
- package/dist/modules/settings/deployment-settings.service.js +8 -3
- package/dist/modules/settings/deployment-settings.service.js.map +1 -1
- package/dist/modules/settings/setup.routes.d.ts +52 -1
- package/dist/modules/settings/setup.routes.d.ts.map +1 -1
- package/dist/modules/settings/setup.routes.js +207 -19
- package/dist/modules/settings/setup.routes.js.map +1 -1
- package/dist/modules/skills/skills.contract.d.ts +90 -18
- package/dist/modules/skills/skills.contract.d.ts.map +1 -1
- package/dist/modules/skills/skills.contract.js +4 -1
- package/dist/modules/skills/skills.contract.js.map +1 -1
- package/dist/modules/skills/skills.service.d.ts +98 -9
- package/dist/modules/skills/skills.service.d.ts.map +1 -1
- package/dist/modules/skills/skills.service.js +239 -37
- package/dist/modules/skills/skills.service.js.map +1 -1
- package/dist/modules/skills/skills.tools.d.ts +7 -0
- package/dist/modules/skills/skills.tools.d.ts.map +1 -1
- package/dist/modules/skills/skills.tools.js +71 -7
- package/dist/modules/skills/skills.tools.js.map +1 -1
- package/dist/modules/tool-auth/external-api-key.service.d.ts.map +1 -1
- package/dist/modules/tool-auth/external-api-key.service.js +12 -4
- package/dist/modules/tool-auth/external-api-key.service.js.map +1 -1
- package/dist/modules/tool-auth/internal-token.service.d.ts +3 -3
- package/dist/modules/tool-auth/tool-auth.middleware.d.ts +16 -7
- package/dist/modules/tool-auth/tool-auth.middleware.d.ts.map +1 -1
- package/dist/modules/tool-auth/tool-auth.middleware.js +34 -12
- package/dist/modules/tool-auth/tool-auth.middleware.js.map +1 -1
- package/dist/modules/tool-helpers/tool-handler.d.ts +2 -1
- package/dist/modules/tool-helpers/tool-handler.d.ts.map +1 -1
- package/dist/modules/tool-helpers/tool-handler.js +25 -4
- package/dist/modules/tool-helpers/tool-handler.js.map +1 -1
- package/dist/modules/tool-helpers/tool.contract.d.ts +3 -2
- package/dist/modules/tool-helpers/tool.contract.d.ts.map +1 -1
- package/dist/modules/tool-helpers/tool.contract.js.map +1 -1
- package/dist/modules/tool-helpers/validate-token.js +1 -1
- package/dist/modules/tool-helpers/validate-token.js.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.tools.d.ts.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.tools.js +42 -31
- package/dist/modules/tool-manuals/tool-manuals.tools.js.map +1 -1
- package/dist/modules/tool-registry/description-length.d.ts +80 -0
- package/dist/modules/tool-registry/description-length.d.ts.map +1 -0
- package/dist/modules/tool-registry/description-length.js +108 -0
- package/dist/modules/tool-registry/description-length.js.map +1 -0
- package/dist/modules/workflow/agent-tools/change-request-summary.d.ts +98 -0
- package/dist/modules/workflow/agent-tools/change-request-summary.d.ts.map +1 -0
- package/dist/modules/workflow/agent-tools/change-request-summary.js +81 -0
- package/dist/modules/workflow/agent-tools/change-request-summary.js.map +1 -0
- package/dist/modules/workflow/agent-tools/workflow.tools.d.ts.map +1 -1
- package/dist/modules/workflow/agent-tools/workflow.tools.js +75 -35
- package/dist/modules/workflow/agent-tools/workflow.tools.js.map +1 -1
- package/dist/modules/workflow/file-lock.service.d.ts +24 -0
- package/dist/modules/workflow/file-lock.service.d.ts.map +1 -1
- package/dist/modules/workflow/file-lock.service.js +30 -0
- package/dist/modules/workflow/file-lock.service.js.map +1 -1
- package/dist/modules/workflow/git/git.service.d.ts +94 -0
- package/dist/modules/workflow/git/git.service.d.ts.map +1 -1
- package/dist/modules/workflow/git/git.service.js +193 -3
- package/dist/modules/workflow/git/git.service.js.map +1 -1
- package/dist/modules/workflow/pending-commits.service.d.ts +38 -0
- package/dist/modules/workflow/pending-commits.service.d.ts.map +1 -1
- package/dist/modules/workflow/pending-commits.service.js +60 -1
- package/dist/modules/workflow/pending-commits.service.js.map +1 -1
- package/dist/modules/workflow/recovery-bot.d.ts.map +1 -1
- package/dist/modules/workflow/recovery-bot.js +7 -3
- package/dist/modules/workflow/recovery-bot.js.map +1 -1
- package/dist/modules/workflow/review-workflow/review-workflow.service.d.ts.map +1 -1
- package/dist/modules/workflow/review-workflow/review-workflow.service.js +12 -3
- package/dist/modules/workflow/review-workflow/review-workflow.service.js.map +1 -1
- package/dist/modules/workflow/workflow-hooks.d.ts +54 -32
- package/dist/modules/workflow/workflow-hooks.d.ts.map +1 -1
- package/dist/modules/workflow/workflow-hooks.js +16 -1
- package/dist/modules/workflow/workflow-hooks.js.map +1 -1
- package/dist/modules/workflow/workflow.service.d.ts +60 -6
- package/dist/modules/workflow/workflow.service.d.ts.map +1 -1
- package/dist/modules/workflow/workflow.service.js +115 -5
- package/dist/modules/workflow/workflow.service.js.map +1 -1
- package/dist/modules/workspace/agent-access.gate.d.ts +94 -0
- package/dist/modules/workspace/agent-access.gate.d.ts.map +1 -0
- package/dist/modules/workspace/agent-access.gate.js +123 -0
- package/dist/modules/workspace/agent-access.gate.js.map +1 -0
- package/dist/modules/workspace/agent-upload.routes.d.ts +77 -0
- package/dist/modules/workspace/agent-upload.routes.d.ts.map +1 -0
- package/dist/modules/workspace/agent-upload.routes.js +210 -0
- package/dist/modules/workspace/agent-upload.routes.js.map +1 -0
- package/dist/modules/workspace/agent-upload.store.d.ts +284 -0
- package/dist/modules/workspace/agent-upload.store.d.ts.map +1 -0
- package/dist/modules/workspace/agent-upload.store.js +553 -0
- package/dist/modules/workspace/agent-upload.store.js.map +1 -0
- package/dist/modules/workspace/routine-write-policy.d.ts +5 -6
- package/dist/modules/workspace/routine-write-policy.d.ts.map +1 -1
- package/dist/modules/workspace/routine-write-policy.js +5 -6
- package/dist/modules/workspace/routine-write-policy.js.map +1 -1
- package/dist/modules/workspace/session-sink.d.ts +5 -5
- package/dist/modules/workspace/set-aside-clone.d.ts +46 -0
- package/dist/modules/workspace/set-aside-clone.d.ts.map +1 -0
- package/dist/modules/workspace/set-aside-clone.js +92 -0
- package/dist/modules/workspace/set-aside-clone.js.map +1 -0
- package/dist/modules/workspace/startup/kb-startup-runner.d.ts +59 -9
- package/dist/modules/workspace/startup/kb-startup-runner.d.ts.map +1 -1
- package/dist/modules/workspace/startup/kb-startup-runner.js +65 -24
- package/dist/modules/workspace/startup/kb-startup-runner.js.map +1 -1
- package/dist/modules/workspace/startup/steps/seed-tree.d.ts.map +1 -1
- package/dist/modules/workspace/startup/steps/seed-tree.js +3 -3
- package/dist/modules/workspace/startup/steps/seed-tree.js.map +1 -1
- package/dist/modules/workspace/startup/steps/template-source.d.ts +40 -0
- package/dist/modules/workspace/startup/steps/template-source.d.ts.map +1 -1
- package/dist/modules/workspace/startup/steps/template-source.js +46 -4
- package/dist/modules/workspace/startup/steps/template-source.js.map +1 -1
- package/dist/modules/workspace/upload-limits.d.ts +13 -0
- package/dist/modules/workspace/upload-limits.d.ts.map +1 -0
- package/dist/modules/workspace/upload-limits.js +13 -0
- package/dist/modules/workspace/upload-limits.js.map +1 -0
- package/dist/modules/workspace/workspace.routes.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.routes.js +93 -4
- package/dist/modules/workspace/workspace.routes.js.map +1 -1
- package/dist/modules/workspace/workspace.service.d.ts +128 -5
- package/dist/modules/workspace/workspace.service.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.service.js +316 -58
- package/dist/modules/workspace/workspace.service.js.map +1 -1
- package/dist/modules/workspace/workspace.tools.d.ts +13 -11
- package/dist/modules/workspace/workspace.tools.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.tools.js +791 -198
- package/dist/modules/workspace/workspace.tools.js.map +1 -1
- package/dist/modules/workspace/write-denial.d.ts +0 -6
- package/dist/modules/workspace/write-denial.d.ts.map +1 -1
- package/dist/modules/workspace/write-denial.js +0 -6
- package/dist/modules/workspace/write-denial.js.map +1 -1
- package/dist/modules/workspace/zip-entry-rules.d.ts +114 -0
- package/dist/modules/workspace/zip-entry-rules.d.ts.map +1 -0
- package/dist/modules/workspace/zip-entry-rules.js +154 -0
- package/dist/modules/workspace/zip-entry-rules.js.map +1 -0
- package/dist/modules/write-access/write-access.d.ts +60 -0
- package/dist/modules/write-access/write-access.d.ts.map +1 -0
- package/dist/modules/write-access/write-access.js +129 -0
- package/dist/modules/write-access/write-access.js.map +1 -0
- package/dist/shared/column-crypto.d.ts +194 -0
- package/dist/shared/column-crypto.d.ts.map +1 -0
- package/dist/shared/column-crypto.js +144 -0
- package/dist/shared/column-crypto.js.map +1 -0
- package/dist/shared/domain-errors.d.ts +25 -0
- package/dist/shared/domain-errors.d.ts.map +1 -1
- package/dist/shared/domain-errors.js +28 -0
- package/dist/shared/domain-errors.js.map +1 -1
- package/dist/shared/git.contract.d.ts +20 -0
- package/dist/shared/git.contract.d.ts.map +1 -1
- package/dist/shared/git.contract.js +26 -0
- package/dist/shared/git.contract.js.map +1 -1
- package/dist/shared/token-crypto.d.ts.map +1 -1
- package/dist/shared/token-crypto.js +25 -1
- package/dist/shared/token-crypto.js.map +1 -1
- package/dist/tenancy/static-tenant-source.d.ts +0 -1
- package/dist/tenancy/static-tenant-source.d.ts.map +1 -1
- package/dist/tenancy/static-tenant-source.js +1 -2
- package/dist/tenancy/static-tenant-source.js.map +1 -1
- package/dist/tenancy/tenant-secrets.d.ts +5 -1
- package/dist/tenancy/tenant-secrets.d.ts.map +1 -1
- package/dist/tenancy/tenant-secrets.js +4 -0
- package/dist/tenancy/tenant-secrets.js.map +1 -1
- package/kb-template/AGENTS.md +2 -0
- package/migrations/0014_change_request_closed_reason.sql +1 -0
- package/migrations/0015_account_deactivation.sql +3 -0
- package/migrations/0016_pii_encryption.sql +20 -0
- package/migrations/meta/0014_snapshot.json +2265 -0
- package/migrations/meta/0015_snapshot.json +2271 -0
- package/migrations/meta/0016_snapshot.json +2327 -0
- package/migrations/meta/_journal.json +21 -0
- package/package.json +3 -3
- package/src/__tests__/kb-layout-config.test.ts +0 -2
- package/src/__tests__/retired-settings.test.ts +96 -0
- package/src/core/__tests__/gated-boot.test.ts +132 -0
- package/src/core/__tests__/lifecycle.test.ts +241 -5
- package/src/core/__tests__/set-aside-root-is-one-place.test.ts +63 -0
- package/src/core/core-ports.ts +11 -1
- package/src/core/create-core-server.ts +52 -16
- package/src/core/create-core-services.ts +156 -24
- package/src/core/lifecycle.ts +117 -13
- package/src/core-config.ts +31 -14
- package/src/index.ts +30 -1
- package/src/modules/access/__tests__/access-control.preview-relocation.test.ts +385 -0
- package/src/modules/access/__tests__/access-control.prospective.test.ts +94 -18
- package/src/modules/access/__tests__/access.routes.prospective.test.ts +6 -7
- package/src/modules/access/__tests__/users-db-double.ts +21 -12
- package/src/modules/access/access-control.interface.ts +43 -12
- package/src/modules/access/access-control.service.ts +234 -36
- package/src/modules/access/access.routes.ts +17 -16
- package/src/modules/access/directory-sync-bot.ts +7 -3
- package/src/modules/agent-instructions/__tests__/agent-instructions.route.test.ts +11 -5
- package/src/modules/agent-instructions/__tests__/compose.test.ts +19 -10
- package/src/modules/agent-instructions/__tests__/shared-file-rules.test.ts +238 -0
- package/src/modules/agent-instructions/agent-instructions.routes.ts +12 -2
- package/src/modules/agent-instructions/compose.ts +50 -7
- package/src/modules/agent-instructions/index.ts +12 -0
- package/src/modules/agent-instructions/shared-file-rules.ts +314 -0
- package/src/modules/audit/agent-audit.service.ts +4 -2
- package/src/modules/auth/__tests__/account-deactivation.test.ts +253 -0
- package/src/modules/auth/__tests__/account-erasure.approval-gate.test.ts +6 -2
- package/src/modules/auth/__tests__/account.routes.test.ts +87 -6
- package/src/modules/auth/__tests__/auth.middleware.test.ts +45 -22
- package/src/modules/auth/__tests__/auth.service.test.ts +4 -2
- package/src/modules/auth/account-admission.ts +78 -9
- package/src/modules/auth/account-erasure.service.ts +69 -18
- package/src/modules/auth/account.routes.ts +63 -7
- package/src/modules/auth/auth.middleware.ts +19 -8
- package/src/modules/auth/auth.routes.ts +8 -0
- package/src/modules/auth/auth.service.ts +206 -23
- package/src/modules/auth/oidc-auth-provider.ts +7 -2
- package/src/modules/code-mode/__tests__/chain-runtime.e2e.test.ts +335 -0
- package/src/modules/code-mode/__tests__/code-mode.tool.test.ts +46 -2
- package/src/modules/code-mode/code-mode.tool.ts +80 -34
- package/src/modules/database/__tests__/connection.test.ts +12 -0
- package/src/modules/database/__tests__/pii-backfill.pg.test.ts +561 -0
- package/src/modules/database/connection.ts +117 -0
- package/src/modules/database/core-schema.ts +116 -58
- package/src/modules/database/migrate.ts +353 -1
- package/src/modules/kb-fs/__tests__/branch-name.test.ts +10 -0
- package/src/modules/kb-fs/__tests__/repo-path.test.ts +123 -0
- package/src/modules/kb-fs/branch-name.ts +14 -1
- package/src/modules/kb-fs/repo-path.ts +85 -0
- package/src/modules/kb-sync/__tests__/kb-sync.routes.test.ts +26 -1
- package/src/modules/kb-sync/kb-sync.routes.ts +14 -4
- package/src/modules/kb-sync/sync-auth.ts +2 -2
- package/src/modules/mcp/__tests__/mcp-auth.middleware.test.ts +60 -3
- package/src/modules/mcp/__tests__/mcp.e2e.test.ts +4 -3
- package/src/modules/mcp/__tests__/mcp.service.test.ts +115 -13
- package/src/modules/mcp/mcp-auth.middleware.ts +20 -6
- package/src/modules/mcp/mcp.service.ts +46 -7
- package/src/modules/mcp/oauth/bevel-oauth-provider.ts +3 -1
- package/src/modules/plugins/__tests__/plugins.tools.test.ts +2 -1
- package/src/modules/plugins/join-request-records.store.ts +7 -4
- package/src/modules/settings/__tests__/deployment-settings.service.test.ts +16 -0
- package/src/modules/settings/__tests__/setup.routes.git-mode.test.ts +91 -58
- package/src/modules/settings/__tests__/setup.routes.github-app.test.ts +25 -8
- package/src/modules/settings/__tests__/setup.routes.managed-phase.test.ts +14 -11
- package/src/modules/settings/__tests__/setup.routes.repository-change.test.ts +390 -0
- package/src/modules/settings/__tests__/setup.routes.test.ts +3 -0
- package/src/modules/settings/deployment-settings.service.ts +8 -3
- package/src/modules/settings/setup.routes.ts +263 -19
- package/src/modules/skills/__tests__/allowed-tools-warn.tools.test.ts +2 -1
- package/src/modules/skills/__tests__/branch-skills.tools.test.ts +218 -0
- package/src/modules/skills/__tests__/skills.service.test.ts +229 -5
- package/src/modules/skills/skills.contract.ts +91 -18
- package/src/modules/skills/skills.service.ts +278 -41
- package/src/modules/skills/skills.tools.ts +80 -8
- package/src/modules/tool-auth/__tests__/manual-auth.middleware.test.ts +14 -1
- package/src/modules/tool-auth/external-api-key.service.ts +12 -4
- package/src/modules/tool-auth/internal-token.service.ts +3 -3
- package/src/modules/tool-auth/tool-auth.middleware.ts +34 -11
- package/src/modules/tool-helpers/__tests__/agent-roles-write.test.ts +5 -3
- package/src/modules/tool-helpers/__tests__/phase4-tools.test.ts +3 -3
- package/src/modules/tool-helpers/__tests__/validate-token.test.ts +11 -1
- package/src/modules/tool-helpers/tool-handler.ts +24 -4
- package/src/modules/tool-helpers/tool.contract.ts +3 -2
- package/src/modules/tool-helpers/validate-token.ts +1 -1
- package/src/modules/tool-manuals/tool-manuals.tools.ts +44 -31
- package/src/modules/tool-registry/__tests__/tool-description-length.test.ts +378 -0
- package/src/modules/tool-registry/description-length.ts +111 -0
- package/src/modules/workflow/__tests__/pending-commits.repository-replaced.test.ts +111 -0
- package/src/modules/workflow/__tests__/workflow.routes.history-read-gate.test.ts +25 -0
- package/src/modules/workflow/__tests__/workflow.service.repository-replaced.test.ts +249 -0
- package/src/modules/workflow/agent-tools/__tests__/workflow.tools.test.ts +264 -6
- package/src/modules/workflow/agent-tools/change-request-summary.ts +182 -0
- package/src/modules/workflow/agent-tools/workflow.tools.ts +86 -35
- package/src/modules/workflow/file-lock.service.ts +31 -0
- package/src/modules/workflow/git/__tests__/git.service.fileBytesAtCommit.test.ts +260 -0
- package/src/modules/workflow/git/__tests__/git.service.prFetchFailure.test.ts +170 -0
- package/src/modules/workflow/git/git.service.ts +215 -1
- package/src/modules/workflow/pending-commits.service.ts +64 -2
- package/src/modules/workflow/recovery-bot.ts +7 -3
- package/src/modules/workflow/review-workflow/__tests__/carry-approvals-forward.test.ts +4 -0
- package/src/modules/workflow/review-workflow/__tests__/erase-approver.test.ts +25 -3
- package/src/modules/workflow/review-workflow/review-workflow.service.ts +12 -3
- package/src/modules/workflow/workflow-hooks.ts +64 -26
- package/src/modules/workflow/workflow.service.ts +125 -5
- package/src/modules/workspace/__tests__/agent-access.gate.test.ts +208 -0
- package/src/modules/workspace/__tests__/agent-uploads.test.ts +1604 -0
- package/src/modules/workspace/__tests__/escape-sequences.routes.test.ts +394 -0
- package/src/modules/workspace/__tests__/file-stat-access.test.ts +2 -1
- package/src/modules/workspace/__tests__/git-internals.security.test.ts +2 -1
- package/src/modules/workspace/__tests__/set-aside-clone.test.ts +52 -0
- package/src/modules/workspace/__tests__/workspace.routes.at-ref.test.ts +305 -0
- package/src/modules/workspace/__tests__/workspace.routes.download.test.ts +2 -0
- package/src/modules/workspace/__tests__/workspace.service.any-workspace-credentials.test.ts +156 -0
- package/src/modules/workspace/__tests__/workspace.service.forget-clone-races.test.ts +147 -0
- package/src/modules/workspace/__tests__/workspace.service.replaced-repository.test.ts +402 -0
- package/src/modules/workspace/__tests__/workspace.service.test.ts +77 -9
- package/src/modules/workspace/__tests__/workspace.tools.agents-file.test.ts +41 -39
- package/src/modules/workspace/__tests__/workspace.tools.branch-errors.test.ts +2 -3
- package/src/modules/workspace/__tests__/workspace.tools.test.ts +766 -56
- package/src/modules/workspace/agent-access.gate.ts +164 -0
- package/src/modules/workspace/agent-upload.routes.ts +214 -0
- package/src/modules/workspace/agent-upload.store.ts +668 -0
- package/src/modules/workspace/routine-write-policy.ts +5 -6
- package/src/modules/workspace/session-sink.ts +5 -5
- package/src/modules/workspace/set-aside-clone.ts +96 -0
- package/src/modules/workspace/startup/__tests__/kb-startup-runner.test.ts +86 -0
- package/src/modules/workspace/startup/kb-startup-runner.ts +115 -34
- package/src/modules/workspace/startup/steps/__tests__/steps.test.ts +9 -9
- package/src/modules/workspace/startup/steps/seed-tree.ts +3 -6
- package/src/modules/workspace/startup/steps/template-source.ts +53 -5
- package/src/modules/workspace/upload-limits.ts +12 -0
- package/src/modules/workspace/workspace.routes.ts +96 -5
- package/src/modules/workspace/workspace.service.ts +319 -61
- package/src/modules/workspace/workspace.tools.ts +894 -214
- package/src/modules/workspace/write-denial.ts +0 -8
- package/src/modules/workspace/zip-entry-rules.ts +173 -0
- package/src/modules/write-access/__tests__/write-access.test.ts +248 -0
- package/src/modules/write-access/write-access.ts +153 -0
- package/src/shared/__tests__/column-crypto.test.ts +217 -0
- package/src/shared/column-crypto.ts +218 -0
- package/src/shared/domain-errors.ts +31 -0
- package/src/shared/git.contract.ts +27 -0
- package/src/shared/token-crypto.ts +28 -1
- package/src/tenancy/__tests__/static-tenant-source.test.ts +4 -1
- package/src/tenancy/static-tenant-source.ts +1 -3
- package/src/tenancy/tenant-secrets.ts +5 -1
- package/dist/modules/workflow/session-ontology.policy.d.ts +0 -52
- package/dist/modules/workflow/session-ontology.policy.d.ts.map +0 -1
- package/dist/modules/workflow/session-ontology.policy.js +0 -62
- package/dist/modules/workflow/session-ontology.policy.js.map +0 -1
- package/dist/modules/workflow/session-ontology.service.d.ts +0 -105
- package/dist/modules/workflow/session-ontology.service.d.ts.map +0 -1
- package/dist/modules/workflow/session-ontology.service.js +0 -147
- package/dist/modules/workflow/session-ontology.service.js.map +0 -1
- package/dist/modules/workspace/session-ontology.gate.d.ts +0 -114
- package/dist/modules/workspace/session-ontology.gate.d.ts.map +0 -1
- package/dist/modules/workspace/session-ontology.gate.js +0 -161
- package/dist/modules/workspace/session-ontology.gate.js.map +0 -1
- package/dist/shared/kb-layout.d.ts +0 -39
- package/dist/shared/kb-layout.d.ts.map +0 -1
- package/dist/shared/kb-layout.js +0 -103
- package/dist/shared/kb-layout.js.map +0 -1
- package/dist/shared/kb-layout.test.d.ts +0 -2
- package/dist/shared/kb-layout.test.d.ts.map +0 -1
- package/dist/shared/kb-layout.test.js +0 -75
- package/dist/shared/kb-layout.test.js.map +0 -1
- package/src/modules/workflow/__tests__/session-ontology.policy.test.ts +0 -62
- package/src/modules/workflow/__tests__/session-ontology.service.test.ts +0 -201
- package/src/modules/workflow/session-ontology.policy.ts +0 -70
- package/src/modules/workflow/session-ontology.service.ts +0 -183
- package/src/modules/workspace/__tests__/session-ontology.gate.test.ts +0 -239
- package/src/modules/workspace/session-ontology.gate.ts +0 -191
- package/src/shared/kb-layout.test.ts +0 -98
- package/src/shared/kb-layout.ts +0 -102
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash, randomBytes } from 'node:crypto';
|
|
2
2
|
import { logger } from '../../shared/logging.js';
|
|
3
3
|
const log = logger('external-api-key');
|
|
4
|
-
import { and,
|
|
4
|
+
import { and, desc, eq, isNotNull, isNull } from 'drizzle-orm';
|
|
5
5
|
import { externalApiKeys, users } from '../database/schema.js';
|
|
6
6
|
import { InvalidTokenLabelError, TokenNotFoundError, TokenStillActiveError, } from './external-api-key.errors.js';
|
|
7
7
|
import { DEFAULT_KEY_KIND, } from './external-api-key.interface.js';
|
|
@@ -78,7 +78,9 @@ export class ExternalApiKeyService {
|
|
|
78
78
|
// Join users so a single round-trip resolves both "token is valid" and
|
|
79
79
|
// "load the user it belongs to". The unique index on token_hash makes
|
|
80
80
|
// this a point-lookup. `isNull(revokedAt)` is what enforces revocation
|
|
81
|
-
// — the row remains for audit
|
|
81
|
+
// — the row remains for audit — and `isNull(deactivatedAt)` is what
|
|
82
|
+
// stops a switched-off account's keys without revoking them, so
|
|
83
|
+
// switching it back on restores them.
|
|
82
84
|
const [row] = await this.db
|
|
83
85
|
.select({
|
|
84
86
|
tokenId: externalApiKeys.id,
|
|
@@ -89,7 +91,7 @@ export class ExternalApiKeyService {
|
|
|
89
91
|
})
|
|
90
92
|
.from(externalApiKeys)
|
|
91
93
|
.innerJoin(users, eq(externalApiKeys.userId, users.id))
|
|
92
|
-
.where(and(eq(externalApiKeys.tokenHash, tokenHash), isNull(externalApiKeys.revokedAt)))
|
|
94
|
+
.where(and(eq(externalApiKeys.tokenHash, tokenHash), isNull(externalApiKeys.revokedAt), isNull(users.deactivatedAt)))
|
|
93
95
|
.limit(1);
|
|
94
96
|
if (!row)
|
|
95
97
|
return null;
|
|
@@ -132,6 +134,11 @@ export class ExternalApiKeyService {
|
|
|
132
134
|
// Owner joined in so the admin overview is one round-trip; ordered by
|
|
133
135
|
// owner email so per-account grouping is a linear pass, newest key
|
|
134
136
|
// first within an account (same order the owner sees on their own page).
|
|
137
|
+
// The email half of that order is applied in-process: the column is
|
|
138
|
+
// ciphertext in the database, where ORDER BY would sort by IV noise. The
|
|
139
|
+
// sort is stable, so the database's newest-first survives within an owner.
|
|
140
|
+
// By code unit, not by locale: a collation can call two different
|
|
141
|
+
// addresses equal, and equal here means "the same owner's group".
|
|
135
142
|
const rows = await this.db
|
|
136
143
|
.select({
|
|
137
144
|
key: externalApiKeys,
|
|
@@ -141,7 +148,8 @@ export class ExternalApiKeyService {
|
|
|
141
148
|
})
|
|
142
149
|
.from(externalApiKeys)
|
|
143
150
|
.innerJoin(users, eq(externalApiKeys.userId, users.id))
|
|
144
|
-
.orderBy(
|
|
151
|
+
.orderBy(desc(externalApiKeys.createdAt));
|
|
152
|
+
rows.sort((a, b) => (a.email < b.email ? -1 : a.email > b.email ? 1 : 0));
|
|
145
153
|
return rows.map((row) => ({
|
|
146
154
|
...toSummary(row.key),
|
|
147
155
|
user: { id: row.userId, email: row.email, name: row.name },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-api-key.service.js","sourceRoot":"","sources":["../../../src/modules/tool-auth/external-api-key.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,MAAM,GAAG,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"external-api-key.service.js","sourceRoot":"","sources":["../../../src/modules/tool-auth/external-api-key.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,MAAM,GAAG,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAY,MAAM,aAAa,CAAC;AAGzE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,gBAAgB,GAQjB,MAAM,iCAAiC,CAAC;AAEzC,4EAA4E;AAC5E,yEAAyE;AACzE,wEAAwE;AACxE,mDAAmD;AACnD,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,0EAA0E;AAC1E,yEAAyE;AACzE,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B,MAAM,aAAa,GAAG,GAAG,CAAC;AAE1B,MAAM,OAAO,qBAAqB;IAeb;IACA;IACA;IAhBF,QAAQ,CAAoB;IAE7C;;;;;;;;;;OAUG;IACH,YACmB,EAAY,EACZ,SAAiB,EACjB,QAA+C,EAAE;QAFjD,OAAE,GAAF,EAAE,CAAU;QACZ,cAAS,GAAT,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,GAAG,CAAC,SAA8B,IAAI,IAAI;QACtD,SAAS,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI;KAC1D,CAAC;AACJ,CAAC"}
|
|
@@ -10,9 +10,9 @@ export interface InternalTokenClaim {
|
|
|
10
10
|
/**
|
|
11
11
|
* The agent run / conversation id (the Mastra thread id) this token is scoped
|
|
12
12
|
* to, when minted per-run. Surfaced as `ToolContext.sessionId` so the
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* agent-access hooks can tell the in-process agent's run apart (the
|
|
14
|
+
* external/MCP path carries `sessionId` on the tool body instead). Absent
|
|
15
|
+
* for identity-only tokens.
|
|
16
16
|
*/
|
|
17
17
|
sessionId?: string;
|
|
18
18
|
/**
|
|
@@ -62,10 +62,10 @@ declare global {
|
|
|
62
62
|
export declare const requireInternalSource: RequestHandler;
|
|
63
63
|
/**
|
|
64
64
|
* Mirror of `requireInternalSource` for surfaces that must admit ONLY external
|
|
65
|
-
* callers. `start_session` mints a fresh chat thread as the caller's
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
65
|
+
* callers. `start_session` mints a fresh chat thread as the caller's session
|
|
66
|
+
* id; an internal (in-process agent) token already carries its run's
|
|
67
|
+
* `sessionId`, so letting it mint a new thread mid-run would silently split
|
|
68
|
+
* one conversation in two.
|
|
69
69
|
*
|
|
70
70
|
* "External" is decided by the VERIFIER, not by which credential shape
|
|
71
71
|
* authenticated: a `bevel_…` connection key resolves external, and so does an
|
|
@@ -100,14 +100,23 @@ export type VerifyResult = {
|
|
|
100
100
|
* primitive both `createToolAuthMiddleware` (our Express hosting) and
|
|
101
101
|
* `validateToken` (the tool-author SDK) are built on, so there is ONE auth path.
|
|
102
102
|
*/
|
|
103
|
-
export declare function createTokenVerifier(externalApiKeyService: IExternalApiKeyService, internalTokenService: InternalTokenService
|
|
103
|
+
export declare function createTokenVerifier(externalApiKeyService: IExternalApiKeyService, internalTokenService: InternalTokenService,
|
|
104
|
+
/**
|
|
105
|
+
* Whether the account an internal token was minted for is still on. An
|
|
106
|
+
* internal token carries only a user id and lives up to an hour (longer
|
|
107
|
+
* for the MCP loopback), so without this a switched-off account's running
|
|
108
|
+
* agent would keep working until it expired. Connection keys need no
|
|
109
|
+
* second look: their lookup reads the account. Every deployment passes
|
|
110
|
+
* it; absent, internal tokens are judged on their signature alone.
|
|
111
|
+
*/
|
|
112
|
+
accounts?: Pick<AuthService, 'isActive'>): (token: string | undefined) => Promise<VerifyResult>;
|
|
104
113
|
/**
|
|
105
114
|
* The one auth gate every tool endpoint applies — a THIN Express adapter over
|
|
106
115
|
* `createTokenVerifier`: parse the bearer header, run the shared verify core,
|
|
107
116
|
* normalize the result to `req.toolAuth` (or the matching status). All auth logic
|
|
108
117
|
* lives in the verifier; this only does header parsing + HTTP mapping.
|
|
109
118
|
*/
|
|
110
|
-
export declare function createToolAuthMiddleware(externalApiKeyService: IExternalApiKeyService, internalTokenService: InternalTokenService): RequestHandler;
|
|
119
|
+
export declare function createToolAuthMiddleware(externalApiKeyService: IExternalApiKeyService, internalTokenService: InternalTokenService, accounts?: Pick<AuthService, 'isActive'>): RequestHandler;
|
|
111
120
|
/**
|
|
112
121
|
* Auth gate for the READ-ONLY discovery manuals (`GET /agent/utcp` +
|
|
113
122
|
* `/agent/internal/utcp`) ONLY. Superset of `createToolAuthMiddleware`: it
|
|
@@ -119,5 +128,5 @@ export declare function createToolAuthMiddleware(externalApiKeyService: IExterna
|
|
|
119
128
|
* JWT can read the manual but can never invoke a tool. The internal manual stays
|
|
120
129
|
* `requireInternalSource`-gated downstream, so a session/key is 403'd there.
|
|
121
130
|
*/
|
|
122
|
-
export declare function createManualAuthMiddleware(externalApiKeyService: IExternalApiKeyService, internalTokenService: InternalTokenService, authService: AuthService): RequestHandler;
|
|
131
|
+
export declare function createManualAuthMiddleware(externalApiKeyService: IExternalApiKeyService, internalTokenService: InternalTokenService, authService: Pick<AuthService, 'isActive' | 'resolveSession'>): RequestHandler;
|
|
123
132
|
//# sourceMappingURL=tool-auth.middleware.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-auth.middleware.d.ts","sourceRoot":"","sources":["../../../src/modules/tool-auth/tool-auth.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmC,cAAc,EAAE,MAAM,SAAS,CAAC;AAI/E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-auth.middleware.d.ts","sourceRoot":"","sources":["../../../src/modules/tool-auth/tool-auth.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmC,cAAc,EAAE,MAAM,SAAS,CAAC;AAI/E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAGnE;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gJAAgJ;IAChJ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iLAAiL;IACjL,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CACzB;AAED,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,OAAO,CAAC;QAChB,UAAU,OAAO;YACf,QAAQ,CAAC,EAAE,QAAQ,CAAC;SACrB;KACF;CACF;AAID;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,EAAE,cAMnC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,qBAAqB,EAAE,cAMnC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GACpB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GAC5B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvE;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,qBAAqB,EAAE,sBAAsB,EAC7C,oBAAoB,EAAE,oBAAoB;AAC1C;;;;;;;GAOG;AACH,QAAQ,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,GACvC,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC,YAAY,CAAC,CAwCtD;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,qBAAqB,EAAE,sBAAsB,EAC7C,oBAAoB,EAAE,oBAAoB,EAC1C,QAAQ,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,GACvC,cAAc,CAwBhB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CACxC,qBAAqB,EAAE,sBAAsB,EAC7C,oBAAoB,EAAE,oBAAoB,EAC1C,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,gBAAgB,CAAC,GAC5D,cAAc,CAgDhB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { logger } from '../../shared/logging.js';
|
|
2
2
|
const log = logger('tools');
|
|
3
|
+
import { ACCOUNT_DEACTIVATED_MESSAGE, AuthBackendError } from '../auth/account-admission.js';
|
|
3
4
|
import { INVALID_CONNECTION_KEY_CHALLENGE, INVALID_CONNECTION_KEY_MESSAGE } from './connection-key-rejection.js';
|
|
4
5
|
const WWW_AUTH = 'Bearer realm="bevel-tools"';
|
|
5
6
|
/**
|
|
@@ -23,10 +24,10 @@ export const requireInternalSource = (req, res, next) => {
|
|
|
23
24
|
};
|
|
24
25
|
/**
|
|
25
26
|
* Mirror of `requireInternalSource` for surfaces that must admit ONLY external
|
|
26
|
-
* callers. `start_session` mints a fresh chat thread as the caller's
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* callers. `start_session` mints a fresh chat thread as the caller's session
|
|
28
|
+
* id; an internal (in-process agent) token already carries its run's
|
|
29
|
+
* `sessionId`, so letting it mint a new thread mid-run would silently split
|
|
30
|
+
* one conversation in two.
|
|
30
31
|
*
|
|
31
32
|
* "External" is decided by the VERIFIER, not by which credential shape
|
|
32
33
|
* authenticated: a `bevel_…` connection key resolves external, and so does an
|
|
@@ -52,7 +53,16 @@ export const requireExternalSource = (req, res, next) => {
|
|
|
52
53
|
* primitive both `createToolAuthMiddleware` (our Express hosting) and
|
|
53
54
|
* `validateToken` (the tool-author SDK) are built on, so there is ONE auth path.
|
|
54
55
|
*/
|
|
55
|
-
export function createTokenVerifier(externalApiKeyService, internalTokenService
|
|
56
|
+
export function createTokenVerifier(externalApiKeyService, internalTokenService,
|
|
57
|
+
/**
|
|
58
|
+
* Whether the account an internal token was minted for is still on. An
|
|
59
|
+
* internal token carries only a user id and lives up to an hour (longer
|
|
60
|
+
* for the MCP loopback), so without this a switched-off account's running
|
|
61
|
+
* agent would keep working until it expired. Connection keys need no
|
|
62
|
+
* second look: their lookup reads the account. Every deployment passes
|
|
63
|
+
* it; absent, internal tokens are judged on their signature alone.
|
|
64
|
+
*/
|
|
65
|
+
accounts) {
|
|
56
66
|
const missing = { ok: false, status: 401, message: 'A connection key or internal token is required' };
|
|
57
67
|
return async (token) => {
|
|
58
68
|
if (!token)
|
|
@@ -67,6 +77,9 @@ export function createTokenVerifier(externalApiKeyService, internalTokenService)
|
|
|
67
77
|
const claim = internalTokenService.verify(token);
|
|
68
78
|
if (!claim)
|
|
69
79
|
return { ok: false, status: 401, message: 'Invalid or expired internal token' };
|
|
80
|
+
if (accounts && !(await accounts.isActive(claim.userId))) {
|
|
81
|
+
return { ok: false, status: 401, message: ACCOUNT_DEACTIVATED_MESSAGE };
|
|
82
|
+
}
|
|
70
83
|
return claim.externalProxy
|
|
71
84
|
? {
|
|
72
85
|
ok: true,
|
|
@@ -95,8 +108,8 @@ export function createTokenVerifier(externalApiKeyService, internalTokenService)
|
|
|
95
108
|
* normalize the result to `req.toolAuth` (or the matching status). All auth logic
|
|
96
109
|
* lives in the verifier; this only does header parsing + HTTP mapping.
|
|
97
110
|
*/
|
|
98
|
-
export function createToolAuthMiddleware(externalApiKeyService, internalTokenService) {
|
|
99
|
-
const verify = createTokenVerifier(externalApiKeyService, internalTokenService);
|
|
111
|
+
export function createToolAuthMiddleware(externalApiKeyService, internalTokenService, accounts) {
|
|
112
|
+
const verify = createTokenVerifier(externalApiKeyService, internalTokenService, accounts);
|
|
100
113
|
return async (req, res, next) => {
|
|
101
114
|
const header = req.headers.authorization;
|
|
102
115
|
if (!header || !header.toLowerCase().startsWith('bearer ')) {
|
|
@@ -134,7 +147,7 @@ export function createToolAuthMiddleware(externalApiKeyService, internalTokenSer
|
|
|
134
147
|
* `requireInternalSource`-gated downstream, so a session/key is 403'd there.
|
|
135
148
|
*/
|
|
136
149
|
export function createManualAuthMiddleware(externalApiKeyService, internalTokenService, authService) {
|
|
137
|
-
const verify = createTokenVerifier(externalApiKeyService, internalTokenService);
|
|
150
|
+
const verify = createTokenVerifier(externalApiKeyService, internalTokenService, authService);
|
|
138
151
|
return async (req, res, next) => {
|
|
139
152
|
const header = req.headers.authorization;
|
|
140
153
|
if (!header || !header.toLowerCase().startsWith('bearer ')) {
|
|
@@ -163,15 +176,24 @@ export function createManualAuthMiddleware(externalApiKeyService, internalTokenS
|
|
|
163
176
|
return;
|
|
164
177
|
}
|
|
165
178
|
// Otherwise treat the bearer as a browser session JWT.
|
|
179
|
+
let userId;
|
|
166
180
|
try {
|
|
167
|
-
|
|
168
|
-
req.toolAuth = { source: 'session', userId, scope: 'write' };
|
|
169
|
-
next();
|
|
181
|
+
({ userId } = await authService.resolveSession(token));
|
|
170
182
|
}
|
|
171
|
-
catch {
|
|
183
|
+
catch (err) {
|
|
184
|
+
// The account could not be looked up: an outage, not a verdict on the
|
|
185
|
+
// session, and a 401 would sign a valid caller out over it.
|
|
186
|
+
if (err instanceof AuthBackendError) {
|
|
187
|
+
log.error('session account lookup failed:', { err: err.cause });
|
|
188
|
+
res.status(500).json({ error: 'Authentication backend unavailable' });
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
172
191
|
res.setHeader('WWW-Authenticate', WWW_AUTH);
|
|
173
192
|
res.status(401).json({ error: 'Invalid or expired token' });
|
|
193
|
+
return;
|
|
174
194
|
}
|
|
195
|
+
req.toolAuth = { source: 'session', userId, scope: 'write' };
|
|
196
|
+
next();
|
|
175
197
|
};
|
|
176
198
|
}
|
|
177
199
|
//# sourceMappingURL=tool-auth.middleware.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-auth.middleware.js","sourceRoot":"","sources":["../../../src/modules/tool-auth/tool-auth.middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-auth.middleware.js","sourceRoot":"","sources":["../../../src/modules/tool-auth/tool-auth.middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;AAG5B,OAAO,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,MAAM,8BAA8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GAAG,YAAY,gBAAgB,EAAE,CAAC;gBACpC,GAAG,CAAC,KAAK,CAAC,gCAAgC,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;gBAChE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,oCAAoC,EAAE,CAAC,CAAC;gBACtE,OAAO;YACT,CAAC;YACD,GAAG,CAAC,SAAS,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;YAC5C,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,0BAA0B,EAAE,CAAC,CAAC;YAC5D,OAAO;QACT,CAAC;QACD,GAAG,CAAC,QAAQ,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;QAC7D,IAAI,EAAE,CAAC;IACT,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Request, Response } from 'express';
|
|
2
2
|
import { type ToolHandler } from './tool.contract.js';
|
|
3
3
|
import type { ResolveToolContext } from './tool-context.js';
|
|
4
|
+
import { type IWriteAccess } from '../write-access/write-access.js';
|
|
4
5
|
import '../tool-auth/tool-auth.middleware.js';
|
|
5
6
|
export interface ToolHandlerOptions {
|
|
6
7
|
/** Mutating tool — refuse read-scoped callers up front (defense in depth). */
|
|
@@ -14,6 +15,6 @@ export interface ToolHandlerOptions {
|
|
|
14
15
|
* The handler receives `req.body` as the flat args (UTCP's `body_field` already
|
|
15
16
|
* delivered the inner body as the request body).
|
|
16
17
|
*/
|
|
17
|
-
export declare function createToolHandlerFactory(resolve: ResolveToolContext): (handler: ToolHandler, opts?: ToolHandlerOptions) => (req: Request, res: Response) => Promise<void>;
|
|
18
|
+
export declare function createToolHandlerFactory(resolve: ResolveToolContext, writeAccess?: IWriteAccess): (handler: ToolHandler, opts?: ToolHandlerOptions) => (req: Request, res: Response) => Promise<void>;
|
|
18
19
|
export type ToolHandlerFactory = ReturnType<typeof createToolHandlerFactory>;
|
|
19
20
|
//# sourceMappingURL=tool-handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-handler.d.ts","sourceRoot":"","sources":["../../../src/modules/tool-helpers/tool-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAIjD,OAAO,EAA4B,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGhF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,sCAAsC,CAAC;AAU9C,MAAM,WAAW,kBAAkB;IACjC,8EAA8E;IAC9E,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"tool-handler.d.ts","sourceRoot":"","sources":["../../../src/modules/tool-helpers/tool-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAIjD,OAAO,EAA4B,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGhF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAmD,KAAK,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACrH,OAAO,sCAAsC,CAAC;AAU9C,MAAM,WAAW,kBAAkB;IACjC,8EAA8E;IAC9E,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,kBAAkB,EAAE,WAAW,GAAE,YAA6B,IAClF,SAAS,WAAW,EAAE,OAAM,kBAAuB,MAC/D,KAAK,OAAO,EAAE,KAAK,QAAQ,KAAG,OAAO,CAAC,IAAI,CAAC,CA4F5D;AAED,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
|
|
@@ -3,6 +3,7 @@ const log = logger('tools');
|
|
|
3
3
|
import { hasHttpStatus, ToolError } from './tool.contract.js';
|
|
4
4
|
import { WorkflowDomainError } from '../../shared/domain-errors.js';
|
|
5
5
|
import { domainErrorBody } from '../../shared/http-errors.js';
|
|
6
|
+
import { alwaysWritable, READ_ONLY_CODE, refuseWriteTool } from '../write-access/write-access.js';
|
|
6
7
|
import '../tool-auth/tool-auth.middleware.js'; // Express Request.toolAuth augmentation
|
|
7
8
|
function isAsyncIterable(v) {
|
|
8
9
|
return (typeof v === 'object' &&
|
|
@@ -17,7 +18,7 @@ function isAsyncIterable(v) {
|
|
|
17
18
|
* The handler receives `req.body` as the flat args (UTCP's `body_field` already
|
|
18
19
|
* delivered the inner body as the request body).
|
|
19
20
|
*/
|
|
20
|
-
export function createToolHandlerFactory(resolve) {
|
|
21
|
+
export function createToolHandlerFactory(resolve, writeAccess = alwaysWritable) {
|
|
21
22
|
return function toolHandler(handler, opts = {}) {
|
|
22
23
|
return async (req, res) => {
|
|
23
24
|
const auth = req.toolAuth;
|
|
@@ -29,11 +30,31 @@ export function createToolHandlerFactory(resolve) {
|
|
|
29
30
|
res.status(403).json({ error: 'This tool requires write access.' });
|
|
30
31
|
return;
|
|
31
32
|
}
|
|
33
|
+
// Before anything is awaited: a client that goes away during the
|
|
34
|
+
// write-access check below must still abort the call.
|
|
35
|
+
//
|
|
36
|
+
// Asked of the RESPONSE. The request closes as soon as its body has
|
|
37
|
+
// been read, with the client still there and waiting, so its `close`
|
|
38
|
+
// says nothing about the client; the response closes when it has been
|
|
39
|
+
// sent or the connection is gone, and `writableEnded` tells the two
|
|
40
|
+
// apart.
|
|
32
41
|
const abort = new AbortController();
|
|
33
|
-
|
|
42
|
+
res.on('close', () => {
|
|
34
43
|
if (!res.writableEnded)
|
|
35
44
|
abort.abort();
|
|
36
45
|
});
|
|
46
|
+
// The tool layer's half of the read-only gate: the HTTP gate lets every
|
|
47
|
+
// tool call through, since only here is a write tool told from a read.
|
|
48
|
+
if (opts.write) {
|
|
49
|
+
const refusal = await refuseWriteTool(writeAccess);
|
|
50
|
+
if (refusal !== null) {
|
|
51
|
+
res.status(403).json({ error: refusal, code: READ_ONLY_CODE });
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
// The client left while the verdict was awaited: nobody to answer.
|
|
55
|
+
if (abort.signal.aborted)
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
37
58
|
const body = req.body;
|
|
38
59
|
if (body !== undefined && body !== null && (typeof body !== 'object' || Array.isArray(body))) {
|
|
39
60
|
res.status(400).json({ error: 'Request body must be a JSON object.' });
|
|
@@ -42,8 +63,8 @@ export function createToolHandlerFactory(resolve) {
|
|
|
42
63
|
const args = (body ?? {});
|
|
43
64
|
// `sessionId` rides the tool body like `branch` does: the external MCP
|
|
44
65
|
// proxy injects it (ask-tool continuity convention) and the in-process
|
|
45
|
-
// agent passes its thread id. Surfaced on the context so the
|
|
46
|
-
// gate can
|
|
66
|
+
// agent passes its thread id. Surfaced on the context so the
|
|
67
|
+
// agent-access gate can name the run without each handler re-reading args.
|
|
47
68
|
const sessionId = typeof args.sessionId === 'string' && args.sessionId.length > 0
|
|
48
69
|
? args.sessionId
|
|
49
70
|
: undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-handler.js","sourceRoot":"","sources":["../../../src/modules/tool-helpers/tool-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,SAAS,EAAoB,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,E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AAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;YACvC,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -30,8 +30,9 @@ export interface ToolContext {
|
|
|
30
30
|
* The agent run / conversation id this call belongs to (the agent thread id).
|
|
31
31
|
* Supplied as a `sessionId` field on the tool's input body — the external MCP
|
|
32
32
|
* proxy injects it via the `ask`-tool continuity convention, and the
|
|
33
|
-
* in-process agent passes its thread id.
|
|
34
|
-
*
|
|
33
|
+
* in-process agent passes its thread id. Handed to the agent-access hooks,
|
|
34
|
+
* which is how a deployment scopes a rule to one conversation. Absent for
|
|
35
|
+
* non-agent or unthreaded calls.
|
|
35
36
|
*/
|
|
36
37
|
sessionId?: string;
|
|
37
38
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.contract.d.ts","sourceRoot":"","sources":["../../../src/modules/tool-helpers/tool.contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IAIxB,MAAM,EAAE,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;IAC5C,gFAAgF;IAChF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB
|
|
1
|
+
{"version":3,"file":"tool.contract.d.ts","sourceRoot":"","sources":["../../../src/modules/tool-helpers/tool.contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK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CAAC,MAAM,EAAE,OAAO,CAAC,YAAA;CAK7C;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAUtF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.contract.js","sourceRoot":"","sources":["../../../src/modules/tool-helpers/tool.contract.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tool.contract.js","sourceRoot":"","sources":["../../../src/modules/tool-helpers/tool.contract.ts"],"names":[],"mappings":"AAqEA;;;;;;;;GAQG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAGvB;IACA;IAHX,YACE,OAAe,EACN,MAAc,EACd,OAAiC;QAE1C,KAAK,CAAC,OAAO,CAAC,CAAC;QAHN,WAAM,GAAN,MAAM,CAAQ;QACd,YAAO,GAAP,OAAO,CAA0B;QAG1C,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;CACF;AAED,MAAM,UAAU,aAAa,CAAC,GAAY;IACxC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC1D,MAAM,MAAM,GAAI,GAA4B,CAAC,MAAM,CAAC;IACpD,OAAO,CACL,OAAO,MAAM,KAAK,QAAQ;QAC1B,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC;QACxB,MAAM,IAAI,GAAG;QACb,MAAM,IAAI,GAAG;QACb,OAAQ,GAA6B,CAAC,OAAO,KAAK,QAAQ,CAC3D,CAAC;AACJ,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { createTokenVerifier } from '../tool-auth/tool-auth.middleware.js';
|
|
|
2
2
|
import { createToolContextResolver } from './tool-context.js';
|
|
3
3
|
import { ToolError } from './tool.contract.js';
|
|
4
4
|
export function createToolValidator(deps) {
|
|
5
|
-
const verify = createTokenVerifier(deps.externalApiKeyService, deps.internalTokenService);
|
|
5
|
+
const verify = createTokenVerifier(deps.externalApiKeyService, deps.internalTokenService, deps.authService);
|
|
6
6
|
const resolve = createToolContextResolver(deps);
|
|
7
7
|
return async (token, signal) => {
|
|
8
8
|
let result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-token.js","sourceRoot":"","sources":["../../../src/modules/tool-helpers/validate-token.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAwB,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,SAAS,EAAoB,MAAM,oBAAoB,CAAC;AAgCjE,MAAM,UAAU,mBAAmB,CAAC,IAAuB;IACzD,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,qBAAqB,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"validate-token.js","sourceRoot":"","sources":["../../../src/modules/tool-helpers/validate-token.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAwB,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,SAAS,EAAoB,MAAM,oBAAoB,CAAC;AAgCjE,MAAM,UAAU,mBAAmB,CAAC,IAAuB;IACzD,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,qBAAqB,EAAE,IAAI,CAAC,oBAAoB,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAC5G,MAAM,OAAO,GAAG,yBAAyB,CAAC,IAAI,CAAC,CAAC;IAChD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;QAC7B,IAAI,MAAM,CAAC;QACX,IAAI,CAAC;YACH,MAAM,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;YACP,M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ACzD,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,eAAe,GAAG,oBAAoB,CAAC,CAAC;CAC7D,GACA,IAAI,CAmNN"}
|
|
@@ -25,31 +25,23 @@ export function registerToolManualsTools(registry, router, toolAuth, toolHandler
|
|
|
25
25
|
const varKey = (manualName, varName) => utcpNamespacedKey(manualName, varName);
|
|
26
26
|
const listSetupDef = toolDef({
|
|
27
27
|
name: 'list_tool_setup',
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
'
|
|
35
|
-
'
|
|
36
|
-
'
|
|
37
|
-
'
|
|
38
|
-
'
|
|
39
|
-
'
|
|
40
|
-
'
|
|
41
|
-
'is
|
|
42
|
-
'
|
|
43
|
-
'tool
|
|
44
|
-
'
|
|
45
|
-
'are the only ones missing — every other tool is listed and callable, and a refused file is listed ' +
|
|
46
|
-
'again as a normal tool on the next call once it is fixed (or removed), with nothing to restart or ' +
|
|
47
|
-
'reconnect. ' +
|
|
48
|
-
'The listing is the RELEASED catalog, built from the default branch only: a server or `.tool` you ' +
|
|
49
|
-
'declared on a draft is not listed, not callable and not signed-in-able until that draft is merged. ' +
|
|
50
|
-
'Pass `branch` (the draft you wrote the declaration on) and `onBranchOnly` names every tool declared ' +
|
|
51
|
-
'there that the default branch does not serve yet — open a change request, then ask the user to ' +
|
|
52
|
-
'review and merge it in the app to activate it.',
|
|
28
|
+
// What each FIELD means is documented on the field, in `outputs` below:
|
|
29
|
+
// `setup.kind`, `variables` and `invalid` each carried a paragraph here,
|
|
30
|
+
// which made this description two thousand characters and so the first
|
|
31
|
+
// thing a client cut. The description says what the tool answers and the
|
|
32
|
+
// three things an agent cannot read off a field.
|
|
33
|
+
description: 'Configuration status of every `.tool` the current user can access: what each tool needs set up and what is ' +
|
|
34
|
+
'already configured, as `{ tools, invalid, onBranchOnly, note? }`. Scoped to the CALLER — a `.tool` it cannot ' +
|
|
35
|
+
'READ is absent entirely, and every flag is the caller\'s own state. ' +
|
|
36
|
+
'Secret VALUES are never returned and can never be set through a tool: an admin enters them in the tool editor, ' +
|
|
37
|
+
'and users sign in on /connect rather than typing a value. ' +
|
|
38
|
+
'What gates setting a tool\'s shared secrets is `canWrite` on the `.tool` FILE — per-file access from its ' +
|
|
39
|
+
'frontmatter `write:`/`owner:` verbs and the access.md chain, NOT a platform role: the people who manage the ' +
|
|
40
|
+
'file configure the tool. ' +
|
|
41
|
+
'The listing is the RELEASED catalog, built from the default branch only: a server or `.tool` you declared on a ' +
|
|
42
|
+
'draft is not listed, not callable and not signed-in-able until that draft is merged. Pass `branch` (the draft ' +
|
|
43
|
+
'you wrote the declaration on) and `onBranchOnly` names every tool declared there that the default branch does ' +
|
|
44
|
+
'not serve yet — open a change request, then ask the user to review and merge it in the app to activate it.',
|
|
53
45
|
path: '/api/agent/tools/list_tool_setup',
|
|
54
46
|
inputs: {
|
|
55
47
|
type: 'object',
|
|
@@ -77,12 +69,30 @@ export function registerToolManualsTools(registry, router, toolAuth, toolHandler
|
|
|
77
69
|
type: { type: 'string' },
|
|
78
70
|
setup: {
|
|
79
71
|
type: ['object', 'null'],
|
|
80
|
-
description:
|
|
81
|
-
properties: {
|
|
72
|
+
description: "An MCP server's sign-in requirement; null for non-mcp tools.",
|
|
73
|
+
properties: {
|
|
74
|
+
kind: {
|
|
75
|
+
type: 'string',
|
|
76
|
+
description: '`open` = no sign-in; `oauth-auto` = sign-in was configured automatically; `oauth-manual` = the ' +
|
|
77
|
+
'sign-in needs an OAuth app the owner registers with the provider: a writer declares its client ' +
|
|
78
|
+
'id on a `user`-scoped variable with an `oauth` block — in the plugin.json extensions entry for ' +
|
|
79
|
+
'an mcp.json server (endpoints are discovered from the server; PKCE is on by default), or in the ' +
|
|
80
|
+
'`.tool` file with explicit URLs — and pastes the client secret on the tool\'s page.',
|
|
81
|
+
},
|
|
82
|
+
reason: {
|
|
83
|
+
type: 'string',
|
|
84
|
+
description: 'Present only while something still blocks the sign-in, and says what.',
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
canWrite: {
|
|
89
|
+
type: 'boolean',
|
|
90
|
+
description: 'You may write this `.tool` FILE, which is what gates setting its shared secrets.',
|
|
82
91
|
},
|
|
83
|
-
canWrite: { type: 'boolean' },
|
|
84
92
|
variables: {
|
|
85
93
|
type: 'array',
|
|
94
|
+
description: 'What this tool needs configured, and by whom: per variable, whether the shared (admin) value is ' +
|
|
95
|
+
'set and whether the CURRENT user has set or authorized their own.',
|
|
86
96
|
items: {
|
|
87
97
|
type: 'object',
|
|
88
98
|
properties: {
|
|
@@ -106,9 +116,10 @@ export function registerToolManualsTools(registry, router, toolAuth, toolHandler
|
|
|
106
116
|
},
|
|
107
117
|
invalid: {
|
|
108
118
|
type: 'array',
|
|
109
|
-
description: '`.tool` files the scan refused — the ONLY tools missing from `tools
|
|
110
|
-
'why it was refused, with the line/column or field where the validation
|
|
111
|
-
'delete it) and the next call lists it as a normal tool
|
|
119
|
+
description: '`.tool` files the scan refused — the ONLY tools missing from `tools`; every other tool is listed and ' +
|
|
120
|
+
'callable. Each names the file and why it was refused, with the line/column or field where the validation ' +
|
|
121
|
+
'failed. Fix the file (or delete it) and the next call lists it as a normal tool, with nothing to restart ' +
|
|
122
|
+
'or reconnect. Never contains a secret value.',
|
|
112
123
|
items: {
|
|
113
124
|
type: 'object',
|
|
114
125
|
properties: {
|