@botbotgo/agent-harness 0.0.56 → 0.0.58
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 +66 -1
- package/README.zh.md +574 -0
- package/dist/api.d.ts +7 -0
- package/dist/api.js +6 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/package-version.d.ts +1 -1
- package/dist/package-version.js +1 -1
- package/dist/resource/resource-impl.js +41 -9
- package/dist/runtime/agent-runtime-adapter.d.ts +8 -0
- package/dist/runtime/agent-runtime-adapter.js +116 -8
- package/dist/runtime/harness.d.ts +7 -0
- package/dist/runtime/harness.js +7 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/inventory.d.ts +10 -5
- package/dist/runtime/inventory.js +50 -12
- package/dist/runtime/skill-requirements.d.ts +27 -0
- package/dist/runtime/skill-requirements.js +112 -0
- package/dist/runtime/support/runtime-env.d.ts +2 -0
- package/dist/runtime/support/runtime-env.js +57 -0
- package/dist/runtime/support/skill-metadata.d.ts +14 -1
- package/dist/runtime/support/skill-metadata.js +59 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,15 +1,45 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="./docs/assets/readme-banner.png" alt="botbotgo runtime banner" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<strong>English</strong> · <a href="./README.zh.md">中文</a>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
1
9
|
# @botbotgo/agent-harness
|
|
2
10
|
|
|
11
|
+
<p align="center">
|
|
12
|
+
<strong>A workspace-shaped runtime for agent systems that need to keep running after the demo.</strong>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<a href="https://botbotgo.github.io/agent-harness/">Product website</a>
|
|
17
|
+
(static page in <code>docs/</code>, publish with GitHub Pages; EN / 中文 toggle)
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
<p align="center">
|
|
21
|
+
<em
|
|
22
|
+
>We specialize in AI solutions. If you have a product idea you want to ship,
|
|
23
|
+
<a href="mailto:info@easynet.world">info@easynet.world</a>.</em
|
|
24
|
+
>
|
|
25
|
+
</p>
|
|
26
|
+
|
|
3
27
|
## Product Overview
|
|
4
28
|
|
|
5
29
|
`@botbotgo/agent-harness` is a workspace-shaped application runtime for real agent products.
|
|
6
30
|
|
|
7
31
|
It is not a new agent framework. It is the runtime layer around LangChain v1 and DeepAgents that turns one workspace into one operable application runtime.
|
|
8
32
|
|
|
33
|
+
The point is simple:
|
|
34
|
+
|
|
35
|
+
- Codex, Claude Code, and Cursor are products for people using agents
|
|
36
|
+
- LangChain v1 and DeepAgents are frameworks for defining agent execution semantics
|
|
37
|
+
- `agent-harness` is the runtime product layer for shipping, operating, recovering, and governing multi-agent applications
|
|
38
|
+
|
|
9
39
|
The product boundary is strict:
|
|
10
40
|
|
|
11
41
|
- LangChain v1 and DeepAgents own agent execution semantics
|
|
12
|
-
-
|
|
42
|
+
- application-level orchestration and lifecycle management stays in the harness
|
|
13
43
|
|
|
14
44
|
That means:
|
|
15
45
|
|
|
@@ -39,6 +69,27 @@ Boundary documents live in:
|
|
|
39
69
|
- `docs/product-boundary.md`
|
|
40
70
|
- `docs/feature-checklist.md`
|
|
41
71
|
|
|
72
|
+
## Why This Exists
|
|
73
|
+
|
|
74
|
+
Most agent demos stop at execution.
|
|
75
|
+
|
|
76
|
+
Real products need a runtime that can answer harder questions:
|
|
77
|
+
|
|
78
|
+
- Where do runs live?
|
|
79
|
+
- How are approvals resolved?
|
|
80
|
+
- What survives process restart?
|
|
81
|
+
- How do you inspect threads and events without exposing raw backend state?
|
|
82
|
+
- How do you swap backend implementations without rewriting the product model?
|
|
83
|
+
|
|
84
|
+
`agent-harness` is the layer that answers those questions without turning your application API into a mirror of LangChain v1 or DeepAgents.
|
|
85
|
+
|
|
86
|
+
## What Makes It Different
|
|
87
|
+
|
|
88
|
+
- It treats `runs`, `threads`, `approvals`, `events`, and recovery as product concepts
|
|
89
|
+
- It keeps checkpoint resume system-managed instead of promoting checkpoint internals into the primary API
|
|
90
|
+
- It lets YAML own assembly complexity while code keeps a tiny surface
|
|
91
|
+
- It goes deep on runtime concerns that upstream libraries do not fully productize
|
|
92
|
+
|
|
42
93
|
## Quick Start
|
|
43
94
|
|
|
44
95
|
Install:
|
|
@@ -89,6 +140,13 @@ try {
|
|
|
89
140
|
}
|
|
90
141
|
```
|
|
91
142
|
|
|
143
|
+
If you want the shortest possible mental model:
|
|
144
|
+
|
|
145
|
+
- one workspace becomes one runtime
|
|
146
|
+
- YAML defines assembly and policy
|
|
147
|
+
- `run(runtime, { ... })` executes requests against that runtime
|
|
148
|
+
- the runtime owns lifecycle, inspection, and recovery
|
|
149
|
+
|
|
92
150
|
## Feature List
|
|
93
151
|
|
|
94
152
|
- Workspace runtime for multi-agent applications
|
|
@@ -103,6 +161,13 @@ try {
|
|
|
103
161
|
- MCP bridge support for agent-declared MCP servers
|
|
104
162
|
- MCP server support for exposing harness tools outward
|
|
105
163
|
|
|
164
|
+
### Runtime Strengths
|
|
165
|
+
|
|
166
|
+
- Stable product-facing API even when backend details evolve
|
|
167
|
+
- Strong separation between public runtime contract and backend adapter contract
|
|
168
|
+
- Clear YAML ownership for routing, topology, policy, and infrastructure objects
|
|
169
|
+
- Better fit for long-running, approval-heavy, multi-agent products than a thin agent loop wrapper
|
|
170
|
+
|
|
106
171
|
## How To Use
|
|
107
172
|
|
|
108
173
|
### Create A Runtime
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,574 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="./docs/assets/readme-banner.png" alt="botbotgo runtime banner" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="./README.md">English</a> · <strong>中文</strong>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
# @botbotgo/agent-harness
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<strong>面向「演示之后还要继续跑」的 agent 体系的工作区形态运行时。</strong>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<a href="https://botbotgo.github.io/agent-harness/">产品网站</a>
|
|
17
|
+
(<code>docs/</code> 中的静态页,通过 GitHub Pages 发布;支持中英文切换)
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
<p align="center">
|
|
21
|
+
<em
|
|
22
|
+
>我们专注于 AI 解决方案。若有希望落地的产品想法,欢迎来信
|
|
23
|
+
<a href="mailto:info@easynet.world">info@easynet.world</a>。</em
|
|
24
|
+
>
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
## 产品概览
|
|
28
|
+
|
|
29
|
+
`@botbotgo/agent-harness` 是面向真实 agent 产品的、工作区形态的应用运行时。
|
|
30
|
+
|
|
31
|
+
它不是又一个 agent 框架,而是围绕 LangChain v1 与 DeepAgents 的运行时层:把一个工作区变成一套可运维的应用运行时。
|
|
32
|
+
|
|
33
|
+
关系可以概括为:
|
|
34
|
+
|
|
35
|
+
- Codex、Claude Code、Cursor 是「人用 agent」的产品
|
|
36
|
+
- LangChain v1 与 DeepAgents 是定义 agent 执行语义的框架
|
|
37
|
+
- `agent-harness` 是交付、运维、恢复与治理多 agent 应用的运行时产品层
|
|
38
|
+
|
|
39
|
+
产品边界是清晰的:
|
|
40
|
+
|
|
41
|
+
- LangChain v1 与 DeepAgents 拥有 agent 执行语义
|
|
42
|
+
- 应用级编排与生命周期管理留在 harness 中
|
|
43
|
+
|
|
44
|
+
因此:
|
|
45
|
+
|
|
46
|
+
- 对外 API 保持精简
|
|
47
|
+
- 复杂装配与运行策略放在 YAML
|
|
48
|
+
- 后端实现可换时,运行时生命周期模型仍保持稳定
|
|
49
|
+
- 后端细节藏在适配器之后
|
|
50
|
+
|
|
51
|
+
运行时提供:
|
|
52
|
+
|
|
53
|
+
- `createAgentHarness(workspaceRoot)`、`run(...)`、`resolveApproval(...)`、`subscribe(...)`、各类查询方法,以及 `stop(...)`
|
|
54
|
+
- 以 YAML 描述的工作区装配:路由、模型、工具、存储、后端、MCP、恢复与维护等
|
|
55
|
+
- 通过适配器对接当前的 LangChain v1 与 DeepAgents 执行
|
|
56
|
+
- 本地 `resources/tools/` 与 `resources/skills/` 的发现
|
|
57
|
+
- 持久化的线程、运行、审批、事件、队列状态与恢复元数据
|
|
58
|
+
|
|
59
|
+
仓库自带的默认配置刻意做成「形状完整」。随仓库提供的 YAML 对重要的运行时与 agent 开关给出显式默认值,便于从具体配置起步,而不必从源码反推适配器行为。
|
|
60
|
+
|
|
61
|
+
默认原则是:
|
|
62
|
+
|
|
63
|
+
- 若 LangChain v1 或 DeepAgents 已有能力,则在 YAML 中映射并在内部适配
|
|
64
|
+
- 除非问题确实属于运行时职责,否则不增加新的公共运行时 API
|
|
65
|
+
|
|
66
|
+
边界说明见:
|
|
67
|
+
|
|
68
|
+
- `docs/upstream-feature-matrix.md`
|
|
69
|
+
- `docs/product-boundary.md`
|
|
70
|
+
- `docs/feature-checklist.md`
|
|
71
|
+
|
|
72
|
+
## 为何需要它
|
|
73
|
+
|
|
74
|
+
多数 agent 演示停在「能跑」。
|
|
75
|
+
|
|
76
|
+
真实产品需要能回答更难问题的运行时:
|
|
77
|
+
|
|
78
|
+
- 运行(runs)存在哪里?
|
|
79
|
+
- 审批如何闭环?
|
|
80
|
+
- 进程重启后什么还在?
|
|
81
|
+
- 如何在不暴露原始后端状态的前提下检查线程与事件?
|
|
82
|
+
- 如何在不大改产品模型的前提下替换后端实现?
|
|
83
|
+
|
|
84
|
+
`agent-harness` 在不把应用 API 变成 LangChain v1 / DeepAgents 翻版的前提下,回答这些问题。
|
|
85
|
+
|
|
86
|
+
## 有何不同
|
|
87
|
+
|
|
88
|
+
- 将 `runs`、`threads`、`approvals`、`events` 与恢复视为产品概念
|
|
89
|
+
- 将 checkpoint 恢复作为系统管理的行为,而不是把 checkpoint 细节抬成主 API
|
|
90
|
+
- 复杂装配交给 YAML,代码面保持极小
|
|
91
|
+
- 在上游库未充分产品化的运行时时,做深做透
|
|
92
|
+
|
|
93
|
+
## 快速开始
|
|
94
|
+
|
|
95
|
+
安装:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
npm install @botbotgo/agent-harness
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
工作区布局:
|
|
102
|
+
|
|
103
|
+
```text
|
|
104
|
+
your-workspace/
|
|
105
|
+
config/
|
|
106
|
+
workspace.yaml
|
|
107
|
+
agent-context.md
|
|
108
|
+
models.yaml
|
|
109
|
+
embedding-models.yaml
|
|
110
|
+
vector-stores.yaml
|
|
111
|
+
stores.yaml
|
|
112
|
+
backends.yaml
|
|
113
|
+
tools.yaml
|
|
114
|
+
mcp.yaml
|
|
115
|
+
agents/
|
|
116
|
+
direct.yaml
|
|
117
|
+
orchestra.yaml
|
|
118
|
+
resources/
|
|
119
|
+
package.json
|
|
120
|
+
tools/
|
|
121
|
+
skills/
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
最小用法:
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
import { createAgentHarness, run, stop } from "@botbotgo/agent-harness";
|
|
128
|
+
|
|
129
|
+
const runtime = await createAgentHarness("/absolute/path/to/workspace");
|
|
130
|
+
|
|
131
|
+
try {
|
|
132
|
+
const result = await run(runtime, {
|
|
133
|
+
agentId: "auto",
|
|
134
|
+
input: "Explain what this workspace is for.",
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
console.log(result.output);
|
|
138
|
+
} finally {
|
|
139
|
+
await stop(runtime);
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
最短心智模型:
|
|
144
|
+
|
|
145
|
+
- 一个工作区对应一个运行时
|
|
146
|
+
- YAML 定义装配与策略
|
|
147
|
+
- `run(runtime, { ... })` 在该运行时上执行请求
|
|
148
|
+
- 运行时负责生命周期、可观测性与恢复
|
|
149
|
+
|
|
150
|
+
## 功能列表
|
|
151
|
+
|
|
152
|
+
- 多 agent 应用的工作区运行时
|
|
153
|
+
- 精简的公共运行时契约
|
|
154
|
+
- YAML 定义的主机路由与运行时策略
|
|
155
|
+
- LangChain v1 与 DeepAgents 后端适配
|
|
156
|
+
- 自动发现本地工具与 SKILL 包
|
|
157
|
+
- 原生 provider 工具、MCP 工具与工作区本地工具模块
|
|
158
|
+
- 持久化线程、运行、审批、生命周期事件与排队运行
|
|
159
|
+
- 运行时管理的恢复与 checkpoint 维护
|
|
160
|
+
- 运行结果中的结构化输出与多模态内容保留
|
|
161
|
+
- 将 agent 声明的 MCP 服务桥接进来
|
|
162
|
+
- 将 harness 工具对外暴露为 MCP 服务
|
|
163
|
+
|
|
164
|
+
### 运行时优势
|
|
165
|
+
|
|
166
|
+
- 后端细节演进时,面向产品的 API 仍可保持稳定
|
|
167
|
+
- 公共运行时契约与后端适配契约分离清晰
|
|
168
|
+
- 路由、拓扑、策略与基础设施对象由 YAML 明确拥有
|
|
169
|
+
- 相较薄封装 agent 循环,更适合长运行、重审批、多 agent 产品
|
|
170
|
+
|
|
171
|
+
## 使用方式
|
|
172
|
+
|
|
173
|
+
### 创建运行时
|
|
174
|
+
|
|
175
|
+
```ts
|
|
176
|
+
import { AgentHarnessRuntime, createAgentHarness } from "@botbotgo/agent-harness";
|
|
177
|
+
|
|
178
|
+
const runtime: AgentHarnessRuntime = await createAgentHarness("/absolute/path/to/workspace");
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
`createAgentHarness(...)` 会加载工作区、解析 `resources/`、在 `runRoot` 下初始化持久化,并启动运行时维护任务。
|
|
182
|
+
|
|
183
|
+
### 发起一次运行
|
|
184
|
+
|
|
185
|
+
```ts
|
|
186
|
+
import { run } from "@botbotgo/agent-harness";
|
|
187
|
+
|
|
188
|
+
const result = await run(runtime, {
|
|
189
|
+
agentId: "orchestra",
|
|
190
|
+
input: "Summarize the runtime design.",
|
|
191
|
+
invocation: {
|
|
192
|
+
context: {
|
|
193
|
+
requestId: "req-123",
|
|
194
|
+
},
|
|
195
|
+
inputs: {
|
|
196
|
+
visitCount: 1,
|
|
197
|
+
},
|
|
198
|
+
attachments: {
|
|
199
|
+
"/tmp/spec.md": { content: "draft" },
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
`run(runtime, { ... })` 会创建或延续持久化线程,并返回 `threadId`、`runId`、`state` 以及紧凑文本 `output`。更丰富的上游结果形态仍可通过 `outputContent`、`contentBlocks`、`structuredResponse` 等获得。
|
|
206
|
+
|
|
207
|
+
将 `invocation` 作为面向运行时的请求信封:
|
|
208
|
+
|
|
209
|
+
- `invocation.context`:请求级执行上下文
|
|
210
|
+
- `invocation.inputs`:结构化运行时输入
|
|
211
|
+
- `invocation.attachments`:当前后端可解释的类附件负载
|
|
212
|
+
|
|
213
|
+
### 由运行时路由
|
|
214
|
+
|
|
215
|
+
```ts
|
|
216
|
+
const result = await run(runtime, {
|
|
217
|
+
agentId: "auto",
|
|
218
|
+
input: "Inspect the repository and explain the release flow.",
|
|
219
|
+
});
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
`agentId: "auto"` 会按顺序评估 `config/workspace.yaml` 中的路由规则,再使用 `routing.defaultAgentId`,且仅当 `routing.modelRouting: true` 时才回退到模型路由。
|
|
223
|
+
|
|
224
|
+
### 流式输出与事件
|
|
225
|
+
|
|
226
|
+
```ts
|
|
227
|
+
const result = await run(runtime, {
|
|
228
|
+
agentId: "orchestra",
|
|
229
|
+
input: "Inspect the workspace and explain the available tools.",
|
|
230
|
+
listeners: {
|
|
231
|
+
onChunk(chunk) {
|
|
232
|
+
process.stdout.write(chunk);
|
|
233
|
+
},
|
|
234
|
+
onContentBlocks(blocks) {
|
|
235
|
+
console.log(blocks);
|
|
236
|
+
},
|
|
237
|
+
onEvent(event) {
|
|
238
|
+
console.log(event.eventType, event.payload);
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
`subscribe(...)` 是对已存储生命周期事件的只读观察者接口。
|
|
245
|
+
|
|
246
|
+
运行时事件流包括:
|
|
247
|
+
|
|
248
|
+
- `run.created`
|
|
249
|
+
- `run.queued`
|
|
250
|
+
- `run.dequeued`
|
|
251
|
+
- `run.state.changed`
|
|
252
|
+
- `approval.requested`
|
|
253
|
+
- `approval.resolved`
|
|
254
|
+
- `output.delta`
|
|
255
|
+
|
|
256
|
+
### 检查线程与审批
|
|
257
|
+
|
|
258
|
+
```ts
|
|
259
|
+
import {
|
|
260
|
+
getApproval,
|
|
261
|
+
getThread,
|
|
262
|
+
listApprovals,
|
|
263
|
+
listThreads,
|
|
264
|
+
resolveApproval,
|
|
265
|
+
} from "@botbotgo/agent-harness";
|
|
266
|
+
|
|
267
|
+
const threads = await listThreads(runtime);
|
|
268
|
+
const thread = await getThread(runtime, threads[0]!.threadId);
|
|
269
|
+
const approvals = await listApprovals(runtime, { status: "pending" });
|
|
270
|
+
const approval = approvals[0] ? await getApproval(runtime, approvals[0].approvalId) : null;
|
|
271
|
+
|
|
272
|
+
if (approval) {
|
|
273
|
+
await resolveApproval(runtime, {
|
|
274
|
+
approvalId: approval.approvalId,
|
|
275
|
+
decision: "approve",
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
这些方法返回面向运行时的记录,而非原始 checkpoint 或后端对象。
|
|
281
|
+
|
|
282
|
+
### 接入与暴露 MCP
|
|
283
|
+
|
|
284
|
+
将 MCP 服务桥接到 agent:
|
|
285
|
+
|
|
286
|
+
```yaml
|
|
287
|
+
apiVersion: agent-harness/v1alpha1
|
|
288
|
+
kind: Agent
|
|
289
|
+
metadata:
|
|
290
|
+
name: orchestra
|
|
291
|
+
spec:
|
|
292
|
+
execution:
|
|
293
|
+
backend: deepagent
|
|
294
|
+
modelRef: model/default
|
|
295
|
+
mcpServers:
|
|
296
|
+
- name: browser
|
|
297
|
+
command: node
|
|
298
|
+
args: ["./mcp-browser-server.mjs"]
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
将 harness 工具作为 MCP 服务对外暴露:
|
|
302
|
+
|
|
303
|
+
```ts
|
|
304
|
+
import { createToolMcpServer, serveToolsOverStdio } from "@botbotgo/agent-harness";
|
|
305
|
+
|
|
306
|
+
const server = await createToolMcpServer(runtime, { agentId: "orchestra" });
|
|
307
|
+
await serveToolsOverStdio(runtime, { agentId: "orchestra" });
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### 停止运行时
|
|
311
|
+
|
|
312
|
+
```ts
|
|
313
|
+
import { stop } from "@botbotgo/agent-harness";
|
|
314
|
+
|
|
315
|
+
await stop(runtime);
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
## 如何配置
|
|
319
|
+
|
|
320
|
+
使用 Kubernetes 风格的 YAML:
|
|
321
|
+
|
|
322
|
+
- 集合类文件使用 `apiVersion`、复数 `kind` 与 `spec: []`
|
|
323
|
+
- 单例文件使用 `apiVersion`、单数 `kind`、`metadata` 与 `spec`
|
|
324
|
+
|
|
325
|
+
核心工作区文件:
|
|
326
|
+
|
|
327
|
+
- `config/workspace.yaml`
|
|
328
|
+
- `config/agent-context.md`
|
|
329
|
+
- `config/models.yaml`
|
|
330
|
+
- `config/embedding-models.yaml`
|
|
331
|
+
- `config/vector-stores.yaml`
|
|
332
|
+
- `config/stores.yaml`
|
|
333
|
+
- `config/backends.yaml`
|
|
334
|
+
- `config/tools.yaml`
|
|
335
|
+
- `config/mcp.yaml`
|
|
336
|
+
- `config/agents/direct.yaml`
|
|
337
|
+
- `config/agents/orchestra.yaml`
|
|
338
|
+
- `resources/tools/`
|
|
339
|
+
- `resources/skills/`
|
|
340
|
+
|
|
341
|
+
主要有三层配置:
|
|
342
|
+
|
|
343
|
+
- `config/workspace.yaml` 中的运行时策略
|
|
344
|
+
- `config/*.yaml` 中的可复用对象目录
|
|
345
|
+
- `config/agents/*.yaml` 中的 agent 装配
|
|
346
|
+
|
|
347
|
+
### `config/workspace.yaml`
|
|
348
|
+
|
|
349
|
+
用于工作区范围的运行时策略。
|
|
350
|
+
|
|
351
|
+
重要字段:
|
|
352
|
+
|
|
353
|
+
- `runRoot`
|
|
354
|
+
- `concurrency.maxConcurrentRuns`
|
|
355
|
+
- `routing.defaultAgentId`
|
|
356
|
+
- `routing.rules`
|
|
357
|
+
- `routing.systemPrompt`
|
|
358
|
+
- `routing.modelRouting`
|
|
359
|
+
- `maintenance.checkpoints`
|
|
360
|
+
- `recovery.enabled`
|
|
361
|
+
- `recovery.resumeResumingRunsOnStartup`
|
|
362
|
+
- `recovery.maxRecoveryAttempts`
|
|
363
|
+
|
|
364
|
+
`recovery.resumeResumingRunsOnStartup` 将 checkpoint 恢复保持为运行时拥有的生命周期行为,而不是把 checkpoint 编排暴露为主 API。
|
|
365
|
+
|
|
366
|
+
示例:
|
|
367
|
+
|
|
368
|
+
```yaml
|
|
369
|
+
apiVersion: agent-harness/v1alpha1
|
|
370
|
+
kind: Runtime
|
|
371
|
+
metadata:
|
|
372
|
+
name: default
|
|
373
|
+
spec:
|
|
374
|
+
runRoot: ./.agent
|
|
375
|
+
concurrency:
|
|
376
|
+
maxConcurrentRuns: 3
|
|
377
|
+
routing:
|
|
378
|
+
defaultAgentId: orchestra
|
|
379
|
+
modelRouting: false
|
|
380
|
+
maintenance:
|
|
381
|
+
checkpoints:
|
|
382
|
+
enabled: true
|
|
383
|
+
recovery:
|
|
384
|
+
enabled: true
|
|
385
|
+
resumeResumingRunsOnStartup: true
|
|
386
|
+
maxRecoveryAttempts: 3
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### `config/agent-context.md`
|
|
390
|
+
|
|
391
|
+
用于在构建 agent 时加载的共享启动记忆。
|
|
392
|
+
|
|
393
|
+
在此放置稳定的项目上下文;视为启动上下文,而非可变长期记忆。
|
|
394
|
+
|
|
395
|
+
### `config/models.yaml`
|
|
396
|
+
|
|
397
|
+
命名聊天模型预设:
|
|
398
|
+
|
|
399
|
+
```yaml
|
|
400
|
+
apiVersion: agent-harness/v1alpha1
|
|
401
|
+
kind: Models
|
|
402
|
+
spec:
|
|
403
|
+
- name: default
|
|
404
|
+
provider: openai
|
|
405
|
+
model: gpt-4.1
|
|
406
|
+
temperature: 0.2
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
加载为 `model/default`。
|
|
410
|
+
|
|
411
|
+
### `config/embedding-models.yaml`
|
|
412
|
+
|
|
413
|
+
面向检索类工具的命名嵌入模型预设。
|
|
414
|
+
|
|
415
|
+
### `config/vector-stores.yaml`
|
|
416
|
+
|
|
417
|
+
检索工具引用的命名向量库预设。
|
|
418
|
+
|
|
419
|
+
### `config/stores.yaml`
|
|
420
|
+
|
|
421
|
+
可复用的存储与 checkpointer 预设:
|
|
422
|
+
|
|
423
|
+
```yaml
|
|
424
|
+
apiVersion: agent-harness/v1alpha1
|
|
425
|
+
kind: Stores
|
|
426
|
+
spec:
|
|
427
|
+
- kind: Store
|
|
428
|
+
name: default
|
|
429
|
+
storeKind: FileStore
|
|
430
|
+
path: store.json
|
|
431
|
+
- kind: Checkpointer
|
|
432
|
+
name: default
|
|
433
|
+
checkpointerKind: MemorySaver
|
|
434
|
+
- kind: Checkpointer
|
|
435
|
+
name: sqlite
|
|
436
|
+
checkpointerKind: SqliteSaver
|
|
437
|
+
path: checkpoints.sqlite
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
### `config/backends.yaml`
|
|
441
|
+
|
|
442
|
+
可复用的 DeepAgents 后端预设,使文件系统与 `/memories/*` 拓扑保留在 YAML 中:
|
|
443
|
+
|
|
444
|
+
```yaml
|
|
445
|
+
apiVersion: agent-harness/v1alpha1
|
|
446
|
+
kind: Backends
|
|
447
|
+
spec:
|
|
448
|
+
- kind: Backend
|
|
449
|
+
name: default
|
|
450
|
+
backendKind: CompositeBackend
|
|
451
|
+
state:
|
|
452
|
+
kind: VfsSandbox
|
|
453
|
+
rootDir: .
|
|
454
|
+
virtualMode: true
|
|
455
|
+
timeout: 600
|
|
456
|
+
routes:
|
|
457
|
+
/memories/:
|
|
458
|
+
kind: StoreBackend
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
### `config/tools.yaml`
|
|
462
|
+
|
|
463
|
+
可复用工具对象。
|
|
464
|
+
|
|
465
|
+
内置工具族包括函数工具、后端工具、MCP 工具、bundle 与原生 provider 工具。原生 provider 工具在 YAML 中声明并直接解析到上游工厂。
|
|
466
|
+
|
|
467
|
+
### `config/mcp.yaml`
|
|
468
|
+
|
|
469
|
+
命名 MCP 服务预设。
|
|
470
|
+
|
|
471
|
+
### `config/agents/*.yaml`
|
|
472
|
+
|
|
473
|
+
Agent 始终使用 `kind: Agent` 以及 `spec.execution.backend`。
|
|
474
|
+
|
|
475
|
+
两个嵌套区块:
|
|
476
|
+
|
|
477
|
+
- `spec.runtime`:harness 侧运行时放置,例如 `spec.runtime.runRoot`
|
|
478
|
+
- `spec.execution`:上游执行语义与面向适配器的配置
|
|
479
|
+
|
|
480
|
+
direct 主机示例:
|
|
481
|
+
|
|
482
|
+
```yaml
|
|
483
|
+
apiVersion: agent-harness/v1alpha1
|
|
484
|
+
kind: Agent
|
|
485
|
+
metadata:
|
|
486
|
+
name: direct
|
|
487
|
+
spec:
|
|
488
|
+
runtime:
|
|
489
|
+
runRoot: ./.agent
|
|
490
|
+
execution:
|
|
491
|
+
backend: langchain-v1
|
|
492
|
+
modelRef: model/default
|
|
493
|
+
tools: []
|
|
494
|
+
skills: []
|
|
495
|
+
memory: []
|
|
496
|
+
subagents: []
|
|
497
|
+
mcpServers: []
|
|
498
|
+
config:
|
|
499
|
+
checkpointer:
|
|
500
|
+
ref: checkpointer/default
|
|
501
|
+
store:
|
|
502
|
+
ref: store/default
|
|
503
|
+
interruptOn: {}
|
|
504
|
+
filesystem:
|
|
505
|
+
rootDir: .
|
|
506
|
+
virtualMode: true
|
|
507
|
+
maxFileSizeMb: 10
|
|
508
|
+
middleware: []
|
|
509
|
+
systemPrompt: Answer simple requests directly.
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
orchestra 主机示例:
|
|
513
|
+
|
|
514
|
+
```yaml
|
|
515
|
+
apiVersion: agent-harness/v1alpha1
|
|
516
|
+
kind: Agent
|
|
517
|
+
metadata:
|
|
518
|
+
name: orchestra
|
|
519
|
+
spec:
|
|
520
|
+
runtime:
|
|
521
|
+
runRoot: ./.agent
|
|
522
|
+
execution:
|
|
523
|
+
backend: deepagent
|
|
524
|
+
modelRef: model/default
|
|
525
|
+
memory:
|
|
526
|
+
- path: config/agent-context.md
|
|
527
|
+
tools: []
|
|
528
|
+
skills: []
|
|
529
|
+
subagents: []
|
|
530
|
+
mcpServers: []
|
|
531
|
+
config:
|
|
532
|
+
store:
|
|
533
|
+
ref: store/default
|
|
534
|
+
checkpointer:
|
|
535
|
+
ref: checkpointer/default
|
|
536
|
+
backend:
|
|
537
|
+
ref: backend/default
|
|
538
|
+
interruptOn: {}
|
|
539
|
+
middleware: []
|
|
540
|
+
generalPurposeAgent: true
|
|
541
|
+
taskDescription: Complete delegated sidecar work and return concise results without bloating the parent context.
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
后端相关选项优先直接写在 `spec.execution.config` 中沿用上游概念。上游能力覆盖见 [docs/upstream-feature-matrix.md](docs/upstream-feature-matrix.md)。
|
|
545
|
+
|
|
546
|
+
## 设计说明
|
|
547
|
+
|
|
548
|
+
- `agent-harness` 不是第三个 agent 框架
|
|
549
|
+
- 公共运行时契约保持通用且精简
|
|
550
|
+
- 应用级编排与生命周期管理留在 harness 中
|
|
551
|
+
- 应尽量在 YAML 中直接表达 LangChain v1 与 DeepAgents 的概念
|
|
552
|
+
- 能用 YAML 表达的能力,优先 YAML 而非扩张公共 API
|
|
553
|
+
- 恢复、审批、线程、运行与事件是运行时概念,不是后端逃生舱
|
|
554
|
+
- 新的 LangChain v1 或 DeepAgents 配置应先落在 YAML 映射与测试中,再考虑公共运行时 API
|
|
555
|
+
|
|
556
|
+
简言之:产品模型稳定,执行语义仍归上游。
|
|
557
|
+
|
|
558
|
+
## API 摘要
|
|
559
|
+
|
|
560
|
+
主要导出:
|
|
561
|
+
|
|
562
|
+
- `createAgentHarness`
|
|
563
|
+
- `AgentHarnessRuntime`
|
|
564
|
+
- `run`
|
|
565
|
+
- `resolveApproval`
|
|
566
|
+
- `subscribe`
|
|
567
|
+
- `listThreads`
|
|
568
|
+
- `getThread`
|
|
569
|
+
- `deleteThread`
|
|
570
|
+
- `listApprovals`
|
|
571
|
+
- `getApproval`
|
|
572
|
+
- `createToolMcpServer`
|
|
573
|
+
- `serveToolsOverStdio`
|
|
574
|
+
- `stop`
|
package/dist/api.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ApprovalRecord, RunOptions, ResumeOptions, RuntimeAdapterOptions, ThreadSummary, ThreadRecord, WorkspaceLoadOptions } from "./contracts/types.js";
|
|
2
2
|
import { AgentHarnessRuntime } from "./runtime/harness.js";
|
|
3
|
+
import type { InventoryAgentRecord, InventorySkillRecord } from "./runtime/inventory.js";
|
|
4
|
+
import type { RequirementAssessmentOptions } from "./runtime/skill-requirements.js";
|
|
3
5
|
import type { ToolMcpServerOptions } from "./mcp.js";
|
|
4
6
|
export { AgentHarnessRuntime } from "./runtime/harness.js";
|
|
5
7
|
type CreateAgentHarnessOptions = {
|
|
@@ -15,6 +17,11 @@ export declare function getThread(runtime: AgentHarnessRuntime, threadId: string
|
|
|
15
17
|
export declare function deleteThread(runtime: AgentHarnessRuntime, threadId: string): Promise<boolean>;
|
|
16
18
|
export declare function listApprovals(runtime: AgentHarnessRuntime, filter?: Parameters<AgentHarnessRuntime["listApprovals"]>[0]): Promise<ApprovalRecord[]>;
|
|
17
19
|
export declare function getApproval(runtime: AgentHarnessRuntime, approvalId: string): Promise<ApprovalRecord | null>;
|
|
20
|
+
export declare function listAgentSkills(runtime: AgentHarnessRuntime, agentId: string, options?: RequirementAssessmentOptions): InventorySkillRecord[];
|
|
21
|
+
export declare function describeInventory(runtime: AgentHarnessRuntime, options?: RequirementAssessmentOptions): {
|
|
22
|
+
workspaceRoot: string;
|
|
23
|
+
agents: InventoryAgentRecord[];
|
|
24
|
+
};
|
|
18
25
|
export declare function resolveApproval(runtime: AgentHarnessRuntime, options: ResumeOptions): Promise<import("./contracts/types.js").RunResult>;
|
|
19
26
|
export declare function stop(runtime: AgentHarnessRuntime): Promise<void>;
|
|
20
27
|
export declare function createToolMcpServer(runtime: AgentHarnessRuntime, options: ToolMcpServerOptions): Promise<import("@modelcontextprotocol/sdk/server/mcp.js").McpServer>;
|
package/dist/api.js
CHANGED
|
@@ -28,6 +28,12 @@ export async function listApprovals(runtime, filter) {
|
|
|
28
28
|
export async function getApproval(runtime, approvalId) {
|
|
29
29
|
return runtime.getApproval(approvalId);
|
|
30
30
|
}
|
|
31
|
+
export function listAgentSkills(runtime, agentId, options) {
|
|
32
|
+
return runtime.listAgentSkills(agentId, options);
|
|
33
|
+
}
|
|
34
|
+
export function describeInventory(runtime, options) {
|
|
35
|
+
return runtime.describeWorkspaceInventory(options);
|
|
36
|
+
}
|
|
31
37
|
export async function resolveApproval(runtime, options) {
|
|
32
38
|
return runtime.resume(options);
|
|
33
39
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { AgentHarnessRuntime, createAgentHarness, createToolMcpServer, deleteThread, getApproval, getThread, listApprovals, listThreads, resolveApproval, run, serveToolsOverStdio, subscribe, stop, } from "./api.js";
|
|
1
|
+
export { AgentHarnessRuntime, createAgentHarness, createToolMcpServer, deleteThread, describeInventory, getApproval, getThread, listAgentSkills, listApprovals, listThreads, resolveApproval, run, serveToolsOverStdio, subscribe, stop, } from "./api.js";
|
|
2
2
|
export type { ToolMcpServerOptions } from "./mcp.js";
|
|
3
3
|
export { tool } from "./tools.js";
|