@xmoxmo/bncr 0.0.5 → 0.0.7

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
@@ -37,7 +37,20 @@ openclaw gateway restart
37
37
 
38
38
  ---
39
39
 
40
- ## 3. 当前能力
40
+ ## 3. 客户端接入流程(最简)
41
+
42
+ 1. 在客户端插件配置中,将 **OpenClaw Token** 填写为 **gateway token**,并正确填写 host / port / ssl 后启用插件。
43
+ 2. 启动(或重启)bncr 客户端后,在 OpenClaw 侧执行:
44
+
45
+ ```bash
46
+ openclaw devices approve --latest
47
+ ```
48
+
49
+ 完成后,客户端会使用自己的身份并自动保存后续授权。
50
+
51
+ ---
52
+
53
+ ## 4. 当前能力
41
54
 
42
55
  - 文本
43
56
  - 图片
@@ -54,7 +67,7 @@ openclaw gateway restart
54
67
 
55
68
  ---
56
69
 
57
- ## 4. 架构定位
70
+ ## 5. 架构定位
58
71
 
59
72
  bncr 当前采用两层模型:
60
73
 
@@ -77,7 +90,7 @@ plugins/bncr/src/
77
90
 
78
91
  ---
79
92
 
80
- ## 5. 配置项总览
93
+ ## 6. 配置项总览
81
94
 
82
95
  当前主要配置字段:
83
96
 
@@ -98,7 +111,7 @@ plugins/bncr/src/
98
111
 
99
112
  ---
100
113
 
101
- ## 6. 状态与诊断
114
+ ## 7. 状态与诊断
102
115
 
103
116
  常用检查:
104
117
 
@@ -116,7 +129,7 @@ openclaw health --json
116
129
 
117
130
  ---
118
131
 
119
- ## 7. 自检与测试
132
+ ## 8. 自检与测试
120
133
 
121
134
  ```bash
122
135
  cd plugins/bncr
@@ -133,11 +146,12 @@ npm pack
133
146
 
134
147
  ---
135
148
 
136
- ## 8. 上线前检查
149
+ ## 9. 上线前检查
137
150
 
138
151
  上线前建议至少确认:
139
152
 
140
153
  - README 与当前实现一致
154
+ - **隐私清理**:测试/示例/日志中的 scope、ID、账号等做去标识化(必要时用占位值)
141
155
  - 配置 schema 与实际字段一致
142
156
  - 测试通过
143
157
  - 自检通过
package/index.ts CHANGED
@@ -5,17 +5,43 @@ import {
5
5
  import { BncrConfigSchema } from "./src/core/config-schema.js";
6
6
  import { createBncrBridge, createBncrChannelPlugin } from "./src/channel.js";
7
7
 
8
+ type BridgeSingleton = ReturnType<typeof createBncrBridge>;
9
+
10
+ const getBridgeSingleton = (api: OpenClawPluginApi) => {
11
+ const g = globalThis as typeof globalThis & { __bncrBridge?: BridgeSingleton };
12
+ if (!g.__bncrBridge) g.__bncrBridge = createBncrBridge(api);
13
+ return g.__bncrBridge;
14
+ };
15
+
8
16
  const plugin = {
9
17
  id: "bncr",
10
18
  name: "Bncr",
11
19
  description: "Bncr channel plugin",
12
20
  configSchema: BncrConfigSchema,
13
21
  register(api: OpenClawPluginApi) {
14
- const bridge = createBncrBridge(api);
22
+ const bridge = getBridgeSingleton(api);
23
+ const debugLog = (...args: any[]) => {
24
+ if (!bridge.isDebugEnabled?.()) return;
25
+ api.logger.info?.(...args);
26
+ };
27
+
28
+ debugLog(`bncr plugin register bridge=${(bridge as any)?.bridgeId || 'unknown'}`);
29
+
30
+ const resolveDebug = async () => {
31
+ try {
32
+ const cfg = await api.runtime.config.loadConfig();
33
+ return Boolean((cfg as any)?.channels?.bncr?.debug?.verbose);
34
+ } catch {
35
+ return false;
36
+ }
37
+ };
15
38
 
16
39
  api.registerService({
17
40
  id: "bncr-bridge-service",
18
- start: bridge.startService,
41
+ start: async (ctx) => {
42
+ const debug = await resolveDebug();
43
+ await bridge.startService(ctx, debug);
44
+ },
19
45
  stop: bridge.stopService,
20
46
  });
21
47
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmoxmo/bncr",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",