Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/http-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ wait_ready() {
case "$group" in
scim)
export NEXT_PUBLIC_FORCE_HOSTED=true
export BILLING_ENABLED=true NEXT_PUBLIC_BILLING_ENABLED=true
export BILLING_ENABLED=true
export ENTERPRISE_ENABLED=true
export SCIM_ENABLED=true
export SSO_ENABLED=true
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/integrations/slack.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Sim requests these scopes when someone connects a Slack account. For a self-host
| `reactions:write` | Add emoji reactions to messages |
| `reactions:read` | View emoji reactions on messages |

Requested only when `SLACK_EXTENDED_SCOPES` and `NEXT_PUBLIC_SLACK_EXTENDED_SCOPES` are enabled. Enable them only after Slack approves the app for these scopes:
Requested only when `SLACK_EXTENDED_SCOPES` is enabled. Enable them only after Slack approves the app for these scopes:

| Scope | Description |
| ----- | ----------- |
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/platform/enterprise/self-hosted.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ curl -X PATCH https://sim.example.com/api/v1/admin/organizations/$ORG_ID/session
</Step>
</Steps>

When invitations are disabled with `DISABLE_INVITATIONS` and `NEXT_PUBLIC_DISABLE_INVITATIONS`, use the Admin API to manage organization membership and workspace access. Internal members join the organization. External workspace members receive access to a specific workspace without joining the organization.
When invitations are disabled with `DISABLE_INVITATIONS`, use the Admin API to manage organization membership and workspace access. Internal members join the organization. External workspace members receive access to a specific workspace without joining the organization.

### Read audit logs and permission groups

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ Requests use a shared anonymous session.

| Variable | Effect |
| --- | --- |
| `DISABLE_INVITATIONS=true` / `NEXT_PUBLIC_DISABLE_INVITATIONS=true` | Disable workspace invitations globally. |
| `DISABLE_PUBLIC_API=true` / `NEXT_PUBLIC_DISABLE_PUBLIC_API=true` | Disable the public API globally. |
| `DISABLE_INVITATIONS=true` | Disable workspace invitations globally. |
| `DISABLE_PUBLIC_API=true` | Disable the public API globally. |
| `ADMIN_API_KEY` | Enables Admin API GitOps operations and organization provisioning. |

Set both server and `NEXT_PUBLIC_` flags where a pair is listed. The server flag enforces the restriction; its counterpart controls the UI.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ Most `/api` routes also pass through Next.js Proxy, which buffers only the first

## Limits

With `BILLING_ENABLED` disabled, hosted-plan execution rates/timeouts and table/storage quotas are not enforced unless you set their free-tier variables. Independent protocol, body-size, concurrency, and security rate limits still apply. Billing-enabled deployments enforce their plan limits. Keep `BILLING_ENABLED` and `NEXT_PUBLIC_BILLING_ENABLED` consistent so enforcement and the UI agree.
With `BILLING_ENABLED` disabled, hosted-plan execution rates/timeouts and table/storage quotas are not enforced unless you set their free-tier variables. Independent protocol, body-size, concurrency, and security rate limits still apply. Billing-enabled deployments enforce their plan limits.

Retention cleanup is separately opt-in through `DATA_RETENTION_ENABLED` or the enterprise suite. A configured retention policy still applies without billing; see [Data retention](/platform/enterprise/data-retention).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ Webhook triggers receive callbacks from the provider and must be able to verify
| Variable | Needed for |
|---|---|
| `SLACK_SIGNING_SECRET` | Verifying Slack event and slash-command signatures |
| `SLACK_EXTENDED_SCOPES` / `NEXT_PUBLIC_SLACK_EXTENDED_SCOPES` | Enabling the native Sim-app trigger and its broader Slack scope set; set both to the same value |
| `SLACK_EXTENDED_SCOPES` | Enabling the native Sim-app trigger and its broader Slack scope set |

When enabling the native Sim Slack trigger, configure all three variables together. Enable the extended-scope flags only after Slack approves the app for `assistant:write`, `app_mentions:read`, and `im:history`; otherwise Slack rejects OAuth authorization. Slack OAuth actions can use `SLACK_CLIENT_ID` and `SLACK_CLIENT_SECRET` without enabling the native trigger or supplying a signing secret.

Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/platform/self-hosting/sandboxes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ MOTHERSHIP_E2B_TEMPLATE_ID=<shell-template-ref>
DAYTONA_SHELL_SNAPSHOT_ID=<shell-snapshot-ref>
```

These values do not replace `E2B_FUNCTION_TEMPLATE_ID` or `DAYTONA_FUNCTION_SNAPSHOT_ID`. Shell, Function, document, and Pi images have separate package contracts and release cadences. Pi also needs `E2B_PI_TEMPLATE_ID` or `DAYTONA_PI_SNAPSHOT_ID`; revealing a Pi mode with `NEXT_PUBLIC_E2B_ENABLED` does not supply that image.
These values do not replace `E2B_FUNCTION_TEMPLATE_ID` or `DAYTONA_FUNCTION_SNAPSHOT_ID`. Shell, Function, document, and Pi images have separate package contracts and release cadences. Pi also needs `E2B_PI_TEMPLATE_ID` or `DAYTONA_PI_SNAPSHOT_ID`; `E2B_ENABLED` reveals the Pi cloud modes but does not supply that image.

## Related docs

Expand Down
8 changes: 1 addition & 7 deletions apps/docs/content/docs/platform/self-hosting/security.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,7 @@ 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.
</Callout>

The Function block's Sandbox selector, Shell, and **Settings → Sandboxes** follow the server's own readiness check; no browser variable is involved. One browser-side variable relates to sandbox readiness and is not derived automatically:

| Variable | Effect when unset |
|---|---|
| `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 it only **after** the server-side configuration above is complete — it is an assertion about readiness, not a switch, and the server-side check has its own conditions beyond it. See [Sandboxes](/platform/self-hosting/sandboxes) for the base-image build and promotion procedure. `bunx sim-setup doctor` reports a mismatch in either direction.
The Function block's Sandbox selector, Shell, and **Settings → Sandboxes** follow the server's own readiness check; no browser variable is involved. The E2B-backed Pi block modes appear when `E2B_ENABLED` is set. 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. See [Sandboxes](/platform/self-hosting/sandboxes) for the base-image build and promotion procedure.

<Callout type="warn">
With the default local sandbox, treat everyone who can author a workflow as someone running code in your app container's security context. If your Sim instance is open to a wide or partly-trusted audience, use a remote sandbox provider and enable the NetworkPolicy egress restrictions.
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/workflows/blocks/pi.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ Enable the Pi sandbox as below and supply a provider BYOK key. For private repos

Create PR runs in a sandbox image with the Pi CLI, Git, Node.js, and Bun baked in. Repository dependencies are not preinstalled; Pi can run `bun install` when a repository needs them.

1. **Enable sandbox execution.** On self-hosted Sim, set `E2B_ENABLED=true`, `E2B_API_KEY`, `E2B_PI_TEMPLATE_ID` (the Pi template id), and `NEXT_PUBLIC_E2B_ENABLED=true` (this reveals Plan, Create PR, Update PR, and Review Code in the UI). Build the template with `bun run apps/sim/scripts/build-pi-e2b-template.ts`. These modes stay hidden until `NEXT_PUBLIC_E2B_ENABLED` is set.
1. **Enable sandbox execution.** On self-hosted Sim, set `E2B_ENABLED=true`, `E2B_API_KEY`, and `E2B_PI_TEMPLATE_ID` (the Pi template id). Build the template with `bun run apps/sim/scripts/build-pi-e2b-template.ts`. Plan, Create PR, Update PR, and Review Code stay hidden until `E2B_ENABLED` is set.

The repository template requests **4 vCPU and 8 GiB of RAM**. Confirm your account’s build and session limits against [E2B pricing](https://e2b.dev/pricing); account limits can be lower than Sim’s requested lifetime. Sizing is fixed when the template is built — E2B has no per-sandbox override — so changing it means rebuilding the template, not restarting Sim. Sandboxes are billed per second against the resources they are allocated, not the ones they use. Both numbers live in `apps/sim/scripts/pi-sandbox-packages.ts` and are shared with the Daytona snapshot so the failover image cannot drift from the primary.

Expand Down
6 changes: 3 additions & 3 deletions apps/sim/blocks/blocks/pi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PiIcon } from '@/components/icons'
import { getEnv, isTruthy } from '@/lib/core/config/env'
import { getDeploymentShape } from '@/lib/core/config/deployment-shape'
import type { BlockConfig } from '@/blocks/types'
import { AuthMode, IntegrationType } from '@/blocks/types'
import {
Expand Down Expand Up @@ -164,7 +164,7 @@ export const PiBlock: BlockConfig = {
title: 'Mode',
type: 'dropdown',
/** Cloud modes require E2B and stay hidden when it is disabled. */
value: () => (isTruthy(getEnv('NEXT_PUBLIC_E2B_ENABLED')) ? 'cloud' : 'local'),
value: () => (getDeploymentShape().e2bEnabled ? 'cloud' : 'local'),
options: () => {
const options = [
{
Expand All @@ -173,7 +173,7 @@ export const PiBlock: BlockConfig = {
description: 'Edits files on your own machine over SSH',
},
]
if (isTruthy(getEnv('NEXT_PUBLIC_E2B_ENABLED'))) {
if (getDeploymentShape().e2bEnabled) {
options.unshift(
{
label: 'Create PR',
Expand Down
14 changes: 4 additions & 10 deletions apps/sim/hooks/use-permission-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { useMemo } from 'react'
import { useParams } from 'next/navigation'
import type { IntegrationAvailabilityResponse } from '@/lib/api/contracts/common'
import { getEnv, isTruthy } from '@/lib/core/config/env'
import { useDeploymentShape } from '@/lib/core/config/deployment-shape'
import { resolveIntegrationAccess } from '@/lib/integrations/access'
import {
DEFAULT_PERMISSION_GROUP_CONFIG,
Expand Down Expand Up @@ -54,6 +54,7 @@ export interface PermissionConfigResult {

export function usePermissionConfig(): PermissionConfigResult {
const params = useParams()
const deployment = useDeploymentShape()
const workspaceId = typeof params?.workspaceId === 'string' ? params.workspaceId : undefined

const {
Expand Down Expand Up @@ -134,15 +135,8 @@ export function usePermissionConfig(): PermissionConfigResult {
}
}, [config.allowedModelProviders])

const isInvitationsDisabled = useMemo(() => {
const featureFlagDisabled = isTruthy(getEnv('NEXT_PUBLIC_DISABLE_INVITATIONS'))
return featureFlagDisabled || config.disableInvitations
}, [config.disableInvitations])

const isPublicApiDisabled = useMemo(() => {
const featureFlagDisabled = isTruthy(getEnv('NEXT_PUBLIC_DISABLE_PUBLIC_API'))
return featureFlagDisabled || config.disablePublicApi
}, [config.disablePublicApi])
const isInvitationsDisabled = Boolean(deployment.invitationsDisabled) || config.disableInvitations
const isPublicApiDisabled = Boolean(deployment.publicApiDisabled) || config.disablePublicApi

const mergedConfig = useMemo(
() => ({ ...config, allowedIntegrations: mergedAllowedIntegrations }),
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/hooks/use-workspace-invite-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface UseWorkspaceInvitePolicyReturn {
* teammate-management action must read it.
*
* Two independent sources say no, and both have to be consulted: the deployment
* or permission-group switch (`NEXT_PUBLIC_DISABLE_INVITATIONS`, a permission
* or permission-group switch (`DISABLE_INVITATIONS`, a permission
* group's `disableInvitations`), which is silent about why, and the workspace's
* own plan policy, which supplies {@link UseWorkspaceInvitePolicyReturn.inviteDisabledReason}.
* Reading only one of them is what lets an entry point offer an invite the server
Expand Down
9 changes: 9 additions & 0 deletions apps/sim/lib/api/contracts/workspaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,15 @@ export const deploymentShapeSchema = z.object({
* with app versions that predate projecting it; readers treat absent as `open`.
*/
registrationMode: z.enum(REGISTRATION_MODES).optional(),
/**
* Server-only switches the browser used to read from `NEXT_PUBLIC_*` twins. Optional
* for rolling compatibility with app versions that predate projecting them; readers
* treat absent as `false`.
*/
e2bEnabled: z.boolean().optional(),
slackExtendedScopes: z.boolean().optional(),
invitationsDisabled: z.boolean().optional(),
publicApiDisabled: z.boolean().optional(),
})

export type DeploymentShape = z.output<typeof deploymentShapeSchema>
Expand Down
24 changes: 23 additions & 1 deletion apps/sim/lib/core/config/deployment-projection.dom.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ import { describe, expect, it, vi } from 'vitest'

vi.hoisted(() => {
vi.stubEnv('NEXT_PUBLIC_APP_URL', '')
vi.stubEnv('NEXT_PUBLIC_BILLING_ENABLED', '')
vi.stubEnv('SSO_ENABLED', 'false')
vi.stubEnv('E2B_ENABLED', 'false')
vi.stubEnv('SLACK_EXTENDED_SCOPES', 'false')
vi.stubEnv('DISABLE_INVITATIONS', 'false')
vi.stubEnv('DISABLE_PUBLIC_API', 'true')
vi.stubEnv('INBOX_ENABLED', 'true')
vi.stubEnv('REGISTRATION_MODE', 'open')
document.documentElement.setAttribute(
Expand All @@ -24,6 +27,9 @@ vi.hoisted(() => {
azureConfigured: false,
cohereConfigured: false,
registrationMode: 'closed-no-email',
e2bEnabled: true,
slackExtendedScopes: true,
invitationsDisabled: true,
features: {
sso: true,
accessControl: true,
Expand All @@ -42,13 +48,17 @@ import {
getRegistrationMode,
isAccessControlEnabled,
isAuditLogsEnabled,
isE2bEnabled,
isEmailPasswordAuthEnabled,
isEmailSignupAllowed,
isInboxEnabled,
isInvitationsDisabled,
isOrganizationsEnabled,
isPublicApiDisabled,
isSandboxesEnabled,
isSelfServeRegistrationClosed,
isSessionPoliciesEnabled,
isSlackExtendedScopesEnabled,
isSsoEnabled,
} from '@/lib/core/config/env-flags'

Expand All @@ -75,3 +85,15 @@ describe('browser registration flags', () => {
expect(isEmailPasswordAuthEnabled).toBe(false)
})
})

describe('browser deployment switches', () => {
it('take the projected server answer over the browser environment', () => {
expect(isE2bEnabled).toBe(true)
expect(isSlackExtendedScopesEnabled).toBe(true)
expect(isInvitationsDisabled).toBe(true)
})

it('read a switch the projection omits as off', () => {
expect(isPublicApiDisabled).toBe(false)
})
})
9 changes: 9 additions & 0 deletions apps/sim/lib/core/config/deployment-projection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ export function readProjectedEnterpriseFeatures(
return state
}

/**
* A top-level boolean of the projected shape, or `null` when there is no projection
* or it does not carry that field as a boolean.
*/
export function readProjectedBoolean(key: string): boolean | null {
const value = readDeploymentProjection()?.[key]
return typeof value === 'boolean' ? value : null
}

/**
* The projected registration mode, or `null` when there is no projection or it
* does not carry a recognized mode.
Expand Down
1 change: 0 additions & 1 deletion apps/sim/lib/core/config/deployment-shape.dom.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'

vi.hoisted(() => {
vi.stubEnv('NEXT_PUBLIC_APP_URL', '')
vi.stubEnv('NEXT_PUBLIC_BILLING_ENABLED', '')
vi.stubEnv('NEXT_PUBLIC_FORCE_HOSTED', '')
document.documentElement.id = '__next_error__'
})
Expand Down
14 changes: 13 additions & 1 deletion apps/sim/lib/core/config/deployment-shape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ import {
isCustomBlocksEnabled,
isDataDrainsEnabled,
isDataRetentionEnabled,
isE2bEnabled,
isForkingEnabled,
isHosted,
isInboxEnabled,
isInvitationsDisabled,
isOrganizationsEnabled,
isPublicApiDisabled,
isSandboxesEnabled,
isScimEnabled,
isSessionPoliciesEnabled,
isSlackExtendedScopesEnabled,
isSsoEnabled,
isUsageMonitoringEnabled,
} from '@/lib/core/config/env-flags'
Expand Down Expand Up @@ -108,6 +112,10 @@ export function resolveDeploymentShape(): DeploymentShape {
azureConfigured: isAzureConfigured,
cohereConfigured: isCohereConfigured,
registrationMode: getRegistrationMode(),
e2bEnabled: isE2bEnabled,
slackExtendedScopes: isSlackExtendedScopesEnabled,
invitationsDisabled: isInvitationsDisabled,
publicApiDisabled: isPublicApiDisabled,
features: {
accessControl: isAccessControlEnabled,
auditLogs: isAuditLogsEnabled,
Expand Down Expand Up @@ -135,7 +143,11 @@ function isSameDeploymentShape(seeded: DeploymentShape | null, next: DeploymentS
seeded.chatEnabled !== next.chatEnabled ||
seeded.azureConfigured !== next.azureConfigured ||
seeded.cohereConfigured !== next.cohereConfigured ||
seeded.registrationMode !== next.registrationMode
seeded.registrationMode !== next.registrationMode ||
seeded.e2bEnabled !== next.e2bEnabled ||
seeded.slackExtendedScopes !== next.slackExtendedScopes ||
seeded.invitationsDisabled !== next.invitationsDisabled ||
seeded.publicApiDisabled !== next.publicApiDisabled
) {
return false
}
Expand Down
Loading