配置 Figena CLI profile
为每个工作区或环境分别保存设置和凭据,并按命令选择要用的 profile。
开发者工具Figena CLI4 分钟阅读
概述
profile 是一组命名的设置,并带有自己的凭据。每个环境或工作区使用一个 profile,例如 production 和 staging,这样命令就不会误发到错误的地方。CLI 一开始有一个名为 default 的 profile。
可以保存的设置
apiBaseUrl:Figena API 地址,例如https://api.figena.com/api。orgId:默认工作区 ID,需要--org的命令会改用它。workspaceId:随 profile 保存,供你参考。当前的命令从orgId读取工作区。output:默认输出格式,可选table、json或ndjson。authType:profile 记录的凭据类型,user或service。
其他键会被拒绝,提示“unsupported config key”;无效的输出格式或凭据类型同样会被拒绝。
创建和切换 profile
# 创建 profile 并设为当前 profilefigena config init --profile production --api-base-url https://api.figena.com/api# 再添加一个 profile,但不切换过去figena profile create staging --api-base-url <staging-api-url># 列出 profile,当前的会被标出figena profile list# 切换当前 profilefigena profile use staging查看和修改设置
figena config set orgId <workspace-id>figena config set output jsonfigena config get orgIdfigena config showconfig set 和 config get 作用于本条命令选中的 profile。config show 输出当前 profile 名称、正在使用的 profile 及其设置。
为单条命令选择 profile
加上 --profile <name> 可以让单条命令使用另一个 profile;加上 --api-base-url <url> 可以只为这条命令覆盖 API 地址,不会保存。全局选项写在命令名之前或之后都可以。
figena --profile staging auth statusfigena runs list --profile production --output json查找工作区 ID
agents list、runs list、knowledge list 等命令需要来自 --org 或 profile 中 orgId 的工作区 ID。使用 Agent Key 时,figena openport workspaces 会列出这把密钥可以访问的工作区;否则请向工作区管理员索取。缺少 ID 时,这些命令会停止,并提示类似“agents list requires --org or profile orgId”的信息。