@botbotgo/agent-harness 0.0.119 → 0.0.121
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/api.d.ts +1 -0
- package/dist/api.js +1 -0
- package/dist/contracts/runtime.d.ts +3 -113
- package/dist/contracts/workspace.d.ts +30 -12
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/package-version.d.ts +1 -1
- package/dist/package-version.js +1 -1
- package/dist/runtime/adapter/middleware-assembly.d.ts +28 -4
- package/dist/runtime/adapter/middleware-assembly.js +65 -30
- package/dist/runtime/adapter/stream-event-projection.d.ts +0 -1
- package/dist/runtime/adapter/stream-event-projection.js +2 -8
- package/dist/runtime/agent-runtime-adapter.d.ts +2 -2
- package/dist/runtime/agent-runtime-adapter.js +39 -29
- package/dist/runtime/harness/events/listener-runtime.d.ts +3 -2
- package/dist/runtime/harness/events/streaming.d.ts +24 -3
- package/dist/runtime/harness/events/streaming.js +0 -20
- package/dist/runtime/harness/run/stream-run.d.ts +4 -6
- package/dist/runtime/harness/run/stream-run.js +1 -31
- package/dist/runtime/harness.js +10 -11
- package/dist/runtime/parsing/index.d.ts +1 -1
- package/dist/runtime/parsing/index.js +1 -1
- package/dist/runtime/parsing/stream-event-parsing.d.ts +1 -8
- package/dist/runtime/parsing/stream-event-parsing.js +0 -321
- package/dist/runtime/support/compiled-binding.d.ts +5 -5
- package/dist/runtime/support/compiled-binding.js +67 -27
- package/dist/upstream-events.d.ts +20 -0
- package/dist/upstream-events.js +172 -0
- package/dist/utils/compiled-binding.d.ts +3 -0
- package/dist/utils/compiled-binding.js +33 -0
- package/dist/workspace/agent-binding-compiler.js +28 -17
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { attachLegacyExecutionAliases, stripLegacyExecutionAliases } from "../../utils/compiled-binding.js";
|
|
1
2
|
import { asRecord } from "../../utils/object.js";
|
|
2
3
|
const bindingExecutionViewCache = new WeakMap();
|
|
3
4
|
function getLegacyAdapterParams(binding) {
|
|
@@ -21,11 +22,11 @@ function inferBindingAdapterKind(binding) {
|
|
|
21
22
|
function normalizeBindingExecution(binding) {
|
|
22
23
|
const adapterKind = inferBindingAdapterKind(binding);
|
|
23
24
|
if (binding.execution?.kind === "langchain-v1") {
|
|
24
|
-
binding
|
|
25
|
+
attachLegacyExecutionAliases(binding);
|
|
25
26
|
return { adapterKind, execution: binding.execution };
|
|
26
27
|
}
|
|
27
28
|
if (binding.execution?.kind === "deepagent") {
|
|
28
|
-
binding
|
|
29
|
+
attachLegacyExecutionAliases(binding);
|
|
29
30
|
return { adapterKind, execution: binding.execution };
|
|
30
31
|
}
|
|
31
32
|
if (adapterKind !== "langchain-v1" && adapterKind !== "deepagent") {
|
|
@@ -37,6 +38,7 @@ function normalizeBindingExecution(binding) {
|
|
|
37
38
|
params: binding.langchainAgentParams,
|
|
38
39
|
};
|
|
39
40
|
binding.execution = execution;
|
|
41
|
+
attachLegacyExecutionAliases(binding);
|
|
40
42
|
return { adapterKind, execution };
|
|
41
43
|
}
|
|
42
44
|
if (binding.deepAgentParams) {
|
|
@@ -45,25 +47,26 @@ function normalizeBindingExecution(binding) {
|
|
|
45
47
|
params: binding.deepAgentParams,
|
|
46
48
|
};
|
|
47
49
|
binding.execution = execution;
|
|
50
|
+
attachLegacyExecutionAliases(binding);
|
|
48
51
|
return { adapterKind, execution };
|
|
49
52
|
}
|
|
50
53
|
const legacyAdapterParams = getLegacyAdapterParams(binding);
|
|
51
54
|
if (adapterKind === "langchain-v1" && legacyAdapterParams) {
|
|
52
55
|
const params = legacyAdapterParams;
|
|
53
|
-
binding.langchainAgentParams = params;
|
|
54
56
|
binding.execution = {
|
|
55
57
|
kind: "langchain-v1",
|
|
56
58
|
params,
|
|
57
59
|
};
|
|
60
|
+
attachLegacyExecutionAliases(binding);
|
|
58
61
|
return { adapterKind, execution: binding.execution };
|
|
59
62
|
}
|
|
60
63
|
if (adapterKind === "deepagent" && legacyAdapterParams) {
|
|
61
64
|
const params = legacyAdapterParams;
|
|
62
|
-
binding.deepAgentParams = params;
|
|
63
65
|
binding.execution = {
|
|
64
66
|
kind: "deepagent",
|
|
65
67
|
params,
|
|
66
68
|
};
|
|
69
|
+
attachLegacyExecutionAliases(binding);
|
|
67
70
|
return { adapterKind, execution: binding.execution };
|
|
68
71
|
}
|
|
69
72
|
return { adapterKind };
|
|
@@ -75,13 +78,16 @@ function deriveBindingExecutionView(binding) {
|
|
|
75
78
|
}
|
|
76
79
|
const normalized = normalizeBindingExecution(binding);
|
|
77
80
|
const adapterKind = normalized.adapterKind;
|
|
78
|
-
const langchainParams = normalized.execution?.kind === "langchain-v1" ?
|
|
79
|
-
const deepAgentParams = normalized.execution?.kind === "deepagent" ?
|
|
81
|
+
const langchainParams = normalized.execution?.kind === "langchain-v1" ? binding.langchainAgentParams : undefined;
|
|
82
|
+
const deepAgentParams = normalized.execution?.kind === "deepagent" ? binding.deepAgentParams : undefined;
|
|
83
|
+
const canonicalLangchainParams = normalized.execution?.kind === "langchain-v1" ? normalized.execution.params : undefined;
|
|
84
|
+
const canonicalDeepAgentParams = normalized.execution?.kind === "deepagent" ? normalized.execution.params : undefined;
|
|
80
85
|
const primaryTools = langchainParams?.tools ?? deepAgentParams?.tools ?? [];
|
|
81
86
|
const middlewareConfigs = langchainParams?.middleware ?? deepAgentParams?.middleware;
|
|
82
87
|
const middlewareKinds = new Set((middlewareConfigs ?? [])
|
|
83
88
|
.map((entry) => typeof entry.kind === "string" ? entry.kind : "")
|
|
84
89
|
.filter(Boolean));
|
|
90
|
+
const langchainRuntimeConfig = binding.harnessRuntime?.langchain;
|
|
85
91
|
const view = {
|
|
86
92
|
adapterKind,
|
|
87
93
|
langchainParams,
|
|
@@ -93,13 +99,14 @@ function deriveBindingExecutionView(binding) {
|
|
|
93
99
|
systemPrompt: langchainParams?.systemPrompt ?? deepAgentParams?.systemPrompt,
|
|
94
100
|
middlewareConfigs,
|
|
95
101
|
middlewareKinds,
|
|
96
|
-
interruptCompatibilityRules:
|
|
102
|
+
interruptCompatibilityRules: langchainRuntimeConfig?.interruptOn ??
|
|
103
|
+
langchainParams?.interruptOn ??
|
|
97
104
|
deepAgentParams?.interruptOn,
|
|
98
|
-
storeConfig:
|
|
99
|
-
langChainSubagentSupport: (
|
|
100
|
-
langchainParams?.generalPurposeAgent === true ||
|
|
101
|
-
Boolean(langchainParams?.taskDescription?.trim()),
|
|
102
|
-
deepAgentSubagentCount:
|
|
105
|
+
storeConfig: canonicalDeepAgentParams?.store ?? binding.harnessRuntime?.store,
|
|
106
|
+
langChainSubagentSupport: (langchainRuntimeConfig?.subagents?.length ?? 0) > 0 ||
|
|
107
|
+
(langchainRuntimeConfig?.generalPurposeAgent ?? langchainParams?.generalPurposeAgent) === true ||
|
|
108
|
+
Boolean((langchainRuntimeConfig?.taskDescription ?? langchainParams?.taskDescription)?.trim()),
|
|
109
|
+
deepAgentSubagentCount: canonicalDeepAgentParams?.subagents?.length ?? 0,
|
|
103
110
|
};
|
|
104
111
|
bindingExecutionViewCache.set(binding, view);
|
|
105
112
|
return view;
|
|
@@ -137,48 +144,78 @@ export function withUpdatedBindingExecutionParams(binding, updater) {
|
|
|
137
144
|
}
|
|
138
145
|
const updatedParams = updater(params);
|
|
139
146
|
if (kind === "langchain-v1") {
|
|
140
|
-
return {
|
|
141
|
-
...binding,
|
|
147
|
+
return attachLegacyExecutionAliases({
|
|
148
|
+
...stripLegacyExecutionAliases(binding),
|
|
142
149
|
execution: {
|
|
143
150
|
kind,
|
|
144
151
|
params: updatedParams,
|
|
145
152
|
},
|
|
146
|
-
|
|
147
|
-
};
|
|
153
|
+
});
|
|
148
154
|
}
|
|
149
|
-
return {
|
|
150
|
-
...binding,
|
|
155
|
+
return attachLegacyExecutionAliases({
|
|
156
|
+
...stripLegacyExecutionAliases(binding),
|
|
151
157
|
execution: {
|
|
152
158
|
kind,
|
|
153
159
|
params: updatedParams,
|
|
154
160
|
},
|
|
155
|
-
|
|
156
|
-
};
|
|
161
|
+
});
|
|
157
162
|
}
|
|
158
163
|
export function getBindingSkills(binding) {
|
|
164
|
+
const langchainSkills = binding.harnessRuntime?.langchain?.skills;
|
|
165
|
+
if (Array.isArray(langchainSkills)) {
|
|
166
|
+
return langchainSkills;
|
|
167
|
+
}
|
|
168
|
+
const legacyLangchainSkills = binding.langchainAgentParams?.skills;
|
|
169
|
+
if (Array.isArray(legacyLangchainSkills)) {
|
|
170
|
+
return legacyLangchainSkills;
|
|
171
|
+
}
|
|
159
172
|
const execution = getBindingExecutionParams(binding);
|
|
160
|
-
return Array.isArray(execution?.skills)
|
|
173
|
+
return Array.isArray(execution?.skills)
|
|
174
|
+
? (execution.skills)
|
|
175
|
+
: [];
|
|
161
176
|
}
|
|
162
177
|
export function getBindingMemorySources(binding) {
|
|
178
|
+
const langchainMemory = binding.harnessRuntime?.langchain?.memory;
|
|
179
|
+
if (Array.isArray(langchainMemory)) {
|
|
180
|
+
return langchainMemory;
|
|
181
|
+
}
|
|
182
|
+
const legacyLangchainMemory = binding.langchainAgentParams?.memory;
|
|
183
|
+
if (Array.isArray(legacyLangchainMemory)) {
|
|
184
|
+
return legacyLangchainMemory;
|
|
185
|
+
}
|
|
163
186
|
const execution = getBindingExecutionParams(binding);
|
|
164
187
|
return Array.isArray(execution?.memory)
|
|
165
188
|
? (execution.memory)
|
|
166
189
|
: [];
|
|
167
190
|
}
|
|
168
191
|
export function getBindingSubagents(binding) {
|
|
192
|
+
const langchainSubagents = binding.harnessRuntime?.langchain?.subagents;
|
|
193
|
+
if (Array.isArray(langchainSubagents)) {
|
|
194
|
+
return langchainSubagents;
|
|
195
|
+
}
|
|
196
|
+
const legacyLangchainSubagents = binding.langchainAgentParams?.subagents;
|
|
197
|
+
if (Array.isArray(legacyLangchainSubagents)) {
|
|
198
|
+
return legacyLangchainSubagents;
|
|
199
|
+
}
|
|
169
200
|
const execution = getBindingExecutionParams(binding);
|
|
170
201
|
return Array.isArray(execution?.subagents)
|
|
171
202
|
? (execution.subagents)
|
|
172
203
|
: [];
|
|
173
204
|
}
|
|
174
205
|
export function getBindingGeneralPurposeAgent(binding) {
|
|
175
|
-
const
|
|
176
|
-
|
|
206
|
+
const langchainGeneralPurposeAgent = binding.harnessRuntime?.langchain?.generalPurposeAgent;
|
|
207
|
+
if (typeof langchainGeneralPurposeAgent === "boolean") {
|
|
208
|
+
return langchainGeneralPurposeAgent;
|
|
209
|
+
}
|
|
210
|
+
const value = binding.langchainAgentParams?.generalPurposeAgent;
|
|
177
211
|
return typeof value === "boolean" ? value : undefined;
|
|
178
212
|
}
|
|
179
213
|
export function getBindingTaskDescription(binding) {
|
|
180
|
-
const
|
|
181
|
-
|
|
214
|
+
const langchainTaskDescription = binding.harnessRuntime?.langchain?.taskDescription;
|
|
215
|
+
if (typeof langchainTaskDescription === "string" && langchainTaskDescription.trim().length > 0) {
|
|
216
|
+
return langchainTaskDescription;
|
|
217
|
+
}
|
|
218
|
+
const value = binding.langchainAgentParams?.taskDescription;
|
|
182
219
|
return typeof value === "string" && value.trim().length > 0 ? value : undefined;
|
|
183
220
|
}
|
|
184
221
|
export function getBindingBackendConfig(binding) {
|
|
@@ -187,8 +224,11 @@ export function getBindingBackendConfig(binding) {
|
|
|
187
224
|
return typeof backend === "object" && backend ? backend : undefined;
|
|
188
225
|
}
|
|
189
226
|
export function getBindingFilesystemConfig(binding) {
|
|
190
|
-
const
|
|
191
|
-
|
|
227
|
+
const langchainFilesystem = binding.harnessRuntime?.langchain?.filesystem;
|
|
228
|
+
if (typeof langchainFilesystem === "object" && langchainFilesystem) {
|
|
229
|
+
return langchainFilesystem;
|
|
230
|
+
}
|
|
231
|
+
const filesystem = binding.langchainAgentParams?.filesystem;
|
|
192
232
|
return typeof filesystem === "object" && filesystem ? filesystem : undefined;
|
|
193
233
|
}
|
|
194
234
|
export function isLangChainBinding(binding) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type UpstreamTimelineProjection = {
|
|
2
|
+
type: "thinking";
|
|
3
|
+
text: string;
|
|
4
|
+
} | {
|
|
5
|
+
type: "step";
|
|
6
|
+
step: string;
|
|
7
|
+
category: "llm" | "tool" | "skill" | "memory" | "chain" | "approval";
|
|
8
|
+
status: "started" | "completed" | "failed";
|
|
9
|
+
key: string;
|
|
10
|
+
} | {
|
|
11
|
+
type: "tool-result";
|
|
12
|
+
toolName: string;
|
|
13
|
+
output: unknown;
|
|
14
|
+
isError?: boolean;
|
|
15
|
+
key: string;
|
|
16
|
+
};
|
|
17
|
+
export type UpstreamTimelineReducer = {
|
|
18
|
+
consume: (event: unknown) => UpstreamTimelineProjection[];
|
|
19
|
+
};
|
|
20
|
+
export declare function createUpstreamTimelineReducer(): UpstreamTimelineReducer;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { extractInterruptPayload, extractReasoningStreamOutput, extractToolResult } from "./runtime/parsing/index.js";
|
|
2
|
+
function asObject(value) {
|
|
3
|
+
return typeof value === "object" && value !== null ? value : null;
|
|
4
|
+
}
|
|
5
|
+
function readStringArray(value) {
|
|
6
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
7
|
+
}
|
|
8
|
+
function normalizeSegment(value) {
|
|
9
|
+
return value
|
|
10
|
+
.replace(/[_-]+/g, " ")
|
|
11
|
+
.replace(/\s+/g, " ")
|
|
12
|
+
.trim();
|
|
13
|
+
}
|
|
14
|
+
function titleCase(value) {
|
|
15
|
+
return normalizeSegment(value)
|
|
16
|
+
.split(" ")
|
|
17
|
+
.filter(Boolean)
|
|
18
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
19
|
+
.join(" ");
|
|
20
|
+
}
|
|
21
|
+
function readEventContext(event) {
|
|
22
|
+
const typed = asObject(event);
|
|
23
|
+
return {
|
|
24
|
+
eventName: typeof typed?.event === 'string' ? typed.event : "",
|
|
25
|
+
name: typeof typed?.name === 'string' ? typed.name : "",
|
|
26
|
+
runType: typeof typed?.run_type === 'string' ? typed.run_type : "",
|
|
27
|
+
tags: readStringArray(typed?.tags),
|
|
28
|
+
ns: readStringArray(typed?.ns),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function containsSemanticHint(values, hint) {
|
|
32
|
+
return values.some((value) => hint.test(value));
|
|
33
|
+
}
|
|
34
|
+
function classifyStepCategory(context) {
|
|
35
|
+
const hints = [context.name, context.runType, ...context.tags, ...context.ns].map((value) => value.toLowerCase());
|
|
36
|
+
if (containsSemanticHint(hints, /\b(skill|skills)\b/)) {
|
|
37
|
+
return "skill";
|
|
38
|
+
}
|
|
39
|
+
if (containsSemanticHint(hints, /\b(memory|recall|store|checkpoint)\b/)) {
|
|
40
|
+
return "memory";
|
|
41
|
+
}
|
|
42
|
+
if (context.eventName.startsWith("on_tool_") || context.runType === "tool") {
|
|
43
|
+
return "tool";
|
|
44
|
+
}
|
|
45
|
+
return "chain";
|
|
46
|
+
}
|
|
47
|
+
function buildStepLabel(category, status, name) {
|
|
48
|
+
const displayName = titleCase(name || category);
|
|
49
|
+
if (category === "llm") {
|
|
50
|
+
return status === "started" ? `Calling LLM ${displayName}` : `Completed LLM ${displayName}`;
|
|
51
|
+
}
|
|
52
|
+
if (category === "tool") {
|
|
53
|
+
if (status === "failed") {
|
|
54
|
+
return `Tool ${displayName} failed`;
|
|
55
|
+
}
|
|
56
|
+
return status === "started" ? `Calling tool ${displayName}` : `Completed tool ${displayName}`;
|
|
57
|
+
}
|
|
58
|
+
if (category === "skill") {
|
|
59
|
+
return status === "started" ? `Calling skill ${displayName}` : `Completed skill ${displayName}`;
|
|
60
|
+
}
|
|
61
|
+
if (category === "memory") {
|
|
62
|
+
return status === "started" ? `Accessing memory ${displayName}` : `Completed memory ${displayName}`;
|
|
63
|
+
}
|
|
64
|
+
return status === "started" ? `Running ${displayName}` : `Completed ${displayName}`;
|
|
65
|
+
}
|
|
66
|
+
function createProjectionKey(parts) {
|
|
67
|
+
return JSON.stringify(parts);
|
|
68
|
+
}
|
|
69
|
+
export function createUpstreamTimelineReducer() {
|
|
70
|
+
const emittedStepKeys = new Set();
|
|
71
|
+
const emittedToolResultKeys = new Set();
|
|
72
|
+
return {
|
|
73
|
+
consume(event) {
|
|
74
|
+
const projections = [];
|
|
75
|
+
const context = readEventContext(event);
|
|
76
|
+
const reasoning = extractReasoningStreamOutput(event);
|
|
77
|
+
if (reasoning) {
|
|
78
|
+
projections.push({
|
|
79
|
+
type: "thinking",
|
|
80
|
+
text: reasoning,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const interruptPayload = extractInterruptPayload(event);
|
|
84
|
+
if (interruptPayload) {
|
|
85
|
+
const key = createProjectionKey(["approval", context.eventName || "interrupt", interruptPayload]);
|
|
86
|
+
if (!emittedStepKeys.has(key)) {
|
|
87
|
+
emittedStepKeys.add(key);
|
|
88
|
+
projections.push({
|
|
89
|
+
type: "step",
|
|
90
|
+
step: "Waiting for approval",
|
|
91
|
+
category: "approval",
|
|
92
|
+
status: "started",
|
|
93
|
+
key,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (context.eventName === "on_chat_model_start") {
|
|
98
|
+
const stepName = context.name || "model";
|
|
99
|
+
const key = createProjectionKey(["llm", "started", stepName]);
|
|
100
|
+
if (!emittedStepKeys.has(key)) {
|
|
101
|
+
emittedStepKeys.add(key);
|
|
102
|
+
projections.push({
|
|
103
|
+
type: "step",
|
|
104
|
+
step: buildStepLabel("llm", "started", stepName),
|
|
105
|
+
category: "llm",
|
|
106
|
+
status: "started",
|
|
107
|
+
key,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (context.eventName === "on_tool_start"
|
|
112
|
+
|| (context.eventName === "on_chain_start" && context.runType === "tool")
|
|
113
|
+
|| context.eventName === "on_chain_start") {
|
|
114
|
+
const category = classifyStepCategory(context);
|
|
115
|
+
if (category !== "llm") {
|
|
116
|
+
const stepName = context.name || context.runType || "chain";
|
|
117
|
+
const key = createProjectionKey([category, "started", stepName]);
|
|
118
|
+
if (!emittedStepKeys.has(key)) {
|
|
119
|
+
emittedStepKeys.add(key);
|
|
120
|
+
projections.push({
|
|
121
|
+
type: "step",
|
|
122
|
+
step: buildStepLabel(category, "started", stepName),
|
|
123
|
+
category,
|
|
124
|
+
status: "started",
|
|
125
|
+
key,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const toolResult = extractToolResult(event);
|
|
131
|
+
if (toolResult) {
|
|
132
|
+
const resultKey = createProjectionKey(["tool-result", toolResult.toolName, toolResult.output, toolResult.isError === true]);
|
|
133
|
+
if (!emittedToolResultKeys.has(resultKey)) {
|
|
134
|
+
emittedToolResultKeys.add(resultKey);
|
|
135
|
+
projections.push({
|
|
136
|
+
type: "tool-result",
|
|
137
|
+
toolName: toolResult.toolName,
|
|
138
|
+
output: toolResult.output,
|
|
139
|
+
...(toolResult.isError !== undefined ? { isError: toolResult.isError } : {}),
|
|
140
|
+
key: resultKey,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
const stepKey = createProjectionKey(["tool", toolResult.isError ? "failed" : "completed", toolResult.toolName]);
|
|
144
|
+
if (!emittedStepKeys.has(stepKey)) {
|
|
145
|
+
emittedStepKeys.add(stepKey);
|
|
146
|
+
projections.push({
|
|
147
|
+
type: "step",
|
|
148
|
+
step: buildStepLabel("tool", toolResult.isError ? "failed" : "completed", toolResult.toolName),
|
|
149
|
+
category: "tool",
|
|
150
|
+
status: toolResult.isError ? "failed" : "completed",
|
|
151
|
+
key: stepKey,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (context.eventName === "on_chain_end" && context.runType !== "tool" && context.name) {
|
|
156
|
+
const category = classifyStepCategory(context);
|
|
157
|
+
const key = createProjectionKey([category, "completed", context.name]);
|
|
158
|
+
if (!emittedStepKeys.has(key)) {
|
|
159
|
+
emittedStepKeys.add(key);
|
|
160
|
+
projections.push({
|
|
161
|
+
type: "step",
|
|
162
|
+
step: buildStepLabel(category, "completed", context.name),
|
|
163
|
+
category,
|
|
164
|
+
status: "completed",
|
|
165
|
+
key,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return projections;
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { CompiledAgentBinding } from "../contracts/types.js";
|
|
2
|
+
export declare function attachLegacyExecutionAliases(binding: CompiledAgentBinding): CompiledAgentBinding;
|
|
3
|
+
export declare function stripLegacyExecutionAliases(binding: CompiledAgentBinding): CompiledAgentBinding;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
function defineExecutionAlias(binding, property, kind) {
|
|
2
|
+
if (Object.prototype.hasOwnProperty.call(binding, property)) {
|
|
3
|
+
return;
|
|
4
|
+
}
|
|
5
|
+
Object.defineProperty(binding, property, {
|
|
6
|
+
configurable: true,
|
|
7
|
+
enumerable: false,
|
|
8
|
+
get() {
|
|
9
|
+
return binding.execution?.kind === kind ? binding.execution.params : undefined;
|
|
10
|
+
},
|
|
11
|
+
set(value) {
|
|
12
|
+
if (value === undefined) {
|
|
13
|
+
if (binding.execution?.kind === kind) {
|
|
14
|
+
delete binding.execution;
|
|
15
|
+
}
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
binding.execution = {
|
|
19
|
+
kind,
|
|
20
|
+
params: value,
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export function attachLegacyExecutionAliases(binding) {
|
|
26
|
+
defineExecutionAlias(binding, "langchainAgentParams", "langchain-v1");
|
|
27
|
+
defineExecutionAlias(binding, "deepAgentParams", "deepagent");
|
|
28
|
+
return binding;
|
|
29
|
+
}
|
|
30
|
+
export function stripLegacyExecutionAliases(binding) {
|
|
31
|
+
const { langchainAgentParams: _langchainAgentParams, deepAgentParams: _deepAgentParams, ...rest } = binding;
|
|
32
|
+
return rest;
|
|
33
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { getSkillInheritancePolicy, resolveToolTargets } from "../extensions.js";
|
|
3
|
+
import { attachLegacyExecutionAliases } from "../utils/compiled-binding.js";
|
|
3
4
|
import { compileModel, compileTool } from "./resource-compilers.js";
|
|
4
5
|
import { inferAgentCapabilities } from "./support/agent-capabilities.js";
|
|
5
6
|
import { getAgentExecutionConfigValue, getAgentExecutionObject, getAgentExecutionString } from "./support/agent-execution-config.js";
|
|
@@ -142,7 +143,6 @@ function compileExecutionCore(agent, models, tools) {
|
|
|
142
143
|
responseFormat: resolveResponseFormat(agent),
|
|
143
144
|
contextSchema: resolveContextSchema(agent),
|
|
144
145
|
middleware: resolveCompiledMiddleware(agent, models),
|
|
145
|
-
passthrough: resolvePassthrough(agent),
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
148
|
function resolveBackendConfig(agent, refs) {
|
|
@@ -251,6 +251,7 @@ export function compileBinding(workspaceRoot, agent, agents, referencedSubagentI
|
|
|
251
251
|
...agent,
|
|
252
252
|
modelRef: agent.modelRef || (internalSubagent ? "model/default" : ""),
|
|
253
253
|
}, models, tools);
|
|
254
|
+
const passthrough = resolvePassthrough(agent);
|
|
254
255
|
const compiledAgentModel = executionCore.model;
|
|
255
256
|
const backend = resolveBackendConfig(agent, refs);
|
|
256
257
|
const store = resolveStoreConfig(agent, refs);
|
|
@@ -268,6 +269,28 @@ export function compileBinding(workspaceRoot, agent, agents, referencedSubagentI
|
|
|
268
269
|
workspaceRoot,
|
|
269
270
|
capabilities: inferAgentCapabilities(agent),
|
|
270
271
|
resilience,
|
|
272
|
+
...(agent.executionMode === "deepagent"
|
|
273
|
+
? {
|
|
274
|
+
deepagent: {
|
|
275
|
+
description: agent.description,
|
|
276
|
+
passthrough,
|
|
277
|
+
},
|
|
278
|
+
}
|
|
279
|
+
: {}),
|
|
280
|
+
...(agent.executionMode === "langchain-v1"
|
|
281
|
+
? {
|
|
282
|
+
langchain: {
|
|
283
|
+
passthrough,
|
|
284
|
+
interruptOn: resolveInterruptOn(agent),
|
|
285
|
+
filesystem: getAgentExecutionObject(agent, "filesystem", { executionMode: "langchain-v1" }),
|
|
286
|
+
subagents: compileSubagents(agent, agents, workspaceRoot, models, tools, compiledAgentSkills, compiledAgentModel),
|
|
287
|
+
memory: compiledAgentMemory,
|
|
288
|
+
skills: compiledAgentSkills,
|
|
289
|
+
generalPurposeAgent: getAgentExecutionConfigValue(agent, "generalPurposeAgent", { executionMode: "langchain-v1" }),
|
|
290
|
+
taskDescription: getAgentExecutionString(agent, "taskDescription", { executionMode: "langchain-v1" }),
|
|
291
|
+
},
|
|
292
|
+
}
|
|
293
|
+
: {}),
|
|
271
294
|
...(checkpointer ? { checkpointer: checkpointer.config } : {}),
|
|
272
295
|
...(store ? { store: store.config } : {}),
|
|
273
296
|
...(runtimeMemory ? { runtimeMemory: runtimeMemory.config } : {}),
|
|
@@ -281,18 +304,10 @@ export function compileBinding(workspaceRoot, agent, agents, referencedSubagentI
|
|
|
281
304
|
model: executionCore.model,
|
|
282
305
|
tools: executionCore.tools,
|
|
283
306
|
systemPrompt: executionCore.systemPrompt,
|
|
284
|
-
interruptOn: resolveInterruptOn(agent),
|
|
285
307
|
stateSchema: getAgentExecutionConfigValue(agent, "stateSchema", { executionMode: "langchain-v1" }),
|
|
286
308
|
responseFormat: executionCore.responseFormat,
|
|
287
309
|
contextSchema: executionCore.contextSchema,
|
|
288
|
-
filesystem: getAgentExecutionObject(agent, "filesystem", { executionMode: "langchain-v1" }),
|
|
289
310
|
middleware: executionCore.middleware,
|
|
290
|
-
passthrough: executionCore.passthrough,
|
|
291
|
-
subagents: compileSubagents(agent, agents, workspaceRoot, models, tools, compiledAgentSkills, compiledAgentModel),
|
|
292
|
-
memory: compiledAgentMemory,
|
|
293
|
-
skills: compiledAgentSkills,
|
|
294
|
-
generalPurposeAgent: getAgentExecutionConfigValue(agent, "generalPurposeAgent", { executionMode: "langchain-v1" }),
|
|
295
|
-
taskDescription: getAgentExecutionString(agent, "taskDescription", { executionMode: "langchain-v1" }),
|
|
296
311
|
includeAgentName: getAgentExecutionConfigValue(agent, "includeAgentName", { executionMode: "langchain-v1" }) === "inline" ? "inline" : undefined,
|
|
297
312
|
version: langchainVersion === "v1" || langchainVersion === "v2"
|
|
298
313
|
? langchainVersion
|
|
@@ -301,11 +316,10 @@ export function compileBinding(workspaceRoot, agent, agents, referencedSubagentI
|
|
|
301
316
|
description: agent.description,
|
|
302
317
|
},
|
|
303
318
|
};
|
|
304
|
-
return {
|
|
319
|
+
return attachLegacyExecutionAliases({
|
|
305
320
|
...base,
|
|
306
321
|
execution: executionBinding,
|
|
307
|
-
|
|
308
|
-
};
|
|
322
|
+
});
|
|
309
323
|
}
|
|
310
324
|
const executionBinding = {
|
|
311
325
|
kind: "deepagent",
|
|
@@ -316,8 +330,6 @@ export function compileBinding(workspaceRoot, agent, agents, referencedSubagentI
|
|
|
316
330
|
responseFormat: executionCore.responseFormat,
|
|
317
331
|
contextSchema: executionCore.contextSchema,
|
|
318
332
|
middleware: executionCore.middleware,
|
|
319
|
-
passthrough: executionCore.passthrough,
|
|
320
|
-
description: agent.description,
|
|
321
333
|
subagents: compileSubagents(agent, agents, workspaceRoot, models, tools, compiledAgentSkills, compiledAgentModel),
|
|
322
334
|
interruptOn: resolveInterruptOn(agent),
|
|
323
335
|
...(backend ? { backend: backend.config } : {}),
|
|
@@ -327,9 +339,8 @@ export function compileBinding(workspaceRoot, agent, agents, referencedSubagentI
|
|
|
327
339
|
skills: compiledAgentSkills,
|
|
328
340
|
},
|
|
329
341
|
};
|
|
330
|
-
return {
|
|
342
|
+
return attachLegacyExecutionAliases({
|
|
331
343
|
...base,
|
|
332
344
|
execution: executionBinding,
|
|
333
|
-
|
|
334
|
-
};
|
|
345
|
+
});
|
|
335
346
|
}
|