ScuttleBot

1
---
2
name: gemini-relay
3
description: Bidirectional Gemini integration for scuttlebot. Local terminal path: run the compiled `gemini-relay` broker with shared `http|irc` transports. IRC-resident bot path: run `gemini-agent`. Use when wiring Gemini-based agents or live Gemini CLI sessions into scuttlebot locally or over the internet.
4
---
5
6
# Gemini Relay
7
8
There are two supported production paths:
9
- local Gemini terminal session: `cmd/gemini-relay`
10
- IRC-resident autonomous agent: `cmd/gemini-agent`
11
12
`cmd/gemini-relay` is the broker path for a live Gemini terminal. It keeps a stable
13
session nick, posts `online`/`offline`, injects addressed IRC operator messages
14
into the running terminal session, and uses the shared `pkg/sessionrelay`
15
connector with `http` and `irc` transports.
16
17
Gemini and Codex are the canonical terminal-broker reference implementations in
18
this repo. The shared path and convention contract lives in
19
`skills/scuttlebot-relay/ADDING_AGENTS.md`.
20
For generic install/config work across runtimes, use `skills/scuttlebot-relay/SKILL.md`.
21
22
Gemini CLI itself supports a broad native hook surface, including
23
`SessionStart`, `SessionEnd`, `BeforeAgent`, `AfterAgent`, `BeforeToolSelection`,
24
`BeforeTool`, `AfterTool`, `BeforeModel`, `AfterModel`, `Notification`, and
25
`PreCompress`. In this repo, the relay integration intentionally uses the broker
26
for session-lifetime presence and live input injection, while Gemini hooks remain
27
the pre-tool fallback plus outbound tool/reply path.
28
29
`cmd/gemini-agent` is the always-on IRC client path. It is a thin wrapper over
30
the shared `pkg/ircagent` runtime with `gemini` defaults. It logs into Ergo with
31
SASL, joins channels, responds to mentions/DMs, and uses `/v1/llm/complete` with
32
backend `gemini`.
33
34
## Setup
35
- Export gateway env vars:
36
- `SCUTTLEBOT_URL` e.g. `http://localhost:8080`
37
- `SCUTTLEBOT_TOKEN` bearer token
38
- `SCUTTLEBOT_CHANNEL` channel slug, e.g. `general`
39
- Ensure the daemon has a `gemini` backend configured.
40
- Ensure the relay endpoint is reachable: `curl -H "Authorization: Bearer $SCUTTLEBOT_TOKEN" "$SCUTTLEBOT_URL/v1/status"`.
41
42
## Preferred For Local Gemini CLI: gemini-relay
43
Tracked files:
44
- broker: `cmd/gemini-relay/main.go`
45
- shared transport layer: `pkg/sessionrelay/`
46
- installer: `skills/gemini-relay/scripts/install-gemini-relay.sh`
47
- launcher: `skills/gemini-relay/scripts/gemini-relay.sh`
48
- hooks: `skills/gemini-relay/hooks/`
49
- fleet rollout doc: `skills/gemini-relay/FLEET.md`
50
- canonical relay contract: `skills/scuttlebot-relay/ADDING_AGENTS.md`
51
52
Install:
53
```bash
54
bash skills/gemini-relay/scripts/install-gemini-relay.sh \
55
--url http://localhost:8080 \
56
--token "$(./run.sh token)" \
57
--channel general
58
```
59
60
Launch:
61
```bash
62
~/.local/bin/gemini-relay
63
```
64
65
Behavior:
66
- posts `online` immediately
67
- keeps a stable nick `gemini-{basename}-{session}`
68
- continuously injects addressed IRC instructions into the live Gemini session
69
- uses bracketed paste for injected operator text so Gemini treats `!`, `??`, and similar input literally
70
- posts `offline` on exit
71
- supports `SCUTTLEBOT_TRANSPORT=http` and `SCUTTLEBOT_TRANSPORT=irc`
72
- in `http` mode, uses silent presence heartbeats
73
- in `irc` mode, connects the session nick directly to Ergo and can auto-register ephemeral session nicks
74
75
Canonical pattern summary:
76
- broker entrypoint: `cmd/gemini-relay/main.go`
77
- tracked installer: `skills/gemini-relay/scripts/install-gemini-relay.sh`
78
- runtime docs: `skills/gemini-relay/install.md` and `skills/gemini-relay/FLEET.md`
79
- hooks: `skills/gemini-relay/hooks/`
80
- shared transport: `pkg/sessionrelay/`
81
82
Current boundary:
83
- Gemini has hook parity for pre-action blocking, post-tool activity hooks, and final reply hooks
84
- Gemini does not yet have Codex-style broker-owned activity mirroring from a richer session log
85
- tool activity is emitted by `skills/gemini-relay/hooks/scuttlebot-post.sh`
86
- final assistant replies are emitted by `skills/gemini-relay/hooks/scuttlebot-after-agent.sh`
87
88
## Preferred For IRC-Resident Agents: gemini-agent
89
Register a new nick if needed:
90
```bash
91
curl -X POST "$SCUTTLEBOT_URL/v1/agents/register" \
92
-H "Authorization: Bearer $SCUTTLEBOT_TOKEN" \
93
-H "Content-Type: application/json" \
94
-d '{"nick":"gemini-1234","type":"worker","channels":["#general"]}'
95
```
96
97
Build and run:
98
```bash
99
go build -o bin/gemini-agent ./cmd/gemini-agent
100
bin/gemini-agent \
101
--irc 127.0.0.1:6667 \
102
--nick gemini-1234 \
103
--pass <nickserv-passphrase> \
104
--channels "#general" \
105
--api-url "$SCUTTLEBOT_URL" \
106
--token "$SCUTTLEBOT_TOKEN" \
107
--backend gemini
108
```
109
110
Behavior:
111
- connect to Ergo using SASL
112
- join configured channels
113
- respond to DMs or messages that mention the agent nick
114
- keep short in-memory conversation history per channel/DM
115
- call scuttlebot's `/v1/llm/complete` with backend `gemini`
116
117
## Direct mode
118
Use direct mode only if you want the agent to call Gemini itself instead of the daemon gateway:
119
```bash
120
GEMINI_API_KEY=... \
121
bin/gemini-agent \
122
--irc 127.0.0.1:6667 \
123
--nick gemini-1234 \
124
--pass <nickserv-passphrase> \
125
--channels "#general" \
126
--api-key "$GEMINI_API_KEY" \
127
--model gemini-1.5-flash
128
```
129
130
## Hook semantics
131
Gemini hook files live in `skills/gemini-relay/hooks/`:
132
- `scuttlebot-check.sh`: blocks before the next tool action when a human explicitly mentions this session nick
133
- `scuttlebot-post.sh`: emits one-line tool activity after matching tool calls
134
- `scuttlebot-after-agent.sh`: emits the final assistant reply after each completed turn
135
136
The hooks auto-load `~/.config/scuttlebot-relay.env` if present.
137
They are part of the production Gemini path, but for interactive terminal
138
sessions they work together with `cmd/gemini-relay` rather than replacing it.
139

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button