@dexto/core 1.2.5 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/agent/schemas.cjs +23 -19
  2. package/dist/agent/schemas.d.ts +111 -107
  3. package/dist/agent/schemas.d.ts.map +1 -1
  4. package/dist/agent/schemas.js +7 -3
  5. package/dist/memory/index.cjs +2 -0
  6. package/dist/memory/index.d.ts +1 -1
  7. package/dist/memory/index.d.ts.map +1 -1
  8. package/dist/memory/index.js +3 -1
  9. package/dist/memory/schemas.cjs +10 -0
  10. package/dist/memory/schemas.d.ts +33 -4
  11. package/dist/memory/schemas.d.ts.map +1 -1
  12. package/dist/memory/schemas.js +9 -0
  13. package/dist/prompts/index.cjs +6 -8
  14. package/dist/prompts/index.d.ts +2 -4
  15. package/dist/prompts/index.d.ts.map +1 -1
  16. package/dist/prompts/index.js +4 -6
  17. package/dist/prompts/prompt-manager.cjs +2 -4
  18. package/dist/prompts/prompt-manager.d.ts.map +1 -1
  19. package/dist/prompts/prompt-manager.js +2 -4
  20. package/dist/prompts/providers/config-prompt-provider.cjs +331 -0
  21. package/dist/prompts/providers/config-prompt-provider.d.ts +34 -0
  22. package/dist/prompts/providers/config-prompt-provider.d.ts.map +1 -0
  23. package/dist/prompts/providers/config-prompt-provider.js +308 -0
  24. package/dist/prompts/schemas.cjs +42 -23
  25. package/dist/prompts/schemas.d.ts +121 -12
  26. package/dist/prompts/schemas.d.ts.map +1 -1
  27. package/dist/prompts/schemas.js +39 -22
  28. package/dist/prompts/types.d.ts +1 -1
  29. package/dist/prompts/types.d.ts.map +1 -1
  30. package/dist/systemPrompt/in-built-prompts.cjs +0 -5
  31. package/dist/systemPrompt/in-built-prompts.d.ts +1 -2
  32. package/dist/systemPrompt/in-built-prompts.d.ts.map +1 -1
  33. package/dist/systemPrompt/in-built-prompts.js +0 -4
  34. package/dist/systemPrompt/manager.cjs +24 -19
  35. package/dist/systemPrompt/manager.d.ts +2 -2
  36. package/dist/systemPrompt/manager.d.ts.map +1 -1
  37. package/dist/systemPrompt/manager.js +24 -19
  38. package/dist/systemPrompt/registry.cjs +1 -2
  39. package/dist/systemPrompt/registry.d.ts +1 -1
  40. package/dist/systemPrompt/registry.d.ts.map +1 -1
  41. package/dist/systemPrompt/registry.js +1 -2
  42. package/dist/systemPrompt/schemas.cjs +3 -17
  43. package/dist/systemPrompt/schemas.d.ts +13 -189
  44. package/dist/systemPrompt/schemas.d.ts.map +1 -1
  45. package/dist/systemPrompt/schemas.js +3 -17
  46. package/dist/utils/service-initializer.cjs +1 -0
  47. package/dist/utils/service-initializer.d.ts.map +1 -1
  48. package/dist/utils/service-initializer.js +1 -0
  49. package/package.json +1 -1
  50. package/dist/prompts/providers/file-prompt-provider.cjs +0 -401
  51. package/dist/prompts/providers/file-prompt-provider.d.ts +0 -49
  52. package/dist/prompts/providers/file-prompt-provider.d.ts.map +0 -1
  53. package/dist/prompts/providers/file-prompt-provider.js +0 -378
  54. package/dist/prompts/providers/starter-prompt-provider.cjs +0 -172
  55. package/dist/prompts/providers/starter-prompt-provider.d.ts +0 -47
  56. package/dist/prompts/providers/starter-prompt-provider.d.ts.map +0 -1
  57. package/dist/prompts/providers/starter-prompt-provider.js +0 -149
@@ -161,6 +161,7 @@ async function createAgentServices(config, configPath, logger, agentEventBus) {
161
161
  config.systemPrompt,
162
162
  configDir,
163
163
  memoryManager,
164
+ config.memories,
164
165
  logger
165
166
  );
166
167
  const stateManager = new import_state_manager.AgentStateManager(config, agentEventBus, logger);
@@ -1 +1 @@
1
- {"version":3,"file":"service-initializer.d.ts","sourceRoot":"","sources":["../../src/utils/service-initializer.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,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,mBAAmB,CACrC,MAAM,EAAE,oBAAoB,EAC5B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,MAAM,EAAE,YAAY,EACpB,aAAa,EAAE,aAAa,GAC7B,OAAO,CAAC,aAAa,CAAC,CA+NxB"}
@@ -129,6 +129,7 @@ async function createAgentServices(config, configPath, logger, agentEventBus) {
129
129
  config.systemPrompt,
130
130
  configDir,
131
131
  memoryManager,
132
+ config.memories,
132
133
  logger
133
134
  );
134
135
  const stateManager = new AgentStateManager(config, agentEventBus, logger);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dexto/core",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,401 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var file_prompt_provider_exports = {};
20
- __export(file_prompt_provider_exports, {
21
- FilePromptProvider: () => FilePromptProvider
22
- });
23
- module.exports = __toCommonJS(file_prompt_provider_exports);
24
- var import_utils = require("../utils.js");
25
- var import_name_validation = require("../name-validation.js");
26
- var import_types = require("../../logger/v2/types.js");
27
- var import_errors = require("../errors.js");
28
- var import_promises = require("fs/promises");
29
- var import_path = require("path");
30
- var import_fs = require("fs");
31
- var import_os = require("os");
32
- var import_execution_context = require("../../utils/execution-context.js");
33
- class FilePromptProvider {
34
- // Multiple command directories (local project/repo and global user dir)
35
- commandDirs;
36
- resourceManager;
37
- promptsCache = [];
38
- cacheValid = false;
39
- promptResources = /* @__PURE__ */ new Map();
40
- inlineContent = /* @__PURE__ */ new Map();
41
- logger;
42
- constructor(options, logger) {
43
- this.logger = logger.createChild(import_types.DextoLogComponent.PROMPT);
44
- this.commandDirs = this.resolveDefaultCommandDirs();
45
- this.resourceManager = options.resourceManager;
46
- }
47
- getSource() {
48
- return "file";
49
- }
50
- invalidateCache() {
51
- this.cacheValid = false;
52
- this.promptsCache = [];
53
- this.promptResources.clear();
54
- this.inlineContent.clear();
55
- this.logger.debug("FilePromptProvider cache invalidated");
56
- }
57
- async getPrompt(name, args) {
58
- if (!this.cacheValid) {
59
- await this.buildPromptsCache();
60
- }
61
- const prompt = this.promptsCache.find((p) => p.name === name);
62
- if (!prompt) {
63
- throw import_errors.PromptError.notFound(name);
64
- }
65
- const resourceUri = this.promptResources.get(name);
66
- let text = this.inlineContent.get(name) ?? "";
67
- if (resourceUri) {
68
- try {
69
- const result = await this.resourceManager.read(resourceUri);
70
- const first = result.contents[0];
71
- if (first?.text && typeof first.text === "string") {
72
- text = first.text;
73
- } else if (first?.blob && typeof first.blob === "string") {
74
- text = Buffer.from(first.blob, "base64").toString("utf-8");
75
- } else {
76
- this.logger.warn(`Prompt ${name} resource ${resourceUri} did not contain text`);
77
- }
78
- } catch (error) {
79
- this.logger.warn(
80
- `Failed to load prompt resource ${resourceUri}: ${error instanceof Error ? error.message : String(error)}`
81
- );
82
- }
83
- }
84
- if (!text) {
85
- throw import_errors.PromptError.missingText();
86
- }
87
- const resolved = this.applyArguments(text, args);
88
- return {
89
- description: prompt.description,
90
- messages: [
91
- {
92
- role: "user",
93
- content: {
94
- type: "text",
95
- text: resolved
96
- }
97
- }
98
- ]
99
- };
100
- }
101
- async listPrompts(_cursor) {
102
- if (!this.cacheValid) {
103
- await this.buildPromptsCache();
104
- }
105
- return {
106
- prompts: this.promptsCache
107
- };
108
- }
109
- async getPromptDefinition(name) {
110
- if (!this.cacheValid) {
111
- await this.buildPromptsCache();
112
- }
113
- const promptInfo = this.promptsCache.find((p) => p.name === name);
114
- if (!promptInfo) {
115
- return null;
116
- }
117
- return {
118
- name: promptInfo.name,
119
- ...promptInfo.title && { title: promptInfo.title },
120
- ...promptInfo.description && { description: promptInfo.description },
121
- ...promptInfo.arguments && { arguments: promptInfo.arguments }
122
- };
123
- }
124
- async buildPromptsCache() {
125
- const cache = [];
126
- const resourceMap = /* @__PURE__ */ new Map();
127
- const inlineMap = /* @__PURE__ */ new Map();
128
- const seenNames = /* @__PURE__ */ new Set();
129
- const scannedDirs = [];
130
- for (const dir of this.commandDirs) {
131
- if (!(0, import_fs.existsSync)(dir)) {
132
- continue;
133
- }
134
- try {
135
- scannedDirs.push(dir);
136
- const files = await (0, import_promises.readdir)(dir);
137
- const markdownFiles = files.filter((file) => (0, import_path.extname)(file).toLowerCase() === ".md");
138
- for (const file of markdownFiles) {
139
- try {
140
- try {
141
- const candidate = (0, import_path.join)(dir, file);
142
- const resolvedDir = await (0, import_promises.realpath)(dir);
143
- const resolvedFile = await (0, import_promises.realpath)(candidate);
144
- const rel = (0, import_path.relative)(resolvedDir, resolvedFile);
145
- if (rel.startsWith(".." + import_path.sep) || rel === "..") {
146
- this.logger.warn(
147
- `Skipping file '${file}' in '${dir}': path traversal attempt detected (resolved outside directory)`
148
- );
149
- continue;
150
- }
151
- } catch (realpathError) {
152
- this.logger.warn(
153
- `Skipping file '${file}' in '${dir}': unable to resolve path (${realpathError instanceof Error ? realpathError.message : String(realpathError)})`
154
- );
155
- continue;
156
- }
157
- const parsed = await this.parsePromptFile(file, dir);
158
- if (seenNames.has(parsed.info.name)) {
159
- this.logger.debug(
160
- `Skipping duplicate prompt name '${parsed.info.name}' from ${(0, import_path.join)(
161
- dir,
162
- file
163
- )}`
164
- );
165
- continue;
166
- }
167
- const storage = await this.storePromptContent(parsed.content, file);
168
- if (storage.resourceUri) {
169
- resourceMap.set(parsed.info.name, storage.resourceUri);
170
- }
171
- if (storage.inlineContent) {
172
- inlineMap.set(parsed.info.name, storage.inlineContent);
173
- }
174
- if (storage.resourceUri || storage.inlineContent) {
175
- const metadata = {
176
- ...parsed.info.metadata ?? {},
177
- ...storage.resourceUri && { resourceUri: storage.resourceUri }
178
- // Security: Don't expose absolute sourceDir path
179
- // The relative filePath in parsed.info.metadata is sufficient
180
- };
181
- if (Object.keys(metadata).length > 0) {
182
- parsed.info = { ...parsed.info, metadata };
183
- } else {
184
- parsed.info = { ...parsed.info };
185
- delete parsed.info.metadata;
186
- }
187
- }
188
- cache.push(parsed.info);
189
- seenNames.add(parsed.info.name);
190
- } catch (error) {
191
- this.logger.warn(
192
- `Failed to process prompt file '${file}' in '${dir}': ${error instanceof Error ? error.message : String(error)}`
193
- );
194
- }
195
- }
196
- } catch (error) {
197
- this.logger.debug(
198
- `Commands directory '${dir}' not accessible: ${error instanceof Error ? error.message : String(error)}`
199
- );
200
- }
201
- }
202
- this.logger.debug(
203
- `\u{1F4DD} Cached ${cache.length} file prompts from directories: ${scannedDirs.join(", ")}`
204
- );
205
- this.promptsCache = cache;
206
- this.promptResources = resourceMap;
207
- this.inlineContent = inlineMap;
208
- this.cacheValid = true;
209
- }
210
- async parsePromptFile(fileName, baseDir) {
211
- const promptName = fileName.replace(/\.md$/, "");
212
- const filePath = (0, import_path.join)(baseDir, fileName);
213
- const content = await (0, import_promises.readFile)(filePath, "utf-8");
214
- const lines = content.trim().split("\n");
215
- let description = `File prompt: ${promptName}`;
216
- let title = promptName;
217
- let category;
218
- let id;
219
- let nameOverride;
220
- let argumentHint;
221
- let contentBody;
222
- if (lines[0]?.trim() === "---") {
223
- let inFrontmatter = false;
224
- let frontmatterEnd = 0;
225
- for (let i = 0; i < lines.length; i++) {
226
- if (lines[i]?.trim() === "---") {
227
- if (!inFrontmatter) {
228
- inFrontmatter = true;
229
- } else {
230
- frontmatterEnd = i;
231
- break;
232
- }
233
- }
234
- }
235
- if (frontmatterEnd > 0) {
236
- const frontmatterLines = lines.slice(1, frontmatterEnd);
237
- contentBody = lines.slice(frontmatterEnd + 1).join("\n");
238
- for (const line of frontmatterLines) {
239
- if (line.includes("description:")) {
240
- const descMatch = line.match(/description:\s*(?:['"](.+)['"]|(.+))/);
241
- if (descMatch) {
242
- description = (descMatch[1] || descMatch[2] || "").trim();
243
- }
244
- } else if (line.includes("id:")) {
245
- const idMatch = line.match(/id:\s*(?:['"](.+)['"]|(.+))/);
246
- if (idMatch) {
247
- id = (idMatch[1] || idMatch[2] || "").trim();
248
- }
249
- } else if (line.includes("name:")) {
250
- const nameMatch = line.match(/name:\s*(?:['"](.+)['"]|(.+))/);
251
- if (nameMatch) {
252
- nameOverride = (nameMatch[1] || nameMatch[2] || "").trim();
253
- }
254
- } else if (line.includes("category:")) {
255
- const categoryMatch = line.match(/category:\s*(?:['"](.+)['"]|(.+))/);
256
- if (categoryMatch) {
257
- category = (categoryMatch[1] || categoryMatch[2] || "").trim();
258
- }
259
- } else if (line.includes("argument-hint:")) {
260
- const hintMatch = line.match(/argument-hint:\s*(?:['"](.+)['"]|(.+))/);
261
- if (hintMatch) {
262
- argumentHint = (hintMatch[1] || hintMatch[2] || "").trim();
263
- }
264
- }
265
- }
266
- }
267
- }
268
- if (!contentBody) {
269
- contentBody = content;
270
- }
271
- const bodyLines = contentBody.trim().split("\n");
272
- for (const line of bodyLines) {
273
- if (line.trim().startsWith("#")) {
274
- title = line.trim().replace(/^#+\s*/, "");
275
- break;
276
- }
277
- }
278
- const finalName = (nameOverride ?? promptName).trim();
279
- (0, import_name_validation.assertValidPromptName)(finalName, {
280
- hint: "Use kebab-case in the 'name:' field or file name."
281
- });
282
- const parsedArguments = argumentHint ? this.parseArgumentHint(argumentHint) : void 0;
283
- const relativePath = (0, import_path.relative)(baseDir, filePath);
284
- const promptInfo = {
285
- name: finalName,
286
- title,
287
- description,
288
- source: "file",
289
- ...parsedArguments && { arguments: parsedArguments },
290
- metadata: {
291
- originalName: promptName,
292
- fileName,
293
- // Only include relative path within the commands directory (e.g., "my-command.md")
294
- // not the full path which could expose ~/.dexto or project structure
295
- ...relativePath && { filePath: relativePath },
296
- ...id && { id },
297
- ...category && { category }
298
- }
299
- };
300
- return { info: promptInfo, content: contentBody };
301
- }
302
- /**
303
- * Parse argument-hint string into structured argument definitions
304
- * Format: "[style] [length?]" → [{name: "style", required: true}, {name: "length", required: false}]
305
- */
306
- parseArgumentHint(hint) {
307
- const args = [];
308
- const argPattern = /\[([^\]]+)\]/g;
309
- let match;
310
- while ((match = argPattern.exec(hint)) !== null) {
311
- const argText = match[1];
312
- if (!argText) continue;
313
- const isOptional = argText.endsWith("?");
314
- const name = isOptional ? argText.slice(0, -1).trim() : argText.trim();
315
- if (name) {
316
- args.push({
317
- name,
318
- required: !isOptional
319
- });
320
- }
321
- }
322
- return args;
323
- }
324
- async storePromptContent(content, fileName) {
325
- const blobService = this.resourceManager.getBlobStore();
326
- if (!blobService) {
327
- this.logger.warn("BlobService not available; storing prompt content in memory");
328
- return { inlineContent: content };
329
- }
330
- const blobInput = Buffer.from(content, "utf-8");
331
- const blob = await blobService.store(blobInput, {
332
- mimeType: "text/markdown",
333
- originalName: fileName,
334
- source: "system"
335
- });
336
- return { resourceUri: blob.uri };
337
- }
338
- /**
339
- * Apply arguments to a file prompt's content.
340
- *
341
- * Behavior mirrors Claude Code-style file prompts:
342
- * - Positional placeholders ($1..$9 and $ARGUMENTS) are expanded first.
343
- * - If and only if the template contains explicit placeholders ($1..$9 or $ARGUMENTS),
344
- * then we consider arguments "deconstructed in-template" and DO NOT append them again.
345
- * - If the template contains no such placeholders, we append either:
346
- * - `Context: <_context>` above the content when `_context` is provided, or
347
- * - `Arguments: key: value, ...` below the content for plain named args.
348
- *
349
- * Notes:
350
- * - The `$$` sequence is an escape for a literal dollar sign. It MUST NOT be
351
- * treated as a placeholder indicator and should not suppress argument appending.
352
- */
353
- applyArguments(content, args) {
354
- const detectionTarget = content.replaceAll("$$", "");
355
- const usesPositionalPlaceholders = /\$[1-9](?!\d)/.test(detectionTarget) || detectionTarget.includes("$ARGUMENTS");
356
- const expanded = (0, import_utils.expandPlaceholders)(content, args).trim();
357
- if (!args || typeof args !== "object" || Object.keys(args).length === 0) {
358
- return expanded;
359
- }
360
- if (!usesPositionalPlaceholders) {
361
- if (args._context) {
362
- const contextString = String(args._context);
363
- return `${expanded}
364
-
365
- Context: ${contextString}`;
366
- }
367
- const argEntries = Object.entries(args).filter(([key]) => !key.startsWith("_"));
368
- if (argEntries.length > 0) {
369
- const formattedArgs = argEntries.map(([key, value]) => `${key}: ${value}`).join(", ");
370
- return `${expanded}
371
-
372
- Arguments: ${formattedArgs}`;
373
- }
374
- }
375
- return expanded;
376
- }
377
- // Determine default command/prompt directories based on execution context
378
- resolveDefaultCommandDirs() {
379
- const dirs = [];
380
- const sourceRoot = (0, import_execution_context.findDextoSourceRoot)();
381
- const projectRoot = (0, import_execution_context.findDextoProjectRoot)();
382
- const localRoot = sourceRoot ?? projectRoot ?? null;
383
- if (localRoot) {
384
- const commandsDir = (0, import_path.resolve)(localRoot, "commands");
385
- if ((0, import_fs.existsSync)(commandsDir)) dirs.push(commandsDir);
386
- }
387
- const globalCommands = (0, import_path.resolve)((0, import_os.homedir)(), ".dexto", "commands");
388
- if ((0, import_fs.existsSync)(globalCommands)) dirs.push(globalCommands);
389
- if (dirs.length === 0) {
390
- if (localRoot) {
391
- dirs.push((0, import_path.resolve)(localRoot, "commands"));
392
- }
393
- dirs.push(globalCommands);
394
- }
395
- return dirs;
396
- }
397
- }
398
- // Annotate the CommonJS export names for ESM import in node:
399
- 0 && (module.exports = {
400
- FilePromptProvider
401
- });
@@ -1,49 +0,0 @@
1
- import type { PromptProvider, PromptDefinition, PromptListResult } from '../types.js';
2
- import type { GetPromptResult } from '@modelcontextprotocol/sdk/types.js';
3
- import type { IDextoLogger } from '../../logger/v2/types.js';
4
- import type { ResourceManager } from '../../resources/manager.js';
5
- interface FilePromptProviderOptions {
6
- resourceManager: ResourceManager;
7
- }
8
- export declare class FilePromptProvider implements PromptProvider {
9
- private readonly commandDirs;
10
- private readonly resourceManager;
11
- private promptsCache;
12
- private cacheValid;
13
- private promptResources;
14
- private inlineContent;
15
- private logger;
16
- constructor(options: FilePromptProviderOptions, logger: IDextoLogger);
17
- getSource(): string;
18
- invalidateCache(): void;
19
- getPrompt(name: string, args?: Record<string, unknown>): Promise<GetPromptResult>;
20
- listPrompts(_cursor?: string): Promise<PromptListResult>;
21
- getPromptDefinition(name: string): Promise<PromptDefinition | null>;
22
- private buildPromptsCache;
23
- private parsePromptFile;
24
- /**
25
- * Parse argument-hint string into structured argument definitions
26
- * Format: "[style] [length?]" → [{name: "style", required: true}, {name: "length", required: false}]
27
- */
28
- private parseArgumentHint;
29
- private storePromptContent;
30
- /**
31
- * Apply arguments to a file prompt's content.
32
- *
33
- * Behavior mirrors Claude Code-style file prompts:
34
- * - Positional placeholders ($1..$9 and $ARGUMENTS) are expanded first.
35
- * - If and only if the template contains explicit placeholders ($1..$9 or $ARGUMENTS),
36
- * then we consider arguments "deconstructed in-template" and DO NOT append them again.
37
- * - If the template contains no such placeholders, we append either:
38
- * - `Context: <_context>` above the content when `_context` is provided, or
39
- * - `Arguments: key: value, ...` below the content for plain named args.
40
- *
41
- * Notes:
42
- * - The `$$` sequence is an escape for a literal dollar sign. It MUST NOT be
43
- * treated as a placeholder indicator and should not suppress argument appending.
44
- */
45
- private applyArguments;
46
- private resolveDefaultCommandDirs;
47
- }
48
- export {};
49
- //# sourceMappingURL=file-prompt-provider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-prompt-provider.d.ts","sourceRoot":"","sources":["../../../src/prompts/providers/file-prompt-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAc,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG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