@botbotgo/agent-harness 0.0.112 → 0.0.114
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 +1 -4
- package/dist/package-version.d.ts +1 -1
- package/dist/package-version.js +1 -1
- package/dist/runtime/adapter/middleware-assembly.d.ts +11 -0
- package/dist/runtime/adapter/middleware-assembly.js +67 -46
- package/dist/runtime/adapter/runnable-config.d.ts +0 -1
- package/dist/runtime/adapter/runnable-config.js +0 -1
- package/dist/runtime/support/compiled-binding.js +2 -2
- package/dist/workspace/agent-binding-compiler.js +6 -10
- package/dist/workspace/support/agent-execution-config.js +2 -2
- package/dist/workspace/validate.js +1 -4
- package/package.json +1 -1
|
@@ -139,16 +139,14 @@ export type CompiledSubAgent = {
|
|
|
139
139
|
model?: CompiledModel;
|
|
140
140
|
interruptOn?: Record<string, boolean | object>;
|
|
141
141
|
skills?: string[];
|
|
142
|
-
memory?: string[];
|
|
143
142
|
responseFormat?: unknown;
|
|
144
|
-
contextSchema?: unknown;
|
|
145
143
|
middleware?: Array<Record<string, unknown>>;
|
|
146
|
-
passthrough?: Record<string, unknown>;
|
|
147
144
|
};
|
|
148
145
|
export type LangChainAgentParams = {
|
|
149
146
|
model: CompiledModel;
|
|
150
147
|
tools: CompiledTool[];
|
|
151
148
|
systemPrompt?: string;
|
|
149
|
+
interruptOn?: Record<string, boolean | object>;
|
|
152
150
|
stateSchema?: unknown;
|
|
153
151
|
responseFormat?: unknown;
|
|
154
152
|
contextSchema?: unknown;
|
|
@@ -172,7 +170,6 @@ export type DeepAgentParams = {
|
|
|
172
170
|
responseFormat?: unknown;
|
|
173
171
|
contextSchema?: unknown;
|
|
174
172
|
middleware?: Array<Record<string, unknown>>;
|
|
175
|
-
passthrough?: Record<string, unknown>;
|
|
176
173
|
description: string;
|
|
177
174
|
subagents: CompiledSubAgent[];
|
|
178
175
|
interruptOn?: Record<string, boolean | object>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export declare const AGENT_HARNESS_VERSION = "0.0.113";
|
package/dist/package-version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export const AGENT_HARNESS_VERSION = "0.0.113";
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { FilesystemBackend } from "deepagents";
|
|
2
2
|
import type { CompiledAgentBinding, CompiledModel, CompiledSubAgent, DeepAgentParams, RuntimeAdapterOptions } from "../../contracts/types.js";
|
|
3
3
|
import type { ExecutableTool } from "./flow/invoke-runtime.js";
|
|
4
|
+
export declare function buildBuiltinTaskSubagentRunnableConfig(input: {
|
|
5
|
+
selectedSubagent: CompiledSubAgent;
|
|
6
|
+
defaultModel: unknown;
|
|
7
|
+
defaultTools: unknown[];
|
|
8
|
+
middleware: unknown[];
|
|
9
|
+
}): Record<string, unknown>;
|
|
10
|
+
export declare function buildBuiltinTaskSubagentMiddleware(input: {
|
|
11
|
+
selectedSubagent: CompiledSubAgent;
|
|
12
|
+
builtinBackend: unknown;
|
|
13
|
+
summarizationModel: unknown;
|
|
14
|
+
}): unknown[];
|
|
4
15
|
export declare function resolveBuiltinMiddlewareBackend(input: {
|
|
5
16
|
binding: CompiledAgentBinding;
|
|
6
17
|
runtimeAdapterOptions: RuntimeAdapterOptions;
|
|
@@ -8,6 +8,43 @@ import { isRecord } from "../../utils/object.js";
|
|
|
8
8
|
import { resolveDeclaredMiddleware } from "./tool/declared-middleware.js";
|
|
9
9
|
import { bindingHasLangChainSubagentSupport, bindingHasMiddlewareKind, getBindingDeepAgentParams, getBindingInterruptCompatibilityRules, getBindingLangChainParams, getBindingMiddlewareConfigs, getBindingPrimaryModel, isDeepAgentBinding, isLangChainBinding, } from "../support/compiled-binding.js";
|
|
10
10
|
import { applyDeepAgentDelegationPromptCompatibility, materializeDeepAgentSkillSourcePaths } from "./compat/deepagent-compat.js";
|
|
11
|
+
export function buildBuiltinTaskSubagentRunnableConfig(input) {
|
|
12
|
+
const { selectedSubagent, defaultModel, defaultTools, middleware } = input;
|
|
13
|
+
return {
|
|
14
|
+
model: (selectedSubagent.model ?? defaultModel),
|
|
15
|
+
tools: (selectedSubagent.tools ?? defaultTools),
|
|
16
|
+
systemPrompt: selectedSubagent.systemPrompt ?? DEFAULT_SUBAGENT_PROMPT,
|
|
17
|
+
middleware: middleware,
|
|
18
|
+
responseFormat: selectedSubagent.responseFormat,
|
|
19
|
+
name: selectedSubagent.name,
|
|
20
|
+
description: selectedSubagent.description,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function buildBuiltinTaskSubagentMiddleware(input) {
|
|
24
|
+
const { selectedSubagent, builtinBackend, summarizationModel } = input;
|
|
25
|
+
const defaultSubagentMiddleware = [
|
|
26
|
+
createPatchToolCallsMiddleware(),
|
|
27
|
+
createSummarizationMiddleware({
|
|
28
|
+
model: summarizationModel,
|
|
29
|
+
backend: builtinBackend,
|
|
30
|
+
}),
|
|
31
|
+
];
|
|
32
|
+
const subagentSkillsMiddleware = selectedSubagent.skills?.length
|
|
33
|
+
? [createSkillsMiddleware({ backend: builtinBackend, sources: selectedSubagent.skills })]
|
|
34
|
+
: [];
|
|
35
|
+
const subagentMiddleware = selectedSubagent.middleware ?? [];
|
|
36
|
+
const interruptMiddleware = selectedSubagent.interruptOn
|
|
37
|
+
? [humanInTheLoopMiddleware({
|
|
38
|
+
interruptOn: compileInterruptOn(selectedSubagent.tools ?? [], selectedSubagent.interruptOn),
|
|
39
|
+
})]
|
|
40
|
+
: [];
|
|
41
|
+
return [
|
|
42
|
+
...defaultSubagentMiddleware,
|
|
43
|
+
...subagentSkillsMiddleware,
|
|
44
|
+
...subagentMiddleware,
|
|
45
|
+
...interruptMiddleware,
|
|
46
|
+
];
|
|
47
|
+
}
|
|
11
48
|
function buildLangChainContextMiddleware(params) {
|
|
12
49
|
const middleware = [];
|
|
13
50
|
const hasSkills = (params.compatibleParams.skills?.length ?? 0) > 0;
|
|
@@ -51,22 +88,26 @@ export function resolveBuiltinMiddlewareBackend(input) {
|
|
|
51
88
|
return new StateBackend(runtimeLike);
|
|
52
89
|
}
|
|
53
90
|
export async function resolveSubagents(input) {
|
|
54
|
-
return Promise.all(input.subagents.map(async (subagent) =>
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
91
|
+
return Promise.all(input.subagents.map(async (subagent) => {
|
|
92
|
+
// Only pass DeepAgents-supported subagent fields through to upstream middleware.
|
|
93
|
+
// Harness-only extensions stay internal instead of becoming a second subagent dialect.
|
|
94
|
+
return {
|
|
95
|
+
name: subagent.name,
|
|
96
|
+
description: subagent.description,
|
|
97
|
+
systemPrompt: subagent.systemPrompt,
|
|
98
|
+
model: subagent.model ? (await input.resolveModel(subagent.model)) : undefined,
|
|
99
|
+
tools: subagent.tools ? input.resolveTools(subagent.tools, input.binding) : undefined,
|
|
100
|
+
skills: await materializeDeepAgentSkillSourcePaths({
|
|
101
|
+
workspaceRoot: input.binding?.harnessRuntime.workspaceRoot,
|
|
102
|
+
runRoot: input.binding?.harnessRuntime.runRoot,
|
|
103
|
+
ownerId: `${input.binding?.agent.id ?? "agent"}-${subagent.name}`,
|
|
104
|
+
skillPaths: subagent.skills,
|
|
105
|
+
}),
|
|
106
|
+
interruptOn: compileInterruptOn(subagent.tools ?? [], subagent.interruptOn),
|
|
107
|
+
responseFormat: subagent.responseFormat,
|
|
108
|
+
middleware: (await resolveDeclaredMiddleware(subagent.middleware, input.createDeclaredMiddlewareResolverOptions(input.binding))),
|
|
109
|
+
};
|
|
110
|
+
}));
|
|
70
111
|
}
|
|
71
112
|
export async function invokeBuiltinTaskTool(input) {
|
|
72
113
|
if (!isDeepAgentBinding(input.binding)) {
|
|
@@ -89,37 +130,17 @@ export async function invokeBuiltinTaskTool(input) {
|
|
|
89
130
|
const summarizationModel = selectedSubagent.model
|
|
90
131
|
? await input.resolveModel(selectedSubagent.model)
|
|
91
132
|
: await input.resolveModel(params.model);
|
|
92
|
-
const middleware =
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
...(selectedSubagent.memory?.length
|
|
97
|
-
? [createMemoryMiddleware({ backend: builtinBackend, sources: selectedSubagent.memory })]
|
|
98
|
-
: []),
|
|
99
|
-
...(selectedSubagent.middleware ??
|
|
100
|
-
[
|
|
101
|
-
createPatchToolCallsMiddleware(),
|
|
102
|
-
createSummarizationMiddleware({
|
|
103
|
-
model: summarizationModel,
|
|
104
|
-
backend: builtinBackend,
|
|
105
|
-
}),
|
|
106
|
-
]),
|
|
107
|
-
...(selectedSubagent.interruptOn
|
|
108
|
-
? [humanInTheLoopMiddleware({
|
|
109
|
-
interruptOn: compileInterruptOn(selectedSubagent.tools ?? [], selectedSubagent.interruptOn),
|
|
110
|
-
})]
|
|
111
|
-
: []),
|
|
112
|
-
];
|
|
113
|
-
const runnable = createAgent({
|
|
114
|
-
model: (selectedSubagent.model ?? (await input.resolveModel(params.model))),
|
|
115
|
-
tools: (selectedSubagent.tools ?? input.resolveTools(params.tools, input.binding)),
|
|
116
|
-
systemPrompt: selectedSubagent.systemPrompt ?? DEFAULT_SUBAGENT_PROMPT,
|
|
117
|
-
middleware: middleware,
|
|
118
|
-
responseFormat: selectedSubagent.responseFormat,
|
|
119
|
-
contextSchema: selectedSubagent.contextSchema,
|
|
120
|
-
name: selectedSubagent.name,
|
|
121
|
-
description: selectedSubagent.description,
|
|
133
|
+
const middleware = buildBuiltinTaskSubagentMiddleware({
|
|
134
|
+
selectedSubagent,
|
|
135
|
+
builtinBackend,
|
|
136
|
+
summarizationModel,
|
|
122
137
|
});
|
|
138
|
+
const runnable = createAgent(buildBuiltinTaskSubagentRunnableConfig({
|
|
139
|
+
selectedSubagent,
|
|
140
|
+
defaultModel: await input.resolveModel(params.model),
|
|
141
|
+
defaultTools: input.resolveTools(params.tools, input.binding),
|
|
142
|
+
middleware,
|
|
143
|
+
}));
|
|
123
144
|
const result = await runnable.invoke({ messages: [new HumanMessage({ content: description })] }, { configurable: { thread_id: `${input.binding.agent.id}:builtin-task` }, ...(input.options?.context ? { context: input.options.context } : {}) });
|
|
124
145
|
const visibleOutput = extractVisibleOutput(result);
|
|
125
146
|
const fallbackOutput = extractToolFallbackContext(result);
|
|
@@ -37,7 +37,6 @@ export function buildLangChainRunnableConfig(params) {
|
|
|
37
37
|
export function buildDeepAgentRunnableConfig(params) {
|
|
38
38
|
const { compatibleParams, resolvedModel, resolvedTools, resolvedMiddleware, resolvedSubagents, resolvedCheckpointer, resolvedStore, resolvedBackend, resolvedInterruptOn, resolvedSkills, } = params;
|
|
39
39
|
return buildResolvedRunnableConfig({
|
|
40
|
-
passthrough: compatibleParams.passthrough ?? {},
|
|
41
40
|
staticConfig: {
|
|
42
41
|
systemPrompt: compatibleParams.systemPrompt,
|
|
43
42
|
responseFormat: compatibleParams.responseFormat,
|
|
@@ -31,8 +31,8 @@ function deriveBindingExecutionView(binding) {
|
|
|
31
31
|
systemPrompt: langchainParams?.systemPrompt ?? deepAgentParams?.systemPrompt,
|
|
32
32
|
middlewareConfigs,
|
|
33
33
|
middlewareKinds,
|
|
34
|
-
interruptCompatibilityRules:
|
|
35
|
-
|
|
34
|
+
interruptCompatibilityRules: langchainParams?.interruptOn ??
|
|
35
|
+
deepAgentParams?.interruptOn,
|
|
36
36
|
storeConfig: deepAgentParams?.store ?? binding.harnessRuntime?.store,
|
|
37
37
|
langChainSubagentSupport: (langchainParams?.subagents?.length ?? 0) > 0 ||
|
|
38
38
|
langchainParams?.generalPurposeAgent === true ||
|
|
@@ -87,8 +87,7 @@ export function requireTools(tools, refs, ownerId) {
|
|
|
87
87
|
}
|
|
88
88
|
return Array.from(deduped.values());
|
|
89
89
|
}
|
|
90
|
-
function buildSubagent(agent, workspaceRoot, models, tools, parentSkills, parentModel
|
|
91
|
-
const ownMemory = compileAgentMemories(workspaceRoot, agent.memorySources);
|
|
90
|
+
function buildSubagent(agent, workspaceRoot, models, tools, parentSkills, parentModel) {
|
|
92
91
|
const execution = compileExecutionCore(agent, models, tools);
|
|
93
92
|
return {
|
|
94
93
|
name: resolveAgentRuntimeName(agent),
|
|
@@ -98,11 +97,8 @@ function buildSubagent(agent, workspaceRoot, models, tools, parentSkills, parent
|
|
|
98
97
|
model: agent.modelRef ? execution.model : parentModel,
|
|
99
98
|
interruptOn: resolveInterruptOn(agent),
|
|
100
99
|
skills: compileAgentSkills(workspaceRoot, agent, parentSkills),
|
|
101
|
-
memory: ownMemory.length > 0 ? ownMemory : parentMemory,
|
|
102
100
|
responseFormat: execution.responseFormat,
|
|
103
|
-
contextSchema: execution.contextSchema,
|
|
104
101
|
middleware: execution.middleware,
|
|
105
|
-
passthrough: execution.passthrough,
|
|
106
102
|
};
|
|
107
103
|
}
|
|
108
104
|
function resolveSystemPrompt(agent) {
|
|
@@ -129,13 +125,13 @@ function resolvePassthrough(agent) {
|
|
|
129
125
|
const passthrough = getAgentExecutionObject(agent, "passthrough");
|
|
130
126
|
return passthrough ? { ...passthrough } : undefined;
|
|
131
127
|
}
|
|
132
|
-
function compileSubagents(agent, agents, workspaceRoot, models, tools, compiledAgentSkills, compiledAgentModel
|
|
128
|
+
function compileSubagents(agent, agents, workspaceRoot, models, tools, compiledAgentSkills, compiledAgentModel) {
|
|
133
129
|
return agent.subagentRefs.map((ref) => {
|
|
134
130
|
const subagent = agents.get(resolveRefId(ref));
|
|
135
131
|
if (!subagent) {
|
|
136
132
|
throw new Error(`Missing subagent ${ref} for agent ${agent.id}`);
|
|
137
133
|
}
|
|
138
|
-
return buildSubagent(subagent, workspaceRoot, models, tools, compiledAgentSkills, compiledAgentModel
|
|
134
|
+
return buildSubagent(subagent, workspaceRoot, models, tools, compiledAgentSkills, compiledAgentModel);
|
|
139
135
|
});
|
|
140
136
|
}
|
|
141
137
|
function compileExecutionCore(agent, models, tools) {
|
|
@@ -293,13 +289,14 @@ export function compileBinding(workspaceRoot, agent, agents, referencedSubagentI
|
|
|
293
289
|
model: execution.model,
|
|
294
290
|
tools: execution.tools,
|
|
295
291
|
systemPrompt: execution.systemPrompt,
|
|
292
|
+
interruptOn: resolveInterruptOn(agent),
|
|
296
293
|
stateSchema: getAgentExecutionConfigValue(agent, "stateSchema", { executionMode: "langchain-v1" }),
|
|
297
294
|
responseFormat: execution.responseFormat,
|
|
298
295
|
contextSchema: execution.contextSchema,
|
|
299
296
|
filesystem: getAgentExecutionObject(agent, "filesystem", { executionMode: "langchain-v1" }),
|
|
300
297
|
middleware: execution.middleware,
|
|
301
298
|
passthrough: execution.passthrough,
|
|
302
|
-
subagents: compileSubagents(agent, agents, workspaceRoot, models, tools, compiledAgentSkills, compiledAgentModel
|
|
299
|
+
subagents: compileSubagents(agent, agents, workspaceRoot, models, tools, compiledAgentSkills, compiledAgentModel),
|
|
303
300
|
memory: compiledAgentMemory,
|
|
304
301
|
skills: compiledAgentSkills,
|
|
305
302
|
generalPurposeAgent: getAgentExecutionConfigValue(agent, "generalPurposeAgent", { executionMode: "langchain-v1" }),
|
|
@@ -329,9 +326,8 @@ export function compileBinding(workspaceRoot, agent, agents, referencedSubagentI
|
|
|
329
326
|
responseFormat: execution.responseFormat,
|
|
330
327
|
contextSchema: execution.contextSchema,
|
|
331
328
|
middleware: execution.middleware,
|
|
332
|
-
passthrough: execution.passthrough,
|
|
333
329
|
description: agent.description,
|
|
334
|
-
subagents: compileSubagents(agent, agents, workspaceRoot, models, tools, compiledAgentSkills, compiledAgentModel
|
|
330
|
+
subagents: compileSubagents(agent, agents, workspaceRoot, models, tools, compiledAgentSkills, compiledAgentModel),
|
|
335
331
|
interruptOn: resolveInterruptOn(agent),
|
|
336
332
|
...(backend ? { backend: backend.config } : {}),
|
|
337
333
|
...(store ? { store: store.config } : {}),
|
|
@@ -8,8 +8,8 @@ function deriveAgentExecutionViews(agent) {
|
|
|
8
8
|
const langchainConfig = asRecord(agent.langchainAgentConfig);
|
|
9
9
|
const deepAgentConfig = asRecord(agent.deepAgentConfig);
|
|
10
10
|
const views = {
|
|
11
|
-
"langchain-v1": [langchainConfig
|
|
12
|
-
deepagent: [deepAgentConfig
|
|
11
|
+
"langchain-v1": [langchainConfig ?? {}],
|
|
12
|
+
deepagent: [deepAgentConfig ?? {}],
|
|
13
13
|
};
|
|
14
14
|
agentExecutionViewsCache.set(agent, views);
|
|
15
15
|
return views;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isDelegationCapableAgent, isMemoryCapableAgent, } from "./support/agent-capabilities.js";
|
|
2
2
|
import { getAgentExecutionConfigValue, getAgentExecutionConfigs } from "./support/agent-execution-config.js";
|
|
3
3
|
const allowedExecutionModes = new Set(["deepagent", "langchain-v1"]);
|
|
4
4
|
function validateCheckpointerConfig(agent) {
|
|
@@ -88,8 +88,5 @@ export function validateTopology(agents) {
|
|
|
88
88
|
if (!isDelegationCapableAgent(agent)) {
|
|
89
89
|
throw new Error(`Subagent ${agent.id} must use a delegation-capable backend`);
|
|
90
90
|
}
|
|
91
|
-
if (!hasAgentSystemPrompt(agent)) {
|
|
92
|
-
throw new Error(`Subagent ${agent.id} requires systemPrompt`);
|
|
93
|
-
}
|
|
94
91
|
}
|
|
95
92
|
}
|