Real-time awareness, coordination, and collaboration for Claude Code agents via Gigabuddy places. Agents see peers join and leave, what files they're focused…

Real-time awareness, coordination, and collaboration for Claude Code agents via Gigabuddy places. Agents see peers join and leave, what files they're focused on, conflicts, and messages — injected straight into context.
# In Claude Code:
/plugin marketplace add gigabuddy/agent-plugins
/plugin install gigabuddy
Restart Claude Code — plugin MCP servers only attach at session start.
The plugin is a thin shell: it launches the @gigabuddy/agent MCP server from npm, which connects your session to the Gigabuddy door. Sign in when prompted on first connect.
@gigabuddy/agent, the Gigabuddy agent client./decide, /handover, /pickup, /idea, /issue. Skill guidance is served live by the Gigabuddy door, so it improves without plugin updates.This repository contains the plugin shell only. The Gigabuddy platform is proprietary; see https://gigabuddy.com.
mod/register.tsx 168 lines1/**
2 * The Gigabuddy mod — Gigabuddy driving this Claude Code session from its live
3 * record (page:ihuoK970I4i8, decision:FWFiBJHe8lPw).
4 *
5 * The plugin's own MCP server (`agent`) already holds the live connection to
6 * Gigabuddy, and this module does one thing: a loop collects what the person
7 * sent from the session view (bounded waits, re-armed from a timer, so nothing
8 * polls a server). A message is submitted as the person's own words
9 * (`$.prompt.submit` with `asUser`, a turn of its own once the session is
10 * idle); a Stop ends the running turn.
11 *
12 * The wait runs over the agent's private socket (`$.http.fetch`), which
13 * `session_commands_socket` names, and only there. Never over `$.mcp.call`: an
14 * MCP call in flight is moved to a background task whenever a message reaches
15 * the session, and its result then reaches the MODEL as a task notification —
16 * on an idle session a turn of its own, which moves the next wait to the
17 * background in turn, so the model wakes itself every 25s. The MCP fallback
18 * this loop once had did exactly that on 2026-10-19: an IPv4 outage failed two
19 * socket waits in a row, every open session settled on MCP for good and kept
20 * waking itself. So a failed wait only backs off and asks the agent again
21 * where to wait (it may have restarted). A session the socket cannot serve is
22 * not driven from Gigabuddy, which costs far less than a model that wakes
23 * itself.
24 *
25 * It does NOT decide tool prompts. A mod can only replace Claude Code's own
26 * permission dialog with a prompt of its own, which loses the dialog's choices
27 * (don't ask again, this session, the suggested rules, auto mode) — Daniel,
28 * 2026-10-09: not until a mod's prompt is at least as good. Answering the real
29 * dialog from Gigabuddy is the channel relay's job (libs/agent channel.ts),
30 * for a session launched with the channel: `claude
31 * --dangerously-load-development-channels plugin:gigabuddy@gigabuddy`. The
32 * server-side tools for a mod-driven approval (`permission_check` and
33 * friends) stay, unused, for when that prompt is built.
34 *
35 * A hook's budget counts its own time only, never a `$` call in flight, so the
36 * waits cost nothing. Nothing here runs under `-p` (no one to ask).
37 */
38import type { EngineInterface, Register } from 'claude-code';
39
40/** The server's key in this plugin's .mcp.json. */
41const SERVER_KEY = 'agent';
42/** One bounded wait on the agent; the socket caps it there too. */
43const WAIT_MS = 25_000;
44/** Between two inbound waits — a breath, not a poll: the wait itself blocks until something arrives. */
45const REARM_MS = 50;
46/** After a failed wait, before asking the agent again where to wait; doubled per failure in a row, up to RETRY_MAX_MS. */
47const RETRY_MS = 5_000;
48const RETRY_MAX_MS = 60_000;
49
50/** A JSON object from text; `{}` when it is not one. */
51function parseJson(text: string | undefined): Record<string, unknown> {
52 if (!text) return {};
53 try {
54 const parsed = JSON.parse(text) as unknown;
55 return parsed && typeof parsed === 'object' ? (parsed as Record<string, unknown>) : {};
56 } catch {
57 return {};
58 }
59}
60
61/** Where the inbound loop waits: the agent's private socket. */
62type Inbound = { socketPath: string; token: string };
63
64/** What the inbound loop needs of the module: the server, where it waits, failures in a row, and the running turn for Stop. */
65type Link = { server: string | null; inbound: Inbound | null; failures: number; turnId: string | null };
66
67/**
68 * Ask the agent where to wait. 'none': nothing to collect (the launcher's
69 * stand-in, with no agent running). Throws when the agent can't say right now
70 * (restarting, a socket it could not open, an agent without the verb).
71 */
72async function locate($: EngineInterface, server: string): Promise<Inbound | 'none'> {
73 const result = await $.mcp.call(server, 'session_commands_socket');
74 const text = result.content.find((c) => c.type === 'text')?.text;
75 if (result.isError) throw new Error(`no socket from the agent: ${text ?? 'no reason given'}`);
76 const { socketPath, token } = parseJson(text);
77 return typeof socketPath === 'string' && typeof token === 'string' ? { socketPath, token } : 'none';
78}
79
80/** One bounded wait: everything held, the next command, or nothing after WAIT_MS. */
81async function wait($: EngineInterface, inbound: Inbound): Promise<unknown> {
82 const res = await $.http.fetch(`http://agent/commands?wait=${WAIT_MS}`, {
83 socketPath: inbound.socketPath,
84 headers: { authorization: `Bearer ${inbound.token}` },
85 });
86 if (!res.ok) throw new Error(`the agent answered ${res.status}`);
87 return parseJson(res.text)['commands'];
88}
89
90/** One wait, then whatever came in, then the next wait. Re-armed from a timer: work that outlives a dispatch. */
91async function collect($: EngineInterface, link: Link): Promise<void> {
92 if (!link.server) return;
93 let commands: unknown;
94 try {
95 if (!link.inbound) {
96 const found = await locate($, link.server);
97 if (found === 'none') {
98 $.ui.log('gigabuddy: no agent running, so nothing to collect from Gigabuddy', { to: 'debug' });
99 return;
100 }
101 link.inbound = found;
102 }
103 commands = await wait($, link.inbound);
104 link.failures = 0;
105 } catch (err) {
106 const delay = Math.min(RETRY_MS * 2 ** link.failures, RETRY_MAX_MS);
107 link.failures += 1;
108 link.inbound = null;
109 $.ui.log(`gigabuddy: session commands wait failed (${String(err)}); again in ${delay}ms`, { to: 'debug' });
110 $.clock.after(delay, () => void collect($, link));
111 return;
112 }
113 for (const command of Array.isArray(commands) ? commands : []) {
114 try {
115 await handle($, link, command as Record<string, unknown>);
116 } catch (err) {
117 $.ui.log(`gigabuddy: a command from Gigabuddy failed: ${String(err)}`, { to: 'debug' });
118 }
119 }
120 $.clock.after(REARM_MS, () => void collect($, link));
121}
122
123async function handle($: EngineInterface, link: Link, command: Record<string, unknown>): Promise<void> {
124 if (command['kind'] === 'message' && typeof command['text'] === 'string' && command['text']) {
125 // The person's own words, read bare; queued for a turn of its own once the session is idle.
126 await $.prompt.submit({ text: command['text'], asUser: true });
127 return;
128 }
129 if (command['kind'] === 'abort') {
130 if (!link.turnId) return;
131 try {
132 await $.turn.abort({ turnId: link.turnId });
133 $.ui.toast('Stopped from Gigabuddy');
134 } catch (err) {
135 $.ui.log(`gigabuddy: stop failed: ${String(err)}`, { to: 'debug' });
136 }
137 }
138}
139
140export const register: Register = (on) => {
141 /** The server's name as `$.mcp.call` takes it (null until connected), where to wait, failures in a row, and the running turn. */
142 const link: Link = { server: null, inbound: null, failures: 0, turnId: null };
143
144 // ── Inbound: what the person sent from the session view ─────────────────────
145
146 on('session.start', async ($, e, next) => {
147 if (!e.isInteractive) return next(e);
148 const connected = await $.mcp.connect(SERVER_KEY);
149 if (connected.isConnected) {
150 link.server = connected.server;
151 $.clock.after(REARM_MS, () => void collect($, link));
152 } else {
153 $.ui.log(`gigabuddy: not driving this session from Gigabuddy (${connected.message})`, { to: 'debug' });
154 }
155 return next(e);
156 });
157
158 on('turn.start', ($, e, next) => {
159 link.turnId = e.turnId;
160 return next(e);
161 });
162
163 on('turn.complete', ($, e, next) => {
164 link.turnId = null;
165 return next(e);
166 });
167};
168