@haikit/mcp 0.32.0 → 0.34.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 +60 -1
- package/dist/auth.d.ts +151 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +334 -0
- package/dist/auth.js.map +1 -0
- package/dist/credential.d.ts +55 -0
- package/dist/credential.d.ts.map +1 -0
- package/dist/credential.js +62 -0
- package/dist/credential.js.map +1 -0
- package/dist/errors.d.ts +24 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +3 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +44 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +511 -144
- package/dist/index.js.map +1 -1
- package/dist/oauth.d.ts +193 -0
- package/dist/oauth.d.ts.map +1 -0
- package/dist/oauth.js +558 -0
- package/dist/oauth.js.map +1 -0
- package/dist/postgres.d.ts +25 -0
- package/dist/postgres.d.ts.map +1 -0
- package/dist/postgres.js +97 -0
- package/dist/postgres.js.map +1 -0
- package/dist/routes.d.ts +17 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +228 -0
- package/dist/routes.js.map +1 -0
- package/dist/seal.d.ts +25 -0
- package/dist/seal.d.ts.map +1 -0
- package/dist/seal.js +60 -0
- package/dist/seal.js.map +1 -0
- package/dist/store.d.ts +50 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +83 -0
- package/dist/store.js.map +1 -0
- package/dist/transports.d.ts +17 -3
- package/dist/transports.d.ts.map +1 -1
- package/dist/transports.js +13 -3
- package/dist/transports.js.map +1 -1
- package/package.json +6 -2
- package/src/auth.ts +466 -0
- package/src/credential.ts +78 -0
- package/src/errors.ts +26 -2
- package/src/index.ts +555 -158
- package/src/oauth.ts +659 -0
- package/src/postgres.ts +127 -0
- package/src/routes.ts +243 -0
- package/src/seal.ts +62 -0
- package/src/store.ts +118 -0
- package/src/transports.ts +34 -4
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The user has no credential, or the server refused theirs: thrown inside a
|
|
3
|
+
* connection, where the transport passes it on unchanged, and made an
|
|
4
|
+
* `McpError` with reason `auth`.
|
|
5
|
+
*/
|
|
6
|
+
export class NeedsAuth extends Error {
|
|
7
|
+
kind;
|
|
8
|
+
name = "NeedsAuth";
|
|
9
|
+
constructor(kind) {
|
|
10
|
+
super(kind === "connect" ? "the user has no credential" : "the server refused the user's credential");
|
|
11
|
+
this.kind = kind;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** The app's lookup of a credential failed, or a refresh couldn't be made: made an `McpError` with reason `connection`. */
|
|
15
|
+
export class LookupFailed extends Error {
|
|
16
|
+
name = "LookupFailed";
|
|
17
|
+
constructor(cause) {
|
|
18
|
+
super("the user's credential could not be looked up", { cause });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The server names another authorization server than the one its `issuer`
|
|
23
|
+
* pins, or than the one that issued a credential: made an `McpError` with
|
|
24
|
+
* reason `protocol`. The pin decides, not the user, so it's never `auth`.
|
|
25
|
+
*/
|
|
26
|
+
export class Mismatch extends Error {
|
|
27
|
+
name = "Mismatch";
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A lookup that takes at most `ms`, and that `stop()` ends at once: one that
|
|
31
|
+
* never answered would hold up every call after it, and its timer would keep
|
|
32
|
+
* the process going.
|
|
33
|
+
*/
|
|
34
|
+
export class Lookup {
|
|
35
|
+
ms;
|
|
36
|
+
what;
|
|
37
|
+
stopping = null;
|
|
38
|
+
constructor(ms,
|
|
39
|
+
/** Names what's looked up, in the errors. */
|
|
40
|
+
what) {
|
|
41
|
+
this.ms = ms;
|
|
42
|
+
this.what = what;
|
|
43
|
+
}
|
|
44
|
+
async run(look) {
|
|
45
|
+
let timer;
|
|
46
|
+
const cut = new Promise((_, reject) => {
|
|
47
|
+
timer = setTimeout(() => reject(new Error(`no ${this.what} within ${this.ms} ms`)), this.ms);
|
|
48
|
+
this.stopping = () => reject(new Error(`closed while the ${this.what} was being looked up`));
|
|
49
|
+
});
|
|
50
|
+
try {
|
|
51
|
+
return await Promise.race([Promise.resolve().then(look), cut]);
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
clearTimeout(timer);
|
|
55
|
+
this.stopping = null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
stop() {
|
|
59
|
+
this.stopping?.();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=credential.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential.js","sourceRoot":"","sources":["../src/credential.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAEb;IADZ,IAAI,GAAG,WAAW,CAAC;IAC5B,YAAqB,IAA6B;QAChD,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,0CAA0C,CAAC,CAAC;QADnF,SAAI,GAAJ,IAAI,CAAyB;IAElD,CAAC;CACF;AAED,2HAA2H;AAC3H,MAAM,OAAO,YAAa,SAAQ,KAAK;IAC5B,IAAI,GAAG,cAAc,CAAC;IAC/B,YAAY,KAAc;QACxB,KAAK,CAAC,8CAA8C,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACnE,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,IAAI,GAAG,UAAU,CAAC;CAC5B;AAiBD;;;;GAIG;AACH,MAAM,OAAO,MAAM;IAIE;IAEA;IALX,QAAQ,GAAwB,IAAI,CAAC;IAE7C,YACmB,EAAU;IAC3B,6CAA6C;IAC5B,IAAY;QAFZ,OAAE,GAAF,EAAE,CAAQ;QAEV,SAAI,GAAJ,IAAI,CAAQ;IAC5B,CAAC;IAEJ,KAAK,CAAC,GAAG,CAAI,IAA0B;QACrC,IAAI,KAAgD,CAAC;QACrD,MAAM,GAAG,GAAG,IAAI,OAAO,CAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;YAC3C,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,WAAW,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;YAC7F,IAAI,CAAC,QAAQ,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,oBAAoB,IAAI,CAAC,IAAI,sBAAsB,CAAC,CAAC,CAAC;QAC/F,CAAC,CAAC,CAAC;QACH,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;QACjE,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACvB,CAAC;IACH,CAAC;IAED,IAAI;QACF,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;IACpB,CAAC;CACF"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -9,8 +9,28 @@ import type { ContentBlock } from "@modelcontextprotocol/client";
|
|
|
9
9
|
* - `protocol`: the server refused the call, such as for a tool it doesn't
|
|
10
10
|
* have, or asked for something this client doesn't do.
|
|
11
11
|
* - `closed`: `close()` was called.
|
|
12
|
+
* - `user`: a server with `auth` had no user to call as, so nothing was sent.
|
|
13
|
+
* - `auth`: the user's credential for the server is missing, was refused, or
|
|
14
|
+
* needs more access. `auth` on the error says which.
|
|
12
15
|
*/
|
|
13
|
-
export type McpErrorReason = "args" | "result" | "timeout" | "connection" | "protocol" | "closed";
|
|
16
|
+
export type McpErrorReason = "args" | "result" | "timeout" | "connection" | "protocol" | "closed" | "user" | "auth";
|
|
17
|
+
/** What a call with reason `auth` needs from the user. */
|
|
18
|
+
export interface McpAuthNeed {
|
|
19
|
+
/**
|
|
20
|
+
* `connect`: the user has no credential for the server, so nothing was sent.
|
|
21
|
+
* `reconnect`: the server refused theirs. `scope`: theirs needs more access.
|
|
22
|
+
*/
|
|
23
|
+
readonly kind: "connect" | "reconnect" | "scope";
|
|
24
|
+
/** On `scope`: the scope the server asked for, as its challenge put it. */
|
|
25
|
+
readonly scope?: string;
|
|
26
|
+
/**
|
|
27
|
+
* For an `oauth()` server: the app's connect route for this server and the
|
|
28
|
+
* call's conversation, asking for `scope` if there is one, such as
|
|
29
|
+
* `/mcp/connect/github?conversation=c_123`. For the browser, as a surface's
|
|
30
|
+
* prop: never for the model. Absent for `bearer()` and `sdk()`.
|
|
31
|
+
*/
|
|
32
|
+
readonly connect?: string;
|
|
33
|
+
}
|
|
14
34
|
/**
|
|
15
35
|
* A call that didn't get a result. The message names only the server and the
|
|
16
36
|
* tool, never what the server said: a HaiKIT tool that lets this go reaches the
|
|
@@ -32,12 +52,15 @@ export declare class McpError extends Error {
|
|
|
32
52
|
readonly text: string | undefined;
|
|
33
53
|
/** A JSON-RPC error's code. */
|
|
34
54
|
readonly code: number | undefined;
|
|
55
|
+
/** With reason `auth`: what the user's credential needs. */
|
|
56
|
+
readonly auth: McpAuthNeed | undefined;
|
|
35
57
|
constructor(reason: McpErrorReason, message: string, detail: {
|
|
36
58
|
server: string;
|
|
37
59
|
tool?: string;
|
|
38
60
|
text?: string;
|
|
39
61
|
code?: number;
|
|
40
62
|
cause?: unknown;
|
|
63
|
+
auth?: McpAuthNeed;
|
|
41
64
|
});
|
|
42
65
|
}
|
|
43
66
|
/**
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8B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CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,WAAW,CAAA;KAAE;CAU/G;AAED;;;;GAIG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,kBAAkB;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oDAAoD;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,QAAQ,CAAC,OAAO,EAAE,YAAY,EAAE,CAAC;gBAErB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE;CAOlE;AAED,eAAO,MAAM,UAAU,GAAI,KAAK,OAAO,KAAG,GAAG,IAAI,QAA2D,CAAC;AAE7G,eAAO,MAAM,cAAc,GAAI,KAAK,OAAO,KAAG,GAAG,IAAI,YACA,CAAC"}
|
package/dist/errors.js
CHANGED
|
@@ -19,6 +19,8 @@ export class McpError extends Error {
|
|
|
19
19
|
text;
|
|
20
20
|
/** A JSON-RPC error's code. */
|
|
21
21
|
code;
|
|
22
|
+
/** With reason `auth`: what the user's credential needs. */
|
|
23
|
+
auth;
|
|
22
24
|
constructor(reason, message, detail) {
|
|
23
25
|
super(message, detail.cause === undefined ? undefined : { cause: detail.cause });
|
|
24
26
|
this.reason = reason;
|
|
@@ -26,6 +28,7 @@ export class McpError extends Error {
|
|
|
26
28
|
this.tool = detail.tool;
|
|
27
29
|
this.text = detail.text;
|
|
28
30
|
this.code = detail.code;
|
|
31
|
+
this.auth = detail.auth === undefined ? undefined : Object.freeze({ ...detail.auth });
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
/**
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"
|
|
1
|
+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CAAC,GAAG,MAAM,IAAI,IAAI,oBAAoB,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrF,CAAC;CACF;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAY,EAAmB,EAAE,CAAC,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,UAAU,CAAC;AAE7G,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAY,EAAuB,EAAE,CAClE,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,cAAc,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,23 +14,42 @@
|
|
|
14
14
|
* Imports only @haikit/core, like the model adapters.
|
|
15
15
|
*/
|
|
16
16
|
import type { Progress, Schema } from "@haikit/core";
|
|
17
|
-
import { type ContentBlock, type Transport, type VersionNegotiationMode } from "@modelcontextprotocol/client";
|
|
18
|
-
|
|
17
|
+
import { type AuthProvider, type ContentBlock, type Transport, type VersionNegotiationMode } from "@modelcontextprotocol/client";
|
|
18
|
+
import { type McpServerAuth } from "./auth.js";
|
|
19
|
+
export { createMcpAuth, type McpAccount, type McpAuth, type McpAuthOptions, type McpConnected, type McpServerAuth, type OAuthServerOptions, } from "./auth.js";
|
|
20
|
+
export { McpError, McpToolError, isMcpError, isMcpToolError, type McpAuthNeed, type McpErrorReason } from "./errors.js";
|
|
19
21
|
export { textOf, type TextOptions } from "./text.js";
|
|
22
|
+
export { memoryCredentialStore, type CredentialStore } from "./store.js";
|
|
20
23
|
export { http, stdio, type HttpOptions } from "./transports.js";
|
|
21
|
-
export type { ContentBlock, Transport } from "@modelcontextprotocol/client";
|
|
24
|
+
export type { AuthProvider, ContentBlock, OAuthClientProvider, Transport } from "@modelcontextprotocol/client";
|
|
22
25
|
export interface McpServerOptions {
|
|
23
26
|
/** Names the server in errors and warnings, as in `github/search_issues`. */
|
|
24
27
|
name: string;
|
|
25
28
|
/**
|
|
26
29
|
* Makes a connection: called by the first `connect()` or call, and again
|
|
27
|
-
* for each reconnect. `http(url)` and `stdio({ command })` make one.
|
|
30
|
+
* for each reconnect. `http(url)` and `stdio({ command })` make one. For a
|
|
31
|
+
* server with `auth`, it's given the user's `AuthProvider`, and must be
|
|
32
|
+
* `http()`'s.
|
|
28
33
|
*/
|
|
29
|
-
transport: () => Transport | Promise<Transport>;
|
|
34
|
+
transport: (authProvider?: AuthProvider) => Transport | Promise<Transport>;
|
|
35
|
+
/**
|
|
36
|
+
* Makes each call as the user it runs for, with their own credential, over
|
|
37
|
+
* a connection of their own: `mcpAuth.oauth()`, `mcpAuth.bearer(token)` or
|
|
38
|
+
* `mcpAuth.sdk(make)`, from `createMcpAuth`. Without it, every call shares
|
|
39
|
+
* one connection and one identity.
|
|
40
|
+
*/
|
|
41
|
+
auth?: McpServerAuth;
|
|
42
|
+
/**
|
|
43
|
+
* With `auth`: the most users connected at once. Past it, the least recently
|
|
44
|
+
* used connection with no call in flight is closed. Default 100.
|
|
45
|
+
*/
|
|
46
|
+
maxConnections?: number;
|
|
47
|
+
/** With `auth`: a user's connection is closed after this long with no call, in milliseconds. Default 300,000. */
|
|
48
|
+
idleMs?: number;
|
|
30
49
|
/**
|
|
31
50
|
* How long the server may go without answering a call or reporting progress
|
|
32
|
-
* on it, in milliseconds. Also bounds making the transport, connecting
|
|
33
|
-
* listing tools. Default 30,000.
|
|
51
|
+
* on it, in milliseconds. Also bounds making the transport, connecting,
|
|
52
|
+
* listing tools and, with `auth`, looking up a user's token. Default 30,000.
|
|
34
53
|
*/
|
|
35
54
|
timeoutMs?: number;
|
|
36
55
|
/**
|
|
@@ -50,6 +69,8 @@ export interface McpServerOptions {
|
|
|
50
69
|
}
|
|
51
70
|
export interface McpToolChange {
|
|
52
71
|
server: string;
|
|
72
|
+
/** With `auth`: the user whose connection saw the change. Each user's tools are compared apart. */
|
|
73
|
+
user?: string;
|
|
53
74
|
/** Declared tools the server no longer has. */
|
|
54
75
|
removed: string[];
|
|
55
76
|
/** Declared tools whose input or output schema, or task support, changed. */
|
|
@@ -82,10 +103,16 @@ export interface McpResult {
|
|
|
82
103
|
*/
|
|
83
104
|
export interface McpCallCtx {
|
|
84
105
|
/**
|
|
85
|
-
* The conversation the call is for.
|
|
86
|
-
*
|
|
106
|
+
* The conversation the call is for. A server with `auth` calls as its
|
|
107
|
+
* owner, from `userOf`.
|
|
87
108
|
*/
|
|
88
109
|
readonly conversationId?: string;
|
|
110
|
+
/**
|
|
111
|
+
* For a server with `auth`: the user to call as, for a call made outside any
|
|
112
|
+
* conversation, such as a job. With a `conversationId` too, it must be the
|
|
113
|
+
* conversation's owner.
|
|
114
|
+
*/
|
|
115
|
+
readonly userId?: string;
|
|
89
116
|
/** Hears the server's progress notifications, as `ToolCtx.progress` does. */
|
|
90
117
|
progress?(progress: Progress): void;
|
|
91
118
|
}
|
|
@@ -116,9 +143,15 @@ export interface McpConnection {
|
|
|
116
143
|
* Connects, and checks every declared tool: it throws if the server has no
|
|
117
144
|
* tool of that name, or one that can only run as an MCP task. Call it at
|
|
118
145
|
* startup, so a mistake stops the app there; the first call connects
|
|
119
|
-
* otherwise, and fails with the same error.
|
|
146
|
+
* otherwise, and fails with the same error. A server with `auth` needs
|
|
147
|
+
* the user to connect as, and checks the tools that user sees.
|
|
148
|
+
*/
|
|
149
|
+
connect(userId?: string): Promise<void>;
|
|
150
|
+
/**
|
|
151
|
+
* For a server with `auth`: closes the user's connection, if they have
|
|
152
|
+
* one. Their next call makes a new one, and looks up their credential again.
|
|
120
153
|
*/
|
|
121
|
-
|
|
154
|
+
forget(userId: string): Promise<void>;
|
|
122
155
|
/** Closes the connection, and stops a `stdio` server. Final: a later call fails with reason `closed`. */
|
|
123
156
|
close(): Promise<void>;
|
|
124
157
|
}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EASL,KAAK,YAAY,EAEjB,KAAK,YAAY,EAEjB,KAAK,SAAS,EACd,KAAK,sBAAsB,EAC5B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAA2C,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAKxF,OAAO,EACL,aAAa,EACb,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,kBAAkB,GACxB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AACxH,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,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