@botbotgo/agent-harness 0.0.98 → 0.0.100

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 (64) hide show
  1. package/README.md +5 -4
  2. package/README.zh.md +4 -0
  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/runtime/adapter/deepagent-runnable-config.d.ts +30 -0
  10. package/dist/runtime/adapter/deepagent-runnable-config.js +22 -0
  11. package/dist/runtime/adapter/index.d.ts +0 -2
  12. package/dist/runtime/adapter/index.js +0 -2
  13. package/dist/runtime/adapter/invocation-result.d.ts +13 -0
  14. package/dist/runtime/adapter/invocation-result.js +40 -0
  15. package/dist/runtime/adapter/langchain-runnable-config.d.ts +25 -0
  16. package/dist/runtime/adapter/langchain-runnable-config.js +19 -0
  17. package/dist/runtime/adapter/local-tool-invocation.d.ts +23 -0
  18. package/dist/runtime/adapter/local-tool-invocation.js +64 -0
  19. package/dist/runtime/adapter/runtime-adapter-support.d.ts +18 -0
  20. package/dist/runtime/adapter/runtime-adapter-support.js +54 -0
  21. package/dist/runtime/adapter/stream-event-projection.d.ts +19 -0
  22. package/dist/runtime/adapter/stream-event-projection.js +79 -0
  23. package/dist/runtime/adapter/stream-text-consumption.d.ts +4 -0
  24. package/dist/runtime/adapter/stream-text-consumption.js +18 -0
  25. package/dist/runtime/adapter/tool/builtin-middleware-tools.d.ts +64 -0
  26. package/dist/runtime/adapter/tool/builtin-middleware-tools.js +144 -0
  27. package/dist/runtime/adapter/tool/tool-replay.d.ts +18 -0
  28. package/dist/runtime/adapter/tool/tool-replay.js +26 -0
  29. package/dist/runtime/agent-runtime-adapter.d.ts +1 -42
  30. package/dist/runtime/agent-runtime-adapter.js +94 -1425
  31. package/dist/runtime/harness/run/helpers.js +2 -8
  32. package/dist/runtime/harness/run/routing.d.ts +1 -3
  33. package/dist/runtime/harness/run/routing.js +2 -25
  34. package/dist/runtime/harness/run/run-lifecycle.d.ts +0 -11
  35. package/dist/runtime/harness/run/run-lifecycle.js +7 -50
  36. package/dist/runtime/harness/runtime-defaults.d.ts +4 -0
  37. package/dist/runtime/harness/runtime-defaults.js +39 -0
  38. package/dist/runtime/harness/system/inventory.js +2 -1
  39. package/dist/runtime/harness/system/skill-requirements.d.ts +1 -0
  40. package/dist/runtime/harness.d.ts +3 -7
  41. package/dist/runtime/harness.js +56 -69
  42. package/dist/runtime/index.d.ts +1 -12
  43. package/dist/runtime/index.js +1 -12
  44. package/dist/runtime/support/compiled-binding.d.ts +0 -2
  45. package/dist/runtime/support/compiled-binding.js +3 -22
  46. package/dist/runtime/support/harness-support.d.ts +0 -11
  47. package/dist/runtime/support/harness-support.js +1 -44
  48. package/dist/runtime/support/index.d.ts +1 -1
  49. package/dist/runtime/support/index.js +1 -1
  50. package/dist/workspace/agent-binding-compiler.js +9 -93
  51. package/dist/workspace/index.d.ts +0 -5
  52. package/dist/workspace/index.js +0 -5
  53. package/dist/workspace/object-loader.js +4 -21
  54. package/dist/workspace/support/agent-capabilities.js +2 -2
  55. package/dist/workspace/support/workspace-ref-utils.d.ts +0 -2
  56. package/dist/workspace/support/workspace-ref-utils.js +0 -17
  57. package/dist/workspace/validate.js +1 -1
  58. package/package.json +1 -1
  59. package/dist/config/workflows/langgraph-workflows.yaml +0 -570
  60. package/dist/config/workflows/runtime-profiles.yaml +0 -94
  61. package/dist/runtime/adapter/langgraph/presets.d.ts +0 -25
  62. package/dist/runtime/adapter/langgraph/presets.js +0 -165
  63. package/dist/runtime/adapter/langgraph/profiles.d.ts +0 -6
  64. package/dist/runtime/adapter/langgraph/profiles.js +0 -206
@@ -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;
@@ -41,60 +40,20 @@ export declare class AgentRuntimeAdapter {
41
40
  private resolveBuiltinMiddlewareBackend;
42
41
  private invokeBuiltinTaskTool;
43
42
  private resolveBuiltinMiddlewareTools;
44
- private canReplayToolCallsLocally;
45
43
  private resolveAutomaticSummarizationMiddleware;
46
44
  private resolveLangChainAutomaticMiddleware;
47
45
  private resolveDeepAgentAutomaticMiddleware;
48
46
  private resolveMiddleware;
49
47
  private resolveCheckpointer;
50
- private resolveLangGraphWorkflowCheckpointer;
51
- private buildRouteSystemPrompt;
52
48
  private resolveSubagents;
53
49
  private createLangChainRunnable;
54
- private normalizeLangGraphWorkflowNode;
55
- private invokeLangGraphToolNode;
56
- private listLangGraphWorkflowNodes;
57
- private normalizeLangGraphWorkflowEdge;
58
- private listLangGraphWorkflowEdges;
59
- private shouldFollowLangGraphEdge;
60
- private listLangGraphWorkflowNextNodes;
61
50
  private extractInvocationRequestText;
62
51
  private prependSystemMessage;
63
52
  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
53
  private extractExecutedToolResults;
82
- private extractLangGraphResultOutput;
83
- private streamLangGraphWorkflow;
84
54
  private createRunnable;
55
+ private createDeepAgentRunnable;
85
56
  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
57
  invoke(binding: CompiledAgentBinding, input: MessageContent, threadId: string, runId: string, resumePayload?: unknown, history?: TranscriptMessage[], options?: {
99
58
  context?: Record<string, unknown>;
100
59
  state?: Record<string, unknown>;