@serfab/cadre-host 1.7.0 → 1.9.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/README.md +31 -16
- package/dist/bin/host.js +41 -20
- package/dist/bin/host.js.map +1 -1
- package/dist/donation/donation-service.d.ts +27 -4
- package/dist/donation/donation-service.js +57 -6
- package/dist/donation/donation-service.js.map +1 -1
- package/dist/donation/donation-store.d.ts +3 -1
- package/dist/donation/donation-store.js +5 -1
- package/dist/donation/donation-store.js.map +1 -1
- package/dist/donation/grant-service.d.ts +16 -7
- package/dist/donation/grant-service.js +57 -10
- package/dist/donation/grant-service.js.map +1 -1
- package/dist/donation/index.d.ts +2 -2
- package/dist/donation/index.js +1 -1
- package/dist/donation/index.js.map +1 -1
- package/dist/donation/types.d.ts +29 -7
- package/dist/donation/types.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/nat/address-resolver.d.ts +3 -2
- package/dist/nat/address-resolver.js.map +1 -1
- package/dist/orchestrator/host-process-orchestrator.d.ts +2 -2
- package/dist/orchestrator/host-process-orchestrator.js +22 -12
- package/dist/orchestrator/host-process-orchestrator.js.map +1 -1
- package/dist/orchestrator/node-identity.d.ts +1 -1
- package/dist/orchestrator/node-identity.js +1 -1
- package/dist/orchestrator/port-allocator.d.ts +6 -39
- package/dist/orchestrator/port-allocator.js +9 -89
- package/dist/orchestrator/port-allocator.js.map +1 -1
- package/dist/server/events/types.d.ts +3 -0
- package/dist/server/index.d.ts +19 -18
- package/dist/server/index.js +13 -15
- package/dist/server/index.js.map +1 -1
- package/dist/server/routes/grants-admin.d.ts +15 -3
- package/dist/server/routes/grants-admin.js +33 -7
- package/dist/server/routes/grants-admin.js.map +1 -1
- package/dist/server/routes/nodes.d.ts +13 -5
- package/dist/server/routes/nodes.js +58 -39
- package/dist/server/routes/nodes.js.map +1 -1
- package/dist/server/routes/status.d.ts +13 -0
- package/dist/server/routes/status.js +2 -0
- package/dist/server/routes/status.js.map +1 -1
- package/dist/ui/assets/index-C6nELNfC.js +23 -0
- package/dist/ui/assets/index-C6nELNfC.js.map +1 -0
- package/dist/ui/assets/index-TtIYSeZO.css +1 -0
- package/dist/ui/index.html +2 -2
- package/package.json +4 -4
- package/src/__tests__/global-setup.ts +58 -56
- package/src/__tests__/orchestrator-env-scrub.test.ts +12 -11
- package/src/__tests__/orchestrator-handle-contract.ts +134 -0
- package/src/__tests__/orchestrator-node-identity.test.ts +6 -7
- package/src/__tests__/orchestrator-owner.test.ts +6 -13
- package/src/__tests__/orchestrator-pin-keys.test.ts +6 -7
- package/src/__tests__/orchestrator-ports.test.ts +5 -34
- package/src/__tests__/orchestrator-push.test.ts +6 -5
- package/src/__tests__/orchestrator-teardown.ts +65 -0
- package/src/__tests__/orchestrator.test.ts +23 -22
- package/src/auth/__tests__/trust-circle-integration.test.ts +1 -1
- package/src/bin/host.ts +56 -33
- package/src/donation/__tests__/donation-service.test.ts +38 -0
- package/src/donation/__tests__/fake-orchestrator.test.ts +19 -14
- package/src/donation/__tests__/fake-orchestrator.ts +21 -3
- package/src/donation/__tests__/grant-service.test.ts +2 -2
- package/src/donation/donation-service.ts +58 -6
- package/src/donation/donation-store.ts +176 -171
- package/src/donation/grant-service.ts +252 -200
- package/src/donation/index.ts +65 -64
- package/src/donation/types.ts +260 -244
- package/src/index.ts +2 -0
- package/src/nat/address-resolver.ts +3 -2
- package/src/orchestrator/host-process-orchestrator.ts +1260 -1251
- package/src/orchestrator/node-identity.ts +1 -1
- package/src/orchestrator/port-allocator.ts +16 -91
- package/src/server/__tests__/fakes.ts +44 -0
- package/src/server/__tests__/grants-admin-route.test.ts +171 -73
- package/src/server/__tests__/nodes-route.test.ts +49 -25
- package/src/server/__tests__/publishers.test.ts +5 -41
- package/src/server/__tests__/server.smoke.test.ts +7 -37
- package/src/server/__tests__/status-route.test.ts +8 -21
- package/src/server/__tests__/strands-route.test.ts +3 -2
- package/src/server/events/types.ts +24 -23
- package/src/server/index.ts +267 -267
- package/src/server/routes/grants-admin.ts +74 -41
- package/src/server/routes/nodes.ts +61 -43
- package/src/server/routes/status.ts +16 -0
- package/dist/donation/__tests__/fake-orchestrator.d.ts +0 -103
- package/dist/donation/__tests__/fake-orchestrator.js +0 -180
- package/dist/donation/__tests__/fake-orchestrator.js.map +0 -1
- package/dist/ui/assets/index-BVoqLjyX.css +0 -1
- package/dist/ui/assets/index-CEoNRwM_.js +0 -17
- package/dist/ui/assets/index-CEoNRwM_.js.map +0 -1
|
@@ -6,16 +6,24 @@
|
|
|
6
6
|
* `onStateChange` (forwarded by `createLocalUiServer.start`) — the route
|
|
7
7
|
* handlers don't re-publish.
|
|
8
8
|
*
|
|
9
|
-
* start/restart are real for the admin's owner node (
|
|
10
|
-
* persisted `OwnerSpawnConfig`).
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
9
|
+
* start/stop/restart are real for the admin's owner node only (start/restart
|
|
10
|
+
* re-spawn it from the persisted `OwnerSpawnConfig`). Every other node this
|
|
11
|
+
* route can see is a donated node, whose lifecycle belongs to the donation
|
|
12
|
+
* surface — this route no longer spawns generic nodes, and a stop here would
|
|
13
|
+
* be undone at once by the donation supervisor's respawn. So all three verbs
|
|
14
|
+
* answer a known non-owner node with 501, pointing at the donation teardown.
|
|
15
|
+
*
|
|
16
|
+
* Owner start/restart are founder-only: a donor-only host that once ran as a
|
|
17
|
+
* founder still holds the owner handle and saved config (so re-enabling
|
|
18
|
+
* `ownCadre` can resume it), but spawning it here would bring the owner node
|
|
19
|
+
* back without its trust circle, NAT or strand services — so those answer 409.
|
|
14
20
|
*/
|
|
15
21
|
import type { FastifyInstance } from 'fastify';
|
|
16
22
|
import type { HostProcessOrchestrator } from '../../orchestrator/index.js';
|
|
23
|
+
import type { HostRole } from './status.js';
|
|
17
24
|
export interface NodesRoutesOptions {
|
|
18
25
|
orchestrator: HostProcessOrchestrator;
|
|
26
|
+
role: HostRole;
|
|
19
27
|
}
|
|
20
28
|
export declare function registerNodesRoutes(app: FastifyInstance, opts: NodesRoutesOptions): void;
|
|
21
29
|
/**
|
|
@@ -6,29 +6,31 @@
|
|
|
6
6
|
* `onStateChange` (forwarded by `createLocalUiServer.start`) — the route
|
|
7
7
|
* handlers don't re-publish.
|
|
8
8
|
*
|
|
9
|
-
* start/restart are real for the admin's owner node (
|
|
10
|
-
* persisted `OwnerSpawnConfig`).
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
9
|
+
* start/stop/restart are real for the admin's owner node only (start/restart
|
|
10
|
+
* re-spawn it from the persisted `OwnerSpawnConfig`). Every other node this
|
|
11
|
+
* route can see is a donated node, whose lifecycle belongs to the donation
|
|
12
|
+
* surface — this route no longer spawns generic nodes, and a stop here would
|
|
13
|
+
* be undone at once by the donation supervisor's respawn. So all three verbs
|
|
14
|
+
* answer a known non-owner node with 501, pointing at the donation teardown.
|
|
15
|
+
*
|
|
16
|
+
* Owner start/restart are founder-only: a donor-only host that once ran as a
|
|
17
|
+
* founder still holds the owner handle and saved config (so re-enabling
|
|
18
|
+
* `ownCadre` can resume it), but spawning it here would bring the owner node
|
|
19
|
+
* back without its trust circle, NAT or strand services — so those answer 409.
|
|
14
20
|
*/
|
|
15
21
|
import { existsSync, openSync, readSync, closeSync, statSync } from 'node:fs';
|
|
16
22
|
import { defaultLogPath } from '../../orchestrator/log-rotator.js';
|
|
17
23
|
const DEFAULT_LOG_LINES = 200;
|
|
18
24
|
const MAX_LOG_LINES = 2000;
|
|
19
25
|
export function registerNodesRoutes(app, opts) {
|
|
20
|
-
const { orchestrator } = opts;
|
|
26
|
+
const { orchestrator, role } = opts;
|
|
21
27
|
app.get('/api/nodes', async () => {
|
|
22
28
|
return { ok: true, data: { nodes: orchestrator.listNodes() } };
|
|
23
29
|
});
|
|
24
30
|
app.get('/api/nodes/:id', async (request, reply) => {
|
|
25
31
|
const node = orchestrator.getNode(request.params.id);
|
|
26
|
-
if (!node)
|
|
27
|
-
return reply.
|
|
28
|
-
ok: false,
|
|
29
|
-
error: { code: 'not_found', message: `Unknown node: ${request.params.id}` },
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
+
if (!node)
|
|
33
|
+
return notFound(reply, request.params.id);
|
|
32
34
|
let stats = null;
|
|
33
35
|
try {
|
|
34
36
|
stats = await orchestrator.getStats(node.dockerId);
|
|
@@ -40,12 +42,8 @@ export function registerNodesRoutes(app, opts) {
|
|
|
40
42
|
});
|
|
41
43
|
app.get('/api/nodes/:id/logs', async (request, reply) => {
|
|
42
44
|
const node = orchestrator.getNode(request.params.id);
|
|
43
|
-
if (!node)
|
|
44
|
-
return reply.
|
|
45
|
-
ok: false,
|
|
46
|
-
error: { code: 'not_found', message: `Unknown node: ${request.params.id}` },
|
|
47
|
-
});
|
|
48
|
-
}
|
|
45
|
+
if (!node)
|
|
46
|
+
return notFound(reply, request.params.id);
|
|
49
47
|
const requested = Number(request.query.lines ?? DEFAULT_LOG_LINES);
|
|
50
48
|
const tail = Number.isFinite(requested)
|
|
51
49
|
? Math.max(1, Math.min(MAX_LOG_LINES, Math.floor(requested)))
|
|
@@ -53,59 +51,80 @@ export function registerNodesRoutes(app, opts) {
|
|
|
53
51
|
const lines = tailLogFile(defaultLogPath(node.workdir), tail);
|
|
54
52
|
return { ok: true, data: { lines } };
|
|
55
53
|
});
|
|
54
|
+
// start / stop / restart: real for the admin's owner node (started from the
|
|
55
|
+
// persisted OwnerSpawnConfig). Donated-node lifecycle belongs to the donation
|
|
56
|
+
// surface — those ids return a clear not_implemented that points there;
|
|
57
|
+
// unknown ids 404.
|
|
56
58
|
app.post('/api/nodes/:id/stop', async (request, reply) => {
|
|
57
|
-
const
|
|
58
|
-
if (!
|
|
59
|
-
return reply
|
|
60
|
-
ok: false,
|
|
61
|
-
error: { code: 'not_found', message: `Unknown node: ${request.params.id}` },
|
|
62
|
-
});
|
|
59
|
+
const { id } = request.params;
|
|
60
|
+
if (!orchestrator.isOwnerNode(id)) {
|
|
61
|
+
return ownerOnlyFallback(reply, orchestrator, id, 'stop');
|
|
63
62
|
}
|
|
63
|
+
const dockerId = orchestrator.resolveDockerId(id);
|
|
64
|
+
if (!dockerId)
|
|
65
|
+
return notFound(reply, id);
|
|
64
66
|
await orchestrator.stopContainer(dockerId);
|
|
65
67
|
// The orchestrator emits its own onStateChange — createLocalUiServer
|
|
66
68
|
// forwards that to the bus. Don't double-publish here.
|
|
67
69
|
return { ok: true };
|
|
68
70
|
});
|
|
69
|
-
// start / restart: real for the admin's owner node (spawned from the
|
|
70
|
-
// persisted OwnerSpawnConfig). Generic node lifecycle now belongs to the
|
|
71
|
-
// donation surface (/grants) — those ids return a clear not_implemented that
|
|
72
|
-
// points there; unknown ids 404.
|
|
73
71
|
app.post('/api/nodes/:id/start', async (request, reply) => {
|
|
74
72
|
const { id } = request.params;
|
|
75
73
|
if (orchestrator.isOwnerNode(id)) {
|
|
74
|
+
if (role === 'donor')
|
|
75
|
+
return ownCadreDisabled(reply, 'start');
|
|
76
76
|
if (!orchestrator.hasOwnerConfig()) {
|
|
77
77
|
return notImplemented(reply, `start ${id}: owner node has no saved spawn config.`);
|
|
78
78
|
}
|
|
79
79
|
const node = await orchestrator.ensureOwnerNode();
|
|
80
80
|
return { ok: true, data: { node } };
|
|
81
81
|
}
|
|
82
|
-
return
|
|
82
|
+
return ownerOnlyFallback(reply, orchestrator, id, 'start');
|
|
83
83
|
});
|
|
84
84
|
app.post('/api/nodes/:id/restart', async (request, reply) => {
|
|
85
85
|
const { id } = request.params;
|
|
86
86
|
if (orchestrator.isOwnerNode(id)) {
|
|
87
|
+
if (role === 'donor')
|
|
88
|
+
return ownCadreDisabled(reply, 'restart');
|
|
87
89
|
if (!orchestrator.hasOwnerConfig()) {
|
|
88
90
|
return notImplemented(reply, `restart ${id}: owner node has no saved spawn config.`);
|
|
89
91
|
}
|
|
90
92
|
const node = await orchestrator.restartOwnerNode();
|
|
91
93
|
return { ok: true, data: { node } };
|
|
92
94
|
}
|
|
93
|
-
return
|
|
95
|
+
return ownerOnlyFallback(reply, orchestrator, id, 'restart');
|
|
94
96
|
});
|
|
95
97
|
}
|
|
96
|
-
/**
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
98
|
+
/**
|
|
99
|
+
* 404 for unknown ids; 501 not_implemented for known non-owner nodes — all of
|
|
100
|
+
* them donated. A donated node's containerId is its donation id, so the
|
|
101
|
+
* message names `node.id` rather than the route param, which may be the
|
|
102
|
+
* opaque dockerId — only the donation id is what the terminate command takes.
|
|
103
|
+
*/
|
|
104
|
+
function ownerOnlyFallback(reply, orchestrator, id, verb) {
|
|
105
|
+
const node = orchestrator.getNode(id);
|
|
106
|
+
if (!node)
|
|
107
|
+
return notFound(reply, id);
|
|
108
|
+
return notImplemented(reply, `${verb} ${id}: only the owner node can be started, stopped or restarted here; a donated node's lifecycle is owned by the donation surface — end it with 'cadre-host grant terminate ${node.id}' (DELETE /grants-admin/donations/${node.id}).`);
|
|
109
|
+
}
|
|
110
|
+
function notFound(reply, id) {
|
|
111
|
+
return reply.code(404).send({
|
|
112
|
+
ok: false,
|
|
113
|
+
error: { code: 'not_found', message: `Unknown node: ${id}` },
|
|
114
|
+
});
|
|
105
115
|
}
|
|
106
116
|
function notImplemented(reply, message) {
|
|
107
117
|
return reply.code(501).send({ ok: false, error: { code: 'not_implemented', message } });
|
|
108
118
|
}
|
|
119
|
+
function ownCadreDisabled(reply, verb) {
|
|
120
|
+
return reply.code(409).send({
|
|
121
|
+
ok: false,
|
|
122
|
+
error: {
|
|
123
|
+
code: 'own_cadre_disabled',
|
|
124
|
+
message: `${verb} owner: this host's own cadre is turned off (donor-only mode). Set ownCadre.enabled in host.config.json and restart cadre-host to run it again.`,
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
}
|
|
109
128
|
/**
|
|
110
129
|
* Read the last `n` lines from a log file by walking the tail in chunks.
|
|
111
130
|
* Returns [] for a missing file.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../src/server/routes/nodes.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../src/server/routes/nodes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAK9E,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAInE,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,aAAa,GAAG,IAAI,CAAC;AAO3B,MAAM,UAAU,mBAAmB,CAAC,GAAoB,EAAE,IAAwB;IAChF,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IAEpC,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE;QAC/B,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,YAAY,CAAC,SAAS,EAAE,EAAE,EAAE,CAAC;IACjE,CAAC,CAAC,CAAC;IAEH,GAAG,CAAC,GAAG,CAA6B,gBAAgB,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QAC7E,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACrD,IAAI,CAAC,IAAI;YAAE,OAAO,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACrD,IAAI,KAAK,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC;YACH,KAAK,GAAG,MAAM,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrD,CAAC;QAAC,MAAM,CAAC;YACP,wDAAwD;QAC1D,CAAC;QAC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C,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACpC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI;oBAAE,YAAY,EAAE,CAAC;YACtC,CAAC;QACH,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACvD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjC,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAC5E,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;YAAS,CAAC;QACT,SAAS,CAAC,EAAE,CAAC,CAAC;IAChB,CAAC;AACH,CAAC"}
|
|
@@ -11,8 +11,14 @@ import type { TrustCircleService } from '../../auth/index.js';
|
|
|
11
11
|
import type { NatService } from '../../nat/index.js';
|
|
12
12
|
import type { NatStatusSnapshot } from '../../nat/types.js';
|
|
13
13
|
import type { UpdateService } from '../../update/index.js';
|
|
14
|
+
/**
|
|
15
|
+
* Which role the running process is in: `'founder'` also runs the host's own
|
|
16
|
+
* cadre (`ownCadre.enabled` at start), `'donor'` only donates nodes.
|
|
17
|
+
*/
|
|
18
|
+
export type HostRole = 'founder' | 'donor';
|
|
14
19
|
export interface StatusRouteOptions {
|
|
15
20
|
orchestrator: HostProcessOrchestrator;
|
|
21
|
+
role: HostRole;
|
|
16
22
|
/** Present only when the host runs its own personal cadre (`ownCadre.enabled`). */
|
|
17
23
|
trustCircle?: TrustCircleService;
|
|
18
24
|
/** Present only when the host runs its own personal cadre (`ownCadre.enabled`). */
|
|
@@ -25,11 +31,18 @@ export interface StatusResponse {
|
|
|
25
31
|
version: string;
|
|
26
32
|
uptimeSeconds: number;
|
|
27
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Decided at start from `ownCadre.enabled` — the running process, not the file
|
|
36
|
+
* on disk, which may have been edited since without a restart.
|
|
37
|
+
*/
|
|
38
|
+
role: HostRole;
|
|
28
39
|
nodes: Array<{
|
|
29
40
|
id: string;
|
|
30
41
|
partyId: string;
|
|
31
42
|
status: ManagedNodeInfo['status'];
|
|
32
43
|
profile: ManagedNodeInfo['profile'];
|
|
44
|
+
/** Present (true) only on the host's own owner node; every other node is donated. */
|
|
45
|
+
owner?: true;
|
|
33
46
|
}>;
|
|
34
47
|
/** Omitted in donor-only mode (no host-own trust circle). */
|
|
35
48
|
trustCircle?: {
|
|
@@ -16,6 +16,7 @@ export function registerStatusRoute(app, opts) {
|
|
|
16
16
|
partyId: n.partyId,
|
|
17
17
|
status: n.status,
|
|
18
18
|
profile: n.profile,
|
|
19
|
+
...(n.owner ? { owner: true } : {}),
|
|
19
20
|
}));
|
|
20
21
|
const response = {
|
|
21
22
|
service: {
|
|
@@ -23,6 +24,7 @@ export function registerStatusRoute(app, opts) {
|
|
|
23
24
|
version,
|
|
24
25
|
uptimeSeconds: secondsSince(PROCESS_STARTED_AT),
|
|
25
26
|
},
|
|
27
|
+
role: opts.role,
|
|
26
28
|
nodes,
|
|
27
29
|
};
|
|
28
30
|
// Trust-circle + connectivity exist only when the host runs its own
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/server/routes/status.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAWzC,MAAM,kBAAkB,GAAG,OAAO,CAAC,MAAM,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