@useatlas/create 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -18
- package/index.ts +191 -31
- package/package.json +1 -1
- package/templates/docker/.env.example +3 -3
- package/templates/docker/Dockerfile.sidecar +28 -0
- package/templates/docker/bin/__tests__/plugin-cli.test.ts +11 -11
- package/templates/docker/bin/atlas.ts +120 -56
- package/templates/docker/data/demo-semantic/catalog.yml +51 -27
- package/templates/docker/data/demo-semantic/entities/accounts.yml +95 -103
- package/templates/docker/data/demo-semantic/entities/companies.yml +88 -152
- package/templates/docker/data/demo-semantic/entities/people.yml +82 -95
- package/templates/docker/data/demo-semantic/glossary.yml +104 -8
- package/templates/docker/data/demo-semantic/metrics/accounts.yml +62 -23
- package/templates/docker/data/demo-semantic/metrics/companies.yml +52 -78
- package/templates/docker/docker-compose.yml +1 -1
- package/templates/docker/docs/deploy.md +4 -41
- package/templates/docker/package.json +17 -1
- package/templates/docker/semantic/catalog.yml +62 -3
- package/templates/docker/semantic/entities/accounts.yml +162 -0
- package/templates/docker/semantic/entities/companies.yml +143 -0
- package/templates/docker/semantic/entities/people.yml +132 -0
- package/templates/docker/semantic/glossary.yml +116 -4
- package/templates/docker/semantic/metrics/accounts.yml +77 -0
- package/templates/docker/semantic/metrics/companies.yml +63 -0
- package/templates/docker/sidecar/Dockerfile +5 -6
- package/templates/docker/sidecar/railway.json +1 -2
- package/templates/docker/src/api/__tests__/admin.test.ts +7 -7
- package/templates/docker/src/api/__tests__/health-plugin.test.ts +7 -0
- package/templates/docker/src/api/__tests__/health.test.ts +30 -8
- package/templates/docker/src/api/routes/admin.ts +549 -8
- package/templates/docker/src/api/routes/chat.ts +5 -20
- package/templates/docker/src/api/routes/health.ts +39 -27
- package/templates/docker/src/api/routes/openapi.ts +1329 -74
- package/templates/docker/src/api/routes/query.ts +2 -1
- package/templates/docker/src/api/server.ts +27 -0
- package/templates/docker/src/app/api/[...route]/route.ts +2 -2
- package/templates/docker/src/app/globals.css +13 -12
- package/templates/docker/src/app/layout.tsx +9 -2
- package/templates/docker/src/components/ui/alert-dialog.tsx +196 -0
- package/templates/docker/src/components/ui/badge.tsx +48 -0
- package/templates/docker/src/components/ui/button.tsx +64 -0
- package/templates/docker/src/components/ui/card.tsx +92 -0
- package/templates/docker/src/components/ui/collapsible.tsx +33 -0
- package/templates/docker/src/components/ui/command.tsx +184 -0
- package/templates/docker/src/components/ui/dialog.tsx +158 -0
- package/templates/docker/src/components/ui/dropdown-menu.tsx +257 -0
- package/templates/docker/src/components/ui/input.tsx +21 -0
- package/templates/docker/src/components/ui/scroll-area.tsx +58 -0
- package/templates/docker/src/components/ui/select.tsx +190 -0
- package/templates/docker/src/components/ui/separator.tsx +28 -0
- package/templates/docker/src/components/ui/sheet.tsx +143 -0
- package/templates/docker/src/components/ui/sidebar.tsx +726 -0
- package/templates/docker/src/components/ui/skeleton.tsx +13 -0
- package/templates/docker/src/components/ui/table.tsx +116 -0
- package/templates/docker/src/components/ui/tabs.tsx +91 -0
- package/templates/docker/src/components/ui/toggle-group.tsx +83 -0
- package/templates/docker/src/components/ui/toggle.tsx +47 -0
- package/templates/docker/src/components/ui/tooltip.tsx +57 -0
- package/templates/docker/src/hooks/use-mobile.ts +19 -0
- package/templates/docker/src/lib/__tests__/agent-cache.test.ts +2 -0
- package/templates/docker/src/lib/__tests__/agent-dialect.test.ts +17 -0
- package/templates/docker/src/lib/__tests__/agent-health-annotations.test.ts +2 -0
- package/templates/docker/src/lib/__tests__/agent-integration.test.ts +2 -0
- package/templates/docker/src/lib/__tests__/config.test.ts +69 -19
- package/templates/docker/src/lib/__tests__/plugin-aware-validation.test.ts +321 -0
- package/templates/docker/src/lib/__tests__/providers.test.ts +32 -1
- package/templates/docker/src/lib/__tests__/startup-actions.test.ts +9 -0
- package/templates/docker/src/lib/__tests__/startup-first-run.test.ts +429 -0
- package/templates/docker/src/lib/__tests__/startup.test.ts +5 -0
- package/templates/docker/src/lib/agent-query.ts +5 -23
- package/templates/docker/src/lib/agent.ts +32 -112
- package/templates/docker/src/lib/auth/__tests__/migrate.test.ts +5 -3
- package/templates/docker/src/lib/auth/middleware.ts +30 -4
- package/templates/docker/src/lib/auth/migrate.ts +97 -0
- package/templates/docker/src/lib/auth/server.ts +12 -1
- package/templates/docker/src/lib/config.ts +38 -40
- package/templates/docker/src/lib/db/__tests__/connection.test.ts +89 -14
- package/templates/docker/src/lib/db/__tests__/registry-health.test.ts +1 -18
- package/templates/docker/src/lib/db/__tests__/registry-pool-limits.test.ts +0 -19
- package/templates/docker/src/lib/db/__tests__/registry.test.ts +11 -208
- package/templates/docker/src/lib/db/connection.ts +87 -265
- package/templates/docker/src/lib/db/internal.ts +6 -1
- package/templates/docker/src/lib/plugins/__tests__/hooks-integration.test.ts +3 -1
- package/templates/docker/src/lib/plugins/__tests__/hooks.test.ts +2 -2
- package/templates/docker/src/lib/plugins/__tests__/migrate.test.ts +355 -1
- package/templates/docker/src/lib/plugins/__tests__/registry.test.ts +32 -5
- package/templates/docker/src/lib/plugins/__tests__/wiring.test.ts +228 -14
- package/templates/docker/src/lib/plugins/index.ts +4 -1
- package/templates/docker/src/lib/plugins/migrate.ts +104 -1
- package/templates/docker/src/lib/plugins/registry.ts +14 -8
- package/templates/docker/src/lib/plugins/wiring.ts +113 -4
- package/templates/docker/src/lib/providers.ts +6 -1
- package/templates/docker/src/lib/security.ts +24 -0
- package/templates/docker/src/lib/semantic.ts +2 -0
- package/templates/docker/src/lib/sidecar-types.ts +12 -1
- package/templates/docker/src/lib/startup.ts +71 -101
- package/templates/docker/src/lib/tools/__tests__/custom-validation.test.ts +2 -0
- package/templates/docker/src/lib/tools/__tests__/explore-nsjail.test.ts +32 -18
- package/templates/docker/src/lib/tools/__tests__/explore-plugin.test.ts +14 -14
- package/templates/docker/src/lib/tools/__tests__/explore-sdk-compat.test.ts +1 -1
- package/templates/docker/src/lib/tools/__tests__/explore-sidecar.test.ts +5 -3
- package/templates/docker/src/lib/tools/__tests__/python-nsjail.test.ts +515 -0
- package/templates/docker/src/lib/tools/__tests__/python-sandbox.test.ts +397 -0
- package/templates/docker/src/lib/tools/__tests__/python-sidecar.test.ts +365 -0
- package/templates/docker/src/lib/tools/__tests__/python.test.ts +331 -0
- package/templates/docker/src/lib/tools/__tests__/registry-actions.test.ts +1 -13
- package/templates/docker/src/lib/tools/__tests__/registry.test.ts +38 -31
- package/templates/docker/src/lib/tools/__tests__/sql-audit.test.ts +2 -0
- package/templates/docker/src/lib/tools/__tests__/sql-connection-whitelist.test.ts +2 -0
- package/templates/docker/src/lib/tools/__tests__/sql-ratelimit.test.ts +2 -0
- package/templates/docker/src/lib/tools/__tests__/sql.test.ts +5 -308
- package/templates/docker/src/lib/tools/explore-nsjail.ts +17 -12
- package/templates/docker/src/lib/tools/explore-sidecar.ts +25 -0
- package/templates/docker/src/lib/tools/explore.ts +28 -32
- package/templates/docker/src/lib/tools/python-nsjail.ts +396 -0
- package/templates/docker/src/lib/tools/python-sandbox.ts +476 -0
- package/templates/docker/src/lib/tools/python-sidecar.ts +150 -0
- package/templates/docker/src/lib/tools/python.ts +367 -0
- package/templates/docker/src/lib/tools/registry.ts +49 -22
- package/templates/docker/src/lib/tools/sql.ts +88 -88
- package/templates/docker/src/types/vercel-sandbox.d.ts +7 -0
- package/templates/docker/src/ui/components/admin/admin-layout.tsx +77 -8
- package/templates/docker/src/ui/components/admin/admin-sidebar.tsx +25 -17
- package/templates/docker/src/ui/components/admin/change-password-dialog.tsx +128 -0
- package/templates/docker/src/ui/components/admin/entity-detail.tsx +3 -3
- package/templates/docker/src/ui/components/admin/semantic-file-tree.tsx +159 -0
- package/templates/docker/src/ui/components/atlas-chat.tsx +64 -12
- package/templates/docker/src/ui/components/chart/result-chart.tsx +25 -15
- package/templates/docker/src/ui/components/chat/markdown.tsx +88 -42
- package/templates/docker/src/ui/components/chat/python-result-card.tsx +244 -0
- package/templates/docker/src/ui/components/chat/sql-block.tsx +39 -15
- package/templates/docker/src/ui/components/chat/sql-result-card.tsx +6 -1
- package/templates/docker/src/ui/components/chat/tool-part.tsx +12 -3
- package/templates/docker/src/ui/components/chat/typing-indicator.tsx +5 -2
- package/templates/docker/src/ui/components/conversations/conversation-item.tsx +25 -20
- package/templates/docker/src/ui/context.tsx +1 -1
- package/templates/docker/src/ui/hooks/use-conversations.ts +3 -3
- package/templates/docker/src/ui/hooks/use-dark-mode.ts +17 -10
- package/templates/docker/tsconfig.json +2 -2
- package/templates/nextjs-standalone/.env.example +1 -1
- package/templates/nextjs-standalone/bin/__tests__/plugin-cli.test.ts +11 -11
- package/templates/nextjs-standalone/bin/atlas.ts +120 -56
- package/templates/nextjs-standalone/data/demo-semantic/catalog.yml +51 -27
- package/templates/nextjs-standalone/data/demo-semantic/entities/accounts.yml +95 -103
- package/templates/nextjs-standalone/data/demo-semantic/entities/companies.yml +88 -152
- package/templates/nextjs-standalone/data/demo-semantic/entities/people.yml +82 -95
- package/templates/nextjs-standalone/data/demo-semantic/glossary.yml +104 -8
- package/templates/nextjs-standalone/data/demo-semantic/metrics/accounts.yml +62 -23
- package/templates/nextjs-standalone/data/demo-semantic/metrics/companies.yml +52 -78
- package/templates/nextjs-standalone/docs/deploy.md +4 -41
- package/templates/nextjs-standalone/package.json +11 -2
- package/templates/nextjs-standalone/scripts/migrate-auth.ts +25 -0
- package/templates/nextjs-standalone/scripts/seed-demo.ts +94 -0
- package/templates/nextjs-standalone/semantic/catalog.yml +62 -3
- package/templates/nextjs-standalone/semantic/entities/accounts.yml +162 -0
- package/templates/nextjs-standalone/semantic/entities/companies.yml +143 -0
- package/templates/nextjs-standalone/semantic/entities/people.yml +132 -0
- package/templates/nextjs-standalone/semantic/glossary.yml +116 -4
- package/templates/nextjs-standalone/semantic/metrics/accounts.yml +77 -0
- package/templates/nextjs-standalone/semantic/metrics/companies.yml +63 -0
- package/templates/nextjs-standalone/src/api/__tests__/admin.test.ts +7 -7
- package/templates/nextjs-standalone/src/api/__tests__/health-plugin.test.ts +7 -0
- package/templates/nextjs-standalone/src/api/__tests__/health.test.ts +30 -8
- package/templates/nextjs-standalone/src/api/routes/admin.ts +549 -8
- package/templates/nextjs-standalone/src/api/routes/chat.ts +5 -20
- package/templates/nextjs-standalone/src/api/routes/health.ts +39 -27
- package/templates/nextjs-standalone/src/api/routes/openapi.ts +1329 -74
- package/templates/nextjs-standalone/src/api/routes/query.ts +2 -1
- package/templates/nextjs-standalone/src/api/server.ts +27 -0
- package/templates/nextjs-standalone/src/app/api/[...route]/route.ts +2 -2
- package/templates/nextjs-standalone/src/app/globals.css +13 -12
- package/templates/nextjs-standalone/src/app/layout.tsx +9 -2
- package/templates/nextjs-standalone/src/components/ui/alert-dialog.tsx +196 -0
- package/templates/nextjs-standalone/src/components/ui/badge.tsx +48 -0
- package/templates/nextjs-standalone/src/components/ui/button.tsx +64 -0
- package/templates/nextjs-standalone/src/components/ui/card.tsx +92 -0
- package/templates/nextjs-standalone/src/components/ui/collapsible.tsx +33 -0
- package/templates/nextjs-standalone/src/components/ui/command.tsx +184 -0
- package/templates/nextjs-standalone/src/components/ui/dialog.tsx +158 -0
- package/templates/nextjs-standalone/src/components/ui/dropdown-menu.tsx +257 -0
- package/templates/nextjs-standalone/src/components/ui/input.tsx +21 -0
- package/templates/nextjs-standalone/src/components/ui/scroll-area.tsx +58 -0
- package/templates/nextjs-standalone/src/components/ui/select.tsx +190 -0
- package/templates/nextjs-standalone/src/components/ui/separator.tsx +28 -0
- package/templates/nextjs-standalone/src/components/ui/sheet.tsx +143 -0
- package/templates/nextjs-standalone/src/components/ui/sidebar.tsx +726 -0
- package/templates/nextjs-standalone/src/components/ui/skeleton.tsx +13 -0
- package/templates/nextjs-standalone/src/components/ui/table.tsx +116 -0
- package/templates/nextjs-standalone/src/components/ui/tabs.tsx +91 -0
- package/templates/nextjs-standalone/src/components/ui/toggle-group.tsx +83 -0
- package/templates/nextjs-standalone/src/components/ui/toggle.tsx +47 -0
- package/templates/nextjs-standalone/src/components/ui/tooltip.tsx +57 -0
- package/templates/nextjs-standalone/src/hooks/use-mobile.ts +19 -0
- package/templates/nextjs-standalone/src/lib/__tests__/agent-cache.test.ts +2 -0
- package/templates/nextjs-standalone/src/lib/__tests__/agent-dialect.test.ts +17 -0
- package/templates/nextjs-standalone/src/lib/__tests__/agent-health-annotations.test.ts +2 -0
- package/templates/nextjs-standalone/src/lib/__tests__/agent-integration.test.ts +2 -0
- package/templates/nextjs-standalone/src/lib/__tests__/config.test.ts +69 -19
- package/templates/nextjs-standalone/src/lib/__tests__/plugin-aware-validation.test.ts +321 -0
- package/templates/nextjs-standalone/src/lib/__tests__/providers.test.ts +32 -1
- package/templates/nextjs-standalone/src/lib/__tests__/startup-actions.test.ts +9 -0
- package/templates/nextjs-standalone/src/lib/__tests__/startup-first-run.test.ts +429 -0
- package/templates/nextjs-standalone/src/lib/__tests__/startup.test.ts +5 -0
- package/templates/nextjs-standalone/src/lib/agent-query.ts +5 -23
- package/templates/nextjs-standalone/src/lib/agent.ts +32 -112
- package/templates/nextjs-standalone/src/lib/auth/__tests__/migrate.test.ts +5 -3
- package/templates/nextjs-standalone/src/lib/auth/middleware.ts +30 -4
- package/templates/nextjs-standalone/src/lib/auth/migrate.ts +97 -0
- package/templates/nextjs-standalone/src/lib/auth/server.ts +12 -1
- package/templates/nextjs-standalone/src/lib/config.ts +38 -40
- package/templates/nextjs-standalone/src/lib/db/__tests__/connection.test.ts +89 -14
- package/templates/nextjs-standalone/src/lib/db/__tests__/registry-health.test.ts +1 -18
- package/templates/nextjs-standalone/src/lib/db/__tests__/registry-pool-limits.test.ts +0 -19
- package/templates/nextjs-standalone/src/lib/db/__tests__/registry.test.ts +11 -208
- package/templates/nextjs-standalone/src/lib/db/connection.ts +87 -265
- package/templates/nextjs-standalone/src/lib/db/internal.ts +6 -1
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/hooks-integration.test.ts +3 -1
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/hooks.test.ts +2 -2
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/migrate.test.ts +355 -1
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/registry.test.ts +32 -5
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/wiring.test.ts +228 -14
- package/templates/nextjs-standalone/src/lib/plugins/index.ts +4 -1
- package/templates/nextjs-standalone/src/lib/plugins/migrate.ts +104 -1
- package/templates/nextjs-standalone/src/lib/plugins/registry.ts +14 -8
- package/templates/nextjs-standalone/src/lib/plugins/wiring.ts +113 -4
- package/templates/nextjs-standalone/src/lib/providers.ts +6 -1
- package/templates/nextjs-standalone/src/lib/security.ts +24 -0
- package/templates/nextjs-standalone/src/lib/semantic.ts +2 -0
- package/templates/nextjs-standalone/src/lib/sidecar-types.ts +12 -1
- package/templates/nextjs-standalone/src/lib/startup.ts +71 -101
- package/templates/nextjs-standalone/src/lib/tools/__tests__/custom-validation.test.ts +2 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-nsjail.test.ts +32 -18
- package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-plugin.test.ts +14 -14
- package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-sdk-compat.test.ts +1 -1
- package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-sidecar.test.ts +5 -3
- package/templates/nextjs-standalone/src/lib/tools/__tests__/python-nsjail.test.ts +515 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/python-sandbox.test.ts +397 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/python-sidecar.test.ts +365 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/python.test.ts +331 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/registry-actions.test.ts +1 -13
- package/templates/nextjs-standalone/src/lib/tools/__tests__/registry.test.ts +38 -31
- package/templates/nextjs-standalone/src/lib/tools/__tests__/sql-audit.test.ts +2 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/sql-connection-whitelist.test.ts +2 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/sql-ratelimit.test.ts +2 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/sql.test.ts +5 -308
- package/templates/nextjs-standalone/src/lib/tools/explore-nsjail.ts +17 -12
- package/templates/nextjs-standalone/src/lib/tools/explore-sidecar.ts +25 -0
- package/templates/nextjs-standalone/src/lib/tools/explore.ts +28 -32
- package/templates/nextjs-standalone/src/lib/tools/python-nsjail.ts +396 -0
- package/templates/nextjs-standalone/src/lib/tools/python-sandbox.ts +476 -0
- package/templates/nextjs-standalone/src/lib/tools/python-sidecar.ts +150 -0
- package/templates/nextjs-standalone/src/lib/tools/python.ts +367 -0
- package/templates/nextjs-standalone/src/lib/tools/registry.ts +49 -22
- package/templates/nextjs-standalone/src/lib/tools/sql.ts +88 -88
- package/templates/nextjs-standalone/src/ui/components/admin/admin-layout.tsx +77 -8
- package/templates/nextjs-standalone/src/ui/components/admin/admin-sidebar.tsx +25 -17
- package/templates/nextjs-standalone/src/ui/components/admin/change-password-dialog.tsx +128 -0
- package/templates/nextjs-standalone/src/ui/components/admin/entity-detail.tsx +3 -3
- package/templates/nextjs-standalone/src/ui/components/admin/semantic-file-tree.tsx +159 -0
- package/templates/nextjs-standalone/src/ui/components/atlas-chat.tsx +64 -12
- package/templates/nextjs-standalone/src/ui/components/chart/result-chart.tsx +25 -15
- package/templates/nextjs-standalone/src/ui/components/chat/markdown.tsx +88 -42
- package/templates/nextjs-standalone/src/ui/components/chat/python-result-card.tsx +244 -0
- package/templates/nextjs-standalone/src/ui/components/chat/sql-block.tsx +39 -15
- package/templates/nextjs-standalone/src/ui/components/chat/sql-result-card.tsx +6 -1
- package/templates/nextjs-standalone/src/ui/components/chat/tool-part.tsx +12 -3
- package/templates/nextjs-standalone/src/ui/components/chat/typing-indicator.tsx +5 -2
- package/templates/nextjs-standalone/src/ui/components/conversations/conversation-item.tsx +25 -20
- package/templates/nextjs-standalone/src/ui/context.tsx +1 -1
- package/templates/nextjs-standalone/src/ui/hooks/use-conversations.ts +3 -3
- package/templates/nextjs-standalone/src/ui/hooks/use-dark-mode.ts +17 -10
- package/templates/nextjs-standalone/tsconfig.json +0 -1
- package/templates/nextjs-standalone/vercel.json +4 -1
- package/templates/docker/render.yaml +0 -34
- package/templates/docker/semantic/entities/.gitkeep +0 -0
- package/templates/docker/semantic/metrics/.gitkeep +0 -0
- package/templates/docker/src/lib/db/__tests__/duckdb.test.ts +0 -141
- package/templates/docker/src/lib/db/__tests__/salesforce.test.ts +0 -339
- package/templates/docker/src/lib/db/__tests__/snowflake.test.ts +0 -217
- package/templates/docker/src/lib/db/duckdb.ts +0 -122
- package/templates/docker/src/lib/db/salesforce.ts +0 -342
- package/templates/docker/src/lib/tools/__tests__/salesforce-tool.test.ts +0 -154
- package/templates/docker/src/lib/tools/__tests__/soql-validation.test.ts +0 -303
- package/templates/docker/src/lib/tools/__tests__/sql-duckdb.test.ts +0 -233
- package/templates/docker/src/lib/tools/salesforce.ts +0 -138
- package/templates/docker/src/lib/tools/soql-validation.ts +0 -172
- package/templates/nextjs-standalone/semantic/entities/.gitkeep +0 -0
- package/templates/nextjs-standalone/semantic/metrics/.gitkeep +0 -0
- package/templates/nextjs-standalone/src/lib/db/__tests__/duckdb.test.ts +0 -141
- package/templates/nextjs-standalone/src/lib/db/__tests__/salesforce.test.ts +0 -339
- package/templates/nextjs-standalone/src/lib/db/__tests__/snowflake.test.ts +0 -217
- package/templates/nextjs-standalone/src/lib/db/duckdb.ts +0 -122
- package/templates/nextjs-standalone/src/lib/db/salesforce.ts +0 -342
- package/templates/nextjs-standalone/src/lib/tools/__tests__/salesforce-tool.test.ts +0 -154
- package/templates/nextjs-standalone/src/lib/tools/__tests__/soql-validation.test.ts +0 -303
- package/templates/nextjs-standalone/src/lib/tools/__tests__/sql-duckdb.test.ts +0 -233
- package/templates/nextjs-standalone/src/lib/tools/salesforce.ts +0 -138
- package/templates/nextjs-standalone/src/lib/tools/soql-validation.ts +0 -172
|
@@ -1,10 +1,33 @@
|
|
|
1
|
-
import { describe, expect, it, beforeEach, afterEach, spyOn } from "bun:test";
|
|
1
|
+
import { describe, expect, it, beforeEach, afterEach, spyOn, mock } from "bun:test";
|
|
2
2
|
import * as fs from "fs";
|
|
3
3
|
|
|
4
4
|
// ---------------------------------------------------------------------------
|
|
5
5
|
// Mocks
|
|
6
6
|
// ---------------------------------------------------------------------------
|
|
7
7
|
|
|
8
|
+
// Mock structured logger — must be before explore-nsjail import
|
|
9
|
+
let logWarnCalls: unknown[][] = [];
|
|
10
|
+
let logErrorCalls: unknown[][] = [];
|
|
11
|
+
|
|
12
|
+
const mockLogger = {
|
|
13
|
+
info: () => {},
|
|
14
|
+
warn: (...args: unknown[]) => { logWarnCalls.push(args); },
|
|
15
|
+
error: (...args: unknown[]) => { logErrorCalls.push(args); },
|
|
16
|
+
debug: () => {},
|
|
17
|
+
fatal: () => {},
|
|
18
|
+
trace: () => {},
|
|
19
|
+
child: () => mockLogger,
|
|
20
|
+
level: "info",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
mock.module("@atlas/api/lib/logger", () => ({
|
|
24
|
+
createLogger: () => mockLogger,
|
|
25
|
+
getLogger: () => mockLogger,
|
|
26
|
+
withRequestContext: (_ctx: unknown, fn: () => unknown) => fn(),
|
|
27
|
+
getRequestContext: () => undefined,
|
|
28
|
+
redactPaths: [],
|
|
29
|
+
}));
|
|
30
|
+
|
|
8
31
|
// Track Bun.spawn calls
|
|
9
32
|
let spawnCalls: { args: unknown[]; options: unknown }[] = [];
|
|
10
33
|
let spawnResult: {
|
|
@@ -50,7 +73,8 @@ const callbacks = {
|
|
|
50
73
|
},
|
|
51
74
|
};
|
|
52
75
|
|
|
53
|
-
|
|
76
|
+
const { isNsjailAvailable, createNsjailBackend, testNsjailCapabilities } =
|
|
77
|
+
await import("@atlas/api/lib/tools/explore-nsjail");
|
|
54
78
|
|
|
55
79
|
// ---------------------------------------------------------------------------
|
|
56
80
|
// Helpers
|
|
@@ -145,6 +169,8 @@ describe("exec", () => {
|
|
|
145
169
|
spawnCalls = [];
|
|
146
170
|
invalidateCalled = false;
|
|
147
171
|
markFailedCalled = false;
|
|
172
|
+
logWarnCalls = [];
|
|
173
|
+
logErrorCalls = [];
|
|
148
174
|
setSpawnResult("", "", 0);
|
|
149
175
|
});
|
|
150
176
|
|
|
@@ -311,8 +337,6 @@ describe("exec", () => {
|
|
|
311
337
|
new Set(["/usr/local/bin/nsjail", SEMANTIC_ROOT]),
|
|
312
338
|
);
|
|
313
339
|
|
|
314
|
-
const warnSpy = spyOn(console, "warn").mockImplementation(() => {});
|
|
315
|
-
|
|
316
340
|
const backend = await createNsjailBackend(SEMANTIC_ROOT, callbacks);
|
|
317
341
|
await backend.exec("ls");
|
|
318
342
|
|
|
@@ -320,7 +344,6 @@ describe("exec", () => {
|
|
|
320
344
|
const tIndex = args.indexOf("-t");
|
|
321
345
|
expect(args[tIndex + 1]).toBe("10"); // default
|
|
322
346
|
|
|
323
|
-
warnSpy.mockRestore();
|
|
324
347
|
spy.mockRestore();
|
|
325
348
|
});
|
|
326
349
|
|
|
@@ -331,8 +354,6 @@ describe("exec", () => {
|
|
|
331
354
|
new Set(["/usr/local/bin/nsjail", SEMANTIC_ROOT]),
|
|
332
355
|
);
|
|
333
356
|
|
|
334
|
-
const warnSpy = spyOn(console, "warn").mockImplementation(() => {});
|
|
335
|
-
|
|
336
357
|
const backend = await createNsjailBackend(SEMANTIC_ROOT, callbacks);
|
|
337
358
|
await backend.exec("ls");
|
|
338
359
|
|
|
@@ -340,7 +361,6 @@ describe("exec", () => {
|
|
|
340
361
|
const tIndex = args.indexOf("-t");
|
|
341
362
|
expect(args[tIndex + 1]).toBe("10"); // default
|
|
342
363
|
|
|
343
|
-
warnSpy.mockRestore();
|
|
344
364
|
spy.mockRestore();
|
|
345
365
|
});
|
|
346
366
|
|
|
@@ -351,8 +371,6 @@ describe("exec", () => {
|
|
|
351
371
|
new Set(["/usr/local/bin/nsjail", SEMANTIC_ROOT]),
|
|
352
372
|
);
|
|
353
373
|
|
|
354
|
-
const warnSpy = spyOn(console, "warn").mockImplementation(() => {});
|
|
355
|
-
|
|
356
374
|
const backend = await createNsjailBackend(SEMANTIC_ROOT, callbacks);
|
|
357
375
|
await backend.exec("ls");
|
|
358
376
|
|
|
@@ -360,7 +378,6 @@ describe("exec", () => {
|
|
|
360
378
|
const memIndex = args.indexOf("--rlimit_as");
|
|
361
379
|
expect(args[memIndex + 1]).toBe("256"); // default
|
|
362
380
|
|
|
363
|
-
warnSpy.mockRestore();
|
|
364
381
|
spy.mockRestore();
|
|
365
382
|
});
|
|
366
383
|
|
|
@@ -371,7 +388,6 @@ describe("exec", () => {
|
|
|
371
388
|
);
|
|
372
389
|
|
|
373
390
|
setSpawnResult("", "nsjail setup failure", 109);
|
|
374
|
-
const errorSpy = spyOn(console, "error").mockImplementation(() => {});
|
|
375
391
|
|
|
376
392
|
const backend = await createNsjailBackend(SEMANTIC_ROOT, callbacks);
|
|
377
393
|
const result = await backend.exec("ls");
|
|
@@ -379,7 +395,6 @@ describe("exec", () => {
|
|
|
379
395
|
expect(result.exitCode).toBe(109);
|
|
380
396
|
expect(markFailedCalled).toBe(true);
|
|
381
397
|
|
|
382
|
-
errorSpy.mockRestore();
|
|
383
398
|
spy.mockRestore();
|
|
384
399
|
});
|
|
385
400
|
|
|
@@ -391,17 +406,16 @@ describe("exec", () => {
|
|
|
391
406
|
|
|
392
407
|
// Exit code 137 = 128 + 9 (SIGKILL)
|
|
393
408
|
setSpawnResult("", "", 137);
|
|
394
|
-
const warnSpy = spyOn(console, "warn").mockImplementation(() => {});
|
|
395
409
|
|
|
396
410
|
const backend = await createNsjailBackend(SEMANTIC_ROOT, callbacks);
|
|
397
411
|
const result = await backend.exec("sleep 999");
|
|
398
412
|
|
|
399
413
|
expect(result.exitCode).toBe(137);
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
414
|
+
// log.warn({ signal, command }, "nsjail child killed by signal")
|
|
415
|
+
expect(logWarnCalls.length).toBeGreaterThanOrEqual(1);
|
|
416
|
+
const warnObj = logWarnCalls[0][0] as { signal: number };
|
|
417
|
+
expect(warnObj.signal).toBe(9);
|
|
403
418
|
|
|
404
|
-
warnSpy.mockRestore();
|
|
405
419
|
spy.mockRestore();
|
|
406
420
|
});
|
|
407
421
|
});
|
|
@@ -67,7 +67,7 @@ mock.module("@atlas/api/lib/plugins/hooks", () => ({
|
|
|
67
67
|
|
|
68
68
|
let mockSandboxPlugins: Array<{
|
|
69
69
|
id: string;
|
|
70
|
-
|
|
70
|
+
types: string[];
|
|
71
71
|
version: string;
|
|
72
72
|
sandbox: {
|
|
73
73
|
create(root: string): Promise<ExploreBackend> | ExploreBackend;
|
|
@@ -146,7 +146,7 @@ describe("explore sandbox plugin integration", () => {
|
|
|
146
146
|
mockSandboxPlugins = [
|
|
147
147
|
{
|
|
148
148
|
id: "plugin-a",
|
|
149
|
-
|
|
149
|
+
types: ["sandbox"],
|
|
150
150
|
version: "1.0.0",
|
|
151
151
|
sandbox: { create: async () => backend },
|
|
152
152
|
},
|
|
@@ -165,7 +165,7 @@ describe("explore sandbox plugin integration", () => {
|
|
|
165
165
|
mockSandboxPlugins = [
|
|
166
166
|
{
|
|
167
167
|
id: "low-priority",
|
|
168
|
-
|
|
168
|
+
types: ["sandbox"],
|
|
169
169
|
version: "1.0.0",
|
|
170
170
|
sandbox: {
|
|
171
171
|
create: async () => makeMockBackend("low"),
|
|
@@ -174,7 +174,7 @@ describe("explore sandbox plugin integration", () => {
|
|
|
174
174
|
},
|
|
175
175
|
{
|
|
176
176
|
id: "high-priority",
|
|
177
|
-
|
|
177
|
+
types: ["sandbox"],
|
|
178
178
|
version: "1.0.0",
|
|
179
179
|
sandbox: {
|
|
180
180
|
create: async () => makeMockBackend("high"),
|
|
@@ -196,7 +196,7 @@ describe("explore sandbox plugin integration", () => {
|
|
|
196
196
|
mockSandboxPlugins = [
|
|
197
197
|
{
|
|
198
198
|
id: "broken-plugin",
|
|
199
|
-
|
|
199
|
+
types: ["sandbox"],
|
|
200
200
|
version: "1.0.0",
|
|
201
201
|
sandbox: {
|
|
202
202
|
create: async () => { throw new Error("init failed"); },
|
|
@@ -205,7 +205,7 @@ describe("explore sandbox plugin integration", () => {
|
|
|
205
205
|
},
|
|
206
206
|
{
|
|
207
207
|
id: "working-plugin",
|
|
208
|
-
|
|
208
|
+
types: ["sandbox"],
|
|
209
209
|
version: "1.0.0",
|
|
210
210
|
sandbox: {
|
|
211
211
|
create: async () => makeMockBackend("working"),
|
|
@@ -228,7 +228,7 @@ describe("explore sandbox plugin integration", () => {
|
|
|
228
228
|
mockSandboxPlugins = [
|
|
229
229
|
{
|
|
230
230
|
id: "broken-1",
|
|
231
|
-
|
|
231
|
+
types: ["sandbox"],
|
|
232
232
|
version: "1.0.0",
|
|
233
233
|
sandbox: {
|
|
234
234
|
create: async () => { throw new Error("fail 1"); },
|
|
@@ -236,7 +236,7 @@ describe("explore sandbox plugin integration", () => {
|
|
|
236
236
|
},
|
|
237
237
|
{
|
|
238
238
|
id: "broken-2",
|
|
239
|
-
|
|
239
|
+
types: ["sandbox"],
|
|
240
240
|
version: "1.0.0",
|
|
241
241
|
sandbox: {
|
|
242
242
|
create: async () => { throw new Error("fail 2"); },
|
|
@@ -255,7 +255,7 @@ describe("explore sandbox plugin integration", () => {
|
|
|
255
255
|
mockSandboxPlugins = [
|
|
256
256
|
{
|
|
257
257
|
id: "my-sandbox",
|
|
258
|
-
|
|
258
|
+
types: ["sandbox"],
|
|
259
259
|
version: "2.0.0",
|
|
260
260
|
sandbox: { create: async () => makeMockBackend("my-sandbox") },
|
|
261
261
|
},
|
|
@@ -274,7 +274,7 @@ describe("explore sandbox plugin integration", () => {
|
|
|
274
274
|
mockSandboxPlugins = [
|
|
275
275
|
{
|
|
276
276
|
id: "test-plugin",
|
|
277
|
-
|
|
277
|
+
types: ["sandbox"],
|
|
278
278
|
version: "1.0.0",
|
|
279
279
|
sandbox: { create: async () => makeMockBackend("test") },
|
|
280
280
|
},
|
|
@@ -297,7 +297,7 @@ describe("explore sandbox plugin integration", () => {
|
|
|
297
297
|
mockSandboxPlugins = [
|
|
298
298
|
{
|
|
299
299
|
id: "clearable-plugin",
|
|
300
|
-
|
|
300
|
+
types: ["sandbox"],
|
|
301
301
|
version: "1.0.0",
|
|
302
302
|
sandbox: { create: async () => makeMockBackend("clearable") },
|
|
303
303
|
},
|
|
@@ -321,7 +321,7 @@ describe("explore sandbox plugin integration", () => {
|
|
|
321
321
|
mockSandboxPlugins = [
|
|
322
322
|
{
|
|
323
323
|
id: "should-be-skipped",
|
|
324
|
-
|
|
324
|
+
types: ["sandbox"],
|
|
325
325
|
version: "1.0.0",
|
|
326
326
|
sandbox: { create: async () => makeMockBackend("skipped") },
|
|
327
327
|
},
|
|
@@ -343,7 +343,7 @@ describe("explore sandbox plugin integration", () => {
|
|
|
343
343
|
mockSandboxPlugins = [
|
|
344
344
|
{
|
|
345
345
|
id: "explicit-low",
|
|
346
|
-
|
|
346
|
+
types: ["sandbox"],
|
|
347
347
|
version: "1.0.0",
|
|
348
348
|
sandbox: {
|
|
349
349
|
create: async () => makeMockBackend("explicit-low"),
|
|
@@ -352,7 +352,7 @@ describe("explore sandbox plugin integration", () => {
|
|
|
352
352
|
},
|
|
353
353
|
{
|
|
354
354
|
id: "default-priority",
|
|
355
|
-
|
|
355
|
+
types: ["sandbox"],
|
|
356
356
|
version: "1.0.0",
|
|
357
357
|
sandbox: {
|
|
358
358
|
// No priority — defaults to 60 (SANDBOX_DEFAULT_PRIORITY)
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* assertions will fail at compile time.
|
|
8
8
|
*
|
|
9
9
|
* Both types are defined in this file to avoid a cross-package import
|
|
10
|
-
* (@atlas/api does not depend on @
|
|
10
|
+
* (@atlas/api does not depend on @useatlas/plugin-sdk by design).
|
|
11
11
|
*/
|
|
12
12
|
import { describe, test, expect } from "bun:test";
|
|
13
13
|
import type { ExecResult, ExploreBackend } from "../explore";
|
|
@@ -70,10 +70,12 @@ describe("sidecar exec", () => {
|
|
|
70
70
|
expect(result.stderr).toBe("");
|
|
71
71
|
expect(result.exitCode).toBe(0);
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
// Filter out the health check call made during createSidecarBackend init
|
|
74
|
+
const execCalls = fetchCalls.filter((c) => c.url.endsWith("/exec"));
|
|
75
|
+
expect(execCalls).toHaveLength(1);
|
|
76
|
+
expect(execCalls[0].url).toBe("http://localhost:8080/exec");
|
|
75
77
|
|
|
76
|
-
const body = JSON.parse(
|
|
78
|
+
const body = JSON.parse(execCalls[0].options.body as string);
|
|
77
79
|
expect(body.command).toBe("ls");
|
|
78
80
|
expect(body.timeout).toBe(10_000);
|
|
79
81
|
});
|