@xmoxmo/bncr 0.6.4 → 0.6.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.
- package/README.md +36 -5
- package/package.json +1 -1
- package/scripts/check-pack.mjs +2 -0
- package/scripts/selfcheck.mjs +2 -0
- package/src/messaging/inbound/command-owner.ts +33 -0
- package/src/messaging/inbound/commands.ts +386 -252
- package/src/messaging/inbound/dispatch-prep.ts +8 -4
- package/src/messaging/inbound/dispatch.ts +3 -1
- package/src/messaging/inbound/native-command-runtime.ts +4 -0
- package/src/messaging/inbound/native-command.ts +89 -15
- package/src/messaging/inbound/reply-dispatch.ts +17 -36
- package/src/messaging/inbound/scene-admin.ts +31 -3
- package/src/openclaw/inbound-session-runtime.ts +17 -0
- package/src/openclaw/session-reset-runtime.ts +77 -0
- package/src/plugin/inbound-acceptance.ts +18 -7
package/README.md
CHANGED
|
@@ -91,10 +91,32 @@ openclaw devices approve --latest
|
|
|
91
91
|
补充口径:
|
|
92
92
|
|
|
93
93
|
- 入站会话按正式 scene / route 语义接入 OpenClaw,区分私聊与群聊会话。
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
-
|
|
94
|
+
|
|
95
|
+
#### 私聊管理员
|
|
96
|
+
|
|
97
|
+
- 不受白名单约束。裸发命令(如 `/whoami`、`/status`、`/new`、`/reset`、`/verbose`、`/model`)直接转发 OpenClaw/agent 处理,bncr 不拦截。
|
|
98
|
+
- `/bncr xxx` 由 bncr 插件解析处理(admin 权限)。
|
|
99
|
+
- 裸发 `/whoami` 与 `/bncr whoami` 由不同处理器响应,结果可能不同。
|
|
100
|
+
|
|
101
|
+
#### 私聊非管理员
|
|
102
|
+
|
|
103
|
+
- 白名单裸发命令 `/whoami`、`/status`、`/verbose`、`/model` 会临时提权为 admin 后注入 OpenClaw 原生命令解析器处理,即使解析失败也不 fallback 到 agent。
|
|
104
|
+
- 白名单裸发命令 `/new`、`/reset` 会临时提权为 admin 后由 bncr 本地执行会话重置,不 fallback 到 agent。
|
|
105
|
+
- `/stop` 不经过 bncr 原生命令处理器,所有调用者统一走会话级 stop 快速路径;私聊非管理员在该路径下注入 owner 权限后交给 OpenClaw 处理,不 fallback 到 agent。
|
|
106
|
+
- 非白名单裸发命令(如 `/allow`、`/mode`)以调用者自身身份交给 OpenClaw/agent 处理,允许 fallback 到 agent。
|
|
107
|
+
- `/bncr` 前缀命令由 bncr 插件按非管理员权限处理,可用的子命令为:`whoami`、`status`、`new`、`reset`、`verbose`、`history-help`、`history-limit`、`history-force`、`download-media`。
|
|
108
|
+
- `/bncr` 未知子命令(含 `/bncr stop`)→ 直接拒绝,不转发 agent。
|
|
109
|
+
- 非管理员私聊执行 self-admin 命令(`history-*`、`download-media`)时,如传入 `sceneId` 参数,仅允许控制当前私聊会话,传入其他会话 ID 会被拒绝。
|
|
110
|
+
|
|
111
|
+
#### 群聊
|
|
112
|
+
|
|
113
|
+
- 管理员:`/bncr xxx` 由 bncr 插件解析处理(admin 权限),裸发命令放行给 OpenClaw/agent。
|
|
114
|
+
- 非管理员:裸发 `/whoami` 由 bncr 拦截返回身份;其余裸发命令放行给 OpenClaw/agent。
|
|
115
|
+
- 非管理员执行场景管理命令(`mode`、`history-help`、`history-limit`、`history-force`、`download-media`、`allow`、`deny`、`bind`、`revoke`、`list`)时,统一返回 `Admin permission required.`,不再附带用法提示。
|
|
116
|
+
- 非管理员执行 `/bncr new`、`/bncr reset`、`/bncr verbose` 时仍按静默拒绝处理。
|
|
117
|
+
|
|
118
|
+
#### 其他
|
|
119
|
+
|
|
98
120
|
- `/bncr list pending` 与 `/bncr list scenes` 采用按私聊 / 群聊分组的摘要展示格式,便于现场排查 scene 状态。
|
|
99
121
|
|
|
100
122
|
### `/bncr help` 权限过滤
|
|
@@ -103,7 +125,7 @@ openclaw devices approve --latest
|
|
|
103
125
|
|
|
104
126
|
- 管理员:展示全部命令
|
|
105
127
|
- 私聊非管理员:展示当前可用命令,不展示管理类命令
|
|
106
|
-
-
|
|
128
|
+
- 群聊非管理员:仅展示 `/bncr whoami`、`/bncr status`,不展示 `new`、`reset`、`verbose`、`mode`、`history-*`、`download-media` 等命令
|
|
107
129
|
|
|
108
130
|
示例:
|
|
109
131
|
|
|
@@ -148,6 +170,15 @@ openclaw devices approve --latest
|
|
|
148
170
|
• /bncr status
|
|
149
171
|
• /bncr new
|
|
150
172
|
• /bncr reset
|
|
173
|
+
• /bncr verbose on|off|full
|
|
174
|
+
|
|
175
|
+
📋 Conversation history
|
|
176
|
+
• /bncr history-help
|
|
177
|
+
• /bncr history-limit [<number>|clear] [<SceneId>]
|
|
178
|
+
• /bncr history-force on|off|clear [<SceneId>]
|
|
179
|
+
|
|
180
|
+
🌐 Remote media
|
|
181
|
+
• /bncr download-media on|off|clear|default on|off [<SceneId>]
|
|
151
182
|
```
|
|
152
183
|
|
|
153
184
|
群聊非管理员:
|
package/package.json
CHANGED
package/scripts/check-pack.mjs
CHANGED
|
@@ -58,6 +58,7 @@ const requiredSourceFiles = [
|
|
|
58
58
|
'src/core/status.ts',
|
|
59
59
|
'src/core/targets.ts',
|
|
60
60
|
'src/core/types.ts',
|
|
61
|
+
'src/messaging/inbound/command-owner.ts',
|
|
61
62
|
'src/messaging/inbound/commands.ts',
|
|
62
63
|
'src/messaging/inbound/context-facts.ts',
|
|
63
64
|
'src/messaging/inbound/dispatch-prep.ts',
|
|
@@ -90,6 +91,7 @@ const requiredSourceFiles = [
|
|
|
90
91
|
'src/messaging/outbound/target-resolver.ts',
|
|
91
92
|
'src/openclaw/config-runtime.ts',
|
|
92
93
|
'src/openclaw/inbound-session-runtime.ts',
|
|
94
|
+
'src/openclaw/session-reset-runtime.ts',
|
|
93
95
|
'src/openclaw/media-runtime.ts',
|
|
94
96
|
'src/openclaw/reply-runtime.ts',
|
|
95
97
|
'src/openclaw/routing-runtime.ts',
|
package/scripts/selfcheck.mjs
CHANGED
|
@@ -57,6 +57,7 @@ const requiredSourceFiles = [
|
|
|
57
57
|
'src/core/targets.ts',
|
|
58
58
|
'src/core/types.ts',
|
|
59
59
|
'src/core/value-sanitize.ts',
|
|
60
|
+
'src/messaging/inbound/command-owner.ts',
|
|
60
61
|
'src/messaging/inbound/commands.ts',
|
|
61
62
|
'src/messaging/inbound/context-facts.ts',
|
|
62
63
|
'src/messaging/inbound/contracts.ts',
|
|
@@ -101,6 +102,7 @@ const requiredSourceFiles = [
|
|
|
101
102
|
'src/openclaw/channel-runtime-contracts.ts',
|
|
102
103
|
'src/openclaw/config-runtime.ts',
|
|
103
104
|
'src/openclaw/inbound-session-runtime.ts',
|
|
105
|
+
'src/openclaw/session-reset-runtime.ts',
|
|
104
106
|
'src/openclaw/media-runtime.ts',
|
|
105
107
|
'src/openclaw/reply-runtime.ts',
|
|
106
108
|
'src/openclaw/routing-runtime.ts',
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { BncrInboundConfig } from './contracts.ts';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Inject a sender into cfg.commands.ownerAllowFrom without mutating cfg.
|
|
5
|
+
* The sender is only added when the caller may be treated as an owner for
|
|
6
|
+
* OpenClaw native command dispatch.
|
|
7
|
+
*/
|
|
8
|
+
export function mergeBncrOwnerAllowFromIntoConfig(args: {
|
|
9
|
+
cfg: BncrInboundConfig;
|
|
10
|
+
senderIdForContext: string;
|
|
11
|
+
}): BncrInboundConfig {
|
|
12
|
+
const { cfg, senderIdForContext } = args;
|
|
13
|
+
const senderId = String(senderIdForContext || '').trim();
|
|
14
|
+
if (!senderId) return cfg;
|
|
15
|
+
|
|
16
|
+
const rawCommands = cfg.commands;
|
|
17
|
+
const currentCommands: { ownerAllowFrom?: string[] } =
|
|
18
|
+
rawCommands !== null && typeof rawCommands === 'object' && !Array.isArray(rawCommands)
|
|
19
|
+
? (rawCommands as { ownerAllowFrom?: string[] })
|
|
20
|
+
: {};
|
|
21
|
+
const currentOwnerAllowFrom = Array.isArray(currentCommands.ownerAllowFrom)
|
|
22
|
+
? currentCommands.ownerAllowFrom
|
|
23
|
+
: [];
|
|
24
|
+
if (currentOwnerAllowFrom.includes(senderId)) return cfg;
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
...cfg,
|
|
28
|
+
commands: {
|
|
29
|
+
...currentCommands,
|
|
30
|
+
ownerAllowFrom: [...currentOwnerAllowFrom, senderId],
|
|
31
|
+
},
|
|
32
|
+
} satisfies BncrInboundConfig;
|
|
33
|
+
}
|