agent-recall-core 3.4.46 → 3.4.47
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/dist/helpers/handoff.d.ts.map +1 -1
- package/dist/helpers/handoff.js +17 -9
- package/dist/helpers/handoff.js.map +1 -1
- package/dist/helpers/journal-files.d.ts +24 -1
- package/dist/helpers/journal-files.d.ts.map +1 -1
- package/dist/helpers/journal-files.js +29 -10
- package/dist/helpers/journal-files.js.map +1 -1
- package/dist/helpers/journal-filter.d.ts +25 -0
- package/dist/helpers/journal-filter.d.ts.map +1 -1
- package/dist/helpers/journal-filter.js +12 -1
- package/dist/helpers/journal-filter.js.map +1 -1
- package/dist/index.d.ts +12 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -4
- package/dist/index.js.map +1 -1
- package/dist/retrieval/candidates.d.ts +314 -0
- package/dist/retrieval/candidates.d.ts.map +1 -0
- package/dist/retrieval/candidates.js +321 -0
- package/dist/retrieval/candidates.js.map +1 -0
- package/dist/retrieval/contradiction.d.ts +232 -0
- package/dist/retrieval/contradiction.d.ts.map +1 -0
- package/dist/retrieval/contradiction.js +320 -0
- package/dist/retrieval/contradiction.js.map +1 -0
- package/dist/retrieval/query-memory.d.ts +419 -0
- package/dist/retrieval/query-memory.d.ts.map +1 -0
- package/dist/retrieval/query-memory.js +1068 -0
- package/dist/retrieval/query-memory.js.map +1 -0
- package/dist/retrieval/scope.d.ts +75 -0
- package/dist/retrieval/scope.d.ts.map +1 -0
- package/dist/retrieval/scope.js +91 -0
- package/dist/retrieval/scope.js.map +1 -0
- package/dist/storage/corrections.d.ts +31 -1
- package/dist/storage/corrections.d.ts.map +1 -1
- package/dist/storage/corrections.js +34 -1
- package/dist/storage/corrections.js.map +1 -1
- package/dist/storage/lifecycle-telemetry.d.ts +20 -5
- package/dist/storage/lifecycle-telemetry.d.ts.map +1 -1
- package/dist/storage/lifecycle-telemetry.js +16 -5
- package/dist/storage/lifecycle-telemetry.js.map +1 -1
- package/dist/storage/session.d.ts +28 -1
- package/dist/storage/session.d.ts.map +1 -1
- package/dist/storage/session.js +41 -8
- package/dist/storage/session.js.map +1 -1
- package/dist/supabase/recall-backend.d.ts +25 -2
- package/dist/supabase/recall-backend.d.ts.map +1 -1
- package/dist/supabase/recall-backend.js +82 -21
- package/dist/supabase/recall-backend.js.map +1 -1
- package/dist/supabase/sync.d.ts +41 -0
- package/dist/supabase/sync.d.ts.map +1 -1
- package/dist/supabase/sync.js +46 -0
- package/dist/supabase/sync.js.map +1 -1
- package/dist/tools-logic/check.d.ts.map +1 -1
- package/dist/tools-logic/check.js +62 -36
- package/dist/tools-logic/check.js.map +1 -1
- package/dist/tools-logic/drill-down.d.ts +24 -0
- package/dist/tools-logic/drill-down.d.ts.map +1 -1
- package/dist/tools-logic/drill-down.js +36 -0
- package/dist/tools-logic/drill-down.js.map +1 -1
- package/dist/tools-logic/journal-cold-start.d.ts.map +1 -1
- package/dist/tools-logic/journal-cold-start.js +48 -9
- package/dist/tools-logic/journal-cold-start.js.map +1 -1
- package/dist/tools-logic/journal-list.d.ts +42 -0
- package/dist/tools-logic/journal-list.d.ts.map +1 -1
- package/dist/tools-logic/journal-list.js +60 -10
- package/dist/tools-logic/journal-list.js.map +1 -1
- package/dist/tools-logic/journal-read.d.ts.map +1 -1
- package/dist/tools-logic/journal-read.js +22 -13
- package/dist/tools-logic/journal-read.js.map +1 -1
- package/dist/tools-logic/journal-search.d.ts +58 -0
- package/dist/tools-logic/journal-search.d.ts.map +1 -1
- package/dist/tools-logic/journal-search.js +123 -92
- package/dist/tools-logic/journal-search.js.map +1 -1
- package/dist/tools-logic/palace-search.d.ts.map +1 -1
- package/dist/tools-logic/palace-search.js +30 -11
- package/dist/tools-logic/palace-search.js.map +1 -1
- package/dist/tools-logic/palace-walk.d.ts +10 -0
- package/dist/tools-logic/palace-walk.d.ts.map +1 -1
- package/dist/tools-logic/palace-walk.js +25 -16
- package/dist/tools-logic/palace-walk.js.map +1 -1
- package/dist/tools-logic/recall-insight.d.ts +20 -0
- package/dist/tools-logic/recall-insight.d.ts.map +1 -1
- package/dist/tools-logic/recall-insight.js +12 -1
- package/dist/tools-logic/recall-insight.js.map +1 -1
- package/dist/tools-logic/session-end.d.ts.map +1 -1
- package/dist/tools-logic/session-end.js +23 -7
- package/dist/tools-logic/session-end.js.map +1 -1
- package/dist/tools-logic/session-start.d.ts +85 -0
- package/dist/tools-logic/session-start.d.ts.map +1 -1
- package/dist/tools-logic/session-start.js +245 -108
- package/dist/tools-logic/session-start.js.map +1 -1
- package/dist/tools-logic/smart-recall.d.ts +87 -62
- package/dist/tools-logic/smart-recall.d.ts.map +1 -1
- package/dist/tools-logic/smart-recall.js +159 -510
- package/dist/tools-logic/smart-recall.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drill-down.js","sourceRoot":"","sources":["../../src/tools-logic/drill-down.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"drill-down.js","sourceRoot":"","sources":["../../src/tools-logic/drill-down.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAsBtC,6EAA6E;AAC7E,MAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,SAAS,GAAG,CAAC,CAAS;IACpB,OAAO,CAAC,CAAC,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,EAAE,CAAC;QACvB,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC;QACrE,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YAC7C,MAAM,IAAI,KAAK,CAAC,6BAA6B,GAAG,CAAC,IAAI,SAAS,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;QAC5E,CAAC;QAED,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;QACnC,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QACzC,uEAAuE;QACvE,qEAAqE;QACrE,kEAAkE;QAClE,wEAAwE;QACxE,IAAI,sBAAsB,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QAC9C,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;IACpF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC,CAAC,0BAA0B;IACzC,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"journal-cold-start.d.ts","sourceRoot":"","sources":["../../src/tools-logic/journal-cold-start.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"journal-cold-start.d.ts","sourceRoot":"","sources":["../../src/tools-logic/journal-cold-start.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,cAAc,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACzD,cAAc,EAAE;QACd,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;QACjC,SAAS,EAAE,KAAK,CAAC;YACf,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,EAAE,MAAM,CAAC;YACb,QAAQ,EAAE,MAAM,CAAC;YACjB,WAAW,EAAE,MAAM,CAAC;YACpB,cAAc,EAAE,MAAM,EAAE,CAAC;SAC1B,CAAC,CAAC;QACH,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,KAAK,EAAE;QACL,GAAG,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,KAAK,CAAC;gBAAE,IAAI,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;gBAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;aAAE,CAAC,CAAA;SAAE,CAAC;QAC3G,IAAI,EAAE;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC;QACxB,IAAI,EAAE;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC;KACzB,CAAC;IACF,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAgJpG"}
|
|
@@ -8,6 +8,7 @@ import { palaceDir } from "../storage/paths.js";
|
|
|
8
8
|
import { ensurePalaceInitialized, listRooms } from "../palace/rooms.js";
|
|
9
9
|
import { readAwareness, readAwarenessState } from "../palace/awareness.js";
|
|
10
10
|
import { readP0Corrections } from "../storage/corrections.js";
|
|
11
|
+
import { readTierCandidates } from "../retrieval/candidates.js";
|
|
11
12
|
export async function journalColdStart(input) {
|
|
12
13
|
const slug = await resolveProject(input.project);
|
|
13
14
|
const entries = listJournalFiles(slug);
|
|
@@ -31,11 +32,19 @@ export async function journalColdStart(input) {
|
|
|
31
32
|
palaceContext.awareness_summary = awarenessContent.split("\n").slice(0, 60).join("\n");
|
|
32
33
|
}
|
|
33
34
|
const rooms = listRooms(slug);
|
|
35
|
+
// Wave 3a (P0 palace-room KNOWN-GAP closure, 2026-08-30): routed through
|
|
36
|
+
// the shared, trust-safe FETCH stage (readTierCandidates) instead of a
|
|
37
|
+
// raw fs.existsSync+readFileSync on the room's README.md — a
|
|
38
|
+
// rescue-tagged README can no longer be dumped verbatim into the
|
|
39
|
+
// cold-start bootstrap payload. readTierCandidates includes README.md by
|
|
40
|
+
// default (matching the original scope), so filtering to that one file
|
|
41
|
+
// reproduces the "top-3 rooms, README focus" selection exactly.
|
|
34
42
|
palaceContext.top_rooms = rooms.slice(0, 3).map(r => {
|
|
35
|
-
const
|
|
43
|
+
const roomCandidates = readTierCandidates("palace-room", slug, { room: r.slug });
|
|
44
|
+
const readmeCandidate = roomCandidates.find(c => c.file === "README.md");
|
|
36
45
|
let recentEntries = [];
|
|
37
|
-
if (
|
|
38
|
-
const rmContent =
|
|
46
|
+
if (readmeCandidate) {
|
|
47
|
+
const rmContent = readmeCandidate.content;
|
|
39
48
|
// Split on entry headers "### date — importance"
|
|
40
49
|
const parts = rmContent.split(/(?=^### )/m).filter(s => s.trimStart().startsWith("###"));
|
|
41
50
|
// Take last 3, trim to 300 chars each to keep cold-start lean
|
|
@@ -74,17 +83,47 @@ export async function journalColdStart(input) {
|
|
|
74
83
|
const hot = [];
|
|
75
84
|
let warmCount = 0;
|
|
76
85
|
let coldCount = 0;
|
|
86
|
+
// Wave 3a (P0 palace-room KNOWN-GAP closure, 2026-08-30): the hot-window
|
|
87
|
+
// journal content is now sourced from the shared, trust-safe FETCH stage
|
|
88
|
+
// (readTierCandidates) instead of a raw fs.statSync+readFileSync per
|
|
89
|
+
// entry — a rescue-tagged journal card falling inside the 1.5-day hot
|
|
90
|
+
// window can no longer have its brief surfaced into the cold-start dump.
|
|
91
|
+
// `entries` itself still comes from listJournalFiles (unchanged, used
|
|
92
|
+
// only for existence/date bucketing, never content), and
|
|
93
|
+
// readTierCandidates's own live-half reader calls that SAME function
|
|
94
|
+
// internally with the SAME default (includeArchive=false), so
|
|
95
|
+
// `sourcePath` keys line up 1:1 with `path.join(entry.dir, entry.file)`.
|
|
96
|
+
const journalCandidates = readTierCandidates("journal", slug);
|
|
97
|
+
const journalCandidateByPath = new Map(journalCandidates.map(c => [c.sourcePath, c]));
|
|
77
98
|
for (const entry of entries) {
|
|
78
99
|
const ageMs = Date.now() - new Date(entry.date).getTime();
|
|
79
100
|
const ageDays = ageMs / (1000 * 60 * 60 * 24);
|
|
80
101
|
if (ageDays <= 1.5) {
|
|
81
|
-
const state = readState(slug, entry.date);
|
|
82
102
|
const fullPath = path.join(entry.dir, entry.file);
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
103
|
+
const candidate = journalCandidateByPath.get(fullPath);
|
|
104
|
+
const state = readState(slug, entry.date);
|
|
105
|
+
// Wave 3a review fix (2026-08-30): a rescue-tagged (trust-filtered) or
|
|
106
|
+
// otherwise-unreadable hot-window entry still EXISTS — its date is
|
|
107
|
+
// mtime-derived, not attacker-controlled — so it is counted in `hot`
|
|
108
|
+
// with a NULL brief (content quarantined, existence preserved), never
|
|
109
|
+
// dropped. The old `if (!candidate) continue` skipped it from every
|
|
110
|
+
// bucket while `total_entries` (= entries.length) still counted it, so
|
|
111
|
+
// hot+warm+cold diverged from total_entries whenever a rescue card fell
|
|
112
|
+
// in the 1.5-day window — a silently-wrong surfaced count. This mirrors
|
|
113
|
+
// the journal-list quarantine-not-drop decision; the bucket sum now
|
|
114
|
+
// always equals total_entries.
|
|
115
|
+
let brief = null;
|
|
116
|
+
if (candidate) {
|
|
117
|
+
// Threshold uses char-count (`content.length`, UTF-16 code units),
|
|
118
|
+
// consistent with the char-count slice below — the old code compared
|
|
119
|
+
// bytes (`stats.size`) but sliced by chars, so a CJK-heavy file could
|
|
120
|
+
// get a false "...(truncated)" marker while never actually being cut.
|
|
121
|
+
const content = candidate.content.length > 20000
|
|
122
|
+
? candidate.content.slice(0, 20000) + "\n...(truncated)"
|
|
123
|
+
: candidate.content;
|
|
124
|
+
brief = extractSection(content, "brief");
|
|
125
|
+
}
|
|
126
|
+
hot.push({ date: entry.date, state, brief });
|
|
88
127
|
}
|
|
89
128
|
else if (ageDays <= 7) {
|
|
90
129
|
warmCount++;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"journal-cold-start.js","sourceRoot":"","sources":["../../src/tools-logic/journal-cold-start.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AA+
|
|
1
|
+
{"version":3,"file":"journal-cold-start.js","sourceRoot":"","sources":["../../src/tools-logic/journal-cold-start.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAA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,SAAS,EAAE,CAAC;gBACd,mEAAmE;gBACnE,qEAAqE;gBACrE,sEAAsE;gBACtE,sEAAsE;gBACtE,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK;oBAC9C,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,kBAAkB;oBACxD,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC;gBACtB,KAAK,GAAG,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC3C,CAAC;YACD,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/C,CAAC;aAAM,IAAI,OAAO,IAAI,CAAC,EAAE,CAAC;YACxB,SAAS,EAAE,CAAC;QACd,CAAC;aAAM,CAAC;YACN,SAAS,EAAE,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,UAAU;QACV,cAAc,EAAE,aAAa;QAC7B,cAAc,EAAE,aAAa;QAC7B,KAAK,EAAE;YACL,GAAG,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE;YACxC,IAAI,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE;YAC1B,IAAI,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE;SAC3B;QACD,aAAa,EAAE,OAAO,CAAC,MAAM;KAC9B,CAAC;AACJ,CAAC"}
|
|
@@ -10,5 +10,47 @@ export interface JournalListResult {
|
|
|
10
10
|
momentum: string;
|
|
11
11
|
}>;
|
|
12
12
|
}
|
|
13
|
+
/** Title shown for a quarantined (rescue-sourced) entry — never the real, attacker-influenced title/momentum. */
|
|
14
|
+
export declare const QUARANTINE_TITLE = "[quarantined \u2014 rescue-sourced entry]";
|
|
15
|
+
/**
|
|
16
|
+
* Identity-trust (P0 trust-class closure, 2026-08-30, wave/pipe-p0-trustclass;
|
|
17
|
+
* REVISED by the independent-review FIX 1 pass, same date):
|
|
18
|
+
*
|
|
19
|
+
* ORIGINAL fix (this wave's first pass) routed through `readTierCandidates`,
|
|
20
|
+
* which DROPS the whole rescue-tagged row before returning. Independent
|
|
21
|
+
* review flagged this as an over-reach: `candidate.date` here is the
|
|
22
|
+
* journal-live tier's FILENAME date, itself derived from `listJournalFiles`'s
|
|
23
|
+
* own `dateMatch` guard at rescue-write time — i.e. system-clock-derived at
|
|
24
|
+
* the moment `distillOneSession` wrote the card
|
|
25
|
+
* (`storage/working-memory.ts`'s `writeSessionCard` call), NOT a value an
|
|
26
|
+
* attacker's prompt content can influence. Only `title`/`momentum` (parsed
|
|
27
|
+
* from the file's raw BODY) are the actual injection vector. Dropping the
|
|
28
|
+
* whole row therefore hid the entry's EXISTENCE for no security reason —
|
|
29
|
+
* and because `limit` was applied AFTER the drop, `journal_list(limit=N)`
|
|
30
|
+
* silently backfilled the quota from further back in time, misrepresenting
|
|
31
|
+
* recency/continuity with no signal to the caller that anything was hidden.
|
|
32
|
+
*
|
|
33
|
+
* THE FIX: use `listCandidateStubs` (packages/core/src/retrieval/
|
|
34
|
+
* candidates.ts) instead of `readTierCandidates` — it preserves EVERY
|
|
35
|
+
* candidate's existence (date/file) but strips `content` for any row whose
|
|
36
|
+
* underlying candidate is untrusted. A quarantined row here renders with
|
|
37
|
+
* `QUARANTINE_TITLE` and an empty momentum, AT its real date, in its real
|
|
38
|
+
* chronological position — never dropped, never given a fabricated
|
|
39
|
+
* title/momentum. `limit` is applied to the FULL rendered list (quarantined
|
|
40
|
+
* rows included, in position), so the window never silently backfills past
|
|
41
|
+
* a hidden entry.
|
|
42
|
+
*
|
|
43
|
+
* Error-path note (Worker Done-Definition #1): a journal-live-tier candidate's
|
|
44
|
+
* `date` can never be malformed/unparseable here — `listJournalFiles` (the
|
|
45
|
+
* live-tier reader `listCandidateStubs("journal", ...)` delegates to)
|
|
46
|
+
* requires a leading `^\d{4}-\d{2}-\d{2}` filename match before a file is
|
|
47
|
+
* even considered a candidate at all (see helpers/journal-files.ts), so
|
|
48
|
+
* every candidate this function ever sees already carries a well-formed
|
|
49
|
+
* date string by construction — no additional validation/fallback is needed
|
|
50
|
+
* here for that path. (journalList never opts into rollup/raw-archive
|
|
51
|
+
* candidates, whose date semantics differ — see candidates.ts's own header —
|
|
52
|
+
* so this guarantee is not weakened by a future opt-in without a
|
|
53
|
+
* corresponding review of this comment.)
|
|
54
|
+
*/
|
|
13
55
|
export declare function journalList(input: JournalListInput): Promise<JournalListResult>;
|
|
14
56
|
//# sourceMappingURL=journal-list.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"journal-list.d.ts","sourceRoot":"","sources":["../../src/tools-logic/journal-list.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"journal-list.d.ts","sourceRoot":"","sources":["../../src/tools-logic/journal-list.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACnE;AAED,iHAAiH;AACjH,eAAO,MAAM,gBAAgB,8CAAyC,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAsB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAwBrF"}
|
|
@@ -1,18 +1,68 @@
|
|
|
1
|
-
import * as fs from "node:fs";
|
|
2
|
-
import * as path from "node:path";
|
|
3
1
|
import { resolveProject } from "../storage/project.js";
|
|
4
|
-
import {
|
|
2
|
+
import { extractTitle, extractMomentum } from "../helpers/journal-files.js";
|
|
3
|
+
import { listCandidateStubs } from "../retrieval/candidates.js";
|
|
4
|
+
/** Title shown for a quarantined (rescue-sourced) entry — never the real, attacker-influenced title/momentum. */
|
|
5
|
+
export const QUARANTINE_TITLE = "[quarantined — rescue-sourced entry]";
|
|
6
|
+
/**
|
|
7
|
+
* Identity-trust (P0 trust-class closure, 2026-08-30, wave/pipe-p0-trustclass;
|
|
8
|
+
* REVISED by the independent-review FIX 1 pass, same date):
|
|
9
|
+
*
|
|
10
|
+
* ORIGINAL fix (this wave's first pass) routed through `readTierCandidates`,
|
|
11
|
+
* which DROPS the whole rescue-tagged row before returning. Independent
|
|
12
|
+
* review flagged this as an over-reach: `candidate.date` here is the
|
|
13
|
+
* journal-live tier's FILENAME date, itself derived from `listJournalFiles`'s
|
|
14
|
+
* own `dateMatch` guard at rescue-write time — i.e. system-clock-derived at
|
|
15
|
+
* the moment `distillOneSession` wrote the card
|
|
16
|
+
* (`storage/working-memory.ts`'s `writeSessionCard` call), NOT a value an
|
|
17
|
+
* attacker's prompt content can influence. Only `title`/`momentum` (parsed
|
|
18
|
+
* from the file's raw BODY) are the actual injection vector. Dropping the
|
|
19
|
+
* whole row therefore hid the entry's EXISTENCE for no security reason —
|
|
20
|
+
* and because `limit` was applied AFTER the drop, `journal_list(limit=N)`
|
|
21
|
+
* silently backfilled the quota from further back in time, misrepresenting
|
|
22
|
+
* recency/continuity with no signal to the caller that anything was hidden.
|
|
23
|
+
*
|
|
24
|
+
* THE FIX: use `listCandidateStubs` (packages/core/src/retrieval/
|
|
25
|
+
* candidates.ts) instead of `readTierCandidates` — it preserves EVERY
|
|
26
|
+
* candidate's existence (date/file) but strips `content` for any row whose
|
|
27
|
+
* underlying candidate is untrusted. A quarantined row here renders with
|
|
28
|
+
* `QUARANTINE_TITLE` and an empty momentum, AT its real date, in its real
|
|
29
|
+
* chronological position — never dropped, never given a fabricated
|
|
30
|
+
* title/momentum. `limit` is applied to the FULL rendered list (quarantined
|
|
31
|
+
* rows included, in position), so the window never silently backfills past
|
|
32
|
+
* a hidden entry.
|
|
33
|
+
*
|
|
34
|
+
* Error-path note (Worker Done-Definition #1): a journal-live-tier candidate's
|
|
35
|
+
* `date` can never be malformed/unparseable here — `listJournalFiles` (the
|
|
36
|
+
* live-tier reader `listCandidateStubs("journal", ...)` delegates to)
|
|
37
|
+
* requires a leading `^\d{4}-\d{2}-\d{2}` filename match before a file is
|
|
38
|
+
* even considered a candidate at all (see helpers/journal-files.ts), so
|
|
39
|
+
* every candidate this function ever sees already carries a well-formed
|
|
40
|
+
* date string by construction — no additional validation/fallback is needed
|
|
41
|
+
* here for that path. (journalList never opts into rollup/raw-archive
|
|
42
|
+
* candidates, whose date semantics differ — see candidates.ts's own header —
|
|
43
|
+
* so this guarantee is not weakened by a future opt-in without a
|
|
44
|
+
* corresponding review of this comment.)
|
|
45
|
+
*/
|
|
5
46
|
export async function journalList(input) {
|
|
6
47
|
const slug = await resolveProject(input.project);
|
|
7
|
-
|
|
48
|
+
const stubs = listCandidateStubs("journal", slug);
|
|
8
49
|
const limit = input.limit ?? 10;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const content =
|
|
14
|
-
return {
|
|
50
|
+
const entries = stubs.map((s) => {
|
|
51
|
+
if (!s.trusted) {
|
|
52
|
+
return { date: s.date, title: QUARANTINE_TITLE, momentum: "" };
|
|
53
|
+
}
|
|
54
|
+
const content = s.content ?? "";
|
|
55
|
+
return {
|
|
56
|
+
date: s.date,
|
|
57
|
+
title: extractTitle(content),
|
|
58
|
+
momentum: extractMomentum(content),
|
|
59
|
+
};
|
|
15
60
|
});
|
|
61
|
+
// Slice the FULL rendered list (quarantined rows included, in their real
|
|
62
|
+
// chronological position) — never slice the raw candidate/stub array
|
|
63
|
+
// before rendering. This is what closes the "silent backfill" bug: the
|
|
64
|
+
// limit window's boundary is decided over the SAME set a caller sees.
|
|
65
|
+
const result = limit > 0 ? entries.slice(0, limit) : entries;
|
|
16
66
|
return { project: slug, entries: result };
|
|
17
67
|
}
|
|
18
68
|
//# sourceMappingURL=journal-list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"journal-list.js","sourceRoot":"","sources":["../../src/tools-logic/journal-list.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"journal-list.js","sourceRoot":"","sources":["../../src/tools-logic/journal-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAYhE,iHAAiH;AACjH,MAAM,CAAC,MAAM,gBAAgB,GAAG,sCAAsC,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,KAAuB;IACvD,MAAM,IAAI,GAAG,MAAM,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjD,MAAM,KAAK,GAAG,kBAAkB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAClD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;IAEhC,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAC9B,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;YACf,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;QACjE,CAAC;QACD,MAAM,OAAO,GAAG,CAAC,CAAC,OAAO,IAAI,EAAE,CAAC;QAChC,OAAO;YACL,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC;YAC5B,QAAQ,EAAE,eAAe,CAAC,OAAO,CAAC;SACnC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,yEAAyE;IACzE,qEAAqE;IACrE,uEAAuE;IACvE,sEAAsE;IACtE,MAAM,MAAM,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAE7D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAC5C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"journal-read.d.ts","sourceRoot":"","sources":["../../src/tools-logic/journal-read.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"journal-read.d.ts","sourceRoot":"","sources":["../../src/tools-logic/journal-read.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAgDrF"}
|
|
@@ -1,34 +1,43 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
|
-
import * as path from "node:path";
|
|
3
2
|
import { resolveProject } from "../storage/project.js";
|
|
4
|
-
import {
|
|
3
|
+
import { readJournalFile } from "../helpers/journal-files.js";
|
|
5
4
|
import { extractSection } from "../helpers/sections.js";
|
|
5
|
+
import { readTierCandidates } from "../retrieval/candidates.js";
|
|
6
6
|
export async function journalRead(input) {
|
|
7
7
|
const slug = await resolveProject(input.project);
|
|
8
8
|
let targetDate = input.date ?? "latest";
|
|
9
9
|
if (targetDate === "latest") {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
// Identity-trust (P0 trust-class closure, 2026-08-30, wave/pipe-p0-trustclass,
|
|
11
|
+
// gap #1): was a hand-rolled listJournalFiles()+mtime scan with its OWN
|
|
12
|
+
// raw fs.readFileSync, bypassing readJournalFile's choke entirely — a
|
|
13
|
+
// rescue-tagged card could win "latest" and surface unfiltered. Routed
|
|
14
|
+
// through readTierCandidates (already trust-tagged + safe-by-default:
|
|
15
|
+
// drops untrusted candidates before returning), matching includeRollupArchive
|
|
16
|
+
// to the original's `listJournalFiles(slug, true)` includeArchive=true scope.
|
|
17
|
+
const candidates = readTierCandidates("journal", slug, { includeRollupArchive: true });
|
|
18
|
+
if (candidates.length === 0) {
|
|
12
19
|
return { content: "", date: "", project: slug, error: `No journal entries found for project '${slug}'` };
|
|
13
20
|
}
|
|
14
|
-
// Among
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
// Among candidates with the most recent date, pick the one with the
|
|
22
|
+
// highest mtime (candidates are NOT guaranteed globally date-sorted:
|
|
23
|
+
// the live half and the rollup-archive half are each sorted
|
|
24
|
+
// independently, then concatenated — see candidates.ts's own header).
|
|
25
|
+
const latestDate = candidates.reduce((max, c) => (c.date > max ? c.date : max), candidates[0].date);
|
|
26
|
+
const recentCandidates = candidates.filter(c => c.date === latestDate);
|
|
27
|
+
let bestCandidate = recentCandidates[0];
|
|
18
28
|
let bestMtime = 0;
|
|
19
|
-
for (const
|
|
29
|
+
for (const cand of recentCandidates) {
|
|
20
30
|
try {
|
|
21
|
-
const stat = fs.statSync(
|
|
31
|
+
const stat = fs.statSync(cand.sourcePath);
|
|
22
32
|
if (stat.mtimeMs > bestMtime) {
|
|
23
33
|
bestMtime = stat.mtimeMs;
|
|
24
|
-
|
|
34
|
+
bestCandidate = cand;
|
|
25
35
|
}
|
|
26
36
|
}
|
|
27
37
|
catch { /* skip unreadable files */ }
|
|
28
38
|
}
|
|
29
|
-
const raw = fs.readFileSync(path.join(bestEntry.dir, bestEntry.file), "utf-8");
|
|
30
39
|
const section = input.section ?? "all";
|
|
31
|
-
const extracted = extractSection(
|
|
40
|
+
const extracted = extractSection(bestCandidate.content, section) || "";
|
|
32
41
|
const content = extracted.length > 20000 ? extracted.slice(0, 20000) + "\n\n...(truncated)" : extracted;
|
|
33
42
|
return { content, date: latestDate, project: slug };
|
|
34
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"journal-read.js","sourceRoot":"","sources":["../../src/tools-logic/journal-read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,
|
|
1
|
+
{"version":3,"file":"journal-read.js","sourceRoot":"","sources":["../../src/tools-logic/journal-read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,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oB,CAAC,CAAC,CAAC,GAAG,CAAC;IACtF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACtD,CAAC"}
|
|
@@ -8,6 +8,15 @@ export interface JournalSearchInput {
|
|
|
8
8
|
* Accepts ISO date string ("2026-05-01") or relative duration ("7d", "30d").
|
|
9
9
|
* Palace and insight results are unaffected. */
|
|
10
10
|
since?: string;
|
|
11
|
+
/** SCOPE stage (Wave 3b, retrieval/scope.ts) — threaded through to
|
|
12
|
+
* queryMemory() for forward-compat with future consumers of this seam.
|
|
13
|
+
* Currently a NO-OP for the journal tier: readTierCandidates("journal",
|
|
14
|
+
* project, ...) only ever reads `project`'s own tree, so every journal
|
|
15
|
+
* candidate is trivially "of project" — there is nothing cross-project
|
|
16
|
+
* to filter (see query-memory.ts's `SCOPE_ATTRIBUTED_TIERS`). Kept as an
|
|
17
|
+
* accepted parameter so a future genuinely cross-project journal-like
|
|
18
|
+
* tier does not require another signature change here. */
|
|
19
|
+
scope?: string;
|
|
11
20
|
}
|
|
12
21
|
/**
|
|
13
22
|
* Parse a `since` value into a Date cutoff.
|
|
@@ -16,10 +25,59 @@ export interface JournalSearchInput {
|
|
|
16
25
|
export declare function parseSinceDate(since: string): Date;
|
|
17
26
|
export interface JournalSearchResult {
|
|
18
27
|
results: Array<{
|
|
28
|
+
/**
|
|
29
|
+
* RESOLVABLE-ANNOTATION fix (pre-ship red-team fix, STEP 4c, 2026-09-01,
|
|
30
|
+
* wave/pipe-w5fix — correctness red-team). Additive: this result's own
|
|
31
|
+
* stable identity (`QueryMemoryItem.id`, the SAME id `smart_recall`'s
|
|
32
|
+
* `SmartRecallResultItem.id` exposes for the equivalent underlying
|
|
33
|
+
* item), so `supersededBy`/`conflictsWith` below can be cross-referenced
|
|
34
|
+
* against a SIBLING entry's `id` in this SAME array — mirroring
|
|
35
|
+
* `SmartRecallResultItem`'s existing `id` field. Before this fix,
|
|
36
|
+
* `JournalSearchResult.results` carried no `id` of its own at all, so an
|
|
37
|
+
* agent reading `journal_search`'s JSON output had a `supersededBy`
|
|
38
|
+
* value with nothing in the SAME payload to resolve it against (it was
|
|
39
|
+
* only meaningful against `queryMemory()`'s internal, unexposed item
|
|
40
|
+
* set) — this is `E10`'s "annotation is resolvable via id" requirement.
|
|
41
|
+
*/
|
|
42
|
+
id: string;
|
|
19
43
|
date: string;
|
|
20
44
|
section: string;
|
|
21
45
|
excerpt: string;
|
|
22
46
|
line: number;
|
|
47
|
+
/**
|
|
48
|
+
* CONTRADICTION stage (Wave 5a, `retrieval/contradiction.ts`) — set ONLY
|
|
49
|
+
* when this result was detected as the STALE side of a same-tier
|
|
50
|
+
* version-token conflict with a sibling that could be confidently
|
|
51
|
+
* ordered as more current. Holds the CURRENT sibling's `id` — as of the
|
|
52
|
+
* STEP 4c fix above, that id is now this SAME array's own `id` field for
|
|
53
|
+
* the corresponding entry (when that sibling survives this call's own
|
|
54
|
+
* `section` filter / `limit` truncation — see below). Additive — absent
|
|
55
|
+
* when no conflict was detected. W5a salvage (2026-08-31, HIGH-3): this
|
|
56
|
+
* field was computed by `queryMemory()`'s journal tier all along but
|
|
57
|
+
* silently dropped by this function's own field-list map below (the
|
|
58
|
+
* same gap `smart-recall.ts`'s `localRecallSearch` had) — now threaded
|
|
59
|
+
* through. NOTE: since `journalSearch()` still applies its own `section`
|
|
60
|
+
* filter and `limit` slice AFTER this map, a `supersededBy`/
|
|
61
|
+
* `conflictsWith` id CAN still point at a sibling that this call's OWN
|
|
62
|
+
* filtered/truncated `results` array no longer contains — this is an
|
|
63
|
+
* accepted, additive-metadata limitation (see STEP 3 of the W5a salvage
|
|
64
|
+
* report), not a broken contract: the id is still meaningful against the
|
|
65
|
+
* underlying `queryMemory()` candidate set, and — as of STEP 4c —
|
|
66
|
+
* resolvable within THIS array whenever both sides of the pair survive
|
|
67
|
+
* the same filter/truncation (unlike before, when there was no `id`
|
|
68
|
+
* field on this shape to resolve against even in that common case).
|
|
69
|
+
* ANNOTATE-ONLY (STEP 4a): a `supersededBy` result's rank/order in this
|
|
70
|
+
* array is never changed by the contradiction stage itself (see
|
|
71
|
+
* query-memory.ts's `applyContradictionStage`) — journalSearch's own
|
|
72
|
+
* independent date-descending sort below is unaffected either way.
|
|
73
|
+
*/
|
|
74
|
+
supersededBy?: string;
|
|
75
|
+
/** CONTRADICTION stage (Wave 5a) — the `id`s of every sibling this
|
|
76
|
+
* result's text grammar-conflicts with, regardless of whether a stale
|
|
77
|
+
* direction could be resolved. See `supersededBy`'s doc comment for
|
|
78
|
+
* the same truncation/section-filter caveat, and for the STEP 4c
|
|
79
|
+
* resolvable-via-`id` fix. */
|
|
80
|
+
conflictsWith?: string[];
|
|
23
81
|
}>;
|
|
24
82
|
palace_searched: boolean;
|
|
25
83
|
_note?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"journal-search.d.ts","sourceRoot":"","sources":["../../src/tools-logic/journal-search.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"journal-search.d.ts","sourceRoot":"","sources":["../../src/tools-logic/journal-search.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;qDAEiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;;+DAO2D;IAC3D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAQlD;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,KAAK,CAAC;QACb;;;;;;;;;;;;;WAaG;QACH,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb;;;;;;;;;;;;;;;;;;;;;;;;;;WA0BG;QACH,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB;;;;uCAI+B;QAC/B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;KAC1B,CAAC,CAAC;IACH,eAAe,EAAE,OAAO,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAgCD,wBAAsB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAmJ3F"}
|