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,742 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stage 2: consolidation of staged memories into the live store.
|
|
3
|
+
*
|
|
4
|
+
* Stage 1 (the idle extractor) writes what each session learned into the store
|
|
5
|
+
* one session at a time. That is fast and cheap but it cannot resolve anything
|
|
6
|
+
* ACROSS sessions: two sessions can state contradictory facts, five sessions can
|
|
7
|
+
* each record a fragment of one procedure, and nothing ever decides which of
|
|
8
|
+
* them is the current truth.
|
|
9
|
+
*
|
|
10
|
+
* Consolidation is the second pass. It hands the recent memories to a
|
|
11
|
+
* restricted sub-agent whose only job is to return a merged set — replacing,
|
|
12
|
+
* merging, or retiring entries — as strict JSON. The plugin then applies that
|
|
13
|
+
* JSON itself, so the child never touches the store and the write path stays in
|
|
14
|
+
* one place with a snapshot to roll back to.
|
|
15
|
+
*
|
|
16
|
+
* @module dsh-cross-memory/consolidate
|
|
17
|
+
*/
|
|
18
|
+
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
19
|
+
import type { LlmRuntime } from '@deepseek-ai/dsh-llm';
|
|
20
|
+
import type { MemoryEntry, MemoryDraft, MemoryKind, MemoryScope } from './types.js';
|
|
21
|
+
/** System instruction for the consolidation sub-agent. */
|
|
22
|
+
export declare const CONSOLIDATE_SYSTEM: string;
|
|
23
|
+
/** JSON output contract for one consolidation call. */
|
|
24
|
+
export declare const CONSOLIDATE_JSON_SCHEMA: {
|
|
25
|
+
readonly type: 'object';
|
|
26
|
+
readonly additionalProperties: false;
|
|
27
|
+
readonly required: readonly ['memories'];
|
|
28
|
+
readonly properties: {
|
|
29
|
+
readonly memories: {
|
|
30
|
+
readonly type: 'array';
|
|
31
|
+
readonly items: {
|
|
32
|
+
readonly type: 'object';
|
|
33
|
+
readonly additionalProperties: false;
|
|
34
|
+
readonly required: readonly ['scope', 'title', 'body', 'appliesTo'];
|
|
35
|
+
readonly properties: {
|
|
36
|
+
readonly id: {
|
|
37
|
+
readonly oneOf: readonly [{
|
|
38
|
+
readonly type: 'string';
|
|
39
|
+
}, {
|
|
40
|
+
readonly type: 'null';
|
|
41
|
+
}];
|
|
42
|
+
};
|
|
43
|
+
readonly scope: {
|
|
44
|
+
readonly type: 'string';
|
|
45
|
+
readonly enum: readonly ['global', 'project'];
|
|
46
|
+
};
|
|
47
|
+
readonly kind: {
|
|
48
|
+
readonly type: 'string';
|
|
49
|
+
readonly enum: readonly ['fact', 'preference', 'knowledge', 'failure', 'procedure'];
|
|
50
|
+
};
|
|
51
|
+
readonly title: {
|
|
52
|
+
readonly type: 'string';
|
|
53
|
+
};
|
|
54
|
+
readonly body: {
|
|
55
|
+
readonly type: 'string';
|
|
56
|
+
};
|
|
57
|
+
readonly tags: {
|
|
58
|
+
readonly type: 'array';
|
|
59
|
+
readonly items: {
|
|
60
|
+
readonly type: 'string';
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
readonly appliesTo: {
|
|
64
|
+
readonly type: 'string';
|
|
65
|
+
};
|
|
66
|
+
readonly durability: {
|
|
67
|
+
readonly type: 'string';
|
|
68
|
+
readonly enum: readonly ['durable', 'snapshot'];
|
|
69
|
+
};
|
|
70
|
+
readonly asOf: {
|
|
71
|
+
readonly type: 'string';
|
|
72
|
+
};
|
|
73
|
+
readonly derivedFrom: {
|
|
74
|
+
readonly type: 'array';
|
|
75
|
+
readonly items: {
|
|
76
|
+
readonly type: 'string';
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
readonly retire: {
|
|
83
|
+
readonly type: 'array';
|
|
84
|
+
readonly items: {
|
|
85
|
+
readonly type: 'string';
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
readonly skills: {
|
|
89
|
+
readonly type: 'array';
|
|
90
|
+
readonly items: {
|
|
91
|
+
readonly type: 'object';
|
|
92
|
+
readonly additionalProperties: false;
|
|
93
|
+
readonly required: readonly ['name', 'description', 'steps'];
|
|
94
|
+
readonly properties: {
|
|
95
|
+
readonly name: {
|
|
96
|
+
readonly type: 'string';
|
|
97
|
+
};
|
|
98
|
+
readonly description: {
|
|
99
|
+
readonly type: 'string';
|
|
100
|
+
};
|
|
101
|
+
readonly steps: {
|
|
102
|
+
readonly type: 'array';
|
|
103
|
+
readonly items: {
|
|
104
|
+
readonly type: 'string';
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
readonly notes: {
|
|
111
|
+
readonly type: 'string';
|
|
112
|
+
};
|
|
113
|
+
readonly persona: {
|
|
114
|
+
readonly type: 'string';
|
|
115
|
+
};
|
|
116
|
+
readonly conflicts: {
|
|
117
|
+
readonly type: 'array';
|
|
118
|
+
readonly items: {
|
|
119
|
+
readonly type: 'object';
|
|
120
|
+
readonly additionalProperties: false;
|
|
121
|
+
readonly required: readonly ['keep', 'drop', 'reason'];
|
|
122
|
+
readonly properties: {
|
|
123
|
+
readonly keep: {
|
|
124
|
+
readonly type: 'string';
|
|
125
|
+
};
|
|
126
|
+
readonly drop: {
|
|
127
|
+
readonly type: 'string';
|
|
128
|
+
};
|
|
129
|
+
readonly reason: {
|
|
130
|
+
readonly type: 'string';
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
/** One skill draft proposed by a consolidation pass. */
|
|
138
|
+
export interface SkillDraft {
|
|
139
|
+
/** Kebab-case skill name. */
|
|
140
|
+
readonly name: string;
|
|
141
|
+
/** One-line description. */
|
|
142
|
+
readonly description: string;
|
|
143
|
+
/** Ordered steps. */
|
|
144
|
+
readonly steps: readonly string[];
|
|
145
|
+
}
|
|
146
|
+
/** One consolidation proposal, already validated against the input. */
|
|
147
|
+
export interface ConsolidationPlan {
|
|
148
|
+
/** Memories to add or replace, keyed by the id they replace (or `undefined` to add). */
|
|
149
|
+
readonly upserts: readonly {
|
|
150
|
+
id: string | null;
|
|
151
|
+
scope: MemoryScope;
|
|
152
|
+
kind: MemoryKind;
|
|
153
|
+
title: string;
|
|
154
|
+
body: string;
|
|
155
|
+
tags: readonly string[];
|
|
156
|
+
keys?: readonly string[];
|
|
157
|
+
appliesTo?: string;
|
|
158
|
+
durability?: 'durable' | 'snapshot';
|
|
159
|
+
asOf?: number;
|
|
160
|
+
derivedFrom?: readonly string[];
|
|
161
|
+
}[];
|
|
162
|
+
/** Ids to delete. */
|
|
163
|
+
readonly retire: readonly string[];
|
|
164
|
+
/** Skill drafts extracted from the memory set. */
|
|
165
|
+
readonly skills: readonly SkillDraft[];
|
|
166
|
+
/** The sub-agent's one-line account of what it changed. */
|
|
167
|
+
readonly notes: string;
|
|
168
|
+
/**
|
|
169
|
+
* Pairs of memories that contradict each other.
|
|
170
|
+
*
|
|
171
|
+
* A contradiction is the one thing a merge must NOT resolve silently: the
|
|
172
|
+
* assistant cannot know which of two statements the user still means. Naming
|
|
173
|
+
* the pair turns "the store quietly picked one" into a question with a winner
|
|
174
|
+
* and a reason, and a `permanent` rule always wins the "ask a person" branch.
|
|
175
|
+
*/
|
|
176
|
+
readonly conflicts?: readonly {
|
|
177
|
+
readonly keep: string;
|
|
178
|
+
readonly drop: string;
|
|
179
|
+
readonly reason: string;
|
|
180
|
+
}[];
|
|
181
|
+
/**
|
|
182
|
+
* The refreshed profile of the user, in markdown.
|
|
183
|
+
*
|
|
184
|
+
* Omitted when the pass had nothing to add: the pass is shown the current
|
|
185
|
+
* profile and told to return it unchanged rather than to re-invent it, because
|
|
186
|
+
* a profile that is rewritten from scratch every six hours drifts.
|
|
187
|
+
*/
|
|
188
|
+
readonly persona?: string;
|
|
189
|
+
}
|
|
190
|
+
/** Render the input document handed to the consolidation agent. */
|
|
191
|
+
export declare function renderConsolidationInput(entries: readonly MemoryEntry[], projectLabel: string, currentPersona?: string): string;
|
|
192
|
+
/** Parse and validate the agent's JSON reply into a plan. */
|
|
193
|
+
export declare function parsePlan(text: string, knownIds: ReadonlySet<string>, maxUpserts: number): ConsolidationPlan | undefined;
|
|
194
|
+
/**
|
|
195
|
+
* Turn a contradiction report into questions for a person.
|
|
196
|
+
*
|
|
197
|
+
* A conflict is never auto-resolved, and never even adjudicated: whether a rule
|
|
198
|
+
* still holds is intent, and intent is the one thing only the user knows. The
|
|
199
|
+
* merge child's own opinion about the winner is recorded as the reason, not
|
|
200
|
+
* applied as a verdict. Every conflict therefore reaches a person, whatever
|
|
201
|
+
* `autoDecide` says.
|
|
202
|
+
*
|
|
203
|
+
* @param conflicts - the plan's report.
|
|
204
|
+
* @param entries - the reviewed page, for titles and protection flags.
|
|
205
|
+
* @returns one dispute per resolvable conflict.
|
|
206
|
+
*/
|
|
207
|
+
export declare function conflictDisputes(conflicts: readonly {
|
|
208
|
+
keep: string;
|
|
209
|
+
drop: string;
|
|
210
|
+
reason: string;
|
|
211
|
+
}[], entries: readonly MemoryEntry[]): ConsolidationDispute[];
|
|
212
|
+
/** Everything one consolidation run needs. */
|
|
213
|
+
export interface ConsolidateRequest {
|
|
214
|
+
/** The agent whose subagent seam is used; also the lineage parent. */
|
|
215
|
+
readonly parent: Agent;
|
|
216
|
+
/** Provider the child should use, defaulting to the parent's own route. */
|
|
217
|
+
readonly provider?: string;
|
|
218
|
+
readonly model?: string;
|
|
219
|
+
/**
|
|
220
|
+
* Agent Preset the child runs under.
|
|
221
|
+
*
|
|
222
|
+
* Required by the 0.2.1-rc.2 seam: a child that names no preset inherits the
|
|
223
|
+
* parent's composition, and the parent's tools are exactly what this pass
|
|
224
|
+
* exists to withhold. The preset this plugin registers carries no tool rows
|
|
225
|
+
* at all, so the child can only answer.
|
|
226
|
+
*/
|
|
227
|
+
readonly agentPreset?: string;
|
|
228
|
+
/** Subagent provider name; `spawn` unless a deployment names another. */
|
|
229
|
+
readonly subagentProvider?: string;
|
|
230
|
+
/** Entries to consider, newest first. */
|
|
231
|
+
readonly entries: readonly MemoryEntry[];
|
|
232
|
+
/** The profile as it stands, so the pass refines it rather than re-inventing it. */
|
|
233
|
+
readonly persona?: string;
|
|
234
|
+
/** Model-facing project label. */
|
|
235
|
+
readonly projectLabel: string;
|
|
236
|
+
/** Cap on returned memories. */
|
|
237
|
+
readonly maxUpserts: number;
|
|
238
|
+
/** Tool names to deny the child; must be names the registry actually has. */
|
|
239
|
+
readonly denyTools: readonly string[];
|
|
240
|
+
/** Deadline for the child run. */
|
|
241
|
+
readonly timeoutMs: number;
|
|
242
|
+
/** Output token cap for the direct (no-subagent) path. */
|
|
243
|
+
readonly maxOutputTokens?: number;
|
|
244
|
+
/** Route the direct (no-subagent) path runs on. */
|
|
245
|
+
readonly route?: {
|
|
246
|
+
provider: string;
|
|
247
|
+
model: string;
|
|
248
|
+
reasoningEffort?: string;
|
|
249
|
+
};
|
|
250
|
+
readonly signal: AbortSignal;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* The subagent seam this module consumes, kept structural for testability.
|
|
254
|
+
*
|
|
255
|
+
* Two kernel shapes live here, because the seam changed under this plugin:
|
|
256
|
+
*
|
|
257
|
+
* - `startActivation` is the 0.2.1-rc.2 shape. The provider is named, the
|
|
258
|
+
* request is nested under it, and the child's tool set comes from an Agent
|
|
259
|
+
* Preset named in the request — `toolFilter` and `persona` are gone from the
|
|
260
|
+
* start request (the model-facing subagent tool rejects both outright).
|
|
261
|
+
* - `start` is the pre-0.2.1 shape: a name-addressed call whose request carries
|
|
262
|
+
* `toolFilter` and `persona`.
|
|
263
|
+
*
|
|
264
|
+
* The new shape is preferred, and it is only used when a preset is available:
|
|
265
|
+
* without one the child inherits the parent's composition, so a "restricted"
|
|
266
|
+
* child would quietly get the parent's tools back.
|
|
267
|
+
*/
|
|
268
|
+
export interface ActivationSpec {
|
|
269
|
+
provider: string;
|
|
270
|
+
/**
|
|
271
|
+
* The child's label.
|
|
272
|
+
*
|
|
273
|
+
* The kernel writes this field into the child's continuable descriptor
|
|
274
|
+
* UNCONDITIONALLY (`label: input.label`) and then validates the whole
|
|
275
|
+
* descriptor with `snapshotJsonValue`, which rejects `undefined`. Omitting
|
|
276
|
+
* it therefore does not mean "no label" — it means "this descriptor cannot be
|
|
277
|
+
* serialized", and the pass dies with `subagent descriptor is not losslessly
|
|
278
|
+
* JSON-serializable`. Every consolidation attempt failed that way from
|
|
279
|
+
* 2026-10-20 until this field was declared here.
|
|
280
|
+
*/
|
|
281
|
+
label: string;
|
|
282
|
+
/**
|
|
283
|
+
* Cancellation for the whole activation.
|
|
284
|
+
*
|
|
285
|
+
* Top-level, NOT inside `request`: the kernel reads `spec.signal` directly
|
|
286
|
+
* (`spec.signal.throwIfAborted()`, and `prepareContinuable({ signal })`), so a
|
|
287
|
+
* spec that carries the signal only in its request throws
|
|
288
|
+
* `Cannot read properties of undefined (reading 'throwIfAborted')` — after the
|
|
289
|
+
* child has already been reserved, which is why it reads as a crash rather than
|
|
290
|
+
* a refusal.
|
|
291
|
+
*
|
|
292
|
+
* The kernel's continuable path reads exactly these top-level fields —
|
|
293
|
+
* `provider`, `label`, `signal`, `childId`, `delivery`, `request` — and these
|
|
294
|
+
* on the request: `prompt`, `parent`, `maxDepth`, `outputSchema`,
|
|
295
|
+
* `agentOptions`, `agentPreset`, `cwd`. Anything omitted here fails at the
|
|
296
|
+
* kernel boundary, not at this module's type boundary.
|
|
297
|
+
*/
|
|
298
|
+
signal: AbortSignal;
|
|
299
|
+
request: {
|
|
300
|
+
prompt: {
|
|
301
|
+
type: 'text';
|
|
302
|
+
text: string;
|
|
303
|
+
}[];
|
|
304
|
+
parent: Agent;
|
|
305
|
+
/** Kept for the request contract even though the kernel reads the top-level one. */
|
|
306
|
+
signal: AbortSignal;
|
|
307
|
+
agentOptions?: {
|
|
308
|
+
provider?: string;
|
|
309
|
+
model?: string;
|
|
310
|
+
};
|
|
311
|
+
outputSchema?: unknown;
|
|
312
|
+
maxDepth?: number;
|
|
313
|
+
agentPreset?: string;
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
export interface SubagentSeam {
|
|
317
|
+
startActivation?: (spec: ActivationSpec) => Promise<{
|
|
318
|
+
result: Promise<{
|
|
319
|
+
output: readonly unknown[];
|
|
320
|
+
structured?: unknown;
|
|
321
|
+
stopReason?: {
|
|
322
|
+
kind: string;
|
|
323
|
+
};
|
|
324
|
+
}>;
|
|
325
|
+
}>;
|
|
326
|
+
start?: (name: string, request: {
|
|
327
|
+
prompt: {
|
|
328
|
+
type: 'text';
|
|
329
|
+
text: string;
|
|
330
|
+
}[];
|
|
331
|
+
parent: Agent;
|
|
332
|
+
signal: AbortSignal;
|
|
333
|
+
agentOptions?: {
|
|
334
|
+
provider?: string;
|
|
335
|
+
model?: string;
|
|
336
|
+
};
|
|
337
|
+
outputSchema?: unknown;
|
|
338
|
+
maxDepth?: number;
|
|
339
|
+
toolFilter?: {
|
|
340
|
+
deny?: readonly string[];
|
|
341
|
+
allow?: readonly string[];
|
|
342
|
+
};
|
|
343
|
+
persona?: string;
|
|
344
|
+
}) => Promise<{
|
|
345
|
+
result: Promise<{
|
|
346
|
+
output: readonly unknown[];
|
|
347
|
+
structured?: unknown;
|
|
348
|
+
stopReason?: {
|
|
349
|
+
kind: string;
|
|
350
|
+
};
|
|
351
|
+
}>;
|
|
352
|
+
}>;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* The Agent Preset the consolidation child runs under.
|
|
356
|
+
*
|
|
357
|
+
* Since 0.2.1-rc.2 the kernel takes a child's tool set from the preset it
|
|
358
|
+
* names: a request's own `toolFilter` and `persona` are gone, and a child that
|
|
359
|
+
* names no preset inherits the parent's composition — which would hand the
|
|
360
|
+
* consolidation pass the parent's tools, the one thing this pass must never
|
|
361
|
+
* have. This preset carries no tool rows at all, so the child can only answer.
|
|
362
|
+
*/
|
|
363
|
+
export declare const CONSOLIDATE_PRESET_ID = "memories-consolidator";
|
|
364
|
+
/**
|
|
365
|
+
* Label every consolidation child runs under.
|
|
366
|
+
*
|
|
367
|
+
* A plain constant, never derived from anything that can be `undefined`: see
|
|
368
|
+
* {@link ActivationSpec.label} for what a missing label does to the child's
|
|
369
|
+
* descriptor.
|
|
370
|
+
*/
|
|
371
|
+
export declare const CONSOLIDATE_LABEL = "\u8BB0\u5FC6\u5408\u5E76";
|
|
372
|
+
/** Output token cap for the direct (no-subagent) consolidation path. */
|
|
373
|
+
export declare const DEFAULT_CONSOLIDATE_MAX_OUTPUT_TOKENS = 8192;
|
|
374
|
+
/**
|
|
375
|
+
* Tools the consolidation child must not have: it reads and proposes, nothing else.
|
|
376
|
+
*
|
|
377
|
+
* The list is deliberately cross-platform (it names both `bash` and `pwsh`,
|
|
378
|
+
* both `str_replace_editor` and `edit`), so any single deployment has only a
|
|
379
|
+
* subset. {@link denyToolsFor} narrows it before use.
|
|
380
|
+
*/
|
|
381
|
+
export declare const CONSOLIDATE_DENY_TOOLS: readonly ['write', 'edit', 'str_replace_editor', 'pwsh', 'bash', 'terminal', 'web_search', 'web_fetch', 'subagent', 'subagent_fork', 'workflow', 'ralph', 'job_kill', 'interrupt_agent', 'memory', 'todo_write', 'create_goal', 'update_goal'];
|
|
382
|
+
/**
|
|
383
|
+
* Narrow the deny list to tools this deployment actually has.
|
|
384
|
+
*
|
|
385
|
+
* `tools.restrict()` fails loud on an unknown name — a feature, since a typo in
|
|
386
|
+
* a filter must not silently leave a capability enabled. But a cross-platform
|
|
387
|
+
* deny list names tools that do not exist here, and that loud failure would
|
|
388
|
+
* sink every consolidation pass. Pass the registry's own names and this returns
|
|
389
|
+
* the intersection.
|
|
390
|
+
* @param available - every tool name the registry knows.
|
|
391
|
+
* @returns the deny list, filtered to known names.
|
|
392
|
+
*/
|
|
393
|
+
export declare function denyToolsFor(available: ReadonlySet<string>): string[];
|
|
394
|
+
/**
|
|
395
|
+
* Run one consolidation through a restricted sub-agent.
|
|
396
|
+
* @param seam - the `ctx.subagents` service.
|
|
397
|
+
* @param request - entries, route, caps, and cancellation.
|
|
398
|
+
* @returns the validated plan, or `undefined` when the child produced none.
|
|
399
|
+
*/
|
|
400
|
+
export declare function runConsolidation(seam: SubagentSeam, request: ConsolidateRequest): Promise<ConsolidationPlan | undefined>;
|
|
401
|
+
/**
|
|
402
|
+
* Build the spec the 0.2.1-rc.2 seam takes.
|
|
403
|
+
*
|
|
404
|
+
* Extracted so a test can inspect it without a kernel: the one bug this shape
|
|
405
|
+
* can carry — a missing `label` — is invisible from the seam's type unless the
|
|
406
|
+
* type declares the field, and the failure it causes happens inside the
|
|
407
|
+
* kernel's descriptor validator, three calls away from here. See
|
|
408
|
+
* {@link ActivationSpec.label}.
|
|
409
|
+
*
|
|
410
|
+
* @param request - route, preset and lineage parent.
|
|
411
|
+
* @param prompt - the child's single user message.
|
|
412
|
+
* @param timeout - the child's deadline.
|
|
413
|
+
* @returns the spec, with every optional field absent rather than `undefined`.
|
|
414
|
+
*/
|
|
415
|
+
export declare function buildActivationSpec(request: ConsolidateRequest, prompt: {
|
|
416
|
+
type: 'text';
|
|
417
|
+
text: string;
|
|
418
|
+
}[], timeout: AbortSignal, outputSchema?: unknown): ActivationSpec;
|
|
419
|
+
/**
|
|
420
|
+
* Run one consolidation without a subagent: a plain model call that owns no
|
|
421
|
+
* tools at all.
|
|
422
|
+
*
|
|
423
|
+
* This is the fallback for a deployment whose subagent seam cannot express a
|
|
424
|
+
* restricted child (no Agent Preset service, or a seam that predates the
|
|
425
|
+
* preset contract). It is not a weaker guarantee: the model is handed no tool
|
|
426
|
+
* list whatsoever, so it cannot write, shell out, or delegate — the same
|
|
427
|
+
* property the old deny list bought, reached by a different route.
|
|
428
|
+
*
|
|
429
|
+
* @param llm - the LLM runtime.
|
|
430
|
+
* @param request - entries, route, caps, and cancellation.
|
|
431
|
+
* @returns the validated plan, or `undefined` when the model produced none.
|
|
432
|
+
*/
|
|
433
|
+
export declare function runConsolidationDirect(llm: LlmRuntime, request: ConsolidateRequest): Promise<ConsolidationPlan | undefined>;
|
|
434
|
+
/**
|
|
435
|
+
* Choose which memories one consolidation pass reviews.
|
|
436
|
+
*
|
|
437
|
+
* The pass used to receive the newest N entries, which meant an old memory was
|
|
438
|
+
* never looked at again: the first page never changed, so a stale fact deep in
|
|
439
|
+
* the store was unreachable by the only mechanism that could retire it.
|
|
440
|
+
* Selection prefers what was never reviewed, then what was reviewed longest
|
|
441
|
+
* ago, so every memory is eventually reached while new material — and material
|
|
442
|
+
* the model actually uses — still goes first.
|
|
443
|
+
*
|
|
444
|
+
* @param entries - every candidate entry.
|
|
445
|
+
* @param reviewedAt - `scope\u0000id` → last review time, or 0 when never.
|
|
446
|
+
* @param max - how many entries the pass may consider.
|
|
447
|
+
* @returns the selection to hand the sub-agent.
|
|
448
|
+
*/
|
|
449
|
+
export declare function selectForConsolidation(entries: readonly MemoryEntry[], reviewedAt: ReadonlyMap<string, number>, max: number): readonly MemoryEntry[];
|
|
450
|
+
/** A snapshot of the store taken before applying a plan, used to roll back. */
|
|
451
|
+
export interface ConsolidationSnapshot {
|
|
452
|
+
/** Entries as they were before the plan ran. */
|
|
453
|
+
readonly entries: readonly MemoryEntry[];
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* One consolidation decision that a person should make rather than the pass.
|
|
457
|
+
*
|
|
458
|
+
* The pass runs unattended, so the question is not "is this a good edit" but
|
|
459
|
+
* "can this edit be undone or noticed if it is wrong". Archiving an entry nobody
|
|
460
|
+
* ever read, folding a duplicate, sharpening a body while keeping its anchors:
|
|
461
|
+
* all reversible or visible. Deleting the memory a session actually used,
|
|
462
|
+
* rewriting what a person typed, or dropping the paths a body cited — those need
|
|
463
|
+
* a human, because the loss is invisible and the pass has no model of what it did
|
|
464
|
+
* not understand. A scope change is not on the list because it is not offered at
|
|
465
|
+
* all: every existing memory is pinned to the scope it already lives in.
|
|
466
|
+
*/
|
|
467
|
+
export interface ConsolidationDispute {
|
|
468
|
+
/** Entry id the decision is about. */
|
|
469
|
+
readonly id: string;
|
|
470
|
+
/** Scope the entry lives in. */
|
|
471
|
+
readonly scope: MemoryScope;
|
|
472
|
+
/** What would happen to it. */
|
|
473
|
+
readonly action: 'rewrite' | 'retire';
|
|
474
|
+
/** Title before the change, for the reader. */
|
|
475
|
+
readonly title: string;
|
|
476
|
+
/** One short sentence saying why this one is being asked about. */
|
|
477
|
+
readonly reason: string;
|
|
478
|
+
/** What the entry says today. */
|
|
479
|
+
readonly before: string;
|
|
480
|
+
/** What the pass wants it to say; empty for a retirement. */
|
|
481
|
+
readonly after: string;
|
|
482
|
+
/**
|
|
483
|
+
* True when no automatic decision may be taken: a person wrote or pinned it, or
|
|
484
|
+
* marked it permanent. Everything else may be adjudicated.
|
|
485
|
+
*
|
|
486
|
+
* These are the promises the plugin makes to its owner, so the whole "automate
|
|
487
|
+
* the rest" design stops here: an AI may decide whether a merge lost
|
|
488
|
+
* information, it may not decide that a rule somebody pinned no longer applies.
|
|
489
|
+
*/
|
|
490
|
+
readonly hard?: boolean;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Pin every existing memory to the scope it already lives in.
|
|
494
|
+
*
|
|
495
|
+
* A scope decides which sessions a memory is injected into, and a body that names
|
|
496
|
+
* a path, host or product says nothing about that: the developer's own machines,
|
|
497
|
+
* tools and cross-machine workflow are global even when they name a drive letter.
|
|
498
|
+
* Leaving the question to each pass produced two failure modes at once — a queue
|
|
499
|
+
* of "move this from global to project" decisions nobody wanted to answer, and a
|
|
500
|
+
* staged "move" whose acceptance wrote a second copy under the new scope (the
|
|
501
|
+
* original was never archived) and demoted its provenance to `auto`.
|
|
502
|
+
*
|
|
503
|
+
* So the rule is structural instead of conversational: the pass may place NEW
|
|
504
|
+
* memories anywhere, and every existing memory stays where it is. Callers that
|
|
505
|
+
* stage a disputed row must use the pinned plan too, or accepting that row would
|
|
506
|
+
* still write the proposed scope.
|
|
507
|
+
*
|
|
508
|
+
* @param plan - the plan the pass returned.
|
|
509
|
+
* @param entries - the entries as they were before the pass ran.
|
|
510
|
+
* @returns the plan with existing entries pinned, and each proposal that was overruled.
|
|
511
|
+
*/
|
|
512
|
+
export declare function pinExistingScopes(plan: ConsolidationPlan, entries: readonly MemoryEntry[]): {
|
|
513
|
+
plan: ConsolidationPlan;
|
|
514
|
+
pinned: readonly {
|
|
515
|
+
id: string;
|
|
516
|
+
proposed: MemoryScope;
|
|
517
|
+
kept: MemoryScope;
|
|
518
|
+
}[];
|
|
519
|
+
};
|
|
520
|
+
/**
|
|
521
|
+
* Split a plan into what may be applied unattended and what should be asked about.
|
|
522
|
+
*
|
|
523
|
+
* The rules are deliberately about *loss*, not taste: the pass is allowed to
|
|
524
|
+
* sharpen wording, merge duplicates and retire memories nothing ever read. It is
|
|
525
|
+
* not allowed to quietly destroy a fact a session used, rewrite something a
|
|
526
|
+
* person wrote, or drop the concrete anchors (file paths) that made a body
|
|
527
|
+
* checkable. Scope is not a judgement at all: every existing entry is pinned to
|
|
528
|
+
* the scope it lives in (see {@link pinExistingScopes}), so a rewrite can never
|
|
529
|
+
* end up as a second copy in another scope.
|
|
530
|
+
*
|
|
531
|
+
* @param plan - the plan the pass returned.
|
|
532
|
+
* @param snapshot - the entries as they were before it ran.
|
|
533
|
+
* @returns the safe remainder and the decisions to ask about.
|
|
534
|
+
*/
|
|
535
|
+
export declare function classifyPlan(plan: ConsolidationPlan, snapshot: ConsolidationSnapshot): {
|
|
536
|
+
safe: ConsolidationPlan;
|
|
537
|
+
disputes: readonly ConsolidationDispute[];
|
|
538
|
+
};
|
|
539
|
+
/**
|
|
540
|
+
* Whether one waiting row still carries the plan fragment that applies it.
|
|
541
|
+
*
|
|
542
|
+
* The rows and the plan are stored side by side, so a row can outlive its
|
|
543
|
+
* fragment: a sync conflict used to stage `upserts: []` beside real questions,
|
|
544
|
+
* and applying that empty plan "succeeded" without writing anything, after
|
|
545
|
+
* which the row — the only visible trace — was dropped. A row that has no
|
|
546
|
+
* matching upsert (rewrite) or retire entry has nothing to apply, and saying so
|
|
547
|
+
* is the only honest answer.
|
|
548
|
+
*
|
|
549
|
+
* @param plan - the plan stored with the pending rows.
|
|
550
|
+
* @param row - the decision a person is answering.
|
|
551
|
+
* @returns true when applying this row is more than a no-op.
|
|
552
|
+
*/
|
|
553
|
+
export declare function hasApplicableFragment(plan: ConsolidationPlan, row: ConsolidationDispute): boolean;
|
|
554
|
+
/** Apply one plan against a store-like target. */
|
|
555
|
+
export interface ConsolidationTarget {
|
|
556
|
+
/** Write one entry, keeping `keepId` when given. */
|
|
557
|
+
upsert(draft: MemoryDraft, projectRoot: string | undefined, source: MemoryEntry['source'], keepId?: string): Promise<{
|
|
558
|
+
entry: MemoryEntry;
|
|
559
|
+
action: 'created' | 'updated';
|
|
560
|
+
}>;
|
|
561
|
+
/** Move one entry out of the live store; returns whether it was there. */
|
|
562
|
+
archive(scope: MemoryScope, projectRoot: string | undefined, id: string): Promise<boolean>;
|
|
563
|
+
/** Put an archived entry back, used to roll back a failed plan. */
|
|
564
|
+
restore(scope: MemoryScope, projectRoot: string | undefined, id: string): Promise<boolean>;
|
|
565
|
+
}
|
|
566
|
+
/** The outcome of applying a plan. */
|
|
567
|
+
export interface ConsolidationResult {
|
|
568
|
+
readonly written: number;
|
|
569
|
+
readonly retired: number;
|
|
570
|
+
readonly notes: string;
|
|
571
|
+
}
|
|
572
|
+
/** A plan waiting for a human, as stored between passes. */
|
|
573
|
+
export interface PendingPlan {
|
|
574
|
+
/** The disputed part of the plan, so accepting one is a matter of applying it. */
|
|
575
|
+
readonly plan: ConsolidationPlan;
|
|
576
|
+
/** One row per decision being asked about, for the reader. */
|
|
577
|
+
readonly disputes: readonly ConsolidationDispute[];
|
|
578
|
+
/** Workspace root the plan was prepared for, or `''` for a global-only pass. */
|
|
579
|
+
readonly projectRoot: string;
|
|
580
|
+
/** When the pass produced it. */
|
|
581
|
+
readonly at: number;
|
|
582
|
+
/** Scope label shown to the reader. */
|
|
583
|
+
readonly label: string;
|
|
584
|
+
}
|
|
585
|
+
/** Where a pending proposal lives, one per store. */
|
|
586
|
+
export declare function pendingPlanPath(memoriesDir: string): string;
|
|
587
|
+
/**
|
|
588
|
+
* Stage a plan instead of applying it.
|
|
589
|
+
*
|
|
590
|
+
* A background pass rewrites memories with no model of what it is destroying: on
|
|
591
|
+
* a real store one such pass erased the trigger phrase from 32 memories, demoted
|
|
592
|
+
* 8 hand-written rules to "extracted guess", and turned Chinese titles back into
|
|
593
|
+
* English — all silently, and all found only in a later audit. A proposal has the
|
|
594
|
+
* same power and none of the risk: nothing changes until a person says so.
|
|
595
|
+
*
|
|
596
|
+
* @param memoriesDir - the store root.
|
|
597
|
+
* @param pending - the plan and where it came from.
|
|
598
|
+
*/
|
|
599
|
+
export declare function writePendingPlan(memoriesDir: string, pending: PendingPlan): Promise<void>;
|
|
600
|
+
/**
|
|
601
|
+
* Read the pending proposal, if any.
|
|
602
|
+
*
|
|
603
|
+
* @param memoriesDir - the store root.
|
|
604
|
+
* @returns the proposal, or `undefined` when there is none or it is unreadable.
|
|
605
|
+
*/
|
|
606
|
+
export declare function readPendingPlan(memoriesDir: string): Promise<PendingPlan | undefined>;
|
|
607
|
+
/**
|
|
608
|
+
* Merge newly disputed decisions into the ones already waiting.
|
|
609
|
+
*
|
|
610
|
+
* A later pass must not silently replace a question: the reader may be part-way
|
|
611
|
+
* through deciding, and the same id can legitimately be disputed twice (the pass
|
|
612
|
+
* proposes something else about it). Newest wins for an id, older rows stay.
|
|
613
|
+
*
|
|
614
|
+
* @param memoriesDir - the store root.
|
|
615
|
+
* @param pending - the rows and the plan fragment that would apply them.
|
|
616
|
+
* @returns how many rows are waiting after the merge.
|
|
617
|
+
*/
|
|
618
|
+
export declare function mergePendingPlan(memoriesDir: string, pending: PendingPlan): Promise<number>;
|
|
619
|
+
/**
|
|
620
|
+
* Whether a staged proposal is still worth leaving alone.
|
|
621
|
+
*
|
|
622
|
+
* A proposal is a question, and questions go stale: entries keep arriving while
|
|
623
|
+
* it waits, so an old proposal describes a store that no longer exists. Inside
|
|
624
|
+
* the window a background pass does not spend a model call to overwrite a
|
|
625
|
+
* question nobody has answered; past it, the fresh proposal wins.
|
|
626
|
+
*
|
|
627
|
+
* @param pending - the staged proposal.
|
|
628
|
+
* @param maxAgeHours - the window; `0` means "wait for an answer".
|
|
629
|
+
* @param now - clock.
|
|
630
|
+
* @returns true when a running pass should leave it in place.
|
|
631
|
+
*/
|
|
632
|
+
export declare function proposalIsFresh(pending: PendingPlan, maxAgeHours: number, now: number): boolean;
|
|
633
|
+
/**
|
|
634
|
+
* Drop the pending proposal.
|
|
635
|
+
*
|
|
636
|
+
* @param memoriesDir - the store root.
|
|
637
|
+
* @returns whether one was there.
|
|
638
|
+
*/
|
|
639
|
+
export declare function clearPendingPlan(memoriesDir: string): Promise<boolean>;
|
|
640
|
+
/**
|
|
641
|
+
* Apply a plan, restoring the snapshot when a write fails.
|
|
642
|
+
*
|
|
643
|
+
* The child proposes; this function is the only writer. Applying is all-or-
|
|
644
|
+
* nothing: a failure mid-plan puts the entries it already touched back the way
|
|
645
|
+
* they were, so a half-consolidated store is never left behind.
|
|
646
|
+
*
|
|
647
|
+
* @param plan - the validated plan.
|
|
648
|
+
* @param target - the store to write to.
|
|
649
|
+
* @param projectRoot - workspace root for project entries.
|
|
650
|
+
* @param snapshot - entries as they were before the plan.
|
|
651
|
+
* @returns how many entries were written and retired.
|
|
652
|
+
*/
|
|
653
|
+
export declare function applyPlan(plan: ConsolidationPlan, target: ConsolidationTarget, projectRoot: string | undefined, snapshot: ConsolidationSnapshot): Promise<ConsolidationResult>;
|
|
654
|
+
/**
|
|
655
|
+
* The adjudicator's answer shape.
|
|
656
|
+
*
|
|
657
|
+
* One decision per dispute, keyed by id, plus a confidence the caller thresholds
|
|
658
|
+
* on. Deliberately no free-form field: an adjudicator that can explain itself in
|
|
659
|
+
* prose can also argue itself into a retire, and the only thing this layer is
|
|
660
|
+
* allowed to judge is whether information survives.
|
|
661
|
+
*/
|
|
662
|
+
export declare const ADJUDICATE_JSON_SCHEMA: {
|
|
663
|
+
readonly type: 'object';
|
|
664
|
+
readonly additionalProperties: false;
|
|
665
|
+
readonly required: readonly ['decisions'];
|
|
666
|
+
readonly properties: {
|
|
667
|
+
readonly decisions: {
|
|
668
|
+
readonly type: 'array';
|
|
669
|
+
readonly items: {
|
|
670
|
+
readonly type: 'object';
|
|
671
|
+
readonly additionalProperties: false;
|
|
672
|
+
readonly required: readonly ['id', 'accept', 'confidence', 'reason'];
|
|
673
|
+
readonly properties: {
|
|
674
|
+
readonly id: {
|
|
675
|
+
readonly type: 'string';
|
|
676
|
+
};
|
|
677
|
+
readonly accept: {
|
|
678
|
+
readonly type: 'boolean';
|
|
679
|
+
};
|
|
680
|
+
readonly confidence: {
|
|
681
|
+
readonly type: 'number';
|
|
682
|
+
};
|
|
683
|
+
readonly reason: {
|
|
684
|
+
readonly type: 'string';
|
|
685
|
+
};
|
|
686
|
+
};
|
|
687
|
+
};
|
|
688
|
+
};
|
|
689
|
+
};
|
|
690
|
+
};
|
|
691
|
+
/** What the adjudicator is asked to judge. */
|
|
692
|
+
export declare const ADJUDICATE_SYSTEM: string;
|
|
693
|
+
/**
|
|
694
|
+
* Render the disputes for the adjudicator.
|
|
695
|
+
* @param disputes - items the classifier would not apply on its own.
|
|
696
|
+
* @returns the document handed to the child.
|
|
697
|
+
*/
|
|
698
|
+
export declare function renderAdjudicationInput(disputes: readonly ConsolidationDispute[]): string;
|
|
699
|
+
/** One adjudicator answer. */
|
|
700
|
+
export interface DisputeVerdict {
|
|
701
|
+
/** Entry the decision is about. */
|
|
702
|
+
readonly id: string;
|
|
703
|
+
/** Whether the change may be applied. */
|
|
704
|
+
readonly accept: boolean;
|
|
705
|
+
/** 0..1; the caller drops anything under its floor. */
|
|
706
|
+
readonly confidence: number;
|
|
707
|
+
/** One short sentence, for the log and the pending panel. */
|
|
708
|
+
readonly reason: string;
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* Ask a restricted child to adjudicate the disputes a person used to answer.
|
|
712
|
+
*
|
|
713
|
+
* Same seam, same preset and same fence as the consolidation pass itself, so the
|
|
714
|
+
* child still has no tools: it reads the two bodies and answers. Anything the
|
|
715
|
+
* child does not return, returns twice, or returns unparseably is treated as
|
|
716
|
+
* "no verdict" and stays with the human — this layer can only ever ADD an answer,
|
|
717
|
+
* never suppress a question.
|
|
718
|
+
*
|
|
719
|
+
* @param seam - the `ctx.subagents` service.
|
|
720
|
+
* @param request - route, preset, caps and the parent agent.
|
|
721
|
+
* @param disputes - items to adjudicate; hard stops must already be filtered out.
|
|
722
|
+
* @returns one verdict per answered id, possibly empty.
|
|
723
|
+
*/
|
|
724
|
+
export declare function adjudicateDisputes(seam: SubagentSeam, request: ConsolidateRequest, disputes: readonly ConsolidationDispute[]): Promise<readonly DisputeVerdict[]>;
|
|
725
|
+
/**
|
|
726
|
+
* Fold adjudicator verdicts into the plan the caller is about to apply.
|
|
727
|
+
*
|
|
728
|
+
* Rejected items and items under the confidence floor are NOT left pending: a
|
|
729
|
+
* rejection is an answer ("do nothing"), and re-asking it every six hours would
|
|
730
|
+
* turn a decision into a queue. Only unanswered items stay with the human.
|
|
731
|
+
*
|
|
732
|
+
* @param safe - the plan the classifier already cleared; mutated in place.
|
|
733
|
+
* @param plan - the pass's full plan, for the upsert bodies a rewrite needs.
|
|
734
|
+
* @param disputes - items that were sent to the adjudicator.
|
|
735
|
+
* @param verdicts - what came back.
|
|
736
|
+
* @param minConfidence - floor below which a verdict is treated as no answer.
|
|
737
|
+
* @returns the disputes that still need a person.
|
|
738
|
+
*/
|
|
739
|
+
export declare function applyVerdicts(safe: {
|
|
740
|
+
upserts: ConsolidationPlan['upserts'][number][];
|
|
741
|
+
retire: string[];
|
|
742
|
+
}, plan: ConsolidationPlan, disputes: readonly ConsolidationDispute[], verdicts: readonly DisputeVerdict[], minConfidence: number): readonly ConsolidationDispute[];
|