Spaces:
Paused
Paused
| title: GBridge PhoneGPU | |
| emoji: π± | |
| colorFrom: indigo | |
| colorTo: blue | |
| sdk: docker | |
| app_port: 7860 | |
| pinned: false | |
| license: mit | |
| # GBridge PhoneGPU + M5 API Gateway | |
| **The Hugging Face Space that turns an iPhone into a private ML server, provides a WebOllama-style local compute gateway, and turns Windsurf into the build agent for the bridge itself.** | |
| The Space is the public endpoint. The iPhone is the private model worker. Windsurf is the engineering agent. gbridge is the connective tissue. M5 provides OpenAI-compatible access to local Ollama compute. Every job produces a signed receipt. | |
| ## What this is | |
| GBridge is a **capability-to-endpoint connectivity layer**. | |
| A live node (iPhone, browser, Windsurf agent) advertises a capability, leases it to the Space, and the Space binds it to an HTTP/WebSocket endpoint. Jobs route to the node. Results return with signed receipts. | |
| ## Pages | |
| - `/` β Landing / Manifest | |
| - `/phone` β iPhone compute bridge with QR pairing | |
| - `/gbridge` β Protocol explorer with capability lease table | |
| - `/windsurf` β Build packet generator and MCP manifest export | |
| - `/receipts` β Proof console for signed compute receipts | |
| - `/dashboard` β 2050 real-time control plane | |
| - `/m5` β M5 API Gateway (WebOllama-style local compute interface) | |
| ## Core API | |
| - `POST /api/gbridge/session` β create compute session | |
| - `GET /api/gbridge/session/{id}` β session status | |
| - `POST /cap/{capability_name}` β invoke leased capability | |
| - `GET /api/windsurf/packet` β Windsurf build packet | |
| - `GET /api/windsurf/mcp` β MCP server manifest | |
| - `POST /api/windsurf/ingest` β ingest agent build report | |
| - `GET /api/receipts` β list receipts | |
| - `POST /api/receipts/{id}/verify` β verify receipt | |
| ## M5 API Gateway (OpenAI-Compatible) | |
| M5 provides a Groq/OpenRouter-style API gateway for local Ollama compute. | |
| ### Account API | |
| - `POST /api/accounts/register` β Create account | |
| - `POST /api/accounts/login` β Login and get API key | |
| - `GET /api/accounts/me` β Get account details | |
| - `POST /api/accounts/api-keys` β Create API key | |
| - `DELETE /api/accounts/api-keys/{key_id}` β Revoke API key | |
| - `POST /api/accounts/chats` β Create chat session | |
| - `GET /api/accounts/chats` β List chat sessions | |
| - `GET /api/accounts/chats/{session_id}` β Get chat history | |
| ### OpenAI-Compatible API | |
| - `POST /v1/chat/completions` β Chat completions (supports streaming) | |
| - `GET /v1/models` β List available Ollama models | |
| ### Usage Example | |
| ```bash | |
| # Register | |
| curl -X POST https://your-space.hf.space/api/accounts/register \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"email":"user@example.com","password":"pass123","name":"User"}' | |
| # Login to get API key | |
| curl -X POST https://your-space.hf.space/api/accounts/login \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"email":"user@example.com","password":"pass123"}' | |
| # Use OpenAI-compatible endpoint | |
| curl -X POST https://your-space.hf.space/v1/chat/completions \ | |
| -H "Content-Type: application/json" \ | |
| -H "X-API-Key: m5_xxxx" \ | |
| -d '{"model":"llama3.2","messages":[{"role":"user","content":"Hello"}],"ollama_url":"http://localhost:11434"}' | |
| ``` | |
| ## gbridge primitive | |
| ```python | |
| route_capability_call(capability_name, payload) | |
| ``` | |
| 1. Find active lease for capability | |
| 2. Verify lease is not expired | |
| 3. Check payload policy | |
| 4. Create job | |
| 5. Route to correct node | |
| 6. Return async job id | |
| 7. Verify receipt | |
| 8. Return output + receipt | |
| ## Architecture | |
| ``` | |
| Hugging Face Space | |
| βββ gbridge router | |
| βββ phone relay (WebSocket) | |
| βββ receipt verifier | |
| βββ Windsurf packet generator | |
| βββ MCP manifest exporter | |
| iPhone Worker (PWA) | |
| βββ local runtime detector | |
| βββ local ML / redaction / embeddings | |
| βββ device keypair | |
| βββ signed receipt emitter | |
| Windsurf / Cascade | |
| βββ consumes generated build packet | |
| βββ optionally connects through MCP/gbridge manifest | |
| βββ patches repo | |
| βββ sends build report back as receipt | |
| ``` | |
| ## What this is | |
| PhoneGPU Space creates a new topology: | |
| - **Public Space** = control plane, API, marketplace, verifier, dashboard | |
| - **iPhone** = private edge inference node (Neural Engine / GPU / CPU) | |
| - **Receipt** = proof of local execution | |
| This is not cloud inference from a phone. This is **device-leased inference**: a public Hugging Face Space temporarily binds a private iPhone as its backend ML worker through a revocable, receipt-producing compute session. | |
| ## How it works | |
| 1. Open the Space and create a session | |
| 2. Scan the QR code with your iPhone | |
| 3. The iPhone registers as a worker and advertises its capabilities | |
| 4. Submit an inference job through the Space UI or API | |
| 5. The iPhone receives the job, runs it locally with Core ML / Web ML | |
| 6. The iPhone returns the result plus a signed receipt | |
| 7. The Space verifies and stores the receipt | |
| ## Environment Variables | |
| | Variable | Description | Default | | |
| |----------|-------------|---------| | |
| | `SPACE_PUBLIC_URL` | Public URL of this Space | Auto-detected | | |
| | `SESSION_TTL_SECONDS` | Session lifetime | 3600 | | |
| | `JOB_TTL_SECONDS` | Job timeout | 300 | | |
| | `MAX_PAYLOAD_BYTES` | Max request payload | 10485760 | | |
| | `REQUIRE_DEVICE_SIGNATURES` | Require signed receipts | false | | |
| | `RECEIPT_STORAGE_PATH` | Where to store receipts | ./data/receipts.jsonl | | |
| ## API Endpoints | |
| - `POST /api/session` β Create a new compute session | |
| - `GET /api/session/{id}` β Get session status | |
| - `POST /api/session/{id}/job` β Submit inference job | |
| - `GET /api/job/{id}` β Get job result | |
| - `GET /api/receipt/{id}` β Get signed receipt | |
| - `POST /api/receipt/{id}/verify` β Verify receipt | |
| - `GET /worker` β iPhone worker page (with QR scan) | |
| - `WS /ws/worker/{session_id}/{worker_id}` β Worker WebSocket | |
| ## Capabilities (v1) | |
| - `iphone.text.embedding.private` β Local text embedding | |
| - `iphone.image.classify.local` β Local image classification | |
| - `iphone.privacy.redact.local` β Local privacy redaction | |
| ## Architecture | |
| ``` | |
| User β HF Space UI/API β Session β Job Queue β iPhone Worker β Core ML/ONNX/WebML β Signed Result β Receipt | |
| ``` | |
| ## Security | |
| - Outbound-only connections from iPhone (no inbound ports needed) | |
| - Worker join tokens with expiry | |
| - Ed25519 receipt signatures where supported | |
| - Input/output hashing for verification | |
| - Privacy modes: raw, hash-only, local-only | |
| ## Development | |
| ```bash | |
| pip install -r requirements.txt | |
| python -m uvicorn app.main:app --host 0.0.0.0 --port 7860 | |
| ``` | |
| ## License | |
| Proprietary β Membra Technologies | |