Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(cli): mask agent env values in get and set output (MUL-10241) (#11614)
T Mohan Aditya15271962b189
diff --git a/apps/docs/content/docs/cli.fr.mdx b/apps/docs/content/docs/cli.fr.mdxindex 47fc23bc57..3a0b4bba8e 100644--- a/apps/docs/content/docs/cli.fr.mdx+++ b/apps/docs/content/docs/cli.fr.mdx@@ -291,7 +291,7 @@ multica agent env set <agent-id> --custom-env-stdin < agent-env.jsonmultica agent update <agent-id> --mcp-config-file ./mcp.json```-- Les options `--custom-env` n'existent que sur `agent create`. Pour modifier les variables ensuite, utilisez `agent env set`, qui remplace l'ensemble ; les clés dont la valeur est `****` gardent leur valeur actuelle.+- Les options `--custom-env` n'existent que sur `agent create`. Pour modifier les variables ensuite, utilisez `agent env set`, qui remplace l'ensemble ; les clés dont la valeur est `****` gardent leur valeur actuelle. `agent env get` et `agent env set` affichent les valeurs masquées en `****` ; ajoutez `--show-values` pour les voir, par exemple pour copier les variables vers un autre agent.- `agent update --mcp-config null` efface la configuration MCP.- `--custom-args` est un tableau JSON placé à la fin des arguments de lancement. Choisissez le modèle avec `--model` ; certains outils refusent un `--model` dans les arguments personnalisés.- `--permission-mode` détermine qui peut invoquer l'agent : `private` pour le propriétaire seul, ou `public_to` avec `--public-to-workspace` ou `--public-to-member <user-id>`. `--visibility private|workspace` est l'ancienne forme, convertie en `--permission-mode` ; si les deux sont fournis, `--permission-mode` l'emporte.@@ -540,7 +540,7 @@ Migration depuis l'ancien découpage CSV : remplacez `--attachment a,b` par `--a| | `copy <agent-id>` | Copier dans un nouvel agent ; l'original reste intact | `--name` (par défaut, le nom d'origine suivi de ` (copy)`), `--runtime-id` (copier vers un autre runtime exige aussi `--model`), `--no-skills` ; la configuration secrète comme `custom_env`, `mcp_config` et `runtime_config` n'est pas copiée — fournissez-la à nouveau avec les mêmes options que pour `create` || | `tasks <id>` | Afficher les exécutions d'un agent | || | `avatar <id>` | Envoyer un avatar | |-| | `env get/set <agent-id>` | Lire et écrire les variables d'environnement personnalisées (propriétaire de l'agent ou owner/admin de l'espace de travail ; chaque lecture est enregistrée) | `set` : `--custom-env` / `--custom-env-file` / `--custom-env-stdin` ; remplace l'ensemble, et les clés dont la valeur est `****` gardent leur valeur |+| | `env get/set <agent-id>` | Lire et écrire les variables d'environnement personnalisées (propriétaire de l'agent ou owner/admin de l'espace de travail ; chaque lecture est enregistrée) | `set` : `--custom-env` / `--custom-env-file` / `--custom-env-stdin` ; remplace l'ensemble, et les clés dont la valeur est `****` gardent leur valeur. Les valeurs s'affichent en `****` sauf avec `--show-values` || | `skills list/set/add <agent-id>` | Gérer les skills rattachés | `--skill-ids` (`set` remplace toute la liste, `add` ajoute à la suite) || | `mcp list/add/enable/disable/remove <agent-id>` | Assigner des serveurs MCP de l'espace de travail à cet agent | Récupérez l'ID du serveur avec `workspace mcp list`. Une entrée de la bibliothèque n'a aucun effet tant qu'elle n'est pas ajoutée ici ; `disable` cesse de l'envoyer sans supprimer l'assignation || `autopilot` | `list/get/create/update/delete` | Gérer les automatisations | `create` : `--title`, `--mode` (obligatoires), exactement une option parmi `--agent` / `--squad` / `--squad-id` (obligatoire), `--description`, `--issue-title-template`, `--project`, `--subscriber` (répétable) |diff --git a/apps/docs/content/docs/cli.ja.mdx b/apps/docs/content/docs/cli.ja.mdxindex e12afa2216..cc5e0fd192 100644--- a/apps/docs/content/docs/cli.ja.mdx+++ b/apps/docs/content/docs/cli.ja.mdx@@ -291,7 +291,7 @@ multica agent env set <agent-id> --custom-env-stdin < agent-env.jsonmultica agent update <agent-id> --mcp-config-file ./mcp.json```-- `--custom-env` 系のフラグは `agent create` にしかありません。後から変えるときは `agent env set` を使います。これは全体を置き換え、値を `****` にしたキーは元の値を保ちます。+- `--custom-env` 系のフラグは `agent create` にしかありません。後から変えるときは `agent env set` を使います。これは全体を置き換え、値を `****` にしたキーは元の値を保ちます。`agent env get` と `agent env set` の出力では値が `****` で表示されます。別のエージェントへコピーするときなど、実際の値が必要なら `--show-values` を付けます。- `agent update --mcp-config null` で MCP 設定を消去します。- `--custom-args` は JSON 配列で、起動引数の最後に置かれます。モデルは `--model` で選んでください。カスタム引数の中の `--model` を受け付けないツールもあります。- エージェントを呼び出せる人は `--permission-mode` で決めます。`private` は所有者だけ、`public_to` は `--public-to-workspace` または `--public-to-member <user-id>` と組み合わせます。`--visibility private|workspace` は古い書き方で、`--permission-mode` に対応付けられます。両方を指定した場合は `--permission-mode` が優先されます。@@ -532,7 +532,7 @@ CSV 形式からの移行: 2 つのファイルを添付する場合は `--attac| | `copy <agent-id>` | 新しいエージェントとして複製。元のエージェントは変更されません | `--name`(デフォルトは元の名前 + ` (copy)`)、`--runtime-id`(別のランタイムへ複製する場合は `--model` の同時指定が必須)、`--no-skills`;`custom_env`、`mcp_config`、`runtime_config` などの機密設定は複製されないため、`create` と同じフラグで再指定してください || | `tasks <id>` | エージェントの実行を表示 | || | `avatar <id>` | アバターをアップロード | |-| | `env get/set <agent-id>` | カスタム環境変数の読み書き(エージェントの所有者、またはワークスペースの owner/admin。読み取りはすべて記録される) | `set`: `--custom-env` / `--custom-env-file` / `--custom-env-stdin`。全体を置き換え、値が `****` のキーは元の値を保つ |+| | `env get/set <agent-id>` | カスタム環境変数の読み書き(エージェントの所有者、またはワークスペースの owner/admin。読み取りはすべて記録される) | `set`: `--custom-env` / `--custom-env-file` / `--custom-env-stdin`。全体を置き換え、値が `****` のキーは元の値を保つ。出力の値は `--show-values` を付けない限り `****` || | `skills list/set/add <agent-id>` | 紐付けられたスキルを管理 | `--skill-ids`(`set` は全置換、`add` は追加) || | `mcp list/add/enable/disable/remove <agent-id>` | ワークスペース MCP サーバーをこのエージェントに割り当て | server id は `workspace mcp list` から取得。ライブラリの項目はここで追加するまで機能しません。`disable` は割り当てを残したまま送信を停止します || `autopilot` | `list/get/create/update/delete` | オートパイロットを管理 | `create`: `--title`、`--mode`(どちらも必須)、`--agent` / `--squad` / `--squad-id` のいずれか1つ(必須)、`--description`、`--issue-title-template`、`--project`、`--subscriber`(繰り返し可) |diff --git a/apps/docs/content/docs/cli.ko.mdx b/apps/docs/content/docs/cli.ko.mdxindex 95552bda7e..1daad127c5 100644--- a/apps/docs/content/docs/cli.ko.mdx+++ b/apps/docs/content/docs/cli.ko.mdx@@ -291,7 +291,7 @@ multica agent env set <agent-id> --custom-env-stdin < agent-env.jsonmultica agent update <agent-id> --mcp-config-file ./mcp.json```-- `--custom-env` 계열 플래그는 `agent create`에만 있습니다. 나중에 바꿀 때는 `agent env set`을 쓰며, 전체를 교체하고 값이 `****`인 키는 기존 값을 유지합니다.+- `--custom-env` 계열 플래그는 `agent create`에만 있습니다. 나중에 바꿀 때는 `agent env set`을 쓰며, 전체를 교체하고 값이 `****`인 키는 기존 값을 유지합니다. `agent env get`과 `agent env set`은 값을 `****`로 가려서 출력하며, 다른 에이전트로 복사할 때처럼 실제 값이 필요하면 `--show-values`를 붙입니다.- `agent update --mcp-config null`은 MCP 설정을 지웁니다.- `--custom-args`는 JSON 배열이며 실행 인수의 맨 끝에 붙습니다. 모델은 `--model`로 고르세요. 사용자 지정 인수 안의 `--model`을 거부하는 도구도 있습니다.- 에이전트를 호출할 수 있는 사람은 `--permission-mode`로 정합니다. `private`은 소유자만, `public_to`는 `--public-to-workspace` 또는 `--public-to-member <user-id>`와 함께 씁니다. `--visibility private|workspace`는 예전 방식이며 `--permission-mode`로 변환됩니다. 둘 다 지정하면 `--permission-mode`가 우선합니다.@@ -532,7 +532,7 @@ CLI 설정 파일에는 사용자를 대신해 Multica에 접근할 수 있는 t| | `copy <agent-id>` | 원래 에이전트에 영향 없이 새 에이전트로 복사 | `--name`(기본값은 원래 이름 + ` (copy)`), `--runtime-id`(다른 런타임으로 복사할 때 `--model`도 필수), `--no-skills`. `custom_env`, `mcp_config`, `runtime_config` 같은 기밀 설정은 복사되지 않으며 `create`와 같은 flag로 다시 제공해야 함 || | `tasks <id>` | 에이전트 실행 확인 | || | `avatar <id>` | 아바타 업로드 | |-| | `env get/set <agent-id>` | 사용자 지정 환경 변수 읽기/쓰기(에이전트 소유자 또는 워크스페이스 owner/admin. 읽을 때마다 기록됨) | `set`: `--custom-env` / `--custom-env-file` / `--custom-env-stdin`. 전체를 교체하며 값이 `****`인 키는 기존 값 유지 |+| | `env get/set <agent-id>` | 사용자 지정 환경 변수 읽기/쓰기(에이전트 소유자 또는 워크스페이스 owner/admin. 읽을 때마다 기록됨) | `set`: `--custom-env` / `--custom-env-file` / `--custom-env-stdin`. 전체를 교체하며 값이 `****`인 키는 기존 값 유지. 출력 값은 `--show-values`가 없으면 `****` || | `skills list/set/add <agent-id>` | 연결된 스킬 관리 | `--skill-ids`(`set`은 전체 교체, `add`는 증분 추가) || | `mcp list/add/enable/disable/remove <agent-id>` | 워크스페이스 MCP 서버를 이 에이전트에 할당 | server id는 `workspace mcp list`에서 확인. 라이브러리 항목은 여기서 추가하기 전까지 동작하지 않으며, `disable`은 할당을 유지한 채 전달만 중단합니다 || `autopilot` | `list/get/create/update/delete` | 자동화 관리 | `create`: `--title`, `--mode`(둘 다 필수), `--agent` / `--squad` / `--squad-id` 중 하나만(필수), `--description`, `--issue-title-template`, `--project`, `--subscriber`(반복 가능) |diff --git a/apps/docs/content/docs/cli.mdx b/apps/docs/content/docs/cli.mdxindex 965e71fe03..5586c8627e 100644--- a/apps/docs/content/docs/cli.mdx+++ b/apps/docs/content/docs/cli.mdx@@ -291,7 +291,7 @@ multica agent env set <agent-id> --custom-env-stdin < agent-env.jsonmultica agent update <agent-id> --mcp-config-file ./mcp.json```-- The `--custom-env` flags exist only on `agent create`. Change variables later with `agent env set`, which replaces the whole set; keys whose value is `****` keep their existing value.+- The `--custom-env` flags exist only on `agent create`. Change variables later with `agent env set`, which replaces the whole set; keys whose value is `****` keep their existing value. `agent env get` and `agent env set` print values masked as `****`; add `--show-values` to see them, for example to copy variables to another agent.- `agent update --mcp-config null` clears the MCP configuration.- `--custom-args` is a JSON array placed at the end of the launch arguments. Choose the model with `--model`; some tools reject `--model` inside custom arguments.- `--permission-mode` controls who can invoke the agent: `private` for the owner only, or `public_to` with `--public-to-workspace` or `--public-to-member <user-id>`. `--visibility private|workspace` is the older form and maps onto `--permission-mode`; when both are given, `--permission-mode` wins.@@ -549,7 +549,7 @@ Migration from CSV parsing: replace `--attachment a,b` with `--attachment a --at| | `copy <agent-id>` | Copy into a new agent; the original is untouched | `--name` (defaults to the original name plus ` (copy)`), `--runtime-id` (copying to another runtime also requires `--model`), `--no-skills`; secret configuration such as `custom_env`, `mcp_config`, and `runtime_config` is not copied — re-provide it with the same flags as `create` || | `tasks <id>` | View an agent's runs | || | `avatar <id>` | Upload an avatar | |-| | `env get/set <agent-id>` | Read and write custom environment variables (agent owner or workspace owner/admin; every read is recorded) | `set`: `--custom-env` / `--custom-env-file` / `--custom-env-stdin`; replaces the whole set, and keys whose value is `****` keep their existing value |+| | `env get/set <agent-id>` | Read and write custom environment variables (agent owner or workspace owner/admin; every read is recorded) | `set`: `--custom-env` / `--custom-env-file` / `--custom-env-stdin`; replaces the whole set, and keys whose value is `****` keep their existing value. Values are printed as `****` unless `--show-values` || | `skills list/set/add <agent-id>` | Manage attached skills | `--skill-ids` (`set` replaces the full list, `add` appends) || | `mcp list/add/enable/disable/remove <agent-id>` | Assign workspace MCP servers to this agent | Take the server id from `workspace mcp list`. A library entry does nothing until it is added here; `disable` stops sending it without dropping the assignment || `autopilot` | `list/get/create/update/delete` | Manage automations | `create`: `--title`, `--mode` (both required), exactly one of `--agent` / `--squad` / `--squad-id` (required), `--description`, `--issue-title-template`, `--project`, `--subscriber` (repeatable) |diff --git a/apps/docs/content/docs/cli.zh-Hant.mdx b/apps/docs/content/docs/cli.zh-Hant.mdxindex 0e98825a60..d817a7689c 100644--- a/apps/docs/content/docs/cli.zh-Hant.mdx+++ b/apps/docs/content/docs/cli.zh-Hant.mdx@@ -282,7 +282,7 @@ multica agent env set <agent-id> --custom-env-stdin < agent-env.jsonmultica agent update <agent-id> --mcp-config-file ./mcp.json```-- `--custom-env` 系列只在 `agent create` 中可用。之後修改用 `agent env set`,它整體替換原有變數,值寫成 `****` 的鍵保留原值。+- `--custom-env` 系列只在 `agent create` 中可用。之後修改用 `agent env set`,它整體替換原有變數,值寫成 `****` 的鍵保留原值。`agent env get` 和 `agent env set` 輸出的值都顯示為 `****`,要看原值(例如複製到另一個 AI 代理)請加 `--show-values`。- `agent update --mcp-config null` 清除 MCP 配置。- `--custom-args` 是 JSON 陣列,排在啟動引數的最後。選模型用 `--model`,部分工具會拒絕出現在自定義引數裡的 `--model`。- 誰能呼叫 AI 代理用 `--permission-mode`:`private` 只有所有者,`public_to` 配合 `--public-to-workspace` 或 `--public-to-member <user-id>`。`--visibility private|workspace` 是舊寫法,會對映到 `--permission-mode`;兩者同時給出時以 `--permission-mode` 為準。@@ -523,7 +523,7 @@ CLI 配置檔案包含可代表你訪問 Multica 的令牌。不要提交到倉| | `copy <agent-id>` | 複製為新 AI 代理,原 AI 代理不受影響 | `--name`(預設為原名加 ` (copy)`)、`--runtime-id`(複製到其他執行時時必須同時指定 `--model`)、`--no-skills`;`custom_env`、`mcp_config`、`runtime_config` 等機密配置不會複製,需用與 `create` 相同的 flag 重新提供 || | `tasks <id>` | 檢視 AI 代理的執行 | || | `avatar <id>` | 上傳頭像 | |-| | `env get/set <agent-id>` | 讀寫自定義環境變數(AI 代理所有者或工作區 owner/admin;每次讀取都會記錄) | `set`:`--custom-env` / `--custom-env-file` / `--custom-env-stdin`,整體替換,值為 `****` 的鍵保留原值 |+| | `env get/set <agent-id>` | 讀寫自定義環境變數(AI 代理所有者或工作區 owner/admin;每次讀取都會記錄) | `set`:`--custom-env` / `--custom-env-file` / `--custom-env-stdin`,整體替換,值為 `****` 的鍵保留原值。輸出的值顯示為 `****`,加 `--show-values` 顯示原值 || | `skills list/set/add <agent-id>` | 管理繫結的 skill | `--skill-ids`(`set` 全量替換,`add` 增量新增) || | `mcp list/add/enable/disable/remove <agent-id>` | 給該 agent 分配工作區 MCP 服務 | server id 從 `workspace mcp list` 獲取。庫裡的條目在這裡新增之前不會生效;`disable` 只停止下發,保留分配 || `autopilot` | `list/get/create/update/delete` | 管理自動化 | `create`:`--title`、`--mode`(均必填)、`--agent` / `--squad` / `--squad-id`(三選一,必填)、`--description`、`--issue-title-template`、`--project`、`--subscriber`(可重複) |diff --git a/apps/docs/content/docs/cli.zh.mdx b/apps/docs/content/docs/cli.zh.mdxindex 6bce9298a8..22d73cb30a 100644--- a/apps/docs/content/docs/cli.zh.mdx+++ b/apps/docs/content/docs/cli.zh.mdx@@ -291,7 +291,7 @@ multica agent env set <agent-id> --custom-env-stdin < agent-env.jsonmultica agent update <agent-id> --mcp-config-file ./mcp.json```-- `--custom-env` 系列只在 `agent create` 中可用。之后修改用 `agent env set`,它整体替换原有变量,值写成 `****` 的键保留原值。+- `--custom-env` 系列只在 `agent create` 中可用。之后修改用 `agent env set`,它整体替换原有变量,值写成 `****` 的键保留原值。`agent env get` 和 `agent env set` 输出的值都显示为 `****`,要看原值(比如复制到另一个智能体)请加 `--show-values`。- `agent update --mcp-config null` 清除 MCP 配置。- `--custom-args` 是 JSON 数组,排在启动参数的最后。选模型用 `--model`,部分工具会拒绝出现在自定义参数里的 `--model`。- 谁能调用智能体用 `--permission-mode`:`private` 只有所有者,`public_to` 配合 `--public-to-workspace` 或 `--public-to-member <user-id>`。`--visibility private|workspace` 是旧写法,会映射到 `--permission-mode`;两者同时给出时以 `--permission-mode` 为准。@@ -532,7 +532,7 @@ CLI 配置文件包含可代表你访问 Multica 的令牌。不要提交到仓| | `copy <agent-id>` | 复制为新智能体,原智能体不受影响 | `--name`(默认为原名加 ` (copy)`)、`--runtime-id`(复制到其他运行时时必须同时指定 `--model`)、`--no-skills`;`custom_env`、`mcp_config`、`runtime_config` 等机密配置不会复制,需用与 `create` 相同的 flag 重新提供 || | `tasks <id>` | 查看智能体的运行 | || | `avatar <id>` | 上传头像 | |-| | `env get/set <agent-id>` | 读写自定义环境变量(智能体所有者或工作区 owner/admin;每次读取都会记录) | `set`:`--custom-env` / `--custom-env-file` / `--custom-env-stdin`,整体替换,值为 `****` 的键保留原值 |+| | `env get/set <agent-id>` | 读写自定义环境变量(智能体所有者或工作区 owner/admin;每次读取都会记录) | `set`:`--custom-env` / `--custom-env-file` / `--custom-env-stdin`,整体替换,值为 `****` 的键保留原值。输出的值显示为 `****`,加 `--show-values` 显示原值 || | `skills list/set/add <agent-id>` | 管理绑定的 skill | `--skill-ids`(`set` 全量替换,`add` 增量添加) || | `mcp list/add/enable/disable/remove <agent-id>` | 给该 agent 分配工作区 MCP 服务 | server id 从 `workspace mcp list` 获取。库里的条目在这里添加之前不会生效;`disable` 只停止下发,保留分配 || `autopilot` | `list/get/create/update/delete` | 管理自动化 | `create`:`--title`、`--mode`(均必填)、`--agent` / `--squad` / `--squad-id`(三选一,必填)、`--description`、`--issue-title-template`、`--project`、`--subscriber`(可重复) |diff --git a/server/cmd/multica/cmd_agent.go b/server/cmd/multica/cmd_agent.goindex 18ced080d7..78a1537d11 100644--- a/server/cmd/multica/cmd_agent.go+++ b/server/cmd/multica/cmd_agent.go@@ -8,6 +8,7 @@ import ("net/url""os""path/filepath"+ "sort""strings""time"@@ -97,7 +98,7 @@ var agentEnvCmd = &cobra.Command{var agentEnvGetCmd = &cobra.Command{Use: "get <agent-id>",- Short: "Print an agent's custom_env as a JSON map (agent owner or workspace owner/admin; every call is recorded)",+ Short: "Print an agent's custom_env as a JSON map, values masked as **** unless --show-values (agent owner or workspace owner/admin; every call is recorded)",Args: exactArgs(1),RunE: runAgentEnvGet,}@@ -239,6 +240,7 @@ func init() {// agent env getagentEnvGetCmd.Flags().String("output", "json", "Output format: json or table")+ agentEnvGetCmd.Flags().Bool("show-values", false, "Print custom_env values in cleartext (default: mask them)")// agent env set. Same three secret-safe input channels as `agent// create` so scripts can keep secrets out of shell history. Mutual@@ -247,6 +249,7 @@ func init() {agentEnvSetCmd.Flags().Bool("custom-env-stdin", false, "Read the replacement custom_env JSON object from stdin. Keeps secrets out of shell history and 'ps'. Mutually exclusive with --custom-env and --custom-env-file.")agentEnvSetCmd.Flags().String("custom-env-file", "", "Read the replacement custom_env JSON object from a file path (suggested mode: 0600). Mutually exclusive with --custom-env and --custom-env-stdin.")agentEnvSetCmd.Flags().String("output", "json", "Output format: json or table")+ agentEnvSetCmd.Flags().Bool("show-values", false, "Print custom_env values in cleartext (default: mask them)")}// resolveProfile returns the --profile flag value (empty string means default profile).@@ -1159,9 +1162,10 @@ func printAgentSkillsMutationResult(cmd *cobra.Command, agentID string, result j// Agent env subcommands// runAgentEnvGet fetches the plaintext custom_env for a single agent-// via the audited `/env` endpoint. The CLI prints raw JSON in JSON-// mode and a key/value table otherwise; we never truncate or mask-// values here — the security gate is on the server, not the printer.+// via the audited `/env` endpoint. Values are masked in both output modes+// unless --show-values is given: the secret-safe input channels keep secrets+// off the command line, and printing them would put them straight back on+// stdout.func runAgentEnvGet(cmd *cobra.Command, args []string) error {client, err := newAPIClient(cmd)if err != nil {@@ -1177,12 +1181,14 @@ func runAgentEnvGet(cmd *cobra.Command, args []string) error {}output, _ := cmd.Flags().GetString("output")+ reveal, _ := cmd.Flags().GetBool("show-values")+ result := agentEnvForOutput(resp, reveal)if output == "json" {- return cli.PrintJSON(os.Stdout, resp)+ return cli.PrintJSON(os.Stdout, result)}headers := []string{"KEY", "VALUE"}- env, _ := resp["custom_env"].(map[string]any)+ env, _ := result["custom_env"].(map[string]any)rows := make([][]string, 0, len(env))for k, v := range env {rows = append(rows, []string{k, fmt.Sprintf("%v", v)})@@ -1191,6 +1197,29 @@ func runAgentEnvGet(cmd *cobra.Command, args []string) error {return nil}+const agentEnvMaskedValue = "****"++// agentEnvForOutput copies an /env response with every custom_env value+// replaced by a fixed placeholder. The copy keeps the caller's response+// intact, since runAgentEnvSet still reads it after printing.+func agentEnvForOutput(resp map[string]any, reveal bool) map[string]any {+ if reveal || resp == nil {+ return resp+ }+ result := make(map[string]any, len(resp))+ for key, value := range resp {+ result[key] = value+ }+ if env, ok := result["custom_env"].(map[string]any); ok {+ masked := make(map[string]any, len(env))+ for key := range env {+ masked[key] = agentEnvMaskedValue+ }+ result["custom_env"] = masked+ }+ return result+}+// runAgentEnvSet replaces an agent's custom_env wholesale via the// audited `/env` endpoint. The three secret-safe input channels// (--custom-env, --custom-env-stdin, --custom-env-file) are required@@ -1210,6 +1239,7 @@ func runAgentEnvSet(cmd *cobra.Command, args []string) error {if !ok {return fmt.Errorf("specify the new env via --custom-env, --custom-env-stdin, or --custom-env-file (pass '{}' to clear)")}+ warnAgentEnvMaskedInput(os.Stderr, args[0], ce)body := map[string]any{"custom_env": ce}@@ -1222,8 +1252,9 @@ func runAgentEnvSet(cmd *cobra.Command, args []string) error {}output, _ := cmd.Flags().GetString("output")+ reveal, _ := cmd.Flags().GetBool("show-values")if output == "json" {- return cli.PrintJSON(os.Stdout, result)+ return cli.PrintJSON(os.Stdout, agentEnvForOutput(result, reveal))}env, _ := result["custom_env"].(map[string]any)@@ -1231,6 +1262,26 @@ func runAgentEnvSet(cmd *cobra.Command, args []string) error {return nil}+// warnAgentEnvMaskedInput flags **** values in an `env set` payload. The+// server keeps the target agent's existing value for such a key and drops+// the key when the agent has none, so piping masked `env get` output from+// one agent into another succeeds while copying nothing. Only key names are+// printed, never values.+func warnAgentEnvMaskedInput(w io.Writer, agentID string, ce map[string]string) {+ var keys []string+ for k, v := range ce {+ if v == agentEnvMaskedValue {+ keys = append(keys, k)+ }+ }+ if len(keys) == 0 {+ return+ }+ sort.Strings(keys)+ fmt.Fprintf(w, "Note: %s set to %s keep agent %s's existing value; keys that agent does not already have are dropped.\n", strings.Join(keys, ", "), agentEnvMaskedValue, agentID)+ fmt.Fprintln(w, "To copy env from another agent, read it with 'multica agent env get <source-agent-id> --show-values'.")+}+// Helpers// parseCustomEnv parses the --custom-env flag value (a JSON object literal)diff --git a/server/cmd/multica/cmd_agent_env_output_test.go b/server/cmd/multica/cmd_agent_env_output_test.gonew file mode 100644index 0000000000..e993067bd1--- /dev/null+++ b/server/cmd/multica/cmd_agent_env_output_test.go@@ -0,0 +1,119 @@+package main++import (+ "bytes"+ "encoding/json"+ "net/http"+ "net/http/httptest"+ "strings"+ "testing"++ "github.com/spf13/cobra"+)++const envOutputTestSecret = "ghp_DO_NOT_ECHO_THIS_TOKEN"++func newAgentEnvOutputTestServer(t *testing.T) *httptest.Server {+ t.Helper()+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ if r.URL.Path != "/api/agents/agent-123/env" {+ t.Errorf("unexpected path: %s", r.URL.Path)+ }+ var body map[string]any+ if r.Method == http.MethodPut {+ if err := json.NewDecoder(r.Body).Decode(&body); err != nil {+ t.Errorf("decode PUT body: %v", err)+ }+ }+ w.Header().Set("Content-Type", "application/json")+ _ = json.NewEncoder(w).Encode(map[string]any{+ "agent_id": "agent-123",+ "custom_env": map[string]any{"GITHUB_TOKEN": envOutputTestSecret},+ })+ }))+ t.Cleanup(srv.Close)+ setCLITestServerEnv(t, srv.URL)+ return srv+}++func TestAgentEnvOutputMasksValuesByDefault(t *testing.T) {+ for _, output := range []string{"json", "table"} {+ t.Run("get "+output, func(t *testing.T) {+ newAgentEnvOutputTestServer(t)+ cmd := &cobra.Command{Use: "get"}+ cmd.Flags().String("output", output, "")+ got, err := captureStdout(t, func() error { return runAgentEnvGet(cmd, []string{"agent-123"}) })+ if err != nil {+ t.Fatalf("runAgentEnvGet: %v", err)+ }+ if strings.Contains(got, envOutputTestSecret) {+ t.Fatalf("env get %s output echoed the secret: %s", output, got)+ }+ if !strings.Contains(got, "GITHUB_TOKEN") {+ t.Fatalf("env get %s output lost the key name: %s", output, got)+ }+ })+ }++ newAgentEnvOutputTestServer(t)+ cmd := &cobra.Command{Use: "set"}+ cmd.Flags().String("custom-env", "", "")+ cmd.Flags().Bool("custom-env-stdin", false, "")+ cmd.Flags().String("custom-env-file", "", "")+ cmd.Flags().String("output", "json", "")+ if err := cmd.Flags().Set("custom-env", `{"GITHUB_TOKEN":"`+envOutputTestSecret+`"}`); err != nil {+ t.Fatalf("set custom-env flag: %v", err)+ }+ got, err := captureStdout(t, func() error { return runAgentEnvSet(cmd, []string{"agent-123"}) })+ if err != nil {+ t.Fatalf("runAgentEnvSet: %v", err)+ }+ if strings.Contains(got, envOutputTestSecret) {+ t.Fatalf("env set output echoed the secret: %s", got)+ }+ if !strings.Contains(got, "GITHUB_TOKEN") {+ t.Fatalf("env set output lost the key name: %s", got)+ }+}++func TestAgentEnvOutputCanRevealValuesOnRequest(t *testing.T) {+ newAgentEnvOutputTestServer(t)+ cmd := &cobra.Command{Use: "get"}+ cmd.Flags().String("output", "json", "")+ cmd.Flags().Bool("show-values", false, "")+ if err := cmd.Flags().Set("show-values", "true"); err != nil {+ t.Fatalf("set show-values flag: %v", err)+ }+ got, err := captureStdout(t, func() error { return runAgentEnvGet(cmd, []string{"agent-123"}) })+ if err != nil {+ t.Fatalf("runAgentEnvGet: %v", err)+ }+ if !strings.Contains(got, envOutputTestSecret) {+ t.Fatalf("--show-values did not reveal the value: %s", got)+ }+}++func TestAgentEnvSetWarnsOnMaskedInput(t *testing.T) {+ var buf bytes.Buffer+ warnAgentEnvMaskedInput(&buf, "agent-123", map[string]string{+ "B_TOKEN": agentEnvMaskedValue,+ "A_TOKEN": agentEnvMaskedValue,+ "PLAIN": envOutputTestSecret,+ })+ got := buf.String()+ if !strings.Contains(got, "A_TOKEN, B_TOKEN") {+ t.Fatalf("warning should list masked keys in sorted order: %s", got)+ }+ if !strings.Contains(got, "--show-values") {+ t.Fatalf("warning should point at --show-values: %s", got)+ }+ if strings.Contains(got, "PLAIN") || strings.Contains(got, envOutputTestSecret) {+ t.Fatalf("warning should mention only masked keys and never values: %s", got)+ }++ buf.Reset()+ warnAgentEnvMaskedInput(&buf, "agent-123", map[string]string{"PLAIN": envOutputTestSecret})+ if buf.Len() != 0 {+ t.Fatalf("no masked values should produce no warning, got: %s", buf.String())+ }+}diff --git a/server/internal/service/builtin_skills/multica-platform/references/agents.md b/server/internal/service/builtin_skills/multica-platform/references/agents.mdindex 53ad2a8856..c39f0968af 100644--- a/server/internal/service/builtin_skills/multica-platform/references/agents.md+++ b/server/internal/service/builtin_skills/multica-platform/references/agents.md@@ -21,7 +21,7 @@ These commands read state and have no side effects:```bashmultica agent get <agent-id> --output json # full persisted agent recordmultica agent skills list <agent-id> --output json # current skill bindings-multica agent env get <agent-id> --output json # plaintext env (agent owner or ws owner/admin; agents denied)+multica agent env get <agent-id> --output json # env keys, values masked as **** (agent owner or ws owner/admin; agents denied)```An agent can also be **unbound**: `runtime_id` is `NULL` (served as `""` with@@ -260,6 +260,11 @@ Read-side facts (these are the wrong assumptions to avoid):owner** or a workspace **owner/admin**, and **agent actors are denied**regardless of the backing member's role — a running agent cannot read anotheragent's secrets, not even one its own human owns.+- `agent env get` and `agent env set` mask every value as `****` in their+ output by default; pass `--show-values` to print plaintext. Feeding masked+ output back into `env set` on the **same** agent keeps each value, but on a+ different agent the `****` keys are dropped — copy env between agents from+ `env get --show-values` output.- Writing values after creation does NOT go through `agent update`. The genericupdate path rejects any `custom_env` field with a 400 ("use PUT/api/agents/{id}/env"). Plaintext env writes are handled by