@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.
Files changed (32) hide show
  1. package/dist/api.d.ts +1 -0
  2. package/dist/api.js +1 -0
  3. package/dist/contracts/runtime.d.ts +3 -113
  4. package/dist/contracts/workspace.d.ts +30 -12
  5. package/dist/index.d.ts +2 -1
  6. package/dist/index.js +1 -1
  7. package/dist/package-version.d.ts +1 -1
  8. package/dist/package-version.js +1 -1
  9. package/dist/runtime/adapter/middleware-assembly.d.ts +28 -4
  10. package/dist/runtime/adapter/middleware-assembly.js +65 -30
  11. package/dist/runtime/adapter/stream-event-projection.d.ts +0 -1
  12. package/dist/runtime/adapter/stream-event-projection.js +2 -8
  13. package/dist/runtime/agent-runtime-adapter.d.ts +2 -2
  14. package/dist/runtime/agent-runtime-adapter.js +39 -29
  15. package/dist/runtime/harness/events/listener-runtime.d.ts +3 -2
  16. package/dist/runtime/harness/events/streaming.d.ts +24 -3
  17. package/dist/runtime/harness/events/streaming.js +0 -20
  18. package/dist/runtime/harness/run/stream-run.d.ts +4 -6
  19. package/dist/runtime/harness/run/stream-run.js +1 -31
  20. package/dist/runtime/harness.js +10 -11
  21. package/dist/runtime/parsing/index.d.ts +1 -1
  22. package/dist/runtime/parsing/index.js +1 -1
  23. package/dist/runtime/parsing/stream-event-parsing.d.ts +1 -8
  24. package/dist/runtime/parsing/stream-event-parsing.js +0 -321
  25. package/dist/runtime/support/compiled-binding.d.ts +5 -5
  26. package/dist/runtime/support/compiled-binding.js +67 -27
  27. package/dist/upstream-events.d.ts +20 -0
  28. package/dist/upstream-events.js +172 -0
  29. package/dist/utils/compiled-binding.d.ts +3 -0
  30. package/dist/utils/compiled-binding.js +33 -0
  31. package/dist/workspace/agent-binding-compiler.js +28 -17
  32. package/package.json +1 -1
package/dist/api.d.ts CHANGED
@@ -4,6 +4,7 @@ import type { InventoryAgentRecord, InventorySkillRecord } from "./runtime/harne
4
4
  import type { RequirementAssessmentOptions } from "./runtime/harness/system/skill-requirements.js";
5
5
  import type { ToolMcpServerOptions } from "./mcp.js";
6
6
  export { AgentHarnessRuntime } from "./runtime/harness.js";
7
+ export { createUpstreamTimelineReducer } from "./upstream-events.js";
7
8
  type CreateAgentHarnessOptions = {
8
9
  /**
9
10
  * Workspace loading behavior.
package/dist/api.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { AgentHarnessRuntime } from "./runtime/harness.js";
2
2
  import { loadWorkspace } from "./workspace/compile.js";
3
3
  export { AgentHarnessRuntime } from "./runtime/harness.js";
4
+ export { createUpstreamTimelineReducer } from "./upstream-events.js";
4
5
  export async function createAgentHarness(workspaceRoot = process.cwd(), options = {}) {
5
6
  const workspace = await loadWorkspace(workspaceRoot, options.load ?? {});
6
7
  const harness = new AgentHarnessRuntime(workspace, options.adapter ?? {});
@@ -9,7 +9,7 @@ export type ThreadSummary = {
9
9
  status: RunState;
10
10
  };
11
11
  export type SessionRecord = ThreadSummary;
12
- export type KnownHarnessEventType = "run.created" | "run.queued" | "run.dequeued" | "run.state.changed" | "run.resumed" | "approval.requested" | "approval.resolved" | "artifact.created" | "output.delta" | "reasoning.delta" | "runtime.health.changed" | "runtime.synthetic_fallback";
12
+ export type KnownHarnessEventType = "run.created" | "run.queued" | "run.dequeued" | "run.state.changed" | "run.resumed" | "approval.requested" | "approval.resolved" | "artifact.created" | "output.delta" | "runtime.health.changed" | "runtime.synthetic_fallback";
13
13
  export type HarnessEventType = KnownHarnessEventType | (string & {});
14
14
  export type HarnessEvent = {
15
15
  eventId: string;
@@ -85,90 +85,12 @@ export type RunResult = {
85
85
  artifacts?: ArtifactRecord[];
86
86
  metadata?: Record<string, unknown>;
87
87
  };
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
- };
88
+ export type UpstreamRuntimeEvent = unknown;
156
89
  export type RuntimeListeners = {
157
90
  onEvent?: (event: HarnessEvent) => void | Promise<void>;
158
- };
159
- export type FrontendStreamListeners = {
160
- onChunk?: (chunk: string) => void | Promise<void>;
161
- onContentBlocks?: (blocks: unknown[]) => void | Promise<void>;
162
91
  onUpstreamEvent?: (event: UpstreamRuntimeEvent) => void | Promise<void>;
163
- onReasoning?: (chunk: string) => void | Promise<void>;
164
- onStep?: (step: string) => void | Promise<void>;
165
- onToolResult?: (item: {
166
- toolName: string;
167
- output: unknown;
168
- isError?: boolean;
169
- }) => void | Promise<void>;
170
92
  };
171
- export type RunListeners = RuntimeListeners & FrontendStreamListeners;
93
+ export type RunListeners = RuntimeListeners;
172
94
  export type MessageContentPart = {
173
95
  type: "text";
174
96
  text: string;
@@ -212,38 +134,6 @@ export type HarnessStreamItem = {
212
134
  } | {
213
135
  type: "result";
214
136
  result: RunResult;
215
- } | {
216
- type: "content";
217
- threadId: string;
218
- runId: string;
219
- agentId: string;
220
- content: string;
221
- } | {
222
- type: "content-blocks";
223
- threadId: string;
224
- runId: string;
225
- agentId: string;
226
- contentBlocks: unknown[];
227
- } | {
228
- type: "reasoning";
229
- threadId: string;
230
- runId: string;
231
- agentId: string;
232
- content: string;
233
- } | {
234
- type: "step";
235
- threadId: string;
236
- runId: string;
237
- agentId: string;
238
- content: string;
239
- } | {
240
- type: "tool-result";
241
- threadId: string;
242
- runId: string;
243
- agentId: string;
244
- toolName: string;
245
- output: unknown;
246
- isError?: boolean;
247
137
  };
248
138
  export type TranscriptMessage = {
249
139
  role: "user" | "assistant";
@@ -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>;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- export { AgentHarnessRuntime, cancelRun, createAgentHarness, createToolMcpServer, deleteThread, describeInventory, getApproval, getHealth, getRun, getThread, listAgentSkills, listApprovals, listRuns, listThreads, resolveApproval, run, serveToolsOverStdio, subscribe, stop, } from "./api.js";
1
+ export { AgentHarnessRuntime, cancelRun, createAgentHarness, createUpstreamTimelineReducer, createToolMcpServer, deleteThread, describeInventory, getApproval, getHealth, getRun, getThread, listAgentSkills, listApprovals, listRuns, listThreads, resolveApproval, run, serveToolsOverStdio, subscribe, stop, } from "./api.js";
2
2
  export type { ToolMcpServerOptions } from "./mcp.js";
3
3
  export { tool } from "./tools.js";
4
+ export type { UpstreamTimelineProjection, UpstreamTimelineReducer } from "./upstream-events.js";
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { AgentHarnessRuntime, cancelRun, createAgentHarness, createToolMcpServer, deleteThread, describeInventory, getApproval, getHealth, getRun, getThread, listAgentSkills, listApprovals, listRuns, listThreads, resolveApproval, run, serveToolsOverStdio, subscribe, stop, } from "./api.js";
1
+ export { AgentHarnessRuntime, cancelRun, createAgentHarness, createUpstreamTimelineReducer, createToolMcpServer, deleteThread, describeInventory, getApproval, getHealth, getRun, getThread, listAgentSkills, listApprovals, listRuns, listThreads, resolveApproval, run, serveToolsOverStdio, subscribe, stop, } from "./api.js";
2
2
  export { tool } from "./tools.js";
@@ -1 +1 @@
1
- export declare const AGENT_HARNESS_VERSION = "0.0.118";
1
+ export declare const AGENT_HARNESS_VERSION = "0.0.120";
@@ -1 +1 @@
1
- export const AGENT_HARNESS_VERSION = "0.0.118";
1
+ export const AGENT_HARNESS_VERSION = "0.0.120";
@@ -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) {
@@ -6,7 +6,6 @@ export type StreamEventProjectionState = {
6
6
  emittedToolError: boolean;
7
7
  emittedToolResult: boolean;
8
8
  seenTerminalOutputs: Set<string>;
9
- lastStep: string;
10
9
  };
11
10
  export declare function createStreamEventProjectionState(): StreamEventProjectionState;
12
11
  export declare function projectRuntimeStreamEvent(params: {
@@ -1,5 +1,5 @@
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, } from "../parsing/stream-event-parsing.js";
3
3
  import { resolveModelFacingToolName } from "./tool/tool-name-mapping.js";
4
4
  export function createStreamEventProjectionState() {
5
5
  return {
@@ -7,14 +7,13 @@ export function createStreamEventProjectionState() {
7
7
  emittedToolError: false,
8
8
  emittedToolResult: false,
9
9
  seenTerminalOutputs: new Set(),
10
- lastStep: "",
11
10
  };
12
11
  }
13
12
  export function projectRuntimeStreamEvent(params) {
14
13
  const { event, allowVisibleStreamDeltas, includeStateStreamOutput, toolNameMapping, primaryTools, state, } = params;
15
14
  const chunks = [{
16
15
  kind: "upstream-event",
17
- event: normalizeUpstreamRuntimeEvent(event),
16
+ event,
18
17
  }];
19
18
  const interruptPayload = extractInterruptPayload(event);
20
19
  if (interruptPayload) {
@@ -45,11 +44,6 @@ export function projectRuntimeStreamEvent(params) {
45
44
  }
46
45
  }
47
46
  }
48
- const agentStep = extractAgentStep(event);
49
- if (agentStep && agentStep !== state.lastStep) {
50
- state.lastStep = agentStep;
51
- chunks.push({ kind: "step", content: agentStep });
52
- }
53
47
  const toolResult = extractToolResult(event);
54
48
  if (toolResult) {
55
49
  state.emittedToolResult = true;
@@ -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,4 +1,5 @@
1
- import type { HarnessStreamItem, RunListeners, RunResult } from "../../../contracts/types.js";
1
+ import type { RunListeners, RunResult } from "../../../contracts/types.js";
2
+ import { type InternalHarnessStreamItem } from "./streaming.js";
2
3
  export declare function createListenerDispatchRuntime(input: {
3
4
  notifyListener: <T>(listener: ((value: T) => void | Promise<void>) | undefined, value: T) => Promise<void>;
4
5
  getThread: (threadId: string) => Promise<{
@@ -14,5 +15,5 @@ export declare function createListenerDispatchRuntime(input: {
14
15
  };
15
16
  } | null>;
16
17
  }): {
17
- dispatchRunListeners: (stream: AsyncGenerator<HarnessStreamItem>, listeners: RunListeners) => Promise<RunResult>;
18
+ dispatchRunListeners: (stream: AsyncGenerator<InternalHarnessStreamItem>, listeners: RunListeners) => Promise<RunResult>;
18
19
  };