dsh-cerebrum 0.1.1 → 0.1.2
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 +1 -0
- package/docs/publish.md +6 -0
- package/lib/api.js +1 -1
- package/lib/client.js +67 -2
- package/lib/config.js +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -57,6 +57,7 @@ dsh plugin --profile desktop add D:\workspace\dsh-cerebrum
|
|
|
57
57
|
|
|
58
58
|
- **不喜欢可以关掉**:面板里的 🙈 隐藏芯片(点小 🧠 恢复);彻底关闭用配置 `ui.enabled: false`(重启宿主生效,芯片完全不出现);
|
|
59
59
|
- 面板可**拖动**(按住标题栏)、可 **📌 固定**到输入栏上方成横条;
|
|
60
|
+
- **宠物联动(免配置)**:检测到同源的 `dsh-pet`(`/dsh-pet-7340`)时,情绪变化会自动推给桌宠——加锁 → 让宠物说一句大脑台词 → 释放锁;不需要用户配置。不想要联动可设 `ui.drivePet: false`;
|
|
60
61
|
- 数据来自宿主内置的 127.0.0.1 只读 API(`http://127.0.0.1:18734`,端口可配 `config.api.port`);
|
|
61
62
|
- UI 只读:修改记忆/情绪仍通过 `cerebrum_*` 工具;
|
|
62
63
|
- 免构建 client bundle(`lib/client.js`),与宿主同一个安装包——**装一个插件,大脑 + 面板都有**。
|
package/docs/publish.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# 发布 dsh-cerebrum 到 DSH 插件市场
|
|
2
2
|
|
|
3
|
+
> **发布状态(2026-10-28)**
|
|
4
|
+
> - GitHub 公开仓库:https://github.com/liu-wen-wu/dsh-cerebrum(main + tag v0.1.1,SSH 推送)
|
|
5
|
+
> - npm:`dsh-cerebrum@0.1.1` 已上线(latest;0.1.0 为上一版)
|
|
6
|
+
> - 市场收录申请:https://github.com/polang233/dsh-plugin-index/issues/121
|
|
7
|
+
> - 本地安装:`dsh-cerebrum@link:D:/workspace/dsh-cerebrum`(desktop profile,已热加载验证)
|
|
8
|
+
|
|
3
9
|
> 目标市场:dshopen.org(DSH 应用内「插件市场/Discover」读取的社区索引,`https://dshopen.org/index.json`)。
|
|
4
10
|
> 收录流程由 [dsh-plugin-index](https://github.com/polang233/dsh-plugin-index) 人工审核:**公开仓库 + 可安装的 npm 版本 + 明确许可证**,三样齐全后提 issue 收录。
|
|
5
11
|
|
package/lib/api.js
CHANGED
|
@@ -42,7 +42,7 @@ export const startBrainApi = (service, { port = 18734, ui = { enabled: true }, l
|
|
|
42
42
|
return send(res, 200, { ok: true, name: 'dsh-cerebrum', uptimeMs: Date.now() - service.startedAt })
|
|
43
43
|
case '/ui':
|
|
44
44
|
// The client respects this: ui.enabled=false removes the chip entirely.
|
|
45
|
-
return send(res, 200, { enabled: ui.enabled !== false })
|
|
45
|
+
return send(res, 200, { enabled: ui.enabled !== false, drivePet: ui.drivePet !== false })
|
|
46
46
|
case '/state': {
|
|
47
47
|
const sessionId = url.searchParams.get('session') || undefined
|
|
48
48
|
return send(res, 200, service.state(sessionId))
|
package/lib/client.js
CHANGED
|
@@ -86,17 +86,82 @@ window.__ModuleLoader__.load({
|
|
|
86
86
|
})
|
|
87
87
|
var panelRef = useRef(null)
|
|
88
88
|
var dragRef = useRef(null)
|
|
89
|
+
var petRef = useRef({ key: '', at: 0 })
|
|
90
|
+
var uiRef = useRef({ enabled: true, drivePet: true })
|
|
89
91
|
|
|
90
92
|
useEffect(function () {
|
|
91
93
|
var alive = true
|
|
92
94
|
// The host decides whether users opted out of the whole chip.
|
|
93
95
|
get('/ui').then(function (data) {
|
|
94
|
-
if (
|
|
96
|
+
if (data) {
|
|
97
|
+
uiRef.current = { enabled: data.enabled !== false, drivePet: data.drivePet !== false }
|
|
98
|
+
if (!alive) return
|
|
99
|
+
if (data.enabled === false) setUiEnabled(false)
|
|
100
|
+
}
|
|
95
101
|
})
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Built-in pet bridge: no setup required. When a dsh-pet instance is
|
|
105
|
+
* detected on this origin, emotion changes are pushed to it as a
|
|
106
|
+
* locked "performance" (bubble line), then the lock is released.
|
|
107
|
+
*/
|
|
108
|
+
var drivePet = function (hints) {
|
|
109
|
+
if (uiRef.current.drivePet === false) return
|
|
110
|
+
var key = (hints.emotionKey || '') + '|' + (hints.line || '')
|
|
111
|
+
var now = Date.now()
|
|
112
|
+
if (petRef.current.key === key) return
|
|
113
|
+
if (now - petRef.current.at < 20000) return
|
|
114
|
+
if ((hints.intensity || 0) < 0.25) return
|
|
115
|
+
petRef.current.key = key
|
|
116
|
+
petRef.current.at = now
|
|
117
|
+
fetch('/dsh-pet-7340/state')
|
|
118
|
+
.then(function (r) { return r.ok ? r.json() : null })
|
|
119
|
+
.then(function (st) {
|
|
120
|
+
if (!st || !st.pets) return
|
|
121
|
+
var id = Object.keys(st.pets)[0]
|
|
122
|
+
if (!id) return
|
|
123
|
+
var attempt = function (surface) {
|
|
124
|
+
var q = '?pet=' + encodeURIComponent(id) + '&surface=' + surface
|
|
125
|
+
return fetch('/dsh-pet-7340/lock' + q, {
|
|
126
|
+
method: 'POST',
|
|
127
|
+
headers: { 'Content-Type': 'application/json' },
|
|
128
|
+
body: JSON.stringify({ ttl: 8000, surface: surface }),
|
|
129
|
+
})
|
|
130
|
+
.then(function (r) { return r.json() })
|
|
131
|
+
.then(function (lock) {
|
|
132
|
+
if (!lock || lock.ok === false || !lock.lockId) {
|
|
133
|
+
if (surface === 'web') return attempt('desktop')
|
|
134
|
+
return
|
|
135
|
+
}
|
|
136
|
+
var lq = q + '&lock=' + encodeURIComponent(lock.lockId)
|
|
137
|
+
return fetch('/dsh-pet-7340/broadcast' + lq, {
|
|
138
|
+
method: 'POST',
|
|
139
|
+
headers: { 'Content-Type': 'application/json' },
|
|
140
|
+
body: JSON.stringify({ text: hints.line, duration: 6000 }),
|
|
141
|
+
})
|
|
142
|
+
.catch(function () {})
|
|
143
|
+
.then(function () {
|
|
144
|
+
return fetch('/dsh-pet-7340/lock/release' + q, {
|
|
145
|
+
method: 'POST',
|
|
146
|
+
headers: { 'Content-Type': 'application/json' },
|
|
147
|
+
body: JSON.stringify({ lockId: lock.lockId }),
|
|
148
|
+
}).catch(function () {})
|
|
149
|
+
})
|
|
150
|
+
})
|
|
151
|
+
}
|
|
152
|
+
return attempt('web')
|
|
153
|
+
})
|
|
154
|
+
.catch(function () {})
|
|
155
|
+
}
|
|
156
|
+
|
|
96
157
|
var tick = function () {
|
|
97
|
-
|
|
158
|
+
var qs = sessionId ? '?session=' + encodeURIComponent(sessionId) : ''
|
|
159
|
+
get('/state' + qs).then(function (data) {
|
|
98
160
|
if (alive && data) setState(data)
|
|
99
161
|
})
|
|
162
|
+
get('/render-hints' + qs).then(function (hints) {
|
|
163
|
+
if (alive && hints) drivePet(hints)
|
|
164
|
+
})
|
|
100
165
|
}
|
|
101
166
|
tick()
|
|
102
167
|
var timer = setInterval(tick, POLL_MS)
|
package/lib/config.js
CHANGED
|
@@ -49,6 +49,8 @@ export const DEFAULT_CONFIG = {
|
|
|
49
49
|
/** Client UI (the brain chip/dashboard). Users who dislike it can switch it off. */
|
|
50
50
|
ui: {
|
|
51
51
|
enabled: true,
|
|
52
|
+
/** Built-in bridge: drive a detected dsh-pet with brain emotions. */
|
|
53
|
+
drivePet: true,
|
|
52
54
|
},
|
|
53
55
|
autoCapture: {
|
|
54
56
|
enabled: true,
|
|
@@ -120,6 +122,7 @@ export const resolveConfig = (raw, { home = resolveHome(), cwd = process.cwd() }
|
|
|
120
122
|
merged.api.enabled = merged.api.enabled !== false
|
|
121
123
|
merged.api.port = Math.round(clampNumber(merged.api.port, 18734, 1024, 65535))
|
|
122
124
|
merged.ui.enabled = merged.ui.enabled !== false
|
|
125
|
+
merged.ui.drivePet = merged.ui.drivePet !== false
|
|
123
126
|
merged.autoCapture.maxTextChars = Math.round(clampNumber(merged.autoCapture.maxTextChars, 2000, 200, 20000))
|
|
124
127
|
merged.autoCapture.toolResultChars = Math.round(clampNumber(merged.autoCapture.toolResultChars, 300, 40, 4000))
|
|
125
128
|
merged.autoCapture.minChars = Math.round(clampNumber(merged.autoCapture.minChars, 6, 0, 500))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-cerebrum",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Brain-inspired cognitive architecture for DeepSeek Harness: hippocampal episodic memory, cortical semantic memory, spreading-activation recall, appraisal-based emotion, neuromodulator state, Big Five personality and dual-process judgment.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|