Colab GPU
by Gruu6y
README.md
<div align="center">
<img src="assets/logo.svg" width="96" height="96" alt="Colab GPU Logo" />
# Colab GPU
**Direct Google Colab API + Isolated PKCE OAuth GPU Orchestrator · Zero Browser · Zero Cookie Scraping**
**English (Current)** | [简体中文](./docs/README.zh-CN.md)
Direct Colab API + OAuth2 PKCE · Multi-Spec Concurrent GPU Racer · Multi-Exit Proxy Pool & Circuit Breaker · Multi-Signal Idle-Burn Watchdog · Atomic Ready-Card Leases · Read-Only Agent Task Pool
[**Roadmap & Harness Support**](./docs/ROADMAP.md) · [**Architecture**](./.github/ARCHITECTURE.md) · [**Changelog**](./CHANGELOG.md) · [**Releases**](https://github.com/Gruu6y/Colab-GPU/releases) · [**Discussions**](https://github.com/Gruu6y/Colab-GPU/discussions) · [**Issues**](https://github.com/Gruu6y/Colab-GPU/issues)
<p>
<a href="https://github.com/Gruu6y/Colab-GPU/releases"><img src="https://img.shields.io/github/v/release/Gruu6y/Colab-GPU?style=flat-square&color=3186ff&label=Release" alt="Latest Release" /></a>
<img src="https://img.shields.io/badge/Version-1.0.0-0f172a?style=flat-square" alt="Version 1.0.0" />
<img src="https://img.shields.io/badge/Protocol-Colab%20API%20%2B%20OAuth2%20PKCE-f59e0b?style=flat-square" alt="Colab API + OAuth2 PKCE" />
<img src="https://img.shields.io/badge/Platform-Windows%20%7C%20macOS%20%7C%20Linux-1e293b?style=flat-square" alt="Platform" />
<img src="https://img.shields.io/badge/Node-%3E%3D22.0.0-16a34a?style=flat-square" alt="Node >= 22" />
<a href="https://github.com/Gruu6y/Colab-GPU/actions"><img src="https://img.shields.io/github/actions/workflow/status/Gruu6y/Colab-GPU/ci.yml?branch=main&style=flat-square&label=CI" alt="CI Status" /></a>
<a href="./LICENSE"><img src="https://img.shields.io/badge/License-GPL--3.0-2563eb?style=flat-square" alt="License: GPL-3.0" /></a>
<a href="./NOTICE"><img src="https://img.shields.io/badge/Attribution-Required%20(NOTICE)-8b5cf6?style=flat-square" alt="Attribution Required" /></a>
</p>
<p><sub>🟢 <strong>v1.0.0 Stable Release</strong> — Currently supports <strong>Google Antigravity</strong> first. Need another host/harness (Claude Code, Cursor, Codex, Windsurf, Cline, Zed, etc.)? <a href="https://github.com/Gruu6y/Colab-GPU/issues/new?template=harness_request.yml"><strong>Open an Issue</strong></a> and support for your requested harness will be added right away!</sub></p>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/images/hero-dark.png" />
<source media="(prefers-color-scheme: light)" srcset="docs/images/hero-light.png" />
<img src="docs/images/hero-dark.png" width="100%" alt="Colab GPU v1.0.0 Sidecar Console Showcase" />
</picture>
<sub>Illustrative showcase rendered with sample accounts and sample workloads. No real credentials or user workspaces are shown.</sub>
</div>
> **Non-Affiliation & Harness Support Notice**
>
> **Colab GPU (`agy-colab`) is an independent open-source project and is not affiliated with or endorsed by Google LLC.**
> References to “Google”, “Google Colab”, and “Antigravity” are strictly for compatibility and descriptive purposes.
>
> **Host Harness Scope**: `v1.0.0` currently targets **Google Antigravity** first. **As soon as any user opens an Issue requesting another harness or MCP host**, support for that harness will be implemented promptly — [Request a Harness](https://github.com/Gruu6y/Colab-GPU/issues/new?template=harness_request.yml).
---
## Highlights
- **Direct Google Colab API + Isolated PKCE OAuth (Zero Browser · Zero Cookie Fragility)**: Authenticates Google accounts with isolated OAuth2 PKCE tokens (zero GCP project setup required out of the box; optional `AGY_COLAB_OAUTH_CLIENT_*` overrides supported; scans existing `~/.colab-accounts` ADC files) and calls Colab endpoints directly over `undici` — no Puppeteer, no Playwright, and no brittle browser DOM scraping.
- **Multi-Spec Concurrent GPU Racer (`AIMD 429` + Incremental Guard)**: Arm multiple GPU tiers (`G4 96G`, `A100 80G`, `A100 40G`, `V100 16G`, `L4 24G`, `T4 16G`) in parallel, fan out 2 concurrent workers on single-spec targets, snapshot per-account baseline assignments before racing so excess grabs are automatically cleaned up (`stopAndVerify`), guard against silent `A100 80G -> 40G` downgrades, and adapt concurrency on HTTP `429` rate limits.
- **Multi-Exit Proxy Pool & Circuit Breaker**: Route Colab control-plane traffic via `direct`, `single`, or a multi-node `pool` with `per_account` deterministic affinity (+ automatic failover), `fastest` EMA latency routing, or `round_robin` rotation. Every node keeps an isolated `ProxyAgent`, backs off exponentially on failure / `429`, recovers cleanly via half-open probing, performs single transparent failover even when `retries === 0`, and scrubs all `user:pass` credentials from logs and responses.
- **90-Day FIFO CU Ledger & API Glitch Protection**: Track manual compute-unit refill batches with FIFO 90-day expiration estimates, real-time hourly burn rates, and single-sample zero-balance API glitch protection across every connected account.
- **Multi-Signal Idle-Burn Watchdog, Ghost Radar & Persistent Snooze**: Evaluates GPU utilization, VRAM deltas, host RAM/disk motion, keepalive Python sleep loops (`vram_resident` fallback when GPU telemetry probes fail), cold-start grace windows, and Task Pool heartbeats (`< 10m`) before alerting — with per-runtime persisted Snooze and pure-OAuth `[GHOST]` detection.
- **Atomic Ready-Card Lease Pool & Zero-Downtime Token Renewal**: Domain-locked `PluginStore` prevents lost updates under concurrent writes; AI agents atomically claim `READY` cards (`colab_claim_card`), drop negotiated tasks with mandatory ETA (`colab_task_create`), pulse heartbeats every `5–8` minutes (`colab_task_update`), renew expiring 60-minute proxy tokens without stopping kernels (`colab_refresh_card_token`), and cleanly return or stop billing (`colab_release_card`).
### Why Direct Colab API + OAuth Instead of Browser / Cookie Scripts?
| Dimension | Traditional Browser / Cookie Scripts | Colab GPU (`Direct Colab API + OAuth`) |
| :--- | :--- | :--- |
| **Authentication** | Shared browser profiles, volatile cookies, frequent relogin | **Isolated multi-account OAuth2 PKCE** (auto-refresh `access_token`, zero cookies) |
| **Footprint** | Heavy headless Chrome / Puppeteer processes & DOM breakages | **Zero-browser Node + `undici`** API calls (`~226 KiB` server bundle) |
| **GCP Setup** | Often forces users to configure custom GCP projects first | **Works out of the box** (+ optional `AGY_COLAB_OAUTH_CLIENT_*` env override) |
| **Long Jobs (>60m)** | Kernel token expires mid-run or forces web tab keepalive | **`colab_refresh_card_token`** renews `proxyToken` live without stopping kernels |
| **Multi-Exit Egress** | All tabs share one browser proxy profile | **`per_account` / `fastest` / `round_robin` Proxy Pool** with circuit breaker |
---
## Visual Overview
### 1. Core Capabilities at a Glance
<p align="center">
<img src="docs/images/features-bento.png" width="100%" alt="Colab GPU four core feature pillars" />
</p>
| Pillar | What It Handles | Key Mechanism |
| :--- | :--- | :--- |
| **Concurrent GPU Racer** | Grab exact card counts across multi-spec picks & accounts | Baseline snapshot diff + 2-worker fan-out + AIMD `429` throttle + `stopAndVerify` cleanup |
| **Multi-Exit Proxy Pool** | Resilient multi-region HTTP proxy routing per account | `per_account` / `fastest` / `round_robin` + exponential circuit breaker + isolated probe sweeps |
| **Idle-Burn Watchdog** | Stop silent compute-unit waste without false positives | VRAM + GPU + RAM + Disk + Task heartbeat (<10m) fusion + persisted Snooze + Ghost radar |
| **Agent Lease & Task Cockpit** | Multi-agent coordination with live read-only ETA board | Atomic `ready -> in_use` locks + mandatory ETA + `5–8m` heartbeats + zero-downtime token renewal |
### 2. Dual-Visibility MCP Architecture
<p align="center">
<img src="docs/images/architecture.png" width="100%" alt="Colab GPU dual-visibility MCP server architecture" />
</p>
**Strict Tool Privilege Isolation (`10` Model-Visible Agent Tools vs. `19` App-Only UI Tools)**:
- **Model-Visible Agent Tools (`colab_*`)**: `colab_open_panel`, `colab_status`, `colab_discover_ready_cards`, `colab_claim_card`, `colab_refresh_card_token`, `colab_release_card`, `colab_task_create`, `colab_task_update`, `colab_task_list`, `colab_task_remove`.
- **App-Only Sidecar UI Tools (`app_*`, `visibility: ['app']`)**: Hidden from LLM context (`app_get_dashboard`, `app_refresh_dashboard`, `app_set_config`, `app_test_proxy_pool`, `app_test_proxy`, `app_oauth_start`, `app_oauth_complete`, `app_legacy_scan`, `app_legacy_import`, `app_account_update`, `app_account_remove`, `app_add_balance_batch`, `app_stop_runtime`, `app_update_lease`, `app_snooze_idle`, `app_race_start`, `app_race_status`, `app_race_stop`, `app_race_dismiss`).
<details>
<summary><strong>Technical Deep Dive: Concurrency, Proxy Circuit Breaker, Idle Detection & State Safety (click to expand)</strong></summary>
1. **Incremental Baseline Racing & Silent Downgrade Guard (`src/server/colab/racer.ts`)**:
- Before launching race workers, `RaceManager` queries every candidate account's active assignments and **skips any account whose baseline preflight fails** instead of racing against an empty baseline.
- Each GPU candidate carries priority rankings (`G4 96G > A100 80G > A100 40G > V100 16G > L4 24G > T4 16G`). If Colab silently returns a 40 GB A100 when only `A100 80G` was selected, `RaceManager` detects real VRAM via Jupyter probe and immediately unassigns the downgraded instance rather than counting it toward target quota.
- `NETWORK_ERROR` triggers gentle backoff without poisoning HTTP `429` AIMD streaks; `NOT_ENTITLED` and `HTTP 412` surface explicit diagnostics.
2. **Multi-Exit Proxy Pool & Isolated Probes (`src/server/net/proxy-pool.ts`, `http.ts`)**:
- Deterministic hash-pinned `per_account` affinity pairs each Google account with its stable exit IP while failing over onto healthy alternate nodes if a node opens its circuit breaker.
- `app_test_proxy_pool` runs **ephemeral probe dispatchers** (`probeProxyNode`, `probeProxyPool`, `testProxyConnectivity`) that never mutate live active `ProxyAgent` pools or clear healthy traffic caches.
- Credential-bearing URLs (`http://user:pass@host:port`) are scrubbed immediately via `maskProxyUrl` and `scrubProxyCredentialsFromText` before hitting UI payloads, logs, or error banners.
3. **Multi-Signal Idle Watchdog (`src/server/state/dashboard-cache.ts`, `colab/runtime.ts`)**:
- Parses fractional (`0..1`) and percentage (`0..100`) GPU utilization metrics safely, detects probe-failure blindspots (never falsely blaming `vram_resident` when GPU utilization wasn't reported), tracks rolling RAM/Disk byte progression, exempts cold starts, flags stale `READY` leases (`ready_timeout`), and respects both `< 10m` Task Pool heartbeats and persisted `snoozeUntil` deadlines.
- `DashboardCache` buffers transient errors across 2 polling cycles before surfacing degraded banners and preserves existing good account/runtime state across partial failures.
4. **Domain-Locked Persistence & Handshake (`src/server/state/store.ts`, `server/index.ts`)**:
- All mutations to `leases`, `tasks`, `config`, `accounts`, and `ledger` serialize through domain-scoped async mutexes (`withDomainLock`), making parallel MCP calls and UI polls atomic without coarse global stalling.
- Every dashboard payload carries `protocolVersion: 3` and `serverBuildId` compared against `window.__AGY_DISK_BUILD_ID__` injected from `dist/server.mjs` so UI panels automatically warn when the host needs a plugin reload after an upgrade.
</details>
---
## Quick Start
> **Requires Node.js >= 22.0.0** and **Google Antigravity** (other harnesses added on request — see below!).
### Option A: Portable Release Bundle (Recommended · Zero `npm install`)
1. Download **`agy-colab-v1.0.0.zip`** (Windows) or **`agy-colab-v1.0.0.tar.gz`** (macOS / Linux) from [**GitHub Releases**](https://github.com/Gruu6y/Colab-GPU/releases/latest) (verify checksums against `SHA256SUMS.txt`).
2. Extract the archive and run the bundled installer from the extracted `agy-colab/` folder:
```bash
node install-portable.mjs
```
3. Open **Plugins Manager** in Antigravity, toggle **`Colab GPU` (`agy-colab`)** on (or off/on after an upgrade), and run `"Open the Colab GPU panel"` or invoke `colab_open_panel`.
### Option B: Build & Install from Source (Developers)
```bash
git clone https://github.com/Gruu6y/Colab-GPU.git
cd Colab-GPU
npm ci
npm run build
npm run install:plugin
```
`npm run install:plugin` deploys cleanly to `~/.gemini/config/plugins/agy-colab` (symlink/junction for `node_modules` by default, or pass `-- --copy-deps` for a standalone copy).
### Need Another Harness? (Claude Code / Cursor / Codex / Windsurf / Cline / etc.)
`v1.0.0` temporarily supports **Google Antigravity** first (MCP Stdio + `ui://` MCP App sidecar panel).
If you want **Colab GPU** running on another coding harness or MCP client, please **[open a Harness Support Issue](https://github.com/Gruu6y/Colab-GPU/issues/new?template=harness_request.yml)** naming your harness — we will add native adapter/UI/skill support right away!
---
## Agent Collaboration Protocol (`colab-agent-workflow`)
The bundled skill [`skills/colab-agent-workflow/SKILL.md`](./skills/colab-agent-workflow/SKILL.md) teaches Antigravity agents to coordinate safely on shared GPUs:
1. **Inspect & Discover**: `colab_status` -> `colab_discover_ready_cards` (`minVramGb`). Never steal another agent's `in_use` GPU.
2. **Atomic Claim**: `colab_claim_card` (`owner`, `note`, `endpoint` or auto-smallest match).
3. **Register Task with Mandatory ETA**: `colab_task_create` (`estimatedMinutes > 0`, `assignedEndpoint`, step breakdown) drops a read-only progress card onto the user's panel.
4. **Heartbeat Every 5–8 Minutes**: `colab_task_update` keeps ETA accurate and stops CPU preprocessing / data-loading steps from tripping `IDLE_BURN`.
5. **Renew Long-Job Tokens (>50m)**: `colab_refresh_card_token` refreshes the ~60m `proxyToken` live without killing running kernels.
6. **Clean Closeout**: Finalize task (`done` / `failed`), then call `colab_release_card` (`action: "stop"` to end billing, or `"ready"` only for immediate warm handoff).
---
## FAQ
- **Which host harnesses are currently supported?**
**Google Antigravity** is fully supported out of the box in `v1.0.0`. Because this plugin speaks standard MCP (`@modelcontextprotocol/sdk` + `@modelcontextprotocol/ext-apps`), adapting to other harnesses (Claude Code, Cursor, Codex, Windsurf, Cline, Zed, etc.) is straightforward — **open an Issue and we will add support immediately**.
- **Do I need to configure my own Google Cloud OAuth app?**
No. `src/server/colab/auth.ts` uses Google's public installed desktop OAuth client parameters (RFC 8252 + PKCE) out of the box, or you can set `AGY_COLAB_OAUTH_CLIENT_ID` and `AGY_COLAB_OAUTH_CLIENT_SECRET` in `mcp_config.json` to use your own GCP OAuth client. Credentials stay strictly inside `~/.gemini/antigravity/plugin_data/agy-colab` (or your `${PLUGIN_DATA}` directory).
- **Will updating or toggling the plugin delete my active GPU leases or credentials?**
No. Runtime state, credentials, balance batches, snoozes, and tasks live in Antigravity's separate `plugin_data/agy-colab` directory, isolated from plugin installation files in `~/.gemini/config/plugins/agy-colab`.
- **Where are proxy passwords protected?**
Proxy URLs stored in `config.json` are normalized and validated strictly (`http://` / `https://` only) and scrubbed by `maskProxyUrl` / `scrubProxyCredentialsFromText` before entering UI payloads, dashboard caches, error messages, or logs.
<details>
<summary><strong>CLI Utilities & Repository Structure (Click to expand)</strong></summary>
#### Common CLI Commands
```bash
npm run version:check # Verify single SemVer SSOT across package, manifests, code & docs
npm run typecheck # Typecheck both UI (React/Vite) and MCP Server (TypeScript)
npm run build # Build single-file UI HTML and bundled ESM MCP server
npm run test:gates # Run architecture, XSS/secret hygiene, zero-demo & asset-budget gates
npm test # Run full zero-mocked-network + MCP stdio integration suite
npm run install:plugin # Install into ~/.gemini/config/plugins/agy-colab (-- --copy-deps supported)
npm run package:release # Build portable .zip / .tar.gz bundles + SHA256SUMS.txt into release/
```
#### Repository Layout
```text
Colab-GPU/
├── plugin.json / mcp_config.json # Antigravity plugin & MCP server manifest (ID: agy-colab)
├── LICENSE / NOTICE / CITATION.cff # GPL-3.0-only license, Section 7 NOTICE & citation metadata
├── THIRD_PARTY_NOTICES.md # MIT / Apache-2.0 dependency attributions
├── AGENTS.md / CHANGELOG.md # Engineering redlines & bilingual release history
├── assets/logo.svg # Compact vector plugin emblem (< 256 KiB budget)
├── docs/ # README.zh-CN.md, ROADMAP.md, ADRs, CONTRIBUTORS & showcase images
├── skills/colab-agent-workflow/ # Bundled Agent collaboration protocol skill (SKILL.md)
├── scripts/ # install-plugin.mjs, check-version.mjs, package-release.mjs
├── src/
│ ├── server/
│ │ ├── index.ts # MCP stdio entry, ui:// resource host & build-id injection
│ │ ├── colab/ # auth.ts (PKCE OAuth), api.ts, racer.ts (AIMD), runtime.ts (telemetry)
│ │ ├── net/ # http.ts (failover/scrubbing), proxy-pool.ts (affinity/fastest/breaker)
│ │ ├── state/ # store.ts (domain locks), balance-ledger.ts (FIFO), dashboard-cache.ts, legacy-sync.ts
│ │ └── tools/ # agent-tools.ts (10 colab_* tools), app-tools.ts (19 app_* UI tools), dashboard.ts
│ └── ui/ # React 19 single-file MCP App console (App.tsx, components/, lib/, theme.css)
└── tests/ # 7 domain suites + architectural/security gates (node:test)
```
</details>
---
## License, Derivative Rules & Citation
### 1. Open-Source License & Mandatory Attribution (`GPL-3.0-only` + `NOTICE`)
**Colab GPU (`agy-colab`)** (`Copyright (C) 2026 Gruu6y`) is licensed under the **[GNU General Public License v3.0 (`GPL-3.0-only`)](./LICENSE)** with mandatory Section 7 attribution terms in **[`NOTICE`](./NOTICE)**.
Any fork, modification, port, or redistribution must comply with all three requirements:
1. **Same-License Copyleft**: Any derivative plugin, bundled MCP server, or distribution incorporating code from Colab GPU must be released under **`GPL-3.0`** with complete corresponding source code accessible. Proprietary bundling or closed-source resale is prohibited.
2. **Preserve Attribution Chain**: Retain [`LICENSE`](./LICENSE), [`NOTICE`](./NOTICE), and [`THIRD_PARTY_NOTICES.md`](./THIRD_PARTY_NOTICES.md) intact, and preserve visible credit linking back to `@Gruu6y` and `Gruu6y/Colab-GPU`.
3. **Mark Modifications & Non-Endorsement**: Document modification summaries and dates on altered files, and do not distribute modified forks under the unmodified `Colab GPU` / `agy-colab` branding as official releases without permission.
#### Downstream Attribution Snippet
```markdown
> Built upon [Colab GPU](https://github.com/Gruu6y/Colab-GPU) by [@Gruu6y](https://github.com/Gruu6y), licensed under [GPL-3.0](https://www.gnu.org/licenses/gpl-3.0.html). Attribution and third-party notices are preserved in `NOTICE` and `THIRD_PARTY_NOTICES.md`.
```
#### Citation (`CITATION.cff` / BibTeX)
```bibtex
@software{gruu6y_colab_gpu_2026,
author = {Gruu6y},
title = {{Colab GPU (agy-colab): Direct Google Colab GPU Orchestrator, Multi-Exit Proxy Pool & Agent Task Cockpit}},
year = {2026},
version = {1.0.0},
license = {GPL-3.0-only},
url = {https://github.com/Gruu6y/Colab-GPU}
}
```
### 2. Community Contributors & Release Verification
- **Contributors**: Thank you to everyone testing, filing bugs, requesting new harnesses, and opening PRs — see [`docs/CONTRIBUTORS.md`](./docs/CONTRIBUTORS.md) and [`.github/CONTRIBUTING.md`](./.github/CONTRIBUTING.md).
- **Security Policy**: Report vulnerabilities privately via **GitHub Security Advisories** — see [`.github/SECURITY.md`](./.github/SECURITY.md).
- **Verifying Releases**: Every official GitHub Release attaches a CI-generated `SHA256SUMS.txt` digest file covering both `agy-colab-v<version>.zip` and `agy-colab-v<version>.tar.gz`.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues