agent-comms 1.29.0 → 1.31.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 (32) 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/identity.d.ts +2 -0
  5. package/dist/core/identity.d.ts.map +1 -1
  6. package/dist/core/identity.js +9 -4
  7. package/dist/core/identity.js.map +1 -1
  8. package/dist/core/wire-mesh-identity.d.ts +7 -0
  9. package/dist/core/wire-mesh-identity.d.ts.map +1 -0
  10. package/dist/core/wire-mesh-identity.js +23 -0
  11. package/dist/core/wire-mesh-identity.js.map +1 -0
  12. package/dist/core/wire-mesh-transport.d.ts +57 -0
  13. package/dist/core/wire-mesh-transport.d.ts.map +1 -0
  14. package/dist/core/wire-mesh-transport.js +466 -0
  15. package/dist/core/wire-mesh-transport.js.map +1 -0
  16. package/dist/test/test-transport.d.ts +4 -0
  17. package/dist/test/test-transport.d.ts.map +1 -1
  18. package/dist/test/test-transport.js +13 -0
  19. package/dist/test/test-transport.js.map +1 -1
  20. package/dist/test/wire-mesh-identity.test.d.ts +5 -0
  21. package/dist/test/wire-mesh-identity.test.d.ts.map +1 -0
  22. package/dist/test/wire-mesh-identity.test.js +27 -0
  23. package/dist/test/wire-mesh-identity.test.js.map +1 -0
  24. package/dist/test/wire-mesh-transport-approval.integration.test.d.ts +5 -0
  25. package/dist/test/wire-mesh-transport-approval.integration.test.d.ts.map +1 -0
  26. package/dist/test/wire-mesh-transport-approval.integration.test.js +164 -0
  27. package/dist/test/wire-mesh-transport-approval.integration.test.js.map +1 -0
  28. package/dist/test/wire-mesh-transport.integration.test.d.ts +5 -0
  29. package/dist/test/wire-mesh-transport.integration.test.d.ts.map +1 -0
  30. package/dist/test/wire-mesh-transport.integration.test.js +89 -0
  31. package/dist/test/wire-mesh-transport.integration.test.js.map +1 -0
  32. package/package.json +2 -2
@@ -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": "1.29.0"
18
+ "version": "1.31.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": "1.29.0",
4
+ "version": "1.31.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-1.29.0-blue)](https://github.com/ExaDev/agent-comms/releases/tag/v1.29.0)
5
+ [![version](https://img.shields.io/badge/version-1.31.0-blue)](https://github.com/ExaDev/agent-comms/releases/tag/v1.31.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.
@@ -42,6 +42,8 @@ export declare function getCertificateFingerprint(certificate: string): string;
42
42
  * Compute the SHA-256 fingerprint of a certificate already presented as raw DER bytes — the shape `tls.TLSSocket.getPeerCertificate().raw` returns for a live connection. Same hashing and formatting as `getCertificateFingerprint`, so a value pinned from a PEM certificate compares equal to the fingerprint of that same certificate presented live over a socket.
43
43
  */
44
44
  export declare function fingerprintDer(der: Buffer): string;
45
+ /** The raw, uncompressed SEC1 public-key point (0x04 || X || Y) for a PEM-encoded EC private key -- what wire-mesh's own device-id and identity-key.public-key are both derived from, never a certificate's DER encoding. */
46
+ export declare function rawPublicKeyFromPrivateKey(privateKeyPem: string): Uint8Array;
45
47
  /** Derives wire-mesh's own device-id (SHA-256 of the raw, uncompressed SEC1 public-key point) from a PEM-encoded EC private key. */
46
48
  export declare function deriveDeviceId(privateKeyPem: string): Uint8Array;
47
49
  //# sourceMappingURL=identity.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/core/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAeH,wGAAwG;AACxG,eAAO,MAAM,uBAAuB,QAA4B,CAAC;AAEjE,MAAM,WAAW,YAAY;IAC3B,sCAAsC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,6EAA6E;IAC7E,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,QAAQ,EAAE,UAAU,CAAC;CACtB;AA6MD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,IAAI,YAAY,CAsE/C;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAGrE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAKlD;AAaD,oIAAoI;AACpI,wBAAgB,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,UAAU,CAYhE"}
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/core/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAeH,wGAAwG;AACxG,eAAO,MAAM,uBAAuB,QAA4B,CAAC;AAEjE,MAAM,WAAW,YAAY;IAC3B,sCAAsC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,6EAA6E;IAC7E,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,QAAQ,EAAE,UAAU,CAAC;CACtB;AA6MD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,IAAI,YAAY,CAsE/C;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAGrE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAKlD;AAaD,6NAA6N;AAC7N,wBAAgB,0BAA0B,CAAC,aAAa,EAAE,MAAM,GAAG,UAAU,CAW5E;AAED,oIAAoI;AACpI,wBAAgB,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,UAAU,CAIhE"}
@@ -256,19 +256,24 @@ function pemToDer(pem) {
256
256
  .replace(/\s/g, "");
257
257
  return Buffer.from(b64, "base64");
258
258
  }
259
- /** Derives wire-mesh's own device-id (SHA-256 of the raw, uncompressed SEC1 public-key point) from a PEM-encoded EC private key. */
260
- export function deriveDeviceId(privateKeyPem) {
259
+ /** The raw, uncompressed SEC1 public-key point (0x04 || X || Y) for a PEM-encoded EC private key -- what wire-mesh's own device-id and identity-key.public-key are both derived from, never a certificate's DER encoding. */
260
+ export function rawPublicKeyFromPrivateKey(privateKeyPem) {
261
261
  const publicKey = createPublicKey(privateKeyPem);
262
262
  const jwk = publicKey.export({ format: "jwk" });
263
263
  if (jwk.x === undefined || jwk.y === undefined) {
264
264
  throw new Error("expected an EC JWK with x/y coordinates");
265
265
  }
266
- const rawPublicKey = Buffer.concat([
266
+ return Buffer.concat([
267
267
  Buffer.from([UNCOMPRESSED_POINT_TAG]),
268
268
  Buffer.from(jwk.x, "base64url"),
269
269
  Buffer.from(jwk.y, "base64url"),
270
270
  ]);
271
- return createHash("sha256").update(rawPublicKey).digest();
271
+ }
272
+ /** Derives wire-mesh's own device-id (SHA-256 of the raw, uncompressed SEC1 public-key point) from a PEM-encoded EC private key. */
273
+ export function deriveDeviceId(privateKeyPem) {
274
+ return createHash("sha256")
275
+ .update(rawPublicKeyFromPrivateKey(privateKeyPem))
276
+ .digest();
272
277
  }
273
278
  /** Encode DER bytes as a PEM certificate string. */
274
279
  function derToCertificatePem(der) {
@@ -1 +1 @@
1
- {"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/core/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,UAAU,EACV,eAAe,EACf,UAAU,EACV,mBAAmB,EACnB,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,sIAAsI;AACtI,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAEpC,+EAA+E;AAE/E,wGAAwG;AACxG,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAejE,8EAA8E;AAE9E,iCAAiC;AACjC,SAAS,SAAS,CAAC,MAAc;IAC/B,IAAI,MAAM,GAAG,IAAI;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAChD,IAAI,MAAM,GAAG,KAAK;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IACvD,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,uCAAuC;AACvC,SAAS,OAAO,CAAC,GAAW,EAAE,OAAe;IAC3C,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QAClB,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC;QACzB,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AAED,oBAAoB;AACpB,SAAS,WAAW,CAAC,GAAG,KAAe;IACrC,OAAO,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,eAAe;AACf,SAAS,MAAM,CAA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H,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Adapts agent-comms' own PeerIdentity (a PEM-encoded ECDSA P-256 keypair plus a self-signed X.509 certificate, identity.ts's own concern) into wire-mesh-core's IdentityPort -- the shape MeshSession and createTlsTransport both expect. Both sides wrap the exact same keypair; only the envelope differs. The certificate itself plays no part here -- IdentityPort's own device-id is derived straight from the raw public key, identically to how identity.ts's own deriveDeviceId already works, so the two stay consistent by construction rather than by convention.
3
+ */
4
+ import type { IdentityPort } from "@exadev/wire-mesh-core/ports/identity";
5
+ import type { PeerIdentity } from "./identity.js";
6
+ export declare function toIdentityPort(identity: Readonly<PeerIdentity>): Promise<IdentityPort>;
7
+ //# sourceMappingURL=wire-mesh-identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-mesh-identity.d.ts","sourceRoot":"","sources":["../../src/core/wire-mesh-identity.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAelD,wBAAsB,cAAc,CAClC,QAAQ,EAAE,QAAQ,CAAC,YAAY,CAAC,GAC/B,OAAO,CAAC,YAAY,CAAC,CAWvB"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Adapts agent-comms' own PeerIdentity (a PEM-encoded ECDSA P-256 keypair plus a self-signed X.509 certificate, identity.ts's own concern) into wire-mesh-core's IdentityPort -- the shape MeshSession and createTlsTransport both expect. Both sides wrap the exact same keypair; only the envelope differs. The certificate itself plays no part here -- IdentityPort's own device-id is derived straight from the raw public key, identically to how identity.ts's own deriveDeviceId already works, so the two stay consistent by construction rather than by convention.
3
+ */
4
+ import { webcrypto } from "node:crypto";
5
+ import { createNodeIdentity } from "@exadev/wire-mesh-core/adapters/node-identity";
6
+ import { rawPublicKeyFromPrivateKey } from "./identity.js";
7
+ /** COSE algorithm identifier for ES256 (P-256 + SHA-256) -- wire-mesh's own identity-key.alg convention. */
8
+ const ES256 = -7;
9
+ /** Strips a PEM envelope down to its raw DER bytes, copied into a fresh, non-shared, whole-buffer Uint8Array -- Web Crypto's BufferSource parameters reject a view over a SharedArrayBuffer or a sub-range view, neither of which Buffer.from's return type is guaranteed not to be. */
10
+ function pemToDer(pem, label) {
11
+ const b64 = pem
12
+ .replace(new RegExp(`-----BEGIN ${label}-----`), "")
13
+ .replace(new RegExp(`-----END ${label}-----`), "")
14
+ .replace(/\s/g, "");
15
+ return Uint8Array.from(Buffer.from(b64, "base64"));
16
+ }
17
+ export async function toIdentityPort(identity) {
18
+ const privateKeyDer = pemToDer(identity.privateKey, "PRIVATE KEY");
19
+ const privateKey = await webcrypto.subtle.importKey("pkcs8", privateKeyDer, { name: "ECDSA", namedCurve: "P-256" }, true, ["sign"]);
20
+ const publicKeyBytes = rawPublicKeyFromPrivateKey(identity.privateKey);
21
+ return createNodeIdentity(privateKey, publicKeyBytes, ES256);
22
+ }
23
+ //# sourceMappingURL=wire-mesh-identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-mesh-identity.js","sourceRoot":"","sources":["../../src/core/wire-mesh-identity.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AAGnF,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAE3D,4GAA4G;AAC5G,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC;AAEjB,wRAAwR;AACxR,SAAS,QAAQ,CAAC,GAAW,EAAE,KAAa;IAC1C,MAAM,GAAG,GAAG,GAAG;SACZ,OAAO,CAAC,IAAI,MAAM,CAAC,cAAc,KAAK,OAAO,CAAC,EAAE,EAAE,CAAC;SACnD,OAAO,CAAC,IAAI,MAAM,CAAC,YAAY,KAAK,OAAO,CAAC,EAAE,EAAE,CAAC;SACjD,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACtB,OAAO,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,QAAgC;IAEhC,MAAM,aAAa,GAAG,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IACnE,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,SAAS,CACjD,OAAO,EACP,aAAa,EACb,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,EACtC,IAAI,EACJ,CAAC,MAAM,CAAC,CACT,CAAC;IACF,MAAM,cAAc,GAAG,0BAA0B,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IACvE,OAAO,kBAAkB,CAAC,UAAU,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * WireMeshTransport — MeshTransport implemented over @exadev/wire-mesh-core, carrying the existing MeshMessage union as an opaque payload rather than inventing new wire semantics. This is the P2 substrate swap's own deliverable: MeshStore, CommsTool, and every existing agent/room/message behaviour above the transport are completely unaffected -- only how bytes move between peers changes.
3
+ *
4
+ * Every agent-comms MeshMessage rides as a single namespaced manage-command verb (FRAME_VERB) under one flat scope (FRAME_SCOPE); the message itself is carried opaquely in the command's own params.message field. This needs no spec/CDDL change: manage-command-params is already an open `{* tstr => any}` socket for exactly this purpose.
5
+ *
6
+ * Peer identity is authenticated at the transport layer, not asserted on the wire: createTlsTransport verifies a peer's presented certificate cryptographically and exposes the result as Connection.peerDeviceId before any MeshMessage is ever exchanged, which is what lets the `pong` self-identification message retire entirely -- there is nothing left for it to prove that the connection itself hasn't already proven.
7
+ *
8
+ * connect_request's accept/reject flow maps onto sendManageRequest's own request/response round trip directly, rather than a separate pair of connect_accepted/connect_rejected messages: manage-request-frame already tolerates arbitrary latency between a request and its response, so "waiting for a human to approve" is simply a manage-response that hasn't been sent yet, not a protocol gap needing its own mechanism. connect_request therefore holds its own IncomingManageRequest open (rather than responding immediately) until acceptConnection/rejectConnection is actually called.
9
+ */
10
+ import type { MeshMessage, PeerInfo } from "./wire-protocol.js";
11
+ import type { ConnectionHandle, ListenerInfo, ListenerPolicy, MeshTransport, TransportEvents } from "./transport.js";
12
+ import type { PeerIdentity } from "./identity.js";
13
+ export declare class WireMeshTransport implements MeshTransport {
14
+ private readonly wireTransport;
15
+ private readonly events;
16
+ private readonly identityReady;
17
+ private _dataPort;
18
+ private _isCoordinator;
19
+ private shutDown;
20
+ /** A method call, not a direct property read -- deliberately, so TS's control-flow narrowing (which does track `this.shutDown` as staying false for the rest of a function once an early `if (this.shutDown) return` has passed, with no awareness that an `await` in between gave a concurrent shutdown() call the chance to flip it) doesn't treat every later re-check in the same async function as unreachable. Each of these re-checks is real: shutdown() can run at any time this function is suspended on an await. */
21
+ private isShuttingDown;
22
+ private dataListener;
23
+ private coordinatorListeners;
24
+ private defaultListenerId;
25
+ private coordinatorSession;
26
+ private peerSessions;
27
+ private allSessions;
28
+ /** Registers a session in both peerSessions (addressing -- last one in for a given peer wins) and allSessions (shutdown -- every session, always). */
29
+ private trackSession;
30
+ private dataDials;
31
+ private pendingConnections;
32
+ constructor(events: TransportEvents, identity: Readonly<PeerIdentity>);
33
+ get dataPort(): number;
34
+ get isCoordinator(): boolean;
35
+ get hasCoordinatorConnection(): boolean;
36
+ private handleAcceptedConnection;
37
+ private consumeIncoming;
38
+ private dispatchIncoming;
39
+ /** Routes an already-decoded MeshMessage to the matching TransportEvents callback -- the same dispatch regardless of which listener (coordinator or data) accepted the connection it arrived on, since the message's own method, not the port it arrived on, is what determines meaning. */
40
+ private route;
41
+ private watchForDisconnect;
42
+ startDataServer(): Promise<void>;
43
+ connectToCoordinator(host: string, port: number, peerId: string, dataPort: number): Promise<void>;
44
+ becomeCoordinator(host: string, port: number): Promise<void>;
45
+ connectToPeer(peer: PeerInfo, _ownPeerId: string): Promise<void>;
46
+ send(handle: ConnectionHandle, message: MeshMessage): Promise<void>;
47
+ broadcast(message: MeshMessage): Promise<void>;
48
+ connectToRemote(host: string, port: number, peerId: string, dataPort: number, name: string, fingerprint: string): Promise<void>;
49
+ acceptConnection(handle: ConnectionHandle): Promise<void>;
50
+ rejectConnection(handle: ConnectionHandle, reason: string): Promise<void>;
51
+ addListener(host: string, port: number, policy: ListenerPolicy): Promise<string>;
52
+ removeListener(id: string): Promise<void>;
53
+ listListeners(): ListenerInfo[];
54
+ shutdown(): Promise<void>;
55
+ unref(): void;
56
+ }
57
+ //# sourceMappingURL=wire-mesh-transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-mesh-transport.d.ts","sourceRoot":"","sources":["../../src/core/wire-mesh-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAmBH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,aAAa,EACb,eAAe,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AA6DlD,qBAAa,iBAAkB,YAAW,aAAa;IACrD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAY;IAC1C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;IACzC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAE5B;IAEF,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAS;IAEzB,ggBAAggB;IAChgB,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,YAAY,CAAuB;IAG3C,OAAO,CAAC,oBAAoB,CAAsC;IAClE,OAAO,CA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B,OAAO,CAAC,IAAI,CAAC;IA+BV,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBzD,gBAAgB,CACpB,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC;IAoBV,WAAW,CACf,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,MAAM,CAAC;IAkBZ,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU/C,aAAa,IAAI,YAAY,EAAE;IAczB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IA8B/B,KAAK,IAAI,IAAI;CAMd"}
@@ -0,0 +1,466 @@
1
+ /**
2
+ * WireMeshTransport — MeshTransport implemented over @exadev/wire-mesh-core, carrying the existing MeshMessage union as an opaque payload rather than inventing new wire semantics. This is the P2 substrate swap's own deliverable: MeshStore, CommsTool, and every existing agent/room/message behaviour above the transport are completely unaffected -- only how bytes move between peers changes.
3
+ *
4
+ * Every agent-comms MeshMessage rides as a single namespaced manage-command verb (FRAME_VERB) under one flat scope (FRAME_SCOPE); the message itself is carried opaquely in the command's own params.message field. This needs no spec/CDDL change: manage-command-params is already an open `{* tstr => any}` socket for exactly this purpose.
5
+ *
6
+ * Peer identity is authenticated at the transport layer, not asserted on the wire: createTlsTransport verifies a peer's presented certificate cryptographically and exposes the result as Connection.peerDeviceId before any MeshMessage is ever exchanged, which is what lets the `pong` self-identification message retire entirely -- there is nothing left for it to prove that the connection itself hasn't already proven.
7
+ *
8
+ * connect_request's accept/reject flow maps onto sendManageRequest's own request/response round trip directly, rather than a separate pair of connect_accepted/connect_rejected messages: manage-request-frame already tolerates arbitrary latency between a request and its response, so "waiting for a human to approve" is simply a manage-response that hasn't been sent yet, not a protocol gap needing its own mechanism. connect_request therefore holds its own IncomingManageRequest open (rather than responding immediately) until acceptConnection/rejectConnection is actually called.
9
+ */
10
+ import { createTlsTransport } from "@exadev/wire-mesh-core/adapters/tls-transport";
11
+ import { acceptMeshSession, } from "@exadev/wire-mesh-core/domain/mesh-session";
12
+ import { deviceIdToHex } from "@exadev/wire-mesh-core/domain/device-id";
13
+ import { isMeshMessage } from "./wire-protocol.js";
14
+ import { toIdentityPort } from "./wire-mesh-identity.js";
15
+ import { nanoid } from "./nanoid.js";
16
+ // ---------------------------------------------------------------------------
17
+ // Constants
18
+ // ---------------------------------------------------------------------------
19
+ const COORDINATOR_HOST = "127.0.0.1";
20
+ /** This project's own namespaced domain (registrant "exadev.io", local name "agent-comms-v1"), matching namespaced-domain-id's "<registrant>/<local-name>" shape -- registry/core-domains.md's own recommended pattern for a third party. */
21
+ const DOMAIN = "exadev.io/agent-comms-v1";
22
+ /** One verb for the entire MeshMessage union: this phase carries every message opaquely rather than modelling each arm as its own verb, which is core/room's own job once P3 gives this substrate real room semantics. */
23
+ const FRAME_VERB = "exadev.io/agent-comms-v1:frame";
24
+ /** No finer-grained authorisation model exists above "you're a TLS-authenticated member of this mesh" at this phase -- exactly today's TlsTransport model, which does no per-message authorisation either. */
25
+ const FRAME_SCOPE = { kind: "agent-comms-mesh" };
26
+ // ---------------------------------------------------------------------------
27
+ // Message carriage
28
+ // ---------------------------------------------------------------------------
29
+ function buildCommand(message) {
30
+ return { verb: FRAME_VERB, params: { message } };
31
+ }
32
+ /** Extracts and validates the carried MeshMessage from an incoming command. Returns undefined for anything that isn't a well-formed frame -- an unrecognised or malformed payload is dropped, not thrown, the same tolerance TlsTransport's own frame parser already extends to input it can't make sense of. */
33
+ function extractMessage(command) {
34
+ if (command.verb !== FRAME_VERB)
35
+ return undefined;
36
+ const params = command.params;
37
+ if (typeof params !== "object" || params === null)
38
+ return undefined;
39
+ if (!("message" in params))
40
+ return undefined;
41
+ const message = params.message;
42
+ return isMeshMessage(message) ? message : undefined;
43
+ }
44
+ // ---------------------------------------------------------------------------
45
+ // WireMeshTransport
46
+ // ---------------------------------------------------------------------------
47
+ export class WireMeshTransport {
48
+ wireTransport;
49
+ events;
50
+ identityReady;
51
+ _dataPort = 0;
52
+ _isCoordinator = false;
53
+ shutDown = false;
54
+ /** A method call, not a direct property read -- deliberately, so TS's control-flow narrowing (which does track `this.shutDown` as staying false for the rest of a function once an early `if (this.shutDown) return` has passed, with no awareness that an `await` in between gave a concurrent shutdown() call the chance to flip it) doesn't treat every later re-check in the same async function as unreachable. Each of these re-checks is real: shutdown() can run at any time this function is suspended on an await. */
55
+ isShuttingDown() {
56
+ return this.shutDown;
57
+ }
58
+ // -- Data server (accepts data connections from already-known peers) --
59
+ dataListener;
60
+ // -- Coordinator listeners (the well-known bootstrap port, plus any additional adapters addListener creates) --
61
+ coordinatorListeners = new Map();
62
+ defaultListenerId;
63
+ // -- The session dialled via connectToCoordinator, when this instance is not itself the coordinator --
64
+ coordinatorSession;
65
+ // -- Every live session, keyed by the peer's authenticated device-id hex (== ConnectionHandle.id) -- covers coordinator-client, coordinator-accepted, and peer data sessions alike, since send()/broadcast() must reach whichever kind of session a peer happens to be reachable through. A single-slot-per-key map by construction: mesh formation genuinely establishes TWO independent sessions to the same peer (see the dataDials comment below), and the second one registered here simply overwrites the first as far as addressing goes -- fine for send()/broadcast() (either socket reaches the same peer), but NOT fine for shutdown, which must close every live session regardless of whether it's still reachable through this map. allSessions below exists specifically so shutdown never leaks the one this map's overwrite silently stopped tracking.
66
+ peerSessions = new Map();
67
+ // -- Every live session this transport has ever created, accepted or dialled, for shutdown's own use only -- never used for addressing (peerSessions is), so it never loses track of one session to another sharing the same peer id.
68
+ allSessions = new Set();
69
+ /** Registers a session in both peerSessions (addressing -- last one in for a given peer wins) and allSessions (shutdown -- every session, always). */
70
+ trackSession(key, session) {
71
+ this.peerSessions.set(key, session);
72
+ this.allSessions.add(session);
73
+ }
74
+ // -- Peers this side has dialled via connectToPeer specifically (in flight or established) -- deliberately separate from peerSessions, which also holds sessions this side reached the SAME peer through for an unrelated reason (most concretely, the coordinator-client session connectToCoordinator opens to the coordinator's own device-id). Mesh formation deliberately establishes a second, independent connection in each direction so each side's own acceptor can push its own state (see mesh-store.ts's own handlePeerConnected), so connectToPeer's "don't dial twice" guard must not be satisfied by an unrelated session that merely happens to share the same peer ID.
75
+ dataDials = new Set();
76
+ // -- connect_request frames awaiting a human accept/reject decision, keyed by the requester's device-id hex --
77
+ pendingConnections = new Map();
78
+ constructor(events, identity) {
79
+ this.events = events;
80
+ this.wireTransport = createTlsTransport({
81
+ certificatePem: identity.certificate,
82
+ privateKeyPem: identity.privateKey,
83
+ });
84
+ this.identityReady = toIdentityPort(identity);
85
+ }
86
+ // -- Public getters --
87
+ get dataPort() {
88
+ return this._dataPort;
89
+ }
90
+ get isCoordinator() {
91
+ return this._isCoordinator;
92
+ }
93
+ get hasCoordinatorConnection() {
94
+ return this.coordinatorSession !== undefined;
95
+ }
96
+ // -----------------------------------------------------------------------
97
+ // Connection acceptance -- shared by every listener (coordinator or data)
98
+ // -----------------------------------------------------------------------
99
+ async handleAcceptedConnection(connection, policy, fireOnPeerConnected) {
100
+ if (this.shutDown) {
101
+ await connection.close();
102
+ return;
103
+ }
104
+ const peerDeviceId = connection.peerDeviceId;
105
+ if (peerDeviceId === undefined) {
106
+ // No certificate presented at all -- nothing to authenticate this peer against.
107
+ await connection.close();
108
+ return;
109
+ }
110
+ const deviceIdHex = deviceIdToHex(peerDeviceId);
111
+ const identity = await this.identityReady;
112
+ const session = await acceptMeshSession(connection, identity, [DOMAIN]);
113
+ if (this.isShuttingDown()) {
114
+ await session.close();
115
+ return;
116
+ }
117
+ this.trackSession(deviceIdHex, session);
118
+ // ConnectionHandle.policy is `?: ListenerPolicy`, not `?: ListenerPolicy | undefined` -- under exactOptionalPropertyTypes these are genuinely different types, so the key must be entirely absent rather than present-with-undefined-value when this listener has no policy of its own.
119
+ const handle = {
120
+ id: deviceIdHex,
121
+ ...(policy !== undefined ? { policy } : {}),
122
+ };
123
+ if (fireOnPeerConnected) {
124
+ const info = {
125
+ id: deviceIdHex,
126
+ port: 0,
127
+ startedAt: new Date().toISOString(),
128
+ };
129
+ this.events.onPeerConnected(handle, info);
130
+ }
131
+ this.consumeIncoming(session, handle);
132
+ this.watchForDisconnect(session, handle, deviceIdHex);
133
+ }
134
+ consumeIncoming(session, handle) {
135
+ void (async () => {
136
+ for await (const request of session.incomingManageRequests) {
137
+ if (this.shutDown)
138
+ break;
139
+ await this.dispatchIncoming(request, handle);
140
+ }
141
+ })();
142
+ }
143
+ async dispatchIncoming(request, handle) {
144
+ const message = extractMessage(request.command);
145
+ if (message === undefined) {
146
+ await request.respond({ result: "ok" }).catch(() => undefined);
147
+ return;
148
+ }
149
+ if (message.method === "connect_request") {
150
+ // Held open deliberately -- see this file's own header comment. Answered later by acceptConnection/rejectConnection, not here.
151
+ this.pendingConnections.set(handle.id, {
152
+ respond: request.respond,
153
+ dataPort: message.dataPort,
154
+ name: message.name,
155
+ fingerprint: message.fingerprint,
156
+ policy: handle.policy,
157
+ });
158
+ this.events.onConnectionRequest(handle, {
159
+ peerId: handle.id,
160
+ dataPort: message.dataPort,
161
+ name: message.name,
162
+ fingerprint: message.fingerprint,
163
+ });
164
+ return;
165
+ }
166
+ this.route(handle, message);
167
+ await request.respond({ result: "ok" }).catch(() => undefined);
168
+ }
169
+ /** Routes an already-decoded MeshMessage to the matching TransportEvents callback -- the same dispatch regardless of which listener (coordinator or data) accepted the connection it arrived on, since the message's own method, not the port it arrived on, is what determines meaning. */
170
+ route(handle, message) {
171
+ switch (message.method) {
172
+ case "introduce": {
173
+ this.events.onIntroduction(handle, {
174
+ peerId: handle.id,
175
+ dataPort: message.dataPort,
176
+ });
177
+ return;
178
+ }
179
+ case "peer_list": {
180
+ this.events.onPeerList(message.peers);
181
+ return;
182
+ }
183
+ case "peer_joined": {
184
+ this.events.onPeerJoined(message.peer);
185
+ return;
186
+ }
187
+ case "become_coordinator": {
188
+ this.events.onBecomeCoordinator(message.peerList);
189
+ return;
190
+ }
191
+ case "connect_accepted":
192
+ case "connect_rejected": {
193
+ // Never constructed by this transport -- connectToRemote's own sendManageRequest outcome carries this meaning directly. Dropped rather than treated as an error in case a future peer still sends one (forward compatibility with anything else speaking this same opaque-frame domain).
194
+ return;
195
+ }
196
+ default: {
197
+ this.events.onMessage(handle, message);
198
+ }
199
+ }
200
+ }
201
+ watchForDisconnect(session, handle, deviceIdHex) {
202
+ void (async () => {
203
+ for await (const event of session.events) {
204
+ if (event.state.status === "closed") {
205
+ const wasTracked = this.peerSessions.get(deviceIdHex) === session;
206
+ if (wasTracked)
207
+ this.peerSessions.delete(deviceIdHex);
208
+ this.allSessions.delete(session);
209
+ this.pendingConnections.delete(deviceIdHex);
210
+ // A no-op when this session was never a connectToPeer dial (e.g. the coordinator-client or an accepted connection) -- Set.delete on an absent key is always safe.
211
+ this.dataDials.delete(deviceIdHex);
212
+ if (wasTracked && !this.shutDown) {
213
+ this.events.onPeerDisconnected(handle);
214
+ }
215
+ return;
216
+ }
217
+ }
218
+ })();
219
+ }
220
+ // -----------------------------------------------------------------------
221
+ // MeshTransport -- Data server
222
+ // -----------------------------------------------------------------------
223
+ async startDataServer() {
224
+ this.dataListener = await this.wireTransport.listen(`${COORDINATOR_HOST}:0`, (connection) => {
225
+ void this.handleAcceptedConnection(connection, undefined, true);
226
+ });
227
+ const port = this.dataListener.address.split(":").pop();
228
+ this._dataPort = port === undefined ? 0 : Number(port);
229
+ }
230
+ // -----------------------------------------------------------------------
231
+ // MeshTransport -- Coordinator connection (client side)
232
+ // -----------------------------------------------------------------------
233
+ async connectToCoordinator(host, port, peerId, dataPort) {
234
+ const connection = await this.wireTransport.connect(`${host}:${String(port)}`);
235
+ const identity = await this.identityReady;
236
+ const session = await acceptMeshSession(connection, identity, [DOMAIN]);
237
+ this.coordinatorSession = session;
238
+ const coordinatorDeviceId = connection.peerDeviceId;
239
+ if (coordinatorDeviceId !== undefined) {
240
+ const handle = {
241
+ id: deviceIdToHex(coordinatorDeviceId),
242
+ };
243
+ this.trackSession(handle.id, session);
244
+ this.consumeIncoming(session, handle);
245
+ this.watchForDisconnect(session, handle, handle.id);
246
+ }
247
+ // Fire-and-forget, matching the previous transport's own contract: this resolves once the introduction is sent, not once a response arrives -- peer_list/peer_joined/become_coordinator arrive asynchronously via the normal dispatch path above, independent of this call's own promise.
248
+ void session
249
+ .sendManageRequest(buildCommand({ method: "introduce", peerId, dataPort }), FRAME_SCOPE)
250
+ .catch(() => undefined);
251
+ }
252
+ // -----------------------------------------------------------------------
253
+ // MeshTransport -- Become coordinator (server side)
254
+ // -----------------------------------------------------------------------
255
+ async becomeCoordinator(host, port) {
256
+ const id = nanoid(8);
257
+ const listener = await this.wireTransport.listen(`${host}:${String(port)}`, (connection) => {
258
+ const tracked = this.coordinatorListeners.get(id);
259
+ void this.handleAcceptedConnection(connection, tracked?.policy, false);
260
+ });
261
+ this._isCoordinator = true;
262
+ this.coordinatorListeners.set(id, {
263
+ listener,
264
+ policy: "full",
265
+ host,
266
+ port,
267
+ isDefault: true,
268
+ });
269
+ this.defaultListenerId = id;
270
+ }
271
+ // -----------------------------------------------------------------------
272
+ // MeshTransport -- Peer-to-peer data connections
273
+ // -----------------------------------------------------------------------
274
+ async connectToPeer(peer, _ownPeerId) {
275
+ if (this.shutDown || this.dataDials.has(peer.id))
276
+ return;
277
+ this.dataDials.add(peer.id);
278
+ const connection = await this.wireTransport
279
+ .connect(`${COORDINATOR_HOST}:${String(peer.port)}`)
280
+ .catch((error) => {
281
+ this.events.onError?.(error instanceof Error
282
+ ? new Error(`connectToPeer(${peer.id}, port ${String(peer.port)}): ${error.message}`)
283
+ : new Error(`connectToPeer(${peer.id}, port ${String(peer.port)}) failed`));
284
+ return undefined;
285
+ });
286
+ if (connection === undefined || this.isShuttingDown()) {
287
+ this.dataDials.delete(peer.id);
288
+ return;
289
+ }
290
+ const peerDeviceId = connection.peerDeviceId;
291
+ if (peerDeviceId === undefined) {
292
+ this.dataDials.delete(peer.id);
293
+ await connection.close();
294
+ return;
295
+ }
296
+ const deviceIdHex = deviceIdToHex(peerDeviceId);
297
+ if (deviceIdHex !== peer.id) {
298
+ // The peer we reached does not hold the key peer.id claims to name -- refuse exactly like a mismatched fingerprint would have under the previous transport.
299
+ this.events.onError?.(new Error(`connectToPeer: peer at port ${String(peer.port)} authenticated as ${deviceIdHex}, expected ${peer.id}`));
300
+ this.dataDials.delete(peer.id);
301
+ await connection.close();
302
+ return;
303
+ }
304
+ const identity = await this.identityReady;
305
+ const session = await acceptMeshSession(connection, identity, [DOMAIN]);
306
+ if (this.isShuttingDown()) {
307
+ this.dataDials.delete(peer.id);
308
+ await session.close();
309
+ return;
310
+ }
311
+ this.trackSession(deviceIdHex, session);
312
+ const handle = { id: deviceIdHex };
313
+ this.consumeIncoming(session, handle);
314
+ this.watchForDisconnect(session, handle, deviceIdHex);
315
+ }
316
+ // -----------------------------------------------------------------------
317
+ // MeshTransport -- Send / broadcast
318
+ // -----------------------------------------------------------------------
319
+ async send(handle, message) {
320
+ const session = this.peerSessions.get(handle.id);
321
+ if (session === undefined)
322
+ return;
323
+ await session
324
+ .sendManageRequest(buildCommand(message), FRAME_SCOPE)
325
+ .catch((error) => {
326
+ this.events.onError?.(error instanceof Error
327
+ ? error
328
+ : new Error(`send(${handle.id}) failed: ${String(error)}`));
329
+ });
330
+ }
331
+ async broadcast(message) {
332
+ const command = buildCommand(message);
333
+ await Promise.all([...this.peerSessions.values()].map((session) => session.sendManageRequest(command, FRAME_SCOPE).catch(() => undefined)));
334
+ }
335
+ // -----------------------------------------------------------------------
336
+ // MeshTransport -- Connection approval (connectToRemote flow)
337
+ // -----------------------------------------------------------------------
338
+ async connectToRemote(host, port, peerId, dataPort, name, fingerprint) {
339
+ const connection = await this.wireTransport.connect(`${host}:${String(port)}`);
340
+ const identity = await this.identityReady;
341
+ const session = await acceptMeshSession(connection, identity, [DOMAIN]);
342
+ const outcome = await session.sendManageRequest(buildCommand({
343
+ method: "connect_request",
344
+ peerId,
345
+ dataPort,
346
+ name,
347
+ fingerprint,
348
+ }), FRAME_SCOPE);
349
+ if (outcome.result === "error") {
350
+ await session.close();
351
+ throw new Error(outcome.message ?? outcome.code);
352
+ }
353
+ const coordinatorDeviceId = connection.peerDeviceId;
354
+ if (coordinatorDeviceId !== undefined) {
355
+ const handle = {
356
+ id: deviceIdToHex(coordinatorDeviceId),
357
+ };
358
+ this.trackSession(handle.id, session);
359
+ this.consumeIncoming(session, handle);
360
+ this.watchForDisconnect(session, handle, handle.id);
361
+ }
362
+ }
363
+ async acceptConnection(handle) {
364
+ const pending = this.pendingConnections.get(handle.id);
365
+ if (pending === undefined) {
366
+ throw new Error(`No pending connection for handle ${handle.id}`);
367
+ }
368
+ this.pendingConnections.delete(handle.id);
369
+ await pending.respond({ result: "ok" });
370
+ const acceptedHandle = {
371
+ id: handle.id,
372
+ ...(pending.policy !== undefined ? { policy: pending.policy } : {}),
373
+ };
374
+ this.events.onIntroduction(acceptedHandle, {
375
+ peerId: handle.id,
376
+ dataPort: pending.dataPort,
377
+ });
378
+ }
379
+ async rejectConnection(handle, reason) {
380
+ const pending = this.pendingConnections.get(handle.id);
381
+ if (pending === undefined) {
382
+ throw new Error(`No pending connection for handle ${handle.id}`);
383
+ }
384
+ this.pendingConnections.delete(handle.id);
385
+ await pending.respond({
386
+ result: "error",
387
+ code: "rejected",
388
+ message: reason,
389
+ });
390
+ const session = this.peerSessions.get(handle.id);
391
+ this.peerSessions.delete(handle.id);
392
+ if (session !== undefined)
393
+ await session.close();
394
+ }
395
+ // -----------------------------------------------------------------------
396
+ // MeshTransport -- Listener management
397
+ // -----------------------------------------------------------------------
398
+ async addListener(host, port, policy) {
399
+ const id = nanoid(8);
400
+ const listener = await this.wireTransport.listen(`${host}:${String(port)}`, (connection) => {
401
+ void this.handleAcceptedConnection(connection, policy, false);
402
+ });
403
+ this.coordinatorListeners.set(id, {
404
+ listener,
405
+ policy,
406
+ host,
407
+ port,
408
+ isDefault: false,
409
+ });
410
+ return id;
411
+ }
412
+ async removeListener(id) {
413
+ if (id === this.defaultListenerId) {
414
+ throw new Error("Cannot remove the default listener");
415
+ }
416
+ const tracked = this.coordinatorListeners.get(id);
417
+ if (tracked === undefined)
418
+ return;
419
+ this.coordinatorListeners.delete(id);
420
+ await tracked.listener.close();
421
+ }
422
+ listListeners() {
423
+ return [...this.coordinatorListeners.entries()].map(([id, tracked]) => ({
424
+ id,
425
+ host: tracked.host,
426
+ port: tracked.port,
427
+ policy: tracked.policy,
428
+ isDefault: tracked.isDefault,
429
+ }));
430
+ }
431
+ // -----------------------------------------------------------------------
432
+ // MeshTransport -- Shutdown / unref
433
+ // -----------------------------------------------------------------------
434
+ async shutdown() {
435
+ this.shutDown = true;
436
+ this.dataDials.clear();
437
+ for (const pending of this.pendingConnections.values()) {
438
+ await pending
439
+ .respond({ result: "error", code: "shutting_down" })
440
+ .catch(() => undefined);
441
+ }
442
+ this.pendingConnections.clear();
443
+ // Every live session, whichever of possibly several to the same peer -- peerSessions alone would only close the last one registered under a shared key, leaving any other (e.g. the coordinator-client session to a peer this side also has a data connection to) still open and accepting, which would make the listener it belongs to wait forever for it to end.
444
+ for (const session of this.allSessions) {
445
+ await session.close().catch(() => undefined);
446
+ }
447
+ this.allSessions.clear();
448
+ this.peerSessions.clear();
449
+ this.coordinatorSession = undefined;
450
+ if (this.dataListener !== undefined) {
451
+ await this.dataListener.close();
452
+ this.dataListener = undefined;
453
+ }
454
+ for (const tracked of this.coordinatorListeners.values()) {
455
+ await tracked.listener.close();
456
+ }
457
+ this.coordinatorListeners.clear();
458
+ }
459
+ unref() {
460
+ this.dataListener?.unref?.();
461
+ for (const tracked of this.coordinatorListeners.values()) {
462
+ tracked.listener.unref?.();
463
+ }
464
+ }
465
+ }
466
+ //# sourceMappingURL=wire-mesh-transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-mesh-transport.js","sourceRoot":"","sources":["../../src/core/wire-mesh-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAA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AAK,EAAE,CAAC;QAEhC,oWAAoW;QACpW,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACvC,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC/C,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC1B,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;QAEpC,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACpC,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;YAChC,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;QAChC,CAAC;QAED,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,EAAE,CAAC;YACzD,MAAM,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACjC,CAAC;QACD,IAAI,CAAC,oBAAoB,CAAC,KAAK,EAAE,CAAC;IACpC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,YAAY,EAAE,KAAK,EAAE,EAAE,CAAC;QAC7B,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,EAAE,CAAC;YACzD,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC;QAC7B,CAAC;IACH,CAAC;CACF"}
@@ -1,6 +1,10 @@
1
1
  /** Wires a real TlsTransport with a freshly generated identity onto a freshly constructed MeshStore -- the same setTransport() call every production bridge makes immediately after construction. MeshStore has no default transport, so every test that constructs one needs this (or an equivalent explicit setTransport() call) before init() or any other transport-using method runs. */
2
2
  import type { MeshStore } from "../core/mesh-store.js";
3
3
  export declare function wireTestTransport(store: MeshStore): void;
4
+ /**
5
+ * Wires a real WireMeshTransport onto a freshly constructed MeshStore -- the P2 substrate swap's own analogue of wireTestTransport above. Sets peerId to deviceIdToHex(identity.deviceId) rather than the certificate fingerprint: production bridges don't cut MeshStore.peerId over to this until step 4 of the migration's own sequencing, but WireMeshTransport's own internal session bookkeeping is already keyed by device-id, so a test exercising it end-to-end through a real MeshStore needs the two identity spaces to actually correlate.
6
+ */
7
+ export declare function wireWireMeshTestTransport(store: MeshStore): void;
4
8
  /**
5
9
  * Polls condition() until it returns true or timeoutMs elapses, rather than a fixed sleep() before a single check. A real TLS handshake plus the peer_list -> connectToPeer -> state_sync -> handlePeerConnected round trip genuinely takes variable, load-dependent wall-clock time -- comfortably inside a fixed sleep on a fast local machine, not reliably so under a throttled CI runner. Throws with a descriptive message on timeout rather than letting the caller's own assertion fail with a less specific one.
6
10
  */
@@ -1 +1 @@
1
- {"version":3,"file":"test-transport.d.ts","sourceRoot":"","sources":["../../src/test/test-transport.ts"],"names":[],"mappings":"AAAA,8XAA8X;AAI9X,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CASxD;AAMD;;GAEG;AACH,wBAAsB,OAAO,CAC3B,SAAS,EAAE,MAAM,OAAO,EACxB,WAAW,EAAE,MAAM,EACnB,SAAS,SAA8B,GACtC,OAAO,CAAC,IAAI,CAAC,CAYf"}
1
+ {"version":3,"file":"test-transport.d.ts","sourceRoot":"","sources":["../../src/test/test-transport.ts"],"names":[],"mappings":"AAAA,8XAA8X;AAM9X,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CASxD;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAOhE;AAMD;;GAEG;AACH,wBAAsB,OAAO,CAC3B,SAAS,EAAE,MAAM,OAAO,EACxB,WAAW,EAAE,MAAM,EACnB,SAAS,SAA8B,GACtC,OAAO,CAAC,IAAI,CAAC,CAYf"}
@@ -1,6 +1,8 @@
1
1
  /** Wires a real TlsTransport with a freshly generated identity onto a freshly constructed MeshStore -- the same setTransport() call every production bridge makes immediately after construction. MeshStore has no default transport, so every test that constructs one needs this (or an equivalent explicit setTransport() call) before init() or any other transport-using method runs. */
2
2
  import { TlsTransport } from "../core/tls-transport.js";
3
+ import { WireMeshTransport } from "../core/wire-mesh-transport.js";
3
4
  import { generateIdentity } from "../core/identity.js";
5
+ import { deviceIdToHex } from "@exadev/wire-mesh-core/domain/device-id";
4
6
  export function wireTestTransport(store) {
5
7
  const identity = generateIdentity();
6
8
  // Every real bridge sets peerId to the identity's own certificate fingerprint before wiring the transport -- TlsTransport's cert-pinning trust model means a peer's advertised ID and the fingerprint the other side actually authenticates the connection against must be the same value, or introduction/state-sync never recognises the peer as itself.
@@ -11,6 +13,17 @@ export function wireTestTransport(store) {
11
13
  console.error(`[transport error, peerId=${store.peerId}]`, e.message);
12
14
  };
13
15
  }
16
+ /**
17
+ * Wires a real WireMeshTransport onto a freshly constructed MeshStore -- the P2 substrate swap's own analogue of wireTestTransport above. Sets peerId to deviceIdToHex(identity.deviceId) rather than the certificate fingerprint: production bridges don't cut MeshStore.peerId over to this until step 4 of the migration's own sequencing, but WireMeshTransport's own internal session bookkeeping is already keyed by device-id, so a test exercising it end-to-end through a real MeshStore needs the two identity spaces to actually correlate.
18
+ */
19
+ export function wireWireMeshTestTransport(store) {
20
+ const identity = generateIdentity();
21
+ store.peerId = deviceIdToHex(Uint8Array.from(identity.deviceId));
22
+ store.setTransport(new WireMeshTransport(store.events, identity));
23
+ store.onError = (e) => {
24
+ console.error(`[transport error, peerId=${store.peerId}]`, e.message);
25
+ };
26
+ }
14
27
  // Generous on purpose: waitFor returns the instant its condition holds, so a long ceiling costs nothing on the happy path (a local run settles in well under a second) and only matters for the worst case -- a loaded CI runner working through a real, sequential chain of TLS handshakes (each one genuine X.509 certificate work, not instant) for the accept-flow's second connection direction, confirmed to need meaningfully more than 5s on at least one real CI run.
15
28
  const DEFAULT_WAIT_FOR_TIMEOUT_MS = 20_000;
16
29
  const WAIT_FOR_POLL_INTERVAL_MS = 20;
@@ -1 +1 @@
1
- {"version":3,"file":"test-transport.js","sourceRoot":"","sources":["../../src/test/test-transport.ts"],"names":[],"mappings":"AAAA,8XAA8X;AAE9X,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGvD,MAAM,UAAU,iBAAiB,CAAC,KAAgB;IAChD,MAAM,QAAQ,GAAG,gBAAgB,EAAE,CAAC;IACpC,2VAA2V;IAC3V,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,WAAW,CAAC;IACpC,KAAK,CAAC,YAAY,CAAC,IAAI,YAAY,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC7D,4PAA4P;IAC5P,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,EAAE,EAAE;QACpB,OAAO,CAAC,KAAK,CAAC,4BAA4B,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;IACxE,CAAC,CAAC;AACJ,CAAC;AAED,+cAA+c;AAC/c,MAAM,2BAA2B,GAAG,MAAM,CAAC;AAC3C,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAErC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,SAAwB,EACxB,WAAmB,EACnB,SAAS,GAAG,2BAA2B;IAEvC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;IACxC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;QACpB,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,QAAQ,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CACb,2BAA2B,MAAM,CAAC,SAAS,CAAC,OAAO,WAAW,EAAE,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AO,GAAG,CAAC,CAAC,EAAE,EAAE;QACpB,OAAO,CAAC,KAAK,CAAC,4BAA4B,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;IACxE,CAAC,CAAC;AACJ,CAAC;AAED,+cAA+c;AAC/c,MAAM,2BAA2B,GAAG,MAAM,CAAC;AAC3C,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAErC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,SAAwB,EACxB,WAAmB,EACnB,SAAS,GAAG,2BAA2B;IAEvC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;IACxC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;QACpB,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,QAAQ,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CACb,2BAA2B,MAAM,CAAC,SAAS,CAAC,OAAO,WAAW,EAAE,CACjE,CAAC;QACJ,CAAC;QACD,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAC5B,UAAU,CAAC,OAAO,EAAE,yBAAyB,CAAC,CAC/C,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * toIdentityPort must produce the identical device-id identity.ts's own deriveDeviceId already computes for the same keypair -- the two are meant to be the same identity wrapped in two different envelopes, not two independent derivations that happen to usually agree.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=wire-mesh-identity.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-mesh-identity.test.d.ts","sourceRoot":"","sources":["../../src/test/wire-mesh-identity.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * toIdentityPort must produce the identical device-id identity.ts's own deriveDeviceId already computes for the same keypair -- the two are meant to be the same identity wrapped in two different envelopes, not two independent derivations that happen to usually agree.
3
+ */
4
+ import * as assert from "node:assert/strict";
5
+ import { test } from "node:test";
6
+ import { generateIdentity } from "../core/identity.js";
7
+ import { toIdentityPort } from "../core/wire-mesh-identity.js";
8
+ void test("toIdentityPort's deviceId matches identity.ts's own deriveDeviceId", async () => {
9
+ const identity = generateIdentity();
10
+ const port = await toIdentityPort(identity);
11
+ assert.equal(Buffer.from(port.deviceId).toString("hex"), Buffer.from(identity.deviceId).toString("hex"));
12
+ });
13
+ void test("toIdentityPort can sign and verify its own signature", async () => {
14
+ const identity = generateIdentity();
15
+ const port = await toIdentityPort(identity);
16
+ const message = Buffer.from("hello wire-mesh");
17
+ const signature = await port.sign(message);
18
+ const valid = await port.verify(port.identityKey, message, signature);
19
+ assert.equal(valid, true);
20
+ });
21
+ void test("toIdentityPort's own deriveDeviceId agrees with its own deviceId for its own key", async () => {
22
+ const identity = generateIdentity();
23
+ const port = await toIdentityPort(identity);
24
+ const rederived = await port.deriveDeviceId(port.identityKey["public-key"]);
25
+ assert.equal(Buffer.from(rederived).toString("hex"), Buffer.from(port.deviceId).toString("hex"));
26
+ });
27
+ //# sourceMappingURL=wire-mesh-identity.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-mesh-identity.test.js","sourceRoot":"","sources":["../../src/test/wire-mesh-identity.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,KAAK,IAAI,CAAC,oEAAoE,EAAE,KAAK,IAAI,EAAE;IACzF,MAAM,QAAQ,GAAG,gBAAgB,EAAE,CAAC;IACpC,MAAM,IAAI,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,CAAC,KAAK,CACV,MAAM,CAAC,IAAI,CA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ection-approval flow (connectToRemote/acceptConnection/rejectConnection) and listener management, mirroring approval.integration.test.ts's own scenarios against the new substrate.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=wire-mesh-transport-approval.integration.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-mesh-transport-approval.integration.test.d.ts","sourceRoot":"","sources":["../../src/test/wire-mesh-transport-approval.integration.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,164 @@
1
+ /**
2
+ * Parity test for WireMeshTransport's connection-approval flow (connectToRemote/acceptConnection/rejectConnection) and listener management, mirroring approval.integration.test.ts's own scenarios against the new substrate.
3
+ */
4
+ import * as assert from "node:assert/strict";
5
+ import { test, describe } from "node:test";
6
+ import * as net from "node:net";
7
+ import { MeshStore } from "../core/mesh-store.js";
8
+ import { waitFor, wireWireMeshTestTransport } from "./test-transport.js";
9
+ function findFreePort() {
10
+ return new Promise((resolve, reject) => {
11
+ const server = net.createServer();
12
+ server.listen(0, "127.0.0.1", () => {
13
+ const addr = server.address();
14
+ const port = typeof addr === "object" && addr !== null ? addr.port : 0;
15
+ server.close(() => resolve(port));
16
+ });
17
+ server.on("error", reject);
18
+ });
19
+ }
20
+ let portOffset = 0;
21
+ async function uniquePort() {
22
+ portOffset += 10;
23
+ const base = await findFreePort();
24
+ return base + portOffset;
25
+ }
26
+ describe("WireMeshTransport connection approval", () => {
27
+ void test("accept establishes the peer connection", async () => {
28
+ const portA = await uniquePort();
29
+ const portB = portA + 100;
30
+ const storeA = new MeshStore(portA);
31
+ wireWireMeshTestTransport(storeA);
32
+ const storeB = new MeshStore(portB);
33
+ wireWireMeshTestTransport(storeB);
34
+ try {
35
+ const receivedRequests = [];
36
+ storeA.onDelivery = (_id, event) => {
37
+ if (event.type === "connection_request") {
38
+ receivedRequests.push(event);
39
+ }
40
+ };
41
+ await storeA.init();
42
+ await storeA.registerAgent({
43
+ name: "coordinator",
44
+ harness: "test",
45
+ cwd: "/test/a",
46
+ pid: process.pid,
47
+ visibility: "visible",
48
+ tags: [],
49
+ });
50
+ await storeB.startDataServerOnly();
51
+ await storeB.registerAgent({
52
+ name: "connector",
53
+ harness: "test",
54
+ cwd: "/test/b",
55
+ pid: process.pid,
56
+ visibility: "visible",
57
+ tags: [],
58
+ });
59
+ storeB.connectToRemote("127.0.0.1", portA);
60
+ await waitFor(() => receivedRequests.length === 1, "coordinator receives the connection request");
61
+ const request = receivedRequests[0];
62
+ assert.ok(request?.connectionId);
63
+ await storeA.acceptConnection(request.connectionId);
64
+ await waitFor(() => storeA.serialise().agents[storeB.peerId] !== undefined, "coordinator sees the connector agent");
65
+ await waitFor(() => storeB.serialise().agents[storeA.peerId] !== undefined, "connector sees the coordinator agent");
66
+ const agentsA = await storeA.listAgents(storeA.peerId);
67
+ const agentsB = await storeB.listAgents(storeB.peerId);
68
+ assert.ok(agentsA.some((a) => a.id === storeB.peerId), "Coordinator should see the connector agent");
69
+ assert.ok(agentsB.some((a) => a.id === storeA.peerId), "Connector should see the coordinator agent");
70
+ }
71
+ finally {
72
+ await storeB.shutdown();
73
+ await storeA.shutdown();
74
+ }
75
+ });
76
+ void test("reject closes with reason", async () => {
77
+ const portA = await uniquePort();
78
+ const portB = portA + 100;
79
+ const storeA = new MeshStore(portA);
80
+ wireWireMeshTestTransport(storeA);
81
+ const storeB = new MeshStore(portB);
82
+ wireWireMeshTestTransport(storeB);
83
+ try {
84
+ const receivedRequests = [];
85
+ storeA.onDelivery = (_id, event) => {
86
+ if (event.type === "connection_request") {
87
+ receivedRequests.push(event);
88
+ }
89
+ };
90
+ await storeA.init();
91
+ await storeA.registerAgent({
92
+ name: "coordinator",
93
+ harness: "test",
94
+ cwd: "/test/a",
95
+ pid: process.pid,
96
+ visibility: "visible",
97
+ tags: [],
98
+ });
99
+ await storeB.startDataServerOnly();
100
+ await storeB.registerAgent({
101
+ name: "connector",
102
+ harness: "test",
103
+ cwd: "/test/b",
104
+ pid: process.pid,
105
+ visibility: "visible",
106
+ tags: [],
107
+ });
108
+ storeB.connectToRemote("127.0.0.1", portA);
109
+ await waitFor(() => receivedRequests.length === 1, "coordinator receives the connection request");
110
+ const request = receivedRequests[0];
111
+ assert.ok(request?.connectionId);
112
+ await storeA.rejectConnection(request.connectionId, "unauthorised");
113
+ await waitFor(() => storeA.listPendingConnections().length === 0, "the pending connection clears");
114
+ const agentsA = await storeA.listAgents(storeA.peerId);
115
+ assert.ok(!agentsA.some((a) => a.id === storeB.peerId), "Rejected peer should not appear in agent list");
116
+ }
117
+ finally {
118
+ await storeB.shutdown();
119
+ await storeA.shutdown();
120
+ }
121
+ });
122
+ });
123
+ describe("WireMeshTransport listener management", () => {
124
+ void test("addListener creates an additional listener; removeListener removes it", async () => {
125
+ const port = await uniquePort();
126
+ const store = new MeshStore(port);
127
+ wireWireMeshTestTransport(store);
128
+ try {
129
+ await store.init();
130
+ const before = store.listListeners();
131
+ assert.strictEqual(before.length, 1, "starts with just the default listener");
132
+ assert.ok(before[0]?.isDefault);
133
+ const extraPort = await uniquePort();
134
+ const id = await store.addListener("127.0.0.1", extraPort, "observe");
135
+ const afterAdd = store.listListeners();
136
+ assert.strictEqual(afterAdd.length, 2);
137
+ const added = afterAdd.find((l) => l.id === id);
138
+ assert.ok(added);
139
+ assert.strictEqual(added.policy, "observe");
140
+ assert.strictEqual(added.isDefault, false);
141
+ await store.removeListener(id);
142
+ const afterRemove = store.listListeners();
143
+ assert.strictEqual(afterRemove.length, 1);
144
+ }
145
+ finally {
146
+ await store.shutdown();
147
+ }
148
+ });
149
+ void test("removeListener rejects removing the default listener", async () => {
150
+ const port = await uniquePort();
151
+ const store = new MeshStore(port);
152
+ wireWireMeshTestTransport(store);
153
+ try {
154
+ await store.init();
155
+ const [defaultListener] = store.listListeners();
156
+ assert.ok(defaultListener);
157
+ await assert.rejects(() => store.removeListener(defaultListener.id));
158
+ }
159
+ finally {
160
+ await store.shutdown();
161
+ }
162
+ });
163
+ });
164
+ //# sourceMappingURL=wire-mesh-transport-approval.integration.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-mesh-transport-approval.integration.test.js","sourceRoot":"","sources":["../../src/test/wire-mesh-transport-approval.integration.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAEzE,SAAS,YAAY;IACnB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC;QAClC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,WAAW,EAAE,GAAG,EAAE;YACjC,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;YAC9B,MAAM,IAAI,GAAG,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YACvE,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,IAAI,UAAU,GAAG,CAAC,CAAC;AACnB,KAAK,UAAU,UAAU;IACvB,UAAU,IAAI,EAAE,CAAC;IACjB,MAAM,IAAI,GAAG,MAAM,YAAY,EAAE,CAAC;IAClC,OAAO,IAAI,GAAG,UAAU,CAAC;AAC3B,CAAC;AAED,QAAQ,CAAC,uCAAuC,EAAE,GA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E,CAAC;YAChD,MAAM,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC;YAC3B,MAAM,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC;QACvE,CAAC;gBAAS,CAAC;YACT,MAAM,KAAK,CAAC,QAAQ,EAAE,CAAC;QACzB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * End-to-end parity test for WireMeshTransport, mirroring mesh-e2e.integration.test.ts's own scenario (coordinator discovery, room creation, messaging, delivery push) but against the new substrate instead of TlsTransport -- the concrete proof this phase's own charter ("semantics unchanged") holds for the core mesh-formation path, using waitFor polling rather than fixed sleeps for the same reason approval.integration.test.ts already does.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=wire-mesh-transport.integration.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-mesh-transport.integration.test.d.ts","sourceRoot":"","sources":["../../src/test/wire-mesh-transport.integration.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * End-to-end parity test for WireMeshTransport, mirroring mesh-e2e.integration.test.ts's own scenario (coordinator discovery, room creation, messaging, delivery push) but against the new substrate instead of TlsTransport -- the concrete proof this phase's own charter ("semantics unchanged") holds for the core mesh-formation path, using waitFor polling rather than fixed sleeps for the same reason approval.integration.test.ts already does.
3
+ */
4
+ import * as assert from "node:assert/strict";
5
+ import { test } from "node:test";
6
+ import { MeshStore } from "../core/mesh-store.js";
7
+ import { CommsTool } from "../core/tool.js";
8
+ import { buildAction } from "../core/bridge.js";
9
+ import { waitFor, wireWireMeshTestTransport } from "./test-transport.js";
10
+ async function createStore(port, name, harness) {
11
+ const store = new MeshStore(port);
12
+ wireWireMeshTestTransport(store);
13
+ const deliveries = [];
14
+ store.onDelivery = (_agentId, event) => {
15
+ deliveries.push(event);
16
+ };
17
+ const tool = new CommsTool(store);
18
+ await store.init();
19
+ await store.registerAgent({
20
+ name,
21
+ harness,
22
+ cwd: `/test/${name}`,
23
+ pid: process.pid,
24
+ visibility: "visible",
25
+ tags: [],
26
+ });
27
+ return { store, tool, deliveries };
28
+ }
29
+ void test("WireMeshTransport: coordinator discovery, rooms, messaging, and delivery match TlsTransport's own semantics", async () => {
30
+ const port = 20_000 + Math.floor(Math.random() * 1000);
31
+ const a = await createStore(port, "peer-a", "test-a");
32
+ let b;
33
+ try {
34
+ b = await createStore(port, "peer-b", "test-b");
35
+ await waitFor(() => a.store.serialise().agents[b?.store.peerId ?? ""] !== undefined, "A sees B's agent");
36
+ await waitFor(() => b?.store.serialise().agents[a.store.peerId] !== undefined, "B sees A's agent");
37
+ const agentsA = await a.store.listAgents(a.store.peerId);
38
+ const agentsB = await b.store.listAgents(b.store.peerId);
39
+ assert.ok(agentsA.length >= 2, "A should see both agents");
40
+ assert.ok(agentsB.length >= 2, "B should see both agents");
41
+ const roomId = `test-room-${String(Date.now())}`;
42
+ const room = await a.store.createRoom({
43
+ name: roomId,
44
+ type: "public",
45
+ owner: a.store.peerId,
46
+ description: "Test room",
47
+ });
48
+ await waitFor(() => b?.store.serialise().rooms[room.id] !== undefined, "B sees the room");
49
+ await b.store.joinRoom(room.id, b.store.peerId);
50
+ await waitFor(() => a.store.serialise().rooms[room.id]?.members.length === 2, "A sees B join the room");
51
+ const roomA = await a.store.getRoom(room.id);
52
+ const roomB = await b.store.getRoom(room.id);
53
+ assert.strictEqual(roomA?.members.length, 2, "A should see 2 room members");
54
+ assert.strictEqual(roomB?.members.length, 2, "B should see 2 room members");
55
+ b.deliveries.length = 0;
56
+ await a.store.sendRoomMessage(room.id, a.store.peerId, "Hello from A!");
57
+ await waitFor(() => b?.deliveries.length !== 0, "B receives the room message");
58
+ const roomMsg = b.deliveries[0];
59
+ assert.ok(roomMsg);
60
+ assert.strictEqual(roomMsg.type, "room_message");
61
+ assert.strictEqual(roomMsg.message.content, "Hello from A!");
62
+ b.deliveries.length = 0;
63
+ await a.store.sendDm(a.store.peerId, b.store.peerId, "Hey B!");
64
+ await waitFor(() => b?.deliveries.length !== 0, "B receives the DM");
65
+ const dmEvent = b.deliveries[0];
66
+ assert.ok(dmEvent);
67
+ assert.strictEqual(dmEvent.type, "dm");
68
+ const messages = await b.store.readRoomMessages(room.id);
69
+ assert.ok(messages.length >= 1, "B should see the message");
70
+ a.deliveries.length = 0;
71
+ const action = buildAction({
72
+ action: "send",
73
+ target: room.id,
74
+ content: "Hello from B via tool!",
75
+ });
76
+ await b.tool.handle({
77
+ agentId: b.store.peerId,
78
+ harness: "test-b",
79
+ cwd: "/test/peer-b",
80
+ pid: process.pid,
81
+ }, action);
82
+ await waitFor(() => a.deliveries.length !== 0, "A receives B's tool-sent message");
83
+ }
84
+ finally {
85
+ await b?.store.shutdown();
86
+ await a.store.shutdown();
87
+ }
88
+ });
89
+ //# sourceMappingURL=wire-mesh-transport.integration.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-mesh-transport.integration.test.js","sourceRoot":"","sources":["../../src/test/wire-mesh-transport.integration.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAEzE,KAAK,UAAU,WAAW,CACxB,IAAY,EACZ,IAAY,EACZ,OAAe;IAEf,MAAM,KAAK,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;IAClC,yBAAyB,CAAC,KAAK,CAAC,CAAC;IAEjC,MAAM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,CAAC,CAAC,CAAC,CAAC;QAChC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;QACnB,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAEvC,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzD,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,EAAE,0BAA0B,CAAC,CAAC;QAE5D,CAAC,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;QACxB,MAAM,MAAM,GAAG,WAAW,CAAC;YACzB,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,IAAI,CAAC,EAAE;YACf,OAAO,EAAE,wBAAwB;SAClC,CAAC,CAAC;QACH,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CACjB;YACE,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM;YACvB,OAAO,EAAE,QAAQ;YACjB,GAAG,EAAE,cAAc;YACnB,GAAG,EAAE,OAAO,CAAC,GAAG;SACjB,EACD,MAAM,CACP,CAAC;QACF,MAAM,OAAO,CACX,GAAG,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAC/B,kCAAkC,CACnC,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC1B,MAAM,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;AACH,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-comms",
3
- "version": "1.29.0",
3
+ "version": "1.31.0",
4
4
  "description": "Cross-harness communication mesh for LLM agents — rooms, DMs, presence, and real-time push delivery over TCP",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@10.33.0",
@@ -52,7 +52,7 @@
52
52
  "generate:server-json": "tsx scripts/sync-release-metadata.ts",
53
53
  "publish:mcp-registry": "tsx scripts/publish-mcp-registry.ts",
54
54
  "lint": "eslint .",
55
- "test": "node --test --test-concurrency=1 dist/test/coordinator-socket-error.integration.test.js dist/test/identity-store.test.js dist/test/identity-cert.test.js dist/test/identity-device-id.test.js dist/test/broadcast-window.integration.test.js dist/test/identity-restart.integration.test.js dist/test/mesh-e2e.integration.test.js dist/test/tls-transport.integration.test.js dist/test/peer-id-verification.integration.test.js dist/test/become-coordinator-actual-port.integration.test.js dist/test/state-sync-convergence.test.js dist/test/downtime-replay.test.js dist/test/downtime-replay.integration.test.js dist/test/filestore.test.js dist/test/handshake.test.js dist/test/approval.integration.test.js dist/test/listener-policy.integration.test.js dist/test/mesh-smoke.integration.test.js",
55
+ "test": "node --test --test-concurrency=1 dist/test/coordinator-socket-error.integration.test.js dist/test/identity-store.test.js dist/test/identity-cert.test.js dist/test/identity-device-id.test.js dist/test/wire-mesh-identity.test.js dist/test/broadcast-window.integration.test.js dist/test/identity-restart.integration.test.js dist/test/mesh-e2e.integration.test.js dist/test/tls-transport.integration.test.js dist/test/peer-id-verification.integration.test.js dist/test/become-coordinator-actual-port.integration.test.js dist/test/state-sync-convergence.test.js dist/test/downtime-replay.test.js dist/test/downtime-replay.integration.test.js dist/test/filestore.test.js dist/test/handshake.test.js dist/test/approval.integration.test.js dist/test/listener-policy.integration.test.js dist/test/mesh-smoke.integration.test.js dist/test/wire-mesh-transport.integration.test.js dist/test/wire-mesh-transport-approval.integration.test.js",
56
56
  "test:visibility": "node --test dist/test/visibility.integration.test.js",
57
57
  "test:delivery": "node dist/test/delivery-receipt.runner.js",
58
58
  "test:federation": "node dist/test/federation.integration.test.js",