mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-01 07:24:38 -07:00
2.4 KiB
2.4 KiB
Plan: Worker Provider Abstraction for Offload System
Objective
Abstract the remote execution infrastructure (GCE COS, GCE Linux, Cloud Workstations) behind a common WorkerProvider interface. This eliminates infrastructure-specific prompts (like "use container mode") and makes the system extensible to new backends.
Architectural Changes
1. New Provider Abstraction
Create a modular provider system where each infrastructure type implements a standard interface.
- Base Interface:
WorkerProvider(methods forexec,sync,provision,getStatus). - Implementations:
GceCosProvider: Handles COS with Cloud-Init anddocker execwrapping.GceLinuxProvider: Handles standard Linux VMs with direct execution.LocalDockerProvider: (Future) Runs offload tasks in a local container.WorkstationProvider: (Future) Integrates with Google Cloud Workstations.
2. Auto-Discovery
Modify setup.ts to:
- Prompt for a high-level "Provider Type" (e.g., "Google Cloud (COS)", "Google Cloud (Linux)").
- Auto-detect environment details where possible (e.g., fetching internal IPs, identifying container names).
3. Clean Orchestration
Refactor orchestrator.ts to be provider-agnostic:
- It asks the provider to "Ensure Ready" (wake VM).
- It asks the provider to "Prepare Environment" (worktree setup).
- It asks the provider to "Launch Task" (tmux initialization).
Implementation Steps
Phase 1: Infrastructure Cleanup
- Move existing procedural logic from
fleet.ts,setup.ts, andorchestrator.tsinto a newproviders/directory. - Create
ProviderFactoryto instantiate the correct implementation based onsettings.json.
Phase 2: Refactor Scripts
fleet.ts: Proxy all actions (provision,rebuild,stop) to the provider.orchestrator.ts: Use the provider for the entire lifecycle of a job.status.ts: Use the provider'sgetStatus()method to derive state.
Phase 3: Validation
- Verify that the
gcli-workerSSH alias and IAP tunneling remain functional. - Ensure "Fast-Path SSH" is still the primary interactive gateway.
Verification
- Run
npm run offload:fleet provisionand ensure it creates a COS-native worker. - Run
npm run offload:setupand verify it no longer asks cryptic infrastructure questions. - Launch a review and verify it uses `docker exec internally for the COS provider.