@dexto/core 1.13.0 → 1.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/DextoAgent.cjs +7 -0
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +7 -0
- package/dist/context/manager.cjs +34 -31
- package/dist/context/manager.d.ts +5 -6
- package/dist/context/manager.d.ts.map +1 -1
- package/dist/context/manager.js +36 -32
- package/dist/context/utils.cjs +6 -17
- package/dist/context/utils.d.ts +2 -0
- package/dist/context/utils.d.ts.map +1 -1
- package/dist/context/utils.js +5 -17
- package/dist/events/index.cjs +8 -0
- package/dist/events/index.d.ts +16 -5
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +8 -0
- package/dist/llm/executor/repeated-pruned-tool-calls.cjs +69 -0
- package/dist/llm/executor/repeated-pruned-tool-calls.d.ts +17 -0
- package/dist/llm/executor/repeated-pruned-tool-calls.d.ts.map +1 -0
- package/dist/llm/executor/repeated-pruned-tool-calls.js +46 -0
- package/dist/llm/executor/tool-output-spill.cjs +92 -0
- package/dist/llm/executor/tool-output-spill.d.ts +24 -0
- package/dist/llm/executor/tool-output-spill.d.ts.map +1 -0
- package/dist/llm/executor/tool-output-spill.js +65 -0
- package/dist/llm/executor/turn-executor.cjs +105 -15
- package/dist/llm/executor/turn-executor.d.ts +21 -4
- package/dist/llm/executor/turn-executor.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.js +111 -15
- package/dist/llm/services/factory.cjs +2 -1
- package/dist/llm/services/factory.d.ts +2 -1
- package/dist/llm/services/factory.d.ts.map +1 -1
- package/dist/llm/services/factory.js +2 -1
- package/dist/llm/services/vercel.cjs +2 -1
- package/dist/llm/services/vercel.d.ts +2 -1
- package/dist/llm/services/vercel.d.ts.map +1 -1
- package/dist/llm/services/vercel.js +2 -1
- package/dist/session/chat-session.cjs +1 -0
- package/dist/session/chat-session.d.ts +2 -0
- package/dist/session/chat-session.d.ts.map +1 -1
- package/dist/session/chat-session.js +1 -0
- package/dist/session/session-manager.cjs +16 -2
- package/dist/session/session-manager.d.ts +2 -0
- package/dist/session/session-manager.d.ts.map +1 -1
- package/dist/session/session-manager.js +16 -2
- package/dist/storage/index.cjs +2 -0
- package/dist/storage/index.d.ts +2 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +2 -0
- package/dist/storage/stores/backend.cjs +26 -0
- package/dist/storage/stores/backend.d.ts +20 -0
- package/dist/storage/stores/backend.d.ts.map +1 -1
- package/dist/storage/stores/backend.js +25 -0
- package/dist/storage/stores/in-memory.cjs +20 -3
- package/dist/storage/stores/in-memory.d.ts +16 -0
- package/dist/storage/stores/in-memory.d.ts.map +1 -1
- package/dist/storage/stores/in-memory.js +18 -2
- package/dist/storage/stores/types.d.ts +3 -0
- package/dist/storage/stores/types.d.ts.map +1 -1
- package/dist/storage/tool-executions/types.d.ts +2 -2
- package/dist/storage/tool-outputs/types.cjs +16 -0
- package/dist/storage/tool-outputs/types.d.ts +19 -0
- package/dist/storage/tool-outputs/types.d.ts.map +1 -0
- package/dist/storage/tool-outputs/types.js +0 -0
- package/dist/tools/activity.cjs +8 -0
- package/dist/tools/activity.d.ts +1 -0
- package/dist/tools/activity.d.ts.map +1 -1
- package/dist/tools/activity.js +8 -0
- package/dist/tools/tool-manager.cjs +39 -5
- package/dist/tools/tool-manager.d.ts +5 -0
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +39 -5
- package/dist/tools/tool-output-read.cjs +129 -0
- package/dist/tools/tool-output-read.d.ts +19 -0
- package/dist/tools/tool-output-read.d.ts.map +1 -0
- package/dist/tools/tool-output-read.js +106 -0
- package/dist/tools/types.d.ts +7 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/utils/service-initializer.cjs +4 -0
- package/dist/utils/service-initializer.d.ts +2 -0
- package/dist/utils/service-initializer.d.ts.map +1 -1
- package/dist/utils/service-initializer.js +4 -0
- package/package.json +2 -2
- package/dist/llm/executor/tool-output-truncator.cjs +0 -75
- package/dist/llm/executor/tool-output-truncator.d.ts +0 -27
- package/dist/llm/executor/tool-output-truncator.d.ts.map +0 -1
- package/dist/llm/executor/tool-output-truncator.js +0 -48
|
@@ -82,6 +82,8 @@ let _ToolManager = class _ToolManager {
|
|
|
82
82
|
}
|
|
83
83
|
mcpManager;
|
|
84
84
|
agentTools = /* @__PURE__ */ new Map();
|
|
85
|
+
/** Core-owned tools: always registered, never replaced by host tools or filtered per session. */
|
|
86
|
+
coreTools = [];
|
|
85
87
|
approvalManager;
|
|
86
88
|
allowedToolsProvider;
|
|
87
89
|
approvalMode;
|
|
@@ -145,9 +147,23 @@ let _ToolManager = class _ToolManager {
|
|
|
145
147
|
async initialize() {
|
|
146
148
|
this.logger.debug("ToolManager initialization complete");
|
|
147
149
|
}
|
|
150
|
+
registerCoreTools(tools) {
|
|
151
|
+
this.coreTools = tools;
|
|
152
|
+
for (const tool of tools) {
|
|
153
|
+
this.agentTools.set(tool.id, tool);
|
|
154
|
+
}
|
|
155
|
+
this.invalidateCache();
|
|
156
|
+
}
|
|
148
157
|
setTools(tools) {
|
|
149
158
|
this.agentTools.clear();
|
|
159
|
+
for (const tool of this.coreTools) {
|
|
160
|
+
this.agentTools.set(tool.id, tool);
|
|
161
|
+
}
|
|
150
162
|
for (const tool of tools) {
|
|
163
|
+
if (this.coreTools.some((coreTool) => coreTool.id === tool.id)) {
|
|
164
|
+
this.logger.warn(`Ignoring host tool '${tool.id}': the id belongs to a core tool`);
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
151
167
|
this.agentTools.set(tool.id, tool);
|
|
152
168
|
}
|
|
153
169
|
this.invalidateCache();
|
|
@@ -324,7 +340,12 @@ let _ToolManager = class _ToolManager {
|
|
|
324
340
|
* Filter a tool set based on disabled tools for a session.
|
|
325
341
|
*/
|
|
326
342
|
filterToolsForSession(toolSet, sessionId) {
|
|
327
|
-
|
|
343
|
+
const filtered = this.sessionToolPolicy.filterToolsForSession(toolSet, sessionId);
|
|
344
|
+
for (const tool of this.coreTools) {
|
|
345
|
+
const definition = toolSet[tool.id];
|
|
346
|
+
if (definition !== void 0) filtered[tool.id] = definition;
|
|
347
|
+
}
|
|
348
|
+
return filtered;
|
|
328
349
|
}
|
|
329
350
|
/**
|
|
330
351
|
* Check if a session has auto-approve tools set.
|
|
@@ -1191,11 +1212,18 @@ let _ToolManager = class _ToolManager {
|
|
|
1191
1212
|
`Tool execution already failed: ${executionId}`
|
|
1192
1213
|
);
|
|
1193
1214
|
}
|
|
1215
|
+
if (this.resumesRunningExecution(call, record.status)) {
|
|
1216
|
+
return void 0;
|
|
1217
|
+
}
|
|
1194
1218
|
throw ToolError.executionFailed(
|
|
1195
1219
|
call.toolName,
|
|
1196
1220
|
`Tool execution already ${record.status}: ${executionId}`
|
|
1197
1221
|
);
|
|
1198
1222
|
}
|
|
1223
|
+
/** A `resumable` local tool re-enters its own matching record that is still running. */
|
|
1224
|
+
resumesRunningExecution(call, status) {
|
|
1225
|
+
return status === "running" && call.identity.type === "local" && this.agentTools.get(call.identity.toolId)?.resumable === true;
|
|
1226
|
+
}
|
|
1199
1227
|
async recordDirectToolExecutionFailure(call, invocation, error) {
|
|
1200
1228
|
const identity = this.resolveToolExecutionIdentity(
|
|
1201
1229
|
invocation ?? {},
|
|
@@ -1340,10 +1368,16 @@ let _ToolManager = class _ToolManager {
|
|
|
1340
1368
|
}
|
|
1341
1369
|
return this.createFailedPreparedToolResult(call, started.record.error);
|
|
1342
1370
|
}
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1371
|
+
if (!this.resumesRunningExecution(call, started.record.status)) {
|
|
1372
|
+
throw ToolError.executionFailed(
|
|
1373
|
+
call.toolName,
|
|
1374
|
+
`Tool execution already ${started.record.status}: ${executionId}`
|
|
1375
|
+
);
|
|
1376
|
+
}
|
|
1377
|
+
this.logger.info("Resuming running prepared tool execution", {
|
|
1378
|
+
executionId,
|
|
1379
|
+
toolName: call.toolName
|
|
1380
|
+
});
|
|
1347
1381
|
}
|
|
1348
1382
|
}
|
|
1349
1383
|
const startTime = Date.now();
|
|
@@ -0,0 +1,129 @@
|
|
|
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 tool_output_read_exports = {};
|
|
20
|
+
__export(tool_output_read_exports, {
|
|
21
|
+
createToolOutputReadTool: () => createToolOutputReadTool
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(tool_output_read_exports);
|
|
24
|
+
var import_zod = require("zod");
|
|
25
|
+
var import_tool_output_spill = require("../llm/executor/tool-output-spill.js");
|
|
26
|
+
var import_activity = require("./activity.js");
|
|
27
|
+
var import_errors = require("./errors.js");
|
|
28
|
+
var import_define_tool = require("./define-tool.js");
|
|
29
|
+
var import_presentation = require("./presentation.js");
|
|
30
|
+
const MAX_READ_LINES = 2e3;
|
|
31
|
+
const MAX_READ_CHARS = 5e4;
|
|
32
|
+
const DEFAULT_MAX_MATCHES = 100;
|
|
33
|
+
const MAX_MATCHES = 500;
|
|
34
|
+
const MAX_MATCH_LINE_CHARS = 500;
|
|
35
|
+
const ToolOutputReadInputSchema = import_zod.z.object({
|
|
36
|
+
id: import_zod.z.string().min(1).describe("The tool call id named in a truncated or cleared tool result."),
|
|
37
|
+
offset: import_zod.z.number().int().min(1).optional().describe("1-based line to start reading from. Defaults to 1."),
|
|
38
|
+
charOffset: import_zod.z.number().int().min(0).optional().describe(
|
|
39
|
+
"0-based character to start from within the offset line, for lines too long to read at once."
|
|
40
|
+
),
|
|
41
|
+
limit: import_zod.z.number().int().min(1).max(MAX_READ_LINES).optional().describe(`Number of lines to read, up to ${MAX_READ_LINES}.`),
|
|
42
|
+
pattern: import_zod.z.string().min(1).optional().describe(
|
|
43
|
+
"Search instead of reading a range: returns lines containing this text (case-insensitive) with their line numbers."
|
|
44
|
+
),
|
|
45
|
+
maxMatches: import_zod.z.number().int().min(1).max(MAX_MATCHES).optional().describe(`Most matching lines to return with pattern, up to ${MAX_MATCHES}.`)
|
|
46
|
+
}).strict();
|
|
47
|
+
function createToolOutputReadTool(stores) {
|
|
48
|
+
return (0, import_define_tool.defineTool)({
|
|
49
|
+
id: import_tool_output_spill.TOOL_OUTPUT_READ_TOOL_NAME,
|
|
50
|
+
description: "Read a tool result that was truncated or cleared from this conversation, by the id named in its marker. Read a line range with offset and limit, or search it with pattern. Use this instead of re-running the tool.",
|
|
51
|
+
inputSchema: ToolOutputReadInputSchema,
|
|
52
|
+
needsApproval: false,
|
|
53
|
+
presentation: {
|
|
54
|
+
activity: import_activity.TOOL_ACTIVITY.readToolOutput,
|
|
55
|
+
describeHeader: (input) => (0, import_presentation.createLocalToolCallHeader)({
|
|
56
|
+
title: "Read earlier output",
|
|
57
|
+
argsText: input.pattern === void 0 ? input.id : `${input.id} "${input.pattern}"`
|
|
58
|
+
})
|
|
59
|
+
},
|
|
60
|
+
async execute(input, context) {
|
|
61
|
+
const sessionId = context.sessionId;
|
|
62
|
+
if (sessionId === void 0) {
|
|
63
|
+
throw import_errors.ToolError.executionFailed(import_tool_output_spill.TOOL_OUTPUT_READ_TOOL_NAME, "it needs a session");
|
|
64
|
+
}
|
|
65
|
+
const text = await loadToolOutput(stores, sessionId, input.id);
|
|
66
|
+
if (text === void 0) {
|
|
67
|
+
return `No stored output with id "${input.id}" in this conversation. It may have expired. Re-run the tool if it only reads data, or narrow the request.`;
|
|
68
|
+
}
|
|
69
|
+
return input.pattern === void 0 ? readLines(text, input) : searchLines(text, input.pattern, input.maxMatches ?? DEFAULT_MAX_MATCHES);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
async function loadToolOutput(stores, sessionId, toolCallId) {
|
|
74
|
+
const stored = await stores.toolOutputs.load({ sessionId, toolCallId });
|
|
75
|
+
if (stored !== void 0) return stored;
|
|
76
|
+
const messages = await stores.conversation.listMessages({ sessionId });
|
|
77
|
+
const message = messages.find(
|
|
78
|
+
(candidate) => candidate.role === "tool" && candidate.toolCallId === toolCallId
|
|
79
|
+
);
|
|
80
|
+
if (message?.role !== "tool") return void 0;
|
|
81
|
+
return message.content.flatMap((part) => part.type === "text" ? [part.text] : []).join("\n");
|
|
82
|
+
}
|
|
83
|
+
function readLines(text, input) {
|
|
84
|
+
const lines = text.split("\n");
|
|
85
|
+
const start = Math.min(input.offset ?? 1, lines.length);
|
|
86
|
+
const end = Math.min(start - 1 + (input.limit ?? MAX_READ_LINES), lines.length);
|
|
87
|
+
const selected = [];
|
|
88
|
+
let chars = 0;
|
|
89
|
+
for (let line = start; line <= end && chars < MAX_READ_CHARS; line += 1) {
|
|
90
|
+
const full = lines[line - 1] ?? "";
|
|
91
|
+
const from = line === start ? Math.min(input.charOffset ?? 0, full.length) : 0;
|
|
92
|
+
const piece = full.slice(from, from + MAX_READ_CHARS - chars);
|
|
93
|
+
selected.push(`${line}: ${piece}`);
|
|
94
|
+
chars += piece.length + 1;
|
|
95
|
+
if (from + piece.length < full.length) {
|
|
96
|
+
const next = from + piece.length;
|
|
97
|
+
return `${selected.join("\n")}
|
|
98
|
+
|
|
99
|
+
[Line ${line} continues (${full.length} characters). Use offset=${line} charOffset=${next} to continue.]`;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const last = start + selected.length - 1;
|
|
103
|
+
const hint = last < lines.length ? `Showing lines ${start}-${last} of ${lines.length}. Use offset=${last + 1} to continue.` : `Showing lines ${start}-${last} of ${lines.length}.`;
|
|
104
|
+
return `${selected.join("\n")}
|
|
105
|
+
|
|
106
|
+
[${hint}]`;
|
|
107
|
+
}
|
|
108
|
+
function searchLines(text, pattern, maxMatches) {
|
|
109
|
+
const needle = pattern.toLowerCase();
|
|
110
|
+
const lines = text.split("\n");
|
|
111
|
+
const found = [];
|
|
112
|
+
let total = 0;
|
|
113
|
+
lines.forEach((line, index) => {
|
|
114
|
+
if (!line.toLowerCase().includes(needle)) return;
|
|
115
|
+
total += 1;
|
|
116
|
+
if (found.length < maxMatches) {
|
|
117
|
+
found.push(`${index + 1}: ${line.slice(0, MAX_MATCH_LINE_CHARS)}`);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
if (total === 0) return `[No lines contain "${pattern}" in ${lines.length} lines.]`;
|
|
121
|
+
const shown = total > found.length ? `Showing ${found.length} of ${total} matching lines; raise maxMatches or narrow the pattern.` : `${total} matching lines of ${lines.length}.`;
|
|
122
|
+
return `${found.join("\n")}
|
|
123
|
+
|
|
124
|
+
[${shown} Read around a match with offset.]`;
|
|
125
|
+
}
|
|
126
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
127
|
+
0 && (module.exports = {
|
|
128
|
+
createToolOutputReadTool
|
|
129
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Core `tool_output_read`: pages through or searches a tool result stored for this session. */
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import type { ConversationStore } from '../storage/conversation/types.js';
|
|
4
|
+
import type { ToolOutputStore } from '../storage/tool-outputs/types.js';
|
|
5
|
+
import type { Tool } from './types.js';
|
|
6
|
+
declare const ToolOutputReadInputSchema: z.ZodObject<{
|
|
7
|
+
id: z.ZodString;
|
|
8
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
charOffset: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
12
|
+
maxMatches: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
}, z.core.$strict>;
|
|
14
|
+
export declare function createToolOutputReadTool(stores: {
|
|
15
|
+
conversation: ConversationStore;
|
|
16
|
+
toolOutputs: ToolOutputStore;
|
|
17
|
+
}): Tool<typeof ToolOutputReadInputSchema>;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=tool-output-read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-output-read.d.ts","sourceRoot":"","sources":["../../src/tools/tool-output-read.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAMxE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAQvC,QAAA,MAAM,yBAAyB;;;;;;;kBA0ClB,CAAC;AAId,wBAAgB,wBAAwB,CAAC,MAAM,EAAE;IAC7C,YAAY,EAAE,iBAAiB,CAAC;IAChC,WAAW,EAAE,eAAe,CAAC;CAChC,GAAG,IAAI,CAAC,OAAO,yBAAyB,CAAC,CAkCzC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import "../chunk-C6A6W6XS.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { TOOL_OUTPUT_READ_TOOL_NAME } from "../llm/executor/tool-output-spill.js";
|
|
4
|
+
import { TOOL_ACTIVITY } from "./activity.js";
|
|
5
|
+
import { ToolError } from "./errors.js";
|
|
6
|
+
import { defineTool } from "./define-tool.js";
|
|
7
|
+
import { createLocalToolCallHeader } from "./presentation.js";
|
|
8
|
+
const MAX_READ_LINES = 2e3;
|
|
9
|
+
const MAX_READ_CHARS = 5e4;
|
|
10
|
+
const DEFAULT_MAX_MATCHES = 100;
|
|
11
|
+
const MAX_MATCHES = 500;
|
|
12
|
+
const MAX_MATCH_LINE_CHARS = 500;
|
|
13
|
+
const ToolOutputReadInputSchema = z.object({
|
|
14
|
+
id: z.string().min(1).describe("The tool call id named in a truncated or cleared tool result."),
|
|
15
|
+
offset: z.number().int().min(1).optional().describe("1-based line to start reading from. Defaults to 1."),
|
|
16
|
+
charOffset: z.number().int().min(0).optional().describe(
|
|
17
|
+
"0-based character to start from within the offset line, for lines too long to read at once."
|
|
18
|
+
),
|
|
19
|
+
limit: z.number().int().min(1).max(MAX_READ_LINES).optional().describe(`Number of lines to read, up to ${MAX_READ_LINES}.`),
|
|
20
|
+
pattern: z.string().min(1).optional().describe(
|
|
21
|
+
"Search instead of reading a range: returns lines containing this text (case-insensitive) with their line numbers."
|
|
22
|
+
),
|
|
23
|
+
maxMatches: z.number().int().min(1).max(MAX_MATCHES).optional().describe(`Most matching lines to return with pattern, up to ${MAX_MATCHES}.`)
|
|
24
|
+
}).strict();
|
|
25
|
+
function createToolOutputReadTool(stores) {
|
|
26
|
+
return defineTool({
|
|
27
|
+
id: TOOL_OUTPUT_READ_TOOL_NAME,
|
|
28
|
+
description: "Read a tool result that was truncated or cleared from this conversation, by the id named in its marker. Read a line range with offset and limit, or search it with pattern. Use this instead of re-running the tool.",
|
|
29
|
+
inputSchema: ToolOutputReadInputSchema,
|
|
30
|
+
needsApproval: false,
|
|
31
|
+
presentation: {
|
|
32
|
+
activity: TOOL_ACTIVITY.readToolOutput,
|
|
33
|
+
describeHeader: (input) => createLocalToolCallHeader({
|
|
34
|
+
title: "Read earlier output",
|
|
35
|
+
argsText: input.pattern === void 0 ? input.id : `${input.id} "${input.pattern}"`
|
|
36
|
+
})
|
|
37
|
+
},
|
|
38
|
+
async execute(input, context) {
|
|
39
|
+
const sessionId = context.sessionId;
|
|
40
|
+
if (sessionId === void 0) {
|
|
41
|
+
throw ToolError.executionFailed(TOOL_OUTPUT_READ_TOOL_NAME, "it needs a session");
|
|
42
|
+
}
|
|
43
|
+
const text = await loadToolOutput(stores, sessionId, input.id);
|
|
44
|
+
if (text === void 0) {
|
|
45
|
+
return `No stored output with id "${input.id}" in this conversation. It may have expired. Re-run the tool if it only reads data, or narrow the request.`;
|
|
46
|
+
}
|
|
47
|
+
return input.pattern === void 0 ? readLines(text, input) : searchLines(text, input.pattern, input.maxMatches ?? DEFAULT_MAX_MATCHES);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async function loadToolOutput(stores, sessionId, toolCallId) {
|
|
52
|
+
const stored = await stores.toolOutputs.load({ sessionId, toolCallId });
|
|
53
|
+
if (stored !== void 0) return stored;
|
|
54
|
+
const messages = await stores.conversation.listMessages({ sessionId });
|
|
55
|
+
const message = messages.find(
|
|
56
|
+
(candidate) => candidate.role === "tool" && candidate.toolCallId === toolCallId
|
|
57
|
+
);
|
|
58
|
+
if (message?.role !== "tool") return void 0;
|
|
59
|
+
return message.content.flatMap((part) => part.type === "text" ? [part.text] : []).join("\n");
|
|
60
|
+
}
|
|
61
|
+
function readLines(text, input) {
|
|
62
|
+
const lines = text.split("\n");
|
|
63
|
+
const start = Math.min(input.offset ?? 1, lines.length);
|
|
64
|
+
const end = Math.min(start - 1 + (input.limit ?? MAX_READ_LINES), lines.length);
|
|
65
|
+
const selected = [];
|
|
66
|
+
let chars = 0;
|
|
67
|
+
for (let line = start; line <= end && chars < MAX_READ_CHARS; line += 1) {
|
|
68
|
+
const full = lines[line - 1] ?? "";
|
|
69
|
+
const from = line === start ? Math.min(input.charOffset ?? 0, full.length) : 0;
|
|
70
|
+
const piece = full.slice(from, from + MAX_READ_CHARS - chars);
|
|
71
|
+
selected.push(`${line}: ${piece}`);
|
|
72
|
+
chars += piece.length + 1;
|
|
73
|
+
if (from + piece.length < full.length) {
|
|
74
|
+
const next = from + piece.length;
|
|
75
|
+
return `${selected.join("\n")}
|
|
76
|
+
|
|
77
|
+
[Line ${line} continues (${full.length} characters). Use offset=${line} charOffset=${next} to continue.]`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const last = start + selected.length - 1;
|
|
81
|
+
const hint = last < lines.length ? `Showing lines ${start}-${last} of ${lines.length}. Use offset=${last + 1} to continue.` : `Showing lines ${start}-${last} of ${lines.length}.`;
|
|
82
|
+
return `${selected.join("\n")}
|
|
83
|
+
|
|
84
|
+
[${hint}]`;
|
|
85
|
+
}
|
|
86
|
+
function searchLines(text, pattern, maxMatches) {
|
|
87
|
+
const needle = pattern.toLowerCase();
|
|
88
|
+
const lines = text.split("\n");
|
|
89
|
+
const found = [];
|
|
90
|
+
let total = 0;
|
|
91
|
+
lines.forEach((line, index) => {
|
|
92
|
+
if (!line.toLowerCase().includes(needle)) return;
|
|
93
|
+
total += 1;
|
|
94
|
+
if (found.length < maxMatches) {
|
|
95
|
+
found.push(`${index + 1}: ${line.slice(0, MAX_MATCH_LINE_CHARS)}`);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
if (total === 0) return `[No lines contain "${pattern}" in ${lines.length} lines.]`;
|
|
99
|
+
const shown = total > found.length ? `Showing ${found.length} of ${total} matching lines; raise maxMatches or narrow the pattern.` : `${total} matching lines of ${lines.length}.`;
|
|
100
|
+
return `${found.join("\n")}
|
|
101
|
+
|
|
102
|
+
[${shown} Read around a match with offset.]`;
|
|
103
|
+
}
|
|
104
|
+
export {
|
|
105
|
+
createToolOutputReadTool
|
|
106
|
+
};
|
package/dist/tools/types.d.ts
CHANGED
|
@@ -164,6 +164,13 @@ export interface Tool<TSchema extends ZodTypeAny = ZodTypeAny> {
|
|
|
164
164
|
* by {@link ToolManager} when applying tool approval policy lists.
|
|
165
165
|
*/
|
|
166
166
|
aliases?: string[] | undefined;
|
|
167
|
+
/**
|
|
168
|
+
* Lets a host retry re-enter this tool's own durable execution record while it is still
|
|
169
|
+
* `running` with the same identity and input, instead of failing with "already running".
|
|
170
|
+
* Only for tools that reconcile their own partial progress (e.g. from a host-side journal);
|
|
171
|
+
* every other tool keeps the default, which never runs an in-flight execution twice.
|
|
172
|
+
*/
|
|
173
|
+
resumable?: boolean | undefined;
|
|
167
174
|
}
|
|
168
175
|
export type ToolApprovalDecision = boolean | string | null;
|
|
169
176
|
export type ToolNeedsApproval<TSchema extends ZodTypeAny = ZodTypeAny> = ToolApprovalDecision | ((input: z.output<TSchema>, context: ToolExecutionContext) => Promise<ToolApprovalDecision> | ToolApprovalDecision);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,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ACzB,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7B,QAAQ,CACJ,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE,IAAI,CAAC,wBAAwB,EAAE,WAAW,GAAG,YAAY,CAAC,GACrE,OAAO,CAAC,OAAO,CAAC,CAAC;CACvB"}
|
|
@@ -32,6 +32,7 @@ __export(service_initializer_exports, {
|
|
|
32
32
|
initializeAgentTelemetry: () => initializeAgentTelemetry
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(service_initializer_exports);
|
|
35
|
+
var import_in_memory = require("../storage/stores/in-memory.js");
|
|
35
36
|
var import_manager = require("../mcp/manager.js");
|
|
36
37
|
var import_tool_manager = require("../tools/tool-manager.js");
|
|
37
38
|
var import_manager2 = require("../systemPrompt/manager.js");
|
|
@@ -78,6 +79,7 @@ async function createAgentServices(config, logger, agentEventBus, overrides, com
|
|
|
78
79
|
const approvalStore = stores.getStore("approvals");
|
|
79
80
|
const sessionStore = stores.getStore("sessions");
|
|
80
81
|
const conversationStore = stores.getStore("conversation");
|
|
82
|
+
const toolOutputStore = stores.getStore("toolOutputs") ?? new import_in_memory.InMemoryToolOutputStore();
|
|
81
83
|
const sessionToolPreferencesStore = new import_session_tool_preferences_store.SessionToolPreferencesStore(
|
|
82
84
|
stores.getStore("toolPreferences"),
|
|
83
85
|
logger,
|
|
@@ -198,6 +200,7 @@ async function createAgentServices(config, logger, agentEventBus, overrides, com
|
|
|
198
200
|
agentEventBus,
|
|
199
201
|
sessionStore,
|
|
200
202
|
conversationStore,
|
|
203
|
+
toolOutputStore,
|
|
201
204
|
resourceManager,
|
|
202
205
|
// Add resource manager for blob storage
|
|
203
206
|
hookManager,
|
|
@@ -243,6 +246,7 @@ async function createAgentServices(config, logger, agentEventBus, overrides, com
|
|
|
243
246
|
workspaceManager,
|
|
244
247
|
searchService,
|
|
245
248
|
stores,
|
|
249
|
+
toolOutputStore,
|
|
246
250
|
resourceManager,
|
|
247
251
|
approvalManager,
|
|
248
252
|
memoryManager,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ToolOutputStore } from '../storage/tool-outputs/types.js';
|
|
1
2
|
import { MCPManager } from '../mcp/manager.js';
|
|
2
3
|
import { ToolManager } from '../tools/tool-manager.js';
|
|
3
4
|
import type { ToolPolicies } from '../tools/schemas.js';
|
|
@@ -36,6 +37,7 @@ export type AgentServices = {
|
|
|
36
37
|
workspaceManager: WorkspaceManager;
|
|
37
38
|
searchService: SearchService;
|
|
38
39
|
stores: DextoStores;
|
|
40
|
+
toolOutputStore: ToolOutputStore;
|
|
39
41
|
resourceManager: ResourceManager;
|
|
40
42
|
approvalManager: ApprovalManager;
|
|
41
43
|
memoryManager: MemoryManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-initializer.d.ts","sourceRoot":"","sources":["../../src/utils/service-initializer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"service-initializer.d.ts","sourceRoot":"","sources":["../../src/utils/service-initializer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AASxE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mDAAmD,CAAC;AAC9F,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,aAAa,EAA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,sBAAsB,GAAG,IAAI,CAAC;IACjF,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,KAAK,CAAC,EAAE,IAAI,EAAE,GAAG,SAAS,CAAC;IAC3B,uBAAuB,CAAC,EAAE,uBAAuB,GAAG,SAAS,CAAC;IAC9D,kBAAkB,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACpD,gBAAgB,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;CACtD,CAAC;AAEF,wBAAsB,wBAAwB,CAC1C,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,MAAM,EACd,kBAAkB,CAAC,EAAE,kBAAkB,GAAG,SAAS,GACpD,OAAO,CAAC,IAAI,CAAC,CAef;AAGD;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACrC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,aAAa,EAC5B,SAAS,CAAC,EAAE,yBAAyB,EACrC,kBAAkB,CAAC,EAAE,kBAAkB,GAAG,IAAI,GAAG,SAAS,EAC1D,WAAW,CAAC,EAAE,aAAa,GAAG,SAAS,GACxC,OAAO,CAAC,aAAa,CAAC,CA+OxB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "../chunk-C6A6W6XS.js";
|
|
2
|
+
import { InMemoryToolOutputStore } from "../storage/stores/in-memory.js";
|
|
2
3
|
import { MCPManager } from "../mcp/manager.js";
|
|
3
4
|
import { ToolManager } from "../tools/tool-manager.js";
|
|
4
5
|
import { SystemPromptManager } from "../systemPrompt/manager.js";
|
|
@@ -45,6 +46,7 @@ async function createAgentServices(config, logger, agentEventBus, overrides, com
|
|
|
45
46
|
const approvalStore = stores.getStore("approvals");
|
|
46
47
|
const sessionStore = stores.getStore("sessions");
|
|
47
48
|
const conversationStore = stores.getStore("conversation");
|
|
49
|
+
const toolOutputStore = stores.getStore("toolOutputs") ?? new InMemoryToolOutputStore();
|
|
48
50
|
const sessionToolPreferencesStore = new SessionToolPreferencesStore(
|
|
49
51
|
stores.getStore("toolPreferences"),
|
|
50
52
|
logger,
|
|
@@ -165,6 +167,7 @@ async function createAgentServices(config, logger, agentEventBus, overrides, com
|
|
|
165
167
|
agentEventBus,
|
|
166
168
|
sessionStore,
|
|
167
169
|
conversationStore,
|
|
170
|
+
toolOutputStore,
|
|
168
171
|
resourceManager,
|
|
169
172
|
// Add resource manager for blob storage
|
|
170
173
|
hookManager,
|
|
@@ -210,6 +213,7 @@ async function createAgentServices(config, logger, agentEventBus, overrides, com
|
|
|
210
213
|
workspaceManager,
|
|
211
214
|
searchService,
|
|
212
215
|
stores,
|
|
216
|
+
toolOutputStore,
|
|
213
217
|
resourceManager,
|
|
214
218
|
approvalManager,
|
|
215
219
|
memoryManager,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dexto/core",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -174,7 +174,7 @@
|
|
|
174
174
|
"nanoid": "^5.1.6",
|
|
175
175
|
"winston": "^3.17.0",
|
|
176
176
|
"yaml": "^2.8.3",
|
|
177
|
-
"@dexto/llm": "1.13.
|
|
177
|
+
"@dexto/llm": "1.13.2"
|
|
178
178
|
},
|
|
179
179
|
"devDependencies": {
|
|
180
180
|
"@opentelemetry/context-async-hooks": "^1.28.0",
|
|
@@ -1,75 +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 tool_output_truncator_exports = {};
|
|
20
|
-
__export(tool_output_truncator_exports, {
|
|
21
|
-
DEFAULT_MAX_FILE_LINES: () => DEFAULT_MAX_FILE_LINES,
|
|
22
|
-
DEFAULT_MAX_LINE_LENGTH: () => DEFAULT_MAX_LINE_LENGTH,
|
|
23
|
-
DEFAULT_MAX_TOOL_OUTPUT_CHARS: () => DEFAULT_MAX_TOOL_OUTPUT_CHARS,
|
|
24
|
-
truncateStringOutput: () => truncateStringOutput,
|
|
25
|
-
truncateToolResult: () => truncateToolResult
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(tool_output_truncator_exports);
|
|
28
|
-
const DEFAULT_MAX_TOOL_OUTPUT_CHARS = 12e4;
|
|
29
|
-
const DEFAULT_MAX_FILE_LINES = 2e3;
|
|
30
|
-
const DEFAULT_MAX_LINE_LENGTH = 2e3;
|
|
31
|
-
function truncateStringOutput(output, options = {}) {
|
|
32
|
-
const maxChars = options.maxChars ?? DEFAULT_MAX_TOOL_OUTPUT_CHARS;
|
|
33
|
-
if (output.length <= maxChars) {
|
|
34
|
-
return {
|
|
35
|
-
output,
|
|
36
|
-
truncated: false,
|
|
37
|
-
originalLength: output.length
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
const truncatedOutput = output.slice(0, maxChars) + `
|
|
41
|
-
|
|
42
|
-
[Output truncated - exceeded maximum length of ${maxChars} characters. Total length was ${output.length} characters.]`;
|
|
43
|
-
return {
|
|
44
|
-
output: truncatedOutput,
|
|
45
|
-
truncated: true,
|
|
46
|
-
originalLength: output.length
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
function truncateToolResult(result, options = {}) {
|
|
50
|
-
const newContent = result.content.map((part) => {
|
|
51
|
-
if (part.type === "text") {
|
|
52
|
-
const { output, truncated } = truncateStringOutput(part.text, options);
|
|
53
|
-
if (truncated) {
|
|
54
|
-
return { ...part, text: output };
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return part;
|
|
58
|
-
});
|
|
59
|
-
return {
|
|
60
|
-
...result,
|
|
61
|
-
content: newContent,
|
|
62
|
-
meta: {
|
|
63
|
-
...result.meta
|
|
64
|
-
// We could add a flag here if we wanted to track truncation in metadata
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
-
0 && (module.exports = {
|
|
70
|
-
DEFAULT_MAX_FILE_LINES,
|
|
71
|
-
DEFAULT_MAX_LINE_LENGTH,
|
|
72
|
-
DEFAULT_MAX_TOOL_OUTPUT_CHARS,
|
|
73
|
-
truncateStringOutput,
|
|
74
|
-
truncateToolResult
|
|
75
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { SanitizedToolResult } from '../../context/types.js';
|
|
2
|
-
export declare const DEFAULT_MAX_TOOL_OUTPUT_CHARS = 120000;
|
|
3
|
-
export declare const DEFAULT_MAX_FILE_LINES = 2000;
|
|
4
|
-
export declare const DEFAULT_MAX_LINE_LENGTH = 2000;
|
|
5
|
-
export interface TruncationOptions {
|
|
6
|
-
maxChars?: number;
|
|
7
|
-
}
|
|
8
|
-
export interface TruncationResult {
|
|
9
|
-
output: string;
|
|
10
|
-
truncated: boolean;
|
|
11
|
-
originalLength: number;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Truncates a string tool output to prevent context overflow.
|
|
15
|
-
* Appends a warning message if truncated.
|
|
16
|
-
*/
|
|
17
|
-
export declare function truncateStringOutput(output: string, options?: TruncationOptions): TruncationResult;
|
|
18
|
-
/**
|
|
19
|
-
* Truncates a SanitizedToolResult.
|
|
20
|
-
* Currently only truncates text parts.
|
|
21
|
-
*
|
|
22
|
-
* @param result The sanitized tool result to truncate
|
|
23
|
-
* @param options Truncation options
|
|
24
|
-
* @returns The truncated result
|
|
25
|
-
*/
|
|
26
|
-
export declare function truncateToolResult(result: SanitizedToolResult, options?: TruncationOptions): SanitizedToolResult;
|
|
27
|
-
//# sourceMappingURL=tool-output-truncator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-output-truncator.d.ts","sourceRoot":"","sources":["../../../src/llm/executor/tool-output-truncator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7D,eAAO,MAAM,6BAA6B,SAAU,CAAC;AACrD,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAC3C,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAE5C,MAAM,WAAW,iBAAiB;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAChC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,iBAAsB,GAChC,gBAAgB,CAoBlB;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAC9B,MAAM,EAAE,mBAAmB,EAC3B,OAAO,GAAE,iBAAsB,GAChC,mBAAmB,CAmBrB"}
|