环境变量

May 20, 2026 · View on GitHub

本文列出当前仓库代码读取的环境变量。部分值可被 flags 或 config files 覆盖;command help 仍是最近的 executable reference。

仓库通用

VariableUsed byDefaultNotes
PG_DSNcg service runcg admission runcg setup project、database setup scripts、demo scriptsPostgreSQL DSN。Database-backed service、setup、admission 和 full tests 需要它。
CG_BASE_URLCLI clients、Admin Service runner、NanoBot runtimes、demo scripts提供默认时为 http://127.0.0.1:8000CommonGround Service base URL。
CG_PROJECT_IDAdmin Service runner、NanoBot runtimes、demo scriptslocal Admin/demo paths 中为 cg-demo;NanoBot runtime entrypoints 中 requiredProject namespace。

CommonGround Service

CommonGround/service/config.pyServiceConfig.from_env() 读取。

VariableDefaultNotes
CG_HOST127.0.0.1cg service run bind host。
CG_PORT8000Bind port。
CG_LOG_LEVELinfoUvicorn/service log level。
CG_SERVICE_NAMEcommonground-v3-serviceRuntime settings 中的 service name。
CG_CLAIM_TIMEOUT_SECONDS30Claim lease timeout。
CG_CLAIM_REAPER_INTERVAL_SECONDS0Claim reaper interval。
PG_DSNPostgreSQL-backed service 必需。
CG_AGENT_PROJECT_HEADERX-CG-Project-IdAgent project identity 使用的 header name。
CG_AGENT_ID_HEADERX-CG-Agent-IdAgent id identity 使用的 header name。

CLI Client

CommonGround/cli.pyCommonGround/cli_config.pyCommonGround/cli_profiles.py 读取。

VariableDefaultNotes
CG_CONFIG_PATH存在或写入时为 ~/.config/commonground/config.jsonCLI JSON config path。Flags 优先。
CG_BASE_URLhttp://127.0.0.1:8000CommonGround Service URL。
CG_AGENT_CREDENTIAL_TOKENCommonGround requests 使用的 direct AgentCredential bearer token。
CG_AGENT_CREDENTIAL_TOKEN_FILE包含 AgentCredential token 的文件。文件权限必须是 0600
CG_CALLER_PROJECT_ID无法从 command arguments 或 profile 推断 identity 时使用的 caller project id。
CG_CALLER_AGENT_IDCaller agent id;必须和 caller project id 配对。
CG_ADMIN_BASE_URLGeneral CLI 无默认;setup client-config 默认为 http://127.0.0.1:8001Profile bootstrap 使用的 Admin Service URL。
CG_ADMIN_AUTH_TOKENDirect Admin Service API bearer token。
CG_ADMIN_AUTH_TOKEN_FILELocal admission/setup flows 使用 default setup path;generic CLI 无默认,除非 config 或 env 提供包含 Admin Service API bearer token 的文件。文件权限必须是 0600
PG_DSNcg setup project seed/status 使用;未传 --pg-dsn 时 required。

cg worker claim run 还会把这些变量注入 child process:

VariableMeaning
CG_PROJECT_IDClaimed turn project id。
CG_TURN_IDClaimed turn id。
CG_AGENT_IDClaiming Agent id。
CG_CLAIM_FILEJSON claim file path。
CG_CONTEXT_FILEJSON context file path。
CG_CLAIM_TOKENJSON-serialized claim handle。

Admin Service Admission

Integrations/admin_service/admission_runner.py 和 setup helpers 读取。

VariableDefaultNotes
PG_DSNcg admission run 和 project setup 必需。
CG_BASE_URLhttp://127.0.0.1:8000Admin Service Agent 使用的 CommonGround Service URL。
CG_PROJECT_IDcg-demoLocal Admin Service API admission 的 project。
CG_ADMIN_SERVICE_TOKEN_FILE~/.local/share/commonground/operator/projects/<project_id>/admin-service.cgac包含 Admin Service AgentCredential 的文件。
CG_ADMIN_AUTH_TOKEN_FILE~/.local/share/commonground/operator/projects/<project_id>/admin-api-bearer.token包含 Admin Service API bearer token 的文件。
CG_ADMIN_HOST127.0.0.1cg admission run bind host。
CG_ADMIN_PORT8001Bind port。
CG_ADMIN_INVITE_CONFIG_JSONbyoa.conversation_worker.v1 使用的 optional invite config JSON。
CG_ADMIN_LOG_LEVELinfoUvicorn log level。

NanoBot Runtime

Integrations/nanobot/runtime/* 和 provision handlers 读取。

VariableUsed byDefaultNotes
CG_BASE_URLLeaf worker、self-root frontside、runtime clientshttp://127.0.0.1:8000CommonGround Service URL。
CG_PROJECT_IDLeaf worker、self-root frontside、demo configsRuntime entrypoints 中 requiredProject id。
CG_AGENT_IDLeaf worker、self-root frontsideRequiredRuntime Agent id。
CG_AGENT_CREDENTIAL_TOKENLeaf worker、self-root frontside、runtime client auth、demo configsRuntime clients 中 requiredAgentCredential bearer token。
CG_AGENT_CREDENTIAL_TOKEN_FILEDemo NanoBot config fragments传给在 Python entrypoint 之外解析 token file 的 runtime configs。
CG_AGENT_REGISTRATION_SPECLeaf workerOptionalEncoded registration spec。存在时,role、capabilities、grants 和 accepts_work 必须匹配已注册的 leaf Agent。
CG_PROVISION_TURN_IDLeaf workerOptional传给 provisioned leaf workers 的 source provision turn id。
NANOBOT_REPO_ROOTRuntime factory、leaf worker、provision launch envOptional;只有相邻 checkout 存在时才会 auto-detect可选的 NanoBot source checkout,用来覆盖已安装的 nanobot package。
NANOBOT_CONFIG_PATHLeaf worker、demo configsOptionalNanoBot config file path。
NANOBOT_WORKSPACELeaf workerOptionalProvisioned runtime 的 workspace path。
CG_NANOBOT_LOG_LEVELRuntime factoryINFONanoBot runtime logging level。
CG_PROVISION_LIFECYCLE_CLEANUP_INTERVAL_SECONDSscripts/demo/run_nanobot_provisioner.py30.0Demo provisioner 的 provision lifecycle cleanup interval。
CG_PROVISION_LIFECYCLE_TTL_SECONDSscripts/demo/run_nanobot_provisioner.pyDemo provisioner 的 optional provision lifecycle TTL。

Provision handlers 可能为 child runtime 构造包含 CG_BASE_URLCG_PROJECT_IDCG_AGENT_IDCG_AGENT_CREDENTIAL_TOKENCG_PROVISION_TURN_IDNANOBOT_REPO_ROOTNANOBOT_CONFIG_PATHNANOBOT_WORKSPACE 的环境。Process substrate 会在启动 child processes 前移除 CG_*CLAIM*TOKEN* 变量。

Demo 脚本与示例

scripts/demo/ 下的脚本和 examples/nanobot/ 下的 configs 读取。

VariableDefaultNotes
CG_DEMO_LOG_LEVELINFOCommon demo helpers 中的 demo logging level。
CG_HTTP_LOG_LEVELWARNINGCommon demo helpers 中的 HTTP library logging level。
CG_FRONTSIDE_AGENT_IDCommon demo helpers 中为 frontsideDemos 使用的 frontside/requester Agent id。
CG_NANOBOT_A_AGENT_IDnanobot_aDemo NanoBot A Agent id。
CG_NANOBOT_PROVISIONER_AGENT_IDnanobot_provisioner_alphaDemo provisioner Agent id。
NANOBOT_REQUESTER_WORKSPACE~/.nanobot-cg-requesterDemo helpers 使用的 requester workspace。
NANOBOT_A_WORKSPACE~/.nanobot-aNanoBot A workspace。
NANOBOT_LEAF_WORKSPACE~/.nanobot-leafLeaf workspace。
NANOBOT_PROVISIONER_WORKSPACE~/.nanobot-provisionerProvisioner workspace。
CG_BINcg-skill roundtrip demo 中为 repository .venv/bin/cg覆盖 demo scripts 使用的 cg executable path。
CG_AUTH_TOKENscripts/demo/send_demo_request.py requester config 允许透传;当前 cg CLI auth 使用 CG_AGENT_CREDENTIAL_TOKEN
CG_AUTH_TOKEN_FILEscripts/demo/send_demo_request.py requester config 允许透传;当前 cg CLI auth 使用 CG_AGENT_CREDENTIAL_TOKEN_FILE

公开 docs 和 examples 必须对 DSN、bearer tokens、provider API keys 和 workstation-specific paths 使用 placeholders。