@botbotgo/agent-harness 0.0.119 → 0.0.120

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,5 +1,6 @@
1
1
  import type { RunState } from "./core.js";
2
2
  import type { CompiledAgentBinding, CompiledModel, CompiledTool, ParsedAgentObject, ParsedToolObject, WorkspaceBundle } from "./workspace.js";
3
+ import type { CompatibleStreamPart as InternalCompatibleStreamPart, NormalizedUpstreamEvent as InternalNormalizedUpstreamEvent, UpstreamRuntimeEvent as InternalUpstreamRuntimeEvent } from "../runtime/parsing/stream-event-types.js";
3
4
  export type ThreadSummary = {
4
5
  agentId: string;
5
6
  threadId: string;
@@ -85,74 +86,9 @@ export type RunResult = {
85
86
  artifacts?: ArtifactRecord[];
86
87
  metadata?: Record<string, unknown>;
87
88
  };
88
- export type NormalizedUpstreamEvent = {
89
- kind: "text-delta";
90
- source: "model" | "state";
91
- text: string;
92
- ns?: string[];
93
- nodeName?: string;
94
- } | {
95
- kind: "reasoning-delta";
96
- text: string;
97
- ns?: string[];
98
- nodeName?: string;
99
- } | {
100
- kind: "tool-start";
101
- toolName: string;
102
- input?: unknown;
103
- ns?: string[];
104
- nodeName?: string;
105
- } | {
106
- kind: "tool-end";
107
- toolName: string;
108
- output?: unknown;
109
- isError?: boolean;
110
- ns?: string[];
111
- nodeName?: string;
112
- } | {
113
- kind: "agent-step";
114
- label: string;
115
- ns?: string[];
116
- nodeName?: string;
117
- } | {
118
- kind: "interrupt";
119
- interrupt: unknown;
120
- ns?: string[];
121
- nodeName?: string;
122
- } | {
123
- kind: "run-event";
124
- eventName: string;
125
- data?: Record<string, unknown>;
126
- ns?: string[];
127
- nodeName?: string;
128
- };
129
- export type CompatibleStreamPart = {
130
- type: "messages";
131
- ns: string[];
132
- data: [unknown, Record<string, unknown>];
133
- } | {
134
- type: "updates";
135
- ns: string[];
136
- data: Record<string, unknown>;
137
- } | {
138
- type: "custom";
139
- ns: string[];
140
- data: unknown;
141
- };
142
- export type UpstreamRuntimeEvent = {
143
- format: "langgraph-v2";
144
- /** @deprecated Prefer streamPart plus raw/event/name/data/ns for upstream-aligned consumption. */
145
- normalized: NormalizedUpstreamEvent;
146
- streamPart: CompatibleStreamPart;
147
- raw: unknown;
148
- event?: string;
149
- name?: string;
150
- runType?: string;
151
- data?: Record<string, unknown>;
152
- metadata?: Record<string, unknown>;
153
- tags?: string[];
154
- ns?: string[];
155
- };
89
+ export type NormalizedUpstreamEvent = InternalNormalizedUpstreamEvent;
90
+ export type CompatibleStreamPart = InternalCompatibleStreamPart;
91
+ export type UpstreamRuntimeEvent = InternalUpstreamRuntimeEvent;
156
92
  export type RuntimeListeners = {
157
93
  onEvent?: (event: HarnessEvent) => void | Promise<void>;
158
94
  };
@@ -146,18 +146,10 @@ export type LangChainAgentParams = {
146
146
  model: CompiledModel;
147
147
  tools: CompiledTool[];
148
148
  systemPrompt?: string;
149
- interruptOn?: Record<string, boolean | object>;
150
149
  stateSchema?: unknown;
151
150
  responseFormat?: unknown;
152
151
  contextSchema?: unknown;
153
- filesystem?: Record<string, unknown>;
154
152
  middleware?: Array<Record<string, unknown>>;
155
- passthrough?: Record<string, unknown>;
156
- subagents?: CompiledSubAgent[];
157
- memory?: string[];
158
- skills?: string[];
159
- generalPurposeAgent?: boolean;
160
- taskDescription?: string;
161
153
  includeAgentName?: "inline";
162
154
  version?: "v1" | "v2";
163
155
  name?: string;
@@ -170,8 +162,6 @@ export type DeepAgentParams = {
170
162
  responseFormat?: unknown;
171
163
  contextSchema?: unknown;
172
164
  middleware?: Array<Record<string, unknown>>;
173
- passthrough?: Record<string, unknown>;
174
- description: string;
175
165
  subagents: CompiledSubAgent[];
176
166
  interruptOn?: Record<string, boolean | object>;
177
167
  backend?: Record<string, unknown>;
@@ -180,6 +170,20 @@ export type DeepAgentParams = {
180
170
  memory: string[];
181
171
  skills: string[];
182
172
  };
173
+ export type LegacyLangChainAgentParams = LangChainAgentParams & {
174
+ passthrough?: Record<string, unknown>;
175
+ interruptOn?: Record<string, boolean | object>;
176
+ filesystem?: Record<string, unknown>;
177
+ subagents?: CompiledSubAgent[];
178
+ memory?: string[];
179
+ skills?: string[];
180
+ generalPurposeAgent?: boolean;
181
+ taskDescription?: string;
182
+ };
183
+ export type LegacyDeepAgentParams = DeepAgentParams & {
184
+ description?: string;
185
+ passthrough?: Record<string, unknown>;
186
+ };
183
187
  export type CompiledExecutionBinding = {
184
188
  kind: "langchain-v1";
185
189
  params: LangChainAgentParams;
@@ -203,17 +207,31 @@ export type CompiledAgentBinding = {
203
207
  * Compatibility alias for older tests and callers.
204
208
  * Prefer `execution.kind === "langchain-v1"` and `execution.params`.
205
209
  */
206
- langchainAgentParams?: LangChainAgentParams;
210
+ langchainAgentParams?: LegacyLangChainAgentParams;
207
211
  /**
208
212
  * Compatibility alias for older tests and callers.
209
213
  * Prefer `execution.kind === "deepagent"` and `execution.params`.
210
214
  */
211
- deepAgentParams?: DeepAgentParams;
215
+ deepAgentParams?: LegacyDeepAgentParams;
212
216
  harnessRuntime: {
213
217
  runRoot: string;
214
218
  workspaceRoot?: string;
215
219
  capabilities?: RuntimeCapabilities;
216
220
  resilience?: Record<string, unknown>;
221
+ deepagent?: {
222
+ description?: string;
223
+ passthrough?: Record<string, unknown>;
224
+ };
225
+ langchain?: {
226
+ passthrough?: Record<string, unknown>;
227
+ interruptOn?: Record<string, boolean | object>;
228
+ filesystem?: Record<string, unknown>;
229
+ subagents?: CompiledSubAgent[];
230
+ memory?: string[];
231
+ skills?: string[];
232
+ generalPurposeAgent?: boolean;
233
+ taskDescription?: string;
234
+ };
217
235
  checkpointer?: Record<string, unknown> | boolean;
218
236
  store?: Record<string, unknown>;
219
237
  runtimeMemory?: Record<string, unknown>;
@@ -1 +1 @@
1
- export declare const AGENT_HARNESS_VERSION = "0.0.118";
1
+ export declare const AGENT_HARNESS_VERSION = "0.0.119";
@@ -1 +1 @@
1
- export const AGENT_HARNESS_VERSION = "0.0.118";
1
+ export const AGENT_HARNESS_VERSION = "0.0.119";
@@ -1,6 +1,20 @@
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 type LangChainRuntimeExtensionPlan = {
5
+ includePatchToolCalls: boolean;
6
+ includeAutomaticSummarization: boolean;
7
+ context: {
8
+ skills: string[];
9
+ memory: string[];
10
+ };
11
+ delegation?: {
12
+ subagents: CompiledSubAgent[];
13
+ generalPurposeAgent?: boolean;
14
+ taskDescription?: string;
15
+ interruptOn?: Record<string, boolean | object>;
16
+ };
17
+ };
4
18
  export type UpstreamSubagentConfig = {
5
19
  name: string;
6
20
  description: string;
@@ -19,6 +33,7 @@ export declare function buildBuiltinTaskSubagentMiddleware(input: {
19
33
  builtinBackend: unknown;
20
34
  summarizationModel: unknown;
21
35
  }): unknown[];
36
+ export declare function planLangChainRuntimeExtensions(binding: CompiledAgentBinding): LangChainRuntimeExtensionPlan | undefined;
22
37
  export declare function resolveBuiltinMiddlewareBackend(input: {
23
38
  binding: CompiledAgentBinding;
24
39
  runtimeAdapterOptions: RuntimeAdapterOptions;
@@ -70,13 +85,22 @@ export declare function resolveBuiltinMiddlewareTools(input: {
70
85
  files?: Record<string, unknown>;
71
86
  }) => Promise<unknown>;
72
87
  }): Promise<Map<string, ExecutableTool>>;
73
- export declare function resolveAutomaticSummarizationMiddleware(input: {
88
+ export declare function materializeAutomaticSummarizationMiddleware(input: {
74
89
  binding: CompiledAgentBinding;
75
90
  createDeclaredMiddlewareResolverOptions: (binding?: CompiledAgentBinding) => unknown;
76
91
  }): Promise<unknown[]>;
77
- export declare function resolveLangChainAutomaticMiddleware(input: {
92
+ export declare function materializeLangChainRuntimeMiddleware(input: {
93
+ binding: CompiledAgentBinding;
94
+ plan: LangChainRuntimeExtensionPlan;
95
+ materializeAutomaticSummarizationMiddleware: (binding: CompiledAgentBinding) => Promise<unknown[]>;
96
+ resolveFilesystemBackend: (binding: CompiledAgentBinding) => FilesystemBackend;
97
+ resolveModel: (model: CompiledModel) => Promise<unknown>;
98
+ resolveTools: (tools: Parameters<DeepAgentParams["tools"]["slice"]>[0] extends never ? never : any, binding?: CompiledAgentBinding) => unknown[];
99
+ resolveSubagents: (subagents: CompiledSubAgent[], binding?: CompiledAgentBinding) => Promise<UpstreamSubagentConfig[]>;
100
+ }): Promise<unknown[]>;
101
+ export declare function resolveLangChainRuntimeExtensionMiddleware(input: {
78
102
  binding: CompiledAgentBinding;
79
- resolveAutomaticSummarizationMiddleware: (binding: CompiledAgentBinding) => Promise<unknown[]>;
103
+ materializeAutomaticSummarizationMiddleware: (binding: CompiledAgentBinding) => Promise<unknown[]>;
80
104
  resolveFilesystemBackend: (binding: CompiledAgentBinding) => FilesystemBackend;
81
105
  resolveModel: (model: CompiledModel) => Promise<unknown>;
82
106
  resolveTools: (tools: Parameters<DeepAgentParams["tools"]["slice"]>[0] extends never ? never : any, binding?: CompiledAgentBinding) => unknown[];
@@ -89,5 +113,5 @@ export declare function resolveMiddleware(input: {
89
113
  }>;
90
114
  runtimeAdapterOptions: RuntimeAdapterOptions;
91
115
  createDeclaredMiddlewareResolverOptions: (binding?: CompiledAgentBinding) => unknown;
92
- resolveLangChainAutomaticMiddleware: (binding: CompiledAgentBinding) => Promise<unknown[]>;
116
+ resolveLangChainRuntimeExtensionMiddleware: (binding: CompiledAgentBinding) => Promise<unknown[]>;
93
117
  }): Promise<unknown[]>;
@@ -62,6 +62,36 @@ function resolveLangChainDelegationCompatibility(params) {
62
62
  taskDescription: params.taskDescription,
63
63
  });
64
64
  }
65
+ export function planLangChainRuntimeExtensions(binding) {
66
+ const primaryModel = getBindingPrimaryModel(binding);
67
+ if (!isLangChainBinding(binding) || !primaryModel) {
68
+ return undefined;
69
+ }
70
+ const skills = getBindingSkills(binding);
71
+ const memory = getBindingMemorySources(binding);
72
+ const delegationCompatibility = resolveLangChainDelegationCompatibility({
73
+ model: primaryModel,
74
+ subagents: getBindingSubagents(binding),
75
+ generalPurposeAgent: getBindingGeneralPurposeAgent(binding),
76
+ taskDescription: getBindingTaskDescription(binding),
77
+ });
78
+ return {
79
+ includePatchToolCalls: !bindingHasMiddlewareKind(binding, "patchToolCalls"),
80
+ includeAutomaticSummarization: !bindingHasMiddlewareKind(binding, "summarization"),
81
+ context: {
82
+ skills,
83
+ memory,
84
+ },
85
+ delegation: bindingHasLangChainSubagentSupport(binding)
86
+ ? {
87
+ subagents: delegationCompatibility.subagents ?? [],
88
+ generalPurposeAgent: delegationCompatibility.generalPurposeAgent,
89
+ taskDescription: delegationCompatibility.taskDescription,
90
+ interruptOn: getBindingInterruptCompatibilityRules(binding),
91
+ }
92
+ : undefined,
93
+ };
94
+ }
65
95
  export function resolveBuiltinMiddlewareBackend(input) {
66
96
  const runtimeState = {
67
97
  ...(input.options?.state ?? {}),
@@ -154,57 +184,62 @@ export async function resolveBuiltinMiddlewareTools(input) {
154
184
  : undefined,
155
185
  });
156
186
  }
157
- export async function resolveAutomaticSummarizationMiddleware(input) {
158
- if (bindingHasMiddlewareKind(input.binding, "summarization")) {
159
- return [];
160
- }
187
+ export async function materializeAutomaticSummarizationMiddleware(input) {
161
188
  const primaryModel = getBindingPrimaryModel(input.binding);
162
189
  if (!primaryModel) {
163
190
  return [];
164
191
  }
165
192
  return resolveDeclaredMiddleware([{ kind: "summarization", model: primaryModel }], input.createDeclaredMiddlewareResolverOptions(input.binding));
166
193
  }
167
- export async function resolveLangChainAutomaticMiddleware(input) {
194
+ export async function materializeLangChainRuntimeMiddleware(input) {
168
195
  const primaryModel = getBindingPrimaryModel(input.binding);
169
196
  const primaryTools = getBindingPrimaryTools(input.binding);
170
- if (!isLangChainBinding(input.binding) || !primaryModel) {
197
+ if (!primaryModel) {
171
198
  return [];
172
199
  }
173
- const delegationCompatibility = resolveLangChainDelegationCompatibility({
174
- model: primaryModel,
175
- subagents: getBindingSubagents(input.binding),
176
- generalPurposeAgent: getBindingGeneralPurposeAgent(input.binding),
177
- taskDescription: getBindingTaskDescription(input.binding),
178
- });
179
- const automaticMiddleware = [];
180
- automaticMiddleware.push(createPatchToolCallsMiddleware());
181
- automaticMiddleware.push(...(await input.resolveAutomaticSummarizationMiddleware(input.binding)));
182
- automaticMiddleware.push(...buildLangChainContextMiddleware({
200
+ const runtimeMiddleware = [];
201
+ if (input.plan.includePatchToolCalls) {
202
+ runtimeMiddleware.push(createPatchToolCallsMiddleware());
203
+ }
204
+ if (input.plan.includeAutomaticSummarization) {
205
+ runtimeMiddleware.push(...(await input.materializeAutomaticSummarizationMiddleware(input.binding)));
206
+ }
207
+ runtimeMiddleware.push(...buildLangChainContextMiddleware({
183
208
  binding: input.binding,
184
- skills: getBindingSkills(input.binding),
185
- memory: getBindingMemorySources(input.binding),
209
+ skills: input.plan.context.skills,
210
+ memory: input.plan.context.memory,
186
211
  resolveFilesystemBackend: input.resolveFilesystemBackend,
187
212
  }));
188
- if (bindingHasLangChainSubagentSupport(input.binding)) {
189
- automaticMiddleware.push(createSubAgentMiddleware({
213
+ if (input.plan.delegation) {
214
+ runtimeMiddleware.push(createSubAgentMiddleware({
190
215
  defaultModel: (await input.resolveModel(primaryModel)),
191
216
  defaultTools: input.resolveTools(primaryTools, input.binding),
192
- defaultInterruptOn: getBindingInterruptCompatibilityRules(input.binding),
193
- subagents: (await input.resolveSubagents(delegationCompatibility.subagents ?? [], input.binding)),
194
- generalPurposeAgent: delegationCompatibility.generalPurposeAgent,
195
- taskDescription: delegationCompatibility.taskDescription ?? null,
217
+ defaultInterruptOn: input.plan.delegation.interruptOn,
218
+ subagents: (await input.resolveSubagents(input.plan.delegation.subagents, input.binding)),
219
+ generalPurposeAgent: input.plan.delegation.generalPurposeAgent,
220
+ taskDescription: input.plan.delegation.taskDescription ?? null,
196
221
  }));
197
222
  }
198
- return automaticMiddleware;
223
+ return runtimeMiddleware;
224
+ }
225
+ export async function resolveLangChainRuntimeExtensionMiddleware(input) {
226
+ const plan = planLangChainRuntimeExtensions(input.binding);
227
+ if (!plan) {
228
+ return [];
229
+ }
230
+ return materializeLangChainRuntimeMiddleware({
231
+ ...input,
232
+ plan,
233
+ });
199
234
  }
200
235
  export async function resolveMiddleware(input) {
201
- const declarativeMiddleware = await resolveDeclaredMiddleware(getBindingMiddlewareConfigs(input.binding), input.createDeclaredMiddlewareResolverOptions(input.binding));
202
- const automaticMiddleware = isLangChainBinding(input.binding)
203
- ? await input.resolveLangChainAutomaticMiddleware(input.binding)
236
+ const declarativeUpstreamMiddleware = await resolveDeclaredMiddleware(getBindingMiddlewareConfigs(input.binding), input.createDeclaredMiddlewareResolverOptions(input.binding));
237
+ const runtimeExtensionMiddleware = isLangChainBinding(input.binding)
238
+ ? await input.resolveLangChainRuntimeExtensionMiddleware(input.binding)
204
239
  : [];
205
240
  const middleware = [
206
- ...declarativeMiddleware,
207
- ...automaticMiddleware,
241
+ ...declarativeUpstreamMiddleware,
242
+ ...runtimeExtensionMiddleware,
208
243
  ...(input.runtimeAdapterOptions.middlewareResolver ? input.runtimeAdapterOptions.middlewareResolver(input.binding) : []),
209
244
  ];
210
245
  if (input.interruptOn && Object.keys(input.interruptOn).length > 0) {
@@ -1,6 +1,108 @@
1
1
  import { sanitizeVisibleText } from "../parsing/output-parsing.js";
2
- import { computeIncrementalOutput, extractAgentStep, extractInterruptPayload, extractReasoningStreamOutput, extractStateStreamOutput, extractTerminalStreamOutput, extractToolResult, extractVisibleStreamOutput, normalizeTerminalOutputKey, normalizeUpstreamRuntimeEvent, } from "../parsing/stream-event-parsing.js";
2
+ import { computeIncrementalOutput, extractInterruptPayload, extractReasoningStreamOutput, extractStateStreamOutput, extractTerminalStreamOutput, extractToolResult, extractVisibleStreamOutput, normalizeTerminalOutputKey, normalizeUpstreamRuntimeEvent, } from "../parsing/stream-event-parsing.js";
3
3
  import { resolveModelFacingToolName } from "./tool/tool-name-mapping.js";
4
+ function formatStepValue(value, maxLength = 120) {
5
+ if (value == null)
6
+ return "";
7
+ const normalized = typeof value === "string"
8
+ ? parseMaybeJson(value)
9
+ : value;
10
+ const summarized = summarizeStepValue(normalized);
11
+ const serialized = typeof summarized === "string"
12
+ ? summarized
13
+ : (() => {
14
+ try {
15
+ return JSON.stringify(summarized);
16
+ }
17
+ catch {
18
+ return String(summarized);
19
+ }
20
+ })();
21
+ return serialized.length > maxLength ? serialized.slice(0, maxLength) + "…" : serialized;
22
+ }
23
+ function parseMaybeJson(value) {
24
+ const trimmed = value.trim();
25
+ if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) {
26
+ return value;
27
+ }
28
+ try {
29
+ return JSON.parse(trimmed);
30
+ }
31
+ catch {
32
+ return value;
33
+ }
34
+ }
35
+ function summarizeStepValue(value) {
36
+ if (typeof value !== "object" || !value) {
37
+ return value;
38
+ }
39
+ const record = value;
40
+ if (typeof record.url === "string" && typeof record.status === "number") {
41
+ const warnings = Array.isArray(record.warnings) ? record.warnings.filter((item) => typeof item === "string") : [];
42
+ return {
43
+ status: record.status,
44
+ ok: record.ok,
45
+ quality: record.quality,
46
+ source: record.source,
47
+ warnings,
48
+ };
49
+ }
50
+ return value;
51
+ }
52
+ function humanizeEventName(name) {
53
+ return name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[._-]+/g, " ").replace(/\s+/g, " ").trim().toLowerCase();
54
+ }
55
+ function deriveAgentStep(event) {
56
+ if (typeof event !== "object" || !event)
57
+ return null;
58
+ const typed = event;
59
+ const name = typeof typed.name === "string" ? typed.name : "";
60
+ if (typed.event === "on_tool_start" || (typed.event === "on_chain_start" && typed.run_type === "tool")) {
61
+ const inputSummary = formatStepValue(typed.data?.input);
62
+ return inputSummary ? `tool ${name || "tool"} ${inputSummary}` : `tool ${name || "tool"}`;
63
+ }
64
+ if (typed.event === "on_tool_end" || (typed.event === "on_chain_end" && typed.run_type === "tool")) {
65
+ const outputSummary = formatStepValue(typed.data?.output, 80);
66
+ return outputSummary ? `tool ${name || "tool"} done ${outputSummary}` : `tool ${name || "tool"} done`;
67
+ }
68
+ if (typed.event === "on_tool_error" || (typed.event === "on_chain_error" && typed.run_type === "tool")) {
69
+ const errorSummary = formatStepValue(typed.data?.error ?? typed.data?.output, 80);
70
+ return errorSummary ? `tool ${name || "tool"} error ${errorSummary}` : `tool ${name || "tool"} error`;
71
+ }
72
+ if (typed.event === "on_chat_model_start") {
73
+ const inputTools = typed.data?.input?.tools;
74
+ const tools = typed.invocation_params?.tools ?? inputTools ?? [];
75
+ const toolNames = tools.map((tool) => tool.name ?? tool.function?.name).filter((toolName) => typeof toolName === "string").join(", ");
76
+ return toolNames ? `calling model tools: [${toolNames}]` : "calling model…";
77
+ }
78
+ if (typed.event === "on_chain_start") {
79
+ if (/SkillsMiddleware/i.test(name))
80
+ return "loading skills…";
81
+ if (/MemoryMiddleware/i.test(name))
82
+ return "loading memory…";
83
+ if (/patchToolCallsMiddleware/i.test(name))
84
+ return "normalizing tool calls…";
85
+ if (/HumanInTheLoopMiddleware/i.test(name))
86
+ return "checking approvals…";
87
+ if (/todoListMiddleware/i.test(name))
88
+ return "updating plan…";
89
+ if (/model_request/i.test(name))
90
+ return "preparing model request…";
91
+ if (/RunnableLambda/i.test(name) || /^__start__$/.test(name))
92
+ return null;
93
+ if (/(subagent|specialist)/i.test(name))
94
+ return `starting ${humanizeEventName(name)}…`;
95
+ if (/agent$/i.test(name))
96
+ return `running ${humanizeEventName(name)}…`;
97
+ }
98
+ if (typed.event === "on_chain_end") {
99
+ if (/(subagent|specialist)/i.test(name))
100
+ return `${humanizeEventName(name)} done`;
101
+ if (/agent$/i.test(name) && !/^__start__$/.test(name))
102
+ return `${humanizeEventName(name)} done`;
103
+ }
104
+ return null;
105
+ }
4
106
  export function createStreamEventProjectionState() {
5
107
  return {
6
108
  emittedOutput: "",
@@ -45,7 +147,7 @@ export function projectRuntimeStreamEvent(params) {
45
147
  }
46
148
  }
47
149
  }
48
- const agentStep = extractAgentStep(event);
150
+ const agentStep = deriveAgentStep(event);
49
151
  if (agentStep && agentStep !== state.lastStep) {
50
152
  state.lastStep = agentStep;
51
153
  chunks.push({ kind: "step", content: agentStep });
@@ -62,8 +62,8 @@ export declare class AgentRuntimeAdapter {
62
62
  private createAssemblyResolvers;
63
63
  private invokeBuiltinTaskTool;
64
64
  private resolveBuiltinMiddlewareTools;
65
- private resolveAutomaticSummarizationMiddleware;
66
- private resolveLangChainAutomaticMiddleware;
65
+ private materializeAutomaticSummarizationMiddleware;
66
+ private resolveLangChainRuntimeExtensionMiddleware;
67
67
  private resolveMiddleware;
68
68
  private resolveSubagents;
69
69
  private createLangChainRunnable;
@@ -8,7 +8,7 @@ import { buildToolNameMapping, } from "./adapter/tool/tool-name-mapping.js";
8
8
  import { executeRuntimeInvocation } from "./adapter/flow/invocation-flow.js";
9
9
  import { streamRuntimeExecution } from "./adapter/flow/stream-runtime.js";
10
10
  import { applyStrictToolJsonInstruction as applyStrictToolJsonInstructionHelper, callRuntimeWithToolParseRecovery as callRuntimeWithToolParseRecoveryHelper, createModelFallbackRunnable as createModelFallbackRunnableHelper, invokeWithProviderRetry as invokeWithProviderRetryHelper, iterateWithTimeout as iterateWithTimeoutHelper, materializeModelStream as materializeModelStreamHelper, RuntimeOperationTimeoutError, withRuntimeTimeout, } from "./adapter/runtime-shell.js";
11
- import { invokeBuiltinTaskTool as invokeBuiltinTaskToolHelper, resolveAutomaticSummarizationMiddleware as resolveAutomaticSummarizationMiddlewareHelper, resolveBuiltinMiddlewareBackend as resolveBuiltinMiddlewareBackendHelper, resolveBuiltinMiddlewareTools as resolveBuiltinMiddlewareToolsHelper, resolveLangChainAutomaticMiddleware as resolveLangChainAutomaticMiddlewareHelper, resolveMiddleware as resolveMiddlewareHelper, resolveSubagents as resolveSubagentsHelper, } from "./adapter/middleware-assembly.js";
11
+ import { invokeBuiltinTaskTool as invokeBuiltinTaskToolHelper, materializeAutomaticSummarizationMiddleware as materializeAutomaticSummarizationMiddlewareHelper, resolveBuiltinMiddlewareBackend as resolveBuiltinMiddlewareBackendHelper, resolveBuiltinMiddlewareTools as resolveBuiltinMiddlewareToolsHelper, resolveLangChainRuntimeExtensionMiddleware as resolveLangChainRuntimeExtensionMiddlewareHelper, resolveMiddleware as resolveMiddlewareHelper, resolveSubagents as resolveSubagentsHelper, } from "./adapter/middleware-assembly.js";
12
12
  import { computeRemainingTimeoutMs, resolveBindingTimeout, resolveStreamIdleTimeout, } from "./adapter/resilience.js";
13
13
  import { createResolvedModel } from "./adapter/model/model-providers.js";
14
14
  import { compileInterruptOn } from "./adapter/tool/interrupt-policy.js";
@@ -37,20 +37,16 @@ export function resolveRunnableCheckpointer(options, binding) {
37
37
  export function resolveRunnableInterruptOn(binding) {
38
38
  return compileInterruptOn(getBindingPrimaryTools(binding), getBindingInterruptCompatibilityRules(binding));
39
39
  }
40
- function buildUpstreamCreateBaseParams(binding, compileOnlyFields) {
40
+ function buildUpstreamCreateBaseParams(binding, supportedFields) {
41
41
  const executionParams = getBindingExecutionParams(binding);
42
42
  if (!executionParams) {
43
43
  throw new Error(`Agent ${binding.agent.id} has no compiled execution params`);
44
44
  }
45
45
  const source = executionParams;
46
- const passthrough = typeof source.passthrough === "object" && source.passthrough
47
- ? source.passthrough
48
- : undefined;
49
- const stripped = Object.fromEntries(Object.entries(source).filter(([key]) => key !== "passthrough" && !compileOnlyFields.includes(key)));
50
- return {
51
- ...(passthrough ?? {}),
52
- ...stripped,
53
- };
46
+ const upstreamParams = Object.fromEntries(supportedFields
47
+ .filter((key) => key in source && source[key] !== undefined)
48
+ .map((key) => [key, source[key]]));
49
+ return upstreamParams;
54
50
  }
55
51
  export function buildLangChainCreateParams(input) {
56
52
  const executionKind = getBindingExecutionKind(input.binding);
@@ -61,17 +57,29 @@ export function buildLangChainCreateParams(input) {
61
57
  const upstreamParams = buildUpstreamCreateBaseParams(input.binding, [
62
58
  "model",
63
59
  "tools",
60
+ "systemPrompt",
61
+ "stateSchema",
62
+ "contextSchema",
63
+ "checkpointer",
64
+ "store",
65
+ "responseFormat",
64
66
  "middleware",
65
- "interruptOn",
66
- "filesystem",
67
- "subagents",
68
- "memory",
69
- "skills",
70
- "generalPurposeAgent",
71
- "taskDescription",
67
+ "name",
68
+ "description",
69
+ "includeAgentName",
70
+ "version",
72
71
  ]);
72
+ const legacyPassthrough = typeof input.binding.langchainAgentParams?.passthrough === "object" &&
73
+ input.binding.langchainAgentParams?.passthrough
74
+ ? input.binding.langchainAgentParams.passthrough
75
+ : undefined;
76
+ const langchainPassthrough = typeof input.binding.harnessRuntime.langchain?.passthrough === "object" && input.binding.harnessRuntime.langchain?.passthrough
77
+ ? input.binding.harnessRuntime.langchain.passthrough
78
+ : undefined;
73
79
  return {
74
80
  ...upstreamParams,
81
+ ...(legacyPassthrough ?? {}),
82
+ ...(langchainPassthrough ?? {}),
75
83
  ...(input.passthroughOverride ?? {}),
76
84
  systemPrompt: input.systemPromptOverride ?? executionParams.systemPrompt,
77
85
  model: input.resolvedModel,
@@ -89,16 +97,18 @@ export function buildDeepAgentCreateParams(input) {
89
97
  const upstreamParams = buildUpstreamCreateBaseParams(input.binding, [
90
98
  "model",
91
99
  "tools",
100
+ "systemPrompt",
92
101
  "middleware",
93
102
  "subagents",
103
+ "responseFormat",
104
+ "contextSchema",
105
+ "checkpointer",
106
+ "store",
107
+ "backend",
94
108
  "interruptOn",
109
+ "name",
110
+ "memory",
95
111
  "skills",
96
- "backend",
97
- "store",
98
- // These do not belong to DeepAgents top-level create params even if
99
- // compatibility fixtures stuff them into compiled deepagent params.
100
- "generalPurposeAgent",
101
- "taskDescription",
102
112
  ]);
103
113
  return {
104
114
  ...upstreamParams,
@@ -255,18 +265,18 @@ export class AgentRuntimeAdapter {
255
265
  invokeBuiltinTaskTool: assembly.invokeBuiltinTaskTool,
256
266
  });
257
267
  }
258
- async resolveAutomaticSummarizationMiddleware(binding) {
268
+ async materializeAutomaticSummarizationMiddleware(binding) {
259
269
  const assembly = this.createAssemblyResolvers(binding);
260
- return resolveAutomaticSummarizationMiddlewareHelper({
270
+ return materializeAutomaticSummarizationMiddlewareHelper({
261
271
  binding,
262
272
  createDeclaredMiddlewareResolverOptions: assembly.createDeclaredMiddlewareResolverOptions,
263
273
  });
264
274
  }
265
- async resolveLangChainAutomaticMiddleware(binding) {
275
+ async resolveLangChainRuntimeExtensionMiddleware(binding) {
266
276
  const assembly = this.createAssemblyResolvers(binding);
267
- return resolveLangChainAutomaticMiddlewareHelper({
277
+ return resolveLangChainRuntimeExtensionMiddlewareHelper({
268
278
  binding,
269
- resolveAutomaticSummarizationMiddleware: (currentBinding) => this.resolveAutomaticSummarizationMiddleware(currentBinding),
279
+ materializeAutomaticSummarizationMiddleware: (currentBinding) => this.materializeAutomaticSummarizationMiddleware(currentBinding),
270
280
  resolveFilesystemBackend: assembly.resolveFilesystemBackend,
271
281
  resolveModel: assembly.resolveModel,
272
282
  resolveTools: assembly.resolveTools,
@@ -280,7 +290,7 @@ export class AgentRuntimeAdapter {
280
290
  interruptOn,
281
291
  runtimeAdapterOptions: this.options,
282
292
  createDeclaredMiddlewareResolverOptions: assembly.createDeclaredMiddlewareResolverOptions,
283
- resolveLangChainAutomaticMiddleware: (currentBinding) => this.resolveLangChainAutomaticMiddleware(currentBinding),
293
+ resolveLangChainRuntimeExtensionMiddleware: (currentBinding) => this.resolveLangChainRuntimeExtensionMiddleware(currentBinding),
284
294
  });
285
295
  }
286
296
  async resolveSubagents(subagents, binding) {
@@ -1,2 +1,3 @@
1
1
  export { extractReasoningText, extractToolFallbackContext, extractVisibleOutput, hasToolCalls, isLikelyToolArgsObject, readTextContent, sanitizeVisibleText, tryParseJson, wrapResolvedModel, } from "./output-parsing.js";
2
- export { extractAgentStep, extractInterruptPayload, extractReasoningStreamOutput, extractTerminalStreamOutput, extractToolResult, normalizeTerminalOutputKey, readStreamDelta, type RuntimeStreamChunk, } from "./stream-event-parsing.js";
2
+ export { extractInterruptPayload, extractReasoningStreamOutput, extractTerminalStreamOutput, extractToolResult, normalizeTerminalOutputKey, readStreamDelta, type RuntimeStreamChunk, } from "./stream-event-parsing.js";
3
+ export type { CompatibleStreamPart, NormalizedUpstreamEvent, UpstreamRuntimeEvent, } from "./stream-event-types.js";
@@ -1,2 +1,2 @@
1
1
  export { extractReasoningText, extractToolFallbackContext, extractVisibleOutput, hasToolCalls, isLikelyToolArgsObject, readTextContent, sanitizeVisibleText, tryParseJson, wrapResolvedModel, } from "./output-parsing.js";
2
- export { extractAgentStep, extractInterruptPayload, extractReasoningStreamOutput, extractTerminalStreamOutput, extractToolResult, normalizeTerminalOutputKey, readStreamDelta, } from "./stream-event-parsing.js";
2
+ export { extractInterruptPayload, extractReasoningStreamOutput, extractTerminalStreamOutput, extractToolResult, normalizeTerminalOutputKey, readStreamDelta, } from "./stream-event-parsing.js";
@@ -1,4 +1,4 @@
1
- import type { CompatibleStreamPart, UpstreamRuntimeEvent } from "../../contracts/types.js";
1
+ import type { CompatibleStreamPart, UpstreamRuntimeEvent } from "./stream-event-types.js";
2
2
  export type RuntimeStreamChunk = {
3
3
  kind: "upstream-event";
4
4
  event: UpstreamRuntimeEvent;
@@ -26,7 +26,6 @@ export declare function extractTerminalStreamOutput(event: unknown): string;
26
26
  export declare function extractReasoningStreamOutput(event: unknown): string;
27
27
  export declare function extractVisibleStreamOutput(event: unknown): string;
28
28
  export declare function extractStateStreamOutput(event: unknown): string;
29
- export declare function extractAgentStep(event: unknown): string | null;
30
29
  export declare function extractToolResult(event: unknown): {
31
30
  toolName: string;
32
31
  output: unknown;
@@ -129,15 +129,6 @@ function normalizeUpstreamEventShape(event) {
129
129
  ...(nodeName ? { nodeName } : {}),
130
130
  };
131
131
  }
132
- const agentStep = extractAgentStep(event.raw);
133
- if (agentStep) {
134
- return {
135
- kind: "agent-step",
136
- label: agentStep,
137
- ...(ns && ns.length > 0 ? { ns } : {}),
138
- ...(nodeName ? { nodeName } : {}),
139
- };
140
- }
141
132
  return {
142
133
  kind: "run-event",
143
134
  eventName: event.event ?? "unknown",
@@ -230,25 +221,6 @@ export function extractCustomCompatibleStreamPart(event) {
230
221
  data: custom.data,
231
222
  };
232
223
  }
233
- function formatStepValue(value, maxLength = 120) {
234
- if (value == null)
235
- return "";
236
- const normalized = typeof value === "string"
237
- ? parseMaybeJson(value)
238
- : value;
239
- const summarized = summarizeStepValue(normalized);
240
- const serialized = typeof summarized === "string"
241
- ? summarized
242
- : (() => {
243
- try {
244
- return JSON.stringify(summarized);
245
- }
246
- catch {
247
- return String(summarized);
248
- }
249
- })();
250
- return serialized.length > maxLength ? serialized.slice(0, maxLength) + "…" : serialized;
251
- }
252
224
  function parseMaybeJson(value) {
253
225
  const trimmed = value.trim();
254
226
  if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) {
@@ -261,26 +233,6 @@ function parseMaybeJson(value) {
261
233
  return value;
262
234
  }
263
235
  }
264
- function summarizeStepValue(value) {
265
- if (typeof value !== "object" || !value) {
266
- return value;
267
- }
268
- const record = value;
269
- if (typeof record.url === "string" && typeof record.status === "number") {
270
- const warnings = Array.isArray(record.warnings) ? record.warnings.filter((item) => typeof item === "string") : [];
271
- return {
272
- status: record.status,
273
- ok: record.ok,
274
- quality: record.quality,
275
- source: record.source,
276
- warnings,
277
- };
278
- }
279
- return value;
280
- }
281
- function humanizeEventName(name) {
282
- return name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[._-]+/g, " ").replace(/\s+/g, " ").trim().toLowerCase();
283
- }
284
236
  function readToolErrorText(value) {
285
237
  if (typeof value === "string") {
286
238
  return value;
@@ -352,57 +304,6 @@ export function extractStateStreamOutput(event) {
352
304
  }
353
305
  return extractVisibleOutput(chunk);
354
306
  }
355
- export function extractAgentStep(event) {
356
- if (typeof event !== "object" || !event)
357
- return null;
358
- const typed = event;
359
- const name = typeof typed.name === "string" ? typed.name : "";
360
- if (typed.event === "on_tool_start" || (typed.event === "on_chain_start" && typed.run_type === "tool")) {
361
- const inputSummary = formatStepValue(typed.data?.input);
362
- return inputSummary ? `tool ${name || "tool"} ${inputSummary}` : `tool ${name || "tool"}`;
363
- }
364
- if (typed.event === "on_tool_end" || (typed.event === "on_chain_end" && typed.run_type === "tool")) {
365
- const outputSummary = formatStepValue(typed.data?.output, 80);
366
- return outputSummary ? `tool ${name || "tool"} done ${outputSummary}` : `tool ${name || "tool"} done`;
367
- }
368
- if (typed.event === "on_tool_error" || (typed.event === "on_chain_error" && typed.run_type === "tool")) {
369
- const errorSummary = formatStepValue(typed.data?.error ?? typed.data?.output, 80);
370
- return errorSummary ? `tool ${name || "tool"} error ${errorSummary}` : `tool ${name || "tool"} error`;
371
- }
372
- if (typed.event === "on_chat_model_start") {
373
- const inputTools = typed.data?.input?.tools;
374
- const tools = typed.invocation_params?.tools ?? inputTools ?? [];
375
- const toolNames = tools.map((tool) => tool.name ?? tool.function?.name).filter((toolName) => typeof toolName === "string").join(", ");
376
- return toolNames ? `calling model tools: [${toolNames}]` : "calling model…";
377
- }
378
- if (typed.event === "on_chain_start") {
379
- if (/SkillsMiddleware/i.test(name))
380
- return "loading skills…";
381
- if (/MemoryMiddleware/i.test(name))
382
- return "loading memory…";
383
- if (/patchToolCallsMiddleware/i.test(name))
384
- return "normalizing tool calls…";
385
- if (/HumanInTheLoopMiddleware/i.test(name))
386
- return "checking approvals…";
387
- if (/todoListMiddleware/i.test(name))
388
- return "updating plan…";
389
- if (/model_request/i.test(name))
390
- return "preparing model request…";
391
- if (/RunnableLambda/i.test(name) || /^__start__$/.test(name))
392
- return null;
393
- if (/(subagent|specialist)/i.test(name))
394
- return `starting ${humanizeEventName(name)}…`;
395
- if (/agent$/i.test(name))
396
- return `running ${humanizeEventName(name)}…`;
397
- }
398
- if (typed.event === "on_chain_end") {
399
- if (/(subagent|specialist)/i.test(name))
400
- return `${humanizeEventName(name)} done`;
401
- if (/agent$/i.test(name) && !/^__start__$/.test(name))
402
- return `${humanizeEventName(name)} done`;
403
- }
404
- return null;
405
- }
406
307
  export function extractToolResult(event) {
407
308
  if (typeof event !== "object" || !event)
408
309
  return null;
@@ -0,0 +1,62 @@
1
+ export type NormalizedUpstreamEvent = {
2
+ kind: "text-delta";
3
+ source: "model" | "state";
4
+ text: string;
5
+ ns?: string[];
6
+ nodeName?: string;
7
+ } | {
8
+ kind: "reasoning-delta";
9
+ text: string;
10
+ ns?: string[];
11
+ nodeName?: string;
12
+ } | {
13
+ kind: "tool-start";
14
+ toolName: string;
15
+ input?: unknown;
16
+ ns?: string[];
17
+ nodeName?: string;
18
+ } | {
19
+ kind: "tool-end";
20
+ toolName: string;
21
+ output?: unknown;
22
+ isError?: boolean;
23
+ ns?: string[];
24
+ nodeName?: string;
25
+ } | {
26
+ kind: "interrupt";
27
+ interrupt: unknown;
28
+ ns?: string[];
29
+ nodeName?: string;
30
+ } | {
31
+ kind: "run-event";
32
+ eventName: string;
33
+ data?: Record<string, unknown>;
34
+ ns?: string[];
35
+ nodeName?: string;
36
+ };
37
+ export type CompatibleStreamPart = {
38
+ type: "messages";
39
+ ns: string[];
40
+ data: [unknown, Record<string, unknown>];
41
+ } | {
42
+ type: "updates";
43
+ ns: string[];
44
+ data: Record<string, unknown>;
45
+ } | {
46
+ type: "custom";
47
+ ns: string[];
48
+ data: unknown;
49
+ };
50
+ export type UpstreamRuntimeEvent = {
51
+ format: "langgraph-v2";
52
+ normalized: NormalizedUpstreamEvent;
53
+ streamPart: CompatibleStreamPart;
54
+ raw: unknown;
55
+ event?: string;
56
+ name?: string;
57
+ runType?: string;
58
+ data?: Record<string, unknown>;
59
+ metadata?: Record<string, unknown>;
60
+ tags?: string[];
61
+ ns?: string[];
62
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,8 +1,8 @@
1
- import type { CompiledAgentBinding, CompiledExecutionBinding, CompiledModel, CompiledSubAgent, CompiledTool, DeepAgentParams, LangChainAgentParams } from "../../contracts/types.js";
1
+ import type { CompiledAgentBinding, CompiledExecutionBinding, CompiledModel, CompiledSubAgent, CompiledTool, DeepAgentParams, LegacyDeepAgentParams, LegacyLangChainAgentParams, LangChainAgentParams } from "../../contracts/types.js";
2
2
  export type BindingExecutionView = {
3
3
  adapterKind: string;
4
- langchainParams?: LangChainAgentParams;
5
- deepAgentParams?: DeepAgentParams;
4
+ langchainParams?: LegacyLangChainAgentParams;
5
+ deepAgentParams?: LegacyDeepAgentParams;
6
6
  executionParams?: LangChainAgentParams | DeepAgentParams;
7
7
  primaryTools: CompiledTool[];
8
8
  primaryModel?: CompiledModel;
@@ -19,8 +19,8 @@ export declare function getBindingExecutionView(binding: CompiledAgentBinding):
19
19
  export declare function getBindingAdapterKind(binding: CompiledAgentBinding): string;
20
20
  export declare function getBindingCanonicalExecution(binding: CompiledAgentBinding): CompiledExecutionBinding | undefined;
21
21
  export declare function getBindingRuntimeExecutionMode(binding: CompiledAgentBinding): string;
22
- export declare function getBindingLangChainParams(binding: CompiledAgentBinding): LangChainAgentParams | undefined;
23
- export declare function getBindingDeepAgentParams(binding: CompiledAgentBinding): DeepAgentParams | undefined;
22
+ export declare function getBindingLangChainParams(binding: CompiledAgentBinding): LegacyLangChainAgentParams | undefined;
23
+ export declare function getBindingDeepAgentParams(binding: CompiledAgentBinding): LegacyDeepAgentParams | undefined;
24
24
  export declare function getBindingExecutionParams(binding: CompiledAgentBinding): LangChainAgentParams | DeepAgentParams | undefined;
25
25
  export declare function getBindingExecutionKind(binding: CompiledAgentBinding): "langchain-v1" | "deepagent" | undefined;
26
26
  export declare function withUpdatedBindingExecutionParams(binding: CompiledAgentBinding, updater: (params: LangChainAgentParams | DeepAgentParams) => LangChainAgentParams | DeepAgentParams): CompiledAgentBinding;
@@ -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.langchainAgentParams ??= binding.execution.params;
25
+ attachLegacyExecutionAliases(binding);
25
26
  return { adapterKind, execution: binding.execution };
26
27
  }
27
28
  if (binding.execution?.kind === "deepagent") {
28
- binding.deepAgentParams ??= binding.execution.params;
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" ? normalized.execution.params : undefined;
79
- const deepAgentParams = normalized.execution?.kind === "deepagent" ? normalized.execution.params : undefined;
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: langchainParams?.interruptOn ??
102
+ interruptCompatibilityRules: langchainRuntimeConfig?.interruptOn ??
103
+ langchainParams?.interruptOn ??
97
104
  deepAgentParams?.interruptOn,
98
- storeConfig: deepAgentParams?.store ?? binding.harnessRuntime?.store,
99
- langChainSubagentSupport: (langchainParams?.subagents?.length ?? 0) > 0 ||
100
- langchainParams?.generalPurposeAgent === true ||
101
- Boolean(langchainParams?.taskDescription?.trim()),
102
- deepAgentSubagentCount: deepAgentParams?.subagents?.length ?? 0,
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
- langchainAgentParams: updatedParams,
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
- deepAgentParams: updatedParams,
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) ? 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 execution = getBindingExecutionParams(binding);
176
- const value = execution?.generalPurposeAgent;
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 execution = getBindingExecutionParams(binding);
181
- const value = execution?.taskDescription;
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 execution = getBindingExecutionParams(binding);
191
- const filesystem = execution?.filesystem;
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,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
- langchainAgentParams: executionBinding.params,
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
- deepAgentParams: executionBinding.params,
334
- };
345
+ });
335
346
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botbotgo/agent-harness",
3
- "version": "0.0.119",
3
+ "version": "0.0.120",
4
4
  "description": "Workspace runtime for multi-agent applications",
5
5
  "type": "module",
6
6
  "packageManager": "npm@10.9.2",