Env reference

From raphaeltm/simple-agent-manager · View interactive version

Env reference is an AI agent skill from the GitHub repository raphaeltm/simple-agent-manager. Full environment variable reference for SAM. Use when adding, modifying, or documenting environment variables, configuring deployment, or working with Worker secrets.

How to use this skill

Skill file

SAM Environment Variable Reference

Installer first-owner binding

BOOTSTRAP_OWNER_EMAIL is an optional API Worker secret set by the user-owned installer before public login. Only the matching provider-verified email can establish the first administrator; leave unset for ordinary installations. Preserve it during routine updates. It is distinct from SETUP_TOKEN (a plain-text var masked in deploy logs, accepted only until setup completes or an active superadmin exists), which authorizes provider configuration rather than user login.

GitHub Environment Secrets (GitHub Settings -> Environments -> production)

Uses GH_* prefix because GitHub Actions secret names cannot start with GITHUB_*.

| Type | Name | Required |

| -------- | -------------------------------------------------- | ------------------------------------------------------------------ |

| Variable | BASE_DOMAIN | Yes |

| Variable | RESOURCE_PREFIX | No (default: sam) |

| Variable | PULUMI_STATE_BUCKET | No (default: sam-pulumi-state) |

| Variable | CF_CONTAINER_ENABLED | No (default: true; set false to force VM runtime) |

| Variable | D1_READ_REPLICATION_MODE | No (default: auto; disabled removes read replicas) |

| Variable | D1_SESSION_MODE | No (default: first-primary; disabled pins reads to primary) |

| Variable | D1_MIGRATION_CHURNING_TABLES | No (may narrow the reviewed built-in retention/expiry table list) |

| Variable | D1_MIGRATION_CHURNING_TABLE_MAX_DECREASE_PERCENT | No (default: 50; range: 0–100) |

| Variable | D1_MIGRATION_READ_ATTEMPTS | No (default: 3; range: 1–5; verification reads only) |

| Variable | D1_MIGRATION_READ_RETRY_DELAY_MS | No (default: 10000; range: 0–60000) |

| Secret | CF_API_TOKEN | Yes (requires Account → SSL and Certificates → Edit for Origin CA; optional Account Analytics → Read for Admin Analytics and the Cloudflare cost snapshot) |

| Secret | CF_ACCOUNT_ID | Yes |

| Secret | CF_ZONE_ID | Yes |

| Secret | DEVCONTAINER_CACHE_CLOUDFLARE_API_TOKEN | No (falls back to CF_API_TOKEN) |

| Secret | DEVCONTAINER_CACHE_CLOUDFLARE_ACCOUNT_ID | No (falls back to CF_ACCOUNT_ID) |

| Secret | R2_ACCESS_KEY_ID | Yes |

| Secret | R2_SECRET_ACCESS_KEY | Yes |

| Secret | PULUMI_CONFIG_PASSPHRASE | Yes |

| Secret | GH_CLIENT_ID | Yes |

| Secret | GH_CLIENT_SECRET | Yes |

| Secret | GH_APP_ID | Yes |

| Secret | GH_APP_PRIVATE_KEY | Yes |

| Secret | GH_APP_SLUG | Yes |

| Secret | GH_WEBHOOK_SECRET | Yes when GitHub App webhooks are active |

| Secret | AGENT_SIGN_IN_TRUST | No (test instances only: JSON trust config for agent sign-in through workload identity; unset => off and the Worker secret is deleted on deploy; see apps/www/src/content/docs/docs/guides/agent-sign-in.md) |

| Secret | ENCRYPTION_KEY | No (auto-generated) |

| Secret | JWT_PRIVATE_KEY | No (auto-generated) |

| Secret | JWT_PUBLIC_KEY | No (auto-generated) |

| Secret | DEPLOY_SIGNING_PRIVATE_KEY | No (auto-generated; override only) |

| Secret | DEPLOY_SIGNING_PUBLIC_KEY | No (derived during deploy; override only) |

| Secret | VAPID_PRIVATE_KEY | No (auto-generated; override only) |

| Secret | VAPID_PUBLIC_KEY | No (derived during deploy; override only) |

| Secret | VAPID_SUBJECT | No (generated contact URI; override only) |

| Variable | ORIGIN_CA_CERT_VALIDITY_DAYS | No (default: 7) |

D1_MIGRATION_CHURNING_TABLES is a comma-separated <binding>.<table> subset of the reviewed defaults: DATABASE.deployment_releases, DATABASE.diagnostic_reconciliation_state, DATABASE.github_trigger_inbox, DATABASE.github_webhook_deliveries, DATABASE.project_files, DATABASE.registry_credential_rate_limits, DATABASE.session_snapshots, DATABASE.sessions, DATABASE.trigger_executions, DATABASE.verifications, DATABASE.vm_provisioning_leases, DATABASE.webhook_deliveries, and OBSERVABILITY_DATABASE.platform_errors. It may narrow but cannot expand this list; unset uses all reviewed defaults. D1_MIGRATION_CHURNING_TABLE_MAX_DECREASE_PERCENT accepts 0–100; a decrease exactly at the configured limit is accepted and a larger decrease blocks.

ORIGIN_CA_CERT and ORIGIN_CA_KEY are legacy rotation inputs for nodes provisioned before per-node Origin CA CSR signing. They are not required for new node provisioning.

GH* to GITHUB* Mapping (done by `configure-secrets.sh`)

GitHub Secret          ->  Cloudflare Worker Secret
GH_CLIENT_ID           ->  GITHUB_CLIENT_ID
GH_CLIENT_SECRET       ->  GITHUB_CLIENT_SECRET
GH_APP_ID              ->  GITHUB_APP_ID
GH_APP_PRIVATE_KEY     ->  GITHUB_APP_PRIVATE_KEY
GH_APP_SLUG            ->  GITHUB_APP_SLUG
GH_WEBHOOK_SECRET      ->  GITHUB_WEBHOOK_SECRET

Use GH_WEBHOOK_SECRET in GitHub Actions because secret names cannot start with GITHUB_. The Worker/runtime secret remains GITHUB_WEBHOOK_SECRET, and it must match the GitHub App webhook secret exactly.

API Worker Runtime Environment Variables

See apps/api/.env.example for the full list. Key variables are listed below.

Private SAM assistant runtime controls

Use the typed Operations admin settings below for live configuration. All eight are non-secret settings stored in D1. User opt-in is a separate per-user setting and defaults to off; clearing the installation switch never enables SAM for a user.

| Admin setting key | Default | Permitted range and meaning |

| -------------------------------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------- |

| operations.samOperatorDisabled | false | Boolean; disables assistant turns/actions installation-wide while preserving saved user preferences. |

| operations.samOperatorWatchLifetimeMs | 86400000 | Integer 1–2147483647; own-work observation lifetime in milliseconds (24 hours). Expiry does not cancel the project task. |

| operations.samOperatorEventPageSize | 25 | Integer 1–25; maximum watches per scan, events per watch, and visible work cards. |

| operations.samOperatorWorkRefreshMs | 30000 | Integer 1000–2147483647; durable own-work refresh cadence in milliseconds, separate from browser refresh. |

| operations.samOperatorWatchRetryLimit | 3 | Integer 1–25; consecutive failed watch refreshes before updates stop. Successful pulls or requested follow-ups reset the count. |

| operations.samOperatorStreamFlushMs | 80 | Integer 16–2000; milliseconds between live updates while the assistant answers. |

| operations.samOperatorStreamHeartbeatMs | 15000 | Integer 1000–120000; keep-alive interval on a live answer stream. |

| operations.samOperatorStreamMaxSubscribers | 4 | Integer 1–20; browser tabs that can follow one answer live at the same time. |

Operations debugger tools (apps/api/src/services/operations-access.ts):

| Admin setting key | Default | Meaning |

| ------------------------------- | ------- | --------------------------------------------------------------------------------------------------------------- |

| operations.debuggerTools | off | off / read / read_ask / read_auto_safe; gate for ops_* MCP tools in the Operations project. No cache. |

| operations.auditRetentionDays | 90 | Integer 1–3650; days operations_audit_log rows are kept (daily 0 3 * * * purge). |

Read-tool limits for the ops_* tools (apps/api/src/services/fleet-ops/settings-definitions.ts, resolved once per call by resolveFleetOpsSettings): operations.debugPackageRetentionDays (7), operations.debugPackageMaxBytes (20 MiB, max 32 MiB), operations.debugPackagePurgeBatchSize (50 per batch, max 90), operations.debugPackagePurgeDeadlineMs (20000), operations.debugPackageCapturesPerHour (20), operations.opsAnomalyEmptyNodeGraceMs (900000), operations.opsAnomalyTerminalTaskGraceMs (900000), operations.opsAnomalyIdleTaskMinutes (60), operations.opsAnomalyDestroyingNodeHours (6), operations.opsAnomalyLookbackHours (24), operations.opsAnomalyMaxPerClass (25), operations.opsNodeLogMaxLines (200), operations.opsNodeLogMaxBytes (65536), operations.opsTimelineMaxEvents (200), operations.opsTimelinePerSourceLimit (100), operations.opsTimelineDefaultWindowHours (168), operations.opsTimelineFanoutLimit (2), operations.opsEntityGraphRowCap (25), operations.opsWorkerLogDefaultWindowMinutes (60), operations.opsListMaxRows (100), operations.opsTextFieldMaxLength (2000). Defaults, ranges and meanings: public docs guides/admin-settings.md#read-tool-limits.

Each refresh selects at most 25 watches and reads at most 25 events per watch: at most 325 caller D1 reads, 75 cold ProjectData RPCs, and 625 local event-reference inserts, plus fixed alarm setup. A work-card read performs at most 75 D1 reads. Each watch persists its next check and charges an attempt before I/O; the alarm uses the earliest watch deadline. Failed watches defer until that deadline and stop after the retry limit, with a visible update warning. The watch lifetime also stops observation independently; neither condition cancels project work.

Admin setting overrides take precedence over registry defaults. The disabled setting is read without the normal settings cache before effects and fails closed when settings storage is unavailable. These controls use the typed settings registry only; no Worker bindings or deployment variables are needed.

Sources: apps/api/src/services/operator-settings.ts, admin-settings-registry.ts, and apps/api/src/durable-objects/sam-session/operator/work.ts.

The assistant reuses existing SAM_MODEL (code default @cf/deepseek-ai/deepseek-v4.1-flash-1017 in resolveSamConfig; omitted from Wrangler bindings unless explicitly overridden through the GitHub Environment variable SAM_MODEL; this model requires the Workers Paid plan or prepaid AI Gateway credits, like the rest of SAM), context/window, tool-result and model-step limits from resolveSamConfig, plus SAM_LLM_TIMEOUT_MS (operator fallback 120000). Operator turn admission uses SAM_MESSAGE_MAX_LENGTH with a 16000-character fallback; legacy subtask-message readers can have a different fallback. No new provider API key is required specifically for enabling the assistant: it uses the installation's supported platform AI configuration and usage gate.

How Worker variables are set

scripts/deploy/sync-wrangler-config.ts (getApiWorkerVars) builds each deployed API Worker's

plain-text variables from, in order:

  1. Top-level [vars] in apps/api/wrangler.toml. It holds only values that differ from the code

default, because every entry is a Worker text binding and Cloudflare caps them per Worker

(assertWorkerTextBindingLimit fails the deploy above 340, counting vars plus every

set_worker_secret name in configure-secrets.sh).

  1. Values the deploy derives itself (BASE_DOMAIN, VERSION, R2_BUCKET_NAME, SAM_INSTALLATION_ID,

ENVIRONMENT, SETUP_TOKEN, ...), which replace any checked-in value.

  1. GitHub Environment variables whose names are in the getOptionalProcessEnvVars list and that the

deploy workflow forwards (both "Sync Wrangler Config" steps in deploy-reusable.yml). A non-empty

value replaces the checked-in value or adds the binding.

A variable that ships no binding runs with its code default. The values [vars] omits because they

equal the code default are recorded in OMITTED_WORKER_VAR_DEFAULTS

(scripts/deploy/worker-var-defaults.ts); apps/api/tests/unit/config/omitted-worker-var-defaults.test.ts

proves each one matches the real read path, and the deploy log reports an Environment override of an

omitted var against that recorded default. Defaults below are code defaults unless marked "shipped".

To run a deployment with a different value, add the var to [vars] (and delete it from the record),

or set a GitHub Environment variable when the name is forwarded. See .claude/rules/07-env-and-urls.md.

Core

Activity coalescing and binding caches are per Worker isolate. Delayed flushes carry their original observed event time, and ProjectData rejects stale writes so a delayed intermediate report cannot overwrite a newer idle/error state from another isolate.

Deployment Storage Retention

Deployment Placement Defaults

Guided Agent Credential Setup

Operational Control Loops

Implementation of the storage-safety, cleanup and preflight behavior documented above:

resolveStorageSafetyConfig() (packages/project-data/src/do/storage-safety.ts)

validates every value and fails closed on a malformed one;

runProjectDataToolPayloadCleanup() / scanToolPayloadCleanupBatch()

(.../tool-payload-cleanup.ts) apply the row/byte/wall-time and approved-plan budgets;

runProjectDataManualToolPayloadCleanup() (.../tool-payload-manual-cleanup.ts) owns the

manual slice, its fingerprint and its cooldown;

measureProjectDataStorageReliefSlice() (.../storage-relief-measurement.ts) owns the

read-only measurement, cursor and byte/deadline bounds; and

runProjectDataStorageReliefPreflight()

(packages/project-data/src/scheduled/project-data-storage-relief-preflight.ts) owns the lease, the

per-slice and per-run admission budgets, and the verified R2 manifest writes.

Absent operational brake keys and KV read errors mean enabled. This fail-open

behavior preserves availability.

GitHub Environment variables for the scheduled Durable Object monitor:

The monitor's CF_API_TOKEN GitHub Environment secret must include the

Cloudflare Workers Observability Write permission. Despite the permission

name, Cloudflare documents it for the supported telemetry query endpoint used

by the read-only cron-liveness check.

Human Input and Web Push

Devcontainer Cache

Google OAuth and GCP

Resource Limits

agent-settings validation bounds for model IDs, tool lists, additional env

entries, provider display names, and OpenCode base URLs. See

apps/api/.env.example and apps/www/src/content/docs/docs/guides/self-hosting.mdx for supported keys

and defaults.

Platform Feedback and Report an Issue

Pagination

Callback Tokens

Timeouts

Workspace Resource History

Audio/Transcription

Client Error Reporting

Project File Library

Codex OAuth Refresh Proxy (`CodexRefreshLock` DO + `/api/auth/codex-refresh`)

Credential Routes Rate Limits

Generic Webhook Triggers

Retired: Trial Onboarding

The anonymous-trial product and every TRIAL_* variable were removed in November 2026. /api/trial/*

answers 410 Gone. The migration-seeded system user and placeholder installation rows remain

(SYSTEM_USER_ID / SYSTEM_INSTALLATION_ID in packages/shared/src/system-ids.ts) and are not

configurable.

VM Agent Environment Variables

Container/User

Workspace Builds

Physical Workspace Deletion and Image-transfer Scratch

Scratch variables are read by the VM agent process; malformed values disable its scratch sweep. Workspace data, snapshot archives, user caches, nested Docker volumes, Docker build cache and deployment/rollback images are outside this sweep. Symlinks, hard links, mounts, nested directories and unknown files are protected.

Git Operations

Session Snapshots

Generated deployments validate and pass these values through cloud-init to newly provisioned VM Agent systemd services. Instant containers receive the same values at launch.

Workspace Callback Token Renewal

The agent renews each workspace callback token after a successful node heartbeat once the token is past the refresh ratio (internal/server/workspace_callback_token_renewal.go). These use their defaults unless set in the agent service environment.

File Operations

Error Reporting

Generated deployments validate and pass these values through cloud-init to newly provisioned VM Agent systemd services.

Message Reporting

ACP (Agent Communication Protocol)

Events

System Info

Active Resource Monitoring

Repeated agent check-ins

TASK_RECONCILIATION_MAX_CHECKINS (default 3) caps automatic check-ins per durable no-progress episode. Human input or a newly completed tool call resets the budget; assistant error/text and system messages do not. A recognized unsupported-model runtime error pauses check-ins before another delivery. At the cap, SAM pauses nudges and asks Clef once using the existing STALLED_TASK_CLASSIFIER_* model, timeout, confidence, and transcript limits (without the long-turn age gate). Disabled/unavailable/uncertain classification never grants additional retries. The session/work remains intact; the attention notice explains how to retry.

Fresh VM boot recovery

SAM Connector

OAUTH_KV is a Pulumi-managed KV namespace binding for the installation's OAuth provider. Connector settings use D1 platform_settings overrides, then environment fallbacks, then defaults. Read and write gates are read fresh, not cached. Configure them in Admin → Integrations → Connector.

| Variable | Default | Meaning |

| ---------------------------------------- | -------------------------------- | ------------------------------------------------------- |

| CONNECTOR_ENABLED | true | Enable the user-level Connector and OAuth authorization |

| CONNECTOR_WRITE_ENABLED | true | Permit sam.write; otherwise read-only |

| CONNECTOR_CLIENT_REGISTRATION | open | open or redirect-host allowlist |

| CONNECTOR_ACCESS_TOKEN_TTL_SECONDS | 3600 | Access-token lifetime |

| CONNECTOR_REFRESH_TOKEN_TTL_SECONDS | 2592000 | Sliding refresh-token lifetime |

| CONNECTOR_ALLOWED_REDIRECT_HOSTS | claude.ai,chatgpt.com,loopback | Registration allowlist |

| CONNECTOR_READ_RATE_LIMIT_PER_MINUTE | 120 | Per-user read budget |

| CONNECTOR_MAX_STARTS_PER_USER_PER_HOUR | 10 | Per-user hourly compute-start cap |

| CONNECTOR_WRITE_RATE_LIMIT_PER_MINUTE | 30 | Per-user write budget |

| CONNECTOR_MAX_STARTS_PER_USER_PER_DAY | 50 | Per-user daily compute-start cap |

| CONNECTOR_LIST_PAGE_SIZE | 50 | Grant/client inventory page size (maximum 1000) |

Allowed redirect hosts default to claude.ai, chatgpt.com, and loopback. The panel also controls read rate and hourly start limits. Disabling the Connector rejects existing tokens without deleting grants.

Connector response bound: CONNECTOR_RESPONSE_MAX_BYTES (default 120000) has a minimum of256bytes and caps serialized tool results (text plus structured content); oversized results return an actionable error.

OAuth public endpoints additionally use CONNECTOR_OAUTH_REQUEST_MAX_BYTES (16384), CONNECTOR_REGISTRATION_PER_IP_PER_HOUR (20), CONNECTOR_REGISTRATION_GLOBAL_PER_HOUR (100; atomic installation-wide D1 admission), and CONNECTOR_CLIENT_IDLE_TTL_SECONDS (7776000, 90 days; at least 60). The per-IP KV limit is auxiliary; the global D1 limit remains safe under parallel requests. Successful token exchanges renew idle dynamic-client expiry. Expired D1 client-index rows are removed during registration and admin client listing; static clients have no idle expiry.

Connector protocol overrides (optional GitHub environment variables are forwarded by both deployment sync steps; omitted values use runtime defaults):

| Variable | Default | Purpose |

| ---------------------------------- | ------- | ------------------------------------------------------- |

| CONNECTOR_REQUEST_MAX_BYTES | 262144 | MCP request body bound |

| CONNECTOR_CLIENT_NAME_MAX_LENGTH | 200 | Dynamic registration name length |

| CONNECTOR_REDIRECT_URI_MAX_COUNT | 10 | Dynamic registration redirect count |

| CONNECTOR_INBOX_SESSION_LIMIT | 5 | Maximum session/interaction-store fanout per inbox page |

CONNECTOR_REGISTRATION_PER_IP_PER_HOUR is a shared-egress abuse bound, not a user quota. Operators serving many clients behind vendor/NAT egress should size this and the atomic CONNECTOR_REGISTRATION_GLOBAL_PER_HOUR backstop for expected connection volume. All CONNECTOR_* environment fallbacks are forwarded into deployed Workers when explicitly configured; Admin settings remain higher-priority overrides.

Managed secret command execution (VM Agent)

The exec_with_secrets job supervisor reads these VM-agent process environment overrides (not Worker bindings):

| Variable | Default | Purpose |

| -------------------------------- | --------- | ------------------------------------------------------------------ |

| SECRET_EXEC_TIMEOUT_MS | 600000 | Default command deadline |

| SECRET_EXEC_MAX_TIMEOUT_MS | 3600000 | Maximum caller deadline |

| SECRET_EXEC_OUTPUT_BYTES | 65536 | Returned/persisted bytes per output stream |

| SECRET_EXEC_MAX_ACTIVE | 8 | Concurrent secret execution jobs per VM-agent process |

| SECRET_EXEC_BODY_BYTES | 1048576 | Private start request body limit |

| SECRET_EXEC_TRANSPORT_GRACE_MS | 2000 | Additional host transport cleanup grace after in-container cleanup |

| SECRET_EXEC_GRACE_MS | 1000 | TERM-to-KILL grace for the in-container process group |

Positive integer values override defaults. These are local VM-agent service/container configuration; generated cloud-init does not forward additional Worker variables for them. Existing WORKSPACE_TOOL_TIMEOUT_MS bounds start/status/cancel transport calls, not the accepted job lifetime. Project/profile/skill managed isSecret env values are placeholders in fresh ordinary delivery. Harness credentials and runtime secret files retain existing paths.

Durable GitHub trigger recovery

Optional Worker variables; GitHub Environment configuration variables use the corresponding GH_TRIGGER_RECOVERY_* names. The reusable deployment workflow maps these to GITHUB_TRIGGER_RECOVERY_* Worker variables in both sync/deploy phases. GitHub reserves the GITHUB_ prefix for configuration variables as well as secrets; no secrets are added.

| Variable | Default | Purpose |

| ---------------------------------------------- | ------------ | -------------------------------------------------------------------------------------------------- |

| GITHUB_TRIGGER_RECOVERY_MAX_WALL_TIME_MS | 20000 | Serial background processing budget checked between candidates; one submission may finish after it |

| GITHUB_TRIGGER_RECOVERY_LEASE_MS | 60000 | Processing lease; overlapping retries reuse one execution |

| GITHUB_TRIGGER_RECOVERY_RETRY_BASE_MS | 30000 | Initial retry backoff |

| GITHUB_TRIGGER_RECOVERY_RETRY_MAX_MS | 900000 | Maximum exponential backoff (at least base) |

| GITHUB_TRIGGER_RECOVERY_MAX_ATTEMPTS | 12 | Automatic attempt budget including crashed claims |

| GITHUB_TRIGGER_RECOVERY_BATCH_SIZE | 25 | Maximum recovery/expiry/retention rows per sweep |

| GITHUB_TRIGGER_RECOVERY_PAYLOAD_MAX_BYTES | 262144 | Maximum verified trigger intake payload bytes |

| GITHUB_TRIGGER_RECOVERY_PAYLOAD_RETENTION_MS | 86400000 | Pending payload expiry threshold (cleanup may lag) |

| GITHUB_TRIGGER_RECOVERY_DEDUP_RETENTION_MS | 7776000000 | Dedup tombstone/audit age; at least payload retention |

Signed supported GitHub trigger events are stored before ACK. Intake storage failure returns non-success. Existing cron retries with exponential backoff and execution-derived task identities; kill switches continue to apply. Payloads are erased on completion/exhaustion and when the payload age budget is reached and bounded cleanup processes the row. Tombstones protect against same-ID replay during the configured dedup window; events replayed after retention are outside that guarantee. Old pre-upgrade audit IDs are never automatically replayed. Recovery cannot restore historical payloads that were never retained.

Payload expiry and tombstone purge run in bounded batches on enabled cron ticks; backlog or a disabled operational loop can delay actual deletion beyond the configured age threshold.

Recovery submissions run in one serial waitUntil loop so other operational sweeps are not delayed. Exhausted attempts/expired payloads use the existing throttled superadmin notification path with safe generic metadata.

Archived chat Fork context: ARCHIVED_FORK_HISTORY_MAX_CHARS bounds retained human/assistant historical text (default 24000), and SAM_SESSION_MESSAGES_MAX_LIMIT bounds the newest transcript page (default 200). History is redacted before truncation; omitted text is disclosed.

External workload identity

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.