@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,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Background worker that drains the `pending_commits` queue: claims a row,
|
|
3
|
+
* runs `commitFile + pushWithRecovery` against the workspace, and either
|
|
4
|
+
* deletes the row (success) or schedules a retry (transient failure) or a
|
|
5
|
+
* recovery-agent run (exhausted transient budget). After the
|
|
6
|
+
* recovery-agent ceiling we escalate to a `'system'` feedback notice.
|
|
7
|
+
*
|
|
8
|
+
* Design context: `lock-decoupling-plan.md`.
|
|
9
|
+
*
|
|
10
|
+
* One worker per backend process; we don't currently run multi-replica
|
|
11
|
+
* backends, so a single drain loop is fine. The `claimNext` SQL uses
|
|
12
|
+
* `FOR UPDATE SKIP LOCKED` so a future multi-replica deployment can run
|
|
13
|
+
* multiple workers without double-processing rows.
|
|
14
|
+
*
|
|
15
|
+
* Concurrency: at most one commit in flight at a time across all
|
|
16
|
+
* workspaces. We could parallelise across workspaces (different
|
|
17
|
+
* `mutex.run` keys), but the current commit volume is comfortably
|
|
18
|
+
* sequential and the simpler shape catches more potential bugs.
|
|
19
|
+
*/
|
|
20
|
+
import type { AuthUser } from '@bevel-software/platform-shared';
|
|
21
|
+
import type { PendingCommitsService, WorkspaceDescriptor } from './pending-commits.service.js';
|
|
22
|
+
import { BACKOFF_MS, N_RECOVERY, N_TRANSIENT } from './pending-commits.service.js';
|
|
23
|
+
/**
|
|
24
|
+
* Where the worker escalates terminal failures — the narrow, workflow-owned
|
|
25
|
+
* slice of whatever notice sink the app provides. The enterprise app passes
|
|
26
|
+
* its feedback service (structurally compatible: its `send` accepts a wider
|
|
27
|
+
* source union); a core-only deployment can pass
|
|
28
|
+
* {@link consoleSystemNoticeSink}, which just logs.
|
|
29
|
+
*/
|
|
30
|
+
export interface ISystemNoticeSink {
|
|
31
|
+
send(notice: {
|
|
32
|
+
source: 'system';
|
|
33
|
+
user: {
|
|
34
|
+
id: string;
|
|
35
|
+
email: string;
|
|
36
|
+
name: string;
|
|
37
|
+
};
|
|
38
|
+
message: string;
|
|
39
|
+
}): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
/** Core default: terminal-failure notices go to stderr (no dashboard). */
|
|
42
|
+
export declare const consoleSystemNoticeSink: ISystemNoticeSink;
|
|
43
|
+
/**
|
|
44
|
+
* The recovery-agent dispatcher the worker calls when a row exhausts its
|
|
45
|
+
* transient budget. Pulled behind an interface so the unit tests can
|
|
46
|
+
* substitute a fake without bringing the entire BackgroundAgentFactory
|
|
47
|
+
* along.
|
|
48
|
+
*/
|
|
49
|
+
export interface RecoveryAgentRunner {
|
|
50
|
+
/**
|
|
51
|
+
* Kick off one recovery-agent run for a stuck pending commit. The
|
|
52
|
+
* agent's commits enqueue normal `pending_commits` rows that the
|
|
53
|
+
* worker drains on subsequent passes — that's how the recovery
|
|
54
|
+
* commits AND the original orphan both land.
|
|
55
|
+
*
|
|
56
|
+
* Implementations should await the agent's terminal step before
|
|
57
|
+
* returning so the worker's retry budget counts whole runs, not
|
|
58
|
+
* mid-stream tool calls.
|
|
59
|
+
*/
|
|
60
|
+
run(input: {
|
|
61
|
+
workspaceId: string;
|
|
62
|
+
branch: string;
|
|
63
|
+
path: string;
|
|
64
|
+
lastError: string;
|
|
65
|
+
originalAuthorEmail: string;
|
|
66
|
+
}): Promise<void>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Workflow surface the worker depends on. A subset of the real
|
|
70
|
+
* `WorkflowService` — pulled behind an interface so tests can stub the
|
|
71
|
+
* commit/push pipeline without spinning up a real git workspace.
|
|
72
|
+
*/
|
|
73
|
+
export interface WorkflowCommitDriver {
|
|
74
|
+
/**
|
|
75
|
+
* Commit whatever's currently on disk for `path`, then push the branch.
|
|
76
|
+
* Uses `pushWithRecovery` semantics internally (cooperative pull-rebase
|
|
77
|
+
* on non-FF). Throws when commit / push terminally fail; the worker
|
|
78
|
+
* catches and decides whether to retry or escalate.
|
|
79
|
+
*/
|
|
80
|
+
runPendingCommit(workspaceId: string, branch: string, path: string, user: AuthUser): Promise<void>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Source of workspaces to poll. The real implementation reads
|
|
84
|
+
* `WorkspaceService.branchDirs.keys()` — the in-memory cache of
|
|
85
|
+
* already-bootstrapped branches. Lazy-bootstrapped workspaces show up
|
|
86
|
+
* here as soon as `getOrCreateForBranch` resolves, so a freshly-touched
|
|
87
|
+
* branch's commits start draining within one poll interval.
|
|
88
|
+
*/
|
|
89
|
+
export interface WorkspaceProvider {
|
|
90
|
+
knownWorkspaces(): Iterable<WorkspaceDescriptor>;
|
|
91
|
+
}
|
|
92
|
+
export interface PendingCommitsWorkerDeps {
|
|
93
|
+
service: PendingCommitsService;
|
|
94
|
+
workflow: WorkflowCommitDriver;
|
|
95
|
+
recoveryAgent: RecoveryAgentRunner;
|
|
96
|
+
feedback: ISystemNoticeSink;
|
|
97
|
+
workspaces: WorkspaceProvider;
|
|
98
|
+
/**
|
|
99
|
+
* The synthetic identity used for `'system'` feedback notices when a
|
|
100
|
+
* row terminally fails. Author of the recovery commits themselves is
|
|
101
|
+
* the recovery agent's own configured user — that's a separate concern.
|
|
102
|
+
*/
|
|
103
|
+
recoveryBot: {
|
|
104
|
+
id: string;
|
|
105
|
+
email: string;
|
|
106
|
+
name: string;
|
|
107
|
+
};
|
|
108
|
+
/** Test seam — defaults to `Date.now`. */
|
|
109
|
+
now?: () => Date;
|
|
110
|
+
/** Test seam — defaults to `setTimeout` wrapped as a promise. */
|
|
111
|
+
sleep?: (ms: number) => Promise<void>;
|
|
112
|
+
}
|
|
113
|
+
export declare class PendingCommitsWorker {
|
|
114
|
+
private readonly deps;
|
|
115
|
+
private running;
|
|
116
|
+
private loopPromise;
|
|
117
|
+
private stopSignal;
|
|
118
|
+
constructor(deps: PendingCommitsWorkerDeps);
|
|
119
|
+
/**
|
|
120
|
+
* Start the drain loop. Idempotent — a second `start()` while the
|
|
121
|
+
* worker is already running is a no-op.
|
|
122
|
+
*/
|
|
123
|
+
start(): void;
|
|
124
|
+
/**
|
|
125
|
+
* Stop the drain loop. Awaits the in-flight pass (so a commit
|
|
126
|
+
* mid-flight gets to finish or fail naturally), then resolves.
|
|
127
|
+
* Idempotent.
|
|
128
|
+
*/
|
|
129
|
+
stop(): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* Run one drain pass: rotate through known workspaces, claim+process
|
|
132
|
+
* one row from each. Exposed publicly so tests can step the loop
|
|
133
|
+
* deterministically without driving `setTimeout`.
|
|
134
|
+
*/
|
|
135
|
+
drainOnce(): Promise<void>;
|
|
136
|
+
private runLoop;
|
|
137
|
+
private interruptibleSleep;
|
|
138
|
+
/**
|
|
139
|
+
* Process a single claimed row. Outcome paths (see plan §lifecycle):
|
|
140
|
+
* - commit + push succeeds → delete the row.
|
|
141
|
+
* - throws, transient budget remains → markTransientFailure.
|
|
142
|
+
* - throws, transient exhausted, recovery budget remains → spawn agent.
|
|
143
|
+
* - throws, recovery exhausted → markNeedsAttention + feedback notice.
|
|
144
|
+
*/
|
|
145
|
+
private processRow;
|
|
146
|
+
}
|
|
147
|
+
export { BACKOFF_MS, N_RECOVERY, N_TRANSIENT };
|
|
148
|
+
//# sourceMappingURL=pending-commits.worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pending-commits.worker.d.ts","sourceRoot":"","sources":["../../../src/modules/workflow/pending-commits.worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,KAAK,EAEV,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAGnF;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,EAAE,QAAQ,CAAC;QACjB,IAAI,EAAE;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC;QAClD,OAAO,EAAE,MAAM,CAAC;KACjB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnB;AAED,0EAA0E;AAC1E,eAAO,MAAM,uBAAuB,EAAE,iBAIrC,CAA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,UAAU,CAAwC;gBAE9C,IAAI,EAAE,wBAAwB;IAQ1C;;;OAGG;IACH,KAAK,IAAI,IAAI;IAMb;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAa3B;;;;OAIG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;YAWlB,OAAO;YAkBP,kBAAkB;IAUhC;;;;;;OAMG;YACW,UAAU;CAsFzB;AA8CD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Background worker that drains the `pending_commits` queue: claims a row,
|
|
3
|
+
* runs `commitFile + pushWithRecovery` against the workspace, and either
|
|
4
|
+
* deletes the row (success) or schedules a retry (transient failure) or a
|
|
5
|
+
* recovery-agent run (exhausted transient budget). After the
|
|
6
|
+
* recovery-agent ceiling we escalate to a `'system'` feedback notice.
|
|
7
|
+
*
|
|
8
|
+
* Design context: `lock-decoupling-plan.md`.
|
|
9
|
+
*
|
|
10
|
+
* One worker per backend process; we don't currently run multi-replica
|
|
11
|
+
* backends, so a single drain loop is fine. The `claimNext` SQL uses
|
|
12
|
+
* `FOR UPDATE SKIP LOCKED` so a future multi-replica deployment can run
|
|
13
|
+
* multiple workers without double-processing rows.
|
|
14
|
+
*
|
|
15
|
+
* Concurrency: at most one commit in flight at a time across all
|
|
16
|
+
* workspaces. We could parallelise across workspaces (different
|
|
17
|
+
* `mutex.run` keys), but the current commit volume is comfortably
|
|
18
|
+
* sequential and the simpler shape catches more potential bugs.
|
|
19
|
+
*/
|
|
20
|
+
import { BACKOFF_MS, N_RECOVERY, N_TRANSIENT } from './pending-commits.service.js';
|
|
21
|
+
import { sanitizeError } from './sanitize-error.js';
|
|
22
|
+
/** Core default: terminal-failure notices go to stderr (no dashboard). */
|
|
23
|
+
export const consoleSystemNoticeSink = {
|
|
24
|
+
async send(notice) {
|
|
25
|
+
console.error(`[system-notice] ${notice.user.email}: ${notice.message}`);
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Idle poll interval between drain sweeps. Half a second is short enough
|
|
30
|
+
* that the post-save commit lag is invisible to humans, long enough that
|
|
31
|
+
* an empty queue doesn't burn DB round-trips.
|
|
32
|
+
*/
|
|
33
|
+
const POLL_INTERVAL_MS = 500;
|
|
34
|
+
export class PendingCommitsWorker {
|
|
35
|
+
deps;
|
|
36
|
+
running = false;
|
|
37
|
+
loopPromise = null;
|
|
38
|
+
stopSignal = null;
|
|
39
|
+
constructor(deps) {
|
|
40
|
+
this.deps = {
|
|
41
|
+
...deps,
|
|
42
|
+
now: deps.now ?? (() => new Date()),
|
|
43
|
+
sleep: deps.sleep ?? defaultSleep,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Start the drain loop. Idempotent — a second `start()` while the
|
|
48
|
+
* worker is already running is a no-op.
|
|
49
|
+
*/
|
|
50
|
+
start() {
|
|
51
|
+
if (this.running)
|
|
52
|
+
return;
|
|
53
|
+
this.running = true;
|
|
54
|
+
this.loopPromise = this.runLoop();
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Stop the drain loop. Awaits the in-flight pass (so a commit
|
|
58
|
+
* mid-flight gets to finish or fail naturally), then resolves.
|
|
59
|
+
* Idempotent.
|
|
60
|
+
*/
|
|
61
|
+
async stop() {
|
|
62
|
+
if (!this.running)
|
|
63
|
+
return;
|
|
64
|
+
this.running = false;
|
|
65
|
+
// Unblock the sleep early so shutdown isn't gated on POLL_INTERVAL_MS.
|
|
66
|
+
if (this.stopSignal) {
|
|
67
|
+
const signal = this.stopSignal;
|
|
68
|
+
this.stopSignal = null;
|
|
69
|
+
signal();
|
|
70
|
+
}
|
|
71
|
+
await this.loopPromise;
|
|
72
|
+
this.loopPromise = null;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Run one drain pass: rotate through known workspaces, claim+process
|
|
76
|
+
* one row from each. Exposed publicly so tests can step the loop
|
|
77
|
+
* deterministically without driving `setTimeout`.
|
|
78
|
+
*/
|
|
79
|
+
async drainOnce() {
|
|
80
|
+
for (const workspace of this.deps.workspaces.knownWorkspaces()) {
|
|
81
|
+
// Bail mid-sweep if stop() fired — the in-flight workspace gets
|
|
82
|
+
// to finish but we don't start a new one.
|
|
83
|
+
if (!this.running)
|
|
84
|
+
return;
|
|
85
|
+
const row = await this.deps.service.claimNext(workspace.id, this.deps.now());
|
|
86
|
+
if (!row)
|
|
87
|
+
continue;
|
|
88
|
+
await this.processRow(row);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async runLoop() {
|
|
92
|
+
while (this.running) {
|
|
93
|
+
try {
|
|
94
|
+
await this.drainOnce();
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
// A throw out of drainOnce means something inside the loop
|
|
98
|
+
// itself failed — claimNext, processRow's outer scope, etc.
|
|
99
|
+
// Log loudly and keep looping; the next pass may succeed.
|
|
100
|
+
console.error('[pending-commits] worker loop iteration threw:', err instanceof Error ? err.stack ?? err.message : err);
|
|
101
|
+
}
|
|
102
|
+
if (!this.running)
|
|
103
|
+
break;
|
|
104
|
+
await this.interruptibleSleep(POLL_INTERVAL_MS);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async interruptibleSleep(ms) {
|
|
108
|
+
if (!this.running)
|
|
109
|
+
return;
|
|
110
|
+
await Promise.race([
|
|
111
|
+
this.deps.sleep(ms),
|
|
112
|
+
new Promise((resolve) => {
|
|
113
|
+
this.stopSignal = resolve;
|
|
114
|
+
}),
|
|
115
|
+
]);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Process a single claimed row. Outcome paths (see plan §lifecycle):
|
|
119
|
+
* - commit + push succeeds → delete the row.
|
|
120
|
+
* - throws, transient budget remains → markTransientFailure.
|
|
121
|
+
* - throws, transient exhausted, recovery budget remains → spawn agent.
|
|
122
|
+
* - throws, recovery exhausted → markNeedsAttention + feedback notice.
|
|
123
|
+
*/
|
|
124
|
+
async processRow(row) {
|
|
125
|
+
const user = {
|
|
126
|
+
// The worker doesn't have a real `users.id` for the commit author —
|
|
127
|
+
// commit attribution flows through `git commit --author="Name <email>"`,
|
|
128
|
+
// not through any FK. Drop a synthetic id so the AuthUser shape is
|
|
129
|
+
// satisfied without hitting the users table.
|
|
130
|
+
id: `pending-commit-author:${row.authorEmail}`,
|
|
131
|
+
email: row.authorEmail,
|
|
132
|
+
name: row.authorName,
|
|
133
|
+
};
|
|
134
|
+
try {
|
|
135
|
+
await this.deps.workflow.runPendingCommit(row.workspaceId, row.branch, row.path, user);
|
|
136
|
+
await this.deps.service.markSucceeded(row.id);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
catch (err) {
|
|
140
|
+
// Sanitize once at the source: this string flows into the DB
|
|
141
|
+
// (`pending_commits.last_error`), stdout logs, the recovery-agent
|
|
142
|
+
// LLM prompt, AND the user-facing feedback notice. Git stderr can
|
|
143
|
+
// contain credentialed URLs ("https://x-access-token:ghp_…@…"); we
|
|
144
|
+
// can't undo a persisted leak, so mask before any of them sees it.
|
|
145
|
+
const message = sanitizeError(err);
|
|
146
|
+
const nextAttempts = row.attempts + 1;
|
|
147
|
+
if (nextAttempts < N_TRANSIENT) {
|
|
148
|
+
// Transient — back off and retry on the next sweep that finds
|
|
149
|
+
// the backoff elapsed.
|
|
150
|
+
await this.deps.service.markTransientFailure(row.id, message);
|
|
151
|
+
console.warn(`[pending-commits] transient failure ws=${row.workspaceId} branch=${row.branch} path=${row.path} attempt=${nextAttempts}/${N_TRANSIENT}: ${message}`);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (row.recoveryAgentRuns < N_RECOVERY) {
|
|
155
|
+
// Transient budget exhausted — hand off to the recovery agent.
|
|
156
|
+
// markRecoveryStarted resets `attempts` so the post-recovery
|
|
157
|
+
// commits get a fresh transient budget.
|
|
158
|
+
await this.deps.service.markRecoveryStarted(row.id);
|
|
159
|
+
console.warn(`[pending-commits] transient budget exhausted ws=${row.workspaceId} branch=${row.branch} path=${row.path}; spawning recovery agent (run ${row.recoveryAgentRuns + 1}/${N_RECOVERY}): ${message}`);
|
|
160
|
+
try {
|
|
161
|
+
await this.deps.recoveryAgent.run({
|
|
162
|
+
workspaceId: row.workspaceId,
|
|
163
|
+
branch: row.branch,
|
|
164
|
+
path: row.path,
|
|
165
|
+
lastError: message,
|
|
166
|
+
originalAuthorEmail: row.authorEmail,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
catch (agentErr) {
|
|
170
|
+
// The recovery agent itself crashed (rare — would mean broken
|
|
171
|
+
// codemode wiring, missing deps, etc.). Treat it the same as
|
|
172
|
+
// the agent finishing without resolving the issue — the row
|
|
173
|
+
// stays `pending` and the next worker pass will hit the same
|
|
174
|
+
// underlying error or escalate after another recovery cycle.
|
|
175
|
+
console.error(`[pending-commits] recovery agent threw for ws=${row.workspaceId} path=${row.path}:`, sanitizeError(agentErr));
|
|
176
|
+
}
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
// Recovery budget exhausted — escalate.
|
|
180
|
+
await this.deps.service.markNeedsAttention(row.id, message);
|
|
181
|
+
console.error(`[pending-commits] TERMINAL ws=${row.workspaceId} branch=${row.branch} path=${row.path} after ${N_RECOVERY} recovery runs: ${message}`);
|
|
182
|
+
try {
|
|
183
|
+
await this.deps.feedback.send({
|
|
184
|
+
source: 'system',
|
|
185
|
+
user: this.deps.recoveryBot,
|
|
186
|
+
message: terminalFailureNotice(row, message),
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
catch (feedbackErr) {
|
|
190
|
+
// Don't let a feedback-sink hiccup mask the underlying terminal
|
|
191
|
+
// failure — the row is already `needs_attention` and the next
|
|
192
|
+
// process restart will keep logging it. Just note that the
|
|
193
|
+
// notice didn't reach the dashboard.
|
|
194
|
+
console.error(`[pending-commits] failed to emit terminal-failure feedback notice for ws=${row.workspaceId} path=${row.path}:`, sanitizeError(feedbackErr));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function terminalFailureNotice(row, error) {
|
|
200
|
+
const elapsedMs = Date.now() - row.queuedAt.getTime();
|
|
201
|
+
const elapsed = formatElapsed(elapsedMs);
|
|
202
|
+
return [
|
|
203
|
+
`[pending_commits] Terminal commit failure after ${N_RECOVERY} recovery attempts.`,
|
|
204
|
+
'',
|
|
205
|
+
`Workspace: ${row.workspaceId}`,
|
|
206
|
+
`Branch: ${row.branch}`,
|
|
207
|
+
`Path: ${row.path}`,
|
|
208
|
+
`Original author: ${row.authorEmail}`,
|
|
209
|
+
`Queued at: ${row.queuedAt.toISOString()} (${elapsed} ago)`,
|
|
210
|
+
`Last error: ${error}`,
|
|
211
|
+
'',
|
|
212
|
+
"This file's bytes are on disk in the workspace but have never been",
|
|
213
|
+
'committed to git. The recovery agent attempted to fix the underlying',
|
|
214
|
+
`issue ${N_RECOVERY} times without success.`,
|
|
215
|
+
'',
|
|
216
|
+
'Investigate manually:',
|
|
217
|
+
' - shell into the deployment, cd into the workspace dir',
|
|
218
|
+
" - inspect `git status` and the file's on-disk state",
|
|
219
|
+
' - either commit the file manually (after fixing the underlying issue)',
|
|
220
|
+
' or delete the row from pending_commits if the file should be',
|
|
221
|
+
' discarded.',
|
|
222
|
+
].join('\n');
|
|
223
|
+
}
|
|
224
|
+
function formatElapsed(ms) {
|
|
225
|
+
if (ms < 1000)
|
|
226
|
+
return `${ms}ms`;
|
|
227
|
+
const s = Math.floor(ms / 1000);
|
|
228
|
+
if (s < 60)
|
|
229
|
+
return `${s}s`;
|
|
230
|
+
const m = Math.floor(s / 60);
|
|
231
|
+
if (m < 60)
|
|
232
|
+
return `${m}m`;
|
|
233
|
+
const h = Math.floor(m / 60);
|
|
234
|
+
if (h < 24)
|
|
235
|
+
return `${h}h`;
|
|
236
|
+
const d = Math.floor(h / 24);
|
|
237
|
+
return `${d}d`;
|
|
238
|
+
}
|
|
239
|
+
function defaultSleep(ms) {
|
|
240
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
241
|
+
}
|
|
242
|
+
// Re-exports so consumers can pull worker + constants from one place
|
|
243
|
+
// without reaching into the service file for the budgets.
|
|
244
|
+
export { BACKOFF_MS, N_RECOVERY, N_TRANSIENT };
|
|
245
|
+
//# sourceMappingURL=pending-commits.worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pending-commits.worker.js","sourceRoot":"","sources":["../../../src/modules/workflow/pending-commits.worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAQH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAiBpD,0EAA0E;AAC1E,MAAM,CAAC,MAAM,uBAAuB,GAAsB;IACxD,KAAK,CAAC,IAAI,CAAC,MAAM;QACf,OAAO,CAAC,KAAK,CAAC,mBAAmB,MAAM,CAAC,IAAI,CAAC,KAAK,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAC3E,CAAC;CACF,CAAC;AAEF;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,GAAG,CAAC;AA6E7B,MAAM,OAAO,oBAAoB;IACd,IAAI,CAEnB;IACM,OAAO,GAAG,KAAK,CAAC;IAChB,WAAW,GAAyB,IAAI,CAAC;IACzC,UAAU,GAAmC,IAAI,CAAC;IAE1D,YAAY,IAA8B;QACxC,IAAI,CAAC,IAAI,GAAG;YACV,GAAG,IAAI;YACP,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC;YACnC,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,YAAY;SAClC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,KAAK;QACH,IAAI,IAAI,CAAC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O,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,qEAAqE;AACrE,0DAA0D;AAC1D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { LocalFilesystem, type CopyOptions, type FileContent, type RemoveOptions, type WriteOptions } from '@mastra/core/workspace';
|
|
2
|
+
/**
|
|
3
|
+
* A `LocalFilesystem` that permits reads but refuses every mutating operation.
|
|
4
|
+
* Mastra hands the agent the workspace filesystem's tools (write_file /
|
|
5
|
+
* edit_file / delete / mkdir / move / copy); for consumer personas we hand it
|
|
6
|
+
* this instead so those tools exist but fail closed — the agent can read and
|
|
7
|
+
* explore the ontology, but cannot change it.
|
|
8
|
+
*
|
|
9
|
+
* The architect agent keeps the lock-aware `LockingFilesystem` (which commits +
|
|
10
|
+
* pushes); consumer agents get no write path at all.
|
|
11
|
+
*/
|
|
12
|
+
export declare class ReadOnlyFilesystem extends LocalFilesystem {
|
|
13
|
+
private static deny;
|
|
14
|
+
writeFile(_path: string, _content: FileContent, _options?: WriteOptions): Promise<void>;
|
|
15
|
+
appendFile(_path: string, _content: FileContent): Promise<void>;
|
|
16
|
+
deleteFile(_path: string, _options?: RemoveOptions): Promise<void>;
|
|
17
|
+
copyFile(_src: string, _dest: string, _options?: CopyOptions): Promise<void>;
|
|
18
|
+
moveFile(_src: string, _dest: string, _options?: CopyOptions): Promise<void>;
|
|
19
|
+
mkdir(_path: string, _options?: {
|
|
20
|
+
recursive?: boolean;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
rmdir(_path: string, _options?: RemoveOptions): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=read-only-filesystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-only-filesystem.d.ts","sourceRoot":"","sources":["../../../src/modules/workflow/read-only-filesystem.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;;;GASG;AACH,qBAAa,kBAAmB,SAAQ,eAAe;IACrD,OAAO,CAAC,MAAM,CAAC,IAAI;IAOJ,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvF,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/D,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5E,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5E,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvE,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAG7E"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { LocalFilesystem, } from '@mastra/core/workspace';
|
|
2
|
+
/**
|
|
3
|
+
* A `LocalFilesystem` that permits reads but refuses every mutating operation.
|
|
4
|
+
* Mastra hands the agent the workspace filesystem's tools (write_file /
|
|
5
|
+
* edit_file / delete / mkdir / move / copy); for consumer personas we hand it
|
|
6
|
+
* this instead so those tools exist but fail closed — the agent can read and
|
|
7
|
+
* explore the ontology, but cannot change it.
|
|
8
|
+
*
|
|
9
|
+
* The architect agent keeps the lock-aware `LockingFilesystem` (which commits +
|
|
10
|
+
* pushes); consumer agents get no write path at all.
|
|
11
|
+
*/
|
|
12
|
+
export class ReadOnlyFilesystem extends LocalFilesystem {
|
|
13
|
+
static deny(op) {
|
|
14
|
+
throw new Error(`This assistant is read-only — "${op}" is not allowed. ` +
|
|
15
|
+
`It can read and analyze the knowledge base, but cannot modify it.`);
|
|
16
|
+
}
|
|
17
|
+
async writeFile(_path, _content, _options) {
|
|
18
|
+
ReadOnlyFilesystem.deny('write_file');
|
|
19
|
+
}
|
|
20
|
+
async appendFile(_path, _content) {
|
|
21
|
+
ReadOnlyFilesystem.deny('append_file');
|
|
22
|
+
}
|
|
23
|
+
async deleteFile(_path, _options) {
|
|
24
|
+
ReadOnlyFilesystem.deny('delete_file');
|
|
25
|
+
}
|
|
26
|
+
async copyFile(_src, _dest, _options) {
|
|
27
|
+
ReadOnlyFilesystem.deny('copy_file');
|
|
28
|
+
}
|
|
29
|
+
async moveFile(_src, _dest, _options) {
|
|
30
|
+
ReadOnlyFilesystem.deny('move_file');
|
|
31
|
+
}
|
|
32
|
+
async mkdir(_path, _options) {
|
|
33
|
+
ReadOnlyFilesystem.deny('mkdir');
|
|
34
|
+
}
|
|
35
|
+
async rmdir(_path, _options) {
|
|
36
|
+
ReadOnlyFilesystem.deny('rmdir');
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=read-only-filesystem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-only-filesystem.js","sourceRoot":"","sources":["../../../src/modules/workflow/read-only-filesystem.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,GAKhB,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;;;GASG;AACH,MAAM,OAAO,kBAAmB,SAAQ,eAAe;IAC7C,MAAM,CAAC,IAAI,CAAC,EAAU;QAC5B,MAAM,IAAI,KAAK,CACb,kCAAkC,EAAE,oBAAoB;YACtD,mEAAmE,CACtE,CAAC;IACJ,CAAC;IAEQ,KAAK,CAAC,SAAS,CAAC,KAAa,EAAE,QAAqB,EAAE,QAAuB;QACpF,kBAAkB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACxC,CAAC;IAEQ,KAAK,CAAC,UAAU,CAAC,KAAa,EAAE,QAAqB;QAC5D,kBAAkB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACzC,CAAC;IAEQ,KAAK,CAAC,UAAU,CAAC,KAAa,EAAE,QAAwB;QAC/D,kBAAkB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACzC,CAAC;IAEQ,KAAK,CAAC,QAAQ,CAAC,IAAY,EAAE,KAAa,EAAE,QAAsB;QACzE,kBAAkB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC;IAEQ,KAAK,CAAC,QAAQ,CAAC,IAAY,EAAE,KAAa,EAAE,QAAsB;QACzE,kBAAkB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC;IAEQ,KAAK,CAAC,KAAK,CAAC,KAAa,EAAE,QAAkC;QACpE,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAEQ,KAAK,CAAC,KAAK,CAAC,KAAa,EAAE,QAAwB;QAC1D,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Synthetic user identity the pending-commits pipeline uses for:
|
|
3
|
+
*
|
|
4
|
+
* 1. The recovery agent's commit authorship — when the background
|
|
5
|
+
* agent resolves a non-FF conflict and lands a resolution commit,
|
|
6
|
+
* that commit needs an author. The recovery bot is a stable
|
|
7
|
+
* attribution that's clearly "the system" rather than any human.
|
|
8
|
+
* 2. The `'system'` feedback notice's `user_id` FK — feedback
|
|
9
|
+
* submissions reference `users(id)`, so we need a real row.
|
|
10
|
+
* 3. The startup-sweep enqueue of orphaned dirty files — those have
|
|
11
|
+
* no recoverable original author, and the recovery bot fits the
|
|
12
|
+
* "this is the system reconciling state" framing.
|
|
13
|
+
*
|
|
14
|
+
* Email convention mirrors the routine-bot pattern (`<role>-bot@<host>`)
|
|
15
|
+
* so admins can tell at a glance what an automation account is for. The
|
|
16
|
+
* `RECOVERY_BOT_EMAIL` env override mirrors `ROUTINE_BOT_EMAIL`.
|
|
17
|
+
*/
|
|
18
|
+
import type { AuthUser } from '@bevel-software/platform-shared';
|
|
19
|
+
import type { Database } from '../database/connection.js';
|
|
20
|
+
export declare const RECOVERY_BOT_EMAIL: string;
|
|
21
|
+
export declare const RECOVERY_BOT_NAME = "Bevel Recovery Bot";
|
|
22
|
+
/**
|
|
23
|
+
* Idempotent ensure-or-fetch of the recovery-bot user row. Modelled on
|
|
24
|
+
* `RoutineRunnerService.ensureBotUser` — same race-safe shape via
|
|
25
|
+
* `onConflictDoNothing` + re-select.
|
|
26
|
+
*
|
|
27
|
+
* Called once at composition-root boot; the resolved `AuthUser` is then
|
|
28
|
+
* cached for the lifetime of the process (the row never changes).
|
|
29
|
+
*/
|
|
30
|
+
export declare function ensureRecoveryBotUser(db: Database): Promise<AuthUser>;
|
|
31
|
+
//# sourceMappingURL=recovery-bot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recovery-bot.d.ts","sourceRoot":"","sources":["../../../src/modules/workflow/recovery-bot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAG1D,eAAO,MAAM,kBAAkB,QAEhB,CAAC;AAEhB,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AAEtD;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAmC3E"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Synthetic user identity the pending-commits pipeline uses for:
|
|
3
|
+
*
|
|
4
|
+
* 1. The recovery agent's commit authorship — when the background
|
|
5
|
+
* agent resolves a non-FF conflict and lands a resolution commit,
|
|
6
|
+
* that commit needs an author. The recovery bot is a stable
|
|
7
|
+
* attribution that's clearly "the system" rather than any human.
|
|
8
|
+
* 2. The `'system'` feedback notice's `user_id` FK — feedback
|
|
9
|
+
* submissions reference `users(id)`, so we need a real row.
|
|
10
|
+
* 3. The startup-sweep enqueue of orphaned dirty files — those have
|
|
11
|
+
* no recoverable original author, and the recovery bot fits the
|
|
12
|
+
* "this is the system reconciling state" framing.
|
|
13
|
+
*
|
|
14
|
+
* Email convention mirrors the routine-bot pattern (`<role>-bot@<host>`)
|
|
15
|
+
* so admins can tell at a glance what an automation account is for. The
|
|
16
|
+
* `RECOVERY_BOT_EMAIL` env override mirrors `ROUTINE_BOT_EMAIL`.
|
|
17
|
+
*/
|
|
18
|
+
import { eq } from 'drizzle-orm';
|
|
19
|
+
import { users } from '../database/schema.js';
|
|
20
|
+
export const RECOVERY_BOT_EMAIL = (process.env.RECOVERY_BOT_EMAIL ?? 'recovery-bot@bevel.local').toLowerCase();
|
|
21
|
+
export const RECOVERY_BOT_NAME = 'Bevel Recovery Bot';
|
|
22
|
+
/**
|
|
23
|
+
* Idempotent ensure-or-fetch of the recovery-bot user row. Modelled on
|
|
24
|
+
* `RoutineRunnerService.ensureBotUser` — same race-safe shape via
|
|
25
|
+
* `onConflictDoNothing` + re-select.
|
|
26
|
+
*
|
|
27
|
+
* Called once at composition-root boot; the resolved `AuthUser` is then
|
|
28
|
+
* cached for the lifetime of the process (the row never changes).
|
|
29
|
+
*/
|
|
30
|
+
export async function ensureRecoveryBotUser(db) {
|
|
31
|
+
const inserted = await db
|
|
32
|
+
.insert(users)
|
|
33
|
+
.values({ email: RECOVERY_BOT_EMAIL, name: RECOVERY_BOT_NAME })
|
|
34
|
+
.onConflictDoNothing({ target: users.email })
|
|
35
|
+
.returning();
|
|
36
|
+
if (inserted.length > 0) {
|
|
37
|
+
const row = inserted[0];
|
|
38
|
+
console.log(`[pending-commits] created recovery-bot user id=${row.id} email=${row.email}`);
|
|
39
|
+
return {
|
|
40
|
+
id: row.id,
|
|
41
|
+
email: row.email,
|
|
42
|
+
name: row.name,
|
|
43
|
+
avatarUrl: row.avatarUrl ?? undefined,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const [row] = await db
|
|
47
|
+
.select()
|
|
48
|
+
.from(users)
|
|
49
|
+
.where(eq(users.email, RECOVERY_BOT_EMAIL))
|
|
50
|
+
.limit(1);
|
|
51
|
+
if (!row) {
|
|
52
|
+
// Vanishingly unlikely: the row exists for the conflict to fire but is
|
|
53
|
+
// gone by the time we re-select. Surface loudly rather than crashing
|
|
54
|
+
// on `row.id` below.
|
|
55
|
+
throw new Error(`recovery-bot user (${RECOVERY_BOT_EMAIL}) disappeared between insert-conflict and re-select`);
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
id: row.id,
|
|
59
|
+
email: row.email,
|
|
60
|
+
name: row.name,
|
|
61
|
+
avatarUrl: row.avatarUrl ?? undefined,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=recovery-bot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recovery-bot.js","sourceRoot":"","sources":["../../../src/modules/workflow/recovery-bot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAGjC,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,MAAM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