@botbotgo/agent-harness 0.0.118 → 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.
@@ -10,8 +10,12 @@ export function getDefaultHostAgentId(workspace, preferredHostAgentId) {
10
10
  }
11
11
  return inferRoutingBindings(workspace).primaryBinding?.agent.id ?? "agent";
12
12
  }
13
+ export function getDefaultRuntimeEntryAgentId(workspace, preferredRuntimeEntryAgentId) {
14
+ return getDefaultHostAgentId(workspace, preferredRuntimeEntryAgentId);
15
+ }
13
16
  export async function resolveSelectedAgentId(options) {
14
- const { workspace, input, requestedAgentId, threadId, preferredHostAgentId, getThreadSummary } = options;
17
+ const { workspace, input, requestedAgentId, threadId, preferredHostAgentId, preferredRuntimeEntryAgentId, getThreadSummary, } = options;
18
+ const preferredEntryAgentId = preferredRuntimeEntryAgentId ?? preferredHostAgentId;
15
19
  if (!requestedAgentId || requestedAgentId === AUTO_AGENT_ID) {
16
20
  if (threadId) {
17
21
  const thread = await getThreadSummary(threadId);
@@ -20,7 +24,7 @@ export async function resolveSelectedAgentId(options) {
20
24
  return thread.agentId;
21
25
  }
22
26
  }
23
- return getDefaultHostAgentId(workspace, preferredHostAgentId);
27
+ return getDefaultRuntimeEntryAgentId(workspace, preferredEntryAgentId);
24
28
  }
25
29
  return requestedAgentId;
26
30
  }
@@ -40,5 +44,5 @@ export function routeAgentId(options) {
40
44
  if (defaultBinding) {
41
45
  return defaultBinding.agent.id;
42
46
  }
43
- return getDefaultHostAgentId(workspace, routingDefaultAgentId);
47
+ return getDefaultRuntimeEntryAgentId(workspace, routingDefaultAgentId);
44
48
  }
@@ -3,7 +3,7 @@ import { createPersistentId } from "../../../utils/id.js";
3
3
  import { normalizeMessageContent } from "../../../utils/message-content.js";
4
4
  import { buildPersistedRunRequest, normalizeRunPriority } from "./helpers.js";
5
5
  import { getRequiredWorkspaceBinding } from "../bindings.js";
6
- import { getBindingAdapterKind } from "../../support/compiled-binding.js";
6
+ import { getBindingAdapterKind, getBindingRuntimeExecutionMode } from "../../support/compiled-binding.js";
7
7
  export async function ensureThreadStarted(runtime, input) {
8
8
  const { selectedAgentId, binding, message, runRequest, existingThreadId } = input;
9
9
  const threadId = existingThreadId ?? createPersistentId();
@@ -23,7 +23,7 @@ export async function ensureThreadStarted(runtime, input) {
23
23
  runId,
24
24
  status: "running",
25
25
  createdAt,
26
- executionMode: getBindingAdapterKind(binding),
26
+ executionMode: getBindingRuntimeExecutionMode(binding),
27
27
  adapterKind: getBindingAdapterKind(binding),
28
28
  userMessage,
29
29
  runRequest,
@@ -46,7 +46,7 @@ export async function ensureThreadStarted(runtime, input) {
46
46
  threadId,
47
47
  runId,
48
48
  agentId: binding.agent.id,
49
- executionMode: getBindingAdapterKind(binding),
49
+ executionMode: getBindingRuntimeExecutionMode(binding),
50
50
  adapterKind: getBindingAdapterKind(binding),
51
51
  createdAt,
52
52
  }),
@@ -14,8 +14,8 @@ export declare class AgentHarnessRuntime {
14
14
  private readonly stores;
15
15
  private readonly embeddingModels;
16
16
  private readonly vectorStores;
17
- private readonly hostBindings;
18
- private readonly defaultHostBinding?;
17
+ private readonly runtimeEntryBindings;
18
+ private readonly defaultRuntimeEntryBinding?;
19
19
  private readonly defaultRunRootValue;
20
20
  private readonly defaultStore;
21
21
  private readonly runtimeMemoryStore;
@@ -38,7 +38,7 @@ export declare class AgentHarnessRuntime {
38
38
  private readonly backgroundEventRuntime;
39
39
  private readonly runtimeEventOperations;
40
40
  private defaultRunRoot;
41
- private getDefaultHostAgentId;
41
+ private getDefaultRuntimeEntryAgentId;
42
42
  private resolveSelectedAgentId;
43
43
  private createPrepareRunStartRuntime;
44
44
  constructor(workspace: WorkspaceBundle, runtimeAdapterOptions?: RuntimeAdapterOptions);
@@ -18,10 +18,10 @@ import { buildResumePayload as buildHarnessResumePayload, resolveApprovalRecord
18
18
  import { cancelRunOperation, executeQueuedRunOperation, resumeRun } from "./harness/run/run-operations.js";
19
19
  import { acquireRunSlot as acquireHarnessRunSlot } from "./harness/run/run-slot-acquisition.js";
20
20
  import { dropPendingRunSlot, enqueuePendingRunSlot } from "./harness/run/run-queue.js";
21
- import { getDefaultHostAgentId, resolveSelectedAgentId, routeAgentId } from "./harness/run/routing.js";
21
+ import { getDefaultRuntimeEntryAgentId, resolveSelectedAgentId, routeAgentId } from "./harness/run/routing.js";
22
22
  import { resolveStoreFromConfig, } from "./harness/run/resources.js";
23
23
  import { createToolMcpServerFromTools, serveToolsOverStdioFromHarness } from "../mcp.js";
24
- import { getBindingAdapterKind } from "./support/compiled-binding.js";
24
+ import { getBindingRuntimeExecutionMode, } from "./support/compiled-binding.js";
25
25
  import { bindingSupportsRunningReplay, getWorkspaceBinding, resolveWorkspaceAgentTools, } from "./harness/bindings.js";
26
26
  import { describeWorkspaceInventory, listAgentSkills as listWorkspaceAgentSkills, } from "./harness/system/inventory.js";
27
27
  import { createDefaultHealthSnapshot, isInventoryEnabled, isThreadMemorySyncEnabled, } from "./harness/runtime-defaults.js";
@@ -48,8 +48,8 @@ export class AgentHarnessRuntime {
48
48
  stores = new Map();
49
49
  embeddingModels = new Map();
50
50
  vectorStores = new Map();
51
- hostBindings;
52
- defaultHostBinding;
51
+ runtimeEntryBindings;
52
+ defaultRuntimeEntryBinding;
53
53
  defaultRunRootValue;
54
54
  defaultStore;
55
55
  runtimeMemoryStore;
@@ -74,8 +74,8 @@ export class AgentHarnessRuntime {
74
74
  defaultRunRoot() {
75
75
  return this.defaultRunRootValue;
76
76
  }
77
- getDefaultHostAgentId() {
78
- return getDefaultHostAgentId(this.workspace, this.routingDefaultAgentId);
77
+ getDefaultRuntimeEntryAgentId() {
78
+ return getDefaultRuntimeEntryAgentId(this.workspace, this.routingDefaultAgentId);
79
79
  }
80
80
  async resolveSelectedAgentId(input, requestedAgentId, threadId) {
81
81
  return resolveSelectedAgentId({
@@ -83,7 +83,7 @@ export class AgentHarnessRuntime {
83
83
  input,
84
84
  requestedAgentId,
85
85
  threadId,
86
- preferredHostAgentId: this.routingDefaultAgentId,
86
+ preferredRuntimeEntryAgentId: this.routingDefaultAgentId,
87
87
  getThreadSummary: (currentThreadId) => this.getSession(currentThreadId),
88
88
  });
89
89
  }
@@ -100,16 +100,16 @@ export class AgentHarnessRuntime {
100
100
  constructor(workspace, runtimeAdapterOptions = {}) {
101
101
  this.workspace = workspace;
102
102
  this.runtimeAdapterOptions = runtimeAdapterOptions;
103
- this.hostBindings = inferRoutingBindings(this.workspace).hostBindings;
104
- this.defaultHostBinding = this.hostBindings[0];
105
- this.defaultRunRootValue = this.defaultHostBinding?.harnessRuntime.runRoot ?? `${this.workspace.workspaceRoot}/run-data`;
103
+ this.runtimeEntryBindings = inferRoutingBindings(this.workspace).runtimeEntryBindings;
104
+ this.defaultRuntimeEntryBinding = this.runtimeEntryBindings[0];
105
+ this.defaultRunRootValue = this.defaultRuntimeEntryBinding?.harnessRuntime.runRoot ?? `${this.workspace.workspaceRoot}/run-data`;
106
106
  const runRoot = this.defaultRunRoot();
107
107
  this.persistence = new SqlitePersistence(runRoot);
108
- const defaultStoreConfig = this.defaultHostBinding?.harnessRuntime.store;
108
+ const defaultStoreConfig = this.defaultRuntimeEntryBinding?.harnessRuntime.store;
109
109
  this.defaultStore = resolveStoreFromConfig(this.stores, defaultStoreConfig, runRoot) ?? new FileBackedStore(`${runRoot}/store.json`);
110
- const runtimeMemoryStoreConfig = typeof this.defaultHostBinding?.harnessRuntime.runtimeMemory?.store === "object" &&
111
- this.defaultHostBinding?.harnessRuntime.runtimeMemory?.store
112
- ? this.defaultHostBinding.harnessRuntime.runtimeMemory.store
110
+ const runtimeMemoryStoreConfig = typeof this.defaultRuntimeEntryBinding?.harnessRuntime.runtimeMemory?.store === "object" &&
111
+ this.defaultRuntimeEntryBinding?.harnessRuntime.runtimeMemory?.store
112
+ ? this.defaultRuntimeEntryBinding.harnessRuntime.runtimeMemory.store
113
113
  : undefined;
114
114
  this.runtimeMemoryStore = resolveStoreFromConfig(this.stores, runtimeMemoryStoreConfig, runRoot) ?? this.defaultStore;
115
115
  this.resolvedRuntimeAdapterOptions = resolveRuntimeAdapterOptions({
@@ -438,7 +438,7 @@ export class AgentHarnessRuntime {
438
438
  agentId: activeBinding.agent.id,
439
439
  requestedAgentId: defaultRequestedAgentId(options.agentId),
440
440
  selectedAgentId: activeSelectedAgentId,
441
- executionMode: getBindingAdapterKind(activeBinding),
441
+ executionMode: getBindingRuntimeExecutionMode(activeBinding),
442
442
  }),
443
443
  });
444
444
  await runCreatedEventPromise;
@@ -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, 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;
@@ -17,8 +17,10 @@ export type BindingExecutionView = {
17
17
  };
18
18
  export declare function getBindingExecutionView(binding: CompiledAgentBinding): BindingExecutionView;
19
19
  export declare function getBindingAdapterKind(binding: CompiledAgentBinding): string;
20
- export declare function getBindingLangChainParams(binding: CompiledAgentBinding): LangChainAgentParams | undefined;
21
- export declare function getBindingDeepAgentParams(binding: CompiledAgentBinding): DeepAgentParams | undefined;
20
+ export declare function getBindingCanonicalExecution(binding: CompiledAgentBinding): CompiledExecutionBinding | undefined;
21
+ export declare function getBindingRuntimeExecutionMode(binding: CompiledAgentBinding): string;
22
+ export declare function getBindingLangChainParams(binding: CompiledAgentBinding): LegacyLangChainAgentParams | undefined;
23
+ export declare function getBindingDeepAgentParams(binding: CompiledAgentBinding): LegacyDeepAgentParams | undefined;
22
24
  export declare function getBindingExecutionParams(binding: CompiledAgentBinding): LangChainAgentParams | DeepAgentParams | undefined;
23
25
  export declare function getBindingExecutionKind(binding: CompiledAgentBinding): "langchain-v1" | "deepagent" | undefined;
24
26
  export declare function withUpdatedBindingExecutionParams(binding: CompiledAgentBinding, updater: (params: LangChainAgentParams | DeepAgentParams) => LangChainAgentParams | DeepAgentParams): CompiledAgentBinding;