agent-recall-core 3.4.42 → 3.4.44
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/digest/store.d.ts.map +1 -1
- package/dist/digest/store.js +14 -8
- package/dist/digest/store.js.map +1 -1
- package/dist/helpers/handoff.d.ts.map +1 -1
- package/dist/helpers/handoff.js +11 -1
- package/dist/helpers/handoff.js.map +1 -1
- package/dist/helpers/tokenize.d.ts +76 -0
- package/dist/helpers/tokenize.d.ts.map +1 -0
- package/dist/helpers/tokenize.js +139 -0
- package/dist/helpers/tokenize.js.map +1 -0
- package/dist/host-profile.d.ts +35 -0
- package/dist/host-profile.d.ts.map +1 -1
- package/dist/host-profile.js +37 -0
- package/dist/host-profile.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/palace/awareness.d.ts.map +1 -1
- package/dist/palace/awareness.js +27 -11
- package/dist/palace/awareness.js.map +1 -1
- package/dist/palace/insights-index.d.ts.map +1 -1
- package/dist/palace/insights-index.js +18 -4
- package/dist/palace/insights-index.js.map +1 -1
- package/dist/palace/pipeline.d.ts.map +1 -1
- package/dist/palace/pipeline.js +7 -1
- package/dist/palace/pipeline.js.map +1 -1
- package/dist/palace/skills.d.ts.map +1 -1
- package/dist/palace/skills.js +37 -10
- package/dist/palace/skills.js.map +1 -1
- package/dist/storage/archive-write.d.ts.map +1 -1
- package/dist/storage/archive-write.js +13 -2
- package/dist/storage/archive-write.js.map +1 -1
- package/dist/storage/behavior-policies.d.ts.map +1 -1
- package/dist/storage/behavior-policies.js +8 -3
- package/dist/storage/behavior-policies.js.map +1 -1
- package/dist/storage/consolidation-queue.d.ts.map +1 -1
- package/dist/storage/consolidation-queue.js +48 -6
- package/dist/storage/consolidation-queue.js.map +1 -1
- package/dist/storage/content-guard.d.ts +33 -7
- package/dist/storage/content-guard.d.ts.map +1 -1
- package/dist/storage/content-guard.js +33 -8
- package/dist/storage/content-guard.js.map +1 -1
- package/dist/storage/corrections.d.ts.map +1 -1
- package/dist/storage/corrections.js +28 -3
- package/dist/storage/corrections.js.map +1 -1
- package/dist/storage/recency-index.d.ts +20 -0
- package/dist/storage/recency-index.d.ts.map +1 -1
- package/dist/storage/recency-index.js +66 -2
- package/dist/storage/recency-index.js.map +1 -1
- package/dist/storage/session-card.d.ts +20 -4
- package/dist/storage/session-card.d.ts.map +1 -1
- package/dist/storage/session-card.js +40 -9
- package/dist/storage/session-card.js.map +1 -1
- package/dist/storage/working-memory.d.ts +64 -0
- package/dist/storage/working-memory.d.ts.map +1 -1
- package/dist/storage/working-memory.js +288 -1
- package/dist/storage/working-memory.js.map +1 -1
- package/dist/tools-logic/alignment-check.d.ts.map +1 -1
- package/dist/tools-logic/alignment-check.js +6 -1
- package/dist/tools-logic/alignment-check.js.map +1 -1
- package/dist/tools-logic/bootstrap.d.ts.map +1 -1
- package/dist/tools-logic/bootstrap.js +1 -15
- package/dist/tools-logic/bootstrap.js.map +1 -1
- package/dist/tools-logic/check-action.d.ts.map +1 -1
- package/dist/tools-logic/check-action.js +13 -78
- package/dist/tools-logic/check-action.js.map +1 -1
- package/dist/tools-logic/check.d.ts.map +1 -1
- package/dist/tools-logic/check.js +8 -1
- package/dist/tools-logic/check.js.map +1 -1
- package/dist/tools-logic/context-synthesize.d.ts.map +1 -1
- package/dist/tools-logic/context-synthesize.js +7 -3
- package/dist/tools-logic/context-synthesize.js.map +1 -1
- package/dist/tools-logic/drill-down.d.ts.map +1 -1
- package/dist/tools-logic/drill-down.js +9 -1
- package/dist/tools-logic/drill-down.js.map +1 -1
- package/dist/tools-logic/journal-capture.d.ts.map +1 -1
- package/dist/tools-logic/journal-capture.js +5 -1
- package/dist/tools-logic/journal-capture.js.map +1 -1
- package/dist/tools-logic/journal-search.d.ts.map +1 -1
- package/dist/tools-logic/journal-search.js +10 -2
- package/dist/tools-logic/journal-search.js.map +1 -1
- package/dist/tools-logic/journal-write.d.ts.map +1 -1
- package/dist/tools-logic/journal-write.js +12 -5
- package/dist/tools-logic/journal-write.js.map +1 -1
- package/dist/tools-logic/knowledge-write.d.ts.map +1 -1
- package/dist/tools-logic/knowledge-write.js +6 -0
- package/dist/tools-logic/knowledge-write.js.map +1 -1
- package/dist/tools-logic/nudge.d.ts.map +1 -1
- package/dist/tools-logic/nudge.js +4 -0
- package/dist/tools-logic/nudge.js.map +1 -1
- package/dist/tools-logic/palace-search.d.ts.map +1 -1
- package/dist/tools-logic/palace-search.js +11 -3
- package/dist/tools-logic/palace-search.js.map +1 -1
- package/dist/tools-logic/palace-write.d.ts.map +1 -1
- package/dist/tools-logic/palace-write.js +11 -5
- package/dist/tools-logic/palace-write.js.map +1 -1
- package/dist/tools-logic/resurrect.d.ts.map +1 -1
- package/dist/tools-logic/resurrect.js +21 -6
- package/dist/tools-logic/resurrect.js.map +1 -1
- package/dist/tools-logic/session-end-reflect.d.ts.map +1 -1
- package/dist/tools-logic/session-end-reflect.js +10 -1
- package/dist/tools-logic/session-end-reflect.js.map +1 -1
- package/dist/tools-logic/session-end.d.ts.map +1 -1
- package/dist/tools-logic/session-end.js +118 -15
- package/dist/tools-logic/session-end.js.map +1 -1
- package/dist/tools-logic/session-start.d.ts.map +1 -1
- package/dist/tools-logic/session-start.js +35 -1
- package/dist/tools-logic/session-start.js.map +1 -1
- package/dist/tools-logic/smart-recall.d.ts.map +1 -1
- package/dist/tools-logic/smart-recall.js +28 -8
- package/dist/tools-logic/smart-recall.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/package.json +1 -1
|
@@ -190,4 +190,68 @@ export declare function wmDelete(sid: string): void;
|
|
|
190
190
|
* is a filesystem read this module does not otherwise need to guard.
|
|
191
191
|
*/
|
|
192
192
|
export declare function guessSlugFromWmLines(lines: WorkingMemoryLine[]): string | null;
|
|
193
|
+
/**
|
|
194
|
+
* C-2 (Train C, 2026-08-12 wave, design doc reports/2026-08-12-trainc-design.md)
|
|
195
|
+
* — the working-memory orphan-rescue sweep, single-sourced.
|
|
196
|
+
*
|
|
197
|
+
* WHY: through the v3.4.42 working-memory wave this sweep lived ONLY inside
|
|
198
|
+
* the CLI's `hook-start` case (packages/cli/src/index.ts) — a session that
|
|
199
|
+
* crashed on a host with no Claude Code hooks (Codex/Cursor/raw MCP) had no
|
|
200
|
+
* path back to a card at all, because nothing but that one CLI command ever
|
|
201
|
+
* ran the sweep. Doctrine (owner, 2026-07-26): the customer's only action is
|
|
202
|
+
* describing intent — the MCP server process itself must carry the memory
|
|
203
|
+
* lifecycle on hook-less hosts. Moved here, byte-for-byte behavior preserved,
|
|
204
|
+
* so BOTH callers — the CLI's `hook-start` case AND core's own `sessionStart()`
|
|
205
|
+
* (tools-logic/session-start.ts, called by the MCP `session_start` tool on
|
|
206
|
+
* every host) — invoke this ONE function. Neither re-implements any part of
|
|
207
|
+
* the sweep; there is exactly one place this logic can drift.
|
|
208
|
+
*
|
|
209
|
+
* Mechanism (unchanged from the original CLI-only version): a working-memory
|
|
210
|
+
* file older than `WM_ORPHAN_WINDOW_MS` with no session card and no
|
|
211
|
+
* recency-index entry yet is presumed to belong to a session that crashed or
|
|
212
|
+
* was `kill -9`'d without ever reaching hook-end (or, on a non-hook host,
|
|
213
|
+
* without the agent ever calling `session_end`). Rescues it into a
|
|
214
|
+
* searchable session card + recency entry, then deletes the WM file.
|
|
215
|
+
* Idempotent (card-exists / recency-exists guards — safe to call on every
|
|
216
|
+
* hook-start AND every session_start, from every open window/process),
|
|
217
|
+
* per-file fault-isolated (one bad orphan can never abort the sweep for its
|
|
218
|
+
* siblings — M1 fix, see the recency-append verification below), and NEVER
|
|
219
|
+
* throws: every failure is reported via `recordHookFailure` instead of
|
|
220
|
+
* propagating, matching every other WM helper's contract in this module.
|
|
221
|
+
*
|
|
222
|
+
* Renamed failure-record hook keys from the CLI original ("hook-start-wm-rescue"
|
|
223
|
+
* -> "wm-orphan-rescue", "hook-start-wm-rescue-recency" -> "wm-orphan-rescue-
|
|
224
|
+
* recency") — cosmetic only, no test or renderer asserts the literal string —
|
|
225
|
+
* because the sweep is no longer CLI-hook-specific; the old names would be
|
|
226
|
+
* actively misleading once an MCP `session_start` call is what triggered a
|
|
227
|
+
* given failure row.
|
|
228
|
+
*
|
|
229
|
+
* The per-file WM→card mechanism itself lives in `distillOneSession` below —
|
|
230
|
+
* factored out so C-3's graceful-exit handler (mcp-server/src/lib/
|
|
231
|
+
* lifecycle-exit.ts, via `distillSessionToCard`) can distill its OWN,
|
|
232
|
+
* still-fresh session immediately (no age gate) through the exact same
|
|
233
|
+
* mechanism this sweep uses for aged orphans, instead of a third
|
|
234
|
+
* reimplementation of "WM lines -> card + recency entry -> delete WM".
|
|
235
|
+
*/
|
|
236
|
+
export declare function rescueOrphanedWorkingMemory(): void;
|
|
237
|
+
/**
|
|
238
|
+
* C-3 (Train C, 2026-08-12 wave) — best-effort freshness for a graceful
|
|
239
|
+
* client close. `mcp-server/src/lib/lifecycle-exit.ts` calls this for the
|
|
240
|
+
* CURRENT process's own `sid` (core's `getSessionId()`) on `stdin` "end"/
|
|
241
|
+
* "close" and on SIGTERM/SIGINT, so a graceful disconnect gets a card
|
|
242
|
+
* immediately instead of waiting up to `WM_ORPHAN_WINDOW_MS` for the NEXT
|
|
243
|
+
* session's orphan sweep to find it. Reuses `distillOneSession` — the SAME
|
|
244
|
+
* WM→card mechanism `rescueOrphanedWorkingMemory` uses for aged orphans —
|
|
245
|
+
* with no age gate, since this is called precisely because the session is
|
|
246
|
+
* ending RIGHT NOW, not because it went stale. A `kill -9` bypasses this
|
|
247
|
+
* entirely by construction (no signal, no stdin event ever fires) and falls
|
|
248
|
+
* through to `rescueOrphanedWorkingMemory` on a LATER session_start/hook-start,
|
|
249
|
+
* exactly as the design doc specifies.
|
|
250
|
+
*
|
|
251
|
+
* No-op (silent) when this session has no working-memory file at all — a
|
|
252
|
+
* session that never had a tool call captured (or whose WM was already
|
|
253
|
+
* cleaned up by a normal `session_end`) has nothing to distill. Never
|
|
254
|
+
* throws: reported via `recordHookFailure` like every other WM helper.
|
|
255
|
+
*/
|
|
256
|
+
export declare function distillSessionToCard(sid: string): void;
|
|
193
257
|
//# sourceMappingURL=working-memory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"working-memory.d.ts","sourceRoot":"","sources":["../../src/storage/working-memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;
|
|
1
|
+
{"version":3,"file":"working-memory.d.ts","sourceRoot":"","sources":["../../src/storage/working-memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAmBH,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,MAAM,CAAC;IAChB,6EAA6E;IAC7E,KAAK,EAAE,MAAM,CAAC;CACf;AAyBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CA0B/F;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,IAAI,qBAAqB,EAAE,CA+BhD;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAgBvD;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAQ1C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,iBAAiB,EAAE,GAAG,MAAM,GAAG,IAAI,CAgC9E;AA+CD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,2BAA2B,IAAI,IAAI,CA4BlD;AAkJD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAStD"}
|
|
@@ -32,9 +32,12 @@ import { getRoot } from "../types.js";
|
|
|
32
32
|
import { ensureDir, truncateUtf8Bytes } from "./fs-utils.js";
|
|
33
33
|
import { isSystemText, parseJsonlLenient } from "./extraction.js";
|
|
34
34
|
import { recordHookFailure } from "./hook-health.js";
|
|
35
|
-
import { sanitizeSlug } from "./paths.js";
|
|
35
|
+
import { sanitizeSlug, projectsRootDir } from "./paths.js";
|
|
36
36
|
import { isValidProjectSlug, listAllProjects } from "./project.js";
|
|
37
37
|
import { scrubForCloud } from "./content-guard.js";
|
|
38
|
+
import { generateFrontmatter } from "../palace/obsidian.js";
|
|
39
|
+
import { writeSessionCard } from "./session-card.js";
|
|
40
|
+
import { appendRecentSession, readRecentSessions } from "./recency-index.js";
|
|
38
41
|
const WM_DIRNAME = "working-memory";
|
|
39
42
|
const JSONL_EXT = ".jsonl";
|
|
40
43
|
const COUNT_EXT = ".count";
|
|
@@ -325,4 +328,288 @@ export function guessSlugFromWmLines(lines) {
|
|
|
325
328
|
}
|
|
326
329
|
return ranked[0]?.slug ?? null;
|
|
327
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* v3.4.42 working-memory wave — orphan-rescue idempotency guard 1/2: does ANY
|
|
333
|
+
* project already have a session card for this sid? Scans every project's
|
|
334
|
+
* journal/ directory for a `*--card--<sid>.md` file (the exact naming
|
|
335
|
+
* convention `writeSessionCard` uses). Never throws — a missing/unreadable
|
|
336
|
+
* projects dir simply means "no card found".
|
|
337
|
+
*
|
|
338
|
+
* Moved here verbatim from packages/cli/src/index.ts (Train C, C-2, 2026-08-12
|
|
339
|
+
* wave) as part of single-sourcing the orphan-rescue sweep — see
|
|
340
|
+
* `rescueOrphanedWorkingMemory`'s doc comment below for why. NOT quite
|
|
341
|
+
* verbatim, though: the original CLI version built the enumeration root via
|
|
342
|
+
* a raw `path.join(root, "projects")`. This package's own F2 architectural
|
|
343
|
+
* guard (test/projects-literal-bypass-guard.test.mjs) forbids any
|
|
344
|
+
* `packages/core/src/**` file other than storage/paths.ts from inlining the
|
|
345
|
+
* `"projects"` literal — moving this function into core surfaced that guard
|
|
346
|
+
* for the first time. Fixed to use `projectsRootDir()`, the sanctioned
|
|
347
|
+
* enumeration-only helper paths.ts itself documents for exactly this case
|
|
348
|
+
* (joining directly against a slug that came FROM a readdir, not a
|
|
349
|
+
* caller-supplied name that needs the case-fold reuse rule).
|
|
350
|
+
*
|
|
351
|
+
* Rescue-slug-parity fix (Train C, 2026-08-13): returns the FOUND slug (the
|
|
352
|
+
* on-disk directory name the readdir actually matched under) instead of a
|
|
353
|
+
* bare boolean. `distillOneSession` below needs this because, when a card
|
|
354
|
+
* for this sid already exists, THIS slug (not a fresh `guessSlugFromWmLines`
|
|
355
|
+
* re-guess, which could itself have drifted since the card was written) is
|
|
356
|
+
* the only correct value for a not-yet-existing recency-ledger entry — see
|
|
357
|
+
* that function's own comment for the full ledger-vs-disk mismatch this
|
|
358
|
+
* closes. `null` means "no card found for this sid in any project."
|
|
359
|
+
*/
|
|
360
|
+
function findCardSlugForSid(sid) {
|
|
361
|
+
try {
|
|
362
|
+
const projectsDir = projectsRootDir();
|
|
363
|
+
if (!fs.existsSync(projectsDir))
|
|
364
|
+
return null;
|
|
365
|
+
for (const slug of fs.readdirSync(projectsDir)) {
|
|
366
|
+
const journalPath = path.join(projectsDir, slug, "journal");
|
|
367
|
+
if (!fs.existsSync(journalPath))
|
|
368
|
+
continue;
|
|
369
|
+
const hit = fs.readdirSync(journalPath).some((f) => f.endsWith(`--card--${sid}.md`));
|
|
370
|
+
if (hit)
|
|
371
|
+
return slug;
|
|
372
|
+
}
|
|
373
|
+
return null;
|
|
374
|
+
}
|
|
375
|
+
catch {
|
|
376
|
+
return null;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* C-2 (Train C, 2026-08-12 wave, design doc reports/2026-08-12-trainc-design.md)
|
|
381
|
+
* — the working-memory orphan-rescue sweep, single-sourced.
|
|
382
|
+
*
|
|
383
|
+
* WHY: through the v3.4.42 working-memory wave this sweep lived ONLY inside
|
|
384
|
+
* the CLI's `hook-start` case (packages/cli/src/index.ts) — a session that
|
|
385
|
+
* crashed on a host with no Claude Code hooks (Codex/Cursor/raw MCP) had no
|
|
386
|
+
* path back to a card at all, because nothing but that one CLI command ever
|
|
387
|
+
* ran the sweep. Doctrine (owner, 2026-07-26): the customer's only action is
|
|
388
|
+
* describing intent — the MCP server process itself must carry the memory
|
|
389
|
+
* lifecycle on hook-less hosts. Moved here, byte-for-byte behavior preserved,
|
|
390
|
+
* so BOTH callers — the CLI's `hook-start` case AND core's own `sessionStart()`
|
|
391
|
+
* (tools-logic/session-start.ts, called by the MCP `session_start` tool on
|
|
392
|
+
* every host) — invoke this ONE function. Neither re-implements any part of
|
|
393
|
+
* the sweep; there is exactly one place this logic can drift.
|
|
394
|
+
*
|
|
395
|
+
* Mechanism (unchanged from the original CLI-only version): a working-memory
|
|
396
|
+
* file older than `WM_ORPHAN_WINDOW_MS` with no session card and no
|
|
397
|
+
* recency-index entry yet is presumed to belong to a session that crashed or
|
|
398
|
+
* was `kill -9`'d without ever reaching hook-end (or, on a non-hook host,
|
|
399
|
+
* without the agent ever calling `session_end`). Rescues it into a
|
|
400
|
+
* searchable session card + recency entry, then deletes the WM file.
|
|
401
|
+
* Idempotent (card-exists / recency-exists guards — safe to call on every
|
|
402
|
+
* hook-start AND every session_start, from every open window/process),
|
|
403
|
+
* per-file fault-isolated (one bad orphan can never abort the sweep for its
|
|
404
|
+
* siblings — M1 fix, see the recency-append verification below), and NEVER
|
|
405
|
+
* throws: every failure is reported via `recordHookFailure` instead of
|
|
406
|
+
* propagating, matching every other WM helper's contract in this module.
|
|
407
|
+
*
|
|
408
|
+
* Renamed failure-record hook keys from the CLI original ("hook-start-wm-rescue"
|
|
409
|
+
* -> "wm-orphan-rescue", "hook-start-wm-rescue-recency" -> "wm-orphan-rescue-
|
|
410
|
+
* recency") — cosmetic only, no test or renderer asserts the literal string —
|
|
411
|
+
* because the sweep is no longer CLI-hook-specific; the old names would be
|
|
412
|
+
* actively misleading once an MCP `session_start` call is what triggered a
|
|
413
|
+
* given failure row.
|
|
414
|
+
*
|
|
415
|
+
* The per-file WM→card mechanism itself lives in `distillOneSession` below —
|
|
416
|
+
* factored out so C-3's graceful-exit handler (mcp-server/src/lib/
|
|
417
|
+
* lifecycle-exit.ts, via `distillSessionToCard`) can distill its OWN,
|
|
418
|
+
* still-fresh session immediately (no age gate) through the exact same
|
|
419
|
+
* mechanism this sweep uses for aged orphans, instead of a third
|
|
420
|
+
* reimplementation of "WM lines -> card + recency entry -> delete WM".
|
|
421
|
+
*/
|
|
422
|
+
export function rescueOrphanedWorkingMemory() {
|
|
423
|
+
try {
|
|
424
|
+
const now = Date.now();
|
|
425
|
+
const wmFiles = wmList();
|
|
426
|
+
// L1 fix (review, post-build, preserved from the CLI original): hoist the
|
|
427
|
+
// recency-index read OUT of the per-orphan loop. `readRecentSessions(1000)`
|
|
428
|
+
// reads and JSON-parses up to 1000 ledger lines from disk; calling it once
|
|
429
|
+
// PER orphan file made the sweep's total cost scale with orphans ×
|
|
430
|
+
// ledger-size instead of once + an O(1) Set lookup per orphan.
|
|
431
|
+
const recentSids = new Set(readRecentSessions(1000).map((e) => e.sid));
|
|
432
|
+
for (const wmFile of wmFiles) {
|
|
433
|
+
// M1 fix (review, post-build, preserved from the CLI original): per-file
|
|
434
|
+
// try/catch — a thrown error while rescuing ONE orphan must never abort
|
|
435
|
+
// the whole sweep, silently skipping every OTHER orphan file that
|
|
436
|
+
// hadn't been reached yet.
|
|
437
|
+
try {
|
|
438
|
+
if (now - wmFile.mtimeMs <= WM_ORPHAN_WINDOW_MS)
|
|
439
|
+
continue; // still fresh — not orphaned yet
|
|
440
|
+
distillOneSession(wmFile, recentSids);
|
|
441
|
+
}
|
|
442
|
+
catch (e) {
|
|
443
|
+
recordHookFailure("wm-orphan-rescue", e);
|
|
444
|
+
// per-file catch — fall through to the next orphan, sweep continues
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
catch (e) {
|
|
449
|
+
recordHookFailure("wm-orphan-rescue", e);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Distill ONE session's working-memory lines into a session card + recency
|
|
454
|
+
* entry, then delete the WM file. No age check here BY DESIGN — that policy
|
|
455
|
+
* decision belongs entirely to the caller: `rescueOrphanedWorkingMemory`
|
|
456
|
+
* only reaches this for files already confirmed older than
|
|
457
|
+
* `WM_ORPHAN_WINDOW_MS`, while `distillSessionToCard` (below, C-3's
|
|
458
|
+
* graceful-exit entry point) calls it immediately for a still-live session.
|
|
459
|
+
* Lets exceptions propagate — both current callers wrap their own call in a
|
|
460
|
+
* try/catch (matching the original inline code's per-item fault isolation),
|
|
461
|
+
* so this extraction changes no failure-handling behavior.
|
|
462
|
+
*
|
|
463
|
+
* Rescue-slug-parity fix (Train C, 2026-08-13): `guessSlugFromWmLines`
|
|
464
|
+
* returns a RAW cwd-captured candidate (e.g. "AgentRecall") that is never
|
|
465
|
+
* itself lowercased/case-folded. `writeSessionCard` → `journalDir` →
|
|
466
|
+
* `resolveProjectDirName` DOES normalize it (lowercases via `sanitizeName`,
|
|
467
|
+
* or reuses whatever casing an existing project dir already has) before the
|
|
468
|
+
* card ever touches disk — so the card can land under `projects/agentrecall/`
|
|
469
|
+
* while the raw guessed value stays "AgentRecall". The recency ledger used
|
|
470
|
+
* to be appended with that same raw, never-normalized value, so a lookup
|
|
471
|
+
* keyed on the ledger's slug (e.g. this file's own
|
|
472
|
+
* `packages/mcp-server/test/kill9-orphan-rescue.test.mjs`, which asserts
|
|
473
|
+
* `recencyLines.some((e) => e.slug === rescuedCard.slug)` against the ACTUAL
|
|
474
|
+
* on-disk directory name) could never find the card it was supposedly
|
|
475
|
+
* pointing at. Fixed by tracking a SEPARATE `ledgerSlug` that is always
|
|
476
|
+
* populated from where the card ACTUALLY is — `writeSessionCard`'s own
|
|
477
|
+
* returned `slug` when this call just wrote it, or `findCardSlugForSid`'s
|
|
478
|
+
* already-resolved slug when the card already existed — never from the raw
|
|
479
|
+
* `guessSlugFromWmLines` guess directly.
|
|
480
|
+
*/
|
|
481
|
+
function distillOneSession(wmFile, recentSids) {
|
|
482
|
+
// Idempotency guard: a card and/or recency entry already recorded for this
|
|
483
|
+
// sid means some or all of the rescue already happened (or the session
|
|
484
|
+
// ended normally via hook-end/session_end without WM having been cleaned
|
|
485
|
+
// up yet by some other race). Tracked as two SEPARATE signals (not one
|
|
486
|
+
// OR'd flag) — a card that exists with no matching recency entry must NOT
|
|
487
|
+
// be treated as fully rescued. `existingCardSlug` (not just a boolean) is
|
|
488
|
+
// the ACTUAL on-disk slug of that pre-existing card, needed below.
|
|
489
|
+
const existingCardSlug = findCardSlugForSid(wmFile.sid);
|
|
490
|
+
const hasCard = existingCardSlug !== null;
|
|
491
|
+
const hasRecency = recentSids.has(wmFile.sid);
|
|
492
|
+
if (hasCard && hasRecency) {
|
|
493
|
+
// Both tiers confirmed — nothing left to do but sweep the leftover WM file.
|
|
494
|
+
wmDelete(wmFile.sid);
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
const wmLines = wmRead(wmFile.sid);
|
|
498
|
+
if (wmLines.length === 0) {
|
|
499
|
+
wmDelete(wmFile.sid); // empty/corrupt — nothing to rescue, stop retrying
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
const first = wmLines[0];
|
|
503
|
+
const last = wmLines[wmLines.length - 1];
|
|
504
|
+
const guessedSlug = guessSlugFromWmLines(wmLines) ?? "auto";
|
|
505
|
+
const title = truncateUtf8Bytes(first.prompt, 120);
|
|
506
|
+
const date = new Date(wmFile.mtimeMs).toISOString().slice(0, 10);
|
|
507
|
+
// The slug the RECENCY LEDGER must record — always the card's real on-disk
|
|
508
|
+
// slug, never the raw guess. Defaults to the already-resolved
|
|
509
|
+
// `existingCardSlug` (the hasCard branch below never overwrites it); the
|
|
510
|
+
// !hasCard branch overwrites it with `written.slug` once the card write
|
|
511
|
+
// confirms where it actually landed.
|
|
512
|
+
let ledgerSlug = existingCardSlug ?? guessedSlug;
|
|
513
|
+
// Card-write is attempted ONLY when a card doesn't already exist (hasCard
|
|
514
|
+
// tracks that precisely). When hasCard is already true, the ONLY
|
|
515
|
+
// remaining gap this sweep needs to close is the recency entry.
|
|
516
|
+
let cardOk = hasCard;
|
|
517
|
+
if (!hasCard) {
|
|
518
|
+
const frontmatter = generateFrontmatter({
|
|
519
|
+
sid: wmFile.sid,
|
|
520
|
+
date,
|
|
521
|
+
slug: guessedSlug,
|
|
522
|
+
slug_confidence: 0,
|
|
523
|
+
slug_candidates: [],
|
|
524
|
+
source: "working-memory-rescue",
|
|
525
|
+
});
|
|
526
|
+
const body = [
|
|
527
|
+
`# ${title}`,
|
|
528
|
+
"",
|
|
529
|
+
`- rescued from working memory after ${wmLines.length} recorded prompt${wmLines.length === 1 ? "" : "s"} (no hook-end ever fired for this session)`,
|
|
530
|
+
`- ts range: ${first.ts} → ${last.ts}`,
|
|
531
|
+
"",
|
|
532
|
+
"## First prompt",
|
|
533
|
+
first.prompt,
|
|
534
|
+
"",
|
|
535
|
+
"## Last prompt",
|
|
536
|
+
last.prompt,
|
|
537
|
+
"",
|
|
538
|
+
].join("\n");
|
|
539
|
+
const written = writeSessionCard({
|
|
540
|
+
markdown: frontmatter + body,
|
|
541
|
+
title,
|
|
542
|
+
artifacts: [],
|
|
543
|
+
linearRefs: [],
|
|
544
|
+
decisions: [],
|
|
545
|
+
nextStep: [],
|
|
546
|
+
sid: wmFile.sid,
|
|
547
|
+
slug: guessedSlug,
|
|
548
|
+
date,
|
|
549
|
+
});
|
|
550
|
+
cardOk = !!written.path;
|
|
551
|
+
if (cardOk)
|
|
552
|
+
ledgerSlug = written.slug || guessedSlug; // the ACTUAL on-disk slug, per WriteSessionCardResult.slug's contract
|
|
553
|
+
}
|
|
554
|
+
if (!cardOk) {
|
|
555
|
+
// The card write itself failed — leave the WM file in place so a future
|
|
556
|
+
// sweep (or the next graceful exit) can retry instead of losing the only
|
|
557
|
+
// remaining record of this session.
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
// M1 fix (preserved from the CLI original): verify the recency append
|
|
561
|
+
// actually landed instead of trusting that it didn't throw.
|
|
562
|
+
// `appendRecentSession` is a DELIBERATELY best-effort, never-throws
|
|
563
|
+
// telemetry ledger — an unwritable root, a full disk, or a permissions
|
|
564
|
+
// error fails SILENTLY inside it. Re-read the ledger after the append and
|
|
565
|
+
// only delete WM once BOTH tiers are confirmed present, so a
|
|
566
|
+
// card-written-but-recency-failed session never becomes permanently
|
|
567
|
+
// invisible to continuity.
|
|
568
|
+
if (!hasRecency) {
|
|
569
|
+
appendRecentSession({
|
|
570
|
+
ts: new Date(wmFile.mtimeMs).toISOString(),
|
|
571
|
+
sid: wmFile.sid,
|
|
572
|
+
slug: ledgerSlug,
|
|
573
|
+
title,
|
|
574
|
+
artifact_count: 0,
|
|
575
|
+
});
|
|
576
|
+
const confirmedRecency = readRecentSessions(1000).some((e) => e.sid === wmFile.sid);
|
|
577
|
+
if (!confirmedRecency) {
|
|
578
|
+
recordHookFailure("wm-orphan-rescue-recency", new Error(`appendRecentSession did not persist for sid=${wmFile.sid}`));
|
|
579
|
+
return; // do NOT delete WM — retry the recency append on the next sweep/exit
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
wmDelete(wmFile.sid);
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* C-3 (Train C, 2026-08-12 wave) — best-effort freshness for a graceful
|
|
586
|
+
* client close. `mcp-server/src/lib/lifecycle-exit.ts` calls this for the
|
|
587
|
+
* CURRENT process's own `sid` (core's `getSessionId()`) on `stdin` "end"/
|
|
588
|
+
* "close" and on SIGTERM/SIGINT, so a graceful disconnect gets a card
|
|
589
|
+
* immediately instead of waiting up to `WM_ORPHAN_WINDOW_MS` for the NEXT
|
|
590
|
+
* session's orphan sweep to find it. Reuses `distillOneSession` — the SAME
|
|
591
|
+
* WM→card mechanism `rescueOrphanedWorkingMemory` uses for aged orphans —
|
|
592
|
+
* with no age gate, since this is called precisely because the session is
|
|
593
|
+
* ending RIGHT NOW, not because it went stale. A `kill -9` bypasses this
|
|
594
|
+
* entirely by construction (no signal, no stdin event ever fires) and falls
|
|
595
|
+
* through to `rescueOrphanedWorkingMemory` on a LATER session_start/hook-start,
|
|
596
|
+
* exactly as the design doc specifies.
|
|
597
|
+
*
|
|
598
|
+
* No-op (silent) when this session has no working-memory file at all — a
|
|
599
|
+
* session that never had a tool call captured (or whose WM was already
|
|
600
|
+
* cleaned up by a normal `session_end`) has nothing to distill. Never
|
|
601
|
+
* throws: reported via `recordHookFailure` like every other WM helper.
|
|
602
|
+
*/
|
|
603
|
+
export function distillSessionToCard(sid) {
|
|
604
|
+
try {
|
|
605
|
+
const wmFile = wmList().find((f) => f.sid === sid);
|
|
606
|
+
if (!wmFile)
|
|
607
|
+
return; // nothing captured for this session — silent no-op
|
|
608
|
+
const recentSids = new Set(readRecentSessions(1000).map((e) => e.sid));
|
|
609
|
+
distillOneSession(wmFile, recentSids);
|
|
610
|
+
}
|
|
611
|
+
catch (e) {
|
|
612
|
+
recordHookFailure("wm-session-distill", e);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
328
615
|
//# sourceMappingURL=working-memory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"working-memory.js","sourceRoot":"","sources":["../../src/storage/working-memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,UAAU,GAAG,gBAAgB,CAAC;AACpC,MAAM,SAAS,GAAG,QAAQ,CAAC;AAC3B,MAAM,SAAS,GAAG,QAAQ,CAAC;AAE3B,0EAA0E;AAC1E,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC;AAChC,iEAAiE;AACjE,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAEtC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,KAAK;AAE1D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mB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I,KAAK,CAAC,+CAA+C,MAAM,CAAC,GAAG,EAAE,CAAC,CACvE,CAAC;YACF,OAAO,CAAC,qEAAqE;QAC/E,CAAC;IACH,CAAC;IAED,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;QACnD,IAAI,CAAC,MAAM;YAAE,OAAO,CAAC,mDAAmD;QACxE,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACvE,iBAAiB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACxC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,iBAAiB,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alignment-check.d.ts","sourceRoot":"","sources":["../../src/tools-logic/alignment-check.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"alignment-check.d.ts","sourceRoot":"","sources":["../../src/tools-logic/alignment-check.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IACtC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,WAAW,GAAG,WAAW,CAAC;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAID,wBAAsB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA+D9F"}
|
|
@@ -5,6 +5,7 @@ import { journalDir, palaceDir, sanitizeSlug } from "../storage/paths.js";
|
|
|
5
5
|
import { ensureDir, todayISO } from "../storage/fs-utils.js";
|
|
6
6
|
import { ensurePalaceInitialized, roomExists } from "../palace/rooms.js";
|
|
7
7
|
import { updatePalaceIndex } from "../palace/index-manager.js";
|
|
8
|
+
import { scrubForCloud } from "../storage/content-guard.js";
|
|
8
9
|
const VALID_CATEGORIES = new Set(["goal", "scope", "priority", "technical", "aesthetic"]);
|
|
9
10
|
export async function alignmentCheck(input) {
|
|
10
11
|
const slug = await resolveProject(input.project);
|
|
@@ -28,6 +29,10 @@ export async function alignmentCheck(input) {
|
|
|
28
29
|
if (input.human_correction)
|
|
29
30
|
entry += `**Human**: ${input.human_correction}\n**Delta**: ${input.delta || "not specified"}\n`;
|
|
30
31
|
entry += "\n";
|
|
32
|
+
// Scrub BEFORE the local write — this log is scanned by contextSynthesize's
|
|
33
|
+
// "Today's Alignment" section AND is a free-text sink (goal/human_correction/
|
|
34
|
+
// delta/unclear/assumptions) with no scrub of any kind previously.
|
|
35
|
+
entry = scrubForCloud(entry);
|
|
31
36
|
const logPath = path.join(dir, `${date}-alignment.md`);
|
|
32
37
|
if (!fs.existsSync(logPath)) {
|
|
33
38
|
fs.writeFileSync(logPath, `# ${date} — Alignment Records\n\n---\n\n${entry}`, "utf-8");
|
|
@@ -42,7 +47,7 @@ export async function alignmentCheck(input) {
|
|
|
42
47
|
const alignFile = path.join(pd, "rooms", "alignment", `${safeCategory}.md`);
|
|
43
48
|
ensureDir(path.dirname(alignFile));
|
|
44
49
|
if (input.human_correction) {
|
|
45
|
-
const palaceEntry = `\n### ${date} ${time} — ${input.confidence}\n**Goal**: ${input.goal}\n**Human correction**: ${input.human_correction}\n**Delta**: ${input.delta || "pending"}\n
|
|
50
|
+
const palaceEntry = scrubForCloud(`\n### ${date} ${time} — ${input.confidence}\n**Goal**: ${input.goal}\n**Human correction**: ${input.human_correction}\n**Delta**: ${input.delta || "pending"}\n`);
|
|
46
51
|
if (fs.existsSync(alignFile)) {
|
|
47
52
|
const existing = fs.readFileSync(alignFile, "utf-8");
|
|
48
53
|
// Dedup: skip if the same goal was already recorded today (prevents double-write from MCP retries)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alignment-check.js","sourceRoot":"","sources":["../../src/tools-logic/alignment-check.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,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"alignment-check.js","sourceRoot":"","sources":["../../src/tools-logic/alignment-check.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,cAAc,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AE,IAAI,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC/G,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/tools-logic/bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/tools-logic/bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA6GH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,KAAK,GAAG,eAAe,GAAG,UAAU,GAAG,cAAc,CAAC;QAC5D,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,gBAAgB,EAAE,cAAc,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,UAAU,GAAG,QAAQ,GAAG,cAAc,GAAG,YAAY,CAAC;IAC5D,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,KAAK,EAAE;QACL,cAAc,EAAE,MAAM,CAAC;QACvB,sBAAsB,EAAE,MAAM,CAAC;QAC/B,mBAAmB,EAAE,MAAM,CAAC;QAC5B,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF;;;;;;;OAOG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChE,WAAW,EAAE,MAAM,CAAC;CACrB;AA8TD,wBAAsB,aAAa,CAAC,OAAO,CAAC,EAAE;IAC5C,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAgS/B;AAMD,wBAAsB,eAAe,CACnC,IAAI,EAAE,mBAAmB,EACzB,SAAS,CAAC,EAAE,eAAe,GAC1B,OAAO,CAAC,YAAY,CAAC,CAgVvB"}
|
|
@@ -19,7 +19,7 @@ import { palaceWrite } from "./palace-write.js";
|
|
|
19
19
|
import { journalWrite } from "./journal-write.js";
|
|
20
20
|
import { awarenessUpdate } from "./awareness-update.js";
|
|
21
21
|
import { palaceDir, sanitizeProject, projectsRootDir } from "../storage/paths.js";
|
|
22
|
-
import { scrubSecretContent } from "../storage/content-guard.js";
|
|
22
|
+
import { scrubSecretContent, scrubPromptInjection } from "../storage/content-guard.js";
|
|
23
23
|
const execFileAsync = promisify(execFile);
|
|
24
24
|
// ---------------------------------------------------------------------------
|
|
25
25
|
// GUARD 3: In-process nonce registry
|
|
@@ -95,20 +95,6 @@ function isSystemDir(name) {
|
|
|
95
95
|
return true; // bare UUIDs
|
|
96
96
|
return SYSTEM_DIR_DENYLIST.has(name);
|
|
97
97
|
}
|
|
98
|
-
/**
|
|
99
|
-
* Strip prompt-injection patterns from imported user content before writing it
|
|
100
|
-
* to palace. CLAUDE.md and AutoMemory files frequently contain
|
|
101
|
-
* `<system-reminder>` markers etc. that, once in palace, would surface to future
|
|
102
|
-
* agents as if they were system instructions.
|
|
103
|
-
*/
|
|
104
|
-
function scrubPromptInjection(s) {
|
|
105
|
-
return s
|
|
106
|
-
.replace(/<\/?\s*(system[-_]?(reminder|prompt|message|instruction)|important|critical)\b[^>]*>/gi, "[stripped tag]")
|
|
107
|
-
.replace(/<\|im_(start|end)\|>/gi, "[stripped]")
|
|
108
|
-
.replace(/\b(ignore|disregard|forget)\s+(all\s+)?(previous|prior|above)\s+(instructions?|prompts?|messages?)/gi, "[stripped injection attempt]")
|
|
109
|
-
.replace(/[--]/g, "") // bidi override
|
|
110
|
-
.replace(/\0/g, "");
|
|
111
|
-
}
|
|
112
98
|
// ---------------------------------------------------------------------------
|
|
113
99
|
// Constants
|
|
114
100
|
// ---------------------------------------------------------------------------
|