hzhang a63f477463 feat(gemini): plexum-host MCP exposure + real consume mirror
Same architecture as the codex sister change:

1. mcp-host subcommand routes argv[1] to mcpbridge.Run, reading
   PLEXUM_MCP_SOCKET / PLEXUM_MCP_AGENT_ID from gemini-cli's
   `gemini mcp add --env` env baking.

2. EnsureGeminiMCPRegistered handles per-agent stable registration
   under `-s user --trust` so gemini auto-approves the tool surface.

3. Post-turn ParseGeminiToolCalls + EmitGeminiToolCalls scans the
   chat JSONL at ~/.gemini/tmp/<ws>/chats/session-*.jsonl. Pairs
   gemini's nested `toolCalls[].id` with the matching
   `functionResponse.id` from later user lines.

4. MutateGeminiSession rewrites the chat JSONL: toolCalls[].args
   → {} (heavy), functionResponse.response.output → marker.

E2E verified: gemini call exec via plexum-host → dynamic.jsonl
records the call → dynamic-tool-clear consumes → gemini session
mirrored → resume gemini sees consumed marker not the original.
2026-06-01 20:14:13 +01:00

Plexum-gemini-provider

Plexum ProviderPlugin that wraps the local gemini CLI binary (Google Gemini CLI) — same CLI-driven pattern as Plexum-anthropic-provider's contractor mode. Each Plexum turn forks one gemini -p subprocess in the agent's workspace.

Reference: openclaw/extensions/google/cli-backend.ts.

Status

v0.1: subprocess-per-turn, JSON output parsing, per-workspace session continuity via --resume. Models: gemini (CLI default), gemini-pro, gemini-flash, gemini-flash-lite.

Install

cd ~/Plexum-gemini-provider
./scripts/install.sh

Then:

  1. Allow in ~/.plexum/plexum.json:

    {"plugins": {"allow": ["plexum-gemini-provider"]}}
    
  2. Bind an agent:

    plexum agent-add --model gemini-flash my-agent
    
  3. Restart + talk:

    systemctl --user restart plexum
    plexum say --agent-id my-agent --session-id $(plexum new-session --agent-id my-agent) "hello"
    

Auth

There is no API key in this plugin's config. The gemini CLI handles auth itself via ~/.gemini/ (OAuth or GEMINI_API_KEY). Run gemini auth login (or set env) once, then this plugin just shells out.

How it works

For each Plexum turn the plugin forks:

gemini --skip-trust --output-format json [--model <m>] [--resume <sid>] -p "<last user msg>"

with cwd = <agent workspace>. The CLI exits with a single JSON blob:

{
  "session_id": "uuid",
  "response": "...",
  "stats": {"models": {...}}
}

We capture session_id into <workspace>/.plexum-gemini-session so the next turn passes --resume and Gemini sees the full prior context. The response text is emitted as one text_delta followed by message_end.

Models

Plexum model id CLI invocation
gemini no --model flag (CLI default — currently gemini-3-flash-preview)
gemini-pro --model pro (CLI alias → gemini-3.1-pro-preview)
gemini-flash --model flash (CLI alias → gemini-3.1-flash-preview)
gemini-flash-lite --model flash-lite (CLI alias → gemini-3.1-flash-lite-preview)

Any other id is passed through as --model <id> verbatim so operators can pin a specific Gemini model the local CLI knows about.

Config options

Field Default Notes
binary gemini executable name or absolute path
extra_args [] appended after the standard flags, before -p

License

Same as Plexum.

Description
Plexum ProviderPlugin wrapping the gemini CLI binary (CLI backend, contractor-style)
Readme 54 KiB
Languages
Go 92.3%
Shell 7.7%