From 9a5f29d31ef0bb83592373e6e834f8f43f27a095 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Fri, 20 Nov 2026 17:34:40 -0800 Subject: [PATCH 1/8] improvement(config): derive enterprise flags from one registry and merge the vLLM and LiteLLM providers --- .github/scripts/http-e2e.sh | 10 +- .../platform/enterprise/access-control.mdx | 1 - .../docs/platform/enterprise/audit-logs.mdx | 1 - .../platform/enterprise/custom-blocks.mdx | 2 +- .../docs/platform/enterprise/data-drains.mdx | 3 +- .../platform/enterprise/data-retention.mdx | 1 - .../docs/platform/enterprise/forks.mdx | 1 - .../docs/platform/enterprise/index.mdx | 1 - .../docs/platform/enterprise/scim/index.mdx | 4 +- .../docs/platform/enterprise/self-hosted.mdx | 47 +- .../content/docs/platform/enterprise/sso.mdx | 7 +- .../platform/enterprise/usage-tracking.mdx | 1 - .../platform/enterprise/verified-domains.mdx | 3 +- .../platform/self-hosting/authentication.mdx | 5 +- .../self-hosting/environment-variables.mdx | 9 +- .../docs/platform/self-hosting/index.mdx | 1 - .../docs/platform/self-hosting/sandboxes.mdx | 6 +- .../docs/platform/self-hosting/security.mdx | 4 +- .../scripts/fixtures/content-baseline.json | 30 +- apps/extension/README.md | 2 +- apps/sim/.env.example | 32 +- apps/sim/app/_shell/public-env-script.tsx | 12 + .../app/api/providers/litellm/models/route.ts | 33 +- .../app/api/providers/vllm/models/route.ts | 37 +- apps/sim/app/layout.tsx | 8 +- apps/sim/blocks/blocks/function.ts | 2 +- apps/sim/blocks/types.ts | 7 + apps/sim/ee/README.md | 4 +- apps/sim/lib/api/contracts/providers.ts | 2 +- apps/sim/lib/api/contracts/workspaces.ts | 26 +- .../aws-marketplace/container-license.test.ts | 1 - .../aws-marketplace/container-license.ts | 5 +- .../billing/core/inbox-entitlement.test.ts | 9 +- apps/sim/lib/billing/core/subscription.ts | 18 +- .../config/deployment-projection.dom.test.ts | 62 ++ .../lib/core/config/deployment-projection.ts | 80 ++ .../core/config/deployment-shape.dom.test.tsx | 40 +- apps/sim/lib/core/config/deployment-shape.ts | 61 +- .../config/enterprise-entitlements.test.ts | 156 --- .../core/config/enterprise-entitlements.ts | 134 --- .../core/config/enterprise-features.test.ts | 138 +++ apps/sim/lib/core/config/env-flags.ts | 230 ++--- apps/sim/lib/core/config/env.ts | 28 +- .../blocks/canvas-sentence-validation.ts | 7 +- .../lib/workflows/blocks/canvas-sentence.ts | 2 +- .../sim/lib/workflows/subblocks/visibility.ts | 10 +- apps/sim/providers/litellm/index.test.ts | 39 + apps/sim/providers/litellm/index.ts | 839 +--------------- .../sim/providers/openai-compat/model-list.ts | 53 + .../providers/openai-compat/self-hosted.ts | 917 ++++++++++++++++++ apps/sim/providers/vllm/index.ts | 805 +-------------- .../consolidate-users-into-organization.ts | 5 +- apps/sim/scripts/test-project-files-e2e.ts | 4 - bun.lock | 1 + .../sim-helm/references/values-model.md | 4 +- helm/sim/Chart.yaml | 2 +- helm/sim/values.yaml | 31 +- packages/deployment-config/package.json | 4 + .../src/enterprise-features.ts | 278 ++++++ packages/sim-setup/src/checks.test.ts | 39 + packages/sim-setup/src/checks.ts | 29 +- packages/sim-setup/src/steps.ts | 32 +- packages/sim-setup/src/twins.test.ts | 7 - packages/sim-setup/src/twins.ts | 58 +- packages/testing/package.json | 1 + .../src/mocks/deployment-shape.mock.ts | 21 +- packages/testing/src/mocks/env-flags.mock.ts | 7 +- 67 files changed, 2095 insertions(+), 2364 deletions(-) create mode 100644 apps/sim/lib/core/config/deployment-projection.dom.test.ts create mode 100644 apps/sim/lib/core/config/deployment-projection.ts delete mode 100644 apps/sim/lib/core/config/enterprise-entitlements.test.ts delete mode 100644 apps/sim/lib/core/config/enterprise-entitlements.ts create mode 100644 apps/sim/lib/core/config/enterprise-features.test.ts create mode 100644 apps/sim/providers/openai-compat/model-list.ts create mode 100644 apps/sim/providers/openai-compat/self-hosted.ts create mode 100644 packages/deployment-config/src/enterprise-features.ts diff --git a/.github/scripts/http-e2e.sh b/.github/scripts/http-e2e.sh index 56cbab01147..d1ac13c2546 100755 --- a/.github/scripts/http-e2e.sh +++ b/.github/scripts/http-e2e.sh @@ -187,10 +187,10 @@ case "$group" in scim) export NEXT_PUBLIC_FORCE_HOSTED=true export BILLING_ENABLED=true NEXT_PUBLIC_BILLING_ENABLED=true - export ENTERPRISE_ENABLED=true NEXT_PUBLIC_ENTERPRISE_ENABLED=true - export SCIM_ENABLED=true NEXT_PUBLIC_SCIM_ENABLED=true - export SSO_ENABLED=true NEXT_PUBLIC_SSO_ENABLED=true - export ORGANIZATIONS_ENABLED=true NEXT_PUBLIC_ORGANIZATIONS_ENABLED=true + export ENTERPRISE_ENABLED=true + export SCIM_ENABLED=true + export SSO_ENABLED=true + export ORGANIZATIONS_ENABLED=true export INTERNAL_API_SECRET=scim-http-ci-local-secret-at-least-32-characters export DB_TX_TRIPWIRE=throw export NEXT_PUBLIC_CHAT_DISABLED=true @@ -282,7 +282,6 @@ case "$group" in export NEXT_PUBLIC_FORCE_HOSTED=false export COPILOT_TOOL_PERMISSIONS_ENABLED=true export KNOWLEDGE_MEMBER_ACCESS=true CREDENTIAL_GROUPS=true ACCESS_CONTROL_ENABLED=true - export NEXT_PUBLIC_ACCESS_CONTROL_ENABLED=true NEXT_PUBLIC_ORGANIZATIONS_ENABLED=true case "$group" in assistant-actions|organization-search) needs_browser=true ;; *) needs_browser=false ;; esac if [ "$needs_browser" = true ]; then start_browser_install "$group" --only-shell chromium; fi export INTERNAL_API_SECRET=desktop-inbox-http-ci-local-secret-at-least-32-characters @@ -335,7 +334,6 @@ case "$group" in export NEXT_PUBLIC_FORCE_HOSTED=false export KNOWLEDGE_MEMBER_ACCESS=true CREDENTIAL_GROUPS=true ACCESS_CONTROL_ENABLED=true export SIM_LINKS=true - export NEXT_PUBLIC_ACCESS_CONTROL_ENABLED=true export API_ENCRYPTION_KEY="$ENCRYPTION_KEY" start_browser_install "$group" --no-shell chromium extension_identity=$(bun - <<'JS' diff --git a/apps/docs/content/docs/platform/enterprise/access-control.mdx b/apps/docs/content/docs/platform/enterprise/access-control.mdx index 3b3b27c4e3f..4c5097c245e 100644 --- a/apps/docs/content/docs/platform/enterprise/access-control.mdx +++ b/apps/docs/content/docs/platform/enterprise/access-control.mdx @@ -147,7 +147,6 @@ On billing-disabled deployments, enable permission groups through the enterprise ```bash ACCESS_CONTROL_ENABLED=true -NEXT_PUBLIC_ACCESS_CONTROL_ENABLED=true ``` The enterprise master configuration can enable the feature; an explicit feature value takes precedence. Billing-enabled self-hosted deployments still require Enterprise. See [self-hosted enterprise setup](/platform/enterprise/self-hosted). diff --git a/apps/docs/content/docs/platform/enterprise/audit-logs.mdx b/apps/docs/content/docs/platform/enterprise/audit-logs.mdx index f7f58c486bb..c052d61cd71 100644 --- a/apps/docs/content/docs/platform/enterprise/audit-logs.mdx +++ b/apps/docs/content/docs/platform/enterprise/audit-logs.mdx @@ -118,7 +118,6 @@ On billing-disabled deployments, enable audit logs through enterprise configurat ```bash AUDIT_LOGS_ENABLED=true -NEXT_PUBLIC_AUDIT_LOGS_ENABLED=true ``` Explicit feature values take precedence over the enterprise master setting. Billing-enabled self-hosted deployments retain the Enterprise gate. See [self-hosted enterprise setup](/platform/enterprise/self-hosted). diff --git a/apps/docs/content/docs/platform/enterprise/custom-blocks.mdx b/apps/docs/content/docs/platform/enterprise/custom-blocks.mdx index 27ca548f35c..2e101ce10e9 100644 --- a/apps/docs/content/docs/platform/enterprise/custom-blocks.mdx +++ b/apps/docs/content/docs/platform/enterprise/custom-blocks.mdx @@ -7,7 +7,7 @@ import { Callout } from '@/components/ui/callout' Publish a workflow as a custom block so teammates can provide its inputs and use selected outputs without access to its source workflow. The block always runs the source's latest deployment. Use it for a shared knowledge lookup, an authenticated internal API, an enrichment step, or a prompt and guardrail maintained in one place. -Publishing and managing a block requires admin access to its source workspace. Billing-enabled deployments require an Enterprise organization. On billing-disabled deployments, enable the custom-block feature through enterprise configuration or `CUSTOM_BLOCKS_ENABLED=true` and `NEXT_PUBLIC_CUSTOM_BLOCKS_ENABLED=true`. An organization is still required; see [self-hosted enterprise setup](/platform/enterprise/self-hosted). +Publishing and managing a block requires admin access to its source workspace. Billing-enabled deployments require an Enterprise organization. On billing-disabled deployments, enable the custom-block feature through enterprise configuration or `CUSTOM_BLOCKS_ENABLED=true`. An organization is still required; see [self-hosted enterprise setup](/platform/enterprise/self-hosted). ## Publish a block diff --git a/apps/docs/content/docs/platform/enterprise/data-drains.mdx b/apps/docs/content/docs/platform/enterprise/data-drains.mdx index aa15772c507..002e11a0ab9 100644 --- a/apps/docs/content/docs/platform/enterprise/data-drains.mdx +++ b/apps/docs/content/docs/platform/enterprise/data-drains.mdx @@ -248,10 +248,9 @@ Enable the feature through enterprise configuration or explicitly set: ```bash DATA_DRAINS_ENABLED=true -NEXT_PUBLIC_DATA_DRAINS_ENABLED=true ``` -An explicit feature value takes precedence over `ENTERPRISE_ENABLED`. When disabled, the page is hidden, mutating drain requests return `404`, and the dispatcher does no work. Billing-enabled deployments retain the Enterprise gate. Keep server and public feature configuration aligned; `bunx sim-setup doctor` checks the pair. See [self-hosted enterprise setup](/platform/enterprise/self-hosted). +An explicit feature value takes precedence over `ENTERPRISE_ENABLED`. When disabled, the page is hidden, mutating drain requests return `404`, and the dispatcher does no work. Billing-enabled deployments retain the Enterprise gate. See [self-hosted enterprise setup](/platform/enterprise/self-hosted). The dispatcher requires scheduled calls to `GET /api/cron/run-data-drains`. Set the same `CRON_SECRET` on the app and its caller; the endpoint returns `401` when it is unset. Generate a secret if needed, then install it in both configurations: diff --git a/apps/docs/content/docs/platform/enterprise/data-retention.mdx b/apps/docs/content/docs/platform/enterprise/data-retention.mdx index c3252f45023..82652802ebc 100644 --- a/apps/docs/content/docs/platform/enterprise/data-retention.mdx +++ b/apps/docs/content/docs/platform/enterprise/data-retention.mdx @@ -128,7 +128,6 @@ On billing-disabled deployments, enable retention through enterprise configurati ```bash DATA_RETENTION_ENABLED=true -NEXT_PUBLIC_DATA_RETENTION_ENABLED=true ``` An explicit feature value takes precedence over the enterprise master configuration. No plan-based default window is introduced: configure the windows you intend to apply. diff --git a/apps/docs/content/docs/platform/enterprise/forks.mdx b/apps/docs/content/docs/platform/enterprise/forks.mdx index b9ad8d99ef5..12868c33f0c 100644 --- a/apps/docs/content/docs/platform/enterprise/forks.mdx +++ b/apps/docs/content/docs/platform/enterprise/forks.mdx @@ -188,7 +188,6 @@ On billing-disabled deployments, enable forking through enterprise configuration ```bash FORKING_ENABLED=true -NEXT_PUBLIC_FORKING_ENABLED=true ``` Explicit feature values take precedence over the master configuration. Billing-enabled self-hosted deployments still require Enterprise. See [self-hosted enterprise setup](/platform/enterprise/self-hosted). diff --git a/apps/docs/content/docs/platform/enterprise/index.mdx b/apps/docs/content/docs/platform/enterprise/index.mdx index 7ccf39afa11..7ef66101373 100644 --- a/apps/docs/content/docs/platform/enterprise/index.mdx +++ b/apps/docs/content/docs/platform/enterprise/index.mdx @@ -26,7 +26,6 @@ On a self-hosted deployment with billing disabled, enable enterprise features th ```bash ENTERPRISE_ENABLED=true -NEXT_PUBLIC_ENTERPRISE_ENABLED=true ``` Individual feature flags override the master switch. Most enterprise settings also need an organization that owns the workspace. Choose one instance-wide organization or provision separate organizations through the Admin API. diff --git a/apps/docs/content/docs/platform/enterprise/scim/index.mdx b/apps/docs/content/docs/platform/enterprise/scim/index.mdx index 7414b2e0d42..0882bc06595 100644 --- a/apps/docs/content/docs/platform/enterprise/scim/index.mdx +++ b/apps/docs/content/docs/platform/enterprise/scim/index.mdx @@ -16,7 +16,7 @@ Configure [SSO](/platform/enterprise/sso) separately for authentication. SCIM ca - On Sim Cloud, use an Enterprise organization and an organization owner or admin account. - [Verify every email domain](/platform/enterprise/verified-domains) you will provision. Sim refuses account creation or an email change to an unverified domain. -- On self-hosted deployments, enable SSO to reach **Single sign-on → Provisioning**, and enable SCIM. The enterprise master pair enables both; individual setup uses `SSO_ENABLED`, `NEXT_PUBLIC_SSO_ENABLED`, `SCIM_ENABLED`, and `NEXT_PUBLIC_SCIM_ENABLED`. See [Self-hosted SSO setup](/platform/enterprise/sso#self-hosted-setup) and [Deployment and upgrades](#deployment-and-upgrades). +- On self-hosted deployments, enable SSO to reach **Single sign-on → Provisioning**, and enable SCIM. `ENTERPRISE_ENABLED` enables both; individual setup uses `SSO_ENABLED` and `SCIM_ENABLED`. See [Self-hosted SSO setup](/platform/enterprise/sso#self-hosted-setup) and [Deployment and upgrades](#deployment-and-upgrades). ## Plan membership and access @@ -205,7 +205,7 @@ While the connection is disabled, **Lock managed membership** and **Disable just Apply database migrations before the new application code. The SCIM tables and suspension fields are additive, allowing older code to run against the expanded schema during rollout. - Keep `SCIM_ENABLED=false` and `NEXT_PUBLIC_SCIM_ENABLED=false` until all older application instances and workers are drained. Older code does not enforce SCIM suspension or explicit permission-group membership. These explicit flags also override the hosted default. + Keep `SCIM_ENABLED=false` until all older application instances and workers are drained. Older code does not enforce SCIM suspension or explicit permission-group membership. This explicit flag also overrides the hosted default. After SCIM has suspended accounts or established managed access, rolling back to code that predates SCIM is unsafe: it cannot enforce those restrictions. Disabling synchronization does not undo suspension or restore earlier membership semantics. diff --git a/apps/docs/content/docs/platform/enterprise/self-hosted.mdx b/apps/docs/content/docs/platform/enterprise/self-hosted.mdx index 8ac8b0e825f..0f6c16a2c9b 100644 --- a/apps/docs/content/docs/platform/enterprise/self-hosted.mdx +++ b/apps/docs/content/docs/platform/enterprise/self-hosted.mdx @@ -13,22 +13,19 @@ This guide covers the standard billing-disabled configuration. If billing is ena ## Enable the feature set -Set both the server flag and its browser twin, then restart the application: +Set the server flag, then restart the application: ```bash ENTERPRISE_ENABLED=true -NEXT_PUBLIC_ENTERPRISE_ENABLED=true ``` -The server flag controls access and the server-resolved workspace settings. The browser twin also enables controls that read browser configuration directly, including SSO on the login page and the Function block's **Sandbox** selector. On a Compose install or source checkout, `bunx sim-setup doctor` reports mismatched twins. See [Verify your install](/platform/self-hosting/verify). +The server flag controls access and everything the browser shows, including SSO on the login page and the Function block's **Sandbox** selector: the browser reads the server's resolved settings, so there is no `NEXT_PUBLIC_` variable to set. Browser variables left over from older releases do nothing; on a Compose install or source checkout, `bunx sim-setup doctor` reports them. See [Verify your install](/platform/self-hosting/verify). Individual flags override the master switch. For example, to enable the suite with data drains disabled: ```bash ENTERPRISE_ENABLED=true -NEXT_PUBLIC_ENTERPRISE_ENABLED=true DATA_DRAINS_ENABLED=false -NEXT_PUBLIC_DATA_DRAINS_ENABLED=false ``` You can also leave the master switch unset and enable individual features. The [feature flag reference](#feature-flag-reference) lists them all. @@ -238,29 +235,31 @@ OAuth token cleanup removes expired and revoked credentials independently of sig Explicit individual flags override the master switch, including when set to `false`. With billing disabled and no enterprise flags set, session policies and the Sim Mailer inbox remain enabled by default. Other features require opt-in. -| Feature | Server variable | Browser variable | -| --- | --- | --- | -| Enterprise suite | `ENTERPRISE_ENABLED` | `NEXT_PUBLIC_ENTERPRISE_ENABLED` | -| Organizations | `ORGANIZATIONS_ENABLED` | `NEXT_PUBLIC_ORGANIZATIONS_ENABLED` | -| Permission groups | `ACCESS_CONTROL_ENABLED` | `NEXT_PUBLIC_ACCESS_CONTROL_ENABLED` | -| SAML and OIDC sign-in | `SSO_ENABLED` | `NEXT_PUBLIC_SSO_ENABLED` | -| Directory provisioning | `SCIM_ENABLED` | `NEXT_PUBLIC_SCIM_ENABLED` | -| Audit logs | `AUDIT_LOGS_ENABLED` | `NEXT_PUBLIC_AUDIT_LOGS_ENABLED` | -| Insights | `USAGE_MONITORING_ENABLED` | `NEXT_PUBLIC_USAGE_MONITORING_ENABLED` | -| Custom blocks | `CUSTOM_BLOCKS_ENABLED` | `NEXT_PUBLIC_CUSTOM_BLOCKS_ENABLED` | -| Session policies — enabled by default | `SESSION_POLICIES_ENABLED` | `NEXT_PUBLIC_SESSION_POLICIES_ENABLED` | -| Retention deletion | `DATA_RETENTION_ENABLED` | `NEXT_PUBLIC_DATA_RETENTION_ENABLED` | -| Data drains | `DATA_DRAINS_ENABLED` | `NEXT_PUBLIC_DATA_DRAINS_ENABLED` | -| Credential groups | `CREDENTIAL_GROUPS` | — | -| Workspace forks | `FORKING_ENABLED` | `NEXT_PUBLIC_FORKING_ENABLED` | -| Sim Mailer inbox — enabled by default | `INBOX_ENABLED` | `NEXT_PUBLIC_INBOX_ENABLED` | -| Sandboxes | `SANDBOXES_ENABLED` | `NEXT_PUBLIC_SANDBOXES_ENABLED` | +Each feature is one server variable. Permission groups also turn on organizations, and organizations are always on when billing is enabled. + +| Feature | Variable | +| --- | --- | +| Enterprise suite | `ENTERPRISE_ENABLED` | +| Organizations | `ORGANIZATIONS_ENABLED` | +| Permission groups | `ACCESS_CONTROL_ENABLED` | +| SAML and OIDC sign-in | `SSO_ENABLED` | +| Directory provisioning | `SCIM_ENABLED` | +| Audit logs | `AUDIT_LOGS_ENABLED` | +| Insights | `USAGE_MONITORING_ENABLED` | +| Custom blocks | `CUSTOM_BLOCKS_ENABLED` | +| Session policies — enabled by default | `SESSION_POLICIES_ENABLED` | +| Retention deletion | `DATA_RETENTION_ENABLED` | +| Data drains | `DATA_DRAINS_ENABLED` | +| Credential groups | `CREDENTIAL_GROUPS` | +| Workspace forks | `FORKING_ENABLED` | +| Sim Mailer inbox — enabled by default | `INBOX_ENABLED` | +| Sandboxes | `SANDBOXES_ENABLED` | ### Sandbox readiness A Sandbox entitlement also requires a remote execution provider with credentials and an immutable Function base image. Until the server verifies readiness, the Function block offers no **Shell** language, and **Settings → Sandboxes** shows an upgrade notice instead of a sandbox list. -`NEXT_PUBLIC_SANDBOXES_ENABLED` exposes the Function block's **Sandbox** selector; it asserts readiness rather than checking it. Set it only after configuring the selected provider and Function base. `bunx sim-setup doctor` compares it with provider readiness. +The Function block's **Sandbox** selector appears once the server confirms both the entitlement and a ready provider. `NEXT_PUBLIC_SANDBOXES_ENABLED` is only a readiness marker that `bunx sim-setup doctor` compares with the provider; the app does not read it. JavaScript without `import`, `require`, a selected sandbox, or a sandbox file-path reference runs in local Node child workers in the app container when Sandbox flags are off. Python, Shell, JavaScript with external imports, and selected custom Sandboxes require the remote Function base and fail with a configuration error until it is ready. See [Sandboxes](/platform/self-hosting/sandboxes). @@ -269,7 +268,7 @@ JavaScript without `import`, `require`, a selected sandbox, or a sandbox file-pa | Symptom | Check | | --- | --- | | A settings section is missing | Check its server flag and restart the app after changing environment variables. These values load at boot; a rebuild is not needed. | -| The login page has no SSO option, or Function has no Sandbox selector | Set the matching `NEXT_PUBLIC_` flag. Run `bunx sim-setup doctor` to check twins and Sandbox readiness. | +| The login page has no SSO option, or Function has no Sandbox selector | Check `SSO_ENABLED` (or `ENTERPRISE_ENABLED`) and Sandbox readiness, then restart the app. Run `bunx sim-setup doctor` to check Sandbox readiness. | | **Settings → Sandboxes** shows an upgrade notice | Check Sandbox entitlement, provider credentials, and the immutable Function base. | | An enabled feature has no effect in a workspace | Confirm that the workspace belongs to an organization. Use the backfill or workspace move procedure if needed. | | Retention deletes nothing | Check `DATA_RETENTION_ENABLED`, explicit windows, scheduler requests, and `CRON_SECRET`. | diff --git a/apps/docs/content/docs/platform/enterprise/sso.mdx b/apps/docs/content/docs/platform/enterprise/sso.mdx index a36c162158b..31076443614 100644 --- a/apps/docs/content/docs/platform/enterprise/sso.mdx +++ b/apps/docs/content/docs/platform/enterprise/sso.mdx @@ -275,22 +275,19 @@ Different domains can also use different providers, such as Okta for `eng.acme.c ## Self-hosted setup -For a deployment with billing disabled, enable SSO and its browser twin: +For a deployment with billing disabled, enable SSO: ```bash SSO_ENABLED=true -NEXT_PUBLIC_SSO_ENABLED=true # Organization membership on first SSO sign-in ORGANIZATIONS_ENABLED=true -NEXT_PUBLIC_ORGANIZATIONS_ENABLED=true # Optional directory provisioning tab SCIM_ENABLED=true -NEXT_PUBLIC_SCIM_ENABLED=true ``` -The enterprise master pair also enables these features. See [Self-hosted enterprise](/platform/enterprise/self-hosted) for organization setup. +`ENTERPRISE_ENABLED=true` also enables these features. See [Self-hosted enterprise](/platform/enterprise/self-hosted) for organization setup. `SSO_TRUSTED_PROVIDER_IDS` is an optional comma-separated list for non-SSO provider account linking. It does not authorize SSO linking; SSO trust comes from the provider's verified domain. diff --git a/apps/docs/content/docs/platform/enterprise/usage-tracking.mdx b/apps/docs/content/docs/platform/enterprise/usage-tracking.mdx index 53f42f47227..401a491eb0a 100644 --- a/apps/docs/content/docs/platform/enterprise/usage-tracking.mdx +++ b/apps/docs/content/docs/platform/enterprise/usage-tracking.mdx @@ -97,7 +97,6 @@ Enable Insights through enterprise configuration or explicitly set: ```bash USAGE_MONITORING_ENABLED=true -NEXT_PUBLIC_USAGE_MONITORING_ENABLED=true ``` Explicit values take precedence over the enterprise master configuration. Billing-enabled deployments retain the Enterprise gate. Organization owner/admin access is still required. See [self-hosted enterprise setup](/platform/enterprise/self-hosted). diff --git a/apps/docs/content/docs/platform/enterprise/verified-domains.mdx b/apps/docs/content/docs/platform/enterprise/verified-domains.mdx index bf39ae424e2..8ad9e3e03bd 100644 --- a/apps/docs/content/docs/platform/enterprise/verified-domains.mdx +++ b/apps/docs/content/docs/platform/enterprise/verified-domains.mdx @@ -41,10 +41,9 @@ Enable SSO to expose **Domains** in the single sign-on settings: ```bash SSO_ENABLED=true -NEXT_PUBLIC_SSO_ENABLED=true ``` -You can instead enable the enterprise suite with both `ENTERPRISE_ENABLED=true` and `NEXT_PUBLIC_ENTERPRISE_ENABLED=true`. Set the browser twin too: the login page's SSO entry point reads it before a workspace loads. See [Self-hosted enterprise](/platform/enterprise/self-hosted). +You can instead enable the enterprise suite with `ENTERPRISE_ENABLED=true`. The login page's SSO entry point reads the server's setting, so there is no browser variable to set. See [Self-hosted enterprise](/platform/enterprise/self-hosted). The older `/workspace//settings/domains` path still resolves to **Single sign-on → Domains**. diff --git a/apps/docs/content/docs/platform/self-hosting/authentication.mdx b/apps/docs/content/docs/platform/self-hosting/authentication.mdx index 32669b65d41..7048f9697a6 100644 --- a/apps/docs/content/docs/platform/self-hosting/authentication.mdx +++ b/apps/docs/content/docs/platform/self-hosting/authentication.mdx @@ -83,7 +83,6 @@ For example, an installation using SSO while allowing existing company email acc ALLOWED_LOGIN_DOMAINS=acme.com DISABLE_EMAIL_SIGNUP=true SSO_ENABLED=true -NEXT_PUBLIC_SSO_ENABLED=true ``` This does not restrict enabled social providers to `acme.com`. Configure or disable those login methods separately. @@ -94,17 +93,15 @@ For a standard billing-disabled self-hosted deployment, enable the enterprise su ```bash ENTERPRISE_ENABLED=true -NEXT_PUBLIC_ENTERPRISE_ENABLED=true ``` Or enable SSO alone: ```bash SSO_ENABLED=true -NEXT_PUBLIC_SSO_ENABLED=true ``` -Set both the server flag and its UI counterpart. Register providers under **Settings → Organization → Single sign-on**. A provider can belong to an organization or be registered without one. +Each is a server variable; the login page and settings read the server's setting, so there is no browser counterpart. Register providers under **Settings → Organization → Single sign-on**. A provider can belong to an organization or be registered without one. Most other enterprise features read settings from the organization that owns a workspace. Set `INSTANCE_ORG_NAME` to place new members in one organization, or provision organizations through the Admin API. See [SSO](/platform/enterprise/sso) and [Self-hosted enterprise features](/platform/enterprise/self-hosted) for provider setup, organization patterns, and billing-enabled behavior. diff --git a/apps/docs/content/docs/platform/self-hosting/environment-variables.mdx b/apps/docs/content/docs/platform/self-hosting/environment-variables.mdx index 277229e234e..a655700c0dc 100644 --- a/apps/docs/content/docs/platform/self-hosting/environment-variables.mdx +++ b/apps/docs/content/docs/platform/self-hosting/environment-variables.mdx @@ -187,7 +187,8 @@ Who may sign up and sign in — the allowlists, blocklists, `DISABLE_REGISTRATIO | `E2B_FUNCTION_TEMPLATE_GENERATION` | Monotonic release generation printed by the same build. Required for E2B | | `DAYTONA_FUNCTION_SNAPSHOT_ID` | Immutable snapshot **ID** (not a name) for the Function base image. Required for Daytona | | `E2B_PI_TEMPLATE_ID` / `DAYTONA_PI_SNAPSHOT_ID` | The image Pi runs on. Separate from the Function base — configuring the provider and Function image alone leaves Pi failing closed | -| `SANDBOXES_ENABLED` / `NEXT_PUBLIC_SANDBOXES_ENABLED` | Enable custom sandbox entitlement through deployment configuration where supported; see the [enterprise guide](/platform/enterprise/self-hosted) for billing-mode requirements. Neither is sufficient on its own — a provider key **and** an immutable Function base must also be configured. Set the `NEXT_PUBLIC_` twin only after the server side works; it enables nothing by itself — it reveals the Function block's Sandbox selector, and on a Compose install or source checkout `bunx sim-setup doctor` confirms it agrees with the selected provider's readiness | +| `SANDBOXES_ENABLED` | Enable custom sandbox entitlement through deployment configuration where supported; see the [enterprise guide](/platform/enterprise/self-hosted) for billing-mode requirements. Not sufficient on its own — a provider key **and** an immutable Function base must also be configured. The Function block's Sandbox selector appears once the server confirms both | +| `NEXT_PUBLIC_SANDBOXES_ENABLED` | Readiness marker only; the app does not read it. On a Compose install or source checkout `bunx sim-setup doctor` compares it with the selected provider's readiness | | `IVM_MAX_EXECUTIONS_PER_WORKER` | Executions before an isolated-vm worker is recycled | | `IVM_MAX_BROKERS_PER_EXECUTION` | Host-call brokers per execution | | `IVM_MAX_BROKER_ARGS_JSON_CHARS` | Max argument payload size | @@ -216,10 +217,10 @@ On standard billing-disabled self-hosted deployments, configuration enables ente | Variable | Description | |----------|-------------| -| `ENTERPRISE_ENABLED`, `NEXT_PUBLIC_ENTERPRISE_ENABLED` | Enable the whole enterprise feature set | -| `SSO_ENABLED`, `NEXT_PUBLIC_SSO_ENABLED` | Enable SAML and OIDC single sign-on on its own. See [Authentication](/platform/self-hosting/authentication#sso-saml-and-oidc) | +| `ENTERPRISE_ENABLED` | Enable the whole enterprise feature set. Each feature is one server variable; the browser reads the server's settings, so no `NEXT_PUBLIC_` counterpart is needed | +| `SSO_ENABLED` | Enable SAML and OIDC single sign-on on its own. See [Authentication](/platform/self-hosting/authentication#sso-saml-and-oidc) | | `SSO_SKIP_DOMAIN_VERIFICATION` | Skip the DNS challenge when an administrator clicks Verify on a domain. Off by default; self-hosted only. Trusts administrator claims for SSO and SCIM across the instance. See [Verified domains](/platform/enterprise/verified-domains#skip-dns-verification) | -| `SCIM_ENABLED`, `NEXT_PUBLIC_SCIM_ENABLED` | Enable directory provisioning on its own. Needs SSO. See [Directory provisioning](/platform/enterprise/scim) | +| `SCIM_ENABLED` | Enable directory provisioning on its own. Needs SSO. See [Directory provisioning](/platform/enterprise/scim) | | `INSTANCE_ORG_NAME` | Name of the organization every user joins automatically at signup | | `INSTANCE_ORG_SLUG` | Slug for that organization (derived from the name when omitted) | | `INSTANCE_ORG_OWNER_EMAIL` | Owner of that organization (defaults to the first user to sign up) | diff --git a/apps/docs/content/docs/platform/self-hosting/index.mdx b/apps/docs/content/docs/platform/self-hosting/index.mdx index f5bb49c276a..a997df1561f 100644 --- a/apps/docs/content/docs/platform/self-hosting/index.mdx +++ b/apps/docs/content/docs/platform/self-hosting/index.mdx @@ -75,7 +75,6 @@ In a standard billing-disabled self-hosted deployment, enterprise features are e ```bash ENTERPRISE_ENABLED=true -NEXT_PUBLIC_ENTERPRISE_ENABLED=true ``` Organizations, SSO, permission groups, audit logs, session policies, retention, and data drains also need their feature-specific configuration. Most read settings from the organization that owns a workspace. Enabling the suite can enable retention processing; review the configured policy before turning it on. diff --git a/apps/docs/content/docs/platform/self-hosting/sandboxes.mdx b/apps/docs/content/docs/platform/self-hosting/sandboxes.mdx index 6195a0e664b..85ab5706976 100644 --- a/apps/docs/content/docs/platform/self-hosting/sandboxes.mdx +++ b/apps/docs/content/docs/platform/self-hosting/sandboxes.mdx @@ -111,11 +111,11 @@ DAYTONA_FUNCTION_SNAPSHOT_ID= | Variable | Effect | |---|---| | `SANDBOXES_ENABLED=true` | Grants the server-side sandbox entitlement on a billing-disabled self-hosted deployment | -| `NEXT_PUBLIC_SANDBOXES_ENABLED=true` | Reveals the Function block's **Sandbox** selector; asserts readiness rather than checking it | +| `NEXT_PUBLIC_SANDBOXES_ENABLED=true` | Readiness marker for `bunx sim-setup doctor`; the app does not read it | -On a billing-disabled deployment, `ENTERPRISE_ENABLED=true` also grants the entitlement when `SANDBOXES_ENABLED` is unset. The server must verify provider credentials and the immutable Function base before offering Shell and the sandbox list. **Settings → Sandboxes** remains in the sidebar but shows an upgrade notice until access/readiness resolves. Python remains selectable; execution still requires the remote configuration. +On a billing-disabled deployment, `ENTERPRISE_ENABLED=true` also grants the entitlement when `SANDBOXES_ENABLED` is unset. The server must verify provider credentials and the immutable Function base before offering Shell, the Function block's **Sandbox** selector, and the sandbox list. **Settings → Sandboxes** remains in the sidebar but shows an upgrade notice until access/readiness resolves. Python remains selectable; execution still requires the remote configuration. -Set the browser flag only after provider verification succeeds. On Compose or a source checkout, `bunx sim-setup doctor` compares the public flag with selected-provider readiness. +On Compose or a source checkout, `bunx sim-setup doctor` compares the readiness marker with selected-provider readiness. ## Promote or roll back a build diff --git a/apps/docs/content/docs/platform/self-hosting/security.mdx b/apps/docs/content/docs/platform/self-hosting/security.mdx index 5cfb65dc7a5..f4d220cd289 100644 --- a/apps/docs/content/docs/platform/self-hosting/security.mdx +++ b/apps/docs/content/docs/platform/self-hosting/security.mdx @@ -197,11 +197,11 @@ continues to run in the local isolate when no remote provider is configured. Without valid provider credentials and the required Function image, code that needs a remote sandbox fails with a configuration error. Verify readiness before enabling its browser controls. -Two browser-side variables assert readiness in the UI; neither is derived automatically: +Two browser-side variables relate to sandbox readiness; neither is derived automatically: | Variable | Effect when unset | |---|---| -| `NEXT_PUBLIC_SANDBOXES_ENABLED` | The Function block's Sandbox selector stays hidden, even with a working provider. Shell and **Settings → Sandboxes** are unaffected — Shell appears, and the settings page swaps its upgrade notice for the sandbox list, from the server's own readiness check. Python stays selectable; whether it runs depends on the server-side provider and Function image, not on this flag | +| `NEXT_PUBLIC_SANDBOXES_ENABLED` | Nothing in the app: the Function block's Sandbox selector, Shell, and **Settings → Sandboxes** all follow the server's own readiness check. `sim-setup doctor` reports it as a mismatch against provider readiness. Python stays selectable; whether it runs depends on the server-side provider and Function image | | `NEXT_PUBLIC_E2B_ENABLED` | The E2B-backed Pi block modes stay hidden; `sim-setup doctor` reports it as a mismatch against `E2B_ENABLED`. Revealing them is not enough to make them run — Pi executes on its own image, pinned with `E2B_PI_TEMPLATE_ID` or `DAYTONA_PI_SNAPSHOT_ID`, and fails closed without it | Set the public values only **after** the server-side configuration above is complete — they are assertions about readiness, not switches, and the server-side check has its own conditions beyond them. See [Sandboxes](/platform/self-hosting/sandboxes) for the base-image build and promotion procedure. `bunx sim-setup doctor` reports a mismatch in either direction. diff --git a/apps/docs/scripts/fixtures/content-baseline.json b/apps/docs/scripts/fixtures/content-baseline.json index 4382245ee9c..3bbe3984161 100644 --- a/apps/docs/scripts/fixtures/content-baseline.json +++ b/apps/docs/scripts/fixtures/content-baseline.json @@ -169043,7 +169043,7 @@ { "lang": "bash", "meta": null, - "sha256": "5617143714516fb95298c56885f1822df0b37044909b07c3c812a9453349c39d", + "sha256": "c56f3129cd839eb27b1ea397c70f6ccdf3d56805289ef03af78dd401fae405ad", "bytes": 67, "line": 119 }, @@ -169133,7 +169133,7 @@ { "lang": "bash", "meta": null, - "sha256": "84569115924bc5382bd3e4238adbb84120218042ac3d5aff4371da6dc5a1663a", + "sha256": "935c6db998ffa465e6d82d163730306a7d2abc09fd01e29e315b1a25b82269b7", "bytes": 59, "line": 114 }, @@ -169412,7 +169412,7 @@ { "lang": "bash", "meta": null, - "sha256": "ee4ee953a8b78edde2fb55b4ec6484fd997d105dba40fd22b41e089e5663b638", + "sha256": "89a6cc0a2f6762092e850616af000eefe136a7d71fd777758a432464ff5ab060", "bytes": 61, "line": 245 }, @@ -169616,7 +169616,7 @@ { "lang": "bash", "meta": null, - "sha256": "fdb1ffde41476ae0be0ef8409dcc90f2aa58e9253154315dbe9d27491cadf172", + "sha256": "6a7117556efe8695899ff5ffaacc94676f53216c4ec1b35e586d140ca6053ac3", "bytes": 67, "line": 123 }, @@ -169857,7 +169857,7 @@ { "lang": "bash", "meta": null, - "sha256": "adac386435fb082984a333d14d686ae3b4edd64af8ba5b654698b6981f027371", + "sha256": "05a588925ebb2ef9447128c4292a86a4d165434c5cfdc0bf21802037445e9cdf", "bytes": 53, "line": 185 } @@ -169923,7 +169923,7 @@ { "lang": "bash", "meta": null, - "sha256": "32bb48d9015f1554d2af3251db885990823fe0d84464d6f0e17a40116958e3e5", + "sha256": "c9ec4341bddca160d4c16be81aa710e6e4265299d72b66529e53d280fef31416", "bytes": 59, "line": 24 } @@ -170982,14 +170982,14 @@ { "lang": "bash", "meta": null, - "sha256": "32bb48d9015f1554d2af3251db885990823fe0d84464d6f0e17a40116958e3e5", + "sha256": "c9ec4341bddca160d4c16be81aa710e6e4265299d72b66529e53d280fef31416", "bytes": 59, "line": 14 }, { "lang": "bash", "meta": null, - "sha256": "73aeb98d174714dbd916c2ef9cdcf60dfe0388cf3856cb7f5eec1afb58094212", + "sha256": "e067941a8a2a2408ef0a23e5d8ca2ec2b46dd82d508fa3374ff7f0b8a39fd81f", "bytes": 123, "line": 23 }, @@ -171465,7 +171465,7 @@ { "lang": "bash", "meta": null, - "sha256": "595f16b051fa3ca256ea924f9eec2016497f66fdd5b89d4a673437b386ea2727", + "sha256": "188acc605116697130e3f4cc63c6d82b055196cc059bc901e94c3a29be04a2d6", "bytes": 246, "line": 276 }, @@ -171584,7 +171584,7 @@ { "lang": "bash", "meta": null, - "sha256": "7d12eedf709c60767192795dd793d7f4890b6fa1a6d2c8e91e5bd6c0a41b4a1c", + "sha256": "c24cfc1066656a2c8230b471f2e15df1a113c68fbe88e44075b5da81390ca345", "bytes": 71, "line": 94 } @@ -171703,7 +171703,7 @@ { "lang": "bash", "meta": null, - "sha256": "281bc47e1b9a2a7b09154f95a1d7396e49b55d7248bca3f5473a12307ed971d9", + "sha256": "9da605beb512cdfd1f2ea43e1e1a3de1a25d6c5d3fdc1100ebaac40fd24e6e4a", "bytes": 45, "line": 38 }, @@ -172154,21 +172154,21 @@ { "lang": "bash", "meta": null, - "sha256": "e7c564ba9dd062044afed2f105ad84eea4edfa126cf43d1c8c37a38b374a2c46", + "sha256": "dd9ca81a343c3f8aee7c8023f036f8da04077ebdf67e4352c4c35c9702bea09a", "bytes": 102, "line": 78 }, { "lang": "bash", "meta": null, - "sha256": "32bb48d9015f1554d2af3251db885990823fe0d84464d6f0e17a40116958e3e5", + "sha256": "c9ec4341bddca160d4c16be81aa710e6e4265299d72b66529e53d280fef31416", "bytes": 59, "line": 91 }, { "lang": "bash", "meta": null, - "sha256": "281bc47e1b9a2a7b09154f95a1d7396e49b55d7248bca3f5473a12307ed971d9", + "sha256": "9da605beb512cdfd1f2ea43e1e1a3de1a25d6c5d3fdc1100ebaac40fd24e6e4a", "bytes": 45, "line": 98 }, @@ -173395,7 +173395,7 @@ { "lang": "bash", "meta": null, - "sha256": "32bb48d9015f1554d2af3251db885990823fe0d84464d6f0e17a40116958e3e5", + "sha256": "c9ec4341bddca160d4c16be81aa710e6e4265299d72b66529e53d280fef31416", "bytes": 59, "line": 72 } diff --git a/apps/extension/README.md b/apps/extension/README.md index b5a4621c7d1..9d8be29ab15 100644 --- a/apps/extension/README.md +++ b/apps/extension/README.md @@ -57,7 +57,7 @@ The E2E suite uses real Chromium, the packaged extension, and a disposable HTTP Release verification must additionally exercise typing `go/` in Chrome's real address bar on a clean profile (the e2e proves the visits, not the address bar), the native toolbar and shortcut, Chrome's real grant/revoke prompt, sign-in/SSO and expiry against the running Sim app, side-panel closing/reopening, workspace changes, narrow widths, and the real Mothership streaming response. The fixture suite does not establish those integrations. The design document records launch scope and release criteria. -The authenticated acceptance suite runs against a real local app, Better Auth, and a disposable Postgres database whose name contains `test`. Enable `KNOWLEDGE_MEMBER_ACCESS`, `CREDENTIAL_GROUPS`, `ACCESS_CONTROL_ENABLED`, and `NEXT_PUBLIC_ACCESS_CONTROL_ENABLED` on that app to exercise restricted organization members: +The authenticated acceptance suite runs against a real local app, Better Auth, and a disposable Postgres database whose name contains `test`. Enable `KNOWLEDGE_MEMBER_ACCESS`, `CREDENTIAL_GROUPS`, and `ACCESS_CONTROL_ENABLED` on that app to exercise restricted organization members: ```sh EXTENSION_APP_E2E_BASE_URL=http://127.0.0.1:3007 \ diff --git a/apps/sim/.env.example b/apps/sim/.env.example index 687acd09473..a5a55d98525 100644 --- a/apps/sim/.env.example +++ b/apps/sim/.env.example @@ -37,7 +37,7 @@ NEXT_PUBLIC_APP_URL=http://localhost:3000 # Copilot/Mothership code tools use a separate shell image. It is selected only # for those code-tool calls and is never a fallback for Function blocks. # SANDBOXES_ENABLED=true # Enables custom sandboxes for self-hosted workspaces -# NEXT_PUBLIC_SANDBOXES_ENABLED=true # Shows remote Function languages and custom sandbox settings; set only after the provider/base is ready +# NEXT_PUBLIC_SANDBOXES_ENABLED=true # Readiness marker `sim-setup doctor` checks; the app verifies the provider itself # # E2B (default provider) # After exporting E2B_API_KEY, build with: bun run apps/sim/scripts/build-function-e2b-template.ts @@ -199,25 +199,27 @@ CRON_SECRET=your_cron_secret # Use `openssl rand -hex 32` to generate. Authentic # Enterprise Features (Optional - self-hosted). One switch enables organizations, SSO, # permission groups, audit logs, custom blocks, session policies, data retention, data -# drains, forks, and the inbox. Set both — the server value grants access, the -# NEXT_PUBLIC_ value decides what the settings UI shows. +# drains, forks, and the inbox. Each feature is one server variable: the browser reads +# the server-resolved state, so there are no NEXT_PUBLIC_ twins to set. # Docs: https://docs.sim.ai/platform/enterprise/self-hosted # ENTERPRISE_ENABLED=true -# NEXT_PUBLIC_ENTERPRISE_ENABLED=true # Per-feature overrides. An explicitly set flag wins over ENTERPRISE_ENABLED, so use these # to enable one feature on its own or to switch a single feature back off. -# ACCESS_CONTROL_ENABLED= / NEXT_PUBLIC_ACCESS_CONTROL_ENABLED= # Permission groups -# SSO_ENABLED= / NEXT_PUBLIC_SSO_ENABLED= # SAML and OIDC sign-in -# AUDIT_LOGS_ENABLED= / NEXT_PUBLIC_AUDIT_LOGS_ENABLED= # Audit logging -# CUSTOM_BLOCKS_ENABLED= / NEXT_PUBLIC_CUSTOM_BLOCKS_ENABLED= # Reusable org-wide blocks -# SESSION_POLICIES_ENABLED= / NEXT_PUBLIC_SESSION_POLICIES_ENABLED= -# DATA_RETENTION_ENABLED= / NEXT_PUBLIC_DATA_RETENTION_ENABLED= # Runs retention deletion — off by default -# DATA_DRAINS_ENABLED= / NEXT_PUBLIC_DATA_DRAINS_ENABLED= # Export streams -# FORKING_ENABLED= # Workspace forks -# CREDENTIAL_GROUPS= # Enterprise managed OAuth collections -# KNOWLEDGE_MEMBER_ACCESS= # Per-member knowledge connectors and hybrid-by-default retrieval -# ORGANIZATIONS_ENABLED= / NEXT_PUBLIC_ORGANIZATIONS_ENABLED= # Organizations only +# ACCESS_CONTROL_ENABLED= # Permission groups (implies organizations) +# SSO_ENABLED= # SAML and OIDC sign-in +# SCIM_ENABLED= # Directory provisioning (needs SSO) +# AUDIT_LOGS_ENABLED= # Audit logging +# CUSTOM_BLOCKS_ENABLED= # Reusable org-wide blocks +# SESSION_POLICIES_ENABLED= # On by default without billing +# INBOX_ENABLED= # Sim Mailer; on by default without billing +# DATA_RETENTION_ENABLED= # Runs retention deletion — off by default +# DATA_DRAINS_ENABLED= # Export streams +# USAGE_MONITORING_ENABLED= # Org-wide credit usage +# FORKING_ENABLED= # Workspace forks +# CREDENTIAL_GROUPS= # Enterprise managed OAuth collections +# KNOWLEDGE_MEMBER_ACCESS= # Per-member knowledge connectors and hybrid-by-default retrieval +# ORGANIZATIONS_ENABLED= # Organizations only # SSO domain verification (Optional - self-hosted, off by default). Trust every organization # owner and admin to claim email domains without DNS proof. Add a domain and click Verify. diff --git a/apps/sim/app/_shell/public-env-script.tsx b/apps/sim/app/_shell/public-env-script.tsx index ccc39d0f30c..400f4a912fd 100644 --- a/apps/sim/app/_shell/public-env-script.tsx +++ b/apps/sim/app/_shell/public-env-script.tsx @@ -1,4 +1,6 @@ import { connection } from 'next/server' +import { DEPLOYMENT_SHAPE_ATTRIBUTE } from '@/lib/core/config/deployment-projection' +import { resolveDeploymentShape } from '@/lib/core/config/deployment-shape' import { PUBLIC_ENV_ATTRIBUTE } from '@/lib/core/config/env' /** @@ -42,6 +44,16 @@ export function publicEnvHtmlAttributes(): Record { return { [PUBLIC_ENV_ATTRIBUTE]: JSON.stringify(readPublicEnv()) } } +/** + * Props to spread onto the `` element carrying the server-resolved deployment + * shape, which the browser reads instead of rebuilding deployment configuration from + * `NEXT_PUBLIC_*` twins. Rides on `` for the same ordering reason as + * {@link publicEnvHtmlAttributes}; see `@/lib/core/config/deployment-projection`. + */ +export function deploymentShapeHtmlAttributes(): Record { + return { [DEPLOYMENT_SHAPE_ATTRIBUTE]: JSON.stringify(resolveDeploymentShape()) } +} + /** * Serialize embedded JSON defensively so a public value cannot terminate the * inline script. JSON's two JavaScript line separators are escaped as well for diff --git a/apps/sim/app/api/providers/litellm/models/route.ts b/apps/sim/app/api/providers/litellm/models/route.ts index bf40b54c424..653b91ebe5a 100644 --- a/apps/sim/app/api/providers/litellm/models/route.ts +++ b/apps/sim/app/api/providers/litellm/models/route.ts @@ -1,12 +1,10 @@ import { createLogger } from '@sim/logger' import { getErrorMessage } from '@sim/utils/errors' import { type NextRequest, NextResponse } from 'next/server' -import { - providerModelsResponseSchema, - vllmUpstreamResponseSchema, -} from '@/lib/api/contracts/providers' +import { providerModelsResponseSchema } from '@/lib/api/contracts/providers' import { env } from '@/lib/core/config/env' import { withRouteHandler } from '@/lib/core/utils/with-route-handler' +import { listOpenAICompatibleModels } from '@/providers/openai-compat/model-list' import { filterBlacklistedModels, isProviderBlacklisted } from '@/providers/utils' const logger = createLogger('LiteLLMModelsAPI') @@ -17,7 +15,7 @@ export const GET = withRouteHandler(async (_request: NextRequest) => { return NextResponse.json({ models: [] }) } - const baseUrl = (env.LITELLM_BASE_URL || '').replace(/\/$/, '') + const baseUrl = env.LITELLM_BASE_URL?.trim() if (!baseUrl) { logger.info('LITELLM_BASE_URL not configured') @@ -27,29 +25,18 @@ export const GET = withRouteHandler(async (_request: NextRequest) => { try { logger.info('Fetching LiteLLM models', { baseUrl }) - const headers: Record = { - 'Content-Type': 'application/json', - } - - if (env.LITELLM_API_KEY) { - headers.Authorization = `Bearer ${env.LITELLM_API_KEY}` - } - - const response = await fetch(`${baseUrl}/v1/models`, { - headers, - next: { revalidate: 60 }, + const allModels = await listOpenAICompatibleModels({ + baseUrl, + apiKey: env.LITELLM_API_KEY, + prefix: 'litellm/', + init: { next: { revalidate: 60 } }, }) - if (!response.ok) { - logger.warn('LiteLLM service is not available', { - status: response.status, - statusText: response.statusText, - }) + if (!allModels) { + logger.warn('LiteLLM service is not available') return NextResponse.json({ models: [] }) } - const data = vllmUpstreamResponseSchema.parse(await response.json()) - const allModels = data.data.map((model) => `litellm/${model.id}`) const models = filterBlacklistedModels(allModels) logger.info('Successfully fetched LiteLLM models', { diff --git a/apps/sim/app/api/providers/vllm/models/route.ts b/apps/sim/app/api/providers/vllm/models/route.ts index 05939b4862c..0a50be1d64b 100644 --- a/apps/sim/app/api/providers/vllm/models/route.ts +++ b/apps/sim/app/api/providers/vllm/models/route.ts @@ -1,13 +1,10 @@ import { createLogger } from '@sim/logger' import { getErrorMessage } from '@sim/utils/errors' import { type NextRequest, NextResponse } from 'next/server' -import { - providerModelsResponseSchema, - vllmUpstreamResponseSchema, -} from '@/lib/api/contracts/providers' +import { providerModelsResponseSchema } from '@/lib/api/contracts/providers' import { env } from '@/lib/core/config/env' import { withRouteHandler } from '@/lib/core/utils/with-route-handler' -import { getOpenAICompatibleApiBaseUrl } from '@/providers/openai-compat/base-url' +import { listOpenAICompatibleModels } from '@/providers/openai-compat/model-list' import { filterBlacklistedModels, isProviderBlacklisted } from '@/providers/utils' const logger = createLogger('VLLMModelsAPI') @@ -29,34 +26,20 @@ export const GET = withRouteHandler(async (_request: NextRequest) => { } try { - const apiBaseUrl = getOpenAICompatibleApiBaseUrl(baseUrl) - logger.info('Fetching vLLM models', { - baseUrl, - }) - - const headers: Record = { - 'Content-Type': 'application/json', - } + logger.info('Fetching vLLM models', { baseUrl }) - if (env.VLLM_API_KEY) { - headers.Authorization = `Bearer ${env.VLLM_API_KEY}` - } - - const response = await fetch(`${apiBaseUrl}/models`, { - headers, - next: { revalidate: 60 }, + const allModels = await listOpenAICompatibleModels({ + baseUrl, + apiKey: env.VLLM_API_KEY, + prefix: 'vllm/', + init: { next: { revalidate: 60 } }, }) - if (!response.ok) { - logger.warn('vLLM service is not available', { - status: response.status, - statusText: response.statusText, - }) + if (!allModels) { + logger.warn('vLLM service is not available') return NextResponse.json({ models: [] }) } - const data = vllmUpstreamResponseSchema.parse(await response.json()) - const allModels = data.data.map((model) => `vllm/${model.id}`) const models = filterBlacklistedModels(allModels) logger.info('Successfully fetched vLLM models', { diff --git a/apps/sim/app/layout.tsx b/apps/sim/app/layout.tsx index 354fe958f39..1d3ca86f852 100644 --- a/apps/sim/app/layout.tsx +++ b/apps/sim/app/layout.tsx @@ -25,6 +25,7 @@ import { SessionProvider } from '@/app/_shell/providers/session-provider' import { ThemeProvider } from '@/app/_shell/providers/theme-provider' import { TooltipProvider } from '@/app/_shell/providers/tooltip-provider' import { + deploymentShapeHtmlAttributes, PublicEnvScript, publicEnvHtmlAttributes, RuntimePublicEnvScript, @@ -177,7 +178,12 @@ export default function RootLayout({ children }: { children: React.ReactNode }) ) return ( - + {isReactScanEnabled && (