@botbotgo/agent-harness 0.0.316 → 0.0.317
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export declare const AGENT_HARNESS_VERSION = "0.0.316";
|
package/dist/package-version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export const AGENT_HARNESS_VERSION = "0.0.316";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sanitizeVisibleText } from "../parsing/output-parsing.js";
|
|
2
|
-
import { computeIncrementalOutput, extractInterruptPayload, extractReasoningStreamOutput, extractStateStreamOutput, extractTerminalStreamOutput, extractToolResult, extractVisibleStreamOutput, normalizeTerminalOutputKey,
|
|
2
|
+
import { computeIncrementalOutput, extractInterruptPayload, extractReasoningStreamOutput, sanitizeRetainedUpstreamEvent, extractStateStreamOutput, extractTerminalStreamOutput, extractToolResult, extractVisibleStreamOutput, normalizeTerminalOutputKey, } from "../parsing/stream-event-parsing.js";
|
|
3
3
|
import { resolveModelFacingToolName } from "./tool/tool-name-mapping.js";
|
|
4
4
|
export function createStreamEventProjectionState() {
|
|
5
5
|
return {
|
|
@@ -13,7 +13,7 @@ export function projectRuntimeStreamEvent(params) {
|
|
|
13
13
|
const { event, allowVisibleStreamDeltas, includeStateStreamOutput, toolNameMapping, primaryTools, state, } = params;
|
|
14
14
|
const chunks = [{
|
|
15
15
|
kind: "upstream-event",
|
|
16
|
-
event:
|
|
16
|
+
event: sanitizeRetainedUpstreamEvent(event),
|
|
17
17
|
}];
|
|
18
18
|
const interruptPayload = extractInterruptPayload(event);
|
|
19
19
|
if (interruptPayload) {
|
|
@@ -24,6 +24,7 @@ export type RuntimeStreamChunk = {
|
|
|
24
24
|
step: RequestExecutionStep;
|
|
25
25
|
};
|
|
26
26
|
export declare function sanitizeStreamPayload(value: unknown): unknown;
|
|
27
|
+
export declare function sanitizeRetainedUpstreamEvent(event: unknown): unknown;
|
|
27
28
|
export declare function extractTerminalStreamOutput(event: unknown): string;
|
|
28
29
|
export declare function extractReasoningStreamOutput(event: unknown): string;
|
|
29
30
|
export declare function extractVisibleStreamOutput(event: unknown): string;
|
|
@@ -5,6 +5,17 @@ const STREAM_PREVIEW_TEXT_CHARS = 2_000;
|
|
|
5
5
|
const MAX_STREAM_OBJECT_KEYS = 64;
|
|
6
6
|
const MAX_STREAM_ARRAY_ITEMS = 64;
|
|
7
7
|
const MAX_STREAM_SANITIZE_DEPTH = 6;
|
|
8
|
+
const LARGE_CONTEXT_KEYS = new Set([
|
|
9
|
+
"input",
|
|
10
|
+
"inputs",
|
|
11
|
+
"messages",
|
|
12
|
+
"history",
|
|
13
|
+
"context",
|
|
14
|
+
"attachments",
|
|
15
|
+
"files",
|
|
16
|
+
"conversation",
|
|
17
|
+
"transcript",
|
|
18
|
+
]);
|
|
8
19
|
function truncatePreview(value, maxChars) {
|
|
9
20
|
if (value.length <= maxChars) {
|
|
10
21
|
return value;
|
|
@@ -75,6 +86,65 @@ function sanitizeStreamPayloadValue(value, depth) {
|
|
|
75
86
|
export function sanitizeStreamPayload(value) {
|
|
76
87
|
return sanitizeStreamPayloadValue(value, 0);
|
|
77
88
|
}
|
|
89
|
+
function summarizeOpaquePayload(value) {
|
|
90
|
+
if (value === null || value === undefined) {
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
93
|
+
if (typeof value === "string") {
|
|
94
|
+
return {
|
|
95
|
+
truncated: true,
|
|
96
|
+
reason: "omitted-large-context",
|
|
97
|
+
originalSizeChars: value.length,
|
|
98
|
+
preview: truncatePreview(value, STREAM_PREVIEW_TEXT_CHARS),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
let serialized = "";
|
|
102
|
+
try {
|
|
103
|
+
serialized = JSON.stringify(value);
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
serialized = String(value);
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
truncated: true,
|
|
110
|
+
reason: "omitted-large-context",
|
|
111
|
+
originalSizeChars: serialized.length,
|
|
112
|
+
preview: truncatePreview(serialized, STREAM_PREVIEW_TEXT_CHARS),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function sanitizeRetainedEventDataField(key, value) {
|
|
116
|
+
if (LARGE_CONTEXT_KEYS.has(key)) {
|
|
117
|
+
if (key === "input" && typeof value === "object" && value && !Array.isArray(value)) {
|
|
118
|
+
const typed = value;
|
|
119
|
+
const taskSubagentType = typeof typed.subagent_type === "string"
|
|
120
|
+
? typed.subagent_type
|
|
121
|
+
: typeof typed.subagentType === "string"
|
|
122
|
+
? typed.subagentType
|
|
123
|
+
: undefined;
|
|
124
|
+
if (taskSubagentType) {
|
|
125
|
+
return { subagent_type: taskSubagentType };
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return summarizeOpaquePayload(value);
|
|
129
|
+
}
|
|
130
|
+
return sanitizeStreamPayload(value);
|
|
131
|
+
}
|
|
132
|
+
export function sanitizeRetainedUpstreamEvent(event) {
|
|
133
|
+
if (typeof event !== "object" || !event || Array.isArray(event)) {
|
|
134
|
+
return sanitizeStreamPayload(event);
|
|
135
|
+
}
|
|
136
|
+
const typed = event;
|
|
137
|
+
const retained = {};
|
|
138
|
+
for (const [key, value] of Object.entries(typed)) {
|
|
139
|
+
if (key === "data" && typeof value === "object" && value && !Array.isArray(value)) {
|
|
140
|
+
const data = value;
|
|
141
|
+
retained.data = Object.fromEntries(Object.entries(data).map(([dataKey, dataValue]) => [dataKey, sanitizeRetainedEventDataField(dataKey, dataValue)]));
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
retained[key] = sanitizeStreamPayload(value);
|
|
145
|
+
}
|
|
146
|
+
return retained;
|
|
147
|
+
}
|
|
78
148
|
function parseMaybeJson(value) {
|
|
79
149
|
const trimmed = value.trim();
|
|
80
150
|
if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) {
|