@botbotgo/agent-harness 0.0.327 → 0.0.328
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/cli/main.js +30 -3
- package/dist/contracts/runtime-requests.d.ts +1 -2
- package/dist/contracts/runtime-scheduling.d.ts +1 -1
- package/dist/flow/flow-graph-upstream.js +3 -7
- package/dist/package-version.d.ts +1 -1
- package/dist/package-version.js +1 -1
- package/dist/projections/request-events.js +0 -1
- package/dist/resource/isolation.js +51 -10
- package/dist/resources/toolkit.mjs +183 -0
- package/dist/resources/tools/cancel_request.mjs +1 -1
- package/dist/resources/tools/fetch_url.mjs +1 -1
- package/dist/resources/tools/http_request.mjs +1 -1
- package/dist/resources/tools/inspect_approvals.mjs +1 -1
- package/dist/resources/tools/inspect_artifacts.mjs +1 -1
- package/dist/resources/tools/inspect_events.mjs +1 -1
- package/dist/resources/tools/inspect_requests.mjs +1 -1
- package/dist/resources/tools/inspect_sessions.mjs +1 -1
- package/dist/resources/tools/list_files.mjs +1 -1
- package/dist/resources/tools/read_artifact.mjs +1 -1
- package/dist/resources/tools/request_approval.mjs +1 -1
- package/dist/resources/tools/run_command.mjs +1 -1
- package/dist/resources/tools/schedule_task.mjs +1 -1
- package/dist/resources/tools/search_files.mjs +1 -1
- package/dist/resources/tools/send_message.mjs +1 -1
- package/dist/runtime/adapter/compat/deepagent-compat.d.ts +0 -9
- package/dist/runtime/adapter/compat/deepagent-compat.js +0 -22
- package/dist/runtime/adapter/flow/stream-runtime.d.ts +4 -0
- package/dist/runtime/adapter/flow/stream-runtime.js +239 -8
- package/dist/runtime/adapter/local-tool-invocation.js +53 -0
- package/dist/runtime/adapter/middleware-assembly.js +174 -29
- package/dist/runtime/adapter/runtime-adapter-support.js +1 -2
- package/dist/runtime/adapter/stream-event-projection.d.ts +17 -0
- package/dist/runtime/adapter/stream-event-projection.js +217 -4
- package/dist/runtime/adapter/tool/builtin-middleware-tools.d.ts +0 -3
- package/dist/runtime/adapter/tool/builtin-middleware-tools.js +37 -17
- package/dist/runtime/adapter/tool/resolved-tool.js +29 -3
- package/dist/runtime/agent-runtime-adapter.d.ts +3 -3
- package/dist/runtime/agent-runtime-adapter.js +12 -33
- package/dist/runtime/agent-runtime-assembly.d.ts +3 -21
- package/dist/runtime/agent-runtime-assembly.js +4 -56
- package/dist/runtime/harness/run/inspection.js +21 -5
- package/dist/runtime/harness/run/run-operations.js +2 -1
- package/dist/runtime/harness/run/stream-run.d.ts +3 -1
- package/dist/runtime/harness/run/stream-run.js +205 -29
- package/dist/runtime/harness.js +3 -0
- package/dist/runtime/parsing/output-content.js +11 -4
- package/dist/runtime/parsing/output-recovery.d.ts +3 -0
- package/dist/runtime/parsing/output-recovery.js +57 -11
- package/dist/runtime/parsing/output-tool-args.d.ts +4 -0
- package/dist/runtime/parsing/output-tool-args.js +122 -0
- package/dist/runtime/parsing/stream-event-parsing.js +37 -3
- package/dist/runtime/support/harness-support.d.ts +1 -0
- package/dist/runtime/support/harness-support.js +44 -2
- package/dist/tools.js +34 -4
- package/package.json +8 -8
|
@@ -1,5 +1,38 @@
|
|
|
1
|
-
import { EXECUTION_WITH_TOOL_EVIDENCE_RETRY_INSTRUCTION, INTERNAL_RUNTIME_SPILL_PATH_INSTRUCTION, STRICT_TOOL_JSON_INSTRUCTION, WORKSPACE_RELATIVE_PATH_INSTRUCTION, WRITE_TODOS_DESCRIPTIVE_CONTENT_INSTRUCTION, WRITE_TODOS_FULL_ENTRY_INSTRUCTION, WRITE_TODOS_NON_EMPTY_INITIAL_LIST_INSTRUCTION, } from "../prompts/runtime-prompts.js";
|
|
1
|
+
import { AUTONOMOUS_INVESTIGATION_RECOVERY_INSTRUCTION, EXECUTION_WITH_TOOL_EVIDENCE_RETRY_INSTRUCTION, INTERNAL_RUNTIME_SPILL_PATH_INSTRUCTION, STRICT_TOOL_JSON_INSTRUCTION, WORKSPACE_RELATIVE_PATH_INSTRUCTION, WRITE_TODOS_DESCRIPTIVE_CONTENT_INSTRUCTION, WRITE_TODOS_FULL_ENTRY_INSTRUCTION, WRITE_TODOS_NON_EMPTY_INITIAL_LIST_INSTRUCTION, } from "../prompts/runtime-prompts.js";
|
|
2
2
|
import { wrapNormalizedMessage, readTextContent } from "./output-content.js";
|
|
3
|
+
function collectRequestMessages(request) {
|
|
4
|
+
if (typeof request !== "object" || !request || Array.isArray(request)) {
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
const typed = request;
|
|
8
|
+
return Array.isArray(typed.messages)
|
|
9
|
+
? typed.messages.filter((message) => typeof message === "object" && !!message && !Array.isArray(message))
|
|
10
|
+
: [];
|
|
11
|
+
}
|
|
12
|
+
function readMessageRole(message) {
|
|
13
|
+
return typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
|
|
14
|
+
}
|
|
15
|
+
function readLatestUserRequestText(request) {
|
|
16
|
+
const messages = collectRequestMessages(request);
|
|
17
|
+
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
18
|
+
const message = messages[index];
|
|
19
|
+
if (readMessageRole(message) !== "user") {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const content = readTextContent(message.content).trim();
|
|
23
|
+
if (content) {
|
|
24
|
+
return content;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return "";
|
|
28
|
+
}
|
|
29
|
+
function readSystemInstructionText(request) {
|
|
30
|
+
return collectRequestMessages(request)
|
|
31
|
+
.filter((message) => readMessageRole(message) === "system")
|
|
32
|
+
.map((message) => readTextContent(message.content).trim())
|
|
33
|
+
.filter(Boolean)
|
|
34
|
+
.join("\n\n");
|
|
35
|
+
}
|
|
3
36
|
function isToolCallParseFailure(error) {
|
|
4
37
|
return error instanceof Error && /error parsing tool call:/i.test(error.message);
|
|
5
38
|
}
|
|
@@ -72,20 +105,33 @@ export function isRetrySafeInvalidToolSelectionError(value) {
|
|
|
72
105
|
return !!text && /is not a valid tool, try one of \[/i.test(text);
|
|
73
106
|
}
|
|
74
107
|
export function shouldValidateExecutionWithoutToolEvidence(request) {
|
|
75
|
-
|
|
76
|
-
|
|
108
|
+
const userText = readLatestUserRequestText(request);
|
|
109
|
+
if (userText) {
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
return readSystemInstructionText(request).length > 0;
|
|
77
113
|
}
|
|
78
114
|
export function resolveExecutionWithoutToolEvidenceInstruction(request, result) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return null;
|
|
115
|
+
const assistantText = readTextContent(result).trim();
|
|
116
|
+
return resolveExecutionWithoutToolEvidenceTextInstruction(request, assistantText, false, {});
|
|
82
117
|
}
|
|
83
118
|
export function resolveExecutionWithoutToolEvidenceTextInstruction(request, assistantText, toolCallEvidence = false, resultEvidence = {}) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
119
|
+
if (!shouldValidateExecutionWithoutToolEvidence(request)) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
const normalizedText = assistantText.trim();
|
|
123
|
+
const hasUnfinishedExecution = resultEvidence.hasIncompletePlanState === true
|
|
124
|
+
|| resultEvidence.hasOpenTaskDelegation === true
|
|
125
|
+
|| resultEvidence.hasMissingDelegatedExecutionEvidence === true;
|
|
126
|
+
if (!normalizedText || !hasUnfinishedExecution) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
const hasExecutionEvidence = toolCallEvidence
|
|
130
|
+
|| resultEvidence.hasWriteTodosEvidence === true
|
|
131
|
+
|| resultEvidence.hasToolResultEvidence === true;
|
|
132
|
+
return hasExecutionEvidence
|
|
133
|
+
? AUTONOMOUS_INVESTIGATION_RECOVERY_INSTRUCTION
|
|
134
|
+
: EXECUTION_WITH_TOOL_EVIDENCE_RETRY_INSTRUCTION;
|
|
89
135
|
}
|
|
90
136
|
export function resolveToolCallRecoveryInstruction(error) {
|
|
91
137
|
if (isRepairableWriteTodosEmptyFailure(error))
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export declare function tryParseJson(value: string): unknown | null;
|
|
2
|
+
export declare function salvageFunctionLikeToolCall(value: unknown): {
|
|
3
|
+
name: string;
|
|
4
|
+
args: Record<string, unknown>;
|
|
5
|
+
} | null;
|
|
2
6
|
export declare function salvageToolArgs(value: unknown): Record<string, unknown> | null;
|
|
3
7
|
export declare function normalizeKnownToolArgs(toolName: unknown, args: Record<string, unknown>): Record<string, unknown>;
|
|
4
8
|
export declare function isLikelyToolArgsObject(value: unknown): boolean;
|
|
@@ -6,6 +6,112 @@ export function tryParseJson(value) {
|
|
|
6
6
|
return null;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
+
function splitTopLevelDelimited(value, delimiter) {
|
|
10
|
+
const parts = [];
|
|
11
|
+
let depthParen = 0;
|
|
12
|
+
let depthBracket = 0;
|
|
13
|
+
let depthBrace = 0;
|
|
14
|
+
let inString = false;
|
|
15
|
+
let quoteChar = "";
|
|
16
|
+
let escaping = false;
|
|
17
|
+
let start = 0;
|
|
18
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
19
|
+
const char = value[index];
|
|
20
|
+
if (inString) {
|
|
21
|
+
if (escaping) {
|
|
22
|
+
escaping = false;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (char === "\\") {
|
|
26
|
+
escaping = true;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (char === quoteChar) {
|
|
30
|
+
inString = false;
|
|
31
|
+
quoteChar = "";
|
|
32
|
+
}
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (char === "\"" || char === "'") {
|
|
36
|
+
inString = true;
|
|
37
|
+
quoteChar = char;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (char === "(")
|
|
41
|
+
depthParen += 1;
|
|
42
|
+
else if (char === ")")
|
|
43
|
+
depthParen -= 1;
|
|
44
|
+
else if (char === "[")
|
|
45
|
+
depthBracket += 1;
|
|
46
|
+
else if (char === "]")
|
|
47
|
+
depthBracket -= 1;
|
|
48
|
+
else if (char === "{")
|
|
49
|
+
depthBrace += 1;
|
|
50
|
+
else if (char === "}")
|
|
51
|
+
depthBrace -= 1;
|
|
52
|
+
else if (char === delimiter && depthParen === 0 && depthBracket === 0 && depthBrace === 0) {
|
|
53
|
+
parts.push(value.slice(start, index).trim());
|
|
54
|
+
start = index + 1;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
parts.push(value.slice(start).trim());
|
|
58
|
+
return parts.filter(Boolean);
|
|
59
|
+
}
|
|
60
|
+
function parseFunctionLikeScalar(value) {
|
|
61
|
+
const trimmed = value.trim();
|
|
62
|
+
if (!trimmed)
|
|
63
|
+
return "";
|
|
64
|
+
if ((trimmed.startsWith("\"") && trimmed.endsWith("\"")) || (trimmed.startsWith("'") && trimmed.endsWith("'"))) {
|
|
65
|
+
try {
|
|
66
|
+
return JSON.parse(trimmed.startsWith("'")
|
|
67
|
+
? `"${trimmed.slice(1, -1).replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`
|
|
68
|
+
: trimmed);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return trimmed.slice(1, -1);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (trimmed === "true")
|
|
75
|
+
return true;
|
|
76
|
+
if (trimmed === "false")
|
|
77
|
+
return false;
|
|
78
|
+
if (trimmed === "null")
|
|
79
|
+
return null;
|
|
80
|
+
if (/^-?\d+(\.\d+)?$/.test(trimmed)) {
|
|
81
|
+
return Number(trimmed);
|
|
82
|
+
}
|
|
83
|
+
const directJson = tryParseJson(trimmed);
|
|
84
|
+
if (directJson !== null) {
|
|
85
|
+
return directJson;
|
|
86
|
+
}
|
|
87
|
+
return trimmed;
|
|
88
|
+
}
|
|
89
|
+
export function salvageFunctionLikeToolCall(value) {
|
|
90
|
+
if (typeof value !== "string") {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
const trimmed = value.trim();
|
|
94
|
+
const match = /^([A-Za-z_][A-Za-z0-9_]*)\(([\s\S]*)\)$/.exec(trimmed);
|
|
95
|
+
if (!match) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
const [, name, rawArgList] = match;
|
|
99
|
+
const entries = splitTopLevelDelimited(rawArgList, ",");
|
|
100
|
+
const args = {};
|
|
101
|
+
for (const entry of entries) {
|
|
102
|
+
const eqIndex = entry.indexOf("=");
|
|
103
|
+
if (eqIndex <= 0) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
const key = entry.slice(0, eqIndex).trim();
|
|
107
|
+
const rawValue = entry.slice(eqIndex + 1).trim();
|
|
108
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
args[key] = parseFunctionLikeScalar(rawValue);
|
|
112
|
+
}
|
|
113
|
+
return { name, args: normalizeKnownToolArgs(name, args) };
|
|
114
|
+
}
|
|
9
115
|
function extractBalancedJsonObject(value) {
|
|
10
116
|
const start = value.indexOf("{");
|
|
11
117
|
if (start < 0)
|
|
@@ -93,10 +199,26 @@ function normalizeWriteTodosArgs(args) {
|
|
|
93
199
|
}),
|
|
94
200
|
};
|
|
95
201
|
}
|
|
202
|
+
function normalizeTaskArgs(args) {
|
|
203
|
+
const description = typeof args.description === "string" && args.description.trim().length > 0
|
|
204
|
+
? args.description
|
|
205
|
+
: undefined;
|
|
206
|
+
const subagentType = typeof args.subagent_type === "string" && args.subagent_type.trim().length > 0
|
|
207
|
+
? args.subagent_type
|
|
208
|
+
: undefined;
|
|
209
|
+
return {
|
|
210
|
+
...args,
|
|
211
|
+
...(description !== undefined ? { description } : {}),
|
|
212
|
+
...(subagentType !== undefined ? { subagent_type: subagentType } : {}),
|
|
213
|
+
};
|
|
214
|
+
}
|
|
96
215
|
export function normalizeKnownToolArgs(toolName, args) {
|
|
97
216
|
if (toolName === "write_todos") {
|
|
98
217
|
return normalizeWriteTodosArgs(args);
|
|
99
218
|
}
|
|
219
|
+
if (toolName === "task") {
|
|
220
|
+
return normalizeTaskArgs(args);
|
|
221
|
+
}
|
|
100
222
|
return args;
|
|
101
223
|
}
|
|
102
224
|
export function isLikelyToolArgsObject(value) {
|
|
@@ -118,9 +118,7 @@ function sanitizeRetainedEventDataField(key, value) {
|
|
|
118
118
|
const typed = value;
|
|
119
119
|
const taskSubagentType = typeof typed.subagent_type === "string"
|
|
120
120
|
? typed.subagent_type
|
|
121
|
-
:
|
|
122
|
-
? typed.subagentType
|
|
123
|
-
: undefined;
|
|
121
|
+
: undefined;
|
|
124
122
|
if (taskSubagentType) {
|
|
125
123
|
return { subagent_type: taskSubagentType };
|
|
126
124
|
}
|
|
@@ -232,6 +230,38 @@ function hasLowSignalInitialWriteTodos(value) {
|
|
|
232
230
|
: [];
|
|
233
231
|
return items.length > 0 && items.every((item) => typeof item?.content === "string" && isLowSignalTodoContent(item.content));
|
|
234
232
|
}
|
|
233
|
+
function isToolMessageLike(value) {
|
|
234
|
+
if (typeof value !== "object" || value === null) {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
const typed = value;
|
|
238
|
+
if (typed.type === "tool" || typed.lc_direct_tool_output === true || typeof typed.tool_call_id === "string") {
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
if (typeof typed.lc_kwargs === "object" && typed.lc_kwargs !== null) {
|
|
242
|
+
const lcKwargs = typed.lc_kwargs;
|
|
243
|
+
return lcKwargs.type === "tool" || lcKwargs.lc_direct_tool_output === true || typeof lcKwargs.tool_call_id === "string";
|
|
244
|
+
}
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
function isDirectToolOutputPayload(value) {
|
|
248
|
+
if (Array.isArray(value)) {
|
|
249
|
+
return value.some((item) => isDirectToolOutputPayload(item));
|
|
250
|
+
}
|
|
251
|
+
if (typeof value !== "object" || value === null) {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
const typed = value;
|
|
255
|
+
if (typed.lc_direct_tool_output === true) {
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
if (Array.isArray(typed.messages) && typed.messages.length > 0 && typed.messages.every((message) => isToolMessageLike(message))) {
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
return (isDirectToolOutputPayload(typed.update)
|
|
262
|
+
|| isDirectToolOutputPayload(typed.output)
|
|
263
|
+
|| isDirectToolOutputPayload(typed.data));
|
|
264
|
+
}
|
|
235
265
|
export function extractTerminalStreamOutput(event) {
|
|
236
266
|
if (typeof event !== "object" || !event)
|
|
237
267
|
return "";
|
|
@@ -242,6 +272,10 @@ export function extractTerminalStreamOutput(event) {
|
|
|
242
272
|
return extractVisibleOutput(typed.data?.output);
|
|
243
273
|
}
|
|
244
274
|
if (typed.event === "on_chain_end") {
|
|
275
|
+
if (typed.run_type === "tool")
|
|
276
|
+
return "";
|
|
277
|
+
if (isDirectToolOutputPayload(typed.data?.output))
|
|
278
|
+
return "";
|
|
245
279
|
const name = typeof typed.name === "string" ? typed.name : "";
|
|
246
280
|
if (/middleware|after_model/i.test(name))
|
|
247
281
|
return "";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { HarnessEvent, InternalApprovalRecord, WorkspaceBundle } from "../../contracts/types.js";
|
|
2
|
+
export declare function describeRuntimeError(error: unknown): string;
|
|
2
3
|
export declare function renderRuntimeFailure(error: unknown): string;
|
|
3
4
|
export declare function renderToolFailure(toolName: string, output: unknown): string;
|
|
4
5
|
export declare function parseInterruptContent(content: string): {
|
|
@@ -1,9 +1,51 @@
|
|
|
1
1
|
import { createPersistentId } from "../../utils/id.js";
|
|
2
2
|
import { isDelegationCapableBinding } from "../../workspace/support/agent-capabilities.js";
|
|
3
3
|
import { isDeepAgentBinding } from "./compiled-binding.js";
|
|
4
|
+
function collectRuntimeErrorMessages(error, seen = new Set()) {
|
|
5
|
+
if (error == null || seen.has(error)) {
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
if (typeof error === "object" || typeof error === "function") {
|
|
9
|
+
seen.add(error);
|
|
10
|
+
}
|
|
11
|
+
if (typeof error === "string") {
|
|
12
|
+
const trimmed = error.trim();
|
|
13
|
+
return trimmed ? [trimmed] : [];
|
|
14
|
+
}
|
|
15
|
+
if (!(error instanceof Error)) {
|
|
16
|
+
const message = String(error).trim();
|
|
17
|
+
return message ? [message] : [];
|
|
18
|
+
}
|
|
19
|
+
const messages = [];
|
|
20
|
+
const primary = error.message.trim();
|
|
21
|
+
if (primary) {
|
|
22
|
+
messages.push(primary);
|
|
23
|
+
}
|
|
24
|
+
const composite = error;
|
|
25
|
+
if (Array.isArray(composite.errors)) {
|
|
26
|
+
for (const nested of composite.errors) {
|
|
27
|
+
messages.push(...collectRuntimeErrorMessages(nested, seen));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (composite.cause !== undefined) {
|
|
31
|
+
messages.push(...collectRuntimeErrorMessages(composite.cause, seen));
|
|
32
|
+
}
|
|
33
|
+
return messages;
|
|
34
|
+
}
|
|
35
|
+
export function describeRuntimeError(error) {
|
|
36
|
+
const uniqueMessages = Array.from(new Set(collectRuntimeErrorMessages(error)));
|
|
37
|
+
if (uniqueMessages.length === 0) {
|
|
38
|
+
return String(error).trim();
|
|
39
|
+
}
|
|
40
|
+
if (uniqueMessages.length === 1) {
|
|
41
|
+
return uniqueMessages[0];
|
|
42
|
+
}
|
|
43
|
+
const nested = uniqueMessages.slice(1, 6);
|
|
44
|
+
const suffix = uniqueMessages.length > 6 ? `\n...and ${uniqueMessages.length - 6} more` : "";
|
|
45
|
+
return `${uniqueMessages[0]}\ncauses:\n${nested.map((message, index) => `${index + 1}. ${message}`).join("\n")}${suffix}`;
|
|
46
|
+
}
|
|
4
47
|
export function renderRuntimeFailure(error) {
|
|
5
|
-
|
|
6
|
-
return `runtime_error=${message}`.trim();
|
|
48
|
+
return `runtime_error=${describeRuntimeError(error)}`.trim();
|
|
7
49
|
}
|
|
8
50
|
function readToolErrorMessage(output) {
|
|
9
51
|
if (typeof output === "string" && output.trim()) {
|
package/dist/tools.js
CHANGED
|
@@ -10,6 +10,9 @@ function getZodLikeTypeName(value) {
|
|
|
10
10
|
return undefined;
|
|
11
11
|
}
|
|
12
12
|
const typed = value;
|
|
13
|
+
if (typeof typed.def?.type === "string") {
|
|
14
|
+
return typed.def.type;
|
|
15
|
+
}
|
|
13
16
|
if (typeof typed._zod?.def?.type === "string") {
|
|
14
17
|
return typed._zod.def.type;
|
|
15
18
|
}
|
|
@@ -42,7 +45,30 @@ function getZodLikeInnerSchema(value) {
|
|
|
42
45
|
return undefined;
|
|
43
46
|
}
|
|
44
47
|
const typed = value;
|
|
45
|
-
return typed.
|
|
48
|
+
return typed.def?.innerType
|
|
49
|
+
?? typed.def?.element
|
|
50
|
+
?? typed.def?.valueType
|
|
51
|
+
?? typed.def?.schema
|
|
52
|
+
?? typed.def?.out
|
|
53
|
+
?? typed.def?.in
|
|
54
|
+
?? typed._zod?.def?.innerType
|
|
55
|
+
?? typed._zod?.def?.element
|
|
56
|
+
?? typed._zod?.def?.valueType
|
|
57
|
+
?? typed._def?.innerType
|
|
58
|
+
?? typed._def?.schema
|
|
59
|
+
?? typed._def?.type
|
|
60
|
+
?? typed._def?.valueType
|
|
61
|
+
?? typed._def?.in
|
|
62
|
+
?? typed._def?.out;
|
|
63
|
+
}
|
|
64
|
+
function isEffectWrappedOptional(value) {
|
|
65
|
+
const typeName = getZodLikeTypeName(value);
|
|
66
|
+
if (typeName !== "effects" && typeName !== "pipeline" && typeName !== "pipe" && typeName !== "transform") {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
const inner = getZodLikeInnerSchema(value);
|
|
70
|
+
const innerTypeName = getZodLikeTypeName(inner);
|
|
71
|
+
return innerTypeName === "optional" || innerTypeName === "default" || innerTypeName === "catch";
|
|
46
72
|
}
|
|
47
73
|
function buildJsonSchemaFromZodLike(value) {
|
|
48
74
|
const shape = getZodLikeObjectShape(value);
|
|
@@ -51,13 +77,13 @@ function buildJsonSchemaFromZodLike(value) {
|
|
|
51
77
|
const required = Object.entries(shape)
|
|
52
78
|
.filter(([, entry]) => {
|
|
53
79
|
const typeName = getZodLikeTypeName(entry);
|
|
54
|
-
return typeName !== "optional" && typeName !== "default" && typeName !== "catch";
|
|
80
|
+
return typeName !== "optional" && typeName !== "default" && typeName !== "catch" && !isEffectWrappedOptional(entry);
|
|
55
81
|
})
|
|
56
82
|
.map(([key]) => key);
|
|
57
83
|
return {
|
|
58
84
|
type: "object",
|
|
59
85
|
properties,
|
|
60
|
-
|
|
86
|
+
required,
|
|
61
87
|
};
|
|
62
88
|
}
|
|
63
89
|
const typeName = getZodLikeTypeName(value);
|
|
@@ -88,6 +114,10 @@ function buildJsonSchemaFromZodLike(value) {
|
|
|
88
114
|
case "nullable":
|
|
89
115
|
case "default":
|
|
90
116
|
case "catch":
|
|
117
|
+
case "effects":
|
|
118
|
+
case "pipeline":
|
|
119
|
+
case "pipe":
|
|
120
|
+
case "transform":
|
|
91
121
|
return buildJsonSchemaFromZodLike(getZodLikeInnerSchema(value)) ?? {};
|
|
92
122
|
default:
|
|
93
123
|
return undefined;
|
|
@@ -106,7 +136,7 @@ export function buildToolJsonSchema(schema) {
|
|
|
106
136
|
required: Object.entries(schema)
|
|
107
137
|
.filter(([, value]) => {
|
|
108
138
|
const typeName = getZodLikeTypeName(value);
|
|
109
|
-
return typeName !== "optional" && typeName !== "default" && typeName !== "catch";
|
|
139
|
+
return typeName !== "optional" && typeName !== "default" && typeName !== "catch" && !isEffectWrappedOptional(value);
|
|
110
140
|
})
|
|
111
141
|
.map(([key]) => key),
|
|
112
142
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botbotgo/agent-harness",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.328",
|
|
4
4
|
"description": "Workspace runtime for multi-agent applications",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -47,19 +47,19 @@
|
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@langchain/anthropic": "^1.
|
|
51
|
-
"@langchain/community": "^1.1.
|
|
52
|
-
"@langchain/core": "^1.1.
|
|
53
|
-
"@langchain/google": "^0.1.
|
|
54
|
-
"@langchain/langgraph": "^1.2.
|
|
50
|
+
"@langchain/anthropic": "^1.3.27",
|
|
51
|
+
"@langchain/community": "^1.1.27",
|
|
52
|
+
"@langchain/core": "^1.1.41",
|
|
53
|
+
"@langchain/google": "^0.1.10",
|
|
54
|
+
"@langchain/langgraph": "^1.2.9",
|
|
55
55
|
"@langchain/ollama": "^1.2.6",
|
|
56
|
-
"@langchain/openai": "^1.
|
|
56
|
+
"@langchain/openai": "^1.4.4",
|
|
57
57
|
"@libsql/client": "^0.17.0",
|
|
58
58
|
"@llamaindex/ollama": "^0.1.23",
|
|
59
59
|
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
60
60
|
"@qdrant/js-client-rest": "^1.17.0",
|
|
61
61
|
"deepagents": "^1.9.0",
|
|
62
|
-
"langchain": "^1.3.
|
|
62
|
+
"langchain": "^1.3.4",
|
|
63
63
|
"llamaindex": "^0.12.1",
|
|
64
64
|
"mem0ai": "^2.4.6",
|
|
65
65
|
"mustache": "^4.2.0",
|