@botbotgo/agent-harness 0.0.41 → 0.0.42
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.
- package/README.md +86 -86
- package/dist/contracts/types.d.ts +8 -1
- package/dist/package-version.d.ts +1 -1
- package/dist/package-version.js +1 -1
- package/dist/runtime/agent-runtime-adapter.d.ts +0 -1
- package/dist/runtime/agent-runtime-adapter.js +9 -41
- package/dist/runtime/checkpoint-maintenance.js +1 -1
- package/dist/runtime/declared-middleware.d.ts +8 -1
- package/dist/runtime/declared-middleware.js +18 -1
- package/dist/runtime/harness.d.ts +4 -0
- package/dist/runtime/harness.js +303 -255
- package/dist/runtime/support/runtime-factories.d.ts +1 -1
- package/dist/runtime/support/runtime-factories.js +3 -0
- package/dist/workspace/agent-binding-compiler.js +11 -8
- package/dist/workspace/object-loader.js +7 -2
- package/dist/workspace/support/workspace-ref-utils.d.ts +4 -0
- package/dist/workspace/support/workspace-ref-utils.js +15 -1
- package/dist/workspace/validate.js +5 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,36 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
## Product Overview
|
|
4
4
|
|
|
5
|
-
`@botbotgo/agent-harness`
|
|
5
|
+
`@botbotgo/agent-harness` is a workspace-shaped application runtime for real agent products.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
It is not a new agent framework. It is the layer that sits around LangChain v1 and DeepAgents so an application can be assembled, configured, operated, and recovered as one runtime.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
- execution frameworks can run agents, but they do not give you a workspace-shaped product runtime by themselves
|
|
11
|
-
- applications need persisted threads, resumability, approvals, and operational control, not just model calls
|
|
9
|
+
The package is built for the gap between:
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
- agent execution semantics owned by LangChain v1 and DeepAgents
|
|
12
|
+
- application runtime concerns such as persisted threads, approvals, recovery, routing, maintenance, and local resource loading
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
- YAML-defined agents, models, routing, and maintenance policy
|
|
17
|
-
- local tools and SKILL packages loaded from `resources/`
|
|
18
|
-
- DeepAgents-first execution with LangChain v1 compatibility
|
|
19
|
-
- feature-level runtime APIs for runs, threads, approvals, and events
|
|
20
|
-
|
|
21
|
-
Core API:
|
|
14
|
+
What it provides:
|
|
22
15
|
|
|
23
|
-
- `createAgentHarness(...)`
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
- `
|
|
27
|
-
-
|
|
28
|
-
- `listApprovals(...)`
|
|
29
|
-
- `getApproval(...)`
|
|
30
|
-
- `stop(...)`
|
|
16
|
+
- a small runtime API centered on `createAgentHarness(...)`, `run(...)`, `subscribe(...)`, inspection methods, and `stop(...)`
|
|
17
|
+
- YAML-defined runtime assembly for hosts, models, routing, recovery, concurrency, MCP, and maintenance policy
|
|
18
|
+
- DeepAgents-first execution with LangChain v1 compatibility
|
|
19
|
+
- local `resources/tools/` and `resources/skills/` loading
|
|
20
|
+
- persisted runs, threads, approvals, events, and resumable checkpoints
|
|
31
21
|
|
|
32
22
|
## Quick Start
|
|
33
23
|
|
|
34
|
-
Install
|
|
24
|
+
Install:
|
|
35
25
|
|
|
36
26
|
```bash
|
|
37
27
|
npm install @botbotgo/agent-harness
|
|
@@ -54,19 +44,17 @@ your-workspace/
|
|
|
54
44
|
skills/
|
|
55
45
|
```
|
|
56
46
|
|
|
57
|
-
Use the standard layout only. Agent entry files must live under `config/agents/`.
|
|
58
|
-
|
|
59
47
|
Minimal usage:
|
|
60
48
|
|
|
61
49
|
```ts
|
|
62
50
|
import { createAgentHarness, run, stop } from "@botbotgo/agent-harness";
|
|
63
51
|
|
|
64
|
-
const runtime = await createAgentHarness("/absolute/path/to/
|
|
52
|
+
const runtime = await createAgentHarness("/absolute/path/to/workspace");
|
|
65
53
|
|
|
66
54
|
try {
|
|
67
55
|
const result = await run(runtime, {
|
|
68
56
|
agentId: "auto",
|
|
69
|
-
input: "
|
|
57
|
+
input: "Explain what this workspace is for.",
|
|
70
58
|
});
|
|
71
59
|
|
|
72
60
|
console.log(result.output);
|
|
@@ -77,13 +65,16 @@ try {
|
|
|
77
65
|
|
|
78
66
|
## Feature List
|
|
79
67
|
|
|
80
|
-
- Workspace runtime
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
-
-
|
|
84
|
-
- MCP
|
|
85
|
-
-
|
|
68
|
+
- Workspace runtime for multi-agent applications
|
|
69
|
+
- DeepAgents-first execution with LangChain v1 compatibility
|
|
70
|
+
- YAML-defined host routing
|
|
71
|
+
- Auto-discovered local tools and SKILL packages
|
|
72
|
+
- MCP bridge support for agent-declared MCP servers
|
|
73
|
+
- MCP server support for exposing harness tools outward
|
|
74
|
+
- Persisted threads, runs, approvals, and lifecycle events
|
|
75
|
+
- Recovery policy and resumable checkpoints
|
|
86
76
|
- Background checkpoint maintenance
|
|
77
|
+
- Runtime-level concurrency control
|
|
87
78
|
|
|
88
79
|
## How To Use
|
|
89
80
|
|
|
@@ -95,13 +86,9 @@ import { AgentHarnessRuntime, createAgentHarness } from "@botbotgo/agent-harness
|
|
|
95
86
|
const runtime: AgentHarnessRuntime = await createAgentHarness("/absolute/path/to/workspace");
|
|
96
87
|
```
|
|
97
88
|
|
|
98
|
-
|
|
89
|
+
You can also create a runtime from a precompiled `WorkspaceBundle`.
|
|
99
90
|
|
|
100
|
-
|
|
101
|
-
const runtime = await createAgentHarness(workspaceBundle);
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
`createAgentHarness(workspaceRoot)` loads one `WorkspaceBundle`, resolves `resources/`, initializes persistence under `runRoot`, and starts runtime maintenance.
|
|
91
|
+
`createAgentHarness(...)` loads one workspace, resolves `resources/`, initializes persistence under `runRoot`, and starts runtime maintenance.
|
|
105
92
|
|
|
106
93
|
### Run A Request
|
|
107
94
|
|
|
@@ -110,7 +97,7 @@ import { run } from "@botbotgo/agent-harness";
|
|
|
110
97
|
|
|
111
98
|
const result = await run(runtime, {
|
|
112
99
|
agentId: "orchestra",
|
|
113
|
-
input: "
|
|
100
|
+
input: "Summarize the runtime design.",
|
|
114
101
|
context: {
|
|
115
102
|
requestId: "req-123",
|
|
116
103
|
},
|
|
@@ -120,24 +107,24 @@ const result = await run(runtime, {
|
|
|
120
107
|
});
|
|
121
108
|
```
|
|
122
109
|
|
|
123
|
-
Each run creates or continues a persisted thread
|
|
110
|
+
Each run creates or continues a persisted thread and returns `threadId`, `runId`, `state`, and `output`.
|
|
124
111
|
|
|
125
|
-
When the
|
|
112
|
+
When the upstream LangChain v1 or DeepAgents graph expects extra invocation data, the runtime passes it through directly instead of inventing a parallel harness abstraction:
|
|
126
113
|
|
|
127
|
-
- `context
|
|
128
|
-
- `state
|
|
129
|
-
- `files
|
|
114
|
+
- `context` is forwarded as runtime context
|
|
115
|
+
- `state` is merged into the invocation input
|
|
116
|
+
- `files` is merged into the invocation input for state-backed DeepAgents files, memories, and skills
|
|
130
117
|
|
|
131
118
|
### Let The Runtime Route
|
|
132
119
|
|
|
133
120
|
```ts
|
|
134
121
|
const result = await run(runtime, {
|
|
135
122
|
agentId: "auto",
|
|
136
|
-
input: "Inspect
|
|
123
|
+
input: "Inspect the repository and explain the release flow.",
|
|
137
124
|
});
|
|
138
125
|
```
|
|
139
126
|
|
|
140
|
-
`agentId: "auto"` evaluates ordered `routing.rules
|
|
127
|
+
`agentId: "auto"` evaluates ordered `routing.rules`, then `routing.defaultAgentId`, and only falls back to model routing when `routing.modelRouting: true`.
|
|
141
128
|
|
|
142
129
|
### Stream Output And Events
|
|
143
130
|
|
|
@@ -156,9 +143,9 @@ const result = await run(runtime, {
|
|
|
156
143
|
});
|
|
157
144
|
```
|
|
158
145
|
|
|
159
|
-
|
|
146
|
+
`subscribe(...)` is a read-only observer surface over stored lifecycle events.
|
|
160
147
|
|
|
161
|
-
###
|
|
148
|
+
### Inspect Threads And Approvals
|
|
162
149
|
|
|
163
150
|
```ts
|
|
164
151
|
import {
|
|
@@ -174,21 +161,7 @@ const approvals = await listApprovals(runtime, { status: "pending" });
|
|
|
174
161
|
const approval = approvals[0] ? await getApproval(runtime, approvals[0].approvalId) : null;
|
|
175
162
|
```
|
|
176
163
|
|
|
177
|
-
These methods return
|
|
178
|
-
|
|
179
|
-
### Use Skills And Local Tools
|
|
180
|
-
|
|
181
|
-
`agent-harness` treats `resources/skills/` as SKILL packages and `resources/tools/` as executable local tools.
|
|
182
|
-
|
|
183
|
-
```yaml
|
|
184
|
-
spec:
|
|
185
|
-
skills:
|
|
186
|
-
- path: resources/skills/reviewer
|
|
187
|
-
tools:
|
|
188
|
-
- ref: tool/local-toolset
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
Tool modules are discovered from `resources/tools/*.js`, `resources/tools/*.mjs`, and `resources/tools/*.cjs`. The preferred format is exporting `tool({...})`.
|
|
164
|
+
These methods return runtime-facing records, not raw persistence or backend objects.
|
|
192
165
|
|
|
193
166
|
### Bridge MCP Servers Into Agents
|
|
194
167
|
|
|
@@ -201,10 +174,9 @@ spec:
|
|
|
201
174
|
- name: docs
|
|
202
175
|
transport: http
|
|
203
176
|
url: https://example.com/mcp
|
|
204
|
-
token: ${DOCS_MCP_TOKEN}
|
|
205
177
|
```
|
|
206
178
|
|
|
207
|
-
The runtime discovers MCP tools, filters them through agent
|
|
179
|
+
The runtime discovers MCP tools, filters them through agent configuration, and exposes them like other tools.
|
|
208
180
|
|
|
209
181
|
### Expose Runtime Tools As An MCP Server
|
|
210
182
|
|
|
@@ -227,33 +199,41 @@ await stop(runtime);
|
|
|
227
199
|
|
|
228
200
|
Core workspace files:
|
|
229
201
|
|
|
230
|
-
- `config/workspace.yaml
|
|
231
|
-
- `config/agent-context.md
|
|
232
|
-
- `config/models.yaml
|
|
233
|
-
- `config/agents/direct.yaml
|
|
234
|
-
- `config/agents/orchestra.yaml
|
|
235
|
-
- `resources/package.json
|
|
236
|
-
- `resources/tools
|
|
237
|
-
- `resources/skills
|
|
202
|
+
- `config/workspace.yaml`
|
|
203
|
+
- `config/agent-context.md`
|
|
204
|
+
- `config/models.yaml`
|
|
205
|
+
- `config/agents/direct.yaml`
|
|
206
|
+
- `config/agents/orchestra.yaml`
|
|
207
|
+
- `resources/package.json`
|
|
208
|
+
- `resources/tools/`
|
|
209
|
+
- `resources/skills/`
|
|
238
210
|
|
|
239
211
|
### `config/workspace.yaml`
|
|
240
212
|
|
|
241
|
-
Use this file for:
|
|
213
|
+
Use this file for runtime-level policy:
|
|
242
214
|
|
|
243
215
|
- `runRoot`
|
|
244
|
-
-
|
|
216
|
+
- `routing.rules`
|
|
217
|
+
- `routing.defaultAgentId`
|
|
245
218
|
- `routing.systemPrompt`
|
|
219
|
+
- `routing.modelRouting`
|
|
220
|
+
- `concurrency.maxConcurrentRuns`
|
|
221
|
+
- `recovery.enabled`
|
|
222
|
+
- `recovery.resumeOnStartup`
|
|
223
|
+
- `recovery.maxRecoveryAttempts`
|
|
246
224
|
- `maintenance.checkpoints.*`
|
|
247
225
|
|
|
248
226
|
If `runRoot` is omitted, the runtime defaults to `<workspace-root>/run-data`.
|
|
249
227
|
|
|
250
228
|
### `config/agent-context.md`
|
|
251
229
|
|
|
252
|
-
Use this file for shared
|
|
230
|
+
Use this file for shared startup context loaded into agents at construction time.
|
|
253
231
|
|
|
254
|
-
|
|
232
|
+
Put stable project context here. Do not use it as mutable long-term memory.
|
|
255
233
|
|
|
256
|
-
|
|
234
|
+
### `config/agents/*.yaml`
|
|
235
|
+
|
|
236
|
+
Use agent YAML for upstream-facing agent assembly. Common fields include:
|
|
257
237
|
|
|
258
238
|
- `modelRef`
|
|
259
239
|
- `systemPrompt`
|
|
@@ -263,19 +243,39 @@ Use `config/agents/*.yaml` to configure agents. Common fields include:
|
|
|
263
243
|
- `checkpointer`
|
|
264
244
|
- `store`
|
|
265
245
|
- `backend`
|
|
246
|
+
- `middleware`
|
|
266
247
|
- `subagents`
|
|
248
|
+
- `mcpServers`
|
|
267
249
|
|
|
268
|
-
###
|
|
250
|
+
### `resources/`
|
|
269
251
|
|
|
270
|
-
Use `resources/` for executable extensions:
|
|
252
|
+
Use `resources/` for executable local extensions:
|
|
271
253
|
|
|
272
|
-
- `resources/tools/` for
|
|
254
|
+
- `resources/tools/` for tool modules
|
|
273
255
|
- `resources/skills/` for SKILL packages
|
|
274
256
|
|
|
275
|
-
|
|
257
|
+
Tool modules are discovered from `resources/tools/*.js`, `resources/tools/*.mjs`, and `resources/tools/*.cjs`.
|
|
258
|
+
|
|
259
|
+
The preferred tool module format is exporting `tool({...})`.
|
|
260
|
+
|
|
261
|
+
Keep runtime extension source under `resources/`. Keep tests outside the published source tree, for example under repository `test/`.
|
|
262
|
+
|
|
263
|
+
## Design Notes
|
|
276
264
|
|
|
277
|
-
|
|
265
|
+
- `agent-harness` should express LangChain v1 and DeepAgents concepts as directly as possible
|
|
266
|
+
- agent-level execution behavior stays upstream
|
|
267
|
+
- application-level orchestration and lifecycle management stays in the harness
|
|
268
|
+
- checkpoint resume is treated as a system-managed runtime behavior, not a primary public abstraction
|
|
278
269
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
-
|
|
270
|
+
## API Summary
|
|
271
|
+
|
|
272
|
+
- `createAgentHarness(...)`
|
|
273
|
+
- `run(...)`
|
|
274
|
+
- `subscribe(...)`
|
|
275
|
+
- `listThreads(...)`
|
|
276
|
+
- `getThread(...)`
|
|
277
|
+
- `listApprovals(...)`
|
|
278
|
+
- `getApproval(...)`
|
|
279
|
+
- `createToolMcpServer(...)`
|
|
280
|
+
- `serveToolsOverStdio(...)`
|
|
281
|
+
- `stop(...)`
|
|
@@ -182,7 +182,7 @@ export type CompiledAgentBinding = {
|
|
|
182
182
|
runRoot: string;
|
|
183
183
|
workspaceRoot?: string;
|
|
184
184
|
hostFacing: boolean;
|
|
185
|
-
checkpointer?: Record<string, unknown
|
|
185
|
+
checkpointer?: Record<string, unknown> | boolean;
|
|
186
186
|
store?: Record<string, unknown>;
|
|
187
187
|
};
|
|
188
188
|
};
|
|
@@ -405,6 +405,12 @@ export type RuntimeModelResolver = (modelId: string) => unknown;
|
|
|
405
405
|
export type RuntimeEmbeddingModelResolver = (embeddingModelId: string) => unknown;
|
|
406
406
|
export type RuntimeVectorStoreResolver = (vectorStoreId: string) => unknown;
|
|
407
407
|
export type RuntimeMiddlewareResolver = (binding: CompiledAgentBinding) => unknown[];
|
|
408
|
+
export type RuntimeDeclaredMiddlewareResolver = (input: {
|
|
409
|
+
kind: string;
|
|
410
|
+
config: Record<string, unknown>;
|
|
411
|
+
binding?: CompiledAgentBinding;
|
|
412
|
+
resolveModel: (model: CompiledModel) => Promise<unknown>;
|
|
413
|
+
}) => unknown | unknown[] | null | undefined | Promise<unknown | unknown[] | null | undefined>;
|
|
408
414
|
export type RuntimeCheckpointerResolver = (binding: CompiledAgentBinding) => unknown;
|
|
409
415
|
export type RuntimeStoreResolver = (binding: CompiledAgentBinding) => unknown;
|
|
410
416
|
export type RuntimeBackendResolver = (binding: CompiledAgentBinding) => unknown;
|
|
@@ -414,6 +420,7 @@ export type RuntimeAdapterOptions = {
|
|
|
414
420
|
embeddingModelResolver?: RuntimeEmbeddingModelResolver;
|
|
415
421
|
vectorStoreResolver?: RuntimeVectorStoreResolver;
|
|
416
422
|
middlewareResolver?: RuntimeMiddlewareResolver;
|
|
423
|
+
declaredMiddlewareResolver?: RuntimeDeclaredMiddlewareResolver;
|
|
417
424
|
checkpointerResolver?: RuntimeCheckpointerResolver;
|
|
418
425
|
storeResolver?: RuntimeStoreResolver;
|
|
419
426
|
backendResolver?: RuntimeBackendResolver;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export declare const AGENT_HARNESS_VERSION = "0.0.41";
|
package/dist/package-version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export const AGENT_HARNESS_VERSION = "0.0.41";
|
|
@@ -15,7 +15,6 @@ declare class RuntimeOperationTimeoutError extends Error {
|
|
|
15
15
|
export declare class AgentRuntimeAdapter {
|
|
16
16
|
private readonly options;
|
|
17
17
|
constructor(options?: RuntimeAdapterOptions);
|
|
18
|
-
private canUseSimpleDeepAgentFastPath;
|
|
19
18
|
private resolveBindingTimeout;
|
|
20
19
|
private resolveStreamIdleTimeout;
|
|
21
20
|
private withTimeout;
|
|
@@ -12,6 +12,9 @@ import { computeIncrementalOutput, extractAgentStep, extractInterruptPayload, ex
|
|
|
12
12
|
import { wrapToolForExecution } from "./tool-hitl.js";
|
|
13
13
|
import { resolveDeclaredMiddleware } from "./declared-middleware.js";
|
|
14
14
|
import { extractMessageText, normalizeMessageContent } from "../utils/message-content.js";
|
|
15
|
+
function countConfiguredTools(binding) {
|
|
16
|
+
return binding.langchainAgentParams?.tools.length ?? binding.deepAgentParams?.tools.length ?? 0;
|
|
17
|
+
}
|
|
15
18
|
const AGENT_INTERRUPT_SENTINEL_PREFIX = "__agent_harness_interrupt__:";
|
|
16
19
|
const MODEL_SAFE_TOOL_NAME_PATTERN = /^[a-zA-Z0-9_-]+$/;
|
|
17
20
|
class RuntimeOperationTimeoutError extends Error {
|
|
@@ -163,33 +166,11 @@ function asStructuredExecutableTool(resolvedTool, modelFacingName, description)
|
|
|
163
166
|
schema: normalizeResolvedToolSchema(resolvedTool),
|
|
164
167
|
});
|
|
165
168
|
}
|
|
166
|
-
function countConfiguredTools(binding) {
|
|
167
|
-
return binding.langchainAgentParams?.tools.length ?? binding.deepAgentParams?.tools.length ?? 0;
|
|
168
|
-
}
|
|
169
169
|
export class AgentRuntimeAdapter {
|
|
170
170
|
options;
|
|
171
171
|
constructor(options = {}) {
|
|
172
172
|
this.options = options;
|
|
173
173
|
}
|
|
174
|
-
canUseSimpleDeepAgentFastPath(binding) {
|
|
175
|
-
const params = binding.deepAgentParams;
|
|
176
|
-
if (!params) {
|
|
177
|
-
return false;
|
|
178
|
-
}
|
|
179
|
-
if ((params.subagents?.length ?? 0) > 0) {
|
|
180
|
-
return false;
|
|
181
|
-
}
|
|
182
|
-
if ((params.memory?.length ?? 0) > 0) {
|
|
183
|
-
return false;
|
|
184
|
-
}
|
|
185
|
-
if ((params.skills?.length ?? 0) > 0) {
|
|
186
|
-
return false;
|
|
187
|
-
}
|
|
188
|
-
if (params.backend || params.store) {
|
|
189
|
-
return false;
|
|
190
|
-
}
|
|
191
|
-
return true;
|
|
192
|
-
}
|
|
193
174
|
resolveBindingTimeout(binding) {
|
|
194
175
|
return resolveTimeoutMs(binding.langchainAgentParams?.model.init.timeout ?? binding.deepAgentParams?.model.init.timeout);
|
|
195
176
|
}
|
|
@@ -452,6 +433,8 @@ export class AgentRuntimeAdapter {
|
|
|
452
433
|
const declarativeMiddleware = await resolveDeclaredMiddleware(binding.langchainAgentParams?.middleware ??
|
|
453
434
|
binding.deepAgentParams?.middleware, {
|
|
454
435
|
resolveModel: (model) => this.resolveModel(model),
|
|
436
|
+
resolveCustom: this.options.declaredMiddlewareResolver,
|
|
437
|
+
binding,
|
|
455
438
|
});
|
|
456
439
|
const middleware = [
|
|
457
440
|
...declarativeMiddleware,
|
|
@@ -485,7 +468,7 @@ export class AgentRuntimeAdapter {
|
|
|
485
468
|
.replaceAll("{{secondaryAgentId}}", secondaryBinding.agent.id)
|
|
486
469
|
.replaceAll("{{secondaryDescription}}", secondaryBinding.agent.description);
|
|
487
470
|
}
|
|
488
|
-
async resolveSubagents(subagents) {
|
|
471
|
+
async resolveSubagents(subagents, binding) {
|
|
489
472
|
return Promise.all(subagents.map(async (subagent) => ({
|
|
490
473
|
...subagent,
|
|
491
474
|
model: subagent.model ? (await this.resolveModel(subagent.model)) : undefined,
|
|
@@ -495,6 +478,8 @@ export class AgentRuntimeAdapter {
|
|
|
495
478
|
contextSchema: subagent.contextSchema,
|
|
496
479
|
middleware: (await resolveDeclaredMiddleware(subagent.middleware, {
|
|
497
480
|
resolveModel: (model) => this.resolveModel(model),
|
|
481
|
+
resolveCustom: this.options.declaredMiddlewareResolver,
|
|
482
|
+
binding,
|
|
498
483
|
})),
|
|
499
484
|
})));
|
|
500
485
|
}
|
|
@@ -526,23 +511,6 @@ export class AgentRuntimeAdapter {
|
|
|
526
511
|
if (!params) {
|
|
527
512
|
throw new Error(`Agent ${binding.agent.id} has no runnable params`);
|
|
528
513
|
}
|
|
529
|
-
if (this.canUseSimpleDeepAgentFastPath(binding)) {
|
|
530
|
-
const interruptOn = this.resolveInterruptOn(binding);
|
|
531
|
-
const model = (await this.resolveModel(params.model));
|
|
532
|
-
const tools = this.resolveTools(params.tools, binding);
|
|
533
|
-
if (tools.length > 0 && typeof model.bindTools !== "function") {
|
|
534
|
-
throw new Error(`Agent ${binding.agent.id} configures ${tools.length} tool(s), but resolved model ${params.model.id} does not support tool binding.`);
|
|
535
|
-
}
|
|
536
|
-
return createAgent({
|
|
537
|
-
model: model,
|
|
538
|
-
tools: tools,
|
|
539
|
-
systemPrompt: params.systemPrompt,
|
|
540
|
-
responseFormat: params.responseFormat,
|
|
541
|
-
contextSchema: params.contextSchema,
|
|
542
|
-
middleware: (await this.resolveMiddleware(binding, interruptOn)),
|
|
543
|
-
checkpointer: this.resolveCheckpointer(binding),
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
514
|
const deepAgentConfig = {
|
|
547
515
|
model: (await this.resolveModel(params.model)),
|
|
548
516
|
tools: this.resolveTools(params.tools, binding),
|
|
@@ -550,7 +518,7 @@ export class AgentRuntimeAdapter {
|
|
|
550
518
|
responseFormat: params.responseFormat,
|
|
551
519
|
contextSchema: params.contextSchema,
|
|
552
520
|
middleware: (await this.resolveMiddleware(binding)),
|
|
553
|
-
subagents: (await this.resolveSubagents(params.subagents)),
|
|
521
|
+
subagents: (await this.resolveSubagents(params.subagents, binding)),
|
|
554
522
|
checkpointer: this.resolveCheckpointer(binding),
|
|
555
523
|
store: this.options.storeResolver?.(binding),
|
|
556
524
|
backend: this.options.backendResolver?.(binding),
|
|
@@ -46,7 +46,7 @@ export function readCheckpointMaintenanceConfig(workspace) {
|
|
|
46
46
|
}
|
|
47
47
|
function resolveSqliteCheckpointPath(binding) {
|
|
48
48
|
const config = binding.harnessRuntime.checkpointer;
|
|
49
|
-
if (!config) {
|
|
49
|
+
if (!config || typeof config === "boolean") {
|
|
50
50
|
return null;
|
|
51
51
|
}
|
|
52
52
|
const kind = typeof config.kind === "string" ? config.kind : "FileCheckpointer";
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import type { CompiledModel } from "../contracts/types.js";
|
|
1
|
+
import type { CompiledAgentBinding, CompiledModel } from "../contracts/types.js";
|
|
2
2
|
export declare function resolveDeclaredMiddleware(middlewareConfigs: unknown[] | undefined, options: {
|
|
3
3
|
resolveModel: (model: CompiledModel) => Promise<unknown>;
|
|
4
|
+
resolveCustom?: (input: {
|
|
5
|
+
kind: string;
|
|
6
|
+
config: Record<string, unknown>;
|
|
7
|
+
binding?: CompiledAgentBinding;
|
|
8
|
+
resolveModel: (model: CompiledModel) => Promise<unknown>;
|
|
9
|
+
}) => unknown | unknown[] | null | undefined | Promise<unknown | unknown[] | null | undefined>;
|
|
10
|
+
binding?: CompiledAgentBinding;
|
|
4
11
|
}): Promise<unknown[]>;
|
|
@@ -83,8 +83,25 @@ export async function resolveDeclaredMiddleware(middlewareConfigs, options) {
|
|
|
83
83
|
case "anthropicPromptCaching":
|
|
84
84
|
resolved.push(anthropicPromptCachingMiddleware(runtimeConfig));
|
|
85
85
|
break;
|
|
86
|
-
default:
|
|
86
|
+
default: {
|
|
87
|
+
const customResolved = options.resolveCustom
|
|
88
|
+
? await options.resolveCustom({
|
|
89
|
+
kind,
|
|
90
|
+
config: runtimeConfig,
|
|
91
|
+
binding: options.binding,
|
|
92
|
+
resolveModel: options.resolveModel,
|
|
93
|
+
})
|
|
94
|
+
: undefined;
|
|
95
|
+
if (Array.isArray(customResolved)) {
|
|
96
|
+
resolved.push(...customResolved);
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
if (customResolved) {
|
|
100
|
+
resolved.push(customResolved);
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
87
103
|
throw new Error(`Unsupported declarative middleware kind ${kind}`);
|
|
104
|
+
}
|
|
88
105
|
}
|
|
89
106
|
}
|
|
90
107
|
return resolved;
|
|
@@ -21,6 +21,9 @@ export declare class AgentHarnessRuntime {
|
|
|
21
21
|
private readonly resolvedRuntimeAdapterOptions;
|
|
22
22
|
private readonly checkpointMaintenance;
|
|
23
23
|
private readonly recoveryConfig;
|
|
24
|
+
private readonly concurrencyConfig;
|
|
25
|
+
private activeRunSlots;
|
|
26
|
+
private readonly pendingRunSlots;
|
|
24
27
|
private listHostBindings;
|
|
25
28
|
private defaultRunRoot;
|
|
26
29
|
private heuristicRoute;
|
|
@@ -68,6 +71,7 @@ export declare class AgentHarnessRuntime {
|
|
|
68
71
|
private resolveApprovalRecord;
|
|
69
72
|
private isDecisionRun;
|
|
70
73
|
private notifyListener;
|
|
74
|
+
private acquireRunSlot;
|
|
71
75
|
private dispatchRunListeners;
|
|
72
76
|
run(options: RunOptions): Promise<RunResult>;
|
|
73
77
|
streamEvents(options: RunStartOptions): AsyncGenerator<HarnessStreamItem>;
|