設定 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」的訊息。