dsh-layers-hippocampus 1.7.0 → 1.7.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/CHANGELOG.md +1910 -1845
- package/README.md +24 -3
- package/docs/ARCHITECTURE.zh.md +2 -2
- package/index.js +180 -10
- package/package.json +1 -1
- package/src/config.js +41 -0
- package/src/hintFeedback.js +200 -0
- package/src/promptHygiene.js +144 -0
- package/src/utils/promptLayout.js +36 -1
- package/src/webRoutes.js +5 -0
- package/ui/client.js +1006 -675
package/ui/client.js
CHANGED
|
@@ -2531,6 +2531,7 @@
|
|
|
2531
2531
|
// v1.6.7 M1: visible in the 上下文窗口 card in both modes, so it must also be
|
|
2532
2532
|
// in the simple-mode allowlist — a control that renders but never saves is a lie.
|
|
2533
2533
|
'context.injectMode',
|
|
2534
|
+
'context.mode',
|
|
2534
2535
|
'raw.mode',
|
|
2535
2536
|
'raw.maxTotalMb',
|
|
2536
2537
|
'raw.compressionEngine',
|
|
@@ -2643,6 +2644,10 @@
|
|
|
2643
2644
|
target: Number(config.context.target),
|
|
2644
2645
|
injectPrompt: Boolean(config.context.injectPrompt),
|
|
2645
2646
|
injectMode: config.context && config.context.injectMode === 'full' ? 'full' : 'index',
|
|
2647
|
+
// v1.7.1: default to TASK — a build session must not be fed hints forever.
|
|
2648
|
+
mode: config.context && config.context.mode === 'expert' ? 'expert' : 'task',
|
|
2649
|
+
hintsIdleSilenceAfter: Number((config.context && config.context.hintsIdleSilenceAfter) ?? 8),
|
|
2650
|
+
statePointer: (config.context && config.context.statePointer) || { enabled: true, maxChars: 300 },
|
|
2646
2651
|
// v1.5.0 physical routing + session handoff. Read with defaults so an
|
|
2647
2652
|
// older Host half that has not learned these keys yet still renders.
|
|
2648
2653
|
autoSpaceFollow: Boolean((config.context && config.context.autoSpaceFollow) ?? false),
|
|
@@ -2918,306 +2923,39 @@
|
|
|
2918
2923
|
);
|
|
2919
2924
|
}
|
|
2920
2925
|
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
// v1.5.4 escape hatch: reset a wedged rollover/handoff state from the UI.
|
|
2934
|
-
const [escapeStatus, setEscapeStatus] = React.useState(null);
|
|
2935
|
-
const [escapeBusy, setEscapeBusy] = React.useState(false);
|
|
2936
|
-
|
|
2937
|
-
React.useEffect(() => {
|
|
2938
|
-
if (serverConfig && draft === null) setDraft(draftFromConfig(serverConfig));
|
|
2939
|
-
}, [serverConfig, draft]);
|
|
2940
|
-
|
|
2941
|
-
if (shellState === 'failed') {
|
|
2942
|
-
return h(
|
|
2943
|
-
'div',
|
|
2944
|
-
{ style: { padding: 16, display: 'flex', flexDirection: 'column', gap: 12 } },
|
|
2945
|
-
h(FailureBanner, { error: state.error || configState.error, attempts: state.attempts, gaveUp: state.gaveUp }),
|
|
2946
|
-
);
|
|
2947
|
-
}
|
|
2948
|
-
if (!serverConfig) return h('div', { style: { padding: 16 } }, h(PhaseCard, { payload: state.payload, error: configState.error, shellState }));
|
|
2949
|
-
if (!draft) return h('div', { style: { padding: 16, color: palette.muted } }, '读取配置…');
|
|
2950
|
-
|
|
2951
|
-
// The settings page follows the SAME global selector as the panel: its
|
|
2952
|
-
// status bar and space line describe the selected space, not a hard-coded
|
|
2953
|
-
// default. Switching in the panel updates this slot through the bus.
|
|
2954
|
-
const statsPayload = state.payload;
|
|
2955
|
-
const sessionPanel = statsPayload && statsPayload.panel ? statsPayload.panel.session : null;
|
|
2956
|
-
const reportedSpace = statsPayload && statsPayload.panel && statsPayload.panel.spaces ? statsPayload.panel.spaces.current : null;
|
|
2957
|
-
const displayedSpace = activeSpace || reportedSpace || 'default';
|
|
2958
|
-
|
|
2959
|
-
const edit = (path, value) => {
|
|
2960
|
-
setStatus(null);
|
|
2961
|
-
setDraft((prev) => {
|
|
2962
|
-
const next = {
|
|
2963
|
-
...prev,
|
|
2964
|
-
context: { ...(prev.context || {}) },
|
|
2965
|
-
// index joins the shallow-clone list so an 'index.maxPostingsPerTag'
|
|
2966
|
-
// edit never mutates the previous draft object (the class of bug that
|
|
2967
|
-
// makes a cancelled edit silently stick around).
|
|
2968
|
-
index: { ...(prev.index || {}) },
|
|
2969
|
-
temp: { ...(prev.temp || {}) },
|
|
2970
|
-
tagTree: { ...(prev.tagTree || {}) },
|
|
2971
|
-
// tools.disabled is an ARRAY: clone it so a cancelled edit cannot
|
|
2972
|
-
// mutate the previous draft's array in place.
|
|
2973
|
-
tools: {
|
|
2974
|
-
...(prev.tools || {}),
|
|
2975
|
-
disabled: Array.isArray(prev.tools && prev.tools.disabled) ? [...prev.tools.disabled] : [],
|
|
2976
|
-
},
|
|
2977
|
-
tagging: { ...(prev.tagging || {}) },
|
|
2978
|
-
features: { ...(prev.features || {}) },
|
|
2979
|
-
dream: { ...(prev.dream || {}) },
|
|
2980
|
-
l2Merge: { ...(prev.l2Merge || {}) },
|
|
2981
|
-
};
|
|
2982
|
-
if (path.indexOf('.') >= 0) {
|
|
2983
|
-
const [group, leaf] = path.split('.');
|
|
2984
|
-
next[group] = { ...(next[group] || {}), [leaf]: value };
|
|
2985
|
-
} else {
|
|
2986
|
-
next[path] = value;
|
|
2987
|
-
}
|
|
2988
|
-
return next;
|
|
2989
|
-
});
|
|
2990
|
-
};
|
|
2991
|
-
|
|
2992
|
-
/** Client pre-check mirrors the server ranges; the server stays the authority. */
|
|
2993
|
-
const validateDraft = () => {
|
|
2994
|
-
// v1.6.3 简洁模式:只校验可见项,隐藏项不提交也不阻止保存。
|
|
2995
|
-
const rules = simpleMode ? NUMBER_RULES.filter((rule) => SIMPLE_NUMBER_KEYS.includes(rule.key)) : NUMBER_RULES;
|
|
2996
|
-
for (const rule of rules) {
|
|
2997
|
-
const value = readPath(draft, rule.key);
|
|
2998
|
-
const number = Number(value);
|
|
2999
|
-
if (!Number.isFinite(number)) return `${rule.label} 必须是数字`;
|
|
3000
|
-
if (number < rule.min || number > rule.max) return `${rule.label} 必须在 ${rule.min} – ${rule.max} 之间(当前 ${number})`;
|
|
3001
|
-
}
|
|
3002
|
-
if (!simpleMode && !String(draft.maintenanceCron || '').trim()) return 'Cron 表达式不能为空';
|
|
3003
|
-
return null;
|
|
3004
|
-
};
|
|
3005
|
-
|
|
3006
|
-
const save = async () => {
|
|
3007
|
-
setStatus(null);
|
|
3008
|
-
const problem = validateDraft();
|
|
3009
|
-
if (problem) {
|
|
3010
|
-
setStatus({ tone: 'error', text: problem });
|
|
3011
|
-
return;
|
|
3012
|
-
}
|
|
3013
|
-
setSaving(true);
|
|
3014
|
-
// NOTE: dataDir is NOT part of this save. Physical storage migration
|
|
3015
|
-
// (A/B copy, state=migrating, old dir kept as backup) lives in the
|
|
3016
|
-
// separate system-level StorageMigratorUI and is submitted on its own.
|
|
3017
|
-
const patch = {
|
|
3018
|
-
maintenanceCron: String(draft.maintenanceCron).trim(),
|
|
3019
|
-
briefing: Boolean(draft.briefing),
|
|
3020
|
-
promptSection: Boolean(draft.promptSection),
|
|
3021
|
-
autoMaintainOnBoot: Boolean(draft.autoMaintainOnBoot),
|
|
3022
|
-
enableDream: Boolean(draft.enableDream),
|
|
3023
|
-
enableReflection: Boolean(draft.enableReflection),
|
|
3024
|
-
dreamIdleMinutes: Number(draft.dreamIdleMinutes),
|
|
3025
|
-
graphMaxEdges: Number(draft.graphMaxEdges),
|
|
3026
|
-
storageBudgetMb: Number(draft.storageBudgetMb),
|
|
3027
|
-
'decay.halfLifeDays': Number(draft.decayHalfLifeDays),
|
|
3028
|
-
'activeSet.cap': Number(draft.activeSetCap),
|
|
3029
|
-
maxRecallTopK: Number(draft.maxRecallTopK),
|
|
3030
|
-
'retrieval.topK': Number(draft.retrievalTopK),
|
|
3031
|
-
'context.maxTokens': Number(draft.context.maxTokens),
|
|
3032
|
-
'context.maxInjectTokens': Number(draft.context.maxInjectTokens),
|
|
3033
|
-
'context.threshold': Number(draft.context.threshold),
|
|
3034
|
-
'context.target': Number(draft.context.target),
|
|
3035
|
-
'context.injectPrompt': Boolean(draft.context.injectPrompt),
|
|
3036
|
-
'context.injectMode': draft.context.injectMode === 'full' ? 'full' : 'index',
|
|
3037
|
-
'context.autoSpaceFollow': Boolean(draft.context.autoSpaceFollow),
|
|
3038
|
-
'context.autoRolloverEnabled': Boolean(draft.context.autoRolloverEnabled),
|
|
3039
|
-
'context.coldStartInjectSummary': Boolean(draft.context.coldStartInjectSummary),
|
|
3040
|
-
'context.coldStartInjectRecentTurns': Boolean(draft.context.coldStartInjectRecentTurns),
|
|
3041
|
-
'context.autoRolloverThreshold': Number(draft.context.autoRolloverThreshold),
|
|
3042
|
-
'context.nativeTokenLimit': Number(draft.context.nativeTokenLimit),
|
|
3043
|
-
'context.requireExplicitConsentForTransfer': Boolean(draft.context.requireExplicitConsentForTransfer),
|
|
3044
|
-
'index.maxPostingsPerTag': Number(draft.index.maxPostingsPerTag),
|
|
3045
|
-
'tools.disabled': Array.isArray(draft.tools.disabled) ? [...draft.tools.disabled] : [],
|
|
3046
|
-
'tagging.autoTag': Boolean(draft.tagging.autoTag),
|
|
3047
|
-
'tagging.maxTags': Number(draft.tagging.maxTags),
|
|
3048
|
-
'features.multiSpace': Boolean(draft.features.multiSpace),
|
|
3049
|
-
'features.crossSpaceTransfer': Boolean(draft.features.crossSpaceTransfer),
|
|
3050
|
-
'features.crossSpaceRecall': Boolean(draft.features.crossSpaceRecall),
|
|
3051
|
-
'dream.useLlm': Boolean(draft.dream.useLlm),
|
|
3052
|
-
'dream.minGroupSize': Number(draft.dream.minGroupSize),
|
|
3053
|
-
'dream.maxGroupsPerRun': Number(draft.dream.maxGroupsPerRun),
|
|
3054
|
-
'dream.maxSummaryChars': Number(draft.dream.maxSummaryChars),
|
|
3055
|
-
'dream.maxSourceChars': Number(draft.dream.maxSourceChars),
|
|
3056
|
-
'dream.maxEventsPerGroup': Number(draft.dream.maxEventsPerGroup),
|
|
3057
|
-
'dream.llmTimeoutMs': Number(draft.dream.llmTimeoutMs),
|
|
3058
|
-
'dream.failureThreshold': Number(draft.dream.failureThreshold),
|
|
3059
|
-
'dream.cooldownMinutes': Number(draft.dream.cooldownMinutes),
|
|
3060
|
-
'dream.compensateAfterHours': Number(draft.dream.compensateAfterHours),
|
|
3061
|
-
'dream.onlyLowValley': Boolean(draft.dream.onlyLowValley),
|
|
3062
|
-
'l2Merge.enabled': Boolean(draft.l2Merge.enabled),
|
|
3063
|
-
'l2Merge.minGroupSize': Number(draft.l2Merge.minGroupSize),
|
|
3064
|
-
'l2Merge.maxGroupsPerRun': Number(draft.l2Merge.maxGroupsPerRun),
|
|
3065
|
-
'l2Merge.maxSummaryChars': Number(draft.l2Merge.maxSummaryChars),
|
|
3066
|
-
'temp.ttlDays': Number(draft.temp.ttlDays),
|
|
3067
|
-
'temp.promotionWindowDays': Number(draft.temp.promotionWindowDays),
|
|
3068
|
-
'raw.mode': String(draft.rawMode),
|
|
3069
|
-
'raw.minSalience': Number(draft.rawMinSalience),
|
|
3070
|
-
'raw.maxTotalMb': Number(draft.rawMaxTotalMb),
|
|
3071
|
-
'raw.retentionDays': Number(draft.rawRetentionDays),
|
|
3072
|
-
'raw.archiveAfterDays': Number(draft.rawArchiveAfterDays),
|
|
3073
|
-
'raw.compressionEngine': ['brotli', 'zstd', 'gzip'].includes(draft.rawCompressionEngine)
|
|
3074
|
-
? draft.rawCompressionEngine
|
|
3075
|
-
: 'brotli',
|
|
3076
|
-
'raw.maxScanTurns': Number(draft.rawMaxScanTurns),
|
|
3077
|
-
'delete.graceHours': Number(draft.deleteGraceHours),
|
|
3078
|
-
'review.enabled': Boolean(draft.reviewEnabled),
|
|
3079
|
-
'tagTree.midHalfLifeMultiplier': Number(draft.tagTree.midHalfLifeMultiplier),
|
|
3080
|
-
'tagTree.midGracePeriodDays': Number(draft.tagTree.midGracePeriodDays),
|
|
3081
|
-
'tagTree.pruneBatchSize': Number(draft.tagTree.pruneBatchSize),
|
|
3082
|
-
'tagTree.leafDecayFloor': Number(draft.tagTree.leafDecayFloor),
|
|
3083
|
-
'identity.eventTimePolicy': draft.eventTimePolicy,
|
|
3084
|
-
};
|
|
3085
|
-
// v1.6.3: 简洁模式只提交可见键,隐藏项在文件里保持原值(不重置为默认值)。
|
|
3086
|
-
const payloadPatch = simpleMode
|
|
3087
|
-
? Object.fromEntries(Object.entries(patch).filter(([key]) => SIMPLE_PATCH_KEYS.includes(key)))
|
|
3088
|
-
: patch;
|
|
3089
|
-
try {
|
|
3090
|
-
const { body } = await getJson(API.config, {
|
|
3091
|
-
method: 'POST',
|
|
3092
|
-
headers: { 'content-type': 'application/json' },
|
|
3093
|
-
body: JSON.stringify({ patch: payloadPatch }),
|
|
3094
|
-
});
|
|
3095
|
-
if (body && body.ok === true) {
|
|
3096
|
-
setDraft(draftFromConfig(body.config));
|
|
3097
|
-
setStatus({ tone: body.persisted ? 'ok' : 'warn', text: body.persisted ? '已保存并生效' : `已生效(未持久化):${body.note || ''}` });
|
|
3098
|
-
// The panel listens for this: it refetches stats + graph right away
|
|
3099
|
-
// instead of waiting for the next 3s poll.
|
|
3100
|
-
announce('config-changed');
|
|
3101
|
-
} else {
|
|
3102
|
-
const error = (body && body.error) || {};
|
|
3103
|
-
setStatus({ tone: 'error', text: `${error.code || 'MEM_E_UNKNOWN'}: ${error.message || '保存失败'}` });
|
|
3104
|
-
}
|
|
3105
|
-
} catch (error) {
|
|
3106
|
-
setStatus({ tone: 'error', text: String((error && error.message) || error) });
|
|
3107
|
-
} finally {
|
|
3108
|
-
setSaving(false);
|
|
3109
|
-
}
|
|
3110
|
-
};
|
|
3111
|
-
|
|
3112
|
-
const disabled = saving || shellState !== 'ready';
|
|
3113
|
-
|
|
3114
|
-
// Escape hatch handler: clear session baseline + in-flight guard + marker.
|
|
3115
|
-
// It never deletes memories; if it fails the panel reports the code plainly.
|
|
3116
|
-
const resetHandoffState = async () => {
|
|
3117
|
-
setEscapeBusy(true);
|
|
3118
|
-
setEscapeStatus(null);
|
|
3119
|
-
try {
|
|
3120
|
-
const { status: httpStatus, body } = await getJson(API.sessionReset, {
|
|
3121
|
-
method: 'POST',
|
|
3122
|
-
headers: { 'content-type': 'application/json' },
|
|
3123
|
-
body: JSON.stringify({ reason: 'ui_escape_hatch' }),
|
|
3124
|
-
});
|
|
3125
|
-
if (body && body.ok === true) {
|
|
3126
|
-
setEscapeStatus({ tone: 'ok', text: '已重置交接状态:会话基线清零、handoff 标记已消费' });
|
|
3127
|
-
announce('config-changed');
|
|
3128
|
-
} else {
|
|
3129
|
-
const error = (body && body.error) || {};
|
|
3130
|
-
setEscapeStatus({ tone: 'error', text: `重置失败:${error.code || 'MEM_E_UNKNOWN'} ${error.message || `HTTP ${httpStatus}`}` });
|
|
3131
|
-
}
|
|
3132
|
-
} catch (error) {
|
|
3133
|
-
setEscapeStatus({ tone: 'error', text: `重置失败:${(error && error.message) || error}` });
|
|
3134
|
-
} finally {
|
|
3135
|
-
setEscapeBusy(false);
|
|
3136
|
-
}
|
|
3137
|
-
};
|
|
2926
|
+
/**
|
|
2927
|
+
* v1.7.2: the settings page is no longer one 1200-line function. Five groups, one rail
|
|
2928
|
+
* item each; `visibleInSimple` makes the 简洁模式 promise (身份 / 上下文窗口 / 存储迁移 /
|
|
2929
|
+
* 原始回合留存) declarative instead of a `simpleMode &&` scattered across the JSX.
|
|
2930
|
+
*/
|
|
2931
|
+
const SETTINGS_GROUPS = [
|
|
2932
|
+
{ id: 'identity', label: '身份与行为', hint: '人格锚点 · 空闲行为', visibleInSimple: true },
|
|
2933
|
+
{ id: 'context', label: '上下文与注入', hint: '窗口记账 · 注入形态 · 运行模式 · 检索 · 调度', visibleInSimple: true },
|
|
2934
|
+
{ id: 'ingest', label: '摄入与蒸馏', hint: '打标 · 工具裁剪 · 能力开关 · Dream / L2 合并 / L2.5', visibleInSimple: false },
|
|
2935
|
+
{ id: 'retention', label: '留存与归档', hint: 'raw 冷热分层 · 标签树 · 老化 · 存储图谱 · 删除复习', visibleInSimple: true },
|
|
2936
|
+
{ id: 'space', label: '空间与存储', hint: '多空间路由 · 会话交接 · 数据目录迁移', visibleInSimple: true },
|
|
2937
|
+
];
|
|
3138
2938
|
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
2939
|
+
/**
|
|
2940
|
+
* v1.7.2 settings refactor: the "身份与行为" group body. Moved verbatim out of
|
|
2941
|
+
* MemorySettings; every name it used is destructured from the shared bag, so not a
|
|
2942
|
+
* single character inside the JSX had to change.
|
|
2943
|
+
*/
|
|
2944
|
+
function SettingsIdentityGroup(bag) {
|
|
2945
|
+
const { activeSpace, state, configState, serverConfig, shellState, draft, status, saving, settingsMode, simpleMode, escapeStatus, escapeBusy, statsPayload, sessionPanel, reportedSpace, displayedSpace, edit, disabled, resetHandoffState } = bag;
|
|
2946
|
+
return [
|
|
3145
2947
|
h(
|
|
3146
|
-
|
|
3147
|
-
{
|
|
3148
|
-
h(
|
|
3149
|
-
'
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
: {}),
|
|
3157
|
-
},
|
|
3158
|
-
onClick: () => {
|
|
3159
|
-
writeSettingsMode('simple');
|
|
3160
|
-
setSettingsMode('simple');
|
|
3161
|
-
},
|
|
3162
|
-
},
|
|
3163
|
-
'简洁模式',
|
|
3164
|
-
),
|
|
3165
|
-
h(
|
|
3166
|
-
'button',
|
|
3167
|
-
{
|
|
3168
|
-
type: 'button',
|
|
3169
|
-
style: {
|
|
3170
|
-
...smallButtonStyle,
|
|
3171
|
-
...(!simpleMode
|
|
3172
|
-
? { borderColor: palette.accent, color: palette.accent, fontWeight: 600 }
|
|
3173
|
-
: {}),
|
|
3174
|
-
},
|
|
3175
|
-
onClick: () => {
|
|
3176
|
-
writeSettingsMode('pro');
|
|
3177
|
-
setSettingsMode('pro');
|
|
3178
|
-
},
|
|
3179
|
-
},
|
|
3180
|
-
'专业模式',
|
|
3181
|
-
),
|
|
3182
|
-
h(
|
|
3183
|
-
'span',
|
|
3184
|
-
{ style: { ...labelStyle, marginBottom: 0 } },
|
|
3185
|
-
simpleMode
|
|
3186
|
-
? '只显示身份、上下文窗口、存储位置迁移与原始回合留存三项;其余配置保持文件中的现有值,不会被改写。'
|
|
3187
|
-
: '显示全部配置项。',
|
|
3188
|
-
),
|
|
2948
|
+
Section,
|
|
2949
|
+
{ title: '身份' },
|
|
2950
|
+
h(Select, {
|
|
2951
|
+
label: '事件时间策略(identity.eventTimePolicy)',
|
|
2952
|
+
hint: 'content:由内容推导;explicit:调用方必须提供;ingest:使用写入时刻。',
|
|
2953
|
+
value: draft.eventTimePolicy,
|
|
2954
|
+
options: EVENT_TIME_OPTIONS,
|
|
2955
|
+
onChange: (value) => edit('eventTimePolicy', value),
|
|
2956
|
+
disabled,
|
|
2957
|
+
}),
|
|
3189
2958
|
),
|
|
3190
|
-
shellState !== 'ready'
|
|
3191
|
-
? h(
|
|
3192
|
-
'div',
|
|
3193
|
-
{
|
|
3194
|
-
style: {
|
|
3195
|
-
padding: '8px 12px',
|
|
3196
|
-
borderRadius: 10,
|
|
3197
|
-
border: `1px solid ${palette.warn}`,
|
|
3198
|
-
color: palette.warn,
|
|
3199
|
-
fontSize: 12,
|
|
3200
|
-
},
|
|
3201
|
-
},
|
|
3202
|
-
`当前状态:${shellState}。可以查看配置,但写入要等记忆库就绪(写入会被 MEM_E_NOT_READY 拒绝,不会静默丢失)。`,
|
|
3203
|
-
)
|
|
3204
|
-
: null,
|
|
3205
|
-
status && status.tone === 'error'
|
|
3206
|
-
? h(
|
|
3207
|
-
'div',
|
|
3208
|
-
{
|
|
3209
|
-
style: {
|
|
3210
|
-
padding: '10px 12px',
|
|
3211
|
-
borderRadius: 10,
|
|
3212
|
-
border: `1px solid ${palette.danger}`,
|
|
3213
|
-
background: 'rgba(217,83,79,0.12)',
|
|
3214
|
-
color: palette.danger,
|
|
3215
|
-
fontSize: 13,
|
|
3216
|
-
},
|
|
3217
|
-
},
|
|
3218
|
-
status.text,
|
|
3219
|
-
)
|
|
3220
|
-
: null,
|
|
3221
2959
|
h(
|
|
3222
2960
|
Section,
|
|
3223
2961
|
{ title: '行为', hidden: simpleMode },
|
|
@@ -3242,23 +2980,204 @@
|
|
|
3242
2980
|
onChange: (value) => edit('briefing', value),
|
|
3243
2981
|
disabled,
|
|
3244
2982
|
}),
|
|
3245
|
-
h(Toggle, {
|
|
3246
|
-
label: '提示注入(promptSection)',
|
|
3247
|
-
hint: '注册 memory 提示段,教模型何时写、何时读。',
|
|
3248
|
-
checked: draft.promptSection,
|
|
3249
|
-
onChange: (value) => edit('promptSection', value),
|
|
2983
|
+
h(Toggle, {
|
|
2984
|
+
label: '提示注入(promptSection)',
|
|
2985
|
+
hint: '注册 memory 提示段,教模型何时写、何时读。',
|
|
2986
|
+
checked: draft.promptSection,
|
|
2987
|
+
onChange: (value) => edit('promptSection', value),
|
|
2988
|
+
disabled,
|
|
2989
|
+
}),
|
|
2990
|
+
h(Toggle, {
|
|
2991
|
+
label: '启动后立即维护(autoMaintainOnBoot)',
|
|
2992
|
+
checked: draft.autoMaintainOnBoot,
|
|
2993
|
+
onChange: (value) => edit('autoMaintainOnBoot', value),
|
|
2994
|
+
disabled,
|
|
2995
|
+
}),
|
|
2996
|
+
),
|
|
2997
|
+
// Tool schema pruning (v1.5.3): every enabled tool pays its JSON schema
|
|
2998
|
+
// in prompt tokens on every turn. Disabled entries are validated server
|
|
2999
|
+
// side (unknown/core names abort activation), so the save cannot lie.
|
|
3000
|
+
];
|
|
3001
|
+
}
|
|
3002
|
+
|
|
3003
|
+
/**
|
|
3004
|
+
* v1.7.2 settings refactor: the "上下文与注入" group body. Moved verbatim out of
|
|
3005
|
+
* MemorySettings; every name it used is destructured from the shared bag, so not a
|
|
3006
|
+
* single character inside the JSX had to change.
|
|
3007
|
+
*/
|
|
3008
|
+
function SettingsContextGroup(bag) {
|
|
3009
|
+
const { activeSpace, state, configState, serverConfig, shellState, draft, status, saving, settingsMode, simpleMode, escapeStatus, escapeBusy, statsPayload, sessionPanel, reportedSpace, displayedSpace, edit, disabled, resetHandoffState } = bag;
|
|
3010
|
+
return [
|
|
3011
|
+
h(
|
|
3012
|
+
Section,
|
|
3013
|
+
{ title: '上下文窗口' },
|
|
3014
|
+
h(Field, {
|
|
3015
|
+
label: '预算(token)',
|
|
3016
|
+
hint: '日常 4000;长视频或重构时建议 8000 - 12000。',
|
|
3017
|
+
value: draft.context.maxTokens,
|
|
3018
|
+
min: 256,
|
|
3019
|
+
max: 1000000,
|
|
3020
|
+
step: 256,
|
|
3021
|
+
onChange: (value) => edit('context.maxTokens', value),
|
|
3022
|
+
disabled,
|
|
3023
|
+
}),
|
|
3024
|
+
h(Field, {
|
|
3025
|
+
label: '单次召回注入上限(token)',
|
|
3026
|
+
hint: '一次 recall 返回 JSON 的硬上限(默认 4000,256 – 100000)。超限会截断并带 truncated:true,绝不静默超发。',
|
|
3027
|
+
value: draft.context.maxInjectTokens,
|
|
3028
|
+
min: 256,
|
|
3029
|
+
max: 100000,
|
|
3030
|
+
step: 256,
|
|
3031
|
+
onChange: (value) => edit('context.maxInjectTokens', value),
|
|
3032
|
+
disabled,
|
|
3033
|
+
}),
|
|
3034
|
+
h(Field, {
|
|
3035
|
+
label: '淘汰阈值',
|
|
3036
|
+
hint: '占用超过该比例即开始淘汰,必须大于收敛目标。',
|
|
3037
|
+
value: draft.context.threshold,
|
|
3038
|
+
min: 0.1,
|
|
3039
|
+
max: 0.99,
|
|
3040
|
+
step: 0.01,
|
|
3041
|
+
onChange: (value) => edit('context.threshold', value),
|
|
3042
|
+
disabled,
|
|
3043
|
+
}),
|
|
3044
|
+
h(Field, {
|
|
3045
|
+
label: '收敛目标',
|
|
3046
|
+
value: draft.context.target,
|
|
3047
|
+
min: 0.05,
|
|
3048
|
+
max: 0.98,
|
|
3049
|
+
step: 0.01,
|
|
3050
|
+
onChange: (value) => edit('context.target', value),
|
|
3051
|
+
disabled,
|
|
3052
|
+
}),
|
|
3053
|
+
h(Toggle, {
|
|
3054
|
+
label: '注入上下文预算段(context.injectPrompt)',
|
|
3055
|
+
checked: draft.context.injectPrompt,
|
|
3056
|
+
onChange: (value) => edit('context.injectPrompt', value),
|
|
3057
|
+
disabled,
|
|
3058
|
+
}),
|
|
3059
|
+
// v1.6.7 M1: pointer lines by default. `full` is kept as the escape hatch
|
|
3060
|
+
// for anyone who wants the old body rendering back.
|
|
3061
|
+
h(Select, {
|
|
3062
|
+
label: '记忆块注入形态(context.injectMode)',
|
|
3063
|
+
hint: '索引(推荐):每块只注入 eventId + 标签 + 标题,正文按需用 recall 取;占用已用窗口的 1/10 不到。全文:沿用旧版渲染,正文直接进 Prompt(更费 Token)。',
|
|
3064
|
+
value: draft.context.injectMode === 'full' ? 'full' : 'index',
|
|
3065
|
+
options: [
|
|
3066
|
+
{ value: 'index', label: '索引(eventId + 标签 + 标题)' },
|
|
3067
|
+
{ value: 'full', label: '全文(旧版渲染)' },
|
|
3068
|
+
],
|
|
3069
|
+
onChange: (value) => edit('context.injectMode', value),
|
|
3070
|
+
disabled,
|
|
3071
|
+
}),
|
|
3072
|
+
// v1.7.1: the task/expert switch. It gates TWO behaviours (hint silence and
|
|
3073
|
+
// the state line); the summary-hygiene clean-up above is always on.
|
|
3074
|
+
h(Select, {
|
|
3075
|
+
label: '运行模式(context.mode)',
|
|
3076
|
+
hint: '任务(推荐,构建/调试):提示标签连续 N 次且一次都没换来 recall 就单向静默,并注入一行「当前状态」(仓库 HEAD / 窗口压力)。专家:每个提示都保留,不注入状态行。',
|
|
3077
|
+
value: draft.context.mode === 'expert' ? 'expert' : 'task',
|
|
3078
|
+
options: [
|
|
3079
|
+
{ value: 'task', label: '任务(静默无效提示 + 当前状态行)' },
|
|
3080
|
+
{ value: 'expert', label: '专家(全量提示,不静默)' },
|
|
3081
|
+
],
|
|
3082
|
+
onChange: (value) => edit('context.mode', value),
|
|
3083
|
+
disabled,
|
|
3084
|
+
}),
|
|
3085
|
+
h(Field, {
|
|
3086
|
+
label: '提示静默阈值(context.hintsIdleSilenceAfter)',
|
|
3087
|
+
hint: '仅任务模式生效:同一标签连续展示这么多次且从未带来一次 recall,就永久不再出现。默认 8。',
|
|
3088
|
+
value: draft.context.hintsIdleSilenceAfter,
|
|
3089
|
+
min: 1,
|
|
3090
|
+
max: 100,
|
|
3091
|
+
step: 1,
|
|
3092
|
+
onChange: (value) => edit('context.hintsIdleSilenceAfter', value),
|
|
3093
|
+
disabled: disabled || (draft.context.mode === 'expert'),
|
|
3094
|
+
}),
|
|
3095
|
+
h(Toggle, {
|
|
3096
|
+
label: '注入当前状态行(context.statePointer.enabled)',
|
|
3097
|
+
hint: '任务模式有效:在 Prompt 末尾注入一行「仓库 HEAD · 窗口压力」,总长 ≤ maxChars。',
|
|
3098
|
+
checked: Boolean(draft.context.statePointer && draft.context.statePointer.enabled),
|
|
3099
|
+
onChange: (value) =>
|
|
3100
|
+
edit('context.statePointer', { ...(draft.context.statePointer || {}), enabled: value }),
|
|
3101
|
+
disabled,
|
|
3102
|
+
}),
|
|
3103
|
+
),
|
|
3104
|
+
h(
|
|
3105
|
+
Section,
|
|
3106
|
+
{ title: '检索', hint: '默认 topK 不得超过检索上限。', hidden: simpleMode },
|
|
3107
|
+
h(Field, {
|
|
3108
|
+
label: '默认 topK(retrieval.topK)',
|
|
3109
|
+
value: draft.retrievalTopK,
|
|
3110
|
+
min: 1,
|
|
3111
|
+
max: 1000,
|
|
3112
|
+
step: 1,
|
|
3113
|
+
onChange: (value) => edit('retrievalTopK', value),
|
|
3114
|
+
disabled,
|
|
3115
|
+
}),
|
|
3116
|
+
h(Field, {
|
|
3117
|
+
label: '检索上限(maxRecallTopK)',
|
|
3118
|
+
value: draft.maxRecallTopK,
|
|
3119
|
+
min: 1,
|
|
3120
|
+
max: 1000,
|
|
3121
|
+
step: 1,
|
|
3122
|
+
onChange: (value) => edit('maxRecallTopK', value),
|
|
3123
|
+
disabled,
|
|
3124
|
+
}),
|
|
3125
|
+
),
|
|
3126
|
+
h(
|
|
3127
|
+
Section,
|
|
3128
|
+
{ title: '调度', hidden: simpleMode },
|
|
3129
|
+
h(TextInput, {
|
|
3130
|
+
label: '维护 Cron(5 段)',
|
|
3131
|
+
hint: '例:0 */6 * * *(每 6 小时)。非法表达式会被后端拒绝。',
|
|
3132
|
+
value: draft.maintenanceCron,
|
|
3133
|
+
onChange: (value) => edit('maintenanceCron', value),
|
|
3134
|
+
disabled,
|
|
3135
|
+
}),
|
|
3136
|
+
h(Field, {
|
|
3137
|
+
label: '空闲判定(分钟)',
|
|
3138
|
+
value: draft.dreamIdleMinutes,
|
|
3139
|
+
min: 1,
|
|
3140
|
+
max: 525600,
|
|
3141
|
+
step: 1,
|
|
3142
|
+
onChange: (value) => edit('dreamIdleMinutes', value),
|
|
3250
3143
|
disabled,
|
|
3251
3144
|
}),
|
|
3145
|
+
),
|
|
3146
|
+
];
|
|
3147
|
+
}
|
|
3148
|
+
|
|
3149
|
+
/**
|
|
3150
|
+
* v1.7.2 settings refactor: the "摄入与蒸馏" group body. Moved verbatim out of
|
|
3151
|
+
* MemorySettings; every name it used is destructured from the shared bag, so not a
|
|
3152
|
+
* single character inside the JSX had to change.
|
|
3153
|
+
*/
|
|
3154
|
+
function SettingsIngestGroup(bag) {
|
|
3155
|
+
const { activeSpace, state, configState, serverConfig, shellState, draft, status, saving, settingsMode, simpleMode, escapeStatus, escapeBusy, statsPayload, sessionPanel, reportedSpace, displayedSpace, edit, disabled, resetHandoffState } = bag;
|
|
3156
|
+
return [
|
|
3157
|
+
h(
|
|
3158
|
+
Section,
|
|
3159
|
+
{
|
|
3160
|
+
title: '入库自动打标(Pre-Ingest Tagging)',
|
|
3161
|
+
hint: '模型手传 tags 优先;未传 tags 时由引擎从内容形态提取 1–2 个锚点(错误类型 / errno / 代码块语言 / HTTP 状态 / 文件路径 / 任务语句)。raw 保持纯净,锚点直接进 L1.5 索引;提取不到只记 MEM_E_AUTO_TAG_MISS 警告,不阻断写入。',
|
|
3162
|
+
hidden: simpleMode,
|
|
3163
|
+
},
|
|
3252
3164
|
h(Toggle, {
|
|
3253
|
-
label: '
|
|
3254
|
-
checked: draft.
|
|
3255
|
-
onChange: (value) => edit('
|
|
3165
|
+
label: '启用引擎侧自动打标(tagging.autoTag)',
|
|
3166
|
+
checked: draft.tagging.autoTag,
|
|
3167
|
+
onChange: (value) => edit('tagging.autoTag', value),
|
|
3168
|
+
disabled,
|
|
3169
|
+
}),
|
|
3170
|
+
h(Field, {
|
|
3171
|
+
label: '最多自动标签数(tagging.maxTags)',
|
|
3172
|
+
hint: '1 – 5,默认 2。只影响未手传 tags 的写入。',
|
|
3173
|
+
value: draft.tagging.maxTags,
|
|
3174
|
+
min: 1,
|
|
3175
|
+
max: 5,
|
|
3176
|
+
step: 1,
|
|
3177
|
+
onChange: (value) => edit('tagging.maxTags', value),
|
|
3256
3178
|
disabled,
|
|
3257
3179
|
}),
|
|
3258
3180
|
),
|
|
3259
|
-
// Tool schema pruning (v1.5.3): every enabled tool pays its JSON schema
|
|
3260
|
-
// in prompt tokens on every turn. Disabled entries are validated server
|
|
3261
|
-
// side (unknown/core names abort activation), so the save cannot lie.
|
|
3262
3181
|
h(
|
|
3263
3182
|
Section,
|
|
3264
3183
|
{
|
|
@@ -3289,30 +3208,6 @@
|
|
|
3289
3208
|
});
|
|
3290
3209
|
}),
|
|
3291
3210
|
),
|
|
3292
|
-
h(
|
|
3293
|
-
Section,
|
|
3294
|
-
{
|
|
3295
|
-
title: '入库自动打标(Pre-Ingest Tagging)',
|
|
3296
|
-
hint: '模型手传 tags 优先;未传 tags 时由引擎从内容形态提取 1–2 个锚点(错误类型 / errno / 代码块语言 / HTTP 状态 / 文件路径 / 任务语句)。raw 保持纯净,锚点直接进 L1.5 索引;提取不到只记 MEM_E_AUTO_TAG_MISS 警告,不阻断写入。',
|
|
3297
|
-
hidden: simpleMode,
|
|
3298
|
-
},
|
|
3299
|
-
h(Toggle, {
|
|
3300
|
-
label: '启用引擎侧自动打标(tagging.autoTag)',
|
|
3301
|
-
checked: draft.tagging.autoTag,
|
|
3302
|
-
onChange: (value) => edit('tagging.autoTag', value),
|
|
3303
|
-
disabled,
|
|
3304
|
-
}),
|
|
3305
|
-
h(Field, {
|
|
3306
|
-
label: '最多自动标签数(tagging.maxTags)',
|
|
3307
|
-
hint: '1 – 5,默认 2。只影响未手传 tags 的写入。',
|
|
3308
|
-
value: draft.tagging.maxTags,
|
|
3309
|
-
min: 1,
|
|
3310
|
-
max: 5,
|
|
3311
|
-
step: 1,
|
|
3312
|
-
onChange: (value) => edit('tagging.maxTags', value),
|
|
3313
|
-
disabled,
|
|
3314
|
-
}),
|
|
3315
|
-
),
|
|
3316
3211
|
h(
|
|
3317
3212
|
Section,
|
|
3318
3213
|
{
|
|
@@ -3501,108 +3396,292 @@
|
|
|
3501
3396
|
),
|
|
3502
3397
|
h(
|
|
3503
3398
|
Section,
|
|
3504
|
-
{ title: '
|
|
3505
|
-
h(
|
|
3506
|
-
label: '
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3399
|
+
{ title: 'L2.5 趋势隔离', hidden: simpleMode },
|
|
3400
|
+
h(Field, {
|
|
3401
|
+
label: '隔离期(天)',
|
|
3402
|
+
value: draft.temp.ttlDays,
|
|
3403
|
+
min: 1,
|
|
3404
|
+
max: 3650,
|
|
3405
|
+
step: 1,
|
|
3406
|
+
suffix: '天',
|
|
3407
|
+
onChange: (value) => edit('temp.ttlDays', value),
|
|
3408
|
+
disabled,
|
|
3409
|
+
}),
|
|
3410
|
+
h(Field, {
|
|
3411
|
+
label: '晋升窗口(天)',
|
|
3412
|
+
hint: '必须不大于隔离期。',
|
|
3413
|
+
value: draft.temp.promotionWindowDays,
|
|
3414
|
+
min: 0,
|
|
3415
|
+
max: 3650,
|
|
3416
|
+
step: 1,
|
|
3417
|
+
suffix: '天',
|
|
3418
|
+
onChange: (value) => edit('temp.promotionWindowDays', value),
|
|
3419
|
+
disabled,
|
|
3420
|
+
}),
|
|
3421
|
+
),
|
|
3422
|
+
];
|
|
3423
|
+
}
|
|
3424
|
+
|
|
3425
|
+
/**
|
|
3426
|
+
* v1.7.2 settings refactor: the "留存与归档" group body. Moved verbatim out of
|
|
3427
|
+
* MemorySettings; every name it used is destructured from the shared bag, so not a
|
|
3428
|
+
* single character inside the JSX had to change.
|
|
3429
|
+
*/
|
|
3430
|
+
function SettingsRetentionGroup(bag) {
|
|
3431
|
+
const { activeSpace, state, configState, serverConfig, shellState, draft, status, saving, settingsMode, simpleMode, escapeStatus, escapeBusy, statsPayload, sessionPanel, reportedSpace, displayedSpace, edit, disabled, resetHandoffState } = bag;
|
|
3432
|
+
return [
|
|
3433
|
+
h(
|
|
3434
|
+
Section,
|
|
3435
|
+
{
|
|
3436
|
+
title: '原始回合留存(raw)',
|
|
3437
|
+
hint: '只做取证,不参与索引;高价值/代码/报错/工具输出才会留,且有日/总量/保留期上限。',
|
|
3438
|
+
},
|
|
3439
|
+
h(Select, {
|
|
3440
|
+
label: 'raw.mode',
|
|
3441
|
+
hint: 'salience:只留高价值轮次;all:全留(仍受上限);off:关闭 deep_raw。',
|
|
3442
|
+
value: draft.rawMode,
|
|
3443
|
+
options: [
|
|
3444
|
+
{ value: 'salience', label: 'salience — 只留高价值(默认)' },
|
|
3445
|
+
{ value: 'all', label: 'all — 全量(受预算限制)' },
|
|
3446
|
+
{ value: 'off', label: 'off — 不留 raw' },
|
|
3447
|
+
],
|
|
3448
|
+
onChange: (value) => edit('rawMode', value),
|
|
3449
|
+
disabled,
|
|
3450
|
+
}),
|
|
3451
|
+
simpleMode
|
|
3452
|
+
? null
|
|
3453
|
+
: h(Field, {
|
|
3454
|
+
label: 'raw 最小显著度',
|
|
3455
|
+
value: draft.rawMinSalience,
|
|
3456
|
+
min: 0,
|
|
3457
|
+
max: 1,
|
|
3458
|
+
step: 0.05,
|
|
3459
|
+
onChange: (value) => edit('rawMinSalience', value),
|
|
3460
|
+
disabled,
|
|
3461
|
+
}),
|
|
3462
|
+
h(Field, {
|
|
3463
|
+
label: 'raw 总量上限(MB)',
|
|
3464
|
+
value: draft.rawMaxTotalMb,
|
|
3465
|
+
min: 16,
|
|
3466
|
+
max: 4096,
|
|
3467
|
+
step: 16,
|
|
3468
|
+
suffix: 'MB',
|
|
3469
|
+
onChange: (value) => edit('rawMaxTotalMb', value),
|
|
3470
|
+
disabled,
|
|
3471
|
+
}),
|
|
3472
|
+
simpleMode
|
|
3473
|
+
? null
|
|
3474
|
+
: h(Field, {
|
|
3475
|
+
label: 'raw 保留期(天)',
|
|
3476
|
+
value: draft.rawRetentionDays,
|
|
3477
|
+
min: 1,
|
|
3478
|
+
max: 365,
|
|
3479
|
+
step: 1,
|
|
3480
|
+
suffix: '天',
|
|
3481
|
+
onChange: (value) => edit('rawRetentionDays', value),
|
|
3482
|
+
disabled,
|
|
3483
|
+
}),
|
|
3484
|
+
simpleMode
|
|
3485
|
+
? null
|
|
3486
|
+
: h(Field, {
|
|
3487
|
+
label: '冷压缩阈值(raw.archiveAfterDays,天)',
|
|
3488
|
+
hint: '超过该天数的日分片会被按月合并为 .jsonl.gz(默认 7,必须小于保留期)。只有近 30 天零访问、且不含 pinned / status:handoff / 高频标签的分片才会被压缩;deep_raw 仍可流式读取。',
|
|
3489
|
+
value: draft.rawArchiveAfterDays,
|
|
3490
|
+
min: 1,
|
|
3491
|
+
max: 3650,
|
|
3492
|
+
step: 1,
|
|
3493
|
+
suffix: '天',
|
|
3494
|
+
onChange: (value) => edit('rawArchiveAfterDays', value),
|
|
3495
|
+
disabled,
|
|
3496
|
+
}),
|
|
3497
|
+
h(Select, {
|
|
3498
|
+
label: '冷压缩引擎(raw.compressionEngine)',
|
|
3499
|
+
hint:
|
|
3500
|
+
(statsPayload && statsPayload.capabilities && statsPayload.capabilities.compression
|
|
3501
|
+
? `当前运行时 Node ${statsPayload.capabilities.compression.node}:brotli ${statsPayload.capabilities.compression.brotli ? '可用' : '不可用'},gzip ${statsPayload.capabilities.compression.gzip ? '可用' : '不可用'},zstd ${statsPayload.capabilities.compression.zstd ? '可用' : '不可用'}。`
|
|
3502
|
+
: '') +
|
|
3503
|
+
'全部为 Node 内置编解码器(无需下载或安装外部包)。Brotli 11 级为冷数据默认的极限压缩;Gzip/Zstd 仍可选。历史归档保持原格式,三种格式都可流式读取。',
|
|
3504
|
+
value: draft.rawCompressionEngine,
|
|
3505
|
+
options: [
|
|
3506
|
+
{ value: 'brotli', label: 'Brotli 11 级(Node 内置,默认,压缩率最高)' },
|
|
3507
|
+
{ value: 'gzip', label: 'Gzip(Node 内置,兼容性最好)' },
|
|
3508
|
+
{ value: 'zstd', label: 'Zstd(Node 内置,解压更快)' },
|
|
3509
|
+
],
|
|
3510
|
+
onChange: (value) => edit('rawCompressionEngine', value),
|
|
3511
|
+
disabled,
|
|
3512
|
+
}),
|
|
3513
|
+
simpleMode
|
|
3514
|
+
? null
|
|
3515
|
+
: h(
|
|
3516
|
+
'div',
|
|
3517
|
+
{ style: { display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap', margin: '4px 0 10px' } },
|
|
3518
|
+
h(
|
|
3519
|
+
'button',
|
|
3520
|
+
{
|
|
3521
|
+
type: 'button',
|
|
3522
|
+
style: smallButtonStyle,
|
|
3523
|
+
disabled,
|
|
3524
|
+
onClick: () =>
|
|
3525
|
+
edit(
|
|
3526
|
+
'rawCompressionEngine',
|
|
3527
|
+
draft.rawCompressionEngine === 'brotli' ? 'gzip' : 'brotli',
|
|
3528
|
+
),
|
|
3529
|
+
},
|
|
3530
|
+
draft.rawCompressionEngine === 'brotli' ? '切回 Gzip(兼容模式)' : '启用 Brotli 11 级(极限压缩)',
|
|
3531
|
+
),
|
|
3532
|
+
h(
|
|
3533
|
+
'span',
|
|
3534
|
+
{ style: { ...labelStyle, marginBottom: 0 } },
|
|
3535
|
+
draft.rawCompressionEngine === 'brotli'
|
|
3536
|
+
? 'Brotli 11 级已选中:点击“保存全部”后,新归档使用 .jsonl.br。'
|
|
3537
|
+
: '当前未使用极限压缩:点击“保存全部”后切换,下个月归档生效。',
|
|
3538
|
+
),
|
|
3539
|
+
),
|
|
3540
|
+
simpleMode
|
|
3541
|
+
? null
|
|
3542
|
+
: h(Field, {
|
|
3543
|
+
label: 'deep_raw 扫描回合上限(raw.maxScanTurns)',
|
|
3544
|
+
hint: 'deep_raw 从最新记录倒序最多扫描的回合数(默认 5000,下次 deep_raw 即生效)。调大可回溯更久但更慢;超出上限会 truncated=true 并在 notes 说明。',
|
|
3545
|
+
value: draft.rawMaxScanTurns,
|
|
3546
|
+
min: 500,
|
|
3547
|
+
max: 50000,
|
|
3548
|
+
step: 500,
|
|
3549
|
+
onChange: (value) => edit('rawMaxScanTurns', value),
|
|
3550
|
+
disabled,
|
|
3551
|
+
}),
|
|
3552
|
+
),
|
|
3553
|
+
h(
|
|
3554
|
+
Section,
|
|
3555
|
+
{
|
|
3556
|
+
title: '标签树(L1.5 幽灵宽限)',
|
|
3557
|
+
hint: '层级标签的生死节奏:root 永生、leaf 引用归零即死、mid 在宽限期内变"幽灵"(recall 只给元数据、引导 deep_raw),过期未复活才消亡。四个值都在下一次维护生效。',
|
|
3558
|
+
hidden: simpleMode,
|
|
3559
|
+
},
|
|
3560
|
+
h(Slider, {
|
|
3561
|
+
label: 'mid 半衰期倍率(tagTree.midHalfLifeMultiplier)',
|
|
3562
|
+
hint: 'mid 半衰期 = 倍率 × leaf 半衰期(1 天)。默认 3:mid 比叶子多活 3 倍。调大→幽灵留存更久,历史更完整;调小→层级更快被清理。',
|
|
3563
|
+
value: draft.tagTree.midHalfLifeMultiplier,
|
|
3564
|
+
min: 1,
|
|
3565
|
+
max: 10,
|
|
3566
|
+
step: 0.5,
|
|
3567
|
+
onChange: (value) => edit('tagTree.midHalfLifeMultiplier', value),
|
|
3568
|
+
disabled,
|
|
3569
|
+
}),
|
|
3570
|
+
h(Slider, {
|
|
3571
|
+
label: 'mid 宽限期(tagTree.midGracePeriodDays)',
|
|
3572
|
+
hint: 'mid 失去最后一个叶子后的宽限天数(默认 30)。期内新叶子可立即复活它;期内召回只返回"存在模糊记忆"的元数据,绝不注入正文。',
|
|
3573
|
+
value: draft.tagTree.midGracePeriodDays,
|
|
3574
|
+
min: 7,
|
|
3575
|
+
max: 180,
|
|
3576
|
+
step: 1,
|
|
3577
|
+
suffix: '天',
|
|
3578
|
+
onChange: (value) => edit('tagTree.midGracePeriodDays', value),
|
|
3579
|
+
disabled,
|
|
3580
|
+
}),
|
|
3581
|
+
h(Slider, {
|
|
3582
|
+
label: '剪枝批大小(tagTree.pruneBatchSize)',
|
|
3583
|
+
hint: '每次维护最多消费的待修剪叶子数(默认 100)。调小→死叶分批消失、队列落盘跨重启排空,避免一次维护风暴。',
|
|
3584
|
+
value: draft.tagTree.pruneBatchSize,
|
|
3585
|
+
min: 10,
|
|
3586
|
+
max: 500,
|
|
3587
|
+
step: 10,
|
|
3588
|
+
onChange: (value) => edit('tagTree.pruneBatchSize', value),
|
|
3510
3589
|
disabled,
|
|
3511
3590
|
}),
|
|
3512
|
-
h(
|
|
3513
|
-
label: '
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3591
|
+
h(Slider, {
|
|
3592
|
+
label: 'leaf 衰减地板(tagTree.leafDecayFloor)',
|
|
3593
|
+
hint: '0 = 只按引用归零死亡(严格 forget 驱动);>0 时衰减低于该分数、又被排队的叶子会被修剪。0.05 ≈ 5 个叶子寿命后进入历史视图。',
|
|
3594
|
+
value: draft.tagTree.leafDecayFloor,
|
|
3595
|
+
min: 0,
|
|
3596
|
+
max: 1,
|
|
3597
|
+
step: 0.01,
|
|
3598
|
+
onChange: (value) => edit('tagTree.leafDecayFloor', value),
|
|
3519
3599
|
disabled,
|
|
3520
3600
|
}),
|
|
3521
3601
|
),
|
|
3522
3602
|
h(
|
|
3523
3603
|
Section,
|
|
3524
|
-
{ title: '
|
|
3604
|
+
{ title: '老化与活跃集合', hint: '这两个值同时是策略参数:写入 config 即进入 policy,下一次维护生效。', hidden: simpleMode },
|
|
3525
3605
|
h(Field, {
|
|
3526
|
-
label: '
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3606
|
+
label: '记忆半衰期(decay.halfLifeDays)',
|
|
3607
|
+
hint: '默认 30 天。调大能记住更久。',
|
|
3608
|
+
value: draft.decayHalfLifeDays,
|
|
3609
|
+
min: 7,
|
|
3610
|
+
max: 365,
|
|
3530
3611
|
step: 1,
|
|
3531
|
-
|
|
3612
|
+
suffix: '天',
|
|
3613
|
+
onChange: (value) => edit('decayHalfLifeDays', value),
|
|
3532
3614
|
disabled,
|
|
3533
3615
|
}),
|
|
3534
3616
|
h(Field, {
|
|
3535
|
-
label: '
|
|
3536
|
-
|
|
3537
|
-
|
|
3617
|
+
label: '活跃标签上限(activeSet.cap)',
|
|
3618
|
+
hint: '默认 200。多项目并行可调至 500(下次维护生效)。',
|
|
3619
|
+
value: draft.activeSetCap,
|
|
3620
|
+
min: 100,
|
|
3538
3621
|
max: 1000,
|
|
3539
|
-
step:
|
|
3540
|
-
onChange: (value) => edit('
|
|
3622
|
+
step: 50,
|
|
3623
|
+
onChange: (value) => edit('activeSetCap', value),
|
|
3541
3624
|
disabled,
|
|
3542
3625
|
}),
|
|
3543
3626
|
),
|
|
3544
3627
|
h(
|
|
3545
3628
|
Section,
|
|
3546
|
-
{ title: '
|
|
3547
|
-
h(Field, {
|
|
3548
|
-
label: '预算(token)',
|
|
3549
|
-
hint: '日常 4000;长视频或重构时建议 8000 - 12000。',
|
|
3550
|
-
value: draft.context.maxTokens,
|
|
3551
|
-
min: 256,
|
|
3552
|
-
max: 1000000,
|
|
3553
|
-
step: 256,
|
|
3554
|
-
onChange: (value) => edit('context.maxTokens', value),
|
|
3555
|
-
disabled,
|
|
3556
|
-
}),
|
|
3629
|
+
{ title: '存储与图谱', hint: '存储预算只影响左上角环形图的阈值,不会删除任何数据。', hidden: simpleMode },
|
|
3557
3630
|
h(Field, {
|
|
3558
|
-
label: '
|
|
3559
|
-
hint: '
|
|
3560
|
-
value: draft.
|
|
3561
|
-
min:
|
|
3562
|
-
max:
|
|
3563
|
-
step:
|
|
3564
|
-
|
|
3631
|
+
label: '存储预算上限(MB)',
|
|
3632
|
+
hint: '普通用户 50MB;重度用户可调至 200MB+。软上限:超限只在环形图标红,不删档。',
|
|
3633
|
+
value: draft.storageBudgetMb,
|
|
3634
|
+
min: 10,
|
|
3635
|
+
max: 1000,
|
|
3636
|
+
step: 10,
|
|
3637
|
+
suffix: 'MB',
|
|
3638
|
+
onChange: (value) => edit('storageBudgetMb', value),
|
|
3565
3639
|
disabled,
|
|
3566
3640
|
}),
|
|
3567
3641
|
h(Field, {
|
|
3568
|
-
label: '
|
|
3569
|
-
hint: '
|
|
3570
|
-
value: draft.
|
|
3571
|
-
min:
|
|
3572
|
-
max:
|
|
3573
|
-
step:
|
|
3574
|
-
onChange: (value) => edit('
|
|
3642
|
+
label: '图谱最大边数(graphMaxEdges)',
|
|
3643
|
+
hint: '保存后立即按新上限重新拉取 /api/hippocampus/graph 并重绘。',
|
|
3644
|
+
value: draft.graphMaxEdges,
|
|
3645
|
+
min: 100,
|
|
3646
|
+
max: 2000,
|
|
3647
|
+
step: 100,
|
|
3648
|
+
onChange: (value) => edit('graphMaxEdges', value),
|
|
3575
3649
|
disabled,
|
|
3576
3650
|
}),
|
|
3651
|
+
),
|
|
3652
|
+
h(
|
|
3653
|
+
Section,
|
|
3654
|
+
{ title: '删除与复习', hint: '两阶段删除先挂起,宽限期内 restore 可取消;复习排期由引擎推进。', hidden: simpleMode },
|
|
3577
3655
|
h(Field, {
|
|
3578
|
-
label: '
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3656
|
+
label: '删除宽限期(小时)',
|
|
3657
|
+
hint: '0 = 立即执行(旧行为);默认 24 小时。',
|
|
3658
|
+
value: draft.deleteGraceHours,
|
|
3659
|
+
min: 0,
|
|
3660
|
+
max: 168,
|
|
3661
|
+
step: 1,
|
|
3662
|
+
suffix: '小时',
|
|
3663
|
+
onChange: (value) => edit('deleteGraceHours', value),
|
|
3584
3664
|
disabled,
|
|
3585
3665
|
}),
|
|
3586
3666
|
h(Toggle, {
|
|
3587
|
-
label: '
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
}),
|
|
3592
|
-
// v1.6.7 M1: pointer lines by default. `full` is kept as the escape hatch
|
|
3593
|
-
// for anyone who wants the old body rendering back.
|
|
3594
|
-
h(Select, {
|
|
3595
|
-
label: '记忆块注入形态(context.injectMode)',
|
|
3596
|
-
hint: '索引(推荐):每块只注入 eventId + 标签 + 标题,正文按需用 recall 取;占用已用窗口的 1/10 不到。全文:沿用旧版渲染,正文直接进 Prompt(更费 Token)。',
|
|
3597
|
-
value: draft.context.injectMode === 'full' ? 'full' : 'index',
|
|
3598
|
-
options: [
|
|
3599
|
-
{ value: 'index', label: '索引(eventId + 标签 + 标题)' },
|
|
3600
|
-
{ value: 'full', label: '全文(旧版渲染)' },
|
|
3601
|
-
],
|
|
3602
|
-
onChange: (value) => edit('context.injectMode', value),
|
|
3667
|
+
label: '启用间隔重复复习(1,2,4,7,15,30 天)',
|
|
3668
|
+
hint: 'reinforce 会让事件进入下一档;到期项由 maintain 汇总到 memory_admin action=reviews。',
|
|
3669
|
+
checked: draft.reviewEnabled,
|
|
3670
|
+
onChange: (value) => edit('reviewEnabled', value),
|
|
3603
3671
|
disabled,
|
|
3604
3672
|
}),
|
|
3605
3673
|
),
|
|
3674
|
+
];
|
|
3675
|
+
}
|
|
3676
|
+
|
|
3677
|
+
/**
|
|
3678
|
+
* v1.7.2 settings refactor: the "空间与存储" group body. Moved verbatim out of
|
|
3679
|
+
* MemorySettings; every name it used is destructured from the shared bag, so not a
|
|
3680
|
+
* single character inside the JSX had to change.
|
|
3681
|
+
*/
|
|
3682
|
+
function SettingsSpaceGroup(bag) {
|
|
3683
|
+
const { activeSpace, state, configState, serverConfig, shellState, draft, status, saving, settingsMode, simpleMode, escapeStatus, escapeBusy, statsPayload, sessionPanel, reportedSpace, displayedSpace, edit, disabled, resetHandoffState } = bag;
|
|
3684
|
+
return [
|
|
3606
3685
|
h(
|
|
3607
3686
|
Section,
|
|
3608
3687
|
{
|
|
@@ -3728,285 +3807,534 @@
|
|
|
3728
3807
|
// UI_TASK_1: physical dataDir migration is a SYSTEM-LEVEL tool, fully
|
|
3729
3808
|
// decoupled from business-data transfer (no event ids, no spaces here).
|
|
3730
3809
|
h(StorageMigratorUI, { config: serverConfig, disabled }),
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3810
|
+
];
|
|
3811
|
+
}
|
|
3812
|
+
|
|
3813
|
+
|
|
3814
|
+
/**
|
|
3815
|
+
* v1.7.2: the rail. Sticky, narrow, and always the same five (four in 简洁模式) items:
|
|
3816
|
+
* a settings page people visit twice a year is not the place for a menu that shrinks
|
|
3817
|
+
* and grows with capability flags.
|
|
3818
|
+
*/
|
|
3819
|
+
function SettingsNav({ items, activeId, onPick, height }) {
|
|
3820
|
+
return h(
|
|
3821
|
+
'div',
|
|
3822
|
+
{
|
|
3823
|
+
style: {
|
|
3824
|
+
// v1.7.2 (fixed): the rail owns its own scrollbar and stretches to the shell
|
|
3825
|
+
// height, so it stays put while the cards scroll in the sibling pane.
|
|
3826
|
+
// `position: sticky` cannot work here: the Host shell's overflow wrapper is not
|
|
3827
|
+
// the scroller, and a sticky child of a non-scrolling overflow ancestor simply
|
|
3828
|
+
// scrolls away with the content.
|
|
3829
|
+
flex: '0 0 148px',
|
|
3830
|
+
width: 148,
|
|
3831
|
+
alignSelf: 'stretch',
|
|
3832
|
+
maxHeight: height || undefined,
|
|
3833
|
+
overflowY: 'auto',
|
|
3834
|
+
overflowX: 'hidden',
|
|
3835
|
+
paddingRight: 4,
|
|
3836
|
+
display: 'flex',
|
|
3837
|
+
flexDirection: 'column',
|
|
3838
|
+
gap: 2,
|
|
3736
3839
|
},
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
suffix: 'MB',
|
|
3767
|
-
onChange: (value) => edit('rawMaxTotalMb', value),
|
|
3768
|
-
disabled,
|
|
3769
|
-
}),
|
|
3770
|
-
simpleMode
|
|
3771
|
-
? null
|
|
3772
|
-
: h(Field, {
|
|
3773
|
-
label: 'raw 保留期(天)',
|
|
3774
|
-
value: draft.rawRetentionDays,
|
|
3775
|
-
min: 1,
|
|
3776
|
-
max: 365,
|
|
3777
|
-
step: 1,
|
|
3778
|
-
suffix: '天',
|
|
3779
|
-
onChange: (value) => edit('rawRetentionDays', value),
|
|
3780
|
-
disabled,
|
|
3781
|
-
}),
|
|
3782
|
-
simpleMode
|
|
3783
|
-
? null
|
|
3784
|
-
: h(Field, {
|
|
3785
|
-
label: '冷压缩阈值(raw.archiveAfterDays,天)',
|
|
3786
|
-
hint: '超过该天数的日分片会被按月合并为 .jsonl.gz(默认 7,必须小于保留期)。只有近 30 天零访问、且不含 pinned / status:handoff / 高频标签的分片才会被压缩;deep_raw 仍可流式读取。',
|
|
3787
|
-
value: draft.rawArchiveAfterDays,
|
|
3788
|
-
min: 1,
|
|
3789
|
-
max: 3650,
|
|
3790
|
-
step: 1,
|
|
3791
|
-
suffix: '天',
|
|
3792
|
-
onChange: (value) => edit('rawArchiveAfterDays', value),
|
|
3793
|
-
disabled,
|
|
3794
|
-
}),
|
|
3795
|
-
h(Select, {
|
|
3796
|
-
label: '冷压缩引擎(raw.compressionEngine)',
|
|
3797
|
-
hint:
|
|
3798
|
-
(statsPayload && statsPayload.capabilities && statsPayload.capabilities.compression
|
|
3799
|
-
? `当前运行时 Node ${statsPayload.capabilities.compression.node}:brotli ${statsPayload.capabilities.compression.brotli ? '可用' : '不可用'},gzip ${statsPayload.capabilities.compression.gzip ? '可用' : '不可用'},zstd ${statsPayload.capabilities.compression.zstd ? '可用' : '不可用'}。`
|
|
3800
|
-
: '') +
|
|
3801
|
-
'全部为 Node 内置编解码器(无需下载或安装外部包)。Brotli 11 级为冷数据默认的极限压缩;Gzip/Zstd 仍可选。历史归档保持原格式,三种格式都可流式读取。',
|
|
3802
|
-
value: draft.rawCompressionEngine,
|
|
3803
|
-
options: [
|
|
3804
|
-
{ value: 'brotli', label: 'Brotli 11 级(Node 内置,默认,压缩率最高)' },
|
|
3805
|
-
{ value: 'gzip', label: 'Gzip(Node 内置,兼容性最好)' },
|
|
3806
|
-
{ value: 'zstd', label: 'Zstd(Node 内置,解压更快)' },
|
|
3807
|
-
],
|
|
3808
|
-
onChange: (value) => edit('rawCompressionEngine', value),
|
|
3809
|
-
disabled,
|
|
3810
|
-
}),
|
|
3811
|
-
simpleMode
|
|
3812
|
-
? null
|
|
3813
|
-
: h(
|
|
3814
|
-
'div',
|
|
3815
|
-
{ style: { display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap', margin: '4px 0 10px' } },
|
|
3816
|
-
h(
|
|
3817
|
-
'button',
|
|
3818
|
-
{
|
|
3819
|
-
type: 'button',
|
|
3820
|
-
style: smallButtonStyle,
|
|
3821
|
-
disabled,
|
|
3822
|
-
onClick: () =>
|
|
3823
|
-
edit(
|
|
3824
|
-
'rawCompressionEngine',
|
|
3825
|
-
draft.rawCompressionEngine === 'brotli' ? 'gzip' : 'brotli',
|
|
3826
|
-
),
|
|
3827
|
-
},
|
|
3828
|
-
draft.rawCompressionEngine === 'brotli' ? '切回 Gzip(兼容模式)' : '启用 Brotli 11 级(极限压缩)',
|
|
3829
|
-
),
|
|
3830
|
-
h(
|
|
3831
|
-
'span',
|
|
3832
|
-
{ style: { ...labelStyle, marginBottom: 0 } },
|
|
3833
|
-
draft.rawCompressionEngine === 'brotli'
|
|
3834
|
-
? 'Brotli 11 级已选中:点击“保存全部”后,新归档使用 .jsonl.br。'
|
|
3835
|
-
: '当前未使用极限压缩:点击“保存全部”后切换,下个月归档生效。',
|
|
3836
|
-
),
|
|
3837
|
-
),
|
|
3838
|
-
simpleMode
|
|
3839
|
-
? null
|
|
3840
|
-
: h(Field, {
|
|
3841
|
-
label: 'deep_raw 扫描回合上限(raw.maxScanTurns)',
|
|
3842
|
-
hint: 'deep_raw 从最新记录倒序最多扫描的回合数(默认 5000,下次 deep_raw 即生效)。调大可回溯更久但更慢;超出上限会 truncated=true 并在 notes 说明。',
|
|
3843
|
-
value: draft.rawMaxScanTurns,
|
|
3844
|
-
min: 500,
|
|
3845
|
-
max: 50000,
|
|
3846
|
-
step: 500,
|
|
3847
|
-
onChange: (value) => edit('rawMaxScanTurns', value),
|
|
3848
|
-
disabled,
|
|
3849
|
-
}),
|
|
3840
|
+
},
|
|
3841
|
+
h(
|
|
3842
|
+
'div',
|
|
3843
|
+
{ style: { fontSize: 11, fontWeight: 600, color: palette.muted, letterSpacing: 0.4, padding: '2px 8px 6px' } },
|
|
3844
|
+
'设置分组',
|
|
3845
|
+
),
|
|
3846
|
+
...items.map((item) =>
|
|
3847
|
+
h(
|
|
3848
|
+
'button',
|
|
3849
|
+
{
|
|
3850
|
+
key: item.id,
|
|
3851
|
+
type: 'button',
|
|
3852
|
+
onClick: () => onPick(item.id),
|
|
3853
|
+
title: item.hint,
|
|
3854
|
+
style: {
|
|
3855
|
+
textAlign: 'left',
|
|
3856
|
+
padding: '7px 9px',
|
|
3857
|
+
borderRadius: 7,
|
|
3858
|
+
border: `1px solid ${item.id === activeId ? palette.accent : 'transparent'}`,
|
|
3859
|
+
background: item.id === activeId ? 'rgba(79,140,255,0.12)' : 'transparent',
|
|
3860
|
+
color: item.id === activeId ? palette.accent : palette.text,
|
|
3861
|
+
fontSize: 12,
|
|
3862
|
+
fontWeight: item.id === activeId ? 600 : 400,
|
|
3863
|
+
cursor: 'pointer',
|
|
3864
|
+
lineHeight: 1.3,
|
|
3865
|
+
},
|
|
3866
|
+
},
|
|
3867
|
+
item.label,
|
|
3868
|
+
),
|
|
3850
3869
|
),
|
|
3870
|
+
);
|
|
3871
|
+
}
|
|
3872
|
+
|
|
3873
|
+
/**
|
|
3874
|
+
* v1.7.2: one rail target. The header carries the group's promise ("what lives here"),
|
|
3875
|
+
* because 17 cards in one column gave no way to tell 检索 from 调度 at a glance.
|
|
3876
|
+
*/
|
|
3877
|
+
function SettingsGroup({ groupId, label, hint, groupRefs, children }) {
|
|
3878
|
+
return h(
|
|
3879
|
+
'div',
|
|
3880
|
+
{
|
|
3881
|
+
ref: (node) => {
|
|
3882
|
+
if (node && node.dataset) node.dataset.groupId = groupId;
|
|
3883
|
+
if (groupRefs && groupRefs.current) groupRefs.current[groupId] = node;
|
|
3884
|
+
},
|
|
3885
|
+
'data-group-id': groupId,
|
|
3886
|
+
style: { display: 'flex', flexDirection: 'column', gap: 10, scrollMarginTop: 12 },
|
|
3887
|
+
},
|
|
3851
3888
|
h(
|
|
3852
|
-
|
|
3853
|
-
{
|
|
3854
|
-
h(
|
|
3855
|
-
|
|
3856
|
-
hint: '0 = 立即执行(旧行为);默认 24 小时。',
|
|
3857
|
-
value: draft.deleteGraceHours,
|
|
3858
|
-
min: 0,
|
|
3859
|
-
max: 168,
|
|
3860
|
-
step: 1,
|
|
3861
|
-
suffix: '小时',
|
|
3862
|
-
onChange: (value) => edit('deleteGraceHours', value),
|
|
3863
|
-
disabled,
|
|
3864
|
-
}),
|
|
3865
|
-
h(Toggle, {
|
|
3866
|
-
label: '启用间隔重复复习(1,2,4,7,15,30 天)',
|
|
3867
|
-
hint: 'reinforce 会让事件进入下一档;到期项由 maintain 汇总到 memory_admin action=reviews。',
|
|
3868
|
-
checked: draft.reviewEnabled,
|
|
3869
|
-
onChange: (value) => edit('reviewEnabled', value),
|
|
3870
|
-
disabled,
|
|
3871
|
-
}),
|
|
3889
|
+
'div',
|
|
3890
|
+
{ style: { display: 'flex', alignItems: 'baseline', gap: 8, paddingTop: 2, borderTop: `1px solid ${palette.border}` } },
|
|
3891
|
+
h('div', { style: { fontSize: 13, fontWeight: 700 } }, label),
|
|
3892
|
+
hint ? h('div', { style: { fontSize: 11, color: palette.muted, flex: '1 1 auto', minWidth: 0 } }, hint) : null,
|
|
3872
3893
|
),
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3894
|
+
...(Array.isArray(children) ? children : [children]),
|
|
3895
|
+
);
|
|
3896
|
+
}
|
|
3897
|
+
|
|
3898
|
+
function MemorySettings() {
|
|
3899
|
+
const activeSpace = useActiveSpace();
|
|
3900
|
+
const state = useMemoryStats(activeSpace);
|
|
3901
|
+
const configState = useConfig();
|
|
3902
|
+
const serverConfig = configState.config;
|
|
3903
|
+
const shellState = state.state;
|
|
3904
|
+
const [draft, setDraft] = React.useState(null);
|
|
3905
|
+
const [status, setStatus] = React.useState(null);
|
|
3906
|
+
const [saving, setSaving] = React.useState(false);
|
|
3907
|
+
// v1.6.3: 简洁模式 / 专业模式(纯客户端偏好,存 localStorage)。
|
|
3908
|
+
const [settingsMode, setSettingsMode] = React.useState(readSettingsMode);
|
|
3909
|
+
const simpleMode = settingsMode === 'simple';
|
|
3910
|
+
// v1.5.4 escape hatch: reset a wedged rollover/handoff state from the UI.
|
|
3911
|
+
const [escapeStatus, setEscapeStatus] = React.useState(null);
|
|
3912
|
+
const [escapeBusy, setEscapeBusy] = React.useState(false);
|
|
3913
|
+
|
|
3914
|
+
// v1.7.2 settings refactor: which rail item is highlighted. The refs are how the
|
|
3915
|
+
// rail scrolls to a group without ids leaking into the DOM (and without a
|
|
3916
|
+
// document.querySelector that would break the moment two settings pages mount).
|
|
3917
|
+
const [activeGroup, setActiveGroup] = React.useState(SETTINGS_GROUPS[0].id);
|
|
3918
|
+
const groupRefs = React.useRef({});
|
|
3919
|
+
// v1.7.2 (fixed): the Host shell gives this page no scroll container of its own, so the
|
|
3920
|
+
// two panes are sized from the viewport: measure the shell's top edge once and hand the
|
|
3921
|
+
// rest of the visible height to the layout, which lets the cards pane scroll inside it
|
|
3922
|
+
// while the rail stays pinned.
|
|
3923
|
+
const settingsShellRef = React.useRef(null);
|
|
3924
|
+
const settingsContentRef = React.useRef(null);
|
|
3925
|
+
const [shellHeight, setShellHeight] = React.useState(null);
|
|
3926
|
+
React.useEffect(() => {
|
|
3927
|
+
const measure = () => {
|
|
3928
|
+
const node = settingsShellRef.current;
|
|
3929
|
+
if (!node || typeof node.getBoundingClientRect !== 'function') return;
|
|
3930
|
+
const top = node.getBoundingClientRect().top || 0;
|
|
3931
|
+
const viewport = typeof window !== 'undefined' && window.innerHeight ? window.innerHeight : 900;
|
|
3932
|
+
setShellHeight(Math.max(320, Math.round(viewport - top - 24)));
|
|
3933
|
+
};
|
|
3934
|
+
measure();
|
|
3935
|
+
if (typeof window !== 'undefined' && window.addEventListener) window.addEventListener('resize', measure);
|
|
3936
|
+
return () => {
|
|
3937
|
+
if (typeof window !== 'undefined' && window.removeEventListener) window.removeEventListener('resize', measure);
|
|
3938
|
+
};
|
|
3939
|
+
}, []);
|
|
3940
|
+
React.useEffect(() => {
|
|
3941
|
+
if (!draft || typeof IntersectionObserver !== 'function') return undefined;
|
|
3942
|
+
const observer = new IntersectionObserver(
|
|
3943
|
+
(entries) => {
|
|
3944
|
+
const visible = entries.filter((entry) => entry.isIntersecting).sort((a, b) => b.intersectionRatio - a.intersectionRatio);
|
|
3945
|
+
const id = visible[0] && visible[0].target && visible[0].target.dataset ? visible[0].target.dataset.groupId : null;
|
|
3946
|
+
if (id) setActiveGroup((current) => (current === id ? current : id));
|
|
3947
|
+
},
|
|
3948
|
+
{
|
|
3949
|
+
// v1.7.2 (fixed): observe INSIDE the cards pane. A viewport-rooted observer never
|
|
3950
|
+
// fires once the pane owns its own scrollbar.
|
|
3951
|
+
root: settingsContentRef.current || null,
|
|
3952
|
+
rootMargin: '-8% 0px -70% 0px',
|
|
3953
|
+
threshold: [0.1, 0.35, 0.6],
|
|
3954
|
+
},
|
|
3955
|
+
);
|
|
3956
|
+
for (const node of Object.values(groupRefs.current)) {
|
|
3957
|
+
if (node) observer.observe(node);
|
|
3958
|
+
}
|
|
3959
|
+
return () => observer.disconnect();
|
|
3960
|
+
}, [draft, shellHeight]);
|
|
3961
|
+
|
|
3962
|
+
|
|
3963
|
+
React.useEffect(() => {
|
|
3964
|
+
if (serverConfig && draft === null) setDraft(draftFromConfig(serverConfig));
|
|
3965
|
+
}, [serverConfig, draft]);
|
|
3966
|
+
|
|
3967
|
+
if (shellState === 'failed') {
|
|
3968
|
+
return h(
|
|
3969
|
+
'div',
|
|
3970
|
+
{ style: { padding: 16, display: 'flex', flexDirection: 'column', gap: 12 } },
|
|
3971
|
+
h(FailureBanner, { error: state.error || configState.error, attempts: state.attempts, gaveUp: state.gaveUp }),
|
|
3972
|
+
);
|
|
3973
|
+
}
|
|
3974
|
+
if (!serverConfig) return h('div', { style: { padding: 16 } }, h(PhaseCard, { payload: state.payload, error: configState.error, shellState }));
|
|
3975
|
+
if (!draft) return h('div', { style: { padding: 16, color: palette.muted } }, '读取配置…');
|
|
3976
|
+
|
|
3977
|
+
// The settings page follows the SAME global selector as the panel: its
|
|
3978
|
+
// status bar and space line describe the selected space, not a hard-coded
|
|
3979
|
+
// default. Switching in the panel updates this slot through the bus.
|
|
3980
|
+
const statsPayload = state.payload;
|
|
3981
|
+
const sessionPanel = statsPayload && statsPayload.panel ? statsPayload.panel.session : null;
|
|
3982
|
+
const reportedSpace = statsPayload && statsPayload.panel && statsPayload.panel.spaces ? statsPayload.panel.spaces.current : null;
|
|
3983
|
+
const displayedSpace = activeSpace || reportedSpace || 'default';
|
|
3984
|
+
|
|
3985
|
+
const edit = (path, value) => {
|
|
3986
|
+
setStatus(null);
|
|
3987
|
+
setDraft((prev) => {
|
|
3988
|
+
const next = {
|
|
3989
|
+
...prev,
|
|
3990
|
+
context: { ...(prev.context || {}) },
|
|
3991
|
+
// index joins the shallow-clone list so an 'index.maxPostingsPerTag'
|
|
3992
|
+
// edit never mutates the previous draft object (the class of bug that
|
|
3993
|
+
// makes a cancelled edit silently stick around).
|
|
3994
|
+
index: { ...(prev.index || {}) },
|
|
3995
|
+
temp: { ...(prev.temp || {}) },
|
|
3996
|
+
tagTree: { ...(prev.tagTree || {}) },
|
|
3997
|
+
// tools.disabled is an ARRAY: clone it so a cancelled edit cannot
|
|
3998
|
+
// mutate the previous draft's array in place.
|
|
3999
|
+
tools: {
|
|
4000
|
+
...(prev.tools || {}),
|
|
4001
|
+
disabled: Array.isArray(prev.tools && prev.tools.disabled) ? [...prev.tools.disabled] : [],
|
|
4002
|
+
},
|
|
4003
|
+
tagging: { ...(prev.tagging || {}) },
|
|
4004
|
+
features: { ...(prev.features || {}) },
|
|
4005
|
+
dream: { ...(prev.dream || {}) },
|
|
4006
|
+
l2Merge: { ...(prev.l2Merge || {}) },
|
|
4007
|
+
};
|
|
4008
|
+
if (path.indexOf('.') >= 0) {
|
|
4009
|
+
const [group, leaf] = path.split('.');
|
|
4010
|
+
next[group] = { ...(next[group] || {}), [leaf]: value };
|
|
4011
|
+
} else {
|
|
4012
|
+
next[path] = value;
|
|
4013
|
+
}
|
|
4014
|
+
return next;
|
|
4015
|
+
});
|
|
4016
|
+
};
|
|
4017
|
+
|
|
4018
|
+
/** Client pre-check mirrors the server ranges; the server stays the authority. */
|
|
4019
|
+
const validateDraft = () => {
|
|
4020
|
+
// v1.6.3 简洁模式:只校验可见项,隐藏项不提交也不阻止保存。
|
|
4021
|
+
const rules = simpleMode ? NUMBER_RULES.filter((rule) => SIMPLE_NUMBER_KEYS.includes(rule.key)) : NUMBER_RULES;
|
|
4022
|
+
for (const rule of rules) {
|
|
4023
|
+
const value = readPath(draft, rule.key);
|
|
4024
|
+
const number = Number(value);
|
|
4025
|
+
if (!Number.isFinite(number)) return `${rule.label} 必须是数字`;
|
|
4026
|
+
if (number < rule.min || number > rule.max) return `${rule.label} 必须在 ${rule.min} – ${rule.max} 之间(当前 ${number})`;
|
|
4027
|
+
}
|
|
4028
|
+
if (!simpleMode && !String(draft.maintenanceCron || '').trim()) return 'Cron 表达式不能为空';
|
|
4029
|
+
return null;
|
|
4030
|
+
};
|
|
4031
|
+
|
|
4032
|
+
const save = async () => {
|
|
4033
|
+
setStatus(null);
|
|
4034
|
+
const problem = validateDraft();
|
|
4035
|
+
if (problem) {
|
|
4036
|
+
setStatus({ tone: 'error', text: problem });
|
|
4037
|
+
return;
|
|
4038
|
+
}
|
|
4039
|
+
setSaving(true);
|
|
4040
|
+
// NOTE: dataDir is NOT part of this save. Physical storage migration
|
|
4041
|
+
// (A/B copy, state=migrating, old dir kept as backup) lives in the
|
|
4042
|
+
// separate system-level StorageMigratorUI and is submitted on its own.
|
|
4043
|
+
const patch = {
|
|
4044
|
+
maintenanceCron: String(draft.maintenanceCron).trim(),
|
|
4045
|
+
briefing: Boolean(draft.briefing),
|
|
4046
|
+
promptSection: Boolean(draft.promptSection),
|
|
4047
|
+
autoMaintainOnBoot: Boolean(draft.autoMaintainOnBoot),
|
|
4048
|
+
enableDream: Boolean(draft.enableDream),
|
|
4049
|
+
enableReflection: Boolean(draft.enableReflection),
|
|
4050
|
+
dreamIdleMinutes: Number(draft.dreamIdleMinutes),
|
|
4051
|
+
graphMaxEdges: Number(draft.graphMaxEdges),
|
|
4052
|
+
storageBudgetMb: Number(draft.storageBudgetMb),
|
|
4053
|
+
'decay.halfLifeDays': Number(draft.decayHalfLifeDays),
|
|
4054
|
+
'activeSet.cap': Number(draft.activeSetCap),
|
|
4055
|
+
maxRecallTopK: Number(draft.maxRecallTopK),
|
|
4056
|
+
'retrieval.topK': Number(draft.retrievalTopK),
|
|
4057
|
+
'context.maxTokens': Number(draft.context.maxTokens),
|
|
4058
|
+
'context.maxInjectTokens': Number(draft.context.maxInjectTokens),
|
|
4059
|
+
'context.threshold': Number(draft.context.threshold),
|
|
4060
|
+
'context.target': Number(draft.context.target),
|
|
4061
|
+
'context.injectPrompt': Boolean(draft.context.injectPrompt),
|
|
4062
|
+
'context.injectMode': draft.context.injectMode === 'full' ? 'full' : 'index',
|
|
4063
|
+
'context.mode': draft.context.mode === 'expert' ? 'expert' : 'task',
|
|
4064
|
+
'context.hintsIdleSilenceAfter': Number(draft.context.hintsIdleSilenceAfter),
|
|
4065
|
+
'context.statePointer.enabled': Boolean(draft.context.statePointer && draft.context.statePointer.enabled),
|
|
4066
|
+
'context.autoSpaceFollow': Boolean(draft.context.autoSpaceFollow),
|
|
4067
|
+
'context.autoRolloverEnabled': Boolean(draft.context.autoRolloverEnabled),
|
|
4068
|
+
'context.coldStartInjectSummary': Boolean(draft.context.coldStartInjectSummary),
|
|
4069
|
+
'context.coldStartInjectRecentTurns': Boolean(draft.context.coldStartInjectRecentTurns),
|
|
4070
|
+
'context.autoRolloverThreshold': Number(draft.context.autoRolloverThreshold),
|
|
4071
|
+
'context.nativeTokenLimit': Number(draft.context.nativeTokenLimit),
|
|
4072
|
+
'context.requireExplicitConsentForTransfer': Boolean(draft.context.requireExplicitConsentForTransfer),
|
|
4073
|
+
'index.maxPostingsPerTag': Number(draft.index.maxPostingsPerTag),
|
|
4074
|
+
'tools.disabled': Array.isArray(draft.tools.disabled) ? [...draft.tools.disabled] : [],
|
|
4075
|
+
'tagging.autoTag': Boolean(draft.tagging.autoTag),
|
|
4076
|
+
'tagging.maxTags': Number(draft.tagging.maxTags),
|
|
4077
|
+
'features.multiSpace': Boolean(draft.features.multiSpace),
|
|
4078
|
+
'features.crossSpaceTransfer': Boolean(draft.features.crossSpaceTransfer),
|
|
4079
|
+
'features.crossSpaceRecall': Boolean(draft.features.crossSpaceRecall),
|
|
4080
|
+
'dream.useLlm': Boolean(draft.dream.useLlm),
|
|
4081
|
+
'dream.minGroupSize': Number(draft.dream.minGroupSize),
|
|
4082
|
+
'dream.maxGroupsPerRun': Number(draft.dream.maxGroupsPerRun),
|
|
4083
|
+
'dream.maxSummaryChars': Number(draft.dream.maxSummaryChars),
|
|
4084
|
+
'dream.maxSourceChars': Number(draft.dream.maxSourceChars),
|
|
4085
|
+
'dream.maxEventsPerGroup': Number(draft.dream.maxEventsPerGroup),
|
|
4086
|
+
'dream.llmTimeoutMs': Number(draft.dream.llmTimeoutMs),
|
|
4087
|
+
'dream.failureThreshold': Number(draft.dream.failureThreshold),
|
|
4088
|
+
'dream.cooldownMinutes': Number(draft.dream.cooldownMinutes),
|
|
4089
|
+
'dream.compensateAfterHours': Number(draft.dream.compensateAfterHours),
|
|
4090
|
+
'dream.onlyLowValley': Boolean(draft.dream.onlyLowValley),
|
|
4091
|
+
'l2Merge.enabled': Boolean(draft.l2Merge.enabled),
|
|
4092
|
+
'l2Merge.minGroupSize': Number(draft.l2Merge.minGroupSize),
|
|
4093
|
+
'l2Merge.maxGroupsPerRun': Number(draft.l2Merge.maxGroupsPerRun),
|
|
4094
|
+
'l2Merge.maxSummaryChars': Number(draft.l2Merge.maxSummaryChars),
|
|
4095
|
+
'temp.ttlDays': Number(draft.temp.ttlDays),
|
|
4096
|
+
'temp.promotionWindowDays': Number(draft.temp.promotionWindowDays),
|
|
4097
|
+
'raw.mode': String(draft.rawMode),
|
|
4098
|
+
'raw.minSalience': Number(draft.rawMinSalience),
|
|
4099
|
+
'raw.maxTotalMb': Number(draft.rawMaxTotalMb),
|
|
4100
|
+
'raw.retentionDays': Number(draft.rawRetentionDays),
|
|
4101
|
+
'raw.archiveAfterDays': Number(draft.rawArchiveAfterDays),
|
|
4102
|
+
'raw.compressionEngine': ['brotli', 'zstd', 'gzip'].includes(draft.rawCompressionEngine)
|
|
4103
|
+
? draft.rawCompressionEngine
|
|
4104
|
+
: 'brotli',
|
|
4105
|
+
'raw.maxScanTurns': Number(draft.rawMaxScanTurns),
|
|
4106
|
+
'delete.graceHours': Number(draft.deleteGraceHours),
|
|
4107
|
+
'review.enabled': Boolean(draft.reviewEnabled),
|
|
4108
|
+
'tagTree.midHalfLifeMultiplier': Number(draft.tagTree.midHalfLifeMultiplier),
|
|
4109
|
+
'tagTree.midGracePeriodDays': Number(draft.tagTree.midGracePeriodDays),
|
|
4110
|
+
'tagTree.pruneBatchSize': Number(draft.tagTree.pruneBatchSize),
|
|
4111
|
+
'tagTree.leafDecayFloor': Number(draft.tagTree.leafDecayFloor),
|
|
4112
|
+
'identity.eventTimePolicy': draft.eventTimePolicy,
|
|
4113
|
+
};
|
|
4114
|
+
// v1.6.3: 简洁模式只提交可见键,隐藏项在文件里保持原值(不重置为默认值)。
|
|
4115
|
+
const payloadPatch = simpleMode
|
|
4116
|
+
? Object.fromEntries(Object.entries(patch).filter(([key]) => SIMPLE_PATCH_KEYS.includes(key)))
|
|
4117
|
+
: patch;
|
|
4118
|
+
try {
|
|
4119
|
+
const { body } = await getJson(API.config, {
|
|
4120
|
+
method: 'POST',
|
|
4121
|
+
headers: { 'content-type': 'application/json' },
|
|
4122
|
+
body: JSON.stringify({ patch: payloadPatch }),
|
|
4123
|
+
});
|
|
4124
|
+
if (body && body.ok === true) {
|
|
4125
|
+
setDraft(draftFromConfig(body.config));
|
|
4126
|
+
setStatus({ tone: body.persisted ? 'ok' : 'warn', text: body.persisted ? '已保存并生效' : `已生效(未持久化):${body.note || ''}` });
|
|
4127
|
+
// The panel listens for this: it refetches stats + graph right away
|
|
4128
|
+
// instead of waiting for the next 3s poll.
|
|
4129
|
+
announce('config-changed');
|
|
4130
|
+
} else {
|
|
4131
|
+
const error = (body && body.error) || {};
|
|
4132
|
+
setStatus({ tone: 'error', text: `${error.code || 'MEM_E_UNKNOWN'}: ${error.message || '保存失败'}` });
|
|
4133
|
+
}
|
|
4134
|
+
} catch (error) {
|
|
4135
|
+
setStatus({ tone: 'error', text: String((error && error.message) || error) });
|
|
4136
|
+
} finally {
|
|
4137
|
+
setSaving(false);
|
|
4138
|
+
}
|
|
4139
|
+
};
|
|
4140
|
+
|
|
4141
|
+
const disabled = saving || shellState !== 'ready';
|
|
4142
|
+
|
|
4143
|
+
// Escape hatch handler: clear session baseline + in-flight guard + marker.
|
|
4144
|
+
// It never deletes memories; if it fails the panel reports the code plainly.
|
|
4145
|
+
const resetHandoffState = async () => {
|
|
4146
|
+
setEscapeBusy(true);
|
|
4147
|
+
setEscapeStatus(null);
|
|
4148
|
+
try {
|
|
4149
|
+
const { status: httpStatus, body } = await getJson(API.sessionReset, {
|
|
4150
|
+
method: 'POST',
|
|
4151
|
+
headers: { 'content-type': 'application/json' },
|
|
4152
|
+
body: JSON.stringify({ reason: 'ui_escape_hatch' }),
|
|
4153
|
+
});
|
|
4154
|
+
if (body && body.ok === true) {
|
|
4155
|
+
setEscapeStatus({ tone: 'ok', text: '已重置交接状态:会话基线清零、handoff 标记已消费' });
|
|
4156
|
+
announce('config-changed');
|
|
4157
|
+
} else {
|
|
4158
|
+
const error = (body && body.error) || {};
|
|
4159
|
+
setEscapeStatus({ tone: 'error', text: `重置失败:${error.code || 'MEM_E_UNKNOWN'} ${error.message || `HTTP ${httpStatus}`}` });
|
|
4160
|
+
}
|
|
4161
|
+
} catch (error) {
|
|
4162
|
+
setEscapeStatus({ tone: 'error', text: `重置失败:${(error && error.message) || error}` });
|
|
4163
|
+
} finally {
|
|
4164
|
+
setEscapeBusy(false);
|
|
4165
|
+
}
|
|
4166
|
+
};
|
|
4167
|
+
|
|
4168
|
+
// 简洁模式 hides groups wholesale: a rail item with nothing visible under it would
|
|
4169
|
+
// be a dead link, so the filter and the render read the SAME flag.
|
|
4170
|
+
const settingsNavItems = SETTINGS_GROUPS.filter((group) => !simpleMode || group.visibleInSimple);
|
|
4171
|
+
const pickGroup = (id) => {
|
|
4172
|
+
setActiveGroup(id);
|
|
4173
|
+
const node = groupRefs.current[id];
|
|
4174
|
+
if (node && typeof node.scrollIntoView === 'function') node.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
4175
|
+
};
|
|
4176
|
+
// One bag instead of 20 positional props: the group bodies were moved verbatim out
|
|
4177
|
+
// of this function, so they still read `draft` / `edit` / `disabled` from here.
|
|
4178
|
+
const settingsBag = {
|
|
4179
|
+
activeSpace,
|
|
4180
|
+
state,
|
|
4181
|
+
configState,
|
|
4182
|
+
serverConfig,
|
|
4183
|
+
shellState,
|
|
4184
|
+
draft,
|
|
4185
|
+
status,
|
|
4186
|
+
saving,
|
|
4187
|
+
settingsMode,
|
|
4188
|
+
simpleMode,
|
|
4189
|
+
escapeStatus,
|
|
4190
|
+
escapeBusy,
|
|
4191
|
+
statsPayload,
|
|
4192
|
+
sessionPanel,
|
|
4193
|
+
reportedSpace,
|
|
4194
|
+
displayedSpace,
|
|
4195
|
+
edit,
|
|
4196
|
+
disabled,
|
|
4197
|
+
resetHandoffState,
|
|
4198
|
+
};
|
|
4199
|
+
|
|
4200
|
+
return h(
|
|
4201
|
+
'div',
|
|
4202
|
+
{ style: { padding: 16, display: 'flex', flexDirection: 'column', gap: 12, maxWidth: 980 } },
|
|
4203
|
+
h('div', { style: { fontSize: 16, fontWeight: 600 } }, '海马体记忆'),
|
|
4204
|
+
h('div', { style: labelStyle }, '保存后立即作用于运行时(fail-fast 校验,越界会被拒绝),并在可持久化时写回 Loader 配置。'),
|
|
4205
|
+
// v1.6.3: 视图切换。简洁模式只显示四块,隐藏项不参与保存、文件里保持原值。
|
|
4206
|
+
h(
|
|
4207
|
+
'div',
|
|
4208
|
+
{ style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' } },
|
|
4209
|
+
h(
|
|
4210
|
+
'button',
|
|
4211
|
+
{
|
|
4212
|
+
type: 'button',
|
|
4213
|
+
style: {
|
|
4214
|
+
...smallButtonStyle,
|
|
4215
|
+
...(simpleMode
|
|
4216
|
+
? { borderColor: palette.accent, color: palette.accent, fontWeight: 600 }
|
|
4217
|
+
: {}),
|
|
4218
|
+
},
|
|
4219
|
+
onClick: () => {
|
|
4220
|
+
writeSettingsMode('simple');
|
|
4221
|
+
setSettingsMode('simple');
|
|
4222
|
+
},
|
|
4223
|
+
},
|
|
4224
|
+
'简洁模式',
|
|
4225
|
+
),
|
|
4226
|
+
h(
|
|
4227
|
+
'button',
|
|
4228
|
+
{
|
|
4229
|
+
type: 'button',
|
|
4230
|
+
style: {
|
|
4231
|
+
...smallButtonStyle,
|
|
4232
|
+
...(!simpleMode
|
|
4233
|
+
? { borderColor: palette.accent, color: palette.accent, fontWeight: 600 }
|
|
4234
|
+
: {}),
|
|
4235
|
+
},
|
|
4236
|
+
onClick: () => {
|
|
4237
|
+
writeSettingsMode('pro');
|
|
4238
|
+
setSettingsMode('pro');
|
|
4239
|
+
},
|
|
4240
|
+
},
|
|
4241
|
+
'专业模式',
|
|
4242
|
+
),
|
|
4243
|
+
h(
|
|
4244
|
+
'span',
|
|
4245
|
+
{ style: { ...labelStyle, marginBottom: 0 } },
|
|
4246
|
+
simpleMode
|
|
4247
|
+
? '只显示身份、上下文窗口、存储位置迁移与原始回合留存三项;其余配置保持文件中的现有值,不会被改写。'
|
|
4248
|
+
: '显示全部配置项。',
|
|
4249
|
+
),
|
|
3897
4250
|
),
|
|
4251
|
+
shellState !== 'ready'
|
|
4252
|
+
? h(
|
|
4253
|
+
'div',
|
|
4254
|
+
{
|
|
4255
|
+
style: {
|
|
4256
|
+
padding: '8px 12px',
|
|
4257
|
+
borderRadius: 10,
|
|
4258
|
+
border: `1px solid ${palette.warn}`,
|
|
4259
|
+
color: palette.warn,
|
|
4260
|
+
fontSize: 12,
|
|
4261
|
+
},
|
|
4262
|
+
},
|
|
4263
|
+
`当前状态:${shellState}。可以查看配置,但写入要等记忆库就绪(写入会被 MEM_E_NOT_READY 拒绝,不会静默丢失)。`,
|
|
4264
|
+
)
|
|
4265
|
+
: null,
|
|
4266
|
+
status && status.tone === 'error'
|
|
4267
|
+
? h(
|
|
4268
|
+
'div',
|
|
4269
|
+
{
|
|
4270
|
+
style: {
|
|
4271
|
+
padding: '10px 12px',
|
|
4272
|
+
borderRadius: 10,
|
|
4273
|
+
border: `1px solid ${palette.danger}`,
|
|
4274
|
+
background: 'rgba(217,83,79,0.12)',
|
|
4275
|
+
color: palette.danger,
|
|
4276
|
+
fontSize: 13,
|
|
4277
|
+
},
|
|
4278
|
+
},
|
|
4279
|
+
status.text,
|
|
4280
|
+
)
|
|
4281
|
+
: null,
|
|
4282
|
+
// v1.7.2 (fixed): grouped, two-pane layout. The rail and the cards each own their
|
|
4283
|
+
// scrollbar and both are sized from the measured viewport height — that is what makes
|
|
4284
|
+
// the rail follow the user instead of scrolling out of view with the cards.
|
|
3898
4285
|
h(
|
|
3899
|
-
|
|
4286
|
+
'div',
|
|
3900
4287
|
{
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
4288
|
+
ref: settingsShellRef,
|
|
4289
|
+
style: {
|
|
4290
|
+
display: 'flex',
|
|
4291
|
+
alignItems: 'stretch',
|
|
4292
|
+
gap: 18,
|
|
4293
|
+
...(shellHeight ? { height: shellHeight } : {}),
|
|
4294
|
+
},
|
|
3904
4295
|
},
|
|
3905
|
-
h(
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
h(
|
|
3948
|
-
Section,
|
|
3949
|
-
{ title: '老化与活跃集合', hint: '这两个值同时是策略参数:写入 config 即进入 policy,下一次维护生效。', hidden: simpleMode },
|
|
3950
|
-
h(Field, {
|
|
3951
|
-
label: '记忆半衰期(decay.halfLifeDays)',
|
|
3952
|
-
hint: '默认 30 天。调大能记住更久。',
|
|
3953
|
-
value: draft.decayHalfLifeDays,
|
|
3954
|
-
min: 7,
|
|
3955
|
-
max: 365,
|
|
3956
|
-
step: 1,
|
|
3957
|
-
suffix: '天',
|
|
3958
|
-
onChange: (value) => edit('decayHalfLifeDays', value),
|
|
3959
|
-
disabled,
|
|
3960
|
-
}),
|
|
3961
|
-
h(Field, {
|
|
3962
|
-
label: '活跃标签上限(activeSet.cap)',
|
|
3963
|
-
hint: '默认 200。多项目并行可调至 500(下次维护生效)。',
|
|
3964
|
-
value: draft.activeSetCap,
|
|
3965
|
-
min: 100,
|
|
3966
|
-
max: 1000,
|
|
3967
|
-
step: 50,
|
|
3968
|
-
onChange: (value) => edit('activeSetCap', value),
|
|
3969
|
-
disabled,
|
|
3970
|
-
}),
|
|
3971
|
-
),
|
|
3972
|
-
h(
|
|
3973
|
-
Section,
|
|
3974
|
-
{ title: 'L2.5 趋势隔离', hidden: simpleMode },
|
|
3975
|
-
h(Field, {
|
|
3976
|
-
label: '隔离期(天)',
|
|
3977
|
-
value: draft.temp.ttlDays,
|
|
3978
|
-
min: 1,
|
|
3979
|
-
max: 3650,
|
|
3980
|
-
step: 1,
|
|
3981
|
-
suffix: '天',
|
|
3982
|
-
onChange: (value) => edit('temp.ttlDays', value),
|
|
3983
|
-
disabled,
|
|
3984
|
-
}),
|
|
3985
|
-
h(Field, {
|
|
3986
|
-
label: '晋升窗口(天)',
|
|
3987
|
-
hint: '必须不大于隔离期。',
|
|
3988
|
-
value: draft.temp.promotionWindowDays,
|
|
3989
|
-
min: 0,
|
|
3990
|
-
max: 3650,
|
|
3991
|
-
step: 1,
|
|
3992
|
-
suffix: '天',
|
|
3993
|
-
onChange: (value) => edit('temp.promotionWindowDays', value),
|
|
3994
|
-
disabled,
|
|
3995
|
-
}),
|
|
3996
|
-
),
|
|
3997
|
-
h(
|
|
3998
|
-
Section,
|
|
3999
|
-
{ title: '身份' },
|
|
4000
|
-
h(Select, {
|
|
4001
|
-
label: '事件时间策略(identity.eventTimePolicy)',
|
|
4002
|
-
hint: 'content:由内容推导;explicit:调用方必须提供;ingest:使用写入时刻。',
|
|
4003
|
-
value: draft.eventTimePolicy,
|
|
4004
|
-
options: EVENT_TIME_OPTIONS,
|
|
4005
|
-
onChange: (value) => edit('eventTimePolicy', value),
|
|
4006
|
-
disabled,
|
|
4007
|
-
}),
|
|
4008
|
-
),
|
|
4009
|
-
h(
|
|
4296
|
+
h(SettingsNav, { items: settingsNavItems, activeId: activeGroup, onPick: pickGroup, height: shellHeight }),
|
|
4297
|
+
h(
|
|
4298
|
+
'div',
|
|
4299
|
+
{
|
|
4300
|
+
ref: settingsContentRef,
|
|
4301
|
+
style: {
|
|
4302
|
+
flex: '1 1 460px',
|
|
4303
|
+
minWidth: 0,
|
|
4304
|
+
display: 'flex',
|
|
4305
|
+
flexDirection: 'column',
|
|
4306
|
+
gap: 14,
|
|
4307
|
+
overflowY: 'auto',
|
|
4308
|
+
overflowX: 'hidden',
|
|
4309
|
+
paddingRight: 6,
|
|
4310
|
+
},
|
|
4311
|
+
},
|
|
4312
|
+
h(
|
|
4313
|
+
SettingsGroup,
|
|
4314
|
+
{ groupId: 'identity', label: '身份与行为', hint: '人格锚点 · 空闲行为', groupRefs },
|
|
4315
|
+
...SettingsIdentityGroup(settingsBag),
|
|
4316
|
+
),
|
|
4317
|
+
h(
|
|
4318
|
+
SettingsGroup,
|
|
4319
|
+
{ groupId: 'context', label: '上下文与注入', hint: '窗口记账 · 注入形态 · 运行模式 · 检索 · 调度', groupRefs },
|
|
4320
|
+
...SettingsContextGroup(settingsBag),
|
|
4321
|
+
),
|
|
4322
|
+
h(
|
|
4323
|
+
SettingsGroup,
|
|
4324
|
+
{ groupId: 'ingest', label: '摄入与蒸馏', hint: '打标 · 工具裁剪 · 能力开关 · Dream / L2 合并 / L2.5', groupRefs },
|
|
4325
|
+
...SettingsIngestGroup(settingsBag),
|
|
4326
|
+
),
|
|
4327
|
+
h(
|
|
4328
|
+
SettingsGroup,
|
|
4329
|
+
{ groupId: 'retention', label: '留存与归档', hint: 'raw 冷热分层 · 标签树 · 老化 · 存储图谱 · 删除复习', groupRefs },
|
|
4330
|
+
...SettingsRetentionGroup(settingsBag),
|
|
4331
|
+
),
|
|
4332
|
+
h(
|
|
4333
|
+
SettingsGroup,
|
|
4334
|
+
{ groupId: 'space', label: '空间与存储', hint: '多空间路由 · 会话交接 · 数据目录迁移', groupRefs },
|
|
4335
|
+
...SettingsSpaceGroup(settingsBag),
|
|
4336
|
+
),
|
|
4337
|
+
h(
|
|
4010
4338
|
'div',
|
|
4011
4339
|
{ style: { display: 'flex', alignItems: 'center', gap: 12, position: 'sticky', bottom: 0, padding: '8px 0', background: 'transparent' } },
|
|
4012
4340
|
h(
|
|
@@ -4031,11 +4359,14 @@
|
|
|
4031
4359
|
),
|
|
4032
4360
|
// The very bottom of the settings content (after the save row): the
|
|
4033
4361
|
// promise the engine can actually keep. Sessions die; the persona does not.
|
|
4034
|
-
|
|
4362
|
+
h(
|
|
4035
4363
|
'div',
|
|
4036
4364
|
{ style: { paddingTop: 10, borderTop: `1px solid ${palette.border}`, fontSize: 12, fontWeight: 600, color: palette.muted } },
|
|
4037
4365
|
'本插件不能保证一个会话永生不死,只能保证人格不死。',
|
|
4038
4366
|
),
|
|
4367
|
+
|
|
4368
|
+
),
|
|
4369
|
+
),
|
|
4039
4370
|
);
|
|
4040
4371
|
}
|
|
4041
4372
|
/**
|