@silkweave/mcp 2.6.0 → 3.0.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 +5 -5
- package/build/cliProxy.d.mts +13 -0
- package/build/cliProxy.d.mts.map +1 -0
- package/build/cliProxy.mjs +113 -0
- package/build/cliProxy.mjs.map +1 -0
- package/build/index.d.mts +12 -33
- package/build/index.d.mts.map +1 -1
- package/build/index.mjs +25 -415
- package/build/index.mjs.map +1 -1
- package/build/registerTools-DlguElKV.mjs +145 -0
- package/build/registerTools-DlguElKV.mjs.map +1 -0
- package/build/result-BVpEX7jU.d.mts +64 -0
- package/build/result-BVpEX7jU.d.mts.map +1 -0
- package/build/result-B_9Eo1ey.mjs +79 -0
- package/build/result-B_9Eo1ey.mjs.map +1 -0
- package/build/tools.d.mts +2 -0
- package/build/tools.mjs +3 -0
- package/package.json +42 -10
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ Configure in Claude Desktop or Claude Code:
|
|
|
39
39
|
|
|
40
40
|
### http
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
**Stateless** MCP transport over HTTP with per-call SSE streaming (no sessions, so any request can hit any instance behind a plain load balancer).
|
|
43
43
|
|
|
44
44
|
```typescript
|
|
45
45
|
import { silkweave } from '@silkweave/core'
|
|
@@ -51,7 +51,7 @@ await silkweave({ name: 'my-tools', description: 'My Tools', version: '1.0.0' })
|
|
|
51
51
|
.start()
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
Exposes `POST /mcp` (
|
|
54
|
+
Exposes a single stateless `POST /mcp` (each call mints a fresh transport with `sessionIdGenerator: undefined`; progress streams over SSE per call). No `Mcp-Session-Id`, no `GET`/`DELETE` reconnect. Built on Express with `StreamableHTTPServerTransport` from the MCP SDK.
|
|
55
55
|
|
|
56
56
|
| Option | Type | Description |
|
|
57
57
|
|--------|------|-------------|
|
|
@@ -62,11 +62,11 @@ Exposes `POST /mcp` (invoke tools), `GET /mcp` (SSE stream), and `DELETE /mcp` (
|
|
|
62
62
|
|
|
63
63
|
### cliProxy
|
|
64
64
|
|
|
65
|
-
MCP CLI proxy client - connects to a running HTTP MCP server and invokes tools from the command line.
|
|
65
|
+
MCP CLI proxy client - connects to a running HTTP MCP server and invokes tools from the command line. Imported from the dedicated `@silkweave/mcp/cli-proxy` subpath (kept out of the package root so importing the `stdio`/`http` servers does not pull the CLI client's `commander` + `@clack/prompts` into the server path). Those two are **optional peer dependencies** - install them alongside `@silkweave/mcp` when you use the CLI proxy.
|
|
66
66
|
|
|
67
67
|
```typescript
|
|
68
68
|
import { silkweave } from '@silkweave/core'
|
|
69
|
-
import { cliProxy } from '@silkweave/mcp'
|
|
69
|
+
import { cliProxy } from '@silkweave/mcp/cli-proxy'
|
|
70
70
|
|
|
71
71
|
await silkweave({ name: 'my-tools', description: 'My Tools', version: '1.0.0' })
|
|
72
72
|
.adapter(cliProxy({ url: 'http://localhost:8080/mcp' }))
|
|
@@ -194,4 +194,4 @@ All result utilities are exported from `@silkweave/mcp`:
|
|
|
194
194
|
|
|
195
195
|
- [Silkweave README](https://github.com/silkweave/silkweave) - Full documentation
|
|
196
196
|
- [`@silkweave/core`](https://www.npmjs.com/package/@silkweave/core) - Core library
|
|
197
|
-
- [`@silkweave/
|
|
197
|
+
- [`@silkweave/edge`](https://www.npmjs.com/package/@silkweave/edge) - Stateless MCP on Web-Standard edge/serverless runtimes (Cloudflare Workers, Vercel, Bun, Deno)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AdapterFactory } from "@silkweave/core";
|
|
2
|
+
import { ContentBlock } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
|
|
4
|
+
//#region src/adapter/cliProxy.d.ts
|
|
5
|
+
type CLIFormatterFn = (message: ContentBlock, index: number, messages: ContentBlock[]) => string | undefined;
|
|
6
|
+
interface CliProxyOptions {
|
|
7
|
+
url: URL;
|
|
8
|
+
formatter?: CLIFormatterFn;
|
|
9
|
+
}
|
|
10
|
+
declare const cliProxy: AdapterFactory<CliProxyOptions>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { CLIFormatterFn, CliProxyOptions, cliProxy };
|
|
13
|
+
//# sourceMappingURL=cliProxy.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cliProxy.d.mts","names":[],"sources":["../src/adapter/cliProxy.ts"],"mappings":";;;;KAWY,cAAA,IAAkB,OAAA,EAAS,YAAA,EAAc,KAAA,UAAe,QAAA,EAAU,YAAA;AAAA,UAE7D,eAAA;EACf,GAAA,EAAK,GAAA;EACL,SAAA,GAAY,cAAA;AAAA;AAAA,cA4DD,QAAA,EAAU,cAAA,CAAe,eAAA"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { i as parseResourceMessage } from "./result-B_9Eo1ey.mjs";
|
|
2
|
+
import { createCLILogger } from "@silkweave/logger";
|
|
3
|
+
import { kebabCase } from "change-case";
|
|
4
|
+
import { randomUUID } from "crypto";
|
|
5
|
+
import { intro } from "@clack/prompts";
|
|
6
|
+
import { Client } from "@modelcontextprotocol/sdk/client";
|
|
7
|
+
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
8
|
+
import { LoggingMessageNotificationSchema, ProgressNotificationSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
9
|
+
import { Command } from "commander";
|
|
10
|
+
//#region src/adapter/cliProxy.ts
|
|
11
|
+
function coerce(value, type) {
|
|
12
|
+
if (value === void 0) return;
|
|
13
|
+
if (type === "number" || type === "integer") {
|
|
14
|
+
const n = Number(value);
|
|
15
|
+
return Number.isNaN(n) ? value : n;
|
|
16
|
+
}
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
function addCliOption(command, key, prop) {
|
|
20
|
+
const flag = kebabCase(key);
|
|
21
|
+
const description = prop.description;
|
|
22
|
+
const defaultValue = prop.default;
|
|
23
|
+
const type = prop.type;
|
|
24
|
+
if (type === "boolean") {
|
|
25
|
+
command.option(`--${flag}`, description, defaultValue);
|
|
26
|
+
command.option(`--no-${flag}`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (type === "number" || type === "integer") {
|
|
30
|
+
command.option(`--${flag} <number>`, description, defaultValue);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (type === "string" || prop.enum) {
|
|
34
|
+
command.option(`--${flag} <string>`, description, defaultValue);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (type === "object" || type === "array") {
|
|
38
|
+
command.option(`--${flag} <json>`, description ?? "", JSON.parse, defaultValue);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
throw new Error(`Unsupported JSON Schema type for CLI option "${key}": ${type ?? "undefined"}`);
|
|
42
|
+
}
|
|
43
|
+
const defaultFormatter = (message) => {
|
|
44
|
+
if (message.type === "text" && !message.text.includes("mcp://toolResult/")) return `${message.text}`;
|
|
45
|
+
else if (message.type === "resource") return parseResourceMessage(message);
|
|
46
|
+
else return JSON.stringify(message);
|
|
47
|
+
};
|
|
48
|
+
const cliProxy = ({ url, formatter = defaultFormatter }) => {
|
|
49
|
+
return (options, baseContext) => {
|
|
50
|
+
const context = baseContext.fork({ adapter: "cliProxy" });
|
|
51
|
+
const program = new Command().name(options.name).description(options.description).version(options.version).option("-s, --silent", "Silent mode, prevent log messages", false);
|
|
52
|
+
return {
|
|
53
|
+
context,
|
|
54
|
+
start: async () => {
|
|
55
|
+
const client = new Client({
|
|
56
|
+
name: options.name,
|
|
57
|
+
description: options.description,
|
|
58
|
+
version: options.version
|
|
59
|
+
});
|
|
60
|
+
const transport = new StreamableHTTPClientTransport(url);
|
|
61
|
+
await client.connect(transport);
|
|
62
|
+
const { tools } = await client.listTools();
|
|
63
|
+
for (const tool of tools) {
|
|
64
|
+
const name = kebabCase(tool.name);
|
|
65
|
+
const command = program.command(name);
|
|
66
|
+
if (tool.description) command.description(tool.description);
|
|
67
|
+
const properties = tool.inputSchema.properties ?? {};
|
|
68
|
+
for (const key of Object.keys(properties)) addCliOption(command, key, properties[key]);
|
|
69
|
+
command.action(async (args) => {
|
|
70
|
+
const { silent } = program.opts();
|
|
71
|
+
const logger = createCLILogger();
|
|
72
|
+
if (!silent) {
|
|
73
|
+
intro(`${options.name} - ${tool.name}`);
|
|
74
|
+
client.setNotificationHandler(LoggingMessageNotificationSchema, ({ params: { level, data } }) => {
|
|
75
|
+
logger[level](data);
|
|
76
|
+
});
|
|
77
|
+
client.setNotificationHandler(ProgressNotificationSchema, ({ params: { progress, total, message } }) => {
|
|
78
|
+
logger.info({
|
|
79
|
+
progress,
|
|
80
|
+
total,
|
|
81
|
+
message
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const input = {};
|
|
86
|
+
for (const key of Object.keys(properties)) {
|
|
87
|
+
const value = args[key];
|
|
88
|
+
if (value !== void 0) input[key] = coerce(value, properties[key]?.type);
|
|
89
|
+
}
|
|
90
|
+
(await client.callTool({
|
|
91
|
+
name: tool.name,
|
|
92
|
+
arguments: input,
|
|
93
|
+
_meta: {
|
|
94
|
+
progressToken: randomUUID(),
|
|
95
|
+
disposition: "json"
|
|
96
|
+
}
|
|
97
|
+
})).content.forEach((message, index, messages) => {
|
|
98
|
+
const text = formatter(message, index, messages);
|
|
99
|
+
process.stdout.write(`${text}\n`);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
await program.parseAsync();
|
|
104
|
+
await transport.close();
|
|
105
|
+
},
|
|
106
|
+
stop: async () => {}
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
//#endregion
|
|
111
|
+
export { cliProxy };
|
|
112
|
+
|
|
113
|
+
//# sourceMappingURL=cliProxy.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cliProxy.mjs","names":[],"sources":["../src/adapter/cliProxy.ts"],"sourcesContent":["import { intro } from '@clack/prompts'\nimport { Client } from '@modelcontextprotocol/sdk/client'\nimport { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js'\nimport { ContentBlock, LoggingMessageNotificationSchema, ProgressNotificationSchema, ToolResultContent } from '@modelcontextprotocol/sdk/types.js'\nimport { AdapterFactory } from '@silkweave/core'\nimport { createCLILogger } from '@silkweave/logger'\nimport { kebabCase } from 'change-case'\nimport { Command } from 'commander'\nimport { randomUUID } from 'crypto'\nimport { parseResourceMessage } from '../util/result.js'\n\nexport type CLIFormatterFn = (message: ContentBlock, index: number, messages: ContentBlock[]) => string | undefined\n\nexport interface CliProxyOptions {\n url: URL\n formatter?: CLIFormatterFn\n}\n\ninterface JsonSchemaProperty {\n type?: 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | string\n description?: string\n default?: unknown\n enum?: unknown[]\n}\n\ninterface JsonSchemaObject {\n type?: 'object'\n properties?: Record<string, JsonSchemaProperty>\n required?: string[]\n}\n\nfunction coerce(value: unknown, type: JsonSchemaProperty['type']): unknown {\n if (value === undefined) { return undefined }\n if (type === 'number' || type === 'integer') {\n const n = Number(value)\n return Number.isNaN(n) ? value : n\n }\n return value\n}\n\nfunction addCliOption(command: Command, key: string, prop: JsonSchemaProperty) {\n const flag = kebabCase(key)\n const description = prop.description\n const defaultValue = prop.default\n const type = prop.type\n if (type === 'boolean') {\n command.option(`--${flag}`, description, defaultValue as boolean | undefined)\n command.option(`--no-${flag}`)\n return\n }\n if (type === 'number' || type === 'integer') {\n command.option(`--${flag} <number>`, description, defaultValue as string | undefined)\n return\n }\n if (type === 'string' || prop.enum) {\n command.option(`--${flag} <string>`, description, defaultValue as string | undefined)\n return\n }\n if (type === 'object' || type === 'array') {\n command.option(`--${flag} <json>`, description ?? '', JSON.parse, defaultValue as never)\n return\n }\n throw new Error(`Unsupported JSON Schema type for CLI option \"${key}\": ${type ?? 'undefined'}`)\n}\n\nconst defaultFormatter: CLIFormatterFn = (message) => {\n if (message.type === 'text' && !message.text.includes('mcp://toolResult/')) {\n return `${message.text}`\n } else if (message.type === 'resource') {\n return parseResourceMessage(message)\n } else {\n return JSON.stringify(message)\n }\n}\n\nexport const cliProxy: AdapterFactory<CliProxyOptions> = ({ url, formatter = defaultFormatter }) => {\n return (options, baseContext) => {\n const context = baseContext.fork({ adapter: 'cliProxy' })\n const program = new Command()\n .name(options.name)\n .description(options.description)\n .version(options.version)\n .option('-s, --silent', 'Silent mode, prevent log messages', false)\n\n return {\n context,\n start: async () => {\n const client = new Client({\n name: options.name,\n description: options.description,\n version: options.version\n })\n const transport = new StreamableHTTPClientTransport(url)\n await client.connect(transport)\n const { tools } = await client.listTools()\n for (const tool of tools) {\n const name = kebabCase(tool.name)\n const command = program.command(name)\n if (tool.description) { command.description(tool.description) }\n const schema = tool.inputSchema as JsonSchemaObject\n const properties = schema.properties ?? {}\n for (const key of Object.keys(properties)) {\n addCliOption(command, key, properties[key])\n }\n command.action(async (args: Record<string, unknown>) => {\n const { silent } = program.opts<{ silent: boolean }>()\n const logger = createCLILogger()\n if (!silent) {\n intro(`${options.name} - ${tool.name}`)\n client.setNotificationHandler(LoggingMessageNotificationSchema, ({ params: { level, data } }) => {\n logger[level](data)\n })\n client.setNotificationHandler(ProgressNotificationSchema, ({ params: { progress, total, message } }) => {\n logger.info({ progress, total, message })\n })\n }\n const input: Record<string, unknown> = {}\n for (const key of Object.keys(properties)) {\n const value = args[key]\n if (value !== undefined) { input[key] = coerce(value, properties[key]?.type) }\n }\n const response = await client.callTool({\n name: tool.name,\n arguments: input,\n _meta: { progressToken: randomUUID(), disposition: 'json' }\n }) as ToolResultContent\n response.content.forEach((message, index, messages) => {\n const text = formatter(message, index, messages)\n process.stdout.write(`${text}\\n`)\n })\n })\n }\n await program.parseAsync()\n await transport.close()\n },\n stop: async () => { /* noop */ }\n }\n }\n}\n"],"mappings":";;;;;;;;;;AA+BA,SAAS,OAAO,OAAgB,MAA2C;AACzE,KAAI,UAAU,KAAA,EAAa;AAC3B,KAAI,SAAS,YA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AAO,SAAS;AAChD,eAAQ,OAAO,MAAM,GAAG,KAAK,IAAI;QACjC;OACF;;AAEJ,UAAM,QAAQ,YAAY;AAC1B,UAAM,UAAU,OAAO;;GAEzB,MAAM,YAAY;GACnB"}
|
package/build/index.d.mts
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Action, AdapterFactory, SilkweaveContext, SilkweaveError, SilkweaveOptions } from "@silkweave/core";
|
|
1
|
+
import { a as smartToolResult, c as requestFromExtra, i as parseResourceMessage, n as handleToolError, o as RegisterToolsOptions, r as jsonToolResult, s as registerTools, t as errorToolResult } from "./result-BVpEX7jU.mjs";
|
|
3
2
|
import { CreateMcpExpressAppOptions } from "@modelcontextprotocol/sdk/server/express.js";
|
|
3
|
+
import { Action, AdapterFactory, SilkweaveContext, SilkweaveOptions } from "@silkweave/core";
|
|
4
4
|
import { Express, RequestHandler } from "express";
|
|
5
5
|
import { AuthConfig, AuthInfo } from "@silkweave/auth";
|
|
6
6
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
7
7
|
import { CorsOptions, CorsOptions as CorsOptions$1 } from "cors";
|
|
8
8
|
import { Server } from "http";
|
|
9
9
|
|
|
10
|
-
//#region src/adapter/cliProxy.d.ts
|
|
11
|
-
type CLIFormatterFn = (message: ContentBlock, index: number, messages: ContentBlock[]) => string | undefined;
|
|
12
|
-
interface CliProxyOptions {
|
|
13
|
-
url: URL;
|
|
14
|
-
formatter?: CLIFormatterFn;
|
|
15
|
-
}
|
|
16
|
-
declare const cliProxy: AdapterFactory<CliProxyOptions>;
|
|
17
|
-
//#endregion
|
|
18
10
|
//#region src/adapter/http.d.ts
|
|
19
11
|
interface StartMcpHttpOptions extends CreateMcpExpressAppOptions {
|
|
20
12
|
host: string;
|
|
@@ -74,8 +66,8 @@ declare function authMiddleware(auth: AuthConfig, context: SilkweaveContext): Re
|
|
|
74
66
|
declare const MCP_REQUIRED_HEADERS: string[];
|
|
75
67
|
/**
|
|
76
68
|
* CORS middleware preconfigured to expose the headers MCP clients need
|
|
77
|
-
* (`
|
|
78
|
-
*
|
|
69
|
+
* (`Last-Event-Id`, `Mcp-Protocol-Version`, `WWW-Authenticate`) on top of any
|
|
70
|
+
* user-supplied options. (Stateless transport - no `Mcp-Session-Id`.)
|
|
79
71
|
*
|
|
80
72
|
* Pass `false` to disable, omit / pass `true` for permissive defaults, or pass
|
|
81
73
|
* a `CorsOptions` object to override.
|
|
@@ -132,33 +124,20 @@ declare function sideloadResource(options?: SideloadResourceOptions): RequestHan
|
|
|
132
124
|
//#endregion
|
|
133
125
|
//#region src/handlers/transport.d.ts
|
|
134
126
|
interface McpTransportHandlers {
|
|
135
|
-
/** `POST /mcp` -
|
|
127
|
+
/** `POST /mcp` - handle a single stateless MCP request/response (SSE per call). */
|
|
136
128
|
post: RequestHandler;
|
|
137
|
-
/** `GET /mcp` and `DELETE /mcp` - long-poll session stream / session termination. Also covers `GET /mcp/resource/:id`. */
|
|
138
|
-
stream: RequestHandler;
|
|
139
129
|
}
|
|
140
130
|
/**
|
|
141
|
-
* Build the MCP Streamable HTTP transport route
|
|
131
|
+
* Build the MCP Streamable HTTP transport route handler.
|
|
142
132
|
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
133
|
+
* Stateless (per the 2026 spec direction): each `POST /mcp` mints a fresh
|
|
134
|
+
* transport + server with `sessionIdGenerator: undefined`, handles exactly that
|
|
135
|
+
* request (streaming progress over SSE when the call carries a `progressToken`),
|
|
136
|
+
* and tears down on response close. No `Mcp-Session-Id`, no session map, no
|
|
137
|
+
* `GET`/`DELETE` reconnect - any request can hit any instance.
|
|
146
138
|
*/
|
|
147
139
|
declare function mcpTransport(silkweaveOptions: SilkweaveOptions, context: SilkweaveContext, actions: Action[]): McpTransportHandlers;
|
|
148
140
|
//#endregion
|
|
149
|
-
//#region src/util/result.d.ts
|
|
150
|
-
declare function smartToolResult(data: string | object | object[]): CallToolResult;
|
|
151
|
-
declare function jsonToolResult(data: object, isError?: boolean): CallToolResult;
|
|
152
|
-
declare function errorToolResult({
|
|
153
|
-
code,
|
|
154
|
-
name,
|
|
155
|
-
message
|
|
156
|
-
}: SilkweaveError): CallToolResult;
|
|
157
|
-
declare function handleToolError(error: unknown): CallToolResult;
|
|
158
|
-
declare function parseResourceMessage({
|
|
159
|
-
resource
|
|
160
|
-
}: EmbeddedResource): string;
|
|
161
|
-
//#endregion
|
|
162
141
|
//#region src/util/sideload.d.ts
|
|
163
142
|
interface SideloadResource {
|
|
164
143
|
id: string;
|
|
@@ -171,5 +150,5 @@ declare function createSideloadResource(buffer: Buffer, {
|
|
|
171
150
|
contentType
|
|
172
151
|
}: Pick<SideloadResource, 'name' | 'contentType'>): Promise<SideloadResource>;
|
|
173
152
|
//#endregion
|
|
174
|
-
export {
|
|
153
|
+
export { type CorsOptions, MCP_REQUIRED_HEADERS, McpTransportHandlers, OAuthRouteHandlers, RegisterToolsOptions, SideloadResource, SideloadResourceOptions, StartMcpHttpOptions, authMiddleware, authStorage, buildMcpExpressApp, createSideloadResource, errorToolResult, handleToolError, http, jsonToolResult, mcpCors, mcpTransport, oauthRoutes, parseResourceMessage, protectedResourceMetadata, registerTools, requestFromExtra, sideloadResource, smartToolResult, startMcpServer, stdio };
|
|
175
154
|
//# sourceMappingURL=index.d.mts.map
|
package/build/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/adapter/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/adapter/http.ts","../src/adapter/stdio.ts","../src/handlers/auth.ts","../src/handlers/cors.ts","../src/handlers/metadata.ts","../src/handlers/oauth.ts","../src/handlers/sideload.ts","../src/handlers/transport.ts","../src/util/sideload.ts"],"mappings":";;;;;;;;;;UAaiB,mBAAA,SAA4B,0BAAA;EAC3C,IAAA;EACA,IAAA;EACA,IAAA,GAAO,UAAA;EAHQ;EAKf,IAAA,GAAO,aAAA;;E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