agent-comms 2.20.1 → 2.21.0

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.
Files changed (52) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +1 -1
  4. package/dist/core/agent-registry.d.ts +38 -0
  5. package/dist/core/agent-registry.d.ts.map +1 -0
  6. package/dist/core/agent-registry.js +117 -0
  7. package/dist/core/agent-registry.js.map +1 -0
  8. package/dist/core/connection-approval.d.ts +48 -0
  9. package/dist/core/connection-approval.d.ts.map +1 -0
  10. package/dist/core/connection-approval.js +89 -0
  11. package/dist/core/connection-approval.js.map +1 -0
  12. package/dist/core/delivery-engine.d.ts +82 -0
  13. package/dist/core/delivery-engine.d.ts.map +1 -0
  14. package/dist/core/delivery-engine.js +464 -0
  15. package/dist/core/delivery-engine.js.map +1 -0
  16. package/dist/core/federation-bridge.d.ts +32 -0
  17. package/dist/core/federation-bridge.d.ts.map +1 -0
  18. package/dist/core/federation-bridge.js +113 -0
  19. package/dist/core/federation-bridge.js.map +1 -0
  20. package/dist/core/mesh-store-shared.d.ts +39 -0
  21. package/dist/core/mesh-store-shared.d.ts.map +1 -0
  22. package/dist/core/mesh-store-shared.js +32 -0
  23. package/dist/core/mesh-store-shared.js.map +1 -0
  24. package/dist/core/mesh-store.d.ts +65 -256
  25. package/dist/core/mesh-store.d.ts.map +1 -1
  26. package/dist/core/mesh-store.js +211 -1917
  27. package/dist/core/mesh-store.js.map +1 -1
  28. package/dist/core/peer-lifecycle.d.ts +36 -0
  29. package/dist/core/peer-lifecycle.d.ts.map +1 -0
  30. package/dist/core/peer-lifecycle.js +85 -0
  31. package/dist/core/peer-lifecycle.js.map +1 -0
  32. package/dist/core/room-lifecycle.d.ts +82 -0
  33. package/dist/core/room-lifecycle.d.ts.map +1 -0
  34. package/dist/core/room-lifecycle.js +459 -0
  35. package/dist/core/room-lifecycle.js.map +1 -0
  36. package/dist/core/room-messaging.d.ts +31 -0
  37. package/dist/core/room-messaging.d.ts.map +1 -0
  38. package/dist/core/room-messaging.js +120 -0
  39. package/dist/core/room-messaging.js.map +1 -0
  40. package/dist/core/room-protocol.d.ts +85 -0
  41. package/dist/core/room-protocol.d.ts.map +1 -0
  42. package/dist/core/room-protocol.js +479 -0
  43. package/dist/core/room-protocol.js.map +1 -0
  44. package/dist/core/room-wire-extensions.d.ts +36 -0
  45. package/dist/core/room-wire-extensions.d.ts.map +1 -0
  46. package/dist/core/room-wire-extensions.js +52 -0
  47. package/dist/core/room-wire-extensions.js.map +1 -0
  48. package/dist/core/stale-agent-checker.d.ts +28 -0
  49. package/dist/core/stale-agent-checker.d.ts.map +1 -0
  50. package/dist/core/stale-agent-checker.js +77 -0
  51. package/dist/core/stale-agent-checker.js.map +1 -0
  52. package/package.json +1 -1
@@ -15,7 +15,7 @@
15
15
  "url": "https://github.com/ExaDev/agent-comms.git"
16
16
  },
17
17
  "description": "Cross-harness LLM agent communication mesh — rooms, DMs, and presence",
18
- "version": "2.20.1"
18
+ "version": "2.21.0"
19
19
  }
20
20
  ]
21
21
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agent-comms",
3
3
  "description": "Cross-harness LLM agent communication mesh — rooms, DMs, and presence",
4
- "version": "2.20.1",
4
+ "version": "2.21.0",
5
5
  "author": {
6
6
  "name": "ExaDev"
7
7
  },
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![GitHub](https://img.shields.io/badge/GitHub-181717?logo=github&logoColor=white)](https://github.com/ExaDev/agent-comms)
4
4
  [![npm](https://img.shields.io/badge/npm-CB3837?logo=npm&logoColor=white)](https://www.npmjs.com/package/agent-comms)
5
- [![version](https://img.shields.io/badge/version-2.20.1-blue)](https://github.com/ExaDev/agent-comms/releases/tag/v2.20.1)
5
+ [![version](https://img.shields.io/badge/version-2.21.0-blue)](https://github.com/ExaDev/agent-comms/releases/tag/v2.21.0)
6
6
  [![CI](https://img.shields.io/github/actions/workflow/status/ExaDev/agent-comms/ci.yml?branch=main)](https://github.com/ExaDev/agent-comms/actions)
7
7
 
8
8
  Cross-harness communication mesh for LLM agents: rooms, DMs, presence, and visibility over TCP with zero filesystem dependencies.
@@ -0,0 +1,38 @@
1
+ /**
2
+ * AgentRegistry — the agent-identity half of CommsStore: the per-(harness, cwd) identity cache readIdentity/writeIdentity uses to recognise a restarted bridge as the same agent, and the register/get/update/list/offline lifecycle around an AgentIdentity record itself. Split out of mesh-store.ts to reduce it under the repo's max-lines cap.
3
+ */
4
+ import type { DeliveryEngine } from "./delivery-engine.js";
5
+ import type { FederationManager } from "./federation.js";
6
+ import type { AgentIdentity, Visibility } from "./types.js";
7
+ /** The state and collaborators AgentRegistry needs from MeshStore. agents/identityCache are direct references into MeshStore's own fields; startedAt is a readonly value copied once; deliveryEngine and federation are the already-constructed instances, narrowed to what agent-lifecycle bookkeeping ever needs. */
8
+ export interface AgentRegistryDeps {
9
+ agents: Map<string, AgentIdentity>;
10
+ identityCache: Map<string, {
11
+ id: string;
12
+ }>;
13
+ startedAt: string;
14
+ getPeerId: () => string;
15
+ deliveryEngine: Pick<DeliveryEngine, "bump" | "broadcastPatch" | "notifyRoomsOfStatus" | "notifyRoomsOfNameChange">;
16
+ federation: Pick<FederationManager, "broadcastAgentVisible" | "broadcastAgentGone">;
17
+ }
18
+ export declare class AgentRegistry {
19
+ private readonly deps;
20
+ constructor(deps: AgentRegistryDeps);
21
+ readIdentity(harness: string, cwd: string): Promise<{
22
+ id: string;
23
+ } | undefined>;
24
+ writeIdentity(harness: string, cwd: string, id: string): Promise<void>;
25
+ registerAgent(opts: {
26
+ name: string;
27
+ harness: string;
28
+ cwd: string;
29
+ pid: number;
30
+ visibility: Visibility;
31
+ tags: string[];
32
+ }): Promise<AgentIdentity>;
33
+ getAgent(id: string): Promise<AgentIdentity | undefined>;
34
+ updateAgent(id: string, patch: Partial<Pick<AgentIdentity, "name" | "visibility" | "status" | "tags" | "pid">>): Promise<AgentIdentity>;
35
+ listAgents(requesterId: string): Promise<AgentIdentity[]>;
36
+ setAgentOffline(id: string): Promise<void>;
37
+ }
38
+ //# sourceMappingURL=agent-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-registry.d.ts","sourceRoot":"","sources":["../../src/core/agent-registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE5D,uTAAuT;AACvT,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACnC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,MAAM,CAAC;IACxB,cAAc,EAAE,IAAI,CAClB,cAAc,EACZ,MAAM,GACN,gBAAgB,GAChB,qBAAqB,GACrB,yBAAyB,CAC5B,CAAC;IACF,UAAU,EAAE,IAAI,CACd,iBAAiB,EACjB,uBAAuB,GAAG,oBAAoB,CAC/C,CAAC;CACH;AAED,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,iBAAiB;IAM9C,YAAY,CAChB,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;IAKhC,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAStE,aAAa,CAAC,IAAI,EAAE;QACxB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;QACZ,UAAU,EAAE,UAAU,CAAC;QACvB,IAAI,EAAE,MAAM,EAAE,CAAC;KAChB,GAAG,OAAO,CAAC,aAAa,CAAC;IAwCpB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAKxD,WAAW,CACf,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,OAAO,CACZ,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC,CACvE,GACA,OAAO,CAAC,aAAa,CAAC;IA8BnB,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAUzD,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAoBjD"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * AgentRegistry — the agent-identity half of CommsStore: the per-(harness, cwd) identity cache readIdentity/writeIdentity uses to recognise a restarted bridge as the same agent, and the register/get/update/list/offline lifecycle around an AgentIdentity record itself. Split out of mesh-store.ts to reduce it under the repo's max-lines cap.
3
+ */
4
+ import { CommsError } from "./store.js";
5
+ export class AgentRegistry {
6
+ deps;
7
+ constructor(deps) {
8
+ this.deps = deps;
9
+ }
10
+ // -----------------------------------------------------------------------
11
+ // CommsStore — Identity
12
+ // -----------------------------------------------------------------------
13
+ async readIdentity(harness, cwd) {
14
+ await Promise.resolve();
15
+ return this.deps.identityCache.get(`${harness}--${cwd}`);
16
+ }
17
+ async writeIdentity(harness, cwd, id) {
18
+ await Promise.resolve();
19
+ this.deps.identityCache.set(`${harness}--${cwd}`, { id });
20
+ }
21
+ // -----------------------------------------------------------------------
22
+ // CommsStore — Agent registry
23
+ // -----------------------------------------------------------------------
24
+ async registerAgent(opts) {
25
+ const existing = await this.readIdentity(opts.harness, opts.cwd);
26
+ if (existing) {
27
+ return this.updateAgent(existing.id, {
28
+ name: opts.name,
29
+ visibility: opts.visibility,
30
+ tags: opts.tags,
31
+ status: "active",
32
+ pid: opts.pid,
33
+ });
34
+ }
35
+ const id = this.deps.getPeerId();
36
+ const agent = {
37
+ id,
38
+ version: 1,
39
+ name: opts.name,
40
+ harness: opts.harness,
41
+ cwd: opts.cwd,
42
+ pid: opts.pid,
43
+ startedAt: this.deps.startedAt,
44
+ visibility: opts.visibility,
45
+ status: "active",
46
+ tags: opts.tags,
47
+ subscribedRooms: [],
48
+ };
49
+ this.deps.agents.set(id, agent);
50
+ await this.writeIdentity(opts.harness, opts.cwd, id);
51
+ await this.deps.deliveryEngine.broadcastPatch({
52
+ type: "agent_upsert",
53
+ agent,
54
+ });
55
+ // Broadcast presence to federated links
56
+ if (agent.visibility === "visible") {
57
+ await this.deps.federation.broadcastAgentVisible(agent);
58
+ }
59
+ return agent;
60
+ }
61
+ async getAgent(id) {
62
+ await Promise.resolve();
63
+ return this.deps.agents.get(id);
64
+ }
65
+ async updateAgent(id, patch) {
66
+ const agent = this.deps.agents.get(id);
67
+ if (!agent)
68
+ throw new CommsError(`Agent ${id} not found`, "AGENT_NOT_FOUND");
69
+ const oldStatus = agent.status;
70
+ const oldName = agent.name;
71
+ Object.assign(agent, patch);
72
+ this.deps.deliveryEngine.bump(agent);
73
+ this.deps.agents.set(id, agent);
74
+ await this.deps.deliveryEngine.broadcastPatch({
75
+ type: "agent_upsert",
76
+ agent,
77
+ });
78
+ if (patch.name !== undefined && patch.name !== oldName) {
79
+ await this.deps.deliveryEngine.notifyRoomsOfNameChange(id, oldName, patch.name);
80
+ }
81
+ if (patch.status && patch.status !== oldStatus) {
82
+ await this.deps.deliveryEngine.notifyRoomsOfStatus(id, patch.status);
83
+ }
84
+ return agent;
85
+ }
86
+ async listAgents(requesterId) {
87
+ await Promise.resolve();
88
+ const result = [];
89
+ for (const agent of this.deps.agents.values()) {
90
+ if (agent.visibility === "ghost" && agent.id !== requesterId)
91
+ continue;
92
+ result.push(agent);
93
+ }
94
+ return result;
95
+ }
96
+ async setAgentOffline(id) {
97
+ const agent = this.deps.agents.get(id);
98
+ if (!agent)
99
+ return;
100
+ if (agent.status === "offline")
101
+ return;
102
+ // Only the owning store should broadcast the status change. Other stores learn about it via the agent_offline mesh patch.
103
+ const isOwner = id === this.deps.getPeerId();
104
+ agent.status = "offline";
105
+ this.deps.deliveryEngine.bump(agent);
106
+ this.deps.agents.set(id, agent);
107
+ if (isOwner) {
108
+ await this.deps.deliveryEngine.notifyRoomsOfStatus(id, "offline");
109
+ await this.deps.deliveryEngine.broadcastPatch({
110
+ type: "agent_offline",
111
+ agentId: id,
112
+ });
113
+ await this.deps.federation.broadcastAgentGone(id);
114
+ }
115
+ }
116
+ }
117
+ //# sourceMappingURL=agent-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-registry.js","sourceRoot":"","sources":["../../src/core/agent-registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAwBxC,MAAM,OAAO,aAAa;IACK;IAA7B,YAA6B,IAAuB;QAAvB,SAAI,GAAJ,IAAI,CAAmB;IAAG,CAAC;IAExD,0EAA0E;IAC1E,wBAAwB;IACxB,0EAA0E;IAE1E,KAAK,CAAC,YAAY,CAChB,OAAe,EACf,GAAW;QAEX,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,OAAO,KAAK,GAAG,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,OAAe,EAAE,GAAW,EAAE,EAAU;QAC1D,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,OAA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O,EAAE,CAAC;YACZ,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,mBAAmB,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;YAClE,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC;gBAC5C,IAAI,EAAE,eAAe;gBACrB,OAAO,EAAE,EAAE;aACZ,CAAC,CAAC;YACH,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * ConnectionApproval — inbound mesh-connection admission: queues a connection_request for the owning agent to accept/reject, and the accept/reject/list/connectToRemote/startDataServerOnly operations around it. Split out of mesh-store.ts to reduce it under the repo's max-lines cap. Owns pendingInboundConnections exclusively -- nothing outside this class ever reads or writes it.
3
+ */
4
+ import type { DeliveryEngine } from "./delivery-engine.js";
5
+ import type { ConnectionHandle, MeshTransport } from "./transport.js";
6
+ import type { AgentIdentity, DeliveryEvent } from "./types.js";
7
+ import type { PeerInfo } from "./wire-protocol.js";
8
+ /** The state and collaborators ConnectionApproval needs from MeshStore. agents/peerInfo are direct references into MeshStore's own fields; startedAt is a readonly value copied once (MeshStore never reassigns it); the closures read MeshStore's own current peerId/transport/onDelivery, and queueDelivery is DeliveryEngine's own already-constructed method. */
9
+ export interface ConnectionApprovalDeps {
10
+ agents: Map<string, AgentIdentity>;
11
+ peerInfo: Map<string, PeerInfo>;
12
+ startedAt: string;
13
+ getPeerId: () => string;
14
+ requireTransport: () => MeshTransport;
15
+ getOnDelivery: () => ((agentId: string, event: DeliveryEvent) => void | Promise<void>) | undefined;
16
+ queueDelivery: DeliveryEngine["queueDelivery"];
17
+ }
18
+ export declare class ConnectionApproval {
19
+ private readonly deps;
20
+ private readonly pendingInboundConnections;
21
+ constructor(deps: ConnectionApprovalDeps);
22
+ handleConnectionRequest(handle: ConnectionHandle, request: {
23
+ peerId: string;
24
+ dataPort: number;
25
+ name: string;
26
+ fingerprint: string;
27
+ }): void;
28
+ /** Accept a pending inbound connection. */
29
+ acceptConnection(connectionId: string): Promise<void>;
30
+ /** Reject a pending inbound connection. */
31
+ rejectConnection(connectionId: string, reason: string): Promise<void>;
32
+ /** List all pending inbound connections awaiting approval. */
33
+ listPendingConnections(): {
34
+ connectionId: string;
35
+ peerId: string;
36
+ dataPort: number;
37
+ name: string;
38
+ fingerprint: string;
39
+ }[];
40
+ /** Initiate an outbound connection to a remote coordinator requiring approval.
41
+ * Fires the connect_request and returns immediately. The connection
42
+ * completes asynchronously when the coordinator accepts or rejects. */
43
+ connectToRemote(host: string, port: number): Promise<void>;
44
+ /** Start only the data server without connecting to a coordinator.
45
+ * Used for testing scenarios where the peer connects via connectToRemote. */
46
+ startDataServerOnly(): Promise<void>;
47
+ }
48
+ //# sourceMappingURL=connection-approval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection-approval.d.ts","sourceRoot":"","sources":["../../src/core/connection-approval.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,qWAAqW;AACrW,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACnC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,aAAa,CAAC;IACtC,aAAa,EAAE,MACX,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GACjE,SAAS,CAAC;IACd,aAAa,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;CAChD;AAED,qBAAa,kBAAkB;IAMjB,OAAO,CAAC,QAAQ,CAAC,IAAI;IALjC,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAGtC;gBAEyB,IAAI,EAAE,sBAAsB;IAEzD,uBAAuB,CACrB,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE;QACP,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;KACrB,GACA,IAAI;IA0BP,2CAA2C;IACrC,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU3D,2CAA2C;IACrC,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU3E,8DAA8D;IAC9D,sBAAsB,IAAI;QACxB,YAAY,EAAE,MAAM,CAAC;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;KACrB,EAAE;IAOH;;4EAEwE;IACxE,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqB1D;kFAC8E;IACxE,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;CAU3C"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * ConnectionApproval — inbound mesh-connection admission: queues a connection_request for the owning agent to accept/reject, and the accept/reject/list/connectToRemote/startDataServerOnly operations around it. Split out of mesh-store.ts to reduce it under the repo's max-lines cap. Owns pendingInboundConnections exclusively -- nothing outside this class ever reads or writes it.
3
+ */
4
+ export class ConnectionApproval {
5
+ deps;
6
+ pendingInboundConnections = new Map();
7
+ constructor(deps) {
8
+ this.deps = deps;
9
+ }
10
+ handleConnectionRequest(handle, request) {
11
+ this.pendingInboundConnections.set(handle.id, {
12
+ peerId: request.peerId,
13
+ dataPort: request.dataPort,
14
+ name: request.name,
15
+ fingerprint: request.fingerprint,
16
+ });
17
+ // Deliver connection_request event to the owning agent
18
+ const connectionId = handle.id;
19
+ const event = {
20
+ type: "connection_request",
21
+ connectionId,
22
+ peerId: request.peerId,
23
+ dataPort: request.dataPort,
24
+ name: request.name,
25
+ fingerprint: request.fingerprint,
26
+ };
27
+ const peerId = this.deps.getPeerId();
28
+ this.deps.queueDelivery(peerId, event);
29
+ const onDelivery = this.deps.getOnDelivery();
30
+ if (onDelivery) {
31
+ void onDelivery(peerId, event);
32
+ }
33
+ }
34
+ /** Accept a pending inbound connection. */
35
+ async acceptConnection(connectionId) {
36
+ const pending = this.pendingInboundConnections.get(connectionId);
37
+ if (!pending) {
38
+ throw new Error(`No pending connection ${connectionId}`);
39
+ }
40
+ this.pendingInboundConnections.delete(connectionId);
41
+ const handle = { id: connectionId };
42
+ await this.deps.requireTransport().acceptConnection(handle);
43
+ }
44
+ /** Reject a pending inbound connection. */
45
+ async rejectConnection(connectionId, reason) {
46
+ const pending = this.pendingInboundConnections.get(connectionId);
47
+ if (!pending) {
48
+ throw new Error(`No pending connection ${connectionId}`);
49
+ }
50
+ this.pendingInboundConnections.delete(connectionId);
51
+ const handle = { id: connectionId };
52
+ await this.deps.requireTransport().rejectConnection(handle, reason);
53
+ }
54
+ /** List all pending inbound connections awaiting approval. */
55
+ listPendingConnections() {
56
+ return [...this.pendingInboundConnections.entries()].map(([id, info]) => ({
57
+ connectionId: id,
58
+ ...info,
59
+ }));
60
+ }
61
+ /** Initiate an outbound connection to a remote coordinator requiring approval.
62
+ * Fires the connect_request and returns immediately. The connection
63
+ * completes asynchronously when the coordinator accepts or rejects. */
64
+ connectToRemote(host, port) {
65
+ const peerId = this.deps.getPeerId();
66
+ const agent = this.deps.agents.get(peerId);
67
+ // Fire-and-forget: don't await the full approval handshake. The coordinator will either accept (triggering normal introduction flow) or reject (closing the socket). Handle rejection to avoid unhandled rejection.
68
+ this.deps
69
+ .requireTransport()
70
+ .connectToRemote(host, port, peerId, this.deps.requireTransport().dataPort, agent?.name ?? "", "")
71
+ .catch(() => {
72
+ // Rejection is expected when the coordinator denies the connection. Log silently — the calling tool already returned success.
73
+ });
74
+ return Promise.resolve();
75
+ }
76
+ /** Start only the data server without connecting to a coordinator.
77
+ * Used for testing scenarios where the peer connects via connectToRemote. */
78
+ async startDataServerOnly() {
79
+ await this.deps.requireTransport().startDataServer();
80
+ const peerId = this.deps.getPeerId();
81
+ this.deps.peerInfo.set(peerId, {
82
+ id: peerId,
83
+ port: this.deps.requireTransport().dataPort,
84
+ startedAt: this.deps.startedAt,
85
+ });
86
+ this.deps.requireTransport().unref();
87
+ }
88
+ }
89
+ //# sourceMappingURL=connection-approval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection-approval.js","sourceRoot":"","sources":["../../src/core/connection-approval.ts"],"names":[],"mappings":"AAAA;;GAEG;AAoBH,MAAM,OAAO,kBAAkB;IAMA;IALZ,yBAAyB,GAAG,IAAI,GAAG,EAGjD,CAAC;IAEJ,YAA6B,IAA4B;QAA5B,SAAI,GAAJ,IAAI,CAAwB;IAAG,CAAC;IAE7D,uBAAuB,CACrB,MAAwB,EACxB,OAKC;QAED,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE;YAC5C,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,WAAW,EAAE,OAAO,CAAC,WAAW;SACjC,CAAC,CAAC;QAEH,uDAAuD;QACvD,MAAM,YAAY,GAAG,MAAM,CAAC,EAAE,CAA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SAAS,EAAE,CAAC;QACrC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE;YAC7B,EAAE,EAAE,MAAM;YACV,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,QAAQ;YAC3C,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS;SAC/B,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,KAAK,EAAE,CAAC;IACvC,CAAC;CACF"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * DeliveryEngine — the busiest hub in MeshStore: owns queued/local delivery, room-membership CRDT merge (mergeRoom/refreshMembership/recordMemberOp), patch application and broadcast, read receipts, and the two gossip callbacks (presence-advert, revocation-announce) that mutate this state directly. Split out of mesh-store.ts to reduce it under the repo's max-lines cap. Every core Map it touches (agents/rooms/messages/dms/deliveryQueues/localDeliveryKeys/pendingMarkReadTimers) is a direct reference into MeshStore's own fields, shared by construction rather than copied, since AgentRegistry, RoomLifecycle, RoomProtocol, RoomMessaging, FederationBridge, and StaleAgentChecker all read or mutate the same underlying state.
3
+ */
4
+ import type { CapabilityToken } from "wire-mesh-core/generated/protocol";
5
+ import type { RevocationEntry } from "wire-mesh-core/generated/protocol";
6
+ import type { MeshStoreIdentity } from "./mesh-store-shared.js";
7
+ import type { MeshTransport } from "./transport.js";
8
+ import type { MeshStatePatch, SerialisedState } from "./wire-protocol.js";
9
+ import type { AgentIdentity, AgentStatus, DeliveryEvent, DmMessage, Room, RoomMessage } from "./types.js";
10
+ /**
11
+ * The state and collaborators DeliveryEngine needs from MeshStore. The Maps/Set/array are direct references into MeshStore's own fields (shared by construction, not copied); the closures read MeshStore's own current values or call through to a not-yet-constructed collaborator at the time DeliveryEngine itself is built (see sendRoomRequestToMember below).
12
+ */
13
+ export interface DeliveryEngineDeps {
14
+ agents: Map<string, AgentIdentity>;
15
+ rooms: Map<string, Room>;
16
+ messages: Map<string, RoomMessage[]>;
17
+ dms: Map<string, DmMessage[]>;
18
+ deliveryQueues: Map<string, DeliveryEvent[]>;
19
+ localDeliveryKeys: Set<string>;
20
+ pendingMarkReadTimers: ReturnType<typeof setTimeout>[];
21
+ getPeerId: () => string;
22
+ requireIdentity: () => MeshStoreIdentity;
23
+ requireTransport: () => MeshTransport;
24
+ getOnDelivery: () => ((agentId: string, event: DeliveryEvent) => void | Promise<void>) | undefined;
25
+ getOnPatch: () => ((patch: MeshStatePatch) => void | Promise<void>) | undefined;
26
+ isShutDown: () => boolean;
27
+ /**
28
+ * Sends one directed room-domain request to a single member, queuing it for retry when unreachable -- RoomProtocol's own method. Deferred: RoomProtocol doesn't exist yet when DeliveryEngine is constructed (construction order: discovery -> deliveryEngine -> ... -> roomProtocol), so MeshStore wires this as `(...) => this.roomProtocol.sendRoomRequestToMember(...)`, a closure over `this` that only resolves `this.roomProtocol` when markRead actually calls it at runtime, well after the constructor has finished -- the same lazy-`this`-capture pattern the constructor already uses to wire FederationManager's own callbacks before `this.federation` exists.
29
+ */
30
+ sendRoomRequestToMember: (memberId: string, roomPath: string, token: CapabilityToken, params: Record<string, unknown>) => Promise<void>;
31
+ }
32
+ export declare class DeliveryEngine {
33
+ private readonly deps;
34
+ constructor(deps: DeliveryEngineDeps);
35
+ /** Applies a peer's gossiped presence status to this store's own local record, without broadcasting it back onto the mesh -- gossip itself is already how this fact propagates (each side's WireMeshTransport re-advertises its own status periodically), so re-broadcasting a received one would just bounce it around indefinitely. Silently ignored for a device-id this store doesn't yet have an agent record for: presence gossip is a transport-layer fact about an already-known peer's current status, not itself a source of truth for who that peer is -- that still comes only from agent_upsert/registerAgent, which carries the name/harness/cwd/tags a fabricated partial record here never could. */
36
+ handlePresenceAdvert(agentId: string, status: AgentStatus): void;
37
+ /** Verifies a gossiped revocation-entry and, if it verifies, records it in this store's own RevocationView -- future verifyRoomToken calls against this token's (token-id, issuer) pair fail with "revoked" from this point on. A failing entry is dropped silently: the same "hostile input produces a verdict, never a throw" contract verifyRevocationEntry itself already guarantees, so there is nothing further for a caller to react to. */
38
+ handleRevocationAnnounce(entry: RevocationEntry): Promise<void>;
39
+ /** Append to a target agent's delivery queue, bounded oldest-first (#28). */
40
+ queueDelivery(agentId: string, event: DeliveryEvent): void;
41
+ /**
42
+ * Merge an incoming room record into the local one. Scalar fields follow the version gate the caller already applied (an equal or higher version reaches here), while membership is always element-merged per agent by highest operation revision, so concurrent joins of different agents survive and a kick racing a join converges with the kick honoured (#27). The members and invited views are re-derived from the merged operations.
43
+ */
44
+ private mergeRoom;
45
+ /**
46
+ * Derive the members and invited views from the per-agent operation maps. An agent is in the list when their latest join strictly outranks their latest leave; equal revisions mean the leave wins, so a kick racing a concurrent join converges with the kick honoured (#27).
47
+ */
48
+ refreshMembership(room: Room): void;
49
+ /** Record a membership operation at the room's current revision. */
50
+ recordMemberOp(room: Room, list: "member" | "invited", op: "join" | "leave", agentId: string): void;
51
+ /** Merge per-agent operation maps by highest revision per agent. */
52
+ private static mergeMemberOps;
53
+ /** Bump an entity's sync revision; call before broadcasting a local mutation. */
54
+ bump<T extends {
55
+ version: number;
56
+ }>(entity: T): T;
57
+ /**
58
+ * Merge a peer's state snapshot into the local state. Agents and rooms accept the incoming copy when it carries a revision at least as high as the local one, so a peer holding stale entities converges when it receives a fresher snapshot, while its own stale copies are rejected by peers that stayed current (#27). Message and DM histories are append-only: add unseen entries and union read receipts.
59
+ */
60
+ applyStateSync(state: SerialisedState): void;
61
+ applyPatch(patch: MeshStatePatch): Promise<void>;
62
+ broadcastPatch(patch: MeshStatePatch): Promise<void>;
63
+ deliverLocallyAndBroadcast(agentId: string, event: DeliveryEvent): Promise<void>;
64
+ /**
65
+ * Fire onDelivery for an event targeting this peer's own agent, deduped against events already delivered in this process. Used both for live deliveries and for replays of events that accumulated while this process was down (#28): the dedup set is per-process, so a replayed event this process never saw fires, and one it already handled does not.
66
+ */
67
+ fireLocalDelivery(agentId: string, event: DeliveryEvent): void;
68
+ deliverToRoom(roomId: string, event: DeliveryEvent, excludeAgent?: string): Promise<void>;
69
+ notifyRoomsOfStatus(agentId: string, status: AgentStatus): Promise<void>;
70
+ notifyRoomsOfNameChange(agentId: string, oldName: string, newName: string): Promise<void>;
71
+ private emitDeliveryStatus;
72
+ private findMessageSender;
73
+ /** Like findMessageSender, but also returns the room-path a room.read needs to address: room itself for a room message, or the specific DM key (this.dms is keyed by dmRoomPath/"self:...", not the bare pair) the message was actually found under. */
74
+ private findMessageLocation;
75
+ /**
76
+ * Marks a message read by readBy (always this store's own identity -- see the auto-mark-read timers in fireLocalDelivery and drainDelivery, its only callers) and notifies the message's own author via a directed, wire-authenticated room.read (P3.5), replacing the legacy message_read patch's mesh-wide broadcast: only the author is a genuine audience for "did you read my message" per core/room's own always-voluntary read-receipt design, and a direct request to them is strictly more than the old broadcast actually needed. Silently does nothing beyond the local readBy update when the author is this store itself (a self-DM, or an already-own message) or when this store holds no room:member token for the message's own room-path -- read receipts stay best-effort by design, never a reason to throw.
77
+ */
78
+ private markRead;
79
+ deliver(agentId: string, event: DeliveryEvent): Promise<void>;
80
+ drainDelivery(agentId: string): Promise<DeliveryEvent[]>;
81
+ }
82
+ //# sourceMappingURL=delivery-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delivery-engine.d.ts","sourceRoot":"","sources":["../../src/core/delivery-engine.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAOzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,aAAa,EAEb,SAAS,EAC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