dsh-cross-memory 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +247 -2
- package/cordis.patch.yml +27 -0
- package/docs/DETAIL.md +13 -0
- package/docs/DETAIL.zh.md +17 -0
- package/icon.svg +1 -0
- package/lib/backfill.js +273 -0
- package/lib/citations.js +305 -0
- package/lib/client.js +1550 -0
- package/lib/config.js +736 -0
- package/lib/consolidate.js +1119 -0
- package/lib/extract.js +570 -0
- package/lib/gate.js +137 -0
- package/lib/git-origin.js +224 -0
- package/lib/index.js +4475 -0
- package/lib/log.js +260 -0
- package/lib/loops.js +186 -0
- package/lib/notices.js +195 -0
- package/lib/notify.js +33 -0
- package/lib/persona.js +112 -0
- package/lib/query.js +93 -0
- package/lib/raw-recall.js +286 -0
- package/lib/reflection.js +291 -0
- package/lib/remote.js +455 -0
- package/lib/render.js +678 -0
- package/lib/retention.js +64 -0
- package/lib/schedule.js +245 -0
- package/lib/search.js +1068 -0
- package/lib/skills.js +220 -0
- package/lib/state.js +701 -0
- package/lib/storage.js +1424 -0
- package/lib/sync-runtime.js +268 -0
- package/lib/sync.js +620 -0
- package/lib/test/activity.test.js +74 -0
- package/lib/test/archive.test.js +182 -0
- package/lib/test/backfill.test.js +144 -0
- package/lib/test/citations.test.js +91 -0
- package/lib/test/client-wiring.test.js +134 -0
- package/lib/test/consolidate-job.test.js +95 -0
- package/lib/test/consolidate.test.js +430 -0
- package/lib/test/consolidation-selection.test.js +152 -0
- package/lib/test/dedupe-keys.test.js +230 -0
- package/lib/test/delta.test.js +93 -0
- package/lib/test/derived.test.js +110 -0
- package/lib/test/disputes-panel.test.js +314 -0
- package/lib/test/eval.test.js +171 -0
- package/lib/test/expand.test.js +164 -0
- package/lib/test/extract.test.js +1020 -0
- package/lib/test/git-origin.test.js +189 -0
- package/lib/test/injection.test.js +440 -0
- package/lib/test/kind-filter.test.js +49 -0
- package/lib/test/legacy-state.test.js +69 -0
- package/lib/test/log.test.js +156 -0
- package/lib/test/loops.test.js +86 -0
- package/lib/test/memory.test.js +855 -0
- package/lib/test/notices.test.js +140 -0
- package/lib/test/persona.test.js +73 -0
- package/lib/test/prefilter.test.js +73 -0
- package/lib/test/preset.test.js +77 -0
- package/lib/test/raw-recall.test.js +186 -0
- package/lib/test/recall.test.js +433 -0
- package/lib/test/reflection.test.js +64 -0
- package/lib/test/remote.test.js +227 -0
- package/lib/test/retention.test.js +117 -0
- package/lib/test/retrieval.test.js +142 -0
- package/lib/test/rotation.test.js +228 -0
- package/lib/test/schedule.test.js +112 -0
- package/lib/test/settings-card.test.js +58 -0
- package/lib/test/skills.test.js +129 -0
- package/lib/test/state.test.js +212 -0
- package/lib/test/subagent-contract.test.js +139 -0
- package/lib/test/sweep.test.js +159 -0
- package/lib/test/sync.test.js +314 -0
- package/lib/test/time.test.js +171 -0
- package/lib/time.js +303 -0
- package/lib/tool.js +330 -0
- package/lib/types/backfill.d.ts +96 -0
- package/lib/types/citations.d.ts +105 -0
- package/lib/types/config.d.ts +811 -0
- package/lib/types/consolidate.d.ts +742 -0
- package/lib/types/extract.d.ts +352 -0
- package/lib/types/gate.d.ts +83 -0
- package/lib/types/git-origin.d.ts +23 -0
- package/lib/types/index.d.ts +1316 -0
- package/lib/types/log.d.ts +144 -0
- package/lib/types/loops.d.ts +82 -0
- package/lib/types/notices.d.ts +117 -0
- package/lib/types/notify.d.ts +12 -0
- package/lib/types/persona.d.ts +43 -0
- package/lib/types/query.d.ts +45 -0
- package/lib/types/raw-recall.d.ts +84 -0
- package/lib/types/reflection.d.ts +122 -0
- package/lib/types/remote.d.ts +233 -0
- package/lib/types/render.d.ts +286 -0
- package/lib/types/retention.d.ts +66 -0
- package/lib/types/schedule.d.ts +116 -0
- package/lib/types/search.d.ts +583 -0
- package/lib/types/skills.d.ts +71 -0
- package/lib/types/state.d.ts +294 -0
- package/lib/types/storage.d.ts +458 -0
- package/lib/types/sync-runtime.d.ts +103 -0
- package/lib/types/sync.d.ts +222 -0
- package/lib/types/test/activity.test.d.ts +1 -0
- package/lib/types/test/archive.test.d.ts +1 -0
- package/lib/types/test/backfill.test.d.ts +1 -0
- package/lib/types/test/citations.test.d.ts +1 -0
- package/lib/types/test/client-wiring.test.d.ts +1 -0
- package/lib/types/test/consolidate-job.test.d.ts +1 -0
- package/lib/types/test/consolidate.test.d.ts +1 -0
- package/lib/types/test/consolidation-selection.test.d.ts +1 -0
- package/lib/types/test/dedupe-keys.test.d.ts +1 -0
- package/lib/types/test/delta.test.d.ts +1 -0
- package/lib/types/test/derived.test.d.ts +1 -0
- package/lib/types/test/disputes-panel.test.d.ts +1 -0
- package/lib/types/test/eval.test.d.ts +1 -0
- package/lib/types/test/expand.test.d.ts +1 -0
- package/lib/types/test/extract.test.d.ts +1 -0
- package/lib/types/test/git-origin.test.d.ts +1 -0
- package/lib/types/test/injection.test.d.ts +1 -0
- package/lib/types/test/kind-filter.test.d.ts +1 -0
- package/lib/types/test/legacy-state.test.d.ts +1 -0
- package/lib/types/test/log.test.d.ts +1 -0
- package/lib/types/test/loops.test.d.ts +1 -0
- package/lib/types/test/memory.test.d.ts +1 -0
- package/lib/types/test/notices.test.d.ts +1 -0
- package/lib/types/test/persona.test.d.ts +1 -0
- package/lib/types/test/prefilter.test.d.ts +1 -0
- package/lib/types/test/preset.test.d.ts +1 -0
- package/lib/types/test/raw-recall.test.d.ts +1 -0
- package/lib/types/test/recall.test.d.ts +1 -0
- package/lib/types/test/reflection.test.d.ts +1 -0
- package/lib/types/test/remote.test.d.ts +1 -0
- package/lib/types/test/retention.test.d.ts +1 -0
- package/lib/types/test/retrieval.test.d.ts +1 -0
- package/lib/types/test/rotation.test.d.ts +1 -0
- package/lib/types/test/schedule.test.d.ts +1 -0
- package/lib/types/test/settings-card.test.d.ts +1 -0
- package/lib/types/test/skills.test.d.ts +1 -0
- package/lib/types/test/state.test.d.ts +1 -0
- package/lib/types/test/subagent-contract.test.d.ts +1 -0
- package/lib/types/test/sweep.test.d.ts +1 -0
- package/lib/types/test/sync.test.d.ts +1 -0
- package/lib/types/test/time.test.d.ts +1 -0
- package/lib/types/time.d.ts +67 -0
- package/lib/types/tool.d.ts +9 -0
- package/lib/types/types.d.ts +374 -0
- package/lib/types/workspace.d.ts +20 -0
- package/lib/types.js +47 -0
- package/lib/workspace.js +65 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +126 -4
|
@@ -0,0 +1,811 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for `dsh-cross-memory`.
|
|
3
|
+
*
|
|
4
|
+
* One row config, two kinds of field, deliberately separated:
|
|
5
|
+
*
|
|
6
|
+
* - **Deployment** (`dshHome`, `memoriesDir`, `projectRootMarkers`, `logFile`):
|
|
7
|
+
* where the store lives and how a workspace root is identified. Composition
|
|
8
|
+
* facts; changing one means remounting the row.
|
|
9
|
+
* - **Tunables**: every behavioural knob, declared in {@link Config} with
|
|
10
|
+
* `.volatile()`. That marker is what makes a field live — the Loader hands it
|
|
11
|
+
* to `apply` as a reference rather than a value, the settings domain projects
|
|
12
|
+
* it into the browser, and a write from the Memories page updates the
|
|
13
|
+
* reference in place (announced as `loader/volatile-update`), so a knob takes
|
|
14
|
+
* effect without a restart or a reload. {@link MemoriesSettings} is the same
|
|
15
|
+
* field list as plain data, which is what the runtime reads.
|
|
16
|
+
*
|
|
17
|
+
* @module dsh-cross-memory/config
|
|
18
|
+
*/
|
|
19
|
+
import z from '@deepseek-ai/schemastery';
|
|
20
|
+
import { type Volatile } from '@deepseek-ai/cosmokit';
|
|
21
|
+
/**
|
|
22
|
+
* Profile entry id owning this plugin, and therefore the key its tunables are
|
|
23
|
+
* addressed by: the Memories page and the Plugins-page configuration card both
|
|
24
|
+
* ask for this form as `ctx.configForms.get('memories')`, and a composition row
|
|
25
|
+
* in `cordis.patch.yml` overrides it under the same id.
|
|
26
|
+
*/
|
|
27
|
+
export declare const ENTRY_ID = "memories";
|
|
28
|
+
/** Default child-name markers that identify a workspace root. */
|
|
29
|
+
export declare const DEFAULT_PROJECT_ROOT_MARKERS: readonly ['.git'];
|
|
30
|
+
/** Default background sync interval, in minutes; used when no clock times are set. */
|
|
31
|
+
export declare const DEFAULT_SYNC_INTERVAL_MINUTES = 10;
|
|
32
|
+
/** Default clock times: just after DeepSeek off-peak pricing starts (12:00 and 18:00 local). */
|
|
33
|
+
export declare const DEFAULT_SYNC_CLOCK = "12:05,18:05";
|
|
34
|
+
/** Default debounce before a burst of memory writes becomes one commit, in seconds. */
|
|
35
|
+
export declare const DEFAULT_SYNC_DEBOUNCE_SECONDS = 2;
|
|
36
|
+
/** Default byte budget for the injected memory summary. */
|
|
37
|
+
export declare const DEFAULT_MAX_SUMMARY_BYTES = 4096;
|
|
38
|
+
/** Default cap on entries listed in the injected summary per scope. */
|
|
39
|
+
export declare const DEFAULT_MAX_SUMMARY_ENTRIES = 12;
|
|
40
|
+
/**
|
|
41
|
+
* Whether a conversation is told about memories written after its summary.
|
|
42
|
+
*
|
|
43
|
+
* The summary is a snapshot from the first step of the conversation, so a
|
|
44
|
+
* memory extracted or consolidated ten turns later would otherwise stay
|
|
45
|
+
* invisible until the model thought to search for it. The delta block is
|
|
46
|
+
* bounded (two per conversation, 800 bytes each) and only names entries whose
|
|
47
|
+
* `updated` stamp is newer than the last injection, so it costs one short
|
|
48
|
+
* paragraph rather than a second summary.
|
|
49
|
+
*/
|
|
50
|
+
export declare const DEFAULT_INJECT_DELTA = true;
|
|
51
|
+
/**
|
|
52
|
+
* How many additional memories one conversation lists by title only.
|
|
53
|
+
*
|
|
54
|
+
* The summary can only name a dozen entries and reserves at most a third of its
|
|
55
|
+
* slots for never-surfaced material; measured on a real store at baseline that
|
|
56
|
+
* left 58.6% of live entries never injected or read. Sixteen titles cost about
|
|
57
|
+
* 1.6 KB and are enough to make the whole store discoverable over a couple of
|
|
58
|
+
* dozen sessions: each conversation rotates through the entries the summary did
|
|
59
|
+
* not have room for, oldest-unseen first. The global scope takes three quarters
|
|
60
|
+
* of the block, so a global library of 600 entries moves about 12 a session.
|
|
61
|
+
* 0 disables the rotation block.
|
|
62
|
+
*/
|
|
63
|
+
export declare const DEFAULT_ROTATION_ENTRIES = 16;
|
|
64
|
+
/**
|
|
65
|
+
* User turns between rotation blocks inside one long conversation.
|
|
66
|
+
*
|
|
67
|
+
* Once per conversation is not enough for a session that runs for hours: the
|
|
68
|
+
* store keeps growing and the model keeps needing names it has not seen yet.
|
|
69
|
+
* Re-arming the block every this many USER turns keeps the cost bounded (one
|
|
70
|
+
* ~1.6 KB block per span) and lets coverage accumulate within a single long
|
|
71
|
+
* session. 0 keeps the old once-per-conversation behaviour.
|
|
72
|
+
*/
|
|
73
|
+
export declare const DEFAULT_ROTATION_EVERY_TURNS = 8;
|
|
74
|
+
/** Byte budget for the title-only rotation block. */
|
|
75
|
+
export declare const DEFAULT_ROTATION_MAX_BYTES = 1600;
|
|
76
|
+
/**
|
|
77
|
+
* Default cap on the GLOBAL section's bullets, below {@link DEFAULT_MAX_SUMMARY_ENTRIES}.
|
|
78
|
+
*
|
|
79
|
+
* The two scopes share one byte budget and the global section renders first, so
|
|
80
|
+
* an uncapped global scope absorbs whatever the project scope leaves over.
|
|
81
|
+
* Measured on a real store: a two-memory project session spent 87% of its budget
|
|
82
|
+
* on global entries, and in every session the same six were unrelated to the
|
|
83
|
+
* workspace (a plugin's logger threshold, a sidebar adapter, a model catalog).
|
|
84
|
+
* Four keeps the portable half visible without letting it bury the scope that is
|
|
85
|
+
* actually about this conversation.
|
|
86
|
+
*/
|
|
87
|
+
export declare const DEFAULT_GLOBAL_SUMMARY_ENTRIES = 4;
|
|
88
|
+
/**
|
|
89
|
+
* Default byte budget for the global section alone, inside {@link DEFAULT_MAX_SUMMARY_BYTES}.
|
|
90
|
+
*
|
|
91
|
+
* A count cap is not enough. Chinese entries cost roughly three bytes per
|
|
92
|
+
* character, so four of them fill about 2.6 KB of a 4 KB block — measured on a
|
|
93
|
+
* real store the global half still took 45–81% of every session after the count
|
|
94
|
+
* cap was added. Reserving bytes is what actually leaves room for the scope that
|
|
95
|
+
* is about this conversation.
|
|
96
|
+
*
|
|
97
|
+
* 1200 is about a third of the content budget: the block's frame (intro and
|
|
98
|
+
* guidance) costs ~700 bytes of the 4096, so the two scopes divide ~3400, and a
|
|
99
|
+
* third to the half that every session shares leaves two thirds to the half that
|
|
100
|
+
* is actually about this workspace.
|
|
101
|
+
*/
|
|
102
|
+
export declare const DEFAULT_GLOBAL_SUMMARY_BYTES = 1200;
|
|
103
|
+
/**
|
|
104
|
+
* Default number of those entries reserved for memories never listed before.
|
|
105
|
+
*
|
|
106
|
+
* Three, because the reservation is a queue that drains: once an entry has been
|
|
107
|
+
* listed it leaves the pool, and unused slots fall back to the ranking, so the
|
|
108
|
+
* steady-state cost is one slot per newly written memory. It only ever costs
|
|
109
|
+
* more than that while there is a backlog of never-listed memories — which is
|
|
110
|
+
* exactly when showing them matters. Measured on a real store, two slots pushed
|
|
111
|
+
* the correction of an already-listed memory to the *next* session and three
|
|
112
|
+
* showed both in the first one. `0` restores pure ranking, which on a saturated
|
|
113
|
+
* scope is a fixed point that never shows anything new.
|
|
114
|
+
*/
|
|
115
|
+
export declare const DEFAULT_SUMMARY_FRESH_SLOTS = 3;
|
|
116
|
+
/**
|
|
117
|
+
* Default cap on stored entries per scope before the least recently used are evicted.
|
|
118
|
+
*
|
|
119
|
+
* 1000 rather than 200 as of 2026-10-24, after the recall path got an inverted
|
|
120
|
+
* index (`prefilterEntries`): measured on this machine, 1000 entries cost 63 ms
|
|
121
|
+
* per turn scanning everything and 25 ms through the index, and the index falls
|
|
122
|
+
* back to a full scan when it would leave too few candidates to be trusted.
|
|
123
|
+
* `scripts/recall-bench.mjs` is the probe that decided it; re-run it before
|
|
124
|
+
* raising this again.
|
|
125
|
+
*/
|
|
126
|
+
export declare const DEFAULT_MAX_ENTRIES_PER_SCOPE = 1000;
|
|
127
|
+
/** Default hours between periodic maintenance sweeps; `0` disables the sweep. */
|
|
128
|
+
export declare const DEFAULT_SWEEP_INTERVAL_HOURS = 12;
|
|
129
|
+
/** Default days an unused memory survives before it is archived; `0` disables archival. */
|
|
130
|
+
export declare const DEFAULT_MAX_UNUSED_DAYS = 90;
|
|
131
|
+
/**
|
|
132
|
+
* Default days a `snapshot` memory survives before it is archived; `0` disables.
|
|
133
|
+
*
|
|
134
|
+
* A reading taken at one moment is wrong from the day after it was taken, and
|
|
135
|
+
* reading it does not make it right, so it cannot be judged by the unused clock
|
|
136
|
+
* that a convention is judged by. Sixty days is long enough to be useful as
|
|
137
|
+
* history and short enough that a stale number stops being quoted.
|
|
138
|
+
*/
|
|
139
|
+
export declare const DEFAULT_SNAPSHOT_MAX_AGE_DAYS = 60;
|
|
140
|
+
/** Default share of title/body tokens two memories must have in common to be merged. */
|
|
141
|
+
export declare const DEFAULT_DEDUPE_SIMILARITY = 0.7;
|
|
142
|
+
/** Default recall mode: how much of a conversation pays for cross-session memory. */
|
|
143
|
+
export declare const DEFAULT_RECALL_MODE = "on-demand";
|
|
144
|
+
/**
|
|
145
|
+
* Default minimum relevance a recall delta must reach.
|
|
146
|
+
*
|
|
147
|
+
* 20 was the old value and it silently disabled Chinese recall: a Chinese
|
|
148
|
+
* paraphrase that shares two bigrams with a title scores around 9-12, so nothing
|
|
149
|
+
* ever cleared it. The floor is now a strictness knob, and the PRECISION lives in
|
|
150
|
+
* `recallMinTerms` — the structural evidence gate, which a score threshold cannot
|
|
151
|
+
* replace. 9 is just above one shared bigram in a title (8) so that a single
|
|
152
|
+
* common word is never sufficient on its own.
|
|
153
|
+
*/
|
|
154
|
+
export declare const DEFAULT_RECALL_MIN_SCORE = 9;
|
|
155
|
+
/** Default cap on recall deltas injected into one conversation. */
|
|
156
|
+
export declare const DEFAULT_RECALL_MAX_PER_CONVERSATION = 4;
|
|
157
|
+
/**
|
|
158
|
+
* Default byte budget for one recall delta block.
|
|
159
|
+
*
|
|
160
|
+
* Sized for the several short entries a single turn can legitimately match, not
|
|
161
|
+
* for one: the frame and the preamble cost roughly 250 bytes, and a one-line
|
|
162
|
+
* entry costs about 90. At 800 a two-entry block would not fit, which is why
|
|
163
|
+
* this is not 400 as it was when a delta could only ever hold one memory.
|
|
164
|
+
*/
|
|
165
|
+
export declare const DEFAULT_RECALL_MAX_BYTES = 1200;
|
|
166
|
+
/** Default minimum length of a user turn worth a recall decision. */
|
|
167
|
+
export declare const DEFAULT_RECALL_MIN_QUERY_CHARS = 2;
|
|
168
|
+
/**
|
|
169
|
+
* Whether a recall block may also carry original conversation excerpts.
|
|
170
|
+
*
|
|
171
|
+
* Off by default: this injects prose from *other* sessions, which is a privacy
|
|
172
|
+
* step beyond recalling a memory summary, so it is opt-in.
|
|
173
|
+
*/
|
|
174
|
+
export declare const DEFAULT_RAW_RECALL = false;
|
|
175
|
+
/** Byte budget for the raw excerpt half of one recall block. */
|
|
176
|
+
export declare const DEFAULT_RAW_RECALL_BYTES = 2400;
|
|
177
|
+
/** Most raw excerpts one recall block may carry. */
|
|
178
|
+
export declare const DEFAULT_RAW_RECALL_EXCERPTS = 3;
|
|
179
|
+
/**
|
|
180
|
+
* Default number of distinct strong-field terms a recall needs.
|
|
181
|
+
*
|
|
182
|
+
* Two is what makes a paraphrased question reachable without letting a shared
|
|
183
|
+
* common word in: "这个插件的日志在哪里" shares 插件 and 日志 with a memory titled
|
|
184
|
+
* "插件日志的查看方式" (two terms, credited), while "该插件是否有日志" shares only
|
|
185
|
+
* 插件 with a title about plugin registration order (one term, not credited).
|
|
186
|
+
*/
|
|
187
|
+
export declare const DEFAULT_RECALL_MIN_TERMS = 2;
|
|
188
|
+
/**
|
|
189
|
+
* Every valid recall mode.
|
|
190
|
+
*
|
|
191
|
+
* `once` is the original behaviour (one bounded summary per conversation, every
|
|
192
|
+
* later recall through the tool); `on-demand` additionally injects a small delta
|
|
193
|
+
* when the current turn clearly matches a stored memory; `off` leaves only the
|
|
194
|
+
* tool. The mode decides what a conversation pays for, so it is a user knob.
|
|
195
|
+
*/
|
|
196
|
+
export declare const RECALL_MODES: readonly ['once', 'on-demand', 'off'];
|
|
197
|
+
/** How much cross-session memory one conversation pays for. */
|
|
198
|
+
export type RecallMode = (typeof RECALL_MODES)[number];
|
|
199
|
+
/** Narrow an unknown value to a recall mode, defaulting to `on-demand`. */
|
|
200
|
+
export declare function toRecallMode(value: unknown): RecallMode;
|
|
201
|
+
/** Default idle delay before a finished session is mined for memories. */
|
|
202
|
+
export declare const DEFAULT_AUTO_EXTRACT_IDLE_MS = 300000;
|
|
203
|
+
/** Default number of surface messages handed to the extractor. */
|
|
204
|
+
export declare const DEFAULT_EXTRACT_WINDOW_MESSAGES = 60;
|
|
205
|
+
/** Default character budget for the extraction transcript. */
|
|
206
|
+
export declare const DEFAULT_EXTRACT_MAX_INPUT_CHARS = 48000;
|
|
207
|
+
/**
|
|
208
|
+
* Default minutes between periodic extraction checks; `0` disables them.
|
|
209
|
+
*
|
|
210
|
+
* A settle-only pass mines a session once, after it has been quiet for the whole
|
|
211
|
+
* quiet window, and reads only the newest slice of it — so a long working session
|
|
212
|
+
* loses everything before that slice for good, because the watermark moves past
|
|
213
|
+
* it. A periodic check mines in slices as the session runs, which is also why the
|
|
214
|
+
* window above is sized for one interval rather than for a whole conversation.
|
|
215
|
+
*/
|
|
216
|
+
export declare const DEFAULT_EXTRACT_INTERVAL_MINUTES = 30;
|
|
217
|
+
/**
|
|
218
|
+
* Default output-token cap for one extraction call.
|
|
219
|
+
*
|
|
220
|
+
* Raised from 2048 to 4096 on 2026-09-23: asked for up to five memories with
|
|
221
|
+
* tags, keys, `appliesTo` and a summary paragraph in Chinese, a rich reply runs
|
|
222
|
+
* past 2048 tokens, and the first real `/memories mine` in the field came back
|
|
223
|
+
* cut in half (`max-tokens`).
|
|
224
|
+
*
|
|
225
|
+
* Raised again to 8192 on 2026-09-24, because the measured cause was not reply
|
|
226
|
+
* length. A background extraction call inherits the session's route, reasoning
|
|
227
|
+
* level included, and a thinking model bills its reasoning against this same
|
|
228
|
+
* ceiling — so the cap can be spent before the first visible token. The store's
|
|
229
|
+
* own log recorded five calls that came back pinned to the cap with nothing
|
|
230
|
+
* usable (`[5766 in / 4096 out]` … `[24490 in / 4096 out]`), four of them on
|
|
231
|
+
* `deepseek-flash` at `reasoningEffort: high` and one on `gpt-6-astra`; raising
|
|
232
|
+
* the ceiling without the `memories`-first reply order would only have moved the
|
|
233
|
+
* cliff. The cap is still a ceiling rather than a spend, so replies that finish
|
|
234
|
+
* early cost exactly as much as before.
|
|
235
|
+
*/
|
|
236
|
+
export declare const DEFAULT_EXTRACT_MAX_OUTPUT_TOKENS = 8192;
|
|
237
|
+
/** Default timeout for one extraction call. */
|
|
238
|
+
export declare const DEFAULT_EXTRACT_TIMEOUT_MS = 120000;
|
|
239
|
+
/** Default max drafts one extraction may produce. */
|
|
240
|
+
export declare const DEFAULT_EXTRACT_MAX_MEMORIES = 5;
|
|
241
|
+
/** Default idle hours a session must accumulate before it is mined. */
|
|
242
|
+
export declare const DEFAULT_MIN_IDLE_HOURS = 6;
|
|
243
|
+
/** Default age limit: sessions idle longer than this are never mined. */
|
|
244
|
+
export declare const DEFAULT_MAX_AGE_DAYS = 10;
|
|
245
|
+
/** Default cap on sessions mined per pass. */
|
|
246
|
+
export declare const DEFAULT_MAX_SESSIONS_PER_PASS = 2;
|
|
247
|
+
/** Default hours between consolidation passes. */
|
|
248
|
+
export declare const DEFAULT_CONSOLIDATE_COOLDOWN_HOURS = 6;
|
|
249
|
+
/**
|
|
250
|
+
* Default hours a consolidation proposal waits for a decision before a new pass
|
|
251
|
+
* may replace it.
|
|
252
|
+
*
|
|
253
|
+
* A proposal is a question, and questions go stale: entries keep being written
|
|
254
|
+
* while it waits, so an old proposal describes a store that no longer exists.
|
|
255
|
+
* Inside this window a running pass leaves the pending one alone — proposing
|
|
256
|
+
* again would spend a model call to overwrite a question nobody has answered —
|
|
257
|
+
* and past it the fresh proposal wins. `/memories consolidate` ignores the
|
|
258
|
+
* window, because a user who types the command is asking now.
|
|
259
|
+
*/
|
|
260
|
+
export declare const DEFAULT_CONSOLIDATE_PROPOSAL_MAX_AGE_HOURS = 72;
|
|
261
|
+
/** Default cap on entries one consolidation pass considers. */
|
|
262
|
+
export declare const DEFAULT_CONSOLIDATE_MAX_ENTRIES = 64;
|
|
263
|
+
/** Default timeout for one consolidation sub-agent run. */
|
|
264
|
+
export declare const DEFAULT_CONSOLIDATE_TIMEOUT_MS = 180000;
|
|
265
|
+
/** Default wait after a provider refuses a background pass for quota or rate. */
|
|
266
|
+
export declare const DEFAULT_QUOTA_COOLDOWN_MINUTES = 30;
|
|
267
|
+
/** Default ceiling for that wait as consecutive refusals double it. */
|
|
268
|
+
export declare const DEFAULT_QUOTA_COOLDOWN_MAX_MINUTES = 480;
|
|
269
|
+
/** Default verbosity of the plugin's own log file. */
|
|
270
|
+
export declare const DEFAULT_LOG_LEVEL: 'info';
|
|
271
|
+
/** Default for logging every maintenance decision rather than only pass summaries. */
|
|
272
|
+
export declare const DEFAULT_TRACE_MAINTENANCE = false;
|
|
273
|
+
/**
|
|
274
|
+
* Share of a scope above which a query term stops being recall evidence.
|
|
275
|
+
*
|
|
276
|
+
* Measured on the real 200-entry global scope: `dsh` sits in 44 of 200 strong
|
|
277
|
+
* fields (22%), `mac` in 24 (12%), then a long tail below 11%. At 0.15 exactly
|
|
278
|
+
* one term qualifies — the one the README singles out — and the effect is
|
|
279
|
+
* large and one-sided: the turn "dsh 插件 配置" admits 37 memories without the
|
|
280
|
+
* discount and 9 with it, "dsh 版本" 35 → 4, while "插件 内核 版本" and
|
|
281
|
+
* "mac 代理 端口" are unchanged and all ten labelled retrieval probes keep their
|
|
282
|
+
* gate verdict.
|
|
283
|
+
*/
|
|
284
|
+
export declare const DEFAULT_EVIDENCE_MAX_DF = 0.15;
|
|
285
|
+
/**
|
|
286
|
+
* Default peak-hours spec: none.
|
|
287
|
+
*
|
|
288
|
+
* Deliberately empty rather than pre-filled with one provider's timetable: this
|
|
289
|
+
* plugin can run on any route, and silently refusing to work at certain hours
|
|
290
|
+
* would be a surprising default. The description names a value that suits
|
|
291
|
+
* DeepSeek.
|
|
292
|
+
*/
|
|
293
|
+
export declare const DEFAULT_PEAK_HOURS = "";
|
|
294
|
+
/**
|
|
295
|
+
* This plugin's entry config: the deployment facts plus every tunable.
|
|
296
|
+
*
|
|
297
|
+
* The tunables are live — declared `.volatile()`, which is what the settings
|
|
298
|
+
* domain projects into the Memories page and what makes the Loader hand them to
|
|
299
|
+
* `apply` as references rather than values, so a committed write reaches the
|
|
300
|
+
* running plugin in place. The deployment fields stay ordinary: changing a path
|
|
301
|
+
* is a remount, not a knob.
|
|
302
|
+
*/
|
|
303
|
+
export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
304
|
+
/** Harness home; defaults to `$DSH_HOME` (or `~/.dsh`). */
|
|
305
|
+
dshHome: z<string, string, "plain">;
|
|
306
|
+
/** Directory holding every memory store; defaults to `<dshHome>/memories`. */
|
|
307
|
+
memoriesDir: z<string, string, "plain">;
|
|
308
|
+
/** Child names that mark a workspace root during the upward walk. */
|
|
309
|
+
projectRootMarkers: z<string[], string[], "defined">;
|
|
310
|
+
/** Plugin log file; defaults to `<dshHome>/logs/dsh-cross-memory.log`. Empty disables file logging. */
|
|
311
|
+
logFile: z<string, string, "plain">;
|
|
312
|
+
/** Git remote the memory store syncs through; empty keeps the repository local-only. */
|
|
313
|
+
syncConflictProvider: z<string, string, "volatile-defined">;
|
|
314
|
+
syncConflictModel: z<string, string, "volatile-defined">;
|
|
315
|
+
syncRemote: z<string, string, "volatile-defined">;
|
|
316
|
+
/** Local clock times to sync at, e.g. `12:05,18:05`; wins over the interval. */
|
|
317
|
+
syncClock: z<string, string, "volatile-defined">;
|
|
318
|
+
/** Background sync interval in minutes; 0 disables the timer. */
|
|
319
|
+
syncIntervalMinutes: z<number, number, "volatile-defined">;
|
|
320
|
+
/** Debounce before a memory write is committed locally. */
|
|
321
|
+
syncDebounceSeconds: z<number, number, "volatile-defined">;
|
|
322
|
+
/** Byte budget for the injected summary. `0` disables injection. */
|
|
323
|
+
maxSummaryBytes: z<number, number, "volatile-defined">;
|
|
324
|
+
/** Max entries listed per scope in the injected summary. */
|
|
325
|
+
maxSummaryEntries: z<number, number, "volatile-defined">;
|
|
326
|
+
/** Max entries listed for the global scope, which every session shares. */
|
|
327
|
+
globalSummaryEntries: z<number, number, "volatile-defined">;
|
|
328
|
+
/** Byte budget for the global section alone. */
|
|
329
|
+
globalSummaryBytes: z<number, number, "volatile-defined">;
|
|
330
|
+
/** How many of those entries are reserved for never-listed memories. */
|
|
331
|
+
summaryFreshSlots: z<number, number, "volatile-defined">;
|
|
332
|
+
/** How the injected summary is refreshed as the conversation moves on. */
|
|
333
|
+
recallMode: z<string, string, "volatile-defined">;
|
|
334
|
+
/** Minimum relevance a recall delta must reach. */
|
|
335
|
+
recallMinScore: z<number, number, "volatile-defined">;
|
|
336
|
+
/** Cap on recall deltas injected into one conversation. */
|
|
337
|
+
recallMaxPerConversation: z<number, number, "volatile-defined">;
|
|
338
|
+
/** Byte budget for one recall delta block. */
|
|
339
|
+
recallMaxBytes: z<number, number, "volatile-defined">;
|
|
340
|
+
rawRecall: z<boolean, boolean, "volatile-defined">;
|
|
341
|
+
rawRecallBytes: z<number, number, "volatile-defined">;
|
|
342
|
+
rawRecallExcerpts: z<number, number, "volatile-defined">;
|
|
343
|
+
/** Shortest user turn worth a recall decision. */
|
|
344
|
+
recallMinQueryChars: z<number, number, "volatile-defined">;
|
|
345
|
+
/** Distinct strong-field terms a recall needs before it is credited. */
|
|
346
|
+
recallMinTerms: z<number, number, "volatile-defined">;
|
|
347
|
+
/**
|
|
348
|
+
* Whether memories written after the summary was injected get a small delta.
|
|
349
|
+
*
|
|
350
|
+
* Off leaves the once-per-conversation summary as the only automatic block;
|
|
351
|
+
* the `memory` tool and the on-demand recall path still work.
|
|
352
|
+
*/
|
|
353
|
+
injectDelta: z<boolean, boolean, "volatile-defined">;
|
|
354
|
+
/**
|
|
355
|
+
* How many extra memories one conversation lists by title only.
|
|
356
|
+
*
|
|
357
|
+
* The summary names at most a dozen entries, so most of a large store is never
|
|
358
|
+
* seen. The rotation block spends about a kilobyte on titles the summary had
|
|
359
|
+
* no room for, oldest-unseen first, so the whole store becomes discoverable
|
|
360
|
+
* over a few dozen sessions. 0 disables it.
|
|
361
|
+
*/
|
|
362
|
+
rotationEntries: z<number, number, "volatile-defined">;
|
|
363
|
+
/**
|
|
364
|
+
* User turns between rotation blocks inside one long conversation.
|
|
365
|
+
*
|
|
366
|
+
* A session that runs for hours outlives its first block: the store grows and
|
|
367
|
+
* the model needs names it has not seen. Re-arming every this many turns keeps
|
|
368
|
+
* the cost bounded (one block per span) and lets coverage accumulate within a
|
|
369
|
+
* single long session. 0 keeps once-per-conversation.
|
|
370
|
+
*/
|
|
371
|
+
rotationEveryTurns: z<number, number, "volatile-defined">;
|
|
372
|
+
/** Max stored entries per scope; the least-recently-updated are evicted. */
|
|
373
|
+
maxEntriesPerScope: z<number, number, "volatile-defined">;
|
|
374
|
+
/** Days an unused memory survives before it is archived. `0` disables archival. */
|
|
375
|
+
maxUnusedDays: z<number, number, "volatile-defined">;
|
|
376
|
+
/** Days a snapshot memory survives regardless of use. `0` disables. */
|
|
377
|
+
snapshotMaxAgeDays: z<number, number, "volatile-defined">;
|
|
378
|
+
/** Token overlap above which a new memory supersedes an existing one. */
|
|
379
|
+
dedupeSimilarity: z<number, number, "volatile-defined">;
|
|
380
|
+
/** Hours between periodic maintenance sweeps. `0` disables the sweep. */
|
|
381
|
+
sweepIntervalHours: z<number, number, "volatile-defined">;
|
|
382
|
+
/** Whether the idle-time background extractor runs at all. */
|
|
383
|
+
autoExtract: z<boolean, boolean, "volatile-defined">;
|
|
384
|
+
/** Idle milliseconds before a session is mined. */
|
|
385
|
+
autoExtractIdleMs: z<number, number, "volatile-defined">;
|
|
386
|
+
/** Surface messages included in one extraction window. */
|
|
387
|
+
extractWindowMessages: z<number, number, "volatile-defined">;
|
|
388
|
+
/** Character budget for the extraction transcript. */
|
|
389
|
+
extractMaxInputChars: z<number, number, "volatile-defined">;
|
|
390
|
+
/** Output-token cap for one extraction call. */
|
|
391
|
+
extractMaxOutputTokens: z<number, number, "volatile-defined">;
|
|
392
|
+
/** Timeout for one extraction call. */
|
|
393
|
+
extractTimeoutMs: z<number, number, "volatile-defined">;
|
|
394
|
+
/** Max drafts one extraction may produce. */
|
|
395
|
+
extractMaxMemories: z<number, number, "volatile-defined">;
|
|
396
|
+
/** Minutes between periodic extraction checks over every open session. */
|
|
397
|
+
extractIntervalMinutes: z<number, number, "volatile-defined">;
|
|
398
|
+
/** A session must have been idle this long before it is mined. */
|
|
399
|
+
minIdleHours: z<number, number, "volatile-defined">;
|
|
400
|
+
/** Sessions older than this are never mined. */
|
|
401
|
+
maxAgeDays: z<number, number, "volatile-defined">;
|
|
402
|
+
/** Sessions mined per pass; bounds one pass\'s quota cost. */
|
|
403
|
+
maxSessionsPerPass: z<number, number, "volatile-defined">;
|
|
404
|
+
consolidate: z<boolean, boolean, "volatile-defined">;
|
|
405
|
+
consolidateCooldownHours: z<number, number, "volatile-defined">;
|
|
406
|
+
consolidateProposalMaxAgeHours: z<number, number, "volatile-defined">;
|
|
407
|
+
consolidateMaxEntries: z<number, number, "volatile-defined">;
|
|
408
|
+
consolidateTimeoutMs: z<number, number, "volatile-defined">;
|
|
409
|
+
/** Stop background passes while the provider is refusing for quota or rate. */
|
|
410
|
+
pauseOnQuotaError: z<boolean, boolean, "volatile-defined">;
|
|
411
|
+
/** Wait after the first such refusal; doubles per consecutive refusal. */
|
|
412
|
+
quotaCooldownMinutes: z<number, number, "volatile-defined">;
|
|
413
|
+
/** Ceiling for that doubling. */
|
|
414
|
+
quotaCooldownMaxMinutes: z<number, number, "volatile-defined">;
|
|
415
|
+
/** Explicit extraction provider route; empty reuses the session route. */
|
|
416
|
+
extractProvider: z<string, string, "volatile-defined">;
|
|
417
|
+
/** Explicit extraction model; empty reuses the session route. */
|
|
418
|
+
extractModel: z<string, string, "volatile-defined">;
|
|
419
|
+
/**
|
|
420
|
+
* Whether an AI may decide the consolidation questions that used to wait for a person.
|
|
421
|
+
*
|
|
422
|
+
* Every merge used to stop at the human panel as soon as an entry had been read
|
|
423
|
+
* once, which on a real store meant all nine proposals waited — and the panel is
|
|
424
|
+
* where automation can be added safely, because the alternative to a decision is
|
|
425
|
+
* not "safer", it is "nothing ever happens".
|
|
426
|
+
*/
|
|
427
|
+
autoDecide: z<boolean, boolean, "volatile-defined">;
|
|
428
|
+
/** Confidence floor under which an AI verdict is treated as "no answer". */
|
|
429
|
+
autoDecideMinConfidence: z<number, number, "volatile-defined">;
|
|
430
|
+
/** Explicit consolidation provider route; empty falls back to the extraction route. */
|
|
431
|
+
consolidateProvider: z<string, string, "volatile-defined">;
|
|
432
|
+
/** Explicit consolidation model; empty falls back to the extraction route. */
|
|
433
|
+
consolidateModel: z<string, string, "volatile-defined">;
|
|
434
|
+
/** Whether the `memory` tool is registered for the model. */
|
|
435
|
+
enableTool: z<boolean, boolean, "volatile-defined">;
|
|
436
|
+
/** Whether `/memories` is registered. */
|
|
437
|
+
enableCommand: z<boolean, boolean, "volatile-defined">;
|
|
438
|
+
/** How much this plugin records in its own log file. */
|
|
439
|
+
logLevel: z<string, string, "volatile-defined">;
|
|
440
|
+
/** Whether maintenance decisions are logged at info, where a stock logLevel keeps them. */
|
|
441
|
+
traceMaintenance: z<boolean, boolean, "volatile-defined">;
|
|
442
|
+
/** Whether the plugin may speak without being asked. */
|
|
443
|
+
noticesEnabled: z<boolean, boolean, "volatile-defined">;
|
|
444
|
+
/** Windows during which nothing is delivered. */
|
|
445
|
+
noticeQuietHours: z<string, string, "volatile-defined">;
|
|
446
|
+
/** Whether the weekly reflection pass may run. */
|
|
447
|
+
reflectionEnabled: z<boolean, boolean, "volatile-defined">;
|
|
448
|
+
/** Whether a model decides if a judgement-based notice is worth an interruption. */
|
|
449
|
+
noticeGate: z<boolean, boolean, "volatile-defined">;
|
|
450
|
+
/** Byte budget for the persona block injected ahead of the memory summary. */
|
|
451
|
+
personaMaxBytes: z<number, number, "volatile-defined">;
|
|
452
|
+
/** Share of a scope above which a query term stops counting as recall evidence. */
|
|
453
|
+
evidenceMaxDf: z<number, number, "volatile-defined">;
|
|
454
|
+
/** Local-time windows whose tokens are the expensive ones. */
|
|
455
|
+
peakHours: z<string, string, "volatile-defined">;
|
|
456
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
457
|
+
/** Harness home; defaults to `$DSH_HOME` (or `~/.dsh`). */
|
|
458
|
+
dshHome: z<string, string, "plain">;
|
|
459
|
+
/** Directory holding every memory store; defaults to `<dshHome>/memories`. */
|
|
460
|
+
memoriesDir: z<string, string, "plain">;
|
|
461
|
+
/** Child names that mark a workspace root during the upward walk. */
|
|
462
|
+
projectRootMarkers: z<string[], string[], "defined">;
|
|
463
|
+
/** Plugin log file; defaults to `<dshHome>/logs/dsh-cross-memory.log`. Empty disables file logging. */
|
|
464
|
+
logFile: z<string, string, "plain">;
|
|
465
|
+
/** Git remote the memory store syncs through; empty keeps the repository local-only. */
|
|
466
|
+
syncConflictProvider: z<string, string, "volatile-defined">;
|
|
467
|
+
syncConflictModel: z<string, string, "volatile-defined">;
|
|
468
|
+
syncRemote: z<string, string, "volatile-defined">;
|
|
469
|
+
/** Local clock times to sync at, e.g. `12:05,18:05`; wins over the interval. */
|
|
470
|
+
syncClock: z<string, string, "volatile-defined">;
|
|
471
|
+
/** Background sync interval in minutes; 0 disables the timer. */
|
|
472
|
+
syncIntervalMinutes: z<number, number, "volatile-defined">;
|
|
473
|
+
/** Debounce before a memory write is committed locally. */
|
|
474
|
+
syncDebounceSeconds: z<number, number, "volatile-defined">;
|
|
475
|
+
/** Byte budget for the injected summary. `0` disables injection. */
|
|
476
|
+
maxSummaryBytes: z<number, number, "volatile-defined">;
|
|
477
|
+
/** Max entries listed per scope in the injected summary. */
|
|
478
|
+
maxSummaryEntries: z<number, number, "volatile-defined">;
|
|
479
|
+
/** Max entries listed for the global scope, which every session shares. */
|
|
480
|
+
globalSummaryEntries: z<number, number, "volatile-defined">;
|
|
481
|
+
/** Byte budget for the global section alone. */
|
|
482
|
+
globalSummaryBytes: z<number, number, "volatile-defined">;
|
|
483
|
+
/** How many of those entries are reserved for never-listed memories. */
|
|
484
|
+
summaryFreshSlots: z<number, number, "volatile-defined">;
|
|
485
|
+
/** How the injected summary is refreshed as the conversation moves on. */
|
|
486
|
+
recallMode: z<string, string, "volatile-defined">;
|
|
487
|
+
/** Minimum relevance a recall delta must reach. */
|
|
488
|
+
recallMinScore: z<number, number, "volatile-defined">;
|
|
489
|
+
/** Cap on recall deltas injected into one conversation. */
|
|
490
|
+
recallMaxPerConversation: z<number, number, "volatile-defined">;
|
|
491
|
+
/** Byte budget for one recall delta block. */
|
|
492
|
+
recallMaxBytes: z<number, number, "volatile-defined">;
|
|
493
|
+
rawRecall: z<boolean, boolean, "volatile-defined">;
|
|
494
|
+
rawRecallBytes: z<number, number, "volatile-defined">;
|
|
495
|
+
rawRecallExcerpts: z<number, number, "volatile-defined">;
|
|
496
|
+
/** Shortest user turn worth a recall decision. */
|
|
497
|
+
recallMinQueryChars: z<number, number, "volatile-defined">;
|
|
498
|
+
/** Distinct strong-field terms a recall needs before it is credited. */
|
|
499
|
+
recallMinTerms: z<number, number, "volatile-defined">;
|
|
500
|
+
/**
|
|
501
|
+
* Whether memories written after the summary was injected get a small delta.
|
|
502
|
+
*
|
|
503
|
+
* Off leaves the once-per-conversation summary as the only automatic block;
|
|
504
|
+
* the `memory` tool and the on-demand recall path still work.
|
|
505
|
+
*/
|
|
506
|
+
injectDelta: z<boolean, boolean, "volatile-defined">;
|
|
507
|
+
/**
|
|
508
|
+
* How many extra memories one conversation lists by title only.
|
|
509
|
+
*
|
|
510
|
+
* The summary names at most a dozen entries, so most of a large store is never
|
|
511
|
+
* seen. The rotation block spends about a kilobyte on titles the summary had
|
|
512
|
+
* no room for, oldest-unseen first, so the whole store becomes discoverable
|
|
513
|
+
* over a few dozen sessions. 0 disables it.
|
|
514
|
+
*/
|
|
515
|
+
rotationEntries: z<number, number, "volatile-defined">;
|
|
516
|
+
/**
|
|
517
|
+
* User turns between rotation blocks inside one long conversation.
|
|
518
|
+
*
|
|
519
|
+
* A session that runs for hours outlives its first block: the store grows and
|
|
520
|
+
* the model needs names it has not seen. Re-arming every this many turns keeps
|
|
521
|
+
* the cost bounded (one block per span) and lets coverage accumulate within a
|
|
522
|
+
* single long session. 0 keeps once-per-conversation.
|
|
523
|
+
*/
|
|
524
|
+
rotationEveryTurns: z<number, number, "volatile-defined">;
|
|
525
|
+
/** Max stored entries per scope; the least-recently-updated are evicted. */
|
|
526
|
+
maxEntriesPerScope: z<number, number, "volatile-defined">;
|
|
527
|
+
/** Days an unused memory survives before it is archived. `0` disables archival. */
|
|
528
|
+
maxUnusedDays: z<number, number, "volatile-defined">;
|
|
529
|
+
/** Days a snapshot memory survives regardless of use. `0` disables. */
|
|
530
|
+
snapshotMaxAgeDays: z<number, number, "volatile-defined">;
|
|
531
|
+
/** Token overlap above which a new memory supersedes an existing one. */
|
|
532
|
+
dedupeSimilarity: z<number, number, "volatile-defined">;
|
|
533
|
+
/** Hours between periodic maintenance sweeps. `0` disables the sweep. */
|
|
534
|
+
sweepIntervalHours: z<number, number, "volatile-defined">;
|
|
535
|
+
/** Whether the idle-time background extractor runs at all. */
|
|
536
|
+
autoExtract: z<boolean, boolean, "volatile-defined">;
|
|
537
|
+
/** Idle milliseconds before a session is mined. */
|
|
538
|
+
autoExtractIdleMs: z<number, number, "volatile-defined">;
|
|
539
|
+
/** Surface messages included in one extraction window. */
|
|
540
|
+
extractWindowMessages: z<number, number, "volatile-defined">;
|
|
541
|
+
/** Character budget for the extraction transcript. */
|
|
542
|
+
extractMaxInputChars: z<number, number, "volatile-defined">;
|
|
543
|
+
/** Output-token cap for one extraction call. */
|
|
544
|
+
extractMaxOutputTokens: z<number, number, "volatile-defined">;
|
|
545
|
+
/** Timeout for one extraction call. */
|
|
546
|
+
extractTimeoutMs: z<number, number, "volatile-defined">;
|
|
547
|
+
/** Max drafts one extraction may produce. */
|
|
548
|
+
extractMaxMemories: z<number, number, "volatile-defined">;
|
|
549
|
+
/** Minutes between periodic extraction checks over every open session. */
|
|
550
|
+
extractIntervalMinutes: z<number, number, "volatile-defined">;
|
|
551
|
+
/** A session must have been idle this long before it is mined. */
|
|
552
|
+
minIdleHours: z<number, number, "volatile-defined">;
|
|
553
|
+
/** Sessions older than this are never mined. */
|
|
554
|
+
maxAgeDays: z<number, number, "volatile-defined">;
|
|
555
|
+
/** Sessions mined per pass; bounds one pass\'s quota cost. */
|
|
556
|
+
maxSessionsPerPass: z<number, number, "volatile-defined">;
|
|
557
|
+
consolidate: z<boolean, boolean, "volatile-defined">;
|
|
558
|
+
consolidateCooldownHours: z<number, number, "volatile-defined">;
|
|
559
|
+
consolidateProposalMaxAgeHours: z<number, number, "volatile-defined">;
|
|
560
|
+
consolidateMaxEntries: z<number, number, "volatile-defined">;
|
|
561
|
+
consolidateTimeoutMs: z<number, number, "volatile-defined">;
|
|
562
|
+
/** Stop background passes while the provider is refusing for quota or rate. */
|
|
563
|
+
pauseOnQuotaError: z<boolean, boolean, "volatile-defined">;
|
|
564
|
+
/** Wait after the first such refusal; doubles per consecutive refusal. */
|
|
565
|
+
quotaCooldownMinutes: z<number, number, "volatile-defined">;
|
|
566
|
+
/** Ceiling for that doubling. */
|
|
567
|
+
quotaCooldownMaxMinutes: z<number, number, "volatile-defined">;
|
|
568
|
+
/** Explicit extraction provider route; empty reuses the session route. */
|
|
569
|
+
extractProvider: z<string, string, "volatile-defined">;
|
|
570
|
+
/** Explicit extraction model; empty reuses the session route. */
|
|
571
|
+
extractModel: z<string, string, "volatile-defined">;
|
|
572
|
+
/**
|
|
573
|
+
* Whether an AI may decide the consolidation questions that used to wait for a person.
|
|
574
|
+
*
|
|
575
|
+
* Every merge used to stop at the human panel as soon as an entry had been read
|
|
576
|
+
* once, which on a real store meant all nine proposals waited — and the panel is
|
|
577
|
+
* where automation can be added safely, because the alternative to a decision is
|
|
578
|
+
* not "safer", it is "nothing ever happens".
|
|
579
|
+
*/
|
|
580
|
+
autoDecide: z<boolean, boolean, "volatile-defined">;
|
|
581
|
+
/** Confidence floor under which an AI verdict is treated as "no answer". */
|
|
582
|
+
autoDecideMinConfidence: z<number, number, "volatile-defined">;
|
|
583
|
+
/** Explicit consolidation provider route; empty falls back to the extraction route. */
|
|
584
|
+
consolidateProvider: z<string, string, "volatile-defined">;
|
|
585
|
+
/** Explicit consolidation model; empty falls back to the extraction route. */
|
|
586
|
+
consolidateModel: z<string, string, "volatile-defined">;
|
|
587
|
+
/** Whether the `memory` tool is registered for the model. */
|
|
588
|
+
enableTool: z<boolean, boolean, "volatile-defined">;
|
|
589
|
+
/** Whether `/memories` is registered. */
|
|
590
|
+
enableCommand: z<boolean, boolean, "volatile-defined">;
|
|
591
|
+
/** How much this plugin records in its own log file. */
|
|
592
|
+
logLevel: z<string, string, "volatile-defined">;
|
|
593
|
+
/** Whether maintenance decisions are logged at info, where a stock logLevel keeps them. */
|
|
594
|
+
traceMaintenance: z<boolean, boolean, "volatile-defined">;
|
|
595
|
+
/** Whether the plugin may speak without being asked. */
|
|
596
|
+
noticesEnabled: z<boolean, boolean, "volatile-defined">;
|
|
597
|
+
/** Windows during which nothing is delivered. */
|
|
598
|
+
noticeQuietHours: z<string, string, "volatile-defined">;
|
|
599
|
+
/** Whether the weekly reflection pass may run. */
|
|
600
|
+
reflectionEnabled: z<boolean, boolean, "volatile-defined">;
|
|
601
|
+
/** Whether a model decides if a judgement-based notice is worth an interruption. */
|
|
602
|
+
noticeGate: z<boolean, boolean, "volatile-defined">;
|
|
603
|
+
/** Byte budget for the persona block injected ahead of the memory summary. */
|
|
604
|
+
personaMaxBytes: z<number, number, "volatile-defined">;
|
|
605
|
+
/** Share of a scope above which a query term stops counting as recall evidence. */
|
|
606
|
+
evidenceMaxDf: z<number, number, "volatile-defined">;
|
|
607
|
+
/** Local-time windows whose tokens are the expensive ones. */
|
|
608
|
+
peakHours: z<string, string, "volatile-defined">;
|
|
609
|
+
}>>, "plain">;
|
|
610
|
+
/**
|
|
611
|
+
* The tunables as plain data: the entry config's live half, unwrapped.
|
|
612
|
+
*
|
|
613
|
+
* Spelled out rather than derived from {@link Config} because a schemastery
|
|
614
|
+
* schema's output type does not survive `keyof` (the library builds it through a
|
|
615
|
+
* deferred conditional), and a mistyped runtime contract is worse than a
|
|
616
|
+
* duplicated one. What keeps the two in step is a test, not the type system: see
|
|
617
|
+
* `test/settings-card.test.ts`, which holds this list, the entry schema's live
|
|
618
|
+
* fields, and the card's field list against each other.
|
|
619
|
+
*/
|
|
620
|
+
export interface MemoriesSettings {
|
|
621
|
+
/** Summary injection: budget, per-scope caps, and the recall delta. */
|
|
622
|
+
maxSummaryBytes: number;
|
|
623
|
+
maxSummaryEntries: number;
|
|
624
|
+
globalSummaryEntries: number;
|
|
625
|
+
globalSummaryBytes: number;
|
|
626
|
+
summaryFreshSlots: number;
|
|
627
|
+
recallMode: string;
|
|
628
|
+
recallMinScore: number;
|
|
629
|
+
recallMaxPerConversation: number;
|
|
630
|
+
recallMaxBytes: number;
|
|
631
|
+
rawRecall: boolean;
|
|
632
|
+
rawRecallBytes: number;
|
|
633
|
+
rawRecallExcerpts: number;
|
|
634
|
+
recallMinQueryChars: number;
|
|
635
|
+
recallMinTerms: number;
|
|
636
|
+
/** Whether memories written after the summary are announced as a delta. */
|
|
637
|
+
injectDelta: boolean;
|
|
638
|
+
/** How many extra memories one conversation lists by title only (0 disables). */
|
|
639
|
+
rotationEntries: number;
|
|
640
|
+
/** User turns between rotation blocks inside one long conversation (0 = once). */
|
|
641
|
+
rotationEveryTurns: number;
|
|
642
|
+
/** Retention: what the store keeps, and for how long. */
|
|
643
|
+
maxEntriesPerScope: number;
|
|
644
|
+
maxUnusedDays: number;
|
|
645
|
+
snapshotMaxAgeDays: number;
|
|
646
|
+
dedupeSimilarity: number;
|
|
647
|
+
sweepIntervalHours: number;
|
|
648
|
+
/** Background extraction: when it runs and how much it reads. */
|
|
649
|
+
autoExtract: boolean;
|
|
650
|
+
autoExtractIdleMs: number;
|
|
651
|
+
extractWindowMessages: number;
|
|
652
|
+
extractMaxInputChars: number;
|
|
653
|
+
extractMaxOutputTokens: number;
|
|
654
|
+
extractTimeoutMs: number;
|
|
655
|
+
extractMaxMemories: number;
|
|
656
|
+
extractIntervalMinutes: number;
|
|
657
|
+
minIdleHours: number;
|
|
658
|
+
maxAgeDays: number;
|
|
659
|
+
maxSessionsPerPass: number;
|
|
660
|
+
/** Git remote the store syncs through; empty keeps it local-only. */
|
|
661
|
+
syncRemote: string;
|
|
662
|
+
/** Provider for AI conflict resolution; empty falls back to the extraction route. */
|
|
663
|
+
syncConflictProvider: string;
|
|
664
|
+
/** Model for AI conflict resolution; empty falls back to the extraction route. */
|
|
665
|
+
syncConflictModel: string;
|
|
666
|
+
/** Local clock times to sync at, comma separated `HH:MM`; wins over the interval. */
|
|
667
|
+
syncClock: string;
|
|
668
|
+
/** Background sync interval in minutes; 0 disables the timer. */
|
|
669
|
+
syncIntervalMinutes: number;
|
|
670
|
+
/** Debounce before a memory write becomes one commit, in seconds. */
|
|
671
|
+
syncDebounceSeconds: number;
|
|
672
|
+
/** Consolidation: the restricted sub-agent pass that merges new memories. */
|
|
673
|
+
consolidate: boolean;
|
|
674
|
+
consolidateCooldownHours: number;
|
|
675
|
+
consolidateProposalMaxAgeHours: number;
|
|
676
|
+
consolidateMaxEntries: number;
|
|
677
|
+
consolidateTimeoutMs: number;
|
|
678
|
+
pauseOnQuotaError: boolean;
|
|
679
|
+
quotaCooldownMinutes: number;
|
|
680
|
+
quotaCooldownMaxMinutes: number;
|
|
681
|
+
/** Whether an AI may adjudicate what would otherwise wait for a person. */
|
|
682
|
+
autoDecide: boolean;
|
|
683
|
+
/** Confidence floor under which an AI verdict counts as no answer. */
|
|
684
|
+
autoDecideMinConfidence: number;
|
|
685
|
+
/** Byte budget for the injected persona block. */
|
|
686
|
+
personaMaxBytes: number;
|
|
687
|
+
/** Whether a model gates judgement-based notices. */
|
|
688
|
+
noticeGate: boolean;
|
|
689
|
+
/** Whether the weekly reflection pass may run. */
|
|
690
|
+
reflectionEnabled: boolean;
|
|
691
|
+
/** Whether the plugin may speak without being asked. */
|
|
692
|
+
noticesEnabled: boolean;
|
|
693
|
+
/** Local-time windows during which notices are held. */
|
|
694
|
+
noticeQuietHours: string;
|
|
695
|
+
/** Model routes for the plugin's own calls; empty reuses the session's route. */
|
|
696
|
+
extractProvider: string;
|
|
697
|
+
extractModel: string;
|
|
698
|
+
consolidateProvider: string;
|
|
699
|
+
consolidateModel: string;
|
|
700
|
+
/** Registrations the model sees. */
|
|
701
|
+
enableTool: boolean;
|
|
702
|
+
enableCommand: boolean;
|
|
703
|
+
/** This plugin's own log file and how much it records. */
|
|
704
|
+
logLevel: string;
|
|
705
|
+
traceMaintenance: boolean;
|
|
706
|
+
evidenceMaxDf: number;
|
|
707
|
+
peakHours: string;
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Every tunable with its shipped value.
|
|
711
|
+
*
|
|
712
|
+
* The runtime never reads this object for behaviour — the Loader resolves the
|
|
713
|
+
* schema defaults — but it is the same set as plain data: the key list the
|
|
714
|
+
* runtime and the card are both checked against, with the values a harness (or
|
|
715
|
+
* any deployment that configures nothing) starts from.
|
|
716
|
+
*/
|
|
717
|
+
export declare const MEMORIES_SETTINGS_DEFAULTS: MemoriesSettings;
|
|
718
|
+
/**
|
|
719
|
+
* The raw, possibly partial entry configuration the loader hands `apply`.
|
|
720
|
+
*
|
|
721
|
+
* The tunables are spelled flat on the row, and how they arrive depends on who
|
|
722
|
+
* composed it: a row the Loader mounted against {@link Config} carries them as
|
|
723
|
+
* live references, while a hand-written one (a composition without the schema, a
|
|
724
|
+
* test harness) carries plain values. Both are accepted here, and
|
|
725
|
+
* {@link plainRow} is what reads them out.
|
|
726
|
+
*/
|
|
727
|
+
export interface MemoriesConfig extends Partial<RowTunables> {
|
|
728
|
+
dshHome?: string;
|
|
729
|
+
memoriesDir?: string;
|
|
730
|
+
projectRootMarkers?: string[];
|
|
731
|
+
/**
|
|
732
|
+
* Directories that are a workspace even though they are not a repository.
|
|
733
|
+
*
|
|
734
|
+
* Keyed by absolute path prefix, valued by the scope root to file under. The
|
|
735
|
+
* harness home is excluded from scoping on purpose (it is where a session is
|
|
736
|
+
* *started*, not what it works on), but plugin and kernel work really does
|
|
737
|
+
* happen there — and 28% of the global scope turned out to be exactly that:
|
|
738
|
+
* DSH-development notes following the user into every unrelated project. Naming
|
|
739
|
+
* a directory here gives it a scope of its own without weakening the catch-all
|
|
740
|
+
* rule for the home directory itself.
|
|
741
|
+
*/
|
|
742
|
+
projectRootOverrides?: Record<string, string>;
|
|
743
|
+
/** Plugin log file; defaults to `<dshHome>/logs/dsh-cross-memory.log`. Empty disables file logging. */
|
|
744
|
+
logFile?: string;
|
|
745
|
+
}
|
|
746
|
+
/** One tunable as a row carries it: the value itself, or the reference to it. */
|
|
747
|
+
type RowField<T> = T | Volatile<T>;
|
|
748
|
+
/** Every tunable, keyed as the row spells it. */
|
|
749
|
+
type RowTunables = {
|
|
750
|
+
[K in keyof MemoriesSettings]: RowField<MemoriesSettings[K]>;
|
|
751
|
+
};
|
|
752
|
+
/** Fully resolved deployment configuration. */
|
|
753
|
+
export interface ResolvedConfig {
|
|
754
|
+
readonly dshHome: string;
|
|
755
|
+
readonly memoriesDir: string;
|
|
756
|
+
readonly projectRootMarkers: readonly string[];
|
|
757
|
+
/** Absolute prefixes that own a scope regardless of markers, longest first. */
|
|
758
|
+
readonly projectRootOverrides: readonly (readonly [string, string])[];
|
|
759
|
+
/**
|
|
760
|
+
* Log file for the plugin's own lines; empty disables file logging.
|
|
761
|
+
*
|
|
762
|
+
* A deployment fact rather than a tunable: it is a path. The knob that matters
|
|
763
|
+
* day to day is `logLevel`.
|
|
764
|
+
*/
|
|
765
|
+
readonly logFile: string;
|
|
766
|
+
/** The tunables this row resolves to, as read when the plugin was mounted. */
|
|
767
|
+
readonly tunables: MemoriesSettings;
|
|
768
|
+
}
|
|
769
|
+
/** Coerce one possibly-absent tunable set into a complete, clamped section. */
|
|
770
|
+
export declare function normalizeSettings(input: Partial<MemoriesSettings> | undefined): MemoriesSettings;
|
|
771
|
+
/**
|
|
772
|
+
* The route one consolidation pass runs on.
|
|
773
|
+
*
|
|
774
|
+
* Codex keeps `memories.extract_model` and `memories.consolidation_model`
|
|
775
|
+
* separate; here an unset consolidation route falls back to the extraction one
|
|
776
|
+
* and then to the session's own logged route, so an existing configuration that
|
|
777
|
+
* only names `extractProvider`/`extractModel` keeps behaving as before.
|
|
778
|
+
*
|
|
779
|
+
* @param settings - the tunables in force.
|
|
780
|
+
* @returns the provider/model pair, or `{}` to reuse the session route.
|
|
781
|
+
*/
|
|
782
|
+
export declare function consolidationRouteOf(settings: MemoriesSettings): {
|
|
783
|
+
provider?: string;
|
|
784
|
+
model?: string;
|
|
785
|
+
};
|
|
786
|
+
/**
|
|
787
|
+
* One entry config with its live references read out.
|
|
788
|
+
*
|
|
789
|
+
* A row the Loader mounted arrives with every tunable as a `Volatile` reference
|
|
790
|
+
* that a committed settings write updates in place; a plain row (a test harness,
|
|
791
|
+
* a hand-written composition) arrives with the values themselves. Both pass
|
|
792
|
+
* through here unchanged in shape, so every reader downstream sees plain data
|
|
793
|
+
* and the same code serves the two cases.
|
|
794
|
+
*
|
|
795
|
+
* @param config - the row as `apply` received it.
|
|
796
|
+
* @returns the same row with references replaced by their current values.
|
|
797
|
+
*/
|
|
798
|
+
export declare function plainRow(config: MemoriesConfig): MemoriesConfig;
|
|
799
|
+
/**
|
|
800
|
+
* The tunables an entry config holds right now.
|
|
801
|
+
*
|
|
802
|
+
* A read rather than a value on purpose: a committed settings write lands in the
|
|
803
|
+
* row's references without re-mounting the plugin, so the runtime asks again
|
|
804
|
+
* instead of holding a snapshot.
|
|
805
|
+
*
|
|
806
|
+
* @param config - the row as `apply` received it.
|
|
807
|
+
* @returns the normalized tunables in force.
|
|
808
|
+
*/
|
|
809
|
+
export declare function readTunables(config: MemoriesConfig): MemoriesSettings;
|
|
810
|
+
export declare function resolveConfig(config?: MemoriesConfig): ResolvedConfig;
|
|
811
|
+
export {};
|