agent-comms 8.0.2 → 8.0.3
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/test/front-real-bridge-identity-overlap.integration.test.d.ts +7 -0
- package/dist/test/front-real-bridge-identity-overlap.integration.test.d.ts.map +1 -0
- package/dist/test/front-real-bridge-identity-overlap.integration.test.js +97 -0
- package/dist/test/front-real-bridge-identity-overlap.integration.test.js.map +1 -0
- package/dist/test/test-transport.d.ts +3 -0
- package/dist/test/test-transport.d.ts.map +1 -1
- package/dist/test/test-transport.js +2 -2
- package/dist/test/test-transport.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/ExaDev/agent-comms)
|
|
4
4
|
[](https://www.npmjs.com/package/agent-comms)
|
|
5
|
-
[](https://github.com/ExaDev/agent-comms/releases/tag/v8.0.3)
|
|
6
6
|
[](https://github.com/ExaDev/agent-comms/actions)
|
|
7
7
|
|
|
8
8
|
Cross-harness communication mesh for LLM agents: rooms, DMs, presence, and visibility over TCP with zero filesystem dependencies.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reproduces agent-comms#299: a session fronted by the default cc-peer front builds its store from the same identity slot the real claude-code bridge for that directory would use (computeFrontSlot). loadIdentityForFront (front.ts's own path) never takes the slot's exclusivity lock, so nothing stops a real bridge starting afterwards from also loading that slot's identity via loadOrCreateIdentity — both stores end up holding the literal same device-id, each with its own live hub session, for as long as the front takes to notice (via its own poll) that the slot is now held and detach.
|
|
3
|
+
*
|
|
4
|
+
* This test constructs exactly that: a "front" store built via loadIdentityForFront, and a "real bridge" store built afterwards via loadOrCreateIdentity against the same slot — both against a real relay hub (the same domain logic mesh.exadev.io's Durable Object runs, served locally over WebSockets by hub-helpers.ts). A third, unrelated observer store discovers the shared device id through the hub and checks it stays routable once the front (the older of the two live sessions) shuts down, simulating the front noticing the takeover and detaching.
|
|
5
|
+
*/
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=front-real-bridge-identity-overlap.integration.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"front-real-bridge-identity-overlap.integration.test.d.ts","sourceRoot":"","sources":["../../src/test/front-real-bridge-identity-overlap.integration.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reproduces agent-comms#299: a session fronted by the default cc-peer front builds its store from the same identity slot the real claude-code bridge for that directory would use (computeFrontSlot). loadIdentityForFront (front.ts's own path) never takes the slot's exclusivity lock, so nothing stops a real bridge starting afterwards from also loading that slot's identity via loadOrCreateIdentity — both stores end up holding the literal same device-id, each with its own live hub session, for as long as the front takes to notice (via its own poll) that the slot is now held and detach.
|
|
3
|
+
*
|
|
4
|
+
* This test constructs exactly that: a "front" store built via loadIdentityForFront, and a "real bridge" store built afterwards via loadOrCreateIdentity against the same slot — both against a real relay hub (the same domain logic mesh.exadev.io's Durable Object runs, served locally over WebSockets by hub-helpers.ts). A third, unrelated observer store discovers the shared device id through the hub and checks it stays routable once the front (the older of the two live sessions) shuts down, simulating the front noticing the takeover and detaching.
|
|
5
|
+
*/
|
|
6
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
7
|
+
import * as fs from "node:fs";
|
|
8
|
+
import * as path from "node:path";
|
|
9
|
+
import { tmpdir } from "node:os";
|
|
10
|
+
import { MeshStore } from "../core/mesh-store.js";
|
|
11
|
+
import { loadIdentityForFront, releaseIdentityLock, } from "../core/identity-store.js";
|
|
12
|
+
import { realHubOverWs, TeardownStack } from "./hub-helpers.js";
|
|
13
|
+
import { wireTestTransport, waitFor as waitForCondition, } from "./test-transport.js";
|
|
14
|
+
const cleanups = new TeardownStack();
|
|
15
|
+
afterEach(async () => {
|
|
16
|
+
await cleanups.run();
|
|
17
|
+
});
|
|
18
|
+
/** Starts an unrelated observer store on its own machine, dialling the same hub, so its view of the shared-identity device only ever arrives via hub gossip — exactly the cross-machine visibility agent-comms#299 is actually about. */
|
|
19
|
+
async function startObserver(hubUrl) {
|
|
20
|
+
const store = new MeshStore({ coordinatorPort: 0, hubUrl });
|
|
21
|
+
await wireTestTransport(store, { presenceReadvertiseIntervalMs: 50 });
|
|
22
|
+
await store.init();
|
|
23
|
+
cleanups.push(async () => store.shutdown());
|
|
24
|
+
await store.registerAgent({
|
|
25
|
+
name: "observer",
|
|
26
|
+
harness: "test",
|
|
27
|
+
cwd: "/test/observer",
|
|
28
|
+
pid: process.pid,
|
|
29
|
+
visibility: "visible",
|
|
30
|
+
tags: ["observer"],
|
|
31
|
+
});
|
|
32
|
+
return store;
|
|
33
|
+
}
|
|
34
|
+
describe("front and real bridge sharing one identity slot (agent-comms#299)", () => {
|
|
35
|
+
it("keeps the shared device routable from another machine once the front (the older session) shuts down", async () => {
|
|
36
|
+
const hub = await realHubOverWs();
|
|
37
|
+
cleanups.push(hub.close);
|
|
38
|
+
const slot = {
|
|
39
|
+
harness: "claude-code",
|
|
40
|
+
cwd: "/test/fronted-session",
|
|
41
|
+
dir: fs.mkdtempSync(path.join(tmpdir(), "agent-comms-test-identity-")),
|
|
42
|
+
};
|
|
43
|
+
// The front: loadIdentityForFront never takes the slot lock, matching front.ts's own real behaviour.
|
|
44
|
+
const front = new MeshStore({ coordinatorPort: 0, hubUrl: hub.url });
|
|
45
|
+
await wireTestTransport(front, {
|
|
46
|
+
slot,
|
|
47
|
+
identityLoader: loadIdentityForFront,
|
|
48
|
+
presenceReadvertiseIntervalMs: 50,
|
|
49
|
+
});
|
|
50
|
+
await front.init();
|
|
51
|
+
cleanups.push(async () => front.shutdown());
|
|
52
|
+
await front.registerAgent({
|
|
53
|
+
name: "fronted-session",
|
|
54
|
+
harness: "claude-code",
|
|
55
|
+
cwd: slot.cwd,
|
|
56
|
+
pid: process.pid,
|
|
57
|
+
visibility: "visible",
|
|
58
|
+
tags: [],
|
|
59
|
+
});
|
|
60
|
+
// The real bridge starts afterwards, against the same slot. loadOrCreateIdentity succeeds in taking the lock, since the front never held it, so it loads the identical persisted identity rather than falling back to an ephemeral one.
|
|
61
|
+
const realBridge = new MeshStore({ coordinatorPort: 0, hubUrl: hub.url });
|
|
62
|
+
await wireTestTransport(realBridge, {
|
|
63
|
+
slot,
|
|
64
|
+
presenceReadvertiseIntervalMs: 50,
|
|
65
|
+
});
|
|
66
|
+
await realBridge.init();
|
|
67
|
+
cleanups.push(async () => {
|
|
68
|
+
realBridge.shutdown();
|
|
69
|
+
releaseIdentityLock(slot);
|
|
70
|
+
});
|
|
71
|
+
await realBridge.registerAgent({
|
|
72
|
+
name: "fronted-session",
|
|
73
|
+
harness: "claude-code",
|
|
74
|
+
cwd: slot.cwd,
|
|
75
|
+
pid: process.pid,
|
|
76
|
+
visibility: "visible",
|
|
77
|
+
tags: [],
|
|
78
|
+
});
|
|
79
|
+
expect(realBridge.peerId).toBe(front.peerId);
|
|
80
|
+
const sharedDeviceId = front.peerId;
|
|
81
|
+
const observer = await startObserver(hub.url);
|
|
82
|
+
observer.addTrustedGateway(sharedDeviceId);
|
|
83
|
+
front.addTrustedGateway(observer.peerId);
|
|
84
|
+
realBridge.addTrustedGateway(observer.peerId);
|
|
85
|
+
await waitForCondition(async () => {
|
|
86
|
+
const agents = await observer.listAgents(observer.peerId);
|
|
87
|
+
return agents.some((agent) => agent.id === sharedDeviceId);
|
|
88
|
+
}, "observer to learn of the shared-identity device via the hub");
|
|
89
|
+
// The front is the older of the two live sessions (it registered first) — shutting it down here stands in for the front's own poll noticing the real bridge now holds the slot and detaching.
|
|
90
|
+
await front.shutdown();
|
|
91
|
+
await waitForCondition(async () => {
|
|
92
|
+
const agents = await observer.listAgents(observer.peerId);
|
|
93
|
+
return agents.some((agent) => agent.id === sharedDeviceId);
|
|
94
|
+
}, "the device to stay routable from the observer once the front (the older session) has shut down, since the real bridge is still live under the same identity");
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
//# sourceMappingURL=front-real-bridge-identity-overlap.integration.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"front-real-bridge-identity-overlap.integration.test.js","sourceRoot":"","sources":["../../src/test/front-real-bridge-identity-overlap.integration.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EACL,iBAAiB,EACjB,OAAO,IAAI,gBAAgB,GAC5B,MAAM,qBAAqB,CAAC;AAG7B,MAAM,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAC;AAErC,SAAS,CAAC,KAAK,IAAI,EAAE;IACnB,MAAM,QAAQ,CAAC,GAAG,EAAE,CAAC;AACvB,CAAC,CAAC,CAAC;AAEH,yOAAyO;AACzO,KAAK,UAAU,aAAa,CAAC,MAAc;IACzC,MAAM,KAAK,GAAG,IAAI,SAAS,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAC5D,MAAM,iBAAiB,CAAC,KAAK,EAAE,EAAE,6BAA6B,EAAE,EAAE,EAAE,CAAC,CAAC;IACtE,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;IACnB,QAAQ,CAAC,IAAI,CAAC,KAAK,IAAI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,QAAQ,CAAC,MAAM,CAAC,CAAC;YAC1D,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,cAAc,CAAC,CAAC;QAC7D,CAAC,EAAE,6DAA6D,CAAC,CAAC;QAElE,8LAA8L;QAC9L,MAAM,KAAK,CAAC,QAAQ,EAAE,CAAC;QAEvB,MAAM,gBAAgB,CAAC,KAAK,IAAI,EAAE;YAChC,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAC1D,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,cAAc,CAAC,CAAC;QAC7D,CAAC,EAAE,6JAA6J,CAAC,CAAC;IACpK,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** Wires a real WireMeshTransport plus a persisted identity slot onto a freshly constructed MeshStore -- the same setTransport()/setIdentity() calls every production bridge makes immediately after construction (via createBridgeMesh). MeshStore has no default transport or identity, so every test that constructs one needs this (or an equivalent explicit wiring) before init(), createRoom(), or any other transport- or identity-using method runs. */
|
|
2
2
|
import { WireMeshTransport } from "../core/wire-mesh-transport.js";
|
|
3
3
|
import type { IdentitySlot } from "../core/identity-store.js";
|
|
4
|
+
import type { PeerIdentity } from "../core/identity.js";
|
|
4
5
|
import type { UserIdentityOptions } from "../core/user-identity.js";
|
|
5
6
|
import type { MeshStore } from "../core/mesh-store.js";
|
|
6
7
|
/** Wires store onto a fresh WireMeshTransport and a persisted identity slot, returning the slot so a test can inspect (or reuse) the persisted room tokens directly via loadRoomTokens(). Defaults to a throwaway temp-dir slot per call -- pass an explicit slot when a test needs the same identity to survive across more than one wireTestTransport call (e.g. simulating a restart). pendingConnectionTimeoutMs overrides WireMeshTransport's own default 5-minute connect_request expiry -- a test proving that expiry behaviour needs it far shorter than any real approval window. presenceReadvertiseIntervalMs likewise overrides the default 20s presence re-advertisement cadence -- a test proving that behaviour needs it far shorter too, or a test that doesn't care about presence at all wants it long enough to never fire spuriously mid-test. Wires getSelfAgentAdvert (`() => store.selfAgentAdvert`) and getHostedRooms (`() => store.hostedRooms`) the same way createBridgeMesh does -- a test relying on gossip carrying the registered agent/self extension (e.g. remote-directory-merge coverage, agent-comms#155) or the hosted-room extension (room discovery through list_rooms) needs these wired exactly like production does. */
|
|
@@ -9,6 +10,8 @@ interface WireTransportOptions {
|
|
|
9
10
|
pendingConnectionTimeoutMs?: number | undefined;
|
|
10
11
|
presenceReadvertiseIntervalMs?: number | undefined;
|
|
11
12
|
userIdentityOptions?: Readonly<UserIdentityOptions> | undefined;
|
|
13
|
+
/** Overrides which identity-store loader resolves this store's identity for the given slot — defaults to loadOrCreateIdentity (the real-bridge path, which takes the slot's exclusivity lock). Pass loadIdentityForFront to model the default cc-peer front's own store instead (agent-comms#299's own reproduction needs both loaders live against one slot at once, which no single wireTestTransport call could otherwise construct). */
|
|
14
|
+
identityLoader?: ((slot: Readonly<IdentitySlot>) => PeerIdentity) | undefined;
|
|
12
15
|
}
|
|
13
16
|
/** Wires store onto a fresh WireMeshTransport and a persisted identity slot, returning the slot so a test can inspect (or reuse) the persisted room tokens directly via loadRoomTokens(). Defaults to a throwaway temp-dir slot per call -- pass an explicit slot when a test needs the same identity to survive across more than one wireTestTransport call (e.g. simulating a restart). pendingConnectionTimeoutMs overrides WireMeshTransport's own default 5-minute connect_request expiry -- a test proving that expiry behaviour needs it far shorter than any real approval window. presenceReadvertiseIntervalMs likewise overrides the default 20s presence re-advertisement cadence -- a test proving that behaviour needs it far shorter too, or a test that doesn't care about presence at all wants it long enough to never fire spuriously mid-test. Wires getSelfAgentAdvert (`() => store.selfAgentAdvert`) and getHostedRooms (`() => store.hostedRooms`) the same way createBridgeMesh does -- a test relying on gossip carrying the registered agent/self extension (e.g. remote-directory-merge coverage, agent-comms#155) or the hosted-room extension (room discovery through list_rooms) needs these wired exactly like production does. */
|
|
14
17
|
export declare function wireTestTransport(store: MeshStore, options?: WireTransportOptions): Promise<IdentitySlot>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-transport.d.ts","sourceRoot":"","sources":["../../src/test/test-transport.ts"],"names":[],"mappings":"AAAA,icAAic;AAKjc,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAMnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"test-transport.d.ts","sourceRoot":"","sources":["../../src/test/test-transport.ts"],"names":[],"mappings":"AAAA,icAAic;AAKjc,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAMnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAKvD,msCAAmsC;AACnsC,UAAU,oBAAoB;IAC5B,IAAI,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC;IAC1C,0BAA0B,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChD,6BAA6B,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnD,mBAAmB,CAAC,EAAE,QAAQ,CAAC,mBAAmB,CAAC,GAAG,SAAS,CAAC;IAChE,4aAA4a;IAC5a,cAAc,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,YAAY,CAAC,KAAK,YAAY,CAAC,GAAG,SAAS,CAAC;CAC/E;AA4DD,msCAAmsC;AACnsC,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,SAAS,EAChB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,YAAY,CAAC,CAGvB;AAED,qcAAqc;AACrc,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,SAAS,EAChB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,SAAS,EAAE,iBAAiB,CAAA;CAAE,CAAC,CAE/D;AAMD;;GAEG;AACH,wBAAsB,OAAO,CAC3B,SAAS,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,EAC3C,WAAW,EAAE,MAAM,EACnB,SAAS,SAA8B,GACtC,OAAO,CAAC,IAAI,CAAC,CAYf"}
|
|
@@ -14,13 +14,13 @@ import { nanoid } from "../core/nanoid.js";
|
|
|
14
14
|
/** Short enough to keep generated test identity slots readable, long enough that two concurrent test runs won't collide on the same throwaway cwd. */
|
|
15
15
|
const TEST_IDENTITY_CWD_ID_LENGTH = 8;
|
|
16
16
|
async function wireTransportInternal(store, options) {
|
|
17
|
-
const { slot, pendingConnectionTimeoutMs, presenceReadvertiseIntervalMs, userIdentityOptions, } = options ?? {};
|
|
17
|
+
const { slot, pendingConnectionTimeoutMs, presenceReadvertiseIntervalMs, userIdentityOptions, identityLoader = loadOrCreateIdentity, } = options ?? {};
|
|
18
18
|
const resolvedSlot = slot ?? {
|
|
19
19
|
harness: "test",
|
|
20
20
|
cwd: nanoid(TEST_IDENTITY_CWD_ID_LENGTH),
|
|
21
21
|
dir: fs.mkdtempSync(path.join(tmpdir(), "agent-comms-test-identity-")),
|
|
22
22
|
};
|
|
23
|
-
const identity =
|
|
23
|
+
const identity = identityLoader(resolvedSlot);
|
|
24
24
|
// A fresh throwaway directory per call, matching resolvedSlot's own default: each test MeshStore represents a separate device belonging to a separate person, so it needs its own user-principal identity, never the real machine-wide ~/.agent-comms/user-identity.json a production bridge shares. A caller that needs to know this store's own principal device-id ahead of time (agent-comms#187's own principal-keyed admission tests) passes an explicit userIdentityOptions naming a directory it already loaded itself, rather than this store minting one it can never be told about afterwards.
|
|
25
25
|
const resolvedUserIdentityOptions = userIdentityOptions ?? {
|
|
26
26
|
dir: fs.mkdtempSync(path.join(tmpdir(), "agent-comms-test-user-identity-")),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-transport.js","sourceRoot":"","sources":["../../src/test/test-transport.ts"],"names":[],"mappings":"AAAA,icAAic;AAEjc,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"test-transport.js","sourceRoot":"","sources":["../../src/test/test-transport.ts"],"names":[],"mappings":"AAAA,icAAic;AAEjc,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B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