Agent Zero AI framework
Harden Gemini CLI container setup
Alessandro25d906edb778
diff --git a/plugins/_orchestrator/skills/orchestrator/AGENTS.md b/plugins/_orchestrator/skills/orchestrator/AGENTS.mdindex 26ba77a0d..cd337eb27 100644--- a/plugins/_orchestrator/skills/orchestrator/AGENTS.md+++ b/plugins/_orchestrator/skills/orchestrator/AGENTS.md@@ -22,6 +22,7 @@- `SKILL.md` must tell agents to read only the relevant reference file before acting.- Claude Code reference guidance must avoid plain `claude` and bare `claude auth login` until the user chooses `--claudeai`, `--console`, `--sso`, or external API-key auth.- Claude Code API-key auth must source Agent Zero secrets from `/a0/usr/.env`, not from the workdir.+- Gemini CLI container runs must use `§§secret(GEMINI_API_KEY)` when that key is in Agent Zero secrets; do not assume it is exported from `/a0/usr/.env`.- If a full-screen Claude Code TUI is already open, the Claude reference must reset the terminal session instead of sending Enter or `/login`.- Root shells must not use Claude Code `bypassPermissions`; non-root shells may use it as the default non-interactive mode.- Long-running commands should stay in a shell session and be polled there.diff --git a/plugins/_orchestrator/skills/orchestrator/references/gemini.md b/plugins/_orchestrator/skills/orchestrator/references/gemini.mdindex 4352c5ab6..71d21ca8f 100644--- a/plugins/_orchestrator/skills/orchestrator/references/gemini.md+++ b/plugins/_orchestrator/skills/orchestrator/references/gemini.md@@ -4,8 +4,22 @@ Use Gemini CLI for headless Google Gemini coding tasks. Always pass `-p`; bare `## Install And Probe+Check first:++```bash+command -v gemini+```++If missing, install it as one command and wait or poll that same terminal session until it completes. Do not append version, help, or smoke commands to the install call:+```bash-command -v gemini >/dev/null || npm install -g @google/gemini-cli+npm install -g @google/gemini-cli --no-progress+```++Then probe it:++```bash+command -v geminigemini --versiongemini --help```@@ -21,12 +35,10 @@ gemini -p "Respond exactly: TERMINAL_AGENT_SMOKE_OK" --output-format json --apprHeadless mode uses existing cached Google credentials, a Gemini API key, or Vertex AI credentials. Do not start bare `gemini` through Agent Zero for login; it opens a TUI. For local browser sign-in, ask the user to run `gemini` in their own terminal, select **Sign in with Google**, finish in the browser, and then retry the smoke prompt.-For container automation, prefer `GEMINI_API_KEY`. Ask the user to add it through **Settings > External Services > Secrets Management**, then source `/a0/usr/.env` without printing it:+For container automation, prefer `GEMINI_API_KEY`. Ask the user to add it through **Settings > External Services > Secrets Management**. If `GEMINI_API_KEY` is listed in Agent Zero's available secrets, do not source `/a0/usr/.env`; pass the exact secret alias only to the Gemini process:```bash-set -a-. /a0/usr/.env-set +a+GEMINI_API_KEY='§§secret(GEMINI_API_KEY)' gemini -p "Respond exactly: TERMINAL_AGENT_SMOKE_OK" --output-format json --approval-mode=yolo --skip-trust```Vertex AI may instead use `GOOGLE_API_KEY`, `GOOGLE_APPLICATION_CREDENTIALS`, or cached Application Default Credentials. It also requires `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION`. Never ask the user to paste keys or service-account JSON into chat.@@ -39,3 +51,5 @@ gemini -p "$TASK" --output-format json --approval-mode=yolo --skip-trust```Add `-m "$MODEL"` only when the user or settings provide a model override. Use `--approval-mode=plan` instead of `yolo` when the user explicitly asks for read-only analysis.++When using the saved Gemini secret for a real task, prefix the real-task command with `GEMINI_API_KEY='§§secret(GEMINI_API_KEY)'` in the same way. Never print or probe the expanded value.diff --git a/plugins/_orchestrator/tests/test_status_adapters.py b/plugins/_orchestrator/tests/test_status_adapters.pyindex 583e21467..d1c87a9ca 100644--- a/plugins/_orchestrator/tests/test_status_adapters.py+++ b/plugins/_orchestrator/tests/test_status_adapters.py@@ -230,6 +230,9 @@ def test_skill_documents_human_setup_loop_and_a0_exception():assert "--approval-mode=yolo" in gemini_textassert "--skip-trust" in gemini_textassert "GEMINI_API_KEY" in gemini_text+ assert "§§secret(GEMINI_API_KEY)" in gemini_text+ assert "do not source `/a0/usr/.env`" in gemini_text+ assert "Do not append version, help, or smoke commands" in gemini_textassert "GOOGLE_APPLICATION_CREDENTIALS" in gemini_textassert "Do not start bare `gemini`" in gemini_text