@bevel-software/platform-core-backend 0.1.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/LICENSE +202 -0
- package/dist/assets.d.ts +5 -0
- package/dist/assets.d.ts.map +1 -0
- package/dist/assets.js +23 -0
- package/dist/assets.js.map +1 -0
- package/dist/core/core-ports.d.ts +83 -0
- package/dist/core/core-ports.d.ts.map +1 -0
- package/dist/core/core-ports.js +12 -0
- package/dist/core/core-ports.js.map +1 -0
- package/dist/core/create-core-server.d.ts +62 -0
- package/dist/core/create-core-server.d.ts.map +1 -0
- package/dist/core/create-core-server.js +204 -0
- package/dist/core/create-core-server.js.map +1 -0
- package/dist/core/create-core-services.d.ts +95 -0
- package/dist/core/create-core-services.d.ts.map +1 -0
- package/dist/core/create-core-services.js +352 -0
- package/dist/core/create-core-services.js.map +1 -0
- package/dist/core-config.d.ts +119 -0
- package/dist/core-config.d.ts.map +1 -0
- package/dist/core-config.js +240 -0
- package/dist/core-config.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/access/access-control.interface.d.ts +348 -0
- package/dist/modules/access/access-control.interface.d.ts.map +1 -0
- package/dist/modules/access/access-control.interface.js +2 -0
- package/dist/modules/access/access-control.interface.js.map +1 -0
- package/dist/modules/access/access-control.service.d.ts +323 -0
- package/dist/modules/access/access-control.service.d.ts.map +1 -0
- package/dist/modules/access/access-control.service.js +1431 -0
- package/dist/modules/access/access-control.service.js.map +1 -0
- package/dist/modules/access/access-errors.d.ts +34 -0
- package/dist/modules/access/access-errors.d.ts.map +1 -0
- package/dist/modules/access/access-errors.js +40 -0
- package/dist/modules/access/access-errors.js.map +1 -0
- package/dist/modules/access/access-mutation.service.d.ts +176 -0
- package/dist/modules/access/access-mutation.service.d.ts.map +1 -0
- package/dist/modules/access/access-mutation.service.js +307 -0
- package/dist/modules/access/access-mutation.service.js.map +1 -0
- package/dist/modules/access/access-splice.d.ts +98 -0
- package/dist/modules/access/access-splice.d.ts.map +1 -0
- package/dist/modules/access/access-splice.js +346 -0
- package/dist/modules/access/access-splice.js.map +1 -0
- package/dist/modules/access/access.routes.d.ts +10 -0
- package/dist/modules/access/access.routes.d.ts.map +1 -0
- package/dist/modules/access/access.routes.js +757 -0
- package/dist/modules/access/access.routes.js.map +1 -0
- package/dist/modules/access/creator-access.d.ts +113 -0
- package/dist/modules/access/creator-access.d.ts.map +1 -0
- package/dist/modules/access/creator-access.js +212 -0
- package/dist/modules/access/creator-access.js.map +1 -0
- package/dist/modules/access/kb-read-filter.d.ts +41 -0
- package/dist/modules/access/kb-read-filter.d.ts.map +1 -0
- package/dist/modules/access/kb-read-filter.js +60 -0
- package/dist/modules/access/kb-read-filter.js.map +1 -0
- package/dist/modules/access/roles-admin.service.d.ts +240 -0
- package/dist/modules/access/roles-admin.service.d.ts.map +1 -0
- package/dist/modules/access/roles-admin.service.js +630 -0
- package/dist/modules/access/roles-admin.service.js.map +1 -0
- package/dist/modules/access/roles-edit.d.ts +91 -0
- package/dist/modules/access/roles-edit.d.ts.map +1 -0
- package/dist/modules/access/roles-edit.js +232 -0
- package/dist/modules/access/roles-edit.js.map +1 -0
- package/dist/modules/access/roles-yaml-guard.d.ts +56 -0
- package/dist/modules/access/roles-yaml-guard.d.ts.map +1 -0
- package/dist/modules/access/roles-yaml-guard.js +79 -0
- package/dist/modules/access/roles-yaml-guard.js.map +1 -0
- package/dist/modules/admin/admin-access.routes.d.ts +18 -0
- package/dist/modules/admin/admin-access.routes.d.ts.map +1 -0
- package/dist/modules/admin/admin-access.routes.js +26 -0
- package/dist/modules/admin/admin-access.routes.js.map +1 -0
- package/dist/modules/admin/admin-access.service.d.ts +24 -0
- package/dist/modules/admin/admin-access.service.d.ts.map +1 -0
- package/dist/modules/admin/admin-access.service.js +41 -0
- package/dist/modules/admin/admin-access.service.js.map +1 -0
- package/dist/modules/admin/admin.interface.d.ts +11 -0
- package/dist/modules/admin/admin.interface.d.ts.map +1 -0
- package/dist/modules/admin/admin.interface.js +2 -0
- package/dist/modules/admin/admin.interface.js.map +1 -0
- package/dist/modules/auth/account-erasure.service.d.ts +80 -0
- package/dist/modules/auth/account-erasure.service.d.ts.map +1 -0
- package/dist/modules/auth/account-erasure.service.js +91 -0
- package/dist/modules/auth/account-erasure.service.js.map +1 -0
- package/dist/modules/auth/auth.middleware.d.ts +23 -0
- package/dist/modules/auth/auth.middleware.d.ts.map +1 -0
- package/dist/modules/auth/auth.middleware.js +68 -0
- package/dist/modules/auth/auth.middleware.js.map +1 -0
- package/dist/modules/auth/auth.routes.d.ts +25 -0
- package/dist/modules/auth/auth.routes.d.ts.map +1 -0
- package/dist/modules/auth/auth.routes.js +72 -0
- package/dist/modules/auth/auth.routes.js.map +1 -0
- package/dist/modules/auth/auth.service.d.ts +76 -0
- package/dist/modules/auth/auth.service.d.ts.map +1 -0
- package/dist/modules/auth/auth.service.js +168 -0
- package/dist/modules/auth/auth.service.js.map +1 -0
- package/dist/modules/code-mode/code-mode-names.d.ts +16 -0
- package/dist/modules/code-mode/code-mode-names.d.ts.map +1 -0
- package/dist/modules/code-mode/code-mode-names.js +30 -0
- package/dist/modules/code-mode/code-mode-names.js.map +1 -0
- package/dist/modules/code-mode/code-mode.tool.d.ts +13 -0
- package/dist/modules/code-mode/code-mode.tool.d.ts.map +1 -0
- package/dist/modules/code-mode/code-mode.tool.js +112 -0
- package/dist/modules/code-mode/code-mode.tool.js.map +1 -0
- package/dist/modules/code-mode/index.d.ts +3 -0
- package/dist/modules/code-mode/index.d.ts.map +1 -0
- package/dist/modules/code-mode/index.js +3 -0
- package/dist/modules/code-mode/index.js.map +1 -0
- package/dist/modules/database/connection.d.ts +6 -0
- package/dist/modules/database/connection.d.ts.map +1 -0
- package/dist/modules/database/connection.js +12 -0
- package/dist/modules/database/connection.js.map +1 -0
- package/dist/modules/database/core-schema.d.ts +2273 -0
- package/dist/modules/database/core-schema.d.ts.map +1 -0
- package/dist/modules/database/core-schema.js +413 -0
- package/dist/modules/database/core-schema.js.map +1 -0
- package/dist/modules/database/migrate.d.ts +10 -0
- package/dist/modules/database/migrate.d.ts.map +1 -0
- package/dist/modules/database/migrate.js +40 -0
- package/dist/modules/database/migrate.js.map +1 -0
- package/dist/modules/database/schema.d.ts +12 -0
- package/dist/modules/database/schema.d.ts.map +1 -0
- package/dist/modules/database/schema.js +12 -0
- package/dist/modules/database/schema.js.map +1 -0
- package/dist/modules/diff/diff-paths.d.ts +2 -0
- package/dist/modules/diff/diff-paths.d.ts.map +1 -0
- package/dist/modules/diff/diff-paths.js +9 -0
- package/dist/modules/diff/diff-paths.js.map +1 -0
- package/dist/modules/diff/diff.config.d.ts +8 -0
- package/dist/modules/diff/diff.config.d.ts.map +1 -0
- package/dist/modules/diff/diff.config.js +13 -0
- package/dist/modules/diff/diff.config.js.map +1 -0
- package/dist/modules/diff/diff.interface.d.ts +73 -0
- package/dist/modules/diff/diff.interface.d.ts.map +1 -0
- package/dist/modules/diff/diff.interface.js +2 -0
- package/dist/modules/diff/diff.interface.js.map +1 -0
- package/dist/modules/diff/diff.routes.d.ts +35 -0
- package/dist/modules/diff/diff.routes.d.ts.map +1 -0
- package/dist/modules/diff/diff.routes.js +228 -0
- package/dist/modules/diff/diff.routes.js.map +1 -0
- package/dist/modules/diff/diff.service.d.ts +51 -0
- package/dist/modules/diff/diff.service.d.ts.map +1 -0
- package/dist/modules/diff/diff.service.js +489 -0
- package/dist/modules/diff/diff.service.js.map +1 -0
- package/dist/modules/diff/line-diff.d.ts +16 -0
- package/dist/modules/diff/line-diff.d.ts.map +1 -0
- package/dist/modules/diff/line-diff.js +67 -0
- package/dist/modules/diff/line-diff.js.map +1 -0
- package/dist/modules/mcp/mcp-auth.middleware.d.ts +27 -0
- package/dist/modules/mcp/mcp-auth.middleware.d.ts.map +1 -0
- package/dist/modules/mcp/mcp-auth.middleware.js +116 -0
- package/dist/modules/mcp/mcp-auth.middleware.js.map +1 -0
- package/dist/modules/mcp/mcp-session-store.d.ts +74 -0
- package/dist/modules/mcp/mcp-session-store.d.ts.map +1 -0
- package/dist/modules/mcp/mcp-session-store.js +131 -0
- package/dist/modules/mcp/mcp-session-store.js.map +1 -0
- package/dist/modules/mcp/mcp.routes.d.ts +24 -0
- package/dist/modules/mcp/mcp.routes.d.ts.map +1 -0
- package/dist/modules/mcp/mcp.routes.js +229 -0
- package/dist/modules/mcp/mcp.routes.js.map +1 -0
- package/dist/modules/mcp/mcp.service.d.ts +198 -0
- package/dist/modules/mcp/mcp.service.d.ts.map +1 -0
- package/dist/modules/mcp/mcp.service.js +840 -0
- package/dist/modules/mcp/mcp.service.js.map +1 -0
- package/dist/modules/mcp/oauth/bevel-oauth-provider.d.ts +76 -0
- package/dist/modules/mcp/oauth/bevel-oauth-provider.d.ts.map +1 -0
- package/dist/modules/mcp/oauth/bevel-oauth-provider.js +291 -0
- package/dist/modules/mcp/oauth/bevel-oauth-provider.js.map +1 -0
- package/dist/modules/mcp/oauth/oauth-consent.routes.d.ts +18 -0
- package/dist/modules/mcp/oauth/oauth-consent.routes.d.ts.map +1 -0
- package/dist/modules/mcp/oauth/oauth-consent.routes.js +52 -0
- package/dist/modules/mcp/oauth/oauth-consent.routes.js.map +1 -0
- package/dist/modules/mcp/oauth/oauth-state.d.ts +32 -0
- package/dist/modules/mcp/oauth/oauth-state.d.ts.map +1 -0
- package/dist/modules/mcp/oauth/oauth-state.js +34 -0
- package/dist/modules/mcp/oauth/oauth-state.js.map +1 -0
- package/dist/modules/secrets-vault/db-secrets-vault.service.d.ts +92 -0
- package/dist/modules/secrets-vault/db-secrets-vault.service.d.ts.map +1 -0
- package/dist/modules/secrets-vault/db-secrets-vault.service.js +728 -0
- package/dist/modules/secrets-vault/db-secrets-vault.service.js.map +1 -0
- package/dist/modules/secrets-vault/index.d.ts +7 -0
- package/dist/modules/secrets-vault/index.d.ts.map +1 -0
- package/dist/modules/secrets-vault/index.js +6 -0
- package/dist/modules/secrets-vault/index.js.map +1 -0
- package/dist/modules/secrets-vault/mcp-oauth-discovery.service.d.ts +63 -0
- package/dist/modules/secrets-vault/mcp-oauth-discovery.service.d.ts.map +1 -0
- package/dist/modules/secrets-vault/mcp-oauth-discovery.service.js +269 -0
- package/dist/modules/secrets-vault/mcp-oauth-discovery.service.js.map +1 -0
- package/dist/modules/secrets-vault/secrets-variable-loader.d.ts +46 -0
- package/dist/modules/secrets-vault/secrets-variable-loader.d.ts.map +1 -0
- package/dist/modules/secrets-vault/secrets-variable-loader.js +87 -0
- package/dist/modules/secrets-vault/secrets-variable-loader.js.map +1 -0
- package/dist/modules/secrets-vault/secrets-vault.contract.d.ts +210 -0
- package/dist/modules/secrets-vault/secrets-vault.contract.d.ts.map +1 -0
- package/dist/modules/secrets-vault/secrets-vault.contract.js +90 -0
- package/dist/modules/secrets-vault/secrets-vault.contract.js.map +1 -0
- package/dist/modules/secrets-vault/secrets-vault.routes.d.ts +30 -0
- package/dist/modules/secrets-vault/secrets-vault.routes.d.ts.map +1 -0
- package/dist/modules/secrets-vault/secrets-vault.routes.js +490 -0
- package/dist/modules/secrets-vault/secrets-vault.routes.js.map +1 -0
- package/dist/modules/skills/index.d.ts +5 -0
- package/dist/modules/skills/index.d.ts.map +1 -0
- package/dist/modules/skills/index.js +4 -0
- package/dist/modules/skills/index.js.map +1 -0
- package/dist/modules/skills/skills.contract.d.ts +58 -0
- package/dist/modules/skills/skills.contract.d.ts.map +1 -0
- package/dist/modules/skills/skills.contract.js +10 -0
- package/dist/modules/skills/skills.contract.js.map +1 -0
- package/dist/modules/skills/skills.routes.d.ts +15 -0
- package/dist/modules/skills/skills.routes.d.ts.map +1 -0
- package/dist/modules/skills/skills.routes.js +34 -0
- package/dist/modules/skills/skills.routes.js.map +1 -0
- package/dist/modules/skills/skills.service.d.ts +21 -0
- package/dist/modules/skills/skills.service.d.ts.map +1 -0
- package/dist/modules/skills/skills.service.js +202 -0
- package/dist/modules/skills/skills.service.js.map +1 -0
- package/dist/modules/skills/skills.tools.d.ts +15 -0
- package/dist/modules/skills/skills.tools.d.ts.map +1 -0
- package/dist/modules/skills/skills.tools.js +96 -0
- package/dist/modules/skills/skills.tools.js.map +1 -0
- package/dist/modules/tool-auth/external-api-key.errors.d.ts +14 -0
- package/dist/modules/tool-auth/external-api-key.errors.d.ts.map +1 -0
- package/dist/modules/tool-auth/external-api-key.errors.js +23 -0
- package/dist/modules/tool-auth/external-api-key.errors.js.map +1 -0
- package/dist/modules/tool-auth/external-api-key.interface.d.ts +90 -0
- package/dist/modules/tool-auth/external-api-key.interface.d.ts.map +1 -0
- package/dist/modules/tool-auth/external-api-key.interface.js +2 -0
- package/dist/modules/tool-auth/external-api-key.interface.js.map +1 -0
- package/dist/modules/tool-auth/external-api-key.service.d.ts +25 -0
- package/dist/modules/tool-auth/external-api-key.service.d.ts.map +1 -0
- package/dist/modules/tool-auth/external-api-key.service.js +164 -0
- package/dist/modules/tool-auth/external-api-key.service.js.map +1 -0
- package/dist/modules/tool-auth/internal-token.service.d.ts +62 -0
- package/dist/modules/tool-auth/internal-token.service.d.ts.map +1 -0
- package/dist/modules/tool-auth/internal-token.service.js +85 -0
- package/dist/modules/tool-auth/internal-token.service.js.map +1 -0
- package/dist/modules/tool-auth/llm-usage-meter.d.ts +16 -0
- package/dist/modules/tool-auth/llm-usage-meter.d.ts.map +1 -0
- package/dist/modules/tool-auth/llm-usage-meter.js +6 -0
- package/dist/modules/tool-auth/llm-usage-meter.js.map +1 -0
- package/dist/modules/tool-auth/tool-auth.middleware.d.ts +101 -0
- package/dist/modules/tool-auth/tool-auth.middleware.d.ts.map +1 -0
- package/dist/modules/tool-auth/tool-auth.middleware.js +166 -0
- package/dist/modules/tool-auth/tool-auth.middleware.js.map +1 -0
- package/dist/modules/tool-helpers/index.d.ts +19 -0
- package/dist/modules/tool-helpers/index.d.ts.map +1 -0
- package/dist/modules/tool-helpers/index.js +18 -0
- package/dist/modules/tool-helpers/index.js.map +1 -0
- package/dist/modules/tool-helpers/tool-context.d.ts +35 -0
- package/dist/modules/tool-helpers/tool-context.d.ts.map +1 -0
- package/dist/modules/tool-helpers/tool-context.js +66 -0
- package/dist/modules/tool-helpers/tool-context.js.map +1 -0
- package/dist/modules/tool-helpers/tool-def.d.ts +33 -0
- package/dist/modules/tool-helpers/tool-def.d.ts.map +1 -0
- package/dist/modules/tool-helpers/tool-def.js +57 -0
- package/dist/modules/tool-helpers/tool-def.js.map +1 -0
- package/dist/modules/tool-helpers/tool-handler.d.ts +19 -0
- package/dist/modules/tool-helpers/tool-handler.d.ts.map +1 -0
- package/dist/modules/tool-helpers/tool-handler.js +84 -0
- package/dist/modules/tool-helpers/tool-handler.js.map +1 -0
- package/dist/modules/tool-helpers/tool.contract.d.ts +64 -0
- package/dist/modules/tool-helpers/tool.contract.d.ts.map +1 -0
- package/dist/modules/tool-helpers/tool.contract.js +24 -0
- package/dist/modules/tool-helpers/tool.contract.js.map +1 -0
- package/dist/modules/tool-helpers/validate-token.d.ts +31 -0
- package/dist/modules/tool-helpers/validate-token.d.ts.map +1 -0
- package/dist/modules/tool-helpers/validate-token.js +20 -0
- package/dist/modules/tool-helpers/validate-token.js.map +1 -0
- package/dist/modules/tool-manuals/index.d.ts +5 -0
- package/dist/modules/tool-manuals/index.d.ts.map +1 -0
- package/dist/modules/tool-manuals/index.js +5 -0
- package/dist/modules/tool-manuals/index.js.map +1 -0
- package/dist/modules/tool-manuals/tool-manuals.contract.d.ts +182 -0
- package/dist/modules/tool-manuals/tool-manuals.contract.d.ts.map +1 -0
- package/dist/modules/tool-manuals/tool-manuals.contract.js +19 -0
- package/dist/modules/tool-manuals/tool-manuals.contract.js.map +1 -0
- package/dist/modules/tool-manuals/tool-manuals.routes.d.ts +24 -0
- package/dist/modules/tool-manuals/tool-manuals.routes.d.ts.map +1 -0
- package/dist/modules/tool-manuals/tool-manuals.routes.js +102 -0
- package/dist/modules/tool-manuals/tool-manuals.routes.js.map +1 -0
- package/dist/modules/tool-manuals/tool-manuals.service.d.ts +108 -0
- package/dist/modules/tool-manuals/tool-manuals.service.d.ts.map +1 -0
- package/dist/modules/tool-manuals/tool-manuals.service.js +710 -0
- package/dist/modules/tool-manuals/tool-manuals.service.js.map +1 -0
- package/dist/modules/tool-manuals/tool-manuals.tools.d.ts +35 -0
- package/dist/modules/tool-manuals/tool-manuals.tools.d.ts.map +1 -0
- package/dist/modules/tool-manuals/tool-manuals.tools.js +157 -0
- package/dist/modules/tool-manuals/tool-manuals.tools.js.map +1 -0
- package/dist/modules/tool-registry/manual.routes.d.ts +6 -0
- package/dist/modules/tool-registry/manual.routes.d.ts.map +1 -0
- package/dist/modules/tool-registry/manual.routes.js +76 -0
- package/dist/modules/tool-registry/manual.routes.js.map +1 -0
- package/dist/modules/tool-registry/tool-registry.d.ts +23 -0
- package/dist/modules/tool-registry/tool-registry.d.ts.map +1 -0
- package/dist/modules/tool-registry/tool-registry.js +46 -0
- package/dist/modules/tool-registry/tool-registry.js.map +1 -0
- package/dist/modules/tool-registry/tool.contract.d.ts +48 -0
- package/dist/modules/tool-registry/tool.contract.d.ts.map +1 -0
- package/dist/modules/tool-registry/tool.contract.js +2 -0
- package/dist/modules/tool-registry/tool.contract.js.map +1 -0
- package/dist/modules/workflow/agent-tools/workflow.tools.d.ts +14 -0
- package/dist/modules/workflow/agent-tools/workflow.tools.d.ts.map +1 -0
- package/dist/modules/workflow/agent-tools/workflow.tools.js +437 -0
- package/dist/modules/workflow/agent-tools/workflow.tools.js.map +1 -0
- package/dist/modules/workflow/event-bus.d.ts +107 -0
- package/dist/modules/workflow/event-bus.d.ts.map +1 -0
- package/dist/modules/workflow/event-bus.js +224 -0
- package/dist/modules/workflow/event-bus.js.map +1 -0
- package/dist/modules/workflow/events.routes.d.ts +80 -0
- package/dist/modules/workflow/events.routes.d.ts.map +1 -0
- package/dist/modules/workflow/events.routes.js +216 -0
- package/dist/modules/workflow/events.routes.js.map +1 -0
- package/dist/modules/workflow/file-change-notifier.d.ts +38 -0
- package/dist/modules/workflow/file-change-notifier.d.ts.map +1 -0
- package/dist/modules/workflow/file-change-notifier.js +22 -0
- package/dist/modules/workflow/file-change-notifier.js.map +1 -0
- package/dist/modules/workflow/file-lock.service.d.ts +57 -0
- package/dist/modules/workflow/file-lock.service.d.ts.map +1 -0
- package/dist/modules/workflow/file-lock.service.js +202 -0
- package/dist/modules/workflow/file-lock.service.js.map +1 -0
- package/dist/modules/workflow/git/branch-name.d.ts +10 -0
- package/dist/modules/workflow/git/branch-name.d.ts.map +1 -0
- package/dist/modules/workflow/git/branch-name.js +76 -0
- package/dist/modules/workflow/git/branch-name.js.map +1 -0
- package/dist/modules/workflow/git/clone-config.d.ts +61 -0
- package/dist/modules/workflow/git/clone-config.d.ts.map +1 -0
- package/dist/modules/workflow/git/clone-config.js +69 -0
- package/dist/modules/workflow/git/clone-config.js.map +1 -0
- package/dist/modules/workflow/git/git-version.d.ts +34 -0
- package/dist/modules/workflow/git/git-version.d.ts.map +1 -0
- package/dist/modules/workflow/git/git-version.js +63 -0
- package/dist/modules/workflow/git/git-version.js.map +1 -0
- package/dist/modules/workflow/git/git.service.d.ts +427 -0
- package/dist/modules/workflow/git/git.service.d.ts.map +1 -0
- package/dist/modules/workflow/git/git.service.js +1987 -0
- package/dist/modules/workflow/git/git.service.js.map +1 -0
- package/dist/modules/workflow/git/mutex.d.ts +11 -0
- package/dist/modules/workflow/git/mutex.d.ts.map +1 -0
- package/dist/modules/workflow/git/mutex.js +23 -0
- package/dist/modules/workflow/git/mutex.js.map +1 -0
- package/dist/modules/workflow/git/pull-request.service.d.ts +124 -0
- package/dist/modules/workflow/git/pull-request.service.d.ts.map +1 -0
- package/dist/modules/workflow/git/pull-request.service.js +328 -0
- package/dist/modules/workflow/git/pull-request.service.js.map +1 -0
- package/dist/modules/workflow/locking-filesystem.d.ts +133 -0
- package/dist/modules/workflow/locking-filesystem.d.ts.map +1 -0
- package/dist/modules/workflow/locking-filesystem.js +400 -0
- package/dist/modules/workflow/locking-filesystem.js.map +1 -0
- package/dist/modules/workflow/pending-commits.service.d.ts +221 -0
- package/dist/modules/workflow/pending-commits.service.d.ts.map +1 -0
- package/dist/modules/workflow/pending-commits.service.js +364 -0
- package/dist/modules/workflow/pending-commits.service.js.map +1 -0
- package/dist/modules/workflow/pending-commits.worker.d.ts +148 -0
- package/dist/modules/workflow/pending-commits.worker.d.ts.map +1 -0
- package/dist/modules/workflow/pending-commits.worker.js +245 -0
- package/dist/modules/workflow/pending-commits.worker.js.map +1 -0
- package/dist/modules/workflow/read-only-filesystem.d.ts +24 -0
- package/dist/modules/workflow/read-only-filesystem.d.ts.map +1 -0
- package/dist/modules/workflow/read-only-filesystem.js +39 -0
- package/dist/modules/workflow/read-only-filesystem.js.map +1 -0
- package/dist/modules/workflow/recovery-bot.d.ts +31 -0
- package/dist/modules/workflow/recovery-bot.d.ts.map +1 -0
- package/dist/modules/workflow/recovery-bot.js +64 -0
- package/dist/modules/workflow/recovery-bot.js.map +1 -0
- package/dist/modules/workflow/review-workflow/review-workflow.interface.d.ts +137 -0
- package/dist/modules/workflow/review-workflow/review-workflow.interface.d.ts.map +1 -0
- package/dist/modules/workflow/review-workflow/review-workflow.interface.js +2 -0
- package/dist/modules/workflow/review-workflow/review-workflow.interface.js.map +1 -0
- package/dist/modules/workflow/review-workflow/review-workflow.service.d.ts +26 -0
- package/dist/modules/workflow/review-workflow/review-workflow.service.d.ts.map +1 -0
- package/dist/modules/workflow/review-workflow/review-workflow.service.js +636 -0
- package/dist/modules/workflow/review-workflow/review-workflow.service.js.map +1 -0
- package/dist/modules/workflow/sanitize-error.d.ts +29 -0
- package/dist/modules/workflow/sanitize-error.d.ts.map +1 -0
- package/dist/modules/workflow/sanitize-error.js +60 -0
- package/dist/modules/workflow/sanitize-error.js.map +1 -0
- package/dist/modules/workflow/session-ontology.policy.d.ts +52 -0
- package/dist/modules/workflow/session-ontology.policy.d.ts.map +1 -0
- package/dist/modules/workflow/session-ontology.policy.js +62 -0
- package/dist/modules/workflow/session-ontology.policy.js.map +1 -0
- package/dist/modules/workflow/session-ontology.service.d.ts +100 -0
- package/dist/modules/workflow/session-ontology.service.d.ts.map +1 -0
- package/dist/modules/workflow/session-ontology.service.js +143 -0
- package/dist/modules/workflow/session-ontology.service.js.map +1 -0
- package/dist/modules/workflow/workflow-hooks.d.ts +87 -0
- package/dist/modules/workflow/workflow-hooks.d.ts.map +1 -0
- package/dist/modules/workflow/workflow-hooks.js +35 -0
- package/dist/modules/workflow/workflow-hooks.js.map +1 -0
- package/dist/modules/workflow/workflow.errors.d.ts +171 -0
- package/dist/modules/workflow/workflow.errors.d.ts.map +1 -0
- package/dist/modules/workflow/workflow.errors.js +260 -0
- package/dist/modules/workflow/workflow.errors.js.map +1 -0
- package/dist/modules/workflow/workflow.routes.d.ts +26 -0
- package/dist/modules/workflow/workflow.routes.d.ts.map +1 -0
- package/dist/modules/workflow/workflow.routes.js +804 -0
- package/dist/modules/workflow/workflow.routes.js.map +1 -0
- package/dist/modules/workflow/workflow.service.d.ts +385 -0
- package/dist/modules/workflow/workflow.service.d.ts.map +1 -0
- package/dist/modules/workflow/workflow.service.js +1155 -0
- package/dist/modules/workflow/workflow.service.js.map +1 -0
- package/dist/modules/workspace/bevel-ignore.d.ts +25 -0
- package/dist/modules/workspace/bevel-ignore.d.ts.map +1 -0
- package/dist/modules/workspace/bevel-ignore.js +57 -0
- package/dist/modules/workspace/bevel-ignore.js.map +1 -0
- package/dist/modules/workspace/kb-seed.interface.d.ts +36 -0
- package/dist/modules/workspace/kb-seed.interface.d.ts.map +1 -0
- package/dist/modules/workspace/kb-seed.interface.js +2 -0
- package/dist/modules/workspace/kb-seed.interface.js.map +1 -0
- package/dist/modules/workspace/kb-seed.service.d.ts +70 -0
- package/dist/modules/workspace/kb-seed.service.d.ts.map +1 -0
- package/dist/modules/workspace/kb-seed.service.js +325 -0
- package/dist/modules/workspace/kb-seed.service.js.map +1 -0
- package/dist/modules/workspace/routine-write-policy.d.ts +49 -0
- package/dist/modules/workspace/routine-write-policy.d.ts.map +1 -0
- package/dist/modules/workspace/routine-write-policy.js +46 -0
- package/dist/modules/workspace/routine-write-policy.js.map +1 -0
- package/dist/modules/workspace/session-ontology.gate.d.ts +112 -0
- package/dist/modules/workspace/session-ontology.gate.d.ts.map +1 -0
- package/dist/modules/workspace/session-ontology.gate.js +161 -0
- package/dist/modules/workspace/session-ontology.gate.js.map +1 -0
- package/dist/modules/workspace/session-sink.d.ts +25 -0
- package/dist/modules/workspace/session-sink.d.ts.map +1 -0
- package/dist/modules/workspace/session-sink.js +8 -0
- package/dist/modules/workspace/session-sink.js.map +1 -0
- package/dist/modules/workspace/spill-store.d.ts +24 -0
- package/dist/modules/workspace/spill-store.d.ts.map +1 -0
- package/dist/modules/workspace/spill-store.js +87 -0
- package/dist/modules/workspace/spill-store.js.map +1 -0
- package/dist/modules/workspace/workspace.routes.d.ts +25 -0
- package/dist/modules/workspace/workspace.routes.d.ts.map +1 -0
- package/dist/modules/workspace/workspace.routes.js +1046 -0
- package/dist/modules/workspace/workspace.routes.js.map +1 -0
- package/dist/modules/workspace/workspace.service.d.ts +339 -0
- package/dist/modules/workspace/workspace.service.d.ts.map +1 -0
- package/dist/modules/workspace/workspace.service.js +1221 -0
- package/dist/modules/workspace/workspace.service.js.map +1 -0
- package/dist/modules/workspace/workspace.tools.d.ts +19 -0
- package/dist/modules/workspace/workspace.tools.d.ts.map +1 -0
- package/dist/modules/workspace/workspace.tools.js +767 -0
- package/dist/modules/workspace/workspace.tools.js.map +1 -0
- package/dist/shared/frontmatter-id.d.ts +35 -0
- package/dist/shared/frontmatter-id.d.ts.map +1 -0
- package/dist/shared/frontmatter-id.js +68 -0
- package/dist/shared/frontmatter-id.js.map +1 -0
- package/dist/shared/fs-walk.d.ts +9 -0
- package/dist/shared/fs-walk.d.ts.map +1 -0
- package/dist/shared/fs-walk.js +34 -0
- package/dist/shared/fs-walk.js.map +1 -0
- package/dist/shared/hash-email.d.ts +11 -0
- package/dist/shared/hash-email.d.ts.map +1 -0
- package/dist/shared/hash-email.js +14 -0
- package/dist/shared/hash-email.js.map +1 -0
- package/dist/shared/kb-layout.d.ts +38 -0
- package/dist/shared/kb-layout.d.ts.map +1 -0
- package/dist/shared/kb-layout.js +102 -0
- package/dist/shared/kb-layout.js.map +1 -0
- package/dist/shared/kb-layout.test.d.ts +2 -0
- package/dist/shared/kb-layout.test.d.ts.map +1 -0
- package/dist/shared/kb-layout.test.js +67 -0
- package/dist/shared/kb-layout.test.js.map +1 -0
- package/dist/shared/ssrf.d.ts +20 -0
- package/dist/shared/ssrf.d.ts.map +1 -0
- package/dist/shared/ssrf.js +89 -0
- package/dist/shared/ssrf.js.map +1 -0
- package/dist/shared/token-crypto.d.ts +16 -0
- package/dist/shared/token-crypto.d.ts.map +1 -0
- package/dist/shared/token-crypto.js +49 -0
- package/dist/shared/token-crypto.js.map +1 -0
- package/dist/shared/ttl-cache.d.ts +16 -0
- package/dist/shared/ttl-cache.d.ts.map +1 -0
- package/dist/shared/ttl-cache.js +27 -0
- package/dist/shared/ttl-cache.js.map +1 -0
- package/dist/shared/utcp-namespace.d.ts +46 -0
- package/dist/shared/utcp-namespace.d.ts.map +1 -0
- package/dist/shared/utcp-namespace.js +82 -0
- package/dist/shared/utcp-namespace.js.map +1 -0
- package/dist/version.d.ts +17 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +19 -0
- package/dist/version.js.map +1 -0
- package/kb-template/.bevelignore +21 -0
- package/kb-template/Agents/.gitkeep +0 -0
- package/kb-template/Agents/README.md +38 -0
- package/kb-template/CLAUDE.md +419 -0
- package/kb-template/Data/.gitkeep +0 -0
- package/kb-template/Data/README.md +39 -0
- package/kb-template/KnowledgeBase/.gitkeep +0 -0
- package/kb-template/KnowledgeBase/README.md +37 -0
- package/kb-template/Pipelines/.gitkeep +0 -0
- package/kb-template/Pipelines/README.md +38 -0
- package/kb-template/Skills/.gitkeep +0 -0
- package/kb-template/Skills/README.md +32 -0
- package/kb-template/Tools/.gitkeep +0 -0
- package/kb-template/Tools/README.md +42 -0
- package/kb-template/access.md +36 -0
- package/migrations/0000_core_init.sql +243 -0
- package/migrations/meta/0000_snapshot.json +1480 -0
- package/migrations/meta/_journal.json +13 -0
- package/package.json +80 -0
- package/src/assets.ts +25 -0
- package/src/core/core-ports.ts +91 -0
- package/src/core/create-core-server.ts +338 -0
- package/src/core/create-core-services.ts +501 -0
- package/src/core-config.ts +257 -0
- package/src/index.ts +69 -0
- package/src/modules/access/__tests__/access-control.atref-batch.test.ts +98 -0
- package/src/modules/access/__tests__/access-control.read-batch.test.ts +132 -0
- package/src/modules/access/__tests__/access-control.service.test.ts +1011 -0
- package/src/modules/access/__tests__/access-mutation.service.test.ts +439 -0
- package/src/modules/access/__tests__/access-splice.test.ts +247 -0
- package/src/modules/access/__tests__/access.routes.revoke.test.ts +407 -0
- package/src/modules/access/__tests__/creator-access.test.ts +217 -0
- package/src/modules/access/__tests__/grant-sources.test.ts +204 -0
- package/src/modules/access/__tests__/kb-read-filter.test.ts +70 -0
- package/src/modules/access/__tests__/roles-admin.service.test.ts +469 -0
- package/src/modules/access/__tests__/roles-edit.test.ts +138 -0
- package/src/modules/access/__tests__/roles-yaml-guard.test.ts +70 -0
- package/src/modules/access/__tests__/roles.routes.test.ts +234 -0
- package/src/modules/access/access-control.interface.ts +383 -0
- package/src/modules/access/access-control.service.ts +1794 -0
- package/src/modules/access/access-errors.ts +60 -0
- package/src/modules/access/access-mutation.service.ts +369 -0
- package/src/modules/access/access-splice.ts +413 -0
- package/src/modules/access/access.routes.ts +894 -0
- package/src/modules/access/creator-access.ts +270 -0
- package/src/modules/access/kb-read-filter.ts +76 -0
- package/src/modules/access/roles-admin.service.ts +741 -0
- package/src/modules/access/roles-edit.ts +248 -0
- package/src/modules/access/roles-yaml-guard.ts +89 -0
- package/src/modules/admin/admin-access.routes.ts +29 -0
- package/src/modules/admin/admin-access.service.ts +38 -0
- package/src/modules/admin/admin.interface.ts +10 -0
- package/src/modules/auth/account-erasure.service.ts +183 -0
- package/src/modules/auth/auth.middleware.ts +78 -0
- package/src/modules/auth/auth.routes.ts +97 -0
- package/src/modules/auth/auth.service.ts +199 -0
- package/src/modules/code-mode/code-mode-names.ts +38 -0
- package/src/modules/code-mode/code-mode.tool.ts +117 -0
- package/src/modules/code-mode/index.ts +6 -0
- package/src/modules/database/connection.ts +15 -0
- package/src/modules/database/core-schema.ts +431 -0
- package/src/modules/database/migrate.ts +43 -0
- package/src/modules/database/schema.ts +11 -0
- package/src/modules/diff/__tests__/diff.routes.read-gate.test.ts +87 -0
- package/src/modules/diff/__tests__/diff.routes.rejectPathsLocked.test.ts +150 -0
- package/src/modules/diff/__tests__/diff.service.seed-atomicity.test.ts +184 -0
- package/src/modules/diff/__tests__/diff.service.test.ts +202 -0
- package/src/modules/diff/diff-paths.ts +9 -0
- package/src/modules/diff/diff.config.ts +12 -0
- package/src/modules/diff/diff.interface.ts +78 -0
- package/src/modules/diff/diff.routes.ts +277 -0
- package/src/modules/diff/diff.service.ts +508 -0
- package/src/modules/diff/line-diff.ts +79 -0
- package/src/modules/mcp/__tests__/bevel-oauth-provider.test.ts +287 -0
- package/src/modules/mcp/__tests__/mcp-auth.middleware.test.ts +249 -0
- package/src/modules/mcp/__tests__/mcp-proxy-helpers.test.ts +253 -0
- package/src/modules/mcp/__tests__/mcp-session-store.test.ts +151 -0
- package/src/modules/mcp/__tests__/mcp.e2e.test.ts +150 -0
- package/src/modules/mcp/__tests__/mcp.routes.delete.test.ts +92 -0
- package/src/modules/mcp/__tests__/mcp.service.test.ts +414 -0
- package/src/modules/mcp/mcp-auth.middleware.ts +126 -0
- package/src/modules/mcp/mcp-session-store.ts +162 -0
- package/src/modules/mcp/mcp.routes.ts +263 -0
- package/src/modules/mcp/mcp.service.ts +973 -0
- package/src/modules/mcp/oauth/bevel-oauth-provider.ts +401 -0
- package/src/modules/mcp/oauth/oauth-consent.routes.ts +60 -0
- package/src/modules/mcp/oauth/oauth-state.ts +61 -0
- package/src/modules/secrets-vault/__tests__/connect-pending.route.test.ts +277 -0
- package/src/modules/secrets-vault/__tests__/db-secrets-vault.oauth.test.ts +206 -0
- package/src/modules/secrets-vault/__tests__/mcp-oauth-discovery.service.test.ts +178 -0
- package/src/modules/secrets-vault/__tests__/scopes-covered.test.ts +101 -0
- package/src/modules/secrets-vault/__tests__/secrets-variable-loader.test.ts +54 -0
- package/src/modules/secrets-vault/__tests__/tool-owner-gate.route.test.ts +143 -0
- package/src/modules/secrets-vault/db-secrets-vault.service.ts +792 -0
- package/src/modules/secrets-vault/index.ts +25 -0
- package/src/modules/secrets-vault/mcp-oauth-discovery.service.ts +289 -0
- package/src/modules/secrets-vault/secrets-variable-loader.ts +104 -0
- package/src/modules/secrets-vault/secrets-vault.contract.ts +270 -0
- package/src/modules/secrets-vault/secrets-vault.routes.ts +526 -0
- package/src/modules/skills/__tests__/skills.service.test.ts +176 -0
- package/src/modules/skills/index.ts +10 -0
- package/src/modules/skills/skills.contract.ts +54 -0
- package/src/modules/skills/skills.routes.ts +38 -0
- package/src/modules/skills/skills.service.ts +245 -0
- package/src/modules/skills/skills.tools.ts +121 -0
- package/src/modules/tool-auth/__tests__/external-api-key.service.test.ts +358 -0
- package/src/modules/tool-auth/__tests__/internal-token.service.test.ts +79 -0
- package/src/modules/tool-auth/__tests__/manual-auth.middleware.test.ts +88 -0
- package/src/modules/tool-auth/external-api-key.errors.ts +25 -0
- package/src/modules/tool-auth/external-api-key.interface.ts +99 -0
- package/src/modules/tool-auth/external-api-key.service.ts +209 -0
- package/src/modules/tool-auth/internal-token.service.ts +124 -0
- package/src/modules/tool-auth/llm-usage-meter.ts +19 -0
- package/src/modules/tool-auth/tool-auth.middleware.ts +220 -0
- package/src/modules/tool-helpers/__tests__/phase0-loopback-spike.test.ts +129 -0
- package/src/modules/tool-helpers/__tests__/phase4-tools.test.ts +95 -0
- package/src/modules/tool-helpers/__tests__/tools-surface.test.ts +146 -0
- package/src/modules/tool-helpers/__tests__/validate-token.test.ts +75 -0
- package/src/modules/tool-helpers/index.ts +18 -0
- package/src/modules/tool-helpers/tool-context.ts +98 -0
- package/src/modules/tool-helpers/tool-def.ts +73 -0
- package/src/modules/tool-helpers/tool-handler.ts +91 -0
- package/src/modules/tool-helpers/tool.contract.ts +85 -0
- package/src/modules/tool-helpers/validate-token.ts +50 -0
- package/src/modules/tool-manuals/__tests__/tool-manuals.mcp-oauth.test.ts +200 -0
- package/src/modules/tool-manuals/__tests__/tool-manuals.service.test.ts +499 -0
- package/src/modules/tool-manuals/__tests__/tool-manuals.tools.test.ts +156 -0
- package/src/modules/tool-manuals/index.ts +12 -0
- package/src/modules/tool-manuals/tool-manuals.contract.ts +183 -0
- package/src/modules/tool-manuals/tool-manuals.routes.ts +110 -0
- package/src/modules/tool-manuals/tool-manuals.service.ts +781 -0
- package/src/modules/tool-manuals/tool-manuals.tools.ts +202 -0
- package/src/modules/tool-registry/__tests__/tool-registry.test.ts +64 -0
- package/src/modules/tool-registry/manual.routes.ts +87 -0
- package/src/modules/tool-registry/tool-registry.ts +55 -0
- package/src/modules/tool-registry/tool.contract.ts +52 -0
- package/src/modules/workflow/__tests__/event-bus.test.ts +322 -0
- package/src/modules/workflow/__tests__/file-change-notifier.test.ts +51 -0
- package/src/modules/workflow/__tests__/format-affected-owners.test.ts +67 -0
- package/src/modules/workflow/__tests__/locking-filesystem.test.ts +445 -0
- package/src/modules/workflow/__tests__/pending-commits.canonical.test.ts +36 -0
- package/src/modules/workflow/__tests__/pending-commits.worker.test.ts +243 -0
- package/src/modules/workflow/__tests__/preserve-roles-yaml.test.ts +308 -0
- package/src/modules/workflow/__tests__/sanitize-error.test.ts +67 -0
- package/src/modules/workflow/__tests__/session-ontology.policy.test.ts +62 -0
- package/src/modules/workflow/__tests__/session-ontology.service.test.ts +200 -0
- package/src/modules/workflow/__tests__/workflow.service.commitFileWhileLocked.test.ts +232 -0
- package/src/modules/workflow/__tests__/workflow.service.facade.test.ts +380 -0
- package/src/modules/workflow/__tests__/workflow.service.releaseLock.test.ts +340 -0
- package/src/modules/workflow/agent-tools/__tests__/workflow.tools.test.ts +192 -0
- package/src/modules/workflow/agent-tools/workflow.tools.ts +502 -0
- package/src/modules/workflow/event-bus.ts +262 -0
- package/src/modules/workflow/events.routes.ts +266 -0
- package/src/modules/workflow/file-change-notifier.ts +54 -0
- package/src/modules/workflow/file-lock.service.ts +269 -0
- package/src/modules/workflow/git/__tests__/branch-name.test.ts +86 -0
- package/src/modules/workflow/git/__tests__/branchAuthor.test.ts +80 -0
- package/src/modules/workflow/git/__tests__/clone-config.test.ts +15 -0
- package/src/modules/workflow/git/__tests__/git-test-helpers.ts +47 -0
- package/src/modules/workflow/git/__tests__/git-version.failure.test.ts +24 -0
- package/src/modules/workflow/git/__tests__/git-version.test.ts +49 -0
- package/src/modules/workflow/git/__tests__/git.service.accessGating.test.ts +389 -0
- package/src/modules/workflow/git/__tests__/git.service.changedFilesForPr.test.ts +124 -0
- package/src/modules/workflow/git/__tests__/git.service.commitChanges.test.ts +105 -0
- package/src/modules/workflow/git/__tests__/git.service.commitFile.test.ts +211 -0
- package/src/modules/workflow/git/__tests__/git.service.createBranch.test.ts +154 -0
- package/src/modules/workflow/git/__tests__/git.service.deleteBranch.test.ts +320 -0
- package/src/modules/workflow/git/__tests__/git.service.diffFileAtCommit.test.ts +202 -0
- package/src/modules/workflow/git/__tests__/git.service.diffFileBetweenBranches.test.ts +453 -0
- package/src/modules/workflow/git/__tests__/git.service.list-branches.test.ts +198 -0
- package/src/modules/workflow/git/__tests__/git.service.listTrackedFiles.test.ts +125 -0
- package/src/modules/workflow/git/__tests__/git.service.logForFile.test.ts +219 -0
- package/src/modules/workflow/git/__tests__/git.service.mergeChangeRequest.test.ts +145 -0
- package/src/modules/workflow/git/__tests__/git.service.pendingChanges.test.ts +240 -0
- package/src/modules/workflow/git/__tests__/git.service.postMergePull.test.ts +272 -0
- package/src/modules/workflow/git/__tests__/git.service.pull.test.ts +232 -0
- package/src/modules/workflow/git/__tests__/git.service.readFileAtRef.test.ts +101 -0
- package/src/modules/workflow/git/__tests__/git.service.status.test.ts +127 -0
- package/src/modules/workflow/git/__tests__/mutex.test.ts +78 -0
- package/src/modules/workflow/git/__tests__/pull-request.service.test.ts +225 -0
- package/src/modules/workflow/git/__tests__/pull-request.service.viewer-can-cancel.test.ts +101 -0
- package/src/modules/workflow/git/branch-name.ts +70 -0
- package/src/modules/workflow/git/clone-config.ts +71 -0
- package/src/modules/workflow/git/git-version.ts +70 -0
- package/src/modules/workflow/git/git.service.ts +2248 -0
- package/src/modules/workflow/git/mutex.ts +22 -0
- package/src/modules/workflow/git/pull-request.service.ts +447 -0
- package/src/modules/workflow/locking-filesystem.ts +489 -0
- package/src/modules/workflow/pending-commits.service.ts +444 -0
- package/src/modules/workflow/pending-commits.worker.ts +361 -0
- package/src/modules/workflow/read-only-filesystem.ts +54 -0
- package/src/modules/workflow/recovery-bot.ts +73 -0
- package/src/modules/workflow/review-workflow/__tests__/approval-states.test.ts +560 -0
- package/src/modules/workflow/review-workflow/__tests__/cancel-pr.test.ts +176 -0
- package/src/modules/workflow/review-workflow/__tests__/merge-gate.test.ts +258 -0
- package/src/modules/workflow/review-workflow/review-workflow.interface.ts +199 -0
- package/src/modules/workflow/review-workflow/review-workflow.service.ts +806 -0
- package/src/modules/workflow/sanitize-error.ts +62 -0
- package/src/modules/workflow/session-ontology.policy.ts +70 -0
- package/src/modules/workflow/session-ontology.service.ts +178 -0
- package/src/modules/workflow/workflow-hooks.ts +101 -0
- package/src/modules/workflow/workflow.errors.ts +285 -0
- package/src/modules/workflow/workflow.routes.ts +858 -0
- package/src/modules/workflow/workflow.service.ts +1555 -0
- package/src/modules/workspace/__tests__/kb-seed.service.test.ts +213 -0
- package/src/modules/workspace/__tests__/routine-write-policy.test.ts +68 -0
- package/src/modules/workspace/__tests__/session-ontology.gate.test.ts +237 -0
- package/src/modules/workspace/__tests__/spill-store.test.ts +43 -0
- package/src/modules/workspace/__tests__/workspace.routes.create-grant.test.ts +233 -0
- package/src/modules/workspace/__tests__/workspace.routes.delete.test.ts +176 -0
- package/src/modules/workspace/__tests__/workspace.routes.download.test.ts +303 -0
- package/src/modules/workspace/__tests__/workspace.routes.read-gate.test.ts +276 -0
- package/src/modules/workspace/__tests__/workspace.service.read-filter.test.ts +120 -0
- package/src/modules/workspace/__tests__/workspace.service.test.ts +565 -0
- package/src/modules/workspace/__tests__/workspace.tools.test.ts +504 -0
- package/src/modules/workspace/bevel-ignore.ts +62 -0
- package/src/modules/workspace/kb-seed.interface.ts +36 -0
- package/src/modules/workspace/kb-seed.service.ts +361 -0
- package/src/modules/workspace/routine-write-policy.ts +79 -0
- package/src/modules/workspace/session-ontology.gate.ts +189 -0
- package/src/modules/workspace/session-sink.ts +25 -0
- package/src/modules/workspace/spill-store.ts +87 -0
- package/src/modules/workspace/workspace.routes.ts +1114 -0
- package/src/modules/workspace/workspace.service.ts +1343 -0
- package/src/modules/workspace/workspace.tools.ts +885 -0
- package/src/shared/__tests__/frontmatter-id.test.ts +88 -0
- package/src/shared/__tests__/fs-walk.test.ts +42 -0
- package/src/shared/__tests__/ssrf.test.ts +53 -0
- package/src/shared/__tests__/utcp-namespace.test.ts +19 -0
- package/src/shared/frontmatter-id.ts +72 -0
- package/src/shared/fs-walk.ts +30 -0
- package/src/shared/hash-email.ts +14 -0
- package/src/shared/kb-layout.test.ts +88 -0
- package/src/shared/kb-layout.ts +101 -0
- package/src/shared/ssrf.ts +78 -0
- package/src/shared/token-crypto.ts +54 -0
- package/src/shared/ttl-cache.ts +27 -0
- package/src/shared/utcp-namespace.ts +88 -0
- package/src/version.ts +19 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-run write restriction for background/routine agents.
|
|
3
|
+
*
|
|
4
|
+
* The ontology-session gate ({@link ../workflow/session-ontology.service}) bounds
|
|
5
|
+
* WHICH ontology a run may write; this narrower gate bounds WHAT KIND of file a
|
|
6
|
+
* run may write, by extension. It exists for the `watchlist_check` routine, which is
|
|
7
|
+
* allowed to refresh dashboard views (`.html`) but must never touch the
|
|
8
|
+
* knowledge-graph nodes (`.md`) or any other file — a hard, code-level guarantee
|
|
9
|
+
* rather than a prompt request (a prompt-only rule has already proven insufficient).
|
|
10
|
+
*
|
|
11
|
+
* Keyed by the agent run's `sessionId` (the background agent passes its run id as
|
|
12
|
+
* the session id, which the internal token then carries onto every loopback tool
|
|
13
|
+
* call as `ctx.sessionId`). A restriction lives only for the duration of one
|
|
14
|
+
* in-process run, so the store is a plain in-memory map — no durability needed,
|
|
15
|
+
* unlike the ontology touched-set which must survive restarts and span the MCP
|
|
16
|
+
* proxy. The executor sets the restriction before streaming and clears it after.
|
|
17
|
+
*/
|
|
18
|
+
export interface IRoutineWritePolicy {
|
|
19
|
+
/**
|
|
20
|
+
* Confine a session's writes to the given file extensions (each including the
|
|
21
|
+
* leading dot, e.g. `['.html', '.htm']`). Overwrites any prior restriction for
|
|
22
|
+
* the session. A session with no restriction is unrestricted (the default for
|
|
23
|
+
* chat + `ontology_ingest` runs).
|
|
24
|
+
*/
|
|
25
|
+
restrictToExtensions(sessionId: string, extensions: readonly string[]): void;
|
|
26
|
+
/** Drop a session's restriction (called at run end). */
|
|
27
|
+
clear(sessionId: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* Throw a 403 `ToolError` when the session is restricted and `wsPath`'s
|
|
30
|
+
* extension is not on its allow-list. No session id, or no active restriction,
|
|
31
|
+
* always passes — so this is a no-op for every non-restricted caller.
|
|
32
|
+
*/
|
|
33
|
+
assertPathWritable(sessionId: string | undefined, wsPath: string): void;
|
|
34
|
+
/**
|
|
35
|
+
* Throw a 403 `ToolError` when the session is restricted at all — for write
|
|
36
|
+
* tools with no single target path to check (arbitrary shell), which a
|
|
37
|
+
* restricted run must not be able to use as a write bypass.
|
|
38
|
+
*/
|
|
39
|
+
assertUnrestricted(sessionId: string | undefined): void;
|
|
40
|
+
}
|
|
41
|
+
export declare class RoutineWritePolicyService implements IRoutineWritePolicy {
|
|
42
|
+
/** sessionId → allowed lowercased extensions. Absent = unrestricted. */
|
|
43
|
+
private readonly restrictions;
|
|
44
|
+
restrictToExtensions(sessionId: string, extensions: readonly string[]): void;
|
|
45
|
+
clear(sessionId: string): void;
|
|
46
|
+
assertPathWritable(sessionId: string | undefined, wsPath: string): void;
|
|
47
|
+
assertUnrestricted(sessionId: string | undefined): void;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=routine-write-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routine-write-policy.d.ts","sourceRoot":"","sources":["../../../src/modules/workspace/routine-write-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,MAAM,WAAW,mBAAmB;IAClC;;;;;OAKG;IACH,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IAC7E,wDAAwD;IACxD,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B;;;;OAIG;IACH,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACxE;;;;OAIG;IACH,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;CACzD;AAED,qBAAa,yBAA0B,YAAW,mBAAmB;IACnE,wEAAwE;IACxE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAkC;IAE/D,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI;IAI5E,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAI9B,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAcvE,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;CAQxD"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-run write restriction for background/routine agents.
|
|
3
|
+
*
|
|
4
|
+
* The ontology-session gate ({@link ../workflow/session-ontology.service}) bounds
|
|
5
|
+
* WHICH ontology a run may write; this narrower gate bounds WHAT KIND of file a
|
|
6
|
+
* run may write, by extension. It exists for the `watchlist_check` routine, which is
|
|
7
|
+
* allowed to refresh dashboard views (`.html`) but must never touch the
|
|
8
|
+
* knowledge-graph nodes (`.md`) or any other file — a hard, code-level guarantee
|
|
9
|
+
* rather than a prompt request (a prompt-only rule has already proven insufficient).
|
|
10
|
+
*
|
|
11
|
+
* Keyed by the agent run's `sessionId` (the background agent passes its run id as
|
|
12
|
+
* the session id, which the internal token then carries onto every loopback tool
|
|
13
|
+
* call as `ctx.sessionId`). A restriction lives only for the duration of one
|
|
14
|
+
* in-process run, so the store is a plain in-memory map — no durability needed,
|
|
15
|
+
* unlike the ontology touched-set which must survive restarts and span the MCP
|
|
16
|
+
* proxy. The executor sets the restriction before streaming and clears it after.
|
|
17
|
+
*/
|
|
18
|
+
import { ToolError } from '../tool-helpers/tool.contract.js';
|
|
19
|
+
export class RoutineWritePolicyService {
|
|
20
|
+
/** sessionId → allowed lowercased extensions. Absent = unrestricted. */
|
|
21
|
+
restrictions = new Map();
|
|
22
|
+
restrictToExtensions(sessionId, extensions) {
|
|
23
|
+
this.restrictions.set(sessionId, new Set(extensions.map((e) => e.toLowerCase())));
|
|
24
|
+
}
|
|
25
|
+
clear(sessionId) {
|
|
26
|
+
this.restrictions.delete(sessionId);
|
|
27
|
+
}
|
|
28
|
+
assertPathWritable(sessionId, wsPath) {
|
|
29
|
+
const allowed = sessionId ? this.restrictions.get(sessionId) : undefined;
|
|
30
|
+
if (!allowed)
|
|
31
|
+
return;
|
|
32
|
+
const lower = wsPath.toLowerCase();
|
|
33
|
+
for (const ext of allowed) {
|
|
34
|
+
if (lower.endsWith(ext))
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
throw new ToolError(`This run may only write ${[...allowed].join(', ')} files (dashboard views); "${wsPath}" is blocked. ` +
|
|
38
|
+
'Knowledge-graph nodes and other files are read-only for this routine.', 403);
|
|
39
|
+
}
|
|
40
|
+
assertUnrestricted(sessionId) {
|
|
41
|
+
if (sessionId && this.restrictions.has(sessionId)) {
|
|
42
|
+
throw new ToolError('This run is restricted to writing dashboard views only, so shell commands (which could write any file) are disabled.', 403);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=routine-write-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routine-write-policy.js","sourceRoot":"","sources":["../../../src/modules/workspace/routine-write-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AA0B7D,MAAM,OAAO,yBAAyB;IACpC,wEAAwE;IACvD,YAAY,GAAG,IAAI,GAAG,EAAuB,CAAC;IAE/D,oBAAoB,CAAC,SAAiB,EAAE,UAA6B;QACnE,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC;IACpF,CAAC;IAED,KAAK,CAAC,SAAiB;QACrB,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;IAED,kBAAkB,CAAC,SAA6B,EAAE,MAAc;QAC9D,MAAM,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACzE,IAAI,CAAC,OAAO;YAAE,OAAO;QACrB,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;QACnC,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC1B,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;gBAAE,OAAO;QAClC,CAAC;QACD,MAAM,IAAI,SAAS,CACjB,2BAA2B,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,8BAA8B,MAAM,gBAAgB;YACpG,uEAAuE,EACzE,GAAG,CACJ,CAAC;IACJ,CAAC;IAED,kBAAkB,CAAC,SAA6B;QAC9C,IAAI,SAAS,IAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YAClD,MAAM,IAAI,SAAS,CACjB,sHAAsH,EACtH,GAAG,CACJ,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ontology-session boundary — the per-call gate used by the agent tool handlers.
|
|
3
|
+
*
|
|
4
|
+
* One decision fn, called by every gated file/graph handler:
|
|
5
|
+
* READS (isWrite=false) record the touched ontology and always allow.
|
|
6
|
+
* WRITES (isWrite=true) run the registered BLOCKING `preWrite` hooks
|
|
7
|
+
* (`WorkflowHooks`), then record. The core registers
|
|
8
|
+
* no hook, so core alone only TRACKS; the enterprise
|
|
9
|
+
* overlay registers the ontology block (see
|
|
10
|
+
* `modules/kb/ontology-block.hook.ts`), restoring
|
|
11
|
+
* "allowed only while the session is confined to a
|
|
12
|
+
* single ontology; once it has touched ≥2, all
|
|
13
|
+
* writes are blocked".
|
|
14
|
+
*
|
|
15
|
+
* Skips entirely when: the flag is off, the path is neutral (`ontologyOf` →
|
|
16
|
+
* null), the caller is not an agent, or the caller is the recovery bot. Fails
|
|
17
|
+
* CLOSED for an agent named-path operation that carries no `sessionId`.
|
|
18
|
+
*
|
|
19
|
+
* Lives beside `assertCanRead` in the workspace tools — it does NOT touch
|
|
20
|
+
* `acquireLock` (that gate is protected-branch-only; this boundary applies on
|
|
21
|
+
* all branches and to reads). See `docs/rp4-ontology-boundary-plan-v2.md`.
|
|
22
|
+
*/
|
|
23
|
+
import type { JsonSchema } from '../tool-registry/tool.contract.js';
|
|
24
|
+
import { ToolError, type ToolContext } from '../tool-helpers/tool.contract.js';
|
|
25
|
+
import type { ISessionOntologyService } from '../workflow/session-ontology.service.js';
|
|
26
|
+
import type { WorkflowHooks } from '../workflow/workflow-hooks.js';
|
|
27
|
+
/**
|
|
28
|
+
* The `sessionId` input the ontology-session boundary reads: the agent run /
|
|
29
|
+
* conversation id. The in-process agent supplies its thread id automatically
|
|
30
|
+
* (via its per-run internal token); an external agent has no ambient run id,
|
|
31
|
+
* so it must first mint one with the `start_session` tool and then pass it
|
|
32
|
+
* EXPLICITLY on every gated call — the MCP proxy is a pure passthrough and
|
|
33
|
+
* never injects args.
|
|
34
|
+
*/
|
|
35
|
+
export declare const SESSION_ID_INPUT: JsonSchema;
|
|
36
|
+
/**
|
|
37
|
+
* Boundary warning appended to ontology-gated tool descriptions so the agent
|
|
38
|
+
* knows the restriction before it calls one. Action-then-why phrasing per
|
|
39
|
+
* docs/glossary.md.
|
|
40
|
+
*/
|
|
41
|
+
export declare const ONTOLOGY_BOUNDARY_NOTE = " Stay within one KnowledgeBase ontology per conversation: once this run has read or written files in two different ontologies, every later content write (write_file/edit_file/mkdir/unzip, and both endpoints of move_file/copy_file) is blocked with a 403 and no override. Reads and delete_file never block \u2014 but each one records the ontology it touched and can poison a later content write, so do broad cross-ontology exploration only when you do not intend to write. Note move_file/copy_file are blocked outright when source and destination are different ontologies, since they would carry content across.";
|
|
42
|
+
/** Thrown when a write is refused because the session has crossed ontologies. */
|
|
43
|
+
export declare class OntologyWriteBlockedError extends ToolError {
|
|
44
|
+
constructor(touched: string[], attempted: string, reason: 'multi-ontology' | 'different-ontology');
|
|
45
|
+
}
|
|
46
|
+
/** Thrown when an agent op on a named ontology carries no session id (fail closed). */
|
|
47
|
+
export declare class MissingSessionError extends ToolError {
|
|
48
|
+
constructor();
|
|
49
|
+
}
|
|
50
|
+
export interface SessionOntologyGate {
|
|
51
|
+
service: ISessionOntologyService;
|
|
52
|
+
enabled: boolean;
|
|
53
|
+
kbDirName: string;
|
|
54
|
+
/** Lowercased email of the recovery/merge bot, which is exempt. */
|
|
55
|
+
recoveryBotEmail: string;
|
|
56
|
+
/**
|
|
57
|
+
* The workflow lifecycle-hook registry whose BLOCKING `preWrite` hooks
|
|
58
|
+
* decide whether a gated write/shell op proceeds. Core registers none (the
|
|
59
|
+
* gate then only tracks); the enterprise composition root registers the
|
|
60
|
+
* ontology block against `workflowService.hooks` — pass that same instance
|
|
61
|
+
* here.
|
|
62
|
+
*/
|
|
63
|
+
hooks: WorkflowHooks;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Record a read of `wsPath`'s ontology into the session's touched set. Reads are
|
|
67
|
+
* always allowed — recording is the only effect — but each one widens the
|
|
68
|
+
* touched set and so can poison a later write (see {@link assertOntologyWriteAllowed}).
|
|
69
|
+
* Fails closed (`MissingSessionError`) for an agent read of a named ontology
|
|
70
|
+
* with no session id.
|
|
71
|
+
*/
|
|
72
|
+
export declare function recordOntologyRead(gate: SessionOntologyGate, ctx: ToolContext, wsPath: string): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Assert a write to `wsPath` is allowed, then record it. A write that would
|
|
75
|
+
* carry information into a second ontology is the thing the boundary blocks:
|
|
76
|
+
* permitted only while the session stays confined to the target ontology, and
|
|
77
|
+
* refused with `OntologyWriteBlockedError` once it has touched ≥2. Note `delete`
|
|
78
|
+
* is NOT a write here — removing a node propagates no cross-ontology
|
|
79
|
+
* information, so it goes through {@link recordOntologyRead}.
|
|
80
|
+
*
|
|
81
|
+
* The BLOCKING decision itself lives behind the `preWrite` hooks: the
|
|
82
|
+
* enterprise-registered ontology block evaluates-and-records atomically via
|
|
83
|
+
* `checkOperation(isWrite=true)` and throws to refuse (identical behavior to
|
|
84
|
+
* the previous in-gate decision). Core registers no hook, so with none the
|
|
85
|
+
* write is allowed and only the touch is recorded (tracking stays core). The
|
|
86
|
+
* follow-up read-record after the hooks is idempotent — a no-op when a hook
|
|
87
|
+
* already recorded the allowed write.
|
|
88
|
+
*/
|
|
89
|
+
export declare function assertOntologyWriteAllowed(gate: SessionOntologyGate, ctx: ToolContext, wsPath: string): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Session-level write-eligibility gate for write-capable tools that have no
|
|
92
|
+
* single resolvable target path to check per-call — currently `execute_command`
|
|
93
|
+
* (arbitrary shell). Such a tool cannot be path-confined, so we enforce the
|
|
94
|
+
* boundary at the coarser session level: once the run has crossed into ≥2
|
|
95
|
+
* ontologies (the point at which EVERY path-checked write is already refused),
|
|
96
|
+
* we refuse the tool outright, so shell can't become a write path around the
|
|
97
|
+
* boundary. A fresh or single-ontology session is still allowed; a residual gap
|
|
98
|
+
* remains (a single-ontology session could shell-write a *different* ontology),
|
|
99
|
+
* accepted because arbitrary shell cannot be path-confined and blocking all
|
|
100
|
+
* shell after one KB read would gut its read-style diagnostic use (git/grep/ls).
|
|
101
|
+
*
|
|
102
|
+
* Skips when: the flag is off, the caller is not an agent, the caller is the
|
|
103
|
+
* recovery bot, or there is no session id — there is no named path here to fail
|
|
104
|
+
* closed on, and with no session there is no touched set to evaluate.
|
|
105
|
+
*
|
|
106
|
+
* Like {@link assertOntologyWriteAllowed}, the refusal itself is the
|
|
107
|
+
* enterprise-registered `preWrite` hook's (it evaluates the touched set and
|
|
108
|
+
* throws); core registers none, so shell is never refused in a core-only
|
|
109
|
+
* deployment.
|
|
110
|
+
*/
|
|
111
|
+
export declare function assertShellAllowedWithinOntology(gate: SessionOntologyGate, ctx: ToolContext): Promise<void>;
|
|
112
|
+
//# sourceMappingURL=session-ontology.gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-ontology.gate.d.ts","sourceRoot":"","sources":["../../../src/modules/workspace/session-ontology.gate.ts"],"names":[],"mappings":"AAAA;;;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AAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAOjH"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ontology-session boundary — the per-call gate used by the agent tool handlers.
|
|
3
|
+
*
|
|
4
|
+
* One decision fn, called by every gated file/graph handler:
|
|
5
|
+
* READS (isWrite=false) record the touched ontology and always allow.
|
|
6
|
+
* WRITES (isWrite=true) run the registered BLOCKING `preWrite` hooks
|
|
7
|
+
* (`WorkflowHooks`), then record. The core registers
|
|
8
|
+
* no hook, so core alone only TRACKS; the enterprise
|
|
9
|
+
* overlay registers the ontology block (see
|
|
10
|
+
* `modules/kb/ontology-block.hook.ts`), restoring
|
|
11
|
+
* "allowed only while the session is confined to a
|
|
12
|
+
* single ontology; once it has touched ≥2, all
|
|
13
|
+
* writes are blocked".
|
|
14
|
+
*
|
|
15
|
+
* Skips entirely when: the flag is off, the path is neutral (`ontologyOf` →
|
|
16
|
+
* null), the caller is not an agent, or the caller is the recovery bot. Fails
|
|
17
|
+
* CLOSED for an agent named-path operation that carries no `sessionId`.
|
|
18
|
+
*
|
|
19
|
+
* Lives beside `assertCanRead` in the workspace tools — it does NOT touch
|
|
20
|
+
* `acquireLock` (that gate is protected-branch-only; this boundary applies on
|
|
21
|
+
* all branches and to reads). See `docs/rp4-ontology-boundary-plan-v2.md`.
|
|
22
|
+
*/
|
|
23
|
+
import { ontologyOf } from '../../shared/kb-layout.js';
|
|
24
|
+
import { ToolError } from '../tool-helpers/tool.contract.js';
|
|
25
|
+
/**
|
|
26
|
+
* The `sessionId` input the ontology-session boundary reads: the agent run /
|
|
27
|
+
* conversation id. The in-process agent supplies its thread id automatically
|
|
28
|
+
* (via its per-run internal token); an external agent has no ambient run id,
|
|
29
|
+
* so it must first mint one with the `start_session` tool and then pass it
|
|
30
|
+
* EXPLICITLY on every gated call — the MCP proxy is a pure passthrough and
|
|
31
|
+
* never injects args.
|
|
32
|
+
*/
|
|
33
|
+
export const SESSION_ID_INPUT = {
|
|
34
|
+
type: 'string',
|
|
35
|
+
description: 'The KnowledgeBase session id that scopes this run to one ontology. External agents (direct MCP calls and `call_tool_chain` alike): call the `start_session` tool ONCE at the very start of your work to obtain it, then pass that id here on EVERY gated call. The in-process agent runtime supplies this automatically (do not set it yourself).',
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Boundary warning appended to ontology-gated tool descriptions so the agent
|
|
39
|
+
* knows the restriction before it calls one. Action-then-why phrasing per
|
|
40
|
+
* docs/glossary.md.
|
|
41
|
+
*/
|
|
42
|
+
export const ONTOLOGY_BOUNDARY_NOTE = ' Stay within one KnowledgeBase ontology per conversation: once this run has read or written files in two different ontologies, every later content write (write_file/edit_file/mkdir/unzip, and both endpoints of move_file/copy_file) is blocked with a 403 and no override. Reads and delete_file never block — but each one records the ontology it touched and can poison a later content write, so do broad cross-ontology exploration only when you do not intend to write. Note move_file/copy_file are blocked outright when source and destination are different ontologies, since they would carry content across.';
|
|
43
|
+
/** Thrown when a write is refused because the session has crossed ontologies. */
|
|
44
|
+
export class OntologyWriteBlockedError extends ToolError {
|
|
45
|
+
constructor(touched, attempted, reason) {
|
|
46
|
+
const msg = reason === 'multi-ontology'
|
|
47
|
+
? `This conversation has already read across multiple ontologies (${touched.join(', ')}), so writing is no longer allowed. Start a new conversation to write to "${attempted}".`
|
|
48
|
+
: `This conversation is working in ${touched.join(', ')}, so it can't write to a different ontology ("${attempted}"). Start a new conversation to work in "${attempted}".`;
|
|
49
|
+
super(msg, 403);
|
|
50
|
+
this.name = 'OntologyWriteBlockedError';
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** Thrown when an agent op on a named ontology carries no session id (fail closed). */
|
|
54
|
+
export class MissingSessionError extends ToolError {
|
|
55
|
+
constructor() {
|
|
56
|
+
super('This operation needs a KnowledgeBase session id and none was provided. Call the `start_session` tool once at the start of your work to obtain a sessionId, then pass it explicitly as `sessionId` on every gated call (direct MCP calls and `call_tool_chain` alike).', 403);
|
|
57
|
+
this.name = 'MissingSessionError';
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** Only internal/external agent callers are gated; `session` (browser JWT) and humans are not. */
|
|
61
|
+
function isAgentSource(ctx) {
|
|
62
|
+
return ctx.source === 'internal' || ctx.source === 'external';
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Shared gate preamble for the two per-path operations below. Returns `'skip'`
|
|
66
|
+
* when the boundary doesn't apply to this call (flag off, neutral path,
|
|
67
|
+
* non-agent caller, or recovery bot), otherwise the session id to evaluate
|
|
68
|
+
* against — throwing `MissingSessionError` (fail closed) when an agent op on a
|
|
69
|
+
* named ontology carries none.
|
|
70
|
+
*/
|
|
71
|
+
function resolveGatedSession(gate, ctx, wsPath) {
|
|
72
|
+
if (!gate.enabled)
|
|
73
|
+
return 'skip';
|
|
74
|
+
// Neutral paths never pin/record/block — skip before any identity work.
|
|
75
|
+
if (ontologyOf(wsPath, gate.kbDirName) === null)
|
|
76
|
+
return 'skip';
|
|
77
|
+
// Humans (UI routes) and browser-JWT callers never hit these tools; only
|
|
78
|
+
// agent tool calls are gated.
|
|
79
|
+
if (!isAgentSource(ctx))
|
|
80
|
+
return 'skip';
|
|
81
|
+
// The recovery/merge bot legitimately spans ontologies — exempt by identity.
|
|
82
|
+
if (ctx.user.email.toLowerCase() === gate.recoveryBotEmail)
|
|
83
|
+
return 'skip';
|
|
84
|
+
// Fail closed: an agent operation on a named ontology must carry a session id.
|
|
85
|
+
if (!ctx.sessionId)
|
|
86
|
+
throw new MissingSessionError();
|
|
87
|
+
return ctx.sessionId;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Record a read of `wsPath`'s ontology into the session's touched set. Reads are
|
|
91
|
+
* always allowed — recording is the only effect — but each one widens the
|
|
92
|
+
* touched set and so can poison a later write (see {@link assertOntologyWriteAllowed}).
|
|
93
|
+
* Fails closed (`MissingSessionError`) for an agent read of a named ontology
|
|
94
|
+
* with no session id.
|
|
95
|
+
*/
|
|
96
|
+
export async function recordOntologyRead(gate, ctx, wsPath) {
|
|
97
|
+
const sessionId = resolveGatedSession(gate, ctx, wsPath);
|
|
98
|
+
if (sessionId === 'skip')
|
|
99
|
+
return;
|
|
100
|
+
// checkOperation(isWrite=false) records the touch and always allows.
|
|
101
|
+
await gate.service.checkOperation(sessionId, wsPath, false, gate.kbDirName);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Assert a write to `wsPath` is allowed, then record it. A write that would
|
|
105
|
+
* carry information into a second ontology is the thing the boundary blocks:
|
|
106
|
+
* permitted only while the session stays confined to the target ontology, and
|
|
107
|
+
* refused with `OntologyWriteBlockedError` once it has touched ≥2. Note `delete`
|
|
108
|
+
* is NOT a write here — removing a node propagates no cross-ontology
|
|
109
|
+
* information, so it goes through {@link recordOntologyRead}.
|
|
110
|
+
*
|
|
111
|
+
* The BLOCKING decision itself lives behind the `preWrite` hooks: the
|
|
112
|
+
* enterprise-registered ontology block evaluates-and-records atomically via
|
|
113
|
+
* `checkOperation(isWrite=true)` and throws to refuse (identical behavior to
|
|
114
|
+
* the previous in-gate decision). Core registers no hook, so with none the
|
|
115
|
+
* write is allowed and only the touch is recorded (tracking stays core). The
|
|
116
|
+
* follow-up read-record after the hooks is idempotent — a no-op when a hook
|
|
117
|
+
* already recorded the allowed write.
|
|
118
|
+
*/
|
|
119
|
+
export async function assertOntologyWriteAllowed(gate, ctx, wsPath) {
|
|
120
|
+
const sessionId = resolveGatedSession(gate, ctx, wsPath);
|
|
121
|
+
if (sessionId === 'skip')
|
|
122
|
+
return;
|
|
123
|
+
await gate.hooks.runPreWrite({ kind: 'file-write', sessionId, wsPath });
|
|
124
|
+
// Tracking stays core: record the (now-allowed) write's ontology touch.
|
|
125
|
+
// A blocked write never reaches this line, so it records nothing — same as
|
|
126
|
+
// before the hook split.
|
|
127
|
+
await gate.service.checkOperation(sessionId, wsPath, false, gate.kbDirName);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Session-level write-eligibility gate for write-capable tools that have no
|
|
131
|
+
* single resolvable target path to check per-call — currently `execute_command`
|
|
132
|
+
* (arbitrary shell). Such a tool cannot be path-confined, so we enforce the
|
|
133
|
+
* boundary at the coarser session level: once the run has crossed into ≥2
|
|
134
|
+
* ontologies (the point at which EVERY path-checked write is already refused),
|
|
135
|
+
* we refuse the tool outright, so shell can't become a write path around the
|
|
136
|
+
* boundary. A fresh or single-ontology session is still allowed; a residual gap
|
|
137
|
+
* remains (a single-ontology session could shell-write a *different* ontology),
|
|
138
|
+
* accepted because arbitrary shell cannot be path-confined and blocking all
|
|
139
|
+
* shell after one KB read would gut its read-style diagnostic use (git/grep/ls).
|
|
140
|
+
*
|
|
141
|
+
* Skips when: the flag is off, the caller is not an agent, the caller is the
|
|
142
|
+
* recovery bot, or there is no session id — there is no named path here to fail
|
|
143
|
+
* closed on, and with no session there is no touched set to evaluate.
|
|
144
|
+
*
|
|
145
|
+
* Like {@link assertOntologyWriteAllowed}, the refusal itself is the
|
|
146
|
+
* enterprise-registered `preWrite` hook's (it evaluates the touched set and
|
|
147
|
+
* throws); core registers none, so shell is never refused in a core-only
|
|
148
|
+
* deployment.
|
|
149
|
+
*/
|
|
150
|
+
export async function assertShellAllowedWithinOntology(gate, ctx) {
|
|
151
|
+
if (!gate.enabled)
|
|
152
|
+
return;
|
|
153
|
+
if (!isAgentSource(ctx))
|
|
154
|
+
return;
|
|
155
|
+
if (ctx.user.email.toLowerCase() === gate.recoveryBotEmail)
|
|
156
|
+
return;
|
|
157
|
+
if (!ctx.sessionId)
|
|
158
|
+
return;
|
|
159
|
+
await gate.hooks.runPreWrite({ kind: 'shell', sessionId: ctx.sessionId });
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=session-ontology.gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-ontology.gate.js","sourceRoot":"","sources":["../../../src/modules/workspace/session-ontology.gate.ts"],"names":[],"mappings":"AAAA;;;;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AC,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,gCAAgC,CAAC,IAAyB,EAAE,GAAgB;IAChG,IAAI,CAAC,IAAI,CAAC,OAAO;QAAE,OAAO;IAC1B,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;QAAE,OAAO;IAChC,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,gBAAgB;QAAE,OAAO;IACnE,IAAI,CAAC,GAAG,CAAC,SAAS;QAAE,OAAO;IAE3B,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC;AAC5E,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Port behind `start_session` (workspace.tools.ts): mints the session id an
|
|
3
|
+
* external agent scopes its ontology boundary under. The workspace module owns
|
|
4
|
+
* the port; WHAT backs the id is the composition root's choice:
|
|
5
|
+
*
|
|
6
|
+
* - Core default ({@link UuidSessionSink}): a bare random id — sufficient for
|
|
7
|
+
* the session-ontology gate, with no app-side session record.
|
|
8
|
+
* - The enterprise app substitutes a sink that mints a REAL chat thread, so the
|
|
9
|
+
* same id also works end to end with `ask` (its sessionId IS a chat thread).
|
|
10
|
+
* See the `start_session` comment in workspace.tools.ts for why that
|
|
11
|
+
* unification matters.
|
|
12
|
+
*/
|
|
13
|
+
export interface ISessionSink {
|
|
14
|
+
/** Mint a session id for an external agent run started at `startedAt`. */
|
|
15
|
+
createSession(userId: string, startedAt: Date): Promise<{
|
|
16
|
+
sessionId: string;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
/** Core default: a bare random id — no app-side session record. */
|
|
20
|
+
export declare class UuidSessionSink implements ISessionSink {
|
|
21
|
+
createSession(): Promise<{
|
|
22
|
+
sessionId: string;
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=session-sink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-sink.d.ts","sourceRoot":"","sources":["../../../src/modules/workspace/session-sink.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,YAAY;IAC3B,0EAA0E;IAC1E,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChF;AAED,mEAAmE;AACnE,qBAAa,eAAgB,YAAW,YAAY;IAC5C,aAAa,IAAI,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CAGtD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-sink.js","sourceRoot":"","sources":["../../../src/modules/workspace/session-sink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAmBzC,mEAAmE;AACnE,MAAM,OAAO,eAAe;IAC1B,KAAK,CAAC,aAAa;QACjB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,CAAC;IACrC,CAAC;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare class SpillStore {
|
|
2
|
+
private readonly root;
|
|
3
|
+
constructor(root: string);
|
|
4
|
+
/** Is this `read_file` path a spill ref rather than a workspace-relative path? */
|
|
5
|
+
isSpillRef(p: string): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Park `content` and return the ref to read it back with. The ref is what an
|
|
8
|
+
* agent passes to `read_file` (its `branch` is ignored for spill reads).
|
|
9
|
+
*/
|
|
10
|
+
write(content: string): Promise<{
|
|
11
|
+
ref: string;
|
|
12
|
+
bytes: number;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Read a spill back by ref, optionally a byte window `[offset, offset+limit)`.
|
|
16
|
+
* The window is range-read straight off disk (`createReadStream` with
|
|
17
|
+
* `start`/`end`), so a multi-MB spill never lands in memory just to return a
|
|
18
|
+
* slice. Throws if the ref is malformed or the spill has been GC'd.
|
|
19
|
+
*/
|
|
20
|
+
read(ref: string, offset?: number, limit?: number): Promise<string>;
|
|
21
|
+
/** Best-effort prune of spills older than the TTL. Never throws. */
|
|
22
|
+
private gc;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=spill-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spill-store.d.ts","sourceRoot":"","sources":["../../../src/modules/workspace/spill-store.ts"],"names":[],"mappings":"AAoBA,qBAAa,UAAU;IACT,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,MAAM;IAEzC,kFAAkF;IAClF,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO;IAI9B;;;OAGG;IACG,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAQrE;;;;;OAKG;IACG,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAiBzE,oEAAoE;YACtD,EAAE;CAkBjB"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { createReadStream, promises as fs } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* Global store for `call_tool_chain` spill files. When a tool-chain result is too
|
|
5
|
+
* large to return inline, the full JSON is parked here — OUTSIDE any workspace,
|
|
6
|
+
* in a single shared directory (`config.spillRoot`, sibling of `workspacesRoot`) —
|
|
7
|
+
* so any agent, in-process or external over MCP, can read it back regardless of
|
|
8
|
+
* which branch's workspace (if any) it is operating on.
|
|
9
|
+
*
|
|
10
|
+
* Read-back is via the regular `read_file` tool: a spill is addressed by a
|
|
11
|
+
* reserved, workspace-independent ref (`__tool_chain_spill__/<id>.json`) that
|
|
12
|
+
* `read_file` recognises and resolves here instead of against a workspace
|
|
13
|
+
* filesystem. Files are ephemeral and never committed; each write best-effort
|
|
14
|
+
* prunes entries older than the TTL so the directory can't grow without bound.
|
|
15
|
+
*/
|
|
16
|
+
const SPILL_PREFIX = '__tool_chain_spill__/';
|
|
17
|
+
const TTL_MS = 24 * 60 * 60 * 1000; // 24h
|
|
18
|
+
const ID_RE = /^[A-Za-z0-9._-]+$/; // no path separators — keeps reads inside the root
|
|
19
|
+
export class SpillStore {
|
|
20
|
+
root;
|
|
21
|
+
constructor(root) {
|
|
22
|
+
this.root = root;
|
|
23
|
+
}
|
|
24
|
+
/** Is this `read_file` path a spill ref rather than a workspace-relative path? */
|
|
25
|
+
isSpillRef(p) {
|
|
26
|
+
return p.startsWith(SPILL_PREFIX);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Park `content` and return the ref to read it back with. The ref is what an
|
|
30
|
+
* agent passes to `read_file` (its `branch` is ignored for spill reads).
|
|
31
|
+
*/
|
|
32
|
+
async write(content) {
|
|
33
|
+
await fs.mkdir(this.root, { recursive: true });
|
|
34
|
+
void this.gc();
|
|
35
|
+
const id = `tool-chain-${new Date().toISOString().replace(/[:.]/g, '-')}-${randomSuffix()}.json`;
|
|
36
|
+
await fs.writeFile(path.join(this.root, id), content, 'utf8');
|
|
37
|
+
return { ref: SPILL_PREFIX + id, bytes: Buffer.byteLength(content, 'utf8') };
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Read a spill back by ref, optionally a byte window `[offset, offset+limit)`.
|
|
41
|
+
* The window is range-read straight off disk (`createReadStream` with
|
|
42
|
+
* `start`/`end`), so a multi-MB spill never lands in memory just to return a
|
|
43
|
+
* slice. Throws if the ref is malformed or the spill has been GC'd.
|
|
44
|
+
*/
|
|
45
|
+
async read(ref, offset, limit) {
|
|
46
|
+
const id = ref.slice(SPILL_PREFIX.length);
|
|
47
|
+
if (!ID_RE.test(id))
|
|
48
|
+
throw new Error(`Invalid spill ref "${ref}".`);
|
|
49
|
+
if (typeof limit === 'number' && limit <= 0)
|
|
50
|
+
return '';
|
|
51
|
+
const start = typeof offset === 'number' && offset > 0 ? offset : 0;
|
|
52
|
+
// `end` is INCLUSIVE in createReadStream, so [start, start+limit).
|
|
53
|
+
const end = typeof limit === 'number' ? start + limit - 1 : undefined;
|
|
54
|
+
const filePath = path.join(this.root, id);
|
|
55
|
+
return new Promise((resolve, reject) => {
|
|
56
|
+
const chunks = [];
|
|
57
|
+
const stream = createReadStream(filePath, end !== undefined ? { start, end } : { start });
|
|
58
|
+
stream.on('data', (c) => chunks.push(c));
|
|
59
|
+
stream.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
|
|
60
|
+
stream.on('error', reject);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/** Best-effort prune of spills older than the TTL. Never throws. */
|
|
64
|
+
async gc() {
|
|
65
|
+
try {
|
|
66
|
+
const now = Date.now();
|
|
67
|
+
const names = await fs.readdir(this.root);
|
|
68
|
+
await Promise.all(names.map(async (name) => {
|
|
69
|
+
try {
|
|
70
|
+
const stat = await fs.stat(path.join(this.root, name));
|
|
71
|
+
if (now - stat.mtimeMs > TTL_MS)
|
|
72
|
+
await fs.rm(path.join(this.root, name), { force: true });
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// file vanished mid-sweep / unreadable — ignore
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
// root not yet created or unreadable — nothing to prune
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function randomSuffix() {
|
|
85
|
+
return Math.random().toString(36).slice(2, 8);
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=spill-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spill-store.js","sourceRoot":"","sources":["../../../src/modules/workspace/spill-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;;;;;;;;;;GAYG;AACH,MAAM,YAAY,GAAG,uBAAuB,CAAC;AAC7C,MAAM,MAAM,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,MAAM;AAC1C,MAAM,KAAK,GAAG,mBAAmB,CAAC,CAAC,mDAAmD;AAEtF,MAAM,OAAO,UAAU;IACQ;IAA7B,YAA6B,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAE7C,kFAAkF;IAClF,UAAU,CAAC,CAAS;QAClB,OAAO,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,KAAK,CAAC,OAAe;QACzB,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,KAAK,IAAI,CAAC,EAAE,EAAE,CAAC;QACf,MAAM,EAAE,GAAG,cAAc,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,YAAY,EAAE,OAAO,CAAC;QACjG,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAC9D,OAAO,EAAE,GAAG,EAAE,YAAY,GAAG,EAAE,EAAE,KAAK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software/platform-shared';
|
|
3
|
+
import type { WorkspaceService } from './workspace.service.js';
|
|
4
|
+
import type { AuthService } from '../auth/auth.service.js';
|
|
5
|
+
import type { IAccessControl } from '../access/access-control.interface.js';
|
|
6
|
+
import type { ICreatorAccess } from '../access/creator-access.js';
|
|
7
|
+
import type { WorkflowEventBus } from '../workflow/event-bus.js';
|
|
8
|
+
import '../auth/auth.middleware.js';
|
|
9
|
+
/**
|
|
10
|
+
* Workspaces are per-branch (PLAN §3). Any authenticated user can access
|
|
11
|
+
* any branch's workspace; coordination of concurrent edits lives in the
|
|
12
|
+
* file-lock service, not in giving each user their own clone. We therefore
|
|
13
|
+
* gate every handler on authentication only — there is no "this is my
|
|
14
|
+
* workspace" ownership check.
|
|
15
|
+
*
|
|
16
|
+
* Every file-mutating route on this surface — `PUT /file`, `DELETE /file`,
|
|
17
|
+
* `PATCH /file` (move), `POST /directory`, `POST /upload`, `POST /unzip` —
|
|
18
|
+
* routes its write through `withLock(path, op)`: acquire the per-file
|
|
19
|
+
* workflow lock, perform the op, then release. The release commits the
|
|
20
|
+
* file as a one-file change attributed to the user and pushes it to origin,
|
|
21
|
+
* exactly like the lock-aware filesystem the agent writes through. There
|
|
22
|
+
* is no separate "share" step; save and share are fused.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createWorkspaceRoutes(workspaceService: WorkspaceService, authService: AuthService, workflowService: IWorkflowService, eventBus: WorkflowEventBus, accessControl: IAccessControl, kbDirName: string, creatorAccess: ICreatorAccess): express.Router;
|
|
25
|
+
//# sourceMappingURL=workspace.routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.routes.d.ts","sourceRoot":"","sources":["../../../src/modules/workspace/workspace.routes.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAY,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAYlF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAE5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,4BAA4B,CAAC;AAIpC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CACnC,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,gBAAgB,EACjC,QAAQ,EAAE,gBAAgB,EAC1B,aAAa,EAAE,cAAc,EAC7B,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,cAAc,GAC5B,OAAO,CAAC,MAAM,CAq+BhB"}
|