@bamdra/bamdra-user-bind 0.1.8 → 0.1.10
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 +42 -55
- package/README.zh-CN.md +42 -53
- package/dist/index.js +14 -2
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,81 +1,68 @@
|
|
|
1
1
|
# bamdra-user-bind
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The identity and living profile layer for the Bamdra suite.
|
|
4
4
|
|
|
5
|
-
It
|
|
5
|
+
It can run independently, and it is also auto-provisioned by `bamdra-openclaw-memory`.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
[中文文档](./README.zh-CN.md)
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
- stores bindings and profiles in a local SQLite store
|
|
11
|
-
- exports human-readable backup files for inspection and recovery
|
|
12
|
-
- injects resolved identity into runtime context for downstream memory plugins
|
|
13
|
-
- blocks normal agents from reading other users' private data
|
|
14
|
-
- exposes separate admin tools for natural-language query, edit, merge, issue review, and resync workflows
|
|
9
|
+
## What it does
|
|
15
10
|
|
|
16
|
-
|
|
11
|
+
`bamdra-user-bind` turns raw channel sender IDs into a stable user boundary.
|
|
17
12
|
|
|
18
|
-
|
|
13
|
+
It also becomes the user's evolving profile layer, including:
|
|
19
14
|
|
|
20
|
-
-
|
|
21
|
-
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
-
|
|
25
|
-
[package.json](/Users/wood/workspace/macmini-openclaw/openclaw-enhanced/bamdra-user-bind/package.json)
|
|
15
|
+
- preferred address
|
|
16
|
+
- timezone
|
|
17
|
+
- tone preferences
|
|
18
|
+
- role
|
|
19
|
+
- long-lived user notes
|
|
26
20
|
|
|
27
|
-
|
|
21
|
+
## Why it matters
|
|
28
22
|
|
|
29
|
-
|
|
23
|
+
Without an identity layer:
|
|
30
24
|
|
|
31
|
-
-
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
`~/.openclaw/data/bamdra-user-bind/profiles/private/{userId}.md`
|
|
35
|
-
- export directory:
|
|
36
|
-
`~/.openclaw/data/bamdra-user-bind/exports/`
|
|
37
|
-
|
|
38
|
-
The runtime queries the SQLite store as the controlled source of truth. The Markdown mirror exists so humans can edit a per-user profile the way they would edit a `USER.md`-style file, without turning the whole directory into an unrestricted agent-readable knowledge base.
|
|
25
|
+
- the same person can fragment across channels or sessions
|
|
26
|
+
- memory can attach to the wrong boundary
|
|
27
|
+
- personalization becomes fragile
|
|
39
28
|
|
|
40
|
-
|
|
29
|
+
With it:
|
|
41
30
|
|
|
42
|
-
|
|
31
|
+
- user-aware memory becomes stable
|
|
32
|
+
- personalization survives new sessions
|
|
33
|
+
- the assistant can gradually adapt to the user's style and working habits
|
|
43
34
|
|
|
44
|
-
|
|
35
|
+
## Storage model
|
|
45
36
|
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
37
|
+
- primary store:
|
|
38
|
+
`~/.openclaw/data/bamdra-user-bind/profiles.sqlite`
|
|
39
|
+
- editable Markdown mirrors:
|
|
40
|
+
`~/.openclaw/data/bamdra-user-bind/profiles/private/{userId}.md`
|
|
41
|
+
- export directory:
|
|
42
|
+
`~/.openclaw/data/bamdra-user-bind/exports/`
|
|
49
43
|
|
|
50
|
-
|
|
44
|
+
The SQLite store is the controlled source of truth.
|
|
51
45
|
|
|
52
|
-
|
|
46
|
+
The Markdown mirror is for humans, so profiles stay editable like a living per-user guide instead of becoming a hidden black box.
|
|
53
47
|
|
|
54
|
-
|
|
55
|
-
- cross-user reads are denied by implementation, not by prompt wording alone
|
|
56
|
-
- admin actions are separated into dedicated tools
|
|
57
|
-
- audit records are written for admin reads, edits, merges, syncs, and rejected access attempts
|
|
48
|
+
## Best practice
|
|
58
49
|
|
|
59
|
-
|
|
50
|
+
- keep SQLite local
|
|
51
|
+
- keep profile mirrors private
|
|
52
|
+
- let humans edit the mirror gradually
|
|
53
|
+
- use admin tools only for audit, merge, repair, and maintenance
|
|
60
54
|
|
|
61
|
-
|
|
62
|
-
can run independently as a user identity plugin
|
|
63
|
-
- auto companion:
|
|
64
|
-
`bamdra-openclaw-memory` can auto-provision it during npm-based install bootstrap
|
|
65
|
-
- optional companion:
|
|
66
|
-
`bamdra-memory-vector`
|
|
55
|
+
## What it unlocks
|
|
67
56
|
|
|
68
|
-
|
|
57
|
+
With `bamdra-openclaw-memory`:
|
|
69
58
|
|
|
70
|
-
|
|
59
|
+
- memory becomes user-aware instead of session-only
|
|
71
60
|
|
|
72
|
-
|
|
73
|
-
- `bamdra-user-bind-admin`
|
|
61
|
+
With `bamdra-memory-vector`:
|
|
74
62
|
|
|
75
|
-
|
|
63
|
+
- private notes stay private while still influencing local recall
|
|
76
64
|
|
|
77
|
-
##
|
|
65
|
+
## Repository
|
|
78
66
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
```
|
|
67
|
+
- [GitHub organization](https://github.com/bamdra)
|
|
68
|
+
- [Repository](https://github.com/bamdra/bamdra-user-bind)
|
package/README.zh-CN.md
CHANGED
|
@@ -1,79 +1,68 @@
|
|
|
1
1
|
# bamdra-user-bind
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Bamdra 套件中的身份与“活画像”层。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
它可以独立运行,也会被 `bamdra-openclaw-memory` 自动补齐。
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- 在本地 SQLite 中保存绑定关系和用户画像
|
|
9
|
-
- 导出可读备份文件,方便排查和恢复
|
|
10
|
-
- 把身份解析结果注入运行时上下文,供下游记忆插件使用
|
|
11
|
-
- 普通 agent 无法读取其他用户的私有资料
|
|
12
|
-
- 管理员工具支持自然语言查询、编辑、合并、巡检与重同步
|
|
7
|
+
[English README](./README.md)
|
|
13
8
|
|
|
14
|
-
##
|
|
9
|
+
## 它做什么
|
|
15
10
|
|
|
16
|
-
|
|
11
|
+
`bamdra-user-bind` 会把渠道里的原始 sender ID 转成稳定用户边界。
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
[src/index.ts](/Users/wood/workspace/macmini-openclaw/openclaw-enhanced/bamdra-user-bind/src/index.ts)
|
|
20
|
-
- 插件清单:
|
|
21
|
-
[openclaw.plugin.json](/Users/wood/workspace/macmini-openclaw/openclaw-enhanced/bamdra-user-bind/openclaw.plugin.json)
|
|
22
|
-
- 包元数据:
|
|
23
|
-
[package.json](/Users/wood/workspace/macmini-openclaw/openclaw-enhanced/bamdra-user-bind/package.json)
|
|
13
|
+
同时,它也会逐渐成为用户持续演化的画像层,包括:
|
|
24
14
|
|
|
25
|
-
|
|
15
|
+
- 应该怎么称呼
|
|
16
|
+
- 时区
|
|
17
|
+
- 语气偏好
|
|
18
|
+
- 角色
|
|
19
|
+
- 长期用户备注
|
|
26
20
|
|
|
27
|
-
##
|
|
21
|
+
## 为什么重要
|
|
28
22
|
|
|
29
|
-
|
|
30
|
-
`~/.openclaw/data/bamdra-user-bind/profiles.sqlite`
|
|
31
|
-
- 可编辑的用户画像 Markdown 镜像:
|
|
32
|
-
`~/.openclaw/data/bamdra-user-bind/profiles/private/{userId}.md`
|
|
33
|
-
- 导出目录:
|
|
34
|
-
`~/.openclaw/data/bamdra-user-bind/exports/`
|
|
23
|
+
没有身份层时:
|
|
35
24
|
|
|
36
|
-
|
|
25
|
+
- 同一个人可能在不同渠道或会话里碎片化
|
|
26
|
+
- 记忆可能挂错边界
|
|
27
|
+
- 个性化很难稳定
|
|
37
28
|
|
|
38
|
-
|
|
29
|
+
有了它之后:
|
|
39
30
|
|
|
40
|
-
|
|
31
|
+
- user-aware 记忆会稳定下来
|
|
32
|
+
- 个性化会跨 session 持续存在
|
|
33
|
+
- 智能体会逐步适应用户的风格和习惯
|
|
41
34
|
|
|
42
|
-
|
|
35
|
+
## 存储模型
|
|
43
36
|
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
37
|
+
- 主存储:
|
|
38
|
+
`~/.openclaw/data/bamdra-user-bind/profiles.sqlite`
|
|
39
|
+
- 可编辑 Markdown 镜像:
|
|
40
|
+
`~/.openclaw/data/bamdra-user-bind/profiles/private/{userId}.md`
|
|
41
|
+
- 导出目录:
|
|
42
|
+
`~/.openclaw/data/bamdra-user-bind/exports/`
|
|
47
43
|
|
|
48
|
-
|
|
44
|
+
SQLite 是受控主源。
|
|
49
45
|
|
|
50
|
-
|
|
46
|
+
Markdown 镜像则是给人编辑的,让用户画像更像一份活的 per-user 指南,而不是一个无法触达的黑盒。
|
|
51
47
|
|
|
52
|
-
|
|
53
|
-
- 跨用户访问由实现层直接拒绝,不依赖 prompt 约束
|
|
54
|
-
- 管理员动作通过专用工具执行
|
|
55
|
-
- 管理员查询、编辑、合并、同步与拒绝访问都会留下审计记录
|
|
48
|
+
## 最佳实践
|
|
56
49
|
|
|
57
|
-
|
|
50
|
+
- SQLite 留在本地
|
|
51
|
+
- 画像镜像保持私有
|
|
52
|
+
- 让人逐步维护画像镜像
|
|
53
|
+
- 管理员能力只用于审计、合并、修复和维护
|
|
58
54
|
|
|
59
|
-
|
|
60
|
-
本身就可以作为身份插件使用
|
|
61
|
-
- 自动配套:
|
|
62
|
-
通过 npm 安装 `bamdra-openclaw-memory` 时,主插件可以在 bootstrap 过程中自动补齐它
|
|
63
|
-
- 可选配套:
|
|
64
|
-
`bamdra-memory-vector`
|
|
55
|
+
## 它能解锁什么
|
|
65
56
|
|
|
66
|
-
|
|
57
|
+
与 `bamdra-openclaw-memory` 组合时:
|
|
67
58
|
|
|
68
|
-
|
|
59
|
+
- 记忆会从 session-only 变成真正的 user-aware
|
|
69
60
|
|
|
70
|
-
|
|
71
|
-
- `bamdra-user-bind-admin`
|
|
61
|
+
与 `bamdra-memory-vector` 组合时:
|
|
72
62
|
|
|
73
|
-
|
|
63
|
+
- 私有笔记既能保持私有,又能影响本地召回
|
|
74
64
|
|
|
75
|
-
##
|
|
65
|
+
## 仓库地址
|
|
76
66
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
```
|
|
67
|
+
- [GitHub 首页](https://github.com/bamdra)
|
|
68
|
+
- [仓库地址](https://github.com/bamdra/bamdra-user-bind)
|
package/dist/index.js
CHANGED
|
@@ -1346,7 +1346,7 @@ function renderProfileMarkdown(profile) {
|
|
|
1346
1346
|
`updatedAt: ${escapeFrontmatter(profile.updatedAt)}`,
|
|
1347
1347
|
"---"
|
|
1348
1348
|
].join("\n");
|
|
1349
|
-
const notes = profile.notes ?? defaultProfileNotes();
|
|
1349
|
+
const notes = sanitizeProfileNotes(profile.notes) ?? defaultProfileNotes();
|
|
1350
1350
|
return `${frontmatter}
|
|
1351
1351
|
|
|
1352
1352
|
# \u7528\u6237\u753B\u50CF
|
|
@@ -1390,7 +1390,7 @@ function parseProfileMarkdown(markdown) {
|
|
|
1390
1390
|
const body = lines.slice(index).join("\n");
|
|
1391
1391
|
const notesMatch = body.match(/##\s*备注\s*\n([\s\S]*)$/);
|
|
1392
1392
|
if (notesMatch?.[1]) {
|
|
1393
|
-
notes = notesMatch[1]
|
|
1393
|
+
notes = sanitizeProfileNotes(notesMatch[1]);
|
|
1394
1394
|
}
|
|
1395
1395
|
return {
|
|
1396
1396
|
profilePatch: patch,
|
|
@@ -1608,6 +1608,18 @@ function defaultProfileNotes() {
|
|
|
1608
1608
|
"- \u4F60\u53EF\u4EE5\u5728\u8FD9\u91CC\u7EE7\u7EED\u8865\u5145\u5DE5\u4F5C\u80CC\u666F\u3001\u8868\u8FBE\u4E60\u60EF\u3001\u7981\u5FCC\u548C\u957F\u671F\u504F\u597D\u3002"
|
|
1609
1609
|
].join("\n");
|
|
1610
1610
|
}
|
|
1611
|
+
function sanitizeProfileNotes(notes) {
|
|
1612
|
+
const value = typeof notes === "string" ? notes.trim() : "";
|
|
1613
|
+
if (!value) {
|
|
1614
|
+
return null;
|
|
1615
|
+
}
|
|
1616
|
+
const normalized = value.replace(/\r/g, "");
|
|
1617
|
+
const marker = "## \u5907\u6CE8";
|
|
1618
|
+
const lastMarkerIndex = normalized.lastIndexOf(marker);
|
|
1619
|
+
const sliced = lastMarkerIndex >= 0 ? normalized.slice(lastMarkerIndex + marker.length) : normalized;
|
|
1620
|
+
const cleaned = sliced.replace(/^[::\s\n-]+/, "").replace(/^#\s*用户画像[\s\S]*?##\s*备注\s*/m, "").trim();
|
|
1621
|
+
return cleaned || null;
|
|
1622
|
+
}
|
|
1611
1623
|
function escapeFrontmatter(value) {
|
|
1612
1624
|
if (!value) {
|
|
1613
1625
|
return "null";
|
package/openclaw.plugin.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"type": "tool",
|
|
4
4
|
"name": "Bamdra User Bind",
|
|
5
5
|
"description": "Identity resolution, user profile binding, and admin profile tools for OpenClaw channels.",
|
|
6
|
-
"version": "0.1.
|
|
6
|
+
"version": "0.1.10",
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
8
|
"skills": ["./skills"],
|
|
9
9
|
"configSchema": {
|
package/package.json
CHANGED