@botbotgo/agent-harness 0.0.308 → 0.0.310

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 (195) hide show
  1. package/README.md +17 -1
  2. package/README.zh.md +17 -1
  3. package/dist/acp.d.ts +1 -116
  4. package/dist/acp.js +1 -310
  5. package/dist/api.d.ts +4 -2
  6. package/dist/api.js +4 -1
  7. package/dist/cli/chat-interactive.d.ts +24 -0
  8. package/dist/cli/chat-interactive.js +244 -0
  9. package/dist/cli/chat-rendering.d.ts +9 -0
  10. package/dist/cli/chat-rendering.js +102 -0
  11. package/dist/cli/chat-stream.d.ts +23 -0
  12. package/dist/cli/chat-stream.js +330 -0
  13. package/dist/cli/chat-ui.d.ts +20 -0
  14. package/dist/cli/chat-ui.js +198 -0
  15. package/dist/cli/chat-workspace.d.ts +15 -0
  16. package/dist/cli/chat-workspace.js +205 -0
  17. package/dist/cli/main.d.ts +52 -0
  18. package/dist/cli/main.js +323 -0
  19. package/dist/cli/managed-service-commands.d.ts +23 -0
  20. package/dist/cli/managed-service-commands.js +63 -0
  21. package/dist/cli/managed-service.d.ts +27 -0
  22. package/dist/cli/managed-service.js +61 -0
  23. package/dist/cli/options-init-chat.d.ts +16 -0
  24. package/dist/cli/options-init-chat.js +108 -0
  25. package/dist/cli/options-runtime.d.ts +27 -0
  26. package/dist/cli/options-runtime.js +158 -0
  27. package/dist/cli/options-serve.d.ts +24 -0
  28. package/dist/cli/options-serve.js +166 -0
  29. package/dist/cli/options.d.ts +5 -0
  30. package/dist/cli/options.js +47 -0
  31. package/dist/cli/process-guards.d.ts +14 -0
  32. package/dist/cli/process-guards.js +139 -0
  33. package/dist/cli/request-tree.d.ts +12 -0
  34. package/dist/cli/request-tree.js +296 -0
  35. package/dist/cli/runtime-commands.d.ts +15 -0
  36. package/dist/cli/runtime-commands.js +247 -0
  37. package/dist/cli/runtime-output.d.ts +5 -0
  38. package/dist/cli/runtime-output.js +124 -0
  39. package/dist/cli/server-commands.d.ts +36 -0
  40. package/dist/cli/server-commands.js +250 -0
  41. package/dist/cli/workspace.d.ts +6 -0
  42. package/dist/cli/workspace.js +71 -0
  43. package/dist/cli.d.ts +1 -67
  44. package/dist/cli.js +2 -2734
  45. package/dist/client/acp.d.ts +1 -50
  46. package/dist/client/acp.js +1 -219
  47. package/dist/client/in-process.d.ts +5 -5
  48. package/dist/client/index.d.ts +2 -2
  49. package/dist/client/index.js +1 -1
  50. package/dist/contracts/runtime-evaluation.d.ts +103 -0
  51. package/dist/contracts/runtime-evaluation.js +1 -0
  52. package/dist/contracts/runtime-memory.d.ts +162 -0
  53. package/dist/contracts/runtime-memory.js +1 -0
  54. package/dist/contracts/runtime-observability.d.ts +248 -0
  55. package/dist/contracts/runtime-observability.js +1 -0
  56. package/dist/contracts/runtime-requests.d.ts +342 -0
  57. package/dist/contracts/runtime-requests.js +1 -0
  58. package/dist/contracts/runtime-scheduling.d.ts +146 -0
  59. package/dist/contracts/runtime-scheduling.js +1 -0
  60. package/dist/contracts/runtime.d.ts +5 -1042
  61. package/dist/contracts/runtime.js +27 -1
  62. package/dist/flow/build-flow-graph.js +4 -875
  63. package/dist/flow/flow-graph-normalization.d.ts +56 -0
  64. package/dist/flow/flow-graph-normalization.js +214 -0
  65. package/dist/flow/flow-graph-runtime.d.ts +8 -0
  66. package/dist/flow/flow-graph-runtime.js +107 -0
  67. package/dist/flow/flow-graph-upstream.d.ts +18 -0
  68. package/dist/flow/flow-graph-upstream.js +498 -0
  69. package/dist/flow/types.d.ts +1 -1
  70. package/dist/index.d.ts +4 -4
  71. package/dist/index.js +2 -2
  72. package/dist/init-project.d.ts +1 -12
  73. package/dist/init-project.js +1 -651
  74. package/dist/{procedural → knowledge/procedural}/manager.d.ts +3 -3
  75. package/dist/{procedural → knowledge/procedural}/manager.js +6 -6
  76. package/dist/mcp.d.ts +2 -62
  77. package/dist/mcp.js +2 -253
  78. package/dist/package-version.d.ts +1 -1
  79. package/dist/package-version.js +1 -1
  80. package/dist/persistence/file-store.js +1 -1
  81. package/dist/persistence/sqlite-runtime.d.ts +19 -0
  82. package/dist/persistence/sqlite-runtime.js +86 -0
  83. package/dist/persistence/sqlite-store.js +11 -99
  84. package/dist/{request-events.d.ts → projections/request-events.d.ts} +1 -1
  85. package/dist/{upstream-events.js → projections/upstream-events.js} +1 -1
  86. package/dist/protocol/a2a/http-discovery.d.ts +39 -0
  87. package/dist/protocol/a2a/http-discovery.js +178 -0
  88. package/dist/protocol/a2a/http-rpc.d.ts +28 -0
  89. package/dist/protocol/a2a/http-rpc.js +623 -0
  90. package/dist/protocol/a2a/http.d.ts +72 -1
  91. package/dist/protocol/a2a/http.js +14 -1124
  92. package/dist/protocol/a2a/task-state.d.ts +29 -0
  93. package/dist/protocol/a2a/task-state.js +317 -0
  94. package/dist/protocol/acp/client.js +1 -1
  95. package/dist/protocol/acp/harness-client.d.ts +50 -0
  96. package/dist/protocol/acp/harness-client.js +219 -0
  97. package/dist/protocol/acp/server.d.ts +116 -0
  98. package/dist/protocol/acp/server.js +310 -0
  99. package/dist/protocol/ag-ui/http.js +1 -1
  100. package/dist/protocol/mcp/server.d.ts +76 -0
  101. package/dist/protocol/mcp/server.js +428 -0
  102. package/dist/resource/backend/workspace-scoped-backend.d.ts +40 -0
  103. package/dist/resource/backend/workspace-scoped-backend.js +296 -0
  104. package/dist/resource/mcp/tool-support.d.ts +35 -0
  105. package/dist/resource/mcp/tool-support.js +296 -0
  106. package/dist/resource/mcp-tool-support.d.ts +2 -35
  107. package/dist/resource/mcp-tool-support.js +2 -296
  108. package/dist/resource/providers/resource-provider.d.ts +22 -0
  109. package/dist/resource/providers/resource-provider.js +215 -0
  110. package/dist/resource/resource-impl.d.ts +3 -33
  111. package/dist/resource/resource-impl.js +2 -808
  112. package/dist/resource/resource-types.d.ts +33 -0
  113. package/dist/resource/resource-types.js +1 -0
  114. package/dist/resource/tools/function-tool-resolver.d.ts +2 -0
  115. package/dist/resource/tools/function-tool-resolver.js +306 -0
  116. package/dist/runtime/adapter/middleware-assembly.js +1 -1
  117. package/dist/runtime/adapter/model/invocation-request.js +2 -2
  118. package/dist/runtime/adapter/model/message-assembly.js +1 -1
  119. package/dist/runtime/agent-runtime-adapter.d.ts +3 -63
  120. package/dist/runtime/agent-runtime-adapter.js +5 -233
  121. package/dist/runtime/agent-runtime-assembly.d.ts +67 -0
  122. package/dist/runtime/agent-runtime-assembly.js +211 -0
  123. package/dist/runtime/harness/background-runtime.d.ts +1 -1
  124. package/dist/runtime/harness/events/event-sink.js +1 -1
  125. package/dist/runtime/harness/events/runtime-event-operations.d.ts +1 -1
  126. package/dist/runtime/harness/events/streaming.js +1 -1
  127. package/dist/runtime/harness/public-shapes.d.ts +43 -0
  128. package/dist/runtime/harness/public-shapes.js +186 -0
  129. package/dist/runtime/harness/run/inspection.js +2 -2
  130. package/dist/runtime/harness/run/resources.js +1 -1
  131. package/dist/runtime/harness/run/surface-semantics.js +1 -1
  132. package/dist/runtime/harness/system/inventory.d.ts +1 -1
  133. package/dist/runtime/harness/system/inventory.js +2 -2
  134. package/dist/runtime/harness/system/policy-engine.js +1 -1
  135. package/dist/runtime/harness/system/runtime-memory-manager.js +1 -1
  136. package/dist/runtime/harness/system/skill-requirements.d.ts +1 -1
  137. package/dist/runtime/harness/system/skill-requirements.js +1 -1
  138. package/dist/runtime/harness.d.ts +3 -2
  139. package/dist/runtime/harness.js +11 -191
  140. package/dist/runtime/maintenance/checkpoint-maintenance.js +1 -1
  141. package/dist/runtime/maintenance/runtime-record-maintenance.js +1 -1
  142. package/dist/runtime/parsing/output-content.d.ts +11 -0
  143. package/dist/runtime/parsing/output-content.js +442 -0
  144. package/dist/runtime/parsing/output-parsing.d.ts +3 -29
  145. package/dist/runtime/parsing/output-parsing.js +3 -806
  146. package/dist/runtime/parsing/output-recovery.d.ts +14 -0
  147. package/dist/runtime/parsing/output-recovery.js +288 -0
  148. package/dist/runtime/parsing/output-tool-args.d.ts +4 -0
  149. package/dist/runtime/parsing/output-tool-args.js +120 -0
  150. package/dist/runtime/support/runtime-factories.js +1 -1
  151. package/dist/scaffold/init-project.d.ts +12 -0
  152. package/dist/scaffold/init-project.js +651 -0
  153. package/dist/{extensions.d.ts → tooling/extensions.d.ts} +1 -1
  154. package/dist/{extensions.js → tooling/extensions.js} +3 -3
  155. package/dist/{tool-modules.d.ts → tooling/module-loader.d.ts} +1 -1
  156. package/dist/{tool-modules.js → tooling/module-loader.js} +2 -2
  157. package/dist/workspace/agent-binding-compiler.js +2 -2
  158. package/dist/workspace/compile.js +2 -2
  159. package/dist/workspace/object-loader-paths.d.ts +11 -0
  160. package/dist/workspace/object-loader-paths.js +75 -0
  161. package/dist/workspace/object-loader-readers.d.ts +21 -0
  162. package/dist/workspace/object-loader-readers.js +187 -0
  163. package/dist/workspace/object-loader.d.ts +0 -1
  164. package/dist/workspace/object-loader.js +6 -260
  165. package/dist/workspace/resource-compilers.js +1 -1
  166. package/dist/workspace/support/discovery.js +1 -1
  167. package/package.json +1 -1
  168. package/dist/runtime/adapter/index.d.ts +0 -13
  169. package/dist/runtime/adapter/index.js +0 -13
  170. package/dist/runtime/harness/index.d.ts +0 -19
  171. package/dist/runtime/harness/index.js +0 -19
  172. package/dist/runtime/maintenance/index.d.ts +0 -4
  173. package/dist/runtime/maintenance/index.js +0 -4
  174. package/dist/runtime/parsing/index.d.ts +0 -2
  175. package/dist/runtime/parsing/index.js +0 -2
  176. package/dist/runtime/support/index.d.ts +0 -4
  177. package/dist/runtime/support/index.js +0 -4
  178. package/dist/workspace/support/index.d.ts +0 -2
  179. package/dist/workspace/support/index.js +0 -2
  180. /package/dist/{procedural → knowledge/procedural}/config.d.ts +0 -0
  181. /package/dist/{procedural → knowledge/procedural}/config.js +0 -0
  182. /package/dist/{procedural → knowledge/procedural}/index.d.ts +0 -0
  183. /package/dist/{procedural → knowledge/procedural}/index.js +0 -0
  184. /package/dist/{presentation.d.ts → projections/presentation.d.ts} +0 -0
  185. /package/dist/{presentation.js → projections/presentation.js} +0 -0
  186. /package/dist/{request-events.js → projections/request-events.js} +0 -0
  187. /package/dist/{upstream-events.d.ts → projections/upstream-events.d.ts} +0 -0
  188. /package/dist/runtime/{support → env}/runtime-env.d.ts +0 -0
  189. /package/dist/runtime/{support → env}/runtime-env.js +0 -0
  190. /package/dist/runtime/{support → layout}/runtime-layout.d.ts +0 -0
  191. /package/dist/runtime/{support → layout}/runtime-layout.js +0 -0
  192. /package/dist/runtime/{support → prompts}/runtime-prompts.d.ts +0 -0
  193. /package/dist/runtime/{support → prompts}/runtime-prompts.js +0 -0
  194. /package/dist/runtime/{support → skills}/skill-metadata.d.ts +0 -0
  195. /package/dist/runtime/{support → skills}/skill-metadata.js +0 -0
@@ -1,19 +1,16 @@
1
1
  import path from "node:path";
2
- import { MemorySaver } from "@langchain/langgraph";
3
- import { createDeepAgent, createFilesystemMiddleware, createPatchToolCallsMiddleware, FilesystemBackend, } from "deepagents";
4
- import { createAgent, todoListMiddleware } from "langchain";
2
+ import { createDeepAgent, FilesystemBackend, } from "deepagents";
3
+ import { createAgent } from "langchain";
5
4
  import { wrapResolvedModel, } from "./parsing/output-parsing.js";
6
- import { UPSTREAM_REQUEST_CONFIG_KEY, UPSTREAM_SESSION_CONFIG_KEY } from "./adapter/upstream-configurable-keys.js";
5
+ import { AGENT_INTERRUPT_SENTINEL_PREFIX, buildDeepAgentCreateParams, buildLangChainCreateParams, buildMinimalDeepAgentCreateParams, materializeModelExposedBuiltinMiddlewareTools, resolveLangChainInvocationConfig, resolveRunnableCheckpointer, resolveRunnableInterruptOn, shouldAttachMinimalDeepAgentBackend, shouldAttachMinimalDeepAgentCheckpointer, shouldAttachMinimalDeepAgentStore, shouldUseMinimalDeepAgentAssembly, } from "./agent-runtime-assembly.js";
7
6
  import { resolveDeepAgentSkillSourcePaths, } from "./adapter/compat/deepagent-compat.js";
8
7
  import { buildToolNameMapping, } from "./adapter/tool/tool-name-mapping.js";
9
8
  import { executeRequestInvocation } from "./adapter/flow/invocation-flow.js";
10
- import { asStructuredExecutableTool } from "./adapter/tool/resolved-tool.js";
11
9
  import { streamRuntimeExecution } from "./adapter/flow/stream-runtime.js";
12
10
  import { applyToolRecoveryInstruction as applyToolRecoveryInstructionHelper, applyStrictToolJsonInstruction as applyStrictToolJsonInstructionHelper, callRuntimeWithToolParseRecovery as callRuntimeWithToolParseRecoveryHelper, createModelFallbackRunnable as createModelFallbackRunnableHelper, invokeWithProviderRetry as invokeWithProviderRetryHelper, iterateWithTimeout as iterateWithTimeoutHelper, materializeModelStream as materializeModelStreamHelper, RuntimeOperationTimeoutError, withRuntimeTimeout, } from "./adapter/runtime-shell.js";
13
11
  import { invokeBuiltinTaskTool as invokeBuiltinTaskToolHelper, materializeAutomaticSummarizationMiddleware as materializeAutomaticSummarizationMiddlewareHelper, resolveBuiltinMiddlewareBackend as resolveBuiltinMiddlewareBackendHelper, resolveBuiltinMiddlewareTools as resolveBuiltinMiddlewareToolsHelper, resolveLangChainRuntimeExtensionMiddleware as resolveLangChainRuntimeExtensionMiddlewareHelper, resolveMiddleware as resolveMiddlewareHelper, resolveSubagents as resolveSubagentsHelper, } from "./adapter/middleware-assembly.js";
14
12
  import { computeRemainingTimeoutMs, resolveBindingTimeout, resolveStreamIdleTimeout, } from "./adapter/resilience.js";
15
13
  import { createResolvedModel } from "./adapter/model/model-providers.js";
16
- import { compileInterruptOn } from "./adapter/tool/interrupt-policy.js";
17
14
  import { resolveAdapterTools } from "./adapter/tool-resolution.js";
18
15
  import { resolveRuntimeStreamExecutionContext, } from "./adapter/flow/execution-context.js";
19
16
  import { isRetryableProviderError } from "./adapter/resilience.js";
@@ -21,232 +18,7 @@ export { applyDeepAgentDelegationPromptCompatibility, materializeDeepAgentSkillS
21
18
  export { buildAuthOmittingFetch, normalizeOpenAICompatibleInit } from "./adapter/compat/openai-compatible.js";
22
19
  export { buildToolNameMapping, createModelFacingToolNameCandidates, createModelFacingToolNameLookupCandidates, resolveModelFacingToolName, sanitizeToolNameForModel, } from "./adapter/tool/tool-name-mapping.js";
23
20
  export { computeRemainingTimeoutMs, isRetryableProviderError, resolveBindingTimeout, resolveProviderRetryPolicy, resolveStreamIdleTimeout, resolveTimeoutMs, } from "./adapter/resilience.js";
24
- import { getBindingBackendConfig, getBindingAdapterKind, getBindingDeepAgentSubagents, getBindingExecutionKind, getBindingExecutionParams, getBindingFilesystemConfig, getBindingInterruptCompatibilityRules, getBindingMemorySources, getBindingMiddlewareConfigs, getBindingPrimaryModel, getBindingSkills, getBindingStoreConfig, getBindingToolCount, getBindingPrimaryTools, getBindingSystemPrompt, isDeepAgentBinding, isLangChainBinding, } from "./support/compiled-binding.js";
25
- const AGENT_INTERRUPT_SENTINEL_PREFIX = "__agent_harness_interrupt__:";
26
- const UPSTREAM_BUILTIN_MIDDLEWARE_TOOL_NAMES = Object.freeze([
27
- "write_todos",
28
- "read_todos",
29
- "ls",
30
- "list_files",
31
- "read_file",
32
- "write_file",
33
- "edit_file",
34
- "glob",
35
- "grep",
36
- "search_files",
37
- "execute",
38
- "run_command",
39
- "fetch_url",
40
- "http_request",
41
- "send_message",
42
- "request_approval",
43
- "schedule_task",
44
- "task",
45
- "delegate_task",
46
- ]);
47
- const BUILTIN_MIDDLEWARE_ALIAS_TOOL_NAMES = new Set([
48
- "list_files",
49
- "search_files",
50
- "run_command",
51
- "delegate_task",
52
- ]);
53
- const MODEL_EXPOSED_BUILTIN_MIDDLEWARE_TOOL_NAMES = new Set([
54
- "fetch_url",
55
- "http_request",
56
- "send_message",
57
- "request_approval",
58
- "schedule_task",
59
- ]);
60
- export function materializeModelExposedBuiltinMiddlewareTools(input) {
61
- const explicitToolNames = new Set(input.explicitToolNames ?? []);
62
- const tools = [];
63
- for (const [toolName, tool] of input.builtinTools.entries()) {
64
- if (explicitToolNames.has(toolName)
65
- || BUILTIN_MIDDLEWARE_ALIAS_TOOL_NAMES.has(toolName)
66
- || !MODEL_EXPOSED_BUILTIN_MIDDLEWARE_TOOL_NAMES.has(toolName)) {
67
- continue;
68
- }
69
- tools.push(asStructuredExecutableTool(tool, toolName, tool.name));
70
- }
71
- return tools;
72
- }
73
- export function resolveRunnableCheckpointer(options, binding) {
74
- return options.checkpointerResolver ? options.checkpointerResolver(binding) : new MemorySaver();
75
- }
76
- export function resolveRunnableInterruptOn(binding) {
77
- return compileInterruptOn(getBindingPrimaryTools(binding), getBindingInterruptCompatibilityRules(binding));
78
- }
79
- function buildUpstreamCreateBaseParams(binding, supportedFields) {
80
- const executionParams = getBindingExecutionParams(binding);
81
- if (!executionParams) {
82
- throw new Error(`Agent ${binding.agent.id} has no compiled execution params`);
83
- }
84
- const source = executionParams;
85
- const upstreamParams = Object.fromEntries(supportedFields
86
- .filter((key) => key in source && source[key] !== undefined)
87
- .map((key) => [key, source[key]]));
88
- return upstreamParams;
89
- }
90
- export function buildLangChainCreateParams(input) {
91
- const executionKind = getBindingExecutionKind(input.binding);
92
- const executionParams = getBindingExecutionParams(input.binding);
93
- if (executionKind !== "langchain-v1" || !executionParams) {
94
- throw new Error(`Agent ${input.binding.agent.id} has no langchain params`);
95
- }
96
- const upstreamParams = buildUpstreamCreateBaseParams(input.binding, [
97
- "model",
98
- "tools",
99
- "systemPrompt",
100
- "stateSchema",
101
- "contextSchema",
102
- "checkpointer",
103
- "store",
104
- "responseFormat",
105
- "middleware",
106
- "name",
107
- "description",
108
- "includeAgentName",
109
- "version",
110
- ]);
111
- const legacyPassthrough = typeof input.binding.langchainAgentParams?.passthrough === "object" &&
112
- input.binding.langchainAgentParams?.passthrough
113
- ? input.binding.langchainAgentParams.passthrough
114
- : undefined;
115
- const langchainPassthrough = typeof input.binding.harnessRuntime.langchain?.passthrough === "object" && input.binding.harnessRuntime.langchain?.passthrough
116
- ? input.binding.harnessRuntime.langchain.passthrough
117
- : undefined;
118
- return {
119
- ...upstreamParams,
120
- ...(legacyPassthrough ?? {}),
121
- ...(langchainPassthrough ?? {}),
122
- ...(input.passthroughOverride ?? {}),
123
- systemPrompt: input.systemPromptOverride ?? executionParams.systemPrompt,
124
- model: input.resolvedModel,
125
- tools: input.resolvedTools,
126
- middleware: input.resolvedMiddleware,
127
- checkpointer: input.resolvedCheckpointer,
128
- store: input.resolvedStore,
129
- };
130
- }
131
- export function resolveLangChainInvocationConfig(binding, options) {
132
- const langchainPassthrough = typeof binding.harnessRuntime.langchain?.passthrough === "object" && binding.harnessRuntime.langchain?.passthrough
133
- ? binding.harnessRuntime.langchain.passthrough
134
- : undefined;
135
- const config = {
136
- configurable: {
137
- [UPSTREAM_SESSION_CONFIG_KEY]: options.sessionId,
138
- [UPSTREAM_REQUEST_CONFIG_KEY]: options.requestId,
139
- },
140
- };
141
- if (typeof langchainPassthrough?.recursionLimit === "number") {
142
- config.recursionLimit = langchainPassthrough.recursionLimit;
143
- }
144
- if (options.context) {
145
- config.context = options.context;
146
- }
147
- if (options.toolRuntimeContext) {
148
- config.toolRuntimeContext = options.toolRuntimeContext;
149
- }
150
- return config;
151
- }
152
- export function buildDeepAgentCreateParams(input) {
153
- const executionKind = getBindingExecutionKind(input.binding);
154
- if (executionKind !== "deepagent" || !getBindingExecutionParams(input.binding)) {
155
- throw new Error(`Agent ${input.binding.agent.id} has no runnable params`);
156
- }
157
- const upstreamParams = buildUpstreamCreateBaseParams(input.binding, [
158
- "model",
159
- "tools",
160
- "systemPrompt",
161
- "middleware",
162
- "subagents",
163
- "responseFormat",
164
- "contextSchema",
165
- "checkpointer",
166
- "store",
167
- "backend",
168
- "interruptOn",
169
- "name",
170
- "memory",
171
- "skills",
172
- ]);
173
- return {
174
- ...upstreamParams,
175
- skills: input.resolvedSkills,
176
- model: input.resolvedModel,
177
- tools: input.resolvedTools,
178
- middleware: input.resolvedMiddleware,
179
- subagents: input.resolvedSubagents,
180
- interruptOn: input.resolvedInterruptOn,
181
- ...(input.resolvedCheckpointer !== undefined ? { checkpointer: input.resolvedCheckpointer } : {}),
182
- ...(input.resolvedStore !== undefined ? { store: input.resolvedStore } : {}),
183
- ...(input.resolvedBackend !== undefined ? { backend: input.resolvedBackend } : {}),
184
- };
185
- }
186
- export function shouldUseMinimalDeepAgentAssembly(input) {
187
- const executionKind = getBindingExecutionKind(input.binding);
188
- if (executionKind !== "deepagent") {
189
- return false;
190
- }
191
- if (input.resolvedBackend === undefined) {
192
- return false;
193
- }
194
- if (input.resolvedSkills.length > 0) {
195
- return false;
196
- }
197
- if (input.resolvedSubagents.length > 0 || getBindingDeepAgentSubagents(input.binding).length > 0) {
198
- return false;
199
- }
200
- if (getBindingMemorySources(input.binding).length > 0) {
201
- return false;
202
- }
203
- if (input.resolvedMiddleware.length > 0 || (getBindingMiddlewareConfigs(input.binding)?.length ?? 0) > 0) {
204
- return false;
205
- }
206
- return input.resolvedInterruptOn === undefined || Object.keys(input.resolvedInterruptOn).length === 0;
207
- }
208
- export function buildMinimalDeepAgentCreateParams(input) {
209
- const executionKind = getBindingExecutionKind(input.binding);
210
- if (executionKind !== "deepagent" || !getBindingExecutionParams(input.binding)) {
211
- throw new Error(`Agent ${input.binding.agent.id} has no runnable params`);
212
- }
213
- const upstreamParams = buildUpstreamCreateBaseParams(input.binding, [
214
- "systemPrompt",
215
- "contextSchema",
216
- "responseFormat",
217
- "name",
218
- "description",
219
- "includeAgentName",
220
- "version",
221
- ]);
222
- return {
223
- ...upstreamParams,
224
- model: input.resolvedModel,
225
- tools: input.resolvedTools,
226
- middleware: [
227
- todoListMiddleware(),
228
- createFilesystemMiddleware({ backend: input.resolvedBackend }),
229
- createPatchToolCallsMiddleware(),
230
- ],
231
- ...(input.resolvedCheckpointer !== undefined ? { checkpointer: input.resolvedCheckpointer } : {}),
232
- ...(input.resolvedStore !== undefined ? { store: input.resolvedStore } : {}),
233
- };
234
- }
235
- function shouldAttachMinimalDeepAgentCheckpointer(binding, resolvedInterruptOn) {
236
- if (binding.harnessRuntime.checkpointer !== undefined) {
237
- return true;
238
- }
239
- return resolvedInterruptOn !== undefined && Object.keys(resolvedInterruptOn).length > 0;
240
- }
241
- function shouldAttachMinimalDeepAgentStore(binding) {
242
- return getBindingStoreConfig(binding) !== undefined || getBindingMemorySources(binding).length > 0;
243
- }
244
- function shouldAttachMinimalDeepAgentBackend(binding) {
245
- return (getBindingBackendConfig(binding) !== undefined ||
246
- getBindingMemorySources(binding).length > 0 ||
247
- getBindingSkills(binding).length > 0 ||
248
- (getBindingMiddlewareConfigs(binding)?.length ?? 0) > 0);
249
- }
21
+ import { getBindingAdapterKind, getBindingDeepAgentSubagents, getBindingExecutionKind, getBindingFilesystemConfig, getBindingPrimaryModel, getBindingSkills, getBindingToolCount, getBindingPrimaryTools, getBindingSystemPrompt, isDeepAgentBinding, isLangChainBinding, } from "./support/compiled-binding.js";
250
22
  export class AgentRuntimeAdapter {
251
23
  options;
252
24
  modelCache = new Map();
@@ -718,4 +490,4 @@ export class AgentRuntimeAdapter {
718
490
  });
719
491
  }
720
492
  }
721
- export { AgentRuntimeAdapter as RuntimeAdapter, AGENT_INTERRUPT_SENTINEL_PREFIX, AGENT_INTERRUPT_SENTINEL_PREFIX as INTERRUPT_SENTINEL_PREFIX, RuntimeOperationTimeoutError, };
493
+ export { AgentRuntimeAdapter as RuntimeAdapter, AGENT_INTERRUPT_SENTINEL_PREFIX, AGENT_INTERRUPT_SENTINEL_PREFIX as INTERRUPT_SENTINEL_PREFIX, buildDeepAgentCreateParams, buildLangChainCreateParams, buildMinimalDeepAgentCreateParams, materializeModelExposedBuiltinMiddlewareTools, resolveLangChainInvocationConfig, resolveRunnableCheckpointer, resolveRunnableInterruptOn, shouldUseMinimalDeepAgentAssembly, RuntimeOperationTimeoutError, };
@@ -0,0 +1,67 @@
1
+ import type { CompiledAgentBinding, CompiledAsyncSubAgent, RuntimeAdapterOptions } from "../contracts/types.js";
2
+ import type { ExecutableTool } from "./adapter/flow/invoke-runtime.js";
3
+ import type { UpstreamSubagentConfig } from "./adapter/middleware-assembly.js";
4
+ export declare const AGENT_INTERRUPT_SENTINEL_PREFIX = "__agent_harness_interrupt__:";
5
+ export declare function materializeModelExposedBuiltinMiddlewareTools(input: {
6
+ builtinTools: Map<string, ExecutableTool>;
7
+ explicitToolNames?: string[];
8
+ }): unknown[];
9
+ export declare function resolveRunnableCheckpointer(options: RuntimeAdapterOptions, binding: CompiledAgentBinding): unknown;
10
+ export declare function resolveRunnableInterruptOn(binding: CompiledAgentBinding): Record<string, {
11
+ allowedDecisions: import("./adapter/tool/interrupt-policy.js").InterruptDecision[];
12
+ }> | undefined;
13
+ export declare function buildLangChainCreateParams(input: {
14
+ binding: CompiledAgentBinding;
15
+ resolvedModel: unknown;
16
+ resolvedTools: unknown[];
17
+ resolvedMiddleware: unknown[];
18
+ resolvedCheckpointer: unknown;
19
+ resolvedStore: unknown;
20
+ passthroughOverride?: Record<string, unknown>;
21
+ systemPromptOverride?: string;
22
+ }): Record<string, unknown>;
23
+ export declare function resolveLangChainInvocationConfig(binding: CompiledAgentBinding, options: {
24
+ sessionId: string;
25
+ requestId: string;
26
+ legacySessionId?: string;
27
+ legacyRequestId?: string;
28
+ context?: Record<string, unknown>;
29
+ toolRuntimeContext?: Record<string, unknown>;
30
+ }): Record<string, unknown>;
31
+ export declare function buildDeepAgentCreateParams(input: {
32
+ binding: CompiledAgentBinding;
33
+ resolvedModel: unknown;
34
+ resolvedTools: unknown[];
35
+ resolvedMiddleware: unknown[];
36
+ resolvedSubagents: Array<UpstreamSubagentConfig | CompiledAsyncSubAgent>;
37
+ resolvedCheckpointer?: unknown;
38
+ resolvedStore?: unknown;
39
+ resolvedBackend?: unknown;
40
+ resolvedInterruptOn?: Record<string, {
41
+ allowedDecisions: Array<"approve" | "edit" | "reject">;
42
+ }>;
43
+ resolvedSkills: string[];
44
+ }): Record<string, unknown>;
45
+ export declare function shouldUseMinimalDeepAgentAssembly(input: {
46
+ binding: CompiledAgentBinding;
47
+ resolvedMiddleware: unknown[];
48
+ resolvedSubagents: Array<UpstreamSubagentConfig | CompiledAsyncSubAgent>;
49
+ resolvedInterruptOn?: Record<string, {
50
+ allowedDecisions: Array<"approve" | "edit" | "reject">;
51
+ }>;
52
+ resolvedSkills: string[];
53
+ resolvedBackend?: unknown;
54
+ }): boolean;
55
+ export declare function buildMinimalDeepAgentCreateParams(input: {
56
+ binding: CompiledAgentBinding;
57
+ resolvedModel: unknown;
58
+ resolvedTools: unknown[];
59
+ resolvedCheckpointer?: unknown;
60
+ resolvedStore?: unknown;
61
+ resolvedBackend: unknown;
62
+ }): Record<string, unknown>;
63
+ export declare function shouldAttachMinimalDeepAgentCheckpointer(binding: CompiledAgentBinding, resolvedInterruptOn?: Record<string, {
64
+ allowedDecisions: Array<"approve" | "edit" | "reject">;
65
+ }>): boolean;
66
+ export declare function shouldAttachMinimalDeepAgentStore(binding: CompiledAgentBinding): boolean;
67
+ export declare function shouldAttachMinimalDeepAgentBackend(binding: CompiledAgentBinding): boolean;
@@ -0,0 +1,211 @@
1
+ import { MemorySaver } from "@langchain/langgraph";
2
+ import { createFilesystemMiddleware, createPatchToolCallsMiddleware } from "deepagents";
3
+ import { todoListMiddleware } from "langchain";
4
+ import { UPSTREAM_REQUEST_CONFIG_KEY, UPSTREAM_SESSION_CONFIG_KEY } from "./adapter/upstream-configurable-keys.js";
5
+ import { asStructuredExecutableTool } from "./adapter/tool/resolved-tool.js";
6
+ import { compileInterruptOn } from "./adapter/tool/interrupt-policy.js";
7
+ import { getBindingBackendConfig, getBindingDeepAgentSubagents, getBindingExecutionKind, getBindingExecutionParams, getBindingInterruptCompatibilityRules, getBindingMemorySources, getBindingMiddlewareConfigs, getBindingPrimaryTools, getBindingSkills, getBindingStoreConfig, } from "./support/compiled-binding.js";
8
+ export const AGENT_INTERRUPT_SENTINEL_PREFIX = "__agent_harness_interrupt__:";
9
+ const BUILTIN_MIDDLEWARE_ALIAS_TOOL_NAMES = new Set([
10
+ "list_files",
11
+ "search_files",
12
+ "run_command",
13
+ "delegate_task",
14
+ ]);
15
+ const MODEL_EXPOSED_BUILTIN_MIDDLEWARE_TOOL_NAMES = new Set([
16
+ "fetch_url",
17
+ "http_request",
18
+ "send_message",
19
+ "request_approval",
20
+ "schedule_task",
21
+ ]);
22
+ export function materializeModelExposedBuiltinMiddlewareTools(input) {
23
+ const explicitToolNames = new Set(input.explicitToolNames ?? []);
24
+ const tools = [];
25
+ for (const [toolName, tool] of input.builtinTools.entries()) {
26
+ if (explicitToolNames.has(toolName)
27
+ || BUILTIN_MIDDLEWARE_ALIAS_TOOL_NAMES.has(toolName)
28
+ || !MODEL_EXPOSED_BUILTIN_MIDDLEWARE_TOOL_NAMES.has(toolName)) {
29
+ continue;
30
+ }
31
+ tools.push(asStructuredExecutableTool(tool, toolName, tool.name));
32
+ }
33
+ return tools;
34
+ }
35
+ export function resolveRunnableCheckpointer(options, binding) {
36
+ return options.checkpointerResolver ? options.checkpointerResolver(binding) : new MemorySaver();
37
+ }
38
+ export function resolveRunnableInterruptOn(binding) {
39
+ return compileInterruptOn(getBindingPrimaryTools(binding), getBindingInterruptCompatibilityRules(binding));
40
+ }
41
+ function buildUpstreamCreateBaseParams(binding, supportedFields) {
42
+ const executionParams = getBindingExecutionParams(binding);
43
+ if (!executionParams) {
44
+ throw new Error(`Agent ${binding.agent.id} has no compiled execution params`);
45
+ }
46
+ const source = executionParams;
47
+ const upstreamParams = Object.fromEntries(supportedFields
48
+ .filter((key) => key in source && source[key] !== undefined)
49
+ .map((key) => [key, source[key]]));
50
+ return upstreamParams;
51
+ }
52
+ export function buildLangChainCreateParams(input) {
53
+ const executionKind = getBindingExecutionKind(input.binding);
54
+ const executionParams = getBindingExecutionParams(input.binding);
55
+ if (executionKind !== "langchain-v1" || !executionParams) {
56
+ throw new Error(`Agent ${input.binding.agent.id} has no langchain params`);
57
+ }
58
+ const upstreamParams = buildUpstreamCreateBaseParams(input.binding, [
59
+ "model",
60
+ "tools",
61
+ "systemPrompt",
62
+ "stateSchema",
63
+ "contextSchema",
64
+ "checkpointer",
65
+ "store",
66
+ "responseFormat",
67
+ "middleware",
68
+ "name",
69
+ "description",
70
+ "includeAgentName",
71
+ "version",
72
+ ]);
73
+ const legacyPassthrough = typeof input.binding.langchainAgentParams?.passthrough === "object" &&
74
+ input.binding.langchainAgentParams?.passthrough
75
+ ? input.binding.langchainAgentParams.passthrough
76
+ : undefined;
77
+ const langchainPassthrough = typeof input.binding.harnessRuntime.langchain?.passthrough === "object" && input.binding.harnessRuntime.langchain?.passthrough
78
+ ? input.binding.harnessRuntime.langchain.passthrough
79
+ : undefined;
80
+ return {
81
+ ...upstreamParams,
82
+ ...(legacyPassthrough ?? {}),
83
+ ...(langchainPassthrough ?? {}),
84
+ ...(input.passthroughOverride ?? {}),
85
+ systemPrompt: input.systemPromptOverride ?? executionParams.systemPrompt,
86
+ model: input.resolvedModel,
87
+ tools: input.resolvedTools,
88
+ middleware: input.resolvedMiddleware,
89
+ checkpointer: input.resolvedCheckpointer,
90
+ store: input.resolvedStore,
91
+ };
92
+ }
93
+ export function resolveLangChainInvocationConfig(binding, options) {
94
+ const langchainPassthrough = typeof binding.harnessRuntime.langchain?.passthrough === "object" && binding.harnessRuntime.langchain?.passthrough
95
+ ? binding.harnessRuntime.langchain.passthrough
96
+ : undefined;
97
+ const config = {
98
+ configurable: {
99
+ [UPSTREAM_SESSION_CONFIG_KEY]: options.sessionId,
100
+ [UPSTREAM_REQUEST_CONFIG_KEY]: options.requestId,
101
+ },
102
+ };
103
+ if (typeof langchainPassthrough?.recursionLimit === "number") {
104
+ config.recursionLimit = langchainPassthrough.recursionLimit;
105
+ }
106
+ if (options.context) {
107
+ config.context = options.context;
108
+ }
109
+ if (options.toolRuntimeContext) {
110
+ config.toolRuntimeContext = options.toolRuntimeContext;
111
+ }
112
+ return config;
113
+ }
114
+ export function buildDeepAgentCreateParams(input) {
115
+ const executionKind = getBindingExecutionKind(input.binding);
116
+ if (executionKind !== "deepagent" || !getBindingExecutionParams(input.binding)) {
117
+ throw new Error(`Agent ${input.binding.agent.id} has no runnable params`);
118
+ }
119
+ const upstreamParams = buildUpstreamCreateBaseParams(input.binding, [
120
+ "model",
121
+ "tools",
122
+ "systemPrompt",
123
+ "middleware",
124
+ "subagents",
125
+ "responseFormat",
126
+ "contextSchema",
127
+ "checkpointer",
128
+ "store",
129
+ "backend",
130
+ "interruptOn",
131
+ "name",
132
+ "memory",
133
+ "skills",
134
+ ]);
135
+ return {
136
+ ...upstreamParams,
137
+ skills: input.resolvedSkills,
138
+ model: input.resolvedModel,
139
+ tools: input.resolvedTools,
140
+ middleware: input.resolvedMiddleware,
141
+ subagents: input.resolvedSubagents,
142
+ interruptOn: input.resolvedInterruptOn,
143
+ ...(input.resolvedCheckpointer !== undefined ? { checkpointer: input.resolvedCheckpointer } : {}),
144
+ ...(input.resolvedStore !== undefined ? { store: input.resolvedStore } : {}),
145
+ ...(input.resolvedBackend !== undefined ? { backend: input.resolvedBackend } : {}),
146
+ };
147
+ }
148
+ export function shouldUseMinimalDeepAgentAssembly(input) {
149
+ const executionKind = getBindingExecutionKind(input.binding);
150
+ if (executionKind !== "deepagent") {
151
+ return false;
152
+ }
153
+ if (input.resolvedBackend === undefined) {
154
+ return false;
155
+ }
156
+ if (input.resolvedSkills.length > 0) {
157
+ return false;
158
+ }
159
+ if (input.resolvedSubagents.length > 0 || getBindingDeepAgentSubagents(input.binding).length > 0) {
160
+ return false;
161
+ }
162
+ if (getBindingMemorySources(input.binding).length > 0) {
163
+ return false;
164
+ }
165
+ if (input.resolvedMiddleware.length > 0 || (getBindingMiddlewareConfigs(input.binding)?.length ?? 0) > 0) {
166
+ return false;
167
+ }
168
+ return input.resolvedInterruptOn === undefined || Object.keys(input.resolvedInterruptOn).length === 0;
169
+ }
170
+ export function buildMinimalDeepAgentCreateParams(input) {
171
+ const executionKind = getBindingExecutionKind(input.binding);
172
+ if (executionKind !== "deepagent" || !getBindingExecutionParams(input.binding)) {
173
+ throw new Error(`Agent ${input.binding.agent.id} has no runnable params`);
174
+ }
175
+ const upstreamParams = buildUpstreamCreateBaseParams(input.binding, [
176
+ "systemPrompt",
177
+ "contextSchema",
178
+ "responseFormat",
179
+ "name",
180
+ "description",
181
+ "includeAgentName",
182
+ "version",
183
+ ]);
184
+ return {
185
+ ...upstreamParams,
186
+ model: input.resolvedModel,
187
+ tools: input.resolvedTools,
188
+ middleware: [
189
+ todoListMiddleware(),
190
+ createFilesystemMiddleware({ backend: input.resolvedBackend }),
191
+ createPatchToolCallsMiddleware(),
192
+ ],
193
+ ...(input.resolvedCheckpointer !== undefined ? { checkpointer: input.resolvedCheckpointer } : {}),
194
+ ...(input.resolvedStore !== undefined ? { store: input.resolvedStore } : {}),
195
+ };
196
+ }
197
+ export function shouldAttachMinimalDeepAgentCheckpointer(binding, resolvedInterruptOn) {
198
+ if (binding.harnessRuntime.checkpointer !== undefined) {
199
+ return true;
200
+ }
201
+ return resolvedInterruptOn !== undefined && Object.keys(resolvedInterruptOn).length > 0;
202
+ }
203
+ export function shouldAttachMinimalDeepAgentStore(binding) {
204
+ return getBindingStoreConfig(binding) !== undefined || getBindingMemorySources(binding).length > 0;
205
+ }
206
+ export function shouldAttachMinimalDeepAgentBackend(binding) {
207
+ return (getBindingBackendConfig(binding) !== undefined ||
208
+ getBindingMemorySources(binding).length > 0 ||
209
+ getBindingSkills(binding).length > 0 ||
210
+ (getBindingMiddlewareConfigs(binding)?.length ?? 0) > 0);
211
+ }
@@ -9,5 +9,5 @@ export declare function createBackgroundEventRuntime(input: {
9
9
  persistence: RuntimePersistence;
10
10
  publishEvent: (event: HarnessEvent) => void;
11
11
  trackBackgroundTask: (task: Promise<void>) => void;
12
- backgroundEventTypes: ReadonlySet<import("../../contracts/runtime.js").HarnessEventType>;
12
+ backgroundEventTypes: ReadonlySet<import("../../contracts/runtime-observability.js").HarnessEventType>;
13
13
  };
@@ -1,5 +1,5 @@
1
1
  import { EventEmitter } from "node:events";
2
- import { getEventSubscribers } from "../../../extensions.js";
2
+ import { getEventSubscribers } from "../../../tooling/extensions.js";
3
3
  function dispatchListener(listener, event) {
4
4
  void Promise.resolve(listener(event));
5
5
  }
@@ -9,7 +9,7 @@ export declare function createRuntimeEventOperations(runtime: EventRuntime): {
9
9
  error?: string;
10
10
  }) => Promise<HarnessEvent>;
11
11
  requestApprovalAndEmit: (sessionId: string, requestId: string, input: MessageContent, interruptContent: string | undefined, checkpointRef: string, sequence: number) => Promise<{
12
- approval: import("../../../contracts/runtime.js").InternalApprovalRecord;
12
+ approval: import("../../../contracts/runtime-requests.js").InternalApprovalRecord;
13
13
  event: HarnessEvent;
14
14
  }>;
15
15
  emitSyntheticFallback: (sessionId: string, requestId: string, selectedAgentId: string, error: unknown, sequence?: number) => Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import { createFallbackRequestResultFromLatestEvent, mergeRequestResultOutput } from "../run/helpers.js";
2
- import { applyRequestStreamItemToSnapshot, createInitialRequestEventSnapshot, toRequestDataEvent, } from "../../../request-events.js";
2
+ import { applyRequestStreamItemToSnapshot, createInitialRequestEventSnapshot, toRequestDataEvent, } from "../../../projections/request-events.js";
3
3
  export async function emitOutputDeltaAndCreateItem(emit, sessionId, requestId, agentId, content) {
4
4
  await emit(sessionId, requestId, 3, "output.delta", {
5
5
  content,
@@ -0,0 +1,43 @@
1
+ import type { ApprovalRecord, HarnessStreamItem, InvocationEnvelope, MemoryRecord, MessageContent, RequestRecord, RequestResult, RequestSummary, SessionListSummary, SessionRecord, TranscriptMessage } from "../../contracts/types.js";
2
+ import type { PersistedSessionListSummary } from "../../persistence/types.js";
3
+ import type { InternalHarnessStreamItem } from "./events/streaming.js";
4
+ export declare function toPublicRequestResultShape(result: {
5
+ sessionId?: string;
6
+ requestId?: string;
7
+ legacySessionId?: string;
8
+ legacyRequestId?: string;
9
+ state: RequestResult["state"];
10
+ output: string;
11
+ finalMessageText?: string;
12
+ outputContent?: unknown;
13
+ contentBlocks?: unknown[];
14
+ structuredResponse?: unknown;
15
+ interruptContent?: string;
16
+ agentId?: string;
17
+ approvalId?: string;
18
+ pendingActionId?: string;
19
+ delegationId?: string;
20
+ artifacts?: RequestResult["artifacts"];
21
+ metadata?: Record<string, unknown>;
22
+ }): RequestResult;
23
+ export declare function toPublicHarnessStreamItem(item: InternalHarnessStreamItem): HarnessStreamItem;
24
+ export declare function mergeMemoryItems(...groups: MemoryRecord[][]): MemoryRecord[];
25
+ export declare function toSessionListSummary(session: PersistedSessionListSummary): SessionListSummary;
26
+ export declare function summarizeApprovalEvidence(approvals: ApprovalRecord[]): {
27
+ total: number;
28
+ pending: number;
29
+ approved: number;
30
+ edited: number;
31
+ rejected: number;
32
+ expired: number;
33
+ toolNames: string[];
34
+ approvalReasons: string[];
35
+ };
36
+ export declare function toRequestSummary(summary: RequestRecord): RequestSummary;
37
+ export declare function cloneRequestRecord(record: RequestRecord): RequestRecord;
38
+ export declare function cloneSessionRecord(record: SessionRecord): SessionRecord;
39
+ export declare function deriveRequestInputFromTranscript(transcript: TranscriptMessage[], requestId: string | undefined): {
40
+ input: MessageContent;
41
+ invocation?: InvocationEnvelope;
42
+ priority?: number;
43
+ } | null;