-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
1322 lines (1224 loc) · 60.6 KB
/
Copy pathserver.js
File metadata and controls
1322 lines (1224 loc) · 60.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env node
'use strict';
// Subcommand dispatch: CLI subcommands run the installer/launcher, not the
// MCP server. (When Claude Code spawns the server there is no subcommand, so
// argv[2] is undefined and this falls through to the MCP server below.)
if (['init', 'doctor', 'start'].includes(process.argv[2])) {
require('./bin/install.js');
return;
}
// ── stdout discipline (v0.3.9) ──────────────────────────────────────────────
// MCP frames JSON-RPC on stdout. Any non-JSON write there — ours or, far more
// often, a dependency's load banner (e.g. "[encoder] Semantic encoder ready"
// from the semantic model) — corrupts the stream and makes Claude Code drop the
// connection (-32000) or log "Ignoring non-JSON line on stdout". Guard it: lines
// that look like JSON-RPC (start with '{') pass through to the real stdout;
// everything else is redirected to stderr. Installed before any require so it
// catches dependency output at load time.
const __realStdoutWrite = process.stdout.write.bind(process.stdout);
process.stdout.write = function (chunk, ...rest) {
try {
const s = typeof chunk === 'string' ? chunk : chunk.toString('utf8');
if (s.trimStart().startsWith('{')) return __realStdoutWrite(chunk, ...rest);
return process.stderr.write(chunk, ...rest);
} catch {
return __realStdoutWrite(chunk, ...rest);
}
};
/**
* sym-mesh-channel — MCP server that makes Claude Code a peer node on the SYM mesh.
*
* Architecture (MMP Section 13.9: Local Event Interface):
* SymNode (own identity, own SVAF field weights) → relay → mesh
* MCP channel notifications → Claude Code (real-time push)
* MCP tools → SymNode methods (send, publish, recall)
*
* This is a PEER NODE, not a client of the daemon. It has its own identity,
* its own relay connection, and its own SVAF evaluation with engineering-domain
* field weights. Per MMP Section 3: every participant is a peer.
*
* Copyright (c) 2026 SYM.BOT. Apache 2.0 License.
*/
const { Server } = require('@modelcontextprotocol/sdk/server/index.js');
const { StdioServerTransport } = require('@modelcontextprotocol/sdk/server/stdio.js');
const {
CallToolRequestSchema,
ListToolsRequestSchema,
} = require('@modelcontextprotocol/sdk/types.js');
const { SymNode } = require('@sym-bot/sym');
const { scanClassifierRisk, quarantineHeader } = require('./classifier-risk.js');
const { resolveIdentity } = require('./identity.js');
// Kebab-case validator shared by group-related tools.
const KEBAB_CASE_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
// ── Invite URL parsing (shared by sym_invite_info and the internal
// validation path for sym_join_group when passed a URL). Exposed as
// a module-level function so it's trivially unit-testable and the
// same regex doesn't drift between two call sites.
const INVITE_URL_RE = /^([a-z][a-z0-9-]+):\/\/(?:room|group|team)\/([^/?#]+)(?:\/([^?#]+))?(?:\?(.+))?$/i;
function parseInviteURL(url) {
const m = INVITE_URL_RE.exec(url);
if (!m) {
return {
error:
`Unrecognised invite URL: ${url}\n\n` +
`Expected shapes:\n` +
` sym://group/{name} (LAN-only)\n` +
` sym://team/{name}?relay=...&token=... (cross-network via relay)\n` +
` melotune://room/{id}/{name} (app-specific room)`,
};
}
const appScheme = m[1].toLowerCase();
const rawId = decodeURIComponent(m[2]);
const rawName = m[3] ? decodeURIComponent(m[3]) : rawId;
const queryStr = m[4] || '';
const query = Object.fromEntries(
queryStr.split('&').filter(Boolean).map(kv => {
const [k, v = ''] = kv.split('=');
return [decodeURIComponent(k), decodeURIComponent(v)];
})
);
// For sym:// the path element IS the group name. For app-scoped URLs
// (melotune://, melomove://, etc.) the path is the room id and the
// group is prefixed with the app name to avoid collisions.
const serviceType = appScheme === 'sym' ? `_${rawId}._tcp` : `_${appScheme}-${rawId}._tcp`;
const group = appScheme === 'sym' ? rawId : `${appScheme}-${rawId}`;
return {
appScheme,
group,
serviceType,
roomId: rawId,
roomName: rawName,
relayUrl: query.relay || null,
relayToken: query.token || null,
};
}
// ── Bonjour discovery of live SYM-related service types.
// Runs `dns-sd -B _services._dns-sd._udp local.` (macOS / Windows with
// Bonjour) or `avahi-browse -at` (Linux) for 2 seconds, filters to
// service types that look SYM-ish, and reports them. Pure observation,
// no node state changes.
async function discoverGroups() {
const { spawn } = require('child_process');
const platform = process.platform;
let cmd, argv;
if (platform === 'darwin' || platform === 'win32') {
cmd = 'dns-sd';
argv = ['-B', '_services._dns-sd._udp', 'local.'];
} else {
cmd = 'avahi-browse';
argv = ['-t', '-a', '-p']; // terminate after cache, all services, parseable
}
return new Promise((resolve) => {
let child;
try {
child = spawn(cmd, argv, { stdio: ['ignore', 'pipe', 'pipe'] });
} catch (e) {
return resolve({
isError: true,
text:
`Could not run discovery command '${cmd}': ${e?.message || e}\n\n` +
(platform === 'linux'
? `On Linux, install avahi-utils: sudo apt install avahi-utils`
: `Bonjour should be built-in on macOS and Windows 10+.`),
});
}
const out = [];
child.stdout.on('data', (chunk) => out.push(chunk));
child.on('error', (e) => resolve({ isError: true, text: `Discovery command failed: ${e?.message || e}` }));
const timer = setTimeout(() => {
try { child.kill('SIGTERM'); } catch {}
}, 2000);
child.on('close', () => {
clearTimeout(timer);
const text = Buffer.concat(out).toString('utf8');
const typeRe = /_([a-z0-9][a-z0-9-]+)\._tcp/gi;
const seen = new Set();
let m;
while ((m = typeRe.exec(text)) !== null) {
const full = `_${m[1]}._tcp`;
// Filter to the SYM protocol family: global sym, named groups, and
// app-scoped rooms (melotune-<id>, melomove-<id>, etc). Anything
// that looks like generic infra (_services._dns-sd, _tcp, _udp,
// printer protocols, etc.) is ignored.
if (/^_(sym|[a-z]+-[a-z0-9]+|[a-z]+-team|.*-team)\._tcp$/i.test(full)) {
seen.add(full);
}
}
if (seen.size === 0) {
return resolve({
text:
`No SYM-mesh groups visible on the local network right now.\n\n` +
`This only shows groups with at least one node currently online. ` +
`Groups you or teammates have used before are not persisted anywhere ` +
`(p2p architecture — no central directory).\n\n` +
`Your node is on: ${SERVICE_TYPE} (group "${GROUP}").`,
});
}
const lines = [];
lines.push(`SYM-mesh groups visible on LAN (${seen.size}):`);
for (const st of Array.from(seen).sort()) {
const name = st.replace(/^_/, '').replace(/\._tcp$/, '');
const isSelf = st === SERVICE_TYPE ? ' (← your current group)' : '';
lines.push(` ${st} group="${name}"${isSelf}`);
}
lines.push('');
lines.push(`To join one, call sym_join_group with group="<name>".`);
resolve({ text: lines.join('\n') });
});
});
}
// ── Engineering-domain field weights (SVAF α_f) ──────────────
const FIELD_WEIGHTS = {
focus: 2.0, // code, architecture, technical decisions
issue: 2.0, // bugs, blockers, technical debt
intent: 1.5, // what needs building
motivation: 1.0, // why it matters
commitment: 1.5, // deadlines, dependencies
perspective: 0.5, // viewpoint — low for engineering
mood: 0.8, // user fatigue affects code quality
};
// ── SymNode — full peer on the mesh ──────────────────────────
// Default: hostname-based identity, unique per machine. The old default
// ('claude-code-mac') caused ghost-peer bugs when another machine ran
// without SYM_NODE_NAME set — both machines claimed the same name with
// different nodeIds, creating phantom peers that absorbed messages.
// Per-session default (v0.3.8): keep co-resident Claude Code sessions from all
// claiming one shared identity and colliding on the identity lock. Each Claude
// Code session exposes CLAUDE_CODE_SESSION_ID (stable across `--resume`) and
// CLAUDE_PROJECT_DIR, so the default becomes `claude-<repo>-<session6>` —
// unique even for two sessions in the same repo, readable, and stable across
// resume. Bare-npm use (no session id) keeps the hostname default. Named agents
// override with SYM_NODE_NAME (e.g. claude-code-mac, melotune-dev).
function defaultNodeName() {
const clean = (s) => String(s || '').toLowerCase().replace(/[^a-z0-9-]/g, '-').replace(/^-+|-+$/g, '');
const sid = clean(process.env.CLAUDE_CODE_SESSION_ID).slice(0, 6);
if (sid) {
const repo = clean(require('path').basename(process.env.CLAUDE_PROJECT_DIR || process.cwd())) || 'session';
return `claude-${repo}-${sid}`;
}
return `claude-${clean(require('os').hostname())}`;
}
// Node-name collision handling is delegated to the engine (see identity.js). The old plugin-side
// resolver checked liveness with a bare `process.kill(pid, 0)`, which can't distinguish a live
// holder from a recycled PID, so a stale lock could force a -2/-3 suffix and a fresh identity.
// Removed; identity resolution now goes through resolveIdentity + the engine's robust check.
// Per-project identity (v0.3.22): a named role agent (CTO, melotune-dev, …) commits
// its node name + group to `$CLAUDE_PROJECT_DIR/.sym/node.json`, so the plugin alone
// carries a stable per-project identity — no parallel MCP registration, and it
// survives a plugin reinstall because the config lives in the repo, not the plugin.
// Env (SYM_NODE_NAME/SYM_GROUP) still wins; this only overrides the auto default.
// Missing/malformed file → {} → auto default; never a hard fail.
function projectNodeConfig() {
const fs = require('fs'), path = require('path');
const dir = process.env.CLAUDE_PROJECT_DIR || process.cwd();
try {
const cfg = JSON.parse(fs.readFileSync(path.join(dir, '.sym', 'node.json'), 'utf8'));
const clean = (s) => (typeof s === 'string' && s.trim()) ? s.trim() : undefined;
return { node_name: clean(cfg.node_name), group: clean(cfg.group) };
} catch { return {}; }
}
const PROJECT_CFG = projectNodeConfig();
const { name: NODE_NAME, autoSuffix: NODE_AUTOSUFFIX } = resolveIdentity({
pinnedName: process.env.SYM_NODE_NAME || PROJECT_CFG.node_name,
defaultName: defaultNodeName(),
});
// ── Mesh group (MMP §5.8) ──────────────────────────────────
//
// LAN isolation by Bonjour service type. `_sym._tcp` is the default
// (backward compatible). A named group `<foo>` maps to service type
// `_foo._tcp`. Passing a full `_foo._tcp` service type explicitly also
// works. Nodes in different groups never discover each other at mDNS.
// See MeloTune's MoodRoom model for the per-room pattern
// (`_melotune-{id}._tcp`).
function resolveServiceType() {
const explicit = process.env.SYM_SERVICE_TYPE;
if (explicit) return explicit;
const group = process.env.SYM_GROUP || PROJECT_CFG.group;
if (group && group !== 'default') return `_${group}._tcp`;
return '_sym._tcp';
}
// Mutable so sym_join_group can hot-swap the node at runtime without a
// Claude Code restart. Declaring as `let` rather than `const` is the
// smallest change that makes hot-swap possible.
let SERVICE_TYPE = resolveServiceType();
let GROUP = process.env.SYM_GROUP || PROJECT_CFG.group || (SERVICE_TYPE !== '_sym._tcp'
? SERVICE_TYPE.replace(/^_/, '').replace(/\._tcp$/, '')
: 'default');
let RELAY_URL = process.env.SYM_RELAY_URL || null;
let RELAY_TOKEN = process.env.SYM_RELAY_TOKEN || null;
let node = new SymNode({
name: NODE_NAME,
autoSuffix: NODE_AUTOSUFFIX, // engine handles collision (start-time-verified); off for pinned names
cognitiveProfile: 'Engineering node. Code, architecture, debugging, technical decisions.',
svafFieldWeights: FIELD_WEIGHTS,
svafFreshnessSeconds: 7200, // 2hr — session-length context
discoveryServiceType: SERVICE_TYPE,
group: GROUP,
relay: RELAY_URL,
relayToken: RELAY_TOKEN,
silent: true,
});
// ── Send-path delivery integrity (E8 variant c) ──────────────────────────────
// SymNode.remember() dedups on the content hash of the CAT7 fields, returning null
// when identical fields are already in the LOCAL store — and the send/publish
// handlers reported that null as "Duplicate — not re-broadcast". But a local-store
// hit is NOT proof of delivery: a CMB stored while this node had no connected peer,
// or on a prior send before a reconnect, blocks its own identical re-send forever,
// so an explicit operator send silently never reaches the mesh (root-caused
// 2026-07-18; same fail-loudly family as the 0.3.39 unknown-param fix). We record
// which CMB keys were actually delivered to a connected destination: a dedup
// against a NEVER-DELIVERED key is re-issued (disambiguated with the same salt the
// commission loop uses) so the send goes out, while a dedup against an
// already-delivered key stays suppressed — no flood regression. The delivered set
// is channel-internal, so it uses its own stable content hash, not the store's key.
const crypto = require('crypto');
// ── input hygiene (0.3.39) — silent semantic drops must fail loudly ──────────────
// Root-caused 2026-07-18: minds habitually call sym_publish/sym_send with a single
// `content` param; the schema tolerated it as an unknown property and DROPPED it,
// producing constant all-default fields whose hash collides — every call after the
// first answered "Duplicate" while the mind's actual content never reached the mesh.
// Two rails: `content` maps to `focus` (the semantic repair — the habitual call now
// carries meaning), and any OTHER unknown top-level param is a loud error.
function vetCmbArgs(args, extraKeys) {
const known = new Set(['focus', 'issue', 'intent', 'motivation', 'commitment', 'perspective', 'mood', 'payload', 'content', ...extraKeys]);
const unknown = Object.keys(args || {}).filter(k => !known.has(k));
if (unknown.length) {
return `Unknown parameter(s): ${unknown.join(', ')}. Allowed: ${[...known].join(', ')}. Nothing was published — fix the call (a dropped param is a dropped meaning).`;
}
if (args && args.content && !args.focus) args.focus = String(args.content);
return null;
}
let deliveredCmbKeys = new Set(); // reset on hot-swap (sym_join_group)
function cmbContentKey(fields) {
return crypto.createHash('sha256').update(JSON.stringify(fields)).digest('hex').slice(0, 32);
}
// Directed deliveries are tagged per (contentKey, target) so identical content can
// still be delivered to a different peer; broadcasts are tagged by content key only.
function deliveryTag(fields, targetPeerId) {
return targetPeerId ? `${cmbContentKey(fields)}|${targetPeerId}` : cmbContentKey(fields);
}
function connectedPeerCount(n) {
try { const s = n.status && n.status(); return (s && s.peerCount) || (n.peers && n.peers().length) || 0; }
catch { return 0; }
}
// An explicit operator send (sym_send / sym_publish): remember() the CMB, but treat
// a content-dedup miss as "already delivered" ONLY when we actually delivered this
// key to a connected destination before. A dedup against a never-delivered key
// (stored while disconnected, or before a reconnect) is re-issued with a
// disambiguating salt so the operator's send reaches the mesh. okSummary(entry,
// connected) builds the happy-path text so each caller keeps its verb; `now` is
// injectable for deterministic tests. Returns { text, isError? }.
function explicitSend(n, delivered, fields, sendOpts, okSummary, now) {
const stamp = now || (() => new Date().toISOString());
const targetPeerId = sendOpts.to || null;
// A directed send resolved its target from the connected-peer list already, so its
// target is connected by construction; a broadcast reaches someone only if a peer
// is connected to receive the fanned-out frame.
const connected = targetPeerId ? true : connectedPeerCount(n) > 0;
const entry = n.remember(fields, sendOpts);
if (entry) {
if (connected) delivered.add(deliveryTag(fields, targetPeerId));
return { text: okSummary(entry, connected) };
}
if (delivered.has(deliveryTag(fields, targetPeerId))) {
return { text: `Duplicate — identical CMB already delivered${targetPeerId ? '' : ' to the group'}, not re-broadcast.` };
}
const salted = Object.assign({}, fields, { focus: `${fields.focus} [re-sent ${stamp()}]` });
const retry = n.remember(salted, sendOpts);
if (!retry) {
return { text: 'Send failed: the prior copy was undelivered and the disambiguated re-send did not store (persist error). Nothing broadcast.', isError: true };
}
if (connected) delivered.add(deliveryTag(salted, targetPeerId));
return { text: `Re-sent CMB ${retry.key}${targetPeerId ? '' : ' to the group'} — a prior identical copy was in the local store but had never been delivered; content-addressed dedup would otherwise have silently suppressed this send.` };
}
// Event handlers are extracted into a single registration function so the
// hot-swap path in sym_join_group can re-register them on the new node.
// The function reads module-level `NODE_NAME`, `isPeerAllowed`, `pushChannel`,
// `storeMessage`, and `extractCompactHeader` via closure; those don't change
// across swaps.
function registerNodeHandlers(n) {
// Identity collision (added in @sym-bot/sym 0.3.68): the relay told us
// another process is holding our nodeId. Don't try to reconnect — that
// caused the peer-flap loop documented in v0.1.2/v0.1.3 commit messages.
// Exit so Claude Code can decide whether to respawn (with the freshness
// window now elapsed) or surface the failure to the user.
n.on('identity-collision', (info) => {
process.stderr.write(
`sym-mesh-channel: identity collision on relay — another process is holding ` +
`nodeId=${info.nodeId} name=${info.name}. Exiting.\n`
);
process.exit(2);
});
n.on('cmb-accepted', (entry) => {
if (entry.source === NODE_NAME || entry.cmb?.createdBy === NODE_NAME) return;
const source = entry.source || entry.cmb?.createdBy || 'unknown';
if (!isPeerAllowed(source)) return;
const fields = entry.cmb?.fields || {};
const payload = entry.cmb?.payload;
const sec = checkSecurity(source, fields, payload);
if (!sec.safe) { securityAudit(sec.reason, source, sec.excerpt); return; }
const focus = fields?.focus?.text || entry.content || '';
const mood = fields?.mood?.text || '';
const moodSuffix = mood && mood !== 'neutral' ? ` (mood: ${mood})` : '';
// Store the rendered CMB body so the agent can sym_fetch it by [mNNN] ID.
// When the CMB carries an opaque payload alongside CAT7 fields, append a
// PAYLOAD section to the stored body so sym_fetch returns it intact;
// header gains a [+payload Nb] indicator so the receiver knows there's
// structured data beyond CAT7 and should sym_fetch to consume it.
const hasPayload = payload !== undefined && payload !== null;
let body = entry.content || focus;
let payloadSuffix = '';
if (hasPayload) {
const serialized = (() => {
try { return JSON.stringify(payload, null, 2); }
catch { return String(payload); }
})();
body = `${body}\n\n---PAYLOAD---\n${serialized}`;
payloadSuffix = ` [+payload ${serialized.length}b]`;
}
// Directed (peer-bound) delivery indicator (MMP §9.2.2). A directed CMB was
// addressed to THIS node — surface it as sent-to-you so the agent knows to
// respond. `remixed:false` means SVAF delivered it but did not ingest it
// into memory (transient request, not stored) — flag it so the agent does
// not assume it is recallable later.
const dirTag = entry.directed ? ' →you' : '';
const memTag = entry.directed && entry.remixed === false ? ' ·not-stored' : '';
// Classifier-risk guard (2026-07-24): checkSecurity cleared this CMB of injection, but a benign
// CMB whose wording is offensive-security/policy-adjacent can still wedge OUR model the instant
// its text is auto-surfaced. Scan what we're about to surface; if flagged, quarantine — auto-push
// metadata only (quarantineHeader carries no peer free-text), keep the verbatim body stored for a
// deliberate sym_fetch. Guarantee is in NOT auto-surfacing, not in guessing the classifier.
const risk = scanClassifierRisk(`${focus}\n${body}`);
let header;
if (risk.risky) {
securityAudit(`classifier-risk:${risk.terms.join(',')}`, source, focus);
header = quarantineHeader(source, dirTag, risk.terms.length, `${memTag}${payloadSuffix}`);
} else {
header = `[${source}${dirTag}] ${focus}${moodSuffix}${memTag}${payloadSuffix}`;
}
const msgId = storeMessage(source, body, header);
pushChannel('cmb', `${header} [${msgId}]`);
});
n.on('message', (from, content) => {
if (!isPeerAllowed(from)) return;
const sec = checkSecurity(from, { focus: { text: content } }, null);
if (!sec.safe) { securityAudit(sec.reason, from, sec.excerpt); return; }
// Same classifier-risk quarantine as cmb-accepted, for legacy direct messages.
const risk = scanClassifierRisk(content);
let header;
if (risk.risky) {
securityAudit(`classifier-risk:${risk.terms.join(',')}`, from, content.slice(0, 120));
header = quarantineHeader(from, '', risk.terms.length, '');
} else {
header = `[${from}] ${extractCompactHeader(from, content)}`;
}
const msgId = storeMessage(from, content, header);
pushChannel('message', `${header} [${msgId}]`);
});
}
// ── MCP Server ───────────────────────────────────────────────
// Base instructions shown to the agent at every MCP initialize.
const BASE_INSTRUCTIONS =
`You are a peer node on the SYM mesh (identity: ${NODE_NAME}). ` +
'The mesh is publish-subscribe: peers deliver CMBs to you in real-time the instant they publish, as <channel> notifications. That real-time push can be gated by Claude Code policy, so call sym_receive to surface any deliveries the push did not bring into your context (directed sym_send + admitted broadcasts) — a live delivery feed, not a memory query. Call sym_receive at the start of your turn and periodically while coordinating with peers, so no delivery is missed. ' +
'When you receive a CMB from another node, respond via sym_send targeted at that node by name if the reply is for that specific peer (MMP §4.4.4 targeted CMB). ' +
'Publish a CMB to your whole group via sym_publish — a projection of your own state (MMP §9.2 receiver-autonomous SVAF evaluation). ' +
'Both sym_send and sym_publish emit a CAT7 CMB (your projection); each receiver runs SVAF and, if it admits the CMB as an observation, remix-stores it with lineage back to yours. ' +
'Search mesh memory via sym_recall. ' +
'sym_receive and <channel> notifications give compact headers with [mNNN] IDs — use sym_fetch to read the full content when relevant to your current task.';
// Final startup step (MMP §4.2 O2 — rejoin-without-replay). The SymNode
// constructor builds the memory-store index from disk, so the primer is
// available synchronously without needing node.start(). Appending it to
// the MCP instructions payload means a fresh Claude Code session wakes
// with prior remix memory — own observations plus peer observations
// admitted by SVAF — already loaded into context, zero first-turn
// sym_recall overhead.
//
// MCP SDK reads `instructions` at Server construction time (storing it in
// a private field) and emits it only on initialize-response; mutations on
// the public property after construction are ignored. Compute once, pass in.
let primerText = '';
try {
const primer = node.buildStartupPrimer();
if (primer && primer.count > 0) primerText = `\n\n${primer.text}`;
} catch (err) {
process.stderr.write(`sym-mesh-channel startup primer skipped: ${err?.message || err}\n`);
}
const mcp = new Server(
{ name: 'sym-mesh', version: '0.1.0' },
{
capabilities: {
tools: {},
experimental: { 'claude/channel': {} },
},
instructions: BASE_INSTRUCTIONS + primerText,
},
);
// ── Tools ────────────────────────────────────────────────────
mcp.setRequestHandler(ListToolsRequestSchema, async () => ({
tools: [
{
name: 'sym_send',
description:
'Send a structured CAT7 CMB to a specific mesh peer (targeted) or to all peers (broadcast, when "to" is omitted). ' +
'Receivers evaluate the CMB per-field via SVAF (MMP §9.2) and, if admitted, remix-store it with lineage pointing back to this CMB. ' +
'Use sym_send when the CMB is for a specific peer (e.g. a peer-review gating request directed at the reviewer role); ' +
'use sym_publish when publishing your own state to the whole group.',
inputSchema: {
type: 'object',
properties: {
focus: { type: 'string', description: 'The task anchor / what this CMB is about. Required.' },
issue: { type: 'string' },
intent: { type: 'string' },
motivation: { type: 'string' },
commitment: { type: 'string' },
perspective: { type: 'string' },
mood: {
type: 'object',
properties: {
text: { type: 'string' },
valence: { type: 'number' },
arousal: { type: 'number' },
},
},
to: {
type: 'string',
description:
'Target peer: either the peer display name (e.g. "claude-research-win") or the full nodeId. ' +
'Call sym_peers first if unsure which peers are connected. Omit to broadcast to all peers.',
},
payload: {
description:
'Optional opaque payload riding alongside CAT7 fields. Use when carrying data beyond ' +
'CAT7 — e.g. an LLM request/response substrate protocol puts the prompt + request_id ' +
'in `payload` rather than smuggling JSON through `motivation` (which is reserved for ' +
'CAT7 semantics). Receivers see the payload via sym_fetch on the channel notification. ' +
'Any JSON-serializable value.',
},
},
required: ['focus'],
},
},
{
name: 'sym_publish',
description:
'Publish a structured CAT7 CMB — a projection of your own state — to all peers in your group. ' +
'Each receiver runs SVAF (MMP §9.2) and, if it admits the CMB as an observation, remix-stores it with lineage. ' +
'Equivalent to sym_send with "to" omitted — kept as a separate tool because publishing your own state is the common case and does not need peer selection.',
inputSchema: {
type: 'object',
properties: {
focus: { type: 'string' },
issue: { type: 'string' },
intent: { type: 'string' },
motivation: { type: 'string' },
commitment: { type: 'string' },
perspective: { type: 'string' },
mood: {
type: 'object',
properties: {
text: { type: 'string' },
valence: { type: 'number' },
arousal: { type: 'number' },
},
},
payload: {
description:
'Optional opaque payload riding alongside CAT7 fields. Use when broadcasting data ' +
'beyond CAT7 (e.g. llm-capability-advertise carrying served_capabilities). ' +
'Any JSON-serializable value.',
},
},
required: ['focus'],
},
},
{
name: 'sym_recall',
description: 'Search mesh memory for relevant CMBs.',
inputSchema: {
type: 'object',
properties: { query: { type: 'string', description: 'Search query (empty for all)' } },
required: ['query'],
},
},
{
name: 'sym_peers',
description: 'List connected mesh peers.',
inputSchema: { type: 'object', properties: {} },
},
{
name: 'sym_status',
description: 'Get mesh node status — relay connection, peer count, memory count.',
inputSchema: { type: 'object', properties: {} },
},
{
name: 'sym_fetch',
description: 'Fetch full content of a mesh message by ID. Use when a compact channel notification needs deeper reading.',
inputSchema: {
type: 'object',
properties: { msg_id: { type: 'string', description: 'Message ID (e.g., m007)' } },
required: ['msg_id'],
},
},
{
name: 'sym_receive',
description: 'Surface the CMBs the mesh has delivered to you in real-time — directed sym_send addressed to you, plus admitted broadcasts published to your group. The mesh is publish-subscribe: peers deliver the instant they publish, pushed as <channel> notifications. Because that push can be gated by Claude Code policy, sym_receive surfaces any deliveries it missed so none is lost — a live delivery feed, NOT a store query (use sym_recall to search stored memory). Call it at the start of a turn and periodically while coordinating so no delivery is missed. Returns compact headers with [mNNN] IDs (newest last); use sym_fetch for full content, reply via sym_send.',
inputSchema: {
type: 'object',
properties: {
peek: { type: 'boolean', description: 'If true, do not advance the read cursor (same items return next call). Default false — draining.' },
limit: { type: 'number', description: 'Max messages to return (default 50, newest last).' },
},
},
},
{
name: 'sym_group_info',
description: 'Report the mesh group this node is in (MMP §5.8). Shows service type + group name + peer count.',
inputSchema: { type: 'object', properties: {} },
},
{
name: 'sym_invite_create',
description: 'Generate a shareable invite URL for a named mesh group. Team leads use this to let teammates join their dev-team mesh. LAN-only invite: pass group only, returns sym://group/{name}. Cross-network invite: pass relay_url + relay_token too, returns sym://team/{name}?relay=...&token=... — teammates on different networks join through the relay.',
inputSchema: {
type: 'object',
properties: {
group: { type: 'string', description: 'Kebab-case group name, e.g. "backend-team".' },
relay_url: { type: 'string', description: 'Optional WebSocket relay URL, e.g. wss://sym-relay.onrender.com. Include for cross-network teams.' },
relay_token: { type: 'string', description: 'Optional relay authentication token (shared secret for this team channel).' },
},
required: ['group'],
},
},
{
name: 'sym_invite_info',
description: 'Parse a mesh invite URL and return everything the invitee needs to join: group name, service type, and any relay credentials. Read-only; does NOT switch the current node (use sym_join_group for that). Works on LAN group invites (sym://group/{name}), cross-network team invites (sym://team/{name}?relay=&token=), and app-specific room invites (e.g. melotune://room/{id}/{name}).',
inputSchema: {
type: 'object',
properties: { url: { type: 'string', description: 'Invite URL, e.g. sym://group/backend-team' } },
required: ['url'],
},
},
{
name: 'sym_join_group',
description: 'Hot-swap this node into a different mesh group at runtime — no Claude Code restart needed. Stops the current SymNode, reconstructs it with the new group (and optional relay credentials), and restarts it. Teammates on the same group/relay will discover this node via Bonjour (LAN) or the relay (cross-network). To leave a group, pass group="default" which reverts to the global _sym._tcp mesh.',
inputSchema: {
type: 'object',
properties: {
group: { type: 'string', description: 'Kebab-case group name, e.g. "backend-team". Pass "default" to return to the global mesh.' },
relay_url: { type: 'string', description: 'Optional WebSocket relay URL for cross-network teams. Leave empty for LAN-only.' },
relay_token: { type: 'string', description: 'Optional relay authentication token.' },
},
required: ['group'],
},
},
{
name: 'sym_groups_discover',
description: 'List SYM-mesh groups currently advertising on the local network. Uses Bonjour / mDNS to find service types matching the SYM protocol. Only shows groups with at least one node online right now — there is no central directory of offline-but-known groups. macOS and Windows have Bonjour built in; Linux requires avahi-daemon.',
inputSchema: { type: 'object', properties: {} },
},
],
}));
mcp.setRequestHandler(CallToolRequestSchema, async (request) => {
const { name, arguments: args } = request.params;
switch (name) {
case 'sym_send': {
{
const argErr = vetCmbArgs(args, ['to']);
if (argErr) return { content: [{ type: 'text', text: argErr }], isError: true };
}
// Emit a structured CAT7 CMB per MMP §4.2. When args.to names a peer,
// route as a targeted send (§4.4.4); otherwise broadcast. Receivers
// run SVAF (§9.2) and remix-store on accept — no separate "message"
// frame path, no raw-text channel.
const fields = {
focus: args.focus || 'directive',
issue: args.issue || 'none',
intent: args.intent || 'directive',
motivation: args.motivation || '',
commitment: args.commitment || '',
perspective: args.perspective || NODE_NAME,
mood: args.mood || { text: 'neutral', valence: 0, arousal: 0 },
};
let targetPeerId = null;
if (args.to) {
const peers = node.peers();
// Exact full-nodeId match first (unambiguous).
const byNodeId = peers.filter(p => p.peerId === args.to);
// Name match second.
const byName = peers.filter(p => p.name === args.to);
// Short-id prefix match last (for human-typed 8-char prefixes).
const byPrefix = peers.filter(p => p.id === args.to);
let matches;
if (byNodeId.length > 0) matches = byNodeId;
else if (byName.length > 0) matches = byName;
else if (byPrefix.length > 0) matches = byPrefix;
else matches = [];
if (matches.length === 0) {
return {
content: [{ type: 'text', text: `Peer "${args.to}" not connected. Call sym_peers to see connected peers.` }],
isError: true,
};
}
if (matches.length > 1) {
const names = matches.map(p => `${p.name} (${p.peerId})`).join(', ');
return {
content: [{ type: 'text', text: `Peer "${args.to}" is ambiguous — matches: ${names}. Pass the full nodeId.` }],
isError: true,
};
}
targetPeerId = matches[0].peerId;
}
const sendOpts = {};
if (targetPeerId) sendOpts.to = targetPeerId;
if (args.payload !== undefined && args.payload !== null) sendOpts.payload = args.payload;
const r = explicitSend(node, deliveredCmbKeys, fields, sendOpts, (entry, connected) =>
targetPeerId
? `Sent CMB ${entry.key} to ${args.to}`
: (connected
? `Broadcast CMB ${entry.key} to all peers`
: `Stored CMB ${entry.key} locally, but NO peers are connected — it was not delivered (not silently dropped; re-sendable once a peer connects).`));
return { content: [{ type: 'text', text: r.text }], ...(r.isError ? { isError: true } : {}) };
}
case 'sym_publish': {
{
const argErr = vetCmbArgs(args, []);
if (argErr) return { content: [{ type: 'text', text: argErr }], isError: true };
}
const fields = {
focus: args.focus || 'observation',
issue: args.issue || 'none',
intent: args.intent || 'observation',
motivation: args.motivation || '',
commitment: args.commitment || '',
perspective: args.perspective || NODE_NAME,
mood: args.mood || { text: 'neutral', valence: 0, arousal: 0 },
};
const observeOpts = {};
if (args.payload !== undefined && args.payload !== null) observeOpts.payload = args.payload;
const r = explicitSend(node, deliveredCmbKeys, fields, observeOpts, (entry, connected) =>
connected
? `Published: ${entry.key}`
: `Published locally: ${entry.key} — but NO peers are connected, so no one received it (not silently dropped).`);
return { content: [{ type: 'text', text: r.text }], ...(r.isError ? { isError: true } : {}) };
}
case 'sym_recall': {
const results = node.recall(args.query || '');
if (results.length === 0) {
return { content: [{ type: 'text', text: 'No memories found.' }] };
}
const lines = results.slice(0, 10).map(r => {
const focus = r.cmb?.fields?.focus?.text || r.content || '';
const source = r.source || r.cmb?.createdBy || 'unknown';
const time = r.timestamp ? new Date(r.timestamp).toLocaleString() : '';
const cut = focus.length > 150 ? '\u2026 [truncated \u2014 sym_fetch for full]' : '';
return `[${source}] ${time}\n ${focus.slice(0, 150)}${cut}`;
});
const more = results.length > 10
? `\n\n(+${results.length - 10} more matched — narrow the query to see them)`
: '';
return { content: [{ type: 'text', text: lines.join('\n\n') + more }] };
}
case 'sym_peers': {
const peers = node.peers();
if (peers.length === 0) {
return { content: [{ type: 'text', text: 'No peers connected.' }] };
}
const lines = peers.map(p => `${p.name} via ${p.source || 'unknown'}`);
return { content: [{ type: 'text', text: `${peers.length} peer(s):\n${lines.join('\n')}` }] };
}
case 'sym_fetch': {
// inNNNN → SDK delivery inbox (pull path); mNNN → channel-push store.
if (typeof args.msg_id === 'string' && args.msg_id.startsWith('in')) {
const m = node.inboxGet(args.msg_id);
if (!m) return { content: [{ type: 'text', text: `Message ${args.msg_id} not found (expired or invalid ID).` }] };
// Append the opaque payload (now preserved on the inbox message) so the
// pull path returns structured data intact, exactly like the channel-push
// store does — otherwise sym_fetch on a directed CMB silently loses it.
let body = m.content || '';
if (m.payload !== undefined && m.payload !== null) {
let serialized;
try { serialized = JSON.stringify(m.payload, null, 2); } catch { serialized = String(m.payload); }
body = `${body}\n\n---PAYLOAD---\n${serialized}`;
}
return { content: [{ type: 'text', text: `[${m.from}] ${new Date(m.receivedAt).toISOString()}\n\n${body}` }] };
}
const entry = MESSAGE_STORE.get(args.msg_id);
if (!entry) {
return { content: [{ type: 'text', text: `Message ${args.msg_id} not found (expired or invalid ID).` }] };
}
return {
content: [{
type: 'text',
text: `[${entry.from}] ${new Date(entry.timestamp).toISOString()}\n\n${entry.content}`,
}],
};
}
case 'sym_receive': {
// Thin adapter over the SDK primitive: the node owns the delivery buffer
// + drain cursor (node.inbox()). This wrapper only formats for display.
const { messages, remaining } = node.inbox({ peek: !!args.peek, limit: args.limit });
if (!messages.length) {
return { content: [{ type: 'text', text: 'Caught up — nothing new delivered since your last sym_receive.' }] };
}
const now = Date.now();
const lines = messages.map((m) => {
if (m.from === NODE_NAME) return null; // never surface our own deliveries
// The security layer still gates the pull path: peer allowlist +
// prompt-injection filter run on every message before it enters context.
if (!isPeerAllowed(m.from)) return null;
// payload lives at m.payload (sibling of fields), not m.fields.payload.
const sec = checkSecurity(m.from, m.fields || {}, m.payload);
if (!sec.safe) { securityAudit(sec.reason, m.from, sec.excerpt); return null; }
const age = Math.round((now - m.receivedAt) / 1000);
const focus = m.fields?.focus?.text || m.content || '';
const dirTag = m.directed ? ' →you' : '';
const memTag = m.directed && m.remixed === false ? ' ·not-stored' : '';
// Flag structured data so the agent knows to sym_fetch the full body.
const payTag = (m.payload !== undefined && m.payload !== null) ? ' [+payload]' : '';
const flat = String(focus).replace(/\s+/g, ' ');
const cutTag = flat.length > 90 ? '\u2026' : '';
return `[${m.from}${dirTag}] ${flat.slice(0, 90)}${cutTag}${memTag}${payTag} [${m.id}] (${age}s ago)`;
}).filter(Boolean);
if (!lines.length) {
return { content: [{ type: 'text', text: 'Caught up — nothing new delivered since your last sym_receive.' }] };
}
const moreNote = remaining > 0 ? ` (+${remaining} more — call sym_receive again)` : '';
return {
content: [{
type: 'text',
text: `${lines.length} new mesh message(s)${args.peek ? ' (peek — not drained)' : ''}${moreNote}:\n${lines.join('\n')}\n\nUse sym_fetch <id> for full content; reply via sym_send to=<peer>.`,
}],
};
}
case 'sym_status': {
const s = node.status();
return {
content: [{
type: 'text',
text: `Node: ${NODE_NAME} (${node.nodeId?.slice(0, 8) || '?'})\n` +
`Group: ${GROUP} (${SERVICE_TYPE})\n` +
`Relay: ${s.relayConnected ? 'connected' : 'disconnected'}\n` +
`Peers: ${s.peerCount || 0}\n` +
`Memories: ${s.memoryCount || 0}`,
}],
};
}
case 'sym_group_info': {
const s = node.status();
// Read the connected-peer list from status() — `node.getPeers` is not a
// public method, so the old call always fell through to `[]` and printed
// "(no peers in this group)" even when peers were connected, while the
// count below (s.peerCount) showed the real number. That count/list
// disagreement looked like a membership-handshake failure but was purely
// this rendering bug. `status().peers` is the same source as peerCount.
const peers = Array.isArray(s.peers) ? s.peers : [];
const peerLines = peers.length
? peers.map(p => ` ${p.name} (${(p.peerId || '').slice(0, 8)}) via ${p.source || '?'}`).join('\n')
: ' (no peers in this group)';
return {
content: [{
type: 'text',
text: `Mesh group (MMP §5.8):\n` +
` group: ${GROUP}\n` +
` service type: ${SERVICE_TYPE}\n` +
` node: ${NODE_NAME} (${node.nodeId?.slice(0, 8) || '?'})\n` +
` peers in group: ${s.peerCount || 0}\n` +
peerLines + `\n\n` +
`To join a different group, restart the sym-mesh-channel MCP server with env var SYM_GROUP=<name> or SYM_SERVICE_TYPE=<_foo._tcp>.`,
}],
};
}
case 'sym_invite_create': {
const group = args?.group;
const relayUrl = args?.relay_url;
const relayToken = args?.relay_token;
if (!group || typeof group !== 'string') {
return { content: [{ type: 'text', text: 'Missing required argument: group' }], isError: true };
}
if (!KEBAB_CASE_RE.test(group)) {
return {
content: [{
type: 'text',
text: `Invalid group name: "${group}". Must be kebab-case (lowercase alphanumerics + single hyphens), e.g. "backend-team".`,
}],
isError: true,
};
}
// LAN-only flavor: sym://group/{name}
// Cross-network flavor: sym://team/{name}?relay=...&token=...
let url;
let flavor;
if (relayUrl || relayToken) {
if (!relayUrl) return { content: [{ type: 'text', text: 'relay_token requires relay_url' }], isError: true };
const params = [`relay=${encodeURIComponent(relayUrl)}`];
if (relayToken) params.push(`token=${encodeURIComponent(relayToken)}`);
url = `sym://team/${group}?${params.join('&')}`;
flavor = 'cross-network (relay)';
} else {
url = `sym://group/${group}`;
flavor = 'LAN-only (Bonjour)';
}
const youRunning = GROUP === group
? `You're already on this group — teammates who join will see you.`
: `You are currently on group "${GROUP}". To be reachable, call sym_join_group with group="${group}" (+ same relay creds if cross-network) before sharing.`;
return {
content: [{
type: 'text',
text: `Invite URL (${flavor}):\n\n ${url}\n\n` +
`Share this URL with teammates. Each pastes it into Claude Code and calls sym_join_group (or sym_invite_info for a dry run first).\n\n` +
youRunning,
}],
};
}
case 'sym_invite_info': {
const url = args?.url;
if (!url || typeof url !== 'string') {
return { content: [{ type: 'text', text: 'Missing required argument: url' }], isError: true };
}
const parsed = parseInviteURL(url);
if (parsed.error) {
return { content: [{ type: 'text', text: parsed.error }], isError: true };
}
const { appScheme, group, serviceType, roomId, roomName, relayUrl, relayToken } = parsed;
const out = {
app: appScheme,
group,
service_type: serviceType,
room_id: appScheme === 'sym' ? undefined : roomId,
room_name: appScheme === 'sym' ? undefined : roomName,
relay_url: relayUrl || undefined,
relay_token: relayToken || undefined,
};
for (const k of Object.keys(out)) if (out[k] === undefined) delete out[k];
const joinCall = {
group,
...(relayUrl && { relay_url: relayUrl }),
...(relayToken && { relay_token: relayToken }),
};
return {
content: [{
type: 'text',
text: `Parsed invite: ${url}\n\n` +
JSON.stringify(out, null, 2) + `\n\n` +
`To join, call sym_join_group:\n\n ${JSON.stringify(joinCall)}\n\n` +
`This hot-swaps your node into the ${relayUrl ? 'relay channel' : 'LAN group'} — no Claude Code restart needed.`,
}],
};
}
case 'sym_join_group': {
const group = args?.group;
const relayUrl = args?.relay_url || null;
const relayToken = args?.relay_token || null;
if (!group || typeof group !== 'string') {
return { content: [{ type: 'text', text: 'Missing required argument: group' }], isError: true };
}
if (!KEBAB_CASE_RE.test(group) && group !== 'default') {
return {
content: [{ type: 'text', text: `Invalid group name: "${group}". Must be kebab-case or "default".` }],
isError: true,
};
}
const newServiceType = group === 'default' ? '_sym._tcp' : `_${group}._tcp`;
const prevGroup = GROUP;
const prevServiceType = SERVICE_TYPE;
// Stop the current node cleanly so peers see us leave, then construct
// a fresh one on the new service type. Any failure during restart is
// reported; the previous node will already be stopped, so the caller
// is in a known-disconnected state and can retry.
try {
await node.stop();
} catch (e) {
return {
content: [{ type: 'text', text: `Failed to stop current node: ${e?.message || e}` }],
isError: true,
};
}
const newNode = new SymNode({
name: NODE_NAME,
autoSuffix: NODE_AUTOSUFFIX, // same stable identity across a group hot-swap
cognitiveProfile: 'Engineering node. Code, architecture, debugging, technical decisions.',
svafFieldWeights: FIELD_WEIGHTS,
svafFreshnessSeconds: 7200,
discoveryServiceType: newServiceType,
group,
relay: relayUrl,
relayToken,