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,291 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Agent workspace compiler for the runner service.
|
|
4
|
+
*
|
|
5
|
+
* Writes two things to the agent's temporary working directory:
|
|
6
|
+
*
|
|
7
|
+
* 1. CLAUDE.md — the agent's main instruction/identity file.
|
|
8
|
+
* Source: agents.claude_md column (or auto-generated for boss agents).
|
|
9
|
+
* Memories are appended at the end.
|
|
10
|
+
*
|
|
11
|
+
* 2. .claude/commands/{filename} — Claude Code slash commands.
|
|
12
|
+
* Source: skills table rows for this agent.
|
|
13
|
+
* Each skill becomes an invokable /<filename> command.
|
|
14
|
+
*
|
|
15
|
+
* Directory layout:
|
|
16
|
+
* /tmp/agents/{slug}/
|
|
17
|
+
* CLAUDE.md ← identity + memories
|
|
18
|
+
* .claude/
|
|
19
|
+
* commands/
|
|
20
|
+
* {filename}.md ← one file per skill
|
|
21
|
+
* memory/
|
|
22
|
+
* {type}_{name}.md ← materialized memory files
|
|
23
|
+
*
|
|
24
|
+
* @module runner/compile-claude-md
|
|
25
|
+
*/
|
|
26
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
27
|
+
if (k2 === undefined) k2 = k;
|
|
28
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
29
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
30
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
31
|
+
}
|
|
32
|
+
Object.defineProperty(o, k2, desc);
|
|
33
|
+
}) : (function(o, m, k, k2) {
|
|
34
|
+
if (k2 === undefined) k2 = k;
|
|
35
|
+
o[k2] = m[k];
|
|
36
|
+
}));
|
|
37
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
38
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
39
|
+
}) : function(o, v) {
|
|
40
|
+
o["default"] = v;
|
|
41
|
+
});
|
|
42
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
43
|
+
var ownKeys = function(o) {
|
|
44
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
45
|
+
var ar = [];
|
|
46
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
47
|
+
return ar;
|
|
48
|
+
};
|
|
49
|
+
return ownKeys(o);
|
|
50
|
+
};
|
|
51
|
+
return function (mod) {
|
|
52
|
+
if (mod && mod.__esModule) return mod;
|
|
53
|
+
var result = {};
|
|
54
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
55
|
+
__setModuleDefault(result, mod);
|
|
56
|
+
return result;
|
|
57
|
+
};
|
|
58
|
+
})();
|
|
59
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
+
exports.getAgentWorkDir = getAgentWorkDir;
|
|
61
|
+
exports.getClaudeMdPath = getClaudeMdPath;
|
|
62
|
+
exports.compileClaudeMd = compileClaudeMd;
|
|
63
|
+
exports.materializeMemoryFiles = materializeMemoryFiles;
|
|
64
|
+
const fs = __importStar(require("fs"));
|
|
65
|
+
const path = __importStar(require("path"));
|
|
66
|
+
const db_1 = require("./db");
|
|
67
|
+
const logger_1 = require("./logger");
|
|
68
|
+
/** Base directory for ephemeral agent workspaces. */
|
|
69
|
+
const AGENTS_TMP_DIR = process.env.AGENTS_TMP_DIR ?? '/tmp/agents';
|
|
70
|
+
/**
|
|
71
|
+
* Built-in /recall skill — injected for every agent automatically.
|
|
72
|
+
* Reads memory files from the agent's memory directory on disk.
|
|
73
|
+
*/
|
|
74
|
+
const RECALL_SKILL = `Search your memory files for context relevant to: $ARGUMENTS
|
|
75
|
+
|
|
76
|
+
Use the Read tool to read files from the \`memory/\` directory (relative to your working directory).
|
|
77
|
+
First read \`memory/MEMORY.md\` to see the index, then read specific memory files that match the topic.
|
|
78
|
+
Apply what you find — past preferences, corrections, and patterns — so you don't repeat previous mistakes or ask questions you've already had answered.
|
|
79
|
+
If no relevant memories are found, say so briefly and continue.`;
|
|
80
|
+
/**
|
|
81
|
+
* Memory system instructions injected into every agent's CLAUDE.md.
|
|
82
|
+
* Tells the agent to persist learned facts to .claude/memory/ in its cwd.
|
|
83
|
+
*/
|
|
84
|
+
/**
|
|
85
|
+
* Slack formatting rules injected into every agent's CLAUDE.md.
|
|
86
|
+
* Built-in at the framework level — not visible in the Skills tab.
|
|
87
|
+
*/
|
|
88
|
+
const SLACK_FORMATTING_SECTION = `# Slack Formatting
|
|
89
|
+
|
|
90
|
+
You are responding in Slack. Follow these rules for every message:
|
|
91
|
+
|
|
92
|
+
**Text formatting:**
|
|
93
|
+
- Bold: \`*bold*\` — NOT \`**bold**\`
|
|
94
|
+
- Italic: \`_italic_\` — NOT \`*italic*\`
|
|
95
|
+
- Section headers: \`*Header Text*\` on its own line — NOT \`#\`, \`##\`, \`###\`
|
|
96
|
+
- Inline code: \`` + '`' + `code\`` + '`' + `
|
|
97
|
+
- Code blocks: triple backticks with language hint (\`\`\`sql ... \`\`\`)
|
|
98
|
+
- Lists: \`- item\` or \`1. item\`
|
|
99
|
+
- Links: \`<url|text>\`
|
|
100
|
+
- Horizontal rules: just a blank line — NOT \`---\` or \`***\`
|
|
101
|
+
- Blockquotes: use plain text or \`_italic_\` — NOT \`>\`
|
|
102
|
+
|
|
103
|
+
**Tables — use standard Markdown pipe format:**
|
|
104
|
+
- Every row MUST start and end with \`|\`
|
|
105
|
+
- Always include a separator row: \`|---|---|---|\`
|
|
106
|
+
- Do NOT wrap tables in code blocks
|
|
107
|
+
|
|
108
|
+
Good:
|
|
109
|
+
\`\`\`
|
|
110
|
+
| Name | Count |
|
|
111
|
+
|---|---|
|
|
112
|
+
| Alpha | 42 |
|
|
113
|
+
\`\`\`
|
|
114
|
+
|
|
115
|
+
**Never use:** \`## headings\`, \`**double asterisks**\`, \`> blockquotes\`, \`---\` rules`;
|
|
116
|
+
/**
|
|
117
|
+
* Returns the temporary working directory path for an agent.
|
|
118
|
+
*
|
|
119
|
+
* @param {string} slug - Agent slug (e.g., "gilfoyle").
|
|
120
|
+
* @returns {string} Absolute path to the agent's temp workspace.
|
|
121
|
+
*/
|
|
122
|
+
function getAgentWorkDir(slug) {
|
|
123
|
+
return path.join(AGENTS_TMP_DIR, slug);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Returns the path to the CLAUDE.md file for an agent.
|
|
127
|
+
*
|
|
128
|
+
* @param {string} slug - Agent slug.
|
|
129
|
+
* @returns {string} Absolute path to CLAUDE.md.
|
|
130
|
+
*/
|
|
131
|
+
function getClaudeMdPath(slug) {
|
|
132
|
+
return path.join(getAgentWorkDir(slug), 'CLAUDE.md');
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Compiles the agent workspace: writes CLAUDE.md and skill command files.
|
|
136
|
+
*
|
|
137
|
+
* - CLAUDE.md = agent.claudeMd (identity/instructions) + memory system + memories
|
|
138
|
+
* - .claude/commands/{filename}.md = one file per skill (Claude Code slash commands)
|
|
139
|
+
*
|
|
140
|
+
* For boss agents, CLAUDE.md is auto-generated from the team registry instead of
|
|
141
|
+
* agent.claudeMd (the boss-registry.ts module sets this before calling compileClaudeMd).
|
|
142
|
+
*
|
|
143
|
+
* @param {Agent} agent - The agent to compile for.
|
|
144
|
+
* @param {string} [overrideClaudeMd] - Optional override for CLAUDE.md content (used by boss registry).
|
|
145
|
+
* @returns {Promise<string>} The path to the agent's working directory (pass as cwd to SDK).
|
|
146
|
+
* @throws {Error} If writing to the filesystem fails.
|
|
147
|
+
*/
|
|
148
|
+
async function compileClaudeMd(agent, overrideClaudeMd) {
|
|
149
|
+
const workDir = getAgentWorkDir(agent.slug);
|
|
150
|
+
const claudeMdPath = getClaudeMdPath(agent.slug);
|
|
151
|
+
fs.mkdirSync(workDir, { recursive: true });
|
|
152
|
+
const skills = await (0, db_1.getAgentSkills)(agent.id);
|
|
153
|
+
logger_1.logger.info('Compiling agent workspace', {
|
|
154
|
+
agent: agent.slug,
|
|
155
|
+
skills: skills.length,
|
|
156
|
+
});
|
|
157
|
+
// -------------------------------------------------------------------------
|
|
158
|
+
// 1. Write CLAUDE.md (identity + memory system instructions)
|
|
159
|
+
// -------------------------------------------------------------------------
|
|
160
|
+
const claudeMdContent = buildClaudeMd(agent, overrideClaudeMd);
|
|
161
|
+
fs.writeFileSync(claudeMdPath, claudeMdContent, 'utf-8');
|
|
162
|
+
logger_1.logger.debug('CLAUDE.md written', {
|
|
163
|
+
agent: agent.slug,
|
|
164
|
+
path: claudeMdPath,
|
|
165
|
+
bytes: Buffer.byteLength(claudeMdContent, 'utf-8'),
|
|
166
|
+
});
|
|
167
|
+
// -------------------------------------------------------------------------
|
|
168
|
+
// 2. Write skills as .claude/commands/{filename}.md
|
|
169
|
+
// -------------------------------------------------------------------------
|
|
170
|
+
const commandsDir = path.join(workDir, '.claude', 'commands');
|
|
171
|
+
fs.mkdirSync(commandsDir, { recursive: true });
|
|
172
|
+
// Remove old command files before rewriting (handles deleted skills)
|
|
173
|
+
for (const existing of fs.readdirSync(commandsDir)) {
|
|
174
|
+
fs.rmSync(path.join(commandsDir, existing), { force: true });
|
|
175
|
+
}
|
|
176
|
+
// Built-in recall skill — always injected, not user-visible in Skills tab
|
|
177
|
+
fs.writeFileSync(path.join(commandsDir, 'recall.md'), RECALL_SKILL, 'utf-8');
|
|
178
|
+
for (const skill of skills) {
|
|
179
|
+
const filename = skill.filename.endsWith('.md') ? skill.filename : `${skill.filename}.md`;
|
|
180
|
+
fs.writeFileSync(path.join(commandsDir, filename), skill.content, 'utf-8');
|
|
181
|
+
}
|
|
182
|
+
logger_1.logger.debug('Skill commands written', {
|
|
183
|
+
agent: agent.slug,
|
|
184
|
+
commands: skills.map(s => s.filename),
|
|
185
|
+
dir: commandsDir,
|
|
186
|
+
});
|
|
187
|
+
// -------------------------------------------------------------------------
|
|
188
|
+
// 3. Propagate updates to all existing per-session directories
|
|
189
|
+
// -------------------------------------------------------------------------
|
|
190
|
+
const sessionsDir = path.join(workDir, 'sessions');
|
|
191
|
+
if (fs.existsSync(sessionsDir)) {
|
|
192
|
+
for (const entry of fs.readdirSync(sessionsDir)) {
|
|
193
|
+
const sessionDir = path.join(sessionsDir, entry);
|
|
194
|
+
if (!fs.statSync(sessionDir).isDirectory())
|
|
195
|
+
continue;
|
|
196
|
+
// Update CLAUDE.md
|
|
197
|
+
fs.writeFileSync(path.join(sessionDir, 'CLAUDE.md'), claudeMdContent, 'utf8');
|
|
198
|
+
// Update .claude/commands/
|
|
199
|
+
const sessionCommandsDir = path.join(sessionDir, '.claude', 'commands');
|
|
200
|
+
fs.mkdirSync(sessionCommandsDir, { recursive: true });
|
|
201
|
+
for (const existing of fs.readdirSync(sessionCommandsDir)) {
|
|
202
|
+
fs.rmSync(path.join(sessionCommandsDir, existing), { force: true });
|
|
203
|
+
}
|
|
204
|
+
fs.writeFileSync(path.join(sessionCommandsDir, 'recall.md'), RECALL_SKILL, 'utf-8');
|
|
205
|
+
for (const skill of skills) {
|
|
206
|
+
const filename = skill.filename.endsWith('.md') ? skill.filename : `${skill.filename}.md`;
|
|
207
|
+
fs.writeFileSync(path.join(sessionCommandsDir, filename), skill.content, 'utf-8');
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return workDir;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Materializes memory files from the database to the agent's temp workspace.
|
|
215
|
+
* These files are read by the /recall skill when the agent needs past context.
|
|
216
|
+
*/
|
|
217
|
+
function materializeMemoryFiles(agent, memories) {
|
|
218
|
+
const memoryDir = path.join(getAgentWorkDir(agent.slug), 'memory');
|
|
219
|
+
fs.mkdirSync(memoryDir, { recursive: true });
|
|
220
|
+
const index = ['# Memory Index', ''];
|
|
221
|
+
for (const memory of memories) {
|
|
222
|
+
const filename = `${memory.type}_${sanitizeFilename(memory.name)}.md`;
|
|
223
|
+
fs.writeFileSync(path.join(memoryDir, filename), memory.content, 'utf-8');
|
|
224
|
+
index.push(`- [${memory.name}](${filename}) — ${memory.type}`);
|
|
225
|
+
}
|
|
226
|
+
fs.writeFileSync(path.join(memoryDir, 'MEMORY.md'), index.join('\n'), 'utf-8');
|
|
227
|
+
logger_1.logger.debug('Memory files materialized', { agent: agent.slug, count: memories.length });
|
|
228
|
+
}
|
|
229
|
+
// =============================================================================
|
|
230
|
+
// Private helpers
|
|
231
|
+
// =============================================================================
|
|
232
|
+
/**
|
|
233
|
+
* Builds the CLAUDE.md content for an agent.
|
|
234
|
+
* Structure: identity → Slack formatting rules → memory system instructions.
|
|
235
|
+
*
|
|
236
|
+
* @param {Agent} agent - The agent.
|
|
237
|
+
* @param {string} [overrideClaudeMd] - Override for identity content (boss registry use).
|
|
238
|
+
* @returns {string} Full CLAUDE.md content.
|
|
239
|
+
*/
|
|
240
|
+
function buildClaudeMd(agent, overrideClaudeMd) {
|
|
241
|
+
const sections = [];
|
|
242
|
+
// Identity / instructions
|
|
243
|
+
const identity = overrideClaudeMd ?? agent.claudeMd;
|
|
244
|
+
if (identity.trim()) {
|
|
245
|
+
sections.push(identity.trim());
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
const lines = [`# ${agent.name}`];
|
|
249
|
+
if (agent.persona)
|
|
250
|
+
lines.push('', agent.persona);
|
|
251
|
+
if (agent.description)
|
|
252
|
+
lines.push('', agent.description);
|
|
253
|
+
sections.push(lines.join('\n'));
|
|
254
|
+
}
|
|
255
|
+
// Slack formatting rules (framework-level, not a skill)
|
|
256
|
+
sections.push(SLACK_FORMATTING_SECTION);
|
|
257
|
+
// Memory instructions — internal, not shown in UI
|
|
258
|
+
sections.push(`# Memory
|
|
259
|
+
|
|
260
|
+
Use /recall <topic> proactively — at the start of each conversation and whenever the topic shifts. Don't wait to be asked. Past memories contain user preferences, corrections, and learned patterns that let you pick up where you left off instead of starting from scratch.
|
|
261
|
+
|
|
262
|
+
**When to save a memory** — use the Write tool to create \`memory/{type}_{name}.md\` (IMPORTANT: you MUST actually call the Write tool — do not just say you saved it). Include this frontmatter at the top, followed by the memory content:
|
|
263
|
+
\`\`\`
|
|
264
|
+
---
|
|
265
|
+
name: {name}
|
|
266
|
+
type: {type}
|
|
267
|
+
description: {one line summary}
|
|
268
|
+
---
|
|
269
|
+
{memory content}
|
|
270
|
+
\`\`\`
|
|
271
|
+
Valid types: user|feedback|project|reference. Save when:
|
|
272
|
+
- User explicitly corrects or guides you ("don't do X", "always do Y")
|
|
273
|
+
- You notice a recurring pattern: same question asked repeatedly, same mistake made, same preference shown — save it so you don't start from scratch next time
|
|
274
|
+
- You learn something concrete about the user's role, goals, or working style
|
|
275
|
+
- A project decision or constraint is established that will affect future work
|
|
276
|
+
|
|
277
|
+
**When NOT to save** — one-off tasks, ephemeral state, things already in the code or git history.
|
|
278
|
+
|
|
279
|
+
Keep memories concise and actionable. Bad memory: "user asked about SQL". Good memory: "user prefers CTEs over subqueries — confirmed multiple times".`);
|
|
280
|
+
return sections.join('\n\n---\n\n');
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Sanitizes a string for use as a filename.
|
|
284
|
+
*
|
|
285
|
+
* @param {string} name - Raw name string.
|
|
286
|
+
* @returns {string} Filesystem-safe filename fragment.
|
|
287
|
+
*/
|
|
288
|
+
function sanitizeFilename(name) {
|
|
289
|
+
return name.toLowerCase().replace(/[^a-z0-9_-]/g, '_').slice(0, 64);
|
|
290
|
+
}
|
|
291
|
+
//# sourceMappingURL=compile-claude-md.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-claude-md.js","sourceRoot":"","sources":["../src/compile-claude-md.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEH,0CAEC;AAQD,0CAEC;AAgBD,0CA6EC;AAOD,wDAaC;AA7LD,uCAAyB;AACzB,2CAA6B;AAE7B,6BAAsC;AACtC,qCAAkC;AAElC,qDAAqD;AACrD,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,aAAa,CAAC;AAEnE;;;GAGG;AACH,MAAM,YAAY,GAAG;;;;;gEAK2C,CAAC;AAEjE;;;GAGG;AACH;;;GAGG;AACH,MAAM,wBAAwB,GAAG;;;;;;;;kBAQf,GAAG,GAAG,GAAG,QAAQ,GAAG,GAAG,GAAG;;;;;;;;;;;;;;;;;;;2FAmB+C,CAAC;AAG5F;;;;;GAKG;AACH,SAAgB,eAAe,CAAC,IAAY;IAC1C,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,eAAe,CAAC,IAAY;IAC1C,OAAO,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;;;;;;;;GAaG;AACI,KAAK,UAAU,eAAe,CAAC,KAAY,EAAE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K,CAAC,IAAI,EAAE,CAAC,CAAC;QAClC,IAAI,KAAK,CAAC,OAAO;YAAE,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QACjD,IAAI,KAAK,CAAC,WAAW;YAAE,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;QACzD,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAClC,CAAC;IAED,wDAAwD;IACxD,QAAQ,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IAExC,kDAAkD;IAClD,QAAQ,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;uJAqBuI,CAAC,CAAC;IAEvJ,OAAO,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;AACtC,CAAC;AAED;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,IAAY;IACpC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Generic Slack command handler for agent corrections.
|
|
3
|
+
*
|
|
4
|
+
* Commands use the agent's slug as prefix so any agent can have corrections:
|
|
5
|
+
* @GILFOYLE gilfoyle:correct "always use UTC"
|
|
6
|
+
* @GILFOYLE gilfoyle:corrections
|
|
7
|
+
* @GILFOYLE gilfoyle:corrections remove 3
|
|
8
|
+
* @GILFOYLE gilfoyle:help
|
|
9
|
+
*
|
|
10
|
+
* Commands are intercepted before normal message processing in slack-handler.ts.
|
|
11
|
+
*
|
|
12
|
+
* Adapted from nlq-claude-slack-bot/src/correction-handler.ts.
|
|
13
|
+
* Key changes: NLQ-specific -> generic per-agent, slug-prefixed commands.
|
|
14
|
+
*
|
|
15
|
+
* @module runner/correction-handler
|
|
16
|
+
*/
|
|
17
|
+
import type { Agent } from '@slackhive/shared';
|
|
18
|
+
interface SlackContext {
|
|
19
|
+
userId: string;
|
|
20
|
+
channelId: string;
|
|
21
|
+
threadTs?: string;
|
|
22
|
+
messageTs: string;
|
|
23
|
+
}
|
|
24
|
+
export declare class CorrectionHandler {
|
|
25
|
+
private correctionManager;
|
|
26
|
+
private agent;
|
|
27
|
+
private prefix;
|
|
28
|
+
private reviewerAllowlist;
|
|
29
|
+
private log;
|
|
30
|
+
constructor(agent: Agent);
|
|
31
|
+
/**
|
|
32
|
+
* Returns true if the given text is a command for this agent.
|
|
33
|
+
* Checks for `{slug}:correct`, `{slug}:corrections`, or `{slug}:help`.
|
|
34
|
+
*/
|
|
35
|
+
isCommand(text: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Routes a command to the appropriate handler.
|
|
38
|
+
*/
|
|
39
|
+
handle(ctx: SlackContext, text: string, client: any): Promise<void>;
|
|
40
|
+
private isAuthorized;
|
|
41
|
+
private fetchThreadContext;
|
|
42
|
+
private handleAdd;
|
|
43
|
+
private handleShow;
|
|
44
|
+
private handleRemove;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Generic Slack command handler for agent corrections.
|
|
4
|
+
*
|
|
5
|
+
* Commands use the agent's slug as prefix so any agent can have corrections:
|
|
6
|
+
* @GILFOYLE gilfoyle:correct "always use UTC"
|
|
7
|
+
* @GILFOYLE gilfoyle:corrections
|
|
8
|
+
* @GILFOYLE gilfoyle:corrections remove 3
|
|
9
|
+
* @GILFOYLE gilfoyle:help
|
|
10
|
+
*
|
|
11
|
+
* Commands are intercepted before normal message processing in slack-handler.ts.
|
|
12
|
+
*
|
|
13
|
+
* Adapted from nlq-claude-slack-bot/src/correction-handler.ts.
|
|
14
|
+
* Key changes: NLQ-specific -> generic per-agent, slug-prefixed commands.
|
|
15
|
+
*
|
|
16
|
+
* @module runner/correction-handler
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.CorrectionHandler = void 0;
|
|
20
|
+
const correction_manager_1 = require("./correction-manager");
|
|
21
|
+
const logger_1 = require("./logger");
|
|
22
|
+
const MAX_CORRECTIONS = 30;
|
|
23
|
+
class CorrectionHandler {
|
|
24
|
+
correctionManager;
|
|
25
|
+
agent;
|
|
26
|
+
prefix;
|
|
27
|
+
reviewerAllowlist;
|
|
28
|
+
log;
|
|
29
|
+
constructor(agent) {
|
|
30
|
+
this.agent = agent;
|
|
31
|
+
this.prefix = `${agent.slug}:`;
|
|
32
|
+
this.correctionManager = new correction_manager_1.CorrectionManager(agent);
|
|
33
|
+
this.reviewerAllowlist = (process.env.CORRECTION_REVIEWERS || '').split(',').filter(Boolean);
|
|
34
|
+
this.log = (0, logger_1.agentLogger)(agent.slug);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns true if the given text is a command for this agent.
|
|
38
|
+
* Checks for `{slug}:correct`, `{slug}:corrections`, or `{slug}:help`.
|
|
39
|
+
*/
|
|
40
|
+
isCommand(text) {
|
|
41
|
+
return text.startsWith(`${this.prefix}correct`) || text.startsWith(`${this.prefix}help`);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Routes a command to the appropriate handler.
|
|
45
|
+
*/
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
async handle(ctx, text, client) {
|
|
48
|
+
const threadTs = ctx.threadTs ?? ctx.messageTs;
|
|
49
|
+
const slug = this.agent.slug;
|
|
50
|
+
const postReply = async (msg) => {
|
|
51
|
+
await client.chat.postMessage({
|
|
52
|
+
channel: ctx.channelId,
|
|
53
|
+
thread_ts: threadTs,
|
|
54
|
+
text: msg,
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
// {slug}:help
|
|
58
|
+
if (text === `${this.prefix}help`) {
|
|
59
|
+
await postReply(`*${this.agent.name} Commands*\n\n` +
|
|
60
|
+
`\u2022 \`${slug}:correct <text>\` \u2014 Add a correction rule\n` +
|
|
61
|
+
`\u2022 \`${slug}:corrections\` \u2014 View all stored corrections\n` +
|
|
62
|
+
`\u2022 \`${slug}:corrections remove <N>\` \u2014 Remove correction #N\n` +
|
|
63
|
+
`\u2022 \`${slug}:help\` \u2014 Show this help message`);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
// {slug}:corrections (show all)
|
|
67
|
+
if (text === `${this.prefix}corrections` || text === `${this.prefix}correction`) {
|
|
68
|
+
return this.handleShow(postReply);
|
|
69
|
+
}
|
|
70
|
+
// {slug}:corrections remove N
|
|
71
|
+
const removePrefix = `${this.prefix}corrections remove `;
|
|
72
|
+
if (text.startsWith(removePrefix)) {
|
|
73
|
+
const numStr = text.slice(removePrefix.length).trim();
|
|
74
|
+
const num = parseInt(numStr, 10);
|
|
75
|
+
if (isNaN(num) || num < 1) {
|
|
76
|
+
await postReply(`Usage: \`${slug}:corrections remove <number>\``);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
return this.handleRemove(ctx, num, postReply);
|
|
80
|
+
}
|
|
81
|
+
// {slug}:correct <text>
|
|
82
|
+
const correctPrefix = `${this.prefix}correct `;
|
|
83
|
+
if (text.startsWith(correctPrefix)) {
|
|
84
|
+
const correctionText = text.slice(correctPrefix.length).trim();
|
|
85
|
+
if (!correctionText) {
|
|
86
|
+
await postReply(`Usage: \`${slug}:correct <correction text>\``);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
return this.handleAdd(ctx, correctionText, client, postReply);
|
|
90
|
+
}
|
|
91
|
+
// Unrecognized {slug}: command
|
|
92
|
+
await postReply(`Available commands:\n` +
|
|
93
|
+
`\u2022 \`${slug}:correct <text>\` \u2014 Add a correction\n` +
|
|
94
|
+
`\u2022 \`${slug}:corrections\` \u2014 Show current corrections\n` +
|
|
95
|
+
`\u2022 \`${slug}:corrections remove <N>\` \u2014 Remove correction #N`);
|
|
96
|
+
}
|
|
97
|
+
isAuthorized(userId) {
|
|
98
|
+
if (this.reviewerAllowlist.length === 0)
|
|
99
|
+
return true;
|
|
100
|
+
return this.reviewerAllowlist.includes(userId);
|
|
101
|
+
}
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
103
|
+
async fetchThreadContext(client, channelId, threadTs) {
|
|
104
|
+
try {
|
|
105
|
+
const result = await client.conversations.replies({
|
|
106
|
+
channel: channelId,
|
|
107
|
+
ts: threadTs,
|
|
108
|
+
limit: 20,
|
|
109
|
+
});
|
|
110
|
+
const messages = result.messages ?? [];
|
|
111
|
+
if (messages.length < 2)
|
|
112
|
+
return undefined;
|
|
113
|
+
const userQuestion = (messages[0].text || '').substring(0, 500);
|
|
114
|
+
const botReplyText = messages[1].text || '';
|
|
115
|
+
const sqlMatch = botReplyText.match(/```sql[\s\S]*?```/);
|
|
116
|
+
const botExcerpt = sqlMatch
|
|
117
|
+
? sqlMatch[0].substring(0, 800)
|
|
118
|
+
: botReplyText.substring(0, 500);
|
|
119
|
+
return `User question: "${userQuestion}"\nBot answer (excerpt): ${botExcerpt}`;
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
this.log.error('Failed to fetch thread context', { error });
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
127
|
+
async handleAdd(ctx, correctionText, client, postReply) {
|
|
128
|
+
if (!this.isAuthorized(ctx.userId)) {
|
|
129
|
+
await postReply("You don't have permission to submit corrections.");
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
this.log.info('Processing correction', { user: ctx.userId, text: correctionText.substring(0, 100) });
|
|
133
|
+
await postReply('_Processing correction..._');
|
|
134
|
+
let threadContext;
|
|
135
|
+
if (ctx.threadTs) {
|
|
136
|
+
threadContext = await this.fetchThreadContext(client, ctx.channelId, ctx.threadTs);
|
|
137
|
+
}
|
|
138
|
+
const result = await this.correctionManager.addCorrection(correctionText, ctx.userId, threadContext);
|
|
139
|
+
const emoji = result.success ? ':white_check_mark:' : ':warning:';
|
|
140
|
+
await postReply(`${emoji} ${result.message}`);
|
|
141
|
+
}
|
|
142
|
+
async handleShow(postReply) {
|
|
143
|
+
const raw = await this.correctionManager.getRaw();
|
|
144
|
+
if (!raw) {
|
|
145
|
+
await postReply('No corrections on file.');
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const count = await this.correctionManager.getCount();
|
|
149
|
+
await postReply(`*Current Corrections* (${count}/${MAX_CORRECTIONS}):\n\n${raw}`);
|
|
150
|
+
}
|
|
151
|
+
async handleRemove(ctx, index, postReply) {
|
|
152
|
+
if (!this.isAuthorized(ctx.userId)) {
|
|
153
|
+
await postReply("You don't have permission to modify corrections.");
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const result = await this.correctionManager.removeCorrection(index);
|
|
157
|
+
const emoji = result.success ? ':white_check_mark:' : ':warning:';
|
|
158
|
+
await postReply(`${emoji} ${result.message}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
exports.CorrectionHandler = CorrectionHandler;
|
|
162
|
+
//# sourceMappingURL=correction-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"correction-handler.js","sourceRoot":"","sources":["../src/correction-handler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAGH,6DAAyD;AACzD,qCAAuC;AAEvC,MAAM,eAAe,GAAG,EAAE,CAAC;AAS3B,MAAa,iBAAiB;IACpB,iBAAiB,CAAoB;IACrC,KAAK,CAAQ;IACb,MAAM,CAAS;IACf,iBAAiB,CAAW;IAC5B,GAAG,CAAC;IAEZ,YAAY,KAAY;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,GAAG,K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G,MAAM,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,CAAC;QAElD,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,SAAS,CAAC,yBAAyB,CAAC,CAAC;YAC3C,OAAO;QACT,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,CAAC;QACtD,MAAM,SAAS,CAAC,0BAA0B,KAAK,IAAI,eAAe,SAAS,GAAG,EAAE,CAAC,CAAC;IACpF,CAAC;IAEO,KAAK,CAAC,YAAY,CAAC,GAAiB,EAAE,KAAa,EAAE,SAAyC;QACpG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YACnC,MAAM,SAAS,CAAC,kDAAkD,CAAC,CAAC;YACpE,OAAO;QACT,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;QACpE,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,WAAW,CAAC;QAClE,MAAM,SAAS,CAAC,GAAG,KAAK,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAChD,CAAC;CACF;AAhKD,8CAgKC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Generic correction manager for any SlackHive agent.
|
|
3
|
+
*
|
|
4
|
+
* Corrections are stored as a skill in the database (category: '99-corrections',
|
|
5
|
+
* filename: 'corrections.md') so they:
|
|
6
|
+
* - Persist across container restarts (Postgres)
|
|
7
|
+
* - Are visible/editable in the SlackHive web UI Skills tab
|
|
8
|
+
* - Are automatically compiled into the agent's CLAUDE.md
|
|
9
|
+
*
|
|
10
|
+
* Uses Claude to intelligently consolidate new corrections (dedup, categorize).
|
|
11
|
+
*
|
|
12
|
+
* Adapted from nlq-claude-slack-bot/src/correction-manager.ts.
|
|
13
|
+
* Key changes: flat file -> Postgres skill, NLQ-specific -> generic agent.
|
|
14
|
+
*
|
|
15
|
+
* @module runner/correction-manager
|
|
16
|
+
*/
|
|
17
|
+
import type { Agent } from '@slackhive/shared';
|
|
18
|
+
export interface AddResult {
|
|
19
|
+
success: boolean;
|
|
20
|
+
message: string;
|
|
21
|
+
count: number;
|
|
22
|
+
}
|
|
23
|
+
export declare class CorrectionManager {
|
|
24
|
+
private agent;
|
|
25
|
+
private log;
|
|
26
|
+
private writeChain;
|
|
27
|
+
constructor(agent: Agent);
|
|
28
|
+
/**
|
|
29
|
+
* Reads the current corrections content from the database.
|
|
30
|
+
*/
|
|
31
|
+
readCorrections(): Promise<string>;
|
|
32
|
+
/**
|
|
33
|
+
* Counts the number of corrections (lines starting with digits followed by a dot).
|
|
34
|
+
*/
|
|
35
|
+
getCount(): Promise<number>;
|
|
36
|
+
/**
|
|
37
|
+
* Adds a new correction, using Claude to consolidate and deduplicate.
|
|
38
|
+
* Serializes writes to prevent race conditions.
|
|
39
|
+
*/
|
|
40
|
+
addCorrection(text: string, reviewerId: string, threadContext?: string): Promise<AddResult>;
|
|
41
|
+
private _addCorrection;
|
|
42
|
+
/**
|
|
43
|
+
* Removes a correction by its number and renumbers the rest.
|
|
44
|
+
*/
|
|
45
|
+
removeCorrection(index: number): Promise<{
|
|
46
|
+
success: boolean;
|
|
47
|
+
message: string;
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the raw corrections content.
|
|
51
|
+
*/
|
|
52
|
+
getRaw(): Promise<string>;
|
|
53
|
+
}
|