agent-recall-core 3.4.40 → 3.4.42

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.
Files changed (72) hide show
  1. package/dist/helpers/auto-name.d.ts +2 -1
  2. package/dist/helpers/auto-name.d.ts.map +1 -1
  3. package/dist/helpers/auto-name.js +45 -6
  4. package/dist/helpers/auto-name.js.map +1 -1
  5. package/dist/helpers/journal-sig-theme.d.ts +18 -0
  6. package/dist/helpers/journal-sig-theme.d.ts.map +1 -1
  7. package/dist/helpers/journal-sig-theme.js +6 -1
  8. package/dist/helpers/journal-sig-theme.js.map +1 -1
  9. package/dist/index.d.ts +11 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +12 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/storage/extraction.d.ts +136 -0
  14. package/dist/storage/extraction.d.ts.map +1 -0
  15. package/dist/storage/extraction.js +368 -0
  16. package/dist/storage/extraction.js.map +1 -0
  17. package/dist/storage/fs-utils.d.ts +21 -0
  18. package/dist/storage/fs-utils.d.ts.map +1 -1
  19. package/dist/storage/fs-utils.js +86 -0
  20. package/dist/storage/fs-utils.js.map +1 -1
  21. package/dist/storage/hook-health.d.ts +50 -0
  22. package/dist/storage/hook-health.d.ts.map +1 -0
  23. package/dist/storage/hook-health.js +183 -0
  24. package/dist/storage/hook-health.js.map +1 -0
  25. package/dist/storage/paths.d.ts +23 -4
  26. package/dist/storage/paths.d.ts.map +1 -1
  27. package/dist/storage/paths.js +26 -9
  28. package/dist/storage/paths.js.map +1 -1
  29. package/dist/storage/recency-index.d.ts +79 -0
  30. package/dist/storage/recency-index.d.ts.map +1 -0
  31. package/dist/storage/recency-index.js +204 -0
  32. package/dist/storage/recency-index.js.map +1 -0
  33. package/dist/storage/session-card.d.ts +74 -0
  34. package/dist/storage/session-card.d.ts.map +1 -0
  35. package/dist/storage/session-card.js +219 -0
  36. package/dist/storage/session-card.js.map +1 -0
  37. package/dist/storage/working-memory.d.ts +193 -0
  38. package/dist/storage/working-memory.d.ts.map +1 -0
  39. package/dist/storage/working-memory.js +328 -0
  40. package/dist/storage/working-memory.js.map +1 -0
  41. package/dist/supabase/recall-backend.d.ts +1 -1
  42. package/dist/supabase/recall-backend.d.ts.map +1 -1
  43. package/dist/supabase/recall-backend.js.map +1 -1
  44. package/dist/supabase/sync.d.ts.map +1 -1
  45. package/dist/supabase/sync.js +13 -2
  46. package/dist/supabase/sync.js.map +1 -1
  47. package/dist/tools-logic/drill-down.d.ts +9 -2
  48. package/dist/tools-logic/drill-down.d.ts.map +1 -1
  49. package/dist/tools-logic/drill-down.js +32 -1
  50. package/dist/tools-logic/drill-down.js.map +1 -1
  51. package/dist/tools-logic/journal-search.d.ts.map +1 -1
  52. package/dist/tools-logic/journal-search.js +7 -1
  53. package/dist/tools-logic/journal-search.js.map +1 -1
  54. package/dist/tools-logic/resurrect.d.ts +113 -0
  55. package/dist/tools-logic/resurrect.d.ts.map +1 -0
  56. package/dist/tools-logic/resurrect.js +602 -0
  57. package/dist/tools-logic/resurrect.js.map +1 -0
  58. package/dist/tools-logic/session-start-lite.d.ts +6 -0
  59. package/dist/tools-logic/session-start-lite.d.ts.map +1 -1
  60. package/dist/tools-logic/session-start-lite.js +15 -0
  61. package/dist/tools-logic/session-start-lite.js.map +1 -1
  62. package/dist/tools-logic/session-start.d.ts +29 -0
  63. package/dist/tools-logic/session-start.d.ts.map +1 -1
  64. package/dist/tools-logic/session-start.js +97 -2
  65. package/dist/tools-logic/session-start.js.map +1 -1
  66. package/dist/tools-logic/smart-recall.d.ts +9 -4
  67. package/dist/tools-logic/smart-recall.d.ts.map +1 -1
  68. package/dist/tools-logic/smart-recall.js +170 -4
  69. package/dist/tools-logic/smart-recall.js.map +1 -1
  70. package/dist/types.d.ts +1 -1
  71. package/dist/types.js +1 -1
  72. package/package.json +1 -1
@@ -0,0 +1,74 @@
1
+ /**
2
+ * session-card.ts — mechanical session-card distillation (F3).
3
+ *
4
+ * Pure-mechanical, NO LLM: this runs on the hook-end path and must stay
5
+ * fast/offline. Built directly from the 2026-07-31 continuity-fixture
6
+ * incident (reports/2026-07-31-continuity-fixture.md §2 — "session-card
7
+ * field feasibility"): frontmatter, tool-call artifacts, and Linear refs
8
+ * sourced from direct tool calls are ~70% mechanical; goal/narrative state
9
+ * genuinely needs an LLM pass (out of scope here) — this module only builds
10
+ * the mechanical 70%, unconditionally, on every session end.
11
+ *
12
+ * The card is a NORMAL journal file (written under journal/, not
13
+ * journal/archive/raw/) so it enters existing retrieval + consolidation
14
+ * pipelines for free — no new read path required.
15
+ *
16
+ * Precision rule (fixture report §2): hook-injected `attachment` records
17
+ * (startup-hook stdout, folder-lint dumps, memory-stale-check output, etc.)
18
+ * are NEVER a valid source for artifacts/Linear-refs/title/decisions — that
19
+ * is exactly how the incident's forensics got misdirected. Every extractor
20
+ * below filters those out before scanning.
21
+ */
22
+ export interface SessionCardMeta {
23
+ /** Session UUID — untrusted, sanitized before any path.join. */
24
+ sid: string;
25
+ /** Resolved project slug (may be "auto"). */
26
+ slug: string;
27
+ /** F1's resolveSessionProject() confidence, 0 when slug === "auto". */
28
+ slugConfidence: number;
29
+ /** F1's full candidate ranking — kept so a low-confidence card is re-fileable later. */
30
+ slugCandidates: Array<{
31
+ slug: string;
32
+ count: number;
33
+ }>;
34
+ /** ISO date (YYYY-MM-DD). Defaults to today if omitted. */
35
+ date?: string;
36
+ }
37
+ export interface SessionCardInput {
38
+ /** Head sample of the transcript (JSONL text) — same shape as transcript-reader's `head`. */
39
+ rawHead: string;
40
+ /** Tail sample of the transcript (JSONL text) — same shape as transcript-reader's `tail`. */
41
+ rawTail: string;
42
+ meta: SessionCardMeta;
43
+ }
44
+ export interface SessionCardResult {
45
+ markdown: string;
46
+ title: string;
47
+ artifacts: string[];
48
+ linearRefs: string[];
49
+ decisions: string[];
50
+ nextStep: string[];
51
+ sid: string;
52
+ slug: string;
53
+ date: string;
54
+ }
55
+ /**
56
+ * Build a session card (F3) — pure-mechanical distillation of a session's
57
+ * head+tail transcript sample. Never throws: any internal failure degrades
58
+ * to an empty/best-effort card rather than breaking the hook-end path.
59
+ */
60
+ export declare function buildSessionCard(raw: SessionCardInput): SessionCardResult;
61
+ /**
62
+ * Write a session card as a normal journal file: projects/<slug>/journal/
63
+ * <date>--card--<sid>.md — no new directory, no new read path; existing
64
+ * journal search/consolidation reach it automatically.
65
+ *
66
+ * Idempotent on the session UUID (never overwrites an existing card, matching
67
+ * archive-write.ts's convention) and never throws — a failed write must not
68
+ * break the hook-end / Stop turn.
69
+ */
70
+ export declare function writeSessionCard(card: SessionCardResult): {
71
+ path: string;
72
+ bytes: number;
73
+ };
74
+ //# sourceMappingURL=session-card.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-card.d.ts","sourceRoot":"","sources":["../../src/storage/session-card.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAsBH,MAAM,WAAW,eAAe;IAC9B,gEAAgE;IAChE,GAAG,EAAE,MAAM,CAAC;IACZ,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,cAAc,EAAE,MAAM,CAAC;IACvB,wFAAwF;IACxF,cAAc,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvD,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,6FAA6F;IAC7F,OAAO,EAAE,MAAM,CAAC;IAChB,6FAA6F;IAC7F,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,eAAe,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAwED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,gBAAgB,GAAG,iBAAiB,CA+GzE;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,iBAAiB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAoBzF"}
@@ -0,0 +1,219 @@
1
+ /**
2
+ * session-card.ts — mechanical session-card distillation (F3).
3
+ *
4
+ * Pure-mechanical, NO LLM: this runs on the hook-end path and must stay
5
+ * fast/offline. Built directly from the 2026-07-31 continuity-fixture
6
+ * incident (reports/2026-07-31-continuity-fixture.md §2 — "session-card
7
+ * field feasibility"): frontmatter, tool-call artifacts, and Linear refs
8
+ * sourced from direct tool calls are ~70% mechanical; goal/narrative state
9
+ * genuinely needs an LLM pass (out of scope here) — this module only builds
10
+ * the mechanical 70%, unconditionally, on every session end.
11
+ *
12
+ * The card is a NORMAL journal file (written under journal/, not
13
+ * journal/archive/raw/) so it enters existing retrieval + consolidation
14
+ * pipelines for free — no new read path required.
15
+ *
16
+ * Precision rule (fixture report §2): hook-injected `attachment` records
17
+ * (startup-hook stdout, folder-lint dumps, memory-stale-check output, etc.)
18
+ * are NEVER a valid source for artifacts/Linear-refs/title/decisions — that
19
+ * is exactly how the incident's forensics got misdirected. Every extractor
20
+ * below filters those out before scanning.
21
+ */
22
+ import * as fs from "node:fs";
23
+ import * as path from "node:path";
24
+ import { journalDir, sanitizeSlug } from "./paths.js";
25
+ import { ensureDir, todayISO, truncateUtf8Bytes } from "./fs-utils.js";
26
+ import { generateFrontmatter } from "../palace/obsidian.js";
27
+ import { DECISION_LINE_RE, NEXT_STEP_LINE_RE, parseJsonlLenient, extractArtifactPathsFromRecords, extractLinearRefsFromRecords, extractLinesMatching, extractFirstUserTextFromRecords, extractFinalRecordText, } from "./extraction.js";
28
+ // ---------------------------------------------------------------------------
29
+ // Field size budget (Card <= ~2KB, enforced in BYTES — this repo's content is
30
+ // routinely bilingual/CJK-heavy, where a char-length cap would silently blow
31
+ // well past 2KB on disk).
32
+ // ---------------------------------------------------------------------------
33
+ const CARD_BYTE_CAP = 2000;
34
+ const TITLE_CHAR_CAP = 120;
35
+ const ARTIFACTS_CAP = 10;
36
+ const LINEAR_REFS_CAP = 10;
37
+ const DECISIONS_CAP = 5;
38
+ const NEXT_STEP_CAP = 3;
39
+ const LAST_USER_CHAR_CAP = 300;
40
+ const LAST_ASSISTANT_CHAR_CAP = 800;
41
+ /** H4 fix: cap on F1's ranked slugCandidates list — see the call site in buildSessionCard. */
42
+ const SLUG_CANDIDATES_CAP = 5;
43
+ // DECISION_LINE_RE / NEXT_STEP_LINE_RE / the Linear-ref pattern now live in
44
+ // ./extraction.ts (fix2, 2026-07-31) — single source shared with
45
+ // tools-logic/resurrect.ts. See that module for the "TOW2-357" digit-prefix
46
+ // rationale previously documented inline here.
47
+ // ---------------------------------------------------------------------------
48
+ // Lenient JSONL parsing, boilerplate/content-block/system-text helpers:
49
+ // imported from ./extraction.ts (fix2 + fix3, 2026-07-31) — single source
50
+ // shared with tools-logic/resurrect.ts. SYSTEM_PREFIXES/isSystemText/
51
+ // extractFirstUserText/extractFinal used to be private copies here; they
52
+ // are now extraction.ts's isSystemText/extractFirstUserTextFromRecords/
53
+ // extractFinalRecordText (identical logic, same minLen defaults: 10 for the
54
+ // first-user-text fallback, 1 for the final-record reduction below).
55
+ // ---------------------------------------------------------------------------
56
+ /**
57
+ * Truncate to at most maxBytes, UTF-8 safe (never splits mid multi-byte char
58
+ * into garbage). M8 fix (review, 2026-07-31): delegates to the shared
59
+ * `truncateUtf8Bytes` helper (fs-utils.ts) — the PREVIOUS local implementation
60
+ * here (`buf.subarray(0, maxBytes).toString("utf-8")`) only claimed to be
61
+ * UTF-8 safe; a cut landing mid-multi-byte-sequence silently produced one or
62
+ * more U+FFFD replacement characters (repro'd), which could even push the
63
+ * re-encoded byte length back OVER maxBytes.
64
+ */
65
+ function truncateBytes(text, maxBytes) {
66
+ return truncateUtf8Bytes(text, maxBytes);
67
+ }
68
+ // ---------------------------------------------------------------------------
69
+ // Field extraction
70
+ // ---------------------------------------------------------------------------
71
+ /** Transcript summary record (`{"type":"ai-title","aiTitle":"..."}`), if the transcript has one. */
72
+ function extractAiTitle(lines) {
73
+ for (const rec of lines) {
74
+ if (rec.type === "ai-title" && typeof rec.aiTitle === "string" && rec.aiTitle.trim()) {
75
+ return rec.aiTitle.trim();
76
+ }
77
+ }
78
+ return null;
79
+ }
80
+ // extractFirstUserText / extractFinal / extractArtifacts / extractLinearRefs
81
+ // (M9-fixed) / extractLinesMatching now live in ./extraction.ts as
82
+ // extractFirstUserTextFromRecords / extractFinalRecordText /
83
+ // extractArtifactPathsFromRecords / extractLinearRefsFromRecords /
84
+ // extractLinesMatching — imported above. Single source shared with
85
+ // tools-logic/resurrect.ts (fix2 + fix3, 2026-07-31).
86
+ // ---------------------------------------------------------------------------
87
+ // Public API
88
+ // ---------------------------------------------------------------------------
89
+ /**
90
+ * Build a session card (F3) — pure-mechanical distillation of a session's
91
+ * head+tail transcript sample. Never throws: any internal failure degrades
92
+ * to an empty/best-effort card rather than breaking the hook-end path.
93
+ */
94
+ export function buildSessionCard(raw) {
95
+ const sid = raw?.meta?.sid ?? "";
96
+ const slug = raw?.meta?.slug ?? "auto";
97
+ const date = raw?.meta?.date ?? todayISO();
98
+ try {
99
+ const headLines = parseJsonlLenient(raw.rawHead ?? "");
100
+ const tailLines = parseJsonlLenient(raw.rawTail ?? "");
101
+ const allLines = [...headLines, ...tailLines];
102
+ const title = (extractAiTitle(allLines) ??
103
+ extractFirstUserTextFromRecords(allLines) ??
104
+ "(untitled session)").slice(0, TITLE_CHAR_CAP);
105
+ const artifacts = extractArtifactPathsFromRecords(allLines, ARTIFACTS_CAP);
106
+ const linearRefs = extractLinearRefsFromRecords(allLines, LINEAR_REFS_CAP);
107
+ const finalAssistantText = extractFinalRecordText(allLines, "assistant") ?? "";
108
+ const finalUserText = extractFinalRecordText(allLines, "user") ?? "";
109
+ const decisions = extractLinesMatching(finalAssistantText, DECISION_LINE_RE, DECISIONS_CAP);
110
+ const nextStep = extractLinesMatching(finalAssistantText, NEXT_STEP_LINE_RE, NEXT_STEP_CAP);
111
+ // H4 fix (review, 2026-07-31): cap slugCandidates to the top SLUG_CANDIDATES_CAP
112
+ // by count BEFORE frontmatter serialization. Every other list field on this
113
+ // card already has its own _CAP constant (ARTIFACTS_CAP, LINEAR_REFS_CAP, ...)
114
+ // — this one didn't, and F1's ranked candidate list is NOT length-limited
115
+ // upstream. An uncapped list let a single JSON.stringify'd frontmatter field
116
+ // alone consume the ENTIRE CARD_BYTE_CAP, so the whole-markdown byte
117
+ // truncation below cut mid-YAML — invalid frontmatter (no closing `---`),
118
+ // and every body section after the cut point silently vanished.
119
+ const cappedSlugCandidates = [...(raw?.meta?.slugCandidates ?? [])]
120
+ .sort((a, b) => b.count - a.count)
121
+ .slice(0, SLUG_CANDIDATES_CAP);
122
+ const frontmatter = generateFrontmatter({
123
+ sid,
124
+ date,
125
+ slug,
126
+ slug_confidence: Number((raw?.meta?.slugConfidence ?? 0).toFixed(3)),
127
+ slug_candidates: cappedSlugCandidates,
128
+ source: "hook-end",
129
+ });
130
+ const sections = [`# ${title}`, ""];
131
+ if (linearRefs.length > 0) {
132
+ sections.push("## Linear", linearRefs.join(", "), "");
133
+ }
134
+ if (artifacts.length > 0) {
135
+ sections.push("## Artifacts", ...artifacts.map((p) => `- \`${p}\``), "");
136
+ }
137
+ if (decisions.length > 0) {
138
+ sections.push("## Decisions", ...decisions.map((d) => `- ${d}`), "");
139
+ }
140
+ if (nextStep.length > 0) {
141
+ sections.push("## Next steps", ...nextStep.map((n) => `- ${n}`), "");
142
+ }
143
+ if (finalUserText || finalAssistantText) {
144
+ sections.push("## Last exchange");
145
+ if (finalUserText) {
146
+ const u = finalUserText.trim();
147
+ sections.push(`**User:** ${u.length > LAST_USER_CHAR_CAP ? u.slice(0, LAST_USER_CHAR_CAP) + "…" : u}`, "");
148
+ }
149
+ if (finalAssistantText) {
150
+ const a = finalAssistantText.trim();
151
+ sections.push(`**Assistant:** ${a.length > LAST_ASSISTANT_CHAR_CAP ? a.slice(0, LAST_ASSISTANT_CHAR_CAP) + "…" : a}`, "");
152
+ }
153
+ }
154
+ // H4 fix: byte-truncate ONLY the body, never the frontmatter. A cut
155
+ // mid-YAML produces an invalid card with no closing `---` and silently
156
+ // drops every section after the cut point. Frontmatter is now bounded
157
+ // (capped candidates above, plus the existing per-field caps on every
158
+ // other frontmatter value) so it always fits comfortably on its own; the
159
+ // body absorbs whatever budget remains, BYTE-based (CJK content can far
160
+ // exceed a char-based cap on disk).
161
+ const body = sections.join("\n");
162
+ const frontmatterBytes = Buffer.byteLength(frontmatter, "utf-8");
163
+ const bodyBudget = Math.max(0, CARD_BYTE_CAP - frontmatterBytes);
164
+ const markdown = frontmatter + truncateBytes(body, bodyBudget);
165
+ return { markdown, title, artifacts, linearRefs, decisions, nextStep, sid, slug, date };
166
+ }
167
+ catch {
168
+ // Never throw into the hook-end path — degrade to a minimal, valid card.
169
+ const frontmatter = generateFrontmatter({
170
+ sid,
171
+ date,
172
+ slug,
173
+ slug_confidence: 0,
174
+ slug_candidates: [],
175
+ source: "hook-end",
176
+ });
177
+ const markdown = truncateBytes(`${frontmatter}# (session card build failed)\n`, CARD_BYTE_CAP);
178
+ return {
179
+ markdown,
180
+ title: "(session card build failed)",
181
+ artifacts: [],
182
+ linearRefs: [],
183
+ decisions: [],
184
+ nextStep: [],
185
+ sid,
186
+ slug,
187
+ date,
188
+ };
189
+ }
190
+ }
191
+ /**
192
+ * Write a session card as a normal journal file: projects/<slug>/journal/
193
+ * <date>--card--<sid>.md — no new directory, no new read path; existing
194
+ * journal search/consolidation reach it automatically.
195
+ *
196
+ * Idempotent on the session UUID (never overwrites an existing card, matching
197
+ * archive-write.ts's convention) and never throws — a failed write must not
198
+ * break the hook-end / Stop turn.
199
+ */
200
+ export function writeSessionCard(card) {
201
+ try {
202
+ const slug = sanitizeSlug(card.slug); // slug is caller-controlled; harden before path.join
203
+ const sid = sanitizeSlug(card.sid); // sid is UNTRUSTED (from hook stdin) — sanitize first
204
+ const dir = journalDir(slug);
205
+ ensureDir(dir);
206
+ const dest = path.join(dir, `${card.date}--card--${sid}.md`);
207
+ if (fs.existsSync(dest)) {
208
+ return { path: dest, bytes: 0 };
209
+ }
210
+ const tmp = dest + ".tmp." + process.pid;
211
+ fs.writeFileSync(tmp, card.markdown, "utf-8");
212
+ fs.renameSync(tmp, dest);
213
+ return { path: dest, bytes: Buffer.byteLength(card.markdown, "utf-8") };
214
+ }
215
+ catch {
216
+ return { path: "", bytes: 0 };
217
+ }
218
+ }
219
+ //# sourceMappingURL=session-card.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-card.js","sourceRoot":"","sources":["../../src/storage/session-card.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,+BAA+B,EAC/B,4BAA4B,EAC5B,oBAAoB,EACpB,+BAA+B,EAC/B,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAuCzB,8EAA8E;AAC9E,8EAA8E;AAC9E,6EAA6E;AAC7E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CAAC;QAC7D,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QAClC,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,GAAG,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;QACzC,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC9C,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAEzB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC;IAC1E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAChC,CAAC;AACH,CAAC"}
@@ -0,0 +1,193 @@
1
+ /**
2
+ * working-memory.ts — minutes-level, crash-proof capture tier
3
+ * (v3.4.42 working-memory wave, design doc
4
+ * reports/2026-08-04-working-memory-design.md).
5
+ *
6
+ * WHY: through v3.4.41, AR writes nothing until the Stop hook fires — a
7
+ * crash, `kill -9`, or a context-compact vaporizes the entire live session,
8
+ * and two concurrent Claude Code windows are mutually blind to each other.
9
+ * Owner intent (2026-07-31, verbatim spirit): "like a human brain — you can
10
+ * forget, you can decay, but you need to know what happened 10 minutes
11
+ * before, 5 minutes before." This module is the ONLY new storage primitive
12
+ * for that tier: one JSONL file per session id, appended to on every
13
+ * UserPromptSubmit (hook-ambient), read at hook-start for the cross-window
14
+ * "live" signal and for orphan rescue, and deleted once a session reaches a
15
+ * normal, successful hook-end. WM is NEVER archived — natural forgetting by
16
+ * design; it is a minutes-level cache, not a permanent record.
17
+ *
18
+ * Storage shape: `<AR_ROOT>/working-memory/<sid>.jsonl`, one JSON line per
19
+ * prompt, PLUS a small sidecar counter file `<sid>.jsonl.count` (a bare
20
+ * decimal integer) used ONLY to enforce the per-file line cap in O(1) —
21
+ * see `wmAppend`'s doc comment for why a sidecar counter, not a directory
22
+ * scan or a full-file read, is the right tool here. Per-sid files are a
23
+ * DELIBERATE choice (design doc, non-negotiable): a shared cross-session
24
+ * ledger would need a write-lock on every single prompt across every open
25
+ * window, turning a per-prompt hot path into a cross-process contention
26
+ * point. Per-sid files make that race structurally impossible — two windows
27
+ * literally never touch the same file.
28
+ */
29
+ /** Per-sid line cap (design doc §Mechanism) — bounds disk, not memory. */
30
+ export declare const WM_LINE_CAP = 2000;
31
+ /** Prompt field byte cap (UTF-8-safe) applied at append time. */
32
+ export declare const WM_PROMPT_BYTE_CAP = 300;
33
+ /**
34
+ * Cross-window "live" line window (session-start.ts's continuity assembly):
35
+ * a WM file with mtime younger than this is treated as "another session is
36
+ * (or very recently was) active elsewhere". Exported so session-start.ts and
37
+ * this module share ONE threshold instead of two independently-tuned magic
38
+ * numbers.
39
+ */
40
+ export declare const WM_LIVE_WINDOW_MS: number;
41
+ /**
42
+ * Orphan-rescue window (CLI hook-start): a WM file OLDER than this with no
43
+ * session card and no recency-index entry yet is presumed to belong to a
44
+ * session that crashed/was killed without ever reaching hook-end. Exported
45
+ * for the same single-source-of-truth reason as `WM_LIVE_WINDOW_MS`.
46
+ */
47
+ export declare const WM_ORPHAN_WINDOW_MS: number;
48
+ export interface WorkingMemoryLine {
49
+ /** ISO-8601 timestamp of the prompt. */
50
+ ts: string;
51
+ /** Boilerplate-excluded, UTF-8-safe byte-capped prompt text. */
52
+ prompt: string;
53
+ /** Working directory at the time of the prompt, when known. */
54
+ cwd?: string;
55
+ }
56
+ export interface WorkingMemoryFileInfo {
57
+ /** Session id (the sanitized on-disk basename, minus the .jsonl extension). */
58
+ sid: string;
59
+ /** Last-modified time of the .jsonl file, as epoch milliseconds. */
60
+ mtimeMs: number;
61
+ /** Line count — read from the sidecar counter when present, else counted. */
62
+ lines: number;
63
+ }
64
+ /**
65
+ * Append one prompt to a session's working-memory file. Never throws — this
66
+ * runs on the hook-ambient hot path (every UserPromptSubmit) and a failure
67
+ * here must never delay or deny the ambient injection output that follows
68
+ * it in the caller. Any failure is reported via `recordHookFailure` instead.
69
+ *
70
+ * Boilerplate exclusion: a prompt that IS boilerplate (matches
71
+ * `isSystemText` — harness scaffolding, `<system-reminder>` blocks, etc.)
72
+ * appends NOTHING, not even an empty line, and does not consume any of the
73
+ * per-file line-cap budget.
74
+ *
75
+ * Line-cap strategy (documented per design doc constraint — "cheap stat
76
+ * size heuristic or first-write counter file is acceptable"): a byte-size
77
+ * heuristic on the growing .jsonl file was rejected because prompt length
78
+ * and cwd length both vary per line, making "file size / N" an unreliable
79
+ * proxy for "N lines" — it would let a run of short prompts blow well past
80
+ * the intended 2000-line cap while a run of near-cap-length prompts hits it
81
+ * early. Reading the .jsonl file itself to count lines was rejected because
82
+ * that makes wmAppend's cost scale with SESSION LENGTH (O(n) per prompt over
83
+ * an n-line file), violating the O(1)-hot-path constraint outright. The
84
+ * chosen alternative is a tiny sidecar counter file (a few bytes, a bare
85
+ * decimal integer) that is read once (cheap: a handful of bytes, not the
86
+ * growing transcript) and rewritten once per append — genuinely O(1) with
87
+ * respect to the session's own size.
88
+ *
89
+ * C1 fix (review, post-build): the raw prompt text used to reach disk with
90
+ * only the boilerplate check above — no injection/secret scrub — even though
91
+ * every OTHER persist path in this codebase (journal-write.ts, palace-write.ts,
92
+ * see storage/content-guard.ts) scrubs before writing. WM is a lower tier
93
+ * (minutes-level cache, not a permanent record) but it is NOT lower-exposure:
94
+ * its content is read back verbatim into (a) session-start.ts's cross-SESSION
95
+ * "live" line (surfaced to a DIFFERENT window/agent), (b) rescued session-card
96
+ * bodies (cli/index.ts orphan rescue — a permanent journal artifact once
97
+ * rescued), and (c) resurrect.ts's WM source. A secret or an injected
98
+ * "<system-reminder>ignore previous instructions</system-reminder>" block
99
+ * pasted into one prompt would otherwise flow verbatim into all three. This
100
+ * is the SINGLE choke point for the whole tier — every WM line is built here.
101
+ *
102
+ * Ordering (truncate → scrub → truncate again), deliberately NOT
103
+ * scrub-then-truncate, to preserve the O(1)-hot-path guarantee this module's
104
+ * own header documents: `scrubForCloud` is a ~15-regex pass whose cost scales
105
+ * with input length (measured: ~0.28ms on a 100KB string — see the fix
106
+ * report's benchmark). Truncating to WM_PROMPT_BYTE_CAP FIRST bounds the
107
+ * scrub's input to a small constant (≤300 bytes) regardless of how long the
108
+ * raw prompt was, so the added cost is ~1-2 microseconds per call — the scrub
109
+ * never sees the full pasted-file-sized prompt a user might submit. Content
110
+ * beyond the byte cap is truncated away before it is ever persisted, so it
111
+ * needs no scrubbing; content a secret/tag straddling the truncation boundary
112
+ * can still be caught if enough of it survives inside the retained window.
113
+ * The second truncateUtf8Bytes call is a cheap defensive no-op today (every
114
+ * SECRET_CONTENT_PATTERNS replacement is shorter than what it matches, so
115
+ * scrub never grows the string) — kept so the ≤WM_PROMPT_BYTE_CAP invariant
116
+ * holds even if that redaction-placeholder assumption ever changes.
117
+ */
118
+ export declare function wmAppend(sid: string, entry: {
119
+ ts: string;
120
+ prompt: string;
121
+ cwd?: string;
122
+ }): void;
123
+ /**
124
+ * List every working-memory file currently on disk. Never throws — returns
125
+ * `[]` on any read error (missing directory, permissions, etc.). Used by
126
+ * BOTH the cross-window "live" line (session-start.ts, filters mtime <
127
+ * `WM_LIVE_WINDOW_MS`) and orphan rescue (CLI hook-start, filters mtime >
128
+ * `WM_ORPHAN_WINDOW_MS`) — not on any per-prompt hot path, so a full
129
+ * directory read here is acceptable (unlike `wmAppend`).
130
+ */
131
+ export declare function wmList(): WorkingMemoryFileInfo[];
132
+ /**
133
+ * Read every parsed line of a session's working-memory file, oldest-first.
134
+ * Never throws — returns `[]` when the file is missing, empty, or every line
135
+ * fails to parse/validate.
136
+ */
137
+ export declare function wmRead(sid: string): WorkingMemoryLine[];
138
+ /**
139
+ * Delete a session's working-memory file and its counter sidecar. Idempotent
140
+ * (calling twice, or on a sid with no file, is a silent no-op) and never
141
+ * throws — this runs on the hook-end "sleep consolidation" path (after a
142
+ * successful session-card write) and on the orphan-rescue path, neither of
143
+ * which may fail the hook over a best-effort cleanup step.
144
+ */
145
+ export declare function wmDelete(sid: string): void;
146
+ /**
147
+ * Cheap, LOCAL cwd-majority slug guess for the two working-memory consumers
148
+ * that live in the CORE package (session-start.ts's live line, resurrect.ts's
149
+ * WM source) and therefore cannot import the CLI package's
150
+ * `resolveSessionProject` (packages/cli/src/utils/transcript-reader.ts) — the
151
+ * core package is a DEPENDENCY of the cli package, never the reverse, so a
152
+ * core module importing cli code would be a layering violation. Uses the
153
+ * SAME regex family as that function's Signal 1 (cwd frequency restricted to
154
+ * paths under `~/Projects/<name>`), deliberately WITHOUT its full three-signal
155
+ * claim-not-generate policy (no existing-slug preference, no content signal —
156
+ * working-memory lines carry only prompts + cwd, not the transcript's
157
+ * user/assistant message records that signal 2 scans).
158
+ *
159
+ * DELIBERATE choice, used by ALL THREE working-memory consumers (this core
160
+ * module's two call sites AND the CLI's orphan rescue, even though the
161
+ * latter COULD reach the real `resolveSessionProject`): F1's own
162
+ * claim-not-generate gate can only mint a BRAND-NEW slug when its content
163
+ * signal (from user/assistant transcript records) sees the name mentioned
164
+ * >=3 times — a signal that structurally never fires from cwd-only
165
+ * working-memory data. Routing orphan rescue through the real F1 function
166
+ * would therefore make it unable to attribute a crashed session's FIRST-EVER
167
+ * interaction with AR to its real project (exactly the case a crash-rescue
168
+ * mechanism most needs to handle) unless that project already has an
169
+ * AR_ROOT/projects/<slug> directory — so all three consumers share this
170
+ * lighter, uniform heuristic instead. Every candidate is still checked
171
+ * against `isValidProjectSlug` (the SAME gate F1 itself applies) so a
172
+ * deny-listed/UUID-shaped/otherwise-invalid cwd segment is never selected.
173
+ * Returns `null` when no line's `cwd` matches the pattern, or when every
174
+ * match was invalid (caller falls back to a literal `"auto"`, the existing
175
+ * convention for an unresolved slug elsewhere in this codebase).
176
+ *
177
+ * H1 fix (review, post-build): F1 (`resolveSessionProject`, transcript-reader.ts)
178
+ * scans its FULL ranked candidate list and lets the first one that already
179
+ * has an on-disk project home win outright ("prefer an existing slug" —
180
+ * Signal 3), even over a noisier top-ranked candidate. The original version
181
+ * of this function had no such tie-break — pure cwd-count majority — so a WM
182
+ * session that happened to visit an unrelated-but-more-frequent cwd (e.g. a
183
+ * quick `cd` into a sibling checkout mid-session) could out-vote the project
184
+ * the session actually belongs to, where F1 itself would have picked the
185
+ * established one. Mirrors F1's tie-break using core's OWN project listing
186
+ * (`listAllProjects`, this same module — no cli import, preserving the
187
+ * core→cli layering direction documented above) instead of duplicating a raw
188
+ * `fs.readdirSync` scan. Wrapped in its own try/catch: this function must
189
+ * never throw (same contract as every other WM helper), and `listAllProjects`
190
+ * is a filesystem read this module does not otherwise need to guard.
191
+ */
192
+ export declare function guessSlugFromWmLines(lines: WorkingMemoryLine[]): string | null;
193
+ //# sourceMappingURL=working-memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"working-memory.d.ts","sourceRoot":"","sources":["../../src/storage/working-memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAgBH,0EAA0E;AAC1E,eAAO,MAAM,WAAW,OAAO,CAAC;AAChC,iEAAiE;AACjE,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,QAAqB,CAAC;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,QAAiB,CAAC;AAElD,MAAM,WAAW,iBAAiB;IAChC,wCAAwC;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,qBAAqB;IACpC,+EAA+E;IAC/E,GAAG,EAAE,MAAM,CAAC;IACZ,oEAAoE;IACpE,OAAO,EAAE,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