@useatlas/create 0.0.6 → 0.0.7
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/LICENSE +21 -0
- package/README.md +1 -1
- package/index.ts +253 -36
- package/package.json +4 -4
- package/templates/docker/Dockerfile +1 -1
- package/templates/docker/Dockerfile.sidecar +1 -1
- package/templates/docker/bin/__tests__/duckdb-ingest.test.ts +17 -14
- package/templates/docker/bin/__tests__/failure-threshold.test.ts +148 -0
- package/templates/docker/bin/__tests__/fatal-error-propagation.test.ts +267 -0
- package/templates/docker/bin/__tests__/profiler-heuristics.test.ts +5 -5
- package/templates/docker/bin/__tests__/schema-drift.test.ts +39 -0
- package/templates/docker/bin/atlas.ts +981 -1819
- package/templates/docker/bin/benchmark.ts +14 -16
- package/templates/docker/bin/enrich.ts +7 -2
- package/templates/docker/brand.css +13 -0
- package/templates/docker/data/cybersec-semantic/catalog.yml +222 -0
- package/templates/docker/data/cybersec-semantic/entities/alerts.yml +195 -0
- package/templates/docker/data/cybersec-semantic/entities/assets.yml +191 -0
- package/templates/docker/data/cybersec-semantic/entities/compliance_assessments.yml +170 -0
- package/templates/docker/data/cybersec-semantic/entities/incidents.yml +219 -0
- package/templates/docker/data/cybersec-semantic/entities/organizations.yml +136 -0
- package/templates/docker/data/cybersec-semantic/entities/plans.yml +114 -0
- package/templates/docker/data/cybersec-semantic/entities/remediation_actions.yml +212 -0
- package/templates/docker/data/cybersec-semantic/entities/scan_results.yml +215 -0
- package/templates/docker/data/cybersec-semantic/entities/scans.yml +180 -0
- package/templates/docker/data/cybersec-semantic/entities/subscriptions.yml +184 -0
- package/templates/docker/data/cybersec-semantic/entities/users.yml +140 -0
- package/templates/docker/data/cybersec-semantic/entities/vulnerabilities.yml +154 -0
- package/templates/docker/data/cybersec-semantic/glossary.yml +207 -0
- package/templates/docker/data/cybersec-semantic/metrics/business.yml +148 -0
- package/templates/docker/data/cybersec-semantic/metrics/compliance.yml +138 -0
- package/templates/docker/data/cybersec-semantic/metrics/security.yml +181 -0
- package/templates/docker/data/cybersec.sql +8 -8
- package/templates/docker/data/demo.sql +3 -0
- package/templates/docker/data/ecommerce-semantic/catalog.yml +221 -0
- package/templates/docker/data/ecommerce-semantic/entities/categories.yml +91 -0
- package/templates/docker/data/ecommerce-semantic/entities/customers.yml +133 -0
- package/templates/docker/data/ecommerce-semantic/entities/email_campaigns.yml +119 -0
- package/templates/docker/data/ecommerce-semantic/entities/inventory_levels.yml +153 -0
- package/templates/docker/data/ecommerce-semantic/entities/order_items.yml +159 -0
- package/templates/docker/data/ecommerce-semantic/entities/orders.yml +199 -0
- package/templates/docker/data/ecommerce-semantic/entities/payments.yml +140 -0
- package/templates/docker/data/ecommerce-semantic/entities/product_reviews.yml +155 -0
- package/templates/docker/data/ecommerce-semantic/entities/products.yml +178 -0
- package/templates/docker/data/ecommerce-semantic/entities/promotions.yml +171 -0
- package/templates/docker/data/ecommerce-semantic/entities/returns.yml +144 -0
- package/templates/docker/data/ecommerce-semantic/entities/sellers.yml +124 -0
- package/templates/docker/data/ecommerce-semantic/entities/shipments.yml +159 -0
- package/templates/docker/data/ecommerce-semantic/glossary.yml +193 -0
- package/templates/docker/data/ecommerce-semantic/metrics/customers.yml +116 -0
- package/templates/docker/data/ecommerce-semantic/metrics/operations.yml +131 -0
- package/templates/docker/data/ecommerce-semantic/metrics/revenue.yml +120 -0
- package/templates/docker/docs/deploy.md +2 -1
- package/templates/docker/ee/src/__mocks__/internal.ts +170 -0
- package/templates/docker/ee/src/audit/purge-scheduler.ts +113 -0
- package/templates/docker/ee/src/audit/retention.ts +467 -0
- package/templates/docker/ee/src/auth/ip-allowlist.ts +367 -0
- package/templates/docker/ee/src/auth/roles.ts +562 -0
- package/templates/docker/ee/src/auth/scim.ts +343 -0
- package/templates/docker/ee/src/auth/sso.ts +538 -0
- package/templates/docker/ee/src/backups/engine.ts +355 -0
- package/templates/docker/ee/src/backups/index.ts +26 -0
- package/templates/docker/ee/src/backups/restore.ts +169 -0
- package/templates/docker/ee/src/backups/scheduler.ts +153 -0
- package/templates/docker/ee/src/backups/verify.ts +124 -0
- package/templates/docker/ee/src/branding/white-label.ts +228 -0
- package/templates/docker/ee/src/compliance/masking.ts +477 -0
- package/templates/docker/ee/src/compliance/patterns.ts +16 -0
- package/templates/docker/ee/src/compliance/pii-detection.ts +217 -0
- package/templates/docker/ee/src/compliance/reports.ts +402 -0
- package/templates/docker/ee/src/deploy-mode.ts +37 -0
- package/templates/docker/ee/src/governance/approval.ts +699 -0
- package/templates/docker/ee/src/index.ts +74 -0
- package/templates/docker/ee/src/platform/domains.ts +562 -0
- package/templates/docker/ee/src/platform/model-routing.ts +382 -0
- package/templates/docker/ee/src/platform/residency.ts +265 -0
- package/templates/docker/ee/src/sla/alerting.ts +382 -0
- package/templates/docker/ee/src/sla/index.ts +12 -0
- package/templates/docker/ee/src/sla/metrics.ts +275 -0
- package/templates/docker/ee/src/test-setup.ts +1 -0
- package/templates/docker/next.config.ts +4 -1
- package/templates/docker/package.json +49 -29
- package/templates/docker/sidecar/Dockerfile +1 -1
- package/templates/docker/src/api/index.ts +336 -24
- package/templates/docker/src/api/routes/actions.ts +443 -176
- package/templates/docker/src/api/routes/admin-abuse.ts +219 -0
- package/templates/docker/src/api/routes/admin-approval.ts +418 -0
- package/templates/docker/src/api/routes/admin-audit-retention.ts +405 -0
- package/templates/docker/src/api/routes/admin-auth.ts +122 -0
- package/templates/docker/src/api/routes/admin-branding.ts +252 -0
- package/templates/docker/src/api/routes/admin-compliance.ts +352 -0
- package/templates/docker/src/api/routes/admin-domains.ts +334 -0
- package/templates/docker/src/api/routes/admin-integrations.ts +2667 -0
- package/templates/docker/src/api/routes/admin-ip-allowlist.ts +261 -0
- package/templates/docker/src/api/routes/admin-learned-patterns.ts +525 -0
- package/templates/docker/src/api/routes/admin-model-config.ts +252 -0
- package/templates/docker/src/api/routes/admin-onboarding-emails.ts +145 -0
- package/templates/docker/src/api/routes/admin-orgs.ts +710 -0
- package/templates/docker/src/api/routes/admin-prompts.ts +694 -0
- package/templates/docker/src/api/routes/admin-residency.ts +570 -0
- package/templates/docker/src/api/routes/admin-roles.ts +296 -0
- package/templates/docker/src/api/routes/admin-router.ts +120 -0
- package/templates/docker/src/api/routes/admin-sandbox.ts +417 -0
- package/templates/docker/src/api/routes/admin-scim.ts +262 -0
- package/templates/docker/src/api/routes/admin-sso.ts +545 -0
- package/templates/docker/src/api/routes/admin-suggestions.ts +176 -0
- package/templates/docker/src/api/routes/admin-usage.ts +310 -0
- package/templates/docker/src/api/routes/admin.ts +4156 -898
- package/templates/docker/src/api/routes/auth-preamble.ts +105 -0
- package/templates/docker/src/api/routes/billing.ts +397 -0
- package/templates/docker/src/api/routes/chat.ts +597 -334
- package/templates/docker/src/api/routes/conversations.ts +987 -132
- package/templates/docker/src/api/routes/demo.ts +673 -0
- package/templates/docker/src/api/routes/discord.ts +274 -0
- package/templates/docker/src/api/routes/ee-error-handler.ts +32 -0
- package/templates/docker/src/api/routes/health.ts +129 -14
- package/templates/docker/src/api/routes/middleware.ts +244 -0
- package/templates/docker/src/api/routes/onboarding-emails.ts +134 -0
- package/templates/docker/src/api/routes/onboarding.ts +1109 -0
- package/templates/docker/src/api/routes/openapi.ts +184 -1597
- package/templates/docker/src/api/routes/platform-admin.ts +760 -0
- package/templates/docker/src/api/routes/platform-backups.ts +436 -0
- package/templates/docker/src/api/routes/platform-domains.ts +235 -0
- package/templates/docker/src/api/routes/platform-residency.ts +257 -0
- package/templates/docker/src/api/routes/platform-sla.ts +379 -0
- package/templates/docker/src/api/routes/prompts.ts +221 -0
- package/templates/docker/src/api/routes/public-branding.ts +106 -0
- package/templates/docker/src/api/routes/query.ts +330 -219
- package/templates/docker/src/api/routes/scheduled-tasks.ts +393 -297
- package/templates/docker/src/api/routes/semantic.ts +179 -0
- package/templates/docker/src/api/routes/sessions.ts +210 -0
- package/templates/docker/src/api/routes/shared-domains.ts +98 -0
- package/templates/docker/src/api/routes/shared-schemas.ts +139 -0
- package/templates/docker/src/api/routes/slack.ts +209 -52
- package/templates/docker/src/api/routes/suggestions.ts +233 -0
- package/templates/docker/src/api/routes/tables.ts +67 -0
- package/templates/docker/src/api/routes/teams.ts +222 -0
- package/templates/docker/src/api/routes/validate-sql.ts +188 -0
- package/templates/docker/src/api/routes/validation-hook.ts +62 -0
- package/templates/docker/src/api/routes/widget-loader.ts +356 -0
- package/templates/docker/src/api/routes/widget.ts +428 -0
- package/templates/docker/src/api/routes/wizard.ts +852 -0
- package/templates/docker/src/api/server.ts +187 -69
- package/templates/docker/src/app/error.tsx +5 -2
- package/templates/docker/src/app/globals.css +1 -1
- package/templates/docker/src/app/layout.tsx +7 -2
- package/templates/docker/src/app/page.tsx +39 -5
- package/templates/docker/src/components/data-table/data-table-column-header.tsx +99 -0
- package/templates/docker/src/components/data-table/data-table-date-filter.tsx +225 -0
- package/templates/docker/src/components/data-table/data-table-expandable.tsx +125 -0
- package/templates/docker/src/components/data-table/data-table-faceted-filter.tsx +189 -0
- package/templates/docker/src/components/data-table/data-table-pagination.tsx +112 -0
- package/templates/docker/src/components/data-table/data-table-range-filter.tsx +122 -0
- package/templates/docker/src/components/data-table/data-table-slider-filter.tsx +256 -0
- package/templates/docker/src/components/data-table/data-table-sort-list.tsx +407 -0
- package/templates/docker/src/components/data-table/data-table-toolbar.tsx +149 -0
- package/templates/docker/src/components/data-table/data-table-view-options.tsx +89 -0
- package/templates/docker/src/components/data-table/data-table.tsx +105 -0
- package/templates/docker/src/components/form-dialog.tsx +135 -0
- package/templates/docker/src/components/ui/accordion.tsx +66 -0
- package/templates/docker/src/components/ui/calendar.tsx +220 -0
- package/templates/docker/src/components/ui/checkbox.tsx +32 -0
- package/templates/docker/src/components/ui/faceted.tsx +283 -0
- package/templates/docker/src/components/ui/form.tsx +167 -0
- package/templates/docker/src/components/ui/label.tsx +24 -0
- package/templates/docker/src/components/ui/popover.tsx +89 -0
- package/templates/docker/src/components/ui/progress.tsx +31 -0
- package/templates/docker/src/components/ui/scroll-area.tsx +6 -2
- package/templates/docker/src/components/ui/slider.tsx +63 -0
- package/templates/docker/src/components/ui/sortable.tsx +581 -0
- package/templates/docker/src/components/ui/switch.tsx +35 -0
- package/templates/docker/src/components/ui/textarea.tsx +18 -0
- package/templates/docker/src/config/data-table.ts +82 -0
- package/templates/docker/src/env-check.ts +74 -0
- package/templates/docker/src/hooks/use-callback-ref.ts +27 -0
- package/templates/docker/src/hooks/use-data-table.ts +316 -0
- package/templates/docker/src/hooks/use-debounced-callback.ts +28 -0
- package/templates/docker/src/lib/action-types.ts +7 -41
- package/templates/docker/src/lib/agent-query.ts +4 -2
- package/templates/docker/src/lib/agent.ts +363 -31
- package/templates/docker/src/lib/auth/admin-permissions.ts +38 -0
- package/templates/docker/src/lib/auth/audit.ts +19 -4
- package/templates/docker/src/lib/auth/byot.ts +3 -3
- package/templates/docker/src/lib/auth/client.ts +33 -3
- package/templates/docker/src/lib/auth/detect.ts +29 -8
- package/templates/docker/src/lib/auth/managed.ts +104 -14
- package/templates/docker/src/lib/auth/middleware.ts +53 -6
- package/templates/docker/src/lib/auth/migrate.ts +140 -15
- package/templates/docker/src/lib/auth/oauth-state.ts +123 -0
- package/templates/docker/src/lib/auth/org-permissions.ts +55 -0
- package/templates/docker/src/lib/auth/permissions.ts +26 -19
- package/templates/docker/src/lib/auth/server.ts +355 -9
- package/templates/docker/src/lib/auth/simple-key.ts +3 -3
- package/templates/docker/src/lib/auth/types.ts +15 -21
- package/templates/docker/src/lib/billing/enforcement.ts +368 -0
- package/templates/docker/src/lib/billing/plans.ts +155 -0
- package/templates/docker/src/lib/cache/index.ts +92 -0
- package/templates/docker/src/lib/cache/keys.ts +30 -0
- package/templates/docker/src/lib/cache/lru.ts +79 -0
- package/templates/docker/src/lib/cache/types.ts +31 -0
- package/templates/docker/src/lib/compose-refs.ts +62 -0
- package/templates/docker/src/lib/config.ts +563 -11
- package/templates/docker/src/lib/connection-types.ts +9 -0
- package/templates/docker/src/lib/conversation-types.ts +1 -25
- package/templates/docker/src/lib/conversations.ts +345 -14
- package/templates/docker/src/lib/data-table.ts +61 -0
- package/templates/docker/src/lib/db/connection.ts +793 -39
- package/templates/docker/src/lib/db/internal.ts +985 -139
- package/templates/docker/src/lib/db/migrate.ts +295 -0
- package/templates/docker/src/lib/db/migrations/0000_baseline.sql +703 -0
- package/templates/docker/src/lib/db/migrations/0001_teams_installations.sql +14 -0
- package/templates/docker/src/lib/db/migrations/0002_discord_installations.sql +14 -0
- package/templates/docker/src/lib/db/migrations/0003_telegram_installations.sql +15 -0
- package/templates/docker/src/lib/db/migrations/0004_sandbox_credentials.sql +18 -0
- package/templates/docker/src/lib/db/migrations/0005_oauth_state.sql +16 -0
- package/templates/docker/src/lib/db/migrations/0006_byot_credentials.sql +14 -0
- package/templates/docker/src/lib/db/migrations/0007_gchat_installations.sql +15 -0
- package/templates/docker/src/lib/db/migrations/0008_github_installations.sql +14 -0
- package/templates/docker/src/lib/db/migrations/0009_linear_installations.sql +15 -0
- package/templates/docker/src/lib/db/migrations/0010_whatsapp_installations.sql +14 -0
- package/templates/docker/src/lib/db/migrations/0011_email_installations.sql +16 -0
- package/templates/docker/src/lib/db/migrations/0012_region_migrations.sql +25 -0
- package/templates/docker/src/lib/db/schema.ts +1120 -0
- package/templates/docker/src/lib/db/source-rate-limit.ts +89 -139
- package/templates/docker/src/lib/demo.ts +308 -0
- package/templates/docker/src/lib/discord/store.ts +225 -0
- package/templates/docker/src/lib/effect/ai.ts +243 -0
- package/templates/docker/src/lib/effect/errors.ts +234 -0
- package/templates/docker/src/lib/effect/hono.ts +454 -0
- package/templates/docker/src/lib/effect/index.ts +137 -0
- package/templates/docker/src/lib/effect/layers.ts +496 -0
- package/templates/docker/src/lib/effect/services.ts +776 -0
- package/templates/docker/src/lib/effect/sql.ts +178 -0
- package/templates/docker/src/lib/effect/toolkit.ts +123 -0
- package/templates/docker/src/lib/email/delivery.ts +232 -0
- package/templates/docker/src/lib/email/engine.ts +349 -0
- package/templates/docker/src/lib/email/hooks.ts +107 -0
- package/templates/docker/src/lib/email/index.ts +16 -0
- package/templates/docker/src/lib/email/scheduler.ts +72 -0
- package/templates/docker/src/lib/email/sequence.ts +73 -0
- package/templates/docker/src/lib/email/store.ts +163 -0
- package/templates/docker/src/lib/email/templates.ts +215 -0
- package/templates/docker/src/lib/format.ts +67 -0
- package/templates/docker/src/lib/gchat/store.ts +202 -0
- package/templates/docker/src/lib/github/store.ts +197 -0
- package/templates/docker/src/lib/id.ts +29 -0
- package/templates/docker/src/lib/integrations/types.ts +166 -0
- package/templates/docker/src/lib/learn/pattern-analyzer.ts +224 -0
- package/templates/docker/src/lib/learn/pattern-cache.ts +229 -0
- package/templates/docker/src/lib/learn/pattern-proposer.ts +87 -0
- package/templates/docker/src/lib/learn/suggestion-helpers.ts +34 -0
- package/templates/docker/src/lib/learn/suggestions.ts +139 -0
- package/templates/docker/src/lib/linear/store.ts +200 -0
- package/templates/docker/src/lib/logger.ts +35 -3
- package/templates/docker/src/lib/metering.ts +272 -0
- package/templates/docker/src/lib/parsers.ts +99 -0
- package/templates/docker/src/lib/plugins/hooks.ts +13 -11
- package/templates/docker/src/lib/plugins/index.ts +3 -1
- package/templates/docker/src/lib/plugins/registry.ts +58 -6
- package/templates/docker/src/lib/plugins/settings.ts +147 -0
- package/templates/docker/src/lib/plugins/wiring.ts +6 -9
- package/templates/docker/src/lib/profiler.ts +1665 -0
- package/templates/docker/src/lib/providers.ts +188 -13
- package/templates/docker/src/lib/rls.ts +172 -60
- package/templates/docker/src/lib/sandbox/credentials.ts +206 -0
- package/templates/docker/src/lib/sandbox/validate.ts +179 -0
- package/templates/docker/src/lib/scheduled-task-types.ts +26 -94
- package/templates/docker/src/lib/scheduled-tasks.ts +174 -34
- package/templates/docker/src/lib/scheduler/delivery.ts +248 -150
- package/templates/docker/src/lib/scheduler/engine.ts +190 -154
- package/templates/docker/src/lib/scheduler/executor.ts +74 -23
- package/templates/docker/src/lib/scheduler/preview.ts +72 -0
- package/templates/docker/src/lib/security/abuse.ts +463 -0
- package/templates/docker/src/lib/semantic/diff.ts +267 -0
- package/templates/docker/src/lib/semantic/entities.ts +167 -0
- package/templates/docker/src/lib/semantic/files.ts +283 -0
- package/templates/docker/src/lib/semantic/index.ts +27 -0
- package/templates/docker/src/lib/{semantic-index.ts → semantic/search.ts} +80 -9
- package/templates/docker/src/lib/semantic/sync.ts +581 -0
- package/templates/docker/src/lib/{semantic.ts → semantic/whitelist.ts} +189 -3
- package/templates/docker/src/lib/settings.ts +817 -0
- package/templates/docker/src/lib/sidecar-types.ts +13 -0
- package/templates/docker/src/lib/slack/store.ts +134 -25
- package/templates/docker/src/lib/startup.ts +528 -362
- package/templates/docker/src/lib/teams/store.ts +216 -0
- package/templates/docker/src/lib/telegram/store.ts +202 -0
- package/templates/docker/src/lib/telemetry.ts +40 -0
- package/templates/docker/src/lib/tools/actions/audit.ts +8 -5
- package/templates/docker/src/lib/tools/actions/email.ts +3 -1
- package/templates/docker/src/lib/tools/actions/handler.ts +276 -93
- package/templates/docker/src/lib/tools/actions/jira.ts +2 -2
- package/templates/docker/src/lib/tools/backends/detect.ts +16 -0
- package/templates/docker/src/lib/tools/backends/index.ts +11 -0
- package/templates/docker/src/lib/tools/backends/nsjail.ts +213 -0
- package/templates/docker/src/lib/tools/backends/shared.ts +103 -0
- package/templates/docker/src/lib/tools/backends/types.ts +26 -0
- package/templates/docker/src/lib/tools/explore-nsjail.ts +7 -228
- package/templates/docker/src/lib/tools/explore-sandbox.ts +4 -29
- package/templates/docker/src/lib/tools/explore-sidecar.ts +18 -2
- package/templates/docker/src/lib/tools/explore.ts +246 -54
- package/templates/docker/src/lib/tools/index.ts +17 -0
- package/templates/docker/src/lib/tools/python-nsjail.ts +11 -139
- package/templates/docker/src/lib/tools/python-sandbox.ts +9 -132
- package/templates/docker/src/lib/tools/python-sidecar.ts +184 -3
- package/templates/docker/src/lib/tools/python-stream.ts +33 -0
- package/templates/docker/src/lib/tools/python-wrapper.ts +129 -0
- package/templates/docker/src/lib/tools/python.ts +115 -15
- package/templates/docker/src/lib/tools/registry.ts +14 -2
- package/templates/docker/src/lib/tools/sql.ts +778 -362
- package/templates/docker/src/lib/tracing.ts +16 -0
- package/templates/docker/src/lib/whatsapp/store.ts +198 -0
- package/templates/docker/src/lib/workspace.ts +89 -0
- package/templates/docker/src/progress.ts +121 -0
- package/templates/docker/src/types/data-table.ts +48 -0
- package/templates/docker/src/ui/atlas-chat-reexport.ts +3 -0
- package/templates/docker/src/ui/components/actions/action-approval-card.tsx +26 -19
- package/templates/docker/src/ui/components/actions/action-status-badge.tsx +3 -3
- package/templates/docker/src/ui/components/admin/admin-layout.tsx +57 -39
- package/templates/docker/src/ui/components/admin/admin-sidebar.tsx +213 -35
- package/templates/docker/src/ui/components/admin/delivery-status-badge.tsx +53 -0
- package/templates/docker/src/ui/components/admin/empty-state.tsx +27 -6
- package/templates/docker/src/ui/components/admin/entity-detail.tsx +3 -52
- package/templates/docker/src/ui/components/admin/error-banner.tsx +2 -2
- package/templates/docker/src/ui/components/admin/feature-disabled.tsx +28 -5
- package/templates/docker/src/ui/components/admin-content-wrapper.tsx +87 -0
- package/templates/docker/src/ui/components/atlas-chat.tsx +449 -166
- package/templates/docker/src/ui/components/branding-head.tsx +41 -0
- package/templates/docker/src/ui/components/chart/chart-detection.ts +62 -5
- package/templates/docker/src/ui/components/chart/result-chart.tsx +316 -125
- package/templates/docker/src/ui/components/chat/api-key-bar.tsx +4 -4
- package/templates/docker/src/ui/components/chat/data-table.tsx +45 -4
- package/templates/docker/src/ui/components/chat/error-banner.tsx +86 -5
- package/templates/docker/src/ui/components/chat/follow-up-chips.tsx +29 -0
- package/templates/docker/src/ui/components/chat/markdown.tsx +24 -0
- package/templates/docker/src/ui/components/chat/prompt-library.tsx +206 -0
- package/templates/docker/src/ui/components/chat/python-result-card.tsx +106 -78
- package/templates/docker/src/ui/components/chat/result-card-base.tsx +101 -0
- package/templates/docker/src/ui/components/chat/share-dialog.tsx +377 -0
- package/templates/docker/src/ui/components/chat/sql-result-card.tsx +94 -73
- package/templates/docker/src/ui/components/chat/suggestion-chips.tsx +46 -0
- package/templates/docker/src/ui/components/chat/tool-part.tsx +16 -4
- package/templates/docker/src/ui/components/conversations/conversation-item.tsx +48 -17
- package/templates/docker/src/ui/components/conversations/conversation-list.tsx +38 -24
- package/templates/docker/src/ui/components/conversations/conversation-sidebar.tsx +66 -7
- package/templates/docker/src/ui/components/conversations/delete-confirmation.tsx +9 -2
- package/templates/docker/src/ui/components/error-boundary.tsx +66 -0
- package/templates/docker/src/ui/components/notebook/delete-cell-dialog.tsx +48 -0
- package/templates/docker/src/ui/components/notebook/fork-branch-selector.tsx +68 -0
- package/templates/docker/src/ui/components/notebook/notebook-cell-input.tsx +76 -0
- package/templates/docker/src/ui/components/notebook/notebook-cell-output.tsx +58 -0
- package/templates/docker/src/ui/components/notebook/notebook-cell-toolbar.tsx +91 -0
- package/templates/docker/src/ui/components/notebook/notebook-cell.tsx +119 -0
- package/templates/docker/src/ui/components/notebook/notebook-empty-state.tsx +19 -0
- package/templates/docker/src/ui/components/notebook/notebook-export.ts +287 -0
- package/templates/docker/src/ui/components/notebook/notebook-input-bar.tsx +49 -0
- package/templates/docker/src/ui/components/notebook/notebook-shell.tsx +266 -0
- package/templates/docker/src/ui/components/notebook/notebook-text-cell.tsx +152 -0
- package/templates/docker/src/ui/components/notebook/types.ts +39 -0
- package/templates/docker/src/ui/components/notebook/use-keyboard-nav.ts +109 -0
- package/templates/docker/src/ui/components/notebook/use-notebook.ts +684 -0
- package/templates/docker/src/ui/components/org-switcher.tsx +111 -0
- package/templates/docker/src/ui/components/region-picker.tsx +103 -0
- package/templates/docker/src/ui/components/schema-explorer/schema-explorer.tsx +522 -0
- package/templates/docker/src/ui/components/social-icons.tsx +26 -0
- package/templates/docker/src/ui/components/tour/guided-tour.tsx +81 -0
- package/templates/docker/src/ui/components/tour/index.ts +5 -0
- package/templates/docker/src/ui/components/tour/nav-bar.tsx +100 -0
- package/templates/docker/src/ui/components/tour/tour-overlay.tsx +298 -0
- package/templates/docker/src/ui/components/tour/tour-steps.ts +43 -0
- package/templates/docker/src/ui/components/tour/types.ts +21 -0
- package/templates/docker/src/ui/components/tour/use-tour.ts +193 -0
- package/templates/docker/src/ui/context-reexport.ts +3 -0
- package/templates/docker/src/ui/hooks/theme-init-script.ts +17 -0
- package/templates/docker/src/ui/hooks/use-admin-fetch.ts +38 -30
- package/templates/docker/src/ui/hooks/use-admin-mutation.ts +188 -0
- package/templates/docker/src/ui/hooks/use-atlas-transport.ts +225 -0
- package/templates/docker/src/ui/hooks/use-branding.ts +68 -0
- package/templates/docker/src/ui/hooks/use-conversations.ts +106 -83
- package/templates/docker/src/ui/hooks/use-dark-mode.ts +134 -10
- package/templates/docker/src/ui/hooks/use-deploy-mode.ts +36 -0
- package/templates/docker/src/ui/hooks/use-platform-admin-guard.ts +49 -0
- package/templates/docker/src/ui/lib/action-types.ts +11 -63
- package/templates/docker/src/ui/lib/admin-schemas.ts +744 -0
- package/templates/docker/src/ui/lib/fetch-client.ts +84 -0
- package/templates/docker/src/ui/lib/fetch-error.ts +54 -0
- package/templates/docker/src/ui/lib/helpers.ts +94 -1
- package/templates/docker/src/ui/lib/types.ts +149 -140
- package/templates/docker/tsconfig.json +4 -2
- package/templates/nextjs-standalone/bin/__tests__/duckdb-ingest.test.ts +17 -14
- package/templates/nextjs-standalone/bin/__tests__/failure-threshold.test.ts +148 -0
- package/templates/nextjs-standalone/bin/__tests__/fatal-error-propagation.test.ts +267 -0
- package/templates/nextjs-standalone/bin/__tests__/profiler-heuristics.test.ts +5 -5
- package/templates/nextjs-standalone/bin/__tests__/schema-drift.test.ts +39 -0
- package/templates/nextjs-standalone/bin/atlas.ts +981 -1819
- package/templates/nextjs-standalone/bin/benchmark.ts +14 -16
- package/templates/nextjs-standalone/bin/enrich.ts +7 -2
- package/templates/nextjs-standalone/brand.css +13 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/catalog.yml +222 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/entities/alerts.yml +195 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/entities/assets.yml +191 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/entities/compliance_assessments.yml +170 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/entities/incidents.yml +219 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/entities/organizations.yml +136 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/entities/plans.yml +114 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/entities/remediation_actions.yml +212 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/entities/scan_results.yml +215 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/entities/scans.yml +180 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/entities/subscriptions.yml +184 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/entities/users.yml +140 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/entities/vulnerabilities.yml +154 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/glossary.yml +207 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/metrics/business.yml +148 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/metrics/compliance.yml +138 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/metrics/security.yml +181 -0
- package/templates/nextjs-standalone/data/cybersec.sql +8 -8
- package/templates/nextjs-standalone/data/demo.sql +3 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/catalog.yml +221 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/categories.yml +91 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/customers.yml +133 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/email_campaigns.yml +119 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/inventory_levels.yml +153 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/order_items.yml +159 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/orders.yml +199 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/payments.yml +140 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/product_reviews.yml +155 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/products.yml +178 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/promotions.yml +171 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/returns.yml +144 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/sellers.yml +124 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/shipments.yml +159 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/glossary.yml +193 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/metrics/customers.yml +116 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/metrics/operations.yml +131 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/metrics/revenue.yml +120 -0
- package/templates/nextjs-standalone/docs/deploy.md +2 -1
- package/templates/nextjs-standalone/ee/src/__mocks__/internal.ts +170 -0
- package/templates/nextjs-standalone/ee/src/audit/purge-scheduler.ts +113 -0
- package/templates/nextjs-standalone/ee/src/audit/retention.ts +467 -0
- package/templates/nextjs-standalone/ee/src/auth/ip-allowlist.ts +367 -0
- package/templates/nextjs-standalone/ee/src/auth/roles.ts +562 -0
- package/templates/nextjs-standalone/ee/src/auth/scim.ts +343 -0
- package/templates/nextjs-standalone/ee/src/auth/sso.ts +538 -0
- package/templates/nextjs-standalone/ee/src/backups/engine.ts +355 -0
- package/templates/nextjs-standalone/ee/src/backups/index.ts +26 -0
- package/templates/nextjs-standalone/ee/src/backups/restore.ts +169 -0
- package/templates/nextjs-standalone/ee/src/backups/scheduler.ts +153 -0
- package/templates/nextjs-standalone/ee/src/backups/verify.ts +124 -0
- package/templates/nextjs-standalone/ee/src/branding/white-label.ts +228 -0
- package/templates/nextjs-standalone/ee/src/compliance/masking.ts +477 -0
- package/templates/nextjs-standalone/ee/src/compliance/patterns.ts +16 -0
- package/templates/nextjs-standalone/ee/src/compliance/pii-detection.ts +217 -0
- package/templates/nextjs-standalone/ee/src/compliance/reports.ts +402 -0
- package/templates/nextjs-standalone/ee/src/deploy-mode.ts +37 -0
- package/templates/nextjs-standalone/ee/src/governance/approval.ts +699 -0
- package/templates/nextjs-standalone/ee/src/index.ts +74 -0
- package/templates/nextjs-standalone/ee/src/platform/domains.ts +562 -0
- package/templates/nextjs-standalone/ee/src/platform/model-routing.ts +382 -0
- package/templates/nextjs-standalone/ee/src/platform/residency.ts +265 -0
- package/templates/nextjs-standalone/ee/src/sla/alerting.ts +382 -0
- package/templates/nextjs-standalone/ee/src/sla/index.ts +12 -0
- package/templates/nextjs-standalone/ee/src/sla/metrics.ts +275 -0
- package/templates/nextjs-standalone/ee/src/test-setup.ts +1 -0
- package/templates/nextjs-standalone/next.config.ts +1 -1
- package/templates/nextjs-standalone/package.json +50 -30
- package/templates/nextjs-standalone/src/api/index.ts +336 -24
- package/templates/nextjs-standalone/src/api/routes/actions.ts +443 -176
- package/templates/nextjs-standalone/src/api/routes/admin-abuse.ts +219 -0
- package/templates/nextjs-standalone/src/api/routes/admin-approval.ts +418 -0
- package/templates/nextjs-standalone/src/api/routes/admin-audit-retention.ts +405 -0
- package/templates/nextjs-standalone/src/api/routes/admin-auth.ts +122 -0
- package/templates/nextjs-standalone/src/api/routes/admin-branding.ts +252 -0
- package/templates/nextjs-standalone/src/api/routes/admin-compliance.ts +352 -0
- package/templates/nextjs-standalone/src/api/routes/admin-domains.ts +334 -0
- package/templates/nextjs-standalone/src/api/routes/admin-integrations.ts +2667 -0
- package/templates/nextjs-standalone/src/api/routes/admin-ip-allowlist.ts +261 -0
- package/templates/nextjs-standalone/src/api/routes/admin-learned-patterns.ts +525 -0
- package/templates/nextjs-standalone/src/api/routes/admin-model-config.ts +252 -0
- package/templates/nextjs-standalone/src/api/routes/admin-onboarding-emails.ts +145 -0
- package/templates/nextjs-standalone/src/api/routes/admin-orgs.ts +710 -0
- package/templates/nextjs-standalone/src/api/routes/admin-prompts.ts +694 -0
- package/templates/nextjs-standalone/src/api/routes/admin-residency.ts +570 -0
- package/templates/nextjs-standalone/src/api/routes/admin-roles.ts +296 -0
- package/templates/nextjs-standalone/src/api/routes/admin-router.ts +120 -0
- package/templates/nextjs-standalone/src/api/routes/admin-sandbox.ts +417 -0
- package/templates/nextjs-standalone/src/api/routes/admin-scim.ts +262 -0
- package/templates/nextjs-standalone/src/api/routes/admin-sso.ts +545 -0
- package/templates/nextjs-standalone/src/api/routes/admin-suggestions.ts +176 -0
- package/templates/nextjs-standalone/src/api/routes/admin-usage.ts +310 -0
- package/templates/nextjs-standalone/src/api/routes/admin.ts +4156 -898
- package/templates/nextjs-standalone/src/api/routes/auth-preamble.ts +105 -0
- package/templates/nextjs-standalone/src/api/routes/billing.ts +397 -0
- package/templates/nextjs-standalone/src/api/routes/chat.ts +597 -334
- package/templates/nextjs-standalone/src/api/routes/conversations.ts +987 -132
- package/templates/nextjs-standalone/src/api/routes/demo.ts +673 -0
- package/templates/nextjs-standalone/src/api/routes/discord.ts +274 -0
- package/templates/nextjs-standalone/src/api/routes/ee-error-handler.ts +32 -0
- package/templates/nextjs-standalone/src/api/routes/health.ts +129 -14
- package/templates/nextjs-standalone/src/api/routes/middleware.ts +244 -0
- package/templates/nextjs-standalone/src/api/routes/onboarding-emails.ts +134 -0
- package/templates/nextjs-standalone/src/api/routes/onboarding.ts +1109 -0
- package/templates/nextjs-standalone/src/api/routes/openapi.ts +184 -1597
- package/templates/nextjs-standalone/src/api/routes/platform-admin.ts +760 -0
- package/templates/nextjs-standalone/src/api/routes/platform-backups.ts +436 -0
- package/templates/nextjs-standalone/src/api/routes/platform-domains.ts +235 -0
- package/templates/nextjs-standalone/src/api/routes/platform-residency.ts +257 -0
- package/templates/nextjs-standalone/src/api/routes/platform-sla.ts +379 -0
- package/templates/nextjs-standalone/src/api/routes/prompts.ts +221 -0
- package/templates/nextjs-standalone/src/api/routes/public-branding.ts +106 -0
- package/templates/nextjs-standalone/src/api/routes/query.ts +330 -219
- package/templates/nextjs-standalone/src/api/routes/scheduled-tasks.ts +393 -297
- package/templates/nextjs-standalone/src/api/routes/semantic.ts +179 -0
- package/templates/nextjs-standalone/src/api/routes/sessions.ts +210 -0
- package/templates/nextjs-standalone/src/api/routes/shared-domains.ts +98 -0
- package/templates/nextjs-standalone/src/api/routes/shared-schemas.ts +139 -0
- package/templates/nextjs-standalone/src/api/routes/slack.ts +209 -52
- package/templates/nextjs-standalone/src/api/routes/suggestions.ts +233 -0
- package/templates/nextjs-standalone/src/api/routes/tables.ts +67 -0
- package/templates/nextjs-standalone/src/api/routes/teams.ts +222 -0
- package/templates/nextjs-standalone/src/api/routes/validate-sql.ts +188 -0
- package/templates/nextjs-standalone/src/api/routes/validation-hook.ts +62 -0
- package/templates/nextjs-standalone/src/api/routes/widget-loader.ts +356 -0
- package/templates/nextjs-standalone/src/api/routes/widget.ts +428 -0
- package/templates/nextjs-standalone/src/api/routes/wizard.ts +852 -0
- package/templates/nextjs-standalone/src/api/server.ts +187 -69
- package/templates/nextjs-standalone/src/app/error.tsx +5 -2
- package/templates/nextjs-standalone/src/app/globals.css +1 -1
- package/templates/nextjs-standalone/src/app/layout.tsx +7 -2
- package/templates/nextjs-standalone/src/app/page.tsx +39 -5
- package/templates/nextjs-standalone/src/components/data-table/data-table-column-header.tsx +99 -0
- package/templates/nextjs-standalone/src/components/data-table/data-table-date-filter.tsx +225 -0
- package/templates/nextjs-standalone/src/components/data-table/data-table-expandable.tsx +125 -0
- package/templates/nextjs-standalone/src/components/data-table/data-table-faceted-filter.tsx +189 -0
- package/templates/nextjs-standalone/src/components/data-table/data-table-pagination.tsx +112 -0
- package/templates/nextjs-standalone/src/components/data-table/data-table-range-filter.tsx +122 -0
- package/templates/nextjs-standalone/src/components/data-table/data-table-slider-filter.tsx +256 -0
- package/templates/nextjs-standalone/src/components/data-table/data-table-sort-list.tsx +407 -0
- package/templates/nextjs-standalone/src/components/data-table/data-table-toolbar.tsx +149 -0
- package/templates/nextjs-standalone/src/components/data-table/data-table-view-options.tsx +89 -0
- package/templates/nextjs-standalone/src/components/data-table/data-table.tsx +105 -0
- package/templates/nextjs-standalone/src/components/form-dialog.tsx +135 -0
- package/templates/nextjs-standalone/src/components/ui/accordion.tsx +66 -0
- package/templates/nextjs-standalone/src/components/ui/calendar.tsx +220 -0
- package/templates/nextjs-standalone/src/components/ui/checkbox.tsx +32 -0
- package/templates/nextjs-standalone/src/components/ui/faceted.tsx +283 -0
- package/templates/nextjs-standalone/src/components/ui/form.tsx +167 -0
- package/templates/nextjs-standalone/src/components/ui/label.tsx +24 -0
- package/templates/nextjs-standalone/src/components/ui/popover.tsx +89 -0
- package/templates/nextjs-standalone/src/components/ui/progress.tsx +31 -0
- package/templates/nextjs-standalone/src/components/ui/scroll-area.tsx +6 -2
- package/templates/nextjs-standalone/src/components/ui/slider.tsx +63 -0
- package/templates/nextjs-standalone/src/components/ui/sortable.tsx +581 -0
- package/templates/nextjs-standalone/src/components/ui/switch.tsx +35 -0
- package/templates/nextjs-standalone/src/components/ui/textarea.tsx +18 -0
- package/templates/nextjs-standalone/src/config/data-table.ts +82 -0
- package/templates/nextjs-standalone/src/env-check.ts +74 -0
- package/templates/nextjs-standalone/src/hooks/use-callback-ref.ts +27 -0
- package/templates/nextjs-standalone/src/hooks/use-data-table.ts +316 -0
- package/templates/nextjs-standalone/src/hooks/use-debounced-callback.ts +28 -0
- package/templates/nextjs-standalone/src/lib/action-types.ts +7 -41
- package/templates/nextjs-standalone/src/lib/agent-query.ts +4 -2
- package/templates/nextjs-standalone/src/lib/agent.ts +363 -31
- package/templates/nextjs-standalone/src/lib/api-url.ts +2 -3
- package/templates/nextjs-standalone/src/lib/auth/admin-permissions.ts +38 -0
- package/templates/nextjs-standalone/src/lib/auth/audit.ts +19 -4
- package/templates/nextjs-standalone/src/lib/auth/byot.ts +3 -3
- package/templates/nextjs-standalone/src/lib/auth/detect.ts +29 -8
- package/templates/nextjs-standalone/src/lib/auth/managed.ts +104 -14
- package/templates/nextjs-standalone/src/lib/auth/middleware.ts +53 -6
- package/templates/nextjs-standalone/src/lib/auth/migrate.ts +140 -15
- package/templates/nextjs-standalone/src/lib/auth/oauth-state.ts +123 -0
- package/templates/nextjs-standalone/src/lib/auth/org-permissions.ts +55 -0
- package/templates/nextjs-standalone/src/lib/auth/permissions.ts +26 -19
- package/templates/nextjs-standalone/src/lib/auth/server.ts +355 -9
- package/templates/nextjs-standalone/src/lib/auth/simple-key.ts +3 -3
- package/templates/nextjs-standalone/src/lib/auth/types.ts +15 -21
- package/templates/nextjs-standalone/src/lib/billing/enforcement.ts +368 -0
- package/templates/nextjs-standalone/src/lib/billing/plans.ts +155 -0
- package/templates/nextjs-standalone/src/lib/cache/index.ts +92 -0
- package/templates/nextjs-standalone/src/lib/cache/keys.ts +30 -0
- package/templates/nextjs-standalone/src/lib/cache/lru.ts +79 -0
- package/templates/nextjs-standalone/src/lib/cache/types.ts +31 -0
- package/templates/nextjs-standalone/src/lib/compose-refs.ts +62 -0
- package/templates/nextjs-standalone/src/lib/config.ts +563 -11
- package/templates/nextjs-standalone/src/lib/connection-types.ts +9 -0
- package/templates/nextjs-standalone/src/lib/conversation-types.ts +1 -25
- package/templates/nextjs-standalone/src/lib/conversations.ts +345 -14
- package/templates/nextjs-standalone/src/lib/data-table.ts +61 -0
- package/templates/nextjs-standalone/src/lib/db/connection.ts +793 -39
- package/templates/nextjs-standalone/src/lib/db/internal.ts +985 -139
- package/templates/nextjs-standalone/src/lib/db/migrate.ts +295 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0000_baseline.sql +703 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0001_teams_installations.sql +14 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0002_discord_installations.sql +14 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0003_telegram_installations.sql +15 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0004_sandbox_credentials.sql +18 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0005_oauth_state.sql +16 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0006_byot_credentials.sql +14 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0007_gchat_installations.sql +15 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0008_github_installations.sql +14 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0009_linear_installations.sql +15 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0010_whatsapp_installations.sql +14 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0011_email_installations.sql +16 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0012_region_migrations.sql +25 -0
- package/templates/nextjs-standalone/src/lib/db/schema.ts +1120 -0
- package/templates/nextjs-standalone/src/lib/db/source-rate-limit.ts +89 -139
- package/templates/nextjs-standalone/src/lib/demo.ts +308 -0
- package/templates/nextjs-standalone/src/lib/discord/store.ts +225 -0
- package/templates/nextjs-standalone/src/lib/effect/ai.ts +243 -0
- package/templates/nextjs-standalone/src/lib/effect/errors.ts +234 -0
- package/templates/nextjs-standalone/src/lib/effect/hono.ts +454 -0
- package/templates/nextjs-standalone/src/lib/effect/index.ts +137 -0
- package/templates/nextjs-standalone/src/lib/effect/layers.ts +496 -0
- package/templates/nextjs-standalone/src/lib/effect/services.ts +776 -0
- package/templates/nextjs-standalone/src/lib/effect/sql.ts +178 -0
- package/templates/nextjs-standalone/src/lib/effect/toolkit.ts +123 -0
- package/templates/nextjs-standalone/src/lib/email/delivery.ts +232 -0
- package/templates/nextjs-standalone/src/lib/email/engine.ts +349 -0
- package/templates/nextjs-standalone/src/lib/email/hooks.ts +107 -0
- package/templates/nextjs-standalone/src/lib/email/index.ts +16 -0
- package/templates/nextjs-standalone/src/lib/email/scheduler.ts +72 -0
- package/templates/nextjs-standalone/src/lib/email/sequence.ts +73 -0
- package/templates/nextjs-standalone/src/lib/email/store.ts +163 -0
- package/templates/nextjs-standalone/src/lib/email/templates.ts +215 -0
- package/templates/nextjs-standalone/src/lib/format.test.ts +117 -0
- package/templates/nextjs-standalone/src/lib/format.ts +67 -0
- package/templates/nextjs-standalone/src/lib/gchat/store.ts +202 -0
- package/templates/nextjs-standalone/src/lib/github/store.ts +197 -0
- package/templates/nextjs-standalone/src/lib/id.ts +29 -0
- package/templates/nextjs-standalone/src/lib/integrations/types.ts +166 -0
- package/templates/nextjs-standalone/src/lib/learn/pattern-analyzer.ts +224 -0
- package/templates/nextjs-standalone/src/lib/learn/pattern-cache.ts +229 -0
- package/templates/nextjs-standalone/src/lib/learn/pattern-proposer.ts +87 -0
- package/templates/nextjs-standalone/src/lib/learn/suggestion-helpers.ts +34 -0
- package/templates/nextjs-standalone/src/lib/learn/suggestions.ts +139 -0
- package/templates/nextjs-standalone/src/lib/linear/store.ts +200 -0
- package/templates/nextjs-standalone/src/lib/logger.ts +35 -3
- package/templates/nextjs-standalone/src/lib/metering.ts +272 -0
- package/templates/nextjs-standalone/src/lib/parsers.ts +99 -0
- package/templates/nextjs-standalone/src/lib/plugins/hooks.ts +13 -11
- package/templates/nextjs-standalone/src/lib/plugins/index.ts +3 -1
- package/templates/nextjs-standalone/src/lib/plugins/registry.ts +58 -6
- package/templates/nextjs-standalone/src/lib/plugins/settings.ts +147 -0
- package/templates/nextjs-standalone/src/lib/plugins/wiring.ts +6 -9
- package/templates/nextjs-standalone/src/lib/profiler.ts +1665 -0
- package/templates/nextjs-standalone/src/lib/providers.ts +188 -13
- package/templates/nextjs-standalone/src/lib/rls.ts +172 -60
- package/templates/nextjs-standalone/src/lib/sandbox/credentials.ts +206 -0
- package/templates/nextjs-standalone/src/lib/sandbox/validate.ts +179 -0
- package/templates/nextjs-standalone/src/lib/scheduled-task-types.ts +26 -94
- package/templates/nextjs-standalone/src/lib/scheduled-tasks.ts +174 -34
- package/templates/nextjs-standalone/src/lib/scheduler/delivery.ts +248 -150
- package/templates/nextjs-standalone/src/lib/scheduler/engine.ts +190 -154
- package/templates/nextjs-standalone/src/lib/scheduler/executor.ts +74 -23
- package/templates/nextjs-standalone/src/lib/scheduler/preview.ts +72 -0
- package/templates/nextjs-standalone/src/lib/security/abuse.ts +463 -0
- package/templates/nextjs-standalone/src/lib/semantic/diff.ts +267 -0
- package/templates/nextjs-standalone/src/lib/semantic/entities.ts +167 -0
- package/templates/nextjs-standalone/src/lib/semantic/files.ts +283 -0
- package/templates/nextjs-standalone/src/lib/semantic/index.ts +27 -0
- package/templates/nextjs-standalone/src/lib/{semantic-index.ts → semantic/search.ts} +80 -9
- package/templates/nextjs-standalone/src/lib/semantic/sync.ts +581 -0
- package/templates/nextjs-standalone/src/lib/{semantic.ts → semantic/whitelist.ts} +189 -3
- package/templates/nextjs-standalone/src/lib/settings.ts +817 -0
- package/templates/nextjs-standalone/src/lib/sidecar-types.ts +13 -0
- package/templates/nextjs-standalone/src/lib/slack/store.ts +134 -25
- package/templates/nextjs-standalone/src/lib/startup.ts +528 -362
- package/templates/nextjs-standalone/src/lib/teams/store.ts +216 -0
- package/templates/nextjs-standalone/src/lib/telegram/store.ts +202 -0
- package/templates/nextjs-standalone/src/lib/telemetry.ts +40 -0
- package/templates/nextjs-standalone/src/lib/tools/actions/audit.ts +8 -5
- package/templates/nextjs-standalone/src/lib/tools/actions/email.ts +3 -1
- package/templates/nextjs-standalone/src/lib/tools/actions/handler.ts +276 -93
- package/templates/nextjs-standalone/src/lib/tools/actions/jira.ts +2 -2
- package/templates/nextjs-standalone/src/lib/tools/backends/detect.ts +16 -0
- package/templates/nextjs-standalone/src/lib/tools/backends/index.ts +11 -0
- package/templates/nextjs-standalone/src/lib/tools/backends/nsjail.ts +213 -0
- package/templates/nextjs-standalone/src/lib/tools/backends/shared.ts +103 -0
- package/templates/nextjs-standalone/src/lib/tools/backends/types.ts +26 -0
- package/templates/nextjs-standalone/src/lib/tools/explore-nsjail.ts +7 -228
- package/templates/nextjs-standalone/src/lib/tools/explore-sandbox.ts +4 -29
- package/templates/nextjs-standalone/src/lib/tools/explore-sidecar.ts +18 -2
- package/templates/nextjs-standalone/src/lib/tools/explore.ts +246 -54
- package/templates/nextjs-standalone/src/lib/tools/index.ts +17 -0
- package/templates/nextjs-standalone/src/lib/tools/python-nsjail.ts +11 -139
- package/templates/nextjs-standalone/src/lib/tools/python-sandbox.ts +9 -132
- package/templates/nextjs-standalone/src/lib/tools/python-sidecar.ts +184 -3
- package/templates/nextjs-standalone/src/lib/tools/python-stream.ts +33 -0
- package/templates/nextjs-standalone/src/lib/tools/python-wrapper.ts +129 -0
- package/templates/nextjs-standalone/src/lib/tools/python.ts +115 -15
- package/templates/nextjs-standalone/src/lib/tools/registry.ts +14 -2
- package/templates/nextjs-standalone/src/lib/tools/sql.ts +778 -362
- package/templates/nextjs-standalone/src/lib/tracing.ts +16 -0
- package/templates/nextjs-standalone/src/lib/whatsapp/store.ts +198 -0
- package/templates/nextjs-standalone/src/lib/workspace.ts +89 -0
- package/templates/nextjs-standalone/src/progress.ts +121 -0
- package/templates/nextjs-standalone/src/types/data-table.ts +48 -0
- package/templates/nextjs-standalone/src/ui/atlas-chat-reexport.ts +3 -0
- package/templates/nextjs-standalone/src/ui/components/actions/action-approval-card.tsx +26 -19
- package/templates/nextjs-standalone/src/ui/components/actions/action-status-badge.tsx +3 -3
- package/templates/nextjs-standalone/src/ui/components/admin/admin-layout.tsx +57 -39
- package/templates/nextjs-standalone/src/ui/components/admin/admin-sidebar.tsx +213 -35
- package/templates/nextjs-standalone/src/ui/components/admin/delivery-status-badge.tsx +53 -0
- package/templates/nextjs-standalone/src/ui/components/admin/empty-state.tsx +27 -6
- package/templates/nextjs-standalone/src/ui/components/admin/entity-detail.tsx +3 -52
- package/templates/nextjs-standalone/src/ui/components/admin/error-banner.tsx +2 -2
- package/templates/nextjs-standalone/src/ui/components/admin/feature-disabled.tsx +28 -5
- package/templates/nextjs-standalone/src/ui/components/admin-content-wrapper.tsx +87 -0
- package/templates/nextjs-standalone/src/ui/components/atlas-chat.tsx +449 -166
- package/templates/nextjs-standalone/src/ui/components/branding-head.tsx +41 -0
- package/templates/nextjs-standalone/src/ui/components/chart/chart-detection.ts +62 -5
- package/templates/nextjs-standalone/src/ui/components/chart/result-chart.tsx +316 -125
- package/templates/nextjs-standalone/src/ui/components/chat/api-key-bar.tsx +4 -4
- package/templates/nextjs-standalone/src/ui/components/chat/data-table.tsx +45 -4
- package/templates/nextjs-standalone/src/ui/components/chat/error-banner.tsx +86 -5
- package/templates/nextjs-standalone/src/ui/components/chat/follow-up-chips.tsx +29 -0
- package/templates/nextjs-standalone/src/ui/components/chat/markdown.tsx +24 -0
- package/templates/nextjs-standalone/src/ui/components/chat/prompt-library.tsx +206 -0
- package/templates/nextjs-standalone/src/ui/components/chat/python-result-card.tsx +106 -78
- package/templates/nextjs-standalone/src/ui/components/chat/result-card-base.tsx +101 -0
- package/templates/nextjs-standalone/src/ui/components/chat/share-dialog.tsx +377 -0
- package/templates/nextjs-standalone/src/ui/components/chat/sql-result-card.tsx +94 -73
- package/templates/nextjs-standalone/src/ui/components/chat/suggestion-chips.tsx +46 -0
- package/templates/nextjs-standalone/src/ui/components/chat/tool-part.tsx +16 -4
- package/templates/nextjs-standalone/src/ui/components/conversations/conversation-item.tsx +48 -17
- package/templates/nextjs-standalone/src/ui/components/conversations/conversation-list.tsx +38 -24
- package/templates/nextjs-standalone/src/ui/components/conversations/conversation-sidebar.tsx +66 -7
- package/templates/nextjs-standalone/src/ui/components/conversations/delete-confirmation.tsx +9 -2
- package/templates/nextjs-standalone/src/ui/components/error-boundary.tsx +66 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/delete-cell-dialog.tsx +48 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/fork-branch-selector.tsx +68 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/notebook-cell-input.tsx +76 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/notebook-cell-output.tsx +58 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/notebook-cell-toolbar.tsx +91 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/notebook-cell.tsx +119 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/notebook-empty-state.tsx +19 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/notebook-export.ts +287 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/notebook-input-bar.tsx +49 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/notebook-shell.tsx +266 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/notebook-text-cell.tsx +152 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/types.ts +39 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/use-keyboard-nav.ts +109 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/use-notebook.ts +684 -0
- package/templates/nextjs-standalone/src/ui/components/org-switcher.tsx +111 -0
- package/templates/nextjs-standalone/src/ui/components/region-picker.tsx +103 -0
- package/templates/nextjs-standalone/src/ui/components/schema-explorer/schema-explorer.tsx +522 -0
- package/templates/nextjs-standalone/src/ui/components/social-icons.tsx +26 -0
- package/templates/nextjs-standalone/src/ui/components/tour/guided-tour.tsx +81 -0
- package/templates/nextjs-standalone/src/ui/components/tour/index.ts +5 -0
- package/templates/nextjs-standalone/src/ui/components/tour/nav-bar.tsx +100 -0
- package/templates/nextjs-standalone/src/ui/components/tour/tour-overlay.tsx +298 -0
- package/templates/nextjs-standalone/src/ui/components/tour/tour-steps.ts +43 -0
- package/templates/nextjs-standalone/src/ui/components/tour/types.ts +21 -0
- package/templates/nextjs-standalone/src/ui/components/tour/use-tour.ts +193 -0
- package/templates/nextjs-standalone/src/ui/context-reexport.ts +3 -0
- package/templates/nextjs-standalone/src/ui/hooks/theme-init-script.ts +17 -0
- package/templates/nextjs-standalone/src/ui/hooks/use-admin-fetch.ts +38 -30
- package/templates/nextjs-standalone/src/ui/hooks/use-admin-mutation.ts +188 -0
- package/templates/nextjs-standalone/src/ui/hooks/use-atlas-transport.ts +225 -0
- package/templates/nextjs-standalone/src/ui/hooks/use-branding.ts +68 -0
- package/templates/nextjs-standalone/src/ui/hooks/use-conversations.ts +106 -83
- package/templates/nextjs-standalone/src/ui/hooks/use-dark-mode.ts +134 -10
- package/templates/nextjs-standalone/src/ui/hooks/use-deploy-mode.ts +36 -0
- package/templates/nextjs-standalone/src/ui/hooks/use-platform-admin-guard.ts +49 -0
- package/templates/nextjs-standalone/src/ui/lib/action-types.ts +11 -63
- package/templates/nextjs-standalone/src/ui/lib/admin-schemas.ts +744 -0
- package/templates/nextjs-standalone/src/ui/lib/fetch-client.ts +84 -0
- package/templates/nextjs-standalone/src/ui/lib/fetch-error.ts +54 -0
- package/templates/nextjs-standalone/src/ui/lib/helpers.ts +94 -1
- package/templates/nextjs-standalone/src/ui/lib/types.ts +149 -140
- package/templates/nextjs-standalone/tsconfig.json +3 -2
- package/templates/docker/src/api/__tests__/actions.test.ts +0 -683
- package/templates/docker/src/api/__tests__/admin.test.ts +0 -820
- package/templates/docker/src/api/__tests__/auth.test.ts +0 -165
- package/templates/docker/src/api/__tests__/chat.test.ts +0 -376
- package/templates/docker/src/api/__tests__/conversations.test.ts +0 -555
- package/templates/docker/src/api/__tests__/cors.test.ts +0 -135
- package/templates/docker/src/api/__tests__/health-plugin.test.ts +0 -176
- package/templates/docker/src/api/__tests__/health.test.ts +0 -283
- package/templates/docker/src/api/__tests__/query.test.ts +0 -891
- package/templates/docker/src/api/__tests__/scheduled-tasks.test.ts +0 -601
- package/templates/docker/src/api/__tests__/slack.test.ts +0 -847
- package/templates/docker/src/lib/__tests__/agent-cache.test.ts +0 -439
- package/templates/docker/src/lib/__tests__/agent-dialect.test.ts +0 -131
- package/templates/docker/src/lib/__tests__/agent-health-annotations.test.ts +0 -166
- package/templates/docker/src/lib/__tests__/agent-integration.test.ts +0 -516
- package/templates/docker/src/lib/__tests__/config-actions.test.ts +0 -166
- package/templates/docker/src/lib/__tests__/config.test.ts +0 -1113
- package/templates/docker/src/lib/__tests__/conversations.test.ts +0 -589
- package/templates/docker/src/lib/__tests__/errors.test.ts +0 -256
- package/templates/docker/src/lib/__tests__/logger.test.ts +0 -200
- package/templates/docker/src/lib/__tests__/plugin-aware-validation.test.ts +0 -321
- package/templates/docker/src/lib/__tests__/providers.test.ts +0 -130
- package/templates/docker/src/lib/__tests__/rls.test.ts +0 -435
- package/templates/docker/src/lib/__tests__/scheduled-task-types.test.ts +0 -124
- package/templates/docker/src/lib/__tests__/scheduled-tasks.test.ts +0 -550
- package/templates/docker/src/lib/__tests__/semantic-index.test.ts +0 -547
- package/templates/docker/src/lib/__tests__/semantic-multisource.test.ts +0 -544
- package/templates/docker/src/lib/__tests__/semantic.test.ts +0 -363
- package/templates/docker/src/lib/__tests__/startup-actions.test.ts +0 -461
- package/templates/docker/src/lib/__tests__/startup-first-run.test.ts +0 -429
- package/templates/docker/src/lib/__tests__/startup.test.ts +0 -470
- package/templates/docker/src/lib/__tests__/tracing.test.ts +0 -28
- package/templates/docker/src/lib/auth/__tests__/audit.test.ts +0 -418
- package/templates/docker/src/lib/auth/__tests__/byot-integration.test.ts +0 -222
- package/templates/docker/src/lib/auth/__tests__/byot.test.ts +0 -366
- package/templates/docker/src/lib/auth/__tests__/detect.test.ts +0 -190
- package/templates/docker/src/lib/auth/__tests__/managed.test.ts +0 -173
- package/templates/docker/src/lib/auth/__tests__/middleware.test.ts +0 -456
- package/templates/docker/src/lib/auth/__tests__/migrate.test.ts +0 -203
- package/templates/docker/src/lib/auth/__tests__/permissions.test.ts +0 -225
- package/templates/docker/src/lib/auth/__tests__/server.test.ts +0 -34
- package/templates/docker/src/lib/auth/__tests__/simple-key.test.ts +0 -176
- package/templates/docker/src/lib/auth/__tests__/types.test.ts +0 -44
- package/templates/docker/src/lib/db/__tests__/connection.test.ts +0 -144
- package/templates/docker/src/lib/db/__tests__/internal.test.ts +0 -387
- package/templates/docker/src/lib/db/__tests__/registry-health.test.ts +0 -190
- package/templates/docker/src/lib/db/__tests__/registry-pool-limits.test.ts +0 -137
- package/templates/docker/src/lib/db/__tests__/registry.test.ts +0 -398
- package/templates/docker/src/lib/db/__tests__/source-rate-limit.test.ts +0 -130
- package/templates/docker/src/lib/errors.ts +0 -154
- package/templates/docker/src/lib/plugins/__tests__/hooks-integration.test.ts +0 -204
- package/templates/docker/src/lib/plugins/__tests__/hooks.test.ts +0 -529
- package/templates/docker/src/lib/plugins/__tests__/migrate.test.ts +0 -875
- package/templates/docker/src/lib/plugins/__tests__/registry.test.ts +0 -373
- package/templates/docker/src/lib/plugins/__tests__/tools.test.ts +0 -49
- package/templates/docker/src/lib/plugins/__tests__/wiring.test.ts +0 -799
- package/templates/docker/src/lib/scheduler/__tests__/delivery.test.ts +0 -192
- package/templates/docker/src/lib/scheduler/__tests__/engine.test.ts +0 -248
- package/templates/docker/src/lib/scheduler/__tests__/format-email.test.ts +0 -96
- package/templates/docker/src/lib/scheduler/__tests__/format-slack.test.ts +0 -78
- package/templates/docker/src/lib/scheduler/__tests__/format-webhook.test.ts +0 -78
- package/templates/docker/src/lib/scheduler/index.ts +0 -7
- package/templates/docker/src/lib/slack/__tests__/api.test.ts +0 -160
- package/templates/docker/src/lib/slack/__tests__/format.test.ts +0 -237
- package/templates/docker/src/lib/slack/__tests__/store.test.ts +0 -188
- package/templates/docker/src/lib/slack/__tests__/threads.test.ts +0 -112
- package/templates/docker/src/lib/slack/__tests__/verify.test.ts +0 -111
- package/templates/docker/src/lib/tools/__tests__/action-permissions.test.ts +0 -594
- package/templates/docker/src/lib/tools/__tests__/custom-validation.test.ts +0 -240
- package/templates/docker/src/lib/tools/__tests__/explore-backend.test.ts +0 -267
- package/templates/docker/src/lib/tools/__tests__/explore-nsjail.test.ts +0 -506
- package/templates/docker/src/lib/tools/__tests__/explore-plugin.test.ts +0 -374
- package/templates/docker/src/lib/tools/__tests__/explore-sdk-compat.test.ts +0 -82
- package/templates/docker/src/lib/tools/__tests__/explore-sidecar.test.ts +0 -210
- package/templates/docker/src/lib/tools/__tests__/python-nsjail.test.ts +0 -515
- package/templates/docker/src/lib/tools/__tests__/python-sandbox.test.ts +0 -397
- package/templates/docker/src/lib/tools/__tests__/python-sidecar.test.ts +0 -365
- package/templates/docker/src/lib/tools/__tests__/python.test.ts +0 -331
- package/templates/docker/src/lib/tools/__tests__/registry-actions.test.ts +0 -132
- package/templates/docker/src/lib/tools/__tests__/registry.test.ts +0 -242
- package/templates/docker/src/lib/tools/__tests__/sql-audit.test.ts +0 -227
- package/templates/docker/src/lib/tools/__tests__/sql-connection-whitelist.test.ts +0 -100
- package/templates/docker/src/lib/tools/__tests__/sql-ratelimit.test.ts +0 -227
- package/templates/docker/src/lib/tools/__tests__/sql.test.ts +0 -709
- package/templates/docker/src/lib/tools/actions/__tests__/audit.test.ts +0 -211
- package/templates/docker/src/lib/tools/actions/__tests__/email.test.ts +0 -378
- package/templates/docker/src/lib/tools/actions/__tests__/handler.test.ts +0 -681
- package/templates/docker/src/lib/tools/actions/__tests__/jira.test.ts +0 -427
- package/templates/docker/src/test-setup.ts +0 -38
- package/templates/docker/src/types/vercel-sandbox.d.ts +0 -61
- package/templates/docker/src/ui/components/chat/managed-auth-card.tsx +0 -116
- package/templates/nextjs-standalone/src/api/__tests__/actions.test.ts +0 -683
- package/templates/nextjs-standalone/src/api/__tests__/admin.test.ts +0 -820
- package/templates/nextjs-standalone/src/api/__tests__/auth.test.ts +0 -165
- package/templates/nextjs-standalone/src/api/__tests__/chat.test.ts +0 -376
- package/templates/nextjs-standalone/src/api/__tests__/conversations.test.ts +0 -555
- package/templates/nextjs-standalone/src/api/__tests__/cors.test.ts +0 -135
- package/templates/nextjs-standalone/src/api/__tests__/health-plugin.test.ts +0 -176
- package/templates/nextjs-standalone/src/api/__tests__/health.test.ts +0 -283
- package/templates/nextjs-standalone/src/api/__tests__/query.test.ts +0 -891
- package/templates/nextjs-standalone/src/api/__tests__/scheduled-tasks.test.ts +0 -601
- package/templates/nextjs-standalone/src/api/__tests__/slack.test.ts +0 -847
- package/templates/nextjs-standalone/src/app/global-error.tsx +0 -68
- package/templates/nextjs-standalone/src/lib/__tests__/agent-cache.test.ts +0 -439
- package/templates/nextjs-standalone/src/lib/__tests__/agent-dialect.test.ts +0 -131
- package/templates/nextjs-standalone/src/lib/__tests__/agent-health-annotations.test.ts +0 -166
- package/templates/nextjs-standalone/src/lib/__tests__/agent-integration.test.ts +0 -516
- package/templates/nextjs-standalone/src/lib/__tests__/config-actions.test.ts +0 -166
- package/templates/nextjs-standalone/src/lib/__tests__/config.test.ts +0 -1113
- package/templates/nextjs-standalone/src/lib/__tests__/conversations.test.ts +0 -589
- package/templates/nextjs-standalone/src/lib/__tests__/errors.test.ts +0 -256
- package/templates/nextjs-standalone/src/lib/__tests__/logger.test.ts +0 -200
- package/templates/nextjs-standalone/src/lib/__tests__/plugin-aware-validation.test.ts +0 -321
- package/templates/nextjs-standalone/src/lib/__tests__/providers.test.ts +0 -130
- package/templates/nextjs-standalone/src/lib/__tests__/rls.test.ts +0 -435
- package/templates/nextjs-standalone/src/lib/__tests__/scheduled-task-types.test.ts +0 -124
- package/templates/nextjs-standalone/src/lib/__tests__/scheduled-tasks.test.ts +0 -550
- package/templates/nextjs-standalone/src/lib/__tests__/semantic-index.test.ts +0 -547
- package/templates/nextjs-standalone/src/lib/__tests__/semantic-multisource.test.ts +0 -544
- package/templates/nextjs-standalone/src/lib/__tests__/semantic.test.ts +0 -363
- package/templates/nextjs-standalone/src/lib/__tests__/startup-actions.test.ts +0 -461
- package/templates/nextjs-standalone/src/lib/__tests__/startup-first-run.test.ts +0 -429
- package/templates/nextjs-standalone/src/lib/__tests__/startup.test.ts +0 -470
- package/templates/nextjs-standalone/src/lib/__tests__/tracing.test.ts +0 -28
- package/templates/nextjs-standalone/src/lib/auth/__tests__/audit.test.ts +0 -418
- package/templates/nextjs-standalone/src/lib/auth/__tests__/byot-integration.test.ts +0 -222
- package/templates/nextjs-standalone/src/lib/auth/__tests__/byot.test.ts +0 -366
- package/templates/nextjs-standalone/src/lib/auth/__tests__/detect.test.ts +0 -190
- package/templates/nextjs-standalone/src/lib/auth/__tests__/managed.test.ts +0 -173
- package/templates/nextjs-standalone/src/lib/auth/__tests__/middleware.test.ts +0 -456
- package/templates/nextjs-standalone/src/lib/auth/__tests__/migrate.test.ts +0 -203
- package/templates/nextjs-standalone/src/lib/auth/__tests__/permissions.test.ts +0 -225
- package/templates/nextjs-standalone/src/lib/auth/__tests__/server.test.ts +0 -34
- package/templates/nextjs-standalone/src/lib/auth/__tests__/simple-key.test.ts +0 -176
- package/templates/nextjs-standalone/src/lib/auth/__tests__/types.test.ts +0 -44
- package/templates/nextjs-standalone/src/lib/db/__tests__/connection.test.ts +0 -144
- package/templates/nextjs-standalone/src/lib/db/__tests__/internal.test.ts +0 -387
- package/templates/nextjs-standalone/src/lib/db/__tests__/registry-health.test.ts +0 -190
- package/templates/nextjs-standalone/src/lib/db/__tests__/registry-pool-limits.test.ts +0 -137
- package/templates/nextjs-standalone/src/lib/db/__tests__/registry.test.ts +0 -398
- package/templates/nextjs-standalone/src/lib/db/__tests__/source-rate-limit.test.ts +0 -130
- package/templates/nextjs-standalone/src/lib/errors.ts +0 -154
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/hooks-integration.test.ts +0 -204
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/hooks.test.ts +0 -529
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/migrate.test.ts +0 -875
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/registry.test.ts +0 -373
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/tools.test.ts +0 -49
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/wiring.test.ts +0 -799
- package/templates/nextjs-standalone/src/lib/scheduler/__tests__/delivery.test.ts +0 -192
- package/templates/nextjs-standalone/src/lib/scheduler/__tests__/engine.test.ts +0 -248
- package/templates/nextjs-standalone/src/lib/scheduler/__tests__/format-email.test.ts +0 -96
- package/templates/nextjs-standalone/src/lib/scheduler/__tests__/format-slack.test.ts +0 -78
- package/templates/nextjs-standalone/src/lib/scheduler/__tests__/format-webhook.test.ts +0 -78
- package/templates/nextjs-standalone/src/lib/scheduler/index.ts +0 -7
- package/templates/nextjs-standalone/src/lib/slack/__tests__/api.test.ts +0 -160
- package/templates/nextjs-standalone/src/lib/slack/__tests__/format.test.ts +0 -237
- package/templates/nextjs-standalone/src/lib/slack/__tests__/store.test.ts +0 -188
- package/templates/nextjs-standalone/src/lib/slack/__tests__/threads.test.ts +0 -112
- package/templates/nextjs-standalone/src/lib/slack/__tests__/verify.test.ts +0 -111
- package/templates/nextjs-standalone/src/lib/tools/__tests__/action-permissions.test.ts +0 -594
- package/templates/nextjs-standalone/src/lib/tools/__tests__/custom-validation.test.ts +0 -240
- package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-backend.test.ts +0 -267
- package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-nsjail.test.ts +0 -506
- package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-plugin.test.ts +0 -374
- package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-sdk-compat.test.ts +0 -82
- package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-sidecar.test.ts +0 -210
- package/templates/nextjs-standalone/src/lib/tools/__tests__/python-nsjail.test.ts +0 -515
- package/templates/nextjs-standalone/src/lib/tools/__tests__/python-sandbox.test.ts +0 -397
- package/templates/nextjs-standalone/src/lib/tools/__tests__/python-sidecar.test.ts +0 -365
- package/templates/nextjs-standalone/src/lib/tools/__tests__/python.test.ts +0 -331
- package/templates/nextjs-standalone/src/lib/tools/__tests__/registry-actions.test.ts +0 -132
- package/templates/nextjs-standalone/src/lib/tools/__tests__/registry.test.ts +0 -242
- package/templates/nextjs-standalone/src/lib/tools/__tests__/sql-audit.test.ts +0 -227
- package/templates/nextjs-standalone/src/lib/tools/__tests__/sql-connection-whitelist.test.ts +0 -100
- package/templates/nextjs-standalone/src/lib/tools/__tests__/sql-ratelimit.test.ts +0 -227
- package/templates/nextjs-standalone/src/lib/tools/__tests__/sql.test.ts +0 -709
- package/templates/nextjs-standalone/src/lib/tools/actions/__tests__/audit.test.ts +0 -211
- package/templates/nextjs-standalone/src/lib/tools/actions/__tests__/email.test.ts +0 -378
- package/templates/nextjs-standalone/src/lib/tools/actions/__tests__/handler.test.ts +0 -681
- package/templates/nextjs-standalone/src/lib/tools/actions/__tests__/jira.test.ts +0 -427
- package/templates/nextjs-standalone/src/test-setup.ts +0 -38
- package/templates/nextjs-standalone/src/ui/components/chat/managed-auth-card.tsx +0 -116
|
@@ -9,40 +9,32 @@
|
|
|
9
9
|
* - sidecar: HTTP-isolated container with no secrets (Railway)
|
|
10
10
|
* - just-bash: OverlayFs ensures read-only access; writes stay in memory (dev, or production fallback)
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* Default selection priority: sandbox plugin > Vercel sandbox > nsjail (explicit) > sidecar > nsjail (auto-detect) > just-bash.
|
|
13
|
+
* Operators can override the built-in priority via `sandbox.priority` in atlas.config.ts
|
|
14
|
+
* or `ATLAS_SANDBOX_PRIORITY` env var. Plugin backends always take highest priority.
|
|
13
15
|
* A production warning is logged when falling back to just-bash.
|
|
16
|
+
*
|
|
17
|
+
* Org scoping: when an activeOrganizationId is present in the request
|
|
18
|
+
* context, the explore tool reads from `semantic/.orgs/{orgId}/` instead
|
|
19
|
+
* of `semantic/`. Each org's directory is maintained by the dual-write
|
|
20
|
+
* sync layer (semantic-sync.ts). Backends are cached per semantic root.
|
|
14
21
|
*/
|
|
15
22
|
|
|
16
23
|
import { tool } from "ai";
|
|
17
24
|
import { z } from "zod";
|
|
18
|
-
import
|
|
19
|
-
import { createLogger } from "@atlas/api/lib/logger";
|
|
25
|
+
import { createLogger, getRequestContext } from "@atlas/api/lib/logger";
|
|
20
26
|
import { withSpan } from "@atlas/api/lib/tracing";
|
|
27
|
+
import { getConfig, type SandboxBackendName } from "@atlas/api/lib/config";
|
|
28
|
+
import { getSemanticRoot } from "@atlas/api/lib/semantic/sync";
|
|
29
|
+
import { getSetting } from "@atlas/api/lib/settings";
|
|
30
|
+
import { useVercelSandbox, useSidecar } from "./backends/detect";
|
|
21
31
|
|
|
22
32
|
const log = createLogger("explore");
|
|
23
33
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// --- Backend interface ---
|
|
34
|
+
// --- Backend interface (canonical source: ./backends/types.ts) ---
|
|
27
35
|
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
stderr: string;
|
|
31
|
-
exitCode: number;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Shell backend for the explore tool.
|
|
36
|
-
*
|
|
37
|
-
* Implementations MUST provide read-only filesystem access scoped to the
|
|
38
|
-
* semantic layer directory. Commands execute within /semantic as the working
|
|
39
|
-
* directory. Writes should be silently discarded or cause errors, never
|
|
40
|
-
* modify the host filesystem.
|
|
41
|
-
*/
|
|
42
|
-
export interface ExploreBackend {
|
|
43
|
-
exec(command: string): Promise<ExecResult>;
|
|
44
|
-
close?(): Promise<void>;
|
|
45
|
-
}
|
|
36
|
+
export type { ExecResult, ExploreBackend } from "./backends/types";
|
|
37
|
+
import type { ExploreBackend } from "./backends/types";
|
|
46
38
|
|
|
47
39
|
// --- Self-hosted backend (just-bash) ---
|
|
48
40
|
|
|
@@ -89,10 +81,6 @@ async function createBashBackend(
|
|
|
89
81
|
|
|
90
82
|
// --- Runtime detection ---
|
|
91
83
|
|
|
92
|
-
function useVercelSandbox(): boolean {
|
|
93
|
-
return process.env.ATLAS_RUNTIME === "vercel" || !!process.env.VERCEL;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
84
|
let _nsjailAvailable: boolean | null = null;
|
|
97
85
|
|
|
98
86
|
function useNsjail(): boolean {
|
|
@@ -101,7 +89,7 @@ function useNsjail(): boolean {
|
|
|
101
89
|
// Auto-detect nsjail on PATH (deferred require to avoid loading module at startup)
|
|
102
90
|
try {
|
|
103
91
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
104
|
-
const { isNsjailAvailable } = require("./
|
|
92
|
+
const { isNsjailAvailable } = require("./backends/nsjail");
|
|
105
93
|
_nsjailAvailable = isNsjailAvailable();
|
|
106
94
|
} catch (err) {
|
|
107
95
|
if (
|
|
@@ -114,7 +102,7 @@ function useNsjail(): boolean {
|
|
|
114
102
|
} else {
|
|
115
103
|
log.error(
|
|
116
104
|
{ error: err instanceof Error ? err.message : String(err) },
|
|
117
|
-
"Unexpected error loading
|
|
105
|
+
"Unexpected error loading nsjail module",
|
|
118
106
|
);
|
|
119
107
|
_nsjailAvailable = false;
|
|
120
108
|
}
|
|
@@ -122,17 +110,13 @@ function useNsjail(): boolean {
|
|
|
122
110
|
return _nsjailAvailable ?? false;
|
|
123
111
|
}
|
|
124
112
|
|
|
125
|
-
function useSidecar(): boolean {
|
|
126
|
-
return !!process.env.ATLAS_SANDBOX_URL;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
113
|
/** Track nsjail init failures to avoid infinite retry loops. */
|
|
130
114
|
let _nsjailFailed = false;
|
|
131
115
|
|
|
132
116
|
/** Track sidecar init failures so the health endpoint reports accurately. */
|
|
133
117
|
let _sidecarFailed = false;
|
|
134
118
|
|
|
135
|
-
export type ExploreBackendType =
|
|
119
|
+
export type ExploreBackendType = SandboxBackendName | "plugin";
|
|
136
120
|
|
|
137
121
|
/** Name of the active sandbox plugin (if any). Set during backend init. */
|
|
138
122
|
let _activeSandboxPluginId: string | null = null;
|
|
@@ -142,15 +126,46 @@ export function getActiveSandboxPluginId(): string | null {
|
|
|
142
126
|
return _activeSandboxPluginId;
|
|
143
127
|
}
|
|
144
128
|
|
|
129
|
+
/**
|
|
130
|
+
* Check if a specific backend is available (sync, for health reporting).
|
|
131
|
+
*/
|
|
132
|
+
function isBackendAvailable(name: SandboxBackendName): boolean {
|
|
133
|
+
switch (name) {
|
|
134
|
+
case "vercel-sandbox":
|
|
135
|
+
return useVercelSandbox();
|
|
136
|
+
case "nsjail":
|
|
137
|
+
if (_nsjailFailed) return false;
|
|
138
|
+
return process.env.ATLAS_SANDBOX === "nsjail" || useNsjail();
|
|
139
|
+
case "sidecar":
|
|
140
|
+
return useSidecar() && !_sidecarFailed;
|
|
141
|
+
case "just-bash":
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
145
146
|
/**
|
|
146
147
|
* Returns which explore backend is active (for health endpoint).
|
|
147
148
|
*
|
|
148
149
|
* Plugin detection is lazy — _activeSandboxPluginId is only set after the
|
|
149
150
|
* first explore command triggers getExploreBackend(). Before that, this
|
|
150
151
|
* function falls through to the built-in detection chain.
|
|
152
|
+
*
|
|
153
|
+
* When `sandbox.priority` is configured, the first available backend in the
|
|
154
|
+
* priority list is returned instead of the hardcoded chain.
|
|
151
155
|
*/
|
|
152
156
|
export function getExploreBackendType(): ExploreBackendType {
|
|
153
157
|
if (_activeSandboxPluginId) return "plugin";
|
|
158
|
+
|
|
159
|
+
// Config-driven priority
|
|
160
|
+
const configPriority = getConfig()?.sandbox?.priority;
|
|
161
|
+
if (configPriority && configPriority.length > 0) {
|
|
162
|
+
for (const name of configPriority) {
|
|
163
|
+
if (isBackendAvailable(name)) return name;
|
|
164
|
+
}
|
|
165
|
+
return "just-bash";
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Default chain
|
|
154
169
|
if (useVercelSandbox()) return "vercel-sandbox";
|
|
155
170
|
// Explicit nsjail (ATLAS_SANDBOX=nsjail) — hard-fail if unavailable
|
|
156
171
|
if (process.env.ATLAS_SANDBOX === "nsjail" && !_nsjailFailed) return "nsjail";
|
|
@@ -161,11 +176,96 @@ export function getExploreBackendType(): ExploreBackendType {
|
|
|
161
176
|
return "just-bash";
|
|
162
177
|
}
|
|
163
178
|
|
|
164
|
-
|
|
179
|
+
/**
|
|
180
|
+
* Try to create a specific backend by name. Returns null if the backend
|
|
181
|
+
* is not available (env vars not set, binary not found, etc.).
|
|
182
|
+
*/
|
|
183
|
+
async function tryCreateBackend(name: SandboxBackendName, semanticRoot: string, orgId?: string): Promise<ExploreBackend | null> {
|
|
184
|
+
switch (name) {
|
|
185
|
+
case "vercel-sandbox": {
|
|
186
|
+
if (!useVercelSandbox()) return null;
|
|
187
|
+
try {
|
|
188
|
+
const { createSandboxBackend } = await import("./explore-sandbox");
|
|
189
|
+
return createSandboxBackend(semanticRoot);
|
|
190
|
+
} catch (err) {
|
|
191
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
192
|
+
log.warn(
|
|
193
|
+
{ error: detail },
|
|
194
|
+
"vercel-sandbox backend failed to initialize — trying next in priority",
|
|
195
|
+
);
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
case "nsjail": {
|
|
201
|
+
if (_nsjailFailed) return null;
|
|
202
|
+
// Check if nsjail is available (explicit or auto-detect)
|
|
203
|
+
if (process.env.ATLAS_SANDBOX !== "nsjail" && !useNsjail()) return null;
|
|
204
|
+
try {
|
|
205
|
+
const { createNsjailBackend } = await import("./explore-nsjail");
|
|
206
|
+
return await createNsjailBackend(semanticRoot, {
|
|
207
|
+
onInfrastructureError: invalidateExploreBackend,
|
|
208
|
+
onNsjailFailed: markNsjailFailed,
|
|
209
|
+
});
|
|
210
|
+
} catch (err) {
|
|
211
|
+
_nsjailFailed = true;
|
|
212
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
213
|
+
log.warn(
|
|
214
|
+
{ error: detail },
|
|
215
|
+
"nsjail backend failed to initialize — trying next in priority",
|
|
216
|
+
);
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
165
220
|
|
|
166
|
-
|
|
221
|
+
case "sidecar": {
|
|
222
|
+
// Workspace-level URL override takes priority over env var
|
|
223
|
+
const wsSidecarUrl = orgId ? getSetting("ATLAS_SANDBOX_URL", orgId) : undefined;
|
|
224
|
+
const sidecarUrl = wsSidecarUrl ?? process.env.ATLAS_SANDBOX_URL;
|
|
225
|
+
if ((!sidecarUrl && !useSidecar()) || _sidecarFailed) return null;
|
|
226
|
+
if (!sidecarUrl) return null;
|
|
227
|
+
try {
|
|
228
|
+
const { createSidecarBackend } = await import("./explore-sidecar");
|
|
229
|
+
return createSidecarBackend(sidecarUrl, { semanticRoot });
|
|
230
|
+
} catch (err) {
|
|
231
|
+
_sidecarFailed = true;
|
|
232
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
233
|
+
log.warn(
|
|
234
|
+
{ error: detail },
|
|
235
|
+
"sidecar backend failed to initialize — trying next in priority",
|
|
236
|
+
);
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
case "just-bash": {
|
|
242
|
+
if (process.env.NODE_ENV === "production") {
|
|
243
|
+
log.warn(
|
|
244
|
+
"SECURITY DEGRADATION: Explore tool running without process isolation (just-bash fallback). " +
|
|
245
|
+
"In production, this means shell commands execute directly on the host with only OverlayFs " +
|
|
246
|
+
"read-only protection — no namespace, network, or resource isolation. " +
|
|
247
|
+
"Install nsjail, configure a sidecar (ATLAS_SANDBOX_URL), or deploy on Vercel for sandboxed execution. " +
|
|
248
|
+
"See: https://github.com/google/nsjail",
|
|
249
|
+
);
|
|
250
|
+
} else {
|
|
251
|
+
log.debug("Explore tool using just-bash backend (acceptable for development)");
|
|
252
|
+
}
|
|
253
|
+
return createBashBackend(semanticRoot);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Backend cache keyed by semantic root path.
|
|
260
|
+
*
|
|
261
|
+
* For self-hosted (no orgs), there's exactly one entry. For multi-tenant,
|
|
262
|
+
* each org gets its own backend instance (most backends are cheap to create).
|
|
263
|
+
*/
|
|
264
|
+
const backendCache = new Map<string, Promise<ExploreBackend>>();
|
|
265
|
+
|
|
266
|
+
/** Clear cached backends so the next call recreates them. */
|
|
167
267
|
export function invalidateExploreBackend(): void {
|
|
168
|
-
|
|
268
|
+
backendCache.clear();
|
|
169
269
|
_activeSandboxPluginId = null;
|
|
170
270
|
}
|
|
171
271
|
|
|
@@ -173,7 +273,7 @@ export function invalidateExploreBackend(): void {
|
|
|
173
273
|
* Called from explore-nsjail.ts on exit code 109 (sandbox setup failure). */
|
|
174
274
|
export function markNsjailFailed(): void {
|
|
175
275
|
_nsjailFailed = true;
|
|
176
|
-
|
|
276
|
+
backendCache.clear();
|
|
177
277
|
}
|
|
178
278
|
|
|
179
279
|
/** Permanently mark the sidecar as failed so health reports "just-bash".
|
|
@@ -182,16 +282,60 @@ export function markSidecarFailed(): void {
|
|
|
182
282
|
_sidecarFailed = true;
|
|
183
283
|
}
|
|
184
284
|
|
|
185
|
-
function getExploreBackend(): Promise<ExploreBackend> {
|
|
186
|
-
|
|
187
|
-
|
|
285
|
+
function getExploreBackend(semanticRoot: string, orgId?: string): Promise<ExploreBackend> {
|
|
286
|
+
// Workspace override changes the effective backend, so include it in the cache key
|
|
287
|
+
const wsOverride = orgId ? getSetting("ATLAS_SANDBOX_BACKEND", orgId) : undefined;
|
|
288
|
+
const cacheKeyVal = wsOverride ? `${semanticRoot}\0${wsOverride}` : semanticRoot;
|
|
289
|
+
|
|
290
|
+
let promise = backendCache.get(cacheKeyVal);
|
|
291
|
+
if (!promise) {
|
|
292
|
+
promise = (async (): Promise<ExploreBackend> => {
|
|
293
|
+
// Priority -1: Workspace-level backend override (SaaS self-serve)
|
|
294
|
+
if (wsOverride) {
|
|
295
|
+
log.info(
|
|
296
|
+
{ backend: wsOverride, orgId, source: "workspace-setting" },
|
|
297
|
+
"Workspace sandbox override: %s",
|
|
298
|
+
wsOverride,
|
|
299
|
+
);
|
|
300
|
+
// Check if override is a built-in backend name
|
|
301
|
+
const builtInNames: readonly string[] = ["vercel-sandbox", "nsjail", "sidecar", "just-bash"];
|
|
302
|
+
if (builtInNames.includes(wsOverride)) {
|
|
303
|
+
const backend = await tryCreateBackend(wsOverride as SandboxBackendName, semanticRoot, orgId);
|
|
304
|
+
if (backend) return backend;
|
|
305
|
+
log.warn(
|
|
306
|
+
{ backend: wsOverride, orgId },
|
|
307
|
+
"Workspace sandbox override %s unavailable — falling through to default",
|
|
308
|
+
wsOverride,
|
|
309
|
+
);
|
|
310
|
+
} else {
|
|
311
|
+
// Try as a plugin ID
|
|
312
|
+
try {
|
|
313
|
+
const { plugins } = await import("@atlas/api/lib/plugins/registry");
|
|
314
|
+
const { wireSandboxPlugins } = await import("@atlas/api/lib/plugins/wiring");
|
|
315
|
+
const result = await wireSandboxPlugins(plugins, semanticRoot);
|
|
316
|
+
if (result.backend && result.pluginId === wsOverride) {
|
|
317
|
+
_activeSandboxPluginId = result.pluginId;
|
|
318
|
+
return result.backend as ExploreBackend;
|
|
319
|
+
}
|
|
320
|
+
} catch (err) {
|
|
321
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
322
|
+
log.warn(
|
|
323
|
+
{ backend: wsOverride, orgId, err: detail },
|
|
324
|
+
"Workspace sandbox plugin override %s failed — falling through to default",
|
|
325
|
+
wsOverride,
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
// Override not available — fall through to normal chain
|
|
330
|
+
}
|
|
331
|
+
|
|
188
332
|
// Priority 0: Sandbox plugins (sorted by priority, highest first)
|
|
189
333
|
// Skipped when ATLAS_SANDBOX=nsjail — operator explicitly wants nsjail only
|
|
190
334
|
if (process.env.ATLAS_SANDBOX !== "nsjail") {
|
|
191
335
|
try {
|
|
192
336
|
const { plugins } = await import("@atlas/api/lib/plugins/registry");
|
|
193
337
|
const { wireSandboxPlugins } = await import("@atlas/api/lib/plugins/wiring");
|
|
194
|
-
const result = await wireSandboxPlugins(plugins,
|
|
338
|
+
const result = await wireSandboxPlugins(plugins, semanticRoot);
|
|
195
339
|
if (result.failed.length > 0) {
|
|
196
340
|
log.warn(
|
|
197
341
|
{ failed: result.failed, selectedPlugin: result.pluginId },
|
|
@@ -214,17 +358,56 @@ function getExploreBackend(): Promise<ExploreBackend> {
|
|
|
214
358
|
}
|
|
215
359
|
}
|
|
216
360
|
|
|
361
|
+
// --- Config-driven priority ---
|
|
362
|
+
const configPriority = getConfig()?.sandbox?.priority;
|
|
363
|
+
if (configPriority && configPriority.length > 0) {
|
|
364
|
+
log.info(
|
|
365
|
+
{ priority: configPriority },
|
|
366
|
+
"Using configured sandbox priority: %s",
|
|
367
|
+
configPriority.join(" > "),
|
|
368
|
+
);
|
|
369
|
+
for (const name of configPriority) {
|
|
370
|
+
const backend = await tryCreateBackend(name, semanticRoot, orgId);
|
|
371
|
+
if (backend) {
|
|
372
|
+
log.info(
|
|
373
|
+
{ backend: name, source: "config" },
|
|
374
|
+
"Explore backend selected: %s (config priority)",
|
|
375
|
+
name,
|
|
376
|
+
);
|
|
377
|
+
return backend;
|
|
378
|
+
}
|
|
379
|
+
log.debug({ backend: name }, "Backend %s unavailable — trying next in priority", name);
|
|
380
|
+
}
|
|
381
|
+
// All config backends failed
|
|
382
|
+
if (configPriority.includes("just-bash")) {
|
|
383
|
+
// just-bash was in the list but somehow failed (should not happen) — try once more
|
|
384
|
+
log.warn(
|
|
385
|
+
{ priority: configPriority },
|
|
386
|
+
"All higher-priority backends in sandbox.priority unavailable — using just-bash",
|
|
387
|
+
);
|
|
388
|
+
return createBashBackend(semanticRoot);
|
|
389
|
+
}
|
|
390
|
+
// Operator did NOT include just-bash — respect their intent
|
|
391
|
+
throw new Error(
|
|
392
|
+
`All backends in sandbox.priority (${configPriority.join(", ")}) failed to initialize. ` +
|
|
393
|
+
"Add 'just-bash' to the priority list if you want an unsandboxed fallback, " +
|
|
394
|
+
"or fix the backend configuration.",
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// --- Default priority chain ---
|
|
399
|
+
|
|
217
400
|
// Priority 1: Vercel Sandbox (Firecracker VM)
|
|
218
401
|
if (useVercelSandbox()) {
|
|
219
402
|
const { createSandboxBackend } = await import("./explore-sandbox");
|
|
220
|
-
return createSandboxBackend(
|
|
403
|
+
return createSandboxBackend(semanticRoot);
|
|
221
404
|
}
|
|
222
405
|
|
|
223
406
|
// Priority 2: nsjail explicit (ATLAS_SANDBOX=nsjail) — hard-fail if init fails
|
|
224
407
|
if (process.env.ATLAS_SANDBOX === "nsjail" && !_nsjailFailed) {
|
|
225
408
|
try {
|
|
226
409
|
const { createNsjailBackend } = await import("./explore-nsjail");
|
|
227
|
-
return await createNsjailBackend(
|
|
410
|
+
return await createNsjailBackend(semanticRoot, {
|
|
228
411
|
onInfrastructureError: invalidateExploreBackend,
|
|
229
412
|
onNsjailFailed: markNsjailFailed,
|
|
230
413
|
});
|
|
@@ -243,14 +426,14 @@ function getExploreBackend(): Promise<ExploreBackend> {
|
|
|
243
426
|
// Skips nsjail auto-detection entirely — no noisy namespace warnings.
|
|
244
427
|
if (useSidecar()) {
|
|
245
428
|
const { createSidecarBackend } = await import("./explore-sidecar");
|
|
246
|
-
return createSidecarBackend(process.env.ATLAS_SANDBOX_URL
|
|
429
|
+
return createSidecarBackend(process.env.ATLAS_SANDBOX_URL!, { semanticRoot });
|
|
247
430
|
}
|
|
248
431
|
|
|
249
432
|
// Priority 4: nsjail auto-detect (binary on PATH, graceful fallback)
|
|
250
433
|
if (!_nsjailFailed && useNsjail()) {
|
|
251
434
|
try {
|
|
252
435
|
const { createNsjailBackend } = await import("./explore-nsjail");
|
|
253
|
-
return await createNsjailBackend(
|
|
436
|
+
return await createNsjailBackend(semanticRoot, {
|
|
254
437
|
onInfrastructureError: invalidateExploreBackend,
|
|
255
438
|
onNsjailFailed: markNsjailFailed,
|
|
256
439
|
});
|
|
@@ -276,13 +459,14 @@ function getExploreBackend(): Promise<ExploreBackend> {
|
|
|
276
459
|
} else {
|
|
277
460
|
log.debug("Explore tool using just-bash backend (acceptable for development)");
|
|
278
461
|
}
|
|
279
|
-
return createBashBackend(
|
|
462
|
+
return createBashBackend(semanticRoot);
|
|
280
463
|
})().catch((err) => {
|
|
281
|
-
|
|
464
|
+
backendCache.delete(cacheKeyVal); // allow retry on next call
|
|
282
465
|
throw err;
|
|
283
466
|
});
|
|
467
|
+
backendCache.set(cacheKeyVal, promise);
|
|
284
468
|
}
|
|
285
|
-
return
|
|
469
|
+
return promise;
|
|
286
470
|
}
|
|
287
471
|
|
|
288
472
|
// --- Tool definition ---
|
|
@@ -314,12 +498,16 @@ Always start by listing the root directory to see what sources are available.`,
|
|
|
314
498
|
}),
|
|
315
499
|
|
|
316
500
|
execute: async ({ command }) => {
|
|
501
|
+
// Resolve org-scoped semantic root from request context
|
|
502
|
+
const orgId = getRequestContext()?.user?.activeOrganizationId;
|
|
503
|
+
const semanticRoot = getSemanticRoot(orgId);
|
|
504
|
+
|
|
317
505
|
let backend: ExploreBackend;
|
|
318
506
|
try {
|
|
319
|
-
backend = await getExploreBackend();
|
|
507
|
+
backend = await getExploreBackend(semanticRoot, orgId);
|
|
320
508
|
} catch (err) {
|
|
321
509
|
const detail = err instanceof Error ? err.message : String(err);
|
|
322
|
-
log.error({ err: detail }, "Explore backend initialization failed");
|
|
510
|
+
log.error({ err: detail, orgId }, "Explore backend initialization failed");
|
|
323
511
|
return `Error: Explore tool is unavailable — ${detail}`;
|
|
324
512
|
}
|
|
325
513
|
|
|
@@ -348,13 +536,17 @@ Always start by listing the root directory to see what sources are available.`,
|
|
|
348
536
|
const start = performance.now();
|
|
349
537
|
const result = await withSpan(
|
|
350
538
|
"atlas.explore",
|
|
351
|
-
{
|
|
539
|
+
{
|
|
540
|
+
"atlas.command": execCommand.slice(0, 200),
|
|
541
|
+
"atlas.backend": getExploreBackendType(),
|
|
542
|
+
...(orgId ? { "atlas.org_id": orgId } : {}),
|
|
543
|
+
},
|
|
352
544
|
() => backend.exec(execCommand),
|
|
353
545
|
);
|
|
354
546
|
const durationMs = Math.round(performance.now() - start);
|
|
355
547
|
|
|
356
548
|
log.debug(
|
|
357
|
-
{ command: execCommand, durationMs, exitCode: result.exitCode },
|
|
549
|
+
{ command: execCommand, durationMs, exitCode: result.exitCode, orgId },
|
|
358
550
|
"explore command",
|
|
359
551
|
);
|
|
360
552
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tools barrel export.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports tool definitions, the registry, and shared backend utilities
|
|
5
|
+
* so callers can import from `@atlas/api/lib/tools` instead of individual files.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Registry
|
|
9
|
+
export { ToolRegistry, buildRegistry, defaultRegistry } from "./registry";
|
|
10
|
+
export type { AtlasTool } from "./registry";
|
|
11
|
+
|
|
12
|
+
// Tool definitions
|
|
13
|
+
export { explore } from "./explore";
|
|
14
|
+
export { executePython } from "./python";
|
|
15
|
+
|
|
16
|
+
// Backend types and utilities
|
|
17
|
+
export * from "./backends";
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import type { PythonBackend, PythonResult } from "./python";
|
|
14
|
+
import { PYTHON_SECURITY_AND_SETUP, PYTHON_EXEC_AND_COLLECT } from "./python-wrapper";
|
|
15
|
+
import { readLimited, MAX_OUTPUT, parsePositiveInt } from "./backends/shared";
|
|
14
16
|
import { randomUUID } from "crypto";
|
|
15
17
|
import { mkdirSync, writeFileSync, rmSync } from "fs";
|
|
16
18
|
import { join } from "path";
|
|
@@ -18,9 +20,6 @@ import { createLogger } from "@atlas/api/lib/logger";
|
|
|
18
20
|
|
|
19
21
|
const log = createLogger("python-nsjail");
|
|
20
22
|
|
|
21
|
-
/** Maximum bytes to read from stdout/stderr (1 MB). */
|
|
22
|
-
const MAX_OUTPUT = 1024 * 1024;
|
|
23
|
-
|
|
24
23
|
/** Default Python execution timeout in seconds. */
|
|
25
24
|
const DEFAULT_TIME_LIMIT = 30;
|
|
26
25
|
|
|
@@ -31,11 +30,9 @@ const DEFAULT_MEMORY_LIMIT = 512;
|
|
|
31
30
|
const DEFAULT_NPROC = 16;
|
|
32
31
|
|
|
33
32
|
/**
|
|
34
|
-
* Python wrapper
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* (JSON on stdin → DataFrame/dict), stdout capture, chart collection
|
|
38
|
-
* (PNG files + Recharts dicts), and structured output via result marker.
|
|
33
|
+
* Non-streaming Python wrapper for nsjail. Composes shared fragments
|
|
34
|
+
* (PYTHON_SECURITY_AND_SETUP, PYTHON_EXEC_AND_COLLECT) with stdin-based
|
|
35
|
+
* data injection and marker-based result emission.
|
|
39
36
|
*/
|
|
40
37
|
const PYTHON_WRAPPER = `
|
|
41
38
|
import sys, json, io, base64, glob, os, ast
|
|
@@ -43,53 +40,11 @@ import sys, json, io, base64, glob, os, ast
|
|
|
43
40
|
_marker = os.environ["ATLAS_RESULT_MARKER"]
|
|
44
41
|
_chart_dir = os.environ.get("ATLAS_CHART_DIR", "/tmp")
|
|
45
42
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"subprocess", "os", "socket", "shutil", "sys", "ctypes", "importlib",
|
|
49
|
-
"code", "signal", "multiprocessing", "threading", "pty", "fcntl",
|
|
50
|
-
"termios", "resource", "posixpath",
|
|
51
|
-
"http", "urllib", "requests", "httpx", "aiohttp", "webbrowser",
|
|
52
|
-
"pickle", "tempfile", "pathlib",
|
|
53
|
-
}
|
|
54
|
-
_BLOCKED_BUILTINS = {
|
|
55
|
-
"compile", "exec", "eval", "__import__", "open", "breakpoint",
|
|
56
|
-
"getattr", "globals", "locals", "vars", "dir", "delattr", "setattr",
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
_user_code = open(sys.argv[1]).read()
|
|
60
|
-
try:
|
|
61
|
-
_tree = ast.parse(_user_code)
|
|
62
|
-
except SyntaxError as e:
|
|
63
|
-
print(_marker + json.dumps({"success": False, "error": f"SyntaxError: {e.msg} (line {e.lineno})"}))
|
|
43
|
+
def _report_error(msg):
|
|
44
|
+
print(_marker + json.dumps({"success": False, "error": msg}))
|
|
64
45
|
sys.exit(0)
|
|
65
46
|
|
|
66
|
-
|
|
67
|
-
for _node in ast.walk(_tree):
|
|
68
|
-
if _blocked:
|
|
69
|
-
break
|
|
70
|
-
if isinstance(_node, ast.Import):
|
|
71
|
-
for _alias in _node.names:
|
|
72
|
-
_mod = _alias.name.split('.')[0]
|
|
73
|
-
if _mod in _BLOCKED_MODULES:
|
|
74
|
-
_blocked = f'Blocked import: "{_mod}" is not allowed'
|
|
75
|
-
break
|
|
76
|
-
elif isinstance(_node, ast.ImportFrom):
|
|
77
|
-
if _node.module:
|
|
78
|
-
_mod = _node.module.split('.')[0]
|
|
79
|
-
if _mod in _BLOCKED_MODULES:
|
|
80
|
-
_blocked = f'Blocked import: "{_mod}" is not allowed'
|
|
81
|
-
elif isinstance(_node, ast.Call):
|
|
82
|
-
_name = None
|
|
83
|
-
if isinstance(_node.func, ast.Name):
|
|
84
|
-
_name = _node.func.id
|
|
85
|
-
elif isinstance(_node.func, ast.Attribute):
|
|
86
|
-
_name = _node.func.attr
|
|
87
|
-
if _name and _name in _BLOCKED_BUILTINS:
|
|
88
|
-
_blocked = f'Blocked builtin: "{_name}()" is not allowed'
|
|
89
|
-
|
|
90
|
-
if _blocked:
|
|
91
|
-
print(_marker + json.dumps({"success": False, "error": _blocked}))
|
|
92
|
-
sys.exit(0)
|
|
47
|
+
${PYTHON_SECURITY_AND_SETUP}
|
|
93
48
|
|
|
94
49
|
# --- Data injection ---
|
|
95
50
|
_stdin_data = sys.stdin.read()
|
|
@@ -107,92 +62,9 @@ if _atlas_data:
|
|
|
107
62
|
except ImportError:
|
|
108
63
|
data = _atlas_data
|
|
109
64
|
|
|
110
|
-
|
|
111
|
-
try:
|
|
112
|
-
import matplotlib
|
|
113
|
-
matplotlib.use('Agg')
|
|
114
|
-
except ImportError:
|
|
115
|
-
pass
|
|
116
|
-
|
|
117
|
-
def chart_path(n=0):
|
|
118
|
-
return os.path.join(_chart_dir, f"chart_{n}.png")
|
|
119
|
-
|
|
120
|
-
# --- Execute user code in isolated namespace ---
|
|
121
|
-
_old_stdout = sys.stdout
|
|
122
|
-
sys.stdout = _captured = io.StringIO()
|
|
123
|
-
|
|
124
|
-
_user_ns = {"chart_path": chart_path, "data": data, "df": df}
|
|
125
|
-
_atlas_error = None
|
|
126
|
-
try:
|
|
127
|
-
exec(_user_code, _user_ns)
|
|
128
|
-
except Exception as e:
|
|
129
|
-
_atlas_error = f"{type(e).__name__}: {e}"
|
|
130
|
-
|
|
131
|
-
_output = _captured.getvalue()
|
|
132
|
-
sys.stdout = _old_stdout
|
|
133
|
-
|
|
134
|
-
# --- Collect results ---
|
|
135
|
-
_charts = []
|
|
136
|
-
for f in sorted(glob.glob(os.path.join(_chart_dir, "chart_*.png"))):
|
|
137
|
-
with open(f, "rb") as fh:
|
|
138
|
-
_charts.append({"base64": base64.b64encode(fh.read()).decode(), "mimeType": "image/png"})
|
|
139
|
-
|
|
140
|
-
_result = {"success": _atlas_error is None}
|
|
141
|
-
if _output.strip():
|
|
142
|
-
_result["output"] = _output.strip()
|
|
143
|
-
if _atlas_error:
|
|
144
|
-
_result["error"] = _atlas_error
|
|
145
|
-
|
|
146
|
-
if "_atlas_table" in _user_ns:
|
|
147
|
-
_result["table"] = _user_ns["_atlas_table"]
|
|
148
|
-
|
|
149
|
-
if "_atlas_chart" in _user_ns:
|
|
150
|
-
_ac = _user_ns["_atlas_chart"]
|
|
151
|
-
if isinstance(_ac, dict):
|
|
152
|
-
_result["rechartsCharts"] = [_ac]
|
|
153
|
-
elif isinstance(_ac, list):
|
|
154
|
-
_result["rechartsCharts"] = _ac
|
|
155
|
-
|
|
156
|
-
if _charts:
|
|
157
|
-
_result["charts"] = _charts
|
|
158
|
-
|
|
159
|
-
print(_marker + json.dumps(_result), file=_old_stdout)
|
|
65
|
+
${PYTHON_EXEC_AND_COLLECT}
|
|
160
66
|
`;
|
|
161
67
|
|
|
162
|
-
/** Read up to `max` bytes from a stream. */
|
|
163
|
-
async function readLimited(stream: ReadableStream, max: number): Promise<string> {
|
|
164
|
-
const reader = stream.getReader();
|
|
165
|
-
const chunks: Uint8Array[] = [];
|
|
166
|
-
let total = 0;
|
|
167
|
-
try {
|
|
168
|
-
while (true) {
|
|
169
|
-
const { done, value } = await reader.read();
|
|
170
|
-
if (done) break;
|
|
171
|
-
total += value.byteLength;
|
|
172
|
-
if (total > max) {
|
|
173
|
-
chunks.push(value.slice(0, max - (total - value.byteLength)));
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
chunks.push(value);
|
|
177
|
-
}
|
|
178
|
-
} finally {
|
|
179
|
-
await reader.cancel().catch(() => {});
|
|
180
|
-
}
|
|
181
|
-
return new TextDecoder().decode(Buffer.concat(chunks));
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/** Parse a positive integer from an env var, returning defaultValue on invalid input. */
|
|
185
|
-
function parsePositiveInt(envVar: string, defaultValue: number, name: string): number {
|
|
186
|
-
const raw = process.env[envVar];
|
|
187
|
-
if (raw === undefined) return defaultValue;
|
|
188
|
-
const parsed = parseInt(raw, 10);
|
|
189
|
-
if (isNaN(parsed) || parsed <= 0) {
|
|
190
|
-
log.warn({ envVar, raw, default: defaultValue }, `Invalid ${envVar} for ${name}, using default`);
|
|
191
|
-
return defaultValue;
|
|
192
|
-
}
|
|
193
|
-
return parsed;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
68
|
/** Build nsjail args for Python execution. */
|
|
197
69
|
export function buildPythonNsjailArgs(
|
|
198
70
|
nsjailPath: string,
|
|
@@ -202,8 +74,8 @@ export function buildPythonNsjailArgs(
|
|
|
202
74
|
chartDir: string,
|
|
203
75
|
_resultMarker: string,
|
|
204
76
|
): string[] {
|
|
205
|
-
const timeLimit = parsePositiveInt("ATLAS_NSJAIL_TIME_LIMIT", DEFAULT_TIME_LIMIT, "time limit");
|
|
206
|
-
const memoryLimit = parsePositiveInt("ATLAS_NSJAIL_MEMORY_LIMIT", DEFAULT_MEMORY_LIMIT, "memory limit");
|
|
77
|
+
const timeLimit = parsePositiveInt("ATLAS_NSJAIL_TIME_LIMIT", DEFAULT_TIME_LIMIT, "time limit", log);
|
|
78
|
+
const memoryLimit = parsePositiveInt("ATLAS_NSJAIL_MEMORY_LIMIT", DEFAULT_MEMORY_LIMIT, "memory limit", log);
|
|
207
79
|
const nproc = DEFAULT_NPROC;
|
|
208
80
|
|
|
209
81
|
return [
|