dsh-cross-memory 0.2.2 → 0.2.4
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/README.md +92 -94
- package/docs/DETAIL.md +75 -10
- package/docs/DETAIL.zh.md +74 -13
- package/lib/backfill.js +1 -0
- package/lib/client.js +6 -1
- package/lib/config.js +50 -18
- package/lib/consolidate.js +123 -35
- package/lib/extract.js +133 -25
- package/lib/index.js +210 -45
- package/lib/loops.js +9 -4
- package/lib/render.js +2 -2
- package/lib/search.js +141 -18
- package/lib/storage.js +8 -0
- package/lib/sync.js +96 -1
- package/lib/test/consolidate.test.js +102 -2
- package/lib/test/extract.test.js +59 -2
- package/lib/test/recall.test.js +59 -26
- package/lib/test/retrieval.test.js +46 -1
- package/lib/test/rotation.test.js +5 -2
- package/lib/test/subagent-contract.test.js +8 -0
- package/lib/test/sync.test.js +46 -1
- package/lib/tool.js +9 -1
- package/lib/types/backfill.d.ts +10 -0
- package/lib/types/config.d.ts +49 -15
- package/lib/types/consolidate.d.ts +44 -14
- package/lib/types/extract.d.ts +95 -3
- package/lib/types/index.d.ts +52 -4
- package/lib/types/search.d.ts +68 -0
- package/lib/types/sync.d.ts +12 -0
- package/lib/types/types.d.ts +8 -0
- package/package.json +1 -1
package/lib/extract.js
CHANGED
|
@@ -13,6 +13,46 @@ import { BlockAssembler, createUserMessage } from '@deepseek-ai/dsh-llm';
|
|
|
13
13
|
import { deriveEventMessage } from '@deepseek-ai/dsh-session/surface';
|
|
14
14
|
import { SessionSeq } from '@deepseek-ai/dsh-session';
|
|
15
15
|
import { MEMORY_SOURCE_KIND, toMemoryKind } from './types.js';
|
|
16
|
+
import { tokenize } from './search.js';
|
|
17
|
+
/**
|
|
18
|
+
* Pick the known titles most worth showing one extraction window.
|
|
19
|
+
*
|
|
20
|
+
* The list used to be taken in time order and cut at a fixed cap, which on a
|
|
21
|
+
* store larger than the cap hid every older title from the extractor: it could
|
|
22
|
+
* not recognise a fact it had already recorded, and wrote a second entry under
|
|
23
|
+
* a re-worded title. Ranking by overlap with the window fixes that within the
|
|
24
|
+
* same budget — the titles the window is actually about are the ones it might
|
|
25
|
+
* re-derive — while the recency tie-break keeps a representative sample when
|
|
26
|
+
* nothing overlaps.
|
|
27
|
+
*
|
|
28
|
+
* @param candidates - every title in the scopes this pass may write to.
|
|
29
|
+
* @param windowText - the transcript window about to be mined.
|
|
30
|
+
* @param limit - most titles to return; `0` returns none.
|
|
31
|
+
* @returns the selected titles, most relevant first.
|
|
32
|
+
*/
|
|
33
|
+
export function selectKnownTitles(candidates, windowText, limit) {
|
|
34
|
+
if (limit <= 0)
|
|
35
|
+
return [];
|
|
36
|
+
if (candidates.length <= limit)
|
|
37
|
+
return candidates.map((candidate) => candidate.title);
|
|
38
|
+
const queryTerms = new Set(tokenize(windowText));
|
|
39
|
+
const scored = candidates.map((candidate, index) => {
|
|
40
|
+
const seen = new Set();
|
|
41
|
+
let overlap = 0;
|
|
42
|
+
for (const term of tokenize(candidate.title)) {
|
|
43
|
+
if (seen.has(term))
|
|
44
|
+
continue;
|
|
45
|
+
seen.add(term);
|
|
46
|
+
if (queryTerms.has(term))
|
|
47
|
+
overlap += 1;
|
|
48
|
+
}
|
|
49
|
+
return { title: candidate.title, overlap, updatedAt: candidate.updatedAt, index };
|
|
50
|
+
});
|
|
51
|
+
scored.sort((left, right) => right.overlap - left.overlap
|
|
52
|
+
|| right.updatedAt - left.updatedAt
|
|
53
|
+
|| left.index - right.index);
|
|
54
|
+
return scored.slice(0, limit).map((item) => item.title);
|
|
55
|
+
}
|
|
16
56
|
/**
|
|
17
57
|
* The system instruction for the extraction call.
|
|
18
58
|
*
|
|
@@ -30,11 +70,11 @@ import { MEMORY_SOURCE_KIND, toMemoryKind } from './types.js';
|
|
|
30
70
|
* truncation keep everything that finished.
|
|
31
71
|
*/
|
|
32
72
|
export const EXTRACT_SYSTEM = [
|
|
33
|
-
'You maintain long-term memory for
|
|
73
|
+
'You maintain long-term memory for an AI assistant\'s user.',
|
|
34
74
|
'Read the supplied conversation transcript and extract only durable, reusable facts that would help in a FUTURE session.',
|
|
35
75
|
'',
|
|
36
|
-
'Record: stable user preferences and working style; project architecture and conventions; build/test/deploy commands; environment and tooling facts; non-obvious gotchas; decisions and their reasons.',
|
|
37
|
-
'Do NOT record: transient task state, one-off debugging output, secrets, API keys, tokens, credentials, personal data, restatements of the code the assistant just wrote, or anything already stated in the transcript as a question rather than a fact.',
|
|
76
|
+
'Record: stable user preferences and working style; project architecture and conventions; build/test/deploy commands; environment and tooling facts; non-obvious gotchas; decisions and their reasons; the user\'s personal background and relationships (family, colleagues, friends, neighbours); personal habits, routines and plans; creative collaborations and shared stories; commitments and promises with their deadlines.',
|
|
77
|
+
'Do NOT record: transient task state, one-off debugging output, secrets, API keys, tokens, credentials, sensitive personal data (ID numbers, medical records, financial account details), restatements of the code the assistant just wrote, or anything already stated in the transcript as a question rather than a fact.',
|
|
38
78
|
'',
|
|
39
79
|
'Write every title and body in Simplified Chinese. Keep paths, commands, identifiers, product names and error strings exactly as they are.',
|
|
40
80
|
'The injected summary shows only the title and roughly the first 100 characters of the body (the budget forces short previews), so lead with the trigger and the decision; put the detail after.',
|
|
@@ -42,13 +82,18 @@ export const EXTRACT_SYSTEM = [
|
|
|
42
82
|
'When a number IS the point of the memory (a measured pass rate, a corpus size, the current state of a system), set "durability":"snapshot" and give "asOf" as the date it was measured; it is then shown with that date and retired once it is old. Everything else is "durable" and needs neither field.',
|
|
43
83
|
'A problem that is already fixed is recorded as fixed ("已修 in <commit>"); never leave it reading as an open problem.',
|
|
44
84
|
'',
|
|
85
|
+
'TIME: a fact carrying a relative time (明天/上周五/前天/下周三/上个月) MUST also carry its absolute date in the body, resolved against the today\'s date given below ("前天(2026-05-25)"). A later turn may ask exactly "那次是几号", and the relative word alone cannot answer it.',
|
|
86
|
+
'UPDATES: when the transcript CHANGES an existing fact — a correction, a changed plan, a new version, a story retcon — do NOT overwrite the old state. Keep the timeline in the body: "旧:<old>;新:<new>(<date> 改)". A later turn may ask what was true BEFORE the change (改口/纠错/真实变化), and only the timeline answers it.',
|
|
87
|
+
'CONFLICTS: when the user says two things about the same subject that do not agree and the transcript does not explain why, record BOTH ("两种说法:<A>;<B>;原因未明"). Never pick one side and drop the other.',
|
|
88
|
+
'',
|
|
45
89
|
'Choose the scope of each memory:',
|
|
46
|
-
'- "global": true across the developer\'s machines and projects — how they like to work, general preferences, tooling, machine and path facts, network and proxy setup, how to move work between machines.',
|
|
90
|
+
'- "global": true across the developer\'s machines and projects — how they like to work, general preferences, tooling, machine and path facts, network and proxy setup, how to move work between machines, and the user\'s personal background and relationships.',
|
|
47
91
|
'- "project": true only for this workspace (its architecture, commands, conventions, gotchas).',
|
|
48
92
|
'Choose by breadth, not by wording: naming a machine, drive letter, repository path, host, employer or customer is NOT by itself evidence of project scope. A durable fact about the developer\'s own environment is global even when it names such a thing, because global memories are what every unrelated project reads. A fact becomes "project" only when it would be wrong or meaningless outside this one workspace.',
|
|
49
93
|
'',
|
|
50
94
|
'Each memory has a short imperative title (max 80 characters), a 1-3 sentence body, up to 5 lowercase keyword tags, and 1-5 search keys: the aliases and keyphrases a future session would actually type (for example "monorepo" for a pnpm-workspace fact).',
|
|
51
95
|
'Search keys are how a memory is found at all, so spend them on the words a person would use who has NOT read the memory: the other name for the same thing, the command, the file, the error text, the product\'s own term. Include the English technical term when the memory is written in Chinese and vice versa — a turn that mixes them ("这个排序改动会不会动到 system prompt") shares no characters with "前缀缓存", and the keys are the only place that gap can be closed. Retrieval is lexical: it matches characters, not meaning.',
|
|
96
|
+
'Also give each memory "entities": the people, places, organisations, objects and dates it is about, each as a short exact name ("刘莹", "南街文具店", "叶楠", "2026-05-25"). A later turn that names one of them ("北街南街分别买了什么") may share no other word with the memory, and the entity list is what makes it reachable.',
|
|
52
97
|
'Give each memory a kind, because the kinds are recalled differently:',
|
|
53
98
|
'- "preference": how the user wants work done, or a correction they issued.',
|
|
54
99
|
'- "failure": something that went wrong and how to avoid repeating it.',
|
|
@@ -59,7 +104,8 @@ export const EXTRACT_SYSTEM = [
|
|
|
59
104
|
'Every memory must also carry "quote": one continuous passage copied VERBATIM from a single message in the transcript above (8-200 characters), keeping its punctuation and wording exactly, and without the "USER:"/"ASSISTANT:" line prefix. Choose the sentence that carries the claim — the user stating it, or the assistant\'s conclusion you are recording — not a greeting, a question or your own summary. Never paraphrase the quote, combine two messages, or invent one. The quote is checked as an exact substring of the transcript before the memory is written, and a memory whose quote does not appear there is discarded, so a paraphrased quote loses the memory.',
|
|
60
105
|
'',
|
|
61
106
|
'Mark whose words a memory preserves with "voice":',
|
|
62
|
-
'- "user" when the user themselves stated it: how they want work done, a correction they issued, a habit, an opinion, a rule they set ("以后都…", "不要…", "我喜欢…").',
|
|
107
|
+
'- "user" when the user themselves stated it: how they want work done, a correction they issued, a habit, an opinion, a rule they set ("以后都…", "不要…", "我喜欢…"), or a fact about their own life.',
|
|
108
|
+
'- "assistant" when the memory preserves the ASSISTANT\'s own words, suggestion or promise. Never file the assistant\'s words as the user\'s: a later turn asking "你当时建议什么" must not be answered with "你说过…".',
|
|
63
109
|
'- Record the SUBSTANCE faithfully but in the form that will be found and understood later: rewrite for clarity when their sentence was context-bound, and keep their exact phrasing only where the wording itself carries the rule (a threshold, a condition, a turn of phrase they will repeat). The voice field records whose claim it is, not a transcript.',
|
|
64
110
|
'- omit the field (the default) when the memory is your own conclusion, an observation about the code, or a fact you looked up.',
|
|
65
111
|
'Never attribute your own conclusion to the user. A profile of this person is rebuilt from the "user" entries, so a misattributed guess becomes a false belief about them.',
|
|
@@ -68,9 +114,10 @@ export const EXTRACT_SYSTEM = [
|
|
|
68
114
|
'- One short sentence each, in the user\'s framing, naming the object ("把报价单发出去", not "邮件相关").',
|
|
69
115
|
'- NEVER drop the time word: if the user said 明天/周五/下周三, the loop text must start with it ("明天把登录页的截图补齐"), because a later question may be exactly "我明天要做什么"; resolve "dueAt" to the absolute ISO date computed from today\'s date given above, and omit it when no deadline was said.',
|
|
70
116
|
'- "dueAt" only when a deadline was actually said, as ISO date or date-time. Never invent one: a loop without a deadline is a note, and nagging somebody about a note turns help into supervision.',
|
|
117
|
+
'- PROGRESS: when the user reports that part of an existing obligation is done ("先还一件,还剩两件"), return a loop whose text KEEPS the original promise\'s wording and adds the remaining part ("还剩两件夜班见闻(原欠三件)"), so the ledger recognises it as the same promise and updates it. Do not keep the original full amount as still owed.',
|
|
71
118
|
'- Skip what the session shows as already done, and skip the assistant\'s own to-dos. An empty array is the normal result.',
|
|
72
119
|
'Prefer few high-value memories over many trivial ones. Return at most the requested number.',
|
|
73
|
-
'Reply with JSON only, no prose and no code fence: {"memories":[{"scope":"global"|"project","kind":string,"title":string,"body":string,"tags":string[],"appliesTo":string,"quote":string}],"loops":[{"text":string,"dueAt":string?}],"summary":string}',
|
|
120
|
+
'Reply with JSON only, no prose and no code fence: {"memories":[{"scope":"global"|"project","kind":string,"title":string,"body":string,"tags":string[],"keys":string[],"entities":string[],"appliesTo":string,"quote":string,"voice":"user"|"assistant"}],"loops":[{"text":string,"dueAt":string?}],"summary":string}',
|
|
74
121
|
'Write the "memories" array first and the "summary" paragraph last: the reply is capped, and a summary written first can spend the whole budget before the first memory is complete.',
|
|
75
122
|
'Write "summary" as one paragraph (2-4 sentences) saying what this session was about — the task, the decisions, and anything that would help someone judge the memories above later. It is stored as the evidence behind them.',
|
|
76
123
|
'When nothing is worth remembering, reply exactly {"memories":[],"summary":""}.'
|
|
@@ -100,6 +147,7 @@ export const EXTRACT_JSON_SCHEMA = {
|
|
|
100
147
|
body: { type: 'string' },
|
|
101
148
|
tags: { type: 'array', items: { type: 'string' } },
|
|
102
149
|
keys: { type: 'array', items: { type: 'string' } },
|
|
150
|
+
entities: { type: 'array', items: { type: 'string' } },
|
|
103
151
|
appliesTo: { type: 'string' },
|
|
104
152
|
quote: { type: 'string' },
|
|
105
153
|
voice: { type: 'string', enum: ['user', 'assistant'] },
|
|
@@ -210,10 +258,13 @@ function blockText(content) {
|
|
|
210
258
|
* @param session - session to read.
|
|
211
259
|
* @param afterSeq - last surface seq already mined (exclusive).
|
|
212
260
|
* @param maxMessages - message cap.
|
|
213
|
-
* @param maxChars - transcript character cap
|
|
214
|
-
* @
|
|
261
|
+
* @param maxChars - transcript character cap.
|
|
262
|
+
* @param order - which end of the backlog to keep. `newest` (the default) is
|
|
263
|
+
* the right window for a session that is nearly caught up; `oldest` is the
|
|
264
|
+
* contiguous one, and it is the only order that cannot skip a message.
|
|
265
|
+
* @returns the rendered window, the highest included seq, and how much it left out.
|
|
215
266
|
*/
|
|
216
|
-
export function collectWindow(session, afterSeq, maxMessages, maxChars) {
|
|
267
|
+
export function collectWindow(session, afterSeq, maxMessages, maxChars, order = 'newest') {
|
|
217
268
|
const floor = SessionSeq(Math.max(0, Math.trunc(afterSeq)));
|
|
218
269
|
const lines = [];
|
|
219
270
|
for (const seq of session.surface.nodes) {
|
|
@@ -234,27 +285,71 @@ export function collectWindow(session, afterSeq, maxMessages, maxChars) {
|
|
|
234
285
|
continue;
|
|
235
286
|
lines.push({ seq, role: message.role === 'user' ? 'user' : 'assistant', text });
|
|
236
287
|
}
|
|
237
|
-
|
|
288
|
+
// `newest` keeps the tail and admits lines backwards from it; `oldest` keeps
|
|
289
|
+
// the head and admits forward. Both keep at least one line even when that line
|
|
290
|
+
// alone blows the character budget: a window that is empty for budget reasons
|
|
291
|
+
// would stall the watermark on the same message forever.
|
|
292
|
+
const selected = order === 'oldest' ? lines.slice(0, maxMessages) : lines.slice(-maxMessages);
|
|
238
293
|
const kept = [];
|
|
239
294
|
let used = 0;
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
295
|
+
if (order === 'oldest') {
|
|
296
|
+
let admitted = 0;
|
|
297
|
+
for (const line of selected) {
|
|
298
|
+
const cost = `${line.role === 'user' ? 'USER' : 'ASSISTANT'}: ${line.text}`.length + 1;
|
|
299
|
+
if (used + cost > maxChars && admitted > 0)
|
|
300
|
+
break;
|
|
301
|
+
used += cost;
|
|
302
|
+
admitted += 1;
|
|
303
|
+
kept.push(line);
|
|
304
|
+
}
|
|
249
305
|
}
|
|
250
|
-
|
|
306
|
+
else {
|
|
307
|
+
for (let index = selected.length - 1; index >= 0; index -= 1) {
|
|
308
|
+
const line = selected[index];
|
|
309
|
+
if (line === undefined)
|
|
310
|
+
continue;
|
|
311
|
+
const cost = `${line.role === 'user' ? 'USER' : 'ASSISTANT'}: ${line.text}`.length + 1;
|
|
312
|
+
if (used + cost > maxChars && kept.length > 0)
|
|
313
|
+
break;
|
|
314
|
+
used += cost;
|
|
315
|
+
kept.unshift(line);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
// The highest seq the window actually covers. For `newest` that is the newest
|
|
319
|
+
// line; for `oldest` it is the newest line of the contiguous head, which is
|
|
320
|
+
// what lets the watermark advance one backlog chunk at a time.
|
|
321
|
+
const lastSeq = kept.at(-1)?.seq;
|
|
251
322
|
return {
|
|
252
323
|
text: kept.map((line) => `${line.role === 'user' ? 'USER' : 'ASSISTANT'}: ${line.text}`).join('\n\n'),
|
|
253
324
|
lastSeq,
|
|
254
325
|
messages: kept.length,
|
|
255
326
|
sources: kept.map((line) => ({ seq: line.seq, text: line.text })),
|
|
327
|
+
skipped: lines.length - kept.length,
|
|
256
328
|
};
|
|
257
329
|
}
|
|
330
|
+
/**
|
|
331
|
+
* The window one extraction pass should mine, preferring contiguity.
|
|
332
|
+
*
|
|
333
|
+
* The newest window is what a session that is nearly caught up wants: it is the
|
|
334
|
+
* most recent material. It cannot be the only order, because the message cap
|
|
335
|
+
* silently drops everything between the watermark and the tail — measured on a
|
|
336
|
+
* long session, one 400-message gap left 340 messages never mined while the
|
|
337
|
+
* watermark stepped over all of them. So: take the newest window, and when it
|
|
338
|
+
* reports a backlog, take the oldest contiguous one instead. The pass cadence
|
|
339
|
+
* then drains the backlog chunk by chunk and nothing is skipped.
|
|
340
|
+
*
|
|
341
|
+
* @param session - session to read.
|
|
342
|
+
* @param afterSeq - last surface seq already mined (exclusive).
|
|
343
|
+
* @param maxMessages - message cap per window.
|
|
344
|
+
* @param maxChars - character cap per window.
|
|
345
|
+
* @returns the window to mine.
|
|
346
|
+
*/
|
|
347
|
+
export function collectExtractionWindow(session, afterSeq, maxMessages, maxChars) {
|
|
348
|
+
const newest = collectWindow(session, afterSeq, maxMessages, maxChars);
|
|
349
|
+
if (newest.skipped === 0)
|
|
350
|
+
return newest;
|
|
351
|
+
return collectWindow(session, afterSeq, maxMessages, maxChars, 'oldest');
|
|
352
|
+
}
|
|
258
353
|
/**
|
|
259
354
|
* Resolve the provider/model route for a model call.
|
|
260
355
|
*
|
|
@@ -346,6 +441,7 @@ export function parseExtraction(text, maxMemories, sessionId) {
|
|
|
346
441
|
? record['tags'].filter((tag) => typeof tag === 'string')
|
|
347
442
|
: [];
|
|
348
443
|
const keys = Array.isArray(record['keys']) ? record['keys'].filter((key) => typeof key === 'string') : [];
|
|
444
|
+
const entities = Array.isArray(record['entities']) ? record['entities'].filter((entity) => typeof entity === 'string') : [];
|
|
349
445
|
const appliesTo = typeof record['appliesTo'] === 'string'
|
|
350
446
|
? redactSecrets(record['appliesTo'].replace(/\s+/gu, ' ').trim()).slice(0, 160)
|
|
351
447
|
: '';
|
|
@@ -359,9 +455,10 @@ export function parseExtraction(text, maxMemories, sessionId) {
|
|
|
359
455
|
const quote = typeof record['quote'] === 'string'
|
|
360
456
|
? redactSecrets(record['quote'].replace(/\s+/gu, ' ').trim()).slice(0, 300)
|
|
361
457
|
: '';
|
|
362
|
-
// "assistant" is
|
|
363
|
-
//
|
|
364
|
-
|
|
458
|
+
// "assistant" is stored explicitly (the assistant's own words are a different
|
|
459
|
+
// claim from the user's); the absent default means "the extractor's own
|
|
460
|
+
// conclusion", which is what every entry written before this field existed is.
|
|
461
|
+
const voice = record['voice'] === 'user' ? 'user' : record['voice'] === 'assistant' ? 'assistant' : undefined;
|
|
365
462
|
usable.push({
|
|
366
463
|
scope: scope,
|
|
367
464
|
kind: toMemoryKind(record['kind']),
|
|
@@ -369,6 +466,7 @@ export function parseExtraction(text, maxMemories, sessionId) {
|
|
|
369
466
|
body: cleanBody,
|
|
370
467
|
tags,
|
|
371
468
|
keys,
|
|
469
|
+
entities,
|
|
372
470
|
...voice === undefined ? {} : { voice },
|
|
373
471
|
...appliesTo.length > 0 ? { appliesTo } : {},
|
|
374
472
|
...quote.length > 0 && quote !== '[redacted]' ? { quote } : {},
|
|
@@ -411,21 +509,30 @@ function squash(value) {
|
|
|
411
509
|
*/
|
|
412
510
|
export function bindEvidence(drafts, sources) {
|
|
413
511
|
const verified = [];
|
|
512
|
+
const dropped = [];
|
|
414
513
|
let unsupported = 0;
|
|
415
514
|
for (const draft of drafts) {
|
|
416
515
|
const quote = draft.quote === undefined ? '' : squash(draft.quote);
|
|
516
|
+
const preview = quote.slice(0, 60);
|
|
517
|
+
if (quote.length === 0) {
|
|
518
|
+
unsupported += 1;
|
|
519
|
+
dropped.push({ title: draft.title, quotePreview: '', reason: 'no-quote' });
|
|
520
|
+
continue;
|
|
521
|
+
}
|
|
417
522
|
if (quote.length < MIN_QUOTE_CHARS) {
|
|
418
523
|
unsupported += 1;
|
|
524
|
+
dropped.push({ title: draft.title, quotePreview: preview, reason: 'quote-too-short' });
|
|
419
525
|
continue;
|
|
420
526
|
}
|
|
421
527
|
const source = sources.find((candidate) => squash(candidate.text).includes(quote));
|
|
422
528
|
if (source === undefined) {
|
|
423
529
|
unsupported += 1;
|
|
530
|
+
dropped.push({ title: draft.title, quotePreview: preview, reason: 'not-in-transcript' });
|
|
424
531
|
continue;
|
|
425
532
|
}
|
|
426
533
|
verified.push({ ...draft, evidenceSeq: source.seq });
|
|
427
534
|
}
|
|
428
|
-
return { drafts: verified, unsupported };
|
|
535
|
+
return { drafts: verified, unsupported, dropped };
|
|
429
536
|
}
|
|
430
537
|
/** The user's local calendar date, as `YYYY-MM-DD`, for resolving relative times. */
|
|
431
538
|
function localDate(now = new Date()) {
|
|
@@ -519,6 +626,7 @@ export async function runExtraction(llm, request) {
|
|
|
519
626
|
summary: salvaged.summary,
|
|
520
627
|
dropped: salvaged.dropped,
|
|
521
628
|
unsupported: bound.unsupported,
|
|
629
|
+
...bound.dropped.length === 0 ? {} : { droppedEvidence: bound.dropped },
|
|
522
630
|
route,
|
|
523
631
|
truncated: true,
|
|
524
632
|
...usage === undefined ? {} : { usage },
|
|
@@ -536,7 +644,7 @@ export async function runExtraction(llm, request) {
|
|
|
536
644
|
if (bound.drafts.length === 0) {
|
|
537
645
|
return { kind: 'none', reason: 'unsupported-evidence', route, ...usage === undefined ? {} : { usage } };
|
|
538
646
|
}
|
|
539
|
-
return { kind: 'memories', drafts: bound.drafts, loops: parsed.loops, summary: parsed.summary, dropped: parsed.dropped, unsupported: bound.unsupported, route, ...usage === undefined ? {} : { usage } };
|
|
647
|
+
return { kind: 'memories', drafts: bound.drafts, loops: parsed.loops, summary: parsed.summary, dropped: parsed.dropped, unsupported: bound.unsupported, ...bound.dropped.length === 0 ? {} : { droppedEvidence: bound.dropped }, route, ...usage === undefined ? {} : { usage } };
|
|
540
648
|
}
|
|
541
649
|
/**
|
|
542
650
|
* Close a JSON reply the output cap cut in half.
|