@bevel-software/platform-core-backend 0.21.0 → 0.23.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 +62 -13
- package/dist/core/create-core-server.js.map +1 -1
- package/dist/core/create-core-services.d.ts +22 -3
- package/dist/core/create-core-services.d.ts.map +1 -1
- package/dist/core/create-core-services.js +158 -23
- package/dist/core/create-core-services.js.map +1 -1
- package/dist/core/lifecycle.d.ts +34 -1
- package/dist/core/lifecycle.d.ts.map +1 -1
- package/dist/core/lifecycle.js +89 -13
- package/dist/core/lifecycle.js.map +1 -1
- package/dist/core-config.d.ts +0 -12
- package/dist/core-config.d.ts.map +1 -1
- package/dist/core-config.js +11 -13
- package/dist/core-config.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- 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-requests.contract.d.ts +75 -0
- package/dist/modules/access/access-requests.contract.d.ts.map +1 -0
- package/dist/modules/access/access-requests.contract.js +20 -0
- package/dist/modules/access/access-requests.contract.js.map +1 -0
- package/dist/modules/access/access-requests.routes.d.ts +35 -0
- package/dist/modules/access/access-requests.routes.d.ts.map +1 -0
- package/dist/modules/access/access-requests.routes.js +237 -0
- package/dist/modules/access/access-requests.routes.js.map +1 -0
- package/dist/modules/access/access-requests.service.d.ts +123 -0
- package/dist/modules/access/access-requests.service.d.ts.map +1 -0
- package/dist/modules/access/access-requests.service.js +337 -0
- package/dist/modules/access/access-requests.service.js.map +1 -0
- package/dist/modules/access/access.routes.d.ts.map +1 -1
- package/dist/modules/access/access.routes.js +13 -15
- package/dist/modules/access/access.routes.js.map +1 -1
- package/dist/modules/access-model/access-grammar.d.ts +12 -0
- package/dist/modules/access-model/access-grammar.d.ts.map +1 -1
- package/dist/modules/access-model/access-grammar.js +24 -0
- package/dist/modules/access-model/access-grammar.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.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 +96 -3
- package/dist/modules/auth/auth.service.d.ts.map +1 -1
- package/dist/modules/auth/auth.service.js +187 -9
- 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/database/core-schema.d.ts +41 -24
- package/dist/modules/database/core-schema.d.ts.map +1 -1
- package/dist/modules/database/core-schema.js +35 -27
- package/dist/modules/database/core-schema.js.map +1 -1
- package/dist/modules/github-app/github-app.client.d.ts +101 -0
- package/dist/modules/github-app/github-app.client.d.ts.map +1 -0
- package/dist/modules/github-app/github-app.client.js +222 -0
- package/dist/modules/github-app/github-app.client.js.map +1 -0
- package/dist/modules/github-app/github-app.connection.d.ts +102 -0
- package/dist/modules/github-app/github-app.connection.d.ts.map +1 -0
- package/dist/modules/github-app/github-app.connection.js +185 -0
- package/dist/modules/github-app/github-app.connection.js.map +1 -0
- package/dist/modules/github-app/github-app.routes.d.ts +59 -0
- package/dist/modules/github-app/github-app.routes.d.ts.map +1 -0
- package/dist/modules/github-app/github-app.routes.js +323 -0
- package/dist/modules/github-app/github-app.routes.js.map +1 -0
- package/dist/modules/github-app/index.d.ts +4 -0
- package/dist/modules/github-app/index.d.ts.map +1 -0
- package/dist/modules/github-app/index.js +4 -0
- package/dist/modules/github-app/index.js.map +1 -0
- 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/remote-url.d.ts +22 -0
- package/dist/modules/kb-fs/remote-url.d.ts.map +1 -0
- package/dist/modules/kb-fs/remote-url.js +35 -0
- package/dist/modules/kb-fs/remote-url.js.map +1 -0
- 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/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-proposals.d.ts +17 -5
- package/dist/modules/plugins/join-proposals.d.ts.map +1 -1
- package/dist/modules/plugins/join-proposals.js +76 -22
- package/dist/modules/plugins/join-proposals.js.map +1 -1
- package/dist/modules/plugins/join-requests.service.d.ts +111 -18
- package/dist/modules/plugins/join-requests.service.d.ts.map +1 -1
- package/dist/modules/plugins/join-requests.service.js +173 -29
- package/dist/modules/plugins/join-requests.service.js.map +1 -1
- package/dist/modules/plugins/plugins.routes.d.ts.map +1 -1
- package/dist/modules/plugins/plugins.routes.js +3 -2
- package/dist/modules/plugins/plugins.routes.js.map +1 -1
- package/dist/modules/settings/deployment-settings.service.d.ts +22 -1
- package/dist/modules/settings/deployment-settings.service.d.ts.map +1 -1
- package/dist/modules/settings/deployment-settings.service.js +101 -7
- package/dist/modules/settings/deployment-settings.service.js.map +1 -1
- package/dist/modules/settings/managed-repository.d.ts +43 -0
- package/dist/modules/settings/managed-repository.d.ts.map +1 -0
- package/dist/modules/settings/managed-repository.js +60 -0
- package/dist/modules/settings/managed-repository.js.map +1 -0
- package/dist/modules/settings/repository-source.d.ts +128 -0
- package/dist/modules/settings/repository-source.d.ts.map +1 -0
- package/dist/modules/settings/repository-source.js +150 -0
- package/dist/modules/settings/repository-source.js.map +1 -0
- package/dist/modules/settings/setup.routes.d.ts +78 -4
- package/dist/modules/settings/setup.routes.d.ts.map +1 -1
- package/dist/modules/settings/setup.routes.js +379 -17
- package/dist/modules/settings/setup.routes.js.map +1 -1
- package/dist/modules/skills/skill-access-requests.routes.d.ts +6 -8
- package/dist/modules/skills/skill-access-requests.routes.d.ts.map +1 -1
- package/dist/modules/skills/skill-access-requests.routes.js +24 -63
- package/dist/modules/skills/skill-access-requests.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 +4 -2
- 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-context.d.ts.map +1 -1
- package/dist/modules/tool-helpers/tool-context.js +15 -0
- package/dist/modules/tool-helpers/tool-context.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/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 +113 -37
- 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 +72 -1
- package/dist/modules/workflow/git/git.service.d.ts.map +1 -1
- package/dist/modules/workflow/git/git.service.js +170 -6
- package/dist/modules/workflow/git/git.service.js.map +1 -1
- package/dist/modules/workflow/git/node-git-runner.d.ts.map +1 -1
- package/dist/modules/workflow/git/node-git-runner.js +5 -0
- package/dist/modules/workflow/git/node-git-runner.js.map +1 -1
- package/dist/modules/workflow/git/pull-request.service.d.ts +45 -0
- package/dist/modules/workflow/git/pull-request.service.d.ts.map +1 -1
- package/dist/modules/workflow/git/pull-request.service.js +99 -0
- package/dist/modules/workflow/git/pull-request.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 +55 -0
- package/dist/modules/workflow/pending-commits.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.routes.d.ts.map +1 -1
- package/dist/modules/workflow/workflow.routes.js +3 -1
- package/dist/modules/workflow/workflow.routes.js.map +1 -1
- package/dist/modules/workflow/workflow.service.d.ts +94 -13
- package/dist/modules/workflow/workflow.service.d.ts.map +1 -1
- package/dist/modules/workflow/workflow.service.js +258 -51
- 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/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 +117 -1
- package/dist/modules/workspace/startup/kb-startup-runner.d.ts.map +1 -1
- package/dist/modules/workspace/startup/kb-startup-runner.js +190 -1
- package/dist/modules/workspace/startup/kb-startup-runner.js.map +1 -1
- package/dist/modules/workspace/workspace.routes.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.routes.js +92 -3
- package/dist/modules/workspace/workspace.routes.js.map +1 -1
- package/dist/modules/workspace/workspace.service.d.ts +115 -5
- package/dist/modules/workspace/workspace.service.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.service.js +272 -26
- package/dist/modules/workspace/workspace.service.js.map +1 -1
- package/dist/modules/workspace/workspace.tools.d.ts +2 -2
- package/dist/modules/workspace/workspace.tools.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.tools.js +337 -117
- package/dist/modules/workspace/workspace.tools.js.map +1 -1
- 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/domain-errors.d.ts +64 -0
- package/dist/shared/domain-errors.d.ts.map +1 -1
- package/dist/shared/domain-errors.js +83 -0
- package/dist/shared/domain-errors.js.map +1 -1
- package/dist/shared/git.contract.d.ts +30 -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/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 +0 -2
- package/dist/tenancy/static-tenant-source.js.map +1 -1
- package/migrations/0014_change_request_closed_reason.sql +1 -0
- package/migrations/0015_account_deactivation.sql +3 -0
- package/migrations/meta/0014_snapshot.json +2265 -0
- package/migrations/meta/0015_snapshot.json +2271 -0
- package/migrations/meta/_journal.json +14 -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 +170 -1
- 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 +69 -15
- package/src/core/create-core-services.ts +190 -27
- package/src/core/lifecycle.ts +98 -13
- package/src/core-config.ts +13 -14
- package/src/index.ts +12 -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-requests.recut.test.ts +134 -0
- package/src/modules/access/__tests__/access-requests.routes.test.ts +610 -0
- package/src/modules/access/__tests__/access.routes.prospective.test.ts +6 -7
- 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-requests.contract.ts +93 -0
- package/src/modules/access/access-requests.routes.ts +286 -0
- package/src/modules/access/access-requests.service.ts +420 -0
- package/src/modules/access/access.routes.ts +13 -15
- package/src/modules/access-model/access-grammar.ts +22 -0
- package/src/modules/agent-instructions/__tests__/agent-instructions.route.test.ts +3 -1
- package/src/modules/auth/__tests__/account-deactivation.test.ts +252 -0
- package/src/modules/auth/__tests__/account.routes.test.ts +81 -3
- package/src/modules/auth/__tests__/auth.middleware.test.ts +45 -22
- package/src/modules/auth/__tests__/auth.service.test.ts +39 -1
- package/src/modules/auth/account-admission.ts +78 -9
- 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 +207 -7
- package/src/modules/auth/oidc-auth-provider.ts +7 -2
- package/src/modules/database/core-schema.ts +35 -27
- package/src/modules/github-app/__tests__/github-app.test.ts +848 -0
- package/src/modules/github-app/github-app.client.ts +268 -0
- package/src/modules/github-app/github-app.connection.ts +204 -0
- package/src/modules/github-app/github-app.routes.ts +359 -0
- package/src/modules/github-app/index.ts +19 -0
- package/src/modules/kb-fs/__tests__/branch-name.test.ts +10 -0
- package/src/modules/kb-fs/__tests__/remote-url.test.ts +38 -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/remote-url.ts +35 -0
- 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.service.test.ts +68 -6
- package/src/modules/mcp/mcp-auth.middleware.ts +20 -6
- package/src/modules/mcp/oauth/bevel-oauth-provider.ts +3 -1
- package/src/modules/plugins/__tests__/join-proposals.test.ts +100 -19
- package/src/modules/plugins/__tests__/join-requests.service.test.ts +27 -11
- package/src/modules/plugins/__tests__/join-requests.settlement.test.ts +371 -0
- package/src/modules/plugins/__tests__/plugins.routes.test.ts +1 -1
- package/src/modules/plugins/__tests__/plugins.tools.test.ts +2 -1
- package/src/modules/plugins/join-proposals.ts +87 -19
- package/src/modules/plugins/join-requests.service.ts +199 -39
- package/src/modules/plugins/plugins.routes.ts +3 -2
- package/src/modules/settings/__tests__/deployment-settings.service.test.ts +16 -0
- package/src/modules/settings/__tests__/repository-source.test.ts +191 -0
- package/src/modules/settings/__tests__/setup.routes.git-mode.test.ts +386 -0
- package/src/modules/settings/__tests__/setup.routes.github-app.test.ts +299 -0
- package/src/modules/settings/__tests__/setup.routes.managed-phase.test.ts +236 -0
- 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 +117 -6
- package/src/modules/settings/managed-repository.ts +68 -0
- package/src/modules/settings/repository-source.ts +197 -0
- package/src/modules/settings/setup.routes.ts +463 -15
- 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__/skill-access-requests.routes.test.ts +5 -1
- package/src/modules/skills/__tests__/skills.service.test.ts +229 -5
- package/src/modules/skills/skill-access-requests.routes.ts +25 -75
- 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 +4 -2
- 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-context.ts +15 -0
- 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/workflow/__tests__/apply-failure.test.ts +9 -1
- 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.facade.test.ts +159 -8
- package/src/modules/workflow/__tests__/workflow.service.repository-replaced.test.ts +249 -0
- package/src/modules/workflow/__tests__/workflow.service.update-from-target.test.ts +146 -40
- package/src/modules/workflow/agent-tools/__tests__/workflow.tools.test.ts +405 -7
- package/src/modules/workflow/agent-tools/change-request-summary.ts +182 -0
- package/src/modules/workflow/agent-tools/workflow.tools.ts +135 -38
- 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.pull.test.ts +121 -0
- package/src/modules/workflow/git/__tests__/pull-request.service.getPrDetail.test.ts +145 -2
- package/src/modules/workflow/git/__tests__/pull-request.service.viewer-can-delete.test.ts +166 -0
- package/src/modules/workflow/git/git.service.ts +193 -4
- package/src/modules/workflow/git/node-git-runner.ts +6 -0
- package/src/modules/workflow/git/pull-request.service.ts +119 -0
- package/src/modules/workflow/pending-commits.service.ts +59 -1
- package/src/modules/workflow/workflow-hooks.ts +64 -26
- package/src/modules/workflow/workflow.routes.ts +3 -1
- package/src/modules/workflow/workflow.service.ts +290 -55
- package/src/modules/workspace/__tests__/agent-access.gate.test.ts +208 -0
- package/src/modules/workspace/__tests__/escape-sequences.routes.test.ts +384 -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.forget-clone-races.test.ts +147 -0
- package/src/modules/workspace/__tests__/workspace.service.replaced-repository.test.ts +326 -0
- package/src/modules/workspace/__tests__/workspace.service.test.ts +20 -9
- package/src/modules/workspace/__tests__/workspace.service.unknown-branch.test.ts +43 -0
- package/src/modules/workspace/__tests__/workspace.tools.agents-file.test.ts +2 -3
- package/src/modules/workspace/__tests__/workspace.tools.branch-errors.test.ts +235 -10
- package/src/modules/workspace/__tests__/workspace.tools.test.ts +720 -17
- package/src/modules/workspace/agent-access.gate.ts +164 -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 +297 -0
- package/src/modules/workspace/startup/kb-startup-runner.ts +242 -2
- package/src/modules/workspace/workspace.routes.ts +95 -3
- package/src/modules/workspace/workspace.service.ts +273 -25
- package/src/modules/workspace/workspace.tools.ts +373 -119
- 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/domain-errors.ts +89 -0
- package/src/shared/git.contract.ts +37 -0
- package/src/tenancy/__tests__/static-tenant-source.test.ts +0 -1
- package/src/tenancy/static-tenant-source.ts +0 -3
- 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
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { GitHubAppRepository, SettingReader } from '../settings/repository-source.js';
|
|
2
|
+
import { GitHubAppClient, type GitHubAppCredentials, type InstallationRepository } from './github-app.client.js';
|
|
3
|
+
/** The repositories a person may connect, as a setting holds them: one `owner/name` a line. */
|
|
4
|
+
export declare function repositoriesAsSetting(names: string[]): string;
|
|
5
|
+
export interface GitHubAppConnectionOptions {
|
|
6
|
+
/** The deployment's settings, as they are in effect. */
|
|
7
|
+
read: SettingReader;
|
|
8
|
+
/** Where a setting's value comes from: what tells an app the operator supplied from one setup registered. */
|
|
9
|
+
sourceOf(key: string): 'env' | 'stored' | 'unset';
|
|
10
|
+
client?: GitHubAppClient;
|
|
11
|
+
now?: () => number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The deployment's connection to GitHub through a GitHub App: the app it
|
|
15
|
+
* acts as, the installation it was given, the repositories it may be
|
|
16
|
+
* pointed at, and the token that stands for the first two when git runs.
|
|
17
|
+
*
|
|
18
|
+
* THE TOKEN EXPIRES. An installation token is good for an hour, which is
|
|
19
|
+
* the point of it: nothing long-lived is stored that reaches the
|
|
20
|
+
* repository. It is kept in memory, renewed before it runs out, and never
|
|
21
|
+
* written anywhere. A deployment that restarts asks for a new one.
|
|
22
|
+
*
|
|
23
|
+
* What is stored is what cannot be asked for again: the app's private key,
|
|
24
|
+
* encrypted like every secret, the number of the installation, and the
|
|
25
|
+
* repositories the person who connected it could push to.
|
|
26
|
+
*
|
|
27
|
+
* WHAT THE INSTALLATION REACHES IS NOT WHAT THE DEPLOYMENT MAY USE. An
|
|
28
|
+
* installation's token reads and writes every repository the installation
|
|
29
|
+
* covers. The person who connected it may hold far less: being able to
|
|
30
|
+
* read ONE of those repositories is enough for GitHub to count the
|
|
31
|
+
* installation among theirs. So the deployment is limited to what that
|
|
32
|
+
* person could push to with their own account, recorded when they
|
|
33
|
+
* connected (see {@link permits}); the installation's reach is what git
|
|
34
|
+
* works through, never what is offered.
|
|
35
|
+
*/
|
|
36
|
+
export declare class GitHubAppConnection implements GitHubAppRepository {
|
|
37
|
+
private readonly opts;
|
|
38
|
+
private readonly client;
|
|
39
|
+
private readonly now;
|
|
40
|
+
private readonly log;
|
|
41
|
+
/** The token in hand and what it is a token FOR: another app or installation is another token. */
|
|
42
|
+
private held;
|
|
43
|
+
/** One renewal at a time, shared by every git call that arrives during it. */
|
|
44
|
+
private renewing;
|
|
45
|
+
/** The last renewal failed: how many in a row have, and until when GitHub is not asked again. */
|
|
46
|
+
private failed;
|
|
47
|
+
constructor(opts: GitHubAppConnectionOptions);
|
|
48
|
+
/** The app the deployment acts as, or null while any part of it is missing. */
|
|
49
|
+
credentials(read?: SettingReader): GitHubAppCredentials | null;
|
|
50
|
+
/** Who supplied the app: whoever operates the deployment, or the setup screen. Null: there is none. */
|
|
51
|
+
registeredBy(): 'environment' | 'setup' | null;
|
|
52
|
+
installationId(read?: SettingReader): string;
|
|
53
|
+
url(read?: SettingReader): string;
|
|
54
|
+
answered(read?: SettingReader): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Whether the deployment may be pointed at `repository`: it is one the
|
|
57
|
+
* person who connected the installation could push to.
|
|
58
|
+
*
|
|
59
|
+
* An installation the OPERATOR supplied, through the environment, has no
|
|
60
|
+
* such person. It is the operator's statement about their own
|
|
61
|
+
* deployment, and everything it reaches is permitted, as everything an
|
|
62
|
+
* access token reaches is.
|
|
63
|
+
*/
|
|
64
|
+
permits(repository: string, read?: SettingReader): boolean;
|
|
65
|
+
token(): string | null;
|
|
66
|
+
/**
|
|
67
|
+
* Have a token for the call about to be made, WITHOUT MAKING THE CALL
|
|
68
|
+
* WAIT ON GITHUB UNLESS IT HAS TO. This runs before every git call the
|
|
69
|
+
* deployment makes, the ones that never leave the disk included.
|
|
70
|
+
*
|
|
71
|
+
* - A token with time to spare: nothing is asked.
|
|
72
|
+
* - A token that is good but close to running out: a renewal is started
|
|
73
|
+
* and the call goes ahead with the token in hand.
|
|
74
|
+
* - No token that is good: the call waits for one, and gets what GitHub
|
|
75
|
+
* says, unless GitHub has just failed to give one. A failure is
|
|
76
|
+
* remembered for a short while that grows with each one in a row, and
|
|
77
|
+
* inside it nothing is asked: git runs with no token, and a call that
|
|
78
|
+
* needed one is told so by the host, at once.
|
|
79
|
+
*
|
|
80
|
+
* `asked` is for an admin waiting on the answer itself (the setup screen
|
|
81
|
+
* listing repositories, proving a connection): GitHub is asked whatever
|
|
82
|
+
* is remembered, and the failure is thrown.
|
|
83
|
+
*/
|
|
84
|
+
prepare(opts?: {
|
|
85
|
+
asked?: boolean;
|
|
86
|
+
}): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* The repositories the deployment may be pointed at: those the
|
|
89
|
+
* installation reaches AND the person who connected it could push to.
|
|
90
|
+
* Asked of GitHub each time, so a repository taken out of the
|
|
91
|
+
* installation since is not offered.
|
|
92
|
+
*/
|
|
93
|
+
repositories(): Promise<{
|
|
94
|
+
repositories: InstallationRepository[];
|
|
95
|
+
more: boolean;
|
|
96
|
+
}>;
|
|
97
|
+
/** Drop the token in hand: the installation it was for is no longer the deployment's. */
|
|
98
|
+
forget(): void;
|
|
99
|
+
private renew;
|
|
100
|
+
private holder;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=github-app.connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-app.connection.d.ts","sourceRoot":"","sources":["../../../src/modules/github-app/github-app.connection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAC3F,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC5B,MAAM,wBAAwB,CAAC;AAQhC,+FAA+F;AAC/F,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAE7D;AAED,MAAM,WAAW,0BAA0B;IACzC,wDAAwD;IACxD,IAAI,EAAE,aAAa,CAAC;IACpB,6GAA6G;IAC7G,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;IAClD,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,mBAAoB,YAAW,mBAAmB;IAWjD,OAAO,CAAC,QAAQ,CAAC,IAAI;IAVjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;IACzC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;IACnC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA8B;IAClD,kGAAkG;IAClG,OAAO,CAAC,IAAI,CAAkE;IAC9E,8EAA8E;IAC9E,OAAO,CAAC,QAAQ,CAA8B;IAC9C,iGAAiG;IACjG,OAAO,CAAC,MAAM,CAAiD;gBAElC,IAAI,EAAE,0BAA0B;IAK7D,+EAA+E;IAC/E,WAAW,CAAC,IAAI,GAAE,aAA8B,GAAG,oBAAoB,GAAG,IAAI;IAW9E,uGAAuG;IACvG,YAAY,IAAI,aAAa,GAAG,OAAO,GAAG,IAAI;IAK9C,cAAc,CAAC,IAAI,GAAE,aAA8B,GAAG,MAAM;IAI5D,GAAG,CAAC,IAAI,GAAE,aAA8B,GAAG,MAAM;IAKjD,QAAQ,CAAC,IAAI,GAAE,aAA8B,GAAG,OAAO;IAIvD;;;;;;;;OAQG;IACH,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,GAAE,aAA8B,GAAG,OAAO;IAU1E,KAAK,IAAI,MAAM,GAAG,IAAI;IAMtB;;;;;;;;;;;;;;;;;OAiBG;IACG,OAAO,CAAC,IAAI,GAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB5D;;;;;OAKG;IACG,YAAY,IAAI,OAAO,CAAC;QAAE,YAAY,EAAE,sBAAsB,EAAE,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC;IAQxF,yFAAyF;IACzF,MAAM,IAAI,IAAI;YAKA,KAAK;IAmBnB,OAAO,CAAC,MAAM;CAGf"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { logger } from '../../shared/logging.js';
|
|
2
|
+
import { GitHubAppClient, } from './github-app.client.js';
|
|
3
|
+
/** Renewed this long before it would expire, so no git call starts on a token with minutes to live. */
|
|
4
|
+
const RENEW_AHEAD_MS = 10 * 60_000;
|
|
5
|
+
/** How long a failed renewal is remembered the first time, and the most it grows to. */
|
|
6
|
+
const FIRST_WAIT_MS = 5_000;
|
|
7
|
+
const LONGEST_WAIT_MS = 5 * 60_000;
|
|
8
|
+
/** The repositories a person may connect, as a setting holds them: one `owner/name` a line. */
|
|
9
|
+
export function repositoriesAsSetting(names) {
|
|
10
|
+
return [...new Set(names.map((name) => name.trim()).filter(Boolean))].join('\n');
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The deployment's connection to GitHub through a GitHub App: the app it
|
|
14
|
+
* acts as, the installation it was given, the repositories it may be
|
|
15
|
+
* pointed at, and the token that stands for the first two when git runs.
|
|
16
|
+
*
|
|
17
|
+
* THE TOKEN EXPIRES. An installation token is good for an hour, which is
|
|
18
|
+
* the point of it: nothing long-lived is stored that reaches the
|
|
19
|
+
* repository. It is kept in memory, renewed before it runs out, and never
|
|
20
|
+
* written anywhere. A deployment that restarts asks for a new one.
|
|
21
|
+
*
|
|
22
|
+
* What is stored is what cannot be asked for again: the app's private key,
|
|
23
|
+
* encrypted like every secret, the number of the installation, and the
|
|
24
|
+
* repositories the person who connected it could push to.
|
|
25
|
+
*
|
|
26
|
+
* WHAT THE INSTALLATION REACHES IS NOT WHAT THE DEPLOYMENT MAY USE. An
|
|
27
|
+
* installation's token reads and writes every repository the installation
|
|
28
|
+
* covers. The person who connected it may hold far less: being able to
|
|
29
|
+
* read ONE of those repositories is enough for GitHub to count the
|
|
30
|
+
* installation among theirs. So the deployment is limited to what that
|
|
31
|
+
* person could push to with their own account, recorded when they
|
|
32
|
+
* connected (see {@link permits}); the installation's reach is what git
|
|
33
|
+
* works through, never what is offered.
|
|
34
|
+
*/
|
|
35
|
+
export class GitHubAppConnection {
|
|
36
|
+
opts;
|
|
37
|
+
client;
|
|
38
|
+
now;
|
|
39
|
+
log = () => logger('github-app');
|
|
40
|
+
/** The token in hand and what it is a token FOR: another app or installation is another token. */
|
|
41
|
+
held = null;
|
|
42
|
+
/** One renewal at a time, shared by every git call that arrives during it. */
|
|
43
|
+
renewing = null;
|
|
44
|
+
/** The last renewal failed: how many in a row have, and until when GitHub is not asked again. */
|
|
45
|
+
failed = null;
|
|
46
|
+
constructor(opts) {
|
|
47
|
+
this.opts = opts;
|
|
48
|
+
this.client = opts.client ?? new GitHubAppClient();
|
|
49
|
+
this.now = opts.now ?? Date.now;
|
|
50
|
+
}
|
|
51
|
+
/** The app the deployment acts as, or null while any part of it is missing. */
|
|
52
|
+
credentials(read = this.opts.read) {
|
|
53
|
+
const credentials = {
|
|
54
|
+
appId: read('githubAppId'),
|
|
55
|
+
slug: read('githubAppSlug'),
|
|
56
|
+
privateKey: read('githubAppPrivateKey'),
|
|
57
|
+
clientId: read('githubAppClientId'),
|
|
58
|
+
clientSecret: read('githubAppClientSecret'),
|
|
59
|
+
};
|
|
60
|
+
return Object.values(credentials).every(Boolean) ? credentials : null;
|
|
61
|
+
}
|
|
62
|
+
/** Who supplied the app: whoever operates the deployment, or the setup screen. Null: there is none. */
|
|
63
|
+
registeredBy() {
|
|
64
|
+
if (!this.credentials())
|
|
65
|
+
return null;
|
|
66
|
+
return this.opts.sourceOf('githubAppId') === 'env' ? 'environment' : 'setup';
|
|
67
|
+
}
|
|
68
|
+
installationId(read = this.opts.read) {
|
|
69
|
+
return read('githubInstallationId');
|
|
70
|
+
}
|
|
71
|
+
url(read = this.opts.read) {
|
|
72
|
+
const repository = read('githubRepository');
|
|
73
|
+
return repository ? `https://github.com/${repository}.git` : '';
|
|
74
|
+
}
|
|
75
|
+
answered(read = this.opts.read) {
|
|
76
|
+
return Boolean(this.credentials(read) && this.installationId(read) && read('githubRepository'));
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Whether the deployment may be pointed at `repository`: it is one the
|
|
80
|
+
* person who connected the installation could push to.
|
|
81
|
+
*
|
|
82
|
+
* An installation the OPERATOR supplied, through the environment, has no
|
|
83
|
+
* such person. It is the operator's statement about their own
|
|
84
|
+
* deployment, and everything it reaches is permitted, as everything an
|
|
85
|
+
* access token reaches is.
|
|
86
|
+
*/
|
|
87
|
+
permits(repository, read = this.opts.read) {
|
|
88
|
+
if (this.opts.sourceOf('githubInstallationId') === 'env')
|
|
89
|
+
return true;
|
|
90
|
+
const wanted = repository.trim().toLowerCase();
|
|
91
|
+
if (!wanted)
|
|
92
|
+
return false;
|
|
93
|
+
// GitHub's names do not tell case apart.
|
|
94
|
+
return read('githubRepositoriesPermitted')
|
|
95
|
+
.split('\n')
|
|
96
|
+
.some((name) => name.trim().toLowerCase() === wanted);
|
|
97
|
+
}
|
|
98
|
+
token() {
|
|
99
|
+
const held = this.held;
|
|
100
|
+
if (!held || held.for !== this.holder() || held.expiresAt <= this.now())
|
|
101
|
+
return null;
|
|
102
|
+
return held.token;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Have a token for the call about to be made, WITHOUT MAKING THE CALL
|
|
106
|
+
* WAIT ON GITHUB UNLESS IT HAS TO. This runs before every git call the
|
|
107
|
+
* deployment makes, the ones that never leave the disk included.
|
|
108
|
+
*
|
|
109
|
+
* - A token with time to spare: nothing is asked.
|
|
110
|
+
* - A token that is good but close to running out: a renewal is started
|
|
111
|
+
* and the call goes ahead with the token in hand.
|
|
112
|
+
* - No token that is good: the call waits for one, and gets what GitHub
|
|
113
|
+
* says, unless GitHub has just failed to give one. A failure is
|
|
114
|
+
* remembered for a short while that grows with each one in a row, and
|
|
115
|
+
* inside it nothing is asked: git runs with no token, and a call that
|
|
116
|
+
* needed one is told so by the host, at once.
|
|
117
|
+
*
|
|
118
|
+
* `asked` is for an admin waiting on the answer itself (the setup screen
|
|
119
|
+
* listing repositories, proving a connection): GitHub is asked whatever
|
|
120
|
+
* is remembered, and the failure is thrown.
|
|
121
|
+
*/
|
|
122
|
+
async prepare(opts = {}) {
|
|
123
|
+
const credentials = this.credentials();
|
|
124
|
+
const installationId = this.installationId();
|
|
125
|
+
if (!credentials || !installationId)
|
|
126
|
+
return;
|
|
127
|
+
const held = this.held?.for === this.holder() ? this.held : null;
|
|
128
|
+
const good = held !== null && held.expiresAt > this.now();
|
|
129
|
+
if (good && held.expiresAt - this.now() > RENEW_AHEAD_MS)
|
|
130
|
+
return;
|
|
131
|
+
if (!opts.asked && this.failed && this.now() < this.failed.until)
|
|
132
|
+
return;
|
|
133
|
+
this.renewing ??= this.renew(credentials, installationId).finally(() => {
|
|
134
|
+
this.renewing = null;
|
|
135
|
+
});
|
|
136
|
+
if (good && !opts.asked) {
|
|
137
|
+
// Not waited on, so not thrown to anyone: the renewal has logged it.
|
|
138
|
+
this.renewing.catch(() => undefined);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
await this.renewing;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The repositories the deployment may be pointed at: those the
|
|
145
|
+
* installation reaches AND the person who connected it could push to.
|
|
146
|
+
* Asked of GitHub each time, so a repository taken out of the
|
|
147
|
+
* installation since is not offered.
|
|
148
|
+
*/
|
|
149
|
+
async repositories() {
|
|
150
|
+
await this.prepare({ asked: true });
|
|
151
|
+
const token = this.token();
|
|
152
|
+
if (!token)
|
|
153
|
+
return { repositories: [], more: false };
|
|
154
|
+
const reached = await this.client.repositories(token);
|
|
155
|
+
return { repositories: reached.repositories.filter((r) => this.permits(r.fullName)), more: reached.more };
|
|
156
|
+
}
|
|
157
|
+
/** Drop the token in hand: the installation it was for is no longer the deployment's. */
|
|
158
|
+
forget() {
|
|
159
|
+
this.held = null;
|
|
160
|
+
this.failed = null;
|
|
161
|
+
}
|
|
162
|
+
async renew(credentials, installationId) {
|
|
163
|
+
const holder = this.holder();
|
|
164
|
+
try {
|
|
165
|
+
const issued = await this.client.installationToken(credentials, installationId);
|
|
166
|
+
this.held = { for: holder, token: issued.token, expiresAt: issued.expiresAt };
|
|
167
|
+
this.failed = null;
|
|
168
|
+
}
|
|
169
|
+
catch (err) {
|
|
170
|
+
const times = (this.failed?.times ?? 0) + 1;
|
|
171
|
+
const wait = Math.min(FIRST_WAIT_MS * 2 ** (times - 1), LONGEST_WAIT_MS);
|
|
172
|
+
this.failed = { times, until: this.now() + wait };
|
|
173
|
+
// Once per failure, and a failure is once per wait.
|
|
174
|
+
this.log().error(`GitHub gave no token for the installation; not asked again for ${Math.round(wait / 1000)} s:`, {
|
|
175
|
+
detail: err instanceof Error ? err.message : String(err),
|
|
176
|
+
failuresInARow: times,
|
|
177
|
+
});
|
|
178
|
+
throw err;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
holder() {
|
|
182
|
+
return `${this.opts.read('githubAppId')}:${this.installationId()}`;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=github-app.connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-app.connection.js","sourceRoot":"","sources":["../../../src/modules/github-app/github-app.connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,OAAO,EACL,eAAe,GAGhB,MAAM,wBAAwB,CAAC;AAEhC,uGAAuG;AACvG,MAAM,cAAc,GAAG,EAAE,GAAG,MAAM,CAAC;AACnC,wFAAwF;AACxF,MAAM,aAAa,GAAG,KAAK,CAAC;AAC5B,MAAM,eAAe,GAAG,CAAC,GAAG,MAAM,CAAC;AAEnC,+FAA+F;AAC/F,MAAM,UAAU,qBAAqB,CAAC,KAAe;IACnD,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACnF,CAAC;AAWD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,mBAAmB;IAWD;IAVZ,MAAM,CAAkB;IACxB,GAAG,CAAe;IAClB,GAAG,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAClD,kGAAkG;IAC1F,IAAI,GAA6D,IAAI,CAAC;IAC9E,8EAA8E;IACtE,QAAQ,GAAyB,IAAI,CAAC;IAC9C,iGAAiG;IACzF,MAAM,GAA4C,IAAI,CAAC;IAE/D,YAA6B,IAAgC;QAAhC,SAAI,GAAJ,IAAI,CAA4B;QAC3D,IAAI,CAA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AAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;gBACxD,cAAc,EAAE,KAAK;aACtB,CAAC,CAAC;YACH,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;IAEO,MAAM;QACZ,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;IACrE,CAAC;CACF"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import type { IAdminAccessService } from '../admin/admin.interface.js';
|
|
3
|
+
import type { DeploymentSettingsService } from '../settings/deployment-settings.service.js';
|
|
4
|
+
import { GitHubAppClient } from './github-app.client.js';
|
|
5
|
+
import { type GitHubAppConnection } from './github-app.connection.js';
|
|
6
|
+
import '../auth/auth.middleware.js';
|
|
7
|
+
export interface GitHubAppRoutesDeps {
|
|
8
|
+
settings: Pick<DeploymentSettingsService, 'resolve' | 'record'>;
|
|
9
|
+
connection: GitHubAppConnection;
|
|
10
|
+
adminAccess: IAdminAccessService;
|
|
11
|
+
/** Where GitHub sends the browser back to: this deployment's own address. */
|
|
12
|
+
publicBackendUrl: string;
|
|
13
|
+
publicFrontendUrl: string;
|
|
14
|
+
/** Whether the deployment is set up: decides which page a round trip ends on. */
|
|
15
|
+
isComplete(): boolean;
|
|
16
|
+
client?: GitHubAppClient;
|
|
17
|
+
}
|
|
18
|
+
/** The address GitHub is told to send the browser back to once the app is installed. */
|
|
19
|
+
export declare function githubAppCallbackUrl(publicBackendUrl: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* The manifest a deployment's own GitHub App is created from. It asks for
|
|
22
|
+
* what the deployment does and nothing else: read and write the contents of
|
|
23
|
+
* the repositories it is installed on. No webhook, no events, not public:
|
|
24
|
+
* the app is this deployment's, installed by its owner on the one
|
|
25
|
+
* repository the knowledge base lives in.
|
|
26
|
+
*/
|
|
27
|
+
export declare function githubAppManifest(publicBackendUrl: string, publicFrontendUrl: string): Record<string, unknown>;
|
|
28
|
+
/**
|
|
29
|
+
* Connecting a repository on GitHub through a GitHub App, from the setup
|
|
30
|
+
* screen. Mounted behind the deployment's sign-in; every route is an
|
|
31
|
+
* admin's.
|
|
32
|
+
*
|
|
33
|
+
* GET /setup/github-app where the connection stands
|
|
34
|
+
* POST /setup/github-app/manifest start registering this deployment's own app
|
|
35
|
+
* GET /setup/github-app/registered GitHub sends the browser back: the app exists
|
|
36
|
+
* POST /setup/github-app/install where on GitHub the app is installed
|
|
37
|
+
* POST /setup/github-app/refresh where to sign in, to read again what may be connected
|
|
38
|
+
* GET /setup/github-app/callback GitHub sends the browser back: the app is installed
|
|
39
|
+
* GET /setup/github-app/repositories what the deployment may be pointed at
|
|
40
|
+
*
|
|
41
|
+
* A ROUND TRIP IS STARTED BY A POST AND ENDED BY A GET. The two routes
|
|
42
|
+
* GitHub sends the browser to are ordinary navigations, authenticated by
|
|
43
|
+
* the session cookie; each checks a state this browser was given when the
|
|
44
|
+
* round trip started, and spends it. Nothing that starts one is a link, so
|
|
45
|
+
* a link somebody was sent starts nothing.
|
|
46
|
+
*
|
|
47
|
+
* WHAT THE DEPLOYMENT MAY REACH is never taken from the address the browser
|
|
48
|
+
* came back on. GitHub puts an installation's number there and anyone can
|
|
49
|
+
* write another: with one app serving many deployments, that number is the
|
|
50
|
+
* only thing between a deployment and another organisation's repositories.
|
|
51
|
+
* GitHub sends the person back signed in, and the deployment asks GitHub
|
|
52
|
+
* two things about THAT PERSON: which installations they reach, and which
|
|
53
|
+
* repositories of the one they named they can push to with their own
|
|
54
|
+
* account. The first alone is not enough, since read access to one
|
|
55
|
+
* repository puts an installation on that list. Only the second is what
|
|
56
|
+
* the deployment may be pointed at.
|
|
57
|
+
*/
|
|
58
|
+
export declare function createGitHubAppRoutes(deps: GitHubAppRoutesDeps): express.Router;
|
|
59
|
+
//# sourceMappingURL=github-app.routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-app.routes.d.ts","sourceRoot":"","sources":["../../../src/modules/github-app/github-app.routes.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAEvE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAkB,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAyB,KAAK,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAC7F,OAAO,4BAA4B,CAAC;AAWpC,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,IAAI,CAAC,yBAAyB,EAAE,SAAS,GAAG,QAAQ,CAAC,CAAC;IAChE,UAAU,EAAE,mBAAmB,CAAC;IAChC,WAAW,EAAE,mBAAmB,CAAC;IACjC,6EAA6E;IAC7E,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iFAAiF;IACjF,UAAU,IAAI,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B;AAED,wFAAwF;AACxF,wBAAgB,oBAAoB,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAErE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAe9G;AAqBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CA0P/E"}
|