dsh-cross-memory 0.0.0-stage → 0.2.1
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 +253 -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 +1660 -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 +4482 -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 +163 -0
- package/lib/query.js +93 -0
- package/lib/raw-recall.js +286 -0
- package/lib/reflection.js +291 -0
- package/lib/remote.js +490 -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 +341 -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 +142 -0
- package/lib/test/persona.test.js +86 -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 +238 -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 +76 -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 +246 -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,1316 @@
|
|
|
1
|
+
import type { UserMessage } from '@deepseek-ai/dsh-llm';
|
|
2
|
+
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
3
|
+
import type { Session } from '@deepseek-ai/dsh-session';
|
|
4
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
5
|
+
import type { MemoriesConfig, MemoriesSettings, ResolvedConfig } from './config.js';
|
|
6
|
+
import { MemoryStore } from './storage.js';
|
|
7
|
+
import { StateStore } from './state.js';
|
|
8
|
+
import type { ConsolidationDispute } from './consolidate.js';
|
|
9
|
+
import type { MemoryDraft, MemoryEntry, MemoryKind, MemoryScope, SessionMode } from './types.js';
|
|
10
|
+
/** Plugin name; also the source tag of every injected message. */
|
|
11
|
+
export declare const name = "memories";
|
|
12
|
+
/**
|
|
13
|
+
* Whether a directory is somewhere a session was *started from*, not a project.
|
|
14
|
+
*
|
|
15
|
+
* {@link findProjectRoot} falls back to the starting directory when it finds no
|
|
16
|
+
* root marker, so any directory a session happens to open in becomes a scope
|
|
17
|
+
* forever. Two of them must never become one: the harness home (plugin work,
|
|
18
|
+
* profiles, logs) and the user's home directory itself. Measured on a real
|
|
19
|
+
* store, the harness home alone had collected 14 memories from five unrelated
|
|
20
|
+
* projects.
|
|
21
|
+
*
|
|
22
|
+
* Descendants of the home directory are deliberately allowed through: a game's
|
|
23
|
+
* save folder under `%LOCALAPPDATA%` is a real workspace with work worth
|
|
24
|
+
* remembering, while the home directory itself is not. The OS temp tree is
|
|
25
|
+
* allowed through too, because half-finished work there is still work.
|
|
26
|
+
*
|
|
27
|
+
* @param root - the candidate workspace root.
|
|
28
|
+
* @param dshHome - the harness home directory.
|
|
29
|
+
* @returns true when the directory must not own a project scope.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isCatchAllDirectory(root: string, dshHome: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Services this plugin requires at activation: the tool registry (for the
|
|
34
|
+
* `memory` tool) and the command registry (for `/memories`).
|
|
35
|
+
*
|
|
36
|
+
* The settings domain, the LLM, and the subagent seam are all optional and
|
|
37
|
+
* reached through `ctx.inject` or `ctx.get`: a deployment with no model adapter
|
|
38
|
+
* or no delegation still loads (it just never runs background extraction or
|
|
39
|
+
* consolidation), and one without the settings domain still serves every
|
|
40
|
+
* model-facing surface (it just has no Memories page).
|
|
41
|
+
*/
|
|
42
|
+
export declare const inject: string[];
|
|
43
|
+
/** Why one session was not mined, for the pass line. */
|
|
44
|
+
type MineSkip = 'off' | 'peak' | 'not-idle' | 'quiet' | 'claim' | 'no-llm' | 'no-route' | 'empty' | 'max-tokens' | 'capped';
|
|
45
|
+
/** One scope's loaded state. */
|
|
46
|
+
interface ScopeState {
|
|
47
|
+
readonly scope: MemoryScope;
|
|
48
|
+
readonly label: string;
|
|
49
|
+
readonly heading: string;
|
|
50
|
+
readonly entries: readonly MemoryEntry[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The memory runtime: one instance per plugin mount, shared by the tool, the
|
|
54
|
+
* injector, the extractor, and the command handler.
|
|
55
|
+
*/
|
|
56
|
+
export declare class MemoriesRuntime {
|
|
57
|
+
private readonly ctx;
|
|
58
|
+
/** Deployment facts resolved once: paths and workspace discovery. */
|
|
59
|
+
readonly deployment: ResolvedConfig;
|
|
60
|
+
readonly store: MemoryStore;
|
|
61
|
+
/** Operational state: watermarks, consolidation jobs, usage counters. */
|
|
62
|
+
readonly state: StateStore;
|
|
63
|
+
/**
|
|
64
|
+
* Live tunables.
|
|
65
|
+
*
|
|
66
|
+
* A thunk rather than a snapshot: the settings namespace is hot-reloaded, so
|
|
67
|
+
* every read must see the value committed most recently, and a restart is
|
|
68
|
+
* never required to change a knob.
|
|
69
|
+
*/
|
|
70
|
+
private readonly settingsThunk;
|
|
71
|
+
/**
|
|
72
|
+
* The LLM runtime as it was at activation, when it was already provided.
|
|
73
|
+
*
|
|
74
|
+
* Kept as a snapshot because by the time a settle pass runs the tree may
|
|
75
|
+
* already be disposing, and a late `ctx.get('llm')` then resolves to nothing —
|
|
76
|
+
* which is exactly the pass a one-shot run depends on.
|
|
77
|
+
*/
|
|
78
|
+
private readonly llmAtActivation;
|
|
79
|
+
/** The subagent seam as it was at activation; absent in a deployment without delegation. */
|
|
80
|
+
private readonly subagentsAtActivation;
|
|
81
|
+
/** Whether the "no llm service" warning has already been written. */
|
|
82
|
+
private warnedNoLlm;
|
|
83
|
+
/** Whether the "no subagent seam" warning has already been written. */
|
|
84
|
+
private warnedNoSubagents;
|
|
85
|
+
/**
|
|
86
|
+
* Whether the tool-free consolidation preset is registered.
|
|
87
|
+
*
|
|
88
|
+
* Since 0.2.1-rc.2 a subagent's tool set comes from the preset it names, and
|
|
89
|
+
* a child that names none inherits the parent's composition — the parent's
|
|
90
|
+
* tools, which is exactly what the consolidation pass must withhold. This flag
|
|
91
|
+
* is what tells the pass that the new-style seam can be used safely.
|
|
92
|
+
*/
|
|
93
|
+
private consolidatePresetReady;
|
|
94
|
+
private readonly rootCache;
|
|
95
|
+
/** Why the last `consolidateNow` declined to run, for the command's report. */
|
|
96
|
+
private consolidateSkip;
|
|
97
|
+
/** Hub-term predicates by store signature; see `hubFor`. */
|
|
98
|
+
private readonly hubCache;
|
|
99
|
+
/** Sessions whose conversation already carries the memory block. */
|
|
100
|
+
private readonly injected;
|
|
101
|
+
/** Recall deltas already injected into each conversation. */
|
|
102
|
+
private readonly recallCounts;
|
|
103
|
+
/** Late memory blocks already injected into each conversation. */
|
|
104
|
+
private readonly deltaCounts;
|
|
105
|
+
/** The user-turn number at which each conversation last emitted a rotation block. */
|
|
106
|
+
private readonly rotationAt;
|
|
107
|
+
/** Entry ids each conversation has already been shown. */
|
|
108
|
+
private readonly surfacedIds;
|
|
109
|
+
/** Injected ids this conversation has already credited as used. */
|
|
110
|
+
private readonly helpedIds;
|
|
111
|
+
/**
|
|
112
|
+
* Sessions whose "nothing was recalled, but something cleared the floor" has
|
|
113
|
+
* already been reported, so the diagnostic costs at most one line each.
|
|
114
|
+
*/
|
|
115
|
+
private readonly nearMissLogged;
|
|
116
|
+
private readonly idleTimers;
|
|
117
|
+
private readonly extracting;
|
|
118
|
+
/**
|
|
119
|
+
* Sessions whose last extraction reply hit the output cap, and when they may
|
|
120
|
+
* be tried again.
|
|
121
|
+
*
|
|
122
|
+
* A capped window is deliberately left unmined so nothing is lost, which is
|
|
123
|
+
* exactly why the retry needs a gate: the cap that cut the reply is a property
|
|
124
|
+
* of the transcript rather than a hiccup, so retrying on the pass cadence would
|
|
125
|
+
* repeat the same full-price call forever. Entries carry the ceiling and route
|
|
126
|
+
* they blamed, so changing either clears the verdict on the spot instead of
|
|
127
|
+
* making a user who just raised the knob wait out a cooldown.
|
|
128
|
+
*/
|
|
129
|
+
private readonly capped;
|
|
130
|
+
private readonly lifecycle;
|
|
131
|
+
/** The plugin's own logger: the host logger, plus the decision facade. */
|
|
132
|
+
private readonly log;
|
|
133
|
+
/**
|
|
134
|
+
* Why the configured log file is not being written, when it could not be
|
|
135
|
+
* opened or a write failed. Set by the composition, surfaced by `/memories
|
|
136
|
+
* stats` — the only reachable diagnostic, since the broken channel cannot
|
|
137
|
+
* report itself.
|
|
138
|
+
*/
|
|
139
|
+
logSinkError: string | undefined;
|
|
140
|
+
constructor(ctx: Context, config: MemoriesConfig, settings?: () => MemoriesSettings);
|
|
141
|
+
/**
|
|
142
|
+
* The LLM runtime to use right now.
|
|
143
|
+
*
|
|
144
|
+
* The activation snapshot first, then a live lookup. In 0.1.7 a service may be
|
|
145
|
+
* provided by a row that runs after this plugin's — the same ordering trap the
|
|
146
|
+
* `settings` and `typert` seams below document — so the snapshot is
|
|
147
|
+
* legitimately `undefined` at activation and stays that way for the whole
|
|
148
|
+
* process. Resolving per call is what keeps a late provider from turning every
|
|
149
|
+
* background pass into a silent no-op.
|
|
150
|
+
*/
|
|
151
|
+
private get llm();
|
|
152
|
+
/**
|
|
153
|
+
* The subagent seam to use right now.
|
|
154
|
+
*
|
|
155
|
+
* Resolved the same way and for the same reason as {@link llm}: consolidation
|
|
156
|
+
* is a subagent pass, so a seam captured at activation when it was not yet
|
|
157
|
+
* provided would disable every later consolidation silently.
|
|
158
|
+
*/
|
|
159
|
+
private get subagents();
|
|
160
|
+
/** The tunables in force right now. */
|
|
161
|
+
get settings(): MemoriesSettings;
|
|
162
|
+
/**
|
|
163
|
+
* Record that the tool-free consolidation preset is registered.
|
|
164
|
+
*
|
|
165
|
+
* The composition answers this once the preset registry is available; the
|
|
166
|
+
* flag is what the consolidation pass reads before it hands a child to the
|
|
167
|
+
* 0.2.1-rc.2 seam.
|
|
168
|
+
*
|
|
169
|
+
* @param ready - whether the preset is registered and usable.
|
|
170
|
+
*/
|
|
171
|
+
markConsolidatePresetReady(ready: boolean): void;
|
|
172
|
+
/** Abort every owned background activity and release the state store. */
|
|
173
|
+
dispose(): void;
|
|
174
|
+
/**
|
|
175
|
+
* Resolve (and cache) one session's workspace root.
|
|
176
|
+
*
|
|
177
|
+
* `undefined` means the session has no project scope at all — see
|
|
178
|
+
* {@link NO_PROJECT_LABEL} — which is a different thing from "the lookup
|
|
179
|
+
* failed": every caller treats it as "this conversation has no workspace".
|
|
180
|
+
*
|
|
181
|
+
* @param session - session whose workspace to resolve.
|
|
182
|
+
* @returns the workspace root, or `undefined` when the session has none.
|
|
183
|
+
*/
|
|
184
|
+
projectRoot(session: Session): Promise<string | undefined>;
|
|
185
|
+
/** Decide one session's project scope; see {@link NO_PROJECT_LABEL}. */
|
|
186
|
+
private resolveProjectRoot;
|
|
187
|
+
/** Load one scope's entries plus its model-facing labels. */
|
|
188
|
+
scopeState(scope: MemoryScope, session: Session): Promise<ScopeState>;
|
|
189
|
+
/**
|
|
190
|
+
* Load both scopes, broadest first, with the surfaced clock taken from the
|
|
191
|
+
* state database.
|
|
192
|
+
*
|
|
193
|
+
* The entry file mirrors `lastSurfaced` for human readers, but the mirror is
|
|
194
|
+
* refreshed at most hourly and entries written before the usage table existed
|
|
195
|
+
* have no row at all: measured on the real store, files claimed 85.8% surfaced
|
|
196
|
+
* while `state.db` had a row for far fewer. Selection (summary fresh slots,
|
|
197
|
+
* rotation, delta) must read the authoritative clock, or "never shown" becomes
|
|
198
|
+
* "shown long ago" and the store's dead entries never rotate in.
|
|
199
|
+
*
|
|
200
|
+
* In a deployment without SQLite the overlay is skipped: the mirror is then
|
|
201
|
+
* the only clock there is.
|
|
202
|
+
*/
|
|
203
|
+
allScopes(session: Session): Promise<readonly ScopeState[]>;
|
|
204
|
+
/** Convert loaded scopes into the search/browse input shape. */
|
|
205
|
+
private groups;
|
|
206
|
+
/** Search both scopes. */
|
|
207
|
+
search(session: Session, query: string, options: {
|
|
208
|
+
scopes?: readonly MemoryScope[];
|
|
209
|
+
tags?: readonly string[];
|
|
210
|
+
kinds?: readonly MemoryKind[];
|
|
211
|
+
limit?: number;
|
|
212
|
+
}): Promise<import("./types.js").MemoryHit[]>;
|
|
213
|
+
/** Browse both scopes without a query. */
|
|
214
|
+
browse(session: Session, options: {
|
|
215
|
+
scopes?: readonly MemoryScope[];
|
|
216
|
+
tags?: readonly string[];
|
|
217
|
+
kinds?: readonly MemoryKind[];
|
|
218
|
+
limit?: number;
|
|
219
|
+
}): Promise<import("./types.js").MemoryHit[]>;
|
|
220
|
+
/** Read one entry by scope and id, recording the hit. */
|
|
221
|
+
read(session: Session, scope: MemoryScope, id: string, record?: boolean): Promise<MemoryEntry | undefined>;
|
|
222
|
+
/**
|
|
223
|
+
* Record one read/search hit.
|
|
224
|
+
*
|
|
225
|
+
* The counter lives in the state database (atomic, concurrent-safe) and is
|
|
226
|
+
* mirrored back into the entry file so the markdown stays a complete picture
|
|
227
|
+
* for a human reader.
|
|
228
|
+
*/
|
|
229
|
+
private touchEntry;
|
|
230
|
+
/** Record hits for a batch of search/browse results, best-effort. */
|
|
231
|
+
recordUsage(session: Session, entries: readonly MemoryEntry[]): Promise<void>;
|
|
232
|
+
/**
|
|
233
|
+
* Store one draft, choosing the scope.
|
|
234
|
+
*
|
|
235
|
+
* The whole draft shape is accepted, not a reduced one: `kind`, `keys`, and
|
|
236
|
+
* `appliesTo` are what make a memory findable and what say when it matters, so
|
|
237
|
+
* a caller that has them must not have to drop them at this seam.
|
|
238
|
+
*
|
|
239
|
+
* A project draft from a session with no workspace is stored globally rather
|
|
240
|
+
* than refused: the extractor cannot know the session has none, and dropping
|
|
241
|
+
* the fact would lose it silently. The rewrite is logged, because the scope it
|
|
242
|
+
* lands in is what decides who sees it later.
|
|
243
|
+
*/
|
|
244
|
+
write(session: Session, draft: MemoryDraft, source: MemoryEntry['source']): Promise<import("./types.js").UpsertResult>;
|
|
245
|
+
/** The one place a draft becomes an entry, so the scope rule has one home. */
|
|
246
|
+
private persist;
|
|
247
|
+
/**
|
|
248
|
+
* Find the project scope whose root directory a global draft cites.
|
|
249
|
+
*
|
|
250
|
+
* Scoping is where a memory earns or loses its reach: an employer, product or
|
|
251
|
+
* repository fact parked in global follows the user into every unrelated
|
|
252
|
+
* project. The extractor is asked to make that call and sometimes gets it
|
|
253
|
+
* wrong, so the store's own project descriptors are the second opinion — a
|
|
254
|
+
* global draft that quotes a known project's path is filed with that project.
|
|
255
|
+
*
|
|
256
|
+
* @param draft - the draft about to be stored.
|
|
257
|
+
* @returns the owning project root, or `undefined` when nothing matches.
|
|
258
|
+
*/
|
|
259
|
+
private projectOwningPath;
|
|
260
|
+
/**
|
|
261
|
+
* Titles already stored in the scopes one extraction pass may write to.
|
|
262
|
+
*
|
|
263
|
+
* Project titles come first: they are the ones a pass in this workspace is
|
|
264
|
+
* most likely to be re-deriving, so they are the ones that must survive the
|
|
265
|
+
* cap. Extraction is otherwise blind to what is already known, which is how one
|
|
266
|
+
* session's lesson ended up stored twice — once in Chinese, once in English.
|
|
267
|
+
*
|
|
268
|
+
* @param root - the session's project root, when it has one.
|
|
269
|
+
* @returns existing titles, capped for the prompt.
|
|
270
|
+
*/
|
|
271
|
+
private knownTitles;
|
|
272
|
+
/** Delete one entry. */
|
|
273
|
+
forget(session: Session, scope: MemoryScope, id: string): Promise<boolean>;
|
|
274
|
+
/**
|
|
275
|
+
* Build the injected summary block for one session, or `undefined` when the
|
|
276
|
+
* store is empty or injection is disabled.
|
|
277
|
+
*
|
|
278
|
+
* @param session - session whose scopes to summarize.
|
|
279
|
+
* @returns the framed block, or `undefined` when there is nothing to say.
|
|
280
|
+
*/
|
|
281
|
+
summary(session: Session): Promise<string | undefined>;
|
|
282
|
+
/**
|
|
283
|
+
* Build the injected block and name the entries it lists.
|
|
284
|
+
*
|
|
285
|
+
* The caller needs both: the text enters the conversation, and the entries it
|
|
286
|
+
* names are marked as surfaced, which is what keeps retention from archiving a
|
|
287
|
+
* memory that works so well it never needs a search.
|
|
288
|
+
*
|
|
289
|
+
* Which entries those are is decided by `selectForSummary`, not by the ranker
|
|
290
|
+
* alone: on a scope with more entries than slots the ranking is a fixed point,
|
|
291
|
+
* so pure ranking would list the same memories forever and never surface
|
|
292
|
+
* anything new — including an explicit correction of one of them.
|
|
293
|
+
*
|
|
294
|
+
* @param session - session whose scopes to summarize.
|
|
295
|
+
* @returns the framed block plus the entries it lists, or `undefined`.
|
|
296
|
+
*/
|
|
297
|
+
private summaryWithSurfaced;
|
|
298
|
+
/**
|
|
299
|
+
* The consolidation decisions waiting for a person.
|
|
300
|
+
*
|
|
301
|
+
* @returns one row per decision, newest pass first.
|
|
302
|
+
*/
|
|
303
|
+
disputes(): Promise<readonly ConsolidationDispute[]>;
|
|
304
|
+
/**
|
|
305
|
+
* Accept or reject one waiting decision.
|
|
306
|
+
*
|
|
307
|
+
* Accepting applies only that item — the plan fragment stored beside the row —
|
|
308
|
+
* so a person can take the safe-looking half of a pass without taking all of
|
|
309
|
+
* it. Rejecting changes nothing: the entry stays exactly as it was.
|
|
310
|
+
*
|
|
311
|
+
* @param id - entry id the decision is about.
|
|
312
|
+
* @param decision - `accept` applies it, `reject` drops it.
|
|
313
|
+
* @returns a human-readable outcome, or `undefined` when nothing matched.
|
|
314
|
+
*/
|
|
315
|
+
resolveDispute(id: string, decision: 'accept' | 'reject'): Promise<string | undefined>;
|
|
316
|
+
/** Load the entries of one scope pair, for a single-item apply. */
|
|
317
|
+
private scopeEntries;
|
|
318
|
+
/** Drop one row from the waiting set, clearing the file when it empties. */
|
|
319
|
+
private removeDispute;
|
|
320
|
+
/**
|
|
321
|
+
* Describe the decisions waiting for a person.
|
|
322
|
+
*
|
|
323
|
+
* @returns a human-readable summary, or `undefined` when nothing is staged.
|
|
324
|
+
*/
|
|
325
|
+
pendingPlan(): Promise<string | undefined>;
|
|
326
|
+
/**
|
|
327
|
+
* Apply every waiting decision.
|
|
328
|
+
*
|
|
329
|
+
* @param _parent - the agent asking; the stored rows carry their own scope.
|
|
330
|
+
* @returns a human-readable summary, or `undefined` when nothing is staged.
|
|
331
|
+
*/
|
|
332
|
+
applyPendingPlan(_parent: Agent): Promise<string | undefined>;
|
|
333
|
+
/**
|
|
334
|
+
* The one line this plugin wants in the summary but cannot express as a memory.
|
|
335
|
+
*
|
|
336
|
+
* Staged skill drafts are the only state that needs a human: consolidation
|
|
337
|
+
* produces them, they are invisible to the model (the harness scans its own
|
|
338
|
+
* skill roots, not the memory store), and nothing else ever mentions them
|
|
339
|
+
* again. Measured on a real store: 13 drafts had accumulated over a week and
|
|
340
|
+
* none had ever been promoted, because the only notice was a line in one
|
|
341
|
+
* session's consolidation reply.
|
|
342
|
+
*
|
|
343
|
+
* @returns the note, or `undefined` when nothing is waiting.
|
|
344
|
+
*/
|
|
345
|
+
private draftNote;
|
|
346
|
+
/**
|
|
347
|
+
* Record that these entries entered a conversation.
|
|
348
|
+
*
|
|
349
|
+
* The state database is authoritative and the entry file is only a mirror for
|
|
350
|
+
* a human reader, refreshed at most hourly: rewriting a dozen markdown files
|
|
351
|
+
* on every injection would cost more than the mark is worth.
|
|
352
|
+
*
|
|
353
|
+
* @param session - conversation the entries appeared in.
|
|
354
|
+
* @param entries - the entries shown.
|
|
355
|
+
*/
|
|
356
|
+
private markSurfaced;
|
|
357
|
+
/**
|
|
358
|
+
* Decide what the model should see at this step boundary.
|
|
359
|
+
*
|
|
360
|
+
* The block enters exactly ONCE per conversation: at the first step where the
|
|
361
|
+
* store has something to say. Nothing re-injects afterwards, so a long session
|
|
362
|
+
* pays for its memories once instead of once per turn, and every later recall
|
|
363
|
+
* goes through `memory_search`.
|
|
364
|
+
*
|
|
365
|
+
* "Once" is decided by the CONVERSATION, not by this process: the block is a
|
|
366
|
+
* durable user message, so {@link carriesRecall} answers whether the model can
|
|
367
|
+
* already see one. A restarted harness restores that message with the rest of
|
|
368
|
+
* the history, so it does not inject a second copy; `clear` and `compact`
|
|
369
|
+
* replace the history and therefore legitimately bring the block back (which is
|
|
370
|
+
* why {@link resetInjection} drops this process's cache there).
|
|
371
|
+
*
|
|
372
|
+
* An empty store deliberately leaves the session unmarked: the block should
|
|
373
|
+
* still appear later if the first memory arrives after the session started.
|
|
374
|
+
*
|
|
375
|
+
* @param agent - the agent whose next step is being prepared.
|
|
376
|
+
* @returns the message to enter the conversation, or `undefined` when this
|
|
377
|
+
* conversation already carries one.
|
|
378
|
+
*/
|
|
379
|
+
injectionFor(agent: Agent): Promise<UserMessage | undefined>;
|
|
380
|
+
/**
|
|
381
|
+
* Whether the model-visible history already carries a memory block.
|
|
382
|
+
*
|
|
383
|
+
* `deriveMessages` projects each surface node exactly once and caches the
|
|
384
|
+
* result, so asking is cheap even on a long session. Any failure reads as "no
|
|
385
|
+
* block", whose worst case is one redundant injection — never a failed turn.
|
|
386
|
+
*/
|
|
387
|
+
private carriesRecall;
|
|
388
|
+
/**
|
|
389
|
+
* The conversation's opening user text, as a topic signal for injection.
|
|
390
|
+
*
|
|
391
|
+
* The summary is built before the model has seen anything, so this is the only
|
|
392
|
+
* evidence about what the session is actually for. Plugin-sourced user
|
|
393
|
+
* messages (the injected block itself) are skipped, and the result is capped
|
|
394
|
+
* because it is a relevance hint, not the transcript.
|
|
395
|
+
*
|
|
396
|
+
* @param session - session being injected.
|
|
397
|
+
* @returns the first real user text, or `undefined` when there is none yet.
|
|
398
|
+
*/
|
|
399
|
+
private openingQuery;
|
|
400
|
+
/** Re-arm injection for one session (used on `clear`/`compact` restarts). */
|
|
401
|
+
resetInjection(session: Session): void;
|
|
402
|
+
/**
|
|
403
|
+
* Credit the injected memories this turn is actually about.
|
|
404
|
+
*
|
|
405
|
+
* The ranking's only demand signal used to be "was this memory searched for",
|
|
406
|
+
* which measures lookup-style knowledge — the entries a session goes looking
|
|
407
|
+
* for — and misses the ones that were handed over and silently used. Measured
|
|
408
|
+
* on a real store, the top-read memories were all of the first kind, and the
|
|
409
|
+
* six rules a person had written were never read at all.
|
|
410
|
+
*
|
|
411
|
+
* The gate is the same credit rule the recall path uses, deliberately: a mere
|
|
412
|
+
* shared word must not count, or every injected memory would earn a use in
|
|
413
|
+
* every conversation and the signal would be worthless. Each entry is credited
|
|
414
|
+
* at most once per conversation.
|
|
415
|
+
*
|
|
416
|
+
* @param agent - the agent whose next step is being prepared.
|
|
417
|
+
*/
|
|
418
|
+
creditInjectedUse(agent: Agent): Promise<void>;
|
|
419
|
+
/**
|
|
420
|
+
* At most one archived memory that answers this turn.
|
|
421
|
+
*
|
|
422
|
+
* The archive is a graveyard only if nothing reads it: 70% of what sits there
|
|
423
|
+
* was genuinely used before it was retired, and the recall path is the only
|
|
424
|
+
* thing that could still reach it. One entry, because a retired memory is a
|
|
425
|
+
* weaker claim than a live one and the block has a byte budget.
|
|
426
|
+
*
|
|
427
|
+
* @param session - session whose scopes to search.
|
|
428
|
+
* @param states - the live scopes; the archive is searched per scope.
|
|
429
|
+
* @param query - the turn's text.
|
|
430
|
+
* @param hub - the term discount, when enabled.
|
|
431
|
+
* @returns zero or one retired entry, best first.
|
|
432
|
+
*/
|
|
433
|
+
private archivedFor;
|
|
434
|
+
/**
|
|
435
|
+
* Which query terms are too common in these scopes to count as evidence.
|
|
436
|
+
*
|
|
437
|
+
* Cached against a signature of the store (entry count plus newest update), so
|
|
438
|
+
* a turn costs one comparison and the document-frequency sweep runs only when
|
|
439
|
+
* something was written. Disabled below 20 entries: with a handful of memories
|
|
440
|
+
* "more than a quarter of the scope" is not a meaningful claim about a word.
|
|
441
|
+
*
|
|
442
|
+
* @param states - the scopes this turn can see.
|
|
443
|
+
* @returns the predicate, or `undefined` when the discount is off.
|
|
444
|
+
*/
|
|
445
|
+
private hubFor;
|
|
446
|
+
/**
|
|
447
|
+
* The on-demand recall delta for this step, or `undefined` when nothing is
|
|
448
|
+
* worth adding.
|
|
449
|
+
*
|
|
450
|
+
* `recallMode: 'on-demand'` answers the one real weakness of injecting once:
|
|
451
|
+
* the summary is a snapshot from the start of the conversation, so a memory
|
|
452
|
+
* that only becomes relevant ten turns later stays invisible unless the model
|
|
453
|
+
* thinks to search for it. The delta is deterministic — the same scorer the
|
|
454
|
+
* tool uses, with no extra model call — and bounded three ways: a score
|
|
455
|
+
* threshold, a per-conversation cap, and one entry per block. Every entry it
|
|
456
|
+
* shows is recorded, so a delta never repeats what the summary listed.
|
|
457
|
+
*
|
|
458
|
+
* @param agent - the agent whose next step is being prepared.
|
|
459
|
+
* @returns the message to enter the conversation, or `undefined`.
|
|
460
|
+
*/
|
|
461
|
+
recallFor(agent: Agent): Promise<UserMessage | undefined>;
|
|
462
|
+
/**
|
|
463
|
+
* Original-turn excerpts for a recall, read from this machine's session logs.
|
|
464
|
+
*
|
|
465
|
+
* Only the sessions the recalled memories came from are read (at most two), so
|
|
466
|
+
* the excerpt is about the same conversation as the memory. A missing log or an
|
|
467
|
+
* unreadable one yields no excerpts rather than failing the recall.
|
|
468
|
+
*
|
|
469
|
+
* @param entries - the memories already chosen for this block.
|
|
470
|
+
* @param query - the current user turn.
|
|
471
|
+
* @returns scrubbed excerpts, empty when disabled or unavailable.
|
|
472
|
+
*/
|
|
473
|
+
private rawExcerpts;
|
|
474
|
+
/**
|
|
475
|
+
* Extend the conversation's "already shown" record.
|
|
476
|
+
*
|
|
477
|
+
* The stamp is what a later delta compares entry `updated` times against, so
|
|
478
|
+
* it advances with every injection, not only with the summary.
|
|
479
|
+
*
|
|
480
|
+
* @param session - conversation that was shown entries.
|
|
481
|
+
* @param ids - entry ids the model can now see.
|
|
482
|
+
* @param at - injection time; defaults to now.
|
|
483
|
+
*/
|
|
484
|
+
private recordInjection;
|
|
485
|
+
/**
|
|
486
|
+
* A bounded block naming memories written after this conversation's summary.
|
|
487
|
+
*
|
|
488
|
+
* The summary is a snapshot: a memory extracted or consolidated ten turns
|
|
489
|
+
* later is invisible until the model thinks to search for it. This path names
|
|
490
|
+
* only entries whose `updated` stamp is newer than the last injection, and
|
|
491
|
+
* only those the conversation has not already been shown, so it is a short
|
|
492
|
+
* paragraph rather than a second summary. Two per conversation, 800 bytes
|
|
493
|
+
* each: the block is a nudge, not a channel.
|
|
494
|
+
*
|
|
495
|
+
* @param agent - the agent whose next step is being prepared.
|
|
496
|
+
* @returns the message to append, or `undefined` when nothing new is worth it.
|
|
497
|
+
*/
|
|
498
|
+
deltaFor(agent: Agent): Promise<UserMessage | undefined>;
|
|
499
|
+
/**
|
|
500
|
+
* The title-only rotation block for this conversation, or `undefined`.
|
|
501
|
+
*
|
|
502
|
+
* The summary is bounded by bytes and by a per-scope cap, so on a large store
|
|
503
|
+
* it can only ever name a small minority of entries: measured on the real
|
|
504
|
+
* store at baseline, 58.6% of live memories had never been injected or read.
|
|
505
|
+
* This block spends about 1.6 KB on titles only — never-surfaced entries first
|
|
506
|
+
* (old ones before new), then the longest-unseen — so a dozen more memories
|
|
507
|
+
* become discoverable per conversation and the whole store rotates through
|
|
508
|
+
* over a few dozen sessions.
|
|
509
|
+
*
|
|
510
|
+
* Once at the start of a conversation, then once more every
|
|
511
|
+
* `rotationEveryTurns` user turns: the block is a durable message, so a
|
|
512
|
+
* restarted harness restores it with the history and knows how many were
|
|
513
|
+
* already emitted.
|
|
514
|
+
*
|
|
515
|
+
* @param agent - the agent whose next step is being prepared.
|
|
516
|
+
* @returns the message to append, or `undefined` when nothing is left to rotate.
|
|
517
|
+
*/
|
|
518
|
+
rotationFor(agent: Agent): Promise<UserMessage | undefined>;
|
|
519
|
+
/**
|
|
520
|
+
* How many turns of the conversation the HUMAN wrote.
|
|
521
|
+
*
|
|
522
|
+
* Counted from the durable history, so the cadence survives a restart: a
|
|
523
|
+
* replayed conversation knows it is on turn 41 without this process having
|
|
524
|
+
* seen turns 1-40.
|
|
525
|
+
*/
|
|
526
|
+
private userTurns;
|
|
527
|
+
/**
|
|
528
|
+
* How many rotation blocks the conversation already carries.
|
|
529
|
+
*
|
|
530
|
+
* The block is a durable user message, so after a restart the history is the
|
|
531
|
+
* only honest record of how many were emitted.
|
|
532
|
+
*/
|
|
533
|
+
private rotationBlocks;
|
|
534
|
+
/**
|
|
535
|
+
* The newest user-authored message, which is what the current turn is about.
|
|
536
|
+
*
|
|
537
|
+
* Tool results and this plugin's own injected blocks are skipped: a recall
|
|
538
|
+
* decision must be driven by the human, not by the assistant's output or by
|
|
539
|
+
* the memory block itself.
|
|
540
|
+
*
|
|
541
|
+
* @param session - session to read.
|
|
542
|
+
* @returns the text, or `undefined` when no user message is on the surface.
|
|
543
|
+
*/
|
|
544
|
+
private latestUserText;
|
|
545
|
+
/** Whether memory is switched off for one session. */
|
|
546
|
+
private sessionOff;
|
|
547
|
+
/** Entry ids already shown to one conversation, created on first use. */
|
|
548
|
+
private seenIds;
|
|
549
|
+
/**
|
|
550
|
+
* Whether background passes are paused right now.
|
|
551
|
+
*
|
|
552
|
+
* Codex gates memory work on a provider-reported remaining-quota percentage;
|
|
553
|
+
* DSH exposes no such number, so the gate here is the refusal itself (see
|
|
554
|
+
* {@link noteLimitRefusal}).
|
|
555
|
+
*
|
|
556
|
+
* @returns true while a recorded wait has not elapsed.
|
|
557
|
+
*/
|
|
558
|
+
private backgroundPaused;
|
|
559
|
+
/**
|
|
560
|
+
* Pause background passes after a provider refused for quota or rate.
|
|
561
|
+
*
|
|
562
|
+
* Only refusals pause: a malformed reply, a timeout, or a missing route says
|
|
563
|
+
* nothing about the account's remaining quota, and treating them as refusals
|
|
564
|
+
* would stop extraction for reasons the cooldown cannot fix.
|
|
565
|
+
*
|
|
566
|
+
* @param error - the failure thrown by an extraction or consolidation call.
|
|
567
|
+
*/
|
|
568
|
+
private noteLimitRefusal;
|
|
569
|
+
/**
|
|
570
|
+
* Record that a session was used just now.
|
|
571
|
+
*
|
|
572
|
+
* This is the input the `maxAgeDays` gate reads. It is deliberately separate
|
|
573
|
+
* from the extraction watermark: a session can be used for days without ever
|
|
574
|
+
* being mined (background extraction needs a long-lived process), and the age
|
|
575
|
+
* gate must still see it as recent.
|
|
576
|
+
*/
|
|
577
|
+
recordActivity(session: Session, now?: number): void;
|
|
578
|
+
/** Whether one session is eligible for extraction (scope and configuration). */
|
|
579
|
+
private eligible;
|
|
580
|
+
/**
|
|
581
|
+
* Whether a session is still young enough to mine.
|
|
582
|
+
*
|
|
583
|
+
* `maxAgeDays` keeps a pass from resurrecting very old conversations: past
|
|
584
|
+
* that horizon a fact is more likely stale than useful, and mining it costs
|
|
585
|
+
* quota. The clock is the session's last observed activity (see
|
|
586
|
+
* {@link recordActivity}), not its watermark — a session that was never mined
|
|
587
|
+
* would otherwise read as infinitely young and the gate would never fire.
|
|
588
|
+
*
|
|
589
|
+
* A session with no recorded activity yet is treated as fresh.
|
|
590
|
+
*/
|
|
591
|
+
private withinAge;
|
|
592
|
+
/**
|
|
593
|
+
* Schedule the idle-time extraction pass for a settled agent.
|
|
594
|
+
*
|
|
595
|
+
* The timer is unref'd, so a background pass never keeps an otherwise finished
|
|
596
|
+
* process alive. That means a one-shot run (a headless task, a script) is
|
|
597
|
+
* normally gone before the pass could fire; extraction is a feature of
|
|
598
|
+
* long-lived surfaces such as `dsh web`, where the session is still open long
|
|
599
|
+
* after the user stopped typing. {@link flushExit} covers the remaining case
|
|
600
|
+
* as far as the process lifecycle allows.
|
|
601
|
+
*/
|
|
602
|
+
scheduleExtraction(agent: Agent): void;
|
|
603
|
+
/**
|
|
604
|
+
* Arm (or re-arm) one agent's settle timer.
|
|
605
|
+
*
|
|
606
|
+
* Kept separate from {@link scheduleExtraction} because a re-arm must not touch
|
|
607
|
+
* `idleSince`: deferring a pass out of the peak window and then resetting the
|
|
608
|
+
* quiet-window clock would push the pass back by the full window every time.
|
|
609
|
+
*
|
|
610
|
+
* @param agent - the agent whose pass is being waited for.
|
|
611
|
+
* @param delayMs - how long to wait.
|
|
612
|
+
*/
|
|
613
|
+
private armTimer;
|
|
614
|
+
/**
|
|
615
|
+
* The bookkeeping every pass shares once it has run.
|
|
616
|
+
*
|
|
617
|
+
* New material is what makes a consolidation pass worth running; retention
|
|
618
|
+
* costs no quota and needs no new material, so it runs on its own interval.
|
|
619
|
+
*
|
|
620
|
+
* @param agent - the session's agent.
|
|
621
|
+
* @param stored - how many drafts the pass stored.
|
|
622
|
+
*/
|
|
623
|
+
private afterPass;
|
|
624
|
+
/**
|
|
625
|
+
* (Re)start the periodic check from the current settings.
|
|
626
|
+
*
|
|
627
|
+
* Idempotent, so the settings watcher can call it on every commit: the old
|
|
628
|
+
* timer is cleared first, and an interval of `0` simply leaves none running.
|
|
629
|
+
*/
|
|
630
|
+
startPeriodicExtraction(): void;
|
|
631
|
+
/** Stop the periodic check, if one is running. */
|
|
632
|
+
stopPeriodicExtraction(): void;
|
|
633
|
+
/** Start (or restart) the store's background git sync from the current settings. */
|
|
634
|
+
startPeriodicSync(): void;
|
|
635
|
+
/** Stop the store's background sync. */
|
|
636
|
+
stopPeriodicSync(): void;
|
|
637
|
+
/** Record that a memory changed; the commit and the network happen later. */
|
|
638
|
+
private markStoreChanged;
|
|
639
|
+
/** The periodic check's timer, when one is armed. */
|
|
640
|
+
private periodicTimer;
|
|
641
|
+
/** The store's git transport; see {@link StoreSyncService}. */
|
|
642
|
+
private readonly storeSync;
|
|
643
|
+
/**
|
|
644
|
+
* Mine every open session that has something new, in slices.
|
|
645
|
+
*
|
|
646
|
+
* This is what keeps a long working session from losing its middle: a
|
|
647
|
+
* settle-only pass reads the newest slice once and then moves the watermark
|
|
648
|
+
* past everything before it, so those messages are never mined. The idle window
|
|
649
|
+
* is deliberately not consulted here — the point is to capture while the
|
|
650
|
+
* session is still running — but peak hours and the quota gate still are, and
|
|
651
|
+
* `runMaintenance` inside {@link mine} waits for a natural gap instead of
|
|
652
|
+
* racing the conversation.
|
|
653
|
+
*
|
|
654
|
+
* A session with nothing new costs no model call.
|
|
655
|
+
*
|
|
656
|
+
* The pass reports itself in one line, and at info at least once an hour even
|
|
657
|
+
* when it did nothing. Without that, every gate that skips work (quota pause,
|
|
658
|
+
* no new material, an ineligible or already-running session, a missing service)
|
|
659
|
+
* left a trace only at the level the file is configured to drop, and "is the
|
|
660
|
+
* background extractor alive at all?" had no answer a reader could act on.
|
|
661
|
+
*/
|
|
662
|
+
runPeriodicPass(): Promise<void>;
|
|
663
|
+
/** Live agents from the harness registry, when the deployment composes one. */
|
|
664
|
+
private liveAgents;
|
|
665
|
+
/**
|
|
666
|
+
* When a session was last seen working, for the "newest first" ordering.
|
|
667
|
+
*
|
|
668
|
+
* The state database is the authority (every status transition writes it);
|
|
669
|
+
* a session the store has never seen falls back to when it was created.
|
|
670
|
+
*/
|
|
671
|
+
private activityOf;
|
|
672
|
+
/** When the pass last reported itself at info level. */
|
|
673
|
+
private lastPassReportAt;
|
|
674
|
+
/**
|
|
675
|
+
* Record one periodic pass.
|
|
676
|
+
*
|
|
677
|
+
* At info when it changed something, failed, or an hour has passed since the
|
|
678
|
+
* last info report; at decision level otherwise. The hourly heartbeat is the
|
|
679
|
+
* point: a pass that does nothing is still evidence, and without it a stall
|
|
680
|
+
* (every session skipped for a reason nobody can see) is indistinguishable
|
|
681
|
+
* from a plugin that never ran.
|
|
682
|
+
*/
|
|
683
|
+
private reportPass;
|
|
684
|
+
/**
|
|
685
|
+
* Run the consolidation pass when its cooldown has elapsed.
|
|
686
|
+
*
|
|
687
|
+
* The pass needs a parent agent for the subagent seam and is process-level, so
|
|
688
|
+
* any settled agent serves; a pass already in flight is skipped because the
|
|
689
|
+
* job lease is exclusive.
|
|
690
|
+
*/
|
|
691
|
+
private consolidateIfDue;
|
|
692
|
+
/** When each agent last entered `idle`; cleared whenever it wakes. */
|
|
693
|
+
private readonly idleSince;
|
|
694
|
+
/**
|
|
695
|
+
* Whether a settled agent has been quiet long enough for `minIdleHours`.
|
|
696
|
+
*
|
|
697
|
+
* The idle timer already waits `autoExtractIdleMs`; this is the second,
|
|
698
|
+
* independent gate Codex applies — a session that keeps being resumed is not
|
|
699
|
+
* a finished conversation, so its facts are still moving.
|
|
700
|
+
*/
|
|
701
|
+
private idleEnough;
|
|
702
|
+
/**
|
|
703
|
+
* Run one extraction as an agent maintenance task.
|
|
704
|
+
*
|
|
705
|
+
* `agent.runMaintenance` claims the true idle phase, so a wake that arrives
|
|
706
|
+
* while the pass runs is queued behind it instead of racing it, and the pass
|
|
707
|
+
* is cancelled if the agent is torn down. A pass that cannot claim the idle
|
|
708
|
+
* phase is skipped; the next settle pass tries again.
|
|
709
|
+
*
|
|
710
|
+
* @param agent - the settled agent to mine.
|
|
711
|
+
* @param options - which gates to ignore. The exit flush passes
|
|
712
|
+
* `ignoreIdleWindow` (a session being torn down is finished by definition)
|
|
713
|
+
* but still respects peak hours, because it is an automatic spend.
|
|
714
|
+
* @returns how many drafts were stored, and which gate refused when none were.
|
|
715
|
+
*/
|
|
716
|
+
private mine;
|
|
717
|
+
/** Cancel a pending extraction timer. */
|
|
718
|
+
cancelExtraction(agent: Agent): void;
|
|
719
|
+
/** Remember an agent so a process exit can still mine it. */
|
|
720
|
+
private track;
|
|
721
|
+
/**
|
|
722
|
+
* Mine every tracked agent once, right now.
|
|
723
|
+
*
|
|
724
|
+
* Called at the disposal boundary and from `beforeExit`: a one-shot run (a
|
|
725
|
+
* headless task, a script) finishes long before the idle timer fires, and
|
|
726
|
+
* without this the session would never be mined — and its watermark would
|
|
727
|
+
* never advance, so every later run would re-read the same transcript.
|
|
728
|
+
*
|
|
729
|
+
* Each call is bounded, so it cannot hang a shutdown beyond the budget, and a
|
|
730
|
+
* session is mined at most once per process.
|
|
731
|
+
*
|
|
732
|
+
* @param timeoutMs - budget for the whole flush.
|
|
733
|
+
* @returns how many drafts were stored across every flushed session.
|
|
734
|
+
*/
|
|
735
|
+
flushExit(timeoutMs?: number): Promise<number>;
|
|
736
|
+
/**
|
|
737
|
+
* What a capped reply blamed: the ceiling and the route the log points at.
|
|
738
|
+
*
|
|
739
|
+
* Stored with the cooldown so that changing either one — the fix the log line
|
|
740
|
+
* asks for — retires the verdict immediately. Without it a user who raises
|
|
741
|
+
* `extractMaxOutputTokens` and watches the next pass report `capped` has been
|
|
742
|
+
* told the knob did nothing.
|
|
743
|
+
*/
|
|
744
|
+
private cappedCause;
|
|
745
|
+
/**
|
|
746
|
+
* How long before this session may be fed to the extractor again, or `0` now.
|
|
747
|
+
*
|
|
748
|
+
* @param key - session id.
|
|
749
|
+
* @returns milliseconds left of the cooldown.
|
|
750
|
+
*/
|
|
751
|
+
private cappedWaitMs;
|
|
752
|
+
/**
|
|
753
|
+
* Record a capped reply and return the wait before the next attempt.
|
|
754
|
+
*
|
|
755
|
+
* @param key - session id.
|
|
756
|
+
* @returns milliseconds of cooldown now in force.
|
|
757
|
+
*/
|
|
758
|
+
private noteCapped;
|
|
759
|
+
/**
|
|
760
|
+
* Whether a session has nothing after its watermark.
|
|
761
|
+
*
|
|
762
|
+
* The check exists so a flush (or a periodic tick) does not spend a model call
|
|
763
|
+
* to learn that there is nothing to read: walking the surface is free.
|
|
764
|
+
*
|
|
765
|
+
* @param session - session to inspect.
|
|
766
|
+
* @returns true when there is nothing new to mine.
|
|
767
|
+
*/
|
|
768
|
+
private hasNothingNew;
|
|
769
|
+
/** Agents that have settled at least once and may need an exit flush. */
|
|
770
|
+
private readonly tracked;
|
|
771
|
+
/** Whether the process-exit flush hook is installed. */
|
|
772
|
+
private exitFlushInstalled;
|
|
773
|
+
/**
|
|
774
|
+
* Best-effort flush of every tracked session.
|
|
775
|
+
*
|
|
776
|
+
* The primary pass is the settle timer; this exists as a safety net for a
|
|
777
|
+
* natural process exit, where the tree may already be disposed and the LLM
|
|
778
|
+
* service gone. Registered on the process rather than through `ctx.effect`,
|
|
779
|
+
* because an effect disposer runs during teardown — exactly when the flush
|
|
780
|
+
* must still be armed.
|
|
781
|
+
*/
|
|
782
|
+
private installExitFlush;
|
|
783
|
+
/** Bound `beforeExit` handler. */
|
|
784
|
+
private readonly exitFlush;
|
|
785
|
+
/**
|
|
786
|
+
* Mine one session's transcript tail and store what it yields.
|
|
787
|
+
*
|
|
788
|
+
* Marks the session as mined for this process even when there was nothing new
|
|
789
|
+
* to store, so the exit flush cannot repeat a call that already ran.
|
|
790
|
+
*
|
|
791
|
+
* @param agent - the settled agent to mine.
|
|
792
|
+
* @param budget - optional outer cancellation (a settle-window or shutdown deadline).
|
|
793
|
+
* @param force - skip the "is the agent idle" gate; used by the exit flush and
|
|
794
|
+
* by `/memories mine`, where the caller has already decided to spend the call.
|
|
795
|
+
* @returns how many drafts were stored, and which gate refused when none were.
|
|
796
|
+
*/
|
|
797
|
+
runExtraction(agent: Agent, budget?: AbortSignal, force?: boolean): Promise<{
|
|
798
|
+
stored: number;
|
|
799
|
+
reason?: MineSkip;
|
|
800
|
+
}>;
|
|
801
|
+
/** Force an extraction now, ignoring the idle timer and the quiet window (used by `/memories mine`). */
|
|
802
|
+
mineNow(agent: Agent): Promise<number>;
|
|
803
|
+
/**
|
|
804
|
+
* Mine conversations that were persisted before this process ever saw them.
|
|
805
|
+
*
|
|
806
|
+
* The live extractor only reads sessions registered in this process, so a
|
|
807
|
+
* conversation that ended before install — or before this process started —
|
|
808
|
+
* is never mined. The logs under `<dshHome>/sessions` still hold the
|
|
809
|
+
* transcript, so this pass decodes them, cuts the same bounded windows the
|
|
810
|
+
* live path uses, and runs the same extraction prompt and store write.
|
|
811
|
+
*
|
|
812
|
+
* Dry run by default: each window is a paid model call, and the caller is the
|
|
813
|
+
* only one who can decide to spend it.
|
|
814
|
+
*
|
|
815
|
+
* @param session - the session that asked; used to skip itself.
|
|
816
|
+
* @param options - `apply` spends calls, `days` bounds log age, `limit`
|
|
817
|
+
* bounds how many sessions one run handles.
|
|
818
|
+
* @returns a human-readable report of what was planned or mined.
|
|
819
|
+
*/
|
|
820
|
+
backfill(session: Session, options: {
|
|
821
|
+
apply: boolean;
|
|
822
|
+
days: number;
|
|
823
|
+
limit: number;
|
|
824
|
+
}): Promise<string>;
|
|
825
|
+
/** Store one backfilled draft, with the same scope rule the live path uses. */
|
|
826
|
+
private persistBackfill;
|
|
827
|
+
/**
|
|
828
|
+
* Mark the global consolidation job dirty.
|
|
829
|
+
*
|
|
830
|
+
* Enqueueing is cheap and only sets a flag: the pass itself runs on the
|
|
831
|
+
* cooldown, so a burst of new memories produces one consolidation, not one
|
|
832
|
+
* per write.
|
|
833
|
+
*
|
|
834
|
+
* @param now - clock for the enqueue timestamp.
|
|
835
|
+
* @param readyNow - skip the cooldown (a manual pass), so the claim that
|
|
836
|
+
* follows can succeed immediately.
|
|
837
|
+
* @param root - workspace root whose project scope this pass should cover;
|
|
838
|
+
* recorded so a later pass does not consolidate a different workspace.
|
|
839
|
+
*/
|
|
840
|
+
enqueueConsolidation(now?: number, readyNow?: boolean, root?: string): void;
|
|
841
|
+
/**
|
|
842
|
+
* Run one consolidation pass if the cooldown has elapsed.
|
|
843
|
+
*
|
|
844
|
+
* The pass produces a merged plan as JSON; this method is the only writer.
|
|
845
|
+
* Every failure is contained and backed off, so a broken pass never damages
|
|
846
|
+
* the store and never retries in a hot loop.
|
|
847
|
+
*
|
|
848
|
+
* @param parent - an agent whose subagent seam and lineage the pass uses.
|
|
849
|
+
* @param options - `apply` writes the result; the default only proposes it.
|
|
850
|
+
* @returns a human-readable summary, or `undefined` when nothing ran.
|
|
851
|
+
*/
|
|
852
|
+
/** Why the last {@link consolidateNow} declined, for `/memories consolidate` to report. */
|
|
853
|
+
get consolidateSkipReason(): string | undefined;
|
|
854
|
+
consolidateNow(parent: Agent, options?: {
|
|
855
|
+
apply?: boolean;
|
|
856
|
+
force?: boolean;
|
|
857
|
+
}): Promise<string | undefined>;
|
|
858
|
+
/**
|
|
859
|
+
* Run one consolidation pass and return the plan it produced.
|
|
860
|
+
*
|
|
861
|
+
* Three routes, in order of preference:
|
|
862
|
+
*
|
|
863
|
+
* 1. The 0.2.1-rc.2 subagent seam, with this plugin's own tool-free preset:
|
|
864
|
+
* the child runs as a real agent that owns no tools.
|
|
865
|
+
* 2. The pre-0.2.1 seam, whose request still carries a tool filter.
|
|
866
|
+
* 3. A plain model call that owns no tools at all.
|
|
867
|
+
*
|
|
868
|
+
* The third route is not a weaker guarantee: a model handed no tool list
|
|
869
|
+
* cannot write, shell out, or delegate, which is the same property the old
|
|
870
|
+
* deny list bought. It exists because the first two need services this
|
|
871
|
+
* plugin cannot assume — the preset registry and delegation are both
|
|
872
|
+
* optional — and a pass that cannot run must leave the store alone and say
|
|
873
|
+
* so, not fail with an exception.
|
|
874
|
+
*
|
|
875
|
+
* @param parent - the agent whose lineage and route the pass uses.
|
|
876
|
+
* @param entries - the memories to review.
|
|
877
|
+
* @param root - the workspace root whose project scope is in scope.
|
|
878
|
+
* @returns the plan, or `undefined` when no route produced one.
|
|
879
|
+
*/
|
|
880
|
+
/**
|
|
881
|
+
* Speak without being asked, when there is something to say.
|
|
882
|
+
*
|
|
883
|
+
* Two deterministic triggers only, for now: a daily line about what the plugin
|
|
884
|
+
* maintained, and a warning when decisions have waited long enough that the
|
|
885
|
+
* pending panel will drop them. Both are judgements a rule can make, which is
|
|
886
|
+
* why they are the first ones allowed to interrupt. Everything smarter (open
|
|
887
|
+
* loops, reflections) enters here later through the same queue, and the same
|
|
888
|
+
* rules apply: evidence or silence, and never the same subject twice.
|
|
889
|
+
*
|
|
890
|
+
* Called from the once-per-conversation hook and from the maintenance sweep. A
|
|
891
|
+
* failure is logged and swallowed: speaking is never allowed to break a turn.
|
|
892
|
+
*/
|
|
893
|
+
private pumpNotices;
|
|
894
|
+
/**
|
|
895
|
+
* Fold the promises one extraction found into the open-loop ledger.
|
|
896
|
+
*
|
|
897
|
+
* Kept separate from `persist` because a loop is not a memory: it has a
|
|
898
|
+
* lifecycle and a deadline, it is never recalled by retrieval, and its id must
|
|
899
|
+
* stay stable across rewrites so one promise cannot become three reminders.
|
|
900
|
+
*/
|
|
901
|
+
private recordLoops;
|
|
902
|
+
/**
|
|
903
|
+
* Synthesize a few observations, at most once a week.
|
|
904
|
+
*
|
|
905
|
+
* Runs on the maintenance path, writes its own files, and never touches the
|
|
906
|
+
* memories it read. The interval and the material threshold are both hard
|
|
907
|
+
* requirements rather than tunables: a reflection is only worth having when
|
|
908
|
+
* something has accumulated, and one written weekly from three memories is the
|
|
909
|
+
* same generic sentence forever.
|
|
910
|
+
*/
|
|
911
|
+
private runReflectionIfDue;
|
|
912
|
+
/**
|
|
913
|
+
* Send one deliberate notification, so the channel can be checked on demand.
|
|
914
|
+
*
|
|
915
|
+
* The digest is once a day and the backlog warning needs a pending plan, so
|
|
916
|
+
* without this the only way to find out whether notifications arrive at all is
|
|
917
|
+
* to wait up to 24 hours for a real notice. Never queued: a probe is not a
|
|
918
|
+
* notice and must not spend the daily guard rail.
|
|
919
|
+
*
|
|
920
|
+
* @returns whether the operating system accepted it.
|
|
921
|
+
*/
|
|
922
|
+
probeNotification(): Promise<{
|
|
923
|
+
ok: boolean;
|
|
924
|
+
reason?: string;
|
|
925
|
+
}>;
|
|
926
|
+
/** The notice queue as one short block, for the command. */
|
|
927
|
+
describeNotices(): Promise<string>;
|
|
928
|
+
/**
|
|
929
|
+
* Record a person's answer to one notice.
|
|
930
|
+
*
|
|
931
|
+
* The plugin has no other way to learn whether a reminder was useful: without
|
|
932
|
+
* this, the acted/dismissed counters stay at zero forever and the only signal
|
|
933
|
+
* left is whether the user complained. Logged at info so the record survives the
|
|
934
|
+
* command output.
|
|
935
|
+
*
|
|
936
|
+
* @param idOrPrefix - full id or unique prefix.
|
|
937
|
+
* @param outcome - acted, dismissed, or snoozed.
|
|
938
|
+
* @returns the answered notice, or why nothing matched.
|
|
939
|
+
*/
|
|
940
|
+
answerNotice(idOrPrefix: string, outcome: 'acted' | 'dismissed' | 'snoozed'): Promise<{
|
|
941
|
+
title?: string;
|
|
942
|
+
reason?: string;
|
|
943
|
+
}>;
|
|
944
|
+
/** Count what the plugin did since one timestamp, from its own log. */
|
|
945
|
+
private maintenanceCounts;
|
|
946
|
+
/**
|
|
947
|
+
* Adjudicate the flagged changes, when a person is not the right answer.
|
|
948
|
+
*
|
|
949
|
+
* The determinism this replaces was not neutral: on a real store every proposal
|
|
950
|
+
* waited on the panel because the entry had been read once, and the panel is
|
|
951
|
+
* only answered when somebody remembers it exists — an unanswered question goes
|
|
952
|
+
* stale and gets dropped. "Keep both copies" is the safe outcome for an AI that
|
|
953
|
+
* is unsure, and it is exactly the outcome of a re-read.
|
|
954
|
+
*
|
|
955
|
+
* Hard stops are filtered out here and never reach the child: permanence,
|
|
956
|
+
* a person's own words are promises, not judgements.
|
|
957
|
+
*
|
|
958
|
+
* @param parent - the agent whose seam runs the child.
|
|
959
|
+
* @param plan - the pass's full plan, for the bodies a rewrite would apply.
|
|
960
|
+
* @param safe - cleared plan, mutated in place with accepted verdicts.
|
|
961
|
+
* @param flagged - every dispute the classifier raised.
|
|
962
|
+
* @param entries - the reviewed page, for the request.
|
|
963
|
+
* @param root - project scope this pass covers.
|
|
964
|
+
* @returns the disputes that still need a person.
|
|
965
|
+
*/
|
|
966
|
+
private decideFlagged;
|
|
967
|
+
private runConsolidationPass;
|
|
968
|
+
/**
|
|
969
|
+
* The store, narrowed to the write surface consolidation needs.
|
|
970
|
+
*
|
|
971
|
+
* The adapter drops `upsert`'s clock parameter so the target's `keepId` is the
|
|
972
|
+
* fourth argument, matching the consolidation contract.
|
|
973
|
+
*/
|
|
974
|
+
private consolidationTarget;
|
|
975
|
+
/**
|
|
976
|
+
* Run the periodic maintenance sweep when its interval has elapsed.
|
|
977
|
+
*
|
|
978
|
+
* Retention is deterministic and costs no quota, so unlike extraction it needs
|
|
979
|
+
* no live conversation — just a store and a clock. Running it here, and once
|
|
980
|
+
* at startup before any session exists, is what makes "unused memories
|
|
981
|
+
* eventually archive" true in a workspace that never happens to produce a new
|
|
982
|
+
* memory: the pass stops being a side effect of extraction succeeding.
|
|
983
|
+
*
|
|
984
|
+
* @param now - injected clock.
|
|
985
|
+
* @returns how many entries were archived.
|
|
986
|
+
*/
|
|
987
|
+
sweepIfDue(now?: number): Promise<number>;
|
|
988
|
+
/** Run retention now, ignoring the interval (used by `/memories sweep`). */
|
|
989
|
+
sweepNow(now?: number): Promise<number>;
|
|
990
|
+
/**
|
|
991
|
+
* Queue a consolidation pass if one is not already waiting and there is work.
|
|
992
|
+
*
|
|
993
|
+
* @param now - clock.
|
|
994
|
+
* @returns whether a pass was queued.
|
|
995
|
+
*/
|
|
996
|
+
private queueConsolidation;
|
|
997
|
+
/**
|
|
998
|
+
* Every memory that cites a path no longer present in any known checkout.
|
|
999
|
+
*
|
|
1000
|
+
* The full scan, without a session: the periodic sweep has no workspace of its
|
|
1001
|
+
* own, so it checks each project's memories against that project's root (plus
|
|
1002
|
+
* the harness home) and global memories against the harness home.
|
|
1003
|
+
*
|
|
1004
|
+
* @returns one row per flagged memory, most specific scope first.
|
|
1005
|
+
*/
|
|
1006
|
+
private staleRows;
|
|
1007
|
+
/**
|
|
1008
|
+
* How many memories cite a path that no longer resolves, for the sweep line.
|
|
1009
|
+
*
|
|
1010
|
+
* @returns the count.
|
|
1011
|
+
*/
|
|
1012
|
+
private countStale;
|
|
1013
|
+
/**
|
|
1014
|
+
* How many memories have never been injected and never read.
|
|
1015
|
+
*
|
|
1016
|
+
* Retention is purely age-based, so on a young store nothing is old enough to
|
|
1017
|
+
* archive and a large unseen tail can sit there with nothing to say so —
|
|
1018
|
+
* measured on a real store twelve days in, 100 of 346 entries had never been
|
|
1019
|
+
* injected into a session nor returned by the tool. The count, plus the age of
|
|
1020
|
+
* the oldest, is what separates "recent entries nobody needed yet" from "the
|
|
1021
|
+
* ranking never reaches these".
|
|
1022
|
+
*
|
|
1023
|
+
* @returns the never-seen count, the store size, and the oldest never-seen age in days.
|
|
1024
|
+
*/
|
|
1025
|
+
private neverSeen;
|
|
1026
|
+
/**
|
|
1027
|
+
* Surface coverage per scope, for `/memories stats`.
|
|
1028
|
+
*
|
|
1029
|
+
* "Seen" means the entry was ever injected into a session or returned by the
|
|
1030
|
+
* tool. The count is what the exposure-rotation work is judged by, and it is
|
|
1031
|
+
* reported per scope because they move independently: a project entry only
|
|
1032
|
+
* rotates in sessions opened in that workspace, while the global half can be
|
|
1033
|
+
* shown anywhere.
|
|
1034
|
+
*
|
|
1035
|
+
* @returns seen/total per scope, plus the age of the oldest never-seen entry.
|
|
1036
|
+
*/
|
|
1037
|
+
private coverageByScope;
|
|
1038
|
+
/**
|
|
1039
|
+
* Apply retention to one scope.
|
|
1040
|
+
*
|
|
1041
|
+
* @param scope - scope to sweep.
|
|
1042
|
+
* @param root - workspace root for a project scope.
|
|
1043
|
+
* @param now - injected clock.
|
|
1044
|
+
* @returns how many entries were archived.
|
|
1045
|
+
*/
|
|
1046
|
+
private retain;
|
|
1047
|
+
/** One line describing the sweep schedule, for `/memories stats`. */
|
|
1048
|
+
private sweepLine;
|
|
1049
|
+
/**
|
|
1050
|
+
* Record one failed `/memories` invocation.
|
|
1051
|
+
*
|
|
1052
|
+
* The command facade returns an error RESULT instead of letting an exception
|
|
1053
|
+
* cross into the harness; this is where the same failure stays visible in the
|
|
1054
|
+
* plugin's own log.
|
|
1055
|
+
*/
|
|
1056
|
+
noteCommandFailure(name: string, error: unknown): void;
|
|
1057
|
+
/**
|
|
1058
|
+
* Record one failed injection attempt.
|
|
1059
|
+
*
|
|
1060
|
+
* Called from the pre-step seam, which runs on every step of every turn: the
|
|
1061
|
+
* turn continues without the memory block rather than failing, and the reason
|
|
1062
|
+
* stays in the log.
|
|
1063
|
+
*/
|
|
1064
|
+
notePreStepFailure(sessionId: string, error: unknown): void;
|
|
1065
|
+
/** One line describing how much of the store has ever reached a session. */
|
|
1066
|
+
private exposureLine;
|
|
1067
|
+
/**
|
|
1068
|
+
* Warn about tunables whose text did not parse.
|
|
1069
|
+
*
|
|
1070
|
+
* A `peakHours` typo silently disables the whole restriction — exactly the kind
|
|
1071
|
+
* of quiet failure this plugin keeps working to avoid — so the settings watcher
|
|
1072
|
+
* calls this and a bad edit says so immediately.
|
|
1073
|
+
*/
|
|
1074
|
+
reportSettingsIssues(): void;
|
|
1075
|
+
/** Where this plugin's log is going, or why it is not. */
|
|
1076
|
+
private logDestination;
|
|
1077
|
+
/**
|
|
1078
|
+
* One line describing the peak-hours rule, for `/memories stats`.
|
|
1079
|
+
*
|
|
1080
|
+
* It reports whether a pass would be deferred *right now*, because that is the
|
|
1081
|
+
* question somebody reading the line is actually asking ("why isn't it
|
|
1082
|
+
* mining?").
|
|
1083
|
+
*/
|
|
1084
|
+
private peakLine;
|
|
1085
|
+
/** This session's memory switch. */
|
|
1086
|
+
sessionMode(session: Session): SessionMode;
|
|
1087
|
+
/**
|
|
1088
|
+
* Turn memory off or on for one session.
|
|
1089
|
+
*
|
|
1090
|
+
* Per session rather than global: the useful case is "this repository is full
|
|
1091
|
+
* of credentials, remember nothing from it", and a switch that silenced every
|
|
1092
|
+
* other project too would be the wrong shape.
|
|
1093
|
+
*
|
|
1094
|
+
* @param session - session to change.
|
|
1095
|
+
* @param value - `on`, `off`, or anything else to report the current state.
|
|
1096
|
+
* @returns a human-readable confirmation.
|
|
1097
|
+
*/
|
|
1098
|
+
setSessionMode(session: Session, value: string): string;
|
|
1099
|
+
/** List one scope's archived entries. */
|
|
1100
|
+
archived(session: Session, scope: MemoryScope): Promise<string>;
|
|
1101
|
+
/**
|
|
1102
|
+
* Restore one archived entry, project scope first.
|
|
1103
|
+
*
|
|
1104
|
+
* @param session - session whose workspace to search.
|
|
1105
|
+
* @param id - entry id.
|
|
1106
|
+
* @returns a human-readable outcome.
|
|
1107
|
+
*/
|
|
1108
|
+
restore(session: Session, id: string): Promise<string>;
|
|
1109
|
+
/** One line describing whether background passes are running, for `/memories stats`. */
|
|
1110
|
+
private backgroundLine;
|
|
1111
|
+
/** A one-line status used by `/memories` and diagnostics. */
|
|
1112
|
+
stats(session: Session): Promise<string>;
|
|
1113
|
+
/**
|
|
1114
|
+
* One line describing project scopes and any basename collision.
|
|
1115
|
+
*
|
|
1116
|
+
* A slug is the project name, so two unrelated repositories of the same name
|
|
1117
|
+
* share one directory; their recorded git origins are the proof. The line is
|
|
1118
|
+
* diagnostic, not a repair: which of the two a memory belongs to cannot be
|
|
1119
|
+
* recovered after the merge, so it has to be seen rather than guessed.
|
|
1120
|
+
*/
|
|
1121
|
+
private projectLine;
|
|
1122
|
+
/**
|
|
1123
|
+
* Warning text for the entries a summary is about to list.
|
|
1124
|
+
*
|
|
1125
|
+
* Only the entries that actually reach the model are checked, which is what
|
|
1126
|
+
* makes a filesystem check affordable on every injection: a handful of paths
|
|
1127
|
+
* instead of the whole store. Roots are the workspace the session is in plus
|
|
1128
|
+
* the harness home, because a memory states paths relative to the repository it
|
|
1129
|
+
* is about.
|
|
1130
|
+
*
|
|
1131
|
+
* @param session - session whose summary is being built.
|
|
1132
|
+
* @param entries - the entries the summary will list.
|
|
1133
|
+
* @returns entry id → warning clause, empty when nothing is stale.
|
|
1134
|
+
*/
|
|
1135
|
+
private citationFlags;
|
|
1136
|
+
/**
|
|
1137
|
+
* List every memory that cites a file which no longer resolves.
|
|
1138
|
+
*
|
|
1139
|
+
* The injected block only warns about what it is showing; this is the full
|
|
1140
|
+
* sweep, so a stale reference can be found and fixed before it misleads a
|
|
1141
|
+
* session that never happened to list it.
|
|
1142
|
+
*
|
|
1143
|
+
* @param session - session whose scopes to scan.
|
|
1144
|
+
* @returns a human-readable report.
|
|
1145
|
+
*/
|
|
1146
|
+
stale(session: Session): Promise<string>;
|
|
1147
|
+
/**
|
|
1148
|
+
* One line describing where consolidation stands, for `/memories stats`.
|
|
1149
|
+
*
|
|
1150
|
+
* A staged proposal is the one piece of maintenance state that needs a person,
|
|
1151
|
+
* and it is otherwise invisible: the background pass produces it and then waits.
|
|
1152
|
+
*
|
|
1153
|
+
* @returns the line.
|
|
1154
|
+
*/
|
|
1155
|
+
private consolidationLine;
|
|
1156
|
+
/** Render one scope's entries for a human-facing command. */
|
|
1157
|
+
list(session: Session, scope: MemoryScope): Promise<string>;
|
|
1158
|
+
/** List the staged skill drafts that still need a person. */
|
|
1159
|
+
skills(): Promise<string>;
|
|
1160
|
+
/** Copy one staged draft into the harness skill root. */
|
|
1161
|
+
promoteSkill(name: string): Promise<string>;
|
|
1162
|
+
/** Delete one staged draft. */
|
|
1163
|
+
discardSkill(name: string): Promise<string>;
|
|
1164
|
+
}
|
|
1165
|
+
/**
|
|
1166
|
+
* Register the memory tool, the injector, the idle extractor, and `/memories`.
|
|
1167
|
+
*
|
|
1168
|
+
* The tunables live in this plugin's own entry config, marked live in
|
|
1169
|
+
* {@link Config}: that is what puts them in the DSH settings surface and what
|
|
1170
|
+
* makes a committed write take effect on the next read — no restart.
|
|
1171
|
+
*
|
|
1172
|
+
* @param ctx - the plugin context.
|
|
1173
|
+
* @param config - entry configuration (paths, workspace discovery, tunables).
|
|
1174
|
+
*/
|
|
1175
|
+
export declare function apply(ctx: Context, config?: MemoriesConfig): void;
|
|
1176
|
+
/** Loader schema re-exported under the name the Cordis loader discovers. */
|
|
1177
|
+
export declare const Config: import("@deepseek-ai/schemastery").default<Schemastery.ObjectS<NoInfer<{
|
|
1178
|
+
dshHome: import("@deepseek-ai/schemastery").default<string, string, "plain">;
|
|
1179
|
+
memoriesDir: import("@deepseek-ai/schemastery").default<string, string, "plain">;
|
|
1180
|
+
projectRootMarkers: import("@deepseek-ai/schemastery").default<string[], string[], "defined">;
|
|
1181
|
+
logFile: import("@deepseek-ai/schemastery").default<string, string, "plain">;
|
|
1182
|
+
syncConflictProvider: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
|
|
1183
|
+
syncConflictModel: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
|
|
1184
|
+
syncRemote: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
|
|
1185
|
+
syncClock: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
|
|
1186
|
+
syncIntervalMinutes: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1187
|
+
syncDebounceSeconds: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1188
|
+
maxSummaryBytes: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1189
|
+
maxSummaryEntries: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1190
|
+
globalSummaryEntries: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1191
|
+
globalSummaryBytes: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1192
|
+
summaryFreshSlots: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1193
|
+
recallMode: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
|
|
1194
|
+
recallMinScore: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1195
|
+
recallMaxPerConversation: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1196
|
+
recallMaxBytes: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1197
|
+
rawRecall: import("@deepseek-ai/schemastery").default<boolean, boolean, "volatile-defined">;
|
|
1198
|
+
rawRecallBytes: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1199
|
+
rawRecallExcerpts: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1200
|
+
recallMinQueryChars: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1201
|
+
recallMinTerms: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1202
|
+
injectDelta: import("@deepseek-ai/schemastery").default<boolean, boolean, "volatile-defined">;
|
|
1203
|
+
rotationEntries: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1204
|
+
rotationEveryTurns: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1205
|
+
maxEntriesPerScope: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1206
|
+
maxUnusedDays: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1207
|
+
snapshotMaxAgeDays: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1208
|
+
dedupeSimilarity: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1209
|
+
sweepIntervalHours: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1210
|
+
autoExtract: import("@deepseek-ai/schemastery").default<boolean, boolean, "volatile-defined">;
|
|
1211
|
+
autoExtractIdleMs: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1212
|
+
extractWindowMessages: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1213
|
+
extractMaxInputChars: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1214
|
+
extractMaxOutputTokens: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1215
|
+
extractTimeoutMs: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1216
|
+
extractMaxMemories: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1217
|
+
extractIntervalMinutes: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1218
|
+
minIdleHours: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1219
|
+
maxAgeDays: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1220
|
+
maxSessionsPerPass: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1221
|
+
consolidate: import("@deepseek-ai/schemastery").default<boolean, boolean, "volatile-defined">;
|
|
1222
|
+
consolidateCooldownHours: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1223
|
+
consolidateProposalMaxAgeHours: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1224
|
+
consolidateMaxEntries: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1225
|
+
consolidateTimeoutMs: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1226
|
+
pauseOnQuotaError: import("@deepseek-ai/schemastery").default<boolean, boolean, "volatile-defined">;
|
|
1227
|
+
quotaCooldownMinutes: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1228
|
+
quotaCooldownMaxMinutes: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1229
|
+
extractProvider: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
|
|
1230
|
+
extractModel: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
|
|
1231
|
+
autoDecide: import("@deepseek-ai/schemastery").default<boolean, boolean, "volatile-defined">;
|
|
1232
|
+
autoDecideMinConfidence: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1233
|
+
consolidateProvider: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
|
|
1234
|
+
consolidateModel: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
|
|
1235
|
+
enableTool: import("@deepseek-ai/schemastery").default<boolean, boolean, "volatile-defined">;
|
|
1236
|
+
enableCommand: import("@deepseek-ai/schemastery").default<boolean, boolean, "volatile-defined">;
|
|
1237
|
+
logLevel: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
|
|
1238
|
+
traceMaintenance: import("@deepseek-ai/schemastery").default<boolean, boolean, "volatile-defined">;
|
|
1239
|
+
noticesEnabled: import("@deepseek-ai/schemastery").default<boolean, boolean, "volatile-defined">;
|
|
1240
|
+
noticeQuietHours: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
|
|
1241
|
+
reflectionEnabled: import("@deepseek-ai/schemastery").default<boolean, boolean, "volatile-defined">;
|
|
1242
|
+
noticeGate: import("@deepseek-ai/schemastery").default<boolean, boolean, "volatile-defined">;
|
|
1243
|
+
personaMaxBytes: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1244
|
+
evidenceMaxDf: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1245
|
+
peakHours: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
|
|
1246
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
1247
|
+
dshHome: import("@deepseek-ai/schemastery").default<string, string, "plain">;
|
|
1248
|
+
memoriesDir: import("@deepseek-ai/schemastery").default<string, string, "plain">;
|
|
1249
|
+
projectRootMarkers: import("@deepseek-ai/schemastery").default<string[], string[], "defined">;
|
|
1250
|
+
logFile: import("@deepseek-ai/schemastery").default<string, string, "plain">;
|
|
1251
|
+
syncConflictProvider: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
|
|
1252
|
+
syncConflictModel: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
|
|
1253
|
+
syncRemote: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
|
|
1254
|
+
syncClock: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
|
|
1255
|
+
syncIntervalMinutes: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1256
|
+
syncDebounceSeconds: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1257
|
+
maxSummaryBytes: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1258
|
+
maxSummaryEntries: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1259
|
+
globalSummaryEntries: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1260
|
+
globalSummaryBytes: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1261
|
+
summaryFreshSlots: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1262
|
+
recallMode: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
|
|
1263
|
+
recallMinScore: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1264
|
+
recallMaxPerConversation: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1265
|
+
recallMaxBytes: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1266
|
+
rawRecall: import("@deepseek-ai/schemastery").default<boolean, boolean, "volatile-defined">;
|
|
1267
|
+
rawRecallBytes: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1268
|
+
rawRecallExcerpts: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1269
|
+
recallMinQueryChars: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1270
|
+
recallMinTerms: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1271
|
+
injectDelta: import("@deepseek-ai/schemastery").default<boolean, boolean, "volatile-defined">;
|
|
1272
|
+
rotationEntries: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1273
|
+
rotationEveryTurns: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1274
|
+
maxEntriesPerScope: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1275
|
+
maxUnusedDays: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1276
|
+
snapshotMaxAgeDays: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1277
|
+
dedupeSimilarity: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1278
|
+
sweepIntervalHours: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1279
|
+
autoExtract: import("@deepseek-ai/schemastery").default<boolean, boolean, "volatile-defined">;
|
|
1280
|
+
autoExtractIdleMs: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1281
|
+
extractWindowMessages: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1282
|
+
extractMaxInputChars: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1283
|
+
extractMaxOutputTokens: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1284
|
+
extractTimeoutMs: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1285
|
+
extractMaxMemories: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1286
|
+
extractIntervalMinutes: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1287
|
+
minIdleHours: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1288
|
+
maxAgeDays: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1289
|
+
maxSessionsPerPass: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1290
|
+
consolidate: import("@deepseek-ai/schemastery").default<boolean, boolean, "volatile-defined">;
|
|
1291
|
+
consolidateCooldownHours: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1292
|
+
consolidateProposalMaxAgeHours: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1293
|
+
consolidateMaxEntries: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1294
|
+
consolidateTimeoutMs: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1295
|
+
pauseOnQuotaError: import("@deepseek-ai/schemastery").default<boolean, boolean, "volatile-defined">;
|
|
1296
|
+
quotaCooldownMinutes: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1297
|
+
quotaCooldownMaxMinutes: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1298
|
+
extractProvider: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
|
|
1299
|
+
extractModel: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
|
|
1300
|
+
autoDecide: import("@deepseek-ai/schemastery").default<boolean, boolean, "volatile-defined">;
|
|
1301
|
+
autoDecideMinConfidence: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1302
|
+
consolidateProvider: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
|
|
1303
|
+
consolidateModel: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
|
|
1304
|
+
enableTool: import("@deepseek-ai/schemastery").default<boolean, boolean, "volatile-defined">;
|
|
1305
|
+
enableCommand: import("@deepseek-ai/schemastery").default<boolean, boolean, "volatile-defined">;
|
|
1306
|
+
logLevel: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
|
|
1307
|
+
traceMaintenance: import("@deepseek-ai/schemastery").default<boolean, boolean, "volatile-defined">;
|
|
1308
|
+
noticesEnabled: import("@deepseek-ai/schemastery").default<boolean, boolean, "volatile-defined">;
|
|
1309
|
+
noticeQuietHours: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
|
|
1310
|
+
reflectionEnabled: import("@deepseek-ai/schemastery").default<boolean, boolean, "volatile-defined">;
|
|
1311
|
+
noticeGate: import("@deepseek-ai/schemastery").default<boolean, boolean, "volatile-defined">;
|
|
1312
|
+
personaMaxBytes: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1313
|
+
evidenceMaxDf: import("@deepseek-ai/schemastery").default<number, number, "volatile-defined">;
|
|
1314
|
+
peakHours: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
|
|
1315
|
+
}>>, "plain">;
|
|
1316
|
+
export {};
|