Files
gemini-cli/scripts/forever-bridge/README.md
Sandy Tao 79ea865790 feat: introduce Forever Mode with A2A listener
- Sisyphus: auto-resume timer with schedule_work tool
- Confucius: built-in sub-agent for knowledge consolidation before compression
- Hippocampus: in-memory short-term memory via background micro-consolidation
- Bicameral Voice: proactive knowledge alignment on user input
- Archive compression mode for long-running sessions
- Onboarding dialog for first-time Forever Mode setup
- Refresh system instruction per turn so hippocampus reaches the model
- Auto-start A2A HTTP server when Forever Mode + Sisyphus enabled
- Bridge external messages into session and capture responses
- Display A2A port in status bar alongside Sisyphus timer
2026-03-06 22:03:20 -08:00

57 lines
2.3 KiB
Markdown

# Forever Bridge — Google Chat via Pub/Sub
Zero-dependency Node.js service that runs Gemini CLI in forever mode on a GCE
VM, receiving Google Chat messages via Cloud Pub/Sub and responding via Chat
REST API.
**No `npm install` needed.** Auth uses the GCE metadata server; Pub/Sub and Chat
use raw REST APIs. Just `node main.mjs`.
## Architecture
```
Google Chat Space
↓ Pub/Sub topic
Cloud Pub/Sub (pull)
main.mjs (poll loop)
├── process-manager.mjs → npx gemini-cli --forever -r -y -m gemini-3-flash-preview
│ └── A2A JSON-RPC on localhost:3100
└── Chat REST API → Google Chat Space (response)
```
## Files
| File | Purpose |
| --------------------- | ------------------------------------------------------------------------ |
| `main.mjs` | Pub/Sub poller, Chat API client, A2A forwarder, health check, entrypoint |
| `process-manager.mjs` | Spawns/restarts Gemini CLI with exponential backoff |
## Usage
```bash
# On a GCE VM with appropriate service account:
export GOOGLE_API_KEY="your-gemini-api-key"
export PUBSUB_SUBSCRIPTION="projects/my-project/subscriptions/chat-sub"
node main.mjs
```
## Environment Variables
| Variable | Required | Default | Description |
| --------------------- | -------- | ------------------------ | --------------------------------- |
| `GOOGLE_API_KEY` | Yes | — | Gemini API key |
| `PUBSUB_SUBSCRIPTION` | Yes | — | `projects/PROJ/subscriptions/SUB` |
| `A2A_PORT` | No | `3100` | Agent A2A port |
| `GEMINI_MODEL` | No | `gemini-3-flash-preview` | Model |
| `HEALTH_PORT` | No | `8081` | Health check port |
| `POLL_INTERVAL_MS` | No | `1000` | Pub/Sub poll interval |
## GCP Prerequisites
1. Chat API + Pub/Sub API enabled
2. Service account with `Pub/Sub Subscriber` + `Chat Bot` roles
3. Google Chat app configured with **Cloud Pub/Sub** connection type
4. Pub/Sub subscription created for the Chat topic