@chenhw7/dsh-memory 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +26 -2
  2. package/README.zh-CN.md +25 -1
  3. package/cordis.patch.yml +10 -0
  4. package/lib/brand.d.ts +7 -0
  5. package/lib/brand.d.ts.map +1 -1
  6. package/lib/brand.js +7 -0
  7. package/lib/brand.js.map +1 -1
  8. package/lib/client/index.js +826 -0
  9. package/lib/context/conflict.d.ts +59 -0
  10. package/lib/context/conflict.d.ts.map +1 -0
  11. package/lib/context/conflict.js +75 -0
  12. package/lib/context/conflict.js.map +1 -0
  13. package/lib/context/index.d.ts +11 -2
  14. package/lib/context/index.d.ts.map +1 -1
  15. package/lib/context/index.js +36 -9
  16. package/lib/context/index.js.map +1 -1
  17. package/lib/context/policy.d.ts +23 -2
  18. package/lib/context/policy.d.ts.map +1 -1
  19. package/lib/context/policy.js +77 -1
  20. package/lib/context/policy.js.map +1 -1
  21. package/lib/index.d.ts +50 -4
  22. package/lib/index.d.ts.map +1 -1
  23. package/lib/index.js +22 -3
  24. package/lib/index.js.map +1 -1
  25. package/lib/invariant.d.ts.map +1 -1
  26. package/lib/remote/index.d.ts +146 -0
  27. package/lib/remote/index.d.ts.map +1 -0
  28. package/lib/remote/index.js +257 -0
  29. package/lib/remote/index.js.map +1 -0
  30. package/lib/remote/typert.remote-client.d.ts +75 -0
  31. package/lib/remote/typert.remote-client.js +86 -0
  32. package/lib/remote/types.d.ts +9 -0
  33. package/lib/remote/types.d.ts.map +1 -0
  34. package/lib/remote/types.js +9 -0
  35. package/lib/remote/types.js.map +1 -0
  36. package/lib/review/accumulator.d.ts +18 -5
  37. package/lib/review/accumulator.d.ts.map +1 -1
  38. package/lib/review/accumulator.js +52 -14
  39. package/lib/review/accumulator.js.map +1 -1
  40. package/lib/review/dedup.d.ts +79 -0
  41. package/lib/review/dedup.d.ts.map +1 -0
  42. package/lib/review/dedup.js +171 -0
  43. package/lib/review/dedup.js.map +1 -0
  44. package/lib/review/extract.d.ts +28 -8
  45. package/lib/review/extract.d.ts.map +1 -1
  46. package/lib/review/extract.js +161 -23
  47. package/lib/review/extract.js.map +1 -1
  48. package/lib/review/index.d.ts +10 -0
  49. package/lib/review/index.d.ts.map +1 -1
  50. package/lib/review/index.js +55 -11
  51. package/lib/review/index.js.map +1 -1
  52. package/lib/scanner.d.ts +16 -0
  53. package/lib/scanner.d.ts.map +1 -1
  54. package/lib/scanner.js +25 -2
  55. package/lib/scanner.js.map +1 -1
  56. package/lib/store/index.d.ts +49 -0
  57. package/lib/store/index.d.ts.map +1 -1
  58. package/lib/store/index.js +238 -15
  59. package/lib/store/index.js.map +1 -1
  60. package/lib/tool/index.d.ts.map +1 -1
  61. package/lib/tool/index.js +173 -3
  62. package/lib/tool/index.js.map +1 -1
  63. package/lib/types.d.ts +60 -4
  64. package/lib/types.d.ts.map +1 -1
  65. package/package.json +39 -17
@@ -0,0 +1,826 @@
1
+ window.__ModuleLoader__.load({
2
+ id: "@chenhw7/dsh-memory",
3
+ factory: (require) => {
4
+ var module = { exports: {} };
5
+ var exports = module.exports;
6
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
+
8
+ // Map external require calls to the factory's injected require
9
+ "use strict";
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+
28
+ // src/client/index.ts
29
+ var index_exports = {};
30
+ __export(index_exports, {
31
+ apply: () => apply,
32
+ inject: () => inject2
33
+ });
34
+ module.exports = __toCommonJS(index_exports);
35
+
36
+ // src/client/MemoryPluginCard.tsx
37
+ var import_react = require("react");
38
+ var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
39
+
40
+ // src/client/card-styles.ts
41
+ var RULES = `
42
+ /* \u2500\u2500 Card shell (port of PluginCard.module.css) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
43
+ .dsm-c-card {
44
+ list-style: none;
45
+ border: 1px solid var(--dsw-alias-border-l2);
46
+ border-radius: 12px;
47
+ background: var(--dsw-alias-bg-layer-3);
48
+ transition: border-color .16s, background .16s;
49
+ }
50
+ .dsm-c-card:hover {
51
+ border-color: var(--dsw-alias-label-dimmed);
52
+ }
53
+ .dsm-c-card-open {
54
+ background: var(--dsw-alias-bg-layer-2);
55
+ border-color: var(--dsw-alias-label-dimmed);
56
+ }
57
+ .dsm-c-header {
58
+ width: 100%;
59
+ appearance: none;
60
+ border: 0;
61
+ background: none;
62
+ font: inherit;
63
+ color: inherit;
64
+ text-align: left;
65
+ cursor: pointer;
66
+ display: flex;
67
+ align-items: center;
68
+ gap: 12px;
69
+ padding: 14px 16px;
70
+ border-radius: 12px;
71
+ }
72
+ .dsm-c-header:focus-visible {
73
+ outline: 2px solid var(--dsw-alias-brand-primary);
74
+ outline-offset: -2px;
75
+ }
76
+ .dsm-c-head-text {
77
+ flex: 1;
78
+ min-width: 0;
79
+ display: flex;
80
+ flex-direction: column;
81
+ gap: 4px;
82
+ }
83
+ .dsm-c-name {
84
+ font-size: 15px;
85
+ font-weight: 600;
86
+ line-height: 1.4;
87
+ color: var(--dsw-alias-label-primary);
88
+ }
89
+ .dsm-c-description {
90
+ font-size: 13px;
91
+ line-height: 1.5;
92
+ color: var(--dsw-alias-label-tertiary);
93
+ }
94
+ .dsm-c-pending {
95
+ flex: none;
96
+ border-radius: 999px;
97
+ padding: 1px 8px;
98
+ font-size: 11px;
99
+ line-height: 17px;
100
+ font-weight: 500;
101
+ white-space: nowrap;
102
+ background: var(--dsw-alias-bg-module-platform);
103
+ color: var(--dsw-alias-label-secondary);
104
+ }
105
+ .dsm-c-chevron {
106
+ flex: none;
107
+ color: var(--dsw-alias-label-tertiary);
108
+ transition: transform .16s;
109
+ }
110
+ .dsm-c-chevron-open {
111
+ transform: rotate(180deg);
112
+ }
113
+ .dsm-c-body {
114
+ border-top: 1px solid var(--dsw-alias-border-l2);
115
+ margin: 0 16px;
116
+ padding-bottom: 8px;
117
+ }
118
+ .dsm-c-read-only {
119
+ margin: 12px 0 0;
120
+ font-size: 12px;
121
+ line-height: 1.5;
122
+ color: var(--dsw-alias-label-tertiary);
123
+ }
124
+ .dsm-c-footer {
125
+ display: flex;
126
+ align-items: center;
127
+ justify-content: flex-end;
128
+ gap: 8px;
129
+ padding: 12px 0 4px;
130
+ border-top: 1px solid var(--dsw-alias-border-l2);
131
+ }
132
+ .dsm-c-failed {
133
+ flex: 1;
134
+ min-width: 0;
135
+ margin: 0;
136
+ font-size: 12px;
137
+ line-height: 1.5;
138
+ color: var(--dsw-alias-label-error);
139
+ }
140
+ .dsm-c-discard,
141
+ .dsm-c-save {
142
+ appearance: none;
143
+ border: 1px solid transparent;
144
+ border-radius: 8px;
145
+ padding: 5px 14px;
146
+ font: inherit;
147
+ font-size: 13px;
148
+ line-height: 1.5;
149
+ cursor: pointer;
150
+ }
151
+ .dsm-c-discard {
152
+ border-color: var(--dsw-alias-border-l2);
153
+ background: none;
154
+ color: var(--dsw-alias-label-secondary);
155
+ }
156
+ .dsm-c-discard:hover:not(:disabled) {
157
+ color: var(--dsw-alias-label-primary);
158
+ border-color: var(--dsw-alias-label-dimmed);
159
+ }
160
+ .dsm-c-save {
161
+ background: var(--dsw-alias-label-primary);
162
+ color: var(--dsw-alias-bg-layer-3);
163
+ }
164
+ .dsm-c-discard:disabled,
165
+ .dsm-c-save:disabled {
166
+ opacity: 0.4;
167
+ cursor: default;
168
+ }
169
+ .dsm-c-discard:focus-visible,
170
+ .dsm-c-save:focus-visible {
171
+ outline: 2px solid var(--dsw-alias-brand-primary);
172
+ outline-offset: 1px;
173
+ }
174
+
175
+ /* \u2500\u2500 Fields (port of fields.module.css) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
176
+ .dsm-c-field {
177
+ display: flex;
178
+ flex-direction: column;
179
+ gap: 6px;
180
+ padding: 12px 0;
181
+ }
182
+ .dsm-c-field + .dsm-c-field {
183
+ border-top: 1px solid var(--dsw-alias-border-l2);
184
+ }
185
+ .dsm-c-head {
186
+ display: flex;
187
+ align-items: center;
188
+ gap: 8px;
189
+ }
190
+ .dsm-c-label {
191
+ flex: 1;
192
+ min-width: 0;
193
+ font-size: 13px;
194
+ font-weight: 500;
195
+ line-height: 1.5;
196
+ color: var(--dsw-alias-label-primary);
197
+ }
198
+ .dsm-c-badges {
199
+ display: inline-flex;
200
+ align-items: center;
201
+ gap: 8px;
202
+ }
203
+ .dsm-c-badge {
204
+ border-radius: 999px;
205
+ padding: 1px 8px;
206
+ font-size: 11px;
207
+ line-height: 17px;
208
+ white-space: nowrap;
209
+ font-weight: 500;
210
+ background: var(--dsw-alias-bg-module-platform);
211
+ color: var(--dsw-alias-label-secondary);
212
+ }
213
+ .dsm-c-badge-muted {
214
+ border-radius: 999px;
215
+ padding: 1px 8px;
216
+ font-size: 11px;
217
+ line-height: 17px;
218
+ white-space: nowrap;
219
+ color: var(--dsw-alias-label-tertiary);
220
+ }
221
+ .dsm-c-reset {
222
+ border: none;
223
+ background: none;
224
+ padding: 0;
225
+ font: inherit;
226
+ font-size: 12px;
227
+ line-height: 1.5;
228
+ color: var(--dsw-alias-label-secondary);
229
+ cursor: pointer;
230
+ }
231
+ .dsm-c-reset:hover:not(:disabled) {
232
+ color: var(--dsw-alias-label-primary);
233
+ }
234
+ .dsm-c-reset:disabled {
235
+ cursor: default;
236
+ }
237
+
238
+ /* Shared input control look (fields.module.css .input). */
239
+ .dsm-c-input {
240
+ height: 34px;
241
+ padding: 0 12px;
242
+ border: 1px solid var(--dsw-alias-border-l2);
243
+ border-radius: 8px;
244
+ background: var(--dsw-alias-bg-layer-3);
245
+ font: inherit;
246
+ font-size: 13px;
247
+ line-height: 1.5;
248
+ color: var(--dsw-alias-label-primary);
249
+ }
250
+ .dsm-c-input:focus-visible {
251
+ outline: none;
252
+ border-color: var(--dsw-alias-brand-primary);
253
+ }
254
+ .dsm-c-input:disabled {
255
+ color: var(--dsw-alias-label-tertiary);
256
+ cursor: default;
257
+ }
258
+ /* inputInvalid mirrors .input with an error border (composes: input in host). */
259
+ .dsm-c-input-invalid {
260
+ height: 34px;
261
+ padding: 0 12px;
262
+ border: 1px solid var(--dsw-alias-label-error);
263
+ border-radius: 8px;
264
+ background: var(--dsw-alias-bg-layer-3);
265
+ font: inherit;
266
+ font-size: 13px;
267
+ line-height: 1.5;
268
+ color: var(--dsw-alias-label-primary);
269
+ }
270
+ .dsm-c-input-invalid:focus-visible {
271
+ outline: none;
272
+ border-color: var(--dsw-alias-label-error);
273
+ }
274
+ .dsm-c-input-invalid:disabled {
275
+ color: var(--dsw-alias-label-tertiary);
276
+ cursor: default;
277
+ }
278
+
279
+ /* select mirrors .input; native arrow kept via appearance. */
280
+ .dsm-c-select {
281
+ height: 34px;
282
+ padding: 0 28px 0 12px;
283
+ border: 1px solid var(--dsw-alias-border-l2);
284
+ border-radius: 8px;
285
+ background: var(--dsw-alias-bg-layer-3);
286
+ font: inherit;
287
+ font-size: 13px;
288
+ line-height: 1.5;
289
+ color: var(--dsw-alias-label-primary);
290
+ cursor: pointer;
291
+ appearance: none;
292
+ -webkit-appearance: none;
293
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none'%3E%3Cpath d='M3 5l4 4 4-4' stroke='%237a7a7a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
294
+ background-repeat: no-repeat;
295
+ background-position: right 10px center;
296
+ }
297
+ .dsm-c-select:focus-visible {
298
+ outline: none;
299
+ border-color: var(--dsw-alias-brand-primary);
300
+ }
301
+ .dsm-c-select:disabled {
302
+ color: var(--dsw-alias-label-tertiary);
303
+ cursor: default;
304
+ }
305
+
306
+ /* textarea mirrors .input borders, multi-line sizing. */
307
+ .dsm-c-textarea {
308
+ min-height: 80px;
309
+ padding: 8px 12px;
310
+ border: 1px solid var(--dsw-alias-border-l2);
311
+ border-radius: 8px;
312
+ background: var(--dsw-alias-bg-layer-3);
313
+ font: inherit;
314
+ font-size: 13px;
315
+ line-height: 1.5;
316
+ color: var(--dsw-alias-label-primary);
317
+ resize: vertical;
318
+ }
319
+ .dsm-c-textarea:focus-visible {
320
+ outline: none;
321
+ border-color: var(--dsw-alias-brand-primary);
322
+ }
323
+ .dsm-c-textarea:disabled {
324
+ color: var(--dsw-alias-label-tertiary);
325
+ cursor: default;
326
+ }
327
+
328
+ /* A checkbox row: the box and its label sit on the head line so the override
329
+ badge + reset stay right-aligned exactly as the text fields do. */
330
+ .dsm-c-check-row {
331
+ display: flex;
332
+ align-items: center;
333
+ gap: 8px;
334
+ flex: 1;
335
+ min-width: 0;
336
+ }
337
+ .dsm-c-checkbox {
338
+ flex: none;
339
+ width: 16px;
340
+ height: 16px;
341
+ margin: 0;
342
+ accent-color: var(--dsw-alias-brand-primary);
343
+ cursor: pointer;
344
+ }
345
+ .dsm-c-checkbox:disabled {
346
+ cursor: default;
347
+ }
348
+ .dsm-c-check-label {
349
+ font-size: 13px;
350
+ font-weight: 500;
351
+ line-height: 1.5;
352
+ color: var(--dsw-alias-label-primary);
353
+ cursor: pointer;
354
+ }
355
+ .dsm-c-check-label:disabled,
356
+ .dsm-c-checkbox:disabled + .dsm-c-check-label {
357
+ color: var(--dsw-alias-label-tertiary);
358
+ cursor: default;
359
+ }
360
+
361
+ .dsm-c-invalid {
362
+ margin: 0;
363
+ font-size: 12px;
364
+ line-height: 1.5;
365
+ color: var(--dsw-alias-label-error);
366
+ }
367
+ .dsm-c-hint {
368
+ margin: 0;
369
+ font-size: 12px;
370
+ line-height: 1.5;
371
+ color: var(--dsw-alias-label-tertiary);
372
+ }
373
+ `;
374
+ var injected = false;
375
+ function inject() {
376
+ if (injected || typeof document === "undefined") return;
377
+ const style = document.createElement("style");
378
+ style.setAttribute("data-dsh-memory", "plugin-card");
379
+ style.textContent = RULES;
380
+ document.head.appendChild(style);
381
+ injected = true;
382
+ }
383
+ var cls = {
384
+ // Card shell (PluginCard.module.css).
385
+ card: "dsm-c-card",
386
+ cardOpen: "dsm-c-card-open",
387
+ header: "dsm-c-header",
388
+ headText: "dsm-c-head-text",
389
+ name: "dsm-c-name",
390
+ description: "dsm-c-description",
391
+ pending: "dsm-c-pending",
392
+ chevron: "dsm-c-chevron",
393
+ chevronOpen: "dsm-c-chevron-open",
394
+ body: "dsm-c-body",
395
+ readOnly: "dsm-c-read-only",
396
+ footer: "dsm-c-footer",
397
+ failed: "dsm-c-failed",
398
+ discard: "dsm-c-discard",
399
+ save: "dsm-c-save",
400
+ // Fields (fields.module.css).
401
+ field: "dsm-c-field",
402
+ head: "dsm-c-head",
403
+ label: "dsm-c-label",
404
+ badges: "dsm-c-badges",
405
+ badge: "dsm-c-badge",
406
+ reset: "dsm-c-reset",
407
+ input: "dsm-c-input",
408
+ inputInvalid: "dsm-c-input-invalid",
409
+ badgeMuted: "dsm-c-badge-muted",
410
+ select: "dsm-c-select",
411
+ textarea: "dsm-c-textarea",
412
+ checkRow: "dsm-c-check-row",
413
+ checkbox: "dsm-c-checkbox",
414
+ checkLabel: "dsm-c-check-label",
415
+ invalid: "dsm-c-invalid",
416
+ hint: "dsm-c-hint"
417
+ };
418
+ var css = (inject(), cls);
419
+
420
+ // src/client/MemoryPluginCard.tsx
421
+ var import_jsx_runtime = require("react/jsx-runtime");
422
+ var MODES = ["policy-only", "full", "index", "custom", "off"];
423
+ var DEFAULTS = {
424
+ memoryMode: "policy-only",
425
+ reviewEnabled: true,
426
+ reviewCandidateThreshold: 10,
427
+ flushOnCompaction: true,
428
+ flushOnDispose: true,
429
+ memoryCharLimit: 5e3,
430
+ memoryPolicyCustomText: ""
431
+ };
432
+ function isOverridden(snap, field) {
433
+ const user = snap.user;
434
+ if (user === void 0 || user === null || typeof user !== "object") return false;
435
+ return Object.prototype.hasOwnProperty.call(user, field);
436
+ }
437
+ function MemoryPluginCard(props) {
438
+ const snap = props.useMemory((s) => s);
439
+ const t = props.t;
440
+ const [open, setOpen] = (0, import_react.useState)(false);
441
+ const committed = snap.value ?? {};
442
+ const [draft, setDraft] = (0, import_react.useState)({ ...DEFAULTS, ...committed });
443
+ const [saving, setSaving] = (0, import_react.useState)(false);
444
+ const [failed, setFailed] = (0, import_react.useState)(false);
445
+ (0, import_react.useEffect)(() => {
446
+ setDraft({ ...DEFAULTS, ...committed });
447
+ setFailed(false);
448
+ }, [committed]);
449
+ const edit = (field, value) => {
450
+ setFailed(false);
451
+ setDraft((prev) => ({ ...prev, [field]: value }));
452
+ };
453
+ const numericInvalid = (field) => {
454
+ const v = draft[field];
455
+ if (v === void 0 || v === null || v === "") return false;
456
+ const n = Number(v);
457
+ return !Number.isFinite(n) || n < 0;
458
+ };
459
+ const dirty = JSON.stringify(draft) !== JSON.stringify({ ...DEFAULTS, ...committed });
460
+ const invalid = numericInvalid("reviewCandidateThreshold") || numericInvalid("memoryCharLimit");
461
+ const disabled = !snap.writable;
462
+ const blocked = !dirty || invalid || saving;
463
+ if (snap.status !== "ready") return null;
464
+ const save = async () => {
465
+ setSaving(true);
466
+ setFailed(false);
467
+ try {
468
+ const ops = [];
469
+ for (const key of Object.keys(DEFAULTS)) {
470
+ if (draft[key] === committed[key]) continue;
471
+ const value = draft[key];
472
+ ops.push(value === void 0 ? props.unset(key) : props.set(key, value));
473
+ }
474
+ await Promise.all(ops);
475
+ } catch {
476
+ setFailed(true);
477
+ } finally {
478
+ setSaving(false);
479
+ }
480
+ };
481
+ const discard = () => {
482
+ setDraft({ ...DEFAULTS, ...committed });
483
+ setFailed(false);
484
+ };
485
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { className: `${css.card}${open ? ` ${css.cardOpen}` : ""}`, children: [
486
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
487
+ "button",
488
+ {
489
+ type: "button",
490
+ className: css.header,
491
+ "aria-expanded": open,
492
+ "aria-label": `${t(open ? "collapse" : "expand")}: ${t("cardTitle")}`,
493
+ onClick: () => {
494
+ setOpen(!open);
495
+ },
496
+ children: [
497
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: css.headText, children: [
498
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: css.name, children: t("cardTitle") }),
499
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: css.description, children: t("cardDescription") })
500
+ ] }),
501
+ dirty ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: css.pending, children: t("unsaved") }) : null,
502
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconChevronDownOutline14, { className: `${css.chevron}${open ? ` ${css.chevronOpen}` : ""}` })
503
+ ]
504
+ }
505
+ ),
506
+ open ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: css.body, children: [
507
+ !snap.writable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: css.readOnly, role: "status", children: t("readOnly") }) : null,
508
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
509
+ SelectField,
510
+ {
511
+ id: "dsh-memory-mode",
512
+ label: t("memoryMode"),
513
+ hint: t("memoryModeHint"),
514
+ overridden: isOverridden(snap, "memoryMode"),
515
+ overriddenLabel: t("overridden"),
516
+ resetLabel: t("reset"),
517
+ disabled,
518
+ value: draft.memoryMode ?? "policy-only",
519
+ options: MODES.map((m) => ({ value: m, label: m })),
520
+ onChange: (v) => edit("memoryMode", v),
521
+ onReset: () => {
522
+ void props.unset("memoryMode");
523
+ edit("memoryMode", void 0);
524
+ }
525
+ }
526
+ ),
527
+ draft.memoryMode === "custom" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
528
+ TextareaField,
529
+ {
530
+ id: "dsh-memory-custom-policy",
531
+ label: t("customPolicy"),
532
+ hint: t("customPolicyHint"),
533
+ overridden: isOverridden(snap, "memoryPolicyCustomText"),
534
+ overriddenLabel: t("overridden"),
535
+ resetLabel: t("reset"),
536
+ disabled,
537
+ value: draft.memoryPolicyCustomText ?? "",
538
+ onChange: (v) => edit("memoryPolicyCustomText", v),
539
+ onReset: () => {
540
+ void props.unset("memoryPolicyCustomText");
541
+ edit("memoryPolicyCustomText", void 0);
542
+ }
543
+ }
544
+ ) : null,
545
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
546
+ CheckboxField,
547
+ {
548
+ id: "dsh-memory-review-enabled",
549
+ label: t("reviewEnabled"),
550
+ hint: t("reviewEnabledHint"),
551
+ overridden: isOverridden(snap, "reviewEnabled"),
552
+ overriddenLabel: t("overridden"),
553
+ resetLabel: t("reset"),
554
+ disabled,
555
+ checked: Boolean(draft.reviewEnabled ?? true),
556
+ onChange: (v) => edit("reviewEnabled", v),
557
+ onReset: () => {
558
+ void props.unset("reviewEnabled");
559
+ edit("reviewEnabled", void 0);
560
+ }
561
+ }
562
+ ),
563
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
564
+ NumberField,
565
+ {
566
+ id: "dsh-memory-review-threshold",
567
+ label: t("reviewThreshold"),
568
+ hint: t("reviewThresholdHint"),
569
+ overridden: isOverridden(snap, "reviewCandidateThreshold"),
570
+ overriddenLabel: t("overridden"),
571
+ resetLabel: t("reset"),
572
+ invalidLabel: t("invalidNumber"),
573
+ invalid: numericInvalid("reviewCandidateThreshold"),
574
+ disabled,
575
+ value: draft.reviewCandidateThreshold ?? "",
576
+ onChange: (v) => edit("reviewCandidateThreshold", v === "" ? void 0 : Number(v)),
577
+ onReset: () => {
578
+ void props.unset("reviewCandidateThreshold");
579
+ edit("reviewCandidateThreshold", void 0);
580
+ }
581
+ }
582
+ ),
583
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
584
+ CheckboxField,
585
+ {
586
+ id: "dsh-memory-flush-compaction",
587
+ label: t("flushOnCompaction"),
588
+ hint: t("flushOnCompactionHint"),
589
+ overridden: isOverridden(snap, "flushOnCompaction"),
590
+ overriddenLabel: t("overridden"),
591
+ resetLabel: t("reset"),
592
+ disabled,
593
+ checked: Boolean(draft.flushOnCompaction ?? true),
594
+ onChange: (v) => edit("flushOnCompaction", v),
595
+ onReset: () => {
596
+ void props.unset("flushOnCompaction");
597
+ edit("flushOnCompaction", void 0);
598
+ }
599
+ }
600
+ ),
601
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
602
+ CheckboxField,
603
+ {
604
+ id: "dsh-memory-flush-dispose",
605
+ label: t("flushOnDispose"),
606
+ hint: t("flushOnDisposeHint"),
607
+ overridden: isOverridden(snap, "flushOnDispose"),
608
+ overriddenLabel: t("overridden"),
609
+ resetLabel: t("reset"),
610
+ disabled,
611
+ checked: Boolean(draft.flushOnDispose ?? true),
612
+ onChange: (v) => edit("flushOnDispose", v),
613
+ onReset: () => {
614
+ void props.unset("flushOnDispose");
615
+ edit("flushOnDispose", void 0);
616
+ }
617
+ }
618
+ ),
619
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
620
+ NumberField,
621
+ {
622
+ id: "dsh-memory-char-limit",
623
+ label: t("charLimit"),
624
+ hint: t("charLimitHint"),
625
+ overridden: isOverridden(snap, "memoryCharLimit"),
626
+ overriddenLabel: t("overridden"),
627
+ resetLabel: t("reset"),
628
+ invalidLabel: t("invalidNumber"),
629
+ invalid: numericInvalid("memoryCharLimit"),
630
+ disabled,
631
+ value: draft.memoryCharLimit ?? "",
632
+ onChange: (v) => edit("memoryCharLimit", v === "" ? void 0 : Number(v)),
633
+ onReset: () => {
634
+ void props.unset("memoryCharLimit");
635
+ edit("memoryCharLimit", void 0);
636
+ }
637
+ }
638
+ ),
639
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: css.footer, children: [
640
+ failed ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: css.failed, role: "status", children: t("saveFailed") }) : null,
641
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: css.discard, disabled: !dirty || saving, onClick: discard, children: t("discard") }),
642
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: css.save, disabled: blocked, onClick: () => void save(), children: t(saving ? "saving" : "save") })
643
+ ] })
644
+ ] }) : null
645
+ ] });
646
+ }
647
+ function FieldHead(props) {
648
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: css.head, children: [
649
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { className: css.label, htmlFor: props.id, children: props.label }),
650
+ props.overridden ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: css.badges, children: [
651
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: css.badge, children: props.overriddenLabel }),
652
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: css.reset, disabled: props.disabled, onClick: props.onReset, children: props.resetLabel })
653
+ ] }) : null
654
+ ] });
655
+ }
656
+ function SelectField(props) {
657
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: css.field, children: [
658
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldHead, { ...props }),
659
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
660
+ "select",
661
+ {
662
+ id: props.id,
663
+ className: css.select,
664
+ value: props.value,
665
+ disabled: props.disabled,
666
+ onChange: (e) => props.onChange(e.target.value),
667
+ children: props.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: o.value, children: o.label }, o.value))
668
+ }
669
+ ),
670
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: css.hint, children: props.hint })
671
+ ] });
672
+ }
673
+ function NumberField(props) {
674
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: css.field, children: [
675
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldHead, { ...props }),
676
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
677
+ "input",
678
+ {
679
+ id: props.id,
680
+ className: props.invalid ? css.inputInvalid : css.input,
681
+ type: "text",
682
+ inputMode: "numeric",
683
+ ...props.invalid ? { "aria-invalid": true } : {},
684
+ value: String(props.value),
685
+ disabled: props.disabled,
686
+ onChange: (e) => props.onChange(e.target.value)
687
+ }
688
+ ),
689
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: props.invalid ? css.invalid : css.hint, children: props.invalid ? props.invalidLabel : props.hint })
690
+ ] });
691
+ }
692
+ function CheckboxField(props) {
693
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: css.field, children: [
694
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: css.head, children: [
695
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: css.checkRow, children: [
696
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
697
+ "input",
698
+ {
699
+ id: props.id,
700
+ type: "checkbox",
701
+ className: css.checkbox,
702
+ checked: props.checked,
703
+ disabled: props.disabled,
704
+ onChange: (e) => props.onChange(e.target.checked)
705
+ }
706
+ ),
707
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { className: css.checkLabel, htmlFor: props.id, children: props.label })
708
+ ] }),
709
+ props.overridden ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: css.badges, children: [
710
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: css.badge, children: props.overriddenLabel }),
711
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: css.reset, disabled: props.disabled, onClick: props.onReset, children: props.resetLabel })
712
+ ] }) : null
713
+ ] }),
714
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: css.hint, children: props.hint })
715
+ ] });
716
+ }
717
+ function TextareaField(props) {
718
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: css.field, children: [
719
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldHead, { ...props }),
720
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
721
+ "textarea",
722
+ {
723
+ id: props.id,
724
+ className: css.textarea,
725
+ value: props.value,
726
+ disabled: props.disabled,
727
+ rows: 4,
728
+ onChange: (e) => props.onChange(e.target.value)
729
+ }
730
+ ),
731
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: css.hint, children: props.hint })
732
+ ] });
733
+ }
734
+
735
+ // src/client/locales.ts
736
+ var en = {
737
+ // Card chrome (mirrors the PluginCard shell's keys).
738
+ cardTitle: "Memory",
739
+ cardDescription: "Long-term memory: how recalled memory reaches the prompt and when it is extracted.",
740
+ expand: "Show settings",
741
+ collapse: "Hide settings",
742
+ unsaved: "Unsaved",
743
+ readOnly: "This deployment stores settings read-only.",
744
+ overridden: "Overridden",
745
+ reset: "Reset to default",
746
+ save: "Save",
747
+ saving: "Saving\u2026",
748
+ discard: "Discard",
749
+ saveFailed: "The deployment did not accept these values; they were left for you to correct.",
750
+ invalidNumber: "Enter a number, or leave blank to use the default.",
751
+ loading: "Loading\u2026",
752
+ unavailable: "Memory settings are not available on this connection.",
753
+ // Fields.
754
+ memoryMode: "Memory mode",
755
+ memoryModeHint: "How recalled memory is rendered into the system prompt.",
756
+ customPolicy: "Custom policy text",
757
+ customPolicyHint: 'Used only when memory mode is "custom".',
758
+ reviewEnabled: "Automatic review extraction",
759
+ reviewEnabledHint: "Extract durable facts from the conversation automatically.",
760
+ reviewThreshold: "Review candidate threshold",
761
+ reviewThresholdHint: "How many candidate turns accumulate before a review pass runs.",
762
+ flushOnCompaction: "Flush on compaction",
763
+ flushOnCompactionHint: "Write pending memory when the context is compacted.",
764
+ flushOnDispose: "Flush on dispose",
765
+ flushOnDisposeHint: "Write pending memory when the session ends.",
766
+ charLimit: "Memory character limit",
767
+ charLimitHint: "Character budget for the frozen memory content snapshot."
768
+ };
769
+ var zh = {
770
+ cardTitle: "\u8BB0\u5FC6",
771
+ cardDescription: "\u957F\u671F\u8BB0\u5FC6\uFF1A\u53EC\u56DE\u7684\u8BB0\u5FC6\u5982\u4F55\u8FDB\u5165\u63D0\u793A\u8BCD\u3001\u4EE5\u53CA\u4F55\u65F6\u81EA\u52A8\u63D0\u53D6\u3002",
772
+ expand: "\u5C55\u5F00\u8BBE\u7F6E",
773
+ collapse: "\u6536\u8D77\u8BBE\u7F6E",
774
+ unsaved: "\u672A\u4FDD\u5B58",
775
+ readOnly: "\u672C\u90E8\u7F72\u7684\u8BBE\u7F6E\u4E3A\u53EA\u8BFB\u3002",
776
+ overridden: "\u5DF2\u8986\u76D6",
777
+ reset: "\u6062\u590D\u9ED8\u8BA4",
778
+ save: "\u4FDD\u5B58",
779
+ saving: "\u4FDD\u5B58\u4E2D\u2026",
780
+ discard: "\u653E\u5F03\u4FEE\u6539",
781
+ saveFailed: "\u672C\u90E8\u7F72\u6CA1\u6709\u63A5\u53D7\u8FD9\u4E9B\u503C\uFF0C\u5DF2\u4FDD\u7559\u4F9B\u4F60\u4FEE\u6539\u3002",
782
+ invalidNumber: "\u8BF7\u586B\u6570\u5B57\uFF1B\u7559\u7A7A\u8868\u793A\u4F7F\u7528\u9ED8\u8BA4\u503C\u3002",
783
+ loading: "\u6B63\u5728\u52A0\u8F7D\u2026",
784
+ unavailable: "\u5F53\u524D\u8FDE\u63A5\u4E0D\u53EF\u7528\u8BB0\u5FC6\u8BBE\u7F6E\u3002",
785
+ memoryMode: "\u8BB0\u5FC6\u6A21\u5F0F",
786
+ memoryModeHint: "\u53EC\u56DE\u7684\u8BB0\u5FC6\u5982\u4F55\u6E32\u67D3\u8FDB\u7CFB\u7EDF\u63D0\u793A\u8BCD\u3002",
787
+ customPolicy: "\u81EA\u5B9A\u4E49\u7B56\u7565\u6587\u672C",
788
+ customPolicyHint: '\u4EC5\u5728\u8BB0\u5FC6\u6A21\u5F0F\u4E3A "custom" \u65F6\u4F7F\u7528\u3002',
789
+ reviewEnabled: "\u81EA\u52A8\u8BC4\u5BA1\u63D0\u53D6",
790
+ reviewEnabledHint: "\u81EA\u52A8\u4ECE\u5BF9\u8BDD\u4E2D\u63D0\u53D6\u53EF\u6301\u4E45\u7684\u4E8B\u5B9E\u3002",
791
+ reviewThreshold: "\u8BC4\u5BA1\u5019\u9009\u9608\u503C",
792
+ reviewThresholdHint: "\u7D2F\u79EF\u591A\u5C11\u5019\u9009\u8F6E\u6B21\u540E\u8FD0\u884C\u4E00\u6B21\u8BC4\u5BA1\u3002",
793
+ flushOnCompaction: "\u538B\u7F29\u65F6\u51B2\u5237",
794
+ flushOnCompactionHint: "\u4E0A\u4E0B\u6587\u88AB\u538B\u7F29\u65F6\u5199\u5165\u5F85\u5199\u8BB0\u5FC6\u3002",
795
+ flushOnDispose: "\u4F1A\u8BDD\u7ED3\u675F\u65F6\u51B2\u5237",
796
+ flushOnDisposeHint: "\u4F1A\u8BDD\u7ED3\u675F\u65F6\u5199\u5165\u5F85\u5199\u8BB0\u5FC6\u3002",
797
+ charLimit: "\u8BB0\u5FC6\u5B57\u7B26\u4E0A\u9650",
798
+ charLimitHint: "\u51BB\u7ED3\u8BB0\u5FC6\u5185\u5BB9\u5FEB\u7167\u7684\u5B57\u7B26\u9884\u7B97\u3002"
799
+ };
800
+
801
+ // src/client/index.ts
802
+ var inject2 = ["slots", "locale", "settingsScope"];
803
+ var NS = "settings.memory";
804
+ var MEMORY_NS = "memory";
805
+ function apply(ctx) {
806
+ ctx.effect(() => ctx.locale.register(NS, { zh, en }), "dsh-memory: locale dictionaries");
807
+ const scope = ctx.settingsScope.bind({ namespace: MEMORY_NS });
808
+ const cardInjected = () => ({
809
+ hooks: { memory: scope },
810
+ set: (field, value) => scope.set(field, value),
811
+ unset: (field) => scope.unset(field)
812
+ });
813
+ ctx.slots.inject("settings.plugin.item", function* () {
814
+ yield ctx.slots.register({
815
+ name: "settings.plugin.item",
816
+ key: "memory",
817
+ locale: NS,
818
+ inject: cardInjected
819
+ }, MemoryPluginCard);
820
+ });
821
+ }
822
+
823
+
824
+ return module.exports;
825
+ }
826
+ });