使用多个 Profile¶
Profile 保存一个账号的登录信息、站点地址和当前工作空间。可为不同账号设置别名,例如 customer-a 和 customer-b。升级前已保存的 API Key Profile 仍可使用。
新增和切换¶
先用账号 A 登录 Studio,在「个人 API 密钥」页面生成临时授权码。运行 owl profile add customer-a,按提示输入所属站点的 HTTPS Registry 地址和临时码。再用账号 B 生成的新码添加 B。输入临时码时,终端隐藏内容。查看站点地址
owl profile add customer-a
owl switch customer-a
owl profile add customer-b
owl profile current
owl --profile customer-b sync
owl --profile customer-b exec owl.workspace.member.list --page_size 1
添加 B 后,默认账号仍是 A。--profile customer-b 只为当前命令选择 B;运行 owl switch customer-b 可让后续命令使用 B。添加账号需要在线兑换临时码,切换只检查本地配置。
别名区分大小写,长度为 1–80 个字符,可使用字母、数字、短横线和下划线,须以字母或数字开头。别名已存在时换一个名称,临时码仍可使用。
沿用已有配置¶
--from 可沿用文件中的站点地址、超时等非身份设置,但仍需用新账号的临时授权码登录。源文件中的 API Key、token_file 和 DPoP 绑定不会复制到新 Profile,源文件保持不变。
临时选择和脚本¶
选择优先级为 --profile > OWL_PROFILE > owl switch 保存的默认值。对 exec、tool exec、tools exec 和校验命令,将 --profile 放在命令前。临时选择不修改默认账号。
owl --profile customer-b profile current -f json
OWL_PROFILE=customer-b owl profile current -f json
owl profile list -f json
Agent 可以通过 OWL_TEMP_CODE 提供新账号的临时码。下面的命令从 OWL_REGISTRY_ENDPOINT 读取站点地址。不要将临时码写入命令、日志或共享文件。
选中 Profile 后,Endpoint 和凭证取自该 Profile,身份环境变量不会覆盖它。非身份环境设置仍生效。设置了 OWL_PROFILE 时,先取消该变量才能执行 owl switch。请求失败不会自动改用其他 Profile。
退出账号和切换工作空间¶
下面的命令保留 A 为默认账号,撤销 B 的 DPoP 凭证。以后重新登录 B 时,使用 B 新生成的临时授权码。DPoP 的 workspace use 必须传工作空间 UUID,并在线验证目标空间。
owl switch customer-a
owl --profile customer-b logout
owl --profile customer-b login --dpop
owl --profile customer-b workspace use wksp_example
同一安装中,同站点同账号的多个别名共用 DPoP 登录状态,退出其中一个会同时退出其余别名。工作空间列表、API Key 获取及依赖 Key 的工作空间管理命令仍需使用 API Key Profile。
文件与配置兼容¶
默认根目录为 ~/.owl,可通过 OWL_DIR 修改。命名 Profile 在 profiles/ 下独立保存配置、缓存、查询文件和日志。dpop/ 保存本机凭证和私钥,备份时应妥善保管。工具缓存按身份隔离。
原 ${OWL_DIR}/config.yaml 保留为 default,不会搬迁。未选择 Profile 时,旧配置和环境变量优先级保持兼容。CLI 的 --conf 已弃用,但仍按原方式读写指定文件,并忽略 OWL_PROFILE 与持久化选择;它不能与 --profile 同用。Registry 的 --config 不受影响。
命令行补全¶
启用 Bash 或 PowerShell 补全后,可用 Tab 提示已有 Profile 别名。补全只读本地缓存,不联网、不切换账号,也不执行工具。新别名需手动输入。
重命名与删除¶
owl profile rename customer-a customer-a-prod
owl profile remove customer-b
owl profile remove obsolete-profile --purge
删除 Profile 不撤销远端 DPoP 凭证;要撤销,先执行对应 Profile 的 logout。默认删除保留 cache/data,--purge 一并清理这些目录。清理失败时保留或恢复配置和别名,已删除的缓存或文件不会恢复。删除当前默认前先切换账号,default 不能重命名或删除。
Agent 管理的运行时 Profile¶
支持 runtime-profile/v1 的 CLI 接受执行器同时注入 OWL_RUNTIME_PROFILE(稳定、非秘密别名)、OWL_RUNTIME_ENDPOINT 和 OWL_RUNTIME_TOKEN。任一变量存在即进入完整校验;每次调用都必须携带非空运行时 Key,不能回退到安装凭据。该模式锁定 Profile 和 endpoint,拒绝 --conf、其他 --profile、owl switch、登录及配置变更。
运行时配置位于 OWL_DIR/profiles/runtime-<别名哈希>,独立保存 cache/data/log/index;配置仅保存 endpoint 与 auth.runtime: true,不保存 Key,也不登记到 state.yaml。同一用户更换 Key 后保留产物目录,但 endpoint/Key 改变会更新缓存身份。执行器应按 deployment/workspace/user 构造别名,必要时隔离外层 Agent 目录。
OWL_RUNTIME_TOKEN 优先于所选 Profile 的认证信息。未启用运行时协议时,已有普通 Profile 与 OWL_API_KEY / OWL_TOKEN 优先级保持不变。运行时 Profile 不提供操作系统沙箱,同一 UID 的环境和文件访问仍由宿主管理。配套发布顺序为 Owl → Agent 完整发行包 → 重装启用用户模式;回滚前先关闭用户模式并重装。