@botbotgo/agent-harness 0.0.165 → 0.0.166
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/README.md +1 -1
- package/README.zh.md +1 -1
- package/dist/package-version.d.ts +1 -1
- package/dist/package-version.js +1 -1
- package/dist/runtime/adapter/local-tool-invocation.js +1 -1
- package/dist/runtime/adapter/tool/tool-arguments.d.ts +2 -1
- package/dist/runtime/adapter/tool/tool-arguments.js +35 -8
- package/package.json +1 -1
package/README.md
CHANGED
package/README.zh.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export declare const AGENT_HARNESS_VERSION = "0.0.165";
|
package/dist/package-version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export const AGENT_HARNESS_VERSION = "0.0.165";
|
|
@@ -49,7 +49,7 @@ export async function runLocalToolInvocationLoop({ binding, request, primaryTool
|
|
|
49
49
|
throw new Error(`Tool ${toolCall.name} is not configured for this agent.`);
|
|
50
50
|
}
|
|
51
51
|
const compiledTool = toolCatalog.get(toolCall.name) ?? toolCatalog.get(resolvedToolName);
|
|
52
|
-
const normalizedArgs = normalizeToolArgsForSchema(toolCall.args, activeExecutable.schema);
|
|
52
|
+
const normalizedArgs = normalizeToolArgsForSchema(toolCall.args, activeExecutable.schema, toolCall.rawArgsInput);
|
|
53
53
|
const toolResult = await activeExecutable.invoke(normalizedArgs);
|
|
54
54
|
const memoryCandidates = compiledTool ? extractMemoryCandidatesFromToolOutput(compiledTool, toolResult) : [];
|
|
55
55
|
executedToolResults.push({
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export declare function stringifyToolOutput(output: unknown): string;
|
|
2
|
-
export declare function normalizeToolArgsForSchema(args: Record<string, unknown>, schema: unknown): Record<string, unknown>;
|
|
2
|
+
export declare function normalizeToolArgsForSchema(args: Record<string, unknown>, schema: unknown, rawArgsInput?: unknown): Record<string, unknown>;
|
|
3
3
|
export declare function extractToolCallsFromResult(result: unknown): Array<{
|
|
4
4
|
id?: string;
|
|
5
5
|
name: string;
|
|
6
6
|
args: Record<string, unknown>;
|
|
7
|
+
rawArgsInput?: unknown;
|
|
7
8
|
}>;
|
|
@@ -14,7 +14,29 @@ export function stringifyToolOutput(output) {
|
|
|
14
14
|
return `${String(output)}`;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
function mapSingleFieldScalarArg(args, expectedKey, rawArgsInput) {
|
|
18
|
+
if (expectedKey in args) {
|
|
19
|
+
return args;
|
|
20
|
+
}
|
|
21
|
+
if (typeof rawArgsInput === "string") {
|
|
22
|
+
const trimmed = rawArgsInput.trim();
|
|
23
|
+
if (trimmed.length === 0) {
|
|
24
|
+
return args;
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
...args,
|
|
28
|
+
[expectedKey]: trimmed,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
if (typeof rawArgsInput === "number" || typeof rawArgsInput === "boolean") {
|
|
32
|
+
return {
|
|
33
|
+
...args,
|
|
34
|
+
[expectedKey]: rawArgsInput,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return args;
|
|
38
|
+
}
|
|
39
|
+
export function normalizeToolArgsForSchema(args, schema, rawArgsInput) {
|
|
18
40
|
const schemaDef = isObject(schema) ? schema._def : undefined;
|
|
19
41
|
const shape = schemaDef
|
|
20
42
|
? isRecord(schemaDef.shape)
|
|
@@ -34,19 +56,23 @@ export function normalizeToolArgsForSchema(args, schema) {
|
|
|
34
56
|
if (expectedKey in args) {
|
|
35
57
|
return args;
|
|
36
58
|
}
|
|
59
|
+
const scalarMappedArgs = mapSingleFieldScalarArg(args, expectedKey, rawArgsInput);
|
|
60
|
+
if (expectedKey in scalarMappedArgs) {
|
|
61
|
+
return scalarMappedArgs;
|
|
62
|
+
}
|
|
37
63
|
const aliasesByExpected = {
|
|
38
64
|
city: ["location", "locality", "place"],
|
|
39
65
|
location: ["city", "city_name"],
|
|
40
66
|
query: ["question", "prompt", "text", "request"],
|
|
41
67
|
};
|
|
42
68
|
const aliases = aliasesByExpected[expectedKey] ?? [];
|
|
43
|
-
const aliasKey = aliases.find((candidate) => candidate in
|
|
44
|
-
if (!aliasKey || !(aliasKey in
|
|
45
|
-
return
|
|
69
|
+
const aliasKey = aliases.find((candidate) => candidate in scalarMappedArgs);
|
|
70
|
+
if (!aliasKey || !(aliasKey in scalarMappedArgs)) {
|
|
71
|
+
return scalarMappedArgs;
|
|
46
72
|
}
|
|
47
73
|
return {
|
|
48
|
-
...
|
|
49
|
-
[expectedKey]:
|
|
74
|
+
...scalarMappedArgs,
|
|
75
|
+
[expectedKey]: scalarMappedArgs[aliasKey],
|
|
50
76
|
};
|
|
51
77
|
}
|
|
52
78
|
export function extractToolCallsFromResult(result) {
|
|
@@ -75,12 +101,13 @@ export function extractToolCallsFromResult(result) {
|
|
|
75
101
|
if (!name) {
|
|
76
102
|
return null;
|
|
77
103
|
}
|
|
78
|
-
const
|
|
104
|
+
const rawArgsInput = toolCall.args ?? functionPayload?.arguments;
|
|
105
|
+
const rawArgs = salvageToolArgs(rawArgsInput) ?? {};
|
|
79
106
|
if (!isObject(rawArgs)) {
|
|
80
107
|
return null;
|
|
81
108
|
}
|
|
82
109
|
const id = typeof toolCall.id === "string" ? toolCall.id : undefined;
|
|
83
|
-
return { id, name, args: rawArgs };
|
|
110
|
+
return { id, name, args: rawArgs, rawArgsInput };
|
|
84
111
|
})
|
|
85
112
|
.filter((item) => item !== null);
|
|
86
113
|
}
|