Secrets Apply Plan Contract
Secrets apply 计划契约
Section titled “Secrets apply 计划契约”本页定义了 openclaw secrets apply 执行的严格契约。
如果目标不匹配这些规则,apply 会在修改配置之前失败。
计划文件结构
Section titled “计划文件结构”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" }, }, ],}支持的目标范围
Section titled “支持的目标范围”计划目标适用于以下文档中支持的凭据路径:
目标类型行为
Section titled “目标类型行为”一般规则:
target.type必须被识别,且必须与规范化的target.path结构匹配。
兼容性别名仍然适用于现有计划:
models.providers.apiKeyskills.entries.apiKeychannels.googlechat.serviceAccount
路径验证规则
Section titled “路径验证规则”每个目标都通过以下所有验证:
type必须是已识别的目标类型。path必须是非空的点分路径。pathSegments可以省略。如果提供,它必须规范化为与path完全相同的路径。- 禁止的段会被拒绝:
__proto__、prototype、constructor。 - 规范化路径必须与目标类型的注册路径结构匹配。
- 如果设置了
providerId或accountId,它必须与路径中编码的 id 匹配。 auth-profiles.json目标需要agentId。- 创建新的
auth-profiles.json映射时,需要包含authProfileProvider。
如果目标验证失败,apply 会以如下错误退出:
Invalid plan target path for models.providers.apiKey: models.providers.openai.baseUrl无效计划不会执行任何写入。
运行时和审计范围说明
Section titled “运行时和审计范围说明”- 仅包含引用的
auth-profiles.json条目(keyRef/tokenRef)包含在运行时解析和审计覆盖范围内。 secrets apply写入支持的openclaw.json目标、支持的auth-profiles.json目标和可选的清除目标。
# 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如果 apply 因无效目标路径消息而失败,请使用 openclaw secrets configure 重新生成计划或将目标路径修改为上述支持的结构。