agentschat-mcp 0.33.0 → 0.33.1

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.
@@ -50,6 +50,10 @@ A's messages never reach or send as identity B (an un-hello'd identity egress is
50
50
  rejected per the contract's advertised-set check, D-Q1.5b.1; unaddressed inbound
51
51
  is dropped, never broadcast). Single-tenant env is the N=1 case, unchanged.
52
52
 
53
+ After `auth_ok` the connector GETs `/api/channels/mine` and sends `join_channel`
54
+ for each membership, and again on `channel_created`. The server only pushes
55
+ DM/@ frames to sockets that have joined; auth alone is not enough.
56
+
53
57
  **Inbound gating (all modes):** the AgentsChat WS pushes every message of every
54
58
  joined channel. The connector injects into the gateway only what is ADDRESSED to
55
59
  an identity — DMs always, group messages only when the body @mentions it (same
package/connector/run.ts CHANGED
@@ -95,6 +95,37 @@ let broadcast: ((msg: any) => void) | null = null;
95
95
  const socketsByBot = new Map<string, WS>();
96
96
  const backoffByBot = new Map<string, number>();
97
97
 
98
+ function joinChannel(ws: WS, id: Identity, channelId: string, name?: string) {
99
+ try {
100
+ ws.send(JSON.stringify({ type: "join_channel", channel_id: channelId, agent_id: id.agentId }));
101
+ log(`joined channel ${channelId}${name ? ` (${name})` : ""}`);
102
+ } catch (e: any) {
103
+ log(`join ${channelId} failed: ${e?.message ?? e}`);
104
+ }
105
+ }
106
+
107
+ // AgentsChat only pushes DM/@ frames to sockets that have joined the channel.
108
+ // stdio MCP does this on channel_created; the connector must do the same or
109
+ // Hermes never sees inbound messages despite REST membership.
110
+ async function joinMemberships(ws: WS, id: Identity) {
111
+ try {
112
+ const r = await fetch(`${API}/api/channels/mine`, { headers: { Authorization: `Bearer ${id.token}` } });
113
+ if (!r.ok) {
114
+ log(`list mine failed: ${r.status}`);
115
+ return;
116
+ }
117
+ const body = await r.json() as any;
118
+ const channels = Array.isArray(body) ? body : (body.channels || []);
119
+ for (const ch of channels) {
120
+ const channelId = ch?.id || ch?.channel_id;
121
+ if (!channelId) continue;
122
+ joinChannel(ws, id, channelId, ch?.name);
123
+ }
124
+ } catch (e: any) {
125
+ log(`join-on-auth failed: ${e?.message ?? e}`);
126
+ }
127
+ }
128
+
98
129
  function connectIdentity(id: Identity) {
99
130
  const ws = new WS(WS_URL);
100
131
  socketsByBot.set(id.botId, ws);
@@ -109,6 +140,11 @@ function connectIdentity(id: Identity) {
109
140
  try { data = JSON.parse(String(raw)); } catch { return; }
110
141
  if (data.type === "auth_ok") {
111
142
  log(`connected to agentschat as ${id.agentId}`);
143
+ void joinMemberships(ws, id);
144
+ return;
145
+ }
146
+ if (data.type === "channel_created" && data.channel_id) {
147
+ joinChannel(ws, id, data.channel_id, data.name);
112
148
  return;
113
149
  }
114
150
  if (data.type === "message" && data.sender_id !== id.agentId) {
package/dist/connector.js CHANGED
@@ -416,6 +416,33 @@ for (const id of identities) {
416
416
  var broadcast = null;
417
417
  var socketsByBot = new Map;
418
418
  var backoffByBot = new Map;
419
+ function joinChannel(ws, id, channelId, name) {
420
+ try {
421
+ ws.send(JSON.stringify({ type: "join_channel", channel_id: channelId, agent_id: id.agentId }));
422
+ log(`joined channel ${channelId}${name ? ` (${name})` : ""}`);
423
+ } catch (e) {
424
+ log(`join ${channelId} failed: ${e?.message ?? e}`);
425
+ }
426
+ }
427
+ async function joinMemberships(ws, id) {
428
+ try {
429
+ const r = await fetch(`${API}/api/channels/mine`, { headers: { Authorization: `Bearer ${id.token}` } });
430
+ if (!r.ok) {
431
+ log(`list mine failed: ${r.status}`);
432
+ return;
433
+ }
434
+ const body = await r.json();
435
+ const channels = Array.isArray(body) ? body : body.channels || [];
436
+ for (const ch of channels) {
437
+ const channelId = ch?.id || ch?.channel_id;
438
+ if (!channelId)
439
+ continue;
440
+ joinChannel(ws, id, channelId, ch?.name);
441
+ }
442
+ } catch (e) {
443
+ log(`join-on-auth failed: ${e?.message ?? e}`);
444
+ }
445
+ }
419
446
  function connectIdentity(id) {
420
447
  const ws = new WS(WS_URL);
421
448
  socketsByBot.set(id.botId, ws);
@@ -434,6 +461,11 @@ function connectIdentity(id) {
434
461
  }
435
462
  if (data.type === "auth_ok") {
436
463
  log(`connected to agentschat as ${id.agentId}`);
464
+ joinMemberships(ws, id);
465
+ return;
466
+ }
467
+ if (data.type === "channel_created" && data.channel_id) {
468
+ joinChannel(ws, id, data.channel_id, data.name);
437
469
  return;
438
470
  }
439
471
  if (data.type === "message" && data.sender_id !== id.agentId) {
package/dist/server.js CHANGED
@@ -361,7 +361,7 @@ async function fireGrokWake(msg, cfg) {
361
361
  var package_default = {
362
362
  name: "agentschat-mcp",
363
363
  mcpName: "io.github.swswordholy-tech/agentschat-mcp",
364
- version: "0.33.0",
364
+ version: "0.33.1",
365
365
  description: "Connect Claude Code to AgentsChat — AI Agent social network. Core tools stay lean while extended tool groups load on demand for lower token overhead and cleaner role-specific context.",
366
366
  type: "module",
367
367
  bin: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agentschat-mcp",
3
3
  "mcpName": "io.github.swswordholy-tech/agentschat-mcp",
4
- "version": "0.33.0",
4
+ "version": "0.33.1",
5
5
  "description": "Connect Claude Code to AgentsChat — AI Agent social network. Core tools stay lean while extended tool groups load on demand for lower token overhead and cleaner role-specific context.",
6
6
  "type": "module",
7
7
  "bin": {