@botbotgo/agent-harness 0.0.99 → 0.0.101

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 (74) hide show
  1. package/README.md +3 -6
  2. package/README.zh.md +2 -2
  3. package/dist/benchmark/upstream-runtime-ab-benchmark.d.ts +1 -1
  4. package/dist/benchmark/upstream-runtime-ab-benchmark.js +1 -2
  5. package/dist/contracts/core.d.ts +2 -2
  6. package/dist/contracts/runtime.d.ts +1 -5
  7. package/dist/package-version.d.ts +1 -1
  8. package/dist/package-version.js +1 -1
  9. package/dist/resource/resource-impl.js +78 -76
  10. package/dist/runtime/adapter/deepagent-runnable-config.d.ts +30 -0
  11. package/dist/runtime/adapter/deepagent-runnable-config.js +22 -0
  12. package/dist/runtime/adapter/index.d.ts +0 -2
  13. package/dist/runtime/adapter/index.js +0 -2
  14. package/dist/runtime/adapter/invocation-result.d.ts +13 -0
  15. package/dist/runtime/adapter/invocation-result.js +40 -0
  16. package/dist/runtime/adapter/langchain-runnable-config.d.ts +25 -0
  17. package/dist/runtime/adapter/langchain-runnable-config.js +19 -0
  18. package/dist/runtime/adapter/local-tool-invocation.d.ts +23 -0
  19. package/dist/runtime/adapter/local-tool-invocation.js +64 -0
  20. package/dist/runtime/adapter/runtime-adapter-support.d.ts +18 -0
  21. package/dist/runtime/adapter/runtime-adapter-support.js +54 -0
  22. package/dist/runtime/adapter/stream-event-projection.d.ts +19 -0
  23. package/dist/runtime/adapter/stream-event-projection.js +79 -0
  24. package/dist/runtime/adapter/stream-text-consumption.d.ts +4 -0
  25. package/dist/runtime/adapter/stream-text-consumption.js +18 -0
  26. package/dist/runtime/adapter/tool/builtin-middleware-tools.d.ts +64 -0
  27. package/dist/runtime/adapter/tool/builtin-middleware-tools.js +144 -0
  28. package/dist/runtime/adapter/tool/tool-replay.d.ts +18 -0
  29. package/dist/runtime/adapter/tool/tool-replay.js +26 -0
  30. package/dist/runtime/agent-runtime-adapter.d.ts +2 -54
  31. package/dist/runtime/agent-runtime-adapter.js +122 -1568
  32. package/dist/runtime/harness/run/helpers.js +2 -8
  33. package/dist/runtime/harness/run/recovery.d.ts +42 -0
  34. package/dist/runtime/harness/run/recovery.js +139 -0
  35. package/dist/runtime/harness/run/routing.d.ts +1 -3
  36. package/dist/runtime/harness/run/routing.js +2 -25
  37. package/dist/runtime/harness/run/run-lifecycle.d.ts +0 -11
  38. package/dist/runtime/harness/run/run-lifecycle.js +7 -50
  39. package/dist/runtime/harness/runtime-defaults.d.ts +4 -0
  40. package/dist/runtime/harness/runtime-defaults.js +39 -0
  41. package/dist/runtime/harness/system/inventory.js +2 -1
  42. package/dist/runtime/harness/system/skill-requirements.d.ts +1 -0
  43. package/dist/runtime/harness.d.ts +5 -24
  44. package/dist/runtime/harness.js +356 -536
  45. package/dist/runtime/index.d.ts +1 -12
  46. package/dist/runtime/index.js +1 -12
  47. package/dist/runtime/support/compiled-binding.d.ts +0 -2
  48. package/dist/runtime/support/compiled-binding.js +3 -22
  49. package/dist/runtime/support/harness-support.d.ts +0 -11
  50. package/dist/runtime/support/harness-support.js +1 -44
  51. package/dist/runtime/support/index.d.ts +1 -1
  52. package/dist/runtime/support/index.js +1 -1
  53. package/dist/runtime/support/runtime-factories.js +2 -2
  54. package/dist/workspace/agent-binding-compiler.js +9 -93
  55. package/dist/workspace/index.d.ts +0 -5
  56. package/dist/workspace/index.js +0 -5
  57. package/dist/workspace/object-loader.js +44 -99
  58. package/dist/workspace/support/agent-capabilities.js +2 -2
  59. package/dist/workspace/support/workspace-ref-utils.d.ts +0 -2
  60. package/dist/workspace/support/workspace-ref-utils.js +0 -17
  61. package/dist/workspace/validate.js +1 -1
  62. package/package.json +1 -1
  63. package/dist/config/workflows/langgraph-workflows.yaml +0 -570
  64. package/dist/config/workflows/runtime-profiles.yaml +0 -94
  65. package/dist/runtime/adapter/langgraph/presets.d.ts +0 -25
  66. package/dist/runtime/adapter/langgraph/presets.js +0 -165
  67. package/dist/runtime/adapter/langgraph/profiles.d.ts +0 -6
  68. package/dist/runtime/adapter/langgraph/profiles.js +0 -206
  69. package/dist/runtime/checkpoint-maintenance.d.ts +0 -1
  70. package/dist/runtime/checkpoint-maintenance.js +0 -1
  71. package/dist/runtime/file-checkpoint-saver.d.ts +0 -1
  72. package/dist/runtime/file-checkpoint-saver.js +0 -1
  73. package/dist/runtime/sqlite-maintained-checkpoint-saver.d.ts +0 -1
  74. package/dist/runtime/sqlite-maintained-checkpoint-saver.js +0 -1
@@ -0,0 +1,18 @@
1
+ import type { CompiledAgentBinding } from "../../contracts/types.js";
2
+ export declare function countConfiguredTools(binding: CompiledAgentBinding): number;
3
+ export declare function asObject(value: unknown): Record<string, unknown> | undefined;
4
+ export declare function sleep(ms: number): Promise<void>;
5
+ export declare function hasConfiguredSubagentSupport(binding: CompiledAgentBinding): boolean;
6
+ export declare function hasConfiguredMiddlewareKind(binding: CompiledAgentBinding, kind: string): boolean;
7
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
8
+ export declare function isObject(value: unknown): value is Record<string, unknown>;
9
+ export declare function truncateLines(lines: string[], maxChars?: number): string;
10
+ export declare function summarizeBuiltinWriteTodosArgs(args: Record<string, unknown>): {
11
+ total: number;
12
+ pending: number;
13
+ completed: number;
14
+ items: Array<{
15
+ content: string;
16
+ status: string;
17
+ }>;
18
+ };
@@ -0,0 +1,54 @@
1
+ import { getBindingLangChainParams, getBindingMiddlewareConfigs, getBindingPrimaryTools } from "../support/compiled-binding.js";
2
+ export function countConfiguredTools(binding) {
3
+ return getBindingPrimaryTools(binding).length;
4
+ }
5
+ export function asObject(value) {
6
+ return typeof value === "object" && value ? value : undefined;
7
+ }
8
+ export function sleep(ms) {
9
+ return new Promise((resolve) => setTimeout(resolve, ms));
10
+ }
11
+ export function hasConfiguredSubagentSupport(binding) {
12
+ const params = getBindingLangChainParams(binding);
13
+ if (!params) {
14
+ return false;
15
+ }
16
+ return (params.subagents?.length ?? 0) > 0 || params.generalPurposeAgent === true || Boolean(params.taskDescription?.trim());
17
+ }
18
+ export function hasConfiguredMiddlewareKind(binding, kind) {
19
+ return getBindingMiddlewareConfigs(binding)?.some((entry) => entry.kind === kind) ?? false;
20
+ }
21
+ export function isRecord(value) {
22
+ return typeof value === "object" && value !== null && !Array.isArray(value);
23
+ }
24
+ export function isObject(value) {
25
+ return isRecord(value);
26
+ }
27
+ export function truncateLines(lines, maxChars = 12_000) {
28
+ const joined = lines.join("\n");
29
+ if (joined.length <= maxChars) {
30
+ return joined;
31
+ }
32
+ return `${joined.slice(0, maxChars - 18)}\n...[truncated]`;
33
+ }
34
+ export function summarizeBuiltinWriteTodosArgs(args) {
35
+ const todos = Array.isArray(args.todos) ? args.todos : [];
36
+ const items = todos.flatMap((todo) => {
37
+ if (!isObject(todo)) {
38
+ return [];
39
+ }
40
+ const content = typeof todo.content === "string" && todo.content.trim().length > 0
41
+ ? todo.content.trim()
42
+ : typeof todo.description === "string" && todo.description.trim().length > 0
43
+ ? todo.description.trim()
44
+ : "";
45
+ const status = typeof todo.status === "string" && todo.status.trim().length > 0 ? todo.status.trim() : "pending";
46
+ return content ? [{ content, status }] : [];
47
+ });
48
+ return {
49
+ total: items.length,
50
+ pending: items.filter((item) => item.status !== "completed").length,
51
+ completed: items.filter((item) => item.status === "completed").length,
52
+ items,
53
+ };
54
+ }
@@ -0,0 +1,19 @@
1
+ import type { CompiledTool } from "../../contracts/types.js";
2
+ import { type RuntimeStreamChunk } from "../parsing/stream-event-parsing.js";
3
+ import { type ToolNameMapping } from "./tool/tool-name-mapping.js";
4
+ export type StreamEventProjectionState = {
5
+ emittedOutput: string;
6
+ emittedToolError: boolean;
7
+ emittedToolResult: boolean;
8
+ seenTerminalOutputs: Set<string>;
9
+ lastStep: string;
10
+ };
11
+ export declare function createStreamEventProjectionState(): StreamEventProjectionState;
12
+ export declare function projectRuntimeStreamEvent(params: {
13
+ event: unknown;
14
+ allowVisibleStreamDeltas: boolean;
15
+ includeStateStreamOutput: boolean;
16
+ toolNameMapping: ToolNameMapping;
17
+ primaryTools: CompiledTool[];
18
+ state: StreamEventProjectionState;
19
+ }): RuntimeStreamChunk[];
@@ -0,0 +1,79 @@
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";
3
+ import { resolveModelFacingToolName } from "./tool/tool-name-mapping.js";
4
+ export function createStreamEventProjectionState() {
5
+ return {
6
+ emittedOutput: "",
7
+ emittedToolError: false,
8
+ emittedToolResult: false,
9
+ seenTerminalOutputs: new Set(),
10
+ lastStep: "",
11
+ };
12
+ }
13
+ export function projectRuntimeStreamEvent(params) {
14
+ const { event, allowVisibleStreamDeltas, includeStateStreamOutput, toolNameMapping, primaryTools, state, } = params;
15
+ const chunks = [{
16
+ kind: "upstream-event",
17
+ event: normalizeUpstreamRuntimeEvent(event),
18
+ }];
19
+ const interruptPayload = extractInterruptPayload(event);
20
+ if (interruptPayload) {
21
+ chunks.push({ kind: "interrupt", content: interruptPayload });
22
+ return chunks;
23
+ }
24
+ const reasoning = extractReasoningStreamOutput(event);
25
+ if (reasoning) {
26
+ chunks.push({ kind: "reasoning", content: reasoning });
27
+ }
28
+ if (allowVisibleStreamDeltas) {
29
+ const visibleStreamOutput = extractVisibleStreamOutput(event);
30
+ if (visibleStreamOutput) {
31
+ const nextOutput = computeIncrementalOutput(state.emittedOutput, visibleStreamOutput);
32
+ state.emittedOutput = nextOutput.accumulated;
33
+ if (nextOutput.delta) {
34
+ chunks.push({ kind: "content", content: nextOutput.delta });
35
+ }
36
+ }
37
+ }
38
+ if (includeStateStreamOutput) {
39
+ const stateStreamOutput = extractStateStreamOutput(event);
40
+ if (stateStreamOutput) {
41
+ const nextOutput = computeIncrementalOutput(state.emittedOutput, sanitizeVisibleText(stateStreamOutput));
42
+ state.emittedOutput = nextOutput.accumulated;
43
+ if (nextOutput.delta) {
44
+ chunks.push({ kind: "content", content: nextOutput.delta });
45
+ }
46
+ }
47
+ }
48
+ const agentStep = extractAgentStep(event);
49
+ if (agentStep && agentStep !== state.lastStep) {
50
+ state.lastStep = agentStep;
51
+ chunks.push({ kind: "step", content: agentStep });
52
+ }
53
+ const toolResult = extractToolResult(event);
54
+ if (toolResult) {
55
+ state.emittedToolResult = true;
56
+ state.emittedToolError = state.emittedToolError || toolResult.isError === true;
57
+ chunks.push({
58
+ kind: "tool-result",
59
+ toolName: resolveModelFacingToolName(toolResult.toolName, toolNameMapping, primaryTools),
60
+ output: toolResult.output,
61
+ isError: toolResult.isError,
62
+ });
63
+ }
64
+ const output = extractTerminalStreamOutput(event);
65
+ if (output) {
66
+ const outputKey = normalizeTerminalOutputKey(output);
67
+ if (!outputKey || !state.seenTerminalOutputs.has(outputKey)) {
68
+ if (outputKey) {
69
+ state.seenTerminalOutputs.add(outputKey);
70
+ }
71
+ const nextOutput = computeIncrementalOutput(state.emittedOutput, sanitizeVisibleText(output));
72
+ state.emittedOutput = nextOutput.accumulated;
73
+ if (nextOutput.delta) {
74
+ chunks.push({ kind: "content", content: nextOutput.delta });
75
+ }
76
+ }
77
+ }
78
+ return chunks;
79
+ }
@@ -0,0 +1,4 @@
1
+ import { type RuntimeStreamChunk } from "../parsing/stream-event-parsing.js";
2
+ export declare function projectTextStreamChunks(stream: AsyncIterable<unknown>): AsyncGenerator<RuntimeStreamChunk, {
3
+ emittedContent: boolean;
4
+ }>;
@@ -0,0 +1,18 @@
1
+ import { extractReasoningText } from "../parsing/output-parsing.js";
2
+ import { readStreamDelta } from "../parsing/stream-event-parsing.js";
3
+ export async function* projectTextStreamChunks(stream) {
4
+ let emittedContent = false;
5
+ for await (const chunk of stream) {
6
+ const delta = readStreamDelta(chunk);
7
+ if (delta) {
8
+ emittedContent = true;
9
+ yield { kind: "content", content: delta };
10
+ continue;
11
+ }
12
+ const reasoning = extractReasoningText(chunk);
13
+ if (reasoning) {
14
+ yield { kind: "reasoning", content: reasoning };
15
+ }
16
+ }
17
+ return { emittedContent };
18
+ }
@@ -0,0 +1,64 @@
1
+ export type BuiltinMiddlewareBackend = {
2
+ lsInfo?: (path: string) => Promise<Array<{
3
+ path: string;
4
+ is_dir?: boolean;
5
+ size?: number;
6
+ }>> | Array<{
7
+ path: string;
8
+ is_dir?: boolean;
9
+ size?: number;
10
+ }>;
11
+ read?: (filePath: string, offset?: number, limit?: number) => Promise<string> | string;
12
+ write?: (filePath: string, content: string) => Promise<{
13
+ error?: string;
14
+ path?: string;
15
+ metadata?: Record<string, unknown>;
16
+ }> | {
17
+ error?: string;
18
+ path?: string;
19
+ metadata?: Record<string, unknown>;
20
+ };
21
+ edit?: (filePath: string, oldString: string, newString: string, replaceAll?: boolean) => Promise<{
22
+ error?: string;
23
+ path?: string;
24
+ occurrences?: number;
25
+ metadata?: Record<string, unknown>;
26
+ }> | {
27
+ error?: string;
28
+ path?: string;
29
+ occurrences?: number;
30
+ metadata?: Record<string, unknown>;
31
+ };
32
+ globInfo?: (pattern: string, path?: string) => Promise<Array<{
33
+ path: string;
34
+ }>> | Array<{
35
+ path: string;
36
+ }>;
37
+ grepRaw?: (pattern: string, path?: string | null, glob?: string | null) => Promise<Array<{
38
+ path: string;
39
+ line: number;
40
+ text: string;
41
+ }> | string> | Array<{
42
+ path: string;
43
+ line: number;
44
+ text: string;
45
+ }> | string;
46
+ execute?: (command: string) => Promise<{
47
+ output: string;
48
+ exitCode: number | null;
49
+ truncated: boolean;
50
+ }> | {
51
+ output: string;
52
+ exitCode: number | null;
53
+ truncated: boolean;
54
+ };
55
+ };
56
+ export type BuiltinExecutableTool = {
57
+ name: string;
58
+ schema: unknown;
59
+ invoke: (input: unknown) => Promise<unknown>;
60
+ };
61
+ export declare function createBuiltinMiddlewareTools(backend: BuiltinMiddlewareBackend, options: {
62
+ includeTaskTool: boolean;
63
+ invokeTaskTool?: (input: unknown) => Promise<unknown>;
64
+ }): Promise<Map<string, BuiltinExecutableTool>>;
@@ -0,0 +1,144 @@
1
+ import { z } from "zod";
2
+ import { isSandboxBackend } from "deepagents";
3
+ import { summarizeBuiltinWriteTodosArgs, truncateLines, isObject } from "../runtime-adapter-support.js";
4
+ export async function createBuiltinMiddlewareTools(backend, options) {
5
+ const tools = new Map();
6
+ tools.set("write_todos", {
7
+ name: "write_todos",
8
+ schema: z.object({
9
+ todos: z.array(z.object({}).passthrough()).optional(),
10
+ }).passthrough(),
11
+ invoke: async (input) => {
12
+ const args = isObject(input) ? input : {};
13
+ const summary = summarizeBuiltinWriteTodosArgs(args);
14
+ return {
15
+ ok: true,
16
+ tool: "write_todos",
17
+ message: `Tracked ${summary.total} todo item(s).`,
18
+ summary,
19
+ };
20
+ },
21
+ });
22
+ tools.set("ls", {
23
+ name: "ls",
24
+ schema: z.object({ path: z.string().optional().default("/") }).passthrough(),
25
+ invoke: async (input) => {
26
+ const targetPath = isObject(input) && typeof input.path === "string" ? input.path : "/";
27
+ const infos = (await Promise.resolve(backend.lsInfo?.(targetPath))) ?? [];
28
+ if (infos.length === 0) {
29
+ return `No files found in ${targetPath}`;
30
+ }
31
+ return truncateLines(infos.map((info) => info.is_dir ? `${info.path} (directory)` : `${info.path}${info.size ? ` (${info.size} bytes)` : ""}`));
32
+ },
33
+ });
34
+ tools.set("read_file", {
35
+ name: "read_file",
36
+ schema: z.object({
37
+ file_path: z.string(),
38
+ offset: z.number().optional(),
39
+ limit: z.number().optional(),
40
+ }).passthrough(),
41
+ invoke: async (input) => {
42
+ const typed = isObject(input) ? input : {};
43
+ const filePath = typeof typed.file_path === "string" ? typed.file_path : "";
44
+ const offset = typeof typed.offset === "number" ? typed.offset : 0;
45
+ const limit = typeof typed.limit === "number" ? typed.limit : 500;
46
+ return Promise.resolve(backend.read?.(filePath, offset, limit)) ?? "";
47
+ },
48
+ });
49
+ tools.set("write_file", {
50
+ name: "write_file",
51
+ schema: z.object({ file_path: z.string(), content: z.string().optional() }).passthrough(),
52
+ invoke: async (input) => {
53
+ const typed = isObject(input) ? input : {};
54
+ const result = await Promise.resolve(backend.write?.(typeof typed.file_path === "string" ? typed.file_path : "", typeof typed.content === "string" ? typed.content : ""));
55
+ return result?.error ?? `Successfully wrote to '${result?.path ?? (typed.file_path ?? "")}'`;
56
+ },
57
+ });
58
+ tools.set("edit_file", {
59
+ name: "edit_file",
60
+ schema: z.object({
61
+ file_path: z.string(),
62
+ old_string: z.string(),
63
+ new_string: z.string(),
64
+ replace_all: z.boolean().optional(),
65
+ }).passthrough(),
66
+ invoke: async (input) => {
67
+ const typed = isObject(input) ? input : {};
68
+ const result = await Promise.resolve(backend.edit?.(typeof typed.file_path === "string" ? typed.file_path : "", typeof typed.old_string === "string" ? typed.old_string : "", typeof typed.new_string === "string" ? typed.new_string : "", typed.replace_all === true));
69
+ return result?.error ?? `Successfully replaced ${result?.occurrences ?? 0} occurrence(s) in '${result?.path ?? (typed.file_path ?? "")}'`;
70
+ },
71
+ });
72
+ tools.set("glob", {
73
+ name: "glob",
74
+ schema: z.object({ pattern: z.string(), path: z.string().optional().default("/") }).passthrough(),
75
+ invoke: async (input) => {
76
+ const typed = isObject(input) ? input : {};
77
+ const pattern = typeof typed.pattern === "string" ? typed.pattern : "";
78
+ const targetPath = typeof typed.path === "string" ? typed.path : "/";
79
+ const infos = (await Promise.resolve(backend.globInfo?.(pattern, targetPath))) ?? [];
80
+ if (infos.length === 0) {
81
+ return `No files found matching pattern '${pattern}'`;
82
+ }
83
+ return truncateLines(infos.map((info) => info.path));
84
+ },
85
+ });
86
+ tools.set("grep", {
87
+ name: "grep",
88
+ schema: z.object({
89
+ pattern: z.string(),
90
+ path: z.string().optional().default("/"),
91
+ glob: z.string().nullable().optional(),
92
+ }).passthrough(),
93
+ invoke: async (input) => {
94
+ const typed = isObject(input) ? input : {};
95
+ const result = await Promise.resolve(backend.grepRaw?.(typeof typed.pattern === "string" ? typed.pattern : "", typeof typed.path === "string" ? typed.path : "/", typeof typed.glob === "string" ? typed.glob : null));
96
+ if (typeof result === "string") {
97
+ return result;
98
+ }
99
+ if (!result || result.length === 0) {
100
+ return `No matches found for pattern '${typeof typed.pattern === "string" ? typed.pattern : ""}'`;
101
+ }
102
+ const lines = [];
103
+ let currentFile = "";
104
+ for (const match of result) {
105
+ if (match.path !== currentFile) {
106
+ currentFile = match.path;
107
+ lines.push(`\n${currentFile}:`);
108
+ }
109
+ lines.push(` ${match.line}: ${match.text}`);
110
+ }
111
+ return truncateLines(lines);
112
+ },
113
+ });
114
+ tools.set("execute", {
115
+ name: "execute",
116
+ schema: z.object({ command: z.string() }).passthrough(),
117
+ invoke: async (input) => {
118
+ if (!isSandboxBackend(backend) || typeof backend.execute !== "function") {
119
+ return "Error: Execution not available. This agent's backend does not support command execution (SandboxBackendProtocol).";
120
+ }
121
+ const typed = isObject(input) ? input : {};
122
+ const result = await Promise.resolve(backend.execute(typeof typed.command === "string" ? typed.command : ""));
123
+ const parts = [result.output];
124
+ if (result.exitCode !== null) {
125
+ parts.push(`\n[Command ${result.exitCode === 0 ? "succeeded" : "failed"} with exit code ${result.exitCode}]`);
126
+ }
127
+ if (result.truncated) {
128
+ parts.push("\n[Output was truncated due to size limits]");
129
+ }
130
+ return parts.join("");
131
+ },
132
+ });
133
+ if (options.includeTaskTool && options.invokeTaskTool) {
134
+ tools.set("task", {
135
+ name: "task",
136
+ schema: z.object({
137
+ description: z.string(),
138
+ subagent_type: z.string(),
139
+ }).passthrough(),
140
+ invoke: options.invokeTaskTool,
141
+ });
142
+ }
143
+ return tools;
144
+ }
@@ -0,0 +1,18 @@
1
+ import type { CompiledAgentBinding, CompiledTool } from "../../../contracts/types.js";
2
+ import type { ToolNameMapping } from "./tool-name-mapping.js";
3
+ type ExecutableToolRecord = {
4
+ name: string;
5
+ schema: unknown;
6
+ invoke: (input: unknown) => Promise<unknown>;
7
+ };
8
+ type BuiltinExecutableTool = {
9
+ name: string;
10
+ schema: unknown;
11
+ invoke: (input: unknown) => Promise<unknown>;
12
+ };
13
+ export declare function canReplayToolCallsLocally(binding: CompiledAgentBinding, toolCalls: Array<{
14
+ id?: string;
15
+ name: string;
16
+ args: Record<string, unknown>;
17
+ }>, primaryTools: CompiledTool[], toolNameMapping: ToolNameMapping, executableTools: Map<string, ExecutableToolRecord>, builtinExecutableTools: Map<string, BuiltinExecutableTool>): boolean;
18
+ export {};
@@ -0,0 +1,26 @@
1
+ import { createModelFacingToolNameLookupCandidates, resolveModelFacingToolName } from "./tool-name-mapping.js";
2
+ import { isLangChainBinding } from "../../support/compiled-binding.js";
3
+ export function canReplayToolCallsLocally(binding, toolCalls, primaryTools, toolNameMapping, executableTools, builtinExecutableTools) {
4
+ if (toolCalls.length === 0) {
5
+ return false;
6
+ }
7
+ if (isLangChainBinding(binding)) {
8
+ return true;
9
+ }
10
+ return toolCalls.every((toolCall) => {
11
+ const resolvedToolName = resolveModelFacingToolName(toolCall.name, toolNameMapping, primaryTools);
12
+ if (resolvedToolName === "task" || toolCall.name === "task") {
13
+ return false;
14
+ }
15
+ const executable = executableTools.get(toolCall.name) ?? executableTools.get(resolvedToolName);
16
+ if (executable) {
17
+ return false;
18
+ }
19
+ const builtinExecutable = builtinExecutableTools.get(toolCall.name) ??
20
+ builtinExecutableTools.get(resolvedToolName) ??
21
+ createModelFacingToolNameLookupCandidates(toolCall.name)
22
+ .map((candidate) => builtinExecutableTools.get(candidate))
23
+ .find((candidate) => candidate !== undefined);
24
+ return builtinExecutable !== undefined;
25
+ });
26
+ }
@@ -20,7 +20,6 @@ export declare class AgentRuntimeAdapter {
20
20
  private readonly options;
21
21
  private readonly modelCache;
22
22
  private readonly runnableCache;
23
- private readonly langGraphSessions;
24
23
  constructor(options?: RuntimeAdapterOptions);
25
24
  private getModelCacheKey;
26
25
  private invokeWithProviderRetry;
@@ -30,71 +29,20 @@ export declare class AgentRuntimeAdapter {
30
29
  private createModelFallbackRunnable;
31
30
  private applyStrictToolJsonInstruction;
32
31
  private resolveModel;
33
- private buildToolNameMapping;
34
- private buildSlashCommandSkillInstruction;
35
- private buildInvocationRequest;
36
- private buildRawModelMessages;
37
32
  private resolveTools;
38
- private compileInterruptOn;
39
- private resolveInterruptOn;
40
33
  private resolveFilesystemBackend;
41
34
  private resolveBuiltinMiddlewareBackend;
35
+ private createDeclaredMiddlewareResolverOptions;
42
36
  private invokeBuiltinTaskTool;
43
37
  private resolveBuiltinMiddlewareTools;
44
- private canReplayToolCallsLocally;
45
38
  private resolveAutomaticSummarizationMiddleware;
46
39
  private resolveLangChainAutomaticMiddleware;
47
- private resolveDeepAgentAutomaticMiddleware;
48
40
  private resolveMiddleware;
49
- private resolveCheckpointer;
50
- private resolveLangGraphWorkflowCheckpointer;
51
- private buildRouteSystemPrompt;
52
41
  private resolveSubagents;
53
42
  private createLangChainRunnable;
54
- private normalizeLangGraphWorkflowNode;
55
- private invokeLangGraphToolNode;
56
- private listLangGraphWorkflowNodes;
57
- private normalizeLangGraphWorkflowEdge;
58
- private listLangGraphWorkflowEdges;
59
- private shouldFollowLangGraphEdge;
60
- private listLangGraphWorkflowNextNodes;
61
- private extractInvocationRequestText;
62
- private prependSystemMessage;
63
- private replaceLastUserMessage;
64
- private resolveLangGraphSessionKey;
65
- private resolveLangGraphSessionIdentity;
66
- private langGraphCheckpointNamespace;
67
- private langGraphCheckpointConfig;
68
- private buildLangGraphWorkflowCheckpoint;
69
- private saveLangGraphSessionToCheckpointer;
70
- private loadLangGraphSessionFromCheckpointer;
71
- private clearLangGraphSessionInCheckpointer;
72
- private langGraphSessionFilePath;
73
- private artifactLangGraphSessionFilePath;
74
- private legacyLangGraphSessionFilePath;
75
- private saveLangGraphSession;
76
- private loadLangGraphSession;
77
- private clearLangGraphSession;
78
- private invokeWorkflowNodeModel;
79
- private invokeLangGraphAgentNode;
80
- private createLangGraphRunnable;
81
- private extractExecutedToolResults;
82
- private extractLangGraphResultOutput;
83
- private streamLangGraphWorkflow;
84
43
  private createRunnable;
44
+ private createDeepAgentRunnable;
85
45
  create(binding: CompiledAgentBinding): Promise<RunnableLike>;
86
- route(input: MessageContent, primaryBinding: CompiledAgentBinding, secondaryBinding: CompiledAgentBinding, options?: {
87
- systemPrompt?: string;
88
- }): Promise<string>;
89
- reviewRunResult(binding: CompiledAgentBinding, input: MessageContent, result: Pick<RunResult, "output" | "state" | "finalMessageText">): Promise<{
90
- assessment: string;
91
- modelId: string;
92
- } | null>;
93
- synthesizeFinalResult(binding: CompiledAgentBinding, input: MessageContent, result: Pick<RunResult, "output" | "state" | "finalMessageText">): Promise<{
94
- output: string;
95
- finalMessageText: string;
96
- modelId: string;
97
- } | null>;
98
46
  invoke(binding: CompiledAgentBinding, input: MessageContent, threadId: string, runId: string, resumePayload?: unknown, history?: TranscriptMessage[], options?: {
99
47
  context?: Record<string, unknown>;
100
48
  state?: Record<string, unknown>;