slackhive 0.1.37 → 0.1.39
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/.dockerignore +14 -0
- package/.env.example +44 -0
- package/.github/ISSUE_TEMPLATE/bug_report.yml +65 -0
- package/.github/ISSUE_TEMPLATE/config.yml +5 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +38 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +27 -0
- package/.github/dependabot.yml +20 -0
- package/.github/workflows/audit.yml +149 -0
- package/.github/workflows/ci.yml +135 -0
- package/CHANGELOG.md +52 -0
- package/CODE_OF_CONDUCT.md +37 -0
- package/CONTRIBUTING.md +204 -0
- package/LICENSE +21 -0
- package/README.md +19 -0
- package/SECURITY.md +47 -0
- package/apps/runner/Dockerfile +33 -0
- package/apps/runner/dist/__tests__/channel-restrictions.test.d.ts +8 -0
- package/apps/runner/dist/__tests__/channel-restrictions.test.js +63 -0
- package/apps/runner/dist/__tests__/channel-restrictions.test.js.map +1 -0
- package/apps/runner/dist/__tests__/claude-handler-resolve.test.d.ts +20 -0
- package/apps/runner/dist/__tests__/claude-handler-resolve.test.js +178 -0
- package/apps/runner/dist/__tests__/claude-handler-resolve.test.js.map +1 -0
- package/apps/runner/dist/__tests__/compile-claude-md.test.d.ts +13 -0
- package/apps/runner/dist/__tests__/compile-claude-md.test.js +144 -0
- package/apps/runner/dist/__tests__/compile-claude-md.test.js.map +1 -0
- package/apps/runner/dist/__tests__/memory-sync.test.d.ts +11 -0
- package/apps/runner/dist/__tests__/memory-sync.test.js +56 -0
- package/apps/runner/dist/__tests__/memory-sync.test.js.map +1 -0
- package/apps/runner/dist/__tests__/slack-file-support.test.d.ts +9 -0
- package/apps/runner/dist/__tests__/slack-file-support.test.js +271 -0
- package/apps/runner/dist/__tests__/slack-file-support.test.js.map +1 -0
- package/apps/runner/dist/__tests__/slack-formatting.test.d.ts +12 -0
- package/apps/runner/dist/__tests__/slack-formatting.test.js +400 -0
- package/apps/runner/dist/__tests__/slack-formatting.test.js.map +1 -0
- package/apps/runner/dist/__tests__/thread-context.test.d.ts +12 -0
- package/apps/runner/dist/__tests__/thread-context.test.js +182 -0
- package/apps/runner/dist/__tests__/thread-context.test.js.map +1 -0
- package/apps/runner/dist/agent-runner.d.ts +118 -0
- package/apps/runner/dist/agent-runner.js +352 -0
- package/apps/runner/dist/agent-runner.js.map +1 -0
- package/apps/runner/dist/claude-handler.d.ts +122 -0
- package/apps/runner/dist/claude-handler.js +402 -0
- package/apps/runner/dist/claude-handler.js.map +1 -0
- package/apps/runner/dist/compile-claude-md.d.ts +59 -0
- package/apps/runner/dist/compile-claude-md.js +291 -0
- package/apps/runner/dist/compile-claude-md.js.map +1 -0
- package/apps/runner/dist/correction-handler.d.ts +46 -0
- package/apps/runner/dist/correction-handler.js +162 -0
- package/apps/runner/dist/correction-handler.js.map +1 -0
- package/apps/runner/dist/correction-manager.d.ts +53 -0
- package/apps/runner/dist/correction-manager.js +241 -0
- package/apps/runner/dist/correction-manager.js.map +1 -0
- package/apps/runner/dist/db.d.ts +193 -0
- package/apps/runner/dist/db.js +492 -0
- package/apps/runner/dist/db.js.map +1 -0
- package/apps/runner/dist/index.d.ts +9 -0
- package/apps/runner/dist/index.js +43 -0
- package/apps/runner/dist/index.js.map +1 -0
- package/apps/runner/dist/job-scheduler.d.ts +57 -0
- package/apps/runner/dist/job-scheduler.js +150 -0
- package/apps/runner/dist/job-scheduler.js.map +1 -0
- package/apps/runner/dist/logger.d.ts +32 -0
- package/apps/runner/dist/logger.js +52 -0
- package/apps/runner/dist/logger.js.map +1 -0
- package/apps/runner/dist/mcp-process-manager.d.ts +38 -0
- package/apps/runner/dist/mcp-process-manager.js +189 -0
- package/apps/runner/dist/mcp-process-manager.js.map +1 -0
- package/apps/runner/dist/memory-mcp.d.ts +14 -0
- package/apps/runner/dist/memory-mcp.js +88 -0
- package/apps/runner/dist/memory-mcp.js.map +1 -0
- package/apps/runner/dist/memory-watcher.d.ts +78 -0
- package/apps/runner/dist/memory-watcher.js +220 -0
- package/apps/runner/dist/memory-watcher.js.map +1 -0
- package/apps/runner/dist/slack-handler.d.ts +120 -0
- package/apps/runner/dist/slack-handler.js +843 -0
- package/apps/runner/dist/slack-handler.js.map +1 -0
- package/apps/runner/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/apps/runner/package.json +42 -0
- package/apps/runner/src/__tests__/channel-restrictions.test.ts +75 -0
- package/apps/runner/src/__tests__/claude-handler-resolve.test.ts +160 -0
- package/apps/runner/src/__tests__/compile-claude-md.test.ts +139 -0
- package/apps/runner/src/__tests__/memory-sync.test.ts +59 -0
- package/apps/runner/src/__tests__/slack-file-support.test.ts +376 -0
- package/apps/runner/src/__tests__/slack-formatting.test.ts +495 -0
- package/apps/runner/src/__tests__/thread-context.test.ts +215 -0
- package/apps/runner/src/agent-runner.ts +397 -0
- package/apps/runner/src/claude-handler.ts +475 -0
- package/apps/runner/src/compile-claude-md.ts +283 -0
- package/apps/runner/src/correction-handler.ts +191 -0
- package/apps/runner/src/correction-manager.ts +285 -0
- package/apps/runner/src/db.ts +604 -0
- package/apps/runner/src/index.ts +46 -0
- package/apps/runner/src/job-scheduler.ts +165 -0
- package/apps/runner/src/logger.ts +49 -0
- package/apps/runner/src/mcp-process-manager.ts +195 -0
- package/apps/runner/src/memory-mcp.ts +85 -0
- package/apps/runner/src/memory-watcher.ts +215 -0
- package/apps/runner/src/slack-handler.ts +929 -0
- package/apps/runner/tsconfig.json +17 -0
- package/apps/runner/vitest.config.mts +17 -0
- package/apps/web/.eslintrc.json +3 -0
- package/apps/web/.next/app-build-manifest.json +323 -0
- package/apps/web/.next/app-path-routes-manifest.json +46 -0
- package/apps/web/.next/build-manifest.json +33 -0
- package/apps/web/.next/cache/.previewinfo +1 -0
- package/apps/web/.next/cache/.rscinfo +1 -0
- 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 +6 -0
- package/apps/web/.next/diagnostics/framework.json +1 -0
- package/apps/web/.next/package.json +1 -0
- package/apps/web/.next/react-loadable-manifest.json +1 -0
- package/apps/web/.next/server/app/_not-found/page.js +2 -0
- package/apps/web/.next/server/app/_not-found/page.js.nft.json +1 -0
- package/apps/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/agents/[slug]/page.js +4 -0
- package/apps/web/.next/server/app/agents/[slug]/page.js.nft.json +1 -0
- package/apps/web/.next/server/app/agents/[slug]/page_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/agents/new/page.js +2 -0
- package/apps/web/.next/server/app/agents/new/page.js.nft.json +1 -0
- package/apps/web/.next/server/app/agents/new/page_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/access/route.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/access/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/access/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/claude-md/route.js +6 -0
- package/apps/web/.next/server/app/api/agents/[id]/claude-md/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/claude-md/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/logs/route.js +3 -0
- package/apps/web/.next/server/app/api/agents/[id]/logs/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/logs/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/manifest/route.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/manifest/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/manifest/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/mcps/route.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/mcps/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/mcps/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/memories/[memId]/route.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/memories/[memId]/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/memories/[memId]/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/memories/route.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/memories/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/memories/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/permissions/route.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/permissions/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/permissions/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/reload/route.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/reload/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/reload/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/restrictions/route.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/restrictions/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/restrictions/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/route.js +33 -0
- package/apps/web/.next/server/app/api/agents/[id]/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/skills/[skillId]/route.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/skills/[skillId]/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/skills/[skillId]/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/skills/route.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/skills/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/skills/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/slack-info/route.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/slack-info/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/slack-info/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/snapshots/[sid]/restore/route.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/snapshots/[sid]/restore/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/snapshots/[sid]/restore/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/snapshots/[sid]/route.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/snapshots/[sid]/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/snapshots/[sid]/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/snapshots/route.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/snapshots/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/snapshots/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/start/route.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/start/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/start/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/stop/route.js +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/stop/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/agents/[id]/stop/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/agents/route.js +91 -0
- package/apps/web/.next/server/app/api/agents/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/agents/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/auth/login/route.js +1 -0
- package/apps/web/.next/server/app/api/auth/login/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/auth/logout/route.js +1 -0
- package/apps/web/.next/server/app/api/auth/logout/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/auth/me/route.js +1 -0
- package/apps/web/.next/server/app/api/auth/me/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/auth/me/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/auth/users/[id]/route.js +1 -0
- package/apps/web/.next/server/app/api/auth/users/[id]/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/auth/users/[id]/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/auth/users/route.js +1 -0
- package/apps/web/.next/server/app/api/auth/users/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/auth/users/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/env-vars/[key]/route.js +1 -0
- package/apps/web/.next/server/app/api/env-vars/[key]/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/env-vars/[key]/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/env-vars/route.js +1 -0
- package/apps/web/.next/server/app/api/env-vars/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/env-vars/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/jobs/[id]/route.js +1 -0
- package/apps/web/.next/server/app/api/jobs/[id]/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/jobs/[id]/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/jobs/[id]/runs/route.js +1 -0
- package/apps/web/.next/server/app/api/jobs/[id]/runs/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/jobs/[id]/runs/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/jobs/route.js +1 -0
- package/apps/web/.next/server/app/api/jobs/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/jobs/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/mcps/[id]/route.js +1 -0
- package/apps/web/.next/server/app/api/mcps/[id]/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/mcps/[id]/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/mcps/[id]/test/route.js +1 -0
- package/apps/web/.next/server/app/api/mcps/[id]/test/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/mcps/[id]/test/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/mcps/route.js +1 -0
- package/apps/web/.next/server/app/api/mcps/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/mcps/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/api/settings/route.js +1 -0
- package/apps/web/.next/server/app/api/settings/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/api/settings/route_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/icon.svg/route.js +1 -0
- package/apps/web/.next/server/app/icon.svg/route.js.nft.json +1 -0
- package/apps/web/.next/server/app/jobs/page.js +2 -0
- package/apps/web/.next/server/app/jobs/page.js.nft.json +1 -0
- package/apps/web/.next/server/app/jobs/page_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/login/page.js +2 -0
- package/apps/web/.next/server/app/login/page.js.nft.json +1 -0
- package/apps/web/.next/server/app/login/page_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/page.js +2 -0
- package/apps/web/.next/server/app/page.js.nft.json +1 -0
- package/apps/web/.next/server/app/page_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/settings/env-vars/page.js +2 -0
- package/apps/web/.next/server/app/settings/env-vars/page.js.nft.json +1 -0
- package/apps/web/.next/server/app/settings/env-vars/page_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/settings/mcps/page.js +2 -0
- package/apps/web/.next/server/app/settings/mcps/page.js.nft.json +1 -0
- package/apps/web/.next/server/app/settings/mcps/page_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app/settings/page.js +2 -0
- package/apps/web/.next/server/app/settings/page.js.nft.json +1 -0
- package/apps/web/.next/server/app/settings/page_client-reference-manifest.js +1 -0
- package/apps/web/.next/server/app-paths-manifest.json +46 -0
- package/apps/web/.next/server/chunks/1157.js +9 -0
- package/apps/web/.next/server/chunks/2287.js +1 -0
- package/apps/web/.next/server/chunks/3444.js +1 -0
- package/apps/web/.next/server/chunks/383.js +6 -0
- package/apps/web/.next/server/chunks/4012.js +58 -0
- package/apps/web/.next/server/chunks/6791.js +1 -0
- package/apps/web/.next/server/chunks/7171.js +1 -0
- package/apps/web/.next/server/chunks/8819.js +22 -0
- package/apps/web/.next/server/edge-runtime-webpack.js +2 -0
- package/apps/web/.next/server/edge-runtime-webpack.js.map +1 -0
- package/apps/web/.next/server/interception-route-rewrite-manifest.js +1 -0
- package/apps/web/.next/server/middleware-build-manifest.js +1 -0
- package/apps/web/.next/server/middleware-manifest.json +32 -0
- package/apps/web/.next/server/middleware-react-loadable-manifest.js +1 -0
- package/apps/web/.next/server/next-font-manifest.js +1 -0
- package/apps/web/.next/server/next-font-manifest.json +1 -0
- package/apps/web/.next/server/pages/_app.js +1 -0
- package/apps/web/.next/server/pages/_app.js.nft.json +1 -0
- package/apps/web/.next/server/pages/_document.js +1 -0
- package/apps/web/.next/server/pages/_document.js.nft.json +1 -0
- package/apps/web/.next/server/pages/_error.js +19 -0
- package/apps/web/.next/server/pages/_error.js.nft.json +1 -0
- package/apps/web/.next/server/pages-manifest.json +5 -0
- package/apps/web/.next/server/server-reference-manifest.js +1 -0
- package/apps/web/.next/server/server-reference-manifest.json +1 -0
- package/apps/web/.next/server/src/middleware.js +14 -0
- package/apps/web/.next/server/src/middleware.js.map +1 -0
- package/apps/web/.next/server/webpack-runtime.js +1 -0
- package/apps/web/.next/static/chunks/18-90b700ea37b686a2.js +1 -0
- package/apps/web/.next/static/chunks/87c73c54-24122e7b92478d00.js +1 -0
- package/apps/web/.next/static/chunks/9664-af80478aa73ba424.js +1 -0
- package/apps/web/.next/static/chunks/app/_not-found/page-b9cee17ed89ca24a.js +1 -0
- package/apps/web/.next/static/chunks/app/agents/[slug]/page-18369fc3fe1a9a7b.js +1 -0
- package/apps/web/.next/static/chunks/app/agents/new/page-bf11cf8901c7e2cd.js +1 -0
- package/apps/web/.next/static/chunks/app/api/agents/[id]/access/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/agents/[id]/claude-md/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/agents/[id]/logs/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/agents/[id]/manifest/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/agents/[id]/mcps/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/agents/[id]/memories/[memId]/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/agents/[id]/memories/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/agents/[id]/permissions/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/agents/[id]/reload/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/agents/[id]/restrictions/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/agents/[id]/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/agents/[id]/skills/[skillId]/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/agents/[id]/skills/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/agents/[id]/slack-info/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/agents/[id]/snapshots/[sid]/restore/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/agents/[id]/snapshots/[sid]/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/agents/[id]/snapshots/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/agents/[id]/start/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/agents/[id]/stop/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/agents/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/auth/login/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/auth/logout/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/auth/me/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/auth/users/[id]/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/auth/users/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/env-vars/[key]/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/env-vars/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/jobs/[id]/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/jobs/[id]/runs/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/jobs/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/mcps/[id]/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/mcps/[id]/test/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/mcps/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/api/settings/route-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/jobs/page-f5aa89a47c50efd8.js +1 -0
- package/apps/web/.next/static/chunks/app/layout-2079f4964aa7314e.js +1 -0
- package/apps/web/.next/static/chunks/app/login/layout-07f0f73ac9839899.js +1 -0
- package/apps/web/.next/static/chunks/app/login/page-aa259283dc38e8f9.js +1 -0
- package/apps/web/.next/static/chunks/app/page-e83437b608104dff.js +1 -0
- package/apps/web/.next/static/chunks/app/settings/env-vars/page-06479dbdfb78b76b.js +1 -0
- package/apps/web/.next/static/chunks/app/settings/mcps/page-75650686ed6490c7.js +1 -0
- package/apps/web/.next/static/chunks/app/settings/page-e1e62fc41ff6cddd.js +1 -0
- package/apps/web/.next/static/chunks/framework-811407f832a33072.js +1 -0
- package/apps/web/.next/static/chunks/main-3f1cddbdd67b1546.js +1 -0
- package/apps/web/.next/static/chunks/main-app-cebd8a6a5ccbf72d.js +1 -0
- package/apps/web/.next/static/chunks/pages/_app-50fa07b56b2d29ac.js +1 -0
- package/apps/web/.next/static/chunks/pages/_error-fed8688bdd23f211.js +1 -0
- package/apps/web/.next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
- package/apps/web/.next/static/chunks/webpack-6c05566dba553c97.js +1 -0
- package/apps/web/.next/static/css/15371687405525e2.css +5 -0
- package/apps/web/.next/static/ikfNbLhuw7jntn35bz0lk/_buildManifest.js +1 -0
- package/apps/web/.next/static/ikfNbLhuw7jntn35bz0lk/_ssgManifest.js +1 -0
- package/apps/web/.next/trace +5 -0
- package/apps/web/.next/types/app/agents/[slug]/page.ts +84 -0
- package/apps/web/.next/types/app/agents/new/page.ts +84 -0
- package/apps/web/.next/types/app/api/agents/[id]/access/route.ts +347 -0
- package/apps/web/.next/types/app/api/agents/[id]/claude-md/route.ts +347 -0
- package/apps/web/.next/types/app/api/agents/[id]/logs/route.ts +347 -0
- package/apps/web/.next/types/app/api/agents/[id]/manifest/route.ts +347 -0
- package/apps/web/.next/types/app/api/agents/[id]/mcps/route.ts +347 -0
- package/apps/web/.next/types/app/api/agents/[id]/memories/[memId]/route.ts +347 -0
- package/apps/web/.next/types/app/api/agents/[id]/memories/route.ts +347 -0
- package/apps/web/.next/types/app/api/agents/[id]/permissions/route.ts +347 -0
- package/apps/web/.next/types/app/api/agents/[id]/reload/route.ts +347 -0
- package/apps/web/.next/types/app/api/agents/[id]/restrictions/route.ts +347 -0
- package/apps/web/.next/types/app/api/agents/[id]/route.ts +347 -0
- package/apps/web/.next/types/app/api/agents/[id]/skills/[skillId]/route.ts +347 -0
- package/apps/web/.next/types/app/api/agents/[id]/skills/route.ts +347 -0
- package/apps/web/.next/types/app/api/agents/[id]/slack-info/route.ts +347 -0
- package/apps/web/.next/types/app/api/agents/[id]/snapshots/[sid]/restore/route.ts +347 -0
- package/apps/web/.next/types/app/api/agents/[id]/snapshots/[sid]/route.ts +347 -0
- package/apps/web/.next/types/app/api/agents/[id]/snapshots/route.ts +347 -0
- package/apps/web/.next/types/app/api/agents/[id]/start/route.ts +347 -0
- package/apps/web/.next/types/app/api/agents/[id]/stop/route.ts +347 -0
- package/apps/web/.next/types/app/api/agents/route.ts +347 -0
- package/apps/web/.next/types/app/api/auth/login/route.ts +347 -0
- package/apps/web/.next/types/app/api/auth/logout/route.ts +347 -0
- package/apps/web/.next/types/app/api/auth/me/route.ts +347 -0
- package/apps/web/.next/types/app/api/auth/users/[id]/route.ts +347 -0
- package/apps/web/.next/types/app/api/auth/users/route.ts +347 -0
- package/apps/web/.next/types/app/api/env-vars/[key]/route.ts +347 -0
- package/apps/web/.next/types/app/api/env-vars/route.ts +347 -0
- package/apps/web/.next/types/app/api/jobs/[id]/route.ts +347 -0
- package/apps/web/.next/types/app/api/jobs/[id]/runs/route.ts +347 -0
- package/apps/web/.next/types/app/api/jobs/route.ts +347 -0
- package/apps/web/.next/types/app/api/mcps/[id]/route.ts +347 -0
- package/apps/web/.next/types/app/api/mcps/[id]/test/route.ts +347 -0
- package/apps/web/.next/types/app/api/mcps/route.ts +347 -0
- package/apps/web/.next/types/app/api/settings/route.ts +347 -0
- package/apps/web/.next/types/app/jobs/page.ts +84 -0
- package/apps/web/.next/types/app/login/layout.ts +84 -0
- package/apps/web/.next/types/app/login/page.ts +84 -0
- package/apps/web/.next/types/app/page.ts +84 -0
- package/apps/web/.next/types/app/settings/env-vars/page.ts +84 -0
- package/apps/web/.next/types/app/settings/mcps/page.ts +84 -0
- package/apps/web/.next/types/app/settings/page.ts +84 -0
- package/apps/web/.next/types/cache-life.d.ts +141 -0
- package/apps/web/.next/types/package.json +1 -0
- package/apps/web/.next/types/routes.d.ts +114 -0
- package/apps/web/.next/types/validator.ts +448 -0
- package/apps/web/Dockerfile +37 -0
- package/apps/web/next-env.d.ts +6 -0
- package/apps/web/next.config.js +6 -0
- package/apps/web/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/apps/web/package.json +48 -0
- package/apps/web/postcss.config.js +3 -0
- package/apps/web/public/logo.svg +17 -0
- package/apps/web/src/app/agents/[slug]/page.tsx +2235 -0
- package/apps/web/src/app/agents/new/page.tsx +1161 -0
- package/apps/web/src/app/api/agents/[id]/access/route.ts +76 -0
- package/apps/web/src/app/api/agents/[id]/claude-md/route.ts +111 -0
- package/apps/web/src/app/api/agents/[id]/logs/route.ts +84 -0
- package/apps/web/src/app/api/agents/[id]/manifest/route.ts +32 -0
- package/apps/web/src/app/api/agents/[id]/mcps/route.ts +73 -0
- package/apps/web/src/app/api/agents/[id]/memories/[memId]/route.ts +31 -0
- package/apps/web/src/app/api/agents/[id]/memories/route.ts +56 -0
- package/apps/web/src/app/api/agents/[id]/permissions/route.ts +74 -0
- package/apps/web/src/app/api/agents/[id]/reload/route.ts +33 -0
- package/apps/web/src/app/api/agents/[id]/restrictions/route.ts +85 -0
- package/apps/web/src/app/api/agents/[id]/route.ts +81 -0
- package/apps/web/src/app/api/agents/[id]/skills/[skillId]/route.ts +52 -0
- package/apps/web/src/app/api/agents/[id]/skills/route.ts +80 -0
- package/apps/web/src/app/api/agents/[id]/slack-info/route.ts +38 -0
- package/apps/web/src/app/api/agents/[id]/snapshots/[sid]/restore/route.ts +61 -0
- package/apps/web/src/app/api/agents/[id]/snapshots/[sid]/route.ts +53 -0
- package/apps/web/src/app/api/agents/[id]/snapshots/route.ts +84 -0
- package/apps/web/src/app/api/agents/[id]/start/route.ts +35 -0
- package/apps/web/src/app/api/agents/[id]/stop/route.ts +35 -0
- package/apps/web/src/app/api/agents/route.ts +99 -0
- package/apps/web/src/app/api/auth/login/route.ts +39 -0
- package/apps/web/src/app/api/auth/logout/route.ts +21 -0
- package/apps/web/src/app/api/auth/me/route.ts +24 -0
- package/apps/web/src/app/api/auth/users/[id]/route.ts +48 -0
- package/apps/web/src/app/api/auth/users/route.ts +63 -0
- package/apps/web/src/app/api/env-vars/[key]/route.ts +66 -0
- package/apps/web/src/app/api/env-vars/route.ts +59 -0
- package/apps/web/src/app/api/jobs/[id]/route.ts +51 -0
- package/apps/web/src/app/api/jobs/[id]/runs/route.ts +24 -0
- package/apps/web/src/app/api/jobs/route.ts +42 -0
- package/apps/web/src/app/api/mcps/[id]/route.ts +60 -0
- package/apps/web/src/app/api/mcps/[id]/test/route.ts +195 -0
- package/apps/web/src/app/api/mcps/route.ts +72 -0
- package/apps/web/src/app/api/settings/route.ts +42 -0
- package/apps/web/src/app/globals.css +124 -0
- package/apps/web/src/app/icon.svg +17 -0
- package/apps/web/src/app/jobs/page.tsx +543 -0
- package/apps/web/src/app/layout-shell.tsx +89 -0
- package/apps/web/src/app/layout.tsx +18 -0
- package/apps/web/src/app/login/layout.tsx +9 -0
- package/apps/web/src/app/login/page.tsx +150 -0
- package/apps/web/src/app/page.tsx +573 -0
- package/apps/web/src/app/settings/env-vars/page.tsx +216 -0
- package/apps/web/src/app/settings/mcps/page.tsx +763 -0
- package/apps/web/src/app/settings/page.tsx +528 -0
- package/apps/web/src/app/sidebar.tsx +345 -0
- package/apps/web/src/lib/__tests__/api-guard.test.ts +189 -0
- package/apps/web/src/lib/__tests__/auth.test.ts +262 -0
- package/apps/web/src/lib/__tests__/boss-registry.test.ts +323 -0
- package/apps/web/src/lib/__tests__/compile.test.ts +161 -0
- package/apps/web/src/lib/__tests__/db-agent-hierarchy.test.ts +136 -0
- package/apps/web/src/lib/__tests__/db-env-vars.test.ts +216 -0
- package/apps/web/src/lib/__tests__/db-restrictions.test.ts +117 -0
- package/apps/web/src/lib/__tests__/db.integration.test.ts +271 -0
- package/apps/web/src/lib/__tests__/diff.test.ts +102 -0
- package/apps/web/src/lib/__tests__/mcp-mask.test.ts +274 -0
- package/apps/web/src/lib/__tests__/skill-templates.test.ts +237 -0
- package/apps/web/src/lib/__tests__/slack-manifest.test.ts +105 -0
- package/apps/web/src/lib/api-guard.ts +68 -0
- package/apps/web/src/lib/auth-context.tsx +71 -0
- package/apps/web/src/lib/auth.ts +128 -0
- package/apps/web/src/lib/boss-registry.ts +90 -0
- package/apps/web/src/lib/compile.ts +51 -0
- package/apps/web/src/lib/db.ts +1196 -0
- package/apps/web/src/lib/diff.ts +43 -0
- package/apps/web/src/lib/mcp-mask.ts +91 -0
- package/apps/web/src/lib/portal.tsx +23 -0
- package/apps/web/src/lib/skill-templates.ts +148 -0
- package/apps/web/src/lib/slack-manifest.ts +85 -0
- package/apps/web/src/middleware.ts +68 -0
- package/apps/web/tailwind.config.js +6 -0
- package/apps/web/tsconfig.json +23 -0
- package/apps/web/vitest.config.mts +21 -0
- package/cli/.claude/settings.local.json +6 -0
- package/cli/README.md +281 -0
- package/cli/node_modules/.package-lock.json +427 -0
- package/cli/node_modules/commander/LICENSE +22 -0
- package/cli/node_modules/commander/Readme.md +1157 -0
- package/cli/node_modules/commander/esm.mjs +16 -0
- package/cli/node_modules/commander/index.js +24 -0
- package/cli/node_modules/commander/lib/argument.js +149 -0
- package/cli/node_modules/commander/lib/command.js +2509 -0
- package/cli/node_modules/commander/lib/error.js +39 -0
- package/cli/node_modules/commander/lib/help.js +520 -0
- package/cli/node_modules/commander/lib/option.js +330 -0
- package/cli/node_modules/commander/lib/suggestSimilar.js +101 -0
- package/cli/node_modules/commander/package-support.json +16 -0
- package/cli/node_modules/commander/package.json +84 -0
- package/cli/node_modules/commander/typings/esm.d.mts +3 -0
- package/cli/node_modules/commander/typings/index.d.ts +969 -0
- package/cli/package-lock.json +449 -0
- package/cli/package.json +44 -0
- package/cli/src/commands/init.ts +514 -0
- package/cli/src/commands/manage.ts +115 -0
- package/cli/src/index.ts +63 -0
- package/cli/tsconfig.json +14 -0
- package/docker-compose.yml +122 -0
- package/docs/agents/boss-agents.mdx +108 -0
- package/docs/agents/creating-agents.mdx +132 -0
- package/docs/agents/memory.mdx +113 -0
- package/docs/agents/tools.mdx +103 -0
- package/docs/configuration/env-vars.mdx +166 -0
- package/docs/configuration/mcp-servers.mdx +203 -0
- package/docs/configuration/slack-app.mdx +175 -0
- package/docs/docs.json +79 -0
- package/docs/favicon.svg +17 -0
- package/docs/features/history.mdx +60 -0
- package/docs/features/import-export.mdx +77 -0
- package/docs/features/logs.mdx +131 -0
- package/docs/features/multi-workspace.mdx +90 -0
- package/docs/features/scheduled-jobs.mdx +231 -0
- package/docs/features/users.mdx +92 -0
- package/docs/introduction.mdx +160 -0
- package/docs/logo/dark.svg +17 -0
- package/docs/logo/light.svg +17 -0
- package/docs/logo/wide-dark.svg +12 -0
- package/docs/logo/wide-light.svg +12 -0
- package/docs/quickstart.mdx +270 -0
- package/docs/self-hosting/docker.mdx +151 -0
- package/docs/self-hosting/production.mdx +176 -0
- package/package.json +20 -36
- package/packages/shared/dist/index.d.ts +8 -0
- package/packages/shared/dist/index.d.ts.map +1 -0
- package/packages/shared/dist/index.js +24 -0
- package/packages/shared/dist/index.js.map +1 -0
- package/packages/shared/dist/types.d.ts +584 -0
- package/packages/shared/dist/types.d.ts.map +1 -0
- package/packages/shared/dist/types.js +39 -0
- package/packages/shared/dist/types.js.map +1 -0
- package/packages/shared/package.json +15 -0
- package/packages/shared/src/db/schema.sql +354 -0
- package/packages/shared/src/index.ts +8 -0
- package/packages/shared/src/types.ts +683 -0
- package/packages/shared/tsconfig.json +17 -0
- package/scripts/dev.sh +45 -0
- /package/{dist → cli/dist}/commands/init.d.ts +0 -0
- /package/{dist → cli/dist}/commands/init.js +0 -0
- /package/{dist → cli/dist}/commands/manage.d.ts +0 -0
- /package/{dist → cli/dist}/commands/manage.js +0 -0
- /package/{dist → cli/dist}/index.d.ts +0 -0
- /package/{dist → cli/dist}/index.js +0 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Generic correction manager for any SlackHive agent.
|
|
4
|
+
*
|
|
5
|
+
* Corrections are stored as a skill in the database (category: '99-corrections',
|
|
6
|
+
* filename: 'corrections.md') so they:
|
|
7
|
+
* - Persist across container restarts (Postgres)
|
|
8
|
+
* - Are visible/editable in the SlackHive web UI Skills tab
|
|
9
|
+
* - Are automatically compiled into the agent's CLAUDE.md
|
|
10
|
+
*
|
|
11
|
+
* Uses Claude to intelligently consolidate new corrections (dedup, categorize).
|
|
12
|
+
*
|
|
13
|
+
* Adapted from nlq-claude-slack-bot/src/correction-manager.ts.
|
|
14
|
+
* Key changes: flat file -> Postgres skill, NLQ-specific -> generic agent.
|
|
15
|
+
*
|
|
16
|
+
* @module runner/correction-manager
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.CorrectionManager = void 0;
|
|
20
|
+
const claude_agent_sdk_1 = require("@anthropic-ai/claude-agent-sdk");
|
|
21
|
+
const db_1 = require("./db");
|
|
22
|
+
const compile_claude_md_1 = require("./compile-claude-md");
|
|
23
|
+
const logger_1 = require("./logger");
|
|
24
|
+
const CORRECTIONS_CATEGORY = '99-corrections';
|
|
25
|
+
const CORRECTIONS_FILENAME = 'corrections.md';
|
|
26
|
+
const CORRECTIONS_SORT_ORDER = 99;
|
|
27
|
+
const MAX_CORRECTIONS = 30;
|
|
28
|
+
class CorrectionManager {
|
|
29
|
+
agent;
|
|
30
|
+
log;
|
|
31
|
+
writeChain = Promise.resolve();
|
|
32
|
+
constructor(agent) {
|
|
33
|
+
this.agent = agent;
|
|
34
|
+
this.log = (0, logger_1.agentLogger)(agent.slug);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Reads the current corrections content from the database.
|
|
38
|
+
*/
|
|
39
|
+
async readCorrections() {
|
|
40
|
+
try {
|
|
41
|
+
const skills = await (0, db_1.getAgentSkills)(this.agent.id);
|
|
42
|
+
const correctionSkill = skills.find((s) => s.category === CORRECTIONS_CATEGORY && s.filename === CORRECTIONS_FILENAME);
|
|
43
|
+
return correctionSkill?.content ?? '';
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
this.log.error('Failed to read corrections from DB', { error });
|
|
47
|
+
return '';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Counts the number of corrections (lines starting with digits followed by a dot).
|
|
52
|
+
*/
|
|
53
|
+
async getCount() {
|
|
54
|
+
const content = await this.readCorrections();
|
|
55
|
+
if (!content)
|
|
56
|
+
return 0;
|
|
57
|
+
const matches = content.match(/^\d+\.\s/gm);
|
|
58
|
+
return matches ? matches.length : 0;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Adds a new correction, using Claude to consolidate and deduplicate.
|
|
62
|
+
* Serializes writes to prevent race conditions.
|
|
63
|
+
*/
|
|
64
|
+
async addCorrection(text, reviewerId, threadContext) {
|
|
65
|
+
const result = await new Promise((resolve) => {
|
|
66
|
+
this.writeChain = this.writeChain.then(async () => {
|
|
67
|
+
resolve(await this._addCorrection(text, reviewerId, threadContext));
|
|
68
|
+
}).catch((error) => {
|
|
69
|
+
this.log.error('Write chain error', { error });
|
|
70
|
+
resolve({ success: false, message: 'Internal error adding correction.', count: 0 });
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
async _addCorrection(text, reviewerId, threadContext) {
|
|
76
|
+
const existing = await this.readCorrections();
|
|
77
|
+
const count = await this.getCount();
|
|
78
|
+
const slug = this.agent.slug;
|
|
79
|
+
if (count >= MAX_CORRECTIONS) {
|
|
80
|
+
return {
|
|
81
|
+
success: false,
|
|
82
|
+
message: `At capacity (${MAX_CORRECTIONS}/${MAX_CORRECTIONS}). Remove an old correction first with \`${slug}:corrections remove <N>\`.`,
|
|
83
|
+
count,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const today = new Date().toLocaleDateString('en-SG', {
|
|
87
|
+
timeZone: 'Asia/Singapore', year: 'numeric', month: 'short', day: 'numeric',
|
|
88
|
+
});
|
|
89
|
+
const agentDesc = this.agent.description
|
|
90
|
+
? `a ${this.agent.description} bot`
|
|
91
|
+
: `the ${this.agent.name} bot`;
|
|
92
|
+
const threadContextBlock = threadContext
|
|
93
|
+
? `\nTHREAD CONTEXT (the conversation that prompted this correction):\n${threadContext}\n`
|
|
94
|
+
: '';
|
|
95
|
+
const threadContextTask = threadContext
|
|
96
|
+
? `\n7. Use the thread context to understand what went wrong, but write the correction as a GENERAL rule\n (not specific to this one question). The correction should help the bot handle ALL similar cases.`
|
|
97
|
+
: '';
|
|
98
|
+
const consolidationPrompt = `You maintain a corrections file for ${agentDesc}.
|
|
99
|
+
|
|
100
|
+
CURRENT FILE:
|
|
101
|
+
---
|
|
102
|
+
${existing || '(empty)'}
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
NEW CORRECTION (submitted by reviewer):
|
|
106
|
+
"${text}"
|
|
107
|
+
${threadContextBlock}
|
|
108
|
+
Reviewer ID: @${reviewerId}
|
|
109
|
+
Date: ${today}
|
|
110
|
+
|
|
111
|
+
Tasks:
|
|
112
|
+
1. If this duplicates an existing correction, respond with ONLY: DUPLICATE: <number>
|
|
113
|
+
2. If this supersedes/updates an existing one, replace it
|
|
114
|
+
3. If it's new, add it to the appropriate category (create a new category if needed)
|
|
115
|
+
4. Keep corrections numbered sequentially across all categories
|
|
116
|
+
5. Keep each correction as a single concise line
|
|
117
|
+
6. Add attribution: (@${reviewerId}, ${today})${threadContextTask}
|
|
118
|
+
|
|
119
|
+
Respond with the FULL updated file content (including the # heading and ## categories).
|
|
120
|
+
If duplicate, respond with ONLY: DUPLICATE: <number>`;
|
|
121
|
+
try {
|
|
122
|
+
let responseText = '';
|
|
123
|
+
for await (const message of (0, claude_agent_sdk_1.query)({
|
|
124
|
+
prompt: consolidationPrompt,
|
|
125
|
+
options: {
|
|
126
|
+
permissionMode: 'bypassPermissions',
|
|
127
|
+
tools: [],
|
|
128
|
+
maxTurns: 1,
|
|
129
|
+
},
|
|
130
|
+
})) {
|
|
131
|
+
if (message.type === 'assistant' && message.message.content) {
|
|
132
|
+
for (const part of message.message.content) {
|
|
133
|
+
if (part.type === 'text') {
|
|
134
|
+
responseText += part.text;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else if (message.type === 'result' && message.result) {
|
|
139
|
+
responseText = message.result;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
responseText = responseText.trim();
|
|
143
|
+
// Check for duplicate
|
|
144
|
+
if (responseText.startsWith('DUPLICATE:')) {
|
|
145
|
+
const dupNum = responseText.replace('DUPLICATE:', '').trim();
|
|
146
|
+
return {
|
|
147
|
+
success: false,
|
|
148
|
+
message: `This duplicates correction #${dupNum}. No changes made.`,
|
|
149
|
+
count,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
// Store as a skill in the database
|
|
153
|
+
await (0, db_1.upsertSkill)(this.agent.id, CORRECTIONS_CATEGORY, CORRECTIONS_FILENAME, responseText, CORRECTIONS_SORT_ORDER);
|
|
154
|
+
// Recompile CLAUDE.md so corrections take effect immediately
|
|
155
|
+
await (0, compile_claude_md_1.compileClaudeMd)(this.agent);
|
|
156
|
+
const newCount = await this.getCount();
|
|
157
|
+
this.log.info('Correction added', { reviewerId, newCount });
|
|
158
|
+
return {
|
|
159
|
+
success: true,
|
|
160
|
+
message: `Correction added (${newCount}/${MAX_CORRECTIONS} slots used).`,
|
|
161
|
+
count: newCount,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
this.log.error('Failed to consolidate correction via Claude', { error });
|
|
166
|
+
return {
|
|
167
|
+
success: false,
|
|
168
|
+
message: 'Failed to process correction. Please try again.',
|
|
169
|
+
count,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Removes a correction by its number and renumbers the rest.
|
|
175
|
+
*/
|
|
176
|
+
async removeCorrection(index) {
|
|
177
|
+
const content = await this.readCorrections();
|
|
178
|
+
if (!content) {
|
|
179
|
+
return { success: false, message: 'No corrections on file.' };
|
|
180
|
+
}
|
|
181
|
+
const lines = content.split('\n');
|
|
182
|
+
const targetPattern = new RegExp(`^${index}\\.\\s`);
|
|
183
|
+
const lineIndex = lines.findIndex((line) => targetPattern.test(line));
|
|
184
|
+
if (lineIndex === -1) {
|
|
185
|
+
return { success: false, message: `Correction #${index} not found.` };
|
|
186
|
+
}
|
|
187
|
+
// Remove the line
|
|
188
|
+
lines.splice(lineIndex, 1);
|
|
189
|
+
// Renumber all remaining numbered items sequentially
|
|
190
|
+
let num = 1;
|
|
191
|
+
const renumbered = lines.map((line) => {
|
|
192
|
+
if (/^\d+\.\s/.test(line)) {
|
|
193
|
+
const replaced = line.replace(/^\d+\./, `${num}.`);
|
|
194
|
+
num++;
|
|
195
|
+
return replaced;
|
|
196
|
+
}
|
|
197
|
+
return line;
|
|
198
|
+
});
|
|
199
|
+
// Clean up empty category sections
|
|
200
|
+
const cleaned = [];
|
|
201
|
+
for (let i = 0; i < renumbered.length; i++) {
|
|
202
|
+
const line = renumbered[i];
|
|
203
|
+
if (line.startsWith('## ')) {
|
|
204
|
+
let nextContentIdx = i + 1;
|
|
205
|
+
while (nextContentIdx < renumbered.length && renumbered[nextContentIdx].trim() === '') {
|
|
206
|
+
nextContentIdx++;
|
|
207
|
+
}
|
|
208
|
+
if (nextContentIdx >= renumbered.length || renumbered[nextContentIdx].startsWith('## ') || renumbered[nextContentIdx].startsWith('# ')) {
|
|
209
|
+
i = nextContentIdx - 1;
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
cleaned.push(line);
|
|
214
|
+
}
|
|
215
|
+
const result = cleaned.join('\n').replace(/\n{3,}/g, '\n\n').trim();
|
|
216
|
+
if (result === '# Verified Corrections' || result === '') {
|
|
217
|
+
// All corrections removed — delete the skill
|
|
218
|
+
await (0, db_1.deleteSkill)(this.agent.id, CORRECTIONS_CATEGORY, CORRECTIONS_FILENAME);
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
await (0, db_1.upsertSkill)(this.agent.id, CORRECTIONS_CATEGORY, CORRECTIONS_FILENAME, result + '\n', CORRECTIONS_SORT_ORDER);
|
|
222
|
+
}
|
|
223
|
+
// Recompile CLAUDE.md
|
|
224
|
+
await (0, compile_claude_md_1.compileClaudeMd)(this.agent);
|
|
225
|
+
const newCount = await this.getCount();
|
|
226
|
+
return {
|
|
227
|
+
success: true,
|
|
228
|
+
message: newCount > 0
|
|
229
|
+
? `Correction #${index} removed. ${newCount} correction(s) remaining.`
|
|
230
|
+
: `Correction #${index} removed. No corrections remaining.`,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Returns the raw corrections content.
|
|
235
|
+
*/
|
|
236
|
+
async getRaw() {
|
|
237
|
+
return this.readCorrections();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
exports.CorrectionManager = CorrectionManager;
|
|
241
|
+
//# sourceMappingURL=correction-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"correction-manager.js","sourceRoot":"","sources":["../src/correction-manager.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,qEAAuD;AACvD,6BAAgE;AAChE,2DAAsD;AAEtD,qCAAuC;AAEvC,MAAM,oBAAoB,GAAG,gBAAgB,CAAC;AAC9C,MAAM,oBAAoB,GAAG,gBAAgB,CAAC;AAC9C,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,eAAe,GAAG,EAAE,CAAC;AAQ3B,MAAa,iBAAiB;IACpB,KAAK,CAAQ;IACb,GAAG,CAAC;IACJ,UAAU,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IAEtD,YAAY,KAAY;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,GAAG,GAAG,IAAA,oBAAW,EAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,eAAe;QACnB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAA,mBAAc,EAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACnD,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CACjC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,oBAAoB,IAAI,CAAC,CAAC,QAAQ,KAAK,oBAAoB,CAClF,CAAC;YACF,OAAO,eAAe,EAAE,OAAO,IAAI,EAAE,CAAC;QACxC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,oCAAoC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YAChE,OAAO,EAAE,C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EAAE,EAAE,oBAAoB,EAAE,oBAAoB,CAAC,CAAC;QAC/E,CAAC;aAAM,CAAC;YACN,MAAM,IAAA,gBAAW,EACf,IAAI,CAAC,KAAK,CAAC,EAAE,EACb,oBAAoB,EACpB,oBAAoB,EACpB,MAAM,GAAG,IAAI,EACb,sBAAsB,CACvB,CAAC;QACJ,CAAC;QAED,sBAAsB;QACtB,MAAM,IAAA,mCAAe,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAElC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QACvC,OAAO;YACL,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,QAAQ,GAAG,CAAC;gBACnB,CAAC,CAAC,eAAe,KAAK,aAAa,QAAQ,2BAA2B;gBACtE,CAAC,CAAC,eAAe,KAAK,qCAAqC;SAC9D,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM;QACV,OAAO,IAAI,CAAC,eAAe,EAAE,CAAC;IAChC,CAAC;CACF;AA1PD,8CA0PC"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview PostgreSQL database client for the runner service.
|
|
3
|
+
*
|
|
4
|
+
* Provides a singleton Pool instance and typed query helpers for all
|
|
5
|
+
* tables used by the runner: agents, mcp_servers, agent_mcps, skills,
|
|
6
|
+
* permissions, memories, and sessions.
|
|
7
|
+
*
|
|
8
|
+
* @module runner/db
|
|
9
|
+
*/
|
|
10
|
+
import { Pool } from 'pg';
|
|
11
|
+
import type { Agent, McpServer, ScheduledJob, Skill, Permission, Restriction, Memory, Session, AgentStatus } from '@slackhive/shared';
|
|
12
|
+
/**
|
|
13
|
+
* Returns the singleton Postgres connection pool.
|
|
14
|
+
* Creates the pool on first call using DATABASE_URL from environment.
|
|
15
|
+
*
|
|
16
|
+
* @returns {Pool} The Postgres connection pool.
|
|
17
|
+
* @throws {Error} If DATABASE_URL is not set.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getPool(): Pool;
|
|
20
|
+
/**
|
|
21
|
+
* Closes the Postgres connection pool.
|
|
22
|
+
* Should be called on graceful shutdown.
|
|
23
|
+
*
|
|
24
|
+
* @returns {Promise<void>}
|
|
25
|
+
*/
|
|
26
|
+
export declare function closePool(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Fetches all agents from the database.
|
|
29
|
+
*
|
|
30
|
+
* @returns {Promise<Agent[]>} All registered agents.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getAllAgents(): Promise<Agent[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Fetches a single agent by ID.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} id - Agent UUID.
|
|
37
|
+
* @returns {Promise<Agent | null>} The agent, or null if not found.
|
|
38
|
+
*/
|
|
39
|
+
export declare function getAgentById(id: string): Promise<Agent | null>;
|
|
40
|
+
/**
|
|
41
|
+
* Updates the runtime status of an agent.
|
|
42
|
+
*
|
|
43
|
+
* @param {string} id - Agent UUID.
|
|
44
|
+
* @param {AgentStatus} status - New status value.
|
|
45
|
+
* @returns {Promise<void>}
|
|
46
|
+
*/
|
|
47
|
+
export declare function updateAgentStatus(id: string, status: AgentStatus): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Updates the Slack bot user ID for an agent after successful auth.test.
|
|
50
|
+
*
|
|
51
|
+
* @param {string} id - Agent UUID.
|
|
52
|
+
* @param {string} slackBotUserId - The bot's Slack user ID (e.g., "U12345678").
|
|
53
|
+
* @returns {Promise<void>}
|
|
54
|
+
*/
|
|
55
|
+
export declare function updateAgentSlackUserId(id: string, slackBotUserId: string): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Fetches all MCP servers assigned to an agent, in catalog order.
|
|
58
|
+
*
|
|
59
|
+
* @param {string} agentId - Agent UUID.
|
|
60
|
+
* @returns {Promise<McpServer[]>} MCP servers assigned to this agent.
|
|
61
|
+
*/
|
|
62
|
+
export declare function getAgentMcpServers(agentId: string): Promise<McpServer[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Fetches all skills for an agent, ordered for CLAUDE.md compilation.
|
|
65
|
+
* Skills are ordered by category (alphabetical) then sort_order (ascending).
|
|
66
|
+
*
|
|
67
|
+
* @param {string} agentId - Agent UUID.
|
|
68
|
+
* @returns {Promise<Skill[]>} Ordered skill files for this agent.
|
|
69
|
+
*/
|
|
70
|
+
export declare function getAgentSkills(agentId: string): Promise<Skill[]>;
|
|
71
|
+
/**
|
|
72
|
+
* Upserts a skill for an agent.
|
|
73
|
+
* Conflicts on (agent_id, category, filename) update content and sort_order.
|
|
74
|
+
*
|
|
75
|
+
* @param {string} agentId - Agent UUID.
|
|
76
|
+
* @param {string} category - Skill category directory (e.g. `'99-corrections'`).
|
|
77
|
+
* @param {string} filename - Skill filename (e.g. `'corrections.md'`).
|
|
78
|
+
* @param {string} content - Full markdown content of the skill.
|
|
79
|
+
* @param {number} [sortOrder=0] - Sort order within the category.
|
|
80
|
+
* @returns {Promise<Skill>} The upserted skill.
|
|
81
|
+
*/
|
|
82
|
+
export declare function upsertSkill(agentId: string, category: string, filename: string, content: string, sortOrder?: number): Promise<Skill>;
|
|
83
|
+
/**
|
|
84
|
+
* Deletes a skill by agent_id, category, and filename.
|
|
85
|
+
*
|
|
86
|
+
* @param {string} agentId - Agent UUID.
|
|
87
|
+
* @param {string} category - Skill category directory.
|
|
88
|
+
* @param {string} filename - Skill filename.
|
|
89
|
+
* @returns {Promise<boolean>} True if a row was deleted.
|
|
90
|
+
*/
|
|
91
|
+
export declare function deleteSkill(agentId: string, category: string, filename: string): Promise<boolean>;
|
|
92
|
+
/**
|
|
93
|
+
* Fetches the tool permissions for an agent.
|
|
94
|
+
*
|
|
95
|
+
* @param {string} agentId - Agent UUID.
|
|
96
|
+
* @returns {Promise<Permission | null>} The permission record, or null if not set.
|
|
97
|
+
*/
|
|
98
|
+
export declare function getAgentPermissions(agentId: string): Promise<Permission | null>;
|
|
99
|
+
/**
|
|
100
|
+
* Fetches the channel restrictions for an agent.
|
|
101
|
+
*
|
|
102
|
+
* @param {string} agentId - Agent UUID.
|
|
103
|
+
* @returns {Promise<Restriction | null>} The restriction record, or null if not configured.
|
|
104
|
+
*/
|
|
105
|
+
export declare function getAgentRestrictions(agentId: string): Promise<Restriction | null>;
|
|
106
|
+
/**
|
|
107
|
+
* Fetches all memory entries for an agent, ordered by type then created_at.
|
|
108
|
+
*
|
|
109
|
+
* @param {string} agentId - Agent UUID.
|
|
110
|
+
* @returns {Promise<Memory[]>} All memory entries for this agent.
|
|
111
|
+
*/
|
|
112
|
+
export declare function getAgentMemories(agentId: string): Promise<Memory[]>;
|
|
113
|
+
/**
|
|
114
|
+
* Upserts a memory entry for an agent.
|
|
115
|
+
* If a memory with the same agent_id and name already exists, it is updated.
|
|
116
|
+
* Otherwise a new entry is created.
|
|
117
|
+
*
|
|
118
|
+
* This is called by the memory watcher when the agent writes new memory files
|
|
119
|
+
* to disk during a conversation.
|
|
120
|
+
*
|
|
121
|
+
* @param {string} agentId - Agent UUID.
|
|
122
|
+
* @param {Memory['type']} type - Memory type classification.
|
|
123
|
+
* @param {string} name - Unique name/identifier for this memory.
|
|
124
|
+
* @param {string} content - Full markdown content of the memory.
|
|
125
|
+
* @returns {Promise<Memory>} The upserted memory record.
|
|
126
|
+
*/
|
|
127
|
+
export declare function upsertMemory(agentId: string, type: Memory['type'], name: string, content: string): Promise<Memory>;
|
|
128
|
+
/**
|
|
129
|
+
* Upserts a memory entry by agent_id and name (no unique constraint version).
|
|
130
|
+
* Uses a safe upsert pattern compatible with the current schema.
|
|
131
|
+
*
|
|
132
|
+
* @param {string} agentId - Agent UUID.
|
|
133
|
+
* @param {Memory['type']} type - Memory type classification.
|
|
134
|
+
* @param {string} name - Memory name (used as identifier).
|
|
135
|
+
* @param {string} content - Full markdown content.
|
|
136
|
+
* @returns {Promise<void>}
|
|
137
|
+
*/
|
|
138
|
+
export declare function upsertMemorySafe(agentId: string, type: Memory['type'], name: string, content: string): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* Fetches a conversation session by agent and session key.
|
|
141
|
+
*
|
|
142
|
+
* @param {string} agentId - Agent UUID.
|
|
143
|
+
* @param {string} sessionKey - Composite key: {userId}-{channelId}-{threadTs|'direct'}.
|
|
144
|
+
* @returns {Promise<Session | null>} The session, or null if not found.
|
|
145
|
+
*/
|
|
146
|
+
export declare function getSession(agentId: string, sessionKey: string): Promise<Session | null>;
|
|
147
|
+
/**
|
|
148
|
+
* Creates or updates a conversation session.
|
|
149
|
+
* Updates last_activity on conflict.
|
|
150
|
+
*
|
|
151
|
+
* @param {string} agentId - Agent UUID.
|
|
152
|
+
* @param {string} sessionKey - Composite session key.
|
|
153
|
+
* @param {string | undefined} claudeSessionId - Claude Code SDK session ID.
|
|
154
|
+
* @returns {Promise<Session>} The upserted session.
|
|
155
|
+
*/
|
|
156
|
+
export declare function upsertSession(agentId: string, sessionKey: string, claudeSessionId?: string, mcpHash?: string): Promise<Session>;
|
|
157
|
+
/**
|
|
158
|
+
* Deletes sessions for an agent that have been inactive for longer than maxAgeMs.
|
|
159
|
+
*
|
|
160
|
+
* @param {string} agentId - Agent UUID.
|
|
161
|
+
* @param {number} maxAgeMs - Maximum session age in milliseconds.
|
|
162
|
+
* @returns {Promise<number>} Number of sessions deleted.
|
|
163
|
+
*/
|
|
164
|
+
export declare function cleanupStaleSessions(agentId: string, maxAgeMs: number): Promise<number>;
|
|
165
|
+
/**
|
|
166
|
+
* Returns all enabled scheduled jobs.
|
|
167
|
+
*
|
|
168
|
+
* @returns {Promise<ScheduledJob[]>}
|
|
169
|
+
*/
|
|
170
|
+
export declare function getAllEnabledJobs(): Promise<ScheduledJob[]>;
|
|
171
|
+
/**
|
|
172
|
+
* Inserts a new job run record with status 'running'.
|
|
173
|
+
*
|
|
174
|
+
* @param {string} jobId - The scheduled job ID.
|
|
175
|
+
* @returns {Promise<string>} The new run ID.
|
|
176
|
+
*/
|
|
177
|
+
export declare function insertJobRun(jobId: string): Promise<string>;
|
|
178
|
+
/**
|
|
179
|
+
* Updates a job run with final status, output, and error.
|
|
180
|
+
*
|
|
181
|
+
* @param {string} runId - The run ID.
|
|
182
|
+
* @param {'success' | 'error'} status - Final status.
|
|
183
|
+
* @param {string | null} output - Truncated output text.
|
|
184
|
+
* @param {string | null} error - Error message if failed.
|
|
185
|
+
*/
|
|
186
|
+
export declare function updateJobRun(runId: string, status: 'success' | 'error', output?: string | null, error?: string | null): Promise<void>;
|
|
187
|
+
/**
|
|
188
|
+
* Returns all env vars as a key→value map. Used by the runner to resolve
|
|
189
|
+
* envRefs in MCP stdio configs at agent start time.
|
|
190
|
+
*
|
|
191
|
+
* @returns {Promise<Record<string, string>>}
|
|
192
|
+
*/
|
|
193
|
+
export declare function getAllEnvVarValues(): Promise<Record<string, string>>;
|