agent-comms 3.20.0 → 3.22.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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +1 -1
- package/dist/bridges/cc-peer/front-runtime.d.ts.map +1 -1
- package/dist/bridges/cc-peer/front-runtime.js +2 -1
- package/dist/bridges/cc-peer/front-runtime.js.map +1 -1
- package/dist/bridges/cc-peer/run.d.ts.map +1 -1
- package/dist/bridges/cc-peer/run.js +2 -1
- package/dist/bridges/cc-peer/run.js.map +1 -1
- package/dist/bridges/user/web/actions.d.ts +59 -0
- package/dist/bridges/user/web/actions.d.ts.map +1 -0
- package/dist/bridges/user/web/actions.js +109 -0
- package/dist/bridges/user/web/actions.js.map +1 -0
- package/dist/bridges/user/web/contract.d.ts +1796 -0
- package/dist/bridges/user/web/contract.d.ts.map +1 -0
- package/dist/bridges/user/web/contract.js +120 -0
- package/dist/bridges/user/web/contract.js.map +1 -0
- package/dist/bridges/user/web/dist/bundle.js +1 -1
- package/dist/bridges/user/web/dist/sw.js +1 -1
- package/dist/bridges/user/web/event-publisher.d.ts +30 -0
- package/dist/bridges/user/web/event-publisher.d.ts.map +1 -0
- package/dist/bridges/user/web/event-publisher.js +84 -0
- package/dist/bridges/user/web/event-publisher.js.map +1 -0
- package/dist/bridges/user/web/frontend/components/App.d.ts.map +1 -1
- package/dist/bridges/user/web/frontend/components/App.js +1 -1
- package/dist/bridges/user/web/frontend/components/App.js.map +1 -1
- package/dist/bridges/user/web/frontend/components/ChatArea.d.ts +3 -2
- package/dist/bridges/user/web/frontend/components/ChatArea.d.ts.map +1 -1
- package/dist/bridges/user/web/frontend/components/ChatArea.js +6 -2
- package/dist/bridges/user/web/frontend/components/ChatArea.js.map +1 -1
- package/dist/bridges/user/web/frontend/main.js +5 -2
- package/dist/bridges/user/web/frontend/main.js.map +1 -1
- package/dist/bridges/user/web/router.d.ts +696 -0
- package/dist/bridges/user/web/router.d.ts.map +1 -0
- package/dist/bridges/user/web/router.js +50 -0
- package/dist/bridges/user/web/router.js.map +1 -0
- package/dist/bridges/user/web/server.d.ts +2 -0
- package/dist/bridges/user/web/server.d.ts.map +1 -1
- package/dist/bridges/user/web/server.js +94 -114
- package/dist/bridges/user/web/server.js.map +1 -1
- package/dist/bridges/user/web/test/contract.unit.test.d.ts +2 -0
- package/dist/bridges/user/web/test/contract.unit.test.d.ts.map +1 -0
- package/dist/bridges/user/web/test/contract.unit.test.js +56 -0
- package/dist/bridges/user/web/test/contract.unit.test.js.map +1 -0
- package/dist/bridges/user/web/test/orpc-router.integration.test.d.ts +7 -0
- package/dist/bridges/user/web/test/orpc-router.integration.test.d.ts.map +1 -0
- package/dist/bridges/user/web/test/orpc-router.integration.test.js +214 -0
- package/dist/bridges/user/web/test/orpc-router.integration.test.js.map +1 -0
- package/dist/core/bridge-mesh.d.ts +2 -0
- package/dist/core/bridge-mesh.d.ts.map +1 -1
- package/dist/core/bridge-mesh.js +5 -1
- package/dist/core/bridge-mesh.js.map +1 -1
- package/dist/core/bridge.d.ts +4 -0
- package/dist/core/bridge.d.ts.map +1 -1
- package/dist/core/bridge.js +19 -0
- package/dist/core/bridge.js.map +1 -1
- package/dist/core/data-frame-routing.d.ts +14 -0
- package/dist/core/data-frame-routing.d.ts.map +1 -0
- package/dist/core/data-frame-routing.js +37 -0
- package/dist/core/data-frame-routing.js.map +1 -0
- package/dist/core/gossip-directory.d.ts +11 -2
- package/dist/core/gossip-directory.d.ts.map +1 -1
- package/dist/core/gossip-directory.js +32 -4
- package/dist/core/gossip-directory.js.map +1 -1
- package/dist/core/hub-session.d.ts +5 -1
- package/dist/core/hub-session.d.ts.map +1 -1
- package/dist/core/hub-session.js +24 -0
- package/dist/core/hub-session.js.map +1 -1
- package/dist/core/mesh-graph-trace-tool.d.ts +12 -0
- package/dist/core/mesh-graph-trace-tool.d.ts.map +1 -0
- package/dist/core/mesh-graph-trace-tool.js +60 -0
- package/dist/core/mesh-graph-trace-tool.js.map +1 -0
- package/dist/core/mesh-graph.d.ts +14 -0
- package/dist/core/mesh-graph.d.ts.map +1 -0
- package/dist/core/mesh-graph.js +46 -0
- package/dist/core/mesh-graph.js.map +1 -0
- package/dist/core/mesh-network-actions.d.ts +28 -0
- package/dist/core/mesh-network-actions.d.ts.map +1 -0
- package/dist/core/mesh-network-actions.js +143 -0
- package/dist/core/mesh-network-actions.js.map +1 -0
- package/dist/core/mesh-store.d.ts +19 -1
- package/dist/core/mesh-store.d.ts.map +1 -1
- package/dist/core/mesh-store.js +56 -0
- package/dist/core/mesh-store.js.map +1 -1
- package/dist/core/package-version.d.ts +4 -0
- package/dist/core/package-version.d.ts.map +1 -1
- package/dist/core/package-version.js +2 -1
- package/dist/core/package-version.js.map +1 -1
- package/dist/core/peer-versions.d.ts +16 -0
- package/dist/core/peer-versions.d.ts.map +1 -0
- package/dist/core/peer-versions.js +42 -0
- package/dist/core/peer-versions.js.map +1 -0
- package/dist/core/room-lifecycle.d.ts +5 -5
- package/dist/core/room-lifecycle.d.ts.map +1 -1
- package/dist/core/room-lifecycle.js +11 -5
- package/dist/core/room-lifecycle.js.map +1 -1
- package/dist/core/room-lookup.d.ts +9 -0
- package/dist/core/room-lookup.d.ts.map +1 -0
- package/dist/core/room-lookup.js +26 -0
- package/dist/core/room-lookup.js.map +1 -0
- package/dist/core/room-messaging.d.ts +2 -2
- package/dist/core/room-messaging.d.ts.map +1 -1
- package/dist/core/room-messaging.js +5 -2
- package/dist/core/room-messaging.js.map +1 -1
- package/dist/core/tool.d.ts +19 -10
- package/dist/core/tool.d.ts.map +1 -1
- package/dist/core/tool.js +25 -151
- package/dist/core/tool.js.map +1 -1
- package/dist/core/transport.d.ts +39 -0
- package/dist/core/transport.d.ts.map +1 -1
- package/dist/core/types.d.ts +18 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +10 -0
- package/dist/core/types.js.map +1 -1
- package/dist/core/version-report-actions.d.ts +18 -0
- package/dist/core/version-report-actions.d.ts.map +1 -0
- package/dist/core/version-report-actions.js +51 -0
- package/dist/core/version-report-actions.js.map +1 -0
- package/dist/core/wire-mesh-core-version.d.ts +6 -0
- package/dist/core/wire-mesh-core-version.d.ts.map +1 -0
- package/dist/core/wire-mesh-core-version.js +20 -0
- package/dist/core/wire-mesh-core-version.js.map +1 -0
- package/dist/core/wire-mesh-transport.d.ts +11 -2
- package/dist/core/wire-mesh-transport.d.ts.map +1 -1
- package/dist/core/wire-mesh-transport.js +29 -46
- package/dist/core/wire-mesh-transport.js.map +1 -1
- package/dist/test/agent-comms-version-gossip.integration.test.d.ts +5 -0
- package/dist/test/agent-comms-version-gossip.integration.test.d.ts.map +1 -0
- package/dist/test/agent-comms-version-gossip.integration.test.js +103 -0
- package/dist/test/agent-comms-version-gossip.integration.test.js.map +1 -0
- package/dist/test/mesh-graph-trace-tool.test.d.ts +2 -0
- package/dist/test/mesh-graph-trace-tool.test.d.ts.map +1 -0
- package/dist/test/mesh-graph-trace-tool.test.js +104 -0
- package/dist/test/mesh-graph-trace-tool.test.js.map +1 -0
- package/dist/test/mesh-graph-trace.integration.test.d.ts +5 -0
- package/dist/test/mesh-graph-trace.integration.test.d.ts.map +1 -0
- package/dist/test/mesh-graph-trace.integration.test.js +146 -0
- package/dist/test/mesh-graph-trace.integration.test.js.map +1 -0
- package/dist/test/peer-versions.test.d.ts +5 -0
- package/dist/test/peer-versions.test.d.ts.map +1 -0
- package/dist/test/peer-versions.test.js +68 -0
- package/dist/test/peer-versions.test.js.map +1 -0
- package/dist/test/query-version.integration.test.d.ts +5 -0
- package/dist/test/query-version.integration.test.d.ts.map +1 -0
- package/dist/test/query-version.integration.test.js +64 -0
- package/dist/test/query-version.integration.test.js.map +1 -0
- package/dist/test/send-by-room-name.test.d.ts +5 -0
- package/dist/test/send-by-room-name.test.d.ts.map +1 -0
- package/dist/test/send-by-room-name.test.js +77 -0
- package/dist/test/send-by-room-name.test.js.map +1 -0
- package/dist/test/tool-version-reporting.test.js +38 -0
- package/dist/test/tool-version-reporting.test.js.map +1 -1
- package/dist/test/version-report-actions.test.d.ts +5 -0
- package/dist/test/version-report-actions.test.d.ts.map +1 -0
- package/dist/test/version-report-actions.test.js +88 -0
- package/dist/test/version-report-actions.test.js.map +1 -0
- package/dist/test/wire-mesh-core-version.test.d.ts +5 -0
- package/dist/test/wire-mesh-core-version.test.d.ts.map +1 -0
- package/dist/test/wire-mesh-core-version.test.js +14 -0
- package/dist/test/wire-mesh-core-version.test.js.map +1 -0
- package/package.json +6 -3
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { deviceIdToHex } from "wire-mesh-core/domain/device-id";
|
|
5
5
|
import { AgentStatus } from "./types.js";
|
|
6
|
+
import { getOwnPackageVersion } from "./package-version.js";
|
|
6
7
|
import { AGENT_SELF_GOSSIP_KEY, HOSTED_ROOMS_GOSSIP_KEY, PRESENCE_GOSSIP_KEY, } from "./wire-mesh-transport.js";
|
|
8
|
+
import { AGENT_COMMS_VERSION_GOSSIP_KEY, } from "./peer-versions.js";
|
|
7
9
|
/** Merges one session event's own directory into the mesh-wide knownDevices view (mutated in place), keeping the newer advert (by snapshot-seconds) whenever a device-id is already known from an earlier event or a different session. */
|
|
8
10
|
export function mergeKnownDevices(knownDevices, directory) {
|
|
9
11
|
for (const entry of directory) {
|
|
@@ -15,6 +17,13 @@ export function mergeKnownDevices(knownDevices, directory) {
|
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
}
|
|
20
|
+
/** Every device this side has ever heard gossip from, mesh-wide -- not just its own directly-connected peers -- with each one's own latest full advert (addresses, snapshot-seconds, and every open-extension field such as presence/status). The trivial array-conversion half of WireMeshTransport's own listKnownDevices, split out purely to keep that file under the repo's max-lines cap, the same reason mergeKnownDevices above already lives here rather than there. */
|
|
21
|
+
export function listKnownDevicesEntries(knownDevices) {
|
|
22
|
+
return Array.from(knownDevices, ([deviceId, advert]) => ({
|
|
23
|
+
deviceId,
|
|
24
|
+
advert,
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
18
27
|
/** Reads a presence extension from one specific device's own gossiped self-advert, if this event's directory carries a fresh one for exactly that device-id -- never for any other device-id a multi-hop directory might mention, since only the session's own authenticated peer's advert is that session's business to report. Returns undefined for a missing presence/status key, or a value that isn't a recognised AgentStatus -- an advert simply not participating in this convention, not an error (the same verifier obligation peer-advert's own open extension tail is documented under). */
|
|
19
28
|
export function findPresenceAdvert(deviceIdHex, directory) {
|
|
20
29
|
const entry = directory.find((candidate) => deviceIdToHex(candidate.device) === deviceIdHex);
|
|
@@ -23,8 +32,10 @@ export function findPresenceAdvert(deviceIdHex, directory) {
|
|
|
23
32
|
const status = entry.advert[PRESENCE_GOSSIP_KEY];
|
|
24
33
|
return AgentStatus.is(status) ? status : undefined;
|
|
25
34
|
}
|
|
26
|
-
/** Re-sends this side's own current presence status
|
|
27
|
-
export function readvertiseGossip(allSessions, hub, hasAnyTrustedGateway, onError, getCurrentPresence, getHostedRooms, getSelfAgentAdvert
|
|
35
|
+
/** Re-sends this side's own current presence status, currently-hosted rooms, self-agent identity, and package versions, together, onto every live session's gossip self-advert -- one gossip frame per tick carrying whichever facts are actually known, rather than a separate frame per fact. Split out of wire-mesh-transport.ts's own WireMeshTransport class purely to keep that file under the repo's max-lines cap, the same reason mergeKnownDevices/findPresenceAdvert above already live here rather than there. A session that fails to send (mid-disconnect, most likely -- watchForDisconnect will independently notice and clean it up) is reported via onError and skipped, not allowed to stop the tick from reaching the rest of allSessions: a periodic broadcast to N peers is N independent operations, not one atomic unit. Unlike presence/hostedRooms/selfAgentAdvert, the versions extension is never actually absent (this side's own agent-comms package version is always known), so every tick this function is called for sends at least that one fact -- there is no "nothing to report" case left to short-circuit on. The hub's own session (agent-comms#156) is gated separately from every ordinary local-peer session in allSessions: local mesh trust is a different layer (connect_request/introduce approval already gated it before it ever joined allSessions), but the hub session is a broadcast to every connected hub peer, trusted or not, and would otherwise leak this side's own presence/hosted-rooms/self-agent/versions advert onto the hub regardless of GatewayTrust -- forwardAdvertsToHub/pushHubCatchUp's own hasAny gate exists to prevent exactly this for OTHER local peers' adverts, and this side's own self-advert deserves the identical gate, not a bypass. */
|
|
36
|
+
export function readvertiseGossip(allSessions, hub, hasAnyTrustedGateway, onError, getCurrentPresence, getHostedRooms, getSelfAgentAdvert,
|
|
37
|
+
/** Reads this side's own currently-running cc-peer version, when this process is fronting/bridging one -- folded into the same AGENT_COMMS_VERSION_GOSSIP_KEY advert as this side's own always-known agent-comms package version (agent-comms#198). Unlike presence/hostedRooms/selfAgentAdvert, agent-comms' own version is never genuinely absent (getOwnPackageVersion() always answers), so the versions extension is built and included unconditionally whenever this function runs at all -- there is no "no version to report" case the way there is for the other three optional facts. */
|
|
38
|
+
getCcPeerVersion) {
|
|
28
39
|
const extensions = {};
|
|
29
40
|
const status = getCurrentPresence?.();
|
|
30
41
|
if (status !== undefined)
|
|
@@ -35,8 +46,12 @@ export function readvertiseGossip(allSessions, hub, hasAnyTrustedGateway, onErro
|
|
|
35
46
|
const selfAgentAdvert = getSelfAgentAdvert?.();
|
|
36
47
|
if (selfAgentAdvert !== undefined)
|
|
37
48
|
extensions[AGENT_SELF_GOSSIP_KEY] = selfAgentAdvert;
|
|
38
|
-
|
|
39
|
-
|
|
49
|
+
const ccPeerVersion = getCcPeerVersion?.();
|
|
50
|
+
const versionsAdvert = {
|
|
51
|
+
agentComms: getOwnPackageVersion(),
|
|
52
|
+
...(ccPeerVersion !== undefined ? { ccPeer: ccPeerVersion } : {}),
|
|
53
|
+
};
|
|
54
|
+
extensions[AGENT_COMMS_VERSION_GOSSIP_KEY] = versionsAdvert;
|
|
40
55
|
for (const session of allSessions) {
|
|
41
56
|
if (hub.ownsSession(session) && !hasAnyTrustedGateway())
|
|
42
57
|
continue;
|
|
@@ -45,4 +60,17 @@ export function readvertiseGossip(allSessions, hub, hasAnyTrustedGateway, onErro
|
|
|
45
60
|
});
|
|
46
61
|
}
|
|
47
62
|
}
|
|
63
|
+
/** Arms readvertiseGossip's own periodic tick, or does nothing at all when neither presence, hosted-rooms, nor self-agent-identity has a source -- WireMeshTransport's own constructor logic, split out here purely to keep that file under the repo's max-lines cap, the same reason mergeKnownDevices/findPresenceAdvert/readvertiseGossip above already live here rather than there. getCcPeerVersion never gates whether the interval starts at all (unlike the other three): it is only ever wired alongside getSelfAgentAdvert in real use (bridge-mesh.ts always supplies that one), so a construction site relying on getCcPeerVersion alone to start ticking isn't a real scenario worth its own branch. Unref'd immediately, matching every other timer this transport owns, so it never keeps the process alive on its own. */
|
|
64
|
+
export function startGossipInterval(allSessions, hub, hasAnyTrustedGateway, onError, getCurrentPresence, getHostedRooms, getSelfAgentAdvert, getCcPeerVersion, intervalMs) {
|
|
65
|
+
if (getCurrentPresence === undefined &&
|
|
66
|
+
getHostedRooms === undefined &&
|
|
67
|
+
getSelfAgentAdvert === undefined) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
const interval = setInterval(() => {
|
|
71
|
+
readvertiseGossip(allSessions, hub, hasAnyTrustedGateway, onError, getCurrentPresence, getHostedRooms, getSelfAgentAdvert, getCcPeerVersion);
|
|
72
|
+
}, intervalMs);
|
|
73
|
+
interval.unref();
|
|
74
|
+
return interval;
|
|
75
|
+
}
|
|
48
76
|
//# sourceMappingURL=gossip-directory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gossip-directory.js","sourceRoot":"","sources":["../../src/core/gossip-directory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAMhE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,GAGpB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"gossip-directory.js","sourceRoot":"","sources":["../../src/core/gossip-directory.ts"],"names":[],"mappings":"AAAA;;GAE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E;YAAE,SAAS;QAClE,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YAC5D,OAAO,EAAE,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,0yBAA0yB;AAC1yB,MAAM,UAAU,mBAAmB,CACjC,WAA6C,EAC7C,GAA8C,EAC9C,oBAAmC,EACnC,OAA6C,EAC7C,kBAA+D,EAC/D,cAA+D,EAC/D,kBAAmE,EACnE,gBAAwD,EACxD,UAAkB;IAElB,IACE,kBAAkB,KAAK,SAAS;QAChC,cAAc,KAAK,SAAS;QAC5B,kBAAkB,KAAK,SAAS,EAChC,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE;QAChC,iBAAiB,CACf,WAAW,EACX,GAAG,EACH,oBAAoB,EACpB,OAAO,EACP,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,CACjB,CAAC;IACJ,CAAC,EAAE,UAAU,CAAC,CAAC;IACf,QAAQ,CAAC,KAAK,EAAE,CAAC;IACjB,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -5,7 +5,7 @@ import { type AcceptedMeshSession, type DirectoryEntry, type IncomingManageReque
|
|
|
5
5
|
import type { CapabilityScope, CapabilityToken, Frame, ManageCommand } from "wire-mesh-core/generated/protocol";
|
|
6
6
|
import type { IdentityPort } from "wire-mesh-core/ports/identity";
|
|
7
7
|
import type { Connection } from "wire-mesh-core/ports/transport";
|
|
8
|
-
import type { ConnectionHandle, TransportEvents } from "./transport.js";
|
|
8
|
+
import type { ConnectionHandle, MeshTraceResult, TransportEvents } from "./transport.js";
|
|
9
9
|
import type { MeshMessage } from "./wire-protocol.js";
|
|
10
10
|
export interface HubSessionDeps {
|
|
11
11
|
/** Resolves this node's own identity port once ready. */
|
|
@@ -35,6 +35,8 @@ export declare class HubSession {
|
|
|
35
35
|
private session;
|
|
36
36
|
/** The raw connection underlying `session` -- MeshSession's own sendGossipUpdate only ever advertises this side's own single device, so advertising OTHER (local mesh) devices onto the hub (agent-comms#155's outbound leg) needs a raw gossip frame sent directly, bypassing that per-session single-self-advert limit. */
|
|
37
37
|
private connection;
|
|
38
|
+
/** The URL this side itself dialled to reach the hub -- tracePath's own local.hubAddress (agent-comms#199), the equivalent of wire-mesh-core's own TracePathOptions.localHubAddress. */
|
|
39
|
+
private url;
|
|
38
40
|
private readonly hubPeersKnown;
|
|
39
41
|
constructor(deps: Readonly<HubSessionDeps>);
|
|
40
42
|
/** This node's own device-id, hex-encoded -- the identifier hub peers address it by. */
|
|
@@ -58,6 +60,8 @@ export declare class HubSession {
|
|
|
58
60
|
advertiseDevices(entries: readonly DirectoryEntry[]): Promise<void>;
|
|
59
61
|
/** Sends a real core/room manage-request to a specific hub-reachable peer, through the hub's relay-connect/relay-data pairing -- the local-to-remote leg of agent-comms#155's routing, mirroring MeshTransport.sendRoomRequest's own not_connected/outcome contract so WireMeshTransport can fall back to this uniformly when memberId isn't a local peer session. Bounded by HUB_ROOM_REQUEST_TIMEOUT_MS (see its own doc) since an unreachable target-device is silently dropped by the hub with no error frame, unlike a local session's own connection-level failure. */
|
|
60
62
|
sendRoomRequest(peerDeviceHex: string, command: ManageCommand, scope: Readonly<CapabilityScope>, token?: CapabilityToken): Promise<ManageOutcome>;
|
|
63
|
+
/** Sends path.trace to a specific hub-reachable peer, through the hub's relay-connect/relay-data pairing -- WireMeshTransport.meshTrace's own hub-relayed fallback (agent-comms#199), mirroring sendRoomRequest's own not_connected contract and HUB_ROOM_REQUEST_TIMEOUT_MS default for the identical reason (an unreachable target-device is silently dropped by the hub, not answered with an error). Delegates the actual send/RTT-measurement/response-parsing to wire-mesh-core's own tracePath, reporting this.url (the address this side itself dialled to reach the hub) as local.hubAddress. */
|
|
64
|
+
tracePath(peerDeviceHex: string, timeoutMs?: number): Promise<MeshTraceResult>;
|
|
61
65
|
}
|
|
62
66
|
/** The slice of HubSessionDeps dispatchHubRequest actually needs. Named so its own tests, and consume()'s call site, don't repeat the same Pick inline. */
|
|
63
67
|
export type HubRequestDispatchDeps = Pick<HubSessionDeps, "isTrusted" | "events" | "handleRoomRequest" | "forwardToLocalPeer">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hub-session.d.ts","sourceRoot":"","sources":["../../src/core/hub-session.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EACnB,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"hub-session.d.ts","sourceRoot":"","sources":["../../src/core/hub-session.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EACnB,MAAM,oCAAoC,CAAC;AAG5C,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,KAAK,EACL,aAAa,EACd,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,eAAe,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAatD,MAAM,WAAW,cAAc;IAC7B,yDAAyD;IACzD,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC;IAC/C,MAAM,EAAE,QAAQ,CAAC,eAAe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AW,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,GACvC,OAAO,CAAC,IAAI,CAAC,CAwDf"}
|
package/dist/core/hub-session.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { acceptMeshSession, } from "wire-mesh-core/domain/mesh-session";
|
|
5
5
|
import { deviceIdToHex } from "wire-mesh-core/domain/device-id";
|
|
6
|
+
import { tracePath as coreTracePath } from "wire-mesh-core/domain/path-trace";
|
|
6
7
|
import { extractMessage } from "./room-router.js";
|
|
7
8
|
import { connectWsUrl } from "./ws-dial.js";
|
|
8
9
|
import { buildCommand, DOMAIN, FRAME_SCOPE, FRAME_VERB, } from "./wire-mesh-transport.js";
|
|
@@ -13,6 +14,8 @@ export class HubSession {
|
|
|
13
14
|
session;
|
|
14
15
|
/** The raw connection underlying `session` -- MeshSession's own sendGossipUpdate only ever advertises this side's own single device, so advertising OTHER (local mesh) devices onto the hub (agent-comms#155's outbound leg) needs a raw gossip frame sent directly, bypassing that per-session single-self-advert limit. */
|
|
15
16
|
connection;
|
|
17
|
+
/** The URL this side itself dialled to reach the hub -- tracePath's own local.hubAddress (agent-comms#199), the equivalent of wire-mesh-core's own TracePathOptions.localHubAddress. */
|
|
18
|
+
url;
|
|
16
19
|
hubPeersKnown = new Set();
|
|
17
20
|
constructor(deps) {
|
|
18
21
|
this.deps = deps;
|
|
@@ -37,6 +40,7 @@ export class HubSession {
|
|
|
37
40
|
return;
|
|
38
41
|
this.session = undefined;
|
|
39
42
|
this.connection = undefined;
|
|
43
|
+
this.url = undefined;
|
|
40
44
|
await session.close();
|
|
41
45
|
}
|
|
42
46
|
/** The device ids (hex) of peers discovered through the hub's gossiped directory. */
|
|
@@ -61,6 +65,7 @@ export class HubSession {
|
|
|
61
65
|
}
|
|
62
66
|
this.session = session;
|
|
63
67
|
this.connection = connection;
|
|
68
|
+
this.url = url;
|
|
64
69
|
this.deps.trackForShutdown(session);
|
|
65
70
|
// Merge the hub's directory (its catch-up arrives as the first session events) and keep refreshing it on every subsequent one. Every trusted remote entry is also surfaced via onDirectory, so the transport can merge it into its own mesh-wide knownDevices (agent-comms#155's remote-directory-merge leg). Filtered to isTrustedForDirectory (agent-comms#156, widened by agent-comms#187's principal allowlist per agent-comms#192) before either hubPeersKnown tracking or onDirectory sees it: an untrusted device's gossiped presence is not merely withheld from listAgents, it is never even recorded as "known" here, so nothing downstream can act on it via any path this class exposes.
|
|
66
71
|
void (async () => {
|
|
@@ -104,6 +109,7 @@ export class HubSession {
|
|
|
104
109
|
if (this.session === session) {
|
|
105
110
|
this.session = undefined;
|
|
106
111
|
this.connection = undefined;
|
|
112
|
+
this.url = undefined;
|
|
107
113
|
}
|
|
108
114
|
}
|
|
109
115
|
/** Sends one message to a hub-discovered peer through the hub's relay pairing. */
|
|
@@ -133,6 +139,24 @@ export class HubSession {
|
|
|
133
139
|
}
|
|
134
140
|
return session.sendManageRequest(command, scope, hexToBytes(peerDeviceHex), token, HUB_ROOM_REQUEST_TIMEOUT_MS);
|
|
135
141
|
}
|
|
142
|
+
/** Sends path.trace to a specific hub-reachable peer, through the hub's relay-connect/relay-data pairing -- WireMeshTransport.meshTrace's own hub-relayed fallback (agent-comms#199), mirroring sendRoomRequest's own not_connected contract and HUB_ROOM_REQUEST_TIMEOUT_MS default for the identical reason (an unreachable target-device is silently dropped by the hub, not answered with an error). Delegates the actual send/RTT-measurement/response-parsing to wire-mesh-core's own tracePath, reporting this.url (the address this side itself dialled to reach the hub) as local.hubAddress. */
|
|
143
|
+
async tracePath(peerDeviceHex, timeoutMs) {
|
|
144
|
+
const session = this.session;
|
|
145
|
+
if (session === undefined) {
|
|
146
|
+
return {
|
|
147
|
+
rttMs: 0,
|
|
148
|
+
local: { relayed: true },
|
|
149
|
+
outcome: { result: "error", code: "not_connected" },
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
return coreTracePath({
|
|
153
|
+
session,
|
|
154
|
+
clock: { now: () => Date.now() },
|
|
155
|
+
targetDevice: hexToBytes(peerDeviceHex),
|
|
156
|
+
timeoutMs: timeoutMs ?? HUB_ROOM_REQUEST_TIMEOUT_MS,
|
|
157
|
+
...(this.url !== undefined ? { localHubAddress: this.url } : {}),
|
|
158
|
+
});
|
|
159
|
+
}
|
|
136
160
|
}
|
|
137
161
|
function hexToBytes(hex) {
|
|
138
162
|
const bytes = new Uint8Array(new ArrayBuffer(hex.length / 2));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hub-session.js","sourceRoot":"","sources":["../../src/core/hub-session.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,iBAAiB,GAKlB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"hub-session.js","sourceRoot":"","sources":["../../src/core/hub-session.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,iBAAiB,GAKlB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAe9E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACL,YAAY,EACZ,MAAM,EACN,WAAW,EACX,UAAU,GACX,MAAM,0BAA0B,CAAC;AAElC,2fAA2f;AAC3f,MAAM,2BAA2B,GAAG,MAAM,CAAC;AAqC3C,MAAM,OAAO,UAAU;IAQQ;IAPrB,OAAO,CAAkC;IACjD,6TAA6T;IACrT,UAAU,CAAyB;IAC3C,wLAAwL;IAChL,GAAG,CAAqB;IACf,aAAa,GAAG,IAAI,GAAG,EAAU,CAAC;IAEnD,YAA6B,IAA8B;QAA9B,SAAI,GAAJ,IAAI,CAA0B;IAAG,CAAC;IAE/D,wFAAwF;IACxF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;QAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IAEtD,MAAM,WAAW,GACf,OAAO,CAAC,QAAQ,KAAK,SAAS;QAC5B,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC;QACjC,CAAC,CAAC,SAAS,CAAC;IAChB,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,YAAY,EAAE,CAAC;QAC9D,MAAM,gBAAgB,GAAG;YACvB,GAAG,OAAO,CAAC,OAAO;YAClB,MAAM,EAAE;gBACN,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM;gBACzB,cAAc,EAAE,SAAS;aAC1B;SACF,CAAC;QACF,MAAM,SAAS,GAAG,IAAI,CAAC,kBAAkB,CACvC,WAAW,EACX,gBAAgB,EAChB,OAAO,CAAC,KAAK,EACb,OAAO,CAAC,KAAK,CACd,CAAC;QACF,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC;YAChC,MAAM,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YACtD,OAAO;QACT,CAAC;IACH,CAAC;IACD,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAChD,CAAC;AAED,s5CAAs5C;AACt5C,SAAS,sBAAsB,CAAC,OAAoB;IAClD,OAAO,OAAO,CAAC,MAAM,KAAK,YAAY,IAAI,OAAO,CAAC,MAAM,KAAK,cAAc,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CommsTool's mesh_graph/mesh_trace action handlers (agent-comms#199) -- split out of tool.ts purely to keep that file under the repo's max-lines cap, the same reason gateway-trust-actions.ts/connection-code-tool.ts were split from it. Free functions over MeshOnlyFeatures's own meshGraph/meshTrace methods rather than class methods, since CommsTool owns no state of its own for this concern.
|
|
3
|
+
*/
|
|
4
|
+
import type { CommsAction } from "./types.js";
|
|
5
|
+
import type { CommsResult, MeshOnlyFeatures } from "./tool.js";
|
|
6
|
+
/** Reports every known device (nodes) and every self-reported connection edge between them (edges), assembled from the cached gossip directory -- a cheap, possibly-stale snapshot; meshTraceAction below is the live, cache-bust counterpart for one specific device. */
|
|
7
|
+
export declare function meshGraphAction(store: Readonly<Pick<MeshOnlyFeatures, "meshGraph">>): CommsResult;
|
|
8
|
+
/** Sends path.trace to action.target and reports the real end-to-end RTT plus each side's own relayed/hub-address knowledge -- the live counterpart to meshGraphAction's gossiped snapshot. */
|
|
9
|
+
export declare function meshTraceAction(store: Readonly<Pick<MeshOnlyFeatures, "meshTrace">>, action: CommsAction & {
|
|
10
|
+
action: "mesh_trace";
|
|
11
|
+
}): Promise<CommsResult>;
|
|
12
|
+
//# sourceMappingURL=mesh-graph-trace-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mesh-graph-trace-tool.d.ts","sourceRoot":"","sources":["../../src/core/mesh-graph-trace-tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAc/D,0QAA0Q;AAC1Q,wBAAgB,eAAe,CAC7B,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAC,GACnD,WAAW,CAiBb;AAED,+LAA+L;AAC/L,wBAAsB,eAAe,CACnC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAC,EACpD,MAAM,EAAE,WAAW,GAAG;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,GAC7C,OAAO,CAAC,WAAW,CAAC,CA+BtB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CommsTool's mesh_graph/mesh_trace action handlers (agent-comms#199) -- split out of tool.ts purely to keep that file under the repo's max-lines cap, the same reason gateway-trust-actions.ts/connection-code-tool.ts were split from it. Free functions over MeshOnlyFeatures's own meshGraph/meshTrace methods rather than class methods, since CommsTool owns no state of its own for this concern.
|
|
3
|
+
*/
|
|
4
|
+
import { tryMeshAction } from "./tool.js";
|
|
5
|
+
/** Column width the "direct"/"relay" edge-kind label is padded to in meshGraphAction's own listing, matching tool.ts's own aligned-column convention for every other tabular action result. */
|
|
6
|
+
const MESH_GRAPH_EDGE_KIND_COLUMN_WIDTH = 6;
|
|
7
|
+
/** Uniform "this bridge isn't backed by a mesh transport" result, mirroring tool.ts's own notMeshBacked for the other MeshOnlyFeatures methods (not exported from there, so re-declared locally the same way gateway-trust-actions.ts's own gatewayTrustUnavailable already does). */
|
|
8
|
+
function meshFeatureUnavailable(action) {
|
|
9
|
+
return {
|
|
10
|
+
isError: true,
|
|
11
|
+
content: `${action} requires a mesh-backed store (this session is running on FileStore)`,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/** Reports every known device (nodes) and every self-reported connection edge between them (edges), assembled from the cached gossip directory -- a cheap, possibly-stale snapshot; meshTraceAction below is the live, cache-bust counterpart for one specific device. */
|
|
15
|
+
export function meshGraphAction(store) {
|
|
16
|
+
if (!store.meshGraph)
|
|
17
|
+
return meshFeatureUnavailable("mesh_graph");
|
|
18
|
+
const graph = store.meshGraph();
|
|
19
|
+
if (graph.nodes.length === 0)
|
|
20
|
+
return { content: "No known devices in the mesh graph.", isError: false };
|
|
21
|
+
const edgeLines = graph.edges.map((edge) => {
|
|
22
|
+
const via = edge.kind === "relay" && edge.via !== undefined ? ` via ${edge.via}` : "";
|
|
23
|
+
return ` ${edge.kind.padEnd(MESH_GRAPH_EDGE_KIND_COLUMN_WIDTH)} ${edge.from} -> ${edge.to}${via}`;
|
|
24
|
+
});
|
|
25
|
+
const edgesBlock = edgeLines.length > 0 ? edgeLines.join("\n") : " (no edges reported)";
|
|
26
|
+
return {
|
|
27
|
+
content: `Mesh graph:\nNodes (${String(graph.nodes.length)}): ${graph.nodes.join(", ")}\nEdges:\n${edgesBlock}`,
|
|
28
|
+
isError: false,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** Sends path.trace to action.target and reports the real end-to-end RTT plus each side's own relayed/hub-address knowledge -- the live counterpart to meshGraphAction's gossiped snapshot. */
|
|
32
|
+
export async function meshTraceAction(store, action) {
|
|
33
|
+
if (!store.meshTrace)
|
|
34
|
+
return meshFeatureUnavailable("mesh_trace");
|
|
35
|
+
return tryMeshAction(`trace ${action.target}`, async () => {
|
|
36
|
+
// Called via `?.()` rather than a `const meshTrace = store.meshTrace` extraction -- the latter would silently drop `this` (WireMeshTransport.meshTrace reads its own private fields), a real bug this exact pattern caught during development. TypeScript can't carry the `if (!store.meshTrace)` guard above across this closure boundary, so `result` is still typed possibly-undefined even though it never actually is at runtime.
|
|
37
|
+
const result = await store.meshTrace?.(action.target, action.timeoutMs);
|
|
38
|
+
if (!result)
|
|
39
|
+
return meshFeatureUnavailable("mesh_trace").content;
|
|
40
|
+
if (result.outcome.result === "error") {
|
|
41
|
+
throw new Error(`${result.outcome.code}${result.outcome.message !== undefined ? `: ${result.outcome.message}` : ""}`);
|
|
42
|
+
}
|
|
43
|
+
const localHub = result.local.hubAddress !== undefined
|
|
44
|
+
? ` (hub ${result.local.hubAddress})`
|
|
45
|
+
: "";
|
|
46
|
+
const lines = [
|
|
47
|
+
`Trace to ${action.target}:`,
|
|
48
|
+
` RTT: ${String(result.rttMs)}ms`,
|
|
49
|
+
` Local: ${result.local.relayed ? "relayed" : "direct"}${localHub}`,
|
|
50
|
+
];
|
|
51
|
+
if (result.remote) {
|
|
52
|
+
const remoteHub = result.remote.hubAddress !== undefined
|
|
53
|
+
? ` (hub ${result.remote.hubAddress})`
|
|
54
|
+
: "";
|
|
55
|
+
lines.push(` Remote: ${result.remote.relayed ? "relayed" : "direct"}${remoteHub}`);
|
|
56
|
+
}
|
|
57
|
+
return lines.join("\n");
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=mesh-graph-trace-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mesh-graph-trace-tool.js","sourceRoot":"","sources":["../../src/core/mesh-graph-trace-tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,+LAA+L;AAC/L,MAAM,iCAAiC,GAAG,CAAC,CAAC;AAE5C,sRAAsR;AACtR,SAAS,sBAAsB,CAAC,MAAc;IAC5C,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,GAAG,MAAM,sEAAsE;KACzF,CAAC;AACJ,CAAC;AAED,0QAA0Q;AAC1Q,MAAM,UAAU,eAAe,CAC7B,KAAoD;IAEpD,IAAI,CAAC,KAAK,CAAC,SAAS;QAAE,OAAO,sBAAsB,CAAC,YAAY,CAAC,CAAC;IAClE,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IAChC,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;QAC1B,OAAO,EAAE,OAAO,EAAE,qCAAqC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAE5E,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACzC,MAAM,GAAG,GACP,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5E,OAAO,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,iCAAiC,CAAC,IAAI,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC;IACrG,CAAC,CAAC,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EAAE,CAAC;QACT,MAAM,KAAK,GAAG;YACZ,YAAY,MAAM,CAAC,MAAM,GAAG;YAC5B,UAAU,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI;YAClC,aAAa,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,GAAG,QAAQ,EAAE;SACtE,CAAC;QACF,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,MAAM,SAAS,GACb,MAAM,CAAC,MAAM,CAAC,UAAU,KAAK,SAAS;gBACpC,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,UAAU,GAAG;gBACtC,CAAC,CAAC,EAAE,CAAC;YACT,KAAK,CAAC,IAAI,CACR,aAAa,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,GAAG,SAAS,EAAE,CACxE,CAAC;QACJ,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mesh-graph -- agent-comms#199's own mesh_graph/mesh_trace primitives, split from wire-mesh-transport.ts under the repo's max-lines cap, the same reason gossip-directory.ts/hub-forwarding.ts were each split from their own owning file. computeMeshGraph assembles this side's best-effort view of the mesh's connection graph out of every known device's own self-reported topology/peers gossip extension (wire-mesh#180); traceMeshPath sends the live path.trace verb (wire-mesh#181) to a specific device, direct or via the hub.
|
|
3
|
+
*/
|
|
4
|
+
import type { AcceptedMeshSession, IncomingManageRequest, ManageOutcome } from "wire-mesh-core/domain/mesh-session";
|
|
5
|
+
import type { PeerAdvert } from "wire-mesh-core/generated/protocol";
|
|
6
|
+
import type { HubSession } from "./hub-session.js";
|
|
7
|
+
import type { MeshGraph, MeshTraceResult } from "./transport.js";
|
|
8
|
+
/** Assembles this side's own best-effort view of the mesh's connection graph out of knownDevices (WireMeshTransport's own mesh-wide gossip aggregation, the identical map listKnownDevices already reads), converted to DirectoryEntry[] the same way hub-forwarding.ts's own pushHubCatchUp already does for its unrelated purpose. Device-ids are hex-encoded, never raw wire-mesh-core DeviceId bytes, matching listKnownDevices' own precedent. */
|
|
9
|
+
export declare function computeMeshGraph(knownDevices: ReadonlyMap<string, Readonly<PeerAdvert>>): MeshGraph;
|
|
10
|
+
/** Sends path.trace to targetDeviceHex, direct if a local peer session exists for it (peerSessions, WireMeshTransport's own addressing map), else via the hub's own relay pairing when connected to one, else resolving an ordinary not_connected outcome rather than throwing -- WireMeshTransport.sendRoomRequest's own identical direct-or-hub fallback, just for path.trace instead of a room-domain verb. Delegates the actual send/RTT-measurement/response-parsing to wire-mesh-core's own tracePath in the direct branch, and to HubSession.tracePath (which does the identical delegation on the hub's own session) in the relayed branch, so neither this function nor either of those duplicates that logic. */
|
|
11
|
+
export declare function traceMeshPath(peerSessions: ReadonlyMap<string, AcceptedMeshSession>, hub: Readonly<Pick<HubSession, "isConnected" | "tracePath">>, targetDeviceHex: string, timeoutMs?: number): Promise<MeshTraceResult>;
|
|
12
|
+
/** Answers an incoming path.trace (agent-comms#199), registered as this side's own "path.trace" room-router handler (createRoomRouter's handlers are keyed by params.verb regardless of domain, despite the room-flavoured name -- see WireMeshTransport's own constructor for where this is wired in alongside the real room verbs). Omits hubAddress unconditionally: RoomVerbHandler's own (request, handle) signature carries no reference to which raw session/connection the request arrived on, so there is no way to look up "the address this side dialled to reach the hub that relayed it" from here -- buildPathTraceResponse's own hubAddress parameter is optional exactly for a receiver with no address to report, so this is an honest omission, not a workaround. Tracked as agent-comms#216 for a future RoomVerbHandler signature change that would let this report it. */
|
|
13
|
+
export declare function handlePathTraceRequest(request: Readonly<IncomingManageRequest>): Promise<ManageOutcome>;
|
|
14
|
+
//# sourceMappingURL=mesh-graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mesh-graph.d.ts","sourceRoot":"","sources":["../../src/core/mesh-graph.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,OAAO,KAAK,EACV,mBAAmB,EAEnB,qBAAqB,EACrB,aAAa,EACd,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjE,ubAAub;AACvb,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,GACtD,SAAS,CAgBX;AAED,2rBAA2rB;AAC3rB,wBAAsB,aAAa,CACjC,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,mBAAmB,CAAC,EACtD,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,aAAa,GAAG,WAAW,CAAC,CAAC,EAC5D,eAAe,EAAE,MAAM,EACvB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,eAAe,CAAC,CAiB1B;AAED,+1BAA+1B;AAC/1B,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,QAAQ,CAAC,qBAAqB,CAAC,GACvC,OAAO,CAAC,aAAa,CAAC,CAExB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mesh-graph -- agent-comms#199's own mesh_graph/mesh_trace primitives, split from wire-mesh-transport.ts under the repo's max-lines cap, the same reason gossip-directory.ts/hub-forwarding.ts were each split from their own owning file. computeMeshGraph assembles this side's best-effort view of the mesh's connection graph out of every known device's own self-reported topology/peers gossip extension (wire-mesh#180); traceMeshPath sends the live path.trace verb (wire-mesh#181) to a specific device, direct or via the hub.
|
|
3
|
+
*/
|
|
4
|
+
import { deviceIdToHex } from "wire-mesh-core/domain/device-id";
|
|
5
|
+
import { assembleTopologyGraph } from "wire-mesh-core/domain/topology";
|
|
6
|
+
import { buildPathTraceResponse, tracePath, } from "wire-mesh-core/domain/path-trace";
|
|
7
|
+
/** Assembles this side's own best-effort view of the mesh's connection graph out of knownDevices (WireMeshTransport's own mesh-wide gossip aggregation, the identical map listKnownDevices already reads), converted to DirectoryEntry[] the same way hub-forwarding.ts's own pushHubCatchUp already does for its unrelated purpose. Device-ids are hex-encoded, never raw wire-mesh-core DeviceId bytes, matching listKnownDevices' own precedent. */
|
|
8
|
+
export function computeMeshGraph(knownDevices) {
|
|
9
|
+
const directory = [...knownDevices.values()].map((advert) => ({ device: advert.device, advert }));
|
|
10
|
+
const graph = assembleTopologyGraph(directory);
|
|
11
|
+
return {
|
|
12
|
+
nodes: graph.nodes.map(deviceIdToHex),
|
|
13
|
+
edges: graph.edges.map((edge) => ({
|
|
14
|
+
kind: edge.kind,
|
|
15
|
+
from: deviceIdToHex(edge.from),
|
|
16
|
+
to: deviceIdToHex(edge.to),
|
|
17
|
+
...(edge.kind === "relay" && edge.via !== undefined
|
|
18
|
+
? { via: deviceIdToHex(edge.via) }
|
|
19
|
+
: {}),
|
|
20
|
+
})),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** Sends path.trace to targetDeviceHex, direct if a local peer session exists for it (peerSessions, WireMeshTransport's own addressing map), else via the hub's own relay pairing when connected to one, else resolving an ordinary not_connected outcome rather than throwing -- WireMeshTransport.sendRoomRequest's own identical direct-or-hub fallback, just for path.trace instead of a room-domain verb. Delegates the actual send/RTT-measurement/response-parsing to wire-mesh-core's own tracePath in the direct branch, and to HubSession.tracePath (which does the identical delegation on the hub's own session) in the relayed branch, so neither this function nor either of those duplicates that logic. */
|
|
24
|
+
export async function traceMeshPath(peerSessions, hub, targetDeviceHex, timeoutMs) {
|
|
25
|
+
const directSession = peerSessions.get(targetDeviceHex);
|
|
26
|
+
if (directSession !== undefined) {
|
|
27
|
+
return tracePath({
|
|
28
|
+
session: directSession,
|
|
29
|
+
clock: { now: () => Date.now() },
|
|
30
|
+
...(timeoutMs !== undefined ? { timeoutMs } : {}),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (hub.isConnected) {
|
|
34
|
+
return hub.tracePath(targetDeviceHex, timeoutMs);
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
rttMs: 0,
|
|
38
|
+
local: { relayed: false },
|
|
39
|
+
outcome: { result: "error", code: "not_connected" },
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** Answers an incoming path.trace (agent-comms#199), registered as this side's own "path.trace" room-router handler (createRoomRouter's handlers are keyed by params.verb regardless of domain, despite the room-flavoured name -- see WireMeshTransport's own constructor for where this is wired in alongside the real room verbs). Omits hubAddress unconditionally: RoomVerbHandler's own (request, handle) signature carries no reference to which raw session/connection the request arrived on, so there is no way to look up "the address this side dialled to reach the hub that relayed it" from here -- buildPathTraceResponse's own hubAddress parameter is optional exactly for a receiver with no address to report, so this is an honest omission, not a workaround. Tracked as agent-comms#216 for a future RoomVerbHandler signature change that would let this report it. */
|
|
43
|
+
export async function handlePathTraceRequest(request) {
|
|
44
|
+
return Promise.resolve(buildPathTraceResponse(request));
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=mesh-graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mesh-graph.js","sourceRoot":"","sources":["../../src/core/mesh-graph.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EACL,sBAAsB,EACtB,SAAS,GACV,MAAM,kCAAkC,CAAC;AAW1C,ubAAub;AACvb,MAAM,UAAU,gBAAgB,CAC9B,YAAuD;IAEvD,MAAM,SAAS,GAAqB,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAChE,C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QACpB,OAAO,GAAG,CAAC,SAAS,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;IACnD,CAAC;IACD,OAAO;QACL,KAAK,EAAE,CAAC;QACR,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;QACzB,OAAO,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE;KACpD,CAAC;AACJ,CAAC;AAED,+1BAA+1B;AAC/1B,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,OAAwC;IAExC,OAAO,OAAO,CAAC,OAAO,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CommsTool's mesh discovery/advertise/interfaces/listener/visibility action handlers -- split out of tool.ts purely to keep that file under the repo's max-lines cap, the same reason gateway-trust-actions.ts/mesh-graph-trace-tool.ts were split from it. Free functions over an explicit DiscoveryManager/CommsStore pair rather than class methods, since CommsTool owns no state of its own for this concern.
|
|
3
|
+
*/
|
|
4
|
+
import type { CommsAction } from "./types.js";
|
|
5
|
+
import type { DiscoveryManager } from "./discovery.js";
|
|
6
|
+
import type { CommsResult, MeshOnlyFeatures } from "./tool.js";
|
|
7
|
+
export declare function meshDiscoverAction(discovery: DiscoveryManager | undefined, action: CommsAction & {
|
|
8
|
+
action: "mesh_discover";
|
|
9
|
+
}): Promise<CommsResult>;
|
|
10
|
+
export declare function meshAdvertiseAction(discovery: DiscoveryManager | undefined, action: CommsAction & {
|
|
11
|
+
action: "mesh_advertise";
|
|
12
|
+
}): Promise<CommsResult>;
|
|
13
|
+
export declare function meshInterfacesAction(store: Readonly<Pick<MeshOnlyFeatures, "getNetworkInterfaces">>): CommsResult;
|
|
14
|
+
export declare function meshUnadvertiseAction(discovery: DiscoveryManager | undefined, action: CommsAction & {
|
|
15
|
+
action: "mesh_unadvertise";
|
|
16
|
+
}): Promise<CommsResult>;
|
|
17
|
+
export declare function meshListenAction(store: Readonly<Pick<MeshOnlyFeatures, "addListener">>, action: CommsAction & {
|
|
18
|
+
action: "mesh_listen";
|
|
19
|
+
}): Promise<CommsResult>;
|
|
20
|
+
export declare function meshUnlistenAction(store: Readonly<Pick<MeshOnlyFeatures, "removeListener">>, action: CommsAction & {
|
|
21
|
+
action: "mesh_unlisten";
|
|
22
|
+
}): Promise<CommsResult>;
|
|
23
|
+
export declare function meshListenersAction(store: Readonly<Pick<MeshOnlyFeatures, "listListeners">>): CommsResult;
|
|
24
|
+
export declare function meshSetVisibilityAction(store: Readonly<Pick<MeshOnlyFeatures, "setVisibility">>, action: CommsAction & {
|
|
25
|
+
action: "mesh_set_visibility";
|
|
26
|
+
}): Promise<CommsResult>;
|
|
27
|
+
export declare function meshGetVisibilityAction(store: Readonly<Pick<MeshOnlyFeatures, "getVisibility">>): CommsResult;
|
|
28
|
+
//# sourceMappingURL=mesh-network-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mesh-network-actions.d.ts","sourceRoot":"","sources":["../../src/core/mesh-network-actions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAoB,MAAM,YAAY,CAAC;AAEhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAa/D,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,gBAAgB,GAAG,SAAS,EACvC,MAAM,EAAE,WAAW,GAAG;IAAE,MAAM,EAAE,eAAe,CAAA;CAAE,GAChD,OAAO,CAAC,WAAW,CAAC,CAmBtB;AAED,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,gBAAgB,GAAG,SAAS,EACvC,MAAM,EAAE,WAAW,GAAG;IAAE,MAAM,EAAE,gBAAgB,CAAA;CAAE,GACjD,OAAO,CAAC,WAAW,CAAC,CAkB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ts purely to keep that file under the repo's max-lines cap, the same reason gateway-trust-actions.ts/mesh-graph-trace-tool.ts were split from it. Free functions over an explicit DiscoveryManager/CommsStore pair rather than class methods, since CommsTool owns no state of its own for this concern.
|
|
3
|
+
*/
|
|
4
|
+
import { notMeshBacked, tryMeshAction } from "./tool.js";
|
|
5
|
+
/** Table column widths for the plain-text listing helpers below, matching tool.ts's own aligned-column convention for every other tabular action result. */
|
|
6
|
+
const INTERFACE_NAME_COLUMN_WIDTH = 12;
|
|
7
|
+
const INTERFACE_FAMILY_COLUMN_WIDTH = 4;
|
|
8
|
+
const LISTENER_HOST_COLUMN_WIDTH = 15;
|
|
9
|
+
const LISTENER_PORT_COLUMN_WIDTH = 6;
|
|
10
|
+
const LISTENER_POLICY_COLUMN_WIDTH = 11;
|
|
11
|
+
/** Default port the mesh coordinator listens on when advertising with no explicit port given. */
|
|
12
|
+
const DEFAULT_MESH_COORDINATOR_PORT = 19876;
|
|
13
|
+
export async function meshDiscoverAction(discovery, action) {
|
|
14
|
+
if (!discovery) {
|
|
15
|
+
return {
|
|
16
|
+
content: "Discovery is not available (no backends registered).",
|
|
17
|
+
isError: true,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const meshes = await discovery.discover(action.method);
|
|
21
|
+
if (meshes.length === 0) {
|
|
22
|
+
return { content: "No meshes discovered.", isError: false };
|
|
23
|
+
}
|
|
24
|
+
const lines = meshes.map((m) => ` ${m.host}:${String(m.port)} ${m.name}${m.agentCount !== undefined ? ` (${String(m.agentCount)} agents)` : ""}`);
|
|
25
|
+
return {
|
|
26
|
+
content: `Discovered meshes:\n${lines.join("\n")}`,
|
|
27
|
+
isError: false,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export async function meshAdvertiseAction(discovery, action) {
|
|
31
|
+
if (!discovery) {
|
|
32
|
+
return {
|
|
33
|
+
content: "Discovery is not available (no backends registered).",
|
|
34
|
+
isError: true,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const port = action.port ?? DEFAULT_MESH_COORDINATOR_PORT;
|
|
38
|
+
const opts = {
|
|
39
|
+
name: action.name,
|
|
40
|
+
port,
|
|
41
|
+
};
|
|
42
|
+
if (action.adapter !== undefined)
|
|
43
|
+
opts.adapter = action.adapter;
|
|
44
|
+
const id = await discovery.advertise(action.method, opts);
|
|
45
|
+
return {
|
|
46
|
+
content: `Advertising mesh "${action.name}" on ${action.method} (port ${String(port)}). ID: ${id}`,
|
|
47
|
+
isError: false,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export function meshInterfacesAction(store) {
|
|
51
|
+
if (!store.getNetworkInterfaces)
|
|
52
|
+
return notMeshBacked("mesh_interfaces");
|
|
53
|
+
const interfaces = store.getNetworkInterfaces();
|
|
54
|
+
if (interfaces.length === 0)
|
|
55
|
+
return { content: "No network interfaces found.", isError: false };
|
|
56
|
+
const lines = interfaces.map((iface) => {
|
|
57
|
+
const internal = iface.internal ? " (internal)" : "";
|
|
58
|
+
return `${iface.name.padEnd(INTERFACE_NAME_COLUMN_WIDTH)} ${iface.family.padEnd(INTERFACE_FAMILY_COLUMN_WIDTH)} ${iface.address}${internal}`;
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
content: `Interfaces:\n${lines.join("\n")}`,
|
|
62
|
+
isError: false,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export async function meshUnadvertiseAction(discovery, action) {
|
|
66
|
+
if (!discovery) {
|
|
67
|
+
return {
|
|
68
|
+
content: "Discovery is not available (no backends registered).",
|
|
69
|
+
isError: true,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
await discovery.stopAdvertising(action.id);
|
|
73
|
+
return { content: `Stopped advertising ${action.id}.`, isError: false };
|
|
74
|
+
}
|
|
75
|
+
export async function meshListenAction(store, action) {
|
|
76
|
+
const policy = action.policy ?? "full";
|
|
77
|
+
const validPolicies = ["full", "observe", "rooms-only", "gateway"];
|
|
78
|
+
if (!validPolicies.includes(policy)) {
|
|
79
|
+
return {
|
|
80
|
+
content: `Invalid policy "${policy}". Must be one of: ${validPolicies.join(", ")}`,
|
|
81
|
+
isError: true,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
if (!store.addListener)
|
|
85
|
+
return notMeshBacked("mesh_listen");
|
|
86
|
+
const addListener = store.addListener.bind(store);
|
|
87
|
+
return tryMeshAction("add listener", async () => {
|
|
88
|
+
const id = await addListener(action.host, action.port ?? 0, policy);
|
|
89
|
+
return `Listener added: ${id} on ${action.host}${String(action.port ?? "auto")} with policy ${policy}.`;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
export async function meshUnlistenAction(store, action) {
|
|
93
|
+
if (!store.removeListener)
|
|
94
|
+
return notMeshBacked("mesh_unlisten");
|
|
95
|
+
const removeListener = store.removeListener.bind(store);
|
|
96
|
+
return tryMeshAction("remove listener", async () => {
|
|
97
|
+
await removeListener(action.id);
|
|
98
|
+
return `Listener ${action.id} removed.`;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
export function meshListenersAction(store) {
|
|
102
|
+
if (!store.listListeners)
|
|
103
|
+
return notMeshBacked("mesh_listeners");
|
|
104
|
+
const listeners = store.listListeners();
|
|
105
|
+
if (listeners.length === 0)
|
|
106
|
+
return { content: "No listeners (not coordinator).", isError: false };
|
|
107
|
+
const lines = listeners.map((l) => {
|
|
108
|
+
const flag = l.isDefault ? " (default)" : "";
|
|
109
|
+
return `${l.id} ${l.host.padEnd(LISTENER_HOST_COLUMN_WIDTH)} ${String(l.port).padEnd(LISTENER_PORT_COLUMN_WIDTH)} ${l.policy.padEnd(LISTENER_POLICY_COLUMN_WIDTH)}${flag}`;
|
|
110
|
+
});
|
|
111
|
+
return {
|
|
112
|
+
content: `Listeners:\n ID Host Port Policy \n${lines.map((l) => ` ${l}`).join("\n")}`,
|
|
113
|
+
isError: false,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export async function meshSetVisibilityAction(store, action) {
|
|
117
|
+
if (!store.setVisibility) {
|
|
118
|
+
return {
|
|
119
|
+
content: "Visibility control is not available on this store.",
|
|
120
|
+
isError: true,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
await store.setVisibility(action.visibility, action.adapter);
|
|
124
|
+
const adapter = action.adapter !== undefined ? ` on adapter "${action.adapter}"` : "";
|
|
125
|
+
return {
|
|
126
|
+
content: `Mesh visibility set to "${action.visibility}"${adapter}.`,
|
|
127
|
+
isError: false,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
export function meshGetVisibilityAction(store) {
|
|
131
|
+
if (!store.getVisibility) {
|
|
132
|
+
return {
|
|
133
|
+
content: "Visibility control is not available on this store.",
|
|
134
|
+
isError: true,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
const visibility = store.getVisibility();
|
|
138
|
+
return {
|
|
139
|
+
content: `Mesh visibility: ${visibility}`,
|
|
140
|
+
isError: false,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=mesh-network-actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mesh-network-actions.js","sourceRoot":"","sources":["../../src/core/mesh-network-actions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAEzD,4JAA4J;AAC5J,MAAM,2BAA2B,GAAG,EAAE,CAAC;AACvC,MAAM,6BAA6B,GAAG,CAAC,CAAC;AACxC,MAAM,0BAA0B,GAAG,EAAE,CAAC;AACtC,MAAM,0BAA0B,GAAG,CAAC,CAAC;AACrC,MAAM,4BAA4B,GAAG,EAAE,CAAC;AAExC,iGAAiG;AACjG,MAAM,6BAA6B,GAAG,KAAK,CAAC;AAE5C,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,SAAuC,EACvC,MAAiD;IAEjD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,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