@dexto/core 1.12.1 → 1.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/DextoAgent.cjs +7 -0
- package/dist/agent/DextoAgent.d.ts +2 -5
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +7 -0
- package/dist/approval/index.cjs +4 -2
- package/dist/approval/index.d.ts +1 -1
- package/dist/approval/index.d.ts.map +1 -1
- package/dist/approval/index.js +3 -2
- package/dist/approval/manager.cjs +23 -4
- package/dist/approval/manager.d.ts +3 -2
- package/dist/approval/manager.d.ts.map +1 -1
- package/dist/approval/manager.js +21 -3
- package/dist/approval/schemas.cjs +5 -0
- package/dist/approval/schemas.d.ts +8 -0
- package/dist/approval/schemas.d.ts.map +1 -1
- package/dist/approval/schemas.js +5 -0
- package/dist/approval/types.d.ts +2 -2
- package/dist/approval/types.d.ts.map +1 -1
- 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 +18 -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 +116 -35
- package/dist/llm/executor/turn-executor.d.ts +21 -5
- package/dist/llm/executor/turn-executor.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.js +122 -35
- 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/mcp/errors.cjs +9 -0
- package/dist/mcp/errors.d.ts +4 -0
- package/dist/mcp/errors.d.ts.map +1 -1
- package/dist/mcp/errors.js +9 -0
- package/dist/mcp/manager.cjs +79 -3
- package/dist/mcp/manager.d.ts +14 -7
- package/dist/mcp/manager.d.ts.map +1 -1
- package/dist/mcp/manager.js +79 -3
- package/dist/mcp/mcp-client.cjs +52 -62
- package/dist/mcp/mcp-client.d.ts.map +1 -1
- package/dist/mcp/mcp-client.js +54 -63
- 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.cjs +12 -8
- package/dist/storage/tool-executions/types.d.ts +11 -2
- package/dist/storage/tool-executions/types.d.ts.map +1 -1
- package/dist/storage/tool-executions/types.js +12 -8
- 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/telemetry/decorators.cjs +47 -23
- package/dist/telemetry/decorators.d.ts +6 -0
- package/dist/telemetry/decorators.d.ts.map +1 -1
- package/dist/telemetry/decorators.js +47 -23
- package/dist/telemetry/operation-span.cjs +5 -2
- package/dist/telemetry/operation-span.d.ts +3 -0
- package/dist/telemetry/operation-span.d.ts.map +1 -1
- package/dist/telemetry/operation-span.js +5 -2
- 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/approval/tool-approval-policy.cjs +11 -1
- package/dist/tools/approval/tool-approval-policy.d.ts +2 -2
- package/dist/tools/approval/tool-approval-policy.d.ts.map +1 -1
- package/dist/tools/approval/tool-approval-policy.js +11 -1
- package/dist/tools/identity.cjs +36 -0
- package/dist/tools/identity.d.ts +6 -0
- package/dist/tools/identity.d.ts.map +1 -0
- package/dist/tools/identity.js +13 -0
- package/dist/tools/index.cjs +2 -0
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +4 -1
- package/dist/tools/presentation/tool-presentation.d.ts +5 -0
- package/dist/tools/presentation/tool-presentation.d.ts.map +1 -1
- package/dist/tools/schema-fingerprint.cjs +48 -0
- package/dist/tools/schema-fingerprint.d.ts +4 -0
- package/dist/tools/schema-fingerprint.d.ts.map +1 -0
- package/dist/tools/schema-fingerprint.js +25 -0
- package/dist/tools/schemas.cjs +3 -0
- package/dist/tools/schemas.d.ts +1 -0
- package/dist/tools/schemas.d.ts.map +1 -1
- package/dist/tools/schemas.js +2 -0
- package/dist/tools/tool-manager.cjs +199 -48
- package/dist/tools/tool-manager.d.ts +25 -11
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +199 -48
- 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 +55 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/utils/schema.cjs +2 -2
- package/dist/utils/schema.d.ts +1 -1
- package/dist/utils/schema.d.ts.map +1 -1
- package/dist/utils/schema.js +2 -2
- 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/dist/utils/stable-fingerprint.cjs +32 -0
- package/dist/utils/stable-fingerprint.d.ts +3 -0
- package/dist/utils/stable-fingerprint.d.ts.map +1 -0
- package/dist/utils/stable-fingerprint.js +9 -0
- package/package.json +9 -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
|
@@ -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
|
@@ -7,6 +7,7 @@ import type { WorkspaceContext } from '../workspace/types.js';
|
|
|
7
7
|
import type { ApprovalManager } from '../approval/manager.js';
|
|
8
8
|
import type { DextoAgent } from '../agent/DextoAgent.js';
|
|
9
9
|
import type { ToolStateStore } from '../storage/index.js';
|
|
10
|
+
import type { ToolExecutionIdentity } from '../storage/tool-executions/types.js';
|
|
10
11
|
import type { MCPManager } from '../mcp/manager.js';
|
|
11
12
|
import type { PromptManager } from '../prompts/prompt-manager.js';
|
|
12
13
|
import type { ResourceManager } from '../resources/manager.js';
|
|
@@ -16,6 +17,7 @@ import type { HostRuntimeContext } from '../runtime/index.js';
|
|
|
16
17
|
import type { AgentRunContext } from '../runtime/run-context.js';
|
|
17
18
|
import type { Skills } from '../skills/index.js';
|
|
18
19
|
import type { WorkspaceManager } from '../workspace/index.js';
|
|
20
|
+
import type { ToolAnnotations } from '@modelcontextprotocol/sdk/types.js';
|
|
19
21
|
/**
|
|
20
22
|
* Interface for forking execution to an isolated sub-agent context.
|
|
21
23
|
*
|
|
@@ -55,6 +57,8 @@ export interface ToolExecutionContextBase {
|
|
|
55
57
|
sessionId?: string | undefined;
|
|
56
58
|
/** Internal run-scoped execution context for this tool invocation */
|
|
57
59
|
runContext?: AgentRunContext | undefined;
|
|
60
|
+
/** Durable identity assigned to this concrete tool execution, when one exists. */
|
|
61
|
+
executionIdentity?: ToolExecutionIdentity | undefined;
|
|
58
62
|
/** Workspace ID if available */
|
|
59
63
|
workspaceId?: string | undefined;
|
|
60
64
|
/** Workspace context if available */
|
|
@@ -63,6 +67,8 @@ export interface ToolExecutionContextBase {
|
|
|
63
67
|
abortSignal?: AbortSignal | undefined;
|
|
64
68
|
/** Unique tool call ID for tracking parallel tool calls */
|
|
65
69
|
toolCallId?: string | undefined;
|
|
70
|
+
/** Outer tool call that owns this nested execution, when applicable. */
|
|
71
|
+
parentToolCallId?: string | undefined;
|
|
66
72
|
/** Host-owned runtime IDs for orchestration and correlation */
|
|
67
73
|
hostRuntime?: HostRuntimeContext | undefined;
|
|
68
74
|
/**
|
|
@@ -132,6 +138,8 @@ export interface Tool<TSchema extends ZodTypeAny = ZodTypeAny> {
|
|
|
132
138
|
getDescription?: ((context: ToolExecutionContext) => Promise<string> | string) | undefined;
|
|
133
139
|
/** Zod schema defining the input parameters */
|
|
134
140
|
inputSchema: TSchema;
|
|
141
|
+
/** Optional Zod schema describing a stable structured result. */
|
|
142
|
+
outputSchema?: ZodTypeAny | undefined;
|
|
135
143
|
/** The actual function that executes the tool - input is validated by Zod before execution */
|
|
136
144
|
execute(input: z.output<TSchema>, context: ToolExecutionContext): Promise<unknown> | unknown;
|
|
137
145
|
/**
|
|
@@ -156,6 +164,13 @@ export interface Tool<TSchema extends ZodTypeAny = ZodTypeAny> {
|
|
|
156
164
|
* by {@link ToolManager} when applying tool approval policy lists.
|
|
157
165
|
*/
|
|
158
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;
|
|
159
174
|
}
|
|
160
175
|
export type ToolApprovalDecision = boolean | string | null;
|
|
161
176
|
export type ToolNeedsApproval<TSchema extends ZodTypeAny = ZodTypeAny> = ToolApprovalDecision | ((input: z.output<TSchema>, context: ToolExecutionContext) => Promise<ToolApprovalDecision> | ToolApprovalDecision);
|
|
@@ -235,9 +250,49 @@ export interface ToolSet {
|
|
|
235
250
|
name?: string;
|
|
236
251
|
description?: string;
|
|
237
252
|
parameters: JSONSchema7;
|
|
253
|
+
outputSchema?: JSONSchema7;
|
|
254
|
+
annotations?: ToolAnnotations;
|
|
238
255
|
_meta?: Record<string, unknown>;
|
|
239
256
|
};
|
|
240
257
|
}
|
|
258
|
+
interface ToolDescriptorBase {
|
|
259
|
+
/** Name accepted by this ToolManager snapshot. */
|
|
260
|
+
name: string;
|
|
261
|
+
description: string;
|
|
262
|
+
inputSchema: JSONSchema7;
|
|
263
|
+
/** Absent when the provider cannot make a trustworthy result-shape guarantee. */
|
|
264
|
+
outputSchema?: JSONSchema7;
|
|
265
|
+
/** Stable fingerprint of the input/output contract for grant and replay validation. */
|
|
266
|
+
schemaFingerprint: string;
|
|
267
|
+
}
|
|
268
|
+
export type ToolIdentity = {
|
|
269
|
+
type: 'local';
|
|
270
|
+
toolId: string;
|
|
271
|
+
} | {
|
|
272
|
+
type: 'mcp';
|
|
273
|
+
/** Stable host connection identity; the Core/CLI implementation uses its config key. */
|
|
274
|
+
connectionId: string;
|
|
275
|
+
/** Name advertised by the upstream MCP server. */
|
|
276
|
+
toolName: string;
|
|
277
|
+
};
|
|
278
|
+
export interface LocalToolDescriptor extends ToolDescriptorBase {
|
|
279
|
+
/** Whether the current ToolManager policy may require approval after validating call input. */
|
|
280
|
+
approval: 'never' | 'possible';
|
|
281
|
+
identity: Extract<ToolIdentity, {
|
|
282
|
+
type: 'local';
|
|
283
|
+
}>;
|
|
284
|
+
}
|
|
285
|
+
export interface MCPToolDescriptor extends ToolDescriptorBase {
|
|
286
|
+
identity: Extract<ToolIdentity, {
|
|
287
|
+
type: 'mcp';
|
|
288
|
+
}>;
|
|
289
|
+
/** Untrusted MCP hints preserved for consumers; host policy must not treat them as authority. */
|
|
290
|
+
annotations?: ToolAnnotations;
|
|
291
|
+
}
|
|
292
|
+
export type ToolDescriptor = LocalToolDescriptor | (MCPToolDescriptor & {
|
|
293
|
+
/** Whether the current ToolManager policy may require approval after validating call input. */
|
|
294
|
+
approval: 'never' | 'possible';
|
|
295
|
+
});
|
|
241
296
|
/**
|
|
242
297
|
* Tool execution result
|
|
243
298
|
*/
|
|
@@ -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,EA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/F,QAAQ,EAAE,OAAO,GAAG,UAAU,CAAC;IAC/B,QAAQ,EAAE,OAAO,CAAC,YAAY,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACtD;AAED,MAAM,WAAW,iBAAkB,SAAQ,kBAAkB;IACzD,QAAQ,EAAE,OAAO,CAAC,YAAY,EAAE;QAAE,IAAI,EAAE,KAAK,CAAA;KAAE,CAAC,CAAC;IACjD,iGAAiG;IACjG,WAAW,CAAC,EAAE,eAAe,CAAC;CACjC;AAED,MAAM,MAAM,cAAc,GACpB,mBAAmB,GACnB,CAAC,iBAAiB,GAAG;IACjB,+FAA+F;IAC/F,QAAQ,EAAE,OAAO,GAAG,UAAU,CAAC;CAClC,CAAC,CAAC;AAMT;;GAEG;AACH,MAAM,WAAW,UAAU;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,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"}
|
package/dist/utils/schema.cjs
CHANGED
|
@@ -22,10 +22,10 @@ __export(schema_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(schema_exports);
|
|
24
24
|
var import_zod = require("zod");
|
|
25
|
-
function convertZodSchemaToJsonSchema(zodSchema, logger) {
|
|
25
|
+
function convertZodSchemaToJsonSchema(zodSchema, logger, io = "input") {
|
|
26
26
|
try {
|
|
27
27
|
const converted = import_zod.z.toJSONSchema(zodSchema, {
|
|
28
|
-
io
|
|
28
|
+
io,
|
|
29
29
|
target: "draft-07",
|
|
30
30
|
unrepresentable: "any"
|
|
31
31
|
});
|
package/dist/utils/schema.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ import type { Logger } from '../logger/v2/types.js';
|
|
|
5
5
|
* Convert Zod schema to JSON Schema format for tool parameters
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
export declare function convertZodSchemaToJsonSchema(zodSchema: z.ZodType, logger: Logger): JSONSchema7;
|
|
8
|
+
export declare function convertZodSchemaToJsonSchema(zodSchema: z.ZodType, logger: Logger, io?: 'input' | 'output'): JSONSchema7;
|
|
9
9
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/utils/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD;;;GAGG;AACH,wBAAgB,4BAA4B,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/utils/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD;;;GAGG;AACH,wBAAgB,4BAA4B,CACxC,SAAS,EAAE,CAAC,CAAC,OAAO,EACpB,MAAM,EAAE,MAAM,EACd,EAAE,GAAE,OAAO,GAAG,QAAkB,GACjC,WAAW,CAuBb"}
|
package/dist/utils/schema.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "../chunk-C6A6W6XS.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
function convertZodSchemaToJsonSchema(zodSchema, logger) {
|
|
3
|
+
function convertZodSchemaToJsonSchema(zodSchema, logger, io = "input") {
|
|
4
4
|
try {
|
|
5
5
|
const converted = z.toJSONSchema(zodSchema, {
|
|
6
|
-
io
|
|
6
|
+
io,
|
|
7
7
|
target: "draft-07",
|
|
8
8
|
unrepresentable: "any"
|
|
9
9
|
});
|
|
@@ -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,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAA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,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,
|
|
@@ -0,0 +1,32 @@
|
|
|
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 stable_fingerprint_exports = {};
|
|
20
|
+
__export(stable_fingerprint_exports, {
|
|
21
|
+
stableFingerprint: () => stableFingerprint
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(stable_fingerprint_exports);
|
|
24
|
+
var import_sha2 = require("@noble/hashes/sha2");
|
|
25
|
+
var import_utils = require("@noble/hashes/utils");
|
|
26
|
+
function stableFingerprint(value) {
|
|
27
|
+
return (0, import_utils.bytesToHex)((0, import_sha2.sha256)(value));
|
|
28
|
+
}
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
stableFingerprint
|
|
32
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stable-fingerprint.d.ts","sourceRoot":"","sources":["../../src/utils/stable-fingerprint.ts"],"names":[],"mappings":"AAGA,2FAA2F;AAC3F,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEvD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dexto/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -133,6 +133,11 @@
|
|
|
133
133
|
"import": "./dist/tools/index.js",
|
|
134
134
|
"require": "./dist/tools/index.cjs"
|
|
135
135
|
},
|
|
136
|
+
"./tools/identity": {
|
|
137
|
+
"types": "./dist/tools/identity.d.ts",
|
|
138
|
+
"import": "./dist/tools/identity.js",
|
|
139
|
+
"require": "./dist/tools/identity.cjs"
|
|
140
|
+
},
|
|
136
141
|
"./tools/presentation": {
|
|
137
142
|
"types": "./dist/tools/presentation.d.ts",
|
|
138
143
|
"import": "./dist/tools/presentation.js",
|
|
@@ -155,7 +160,9 @@
|
|
|
155
160
|
"@ai-sdk/openai-compatible": "^1.0.30",
|
|
156
161
|
"@ai-sdk/provider": "^2.0.0",
|
|
157
162
|
"@ai-sdk/xai": "^2.0.0",
|
|
163
|
+
"@cfworker/json-schema": "^4.1.1",
|
|
158
164
|
"@modelcontextprotocol/sdk": "^1.28.0",
|
|
165
|
+
"@noble/hashes": "^1.8.0",
|
|
159
166
|
"@openrouter/ai-sdk-provider": "^1.5.4",
|
|
160
167
|
"@opentelemetry/api": "^1.9.0",
|
|
161
168
|
"ai": "^5.0.0",
|
|
@@ -167,7 +174,7 @@
|
|
|
167
174
|
"nanoid": "^5.1.6",
|
|
168
175
|
"winston": "^3.17.0",
|
|
169
176
|
"yaml": "^2.8.3",
|
|
170
|
-
"@dexto/llm": "1.
|
|
177
|
+
"@dexto/llm": "1.13.1"
|
|
171
178
|
},
|
|
172
179
|
"devDependencies": {
|
|
173
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"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import "../../chunk-C6A6W6XS.js";
|
|
2
|
-
const DEFAULT_MAX_TOOL_OUTPUT_CHARS = 12e4;
|
|
3
|
-
const DEFAULT_MAX_FILE_LINES = 2e3;
|
|
4
|
-
const DEFAULT_MAX_LINE_LENGTH = 2e3;
|
|
5
|
-
function truncateStringOutput(output, options = {}) {
|
|
6
|
-
const maxChars = options.maxChars ?? DEFAULT_MAX_TOOL_OUTPUT_CHARS;
|
|
7
|
-
if (output.length <= maxChars) {
|
|
8
|
-
return {
|
|
9
|
-
output,
|
|
10
|
-
truncated: false,
|
|
11
|
-
originalLength: output.length
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
const truncatedOutput = output.slice(0, maxChars) + `
|
|
15
|
-
|
|
16
|
-
[Output truncated - exceeded maximum length of ${maxChars} characters. Total length was ${output.length} characters.]`;
|
|
17
|
-
return {
|
|
18
|
-
output: truncatedOutput,
|
|
19
|
-
truncated: true,
|
|
20
|
-
originalLength: output.length
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function truncateToolResult(result, options = {}) {
|
|
24
|
-
const newContent = result.content.map((part) => {
|
|
25
|
-
if (part.type === "text") {
|
|
26
|
-
const { output, truncated } = truncateStringOutput(part.text, options);
|
|
27
|
-
if (truncated) {
|
|
28
|
-
return { ...part, text: output };
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return part;
|
|
32
|
-
});
|
|
33
|
-
return {
|
|
34
|
-
...result,
|
|
35
|
-
content: newContent,
|
|
36
|
-
meta: {
|
|
37
|
-
...result.meta
|
|
38
|
-
// We could add a flag here if we wanted to track truncation in metadata
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
export {
|
|
43
|
-
DEFAULT_MAX_FILE_LINES,
|
|
44
|
-
DEFAULT_MAX_LINE_LENGTH,
|
|
45
|
-
DEFAULT_MAX_TOOL_OUTPUT_CHARS,
|
|
46
|
-
truncateStringOutput,
|
|
47
|
-
truncateToolResult
|
|
48
|
-
};
|