@botbotgo/agent-harness 0.0.308 → 0.0.310
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 +17 -1
- package/README.zh.md +17 -1
- package/dist/acp.d.ts +1 -116
- package/dist/acp.js +1 -310
- package/dist/api.d.ts +4 -2
- package/dist/api.js +4 -1
- package/dist/cli/chat-interactive.d.ts +24 -0
- package/dist/cli/chat-interactive.js +244 -0
- package/dist/cli/chat-rendering.d.ts +9 -0
- package/dist/cli/chat-rendering.js +102 -0
- package/dist/cli/chat-stream.d.ts +23 -0
- package/dist/cli/chat-stream.js +330 -0
- package/dist/cli/chat-ui.d.ts +20 -0
- package/dist/cli/chat-ui.js +198 -0
- package/dist/cli/chat-workspace.d.ts +15 -0
- package/dist/cli/chat-workspace.js +205 -0
- package/dist/cli/main.d.ts +52 -0
- package/dist/cli/main.js +323 -0
- package/dist/cli/managed-service-commands.d.ts +23 -0
- package/dist/cli/managed-service-commands.js +63 -0
- package/dist/cli/managed-service.d.ts +27 -0
- package/dist/cli/managed-service.js +61 -0
- package/dist/cli/options-init-chat.d.ts +16 -0
- package/dist/cli/options-init-chat.js +108 -0
- package/dist/cli/options-runtime.d.ts +27 -0
- package/dist/cli/options-runtime.js +158 -0
- package/dist/cli/options-serve.d.ts +24 -0
- package/dist/cli/options-serve.js +166 -0
- package/dist/cli/options.d.ts +5 -0
- package/dist/cli/options.js +47 -0
- package/dist/cli/process-guards.d.ts +14 -0
- package/dist/cli/process-guards.js +139 -0
- package/dist/cli/request-tree.d.ts +12 -0
- package/dist/cli/request-tree.js +296 -0
- package/dist/cli/runtime-commands.d.ts +15 -0
- package/dist/cli/runtime-commands.js +247 -0
- package/dist/cli/runtime-output.d.ts +5 -0
- package/dist/cli/runtime-output.js +124 -0
- package/dist/cli/server-commands.d.ts +36 -0
- package/dist/cli/server-commands.js +250 -0
- package/dist/cli/workspace.d.ts +6 -0
- package/dist/cli/workspace.js +71 -0
- package/dist/cli.d.ts +1 -67
- package/dist/cli.js +2 -2734
- package/dist/client/acp.d.ts +1 -50
- package/dist/client/acp.js +1 -219
- package/dist/client/in-process.d.ts +5 -5
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +1 -1
- package/dist/contracts/runtime-evaluation.d.ts +103 -0
- package/dist/contracts/runtime-evaluation.js +1 -0
- package/dist/contracts/runtime-memory.d.ts +162 -0
- package/dist/contracts/runtime-memory.js +1 -0
- package/dist/contracts/runtime-observability.d.ts +248 -0
- package/dist/contracts/runtime-observability.js +1 -0
- package/dist/contracts/runtime-requests.d.ts +342 -0
- package/dist/contracts/runtime-requests.js +1 -0
- package/dist/contracts/runtime-scheduling.d.ts +146 -0
- package/dist/contracts/runtime-scheduling.js +1 -0
- package/dist/contracts/runtime.d.ts +5 -1042
- package/dist/contracts/runtime.js +27 -1
- package/dist/flow/build-flow-graph.js +4 -875
- package/dist/flow/flow-graph-normalization.d.ts +56 -0
- package/dist/flow/flow-graph-normalization.js +214 -0
- package/dist/flow/flow-graph-runtime.d.ts +8 -0
- package/dist/flow/flow-graph-runtime.js +107 -0
- package/dist/flow/flow-graph-upstream.d.ts +18 -0
- package/dist/flow/flow-graph-upstream.js +498 -0
- package/dist/flow/types.d.ts +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/init-project.d.ts +1 -12
- package/dist/init-project.js +1 -651
- package/dist/{procedural → knowledge/procedural}/manager.d.ts +3 -3
- package/dist/{procedural → knowledge/procedural}/manager.js +6 -6
- package/dist/mcp.d.ts +2 -62
- package/dist/mcp.js +2 -253
- package/dist/package-version.d.ts +1 -1
- package/dist/package-version.js +1 -1
- package/dist/persistence/file-store.js +1 -1
- package/dist/persistence/sqlite-runtime.d.ts +19 -0
- package/dist/persistence/sqlite-runtime.js +86 -0
- package/dist/persistence/sqlite-store.js +11 -99
- package/dist/{request-events.d.ts → projections/request-events.d.ts} +1 -1
- package/dist/{upstream-events.js → projections/upstream-events.js} +1 -1
- package/dist/protocol/a2a/http-discovery.d.ts +39 -0
- package/dist/protocol/a2a/http-discovery.js +178 -0
- package/dist/protocol/a2a/http-rpc.d.ts +28 -0
- package/dist/protocol/a2a/http-rpc.js +623 -0
- package/dist/protocol/a2a/http.d.ts +72 -1
- package/dist/protocol/a2a/http.js +14 -1124
- package/dist/protocol/a2a/task-state.d.ts +29 -0
- package/dist/protocol/a2a/task-state.js +317 -0
- package/dist/protocol/acp/client.js +1 -1
- package/dist/protocol/acp/harness-client.d.ts +50 -0
- package/dist/protocol/acp/harness-client.js +219 -0
- package/dist/protocol/acp/server.d.ts +116 -0
- package/dist/protocol/acp/server.js +310 -0
- package/dist/protocol/ag-ui/http.js +1 -1
- package/dist/protocol/mcp/server.d.ts +76 -0
- package/dist/protocol/mcp/server.js +428 -0
- package/dist/resource/backend/workspace-scoped-backend.d.ts +40 -0
- package/dist/resource/backend/workspace-scoped-backend.js +296 -0
- package/dist/resource/mcp/tool-support.d.ts +35 -0
- package/dist/resource/mcp/tool-support.js +296 -0
- package/dist/resource/mcp-tool-support.d.ts +2 -35
- package/dist/resource/mcp-tool-support.js +2 -296
- package/dist/resource/providers/resource-provider.d.ts +22 -0
- package/dist/resource/providers/resource-provider.js +215 -0
- package/dist/resource/resource-impl.d.ts +3 -33
- package/dist/resource/resource-impl.js +2 -808
- package/dist/resource/resource-types.d.ts +33 -0
- package/dist/resource/resource-types.js +1 -0
- package/dist/resource/tools/function-tool-resolver.d.ts +2 -0
- package/dist/resource/tools/function-tool-resolver.js +306 -0
- package/dist/runtime/adapter/middleware-assembly.js +1 -1
- package/dist/runtime/adapter/model/invocation-request.js +2 -2
- package/dist/runtime/adapter/model/message-assembly.js +1 -1
- package/dist/runtime/agent-runtime-adapter.d.ts +3 -63
- package/dist/runtime/agent-runtime-adapter.js +5 -233
- package/dist/runtime/agent-runtime-assembly.d.ts +67 -0
- package/dist/runtime/agent-runtime-assembly.js +211 -0
- package/dist/runtime/harness/background-runtime.d.ts +1 -1
- package/dist/runtime/harness/events/event-sink.js +1 -1
- package/dist/runtime/harness/events/runtime-event-operations.d.ts +1 -1
- package/dist/runtime/harness/events/streaming.js +1 -1
- package/dist/runtime/harness/public-shapes.d.ts +43 -0
- package/dist/runtime/harness/public-shapes.js +186 -0
- package/dist/runtime/harness/run/inspection.js +2 -2
- package/dist/runtime/harness/run/resources.js +1 -1
- package/dist/runtime/harness/run/surface-semantics.js +1 -1
- package/dist/runtime/harness/system/inventory.d.ts +1 -1
- package/dist/runtime/harness/system/inventory.js +2 -2
- package/dist/runtime/harness/system/policy-engine.js +1 -1
- package/dist/runtime/harness/system/runtime-memory-manager.js +1 -1
- package/dist/runtime/harness/system/skill-requirements.d.ts +1 -1
- package/dist/runtime/harness/system/skill-requirements.js +1 -1
- package/dist/runtime/harness.d.ts +3 -2
- package/dist/runtime/harness.js +11 -191
- package/dist/runtime/maintenance/checkpoint-maintenance.js +1 -1
- package/dist/runtime/maintenance/runtime-record-maintenance.js +1 -1
- package/dist/runtime/parsing/output-content.d.ts +11 -0
- package/dist/runtime/parsing/output-content.js +442 -0
- package/dist/runtime/parsing/output-parsing.d.ts +3 -29
- package/dist/runtime/parsing/output-parsing.js +3 -806
- package/dist/runtime/parsing/output-recovery.d.ts +14 -0
- package/dist/runtime/parsing/output-recovery.js +288 -0
- package/dist/runtime/parsing/output-tool-args.d.ts +4 -0
- package/dist/runtime/parsing/output-tool-args.js +120 -0
- package/dist/runtime/support/runtime-factories.js +1 -1
- package/dist/scaffold/init-project.d.ts +12 -0
- package/dist/scaffold/init-project.js +651 -0
- package/dist/{extensions.d.ts → tooling/extensions.d.ts} +1 -1
- package/dist/{extensions.js → tooling/extensions.js} +3 -3
- package/dist/{tool-modules.d.ts → tooling/module-loader.d.ts} +1 -1
- package/dist/{tool-modules.js → tooling/module-loader.js} +2 -2
- package/dist/workspace/agent-binding-compiler.js +2 -2
- package/dist/workspace/compile.js +2 -2
- package/dist/workspace/object-loader-paths.d.ts +11 -0
- package/dist/workspace/object-loader-paths.js +75 -0
- package/dist/workspace/object-loader-readers.d.ts +21 -0
- package/dist/workspace/object-loader-readers.js +187 -0
- package/dist/workspace/object-loader.d.ts +0 -1
- package/dist/workspace/object-loader.js +6 -260
- package/dist/workspace/resource-compilers.js +1 -1
- package/dist/workspace/support/discovery.js +1 -1
- package/package.json +1 -1
- package/dist/runtime/adapter/index.d.ts +0 -13
- package/dist/runtime/adapter/index.js +0 -13
- package/dist/runtime/harness/index.d.ts +0 -19
- package/dist/runtime/harness/index.js +0 -19
- package/dist/runtime/maintenance/index.d.ts +0 -4
- package/dist/runtime/maintenance/index.js +0 -4
- package/dist/runtime/parsing/index.d.ts +0 -2
- package/dist/runtime/parsing/index.js +0 -2
- package/dist/runtime/support/index.d.ts +0 -4
- package/dist/runtime/support/index.js +0 -4
- package/dist/workspace/support/index.d.ts +0 -2
- package/dist/workspace/support/index.js +0 -2
- /package/dist/{procedural → knowledge/procedural}/config.d.ts +0 -0
- /package/dist/{procedural → knowledge/procedural}/config.js +0 -0
- /package/dist/{procedural → knowledge/procedural}/index.d.ts +0 -0
- /package/dist/{procedural → knowledge/procedural}/index.js +0 -0
- /package/dist/{presentation.d.ts → projections/presentation.d.ts} +0 -0
- /package/dist/{presentation.js → projections/presentation.js} +0 -0
- /package/dist/{request-events.js → projections/request-events.js} +0 -0
- /package/dist/{upstream-events.d.ts → projections/upstream-events.d.ts} +0 -0
- /package/dist/runtime/{support → env}/runtime-env.d.ts +0 -0
- /package/dist/runtime/{support → env}/runtime-env.js +0 -0
- /package/dist/runtime/{support → layout}/runtime-layout.d.ts +0 -0
- /package/dist/runtime/{support → layout}/runtime-layout.js +0 -0
- /package/dist/runtime/{support → prompts}/runtime-prompts.d.ts +0 -0
- /package/dist/runtime/{support → prompts}/runtime-prompts.js +0 -0
- /package/dist/runtime/{support → skills}/skill-metadata.d.ts +0 -0
- /package/dist/runtime/{support → skills}/skill-metadata.js +0 -0
package/README.md
CHANGED
|
@@ -128,6 +128,20 @@ This file is both a quickstart and a long reference—you do not need to read it
|
|
|
128
128
|
| **Operations / governance** | [Runtime capabilities at a glance](#readme-en-runtime-glance) → [Primary use cases](#readme-en-use-cases) | [Runtime operations](./docs/development/runtime-operations.html) and [`docs/tool-execution-policy.md`](./docs/tool-execution-policy.md). |
|
|
129
129
|
| **API lookup** | Skip to [API Summary](#readme-en-api-summary) | Use it as a bookmarked index; the [API reference](./docs/development/api-reference.html) has fuller detail. |
|
|
130
130
|
|
|
131
|
+
## Repository Source Layout
|
|
132
|
+
|
|
133
|
+
When you work on the open-source package itself, treat `src/` as a layered tree instead of one flat folder:
|
|
134
|
+
|
|
135
|
+
- top-level `src/*.ts` files should stay as stable public entrypoints or compatibility shims
|
|
136
|
+
- public API implementation belongs under `src/public/`
|
|
137
|
+
- protocol servers and transports belong under `src/protocol/**`
|
|
138
|
+
- terminal, projection, and rendering helpers belong under `src/surface/` or `src/cli/`
|
|
139
|
+
- scaffolding and bootstrap generation belong under `src/scaffold/`
|
|
140
|
+
- extension and tool-definition machinery belong under `src/tooling/`
|
|
141
|
+
- runtime internals stay under `src/runtime/`, persistence under `src/persistence/`, and workspace assembly under `src/workspace/`
|
|
142
|
+
|
|
143
|
+
For new code, prefer the domain folder first. Only add a new top-level `src/*.ts` file when it is intentionally part of the package entry surface.
|
|
144
|
+
|
|
131
145
|
## License & Commercial Support
|
|
132
146
|
|
|
133
147
|
This project is licensed under **Apache License 2.0**.
|
|
@@ -1178,6 +1192,7 @@ ACP transport notes:
|
|
|
1178
1192
|
- ACP transport validation now covers the reference-client core flow: capability discovery, request submit, session lookup, request lookup, invalid-JSON handling, notification calls without response ids, stdio JSON-RPC, and HTTP plus SSE runtime notifications.
|
|
1179
1193
|
- Cross-protocol conformance now has an explicit regression gate as well: ACP submission, A2A task lookup and continuation, and runtime MCP inspection must all project the same persisted `sessionId` / `requestId` runtime records instead of drifting into surface-specific identifiers or side stores.
|
|
1180
1194
|
- For the thinnest editor or CLI starter, begin with `agent-harness acp serve --workspace . --transport stdio` and mirror the `examples/03_protocol-surfaces/app/acp-stdio/main.mjs` wire shape. Applications that want an in-process reference client can use `createAcpStdioClient(...)` to issue JSON-RPC requests and route runtime notifications without hand-rolling line parsing.
|
|
1195
|
+
- When a local ACP HTTP endpoint should stay up beyond one foreground shell, use `botbotgo acp start --workspace . --host 127.0.0.1 --port 8787` and later `botbotgo acp stop --workspace .`. The CLI records the managed process under `.botbotgo/services/` so local operators can start and stop it without a second process manager.
|
|
1181
1196
|
- `botbotgo` is the shortest local terminal entrypoint for a published install. It defaults the workspace to the current directory, so teams can `cd` into their own runtime workspace and run `botbotgo` or `botbotgo "..."` directly. `agent-harness` keeps the same implicit-chat behavior, and `-w/--workspace` still lets one shell point at another workspace when needed.
|
|
1182
1197
|
- `agent-harness chat --workspace .` still acts as a local terminal shell over the shared `HarnessClient` contract when you want the explicit subcommand form: the default `stdio` path runs directly in-process against the workspace runtime, while `--transport http --host <host> --port <port>` can still target an already-running ACP HTTP endpoint. One-shot use can pass `--message`, while interactive mode supports `/context`, `/new`, `/agent <agentId>`, `/sessions`, `/requests`, `/resume <sessionId>`, `/approvals`, `/approve`, `/reject`, `/cancel`, `/events`, `/trace`, `/health`, `/overview`, `/session`, `/request [requestId]`, and `/exit`. `/resume` now validates the target session, restores its latest request id, and rehydrates the active agent context; `/request <requestId>` can switch the active request context to a persisted request; `/new` clears the current session/request context without leaving the shell. Terminal chat now keeps one operator-facing flow: it streams tool and progress events as they happen and still prints the full final answer, instead of switching to a separate request-tree-only mode.
|
|
1183
1198
|
- Local repo usage differs from the published binary on purpose. After cloning the repo, use `npm run chat -- --workspace ./config` or `npm run agent-harness -- chat --workspace ./config`. The extra `--` matters: without it, npm treats `--workspace` as npm's own workspace flag. The standalone `agent-harness ...` command only works after the package has been installed or linked so the `bin` entry is on your `PATH`.
|
|
@@ -1186,8 +1201,9 @@ ACP transport notes:
|
|
|
1186
1201
|
- Chat startup now also performs a lightweight workspace-model preflight for the local Ollama path. If the configured endpoint is unreachable or responds with `404 page not found`, the shell prints that warning before the first prompt so endpoint mismatches show up immediately instead of only after the first failed message.
|
|
1187
1202
|
- The interactive prompt now carries the live `agent`, `session`, and short `request` identifier together, so after each reply and during shell-history navigation the user stays anchored to the current runtime turn instead of dropping back to a bare input prompt.
|
|
1188
1203
|
- `serveA2aHttp(runtime)` exposes an A2A-compatible HTTP JSON-RPC bridge plus agent card discovery, mapping both existing methods such as `message/send` and A2A v1.0 PascalCase methods such as `SendMessage`, `SendStreamingMessage`, `GetTask`, `ListTasks`, `CancelTask`, `SubscribeToTask`, `GetAgentCard`, `GetExtendedAgentCard`, and task push-notification config methods onto the existing session/request runtime surface. The bridge now advertises both `1.0` and `0.3` JSON-RPC interfaces, answers `HEAD` / `OPTIONS` discovery on the agent-card path, sets supported-version discovery headers, can optionally expose registry URLs plus detached signed-card metadata for surrounding discovery systems, validates `A2A-Version`, records `A2A-Extensions` into runtime invocation metadata, publishes `TASK_STATE_*` statuses plus the `{ task }` `SendMessage` wrapper, streams an initial `{ task }` snapshot plus later `{ statusUpdate }` payloads over SSE for v1 streaming methods, and can send best-effort webhook task snapshots for configured push notification receivers.
|
|
1204
|
+
- For a managed local bridge, use `botbotgo a2a start --workspace . --host 127.0.0.1 --port 8080` and later `botbotgo a2a stop --workspace .`. This uses the same `.botbotgo/services/` state directory as ACP so both local protocol bridges follow one terminal-first workflow.
|
|
1189
1205
|
- `serveAgUiHttp(runtime)` exposes an AG-UI-compatible HTTP SSE bridge that projects runtime lifecycle, safe progress commentary, text output, upstream thinking, step progress, and tool calls onto `RUN_*`, `STATUS_UPDATE`, `TEXT_MESSAGE_*`, `THINKING_TEXT_MESSAGE_*`, `STEP_*`, and `TOOL_CALL_*` events for UI clients.
|
|
1190
|
-
- `createRuntimeMcpServer(runtime)` and `
|
|
1206
|
+
- `createRuntimeMcpServer(runtime)`, `serveRuntimeMcpOverStdio(runtime)`, and `serveRuntimeMcpOverStreamableHttp(runtime)` expose the persisted runtime control surface itself as MCP tools, including sessions, requests, approvals, artifacts, events, and package export helpers. `botbotgo mcp serve --transport streamable-http --host 127.0.0.1 --port 8090` serves the same tool surface over Streamable HTTP, and `botbotgo mcp start|stop` manages that background endpoint for one workspace.
|
|
1191
1207
|
- `listRequestEvents(...)`, `listRequestTraceItems(...)`, and `exportRequestPackage(...)` are the request-first inspection helpers.
|
|
1192
1208
|
- `exportRequestPackage(...)` and `exportSessionPackage(...)` package stable runtime records, transcript, approvals, events, artifacts, and governance evidence for operator tooling without reaching into persistence internals.
|
|
1193
1209
|
- `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. MCP server catalogs can also declare trust tier, access mode, tenant scope, approval policy, prompt-injection risk, and OAuth scope metadata so governance bundles capture why one remote tool is treated as high-risk. Tool policy overrides can also set `decisionMode: manual | auto-approve | auto-reject | deny-and-continue` so operator evidence and execution behavior stay aligned.
|
package/README.zh.md
CHANGED
|
@@ -126,6 +126,20 @@ durable memory 的写入现在也会在模型做 mutation reconciliation 之前
|
|
|
126
126
|
| **运维 / 治理** | [运行时能力速览](#readme-zh-runtime-glance) → [典型应用场景](#readme-zh-use-cases) | [运行时运维](./docs/development/zh/runtime-operations.html) 与 [`docs/tool-execution-policy.md`](./docs/tool-execution-policy.md)。 |
|
|
127
127
|
| **查 API** | 跳转到文末 [API 摘要](#readme-zh-api-summary) | 日常以[API 参考](./docs/development/zh/api-reference.html)为准。 |
|
|
128
128
|
|
|
129
|
+
## 仓库源码分层
|
|
130
|
+
|
|
131
|
+
如果你维护的是这个开源包本身,请把 `src/` 当成分层目录,而不是平铺文件夹:
|
|
132
|
+
|
|
133
|
+
- `src/*.ts` 顶层文件尽量只保留稳定公共入口或兼容 shim
|
|
134
|
+
- 公共 API 实现放进 `src/public/`
|
|
135
|
+
- 协议服务与传输实现放进 `src/protocol/**`
|
|
136
|
+
- 终端、事件投影与渲染辅助放进 `src/surface/` 或 `src/cli/`
|
|
137
|
+
- 脚手架与项目初始化逻辑放进 `src/scaffold/`
|
|
138
|
+
- 扩展注册、工具定义与模块装载放进 `src/tooling/`
|
|
139
|
+
- runtime 内部继续放在 `src/runtime/`,持久化放在 `src/persistence/`,workspace 装配放在 `src/workspace/`
|
|
140
|
+
|
|
141
|
+
新增实现代码时,优先进入对应 domain 子目录。只有当一个文件本来就属于包的公开入口面时,才新增顶层 `src/*.ts`。
|
|
142
|
+
|
|
129
143
|
## 许可证与商业支持
|
|
130
144
|
|
|
131
145
|
本项目采用 **Apache License 2.0** 开源许可。[查看 LICENSE](./LICENSE)
|
|
@@ -1144,6 +1158,7 @@ ACP transport 说明:
|
|
|
1144
1158
|
- ACP transport 现已覆盖核心参考客户端流程验证:capability discovery、request submit、session lookup、request lookup、invalid JSON 处理、无 id notification 不返回响应,以及 stdio JSON-RPC 与 HTTP + SSE runtime notifications。
|
|
1145
1159
|
- 现在还额外有一条跨协议一致性回归门:ACP 发起的 request、A2A 读取或继续的 task,以及 runtime MCP 暴露的检查结果,必须始终指向同一组持久化 `sessionId` / `requestId` 运行时记录,不能漂移成各协议各自维护的标识体系。
|
|
1146
1160
|
- 如果要从最薄的一层 editor / CLI starter 开始,优先用 `agent-harness acp serve --workspace . --transport stdio`,并直接参考 `examples/03_protocol-surfaces/app/acp-stdio/main.mjs` 的 wire shape。需要在应用内使用 reference client 时,可直接用 `createAcpStdioClient(...)` 发起 JSON-RPC 请求并分流 runtime notifications,避免每个 sidecar 自己重写 line parsing。
|
|
1161
|
+
- 如果本地 ACP HTTP endpoint 需要在前台 shell 之外持续运行,可使用 `botbotgo acp start --workspace . --host 127.0.0.1 --port 8787`,之后再用 `botbotgo acp stop --workspace .` 停止。CLI 会把受管进程记录到 `.botbotgo/services/` 下,因此本地运维不必再额外引入第二套进程管理器。
|
|
1147
1162
|
- 对发布后的安装包来说,`botbotgo` 是最短的本地终端入口。它会默认把当前目录当作 workspace,所以团队只需要 `cd` 到自己的 runtime workspace,然后直接运行 `botbotgo` 或 `botbotgo "..."`。`agent-harness` 也保留同样的隐式 chat 行为;如果要从同一个 shell 指向别的 workspace,继续用 `-w/--workspace` 即可。
|
|
1148
1163
|
- `agent-harness chat --workspace .` 则继续保留为显式子命令形式的本地终端壳:默认 `stdio` 路径会直接在当前进程里连接 workspace runtime,而 `--transport http --host <host> --port <port>` 仍然可以直连已运行的 ACP HTTP endpoint。一次性调用可用 `--message`,交互模式则支持 `/context`、`/new`、`/agent <agentId>`、`/sessions`、`/requests`、`/resume <sessionId>`、`/approvals`、`/approve`、`/reject`、`/cancel`、`/events`、`/trace`、`/health`、`/overview`、`/session`、`/request [requestId]` 与 `/exit`。`/resume` 现在会先校验目标 session,恢复它的 latest request id,并同步 active agent context;`/request <requestId>` 可以把当前上下文切到某个已持久化 request;`/new` 则会在不退出 shell 的情况下清空当前 session/request context。终端 chat 现在统一走一条面向 operator 的输出路径:tool 和进度事件会实时打印,最终完整答复也会继续输出,而不再切到单独的 request-tree-only 模式。
|
|
1149
1164
|
- 如果是在仓库源码目录里直接运行,请使用 `npm run chat -- --workspace ./config`,或者 `npm run agent-harness -- chat --workspace ./config`。这里额外的 `--` 不能省略,否则 npm 会把 `--workspace` 当成它自己的 workspace 参数。只有在包已经被安装或 `npm link` 到系统环境后,`agent-harness ...` 这个独立命令才会出现在 `PATH` 里。
|
|
@@ -1152,8 +1167,9 @@ ACP transport 说明:
|
|
|
1152
1167
|
- chat 启动时现在还会对本地 Ollama 路径做一次轻量 preflight。如果当前 endpoint 不可达,或者直接返回 `404 page not found`,shell 会在第一条 prompt 之前先打印这条告警,这样 endpoint 配错的问题会在启动时立即暴露,而不必等第一条消息失败后才知道。
|
|
1153
1168
|
- 交互式 prompt 现在会同时显示当前 `agent`、`session` 和短 `request` 标识,因此每轮回复之后以及使用 shell 历史记录时,用户都还能清楚地看到自己正处在哪个 runtime turn 上,而不会掉回一个没有上下文的裸输入提示。
|
|
1154
1169
|
- `serveA2aHttp(runtime)` 提供 A2A HTTP JSON-RPC bridge 与 agent card discovery,同时兼容 `message/send` 这类旧方法,以及 `SendMessage`、`SendStreamingMessage`、`GetTask`、`ListTasks`、`CancelTask`、`SubscribeToTask`、`GetAgentCard`、`GetExtendedAgentCard` 与 task push-notification config 这类 A2A v1.0 方法,并统一映射到现有 session/request 运行记录。bridge 现在会同时声明 `1.0` 与 `0.3` 两个 JSON-RPC interface、在 agent card 路径上响应 `HEAD` / `OPTIONS` discovery、写出支持版本的 discovery headers、可选暴露 registry URL 与 detached signed-card metadata 供外围发现系统使用、校验 `A2A-Version`、把 `A2A-Extensions` 记录进 runtime invocation metadata、发布 `TASK_STATE_*` 状态与 `SendMessage` 的 `{ task }` wrapper、在 v1 streaming 方法上先通过 SSE 输出 `{ task }` 初始快照,再输出 `{ statusUpdate }` 增量状态,并可向已配置的 webhook receiver 发送 best-effort task push notifications。
|
|
1170
|
+
- 如果要把本地 A2A bridge 作为受管后台服务运行,可使用 `botbotgo a2a start --workspace . --host 127.0.0.1 --port 8080`,之后再用 `botbotgo a2a stop --workspace .` 停止。它与 ACP 共用 `.botbotgo/services/` 状态目录,因此两个本地协议桥都可以沿用同一套终端优先运维流程。
|
|
1155
1171
|
- `serveAgUiHttp(runtime)` 提供 AG-UI HTTP SSE bridge,把 runtime 生命周期、安全进度播报、文本输出、upstream thinking、step 进度与 tool call 投影成 `RUN_*`、`STATUS_UPDATE`、`TEXT_MESSAGE_*`、`THINKING_TEXT_MESSAGE_*`、`STEP_*` 与 `TOOL_CALL_*` 事件,便于 UI 客户端直接接入。
|
|
1156
|
-
- `createRuntimeMcpServer(runtime)` 与 `
|
|
1172
|
+
- `createRuntimeMcpServer(runtime)`、`serveRuntimeMcpOverStdio(runtime)` 与 `serveRuntimeMcpOverStreamableHttp(runtime)` 会把持久化 runtime 控制面本身暴露成 MCP tools,包括 sessions、requests、approvals、artifacts、events 与 package export helpers。`botbotgo mcp serve --transport streamable-http --host 127.0.0.1 --port 8090` 会把同一套控制面作为 Streamable HTTP 暴露出去,而 `botbotgo mcp start|stop` 可直接托管该后台 endpoint。
|
|
1157
1173
|
- `listRequestEvents(...)`、`listRequestTraceItems(...)` 与 `exportRequestPackage(...)` 是 request-first 的检查 helper。
|
|
1158
1174
|
- `exportRequestPackage(...)` 与 `exportSessionPackage(...)` 可把稳定 runtime 记录、transcript、approvals、events、artifacts 与 governance evidence 一起打包给管理工具,而不必直接访问 persistence 内部实现。
|
|
1159
1175
|
- `runtime/default.governance.remoteMcp` 现在可以按 MCP server 或 transport 做 allow/deny、审批升级,并把 transport 风险等级写进 runtime governance bundles。MCP server catalog 也可以声明 trust tier、access mode、tenant scope、approval policy、prompt-injection risk 与 OAuth scope 元数据,让治理快照能解释为什么某个远端工具被视为高风险。tool policy override 也可以声明 `decisionMode: manual | auto-approve | auto-reject | deny-and-continue`,让治理快照与实际执行路径保持一致。
|
package/dist/acp.d.ts
CHANGED
|
@@ -1,116 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { AgentHarnessRuntime } from "./runtime/harness.js";
|
|
3
|
-
import { getApproval, type PublicRequestListeners } from "./api.js";
|
|
4
|
-
type JsonRpcId = string | number | null;
|
|
5
|
-
export type AcpJsonRpcRequest = {
|
|
6
|
-
jsonrpc?: "2.0";
|
|
7
|
-
id?: JsonRpcId;
|
|
8
|
-
method: string;
|
|
9
|
-
params?: unknown;
|
|
10
|
-
};
|
|
11
|
-
export type AcpJsonRpcError = {
|
|
12
|
-
jsonrpc: "2.0";
|
|
13
|
-
id: JsonRpcId;
|
|
14
|
-
error: {
|
|
15
|
-
code: number;
|
|
16
|
-
message: string;
|
|
17
|
-
data?: unknown;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
export type AcpJsonRpcSuccess = {
|
|
21
|
-
jsonrpc: "2.0";
|
|
22
|
-
id: JsonRpcId;
|
|
23
|
-
result: unknown;
|
|
24
|
-
};
|
|
25
|
-
export type AcpJsonRpcResponse = AcpJsonRpcError | AcpJsonRpcSuccess;
|
|
26
|
-
export type AcpSessionRecord = SessionRecord;
|
|
27
|
-
export type AcpRequestRecord = RequestRecord;
|
|
28
|
-
export type AcpApproval = Awaited<ReturnType<typeof getApproval>> extends infer T ? Exclude<T, null> : never;
|
|
29
|
-
export type AcpArtifact = ArtifactRecord & {
|
|
30
|
-
content?: unknown;
|
|
31
|
-
};
|
|
32
|
-
export type AcpRequestParams = Omit<Extract<RequestOptions, {
|
|
33
|
-
input: unknown;
|
|
34
|
-
}>, "listeners"> & {
|
|
35
|
-
sessionId?: string;
|
|
36
|
-
streamId?: string;
|
|
37
|
-
listeners?: PublicRequestListeners;
|
|
38
|
-
};
|
|
39
|
-
export type AcpServerCapabilities = {
|
|
40
|
-
sessions: {
|
|
41
|
-
list: true;
|
|
42
|
-
get: true;
|
|
43
|
-
summaries: true;
|
|
44
|
-
};
|
|
45
|
-
requests: {
|
|
46
|
-
submit: true;
|
|
47
|
-
list: true;
|
|
48
|
-
get: true;
|
|
49
|
-
plan: {
|
|
50
|
-
get: true;
|
|
51
|
-
};
|
|
52
|
-
cancel: true;
|
|
53
|
-
stream: true;
|
|
54
|
-
trace: {
|
|
55
|
-
list: true;
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
approvals: {
|
|
59
|
-
list: true;
|
|
60
|
-
get: true;
|
|
61
|
-
resolve: true;
|
|
62
|
-
};
|
|
63
|
-
artifacts: {
|
|
64
|
-
list: true;
|
|
65
|
-
read: true;
|
|
66
|
-
};
|
|
67
|
-
events: {
|
|
68
|
-
subscribe: true;
|
|
69
|
-
list: true;
|
|
70
|
-
};
|
|
71
|
-
runtime: {
|
|
72
|
-
health: true;
|
|
73
|
-
overview: true;
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
export type AcpEventNotification = {
|
|
77
|
-
jsonrpc: "2.0";
|
|
78
|
-
method: "events.runtime";
|
|
79
|
-
params: {
|
|
80
|
-
event: {
|
|
81
|
-
eventId: string;
|
|
82
|
-
eventType: string;
|
|
83
|
-
timestamp: string;
|
|
84
|
-
sessionId: string;
|
|
85
|
-
requestId: string;
|
|
86
|
-
sequence: number;
|
|
87
|
-
source: HarnessEvent["source"];
|
|
88
|
-
payload: Record<string, unknown>;
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
export type AcpStreamNotification = {
|
|
93
|
-
jsonrpc: "2.0";
|
|
94
|
-
method: "requests.stream";
|
|
95
|
-
params: {
|
|
96
|
-
streamId: string;
|
|
97
|
-
item: HarnessStreamItem;
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
export type AcpNotification = AcpEventNotification | AcpStreamNotification;
|
|
101
|
-
export declare class AgentHarnessAcpServer {
|
|
102
|
-
private readonly runtime;
|
|
103
|
-
private readonly listeners;
|
|
104
|
-
constructor(runtime: AgentHarnessRuntime);
|
|
105
|
-
capabilities(): AcpServerCapabilities;
|
|
106
|
-
subscribe(listener: (notification: AcpNotification) => void): () => void;
|
|
107
|
-
handle(request: AcpJsonRpcRequest): Promise<AcpJsonRpcResponse | undefined>;
|
|
108
|
-
private methodExists;
|
|
109
|
-
private emitNotification;
|
|
110
|
-
private dispatch;
|
|
111
|
-
private submitStreamingRequest;
|
|
112
|
-
}
|
|
113
|
-
export declare function createAcpServer(runtime: AgentHarnessRuntime): AgentHarnessAcpServer;
|
|
114
|
-
export { createAcpStdioClient } from "./protocol/acp/client.js";
|
|
115
|
-
export { createAcpHttpClient } from "./protocol/acp/client.js";
|
|
116
|
-
export type { AcpHttpClient, AcpHttpClientOptions, AcpStdioClient, AcpStdioClientOptions } from "./protocol/acp/client.js";
|
|
1
|
+
export * from "./protocol/acp/server.js";
|
package/dist/acp.js
CHANGED
|
@@ -1,310 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const CAPABILITIES = {
|
|
3
|
-
sessions: { list: true, get: true, summaries: true },
|
|
4
|
-
requests: { submit: true, list: true, get: true, plan: { get: true }, cancel: true, stream: true, trace: { list: true } },
|
|
5
|
-
approvals: { list: true, get: true, resolve: true },
|
|
6
|
-
artifacts: { list: true, read: true },
|
|
7
|
-
events: { subscribe: true, list: true },
|
|
8
|
-
runtime: { health: true, overview: true },
|
|
9
|
-
};
|
|
10
|
-
function asObject(value, method) {
|
|
11
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
12
|
-
throw new Error(`${method} requires an object params payload.`);
|
|
13
|
-
}
|
|
14
|
-
return value;
|
|
15
|
-
}
|
|
16
|
-
function readOptionalString(value) {
|
|
17
|
-
return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
|
|
18
|
-
}
|
|
19
|
-
function readRequiredString(value, field, method) {
|
|
20
|
-
const normalized = readOptionalString(value);
|
|
21
|
-
if (!normalized) {
|
|
22
|
-
throw new Error(`${method} requires ${field}.`);
|
|
23
|
-
}
|
|
24
|
-
return normalized;
|
|
25
|
-
}
|
|
26
|
-
function toNotification(event) {
|
|
27
|
-
return {
|
|
28
|
-
jsonrpc: "2.0",
|
|
29
|
-
method: "events.runtime",
|
|
30
|
-
params: {
|
|
31
|
-
event: {
|
|
32
|
-
eventId: event.eventId,
|
|
33
|
-
eventType: event.eventType,
|
|
34
|
-
timestamp: event.timestamp,
|
|
35
|
-
sessionId: event.sessionId,
|
|
36
|
-
requestId: event.requestId,
|
|
37
|
-
sequence: event.sequence,
|
|
38
|
-
source: event.source,
|
|
39
|
-
payload: event.payload,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function toStreamNotification(streamId, item) {
|
|
45
|
-
return {
|
|
46
|
-
jsonrpc: "2.0",
|
|
47
|
-
method: "requests.stream",
|
|
48
|
-
params: {
|
|
49
|
-
streamId,
|
|
50
|
-
item,
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
async function readArtifactContent(runtime, params) {
|
|
55
|
-
const method = "artifacts.read";
|
|
56
|
-
const sessionId = readRequiredString(params.sessionId, "sessionId", method);
|
|
57
|
-
const requestId = readRequiredString(params.requestId, "requestId", method);
|
|
58
|
-
const artifactPath = readRequiredString(params.artifactPath, "artifactPath", method);
|
|
59
|
-
const listing = await listRequestArtifacts(runtime, { sessionId, requestId });
|
|
60
|
-
const artifact = listing.items.find((item) => item.path === artifactPath);
|
|
61
|
-
if (!artifact) {
|
|
62
|
-
throw new Error(`Artifact not found for ${requestId}: ${artifactPath}`);
|
|
63
|
-
}
|
|
64
|
-
return {
|
|
65
|
-
...artifact,
|
|
66
|
-
content: await getArtifact(runtime, { sessionId, requestId, artifactPath }),
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
export class AgentHarnessAcpServer {
|
|
70
|
-
runtime;
|
|
71
|
-
listeners = new Set();
|
|
72
|
-
constructor(runtime) {
|
|
73
|
-
this.runtime = runtime;
|
|
74
|
-
this.runtime.subscribe((event) => {
|
|
75
|
-
this.emitNotification(toNotification(event));
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
capabilities() {
|
|
79
|
-
return CAPABILITIES;
|
|
80
|
-
}
|
|
81
|
-
subscribe(listener) {
|
|
82
|
-
this.listeners.add(listener);
|
|
83
|
-
return () => {
|
|
84
|
-
this.listeners.delete(listener);
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
async handle(request) {
|
|
88
|
-
const id = request.id ?? null;
|
|
89
|
-
if (!request || typeof request !== "object" || typeof request.method !== "string" || request.method.trim().length === 0) {
|
|
90
|
-
return {
|
|
91
|
-
jsonrpc: "2.0",
|
|
92
|
-
id,
|
|
93
|
-
error: {
|
|
94
|
-
code: -32600,
|
|
95
|
-
message: "Invalid JSON-RPC request.",
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
if (request.jsonrpc !== undefined && request.jsonrpc !== "2.0") {
|
|
100
|
-
return {
|
|
101
|
-
jsonrpc: "2.0",
|
|
102
|
-
id,
|
|
103
|
-
error: {
|
|
104
|
-
code: -32600,
|
|
105
|
-
message: "Only JSON-RPC 2.0 requests are supported.",
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
try {
|
|
110
|
-
const result = await this.dispatch(request.method, request.params);
|
|
111
|
-
if (request.id === undefined) {
|
|
112
|
-
return undefined;
|
|
113
|
-
}
|
|
114
|
-
return {
|
|
115
|
-
jsonrpc: "2.0",
|
|
116
|
-
id,
|
|
117
|
-
result,
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
if (request.id === undefined) {
|
|
122
|
-
return undefined;
|
|
123
|
-
}
|
|
124
|
-
return {
|
|
125
|
-
jsonrpc: "2.0",
|
|
126
|
-
id,
|
|
127
|
-
error: {
|
|
128
|
-
code: this.methodExists(request.method) ? -32602 : -32601,
|
|
129
|
-
message: error instanceof Error ? error.message : "ACP request failed.",
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
methodExists(method) {
|
|
135
|
-
return new Set([
|
|
136
|
-
"capabilities.get",
|
|
137
|
-
"sessions.list",
|
|
138
|
-
"sessions.get",
|
|
139
|
-
"sessions.summaries",
|
|
140
|
-
"requests.submit",
|
|
141
|
-
"requests.list",
|
|
142
|
-
"requests.get",
|
|
143
|
-
"requests.plan.get",
|
|
144
|
-
"requests.cancel",
|
|
145
|
-
"requests.stream",
|
|
146
|
-
"requests.trace.list",
|
|
147
|
-
"approvals.list",
|
|
148
|
-
"approvals.get",
|
|
149
|
-
"approvals.resolve",
|
|
150
|
-
"artifacts.list",
|
|
151
|
-
"artifacts.read",
|
|
152
|
-
"events.list",
|
|
153
|
-
"runtime.health",
|
|
154
|
-
"runtime.overview",
|
|
155
|
-
]).has(method);
|
|
156
|
-
}
|
|
157
|
-
emitNotification(notification) {
|
|
158
|
-
for (const listener of Array.from(this.listeners)) {
|
|
159
|
-
try {
|
|
160
|
-
listener(notification);
|
|
161
|
-
}
|
|
162
|
-
catch {
|
|
163
|
-
// Ignore subscriber failures so one ACP consumer cannot tear down the server.
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
async dispatch(method, params) {
|
|
168
|
-
switch (method) {
|
|
169
|
-
case "capabilities.get":
|
|
170
|
-
return this.capabilities();
|
|
171
|
-
case "sessions.list": {
|
|
172
|
-
const payload = params === undefined ? {} : asObject(params, method);
|
|
173
|
-
return listSessions(this.runtime, {
|
|
174
|
-
agentId: readOptionalString(payload.agentId),
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
case "sessions.get": {
|
|
178
|
-
const payload = asObject(params, method);
|
|
179
|
-
return getSession(this.runtime, readRequiredString(payload.sessionId, "sessionId", method));
|
|
180
|
-
}
|
|
181
|
-
case "sessions.summaries": {
|
|
182
|
-
const payload = params === undefined ? {} : asObject(params, method);
|
|
183
|
-
return listSessionSummaries(this.runtime, {
|
|
184
|
-
agentId: readOptionalString(payload.agentId),
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
case "requests.submit": {
|
|
188
|
-
const payload = asObject(params, method);
|
|
189
|
-
if (readOptionalString(payload.streamId)) {
|
|
190
|
-
return this.submitStreamingRequest(payload, method);
|
|
191
|
-
}
|
|
192
|
-
return request(this.runtime, {
|
|
193
|
-
agentId: readOptionalString(payload.agentId),
|
|
194
|
-
input: payload.input,
|
|
195
|
-
invocation: payload.invocation,
|
|
196
|
-
listeners: payload.listeners,
|
|
197
|
-
priority: typeof payload.priority === "number" ? payload.priority : undefined,
|
|
198
|
-
sessionId: readOptionalString(payload.sessionId),
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
case "requests.cancel": {
|
|
202
|
-
const payload = asObject(params, method);
|
|
203
|
-
return cancelRequest(this.runtime, {
|
|
204
|
-
requestId: readRequiredString(payload.requestId, "requestId", method),
|
|
205
|
-
reason: readOptionalString(payload.reason),
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
case "requests.list": {
|
|
209
|
-
const payload = params === undefined ? {} : asObject(params, method);
|
|
210
|
-
return listRequests(this.runtime, {
|
|
211
|
-
agentId: readOptionalString(payload.agentId),
|
|
212
|
-
sessionId: readOptionalString(payload.sessionId),
|
|
213
|
-
state: payload.state,
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
case "requests.get": {
|
|
217
|
-
const payload = asObject(params, method);
|
|
218
|
-
return getRequest(this.runtime, readRequiredString(payload.requestId, "requestId", method));
|
|
219
|
-
}
|
|
220
|
-
case "requests.plan.get": {
|
|
221
|
-
const payload = asObject(params, method);
|
|
222
|
-
return getRequestPlanState(this.runtime, {
|
|
223
|
-
sessionId: readRequiredString(payload.sessionId, "sessionId", method),
|
|
224
|
-
requestId: readRequiredString(payload.requestId, "requestId", method),
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
case "requests.trace.list": {
|
|
228
|
-
const payload = asObject(params, method);
|
|
229
|
-
return listRequestTraceItems(this.runtime, {
|
|
230
|
-
sessionId: readRequiredString(payload.sessionId, "sessionId", method),
|
|
231
|
-
requestId: readRequiredString(payload.requestId, "requestId", method),
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
case "approvals.list": {
|
|
235
|
-
const payload = params === undefined ? {} : asObject(params, method);
|
|
236
|
-
return listApprovals(this.runtime, {
|
|
237
|
-
status: payload.status,
|
|
238
|
-
sessionId: readOptionalString(payload.sessionId),
|
|
239
|
-
requestId: readOptionalString(payload.requestId),
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
case "approvals.get": {
|
|
243
|
-
const payload = asObject(params, method);
|
|
244
|
-
return getApproval(this.runtime, readRequiredString(payload.approvalId, "approvalId", method));
|
|
245
|
-
}
|
|
246
|
-
case "approvals.resolve": {
|
|
247
|
-
const payload = asObject(params, method);
|
|
248
|
-
return resolveApproval(this.runtime, {
|
|
249
|
-
approvalId: readRequiredString(payload.approvalId, "approvalId", method),
|
|
250
|
-
decision: payload.decision,
|
|
251
|
-
editedInput: payload.editedInput,
|
|
252
|
-
requestId: readOptionalString(payload.requestId),
|
|
253
|
-
sessionId: readOptionalString(payload.sessionId),
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
case "artifacts.list": {
|
|
257
|
-
const payload = asObject(params, method);
|
|
258
|
-
return listRequestArtifacts(this.runtime, {
|
|
259
|
-
sessionId: readRequiredString(payload.sessionId, "sessionId", method),
|
|
260
|
-
requestId: readRequiredString(payload.requestId, "requestId", method),
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
case "artifacts.read":
|
|
264
|
-
return readArtifactContent(this.runtime, asObject(params, method));
|
|
265
|
-
case "events.list": {
|
|
266
|
-
const payload = asObject(params, method);
|
|
267
|
-
return listRequestEvents(this.runtime, {
|
|
268
|
-
sessionId: readRequiredString(payload.sessionId, "sessionId", method),
|
|
269
|
-
requestId: readRequiredString(payload.requestId, "requestId", method),
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
case "runtime.health":
|
|
273
|
-
return getHealth(this.runtime);
|
|
274
|
-
case "runtime.overview": {
|
|
275
|
-
const payload = params === undefined ? {} : asObject(params, method);
|
|
276
|
-
return getOperatorOverview(this.runtime, {
|
|
277
|
-
limit: typeof payload.limit === "number" ? payload.limit : undefined,
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
default:
|
|
281
|
-
throw new Error(`Unknown ACP method: ${method}`);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
async submitStreamingRequest(payload, method) {
|
|
285
|
-
const streamId = readRequiredString(payload.streamId, "streamId", method);
|
|
286
|
-
let finalResult;
|
|
287
|
-
for await (const item of this.runtime.streamEvents({
|
|
288
|
-
agentId: readOptionalString(payload.agentId),
|
|
289
|
-
input: payload.input,
|
|
290
|
-
invocation: payload.invocation,
|
|
291
|
-
listeners: payload.listeners,
|
|
292
|
-
priority: typeof payload.priority === "number" ? payload.priority : undefined,
|
|
293
|
-
sessionId: readOptionalString(payload.sessionId),
|
|
294
|
-
})) {
|
|
295
|
-
this.emitNotification(toStreamNotification(streamId, item));
|
|
296
|
-
if (item.type === "result") {
|
|
297
|
-
finalResult = item.result;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
if (finalResult) {
|
|
301
|
-
return finalResult;
|
|
302
|
-
}
|
|
303
|
-
throw new Error("ACP streaming request completed without a terminal result.");
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
export function createAcpServer(runtime) {
|
|
307
|
-
return new AgentHarnessAcpServer(runtime);
|
|
308
|
-
}
|
|
309
|
-
export { createAcpStdioClient } from "./protocol/acp/client.js";
|
|
310
|
-
export { createAcpHttpClient } from "./protocol/acp/client.js";
|
|
1
|
+
export * from "./protocol/acp/server.js";
|
package/dist/api.d.ts
CHANGED
|
@@ -2,12 +2,13 @@ import type { ArtifactListing, CancelOptions, InvocationEnvelope, ListMemoriesIn
|
|
|
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";
|
|
5
|
-
import type { RuntimeMcpServerOptions, ToolMcpServerOptions } from "./mcp.js";
|
|
5
|
+
import type { RuntimeMcpServerOptions, RuntimeMcpStreamableHttpServerOptions, ToolMcpServerOptions } from "./mcp.js";
|
|
6
6
|
export { AgentHarnessAcpServer, createAcpServer } from "./acp.js";
|
|
7
7
|
export { createAcpStdioClient } from "./protocol/acp/client.js";
|
|
8
|
+
export type { RuntimeMcpStreamableHttpServer, RuntimeMcpStreamableHttpServerOptions } from "./mcp.js";
|
|
8
9
|
export type { AcpApproval, AcpArtifact, AcpEventNotification, AcpNotification, AcpJsonRpcError, AcpJsonRpcRequest, AcpJsonRpcResponse, AcpJsonRpcSuccess, AcpRequestRecord, AcpRequestParams, AcpServerCapabilities, AcpSessionRecord, AcpStreamNotification, } from "./acp.js";
|
|
9
10
|
export { AgentHarnessRuntime } from "./runtime/harness.js";
|
|
10
|
-
export { createUpstreamTimelineReducer } from "./upstream-events.js";
|
|
11
|
+
export { createUpstreamTimelineReducer } from "./projections/upstream-events.js";
|
|
11
12
|
export type { ListMemoriesInput, ListMemoriesResult, MemoryDecision, MemoryKind, MemoryRecord, MemoryScope, MemorizeInput, MemorizeResult, RecallInput, RecallResult, RemoveMemoryInput, RuntimeEvaluationExport, RuntimeEvaluationExportInput, RuntimeEvaluationReplayInput, RequestPlanState, SessionListSummary, RuntimeSessionPackageInput, RuntimeSessionPackage, UpdateMemoryInput, } from "./contracts/types.js";
|
|
12
13
|
export type { AcpHttpServer, AcpHttpServerOptions } from "./protocol/acp/http.js";
|
|
13
14
|
export type { AcpStdioClient, AcpStdioClientOptions } from "./protocol/acp/client.js";
|
|
@@ -208,3 +209,4 @@ export declare function createToolMcpServer(runtime: AgentHarnessRuntime, option
|
|
|
208
209
|
export declare function serveToolsOverStdio(runtime: AgentHarnessRuntime, options: ToolMcpServerOptions): Promise<import("@modelcontextprotocol/sdk/server/mcp").McpServer>;
|
|
209
210
|
export declare function createRuntimeMcpServer(runtime: AgentHarnessRuntime, options?: RuntimeMcpServerOptions): Promise<import("@modelcontextprotocol/sdk/server/mcp").McpServer>;
|
|
210
211
|
export declare function serveRuntimeMcpOverStdio(runtime: AgentHarnessRuntime, options?: RuntimeMcpServerOptions): Promise<import("@modelcontextprotocol/sdk/server/mcp").McpServer>;
|
|
212
|
+
export declare function serveRuntimeMcpOverStreamableHttp(runtime: AgentHarnessRuntime, options?: RuntimeMcpStreamableHttpServerOptions): Promise<import("./mcp.js").RuntimeMcpStreamableHttpServer>;
|
package/dist/api.js
CHANGED
|
@@ -10,7 +10,7 @@ import { traceStartupStage } from "./runtime/startup-tracing.js";
|
|
|
10
10
|
export { AgentHarnessAcpServer, createAcpServer } from "./acp.js";
|
|
11
11
|
export { createAcpStdioClient } from "./protocol/acp/client.js";
|
|
12
12
|
export { AgentHarnessRuntime } from "./runtime/harness.js";
|
|
13
|
-
export { createUpstreamTimelineReducer } from "./upstream-events.js";
|
|
13
|
+
export { createUpstreamTimelineReducer } from "./projections/upstream-events.js";
|
|
14
14
|
function toApprovalRecord(record) {
|
|
15
15
|
return {
|
|
16
16
|
approvalId: record.approvalId,
|
|
@@ -387,6 +387,9 @@ export async function createRuntimeMcpServer(runtime, options) {
|
|
|
387
387
|
export async function serveRuntimeMcpOverStdio(runtime, options) {
|
|
388
388
|
return runtime.serveRuntimeMcpOverStdio(options);
|
|
389
389
|
}
|
|
390
|
+
export async function serveRuntimeMcpOverStreamableHttp(runtime, options) {
|
|
391
|
+
return runtime.serveRuntimeMcpOverStreamableHttp(options);
|
|
392
|
+
}
|
|
390
393
|
function normalizeUserChatMessage(message) {
|
|
391
394
|
if (message.role !== "user") {
|
|
392
395
|
throw new Error("normalizeUserChatInput only accepts user-role chat messages.");
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Interface as ReadlineInterface } from "node:readline";
|
|
2
|
+
import type { Writable as WritableStream } from "node:stream";
|
|
3
|
+
import type { HarnessClient } from "../client.js";
|
|
4
|
+
import { type ChatWorkspaceModelInfo } from "./chat-workspace.js";
|
|
5
|
+
export declare function runInteractiveChatLoop(input: {
|
|
6
|
+
client: HarnessClient;
|
|
7
|
+
lineReader: ReadlineInterface;
|
|
8
|
+
stdout: (message: string) => void;
|
|
9
|
+
stderr: (message: string) => void;
|
|
10
|
+
stdoutStream?: WritableStream;
|
|
11
|
+
stderrStream?: WritableStream;
|
|
12
|
+
workspacePath: string;
|
|
13
|
+
workspaceModelInfo?: ChatWorkspaceModelInfo;
|
|
14
|
+
requestEvents: boolean;
|
|
15
|
+
chatIsTty: boolean;
|
|
16
|
+
useColor: boolean;
|
|
17
|
+
agentFilter?: string;
|
|
18
|
+
activeAgentId?: string;
|
|
19
|
+
activeSessionId?: string;
|
|
20
|
+
}): Promise<{
|
|
21
|
+
activeAgentId?: string;
|
|
22
|
+
activeSessionId?: string;
|
|
23
|
+
latestRequestId?: string;
|
|
24
|
+
}>;
|