lume-dsh-plugin 0.7.0 → 0.7.1
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 +6 -0
- package/lib/index.js +36 -9
- package/package.json +1 -5
package/README.md
CHANGED
|
@@ -305,6 +305,12 @@ Lume 因此选择「观察 + 重锚」:压缩发生时记录规模,在随后
|
|
|
305
305
|
- v0.1.0 旧版 `persona-state.json` 会在首次启动时自动导入并改名为 `.migrated`
|
|
306
306
|
- 全部数据保存在本地,不上传任何远端
|
|
307
307
|
|
|
308
|
+
## 宿主兼容性
|
|
309
|
+
|
|
310
|
+
- **RPC 通道必须注册在注入了 `webServer` 的作用域里**:宿主的 `connection.rpc.handle` 内部会以**调用方**的 ctx 执行 `webServer.register(route)`,所以正确写法只有 `ctx.inject(["webServer"], (webCtx) => webCtx.connection.rpc.handle(...))`(宿主自带的 `dsh-ppt`、`dsh-api-gateway` 同款)。0.7.1 起已修正;**0.6.2 / 0.7.0 在 DSH Desktop 0.9.1 上会导致 DSH 无法启动**(`cannot get property "webServer" without inject` → 插件树加载失败 → 进 safe mode),请升级。没有 web 载体的宿主只失去 RPC 通道,其余功能照常。
|
|
311
|
+
- **插件不会拖垮宿主**:`apply()` 外层有兜底 try/catch,插件内部的任何异常都降级为「部分功能不可用 + `logger.error`」,不再阻断 DSH 启动。
|
|
312
|
+
- **peer 声明只留宿主运行时保证提供的包**:`@deepseek-ai/dsh-client-ui-primitives` 这类前端包由宿主模块图在运行时提供,**不声明为 peer**——新版桌面安装器做严格 peer 闭包校验,声明它会连带检查它自己的 peer(`dsh-client-runtime`),导致安装/更新被拒绝(desktop 会写进 `.generations-deferred.json` 并冻结整个 profile 迁移)。它仍在 `devDependencies`(tsc 类型与 tsdown external 需要)。
|
|
313
|
+
|
|
308
314
|
## 安装与更新
|
|
309
315
|
|
|
310
316
|
前置条件:已安装 DSH Desktop。
|
package/lib/index.js
CHANGED
|
@@ -102,7 +102,24 @@ const SWITCH_BOUNDARY_TURNS = 2;
|
|
|
102
102
|
export const name = "lume";
|
|
103
103
|
/** 依赖的服务 */
|
|
104
104
|
export const inject = ["systemPrompt", "connection", "storageDomain", "tools", "llm", "agentDefaultModel", "settings"];
|
|
105
|
+
/**
|
|
106
|
+
* 插件入口。**外层只做兜底**:任何宿主 API 变更都不该让 DSH 起不来。
|
|
107
|
+
*
|
|
108
|
+
* 0.7.0 的真实教训:新宿主(DSH Desktop 0.9.x / 宿主包 0.1.5-rc.2)里
|
|
109
|
+
* `connection.rpc.handle` 内部会以**调用方**的 ctx 去 `owner.webServer.register(...)`,
|
|
110
|
+
* 未注入 webServer 时 cordis 抛 "cannot get property \"webServer\" without inject";
|
|
111
|
+
* 插件 apply 抛错 → 整个插件树加载失败 → `DSH entry failed`,用户连界面都进不去。
|
|
112
|
+
* 把异常圈在插件内部,降级成「部分功能不可用」远比「宿主起不来」可接受。
|
|
113
|
+
*/
|
|
105
114
|
export function apply(ctx, config = {}) {
|
|
115
|
+
try {
|
|
116
|
+
applyInner(ctx, config);
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
ctx?.logger?.error?.("lume: 初始化失败,已降级(不影响 DSH 启动;请升级插件或反馈此错误)", error);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function applyInner(ctx, config = {}) {
|
|
106
123
|
const assetsDir = join(dirname(fileURLToPath(import.meta.url)), "..", "assets");
|
|
107
124
|
const builtins = loadPersonalities(assetsDir);
|
|
108
125
|
const sampleCount = config.sampleCount ?? 6;
|
|
@@ -1196,15 +1213,25 @@ export function apply(ctx, config = {}) {
|
|
|
1196
1213
|
return true;
|
|
1197
1214
|
},
|
|
1198
1215
|
});
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1216
|
+
// ── RPC 通道 ──
|
|
1217
|
+
// 必须在**注入了 webServer 的作用域**里注册:新宿主的 `connection.rpc.handle` 内部会
|
|
1218
|
+
// 用调用方 ctx 执行 `owner.webServer.register(route)`(见 dsh-client-connection 的
|
|
1219
|
+
// `owner.effect(() => owner.webServer.register(route))`),缺注入时 cordis 直接抛
|
|
1220
|
+
// "cannot get property \"webServer\" without inject"。宿主自带的 dsh-ppt / dsh-api-gateway
|
|
1221
|
+
// 也都是 `ctx.inject(["webServer"], (webCtx) => webCtx.connection.rpc.handle(...))` 这个写法。
|
|
1222
|
+
// 用作用域注入而不是把 webServer 塞进顶层 inject:没有 web 载体的宿主(headless)里只
|
|
1223
|
+
// 失去 RPC 通道,插件其余功能照常工作,不会被 inject 卡住。
|
|
1224
|
+
ctx.inject(["webServer"], (webCtx) => {
|
|
1225
|
+
webCtx.effect(() => webCtx.connection.rpc.handle(LUME_CHANNEL, async (endpoint, payload) => {
|
|
1226
|
+
currentStore ??= await storesReady;
|
|
1227
|
+
identity ??= await identityReady;
|
|
1228
|
+
const result = await handleEndpoint(endpoint, payload);
|
|
1229
|
+
if (endpoint !== "list" && endpoint !== "getSessionPersona") {
|
|
1230
|
+
webCtx.logger?.warn?.(`lume: rpc ${endpoint} ${JSON.stringify(payload ?? {})} → ok=${result.ok}${result.ok ? "" : ` code=${result.error.code}`}`);
|
|
1231
|
+
}
|
|
1232
|
+
return result;
|
|
1233
|
+
}, { authority: "trusted-host" }), "lume: rpc channel");
|
|
1234
|
+
});
|
|
1208
1235
|
// ── 系统提示词段落 ──
|
|
1209
1236
|
ctx.effect(() => ctx.systemPrompt.section({
|
|
1210
1237
|
name: LUME_PERSONA_SECTION,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lume-dsh-plugin",
|
|
3
3
|
"description": "微光 (Lume) — DSH Desktop 增强插件:给会话装上工程纪律与真实关系。纪律层约束「如何正确完成任务」——意图路由、阶段门控、真实工具证据、交付前复核、文档能力感知;方法层把量化需求、改动台账、假设台账与项目知识变成可检查的产出,并用行为触发器在轨迹上纠偏(撒网不收敛 / 连写不验 / 死路重撞);人设层塑造「以何种风格表达」——从聊天记录、小说、剧本、设定文档蒸馏具名角色,长期记忆与风格随对话演进。约束按需注入,闲聊不额外付 token。",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"exports": {
|
|
@@ -56,7 +56,6 @@
|
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
59
|
-
"@deepseek-ai/dsh-client-ui-primitives": "*",
|
|
60
59
|
"@deepseek-ai/dsh-llm": "*",
|
|
61
60
|
"@deepseek-ai/dsh-storage-domain": "*",
|
|
62
61
|
"@deepseek-ai/dsh-tools": "*",
|
|
@@ -98,9 +97,6 @@
|
|
|
98
97
|
"@deepseek-ai/cordis": {
|
|
99
98
|
"optional": true
|
|
100
99
|
},
|
|
101
|
-
"@deepseek-ai/dsh-client-ui-primitives": {
|
|
102
|
-
"optional": true
|
|
103
|
-
},
|
|
104
100
|
"@deepseek-ai/dsh-llm": {
|
|
105
101
|
"optional": true
|
|
106
102
|
},
|