@xmoxmo/bncr 0.2.3 → 0.2.5

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.
Files changed (36) hide show
  1. package/README.md +67 -4
  2. package/index.ts +24 -1
  3. package/package.json +1 -1
  4. package/src/channel.ts +2823 -1178
  5. package/src/core/connection-capability.ts +70 -0
  6. package/src/core/connection-reachability.ts +141 -0
  7. package/src/core/diagnostics.ts +49 -0
  8. package/src/core/downlink-health.ts +56 -0
  9. package/src/core/extended-diagnostics.ts +65 -0
  10. package/src/core/lease-state.ts +94 -0
  11. package/src/core/outbox-enqueue.ts +22 -0
  12. package/src/core/outbox-entry-builders.ts +91 -0
  13. package/src/core/outbox-file-transfer-bookkeeping.ts +31 -0
  14. package/src/core/outbox-file-transfer-failure.ts +25 -0
  15. package/src/core/outbox-file-transfer-guards.ts +66 -0
  16. package/src/core/outbox-file-transfer-prep.ts +31 -0
  17. package/src/core/outbox-file-transfer-success.ts +34 -0
  18. package/src/core/outbox-push-args.ts +67 -0
  19. package/src/core/outbox-queue.ts +69 -0
  20. package/src/core/outbox-summary.ts +14 -0
  21. package/src/core/outbox-text-push-failure.ts +10 -0
  22. package/src/core/outbox-text-push-guards.ts +51 -0
  23. package/src/core/outbox-text-push-prep.ts +36 -0
  24. package/src/core/outbox-text-push-success.ts +62 -0
  25. package/src/core/register-trace.ts +110 -0
  26. package/src/core/status.ts +62 -10
  27. package/src/core/types.ts +3 -0
  28. package/src/messaging/inbound/dispatch.ts +86 -48
  29. package/src/messaging/outbound/diagnostics.ts +246 -0
  30. package/src/messaging/outbound/media-dedupe.ts +51 -0
  31. package/src/messaging/outbound/queue-selectors.ts +186 -0
  32. package/src/messaging/outbound/reasons.ts +48 -0
  33. package/src/messaging/outbound/reply-enqueue.ts +329 -0
  34. package/src/messaging/outbound/retry-policy.ts +133 -0
  35. package/src/messaging/outbound/send.ts +2 -0
  36. package/src/messaging/outbound/session-route.ts +34 -5
package/README.md CHANGED
@@ -128,7 +128,70 @@ plugins/bncr/src/
128
128
 
129
129
  ---
130
130
 
131
- ## 7. 状态与诊断
131
+ ## 7. 媒体发送(OpenClaw 2026.5.18 验证适用)
132
+
133
+ 当前有两种常见媒体发送方式,它们都属于 OpenClaw 标准能力,但**不是同一条实现链路**。
134
+
135
+ ### 方式 A:Agent 回复中的 `MEDIA:<path>`
136
+
137
+ 适用场景:
138
+
139
+ - agent 在当前会话中直接回附件
140
+ - 由宿主 reply-media / outbound attachment 链统一处理
141
+
142
+ 示例:
143
+
144
+ ```text
145
+ MEDIA:/root/.openclaw/workspace/tmp/demo.png
146
+ ```
147
+
148
+ 说明:
149
+
150
+ - 这条链先经过 OpenClaw 宿主的 `reply-media-paths` / `loadWebMedia` 预处理
151
+ - 本地文件是否允许发送,取决于宿主侧的路径准入与 MIME / 类型白名单
152
+ - 在 `2026.5.18` 口径下,`MEDIA:` 是否成功,**不能直接等价**为 bncr 插件自身的 file-transfer 是否成功
153
+
154
+ ### 方式 B:动作发送链(`message.action` / `send`)
155
+
156
+ 适用场景:
157
+
158
+ - 需要显式指定目标会话 / 路由
159
+ - 需要验证 OpenClaw 动作发送接口到 bncr channel 的下行链路
160
+
161
+ 示例:
162
+
163
+ ```bash
164
+ openclaw gateway call message.action --params '{
165
+ "channel": "bncr",
166
+ "action": "send",
167
+ "accountId": "Primary",
168
+ "idempotencyKey": "bncr-media-demo-1",
169
+ "params": {
170
+ "to": "Bncr:tgBot:-1003776014601:6278285192",
171
+ "caption": "图片发送测试",
172
+ "path": "/root/.openclaw/workspace/tmp/demo.png"
173
+ }
174
+ }'
175
+ ```
176
+
177
+ 说明:
178
+
179
+ - 这是 OpenClaw 标准动作发送接口,不是 bncr 私有命令
180
+ - 这条链与 `MEDIA:` 的宿主 reply-media 预处理链不同
181
+ - 联调时建议把两条链分开验证,避免把宿主准入问题误判成 bncr 文件传输问题
182
+
183
+ ### 2026.5.18 验证说明
184
+
185
+ 以下口径已在 OpenClaw `2026.5.18` 上完成验证,当前建议把媒体问题拆成两类看:
186
+
187
+ 1. `MEDIA:<path>` 失败:优先检查宿主 reply-media / MIME 白名单 / 本地路径准入
188
+ 2. `message.action` 失败:优先检查动作 envelope、目标 `to`、bncr 出站 push/ack 与 file-transfer 日志
189
+
190
+ 后续如果在其他 OpenClaw 版本上完成验证,应继续在本节追加对应版本的验证过程与结论,不直接外推复用 `2026.5.18` 的验证口径。
191
+
192
+ ---
193
+
194
+ ## 8. 状态与诊断
132
195
 
133
196
  常用检查:
134
197
 
@@ -149,7 +212,7 @@ openclaw health --json
149
212
 
150
213
  ---
151
214
 
152
- ## 8. 常见安装/加载问题
215
+ ## 9. 常见安装/加载问题
153
216
 
154
217
  ### 报错:`Cannot find module 'openclaw/plugin-sdk/core'`
155
218
 
@@ -177,7 +240,7 @@ npm root -g
177
240
 
178
241
  然后把 `openclaw` 的真实安装目录软链接到 `~/.openclaw/extensions/bncr/node_modules/openclaw`。
179
242
 
180
- ## 9. 自检与测试
243
+ ## 10. 自检与测试
181
244
 
182
245
  ```bash
183
246
  cd plugins/bncr
@@ -206,7 +269,7 @@ npm pack
206
269
 
207
270
  ---
208
271
 
209
- ## 9. 上线前检查
272
+ ## 11. 上线前检查
210
273
 
211
274
  上线前建议至少确认:
212
275
 
package/index.ts CHANGED
@@ -408,7 +408,30 @@ const dispatchGatewayMethod = (name: GatewayMethodName, opts: any) => {
408
408
  if (!bridge) {
409
409
  throw new Error(`bncr gateway runtime unavailable for ${name}`);
410
410
  }
411
- return gatewayMethodDispatchers[name](bridge, opts);
411
+ try {
412
+ return gatewayMethodDispatchers[name](bridge, opts);
413
+ } catch (error) {
414
+ const detail =
415
+ error instanceof Error
416
+ ? {
417
+ name: error.name,
418
+ message: error.message,
419
+ stack: error.stack || null,
420
+ }
421
+ : { name: 'NonError', message: String(error), stack: null };
422
+ emitBncrLogLine(
423
+ 'error',
424
+ `[bncr] gateway method error ${JSON.stringify({
425
+ method: name,
426
+ bridgeId: bridge.getBridgeId?.() || null,
427
+ gatewayPid: bridge.gatewayPid || null,
428
+ detail,
429
+ })}`,
430
+ { debugOnly: true },
431
+ () => true,
432
+ );
433
+ throw error;
434
+ }
412
435
  };
413
436
 
414
437
  const mirrorGatewayMethodForMockApi = (api: OpenClawPluginApi, name: GatewayMethodName) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmoxmo/bncr",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",