@botbotgo/agent-harness 0.0.183 → 0.0.185

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 CHANGED
@@ -42,10 +42,21 @@
42
42
 
43
43
  **At a glance:** the onboarding path stays thin, the runtime capabilities ship as a complete layer, and most ongoing work moves into **YAML configuration** plus **extensions** (local tools, SKILL packages, MCP) instead of bespoke runtime infrastructure.
44
44
 
45
- - **Easy to start:** `createAgentHarness` → `run` → `stop`, plus inspection helpers such as `subscribe`, `listSessions`, `listApprovals`, and `resolveApproval`.
45
+ - **Easy to start:** `createAgentHarness` → `request` → `stop`, plus inspection helpers such as `subscribe`, `listSessions`, `listApprovals`, and `resolveApproval`.
46
46
  - **Configure:** routing, models, tools, stores, backends, MCP, recovery, and maintenance in declarative workspace YAML (see [Quick Start](#quick-start) and [How To Configure](#how-to-configure)).
47
47
  - **Extend:** drop `tool({...})` modules and SKILL trees under `resources/`, wire shared tools and MCP in catalogs, and let agents whitelist what they use.
48
- - **Built into the runtime:** persisted `runs`, `threads`, `approvals`, and `events`; recovery and queueing; streaming listeners; MCP in/out; LangChain v1 and DeepAgents adapters—so you do not rebuild that layer per app.
48
+ - **Built into the runtime:** persisted `requests`, `sessions`, `approvals`, and `events`; recovery and queueing; streaming listeners; MCP in/out; LangChain v1 and DeepAgents adapters—so you do not rebuild that layer per app.
49
+
50
+ ## Current Public Surface
51
+
52
+ The repository now ships more than a thin runtime bootstrap. The public surface is already broad enough that the homepage and docs need to describe it as a product runtime with external protocol boundaries, not only as YAML plus tools.
53
+
54
+ - **Core runtime API:** `createAgentHarness`, `request`, `subscribe`, `resolveApproval`, inspection helpers, and stable persisted runtime records for `requests`, `sessions`, `approvals`, `events`, and artifacts.
55
+ - **Runtime memory and evidence:** `memorize`, `recall`, `listMemories`, memory policy hooks, `listArtifacts`, `getArtifact`, `exportEvaluationBundle`, `replayEvaluationBundle`, and request/session evidence export helpers.
56
+ - **Protocol and transport surfaces:** `createAcpServer`, `serveAcpStdio`, `serveAcpHttp`, `serveA2aHttp`, `serveAgUiHttp`, and `createRuntimeMcpServer` / `serveRuntimeMcpOverStdio`.
57
+ - **Governed workspace runtime:** YAML-owned routing, concurrency, maintenance, MCP policy, runtime governance bundles, and approval defaults for sensitive memory or write-like MCP side effects.
58
+
59
+ `deepagents-acp` is part of the current public story, not only a direction hidden in planning notes: `agent-harness` is moving toward a standard runtime boundary that external clients can talk to directly while the harness keeps persistence, recovery, approvals, and operator control runtime-owned.
49
60
 
50
61
  ## What Problem We Solve
51
62
 
@@ -55,7 +66,7 @@ If your team already has agents, prompts, tools, and workflows, the missing laye
55
66
 
56
67
  What you get on day one:
57
68
 
58
- - a runtime that keeps `runs`, `threads`, `approvals`, and `events` as inspectable product records
69
+ - a runtime that keeps `requests`, `sessions`, `approvals`, and `events` as inspectable product records
59
70
  - a recovery path that survives interruption, restart, and operator decisions
60
71
  - stable run correlation and continuity metadata so operators can join one persisted run to logs, traces, and fallback transitions
61
72
  - approval defaults for sensitive durable memory writes and write-like MCP calls instead of relying on each tool definition to remember governance
@@ -74,7 +85,7 @@ Once the demo works, the real software problem changes shape:
74
85
  Teams still need clear answers to the runtime questions that appear after that shift:
75
86
 
76
87
  - how approvals are resolved and audited
77
- - how runs, threads, and events stay inspectable
88
+ - how requests, sessions, and events stay inspectable
78
89
  - how execution recovers after interruption, failure, or restart
79
90
  - how routing, concurrency, and maintenance policy stay consistent
80
91
  - how backend churn does not leak into the product model
@@ -84,13 +95,13 @@ Teams still need clear answers to the runtime questions that appear after that s
84
95
  That makes the product story easier to explain:
85
96
 
86
97
  - you bring the workspace, agents, tools, and prompts
87
- - `agent-harness` brings persisted `runs`, `threads`, `approvals`, `events`, recovery, and operator visibility
98
+ - `agent-harness` brings persisted `requests`, `sessions`, `approvals`, `events`, recovery, and operator visibility
88
99
  - your application gets one stable runtime contract instead of backend-specific runtime plumbing
89
100
 
90
101
  In concrete terms:
91
102
 
92
103
  - a product-facing approval and operator surface instead of backend-specific middleware state
93
- - persisted `runs`, `threads`, `approvals`, and `events` as stable runtime records
104
+ - persisted `requests`, `sessions`, `approvals`, and `events` as stable runtime records
94
105
  - runtime-owned inspection fields such as tracing correlation ids and continuity metadata instead of provider-private observability handles
95
106
  - restart-safe recovery and continuation as system-managed behavior
96
107
  - default runtime governance for high-risk memory and MCP side effects
@@ -123,17 +134,17 @@ That means:
123
134
 
124
135
  The runtime provides:
125
136
 
126
- - `createAgentHarness(workspaceRoot)`, `run(...)`, `memorize(...)`, `recall(...)`, `listMemories(...)`, `updateMemory(...)`, `removeMemory(...)`, `resolveApproval(...)`, `subscribe(...)`, inspection methods, and `stop(...)`
137
+ - `createAgentHarness(workspaceRoot)`, `request(...)`, `memorize(...)`, `recall(...)`, `listMemories(...)`, `updateMemory(...)`, `removeMemory(...)`, `resolveApproval(...)`, `subscribe(...)`, inspection methods, and `stop(...)`
127
138
  - YAML-defined workspace assembly for routing, models, tools, stores, backends, MCP, recovery, and maintenance
128
139
  - backend-adapted execution with current LangChain v1 and DeepAgents adapters
129
140
  - local `resources/tools/` `tool({...})` modules and `resources/skills/` discovery
130
- - persisted threads, runs, approvals, events, queue state, and recovery metadata
141
+ - persisted sessions, requests, approvals, events, queue state, and recovery metadata
131
142
 
132
143
  In practice, the harness exists for the parts that are expensive and repetitive to rebuild inside every agent app:
133
144
 
134
145
  - approval inboxes and human decision flow
135
- - persisted runs, threads, and inspectable event history
136
- - run correlation, continuity, and recovery inspection that still works after a stream fallback or restart
146
+ - persisted requests, sessions, and inspectable event history
147
+ - request correlation, continuity, and recovery inspection that still works after a stream fallback or restart
137
148
  - runtime-managed recovery after interrupts, failures, or process restart
138
149
  - queueing, concurrency, maintenance, and operational policy
139
150
  - stable runtime records that stay usable even if the backend changes
@@ -189,17 +200,17 @@ Most agent tooling stops at execution. Production software does not.
189
200
 
190
201
  Real products need a runtime that can answer harder questions:
191
202
 
192
- - Where do runs live?
203
+ - Where do requests live?
193
204
  - How are approvals resolved?
194
205
  - What survives process restart?
195
- - How do you inspect threads and events without exposing raw backend state?
206
+ - How do you inspect sessions and events without exposing raw backend state?
196
207
  - How do you swap backend implementations without rewriting the product model?
197
208
 
198
209
  `agent-harness` is the layer that answers those questions without turning your application API into a mirror of LangChain v1 or DeepAgents.
199
210
 
200
211
  ## What Makes It Different
201
212
 
202
- - It treats `runs`, `threads`, `approvals`, `events`, and recovery as first-class product records
213
+ - It treats `requests`, `sessions`, `approvals`, `events`, and recovery as first-class product records
203
214
  - It gives operators a runtime control surface instead of exposing raw backend internals
204
215
  - It keeps observability and governance runtime-owned with trace correlation, continuity metadata, and approval defaults for sensitive side effects
205
216
  - It keeps checkpoint resume system-managed instead of promoting checkpoint internals into the primary API
@@ -211,7 +222,7 @@ Real products need a runtime that can answer harder questions:
211
222
  Use `agent-harness` when:
212
223
 
213
224
  - you already know your product needs agents, tools, prompts, or MCP access, but the missing layer is runtime operations
214
- - you need approvals, restart recovery, queueing, or inspectable run records as part of the shipped product
225
+ - you need approvals, restart recovery, queueing, or inspectable request records as part of the shipped product
215
226
  - you want one workspace-shaped assembly model instead of hand-written runtime bootstrapping in every app
216
227
  - you want to keep backend execution semantics upstream while holding the product contract stable
217
228
 
@@ -258,12 +269,12 @@ your-workspace/
258
269
  Minimal usage:
259
270
 
260
271
  ```ts
261
- import { createAgentHarness, run, stop } from "@botbotgo/agent-harness";
272
+ import { createAgentHarness, request, stop } from "@botbotgo/agent-harness";
262
273
 
263
274
  const runtime = await createAgentHarness("/absolute/path/to/workspace");
264
275
 
265
276
  try {
266
- const result = await run(runtime, {
277
+ const result = await request(runtime, {
267
278
  agentId: "auto",
268
279
  input: "Explain what this workspace is for.",
269
280
  });
@@ -277,7 +288,7 @@ try {
277
288
  Three-minute mental model:
278
289
 
279
290
  1. Point `createAgentHarness(...)` at a workspace root.
280
- 2. Call `run(runtime, { ... })` to execute one request.
291
+ 2. Call `request(runtime, { ... })` to execute one request.
281
292
  3. Inspect persisted runtime records instead of treating the final answer as the only product artifact.
282
293
 
283
294
  This is the shortest product pitch:
@@ -289,7 +300,7 @@ If you want the shortest possible mental model:
289
300
 
290
301
  - one workspace becomes one runtime
291
302
  - YAML defines assembly and policy
292
- - `run(runtime, { ... })` executes requests against that runtime
303
+ - `request(runtime, { ... })` executes requests against that runtime
293
304
  - the runtime owns lifecycle, inspection, and recovery
294
305
 
295
306
  ## Feature List
@@ -300,9 +311,9 @@ If you want the shortest possible mental model:
300
311
  - LangChain v1 and DeepAgents backend adaptation
301
312
  - Auto-discovered local `tool({...})` tools and SKILL packages
302
313
  - provider-native tools, MCP tools, and workspace-local tool modules
303
- - persisted threads, runs, approvals, lifecycle events, and queued runs
314
+ - persisted sessions, requests, approvals, lifecycle events, and queued requests
304
315
  - runtime-managed recovery and checkpoint maintenance
305
- - structured output and multimodal content preservation in run results
316
+ - structured output and multimodal content preservation in request results
306
317
  - MCP bridge support for agent-declared MCP servers
307
318
  - MCP server support for exposing harness tools outward
308
319
  - optional `mem0` semantic recall augmentation over canonical SQLite durable memory
@@ -362,9 +373,9 @@ const runtime = await createAgentHarness("/path/to/workspace", {
362
373
  ### Run A Request
363
374
 
364
375
  ```ts
365
- import { run } from "@botbotgo/agent-harness";
376
+ import { request } from "@botbotgo/agent-harness";
366
377
 
367
- const result = await run(runtime, {
378
+ const result = await request(runtime, {
368
379
  agentId: "orchestra",
369
380
  input: "Summarize the runtime design.",
370
381
  invocation: {
@@ -381,7 +392,7 @@ const result = await run(runtime, {
381
392
  });
382
393
  ```
383
394
 
384
- `run(runtime, { ... })` creates or continues a persisted session and returns `sessionId`, `requestId`, `state`, and compact text `output`. Richer upstream result shapes stay available through `outputContent`, `contentBlocks`, and `structuredResponse`.
395
+ `request(runtime, { ... })` creates or continues a persisted session and returns `sessionId`, `requestId`, `state`, and compact text `output`. Richer upstream result shapes stay available through `outputContent`, `contentBlocks`, and `structuredResponse`.
385
396
 
386
397
  Use `listRequests(runtime)` and `getRequest(runtime, requestId)` when a product needs a request-centric operations surface such as a review queue or execution dashboard.
387
398
 
@@ -398,9 +409,9 @@ For multimodal chat turns, keep the user-visible content in `input`.
398
409
  - persistence, replay, and transcript inspection should treat `input` as the source of truth for user-visible multimodal chat content
399
410
 
400
411
  ```ts
401
- import { normalizeUserChatInput, run } from "@botbotgo/agent-harness";
412
+ import { normalizeUserChatInput, request } from "@botbotgo/agent-harness";
402
413
 
403
- const result = await run(
414
+ const result = await request(
404
415
  runtime,
405
416
  {
406
417
  agentId: "orchestra",
@@ -415,7 +426,7 @@ const result = await run(
415
426
  );
416
427
  ```
417
428
 
418
- Use `normalizeUserChatInput(...)` when a product already has chat-style user messages and wants to project one user turn onto the stable `run(..., { input, invocation })` surface without introducing a separate harness-owned chat API.
429
+ Use `normalizeUserChatInput(...)` when a product already has chat-style user messages and wants to project one user turn onto the stable `request(..., { input, invocation })` surface without introducing a separate harness-owned chat API.
419
430
 
420
431
  ### Store And Recall Durable Runtime Memory
421
432
 
@@ -453,7 +464,7 @@ Use `memorize(...)`, `recall(...)`, `listMemories(...)`, `updateMemory(...)`, an
453
464
  ### Let The Runtime Route
454
465
 
455
466
  ```ts
456
- const result = await run(runtime, {
467
+ const result = await request(runtime, {
457
468
  agentId: "auto",
458
469
  input: "Inspect the repository and explain the release flow.",
459
470
  });
@@ -464,7 +475,7 @@ const result = await run(runtime, {
464
475
  ### Stream Output And Events
465
476
 
466
477
  ```ts
467
- const result = await run(runtime, {
478
+ const result = await request(runtime, {
468
479
  agentId: "orchestra",
469
480
  input: "Inspect the workspace and explain the available tools.",
470
481
  listeners: {
@@ -487,16 +498,16 @@ const result = await run(runtime, {
487
498
  });
488
499
  ```
489
500
 
490
- `onUpstreamEvent(...)` preserves the raw upstream event payload. `onUpstreamItem(...)` adds runtime correlation metadata such as `threadId`, `runId`, and the current `agentId`, which is useful for flow-graph capture and delegated sub-agent inspection.
501
+ `onUpstreamEvent(...)` preserves the raw upstream event payload. `onUpstreamItem(...)` adds runtime correlation metadata such as `sessionId`, `requestId`, and the current `agentId`, which is useful for flow-graph capture and delegated sub-agent inspection.
491
502
 
492
503
  `subscribe(...)` is the read-only observer surface over stored lifecycle events.
493
504
 
494
505
  The runtime event stream includes:
495
506
 
496
- - `run.created`
497
- - `run.queued`
498
- - `run.dequeued`
499
- - `run.state.changed`
507
+ - `request.created`
508
+ - `request.queued`
509
+ - `request.dequeued`
510
+ - `request.state.changed`
500
511
  - `approval.requested`
501
512
  - `approval.resolved`
502
513
  - `output.delta`
@@ -658,7 +669,7 @@ Important fields:
658
669
  `maintenance.checkpoints` and `maintenance.records` are separate retention layers:
659
670
 
660
671
  - `maintenance.checkpoints` trims backend checkpoint state used for resume/recovery
661
- - `maintenance.records` trims harness-owned terminal thread/run records stored in `runtime.sqlite`
672
+ - `maintenance.records` trims harness-owned terminal session/request records stored in `runtime.sqlite`
662
673
 
663
674
  Example:
664
675
 
@@ -845,7 +856,7 @@ spec:
845
856
  systemPrompt: Answer simple requests directly.
846
857
  ```
847
858
 
848
- When `config.filesystem.sessionStorage.enabled: true` is set for a LangChain binding, the runtime keeps one filesystem root per persisted session/thread and reuses the same runnable cache entry for repeated work on that session instead of collapsing every run onto one shared workspace directory.
859
+ When `config.filesystem.sessionStorage.enabled: true` is set for a LangChain binding, the runtime keeps one filesystem root per persisted session and reuses the same runnable cache entry for repeated work on that session instead of collapsing every request onto one shared workspace directory.
849
860
 
850
861
  Example orchestra host:
851
862
 
@@ -897,7 +908,7 @@ Primary exports:
897
908
 
898
909
  - `createAgentHarness`
899
910
  - `AgentHarnessRuntime`
900
- - `run`
911
+ - `request`
901
912
  - `resolveApproval`
902
913
  - `subscribe`
903
914
  - `listRequests`
@@ -909,8 +920,8 @@ Primary exports:
909
920
  - `getApproval`
910
921
  - `listArtifacts`
911
922
  - `getArtifact`
912
- - `listRunEvents`
913
- - `exportRunPackage`
923
+ - `listRequestEvents`
924
+ - `exportRequestPackage`
914
925
  - `exportSessionPackage`
915
926
  - `exportEvaluationBundle`
916
927
  - `replayEvaluationBundle`
@@ -945,6 +956,7 @@ ACP transport notes:
945
956
  - `serveA2aHttp(runtime)` exposes a minimal A2A-compatible HTTP JSON-RPC bridge plus agent card discovery, mapping `message/send`, `tasks/get`, and `tasks/cancel` onto the existing session/request runtime surface.
946
957
  - `serveAgUiHttp(runtime)` exposes a minimal AG-UI-compatible HTTP SSE bridge that projects `run + output.delta + final result` onto `RUN_STARTED`, `TEXT_MESSAGE_*`, and `RUN_FINISHED` events for UI clients.
947
958
  - `createRuntimeMcpServer(runtime)` and `serveRuntimeMcpOverStdio(runtime)` expose the persisted runtime control surface itself as MCP tools, including sessions, requests, approvals, artifacts, events, and package export helpers.
948
- - `exportRunPackage(...)` and `exportSessionPackage(...)` package stable runtime records, transcript, approvals, events, and artifacts for operator tooling without reaching into persistence internals.
959
+ - `listRequestEvents(...)` and `exportRequestPackage(...)` are the request-first inspection helpers.
960
+ - `exportRequestPackage(...)` and `exportSessionPackage(...)` package stable runtime records, transcript, approvals, events, and artifacts for operator tooling without reaching into persistence internals.
949
961
  - `runtime/default.governance.remoteMcp` can now deny or allow specific MCP servers, raise approval requirements by transport, and stamp transport-based risk tiers into runtime governance bundles.
950
962
  - detailed A2A adapter guidance lives in [`docs/a2a-bridge.md`](docs/a2a-bridge.md)
package/README.zh.md CHANGED
@@ -42,10 +42,21 @@
42
42
 
43
43
  **一句话:** 接入面保持很薄,运行时能力整层交付,日常主要工作集中在 **YAML 配置** 与 **扩展**(本地工具、SKILL 包、MCP),而不是反复自建运行时基础设施。
44
44
 
45
- - **容易上手:** `createAgentHarness` → `run` → `stop`,以及 `subscribe`、`listSessions`、`listApprovals`、`resolveApproval` 等查询与控制能力。
45
+ - **容易上手:** `createAgentHarness` → `request` → `stop`,以及 `subscribe`、`listSessions`、`listApprovals`、`resolveApproval` 等查询与控制能力。
46
46
  - **配置:** 路由、模型、工具、存储、后端、MCP、恢复与维护写在声明式工作区 YAML 里(见[快速开始](#快速开始)与[如何配置](#如何配置))。
47
47
  - **扩展:** 在 `resources/` 下放置 `tool({...})` 模块与 SKILL 目录,在目录里声明共享工具与 MCP,再由各 agent 按名字白名单启用。
48
- - **内建运行时:** 持久化 `runs`、`threads`、`approvals` 与 `events`;恢复与排队;流式监听;MCP 接入与对外暴露;LangChain v1 与 DeepAgents 适配——避免每个应用重复造这一层。
48
+ - **内建运行时:** 持久化 `requests`、`sessions`、`approvals` 与 `events`;恢复与排队;流式监听;MCP 接入与对外暴露;LangChain v1 与 DeepAgents 适配——避免每个应用重复造这一层。
49
+
50
+ ## 当前公开能力面
51
+
52
+ 这个仓库现在公开交付的已经不只是一个很薄的 runtime bootstrap。对外能力已经足够大,首页和文档也应该把它描述成一个带外部协议边界的产品级 runtime,而不只是 “YAML + tools”。
53
+
54
+ - **核心 runtime API:** `createAgentHarness`、`request`、`subscribe`、`resolveApproval`、各类 inspection helper,以及稳定持久化的 `requests`、`sessions`、`approvals`、`events` 和 artifacts 记录。
55
+ - **运行时 memory 与证据能力:** `memorize`、`recall`、`listMemories`、memory policy hooks、`listArtifacts`、`getArtifact`、`exportEvaluationBundle`、`replayEvaluationBundle`,以及 request / session 级证据导出 helper。
56
+ - **协议与传输接面:** `createAcpServer`、`serveAcpStdio`、`serveAcpHttp`、`serveA2aHttp`、`serveAgUiHttp`、以及 `createRuntimeMcpServer` / `serveRuntimeMcpOverStdio`。
57
+ - **受治理的工作区运行时:** 由 YAML 持有的路由、并发、维护、MCP 策略、runtime governance bundles,以及针对敏感 memory 或写类 MCP 副作用的默认审批门槛。
58
+
59
+ `deepagents-acp` 已不应该只藏在规划文档里。它已经是当前公开产品叙事的一部分:`agent-harness` 正在朝一个可被外部客户端直接接入的标准 runtime boundary 演进,同时继续把持久化、恢复、审批和 operator control 保持为 harness 自有职责。
49
60
 
50
61
  ## 我们解决什么问题
51
62
 
@@ -55,7 +66,7 @@
55
66
 
56
67
  第一天就能直接拿到的东西:
57
68
 
58
- - 把 `runs`、`threads`、`approvals`、`events` 作为可查询产品记录保存下来的 runtime
69
+ - 把 `requests`、`sessions`、`approvals`、`events` 作为可查询产品记录保存下来的 runtime
59
70
  - 能跨中断、重启和人工决策继续推进的恢复路径
60
71
  - 稳定的 run 关联与连续性元数据,让一次持久化运行能和日志、trace、fallback 过程对齐
61
72
  - 对敏感 durable memory 写入和写类 MCP 调用默认走审批,而不是把治理责任留给每个工具定义自己记住
@@ -74,7 +85,7 @@ AI 让 agent 逻辑、工具调用和工作流代码更容易生成,真正更
74
85
  团队仍然要正面回答这些运行时问题:
75
86
 
76
87
  - 审批怎么决策、怎么审计
77
- - runsthreads、events 怎么稳定可查
88
+ - requestssessions、events 怎么稳定可查
78
89
  - 执行被打断、失败或进程重启后怎么恢复
79
90
  - 路由、并发和维护策略怎么保持一致
80
91
  - 后端频繁变化时,怎么不让产品模型跟着漂移
@@ -84,13 +95,13 @@ AI 让 agent 逻辑、工具调用和工作流代码更容易生成,真正更
84
95
  换成更直接的产品语言,就是:
85
96
 
86
97
  - 你负责工作区、agents、tools 和 prompts
87
- - `agent-harness` 负责持久化 `runs`、`threads`、`approvals`、`events`、恢复能力与运维可见性
98
+ - `agent-harness` 负责持久化 `requests`、`sessions`、`approvals`、`events`、恢复能力与运维可见性
88
99
  - 你的应用拿到的是一个稳定的 runtime 契约,而不是一堆 backend 专属的运行时胶水代码
89
100
 
90
101
  具体来说,就是把这些能力沉到运行时里:
91
102
 
92
103
  - 面向产品的审批与运维控制面,而不是 backend 专属的中间件状态
93
- - 稳定持久化的 `runs`、`threads`、`approvals` 与 `events` 记录
104
+ - 稳定持久化的 `requests`、`sessions`、`approvals` 与 `events` 记录
94
105
  - 由运行时持有的 tracing correlation id 与 continuity metadata,而不是 provider 私有观测句柄
95
106
  - 由系统托管的重启恢复与中断续跑
96
107
  - 面向高风险 memory / MCP 副作用的默认治理策略
@@ -123,17 +134,17 @@ AI 让 agent 逻辑、工具调用和工作流代码更容易生成,真正更
123
134
 
124
135
  运行时提供:
125
136
 
126
- - `createAgentHarness(workspaceRoot)`、`run(...)`、`memorize(...)`、`recall(...)`、`listMemories(...)`、`updateMemory(...)`、`removeMemory(...)`、`resolveApproval(...)`、`subscribe(...)`、各类查询方法,以及 `stop(...)`
137
+ - `createAgentHarness(workspaceRoot)`、`request(...)`、`memorize(...)`、`recall(...)`、`listMemories(...)`、`updateMemory(...)`、`removeMemory(...)`、`resolveApproval(...)`、`subscribe(...)`、各类查询方法,以及 `stop(...)`
127
138
  - 以 YAML 描述的工作区装配:路由、模型、工具、存储、后端、MCP、恢复与维护等
128
139
  - 通过适配器对接当前的 LangChain v1 与 DeepAgents 执行
129
140
  - 本地 `resources/tools/` 中 `tool({...})` 工具模块与 `resources/skills/` 的发现
130
- - 持久化的线程、运行、审批、事件、队列状态与恢复元数据
141
+ - 持久化的会话、请求、审批、事件、队列状态与恢复元数据
131
142
 
132
143
  落到实际系统里,harness 主要解决那些每个 agent 应用都不应该重复造一遍的运行时难题:
133
144
 
134
145
  - 审批收件箱与人工决策流
135
- - 持久化的 runsthreads 与可查询事件历史
136
- - 即使发生 stream fallback 或进程重启也还能成立的 run 关联、连续性与恢复观测
146
+ - 持久化的 requestssessions 与可查询事件历史
147
+ - 即使发生 stream fallback 或进程重启也还能成立的 request 关联、连续性与恢复观测
137
148
  - 中断、失败或进程重启后的运行时托管恢复
138
149
  - 队列、并发、维护与运维策略
139
150
  - 即使后端变更也保持稳定的运行时记录模型
@@ -186,17 +197,17 @@ AI 让 agent 逻辑、工具调用和工作流代码更容易生成,真正更
186
197
 
187
198
  真实产品需要能回答更难问题的运行时:
188
199
 
189
- - 运行(runs)存在哪里?
200
+ - 请求(requests)存在哪里?
190
201
  - 审批如何闭环?
191
202
  - 进程重启后什么还在?
192
- - 如何在不暴露原始后端状态的前提下检查线程与事件?
203
+ - 如何在不暴露原始后端状态的前提下检查会话与事件?
193
204
  - 如何在不大改产品模型的前提下替换后端实现?
194
205
 
195
206
  `agent-harness` 在不把应用 API 做成 LangChain v1 / DeepAgents 翻版的前提下,回答这些问题。
196
207
 
197
208
  ## 有何不同
198
209
 
199
- - 将 `runs`、`threads`、`approvals`、`events` 与恢复视为一等产品记录
210
+ - 将 `requests`、`sessions`、`approvals`、`events` 与恢复视为一等产品记录
200
211
  - 给运维侧提供运行时控制面,而不是暴露原始后端内部结构
201
212
  - 将可观测性与治理留在运行时:包括 trace correlation、continuity metadata,以及高风险副作用的默认审批
202
213
  - 将 checkpoint 恢复作为系统管理的行为,而不是把 checkpoint 细节抬成主 API
@@ -208,7 +219,7 @@ AI 让 agent 逻辑、工具调用和工作流代码更容易生成,真正更
208
219
  下面这些场景适合用 `agent-harness`:
209
220
 
210
221
  - 你已经确定产品需要 agents、tools、prompts 或 MCP,但真正缺的是运行时运维层
211
- - 你需要把审批、重启恢复、排队调度或可查询运行记录一起作为产品能力交付出去
222
+ - 你需要把审批、重启恢复、排队调度或可查询请求记录一起作为产品能力交付出去
212
223
  - 你希望用一个 workspace 形态的装配模型取代每个应用各写一套启动和运行时胶水
213
224
  - 你想把 backend 的执行语义留在上游,同时把产品契约稳定下来
214
225
 
@@ -255,12 +266,12 @@ your-workspace/
255
266
  最小用法:
256
267
 
257
268
  ```ts
258
- import { createAgentHarness, run, stop } from "@botbotgo/agent-harness";
269
+ import { createAgentHarness, request, stop } from "@botbotgo/agent-harness";
259
270
 
260
271
  const runtime = await createAgentHarness("/absolute/path/to/workspace");
261
272
 
262
273
  try {
263
- const result = await run(runtime, {
274
+ const result = await request(runtime, {
264
275
  agentId: "auto",
265
276
  input: "Explain what this workspace is for.",
266
277
  });
@@ -274,7 +285,7 @@ try {
274
285
  三分钟心智模型:
275
286
 
276
287
  1. 用 `createAgentHarness(...)` 指向一个 workspace root。
277
- 2. 用 `run(runtime, { ... })` 执行一次请求。
288
+ 2. 用 `request(runtime, { ... })` 执行一次请求。
278
289
  3. 把持久化的运行时记录当成产品资产,而不是只盯着最终回答。
279
290
 
280
291
  如果再压缩成最短产品表述,就是:
@@ -286,7 +297,7 @@ try {
286
297
 
287
298
  - 一个工作区对应一个运行时
288
299
  - YAML 定义装配与策略
289
- - `run(runtime, { ... })` 在该运行时上执行请求
300
+ - `request(runtime, { ... })` 在该运行时上执行请求
290
301
  - 运行时负责生命周期、可观测性与恢复
291
302
 
292
303
  ## 功能列表
@@ -297,7 +308,7 @@ try {
297
308
  - LangChain v1 与 DeepAgents 后端适配
298
309
  - 自动发现本地工具与 SKILL 包
299
310
  - 原生 provider 工具、MCP 工具与工作区本地工具模块
300
- - 持久化线程、运行、审批、生命周期事件与排队运行
311
+ - 持久化会话、请求、审批、生命周期事件与排队请求
301
312
  - 运行时管理的恢复与 checkpoint 维护
302
313
  - 运行结果中的结构化输出与多模态内容保留
303
314
  - 将 agent 声明的 MCP 服务桥接进来
@@ -358,9 +369,9 @@ const runtime = await createAgentHarness("/path/to/workspace", {
358
369
  ### 发起一次运行
359
370
 
360
371
  ```ts
361
- import { run } from "@botbotgo/agent-harness";
372
+ import { request } from "@botbotgo/agent-harness";
362
373
 
363
- const result = await run(runtime, {
374
+ const result = await request(runtime, {
364
375
  agentId: "orchestra",
365
376
  input: "Summarize the runtime design.",
366
377
  invocation: {
@@ -377,7 +388,7 @@ const result = await run(runtime, {
377
388
  });
378
389
  ```
379
390
 
380
- `run(runtime, { ... })` 会创建或延续持久化会话,并返回 `sessionId`、`requestId`、`state` 以及紧凑文本 `output`。更丰富的上游结果形态仍可通过 `outputContent`、`contentBlocks`、`structuredResponse` 等获得。
391
+ `request(runtime, { ... })` 会创建或延续持久化会话,并返回 `sessionId`、`requestId`、`state` 以及紧凑文本 `output`。更丰富的上游结果形态仍可通过 `outputContent`、`contentBlocks`、`structuredResponse` 等获得。
381
392
 
382
393
  如果产品需要 request 视角的操作界面,例如 review queue 或执行看板,可使用 `listRequests(runtime)` 与 `getRequest(runtime, requestId)`。
383
394
 
@@ -425,7 +436,7 @@ const recalled = await recall(runtime, {
425
436
  ### 由运行时路由
426
437
 
427
438
  ```ts
428
- const result = await run(runtime, {
439
+ const result = await request(runtime, {
429
440
  agentId: "auto",
430
441
  input: "Inspect the repository and explain the release flow.",
431
442
  });
@@ -436,7 +447,7 @@ const result = await run(runtime, {
436
447
  ### 流式输出与事件
437
448
 
438
449
  ```ts
439
- const result = await run(runtime, {
450
+ const result = await request(runtime, {
440
451
  agentId: "orchestra",
441
452
  input: "Inspect the workspace and explain the available tools.",
442
453
  listeners: {
@@ -457,10 +468,10 @@ const result = await run(runtime, {
457
468
 
458
469
  运行时事件流包括:
459
470
 
460
- - `run.created`
461
- - `run.queued`
462
- - `run.dequeued`
463
- - `run.state.changed`
471
+ - `request.created`
472
+ - `request.queued`
473
+ - `request.dequeued`
474
+ - `request.state.changed`
464
475
  - `approval.requested`
465
476
  - `approval.resolved`
466
477
  - `output.delta`
@@ -618,7 +629,7 @@ await stop(runtime);
618
629
  `maintenance.checkpoints` 与 `maintenance.records` 是两层独立的保留策略:
619
630
 
620
631
  - `maintenance.checkpoints` 清理后端用于 resume/recovery 的 checkpoint 状态
621
- - `maintenance.records` 清理 harness 自己保存在 `runtime.sqlite` 中、已结束的 thread/run 记录
632
+ - `maintenance.records` 清理 harness 自己保存在 `runtime.sqlite` 中、已结束的 session/request 记录
622
633
 
623
634
  示例:
624
635
 
@@ -804,7 +815,7 @@ spec:
804
815
  systemPrompt: Answer simple requests directly.
805
816
  ```
806
817
 
807
- 当 LangChain 绑定启用 `config.filesystem.sessionStorage.enabled: true` 时,runtime 会为每个持久化 session/thread 维护独立的 filesystem 根目录,并按 session 复用 runnable cache,而不是把所有运行都压到同一个共享工作目录里。
818
+ 当 LangChain 绑定启用 `config.filesystem.sessionStorage.enabled: true` 时,runtime 会为每个持久化 session 维护独立的 filesystem 根目录,并按 session 复用 runnable cache,而不是把所有请求都压到同一个共享工作目录里。
808
819
 
809
820
  orchestra 主机示例:
810
821
 
@@ -856,7 +867,7 @@ spec:
856
867
 
857
868
  - `createAgentHarness`
858
869
  - `AgentHarnessRuntime`
859
- - `run`
870
+ - `request`
860
871
  - `resolveApproval`
861
872
  - `subscribe`
862
873
  - `listRequests`
@@ -868,8 +879,8 @@ spec:
868
879
  - `getApproval`
869
880
  - `listArtifacts`
870
881
  - `getArtifact`
871
- - `listRunEvents`
872
- - `exportRunPackage`
882
+ - `listRequestEvents`
883
+ - `exportRequestPackage`
873
884
  - `exportSessionPackage`
874
885
  - `exportEvaluationBundle`
875
886
  - `replayEvaluationBundle`
@@ -904,6 +915,7 @@ ACP transport 说明:
904
915
  - `serveA2aHttp(runtime)` 提供最小可用的 A2A HTTP JSON-RPC bridge 与 agent card discovery,把 `message/send`、`tasks/get`、`tasks/cancel` 映射到现有 session/request runtime surface。
905
916
  - `serveAgUiHttp(runtime)` 提供最小可用的 AG-UI HTTP SSE bridge,把现有 `run + output.delta + final result` 投影成 `RUN_STARTED`、`TEXT_MESSAGE_*` 与 `RUN_FINISHED` 事件,便于 UI 客户端直接接入。
906
917
  - `createRuntimeMcpServer(runtime)` 与 `serveRuntimeMcpOverStdio(runtime)` 会把持久化 runtime 控制面本身暴露成 MCP tools,包括 sessions、requests、approvals、artifacts、events 与 package export helpers。
907
- - `exportRunPackage(...)` 与 `exportSessionPackage(...)` 可把稳定 runtime 记录、transcript、approvals、events 和 artifacts 打包给 operator tooling,而不必直接访问 persistence 内部实现。
918
+ - `listRequestEvents(...)` 与 `exportRequestPackage(...)` request-first 的检查 helper。
919
+ - `exportRequestPackage(...)` 与 `exportSessionPackage(...)` 可把稳定 runtime 记录、transcript、approvals、events 和 artifacts 打包给 operator tooling,而不必直接访问 persistence 内部实现。
908
920
  - `runtime/default.governance.remoteMcp` 现在可以按 MCP server 或 transport 做 allow/deny、审批升级,并把 transport 风险等级写进 runtime governance bundles。
909
921
  - 更详细的 A2A 适配层开发说明见 [`docs/a2a-bridge.md`](docs/a2a-bridge.md)
package/dist/acp.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { ArtifactRecord, HarnessEvent, RequestRecord, RunOptions, SessionRecord } from "./contracts/types.js";
2
2
  import type { AgentHarnessRuntime } from "./runtime/harness.js";
3
- import { getApproval } from "./api.js";
3
+ import { getApproval, type PublicRunListeners } from "./api.js";
4
4
  type JsonRpcId = string | number | null;
5
5
  export type AcpJsonRpcRequest = {
6
6
  jsonrpc?: "2.0";
@@ -31,8 +31,9 @@ export type AcpArtifact = ArtifactRecord & {
31
31
  };
32
32
  export type AcpRunRequestParams = Omit<Extract<RunOptions, {
33
33
  input: unknown;
34
- }>, "threadId"> & {
34
+ }>, "threadId" | "listeners"> & {
35
35
  sessionId?: string;
36
+ listeners?: PublicRunListeners;
36
37
  };
37
38
  export type AcpServerCapabilities = {
38
39
  sessions: {
package/dist/acp.js CHANGED
@@ -1,4 +1,4 @@
1
- import { getApproval, getArtifact, getRequest, getSession, listApprovals, listArtifacts, listRequests, listSessions, resolveApproval, run, } from "./api.js";
1
+ import { getApproval, getArtifact, getRequest, getSession, listApprovals, listArtifacts, listRequests, listSessions, request, resolveApproval, } from "./api.js";
2
2
  const CAPABILITIES = {
3
3
  sessions: { list: true, get: true },
4
4
  requests: { submit: true, list: true, get: true },
@@ -146,7 +146,7 @@ export class AgentHarnessAcpServer {
146
146
  }
147
147
  case "requests.submit": {
148
148
  const payload = asObject(params, method);
149
- return run(this.runtime, {
149
+ return request(this.runtime, {
150
150
  agentId: readOptionalString(payload.agentId),
151
151
  input: payload.input,
152
152
  invocation: payload.invocation,
package/dist/api.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ArtifactListing, CancelOptions, InvocationEnvelope, ListMemoriesInput, ListMemoriesResult, MemoryRecord, MemorizeInput, MemorizeResult, MessageContent, RecallInput, RecallResult, RemoveMemoryInput, RequestRecord, RequestSummary, ResumeOptions, RunDecisionOptions, RunResult, RunStartOptions, RuntimeHealthSnapshot, RuntimeAdapterOptions, RuntimeEvaluationExport, RuntimeEvaluationExportInput, RuntimeEvaluationReplayInput, RuntimeEvaluationReplayResult, RuntimeRunPackage, RuntimeRunPackageInput, RuntimeSessionPackage, RuntimeSessionPackageInput, SessionRecord, SessionSummary, UpdateMemoryInput, WorkspaceLoadOptions } from "./contracts/types.js";
1
+ import type { ArtifactListing, CancelOptions, InvocationEnvelope, ListMemoriesInput, ListMemoriesResult, MemoryRecord, MemorizeInput, MemorizeResult, MessageContent, RecallInput, RecallResult, RemoveMemoryInput, RequestRecord, RequestSummary, ResumeOptions, RunDecisionOptions, RunListeners, RunResult, RunStartOptions, RuntimeHealthSnapshot, RuntimeAdapterOptions, RuntimeEvaluationExport, RuntimeEvaluationExportInput, RuntimeEvaluationReplayInput, RuntimeEvaluationReplayResult as InternalRuntimeEvaluationReplayResult, RuntimeSessionPackage, RuntimeSessionPackageInput, SessionRecord, SessionSummary, TranscriptMessage, UpdateMemoryInput, WorkspaceLoadOptions } from "./contracts/types.js";
2
2
  import { AgentHarnessRuntime } from "./runtime/harness.js";
3
3
  import type { InventoryAgentRecord, InventorySkillRecord } from "./runtime/harness/system/inventory.js";
4
4
  import type { RequirementAssessmentOptions } from "./runtime/harness/system/skill-requirements.js";
@@ -8,12 +8,36 @@ export type { AcpApproval, AcpArtifact, AcpEventNotification, AcpJsonRpcError, A
8
8
  export { AgentHarnessRuntime } from "./runtime/harness.js";
9
9
  export { buildFlowGraph, exportFlowGraphToMermaid, exportFlowGraphToSequenceMermaid } from "./flow/index.js";
10
10
  export { createUpstreamTimelineReducer } from "./upstream-events.js";
11
- export type { ListMemoriesInput, ListMemoriesResult, MemoryDecision, MemoryKind, MemoryRecord, MemoryScope, MemorizeInput, MemorizeResult, RecallInput, RecallResult, RemoveMemoryInput, RuntimeEvaluationExport, RuntimeEvaluationExportInput, RuntimeEvaluationReplayInput, RuntimeEvaluationReplayResult, RuntimeRunPackage, RuntimeRunPackageInput, RuntimeSessionPackage, RuntimeSessionPackageInput, UpdateMemoryInput, } from "./contracts/types.js";
11
+ export type { ListMemoriesInput, ListMemoriesResult, MemoryDecision, MemoryKind, MemoryRecord, MemoryScope, MemorizeInput, MemorizeResult, RecallInput, RecallResult, RemoveMemoryInput, RuntimeEvaluationExport, RuntimeEvaluationExportInput, RuntimeEvaluationReplayInput, RuntimeSessionPackageInput, RuntimeSessionPackage, UpdateMemoryInput, } from "./contracts/types.js";
12
12
  export type { AcpHttpServer, AcpHttpServerOptions } from "./protocol/acp/http.js";
13
13
  export type { A2aAgentCard, A2aHttpServer, A2aHttpServerOptions, A2aTask, A2aTaskState } from "./protocol/a2a/http.js";
14
14
  export type { AcpStdioServer, AcpStdioServerOptions } from "./protocol/acp/stdio.js";
15
15
  export type { AgUiEvent, AgUiHttpServer, AgUiHttpServerOptions, AgUiRunAgentInput } from "./protocol/ag-ui/http.js";
16
- type PublicApprovalRecord = {
16
+ export type RequestEventType = "request.created" | "request.queued" | "request.dequeued" | "request.state.changed" | "request.resumed" | Exclude<NonNullable<RunListeners["onEvent"]> extends (event: infer T) => unknown ? T extends {
17
+ eventType: infer E;
18
+ } ? E : never : never, "run.created" | "run.queued" | "run.dequeued" | "run.state.changed" | "run.resumed"> | (string & {});
19
+ export type RequestEvent = {
20
+ eventId: string;
21
+ eventType: RequestEventType;
22
+ timestamp: string;
23
+ sessionId: string;
24
+ requestId: string;
25
+ sequence: number;
26
+ source: "runtime" | "policy" | "surface" | "worker";
27
+ payload: Record<string, unknown>;
28
+ };
29
+ export type RequestUpstreamEventItem = {
30
+ sessionId: string;
31
+ requestId: string;
32
+ agentId: string;
33
+ event: unknown;
34
+ };
35
+ export type PublicRunListeners = {
36
+ onEvent?: (event: RequestEvent) => void | Promise<void>;
37
+ onUpstreamEvent?: RunListeners["onUpstreamEvent"];
38
+ onUpstreamItem?: (item: RequestUpstreamEventItem) => void | Promise<void>;
39
+ };
40
+ export type Approval = {
17
41
  approvalId: string;
18
42
  pendingActionId: string;
19
43
  sessionId: string;
@@ -25,23 +49,49 @@ type PublicApprovalRecord = {
25
49
  allowedDecisions: Array<"approve" | "edit" | "reject">;
26
50
  inputPreview: Record<string, unknown>;
27
51
  };
52
+ export type RequestArtifactListing = Omit<ArtifactListing, "threadId" | "runId"> & {
53
+ sessionId: string;
54
+ requestId: string;
55
+ };
56
+ export type RequestPackageInput = {
57
+ sessionId: string;
58
+ requestId: string;
59
+ includeArtifacts?: boolean;
60
+ includeArtifactContents?: boolean;
61
+ includeRuntimeHealth?: boolean;
62
+ };
63
+ export type RequestPackage = {
64
+ session: SessionRecord | null;
65
+ request: RequestRecord | null;
66
+ approvals: Approval[];
67
+ transcript: TranscriptMessage[];
68
+ events: RequestEvent[];
69
+ artifacts: RequestArtifactListing["items"];
70
+ runtimeHealth?: RuntimeHealthSnapshot;
71
+ };
72
+ export type RuntimeEvaluationReplayResult = Omit<InternalRuntimeEvaluationReplayResult, "result"> & {
73
+ result: PublicRunResult;
74
+ };
28
75
  type PublicApprovalFilter = {
29
- status?: PublicApprovalRecord["status"];
76
+ status?: Approval["status"];
30
77
  sessionId?: string;
31
78
  requestId?: string;
32
79
  };
33
- type PublicRunStartOptions = Omit<RunStartOptions, "threadId"> & {
80
+ type PublicRunStartOptions = Omit<RunStartOptions, "threadId" | "listeners"> & {
34
81
  sessionId?: string;
82
+ listeners?: PublicRunListeners;
35
83
  };
36
- type PublicRunDecisionOptions = Omit<RunDecisionOptions, "threadId" | "runId"> & {
84
+ type PublicRunDecisionOptions = Omit<RunDecisionOptions, "threadId" | "runId" | "listeners"> & {
37
85
  sessionId: string;
38
86
  requestId?: string;
87
+ listeners?: PublicRunListeners;
39
88
  };
40
89
  type PublicRunOptions = PublicRunStartOptions | PublicRunDecisionOptions;
41
90
  type PublicRunResult = Omit<RunResult, "threadId" | "runId"> & {
42
91
  sessionId: string;
43
92
  requestId: string;
44
93
  };
94
+ export type RequestResult = PublicRunResult;
45
95
  export type UserChatMessage = {
46
96
  role: "user";
47
97
  content: MessageContent;
@@ -61,13 +111,13 @@ type CreateAgentHarnessOptions = {
61
111
  export declare function createAgentHarness(): Promise<AgentHarnessRuntime>;
62
112
  export declare function createAgentHarness(workspaceRoot: string, options?: CreateAgentHarnessOptions): Promise<AgentHarnessRuntime>;
63
113
  export declare function normalizeUserChatInput(input: UserChatInput, options?: NormalizeUserChatInputOptions): Pick<RunStartOptions, "input" | "invocation">;
64
- export declare function run(runtime: AgentHarnessRuntime, options: PublicRunOptions): Promise<PublicRunResult>;
114
+ export declare function request(runtime: AgentHarnessRuntime, options: PublicRunOptions): Promise<PublicRunResult>;
65
115
  export declare function memorize(runtime: AgentHarnessRuntime, input: MemorizeInput): Promise<MemorizeResult>;
66
116
  export declare function recall(runtime: AgentHarnessRuntime, input: RecallInput): Promise<RecallResult>;
67
117
  export declare function listMemories(runtime: AgentHarnessRuntime, input?: ListMemoriesInput): Promise<ListMemoriesResult>;
68
118
  export declare function updateMemory(runtime: AgentHarnessRuntime, input: UpdateMemoryInput): Promise<MemoryRecord>;
69
119
  export declare function removeMemory(runtime: AgentHarnessRuntime, input: RemoveMemoryInput): Promise<MemoryRecord>;
70
- export declare function subscribe(runtime: AgentHarnessRuntime, listener: Parameters<AgentHarnessRuntime["subscribe"]>[0]): () => void;
120
+ export declare function subscribe(runtime: AgentHarnessRuntime, listener: (event: RequestEvent) => void | Promise<void>): () => void;
71
121
  export declare function listSessions(runtime: AgentHarnessRuntime, filter?: Parameters<AgentHarnessRuntime["listThreads"]>[0]): Promise<SessionSummary[]>;
72
122
  export declare function listRequests(runtime: AgentHarnessRuntime, filter?: {
73
123
  agentId?: string;
@@ -77,23 +127,23 @@ export declare function listRequests(runtime: AgentHarnessRuntime, filter?: {
77
127
  export declare function getSession(runtime: AgentHarnessRuntime, sessionId: string): Promise<SessionRecord | null>;
78
128
  export declare function getRequest(runtime: AgentHarnessRuntime, requestId: string): Promise<RequestRecord | null>;
79
129
  export declare function deleteSession(runtime: AgentHarnessRuntime, sessionId: string): Promise<boolean>;
80
- export declare function listApprovals(runtime: AgentHarnessRuntime, filter?: PublicApprovalFilter): Promise<PublicApprovalRecord[]>;
81
- export declare function getApproval(runtime: AgentHarnessRuntime, approvalId: string): Promise<PublicApprovalRecord | null>;
130
+ export declare function listApprovals(runtime: AgentHarnessRuntime, filter?: PublicApprovalFilter): Promise<Approval[]>;
131
+ export declare function getApproval(runtime: AgentHarnessRuntime, approvalId: string): Promise<Approval | null>;
82
132
  export declare function listArtifacts(runtime: AgentHarnessRuntime, input: {
83
133
  sessionId: string;
84
134
  requestId: string;
85
- }): Promise<ArtifactListing>;
135
+ }): Promise<RequestArtifactListing>;
86
136
  export declare function getArtifact(runtime: AgentHarnessRuntime, input: {
87
137
  sessionId: string;
88
138
  requestId: string;
89
139
  artifactPath: string;
90
140
  }): Promise<unknown>;
91
- export declare function listRunEvents(runtime: AgentHarnessRuntime, input: {
141
+ export declare function listRequestEvents(runtime: AgentHarnessRuntime, input: {
92
142
  sessionId: string;
93
143
  requestId: string;
94
- }): Promise<import("./contracts/runtime.js").HarnessEvent[]>;
144
+ }): Promise<RequestEvent[]>;
95
145
  export declare function getHealth(runtime: AgentHarnessRuntime): Promise<RuntimeHealthSnapshot>;
96
- export declare function exportRunPackage(runtime: AgentHarnessRuntime, input: RuntimeRunPackageInput): Promise<RuntimeRunPackage>;
146
+ export declare function exportRequestPackage(runtime: AgentHarnessRuntime, input: RequestPackageInput): Promise<RequestPackage>;
97
147
  export declare function exportSessionPackage(runtime: AgentHarnessRuntime, input: RuntimeSessionPackageInput): Promise<RuntimeSessionPackage>;
98
148
  export declare function exportEvaluationBundle(runtime: AgentHarnessRuntime, input: RuntimeEvaluationExportInput): Promise<RuntimeEvaluationExport>;
99
149
  export declare function replayEvaluationBundle(runtime: AgentHarnessRuntime, input: RuntimeEvaluationReplayInput): Promise<RuntimeEvaluationReplayResult>;
@@ -113,7 +163,7 @@ export declare function resolveApproval(runtime: AgentHarnessRuntime, options: R
113
163
  }): Promise<PublicRunResult>;
114
164
  export declare function cancelRun(runtime: AgentHarnessRuntime, options: CancelOptions & {
115
165
  requestId?: string;
116
- }): Promise<RunResult>;
166
+ }): Promise<PublicRunResult>;
117
167
  export declare function stop(runtime: AgentHarnessRuntime): Promise<void>;
118
168
  export declare function createToolMcpServer(runtime: AgentHarnessRuntime, options: ToolMcpServerOptions): Promise<import("@modelcontextprotocol/sdk/server/mcp.js").McpServer>;
119
169
  export declare function serveToolsOverStdio(runtime: AgentHarnessRuntime, options: ToolMcpServerOptions): Promise<import("@modelcontextprotocol/sdk/server/mcp.js").McpServer>;
package/dist/api.js CHANGED
@@ -71,6 +71,69 @@ function toApprovalRecord(record) {
71
71
  inputPreview: record.inputPreview,
72
72
  };
73
73
  }
74
+ function toPublicEventType(eventType) {
75
+ switch (eventType) {
76
+ case "run.created":
77
+ return "request.created";
78
+ case "run.queued":
79
+ return "request.queued";
80
+ case "run.dequeued":
81
+ return "request.dequeued";
82
+ case "run.state.changed":
83
+ return "request.state.changed";
84
+ case "run.resumed":
85
+ return "request.resumed";
86
+ default:
87
+ return eventType;
88
+ }
89
+ }
90
+ function toPublicEvent(event) {
91
+ return {
92
+ eventId: event.eventId,
93
+ eventType: toPublicEventType(event.eventType),
94
+ timestamp: event.timestamp,
95
+ sessionId: event.threadId,
96
+ requestId: event.runId,
97
+ sequence: event.sequence,
98
+ source: event.source,
99
+ payload: event.payload,
100
+ };
101
+ }
102
+ function toPublicRunListeners(listeners) {
103
+ if (!listeners) {
104
+ return undefined;
105
+ }
106
+ return {
107
+ onEvent: listeners.onEvent ? async (event) => listeners.onEvent(toPublicEvent(event)) : undefined,
108
+ onUpstreamEvent: listeners.onUpstreamEvent,
109
+ onUpstreamItem: listeners.onUpstreamItem
110
+ ? async (item) => listeners.onUpstreamItem({
111
+ sessionId: item.threadId,
112
+ requestId: item.runId,
113
+ agentId: item.agentId,
114
+ event: item.event,
115
+ })
116
+ : undefined,
117
+ };
118
+ }
119
+ function toRequestArtifactListing(listing) {
120
+ return {
121
+ sessionId: listing.threadId,
122
+ requestId: listing.runId,
123
+ items: listing.items,
124
+ };
125
+ }
126
+ function toRequestPackage(pkg) {
127
+ return {
128
+ session: pkg.session,
129
+ request: pkg.request,
130
+ approvals: pkg.approvals.map(toApprovalRecord),
131
+ transcript: pkg.transcript,
132
+ events: pkg.events.map(toPublicEvent),
133
+ artifacts: pkg.artifacts,
134
+ ...(pkg.runtimeHealth ? { runtimeHealth: pkg.runtimeHealth } : {}),
135
+ };
136
+ }
74
137
  function toPublicRunResult(result) {
75
138
  return {
76
139
  sessionId: result.threadId,
@@ -96,7 +159,7 @@ function toInternalRunOptions(options) {
96
159
  approvalId: options.approvalId,
97
160
  decision: options.decision,
98
161
  editedInput: options.editedInput,
99
- listeners: options.listeners,
162
+ listeners: toPublicRunListeners(options.listeners),
100
163
  runId: options.requestId,
101
164
  threadId: options.sessionId,
102
165
  };
@@ -105,7 +168,7 @@ function toInternalRunOptions(options) {
105
168
  agentId: options.agentId,
106
169
  input: options.input,
107
170
  invocation: options.invocation,
108
- listeners: options.listeners,
171
+ listeners: toPublicRunListeners(options.listeners),
109
172
  priority: options.priority,
110
173
  threadId: options.sessionId,
111
174
  };
@@ -131,7 +194,7 @@ export function normalizeUserChatInput(input, options = {}) {
131
194
  : normalizeMessageContent(input);
132
195
  return options.invocation ? { input: content, invocation: options.invocation } : { input: content };
133
196
  }
134
- export async function run(runtime, options) {
197
+ export async function request(runtime, options) {
135
198
  return toPublicRunResult(await runtime.run(toInternalRunOptions(options)));
136
199
  }
137
200
  export async function memorize(runtime, input) {
@@ -150,7 +213,9 @@ export async function removeMemory(runtime, input) {
150
213
  return runtime.removeMemory(input);
151
214
  }
152
215
  export function subscribe(runtime, listener) {
153
- return runtime.subscribe(listener);
216
+ return runtime.subscribe(async (event) => {
217
+ await listener(toPublicEvent(event));
218
+ });
154
219
  }
155
220
  export async function listSessions(runtime, filter) {
156
221
  return (await runtime.listThreads(filter)).map(toSessionSummary);
@@ -185,19 +250,19 @@ export async function getApproval(runtime, approvalId) {
185
250
  return record ? toApprovalRecord(record) : null;
186
251
  }
187
252
  export async function listArtifacts(runtime, input) {
188
- return runtime.listArtifacts(input.sessionId, input.requestId);
253
+ return toRequestArtifactListing(await runtime.listArtifacts(input.sessionId, input.requestId));
189
254
  }
190
255
  export async function getArtifact(runtime, input) {
191
256
  return runtime.readArtifact(input.sessionId, input.requestId, input.artifactPath);
192
257
  }
193
- export async function listRunEvents(runtime, input) {
194
- return runtime.listRunEvents(input.sessionId, input.requestId);
258
+ export async function listRequestEvents(runtime, input) {
259
+ return (await runtime.listRunEvents(input.sessionId, input.requestId)).map(toPublicEvent);
195
260
  }
196
261
  export async function getHealth(runtime) {
197
262
  return runtime.getHealth();
198
263
  }
199
- export async function exportRunPackage(runtime, input) {
200
- return runtime.exportRunPackage(input);
264
+ export async function exportRequestPackage(runtime, input) {
265
+ return toRequestPackage(await runtime.exportRunPackage(input));
201
266
  }
202
267
  export async function exportSessionPackage(runtime, input) {
203
268
  return runtime.exportSessionPackage(input);
@@ -206,7 +271,11 @@ export async function exportEvaluationBundle(runtime, input) {
206
271
  return runtime.exportEvaluationBundle(input);
207
272
  }
208
273
  export async function replayEvaluationBundle(runtime, input) {
209
- return runtime.replayEvaluationBundle(input);
274
+ const replayed = await runtime.replayEvaluationBundle(input);
275
+ return {
276
+ ...replayed,
277
+ result: toPublicRunResult(replayed.result),
278
+ };
210
279
  }
211
280
  export function serveAcpStdio(runtime, options) {
212
281
  return serveAcpOverStdio(runtime, options);
@@ -233,10 +302,10 @@ export async function resolveApproval(runtime, options) {
233
302
  return toPublicRunResult(await runtime.resume(toInternalResumeOptions(options)));
234
303
  }
235
304
  export async function cancelRun(runtime, options) {
236
- return runtime.cancelRun({
305
+ return toPublicRunResult(await runtime.cancelRun({
237
306
  ...options,
238
307
  runId: options.requestId ?? options.runId,
239
- });
308
+ }));
240
309
  }
241
310
  export async function stop(runtime) {
242
311
  return runtime.stop();
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { AgentHarnessAcpServer, AgentHarnessRuntime, buildFlowGraph, cancelRun, createAgentHarness, createAcpServer, createRuntimeMcpServer, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, exportEvaluationBundle, exportRunPackage, exportSessionPackage, replayEvaluationBundle, getArtifact, getAgent, getApproval, getRequest, getHealth, listMemories, listRunEvents, getSession, listAgentSkills, listArtifacts, listApprovals, listRequests, listSessions, memorize, normalizeUserChatInput, recall, removeMemory, resolveApproval, run, serveA2aHttp, serveAcpHttp, serveAcpStdio, serveAgUiHttp, serveRuntimeMcpOverStdio, serveToolsOverStdio, subscribe, stop, updateMemory, exportFlowGraphToMermaid, exportFlowGraphToSequenceMermaid, } from "./api.js";
1
+ export { AgentHarnessAcpServer, AgentHarnessRuntime, buildFlowGraph, cancelRun, createAgentHarness, createAcpServer, createRuntimeMcpServer, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, exportEvaluationBundle, exportRequestPackage, exportSessionPackage, replayEvaluationBundle, getArtifact, getAgent, getApproval, getRequest, getHealth, listMemories, getSession, listAgentSkills, listArtifacts, listApprovals, listRequests, listRequestEvents, listSessions, memorize, normalizeUserChatInput, request, recall, removeMemory, resolveApproval, serveA2aHttp, serveAcpHttp, serveAcpStdio, serveAgUiHttp, serveRuntimeMcpOverStdio, serveToolsOverStdio, subscribe, stop, updateMemory, exportFlowGraphToMermaid, exportFlowGraphToSequenceMermaid, } from "./api.js";
2
2
  export type { AcpApproval, AcpArtifact, AcpEventNotification, AcpJsonRpcError, AcpJsonRpcRequest, AcpJsonRpcResponse, AcpJsonRpcSuccess, AcpRequestRecord, AcpRunRequestParams, AcpServerCapabilities, AcpSessionRecord, } from "./acp.js";
3
- export type { ListMemoriesInput, ListMemoriesResult, MemoryDecision, MemoryKind, MemoryRecord, MemoryScope, MemorizeInput, MemorizeResult, NormalizeUserChatInputOptions, RecallInput, RecallResult, RemoveMemoryInput, RuntimeEvaluationExport, RuntimeEvaluationExportInput, RuntimeEvaluationReplayInput, RuntimeEvaluationReplayResult, RuntimeRunPackage, RuntimeRunPackageInput, RuntimeSessionPackage, RuntimeSessionPackageInput, UpdateMemoryInput, UserChatInput, UserChatMessage, } from "./api.js";
3
+ export type { Approval, ListMemoriesInput, ListMemoriesResult, MemoryDecision, MemoryKind, MemoryRecord, MemoryScope, MemorizeInput, MemorizeResult, NormalizeUserChatInputOptions, PublicRunListeners, RequestArtifactListing, RequestEvent, RequestEventType, RequestPackage, RequestPackageInput, RequestResult, RequestUpstreamEventItem, RecallInput, RecallResult, RemoveMemoryInput, RuntimeEvaluationExport, RuntimeEvaluationExportInput, RuntimeEvaluationReplayInput, RuntimeEvaluationReplayResult, RuntimeSessionPackage, RuntimeSessionPackageInput, UpdateMemoryInput, UserChatInput, UserChatMessage, } from "./api.js";
4
4
  export type { BuildFlowGraphInput, FlowEdge, FlowEdgeKind, FlowGraph, FlowGraphMermaidOptions, FlowGraphSequenceMermaidOptions, FlowGroup, FlowGroupKind, FlowNode, FlowNodeKind, FlowNodeLayer, FlowNodeStatus, } from "./flow/index.js";
5
5
  export type { A2aAgentCard, A2aHttpServer, A2aHttpServerOptions, A2aTask, A2aTaskState, AcpHttpServer, AcpHttpServerOptions, AcpStdioServer, AcpStdioServerOptions, AgUiEvent, AgUiHttpServer, AgUiHttpServerOptions, AgUiRunAgentInput, } from "./api.js";
6
6
  export type { RuntimeMcpServerOptions, ToolMcpServerOptions } from "./mcp.js";
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { AgentHarnessAcpServer, AgentHarnessRuntime, buildFlowGraph, cancelRun, createAgentHarness, createAcpServer, createRuntimeMcpServer, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, exportEvaluationBundle, exportRunPackage, exportSessionPackage, replayEvaluationBundle, getArtifact, getAgent, getApproval, getRequest, getHealth, listMemories, listRunEvents, getSession, listAgentSkills, listArtifacts, listApprovals, listRequests, listSessions, memorize, normalizeUserChatInput, recall, removeMemory, resolveApproval, run, serveA2aHttp, serveAcpHttp, serveAcpStdio, serveAgUiHttp, serveRuntimeMcpOverStdio, serveToolsOverStdio, subscribe, stop, updateMemory, exportFlowGraphToMermaid, exportFlowGraphToSequenceMermaid, } from "./api.js";
1
+ export { AgentHarnessAcpServer, AgentHarnessRuntime, buildFlowGraph, cancelRun, createAgentHarness, createAcpServer, createRuntimeMcpServer, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, exportEvaluationBundle, exportRequestPackage, exportSessionPackage, replayEvaluationBundle, getArtifact, getAgent, getApproval, getRequest, getHealth, listMemories, getSession, listAgentSkills, listArtifacts, listApprovals, listRequests, listRequestEvents, listSessions, memorize, normalizeUserChatInput, request, recall, removeMemory, resolveApproval, serveA2aHttp, serveAcpHttp, serveAcpStdio, serveAgUiHttp, serveRuntimeMcpOverStdio, serveToolsOverStdio, subscribe, stop, updateMemory, exportFlowGraphToMermaid, exportFlowGraphToSequenceMermaid, } from "./api.js";
2
2
  export { tool } from "./tools.js";
@@ -294,7 +294,7 @@ function renderRunScript(options) {
294
294
  ? "Research the latest model and tooling trends for AI product teams. Return a concise brief with sources and caveats."
295
295
  : "Analyze the current architecture direction for this product and return a concise brief with assumptions and caveats.";
296
296
  return `import { fileURLToPath } from "node:url";
297
- import { createAgentHarness, run, stop } from "@botbotgo/agent-harness";
297
+ import { createAgentHarness, request, stop } from "@botbotgo/agent-harness";
298
298
 
299
299
  const appRoot = fileURLToPath(new URL("..", import.meta.url));
300
300
  const args = process.argv.slice(2);
@@ -321,7 +321,7 @@ const input = inputParts.join(" ").trim() ||
321
321
  const runtime = await createAgentHarness(appRoot);
322
322
 
323
323
  try {
324
- const result = await run(runtime, {
324
+ const result = await request(runtime, {
325
325
  agentId: requestedAgentId,
326
326
  input,
327
327
  });
package/dist/mcp.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- import type { ApprovalRecord, ArtifactListing, CompiledTool, HarnessEvent, ParsedToolObject, RunResult, RunState, RunSummary, RuntimeRunPackage, RuntimeRunPackageInput, RuntimeSessionPackage, RuntimeSessionPackageInput, ThreadRecord, ThreadSummary } from "./contracts/types.js";
2
+ import type { ApprovalRecord, ArtifactListing, CompiledTool, HarnessEvent, ParsedToolObject, RunResult, RunState, RunSummary, RuntimeSessionPackage, RuntimeSessionPackageInput, ThreadRecord, ThreadSummary } from "./contracts/types.js";
3
3
  export type ToolMcpServerOptions = {
4
4
  agentId: string;
5
5
  serverInfo?: {
@@ -45,8 +45,14 @@ type RuntimeMcpRuntime = {
45
45
  }) => Promise<RunResult>;
46
46
  listArtifacts: (threadId: string, runId: string) => Promise<ArtifactListing>;
47
47
  readArtifact: (threadId: string, runId: string, artifactPath: string) => Promise<unknown>;
48
- listRunEvents: (threadId: string, runId: string) => Promise<HarnessEvent[]>;
49
- exportRunPackage: (input: RuntimeRunPackageInput) => Promise<RuntimeRunPackage>;
48
+ listRunEvents: (sessionId: string, requestId: string) => Promise<HarnessEvent[]>;
49
+ exportRunPackage: (input: {
50
+ sessionId: string;
51
+ requestId: string;
52
+ includeArtifacts?: boolean;
53
+ includeArtifactContents?: boolean;
54
+ includeRuntimeHealth?: boolean;
55
+ }) => Promise<unknown>;
50
56
  exportSessionPackage: (input: RuntimeSessionPackageInput) => Promise<RuntimeSessionPackage>;
51
57
  };
52
58
  export declare function createToolMcpServerFromTools(tools: ToolMcpServerTool[], options: ToolMcpServerOptions): Promise<McpServer>;
package/dist/mcp.js CHANGED
@@ -212,7 +212,7 @@ export async function createRuntimeMcpServer(runtime, options = {}) {
212
212
  text: renderToolOutput(await runtime.readArtifact(input.sessionId, input.requestId, input.artifactPath)),
213
213
  }],
214
214
  }));
215
- server.tool("list_run_events", "List persisted runtime events for one request.", {
215
+ server.tool("list_request_events", "List persisted runtime events for one request.", {
216
216
  sessionId: z.string(),
217
217
  requestId: z.string(),
218
218
  }, async (input) => ({
@@ -221,7 +221,7 @@ export async function createRuntimeMcpServer(runtime, options = {}) {
221
221
  text: renderToolOutput(await runtime.listRunEvents(input.sessionId, input.requestId)),
222
222
  }],
223
223
  }));
224
- server.tool("export_run_package", "Export a stable runtime run package for one request.", {
224
+ server.tool("export_request_package", "Export a stable runtime request package for one request.", {
225
225
  sessionId: z.string(),
226
226
  requestId: z.string(),
227
227
  includeArtifacts: z.boolean().optional(),
@@ -1 +1 @@
1
- export declare const AGENT_HARNESS_VERSION = "0.0.182";
1
+ export declare const AGENT_HARNESS_VERSION = "0.0.184";
@@ -1 +1 @@
1
- export const AGENT_HARNESS_VERSION = "0.0.182";
1
+ export const AGENT_HARNESS_VERSION = "0.0.184";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botbotgo/agent-harness",
3
- "version": "0.0.183",
3
+ "version": "0.0.185",
4
4
  "description": "Workspace runtime for multi-agent applications",
5
5
  "type": "module",
6
6
  "packageManager": "npm@10.9.2",