@botbotgo/agent-harness 0.0.182 → 0.0.184

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,10 @@
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
49
 
50
50
  ## What Problem We Solve
51
51
 
@@ -55,7 +55,7 @@ If your team already has agents, prompts, tools, and workflows, the missing laye
55
55
 
56
56
  What you get on day one:
57
57
 
58
- - a runtime that keeps `runs`, `threads`, `approvals`, and `events` as inspectable product records
58
+ - a runtime that keeps `requests`, `sessions`, `approvals`, and `events` as inspectable product records
59
59
  - a recovery path that survives interruption, restart, and operator decisions
60
60
  - stable run correlation and continuity metadata so operators can join one persisted run to logs, traces, and fallback transitions
61
61
  - approval defaults for sensitive durable memory writes and write-like MCP calls instead of relying on each tool definition to remember governance
@@ -74,7 +74,7 @@ Once the demo works, the real software problem changes shape:
74
74
  Teams still need clear answers to the runtime questions that appear after that shift:
75
75
 
76
76
  - how approvals are resolved and audited
77
- - how runs, threads, and events stay inspectable
77
+ - how requests, sessions, and events stay inspectable
78
78
  - how execution recovers after interruption, failure, or restart
79
79
  - how routing, concurrency, and maintenance policy stay consistent
80
80
  - how backend churn does not leak into the product model
@@ -84,13 +84,13 @@ Teams still need clear answers to the runtime questions that appear after that s
84
84
  That makes the product story easier to explain:
85
85
 
86
86
  - you bring the workspace, agents, tools, and prompts
87
- - `agent-harness` brings persisted `runs`, `threads`, `approvals`, `events`, recovery, and operator visibility
87
+ - `agent-harness` brings persisted `requests`, `sessions`, `approvals`, `events`, recovery, and operator visibility
88
88
  - your application gets one stable runtime contract instead of backend-specific runtime plumbing
89
89
 
90
90
  In concrete terms:
91
91
 
92
92
  - a product-facing approval and operator surface instead of backend-specific middleware state
93
- - persisted `runs`, `threads`, `approvals`, and `events` as stable runtime records
93
+ - persisted `requests`, `sessions`, `approvals`, and `events` as stable runtime records
94
94
  - runtime-owned inspection fields such as tracing correlation ids and continuity metadata instead of provider-private observability handles
95
95
  - restart-safe recovery and continuation as system-managed behavior
96
96
  - default runtime governance for high-risk memory and MCP side effects
@@ -123,7 +123,7 @@ That means:
123
123
 
124
124
  The runtime provides:
125
125
 
126
- - `createAgentHarness(workspaceRoot)`, `run(...)`, `memorize(...)`, `recall(...)`, `listMemories(...)`, `updateMemory(...)`, `removeMemory(...)`, `resolveApproval(...)`, `subscribe(...)`, inspection methods, and `stop(...)`
126
+ - `createAgentHarness(workspaceRoot)`, `request(...)`, `memorize(...)`, `recall(...)`, `listMemories(...)`, `updateMemory(...)`, `removeMemory(...)`, `resolveApproval(...)`, `subscribe(...)`, inspection methods, and `stop(...)`
127
127
  - YAML-defined workspace assembly for routing, models, tools, stores, backends, MCP, recovery, and maintenance
128
128
  - backend-adapted execution with current LangChain v1 and DeepAgents adapters
129
129
  - local `resources/tools/` `tool({...})` modules and `resources/skills/` discovery
@@ -258,12 +258,12 @@ your-workspace/
258
258
  Minimal usage:
259
259
 
260
260
  ```ts
261
- import { createAgentHarness, run, stop } from "@botbotgo/agent-harness";
261
+ import { createAgentHarness, request, stop } from "@botbotgo/agent-harness";
262
262
 
263
263
  const runtime = await createAgentHarness("/absolute/path/to/workspace");
264
264
 
265
265
  try {
266
- const result = await run(runtime, {
266
+ const result = await request(runtime, {
267
267
  agentId: "auto",
268
268
  input: "Explain what this workspace is for.",
269
269
  });
@@ -277,7 +277,7 @@ try {
277
277
  Three-minute mental model:
278
278
 
279
279
  1. Point `createAgentHarness(...)` at a workspace root.
280
- 2. Call `run(runtime, { ... })` to execute one request.
280
+ 2. Call `request(runtime, { ... })` to execute one request.
281
281
  3. Inspect persisted runtime records instead of treating the final answer as the only product artifact.
282
282
 
283
283
  This is the shortest product pitch:
@@ -289,7 +289,7 @@ If you want the shortest possible mental model:
289
289
 
290
290
  - one workspace becomes one runtime
291
291
  - YAML defines assembly and policy
292
- - `run(runtime, { ... })` executes requests against that runtime
292
+ - `request(runtime, { ... })` executes requests against that runtime
293
293
  - the runtime owns lifecycle, inspection, and recovery
294
294
 
295
295
  ## Feature List
@@ -326,6 +326,19 @@ const runtime: AgentHarnessRuntime = await createAgentHarness("/absolute/path/to
326
326
 
327
327
  `createAgentHarness(...)` loads the workspace, resolves `resources/`, initializes persistence under `runRoot`, and starts runtime maintenance.
328
328
 
329
+ `runtime.spec.resources` may attach multiple extra resource packages. Each entry may point either to a package root that contains `resources/`, or directly to a resource folder that contains its own `package.json`.
330
+
331
+ ```yaml
332
+ apiVersion: agent-harness/v1alpha1
333
+ kind: Runtime
334
+ metadata:
335
+ name: default
336
+ spec:
337
+ resources:
338
+ - ../shared-tools
339
+ - file:../shared-skills
340
+ ```
341
+
329
342
  `createAgentHarness(..., { load })` accepts workspace loading controls.
330
343
 
331
344
  Merge order is deterministic:
@@ -349,9 +362,9 @@ const runtime = await createAgentHarness("/path/to/workspace", {
349
362
  ### Run A Request
350
363
 
351
364
  ```ts
352
- import { run } from "@botbotgo/agent-harness";
365
+ import { request } from "@botbotgo/agent-harness";
353
366
 
354
- const result = await run(runtime, {
367
+ const result = await request(runtime, {
355
368
  agentId: "orchestra",
356
369
  input: "Summarize the runtime design.",
357
370
  invocation: {
@@ -368,7 +381,7 @@ const result = await run(runtime, {
368
381
  });
369
382
  ```
370
383
 
371
- `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`.
384
+ `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`.
372
385
 
373
386
  Use `listRequests(runtime)` and `getRequest(runtime, requestId)` when a product needs a request-centric operations surface such as a review queue or execution dashboard.
374
387
 
@@ -385,9 +398,9 @@ For multimodal chat turns, keep the user-visible content in `input`.
385
398
  - persistence, replay, and transcript inspection should treat `input` as the source of truth for user-visible multimodal chat content
386
399
 
387
400
  ```ts
388
- import { normalizeUserChatInput, run } from "@botbotgo/agent-harness";
401
+ import { normalizeUserChatInput, request } from "@botbotgo/agent-harness";
389
402
 
390
- const result = await run(
403
+ const result = await request(
391
404
  runtime,
392
405
  {
393
406
  agentId: "orchestra",
@@ -402,7 +415,7 @@ const result = await run(
402
415
  );
403
416
  ```
404
417
 
405
- 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.
418
+ 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.
406
419
 
407
420
  ### Store And Recall Durable Runtime Memory
408
421
 
@@ -440,7 +453,7 @@ Use `memorize(...)`, `recall(...)`, `listMemories(...)`, `updateMemory(...)`, an
440
453
  ### Let The Runtime Route
441
454
 
442
455
  ```ts
443
- const result = await run(runtime, {
456
+ const result = await request(runtime, {
444
457
  agentId: "auto",
445
458
  input: "Inspect the repository and explain the release flow.",
446
459
  });
@@ -451,7 +464,7 @@ const result = await run(runtime, {
451
464
  ### Stream Output And Events
452
465
 
453
466
  ```ts
454
- const result = await run(runtime, {
467
+ const result = await request(runtime, {
455
468
  agentId: "orchestra",
456
469
  input: "Inspect the workspace and explain the available tools.",
457
470
  listeners: {
@@ -474,16 +487,16 @@ const result = await run(runtime, {
474
487
  });
475
488
  ```
476
489
 
477
- `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.
490
+ `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.
478
491
 
479
492
  `subscribe(...)` is the read-only observer surface over stored lifecycle events.
480
493
 
481
494
  The runtime event stream includes:
482
495
 
483
- - `run.created`
484
- - `run.queued`
485
- - `run.dequeued`
486
- - `run.state.changed`
496
+ - `request.created`
497
+ - `request.queued`
498
+ - `request.dequeued`
499
+ - `request.state.changed`
487
500
  - `approval.requested`
488
501
  - `approval.resolved`
489
502
  - `output.delta`
@@ -884,7 +897,7 @@ Primary exports:
884
897
 
885
898
  - `createAgentHarness`
886
899
  - `AgentHarnessRuntime`
887
- - `run`
900
+ - `request`
888
901
  - `resolveApproval`
889
902
  - `subscribe`
890
903
  - `listRequests`
@@ -896,8 +909,8 @@ Primary exports:
896
909
  - `getApproval`
897
910
  - `listArtifacts`
898
911
  - `getArtifact`
899
- - `listRunEvents`
900
- - `exportRunPackage`
912
+ - `listRequestEvents`
913
+ - `exportRequestPackage`
901
914
  - `exportSessionPackage`
902
915
  - `exportEvaluationBundle`
903
916
  - `replayEvaluationBundle`
@@ -932,6 +945,7 @@ ACP transport notes:
932
945
  - `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.
933
946
  - `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.
934
947
  - `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.
935
- - `exportRunPackage(...)` and `exportSessionPackage(...)` package stable runtime records, transcript, approvals, events, and artifacts for operator tooling without reaching into persistence internals.
948
+ - `listRequestEvents(...)` and `exportRequestPackage(...)` are the request-first inspection helpers.
949
+ - `exportRequestPackage(...)` and `exportSessionPackage(...)` package stable runtime records, transcript, approvals, events, and artifacts for operator tooling without reaching into persistence internals.
936
950
  - `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.
937
951
  - detailed A2A adapter guidance lives in [`docs/a2a-bridge.md`](docs/a2a-bridge.md)
package/README.zh.md CHANGED
@@ -42,10 +42,10 @@
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
49
 
50
50
  ## 我们解决什么问题
51
51
 
@@ -55,7 +55,7 @@
55
55
 
56
56
  第一天就能直接拿到的东西:
57
57
 
58
- - 把 `runs`、`threads`、`approvals`、`events` 作为可查询产品记录保存下来的 runtime
58
+ - 把 `requests`、`sessions`、`approvals`、`events` 作为可查询产品记录保存下来的 runtime
59
59
  - 能跨中断、重启和人工决策继续推进的恢复路径
60
60
  - 稳定的 run 关联与连续性元数据,让一次持久化运行能和日志、trace、fallback 过程对齐
61
61
  - 对敏感 durable memory 写入和写类 MCP 调用默认走审批,而不是把治理责任留给每个工具定义自己记住
@@ -74,7 +74,7 @@ AI 让 agent 逻辑、工具调用和工作流代码更容易生成,真正更
74
74
  团队仍然要正面回答这些运行时问题:
75
75
 
76
76
  - 审批怎么决策、怎么审计
77
- - runsthreads、events 怎么稳定可查
77
+ - requestssessions、events 怎么稳定可查
78
78
  - 执行被打断、失败或进程重启后怎么恢复
79
79
  - 路由、并发和维护策略怎么保持一致
80
80
  - 后端频繁变化时,怎么不让产品模型跟着漂移
@@ -84,13 +84,13 @@ AI 让 agent 逻辑、工具调用和工作流代码更容易生成,真正更
84
84
  换成更直接的产品语言,就是:
85
85
 
86
86
  - 你负责工作区、agents、tools 和 prompts
87
- - `agent-harness` 负责持久化 `runs`、`threads`、`approvals`、`events`、恢复能力与运维可见性
87
+ - `agent-harness` 负责持久化 `requests`、`sessions`、`approvals`、`events`、恢复能力与运维可见性
88
88
  - 你的应用拿到的是一个稳定的 runtime 契约,而不是一堆 backend 专属的运行时胶水代码
89
89
 
90
90
  具体来说,就是把这些能力沉到运行时里:
91
91
 
92
92
  - 面向产品的审批与运维控制面,而不是 backend 专属的中间件状态
93
- - 稳定持久化的 `runs`、`threads`、`approvals` 与 `events` 记录
93
+ - 稳定持久化的 `requests`、`sessions`、`approvals` 与 `events` 记录
94
94
  - 由运行时持有的 tracing correlation id 与 continuity metadata,而不是 provider 私有观测句柄
95
95
  - 由系统托管的重启恢复与中断续跑
96
96
  - 面向高风险 memory / MCP 副作用的默认治理策略
@@ -123,7 +123,7 @@ AI 让 agent 逻辑、工具调用和工作流代码更容易生成,真正更
123
123
 
124
124
  运行时提供:
125
125
 
126
- - `createAgentHarness(workspaceRoot)`、`run(...)`、`memorize(...)`、`recall(...)`、`listMemories(...)`、`updateMemory(...)`、`removeMemory(...)`、`resolveApproval(...)`、`subscribe(...)`、各类查询方法,以及 `stop(...)`
126
+ - `createAgentHarness(workspaceRoot)`、`request(...)`、`memorize(...)`、`recall(...)`、`listMemories(...)`、`updateMemory(...)`、`removeMemory(...)`、`resolveApproval(...)`、`subscribe(...)`、各类查询方法,以及 `stop(...)`
127
127
  - 以 YAML 描述的工作区装配:路由、模型、工具、存储、后端、MCP、恢复与维护等
128
128
  - 通过适配器对接当前的 LangChain v1 与 DeepAgents 执行
129
129
  - 本地 `resources/tools/` 中 `tool({...})` 工具模块与 `resources/skills/` 的发现
@@ -255,12 +255,12 @@ your-workspace/
255
255
  最小用法:
256
256
 
257
257
  ```ts
258
- import { createAgentHarness, run, stop } from "@botbotgo/agent-harness";
258
+ import { createAgentHarness, request, stop } from "@botbotgo/agent-harness";
259
259
 
260
260
  const runtime = await createAgentHarness("/absolute/path/to/workspace");
261
261
 
262
262
  try {
263
- const result = await run(runtime, {
263
+ const result = await request(runtime, {
264
264
  agentId: "auto",
265
265
  input: "Explain what this workspace is for.",
266
266
  });
@@ -274,7 +274,7 @@ try {
274
274
  三分钟心智模型:
275
275
 
276
276
  1. 用 `createAgentHarness(...)` 指向一个 workspace root。
277
- 2. 用 `run(runtime, { ... })` 执行一次请求。
277
+ 2. 用 `request(runtime, { ... })` 执行一次请求。
278
278
  3. 把持久化的运行时记录当成产品资产,而不是只盯着最终回答。
279
279
 
280
280
  如果再压缩成最短产品表述,就是:
@@ -286,7 +286,7 @@ try {
286
286
 
287
287
  - 一个工作区对应一个运行时
288
288
  - YAML 定义装配与策略
289
- - `run(runtime, { ... })` 在该运行时上执行请求
289
+ - `request(runtime, { ... })` 在该运行时上执行请求
290
290
  - 运行时负责生命周期、可观测性与恢复
291
291
 
292
292
  ## 功能列表
@@ -322,6 +322,19 @@ const runtime: AgentHarnessRuntime = await createAgentHarness("/absolute/path/to
322
322
 
323
323
  `createAgentHarness(...)` 会加载工作区、解析 `resources/`、在 `runRoot` 下初始化持久化,并启动运行时维护任务。
324
324
 
325
+ `runtime.spec.resources` 可以挂载多个额外资源包。每个条目既可以指向“包根目录下带有 `resources/` 的目录”,也可以直接指向“自身带有 `package.json` 的资源目录”。
326
+
327
+ ```yaml
328
+ apiVersion: agent-harness/v1alpha1
329
+ kind: Runtime
330
+ metadata:
331
+ name: default
332
+ spec:
333
+ resources:
334
+ - ../shared-tools
335
+ - file:../shared-skills
336
+ ```
337
+
325
338
  `createAgentHarness(..., { load })` 支持工作区加载控制。
326
339
 
327
340
  合并顺序是确定性的:
@@ -345,9 +358,9 @@ const runtime = await createAgentHarness("/path/to/workspace", {
345
358
  ### 发起一次运行
346
359
 
347
360
  ```ts
348
- import { run } from "@botbotgo/agent-harness";
361
+ import { request } from "@botbotgo/agent-harness";
349
362
 
350
- const result = await run(runtime, {
363
+ const result = await request(runtime, {
351
364
  agentId: "orchestra",
352
365
  input: "Summarize the runtime design.",
353
366
  invocation: {
@@ -364,7 +377,7 @@ const result = await run(runtime, {
364
377
  });
365
378
  ```
366
379
 
367
- `run(runtime, { ... })` 会创建或延续持久化会话,并返回 `sessionId`、`requestId`、`state` 以及紧凑文本 `output`。更丰富的上游结果形态仍可通过 `outputContent`、`contentBlocks`、`structuredResponse` 等获得。
380
+ `request(runtime, { ... })` 会创建或延续持久化会话,并返回 `sessionId`、`requestId`、`state` 以及紧凑文本 `output`。更丰富的上游结果形态仍可通过 `outputContent`、`contentBlocks`、`structuredResponse` 等获得。
368
381
 
369
382
  如果产品需要 request 视角的操作界面,例如 review queue 或执行看板,可使用 `listRequests(runtime)` 与 `getRequest(runtime, requestId)`。
370
383
 
@@ -412,7 +425,7 @@ const recalled = await recall(runtime, {
412
425
  ### 由运行时路由
413
426
 
414
427
  ```ts
415
- const result = await run(runtime, {
428
+ const result = await request(runtime, {
416
429
  agentId: "auto",
417
430
  input: "Inspect the repository and explain the release flow.",
418
431
  });
@@ -423,7 +436,7 @@ const result = await run(runtime, {
423
436
  ### 流式输出与事件
424
437
 
425
438
  ```ts
426
- const result = await run(runtime, {
439
+ const result = await request(runtime, {
427
440
  agentId: "orchestra",
428
441
  input: "Inspect the workspace and explain the available tools.",
429
442
  listeners: {
@@ -444,10 +457,10 @@ const result = await run(runtime, {
444
457
 
445
458
  运行时事件流包括:
446
459
 
447
- - `run.created`
448
- - `run.queued`
449
- - `run.dequeued`
450
- - `run.state.changed`
460
+ - `request.created`
461
+ - `request.queued`
462
+ - `request.dequeued`
463
+ - `request.state.changed`
451
464
  - `approval.requested`
452
465
  - `approval.resolved`
453
466
  - `output.delta`
@@ -843,7 +856,7 @@ spec:
843
856
 
844
857
  - `createAgentHarness`
845
858
  - `AgentHarnessRuntime`
846
- - `run`
859
+ - `request`
847
860
  - `resolveApproval`
848
861
  - `subscribe`
849
862
  - `listRequests`
@@ -855,8 +868,8 @@ spec:
855
868
  - `getApproval`
856
869
  - `listArtifacts`
857
870
  - `getArtifact`
858
- - `listRunEvents`
859
- - `exportRunPackage`
871
+ - `listRequestEvents`
872
+ - `exportRequestPackage`
860
873
  - `exportSessionPackage`
861
874
  - `exportEvaluationBundle`
862
875
  - `replayEvaluationBundle`
@@ -891,6 +904,7 @@ ACP transport 说明:
891
904
  - `serveA2aHttp(runtime)` 提供最小可用的 A2A HTTP JSON-RPC bridge 与 agent card discovery,把 `message/send`、`tasks/get`、`tasks/cancel` 映射到现有 session/request runtime surface。
892
905
  - `serveAgUiHttp(runtime)` 提供最小可用的 AG-UI HTTP SSE bridge,把现有 `run + output.delta + final result` 投影成 `RUN_STARTED`、`TEXT_MESSAGE_*` 与 `RUN_FINISHED` 事件,便于 UI 客户端直接接入。
893
906
  - `createRuntimeMcpServer(runtime)` 与 `serveRuntimeMcpOverStdio(runtime)` 会把持久化 runtime 控制面本身暴露成 MCP tools,包括 sessions、requests、approvals、artifacts、events 与 package export helpers。
894
- - `exportRunPackage(...)` 与 `exportSessionPackage(...)` 可把稳定 runtime 记录、transcript、approvals、events 和 artifacts 打包给 operator tooling,而不必直接访问 persistence 内部实现。
907
+ - `listRequestEvents(...)` 与 `exportRequestPackage(...)` request-first 的检查 helper。
908
+ - `exportRequestPackage(...)` 与 `exportSessionPackage(...)` 可把稳定 runtime 记录、transcript、approvals、events 和 artifacts 打包给 operator tooling,而不必直接访问 persistence 内部实现。
895
909
  - `runtime/default.governance.remoteMcp` 现在可以按 MCP server 或 transport 做 allow/deny、审批升级,并把 transport 风险等级写进 runtime governance bundles。
896
910
  - 更详细的 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.181";
1
+ export declare const AGENT_HARNESS_VERSION = "0.0.183";
@@ -1 +1 @@
1
- export const AGENT_HARNESS_VERSION = "0.0.181";
1
+ export const AGENT_HARNESS_VERSION = "0.0.183";
@@ -31,6 +31,15 @@ export function resolveResourcePackageRoot(root) {
31
31
  }
32
32
  return null;
33
33
  }
34
+ function resolveExplicitResourceRoot(root) {
35
+ if (isDirectoryPath(root)) {
36
+ const packageJsonPath = path.join(root, "package.json");
37
+ if (existsSync(packageJsonPath)) {
38
+ return root;
39
+ }
40
+ }
41
+ return resolveResourcePackageRoot(root);
42
+ }
34
43
  export function isExternalSourceLocator(value) {
35
44
  return typeof value === "string" && /^(npm|tgz|file):/.test(value);
36
45
  }
@@ -198,17 +207,9 @@ export async function ensureExternalResourceSource(locator, workspaceRoot) {
198
207
  const parsed = parseExternalSourceLocator(locator);
199
208
  const baseLocator = `${parsed.kind}:${parsed.spec}`;
200
209
  const packageRoot = await ensureExternalSource(baseLocator, workspaceRoot);
201
- const resourcesRoot = path.join(packageRoot, "resources");
202
- if (!existsSync(resourcesRoot) || !statSync(resourcesRoot).isDirectory()) {
203
- throw new Error(`External source ${baseLocator} is missing resources/.`);
204
- }
205
- const resourcePackageJson = path.join(resourcesRoot, "package.json");
206
- if (!existsSync(resourcePackageJson)) {
207
- throw new Error(`External source ${baseLocator} is missing resources/package.json.`);
208
- }
209
- const resourcePackageRoot = resolveResourcePackageRoot(packageRoot);
210
+ const resourcePackageRoot = resolveExplicitResourceRoot(packageRoot);
210
211
  if (!resourcePackageRoot) {
211
- throw new Error(`External source ${baseLocator} is missing resources/package.json.`);
212
+ throw new Error(`External source ${baseLocator} is missing a resource package root or resources/package.json.`);
212
213
  }
213
214
  return parsed.subpath ? path.join(resourcePackageRoot, parsed.subpath) : resourcePackageRoot;
214
215
  }
@@ -235,17 +236,9 @@ export function resolveExternalResourcePath(locator, workspaceRoot) {
235
236
  const parsed = parseExternalSourceLocator(locator);
236
237
  const baseLocator = `${parsed.kind}:${parsed.spec}`;
237
238
  const packageRoot = resolveExternalSourcePath(baseLocator, workspaceRoot);
238
- const resourcesRoot = path.join(packageRoot, "resources");
239
- if (!existsSync(resourcesRoot) || !statSync(resourcesRoot).isDirectory()) {
240
- throw new Error(`External source ${baseLocator} is missing resources/.`);
241
- }
242
- const resourcePackageJson = path.join(resourcesRoot, "package.json");
243
- if (!existsSync(resourcePackageJson)) {
244
- throw new Error(`External source ${baseLocator} is missing resources/package.json.`);
245
- }
246
- const resourcePackageRoot = resolveResourcePackageRoot(packageRoot);
239
+ const resourcePackageRoot = resolveExplicitResourceRoot(packageRoot);
247
240
  if (!resourcePackageRoot) {
248
- throw new Error(`External source ${baseLocator} is missing resources/package.json.`);
241
+ throw new Error(`External source ${baseLocator} is missing a resource package root or resources/package.json.`);
249
242
  }
250
243
  return parsed.subpath ? path.join(resourcePackageRoot, parsed.subpath) : resourcePackageRoot;
251
244
  }
@@ -100,9 +100,10 @@ function validateRoutingTargets(refs, agentsList) {
100
100
  }
101
101
  function resolveLocalResourceRoot(candidate, workspaceRoot) {
102
102
  const resolved = path.resolve(workspaceRoot, candidate);
103
- const resourceRoot = resolveResourcePackageRoot(resolved);
103
+ const directPackageJsonPath = path.join(resolved, "package.json");
104
+ const resourceRoot = existsSync(directPackageJsonPath) ? resolved : resolveResourcePackageRoot(resolved);
104
105
  if (!resourceRoot) {
105
- throw new Error(`Workspace resource ${candidate} is missing resources/package.json.`);
106
+ throw new Error(`Workspace resource ${candidate} is missing package.json or resources/package.json.`);
106
107
  }
107
108
  return resourceRoot;
108
109
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botbotgo/agent-harness",
3
- "version": "0.0.182",
3
+ "version": "0.0.184",
4
4
  "description": "Workspace runtime for multi-agent applications",
5
5
  "type": "module",
6
6
  "packageManager": "npm@10.9.2",