groove-dev 0.27.211 → 0.27.213

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CLAUDE.md CHANGED
@@ -295,11 +295,3 @@ Audit-driven release. Multi-agent orchestration system with 7 coordination layer
295
295
  - Dashboard: routing donut, cache panel, context health gauges
296
296
  - Monitor/QC agent mode (stay active, loop)
297
297
  - Distribution: demo video, HN launch, Twitter content
298
-
299
- <!-- GROOVE:START -->
300
- ## GROOVE Orchestration (auto-injected)
301
- Active agents: 0
302
- See AGENTS_REGISTRY.md for full agent state, the names of agents on other teams,
303
- and how to consult them directly (InnerChat).
304
- **Memory policy:** GROOVE manages project memory automatically. Do not read or write MEMORY.md or .groove/memory/ files directly.
305
- <!-- GROOVE:END -->
@@ -0,0 +1,87 @@
1
+ // FSL-1.1-Apache-2.0 — see LICENSE
2
+ import { existsSync, readdirSync } from 'fs';
3
+ import { createRequire } from 'module';
4
+ import { dirname, join } from 'path';
5
+ import { pathToFileURL } from 'url';
6
+
7
+ const port = 31415;
8
+ const projectDir = process.argv[2] || process.cwd();
9
+
10
+ function preflightCheck(daemonPath) {
11
+ if (!existsSync(daemonPath)) {
12
+ throw new Error(
13
+ `Daemon entry point not found at ${daemonPath}. ` +
14
+ 'The app may not have been packaged correctly — try reinstalling Groove.'
15
+ );
16
+ }
17
+
18
+ const daemonDir = dirname(daemonPath);
19
+ const require = createRequire(daemonPath);
20
+ const critical = ['express', 'ws'];
21
+ const missing = critical.filter(dep => {
22
+ try { require.resolve(dep); return false; } catch { return true; }
23
+ });
24
+
25
+ if (missing.length) {
26
+ const diag = [`Missing deps: ${missing.join(', ')}`, `GROOVE_DAEMON_PATH: ${daemonPath}`];
27
+ let walkDir = daemonDir;
28
+ for (let i = 0; i < 5 && walkDir !== dirname(walkDir); i++) {
29
+ try {
30
+ const entries = readdirSync(walkDir);
31
+ diag.push(`${walkDir}/: [${entries.join(', ')}]`);
32
+ } catch { diag.push(`${walkDir}/: (unreadable)`); }
33
+ walkDir = dirname(walkDir);
34
+ }
35
+ throw new Error(
36
+ `Daemon is missing dependencies. ` +
37
+ `Diagnostics:\n${diag.join('\n')}\n` +
38
+ 'The app bundle may be incomplete — try reinstalling Groove.'
39
+ );
40
+ }
41
+ }
42
+
43
+ async function main() {
44
+ let Daemon;
45
+ const daemonPath = process.env.GROOVE_DAEMON_PATH;
46
+
47
+ if (daemonPath) {
48
+ preflightCheck(daemonPath);
49
+ const mod = await import(pathToFileURL(daemonPath).href);
50
+ Daemon = mod.Daemon;
51
+ } else {
52
+ const mod = await import('@groove-dev/daemon');
53
+ Daemon = mod.Daemon;
54
+ }
55
+
56
+ const daemon = new Daemon({ port, projectDir });
57
+ await daemon.start();
58
+
59
+ process.send({ type: 'ready', port: daemon.port });
60
+
61
+ process.on('message', (msg) => {
62
+ if (msg.type === 'auth-token') {
63
+ (async () => {
64
+ try { await daemon.setAuthToken(msg.token); } catch (err) {
65
+ process.stderr.write(`[daemon-bridge] setAuthToken failed: ${err.message}\n`);
66
+ }
67
+ })();
68
+ }
69
+ });
70
+
71
+ process.on('SIGTERM', async () => {
72
+ await daemon.stop();
73
+ process.exit(0);
74
+ });
75
+
76
+ process.on('SIGINT', async () => {
77
+ await daemon.stop();
78
+ process.exit(0);
79
+ });
80
+ }
81
+
82
+ main().catch((err) => {
83
+ if (process.send) {
84
+ process.send({ type: 'error', message: err.message });
85
+ }
86
+ process.exit(1);
87
+ });
@@ -21,6 +21,7 @@ import { disconnect } from '../src/commands/disconnect.js';
21
21
  import { remotes } from '../src/commands/remotes.js';
22
22
  import { audit } from '../src/commands/audit.js';
23
23
  import { federationPair, federationUnpair, federationList, federationStatus } from '../src/commands/federation.js';
24
+ import { ask, tell, who } from '../src/commands/ask.js';
24
25
  import { createRequire } from 'node:module';
25
26
  const require = createRequire(import.meta.url);
26
27
  const { version } = require('../../../package.json');
@@ -74,6 +75,25 @@ program
74
75
  .option('-f, --force', 'Required when agents are still running')
75
76
  .action(nuke);
76
77
 
78
+ // InnerChat — agent-to-agent messaging. Listed high in --help because an
79
+ // agent that has lost the capability from context rediscovers it here.
80
+ program
81
+ .command('ask <agent> <message>')
82
+ .description('Ask another agent a question and wait for their answer')
83
+ .option('--from <name>', 'your agent name (defaults to $GROOVE_AGENT_NAME)')
84
+ .action(ask);
85
+
86
+ program
87
+ .command('tell <agent> <message>')
88
+ .description('Send another agent a message without waiting for a reply')
89
+ .option('--from <name>', 'your agent name (defaults to $GROOVE_AGENT_NAME)')
90
+ .action(tell);
91
+
92
+ program
93
+ .command('who')
94
+ .description('List agents you can message with `groove ask` / `groove tell`')
95
+ .action(who);
96
+
77
97
  program
78
98
  .command('rotate <id>')
79
99
  .description('Rotate an agent (kill + respawn with fresh context)')
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@groove-dev/cli",
3
- "version": "0.27.211",
3
+ "version": "0.27.213",
4
4
  "description": "GROOVE CLI — manage AI coding agents from your terminal",
5
5
  "license": "FSL-1.1-Apache-2.0",
6
6
  "type": "module",
@@ -33,8 +33,15 @@ export async function apiCall(method, path, body) {
33
33
  const res = await fetch(url, options);
34
34
 
35
35
  if (!res.ok) {
36
- const err = await res.json().catch(() => ({ error: res.statusText }));
37
- throw new Error(err.error || `HTTP ${res.status}`);
36
+ const body = await res.json().catch(() => ({ error: res.statusText }));
37
+ const err = new Error(body.error || `HTTP ${res.status}`);
38
+ // Carry the response body onto the error. The daemon's actionable fields
39
+ // (availableAgents, didYouMean, note) are the whole point of its error
40
+ // messages — dropping them leaves the caller with a dead end.
41
+ err.status = res.status;
42
+ err.body = body;
43
+ Object.assign(err, body);
44
+ throw err;
38
45
  }
39
46
 
40
47
  return res.json();
@@ -0,0 +1,99 @@
1
+ // GROOVE CLI — InnerChat ask/tell/who
2
+ // FSL-1.1-Apache-2.0 — see LICENSE
3
+ //
4
+ // Agent-to-agent messaging as first-class CLI verbs.
5
+ //
6
+ // The HTTP endpoints came first, and agents were taught them via a curl
7
+ // snippet in the spawn prompt. That decays: on a long session the snippet
8
+ // scrolls out of context and the agent no longer knows the capability exists,
9
+ // or half-remembers it and reaches for a built-in tool that cannot see GROOVE
10
+ // agents. A CLI verb survives that — an agent that has forgotten the details
11
+ // can still run `groove --help` or simply guess `groove ask`, and the command
12
+ // itself explains the rest.
13
+
14
+ import chalk from 'chalk';
15
+ import { apiCall } from '../client.js';
16
+
17
+ // The caller is almost always an agent, and the daemon injects its identity
18
+ // into the environment — so `--from` is a manual override, not a requirement.
19
+ function resolveFrom(opts) {
20
+ const from = opts.from || process.env.GROOVE_AGENT_NAME;
21
+ if (!from) {
22
+ console.error(chalk.red(' Could not tell who is asking.'));
23
+ console.error(chalk.dim(' Pass --from <your-agent-name> (GROOVE_AGENT_NAME is unset — are you running outside an agent?)'));
24
+ process.exit(1);
25
+ }
26
+ return from;
27
+ }
28
+
29
+ function reportError(err, to) {
30
+ console.error(chalk.red(' Failed:'), err.message);
31
+ // The daemon returns actionable bodies (unknown name + roster, ambiguous
32
+ // name + candidates, exchange cap). Surface them rather than a bare status.
33
+ if (err.availableAgents?.length) {
34
+ console.error(chalk.dim(` Agents you can reach: ${err.availableAgents.join(', ')}`));
35
+ }
36
+ if (err.didYouMean?.length) {
37
+ console.error(chalk.dim(` "${to}" is ambiguous — did you mean: ${err.didYouMean.join(', ')}?`));
38
+ }
39
+ process.exit(1);
40
+ }
41
+
42
+ export async function ask(to, message, opts = {}) {
43
+ const from = resolveFrom(opts);
44
+ try {
45
+ console.error(chalk.dim(` Asking ${to}… (this blocks until they answer — that is expected)`));
46
+ const res = await apiCall('POST', '/api/innerchat/ask', { from, to, message });
47
+ // The reply goes to stdout alone so it can be piped/read cleanly; the
48
+ // status chatter goes to stderr.
49
+ console.log(res.reply);
50
+ if (res.exchangesRemaining !== undefined) {
51
+ console.error(chalk.dim(` (${res.exchangesRemaining} exchanges left in this conversation)`));
52
+ }
53
+ } catch (err) {
54
+ reportError(err, to);
55
+ }
56
+ }
57
+
58
+ export async function tell(to, message, opts = {}) {
59
+ const from = resolveFrom(opts);
60
+ try {
61
+ const res = await apiCall('POST', '/api/innerchat/tell', { from, to, message });
62
+ console.error(chalk.green(' Delivered.'), chalk.dim(res.note || `${to} will reply later if needed.`));
63
+ } catch (err) {
64
+ reportError(err, to);
65
+ }
66
+ }
67
+
68
+ // Who can I talk to? The question an agent asks first when it has lost the
69
+ // roster from context — and the reason it otherwise starts guessing names.
70
+ export async function who() {
71
+ try {
72
+ const me = process.env.GROOVE_AGENT_NAME;
73
+ const data = await apiCall('GET', '/api/agents');
74
+ const agents = Array.isArray(data) ? data : (data.agents || []);
75
+ const others = agents.filter((a) => a.name !== me);
76
+
77
+ if (!others.length) {
78
+ console.log(chalk.dim(' No other agents are running right now.'));
79
+ } else {
80
+ console.log(chalk.bold(' Agents you can message:'));
81
+ for (const a of others) {
82
+ const status = a.status === 'running' ? chalk.green('●') : chalk.dim('○');
83
+ console.log(` ${status} ${chalk.bold(a.name)} ${chalk.dim(`(${a.role}${a.status !== 'running' ? `, ${a.status}` : ''})`)}`);
84
+ }
85
+ }
86
+
87
+ const peers = await apiCall('GET', '/api/innerchat/peers').catch(() => ({ peers: [] }));
88
+ if (peers.peers?.length) {
89
+ console.log(chalk.bold('\n Peer machines (address as name@peer):'));
90
+ for (const p of peers.peers) console.log(` ${chalk.bold('@' + p.alias)} ${chalk.dim(p.url)}`);
91
+ }
92
+
93
+ console.log(chalk.dim('\n groove ask <name> "<question>" — blocks until they answer'));
94
+ console.log(chalk.dim(' groove tell <name> "<message>" — returns immediately'));
95
+ } catch (err) {
96
+ console.error(chalk.red(' Failed:'), err.message);
97
+ process.exit(1);
98
+ }
99
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@groove-dev/daemon",
3
- "version": "0.27.211",
3
+ "version": "0.27.213",
4
4
  "description": "GROOVE daemon — agent orchestration engine",
5
5
  "license": "FSL-1.1-Apache-2.0",
6
6
  "type": "module",
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { wrapWithRoleReminder } from './process.js';
4
4
  import { getProvider } from './providers/index.js';
5
+ import { innerChatInstructions } from './innerchat-docs.js';
5
6
 
6
7
  // Reviving a >5M-token claude session has crashed the CLI mid-HTTP-parse
7
8
  // (V8 fatal in JsonStringifier) — past this ceiling the rotator's handoff
@@ -42,7 +43,12 @@ export async function deliverInstruction(daemon, agentId, message, opts = {}) {
42
43
  // and the user's direction, not by how much context has piled up.
43
44
  const clock = daemon.processes.sessionClock?.(agent);
44
45
  const timedMessage = clock ? `${clock}\n\n${finalMessage}` : finalMessage;
45
- const wrappedMessage = wrapWithRoleReminder(agent.role, timedMessage);
46
+ // Spawn-prompt capabilities scroll out of a long session, after which the
47
+ // agent denies it can reach other agents at all. This rides every turn, so
48
+ // it cannot decay — terse by default, expanded when the turn actually asks
49
+ // the agent to contact someone.
50
+ const reach = agentReachHint(daemon, agent, finalMessage);
51
+ const wrappedMessage = wrapWithRoleReminder(agent.role, reach ? `${reach}\n\n${timedMessage}` : timedMessage);
46
52
 
47
53
  // Agent loop path — send straight to the running loop.
48
54
  if (daemon.processes.hasAgentLoop(agentId)) {
@@ -132,3 +138,97 @@ async function respawn(daemon, config) {
132
138
  throw spawnErr;
133
139
  }
134
140
  }
141
+
142
+ // Phrases that mean "go talk to another agent". Deliberately broad: a false
143
+ // positive costs a few tokens of accurate instruction, a false negative costs
144
+ // the user a turn spent watching their agent claim the capability isn't real.
145
+ const CONTACT_INTENT = /\b(ask|message|msg|tell|consult|coordinate|check|sync|reach out|talk|speak|ping|liaise|confer|follow up|loop in)\b/i;
146
+
147
+ // Naming the feature is an EXPLICIT request for it — usually typed after the
148
+ // agent has already failed to find it. That earns the full instructions
149
+ // verbatim, not a hint: no inference, no heuristic that can miss. Matches
150
+ // innerchat / inner chat / inner-chat / InnerChat, and the CLI verbs by name.
151
+ const INNERCHAT_KEYWORD = /\b(inner[\s_-]?chat|groove\s+(?:ask|tell|who))\b/i;
152
+
153
+ /**
154
+ * A capability line appended to every delivered turn.
155
+ *
156
+ * Spawn-time instructions decay — on a long session (or under a model that
157
+ * compacts aggressively) they scroll away, and the agent then insists it has
158
+ * no way to contact anyone, or reaches for a built-in sub-agent tool that
159
+ * cannot see GROOVE agents. Two tiers:
160
+ *
161
+ * - Always: one terse line naming the CLI verbs. ~20 tokens.
162
+ * - When the turn expresses intent to contact someone: the exact command,
163
+ * with the target's real name already filled in.
164
+ */
165
+ export function agentReachHint(daemon, agent, message) {
166
+ let others;
167
+ try {
168
+ others = (daemon.registry.getAll() || []).filter((a) => a.name !== agent.name);
169
+ } catch { return null; }
170
+
171
+ const peers = Array.isArray(daemon.config?.innerchatPeers) ? daemon.config.innerchatPeers : [];
172
+ if (!others.length && !peers.length) return null;
173
+
174
+ const base = '[You can talk to other GROOVE agents: `groove ask <name> "<question>"` waits for their '
175
+ + 'answer, `groove tell <name> "<message>"` does not. `groove who` lists who is reachable. '
176
+ + 'Your own built-in sub-agent/task tools CANNOT reach them.]';
177
+
178
+ const explicit = INNERCHAT_KEYWORD.test(message);
179
+ if (!explicit && !CONTACT_INTENT.test(message)) return base;
180
+
181
+ // Name the agent the user is actually pointing at, so the model has a
182
+ // runnable command rather than a template it has to fill in from memory.
183
+ const lower = message.toLowerCase();
184
+ const named = others.filter((a) => lower.includes(a.name.toLowerCase()));
185
+ const target = named.length === 1 ? named[0] : null;
186
+
187
+ const lines = [
188
+ '[REACHING ANOTHER AGENT — this capability is real and available right now.]',
189
+ ];
190
+ if (explicit) {
191
+ // The user named the feature. Say plainly that it exists, since the usual
192
+ // failure is the agent asserting it doesn't and stopping there.
193
+ lines.push(
194
+ 'The user explicitly asked you to use InnerChat. It exists, it is wired up, and the',
195
+ 'commands below work from your shell right now. Do not tell the user the feature is',
196
+ 'unavailable and do not ask them how to use it — run the command.',
197
+ '',
198
+ );
199
+ }
200
+ if (target) {
201
+ lines.push(
202
+ `To contact ${target.name}, run exactly:`,
203
+ ` groove ask ${target.name} "your question here"`,
204
+ 'That blocks until they answer and prints their reply. Use `groove tell` instead if you '
205
+ + 'do not need the answer before continuing.',
206
+ );
207
+ } else {
208
+ lines.push(
209
+ ' groove who — list who is reachable',
210
+ ' groove ask <name> "<question>" — blocks until they answer, prints the reply',
211
+ ' groove tell <name> "<message>" — returns immediately',
212
+ `Agents reachable now: ${others.map((a) => a.name).join(', ') || '(none)'}`,
213
+ );
214
+ }
215
+ if (peers.length) {
216
+ lines.push(`Agents on peer machines use name@peer (peers: ${peers.map((p) => p.alias).join(', ')}).`);
217
+ }
218
+ lines.push(
219
+ 'Do NOT use your built-in sub-agent/Task/SendMessage tools for this — they cannot see GROOVE '
220
+ + 'agents and will fail. If a name is wrong the command tells you the valid ones; read it and retry.',
221
+ );
222
+
223
+ // Explicit request → re-attach the full reference, so the agent has the
224
+ // complete semantics (blocking vs not, exchange budget, peer addressing)
225
+ // even if the spawn prompt scrolled away long ago.
226
+ if (explicit) {
227
+ lines.push(
228
+ '',
229
+ '--- Full reference (re-sent because you asked for InnerChat by name) ---',
230
+ ...innerChatInstructions(daemon.port || 31415, agent.name, peers),
231
+ );
232
+ }
233
+ return lines.join('\n');
234
+ }
@@ -21,14 +21,26 @@ export function innerChatInstructions(port = 31415, agentName = 'YOUR_NAME', pee
21
21
  '',
22
22
  'Other GROOVE agents may be working alongside you, including on other teams.',
23
23
  'When the user asks you to reach out to, coordinate with, or get input from',
24
- 'another agent, use this — it sends them a message and waits for their reply:',
24
+ 'another agent, use the `groove` CLI — it is already installed and on your PATH:',
25
25
  '',
26
- '> **Do NOT use your built-in `SendMessage` / Agent tools to reach a GROOVE agent.**',
27
- '> Those only address sub-agents you spawned yourself in this session, so they will',
28
- '> fail with "not reachable" or ask you for an `a…-…` agent ID that does not exist',
29
- '> here. GROOVE agents are separate processes. The curl below is the only way to',
30
- '> reach them. Do not invent a fallback (writing a message into a file, etc.) —',
31
- '> if the curl fails, read the error and report it to the user.',
26
+ '```bash',
27
+ 'groove who # who can I reach right now?',
28
+ 'groove ask <AGENT_NAME> "<QUESTION>" # send + WAIT for their answer',
29
+ 'groove tell <AGENT_NAME> "<MESSAGE>" # send without waiting',
30
+ '```',
31
+ '',
32
+ '`groove ask` prints their reply to stdout. It knows who you are from your',
33
+ 'environment, so there is no id or token to look up. If you get the name wrong,',
34
+ 'the error lists the valid names — read it and retry rather than giving up.',
35
+ '',
36
+ '> **Do NOT use your built-in `SendMessage` / Task / sub-agent tools to reach a**',
37
+ '> **GROOVE agent.** Those only address sub-agents you spawned yourself in this',
38
+ '> session, so they will fail with "not reachable" or ask you for an `a…-…` agent',
39
+ '> ID that does not exist here. GROOVE agents are separate processes. Do not invent',
40
+ '> a fallback (writing a message into a file, etc.) — if the command fails, read the',
41
+ '> error and report it to the user.',
42
+ '',
43
+ 'If the `groove` CLI is somehow unavailable, the same thing over HTTP:',
32
44
  '',
33
45
  '```bash',
34
46
  `curl -s http://localhost:${port}/api/innerchat/ask -X POST -H 'Content-Type: application/json' \\`,
@@ -54,6 +66,12 @@ export function innerChatInstructions(port = 31415, agentName = 'YOUR_NAME', pee
54
66
  'delivered back to you later, waking you if your turn has ended:',
55
67
  '',
56
68
  '```bash',
69
+ 'groove tell <AGENT_NAME> "<MESSAGE>"',
70
+ '```',
71
+ '',
72
+ 'Or over HTTP:',
73
+ '',
74
+ '```bash',
57
75
  `curl -s http://localhost:${port}/api/innerchat/tell -X POST -H 'Content-Type: application/json' \\`,
58
76
  ` -d '{"from":"${agentName}","to":"AGENT_NAME","message":"YOUR_MESSAGE"}'`,
59
77
  '```',