From 66b25d353de460b5290ba5f3fee06d9ef4418728 Mon Sep 17 00:00:00 2001 From: Vikhyath Mondreti Date: Tue, 4 Aug 2026 01:04:54 -0700 Subject: [PATCH 01/25] feat(code): cli sandboxes, enterprise timeouts, secrets projections, resolver lift --- .agents/skills/add-managed-cli/SKILL.md | 149 + .../skills/add-managed-cli/agents/openai.yaml | 4 + .claude/commands/add-managed-cli.md | 148 + .cursor/commands/add-managed-cli.md | 144 + .gitignore | 4 +- .../content/docs/en/agents/custom-tools.mdx | 6 +- .../content/docs/en/api-reference/python.mdx | 3 +- .../docs/en/api-reference/typescript.mdx | 1 + apps/docs/content/docs/en/platform/costs.mdx | 5 +- .../content/docs/en/platform/credentials.mdx | 6 +- .../en/platform/enterprise/self-hosted.mdx | 87 +- .../docs/en/workflows/blocks/function.mdx | 273 +- .../content/docs/en/workflows/blocks/pi.mdx | 2 +- .../docs/en/workflows/deployment/api.mdx | 8 +- .../content/docs/en/workflows/how-it-runs.mdx | 2 +- .../content/docs/en/workflows/variables.mdx | 2 +- apps/docs/openapi.json | 22 + apps/sim/.env.example | 20 + .../cleanup-stale-executions/route.test.ts | 138 + .../cron/cleanup-stale-executions/route.ts | 341 +- .../app/api/function/execute/route.test.ts | 788 +- apps/sim/app/api/function/execute/route.ts | 770 +- apps/sim/app/api/guardrails/validate/route.ts | 16 +- .../app/api/mcp/tools/execute/route.test.ts | 51 +- apps/sim/app/api/mcp/tools/execute/route.ts | 25 +- .../app/api/mothership/execute/route.test.ts | 128 +- apps/sim/app/api/mothership/execute/route.ts | 50 +- apps/sim/app/api/providers/route.test.ts | 40 +- apps/sim/app/api/providers/route.ts | 65 +- .../[executionId]/[contextId]/route.test.ts | 102 +- .../[executionId]/[contextId]/route.ts | 43 +- .../app/api/schedules/execute/route.test.ts | 90 +- apps/sim/app/api/schedules/execute/route.ts | 125 +- apps/sim/app/api/tools/image/route.ts | 4 +- apps/sim/app/api/tools/stt/route.ts | 4 +- .../tools/textract/analyze-expense/route.ts | 2 +- .../sim/app/api/tools/textract/parse/route.ts | 4 +- apps/sim/app/api/tools/video/route.ts | 4 +- apps/sim/app/api/wand/route.ts | 7 +- .../[id]/execute/route.async.test.ts | 317 +- .../app/api/workflows/[id]/execute/route.ts | 173 +- .../[executionId]/cancel/route.test.ts | 203 +- .../executions/[executionId]/cancel/route.ts | 250 +- apps/sim/app/api/workflows/utils.ts | 29 +- .../[id]/sandboxes/[sandboxId]/route.ts | 19 +- .../[id]/sandboxes/authorize.test.ts | 36 + .../workspaces/[id]/sandboxes/authorize.ts | 35 +- .../api/workspaces/[id]/sandboxes/route.ts | 6 +- .../use-custom-tool-generation.ts | 2 +- .../log-row-context-menu.test.tsx | 144 + .../log-row-context-menu.tsx | 17 +- .../app/workspace/[workspaceId]/logs/logs.tsx | 17 +- .../components/managed-cli-select.tsx | 51 + .../components/sandbox-create-modal.tsx | 52 +- .../components/sandbox-editor.test.tsx | 224 + .../sandboxes/components/sandbox-editor.tsx | 113 +- .../components/sandboxes/sandboxes.tsx | 94 +- .../components/sandboxes/utils.test.ts | 106 +- .../settings/components/sandboxes/utils.ts | 71 +- .../[workspaceId]/settings/navigation.test.ts | 14 +- .../sub-block/components/code/code.tsx | 53 +- .../components/combobox/combobox.tsx | 26 + .../combobox/missing-option.test.ts | 37 + .../components/combobox/missing-option.ts | 24 + .../sub-block/hooks/use-fetched-options.ts | 63 +- .../components/output-panel/output-panel.tsx | 10 +- .../settings-sidebar/settings-sidebar.tsx | 2 + .../async-preprocessing-correlation.test.ts | 76 +- apps/sim/background/resume-execution.test.ts | 46 +- apps/sim/background/resume-execution.ts | 107 +- apps/sim/background/sandbox-image-build.ts | 40 +- .../sim/background/schedule-execution.test.ts | 62 +- apps/sim/background/schedule-execution.ts | 913 +- apps/sim/background/webhook-execution.test.ts | 10 + apps/sim/background/webhook-execution.ts | 144 +- .../workflow-column-execution.test.ts | 168 + .../background/workflow-column-execution.ts | 1323 +- apps/sim/background/workflow-execution.ts | 288 +- apps/sim/blocks/blocks.test.ts | 3 + apps/sim/blocks/blocks/function.ts | 37 +- apps/sim/blocks/types.ts | 4 +- .../components/settings/navigation.test.ts | 30 +- apps/sim/components/settings/navigation.ts | 26 - .../executor/execution/block-executor.test.ts | 13 +- apps/sim/executor/execution/engine.test.ts | 34 + apps/sim/executor/execution/engine.ts | 25 +- .../execution/snapshot-serializer.test.ts | 23 + .../executor/execution/snapshot-serializer.ts | 7 +- apps/sim/executor/execution/types.ts | 2 + .../handlers/agent/agent-handler.test.ts | 278 + .../executor/handlers/agent/agent-handler.ts | 347 +- .../executor/handlers/agent/memory.test.ts | 244 + apps/sim/executor/handlers/agent/memory.ts | 106 +- .../handlers/agent/skills-resolver.test.ts | 45 +- .../handlers/agent/skills-resolver.ts | 23 +- .../condition/condition-handler.test.ts | 15 +- .../handlers/condition/condition-handler.ts | 26 +- .../function/function-handler.test.ts | 36 + .../handlers/function/function-handler.ts | 17 +- .../mothership/mothership-handler.test.ts | 231 +- .../handlers/mothership/mothership-handler.ts | 88 +- .../handlers/router/router-handler.test.ts | 126 + .../handlers/router/router-handler.ts | 45 +- .../handlers/shared/response-format.test.ts | 34 + .../handlers/shared/response-format.ts | 7 +- .../workflow/custom-block-tool-runner.test.ts | 32 + .../workflow/custom-block-tool-runner.ts | 17 +- .../workflow/workflow-handler.test.ts | 50 +- .../handlers/workflow/workflow-handler.ts | 34 +- .../utils/code-secret-references.test.ts | 20 +- .../executor/utils/code-secret-references.ts | 33 +- ...resolved-secret-content-projection.test.ts | 202 + .../resolved-secret-content-projection.ts | 481 +- .../utils/resolved-secret-matcher-capacity.ts | 37 + .../utils/resolved-secret-matcher.test.ts | 51 + .../executor/utils/resolved-secret-matcher.ts | 299 + .../resolved-secret-trace-registry.test.ts | 173 +- .../utils/resolved-secret-trace-registry.ts | 321 +- apps/sim/executor/variables/resolver.test.ts | 144 + apps/sim/executor/variables/resolver.ts | 80 +- apps/sim/hooks/queries/logs.test.tsx | 200 + apps/sim/hooks/queries/logs.ts | 72 +- apps/sim/hooks/queries/sandboxes.ts | 17 + .../lib/admin/dashboard-organizations.test.ts | 1 + apps/sim/lib/admin/dashboard.ts | 29 + apps/sim/lib/api/contracts/hotspots.test.ts | 27 + apps/sim/lib/api/contracts/logs.ts | 26 - apps/sim/lib/api/contracts/sandboxes.test.ts | 168 + apps/sim/lib/api/contracts/sandboxes.ts | 50 +- .../api/contracts/v1/admin/dashboard.test.ts | 1 + .../lib/api/contracts/v1/admin/dashboard.ts | 36 +- apps/sim/lib/api/contracts/workflows.ts | 11 + .../calculations/usage-reservation.test.ts | 48 + .../billing/calculations/usage-reservation.ts | 102 +- .../billing/core/billing-attribution.test.ts | 9 +- .../lib/billing/core/billing-attribution.ts | 23 + apps/sim/lib/billing/enterprise-outbox.ts | 10 + .../billing/enterprise-provisioning.test.ts | 38 +- .../lib/billing/enterprise-provisioning.ts | 33 +- .../execution-timeout-defaults.test.ts | 32 + .../lib/billing/execution-timeout-defaults.ts | 25 + apps/sim/lib/billing/types/index.test.ts | 24 + apps/sim/lib/billing/types/index.ts | 8 + apps/sim/lib/compare/data/sim.ts | 8 +- apps/sim/lib/content/code.tsx | 2 +- apps/sim/lib/content/mdx.tsx | 5 +- apps/sim/lib/copilot/chat/post.ts | 89 +- .../sim/lib/copilot/chat/workspace-context.ts | 13 +- apps/sim/lib/copilot/environment-context.ts | 10 +- .../lib/copilot/generated/tool-catalog-v1.ts | 4 +- .../lib/copilot/generated/tool-schemas-v1.ts | 4 +- apps/sim/lib/copilot/model-visible-content.ts | 40 + .../lib/copilot/model-visible-schema.test.ts | 105 + apps/sim/lib/copilot/model-visible-schema.ts | 177 + .../lib/copilot/request/lifecycle/run.test.ts | 769 +- apps/sim/lib/copilot/request/lifecycle/run.ts | 654 +- .../copilot/request/lifecycle/start.test.ts | 41 + .../lib/copilot/request/lifecycle/start.ts | 15 +- .../copilot/request/tool-call-state.test.ts | 24 +- .../lib/copilot/request/tool-call-state.ts | 4 +- .../lib/copilot/request/tools/client.test.ts | 41 +- apps/sim/lib/copilot/request/tools/client.ts | 49 +- .../copilot/request/tools/executor.test.ts | 32 + .../sim/lib/copilot/request/tools/executor.ts | 64 +- .../tools/resolved-secret-result.test.ts | 172 +- .../request/tools/resolved-secret-result.ts | 107 +- .../lib/copilot/secret-mount-policy.test.ts | 25 + apps/sim/lib/copilot/secret-mount-policy.ts | 17 + .../tools/handlers/deployment/context.test.ts | 28 +- .../tools/handlers/deployment/context.ts | 19 +- .../tools/handlers/deployment/deploy.test.ts | 73 +- .../tools/handlers/deployment/deploy.ts | 35 +- .../tools/handlers/deployment/manage.test.ts | 2 +- .../tools/handlers/deployment/manage.ts | 15 +- .../tools/handlers/function-execute.test.ts | 55 +- .../tools/handlers/function-execute.ts | 2 +- .../lib/copilot/tools/handlers/vfs.test.ts | 20 + apps/sim/lib/copilot/tools/handlers/vfs.ts | 17 +- .../tools/handlers/workflow/queries.ts | 6 +- apps/sim/lib/copilot/vfs/serializers.test.ts | 14 + apps/sim/lib/copilot/vfs/serializers.ts | 16 +- apps/sim/lib/copilot/vfs/workspace-vfs.ts | 182 +- .../core/async-jobs/backends/database.test.ts | 288 + .../lib/core/async-jobs/backends/database.ts | 217 +- .../async-jobs/backends/trigger-dev.test.ts | 436 +- .../core/async-jobs/backends/trigger-dev.ts | 276 +- apps/sim/lib/core/async-jobs/index.ts | 1 + apps/sim/lib/core/async-jobs/types.test.ts | 11 +- apps/sim/lib/core/async-jobs/types.ts | 26 +- apps/sim/lib/core/config/env-flags.ts | 59 +- apps/sim/lib/core/config/env.ts | 24 +- apps/sim/lib/core/execution-limits/errors.ts | 7 + apps/sim/lib/core/execution-limits/index.ts | 1 + apps/sim/lib/core/execution-limits/metrics.ts | 111 + .../lib/core/execution-limits/types.test.ts | 50 +- apps/sim/lib/core/execution-limits/types.ts | 124 +- apps/sim/lib/core/idempotency/service.test.ts | 199 +- apps/sim/lib/core/idempotency/service.ts | 276 +- apps/sim/lib/execution/cancellation.test.ts | 80 +- apps/sim/lib/execution/cancellation.ts | 22 +- .../code-placeholders/compiler.test.ts | 1030 + .../lib/execution/code-placeholders/index.ts | 54 + .../code-placeholders/javascript-runtime.ts | 33 + .../execution/code-placeholders/javascript.ts | 747 + .../lib/execution/code-placeholders/python.ts | 776 + .../lib/execution/code-placeholders/shared.ts | 223 + .../lib/execution/code-placeholders/shell.ts | 805 + .../lib/execution/code-placeholders/types.ts | 73 + .../execution-deadline-header.test.ts | 31 + .../execution/execution-deadline-header.ts | 29 + apps/sim/lib/execution/isolated-vm-worker.cjs | 24 +- apps/sim/lib/execution/isolated-vm.test.ts | 44 +- apps/sim/lib/execution/isolated-vm.ts | 24 +- apps/sim/lib/execution/manual-cancellation.ts | 13 +- apps/sim/lib/execution/preprocessing.test.ts | 5 + apps/sim/lib/execution/preprocessing.ts | 63 +- .../execution/private-tool-metadata.test.ts | 66 + .../lib/execution/private-tool-metadata.ts | 59 + .../remote-sandbox/cli-tools-boundary.test.ts | 143 + .../remote-sandbox/cli-tools.server.ts | 469 + .../remote-sandbox/cli-tools.test.ts | 242 + .../lib/execution/remote-sandbox/cli-tools.ts | 263 + .../remote-sandbox/conformance.test.ts | 1232 +- .../lib/execution/remote-sandbox/daytona.ts | 383 +- .../e2b-system-packages.test.ts | 181 + apps/sim/lib/execution/remote-sandbox/e2b.ts | 553 +- .../fellows-digest.acceptance.test.ts | 202 + .../fixtures/fellows-council-weekly.py | 3087 +++ .../fixtures/run-fellows-council-weekly.py | 164 + .../remote-sandbox/function-resources.ts | 7 + .../google-cloud-cli.smoke.test.ts | 101 + .../remote-sandbox/image-registry.test.ts | 729 +- .../remote-sandbox/image-registry.ts | 555 +- .../sim/lib/execution/remote-sandbox/index.ts | 480 +- .../remote-sandbox/managed-cli.smoke.test.ts | 70 + .../execution/remote-sandbox/output-limits.ts | 95 + .../remote-sandbox/pi-lifetime.test.ts | 40 +- .../execution/remote-sandbox/pi-lifetime.ts | 77 +- .../lib/execution/remote-sandbox/provider.ts | 7 +- .../execution/remote-sandbox/resolve.test.ts | 326 +- .../lib/execution/remote-sandbox/resolve.ts | 278 +- .../remote-sandbox/sandbox-spec.test.ts | 191 +- .../execution/remote-sandbox/sandbox-spec.ts | 207 +- .../sim/lib/execution/remote-sandbox/types.ts | 93 +- .../remote-sandbox/wand-enricher.test.ts | 81 + .../execution/remote-sandbox/wand-enricher.ts | 81 +- .../remote-sandbox/workspace-sandboxes.ts | 50 +- .../guardrails/validate_hallucination.test.ts | 71 + .../lib/guardrails/validate_hallucination.ts | 63 +- apps/sim/lib/logs/execution/logger.test.ts | 80 +- apps/sim/lib/logs/execution/logger.ts | 80 +- .../logs/execution/logging-session.test.ts | 137 +- .../sim/lib/logs/execution/logging-session.ts | 94 +- .../logs/execution/progress-markers.test.ts | 10 +- .../lib/logs/execution/progress-markers.ts | 31 +- .../execution/trace-secret-projection.test.ts | 69 +- .../logs/execution/trace-secret-projection.ts | 1 + apps/sim/lib/logs/types.ts | 14 +- apps/sim/lib/mothership/inbox/executor.ts | 11 +- apps/sim/lib/table/rows/executions.test.ts | 32 + apps/sim/lib/table/rows/executions.ts | 18 +- apps/sim/lib/table/workflow-columns.test.ts | 56 +- apps/sim/lib/table/workflow-columns.ts | 364 +- apps/sim/lib/webhooks/processor.test.ts | 59 +- apps/sim/lib/webhooks/processor.ts | 82 +- .../custom-blocks/child-execution.test.ts | 15 + .../custom-blocks/child-execution.ts | 19 +- .../workflows/executor/execution-core.test.ts | 113 +- .../lib/workflows/executor/execution-core.ts | 89 +- .../human-in-the-loop-manager.test.ts | 240 +- .../executor/human-in-the-loop-manager.ts | 166 +- .../workflows/orchestration/deploy.test.ts | 19 +- .../sim/lib/workflows/orchestration/deploy.ts | 38 +- apps/sim/lib/workflows/persistence/utils.ts | 9 +- .../lib/workflows/subblocks/options.test.ts | 103 + apps/sim/lib/workflows/subblocks/options.ts | 45 +- apps/sim/providers/index.test.ts | 643 +- apps/sim/providers/index.ts | 330 +- apps/sim/providers/runtime-context.test.ts | 214 + apps/sim/providers/runtime-context.ts | 124 +- apps/sim/providers/utils.ts | 2 +- apps/sim/proxy.test.ts | 1 + apps/sim/proxy.ts | 2 +- .../build-function-daytona-snapshot.ts | 145 + .../scripts/build-function-e2b-template.ts | 114 + apps/sim/scripts/function-e2b-release.test.ts | 68 + apps/sim/scripts/function-e2b-release.ts | 56 + .../scripts/function-sandbox-packages.test.ts | 212 + apps/sim/scripts/function-sandbox-packages.ts | 248 + .../function-sandbox-parity-manifest.test.ts | 114 + .../function-sandbox-parity-manifest.ts | 324 + apps/sim/scripts/verify-sandbox-parity.ts | 383 +- apps/sim/tools/function/execute.ts | 8 +- apps/sim/tools/generated/tool-metadata.ts | 2 +- apps/sim/tools/generated/tool-outputs.ts | 2 +- apps/sim/tools/index.test.ts | 308 +- apps/sim/tools/index.ts | 421 +- apps/sim/vitest.setup.ts | 1 + .../migrations/0282_steep_ted_forrester.sql | 13 + .../db/migrations/meta/0282_snapshot.json | 18441 ++++++++++++++++ packages/db/migrations/meta/_journal.json | 7 + packages/db/schema.ts | 9 + .../chip-select/chip-select.test.ts | 40 + .../components/chip-select/chip-select.tsx | 30 +- packages/emcn/src/components/code/code.tsx | 6 +- packages/emcn/src/components/code/prism.ts | 1 + packages/python-sdk/README.md | 13 +- packages/python-sdk/simstudio/__init__.py | 31 +- packages/python-sdk/tests/test_client.py | 75 +- .../testing/src/mocks/logging-session.mock.ts | 2 + packages/ts-sdk/README.md | 8 +- packages/ts-sdk/src/index.test.ts | 37 + packages/ts-sdk/src/index.ts | 38 +- packages/utils/package.json | 4 + packages/utils/src/sandbox-references.test.ts | 82 + packages/utils/src/sandbox-references.ts | 76 + scripts/setup/checks.ts | 106 +- 317 files changed, 54036 insertions(+), 4366 deletions(-) create mode 100644 .agents/skills/add-managed-cli/SKILL.md create mode 100644 .agents/skills/add-managed-cli/agents/openai.yaml create mode 100644 .claude/commands/add-managed-cli.md create mode 100644 .cursor/commands/add-managed-cli.md create mode 100644 apps/sim/app/api/cron/cleanup-stale-executions/route.test.ts create mode 100644 apps/sim/app/api/workspaces/[id]/sandboxes/authorize.test.ts create mode 100644 apps/sim/app/workspace/[workspaceId]/logs/components/log-row-context-menu/log-row-context-menu.test.tsx create mode 100644 apps/sim/app/workspace/[workspaceId]/settings/components/sandboxes/components/managed-cli-select.tsx create mode 100644 apps/sim/app/workspace/[workspaceId]/settings/components/sandboxes/components/sandbox-editor.test.tsx create mode 100644 apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/combobox/missing-option.test.ts create mode 100644 apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/combobox/missing-option.ts create mode 100644 apps/sim/background/workflow-column-execution.test.ts create mode 100644 apps/sim/executor/handlers/shared/response-format.test.ts create mode 100644 apps/sim/executor/utils/resolved-secret-content-projection.test.ts create mode 100644 apps/sim/executor/utils/resolved-secret-matcher-capacity.ts create mode 100644 apps/sim/executor/utils/resolved-secret-matcher.test.ts create mode 100644 apps/sim/executor/utils/resolved-secret-matcher.ts create mode 100644 apps/sim/hooks/queries/logs.test.tsx create mode 100644 apps/sim/lib/api/contracts/hotspots.test.ts create mode 100644 apps/sim/lib/api/contracts/sandboxes.test.ts create mode 100644 apps/sim/lib/billing/execution-timeout-defaults.test.ts create mode 100644 apps/sim/lib/billing/execution-timeout-defaults.ts create mode 100644 apps/sim/lib/copilot/model-visible-content.ts create mode 100644 apps/sim/lib/copilot/model-visible-schema.test.ts create mode 100644 apps/sim/lib/copilot/model-visible-schema.ts create mode 100644 apps/sim/lib/core/execution-limits/errors.ts create mode 100644 apps/sim/lib/core/execution-limits/metrics.ts create mode 100644 apps/sim/lib/execution/code-placeholders/compiler.test.ts create mode 100644 apps/sim/lib/execution/code-placeholders/index.ts create mode 100644 apps/sim/lib/execution/code-placeholders/javascript-runtime.ts create mode 100644 apps/sim/lib/execution/code-placeholders/javascript.ts create mode 100644 apps/sim/lib/execution/code-placeholders/python.ts create mode 100644 apps/sim/lib/execution/code-placeholders/shared.ts create mode 100644 apps/sim/lib/execution/code-placeholders/shell.ts create mode 100644 apps/sim/lib/execution/code-placeholders/types.ts create mode 100644 apps/sim/lib/execution/execution-deadline-header.test.ts create mode 100644 apps/sim/lib/execution/execution-deadline-header.ts create mode 100644 apps/sim/lib/execution/remote-sandbox/cli-tools-boundary.test.ts create mode 100644 apps/sim/lib/execution/remote-sandbox/cli-tools.server.ts create mode 100644 apps/sim/lib/execution/remote-sandbox/cli-tools.test.ts create mode 100644 apps/sim/lib/execution/remote-sandbox/cli-tools.ts create mode 100644 apps/sim/lib/execution/remote-sandbox/e2b-system-packages.test.ts create mode 100644 apps/sim/lib/execution/remote-sandbox/fellows-digest.acceptance.test.ts create mode 100644 apps/sim/lib/execution/remote-sandbox/fixtures/fellows-council-weekly.py create mode 100644 apps/sim/lib/execution/remote-sandbox/fixtures/run-fellows-council-weekly.py create mode 100644 apps/sim/lib/execution/remote-sandbox/function-resources.ts create mode 100644 apps/sim/lib/execution/remote-sandbox/google-cloud-cli.smoke.test.ts create mode 100644 apps/sim/lib/execution/remote-sandbox/managed-cli.smoke.test.ts create mode 100644 apps/sim/lib/execution/remote-sandbox/output-limits.ts create mode 100644 apps/sim/lib/execution/remote-sandbox/wand-enricher.test.ts create mode 100644 apps/sim/lib/guardrails/validate_hallucination.test.ts create mode 100644 apps/sim/lib/workflows/subblocks/options.test.ts create mode 100644 apps/sim/scripts/build-function-daytona-snapshot.ts create mode 100644 apps/sim/scripts/build-function-e2b-template.ts create mode 100644 apps/sim/scripts/function-e2b-release.test.ts create mode 100644 apps/sim/scripts/function-e2b-release.ts create mode 100644 apps/sim/scripts/function-sandbox-packages.test.ts create mode 100644 apps/sim/scripts/function-sandbox-packages.ts create mode 100644 apps/sim/scripts/function-sandbox-parity-manifest.test.ts create mode 100644 apps/sim/scripts/function-sandbox-parity-manifest.ts create mode 100644 packages/db/migrations/0282_steep_ted_forrester.sql create mode 100644 packages/db/migrations/meta/0282_snapshot.json create mode 100644 packages/emcn/src/components/chip-select/chip-select.test.ts create mode 100644 packages/utils/src/sandbox-references.test.ts create mode 100644 packages/utils/src/sandbox-references.ts diff --git a/.agents/skills/add-managed-cli/SKILL.md b/.agents/skills/add-managed-cli/SKILL.md new file mode 100644 index 00000000000..906d99e5257 --- /dev/null +++ b/.agents/skills/add-managed-cli/SKILL.md @@ -0,0 +1,149 @@ +--- +name: add-managed-cli +description: Add or upgrade a curated, immutable managed CLI for Sim Function sandboxes, including client-safe catalog metadata, a pinned server-only installation recipe, checksum and executable verification, provider compatibility, PATH propagation, content-addressed image identity, and tests. Use when adding a CLI to the Sandbox managed-CLI selector or changing an existing managed CLI version or recipe. +--- + +# Add a Managed CLI + +Add CLIs through the curated registry. Never turn this surface into arbitrary commands or package names: system packages already cover validated Debian/APT coordinates, while managed CLIs require immutable artifacts and reproducible recipes. + +## Read First + +Read these live sources before editing; do not copy their current entries into this skill: + +1. `apps/sim/lib/execution/remote-sandbox/cli-tools.ts` — persisted IDs and client-safe metadata. +2. `apps/sim/lib/execution/remote-sandbox/cli-tools.server.ts` — server-only recipes and recipe helpers. +3. `apps/sim/lib/execution/remote-sandbox/cli-tools.test.ts` — catalog and supply-chain invariants. +4. `apps/sim/lib/execution/remote-sandbox/cli-tools-boundary.test.ts` — client/server import boundary. +5. `apps/sim/lib/execution/remote-sandbox/sandbox-spec.ts` — content-addressed hash inputs. + +Read `resolve.ts` and `e2b.ts` only when changing provisioning mechanics. A normal catalog addition should not require UI, API, database, resolver, or provider edits; those paths derive from the registries. + +Do not modify the dedicated Function base image or the separate Mothership Shell template for a normal managed CLI addition. Managed recipes layer on the Function base image. Do not change `MAX_SANDBOX_CLI_TOOLS` from ten unless the user separately requests a product-limit change. + +## 1. Verify the Upstream Release + +Use primary upstream release documentation and official artifacts. Establish all of the following before writing code: + +- Exact version and stable Linux x86-64 artifact URL. Never use `latest`, mutable redirects, or an unversioned installer. +- SHA-256 for the exact artifact. Prefer a publisher-signed checksum; otherwise download the official artifact and compute it independently. +- Archive layout and the exact executable paths to install. +- Noninteractive, credential-free verification commands for every advertised executable, normally version commands. +- Required PATH entries under `/opt/sim-cli`. +- E2B and Daytona compatibility. Default to both only when the same Linux recipe works on both. + +When the user does not name a version, select the current stable upstream release from primary sources and state the exact version chosen. Do not silently choose a prerelease or infer a version from an unverified secondary source. + +Reject curl-to-shell installers, `npm install`, `pip install`, distro package repositories, arbitrary user commands, and artifacts from unofficial mirrors. Never place credentials, tokens, login commands, or account configuration in an image recipe or build log; authentication is runtime-only. + +## 2. Choose an Immutable ID + +Use `@-r`. + +- New upstream version: append a new ID ending in `-r1`. +- Recipe-only change for the same upstream version: append `-r2`, `-r3`, and so on. +- Never mutate or delete an existing ID or recipe. Persisted sandboxes must continue resolving to the bytes and behavior they selected. +- On upgrade, retain the old ID and recipe and set its metadata to `selectable: false`. Only the newest version keeps the public label selectable. + +Before shipping the first upgrade for a tool family, verify that editing a sandbox cannot leave both the retired and replacement IDs selected. If the generic selector and API validation do not already replace or reject colliding versions, address that once at the generic registry boundary with focused UI and contract tests; never special-case the individual CLI or silently install two versions that expose the same executable. + +Recipe identity includes the ID, revision, and SHA-256 in the sandbox image hash. Keeping old entries is what makes that identity reproducible rather than merely cache-busting. + +## 3. Add Client-Safe Metadata + +In `cli-tools.ts`: + +1. Append the ID to `SANDBOX_CLI_TOOL_IDS` in the same order used by the metadata and recipe registries. +2. Add a `SANDBOX_CLI_TOOLS` entry whose key and `id` exactly match. +3. Provide a unique selectable `label`, concise `description`, existing `category`, and useful executable/vendor aliases in `searchTerms`. +4. Add a category only when no existing category is accurate, then ensure it has at least one selectable entry. + +Keep this file safe for client bundles. It must not contain artifact URLs, checksums, install commands, verification commands, PATH recipes, provider SDKs, or imports from `cli-tools.server.ts`. + +The API enum and searchable grouped selector derive from this registry. Do not add parallel option arrays or route-local wire types. + +## 4. Add the Server-Only Recipe + +In `cli-tools.server.ts`, use the narrowest existing helper: + +- `defineBinaryRecipe` for one downloaded binary. +- `defineTarGzipRecipe` or `defineZipRecipe` for archives containing binaries. +- `defineVerifiedRecipe` for a vendor archive or installer layout that needs explicit commands. +- A direct typed entry only when the helpers cannot faithfully model the release. + +Provide every field the recipe contract requires: + +- Exact `version`, `artifactUrl`, `artifactName`, and lowercase 64-character `sha256`. +- Every installed `executable` and a corresponding `verificationCommands` entry. +- Deterministic extraction/install commands into `/opt/sim-cli`; quote fixed paths and clean temporary artifacts. +- `pathEntries` when the executable is not installed into the helper's default `bin` directory. +- `supportedProviders` only when it differs from the E2B-and-Daytona default. +- `revision` when it differs from `1`; it must agree with the ID suffix. + +Verification must prove the command is discoverable through `sandboxCliEnvironment`, not authenticate or contact a user account. Recipe commands run as root during both prebuilt image creation and runtime provisioning. + +If the artifact host is new, add only the exact official hostname to the `officialHosts` allowlist in `cli-tools.test.ts`. Treat that as a supply-chain review, not a way to silence the test. + +## 5. Preserve Generic Behavior + +Confirm the existing generic paths remain sufficient: + +- `sandboxCliToolRecipes` canonicalizes and resolves the recipe. +- `sandboxCliEnvironment` propagates PATH to Python subprocesses, JavaScript subprocesses, and Shell. +- E2B bakes the recipe into the custom image; runtime-strategy providers install it within the Function timeout. +- CLI-only sandboxes remain buildable even with no language packages. +- `hashSandboxSpec` includes recipe ID, revision, and checksum while preserving the legacy hash for an empty CLI list. +- The settings selector derives groups and search aliases from client-safe metadata. + +Do not special-case a CLI in those layers unless the registry contract cannot express a genuine provider requirement. Extend the registry contract generically when multiple CLIs need the same new behavior. + +## 6. Test the Addition + +Extend tests when the new entry introduces behavior not already covered: + +- For every upgrade, add a regression proving the old ID and recipe remain resolvable but non-selectable, while the replacement ID is selectable. +- Add important executable aliases to the table-driven search assertion. +- Add a focused assertion for a multi-executable recipe, custom PATH, or restricted provider. +- Add an opt-in credentialed smoke test only when installation plus a real minimal command cannot be validated without authentication. Read credentials from test-only environment variables, skip by default, create them only at runtime, and always tear down the sandbox. + +Never commit downloaded artifacts or credentials. + +## Required Validation + +From `apps/sim`: + +```bash +bunx vitest run \ + lib/execution/remote-sandbox/cli-tools.test.ts \ + lib/execution/remote-sandbox/cli-tools-boundary.test.ts \ + lib/execution/remote-sandbox/sandbox-spec.test.ts \ + lib/execution/remote-sandbox/resolve.test.ts \ + lib/api/contracts/sandboxes.test.ts \ + 'app/workspace/[workspaceId]/settings/components/sandboxes/utils.test.ts' \ + 'app/workspace/[workspaceId]/settings/components/sandboxes/components/sandbox-editor.test.tsx' +``` + +From the repository root: + +```bash +bun run type-check +bun run check:api-validation +bunx biome check \ + apps/sim/lib/execution/remote-sandbox/cli-tools.ts \ + apps/sim/lib/execution/remote-sandbox/cli-tools.server.ts \ + apps/sim/lib/execution/remote-sandbox/cli-tools.test.ts +git diff --check +``` + +For a new recipe, also exercise its install and every verification command in an actual E2B or Daytona sandbox when credentials and network access are available. Report clearly when only registry/unit validation ran. + +## Completion Checklist + +- [ ] Official immutable Linux x86-64 artifact and SHA-256 verified. +- [ ] Versioned ID appended; old IDs and recipes retained. +- [ ] Client metadata is searchable, categorized, unique, and recipe-free. +- [ ] Server recipe is pinned, integrity-checked, noninteractive, and credential-free. +- [ ] Every advertised executable has an offline verification command and PATH entry. +- [ ] Provider compatibility is explicit and accurate. +- [ ] Catalog, boundary, hash, resolver, type, API-validation, format, and diff checks pass. +- [ ] Real provider installation was tested, or the missing live verification is disclosed. diff --git a/.agents/skills/add-managed-cli/agents/openai.yaml b/.agents/skills/add-managed-cli/agents/openai.yaml new file mode 100644 index 00000000000..7b10d2ef10b --- /dev/null +++ b/.agents/skills/add-managed-cli/agents/openai.yaml @@ -0,0 +1,4 @@ +interface: + display_name: "Add Managed CLI" + short_description: "Add a verified CLI to sandbox images" + default_prompt: "Use $add-managed-cli to add a pinned, verified CLI to Sim sandbox images." diff --git a/.claude/commands/add-managed-cli.md b/.claude/commands/add-managed-cli.md new file mode 100644 index 00000000000..4b5bfcd0840 --- /dev/null +++ b/.claude/commands/add-managed-cli.md @@ -0,0 +1,148 @@ +--- +description: Add or upgrade a curated, immutable managed CLI for Sim Function sandboxes, including client-safe catalog metadata, a pinned server-only installation recipe, checksum and executable verification, provider compatibility, PATH propagation, content-addressed image identity, and tests. Use when adding a CLI to the Sandbox managed-CLI selector or changing an existing managed CLI version or recipe. +--- + +# Add a Managed CLI + +Add CLIs through the curated registry. Never turn this surface into arbitrary commands or package names: system packages already cover validated Debian/APT coordinates, while managed CLIs require immutable artifacts and reproducible recipes. + +## Read First + +Read these live sources before editing; do not copy their current entries into this skill: + +1. `apps/sim/lib/execution/remote-sandbox/cli-tools.ts` — persisted IDs and client-safe metadata. +2. `apps/sim/lib/execution/remote-sandbox/cli-tools.server.ts` — server-only recipes and recipe helpers. +3. `apps/sim/lib/execution/remote-sandbox/cli-tools.test.ts` — catalog and supply-chain invariants. +4. `apps/sim/lib/execution/remote-sandbox/cli-tools-boundary.test.ts` — client/server import boundary. +5. `apps/sim/lib/execution/remote-sandbox/sandbox-spec.ts` — content-addressed hash inputs. + +Read `resolve.ts` and `e2b.ts` only when changing provisioning mechanics. A normal catalog addition should not require UI, API, database, resolver, or provider edits; those paths derive from the registries. + +Do not modify the dedicated Function base image or the separate Mothership Shell template for a normal managed CLI addition. Managed recipes layer on the Function base image. Do not change `MAX_SANDBOX_CLI_TOOLS` from ten unless the user separately requests a product-limit change. + +## 1. Verify the Upstream Release + +Use primary upstream release documentation and official artifacts. Establish all of the following before writing code: + +- Exact version and stable Linux x86-64 artifact URL. Never use `latest`, mutable redirects, or an unversioned installer. +- SHA-256 for the exact artifact. Prefer a publisher-signed checksum; otherwise download the official artifact and compute it independently. +- Archive layout and the exact executable paths to install. +- Noninteractive, credential-free verification commands for every advertised executable, normally version commands. +- Required PATH entries under `/opt/sim-cli`. +- E2B and Daytona compatibility. Default to both only when the same Linux recipe works on both. + +When the user does not name a version, select the current stable upstream release from primary sources and state the exact version chosen. Do not silently choose a prerelease or infer a version from an unverified secondary source. + +Reject curl-to-shell installers, `npm install`, `pip install`, distro package repositories, arbitrary user commands, and artifacts from unofficial mirrors. Never place credentials, tokens, login commands, or account configuration in an image recipe or build log; authentication is runtime-only. + +## 2. Choose an Immutable ID + +Use `@-r`. + +- New upstream version: append a new ID ending in `-r1`. +- Recipe-only change for the same upstream version: append `-r2`, `-r3`, and so on. +- Never mutate or delete an existing ID or recipe. Persisted sandboxes must continue resolving to the bytes and behavior they selected. +- On upgrade, retain the old ID and recipe and set its metadata to `selectable: false`. Only the newest version keeps the public label selectable. + +Before shipping the first upgrade for a tool family, verify that editing a sandbox cannot leave both the retired and replacement IDs selected. If the generic selector and API validation do not already replace or reject colliding versions, address that once at the generic registry boundary with focused UI and contract tests; never special-case the individual CLI or silently install two versions that expose the same executable. + +Recipe identity includes the ID, revision, and SHA-256 in the sandbox image hash. Keeping old entries is what makes that identity reproducible rather than merely cache-busting. + +## 3. Add Client-Safe Metadata + +In `cli-tools.ts`: + +1. Append the ID to `SANDBOX_CLI_TOOL_IDS` in the same order used by the metadata and recipe registries. +2. Add a `SANDBOX_CLI_TOOLS` entry whose key and `id` exactly match. +3. Provide a unique selectable `label`, concise `description`, existing `category`, and useful executable/vendor aliases in `searchTerms`. +4. Add a category only when no existing category is accurate, then ensure it has at least one selectable entry. + +Keep this file safe for client bundles. It must not contain artifact URLs, checksums, install commands, verification commands, PATH recipes, provider SDKs, or imports from `cli-tools.server.ts`. + +The API enum and searchable grouped selector derive from this registry. Do not add parallel option arrays or route-local wire types. + +## 4. Add the Server-Only Recipe + +In `cli-tools.server.ts`, use the narrowest existing helper: + +- `defineBinaryRecipe` for one downloaded binary. +- `defineTarGzipRecipe` or `defineZipRecipe` for archives containing binaries. +- `defineVerifiedRecipe` for a vendor archive or installer layout that needs explicit commands. +- A direct typed entry only when the helpers cannot faithfully model the release. + +Provide every field the recipe contract requires: + +- Exact `version`, `artifactUrl`, `artifactName`, and lowercase 64-character `sha256`. +- Every installed `executable` and a corresponding `verificationCommands` entry. +- Deterministic extraction/install commands into `/opt/sim-cli`; quote fixed paths and clean temporary artifacts. +- `pathEntries` when the executable is not installed into the helper's default `bin` directory. +- `supportedProviders` only when it differs from the E2B-and-Daytona default. +- `revision` when it differs from `1`; it must agree with the ID suffix. + +Verification must prove the command is discoverable through `sandboxCliEnvironment`, not authenticate or contact a user account. Recipe commands run as root during both prebuilt image creation and runtime provisioning. + +If the artifact host is new, add only the exact official hostname to the `officialHosts` allowlist in `cli-tools.test.ts`. Treat that as a supply-chain review, not a way to silence the test. + +## 5. Preserve Generic Behavior + +Confirm the existing generic paths remain sufficient: + +- `sandboxCliToolRecipes` canonicalizes and resolves the recipe. +- `sandboxCliEnvironment` propagates PATH to Python subprocesses, JavaScript subprocesses, and Shell. +- E2B bakes the recipe into the custom image; runtime-strategy providers install it within the Function timeout. +- CLI-only sandboxes remain buildable even with no language packages. +- `hashSandboxSpec` includes recipe ID, revision, and checksum while preserving the legacy hash for an empty CLI list. +- The settings selector derives groups and search aliases from client-safe metadata. + +Do not special-case a CLI in those layers unless the registry contract cannot express a genuine provider requirement. Extend the registry contract generically when multiple CLIs need the same new behavior. + +## 6. Test the Addition + +Extend tests when the new entry introduces behavior not already covered: + +- For every upgrade, add a regression proving the old ID and recipe remain resolvable but non-selectable, while the replacement ID is selectable. +- Add important executable aliases to the table-driven search assertion. +- Add a focused assertion for a multi-executable recipe, custom PATH, or restricted provider. +- Add an opt-in credentialed smoke test only when installation plus a real minimal command cannot be validated without authentication. Read credentials from test-only environment variables, skip by default, create them only at runtime, and always tear down the sandbox. + +Never commit downloaded artifacts or credentials. + +## Required Validation + +From `apps/sim`: + +```bash +bunx vitest run \ + lib/execution/remote-sandbox/cli-tools.test.ts \ + lib/execution/remote-sandbox/cli-tools-boundary.test.ts \ + lib/execution/remote-sandbox/sandbox-spec.test.ts \ + lib/execution/remote-sandbox/resolve.test.ts \ + lib/api/contracts/sandboxes.test.ts \ + 'app/workspace/[workspaceId]/settings/components/sandboxes/utils.test.ts' \ + 'app/workspace/[workspaceId]/settings/components/sandboxes/components/sandbox-editor.test.tsx' +``` + +From the repository root: + +```bash +bun run type-check +bun run check:api-validation +bunx biome check \ + apps/sim/lib/execution/remote-sandbox/cli-tools.ts \ + apps/sim/lib/execution/remote-sandbox/cli-tools.server.ts \ + apps/sim/lib/execution/remote-sandbox/cli-tools.test.ts +git diff --check +``` + +For a new recipe, also exercise its install and every verification command in an actual E2B or Daytona sandbox when credentials and network access are available. Report clearly when only registry/unit validation ran. + +## Completion Checklist + +- [ ] Official immutable Linux x86-64 artifact and SHA-256 verified. +- [ ] Versioned ID appended; old IDs and recipes retained. +- [ ] Client metadata is searchable, categorized, unique, and recipe-free. +- [ ] Server recipe is pinned, integrity-checked, noninteractive, and credential-free. +- [ ] Every advertised executable has an offline verification command and PATH entry. +- [ ] Provider compatibility is explicit and accurate. +- [ ] Catalog, boundary, hash, resolver, type, API-validation, format, and diff checks pass. +- [ ] Real provider installation was tested, or the missing live verification is disclosed. diff --git a/.cursor/commands/add-managed-cli.md b/.cursor/commands/add-managed-cli.md new file mode 100644 index 00000000000..99b05bca409 --- /dev/null +++ b/.cursor/commands/add-managed-cli.md @@ -0,0 +1,144 @@ +# Add a Managed CLI + +Add CLIs through the curated registry. Never turn this surface into arbitrary commands or package names: system packages already cover validated Debian/APT coordinates, while managed CLIs require immutable artifacts and reproducible recipes. + +## Read First + +Read these live sources before editing; do not copy their current entries into this skill: + +1. `apps/sim/lib/execution/remote-sandbox/cli-tools.ts` — persisted IDs and client-safe metadata. +2. `apps/sim/lib/execution/remote-sandbox/cli-tools.server.ts` — server-only recipes and recipe helpers. +3. `apps/sim/lib/execution/remote-sandbox/cli-tools.test.ts` — catalog and supply-chain invariants. +4. `apps/sim/lib/execution/remote-sandbox/cli-tools-boundary.test.ts` — client/server import boundary. +5. `apps/sim/lib/execution/remote-sandbox/sandbox-spec.ts` — content-addressed hash inputs. + +Read `resolve.ts` and `e2b.ts` only when changing provisioning mechanics. A normal catalog addition should not require UI, API, database, resolver, or provider edits; those paths derive from the registries. + +Do not modify the dedicated Function base image or the separate Mothership Shell template for a normal managed CLI addition. Managed recipes layer on the Function base image. Do not change `MAX_SANDBOX_CLI_TOOLS` from ten unless the user separately requests a product-limit change. + +## 1. Verify the Upstream Release + +Use primary upstream release documentation and official artifacts. Establish all of the following before writing code: + +- Exact version and stable Linux x86-64 artifact URL. Never use `latest`, mutable redirects, or an unversioned installer. +- SHA-256 for the exact artifact. Prefer a publisher-signed checksum; otherwise download the official artifact and compute it independently. +- Archive layout and the exact executable paths to install. +- Noninteractive, credential-free verification commands for every advertised executable, normally version commands. +- Required PATH entries under `/opt/sim-cli`. +- E2B and Daytona compatibility. Default to both only when the same Linux recipe works on both. + +When the user does not name a version, select the current stable upstream release from primary sources and state the exact version chosen. Do not silently choose a prerelease or infer a version from an unverified secondary source. + +Reject curl-to-shell installers, `npm install`, `pip install`, distro package repositories, arbitrary user commands, and artifacts from unofficial mirrors. Never place credentials, tokens, login commands, or account configuration in an image recipe or build log; authentication is runtime-only. + +## 2. Choose an Immutable ID + +Use `@-r`. + +- New upstream version: append a new ID ending in `-r1`. +- Recipe-only change for the same upstream version: append `-r2`, `-r3`, and so on. +- Never mutate or delete an existing ID or recipe. Persisted sandboxes must continue resolving to the bytes and behavior they selected. +- On upgrade, retain the old ID and recipe and set its metadata to `selectable: false`. Only the newest version keeps the public label selectable. + +Before shipping the first upgrade for a tool family, verify that editing a sandbox cannot leave both the retired and replacement IDs selected. If the generic selector and API validation do not already replace or reject colliding versions, address that once at the generic registry boundary with focused UI and contract tests; never special-case the individual CLI or silently install two versions that expose the same executable. + +Recipe identity includes the ID, revision, and SHA-256 in the sandbox image hash. Keeping old entries is what makes that identity reproducible rather than merely cache-busting. + +## 3. Add Client-Safe Metadata + +In `cli-tools.ts`: + +1. Append the ID to `SANDBOX_CLI_TOOL_IDS` in the same order used by the metadata and recipe registries. +2. Add a `SANDBOX_CLI_TOOLS` entry whose key and `id` exactly match. +3. Provide a unique selectable `label`, concise `description`, existing `category`, and useful executable/vendor aliases in `searchTerms`. +4. Add a category only when no existing category is accurate, then ensure it has at least one selectable entry. + +Keep this file safe for client bundles. It must not contain artifact URLs, checksums, install commands, verification commands, PATH recipes, provider SDKs, or imports from `cli-tools.server.ts`. + +The API enum and searchable grouped selector derive from this registry. Do not add parallel option arrays or route-local wire types. + +## 4. Add the Server-Only Recipe + +In `cli-tools.server.ts`, use the narrowest existing helper: + +- `defineBinaryRecipe` for one downloaded binary. +- `defineTarGzipRecipe` or `defineZipRecipe` for archives containing binaries. +- `defineVerifiedRecipe` for a vendor archive or installer layout that needs explicit commands. +- A direct typed entry only when the helpers cannot faithfully model the release. + +Provide every field the recipe contract requires: + +- Exact `version`, `artifactUrl`, `artifactName`, and lowercase 64-character `sha256`. +- Every installed `executable` and a corresponding `verificationCommands` entry. +- Deterministic extraction/install commands into `/opt/sim-cli`; quote fixed paths and clean temporary artifacts. +- `pathEntries` when the executable is not installed into the helper's default `bin` directory. +- `supportedProviders` only when it differs from the E2B-and-Daytona default. +- `revision` when it differs from `1`; it must agree with the ID suffix. + +Verification must prove the command is discoverable through `sandboxCliEnvironment`, not authenticate or contact a user account. Recipe commands run as root during both prebuilt image creation and runtime provisioning. + +If the artifact host is new, add only the exact official hostname to the `officialHosts` allowlist in `cli-tools.test.ts`. Treat that as a supply-chain review, not a way to silence the test. + +## 5. Preserve Generic Behavior + +Confirm the existing generic paths remain sufficient: + +- `sandboxCliToolRecipes` canonicalizes and resolves the recipe. +- `sandboxCliEnvironment` propagates PATH to Python subprocesses, JavaScript subprocesses, and Shell. +- E2B bakes the recipe into the custom image; runtime-strategy providers install it within the Function timeout. +- CLI-only sandboxes remain buildable even with no language packages. +- `hashSandboxSpec` includes recipe ID, revision, and checksum while preserving the legacy hash for an empty CLI list. +- The settings selector derives groups and search aliases from client-safe metadata. + +Do not special-case a CLI in those layers unless the registry contract cannot express a genuine provider requirement. Extend the registry contract generically when multiple CLIs need the same new behavior. + +## 6. Test the Addition + +Extend tests when the new entry introduces behavior not already covered: + +- For every upgrade, add a regression proving the old ID and recipe remain resolvable but non-selectable, while the replacement ID is selectable. +- Add important executable aliases to the table-driven search assertion. +- Add a focused assertion for a multi-executable recipe, custom PATH, or restricted provider. +- Add an opt-in credentialed smoke test only when installation plus a real minimal command cannot be validated without authentication. Read credentials from test-only environment variables, skip by default, create them only at runtime, and always tear down the sandbox. + +Never commit downloaded artifacts or credentials. + +## Required Validation + +From `apps/sim`: + +```bash +bunx vitest run \ + lib/execution/remote-sandbox/cli-tools.test.ts \ + lib/execution/remote-sandbox/cli-tools-boundary.test.ts \ + lib/execution/remote-sandbox/sandbox-spec.test.ts \ + lib/execution/remote-sandbox/resolve.test.ts \ + lib/api/contracts/sandboxes.test.ts \ + 'app/workspace/[workspaceId]/settings/components/sandboxes/utils.test.ts' \ + 'app/workspace/[workspaceId]/settings/components/sandboxes/components/sandbox-editor.test.tsx' +``` + +From the repository root: + +```bash +bun run type-check +bun run check:api-validation +bunx biome check \ + apps/sim/lib/execution/remote-sandbox/cli-tools.ts \ + apps/sim/lib/execution/remote-sandbox/cli-tools.server.ts \ + apps/sim/lib/execution/remote-sandbox/cli-tools.test.ts +git diff --check +``` + +For a new recipe, also exercise its install and every verification command in an actual E2B or Daytona sandbox when credentials and network access are available. Report clearly when only registry/unit validation ran. + +## Completion Checklist + +- [ ] Official immutable Linux x86-64 artifact and SHA-256 verified. +- [ ] Versioned ID appended; old IDs and recipes retained. +- [ ] Client metadata is searchable, categorized, unique, and recipe-free. +- [ ] Server recipe is pinned, integrity-checked, noninteractive, and credential-free. +- [ ] Every advertised executable has an offline verification command and PATH entry. +- [ ] Provider compatibility is explicit and accurate. +- [ ] Catalog, boundary, hash, resolver, type, API-validation, format, and diff checks pass. +- [ ] Real provider installation was tested, or the missing live verification is disclosed. diff --git a/.gitignore b/.gitignore index 501da963969..6e9bdf2c99c 100644 --- a/.gitignore +++ b/.gitignore @@ -50,9 +50,7 @@ dump.rdb .env.production # editor swap files -*.swp -*.swo -*.swn +*.sw? # vercel .vercel diff --git a/apps/docs/content/docs/en/agents/custom-tools.mdx b/apps/docs/content/docs/en/agents/custom-tools.mdx index 9648b00910e..eb3a8c45695 100644 --- a/apps/docs/content/docs/en/agents/custom-tools.mdx +++ b/apps/docs/content/docs/en/agents/custom-tools.mdx @@ -85,6 +85,8 @@ return { }; ``` +For a secret used as a complete JavaScript expression, prefer the unquoted form, such as `const apiKey = {{OPENWEATHER_API_KEY}};`. Quoted and embedded forms remain supported, including the placeholder embedded in the URL above, `"Bearer {{KEY}}"`, template literals, and JavaScript regex literals. The value is bound separately when the tool executes rather than pasted into its source, so its exact string contents are preserved. + You can also use the AI wand to generate code from a description. Environment variables are referenced with `{{KEY}}` syntax. @@ -115,7 +117,7 @@ Once created, custom tools appear alongside built-in tools when configuring an A - **Async/await** — Your code runs in an async context, so you can use `await` directly - **fetch()** — Make HTTP requests to external APIs - **Node.js built-ins** — Access to `crypto`, `Buffer`, and other standard modules -- **Environment variables** — Use `{{KEY}}` syntax to inject secrets +- **Environment variables** — Use `{{KEY}}` syntax to bind secrets at execution time without placing plaintext in source code ### Limitations @@ -156,7 +158,7 @@ From **Settings → Custom Tools** you can: \ No newline at end of file +]} /> diff --git a/apps/docs/content/docs/en/api-reference/typescript.mdx b/apps/docs/content/docs/en/api-reference/typescript.mdx index 791849f94a5..e51c26605bb 100644 --- a/apps/docs/content/docs/en/api-reference/typescript.mdx +++ b/apps/docs/content/docs/en/api-reference/typescript.mdx @@ -91,6 +91,7 @@ const result = await client.executeWorkflow('workflow-id', { message: 'Hello, wo - `stream` (boolean): Enable streaming responses (default: false) - `selectedOutputs` (string[]): Block outputs to stream in `blockName.attribute` format (e.g., `["agent1.content"]`) - `async` (boolean): Execute asynchronously (default: false) + - `executionTimeoutSeconds` (number): Optional server-side async execution cap from 1 to 604800 seconds. Requires `async: true` and cannot extend the account policy. **Returns:** `Promise` diff --git a/apps/docs/content/docs/en/platform/costs.mdx b/apps/docs/content/docs/en/platform/costs.mdx index 46f379730c1..81d5ce42e99 100644 --- a/apps/docs/content/docs/en/platform/costs.mdx +++ b/apps/docs/content/docs/en/platform/costs.mdx @@ -361,10 +361,11 @@ Storage follows the paid tier: Pro and Pro for Teams share the Pro limit, while | Plan | Sync | Async | |------|------|-------| | **Free** | 5 minutes | 90 minutes | -| **Pro / Max / Team / Enterprise** | 50 minutes | 90 minutes | +| **Pro / Max / Team** | 50 minutes | 90 minutes | +| **Enterprise** | 50 minutes | 90 minutes by default; configurable up to 7 days | **Sync runs** complete immediately and return results directly. These are triggered via the API with `async: false` (default) or through the UI. -**Async runs** (triggered via API with `async: true`, webhooks, or schedules) run in the background. +**Async runs** (triggered via API with `async: true`, webhooks, schedules, polling triggers, or table workflow columns) run in the background. A direct async API request can shorten the account policy for that request, but cannot extend it. If a workflow exceeds its time limit, it will be terminated and marked as failed with a timeout error. Design long-running workflows to use async runs or break them into smaller workflows. diff --git a/apps/docs/content/docs/en/platform/credentials.mdx b/apps/docs/content/docs/en/platform/credentials.mdx index 3502b5f6243..7b03b1a72d9 100644 --- a/apps/docs/content/docs/en/platform/credentials.mdx +++ b/apps/docs/content/docs/en/platform/credentials.mdx @@ -69,10 +69,10 @@ Select the secret you want to use. The reference appears highlighted in blue and When a saved secret is successfully substituted through a `{{KEY}}` reference, Sim masks exact, case-sensitive occurrences of its resolved value in log-facing content. This includes the editor's live block-log display, Logs Overview input and output, stored execution traces, log-read API responses, and the Logs block's **Get Run Details** output. Function and Agent span inputs, outputs, and errors, Agent thinking, and Agent tool-call arguments, results, and errors are protected. The replacement is normally shown as `{{KEY}}`. -This is an observability projection only. Secret resolution and workflow behavior are unchanged: blocks, tools, models, and downstream steps receive the real runtime value. Stored functional execution data, workflow execution responses, streams, callbacks, block state, and snapshots are not rewritten. Log-facing views and read APIs receive a separate protected copy, so the Logs Overview **Workflow Input** and **Workflow Output** are masked without changing the underlying workflow result. +Secret resolution and functional workflow behavior are unchanged: blocks, tools, and downstream steps receive the real runtime value. Stored functional execution data, workflow execution responses, streams, callbacks, block state, and snapshots are not rewritten. Log-facing views and read APIs receive a separate protected copy, so the Logs Overview **Workflow Input** and **Workflow Output** are masked without changing the underlying workflow result. Model requests receive another protected projection: exact secret values known to the run are replaced with `{{KEY}}` before model-visible messages, prompts, tool arguments, or tool continuations leave Sim. -Masking is activated only when Sim successfully resolves a value from **Settings → Secrets** through `{{KEY}}`. A hardcoded literal, direct `environmentVariables['KEY']` read, or shell `$KEY` read does not activate it by itself. Once activated, every exact occurrence of that value in the run's log-facing content is masked. Encoded, hashed, or otherwise transformed versions are not matched. Do not deliberately return or print secrets. +Execution-log masking is activated only when Sim successfully resolves a value from **Settings → Secrets** through `{{KEY}}`. A hardcoded literal, direct `environmentVariables['KEY']` read, or shell `$KEY` read does not activate log masking by itself. Model-bound projection also checks the run's authorized secret catalog, including direct reads, but both protections match only exact values. Encoded, hashed, fragmented, or otherwise transformed versions are not matched. Do not deliberately return or print secrets. ### Copilot code execution @@ -136,7 +136,7 @@ When a workflow runs, secrets resolve in this order: : +E2B_FUNCTION_TEMPLATE_GENERATION= +SANDBOXES_ENABLED=true +NEXT_PUBLIC_SANDBOXES_ENABLED=true +``` + +The builder uses E2B's maintained `code-interpreter-v1` base, assigns a fresh +release generation, and prints both runtime values. `--generation` remains +available for release automation, and `--base-template` accepts an immutable +base override when a deployment deliberately owns one. + +For Daytona, use the immutable snapshot ID printed by the builder. The API key needs +`write:snapshots` to build and `write:sandboxes` to execute: + +```bash +DAYTONA_API_KEY=... \ + bun run apps/sim/scripts/build-function-daytona-snapshot.ts \ + --name sim-function-2026-08-03 \ + --parity-manifest /tmp/function-sandbox-manifest.json + +SANDBOX_PROVIDER=daytona +DAYTONA_API_KEY=... +DAYTONA_FUNCTION_SNAPSHOT_ID= +SANDBOXES_ENABLED=true +NEXT_PUBLIC_SANDBOXES_ENABLED=true +``` + +`SANDBOXES_ENABLED` grants the server-side self-hosted entitlement. +`NEXT_PUBLIC_SANDBOXES_ENABLED` exposes remote Python and Shell plus custom +sandbox management in the browser. Set the public flag only after the selected +provider has credentials and a valid immutable Function base configured. + +Use E2B as the release baseline before building or promoting Daytona: + +```bash +# 1. Verify the exact E2B Function build and capture its accepted package/runtime surface. +E2B_ENABLED=true \ +E2B_API_KEY=... \ +E2B_FUNCTION_TEMPLATE_ID=: \ +E2B_FUNCTION_TEMPLATE_GENERATION= \ +SANDBOX_PARITY_MANIFEST_OUT=/tmp/function-sandbox-manifest.json \ + bun run apps/sim/scripts/verify-sandbox-parity.ts + +# 2. Pin Daytona's reconstructed packages to that accepted E2B manifest. +DAYTONA_API_KEY=... \ + bun run apps/sim/scripts/build-function-daytona-snapshot.ts \ + --name sim-function-2026-08-03 \ + --parity-manifest /tmp/function-sandbox-manifest.json + +# 3. Verify the immutable Daytona snapshot against the same baseline before promotion. +SANDBOX_PROVIDER=daytona \ +DAYTONA_API_KEY=... \ +DAYTONA_FUNCTION_SNAPSHOT_ID= \ +SANDBOX_PARITY_MANIFEST_BASELINE=/tmp/function-sandbox-manifest.json \ + bun run apps/sim/scripts/verify-sandbox-parity.ts +``` + + + `E2B_FUNCTION_TEMPLATE_ID` and `DAYTONA_FUNCTION_SNAPSHOT_ID` fail closed when + unset or mutable. The E2B value must be an exact `