@lydt/geogebra-studio 0.0.0-stage → 0.4.0-rc.2
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/.agents/plugins/marketplace.json +21 -0
- package/.codex-plugin/plugin.json +21 -0
- package/.mcp.json +18 -0
- package/LICENSE +339 -0
- package/LICENSE-MIT +21 -0
- package/README.md +108 -2
- package/README.zh-CN.md +89 -0
- package/THIRD_PARTY_NOTICES.md +35 -0
- package/dist/cli.d.ts +27 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +234 -0
- package/dist/cli.js.map +1 -0
- package/dist/export/files.d.ts +4 -0
- package/dist/export/files.d.ts.map +1 -0
- package/dist/export/files.js +44 -0
- package/dist/export/files.js.map +1 -0
- package/dist/export/gikz.d.ts +11 -0
- package/dist/export/gikz.d.ts.map +1 -0
- package/dist/export/gikz.js +28 -0
- package/dist/export/gikz.js.map +1 -0
- package/dist/export/html.d.ts +14 -0
- package/dist/export/html.d.ts.map +1 -0
- package/dist/export/html.js +97 -0
- package/dist/export/html.js.map +1 -0
- package/dist/export/semantic.d.ts +43 -0
- package/dist/export/semantic.d.ts.map +1 -0
- package/dist/export/semantic.js +212 -0
- package/dist/export/semantic.js.map +1 -0
- package/dist/export/viewer-themes.d.ts +76 -0
- package/dist/export/viewer-themes.d.ts.map +1 -0
- package/dist/export/viewer-themes.js +169 -0
- package/dist/export/viewer-themes.js.map +1 -0
- package/dist/export/workspace.d.ts +4 -0
- package/dist/export/workspace.d.ts.map +1 -0
- package/dist/export/workspace.js +25 -0
- package/dist/export/workspace.js.map +1 -0
- package/dist/gikz-browser.js +770 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +84 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +35 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +187 -0
- package/dist/server.js.map +1 -0
- package/dist/studio/artifact.d.ts +37 -0
- package/dist/studio/artifact.d.ts.map +1 -0
- package/dist/studio/artifact.js +61 -0
- package/dist/studio/artifact.js.map +1 -0
- package/dist/studio/browser.d.ts +7 -0
- package/dist/studio/browser.d.ts.map +1 -0
- package/dist/studio/browser.js +67 -0
- package/dist/studio/browser.js.map +1 -0
- package/dist/studio/install.d.ts +4 -0
- package/dist/studio/install.d.ts.map +1 -0
- package/dist/studio/install.js +60 -0
- package/dist/studio/install.js.map +1 -0
- package/dist/tools/apps-api-tools.d.ts +4 -0
- package/dist/tools/apps-api-tools.d.ts.map +1 -0
- package/dist/tools/apps-api-tools.js +96 -0
- package/dist/tools/apps-api-tools.js.map +1 -0
- package/dist/tools/educational-templates.d.ts +33 -0
- package/dist/tools/educational-templates.d.ts.map +1 -0
- package/dist/tools/educational-templates.js +261 -0
- package/dist/tools/educational-templates.js.map +1 -0
- package/dist/tools/export-tools.d.ts +3 -0
- package/dist/tools/export-tools.d.ts.map +1 -0
- package/dist/tools/export-tools.js +118 -0
- package/dist/tools/export-tools.js.map +1 -0
- package/dist/tools/geogebra-tools.d.ts +15 -0
- package/dist/tools/geogebra-tools.d.ts.map +1 -0
- package/dist/tools/geogebra-tools.js +3442 -0
- package/dist/tools/geogebra-tools.js.map +1 -0
- package/dist/tools/index.d.ts +43 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +183 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/performance-tools.d.ts +7 -0
- package/dist/tools/performance-tools.d.ts.map +1 -0
- package/dist/tools/performance-tools.js +312 -0
- package/dist/tools/performance-tools.js.map +1 -0
- package/dist/tools/templates/algebra-templates.d.ts +7 -0
- package/dist/tools/templates/algebra-templates.d.ts.map +1 -0
- package/dist/tools/templates/algebra-templates.js +568 -0
- package/dist/tools/templates/algebra-templates.js.map +1 -0
- package/dist/tools/templates/geometry-templates.d.ts +7 -0
- package/dist/tools/templates/geometry-templates.d.ts.map +1 -0
- package/dist/tools/templates/geometry-templates.js +492 -0
- package/dist/tools/templates/geometry-templates.js.map +1 -0
- package/dist/types/geogebra.d.ts +103 -0
- package/dist/types/geogebra.d.ts.map +1 -0
- package/dist/types/geogebra.js +34 -0
- package/dist/types/geogebra.js.map +1 -0
- package/dist/types/mcp.d.ts +125 -0
- package/dist/types/mcp.d.ts.map +1 -0
- package/dist/types/mcp.js +19 -0
- package/dist/types/mcp.js.map +1 -0
- package/dist/utils/app-info.d.ts +12 -0
- package/dist/utils/app-info.d.ts.map +1 -0
- package/dist/utils/app-info.js +30 -0
- package/dist/utils/app-info.js.map +1 -0
- package/dist/utils/errors.d.ts +37 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +72 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/gemini-compatibility.d.ts +39 -0
- package/dist/utils/gemini-compatibility.d.ts.map +1 -0
- package/dist/utils/gemini-compatibility.js +154 -0
- package/dist/utils/gemini-compatibility.js.map +1 -0
- package/dist/utils/geogebra-instance.d.ts +252 -0
- package/dist/utils/geogebra-instance.d.ts.map +1 -0
- package/dist/utils/geogebra-instance.js +1560 -0
- package/dist/utils/geogebra-instance.js.map +1 -0
- package/dist/utils/geogebra-mock.d.ts +172 -0
- package/dist/utils/geogebra-mock.d.ts.map +1 -0
- package/dist/utils/geogebra-mock.js +732 -0
- package/dist/utils/geogebra-mock.js.map +1 -0
- package/dist/utils/logger.d.ts +4 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +46 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/performance/index.d.ts +76 -0
- package/dist/utils/performance/index.d.ts.map +1 -0
- package/dist/utils/performance/index.js +163 -0
- package/dist/utils/performance/index.js.map +1 -0
- package/dist/utils/performance/instance-pool.d.ts +78 -0
- package/dist/utils/performance/instance-pool.d.ts.map +1 -0
- package/dist/utils/performance/instance-pool.js +268 -0
- package/dist/utils/performance/instance-pool.js.map +1 -0
- package/dist/utils/validation.d.ts +92 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +557 -0
- package/dist/utils/validation.js.map +1 -0
- package/dist/widget.html +110 -0
- package/docs/APPS-API-BRIDGE.md +28 -0
- package/docs/MODERNIZATION.md +15 -0
- package/docs/TANGENT-REGRESSION.md +34 -0
- package/docs/VALIDATION.md +26 -0
- package/docs/VISUAL-STANDARD.md +26 -0
- package/docs/images/native-construction.png +0 -0
- package/examples/tangent-construction.json +26 -0
- package/gikz/LICENSE +339 -0
- package/gikz/PROVENANCE.md +8 -0
- package/gikz/browser.cjs +2 -0
- package/gikz/cli.cjs +195 -0
- package/gikz/core.cjs +806 -0
- package/mcp.json +20 -0
- package/package.json +107 -4
- package/plugin.json +35 -0
- package/runtime/package.json +4 -0
- package/scripts/build-plugin.cjs +15 -0
- package/scripts/build-widget.cjs +7 -0
- package/skills/geogebra-construct/SKILL.md +40 -0
- package/skills/geogebra-setup/SKILL.md +37 -0
- package/skills/geometry-export/SKILL.md +31 -0
- package/src/cli.ts +212 -0
- package/src/export/files.ts +26 -0
- package/src/export/gikz.ts +22 -0
- package/src/export/html.ts +108 -0
- package/src/export/semantic.ts +180 -0
- package/src/export/viewer-themes.ts +165 -0
- package/src/export/workspace.ts +15 -0
- package/src/index.ts +71 -0
- package/src/server.ts +168 -0
- package/src/studio/artifact.ts +50 -0
- package/src/studio/browser.ts +38 -0
- package/src/studio/install.ts +43 -0
- package/src/tools/apps-api-tools.ts +96 -0
- package/src/tools/educational-templates.ts +299 -0
- package/src/tools/export-tools.ts +110 -0
- package/src/tools/geogebra-tools.ts +3836 -0
- package/src/tools/index.ts +192 -0
- package/src/tools/performance-tools.ts +322 -0
- package/src/tools/templates/algebra-templates.ts +619 -0
- package/src/tools/templates/geometry-templates.ts +550 -0
- package/src/types/geogebra.ts +140 -0
- package/src/types/global.d.ts +31 -0
- package/src/types/mcp.ts +141 -0
- package/src/utils/app-info.ts +35 -0
- package/src/utils/errors.ts +97 -0
- package/src/utils/gemini-compatibility.ts +193 -0
- package/src/utils/geogebra-instance.ts +1712 -0
- package/src/utils/geogebra-mock.ts +867 -0
- package/src/utils/logger.ts +60 -0
- package/src/utils/performance/index.ts +211 -0
- package/src/utils/performance/instance-pool.ts +323 -0
- package/src/utils/validation.ts +647 -0
- package/tsconfig.json +35 -0
- package/widget/main.ts +12 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model Context Protocol (MCP) Types
|
|
3
|
+
* Following JSON-RPC 2.0 specification
|
|
4
|
+
*/
|
|
5
|
+
export interface JsonRpcRequest {
|
|
6
|
+
jsonrpc: '2.0';
|
|
7
|
+
method: string;
|
|
8
|
+
params?: Record<string, unknown> | unknown[];
|
|
9
|
+
id?: string | number | null;
|
|
10
|
+
}
|
|
11
|
+
export interface JsonRpcResponse {
|
|
12
|
+
jsonrpc: '2.0';
|
|
13
|
+
result?: unknown;
|
|
14
|
+
error?: JsonRpcError;
|
|
15
|
+
id: string | number | null;
|
|
16
|
+
}
|
|
17
|
+
export interface JsonRpcError {
|
|
18
|
+
code: number;
|
|
19
|
+
message: string;
|
|
20
|
+
data?: unknown;
|
|
21
|
+
}
|
|
22
|
+
export interface McpInitializeRequest extends JsonRpcRequest {
|
|
23
|
+
method: 'initialize';
|
|
24
|
+
params: {
|
|
25
|
+
protocolVersion: string;
|
|
26
|
+
capabilities: {
|
|
27
|
+
tools?: {};
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
};
|
|
30
|
+
clientInfo: {
|
|
31
|
+
name: string;
|
|
32
|
+
version: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export interface McpInitializeResponse extends JsonRpcResponse {
|
|
37
|
+
result?: {
|
|
38
|
+
protocolVersion: string;
|
|
39
|
+
capabilities: {
|
|
40
|
+
tools?: {
|
|
41
|
+
listChanged?: boolean;
|
|
42
|
+
};
|
|
43
|
+
[key: string]: unknown;
|
|
44
|
+
};
|
|
45
|
+
serverInfo: {
|
|
46
|
+
name: string;
|
|
47
|
+
version: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
error?: JsonRpcError;
|
|
51
|
+
}
|
|
52
|
+
export interface McpInitializedNotification extends JsonRpcRequest {
|
|
53
|
+
method: 'notifications/initialized';
|
|
54
|
+
params?: Record<string, never>;
|
|
55
|
+
}
|
|
56
|
+
export interface McpTool {
|
|
57
|
+
name: string;
|
|
58
|
+
description: string;
|
|
59
|
+
annotations?: {
|
|
60
|
+
readOnlyHint: boolean;
|
|
61
|
+
destructiveHint: boolean;
|
|
62
|
+
idempotentHint: boolean;
|
|
63
|
+
openWorldHint: boolean;
|
|
64
|
+
};
|
|
65
|
+
outputSchema?: Record<string, unknown>;
|
|
66
|
+
_meta?: Record<string, unknown>;
|
|
67
|
+
inputSchema: {
|
|
68
|
+
type: 'object';
|
|
69
|
+
properties: Record<string, unknown>;
|
|
70
|
+
required?: string[];
|
|
71
|
+
[key: string]: unknown;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export interface McpToolsListRequest extends JsonRpcRequest {
|
|
75
|
+
method: 'tools/list';
|
|
76
|
+
params?: Record<string, never>;
|
|
77
|
+
}
|
|
78
|
+
export interface McpToolsListResponse extends JsonRpcResponse {
|
|
79
|
+
result?: {
|
|
80
|
+
tools: McpTool[];
|
|
81
|
+
};
|
|
82
|
+
error?: JsonRpcError;
|
|
83
|
+
}
|
|
84
|
+
export interface McpToolCallRequest extends JsonRpcRequest {
|
|
85
|
+
method: 'tools/call';
|
|
86
|
+
params: {
|
|
87
|
+
name: string;
|
|
88
|
+
arguments?: Record<string, unknown>;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export interface McpToolCallResponse extends JsonRpcResponse {
|
|
92
|
+
result?: {
|
|
93
|
+
content: Array<{
|
|
94
|
+
type: 'text' | 'image' | 'resource';
|
|
95
|
+
text?: string;
|
|
96
|
+
data?: string;
|
|
97
|
+
mimeType?: string;
|
|
98
|
+
}>;
|
|
99
|
+
structuredContent?: Record<string, unknown>;
|
|
100
|
+
_meta?: Record<string, unknown>;
|
|
101
|
+
isError?: boolean;
|
|
102
|
+
};
|
|
103
|
+
error?: JsonRpcError;
|
|
104
|
+
}
|
|
105
|
+
export declare enum McpErrorCode {
|
|
106
|
+
ParseError = -32700,
|
|
107
|
+
InvalidRequest = -32600,
|
|
108
|
+
MethodNotFound = -32601,
|
|
109
|
+
InvalidParams = -32602,
|
|
110
|
+
InternalError = -32603,
|
|
111
|
+
ToolNotFound = -32000,
|
|
112
|
+
ToolExecutionError = -32001
|
|
113
|
+
}
|
|
114
|
+
export interface McpServerConfig {
|
|
115
|
+
name: string;
|
|
116
|
+
version: string;
|
|
117
|
+
description: string;
|
|
118
|
+
logLevel?: 'error' | 'warn' | 'info' | 'debug';
|
|
119
|
+
}
|
|
120
|
+
export type ToolHandler = (params: Record<string, unknown>) => Promise<NonNullable<McpToolCallResponse['result']>>;
|
|
121
|
+
export interface ToolDefinition {
|
|
122
|
+
tool: McpTool;
|
|
123
|
+
handler: ToolHandler;
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=mcp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/types/mcp.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,EAAE,CAAC;IAC7C,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,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C,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;IACF,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAGD,oBAAY,YAAY;IACtB,UAAU,SAAS;IACnB,cAAc,SAAS;IACvB,cAAc,SAAS;IACvB,aAAa,SAAS;IACtB,aAAa,SAAS;IACtB,YAAY,SAAS;IACrB,kBAAkB,SAAS;CAC5B;AAGD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;CAChD;AAGD,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,WAAW,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AAEnH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,WAAW,CAAC;CACtB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Model Context Protocol (MCP) Types
|
|
4
|
+
* Following JSON-RPC 2.0 specification
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.McpErrorCode = void 0;
|
|
8
|
+
// Error Codes (following JSON-RPC 2.0 and MCP conventions)
|
|
9
|
+
var McpErrorCode;
|
|
10
|
+
(function (McpErrorCode) {
|
|
11
|
+
McpErrorCode[McpErrorCode["ParseError"] = -32700] = "ParseError";
|
|
12
|
+
McpErrorCode[McpErrorCode["InvalidRequest"] = -32600] = "InvalidRequest";
|
|
13
|
+
McpErrorCode[McpErrorCode["MethodNotFound"] = -32601] = "MethodNotFound";
|
|
14
|
+
McpErrorCode[McpErrorCode["InvalidParams"] = -32602] = "InvalidParams";
|
|
15
|
+
McpErrorCode[McpErrorCode["InternalError"] = -32603] = "InternalError";
|
|
16
|
+
McpErrorCode[McpErrorCode["ToolNotFound"] = -32000] = "ToolNotFound";
|
|
17
|
+
McpErrorCode[McpErrorCode["ToolExecutionError"] = -32001] = "ToolExecutionError";
|
|
18
|
+
})(McpErrorCode || (exports.McpErrorCode = McpErrorCode = {}));
|
|
19
|
+
//# sourceMappingURL=mcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/types/mcp.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAgHH,2DAA2D;AAC3D,IAAY,YAQX;AARD,WAAY,YAAY;IACtB,gEAAmB,CAAA;IACnB,wEAAuB,CAAA;IACvB,wEAAuB,CAAA;IACvB,sEAAsB,CAAA;IACtB,sEAAsB,CAAA;IACtB,oEAAqB,CAAA;IACrB,gFAA2B,CAAA;AAC7B,CAAC,EARW,YAAY,4BAAZ,YAAY,QAQvB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type AppInfo = {
|
|
2
|
+
name: string;
|
|
3
|
+
version: string;
|
|
4
|
+
description: string;
|
|
5
|
+
homepage?: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Load package metadata in one place so CLI/server/tools report the same version.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getAppInfo(): AppInfo;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=app-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-info.d.ts","sourceRoot":"","sources":["../../src/utils/app-info.ts"],"names":[],"mappings":"AAAA,KAAK,OAAO,GAAG;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAIF;;GAEG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAsBpC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAppInfo = getAppInfo;
|
|
4
|
+
let cachedAppInfo;
|
|
5
|
+
/**
|
|
6
|
+
* Load package metadata in one place so CLI/server/tools report the same version.
|
|
7
|
+
*/
|
|
8
|
+
function getAppInfo() {
|
|
9
|
+
if (cachedAppInfo) {
|
|
10
|
+
return cachedAppInfo;
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
const packageJson = require('../../package.json');
|
|
14
|
+
cachedAppInfo = {
|
|
15
|
+
name: packageJson.name || 'GeoGebra Studio',
|
|
16
|
+
version: packageJson.version || '0.0.0',
|
|
17
|
+
description: packageJson.description || 'Model Context Protocol server for GeoGebra mathematical visualization',
|
|
18
|
+
homepage: packageJson.homepage
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
catch (_error) {
|
|
22
|
+
cachedAppInfo = {
|
|
23
|
+
name: 'GeoGebra Studio',
|
|
24
|
+
version: '0.0.0',
|
|
25
|
+
description: 'Model Context Protocol server for GeoGebra mathematical visualization'
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return cachedAppInfo;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=app-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-info.js","sourceRoot":"","sources":["../../src/utils/app-info.ts"],"names":[],"mappings":";;AAYA,gCAsBC;AA3BD,IAAI,aAAkC,CAAC;AAEvC;;GAEG;AACH,SAAgB,UAAU;IACxB,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;QAClD,aAAa,GAAG;YACd,IAAI,EAAE,WAAW,CAAC,IAAI,IAAI,iBAAiB;YAC3C,OAAO,EAAE,WAAW,CAAC,OAAO,IAAI,OAAO;YACvC,WAAW,EAAE,WAAW,CAAC,WAAW,IAAI,uEAAuE;YAC/G,QAAQ,EAAE,WAAW,CAAC,QAAQ;SAC/B,CAAC;IACJ,CAAC;IAAC,OAAO,MAAM,EAAE,CAAC;QAChB,aAAa,GAAG;YACd,IAAI,EAAE,iBAAiB;YACvB,OAAO,EAAE,OAAO;YAChB,WAAW,EAAE,uEAAuE;SACrF,CAAC;IACJ,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { JsonRpcError, McpErrorCode } from '../types/mcp';
|
|
2
|
+
/**
|
|
3
|
+
* Custom error class for MCP-specific errors
|
|
4
|
+
*/
|
|
5
|
+
export declare class McpError extends Error {
|
|
6
|
+
readonly code: number;
|
|
7
|
+
readonly data?: unknown;
|
|
8
|
+
constructor(code: McpErrorCode, message: string, data?: unknown);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Create a JSON-RPC error response
|
|
12
|
+
*/
|
|
13
|
+
export declare function createJsonRpcError(code: McpErrorCode, message: string, data?: unknown): JsonRpcError;
|
|
14
|
+
/**
|
|
15
|
+
* Handle and format errors for JSON-RPC responses
|
|
16
|
+
*/
|
|
17
|
+
export declare function handleError(error: unknown): JsonRpcError;
|
|
18
|
+
/**
|
|
19
|
+
* Validate JSON-RPC request structure
|
|
20
|
+
*/
|
|
21
|
+
export declare function validateJsonRpcRequest(request: unknown): request is {
|
|
22
|
+
jsonrpc: '2.0';
|
|
23
|
+
method: string;
|
|
24
|
+
id?: string | number | null;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Common error creators
|
|
28
|
+
*/
|
|
29
|
+
export declare const errors: {
|
|
30
|
+
parseError: (data?: unknown) => McpError;
|
|
31
|
+
invalidRequest: (data?: unknown) => McpError;
|
|
32
|
+
methodNotFound: (method: string) => McpError;
|
|
33
|
+
invalidParams: (message?: string) => McpError;
|
|
34
|
+
toolNotFound: (toolName: string) => McpError;
|
|
35
|
+
toolExecutionError: (toolName: string, message: string) => McpError;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG1D;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,IAAI,CAAC,EAAE,OAAO,CAAC;gBAEnB,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO;CAMhE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,OAAO,GACb,YAAY,CAMd;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,CAoBxD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;CAAE,CAYnI;AAED;;GAEG;AACH,eAAO,MAAM,MAAM;wBACG,OAAO;4BAGH,OAAO;6BAGN,MAAM;8BAGN,MAAM;6BAGN,MAAM;mCAGA,MAAM,WAAW,MAAM;CAEvD,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.errors = exports.McpError = void 0;
|
|
7
|
+
exports.createJsonRpcError = createJsonRpcError;
|
|
8
|
+
exports.handleError = handleError;
|
|
9
|
+
exports.validateJsonRpcRequest = validateJsonRpcRequest;
|
|
10
|
+
const mcp_1 = require("../types/mcp");
|
|
11
|
+
const logger_1 = __importDefault(require("./logger"));
|
|
12
|
+
/**
|
|
13
|
+
* Custom error class for MCP-specific errors
|
|
14
|
+
*/
|
|
15
|
+
class McpError extends Error {
|
|
16
|
+
code;
|
|
17
|
+
data;
|
|
18
|
+
constructor(code, message, data) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = 'McpError';
|
|
21
|
+
this.code = code;
|
|
22
|
+
this.data = data;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.McpError = McpError;
|
|
26
|
+
/**
|
|
27
|
+
* Create a JSON-RPC error response
|
|
28
|
+
*/
|
|
29
|
+
function createJsonRpcError(code, message, data) {
|
|
30
|
+
return {
|
|
31
|
+
code,
|
|
32
|
+
message,
|
|
33
|
+
data
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Handle and format errors for JSON-RPC responses
|
|
38
|
+
*/
|
|
39
|
+
function handleError(error) {
|
|
40
|
+
logger_1.default.error('Error occurred:', error);
|
|
41
|
+
if (error instanceof McpError) {
|
|
42
|
+
return createJsonRpcError(error.code, error.message, error.data);
|
|
43
|
+
}
|
|
44
|
+
if (error instanceof Error) {
|
|
45
|
+
return createJsonRpcError(mcp_1.McpErrorCode.InternalError, error.message, { stack: error.stack });
|
|
46
|
+
}
|
|
47
|
+
return createJsonRpcError(mcp_1.McpErrorCode.InternalError, 'Unknown error occurred', { error: String(error) });
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Validate JSON-RPC request structure
|
|
51
|
+
*/
|
|
52
|
+
function validateJsonRpcRequest(request) {
|
|
53
|
+
if (typeof request !== 'object' || request === null) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
const req = request;
|
|
57
|
+
return (req['jsonrpc'] === '2.0' &&
|
|
58
|
+
typeof req['method'] === 'string' &&
|
|
59
|
+
(req['id'] === undefined || typeof req['id'] === 'string' || typeof req['id'] === 'number' || req['id'] === null));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Common error creators
|
|
63
|
+
*/
|
|
64
|
+
exports.errors = {
|
|
65
|
+
parseError: (data) => new McpError(mcp_1.McpErrorCode.ParseError, 'Parse error', data),
|
|
66
|
+
invalidRequest: (data) => new McpError(mcp_1.McpErrorCode.InvalidRequest, 'Invalid Request', data),
|
|
67
|
+
methodNotFound: (method) => new McpError(mcp_1.McpErrorCode.MethodNotFound, `Method not found: ${method}`),
|
|
68
|
+
invalidParams: (message = 'Invalid params') => new McpError(mcp_1.McpErrorCode.InvalidParams, message),
|
|
69
|
+
toolNotFound: (toolName) => new McpError(mcp_1.McpErrorCode.ToolNotFound, `Tool not found: ${toolName}`),
|
|
70
|
+
toolExecutionError: (toolName, message) => new McpError(mcp_1.McpErrorCode.ToolExecutionError, `Tool execution failed for ${toolName}: ${message}`)
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":";;;;;;AAqBA,gDAUC;AAKD,kCAoBC;AAKD,wDAYC;AAzED,sCAA0D;AAC1D,sDAA8B;AAE9B;;GAEG;AACH,MAAa,QAAS,SAAQ,KAAK;IACjB,IAAI,CAAS;IACb,IAAI,CAAW;IAE/B,YAAY,IAAkB,EAAE,OAAe,EAAE,IAAc;QAC7D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,I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I,CAAC,KAAK,IAAI,CAAC,CAClH,CAAC;AACJ,CAAC;AAED;;GAEG;AACU,QAAA,MAAM,GAAG;IACpB,UAAU,EAAE,CAAC,IAAc,EAAE,EAAE,CAC7B,IAAI,QAAQ,CAAC,kBAAY,CAAC,UAAU,EAAE,aAAa,EAAE,IAAI,CAAC;IAE5D,cAAc,EAAE,CAAC,IAAc,EAAE,EAAE,CACjC,IAAI,QAAQ,CAAC,kBAAY,CAAC,cAAc,EAAE,iBAAiB,EAAE,IAAI,CAAC;IAEpE,cAAc,EAAE,CAAC,MAAc,EAAE,EAAE,CACjC,IAAI,QAAQ,CAAC,kBAAY,CAAC,cAAc,EAAE,qBAAqB,MAAM,EAAE,CAAC;IAE1E,aAAa,EAAE,CAAC,UAAkB,gBAAgB,EAAE,EAAE,CACpD,IAAI,QAAQ,CAAC,kBAAY,CAAC,aAAa,EAAE,OAAO,CAAC;IAEnD,YAAY,EAAE,CAAC,QAAgB,EAAE,EAAE,CACjC,IAAI,QAAQ,CAAC,kBAAY,CAAC,YAAY,EAAE,mBAAmB,QAAQ,EAAE,CAAC;IAExE,kBAAkB,EAAE,CAAC,QAAgB,EAAE,OAAe,EAAE,EAAE,CACxD,IAAI,QAAQ,CAAC,kBAAY,CAAC,kBAAkB,EAAE,6BAA6B,QAAQ,KAAK,OAAO,EAAE,CAAC;CACrG,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gemini Compatibility Utilities
|
|
3
|
+
*
|
|
4
|
+
* Gemini 2.5 Pro Preview requires stricter JSON Schema compliance:
|
|
5
|
+
* - All properties MUST have explicit "type" fields
|
|
6
|
+
* - No support for oneOf/anyOf/allOf constructs
|
|
7
|
+
* - Type must be specified for all parameter properties
|
|
8
|
+
*/
|
|
9
|
+
export interface GeminiCompatibleSchema {
|
|
10
|
+
type: 'object';
|
|
11
|
+
properties: Record<string, {
|
|
12
|
+
type: 'string' | 'number' | 'boolean' | 'integer' | 'array' | 'object';
|
|
13
|
+
description?: string;
|
|
14
|
+
minimum?: number;
|
|
15
|
+
maximum?: number;
|
|
16
|
+
items?: any;
|
|
17
|
+
properties?: any;
|
|
18
|
+
required?: string[];
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
}>;
|
|
21
|
+
required?: string[];
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Transform a schema to be compatible with Gemini 2.5 Pro Preview
|
|
26
|
+
*/
|
|
27
|
+
export declare function makeGeminiCompatible(schema: any): GeminiCompatibleSchema;
|
|
28
|
+
/**
|
|
29
|
+
* Check if a schema needs Gemini compatibility fixes
|
|
30
|
+
*/
|
|
31
|
+
export declare function needsGeminiCompatibility(schema: any): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Validate that a schema is Gemini-compatible
|
|
34
|
+
*/
|
|
35
|
+
export declare function validateGeminiCompatibility(schema: any): {
|
|
36
|
+
isCompatible: boolean;
|
|
37
|
+
issues: string[];
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=gemini-compatibility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gemini-compatibility.d.ts","sourceRoot":"","sources":["../../src/utils/gemini-compatibility.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE;QACzB,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;QACvE,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,GAAG,CAAC;QACZ,UAAU,CAAC,EAAE,GAAG,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC,CAAC;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,GAAG,GAAG,sBAAsB,CAgExE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAmC7D;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,GAAG,GAAG;IACxD,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAoDA"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Gemini Compatibility Utilities
|
|
4
|
+
*
|
|
5
|
+
* Gemini 2.5 Pro Preview requires stricter JSON Schema compliance:
|
|
6
|
+
* - All properties MUST have explicit "type" fields
|
|
7
|
+
* - No support for oneOf/anyOf/allOf constructs
|
|
8
|
+
* - Type must be specified for all parameter properties
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.makeGeminiCompatible = makeGeminiCompatible;
|
|
12
|
+
exports.needsGeminiCompatibility = needsGeminiCompatibility;
|
|
13
|
+
exports.validateGeminiCompatibility = validateGeminiCompatibility;
|
|
14
|
+
/**
|
|
15
|
+
* Transform a schema to be compatible with Gemini 2.5 Pro Preview
|
|
16
|
+
*/
|
|
17
|
+
function makeGeminiCompatible(schema) {
|
|
18
|
+
if (!schema || typeof schema !== 'object') {
|
|
19
|
+
return {
|
|
20
|
+
type: 'object',
|
|
21
|
+
properties: {},
|
|
22
|
+
required: []
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const result = {
|
|
26
|
+
type: 'object',
|
|
27
|
+
properties: {},
|
|
28
|
+
required: schema.required || []
|
|
29
|
+
};
|
|
30
|
+
// Ensure all properties have explicit types
|
|
31
|
+
if (schema.properties && typeof schema.properties === 'object') {
|
|
32
|
+
for (const [key, prop] of Object.entries(schema.properties)) {
|
|
33
|
+
if (!prop || typeof prop !== 'object') {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const transformedProp = { ...prop };
|
|
37
|
+
// Ensure type is explicitly set
|
|
38
|
+
if (!transformedProp.type) {
|
|
39
|
+
// Infer type from other properties or default to string
|
|
40
|
+
if (transformedProp.minimum !== undefined || transformedProp.maximum !== undefined) {
|
|
41
|
+
transformedProp.type = 'number';
|
|
42
|
+
}
|
|
43
|
+
else if (transformedProp.items !== undefined) {
|
|
44
|
+
transformedProp.type = 'array';
|
|
45
|
+
}
|
|
46
|
+
else if (transformedProp.properties !== undefined) {
|
|
47
|
+
transformedProp.type = 'object';
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
transformedProp.type = 'string';
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// Remove any oneOf/anyOf/allOf constructs as Gemini doesn't support them
|
|
54
|
+
delete transformedProp.oneOf;
|
|
55
|
+
delete transformedProp.anyOf;
|
|
56
|
+
delete transformedProp.allOf;
|
|
57
|
+
// Recursively transform nested objects
|
|
58
|
+
if (transformedProp.type === 'object' && transformedProp.properties) {
|
|
59
|
+
transformedProp.properties = makeGeminiCompatible({
|
|
60
|
+
type: 'object',
|
|
61
|
+
properties: transformedProp.properties,
|
|
62
|
+
required: transformedProp.required
|
|
63
|
+
}).properties;
|
|
64
|
+
}
|
|
65
|
+
// Transform array items if present
|
|
66
|
+
if (transformedProp.type === 'array' && transformedProp.items) {
|
|
67
|
+
if (typeof transformedProp.items === 'object' && !transformedProp.items.type) {
|
|
68
|
+
transformedProp.items = makeGeminiCompatible(transformedProp.items);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
result.properties[key] = transformedProp;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Check if a schema needs Gemini compatibility fixes
|
|
78
|
+
*/
|
|
79
|
+
function needsGeminiCompatibility(schema) {
|
|
80
|
+
if (!schema || typeof schema !== 'object') {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
// Check for missing type at root level
|
|
84
|
+
if (!schema.type) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
// Check for oneOf/anyOf/allOf constructs
|
|
88
|
+
if (schema.oneOf || schema.anyOf || schema.allOf) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
// Check properties for missing types
|
|
92
|
+
if (schema.properties && typeof schema.properties === 'object') {
|
|
93
|
+
for (const prop of Object.values(schema.properties)) {
|
|
94
|
+
if (prop && typeof prop === 'object' && !prop.type) {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
// Check for oneOf/anyOf/allOf in properties
|
|
98
|
+
if (prop && (prop.oneOf || prop.anyOf || prop.allOf)) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
// Recursively check nested objects
|
|
102
|
+
if (prop && prop.type === 'object' && prop.properties && needsGeminiCompatibility(prop)) {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Validate that a schema is Gemini-compatible
|
|
111
|
+
*/
|
|
112
|
+
function validateGeminiCompatibility(schema) {
|
|
113
|
+
const issues = [];
|
|
114
|
+
if (!schema || typeof schema !== 'object') {
|
|
115
|
+
issues.push('Schema is not an object');
|
|
116
|
+
return { isCompatible: false, issues };
|
|
117
|
+
}
|
|
118
|
+
if (!schema.type) {
|
|
119
|
+
issues.push('Root schema missing type field');
|
|
120
|
+
}
|
|
121
|
+
if (schema.oneOf) {
|
|
122
|
+
issues.push('Root schema uses oneOf (not supported by Gemini)');
|
|
123
|
+
}
|
|
124
|
+
if (schema.anyOf) {
|
|
125
|
+
issues.push('Root schema uses anyOf (not supported by Gemini)');
|
|
126
|
+
}
|
|
127
|
+
if (schema.allOf) {
|
|
128
|
+
issues.push('Root schema uses allOf (not supported by Gemini)');
|
|
129
|
+
}
|
|
130
|
+
if (schema.properties && typeof schema.properties === 'object') {
|
|
131
|
+
for (const [key, prop] of Object.entries(schema.properties)) {
|
|
132
|
+
if (!prop || typeof prop !== 'object') {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (!prop.type) {
|
|
136
|
+
issues.push(`Property "${key}" missing type field`);
|
|
137
|
+
}
|
|
138
|
+
if (prop.oneOf) {
|
|
139
|
+
issues.push(`Property "${key}" uses oneOf (not supported by Gemini)`);
|
|
140
|
+
}
|
|
141
|
+
if (prop.anyOf) {
|
|
142
|
+
issues.push(`Property "${key}" uses anyOf (not supported by Gemini)`);
|
|
143
|
+
}
|
|
144
|
+
if (prop.allOf) {
|
|
145
|
+
issues.push(`Property "${key}" uses allOf (not supported by Gemini)`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
isCompatible: issues.length === 0,
|
|
151
|
+
issues
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=gemini-compatibility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gemini-compatibility.js","sourceRoot":"","sources":["../../src/utils/gemini-compatibility.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AAqBH,oDAgEC;AAKD,4DAmCC;AAKD,kEAuDC;AAvKD;;GAEG;AACH,SAAgB,oBAAoB,CAAC,MAAW;IAC9C,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC1C,OAAO;YACL,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,EAAE;YACd,QAAQ,EAAE,EAAE;SACb,CAAC;IACJ,CAAC;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