Secrets apply plan contract
此页面定义了由 openclaw secrets apply 执行的严格合约。
如果目标不符合这些规则,apply 将在变更配置之前失败。
Plan file shape
Section titled “Plan file shape”openclaw secrets apply --from <plan.json> 期望一个 targets 计划目标数组:
{ version: 1, protocolVersion: 1, targets: [ { type: "models.providers.apiKey", path: "models.providers.openai.apiKey", pathSegments: ["models", "providers", "openai", "apiKey"], providerId: "openai", ref: { source: "env", provider: "default", id: "OPENAI_API_KEY" }, }, { type: "auth-profiles.api_key.key", path: "profiles.openai:default.key", pathSegments: ["profiles", "openai:default", "key"], agentId: "main", ref: { source: "env", provider: "default", id: "OPENAI_API_KEY" }, }, ],}Supported target scope
Section titled “Supported target scope”以下位置中支持的凭证路径接受计划目标:
Target type behavior
Section titled “Target type behavior”General rule:
target.type必须被识别,并且必须匹配规范化target.path形状。
现有计划仍接受兼容性别名:
models.providers.apiKeyskills.entries.apiKeychannels.googlechat.serviceAccount
Path validation rules
Section titled “Path validation rules”每个目标都通过以下所有条件进行验证:
type必须是已识别的目标类型。path必须是非空的点路径。pathSegments可以省略。如果提供,它必须规范化为与path完全相同的路径。- 禁止的段将被拒绝:
__proto__、prototype、constructor。 - 规范化路径必须匹配目标类型的注册路径形状。
- 如果设置了
providerId或accountId,它必须匹配路径中编码的 id。 auth-profiles.json目标需要agentId。- 创建新的
auth-profiles.json映射时,请包含authProfileProvider。
Failure behavior
Section titled “Failure behavior”如果目标验证失败,apply 将退出并显示类似以下的错误:
Invalid plan target path for models.providers.apiKey: models.providers.openai.baseUrl对于无效的计划,不会提交任何写入操作。
Exec 提供商 consent behavior
Section titled “Exec 提供商 consent behavior”--dry-run默认跳过 exec SecretRef 检查。- 除非设置了
--allow-exec,否则包含 exec SecretRefs/providers 的计划将在写入模式下被拒绝。 - 在验证/应用包含 exec 的计划时,请在 dry-run 和 write 命令中都传递
--allow-exec。
Runtime and audit scope notes
Section titled “Runtime and audit scope notes”- 仅限引用的
auth-profiles.json条目(keyRef/tokenRef)包含在运行时解析和审计覆盖范围内。 secrets apply会写入受支持的openclaw.json目标、受支持的auth-profiles.json目标以及可选的清理目标。
Operator 检查
Section titled “Operator 检查”# Validate plan without writesopenclaw secrets apply --from /tmp/openclaw-secrets-plan.json --dry-run
# Then apply for realopenclaw secrets apply --from /tmp/openclaw-secrets-plan.json
# For exec-containing plans, opt in explicitly in both modesopenclaw secrets apply --from /tmp/openclaw-secrets-plan.json --dry-run --allow-execopenclaw secrets apply --from /tmp/openclaw-secrets-plan.json --allow-exec如果 apply 失败并显示无效目标路径消息,请使用 openclaw secrets configure 重新生成计划,或者将目标路径修复为上述支持的形状。