agent-recorder 0.0.9 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/package.json +1 -1
  2. package/vendor/node_modules/@agent-recorder/cli/commands/configure-wrap.d.ts.map +1 -1
  3. package/vendor/node_modules/@agent-recorder/cli/commands/configure-wrap.js +5 -31
  4. package/vendor/node_modules/@agent-recorder/cli/commands/configure-wrap.js.map +1 -1
  5. package/vendor/node_modules/@agent-recorder/cli/commands/configure.d.ts +2 -0
  6. package/vendor/node_modules/@agent-recorder/cli/commands/configure.d.ts.map +1 -1
  7. package/vendor/node_modules/@agent-recorder/cli/commands/configure.js +117 -1
  8. package/vendor/node_modules/@agent-recorder/cli/commands/configure.js.map +1 -1
  9. package/vendor/node_modules/@agent-recorder/cli/commands/doctor.d.ts.map +1 -1
  10. package/vendor/node_modules/@agent-recorder/cli/commands/doctor.js +113 -19
  11. package/vendor/node_modules/@agent-recorder/cli/commands/doctor.js.map +1 -1
  12. package/vendor/node_modules/@agent-recorder/cli/commands/doctor.test.d.ts +5 -0
  13. package/vendor/node_modules/@agent-recorder/cli/commands/doctor.test.d.ts.map +1 -0
  14. package/vendor/node_modules/@agent-recorder/cli/commands/doctor.test.js +152 -0
  15. package/vendor/node_modules/@agent-recorder/cli/commands/doctor.test.js.map +1 -0
  16. package/vendor/node_modules/@agent-recorder/cli/commands/install.d.ts +7 -1
  17. package/vendor/node_modules/@agent-recorder/cli/commands/install.d.ts.map +1 -1
  18. package/vendor/node_modules/@agent-recorder/cli/commands/install.js +89 -14
  19. package/vendor/node_modules/@agent-recorder/cli/commands/install.js.map +1 -1
  20. package/vendor/node_modules/@agent-recorder/cli/commands/install.test.d.ts +5 -0
  21. package/vendor/node_modules/@agent-recorder/cli/commands/install.test.d.ts.map +1 -0
  22. package/vendor/node_modules/@agent-recorder/cli/commands/install.test.js +173 -0
  23. package/vendor/node_modules/@agent-recorder/cli/commands/install.test.js.map +1 -0
  24. package/vendor/node_modules/@agent-recorder/cli/commands/start.d.ts.map +1 -1
  25. package/vendor/node_modules/@agent-recorder/cli/commands/start.js +29 -4
  26. package/vendor/node_modules/@agent-recorder/cli/commands/start.js.map +1 -1
  27. package/vendor/node_modules/@agent-recorder/cli/config/hubify.d.ts +51 -0
  28. package/vendor/node_modules/@agent-recorder/cli/config/hubify.d.ts.map +1 -0
  29. package/vendor/node_modules/@agent-recorder/cli/config/hubify.js +125 -0
  30. package/vendor/node_modules/@agent-recorder/cli/config/hubify.js.map +1 -0
  31. package/vendor/node_modules/@agent-recorder/cli/config/hubify.test.d.ts +5 -0
  32. package/vendor/node_modules/@agent-recorder/cli/config/hubify.test.d.ts.map +1 -0
  33. package/vendor/node_modules/@agent-recorder/cli/config/hubify.test.js +329 -0
  34. package/vendor/node_modules/@agent-recorder/cli/config/hubify.test.js.map +1 -0
  35. package/vendor/node_modules/@agent-recorder/cli/index.js +7 -3
  36. package/vendor/node_modules/@agent-recorder/cli/index.js.map +1 -1
  37. package/vendor/node_modules/@agent-recorder/core/claude-config.d.ts +32 -0
  38. package/vendor/node_modules/@agent-recorder/core/claude-config.d.ts.map +1 -0
  39. package/vendor/node_modules/@agent-recorder/core/claude-config.js +65 -0
  40. package/vendor/node_modules/@agent-recorder/core/claude-config.js.map +1 -0
  41. package/vendor/node_modules/@agent-recorder/core/index.d.ts +3 -0
  42. package/vendor/node_modules/@agent-recorder/core/index.d.ts.map +1 -1
  43. package/vendor/node_modules/@agent-recorder/core/index.js +3 -0
  44. package/vendor/node_modules/@agent-recorder/core/index.js.map +1 -1
  45. package/vendor/node_modules/@agent-recorder/core/providers/index.d.ts +9 -0
  46. package/vendor/node_modules/@agent-recorder/core/providers/index.d.ts.map +1 -0
  47. package/vendor/node_modules/@agent-recorder/core/providers/index.js +9 -0
  48. package/vendor/node_modules/@agent-recorder/core/providers/index.js.map +1 -0
  49. package/vendor/node_modules/@agent-recorder/core/providers/io.d.ts +36 -0
  50. package/vendor/node_modules/@agent-recorder/core/providers/io.d.ts.map +1 -0
  51. package/vendor/node_modules/@agent-recorder/core/providers/io.js +88 -0
  52. package/vendor/node_modules/@agent-recorder/core/providers/io.js.map +1 -0
  53. package/vendor/node_modules/@agent-recorder/core/providers/io.test.d.ts +5 -0
  54. package/vendor/node_modules/@agent-recorder/core/providers/io.test.d.ts.map +1 -0
  55. package/vendor/node_modules/@agent-recorder/core/providers/io.test.js +248 -0
  56. package/vendor/node_modules/@agent-recorder/core/providers/io.test.js.map +1 -0
  57. package/vendor/node_modules/@agent-recorder/core/providers/types.d.ts +36 -0
  58. package/vendor/node_modules/@agent-recorder/core/providers/types.d.ts.map +1 -0
  59. package/vendor/node_modules/@agent-recorder/core/providers/types.js +6 -0
  60. package/vendor/node_modules/@agent-recorder/core/providers/types.js.map +1 -0
  61. package/vendor/node_modules/@agent-recorder/core/wrap-utils.d.ts +42 -0
  62. package/vendor/node_modules/@agent-recorder/core/wrap-utils.d.ts.map +1 -0
  63. package/vendor/node_modules/@agent-recorder/core/wrap-utils.js +80 -0
  64. package/vendor/node_modules/@agent-recorder/core/wrap-utils.js.map +1 -0
  65. package/vendor/node_modules/@agent-recorder/service/index.d.ts.map +1 -1
  66. package/vendor/node_modules/@agent-recorder/service/index.js +19 -0
  67. package/vendor/node_modules/@agent-recorder/service/index.js.map +1 -1
  68. package/vendor/node_modules/@agent-recorder/service/mcp/auto-wrap-manager.d.ts +43 -0
  69. package/vendor/node_modules/@agent-recorder/service/mcp/auto-wrap-manager.d.ts.map +1 -0
  70. package/vendor/node_modules/@agent-recorder/service/mcp/auto-wrap-manager.js +221 -0
  71. package/vendor/node_modules/@agent-recorder/service/mcp/auto-wrap-manager.js.map +1 -0
  72. package/vendor/node_modules/@agent-recorder/service/mcp/hub.test.d.ts +6 -0
  73. package/vendor/node_modules/@agent-recorder/service/mcp/hub.test.d.ts.map +1 -0
  74. package/vendor/node_modules/@agent-recorder/service/mcp/hub.test.js +319 -0
  75. package/vendor/node_modules/@agent-recorder/service/mcp/hub.test.js.map +1 -0
  76. package/vendor/node_modules/@agent-recorder/service/mcp/proxy.d.ts +1 -0
  77. package/vendor/node_modules/@agent-recorder/service/mcp/proxy.d.ts.map +1 -1
  78. package/vendor/node_modules/@agent-recorder/service/mcp/proxy.js +239 -34
  79. package/vendor/node_modules/@agent-recorder/service/mcp/proxy.js.map +1 -1
  80. package/vendor/node_modules/@agent-recorder/service/routes/events.d.ts.map +1 -1
  81. package/vendor/node_modules/@agent-recorder/service/routes/events.js +1 -0
  82. package/vendor/node_modules/@agent-recorder/service/routes/events.js.map +1 -1
@@ -0,0 +1,319 @@
1
+ /**
2
+ * Tests for MCP Hub mode.
3
+ * Verifies tools/list aggregation and tools/call routing with multiple providers.
4
+ */
5
+ import { describe, it, expect, beforeEach, afterEach } from "vitest";
6
+ import Fastify, {} from "fastify";
7
+ import { loadConfig, openMemoryDatabase, runMigrations, writeProvidersFile, getDefaultProvidersPath, } from "@agent-recorder/core";
8
+ import { createMcpProxy } from "./proxy.js";
9
+ import * as fs from "node:fs";
10
+ import { join, dirname } from "node:path";
11
+ import { fileURLToPath } from "node:url";
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = dirname(__filename);
14
+ /**
15
+ * Create a mock MCP server that responds to tools/list and tools/call.
16
+ */
17
+ async function createMockMcpServer(port, tools) {
18
+ const app = Fastify({ logger: false });
19
+ // Mock tools/list endpoint
20
+ app.post("/", async (request, reply) => {
21
+ const body = request.body;
22
+ if (body.method === "tools/list") {
23
+ return reply.code(200).send({
24
+ jsonrpc: "2.0",
25
+ result: {
26
+ tools: tools.map((t) => ({
27
+ name: t.name,
28
+ description: t.description,
29
+ inputSchema: { type: "object", properties: {} },
30
+ })),
31
+ },
32
+ id: body.id ?? null,
33
+ });
34
+ }
35
+ if (body.method === "tools/call") {
36
+ const params = body.params;
37
+ const tool = tools.find((t) => t.name === params.name);
38
+ if (!tool) {
39
+ return reply.code(200).send({
40
+ jsonrpc: "2.0",
41
+ error: {
42
+ code: -32602,
43
+ message: `Unknown tool: ${params.name}`,
44
+ },
45
+ id: body.id ?? null,
46
+ });
47
+ }
48
+ return reply.code(200).send({
49
+ jsonrpc: "2.0",
50
+ result: { success: true, tool: params.name },
51
+ id: body.id ?? null,
52
+ });
53
+ }
54
+ return reply.code(400).send({
55
+ jsonrpc: "2.0",
56
+ error: { code: -32601, message: "Method not found" },
57
+ id: body.id ?? null,
58
+ });
59
+ });
60
+ await app.listen({ port, host: "127.0.0.1" });
61
+ return {
62
+ app,
63
+ close: async () => {
64
+ await app.close();
65
+ },
66
+ };
67
+ }
68
+ describe("MCP Hub Mode", () => {
69
+ let db;
70
+ let sessionId;
71
+ let mockServer1;
72
+ let mockServer2;
73
+ beforeEach(async () => {
74
+ // Create in-memory database with migrations
75
+ db = openMemoryDatabase();
76
+ const migrationsDir = join(__dirname, "..", "..", "..", "core", "migrations");
77
+ runMigrations(db, migrationsDir);
78
+ // Create session
79
+ sessionId = "test-session-hub";
80
+ db.prepare("INSERT INTO sessions (id, started_at, status, created_at) VALUES (?, datetime('now'), ?, datetime('now'))").run(sessionId, "active");
81
+ // Start mock MCP servers
82
+ mockServer1 = await createMockMcpServer(9991, [
83
+ { name: "echo", description: "Echo tool" },
84
+ { name: "uppercase", description: "Uppercase tool" },
85
+ ]);
86
+ mockServer2 = await createMockMcpServer(9992, [
87
+ { name: "reverse", description: "Reverse tool" },
88
+ { name: "lowercase", description: "Lowercase tool" },
89
+ ]);
90
+ });
91
+ afterEach(async () => {
92
+ if (mockServer1)
93
+ await mockServer1.close();
94
+ if (mockServer2)
95
+ await mockServer2.close();
96
+ if (db)
97
+ db.close();
98
+ });
99
+ it("aggregates tools/list from multiple providers with namespacing", async () => {
100
+ // Write providers BEFORE creating proxy so it loads them during init
101
+ writeProvidersFile({
102
+ version: 1,
103
+ providers: [
104
+ { id: "server1", type: "http", url: "http://127.0.0.1:9991/" },
105
+ { id: "server2", type: "http", url: "http://127.0.0.1:9992/" },
106
+ ],
107
+ }, getDefaultProvidersPath());
108
+ const config = loadConfig();
109
+ const { app, close } = await createMcpProxy({
110
+ db,
111
+ config: {
112
+ ...config,
113
+ // Override providers path for test
114
+ mcpProxyPort: 19991,
115
+ },
116
+ sessionId,
117
+ });
118
+ try {
119
+ await app.listen({ port: 19991, host: "127.0.0.1" });
120
+ // Call tools/list
121
+ const response = await fetch("http://127.0.0.1:19991/", {
122
+ method: "POST",
123
+ headers: { "Content-Type": "application/json" },
124
+ body: JSON.stringify({
125
+ jsonrpc: "2.0",
126
+ method: "tools/list",
127
+ id: 1,
128
+ }),
129
+ });
130
+ expect(response.status).toBe(200);
131
+ const data = (await response.json());
132
+ const tools = data.result.tools;
133
+ // Verify namespaced tool names from both providers
134
+ expect(tools).toHaveLength(4);
135
+ const toolNames = tools.map((t) => t.name).sort();
136
+ expect(toolNames).toEqual([
137
+ "server1.echo",
138
+ "server1.uppercase",
139
+ "server2.lowercase",
140
+ "server2.reverse",
141
+ ]);
142
+ }
143
+ finally {
144
+ await close();
145
+ // Cleanup providers file
146
+ if (fs.existsSync(getDefaultProvidersPath())) {
147
+ fs.unlinkSync(getDefaultProvidersPath());
148
+ }
149
+ }
150
+ });
151
+ it("routes tools/call to correct provider and records with upstreamKey", async () => {
152
+ // Write providers BEFORE creating proxy so it loads them during init
153
+ writeProvidersFile({
154
+ version: 1,
155
+ providers: [
156
+ { id: "server1", type: "http", url: "http://127.0.0.1:9991/" },
157
+ { id: "server2", type: "http", url: "http://127.0.0.1:9992/" },
158
+ ],
159
+ }, getDefaultProvidersPath());
160
+ const config = loadConfig();
161
+ const { app, close } = await createMcpProxy({
162
+ db,
163
+ config: {
164
+ ...config,
165
+ mcpProxyPort: 19992,
166
+ },
167
+ sessionId,
168
+ });
169
+ try {
170
+ await app.listen({ port: 19992, host: "127.0.0.1" });
171
+ // Call namespaced tool from server1
172
+ const response1 = await fetch("http://127.0.0.1:19992/", {
173
+ method: "POST",
174
+ headers: { "Content-Type": "application/json" },
175
+ body: JSON.stringify({
176
+ jsonrpc: "2.0",
177
+ method: "tools/call",
178
+ params: { name: "server1.echo", arguments: { text: "hello" } },
179
+ id: 2,
180
+ }),
181
+ });
182
+ expect(response1.status).toBe(200);
183
+ const data1 = (await response1.json());
184
+ expect(data1.result.tool).toBe("echo"); // Tool name without namespace
185
+ // Call namespaced tool from server2
186
+ const response2 = await fetch("http://127.0.0.1:19992/", {
187
+ method: "POST",
188
+ headers: { "Content-Type": "application/json" },
189
+ body: JSON.stringify({
190
+ jsonrpc: "2.0",
191
+ method: "tools/call",
192
+ params: { name: "server2.reverse", arguments: { text: "world" } },
193
+ id: 3,
194
+ }),
195
+ });
196
+ expect(response2.status).toBe(200);
197
+ const data2 = (await response2.json());
198
+ expect(data2.result.tool).toBe("reverse");
199
+ // Verify events recorded with correct upstreamKey
200
+ const events = db
201
+ .prepare("SELECT * FROM events WHERE session_id = ? ORDER BY sequence ASC")
202
+ .all(sessionId);
203
+ expect(events).toHaveLength(2);
204
+ // First event: server1.echo -> routed to server1
205
+ expect(events[0].tool_name).toBe("echo");
206
+ expect(events[0].upstream_key).toBe("server1");
207
+ expect(events[0].status).toBe("success");
208
+ // Second event: server2.reverse -> routed to server2
209
+ expect(events[1].tool_name).toBe("reverse");
210
+ expect(events[1].upstream_key).toBe("server2");
211
+ expect(events[1].status).toBe("success");
212
+ }
213
+ finally {
214
+ await close();
215
+ if (fs.existsSync(getDefaultProvidersPath())) {
216
+ fs.unlinkSync(getDefaultProvidersPath());
217
+ }
218
+ }
219
+ });
220
+ it("handles unknown provider gracefully", async () => {
221
+ // Write providers BEFORE creating proxy so it loads them during init
222
+ writeProvidersFile({
223
+ version: 1,
224
+ providers: [
225
+ { id: "server1", type: "http", url: "http://127.0.0.1:9991/" },
226
+ ],
227
+ }, getDefaultProvidersPath());
228
+ const config = loadConfig();
229
+ const { app, close } = await createMcpProxy({
230
+ db,
231
+ config: {
232
+ ...config,
233
+ mcpProxyPort: 19993,
234
+ },
235
+ sessionId,
236
+ });
237
+ try {
238
+ await app.listen({ port: 19993, host: "127.0.0.1" });
239
+ // Call tool with unknown provider ID
240
+ const response = await fetch("http://127.0.0.1:19993/", {
241
+ method: "POST",
242
+ headers: { "Content-Type": "application/json" },
243
+ body: JSON.stringify({
244
+ jsonrpc: "2.0",
245
+ method: "tools/call",
246
+ params: { name: "unknown.tool", arguments: {} },
247
+ id: 4,
248
+ }),
249
+ });
250
+ expect(response.status).toBe(404);
251
+ const data = (await response.json());
252
+ expect(data.error.message).toContain("Unknown provider");
253
+ expect(data.error.data.category).toBe("downstream_unreachable");
254
+ // Verify error event recorded
255
+ const events = db
256
+ .prepare("SELECT * FROM events WHERE session_id = ?")
257
+ .all(sessionId);
258
+ expect(events).toHaveLength(1);
259
+ expect(events[0].tool_name).toBe("tool");
260
+ expect(events[0].upstream_key).toBe("unknown");
261
+ expect(events[0].status).toBe("error");
262
+ expect(events[0].error_category).toBe("downstream_unreachable");
263
+ }
264
+ finally {
265
+ await close();
266
+ if (fs.existsSync(getDefaultProvidersPath())) {
267
+ fs.unlinkSync(getDefaultProvidersPath());
268
+ }
269
+ }
270
+ });
271
+ it("handles provider failure during tools/list gracefully", async () => {
272
+ // Write providers BEFORE creating proxy so it loads them during init
273
+ // Include one unreachable provider
274
+ writeProvidersFile({
275
+ version: 1,
276
+ providers: [
277
+ { id: "server1", type: "http", url: "http://127.0.0.1:9991/" },
278
+ { id: "unreachable", type: "http", url: "http://127.0.0.1:19999/" },
279
+ ],
280
+ }, getDefaultProvidersPath());
281
+ const config = loadConfig();
282
+ const { app, close } = await createMcpProxy({
283
+ db,
284
+ config: {
285
+ ...config,
286
+ mcpProxyPort: 19994,
287
+ debugProxy: true, // Enable debug logging for failure test
288
+ },
289
+ sessionId,
290
+ });
291
+ try {
292
+ await app.listen({ port: 19994, host: "127.0.0.1" });
293
+ // Call tools/list - should return tools from server1 only
294
+ const response = await fetch("http://127.0.0.1:19994/", {
295
+ method: "POST",
296
+ headers: { "Content-Type": "application/json" },
297
+ body: JSON.stringify({
298
+ jsonrpc: "2.0",
299
+ method: "tools/list",
300
+ id: 5,
301
+ }),
302
+ });
303
+ expect(response.status).toBe(200);
304
+ const data = (await response.json());
305
+ const tools = data.result.tools;
306
+ // Should only have tools from server1 (unreachable provider omitted)
307
+ expect(tools).toHaveLength(2);
308
+ const toolNames = tools.map((t) => t.name).sort();
309
+ expect(toolNames).toEqual(["server1.echo", "server1.uppercase"]);
310
+ }
311
+ finally {
312
+ await close();
313
+ if (fs.existsSync(getDefaultProvidersPath())) {
314
+ fs.unlinkSync(getDefaultProvidersPath());
315
+ }
316
+ }
317
+ });
318
+ });
319
+ //# sourceMappingURL=hub.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hub.test.js","sourceRoot":"","sources":["../../src/mcp/hub.test.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,OAAO,EAAE,EAAwB,MAAM,SAAS,CAAC;AAExD,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC;;GAEG;AACH,KAAK,UAAU,mBAAmB,CAChC,IAAY,EACZ,KAAmD;IAEnD,MAAM,GAAG,GAAG,OAAO,CAAC,EAAE,MAAM,EAAE,KAA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,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAClC,MAAM,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAElC,CAAC;YACF,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;YAEhC,qEAAqE;YACrE,MAAM,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAC9B,MAAM,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;YAClD,MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,cAAc,EAAE,mBAAmB,CAAC,CAAC,CAAC;QACnE,CAAC;gBAAS,CAAC;YACT,MAAM,KAAK,EAAE,CAAC;YACd,IAAI,EAAE,CAAC,UAAU,CAAC,uBAAuB,EAAE,CAAC,EAAE,CAAC;gBAC7C,EAAE,CAAC,UAAU,CAAC,uBAAuB,EAAE,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -2,6 +2,7 @@
2
2
  * MCP Proxy using Streamable HTTP transport.
3
3
  * Handles POST requests only, returns application/json responses.
4
4
  * Records tools/call events to the database.
5
+ * Supports hub mode: aggregates multiple HTTP providers.
5
6
  */
6
7
  import { type FastifyInstance } from "fastify";
7
8
  import type Database from "better-sqlite3";
@@ -1 +1 @@
1
- {"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/mcp/proxy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAkDnD,MAAM,WAAW,eAAe;IAC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