@botbotgo/agent-harness 0.0.112 → 0.0.113
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 +0 -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/workspace/agent-binding-compiler.js +5 -10
- package/package.json +1 -1
|
@@ -139,11 +139,8 @@ 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;
|
|
@@ -172,7 +169,6 @@ export type DeepAgentParams = {
|
|
|
172
169
|
responseFormat?: unknown;
|
|
173
170
|
contextSchema?: unknown;
|
|
174
171
|
middleware?: Array<Record<string, unknown>>;
|
|
175
|
-
passthrough?: Record<string, unknown>;
|
|
176
172
|
description: string;
|
|
177
173
|
subagents: CompiledSubAgent[];
|
|
178
174
|
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.112";
|
package/dist/package-version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export const AGENT_HARNESS_VERSION = "0.0.112";
|
|
@@ -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,
|
|
@@ -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) {
|
|
@@ -299,7 +295,7 @@ export function compileBinding(workspaceRoot, agent, agents, referencedSubagentI
|
|
|
299
295
|
filesystem: getAgentExecutionObject(agent, "filesystem", { executionMode: "langchain-v1" }),
|
|
300
296
|
middleware: execution.middleware,
|
|
301
297
|
passthrough: execution.passthrough,
|
|
302
|
-
subagents: compileSubagents(agent, agents, workspaceRoot, models, tools, compiledAgentSkills, compiledAgentModel
|
|
298
|
+
subagents: compileSubagents(agent, agents, workspaceRoot, models, tools, compiledAgentSkills, compiledAgentModel),
|
|
303
299
|
memory: compiledAgentMemory,
|
|
304
300
|
skills: compiledAgentSkills,
|
|
305
301
|
generalPurposeAgent: getAgentExecutionConfigValue(agent, "generalPurposeAgent", { executionMode: "langchain-v1" }),
|
|
@@ -329,9 +325,8 @@ export function compileBinding(workspaceRoot, agent, agents, referencedSubagentI
|
|
|
329
325
|
responseFormat: execution.responseFormat,
|
|
330
326
|
contextSchema: execution.contextSchema,
|
|
331
327
|
middleware: execution.middleware,
|
|
332
|
-
passthrough: execution.passthrough,
|
|
333
328
|
description: agent.description,
|
|
334
|
-
subagents: compileSubagents(agent, agents, workspaceRoot, models, tools, compiledAgentSkills, compiledAgentModel
|
|
329
|
+
subagents: compileSubagents(agent, agents, workspaceRoot, models, tools, compiledAgentSkills, compiledAgentModel),
|
|
335
330
|
interruptOn: resolveInterruptOn(agent),
|
|
336
331
|
...(backend ? { backend: backend.config } : {}),
|
|
337
332
|
...(store ? { store: store.config } : {}),
|