本文档定义了在以下范围内使用的规范凭据资格与解析语义:Documentation Index
Fetch the complete documentation index at: https://openclaw.zhcndoc.com/llms.txt
Use this file to discover all available pages before exploring further.
resolveAuthProfileOrderresolveApiKeyForProfilemodels status --probedoctor-auth
稳定的探测原因码
okexcluded_by_auth_ordermissing_credentialinvalid_expiresexpiredunresolved_refno_model
Token 凭据
Token 凭据(type: "token")支持内联 token 和/或 tokenRef。
资格规则
- 当
token和tokenRef都不存在时,token 配置文件不具备资格。 expires为可选项。- 如果存在
expires,它必须是一个大于0的有限数字。 - 如果
expires无效(NaN、0、负数、非有限值或类型错误),则该配置文件不具备资格,原因码为invalid_expires。 - 如果
expires位于过去,则该配置文件不具备资格,原因码为expired。 tokenRef不会绕过expires校验。
解析规则
- 解析器语义与
expires的资格语义一致。 - 对于具备资格的配置文件,token 材料可以从内联值或
tokenRef中解析。 - 无法解析的引用会在
models status --probe输出中产生unresolved_ref。
Agent 复制可移植性
Agent 认证继承采用读穿透方式。当某个 agent 没有本地配置文件时,它可以在运行时从默认/main agent 存储中解析配置文件,而无需将密钥材料复制到自己的auth-profiles.json 中。
显式复制流程(例如 openclaw agents add)使用此可移植性策略:
api_key配置文件默认可移植,除非copyToAgents: false。token配置文件默认可移植,除非copyToAgents: false。oauth配置文件默认不可移植,因为刷新令牌可能是一次性的或对轮换敏感。- 由提供方拥有的 OAuth 流程只有在已知跨 agent 复制刷新材料是安全的情况下,才可选择设置
copyToAgents: true。
显式 auth 顺序过滤
- 当为某个提供方设置了
auth.order.<provider>或 auth-store 顺序覆盖时,models status --probe只会探测保留在该提供方已解析 auth 顺序中的配置文件 id。 - 该提供方中被显式顺序省略的已存储配置文件不会在之后被静默尝试。探测输出会将其报告为
reasonCode: excluded_by_auth_order,并给出细节Excluded by auth.order for this provider.
探测目标解析
- 探测目标可以来自 auth 配置文件、环境凭据或
models.json。 - 如果某个提供方有凭据,但 OpenClaw 无法为其解析出可探测的模型候选项,
models status --probe会以status: no_model和reasonCode: no_model报告。
外部 CLI 凭据发现
- 仅当当前操作的 provider、runtime 或 auth profile 处于作用域内时,或者当该外部来源的已存储本地配置文件已经存在时,才会发现外部 CLI 拥有的仅运行时凭据。
- Auth-store 调用方应选择明确的 external-CLI 发现模式:
none表示仅持久化/plugin auth,existing表示刷新已存储的 external CLI 配置文件,或scoped表示针对具体 provider/profile 集合。 - 只读/状态路径会传递
allowKeychainPrompt: false;它们仅使用文件后备的 external CLI 凭据,不读取或重用 macOS Keychain 结果。
OAuth SecretRef 策略保护
- SecretRef 输入仅用于静态凭据。
- 如果某个配置文件凭据的
type为oauth,则不支持该配置文件凭据材料使用 SecretRef 对象。 - 如果
auth.profiles.<id>.mode为"oauth",则该配置文件基于 SecretRef 的keyRef/tokenRef输入会被拒绝。 - 违反上述规则会在启动/重载 auth 解析路径中导致硬失败。
向后兼容消息
为兼容脚本,探测错误保持第一行不变:Auth profile credentials are missing or expired.
后续行可添加更友好的说明和稳定的原因码。