dsh-mnemon 0.4.1 → 0.4.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 +4 -2
- package/README.zh-CN.md +4 -2
- package/lib/client.js +740 -647
- package/lib/index.js +60 -2
- package/lib/types/src/client/MnemonView.d.ts +3 -1
- package/lib/types/src/client/locales.d.ts +14 -0
- package/lib/types/src/settings.d.ts +2 -0
- package/lib/types/src/shared/contracts.d.ts +5 -0
- package/lib/types/src/shared/display-mode.d.ts +3 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -14,6 +14,14 @@ import { strToU8, unzipSync, zipSync } from "fflate";
|
|
|
14
14
|
import { execFileSync } from "node:child_process";
|
|
15
15
|
import { fileURLToPath } from "node:url";
|
|
16
16
|
import { z as z$1 } from "zod";
|
|
17
|
+
//#region src/shared/display-mode.ts
|
|
18
|
+
/** Keep the historical misspelling at input boundaries, never in UI or runtime state. */
|
|
19
|
+
function normalizeDisplayMode(value) {
|
|
20
|
+
if (value === void 0 || value === "sidebar") return "sidebar";
|
|
21
|
+
if (value === "builtin" || value === "buildin") return "builtin";
|
|
22
|
+
throw new Error("dsh-mnemon: displayMode must be sidebar or builtin (legacy buildin is accepted)");
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
17
25
|
//#region src/shared/contracts.ts
|
|
18
26
|
const MNEMON_READ_CHANNEL = "/dsh-mnemon-read";
|
|
19
27
|
const MNEMON_ACTIVATION_CHANNEL = "/dsh-mnemon-activation";
|
|
@@ -202,6 +210,11 @@ const Config = z.object({
|
|
|
202
210
|
maxUnknownResults: 2
|
|
203
211
|
}),
|
|
204
212
|
routingGuidance: z.boolean().default(true),
|
|
213
|
+
displayMode: z.union([
|
|
214
|
+
"sidebar",
|
|
215
|
+
"builtin",
|
|
216
|
+
"buildin"
|
|
217
|
+
]).default("sidebar"),
|
|
205
218
|
tabEnabled: z.boolean().default(true),
|
|
206
219
|
writeEnabled: z.boolean().default(true),
|
|
207
220
|
remoteAccess: z.union(["read-only", "trusted-host"]).default("read-only"),
|
|
@@ -457,6 +470,7 @@ function resolveConfig(config = {}) {
|
|
|
457
470
|
memoryTopology: resolveMemoryTopology(config.memoryTopology),
|
|
458
471
|
recallQuality: resolveRecallQuality(config.recallQuality),
|
|
459
472
|
routingGuidance: config.routingGuidance ?? true,
|
|
473
|
+
displayMode: normalizeDisplayMode(config.displayMode),
|
|
460
474
|
tabEnabled: config.tabEnabled ?? true,
|
|
461
475
|
writeEnabled: config.writeEnabled ?? true,
|
|
462
476
|
remoteAccess: config.remoteAccess ?? "read-only",
|
|
@@ -9861,7 +9875,10 @@ function descriptor(settings, namespace) {
|
|
|
9861
9875
|
if (view === void 0) throw new Error(`${namespace} settings namespace is unavailable`);
|
|
9862
9876
|
return {
|
|
9863
9877
|
status: "ready",
|
|
9864
|
-
value: view.value
|
|
9878
|
+
value: namespace === "mnemon" && displayModeOf(view.value) === "buildin" ? {
|
|
9879
|
+
...object(view.value),
|
|
9880
|
+
displayMode: "builtin"
|
|
9881
|
+
} : view.value,
|
|
9865
9882
|
base: view.base,
|
|
9866
9883
|
user: view.user,
|
|
9867
9884
|
revision: view.revision,
|
|
@@ -9874,6 +9891,28 @@ function object(value) {
|
|
|
9874
9891
|
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error("payload must be an object");
|
|
9875
9892
|
return value;
|
|
9876
9893
|
}
|
|
9894
|
+
function displayModeOf(value) {
|
|
9895
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value.displayMode : void 0;
|
|
9896
|
+
}
|
|
9897
|
+
/** Canonicalize only the legacy field through DSH's locked, revision-fenced writer. */
|
|
9898
|
+
async function migrateLegacyDisplayMode(settings) {
|
|
9899
|
+
if (!settings.writable) return;
|
|
9900
|
+
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
9901
|
+
const view = settings.describe({ redactSecrets: true }).find((candidate) => candidate.ns === MNEMON_SETTINGS_NAMESPACE);
|
|
9902
|
+
if (view === void 0) return;
|
|
9903
|
+
if ((typeof view.user === "object" && view.user !== null && Object.hasOwn(view.user, "displayMode") ? displayModeOf(view.user) : displayModeOf(view.base) ?? displayModeOf(view.value)) !== "buildin") return;
|
|
9904
|
+
try {
|
|
9905
|
+
await settings.mutate(MNEMON_SETTINGS_NAMESPACE, [{
|
|
9906
|
+
op: "set",
|
|
9907
|
+
path: ["displayMode"],
|
|
9908
|
+
value: "builtin"
|
|
9909
|
+
}], view.revision);
|
|
9910
|
+
return;
|
|
9911
|
+
} catch (error) {
|
|
9912
|
+
if (attempt === 2 || typeof error !== "object" || error === null || !("code" in error) || error.code !== "SETTINGS_CONFLICT") throw error;
|
|
9913
|
+
}
|
|
9914
|
+
}
|
|
9915
|
+
}
|
|
9877
9916
|
const MUTABLE_FIELDS = [
|
|
9878
9917
|
"storageScope",
|
|
9879
9918
|
"runtimeUserScope",
|
|
@@ -9892,6 +9931,7 @@ const MUTABLE_FIELDS = [
|
|
|
9892
9931
|
"recallMode",
|
|
9893
9932
|
"writebackMode",
|
|
9894
9933
|
"idleReviewMs",
|
|
9934
|
+
"displayMode",
|
|
9895
9935
|
"tabEnabled",
|
|
9896
9936
|
"writeEnabled",
|
|
9897
9937
|
"persistenceStrategy",
|
|
@@ -9936,11 +9976,12 @@ function createSettingsHandler(settings) {
|
|
|
9936
9976
|
return {
|
|
9937
9977
|
op: "set",
|
|
9938
9978
|
path,
|
|
9939
|
-
value: op.value
|
|
9979
|
+
value: namespace === "mnemon" && path[0] === "displayMode" ? normalizeDisplayMode(op.value) : op.value
|
|
9940
9980
|
};
|
|
9941
9981
|
});
|
|
9942
9982
|
const revision = payload.expectedRevision === void 0 ? void 0 : Number(payload.expectedRevision);
|
|
9943
9983
|
await settings.mutate(namespace, ops, revision);
|
|
9984
|
+
if (namespace === "mnemon") await migrateLegacyDisplayMode(settings);
|
|
9944
9985
|
return success(descriptor(settings, namespace));
|
|
9945
9986
|
} catch (error) {
|
|
9946
9987
|
return failure(error, namespace);
|
|
@@ -10937,6 +10978,23 @@ function apply(rawContext, config = {}) {
|
|
|
10937
10978
|
base: resolveInteractionConfig(resolved.conversationInteraction),
|
|
10938
10979
|
applies: "live"
|
|
10939
10980
|
});
|
|
10981
|
+
ctx.effect(() => {
|
|
10982
|
+
let disposed = false;
|
|
10983
|
+
const migrate = () => {
|
|
10984
|
+
if (disposed) return;
|
|
10985
|
+
migrateLegacyDisplayMode(ctx.settings).catch((error) => {
|
|
10986
|
+
console.warn("dsh-mnemon: could not persist the builtin displayMode migration", error);
|
|
10987
|
+
});
|
|
10988
|
+
};
|
|
10989
|
+
const unsubscribe = ctx.on("settings/document-updated", ((namespace) => {
|
|
10990
|
+
if (namespace === "mnemon") migrate();
|
|
10991
|
+
}));
|
|
10992
|
+
migrate();
|
|
10993
|
+
return () => {
|
|
10994
|
+
disposed = true;
|
|
10995
|
+
unsubscribe();
|
|
10996
|
+
};
|
|
10997
|
+
}, "dsh-mnemon: canonical displayMode migration");
|
|
10940
10998
|
const coordinator = new MnemonSubagentCoordinator(ctx.subagents, runtime, void 0, ctx, () => {
|
|
10941
10999
|
const taskAgentModel = runtime.config.taskAgentModel;
|
|
10942
11000
|
if (taskAgentModel.mode !== "fixed") return void 0;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ClientConnectionHandle, type ClientSettingsScope, type Config } from '../shared/contracts.ts';
|
|
1
|
+
import { type ClientConnectionHandle, type ClientSettingsScope, type Config, type MnemonDisplayMode } from '../shared/contracts.ts';
|
|
2
2
|
import { type MnemonTranslate } from './locales.ts';
|
|
3
3
|
export interface MnemonViewProps {
|
|
4
4
|
connection: ClientConnectionHandle;
|
|
@@ -6,6 +6,8 @@ export interface MnemonViewProps {
|
|
|
6
6
|
sessionId?: string;
|
|
7
7
|
workspaceId?: string;
|
|
8
8
|
workspaceSelection?: MnemonWorkspaceSelection;
|
|
9
|
+
/** Placement affects the scope header, never the shared pages or skin. */
|
|
10
|
+
surface?: MnemonDisplayMode;
|
|
9
11
|
t?: MnemonTranslate;
|
|
10
12
|
locale?: string;
|
|
11
13
|
onClose?: () => void;
|
|
@@ -657,6 +657,13 @@ export declare const zh: {
|
|
|
657
657
|
'config.ready': string;
|
|
658
658
|
'config.noticeBefore': string;
|
|
659
659
|
'config.noticeAfter': string;
|
|
660
|
+
'config.displayTitle': string;
|
|
661
|
+
'config.displayDescription': string;
|
|
662
|
+
'config.displayAria': string;
|
|
663
|
+
'config.displaySidebar': string;
|
|
664
|
+
'config.displaySidebarHint': string;
|
|
665
|
+
'config.displayBuiltin': string;
|
|
666
|
+
'config.displayBuiltinHint': string;
|
|
660
667
|
'config.storageTitle': string;
|
|
661
668
|
'config.storageDescription': string;
|
|
662
669
|
'config.scope': string;
|
|
@@ -1531,6 +1538,13 @@ export declare const en: {
|
|
|
1531
1538
|
'config.ready': string;
|
|
1532
1539
|
'config.noticeBefore': string;
|
|
1533
1540
|
'config.noticeAfter': string;
|
|
1541
|
+
'config.displayTitle': string;
|
|
1542
|
+
'config.displayDescription': string;
|
|
1543
|
+
'config.displayAria': string;
|
|
1544
|
+
'config.displaySidebar': string;
|
|
1545
|
+
'config.displaySidebarHint': string;
|
|
1546
|
+
'config.displayBuiltin': string;
|
|
1547
|
+
'config.displayBuiltinHint': string;
|
|
1534
1548
|
'config.storageTitle': string;
|
|
1535
1549
|
'config.storageDescription': string;
|
|
1536
1550
|
'config.scope': string;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { HostConnectionHandle, HostRpcAuthority, HostRpcHandler, HostSettingsService } from './contracts.ts';
|
|
2
2
|
export { MNEMON_SETTINGS_CHANNEL, MNEMON_SETTINGS_NAMESPACE, MNEMON_UI_SETTINGS_NAMESPACE } from './shared/contracts.ts';
|
|
3
|
+
/** Canonicalize only the legacy field through DSH's locked, revision-fenced writer. */
|
|
4
|
+
export declare function migrateLegacyDisplayMode(settings: HostSettingsService): Promise<void>;
|
|
3
5
|
export declare function createSettingsHandler(settings: HostSettingsService): HostRpcHandler;
|
|
4
6
|
export declare function registerSettingsRpc(connection: HostConnectionHandle, settings: HostSettingsService, authority?: HostRpcAuthority): void;
|
|
@@ -132,6 +132,8 @@ export interface ResolvedRecallQualityConfig {
|
|
|
132
132
|
maxMediumResults: number;
|
|
133
133
|
maxUnknownResults: number;
|
|
134
134
|
}
|
|
135
|
+
export { normalizeDisplayMode } from './display-mode.ts';
|
|
136
|
+
export type MnemonDisplayMode = 'sidebar' | 'builtin';
|
|
135
137
|
export interface Config {
|
|
136
138
|
storageScope?: StorageScopeKind;
|
|
137
139
|
/** Whether USER.md follows the selected storage root or stays in the global root. */
|
|
@@ -149,6 +151,8 @@ export interface Config {
|
|
|
149
151
|
memoryTopology?: MemoryTopologyConfig;
|
|
150
152
|
recallQuality?: RecallQualityConfig;
|
|
151
153
|
routingGuidance?: boolean;
|
|
154
|
+
/** Entry placement only. Legacy `buildin` input is migrated to `builtin`. */
|
|
155
|
+
displayMode?: MnemonDisplayMode | 'buildin';
|
|
152
156
|
tabEnabled?: boolean;
|
|
153
157
|
writeEnabled?: boolean;
|
|
154
158
|
/** DSH rc.2 management-channel authority; ignored by DSH 0.1.2-alpha.1. */
|
|
@@ -242,6 +246,7 @@ export interface ResolvedConfig {
|
|
|
242
246
|
memoryTopology: ResolvedMemoryTopologyConfig;
|
|
243
247
|
recallQuality: ResolvedRecallQualityConfig;
|
|
244
248
|
routingGuidance: boolean;
|
|
249
|
+
displayMode: MnemonDisplayMode;
|
|
245
250
|
tabEnabled: boolean;
|
|
246
251
|
writeEnabled: boolean;
|
|
247
252
|
/** DSH rc.2 management-channel authority; ignored by DSH 0.1.2-alpha.1. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mnemon",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Composable three-tier memory control plane for DeepSeek Harness: persistent runtime context, searchable project documents, pluggable long-term memory, guarded strategies, WebUI, and headless tools.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deepseek-harness",
|