|
1 | 1 | # Environment Variables |
2 | 2 |
|
3 | | -`.env.example` is the canonical template for local and deploy-time configuration. |
4 | | -`render.yaml` provides the Render-specific defaults and secret slots. |
| 3 | +This document matches the current TypeScript runtime in `src/config/envSchema.ts`, `src/config/env.ts`, and `src/clients/xOAuthToken.ts`. |
5 | 4 |
|
6 | | -This guide is a compact operator reference, not a second source of truth. |
| 5 | +## Required X OAuth2 |
7 | 6 |
|
8 | | -## Required for Deploy |
| 7 | +These are required for worker and engagement flows: |
9 | 8 |
|
10 | 9 | - `X_CLIENT_ID` |
11 | 10 | - `X_CLIENT_SECRET` |
12 | 11 | - `X_REFRESH_TOKEN` |
13 | | -- `KV_URL` when using Redis-backed shared state |
14 | | -- the active LLM provider key: `XAI_API_KEY`, `OPENAI_API_KEY`, or `ANTHROPIC_API_KEY` |
15 | | - |
16 | | -## Core Runtime Values |
17 | | - |
18 | | -- `LAUNCH_MODE` |
19 | | -- `LOG_LEVEL` |
20 | | -- `BOT_USERNAME` |
21 | | -- `BOT_ACTIVATION_MODE` |
22 | | -- `BOT_DENY_REPLY_MODE` |
23 | | -- `USE_REDIS` |
24 | | -- `REDIS_KEY_PREFIX` |
25 | | -- `DATA_DIR` |
26 | | -- `POLL_INTERVAL_MS` |
27 | | -- `MENTIONS_SOURCE` |
28 | | -- `ADAPTIVE_POLLING_ENABLED` |
29 | | -- `X_REFRESH_BUFFER_SECONDS` |
30 | | -- `X_OAUTH_TOKEN_URL` |
31 | | - |
32 | | -## Optional X OAuth Bootstrap State |
33 | | - |
34 | | -- `X_ACCESS_TOKEN` |
35 | | -- `X_EXPIRES_IN` |
36 | | -- `X_TOKEN_CREATED_AT` |
37 | | -- `X_BOT_USER_ID` |
38 | | - |
39 | | -## Organoid Runtime |
40 | | - |
41 | | -- `EMBODIMENTS_ENABLED` |
42 | | -- `EMBODIMENT_ORCHESTRATION_ENABLED` |
43 | | -- `EMBODIMENT_CONTINUITY_ENABLED` |
44 | | -- `EMBODIMENT_MEMORY_ENABLED` |
45 | | -- `EMBODIMENT_ROUTING_DEBUG` |
46 | | -- `EMBODIMENT_TRAIT_DRIFT_LIMIT` |
47 | | -- `EMBODIMENT_SWARM_ENABLED` |
48 | | -- `EMBODIMENT_ENSEMBLE_ENABLED` |
49 | | -- `EMBODIMENT_AUTONOMY_ENABLED` |
50 | | -- `EMBODIMENT_ARC_ENGINE_ENABLED` |
51 | | - |
52 | | -## LLM Provider Selection |
53 | | - |
54 | | -- `LLM_PROVIDER` |
55 | | -- `LLM_FALLBACK_PROVIDER` |
56 | | -- `LLM_API_KEY` |
| 12 | + |
| 13 | +## X OAuth2 Runtime |
| 14 | + |
| 15 | +- `X_ACCESS_TOKEN` - optional cached access token |
| 16 | +- `X_REFRESH_BUFFER_SECONDS` - refresh threshold before expiry |
| 17 | +- `X_OAUTH_TOKEN_URL` - OAuth2 token endpoint, default `https://api.x.com/2/oauth2/token` |
| 18 | +- `X_BOT_USER_ID` - optional cached bot user id |
| 19 | +- `X_BOT_USERNAME` - optional bot handle |
| 20 | +- `BOT_USERNAME` - fallback bot handle used by older compatibility paths |
| 21 | + |
| 22 | +## LLM Provider Routing |
| 23 | + |
57 | 24 | - `XAI_API_KEY` |
58 | 25 | - `XAI_BASE_URL` |
59 | 26 | - `XAI_MODEL_PRIMARY` |
60 | 27 | - `XAI_MODEL_FALLBACKS` |
| 28 | +- `LLM_API_KEY` - generic provider fallback used by launch env resolution |
| 29 | +- `LLM_PROVIDER` - `xai`, `openai`, or `anthropic` |
| 30 | +- `LLM_FALLBACK_PROVIDER` |
| 31 | +- `LLM_TIMEOUT_MS` |
| 32 | +- `LLM_RETRY_MAX` |
| 33 | +- `LLM_MAX_TOKENS` |
| 34 | +- `LLM_TEMPERATURE` |
61 | 35 | - `OPENAI_API_KEY` |
62 | 36 | - `OPENAI_MODEL` |
63 | 37 | - `OPENAI_BASE_URL` |
64 | 38 | - `ANTHROPIC_API_KEY` |
65 | 39 | - `ANTHROPIC_MODEL` |
66 | 40 | - `ANTHROPIC_BASE_URL` |
67 | 41 |
|
68 | | -## Optional Controls |
| 42 | +## Launch Gates |
69 | 43 |
|
70 | | -- `ALLOWLIST_HANDLES` |
71 | | -- `BOT_WHITELIST_USERNAMES` |
72 | | -- `BOT_WHITELIST_USER_IDS` |
| 44 | +- `LAUNCH_MODE` - `off`, `dry_run`, `staging`, `prod` |
| 45 | +- `DRY_RUN` - legacy compatibility flag, still supported |
| 46 | +- `LEGACY_COMPAT` - enables legacy fallback surfaces |
| 47 | +- `ALLOWLIST_HANDLES` - comma-separated staging allowlist |
| 48 | +- `DEBUG_ARTIFACTS` - enables extra debug artifacts when true |
| 49 | + |
| 50 | +## Persistence and State |
| 51 | + |
| 52 | +- `USE_REDIS` - prefer Redis when `true` |
| 53 | +- `KV_URL` - `redis://` or `rediss://` URL for the state store |
| 54 | +- `REDIS_KEY_PREFIX` - key prefix for Redis-backed state |
| 55 | +- `DATA_DIR` - filesystem state store directory for local runs |
| 56 | + |
| 57 | +## Polling and Timeline Engagement |
| 58 | + |
| 59 | +- `POLL_INTERVAL_MS` |
| 60 | +- `TIMELINE_ENGAGEMENT_ENABLED` |
| 61 | +- `TIMELINE_ENGAGEMENT_INTERVAL_MS` |
| 62 | +- `TIMELINE_ENGAGEMENT_MAX_PER_RUN` |
| 63 | +- `TIMELINE_ENGAGEMENT_MAX_PER_HOUR` |
| 64 | +- `TIMELINE_ENGAGEMENT_MAX_PER_DAY` |
| 65 | +- `TIMELINE_MIN_CONTEXT_SCORE` |
| 66 | +- `TIMELINE_MIN_FINAL_SCORE` |
| 67 | +- `TIMELINE_REQUIRE_THREAD_STRUCTURE` |
| 68 | +- `TIMELINE_SOURCE_ACCOUNTS` |
| 69 | +- `TIMELINE_KEYWORD_FILTERS` |
| 70 | +- `TIMELINE_AUTHOR_COOLDOWN_MINUTES` |
| 71 | +- `TIMELINE_CONVERSATION_COOLDOWN_MINUTES` |
| 72 | + |
| 73 | +## Solana RPC / Onchain |
| 74 | + |
| 75 | +- `SOLANA_RPC_PRIMARY_URL` |
| 76 | +- `SOLANA_RPC_FALLBACK_URL` |
| 77 | +- `BOT_TOKEN_MINT` |
| 78 | +- `BOT_TREASURY_WALLET` |
| 79 | +- `BOT_TICKER` |
| 80 | +- `BOT_PROGRAM_ID` |
| 81 | + |
| 82 | +## Server / Tooling |
| 83 | + |
| 84 | +- `PORT` |
| 85 | +- `NODE_ENV` |
73 | 86 | - `SKIP_ENV_VALIDATION` |
74 | | -- `DEBUG_ARTIFACTS` |
75 | | -- `RATE_LIMIT_BACKEND` |
76 | | -- `POLL_LOCK_ENABLED` |
77 | | -- `FULL_SPECTRUM_PROMPT` |
78 | | -- `REPLICATE_API_KEY` |
79 | | -- `REPLICATE_IMAGE_MODEL` |
80 | | -- `REPLICATE_RUN_TIMEOUT_MS` |
81 | | -- `REPLICATE_DOWNLOAD_TIMEOUT_MS` |
| 87 | + |
| 88 | +## Recommended Minimal Setup |
| 89 | + |
| 90 | +```bash |
| 91 | +X_CLIENT_ID=... |
| 92 | +X_CLIENT_SECRET=... |
| 93 | +X_REFRESH_TOKEN=... |
| 94 | +LAUNCH_MODE=dry_run |
| 95 | +USE_REDIS=false |
| 96 | +``` |
| 97 | + |
| 98 | +## Recommended Production Setup |
| 99 | + |
| 100 | +```bash |
| 101 | +X_CLIENT_ID=... |
| 102 | +X_CLIENT_SECRET=... |
| 103 | +X_REFRESH_TOKEN=... |
| 104 | +X_ACCESS_TOKEN=... |
| 105 | +LAUNCH_MODE=prod |
| 106 | +USE_REDIS=true |
| 107 | +KV_URL=redis://... |
| 108 | +SOLANA_RPC_PRIMARY_URL=https://api.mainnet-beta.solana.com |
| 109 | +``` |
82 | 110 |
|
83 | 111 | ## Notes |
84 | 112 |
|
85 | | -- Render injects platform values such as `PORT` and `NODE_ENV`. |
86 | | -- Keep secrets out of Git; fill them in Render or a local `.env` file. |
87 | | -- If a variable is not listed in `.env.example`, treat it as non-canonical. |
| 113 | +- `X_ACCESS_TOKEN` is cached only; the refresh token is the source of truth for renewal. |
| 114 | +- `LAUNCH_MODE=off` is the safest local default when you are only inspecting the repo. |
| 115 | +- Keep the older `DRY_RUN` flag only for compatibility during the transition. |
0 commit comments