@intlayer/mcp 6.1.6 → 7.0.0-canary.1
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/dist/cjs/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/cjs/client/client.cjs +22 -42
- package/dist/cjs/client/client.cjs.map +1 -1
- package/dist/cjs/client/sse.cjs +59 -57
- package/dist/cjs/client/sse.cjs.map +1 -1
- package/dist/cjs/server/server.cjs +29 -53
- package/dist/cjs/server/server.cjs.map +1 -1
- package/dist/cjs/server/sse.cjs +92 -104
- package/dist/cjs/server/sse.cjs.map +1 -1
- package/dist/cjs/server/stdio.cjs +14 -9
- package/dist/cjs/server/stdio.cjs.map +1 -1
- package/dist/cjs/tools/cli.cjs +203 -268
- package/dist/cjs/tools/cli.cjs.map +1 -1
- package/dist/cjs/tools/docs.cjs +34 -145
- package/dist/cjs/tools/docs.cjs.map +1 -1
- package/dist/esm/client/client.mjs +12 -13
- package/dist/esm/client/client.mjs.map +1 -1
- package/dist/esm/client/sse.mjs +55 -55
- package/dist/esm/client/sse.mjs.map +1 -1
- package/dist/esm/server/server.mjs +20 -25
- package/dist/esm/server/server.mjs.map +1 -1
- package/dist/esm/server/sse.mjs +81 -74
- package/dist/esm/server/sse.mjs.map +1 -1
- package/dist/esm/server/stdio.mjs +10 -6
- package/dist/esm/server/stdio.mjs.map +1 -1
- package/dist/esm/tools/cli.mjs +199 -240
- package/dist/esm/tools/cli.mjs.map +1 -1
- package/dist/esm/tools/docs.mjs +31 -111
- package/dist/esm/tools/docs.mjs.map +1 -1
- package/dist/types/client/client.d.ts +8 -25
- package/dist/types/client/client.d.ts.map +1 -1
- package/dist/types/client/sse.d.ts +1 -2
- package/dist/types/server/server.d.ts +8 -3
- package/dist/types/server/server.d.ts.map +1 -1
- package/dist/types/server/sse.d.ts +1 -3
- package/dist/types/server/stdio.d.ts +1 -3
- package/dist/types/tools/cli.d.ts +7 -2
- package/dist/types/tools/cli.d.ts.map +1 -1
- package/dist/types/tools/docs.d.ts +7 -2
- package/dist/types/tools/docs.d.ts.map +1 -1
- package/package.json +47 -53
- package/LICENSE +0 -202
- package/dist/types/client/sse.d.ts.map +0 -1
- package/dist/types/server/sse.d.ts.map +0 -1
- package/dist/types/server/stdio.d.ts.map +0 -1
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
3
|
+
const require_server_server = require('./server.cjs');
|
|
4
|
+
let __modelcontextprotocol_sdk_server_stdio_js = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
5
|
+
__modelcontextprotocol_sdk_server_stdio_js = require_rolldown_runtime.__toESM(__modelcontextprotocol_sdk_server_stdio_js);
|
|
6
|
+
|
|
7
|
+
//#region src/server/stdio.ts
|
|
8
|
+
const server = require_server_server.loadServer(true);
|
|
6
9
|
const main = async () => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
const transport = new __modelcontextprotocol_sdk_server_stdio_js.StdioServerTransport();
|
|
11
|
+
await server.connect(transport);
|
|
12
|
+
console.error("Intlayer MCP Server running on stdio");
|
|
10
13
|
};
|
|
11
14
|
main().catch((error) => {
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
console.error("Fatal error in main():", error);
|
|
16
|
+
process.exit(1);
|
|
14
17
|
});
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
15
20
|
//# sourceMappingURL=stdio.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/stdio.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { loadServer } from './server';\n\nconst server = loadServer(true);\n\nconst main = async () => {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n console.error('Intlayer MCP Server running on stdio');\n};\n\nmain().catch((error) => {\n console.error('Fatal error in main():', error);\n process.exit(1);\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"stdio.cjs","names":["loadServer","StdioServerTransport"],"sources":["../../../src/server/stdio.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { loadServer } from './server';\n\nconst server = loadServer(true);\n\nconst main = async () => {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n console.error('Intlayer MCP Server running on stdio');\n};\n\nmain().catch((error) => {\n console.error('Fatal error in main():', error);\n process.exit(1);\n});\n"],"mappings":";;;;;;;AAKA,MAAM,SAASA,iCAAW,KAAK;AAE/B,MAAM,OAAO,YAAY;CACvB,MAAM,YAAY,IAAIC,iEAAsB;AAC5C,OAAM,OAAO,QAAQ,UAAU;AAC/B,SAAQ,MAAM,uCAAuC;;AAGvD,MAAM,CAAC,OAAO,UAAU;AACtB,SAAQ,MAAM,0BAA0B,MAAM;AAC9C,SAAQ,KAAK,EAAE;EACf"}
|
package/dist/cjs/tools/cli.cjs
CHANGED
|
@@ -1,271 +1,206 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var cli_exports = {};
|
|
30
|
-
__export(cli_exports, {
|
|
31
|
-
loadCLITools: () => loadCLITools
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(cli_exports);
|
|
34
|
-
var import_cli = require("@intlayer/cli");
|
|
35
|
-
var import_config = require("@intlayer/config");
|
|
36
|
-
var import_zod = __toESM(require("zod"));
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __intlayer_cli = require("@intlayer/cli");
|
|
3
|
+
__intlayer_cli = require_rolldown_runtime.__toESM(__intlayer_cli);
|
|
4
|
+
let __intlayer_types = require("@intlayer/types");
|
|
5
|
+
__intlayer_types = require_rolldown_runtime.__toESM(__intlayer_types);
|
|
6
|
+
let zod_v3 = require("zod/v3");
|
|
7
|
+
zod_v3 = require_rolldown_runtime.__toESM(zod_v3);
|
|
8
|
+
|
|
9
|
+
//#region src/tools/cli.ts
|
|
37
10
|
const loadCLITools = async (server) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
env: import_zod.default.string().optional(),
|
|
230
|
-
envFile: import_zod.default.string().optional(),
|
|
231
|
-
override: import_zod.default.object({
|
|
232
|
-
log: import_zod.default.object({
|
|
233
|
-
prefix: import_zod.default.string().optional(),
|
|
234
|
-
verbose: import_zod.default.boolean().optional()
|
|
235
|
-
}).optional()
|
|
236
|
-
}).optional()
|
|
237
|
-
}).optional().describe("Configuration options")
|
|
238
|
-
},
|
|
239
|
-
async (props) => {
|
|
240
|
-
try {
|
|
241
|
-
const missingTranslations = (0, import_cli.listMissingTranslations)(
|
|
242
|
-
void 0,
|
|
243
|
-
props?.configOptions
|
|
244
|
-
);
|
|
245
|
-
return {
|
|
246
|
-
content: [
|
|
247
|
-
{
|
|
248
|
-
type: "text",
|
|
249
|
-
text: JSON.stringify(missingTranslations, null, 2)
|
|
250
|
-
}
|
|
251
|
-
]
|
|
252
|
-
};
|
|
253
|
-
} catch (error) {
|
|
254
|
-
const errorMessage = error instanceof Error ? error.message : "An unknown error occurred";
|
|
255
|
-
return {
|
|
256
|
-
content: [
|
|
257
|
-
{
|
|
258
|
-
type: "text",
|
|
259
|
-
text: `Content test failed: ${errorMessage}`
|
|
260
|
-
}
|
|
261
|
-
]
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
);
|
|
11
|
+
server.tool("intlayer-build", "Build the dictionaries. List all content declarations files `.content.{ts,tsx,js,json,...}` to update the content callable using the `useIntlayer` hook.", {
|
|
12
|
+
watch: zod_v3.default.boolean().optional().describe("Watch for changes"),
|
|
13
|
+
baseDir: zod_v3.default.string().optional().describe("Base directory"),
|
|
14
|
+
env: zod_v3.default.string().optional().describe("Environment"),
|
|
15
|
+
envFile: zod_v3.default.string().optional().describe("Environment file"),
|
|
16
|
+
verbose: zod_v3.default.boolean().optional().describe("Verbose output"),
|
|
17
|
+
prefix: zod_v3.default.string().optional().describe("Log prefix")
|
|
18
|
+
}, async ({ watch, baseDir, env, envFile, verbose, prefix }) => {
|
|
19
|
+
try {
|
|
20
|
+
const log = {};
|
|
21
|
+
if (verbose) log.mode = "verbose";
|
|
22
|
+
if (prefix) log.prefix = prefix;
|
|
23
|
+
await (0, __intlayer_cli.build)({
|
|
24
|
+
watch,
|
|
25
|
+
configOptions: {
|
|
26
|
+
baseDir,
|
|
27
|
+
env,
|
|
28
|
+
envFile,
|
|
29
|
+
override: { log }
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return { content: [{
|
|
33
|
+
type: "text",
|
|
34
|
+
text: "Build successful."
|
|
35
|
+
}] };
|
|
36
|
+
} catch (error) {
|
|
37
|
+
return { content: [{
|
|
38
|
+
type: "text",
|
|
39
|
+
text: `Build failed: ${error instanceof Error ? error.message : "An unknown error occurred"}`
|
|
40
|
+
}] };
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
server.tool("intlayer-fill", "Fill the dictionaries with missing translations / review translations using Intlayer servers", {
|
|
44
|
+
sourceLocale: zod_v3.default.nativeEnum(__intlayer_types.Locales.ALL_LOCALES).optional().describe("Source locale"),
|
|
45
|
+
outputLocales: zod_v3.default.union([zod_v3.default.nativeEnum(__intlayer_types.Locales.ALL_LOCALES), zod_v3.default.array(zod_v3.default.nativeEnum(__intlayer_types.Locales.ALL_LOCALES))]).optional().describe("Output locales"),
|
|
46
|
+
file: zod_v3.default.union([zod_v3.default.string(), zod_v3.default.array(zod_v3.default.string())]).optional().describe("File path"),
|
|
47
|
+
mode: zod_v3.default.enum(["complete", "review"]).optional().describe("Fill mode"),
|
|
48
|
+
keys: zod_v3.default.union([zod_v3.default.string(), zod_v3.default.array(zod_v3.default.string())]).optional().describe("Keys to include"),
|
|
49
|
+
excludedKeys: zod_v3.default.union([zod_v3.default.string(), zod_v3.default.array(zod_v3.default.string())]).optional().describe("Keys to exclude"),
|
|
50
|
+
pathFilter: zod_v3.default.union([zod_v3.default.string(), zod_v3.default.array(zod_v3.default.string())]).optional().describe("Path filter"),
|
|
51
|
+
gitOptions: zod_v3.default.object({
|
|
52
|
+
gitDiff: zod_v3.default.boolean().optional(),
|
|
53
|
+
gitDiffBase: zod_v3.default.string().optional(),
|
|
54
|
+
gitDiffCurrent: zod_v3.default.string().optional(),
|
|
55
|
+
uncommitted: zod_v3.default.boolean().optional(),
|
|
56
|
+
unpushed: zod_v3.default.boolean().optional(),
|
|
57
|
+
untracked: zod_v3.default.boolean().optional()
|
|
58
|
+
}).optional().describe("Git options"),
|
|
59
|
+
aiOptions: zod_v3.default.object({
|
|
60
|
+
provider: zod_v3.default.string().optional(),
|
|
61
|
+
temperature: zod_v3.default.number().optional(),
|
|
62
|
+
model: zod_v3.default.string().optional(),
|
|
63
|
+
apiKey: zod_v3.default.string().optional(),
|
|
64
|
+
customPrompt: zod_v3.default.string().optional(),
|
|
65
|
+
applicationContext: zod_v3.default.string().optional()
|
|
66
|
+
}).optional().describe("AI options")
|
|
67
|
+
}, async (props) => {
|
|
68
|
+
try {
|
|
69
|
+
const { gitOptions,...rest } = props;
|
|
70
|
+
const fillOptions = {
|
|
71
|
+
...rest,
|
|
72
|
+
gitOptions: void 0
|
|
73
|
+
};
|
|
74
|
+
if (gitOptions) {
|
|
75
|
+
const { gitDiff, uncommitted, unpushed, untracked,...restGit } = gitOptions;
|
|
76
|
+
const mode = [];
|
|
77
|
+
if (gitDiff) mode.push("gitDiff");
|
|
78
|
+
if (uncommitted) mode.push("uncommitted");
|
|
79
|
+
if (unpushed) mode.push("unpushed");
|
|
80
|
+
if (untracked) mode.push("untracked");
|
|
81
|
+
fillOptions.gitOptions = {
|
|
82
|
+
...restGit,
|
|
83
|
+
mode
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
await (0, __intlayer_cli.fill)(fillOptions);
|
|
87
|
+
return { content: [{
|
|
88
|
+
type: "text",
|
|
89
|
+
text: "Fill successful."
|
|
90
|
+
}] };
|
|
91
|
+
} catch (error) {
|
|
92
|
+
return { content: [{
|
|
93
|
+
type: "text",
|
|
94
|
+
text: `Fill failed: ${error instanceof Error ? error.message : "An unknown error occurred"}`
|
|
95
|
+
}] };
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
server.tool("intlayer-push", "Push local dictionaries to the server", {
|
|
99
|
+
deleteLocaleDictionary: zod_v3.default.boolean().optional().describe("Delete local dictionary after push"),
|
|
100
|
+
keepLocaleDictionary: zod_v3.default.boolean().optional().describe("Keep local dictionary after push"),
|
|
101
|
+
dictionaries: zod_v3.default.array(zod_v3.default.string()).optional().describe("List of dictionaries to push"),
|
|
102
|
+
gitOptions: zod_v3.default.object({
|
|
103
|
+
gitDiff: zod_v3.default.boolean().optional(),
|
|
104
|
+
gitDiffBase: zod_v3.default.string().optional(),
|
|
105
|
+
gitDiffCurrent: zod_v3.default.string().optional(),
|
|
106
|
+
uncommitted: zod_v3.default.boolean().optional(),
|
|
107
|
+
unpushed: zod_v3.default.boolean().optional(),
|
|
108
|
+
untracked: zod_v3.default.boolean().optional()
|
|
109
|
+
}).optional().describe("Git options")
|
|
110
|
+
}, async (props) => {
|
|
111
|
+
try {
|
|
112
|
+
const { gitOptions,...rest } = props;
|
|
113
|
+
const pushOptions = {
|
|
114
|
+
...rest,
|
|
115
|
+
gitOptions: void 0
|
|
116
|
+
};
|
|
117
|
+
if (gitOptions) {
|
|
118
|
+
const { gitDiff, uncommitted, unpushed, untracked,...restGit } = gitOptions;
|
|
119
|
+
const mode = [];
|
|
120
|
+
if (gitDiff) mode.push("gitDiff");
|
|
121
|
+
if (uncommitted) mode.push("uncommitted");
|
|
122
|
+
if (unpushed) mode.push("unpushed");
|
|
123
|
+
if (untracked) mode.push("untracked");
|
|
124
|
+
pushOptions.gitOptions = {
|
|
125
|
+
...restGit,
|
|
126
|
+
mode
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
await (0, __intlayer_cli.push)(pushOptions);
|
|
130
|
+
return { content: [{
|
|
131
|
+
type: "text",
|
|
132
|
+
text: "Push successful."
|
|
133
|
+
}] };
|
|
134
|
+
} catch (error) {
|
|
135
|
+
return { content: [{
|
|
136
|
+
type: "text",
|
|
137
|
+
text: `Push failed: ${error instanceof Error ? error.message : "An unknown error occurred"}`
|
|
138
|
+
}] };
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
server.tool("intlayer-pull", "Pull dictionaries from the CMS", {
|
|
142
|
+
dictionaries: zod_v3.default.array(zod_v3.default.string()).optional().describe("List of dictionaries to pull"),
|
|
143
|
+
newDictionariesPath: zod_v3.default.string().optional().describe("Path to save new dictionaries")
|
|
144
|
+
}, async (props) => {
|
|
145
|
+
try {
|
|
146
|
+
await (0, __intlayer_cli.pull)(props);
|
|
147
|
+
return { content: [{
|
|
148
|
+
type: "text",
|
|
149
|
+
text: "Pull successful."
|
|
150
|
+
}] };
|
|
151
|
+
} catch (error) {
|
|
152
|
+
return { content: [{
|
|
153
|
+
type: "text",
|
|
154
|
+
text: `Pull failed: ${error instanceof Error ? error.message : "An unknown error occurred"}`
|
|
155
|
+
}] };
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
server.tool("intlayer-content-list", "List the content declaration (.content.{ts,tsx,js,json,...}) files present in the project. That files contain the multilingual content of the application and are used to build the dictionaries.", { configOptions: zod_v3.default.object({
|
|
159
|
+
baseDir: zod_v3.default.string().optional(),
|
|
160
|
+
env: zod_v3.default.string().optional(),
|
|
161
|
+
envFile: zod_v3.default.string().optional(),
|
|
162
|
+
override: zod_v3.default.object({ log: zod_v3.default.object({
|
|
163
|
+
prefix: zod_v3.default.string().optional(),
|
|
164
|
+
verbose: zod_v3.default.boolean().optional()
|
|
165
|
+
}).optional() }).optional()
|
|
166
|
+
}).optional().describe("Configuration options") }, async (props) => {
|
|
167
|
+
try {
|
|
168
|
+
const rows = (0, __intlayer_cli.listContentDeclarationRows)(props);
|
|
169
|
+
return { content: [{
|
|
170
|
+
type: "text",
|
|
171
|
+
text: JSON.stringify(rows, null, 2)
|
|
172
|
+
}] };
|
|
173
|
+
} catch (error) {
|
|
174
|
+
return { content: [{
|
|
175
|
+
type: "text",
|
|
176
|
+
text: `Content list failed: ${error instanceof Error ? error.message : "An unknown error occurred"}`
|
|
177
|
+
}] };
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
server.tool("intlayer-content-test", "Test if there are missing translations in the content declaration files. That files contain the multilingual content of the application and are used to build the dictionaries.", { configOptions: zod_v3.default.object({
|
|
181
|
+
baseDir: zod_v3.default.string().optional(),
|
|
182
|
+
env: zod_v3.default.string().optional(),
|
|
183
|
+
envFile: zod_v3.default.string().optional(),
|
|
184
|
+
override: zod_v3.default.object({ log: zod_v3.default.object({
|
|
185
|
+
prefix: zod_v3.default.string().optional(),
|
|
186
|
+
verbose: zod_v3.default.boolean().optional()
|
|
187
|
+
}).optional() }).optional()
|
|
188
|
+
}).optional().describe("Configuration options") }, async (props) => {
|
|
189
|
+
try {
|
|
190
|
+
const missingTranslations = (0, __intlayer_cli.listMissingTranslations)(void 0, props?.configOptions);
|
|
191
|
+
return { content: [{
|
|
192
|
+
type: "text",
|
|
193
|
+
text: JSON.stringify(missingTranslations, null, 2)
|
|
194
|
+
}] };
|
|
195
|
+
} catch (error) {
|
|
196
|
+
return { content: [{
|
|
197
|
+
type: "text",
|
|
198
|
+
text: `Content test failed: ${error instanceof Error ? error.message : "An unknown error occurred"}`
|
|
199
|
+
}] };
|
|
200
|
+
}
|
|
201
|
+
});
|
|
266
202
|
};
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
});
|
|
203
|
+
|
|
204
|
+
//#endregion
|
|
205
|
+
exports.loadCLITools = loadCLITools;
|
|
271
206
|
//# sourceMappingURL=cli.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/tools/cli.ts"],"sourcesContent":["import {\n fill,\n listContentDeclarationRows,\n listMissingTranslations,\n pull,\n push,\n} from '@intlayer/cli';\nimport { Locales } from '@intlayer/config';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport z from 'zod';\n\nexport const loadCLITools = async (server: McpServer) => {\n server.tool(\n 'intlayer-fill',\n 'Fill the dictionaries with missing translations / review translations using Intlayer servers',\n {\n sourceLocale: z.nativeEnum(Locales).optional().describe('Source locale'),\n outputLocales: z\n .union([z.nativeEnum(Locales), z.array(z.nativeEnum(Locales))])\n .optional()\n .describe('Output locales'),\n file: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('File path'),\n mode: z.enum(['complete', 'review']).optional().describe('Fill mode'),\n keys: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Keys to include'),\n excludedKeys: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Keys to exclude'),\n pathFilter: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Path filter'),\n gitOptions: z\n .object({\n gitDiff: z.boolean().optional(),\n gitDiffBase: z.string().optional(),\n gitDiffCurrent: z.string().optional(),\n uncommitted: z.boolean().optional(),\n unpushed: z.boolean().optional(),\n untracked: z.boolean().optional(),\n })\n .optional()\n .describe('Git options'),\n aiOptions: z\n .object({\n provider: z.string().optional(),\n temperature: z.number().optional(),\n model: z.string().optional(),\n apiKey: z.string().optional(),\n customPrompt: z.string().optional(),\n applicationContext: z.string().optional(),\n })\n .optional()\n .describe('AI options'),\n },\n async (props) => {\n try {\n const { gitOptions, ...rest } = props;\n const fillOptions: any = { ...rest, gitOptions: undefined };\n\n if (gitOptions) {\n const { gitDiff, uncommitted, unpushed, untracked, ...restGit } =\n gitOptions;\n const mode = [];\n if (gitDiff) mode.push('gitDiff');\n if (uncommitted) mode.push('uncommitted');\n if (unpushed) mode.push('unpushed');\n if (untracked) mode.push('untracked');\n\n fillOptions.gitOptions = { ...restGit, mode };\n }\n\n await fill(fillOptions);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Fill successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Fill failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.tool(\n 'intlayer-push',\n 'Push local dictionaries to the server',\n {\n deleteLocaleDictionary: z\n .boolean()\n .optional()\n .describe('Delete local dictionary after push'),\n keepLocaleDictionary: z\n .boolean()\n .optional()\n .describe('Keep local dictionary after push'),\n dictionaries: z\n .array(z.string())\n .optional()\n .describe('List of dictionaries to push'),\n gitOptions: z\n .object({\n gitDiff: z.boolean().optional(),\n gitDiffBase: z.string().optional(),\n gitDiffCurrent: z.string().optional(),\n uncommitted: z.boolean().optional(),\n unpushed: z.boolean().optional(),\n untracked: z.boolean().optional(),\n })\n .optional()\n .describe('Git options'),\n },\n async (props) => {\n try {\n const { gitOptions, ...rest } = props;\n const pushOptions: any = { ...rest, gitOptions: undefined };\n\n if (gitOptions) {\n const { gitDiff, uncommitted, unpushed, untracked, ...restGit } =\n gitOptions;\n const mode = [];\n if (gitDiff) mode.push('gitDiff');\n if (uncommitted) mode.push('uncommitted');\n if (unpushed) mode.push('unpushed');\n if (untracked) mode.push('untracked');\n\n pushOptions.gitOptions = { ...restGit, mode };\n }\n\n await push(pushOptions);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Push successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Push failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.tool(\n 'intlayer-pull',\n 'Pull dictionaries from the CMS',\n {\n dictionaries: z\n .array(z.string())\n .optional()\n .describe('List of dictionaries to pull'),\n newDictionariesPath: z\n .string()\n .optional()\n .describe('Path to save new dictionaries'),\n },\n async (props) => {\n try {\n await pull(props);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Pull successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Pull failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.tool(\n 'intlayer-content-list',\n 'List the content declaration (.content.{ts,tsx,js,json,...}) files present in the project. That files contain the multilingual content of the application and are used to build the dictionaries.',\n {\n configOptions: z\n .object({\n baseDir: z.string().optional(),\n env: z.string().optional(),\n envFile: z.string().optional(),\n override: z\n .object({\n log: z\n .object({\n prefix: z.string().optional(),\n verbose: z.boolean().optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional()\n .describe('Configuration options'),\n },\n async (props) => {\n try {\n const rows = listContentDeclarationRows(props);\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(rows, null, 2),\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Content list failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.tool(\n 'intlayer-content-test',\n 'Test if there are missing translations in the content declaration files. That files contain the multilingual content of the application and are used to build the dictionaries.',\n {\n configOptions: z\n .object({\n baseDir: z.string().optional(),\n env: z.string().optional(),\n envFile: z.string().optional(),\n override: z\n .object({\n log: z\n .object({\n prefix: z.string().optional(),\n verbose: z.boolean().optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional()\n .describe('Configuration options'),\n },\n async (props) => {\n try {\n const missingTranslations = listMissingTranslations(\n undefined,\n props?.configOptions\n );\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(missingTranslations, null, 2),\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Content test failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAMO;AACP,oBAAwB;AAExB,iBAAc;AAEP,MAAM,eAAe,OAAO,WAAsB;AACvD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,MACE,cAAc,WAAAA,QAAE,WAAW,qBAAO,EAAE,SAAS,EAAE,SAAS,eAAe;AAAA,MACvE,eAAe,WAAAA,QACZ,MAAM,CAAC,WAAAA,QAAE,WAAW,qBAAO,GAAG,WAAAA,QAAE,MAAM,WAAAA,QAAE,WAAW,qBAAO,CAAC,CAAC,CAAC,EAC7D,SAAS,EACT,SAAS,gBAAgB;AAAA,MAC5B,MAAM,WAAAA,QACH,MAAM,CAAC,WAAAA,QAAE,OAAO,GAAG,WAAAA,QAAE,MAAM,WAAAA,QAAE,OAAO,CAAC,CAAC,CAAC,EACvC,SAAS,EACT,SAAS,WAAW;AAAA,MACvB,MAAM,WAAAA,QAAE,KAAK,CAAC,YAAY,QAAQ,CAAC,EAAE,SAAS,EAAE,SAAS,WAAW;AAAA,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A,YACP;AAAA,cACE,MAAM;AAAA,cACN,MAAM,wBAAwB,YAAY;AAAA,YAC5C;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,MACE,eAAe,WAAAA,QACZ,OAAO;AAAA,QACN,SAAS,WAAAA,QAAE,OAAO,EAAE,SAAS;AAAA,QAC7B,KAAK,WAAAA,QAAE,OAAO,EAAE,SAAS;AAAA,QACzB,SAAS,WAAAA,QAAE,OAAO,EAAE,SAAS;AAAA,QAC7B,UAAU,WAAAA,QACP,OAAO;AAAA,UACN,KAAK,WAAAA,QACF,OAAO;AAAA,YACN,QAAQ,WAAAA,QAAE,OAAO,EAAE,SAAS;AAAA,YAC5B,SAAS,WAAAA,QAAE,QAAQ,EAAE,SAAS;AAAA,UAChC,CAAC,EACA,SAAS;AAAA,QACd,CAAC,EACA,SAAS;AAAA,MACd,CAAC,EACA,SAAS,EACT,SAAS,uBAAuB;AAAA,IACrC;AAAA,IACA,OAAO,UAAU;AACf,UAAI;AACF,cAAM,0BAAsB;AAAA,UAC1B;AAAA,UACA,OAAO;AAAA,QACT;AACA,eAAO;AAAA,UACL,SAAS;AAAA,YACP;AAAA,cACE,MAAM;AAAA,cACN,MAAM,KAAK,UAAU,qBAAqB,MAAM,CAAC;AAAA,YACnD;AAAA,UACF;AAAA,QACF;AAAA,MACF,SAAS,OAAO;AACd,cAAM,eACJ,iBAAiB,QAAQ,MAAM,UAAU;AAC3C,eAAO;AAAA,UACL,SAAS;AAAA,YACP;AAAA,cACE,MAAM;AAAA,cACN,MAAM,wBAAwB,YAAY;AAAA,YAC5C;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["z"]}
|
|
1
|
+
{"version":3,"file":"cli.cjs","names":["loadCLITools: LoadCLITools","z","log: Partial<LogConfig>","Locales","fillOptions: any","pushOptions: any"],"sources":["../../../src/tools/cli.ts"],"sourcesContent":["import {\n build,\n fill,\n listContentDeclarationRows,\n listMissingTranslations,\n pull,\n push,\n} from '@intlayer/cli';\nimport { Locales, type LogConfig } from '@intlayer/types';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport z from 'zod/v3';\n\ntype LoadCLITools = (server: McpServer) => Promise<void>;\n\nexport const loadCLITools: LoadCLITools = async (server) => {\n server.tool(\n 'intlayer-build',\n 'Build the dictionaries. List all content declarations files `.content.{ts,tsx,js,json,...}` to update the content callable using the `useIntlayer` hook.',\n {\n watch: z.boolean().optional().describe('Watch for changes'),\n baseDir: z.string().optional().describe('Base directory'),\n env: z.string().optional().describe('Environment'),\n envFile: z.string().optional().describe('Environment file'),\n verbose: z.boolean().optional().describe('Verbose output'),\n prefix: z.string().optional().describe('Log prefix'),\n },\n async ({ watch, baseDir, env, envFile, verbose, prefix }) => {\n try {\n const log: Partial<LogConfig> = {};\n if (verbose) {\n log.mode = 'verbose';\n }\n if (prefix) {\n log.prefix = prefix;\n }\n\n await build({\n watch,\n configOptions: {\n baseDir,\n env,\n envFile,\n override: {\n log,\n },\n },\n });\n\n return {\n content: [\n {\n type: 'text',\n text: 'Build successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Build failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.tool(\n 'intlayer-fill',\n 'Fill the dictionaries with missing translations / review translations using Intlayer servers',\n {\n sourceLocale: z\n .nativeEnum(Locales.ALL_LOCALES)\n .optional()\n .describe('Source locale'),\n outputLocales: z\n .union([\n z.nativeEnum(Locales.ALL_LOCALES),\n z.array(z.nativeEnum(Locales.ALL_LOCALES)),\n ])\n .optional()\n .describe('Output locales'),\n file: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('File path'),\n mode: z.enum(['complete', 'review']).optional().describe('Fill mode'),\n keys: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Keys to include'),\n excludedKeys: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Keys to exclude'),\n pathFilter: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Path filter'),\n gitOptions: z\n .object({\n gitDiff: z.boolean().optional(),\n gitDiffBase: z.string().optional(),\n gitDiffCurrent: z.string().optional(),\n uncommitted: z.boolean().optional(),\n unpushed: z.boolean().optional(),\n untracked: z.boolean().optional(),\n })\n .optional()\n .describe('Git options'),\n aiOptions: z\n .object({\n provider: z.string().optional(),\n temperature: z.number().optional(),\n model: z.string().optional(),\n apiKey: z.string().optional(),\n customPrompt: z.string().optional(),\n applicationContext: z.string().optional(),\n })\n .optional()\n .describe('AI options'),\n },\n async (props) => {\n try {\n const { gitOptions, ...rest } = props;\n const fillOptions: any = { ...rest, gitOptions: undefined };\n\n if (gitOptions) {\n const { gitDiff, uncommitted, unpushed, untracked, ...restGit } =\n gitOptions;\n const mode = [];\n if (gitDiff) mode.push('gitDiff');\n if (uncommitted) mode.push('uncommitted');\n if (unpushed) mode.push('unpushed');\n if (untracked) mode.push('untracked');\n\n fillOptions.gitOptions = { ...restGit, mode };\n }\n\n await fill(fillOptions);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Fill successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Fill failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.tool(\n 'intlayer-push',\n 'Push local dictionaries to the server',\n {\n deleteLocaleDictionary: z\n .boolean()\n .optional()\n .describe('Delete local dictionary after push'),\n keepLocaleDictionary: z\n .boolean()\n .optional()\n .describe('Keep local dictionary after push'),\n dictionaries: z\n .array(z.string())\n .optional()\n .describe('List of dictionaries to push'),\n gitOptions: z\n .object({\n gitDiff: z.boolean().optional(),\n gitDiffBase: z.string().optional(),\n gitDiffCurrent: z.string().optional(),\n uncommitted: z.boolean().optional(),\n unpushed: z.boolean().optional(),\n untracked: z.boolean().optional(),\n })\n .optional()\n .describe('Git options'),\n },\n async (props) => {\n try {\n const { gitOptions, ...rest } = props;\n const pushOptions: any = { ...rest, gitOptions: undefined };\n\n if (gitOptions) {\n const { gitDiff, uncommitted, unpushed, untracked, ...restGit } =\n gitOptions;\n const mode = [];\n if (gitDiff) mode.push('gitDiff');\n if (uncommitted) mode.push('uncommitted');\n if (unpushed) mode.push('unpushed');\n if (untracked) mode.push('untracked');\n\n pushOptions.gitOptions = { ...restGit, mode };\n }\n\n await push(pushOptions);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Push successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Push failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.tool(\n 'intlayer-pull',\n 'Pull dictionaries from the CMS',\n {\n dictionaries: z\n .array(z.string())\n .optional()\n .describe('List of dictionaries to pull'),\n newDictionariesPath: z\n .string()\n .optional()\n .describe('Path to save new dictionaries'),\n },\n async (props) => {\n try {\n await pull(props);\n\n return {\n content: [\n {\n type: 'text',\n text: 'Pull successful.',\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Pull failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.tool(\n 'intlayer-content-list',\n 'List the content declaration (.content.{ts,tsx,js,json,...}) files present in the project. That files contain the multilingual content of the application and are used to build the dictionaries.',\n {\n configOptions: z\n .object({\n baseDir: z.string().optional(),\n env: z.string().optional(),\n envFile: z.string().optional(),\n override: z\n .object({\n log: z\n .object({\n prefix: z.string().optional(),\n verbose: z.boolean().optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional()\n .describe('Configuration options'),\n },\n async (props) => {\n try {\n const rows = listContentDeclarationRows(props);\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(rows, null, 2),\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Content list failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n\n server.tool(\n 'intlayer-content-test',\n 'Test if there are missing translations in the content declaration files. That files contain the multilingual content of the application and are used to build the dictionaries.',\n {\n configOptions: z\n .object({\n baseDir: z.string().optional(),\n env: z.string().optional(),\n envFile: z.string().optional(),\n override: z\n .object({\n log: z\n .object({\n prefix: z.string().optional(),\n verbose: z.boolean().optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional()\n .describe('Configuration options'),\n },\n async (props) => {\n try {\n const missingTranslations = listMissingTranslations(\n undefined,\n props?.configOptions\n );\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(missingTranslations, null, 2),\n },\n ],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'An unknown error occurred';\n return {\n content: [\n {\n type: 'text',\n text: `Content test failed: ${errorMessage}`,\n },\n ],\n };\n }\n }\n );\n};\n"],"mappings":";;;;;;;;;AAcA,MAAaA,eAA6B,OAAO,WAAW;AAC1D,QAAO,KACL,kBACA,4JACA;EACE,OAAOC,eAAE,SAAS,CAAC,UAAU,CAAC,SAAS,oBAAoB;EAC3D,SAASA,eAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,iBAAiB;EACzD,KAAKA,eAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,cAAc;EAClD,SAASA,eAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,mBAAmB;EAC3D,SAASA,eAAE,SAAS,CAAC,UAAU,CAAC,SAAS,iBAAiB;EAC1D,QAAQA,eAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,aAAa;EACrD,EACD,OAAO,EAAE,OAAO,SAAS,KAAK,SAAS,SAAS,aAAa;AAC3D,MAAI;GACF,MAAMC,MAA0B,EAAE;AAClC,OAAI,QACF,KAAI,OAA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