slackhive 0.1.41 → 0.1.43
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/cli/dist/index.js +15786 -52
- package/package.json +9 -3
- package/.dockerignore +0 -14
- package/.env.example +0 -44
- package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -65
- package/.github/ISSUE_TEMPLATE/config.yml +0 -5
- package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -38
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -27
- package/.github/dependabot.yml +0 -20
- package/.github/workflows/audit.yml +0 -149
- package/.github/workflows/ci.yml +0 -135
- package/CHANGELOG.md +0 -52
- package/CODE_OF_CONDUCT.md +0 -37
- package/CONTRIBUTING.md +0 -204
- package/SECURITY.md +0 -47
- package/apps/runner/Dockerfile +0 -33
- package/apps/runner/dist/__tests__/channel-restrictions.test.d.ts +0 -8
- package/apps/runner/dist/__tests__/channel-restrictions.test.js +0 -63
- package/apps/runner/dist/__tests__/channel-restrictions.test.js.map +0 -1
- package/apps/runner/dist/__tests__/claude-handler-resolve.test.d.ts +0 -20
- package/apps/runner/dist/__tests__/claude-handler-resolve.test.js +0 -178
- package/apps/runner/dist/__tests__/claude-handler-resolve.test.js.map +0 -1
- package/apps/runner/dist/__tests__/compile-claude-md.test.d.ts +0 -13
- package/apps/runner/dist/__tests__/compile-claude-md.test.js +0 -144
- package/apps/runner/dist/__tests__/compile-claude-md.test.js.map +0 -1
- package/apps/runner/dist/__tests__/memory-sync.test.d.ts +0 -11
- package/apps/runner/dist/__tests__/memory-sync.test.js +0 -56
- package/apps/runner/dist/__tests__/memory-sync.test.js.map +0 -1
- package/apps/runner/dist/__tests__/slack-file-support.test.d.ts +0 -9
- package/apps/runner/dist/__tests__/slack-file-support.test.js +0 -271
- package/apps/runner/dist/__tests__/slack-file-support.test.js.map +0 -1
- package/apps/runner/dist/__tests__/slack-formatting.test.d.ts +0 -12
- package/apps/runner/dist/__tests__/slack-formatting.test.js +0 -400
- package/apps/runner/dist/__tests__/slack-formatting.test.js.map +0 -1
- package/apps/runner/dist/__tests__/thread-context.test.d.ts +0 -12
- package/apps/runner/dist/__tests__/thread-context.test.js +0 -182
- package/apps/runner/dist/__tests__/thread-context.test.js.map +0 -1
- package/apps/runner/dist/agent-runner.d.ts +0 -118
- package/apps/runner/dist/agent-runner.js +0 -352
- package/apps/runner/dist/agent-runner.js.map +0 -1
- package/apps/runner/dist/claude-handler.d.ts +0 -122
- package/apps/runner/dist/claude-handler.js +0 -402
- package/apps/runner/dist/claude-handler.js.map +0 -1
- package/apps/runner/dist/compile-claude-md.d.ts +0 -59
- package/apps/runner/dist/compile-claude-md.js +0 -291
- package/apps/runner/dist/compile-claude-md.js.map +0 -1
- package/apps/runner/dist/correction-handler.d.ts +0 -46
- package/apps/runner/dist/correction-handler.js +0 -162
- package/apps/runner/dist/correction-handler.js.map +0 -1
- package/apps/runner/dist/correction-manager.d.ts +0 -53
- package/apps/runner/dist/correction-manager.js +0 -241
- package/apps/runner/dist/correction-manager.js.map +0 -1
- package/apps/runner/dist/db.d.ts +0 -193
- package/apps/runner/dist/db.js +0 -492
- package/apps/runner/dist/db.js.map +0 -1
- package/apps/runner/dist/index.d.ts +0 -9
- package/apps/runner/dist/index.js +0 -43
- package/apps/runner/dist/index.js.map +0 -1
- package/apps/runner/dist/job-scheduler.d.ts +0 -57
- package/apps/runner/dist/job-scheduler.js +0 -150
- package/apps/runner/dist/job-scheduler.js.map +0 -1
- package/apps/runner/dist/logger.d.ts +0 -32
- package/apps/runner/dist/logger.js +0 -52
- package/apps/runner/dist/logger.js.map +0 -1
- package/apps/runner/dist/mcp-process-manager.d.ts +0 -38
- package/apps/runner/dist/mcp-process-manager.js +0 -189
- package/apps/runner/dist/mcp-process-manager.js.map +0 -1
- package/apps/runner/dist/memory-mcp.d.ts +0 -14
- package/apps/runner/dist/memory-mcp.js +0 -88
- package/apps/runner/dist/memory-mcp.js.map +0 -1
- package/apps/runner/dist/memory-watcher.d.ts +0 -78
- package/apps/runner/dist/memory-watcher.js +0 -220
- package/apps/runner/dist/memory-watcher.js.map +0 -1
- package/apps/runner/dist/slack-handler.d.ts +0 -120
- package/apps/runner/dist/slack-handler.js +0 -843
- package/apps/runner/dist/slack-handler.js.map +0 -1
- package/apps/runner/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/apps/runner/package.json +0 -42
- package/apps/runner/src/__tests__/channel-restrictions.test.ts +0 -75
- package/apps/runner/src/__tests__/claude-handler-resolve.test.ts +0 -160
- package/apps/runner/src/__tests__/compile-claude-md.test.ts +0 -139
- package/apps/runner/src/__tests__/memory-sync.test.ts +0 -59
- package/apps/runner/src/__tests__/slack-file-support.test.ts +0 -376
- package/apps/runner/src/__tests__/slack-formatting.test.ts +0 -495
- package/apps/runner/src/__tests__/thread-context.test.ts +0 -215
- package/apps/runner/src/agent-runner.ts +0 -397
- package/apps/runner/src/claude-handler.ts +0 -475
- package/apps/runner/src/compile-claude-md.ts +0 -283
- package/apps/runner/src/correction-handler.ts +0 -191
- package/apps/runner/src/correction-manager.ts +0 -285
- package/apps/runner/src/db.ts +0 -604
- package/apps/runner/src/index.ts +0 -46
- package/apps/runner/src/job-scheduler.ts +0 -165
- package/apps/runner/src/logger.ts +0 -49
- package/apps/runner/src/mcp-process-manager.ts +0 -195
- package/apps/runner/src/memory-mcp.ts +0 -85
- package/apps/runner/src/memory-watcher.ts +0 -215
- package/apps/runner/src/slack-handler.ts +0 -929
- package/apps/runner/tsconfig.json +0 -17
- package/apps/runner/vitest.config.mts +0 -17
- package/apps/web/.eslintrc.json +0 -3
- package/apps/web/.next/app-build-manifest.json +0 -323
- package/apps/web/.next/app-path-routes-manifest.json +0 -46
- package/apps/web/.next/build-manifest.json +0 -33
- package/apps/web/.next/cache/.previewinfo +0 -1
- package/apps/web/.next/cache/.rscinfo +0 -1
- package/apps/web/.next/cache/webpack/client-production/0.pack +0 -0
- package/apps/web/.next/cache/webpack/client-production/1.pack +0 -0
- package/apps/web/.next/cache/webpack/client-production/2.pack +0 -0
- package/apps/web/.next/cache/webpack/client-production/3.pack +0 -0
- package/apps/web/.next/cache/webpack/client-production/4.pack +0 -0
- package/apps/web/.next/cache/webpack/client-production/index.pack +0 -0
- package/apps/web/.next/cache/webpack/client-production/index.pack.old +0 -0
- package/apps/web/.next/cache/webpack/edge-server-production/0.pack +0 -0
- package/apps/web/.next/cache/webpack/edge-server-production/1.pack +0 -0
- package/apps/web/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/apps/web/.next/cache/webpack/edge-server-production/index.pack.old +0 -0
- package/apps/web/.next/cache/webpack/server-production/0.pack +0 -0
- package/apps/web/.next/cache/webpack/server-production/1.pack +0 -0
- package/apps/web/.next/cache/webpack/server-production/2.pack +0 -0
- package/apps/web/.next/cache/webpack/server-production/index.pack +0 -0
- package/apps/web/.next/cache/webpack/server-production/index.pack.old +0 -0
- package/apps/web/.next/diagnostics/build-diagnostics.json +0 -6
- package/apps/web/.next/diagnostics/framework.json +0 -1
- package/apps/web/.next/package.json +0 -1
- package/apps/web/.next/react-loadable-manifest.json +0 -1
- package/apps/web/.next/server/app/_not-found/page.js +0 -2
- package/apps/web/.next/server/app/_not-found/page.js.nft.json +0 -1
- package/apps/web/.next/server/app/_not-found/page_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/agents/[slug]/page.js +0 -4
- package/apps/web/.next/server/app/agents/[slug]/page.js.nft.json +0 -1
- package/apps/web/.next/server/app/agents/[slug]/page_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/agents/new/page.js +0 -2
- package/apps/web/.next/server/app/agents/new/page.js.nft.json +0 -1
- package/apps/web/.next/server/app/agents/new/page_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/access/route.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/access/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/access/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/claude-md/route.js +0 -6
- package/apps/web/.next/server/app/api/agents/[id]/claude-md/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/claude-md/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/logs/route.js +0 -3
- package/apps/web/.next/server/app/api/agents/[id]/logs/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/logs/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/manifest/route.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/manifest/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/manifest/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/mcps/route.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/mcps/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/mcps/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/memories/[memId]/route.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/memories/[memId]/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/memories/[memId]/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/memories/route.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/memories/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/memories/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/permissions/route.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/permissions/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/permissions/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/reload/route.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/reload/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/reload/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/restrictions/route.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/restrictions/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/restrictions/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/route.js +0 -33
- package/apps/web/.next/server/app/api/agents/[id]/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/skills/[skillId]/route.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/skills/[skillId]/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/skills/[skillId]/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/skills/route.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/skills/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/skills/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/slack-info/route.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/slack-info/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/slack-info/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/snapshots/[sid]/restore/route.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/snapshots/[sid]/restore/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/snapshots/[sid]/restore/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/snapshots/[sid]/route.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/snapshots/[sid]/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/snapshots/[sid]/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/snapshots/route.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/snapshots/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/snapshots/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/start/route.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/start/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/start/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/stop/route.js +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/stop/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/agents/[id]/stop/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/agents/route.js +0 -91
- package/apps/web/.next/server/app/api/agents/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/agents/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/auth/login/route.js +0 -1
- package/apps/web/.next/server/app/api/auth/login/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/auth/login/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/auth/logout/route.js +0 -1
- package/apps/web/.next/server/app/api/auth/logout/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/auth/logout/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/auth/me/route.js +0 -1
- package/apps/web/.next/server/app/api/auth/me/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/auth/me/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/auth/users/[id]/route.js +0 -1
- package/apps/web/.next/server/app/api/auth/users/[id]/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/auth/users/[id]/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/auth/users/route.js +0 -1
- package/apps/web/.next/server/app/api/auth/users/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/auth/users/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/env-vars/[key]/route.js +0 -1
- package/apps/web/.next/server/app/api/env-vars/[key]/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/env-vars/[key]/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/env-vars/route.js +0 -1
- package/apps/web/.next/server/app/api/env-vars/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/env-vars/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/jobs/[id]/route.js +0 -1
- package/apps/web/.next/server/app/api/jobs/[id]/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/jobs/[id]/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/jobs/[id]/runs/route.js +0 -1
- package/apps/web/.next/server/app/api/jobs/[id]/runs/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/jobs/[id]/runs/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/jobs/route.js +0 -1
- package/apps/web/.next/server/app/api/jobs/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/jobs/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/mcps/[id]/route.js +0 -1
- package/apps/web/.next/server/app/api/mcps/[id]/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/mcps/[id]/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/mcps/[id]/test/route.js +0 -1
- package/apps/web/.next/server/app/api/mcps/[id]/test/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/mcps/[id]/test/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/mcps/route.js +0 -1
- package/apps/web/.next/server/app/api/mcps/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/mcps/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/api/settings/route.js +0 -1
- package/apps/web/.next/server/app/api/settings/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/api/settings/route_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/icon.svg/route.js +0 -1
- package/apps/web/.next/server/app/icon.svg/route.js.nft.json +0 -1
- package/apps/web/.next/server/app/jobs/page.js +0 -2
- package/apps/web/.next/server/app/jobs/page.js.nft.json +0 -1
- package/apps/web/.next/server/app/jobs/page_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/login/page.js +0 -2
- package/apps/web/.next/server/app/login/page.js.nft.json +0 -1
- package/apps/web/.next/server/app/login/page_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/page.js +0 -2
- package/apps/web/.next/server/app/page.js.nft.json +0 -1
- package/apps/web/.next/server/app/page_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/settings/env-vars/page.js +0 -2
- package/apps/web/.next/server/app/settings/env-vars/page.js.nft.json +0 -1
- package/apps/web/.next/server/app/settings/env-vars/page_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/settings/mcps/page.js +0 -2
- package/apps/web/.next/server/app/settings/mcps/page.js.nft.json +0 -1
- package/apps/web/.next/server/app/settings/mcps/page_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app/settings/page.js +0 -2
- package/apps/web/.next/server/app/settings/page.js.nft.json +0 -1
- package/apps/web/.next/server/app/settings/page_client-reference-manifest.js +0 -1
- package/apps/web/.next/server/app-paths-manifest.json +0 -46
- package/apps/web/.next/server/chunks/1157.js +0 -9
- package/apps/web/.next/server/chunks/2287.js +0 -1
- package/apps/web/.next/server/chunks/3444.js +0 -1
- package/apps/web/.next/server/chunks/383.js +0 -6
- package/apps/web/.next/server/chunks/4012.js +0 -58
- package/apps/web/.next/server/chunks/6791.js +0 -1
- package/apps/web/.next/server/chunks/7171.js +0 -1
- package/apps/web/.next/server/chunks/8819.js +0 -22
- package/apps/web/.next/server/edge-runtime-webpack.js +0 -2
- package/apps/web/.next/server/edge-runtime-webpack.js.map +0 -1
- package/apps/web/.next/server/interception-route-rewrite-manifest.js +0 -1
- package/apps/web/.next/server/middleware-build-manifest.js +0 -1
- package/apps/web/.next/server/middleware-manifest.json +0 -32
- package/apps/web/.next/server/middleware-react-loadable-manifest.js +0 -1
- package/apps/web/.next/server/next-font-manifest.js +0 -1
- package/apps/web/.next/server/next-font-manifest.json +0 -1
- package/apps/web/.next/server/pages/_app.js +0 -1
- package/apps/web/.next/server/pages/_app.js.nft.json +0 -1
- package/apps/web/.next/server/pages/_document.js +0 -1
- package/apps/web/.next/server/pages/_document.js.nft.json +0 -1
- package/apps/web/.next/server/pages/_error.js +0 -19
- package/apps/web/.next/server/pages/_error.js.nft.json +0 -1
- package/apps/web/.next/server/pages-manifest.json +0 -5
- package/apps/web/.next/server/server-reference-manifest.js +0 -1
- package/apps/web/.next/server/server-reference-manifest.json +0 -1
- package/apps/web/.next/server/src/middleware.js +0 -14
- package/apps/web/.next/server/src/middleware.js.map +0 -1
- package/apps/web/.next/server/webpack-runtime.js +0 -1
- package/apps/web/.next/static/chunks/18-90b700ea37b686a2.js +0 -1
- package/apps/web/.next/static/chunks/87c73c54-24122e7b92478d00.js +0 -1
- package/apps/web/.next/static/chunks/9664-af80478aa73ba424.js +0 -1
- package/apps/web/.next/static/chunks/app/_not-found/page-b9cee17ed89ca24a.js +0 -1
- package/apps/web/.next/static/chunks/app/agents/[slug]/page-18369fc3fe1a9a7b.js +0 -1
- package/apps/web/.next/static/chunks/app/agents/new/page-bf11cf8901c7e2cd.js +0 -1
- package/apps/web/.next/static/chunks/app/api/agents/[id]/access/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/agents/[id]/claude-md/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/agents/[id]/logs/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/agents/[id]/manifest/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/agents/[id]/mcps/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/agents/[id]/memories/[memId]/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/agents/[id]/memories/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/agents/[id]/permissions/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/agents/[id]/reload/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/agents/[id]/restrictions/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/agents/[id]/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/agents/[id]/skills/[skillId]/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/agents/[id]/skills/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/agents/[id]/slack-info/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/agents/[id]/snapshots/[sid]/restore/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/agents/[id]/snapshots/[sid]/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/agents/[id]/snapshots/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/agents/[id]/start/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/agents/[id]/stop/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/agents/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/auth/login/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/auth/logout/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/auth/me/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/auth/users/[id]/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/auth/users/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/env-vars/[key]/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/env-vars/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/jobs/[id]/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/jobs/[id]/runs/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/jobs/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/mcps/[id]/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/mcps/[id]/test/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/mcps/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/api/settings/route-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/jobs/page-f5aa89a47c50efd8.js +0 -1
- package/apps/web/.next/static/chunks/app/layout-2079f4964aa7314e.js +0 -1
- package/apps/web/.next/static/chunks/app/login/layout-07f0f73ac9839899.js +0 -1
- package/apps/web/.next/static/chunks/app/login/page-aa259283dc38e8f9.js +0 -1
- package/apps/web/.next/static/chunks/app/page-e83437b608104dff.js +0 -1
- package/apps/web/.next/static/chunks/app/settings/env-vars/page-06479dbdfb78b76b.js +0 -1
- package/apps/web/.next/static/chunks/app/settings/mcps/page-75650686ed6490c7.js +0 -1
- package/apps/web/.next/static/chunks/app/settings/page-e1e62fc41ff6cddd.js +0 -1
- package/apps/web/.next/static/chunks/framework-811407f832a33072.js +0 -1
- package/apps/web/.next/static/chunks/main-3f1cddbdd67b1546.js +0 -1
- package/apps/web/.next/static/chunks/main-app-cebd8a6a5ccbf72d.js +0 -1
- package/apps/web/.next/static/chunks/pages/_app-50fa07b56b2d29ac.js +0 -1
- package/apps/web/.next/static/chunks/pages/_error-fed8688bdd23f211.js +0 -1
- package/apps/web/.next/static/chunks/polyfills-42372ed130431b0a.js +0 -1
- package/apps/web/.next/static/chunks/webpack-6c05566dba553c97.js +0 -1
- package/apps/web/.next/static/css/15371687405525e2.css +0 -5
- package/apps/web/.next/static/ikfNbLhuw7jntn35bz0lk/_buildManifest.js +0 -1
- package/apps/web/.next/static/ikfNbLhuw7jntn35bz0lk/_ssgManifest.js +0 -1
- package/apps/web/.next/trace +0 -5
- package/apps/web/.next/types/app/agents/[slug]/page.ts +0 -84
- package/apps/web/.next/types/app/agents/new/page.ts +0 -84
- package/apps/web/.next/types/app/api/agents/[id]/access/route.ts +0 -347
- package/apps/web/.next/types/app/api/agents/[id]/claude-md/route.ts +0 -347
- package/apps/web/.next/types/app/api/agents/[id]/logs/route.ts +0 -347
- package/apps/web/.next/types/app/api/agents/[id]/manifest/route.ts +0 -347
- package/apps/web/.next/types/app/api/agents/[id]/mcps/route.ts +0 -347
- package/apps/web/.next/types/app/api/agents/[id]/memories/[memId]/route.ts +0 -347
- package/apps/web/.next/types/app/api/agents/[id]/memories/route.ts +0 -347
- package/apps/web/.next/types/app/api/agents/[id]/permissions/route.ts +0 -347
- package/apps/web/.next/types/app/api/agents/[id]/reload/route.ts +0 -347
- package/apps/web/.next/types/app/api/agents/[id]/restrictions/route.ts +0 -347
- package/apps/web/.next/types/app/api/agents/[id]/route.ts +0 -347
- package/apps/web/.next/types/app/api/agents/[id]/skills/[skillId]/route.ts +0 -347
- package/apps/web/.next/types/app/api/agents/[id]/skills/route.ts +0 -347
- package/apps/web/.next/types/app/api/agents/[id]/slack-info/route.ts +0 -347
- package/apps/web/.next/types/app/api/agents/[id]/snapshots/[sid]/restore/route.ts +0 -347
- package/apps/web/.next/types/app/api/agents/[id]/snapshots/[sid]/route.ts +0 -347
- package/apps/web/.next/types/app/api/agents/[id]/snapshots/route.ts +0 -347
- package/apps/web/.next/types/app/api/agents/[id]/start/route.ts +0 -347
- package/apps/web/.next/types/app/api/agents/[id]/stop/route.ts +0 -347
- package/apps/web/.next/types/app/api/agents/route.ts +0 -347
- package/apps/web/.next/types/app/api/auth/login/route.ts +0 -347
- package/apps/web/.next/types/app/api/auth/logout/route.ts +0 -347
- package/apps/web/.next/types/app/api/auth/me/route.ts +0 -347
- package/apps/web/.next/types/app/api/auth/users/[id]/route.ts +0 -347
- package/apps/web/.next/types/app/api/auth/users/route.ts +0 -347
- package/apps/web/.next/types/app/api/env-vars/[key]/route.ts +0 -347
- package/apps/web/.next/types/app/api/env-vars/route.ts +0 -347
- package/apps/web/.next/types/app/api/jobs/[id]/route.ts +0 -347
- package/apps/web/.next/types/app/api/jobs/[id]/runs/route.ts +0 -347
- package/apps/web/.next/types/app/api/jobs/route.ts +0 -347
- package/apps/web/.next/types/app/api/mcps/[id]/route.ts +0 -347
- package/apps/web/.next/types/app/api/mcps/[id]/test/route.ts +0 -347
- package/apps/web/.next/types/app/api/mcps/route.ts +0 -347
- package/apps/web/.next/types/app/api/settings/route.ts +0 -347
- package/apps/web/.next/types/app/jobs/page.ts +0 -84
- package/apps/web/.next/types/app/login/layout.ts +0 -84
- package/apps/web/.next/types/app/login/page.ts +0 -84
- package/apps/web/.next/types/app/page.ts +0 -84
- package/apps/web/.next/types/app/settings/env-vars/page.ts +0 -84
- package/apps/web/.next/types/app/settings/mcps/page.ts +0 -84
- package/apps/web/.next/types/app/settings/page.ts +0 -84
- package/apps/web/.next/types/cache-life.d.ts +0 -141
- package/apps/web/.next/types/package.json +0 -1
- package/apps/web/.next/types/routes.d.ts +0 -114
- package/apps/web/.next/types/validator.ts +0 -448
- package/apps/web/Dockerfile +0 -37
- package/apps/web/next-env.d.ts +0 -6
- package/apps/web/next.config.js +0 -6
- package/apps/web/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/apps/web/package.json +0 -48
- package/apps/web/postcss.config.js +0 -3
- package/apps/web/public/logo.svg +0 -17
- package/apps/web/src/app/agents/[slug]/page.tsx +0 -2235
- package/apps/web/src/app/agents/new/page.tsx +0 -1161
- package/apps/web/src/app/api/agents/[id]/access/route.ts +0 -76
- package/apps/web/src/app/api/agents/[id]/claude-md/route.ts +0 -111
- package/apps/web/src/app/api/agents/[id]/logs/route.ts +0 -84
- package/apps/web/src/app/api/agents/[id]/manifest/route.ts +0 -32
- package/apps/web/src/app/api/agents/[id]/mcps/route.ts +0 -73
- package/apps/web/src/app/api/agents/[id]/memories/[memId]/route.ts +0 -31
- package/apps/web/src/app/api/agents/[id]/memories/route.ts +0 -56
- package/apps/web/src/app/api/agents/[id]/permissions/route.ts +0 -74
- package/apps/web/src/app/api/agents/[id]/reload/route.ts +0 -33
- package/apps/web/src/app/api/agents/[id]/restrictions/route.ts +0 -85
- package/apps/web/src/app/api/agents/[id]/route.ts +0 -81
- package/apps/web/src/app/api/agents/[id]/skills/[skillId]/route.ts +0 -52
- package/apps/web/src/app/api/agents/[id]/skills/route.ts +0 -80
- package/apps/web/src/app/api/agents/[id]/slack-info/route.ts +0 -38
- package/apps/web/src/app/api/agents/[id]/snapshots/[sid]/restore/route.ts +0 -61
- package/apps/web/src/app/api/agents/[id]/snapshots/[sid]/route.ts +0 -53
- package/apps/web/src/app/api/agents/[id]/snapshots/route.ts +0 -84
- package/apps/web/src/app/api/agents/[id]/start/route.ts +0 -35
- package/apps/web/src/app/api/agents/[id]/stop/route.ts +0 -35
- package/apps/web/src/app/api/agents/route.ts +0 -99
- package/apps/web/src/app/api/auth/login/route.ts +0 -39
- package/apps/web/src/app/api/auth/logout/route.ts +0 -21
- package/apps/web/src/app/api/auth/me/route.ts +0 -24
- package/apps/web/src/app/api/auth/users/[id]/route.ts +0 -48
- package/apps/web/src/app/api/auth/users/route.ts +0 -63
- package/apps/web/src/app/api/env-vars/[key]/route.ts +0 -66
- package/apps/web/src/app/api/env-vars/route.ts +0 -59
- package/apps/web/src/app/api/jobs/[id]/route.ts +0 -51
- package/apps/web/src/app/api/jobs/[id]/runs/route.ts +0 -24
- package/apps/web/src/app/api/jobs/route.ts +0 -42
- package/apps/web/src/app/api/mcps/[id]/route.ts +0 -60
- package/apps/web/src/app/api/mcps/[id]/test/route.ts +0 -195
- package/apps/web/src/app/api/mcps/route.ts +0 -72
- package/apps/web/src/app/api/settings/route.ts +0 -42
- package/apps/web/src/app/globals.css +0 -124
- package/apps/web/src/app/icon.svg +0 -17
- package/apps/web/src/app/jobs/page.tsx +0 -543
- package/apps/web/src/app/layout-shell.tsx +0 -89
- package/apps/web/src/app/layout.tsx +0 -18
- package/apps/web/src/app/login/layout.tsx +0 -9
- package/apps/web/src/app/login/page.tsx +0 -150
- package/apps/web/src/app/page.tsx +0 -573
- package/apps/web/src/app/settings/env-vars/page.tsx +0 -216
- package/apps/web/src/app/settings/mcps/page.tsx +0 -763
- package/apps/web/src/app/settings/page.tsx +0 -528
- package/apps/web/src/app/sidebar.tsx +0 -345
- package/apps/web/src/lib/__tests__/api-guard.test.ts +0 -189
- package/apps/web/src/lib/__tests__/auth.test.ts +0 -262
- package/apps/web/src/lib/__tests__/boss-registry.test.ts +0 -323
- package/apps/web/src/lib/__tests__/compile.test.ts +0 -161
- package/apps/web/src/lib/__tests__/db-agent-hierarchy.test.ts +0 -136
- package/apps/web/src/lib/__tests__/db-env-vars.test.ts +0 -216
- package/apps/web/src/lib/__tests__/db-restrictions.test.ts +0 -117
- package/apps/web/src/lib/__tests__/db.integration.test.ts +0 -271
- package/apps/web/src/lib/__tests__/diff.test.ts +0 -102
- package/apps/web/src/lib/__tests__/mcp-mask.test.ts +0 -274
- package/apps/web/src/lib/__tests__/skill-templates.test.ts +0 -237
- package/apps/web/src/lib/__tests__/slack-manifest.test.ts +0 -105
- package/apps/web/src/lib/api-guard.ts +0 -68
- package/apps/web/src/lib/auth-context.tsx +0 -71
- package/apps/web/src/lib/auth.ts +0 -128
- package/apps/web/src/lib/boss-registry.ts +0 -90
- package/apps/web/src/lib/compile.ts +0 -51
- package/apps/web/src/lib/db.ts +0 -1196
- package/apps/web/src/lib/diff.ts +0 -43
- package/apps/web/src/lib/mcp-mask.ts +0 -91
- package/apps/web/src/lib/portal.tsx +0 -23
- package/apps/web/src/lib/skill-templates.ts +0 -148
- package/apps/web/src/lib/slack-manifest.ts +0 -85
- package/apps/web/src/middleware.ts +0 -68
- package/apps/web/tailwind.config.js +0 -6
- package/apps/web/tsconfig.json +0 -23
- package/apps/web/vitest.config.mts +0 -21
- package/cli/.claude/settings.local.json +0 -6
- package/cli/node_modules/.package-lock.json +0 -427
- package/cli/node_modules/commander/LICENSE +0 -22
- package/cli/node_modules/commander/Readme.md +0 -1157
- package/cli/node_modules/commander/esm.mjs +0 -16
- package/cli/node_modules/commander/index.js +0 -24
- package/cli/node_modules/commander/lib/argument.js +0 -149
- package/cli/node_modules/commander/lib/command.js +0 -2509
- package/cli/node_modules/commander/lib/error.js +0 -39
- package/cli/node_modules/commander/lib/help.js +0 -520
- package/cli/node_modules/commander/lib/option.js +0 -330
- package/cli/node_modules/commander/lib/suggestSimilar.js +0 -101
- package/cli/node_modules/commander/package-support.json +0 -16
- package/cli/node_modules/commander/package.json +0 -84
- package/cli/node_modules/commander/typings/esm.d.mts +0 -3
- package/cli/node_modules/commander/typings/index.d.ts +0 -969
- package/cli/package-lock.json +0 -449
- package/cli/package.json +0 -44
- package/cli/src/commands/init.ts +0 -514
- package/cli/src/commands/manage.ts +0 -115
- package/cli/src/index.ts +0 -63
- package/cli/tsconfig.json +0 -14
- package/docker-compose.yml +0 -122
- package/docs/agents/boss-agents.mdx +0 -108
- package/docs/agents/creating-agents.mdx +0 -132
- package/docs/agents/memory.mdx +0 -113
- package/docs/agents/tools.mdx +0 -103
- package/docs/configuration/env-vars.mdx +0 -166
- package/docs/configuration/mcp-servers.mdx +0 -203
- package/docs/configuration/slack-app.mdx +0 -175
- package/docs/docs.json +0 -79
- package/docs/favicon.svg +0 -17
- package/docs/features/history.mdx +0 -60
- package/docs/features/import-export.mdx +0 -77
- package/docs/features/logs.mdx +0 -131
- package/docs/features/multi-workspace.mdx +0 -90
- package/docs/features/scheduled-jobs.mdx +0 -231
- package/docs/features/users.mdx +0 -92
- package/docs/introduction.mdx +0 -160
- package/docs/logo/dark.svg +0 -17
- package/docs/logo/light.svg +0 -17
- package/docs/logo/wide-dark.svg +0 -12
- package/docs/logo/wide-light.svg +0 -12
- package/docs/quickstart.mdx +0 -270
- package/docs/self-hosting/docker.mdx +0 -151
- package/docs/self-hosting/production.mdx +0 -176
- package/packages/shared/dist/index.d.ts +0 -8
- package/packages/shared/dist/index.d.ts.map +0 -1
- package/packages/shared/dist/index.js +0 -24
- package/packages/shared/dist/index.js.map +0 -1
- package/packages/shared/dist/types.d.ts +0 -584
- package/packages/shared/dist/types.d.ts.map +0 -1
- package/packages/shared/dist/types.js +0 -39
- package/packages/shared/dist/types.js.map +0 -1
- package/packages/shared/package.json +0 -15
- package/packages/shared/src/db/schema.sql +0 -354
- package/packages/shared/src/index.ts +0 -8
- package/packages/shared/src/types.ts +0 -683
- package/packages/shared/tsconfig.json +0 -17
- package/scripts/dev.sh +0 -45
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Unit tests for compile.ts — compileSkillsOnly and skillToSnapshotSkill.
|
|
3
|
-
*
|
|
4
|
-
* All tests use inline mock data; no database connection required.
|
|
5
|
-
*
|
|
6
|
-
* @module web/lib/__tests__/compile.test
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { describe, it, expect } from 'vitest';
|
|
10
|
-
import { compileSkillsOnly, skillToSnapshotSkill } from '@/lib/compile';
|
|
11
|
-
import type { Skill } from '@slackhive/shared';
|
|
12
|
-
|
|
13
|
-
// ---------------------------------------------------------------------------
|
|
14
|
-
// Helpers
|
|
15
|
-
// ---------------------------------------------------------------------------
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Creates a minimal {@link Skill} object for testing purposes.
|
|
19
|
-
*
|
|
20
|
-
* @param {Partial<Skill>} overrides - Fields to override from defaults.
|
|
21
|
-
* @returns {Skill}
|
|
22
|
-
*/
|
|
23
|
-
function makeSkill(overrides: Partial<Skill>): Skill {
|
|
24
|
-
return {
|
|
25
|
-
id: 'skill-id',
|
|
26
|
-
agentId: 'agent-id',
|
|
27
|
-
category: '00-core',
|
|
28
|
-
filename: 'main.md',
|
|
29
|
-
content: '# Main',
|
|
30
|
-
sortOrder: 0,
|
|
31
|
-
createdAt: new Date('2024-01-01'),
|
|
32
|
-
updatedAt: new Date('2024-01-01'),
|
|
33
|
-
...overrides,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// ---------------------------------------------------------------------------
|
|
38
|
-
// compileSkillsOnly
|
|
39
|
-
// ---------------------------------------------------------------------------
|
|
40
|
-
|
|
41
|
-
describe('compileSkillsOnly', () => {
|
|
42
|
-
it('returns empty string for empty skills array with no fallback', () => {
|
|
43
|
-
expect(compileSkillsOnly([])).toBe('');
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('returns identity block for empty skills array with fallback', () => {
|
|
47
|
-
const result = compileSkillsOnly([], {
|
|
48
|
-
name: 'TestBot',
|
|
49
|
-
description: 'A test bot',
|
|
50
|
-
persona: 'Friendly helper',
|
|
51
|
-
});
|
|
52
|
-
expect(result).toContain('# TestBot');
|
|
53
|
-
expect(result).toContain('A test bot');
|
|
54
|
-
expect(result).toContain('Friendly helper');
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('returns identity block using default persona when persona is undefined', () => {
|
|
58
|
-
const result = compileSkillsOnly([], { name: 'TestBot', description: 'Desc' });
|
|
59
|
-
expect(result).toContain('A helpful assistant.');
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('returns trimmed content for a single skill', () => {
|
|
63
|
-
const skill = makeSkill({ content: ' # Identity\n\nHello world ' });
|
|
64
|
-
const result = compileSkillsOnly([skill]);
|
|
65
|
-
expect(result).toBe('# Identity\n\nHello world');
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('joins multiple skills with double newline sorted by sortOrder', () => {
|
|
69
|
-
const skills = [
|
|
70
|
-
makeSkill({ sortOrder: 2, content: 'Third' }),
|
|
71
|
-
makeSkill({ sortOrder: 0, content: 'First' }),
|
|
72
|
-
makeSkill({ sortOrder: 1, content: 'Second' }),
|
|
73
|
-
];
|
|
74
|
-
const result = compileSkillsOnly(skills);
|
|
75
|
-
expect(result).toBe('First\n\nSecond\n\nThird');
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('strips <!-- skill:... --> header comments from output', () => {
|
|
79
|
-
const skill = makeSkill({
|
|
80
|
-
content: '<!-- skill:identity -->\n# Identity\n\nContent here',
|
|
81
|
-
});
|
|
82
|
-
const result = compileSkillsOnly([skill]);
|
|
83
|
-
expect(result).not.toContain('<!-- skill:identity -->');
|
|
84
|
-
expect(result).toContain('# Identity');
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('correctly sorts skills passed out of order', () => {
|
|
88
|
-
const skills = [
|
|
89
|
-
makeSkill({ sortOrder: 10, content: 'Last' }),
|
|
90
|
-
makeSkill({ sortOrder: 1, content: 'First' }),
|
|
91
|
-
makeSkill({ sortOrder: 5, content: 'Middle' }),
|
|
92
|
-
];
|
|
93
|
-
const result = compileSkillsOnly(skills);
|
|
94
|
-
const parts = result.split('\n\n');
|
|
95
|
-
expect(parts[0]).toBe('First');
|
|
96
|
-
expect(parts[1]).toBe('Middle');
|
|
97
|
-
expect(parts[2]).toBe('Last');
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('returns empty string for a skill with only whitespace content', () => {
|
|
101
|
-
const skill = makeSkill({ content: ' \n\t\n ' });
|
|
102
|
-
const result = compileSkillsOnly([skill]);
|
|
103
|
-
expect(result).toBe('');
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('produces deterministic output for skills with duplicate sortOrder', () => {
|
|
107
|
-
const skills = [
|
|
108
|
-
makeSkill({ sortOrder: 1, content: 'A', filename: 'a.md' }),
|
|
109
|
-
makeSkill({ sortOrder: 1, content: 'B', filename: 'b.md' }),
|
|
110
|
-
];
|
|
111
|
-
const result1 = compileSkillsOnly(skills);
|
|
112
|
-
const result2 = compileSkillsOnly([...skills].reverse());
|
|
113
|
-
// Both calls should contain both skills — order may vary but output must not crash
|
|
114
|
-
expect(result1).toContain('A');
|
|
115
|
-
expect(result1).toContain('B');
|
|
116
|
-
expect(result2).toContain('A');
|
|
117
|
-
expect(result2).toContain('B');
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('returns identity block with empty heading when fallback name is empty string', () => {
|
|
121
|
-
const result = compileSkillsOnly([], { name: '' });
|
|
122
|
-
expect(result).toContain('#');
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('does not mutate the original skills array order', () => {
|
|
126
|
-
const skills = [
|
|
127
|
-
makeSkill({ sortOrder: 2, content: 'B' }),
|
|
128
|
-
makeSkill({ sortOrder: 1, content: 'A' }),
|
|
129
|
-
];
|
|
130
|
-
const originalOrder = skills.map(s => s.content);
|
|
131
|
-
compileSkillsOnly(skills);
|
|
132
|
-
expect(skills.map(s => s.content)).toEqual(originalOrder);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
// ---------------------------------------------------------------------------
|
|
137
|
-
// skillToSnapshotSkill
|
|
138
|
-
// ---------------------------------------------------------------------------
|
|
139
|
-
|
|
140
|
-
describe('skillToSnapshotSkill', () => {
|
|
141
|
-
it('maps category, filename, content, and sortOrder -> sort_order correctly', () => {
|
|
142
|
-
const skill = makeSkill({
|
|
143
|
-
category: '01-knowledge',
|
|
144
|
-
filename: 'schema.md',
|
|
145
|
-
content: '## Schema\n\nDetails',
|
|
146
|
-
sortOrder: 42,
|
|
147
|
-
});
|
|
148
|
-
const snapshot = skillToSnapshotSkill(skill);
|
|
149
|
-
expect(snapshot.category).toBe('01-knowledge');
|
|
150
|
-
expect(snapshot.filename).toBe('schema.md');
|
|
151
|
-
expect(snapshot.content).toBe('## Schema\n\nDetails');
|
|
152
|
-
expect(snapshot.sort_order).toBe(42);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
it('does not include id or agentId in the result', () => {
|
|
156
|
-
const skill = makeSkill({ id: 'some-uuid', agentId: 'agent-uuid' });
|
|
157
|
-
const snapshot = skillToSnapshotSkill(skill);
|
|
158
|
-
expect(snapshot).not.toHaveProperty('id');
|
|
159
|
-
expect(snapshot).not.toHaveProperty('agentId');
|
|
160
|
-
});
|
|
161
|
-
});
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Unit tests for agent hierarchy / enabled fields in db.ts.
|
|
3
|
-
*
|
|
4
|
-
* Covers:
|
|
5
|
-
* - updateAgentEnabled sets the enabled column correctly
|
|
6
|
-
* - updateAgent supports isBoss and reportsTo fields
|
|
7
|
-
* - rowToAgent maps the enabled column (defaults true when missing)
|
|
8
|
-
*
|
|
9
|
-
* No real database required — pg.Pool is mocked via vi.mock.
|
|
10
|
-
*
|
|
11
|
-
* @module web/lib/__tests__/db-agent-hierarchy.test
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
15
|
-
|
|
16
|
-
// ─── Mock pg ──────────────────────────────────────────────────────────────────
|
|
17
|
-
|
|
18
|
-
const mockQuery = vi.fn();
|
|
19
|
-
|
|
20
|
-
vi.mock('pg', () => ({
|
|
21
|
-
Pool: vi.fn().mockImplementation(function() { return { query: mockQuery }; }),
|
|
22
|
-
}));
|
|
23
|
-
|
|
24
|
-
process.env.DATABASE_URL = 'postgresql://mock/db';
|
|
25
|
-
process.env.ENV_SECRET_KEY = 'test-secret-key-32-chars-padding!';
|
|
26
|
-
|
|
27
|
-
import { updateAgentEnabled, updateAgent, getAgentById } from '@/lib/db';
|
|
28
|
-
|
|
29
|
-
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
30
|
-
|
|
31
|
-
const AGENT_ID = 'agent-uuid-001';
|
|
32
|
-
|
|
33
|
-
const BASE_ROW = {
|
|
34
|
-
id: AGENT_ID,
|
|
35
|
-
slug: 'test-agent',
|
|
36
|
-
name: 'Test Agent',
|
|
37
|
-
persona: null,
|
|
38
|
-
description: null,
|
|
39
|
-
slack_bot_token: 'xoxb-test',
|
|
40
|
-
slack_app_token: 'xapp-test',
|
|
41
|
-
slack_signing_secret: 'secret',
|
|
42
|
-
slack_bot_user_id: null,
|
|
43
|
-
model: 'claude-sonnet-4-6',
|
|
44
|
-
status: 'stopped',
|
|
45
|
-
enabled: true,
|
|
46
|
-
is_boss: false,
|
|
47
|
-
reports_to: [],
|
|
48
|
-
claude_md: '',
|
|
49
|
-
created_by: 'system',
|
|
50
|
-
created_at: new Date(),
|
|
51
|
-
updated_at: new Date(),
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
beforeEach(() => {
|
|
55
|
-
mockQuery.mockReset();
|
|
56
|
-
mockQuery.mockResolvedValue({ rows: [] });
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
// ─── updateAgentEnabled ────────────────────────────────────────────────────────
|
|
60
|
-
|
|
61
|
-
describe('updateAgentEnabled', () => {
|
|
62
|
-
it('sets enabled = true', async () => {
|
|
63
|
-
await updateAgentEnabled(AGENT_ID, true);
|
|
64
|
-
expect(mockQuery).toHaveBeenCalledOnce();
|
|
65
|
-
const [sql, params] = mockQuery.mock.calls[0];
|
|
66
|
-
expect(sql).toContain('enabled = $1');
|
|
67
|
-
expect(params).toEqual([true, AGENT_ID]);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('sets enabled = false', async () => {
|
|
71
|
-
await updateAgentEnabled(AGENT_ID, false);
|
|
72
|
-
const [, params] = mockQuery.mock.calls[0];
|
|
73
|
-
expect(params[0]).toBe(false);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
// ─── updateAgent — isBoss + reportsTo ─────────────────────────────────────────
|
|
78
|
-
|
|
79
|
-
describe('updateAgent — hierarchy fields', () => {
|
|
80
|
-
beforeEach(() => {
|
|
81
|
-
mockQuery.mockResolvedValue({ rows: [BASE_ROW] });
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('includes is_boss when isBoss is provided', async () => {
|
|
85
|
-
await updateAgent(AGENT_ID, { isBoss: true });
|
|
86
|
-
const [sql, params] = mockQuery.mock.calls[0];
|
|
87
|
-
expect(sql).toContain('is_boss =');
|
|
88
|
-
expect(params).toContain(true);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('includes reports_to when reportsTo is provided', async () => {
|
|
92
|
-
const bosses = ['boss-uuid-1', 'boss-uuid-2'];
|
|
93
|
-
await updateAgent(AGENT_ID, { reportsTo: bosses });
|
|
94
|
-
const [sql, params] = mockQuery.mock.calls[0];
|
|
95
|
-
expect(sql).toContain('reports_to =');
|
|
96
|
-
expect(params).toContain(bosses);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('sets both isBoss and reportsTo together', async () => {
|
|
100
|
-
await updateAgent(AGENT_ID, { isBoss: false, reportsTo: ['boss-uuid-1'] });
|
|
101
|
-
const [sql, params] = mockQuery.mock.calls[0];
|
|
102
|
-
expect(sql).toContain('is_boss =');
|
|
103
|
-
expect(sql).toContain('reports_to =');
|
|
104
|
-
expect(params).toContain(false);
|
|
105
|
-
expect(params).toContainEqual(['boss-uuid-1']);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('does not include is_boss when isBoss is omitted', async () => {
|
|
109
|
-
await updateAgent(AGENT_ID, { name: 'New Name' });
|
|
110
|
-
const [sql] = mockQuery.mock.calls[0];
|
|
111
|
-
expect(sql).not.toContain('is_boss');
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
// ─── rowToAgent — enabled field mapping ───────────────────────────────────────
|
|
116
|
-
|
|
117
|
-
describe('getAgentById — enabled field', () => {
|
|
118
|
-
it('maps enabled = true from DB row', async () => {
|
|
119
|
-
mockQuery.mockResolvedValue({ rows: [{ ...BASE_ROW, enabled: true }] });
|
|
120
|
-
const agent = await getAgentById(AGENT_ID);
|
|
121
|
-
expect(agent?.enabled).toBe(true);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('maps enabled = false from DB row', async () => {
|
|
125
|
-
mockQuery.mockResolvedValue({ rows: [{ ...BASE_ROW, enabled: false }] });
|
|
126
|
-
const agent = await getAgentById(AGENT_ID);
|
|
127
|
-
expect(agent?.enabled).toBe(false);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it('defaults enabled to true when column is null/undefined', async () => {
|
|
131
|
-
const { enabled: _omit, ...rowWithoutEnabled } = BASE_ROW;
|
|
132
|
-
mockQuery.mockResolvedValue({ rows: [rowWithoutEnabled] });
|
|
133
|
-
const agent = await getAgentById(AGENT_ID);
|
|
134
|
-
expect(agent?.enabled).toBe(true);
|
|
135
|
-
});
|
|
136
|
-
});
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Unit tests for env var functions in db.ts.
|
|
3
|
-
*
|
|
4
|
-
* Verifies that setEnvVar, getEnvVarValues, getAllEnvVars, updateEnvVarDescription,
|
|
5
|
-
* and deleteEnvVar issue the correct SQL — in particular that setEnvVar uses
|
|
6
|
-
* AES-256 encryption (cipher-algo=aes256) rather than the pgcrypto default.
|
|
7
|
-
*
|
|
8
|
-
* No real database required — pg.Pool is mocked via vi.mock.
|
|
9
|
-
*
|
|
10
|
-
* @module web/lib/__tests__/db-env-vars.test
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
14
|
-
|
|
15
|
-
// ─── Mock pg ─────────────────────────────────────────────────────────────────
|
|
16
|
-
|
|
17
|
-
const mockQuery = vi.fn();
|
|
18
|
-
|
|
19
|
-
vi.mock('pg', () => {
|
|
20
|
-
return {
|
|
21
|
-
Pool: vi.fn().mockImplementation(function() { return { query: mockQuery }; }),
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// Set required env vars before importing db so the singleton pool initialises.
|
|
26
|
-
process.env.DATABASE_URL = 'postgresql://mock/db';
|
|
27
|
-
process.env.ENV_SECRET_KEY = 'test-secret-key-32-chars-padding!';
|
|
28
|
-
|
|
29
|
-
import {
|
|
30
|
-
setEnvVar,
|
|
31
|
-
getEnvVarValues,
|
|
32
|
-
getAllEnvVars,
|
|
33
|
-
updateEnvVarDescription,
|
|
34
|
-
deleteEnvVar,
|
|
35
|
-
} from '@/lib/db';
|
|
36
|
-
|
|
37
|
-
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
38
|
-
|
|
39
|
-
beforeEach(() => {
|
|
40
|
-
mockQuery.mockReset();
|
|
41
|
-
mockQuery.mockResolvedValue({ rows: [] });
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
// ─── setEnvVar ────────────────────────────────────────────────────────────────
|
|
45
|
-
|
|
46
|
-
describe('setEnvVar', () => {
|
|
47
|
-
it('calls query with the correct number of parameters', async () => {
|
|
48
|
-
await setEnvVar('MY_KEY', 'my-value');
|
|
49
|
-
expect(mockQuery).toHaveBeenCalledOnce();
|
|
50
|
-
const [, params] = mockQuery.mock.calls[0];
|
|
51
|
-
// $1=key, $2=value, $3=encKey, $4=description
|
|
52
|
-
expect(params).toHaveLength(4);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('passes the key as $1', async () => {
|
|
56
|
-
await setEnvVar('DB_URL', 'postgres://localhost');
|
|
57
|
-
const [, params] = mockQuery.mock.calls[0];
|
|
58
|
-
expect(params[0]).toBe('DB_URL');
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('passes the plaintext value as $2 (encryption done in SQL)', async () => {
|
|
62
|
-
await setEnvVar('DB_URL', 'postgres://localhost');
|
|
63
|
-
const [, params] = mockQuery.mock.calls[0];
|
|
64
|
-
expect(params[1]).toBe('postgres://localhost');
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('passes ENV_SECRET_KEY as $3', async () => {
|
|
68
|
-
await setEnvVar('MY_KEY', 'val');
|
|
69
|
-
const [, params] = mockQuery.mock.calls[0];
|
|
70
|
-
expect(params[2]).toBe('test-secret-key-32-chars-padding!');
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('passes null as $4 when description is omitted', async () => {
|
|
74
|
-
await setEnvVar('MY_KEY', 'val');
|
|
75
|
-
const [, params] = mockQuery.mock.calls[0];
|
|
76
|
-
expect(params[3]).toBeNull();
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('passes description as $4 when provided', async () => {
|
|
80
|
-
await setEnvVar('MY_KEY', 'val', 'My description');
|
|
81
|
-
const [, params] = mockQuery.mock.calls[0];
|
|
82
|
-
expect(params[3]).toBe('My description');
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('uses pgp_sym_encrypt with cipher-algo=aes256 for INSERT', async () => {
|
|
86
|
-
await setEnvVar('MY_KEY', 'val');
|
|
87
|
-
const [sql] = mockQuery.mock.calls[0];
|
|
88
|
-
expect(sql).toContain("pgp_sym_encrypt($2, $3, 'cipher-algo=aes256')");
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('uses pgp_sym_encrypt with cipher-algo=aes256 for ON CONFLICT UPDATE', async () => {
|
|
92
|
-
await setEnvVar('MY_KEY', 'val');
|
|
93
|
-
const [sql] = mockQuery.mock.calls[0];
|
|
94
|
-
// Both the INSERT value and the UPSERT update value must use AES-256
|
|
95
|
-
const matches = (sql as string).match(/cipher-algo=aes256/g);
|
|
96
|
-
expect(matches).toHaveLength(2);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('uses an INSERT … ON CONFLICT upsert pattern', async () => {
|
|
100
|
-
await setEnvVar('MY_KEY', 'val');
|
|
101
|
-
const [sql] = mockQuery.mock.calls[0];
|
|
102
|
-
expect(sql).toMatch(/INSERT INTO env_vars/i);
|
|
103
|
-
expect(sql).toMatch(/ON CONFLICT/i);
|
|
104
|
-
expect(sql).toMatch(/DO UPDATE SET/i);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
// ─── getEnvVarValues ──────────────────────────────────────────────────────────
|
|
109
|
-
|
|
110
|
-
describe('getEnvVarValues', () => {
|
|
111
|
-
it('decrypts values with pgp_sym_decrypt', async () => {
|
|
112
|
-
mockQuery.mockResolvedValue({ rows: [] });
|
|
113
|
-
await getEnvVarValues();
|
|
114
|
-
const [sql] = mockQuery.mock.calls[0];
|
|
115
|
-
expect(sql).toContain('pgp_sym_decrypt');
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('passes ENV_SECRET_KEY as parameter', async () => {
|
|
119
|
-
mockQuery.mockResolvedValue({ rows: [] });
|
|
120
|
-
await getEnvVarValues();
|
|
121
|
-
const [, params] = mockQuery.mock.calls[0];
|
|
122
|
-
expect(params[0]).toBe('test-secret-key-32-chars-padding!');
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('returns a key→value record from query rows', async () => {
|
|
126
|
-
mockQuery.mockResolvedValue({
|
|
127
|
-
rows: [
|
|
128
|
-
{ key: 'FOO', value: 'bar' },
|
|
129
|
-
{ key: 'BAZ', value: 'qux' },
|
|
130
|
-
],
|
|
131
|
-
});
|
|
132
|
-
const result = await getEnvVarValues();
|
|
133
|
-
expect(result).toEqual({ FOO: 'bar', BAZ: 'qux' });
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it('returns an empty object when no rows', async () => {
|
|
137
|
-
mockQuery.mockResolvedValue({ rows: [] });
|
|
138
|
-
const result = await getEnvVarValues();
|
|
139
|
-
expect(result).toEqual({});
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
// ─── getAllEnvVars ────────────────────────────────────────────────────────────
|
|
144
|
-
|
|
145
|
-
describe('getAllEnvVars', () => {
|
|
146
|
-
it('queries key, description, and updated_at', async () => {
|
|
147
|
-
await getAllEnvVars();
|
|
148
|
-
const [sql] = mockQuery.mock.calls[0];
|
|
149
|
-
expect(sql).toContain('key');
|
|
150
|
-
expect(sql).toContain('description');
|
|
151
|
-
expect(sql).toContain('updated_at');
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it('never selects the encrypted value column', async () => {
|
|
155
|
-
await getAllEnvVars();
|
|
156
|
-
const [sql] = mockQuery.mock.calls[0];
|
|
157
|
-
expect(sql).not.toContain('pgp_sym_decrypt');
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it('maps rows to objects with key, description, and updatedAt', async () => {
|
|
161
|
-
const now = new Date();
|
|
162
|
-
mockQuery.mockResolvedValue({
|
|
163
|
-
rows: [{ key: 'MY_KEY', description: 'desc', updated_at: now }],
|
|
164
|
-
});
|
|
165
|
-
const result = await getAllEnvVars();
|
|
166
|
-
expect(result).toEqual([{ key: 'MY_KEY', description: 'desc', updatedAt: now }]);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it('sets description to undefined when null in DB', async () => {
|
|
170
|
-
const now = new Date();
|
|
171
|
-
mockQuery.mockResolvedValue({
|
|
172
|
-
rows: [{ key: 'MY_KEY', description: null, updated_at: now }],
|
|
173
|
-
});
|
|
174
|
-
const [row] = await getAllEnvVars();
|
|
175
|
-
expect(row.description).toBeUndefined();
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
// ─── updateEnvVarDescription ──────────────────────────────────────────────────
|
|
180
|
-
|
|
181
|
-
describe('updateEnvVarDescription', () => {
|
|
182
|
-
it('issues an UPDATE on env_vars', async () => {
|
|
183
|
-
await updateEnvVarDescription('MY_KEY', 'new desc');
|
|
184
|
-
const [sql] = mockQuery.mock.calls[0];
|
|
185
|
-
expect(sql).toMatch(/UPDATE env_vars/i);
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it('passes key and description as parameters', async () => {
|
|
189
|
-
await updateEnvVarDescription('MY_KEY', 'new desc');
|
|
190
|
-
const [, params] = mockQuery.mock.calls[0];
|
|
191
|
-
expect(params).toContain('MY_KEY');
|
|
192
|
-
expect(params).toContain('new desc');
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it('does not touch the encrypted value column', async () => {
|
|
196
|
-
await updateEnvVarDescription('MY_KEY', 'new desc');
|
|
197
|
-
const [sql] = mockQuery.mock.calls[0];
|
|
198
|
-
expect(sql).not.toContain('pgp_sym_encrypt');
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
// ─── deleteEnvVar ─────────────────────────────────────────────────────────────
|
|
203
|
-
|
|
204
|
-
describe('deleteEnvVar', () => {
|
|
205
|
-
it('issues a DELETE on env_vars', async () => {
|
|
206
|
-
await deleteEnvVar('MY_KEY');
|
|
207
|
-
const [sql] = mockQuery.mock.calls[0];
|
|
208
|
-
expect(sql).toMatch(/DELETE FROM env_vars/i);
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it('passes the key as the only parameter', async () => {
|
|
212
|
-
await deleteEnvVar('MY_KEY');
|
|
213
|
-
const [, params] = mockQuery.mock.calls[0];
|
|
214
|
-
expect(params).toEqual(['MY_KEY']);
|
|
215
|
-
});
|
|
216
|
-
});
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Unit tests for agent restriction functions in db.ts.
|
|
3
|
-
*
|
|
4
|
-
* Verifies that getAgentRestrictions and upsertRestrictions issue correct SQL.
|
|
5
|
-
* No real database required — pg.Pool is mocked via vi.mock.
|
|
6
|
-
*
|
|
7
|
-
* @module web/lib/__tests__/db-restrictions.test
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
11
|
-
|
|
12
|
-
// ─── Mock pg ─────────────────────────────────────────────────────────────────
|
|
13
|
-
|
|
14
|
-
const mockQuery = vi.fn();
|
|
15
|
-
|
|
16
|
-
vi.mock('pg', () => ({
|
|
17
|
-
Pool: vi.fn().mockImplementation(function() { return { query: mockQuery }; }),
|
|
18
|
-
}));
|
|
19
|
-
|
|
20
|
-
process.env.DATABASE_URL = 'postgresql://mock/db';
|
|
21
|
-
process.env.ENV_SECRET_KEY = 'test-secret-key-32-chars-padding!';
|
|
22
|
-
|
|
23
|
-
import { getAgentRestrictions, upsertRestrictions } from '@/lib/db';
|
|
24
|
-
|
|
25
|
-
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
26
|
-
|
|
27
|
-
const AGENT_ID = 'agent-uuid-001';
|
|
28
|
-
|
|
29
|
-
const RESTRICTION_ROW = {
|
|
30
|
-
id: 'r-001',
|
|
31
|
-
agent_id: AGENT_ID,
|
|
32
|
-
allowed_channels: ['C_ABC', 'C_DEF'],
|
|
33
|
-
updated_at: new Date('2026-01-01'),
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
beforeEach(() => {
|
|
37
|
-
mockQuery.mockReset();
|
|
38
|
-
mockQuery.mockResolvedValue({ rows: [] });
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// ─── getAgentRestrictions ────────────────────────────────────────────────────
|
|
42
|
-
|
|
43
|
-
describe('getAgentRestrictions', () => {
|
|
44
|
-
it('queries agent_restrictions by agent_id', async () => {
|
|
45
|
-
await getAgentRestrictions(AGENT_ID);
|
|
46
|
-
const [sql] = mockQuery.mock.calls[0];
|
|
47
|
-
expect(sql).toContain('agent_restrictions');
|
|
48
|
-
expect(sql).toContain('agent_id');
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('passes agentId as query parameter', async () => {
|
|
52
|
-
await getAgentRestrictions(AGENT_ID);
|
|
53
|
-
const [, params] = mockQuery.mock.calls[0];
|
|
54
|
-
expect(params).toContain(AGENT_ID);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('returns null when no row found', async () => {
|
|
58
|
-
mockQuery.mockResolvedValue({ rows: [] });
|
|
59
|
-
const result = await getAgentRestrictions(AGENT_ID);
|
|
60
|
-
expect(result).toBeNull();
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('maps row to Restriction with correct fields', async () => {
|
|
64
|
-
mockQuery.mockResolvedValue({ rows: [RESTRICTION_ROW] });
|
|
65
|
-
const result = await getAgentRestrictions(AGENT_ID);
|
|
66
|
-
expect(result).not.toBeNull();
|
|
67
|
-
expect(result!.id).toBe('r-001');
|
|
68
|
-
expect(result!.agentId).toBe(AGENT_ID);
|
|
69
|
-
expect(result!.allowedChannels).toEqual(['C_ABC', 'C_DEF']);
|
|
70
|
-
expect(result!.updatedAt).toEqual(RESTRICTION_ROW.updated_at);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('defaults allowedChannels to [] when column is null', async () => {
|
|
74
|
-
mockQuery.mockResolvedValue({
|
|
75
|
-
rows: [{ ...RESTRICTION_ROW, allowed_channels: null }],
|
|
76
|
-
});
|
|
77
|
-
const result = await getAgentRestrictions(AGENT_ID);
|
|
78
|
-
expect(result!.allowedChannels).toEqual([]);
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
// ─── upsertRestrictions ──────────────────────────────────────────────────────
|
|
83
|
-
|
|
84
|
-
describe('upsertRestrictions', () => {
|
|
85
|
-
it('uses INSERT … ON CONFLICT DO UPDATE', async () => {
|
|
86
|
-
await upsertRestrictions(AGENT_ID, ['C_ABC']);
|
|
87
|
-
const [sql] = mockQuery.mock.calls[0];
|
|
88
|
-
expect(sql).toMatch(/INSERT INTO agent_restrictions/i);
|
|
89
|
-
expect(sql).toMatch(/ON CONFLICT/i);
|
|
90
|
-
expect(sql).toMatch(/DO UPDATE/i);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('passes agentId as first parameter', async () => {
|
|
94
|
-
await upsertRestrictions(AGENT_ID, ['C_ABC']);
|
|
95
|
-
const [, params] = mockQuery.mock.calls[0];
|
|
96
|
-
expect(params[0]).toBe(AGENT_ID);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('passes allowedChannels array as second parameter', async () => {
|
|
100
|
-
const channels = ['C_1', 'C_2', 'C_3'];
|
|
101
|
-
await upsertRestrictions(AGENT_ID, channels);
|
|
102
|
-
const [, params] = mockQuery.mock.calls[0];
|
|
103
|
-
expect(params[1]).toEqual(channels);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('accepts an empty allowedChannels array (unrestricted)', async () => {
|
|
107
|
-
await upsertRestrictions(AGENT_ID, []);
|
|
108
|
-
const [, params] = mockQuery.mock.calls[0];
|
|
109
|
-
expect(params[1]).toEqual([]);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it('updates allowed_channels in the SET clause', async () => {
|
|
113
|
-
await upsertRestrictions(AGENT_ID, ['C_NEW']);
|
|
114
|
-
const [sql] = mockQuery.mock.calls[0];
|
|
115
|
-
expect(sql).toContain('allowed_channels');
|
|
116
|
-
});
|
|
117
|
-
});
|