@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,375 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Component, type ReactNode, type ErrorInfo, useMemo, useState } from "react";
|
|
4
|
+
import {
|
|
5
|
+
ResponsiveContainer,
|
|
6
|
+
BarChart,
|
|
7
|
+
Bar,
|
|
8
|
+
LineChart,
|
|
9
|
+
Line,
|
|
10
|
+
PieChart,
|
|
11
|
+
Pie,
|
|
12
|
+
Cell,
|
|
13
|
+
CartesianGrid,
|
|
14
|
+
XAxis,
|
|
15
|
+
YAxis,
|
|
16
|
+
Tooltip,
|
|
17
|
+
Legend,
|
|
18
|
+
} from "recharts";
|
|
19
|
+
import {
|
|
20
|
+
detectCharts,
|
|
21
|
+
transformData,
|
|
22
|
+
CHART_COLORS_LIGHT,
|
|
23
|
+
CHART_COLORS_DARK,
|
|
24
|
+
type ChartRecommendation,
|
|
25
|
+
type ChartType,
|
|
26
|
+
type RechartsRow,
|
|
27
|
+
type ChartDetectionResult,
|
|
28
|
+
} from "./chart-detection";
|
|
29
|
+
|
|
30
|
+
/* ------------------------------------------------------------------ */
|
|
31
|
+
/* Error boundary */
|
|
32
|
+
/* ------------------------------------------------------------------ */
|
|
33
|
+
|
|
34
|
+
class ChartErrorBoundary extends Component<
|
|
35
|
+
{ children: ReactNode; fallback?: ReactNode },
|
|
36
|
+
{ hasError: boolean }
|
|
37
|
+
> {
|
|
38
|
+
constructor(props: { children: ReactNode; fallback?: ReactNode }) {
|
|
39
|
+
super(props);
|
|
40
|
+
this.state = { hasError: false };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static getDerivedStateFromError(): { hasError: boolean } {
|
|
44
|
+
return { hasError: true };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
componentDidCatch(error: Error, info: ErrorInfo) {
|
|
48
|
+
console.error("Chart rendering failed:", error, info.componentStack);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
render() {
|
|
52
|
+
if (this.state.hasError) {
|
|
53
|
+
return this.props.fallback ?? (
|
|
54
|
+
<div className="rounded-lg border border-yellow-300 bg-yellow-50 px-3 py-2 text-xs text-yellow-700 dark:border-yellow-900/50 dark:bg-yellow-950/20 dark:text-yellow-400">
|
|
55
|
+
Chart could not be rendered. Switch to Table view to see your data.
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
return this.props.children;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* ------------------------------------------------------------------ */
|
|
64
|
+
/* Theme helpers */
|
|
65
|
+
/* ------------------------------------------------------------------ */
|
|
66
|
+
|
|
67
|
+
function getColors(dark: boolean) {
|
|
68
|
+
return dark ? CHART_COLORS_DARK : CHART_COLORS_LIGHT;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function themeTokens(dark: boolean) {
|
|
72
|
+
return {
|
|
73
|
+
grid: dark ? "#3f3f46" : "#e4e4e7",
|
|
74
|
+
axis: dark ? "#a1a1aa" : "#71717a",
|
|
75
|
+
tooltipBg: dark ? "#18181b" : "#ffffff",
|
|
76
|
+
tooltipBorder: dark ? "#3f3f46" : "#e4e4e7",
|
|
77
|
+
tooltipText: dark ? "#e4e4e7" : "#27272a",
|
|
78
|
+
legendText: dark ? "#a1a1aa" : "#71717a",
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* ------------------------------------------------------------------ */
|
|
83
|
+
/* Number formatter for axis / tooltip */
|
|
84
|
+
/* ------------------------------------------------------------------ */
|
|
85
|
+
|
|
86
|
+
function formatNumber(value: unknown): string {
|
|
87
|
+
const num = Number(value);
|
|
88
|
+
if (!isFinite(num)) return String(value ?? "");
|
|
89
|
+
if (Math.abs(num) >= 1_000_000) return `${(num / 1_000_000).toFixed(1)}M`;
|
|
90
|
+
if (Math.abs(num) >= 1_000) return `${(num / 1_000).toFixed(1)}K`;
|
|
91
|
+
return Number.isInteger(num) ? num.toLocaleString() : num.toFixed(2);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function truncateLabel(label: unknown, maxLen = 12): string {
|
|
95
|
+
const str = String(label ?? "");
|
|
96
|
+
return str.length > maxLen ? str.slice(0, maxLen) + "\u2026" : str;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/* ------------------------------------------------------------------ */
|
|
100
|
+
/* Tooltip */
|
|
101
|
+
/* ------------------------------------------------------------------ */
|
|
102
|
+
|
|
103
|
+
function ChartTooltip({ active, payload, label, dark }: {
|
|
104
|
+
active?: boolean;
|
|
105
|
+
payload?: Array<{ name: string; value: number; color: string }>;
|
|
106
|
+
label?: string;
|
|
107
|
+
dark: boolean;
|
|
108
|
+
}) {
|
|
109
|
+
if (!active || !payload?.length) return null;
|
|
110
|
+
const t = themeTokens(dark);
|
|
111
|
+
return (
|
|
112
|
+
<div
|
|
113
|
+
style={{
|
|
114
|
+
background: t.tooltipBg,
|
|
115
|
+
border: `1px solid ${t.tooltipBorder}`,
|
|
116
|
+
borderRadius: 6,
|
|
117
|
+
padding: "8px 12px",
|
|
118
|
+
fontSize: 12,
|
|
119
|
+
color: t.tooltipText,
|
|
120
|
+
}}
|
|
121
|
+
>
|
|
122
|
+
<p style={{ fontWeight: 600, marginBottom: 4 }}>{label}</p>
|
|
123
|
+
{payload.map((entry, i) => (
|
|
124
|
+
<p key={i} style={{ color: entry.color }}>
|
|
125
|
+
{entry.name}: {typeof entry.value === "number" ? formatNumber(entry.value) : entry.value}
|
|
126
|
+
</p>
|
|
127
|
+
))}
|
|
128
|
+
</div>
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/* ------------------------------------------------------------------ */
|
|
133
|
+
/* Sub-chart components */
|
|
134
|
+
/* ------------------------------------------------------------------ */
|
|
135
|
+
|
|
136
|
+
function BarChartView({
|
|
137
|
+
data,
|
|
138
|
+
rec,
|
|
139
|
+
dark,
|
|
140
|
+
}: {
|
|
141
|
+
data: RechartsRow[];
|
|
142
|
+
rec: ChartRecommendation;
|
|
143
|
+
dark: boolean;
|
|
144
|
+
}) {
|
|
145
|
+
const colors = getColors(dark);
|
|
146
|
+
const t = themeTokens(dark);
|
|
147
|
+
const catKey = rec.categoryColumn.header;
|
|
148
|
+
const valKeys = rec.valueColumns.map((c) => c.header);
|
|
149
|
+
|
|
150
|
+
return (
|
|
151
|
+
<ResponsiveContainer width="100%" height={300}>
|
|
152
|
+
<BarChart data={data} margin={{ top: 8, right: 8, bottom: 40, left: 8 }}>
|
|
153
|
+
<CartesianGrid strokeDasharray="3 3" stroke={t.grid} />
|
|
154
|
+
<XAxis
|
|
155
|
+
dataKey={catKey}
|
|
156
|
+
tick={{ fill: t.axis, fontSize: 11 }}
|
|
157
|
+
tickFormatter={(v: string) => truncateLabel(v)}
|
|
158
|
+
angle={-45}
|
|
159
|
+
textAnchor="end"
|
|
160
|
+
height={60}
|
|
161
|
+
/>
|
|
162
|
+
<YAxis tick={{ fill: t.axis, fontSize: 11 }} tickFormatter={formatNumber} />
|
|
163
|
+
<Tooltip content={<ChartTooltip dark={dark} />} />
|
|
164
|
+
{valKeys.length > 1 && (
|
|
165
|
+
<Legend wrapperStyle={{ fontSize: 12, color: t.legendText }} />
|
|
166
|
+
)}
|
|
167
|
+
{valKeys.map((key, i) => (
|
|
168
|
+
<Bar
|
|
169
|
+
key={key}
|
|
170
|
+
dataKey={key}
|
|
171
|
+
fill={colors[i % colors.length]}
|
|
172
|
+
radius={[4, 4, 0, 0]}
|
|
173
|
+
/>
|
|
174
|
+
))}
|
|
175
|
+
</BarChart>
|
|
176
|
+
</ResponsiveContainer>
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function LineChartView({
|
|
181
|
+
data,
|
|
182
|
+
rec,
|
|
183
|
+
dark,
|
|
184
|
+
}: {
|
|
185
|
+
data: RechartsRow[];
|
|
186
|
+
rec: ChartRecommendation;
|
|
187
|
+
dark: boolean;
|
|
188
|
+
}) {
|
|
189
|
+
const colors = getColors(dark);
|
|
190
|
+
const t = themeTokens(dark);
|
|
191
|
+
const catKey = rec.categoryColumn.header;
|
|
192
|
+
const valKeys = rec.valueColumns.map((c) => c.header);
|
|
193
|
+
|
|
194
|
+
return (
|
|
195
|
+
<ResponsiveContainer width="100%" height={300}>
|
|
196
|
+
<LineChart data={data} margin={{ top: 8, right: 8, bottom: 40, left: 8 }}>
|
|
197
|
+
<CartesianGrid strokeDasharray="3 3" stroke={t.grid} />
|
|
198
|
+
<XAxis
|
|
199
|
+
dataKey={catKey}
|
|
200
|
+
tick={{ fill: t.axis, fontSize: 11 }}
|
|
201
|
+
tickFormatter={(v: string) => truncateLabel(v)}
|
|
202
|
+
angle={-45}
|
|
203
|
+
textAnchor="end"
|
|
204
|
+
height={60}
|
|
205
|
+
/>
|
|
206
|
+
<YAxis tick={{ fill: t.axis, fontSize: 11 }} tickFormatter={formatNumber} />
|
|
207
|
+
<Tooltip content={<ChartTooltip dark={dark} />} />
|
|
208
|
+
{valKeys.length > 1 && (
|
|
209
|
+
<Legend wrapperStyle={{ fontSize: 12, color: t.legendText }} />
|
|
210
|
+
)}
|
|
211
|
+
{valKeys.map((key, i) => (
|
|
212
|
+
<Line
|
|
213
|
+
key={key}
|
|
214
|
+
type="monotone"
|
|
215
|
+
dataKey={key}
|
|
216
|
+
stroke={colors[i % colors.length]}
|
|
217
|
+
strokeWidth={2}
|
|
218
|
+
dot={{ r: 3, fill: colors[i % colors.length] }}
|
|
219
|
+
activeDot={{ r: 5 }}
|
|
220
|
+
/>
|
|
221
|
+
))}
|
|
222
|
+
</LineChart>
|
|
223
|
+
</ResponsiveContainer>
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function PieChartView({
|
|
228
|
+
data,
|
|
229
|
+
rec,
|
|
230
|
+
dark,
|
|
231
|
+
}: {
|
|
232
|
+
data: RechartsRow[];
|
|
233
|
+
rec: ChartRecommendation;
|
|
234
|
+
dark: boolean;
|
|
235
|
+
}) {
|
|
236
|
+
const colors = getColors(dark);
|
|
237
|
+
const t = themeTokens(dark);
|
|
238
|
+
const catKey = rec.categoryColumn.header;
|
|
239
|
+
const valKey = rec.valueColumns[0].header;
|
|
240
|
+
|
|
241
|
+
const total = data.reduce((sum, d) => sum + (typeof d[valKey] === "number" ? (d[valKey] as number) : 0), 0);
|
|
242
|
+
|
|
243
|
+
const hasNegative = data.some(d => typeof d[valKey] === "number" && (d[valKey] as number) < 0);
|
|
244
|
+
if (total <= 0 || hasNegative) {
|
|
245
|
+
return (
|
|
246
|
+
<div className="flex h-[300px] items-center justify-center text-xs text-zinc-400">
|
|
247
|
+
Pie chart is not suitable for this data.
|
|
248
|
+
</div>
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return (
|
|
253
|
+
<ResponsiveContainer width="100%" height={300}>
|
|
254
|
+
<PieChart>
|
|
255
|
+
<Pie
|
|
256
|
+
data={data}
|
|
257
|
+
dataKey={valKey}
|
|
258
|
+
nameKey={catKey}
|
|
259
|
+
cx="50%"
|
|
260
|
+
cy="50%"
|
|
261
|
+
innerRadius={40}
|
|
262
|
+
outerRadius={100}
|
|
263
|
+
label={({ name, value }: { name?: string; value?: number }) =>
|
|
264
|
+
`${truncateLabel(String(name ?? ""), 10)} ${total > 0 && value != null ? ((value / total) * 100).toFixed(0) : 0}%`
|
|
265
|
+
}
|
|
266
|
+
labelLine={{ stroke: t.axis }}
|
|
267
|
+
fontSize={11}
|
|
268
|
+
>
|
|
269
|
+
{data.map((_, i) => (
|
|
270
|
+
<Cell key={i} fill={colors[i % colors.length]} />
|
|
271
|
+
))}
|
|
272
|
+
</Pie>
|
|
273
|
+
<Tooltip content={<ChartTooltip dark={dark} />} />
|
|
274
|
+
</PieChart>
|
|
275
|
+
</ResponsiveContainer>
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/* ------------------------------------------------------------------ */
|
|
280
|
+
/* Chart type selector */
|
|
281
|
+
/* ------------------------------------------------------------------ */
|
|
282
|
+
|
|
283
|
+
const CHART_LABELS: Record<ChartType, string> = { bar: "Bar", line: "Line", pie: "Pie" };
|
|
284
|
+
|
|
285
|
+
function ChartTypeSelector({
|
|
286
|
+
recommendations,
|
|
287
|
+
active,
|
|
288
|
+
onChange,
|
|
289
|
+
}: {
|
|
290
|
+
recommendations: ChartRecommendation[];
|
|
291
|
+
active: ChartType;
|
|
292
|
+
onChange: (t: ChartType) => void;
|
|
293
|
+
}) {
|
|
294
|
+
if (recommendations.length <= 1) return null;
|
|
295
|
+
|
|
296
|
+
const seen = new Set<ChartType>();
|
|
297
|
+
const unique = recommendations.filter((r) => {
|
|
298
|
+
if (seen.has(r.type)) return false;
|
|
299
|
+
seen.add(r.type);
|
|
300
|
+
return true;
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
if (unique.length <= 1) return null;
|
|
304
|
+
|
|
305
|
+
return (
|
|
306
|
+
<div className="flex gap-1">
|
|
307
|
+
{unique.map((rec) => (
|
|
308
|
+
<button
|
|
309
|
+
key={rec.type}
|
|
310
|
+
onClick={() => onChange(rec.type)}
|
|
311
|
+
className={`rounded px-2 py-0.5 text-xs font-medium transition-colors ${
|
|
312
|
+
active === rec.type
|
|
313
|
+
? "bg-blue-100 text-blue-700 dark:bg-blue-600/20 dark:text-blue-400"
|
|
314
|
+
: "text-zinc-500 hover:text-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200"
|
|
315
|
+
}`}
|
|
316
|
+
>
|
|
317
|
+
{CHART_LABELS[rec.type]}
|
|
318
|
+
</button>
|
|
319
|
+
))}
|
|
320
|
+
</div>
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/* ------------------------------------------------------------------ */
|
|
325
|
+
/* Main ResultChart component */
|
|
326
|
+
/* ------------------------------------------------------------------ */
|
|
327
|
+
|
|
328
|
+
export function ResultChart({
|
|
329
|
+
headers,
|
|
330
|
+
rows,
|
|
331
|
+
dark,
|
|
332
|
+
detectionResult,
|
|
333
|
+
}: {
|
|
334
|
+
headers: string[];
|
|
335
|
+
rows: string[][];
|
|
336
|
+
dark: boolean;
|
|
337
|
+
detectionResult?: ChartDetectionResult;
|
|
338
|
+
}) {
|
|
339
|
+
const result = useMemo(
|
|
340
|
+
() => detectionResult ?? detectCharts(headers, rows),
|
|
341
|
+
[headers, rows, detectionResult],
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
const [activeType, setActiveType] = useState<ChartType | null>(null);
|
|
345
|
+
|
|
346
|
+
if (!result.chartable) return null;
|
|
347
|
+
|
|
348
|
+
const currentType = activeType ?? result.recommendations[0].type;
|
|
349
|
+
const currentRec = result.recommendations.find((r) => r.type === currentType) ?? result.recommendations[0];
|
|
350
|
+
|
|
351
|
+
// Re-transform data when switching chart type (category axis may differ)
|
|
352
|
+
const chartData = currentRec === result.recommendations[0]
|
|
353
|
+
? result.data
|
|
354
|
+
: transformData(rows, currentRec);
|
|
355
|
+
|
|
356
|
+
return (
|
|
357
|
+
<div className="overflow-hidden rounded-lg border border-zinc-200 dark:border-zinc-700">
|
|
358
|
+
<div className="flex items-center justify-between border-b border-zinc-100 bg-zinc-50/50 px-3 py-2 dark:border-zinc-800 dark:bg-zinc-900/50">
|
|
359
|
+
<span className="text-xs text-zinc-500 dark:text-zinc-400">{currentRec.reason}</span>
|
|
360
|
+
<ChartTypeSelector
|
|
361
|
+
recommendations={result.recommendations}
|
|
362
|
+
active={currentType}
|
|
363
|
+
onChange={setActiveType}
|
|
364
|
+
/>
|
|
365
|
+
</div>
|
|
366
|
+
<ChartErrorBoundary key={currentType}>
|
|
367
|
+
<div className="p-2">
|
|
368
|
+
{currentType === "bar" && <BarChartView data={chartData} rec={currentRec} dark={dark} />}
|
|
369
|
+
{currentType === "line" && <LineChartView data={chartData} rec={currentRec} dark={dark} />}
|
|
370
|
+
{currentType === "pie" && <PieChartView data={chartData} rec={currentRec} dark={dark} />}
|
|
371
|
+
</div>
|
|
372
|
+
</ChartErrorBoundary>
|
|
373
|
+
</div>
|
|
374
|
+
);
|
|
375
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
|
|
5
|
+
export function ApiKeyBar({
|
|
6
|
+
apiKey,
|
|
7
|
+
onSave,
|
|
8
|
+
}: {
|
|
9
|
+
apiKey: string;
|
|
10
|
+
onSave: (key: string) => void;
|
|
11
|
+
}) {
|
|
12
|
+
const [editing, setEditing] = useState(!apiKey);
|
|
13
|
+
const [draft, setDraft] = useState(apiKey);
|
|
14
|
+
|
|
15
|
+
if (!editing && apiKey) {
|
|
16
|
+
return (
|
|
17
|
+
<div className="flex items-center gap-2 rounded-lg border border-zinc-200 bg-zinc-50 px-3 py-2 text-xs dark:border-zinc-700 dark:bg-zinc-900">
|
|
18
|
+
<span className="text-zinc-500 dark:text-zinc-400">API key configured</span>
|
|
19
|
+
<button
|
|
20
|
+
onClick={() => { setDraft(apiKey); setEditing(true); }}
|
|
21
|
+
className="rounded border border-zinc-200 px-2 py-0.5 text-zinc-500 transition-colors hover:border-zinc-400 hover:text-zinc-800 dark:border-zinc-700 dark:text-zinc-400 dark:hover:border-zinc-500 dark:hover:text-zinc-200"
|
|
22
|
+
>
|
|
23
|
+
Change
|
|
24
|
+
</button>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<form
|
|
31
|
+
onSubmit={(e) => {
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
if (draft.trim()) {
|
|
34
|
+
onSave(draft.trim());
|
|
35
|
+
setEditing(false);
|
|
36
|
+
}
|
|
37
|
+
}}
|
|
38
|
+
className="flex items-center gap-2 rounded-lg border border-zinc-200 bg-zinc-50 px-3 py-2 dark:border-zinc-700 dark:bg-zinc-900"
|
|
39
|
+
>
|
|
40
|
+
<input
|
|
41
|
+
type="password"
|
|
42
|
+
value={draft}
|
|
43
|
+
onChange={(e) => setDraft(e.target.value)}
|
|
44
|
+
placeholder="Enter your API key..."
|
|
45
|
+
className="flex-1 bg-transparent text-xs text-zinc-900 placeholder-zinc-400 outline-none dark:text-zinc-100 dark:placeholder-zinc-600"
|
|
46
|
+
autoFocus
|
|
47
|
+
/>
|
|
48
|
+
<button
|
|
49
|
+
type="submit"
|
|
50
|
+
disabled={!draft.trim()}
|
|
51
|
+
className="rounded border border-zinc-200 px-2 py-0.5 text-xs text-zinc-500 transition-colors hover:border-zinc-400 hover:text-zinc-800 disabled:opacity-40 dark:border-zinc-700 dark:text-zinc-400 dark:hover:border-zinc-500 dark:hover:text-zinc-200"
|
|
52
|
+
>
|
|
53
|
+
Save
|
|
54
|
+
</button>
|
|
55
|
+
{apiKey && (
|
|
56
|
+
<button
|
|
57
|
+
type="button"
|
|
58
|
+
onClick={() => setEditing(false)}
|
|
59
|
+
className="text-xs text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300"
|
|
60
|
+
>
|
|
61
|
+
Cancel
|
|
62
|
+
</button>
|
|
63
|
+
)}
|
|
64
|
+
</form>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
|
|
5
|
+
export function CopyButton({ text, label = "Copy" }: { text: string; label?: string }) {
|
|
6
|
+
const [state, setState] = useState<"idle" | "copied" | "failed">("idle");
|
|
7
|
+
return (
|
|
8
|
+
<button
|
|
9
|
+
onClick={async () => {
|
|
10
|
+
try {
|
|
11
|
+
await navigator.clipboard.writeText(text);
|
|
12
|
+
setState("copied");
|
|
13
|
+
setTimeout(() => setState("idle"), 2000);
|
|
14
|
+
} catch (err) {
|
|
15
|
+
console.warn("Clipboard write failed:", err);
|
|
16
|
+
setState("failed");
|
|
17
|
+
setTimeout(() => setState("idle"), 2000);
|
|
18
|
+
}
|
|
19
|
+
}}
|
|
20
|
+
className="rounded border border-zinc-200 px-2 py-1 text-xs text-zinc-500 transition-colors hover:border-zinc-400 hover:text-zinc-800 dark:border-zinc-700 dark:text-zinc-400 dark:hover:border-zinc-500 dark:hover:text-zinc-200"
|
|
21
|
+
>
|
|
22
|
+
{state === "copied" ? "Copied!" : state === "failed" ? "Failed" : label}
|
|
23
|
+
</button>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { formatCell } from "../../lib/helpers";
|
|
5
|
+
|
|
6
|
+
export function DataTable({
|
|
7
|
+
columns,
|
|
8
|
+
rows,
|
|
9
|
+
maxRows = 10,
|
|
10
|
+
}: {
|
|
11
|
+
columns: string[];
|
|
12
|
+
rows: (Record<string, unknown> | unknown[])[];
|
|
13
|
+
maxRows?: number;
|
|
14
|
+
}) {
|
|
15
|
+
const [sortCol, setSortCol] = useState<number | null>(null);
|
|
16
|
+
const [sortDir, setSortDir] = useState<"asc" | "desc">("asc");
|
|
17
|
+
|
|
18
|
+
const hasMore = rows.length > maxRows;
|
|
19
|
+
|
|
20
|
+
const cell = (row: Record<string, unknown> | unknown[], colIdx: number): unknown => {
|
|
21
|
+
if (Array.isArray(row)) return row[colIdx];
|
|
22
|
+
return (row as Record<string, unknown>)[columns[colIdx]];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const handleSort = (colIdx: number) => {
|
|
26
|
+
if (sortCol === colIdx) {
|
|
27
|
+
if (sortDir === "asc") {
|
|
28
|
+
setSortDir("desc");
|
|
29
|
+
} else {
|
|
30
|
+
setSortCol(null);
|
|
31
|
+
setSortDir("asc");
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
setSortCol(colIdx);
|
|
35
|
+
setSortDir("asc");
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const sorted = sortCol !== null
|
|
40
|
+
? [...rows].sort((a, b) => {
|
|
41
|
+
const av = cell(a, sortCol);
|
|
42
|
+
const bv = cell(b, sortCol);
|
|
43
|
+
if (av == null && bv == null) return 0;
|
|
44
|
+
if (av == null) return 1;
|
|
45
|
+
if (bv == null) return -1;
|
|
46
|
+
const aStr = String(av).trim();
|
|
47
|
+
const bStr = String(bv).trim();
|
|
48
|
+
if (aStr === "" && bStr === "") return 0;
|
|
49
|
+
if (aStr === "") return 1;
|
|
50
|
+
if (bStr === "") return -1;
|
|
51
|
+
const an = Number(aStr), bn = Number(bStr);
|
|
52
|
+
if (!isNaN(an) && !isNaN(bn)) {
|
|
53
|
+
return sortDir === "asc" ? an - bn : bn - an;
|
|
54
|
+
}
|
|
55
|
+
const cmp = aStr.localeCompare(bStr);
|
|
56
|
+
return sortDir === "asc" ? cmp : -cmp;
|
|
57
|
+
})
|
|
58
|
+
: rows;
|
|
59
|
+
const display = sorted.slice(0, maxRows);
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<div className="overflow-x-auto rounded-lg border border-zinc-200 dark:border-zinc-700">
|
|
63
|
+
<table className="min-w-full text-xs">
|
|
64
|
+
<thead>
|
|
65
|
+
<tr className="border-b border-zinc-200 bg-zinc-100/80 dark:border-zinc-700 dark:bg-zinc-800/80">
|
|
66
|
+
{columns.map((col, i) => (
|
|
67
|
+
<th
|
|
68
|
+
key={i}
|
|
69
|
+
onClick={() => handleSort(i)}
|
|
70
|
+
className="group cursor-pointer select-none whitespace-nowrap px-3 py-2 text-left font-medium text-zinc-500 transition-colors hover:text-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200"
|
|
71
|
+
>
|
|
72
|
+
{col}
|
|
73
|
+
{sortCol === i
|
|
74
|
+
? sortDir === "asc" ? " \u25B2" : " \u25BC"
|
|
75
|
+
: ""}
|
|
76
|
+
</th>
|
|
77
|
+
))}
|
|
78
|
+
</tr>
|
|
79
|
+
</thead>
|
|
80
|
+
<tbody>
|
|
81
|
+
{display.map((row, i) => (
|
|
82
|
+
<tr
|
|
83
|
+
key={i}
|
|
84
|
+
className={i % 2 === 0 ? "bg-zinc-100/60 dark:bg-zinc-900/60" : "bg-zinc-50/30 dark:bg-zinc-900/30"}
|
|
85
|
+
>
|
|
86
|
+
{columns.map((_, j) => (
|
|
87
|
+
<td key={j} className="whitespace-nowrap px-3 py-1.5 text-zinc-700 dark:text-zinc-300">
|
|
88
|
+
{formatCell(cell(row, j))}
|
|
89
|
+
</td>
|
|
90
|
+
))}
|
|
91
|
+
</tr>
|
|
92
|
+
))}
|
|
93
|
+
</tbody>
|
|
94
|
+
</table>
|
|
95
|
+
{hasMore && (
|
|
96
|
+
<div className="border-t border-zinc-200 px-3 py-1.5 text-xs text-zinc-500 dark:border-zinc-700">
|
|
97
|
+
Showing {maxRows} of {rows.length} rows
|
|
98
|
+
</div>
|
|
99
|
+
)}
|
|
100
|
+
</div>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState, useEffect, useMemo } from "react";
|
|
4
|
+
import { parseChatError, type AuthMode } from "../../lib/types";
|
|
5
|
+
|
|
6
|
+
export function ErrorBanner({ error, authMode }: { error: Error; authMode: AuthMode }) {
|
|
7
|
+
const info = useMemo(() => parseChatError(error, authMode), [error, authMode]);
|
|
8
|
+
const [countdown, setCountdown] = useState(info.retryAfterSeconds ?? 0);
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (!info.retryAfterSeconds) return;
|
|
12
|
+
setCountdown(info.retryAfterSeconds);
|
|
13
|
+
const interval = setInterval(() => {
|
|
14
|
+
setCountdown((prev) => {
|
|
15
|
+
if (prev <= 1) { clearInterval(interval); return 0; }
|
|
16
|
+
return prev - 1;
|
|
17
|
+
});
|
|
18
|
+
}, 1000);
|
|
19
|
+
return () => clearInterval(interval);
|
|
20
|
+
}, [info.retryAfterSeconds]);
|
|
21
|
+
|
|
22
|
+
const detail = info.retryAfterSeconds && countdown > 0
|
|
23
|
+
? `Try again in ${countdown} second${countdown !== 1 ? "s" : ""}.`
|
|
24
|
+
: info.detail;
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div className="mb-2 rounded-lg border border-red-300 bg-red-50 text-red-700 dark:border-red-900/50 dark:bg-red-950/20 dark:text-red-400 px-4 py-3 text-sm">
|
|
28
|
+
<p className="font-medium">{info.title}</p>
|
|
29
|
+
{detail && <p className="mt-1 text-xs opacity-80">{detail}</p>}
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { getToolArgs, getToolResult, isToolComplete } from "../../lib/helpers";
|
|
5
|
+
|
|
6
|
+
export function ExploreCard({ part }: { part: unknown }) {
|
|
7
|
+
const args = getToolArgs(part);
|
|
8
|
+
const result = getToolResult(part);
|
|
9
|
+
const done = isToolComplete(part);
|
|
10
|
+
const [open, setOpen] = useState(false);
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<div className="my-2 overflow-hidden rounded-lg border border-zinc-200 bg-zinc-50 dark:border-zinc-700 dark:bg-zinc-900">
|
|
14
|
+
<button
|
|
15
|
+
onClick={() => done && setOpen(!open)}
|
|
16
|
+
className="flex w-full items-center gap-2 px-3 py-2 text-left text-xs transition-colors hover:bg-zinc-100/60 dark:hover:bg-zinc-800/60"
|
|
17
|
+
>
|
|
18
|
+
<span className="font-mono text-green-400">$</span>
|
|
19
|
+
<span className="flex-1 truncate font-mono text-zinc-700 dark:text-zinc-300">
|
|
20
|
+
{String(args.command ?? "")}
|
|
21
|
+
</span>
|
|
22
|
+
{done ? (
|
|
23
|
+
<span className="text-zinc-400 dark:text-zinc-600">{open ? "\u25BE" : "\u25B8"}</span>
|
|
24
|
+
) : (
|
|
25
|
+
<span className="animate-pulse text-zinc-500">running...</span>
|
|
26
|
+
)}
|
|
27
|
+
</button>
|
|
28
|
+
{open && done && (
|
|
29
|
+
<div className="border-t border-zinc-100 bg-white px-3 py-2 dark:border-zinc-800 dark:bg-zinc-950">
|
|
30
|
+
<pre className="max-h-60 overflow-auto whitespace-pre-wrap font-mono text-xs leading-relaxed text-zinc-500 dark:text-zinc-400">
|
|
31
|
+
{result != null
|
|
32
|
+
? typeof result === "string"
|
|
33
|
+
? result
|
|
34
|
+
: JSON.stringify(result, null, 2)
|
|
35
|
+
: "(no output received)"}
|
|
36
|
+
</pre>
|
|
37
|
+
</div>
|
|
38
|
+
)}
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
export function LoadingCard({ label }: { label: string }) {
|
|
4
|
+
return (
|
|
5
|
+
<div className="my-2 flex items-center gap-2 rounded-lg border border-zinc-200 bg-zinc-50 px-3 py-2 text-xs text-zinc-500 dark:border-zinc-700 dark:bg-zinc-900">
|
|
6
|
+
<span className="inline-block h-3 w-3 animate-spin rounded-full border-2 border-zinc-300 border-t-zinc-600 dark:border-zinc-600 dark:border-t-zinc-300" />
|
|
7
|
+
{label}
|
|
8
|
+
</div>
|
|
9
|
+
);
|
|
10
|
+
}
|