@memberjunction/ai-agents 5.28.0 → 5.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AgentRunner.d.ts +39 -0
- package/dist/AgentRunner.d.ts.map +1 -1
- package/dist/AgentRunner.js +301 -6
- package/dist/AgentRunner.js.map +1 -1
- package/dist/ArtifactToolManager.d.ts +165 -0
- package/dist/ArtifactToolManager.d.ts.map +1 -0
- package/dist/ArtifactToolManager.js +534 -0
- package/dist/ArtifactToolManager.js.map +1 -0
- package/dist/agent-types/loop-agent-prompt-params.d.ts +14 -0
- package/dist/agent-types/loop-agent-prompt-params.d.ts.map +1 -1
- package/dist/agent-types/loop-agent-prompt-params.js +3 -1
- package/dist/agent-types/loop-agent-prompt-params.js.map +1 -1
- package/dist/agent-types/loop-agent-response-type.d.ts +9 -1
- package/dist/agent-types/loop-agent-response-type.d.ts.map +1 -1
- package/dist/agent-types/loop-agent-response-type.js.map +1 -1
- package/dist/agent-types/loop-agent-type.d.ts.map +1 -1
- package/dist/agent-types/loop-agent-type.js +3 -0
- package/dist/agent-types/loop-agent-type.js.map +1 -1
- package/dist/artifact-tools/DataSnapshotToolLibrary.d.ts +18 -0
- package/dist/artifact-tools/DataSnapshotToolLibrary.d.ts.map +1 -0
- package/dist/artifact-tools/DataSnapshotToolLibrary.js +365 -0
- package/dist/artifact-tools/DataSnapshotToolLibrary.js.map +1 -0
- package/dist/artifact-tools/DocxToolLibrary.d.ts +15 -0
- package/dist/artifact-tools/DocxToolLibrary.d.ts.map +1 -0
- package/dist/artifact-tools/DocxToolLibrary.js +160 -0
- package/dist/artifact-tools/DocxToolLibrary.js.map +1 -0
- package/dist/artifact-tools/ExcelToolLibrary.d.ts +16 -0
- package/dist/artifact-tools/ExcelToolLibrary.d.ts.map +1 -0
- package/dist/artifact-tools/ExcelToolLibrary.js +300 -0
- package/dist/artifact-tools/ExcelToolLibrary.js.map +1 -0
- package/dist/artifact-tools/JSONToolLibrary.d.ts +18 -0
- package/dist/artifact-tools/JSONToolLibrary.d.ts.map +1 -0
- package/dist/artifact-tools/JSONToolLibrary.js +178 -0
- package/dist/artifact-tools/JSONToolLibrary.js.map +1 -0
- package/dist/artifact-tools/PDFToolLibrary.d.ts +14 -0
- package/dist/artifact-tools/PDFToolLibrary.d.ts.map +1 -0
- package/dist/artifact-tools/PDFToolLibrary.js +172 -0
- package/dist/artifact-tools/PDFToolLibrary.js.map +1 -0
- package/dist/artifact-tools/TextToolLibrary.d.ts +12 -0
- package/dist/artifact-tools/TextToolLibrary.d.ts.map +1 -0
- package/dist/artifact-tools/TextToolLibrary.js +82 -0
- package/dist/artifact-tools/TextToolLibrary.js.map +1 -0
- package/dist/base-agent.d.ts +12 -0
- package/dist/base-agent.d.ts.map +1 -1
- package/dist/base-agent.js +155 -9
- package/dist/base-agent.js.map +1 -1
- package/dist/file-input-resolver.d.ts +2 -0
- package/dist/file-input-resolver.d.ts.map +1 -0
- package/dist/file-input-resolver.js +4 -0
- package/dist/file-input-resolver.js.map +1 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/memory-cleanup-agent.d.ts +10 -3
- package/dist/memory-cleanup-agent.d.ts.map +1 -1
- package/dist/memory-cleanup-agent.js +10 -3
- package/dist/memory-cleanup-agent.js.map +1 -1
- package/dist/memory-manager-agent.d.ts +341 -7
- package/dist/memory-manager-agent.d.ts.map +1 -1
- package/dist/memory-manager-agent.js +1723 -373
- package/dist/memory-manager-agent.js.map +1 -1
- package/package.json +18 -15
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
import { MJGlobal, UUIDsEqual } from '@memberjunction/global';
|
|
2
|
+
import { ArtifactMetadataEngine } from '@memberjunction/core-entities';
|
|
3
|
+
import { BaseArtifactToolLibrary } from '@memberjunction/ai-core-plus';
|
|
4
|
+
import { DataSnapshotToolLibrary } from './artifact-tools/DataSnapshotToolLibrary.js';
|
|
5
|
+
import { JSONToolLibrary } from './artifact-tools/JSONToolLibrary.js';
|
|
6
|
+
import { TextToolLibrary } from './artifact-tools/TextToolLibrary.js';
|
|
7
|
+
/**
|
|
8
|
+
* Merges tool libraries from an artifact type's inheritance chain.
|
|
9
|
+
*
|
|
10
|
+
* Given a chain ordered leaf-first (most-specific at index 0), tool lookups
|
|
11
|
+
* scan front-to-back, so a child type's tool with the same name as a parent
|
|
12
|
+
* type's tool wins. `GetToolList()` deduplicates by tool name.
|
|
13
|
+
*
|
|
14
|
+
* Used transparently by ArtifactToolManager — callers continue to see a
|
|
15
|
+
* single BaseArtifactToolLibrary.
|
|
16
|
+
*/
|
|
17
|
+
class CompositeArtifactToolLibrary extends BaseArtifactToolLibrary {
|
|
18
|
+
constructor(chain) {
|
|
19
|
+
super();
|
|
20
|
+
this.chain = chain;
|
|
21
|
+
}
|
|
22
|
+
GetToolList() {
|
|
23
|
+
const seen = new Set();
|
|
24
|
+
const merged = [];
|
|
25
|
+
for (const lib of this.chain) {
|
|
26
|
+
for (const tool of lib.GetToolList()) {
|
|
27
|
+
if (seen.has(tool.name))
|
|
28
|
+
continue;
|
|
29
|
+
seen.add(tool.name);
|
|
30
|
+
merged.push(tool);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return merged;
|
|
34
|
+
}
|
|
35
|
+
async InvokeTool(toolName, input, artifactContent) {
|
|
36
|
+
// Dispatch to the first library (leaf-first) that declares this tool.
|
|
37
|
+
for (const lib of this.chain) {
|
|
38
|
+
if (lib.GetToolList().some((t) => t.name === toolName)) {
|
|
39
|
+
return lib.InvokeTool(toolName, input, artifactContent);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
success: false,
|
|
44
|
+
data: null,
|
|
45
|
+
errorMessage: `Tool "${toolName}" is not defined by any library in this artifact type's chain.`,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Manages artifact tools for a single agent run.
|
|
51
|
+
*
|
|
52
|
+
* Follows the ScratchpadManager pattern:
|
|
53
|
+
* - Instantiated once per run
|
|
54
|
+
* - Holds references to input artifacts with alpha IDs
|
|
55
|
+
* - Generates manifest + tool documentation for prompt injection
|
|
56
|
+
* - Executes tool calls and stores results for next turn
|
|
57
|
+
* - Serializable for persistence
|
|
58
|
+
*/
|
|
59
|
+
export class ArtifactToolManager {
|
|
60
|
+
constructor() {
|
|
61
|
+
this.artifacts = new Map();
|
|
62
|
+
this.toolResults = [];
|
|
63
|
+
this.nextAlphaIndex = 0;
|
|
64
|
+
}
|
|
65
|
+
// ─── LIFECYCLE ───
|
|
66
|
+
/** Initialize with input artifacts, assigning alpha IDs */
|
|
67
|
+
Initialize(inputArtifacts) {
|
|
68
|
+
this.Clear();
|
|
69
|
+
for (const artifact of inputArtifacts) {
|
|
70
|
+
const alphaId = this.NextAlphaId();
|
|
71
|
+
this.artifacts.set(alphaId, {
|
|
72
|
+
alphaId,
|
|
73
|
+
name: artifact.name,
|
|
74
|
+
typeName: artifact.typeName,
|
|
75
|
+
mimeType: artifact.mimeType,
|
|
76
|
+
content: artifact.content,
|
|
77
|
+
library: this.ResolveLibrary(artifact.typeName, artifact.toolLibraryClass),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/** Register a mid-run artifact and return its alpha ID */
|
|
82
|
+
RegisterArtifact(artifact) {
|
|
83
|
+
const alphaId = this.NextAlphaId();
|
|
84
|
+
this.artifacts.set(alphaId, {
|
|
85
|
+
alphaId,
|
|
86
|
+
name: artifact.name,
|
|
87
|
+
typeName: artifact.typeName,
|
|
88
|
+
mimeType: artifact.mimeType,
|
|
89
|
+
content: artifact.content,
|
|
90
|
+
library: this.ResolveLibrary(artifact.typeName, artifact.toolLibraryClass),
|
|
91
|
+
});
|
|
92
|
+
return alphaId;
|
|
93
|
+
}
|
|
94
|
+
/** Reset all state */
|
|
95
|
+
Clear() {
|
|
96
|
+
this.artifacts.clear();
|
|
97
|
+
this.toolResults = [];
|
|
98
|
+
this.nextAlphaIndex = 0;
|
|
99
|
+
}
|
|
100
|
+
/** Whether any artifacts are available */
|
|
101
|
+
HasArtifacts() {
|
|
102
|
+
return this.artifacts.size > 0;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Returns artifact content formatted as NativeFileInput candidates for the
|
|
106
|
+
* AIPromptRunner. Only artifacts with a known MIME type and string/Buffer
|
|
107
|
+
* content are included. The runner will check each against the driver's
|
|
108
|
+
* FileCapabilities before actually attaching them.
|
|
109
|
+
*
|
|
110
|
+
* For each candidate, eagerly extracts text content so the Prompts package
|
|
111
|
+
* can fall back to a plain-text injection when the driver doesn't support
|
|
112
|
+
* native file input (e.g., Cerebras, older OpenAI-compat providers).
|
|
113
|
+
*/
|
|
114
|
+
async GetNativeFileInputCandidates() {
|
|
115
|
+
const candidates = [];
|
|
116
|
+
for (const entry of this.artifacts.values()) {
|
|
117
|
+
if (!entry.mimeType)
|
|
118
|
+
continue;
|
|
119
|
+
const contentBuffer = typeof entry.content === 'string'
|
|
120
|
+
? Buffer.from(entry.content)
|
|
121
|
+
: entry.content;
|
|
122
|
+
const base64 = contentBuffer.toString('base64');
|
|
123
|
+
const textContent = await this.extractTextFallback(entry.mimeType, contentBuffer, entry.content);
|
|
124
|
+
candidates.push({
|
|
125
|
+
Name: entry.name,
|
|
126
|
+
MimeType: entry.mimeType,
|
|
127
|
+
Base64Content: base64,
|
|
128
|
+
SizeBytes: contentBuffer.length,
|
|
129
|
+
...(textContent ? { TextContent: textContent } : {}),
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
return candidates;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Best-effort text extraction for fallback when the driver doesn't support
|
|
136
|
+
* native file input. Returns null if extraction fails or isn't applicable
|
|
137
|
+
* (e.g., images, audio).
|
|
138
|
+
*/
|
|
139
|
+
async extractTextFallback(mimeType, buffer, rawContent) {
|
|
140
|
+
const mime = mimeType.toLowerCase();
|
|
141
|
+
// Text-based content — decode directly
|
|
142
|
+
if (mime.startsWith('text/') || mime === 'application/json') {
|
|
143
|
+
return typeof rawContent === 'string' ? rawContent : buffer.toString('utf-8');
|
|
144
|
+
}
|
|
145
|
+
// PDF — use pdfjs-dist (already a dependency of this package)
|
|
146
|
+
if (mime === 'application/pdf') {
|
|
147
|
+
return this.extractPdfText(buffer);
|
|
148
|
+
}
|
|
149
|
+
// Office documents — not supported for text extraction yet
|
|
150
|
+
// (would need mammoth for docx, xlsx-parse for xlsx, etc.)
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
/** Extract all text from a PDF buffer using pdfjs-dist. Returns null on failure. */
|
|
154
|
+
async extractPdfText(buffer) {
|
|
155
|
+
try {
|
|
156
|
+
const pdfjsLib = await import('pdfjs-dist/legacy/build/pdf.mjs');
|
|
157
|
+
const pdfDoc = await pdfjsLib.getDocument({ data: new Uint8Array(buffer) }).promise;
|
|
158
|
+
try {
|
|
159
|
+
const pages = [];
|
|
160
|
+
for (let i = 1; i <= pdfDoc.numPages; i++) {
|
|
161
|
+
const page = await pdfDoc.getPage(i);
|
|
162
|
+
const tc = await page.getTextContent();
|
|
163
|
+
pages.push(tc.items.map((item) => item.str).join(' '));
|
|
164
|
+
}
|
|
165
|
+
return pages.join('\n\n');
|
|
166
|
+
}
|
|
167
|
+
finally {
|
|
168
|
+
pdfDoc.destroy();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// ─── PROMPT INJECTION ───
|
|
176
|
+
/** Markdown manifest: artifact IDs, names, types */
|
|
177
|
+
ToManifestString() {
|
|
178
|
+
if (this.artifacts.size === 0)
|
|
179
|
+
return '';
|
|
180
|
+
const lines = ['## Available Artifacts\n'];
|
|
181
|
+
for (const entry of this.artifacts.values()) {
|
|
182
|
+
const sizeSuffix = Buffer.isBuffer(entry.content)
|
|
183
|
+
? ` (${(entry.content.length / 1024).toFixed(0)} KB)`
|
|
184
|
+
: typeof entry.content === 'string' && entry.content.length > 0
|
|
185
|
+
? ` (${(entry.content.length / 1024).toFixed(0)} KB)`
|
|
186
|
+
: '';
|
|
187
|
+
const mimeNote = entry.mimeType ? ` [${entry.mimeType}]` : '';
|
|
188
|
+
lines.push(`**${entry.alphaId}** — ${entry.typeName}: "${entry.name}"${mimeNote}${sizeSuffix}`);
|
|
189
|
+
}
|
|
190
|
+
lines.push('');
|
|
191
|
+
lines.push('Use the artifact tools below to explore content.');
|
|
192
|
+
lines.push('IMPORTANT: Always use the single-letter artifact ID (A, B, C, etc.) as the `artifactId` value — NOT the artifact name.');
|
|
193
|
+
return lines.join('\n');
|
|
194
|
+
}
|
|
195
|
+
/** Markdown tool documentation grouped by artifact type */
|
|
196
|
+
GetToolDocumentation() {
|
|
197
|
+
if (this.artifacts.size === 0)
|
|
198
|
+
return '';
|
|
199
|
+
// Collect unique type → library pairs
|
|
200
|
+
const typeLibraries = new Map();
|
|
201
|
+
for (const entry of this.artifacts.values()) {
|
|
202
|
+
if (!typeLibraries.has(entry.typeName)) {
|
|
203
|
+
typeLibraries.set(entry.typeName, entry.library);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
const sections = [];
|
|
207
|
+
for (const [typeName, library] of typeLibraries) {
|
|
208
|
+
const tools = library.GetToolList();
|
|
209
|
+
if (tools.length === 0)
|
|
210
|
+
continue;
|
|
211
|
+
sections.push(`## ${typeName} Artifact Tools`);
|
|
212
|
+
for (const tool of tools) {
|
|
213
|
+
const params = Object.keys(tool.inputSchema.properties || {}).join(', ');
|
|
214
|
+
sections.push(`- **${tool.name}**(artifactId${params ? ', ' + params : ''}) — ${tool.description}`);
|
|
215
|
+
}
|
|
216
|
+
sections.push('');
|
|
217
|
+
}
|
|
218
|
+
return sections.join('\n');
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Max characters for the tool results section injected into the prompt.
|
|
222
|
+
* Prevents context overflow when tool results contain large datasets.
|
|
223
|
+
* Results are truncated from oldest first, with a summary of what was dropped.
|
|
224
|
+
*/
|
|
225
|
+
static { this.MAX_RESULTS_CHARS = 50_000; }
|
|
226
|
+
/**
|
|
227
|
+
* Max characters for a single tool result's data section.
|
|
228
|
+
* Individual results that exceed this are truncated with a note,
|
|
229
|
+
* preventing one huge result from consuming the entire budget.
|
|
230
|
+
*/
|
|
231
|
+
static { this.MAX_SINGLE_RESULT_CHARS = 15_000; }
|
|
232
|
+
/** Markdown results from previous turns */
|
|
233
|
+
GetPendingResults() {
|
|
234
|
+
if (this.toolResults.length === 0)
|
|
235
|
+
return '';
|
|
236
|
+
const header = [
|
|
237
|
+
'## Artifact Tool Results',
|
|
238
|
+
'',
|
|
239
|
+
'These are results from your previous artifact tool calls. **Use these results to answer the user — do NOT re-call the same tools.**',
|
|
240
|
+
'',
|
|
241
|
+
].join('\n');
|
|
242
|
+
// Render each result, capping individual results that are disproportionately large
|
|
243
|
+
const rendered = [];
|
|
244
|
+
for (let i = 0; i < this.toolResults.length; i++) {
|
|
245
|
+
const stored = this.toolResults[i];
|
|
246
|
+
const lines = [];
|
|
247
|
+
lines.push(`### Result ${i + 1}: ${stored.artifactId}.${stored.tool}(${JSON.stringify(stored.input)})`);
|
|
248
|
+
if (stored.result.success) {
|
|
249
|
+
let data = typeof stored.result.data === 'string' ? stored.result.data : JSON.stringify(stored.result.data, null, 2);
|
|
250
|
+
if (data.length > ArtifactToolManager.MAX_SINGLE_RESULT_CHARS) {
|
|
251
|
+
data =
|
|
252
|
+
data.slice(0, ArtifactToolManager.MAX_SINGLE_RESULT_CHARS) +
|
|
253
|
+
`\n... (truncated — ${data.length} chars total. Use more specific tool calls to narrow results.)`;
|
|
254
|
+
}
|
|
255
|
+
lines.push('```json');
|
|
256
|
+
lines.push(data);
|
|
257
|
+
lines.push('```');
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
lines.push(`**Error:** ${stored.result.errorMessage}`);
|
|
261
|
+
}
|
|
262
|
+
lines.push('');
|
|
263
|
+
rendered.push({ text: lines.join('\n'), index: i });
|
|
264
|
+
}
|
|
265
|
+
// Check total size and truncate oldest results if over limit
|
|
266
|
+
let totalChars = header.length;
|
|
267
|
+
const included = [];
|
|
268
|
+
let droppedCount = 0;
|
|
269
|
+
// Include results from newest to oldest so most recent are preserved
|
|
270
|
+
for (let i = rendered.length - 1; i >= 0; i--) {
|
|
271
|
+
if (totalChars + rendered[i].text.length > ArtifactToolManager.MAX_RESULTS_CHARS && included.length > 0) {
|
|
272
|
+
droppedCount = i + 1;
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
totalChars += rendered[i].text.length;
|
|
276
|
+
included.unshift(rendered[i].text);
|
|
277
|
+
}
|
|
278
|
+
const parts = [header];
|
|
279
|
+
if (droppedCount > 0) {
|
|
280
|
+
parts.push(`> **Note:** ${droppedCount} earlier result(s) truncated to fit context window. Use artifact tools to re-query if needed.\n`);
|
|
281
|
+
}
|
|
282
|
+
parts.push(...included);
|
|
283
|
+
return parts.join('\n');
|
|
284
|
+
}
|
|
285
|
+
/** One-line summary for compact contexts */
|
|
286
|
+
GetSummary() {
|
|
287
|
+
if (this.artifacts.size === 0)
|
|
288
|
+
return '';
|
|
289
|
+
const count = this.artifacts.size;
|
|
290
|
+
return `${count} artifact${count !== 1 ? 's' : ''} available (${Array.from(this.artifacts.values())
|
|
291
|
+
.map((a) => a.alphaId)
|
|
292
|
+
.join(', ')})`;
|
|
293
|
+
}
|
|
294
|
+
// ─── TOOL EXECUTION ───
|
|
295
|
+
/** Execute tool calls from LLM response */
|
|
296
|
+
async ExecuteToolCalls(calls) {
|
|
297
|
+
const promises = calls.map(async (call) => {
|
|
298
|
+
const startedAt = Date.now();
|
|
299
|
+
// Try exact alpha ID first, then fallback to name match
|
|
300
|
+
let entry = this.artifacts.get(call.artifactId);
|
|
301
|
+
if (!entry) {
|
|
302
|
+
// LLMs sometimes use the artifact name instead of the alpha ID
|
|
303
|
+
for (const e of this.artifacts.values()) {
|
|
304
|
+
if (e.name.toLowerCase() === call.artifactId.toLowerCase() || e.name.toLowerCase().replace(/\s+/g, '_') === call.artifactId.toLowerCase()) {
|
|
305
|
+
entry = e;
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (!entry && this.artifacts.size === 1) {
|
|
311
|
+
// If there's only one artifact, use it regardless of what ID was passed
|
|
312
|
+
entry = this.artifacts.values().next().value;
|
|
313
|
+
}
|
|
314
|
+
if (!entry) {
|
|
315
|
+
this.toolResults.push({
|
|
316
|
+
artifactId: call.artifactId,
|
|
317
|
+
tool: call.tool,
|
|
318
|
+
input: call.input,
|
|
319
|
+
result: {
|
|
320
|
+
success: false,
|
|
321
|
+
data: null,
|
|
322
|
+
errorMessage: `Unknown artifact ID: ${call.artifactId}. Use the alpha ID (A, B, C, etc.) from the manifest.`,
|
|
323
|
+
},
|
|
324
|
+
timestamp: new Date(),
|
|
325
|
+
durationMs: Date.now() - startedAt,
|
|
326
|
+
});
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
// Wrap InvokeTool so any exception inside a handler becomes a structured
|
|
330
|
+
// error result instead of propagating up to the agent loop. Without this,
|
|
331
|
+
// a single malformed artifact (e.g. a table missing `rows`) crashes the
|
|
332
|
+
// entire run via `executePromptStep`'s catch → isConfigurationError.
|
|
333
|
+
let result;
|
|
334
|
+
try {
|
|
335
|
+
result = await entry.library.InvokeTool(call.tool, call.input, entry.content);
|
|
336
|
+
}
|
|
337
|
+
catch (err) {
|
|
338
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
339
|
+
result = {
|
|
340
|
+
success: false,
|
|
341
|
+
data: null,
|
|
342
|
+
errorMessage: `Tool "${call.tool}" on artifact ${entry.alphaId} threw: ${msg}. The artifact content may be malformed for this tool — try a different tool or a different artifact.`,
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
this.toolResults.push({
|
|
346
|
+
artifactId: call.artifactId,
|
|
347
|
+
tool: call.tool,
|
|
348
|
+
input: call.input,
|
|
349
|
+
result,
|
|
350
|
+
timestamp: new Date(),
|
|
351
|
+
durationMs: Date.now() - startedAt,
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
await Promise.all(promises);
|
|
355
|
+
}
|
|
356
|
+
// ─── SERIALIZATION ───
|
|
357
|
+
/** Snapshot for persistence */
|
|
358
|
+
ToJSON() {
|
|
359
|
+
return {
|
|
360
|
+
artifacts: Array.from(this.artifacts.values()).map((a) => ({
|
|
361
|
+
alphaId: a.alphaId,
|
|
362
|
+
name: a.name,
|
|
363
|
+
typeName: a.typeName,
|
|
364
|
+
})),
|
|
365
|
+
resultCount: this.toolResults.length,
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
// ─── AUDIT ───
|
|
369
|
+
/**
|
|
370
|
+
* Access log for this run — one entry per tool invocation, in call order.
|
|
371
|
+
* Useful for audit trails, training data capture, and debugging.
|
|
372
|
+
* Projected from the internal result store (no parallel state).
|
|
373
|
+
*/
|
|
374
|
+
GetAccessLog() {
|
|
375
|
+
return this.toolResults.map((r) => ({
|
|
376
|
+
artifactId: r.artifactId,
|
|
377
|
+
tool: r.tool,
|
|
378
|
+
input: r.input,
|
|
379
|
+
success: r.result.success,
|
|
380
|
+
errorMessage: r.result.errorMessage,
|
|
381
|
+
timestamp: r.timestamp,
|
|
382
|
+
durationMs: r.durationMs,
|
|
383
|
+
}));
|
|
384
|
+
}
|
|
385
|
+
// ─── STATIC HELPERS ───
|
|
386
|
+
/**
|
|
387
|
+
* Determines whether artifact content should be externalized to MJStorage
|
|
388
|
+
* instead of being stored inline.
|
|
389
|
+
*/
|
|
390
|
+
static ShouldExternalizeContent(contentLength, options) {
|
|
391
|
+
const maxInlineChars = options?.maxInlineChars ?? 50_000;
|
|
392
|
+
if (contentLength <= maxInlineChars) {
|
|
393
|
+
return { shouldExternalize: false, reason: 'Content within inline limit' };
|
|
394
|
+
}
|
|
395
|
+
return {
|
|
396
|
+
shouldExternalize: true,
|
|
397
|
+
reason: 'Content exceeds ' + maxInlineChars + ' chars (' + contentLength + ' actual). Row data should be stored in MJStorage.',
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Builds a truncated inline preview of a tables-based content JSON by keeping
|
|
402
|
+
* only the first `maxRowsPerTable` rows per table and attaching truncation metadata.
|
|
403
|
+
*/
|
|
404
|
+
static BuildInlinePreview(contentJson, maxRowsPerTable = 30) {
|
|
405
|
+
let parsed;
|
|
406
|
+
try {
|
|
407
|
+
parsed = JSON.parse(contentJson);
|
|
408
|
+
}
|
|
409
|
+
catch {
|
|
410
|
+
return contentJson;
|
|
411
|
+
}
|
|
412
|
+
const tables = parsed['tables'];
|
|
413
|
+
if (!Array.isArray(tables)) {
|
|
414
|
+
return contentJson;
|
|
415
|
+
}
|
|
416
|
+
let modified = false;
|
|
417
|
+
for (const table of tables) {
|
|
418
|
+
const rows = table['rows'];
|
|
419
|
+
if (!Array.isArray(rows) || rows.length <= maxRowsPerTable) {
|
|
420
|
+
continue;
|
|
421
|
+
}
|
|
422
|
+
const tbl = table;
|
|
423
|
+
if (!tbl['metadata']) {
|
|
424
|
+
tbl['metadata'] = {};
|
|
425
|
+
}
|
|
426
|
+
const metadata = tbl['metadata'];
|
|
427
|
+
metadata['totalRowCount'] = rows.length;
|
|
428
|
+
metadata['truncatedForStorage'] = true;
|
|
429
|
+
tbl['rows'] = rows.slice(0, maxRowsPerTable);
|
|
430
|
+
modified = true;
|
|
431
|
+
}
|
|
432
|
+
return modified ? JSON.stringify(parsed) : contentJson;
|
|
433
|
+
}
|
|
434
|
+
// ─── PRIVATE ───
|
|
435
|
+
/** Generate next alpha-sequence ID: A, B, ... Z, AA, AB, ... */
|
|
436
|
+
NextAlphaId() {
|
|
437
|
+
const index = this.nextAlphaIndex++;
|
|
438
|
+
if (index < 26) {
|
|
439
|
+
return String.fromCharCode(65 + index); // A-Z
|
|
440
|
+
}
|
|
441
|
+
// AA, AB, AC, ...
|
|
442
|
+
const first = Math.floor((index - 26) / 26);
|
|
443
|
+
const second = (index - 26) % 26;
|
|
444
|
+
return String.fromCharCode(65 + first) + String.fromCharCode(65 + second);
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Resolve a tool library for an artifact type, walking the ParentID chain
|
|
448
|
+
* of `MJ: Artifact Types` to collect libraries from the leaf type and all
|
|
449
|
+
* ancestors. Child libraries override parent libraries for same-named tools.
|
|
450
|
+
*
|
|
451
|
+
* Resolution order:
|
|
452
|
+
* 1. If the metadata engine is loaded, walk `typeName → parent → ...` via
|
|
453
|
+
* `ArtifactMetadataEngine`, instantiating each level's `ToolLibraryClass`
|
|
454
|
+
* via ClassFactory. Returns a CompositeArtifactToolLibrary.
|
|
455
|
+
* 2. If the engine isn't loaded or the type isn't found, resolve the single
|
|
456
|
+
* leaf library using the `toolLibraryClass` hint plus name-based fallback.
|
|
457
|
+
*
|
|
458
|
+
* The engine is expected to be configured by AgentRunner before Initialize
|
|
459
|
+
* is called, so path (1) is the normal case.
|
|
460
|
+
*/
|
|
461
|
+
ResolveLibrary(typeName, toolLibraryClass) {
|
|
462
|
+
const chain = this.ResolveLibraryChain(typeName);
|
|
463
|
+
if (chain.length > 1)
|
|
464
|
+
return new CompositeArtifactToolLibrary(chain);
|
|
465
|
+
if (chain.length === 1)
|
|
466
|
+
return chain[0];
|
|
467
|
+
// Engine didn't yield anything — fall back to a single leaf library.
|
|
468
|
+
return this.ResolveLeafLibrary(typeName, toolLibraryClass);
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Walk the ParentID chain for `typeName` in ArtifactMetadataEngine,
|
|
472
|
+
* instantiating each level's ToolLibraryClass via ClassFactory.
|
|
473
|
+
* Returns the chain leaf-first. Levels without a ToolLibraryClass are
|
|
474
|
+
* skipped. Returns [] if the engine isn't loaded or the type isn't found.
|
|
475
|
+
*/
|
|
476
|
+
ResolveLibraryChain(typeName) {
|
|
477
|
+
const engine = ArtifactMetadataEngine.Instance;
|
|
478
|
+
if (!engine.ArtifactTypes?.length)
|
|
479
|
+
return [];
|
|
480
|
+
const chain = [];
|
|
481
|
+
const visited = new Set();
|
|
482
|
+
let current = engine.FindArtifactType(typeName);
|
|
483
|
+
while (current && !visited.has(current.ID)) {
|
|
484
|
+
visited.add(current.ID);
|
|
485
|
+
const className = current.ToolLibraryClass;
|
|
486
|
+
if (className) {
|
|
487
|
+
const lib = MJGlobal.Instance.ClassFactory.CreateInstance(BaseArtifactToolLibrary, className);
|
|
488
|
+
if (lib)
|
|
489
|
+
chain.push(lib);
|
|
490
|
+
}
|
|
491
|
+
current = current.ParentID
|
|
492
|
+
? engine.ArtifactTypes.find((t) => UUIDsEqual(t.ID, current.ParentID))
|
|
493
|
+
: undefined;
|
|
494
|
+
}
|
|
495
|
+
return chain;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Single-library fallback when the metadata engine isn't available.
|
|
499
|
+
* Uses the provided `toolLibraryClass` hint first, then name-based heuristics.
|
|
500
|
+
*/
|
|
501
|
+
ResolveLeafLibrary(typeName, toolLibraryClass) {
|
|
502
|
+
if (toolLibraryClass) {
|
|
503
|
+
const instance = MJGlobal.Instance.ClassFactory.CreateInstance(BaseArtifactToolLibrary, toolLibraryClass);
|
|
504
|
+
if (instance)
|
|
505
|
+
return instance;
|
|
506
|
+
}
|
|
507
|
+
const lower = typeName.toLowerCase();
|
|
508
|
+
if (lower.includes('data') || lower.includes('snapshot')) {
|
|
509
|
+
return new DataSnapshotToolLibrary();
|
|
510
|
+
}
|
|
511
|
+
if (lower.includes('json')) {
|
|
512
|
+
return new JSONToolLibrary();
|
|
513
|
+
}
|
|
514
|
+
// File-based types: try ClassFactory for dynamically registered libraries
|
|
515
|
+
// (PDFToolLibrary, ExcelToolLibrary, DocxToolLibrary are registered by CoreActions)
|
|
516
|
+
if (lower.includes('pdf')) {
|
|
517
|
+
const lib = MJGlobal.Instance.ClassFactory.CreateInstance(BaseArtifactToolLibrary, 'PDFToolLibrary');
|
|
518
|
+
if (lib)
|
|
519
|
+
return lib;
|
|
520
|
+
}
|
|
521
|
+
if (lower.includes('excel') || lower.includes('xlsx') || lower.includes('spreadsheet')) {
|
|
522
|
+
const lib = MJGlobal.Instance.ClassFactory.CreateInstance(BaseArtifactToolLibrary, 'ExcelToolLibrary');
|
|
523
|
+
if (lib)
|
|
524
|
+
return lib;
|
|
525
|
+
}
|
|
526
|
+
if (lower.includes('word') || lower.includes('docx') || lower.includes('document')) {
|
|
527
|
+
const lib = MJGlobal.Instance.ClassFactory.CreateInstance(BaseArtifactToolLibrary, 'DocxToolLibrary');
|
|
528
|
+
if (lib)
|
|
529
|
+
return lib;
|
|
530
|
+
}
|
|
531
|
+
return new TextToolLibrary();
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
//# sourceMappingURL=ArtifactToolManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArtifactToolManager.js","sourceRoot":"","sources":["../src/ArtifactToolManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAA+D,MAAM,8BAA8B,CAAC;AACpI,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAsCnE;;;;;;;;;GASG;AACH,MAAM,4BAA6B,SAAQ,uBAAuB;IAChE,YAA6B,KAAgC;QAC3D,KAAK,EAAE,CAAC;QADmB,UAAK,GAAL,KAAK,CAA2B;IAE7D,CAAC;IAED,WAAW;QACT,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;QAC/B,MA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G,GAAG,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,cAAc,CAA0B,uBAAuB,EAAE,iBAAiB,CAAC,CAAC;YAC/H,IAAI,GAAG;gBAAE,OAAO,GAAG,CAAC;QACtB,CAAC;QACD,OAAO,IAAI,eAAe,EAAE,CAAC;IAC/B,CAAC"}
|
|
@@ -73,6 +73,12 @@ export interface ResponseTypeInclusionRules {
|
|
|
73
73
|
* @default true
|
|
74
74
|
*/
|
|
75
75
|
scratchpad?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Include artifactToolCalls field in the response interface.
|
|
78
|
+
* Auto-aligns with includeArtifactToolsDocs unless explicitly set.
|
|
79
|
+
* @default true
|
|
80
|
+
*/
|
|
81
|
+
artifactToolCalls?: boolean;
|
|
76
82
|
}
|
|
77
83
|
/**
|
|
78
84
|
* Default values for ResponseTypeInclusionRules.
|
|
@@ -223,6 +229,14 @@ export interface LoopAgentTypePromptParams {
|
|
|
223
229
|
* @default 50
|
|
224
230
|
*/
|
|
225
231
|
scratchpadMaxTasks?: number;
|
|
232
|
+
/**
|
|
233
|
+
* Include artifact tools documentation and artifact manifest in the prompt.
|
|
234
|
+
* Artifact tools allow agents to explore input artifacts on demand.
|
|
235
|
+
* Only emitted when artifacts are present in the run.
|
|
236
|
+
* Disable for agents that never work with artifacts.
|
|
237
|
+
* @default true
|
|
238
|
+
*/
|
|
239
|
+
includeArtifactToolsDocs?: boolean;
|
|
226
240
|
/**
|
|
227
241
|
* Maximum number of sub-agents to include in prompt details.
|
|
228
242
|
* -1 = include all (default)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop-agent-prompt-params.d.ts","sourceRoot":"","sources":["../../src/agent-types/loop-agent-prompt-params.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,0BAA0B;IACvC;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"loop-agent-prompt-params.d.ts","sourceRoot":"","sources":["../../src/agent-types/loop-agent-prompt-params.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,0BAA0B;IACvC;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;GAGG;AACH,eAAO,MAAM,qCAAqC,EAAE,QAAQ,CAAC,0BAA0B,CAQtF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,MAAM,WAAW,yBAAyB;IAGtC;;;;;;;;;OASG;IACH,6BAA6B,CAAC,EAAE,0BAA0B,CAAC;IAE3D;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;;;;OAMG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAElC;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;;;;;;OAOG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;IAEtC;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAElC;;;;;;OAMG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC;;;;;;OAMG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAElC;;;;;OAKG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;;;;OAMG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAInC;;;;;;;OAOG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;;GAGG;AACH,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,yBAAyB,CAehF,CAAC"}
|
|
@@ -29,7 +29,8 @@ export const DEFAULT_RESPONSE_TYPE_INCLUSION_RULES = {
|
|
|
29
29
|
commands: true,
|
|
30
30
|
forEach: true,
|
|
31
31
|
while: true,
|
|
32
|
-
scratchpad: true
|
|
32
|
+
scratchpad: true,
|
|
33
|
+
artifactToolCalls: true
|
|
33
34
|
};
|
|
34
35
|
/**
|
|
35
36
|
* Default values for LoopAgentTypePromptParams.
|
|
@@ -47,6 +48,7 @@ export const DEFAULT_LOOP_AGENT_PROMPT_PARAMS = {
|
|
|
47
48
|
includeDateTimeInPrompt: true,
|
|
48
49
|
includeScratchpadDocs: true,
|
|
49
50
|
scratchpadMaxTasks: 50,
|
|
51
|
+
includeArtifactToolsDocs: true,
|
|
50
52
|
maxSubAgentsInPrompt: -1,
|
|
51
53
|
maxActionsInPrompt: -1
|
|
52
54
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop-agent-prompt-params.js","sourceRoot":"","sources":["../../src/agent-types/loop-agent-prompt-params.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;
|
|
1
|
+
{"version":3,"file":"loop-agent-prompt-params.js","sourceRoot":"","sources":["../../src/agent-types/loop-agent-prompt-params.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAwEH;;;GAGG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAyC;IACvF,OAAO,EAAE,IAAI;IACb,aAAa,EAAE,IAAI;IACnB,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,IAAI;IACX,UAAU,EAAE,IAAI;IAChB,iBAAiB,EAAE,IAAI;CAC1B,CAAC;AA+LF;;;GAGG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAwC;IACjF,6BAA6B,EAAE,EAAE,GAAG,qCAAqC,EAAE;IAC3E,kBAAkB,EAAE,IAAI;IACxB,gBAAgB,EAAE,IAAI;IACtB,uBAAuB,EAAE,IAAI;IAC7B,kBAAkB,EAAE,IAAI;IACxB,2BAA2B,EAAE,IAAI;IACjC,uBAAuB,EAAE,IAAI;IAC7B,sBAAsB,EAAE,IAAI;IAC5B,uBAAuB,EAAE,IAAI;IAC7B,qBAAqB,EAAE,IAAI;IAC3B,kBAAkB,EAAE,EAAE;IACtB,wBAAwB,EAAE,IAAI;IAC9B,oBAAoB,EAAE,CAAC,CAAC;IACxB,kBAAkB,EAAE,CAAC,CAAC;CACzB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AgentPayloadChangeRequest, ForEachOperation, WhileOperation, AgentResponseForm, ActionableCommand, AutomaticCommand, AgentScratchpad } from "@memberjunction/ai-core-plus";
|
|
2
|
-
|
|
2
|
+
import { ArtifactToolCall } from "../ArtifactToolManager.js";
|
|
3
|
+
export type { ForEachOperation, WhileOperation, ArtifactToolCall };
|
|
3
4
|
/**
|
|
4
5
|
* Response structure for Loop Agent Type
|
|
5
6
|
*/
|
|
@@ -41,6 +42,13 @@ export interface LoopAgentResponse<P = any> {
|
|
|
41
42
|
* @since 2.46.0
|
|
42
43
|
*/
|
|
43
44
|
scratchpad?: AgentScratchpad;
|
|
45
|
+
/**
|
|
46
|
+
* Artifact tool invocations — explore input artifacts without
|
|
47
|
+
* dumping full content into context. Processed inline on the same
|
|
48
|
+
* turn as other response fields (zero turn cost). Results are
|
|
49
|
+
* injected into the next turn's prompt via _ARTIFACT_TOOL_RESULTS.
|
|
50
|
+
*/
|
|
51
|
+
artifactToolCalls?: ArtifactToolCall[];
|
|
44
52
|
/**
|
|
45
53
|
* Internal reasoning for debugging
|
|
46
54
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop-agent-response-type.d.ts","sourceRoot":"","sources":["../../src/agent-types/loop-agent-response-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"loop-agent-response-type.d.ts","sourceRoot":"","sources":["../../src/agent-types/loop-agent-response-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpL,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,GAAG,GAAG;IACtC;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,YAA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