@bevel-software/platform-core-backend 0.20.0 → 0.21.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/catalog-cache-invalidation.d.ts +7 -2
- package/dist/core/catalog-cache-invalidation.d.ts.map +1 -1
- package/dist/core/catalog-cache-invalidation.js +8 -9
- package/dist/core/catalog-cache-invalidation.js.map +1 -1
- package/dist/core/core-ports.d.ts +19 -0
- 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 +2 -0
- package/dist/core/create-core-server.d.ts.map +1 -1
- package/dist/core/create-core-server.js +23 -105
- package/dist/core/create-core-server.js.map +1 -1
- package/dist/core/create-core-services.d.ts +30 -5
- package/dist/core/create-core-services.d.ts.map +1 -1
- package/dist/core/create-core-services.js +136 -81
- package/dist/core/create-core-services.js.map +1 -1
- package/dist/core/lifecycle.d.ts +74 -28
- package/dist/core/lifecycle.d.ts.map +1 -1
- package/dist/core/lifecycle.js +157 -20
- package/dist/core/lifecycle.js.map +1 -1
- package/dist/core/public-config.d.ts +5 -1
- package/dist/core/public-config.d.ts.map +1 -1
- package/dist/core/public-config.js +7 -5
- package/dist/core/public-config.js.map +1 -1
- package/dist/core-config.d.ts +95 -1
- package/dist/core-config.d.ts.map +1 -1
- package/dist/core-config.js +24 -8
- package/dist/core-config.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/modules/access/access-control.service.d.ts +18 -1
- package/dist/modules/access/access-control.service.d.ts.map +1 -1
- package/dist/modules/access/access-control.service.js +19 -8
- package/dist/modules/access/access-control.service.js.map +1 -1
- package/dist/modules/access/access.routes.d.ts +2 -1
- package/dist/modules/access/access.routes.d.ts.map +1 -1
- package/dist/modules/access/access.routes.js +10 -10
- package/dist/modules/access/access.routes.js.map +1 -1
- package/dist/modules/access/change-read-gate.d.ts +6 -3
- package/dist/modules/access/change-read-gate.d.ts.map +1 -1
- package/dist/modules/access/change-read-gate.js +9 -6
- package/dist/modules/access/change-read-gate.js.map +1 -1
- package/dist/modules/access/creator-access.d.ts +4 -2
- package/dist/modules/access/creator-access.d.ts.map +1 -1
- package/dist/modules/access/creator-access.js +7 -4
- package/dist/modules/access/creator-access.js.map +1 -1
- package/dist/modules/agent-instructions/read-preamble.d.ts +2 -1
- package/dist/modules/agent-instructions/read-preamble.d.ts.map +1 -1
- package/dist/modules/agent-instructions/read-preamble.js +6 -9
- package/dist/modules/agent-instructions/read-preamble.js.map +1 -1
- package/dist/modules/auth/account-admission.d.ts +40 -0
- package/dist/modules/auth/account-admission.d.ts.map +1 -0
- package/dist/modules/auth/account-admission.js +17 -0
- package/dist/modules/auth/account-admission.js.map +1 -0
- package/dist/modules/auth/account.routes.d.ts.map +1 -1
- package/dist/modules/auth/account.routes.js +4 -1
- package/dist/modules/auth/account.routes.js.map +1 -1
- package/dist/modules/auth/auth.service.d.ts +19 -1
- package/dist/modules/auth/auth.service.d.ts.map +1 -1
- package/dist/modules/auth/auth.service.js +33 -1
- 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 +9 -0
- package/dist/modules/auth/oidc-auth-provider.js.map +1 -1
- package/dist/modules/connection-probe/connection-probe.service.d.ts +13 -1
- package/dist/modules/connection-probe/connection-probe.service.d.ts.map +1 -1
- package/dist/modules/connection-probe/connection-probe.service.js +10 -2
- package/dist/modules/connection-probe/connection-probe.service.js.map +1 -1
- package/dist/modules/database/advisory-lock.d.ts +17 -0
- package/dist/modules/database/advisory-lock.d.ts.map +1 -1
- package/dist/modules/database/advisory-lock.js +24 -3
- package/dist/modules/database/advisory-lock.js.map +1 -1
- package/dist/modules/database/connection.d.ts +67 -2
- package/dist/modules/database/connection.d.ts.map +1 -1
- package/dist/modules/database/connection.js +118 -12
- package/dist/modules/database/connection.js.map +1 -1
- package/dist/modules/database/migrate.d.ts +1 -1
- package/dist/modules/database/migrate.d.ts.map +1 -1
- package/dist/modules/database/migrate.js +27 -3
- package/dist/modules/database/migrate.js.map +1 -1
- package/dist/modules/kb-fs/branch-name.d.ts +0 -1
- package/dist/modules/kb-fs/branch-name.d.ts.map +1 -1
- package/dist/modules/kb-fs/branch-name.js +3 -3
- package/dist/modules/kb-fs/branch-name.js.map +1 -1
- package/dist/modules/kb-fs/clone-config.d.ts +9 -8
- package/dist/modules/kb-fs/clone-config.d.ts.map +1 -1
- package/dist/modules/kb-fs/clone-config.js +14 -12
- package/dist/modules/kb-fs/clone-config.js.map +1 -1
- package/dist/modules/mcp/mcp.service.d.ts +7 -0
- package/dist/modules/mcp/mcp.service.d.ts.map +1 -1
- package/dist/modules/mcp/mcp.service.js +4 -4
- package/dist/modules/mcp/mcp.service.js.map +1 -1
- package/dist/modules/plugins/compile/marketplace-compiler.service.d.ts +4 -4
- package/dist/modules/plugins/compile/marketplace-compiler.service.d.ts.map +1 -1
- package/dist/modules/plugins/compile/marketplace-compiler.service.js +7 -10
- package/dist/modules/plugins/compile/marketplace-compiler.service.js.map +1 -1
- package/dist/modules/plugins/discovery/bundle-dialect/bundle.source.d.ts +4 -1
- package/dist/modules/plugins/discovery/bundle-dialect/bundle.source.d.ts.map +1 -1
- package/dist/modules/plugins/discovery/bundle-dialect/bundle.source.js +5 -3
- package/dist/modules/plugins/discovery/bundle-dialect/bundle.source.js.map +1 -1
- package/dist/modules/plugins/discovery/kb-plugin-source.d.ts +6 -1
- package/dist/modules/plugins/discovery/kb-plugin-source.d.ts.map +1 -1
- package/dist/modules/plugins/discovery/kb-plugin-source.js +14 -9
- package/dist/modules/plugins/discovery/kb-plugin-source.js.map +1 -1
- package/dist/modules/plugins/discovery/native.source.d.ts +4 -1
- package/dist/modules/plugins/discovery/native.source.d.ts.map +1 -1
- package/dist/modules/plugins/discovery/native.source.js +4 -2
- package/dist/modules/plugins/discovery/native.source.js.map +1 -1
- package/dist/modules/plugins/index.d.ts +1 -1
- package/dist/modules/plugins/index.d.ts.map +1 -1
- package/dist/modules/plugins/index.js +1 -1
- package/dist/modules/plugins/index.js.map +1 -1
- package/dist/modules/plugins/join-request-jobs.service.d.ts +3 -1
- package/dist/modules/plugins/join-request-jobs.service.d.ts.map +1 -1
- package/dist/modules/plugins/join-request-jobs.service.js +6 -6
- package/dist/modules/plugins/join-request-jobs.service.js.map +1 -1
- package/dist/modules/plugins/join-requests.service.d.ts +3 -1
- package/dist/modules/plugins/join-requests.service.d.ts.map +1 -1
- package/dist/modules/plugins/join-requests.service.js +9 -8
- package/dist/modules/plugins/join-requests.service.js.map +1 -1
- package/dist/modules/plugins/plugin-links.d.ts +65 -10
- package/dist/modules/plugins/plugin-links.d.ts.map +1 -1
- package/dist/modules/plugins/plugin-links.js +136 -31
- package/dist/modules/plugins/plugin-links.js.map +1 -1
- package/dist/modules/plugins/plugin-links.service.d.ts +107 -5
- package/dist/modules/plugins/plugin-links.service.d.ts.map +1 -1
- package/dist/modules/plugins/plugin-links.service.js +151 -21
- package/dist/modules/plugins/plugin-links.service.js.map +1 -1
- package/dist/modules/plugins/plugin-provision.service.d.ts +10 -3
- package/dist/modules/plugins/plugin-provision.service.d.ts.map +1 -1
- package/dist/modules/plugins/plugin-provision.service.js +33 -26
- package/dist/modules/plugins/plugin-provision.service.js.map +1 -1
- package/dist/modules/plugins/plugin-rename.service.d.ts +4 -2
- package/dist/modules/plugins/plugin-rename.service.d.ts.map +1 -1
- package/dist/modules/plugins/plugin-rename.service.js +10 -12
- package/dist/modules/plugins/plugin-rename.service.js.map +1 -1
- package/dist/modules/plugins/plugins.routes.d.ts +3 -0
- package/dist/modules/plugins/plugins.routes.d.ts.map +1 -1
- package/dist/modules/plugins/plugins.routes.js +45 -15
- package/dist/modules/plugins/plugins.routes.js.map +1 -1
- package/dist/modules/plugins/plugins.service.d.ts +4 -4
- package/dist/modules/plugins/plugins.service.d.ts.map +1 -1
- package/dist/modules/plugins/plugins.service.js +7 -10
- package/dist/modules/plugins/plugins.service.js.map +1 -1
- package/dist/modules/plugins/teams.routes.d.ts +4 -1
- package/dist/modules/plugins/teams.routes.d.ts.map +1 -1
- package/dist/modules/plugins/teams.routes.js +11 -9
- package/dist/modules/plugins/teams.routes.js.map +1 -1
- package/dist/modules/secrets-vault/index.d.ts +1 -1
- package/dist/modules/secrets-vault/index.d.ts.map +1 -1
- package/dist/modules/secrets-vault/index.js +1 -1
- package/dist/modules/secrets-vault/index.js.map +1 -1
- package/dist/modules/secrets-vault/secrets-variable-loader.d.ts +29 -11
- package/dist/modules/secrets-vault/secrets-variable-loader.d.ts.map +1 -1
- package/dist/modules/secrets-vault/secrets-variable-loader.js +46 -21
- package/dist/modules/secrets-vault/secrets-variable-loader.js.map +1 -1
- package/dist/modules/secrets-vault/secrets-vault.routes.d.ts +3 -0
- package/dist/modules/secrets-vault/secrets-vault.routes.d.ts.map +1 -1
- package/dist/modules/secrets-vault/secrets-vault.routes.js +4 -6
- package/dist/modules/secrets-vault/secrets-vault.routes.js.map +1 -1
- package/dist/modules/settings/deployment-settings.service.d.ts +12 -8
- package/dist/modules/settings/deployment-settings.service.d.ts.map +1 -1
- package/dist/modules/settings/deployment-settings.service.js +20 -22
- package/dist/modules/settings/deployment-settings.service.js.map +1 -1
- package/dist/modules/settings/setup.routes.d.ts +9 -2
- package/dist/modules/settings/setup.routes.d.ts.map +1 -1
- package/dist/modules/settings/setup.routes.js +20 -14
- package/dist/modules/settings/setup.routes.js.map +1 -1
- package/dist/modules/skills/allowed-tools-check.d.ts +4 -3
- package/dist/modules/skills/allowed-tools-check.d.ts.map +1 -1
- package/dist/modules/skills/allowed-tools-check.js +8 -8
- package/dist/modules/skills/allowed-tools-check.js.map +1 -1
- package/dist/modules/skills/pending-skills.service.d.ts +3 -1
- package/dist/modules/skills/pending-skills.service.d.ts.map +1 -1
- package/dist/modules/skills/pending-skills.service.js +9 -6
- package/dist/modules/skills/pending-skills.service.js.map +1 -1
- package/dist/modules/skills/skill-access-requests.routes.d.ts +2 -1
- package/dist/modules/skills/skill-access-requests.routes.d.ts.map +1 -1
- package/dist/modules/skills/skill-access-requests.routes.js +6 -6
- package/dist/modules/skills/skill-access-requests.routes.js.map +1 -1
- package/dist/modules/skills/skills.routes.d.ts +4 -1
- package/dist/modules/skills/skills.routes.d.ts.map +1 -1
- package/dist/modules/skills/skills.routes.js +4 -4
- package/dist/modules/skills/skills.routes.js.map +1 -1
- package/dist/modules/skills/skills.service.d.ts +4 -2
- package/dist/modules/skills/skills.service.d.ts.map +1 -1
- package/dist/modules/skills/skills.service.js +13 -11
- package/dist/modules/skills/skills.service.js.map +1 -1
- package/dist/modules/tool-manuals/mcp-json-discovery.d.ts +2 -1
- package/dist/modules/tool-manuals/mcp-json-discovery.d.ts.map +1 -1
- package/dist/modules/tool-manuals/mcp-json-discovery.js +6 -5
- package/dist/modules/tool-manuals/mcp-json-discovery.js.map +1 -1
- package/dist/modules/tool-manuals/mcp-server-edit.service.d.ts +4 -2
- package/dist/modules/tool-manuals/mcp-server-edit.service.d.ts.map +1 -1
- package/dist/modules/tool-manuals/mcp-server-edit.service.js +12 -10
- package/dist/modules/tool-manuals/mcp-server-edit.service.js.map +1 -1
- package/dist/modules/tool-manuals/pending-tools.service.d.ts +3 -1
- package/dist/modules/tool-manuals/pending-tools.service.d.ts.map +1 -1
- package/dist/modules/tool-manuals/pending-tools.service.js +19 -16
- package/dist/modules/tool-manuals/pending-tools.service.js.map +1 -1
- package/dist/modules/tool-manuals/tool-delete.service.d.ts +4 -2
- package/dist/modules/tool-manuals/tool-delete.service.d.ts.map +1 -1
- package/dist/modules/tool-manuals/tool-delete.service.js +14 -12
- package/dist/modules/tool-manuals/tool-delete.service.js.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.routes.d.ts +3 -1
- package/dist/modules/tool-manuals/tool-manuals.routes.d.ts.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.routes.js +7 -7
- package/dist/modules/tool-manuals/tool-manuals.routes.js.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.service.d.ts +4 -2
- package/dist/modules/tool-manuals/tool-manuals.service.d.ts.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.service.js +15 -12
- package/dist/modules/tool-manuals/tool-manuals.service.js.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.tools.d.ts +3 -0
- package/dist/modules/tool-manuals/tool-manuals.tools.d.ts.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.tools.js +4 -6
- package/dist/modules/tool-manuals/tool-manuals.tools.js.map +1 -1
- package/dist/modules/workflow/agent-tools/workflow.tools.d.ts +3 -2
- package/dist/modules/workflow/agent-tools/workflow.tools.d.ts.map +1 -1
- package/dist/modules/workflow/agent-tools/workflow.tools.js +9 -9
- package/dist/modules/workflow/agent-tools/workflow.tools.js.map +1 -1
- package/dist/modules/workflow/git/git.service.d.ts +11 -5
- package/dist/modules/workflow/git/git.service.d.ts.map +1 -1
- package/dist/modules/workflow/git/git.service.js +23 -14
- package/dist/modules/workflow/git/git.service.js.map +1 -1
- package/dist/modules/workflow/git/node-git-runner.d.ts +26 -2
- package/dist/modules/workflow/git/node-git-runner.d.ts.map +1 -1
- package/dist/modules/workflow/git/node-git-runner.js +35 -5
- package/dist/modules/workflow/git/node-git-runner.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 +9 -4
- package/dist/modules/workflow/review-workflow/review-workflow.service.js.map +1 -1
- package/dist/modules/workflow/session-ontology.service.d.ts +6 -1
- package/dist/modules/workflow/session-ontology.service.d.ts.map +1 -1
- package/dist/modules/workflow/session-ontology.service.js +6 -2
- package/dist/modules/workflow/session-ontology.service.js.map +1 -1
- package/dist/modules/workflow/workflow.service.d.ts +8 -3
- package/dist/modules/workflow/workflow.service.d.ts.map +1 -1
- package/dist/modules/workflow/workflow.service.js +33 -23
- package/dist/modules/workflow/workflow.service.js.map +1 -1
- package/dist/modules/workspace/session-ontology.gate.d.ts +3 -1
- package/dist/modules/workspace/session-ontology.gate.d.ts.map +1 -1
- package/dist/modules/workspace/session-ontology.gate.js +3 -3
- package/dist/modules/workspace/session-ontology.gate.js.map +1 -1
- package/dist/modules/workspace/startup/kb-git.d.ts +4 -3
- package/dist/modules/workspace/startup/kb-git.d.ts.map +1 -1
- package/dist/modules/workspace/startup/kb-git.js +15 -13
- package/dist/modules/workspace/startup/kb-git.js.map +1 -1
- package/dist/modules/workspace/startup/kb-startup-runner.d.ts +5 -8
- package/dist/modules/workspace/startup/kb-startup-runner.d.ts.map +1 -1
- package/dist/modules/workspace/startup/kb-startup-runner.js +35 -38
- package/dist/modules/workspace/startup/kb-startup-runner.js.map +1 -1
- package/dist/modules/workspace/startup/steps/groups-to-plugins.step.d.ts +7 -1
- package/dist/modules/workspace/startup/steps/groups-to-plugins.step.d.ts.map +1 -1
- package/dist/modules/workspace/startup/steps/groups-to-plugins.step.js +23 -16
- package/dist/modules/workspace/startup/steps/groups-to-plugins.step.js.map +1 -1
- package/dist/modules/workspace/startup/steps/personal-spaces.step.d.ts +7 -1
- package/dist/modules/workspace/startup/steps/personal-spaces.step.d.ts.map +1 -1
- package/dist/modules/workspace/startup/steps/personal-spaces.step.js +12 -5
- package/dist/modules/workspace/startup/steps/personal-spaces.step.js.map +1 -1
- package/dist/modules/workspace/startup/steps/plugin-display-names.step.d.ts +7 -1
- package/dist/modules/workspace/startup/steps/plugin-display-names.step.d.ts.map +1 -1
- package/dist/modules/workspace/startup/steps/plugin-display-names.step.js +12 -5
- package/dist/modules/workspace/startup/steps/plugin-display-names.step.js.map +1 -1
- package/dist/modules/workspace/startup/steps/plugin-manifests.step.d.ts +7 -1
- package/dist/modules/workspace/startup/steps/plugin-manifests.step.d.ts.map +1 -1
- package/dist/modules/workspace/startup/steps/plugin-manifests.step.js +12 -5
- package/dist/modules/workspace/startup/steps/plugin-manifests.step.js.map +1 -1
- package/dist/modules/workspace/startup/steps/seed-tree.d.ts +4 -1
- package/dist/modules/workspace/startup/steps/seed-tree.d.ts.map +1 -1
- package/dist/modules/workspace/startup/steps/seed-tree.js +14 -11
- package/dist/modules/workspace/startup/steps/seed-tree.js.map +1 -1
- package/dist/modules/workspace/startup/steps/template-files.step.d.ts +17 -3
- package/dist/modules/workspace/startup/steps/template-files.step.d.ts.map +1 -1
- package/dist/modules/workspace/startup/steps/template-files.step.js +36 -30
- package/dist/modules/workspace/startup/steps/template-files.step.js.map +1 -1
- package/dist/modules/workspace/startup/steps/template-source.d.ts +6 -1
- package/dist/modules/workspace/startup/steps/template-source.d.ts.map +1 -1
- package/dist/modules/workspace/startup/steps/template-source.js +10 -6
- package/dist/modules/workspace/startup/steps/template-source.js.map +1 -1
- package/dist/modules/workspace/workspace.routes.d.ts +2 -1
- package/dist/modules/workspace/workspace.routes.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.routes.js +8 -7
- package/dist/modules/workspace/workspace.routes.js.map +1 -1
- package/dist/modules/workspace/workspace.service.d.ts +18 -12
- package/dist/modules/workspace/workspace.service.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.service.js +32 -28
- package/dist/modules/workspace/workspace.service.js.map +1 -1
- package/dist/modules/workspace/workspace.tools.d.ts +2 -1
- package/dist/modules/workspace/workspace.tools.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.tools.js +20 -18
- package/dist/modules/workspace/workspace.tools.js.map +1 -1
- package/dist/modules/workspace/write-denial.d.ts +3 -2
- package/dist/modules/workspace/write-denial.d.ts.map +1 -1
- package/dist/modules/workspace/write-denial.js +6 -5
- package/dist/modules/workspace/write-denial.js.map +1 -1
- package/dist/shared/git.contract.d.ts +52 -7
- package/dist/shared/git.contract.d.ts.map +1 -1
- package/dist/shared/git.contract.js +30 -8
- package/dist/shared/git.contract.js.map +1 -1
- package/dist/shared/kb-context.d.ts +76 -0
- package/dist/shared/kb-context.d.ts.map +1 -0
- package/dist/shared/kb-context.js +108 -0
- package/dist/shared/kb-context.js.map +1 -0
- package/dist/shared/kb-layout.d.ts +3 -2
- package/dist/shared/kb-layout.d.ts.map +1 -1
- package/dist/shared/kb-layout.js +4 -3
- package/dist/shared/kb-layout.js.map +1 -1
- package/dist/shared/kb-layout.test.js +35 -27
- package/dist/shared/kb-layout.test.js.map +1 -1
- package/dist/shared/pending-proposals.d.ts +4 -1
- package/dist/shared/pending-proposals.d.ts.map +1 -1
- package/dist/shared/pending-proposals.js +3 -4
- package/dist/shared/pending-proposals.js.map +1 -1
- package/dist/shared/redact-secret.d.ts +5 -5
- package/dist/shared/redact-secret.js +5 -5
- package/dist/tenancy/index.d.ts +13 -0
- package/dist/tenancy/index.d.ts.map +1 -0
- package/dist/tenancy/index.js +13 -0
- package/dist/tenancy/index.js.map +1 -0
- package/dist/tenancy/static-tenant-source.d.ts +98 -0
- package/dist/tenancy/static-tenant-source.d.ts.map +1 -0
- package/dist/tenancy/static-tenant-source.js +220 -0
- package/dist/tenancy/static-tenant-source.js.map +1 -0
- package/dist/tenancy/tenant-host.d.ts +80 -0
- package/dist/tenancy/tenant-host.d.ts.map +1 -0
- package/dist/tenancy/tenant-host.js +217 -0
- package/dist/tenancy/tenant-host.js.map +1 -0
- package/dist/tenancy/tenant-runtime.d.ts +91 -0
- package/dist/tenancy/tenant-runtime.d.ts.map +1 -0
- package/dist/tenancy/tenant-runtime.js +174 -0
- package/dist/tenancy/tenant-runtime.js.map +1 -0
- package/dist/tenancy/tenant-secrets.d.ts +24 -0
- package/dist/tenancy/tenant-secrets.d.ts.map +1 -0
- package/dist/tenancy/tenant-secrets.js +30 -0
- package/dist/tenancy/tenant-secrets.js.map +1 -0
- package/dist/tenancy/tenant-source.contract.d.ts +45 -0
- package/dist/tenancy/tenant-source.contract.d.ts.map +1 -0
- package/dist/tenancy/tenant-source.contract.js +21 -0
- package/dist/tenancy/tenant-source.contract.js.map +1 -0
- package/migrations/0000_core_init.sql +14 -14
- package/migrations/0003_deployment_settings.sql +1 -1
- package/migrations/0005_github_facade.sql +1 -1
- package/migrations/0012_agent_audit.sql +6 -6
- package/package.json +3 -3
- package/src/__tests__/branch-model.test.ts +7 -6
- package/src/__tests__/kb-context.ts +30 -0
- package/src/__tests__/kb-layout-config.test.ts +35 -30
- package/src/core/__tests__/catalog-cache-invalidation.test.ts +2 -1
- package/src/core/__tests__/lifecycle.test.ts +78 -1
- package/src/core/__tests__/public-config.test.ts +5 -1
- package/src/core/catalog-cache-invalidation.ts +16 -11
- package/src/core/core-ports.ts +19 -0
- package/src/core/create-core-server.ts +27 -106
- package/src/core/create-core-services.ts +180 -95
- package/src/core/lifecycle.ts +214 -29
- package/src/core/public-config.ts +8 -5
- package/src/core-config.ts +107 -8
- package/src/index.ts +25 -2
- package/src/modules/access/__tests__/access-control.admin-root-floor.test.ts +2 -1
- package/src/modules/access/__tests__/access.routes.batch.test.ts +2 -1
- package/src/modules/access/__tests__/access.routes.folder-governs.test.ts +2 -1
- package/src/modules/access/__tests__/access.routes.group-grant.test.ts +2 -1
- package/src/modules/access/__tests__/access.routes.overrides.test.ts +2 -1
- package/src/modules/access/__tests__/access.routes.proposal-branch.test.ts +2 -1
- package/src/modules/access/__tests__/access.routes.prospective.test.ts +2 -1
- package/src/modules/access/__tests__/access.routes.revoke.test.ts +2 -1
- package/src/modules/access/__tests__/access.routes.unknown-email.test.ts +2 -1
- package/src/modules/access/__tests__/change-read-gate.test.ts +13 -11
- package/src/modules/access/__tests__/creator-access.test.ts +3 -2
- package/src/modules/access/__tests__/roles.routes.test.ts +2 -1
- package/src/modules/access/access-control.service.ts +20 -6
- package/src/modules/access/access.routes.ts +10 -13
- package/src/modules/access/change-read-gate.ts +10 -4
- package/src/modules/access/creator-access.ts +7 -2
- package/src/modules/agent-instructions/__tests__/read-preamble.test.ts +13 -12
- package/src/modules/agent-instructions/read-preamble.ts +10 -12
- package/src/modules/auth/__tests__/account.routes.test.ts +15 -0
- package/src/modules/auth/__tests__/auth.service.test.ts +60 -0
- package/src/modules/auth/account-admission.ts +44 -0
- package/src/modules/auth/account.routes.ts +4 -1
- package/src/modules/auth/auth.service.ts +33 -1
- package/src/modules/auth/oidc-auth-provider.ts +9 -0
- package/src/modules/connection-probe/connection-probe.service.ts +7 -1
- package/src/modules/database/__tests__/advisory-lock.test.ts +23 -1
- package/src/modules/database/__tests__/connection.test.ts +98 -0
- package/src/modules/database/__tests__/migrations-unqualified.test.ts +32 -0
- package/src/modules/database/advisory-lock.ts +28 -4
- package/src/modules/database/connection.ts +143 -13
- package/src/modules/database/migrate.ts +48 -14
- package/src/modules/diff/__tests__/diff.service.seed-atomicity.test.ts +2 -1
- package/src/modules/diff/__tests__/diff.service.test.ts +2 -1
- package/src/modules/kb-fs/__tests__/branch-name.test.ts +6 -6
- package/src/modules/kb-fs/__tests__/clone-config.test.ts +24 -20
- package/src/modules/kb-fs/branch-name.ts +3 -3
- package/src/modules/kb-fs/clone-config.ts +15 -12
- package/src/modules/marketplace/__tests__/marketplace-repo.head.test.ts +2 -1
- package/src/modules/mcp/mcp.service.ts +11 -4
- package/src/modules/plugins/__tests__/bundle-dialect.e2e.test.ts +12 -11
- package/src/modules/plugins/__tests__/bundle-dialect.test.ts +2 -1
- package/src/modules/plugins/__tests__/compile-marketplace.test.ts +6 -4
- package/src/modules/plugins/__tests__/join-request-jobs.service.test.ts +2 -1
- package/src/modules/plugins/__tests__/join-requests.service.test.ts +2 -1
- package/src/modules/plugins/__tests__/plugin-creation-display-name.test.ts +4 -3
- package/src/modules/plugins/__tests__/plugin-index.service.test.ts +6 -4
- package/src/modules/plugins/__tests__/plugin-links.service.test.ts +220 -5
- package/src/modules/plugins/__tests__/plugin-provision.service.test.ts +3 -1
- package/src/modules/plugins/__tests__/plugin-rename.service.test.ts +7 -6
- package/src/modules/plugins/__tests__/plugins.routes.test.ts +11 -2
- package/src/modules/plugins/__tests__/teams.routes.test.ts +2 -1
- package/src/modules/plugins/compile/marketplace-compiler.service.ts +7 -9
- package/src/modules/plugins/discovery/__tests__/kb-plugin-source.test.ts +20 -16
- package/src/modules/plugins/discovery/bundle-dialect/bundle.source.ts +9 -2
- package/src/modules/plugins/discovery/kb-plugin-source.ts +15 -8
- package/src/modules/plugins/discovery/native.source.ts +4 -1
- package/src/modules/plugins/index.ts +1 -1
- package/src/modules/plugins/join-request-jobs.service.ts +8 -7
- package/src/modules/plugins/join-requests.service.ts +7 -7
- package/src/modules/plugins/plugin-links.service.ts +192 -19
- package/src/modules/plugins/plugin-links.ts +147 -27
- package/src/modules/plugins/plugin-provision.service.ts +54 -27
- package/src/modules/plugins/plugin-rename.service.ts +10 -10
- package/src/modules/plugins/plugins.routes.ts +45 -15
- package/src/modules/plugins/plugins.service.ts +7 -11
- package/src/modules/plugins/teams.routes.ts +16 -8
- package/src/modules/secrets-vault/__tests__/connect-pending.route.test.ts +7 -0
- package/src/modules/secrets-vault/__tests__/secrets-variable-loader.test.ts +40 -0
- package/src/modules/secrets-vault/__tests__/tool-owner-gate.route.test.ts +2 -0
- package/src/modules/secrets-vault/index.ts +2 -0
- package/src/modules/secrets-vault/secrets-variable-loader.ts +51 -21
- package/src/modules/secrets-vault/secrets-vault.routes.ts +7 -6
- package/src/modules/settings/__tests__/deployment-settings.service.test.ts +24 -11
- package/src/modules/settings/__tests__/git-root-folders.test.ts +2 -1
- package/src/modules/settings/__tests__/setup.routes.boot-failure.test.ts +2 -1
- package/src/modules/settings/__tests__/setup.routes.layout-phase.test.ts +7 -4
- package/src/modules/settings/__tests__/setup.routes.oidc.test.ts +2 -0
- package/src/modules/settings/__tests__/setup.routes.sync-status.test.ts +2 -0
- package/src/modules/settings/__tests__/setup.routes.test.ts +33 -52
- package/src/modules/settings/deployment-settings.service.ts +21 -20
- package/src/modules/settings/setup.routes.ts +26 -16
- package/src/modules/skills/__tests__/allowed-tools-check.test.ts +11 -10
- package/src/modules/skills/__tests__/allowed-tools-warn.tools.test.ts +4 -3
- package/src/modules/skills/__tests__/pending-skills.service.test.ts +3 -1
- package/src/modules/skills/__tests__/skill-access-requests.routes.test.ts +2 -1
- package/src/modules/skills/__tests__/skills.routes.warnings.test.ts +2 -1
- package/src/modules/skills/__tests__/skills.service.test.ts +3 -2
- package/src/modules/skills/allowed-tools-check.ts +7 -6
- package/src/modules/skills/pending-skills.service.ts +9 -8
- package/src/modules/skills/skill-access-requests.routes.ts +7 -7
- package/src/modules/skills/skills.routes.ts +4 -3
- package/src/modules/skills/skills.service.ts +13 -9
- package/src/modules/tool-helpers/__tests__/agent-roles-write.test.ts +3 -2
- package/src/modules/tool-helpers/__tests__/phase4-tools.test.ts +3 -2
- package/src/modules/tool-manuals/__tests__/mcp-json-discovery.test.ts +17 -12
- package/src/modules/tool-manuals/__tests__/mcp-server-edit.service.test.ts +2 -1
- package/src/modules/tool-manuals/__tests__/pending-tools.service.test.ts +4 -1
- package/src/modules/tool-manuals/__tests__/tool-delete.service.test.ts +2 -1
- package/src/modules/tool-manuals/__tests__/tool-manuals.archive.route.test.ts +2 -1
- package/src/modules/tool-manuals/__tests__/tool-manuals.cli.test.ts +5 -4
- package/src/modules/tool-manuals/__tests__/tool-manuals.detail.route.test.ts +2 -1
- package/src/modules/tool-manuals/__tests__/tool-manuals.invalid.routes.test.ts +4 -2
- package/src/modules/tool-manuals/__tests__/tool-manuals.invalid.test.ts +13 -5
- package/src/modules/tool-manuals/__tests__/tool-manuals.mcp-oauth.test.ts +2 -1
- package/src/modules/tool-manuals/__tests__/tool-manuals.restart.test.ts +9 -1
- package/src/modules/tool-manuals/__tests__/tool-manuals.service.test.ts +3 -2
- package/src/modules/tool-manuals/__tests__/tool-manuals.tools.test.ts +2 -0
- package/src/modules/tool-manuals/mcp-json-discovery.ts +6 -4
- package/src/modules/tool-manuals/mcp-server-edit.service.ts +13 -11
- package/src/modules/tool-manuals/pending-tools.service.ts +19 -16
- package/src/modules/tool-manuals/tool-delete.service.ts +13 -10
- package/src/modules/tool-manuals/tool-manuals.routes.ts +10 -8
- package/src/modules/tool-manuals/tool-manuals.service.ts +15 -13
- package/src/modules/tool-manuals/tool-manuals.tools.ts +7 -6
- package/src/modules/workflow/__tests__/apply-failure.test.ts +2 -1
- package/src/modules/workflow/__tests__/merge-announces-tree.test.ts +14 -26
- package/src/modules/workflow/__tests__/preserve-roles-yaml.test.ts +2 -1
- package/src/modules/workflow/__tests__/session-ontology.service.test.ts +3 -2
- package/src/modules/workflow/__tests__/workflow.routes.lock-path.test.ts +2 -1
- package/src/modules/workflow/__tests__/workflow.service.branch-in-use.test.ts +3 -10
- package/src/modules/workflow/__tests__/workflow.service.commitFileWhileLocked.test.ts +2 -1
- package/src/modules/workflow/__tests__/workflow.service.deleted-branch-sweep.test.ts +3 -10
- package/src/modules/workflow/__tests__/workflow.service.facade.test.ts +28 -27
- package/src/modules/workflow/__tests__/workflow.service.folder-proposals.test.ts +2 -1
- package/src/modules/workflow/__tests__/workflow.service.platform-restore.test.ts +2 -1
- package/src/modules/workflow/__tests__/workflow.service.read-gate.test.ts +3 -2
- package/src/modules/workflow/__tests__/workflow.service.releaseLock.test.ts +2 -1
- package/src/modules/workflow/__tests__/workflow.service.sync.test.ts +5 -4
- package/src/modules/workflow/__tests__/workflow.service.update-from-target.test.ts +2 -1
- package/src/modules/workflow/agent-tools/__tests__/workflow.tools.test.ts +2 -1
- package/src/modules/workflow/agent-tools/workflow.tools.ts +11 -9
- package/src/modules/workflow/git/__tests__/git.service.accessGating.test.ts +5 -4
- package/src/modules/workflow/git/__tests__/git.service.changedFilesForPr.test.ts +12 -11
- package/src/modules/workflow/git/__tests__/git.service.commitChanges.test.ts +9 -8
- package/src/modules/workflow/git/__tests__/git.service.commitFile.strayPath.test.ts +8 -7
- package/src/modules/workflow/git/__tests__/git.service.commitFile.test.ts +6 -5
- package/src/modules/workflow/git/__tests__/git.service.createBranch.test.ts +3 -2
- package/src/modules/workflow/git/__tests__/git.service.deleteBranch.test.ts +3 -2
- package/src/modules/workflow/git/__tests__/git.service.diffFileAtCommit.test.ts +7 -6
- package/src/modules/workflow/git/__tests__/git.service.diffFileBetweenBranches.test.ts +16 -15
- package/src/modules/workflow/git/__tests__/git.service.fileContentsAtCommit.test.ts +3 -2
- package/src/modules/workflow/git/__tests__/git.service.forkPoint.test.ts +2 -1
- package/src/modules/workflow/git/__tests__/git.service.history-guards.test.ts +2 -1
- package/src/modules/workflow/git/__tests__/git.service.list-branches.test.ts +10 -9
- package/src/modules/workflow/git/__tests__/git.service.listTrackedFiles.test.ts +2 -1
- package/src/modules/workflow/git/__tests__/git.service.logForFile.test.ts +6 -5
- package/src/modules/workflow/git/__tests__/git.service.mergeChangeRequest.test.ts +9 -8
- package/src/modules/workflow/git/__tests__/git.service.pendingChanges.test.ts +2 -1
- package/src/modules/workflow/git/__tests__/git.service.postMergePull.test.ts +4 -3
- package/src/modules/workflow/git/__tests__/git.service.pull.test.ts +9 -8
- package/src/modules/workflow/git/__tests__/git.service.readFileAtRef.test.ts +2 -1
- package/src/modules/workflow/git/__tests__/git.service.revertPathsAndPush.test.ts +2 -1
- package/src/modules/workflow/git/__tests__/git.service.status.test.ts +4 -3
- package/src/modules/workflow/git/__tests__/git.service.syncFromRemote.test.ts +8 -7
- package/src/modules/workflow/git/__tests__/node-git-runner.test.ts +41 -3
- package/src/modules/workflow/git/git.service.ts +24 -13
- package/src/modules/workflow/git/node-git-runner.ts +37 -4
- package/src/modules/workflow/review-workflow/review-workflow.service.ts +9 -6
- package/src/modules/workflow/session-ontology.service.ts +7 -2
- package/src/modules/workflow/workflow.service.ts +31 -24
- package/src/modules/workspace/__tests__/file-stat-access.test.ts +3 -2
- package/src/modules/workspace/__tests__/git-internals.security.test.ts +10 -9
- package/src/modules/workspace/__tests__/session-ontology.gate.test.ts +4 -2
- package/src/modules/workspace/__tests__/workspace-paths-inside-the-repo.test.ts +3 -2
- package/src/modules/workspace/__tests__/workspace.routes.branch-errors.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.routes.create-grant.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.routes.delete.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.routes.download-implies-read.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.routes.download.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.routes.file-writes.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.routes.folders.test.ts +5 -4
- package/src/modules/workspace/__tests__/workspace.routes.move-platform-files.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.routes.read-gate.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.service.ensure-remotes-fetched.test.ts +2 -2
- package/src/modules/workspace/__tests__/workspace.service.list-cloned.test.ts +6 -5
- package/src/modules/workspace/__tests__/workspace.service.move-never-overwrites.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.service.read-filter.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.service.test.ts +84 -50
- package/src/modules/workspace/__tests__/workspace.service.unknown-branch.test.ts +2 -1
- package/src/modules/workspace/__tests__/workspace.tools.agents-file.test.ts +10 -7
- package/src/modules/workspace/__tests__/workspace.tools.branch-errors.test.ts +4 -3
- package/src/modules/workspace/__tests__/workspace.tools.test.ts +9 -8
- package/src/modules/workspace/__tests__/write-denial.test.ts +5 -4
- package/src/modules/workspace/session-ontology.gate.ts +6 -4
- package/src/modules/workspace/startup/__tests__/kb-startup-runner.degraded.test.ts +6 -2
- package/src/modules/workspace/startup/__tests__/kb-startup-runner.test.ts +29 -21
- package/src/modules/workspace/startup/kb-git.ts +15 -22
- package/src/modules/workspace/startup/kb-startup-runner.ts +40 -46
- package/src/modules/workspace/startup/steps/__tests__/steps.test.ts +104 -98
- package/src/modules/workspace/startup/steps/groups-to-plugins.step.ts +24 -16
- package/src/modules/workspace/startup/steps/personal-spaces.step.ts +14 -5
- package/src/modules/workspace/startup/steps/plugin-display-names.step.ts +13 -5
- package/src/modules/workspace/startup/steps/plugin-manifests.step.ts +14 -5
- package/src/modules/workspace/startup/steps/seed-tree.ts +11 -9
- package/src/modules/workspace/startup/steps/template-files.step.ts +43 -34
- package/src/modules/workspace/startup/steps/template-source.ts +8 -5
- package/src/modules/workspace/workspace.routes.ts +8 -7
- package/src/modules/workspace/workspace.service.ts +30 -27
- package/src/modules/workspace/workspace.tools.ts +21 -20
- package/src/modules/workspace/write-denial.ts +7 -5
- package/src/shared/__tests__/kb-layout.plugin.test.ts +19 -16
- package/src/shared/git.contract.ts +70 -8
- package/src/shared/kb-context.ts +130 -0
- package/src/shared/kb-layout.test.ts +37 -27
- package/src/shared/kb-layout.ts +4 -3
- package/src/shared/pending-proposals.ts +7 -4
- package/src/shared/redact-secret.ts +5 -5
- package/src/tenancy/__tests__/static-tenant-source.test.ts +177 -0
- package/src/tenancy/__tests__/tenant-host.test.ts +372 -0
- package/src/tenancy/__tests__/tenant-runtime.test.ts +221 -0
- package/src/tenancy/__tests__/tenant-secrets.test.ts +35 -0
- package/src/tenancy/index.ts +35 -0
- package/src/tenancy/static-tenant-source.ts +296 -0
- package/src/tenancy/tenant-host.ts +261 -0
- package/src/tenancy/tenant-runtime.ts +208 -0
- package/src/tenancy/tenant-secrets.ts +41 -0
- package/src/tenancy/tenant-source.contract.ts +59 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant-runtime.d.ts","sourceRoot":"","sources":["../../src/tenancy/tenant-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAIxF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAIpE,mFAAmF;AACnF,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,YAAY,CAAC;IACnB,GAAG,EAAE,OAAO,CAAC;CACd;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,YAAY,GAAG,QAAQ,GAAG,UAAU,CAAC;AAExE,8EAA8E;AAC9E,MAAM,WAAW,iBAAiB;IAChC,qFAAqF;IACrF,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,gBAAgB,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IAClE,yCAAyC;IACzC,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,mGAAmG;IACnG,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAChD,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB;;;;OAIG;IACH,KAAK,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAChD;AA4BD;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,aAAa;IAetB,QAAQ,CAAC,UAAU,EAAE,gBAAgB;IAdvC,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,UAAU,CAAqC;IACvD,OAAO,CAAC,QAAQ,CAA8B;IAC9C,OAAO,CAAC,OAAO,CAAqE;IACpF,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyD;IAClF,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAwC;IAClE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2C;IAClE,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;IACnC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAGzB,UAAU,EAAE,gBAAgB,EACrC,IAAI,GAAE,iBAAsB;IAW9B,+FAA+F;IAC/F,KAAK,IAAI,IAAI;IAKb,0DAA0D;IAC1D,KAAK,IAAI,IAAI;IAKb,gDAAgD;IAChD,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,KAAK,IAAI,WAAW,CAKvB;IAED,6DAA6D;IAC7D,OAAO,IAAI,MAAM;IAIjB;;;;OAIG;IACG,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC;IAwBpC;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAK9B;;;;OAIG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAyBvB"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { createCoreServices } from '../core/create-core-services.js';
|
|
2
|
+
import { createCoreServer } from '../core/create-core-server.js';
|
|
3
|
+
import { stopCore } from '../core/lifecycle.js';
|
|
4
|
+
import { logger } from '../shared/logging.js';
|
|
5
|
+
const log = logger('tenancy');
|
|
6
|
+
const DEFAULT_RETRY_INITIAL_MS = 5_000;
|
|
7
|
+
const DEFAULT_RETRY_MAX_MS = 60_000;
|
|
8
|
+
/**
|
|
9
|
+
* How a tenant's graph is built with the composition root as a distribution
|
|
10
|
+
* calls it, plus the one thing a host must say: no mirroring onto the shared
|
|
11
|
+
* package's process-wide bindings, since this process has several graphs and
|
|
12
|
+
* no single value to put there.
|
|
13
|
+
*/
|
|
14
|
+
async function activateWithCore(descriptor) {
|
|
15
|
+
const core = await createCoreServices(descriptor.config, { ...descriptor.ports, mirrorSharedBindings: false });
|
|
16
|
+
try {
|
|
17
|
+
// No static dir: the host serves the SPA once, for every tenant.
|
|
18
|
+
const app = await createCoreServer(core, descriptor.extensions ?? {}, {});
|
|
19
|
+
return { core, app };
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
// A graph whose boot failed still holds a pool and a lease.
|
|
23
|
+
await stopCore(core).catch(() => undefined);
|
|
24
|
+
throw err;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async function queuedCommits(graph) {
|
|
28
|
+
return (await graph.core.pendingCommitsService.oldestQueuedAt()) !== null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* One tenant's graph, brought up on first use and stopped when the host
|
|
32
|
+
* says so: `idle → activating → active → evicting → idle`.
|
|
33
|
+
*
|
|
34
|
+
* ACTIVATE ONCE. Requests arriving while the graph is being built all await
|
|
35
|
+
* the one activation in flight. A failed activation is remembered for a
|
|
36
|
+
* short, growing window and answered from memory inside it, so a tenant
|
|
37
|
+
* whose remote is down or whose token is wrong costs one clone attempt per
|
|
38
|
+
* window rather than one per request; past the window the next request
|
|
39
|
+
* tries again, since the remote may be back or the token fixed. An eviction
|
|
40
|
+
* that lands mid-activation waits for the activation and then stops what it
|
|
41
|
+
* produced, so a graph is never left running behind an evicted runtime.
|
|
42
|
+
*
|
|
43
|
+
* IN USE MEANS A RESPONSE IS OPEN. The host tells the runtime when it hands
|
|
44
|
+
* a request over and when that response closes, so idleness counts from the
|
|
45
|
+
* last response that ENDED, and a tenant with any response still open — an
|
|
46
|
+
* event stream a browser holds, a clone in flight — is busy and never
|
|
47
|
+
* evicted from under it.
|
|
48
|
+
*/
|
|
49
|
+
export class TenantRuntime {
|
|
50
|
+
descriptor;
|
|
51
|
+
graph = null;
|
|
52
|
+
activation = null;
|
|
53
|
+
eviction = null;
|
|
54
|
+
failure = null;
|
|
55
|
+
openResponses = 0;
|
|
56
|
+
lastUsedAt;
|
|
57
|
+
activate;
|
|
58
|
+
stopGraph;
|
|
59
|
+
isBusy;
|
|
60
|
+
now;
|
|
61
|
+
retryInitialMs;
|
|
62
|
+
retryMaxMs;
|
|
63
|
+
constructor(descriptor, deps = {}) {
|
|
64
|
+
this.descriptor = descriptor;
|
|
65
|
+
this.activate = deps.activate ?? activateWithCore;
|
|
66
|
+
this.stopGraph = deps.stop ?? ((graph) => stopCore(graph.core));
|
|
67
|
+
this.isBusy = deps.busy ?? queuedCommits;
|
|
68
|
+
this.now = deps.now ?? Date.now;
|
|
69
|
+
this.retryInitialMs = deps.retry?.initialMs ?? DEFAULT_RETRY_INITIAL_MS;
|
|
70
|
+
this.retryMaxMs = deps.retry?.maxMs ?? DEFAULT_RETRY_MAX_MS;
|
|
71
|
+
this.lastUsedAt = this.now();
|
|
72
|
+
}
|
|
73
|
+
/** A request was handed to this tenant; paired with {@link leave} when its response closes. */
|
|
74
|
+
enter() {
|
|
75
|
+
this.openResponses += 1;
|
|
76
|
+
this.lastUsedAt = this.now();
|
|
77
|
+
}
|
|
78
|
+
/** A response to this tenant closed, however it ended. */
|
|
79
|
+
leave() {
|
|
80
|
+
if (this.openResponses > 0)
|
|
81
|
+
this.openResponses -= 1;
|
|
82
|
+
this.lastUsedAt = this.now();
|
|
83
|
+
}
|
|
84
|
+
/** Responses handed over and not yet closed. */
|
|
85
|
+
get open() {
|
|
86
|
+
return this.openResponses;
|
|
87
|
+
}
|
|
88
|
+
get slug() {
|
|
89
|
+
return this.descriptor.slug;
|
|
90
|
+
}
|
|
91
|
+
get state() {
|
|
92
|
+
if (this.eviction)
|
|
93
|
+
return 'evicting';
|
|
94
|
+
if (this.graph)
|
|
95
|
+
return 'active';
|
|
96
|
+
if (this.activation)
|
|
97
|
+
return 'activating';
|
|
98
|
+
return 'idle';
|
|
99
|
+
}
|
|
100
|
+
/** Milliseconds since a request last touched this tenant. */
|
|
101
|
+
idleFor() {
|
|
102
|
+
return this.now() - this.lastUsedAt;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The graph, built if it is not running. Every caller of a concurrent
|
|
106
|
+
* first burst gets the same promise; a caller that arrives during an
|
|
107
|
+
* eviction waits for it, then starts the graph afresh.
|
|
108
|
+
*/
|
|
109
|
+
async handle() {
|
|
110
|
+
this.lastUsedAt = this.now();
|
|
111
|
+
if (this.eviction)
|
|
112
|
+
await this.eviction;
|
|
113
|
+
if (this.graph)
|
|
114
|
+
return this.graph;
|
|
115
|
+
if (this.failure && this.now() < this.failure.until)
|
|
116
|
+
throw this.failure.error;
|
|
117
|
+
this.activation ??= this.activate(this.descriptor).then((graph) => {
|
|
118
|
+
this.graph = graph;
|
|
119
|
+
this.activation = null;
|
|
120
|
+
this.failure = null;
|
|
121
|
+
log.info(`tenant "${this.slug}" activated`);
|
|
122
|
+
return graph;
|
|
123
|
+
}, (err) => {
|
|
124
|
+
this.activation = null;
|
|
125
|
+
const backoffMs = Math.min(this.failure ? this.failure.backoffMs * 2 : this.retryInitialMs, this.retryMaxMs);
|
|
126
|
+
this.failure = { error: err, until: this.now() + backoffMs, backoffMs };
|
|
127
|
+
log.error(`tenant "${this.slug}" failed to activate; not asked again for ${backoffMs}ms:`, { err });
|
|
128
|
+
throw err;
|
|
129
|
+
});
|
|
130
|
+
return this.activation;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Whether an eviction would strand something: a response still open, or
|
|
134
|
+
* work the graph reports (queued commits). False when nothing runs.
|
|
135
|
+
*/
|
|
136
|
+
async busy() {
|
|
137
|
+
if (this.openResponses > 0)
|
|
138
|
+
return true;
|
|
139
|
+
return this.graph ? this.isBusy(this.graph) : false;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Stop the graph, if one runs or is being built. Idempotent: a second call
|
|
143
|
+
* joins the eviction under way. Afterwards the runtime is idle and the
|
|
144
|
+
* next {@link handle} builds a fresh graph.
|
|
145
|
+
*/
|
|
146
|
+
evict() {
|
|
147
|
+
if (this.eviction)
|
|
148
|
+
return this.eviction;
|
|
149
|
+
const eviction = (async () => {
|
|
150
|
+
if (this.activation) {
|
|
151
|
+
// Whatever the build produces is stopped; a build that fails has
|
|
152
|
+
// stopped its own graph already.
|
|
153
|
+
await this.activation.catch(() => undefined);
|
|
154
|
+
}
|
|
155
|
+
const graph = this.graph;
|
|
156
|
+
this.graph = null;
|
|
157
|
+
if (graph) {
|
|
158
|
+
await this.stopGraph(graph);
|
|
159
|
+
log.info(`tenant "${this.slug}" evicted`);
|
|
160
|
+
}
|
|
161
|
+
})();
|
|
162
|
+
// Assigned, then cleared by identity: an eviction with nothing to stop
|
|
163
|
+
// settles before this line runs, and a `finally` inside it would have
|
|
164
|
+
// cleared a field that was not yet set — leaving the settled promise
|
|
165
|
+
// in place as an eviction forever under way.
|
|
166
|
+
this.eviction = eviction;
|
|
167
|
+
void eviction.finally(() => {
|
|
168
|
+
if (this.eviction === eviction)
|
|
169
|
+
this.eviction = null;
|
|
170
|
+
});
|
|
171
|
+
return eviction;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=tenant-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant-runtime.js","sourceRoot":"","sources":["../../src/tenancy/tenant-runtime.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** The three secrets every graph needs, derived rather than stored. */
|
|
2
|
+
export interface TenantSecrets {
|
|
3
|
+
/** Signs the tenant's login sessions and OAuth state. */
|
|
4
|
+
jwtSecret: string;
|
|
5
|
+
/** 32 bytes, base64: encrypts the tenant's vault values, MCP OAuth tokens and stored git credential. */
|
|
6
|
+
secretsEncKey: string;
|
|
7
|
+
/** HMAC key for the tenant's internal (loopback) tool tokens. */
|
|
8
|
+
internalTokenSecret: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A tenant's secrets from ONE master key and its slug, with HKDF-SHA256:
|
|
12
|
+
* the slug is the salt and each secret's name the info, so the three are
|
|
13
|
+
* independent of each other and of every other tenant's.
|
|
14
|
+
*
|
|
15
|
+
* Derived, not generated and stored, for the hand-over: a tenant that leaves
|
|
16
|
+
* for a dedicated deployment takes a `pg_dump` whose vault rows and stored
|
|
17
|
+
* git token are encrypted under its `secretsEncKey`. With derivation the key
|
|
18
|
+
* is reproducible from the master key and the slug on the day of the
|
|
19
|
+
* export, and nothing per tenant has to be kept safe in the meantime. The
|
|
20
|
+
* cloud app's registry calls this with the same inputs and gets the same
|
|
21
|
+
* answer.
|
|
22
|
+
*/
|
|
23
|
+
export declare function deriveTenantSecrets(masterKey: string, slug: string): TenantSecrets;
|
|
24
|
+
//# sourceMappingURL=tenant-secrets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant-secrets.d.ts","sourceRoot":"","sources":["../../src/tenancy/tenant-secrets.ts"],"names":[],"mappings":"AAEA,uEAAuE;AACvE,MAAM,WAAW,aAAa;IAC5B,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,wGAAwG;IACxG,aAAa,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAKD;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,aAAa,CAYlF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { hkdfSync } from 'node:crypto';
|
|
2
|
+
/** The least a master key may hold: 32 characters is 256 bits of a random string. */
|
|
3
|
+
const MIN_MASTER_KEY_LENGTH = 32;
|
|
4
|
+
/**
|
|
5
|
+
* A tenant's secrets from ONE master key and its slug, with HKDF-SHA256:
|
|
6
|
+
* the slug is the salt and each secret's name the info, so the three are
|
|
7
|
+
* independent of each other and of every other tenant's.
|
|
8
|
+
*
|
|
9
|
+
* Derived, not generated and stored, for the hand-over: a tenant that leaves
|
|
10
|
+
* for a dedicated deployment takes a `pg_dump` whose vault rows and stored
|
|
11
|
+
* git token are encrypted under its `secretsEncKey`. With derivation the key
|
|
12
|
+
* is reproducible from the master key and the slug on the day of the
|
|
13
|
+
* export, and nothing per tenant has to be kept safe in the meantime. The
|
|
14
|
+
* cloud app's registry calls this with the same inputs and gets the same
|
|
15
|
+
* answer.
|
|
16
|
+
*/
|
|
17
|
+
export function deriveTenantSecrets(masterKey, slug) {
|
|
18
|
+
if (masterKey.length < MIN_MASTER_KEY_LENGTH) {
|
|
19
|
+
throw new Error(`TENANT_MASTER_KEY must be at least ${MIN_MASTER_KEY_LENGTH} characters of random text`);
|
|
20
|
+
}
|
|
21
|
+
if (!slug)
|
|
22
|
+
throw new Error('A tenant slug is required to derive its secrets');
|
|
23
|
+
const derive = (info) => Buffer.from(hkdfSync('sha256', masterKey, `hexis-tenant:${slug}`, info, 32)).toString('base64');
|
|
24
|
+
return {
|
|
25
|
+
jwtSecret: derive('jwt-secret'),
|
|
26
|
+
secretsEncKey: derive('secrets-enc-key'),
|
|
27
|
+
internalTokenSecret: derive('internal-token-secret'),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=tenant-secrets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant-secrets.js","sourceRoot":"","sources":["../../src/tenancy/tenant-secrets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAYvC,qFAAqF;AACrF,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAEjC;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAiB,EAAE,IAAY;IACjE,IAAI,SAAS,CAAC,MAAM,GAAG,qBAAqB,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,sCAAsC,qBAAqB,4BAA4B,CAAC,CAAC;IAC3G,CAAC;IACD,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IAC9E,MAAM,MAAM,GAAG,CAAC,IAAY,EAAU,EAAE,CACtC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,EAAE,gBAAgB,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAClG,OAAO;QACL,SAAS,EAAE,MAAM,CAAC,YAAY,CAAC;QAC/B,aAAa,EAAE,MAAM,CAAC,iBAAiB,CAAC;QACxC,mBAAmB,EAAE,MAAM,CAAC,uBAAuB,CAAC;KACrD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { TenantConfig } from '../core-config.js';
|
|
2
|
+
import type { CorePorts } from '../core/core-ports.js';
|
|
3
|
+
import type { ServerExtensions } from '../core/create-core-server.js';
|
|
4
|
+
/**
|
|
5
|
+
* A tenant, as the host needs to know it: which host names reach it, what
|
|
6
|
+
* its service graph is built from, and what a distribution adds to that
|
|
7
|
+
* graph. One of these is one `createCoreServices` + `createCoreServer`, run
|
|
8
|
+
* on demand and stopped again when idle — see `tenant-runtime.ts`.
|
|
9
|
+
*
|
|
10
|
+
* `ports` and `extensions` are per tenant on purpose: everything the
|
|
11
|
+
* enterprise overlay does per deployment (its SSO plugin, session sink,
|
|
12
|
+
* erasure participants, extra startup steps) it does per tenant here, through
|
|
13
|
+
* the same two seams, with nothing below the front door knowing the
|
|
14
|
+
* difference.
|
|
15
|
+
*/
|
|
16
|
+
export interface TenantDescriptor {
|
|
17
|
+
/** The tenant's stable name: lowercase, `[a-z][a-z0-9-]*`, at most 40 characters. */
|
|
18
|
+
readonly slug: string;
|
|
19
|
+
/** Host names (no port) whose requests belong to this tenant, lowercase. */
|
|
20
|
+
readonly hosts: readonly string[];
|
|
21
|
+
readonly config: TenantConfig;
|
|
22
|
+
readonly ports?: CorePorts;
|
|
23
|
+
readonly extensions?: ServerExtensions;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Where tenants come from. Core ships {@link StaticTenantSource}, which
|
|
27
|
+
* reads a file, for development and tests; the cloud app implements this
|
|
28
|
+
* over its own registry, where subdomains are provisioned and plans live.
|
|
29
|
+
* A source answers `null` for a host or slug it does not know, and the host
|
|
30
|
+
* turns that into a 404 without building anything.
|
|
31
|
+
*/
|
|
32
|
+
export interface TenantSource {
|
|
33
|
+
resolveByHost(host: string): Promise<TenantDescriptor | null>;
|
|
34
|
+
describe(slug: string): Promise<TenantDescriptor | null>;
|
|
35
|
+
}
|
|
36
|
+
/** What a slug may look like: it names a schema, a folder and a loopback path. */
|
|
37
|
+
export declare const TENANT_SLUG_PATTERN: RegExp;
|
|
38
|
+
export declare function assertTenantSlug(slug: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* A host name the way the host compares it: lowercase, without a port or a
|
|
41
|
+
* trailing dot. `Host` headers and `X-Forwarded-Host` values arrive in every
|
|
42
|
+
* spelling a client or proxy chooses.
|
|
43
|
+
*/
|
|
44
|
+
export declare function normalizeHost(host: string): string;
|
|
45
|
+
//# sourceMappingURL=tenant-source.contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant-source.contract.d.ts","sourceRoot":"","sources":["../../src/tenancy/tenant-source.contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEtE;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,gBAAgB;IAC/B,qFAAqF;IACrF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4EAA4E;IAC5E,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,UAAU,CAAC,EAAE,gBAAgB,CAAC;CACxC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IAC9D,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;CAC1D;AAED,kFAAkF;AAClF,eAAO,MAAM,mBAAmB,QAA2B,CAAC;AAE5D,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKrD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKlD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** What a slug may look like: it names a schema, a folder and a loopback path. */
|
|
2
|
+
export const TENANT_SLUG_PATTERN = /^[a-z][a-z0-9-]{0,39}$/;
|
|
3
|
+
export function assertTenantSlug(slug) {
|
|
4
|
+
if (!TENANT_SLUG_PATTERN.test(slug)) {
|
|
5
|
+
throw new Error(`Tenant slug must match ${TENANT_SLUG_PATTERN} (lowercase, digits, hyphens); got "${slug}"`);
|
|
6
|
+
}
|
|
7
|
+
return slug;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A host name the way the host compares it: lowercase, without a port or a
|
|
11
|
+
* trailing dot. `Host` headers and `X-Forwarded-Host` values arrive in every
|
|
12
|
+
* spelling a client or proxy chooses.
|
|
13
|
+
*/
|
|
14
|
+
export function normalizeHost(host) {
|
|
15
|
+
const trimmed = host.trim().toLowerCase().replace(/\.$/, '');
|
|
16
|
+
// `[::1]:3001` keeps its brackets; `example.test:3001` loses its port.
|
|
17
|
+
if (trimmed.startsWith('['))
|
|
18
|
+
return trimmed.replace(/\]:\d+$/, ']');
|
|
19
|
+
return trimmed.replace(/:\d+$/, '');
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=tenant-source.contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant-source.contract.js","sourceRoot":"","sources":["../../src/tenancy/tenant-source.contract.ts"],"names":[],"mappings":"AAsCA,kFAAkF;AAClF,MAAM,CAAC,MAAM,mBAAmB,GAAG,wBAAwB,CAAC;AAE5D,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,0BAA0B,mBAAmB,uCAAuC,IAAI,GAAG,CAAC,CAAC;IAC/G,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC7D,uEAAuE;IACvE,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IACpE,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -173,51 +173,51 @@ CREATE TABLE IF NOT EXISTS "users" (
|
|
|
173
173
|
--> statement-breakpoint
|
|
174
174
|
DO $$ BEGIN
|
|
175
175
|
IF NOT EXISTS (
|
|
176
|
-
SELECT 1 FROM pg_constraint WHERE conname = 'api_tokens_user_id_users_id_fk' AND conrelid = '
|
|
176
|
+
SELECT 1 FROM pg_constraint WHERE conname = 'api_tokens_user_id_users_id_fk' AND conrelid = to_regclass('api_tokens')
|
|
177
177
|
) THEN
|
|
178
|
-
ALTER TABLE "api_tokens" ADD CONSTRAINT "api_tokens_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "
|
|
178
|
+
ALTER TABLE "api_tokens" ADD CONSTRAINT "api_tokens_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE no action ON UPDATE no action;
|
|
179
179
|
END IF;
|
|
180
180
|
END $$;--> statement-breakpoint
|
|
181
181
|
DO $$ BEGIN
|
|
182
182
|
IF NOT EXISTS (
|
|
183
|
-
SELECT 1 FROM pg_constraint WHERE conname = 'file_locks_holder_user_id_users_id_fk' AND conrelid = '
|
|
183
|
+
SELECT 1 FROM pg_constraint WHERE conname = 'file_locks_holder_user_id_users_id_fk' AND conrelid = to_regclass('file_locks')
|
|
184
184
|
) THEN
|
|
185
|
-
ALTER TABLE "file_locks" ADD CONSTRAINT "file_locks_holder_user_id_users_id_fk" FOREIGN KEY ("holder_user_id") REFERENCES "
|
|
185
|
+
ALTER TABLE "file_locks" ADD CONSTRAINT "file_locks_holder_user_id_users_id_fk" FOREIGN KEY ("holder_user_id") REFERENCES "users"("id") ON DELETE no action ON UPDATE no action;
|
|
186
186
|
END IF;
|
|
187
187
|
END $$;--> statement-breakpoint
|
|
188
188
|
DO $$ BEGIN
|
|
189
189
|
IF NOT EXISTS (
|
|
190
|
-
SELECT 1 FROM pg_constraint WHERE conname = 'oauth_auth_codes_client_id_oauth_clients_client_id_fk' AND conrelid = '
|
|
190
|
+
SELECT 1 FROM pg_constraint WHERE conname = 'oauth_auth_codes_client_id_oauth_clients_client_id_fk' AND conrelid = to_regclass('oauth_auth_codes')
|
|
191
191
|
) THEN
|
|
192
|
-
ALTER TABLE "oauth_auth_codes" ADD CONSTRAINT "oauth_auth_codes_client_id_oauth_clients_client_id_fk" FOREIGN KEY ("client_id") REFERENCES "
|
|
192
|
+
ALTER TABLE "oauth_auth_codes" ADD CONSTRAINT "oauth_auth_codes_client_id_oauth_clients_client_id_fk" FOREIGN KEY ("client_id") REFERENCES "oauth_clients"("client_id") ON DELETE no action ON UPDATE no action;
|
|
193
193
|
END IF;
|
|
194
194
|
END $$;--> statement-breakpoint
|
|
195
195
|
DO $$ BEGIN
|
|
196
196
|
IF NOT EXISTS (
|
|
197
|
-
SELECT 1 FROM pg_constraint WHERE conname = 'oauth_auth_codes_user_id_users_id_fk' AND conrelid = '
|
|
197
|
+
SELECT 1 FROM pg_constraint WHERE conname = 'oauth_auth_codes_user_id_users_id_fk' AND conrelid = to_regclass('oauth_auth_codes')
|
|
198
198
|
) THEN
|
|
199
|
-
ALTER TABLE "oauth_auth_codes" ADD CONSTRAINT "oauth_auth_codes_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "
|
|
199
|
+
ALTER TABLE "oauth_auth_codes" ADD CONSTRAINT "oauth_auth_codes_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE no action ON UPDATE no action;
|
|
200
200
|
END IF;
|
|
201
201
|
END $$;--> statement-breakpoint
|
|
202
202
|
DO $$ BEGIN
|
|
203
203
|
IF NOT EXISTS (
|
|
204
|
-
SELECT 1 FROM pg_constraint WHERE conname = 'oauth_tokens_client_id_oauth_clients_client_id_fk' AND conrelid = '
|
|
204
|
+
SELECT 1 FROM pg_constraint WHERE conname = 'oauth_tokens_client_id_oauth_clients_client_id_fk' AND conrelid = to_regclass('oauth_tokens')
|
|
205
205
|
) THEN
|
|
206
|
-
ALTER TABLE "oauth_tokens" ADD CONSTRAINT "oauth_tokens_client_id_oauth_clients_client_id_fk" FOREIGN KEY ("client_id") REFERENCES "
|
|
206
|
+
ALTER TABLE "oauth_tokens" ADD CONSTRAINT "oauth_tokens_client_id_oauth_clients_client_id_fk" FOREIGN KEY ("client_id") REFERENCES "oauth_clients"("client_id") ON DELETE no action ON UPDATE no action;
|
|
207
207
|
END IF;
|
|
208
208
|
END $$;--> statement-breakpoint
|
|
209
209
|
DO $$ BEGIN
|
|
210
210
|
IF NOT EXISTS (
|
|
211
|
-
SELECT 1 FROM pg_constraint WHERE conname = 'oauth_tokens_user_id_users_id_fk' AND conrelid = '
|
|
211
|
+
SELECT 1 FROM pg_constraint WHERE conname = 'oauth_tokens_user_id_users_id_fk' AND conrelid = to_regclass('oauth_tokens')
|
|
212
212
|
) THEN
|
|
213
|
-
ALTER TABLE "oauth_tokens" ADD CONSTRAINT "oauth_tokens_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "
|
|
213
|
+
ALTER TABLE "oauth_tokens" ADD CONSTRAINT "oauth_tokens_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE no action ON UPDATE no action;
|
|
214
214
|
END IF;
|
|
215
215
|
END $$;--> statement-breakpoint
|
|
216
216
|
DO $$ BEGIN
|
|
217
217
|
IF NOT EXISTS (
|
|
218
|
-
SELECT 1 FROM pg_constraint WHERE conname = 'secrets_user_id_users_id_fk' AND conrelid = '
|
|
218
|
+
SELECT 1 FROM pg_constraint WHERE conname = 'secrets_user_id_users_id_fk' AND conrelid = to_regclass('secrets')
|
|
219
219
|
) THEN
|
|
220
|
-
ALTER TABLE "secrets" ADD CONSTRAINT "secrets_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "
|
|
220
|
+
ALTER TABLE "secrets" ADD CONSTRAINT "secrets_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE cascade ON UPDATE no action;
|
|
221
221
|
END IF;
|
|
222
222
|
END $$;--> statement-breakpoint
|
|
223
223
|
CREATE UNIQUE INDEX IF NOT EXISTS "change_requests_number_unq" ON "change_requests" USING btree ("number");--> statement-breakpoint
|
|
@@ -6,4 +6,4 @@ CREATE TABLE "deployment_settings" (
|
|
|
6
6
|
"updated_at" timestamp DEFAULT now() NOT NULL
|
|
7
7
|
);
|
|
8
8
|
--> statement-breakpoint
|
|
9
|
-
ALTER TABLE "deployment_settings" ADD CONSTRAINT "deployment_settings_updated_by_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "
|
|
9
|
+
ALTER TABLE "deployment_settings" ADD CONSTRAINT "deployment_settings_updated_by_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "users"("id") ON DELETE set null ON UPDATE no action;
|
|
@@ -22,4 +22,4 @@ CREATE TABLE "github_facade_identity" (
|
|
|
22
22
|
);
|
|
23
23
|
--> statement-breakpoint
|
|
24
24
|
ALTER TABLE "api_tokens" ADD COLUMN "kind" text DEFAULT 'key' NOT NULL;--> statement-breakpoint
|
|
25
|
-
ALTER TABLE "github_facade_codes" ADD CONSTRAINT "github_facade_codes_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "
|
|
25
|
+
ALTER TABLE "github_facade_codes" ADD CONSTRAINT "github_facade_codes_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE cascade ON UPDATE no action;
|
|
@@ -26,16 +26,16 @@ CREATE TABLE "agent_events" (
|
|
|
26
26
|
);
|
|
27
27
|
--> statement-breakpoint
|
|
28
28
|
ALTER TABLE "oauth_tokens" ADD COLUMN "connection_id" uuid;--> statement-breakpoint
|
|
29
|
-
ALTER TABLE "agent_connections" ADD CONSTRAINT "agent_connections_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "
|
|
30
|
-
ALTER TABLE "agent_connections" ADD CONSTRAINT "agent_connections_client_id_oauth_clients_client_id_fk" FOREIGN KEY ("client_id") REFERENCES "
|
|
31
|
-
ALTER TABLE "agent_events" ADD CONSTRAINT "agent_events_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "
|
|
32
|
-
ALTER TABLE "agent_events" ADD CONSTRAINT "agent_events_key_id_api_tokens_id_fk" FOREIGN KEY ("key_id") REFERENCES "
|
|
33
|
-
ALTER TABLE "agent_events" ADD CONSTRAINT "agent_events_connection_id_agent_connections_id_fk" FOREIGN KEY ("connection_id") REFERENCES "
|
|
29
|
+
ALTER TABLE "agent_connections" ADD CONSTRAINT "agent_connections_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
30
|
+
ALTER TABLE "agent_connections" ADD CONSTRAINT "agent_connections_client_id_oauth_clients_client_id_fk" FOREIGN KEY ("client_id") REFERENCES "oauth_clients"("client_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
31
|
+
ALTER TABLE "agent_events" ADD CONSTRAINT "agent_events_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
32
|
+
ALTER TABLE "agent_events" ADD CONSTRAINT "agent_events_key_id_api_tokens_id_fk" FOREIGN KEY ("key_id") REFERENCES "api_tokens"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
33
|
+
ALTER TABLE "agent_events" ADD CONSTRAINT "agent_events_connection_id_agent_connections_id_fk" FOREIGN KEY ("connection_id") REFERENCES "agent_connections"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
34
34
|
CREATE INDEX "agent_connections_by_user" ON "agent_connections" USING btree ("user_id");--> statement-breakpoint
|
|
35
35
|
CREATE UNIQUE INDEX "agent_connections_live_unq" ON "agent_connections" USING btree ("user_id","client_id") WHERE "agent_connections"."revoked_at" is null;--> statement-breakpoint
|
|
36
36
|
CREATE INDEX "agent_events_by_key" ON "agent_events" USING btree ("key_id","at");--> statement-breakpoint
|
|
37
37
|
CREATE INDEX "agent_events_by_connection" ON "agent_events" USING btree ("connection_id","at");--> statement-breakpoint
|
|
38
38
|
CREATE INDEX "agent_events_by_at" ON "agent_events" USING btree ("at");--> statement-breakpoint
|
|
39
39
|
CREATE INDEX "agent_events_by_user" ON "agent_events" USING btree ("user_id");--> statement-breakpoint
|
|
40
|
-
ALTER TABLE "oauth_tokens" ADD CONSTRAINT "oauth_tokens_connection_id_agent_connections_id_fk" FOREIGN KEY ("connection_id") REFERENCES "
|
|
40
|
+
ALTER TABLE "oauth_tokens" ADD CONSTRAINT "oauth_tokens_connection_id_agent_connections_id_fk" FOREIGN KEY ("connection_id") REFERENCES "agent_connections"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
41
41
|
CREATE INDEX "oauth_tokens_by_connection" ON "oauth_tokens" USING btree ("connection_id");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bevel-software/platform-core-backend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Open-source core backend of the Bevel platform: git-backed knowledge workspace, workflow (branches/change requests/locks/SSE), skills, tools, secrets vault, access control and the remote MCP surface.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
|
|
53
53
|
"yaml": "^2.9.0",
|
|
54
54
|
"zod": "^3.24.0",
|
|
55
|
-
"@bevel-software/platform-mcp-core": "0.
|
|
56
|
-
"@bevel-software/platform-shared": "0.
|
|
55
|
+
"@bevel-software/platform-mcp-core": "0.21.0",
|
|
56
|
+
"@bevel-software/platform-shared": "0.21.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/adm-zip": "^0.5.8",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect, afterEach, beforeEach } from 'vitest';
|
|
2
2
|
import {
|
|
3
3
|
configureBranchModel,
|
|
4
|
+
currentBranchModel,
|
|
4
5
|
isBranchModelConfigured,
|
|
5
6
|
isProtectedBranch,
|
|
6
7
|
protectedBranchDisplayName,
|
|
@@ -21,14 +22,14 @@ afterEach(() => configureBranchModel(PAIR));
|
|
|
21
22
|
|
|
22
23
|
describe('configureBranchModel', () => {
|
|
23
24
|
it('applies the model to every export', () => {
|
|
24
|
-
expect(isBranchModelConfigured()).toBe(true);
|
|
25
|
+
expect(isBranchModelConfigured(currentBranchModel())).toBe(true);
|
|
25
26
|
expect(DEFAULT_BRANCH).toBe('target-company-state');
|
|
26
27
|
expect([...PROTECTED_BRANCHES].sort()).toEqual([
|
|
27
28
|
'current-company-state',
|
|
28
29
|
'target-company-state',
|
|
29
30
|
]);
|
|
30
|
-
expect(isProtectedBranch('current-company-state')).toBe(true);
|
|
31
|
-
expect(isProtectedBranch('someone/draft')).toBe(false);
|
|
31
|
+
expect(isProtectedBranch(currentBranchModel(), 'current-company-state')).toBe(true);
|
|
32
|
+
expect(isProtectedBranch(currentBranchModel(), 'someone/draft')).toBe(false);
|
|
32
33
|
});
|
|
33
34
|
|
|
34
35
|
it('accepts the comma/space list the environment supplies', () => {
|
|
@@ -37,10 +38,10 @@ describe('configureBranchModel', () => {
|
|
|
37
38
|
});
|
|
38
39
|
|
|
39
40
|
it('derives display names from the slug', () => {
|
|
40
|
-
expect(protectedBranchDisplayName('target-company-state')).toBe('Target company state');
|
|
41
|
+
expect(protectedBranchDisplayName(currentBranchModel(), 'target-company-state')).toBe('Target company state');
|
|
41
42
|
// Unknown names return null so the caller decides between the raw slug and
|
|
42
43
|
// hiding the affordance — it must not invent a name for a feature branch.
|
|
43
|
-
expect(protectedBranchDisplayName('someone/draft')).toBeNull();
|
|
44
|
+
expect(protectedBranchDisplayName(currentBranchModel(), 'someone/draft')).toBeNull();
|
|
44
45
|
});
|
|
45
46
|
|
|
46
47
|
/**
|
|
@@ -74,6 +75,6 @@ describe('configureBranchModel', () => {
|
|
|
74
75
|
configureBranchModel({ defaultBranch: 'nope', protectedBranches: ['other'] }),
|
|
75
76
|
).toThrow();
|
|
76
77
|
expect(DEFAULT_BRANCH).toBe('target-company-state');
|
|
77
|
-
expect(isProtectedBranch('target-company-state')).toBe(true);
|
|
78
|
+
expect(isProtectedBranch(currentBranchModel(), 'target-company-state')).toBe(true);
|
|
78
79
|
});
|
|
79
80
|
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_KB_LAYOUT,
|
|
3
|
+
resolveBranchModel,
|
|
4
|
+
type BranchModel,
|
|
5
|
+
type KbLayout,
|
|
6
|
+
} from '@bevel-software/platform-shared';
|
|
7
|
+
import { KbContext } from '../shared/kb-context.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The knowledge-base context suites hand to the services they construct: the
|
|
11
|
+
* historical two-branch pair `vitest.config.ts` pins (and `test-setup.ts`
|
|
12
|
+
* mirrors onto the shared bindings, for the fixtures that still spell a
|
|
13
|
+
* branch by its binding), the default layout, and `knowledge-base` as the
|
|
14
|
+
* checkout folder. Override any part for a suite that needs another.
|
|
15
|
+
*/
|
|
16
|
+
export const TEST_BRANCH_MODEL: BranchModel = {
|
|
17
|
+
defaultBranch: 'target-company-state',
|
|
18
|
+
protectedBranches: ['current-company-state', 'target-company-state'],
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export function testKbContext(
|
|
22
|
+
overrides: { kbDirName?: string; branchModel?: BranchModel | null; layout?: KbLayout } = {},
|
|
23
|
+
): KbContext {
|
|
24
|
+
const model = overrides.branchModel === undefined ? TEST_BRANCH_MODEL : overrides.branchModel;
|
|
25
|
+
return new KbContext(
|
|
26
|
+
overrides.kbDirName ?? 'knowledge-base',
|
|
27
|
+
model === null ? KbContext.branchModelOrUnconfigured({ defaultBranch: '', protectedBranches: [] }) : resolveBranchModel(model),
|
|
28
|
+
overrides.layout ?? DEFAULT_KB_LAYOUT,
|
|
29
|
+
);
|
|
30
|
+
}
|