@useatlas/create 0.0.1
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/README.md +231 -0
- package/index.ts +829 -0
- package/package.json +38 -0
- package/templates/docker/.env.example +67 -0
- package/templates/docker/Dockerfile +52 -0
- package/templates/docker/bin/__tests__/benchmark.test.ts +598 -0
- package/templates/docker/bin/__tests__/duckdb-ingest.test.ts +171 -0
- package/templates/docker/bin/__tests__/eval.test.ts +434 -0
- package/templates/docker/bin/__tests__/matview-partition.test.ts +615 -0
- package/templates/docker/bin/__tests__/multi-source.test.ts +113 -0
- package/templates/docker/bin/__tests__/plugin-cli.test.ts +322 -0
- package/templates/docker/bin/__tests__/profiler-heuristics.test.ts +608 -0
- package/templates/docker/bin/__tests__/query.test.ts +240 -0
- package/templates/docker/bin/__tests__/schema-drift.test.ts +542 -0
- package/templates/docker/bin/__tests__/view-yaml-generation.test.ts +146 -0
- package/templates/docker/bin/atlas.ts +5044 -0
- package/templates/docker/bin/benchmark.ts +695 -0
- package/templates/docker/bin/enrich.ts +559 -0
- package/templates/docker/bin/eval.ts +770 -0
- package/templates/docker/bin/smoke.ts +438 -0
- package/templates/docker/data/.gitkeep +0 -0
- package/templates/docker/data/cybersec.sql +1961 -0
- package/templates/docker/data/demo-semantic/catalog.yml +40 -0
- package/templates/docker/data/demo-semantic/entities/accounts.yml +170 -0
- package/templates/docker/data/demo-semantic/entities/companies.yml +207 -0
- package/templates/docker/data/demo-semantic/entities/people.yml +145 -0
- package/templates/docker/data/demo-semantic/glossary.yml +22 -0
- package/templates/docker/data/demo-semantic/metrics/accounts.yml +38 -0
- package/templates/docker/data/demo-semantic/metrics/companies.yml +89 -0
- package/templates/docker/data/demo.sql +373 -0
- package/templates/docker/data/ecommerce.sql +1690 -0
- package/templates/docker/data/init-demo-db.sql +8 -0
- package/templates/docker/docker-compose.yml +34 -0
- package/templates/docker/docs/deploy.md +390 -0
- package/templates/docker/eslint.config.mjs +18 -0
- package/templates/docker/gitignore +5 -0
- package/templates/docker/next.config.ts +9 -0
- package/templates/docker/package.json +59 -0
- package/templates/docker/postcss.config.mjs +8 -0
- package/templates/docker/public/.gitkeep +0 -0
- package/templates/docker/public/favicon.svg +4 -0
- package/templates/docker/railway.json +13 -0
- package/templates/docker/render.yaml +34 -0
- package/templates/docker/semantic/catalog.yml +5 -0
- package/templates/docker/semantic/entities/.gitkeep +0 -0
- package/templates/docker/semantic/glossary.yml +6 -0
- package/templates/docker/semantic/metrics/.gitkeep +0 -0
- package/templates/docker/sidecar/Dockerfile +28 -0
- package/templates/docker/sidecar/railway.json +14 -0
- package/templates/docker/sidecar/server.ts +188 -0
- package/templates/docker/src/api/__tests__/actions.test.ts +683 -0
- package/templates/docker/src/api/__tests__/admin.test.ts +820 -0
- package/templates/docker/src/api/__tests__/auth.test.ts +165 -0
- package/templates/docker/src/api/__tests__/chat.test.ts +376 -0
- package/templates/docker/src/api/__tests__/conversations.test.ts +555 -0
- package/templates/docker/src/api/__tests__/cors.test.ts +135 -0
- package/templates/docker/src/api/__tests__/health-plugin.test.ts +169 -0
- package/templates/docker/src/api/__tests__/health.test.ts +261 -0
- package/templates/docker/src/api/__tests__/query.test.ts +891 -0
- package/templates/docker/src/api/__tests__/scheduled-tasks.test.ts +601 -0
- package/templates/docker/src/api/__tests__/slack.test.ts +847 -0
- package/templates/docker/src/api/index.ts +117 -0
- package/templates/docker/src/api/routes/actions.ts +274 -0
- package/templates/docker/src/api/routes/admin.ts +757 -0
- package/templates/docker/src/api/routes/auth.ts +48 -0
- package/templates/docker/src/api/routes/chat.ts +465 -0
- package/templates/docker/src/api/routes/conversations.ts +266 -0
- package/templates/docker/src/api/routes/health.ts +287 -0
- package/templates/docker/src/api/routes/openapi.ts +390 -0
- package/templates/docker/src/api/routes/query.ts +318 -0
- package/templates/docker/src/api/routes/scheduled-tasks.ts +467 -0
- package/templates/docker/src/api/routes/slack.ts +611 -0
- package/templates/docker/src/api/server.ts +226 -0
- package/templates/docker/src/app/api/[...route]/route.ts +33 -0
- package/templates/docker/src/app/error.tsx +24 -0
- package/templates/docker/src/app/globals.css +126 -0
- package/templates/docker/src/app/layout.tsx +19 -0
- package/templates/docker/src/app/page.tsx +14 -0
- package/templates/docker/src/global.d.ts +1 -0
- package/templates/docker/src/lib/__tests__/agent-cache.test.ts +437 -0
- package/templates/docker/src/lib/__tests__/agent-dialect.test.ts +114 -0
- package/templates/docker/src/lib/__tests__/agent-health-annotations.test.ts +164 -0
- package/templates/docker/src/lib/__tests__/agent-integration.test.ts +514 -0
- package/templates/docker/src/lib/__tests__/config-actions.test.ts +166 -0
- package/templates/docker/src/lib/__tests__/config.test.ts +1063 -0
- package/templates/docker/src/lib/__tests__/conversations.test.ts +589 -0
- package/templates/docker/src/lib/__tests__/errors.test.ts +256 -0
- package/templates/docker/src/lib/__tests__/logger.test.ts +200 -0
- package/templates/docker/src/lib/__tests__/providers.test.ts +99 -0
- package/templates/docker/src/lib/__tests__/rls.test.ts +435 -0
- package/templates/docker/src/lib/__tests__/scheduled-task-types.test.ts +124 -0
- package/templates/docker/src/lib/__tests__/scheduled-tasks.test.ts +550 -0
- package/templates/docker/src/lib/__tests__/semantic-index.test.ts +547 -0
- package/templates/docker/src/lib/__tests__/semantic-multisource.test.ts +544 -0
- package/templates/docker/src/lib/__tests__/semantic.test.ts +363 -0
- package/templates/docker/src/lib/__tests__/startup-actions.test.ts +452 -0
- package/templates/docker/src/lib/__tests__/startup.test.ts +465 -0
- package/templates/docker/src/lib/__tests__/tracing.test.ts +28 -0
- package/templates/docker/src/lib/action-types.ts +95 -0
- package/templates/docker/src/lib/agent-query.ts +178 -0
- package/templates/docker/src/lib/agent.ts +505 -0
- package/templates/docker/src/lib/api-url.ts +2 -0
- package/templates/docker/src/lib/auth/__tests__/audit.test.ts +418 -0
- package/templates/docker/src/lib/auth/__tests__/byot-integration.test.ts +222 -0
- package/templates/docker/src/lib/auth/__tests__/byot.test.ts +366 -0
- package/templates/docker/src/lib/auth/__tests__/detect.test.ts +190 -0
- package/templates/docker/src/lib/auth/__tests__/managed.test.ts +173 -0
- package/templates/docker/src/lib/auth/__tests__/middleware.test.ts +456 -0
- package/templates/docker/src/lib/auth/__tests__/migrate.test.ts +201 -0
- package/templates/docker/src/lib/auth/__tests__/permissions.test.ts +225 -0
- package/templates/docker/src/lib/auth/__tests__/server.test.ts +34 -0
- package/templates/docker/src/lib/auth/__tests__/simple-key.test.ts +176 -0
- package/templates/docker/src/lib/auth/__tests__/types.test.ts +44 -0
- package/templates/docker/src/lib/auth/audit.ts +89 -0
- package/templates/docker/src/lib/auth/byot.ts +158 -0
- package/templates/docker/src/lib/auth/client.ts +35 -0
- package/templates/docker/src/lib/auth/detect.ts +83 -0
- package/templates/docker/src/lib/auth/managed.ts +73 -0
- package/templates/docker/src/lib/auth/middleware.ts +208 -0
- package/templates/docker/src/lib/auth/migrate.ts +111 -0
- package/templates/docker/src/lib/auth/permissions.ts +156 -0
- package/templates/docker/src/lib/auth/server.ts +142 -0
- package/templates/docker/src/lib/auth/simple-key.ts +92 -0
- package/templates/docker/src/lib/auth/types.ts +49 -0
- package/templates/docker/src/lib/config.ts +704 -0
- package/templates/docker/src/lib/conversation-types.ts +29 -0
- package/templates/docker/src/lib/conversations.ts +270 -0
- package/templates/docker/src/lib/db/__tests__/connection.test.ts +69 -0
- package/templates/docker/src/lib/db/__tests__/duckdb.test.ts +141 -0
- package/templates/docker/src/lib/db/__tests__/internal.test.ts +387 -0
- package/templates/docker/src/lib/db/__tests__/registry-health.test.ts +207 -0
- package/templates/docker/src/lib/db/__tests__/registry-pool-limits.test.ts +156 -0
- package/templates/docker/src/lib/db/__tests__/registry.test.ts +595 -0
- package/templates/docker/src/lib/db/__tests__/salesforce.test.ts +339 -0
- package/templates/docker/src/lib/db/__tests__/snowflake.test.ts +217 -0
- package/templates/docker/src/lib/db/__tests__/source-rate-limit.test.ts +130 -0
- package/templates/docker/src/lib/db/connection.ts +753 -0
- package/templates/docker/src/lib/db/duckdb.ts +122 -0
- package/templates/docker/src/lib/db/internal.ts +273 -0
- package/templates/docker/src/lib/db/salesforce.ts +342 -0
- package/templates/docker/src/lib/db/source-rate-limit.ts +191 -0
- package/templates/docker/src/lib/errors.ts +154 -0
- package/templates/docker/src/lib/logger.ts +98 -0
- package/templates/docker/src/lib/plugins/__tests__/hooks-integration.test.ts +202 -0
- package/templates/docker/src/lib/plugins/__tests__/hooks.test.ts +529 -0
- package/templates/docker/src/lib/plugins/__tests__/migrate.test.ts +521 -0
- package/templates/docker/src/lib/plugins/__tests__/registry.test.ts +346 -0
- package/templates/docker/src/lib/plugins/__tests__/tools.test.ts +49 -0
- package/templates/docker/src/lib/plugins/__tests__/wiring.test.ts +585 -0
- package/templates/docker/src/lib/plugins/hooks.ts +162 -0
- package/templates/docker/src/lib/plugins/index.ts +9 -0
- package/templates/docker/src/lib/plugins/migrate.ts +309 -0
- package/templates/docker/src/lib/plugins/registry.ts +231 -0
- package/templates/docker/src/lib/plugins/tools.ts +39 -0
- package/templates/docker/src/lib/plugins/wiring.ts +291 -0
- package/templates/docker/src/lib/providers.ts +102 -0
- package/templates/docker/src/lib/rls.ts +321 -0
- package/templates/docker/src/lib/scheduled-task-types.ts +132 -0
- package/templates/docker/src/lib/scheduled-tasks.ts +475 -0
- package/templates/docker/src/lib/scheduler/__tests__/delivery.test.ts +192 -0
- package/templates/docker/src/lib/scheduler/__tests__/engine.test.ts +248 -0
- package/templates/docker/src/lib/scheduler/__tests__/format-email.test.ts +96 -0
- package/templates/docker/src/lib/scheduler/__tests__/format-slack.test.ts +78 -0
- package/templates/docker/src/lib/scheduler/__tests__/format-webhook.test.ts +78 -0
- package/templates/docker/src/lib/scheduler/delivery.ts +248 -0
- package/templates/docker/src/lib/scheduler/engine.ts +317 -0
- package/templates/docker/src/lib/scheduler/executor.ts +73 -0
- package/templates/docker/src/lib/scheduler/format-email.ts +109 -0
- package/templates/docker/src/lib/scheduler/format-slack.ts +35 -0
- package/templates/docker/src/lib/scheduler/format-webhook.ts +37 -0
- package/templates/docker/src/lib/scheduler/index.ts +7 -0
- package/templates/docker/src/lib/security.ts +11 -0
- package/templates/docker/src/lib/semantic-index.ts +503 -0
- package/templates/docker/src/lib/semantic.ts +387 -0
- package/templates/docker/src/lib/sidecar-types.ts +16 -0
- package/templates/docker/src/lib/slack/__tests__/api.test.ts +160 -0
- package/templates/docker/src/lib/slack/__tests__/format.test.ts +237 -0
- package/templates/docker/src/lib/slack/__tests__/store.test.ts +188 -0
- package/templates/docker/src/lib/slack/__tests__/threads.test.ts +112 -0
- package/templates/docker/src/lib/slack/__tests__/verify.test.ts +111 -0
- package/templates/docker/src/lib/slack/api.ts +102 -0
- package/templates/docker/src/lib/slack/format.ts +209 -0
- package/templates/docker/src/lib/slack/store.ts +107 -0
- package/templates/docker/src/lib/slack/threads.ts +64 -0
- package/templates/docker/src/lib/slack/verify.ts +71 -0
- package/templates/docker/src/lib/startup.ts +730 -0
- package/templates/docker/src/lib/tools/__tests__/action-permissions.test.ts +594 -0
- package/templates/docker/src/lib/tools/__tests__/custom-validation.test.ts +238 -0
- package/templates/docker/src/lib/tools/__tests__/explore-backend.test.ts +267 -0
- package/templates/docker/src/lib/tools/__tests__/explore-nsjail.test.ts +492 -0
- package/templates/docker/src/lib/tools/__tests__/explore-plugin.test.ts +374 -0
- package/templates/docker/src/lib/tools/__tests__/explore-sdk-compat.test.ts +82 -0
- package/templates/docker/src/lib/tools/__tests__/explore-sidecar.test.ts +208 -0
- package/templates/docker/src/lib/tools/__tests__/registry-actions.test.ts +144 -0
- package/templates/docker/src/lib/tools/__tests__/registry.test.ts +235 -0
- package/templates/docker/src/lib/tools/__tests__/salesforce-tool.test.ts +154 -0
- package/templates/docker/src/lib/tools/__tests__/soql-validation.test.ts +303 -0
- package/templates/docker/src/lib/tools/__tests__/sql-audit.test.ts +225 -0
- package/templates/docker/src/lib/tools/__tests__/sql-connection-whitelist.test.ts +98 -0
- package/templates/docker/src/lib/tools/__tests__/sql-duckdb.test.ts +233 -0
- package/templates/docker/src/lib/tools/__tests__/sql-ratelimit.test.ts +225 -0
- package/templates/docker/src/lib/tools/__tests__/sql.test.ts +1012 -0
- package/templates/docker/src/lib/tools/actions/__tests__/audit.test.ts +211 -0
- package/templates/docker/src/lib/tools/actions/__tests__/email.test.ts +378 -0
- package/templates/docker/src/lib/tools/actions/__tests__/handler.test.ts +681 -0
- package/templates/docker/src/lib/tools/actions/__tests__/jira.test.ts +427 -0
- package/templates/docker/src/lib/tools/actions/audit.ts +47 -0
- package/templates/docker/src/lib/tools/actions/email.ts +191 -0
- package/templates/docker/src/lib/tools/actions/handler.ts +591 -0
- package/templates/docker/src/lib/tools/actions/index.ts +23 -0
- package/templates/docker/src/lib/tools/actions/jira.ts +220 -0
- package/templates/docker/src/lib/tools/explore-nsjail.ts +343 -0
- package/templates/docker/src/lib/tools/explore-sandbox.ts +264 -0
- package/templates/docker/src/lib/tools/explore-sidecar.ts +163 -0
- package/templates/docker/src/lib/tools/explore.ts +379 -0
- package/templates/docker/src/lib/tools/registry.ts +221 -0
- package/templates/docker/src/lib/tools/salesforce.ts +138 -0
- package/templates/docker/src/lib/tools/soql-validation.ts +172 -0
- package/templates/docker/src/lib/tools/sql.ts +680 -0
- package/templates/docker/src/lib/tracing.ts +40 -0
- package/templates/docker/src/lib/utils.ts +6 -0
- package/templates/docker/src/test-setup.ts +38 -0
- package/templates/docker/src/types/vercel-sandbox.d.ts +54 -0
- package/templates/docker/src/ui/components/actions/action-approval-card.tsx +295 -0
- package/templates/docker/src/ui/components/actions/action-status-badge.tsx +50 -0
- package/templates/docker/src/ui/components/admin/admin-layout.tsx +26 -0
- package/templates/docker/src/ui/components/admin/admin-sidebar.tsx +96 -0
- package/templates/docker/src/ui/components/admin/empty-state.tsx +24 -0
- package/templates/docker/src/ui/components/admin/entity-detail.tsx +233 -0
- package/templates/docker/src/ui/components/admin/entity-list.tsx +96 -0
- package/templates/docker/src/ui/components/admin/error-banner.tsx +22 -0
- package/templates/docker/src/ui/components/admin/feature-disabled.tsx +44 -0
- package/templates/docker/src/ui/components/admin/health-badge.tsx +30 -0
- package/templates/docker/src/ui/components/admin/loading-state.tsx +14 -0
- package/templates/docker/src/ui/components/admin/stat-card.tsx +32 -0
- package/templates/docker/src/ui/components/atlas-chat.tsx +370 -0
- package/templates/docker/src/ui/components/chart/chart-detection.ts +261 -0
- package/templates/docker/src/ui/components/chart/result-chart.tsx +375 -0
- package/templates/docker/src/ui/components/chat/api-key-bar.tsx +66 -0
- package/templates/docker/src/ui/components/chat/copy-button.tsx +25 -0
- package/templates/docker/src/ui/components/chat/data-table.tsx +102 -0
- package/templates/docker/src/ui/components/chat/error-banner.tsx +32 -0
- package/templates/docker/src/ui/components/chat/explore-card.tsx +41 -0
- package/templates/docker/src/ui/components/chat/loading-card.tsx +10 -0
- package/templates/docker/src/ui/components/chat/managed-auth-card.tsx +116 -0
- package/templates/docker/src/ui/components/chat/markdown.tsx +72 -0
- package/templates/docker/src/ui/components/chat/sql-block.tsx +30 -0
- package/templates/docker/src/ui/components/chat/sql-result-card.tsx +144 -0
- package/templates/docker/src/ui/components/chat/starter-prompts.ts +6 -0
- package/templates/docker/src/ui/components/chat/tool-part.tsx +40 -0
- package/templates/docker/src/ui/components/chat/typing-indicator.tsx +19 -0
- package/templates/docker/src/ui/components/conversations/conversation-item.tsx +120 -0
- package/templates/docker/src/ui/components/conversations/conversation-list.tsx +66 -0
- package/templates/docker/src/ui/components/conversations/conversation-sidebar.tsx +78 -0
- package/templates/docker/src/ui/components/conversations/delete-confirmation.tsx +27 -0
- package/templates/docker/src/ui/context.tsx +78 -0
- package/templates/docker/src/ui/hooks/use-admin-fetch.ts +104 -0
- package/templates/docker/src/ui/hooks/use-conversations.ts +184 -0
- package/templates/docker/src/ui/hooks/use-dark-mode.ts +17 -0
- package/templates/docker/src/ui/lib/action-types.ts +63 -0
- package/templates/docker/src/ui/lib/helpers.ts +104 -0
- package/templates/docker/src/ui/lib/types.ts +145 -0
- package/templates/docker/tsconfig.json +41 -0
- package/templates/docker/vercel.json +3 -0
- package/templates/nextjs-standalone/.env.example +68 -0
- package/templates/nextjs-standalone/bin/__tests__/benchmark.test.ts +598 -0
- package/templates/nextjs-standalone/bin/__tests__/duckdb-ingest.test.ts +171 -0
- package/templates/nextjs-standalone/bin/__tests__/eval.test.ts +434 -0
- package/templates/nextjs-standalone/bin/__tests__/matview-partition.test.ts +615 -0
- package/templates/nextjs-standalone/bin/__tests__/multi-source.test.ts +113 -0
- package/templates/nextjs-standalone/bin/__tests__/plugin-cli.test.ts +322 -0
- package/templates/nextjs-standalone/bin/__tests__/profiler-heuristics.test.ts +608 -0
- package/templates/nextjs-standalone/bin/__tests__/query.test.ts +240 -0
- package/templates/nextjs-standalone/bin/__tests__/schema-drift.test.ts +542 -0
- package/templates/nextjs-standalone/bin/__tests__/view-yaml-generation.test.ts +146 -0
- package/templates/nextjs-standalone/bin/atlas.ts +5044 -0
- package/templates/nextjs-standalone/bin/benchmark.ts +695 -0
- package/templates/nextjs-standalone/bin/enrich.ts +559 -0
- package/templates/nextjs-standalone/bin/eval.ts +770 -0
- package/templates/nextjs-standalone/bin/smoke.ts +438 -0
- package/templates/nextjs-standalone/data/.gitkeep +0 -0
- package/templates/nextjs-standalone/data/cybersec.sql +1961 -0
- package/templates/nextjs-standalone/data/demo-semantic/catalog.yml +40 -0
- package/templates/nextjs-standalone/data/demo-semantic/entities/accounts.yml +170 -0
- package/templates/nextjs-standalone/data/demo-semantic/entities/companies.yml +207 -0
- package/templates/nextjs-standalone/data/demo-semantic/entities/people.yml +145 -0
- package/templates/nextjs-standalone/data/demo-semantic/glossary.yml +22 -0
- package/templates/nextjs-standalone/data/demo-semantic/metrics/accounts.yml +38 -0
- package/templates/nextjs-standalone/data/demo-semantic/metrics/companies.yml +89 -0
- package/templates/nextjs-standalone/data/demo.sql +373 -0
- package/templates/nextjs-standalone/data/ecommerce.sql +1690 -0
- package/templates/nextjs-standalone/data/init-demo-db.sql +8 -0
- package/templates/nextjs-standalone/docs/deploy.md +390 -0
- package/templates/nextjs-standalone/eslint.config.mjs +18 -0
- package/templates/nextjs-standalone/gitignore +5 -0
- package/templates/nextjs-standalone/next.config.ts +10 -0
- package/templates/nextjs-standalone/package.json +63 -0
- package/templates/nextjs-standalone/postcss.config.mjs +8 -0
- package/templates/nextjs-standalone/semantic/catalog.yml +5 -0
- package/templates/nextjs-standalone/semantic/entities/.gitkeep +0 -0
- package/templates/nextjs-standalone/semantic/glossary.yml +6 -0
- package/templates/nextjs-standalone/semantic/metrics/.gitkeep +0 -0
- package/templates/nextjs-standalone/src/api/__tests__/actions.test.ts +683 -0
- package/templates/nextjs-standalone/src/api/__tests__/admin.test.ts +820 -0
- package/templates/nextjs-standalone/src/api/__tests__/auth.test.ts +165 -0
- package/templates/nextjs-standalone/src/api/__tests__/chat.test.ts +376 -0
- package/templates/nextjs-standalone/src/api/__tests__/conversations.test.ts +555 -0
- package/templates/nextjs-standalone/src/api/__tests__/cors.test.ts +135 -0
- package/templates/nextjs-standalone/src/api/__tests__/health-plugin.test.ts +169 -0
- package/templates/nextjs-standalone/src/api/__tests__/health.test.ts +261 -0
- package/templates/nextjs-standalone/src/api/__tests__/query.test.ts +891 -0
- package/templates/nextjs-standalone/src/api/__tests__/scheduled-tasks.test.ts +601 -0
- package/templates/nextjs-standalone/src/api/__tests__/slack.test.ts +847 -0
- package/templates/nextjs-standalone/src/api/index.ts +117 -0
- package/templates/nextjs-standalone/src/api/routes/actions.ts +274 -0
- package/templates/nextjs-standalone/src/api/routes/admin.ts +757 -0
- package/templates/nextjs-standalone/src/api/routes/auth.ts +48 -0
- package/templates/nextjs-standalone/src/api/routes/chat.ts +465 -0
- package/templates/nextjs-standalone/src/api/routes/conversations.ts +266 -0
- package/templates/nextjs-standalone/src/api/routes/health.ts +287 -0
- package/templates/nextjs-standalone/src/api/routes/openapi.ts +390 -0
- package/templates/nextjs-standalone/src/api/routes/query.ts +318 -0
- package/templates/nextjs-standalone/src/api/routes/scheduled-tasks.ts +467 -0
- package/templates/nextjs-standalone/src/api/routes/slack.ts +611 -0
- package/templates/nextjs-standalone/src/api/server.ts +226 -0
- package/templates/nextjs-standalone/src/app/api/[...route]/route.ts +33 -0
- package/templates/nextjs-standalone/src/app/error.tsx +24 -0
- package/templates/nextjs-standalone/src/app/global-error.tsx +68 -0
- package/templates/nextjs-standalone/src/app/globals.css +126 -0
- package/templates/nextjs-standalone/src/app/layout.tsx +19 -0
- package/templates/nextjs-standalone/src/app/page.tsx +14 -0
- package/templates/nextjs-standalone/src/lib/__tests__/agent-cache.test.ts +437 -0
- package/templates/nextjs-standalone/src/lib/__tests__/agent-dialect.test.ts +114 -0
- package/templates/nextjs-standalone/src/lib/__tests__/agent-health-annotations.test.ts +164 -0
- package/templates/nextjs-standalone/src/lib/__tests__/agent-integration.test.ts +514 -0
- package/templates/nextjs-standalone/src/lib/__tests__/config-actions.test.ts +166 -0
- package/templates/nextjs-standalone/src/lib/__tests__/config.test.ts +1063 -0
- package/templates/nextjs-standalone/src/lib/__tests__/conversations.test.ts +589 -0
- package/templates/nextjs-standalone/src/lib/__tests__/errors.test.ts +256 -0
- package/templates/nextjs-standalone/src/lib/__tests__/logger.test.ts +200 -0
- package/templates/nextjs-standalone/src/lib/__tests__/providers.test.ts +99 -0
- package/templates/nextjs-standalone/src/lib/__tests__/rls.test.ts +435 -0
- package/templates/nextjs-standalone/src/lib/__tests__/scheduled-task-types.test.ts +124 -0
- package/templates/nextjs-standalone/src/lib/__tests__/scheduled-tasks.test.ts +550 -0
- package/templates/nextjs-standalone/src/lib/__tests__/semantic-index.test.ts +547 -0
- package/templates/nextjs-standalone/src/lib/__tests__/semantic-multisource.test.ts +544 -0
- package/templates/nextjs-standalone/src/lib/__tests__/semantic.test.ts +363 -0
- package/templates/nextjs-standalone/src/lib/__tests__/startup-actions.test.ts +452 -0
- package/templates/nextjs-standalone/src/lib/__tests__/startup.test.ts +465 -0
- package/templates/nextjs-standalone/src/lib/__tests__/tracing.test.ts +28 -0
- package/templates/nextjs-standalone/src/lib/action-types.ts +95 -0
- package/templates/nextjs-standalone/src/lib/agent-query.ts +178 -0
- package/templates/nextjs-standalone/src/lib/agent.ts +505 -0
- package/templates/nextjs-standalone/src/lib/api-url.ts +3 -0
- package/templates/nextjs-standalone/src/lib/auth/__tests__/audit.test.ts +418 -0
- package/templates/nextjs-standalone/src/lib/auth/__tests__/byot-integration.test.ts +222 -0
- package/templates/nextjs-standalone/src/lib/auth/__tests__/byot.test.ts +366 -0
- package/templates/nextjs-standalone/src/lib/auth/__tests__/detect.test.ts +190 -0
- package/templates/nextjs-standalone/src/lib/auth/__tests__/managed.test.ts +173 -0
- package/templates/nextjs-standalone/src/lib/auth/__tests__/middleware.test.ts +456 -0
- package/templates/nextjs-standalone/src/lib/auth/__tests__/migrate.test.ts +201 -0
- package/templates/nextjs-standalone/src/lib/auth/__tests__/permissions.test.ts +225 -0
- package/templates/nextjs-standalone/src/lib/auth/__tests__/server.test.ts +34 -0
- package/templates/nextjs-standalone/src/lib/auth/__tests__/simple-key.test.ts +176 -0
- package/templates/nextjs-standalone/src/lib/auth/__tests__/types.test.ts +44 -0
- package/templates/nextjs-standalone/src/lib/auth/audit.ts +89 -0
- package/templates/nextjs-standalone/src/lib/auth/byot.ts +158 -0
- package/templates/nextjs-standalone/src/lib/auth/client.ts +23 -0
- package/templates/nextjs-standalone/src/lib/auth/detect.ts +83 -0
- package/templates/nextjs-standalone/src/lib/auth/managed.ts +73 -0
- package/templates/nextjs-standalone/src/lib/auth/middleware.ts +208 -0
- package/templates/nextjs-standalone/src/lib/auth/migrate.ts +111 -0
- package/templates/nextjs-standalone/src/lib/auth/permissions.ts +156 -0
- package/templates/nextjs-standalone/src/lib/auth/server.ts +142 -0
- package/templates/nextjs-standalone/src/lib/auth/simple-key.ts +92 -0
- package/templates/nextjs-standalone/src/lib/auth/types.ts +49 -0
- package/templates/nextjs-standalone/src/lib/config.ts +704 -0
- package/templates/nextjs-standalone/src/lib/conversation-types.ts +29 -0
- package/templates/nextjs-standalone/src/lib/conversations.ts +270 -0
- package/templates/nextjs-standalone/src/lib/db/__tests__/connection.test.ts +69 -0
- package/templates/nextjs-standalone/src/lib/db/__tests__/duckdb.test.ts +141 -0
- package/templates/nextjs-standalone/src/lib/db/__tests__/internal.test.ts +387 -0
- package/templates/nextjs-standalone/src/lib/db/__tests__/registry-health.test.ts +207 -0
- package/templates/nextjs-standalone/src/lib/db/__tests__/registry-pool-limits.test.ts +156 -0
- package/templates/nextjs-standalone/src/lib/db/__tests__/registry.test.ts +595 -0
- package/templates/nextjs-standalone/src/lib/db/__tests__/salesforce.test.ts +339 -0
- package/templates/nextjs-standalone/src/lib/db/__tests__/snowflake.test.ts +217 -0
- package/templates/nextjs-standalone/src/lib/db/__tests__/source-rate-limit.test.ts +130 -0
- package/templates/nextjs-standalone/src/lib/db/connection.ts +753 -0
- package/templates/nextjs-standalone/src/lib/db/duckdb.ts +122 -0
- package/templates/nextjs-standalone/src/lib/db/internal.ts +273 -0
- package/templates/nextjs-standalone/src/lib/db/salesforce.ts +342 -0
- package/templates/nextjs-standalone/src/lib/db/source-rate-limit.ts +191 -0
- package/templates/nextjs-standalone/src/lib/errors.ts +154 -0
- package/templates/nextjs-standalone/src/lib/logger.ts +98 -0
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/hooks-integration.test.ts +202 -0
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/hooks.test.ts +529 -0
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/migrate.test.ts +521 -0
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/registry.test.ts +346 -0
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/tools.test.ts +49 -0
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/wiring.test.ts +585 -0
- package/templates/nextjs-standalone/src/lib/plugins/hooks.ts +162 -0
- package/templates/nextjs-standalone/src/lib/plugins/index.ts +9 -0
- package/templates/nextjs-standalone/src/lib/plugins/migrate.ts +309 -0
- package/templates/nextjs-standalone/src/lib/plugins/registry.ts +231 -0
- package/templates/nextjs-standalone/src/lib/plugins/tools.ts +39 -0
- package/templates/nextjs-standalone/src/lib/plugins/wiring.ts +291 -0
- package/templates/nextjs-standalone/src/lib/providers.ts +102 -0
- package/templates/nextjs-standalone/src/lib/rls.ts +321 -0
- package/templates/nextjs-standalone/src/lib/scheduled-task-types.ts +132 -0
- package/templates/nextjs-standalone/src/lib/scheduled-tasks.ts +475 -0
- package/templates/nextjs-standalone/src/lib/scheduler/__tests__/delivery.test.ts +192 -0
- package/templates/nextjs-standalone/src/lib/scheduler/__tests__/engine.test.ts +248 -0
- package/templates/nextjs-standalone/src/lib/scheduler/__tests__/format-email.test.ts +96 -0
- package/templates/nextjs-standalone/src/lib/scheduler/__tests__/format-slack.test.ts +78 -0
- package/templates/nextjs-standalone/src/lib/scheduler/__tests__/format-webhook.test.ts +78 -0
- package/templates/nextjs-standalone/src/lib/scheduler/delivery.ts +248 -0
- package/templates/nextjs-standalone/src/lib/scheduler/engine.ts +317 -0
- package/templates/nextjs-standalone/src/lib/scheduler/executor.ts +73 -0
- package/templates/nextjs-standalone/src/lib/scheduler/format-email.ts +109 -0
- package/templates/nextjs-standalone/src/lib/scheduler/format-slack.ts +35 -0
- package/templates/nextjs-standalone/src/lib/scheduler/format-webhook.ts +37 -0
- package/templates/nextjs-standalone/src/lib/scheduler/index.ts +7 -0
- package/templates/nextjs-standalone/src/lib/security.ts +11 -0
- package/templates/nextjs-standalone/src/lib/semantic-index.ts +503 -0
- package/templates/nextjs-standalone/src/lib/semantic.ts +387 -0
- package/templates/nextjs-standalone/src/lib/sidecar-types.ts +16 -0
- package/templates/nextjs-standalone/src/lib/slack/__tests__/api.test.ts +160 -0
- package/templates/nextjs-standalone/src/lib/slack/__tests__/format.test.ts +237 -0
- package/templates/nextjs-standalone/src/lib/slack/__tests__/store.test.ts +188 -0
- package/templates/nextjs-standalone/src/lib/slack/__tests__/threads.test.ts +112 -0
- package/templates/nextjs-standalone/src/lib/slack/__tests__/verify.test.ts +111 -0
- package/templates/nextjs-standalone/src/lib/slack/api.ts +102 -0
- package/templates/nextjs-standalone/src/lib/slack/format.ts +209 -0
- package/templates/nextjs-standalone/src/lib/slack/store.ts +107 -0
- package/templates/nextjs-standalone/src/lib/slack/threads.ts +64 -0
- package/templates/nextjs-standalone/src/lib/slack/verify.ts +71 -0
- package/templates/nextjs-standalone/src/lib/startup.ts +730 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/action-permissions.test.ts +594 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/custom-validation.test.ts +238 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-backend.test.ts +267 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-nsjail.test.ts +492 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-plugin.test.ts +374 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-sdk-compat.test.ts +82 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-sidecar.test.ts +208 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/registry-actions.test.ts +144 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/registry.test.ts +235 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/salesforce-tool.test.ts +154 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/soql-validation.test.ts +303 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/sql-audit.test.ts +225 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/sql-connection-whitelist.test.ts +98 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/sql-duckdb.test.ts +233 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/sql-ratelimit.test.ts +225 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/sql.test.ts +1012 -0
- package/templates/nextjs-standalone/src/lib/tools/actions/__tests__/audit.test.ts +211 -0
- package/templates/nextjs-standalone/src/lib/tools/actions/__tests__/email.test.ts +378 -0
- package/templates/nextjs-standalone/src/lib/tools/actions/__tests__/handler.test.ts +681 -0
- package/templates/nextjs-standalone/src/lib/tools/actions/__tests__/jira.test.ts +427 -0
- package/templates/nextjs-standalone/src/lib/tools/actions/audit.ts +47 -0
- package/templates/nextjs-standalone/src/lib/tools/actions/email.ts +191 -0
- package/templates/nextjs-standalone/src/lib/tools/actions/handler.ts +591 -0
- package/templates/nextjs-standalone/src/lib/tools/actions/index.ts +23 -0
- package/templates/nextjs-standalone/src/lib/tools/actions/jira.ts +220 -0
- package/templates/nextjs-standalone/src/lib/tools/explore-nsjail.ts +343 -0
- package/templates/nextjs-standalone/src/lib/tools/explore-sandbox.ts +264 -0
- package/templates/nextjs-standalone/src/lib/tools/explore-sidecar.ts +163 -0
- package/templates/nextjs-standalone/src/lib/tools/explore.ts +379 -0
- package/templates/nextjs-standalone/src/lib/tools/registry.ts +221 -0
- package/templates/nextjs-standalone/src/lib/tools/salesforce.ts +138 -0
- package/templates/nextjs-standalone/src/lib/tools/soql-validation.ts +172 -0
- package/templates/nextjs-standalone/src/lib/tools/sql.ts +680 -0
- package/templates/nextjs-standalone/src/lib/tracing.ts +40 -0
- package/templates/nextjs-standalone/src/lib/utils.ts +6 -0
- package/templates/nextjs-standalone/src/test-setup.ts +38 -0
- package/templates/nextjs-standalone/src/ui/components/actions/action-approval-card.tsx +295 -0
- package/templates/nextjs-standalone/src/ui/components/actions/action-status-badge.tsx +50 -0
- package/templates/nextjs-standalone/src/ui/components/admin/admin-layout.tsx +26 -0
- package/templates/nextjs-standalone/src/ui/components/admin/admin-sidebar.tsx +96 -0
- package/templates/nextjs-standalone/src/ui/components/admin/empty-state.tsx +24 -0
- package/templates/nextjs-standalone/src/ui/components/admin/entity-detail.tsx +233 -0
- package/templates/nextjs-standalone/src/ui/components/admin/entity-list.tsx +96 -0
- package/templates/nextjs-standalone/src/ui/components/admin/error-banner.tsx +22 -0
- package/templates/nextjs-standalone/src/ui/components/admin/feature-disabled.tsx +44 -0
- package/templates/nextjs-standalone/src/ui/components/admin/health-badge.tsx +30 -0
- package/templates/nextjs-standalone/src/ui/components/admin/loading-state.tsx +14 -0
- package/templates/nextjs-standalone/src/ui/components/admin/stat-card.tsx +32 -0
- package/templates/nextjs-standalone/src/ui/components/atlas-chat.tsx +370 -0
- package/templates/nextjs-standalone/src/ui/components/chart/chart-detection.ts +261 -0
- package/templates/nextjs-standalone/src/ui/components/chart/result-chart.tsx +375 -0
- package/templates/nextjs-standalone/src/ui/components/chat/api-key-bar.tsx +66 -0
- package/templates/nextjs-standalone/src/ui/components/chat/copy-button.tsx +25 -0
- package/templates/nextjs-standalone/src/ui/components/chat/data-table.tsx +102 -0
- package/templates/nextjs-standalone/src/ui/components/chat/error-banner.tsx +32 -0
- package/templates/nextjs-standalone/src/ui/components/chat/explore-card.tsx +41 -0
- package/templates/nextjs-standalone/src/ui/components/chat/loading-card.tsx +10 -0
- package/templates/nextjs-standalone/src/ui/components/chat/managed-auth-card.tsx +116 -0
- package/templates/nextjs-standalone/src/ui/components/chat/markdown.tsx +72 -0
- package/templates/nextjs-standalone/src/ui/components/chat/sql-block.tsx +30 -0
- package/templates/nextjs-standalone/src/ui/components/chat/sql-result-card.tsx +144 -0
- package/templates/nextjs-standalone/src/ui/components/chat/starter-prompts.ts +6 -0
- package/templates/nextjs-standalone/src/ui/components/chat/tool-part.tsx +40 -0
- package/templates/nextjs-standalone/src/ui/components/chat/typing-indicator.tsx +19 -0
- package/templates/nextjs-standalone/src/ui/components/conversations/conversation-item.tsx +120 -0
- package/templates/nextjs-standalone/src/ui/components/conversations/conversation-list.tsx +66 -0
- package/templates/nextjs-standalone/src/ui/components/conversations/conversation-sidebar.tsx +78 -0
- package/templates/nextjs-standalone/src/ui/components/conversations/delete-confirmation.tsx +27 -0
- package/templates/nextjs-standalone/src/ui/context.tsx +78 -0
- package/templates/nextjs-standalone/src/ui/hooks/use-admin-fetch.ts +104 -0
- package/templates/nextjs-standalone/src/ui/hooks/use-conversations.ts +184 -0
- package/templates/nextjs-standalone/src/ui/hooks/use-dark-mode.ts +17 -0
- package/templates/nextjs-standalone/src/ui/lib/action-types.ts +63 -0
- package/templates/nextjs-standalone/src/ui/lib/helpers.ts +104 -0
- package/templates/nextjs-standalone/src/ui/lib/types.ts +145 -0
- package/templates/nextjs-standalone/tsconfig.json +32 -0
- package/templates/nextjs-standalone/vercel.json +4 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { describe, expect, it, afterEach, mock } from "bun:test";
|
|
2
|
+
import { tool } from "ai";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
// Mock the Salesforce tool so the registry module can be imported
|
|
6
|
+
// without needing jsforce or a real Salesforce connection.
|
|
7
|
+
const mockSfTool = tool({
|
|
8
|
+
description: "Mock querySalesforce",
|
|
9
|
+
inputSchema: z.object({ soql: z.string() }),
|
|
10
|
+
execute: async ({ soql }) => soql,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
mock.module("@atlas/api/lib/tools/salesforce", () => ({
|
|
14
|
+
querySalesforce: mockSfTool,
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
const { ToolRegistry } = await import("@atlas/api/lib/tools/registry");
|
|
18
|
+
|
|
19
|
+
function makeTool(name: string) {
|
|
20
|
+
return tool({
|
|
21
|
+
description: `Test tool: ${name}`,
|
|
22
|
+
inputSchema: z.object({ input: z.string() }),
|
|
23
|
+
execute: async ({ input }) => input,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function makeAction(name: string, opts?: { requiredCredentials?: string[] }) {
|
|
28
|
+
return {
|
|
29
|
+
name,
|
|
30
|
+
description: `Action: ${name}`,
|
|
31
|
+
tool: tool({
|
|
32
|
+
description: name,
|
|
33
|
+
inputSchema: z.object({ input: z.string() }),
|
|
34
|
+
execute: async ({ input }) => input,
|
|
35
|
+
}),
|
|
36
|
+
actionType: `test:${name}`,
|
|
37
|
+
reversible: true,
|
|
38
|
+
defaultApproval: "manual" as const,
|
|
39
|
+
requiredCredentials: opts?.requiredCredentials ?? [],
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
describe("ToolRegistry — getActions", () => {
|
|
44
|
+
it("returns empty array when no actions registered", () => {
|
|
45
|
+
const registry = new ToolRegistry();
|
|
46
|
+
expect(registry.getActions()).toEqual([]);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("returns only tools that are actions (have actionType field)", () => {
|
|
50
|
+
const registry = new ToolRegistry();
|
|
51
|
+
const action1 = makeAction("sendEmail");
|
|
52
|
+
const action2 = makeAction("createTicket");
|
|
53
|
+
registry.register(action1);
|
|
54
|
+
registry.register(action2);
|
|
55
|
+
|
|
56
|
+
const actions = registry.getActions();
|
|
57
|
+
expect(actions).toHaveLength(2);
|
|
58
|
+
expect(actions[0].name).toBe("sendEmail");
|
|
59
|
+
expect(actions[1].name).toBe("createTicket");
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("doesn't return regular tools (without actionType)", () => {
|
|
63
|
+
const registry = new ToolRegistry();
|
|
64
|
+
registry.register({ name: "explore", description: "Explore", tool: makeTool("explore") });
|
|
65
|
+
registry.register({ name: "executeSQL", description: "SQL", tool: makeTool("sql") });
|
|
66
|
+
|
|
67
|
+
const actions = registry.getActions();
|
|
68
|
+
expect(actions).toEqual([]);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
describe("ToolRegistry — validateActionCredentials", () => {
|
|
73
|
+
const origTestApiKey = process.env.TEST_API_KEY;
|
|
74
|
+
const origTestSecret = process.env.TEST_SECRET;
|
|
75
|
+
const origMissingKeyA = process.env.MISSING_KEY_A;
|
|
76
|
+
const origMissingKeyB = process.env.MISSING_KEY_B;
|
|
77
|
+
const origPresentKey = process.env.PRESENT_KEY;
|
|
78
|
+
|
|
79
|
+
afterEach(() => {
|
|
80
|
+
if (origTestApiKey !== undefined) process.env.TEST_API_KEY = origTestApiKey; else delete process.env.TEST_API_KEY;
|
|
81
|
+
if (origTestSecret !== undefined) process.env.TEST_SECRET = origTestSecret; else delete process.env.TEST_SECRET;
|
|
82
|
+
if (origMissingKeyA !== undefined) process.env.MISSING_KEY_A = origMissingKeyA; else delete process.env.MISSING_KEY_A;
|
|
83
|
+
if (origMissingKeyB !== undefined) process.env.MISSING_KEY_B = origMissingKeyB; else delete process.env.MISSING_KEY_B;
|
|
84
|
+
if (origPresentKey !== undefined) process.env.PRESENT_KEY = origPresentKey; else delete process.env.PRESENT_KEY;
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("returns empty array when no actions", () => {
|
|
88
|
+
const registry = new ToolRegistry();
|
|
89
|
+
expect(registry.validateActionCredentials()).toEqual([]);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("returns empty array when all credentials present", () => {
|
|
93
|
+
process.env.TEST_API_KEY = "key-123";
|
|
94
|
+
process.env.TEST_SECRET = "secret-456";
|
|
95
|
+
|
|
96
|
+
const registry = new ToolRegistry();
|
|
97
|
+
registry.register(
|
|
98
|
+
makeAction("myAction", { requiredCredentials: ["TEST_API_KEY", "TEST_SECRET"] }),
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
expect(registry.validateActionCredentials()).toEqual([]);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("returns missing credentials for each action", () => {
|
|
105
|
+
delete process.env.MISSING_KEY_A;
|
|
106
|
+
delete process.env.MISSING_KEY_B;
|
|
107
|
+
process.env.PRESENT_KEY = "exists";
|
|
108
|
+
|
|
109
|
+
const registry = new ToolRegistry();
|
|
110
|
+
registry.register(
|
|
111
|
+
makeAction("actionA", { requiredCredentials: ["MISSING_KEY_A", "PRESENT_KEY"] }),
|
|
112
|
+
);
|
|
113
|
+
registry.register(
|
|
114
|
+
makeAction("actionB", { requiredCredentials: ["MISSING_KEY_B"] }),
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
const result = registry.validateActionCredentials();
|
|
118
|
+
expect(result).toHaveLength(2);
|
|
119
|
+
expect(result[0]).toEqual({ action: "actionA", missing: ["MISSING_KEY_A"] });
|
|
120
|
+
expect(result[1]).toEqual({ action: "actionB", missing: ["MISSING_KEY_B"] });
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
describe("ToolRegistry — actions alongside regular tools", () => {
|
|
125
|
+
it("actions can be registered alongside regular tools", () => {
|
|
126
|
+
const registry = new ToolRegistry();
|
|
127
|
+
registry.register({ name: "explore", description: "Explore", tool: makeTool("explore") });
|
|
128
|
+
registry.register(makeAction("sendEmail"));
|
|
129
|
+
registry.register({ name: "executeSQL", description: "SQL", tool: makeTool("sql") });
|
|
130
|
+
registry.register(makeAction("createTicket"));
|
|
131
|
+
|
|
132
|
+
const all = registry.getAll();
|
|
133
|
+
expect(Object.keys(all).sort()).toEqual([
|
|
134
|
+
"createTicket",
|
|
135
|
+
"executeSQL",
|
|
136
|
+
"explore",
|
|
137
|
+
"sendEmail",
|
|
138
|
+
]);
|
|
139
|
+
|
|
140
|
+
const actions = registry.getActions();
|
|
141
|
+
expect(actions).toHaveLength(2);
|
|
142
|
+
expect(actions.map((a) => a.name).sort()).toEqual(["createTicket", "sendEmail"]);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { describe, expect, it, mock } from "bun:test";
|
|
2
|
+
import { tool } from "ai";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
// Mock the Salesforce tool so buildRegistry({ includeSalesforce: true }) works
|
|
6
|
+
// without needing jsforce or a real Salesforce connection.
|
|
7
|
+
const mockSfTool = tool({
|
|
8
|
+
description: "Mock querySalesforce",
|
|
9
|
+
inputSchema: z.object({ soql: z.string() }),
|
|
10
|
+
execute: async ({ soql }) => soql,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
mock.module("@atlas/api/lib/tools/salesforce", () => ({
|
|
14
|
+
querySalesforce: mockSfTool,
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
// Mock the action tools so buildRegistry({ includeActions: true }) works
|
|
18
|
+
// without needing JIRA/email credentials or external services.
|
|
19
|
+
const mockJiraTool = tool({
|
|
20
|
+
description: "Mock createJiraTicket tool",
|
|
21
|
+
inputSchema: z.object({ summary: z.string() }),
|
|
22
|
+
execute: async ({ summary }) => summary,
|
|
23
|
+
});
|
|
24
|
+
const mockEmailTool = tool({
|
|
25
|
+
description: "Mock sendEmailReport tool",
|
|
26
|
+
inputSchema: z.object({ to: z.string() }),
|
|
27
|
+
execute: async ({ to }) => to,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
mock.module("@atlas/api/lib/tools/actions", () => ({
|
|
31
|
+
createJiraTicket: {
|
|
32
|
+
name: "createJiraTicket",
|
|
33
|
+
description: "### Create JIRA Ticket\nMock description",
|
|
34
|
+
tool: mockJiraTool,
|
|
35
|
+
actionType: "jira:create",
|
|
36
|
+
reversible: true,
|
|
37
|
+
defaultApproval: "manual",
|
|
38
|
+
requiredCredentials: ["JIRA_BASE_URL", "JIRA_EMAIL", "JIRA_API_TOKEN"],
|
|
39
|
+
},
|
|
40
|
+
sendEmailReport: {
|
|
41
|
+
name: "sendEmailReport",
|
|
42
|
+
description: "### Send Email Report\nMock description",
|
|
43
|
+
tool: mockEmailTool,
|
|
44
|
+
actionType: "email:send",
|
|
45
|
+
reversible: false,
|
|
46
|
+
defaultApproval: "admin-only",
|
|
47
|
+
requiredCredentials: ["RESEND_API_KEY"],
|
|
48
|
+
},
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
const { ToolRegistry, defaultRegistry, buildRegistry } = await import(
|
|
52
|
+
"@atlas/api/lib/tools/registry"
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
function makeTool(name: string) {
|
|
56
|
+
return tool({
|
|
57
|
+
description: `Test tool: ${name}`,
|
|
58
|
+
inputSchema: z.object({ input: z.string() }),
|
|
59
|
+
execute: async ({ input }) => input,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
describe("ToolRegistry", () => {
|
|
64
|
+
it("register + get — stores and retrieves a tool", () => {
|
|
65
|
+
const registry = new ToolRegistry();
|
|
66
|
+
const entry = { name: "foo", description: "Foo desc", tool: makeTool("foo") };
|
|
67
|
+
registry.register(entry);
|
|
68
|
+
expect(registry.get("foo")).toBe(entry);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("get returns undefined for unknown name", () => {
|
|
72
|
+
const registry = new ToolRegistry();
|
|
73
|
+
expect(registry.get("nonexistent")).toBeUndefined();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("getAll returns a ToolSet with all registered tools", () => {
|
|
77
|
+
const registry = new ToolRegistry();
|
|
78
|
+
const fooTool = makeTool("foo");
|
|
79
|
+
const barTool = makeTool("bar");
|
|
80
|
+
registry.register({ name: "foo", description: "Foo", tool: fooTool });
|
|
81
|
+
registry.register({ name: "bar", description: "Bar", tool: barTool });
|
|
82
|
+
|
|
83
|
+
const all = registry.getAll();
|
|
84
|
+
expect(Object.keys(all).sort()).toEqual(["bar", "foo"]);
|
|
85
|
+
expect(all.foo).toBe(fooTool);
|
|
86
|
+
expect(all.bar).toBe(barTool);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("describe concatenates descriptions with \\n\\n separator", () => {
|
|
90
|
+
const registry = new ToolRegistry();
|
|
91
|
+
registry.register({ name: "a", description: "Desc A", tool: makeTool("a") });
|
|
92
|
+
registry.register({ name: "b", description: "Desc B", tool: makeTool("b") });
|
|
93
|
+
expect(registry.describe()).toBe("Desc A\n\nDesc B");
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("describe returns empty string for empty registry", () => {
|
|
97
|
+
const registry = new ToolRegistry();
|
|
98
|
+
expect(registry.describe()).toBe("");
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("duplicate registration overwrites the previous entry", () => {
|
|
102
|
+
const registry = new ToolRegistry();
|
|
103
|
+
const tool1 = makeTool("v1");
|
|
104
|
+
const tool2 = makeTool("v2");
|
|
105
|
+
registry.register({ name: "x", description: "First", tool: tool1 });
|
|
106
|
+
registry.register({ name: "x", description: "Second", tool: tool2 });
|
|
107
|
+
|
|
108
|
+
expect(registry.get("x")!.description).toBe("Second");
|
|
109
|
+
expect(registry.get("x")!.tool).toBe(tool2);
|
|
110
|
+
expect(Object.keys(registry.getAll())).toEqual(["x"]);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("describe() preserves registration order", () => {
|
|
114
|
+
const registry = new ToolRegistry();
|
|
115
|
+
registry.register({ name: "a", description: "Desc A", tool: makeTool("a") });
|
|
116
|
+
registry.register({ name: "b", description: "Desc B", tool: makeTool("b") });
|
|
117
|
+
registry.register({ name: "c", description: "Desc C", tool: makeTool("c") });
|
|
118
|
+
expect(registry.describe()).toBe("Desc A\n\nDesc B\n\nDesc C");
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("getAll() returns a fresh object", () => {
|
|
122
|
+
const registry = new ToolRegistry();
|
|
123
|
+
registry.register({ name: "a", description: "A", tool: makeTool("a") });
|
|
124
|
+
registry.register({ name: "b", description: "B", tool: makeTool("b") });
|
|
125
|
+
|
|
126
|
+
const first = registry.getAll();
|
|
127
|
+
delete first.a;
|
|
128
|
+
|
|
129
|
+
const second = registry.getAll();
|
|
130
|
+
expect(second.a).toBeDefined();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("register() throws on empty name", () => {
|
|
134
|
+
const registry = new ToolRegistry();
|
|
135
|
+
expect(() =>
|
|
136
|
+
registry.register({ name: "", description: "X", tool: makeTool("x") })
|
|
137
|
+
).toThrow();
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it("register() throws on empty description", () => {
|
|
141
|
+
const registry = new ToolRegistry();
|
|
142
|
+
expect(() =>
|
|
143
|
+
registry.register({ name: "x", description: "", tool: makeTool("x") })
|
|
144
|
+
).toThrow();
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("register() throws on frozen registry", () => {
|
|
148
|
+
const registry = new ToolRegistry();
|
|
149
|
+
registry.register({ name: "a", description: "A", tool: makeTool("a") });
|
|
150
|
+
registry.freeze();
|
|
151
|
+
expect(() =>
|
|
152
|
+
registry.register({ name: "b", description: "B", tool: makeTool("b") })
|
|
153
|
+
).toThrow();
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
describe("defaultRegistry", () => {
|
|
158
|
+
it("contains all 2 core tools", () => {
|
|
159
|
+
expect(defaultRegistry.get("explore")).toBeDefined();
|
|
160
|
+
expect(defaultRegistry.get("executeSQL")).toBeDefined();
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it("getAll returns exactly the 2 core tools", () => {
|
|
164
|
+
const all = defaultRegistry.getAll();
|
|
165
|
+
expect(Object.keys(all).sort()).toEqual(["executeSQL", "explore"]);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it("describe produces the expected workflow text", () => {
|
|
169
|
+
const text = defaultRegistry.describe();
|
|
170
|
+
expect(text).toContain("### 2. Explore the Semantic Layer");
|
|
171
|
+
expect(text).toContain("### 3. Write and Execute SQL");
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it("is frozen — cannot register additional tools", () => {
|
|
175
|
+
expect(() =>
|
|
176
|
+
defaultRegistry.register({ name: "rogue", description: "X", tool: makeTool("x") })
|
|
177
|
+
).toThrow("Cannot register tools on a frozen registry");
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
describe("buildRegistry", () => {
|
|
182
|
+
it("without Salesforce returns 2 core tools", async () => {
|
|
183
|
+
const registry = await buildRegistry();
|
|
184
|
+
const names = Object.keys(registry.getAll()).sort();
|
|
185
|
+
expect(names).toEqual(["executeSQL", "explore"]);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it("with includeSalesforce returns 3 tools including querySalesforce", async () => {
|
|
189
|
+
const registry = await buildRegistry({ includeSalesforce: true });
|
|
190
|
+
const names = Object.keys(registry.getAll()).sort();
|
|
191
|
+
expect(names).toEqual(["executeSQL", "explore", "querySalesforce"]);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it("with includeActions returns 4 tools including createJiraTicket and sendEmailReport", async () => {
|
|
195
|
+
const registry = await buildRegistry({ includeActions: true });
|
|
196
|
+
const names = Object.keys(registry.getAll()).sort();
|
|
197
|
+
expect(names).toEqual([
|
|
198
|
+
"createJiraTicket",
|
|
199
|
+
"executeSQL",
|
|
200
|
+
"explore",
|
|
201
|
+
"sendEmailReport",
|
|
202
|
+
]);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it("with both includeSalesforce and includeActions returns 5 tools", async () => {
|
|
206
|
+
const registry = await buildRegistry({ includeSalesforce: true, includeActions: true });
|
|
207
|
+
const names = Object.keys(registry.getAll()).sort();
|
|
208
|
+
expect(names).toEqual([
|
|
209
|
+
"createJiraTicket",
|
|
210
|
+
"executeSQL",
|
|
211
|
+
"explore",
|
|
212
|
+
"querySalesforce",
|
|
213
|
+
"sendEmailReport",
|
|
214
|
+
]);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it("returned registry is frozen", async () => {
|
|
218
|
+
const registry = await buildRegistry();
|
|
219
|
+
expect(() =>
|
|
220
|
+
registry.register({ name: "extra", description: "X", tool: makeTool("x") })
|
|
221
|
+
).toThrow("Cannot register tools on a frozen registry");
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it("getActions returns action tools with correct metadata", async () => {
|
|
225
|
+
const registry = await buildRegistry({ includeActions: true });
|
|
226
|
+
const actions = registry.getActions();
|
|
227
|
+
const actionTypes = actions.map((a) => a.actionType).sort();
|
|
228
|
+
expect(actionTypes).toEqual(["email:send", "jira:create"]);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it("core-only registry has no actions", async () => {
|
|
232
|
+
const registry = await buildRegistry();
|
|
233
|
+
expect(registry.getActions()).toEqual([]);
|
|
234
|
+
});
|
|
235
|
+
});
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for the querySalesforce agent tool.
|
|
3
|
+
*/
|
|
4
|
+
import { describe, it, expect, beforeEach, mock } from "bun:test";
|
|
5
|
+
|
|
6
|
+
// Mock Salesforce registry
|
|
7
|
+
const mockQuery = mock(() =>
|
|
8
|
+
Promise.resolve({
|
|
9
|
+
columns: ["Id", "Name"],
|
|
10
|
+
rows: [
|
|
11
|
+
{ Id: "001", Name: "Acme" },
|
|
12
|
+
{ Id: "002", Name: "Widget Co" },
|
|
13
|
+
],
|
|
14
|
+
}),
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
const mockSources = new Map<string, { query: typeof mockQuery; close: () => Promise<void> }>();
|
|
18
|
+
|
|
19
|
+
mock.module("@atlas/api/lib/db/salesforce", () => ({
|
|
20
|
+
getSalesforceSource: (id: string) => {
|
|
21
|
+
const source = mockSources.get(id);
|
|
22
|
+
if (!source) throw new Error(`Salesforce source "${id}" is not registered.`);
|
|
23
|
+
return source;
|
|
24
|
+
},
|
|
25
|
+
listSalesforceSources: () => Array.from(mockSources.keys()),
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
// Mock semantic layer
|
|
29
|
+
mock.module("@atlas/api/lib/semantic", () => ({
|
|
30
|
+
getWhitelistedTables: () => new Set(["account", "contact", "opportunity"]),
|
|
31
|
+
_resetWhitelists: () => {},
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
// Mock audit log (no-op)
|
|
35
|
+
mock.module("@atlas/api/lib/auth/audit", () => ({
|
|
36
|
+
logQueryAudit: () => {},
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
const { querySalesforce } = await import("@atlas/api/lib/tools/salesforce");
|
|
40
|
+
|
|
41
|
+
// Helper to call the tool's execute function
|
|
42
|
+
async function executeTool(params: {
|
|
43
|
+
soql: string;
|
|
44
|
+
explanation: string;
|
|
45
|
+
connectionId?: string;
|
|
46
|
+
}) {
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
+
return (querySalesforce as any).execute(params);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
describe("querySalesforce tool", () => {
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
mockQuery.mockClear();
|
|
54
|
+
mockQuery.mockImplementation(() =>
|
|
55
|
+
Promise.resolve({
|
|
56
|
+
columns: ["Id", "Name"],
|
|
57
|
+
rows: [
|
|
58
|
+
{ Id: "001", Name: "Acme" },
|
|
59
|
+
{ Id: "002", Name: "Widget Co" },
|
|
60
|
+
],
|
|
61
|
+
}),
|
|
62
|
+
);
|
|
63
|
+
mockSources.clear();
|
|
64
|
+
mockSources.set("default", {
|
|
65
|
+
query: mockQuery,
|
|
66
|
+
close: async () => {},
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("executes a valid query and returns results", async () => {
|
|
71
|
+
const result = await executeTool({
|
|
72
|
+
soql: "SELECT Id, Name FROM Account",
|
|
73
|
+
explanation: "Get all accounts",
|
|
74
|
+
});
|
|
75
|
+
expect(result.success).toBe(true);
|
|
76
|
+
expect(result.columns).toEqual(["Id", "Name"]);
|
|
77
|
+
expect(result.rows).toHaveLength(2);
|
|
78
|
+
expect(result.row_count).toBe(2);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("rejects invalid SOQL (mutation)", async () => {
|
|
82
|
+
const result = await executeTool({
|
|
83
|
+
soql: "DELETE FROM Account",
|
|
84
|
+
explanation: "Delete accounts",
|
|
85
|
+
});
|
|
86
|
+
expect(result.success).toBe(false);
|
|
87
|
+
expect(result.error).toContain("Forbidden");
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("rejects queries against non-whitelisted objects", async () => {
|
|
91
|
+
const result = await executeTool({
|
|
92
|
+
soql: "SELECT Id FROM CustomObject__c",
|
|
93
|
+
explanation: "Get custom objects",
|
|
94
|
+
});
|
|
95
|
+
expect(result.success).toBe(false);
|
|
96
|
+
expect(result.error).toContain("not in the allowed list");
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("returns error for unregistered connection", async () => {
|
|
100
|
+
const result = await executeTool({
|
|
101
|
+
soql: "SELECT Id FROM Account",
|
|
102
|
+
explanation: "test",
|
|
103
|
+
connectionId: "nonexistent",
|
|
104
|
+
});
|
|
105
|
+
expect(result.success).toBe(false);
|
|
106
|
+
expect(result.error).toContain("not registered");
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("appends LIMIT when not present", async () => {
|
|
110
|
+
await executeTool({
|
|
111
|
+
soql: "SELECT Id FROM Account",
|
|
112
|
+
explanation: "test",
|
|
113
|
+
});
|
|
114
|
+
// The mockQuery should have been called with a SOQL that includes LIMIT
|
|
115
|
+
const calledWith = (mockQuery.mock.calls as unknown as string[][])[0][0];
|
|
116
|
+
expect(calledWith).toContain("LIMIT");
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("does not double-append LIMIT", async () => {
|
|
120
|
+
await executeTool({
|
|
121
|
+
soql: "SELECT Id FROM Account LIMIT 5",
|
|
122
|
+
explanation: "test",
|
|
123
|
+
});
|
|
124
|
+
const calledWith = (mockQuery.mock.calls as unknown as string[][])[0][0];
|
|
125
|
+
// Should not have two LIMIT clauses
|
|
126
|
+
const limitCount = (calledWith.match(/LIMIT/gi) ?? []).length;
|
|
127
|
+
expect(limitCount).toBe(1);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("scrubs sensitive error messages", async () => {
|
|
131
|
+
mockQuery.mockImplementationOnce(() =>
|
|
132
|
+
Promise.reject(new Error("INVALID_SESSION_ID: Session expired")),
|
|
133
|
+
);
|
|
134
|
+
const result = await executeTool({
|
|
135
|
+
soql: "SELECT Id FROM Account",
|
|
136
|
+
explanation: "test",
|
|
137
|
+
});
|
|
138
|
+
expect(result.success).toBe(false);
|
|
139
|
+
expect(result.error).toContain("check server logs");
|
|
140
|
+
expect(result.error).not.toContain("INVALID_SESSION_ID");
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it("surfaces non-sensitive errors to the agent", async () => {
|
|
144
|
+
mockQuery.mockImplementationOnce(() =>
|
|
145
|
+
Promise.reject(new Error("INVALID_FIELD: No such column 'Foo'")),
|
|
146
|
+
);
|
|
147
|
+
const result = await executeTool({
|
|
148
|
+
soql: "SELECT Foo FROM Account",
|
|
149
|
+
explanation: "test",
|
|
150
|
+
});
|
|
151
|
+
expect(result.success).toBe(false);
|
|
152
|
+
expect(result.error).toContain("INVALID_FIELD");
|
|
153
|
+
});
|
|
154
|
+
});
|