murmur-it 0.2.9 → 0.2.10
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/CHANGELOG.md +12 -1
- package/dist/broker.js +19 -5
- package/dist/core.js +10 -3
- package/dist/mcp.js +51 -12
- package/dist/protocol.js +4 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,16 @@ All notable changes to murmur are documented here. The format follows [Keep a Ch
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.2.10] - 2026-11-05
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Pushes reach sessions on another machine. In a remote hub home the MCP server registers with `listen: true` and hands each push and notice to its own session through `CLAUDE_CODE_MESSAGING_SOCKET`, which the hub cannot reach across machines; a push the socket took is confirmed with `delivered`. An idle session there now wakes on a message instead of waiting for its next prompt. Protocol: `register` takes `listen` for `mcp` and `adapter` connections, and a listening registration gets its queued push messages right away.
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- Sessions on another machine count as alive. A session counts as alive when its host process runs on the hub or when a live `mcp` or `adapter` connection from its host is open. Before, the hub looked only at its own process table, so a session on another machine showed as `presumed-offline` and two of them in folders with the same name could get the same handle.
|
|
16
|
+
|
|
7
17
|
## [0.2.9] - 2026-11-05
|
|
8
18
|
|
|
9
19
|
### Added
|
|
@@ -171,7 +181,8 @@ All notable changes to murmur are documented here. The format follows [Keep a Ch
|
|
|
171
181
|
- Limits: send rate, duplicate window, thread and inbox caps.
|
|
172
182
|
- 283 tests at 100 percent lines and branches, and an end-to-end rig that replayed the live 3-peer scenario.
|
|
173
183
|
|
|
174
|
-
[Unreleased]: https://github.com/rennf93/murmur/compare/v0.2.
|
|
184
|
+
[Unreleased]: https://github.com/rennf93/murmur/compare/v0.2.10...HEAD
|
|
185
|
+
[0.2.10]: https://github.com/rennf93/murmur/releases/tag/v0.2.10
|
|
175
186
|
[0.2.9]: https://github.com/rennf93/murmur/releases/tag/v0.2.9
|
|
176
187
|
[0.2.8]: https://github.com/rennf93/murmur/releases/tag/v0.2.8
|
|
177
188
|
[0.2.7]: https://github.com/rennf93/murmur/releases/tag/v0.2.7
|
package/dist/broker.js
CHANGED
|
@@ -6,7 +6,7 @@ import { fullOf } from './core.js';
|
|
|
6
6
|
import { nativeSend } from './native.js';
|
|
7
7
|
import { ProofWatcher } from './proof.js';
|
|
8
8
|
import { defaultWake } from './wake.js';
|
|
9
|
-
import { LineReader, MurmurError, NOTIFY_BATCH_MS, PROTOCOL_VERSION, THREADS_DEFAULT, THREADS_MAX, WAIT_MAX_MS, encodeLine, renderDelivery, replyFooter, } from './protocol.js';
|
|
9
|
+
import { LineReader, MurmurError, NOTIFY_BATCH_MS, PROTOCOL_VERSION, THREADS_DEFAULT, THREADS_MAX, WAIT_MAX_MS, encodeLine, noticeText, renderDelivery, replyFooter, } from './protocol.js';
|
|
10
10
|
const CLIENT_KINDS = ['mcp', 'cli', 'hook', 'adapter'];
|
|
11
11
|
const HOOK_EVENTS = ['session-start', 'prompt', 'stop', 'session-end'];
|
|
12
12
|
const CLI_NAMES = ['claude', 'codex', 'gemini', 'zcode', 'opencode', 'hummin', 'other'];
|
|
@@ -142,6 +142,7 @@ export class Broker {
|
|
|
142
142
|
this.nativeSendFn = opts.nativeSend ?? nativeSend;
|
|
143
143
|
this.wakeFn = opts.wake ?? defaultWake;
|
|
144
144
|
this.core.hasTools = (handle) => this.presence.has(handle);
|
|
145
|
+
this.core.hostConnected = (host) => [...this.conns].some((c) => c.live && c.host?.hostPid === host.hostPid && c.host.hostStart === host.hostStart);
|
|
145
146
|
this.proof = new ProofWatcher((messageId, recipient) => this.onProof(messageId, recipient), opts.proofPollMs);
|
|
146
147
|
}
|
|
147
148
|
static async start(opts) {
|
|
@@ -227,6 +228,7 @@ export class Broker {
|
|
|
227
228
|
live: false,
|
|
228
229
|
listening: false,
|
|
229
230
|
pendingHost: null,
|
|
231
|
+
host: null,
|
|
230
232
|
pendingBytes: 0,
|
|
231
233
|
waiters: new Set(),
|
|
232
234
|
chain: Promise.resolve(),
|
|
@@ -361,7 +363,7 @@ export class Broker {
|
|
|
361
363
|
case 'auth':
|
|
362
364
|
throw badRequest('connection is already authenticated');
|
|
363
365
|
case 'register':
|
|
364
|
-
this.replyOk(conn.socket, id, this.handleRegister(conn, rec));
|
|
366
|
+
this.replyOk(conn.socket, id, await this.handleRegister(conn, rec));
|
|
365
367
|
return;
|
|
366
368
|
case 'hook':
|
|
367
369
|
this.replyOk(conn.socket, id, this.handleHook(conn, rec));
|
|
@@ -427,7 +429,7 @@ export class Broker {
|
|
|
427
429
|
}
|
|
428
430
|
// Handlers.
|
|
429
431
|
// See RegisterMessage for the identity rules.
|
|
430
|
-
handleRegister(conn, rec) {
|
|
432
|
+
async handleRegister(conn, rec) {
|
|
431
433
|
const kind = reqEnum(rec, 'clientKind', CLIENT_KINDS);
|
|
432
434
|
const handle = optString(rec, 'handle');
|
|
433
435
|
const display = optString(rec, 'display');
|
|
@@ -440,6 +442,14 @@ export class Broker {
|
|
|
440
442
|
const live = kind === 'mcp' || kind === 'adapter';
|
|
441
443
|
let resolved;
|
|
442
444
|
conn.via = null;
|
|
445
|
+
// A rename registers again without these, so only a given value changes them.
|
|
446
|
+
const listen = optBool(rec, 'listen');
|
|
447
|
+
if (host !== undefined) {
|
|
448
|
+
conn.host = host;
|
|
449
|
+
}
|
|
450
|
+
if (live && listen !== undefined) {
|
|
451
|
+
conn.listening = listen;
|
|
452
|
+
}
|
|
443
453
|
if (owner) {
|
|
444
454
|
resolved = this.ownerHandle();
|
|
445
455
|
if (ancestors !== undefined) {
|
|
@@ -475,6 +485,10 @@ export class Broker {
|
|
|
475
485
|
}
|
|
476
486
|
this.bind(conn, resolved, live);
|
|
477
487
|
this.core.touchSeen(resolved);
|
|
488
|
+
if (live && listen === true) {
|
|
489
|
+
// A listener that comes (back) up gets what waited for it.
|
|
490
|
+
await this.pushQueued(resolved);
|
|
491
|
+
}
|
|
478
492
|
return { handle: resolved, owner: this.store.getPeer(resolved)?.isOwner === true };
|
|
479
493
|
}
|
|
480
494
|
ownerHandle() {
|
|
@@ -529,6 +543,7 @@ export class Broker {
|
|
|
529
543
|
this.rebind(before.handle, session.handle);
|
|
530
544
|
}
|
|
531
545
|
conn.listening = listen;
|
|
546
|
+
conn.host = host;
|
|
532
547
|
this.bind(conn, session.handle, listen);
|
|
533
548
|
// MCP servers of this session that registered before it announced itself.
|
|
534
549
|
for (const other of this.conns) {
|
|
@@ -916,8 +931,7 @@ export class Broker {
|
|
|
916
931
|
if (transport === null) {
|
|
917
932
|
return;
|
|
918
933
|
}
|
|
919
|
-
|
|
920
|
-
this.nativeSendFn(transport.socketPath, transport.token, text).catch(() => {
|
|
934
|
+
this.nativeSendFn(transport.socketPath, transport.token, noticeText(entry.payloads)).catch(() => {
|
|
921
935
|
// Notifications are best effort; the data stays in the DB.
|
|
922
936
|
});
|
|
923
937
|
}
|
package/dist/core.js
CHANGED
|
@@ -117,6 +117,10 @@ export class MurmurCore {
|
|
|
117
117
|
hookOverrides = new Map();
|
|
118
118
|
// Set by the broker: does the handle have a live mcp or adapter connection.
|
|
119
119
|
hasTools = () => false;
|
|
120
|
+
// Set by the broker: is a live mcp or adapter connection open from this
|
|
121
|
+
// host. A session on another machine has no process here to look up, so
|
|
122
|
+
// that connection is its liveness.
|
|
123
|
+
hostConnected = () => false;
|
|
120
124
|
// Process table source for session liveness, asked only for the pids that
|
|
121
125
|
// matter; injectable for tests.
|
|
122
126
|
procTable;
|
|
@@ -527,7 +531,7 @@ export class MurmurCore {
|
|
|
527
531
|
const hookState = override !== undefined ? override.state : normalizeHookState(peer.hookState);
|
|
528
532
|
const hookAt = override !== undefined ? override.at : peer.lastHookActivityAt;
|
|
529
533
|
const sessions = byHandle.get(peer.handle) ?? [];
|
|
530
|
-
const session = sessions.find((row) => row.state !== 'ended' &&
|
|
534
|
+
const session = sessions.find((row) => row.state !== 'ended' && this.alive(table, row));
|
|
531
535
|
let presence;
|
|
532
536
|
let busySince = null;
|
|
533
537
|
let idleSince = null;
|
|
@@ -734,7 +738,7 @@ export class MurmurCore {
|
|
|
734
738
|
.listSessions()
|
|
735
739
|
.filter((row) => row.state !== 'ended' && ancestors.includes(row.hostPid));
|
|
736
740
|
const table = this.safeProcTable(candidates.map((row) => row.hostPid));
|
|
737
|
-
const live = candidates.filter((row) =>
|
|
741
|
+
const live = candidates.filter((row) => this.alive(table, row));
|
|
738
742
|
for (const pid of ancestors) {
|
|
739
743
|
const match = live.find((row) => row.hostPid === pid);
|
|
740
744
|
if (match !== undefined) {
|
|
@@ -803,7 +807,7 @@ export class MurmurCore {
|
|
|
803
807
|
}
|
|
804
808
|
const holders = this.store.sessionsForHandle(handle).filter((r) => r.id !== exceptId && r.state !== 'ended');
|
|
805
809
|
const table = this.safeProcTable(holders.map((r) => r.hostPid));
|
|
806
|
-
return !holders.some((r) =>
|
|
810
|
+
return !holders.some((r) => this.alive(table, r));
|
|
807
811
|
}
|
|
808
812
|
// <client>-<cwd basename>, then -2, -3, ... until no live session holds
|
|
809
813
|
// it. A handle whose sessions are all gone is reused, so a restarted
|
|
@@ -817,6 +821,9 @@ export class MurmurCore {
|
|
|
817
821
|
}
|
|
818
822
|
return handle;
|
|
819
823
|
}
|
|
824
|
+
alive(table, row) {
|
|
825
|
+
return isAlive(table, row.hostPid, row.hostStart) || this.hostConnected(row);
|
|
826
|
+
}
|
|
820
827
|
safeProcTable(pids) {
|
|
821
828
|
try {
|
|
822
829
|
return this.procTable(pids);
|
package/dist/mcp.js
CHANGED
|
@@ -3,9 +3,10 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
3
3
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { connectBroker } from './client.js';
|
|
6
|
-
import { getPaths, readToken } from './config.js';
|
|
6
|
+
import { getPaths, isRemoteHome, readToken } from './config.js';
|
|
7
|
+
import { nativeSend } from './native.js';
|
|
7
8
|
import { currentHost } from './proc.js';
|
|
8
|
-
import { HANDLE_RE, MurmurError, WAIT_DEFAULT_MS, WAIT_MAX_MS } from './protocol.js';
|
|
9
|
+
import { HANDLE_RE, MurmurError, WAIT_DEFAULT_MS, WAIT_MAX_MS, noticeText } from './protocol.js';
|
|
9
10
|
// MCP stdio server exposing the murmur broker to agent sessions. Every tool
|
|
10
11
|
// maps to one broker request on a single long-lived connection, and that
|
|
11
12
|
// connection is the session's presence on the bus. Identity comes from the
|
|
@@ -196,22 +197,59 @@ export function buildMcpServer(client, identity = {}) {
|
|
|
196
197
|
});
|
|
197
198
|
return server;
|
|
198
199
|
}
|
|
200
|
+
// This session's own messaging socket, when the home is a remote hub home:
|
|
201
|
+
// the hub cannot reach a socket on this machine, so this server listens for
|
|
202
|
+
// pushes and hands them over itself. Null otherwise.
|
|
203
|
+
export function pushTarget(env, home) {
|
|
204
|
+
const socketPath = env.CLAUDE_CODE_MESSAGING_SOCKET;
|
|
205
|
+
const token = env.CLAUDE_CODE_MESSAGING_TOKEN;
|
|
206
|
+
if (!isRemoteHome(home) || !socketPath || !token) {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
return { socketPath, token };
|
|
210
|
+
}
|
|
211
|
+
// Hands one broker event to the session: a push through its messaging
|
|
212
|
+
// socket, confirmed as delivered once the socket took it (as an adapter
|
|
213
|
+
// confirms), or a notification batch as notice text.
|
|
214
|
+
// shortcut: a push the socket refuses stays sent (readable on the bus, never re-pushed), as with adapters; add a requeue message if refusals show up.
|
|
215
|
+
export async function deliverLocally(ev, target, client, send = nativeSend) {
|
|
216
|
+
if (ev.event === 'notification') {
|
|
217
|
+
await send(target.socketPath, target.token, noticeText(ev.payload));
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
if ((await send(target.socketPath, target.token, ev.payload.text)).ok) {
|
|
221
|
+
const msg = { type: 'delivered', ids: [ev.payload.message.id] };
|
|
222
|
+
await client.request(msg).catch(() => {
|
|
223
|
+
// The broker connection went away: the push stays sent and readable on the bus.
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
199
227
|
// Retries after the broker connection drops: a restart or an upgrade takes a
|
|
200
228
|
// moment, and the murmur bin starts a broker itself when none answers.
|
|
201
229
|
const RECONNECT_ATTEMPTS = 20;
|
|
202
230
|
const RECONNECT_DELAY_MS = 250;
|
|
203
|
-
async function connect(paths) {
|
|
204
|
-
|
|
231
|
+
async function connect(paths, target) {
|
|
232
|
+
if (target === null) {
|
|
233
|
+
return connectBroker({ socketPath: paths.socketPath, token: readToken(paths) });
|
|
234
|
+
}
|
|
235
|
+
const client = await connectBroker({
|
|
236
|
+
socketPath: paths.socketPath,
|
|
237
|
+
token: readToken(paths),
|
|
238
|
+
onEvent: (ev) => {
|
|
239
|
+
void deliverLocally(ev, target, client);
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
return client;
|
|
205
243
|
}
|
|
206
244
|
// MURMUR_HANDLE is an optional per-process override; anything invalid
|
|
207
245
|
// (like an old CHANGE-ME placeholder) or already taken is ignored so the
|
|
208
246
|
// server still registers under its session's own handle.
|
|
209
|
-
async function register(client, identity) {
|
|
247
|
+
async function register(client, identity, listen) {
|
|
210
248
|
const explicit = process.env.MURMUR_HANDLE;
|
|
211
249
|
const wanted = explicit !== undefined && HANDLE_RE.test(explicit) ? explicit : undefined;
|
|
212
250
|
const base = identity.host === undefined
|
|
213
251
|
? { type: 'register', handle: wanted ?? 'anon-' + String(process.pid), clientKind: 'mcp' }
|
|
214
|
-
: { ...identity, type: 'register', clientKind: 'mcp' };
|
|
252
|
+
: { ...identity, type: 'register', clientKind: 'mcp', ...(listen ? { listen } : {}) };
|
|
215
253
|
try {
|
|
216
254
|
await client.request(wanted !== undefined && identity.host !== undefined ? { ...base, handle: wanted } : base);
|
|
217
255
|
}
|
|
@@ -225,7 +263,7 @@ async function register(client, identity) {
|
|
|
225
263
|
// A new registered connection for the same session, or null when no broker
|
|
226
264
|
// answered within the attempts or the server is going away meanwhile (a try
|
|
227
265
|
// may start a broker, which a session that is gone must not do).
|
|
228
|
-
async function reconnect(paths, identity, stopping) {
|
|
266
|
+
async function reconnect(paths, identity, target, stopping) {
|
|
229
267
|
for (let attempt = 0; attempt < RECONNECT_ATTEMPTS; attempt += 1) {
|
|
230
268
|
await new Promise((resolve) => setTimeout(resolve, RECONNECT_DELAY_MS));
|
|
231
269
|
if (stopping()) {
|
|
@@ -233,8 +271,8 @@ async function reconnect(paths, identity, stopping) {
|
|
|
233
271
|
}
|
|
234
272
|
let client;
|
|
235
273
|
try {
|
|
236
|
-
client = await connect(paths);
|
|
237
|
-
await register(client, identity);
|
|
274
|
+
client = await connect(paths, target);
|
|
275
|
+
await register(client, identity, target !== null);
|
|
238
276
|
return client;
|
|
239
277
|
}
|
|
240
278
|
catch {
|
|
@@ -246,9 +284,10 @@ async function reconnect(paths, identity, stopping) {
|
|
|
246
284
|
export async function runMcpServer(stdin = process.stdin) {
|
|
247
285
|
const paths = getPaths();
|
|
248
286
|
const identity = identityFor(currentHost(undefined, false), process.env, process.cwd());
|
|
287
|
+
const target = pushTarget(process.env, paths.home);
|
|
249
288
|
let client;
|
|
250
289
|
try {
|
|
251
|
-
client = await connect(paths);
|
|
290
|
+
client = await connect(paths, target);
|
|
252
291
|
}
|
|
253
292
|
catch (err) {
|
|
254
293
|
const code = err instanceof MurmurError ? err.code : 'internal';
|
|
@@ -256,7 +295,7 @@ export async function runMcpServer(stdin = process.stdin) {
|
|
|
256
295
|
process.exit(1);
|
|
257
296
|
}
|
|
258
297
|
try {
|
|
259
|
-
await register(client, identity);
|
|
298
|
+
await register(client, identity, target !== null);
|
|
260
299
|
}
|
|
261
300
|
catch (err) {
|
|
262
301
|
const code = err instanceof MurmurError ? err.code : 'internal';
|
|
@@ -294,7 +333,7 @@ export async function runMcpServer(stdin = process.stdin) {
|
|
|
294
333
|
client.onClosed = resolve;
|
|
295
334
|
}),
|
|
296
335
|
]);
|
|
297
|
-
next = stopping ? null : await reconnect(paths, identity, () => stopping);
|
|
336
|
+
next = stopping ? null : await reconnect(paths, identity, target, () => stopping);
|
|
298
337
|
}
|
|
299
338
|
client.close();
|
|
300
339
|
}
|
package/dist/protocol.js
CHANGED
|
@@ -17,6 +17,10 @@ export const HANDLE_RE = /^[a-z0-9][a-z0-9-]{1,47}$/;
|
|
|
17
17
|
export const PROOF_POLL_MS = 120000;
|
|
18
18
|
export const THREADS_DEFAULT = 10;
|
|
19
19
|
export const THREADS_MAX = 50;
|
|
20
|
+
// A notification batch as the plain text a session reads.
|
|
21
|
+
export function noticeText(payloads) {
|
|
22
|
+
return '[murmur notice] ' + payloads.map((p) => p.detail).join('; ');
|
|
23
|
+
}
|
|
20
24
|
export class MurmurError extends Error {
|
|
21
25
|
code;
|
|
22
26
|
constructor(code, message) {
|