@bevel-software/platform-core-backend 0.22.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/core-ports.d.ts +11 -1
- package/dist/core/core-ports.d.ts.map +1 -1
- package/dist/core/core-ports.js.map +1 -1
- package/dist/core/create-core-server.d.ts +3 -3
- package/dist/core/create-core-server.d.ts.map +1 -1
- package/dist/core/create-core-server.js +46 -13
- package/dist/core/create-core-server.js.map +1 -1
- package/dist/core/create-core-services.d.ts +12 -2
- package/dist/core/create-core-services.d.ts.map +1 -1
- package/dist/core/create-core-services.js +137 -24
- package/dist/core/create-core-services.js.map +1 -1
- package/dist/core/lifecycle.d.ts +46 -1
- package/dist/core/lifecycle.d.ts.map +1 -1
- package/dist/core/lifecycle.js +99 -13
- package/dist/core/lifecycle.js.map +1 -1
- package/dist/core-config.d.ts +16 -12
- package/dist/core-config.d.ts.map +1 -1
- package/dist/core-config.js +28 -13
- package/dist/core-config.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/modules/access/access-control.interface.d.ts +42 -12
- package/dist/modules/access/access-control.interface.d.ts.map +1 -1
- package/dist/modules/access/access-control.service.d.ts +67 -10
- package/dist/modules/access/access-control.service.d.ts.map +1 -1
- package/dist/modules/access/access-control.service.js +214 -35
- package/dist/modules/access/access-control.service.js.map +1 -1
- package/dist/modules/access/access.routes.d.ts.map +1 -1
- package/dist/modules/access/access.routes.js +17 -16
- package/dist/modules/access/access.routes.js.map +1 -1
- package/dist/modules/access/directory-sync-bot.d.ts.map +1 -1
- package/dist/modules/access/directory-sync-bot.js +7 -3
- package/dist/modules/access/directory-sync-bot.js.map +1 -1
- package/dist/modules/agent-instructions/agent-instructions.routes.d.ts +8 -1
- package/dist/modules/agent-instructions/agent-instructions.routes.d.ts.map +1 -1
- package/dist/modules/agent-instructions/agent-instructions.routes.js +8 -2
- package/dist/modules/agent-instructions/agent-instructions.routes.js.map +1 -1
- package/dist/modules/agent-instructions/compose.d.ts +38 -6
- package/dist/modules/agent-instructions/compose.d.ts.map +1 -1
- package/dist/modules/agent-instructions/compose.js +39 -6
- package/dist/modules/agent-instructions/compose.js.map +1 -1
- package/dist/modules/agent-instructions/index.d.ts +2 -1
- package/dist/modules/agent-instructions/index.d.ts.map +1 -1
- package/dist/modules/agent-instructions/index.js +2 -1
- package/dist/modules/agent-instructions/index.js.map +1 -1
- package/dist/modules/agent-instructions/shared-file-rules.d.ts +115 -0
- package/dist/modules/agent-instructions/shared-file-rules.d.ts.map +1 -0
- package/dist/modules/agent-instructions/shared-file-rules.js +272 -0
- package/dist/modules/agent-instructions/shared-file-rules.js.map +1 -0
- package/dist/modules/audit/agent-audit.service.d.ts.map +1 -1
- package/dist/modules/audit/agent-audit.service.js +4 -2
- package/dist/modules/audit/agent-audit.service.js.map +1 -1
- package/dist/modules/auth/account-admission.d.ts +58 -7
- package/dist/modules/auth/account-admission.d.ts.map +1 -1
- package/dist/modules/auth/account-admission.js +44 -1
- package/dist/modules/auth/account-admission.js.map +1 -1
- package/dist/modules/auth/account-erasure.service.d.ts.map +1 -1
- package/dist/modules/auth/account-erasure.service.js +57 -16
- package/dist/modules/auth/account-erasure.service.js.map +1 -1
- package/dist/modules/auth/account.routes.d.ts +1 -1
- package/dist/modules/auth/account.routes.d.ts.map +1 -1
- package/dist/modules/auth/account.routes.js +61 -5
- package/dist/modules/auth/account.routes.js.map +1 -1
- package/dist/modules/auth/auth.middleware.d.ts +1 -1
- package/dist/modules/auth/auth.middleware.d.ts.map +1 -1
- package/dist/modules/auth/auth.middleware.js +18 -7
- package/dist/modules/auth/auth.middleware.js.map +1 -1
- package/dist/modules/auth/auth.routes.d.ts.map +1 -1
- package/dist/modules/auth/auth.routes.js +8 -0
- package/dist/modules/auth/auth.routes.js.map +1 -1
- package/dist/modules/auth/auth.service.d.ts +70 -2
- package/dist/modules/auth/auth.service.d.ts.map +1 -1
- package/dist/modules/auth/auth.service.js +197 -18
- package/dist/modules/auth/auth.service.js.map +1 -1
- package/dist/modules/auth/oidc-auth-provider.d.ts.map +1 -1
- package/dist/modules/auth/oidc-auth-provider.js +7 -2
- package/dist/modules/auth/oidc-auth-provider.js.map +1 -1
- package/dist/modules/code-mode/code-mode.tool.d.ts +20 -2
- package/dist/modules/code-mode/code-mode.tool.d.ts.map +1 -1
- package/dist/modules/code-mode/code-mode.tool.js +66 -35
- package/dist/modules/code-mode/code-mode.tool.js.map +1 -1
- package/dist/modules/database/connection.d.ts +16 -0
- package/dist/modules/database/connection.d.ts.map +1 -1
- package/dist/modules/database/connection.js +117 -0
- package/dist/modules/database/connection.js.map +1 -1
- package/dist/modules/database/core-schema.d.ts +337 -120
- package/dist/modules/database/core-schema.d.ts.map +1 -1
- package/dist/modules/database/core-schema.js +116 -58
- package/dist/modules/database/core-schema.js.map +1 -1
- package/dist/modules/database/migrate.d.ts +8 -0
- package/dist/modules/database/migrate.d.ts.map +1 -1
- package/dist/modules/database/migrate.js +271 -1
- package/dist/modules/database/migrate.js.map +1 -1
- package/dist/modules/kb-fs/branch-name.d.ts.map +1 -1
- package/dist/modules/kb-fs/branch-name.js +12 -2
- package/dist/modules/kb-fs/branch-name.js.map +1 -1
- package/dist/modules/kb-fs/repo-path.d.ts +11 -16
- package/dist/modules/kb-fs/repo-path.d.ts.map +1 -1
- package/dist/modules/kb-fs/repo-path.js +79 -0
- package/dist/modules/kb-fs/repo-path.js.map +1 -1
- package/dist/modules/kb-sync/kb-sync.routes.d.ts +2 -2
- package/dist/modules/kb-sync/kb-sync.routes.d.ts.map +1 -1
- package/dist/modules/kb-sync/kb-sync.routes.js +14 -3
- package/dist/modules/kb-sync/kb-sync.routes.js.map +1 -1
- package/dist/modules/kb-sync/sync-auth.d.ts +3 -1
- package/dist/modules/kb-sync/sync-auth.d.ts.map +1 -1
- package/dist/modules/kb-sync/sync-auth.js +1 -1
- package/dist/modules/kb-sync/sync-auth.js.map +1 -1
- package/dist/modules/mcp/mcp-auth.middleware.d.ts.map +1 -1
- package/dist/modules/mcp/mcp-auth.middleware.js +21 -6
- package/dist/modules/mcp/mcp-auth.middleware.js.map +1 -1
- package/dist/modules/mcp/mcp.service.d.ts +8 -0
- package/dist/modules/mcp/mcp.service.d.ts.map +1 -1
- package/dist/modules/mcp/mcp.service.js +38 -8
- package/dist/modules/mcp/mcp.service.js.map +1 -1
- package/dist/modules/mcp/oauth/bevel-oauth-provider.d.ts.map +1 -1
- package/dist/modules/mcp/oauth/bevel-oauth-provider.js +3 -2
- package/dist/modules/mcp/oauth/bevel-oauth-provider.js.map +1 -1
- package/dist/modules/plugins/join-request-records.store.d.ts.map +1 -1
- package/dist/modules/plugins/join-request-records.store.js +7 -4
- package/dist/modules/plugins/join-request-records.store.js.map +1 -1
- package/dist/modules/settings/deployment-settings.service.d.ts.map +1 -1
- package/dist/modules/settings/deployment-settings.service.js +8 -3
- package/dist/modules/settings/deployment-settings.service.js.map +1 -1
- package/dist/modules/settings/setup.routes.d.ts +52 -1
- package/dist/modules/settings/setup.routes.d.ts.map +1 -1
- package/dist/modules/settings/setup.routes.js +207 -19
- package/dist/modules/settings/setup.routes.js.map +1 -1
- package/dist/modules/skills/skills.contract.d.ts +90 -18
- package/dist/modules/skills/skills.contract.d.ts.map +1 -1
- package/dist/modules/skills/skills.contract.js +4 -1
- package/dist/modules/skills/skills.contract.js.map +1 -1
- package/dist/modules/skills/skills.service.d.ts +98 -9
- package/dist/modules/skills/skills.service.d.ts.map +1 -1
- package/dist/modules/skills/skills.service.js +239 -37
- package/dist/modules/skills/skills.service.js.map +1 -1
- package/dist/modules/skills/skills.tools.d.ts +7 -0
- package/dist/modules/skills/skills.tools.d.ts.map +1 -1
- package/dist/modules/skills/skills.tools.js +71 -7
- package/dist/modules/skills/skills.tools.js.map +1 -1
- package/dist/modules/tool-auth/external-api-key.service.d.ts.map +1 -1
- package/dist/modules/tool-auth/external-api-key.service.js +12 -4
- package/dist/modules/tool-auth/external-api-key.service.js.map +1 -1
- package/dist/modules/tool-auth/internal-token.service.d.ts +3 -3
- package/dist/modules/tool-auth/tool-auth.middleware.d.ts +16 -7
- package/dist/modules/tool-auth/tool-auth.middleware.d.ts.map +1 -1
- package/dist/modules/tool-auth/tool-auth.middleware.js +34 -12
- package/dist/modules/tool-auth/tool-auth.middleware.js.map +1 -1
- package/dist/modules/tool-helpers/tool-handler.d.ts +2 -1
- package/dist/modules/tool-helpers/tool-handler.d.ts.map +1 -1
- package/dist/modules/tool-helpers/tool-handler.js +25 -4
- package/dist/modules/tool-helpers/tool-handler.js.map +1 -1
- package/dist/modules/tool-helpers/tool.contract.d.ts +3 -2
- package/dist/modules/tool-helpers/tool.contract.d.ts.map +1 -1
- package/dist/modules/tool-helpers/tool.contract.js.map +1 -1
- package/dist/modules/tool-helpers/validate-token.js +1 -1
- package/dist/modules/tool-helpers/validate-token.js.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.tools.d.ts.map +1 -1
- package/dist/modules/tool-manuals/tool-manuals.tools.js +42 -31
- package/dist/modules/tool-manuals/tool-manuals.tools.js.map +1 -1
- package/dist/modules/tool-registry/description-length.d.ts +80 -0
- package/dist/modules/tool-registry/description-length.d.ts.map +1 -0
- package/dist/modules/tool-registry/description-length.js +108 -0
- package/dist/modules/tool-registry/description-length.js.map +1 -0
- package/dist/modules/workflow/agent-tools/change-request-summary.d.ts +98 -0
- package/dist/modules/workflow/agent-tools/change-request-summary.d.ts.map +1 -0
- package/dist/modules/workflow/agent-tools/change-request-summary.js +81 -0
- package/dist/modules/workflow/agent-tools/change-request-summary.js.map +1 -0
- package/dist/modules/workflow/agent-tools/workflow.tools.d.ts.map +1 -1
- package/dist/modules/workflow/agent-tools/workflow.tools.js +75 -35
- package/dist/modules/workflow/agent-tools/workflow.tools.js.map +1 -1
- package/dist/modules/workflow/file-lock.service.d.ts +24 -0
- package/dist/modules/workflow/file-lock.service.d.ts.map +1 -1
- package/dist/modules/workflow/file-lock.service.js +30 -0
- package/dist/modules/workflow/file-lock.service.js.map +1 -1
- package/dist/modules/workflow/git/git.service.d.ts +94 -0
- package/dist/modules/workflow/git/git.service.d.ts.map +1 -1
- package/dist/modules/workflow/git/git.service.js +193 -3
- package/dist/modules/workflow/git/git.service.js.map +1 -1
- package/dist/modules/workflow/pending-commits.service.d.ts +38 -0
- package/dist/modules/workflow/pending-commits.service.d.ts.map +1 -1
- package/dist/modules/workflow/pending-commits.service.js +60 -1
- package/dist/modules/workflow/pending-commits.service.js.map +1 -1
- package/dist/modules/workflow/recovery-bot.d.ts.map +1 -1
- package/dist/modules/workflow/recovery-bot.js +7 -3
- package/dist/modules/workflow/recovery-bot.js.map +1 -1
- package/dist/modules/workflow/review-workflow/review-workflow.service.d.ts.map +1 -1
- package/dist/modules/workflow/review-workflow/review-workflow.service.js +12 -3
- package/dist/modules/workflow/review-workflow/review-workflow.service.js.map +1 -1
- package/dist/modules/workflow/workflow-hooks.d.ts +54 -32
- package/dist/modules/workflow/workflow-hooks.d.ts.map +1 -1
- package/dist/modules/workflow/workflow-hooks.js +16 -1
- package/dist/modules/workflow/workflow-hooks.js.map +1 -1
- package/dist/modules/workflow/workflow.service.d.ts +60 -6
- package/dist/modules/workflow/workflow.service.d.ts.map +1 -1
- package/dist/modules/workflow/workflow.service.js +115 -5
- package/dist/modules/workflow/workflow.service.js.map +1 -1
- package/dist/modules/workspace/agent-access.gate.d.ts +94 -0
- package/dist/modules/workspace/agent-access.gate.d.ts.map +1 -0
- package/dist/modules/workspace/agent-access.gate.js +123 -0
- package/dist/modules/workspace/agent-access.gate.js.map +1 -0
- package/dist/modules/workspace/agent-upload.routes.d.ts +77 -0
- package/dist/modules/workspace/agent-upload.routes.d.ts.map +1 -0
- package/dist/modules/workspace/agent-upload.routes.js +210 -0
- package/dist/modules/workspace/agent-upload.routes.js.map +1 -0
- package/dist/modules/workspace/agent-upload.store.d.ts +284 -0
- package/dist/modules/workspace/agent-upload.store.d.ts.map +1 -0
- package/dist/modules/workspace/agent-upload.store.js +553 -0
- package/dist/modules/workspace/agent-upload.store.js.map +1 -0
- package/dist/modules/workspace/routine-write-policy.d.ts +5 -6
- package/dist/modules/workspace/routine-write-policy.d.ts.map +1 -1
- package/dist/modules/workspace/routine-write-policy.js +5 -6
- package/dist/modules/workspace/routine-write-policy.js.map +1 -1
- package/dist/modules/workspace/session-sink.d.ts +5 -5
- package/dist/modules/workspace/set-aside-clone.d.ts +46 -0
- package/dist/modules/workspace/set-aside-clone.d.ts.map +1 -0
- package/dist/modules/workspace/set-aside-clone.js +92 -0
- package/dist/modules/workspace/set-aside-clone.js.map +1 -0
- package/dist/modules/workspace/startup/kb-startup-runner.d.ts +59 -9
- package/dist/modules/workspace/startup/kb-startup-runner.d.ts.map +1 -1
- package/dist/modules/workspace/startup/kb-startup-runner.js +65 -24
- package/dist/modules/workspace/startup/kb-startup-runner.js.map +1 -1
- package/dist/modules/workspace/startup/steps/seed-tree.d.ts.map +1 -1
- package/dist/modules/workspace/startup/steps/seed-tree.js +3 -3
- package/dist/modules/workspace/startup/steps/seed-tree.js.map +1 -1
- package/dist/modules/workspace/startup/steps/template-source.d.ts +40 -0
- package/dist/modules/workspace/startup/steps/template-source.d.ts.map +1 -1
- package/dist/modules/workspace/startup/steps/template-source.js +46 -4
- package/dist/modules/workspace/startup/steps/template-source.js.map +1 -1
- package/dist/modules/workspace/upload-limits.d.ts +13 -0
- package/dist/modules/workspace/upload-limits.d.ts.map +1 -0
- package/dist/modules/workspace/upload-limits.js +13 -0
- package/dist/modules/workspace/upload-limits.js.map +1 -0
- package/dist/modules/workspace/workspace.routes.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.routes.js +93 -4
- package/dist/modules/workspace/workspace.routes.js.map +1 -1
- package/dist/modules/workspace/workspace.service.d.ts +128 -5
- package/dist/modules/workspace/workspace.service.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.service.js +316 -58
- package/dist/modules/workspace/workspace.service.js.map +1 -1
- package/dist/modules/workspace/workspace.tools.d.ts +13 -11
- package/dist/modules/workspace/workspace.tools.d.ts.map +1 -1
- package/dist/modules/workspace/workspace.tools.js +791 -198
- package/dist/modules/workspace/workspace.tools.js.map +1 -1
- package/dist/modules/workspace/write-denial.d.ts +0 -6
- package/dist/modules/workspace/write-denial.d.ts.map +1 -1
- package/dist/modules/workspace/write-denial.js +0 -6
- package/dist/modules/workspace/write-denial.js.map +1 -1
- package/dist/modules/workspace/zip-entry-rules.d.ts +114 -0
- package/dist/modules/workspace/zip-entry-rules.d.ts.map +1 -0
- package/dist/modules/workspace/zip-entry-rules.js +154 -0
- package/dist/modules/workspace/zip-entry-rules.js.map +1 -0
- package/dist/modules/write-access/write-access.d.ts +60 -0
- package/dist/modules/write-access/write-access.d.ts.map +1 -0
- package/dist/modules/write-access/write-access.js +129 -0
- package/dist/modules/write-access/write-access.js.map +1 -0
- package/dist/shared/column-crypto.d.ts +194 -0
- package/dist/shared/column-crypto.d.ts.map +1 -0
- package/dist/shared/column-crypto.js +144 -0
- package/dist/shared/column-crypto.js.map +1 -0
- package/dist/shared/domain-errors.d.ts +25 -0
- package/dist/shared/domain-errors.d.ts.map +1 -1
- package/dist/shared/domain-errors.js +28 -0
- package/dist/shared/domain-errors.js.map +1 -1
- package/dist/shared/git.contract.d.ts +20 -0
- package/dist/shared/git.contract.d.ts.map +1 -1
- package/dist/shared/git.contract.js +26 -0
- package/dist/shared/git.contract.js.map +1 -1
- package/dist/shared/token-crypto.d.ts.map +1 -1
- package/dist/shared/token-crypto.js +25 -1
- package/dist/shared/token-crypto.js.map +1 -1
- package/dist/tenancy/static-tenant-source.d.ts +0 -1
- package/dist/tenancy/static-tenant-source.d.ts.map +1 -1
- package/dist/tenancy/static-tenant-source.js +1 -2
- package/dist/tenancy/static-tenant-source.js.map +1 -1
- package/dist/tenancy/tenant-secrets.d.ts +5 -1
- package/dist/tenancy/tenant-secrets.d.ts.map +1 -1
- package/dist/tenancy/tenant-secrets.js +4 -0
- package/dist/tenancy/tenant-secrets.js.map +1 -1
- package/kb-template/AGENTS.md +2 -0
- package/migrations/0014_change_request_closed_reason.sql +1 -0
- package/migrations/0015_account_deactivation.sql +3 -0
- package/migrations/0016_pii_encryption.sql +20 -0
- package/migrations/meta/0014_snapshot.json +2265 -0
- package/migrations/meta/0015_snapshot.json +2271 -0
- package/migrations/meta/0016_snapshot.json +2327 -0
- package/migrations/meta/_journal.json +21 -0
- package/package.json +3 -3
- package/src/__tests__/kb-layout-config.test.ts +0 -2
- package/src/__tests__/retired-settings.test.ts +96 -0
- package/src/core/__tests__/gated-boot.test.ts +132 -0
- package/src/core/__tests__/lifecycle.test.ts +241 -5
- package/src/core/__tests__/set-aside-root-is-one-place.test.ts +63 -0
- package/src/core/core-ports.ts +11 -1
- package/src/core/create-core-server.ts +52 -16
- package/src/core/create-core-services.ts +156 -24
- package/src/core/lifecycle.ts +117 -13
- package/src/core-config.ts +31 -14
- package/src/index.ts +30 -1
- package/src/modules/access/__tests__/access-control.preview-relocation.test.ts +385 -0
- package/src/modules/access/__tests__/access-control.prospective.test.ts +94 -18
- package/src/modules/access/__tests__/access.routes.prospective.test.ts +6 -7
- package/src/modules/access/__tests__/users-db-double.ts +21 -12
- package/src/modules/access/access-control.interface.ts +43 -12
- package/src/modules/access/access-control.service.ts +234 -36
- package/src/modules/access/access.routes.ts +17 -16
- package/src/modules/access/directory-sync-bot.ts +7 -3
- package/src/modules/agent-instructions/__tests__/agent-instructions.route.test.ts +11 -5
- package/src/modules/agent-instructions/__tests__/compose.test.ts +19 -10
- package/src/modules/agent-instructions/__tests__/shared-file-rules.test.ts +238 -0
- package/src/modules/agent-instructions/agent-instructions.routes.ts +12 -2
- package/src/modules/agent-instructions/compose.ts +50 -7
- package/src/modules/agent-instructions/index.ts +12 -0
- package/src/modules/agent-instructions/shared-file-rules.ts +314 -0
- package/src/modules/audit/agent-audit.service.ts +4 -2
- package/src/modules/auth/__tests__/account-deactivation.test.ts +253 -0
- package/src/modules/auth/__tests__/account-erasure.approval-gate.test.ts +6 -2
- package/src/modules/auth/__tests__/account.routes.test.ts +87 -6
- package/src/modules/auth/__tests__/auth.middleware.test.ts +45 -22
- package/src/modules/auth/__tests__/auth.service.test.ts +4 -2
- package/src/modules/auth/account-admission.ts +78 -9
- package/src/modules/auth/account-erasure.service.ts +69 -18
- package/src/modules/auth/account.routes.ts +63 -7
- package/src/modules/auth/auth.middleware.ts +19 -8
- package/src/modules/auth/auth.routes.ts +8 -0
- package/src/modules/auth/auth.service.ts +206 -23
- package/src/modules/auth/oidc-auth-provider.ts +7 -2
- package/src/modules/code-mode/__tests__/chain-runtime.e2e.test.ts +335 -0
- package/src/modules/code-mode/__tests__/code-mode.tool.test.ts +46 -2
- package/src/modules/code-mode/code-mode.tool.ts +80 -34
- package/src/modules/database/__tests__/connection.test.ts +12 -0
- package/src/modules/database/__tests__/pii-backfill.pg.test.ts +561 -0
- package/src/modules/database/connection.ts +117 -0
- package/src/modules/database/core-schema.ts +116 -58
- package/src/modules/database/migrate.ts +353 -1
- package/src/modules/kb-fs/__tests__/branch-name.test.ts +10 -0
- package/src/modules/kb-fs/__tests__/repo-path.test.ts +123 -0
- package/src/modules/kb-fs/branch-name.ts +14 -1
- package/src/modules/kb-fs/repo-path.ts +85 -0
- package/src/modules/kb-sync/__tests__/kb-sync.routes.test.ts +26 -1
- package/src/modules/kb-sync/kb-sync.routes.ts +14 -4
- package/src/modules/kb-sync/sync-auth.ts +2 -2
- package/src/modules/mcp/__tests__/mcp-auth.middleware.test.ts +60 -3
- package/src/modules/mcp/__tests__/mcp.e2e.test.ts +4 -3
- package/src/modules/mcp/__tests__/mcp.service.test.ts +115 -13
- package/src/modules/mcp/mcp-auth.middleware.ts +20 -6
- package/src/modules/mcp/mcp.service.ts +46 -7
- package/src/modules/mcp/oauth/bevel-oauth-provider.ts +3 -1
- package/src/modules/plugins/__tests__/plugins.tools.test.ts +2 -1
- package/src/modules/plugins/join-request-records.store.ts +7 -4
- package/src/modules/settings/__tests__/deployment-settings.service.test.ts +16 -0
- package/src/modules/settings/__tests__/setup.routes.git-mode.test.ts +91 -58
- package/src/modules/settings/__tests__/setup.routes.github-app.test.ts +25 -8
- package/src/modules/settings/__tests__/setup.routes.managed-phase.test.ts +14 -11
- package/src/modules/settings/__tests__/setup.routes.repository-change.test.ts +390 -0
- package/src/modules/settings/__tests__/setup.routes.test.ts +3 -0
- package/src/modules/settings/deployment-settings.service.ts +8 -3
- package/src/modules/settings/setup.routes.ts +263 -19
- package/src/modules/skills/__tests__/allowed-tools-warn.tools.test.ts +2 -1
- package/src/modules/skills/__tests__/branch-skills.tools.test.ts +218 -0
- package/src/modules/skills/__tests__/skills.service.test.ts +229 -5
- package/src/modules/skills/skills.contract.ts +91 -18
- package/src/modules/skills/skills.service.ts +278 -41
- package/src/modules/skills/skills.tools.ts +80 -8
- package/src/modules/tool-auth/__tests__/manual-auth.middleware.test.ts +14 -1
- package/src/modules/tool-auth/external-api-key.service.ts +12 -4
- package/src/modules/tool-auth/internal-token.service.ts +3 -3
- package/src/modules/tool-auth/tool-auth.middleware.ts +34 -11
- package/src/modules/tool-helpers/__tests__/agent-roles-write.test.ts +5 -3
- package/src/modules/tool-helpers/__tests__/phase4-tools.test.ts +3 -3
- package/src/modules/tool-helpers/__tests__/validate-token.test.ts +11 -1
- package/src/modules/tool-helpers/tool-handler.ts +24 -4
- package/src/modules/tool-helpers/tool.contract.ts +3 -2
- package/src/modules/tool-helpers/validate-token.ts +1 -1
- package/src/modules/tool-manuals/tool-manuals.tools.ts +44 -31
- package/src/modules/tool-registry/__tests__/tool-description-length.test.ts +378 -0
- package/src/modules/tool-registry/description-length.ts +111 -0
- package/src/modules/workflow/__tests__/pending-commits.repository-replaced.test.ts +111 -0
- package/src/modules/workflow/__tests__/workflow.routes.history-read-gate.test.ts +25 -0
- package/src/modules/workflow/__tests__/workflow.service.repository-replaced.test.ts +249 -0
- package/src/modules/workflow/agent-tools/__tests__/workflow.tools.test.ts +264 -6
- package/src/modules/workflow/agent-tools/change-request-summary.ts +182 -0
- package/src/modules/workflow/agent-tools/workflow.tools.ts +86 -35
- package/src/modules/workflow/file-lock.service.ts +31 -0
- package/src/modules/workflow/git/__tests__/git.service.fileBytesAtCommit.test.ts +260 -0
- package/src/modules/workflow/git/__tests__/git.service.prFetchFailure.test.ts +170 -0
- package/src/modules/workflow/git/git.service.ts +215 -1
- package/src/modules/workflow/pending-commits.service.ts +64 -2
- package/src/modules/workflow/recovery-bot.ts +7 -3
- package/src/modules/workflow/review-workflow/__tests__/carry-approvals-forward.test.ts +4 -0
- package/src/modules/workflow/review-workflow/__tests__/erase-approver.test.ts +25 -3
- package/src/modules/workflow/review-workflow/review-workflow.service.ts +12 -3
- package/src/modules/workflow/workflow-hooks.ts +64 -26
- package/src/modules/workflow/workflow.service.ts +125 -5
- package/src/modules/workspace/__tests__/agent-access.gate.test.ts +208 -0
- package/src/modules/workspace/__tests__/agent-uploads.test.ts +1604 -0
- package/src/modules/workspace/__tests__/escape-sequences.routes.test.ts +394 -0
- package/src/modules/workspace/__tests__/file-stat-access.test.ts +2 -1
- package/src/modules/workspace/__tests__/git-internals.security.test.ts +2 -1
- package/src/modules/workspace/__tests__/set-aside-clone.test.ts +52 -0
- package/src/modules/workspace/__tests__/workspace.routes.at-ref.test.ts +305 -0
- package/src/modules/workspace/__tests__/workspace.routes.download.test.ts +2 -0
- package/src/modules/workspace/__tests__/workspace.service.any-workspace-credentials.test.ts +156 -0
- package/src/modules/workspace/__tests__/workspace.service.forget-clone-races.test.ts +147 -0
- package/src/modules/workspace/__tests__/workspace.service.replaced-repository.test.ts +402 -0
- package/src/modules/workspace/__tests__/workspace.service.test.ts +77 -9
- package/src/modules/workspace/__tests__/workspace.tools.agents-file.test.ts +41 -39
- package/src/modules/workspace/__tests__/workspace.tools.branch-errors.test.ts +2 -3
- package/src/modules/workspace/__tests__/workspace.tools.test.ts +766 -56
- package/src/modules/workspace/agent-access.gate.ts +164 -0
- package/src/modules/workspace/agent-upload.routes.ts +214 -0
- package/src/modules/workspace/agent-upload.store.ts +668 -0
- package/src/modules/workspace/routine-write-policy.ts +5 -6
- package/src/modules/workspace/session-sink.ts +5 -5
- package/src/modules/workspace/set-aside-clone.ts +96 -0
- package/src/modules/workspace/startup/__tests__/kb-startup-runner.test.ts +86 -0
- package/src/modules/workspace/startup/kb-startup-runner.ts +115 -34
- package/src/modules/workspace/startup/steps/__tests__/steps.test.ts +9 -9
- package/src/modules/workspace/startup/steps/seed-tree.ts +3 -6
- package/src/modules/workspace/startup/steps/template-source.ts +53 -5
- package/src/modules/workspace/upload-limits.ts +12 -0
- package/src/modules/workspace/workspace.routes.ts +96 -5
- package/src/modules/workspace/workspace.service.ts +319 -61
- package/src/modules/workspace/workspace.tools.ts +894 -214
- package/src/modules/workspace/write-denial.ts +0 -8
- package/src/modules/workspace/zip-entry-rules.ts +173 -0
- package/src/modules/write-access/__tests__/write-access.test.ts +248 -0
- package/src/modules/write-access/write-access.ts +153 -0
- package/src/shared/__tests__/column-crypto.test.ts +217 -0
- package/src/shared/column-crypto.ts +218 -0
- package/src/shared/domain-errors.ts +31 -0
- package/src/shared/git.contract.ts +27 -0
- package/src/shared/token-crypto.ts +28 -1
- package/src/tenancy/__tests__/static-tenant-source.test.ts +4 -1
- package/src/tenancy/static-tenant-source.ts +1 -3
- package/src/tenancy/tenant-secrets.ts +5 -1
- package/dist/modules/workflow/session-ontology.policy.d.ts +0 -52
- package/dist/modules/workflow/session-ontology.policy.d.ts.map +0 -1
- package/dist/modules/workflow/session-ontology.policy.js +0 -62
- package/dist/modules/workflow/session-ontology.policy.js.map +0 -1
- package/dist/modules/workflow/session-ontology.service.d.ts +0 -105
- package/dist/modules/workflow/session-ontology.service.d.ts.map +0 -1
- package/dist/modules/workflow/session-ontology.service.js +0 -147
- package/dist/modules/workflow/session-ontology.service.js.map +0 -1
- package/dist/modules/workspace/session-ontology.gate.d.ts +0 -114
- package/dist/modules/workspace/session-ontology.gate.d.ts.map +0 -1
- package/dist/modules/workspace/session-ontology.gate.js +0 -161
- package/dist/modules/workspace/session-ontology.gate.js.map +0 -1
- package/dist/shared/kb-layout.d.ts +0 -39
- package/dist/shared/kb-layout.d.ts.map +0 -1
- package/dist/shared/kb-layout.js +0 -103
- package/dist/shared/kb-layout.js.map +0 -1
- package/dist/shared/kb-layout.test.d.ts +0 -2
- package/dist/shared/kb-layout.test.d.ts.map +0 -1
- package/dist/shared/kb-layout.test.js +0 -75
- package/dist/shared/kb-layout.test.js.map +0 -1
- package/src/modules/workflow/__tests__/session-ontology.policy.test.ts +0 -62
- package/src/modules/workflow/__tests__/session-ontology.service.test.ts +0 -201
- package/src/modules/workflow/session-ontology.policy.ts +0 -70
- package/src/modules/workflow/session-ontology.service.ts +0 -183
- package/src/modules/workspace/__tests__/session-ontology.gate.test.ts +0 -239
- package/src/modules/workspace/session-ontology.gate.ts +0 -191
- package/src/shared/kb-layout.test.ts +0 -98
- package/src/shared/kb-layout.ts +0 -102
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import express, { type RequestHandler } from 'express';
|
|
2
|
+
import type { KbLayout } from '@bevel-software/platform-shared';
|
|
2
3
|
import type { AgentPreambleReader } from './read-preamble.js';
|
|
3
4
|
/**
|
|
4
5
|
* The agent-facing instructions route, mounted on the tools router beside
|
|
@@ -17,5 +18,11 @@ import type { AgentPreambleReader } from './read-preamble.js';
|
|
|
17
18
|
* name folders the caller cannot open. A reader throw is a 500, never an
|
|
18
19
|
* empty preamble, so the caller's own fallback decides what to send.
|
|
19
20
|
*/
|
|
20
|
-
export declare function createAgentInstructionsRoutes(manualAuth: RequestHandler, readPreamble: AgentPreambleReader
|
|
21
|
+
export declare function createAgentInstructionsRoutes(manualAuth: RequestHandler, readPreamble: AgentPreambleReader,
|
|
22
|
+
/**
|
|
23
|
+
* The layout in effect, read per request — the shared file rules name the
|
|
24
|
+
* managed guide, whose name the setup save may change without a restart.
|
|
25
|
+
* Optional so a construction with no layout in hand gets `AGENTS.md`.
|
|
26
|
+
*/
|
|
27
|
+
kbLayout?: () => KbLayout): express.Router;
|
|
21
28
|
//# sourceMappingURL=agent-instructions.routes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-instructions.routes.d.ts","sourceRoot":"","sources":["../../../src/modules/agent-instructions/agent-instructions.routes.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-instructions.routes.d.ts","sourceRoot":"","sources":["../../../src/modules/agent-instructions/agent-instructions.routes.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAKhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,cAAc,EAC1B,YAAY,EAAE,mBAAmB;AACjC;;;;GAIG;AACH,QAAQ,CAAC,EAAE,MAAM,QAAQ,GACxB,OAAO,CAAC,MAAM,CAgBhB"}
|
|
@@ -19,14 +19,20 @@ import { composeAgentInstructions } from './compose.js';
|
|
|
19
19
|
* name folders the caller cannot open. A reader throw is a 500, never an
|
|
20
20
|
* empty preamble, so the caller's own fallback decides what to send.
|
|
21
21
|
*/
|
|
22
|
-
export function createAgentInstructionsRoutes(manualAuth, readPreamble
|
|
22
|
+
export function createAgentInstructionsRoutes(manualAuth, readPreamble,
|
|
23
|
+
/**
|
|
24
|
+
* The layout in effect, read per request — the shared file rules name the
|
|
25
|
+
* managed guide, whose name the setup save may change without a restart.
|
|
26
|
+
* Optional so a construction with no layout in hand gets `AGENTS.md`.
|
|
27
|
+
*/
|
|
28
|
+
kbLayout) {
|
|
23
29
|
const router = express.Router();
|
|
24
30
|
router.get('/agent/instructions', manualAuth, async (_req, res) => {
|
|
25
31
|
// Set before the read, so a failure answer is no more cacheable than a
|
|
26
32
|
// successful one: the contract is on the route, not on the happy path.
|
|
27
33
|
res.setHeader('Cache-Control', 'no-store');
|
|
28
34
|
try {
|
|
29
|
-
res.json(composeAgentInstructions(await readPreamble()));
|
|
35
|
+
res.json(composeAgentInstructions(await readPreamble(), kbLayout?.()));
|
|
30
36
|
}
|
|
31
37
|
catch (err) {
|
|
32
38
|
log.error('reading mcp-description.md failed:', { err });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-instructions.routes.js","sourceRoot":"","sources":["../../../src/modules/agent-instructions/agent-instructions.routes.ts"],"names":[],"mappings":"AAAA,OAAO,OAAgC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-instructions.routes.js","sourceRoot":"","sources":["../../../src/modules/agent-instructions/agent-instructions.routes.ts"],"names":[],"mappings":"AAAA,OAAO,OAAgC,MAAM,SAAS,CAAC;AAEvD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,MAAM,GAAG,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAGxD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,6BAA6B,CAC3C,UAA0B,EAC1B,YAAiC;AACjC;;;;GAIG;AACH,QAAyB;IAEzB,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAEhC,MAAM,CAAC,GAAG,CAAC,qBAAqB,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAChE,uEAAuE;QACvE,uEAAuE;QACvE,GAAG,CAAC,SAAS,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;QAC3C,IAAI,CAAC;YACH,GAAG,CAAC,IAAI,CAAC,wBAAwB,CAAC,MAAM,YAAY,EAAE,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;QACzE,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,GAAG,CAAC,KAAK,CAAC,oCAAoC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;YACzD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,uCAAuC,EAAE,CAAC,CAAC;QAC3E,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* What a connected agent is told at the start of an MCP session, composed
|
|
3
|
-
* from
|
|
4
|
-
*
|
|
3
|
+
* from three layers: a platform header the code owns, the rules every file tool
|
|
4
|
+
* shares (`shared-file-rules.ts`, the same text the managed guide carries), and
|
|
5
|
+
* the deployment preamble an admin writes in `mcp-description.md` at the
|
|
6
|
+
* repository root.
|
|
5
7
|
*
|
|
6
8
|
* Two channels carry the result. The full text goes out as `instructions` on
|
|
7
9
|
* the initialize handshake, which Claude Code, Claude Desktop and Cursor place
|
|
@@ -14,7 +16,7 @@
|
|
|
14
16
|
* file access; the hosted proxy, the agent-facing route and the local bridge
|
|
15
17
|
* all read this one composer's output.
|
|
16
18
|
*/
|
|
17
|
-
import { PREAMBLE_CAP, PREAMBLE_FILE, TOOL_PREFIX_CAP } from '@bevel-software/platform-shared';
|
|
19
|
+
import { PREAMBLE_CAP, PREAMBLE_FILE, TOOL_PREFIX_CAP, type KbLayout } from '@bevel-software/platform-shared';
|
|
18
20
|
export { PREAMBLE_CAP, PREAMBLE_FILE, TOOL_PREFIX_CAP };
|
|
19
21
|
/** The tools whose descriptions carry the prefix. Every other tool is untouched. */
|
|
20
22
|
export declare const PREFIXED_TOOLS: ReadonlySet<string>;
|
|
@@ -31,12 +33,37 @@ export declare const PLATFORM_HEADER: string;
|
|
|
31
33
|
* sensible purpose line.
|
|
32
34
|
*/
|
|
33
35
|
export declare const TOOL_PREFIX_LINE = "This organisation's knowledge base. Search it before answering from memory.";
|
|
36
|
+
/**
|
|
37
|
+
* The whole platform-owned part of the handshake text: what Hexis is, then the
|
|
38
|
+
* rules every file tool shares (see `shared-file-rules.ts`). This is what the
|
|
39
|
+
* `header` field carries and what the card shows as fixed and not editable;
|
|
40
|
+
* the admin's preamble follows it.
|
|
41
|
+
*
|
|
42
|
+
* A FUNCTION of the layout, because the shared rules name the managed guide
|
|
43
|
+
* and its file name is a deployment setting.
|
|
44
|
+
*/
|
|
45
|
+
export declare function platformInstructions(layout: KbLayout): string;
|
|
46
|
+
/**
|
|
47
|
+
* The ceiling on the WHOLE handshake text, pinned by a test.
|
|
48
|
+
*
|
|
49
|
+
* No client publishes a limit for `instructions` — what was observed being cut
|
|
50
|
+
* was tool descriptions — so this is not a measured client limit but the
|
|
51
|
+
* arithmetic ceiling of the parts, held low enough that it stays a plausible
|
|
52
|
+
* system-prompt insert (~3,500 tokens): the header, the shared rules under their
|
|
53
|
+
* own cap, and the preamble under its cap plus the marker a cut appends. The
|
|
54
|
+
* test is what makes it a ceiling rather than a hope: a shared rule that grew
|
|
55
|
+
* past it fails before it reaches an agent.
|
|
56
|
+
*/
|
|
57
|
+
export declare const INSTRUCTIONS_CAP = 14000;
|
|
34
58
|
/** The one-line marker that replaces everything past the preamble cap. */
|
|
35
59
|
export declare const PREAMBLE_TRUNCATION_MARKER: string;
|
|
36
60
|
export interface ComposedAgentInstructions {
|
|
37
|
-
/** The
|
|
61
|
+
/** The platform text, then the preamble body when there is one. Sent on the initialize handshake. */
|
|
38
62
|
instructions: string;
|
|
39
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* The platform-owned text alone — the header and the shared file rules — so a
|
|
65
|
+
* card can show the fixed part apart from the admin's.
|
|
66
|
+
*/
|
|
40
67
|
header: string;
|
|
41
68
|
/** The preamble body as sent (cut and marked when over the cap); empty when there is none. */
|
|
42
69
|
preamble: string;
|
|
@@ -60,8 +87,13 @@ export interface ComposedAgentInstructions {
|
|
|
60
87
|
* absent). HTML comments are private notes and never leave the file; an
|
|
61
88
|
* unterminated `<!--` strips everything after it, so the most likely editing
|
|
62
89
|
* slip withholds text rather than leaking it.
|
|
90
|
+
*
|
|
91
|
+
* `layout` decides only the guide's name inside the shared rules, and defaults
|
|
92
|
+
* to the standard one — a caller with no layout in hand (a test, a surface that
|
|
93
|
+
* predates the setting) gets `AGENTS.md`, which is what an unset name means
|
|
94
|
+
* everywhere else.
|
|
63
95
|
*/
|
|
64
|
-
export declare function composeAgentInstructions(preamble: string | null): ComposedAgentInstructions;
|
|
96
|
+
export declare function composeAgentInstructions(preamble: string | null, layout?: KbLayout): ComposedAgentInstructions;
|
|
65
97
|
/**
|
|
66
98
|
* A tool description with the prefix ahead of it: the prefix, a blank line,
|
|
67
99
|
* then the original. Purpose line first, because claude.ai cuts descriptions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../../src/modules/agent-instructions/compose.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../../src/modules/agent-instructions/compose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAOH,OAAO,EAEL,YAAY,EACZ,aAAa,EACb,eAAe,EAEf,KAAK,QAAQ,EACd,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC;AAExD,oFAAoF;AACpF,eAAO,MAAM,cAAc,EAAE,WAAW,CAAC,MAAM,CAAiE,CAAC;AAEjH;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAMkD,CAAC;AAE/E;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,gFAAgF,CAAC;AAE9G;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,CAE7D;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,QAAS,CAAC;AAEvC,0EAA0E;AAC1E,eAAO,MAAM,0BAA0B,QAAyG,CAAC;AAEjJ,MAAM,WAAW,yBAAyB;IACxC,qGAAqG;IACrG,YAAY,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,8FAA8F;IAC9F,QAAQ,EAAE,MAAM,CAAC;IACjB,8FAA8F;IAC9F,cAAc,EAAE,MAAM,CAAC;IACvB,kHAAkH;IAClH,UAAU,EAAE,MAAM,CAAC;IACnB,+EAA+E;IAC/E,SAAS,EAAE,OAAO,CAAC;IACnB,sFAAsF;IACtF,aAAa,EAAE,MAAM,CAAC;IACtB,+DAA+D;IAC/D,mBAAmB,EAAE,OAAO,CAAC;IAC7B,yEAAyE;IACzE,eAAe,EAAE,MAAM,CAAC;IACxB,uFAAuF;IACvF,mBAAmB,EAAE,OAAO,CAAC;CAC9B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,MAAM,GAAE,QAA4B,GACnC,yBAAyB,CA+B3B;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAEjG"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* What a connected agent is told at the start of an MCP session, composed
|
|
3
|
-
* from
|
|
4
|
-
*
|
|
3
|
+
* from three layers: a platform header the code owns, the rules every file tool
|
|
4
|
+
* shares (`shared-file-rules.ts`, the same text the managed guide carries), and
|
|
5
|
+
* the deployment preamble an admin writes in `mcp-description.md` at the
|
|
6
|
+
* repository root.
|
|
5
7
|
*
|
|
6
8
|
* Two channels carry the result. The full text goes out as `instructions` on
|
|
7
9
|
* the initialize handshake, which Claude Code, Claude Desktop and Cursor place
|
|
@@ -19,7 +21,8 @@
|
|
|
19
21
|
// hand-mirrored copy would let the admin's view and the agent's text drift
|
|
20
22
|
// apart. Re-exported here because this module is where the backend reads them
|
|
21
23
|
// from.
|
|
22
|
-
import { PREAMBLE_CAP, PREAMBLE_FILE, TOOL_PREFIX_CAP, stripHtmlComments, } from '@bevel-software/platform-shared';
|
|
24
|
+
import { DEFAULT_KB_LAYOUT, PREAMBLE_CAP, PREAMBLE_FILE, TOOL_PREFIX_CAP, stripHtmlComments, } from '@bevel-software/platform-shared';
|
|
25
|
+
import { sharedFileRulesSection } from './shared-file-rules.js';
|
|
23
26
|
export { PREAMBLE_CAP, PREAMBLE_FILE, TOOL_PREFIX_CAP };
|
|
24
27
|
/** The tools whose descriptions carry the prefix. Every other tool is untouched. */
|
|
25
28
|
export const PREFIXED_TOOLS = new Set(['start_session', 'grep', 'list_files', 'read_file']);
|
|
@@ -41,6 +44,30 @@ export const PLATFORM_HEADER = "Hexis is this organisation's knowledge base, tog
|
|
|
41
44
|
* sensible purpose line.
|
|
42
45
|
*/
|
|
43
46
|
export const TOOL_PREFIX_LINE = "This organisation's knowledge base. Search it before answering from memory.";
|
|
47
|
+
/**
|
|
48
|
+
* The whole platform-owned part of the handshake text: what Hexis is, then the
|
|
49
|
+
* rules every file tool shares (see `shared-file-rules.ts`). This is what the
|
|
50
|
+
* `header` field carries and what the card shows as fixed and not editable;
|
|
51
|
+
* the admin's preamble follows it.
|
|
52
|
+
*
|
|
53
|
+
* A FUNCTION of the layout, because the shared rules name the managed guide
|
|
54
|
+
* and its file name is a deployment setting.
|
|
55
|
+
*/
|
|
56
|
+
export function platformInstructions(layout) {
|
|
57
|
+
return `${PLATFORM_HEADER}\n\n${sharedFileRulesSection(layout)}`;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The ceiling on the WHOLE handshake text, pinned by a test.
|
|
61
|
+
*
|
|
62
|
+
* No client publishes a limit for `instructions` — what was observed being cut
|
|
63
|
+
* was tool descriptions — so this is not a measured client limit but the
|
|
64
|
+
* arithmetic ceiling of the parts, held low enough that it stays a plausible
|
|
65
|
+
* system-prompt insert (~3,500 tokens): the header, the shared rules under their
|
|
66
|
+
* own cap, and the preamble under its cap plus the marker a cut appends. The
|
|
67
|
+
* test is what makes it a ceiling rather than a hope: a shared rule that grew
|
|
68
|
+
* past it fails before it reaches an agent.
|
|
69
|
+
*/
|
|
70
|
+
export const INSTRUCTIONS_CAP = 14_000;
|
|
44
71
|
/** The one-line marker that replaces everything past the preamble cap. */
|
|
45
72
|
export const PREAMBLE_TRUNCATION_MARKER = `[preamble truncated at ${PREAMBLE_CAP.toLocaleString('en-US')} characters; shorten ${PREAMBLE_FILE}]`;
|
|
46
73
|
/**
|
|
@@ -48,15 +75,21 @@ export const PREAMBLE_TRUNCATION_MARKER = `[preamble truncated at ${PREAMBLE_CAP
|
|
|
48
75
|
* absent). HTML comments are private notes and never leave the file; an
|
|
49
76
|
* unterminated `<!--` strips everything after it, so the most likely editing
|
|
50
77
|
* slip withholds text rather than leaking it.
|
|
78
|
+
*
|
|
79
|
+
* `layout` decides only the guide's name inside the shared rules, and defaults
|
|
80
|
+
* to the standard one — a caller with no layout in hand (a test, a surface that
|
|
81
|
+
* predates the setting) gets `AGENTS.md`, which is what an unset name means
|
|
82
|
+
* everywhere else.
|
|
51
83
|
*/
|
|
52
|
-
export function composeAgentInstructions(preamble) {
|
|
84
|
+
export function composeAgentInstructions(preamble, layout = DEFAULT_KB_LAYOUT) {
|
|
85
|
+
const platform = platformInstructions(layout);
|
|
53
86
|
const { text, unterminated } = stripHtmlComments(preamble ?? '');
|
|
54
87
|
const normalized = text.replace(/\r\n?/g, '\n');
|
|
55
88
|
const stripped = normalized.trim();
|
|
56
89
|
const preambleChars = stripped.length;
|
|
57
90
|
const truncated = preambleChars > PREAMBLE_CAP;
|
|
58
91
|
const body = truncated ? `${cutAtCodePoint(stripped, PREAMBLE_CAP)}\n${PREAMBLE_TRUNCATION_MARKER}` : stripped;
|
|
59
|
-
const instructions = body ? `${
|
|
92
|
+
const instructions = body ? `${platform}\n\n${body}` : platform;
|
|
60
93
|
// Classified UNTRIMMED: the leading indentation of a first line is what
|
|
61
94
|
// makes it an indented code block, and the trim above would turn that
|
|
62
95
|
// code into prose. The paragraph itself comes back trimmed.
|
|
@@ -67,7 +100,7 @@ export function composeAgentInstructions(preamble) {
|
|
|
67
100
|
const toolPrefix = toolPrefixTruncated ? cutAtCodePoint(fullPrefix, TOOL_PREFIX_CAP) : fullPrefix;
|
|
68
101
|
return {
|
|
69
102
|
instructions,
|
|
70
|
-
header:
|
|
103
|
+
header: platform,
|
|
71
104
|
preamble: body,
|
|
72
105
|
toolPrefix,
|
|
73
106
|
toolPrefixLine: TOOL_PREFIX_LINE,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../../../src/modules/agent-instructions/compose.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../../../src/modules/agent-instructions/compose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,uEAAuE;AACvE,0EAA0E;AAC1E,2EAA2E;AAC3E,8EAA8E;AAC9E,QAAQ;AACR,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,iBAAiB,GAElB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC;AAExD,oFAAoF;AACpF,MAAM,CAAC,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC,CAAC,eAAe,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC;AAEjH;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAC1B,2GAA2G;IAC3G,gFAAgF;IAChF,8HAA8H;IAC9H,6IAA6I;IAC7I,wJAAwJ;IACxJ,4EAA4E,CAAC;AAE/E;;;;;GA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G,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC7D,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { composeAgentInstructions, prefixToolDescription, PLATFORM_HEADER, TOOL_PREFIX_LINE, PREAMBLE_CAP, TOOL_PREFIX_CAP, PREAMBLE_FILE, PREFIXED_TOOLS, PREAMBLE_TRUNCATION_MARKER, type ComposedAgentInstructions, } from './compose.js';
|
|
1
|
+
export { composeAgentInstructions, prefixToolDescription, platformInstructions, INSTRUCTIONS_CAP, PLATFORM_HEADER, TOOL_PREFIX_LINE, PREAMBLE_CAP, TOOL_PREFIX_CAP, PREAMBLE_FILE, PREFIXED_TOOLS, PREAMBLE_TRUNCATION_MARKER, type ComposedAgentInstructions, } from './compose.js';
|
|
2
|
+
export { POINTER_GUIDE_NAME_BUDGET, SHARED_FILE_RULES_CAP, SHARED_RULES_POINTER_MAX, SHARED_RULES_SECTION, sharedFileRules, sharedFileRulesSection, sharedRulesPointer, type SharedFileRule, } from './shared-file-rules.js';
|
|
2
3
|
export { readAgentPreamble, type AgentPreambleReader, type PreambleWorkspace } from './read-preamble.js';
|
|
3
4
|
export { createAgentInstructionsRoutes } from './agent-instructions.routes.js';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/agent-instructions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,cAAc,EACd,0BAA0B,EAC1B,KAAK,yBAAyB,GAC/B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,KAAK,mBAAmB,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACzG,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/agent-instructions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,cAAc,EACd,0BAA0B,EAC1B,KAAK,yBAAyB,GAC/B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAClB,KAAK,cAAc,GACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,KAAK,mBAAmB,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACzG,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { composeAgentInstructions, prefixToolDescription, PLATFORM_HEADER, TOOL_PREFIX_LINE, PREAMBLE_CAP, TOOL_PREFIX_CAP, PREAMBLE_FILE, PREFIXED_TOOLS, PREAMBLE_TRUNCATION_MARKER, } from './compose.js';
|
|
1
|
+
export { composeAgentInstructions, prefixToolDescription, platformInstructions, INSTRUCTIONS_CAP, PLATFORM_HEADER, TOOL_PREFIX_LINE, PREAMBLE_CAP, TOOL_PREFIX_CAP, PREAMBLE_FILE, PREFIXED_TOOLS, PREAMBLE_TRUNCATION_MARKER, } from './compose.js';
|
|
2
|
+
export { POINTER_GUIDE_NAME_BUDGET, SHARED_FILE_RULES_CAP, SHARED_RULES_POINTER_MAX, SHARED_RULES_SECTION, sharedFileRules, sharedFileRulesSection, sharedRulesPointer, } from './shared-file-rules.js';
|
|
2
3
|
export { readAgentPreamble } from './read-preamble.js';
|
|
3
4
|
export { createAgentInstructionsRoutes } from './agent-instructions.routes.js';
|
|
4
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/agent-instructions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,cAAc,EACd,0BAA0B,GAE3B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAoD,MAAM,oBAAoB,CAAC;AACzG,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/agent-instructions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,cAAc,EACd,0BAA0B,GAE3B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,kBAAkB,GAEnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAoD,MAAM,oBAAoB,CAAC;AACzG,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rules that apply to MORE THAN ONE file tool, written ONCE.
|
|
3
|
+
*
|
|
4
|
+
* They used to be appended, in full, to every tool description that they
|
|
5
|
+
* covered: the content rule rode on all twelve file tools, the agent-guide
|
|
6
|
+
* reminder on all of them plus the shell, the write-mode and escape-sequence
|
|
7
|
+
* paragraphs on two or three apiece. A description then ran to two or three
|
|
8
|
+
* thousand characters, most of it text the agent had already read on the tool
|
|
9
|
+
* above — and clients cut long descriptions from the END, which is where the
|
|
10
|
+
* text specific to the tool sits. Agents saw `file_stat`, `read_file`,
|
|
11
|
+
* `write_file` and `write_files` arrive ending in "[truncated]".
|
|
12
|
+
*
|
|
13
|
+
* So the shared rules are stated in TWO places and in neither description:
|
|
14
|
+
*
|
|
15
|
+
* - the MCP `instructions` of the initialize handshake (see `compose.ts`),
|
|
16
|
+
* which Claude Code, Claude Desktop and Cursor put in the system prompt;
|
|
17
|
+
* - the platform-managed agent guide at the repository root (`AGENTS.md` by
|
|
18
|
+
* default), rendered from `{{sharedFileRules}}` in the template — claude.ai
|
|
19
|
+
* on the web, the Agent SDK and Cline drop `instructions`, and a guide the
|
|
20
|
+
* agent is told to read before its first action is always available.
|
|
21
|
+
*
|
|
22
|
+
* Both places get the SAME string, from {@link sharedFileRulesSection} — not
|
|
23
|
+
* two hand-mirrored copies. A rule written twice is a rule that drifts, and a
|
|
24
|
+
* drifted rule is worse than a repeated one, because the agent cannot tell
|
|
25
|
+
* which copy is current. Each description ends instead with
|
|
26
|
+
* {@link sharedRulesPointer}, one sentence naming the section and the file.
|
|
27
|
+
*
|
|
28
|
+
* Pure text, a function of the layout only: the guide's file name is a
|
|
29
|
+
* deployment setting, so nothing here may snapshot `AGENTS.md`.
|
|
30
|
+
*/
|
|
31
|
+
import { type KbLayout } from '@bevel-software/platform-shared';
|
|
32
|
+
/** The heading the rules live under, in both places and in the pointer sentence. */
|
|
33
|
+
export declare const SHARED_RULES_SECTION = "Working with files";
|
|
34
|
+
/**
|
|
35
|
+
* The ceiling on the whole section. Pinned by a test: the section lands in
|
|
36
|
+
* every conversation through two channels, and a rule moved here to shorten a
|
|
37
|
+
* description has only moved the cost if the section itself grows without
|
|
38
|
+
* limit. Measured against {@link sharedFileRulesSection} under the default
|
|
39
|
+
* layout.
|
|
40
|
+
*
|
|
41
|
+
* 7,000 since two rules moved in from descriptions they took past their cap:
|
|
42
|
+
* the chain's own (what a failed chain and an oversized result answer), true
|
|
43
|
+
* of every call rather than of how to write one, and why large, escape-heavy
|
|
44
|
+
* and binary content goes by upload, which three write tools each said in
|
|
45
|
+
* full.
|
|
46
|
+
*/
|
|
47
|
+
export declare const SHARED_FILE_RULES_CAP = 7000;
|
|
48
|
+
/** One shared rule: how the guide heads it, and the rule itself. */
|
|
49
|
+
export interface SharedFileRule {
|
|
50
|
+
/** Stable id, so a test can name the rule that went missing. */
|
|
51
|
+
id: string;
|
|
52
|
+
/** The heading this rule gets in the section. */
|
|
53
|
+
heading: string;
|
|
54
|
+
/** The rule, as both places state it. Markdown paragraphs, blank-line separated. */
|
|
55
|
+
body: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Every shared rule, in reading order: what to read first, what the content
|
|
59
|
+
* is, what a write may do, then the two protocols that guard a destructive
|
|
60
|
+
* call.
|
|
61
|
+
*
|
|
62
|
+
* The bodies are the sentences the descriptions used to carry, moved rather
|
|
63
|
+
* than rewritten wherever the wording still reads outside its old tool — the
|
|
64
|
+
* ones that said "this tool" or "this call" name the tools instead.
|
|
65
|
+
*/
|
|
66
|
+
export declare function sharedFileRules(layout: KbLayout): readonly SharedFileRule[];
|
|
67
|
+
/**
|
|
68
|
+
* The shared rules as ONE markdown section — the string both channels carry,
|
|
69
|
+
* byte for byte. A `##` section so it drops into the managed guide at that
|
|
70
|
+
* level and still reads as a block in the instructions blob.
|
|
71
|
+
*/
|
|
72
|
+
export declare function sharedFileRulesSection(layout: KbLayout): string;
|
|
73
|
+
/**
|
|
74
|
+
* The longest guide file name the pointer sentence spells out. Beyond this it
|
|
75
|
+
* names the guide by its ROLE instead (see {@link sharedRulesPointer}).
|
|
76
|
+
*
|
|
77
|
+
* There has to be a bound somewhere, because the pointer rides on every file
|
|
78
|
+
* tool and a file name is not a fixed cost: `validateFilename` allows a name
|
|
79
|
+
* of up to 255 bytes, so an unbounded pointer could reach 318 characters and
|
|
80
|
+
* push `file_stat` to 1,428 — over the description cap, recreating on a
|
|
81
|
+
* renamed deployment exactly the truncation this module exists to prevent, and
|
|
82
|
+
* invisibly, because every measurement is taken under the default layout.
|
|
83
|
+
*
|
|
84
|
+
* 40 is well past any name a deployment plausibly picks
|
|
85
|
+
* (`ENGINEERING-AGENT-CONVENTIONS.md` is 32) and the fallback below is only
|
|
86
|
+
* reachable past it.
|
|
87
|
+
*/
|
|
88
|
+
export declare const POINTER_GUIDE_NAME_BUDGET = 40;
|
|
89
|
+
/**
|
|
90
|
+
* The one sentence a tool description ends with, in place of the paragraphs it
|
|
91
|
+
* used to carry. Short on purpose: it costs every description the same ~100
|
|
92
|
+
* characters at worst, and its whole job is to name the section and the file
|
|
93
|
+
* to read.
|
|
94
|
+
*
|
|
95
|
+
* BOUNDED BY CONSTRUCTION, which is what lets the description cap mean
|
|
96
|
+
* something on a deployment that renamed its guide: a name within
|
|
97
|
+
* {@link POINTER_GUIDE_NAME_BUDGET} is spelled out, and a longer one gets the
|
|
98
|
+
* generic wording. Naming the file is the better sentence and wins whenever it
|
|
99
|
+
* fits; a name past the budget is pathological, and there the choice is between
|
|
100
|
+
* a sentence that says where to look and a catalog entry the client cuts. The
|
|
101
|
+
* guide's own name is still in the section's first rule either way.
|
|
102
|
+
*
|
|
103
|
+
* An absent layout means the default one, as it does in
|
|
104
|
+
* `composeAgentInstructions`: a caller reading the layout from configuration
|
|
105
|
+
* gets `undefined` when none is set, and the pointer must still name a file.
|
|
106
|
+
*/
|
|
107
|
+
export declare function sharedRulesPointer(layout?: KbLayout): string;
|
|
108
|
+
/**
|
|
109
|
+
* The most the pointer can ever cost a description, over every layout. What the
|
|
110
|
+
* description cap is measured against, the way the tool prefix is measured at
|
|
111
|
+
* ITS cap rather than at whatever the current admin wrote: a description that
|
|
112
|
+
* only fits beside the short default guide name does not really fit.
|
|
113
|
+
*/
|
|
114
|
+
export declare const SHARED_RULES_POINTER_MAX: number;
|
|
115
|
+
//# sourceMappingURL=shared-file-rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-file-rules.d.ts","sourceRoot":"","sources":["../../../src/modules/agent-instructions/shared-file-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAKL,KAAK,QAAQ,EACd,MAAM,iCAAiC,CAAC;AAGzC,oFAAoF;AACpF,eAAO,MAAM,oBAAoB,uBAAuB,CAAC;AAUzD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB,OAAQ,CAAC;AAE3C,oEAAoE;AACpE,MAAM,WAAW,cAAc;IAC7B,gEAAgE;IAChE,EAAE,EAAE,MAAM,CAAC;IACX,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,oFAAoF;IACpF,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,cAAc,EAAE,CAqH3E;AAgDD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,CAK/D;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAE5C;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,GAAE,QAA4B,GAAG,MAAM,CAK/E;AAED;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,QAGpC,CAAC"}
|