@botbotgo/agent-harness 0.0.40 → 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 +94 -82
- package/dist/config/workspace.yaml +14 -0
- package/dist/contracts/types.d.ts +17 -1
- package/dist/package-version.d.ts +1 -1
- package/dist/package-version.js +1 -1
- package/dist/persistence/file-store.d.ts +36 -0
- package/dist/persistence/file-store.js +32 -0
- package/dist/runtime/agent-runtime-adapter.d.ts +11 -3
- package/dist/runtime/agent-runtime-adapter.js +31 -48
- package/dist/runtime/checkpoint-maintenance.js +1 -1
- package/dist/runtime/declared-middleware.d.ts +8 -1
- package/dist/runtime/declared-middleware.js +57 -5
- package/dist/runtime/harness.d.ts +9 -0
- package/dist/runtime/harness.js +393 -247
- 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 +37 -8
- package/dist/workspace/object-loader.js +12 -2
- package/dist/workspace/support/workspace-ref-utils.d.ts +15 -0
- package/dist/workspace/support/workspace-ref-utils.js +40 -0
- package/dist/workspace/validate.js +11 -11
- 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
|
-
|
|
99
|
-
|
|
100
|
-
```ts
|
|
101
|
-
const runtime = await createAgentHarness(workspaceBundle);
|
|
102
|
-
```
|
|
89
|
+
You can also create a runtime from a precompiled `WorkspaceBundle`.
|
|
103
90
|
|
|
104
|
-
`createAgentHarness(
|
|
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,22 +97,34 @@ 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.",
|
|
101
|
+
context: {
|
|
102
|
+
requestId: "req-123",
|
|
103
|
+
},
|
|
104
|
+
state: {
|
|
105
|
+
visitCount: 1,
|
|
106
|
+
},
|
|
114
107
|
});
|
|
115
108
|
```
|
|
116
109
|
|
|
117
|
-
Each run creates or continues a persisted thread
|
|
110
|
+
Each run creates or continues a persisted thread and returns `threadId`, `runId`, `state`, and `output`.
|
|
111
|
+
|
|
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:
|
|
113
|
+
|
|
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
|
|
118
117
|
|
|
119
118
|
### Let The Runtime Route
|
|
120
119
|
|
|
121
120
|
```ts
|
|
122
121
|
const result = await run(runtime, {
|
|
123
122
|
agentId: "auto",
|
|
124
|
-
input: "Inspect
|
|
123
|
+
input: "Inspect the repository and explain the release flow.",
|
|
125
124
|
});
|
|
126
125
|
```
|
|
127
126
|
|
|
128
|
-
`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`.
|
|
129
128
|
|
|
130
129
|
### Stream Output And Events
|
|
131
130
|
|
|
@@ -144,9 +143,9 @@ const result = await run(runtime, {
|
|
|
144
143
|
});
|
|
145
144
|
```
|
|
146
145
|
|
|
147
|
-
|
|
146
|
+
`subscribe(...)` is a read-only observer surface over stored lifecycle events.
|
|
148
147
|
|
|
149
|
-
###
|
|
148
|
+
### Inspect Threads And Approvals
|
|
150
149
|
|
|
151
150
|
```ts
|
|
152
151
|
import {
|
|
@@ -162,21 +161,7 @@ const approvals = await listApprovals(runtime, { status: "pending" });
|
|
|
162
161
|
const approval = approvals[0] ? await getApproval(runtime, approvals[0].approvalId) : null;
|
|
163
162
|
```
|
|
164
163
|
|
|
165
|
-
These methods return
|
|
166
|
-
|
|
167
|
-
### Use Skills And Local Tools
|
|
168
|
-
|
|
169
|
-
`agent-harness` treats `resources/skills/` as SKILL packages and `resources/tools/` as executable local tools.
|
|
170
|
-
|
|
171
|
-
```yaml
|
|
172
|
-
spec:
|
|
173
|
-
skills:
|
|
174
|
-
- path: resources/skills/reviewer
|
|
175
|
-
tools:
|
|
176
|
-
- ref: tool/local-toolset
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
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.
|
|
180
165
|
|
|
181
166
|
### Bridge MCP Servers Into Agents
|
|
182
167
|
|
|
@@ -189,10 +174,9 @@ spec:
|
|
|
189
174
|
- name: docs
|
|
190
175
|
transport: http
|
|
191
176
|
url: https://example.com/mcp
|
|
192
|
-
token: ${DOCS_MCP_TOKEN}
|
|
193
177
|
```
|
|
194
178
|
|
|
195
|
-
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.
|
|
196
180
|
|
|
197
181
|
### Expose Runtime Tools As An MCP Server
|
|
198
182
|
|
|
@@ -215,33 +199,41 @@ await stop(runtime);
|
|
|
215
199
|
|
|
216
200
|
Core workspace files:
|
|
217
201
|
|
|
218
|
-
- `config/workspace.yaml
|
|
219
|
-
- `config/agent-context.md
|
|
220
|
-
- `config/models.yaml
|
|
221
|
-
- `config/agents/direct.yaml
|
|
222
|
-
- `config/agents/orchestra.yaml
|
|
223
|
-
- `resources/package.json
|
|
224
|
-
- `resources/tools
|
|
225
|
-
- `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/`
|
|
226
210
|
|
|
227
211
|
### `config/workspace.yaml`
|
|
228
212
|
|
|
229
|
-
Use this file for:
|
|
213
|
+
Use this file for runtime-level policy:
|
|
230
214
|
|
|
231
215
|
- `runRoot`
|
|
232
|
-
-
|
|
216
|
+
- `routing.rules`
|
|
217
|
+
- `routing.defaultAgentId`
|
|
233
218
|
- `routing.systemPrompt`
|
|
219
|
+
- `routing.modelRouting`
|
|
220
|
+
- `concurrency.maxConcurrentRuns`
|
|
221
|
+
- `recovery.enabled`
|
|
222
|
+
- `recovery.resumeOnStartup`
|
|
223
|
+
- `recovery.maxRecoveryAttempts`
|
|
234
224
|
- `maintenance.checkpoints.*`
|
|
235
225
|
|
|
236
226
|
If `runRoot` is omitted, the runtime defaults to `<workspace-root>/run-data`.
|
|
237
227
|
|
|
238
228
|
### `config/agent-context.md`
|
|
239
229
|
|
|
240
|
-
Use this file for shared
|
|
230
|
+
Use this file for shared startup context loaded into agents at construction time.
|
|
231
|
+
|
|
232
|
+
Put stable project context here. Do not use it as mutable long-term memory.
|
|
241
233
|
|
|
242
|
-
###
|
|
234
|
+
### `config/agents/*.yaml`
|
|
243
235
|
|
|
244
|
-
Use
|
|
236
|
+
Use agent YAML for upstream-facing agent assembly. Common fields include:
|
|
245
237
|
|
|
246
238
|
- `modelRef`
|
|
247
239
|
- `systemPrompt`
|
|
@@ -251,19 +243,39 @@ Use `config/agents/*.yaml` to configure agents. Common fields include:
|
|
|
251
243
|
- `checkpointer`
|
|
252
244
|
- `store`
|
|
253
245
|
- `backend`
|
|
246
|
+
- `middleware`
|
|
254
247
|
- `subagents`
|
|
248
|
+
- `mcpServers`
|
|
255
249
|
|
|
256
|
-
###
|
|
250
|
+
### `resources/`
|
|
257
251
|
|
|
258
|
-
Use `resources/` for executable extensions:
|
|
252
|
+
Use `resources/` for executable local extensions:
|
|
259
253
|
|
|
260
|
-
- `resources/tools/` for
|
|
254
|
+
- `resources/tools/` for tool modules
|
|
261
255
|
- `resources/skills/` for SKILL packages
|
|
262
256
|
|
|
263
|
-
|
|
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/`.
|
|
264
262
|
|
|
265
|
-
|
|
263
|
+
## Design Notes
|
|
266
264
|
|
|
267
|
-
-
|
|
268
|
-
-
|
|
269
|
-
-
|
|
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
|
|
269
|
+
|
|
270
|
+
## API Summary
|
|
271
|
+
|
|
272
|
+
- `createAgentHarness(...)`
|
|
273
|
+
- `run(...)`
|
|
274
|
+
- `subscribe(...)`
|
|
275
|
+
- `listThreads(...)`
|
|
276
|
+
- `getThread(...)`
|
|
277
|
+
- `listApprovals(...)`
|
|
278
|
+
- `getApproval(...)`
|
|
279
|
+
- `createToolMcpServer(...)`
|
|
280
|
+
- `serveToolsOverStdio(...)`
|
|
281
|
+
- `stop(...)`
|
|
@@ -102,3 +102,17 @@ spec:
|
|
|
102
102
|
# sqlite:
|
|
103
103
|
# sweepBatchSize: 200
|
|
104
104
|
# vacuum: false
|
|
105
|
+
|
|
106
|
+
# agent-harness feature: runtime-managed recovery policy for interrupted runs.
|
|
107
|
+
# This keeps checkpoint resume as an internal lifecycle concern instead of a primary user-facing API concept.
|
|
108
|
+
#
|
|
109
|
+
# Current support:
|
|
110
|
+
# - startup recovery of runs already in `resuming` state
|
|
111
|
+
# - persisted approval-decision intent for cross-restart resume continuation
|
|
112
|
+
# - bounded retry attempts to avoid infinite restart loops
|
|
113
|
+
#
|
|
114
|
+
# Example:
|
|
115
|
+
# recovery:
|
|
116
|
+
# enabled: true
|
|
117
|
+
# resumeResumingRunsOnStartup: true
|
|
118
|
+
# maxRecoveryAttempts: 3
|
|
@@ -86,9 +86,13 @@ export type LangChainAgentParams = {
|
|
|
86
86
|
model: CompiledModel;
|
|
87
87
|
tools: CompiledTool[];
|
|
88
88
|
systemPrompt?: string;
|
|
89
|
+
stateSchema?: unknown;
|
|
89
90
|
responseFormat?: unknown;
|
|
90
91
|
contextSchema?: unknown;
|
|
91
92
|
middleware?: Array<Record<string, unknown>>;
|
|
93
|
+
includeAgentName?: "inline";
|
|
94
|
+
version?: "v1" | "v2";
|
|
95
|
+
name?: string;
|
|
92
96
|
description: string;
|
|
93
97
|
};
|
|
94
98
|
export type CompiledSubAgent = {
|
|
@@ -119,6 +123,8 @@ export type DeepAgentParams = {
|
|
|
119
123
|
name: string;
|
|
120
124
|
memory: string[];
|
|
121
125
|
skills: string[];
|
|
126
|
+
generalPurposeAgent?: boolean;
|
|
127
|
+
taskDescription?: string;
|
|
122
128
|
};
|
|
123
129
|
export type CompiledModel = {
|
|
124
130
|
id: string;
|
|
@@ -176,7 +182,7 @@ export type CompiledAgentBinding = {
|
|
|
176
182
|
runRoot: string;
|
|
177
183
|
workspaceRoot?: string;
|
|
178
184
|
hostFacing: boolean;
|
|
179
|
-
checkpointer?: Record<string, unknown
|
|
185
|
+
checkpointer?: Record<string, unknown> | boolean;
|
|
180
186
|
store?: Record<string, unknown>;
|
|
181
187
|
};
|
|
182
188
|
};
|
|
@@ -262,6 +268,9 @@ export type RunStartOptions = {
|
|
|
262
268
|
agentId?: string;
|
|
263
269
|
input: MessageContent;
|
|
264
270
|
threadId?: string;
|
|
271
|
+
context?: Record<string, unknown>;
|
|
272
|
+
state?: Record<string, unknown>;
|
|
273
|
+
files?: Record<string, unknown>;
|
|
265
274
|
listeners?: RunListeners;
|
|
266
275
|
};
|
|
267
276
|
export type RunDecisionOptions = {
|
|
@@ -396,6 +405,12 @@ export type RuntimeModelResolver = (modelId: string) => unknown;
|
|
|
396
405
|
export type RuntimeEmbeddingModelResolver = (embeddingModelId: string) => unknown;
|
|
397
406
|
export type RuntimeVectorStoreResolver = (vectorStoreId: string) => unknown;
|
|
398
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>;
|
|
399
414
|
export type RuntimeCheckpointerResolver = (binding: CompiledAgentBinding) => unknown;
|
|
400
415
|
export type RuntimeStoreResolver = (binding: CompiledAgentBinding) => unknown;
|
|
401
416
|
export type RuntimeBackendResolver = (binding: CompiledAgentBinding) => unknown;
|
|
@@ -405,6 +420,7 @@ export type RuntimeAdapterOptions = {
|
|
|
405
420
|
embeddingModelResolver?: RuntimeEmbeddingModelResolver;
|
|
406
421
|
vectorStoreResolver?: RuntimeVectorStoreResolver;
|
|
407
422
|
middlewareResolver?: RuntimeMiddlewareResolver;
|
|
423
|
+
declaredMiddlewareResolver?: RuntimeDeclaredMiddlewareResolver;
|
|
408
424
|
checkpointerResolver?: RuntimeCheckpointerResolver;
|
|
409
425
|
storeResolver?: RuntimeStoreResolver;
|
|
410
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";
|
|
@@ -8,6 +8,36 @@ type ThreadMeta = {
|
|
|
8
8
|
status: RunState;
|
|
9
9
|
latestRunId: string;
|
|
10
10
|
};
|
|
11
|
+
type RunMeta = {
|
|
12
|
+
runId: string;
|
|
13
|
+
threadId: string;
|
|
14
|
+
agentId: string;
|
|
15
|
+
executionMode: string;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
updatedAt: string;
|
|
18
|
+
};
|
|
19
|
+
type Lifecycle = {
|
|
20
|
+
state: RunState;
|
|
21
|
+
previousState: RunState | null;
|
|
22
|
+
stateEnteredAt: string;
|
|
23
|
+
lastTransitionAt: string;
|
|
24
|
+
resumable: boolean;
|
|
25
|
+
checkpointRef: string | null;
|
|
26
|
+
};
|
|
27
|
+
type RunIndexRecord = {
|
|
28
|
+
runId: string;
|
|
29
|
+
threadId: string;
|
|
30
|
+
state: RunState;
|
|
31
|
+
resumable: boolean;
|
|
32
|
+
updatedAt: string;
|
|
33
|
+
};
|
|
34
|
+
type RecoveryIntent = {
|
|
35
|
+
kind: "approval-decision";
|
|
36
|
+
savedAt: string;
|
|
37
|
+
checkpointRef: string | null;
|
|
38
|
+
resumePayload: unknown;
|
|
39
|
+
attempts: number;
|
|
40
|
+
};
|
|
11
41
|
export declare class FilePersistence {
|
|
12
42
|
private readonly runRoot;
|
|
13
43
|
constructor(runRoot: string);
|
|
@@ -31,6 +61,7 @@ export declare class FilePersistence {
|
|
|
31
61
|
setRunState(threadId: string, runId: string, state: RunState, checkpointRef?: string | null): Promise<void>;
|
|
32
62
|
appendEvent(event: HarnessEvent): Promise<void>;
|
|
33
63
|
listSessions(): Promise<ThreadSummary[]>;
|
|
64
|
+
listRunIndexes(): Promise<RunIndexRecord[]>;
|
|
34
65
|
getSession(threadId: string): Promise<ThreadSummary | null>;
|
|
35
66
|
getThreadMeta(threadId: string): Promise<ThreadMeta | null>;
|
|
36
67
|
listThreadRuns(threadId: string): Promise<ThreadRunRecord[]>;
|
|
@@ -38,6 +69,8 @@ export declare class FilePersistence {
|
|
|
38
69
|
listApprovals(): Promise<ApprovalRecord[]>;
|
|
39
70
|
getApproval(approvalId: string): Promise<ApprovalRecord | null>;
|
|
40
71
|
getRunApprovals(threadId: string, runId: string): Promise<ApprovalRecord[]>;
|
|
72
|
+
getRunMeta(threadId: string, runId: string): Promise<RunMeta>;
|
|
73
|
+
getRunLifecycle(threadId: string, runId: string): Promise<Lifecycle>;
|
|
41
74
|
listDelegations(): Promise<DelegationRecord[]>;
|
|
42
75
|
createApproval(record: ApprovalRecord): Promise<void>;
|
|
43
76
|
resolveApproval(threadId: string, runId: string, approvalId: string, status: ApprovalRecord["status"]): Promise<ApprovalRecord>;
|
|
@@ -47,5 +80,8 @@ export declare class FilePersistence {
|
|
|
47
80
|
listArtifacts(threadId: string, runId: string): Promise<ArtifactListing>;
|
|
48
81
|
appendThreadMessage(threadId: string, message: TranscriptMessage): Promise<void>;
|
|
49
82
|
listThreadMessages(threadId: string, limit?: number): Promise<TranscriptMessage[]>;
|
|
83
|
+
saveRecoveryIntent(threadId: string, runId: string, intent: RecoveryIntent): Promise<void>;
|
|
84
|
+
getRecoveryIntent(threadId: string, runId: string): Promise<RecoveryIntent | null>;
|
|
85
|
+
clearRecoveryIntent(threadId: string, runId: string): Promise<void>;
|
|
50
86
|
}
|
|
51
87
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import { rm } from "node:fs/promises";
|
|
2
3
|
import { readdir } from "node:fs/promises";
|
|
3
4
|
import { ensureDir, fileExists, readJson, writeJson } from "../utils/fs.js";
|
|
4
5
|
export class FilePersistence {
|
|
@@ -168,6 +169,14 @@ export class FilePersistence {
|
|
|
168
169
|
}));
|
|
169
170
|
return records.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
|
|
170
171
|
}
|
|
172
|
+
async listRunIndexes() {
|
|
173
|
+
const runIndexDir = path.join(this.runRoot, "indexes", "runs");
|
|
174
|
+
if (!(await fileExists(runIndexDir))) {
|
|
175
|
+
return [];
|
|
176
|
+
}
|
|
177
|
+
const entries = (await readdir(runIndexDir)).sort();
|
|
178
|
+
return Promise.all(entries.map((entry) => readJson(path.join(runIndexDir, entry))));
|
|
179
|
+
}
|
|
171
180
|
async getSession(threadId) {
|
|
172
181
|
const filePath = path.join(this.runRoot, "indexes", "threads", `${threadId}.json`);
|
|
173
182
|
if (!(await fileExists(filePath))) {
|
|
@@ -249,6 +258,12 @@ export class FilePersistence {
|
|
|
249
258
|
const entries = (await readdir(approvalsDir)).sort();
|
|
250
259
|
return Promise.all(entries.map((entry) => readJson(path.join(approvalsDir, entry))));
|
|
251
260
|
}
|
|
261
|
+
async getRunMeta(threadId, runId) {
|
|
262
|
+
return readJson(path.join(this.runDir(threadId, runId), "meta.json"));
|
|
263
|
+
}
|
|
264
|
+
async getRunLifecycle(threadId, runId) {
|
|
265
|
+
return readJson(path.join(this.runDir(threadId, runId), "lifecycle.json"));
|
|
266
|
+
}
|
|
252
267
|
async listDelegations() {
|
|
253
268
|
const delegationsDir = path.join(this.runRoot, "indexes", "delegations");
|
|
254
269
|
if (!(await fileExists(delegationsDir))) {
|
|
@@ -321,4 +336,21 @@ export class FilePersistence {
|
|
|
321
336
|
const current = await readJson(messagesPath);
|
|
322
337
|
return current.items.slice(-limit);
|
|
323
338
|
}
|
|
339
|
+
async saveRecoveryIntent(threadId, runId, intent) {
|
|
340
|
+
await writeJson(path.join(this.runDir(threadId, runId), "recovery-intent.json"), intent);
|
|
341
|
+
}
|
|
342
|
+
async getRecoveryIntent(threadId, runId) {
|
|
343
|
+
const intentPath = path.join(this.runDir(threadId, runId), "recovery-intent.json");
|
|
344
|
+
if (!(await fileExists(intentPath))) {
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
return readJson(intentPath);
|
|
348
|
+
}
|
|
349
|
+
async clearRecoveryIntent(threadId, runId) {
|
|
350
|
+
const intentPath = path.join(this.runDir(threadId, runId), "recovery-intent.json");
|
|
351
|
+
if (!(await fileExists(intentPath))) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
await rm(intentPath, { force: true });
|
|
355
|
+
}
|
|
324
356
|
}
|
|
@@ -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;
|
|
@@ -27,6 +26,7 @@ export declare class AgentRuntimeAdapter {
|
|
|
27
26
|
private resolveModel;
|
|
28
27
|
private buildToolNameMapping;
|
|
29
28
|
private buildAgentMessages;
|
|
29
|
+
private buildInvocationRequest;
|
|
30
30
|
private buildRawModelMessages;
|
|
31
31
|
private resolveTools;
|
|
32
32
|
private normalizeInterruptPolicy;
|
|
@@ -40,7 +40,15 @@ export declare class AgentRuntimeAdapter {
|
|
|
40
40
|
route(input: MessageContent, primaryBinding: CompiledAgentBinding, secondaryBinding: CompiledAgentBinding, options?: {
|
|
41
41
|
systemPrompt?: string;
|
|
42
42
|
}): Promise<string>;
|
|
43
|
-
invoke(binding: CompiledAgentBinding, input: MessageContent, threadId: string, runId: string, resumePayload?: unknown, history?: TranscriptMessage[]
|
|
44
|
-
|
|
43
|
+
invoke(binding: CompiledAgentBinding, input: MessageContent, threadId: string, runId: string, resumePayload?: unknown, history?: TranscriptMessage[], options?: {
|
|
44
|
+
context?: Record<string, unknown>;
|
|
45
|
+
state?: Record<string, unknown>;
|
|
46
|
+
files?: Record<string, unknown>;
|
|
47
|
+
}): Promise<RunResult>;
|
|
48
|
+
stream(binding: CompiledAgentBinding, input: MessageContent, threadId: string, history?: TranscriptMessage[], options?: {
|
|
49
|
+
context?: Record<string, unknown>;
|
|
50
|
+
state?: Record<string, unknown>;
|
|
51
|
+
files?: Record<string, unknown>;
|
|
52
|
+
}): AsyncGenerator<RuntimeStreamChunk | string>;
|
|
45
53
|
}
|
|
46
54
|
export { AgentRuntimeAdapter as RuntimeAdapter, AGENT_INTERRUPT_SENTINEL_PREFIX, AGENT_INTERRUPT_SENTINEL_PREFIX as INTERRUPT_SENTINEL_PREFIX, RuntimeOperationTimeoutError, };
|