diff --git a/README.md b/README.md index edec90b..9badcb6 100644 --- a/README.md +++ b/README.md @@ -101,11 +101,11 @@ Bring your own API key (OpenAI, Anthropic, Ollama, or any OpenAI-compatible endp Use the subscriptions you already pay for as native backends on your own machine. No separate API key needed. -**Codex** · **Claude Code** · **Cursor** · **Grok** · **OpenCode** · **Cline** · **Pi** +**Codex** · **Claude Code** · **Cursor** · **Grok** · **OpenCode** · **Cline** · **Gemini** · **Pi** Add an agent profile from Settings, pick your models, and it shows up in the model selector like any other provider. Conversations run inside your workspace with full tool access and resume where you left off. -Prefer to run agents yourself? Any terminal agent (Gemini CLI, Kilo Code, Pi, and others) works in the terminal tab the way it always has. +Prefer to run agents yourself? Any terminal agent (Kilo Code, Pi, and others) works in the terminal tab the way it always has. ## Messaging bots diff --git a/cptr/frontend/src/lib/apis/admin.ts b/cptr/frontend/src/lib/apis/admin.ts index d5a4a18..a8140ff 100644 --- a/cptr/frontend/src/lib/apis/admin.ts +++ b/cptr/frontend/src/lib/apis/admin.ts @@ -60,7 +60,15 @@ export const updateConfig = (config: Record) => // ── Agents ───────────────────────────────────────────────── -export type AgentType = 'codex' | 'claude_code' | 'cursor' | 'grok' | 'opencode' | 'cline' | 'pi'; +export type AgentType = + | 'codex' + | 'claude_code' + | 'cursor' + | 'grok' + | 'opencode' + | 'cline' + | 'gemini' + | 'pi'; export type AgentMode = 'auto' | 'enabled' | 'disabled'; export type AgentStatus = 'ready' | 'not_found' | 'missing_dependency' | 'auth_unknown' | 'error'; diff --git a/cptr/frontend/src/lib/components/Admin/AgentProfileModal.svelte b/cptr/frontend/src/lib/components/Admin/AgentProfileModal.svelte index a9381e5..f53a8d6 100644 --- a/cptr/frontend/src/lib/components/Admin/AgentProfileModal.svelte +++ b/cptr/frontend/src/lib/components/Admin/AgentProfileModal.svelte @@ -49,6 +49,7 @@ grok: 'grok', opencode: 'opencode', cline: 'cline', + gemini: 'gemini', pi: 'pi' }[agent]; } @@ -61,6 +62,7 @@ grok: 'Grok', opencode: 'OpenCode', cline: 'Cline', + gemini: 'Gemini', pi: 'Pi' }[agent]; } @@ -131,6 +133,7 @@ + diff --git a/cptr/frontend/src/lib/components/Admin/Agents.svelte b/cptr/frontend/src/lib/components/Admin/Agents.svelte index 8731f5a..59477f7 100644 --- a/cptr/frontend/src/lib/components/Admin/Agents.svelte +++ b/cptr/frontend/src/lib/components/Admin/Agents.svelte @@ -113,6 +113,7 @@ grok: 'grok', opencode: 'opencode', cline: 'cline', + gemini: 'gemini', pi: 'pi' }[agent]; } @@ -125,6 +126,7 @@ grok: 'Grok', opencode: 'OpenCode', cline: 'Cline', + gemini: 'Gemini', pi: 'Pi' }[agent]; } diff --git a/cptr/utils/agents/detection.py b/cptr/utils/agents/detection.py index 7ea8ceb..24c911a 100644 --- a/cptr/utils/agents/detection.py +++ b/cptr/utils/agents/detection.py @@ -159,7 +159,7 @@ async def detect_profile(profile: dict[str, Any]) -> AgentDetection: return AgentDetection("ready", command, version, None, models) if profile.get("agent") == "cline": - models = await _probe_cline_models(command, profile) + models = await _probe_acp_models(command, profile) if not models: return AgentDetection( "auth_unknown", @@ -170,6 +170,18 @@ async def detect_profile(profile: dict[str, Any]) -> AgentDetection: ) return AgentDetection("ready", command, version, None, models) + if profile.get("agent") == "gemini": + models = await _probe_acp_models(command, profile) + if not models: + return AgentDetection( + "auth_unknown", + command, + version, + "Could not discover Gemini models. Check Gemini CLI login or add models manually.", + [], + ) + return AgentDetection("ready", command, version, None, models) + if profile.get("agent") == "pi": models = await _probe_pi_models(command, profile) if not models: @@ -436,7 +448,7 @@ async def _probe_opencode_models(command: str, profile: dict[str, Any]) -> list[ await proc.wait() -async def _probe_cline_models(command: str, profile: dict[str, Any]) -> list[str] | None: +async def _probe_acp_models(command: str, profile: dict[str, Any]) -> list[str] | None: from cptr.utils.agents.acp import AcpClient, acp_models_from_setup env = os.environ.copy() diff --git a/cptr/utils/agents/models.py b/cptr/utils/agents/models.py index 52cd542..76b9719 100644 --- a/cptr/utils/agents/models.py +++ b/cptr/utils/agents/models.py @@ -80,6 +80,16 @@ DEFAULT_AGENT_PROFILES: list[dict[str, Any]] = [ "models": [], "default_model": "", }, + { + "id": "gemini", + "agent": "gemini", + "name": "Gemini", + "mode": "auto", + "command": "gemini", + "home": None, + "models": [], + "default_model": "", + }, { "id": "pi", "agent": "pi", @@ -93,7 +103,7 @@ DEFAULT_AGENT_PROFILES: list[dict[str, Any]] = [ ] _PROFILE_ID_RE = re.compile(r"^[a-z][a-z0-9_-]{0,63}$") -_VALID_AGENTS = {"codex", "claude_code", "cursor", "grok", "opencode", "cline", "pi"} +_VALID_AGENTS = {"codex", "claude_code", "cursor", "grok", "opencode", "cline", "gemini", "pi"} _VALID_MODES = {"auto", "enabled", "disabled"} _VALID_CODEX_APPROVAL = {"ask", "auto", "full"} _VALID_CODEX_SANDBOX = {"read-only", "workspace-write", "danger-full-access"} @@ -113,6 +123,7 @@ _AGENT_DEFAULTS: dict[str, dict[str, str]] = { "grok": {"name": "Grok", "command": "grok", "model": ""}, "opencode": {"name": "OpenCode", "command": "opencode", "model": ""}, "cline": {"name": "Cline", "command": "cline", "model": ""}, + "gemini": {"name": "Gemini", "command": "gemini", "model": ""}, "pi": {"name": "Pi", "command": "pi", "model": ""}, } @@ -130,7 +141,7 @@ def normalize_agent_profile(raw: dict[str, Any]) -> dict[str, Any]: agent = str(profile.get("agent") or "").strip() if agent not in _VALID_AGENTS: raise HTTPException( - 400, "agent must be codex, claude_code, cursor, grok, opencode, cline, or pi" + 400, "agent must be codex, claude_code, cursor, grok, opencode, cline, gemini, or pi" ) defaults = _AGENT_DEFAULTS[agent] diff --git a/cptr/utils/chat_task.py b/cptr/utils/chat_task.py index a94d6ad..355d9b7 100644 --- a/cptr/utils/chat_task.py +++ b/cptr/utils/chat_task.py @@ -1524,6 +1524,7 @@ async def run_chat_task( "grok": run_grok_agent, "opencode": run_opencode_agent, "cline": run_cline_agent, + "gemini": run_cline_agent, "pi": run_pi_agent, } runner = runners.get(agent_target.agent) diff --git a/cptr/utils/model_targets.py b/cptr/utils/model_targets.py index e2bfd6a..0769531 100644 --- a/cptr/utils/model_targets.py +++ b/cptr/utils/model_targets.py @@ -24,7 +24,7 @@ class ApiModelTarget: class AgentModelTarget: kind: Literal["agent"] profile_id: str - agent: Literal["codex", "claude_code", "cursor", "grok", "opencode", "cline", "pi"] + agent: Literal["codex", "claude_code", "cursor", "grok", "opencode", "cline", "gemini", "pi"] model: str full_model_id: str config: dict[str, Any]