Appearance
Auth 凭证语义
本文定义了以下功能所共用的凭证资质判断与解析语义规范:
resolveAuthProfileOrderresolveApiKeyForProfilemodels status --probedoctor-auth
目标是保持选择时与运行时的行为一致。
稳定错误码
okmissing_credentialinvalid_expiresexpiredunresolved_ref
Token 凭证
Token 凭证(type: "token")支持内联 token 和/或 tokenRef。
资质判断规则
- 当
token和tokenRef均缺失时,该 profile 不可用。 expires为可选字段。- 若
expires存在,必须是大于0的有限数值。 - 若
expires无效(NaN、0、负数、非有限值或类型错误),该 profile 不可用,错误码为invalid_expires。 - 若
expires已过期,该 profile 不可用,错误码为expired。 tokenRef不能绕过expires校验。
解析规则
- 解析器对
expires的处理与资质判断语义一致。 - 对于可用的 profile,token 内容可从内联值或
tokenRef解析。 - 无法解析的引用会在
models status --probe输出中产生unresolved_ref。
兼容旧脚本的报错格式
为保持脚本兼容性,probe 错误的第一行保持不变:
Auth profile credentials are missing or expired.
后续行可添加人性化说明和稳定错误码。