@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
@@ -1,8 +1,29 @@
1
1
  import type { HarnessEvent, HarnessStreamItem, RunListeners, RunResult } from "../../../contracts/types.js";
2
- export declare function emitOutputDeltaAndCreateItem(emit: (threadId: string, runId: string, sequence: number, eventType: string, payload: Record<string, unknown>) => Promise<HarnessEvent>, threadId: string, runId: string, agentId: string, content: string): Promise<HarnessStreamItem>;
3
- export declare function createContentBlocksItem(threadId: string, runId: string, agentId: string, contentBlocks: unknown[]): HarnessStreamItem;
2
+ export type InternalHarnessStreamItem = HarnessStreamItem | {
3
+ type: "content";
4
+ threadId: string;
5
+ runId: string;
6
+ agentId: string;
7
+ content: string;
8
+ } | {
9
+ type: "content-blocks";
10
+ threadId: string;
11
+ runId: string;
12
+ agentId: string;
13
+ contentBlocks: unknown[];
14
+ } | {
15
+ type: "tool-result";
16
+ threadId: string;
17
+ runId: string;
18
+ agentId: string;
19
+ toolName: string;
20
+ output: unknown;
21
+ isError?: boolean;
22
+ };
23
+ export declare function emitOutputDeltaAndCreateItem(emit: (threadId: string, runId: string, sequence: number, eventType: string, payload: Record<string, unknown>) => Promise<HarnessEvent>, threadId: string, runId: string, agentId: string, content: string): Promise<InternalHarnessStreamItem>;
24
+ export declare function createContentBlocksItem(threadId: string, runId: string, agentId: string, contentBlocks: unknown[]): InternalHarnessStreamItem;
4
25
  export declare function createToolResultKey(toolName: string, output: unknown, isError?: boolean): string;
5
- export declare function dispatchRunListeners(stream: AsyncGenerator<HarnessStreamItem>, listeners: RunListeners, options: {
26
+ export declare function dispatchRunListeners(stream: AsyncGenerator<InternalHarnessStreamItem>, listeners: RunListeners, options: {
6
27
  notifyListener: <T>(listener: ((value: T) => void | Promise<void>) | undefined, value: T) => Promise<void>;
7
28
  getThread: (threadId: string) => Promise<{
8
29
  currentState: RunResult["state"];
@@ -50,28 +50,8 @@ export async function dispatchRunListeners(stream, listeners, options) {
50
50
  }
51
51
  if (item.type === "content") {
52
52
  output += item.content;
53
- await options.notifyListener(listeners.onChunk, item.content);
54
53
  continue;
55
54
  }
56
- if (item.type === "content-blocks") {
57
- await options.notifyListener(listeners.onContentBlocks, item.contentBlocks);
58
- continue;
59
- }
60
- if (item.type === "reasoning") {
61
- await options.notifyListener(listeners.onReasoning, item.content);
62
- continue;
63
- }
64
- if (item.type === "step") {
65
- await options.notifyListener(listeners.onStep, item.content);
66
- continue;
67
- }
68
- if (item.type === "tool-result") {
69
- await options.notifyListener(listeners.onToolResult, {
70
- toolName: item.toolName,
71
- output: item.output,
72
- isError: item.isError,
73
- });
74
- }
75
55
  }
76
56
  if (!latestEvent) {
77
57
  throw new Error("run did not emit any events");
@@ -1,14 +1,12 @@
1
- import type { CompiledAgentBinding, HarnessEvent, HarnessStreamItem, MessageContent, RunResult, TranscriptMessage } from "../../../contracts/types.js";
1
+ import type { CompiledAgentBinding, HarnessEvent, MessageContent, RunResult, TranscriptMessage } from "../../../contracts/types.js";
2
+ import { type InternalHarnessStreamItem } from "../events/streaming.js";
2
3
  type RuntimeStreamChunk = string | {
3
4
  kind: "content" | "interrupt" | "reasoning" | "step" | "tool-result" | "upstream-event";
4
5
  content?: string;
5
6
  toolName?: string;
6
7
  output?: unknown;
7
8
  isError?: boolean;
8
- event?: {
9
- format?: string;
10
- raw?: unknown;
11
- } | Record<string, unknown>;
9
+ event?: unknown;
12
10
  };
13
11
  type StreamRunOptions = {
14
12
  binding: CompiledAgentBinding;
@@ -49,5 +47,5 @@ type StreamRunOptions = {
49
47
  clearRunRequest: (threadId: string, runId: string) => Promise<void>;
50
48
  emitSyntheticFallback: (threadId: string, runId: string, selectedAgentId: string, error: unknown) => Promise<void>;
51
49
  };
52
- export declare function streamHarnessRun(options: StreamRunOptions): AsyncGenerator<HarnessStreamItem>;
50
+ export declare function streamHarnessRun(options: StreamRunOptions): AsyncGenerator<InternalHarnessStreamItem>;
53
51
  export {};
@@ -1,5 +1,4 @@
1
1
  import { AGENT_INTERRUPT_SENTINEL_PREFIX, RuntimeOperationTimeoutError } from "../../agent-runtime-adapter.js";
2
- import { normalizeUpstreamRuntimeEvent } from "../../parsing/stream-event-parsing.js";
3
2
  import { renderRuntimeFailure, renderToolFailure } from "../../support/harness-support.js";
4
3
  import { createContentBlocksItem, createToolResultKey, emitOutputDeltaAndCreateItem, } from "../events/streaming.js";
5
4
  function normalizeStreamChunk(chunk) {
@@ -18,9 +17,6 @@ function normalizeStreamChunk(chunk) {
18
17
  if (chunk.kind === "reasoning") {
19
18
  return { kind: "reasoning", content: chunk.content ?? "" };
20
19
  }
21
- if (chunk.kind === "step") {
22
- return { kind: "step", content: chunk.content ?? "" };
23
- }
24
20
  if (chunk.kind === "tool-result") {
25
21
  return {
26
22
  kind: "tool-result",
@@ -31,9 +27,6 @@ function normalizeStreamChunk(chunk) {
31
27
  }
32
28
  return { kind: "content", content: chunk.content ?? "" };
33
29
  }
34
- function isUpstreamRuntimeEvent(event) {
35
- return event.format === "langgraph-v2" && "normalized" in event && "streamPart" in event;
36
- }
37
30
  export async function* streamHarnessRun(options) {
38
31
  const priorHistoryPromise = Promise.resolve(options.isNewThread ? [] : undefined).then((historyHint) => historyHint ?? options.loadPriorHistory(options.threadId, options.runId));
39
32
  yield { type: "event", event: await options.runCreatedEventPromise };
@@ -62,15 +55,12 @@ export async function* streamHarnessRun(options) {
62
55
  streamActivityObserved = true;
63
56
  const normalizedChunk = normalizeStreamChunk(rawChunk);
64
57
  if (normalizedChunk.kind === "upstream-event") {
65
- const rawEvent = normalizedChunk.event;
66
58
  yield {
67
59
  type: "upstream-event",
68
60
  threadId: options.threadId,
69
61
  runId: options.runId,
70
62
  agentId: options.selectedAgentId,
71
- event: isUpstreamRuntimeEvent(rawEvent)
72
- ? rawEvent
73
- : normalizeUpstreamRuntimeEvent(rawEvent.raw ?? rawEvent),
63
+ event: normalizedChunk.event,
74
64
  };
75
65
  continue;
76
66
  }
@@ -100,26 +90,6 @@ export async function* streamHarnessRun(options) {
100
90
  return;
101
91
  }
102
92
  if (normalizedChunk.kind === "reasoning") {
103
- await options.emit(options.threadId, options.runId, 3, "reasoning.delta", {
104
- content: normalizedChunk.content,
105
- });
106
- yield {
107
- type: "reasoning",
108
- threadId: options.threadId,
109
- runId: options.runId,
110
- agentId: options.selectedAgentId,
111
- content: normalizedChunk.content,
112
- };
113
- continue;
114
- }
115
- if (normalizedChunk.kind === "step") {
116
- yield {
117
- type: "step",
118
- threadId: options.threadId,
119
- runId: options.runId,
120
- agentId: options.selectedAgentId,
121
- content: normalizedChunk.content,
122
- };
123
93
  continue;
124
94
  }
125
95
  if (normalizedChunk.kind === "tool-result") {
@@ -38,7 +38,6 @@ export class AgentHarnessRuntime {
38
38
  "run.queued",
39
39
  "run.dequeued",
40
40
  "output.delta",
41
- "reasoning.delta",
42
41
  ]);
43
42
  eventBus = new EventBus();
44
43
  persistence;
@@ -464,15 +463,10 @@ export class AgentHarnessRuntime {
464
463
  const binding = getWorkspaceBinding(this.workspace, selectedAgentId);
465
464
  if (!binding) {
466
465
  const result = await this.run(options);
467
- for (const line of result.output.split("\n")) {
468
- yield {
469
- type: "content",
470
- threadId: result.threadId,
471
- runId: result.runId,
472
- agentId: result.agentId ?? selectedAgentId,
473
- content: `${line}\n`,
474
- };
475
- }
466
+ yield {
467
+ type: "result",
468
+ result,
469
+ };
476
470
  return;
477
471
  }
478
472
  const { threadId, runId, isNewThread, runCreatedEventPromise, releaseRunSlotPromise, } = await prepareRunStart(this.createPrepareRunStartRuntime(), {
@@ -486,7 +480,7 @@ export class AgentHarnessRuntime {
486
480
  state: "running",
487
481
  }),
488
482
  });
489
- yield* streamHarnessRun({
483
+ const stream = streamHarnessRun({
490
484
  binding,
491
485
  input: options.input,
492
486
  invocation,
@@ -506,6 +500,11 @@ export class AgentHarnessRuntime {
506
500
  clearRunRequest: (threadId, runId) => this.persistence.clearRunRequest(threadId, runId),
507
501
  emitSyntheticFallback: (threadId, runId, selectedAgentId, error) => this.runtimeEventOperations.emitSyntheticFallback(threadId, runId, selectedAgentId, error),
508
502
  });
503
+ for await (const item of stream) {
504
+ if (item.type === "event" || item.type === "upstream-event" || item.type === "result") {
505
+ yield item;
506
+ }
507
+ }
509
508
  }
510
509
  async resume(options) {
511
510
  return resumeRun({
@@ -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, type RuntimeStreamChunk, } from "./stream-event-parsing.js";
2
+ export { extractInterruptPayload, extractReasoningStreamOutput, extractTerminalStreamOutput, extractToolResult, normalizeTerminalOutputKey, readStreamDelta, type RuntimeStreamChunk, } from "./stream-event-parsing.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,7 +1,6 @@
1
- import type { CompatibleStreamPart, UpstreamRuntimeEvent } from "../../contracts/types.js";
2
1
  export type RuntimeStreamChunk = {
3
2
  kind: "upstream-event";
4
- event: UpstreamRuntimeEvent;
3
+ event: unknown;
5
4
  } | {
6
5
  kind: "content";
7
6
  content: string;
@@ -11,22 +10,16 @@ export type RuntimeStreamChunk = {
11
10
  } | {
12
11
  kind: "interrupt";
13
12
  content: string;
14
- } | {
15
- kind: "step";
16
- content: string;
17
13
  } | {
18
14
  kind: "tool-result";
19
15
  toolName: string;
20
16
  output: unknown;
21
17
  isError?: boolean;
22
18
  };
23
- export declare function normalizeUpstreamRuntimeEvent(event: unknown): UpstreamRuntimeEvent;
24
- export declare function extractCustomCompatibleStreamPart(event: unknown): CompatibleStreamPart | null;
25
19
  export declare function extractTerminalStreamOutput(event: unknown): string;
26
20
  export declare function extractReasoningStreamOutput(event: unknown): string;
27
21
  export declare function extractVisibleStreamOutput(event: unknown): string;
28
22
  export declare function extractStateStreamOutput(event: unknown): string;
29
- export declare function extractAgentStep(event: unknown): string | null;
30
23
  export declare function extractToolResult(event: unknown): {
31
24
  toolName: string;
32
25
  output: unknown;
@@ -1,254 +1,4 @@
1
1
  import { extractReasoningText, extractVisibleOutput, hasToolCalls, readTextContent } from "./output-parsing.js";
2
- function asObject(value) {
3
- return typeof value === "object" && value !== null ? value : undefined;
4
- }
5
- function extractCustomStreamData(event) {
6
- const typed = asObject(event);
7
- if (!typed) {
8
- return null;
9
- }
10
- const eventName = typeof typed.event === "string" ? typed.event : "";
11
- const ns = Array.isArray(typed.ns) ? typed.ns.filter((item) => typeof item === "string") : undefined;
12
- const data = asObject(typed.data);
13
- if (eventName === "on_custom_event") {
14
- return {
15
- ...(ns && ns.length > 0 ? { ns } : {}),
16
- data: typed.data,
17
- };
18
- }
19
- if (eventName === "on_chain_stream" && data && "custom" in data) {
20
- return {
21
- ...(ns && ns.length > 0 ? { ns } : {}),
22
- data: data.custom,
23
- };
24
- }
25
- return null;
26
- }
27
- export function normalizeUpstreamRuntimeEvent(event) {
28
- const typed = asObject(event);
29
- const tags = Array.isArray(typed?.tags) ? typed.tags.filter((item) => typeof item === "string") : undefined;
30
- const ns = Array.isArray(typed?.ns) ? typed.ns.filter((item) => typeof item === "string") : undefined;
31
- const name = typeof typed?.name === "string" ? typed.name : undefined;
32
- const eventName = typeof typed?.event === "string" ? typed.event : undefined;
33
- const runType = typeof typed?.run_type === "string" ? typed.run_type : undefined;
34
- const data = asObject(typed?.data);
35
- const metadata = asObject(typed?.metadata);
36
- const normalized = normalizeUpstreamEventShape({
37
- raw: event,
38
- event: eventName,
39
- name,
40
- runType,
41
- metadata,
42
- tags,
43
- data,
44
- ns,
45
- });
46
- const streamPart = normalizeCompatibleStreamPart({
47
- raw: event,
48
- event: eventName,
49
- name,
50
- runType,
51
- metadata,
52
- tags,
53
- data,
54
- ns,
55
- normalized,
56
- });
57
- return {
58
- format: "langgraph-v2",
59
- normalized,
60
- raw: event,
61
- event: eventName,
62
- name,
63
- runType,
64
- data,
65
- metadata,
66
- ...(tags && tags.length > 0 ? { tags } : {}),
67
- ...(ns && ns.length > 0 ? { ns } : {}),
68
- streamPart,
69
- };
70
- }
71
- function normalizeUpstreamEventShape(event) {
72
- const nodeName = event.name;
73
- const ns = event.ns;
74
- const interruptPayload = extractInterruptPayload(event.raw);
75
- if (interruptPayload) {
76
- return {
77
- kind: "interrupt",
78
- interrupt: parseMaybeJson(interruptPayload),
79
- ...(ns && ns.length > 0 ? { ns } : {}),
80
- ...(nodeName ? { nodeName } : {}),
81
- };
82
- }
83
- const reasoning = extractReasoningStreamOutput(event.raw);
84
- if (reasoning) {
85
- return {
86
- kind: "reasoning-delta",
87
- text: reasoning,
88
- ...(ns && ns.length > 0 ? { ns } : {}),
89
- ...(nodeName ? { nodeName } : {}),
90
- };
91
- }
92
- const visibleText = extractVisibleStreamOutput(event.raw);
93
- if (visibleText) {
94
- return {
95
- kind: "text-delta",
96
- source: "model",
97
- text: visibleText,
98
- ...(ns && ns.length > 0 ? { ns } : {}),
99
- ...(nodeName ? { nodeName } : {}),
100
- };
101
- }
102
- const stateText = extractStateStreamOutput(event.raw);
103
- if (stateText) {
104
- return {
105
- kind: "text-delta",
106
- source: "state",
107
- text: stateText,
108
- ...(ns && ns.length > 0 ? { ns } : {}),
109
- ...(nodeName ? { nodeName } : {}),
110
- };
111
- }
112
- if (event.event === "on_tool_start" || (event.event === "on_chain_start" && event.runType === "tool")) {
113
- return {
114
- kind: "tool-start",
115
- toolName: nodeName ?? "tool",
116
- ...(event.data && "input" in event.data ? { input: event.data.input } : {}),
117
- ...(ns && ns.length > 0 ? { ns } : {}),
118
- ...(nodeName ? { nodeName } : {}),
119
- };
120
- }
121
- const toolResult = extractToolResult(event.raw);
122
- if (toolResult) {
123
- return {
124
- kind: "tool-end",
125
- toolName: toolResult.toolName,
126
- ...(toolResult.output !== undefined ? { output: toolResult.output } : {}),
127
- ...(toolResult.isError !== undefined ? { isError: toolResult.isError } : {}),
128
- ...(ns && ns.length > 0 ? { ns } : {}),
129
- ...(nodeName ? { nodeName } : {}),
130
- };
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
- return {
142
- kind: "run-event",
143
- eventName: event.event ?? "unknown",
144
- ...(event.data ? { data: event.data } : {}),
145
- ...(ns && ns.length > 0 ? { ns } : {}),
146
- ...(nodeName ? { nodeName } : {}),
147
- };
148
- }
149
- function normalizeCompatibleStreamPart(event) {
150
- const custom = extractCustomCompatibleStreamPart(event.raw);
151
- if (custom) {
152
- return custom;
153
- }
154
- const ns = event.ns ?? [];
155
- const messageChunk = extractMessageCompatibleStreamPart(event);
156
- if (messageChunk) {
157
- return {
158
- type: "messages",
159
- ns,
160
- data: [messageChunk, buildStreamPartMetadata(event)],
161
- };
162
- }
163
- return {
164
- type: "updates",
165
- ns,
166
- data: buildUpdateCompatiblePayload(event),
167
- };
168
- }
169
- function buildStreamPartMetadata(event) {
170
- return {
171
- ...(event.metadata ?? {}),
172
- ...(event.event ? { event: event.event } : {}),
173
- ...(event.name ? { name: event.name } : {}),
174
- ...(event.runType ? { run_type: event.runType } : {}),
175
- ...(event.tags && event.tags.length > 0 ? { tags: event.tags } : {}),
176
- };
177
- }
178
- function extractMessageCompatibleStreamPart(event) {
179
- const typed = asObject(event.raw);
180
- const data = asObject(typed?.data);
181
- if (event.event === "on_chat_model_stream" && data && "chunk" in data) {
182
- return data.chunk;
183
- }
184
- if (event.normalized.kind === "tool-end") {
185
- return {
186
- type: "tool",
187
- name: event.normalized.toolName,
188
- content: event.normalized.output,
189
- ...(event.normalized.isError !== undefined ? { isError: event.normalized.isError } : {}),
190
- };
191
- }
192
- return null;
193
- }
194
- function buildUpdateCompatiblePayload(event) {
195
- const key = event.name ?? event.event ?? "event";
196
- return {
197
- [key]: extractUpdateNodePayload(event),
198
- };
199
- }
200
- function extractUpdateNodePayload(event) {
201
- const data = event.data;
202
- if (event.event === "on_chain_stream" && data && "chunk" in data) {
203
- return data.chunk;
204
- }
205
- if ((event.event === "on_tool_start" || event.event === "on_chain_start") && data && "input" in data) {
206
- return { input: data.input };
207
- }
208
- if ((event.event === "on_tool_end" || event.event === "on_chain_end" || event.event === "on_chat_model_end") && data && "output" in data) {
209
- return data.output;
210
- }
211
- if ((event.event === "on_tool_error" || event.event === "on_chain_error") && data) {
212
- return {
213
- ...(data.output !== undefined ? { output: data.output } : {}),
214
- ...(data.error !== undefined ? { error: data.error } : {}),
215
- };
216
- }
217
- if (event.normalized.kind === "interrupt") {
218
- return { __interrupt__: event.normalized.interrupt };
219
- }
220
- return data ?? {};
221
- }
222
- export function extractCustomCompatibleStreamPart(event) {
223
- const custom = extractCustomStreamData(event);
224
- if (!custom) {
225
- return null;
226
- }
227
- return {
228
- type: "custom",
229
- ns: custom.ns ?? [],
230
- data: custom.data,
231
- };
232
- }
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
2
  function parseMaybeJson(value) {
253
3
  const trimmed = value.trim();
254
4
  if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) {
@@ -261,26 +11,6 @@ function parseMaybeJson(value) {
261
11
  return value;
262
12
  }
263
13
  }
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
14
  function readToolErrorText(value) {
285
15
  if (typeof value === "string") {
286
16
  return value;
@@ -352,57 +82,6 @@ export function extractStateStreamOutput(event) {
352
82
  }
353
83
  return extractVisibleOutput(chunk);
354
84
  }
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
85
  export function extractToolResult(event) {
407
86
  if (typeof event !== "object" || !event)
408
87
  return null;
@@ -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;