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 apps/docs/content/docs/integrations/slack.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,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` is enabled. Enable them only after Slack approves the app for these scopes:
Requested only when `SLACK_EXTENDED_SCOPES` is enabled. Enable it only after Slack approves the app for these scopes:

| Scope | Description |
| ----- | ----------- |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ Requests use a shared anonymous session.
| `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.

## Verify authentication

Sign out and sign back in at the public origin, then open a workflow in two browser windows and confirm edits propagate. Test each enabled login method. If verification is required, create a test account and confirm the message arrives and the verification succeeds. Use [Verify your install](/platform/self-hosting/verify) for deployment checks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ Webhook triggers receive callbacks from the provider and must be able to verify
| `SLACK_SIGNING_SECRET` | Verifying Slack event and slash-command signatures |
| `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.
When enabling the native Sim Slack trigger, configure both variables together. Enable `SLACK_EXTENDED_SCOPES` 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.

Your deployment must also be reachable from the provider's servers for webhook triggers to fire — a Sim instance on a private network can use polling triggers but not webhook triggers. Polling triggers additionally require the scheduler; see [Background Jobs](/platform/self-hosting/background-jobs).

Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/platform/self-hosting/upgrades.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Check the changes for every release between your current version and the target
|---|---|
| **Redis is required.** Sim refuses to start without `REDIS_URL`; there is no PostgreSQL or in-memory fallback. | Keep the bundled Redis, or point `REDIS_URL` at a managed instance before upgrading. App and realtime must reach the same Redis. See [Redis](/platform/self-hosting/redis). |
| **`REGISTRATION_MODE` replaces `DISABLE_REGISTRATION`, `DISABLE_EMAIL_SIGNUP`, and `EMAIL_PASSWORD_SIGNUP_ENABLED`** (and its `NEXT_PUBLIC_` twin). The old variables are still honored as deprecated aliases, and the most restrictive setting wins. `NEXT_PUBLIC_EMAIL_PASSWORD_SIGNUP_ENABLED=false` now also disables email/password sign-in on the server. | Move to `REGISTRATION_MODE`. See [Control registration and sign-in](/platform/self-hosting/authentication#controlling-who-can-sign-up). |
| **Enterprise `NEXT_PUBLIC_*` flags and `NEXT_PUBLIC_SANDBOXES_ENABLED` are no longer read, nor are `NEXT_PUBLIC_BILLING_ENABLED`, `NEXT_PUBLIC_E2B_ENABLED`, `NEXT_PUBLIC_SLACK_EXTENDED_SCOPES`, `NEXT_PUBLIC_DISABLE_INVITATIONS`, and `NEXT_PUBLIC_DISABLE_PUBLIC_API`.** The browser reads the server's resolved settings. | Set the server variable for each feature (`BILLING_ENABLED`, `E2B_ENABLED`, `SLACK_EXTENDED_SCOPES`, `DISABLE_INVITATIONS`, `DISABLE_PUBLIC_API`, …). See the [feature flag reference](/platform/enterprise/self-hosted#feature-flag-reference). |
| **Enterprise `NEXT_PUBLIC_*` flags and `NEXT_PUBLIC_SANDBOXES_ENABLED` are no longer read, nor are `NEXT_PUBLIC_BILLING_ENABLED`, `NEXT_PUBLIC_E2B_ENABLED`, `NEXT_PUBLIC_SLACK_EXTENDED_SCOPES`, `NEXT_PUBLIC_DISABLE_INVITATIONS`, and `NEXT_PUBLIC_DISABLE_PUBLIC_API`.** The browser reads the server's resolved settings. | Set the server variable of the same name without the `NEXT_PUBLIC_` prefix (`BILLING_ENABLED`, `E2B_ENABLED`, `DISABLE_INVITATIONS`, …). The enterprise flags are listed in the [feature flag reference](/platform/enterprise/self-hosted#feature-flag-reference). |
| **`ALLOW_PRIVATE_DATABASE_HOSTS` was removed.** The app logs an error at startup if it is still set. | Name your database, cache, and mail hosts in the egress allowlists. See [Upgrading from an earlier release](/platform/self-hosting/security#upgrading-from-an-earlier-release). |
| **White-labeling was removed.** `NEXT_PUBLIC_BRAND_*`, `NEXT_PUBLIC_CUSTOM_CSS_URL`, `NEXT_PUBLIC_SUPPORT_EMAIL`, `NEXT_PUBLIC_DOCUMENTATION_URL`, `NEXT_PUBLIC_TERMS_URL`, `NEXT_PUBLIC_PRIVACY_URL`, `WHITELABELING_ENABLED`, and `NEXT_PUBLIC_WHITELABELING_ENABLED` are ignored. | Remove them at your convenience; leaving them set is harmless. |
| **`docker-compose.ollama.yml` is now an overlay on `docker-compose.prod.yml`.** | A stack started from the previous standalone file needs its project name carried over, or it starts on an empty database. See [Migrating from the previous Ollama stack](/platform/self-hosting/docker#migrating-from-the-previous-ollama-stack). |
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/lib/api/contracts/workspaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export const deploymentShapeSchema = z.object({
*/
registrationMode: z.enum(REGISTRATION_MODES).optional(),
/**
* Server-only switches the browser used to read from `NEXT_PUBLIC_*` twins. Optional
* Server-only switches, resolved on the server and projected for the browser. Optional
* for rolling compatibility with app versions that predate projecting them; readers
* treat absent as `false`.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const databaseUrl = readTestDatabaseUrl()
vi.mock('@sim/db', () => ({ dbReplica: { execute, select } }))
vi.mock('@/lib/core/config/redis', () => ({
getRedisClient: () => {
throw new Error('Redis is not used by this suite; the usage cache reads the ledger')
throw new Error('Redis is unavailable in this suite; the usage cache falls back to the ledger')
},
}))

Expand Down
20 changes: 20 additions & 0 deletions apps/sim/lib/core/config/deployment-shape.dom.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,26 @@ describe('seeded server shape', () => {
expect(apiKeyFieldShown('custom/model')).toBe(true)
})

it('takes a reseed that changes any top-level switch', () => {
const switches = (Object.keys(HOSTED) as (keyof DeploymentShape)[]).filter(
(key) => typeof HOSTED[key] === 'boolean'
)
expect(switches.length).toBeGreaterThan(0)
for (const key of switches) {
seedDeploymentShape(HOSTED)
const changed = { ...HOSTED, [key]: !HOSTED[key] }
seedDeploymentShape(changed)
expect(getDeploymentShape(), key).toBe(changed)
}
})

it('keeps the current seed for an equal shape', () => {
seedDeploymentShape(HOSTED)
seedDeploymentShape({ ...HOSTED, features: { ...HOSTED.features } })

expect(getDeploymentShape()).toBe(HOSTED)
})

it('is ignored when the server predates deployment projection', () => {
seedDeploymentShape(undefined)

Expand Down
16 changes: 3 additions & 13 deletions apps/sim/lib/core/config/deployment-shape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,9 @@ export function resolveDeploymentShape(): DeploymentShape {

function isSameDeploymentShape(seeded: DeploymentShape | null, next: DeploymentShape): boolean {
if (seeded === null) return false
if (
seeded.hosted !== next.hosted ||
seeded.billingEnabled !== next.billingEnabled ||
seeded.chatEnabled !== next.chatEnabled ||
seeded.azureConfigured !== next.azureConfigured ||
seeded.cohereConfigured !== next.cohereConfigured ||
seeded.registrationMode !== next.registrationMode ||
seeded.e2bEnabled !== next.e2bEnabled ||
seeded.slackExtendedScopes !== next.slackExtendedScopes ||
seeded.invitationsDisabled !== next.invitationsDisabled ||
seeded.publicApiDisabled !== next.publicApiDisabled
) {
return false
const keys = new Set([...Object.keys(seeded), ...Object.keys(next)]) as Set<keyof DeploymentShape>
for (const key of keys) {
if (key !== 'features' && seeded[key] !== next[key]) return false
}
const featureKeys = Object.keys(next.features) as (keyof DeploymentFeatures)[]
return featureKeys.every((key) => seeded.features[key] === next.features[key])
Expand Down
67 changes: 32 additions & 35 deletions apps/sim/lib/core/config/env-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,23 @@ export const isCopilotToolPermissionsEnabled = isTruthy(env.COPILOT_TOOL_PERMISS
export const isMothershipBenchmarkEnabled = isTruthy(env.MOTHERSHIP_BENCHMARK_ENABLED)

/**
* Is billing enforcement enabled.
*
* Server code reads `BILLING_ENABLED`. The browser never sees that variable and
* takes the server's answer from the deployment-shape projection on `<html>`
* (`./deployment-projection`); a document without one reads it as off.
* A server-only switch: `serverValue` on the server; in the browser, which never
* sees server variables, the server's answer from the deployment-shape projection
* on `<html>` (`./deployment-projection`), off on a document without one.
*/
function resolveServerSwitch(
serverValue: Parameters<typeof isTruthy>[0],
projectedKey: string
): boolean {
return typeof window === 'undefined'
? isTruthy(serverValue)
: (readProjectedBoolean(projectedKey) ?? false)
}

/**
* Is billing enforcement enabled (`BILLING_ENABLED`).
*/
export const isBillingEnabled =
typeof window === 'undefined'
? isTruthy(env.BILLING_ENABLED)
: (readProjectedBoolean('billingEnabled') ?? false)
export const isBillingEnabled = resolveServerSwitch(env.BILLING_ENABLED, 'billingEnabled')
Comment thread
waleedlatif1 marked this conversation as resolved.
Resolved

/**
* Is email verification enabled
Expand Down Expand Up @@ -296,15 +303,14 @@ export const isAppConfigEnabled =
* off there until review lands; a self-hosted deployment pointing at its own
* (unlisted) Slack app can opt in.
*
* Server code reads `SLACK_EXTENDED_SCOPES`; the browser reads the server's answer
* from the deployment-shape projection (see {@link isBillingEnabled}). The server
* value decides the grant; the browser value only decides what the credential
* pickers advertise and treat as missing.
* Read from `SLACK_EXTENDED_SCOPES`. The server value decides the grant; the
* browser value only decides what the credential pickers advertise and treat as
* missing.
*/
export const isSlackExtendedScopesEnabled =
typeof window === 'undefined'
? isTruthy(env.SLACK_EXTENDED_SCOPES)
: (readProjectedBoolean('slackExtendedScopes') ?? false)
export const isSlackExtendedScopesEnabled = resolveServerSwitch(
env.SLACK_EXTENDED_SCOPES,
'slackExtendedScopes'
)

/**
* Is Trigger.dev enabled for async job processing
Expand Down Expand Up @@ -553,33 +559,24 @@ export const isAzureConfigured = isTruthy(getEnv('NEXT_PUBLIC_AZURE_CONFIGURED')
export const isCohereConfigured = isTruthy(getEnv('NEXT_PUBLIC_COHERE_CONFIGURED'))

/**
* Are workspace invitations disabled for every user (`DISABLE_INVITATIONS`). The
* browser reads the server's answer from the deployment-shape projection.
* Are workspace invitations disabled for every user (`DISABLE_INVITATIONS`).
*/
export const isInvitationsDisabled =
typeof window === 'undefined'
? isTruthy(env.DISABLE_INVITATIONS)
: (readProjectedBoolean('invitationsDisabled') ?? false)
export const isInvitationsDisabled = resolveServerSwitch(
env.DISABLE_INVITATIONS,
'invitationsDisabled'
)

/**
* Is public API access disabled for every workspace (`DISABLE_PUBLIC_API`): the
* public API toggle is hidden and public API access is blocked. The browser reads
* the server's answer from the deployment-shape projection.
* public API toggle is hidden and public API access is blocked.
*/
export const isPublicApiDisabled =
typeof window === 'undefined'
? isTruthy(env.DISABLE_PUBLIC_API)
: (readProjectedBoolean('publicApiDisabled') ?? false)
export const isPublicApiDisabled = resolveServerSwitch(env.DISABLE_PUBLIC_API, 'publicApiDisabled')

/**
* Is the E2B code-execution provider switched on (`E2B_ENABLED`). Pi's cloud modes
* run in an E2B sandbox and stay hidden without it. The browser reads the server's
* answer from the deployment-shape projection.
* run in an E2B sandbox and stay hidden without it.
*/
export const isE2bEnabled =
typeof window === 'undefined'
? isTruthy(env.E2B_ENABLED)
: (readProjectedBoolean('e2bEnabled') ?? false)
export const isE2bEnabled = resolveServerSwitch(env.E2B_ENABLED, 'e2bEnabled')

/**
* Is Google OAuth login disabled
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4937,7 +4937,7 @@ async function buildOAuthScopesSection(

if (gatedScopes.length) {
section +=
'Requested only when `SLACK_EXTENDED_SCOPES` is enabled. Enable them only after Slack approves the app for these scopes:\n\n'
'Requested only when `SLACK_EXTENDED_SCOPES` is enabled. Enable it only after Slack approves the app for these scopes:\n\n'
section += scopeTable(gatedScopes, describe)
}

Expand Down
Loading