cc-viewer 1.9.38 → 1.9.40

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.
Files changed (90) hide show
  1. package/README.md +1 -1
  2. package/cli.js +21 -3
  3. package/dist/assets/App-xr2_jMmt.js +2 -0
  4. package/dist/assets/{ArchivePreview-BwkACTcN.js → ArchivePreview-D2R7hDMc.js} +1 -1
  5. package/dist/assets/{AudioPreview-Bzzv-8w2.js → AudioPreview-BW-GVXor.js} +1 -1
  6. package/dist/assets/{MdxEditorPanel-DgInZmjn.js → MdxEditorPanel-BmHoSyaM.js} +1 -1
  7. package/dist/assets/Mobile-ChVyshSc.js +1 -0
  8. package/dist/assets/{ProxyStatsModal-C0EVF31b.js → ProxyStatsModal-Bh6hozim.js} +1 -1
  9. package/dist/assets/{SubtitlePreview-D3MhYKJS.js → SubtitlePreview-CIfWePYB.js} +1 -1
  10. package/dist/assets/{_baseUniq-uUw7d1E3.js → _baseUniq-xRiWMqOw.js} +1 -1
  11. package/dist/assets/{arc-BOWuMiV4.js → arc-edNwlWnI.js} +1 -1
  12. package/dist/assets/{architectureDiagram-Q4EWVU46-h5aWPWJ4.js → architectureDiagram-Q4EWVU46-SMfdtr57.js} +1 -1
  13. package/dist/assets/{blockDiagram-DXYQGD6D-CudvZcvo.js → blockDiagram-DXYQGD6D-BxAsQG58.js} +1 -1
  14. package/dist/assets/{c4Diagram-AHTNJAMY-DYlZi3dM.js → c4Diagram-AHTNJAMY-DvEHTYBD.js} +1 -1
  15. package/dist/assets/{channel-XJqusGHw.js → channel-Ce5Cf3nY.js} +1 -1
  16. package/dist/assets/{chunk-4BX2VUAB-CLpyEaWp.js → chunk-4BX2VUAB--OnGvs-9.js} +1 -1
  17. package/dist/assets/{chunk-4TB4RGXK-BAuE3fNK.js → chunk-4TB4RGXK-MSrYeKo5.js} +1 -1
  18. package/dist/assets/{chunk-55IACEB6-B4tW65z_.js → chunk-55IACEB6-CD4rh-7b.js} +1 -1
  19. package/dist/assets/{chunk-EDXVE4YY-Bb7xoST0.js → chunk-EDXVE4YY-CrAxlPfF.js} +1 -1
  20. package/dist/assets/{chunk-FMBD7UC4-CTkqi9Np.js → chunk-FMBD7UC4-CMb4qB5t.js} +1 -1
  21. package/dist/assets/{chunk-OYMX7WX6-uQdTKgLj.js → chunk-OYMX7WX6-CEP3GJND.js} +1 -1
  22. package/dist/assets/{chunk-QZHKN3VN-C6ugcDBb.js → chunk-QZHKN3VN-Xko480I7.js} +1 -1
  23. package/dist/assets/{chunk-YZCP3GAM-Hp9H2dEu.js → chunk-YZCP3GAM-xKPv2jAr.js} +1 -1
  24. package/dist/assets/classDiagram-6PBFFD2Q-CAw9u3mr.js +1 -0
  25. package/dist/assets/classDiagram-v2-HSJHXN6E-CAw9u3mr.js +1 -0
  26. package/dist/assets/clone-CW1SPXDP.js +1 -0
  27. package/dist/assets/{cose-bilkent-S5V4N54A-BqngH0-b.js → cose-bilkent-S5V4N54A-Dd5Fpol9.js} +1 -1
  28. package/dist/assets/{dagre-KV5264BT-CB2GDseU.js → dagre-KV5264BT-BH00hKa4.js} +1 -1
  29. package/dist/assets/{diagram-5BDNPKRD-DLymVFaP.js → diagram-5BDNPKRD-BJZlGmRA.js} +1 -1
  30. package/dist/assets/{diagram-G4DWMVQ6-D90wHjyV.js → diagram-G4DWMVQ6-BTj-YG-C.js} +1 -1
  31. package/dist/assets/{diagram-MMDJMWI5-BUN9g8qX.js → diagram-MMDJMWI5-2ZD4VZMB.js} +1 -1
  32. package/dist/assets/{diagram-TYMM5635-I51WOx9p.js → diagram-TYMM5635-mTEHpW4W.js} +1 -1
  33. package/dist/assets/{erDiagram-SMLLAGMA-CR1_hpJO.js → erDiagram-SMLLAGMA-DTOSCCrk.js} +1 -1
  34. package/dist/assets/{flowDiagram-DWJPFMVM-CiwoAZbF.js → flowDiagram-DWJPFMVM-C4ZAoiRL.js} +1 -1
  35. package/dist/assets/{ganttDiagram-T4ZO3ILL-CJXNdMQL.js → ganttDiagram-T4ZO3ILL-C56IAugD.js} +1 -1
  36. package/dist/assets/{gitGraphDiagram-UUTBAWPF-BaZdjuy6.js → gitGraphDiagram-UUTBAWPF-fvtnUb6S.js} +1 -1
  37. package/dist/assets/{graph-CpnKw6r1.js → graph-CnqqDZhs.js} +1 -1
  38. package/dist/assets/{index-D3x00_V6.js → index-BUkls72j.js} +1 -1
  39. package/dist/assets/{index-BzeiQo_V.js → index-CEinmFtX.js} +1 -1
  40. package/dist/assets/{index-BrAqjeq3.js → index-CcAn_gE2.js} +1 -1
  41. package/dist/assets/{index-C1VAmODt.js → index-CdN-CkKM.js} +1 -1
  42. package/dist/assets/{index-C5FKlPaZ.js → index-DjoCHMpJ.js} +1 -1
  43. package/dist/assets/{index-DL6PUDDq.js → index-Dq3ex7Ip.js} +1 -1
  44. package/dist/assets/{index-VjrFIlap.js → index-F9AcG6Ef.js} +1 -1
  45. package/dist/assets/index-wcuKUBHj.js +2 -0
  46. package/dist/assets/{infoDiagram-42DDH7IO-BvyXlqWb.js → infoDiagram-42DDH7IO-B-b77lg9.js} +1 -1
  47. package/dist/assets/{ishikawaDiagram-UXIWVN3A-CwbVWeK4.js → ishikawaDiagram-UXIWVN3A-B1ituugL.js} +1 -1
  48. package/dist/assets/{journeyDiagram-VCZTEJTY-DDVzhfoW.js → journeyDiagram-VCZTEJTY-DvFc_1_L.js} +1 -1
  49. package/dist/assets/{jszip.min-RVG0sxQ-.js → jszip.min-Br1yL7Q3.js} +1 -1
  50. package/dist/assets/{kanban-definition-6JOO6SKY-CC9zdzb4.js → kanban-definition-6JOO6SKY-B-3zDwdJ.js} +1 -1
  51. package/dist/assets/{layout-BP8agUEZ.js → layout-B8tT3Nrd.js} +1 -1
  52. package/dist/assets/{linear-D2xrTRbP.js → linear-BVxRmpuU.js} +1 -1
  53. package/dist/assets/{mermaid.core-iygJ4rTs.js → mermaid.core-TpktUJt6.js} +2 -2
  54. package/dist/assets/{min-DZABGYh9.js → min-4AuCZ0ho.js} +1 -1
  55. package/dist/assets/{mindmap-definition-QFDTVHPH-DonHZQOo.js → mindmap-definition-QFDTVHPH-MQeup-Jb.js} +1 -1
  56. package/dist/assets/{pieDiagram-DEJITSTG-CEn16Sb_.js → pieDiagram-DEJITSTG-mSFlWRpV.js} +1 -1
  57. package/dist/assets/{quadrantDiagram-34T5L4WZ-385okL2K.js → quadrantDiagram-34T5L4WZ-BE2AHw1J.js} +1 -1
  58. package/dist/assets/{requirementDiagram-MS252O5E-B7AA6wNS.js → requirementDiagram-MS252O5E-CSat0Shv.js} +1 -1
  59. package/dist/assets/{sankeyDiagram-XADWPNL6-BE2hbI0P.js → sankeyDiagram-XADWPNL6-jSfdI1J9.js} +1 -1
  60. package/dist/assets/seqResourceLoaders-DhLjhTUI.js +2 -0
  61. package/dist/assets/{seqResourceLoaders-BdxjrasH.css → seqResourceLoaders-xFMwU2we.css} +1 -1
  62. package/dist/assets/{sequenceDiagram-FGHM5R23-DUbU1ZOb.js → sequenceDiagram-FGHM5R23-n8z9Vixi.js} +1 -1
  63. package/dist/assets/{stateDiagram-FHFEXIEX-BKKvwNQM.js → stateDiagram-FHFEXIEX-Dn_y_D8r.js} +1 -1
  64. package/dist/assets/{stateDiagram-v2-QKLJ7IA2-qXlEdp-K.js → stateDiagram-v2-QKLJ7IA2-BB1b-66S.js} +1 -1
  65. package/dist/assets/{timeline-definition-GMOUNBTQ-DQnlfuvY.js → timeline-definition-GMOUNBTQ-Bvy0hn9D.js} +1 -1
  66. package/dist/assets/{vendor-antd-DTdiXvO1.js → vendor-antd-BciJO790.js} +1 -1
  67. package/dist/assets/{vendor-codemirror-Dg_w9qS2.js → vendor-codemirror-BVX6n7ix.js} +1 -1
  68. package/dist/assets/{vendor-mdxeditor-DNrU6OL8.js → vendor-mdxeditor-BlcXEhaG.js} +2 -2
  69. package/dist/assets/{vendor-qrcode-BdV5qU8N.js → vendor-qrcode-DVibqC0x.js} +1 -1
  70. package/dist/assets/{vendor-virtuoso-BQELbHyq.js → vendor-virtuoso-CsBSMJ5R.js} +1 -1
  71. package/dist/assets/{vennDiagram-DHZGUBPP-B51WBYoK.js → vennDiagram-DHZGUBPP-BVqFkdla.js} +1 -1
  72. package/dist/assets/{wardley-RL74JXVD-DQSgSi6f.js → wardley-RL74JXVD-BIAqGP0w.js} +1 -1
  73. package/dist/assets/{wardleyDiagram-NUSXRM2D-B5PCvQWU.js → wardleyDiagram-NUSXRM2D-DGUvrzIN.js} +1 -1
  74. package/dist/assets/{xychartDiagram-5P7HB3ND-fY2LLKhL.js → xychartDiagram-5P7HB3ND-BjEJgIoR.js} +1 -1
  75. package/dist/index.html +4 -4
  76. package/package.json +1 -1
  77. package/server/lib/im/im-config.js +16 -3
  78. package/server/lib/im/im-proxy-profile.js +99 -0
  79. package/server/lib/project-prefs.js +4 -10
  80. package/server/routes/dingtalk.js +4 -0
  81. package/server/routes/im.js +4 -0
  82. package/server/routes/preferences.js +4 -12
  83. package/server/routes/project-prefs.js +6 -0
  84. package/dist/assets/App-CF8BZExv.js +0 -2
  85. package/dist/assets/Mobile-BwxpuUXE.js +0 -1
  86. package/dist/assets/classDiagram-6PBFFD2Q-CqAo3MbD.js +0 -1
  87. package/dist/assets/classDiagram-v2-HSJHXN6E-CqAo3MbD.js +0 -1
  88. package/dist/assets/clone-BIwWiqgh.js +0 -1
  89. package/dist/assets/index-D-DhPfzj.js +0 -2
  90. package/dist/assets/seqResourceLoaders-DPto114V.js +0 -2
@@ -0,0 +1,99 @@
1
+ // Per-platform proxy-profile pin for IM SDK workers.
2
+ //
3
+ // An IM worker binds its interceptor workspace from process.cwd() (= IM_<id>) the moment
4
+ // server/proxy.js → server/interceptor.js is imported, and reads <LOG_DIR>/IM_<id>/
5
+ // active-profile.json at module top. So the pin must be written BEFORE that import — cli.js
6
+ // calls applyImProxyProfile() just before importing proxy.js.
7
+ //
8
+ // Source of truth: the platform's config (`preferences.json.<platform>.proxyProfileId`). The
9
+ // workspace file is a projection of that config, re-asserted on every boot. We deliberately do
10
+ // NOT reuse interceptor's _writeWorkspaceActive (private, returns bool, swallows) or
11
+ // mergeActivePayload for the clear path: mergeActivePayload coerces a non-string activeId to
12
+ // 'max' (an explicit Default pin), which cannot express "clear the override and follow global".
13
+ // Omitting the activeId key restores the global fallback (see _readWorkspaceActive, which only
14
+ // honors a string activeId). Reads/writes go through the shared json-store kernel (atomic, 0600).
15
+ //
16
+ // "Unset" vs "explicitly cleared": an empty config pin is ambiguous — it is both the factory
17
+ // state and the value after a user clears the selector. A marker file (.proxy-pin-bootstrapped)
18
+ // records that first-boot adoption has already run: before the marker, an existing workspace pin
19
+ // (set via the worker's own proxy UI) is ADOPTED into the config rather than discarded; after the
20
+ // marker, an empty config authoritatively clears the override.
21
+ import { join } from 'node:path';
22
+ import { existsSync, writeFileSync } from 'node:fs';
23
+ import { reportSwallowed } from '../error-report.js';
24
+ import { readJsonStrict, writeJsonAtomic } from '../json-store.js';
25
+ import { normalizeRoles } from '../interceptor-core.js';
26
+ import { loadConfig, saveConfig } from './im-config.js';
27
+ import { imDir } from './im-lock.js';
28
+ import { LOG_DIR } from '../../../findcc.js';
29
+
30
+ const BOOTSTRAP_MARK = '.proxy-pin-bootstrapped';
31
+
32
+ function profileIdsOrNull() {
33
+ // null = profile.json absent/unreadable (unknown, not "empty").
34
+ const file = join(LOG_DIR, 'profile.json');
35
+ const r = readJsonStrict(file);
36
+ if (r.state === 'corrupt') {
37
+ reportSwallowed('im-proxy-profile.read-profile-json', new Error(`profile.json unreadable: ${file}`));
38
+ return null;
39
+ }
40
+ if (r.state !== 'ok') return null;
41
+ return new Set((r.data?.profiles || []).filter((p) => p && typeof p.id === 'string').map((p) => p.id));
42
+ }
43
+
44
+ function markBootstrapped(id) {
45
+ try { writeFileSync(join(imDir(id), BOOTSTRAP_MARK), '', { mode: 0o600 }); }
46
+ catch (err) { reportSwallowed('im-proxy-profile.bootstrap-mark', err); } // best-effort
47
+ }
48
+
49
+ // Persist the platform's pinned proxy profile into the worker's workspace active-profile.json.
50
+ // Returns { applied: 'noop'|'pinned'|'cleared'|'adopted', file }. Throws only when the atomic
51
+ // write fails; the caller (worker boot) treats that as non-fatal and falls back to the
52
+ // existing/global profile.
53
+ export function applyImProxyProfile(id, profileId) {
54
+ const file = join(imDir(id), 'active-profile.json');
55
+ const pin = typeof profileId === 'string' ? profileId.trim() : '';
56
+
57
+ // Structured read: missing / ok / corrupt. A corrupt file is repaired below with a clean
58
+ // payload — data-loss class, must be reported (throttled).
59
+ const r = readJsonStrict(file);
60
+ if (r.state === 'corrupt') {
61
+ reportSwallowed('im-proxy-profile.read-workspace-active', new Error(`active-profile.json unreadable: ${file}`));
62
+ }
63
+ const existing = r.state === 'ok' ? r.data : null;
64
+ // Merge-preserve roles: the worker's own Web UI may own subagent/teammate assignments.
65
+ const roles = normalizeRoles(existing?.roles);
66
+ const existingPin = (typeof existing?.activeId === 'string' && existing.activeId) ? existing.activeId : '';
67
+ const bootstrapped = existsSync(join(imDir(id), BOOTSTRAP_MARK));
68
+
69
+ if (!pin) {
70
+ if (existingPin && r.state === 'ok' && !bootstrapped) {
71
+ // First boot with an empty config but a runtime-set workspace pin: adopt it into the config
72
+ // (so the upgrade never silently discards the user's choice), then config is authoritative.
73
+ try { saveConfig(id, { ...loadConfig(id), proxyProfileId: existingPin }); }
74
+ catch (err) { reportSwallowed('im-proxy-profile.adopt-pin', err); } // non-fatal: keep the runtime pin this boot
75
+ markBootstrapped(id);
76
+ return { applied: 'adopted', file };
77
+ }
78
+ markBootstrapped(id);
79
+ if (!existingPin && r.state !== 'corrupt') return { applied: 'noop', file }; // follow global, nothing to clear
80
+ // Empty config AFTER bootstrap (or a corrupt file) ⇒ authoritatively clear: omit activeId.
81
+ writeJsonAtomic(file, { roles }, { mode: 0o600 });
82
+ return { applied: 'cleared', file };
83
+ }
84
+
85
+ // A non-empty config pin is authoritative; it also settles the bootstrap state.
86
+ markBootstrapped(id);
87
+ if (pin !== 'max') {
88
+ const ids = profileIdsOrNull();
89
+ // Unknown id: the interceptor resolves a dangling workspace activeId to Default and the
90
+ // session seed degrades to legacy main (also Default). Keep the pin so it auto-resumes if
91
+ // the profile is re-created; record it for diagnosis. profile.json unreadable → skip.
92
+ if (ids && !ids.has(pin)) {
93
+ reportSwallowed('im-proxy-profile.unknown-profile',
94
+ new Error(`IM ${id} pinned proxy profile "${pin}" not in profile.json — worker will fall back to Default`));
95
+ }
96
+ }
97
+ writeJsonAtomic(file, { activeId: pin, roles }, { mode: 0o600 });
98
+ return { applied: 'pinned', file };
99
+ }
@@ -15,10 +15,9 @@ import { getProjectName } from './project-state.js';
15
15
 
16
16
  // SINGLE SOURCE of "what must never live inside a fork": secrets (auth password + IM creds),
17
17
  // machine-level paths (logDir/claudeConfigDir), the internal forks map, and global-only features
18
- // that must stay identical across every project (scheduledTasks; contextCompaction — the
19
- // compaction rules are a machine-global list, never per-project). snapshotForFork / cleanPatch /
18
+ // that must stay identical across every project (scheduledTasks). snapshotForFork / cleanPatch /
20
19
  // the admin list read all funnel through stripSensitive so the rule can't drift.
21
- const STRIP_KEYS = ['auth', 'authByProject', 'prefsByProject', 'logDir', 'claudeConfigDir', 'scheduledTasks', 'contextCompaction'];
20
+ const STRIP_KEYS = ['auth', 'authByProject', 'prefsByProject', 'logDir', 'claudeConfigDir', 'scheduledTasks'];
22
21
 
23
22
  /** Strip secrets + IM credentials + machine-level keys from a prefs-shaped object in place. */
24
23
  export function stripSensitive(obj) {
@@ -82,17 +81,12 @@ export function snapshotForFork(prefsRaw) {
82
81
  * stamps them after this runs.
83
82
  */
84
83
  export function resolveScoped(globalPrefs, fork) {
85
- const { approvalModal: gAM, contextCompaction: gCC, ...gRest } = globalPrefs || {};
86
- // Strip the fork's own contextCompaction copy up front so a hand-edited/legacy dirty fork
87
- // can never shadow the global machine-wide list. The GLOBAL value is re-applied below.
88
- const { approvalModal: fAM, contextCompaction: _fCC, ...fRest } = fork || {};
84
+ const { approvalModal: gAM, ...gRest } = globalPrefs || {};
85
+ const { approvalModal: fAM, ...fRest } = fork || {};
89
86
  const merged = { ...gRest, ...fRest };
90
87
  // 定时任务是全局状态(claim CAS 只在全局 prefs 上进行)——fork 永远不得携带/遮蔽它,
91
88
  // 否则脏 fork 会把任务定义/claim 透给 scoped 客户端读侧。
92
89
  delete merged.scheduledTasks;
93
- // Compaction rules are machine-global (STRIP_KEYS already blocks fork writes): after stripping the fork's dirty copy, restore the global value —
94
- // what was removed is the fork's shadowing, not the global value itself (otherwise scoped clients lose the rules and their save would overwrite the global).
95
- if (gCC !== undefined) merged.contextCompaction = gCC;
96
90
  if (gAM || fAM) {
97
91
  // 防引用别名:fork 无 approvalModal 时也返回浅拷贝,避免调用方(preferencesGet 的
98
92
  // voicePack reconcile)回写到解析出的全局对象(当前每请求新解析虽无害,仍保持"绝不外泄内部引用")。
@@ -105,6 +105,10 @@ function dingtalkConfigPost(req, res, parsedUrl, isLocal, deps) {
105
105
  cardTemplateId: incoming.cardTemplateId,
106
106
  aiCardTemplateId: incoming.aiCardTemplateId,
107
107
  aiCardStreamKey: incoming.aiCardStreamKey,
108
+ // Pass through the proxy-profile pin; a client that predates the field omits it, which would
109
+ // let normalize() reset it to ''. Preserve the stored value in that case (mirrors the
110
+ // secret-field "empty = keep" convention) so a legacy full save cannot silently clear the pin.
111
+ proxyProfileId: 'proxyProfileId' in incoming ? incoming.proxyProfileId : loadDingTalkConfig().proxyProfileId,
108
112
  });
109
113
  // 驱动进程管理器(替代旧的在进程 reloadBridge):启用→重启 worker,停用→停 worker。
110
114
  try {
@@ -186,6 +186,10 @@ function imConfigPost(req, res, parsedUrl, isLocal, deps) {
186
186
  const incomingObj = (incoming && typeof incoming === 'object' && !Array.isArray(incoming)) ? incoming : {};
187
187
  const touchesOthers = desc.fields.some((f) => f.key !== 'enabled' && f.key in incomingObj);
188
188
  const effective = touchesOthers ? incomingObj : { ...loadConfig(id), enabled: !!incomingObj.enabled };
189
+ // Preserve the proxy-profile pin across full saves from a client that predates the field (a
190
+ // stale browser bundle / older API caller): absent from the body must not reset it to ''.
191
+ // Mirrors the secret-field "empty = keep" convention so the pin survives version skew.
192
+ if (!('proxyProfileId' in effective)) effective.proxyProfileId = loadConfig(id).proxyProfileId;
189
193
  if (effective.enabled) warnIfEmptyAllowlist(id, effective);
190
194
  const saved = saveConfig(id, effective);
191
195
  // applyProcess(默认 true,保持旧调用方语义):前端 onBlur 自动保存传 false → 仅存盘、不驱动进程,
@@ -154,19 +154,11 @@ function preferencesPost(req, res, parsedUrl, isLocal, deps) {
154
154
  // (admin included) may inject/clear/overwrite tasks through a prefs POST (claim CAS and schedule
155
155
  // state validation live only in the store layer).
156
156
  delete incoming.scheduledTasks;
157
- // Compaction rules are machine-global, and executionTiming:'auto' is auto-injected by the frontend
158
- // without confirmation — the danger class is identical to scheduledTasks. Non-admin clients (an
159
- // open no-password LAN session, or a cross-site form) must not plant a "low threshold + auto +
160
- // arbitrary script" rule into every session of the host operator. Admin-only; stripped otherwise.
161
- if (!isAdminReq(req, isLocal)) {
157
+ // contextCompaction is a rule list; a non-array value would be persisted verbatim and the web
158
+ // normalizer would silently collapse it to the built-in default rule. Drop malformed values,
159
+ // mirroring the fork-side cleanPatch guard (routes/project-prefs.js).
160
+ if (Object.prototype.hasOwnProperty.call(incoming, 'contextCompaction') && !Array.isArray(incoming.contextCompaction)) {
162
161
  delete incoming.contextCompaction;
163
- } else if (Object.prototype.hasOwnProperty.call(incoming, 'contextCompaction')) {
164
- // Admin writes still require same-origin (blocks cross-site form POSTs; same gate as CLAUDE_EXECUTABLE).
165
- if (!isSameOriginBrowserRequest(req, parsedUrl)) {
166
- res.writeHead(403, { 'Content-Type': 'application/json' });
167
- res.end(JSON.stringify({ error: 'Same-origin request required' }));
168
- return;
169
- }
170
162
  }
171
163
  for (const k of Object.keys(incoming)) if (k[0] === '_') delete incoming[k];
172
164
  // IM bridge configs 同理:只能经 admin-only 的 /api/dingtalk/config、/api/im/* 修改,禁止借
@@ -39,6 +39,12 @@ function cleanPatch(patch) {
39
39
  const out = { ...patch };
40
40
  for (const k of Object.keys(out)) if (k[0] === '_') delete out[k];
41
41
  stripSensitive(out); // 含 auth/IM + logDir/claudeConfigDir + prefsByProject(单一来源)
42
+ // contextCompaction is a rule list; a non-array value would otherwise be persisted as-is and
43
+ // break older consumers. Drop malformed values rather than storing them (frontend normalizer
44
+ // already degrades a missing key to the built-in default rule).
45
+ if (Object.prototype.hasOwnProperty.call(out, 'contextCompaction') && !Array.isArray(out.contextCompaction)) {
46
+ delete out.contextCompaction;
47
+ }
42
48
  return out;
43
49
  }
44
50