@syllm/brickly-test-host 0.11.0 → 0.12.0

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
@@ -35,15 +35,31 @@ node node_modules/@syllm/brickly-test-host/dist/host.cjs
35
35
 
36
36
  ### 2. 控制面 HTTP(仅 127.0.0.1)
37
37
 
38
+ **故障注入与录制(runtime→host 方向)**
39
+
38
40
  | 方法 | 路径 | 请求体 | 说明 |
39
41
  |------|------|--------|------|
40
42
  | POST | `/faults` | `{path, brickCode, message?, count?}` | 故障注入:命中 `path` 的下 `count` 次调用(默认 1)短路返回该 brick 错误,**无副作用**(真 handler 不执行) |
41
- | POST | `/reset` | `{}` | 清空故障规则与调用录制(不清 storage 数据) |
43
+ | POST | `/reset` | `{}` | 清空故障规则、调用录制、UI 罐头响应与 UI 调用记录(不清 storage 数据) |
42
44
  | GET | `/calls` | — | `{"calls":[{"path","at"}]}` 调用录制 |
43
45
 
44
46
  `path` 为完整 gRPC 方法路径,如 `/brickly.runtime.v1.BrickStorageService/KvGet`;
45
47
  `brickCode` 为协议错误码,如 `BRICK_STORAGE_NOT_FOUND`、`LIMIT_EXCEEDED`。
46
48
 
49
+ **驱动面(host→runtime 方向)**
50
+
51
+ | 方法 | 路径 | 请求体 | 响应 |
52
+ |------|------|--------|------|
53
+ | POST | `/spawn` | `{brickId, instanceId?, origin?, version?}` | 完整 spawn 凭据 `{spawnId, bootstrapToken, runtimeToHostToken, hostToRuntimeToken, brickId, instanceId}`——铸给第二个 runtime 用(依赖调用等场景) |
54
+ | POST | `/invoke` | `{spawnId?, commandId, input?, timeoutMs?}` | `{ok:true,result}` 或 `{ok:false,error:{brickCode?,message,grpcStatus?}}`;缺省 `spawnId` 用首个 spawn |
55
+ | POST | `/interact` | 同 `/invoke` | 批量模式:`{ok:true,events:[...],result}` 或 `{ok:false,error}` |
56
+ | POST | `/events/push` | `{spawnId?, topic, payload?}` | `{}`,经真 HostEventBus 送达该 runtime 的事件订阅流 |
57
+ | POST | `/ui-handler` | `{method, result}` | 注册 UI 方法罐头响应;`method` 限 `createBrowserWindow / callWindow / closeWindow / forceCloseWindow / listWindows / sendToChild / replyToChild / emitToChild`,未知名返回 400 |
58
+ | GET | `/ui-calls` | — | `{"calls":[{"method","args","at"}]}` runtime 真实发起的 UI 调用记录 |
59
+ | GET | `/runtimes` | — | `{"runtimes":[{"spawnId","brickId","instanceId"}]}` 已注册 runtime 句柄 |
60
+
61
+ 典型流程:`POST /spawn` 拿凭据 → 测试进程按 `BRICKLY_HOST_ENDPOINT / BRICKLY_BOOTSTRAP_TOKEN / BRICKLY_RUNTIME_TO_HOST_TOKEN / BRICKLY_HOST_TO_RUNTIME_TOKEN` 环境变量起 SDK runtime → `POST /invoke` 反向调用命令 → `POST /ui-handler` + `GET /ui-calls` 验证 UI 调用链。
62
+
47
63
  ### 3. 探针参考实现
48
64
 
49
65
  `check/` 目录有 Go / .NET / Python 的最小探针(spawn → 就绪行 → `/calls` → `/reset`),可直接照抄到各独立仓库。