@cleocode/core 2026.4.99 → 2026.4.100
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/gc/daemon.js +481 -0
- package/dist/gc/daemon.js.map +7 -0
- package/dist/gc/index.js +669 -0
- package/dist/gc/index.js.map +7 -0
- package/dist/gc/runner.js +360 -0
- package/dist/gc/runner.js.map +7 -0
- package/dist/gc/state.js +49 -0
- package/dist/gc/state.js.map +7 -0
- package/dist/gc/transcript.js +209 -0
- package/dist/gc/transcript.js.map +7 -0
- package/dist/memory/brain-backfill.js +14643 -0
- package/dist/memory/brain-backfill.js.map +7 -0
- package/dist/memory/precompact-flush.js +47725 -0
- package/dist/memory/precompact-flush.js.map +7 -0
- package/dist/sentient/daemon.js +1100 -0
- package/dist/sentient/daemon.js.map +7 -0
- package/dist/sentient/index.js +1162 -0
- package/dist/sentient/index.js.map +7 -0
- package/dist/sentient/propose-tick.js +549 -0
- package/dist/sentient/propose-tick.js.map +7 -0
- package/dist/sentient/state.js +85 -0
- package/dist/sentient/state.js.map +7 -0
- package/dist/sentient/tick.js +396 -0
- package/dist/sentient/tick.js.map +7 -0
- package/dist/system/platform-paths.js +36 -0
- package/dist/system/platform-paths.js.map +7 -0
- package/package.json +8 -8
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/gc/state.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * GC State \u2014 Persistent crash-recovery state for the autonomous GC daemon.\n *\n * Stored in `.cleo/gc-state.json` (plain JSON, not SQLite) to avoid\n * SQLite WAL conflicts between the long-running daemon process and the\n * main CLEO CLI process. Human-readable for debugging.\n *\n * The file is gitignored (see .gitignore \u00A7.cleo/ section) and created empty\n * by `cleo init`. It is NOT included in `cleo backup restore` scope because\n * it is ephemeral operational state \u2014 only the `daemonPid` and `lastRunAt`\n * fields survive between process restarts.\n *\n * @see ADR-047 \u2014 Autonomous GC and Disk Safety\n * @task T731\n * @epic T726\n */\n\nimport { mkdir, readFile, rename, writeFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\n\n/** Schema version for gc-state.json. Bump on breaking field changes. */\nexport const GC_STATE_SCHEMA_VERSION = '1.0' as const;\n\n/**\n * Persistent GC daemon state written to `.cleo/gc-state.json`.\n *\n * Design principles:\n * - `pendingPrune` enables idempotent crash recovery: populate BEFORE deletion,\n * clear each entry AFTER successful deletion, clear entirely when job completes.\n * - `diskThresholdBreached` is a sticky flag: cleared only when disk drops\n * below the WATCH tier (70%).\n * - `escalationNeeded` is set by the daemon when disk is in WARN/URGENT range;\n * cleared by the CLI after displaying the escalation banner.\n */\nexport interface GCState {\n /** JSON schema version for forward-compatibility checks. */\n schemaVersion: typeof GC_STATE_SCHEMA_VERSION;\n /** ISO-8601 timestamp of last COMPLETED GC run. null = never run. */\n lastRunAt: string | null;\n /** Outcome of the last GC run. */\n lastRunResult: 'success' | 'partial' | 'failed' | null;\n /** Bytes freed in the last completed GC run. */\n lastRunBytesFreed: number;\n /**\n * Paths queued for deletion but not yet deleted.\n * Written BEFORE starting deletion; cleared entry-by-entry on success.\n * Enables idempotent crash recovery on daemon restart.\n */\n pendingPrune: string[] | null;\n /** Number of consecutive GC failures. Triggers escalation banner after 3. */\n consecutiveFailures: number;\n /** Sticky flag: true when disk is \u2265 WATCH tier (70%). Cleared when disk < 70%. */\n diskThresholdBreached: boolean;\n /** Current disk usage percentage (0\u2013100) from the last GC run. */\n lastDiskUsedPct: number | null;\n /**\n * Escalation banner flag. Set by daemon when disk is in WARN+ range.\n * Cleared by CLI after displaying the banner to the user.\n */\n escalationNeeded: boolean;\n /** Escalation reason shown in the CLI banner. */\n escalationReason: string | null;\n /** PID of the currently running daemon process. null = daemon not running. */\n daemonPid: number | null;\n /** ISO-8601 timestamp when the daemon was last started. */\n daemonStartedAt: string | null;\n}\n\n/** Default (empty) GC state for fresh initialisation. */\nexport const DEFAULT_GC_STATE: GCState = {\n schemaVersion: GC_STATE_SCHEMA_VERSION,\n lastRunAt: null,\n lastRunResult: null,\n lastRunBytesFreed: 0,\n pendingPrune: null,\n consecutiveFailures: 0,\n diskThresholdBreached: false,\n lastDiskUsedPct: null,\n escalationNeeded: false,\n escalationReason: null,\n daemonPid: null,\n daemonStartedAt: null,\n};\n\n/**\n * Read the GC state from disk.\n *\n * Returns the default state if the file does not exist or is malformed.\n * Never throws \u2014 GC state file absence is not an error condition.\n *\n * @param statePath - Absolute path to gc-state.json\n * @returns Parsed GC state, merged with defaults for any missing fields\n */\nexport async function readGCState(statePath: string): Promise<GCState> {\n try {\n const raw = await readFile(statePath, 'utf-8');\n const parsed = JSON.parse(raw) as Partial<GCState>;\n // Merge with defaults so new fields added in future schema versions\n // don't cause undefined access on old state files.\n return { ...DEFAULT_GC_STATE, ...parsed };\n } catch {\n // ENOENT (file not yet created) or JSON parse error \u2192 use defaults\n return { ...DEFAULT_GC_STATE };\n }\n}\n\n/**\n * Write the GC state to disk atomically via tmp-then-rename.\n *\n * Atomic write prevents partial reads if the daemon crashes mid-write.\n * Idempotent: safe to call multiple times.\n *\n * @param statePath - Absolute path to gc-state.json\n * @param state - GC state to persist\n */\nexport async function writeGCState(statePath: string, state: GCState): Promise<void> {\n const dir = dirname(statePath);\n await mkdir(dir, { recursive: true });\n\n const tmpPath = join(dir, `.gc-state-${process.pid}.tmp`);\n const json = JSON.stringify(state, null, 2);\n\n await writeFile(tmpPath, json, 'utf-8');\n await rename(tmpPath, statePath);\n}\n\n/**\n * Patch a subset of fields in the GC state file.\n *\n * Convenience wrapper: reads current state, merges patch, writes back.\n *\n * @param statePath - Absolute path to gc-state.json\n * @param patch - Partial state to merge over the existing state\n */\nexport async function patchGCState(statePath: string, patch: Partial<GCState>): Promise<GCState> {\n const current = await readGCState(statePath);\n const updated: GCState = { ...current, ...patch };\n await writeGCState(statePath, updated);\n return updated;\n}\n"],
|
|
5
|
+
"mappings": ";AAiBA,SAAS,OAAO,UAAU,QAAQ,iBAAiB;AACnD,SAAS,SAAS,YAAY;AAGvB,IAAM,0BAA0B;AAgDhC,IAAM,mBAA4B;AAAA,EACvC,eAAe;AAAA,EACf,WAAW;AAAA,EACX,eAAe;AAAA,EACf,mBAAmB;AAAA,EACnB,cAAc;AAAA,EACd,qBAAqB;AAAA,EACrB,uBAAuB;AAAA,EACvB,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,WAAW;AAAA,EACX,iBAAiB;AACnB;AAWA,eAAsB,YAAY,WAAqC;AACrE,MAAI;AACF,UAAM,MAAM,MAAM,SAAS,WAAW,OAAO;AAC7C,UAAM,SAAS,KAAK,MAAM,GAAG;AAG7B,WAAO,EAAE,GAAG,kBAAkB,GAAG,OAAO;AAAA,EAC1C,QAAQ;AAEN,WAAO,EAAE,GAAG,iBAAiB;AAAA,EAC/B;AACF;AAWA,eAAsB,aAAa,WAAmB,OAA+B;AACnF,QAAM,MAAM,QAAQ,SAAS;AAC7B,QAAM,MAAM,KAAK,EAAE,WAAW,KAAK,CAAC;AAEpC,QAAM,UAAU,KAAK,KAAK,aAAa,QAAQ,GAAG,MAAM;AACxD,QAAM,OAAO,KAAK,UAAU,OAAO,MAAM,CAAC;AAE1C,QAAM,UAAU,SAAS,MAAM,OAAO;AACtC,QAAM,OAAO,SAAS,SAAS;AACjC;AAUA,eAAsB,aAAa,WAAmB,OAA2C;AAC/F,QAAM,UAAU,MAAM,YAAY,SAAS;AAC3C,QAAM,UAAmB,EAAE,GAAG,SAAS,GAAG,MAAM;AAChD,QAAM,aAAa,WAAW,OAAO;AACrC,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
// packages/core/src/gc/transcript.ts
|
|
2
|
+
import { lstat as lstat2, readdir as readdir2, stat as stat2 } from "node:fs/promises";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { join as join2 } from "node:path";
|
|
5
|
+
|
|
6
|
+
// packages/core/src/gc/runner.ts
|
|
7
|
+
import { lstat, readdir, rm, stat } from "node:fs/promises";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
async function getPathBytes(targetPath) {
|
|
10
|
+
try {
|
|
11
|
+
const info = await lstat(targetPath);
|
|
12
|
+
if (info.isFile()) return info.size;
|
|
13
|
+
if (!info.isDirectory()) return 0;
|
|
14
|
+
const entries = await readdir(targetPath, { withFileTypes: true });
|
|
15
|
+
let total = 0;
|
|
16
|
+
for (const entry of entries) {
|
|
17
|
+
total += await getPathBytes(join(targetPath, entry.name));
|
|
18
|
+
}
|
|
19
|
+
return total;
|
|
20
|
+
} catch {
|
|
21
|
+
return 0;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async function idempotentRm(targetPath) {
|
|
25
|
+
try {
|
|
26
|
+
await rm(targetPath, { recursive: true, force: true });
|
|
27
|
+
} catch (err) {
|
|
28
|
+
const nodeErr = err;
|
|
29
|
+
if (nodeErr.code === "ENOENT") return;
|
|
30
|
+
throw err;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// packages/core/src/gc/transcript.ts
|
|
35
|
+
var HOT_MAX_MS = 24 * 60 * 60 * 1e3;
|
|
36
|
+
var WARM_MAX_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
37
|
+
function classifyTranscriptTier(ageMs) {
|
|
38
|
+
if (ageMs < HOT_MAX_MS) return "hot";
|
|
39
|
+
if (ageMs < WARM_MAX_MS) return "warm";
|
|
40
|
+
return "cold";
|
|
41
|
+
}
|
|
42
|
+
function parseSessionId(filename) {
|
|
43
|
+
return filename.replace(/\.jsonl$/, "");
|
|
44
|
+
}
|
|
45
|
+
async function scanTranscripts(projectsDir) {
|
|
46
|
+
const resolvedProjectsDir = projectsDir ?? join2(homedir(), ".claude", "projects");
|
|
47
|
+
const now = Date.now();
|
|
48
|
+
const hot = [];
|
|
49
|
+
const warm = [];
|
|
50
|
+
let totalBytes = 0;
|
|
51
|
+
let slugs;
|
|
52
|
+
try {
|
|
53
|
+
const entries = await readdir2(resolvedProjectsDir, { withFileTypes: true });
|
|
54
|
+
slugs = entries.filter((e) => e.isDirectory()).map((e) => e.name);
|
|
55
|
+
} catch {
|
|
56
|
+
return { totalSessions: 0, hot, warm, totalBytes, projectsDir: resolvedProjectsDir };
|
|
57
|
+
}
|
|
58
|
+
for (const slug of slugs) {
|
|
59
|
+
const slugDir = join2(resolvedProjectsDir, slug);
|
|
60
|
+
let entries;
|
|
61
|
+
try {
|
|
62
|
+
entries = await readdir2(slugDir, { withFileTypes: true });
|
|
63
|
+
} catch {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
for (const entry of entries) {
|
|
67
|
+
if (!entry.isFile() || !entry.name.endsWith(".jsonl")) continue;
|
|
68
|
+
const jsonlPath = join2(slugDir, entry.name);
|
|
69
|
+
const sessionId = parseSessionId(entry.name);
|
|
70
|
+
let fileInfo;
|
|
71
|
+
try {
|
|
72
|
+
fileInfo = await stat2(jsonlPath);
|
|
73
|
+
} catch {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const mtimeMs = fileInfo.mtimeMs;
|
|
77
|
+
const ageMs = now - mtimeMs;
|
|
78
|
+
const tier = classifyTranscriptTier(ageMs);
|
|
79
|
+
const bytes = fileInfo.size;
|
|
80
|
+
const candidateSessionDir = join2(slugDir, sessionId);
|
|
81
|
+
let sessionDir = null;
|
|
82
|
+
let sessionDirBytes = 0;
|
|
83
|
+
try {
|
|
84
|
+
const dirInfo = await lstat2(candidateSessionDir);
|
|
85
|
+
if (dirInfo.isDirectory()) {
|
|
86
|
+
sessionDir = candidateSessionDir;
|
|
87
|
+
sessionDirBytes = await getPathBytes(candidateSessionDir);
|
|
88
|
+
}
|
|
89
|
+
} catch {
|
|
90
|
+
}
|
|
91
|
+
const info = {
|
|
92
|
+
jsonlPath,
|
|
93
|
+
projectSlug: slug,
|
|
94
|
+
sessionId,
|
|
95
|
+
mtimeMs,
|
|
96
|
+
ageMs,
|
|
97
|
+
tier,
|
|
98
|
+
bytes,
|
|
99
|
+
sessionDir,
|
|
100
|
+
sessionDirBytes
|
|
101
|
+
};
|
|
102
|
+
totalBytes += bytes + sessionDirBytes;
|
|
103
|
+
if (tier === "hot") {
|
|
104
|
+
hot.push(info);
|
|
105
|
+
} else if (tier === "warm") {
|
|
106
|
+
warm.push(info);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const totalSessions = hot.length + warm.length;
|
|
111
|
+
return { totalSessions, hot, warm, totalBytes, projectsDir: resolvedProjectsDir };
|
|
112
|
+
}
|
|
113
|
+
async function pruneTranscripts(opts) {
|
|
114
|
+
const { olderThanMs, confirm, projectsDir } = opts;
|
|
115
|
+
const dryRun = !confirm;
|
|
116
|
+
const hasApiKey = Boolean(process.env["ANTHROPIC_API_KEY"]);
|
|
117
|
+
const effectiveMaxAgeMs = hasApiKey ? olderThanMs : Math.max(olderThanMs, 30 * 24 * 60 * 60 * 1e3);
|
|
118
|
+
const now = Date.now();
|
|
119
|
+
const deletedPaths = [];
|
|
120
|
+
let bytesFreed = 0;
|
|
121
|
+
let pruned = 0;
|
|
122
|
+
const resolvedProjectsDir = projectsDir ?? join2(homedir(), ".claude", "projects");
|
|
123
|
+
let slugs;
|
|
124
|
+
try {
|
|
125
|
+
const entries = await readdir2(resolvedProjectsDir, { withFileTypes: true });
|
|
126
|
+
slugs = entries.filter((e) => e.isDirectory()).map((e) => e.name);
|
|
127
|
+
} catch {
|
|
128
|
+
return { pruned: 0, bytesFreed: 0, deletedPaths: [], dryRun };
|
|
129
|
+
}
|
|
130
|
+
for (const slug of slugs) {
|
|
131
|
+
const slugDir = join2(resolvedProjectsDir, slug);
|
|
132
|
+
let entries;
|
|
133
|
+
try {
|
|
134
|
+
entries = await readdir2(slugDir, { withFileTypes: true });
|
|
135
|
+
} catch {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
for (const entry of entries) {
|
|
139
|
+
if (!entry.isFile() || !entry.name.endsWith(".jsonl")) continue;
|
|
140
|
+
const jsonlPath = join2(slugDir, entry.name);
|
|
141
|
+
let fileInfo;
|
|
142
|
+
try {
|
|
143
|
+
fileInfo = await stat2(jsonlPath);
|
|
144
|
+
} catch {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
const ageMs = now - fileInfo.mtimeMs;
|
|
148
|
+
if (ageMs <= effectiveMaxAgeMs) continue;
|
|
149
|
+
const sessionId = parseSessionId(entry.name);
|
|
150
|
+
const sessionDir = join2(slugDir, sessionId);
|
|
151
|
+
const jsonlBytes = fileInfo.size;
|
|
152
|
+
let sessionDirBytes = 0;
|
|
153
|
+
try {
|
|
154
|
+
const dirInfo = await lstat2(sessionDir);
|
|
155
|
+
if (dirInfo.isDirectory()) {
|
|
156
|
+
sessionDirBytes = await getPathBytes(sessionDir);
|
|
157
|
+
}
|
|
158
|
+
} catch {
|
|
159
|
+
}
|
|
160
|
+
if (dryRun) {
|
|
161
|
+
deletedPaths.push(jsonlPath);
|
|
162
|
+
if (sessionDirBytes > 0) deletedPaths.push(sessionDir);
|
|
163
|
+
bytesFreed += jsonlBytes + sessionDirBytes;
|
|
164
|
+
pruned++;
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
try {
|
|
168
|
+
await idempotentRm(jsonlPath);
|
|
169
|
+
deletedPaths.push(jsonlPath);
|
|
170
|
+
bytesFreed += jsonlBytes;
|
|
171
|
+
pruned++;
|
|
172
|
+
} catch {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
try {
|
|
176
|
+
const dirInfo = await lstat2(sessionDir);
|
|
177
|
+
if (dirInfo.isDirectory()) {
|
|
178
|
+
await idempotentRm(sessionDir);
|
|
179
|
+
deletedPaths.push(sessionDir);
|
|
180
|
+
bytesFreed += sessionDirBytes;
|
|
181
|
+
}
|
|
182
|
+
} catch {
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return { pruned, bytesFreed, deletedPaths, dryRun };
|
|
187
|
+
}
|
|
188
|
+
function parseDurationMs(duration) {
|
|
189
|
+
const match = /^(\d+(\.\d+)?)(d|h|m|s)$/.exec(duration.trim());
|
|
190
|
+
if (!match?.[1] || !match[3]) {
|
|
191
|
+
throw new Error(`Invalid duration format: "${duration}". Use format like 7d, 24h, 30m, 60s.`);
|
|
192
|
+
}
|
|
193
|
+
const value = parseFloat(match[1]);
|
|
194
|
+
const unit = match[3];
|
|
195
|
+
const multipliers = {
|
|
196
|
+
d: 24 * 60 * 60 * 1e3,
|
|
197
|
+
h: 60 * 60 * 1e3,
|
|
198
|
+
m: 60 * 1e3,
|
|
199
|
+
s: 1e3
|
|
200
|
+
};
|
|
201
|
+
return value * (multipliers[unit] ?? 1e3);
|
|
202
|
+
}
|
|
203
|
+
export {
|
|
204
|
+
classifyTranscriptTier,
|
|
205
|
+
parseDurationMs,
|
|
206
|
+
pruneTranscripts,
|
|
207
|
+
scanTranscripts
|
|
208
|
+
};
|
|
209
|
+
//# sourceMappingURL=transcript.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/gc/transcript.ts", "../../src/gc/runner.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Transcript Scanner \u2014 Inventory and age-classification of Claude session transcripts.\n *\n * Implements the hot/warm/cold three-tier model from memory-architecture-spec.md \u00A76:\n * - HOT (0\u201324h): Full JSONL retained; agents can re-read\n * - WARM (1\u20137d): Pending extraction; scheduled at session end\n * - COLD (>7d): brain.db entries only; raw JSONL deleted (tombstone in brain_obs)\n *\n * Storage layout scanned (\u00A76.2):\n * ```\n * ~/.claude/projects/\n * <project-slug>/\n * <session-uuid>.jsonl \u2190 root-level main session transcript\n * <session-uuid>/ \u2190 session UUID directory\n * subagents/\n * agent-<agentId>.jsonl \u2190 subagent transcript\n * agent-<agentId>.meta.json\n * tool-results/\n * <toolUseId>.json\n * ```\n *\n * @see docs/specs/memory-architecture-spec.md \u00A76.1\u20136.2\n * @task T728\n * @epic T726\n */\n\nimport { lstat, readdir, stat } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\nimport { getPathBytes, idempotentRm } from './runner.js';\n\n// ---------------------------------------------------------------------------\n// Tier boundaries (in milliseconds)\n// ---------------------------------------------------------------------------\n\n/** HOT tier: sessions less than 24 hours old. */\nconst HOT_MAX_MS = 24 * 60 * 60 * 1000;\n\n/** WARM tier: sessions 24h\u20137d old. */\nconst WARM_MAX_MS = 7 * 24 * 60 * 60 * 1000;\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** Hot/warm/cold lifecycle tier for a transcript session. */\nexport type TranscriptTier = 'hot' | 'warm' | 'cold';\n\n/**\n * Metadata for a single session transcript discovered on disk.\n */\nexport interface SessionInfo {\n /** Absolute path to the root session JSONL file. */\n jsonlPath: string;\n /** Project slug (directory name under `~/.claude/projects/`). */\n projectSlug: string;\n /** Session UUID extracted from the JSONL filename. */\n sessionId: string;\n /** Last modified time of the JSONL file (ms since epoch). */\n mtimeMs: number;\n /** Age of the session in milliseconds. */\n ageMs: number;\n /** Lifecycle tier. */\n tier: TranscriptTier;\n /** Size in bytes of the root JSONL file. */\n bytes: number;\n /**\n * Absolute path to the session UUID directory (if it exists).\n * Contains `subagents/` and `tool-results/` subdirs.\n */\n sessionDir: string | null;\n /** Size in bytes of the session UUID directory (including subagents). */\n sessionDirBytes: number;\n}\n\n/**\n * Aggregate scan result: session inventory with tier-based grouping.\n */\nexport interface TranscriptScanResult {\n /** Total number of sessions found. */\n totalSessions: number;\n /** HOT tier sessions (< 24h). */\n hot: SessionInfo[];\n /** WARM tier sessions (24h\u20137d). */\n warm: SessionInfo[];\n /** Total size of all discovered transcripts in bytes. */\n totalBytes: number;\n /** Absolute path to `~/.claude/projects/`. */\n projectsDir: string;\n}\n\n/**\n * Result of a transcript prune operation.\n */\nexport interface TranscriptPruneResult {\n /** Number of sessions pruned. */\n pruned: number;\n /** Bytes freed. */\n bytesFreed: number;\n /** Paths that were deleted (or would be deleted in dry-run). */\n deletedPaths: string[];\n /** Whether this was a dry-run (no filesystem mutations). */\n dryRun: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Classify a session age into a transcript tier.\n *\n * @param ageMs - Session age in milliseconds\n * @returns Lifecycle tier\n */\nexport function classifyTranscriptTier(ageMs: number): TranscriptTier {\n if (ageMs < HOT_MAX_MS) return 'hot';\n if (ageMs < WARM_MAX_MS) return 'warm';\n return 'cold';\n}\n\n/**\n * Parse a session UUID from a JSONL filename.\n *\n * Expected format: `<uuid>.jsonl` where uuid matches the standard\n * UUID v4 pattern (8-4-4-4-12 hex digits).\n *\n * @param filename - JSONL filename (basename only)\n * @returns Session UUID string, or the filename stem if not UUID format\n */\nfunction parseSessionId(filename: string): string {\n return filename.replace(/\\.jsonl$/, '');\n}\n\n// ---------------------------------------------------------------------------\n// Core operations\n// ---------------------------------------------------------------------------\n\n/**\n * Scan `~/.claude/projects/` and return a structured inventory of all\n * session transcripts, classified by hot/warm/cold tier.\n *\n * Does not modify any files. Safe to call at any time.\n *\n * @param projectsDir - Override the default `~/.claude/projects/` path (for testing)\n * @returns Transcript scan result with tier-classified session list\n */\nexport async function scanTranscripts(projectsDir?: string): Promise<TranscriptScanResult> {\n const resolvedProjectsDir = projectsDir ?? join(homedir(), '.claude', 'projects');\n const now = Date.now();\n\n const hot: SessionInfo[] = [];\n const warm: SessionInfo[] = [];\n let totalBytes = 0;\n\n // List project slugs\n let slugs: string[];\n try {\n const entries = await readdir(resolvedProjectsDir, { withFileTypes: true });\n slugs = entries.filter((e) => e.isDirectory()).map((e) => e.name);\n } catch {\n // Directory doesn't exist yet \u2014 return empty result\n return { totalSessions: 0, hot, warm, totalBytes, projectsDir: resolvedProjectsDir };\n }\n\n for (const slug of slugs) {\n const slugDir = join(resolvedProjectsDir, slug);\n\n let entries: import('fs').Dirent[];\n try {\n entries = await readdir(slugDir, { withFileTypes: true });\n } catch {\n continue;\n }\n\n for (const entry of entries) {\n if (!entry.isFile() || !entry.name.endsWith('.jsonl')) continue;\n\n const jsonlPath = join(slugDir, entry.name);\n const sessionId = parseSessionId(entry.name);\n\n let fileInfo: import('fs').Stats;\n try {\n fileInfo = await stat(jsonlPath);\n } catch {\n continue; // File disappeared between readdir and stat\n }\n\n const mtimeMs = fileInfo.mtimeMs;\n const ageMs = now - mtimeMs;\n const tier = classifyTranscriptTier(ageMs);\n const bytes = fileInfo.size;\n\n // Check for associated session UUID directory\n const candidateSessionDir = join(slugDir, sessionId);\n let sessionDir: string | null = null;\n let sessionDirBytes = 0;\n try {\n const dirInfo = await lstat(candidateSessionDir);\n if (dirInfo.isDirectory()) {\n sessionDir = candidateSessionDir;\n sessionDirBytes = await getPathBytes(candidateSessionDir);\n }\n } catch {\n // Session dir doesn't exist \u2014 single-file session\n }\n\n const info: SessionInfo = {\n jsonlPath,\n projectSlug: slug,\n sessionId,\n mtimeMs,\n ageMs,\n tier,\n bytes,\n sessionDir,\n sessionDirBytes,\n };\n\n totalBytes += bytes + sessionDirBytes;\n\n if (tier === 'hot') {\n hot.push(info);\n } else if (tier === 'warm') {\n warm.push(info);\n }\n // COLD sessions have already had their JSONL deleted (tombstone only in brain.db)\n // so they won't appear in the filesystem scan\n }\n }\n\n const totalSessions = hot.length + warm.length;\n return { totalSessions, hot, warm, totalBytes, projectsDir: resolvedProjectsDir };\n}\n\n/**\n * Prune session transcripts older than `olderThanMs` milliseconds.\n *\n * Dry-run by default: pass `confirm: true` to perform actual deletion.\n *\n * Circuit breakers (from memory-architecture-spec.md \u00A76.4):\n * - If `ANTHROPIC_API_KEY` is absent, only delete sessions older than 30d\n * (raw preservation fallback \u2014 skip extraction).\n *\n * @param opts - Prune options\n * @param opts.olderThanMs - Delete sessions older than this many milliseconds\n * @param opts.confirm - If true, perform actual deletion; dry-run if false\n * @param opts.projectsDir - Override `~/.claude/projects/` (for testing)\n * @returns Prune result with count, bytes freed, and deleted paths\n */\nexport async function pruneTranscripts(opts: {\n olderThanMs: number;\n confirm: boolean;\n projectsDir?: string;\n}): Promise<TranscriptPruneResult> {\n const { olderThanMs, confirm, projectsDir } = opts;\n const dryRun = !confirm;\n\n // Circuit breaker: no API key \u2192 be conservative (only prune >30d)\n const hasApiKey = Boolean(process.env['ANTHROPIC_API_KEY']);\n const effectiveMaxAgeMs = hasApiKey\n ? olderThanMs\n : Math.max(olderThanMs, 30 * 24 * 60 * 60 * 1000);\n\n const now = Date.now();\n const deletedPaths: string[] = [];\n let bytesFreed = 0;\n let pruned = 0;\n\n const resolvedProjectsDir = projectsDir ?? join(homedir(), '.claude', 'projects');\n\n let slugs: string[];\n try {\n const entries = await readdir(resolvedProjectsDir, { withFileTypes: true });\n slugs = entries.filter((e) => e.isDirectory()).map((e) => e.name);\n } catch {\n return { pruned: 0, bytesFreed: 0, deletedPaths: [], dryRun };\n }\n\n for (const slug of slugs) {\n const slugDir = join(resolvedProjectsDir, slug);\n\n let entries: import('fs').Dirent[];\n try {\n entries = await readdir(slugDir, { withFileTypes: true });\n } catch {\n continue;\n }\n\n for (const entry of entries) {\n if (!entry.isFile() || !entry.name.endsWith('.jsonl')) continue;\n\n const jsonlPath = join(slugDir, entry.name);\n\n let fileInfo: import('fs').Stats;\n try {\n fileInfo = await stat(jsonlPath);\n } catch {\n continue;\n }\n\n const ageMs = now - fileInfo.mtimeMs;\n if (ageMs <= effectiveMaxAgeMs) continue;\n\n const sessionId = parseSessionId(entry.name);\n const sessionDir = join(slugDir, sessionId);\n\n // Measure bytes before deletion\n const jsonlBytes = fileInfo.size;\n let sessionDirBytes = 0;\n try {\n const dirInfo = await lstat(sessionDir);\n if (dirInfo.isDirectory()) {\n sessionDirBytes = await getPathBytes(sessionDir);\n }\n } catch {\n // No session dir\n }\n\n if (dryRun) {\n deletedPaths.push(jsonlPath);\n if (sessionDirBytes > 0) deletedPaths.push(sessionDir);\n bytesFreed += jsonlBytes + sessionDirBytes;\n pruned++;\n continue;\n }\n\n // Actual deletion\n try {\n await idempotentRm(jsonlPath);\n deletedPaths.push(jsonlPath);\n bytesFreed += jsonlBytes;\n pruned++;\n } catch {\n // Deletion failure: skip this file\n continue;\n }\n\n // Delete associated session directory if it exists\n try {\n const dirInfo = await lstat(sessionDir);\n if (dirInfo.isDirectory()) {\n await idempotentRm(sessionDir);\n deletedPaths.push(sessionDir);\n bytesFreed += sessionDirBytes;\n }\n } catch {\n // No session dir or already deleted\n }\n }\n }\n\n return { pruned, bytesFreed, deletedPaths, dryRun };\n}\n\n/**\n * Parse a human-readable duration string into milliseconds.\n *\n * Supported formats: `7d`, `24h`, `30m`, `1d`, `14d`, `168h`, etc.\n * Used by `cleo transcript prune --older-than <duration>`.\n *\n * @param duration - Duration string (e.g. `\"7d\"`, `\"24h\"`, `\"30m\"`)\n * @returns Duration in milliseconds\n * @throws Error if the format is not recognized\n */\nexport function parseDurationMs(duration: string): number {\n const match = /^(\\d+(\\.\\d+)?)(d|h|m|s)$/.exec(duration.trim());\n if (!match?.[1] || !match[3]) {\n throw new Error(`Invalid duration format: \"${duration}\". Use format like 7d, 24h, 30m, 60s.`);\n }\n const value = parseFloat(match[1]);\n const unit = match[3];\n const multipliers: Record<string, number> = {\n d: 24 * 60 * 60 * 1000,\n h: 60 * 60 * 1000,\n m: 60 * 1000,\n s: 1000,\n };\n return value * (multipliers[unit] ?? 1000);\n}\n", "/**\n * GC Runner \u2014 Core garbage collection logic for autonomous transcript cleanup.\n *\n * Performs disk-pressure-aware pruning of ephemeral transcript and temp files\n * under `~/.claude/projects/` using the five-tier threshold model from T751.\n *\n * Retention policy (per ADR-047 and docs/specs/memory-architecture-spec.md \u00A78):\n * - `.temp/` files: 24h normal, 1h emergency\n * - Transcript directories (agent-*.jsonl, tool-results/): 7d normal, 1d emergency\n * - `.cleo/logs/`: 30d normal, 7d emergency\n * - `.cleo/agent-outputs/*.md` (committed artifacts): NEVER auto-pruned\n *\n * Circuit breaker: if `ANTHROPIC_API_KEY` is absent AND no local model configured,\n * skip extraction and only delete transcripts older than 30 days.\n *\n * @see ADR-047 \u2014 Autonomous GC and Disk Safety\n * @see docs/specs/memory-architecture-spec.md \u00A78\n * @task T731\n * @epic T726\n */\n\nimport { lstat, readdir, rm, stat } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\nimport checkDiskSpaceModule from 'check-disk-space';\n\n/**\n * Checks free + total bytes on the filesystem containing the given path.\n *\n * `check-disk-space@3.4.0` publishes its function as `export { x as default }`\n * in the .d.ts, which TS 6.0 strict resolution treats as a namespaced re-export\n * rather than a callable default. The runtime module itself exposes a callable;\n * we bridge the type gap by typing `checkDiskSpaceModule` as the callable\n * shape at the single import boundary.\n */\nconst checkDiskSpace = checkDiskSpaceModule as unknown as (path: string) => Promise<{\n diskPath: string;\n free: number;\n size: number;\n}>;\n\nimport { patchGCState, readGCState } from './state.js';\n\n// ---------------------------------------------------------------------------\n// Threshold Tiers (from T751 \u00A73.2 and ADR-047)\n// ---------------------------------------------------------------------------\n\n/**\n * Disk usage percentage thresholds.\n *\n * Values mirror the five-tier model recommended by T751 research \u00A73.2:\n * - OK: < 70% \u2014 routine cleanup by age policy only\n * - WATCH: 70-85% \u2014 log + schedule next GC sooner\n * - WARN: 85-90% \u2014 log + set escalation flag for next CLI invocation\n * - URGENT: 90-95% \u2014 auto-prune oldest transcripts immediately\n * - EMERGENCY: \u2265 95% \u2014 auto-prune all transcripts > 1d, pause new writes\n */\nexport const DISK_THRESHOLDS = {\n WATCH: 70,\n WARN: 85,\n URGENT: 90,\n EMERGENCY: 95,\n} as const;\n\n/** Human-readable tier labels. */\nexport type DiskTier = 'ok' | 'watch' | 'warn' | 'urgent' | 'emergency';\n\n/**\n * Result of a single GC run.\n */\nexport interface GCResult {\n /** Disk usage percentage at time of GC run (0\u2013100). */\n diskUsedPct: number;\n /** Disk tier classification. */\n threshold: DiskTier;\n /** Files pruned during this run. */\n pruned: Array<{ path: string; bytes: number }>;\n /** Total bytes freed. */\n bytesFreed: number;\n /** Whether escalation flag was set (disk \u2265 WARN). */\n escalationSet: boolean;\n /** Human-readable escalation reason (set when escalationSet=true). */\n escalationReason: string | null;\n /** ISO-8601 timestamp of run completion. */\n completedAt: string;\n}\n\n/**\n * Options for a GC run.\n */\nexport interface GCRunOptions {\n /**\n * Absolute path to the `.cleo/` directory (used for state file and disk check).\n * Defaults to `~/.cleo`.\n */\n cleoDir?: string;\n /**\n * Override the default `~/.claude/projects/` scan directory.\n * Primarily used in tests to point at a temp directory.\n */\n projectsDir?: string;\n /**\n * Paths from a previous crashed run to resume deletion from.\n * Written to `pendingPrune` in gc-state.json BEFORE starting deletion.\n */\n resumeFrom?: string[];\n /**\n * Dry-run mode: compute what would be pruned, but make zero filesystem changes.\n */\n dryRun?: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Classify a disk usage percentage into a tier.\n *\n * @param pct - Disk usage percentage (0\u2013100)\n * @returns DiskTier\n */\nexport function classifyDiskTier(pct: number): DiskTier {\n if (pct >= DISK_THRESHOLDS.EMERGENCY) return 'emergency';\n if (pct >= DISK_THRESHOLDS.URGENT) return 'urgent';\n if (pct >= DISK_THRESHOLDS.WARN) return 'warn';\n if (pct >= DISK_THRESHOLDS.WATCH) return 'watch';\n return 'ok';\n}\n\n/**\n * Compute retention threshold in milliseconds based on disk tier.\n *\n * Higher disk pressure \u2192 shorter retention \u2192 more aggressive pruning.\n *\n * @param tier - Current disk tier\n * @returns Maximum age in milliseconds for transcript retention\n */\nexport function retentionMs(tier: DiskTier): number {\n switch (tier) {\n case 'emergency':\n return 1 * 24 * 60 * 60 * 1000; // 1 day\n case 'urgent':\n return 3 * 24 * 60 * 60 * 1000; // 3 days\n case 'warn':\n return 7 * 24 * 60 * 60 * 1000; // 7 days\n default:\n return 30 * 24 * 60 * 60 * 1000; // 30 days (watch + ok)\n }\n}\n\n/**\n * Get the size of a path in bytes (file or directory recursively).\n * Returns 0 if the path does not exist.\n *\n * @param targetPath - Path to measure\n * @returns Size in bytes\n */\nexport async function getPathBytes(targetPath: string): Promise<number> {\n try {\n const info = await lstat(targetPath);\n if (info.isFile()) return info.size;\n if (!info.isDirectory()) return 0;\n\n const entries = await readdir(targetPath, { withFileTypes: true });\n let total = 0;\n for (const entry of entries) {\n total += await getPathBytes(join(targetPath, entry.name));\n }\n return total;\n } catch {\n return 0;\n }\n}\n\n/**\n * Idempotently delete a path (file or directory).\n *\n * Silently ignores ENOENT \u2014 safe to call if path was already deleted.\n * Uses `force: true` to suppress errors on missing paths.\n *\n * @param targetPath - Path to delete\n */\nexport async function idempotentRm(targetPath: string): Promise<void> {\n try {\n await rm(targetPath, { recursive: true, force: true });\n } catch (err) {\n const nodeErr = err as NodeJS.ErrnoException;\n if (nodeErr.code === 'ENOENT') return; // already gone \u2014 idempotent\n throw err;\n }\n}\n\n/**\n * Gather transcript session directories under `~/.claude/projects/` that are\n * older than `maxAgeMs`.\n *\n * Only session UUID directories are candidates (not the root JSONL files \u2014\n * those are the main transcript). The `tool-results/` subdirectory within a\n * session directory is always included in the prune candidate once the session\n * is old enough.\n *\n * Committed artifact files (`.cleo/agent-outputs/*.md`) are NEVER included.\n *\n * @param maxAgeMs - Maximum age in ms; sessions older than this are candidates\n * @returns Array of absolute directory paths eligible for pruning\n */\nasync function gatherPruneCandidates(maxAgeMs: number, projectsDir?: string): Promise<string[]> {\n const resolvedProjectsDir = projectsDir ?? join(homedir(), '.claude', 'projects');\n const candidates: string[] = [];\n const now = Date.now();\n\n let projectSlugs: string[];\n try {\n const entries = await readdir(resolvedProjectsDir, { withFileTypes: true });\n projectSlugs = entries.filter((e) => e.isDirectory()).map((e) => e.name);\n } catch {\n // ~/.claude/projects/ doesn't exist yet\n return candidates;\n }\n\n for (const slug of projectSlugs) {\n const slugDir = join(resolvedProjectsDir, slug);\n\n // Collect root JSONL files (HOT/WARM main session transcripts)\n let slugEntries: import('fs').Dirent[];\n try {\n slugEntries = await readdir(slugDir, { withFileTypes: true });\n } catch {\n continue;\n }\n\n for (const entry of slugEntries) {\n const entryPath = join(slugDir, entry.name);\n\n if (entry.isFile() && entry.name.endsWith('.jsonl')) {\n // Root-level session JSONL \u2014 check age\n try {\n const info = await stat(entryPath);\n const ageMs = now - info.mtimeMs;\n if (ageMs > maxAgeMs) {\n candidates.push(entryPath);\n }\n } catch {\n // File disappeared between readdir and stat \u2014 skip\n }\n } else if (entry.isDirectory()) {\n // Session UUID directory \u2014 check mtime of the directory itself\n try {\n const info = await stat(entryPath);\n const ageMs = now - info.mtimeMs;\n if (ageMs > maxAgeMs) {\n candidates.push(entryPath);\n }\n } catch {\n // Directory disappeared \u2014 skip\n }\n }\n }\n }\n\n return candidates;\n}\n\n// ---------------------------------------------------------------------------\n// Main GC Runner\n// ---------------------------------------------------------------------------\n\n/**\n * Execute a GC run: check disk pressure, determine retention threshold,\n * prune eligible transcript files, update gc-state.json.\n *\n * This function is idempotent and safe to call multiple times. Crash recovery\n * is implemented via the `pendingPrune` field in gc-state.json:\n * 1. Write paths to `pendingPrune` BEFORE starting deletion\n * 2. Remove each path from `pendingPrune` AFTER successful deletion\n * 3. Clear `pendingPrune` when the job completes\n *\n * @param opts - GC run options\n * @returns GC run results\n */\nexport async function runGC(opts: GCRunOptions = {}): Promise<GCResult> {\n const cleoDir = opts.cleoDir ?? join(homedir(), '.cleo');\n const statePath = join(cleoDir, 'gc-state.json');\n const dryRun = opts.dryRun ?? false;\n const projectsDir = opts.projectsDir;\n\n // Step 1: Crash recovery \u2014 resume any pending prune from prior run\n const initialState = await readGCState(statePath);\n const resumePaths = opts.resumeFrom ?? initialState.pendingPrune ?? [];\n\n // Step 2: Check disk space on the filesystem containing .cleo/\n let diskUsedPct = 0;\n try {\n const { free, size } = await checkDiskSpace(cleoDir);\n diskUsedPct = size > 0 ? ((size - free) / size) * 100 : 0;\n } catch {\n // Disk check failure is non-fatal; proceed with default tier\n diskUsedPct = 0;\n }\n\n const tier = classifyDiskTier(diskUsedPct);\n const maxAgeMs = retentionMs(tier);\n\n // Step 3: Gather prune candidates\n const candidatesFromScan =\n resumePaths.length > 0 ? resumePaths : await gatherPruneCandidates(maxAgeMs, projectsDir);\n\n // Step 4: Write pendingPrune to state BEFORE any deletion (crash-safe)\n if (!dryRun && candidatesFromScan.length > 0) {\n await patchGCState(statePath, { pendingPrune: candidatesFromScan });\n }\n\n // Step 5: Delete candidates and accumulate results\n const pruned: GCResult['pruned'] = [];\n let bytesFreed = 0;\n const remaining = [...candidatesFromScan];\n\n for (const candidatePath of candidatesFromScan) {\n const bytes = await getPathBytes(candidatePath);\n\n if (dryRun) {\n // Dry run: record what would be deleted, make no changes\n pruned.push({ path: candidatePath, bytes });\n bytesFreed += bytes;\n continue;\n }\n\n try {\n await idempotentRm(candidatePath);\n pruned.push({ path: candidatePath, bytes });\n bytesFreed += bytes;\n // Remove successfully-deleted path from the pending list\n const idx = remaining.indexOf(candidatePath);\n if (idx !== -1) remaining.splice(idx, 1);\n // Persist updated pendingPrune after each deletion (crash-safe)\n await patchGCState(statePath, {\n pendingPrune: remaining.length > 0 ? remaining : null,\n });\n } catch {\n // Deletion failure: leave in pendingPrune for next run\n }\n }\n\n // Step 6: Determine escalation state\n const escalationSet = tier === 'warn' || tier === 'urgent' || tier === 'emergency';\n let escalationReason: string | null = null;\n if (escalationSet) {\n escalationReason = `Disk at ${diskUsedPct.toFixed(1)}% (${tier.toUpperCase()}): ${pruned.length} paths pruned, ${bytesFreed} bytes freed`;\n }\n\n const completedAt = new Date().toISOString();\n\n // Step 7: Update gc-state.json with run results\n if (!dryRun) {\n await patchGCState(statePath, {\n lastRunAt: completedAt,\n lastRunResult: remaining.length === 0 ? 'success' : 'partial',\n lastRunBytesFreed: bytesFreed,\n pendingPrune: remaining.length > 0 ? remaining : null,\n consecutiveFailures: remaining.length > 0 ? initialState.consecutiveFailures + 1 : 0,\n diskThresholdBreached: diskUsedPct >= DISK_THRESHOLDS.WATCH,\n lastDiskUsedPct: diskUsedPct,\n escalationNeeded: escalationSet || initialState.escalationNeeded,\n escalationReason: escalationReason ?? initialState.escalationReason,\n });\n }\n\n return {\n diskUsedPct,\n threshold: tier,\n pruned,\n bytesFreed,\n escalationSet,\n escalationReason,\n completedAt,\n };\n}\n"],
|
|
5
|
+
"mappings": ";AA0BA,SAAS,SAAAA,QAAO,WAAAC,UAAS,QAAAC,aAAY;AACrC,SAAS,eAAe;AACxB,SAAS,QAAAC,aAAY;;;ACPrB,SAAS,OAAO,SAAS,IAAI,YAAY;AAEzC,SAAS,YAAY;AAuIrB,eAAsB,aAAa,YAAqC;AACtE,MAAI;AACF,UAAM,OAAO,MAAM,MAAM,UAAU;AACnC,QAAI,KAAK,OAAO,EAAG,QAAO,KAAK;AAC/B,QAAI,CAAC,KAAK,YAAY,EAAG,QAAO;AAEhC,UAAM,UAAU,MAAM,QAAQ,YAAY,EAAE,eAAe,KAAK,CAAC;AACjE,QAAI,QAAQ;AACZ,eAAW,SAAS,SAAS;AAC3B,eAAS,MAAM,aAAa,KAAK,YAAY,MAAM,IAAI,CAAC;AAAA,IAC1D;AACA,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAUA,eAAsB,aAAa,YAAmC;AACpE,MAAI;AACF,UAAM,GAAG,YAAY,EAAE,WAAW,MAAM,OAAO,KAAK,CAAC;AAAA,EACvD,SAAS,KAAK;AACZ,UAAM,UAAU;AAChB,QAAI,QAAQ,SAAS,SAAU;AAC/B,UAAM;AAAA,EACR;AACF;;;AD3JA,IAAM,aAAa,KAAK,KAAK,KAAK;AAGlC,IAAM,cAAc,IAAI,KAAK,KAAK,KAAK;AA4EhC,SAAS,uBAAuB,OAA+B;AACpE,MAAI,QAAQ,WAAY,QAAO;AAC/B,MAAI,QAAQ,YAAa,QAAO;AAChC,SAAO;AACT;AAWA,SAAS,eAAe,UAA0B;AAChD,SAAO,SAAS,QAAQ,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