@botbotgo/agent-harness 0.0.422 → 0.0.423
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,2 +1,2 @@
|
|
|
1
|
-
export declare const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export declare const AGENT_HARNESS_VERSION = "0.0.423";
|
|
2
2
|
export declare const AGENT_HARNESS_RELEASE_DATE = "2026-05-03";
|
package/dist/package-version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export const AGENT_HARNESS_VERSION = "0.0.423";
|
|
2
2
|
export const AGENT_HARNESS_RELEASE_DATE = "2026-05-03";
|
|
@@ -13,76 +13,15 @@ const TOOL_FOLLOW_UP_INSTRUCTION = "One or more tool results are already availab
|
|
|
13
13
|
const DEFAULT_MAX_TOOL_ITERATIONS = 10_000;
|
|
14
14
|
const MAX_REPEATED_RECOVERY_WITHOUT_PROGRESS = 2;
|
|
15
15
|
const MAX_REPEATED_PLAN_ONLY_AFTER_PLAN = 2;
|
|
16
|
-
function
|
|
17
|
-
if (typeof request === "string") {
|
|
18
|
-
return request;
|
|
19
|
-
}
|
|
20
|
-
if (typeof request !== "object" || request === null) {
|
|
21
|
-
return "";
|
|
22
|
-
}
|
|
23
|
-
try {
|
|
24
|
-
return JSON.stringify(request);
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
return "";
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function extractSelectionTokens(value) {
|
|
31
|
-
const tokens = new Set();
|
|
32
|
-
for (const match of value.matchAll(/[\p{L}\p{N}_-]+/gu)) {
|
|
33
|
-
const token = match[0].toLowerCase();
|
|
34
|
-
if (token.length >= 2) {
|
|
35
|
-
tokens.add(token);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
for (const match of value.matchAll(/[\p{Script=Han}]{2,}/gu)) {
|
|
39
|
-
const sequence = match[0];
|
|
40
|
-
for (let size = 2; size <= Math.min(4, sequence.length); size += 1) {
|
|
41
|
-
for (let index = 0; index <= sequence.length - size; index += 1) {
|
|
42
|
-
tokens.add(sequence.slice(index, index + size).toLowerCase());
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return tokens;
|
|
47
|
-
}
|
|
48
|
-
function prioritizeBootstrapEvidenceTools(primaryTools, request) {
|
|
49
|
-
const requestText = stringifyRequestForToolSelection(request);
|
|
50
|
-
const requestTokens = extractSelectionTokens(requestText);
|
|
51
|
-
const isFinanceRequest = /\b(?:stock|ticker|finance|market|valuation|quote)\b|股票|股价|行情|估值|财报/iu.test(requestText);
|
|
16
|
+
function prioritizeBootstrapEvidenceTools(primaryTools) {
|
|
52
17
|
const evidenceTools = primaryTools
|
|
53
|
-
.map((tool) =>
|
|
54
|
-
|
|
55
|
-
const description = typeof tool.description === "string" ? tool.description : "";
|
|
56
|
-
const toolTokens = extractSelectionTokens(`${name} ${description}`);
|
|
57
|
-
let score = 0;
|
|
58
|
-
for (const token of requestTokens) {
|
|
59
|
-
if (toolTokens.has(token)) {
|
|
60
|
-
score += token.length > 3 ? 2 : 1;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (requestText.toLowerCase().includes(name.toLowerCase())) {
|
|
64
|
-
score += 6;
|
|
65
|
-
}
|
|
66
|
-
return { name, score };
|
|
67
|
-
})
|
|
68
|
-
.filter((tool) => tool.name.length > 0 && !isPlanToolName(tool.name))
|
|
69
|
-
.sort((left, right) => {
|
|
70
|
-
if (right.score !== left.score) {
|
|
71
|
-
return right.score - left.score;
|
|
72
|
-
}
|
|
73
|
-
if (!isFinanceRequest) {
|
|
74
|
-
return 0;
|
|
75
|
-
}
|
|
76
|
-
const leftFinance = left.name.includes("finance") ? 0 : 1;
|
|
77
|
-
const rightFinance = right.name.includes("finance") ? 0 : 1;
|
|
78
|
-
return leftFinance - rightFinance;
|
|
79
|
-
})
|
|
80
|
-
.map((tool) => tool.name);
|
|
18
|
+
.map((tool) => typeof tool.name === "string" ? tool.name.trim() : "")
|
|
19
|
+
.filter((name) => name.length > 0 && !isPlanToolName(name));
|
|
81
20
|
return evidenceTools.slice(0, 4);
|
|
82
21
|
}
|
|
83
|
-
function createBootstrapTodoPlan(primaryTools
|
|
84
|
-
const
|
|
85
|
-
if (
|
|
22
|
+
function createBootstrapTodoPlan(primaryTools) {
|
|
23
|
+
const evidenceTool = prioritizeBootstrapEvidenceTools(primaryTools)[0];
|
|
24
|
+
if (!evidenceTool) {
|
|
86
25
|
return [
|
|
87
26
|
{
|
|
88
27
|
content: "Establish the required visible plan for this request",
|
|
@@ -94,12 +33,9 @@ function createBootstrapTodoPlan(primaryTools, request) {
|
|
|
94
33
|
},
|
|
95
34
|
];
|
|
96
35
|
}
|
|
97
|
-
const evidenceLabel = evidenceTools.length > 0
|
|
98
|
-
? evidenceTools.join(", ")
|
|
99
|
-
: "the selected non-planning evidence tool";
|
|
100
36
|
return [
|
|
101
37
|
{
|
|
102
|
-
content: `
|
|
38
|
+
content: `Run the configured non-planning evidence tool: ${evidenceTool}`,
|
|
103
39
|
status: "in_progress",
|
|
104
40
|
},
|
|
105
41
|
{
|
|
@@ -112,7 +48,7 @@ function createBootstrapTodoPlan(primaryTools, request) {
|
|
|
112
48
|
},
|
|
113
49
|
];
|
|
114
50
|
}
|
|
115
|
-
function buildBootstrapPlanToolResult(primaryTools
|
|
51
|
+
function buildBootstrapPlanToolResult(primaryTools) {
|
|
116
52
|
return {
|
|
117
53
|
messages: [new AIMessage({
|
|
118
54
|
content: "",
|
|
@@ -120,7 +56,7 @@ function buildBootstrapPlanToolResult(primaryTools, request) {
|
|
|
120
56
|
id: `write-todos-bootstrap-${Math.random().toString(36).slice(2, 10)}`,
|
|
121
57
|
name: "write_todos",
|
|
122
58
|
args: {
|
|
123
|
-
todos: createBootstrapTodoPlan(primaryTools
|
|
59
|
+
todos: createBootstrapTodoPlan(primaryTools),
|
|
124
60
|
},
|
|
125
61
|
type: "tool_call",
|
|
126
62
|
}],
|
|
@@ -298,34 +234,6 @@ function resolveCommittedTodoEvidenceTool(executedToolResults, primaryTools) {
|
|
|
298
234
|
id: `todo-committed-evidence-${index}`,
|
|
299
235
|
};
|
|
300
236
|
}
|
|
301
|
-
const requestTokens = extractSelectionTokens(content);
|
|
302
|
-
const scored = availableTools
|
|
303
|
-
.map((tool) => {
|
|
304
|
-
const toolTokens = extractSelectionTokens(`${tool.name} ${tool.description ?? ""}`);
|
|
305
|
-
let score = 0;
|
|
306
|
-
for (const token of requestTokens) {
|
|
307
|
-
if (toolTokens.has(token)) {
|
|
308
|
-
score += token.length > 3 ? 2 : 1;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
return { name: tool.name, score };
|
|
312
|
-
})
|
|
313
|
-
.filter((item) => item.score > 0)
|
|
314
|
-
.sort((left, right) => right.score - left.score);
|
|
315
|
-
if (scored[0] && (!scored[1] || scored[0].score > scored[1].score)) {
|
|
316
|
-
return {
|
|
317
|
-
name: scored[0].name,
|
|
318
|
-
args: {},
|
|
319
|
-
id: `todo-committed-evidence-${index}`,
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
if (matched.length === 1) {
|
|
323
|
-
return {
|
|
324
|
-
name: matched[0],
|
|
325
|
-
args: {},
|
|
326
|
-
id: `todo-committed-evidence-${index}`,
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
237
|
}
|
|
330
238
|
}
|
|
331
239
|
return null;
|
|
@@ -473,7 +381,7 @@ export async function runLocalToolInvocationLoop({ binding, request, primaryTool
|
|
|
473
381
|
if (requiresPlanEvidence(binding)
|
|
474
382
|
&& !hasPlanStateEvidence(executedToolResults, externalPlanEvidence)
|
|
475
383
|
&& builtinExecutableTools.has("write_todos")) {
|
|
476
|
-
pendingResult = buildBootstrapPlanToolResult(primaryTools
|
|
384
|
+
pendingResult = buildBootstrapPlanToolResult(primaryTools);
|
|
477
385
|
continue;
|
|
478
386
|
}
|
|
479
387
|
if (recoveryInstruction) {
|