@lin0306/dsh-mind 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/lib/index.js +34 -8
- package/lib/index.js.map +1 -1
- package/lib/types/.tsbuildinfo +1 -1
- package/lib/types/host.d.ts +26 -2
- package/lib/types/host.d.ts.map +1 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/projection.d.ts +14 -3
- package/lib/types/projection.d.ts.map +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -5904,7 +5904,7 @@ function makeView(state, t) {
|
|
|
5904
5904
|
* `init` 就是新会话的起点:从跨会话档案里**接管**人设与长期记忆,
|
|
5905
5905
|
* 但情感/思想/进度从零开始(它们永远是"这一段对话内"的)。
|
|
5906
5906
|
*/
|
|
5907
|
-
function registerProjection(projections, deps) {
|
|
5907
|
+
async function registerProjection(projections, deps) {
|
|
5908
5908
|
const definition = {
|
|
5909
5909
|
key: PROJECTION_KEY,
|
|
5910
5910
|
stateVersion: 3,
|
|
@@ -5954,12 +5954,30 @@ function registerProjection(projections, deps) {
|
|
|
5954
5954
|
}
|
|
5955
5955
|
}
|
|
5956
5956
|
};
|
|
5957
|
-
|
|
5957
|
+
try {
|
|
5958
|
+
return await projections.register(definition);
|
|
5959
|
+
} catch (error) {
|
|
5960
|
+
logger.warn("[dsh-mind] 注册投影失败:面板与注入会没有数据", error);
|
|
5961
|
+
return;
|
|
5962
|
+
}
|
|
5958
5963
|
}
|
|
5959
|
-
/**
|
|
5960
|
-
|
|
5964
|
+
/**
|
|
5965
|
+
* 从会话上取状态;拿不到就返回 `undefined`(绝不用空状态掩盖问题)。
|
|
5966
|
+
*
|
|
5967
|
+
* 优先用注册时拿到的**句柄**(DSH 0.2.x 的推荐路径,自己折叠、不打弃用警告);
|
|
5968
|
+
* 句柄不可用(老宿主 / 假宿主)才回落注册表级读取——那条从 0.2.1-rc.2 起已弃用。
|
|
5969
|
+
*/
|
|
5970
|
+
function stateOfVia(registration, projections, session) {
|
|
5961
5971
|
try {
|
|
5962
|
-
const
|
|
5972
|
+
const handle = registration;
|
|
5973
|
+
if (handle !== void 0 && typeof handle.stateOf === "function") {
|
|
5974
|
+
const value = handle.stateOf(session);
|
|
5975
|
+
if (value === null || value === void 0 || typeof value !== "object") return void 0;
|
|
5976
|
+
return value;
|
|
5977
|
+
}
|
|
5978
|
+
const fallback = projections.stateOf;
|
|
5979
|
+
if (typeof fallback !== "function") return void 0;
|
|
5980
|
+
const value = fallback.call(projections, session, PROJECTION_KEY);
|
|
5963
5981
|
if (value === null || value === void 0 || typeof value !== "object") return void 0;
|
|
5964
5982
|
return value;
|
|
5965
5983
|
} catch (error) {
|
|
@@ -5967,6 +5985,14 @@ function stateOf(projections, session) {
|
|
|
5967
5985
|
return;
|
|
5968
5986
|
}
|
|
5969
5987
|
}
|
|
5988
|
+
/**
|
|
5989
|
+
* 老入口:直接按注册表读。
|
|
5990
|
+
*
|
|
5991
|
+
* @deprecated 用 `stateOfVia(句柄, …)`。这里只为向后兼容而保留。
|
|
5992
|
+
*/
|
|
5993
|
+
function stateOf(projections, session) {
|
|
5994
|
+
return stateOfVia(void 0, projections, session);
|
|
5995
|
+
}
|
|
5970
5996
|
// src/settings-bridge.ts
|
|
5971
5997
|
/**
|
|
5972
5998
|
* 设置页的宿主半边:把"心念"的配置接到 DSH 的设置服务上,再开一条受围栏的路由给客户端读写。
|
|
@@ -7210,7 +7236,7 @@ function globalOnly(memory) {
|
|
|
7210
7236
|
* @param ctx 插件作用域(root)。每-agent 的东西一律在 `agent/created` 里用 `agent.ctx` 注册。
|
|
7211
7237
|
* @param config patch 里给的配置(可能是 `{}`、可能缺键,按默认补齐)
|
|
7212
7238
|
*/
|
|
7213
|
-
function apply(ctx, config) {
|
|
7239
|
+
async function apply(ctx, config) {
|
|
7214
7240
|
const now0 = Date.now();
|
|
7215
7241
|
const enabled = flag(config, "enabled");
|
|
7216
7242
|
const tunables = toTunables(config);
|
|
@@ -7332,7 +7358,7 @@ function apply(ctx, config) {
|
|
|
7332
7358
|
return state;
|
|
7333
7359
|
}
|
|
7334
7360
|
};
|
|
7335
|
-
registerProjection(projections, {
|
|
7361
|
+
const registration = await registerProjection(projections, {
|
|
7336
7362
|
tunables: () => tunables,
|
|
7337
7363
|
adoptPersist,
|
|
7338
7364
|
note: (message) => logger.info(message),
|
|
@@ -7363,7 +7389,7 @@ function apply(ctx, config) {
|
|
|
7363
7389
|
};
|
|
7364
7390
|
}
|
|
7365
7391
|
});
|
|
7366
|
-
const stateOfSession = (session) =>
|
|
7392
|
+
const stateOfSession = (session) => stateOfVia(registration, projections, session);
|
|
7367
7393
|
const systemPrompt = service(ctx, "systemPrompt");
|
|
7368
7394
|
if (systemPrompt !== void 0 && enabled) {
|
|
7369
7395
|
if (flag(config, "injectRealtime")) registerRealtimeContext(systemPrompt, {
|