@botbotgo/agent-harness 0.0.340 → 0.0.341
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/contracts/workspace.d.ts +10 -0
- package/dist/package-version.d.ts +2 -2
- package/dist/package-version.js +2 -2
- package/dist/runtime/adapter/flow/execution-context.js +3 -2
- package/dist/runtime/adapter/flow/stream-runtime.d.ts +6 -0
- package/dist/runtime/adapter/flow/stream-runtime.js +54 -15
- package/dist/runtime/adapter/invocation-result.js +111 -9
- package/dist/runtime/adapter/local-tool-invocation.js +21 -1
- package/dist/runtime/adapter/middleware/context-hygiene.d.ts +5 -0
- package/dist/runtime/adapter/middleware/context-hygiene.js +83 -0
- package/dist/runtime/adapter/middleware-assembly.d.ts +11 -0
- package/dist/runtime/adapter/middleware-assembly.js +154 -178
- package/dist/runtime/adapter/model/invocation-request.js +39 -1
- package/dist/runtime/adapter/runtime-adapter-support.js +33 -3
- package/dist/runtime/adapter/stream-event-projection.js +6 -5
- package/dist/runtime/adapter/tool/builtin-middleware-tools.d.ts +7 -0
- package/dist/runtime/adapter/tool/builtin-middleware-tools.js +31 -24
- package/dist/runtime/agent-runtime-adapter.d.ts +3 -2
- package/dist/runtime/agent-runtime-adapter.js +128 -9
- package/dist/runtime/agent-runtime-assembly.d.ts +1 -0
- package/dist/runtime/agent-runtime-assembly.js +10 -2
- package/dist/runtime/harness/run/inspection.js +4 -5
- package/dist/runtime/harness/run/stream-run.js +180 -50
- package/dist/runtime/parsing/output-parsing.d.ts +1 -1
- package/dist/runtime/parsing/output-parsing.js +1 -1
- package/dist/runtime/parsing/output-recovery.d.ts +9 -0
- package/dist/runtime/parsing/output-recovery.js +46 -1
- package/dist/runtime/support/compiled-binding.d.ts +5 -0
- package/dist/runtime/support/compiled-binding.js +12 -0
- package/dist/workspace/agent-binding-compiler.js +8 -0
- package/dist/workspace/object-loader.js +6 -0
- package/package.json +1 -1
|
@@ -7,11 +7,20 @@ export declare function isRepairableWriteTodosEmptyFailure(error: unknown): bool
|
|
|
7
7
|
export declare function isToolCallRecoveryFailure(error: unknown): boolean;
|
|
8
8
|
export declare function isRetrySafeInvalidToolSelectionError(value: unknown): boolean;
|
|
9
9
|
export declare function shouldValidateExecutionWithoutToolEvidence(request: unknown): boolean;
|
|
10
|
+
export declare function shouldRequireVisibleTodoPlan(request: unknown): boolean;
|
|
11
|
+
export declare function resolveMissingPlanRecoveryInstruction(params: {
|
|
12
|
+
request: unknown;
|
|
13
|
+
assistantText?: string;
|
|
14
|
+
hasPlanStateEvidence?: boolean;
|
|
15
|
+
hasWriteTodosEvidence?: boolean;
|
|
16
|
+
hasToolResultEvidence?: boolean;
|
|
17
|
+
}): string | null;
|
|
10
18
|
export declare function resolveExecutionWithoutToolEvidenceInstruction(request: unknown, result: unknown): string | null;
|
|
11
19
|
export declare function resolveExecutionWithoutToolEvidenceTextInstruction(request: unknown, assistantText: string, toolCallEvidence?: boolean, resultEvidence?: {
|
|
12
20
|
hasWriteTodosEvidence?: boolean;
|
|
13
21
|
hasToolResultEvidence?: boolean;
|
|
14
22
|
hasIncompletePlanState?: boolean;
|
|
23
|
+
hasPlanStateEvidence?: boolean;
|
|
15
24
|
hasOpenTaskDelegation?: boolean;
|
|
16
25
|
hasMissingDelegatedExecutionEvidence?: boolean;
|
|
17
26
|
}): string | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
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";
|
|
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, WRITE_TODOS_REQUIRED_PLAN_INSTRUCTION, } from "../prompts/runtime-prompts.js";
|
|
2
2
|
import { wrapNormalizedMessage, readTextContent } from "./output-content.js";
|
|
3
3
|
function collectRequestMessages(request) {
|
|
4
4
|
if (typeof request !== "object" || !request || Array.isArray(request)) {
|
|
@@ -111,6 +111,41 @@ export function shouldValidateExecutionWithoutToolEvidence(request) {
|
|
|
111
111
|
}
|
|
112
112
|
return readSystemInstructionText(request).length > 0;
|
|
113
113
|
}
|
|
114
|
+
export function shouldRequireVisibleTodoPlan(request) {
|
|
115
|
+
const userText = readLatestUserRequestText(request).toLowerCase();
|
|
116
|
+
if (!userText) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
return [
|
|
120
|
+
"investigate",
|
|
121
|
+
"investigation",
|
|
122
|
+
"issue",
|
|
123
|
+
"issues",
|
|
124
|
+
"rca",
|
|
125
|
+
"root cause",
|
|
126
|
+
"go deeper",
|
|
127
|
+
"deep research",
|
|
128
|
+
"debug",
|
|
129
|
+
"排查",
|
|
130
|
+
"调查",
|
|
131
|
+
"问题",
|
|
132
|
+
"根因",
|
|
133
|
+
"故障",
|
|
134
|
+
"集群",
|
|
135
|
+
"cluster",
|
|
136
|
+
].some((keyword) => userText.includes(keyword));
|
|
137
|
+
}
|
|
138
|
+
export function resolveMissingPlanRecoveryInstruction(params) {
|
|
139
|
+
const hasPlanEvidence = params.hasWriteTodosEvidence === true
|
|
140
|
+
|| params.hasPlanStateEvidence === true;
|
|
141
|
+
if (!shouldRequireVisibleTodoPlan(params.request) || hasPlanEvidence) {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
if (params.hasToolResultEvidence === true) {
|
|
145
|
+
return WRITE_TODOS_REQUIRED_PLAN_INSTRUCTION;
|
|
146
|
+
}
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
114
149
|
export function resolveExecutionWithoutToolEvidenceInstruction(request, result) {
|
|
115
150
|
const assistantText = readTextContent(result).trim();
|
|
116
151
|
return resolveExecutionWithoutToolEvidenceTextInstruction(request, assistantText, false, {});
|
|
@@ -120,6 +155,16 @@ export function resolveExecutionWithoutToolEvidenceTextInstruction(request, assi
|
|
|
120
155
|
return null;
|
|
121
156
|
}
|
|
122
157
|
const normalizedText = assistantText.trim();
|
|
158
|
+
const missingPlanRecoveryInstruction = resolveMissingPlanRecoveryInstruction({
|
|
159
|
+
request,
|
|
160
|
+
assistantText: normalizedText,
|
|
161
|
+
hasWriteTodosEvidence: resultEvidence.hasWriteTodosEvidence,
|
|
162
|
+
hasPlanStateEvidence: resultEvidence.hasIncompletePlanState === true || resultEvidence.hasPlanStateEvidence === true,
|
|
163
|
+
hasToolResultEvidence: resultEvidence.hasToolResultEvidence,
|
|
164
|
+
});
|
|
165
|
+
if (missingPlanRecoveryInstruction) {
|
|
166
|
+
return missingPlanRecoveryInstruction;
|
|
167
|
+
}
|
|
123
168
|
const hasUnfinishedExecution = resultEvidence.hasIncompletePlanState === true
|
|
124
169
|
|| resultEvidence.hasOpenTaskDelegation === true
|
|
125
170
|
|| resultEvidence.hasMissingDelegatedExecutionEvidence === true;
|
|
@@ -31,6 +31,11 @@ export declare function getBindingDeepAgentSubagents(binding: CompiledAgentBindi
|
|
|
31
31
|
export declare function getBindingGeneralPurposeAgent(binding: CompiledAgentBinding): boolean | undefined;
|
|
32
32
|
export declare function getBindingTaskDescription(binding: CompiledAgentBinding): string | undefined;
|
|
33
33
|
export declare function getBindingBackendConfig(binding: CompiledAgentBinding): Record<string, unknown> | undefined;
|
|
34
|
+
export declare function getBindingInteractionMode(binding: CompiledAgentBinding): "stream" | "invoke" | undefined;
|
|
35
|
+
export declare function getBindingBuiltinToolsConfig(binding: CompiledAgentBinding): {
|
|
36
|
+
filesystem?: boolean;
|
|
37
|
+
todos?: boolean;
|
|
38
|
+
} | undefined;
|
|
34
39
|
export declare function getBindingFilesystemConfig(binding: CompiledAgentBinding): Record<string, unknown> | undefined;
|
|
35
40
|
export declare function isLangChainBinding(binding: CompiledAgentBinding): boolean;
|
|
36
41
|
export declare function isDeepAgentBinding(binding: CompiledAgentBinding): boolean;
|
|
@@ -229,6 +229,18 @@ export function getBindingBackendConfig(binding) {
|
|
|
229
229
|
const backend = execution?.backend;
|
|
230
230
|
return typeof backend === "object" && backend ? backend : undefined;
|
|
231
231
|
}
|
|
232
|
+
export function getBindingInteractionMode(binding) {
|
|
233
|
+
const execution = getBindingExecutionParams(binding);
|
|
234
|
+
const mode = execution?.interactionMode;
|
|
235
|
+
return mode === "invoke" || mode === "stream" ? mode : undefined;
|
|
236
|
+
}
|
|
237
|
+
export function getBindingBuiltinToolsConfig(binding) {
|
|
238
|
+
const execution = getBindingExecutionParams(binding);
|
|
239
|
+
const builtinTools = execution?.builtinTools;
|
|
240
|
+
return typeof builtinTools === "object" && builtinTools
|
|
241
|
+
? builtinTools
|
|
242
|
+
: undefined;
|
|
243
|
+
}
|
|
232
244
|
export function getBindingFilesystemConfig(binding) {
|
|
233
245
|
const langchainFilesystem = binding.harnessRuntime?.langchain?.filesystem;
|
|
234
246
|
if (typeof langchainFilesystem === "object" && langchainFilesystem) {
|
|
@@ -169,6 +169,7 @@ export function requireTools(tools, bindings, ownerId) {
|
|
|
169
169
|
function buildSubagent(agent, workspaceRoot, models, tools, parentSkills, parentModel) {
|
|
170
170
|
const execution = compileExecutionCore(agent, workspaceRoot, models, tools);
|
|
171
171
|
return {
|
|
172
|
+
agentId: agent.id,
|
|
172
173
|
name: resolveAgentRuntimeName(agent),
|
|
173
174
|
description: agent.description,
|
|
174
175
|
systemPrompt: execution.systemPrompt ?? WORKSPACE_BOUNDARY_GUIDANCE,
|
|
@@ -178,6 +179,7 @@ function buildSubagent(agent, workspaceRoot, models, tools, parentSkills, parent
|
|
|
178
179
|
skills: compileAgentSkills(workspaceRoot, agent, parentSkills),
|
|
179
180
|
responseFormat: execution.responseFormat,
|
|
180
181
|
middleware: execution.middleware,
|
|
182
|
+
builtinTools: getAgentExecutionObject(agent, "builtinTools"),
|
|
181
183
|
};
|
|
182
184
|
}
|
|
183
185
|
function resolveSystemPrompt(agent, workspaceRoot) {
|
|
@@ -484,6 +486,12 @@ export function compileBinding(workspaceRoot, agent, agents, referencedSubagentI
|
|
|
484
486
|
name: resolveAgentRuntimeName(agent),
|
|
485
487
|
memory: compiledAgentMemory,
|
|
486
488
|
skills: compiledAgentSkills,
|
|
489
|
+
interactionMode: getAgentExecutionConfigValue(agent, "interactionMode", { executionMode: "deepagent" }) === "invoke"
|
|
490
|
+
? "invoke"
|
|
491
|
+
: getAgentExecutionConfigValue(agent, "interactionMode", { executionMode: "deepagent" }) === "stream"
|
|
492
|
+
? "stream"
|
|
493
|
+
: undefined,
|
|
494
|
+
builtinTools: getAgentExecutionObject(agent, "builtinTools"),
|
|
487
495
|
},
|
|
488
496
|
};
|
|
489
497
|
return attachLegacyExecutionAliases({
|
|
@@ -27,6 +27,8 @@ const CONSUMED_AGENT_CONFIG_KEYS = [
|
|
|
27
27
|
"taskDescription",
|
|
28
28
|
"generalPurposeAgent",
|
|
29
29
|
"filesystem",
|
|
30
|
+
"builtinTools",
|
|
31
|
+
"interactionMode",
|
|
30
32
|
];
|
|
31
33
|
const NON_AGENT_CONFIG_ITEM_KEYS = [
|
|
32
34
|
"id",
|
|
@@ -61,6 +63,8 @@ const MIGRATED_AGENT_CONFIG_KEYS = [
|
|
|
61
63
|
"taskDescription",
|
|
62
64
|
"generalPurposeAgent",
|
|
63
65
|
"filesystem",
|
|
66
|
+
"builtinTools",
|
|
67
|
+
"interactionMode",
|
|
64
68
|
];
|
|
65
69
|
function normalizeAgentItemForMerge(item) {
|
|
66
70
|
const normalized = { ...item };
|
|
@@ -223,6 +227,7 @@ function resolveExecutionBackend(item, current) {
|
|
|
223
227
|
function readSharedAgentConfigFields(config, options = {}) {
|
|
224
228
|
return {
|
|
225
229
|
...(typeof config.store === "object" && config.store ? { store: config.store } : {}),
|
|
230
|
+
...(typeof config.builtinTools === "object" && config.builtinTools ? { builtinTools: cloneConfigValue(config.builtinTools) } : {}),
|
|
226
231
|
...(options.includeDelegationControls && typeof config.taskDescription === "string" && config.taskDescription.trim()
|
|
227
232
|
? { taskDescription: config.taskDescription }
|
|
228
233
|
: {}),
|
|
@@ -258,6 +263,7 @@ function readSharedAgentConfig(config) {
|
|
|
258
263
|
...(config.stateSchema !== undefined ? { stateSchema: config.stateSchema } : {}),
|
|
259
264
|
...(config.responseFormat !== undefined ? { responseFormat: config.responseFormat } : {}),
|
|
260
265
|
...(config.contextSchema !== undefined ? { contextSchema: config.contextSchema } : {}),
|
|
266
|
+
...(config.interactionMode === "stream" || config.interactionMode === "invoke" ? { interactionMode: config.interactionMode } : {}),
|
|
261
267
|
...(config.includeAgentName === "inline" ? { includeAgentName: "inline" } : {}),
|
|
262
268
|
...(config.version === "v1" || config.version === "v2" ? { version: config.version } : {}),
|
|
263
269
|
...(typeof config.filesystem === "object" && config.filesystem ? { filesystem: config.filesystem } : {}),
|