@botbotgo/agent-harness 0.0.31 → 0.0.32
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.31";
|
package/dist/package-version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export const AGENT_HARNESS_VERSION = "0.0.31";
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Command, MemorySaver } from "@langchain/langgraph";
|
|
2
|
+
import { tool as createLangChainTool } from "@langchain/core/tools";
|
|
2
3
|
import { createDeepAgent } from "deepagents";
|
|
3
4
|
import { ChatAnthropic } from "@langchain/anthropic";
|
|
4
5
|
import { ChatGoogle } from "@langchain/google";
|
|
5
6
|
import { ChatOllama } from "@langchain/ollama";
|
|
6
7
|
import { ChatOpenAI } from "@langchain/openai";
|
|
7
8
|
import { createAgent, humanInTheLoopMiddleware, initChatModel } from "langchain";
|
|
9
|
+
import { z } from "zod";
|
|
8
10
|
import { extractEmptyAssistantMessageFailure, extractReasoningText, extractToolFallbackContext, extractVisibleOutput, isLikelyToolArgsObject, isToolCallParseFailure, STRICT_TOOL_JSON_INSTRUCTION, sanitizeVisibleText, tryParseJson, wrapResolvedModel, } from "./parsing/output-parsing.js";
|
|
9
11
|
import { extractAgentStep, extractInterruptPayload, extractReasoningStreamOutput, extractTerminalStreamOutput, extractToolResult, normalizeTerminalOutputKey, readStreamDelta, } from "./parsing/stream-event-parsing.js";
|
|
10
12
|
import { wrapToolForExecution } from "./tool-hitl.js";
|
|
@@ -120,6 +122,37 @@ function wrapResolvedToolWithModelFacingName(resolvedTool, modelFacingName) {
|
|
|
120
122
|
},
|
|
121
123
|
});
|
|
122
124
|
}
|
|
125
|
+
function hasCallableToolHandler(value) {
|
|
126
|
+
if (typeof value !== "object" || value === null) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
const typed = value;
|
|
130
|
+
return typeof typed.invoke === "function" || typeof typed.call === "function" || typeof typed.func === "function";
|
|
131
|
+
}
|
|
132
|
+
function normalizeResolvedToolSchema(resolvedTool) {
|
|
133
|
+
const schema = resolvedTool.schema;
|
|
134
|
+
if (schema && typeof schema.parse === "function" && "_def" in schema) {
|
|
135
|
+
return resolvedTool.schema;
|
|
136
|
+
}
|
|
137
|
+
if (schema && (schema.type === "object" || typeof schema.properties === "object")) {
|
|
138
|
+
return schema;
|
|
139
|
+
}
|
|
140
|
+
return z.object({}).passthrough();
|
|
141
|
+
}
|
|
142
|
+
function asStructuredExecutableTool(resolvedTool, modelFacingName, description) {
|
|
143
|
+
if (!hasCallableToolHandler(resolvedTool)) {
|
|
144
|
+
return resolvedTool;
|
|
145
|
+
}
|
|
146
|
+
const handler = resolvedTool.invoke ?? resolvedTool.call ?? resolvedTool.func;
|
|
147
|
+
if (typeof handler !== "function") {
|
|
148
|
+
return resolvedTool;
|
|
149
|
+
}
|
|
150
|
+
return createLangChainTool(async (input, config) => handler(input, config), {
|
|
151
|
+
name: modelFacingName,
|
|
152
|
+
description,
|
|
153
|
+
schema: normalizeResolvedToolSchema(resolvedTool),
|
|
154
|
+
});
|
|
155
|
+
}
|
|
123
156
|
function countConfiguredTools(binding) {
|
|
124
157
|
return binding.langchainAgentParams?.tools.length ?? binding.deepAgentParams?.tools.length ?? 0;
|
|
125
158
|
}
|
|
@@ -317,6 +350,10 @@ export class AgentRuntimeAdapter {
|
|
|
317
350
|
}
|
|
318
351
|
const wrappedTool = wrapToolForExecution(resolvedTool, compiledTool);
|
|
319
352
|
const modelFacingName = toolNameMapping.originalToModelFacing.get(compiledTool.name) ?? compiledTool.name;
|
|
353
|
+
const structuredTool = asStructuredExecutableTool(wrappedTool, modelFacingName, compiledTool.description);
|
|
354
|
+
if (structuredTool !== wrappedTool) {
|
|
355
|
+
return structuredTool;
|
|
356
|
+
}
|
|
320
357
|
return modelFacingName === compiledTool.name ? wrappedTool : wrapResolvedToolWithModelFacingName(wrappedTool, modelFacingName);
|
|
321
358
|
});
|
|
322
359
|
}
|