@remnic/core 9.3.552 → 9.3.554
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/access-cli.js +4 -4
- package/dist/{chunk-MGVIEM2O.js → chunk-2IT7WFYE.js} +2 -2
- package/dist/{chunk-XEKAG3FM.js → chunk-452WDNFO.js} +2 -2
- package/dist/{chunk-2NM43EWN.js → chunk-D6RIFG4O.js} +2 -2
- package/dist/{chunk-GEL3F3RV.js → chunk-I2K6KCVC.js} +6 -6
- package/dist/{chunk-Y4YATXHL.js → chunk-ILJXM3FV.js} +2 -2
- package/dist/{chunk-RUZOJKNF.js → chunk-JCK7V6SN.js} +2 -2
- package/dist/{chunk-XR6DNK4U.js → chunk-LZZNTPLR.js} +2 -2
- package/dist/{chunk-M3BAMVAE.js → chunk-O4M4WH6V.js} +2 -2
- package/dist/{chunk-NYV435HC.js → chunk-RLPIT4YI.js} +3 -3
- package/dist/{chunk-4426WSWL.js → chunk-SFQ6QNL7.js} +6 -2
- package/dist/chunk-SFQ6QNL7.js.map +1 -0
- package/dist/{chunk-S7WU3Y3D.js → chunk-WMWVO45V.js} +15 -3
- package/dist/chunk-WMWVO45V.js.map +1 -0
- package/dist/cli.js +8 -8
- package/dist/index.js +11 -11
- package/dist/maintenance/archive-observations.d.ts +2 -0
- package/dist/maintenance/archive-observations.js +2 -1
- package/dist/maintenance/migrate-observations.js +3 -3
- package/dist/maintenance/observation-ledger-utils.d.ts +1 -1
- package/dist/maintenance/observation-ledger-utils.js +2 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +2 -2
- package/dist/maintenance/rebuild-memory-projection.js +2 -2
- package/dist/maintenance/rebuild-observations.js +3 -3
- package/dist/orchestrator.js +4 -4
- package/dist/recall-state.js +2 -2
- package/dist/relevance.js +2 -2
- package/dist/schemas.d.ts +22 -22
- package/dist/transfer/types.d.ts +12 -12
- package/package.json +1 -1
- package/src/maintenance/archive-observations.ts +15 -2
- package/src/maintenance/atomic-file.ts +6 -2
- package/dist/chunk-4426WSWL.js.map +0 -1
- package/dist/chunk-S7WU3Y3D.js.map +0 -1
- /package/dist/{chunk-MGVIEM2O.js.map → chunk-2IT7WFYE.js.map} +0 -0
- /package/dist/{chunk-XEKAG3FM.js.map → chunk-452WDNFO.js.map} +0 -0
- /package/dist/{chunk-2NM43EWN.js.map → chunk-D6RIFG4O.js.map} +0 -0
- /package/dist/{chunk-GEL3F3RV.js.map → chunk-I2K6KCVC.js.map} +0 -0
- /package/dist/{chunk-Y4YATXHL.js.map → chunk-ILJXM3FV.js.map} +0 -0
- /package/dist/{chunk-RUZOJKNF.js.map → chunk-JCK7V6SN.js.map} +0 -0
- /package/dist/{chunk-XR6DNK4U.js.map → chunk-LZZNTPLR.js.map} +0 -0
- /package/dist/{chunk-M3BAMVAE.js.map → chunk-O4M4WH6V.js.map} +0 -0
- /package/dist/{chunk-NYV435HC.js.map → chunk-RLPIT4YI.js.map} +0 -0
package/dist/access-cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Orchestrator
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-RLPIT4YI.js";
|
|
4
4
|
import "./chunk-5RIRL3XL.js";
|
|
5
5
|
import "./chunk-BFBF3XEF.js";
|
|
6
6
|
import "./chunk-KVEVLBKC.js";
|
|
@@ -32,12 +32,12 @@ import "./chunk-USYGGIJZ.js";
|
|
|
32
32
|
import "./chunk-V3RXWQIE.js";
|
|
33
33
|
import "./chunk-5IZL4DCV.js";
|
|
34
34
|
import "./chunk-X7XN6YU4.js";
|
|
35
|
-
import "./chunk-
|
|
35
|
+
import "./chunk-452WDNFO.js";
|
|
36
36
|
import "./chunk-TDKQGLJW.js";
|
|
37
37
|
import "./chunk-OZKZ2TRP.js";
|
|
38
38
|
import "./chunk-YDBIWGNI.js";
|
|
39
39
|
import "./chunk-7DHTMOND.js";
|
|
40
|
-
import "./chunk-
|
|
40
|
+
import "./chunk-2IT7WFYE.js";
|
|
41
41
|
import "./chunk-YCN4BVDK.js";
|
|
42
42
|
import "./chunk-ZZTOURJI.js";
|
|
43
43
|
import "./chunk-XKXKSQU7.js";
|
|
@@ -81,7 +81,7 @@ import "./chunk-FADZBOR4.js";
|
|
|
81
81
|
import "./chunk-XPXEJRUB.js";
|
|
82
82
|
import "./chunk-A6D7A2FW.js";
|
|
83
83
|
import "./chunk-FF4KLI5W.js";
|
|
84
|
-
import "./chunk-
|
|
84
|
+
import "./chunk-SFQ6QNL7.js";
|
|
85
85
|
import "./chunk-A2Z6UCWT.js";
|
|
86
86
|
import "./chunk-KXULCVOC.js";
|
|
87
87
|
import "./chunk-SML26KED.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
writeFileAtomically
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SFQ6QNL7.js";
|
|
4
4
|
import {
|
|
5
5
|
log
|
|
6
6
|
} from "./chunk-2ODBA7MQ.js";
|
|
@@ -257,4 +257,4 @@ export {
|
|
|
257
257
|
LastRecallStore,
|
|
258
258
|
TierMigrationStatusStore
|
|
259
259
|
};
|
|
260
|
-
//# sourceMappingURL=chunk-
|
|
260
|
+
//# sourceMappingURL=chunk-2IT7WFYE.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
writeFileAtomically
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SFQ6QNL7.js";
|
|
4
4
|
import {
|
|
5
5
|
log
|
|
6
6
|
} from "./chunk-2ODBA7MQ.js";
|
|
@@ -75,4 +75,4 @@ var RelevanceStore = class {
|
|
|
75
75
|
export {
|
|
76
76
|
RelevanceStore
|
|
77
77
|
};
|
|
78
|
-
//# sourceMappingURL=chunk-
|
|
78
|
+
//# sourceMappingURL=chunk-452WDNFO.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
backupAndWriteRebuiltObservations,
|
|
3
3
|
toHourBucketIso
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-JCK7V6SN.js";
|
|
5
5
|
|
|
6
6
|
// src/maintenance/migrate-observations.ts
|
|
7
7
|
import path from "path";
|
|
@@ -156,4 +156,4 @@ async function migrateObservations(options) {
|
|
|
156
156
|
export {
|
|
157
157
|
migrateObservations
|
|
158
158
|
};
|
|
159
|
-
//# sourceMappingURL=chunk-
|
|
159
|
+
//# sourceMappingURL=chunk-D6RIFG4O.js.map
|
|
@@ -44,21 +44,21 @@ import {
|
|
|
44
44
|
} from "./chunk-HOJZMQ4J.js";
|
|
45
45
|
import {
|
|
46
46
|
migrateObservations
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-D6RIFG4O.js";
|
|
48
48
|
import {
|
|
49
49
|
rebuildMemoryLifecycleLedger
|
|
50
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-O4M4WH6V.js";
|
|
51
51
|
import {
|
|
52
52
|
rebuildMemoryProjection,
|
|
53
53
|
repairMemoryProjection,
|
|
54
54
|
verifyMemoryProjection
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-ILJXM3FV.js";
|
|
56
56
|
import {
|
|
57
57
|
rebuildObservations
|
|
58
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-LZZNTPLR.js";
|
|
59
59
|
import {
|
|
60
60
|
archiveObservations
|
|
61
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-WMWVO45V.js";
|
|
62
62
|
import {
|
|
63
63
|
getBulkImportSource,
|
|
64
64
|
listBulkImportSources,
|
|
@@ -6616,4 +6616,4 @@ export {
|
|
|
6616
6616
|
resolveMemoryDirForNamespace,
|
|
6617
6617
|
registerCli
|
|
6618
6618
|
};
|
|
6619
|
-
//# sourceMappingURL=chunk-
|
|
6619
|
+
//# sourceMappingURL=chunk-I2K6KCVC.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-KJTKLXTH.js";
|
|
4
4
|
import {
|
|
5
5
|
commitPreparedFileAtomically
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-SFQ6QNL7.js";
|
|
7
7
|
import {
|
|
8
8
|
loadPersistedNativeKnowledgeChunks
|
|
9
9
|
} from "./chunk-BEUDU7Y4.js";
|
|
@@ -929,4 +929,4 @@ export {
|
|
|
929
929
|
verifyMemoryProjection,
|
|
930
930
|
repairMemoryProjection
|
|
931
931
|
};
|
|
932
|
-
//# sourceMappingURL=chunk-
|
|
932
|
+
//# sourceMappingURL=chunk-ILJXM3FV.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
writeFileAtomically
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SFQ6QNL7.js";
|
|
4
4
|
|
|
5
5
|
// src/maintenance/observation-ledger-utils.ts
|
|
6
6
|
import path from "path";
|
|
@@ -50,4 +50,4 @@ export {
|
|
|
50
50
|
toHourBucketIso,
|
|
51
51
|
backupAndWriteRebuiltObservations
|
|
52
52
|
};
|
|
53
|
-
//# sourceMappingURL=chunk-
|
|
53
|
+
//# sourceMappingURL=chunk-JCK7V6SN.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
backupAndWriteRebuiltObservations,
|
|
3
3
|
toHourBucketIso
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-JCK7V6SN.js";
|
|
5
5
|
|
|
6
6
|
// src/maintenance/rebuild-observations.ts
|
|
7
7
|
import path from "path";
|
|
@@ -124,4 +124,4 @@ async function rebuildObservations(options) {
|
|
|
124
124
|
export {
|
|
125
125
|
rebuildObservations
|
|
126
126
|
};
|
|
127
|
-
//# sourceMappingURL=chunk-
|
|
127
|
+
//# sourceMappingURL=chunk-LZZNTPLR.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-KJTKLXTH.js";
|
|
4
4
|
import {
|
|
5
5
|
writeFileAtomically
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-SFQ6QNL7.js";
|
|
7
7
|
import {
|
|
8
8
|
StorageManager
|
|
9
9
|
} from "./chunk-TVZ6LKKS.js";
|
|
@@ -74,4 +74,4 @@ export {
|
|
|
74
74
|
backupExistingLedger,
|
|
75
75
|
rebuildMemoryLifecycleLedger
|
|
76
76
|
};
|
|
77
|
-
//# sourceMappingURL=chunk-
|
|
77
|
+
//# sourceMappingURL=chunk-O4M4WH6V.js.map
|
|
@@ -87,7 +87,7 @@ import {
|
|
|
87
87
|
} from "./chunk-X7XN6YU4.js";
|
|
88
88
|
import {
|
|
89
89
|
RelevanceStore
|
|
90
|
-
} from "./chunk-
|
|
90
|
+
} from "./chunk-452WDNFO.js";
|
|
91
91
|
import {
|
|
92
92
|
RerankCache,
|
|
93
93
|
rerankLocalOrNoop
|
|
@@ -106,7 +106,7 @@ import {
|
|
|
106
106
|
LastRecallStore,
|
|
107
107
|
TierMigrationStatusStore,
|
|
108
108
|
clampGraphRecallExpandedEntries
|
|
109
|
-
} from "./chunk-
|
|
109
|
+
} from "./chunk-2IT7WFYE.js";
|
|
110
110
|
import {
|
|
111
111
|
buildQmdRecallCacheKey,
|
|
112
112
|
getCachedQmdRecall,
|
|
@@ -12405,4 +12405,4 @@ export {
|
|
|
12405
12405
|
resolvePersistedMemoryRelativePath,
|
|
12406
12406
|
Orchestrator
|
|
12407
12407
|
};
|
|
12408
|
-
//# sourceMappingURL=chunk-
|
|
12408
|
+
//# sourceMappingURL=chunk-RLPIT4YI.js.map
|
|
@@ -34,7 +34,11 @@ async function writeFileAtomically(outputPath, content, backupPath) {
|
|
|
34
34
|
let resolvedBackupPath;
|
|
35
35
|
try {
|
|
36
36
|
handle = await open(tempPath, "w");
|
|
37
|
-
|
|
37
|
+
if (typeof content === "string") {
|
|
38
|
+
await handle.writeFile(content, "utf-8");
|
|
39
|
+
} else {
|
|
40
|
+
await handle.writeFile(content);
|
|
41
|
+
}
|
|
38
42
|
await handle.sync();
|
|
39
43
|
await handle.close();
|
|
40
44
|
handle = void 0;
|
|
@@ -70,4 +74,4 @@ export {
|
|
|
70
74
|
writeFileAtomically,
|
|
71
75
|
commitPreparedFileAtomically
|
|
72
76
|
};
|
|
73
|
-
//# sourceMappingURL=chunk-
|
|
77
|
+
//# sourceMappingURL=chunk-SFQ6QNL7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/maintenance/atomic-file.ts"],"sourcesContent":["import path from \"node:path\";\nimport { copyFile, mkdir, open, rename, rm, stat } from \"node:fs/promises\";\n\nasync function syncDirectory(dir: string): Promise<void> {\n let handle: Awaited<ReturnType<typeof open>> | undefined;\n try {\n handle = await open(dir, \"r\");\n await handle.sync();\n } catch {\n // Directory fsync is best-effort across platforms and filesystems.\n } finally {\n await handle?.close().catch(() => undefined);\n }\n}\n\nfunction tempPathFor(outputPath: string): string {\n const suffix = `${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}`;\n return path.join(path.dirname(outputPath), `.${path.basename(outputPath)}.${suffix}.tmp`);\n}\n\nexport async function copyExistingFileToBackup(\n sourcePath: string,\n backupPath: string,\n): Promise<string | undefined> {\n try {\n await stat(sourcePath);\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === \"ENOENT\") return undefined;\n throw err;\n }\n\n await mkdir(path.dirname(backupPath), { recursive: true });\n await copyFile(sourcePath, backupPath);\n return backupPath;\n}\n\nexport async function writeFileAtomically(\n outputPath: string,\n content: string | Uint8Array,\n backupPath?: string,\n): Promise<string | undefined> {\n const dir = path.dirname(outputPath);\n await mkdir(dir, { recursive: true });\n const tempPath = tempPathFor(outputPath);\n let handle: Awaited<ReturnType<typeof open>> | undefined;\n let resolvedBackupPath: string | undefined;\n try {\n handle = await open(tempPath, \"w\");\n if (typeof content === \"string\") {\n await handle.writeFile(content, \"utf-8\");\n } else {\n await handle.writeFile(content);\n }\n await handle.sync();\n await handle.close();\n handle = undefined;\n\n if (backupPath) {\n resolvedBackupPath = await copyExistingFileToBackup(outputPath, backupPath);\n }\n await rename(tempPath, outputPath);\n await syncDirectory(dir);\n return resolvedBackupPath;\n } catch (err) {\n await handle?.close().catch(() => undefined);\n await rm(tempPath, { force: true }).catch(() => undefined);\n throw err;\n }\n}\n\nexport async function commitPreparedFileAtomically(\n tempPath: string,\n outputPath: string,\n backupPath?: string,\n): Promise<string | undefined> {\n const dir = path.dirname(outputPath);\n let resolvedBackupPath: string | undefined;\n try {\n if (backupPath) {\n resolvedBackupPath = await copyExistingFileToBackup(outputPath, backupPath);\n }\n await rename(tempPath, outputPath);\n await syncDirectory(dir);\n return resolvedBackupPath;\n } catch (err) {\n await rm(tempPath, { force: true }).catch(() => undefined);\n throw err;\n }\n}\n"],"mappings":";AAAA,OAAO,UAAU;AACjB,SAAS,UAAU,OAAO,MAAM,QAAQ,IAAI,YAAY;AAExD,eAAe,cAAc,KAA4B;AACvD,MAAI;AACJ,MAAI;AACF,aAAS,MAAM,KAAK,KAAK,GAAG;AAC5B,UAAM,OAAO,KAAK;AAAA,EACpB,QAAQ;AAAA,EAER,UAAE;AACA,UAAM,QAAQ,MAAM,EAAE,MAAM,MAAM,MAAS;AAAA,EAC7C;AACF;AAEA,SAAS,YAAY,YAA4B;AAC/C,QAAM,SAAS,GAAG,QAAQ,GAAG,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC;AAClF,SAAO,KAAK,KAAK,KAAK,QAAQ,UAAU,GAAG,IAAI,KAAK,SAAS,UAAU,CAAC,IAAI,MAAM,MAAM;AAC1F;AAEA,eAAsB,yBACpB,YACA,YAC6B;AAC7B,MAAI;AACF,UAAM,KAAK,UAAU;AAAA,EACvB,SAAS,KAAK;AACZ,QAAK,IAA8B,SAAS,SAAU,QAAO;AAC7D,UAAM;AAAA,EACR;AAEA,QAAM,MAAM,KAAK,QAAQ,UAAU,GAAG,EAAE,WAA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SFQ6QNL7.js";
|
|
4
|
+
|
|
1
5
|
// src/maintenance/archive-observations.ts
|
|
2
6
|
import path from "path";
|
|
3
|
-
import { lstat, mkdir, readdir, readFile, realpath, unlink
|
|
7
|
+
import { lstat, mkdir, readdir, readFile, realpath, unlink } from "fs/promises";
|
|
4
8
|
var DATE_FILE_PATTERN = /^(\d{4})-(\d{2})-(\d{2})\.(jsonl|md)$/;
|
|
5
9
|
function normalizeRetentionDays(value) {
|
|
6
10
|
if (!Number.isFinite(value)) return 30;
|
|
@@ -17,6 +21,9 @@ function extractDateFromFilename(name) {
|
|
|
17
21
|
function startOfUtcDay(value) {
|
|
18
22
|
return Date.UTC(value.getUTCFullYear(), value.getUTCMonth(), value.getUTCDate());
|
|
19
23
|
}
|
|
24
|
+
async function writeArchiveFileAtomically(archivePath, content) {
|
|
25
|
+
await writeFileAtomically(archivePath, content);
|
|
26
|
+
}
|
|
20
27
|
async function listFilesRecursive(root, relPrefix = "") {
|
|
21
28
|
const out = [];
|
|
22
29
|
let entries;
|
|
@@ -80,6 +87,7 @@ async function archiveObservations(options) {
|
|
|
80
87
|
);
|
|
81
88
|
const stamp = now.toISOString().replace(/[-:]/g, "").replace(/\.\d{3}Z$/, "Z");
|
|
82
89
|
const archiveRoot = path.join(options.memoryDir, "archive", "observations", stamp);
|
|
90
|
+
const archiveFileWriter = options.archiveFileWriter ?? writeArchiveFileAtomically;
|
|
83
91
|
const candidates = retentionDays === 0 ? [] : await collectArchiveCandidates(
|
|
84
92
|
options.memoryDir,
|
|
85
93
|
cutoffDayStartUtc
|
|
@@ -96,7 +104,11 @@ async function archiveObservations(options) {
|
|
|
96
104
|
const candidateInfo = await lstat(candidate.absolutePath).catch(() => null);
|
|
97
105
|
if (!candidateInfo?.isFile() || candidateInfo.isSymbolicLink()) continue;
|
|
98
106
|
const raw = await readFile(candidate.absolutePath);
|
|
99
|
-
await
|
|
107
|
+
await archiveFileWriter(archivePath, raw);
|
|
108
|
+
const archivedRaw = await readFile(archivePath);
|
|
109
|
+
if (!archivedRaw.equals(raw)) {
|
|
110
|
+
throw new Error(`Archive copy verification failed for ${candidate.relativePath}`);
|
|
111
|
+
}
|
|
100
112
|
await unlink(candidate.absolutePath);
|
|
101
113
|
archivedFiles += 1;
|
|
102
114
|
archivedBytes += raw.byteLength;
|
|
@@ -119,4 +131,4 @@ async function archiveObservations(options) {
|
|
|
119
131
|
export {
|
|
120
132
|
archiveObservations
|
|
121
133
|
};
|
|
122
|
-
//# sourceMappingURL=chunk-
|
|
134
|
+
//# sourceMappingURL=chunk-WMWVO45V.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/maintenance/archive-observations.ts"],"sourcesContent":["import path from \"node:path\";\nimport { lstat, mkdir, readdir, readFile, realpath, unlink } from \"node:fs/promises\";\nimport { writeFileAtomically } from \"./atomic-file.js\";\n\nconst DATE_FILE_PATTERN = /^(\\d{4})-(\\d{2})-(\\d{2})\\.(jsonl|md)$/;\n\ntype ArchiveFileWriter = (archivePath: string, content: Uint8Array) => Promise<void>;\n\nexport interface ArchiveObservationsOptions {\n memoryDir: string;\n retentionDays?: number;\n dryRun?: boolean;\n now?: Date;\n archiveFileWriter?: ArchiveFileWriter;\n}\n\nexport interface ArchiveObservationsResult {\n dryRun: boolean;\n retentionDays: number;\n scannedFiles: number;\n archivedFiles: number;\n archivedBytes: number;\n archiveRoot: string;\n archivedRelativePaths: string[];\n}\n\ninterface CandidateFile {\n absolutePath: string;\n relativePath: string;\n}\n\nfunction normalizeRetentionDays(value: number | undefined): number {\n if (!Number.isFinite(value as number)) return 30;\n return Math.max(0, Math.floor(value as number));\n}\n\nfunction extractDateFromFilename(name: string): Date | null {\n const match = DATE_FILE_PATTERN.exec(name);\n if (!match) return null;\n const iso = `${match[1]}-${match[2]}-${match[3]}T00:00:00.000Z`;\n const parsed = new Date(iso);\n if (Number.isNaN(parsed.getTime())) return null;\n return parsed;\n}\n\nfunction startOfUtcDay(value: Date): number {\n return Date.UTC(value.getUTCFullYear(), value.getUTCMonth(), value.getUTCDate());\n}\n\nasync function writeArchiveFileAtomically(archivePath: string, content: Uint8Array): Promise<void> {\n await writeFileAtomically(archivePath, content);\n}\n\nasync function listFilesRecursive(root: string, relPrefix = \"\"): Promise<string[]> {\n const out: string[] = [];\n let entries: Array<{ name: string; isDirectory(): boolean; isFile(): boolean }>;\n try {\n entries = (await readdir(root, { withFileTypes: true })) as Array<{\n name: string;\n isDirectory(): boolean;\n isFile(): boolean;\n }>;\n } catch {\n return out;\n }\n\n for (const entry of entries) {\n const rel = relPrefix ? path.join(relPrefix, entry.name) : entry.name;\n const full = path.join(root, entry.name);\n if (entry.isDirectory()) {\n out.push(...(await listFilesRecursive(full, rel)));\n continue;\n }\n if (entry.isFile()) out.push(rel);\n }\n\n return out;\n}\n\nasync function collectArchiveCandidates(\n memoryDir: string,\n cutoffTimeMs: number,\n): Promise<CandidateFile[]> {\n const roots = [\"transcripts\", path.join(\"state\", \"tool-usage\"), path.join(\"summaries\", \"hourly\")];\n const out: CandidateFile[] = [];\n const memoryRoot = path.resolve(memoryDir);\n const memoryRealRoot = await realpath(memoryRoot).catch(() => memoryRoot);\n\n for (const relRoot of roots) {\n const absRoot = path.resolve(memoryRoot, relRoot);\n const rootInfo = await lstat(absRoot).catch(() => null);\n if (!rootInfo?.isDirectory() || rootInfo.isSymbolicLink()) continue;\n const absRootReal = await realpath(absRoot).catch(() => null);\n if (absRootReal === null) continue;\n const rootRelative = path.relative(memoryRealRoot, absRootReal);\n if (rootRelative === \"..\" || rootRelative.startsWith(`..${path.sep}`) || path.isAbsolute(rootRelative)) {\n continue;\n }\n const files = await listFilesRecursive(absRoot);\n for (const fileRel of files) {\n const filename = path.basename(fileRel);\n const parsedDate = extractDateFromFilename(filename);\n if (!parsedDate) continue;\n if (parsedDate.getTime() >= cutoffTimeMs) continue;\n const absolutePath = path.resolve(absRoot, fileRel);\n const relativeToMemory = path.relative(memoryRoot, absolutePath);\n if (\n relativeToMemory === \"..\" ||\n relativeToMemory.startsWith(`..${path.sep}`) ||\n path.isAbsolute(relativeToMemory)\n ) {\n continue;\n }\n out.push({\n absolutePath,\n relativePath: path.join(relRoot, fileRel),\n });\n }\n }\n\n out.sort((a, b) => a.relativePath.localeCompare(b.relativePath));\n return out;\n}\n\nexport async function archiveObservations(\n options: ArchiveObservationsOptions,\n): Promise<ArchiveObservationsResult> {\n const retentionDays = normalizeRetentionDays(options.retentionDays);\n const dryRun = options.dryRun !== false;\n const now = options.now ?? new Date();\n const cutoffDayStartUtc = startOfUtcDay(\n new Date(now.getTime() - retentionDays * 24 * 60 * 60 * 1000),\n );\n const stamp = now.toISOString().replace(/[-:]/g, \"\").replace(/\\.\\d{3}Z$/, \"Z\");\n const archiveRoot = path.join(options.memoryDir, \"archive\", \"observations\", stamp);\n const archiveFileWriter = options.archiveFileWriter ?? writeArchiveFileAtomically;\n const candidates =\n retentionDays === 0\n ? []\n : await collectArchiveCandidates(\n options.memoryDir,\n cutoffDayStartUtc,\n );\n\n let archivedFiles = 0;\n let archivedBytes = 0;\n const archivedRelativePaths: string[] = [];\n\n if (!dryRun && candidates.length > 0) {\n await mkdir(archiveRoot, { recursive: true });\n for (const candidate of candidates) {\n const archivePath = path.join(archiveRoot, candidate.relativePath);\n const archiveDir = path.dirname(archivePath);\n await mkdir(archiveDir, { recursive: true });\n const candidateInfo = await lstat(candidate.absolutePath).catch(() => null);\n if (!candidateInfo?.isFile() || candidateInfo.isSymbolicLink()) continue;\n const raw = await readFile(candidate.absolutePath);\n await archiveFileWriter(archivePath, raw);\n const archivedRaw = await readFile(archivePath);\n if (!archivedRaw.equals(raw)) {\n throw new Error(`Archive copy verification failed for ${candidate.relativePath}`);\n }\n await unlink(candidate.absolutePath);\n archivedFiles += 1;\n archivedBytes += raw.byteLength;\n archivedRelativePaths.push(candidate.relativePath);\n }\n } else {\n archivedRelativePaths.push(...candidates.map((c) => c.relativePath));\n }\n\n return {\n dryRun,\n retentionDays,\n scannedFiles: candidates.length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,cAAM,IAAI,MAAM,wCAAwC,UAAU,YAAY,EAAE;AAAA,MAClF;AACA,YAAM,OAAO,UAAU,YAAY;AACnC,uBAAiB;AACjB,uBAAiB,IAAI;AACrB,4BAAsB,KAAK,UAAU,YAAY;AAAA,IACnD;AAAA,EACF,OAAO;AACL,0BAAsB,KAAK,GAAG,WAAW,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC;AAAA,EACrE;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,cAAc,WAAW;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
package/dist/cli.js
CHANGED
|
@@ -89,7 +89,7 @@ import {
|
|
|
89
89
|
runWorkProductStatusCliCommand,
|
|
90
90
|
runWorkProjectCliCommand,
|
|
91
91
|
runWorkTaskCliCommand
|
|
92
|
-
} from "./chunk-
|
|
92
|
+
} from "./chunk-I2K6KCVC.js";
|
|
93
93
|
import "./chunk-7F7Z6MOS.js";
|
|
94
94
|
import "./chunk-MC4FJXPA.js";
|
|
95
95
|
import "./chunk-LQHDIS7L.js";
|
|
@@ -107,12 +107,12 @@ import "./chunk-765K3SAT.js";
|
|
|
107
107
|
import "./chunk-TKWGAOLV.js";
|
|
108
108
|
import "./chunk-UWY7GIVS.js";
|
|
109
109
|
import "./chunk-HOJZMQ4J.js";
|
|
110
|
-
import "./chunk-
|
|
111
|
-
import "./chunk-
|
|
112
|
-
import "./chunk-
|
|
113
|
-
import "./chunk-
|
|
114
|
-
import "./chunk-
|
|
115
|
-
import "./chunk-
|
|
110
|
+
import "./chunk-D6RIFG4O.js";
|
|
111
|
+
import "./chunk-O4M4WH6V.js";
|
|
112
|
+
import "./chunk-ILJXM3FV.js";
|
|
113
|
+
import "./chunk-LZZNTPLR.js";
|
|
114
|
+
import "./chunk-JCK7V6SN.js";
|
|
115
|
+
import "./chunk-WMWVO45V.js";
|
|
116
116
|
import "./chunk-KJTKLXTH.js";
|
|
117
117
|
import "./chunk-H2NCNXMS.js";
|
|
118
118
|
import "./chunk-PU44GBL4.js";
|
|
@@ -141,7 +141,7 @@ import "./chunk-FADZBOR4.js";
|
|
|
141
141
|
import "./chunk-XPXEJRUB.js";
|
|
142
142
|
import "./chunk-A6D7A2FW.js";
|
|
143
143
|
import "./chunk-FF4KLI5W.js";
|
|
144
|
-
import "./chunk-
|
|
144
|
+
import "./chunk-SFQ6QNL7.js";
|
|
145
145
|
import "./chunk-A2Z6UCWT.js";
|
|
146
146
|
import "./chunk-KXULCVOC.js";
|
|
147
147
|
import "./chunk-SML26KED.js";
|
package/dist/index.js
CHANGED
|
@@ -93,7 +93,7 @@ import {
|
|
|
93
93
|
listTrainingExportAdapters,
|
|
94
94
|
registerTrainingExportAdapter,
|
|
95
95
|
runBulkImportCliCommand
|
|
96
|
-
} from "./chunk-
|
|
96
|
+
} from "./chunk-I2K6KCVC.js";
|
|
97
97
|
import "./chunk-7F7Z6MOS.js";
|
|
98
98
|
import "./chunk-MC4FJXPA.js";
|
|
99
99
|
import "./chunk-LQHDIS7L.js";
|
|
@@ -111,12 +111,12 @@ import "./chunk-765K3SAT.js";
|
|
|
111
111
|
import "./chunk-TKWGAOLV.js";
|
|
112
112
|
import "./chunk-UWY7GIVS.js";
|
|
113
113
|
import "./chunk-HOJZMQ4J.js";
|
|
114
|
-
import "./chunk-
|
|
115
|
-
import "./chunk-
|
|
116
|
-
import "./chunk-
|
|
117
|
-
import "./chunk-
|
|
118
|
-
import "./chunk-
|
|
119
|
-
import "./chunk-
|
|
114
|
+
import "./chunk-D6RIFG4O.js";
|
|
115
|
+
import "./chunk-O4M4WH6V.js";
|
|
116
|
+
import "./chunk-ILJXM3FV.js";
|
|
117
|
+
import "./chunk-LZZNTPLR.js";
|
|
118
|
+
import "./chunk-JCK7V6SN.js";
|
|
119
|
+
import "./chunk-WMWVO45V.js";
|
|
120
120
|
import "./chunk-KJTKLXTH.js";
|
|
121
121
|
import {
|
|
122
122
|
clearBulkImportSources,
|
|
@@ -182,7 +182,7 @@ import {
|
|
|
182
182
|
saveTaxonomy,
|
|
183
183
|
validateSlug,
|
|
184
184
|
validateTaxonomy
|
|
185
|
-
} from "./chunk-
|
|
185
|
+
} from "./chunk-RLPIT4YI.js";
|
|
186
186
|
import "./chunk-5RIRL3XL.js";
|
|
187
187
|
import "./chunk-BFBF3XEF.js";
|
|
188
188
|
import {
|
|
@@ -227,7 +227,7 @@ import "./chunk-USYGGIJZ.js";
|
|
|
227
227
|
import "./chunk-V3RXWQIE.js";
|
|
228
228
|
import "./chunk-5IZL4DCV.js";
|
|
229
229
|
import "./chunk-X7XN6YU4.js";
|
|
230
|
-
import "./chunk-
|
|
230
|
+
import "./chunk-452WDNFO.js";
|
|
231
231
|
import "./chunk-TDKQGLJW.js";
|
|
232
232
|
import {
|
|
233
233
|
buildResponseGuidanceRecallSection,
|
|
@@ -235,7 +235,7 @@ import {
|
|
|
235
235
|
} from "./chunk-OZKZ2TRP.js";
|
|
236
236
|
import "./chunk-YDBIWGNI.js";
|
|
237
237
|
import "./chunk-7DHTMOND.js";
|
|
238
|
-
import "./chunk-
|
|
238
|
+
import "./chunk-2IT7WFYE.js";
|
|
239
239
|
import "./chunk-YCN4BVDK.js";
|
|
240
240
|
import {
|
|
241
241
|
DEFAULT_REASONING_TRACE_BOOST,
|
|
@@ -360,7 +360,7 @@ import "./chunk-FADZBOR4.js";
|
|
|
360
360
|
import "./chunk-XPXEJRUB.js";
|
|
361
361
|
import "./chunk-A6D7A2FW.js";
|
|
362
362
|
import "./chunk-FF4KLI5W.js";
|
|
363
|
-
import "./chunk-
|
|
363
|
+
import "./chunk-SFQ6QNL7.js";
|
|
364
364
|
import "./chunk-A2Z6UCWT.js";
|
|
365
365
|
import "./chunk-KXULCVOC.js";
|
|
366
366
|
import "./chunk-SML26KED.js";
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
type ArchiveFileWriter = (archivePath: string, content: Uint8Array) => Promise<void>;
|
|
1
2
|
interface ArchiveObservationsOptions {
|
|
2
3
|
memoryDir: string;
|
|
3
4
|
retentionDays?: number;
|
|
4
5
|
dryRun?: boolean;
|
|
5
6
|
now?: Date;
|
|
7
|
+
archiveFileWriter?: ArchiveFileWriter;
|
|
6
8
|
}
|
|
7
9
|
interface ArchiveObservationsResult {
|
|
8
10
|
dryRun: boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
migrateObservations
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-D6RIFG4O.js";
|
|
4
|
+
import "../chunk-JCK7V6SN.js";
|
|
5
|
+
import "../chunk-SFQ6QNL7.js";
|
|
6
6
|
import "../chunk-PZ5AY32C.js";
|
|
7
7
|
export {
|
|
8
8
|
migrateObservations
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare function writeFileAtomically(outputPath: string, content: string, backupPath?: string): Promise<string | undefined>;
|
|
1
|
+
declare function writeFileAtomically(outputPath: string, content: string | Uint8Array, backupPath?: string): Promise<string | undefined>;
|
|
2
2
|
|
|
3
3
|
interface LedgerWriteOptions<T extends object> {
|
|
4
4
|
memoryDir: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
backupAndWriteRebuiltObservations,
|
|
3
3
|
toHourBucketIso
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-JCK7V6SN.js";
|
|
5
|
+
import "../chunk-SFQ6QNL7.js";
|
|
6
6
|
import "../chunk-PZ5AY32C.js";
|
|
7
7
|
export {
|
|
8
8
|
backupAndWriteRebuiltObservations,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
backupExistingLedger,
|
|
3
3
|
rebuildMemoryLifecycleLedger
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-O4M4WH6V.js";
|
|
5
5
|
import "../chunk-KJTKLXTH.js";
|
|
6
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-SFQ6QNL7.js";
|
|
7
7
|
import "../chunk-TVZ6LKKS.js";
|
|
8
8
|
import "../chunk-5UZXUTVO.js";
|
|
9
9
|
import "../chunk-4H5ZJHEN.js";
|
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
rebuildMemoryProjection,
|
|
4
4
|
repairMemoryProjection,
|
|
5
5
|
verifyMemoryProjection
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-ILJXM3FV.js";
|
|
7
7
|
import "../chunk-KJTKLXTH.js";
|
|
8
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-SFQ6QNL7.js";
|
|
9
9
|
import "../chunk-BEUDU7Y4.js";
|
|
10
10
|
import "../chunk-E5OECWZ5.js";
|
|
11
11
|
import "../chunk-TVZ6LKKS.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
rebuildObservations
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-LZZNTPLR.js";
|
|
4
|
+
import "../chunk-JCK7V6SN.js";
|
|
5
|
+
import "../chunk-SFQ6QNL7.js";
|
|
6
6
|
import "../chunk-PZ5AY32C.js";
|
|
7
7
|
export {
|
|
8
8
|
rebuildObservations
|
package/dist/orchestrator.js
CHANGED
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
sanitizeSessionKeyForFilename,
|
|
27
27
|
shouldFilterLifecycleRecallCandidate,
|
|
28
28
|
summarizeGraphShadowComparison
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-RLPIT4YI.js";
|
|
30
30
|
import "./chunk-5RIRL3XL.js";
|
|
31
31
|
import "./chunk-BFBF3XEF.js";
|
|
32
32
|
import "./chunk-KVEVLBKC.js";
|
|
@@ -58,12 +58,12 @@ import "./chunk-USYGGIJZ.js";
|
|
|
58
58
|
import "./chunk-V3RXWQIE.js";
|
|
59
59
|
import "./chunk-5IZL4DCV.js";
|
|
60
60
|
import "./chunk-X7XN6YU4.js";
|
|
61
|
-
import "./chunk-
|
|
61
|
+
import "./chunk-452WDNFO.js";
|
|
62
62
|
import "./chunk-TDKQGLJW.js";
|
|
63
63
|
import "./chunk-OZKZ2TRP.js";
|
|
64
64
|
import "./chunk-YDBIWGNI.js";
|
|
65
65
|
import "./chunk-7DHTMOND.js";
|
|
66
|
-
import "./chunk-
|
|
66
|
+
import "./chunk-2IT7WFYE.js";
|
|
67
67
|
import "./chunk-YCN4BVDK.js";
|
|
68
68
|
import "./chunk-ZZTOURJI.js";
|
|
69
69
|
import "./chunk-XKXKSQU7.js";
|
|
@@ -107,7 +107,7 @@ import "./chunk-FADZBOR4.js";
|
|
|
107
107
|
import "./chunk-XPXEJRUB.js";
|
|
108
108
|
import "./chunk-A6D7A2FW.js";
|
|
109
109
|
import "./chunk-FF4KLI5W.js";
|
|
110
|
-
import "./chunk-
|
|
110
|
+
import "./chunk-SFQ6QNL7.js";
|
|
111
111
|
import "./chunk-A2Z6UCWT.js";
|
|
112
112
|
import "./chunk-KXULCVOC.js";
|
|
113
113
|
import "./chunk-SML26KED.js";
|
package/dist/recall-state.js
CHANGED
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
LastRecallStore,
|
|
3
3
|
TierMigrationStatusStore,
|
|
4
4
|
clampGraphRecallExpandedEntries
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-2IT7WFYE.js";
|
|
6
|
+
import "./chunk-SFQ6QNL7.js";
|
|
7
7
|
import "./chunk-2ODBA7MQ.js";
|
|
8
8
|
import "./chunk-PZ5AY32C.js";
|
|
9
9
|
export {
|
package/dist/relevance.js
CHANGED
package/dist/schemas.d.ts
CHANGED
|
@@ -275,12 +275,12 @@ declare const EntityMentionSchema: z.ZodObject<{
|
|
|
275
275
|
title: z.ZodString;
|
|
276
276
|
facts: z.ZodArray<z.ZodString, "many">;
|
|
277
277
|
}, "strip", z.ZodTypeAny, {
|
|
278
|
-
title: string;
|
|
279
278
|
key: string;
|
|
279
|
+
title: string;
|
|
280
280
|
facts: string[];
|
|
281
281
|
}, {
|
|
282
|
-
title: string;
|
|
283
282
|
key: string;
|
|
283
|
+
title: string;
|
|
284
284
|
facts: string[];
|
|
285
285
|
}>, "many">>>;
|
|
286
286
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -288,8 +288,8 @@ declare const EntityMentionSchema: z.ZodObject<{
|
|
|
288
288
|
name: string;
|
|
289
289
|
facts: string[];
|
|
290
290
|
structuredSections?: {
|
|
291
|
-
title: string;
|
|
292
291
|
key: string;
|
|
292
|
+
title: string;
|
|
293
293
|
facts: string[];
|
|
294
294
|
}[] | null | undefined;
|
|
295
295
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -298,8 +298,8 @@ declare const EntityMentionSchema: z.ZodObject<{
|
|
|
298
298
|
name: string;
|
|
299
299
|
facts: string[];
|
|
300
300
|
structuredSections?: {
|
|
301
|
-
title: string;
|
|
302
301
|
key: string;
|
|
302
|
+
title: string;
|
|
303
303
|
facts: string[];
|
|
304
304
|
}[] | null | undefined;
|
|
305
305
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -584,12 +584,12 @@ declare const ProactiveExtractionResultSchema: z.ZodObject<{
|
|
|
584
584
|
title: z.ZodString;
|
|
585
585
|
facts: z.ZodArray<z.ZodString, "many">;
|
|
586
586
|
}, "strip", z.ZodTypeAny, {
|
|
587
|
-
title: string;
|
|
588
587
|
key: string;
|
|
588
|
+
title: string;
|
|
589
589
|
facts: string[];
|
|
590
590
|
}, {
|
|
591
|
-
title: string;
|
|
592
591
|
key: string;
|
|
592
|
+
title: string;
|
|
593
593
|
facts: string[];
|
|
594
594
|
}>, "many">>>;
|
|
595
595
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -597,8 +597,8 @@ declare const ProactiveExtractionResultSchema: z.ZodObject<{
|
|
|
597
597
|
name: string;
|
|
598
598
|
facts: string[];
|
|
599
599
|
structuredSections?: {
|
|
600
|
-
title: string;
|
|
601
600
|
key: string;
|
|
601
|
+
title: string;
|
|
602
602
|
facts: string[];
|
|
603
603
|
}[] | null | undefined;
|
|
604
604
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -607,8 +607,8 @@ declare const ProactiveExtractionResultSchema: z.ZodObject<{
|
|
|
607
607
|
name: string;
|
|
608
608
|
facts: string[];
|
|
609
609
|
structuredSections?: {
|
|
610
|
-
title: string;
|
|
611
610
|
key: string;
|
|
611
|
+
title: string;
|
|
612
612
|
facts: string[];
|
|
613
613
|
}[] | null | undefined;
|
|
614
614
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -665,8 +665,8 @@ declare const ProactiveExtractionResultSchema: z.ZodObject<{
|
|
|
665
665
|
name: string;
|
|
666
666
|
facts: string[];
|
|
667
667
|
structuredSections?: {
|
|
668
|
-
title: string;
|
|
669
668
|
key: string;
|
|
669
|
+
title: string;
|
|
670
670
|
facts: string[];
|
|
671
671
|
}[] | null | undefined;
|
|
672
672
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -714,8 +714,8 @@ declare const ProactiveExtractionResultSchema: z.ZodObject<{
|
|
|
714
714
|
name: string;
|
|
715
715
|
facts: string[];
|
|
716
716
|
structuredSections?: {
|
|
717
|
-
title: string;
|
|
718
717
|
key: string;
|
|
718
|
+
title: string;
|
|
719
719
|
facts: string[];
|
|
720
720
|
}[] | null | undefined;
|
|
721
721
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -952,12 +952,12 @@ declare const ExtractionResultSchema: z.ZodObject<{
|
|
|
952
952
|
title: z.ZodString;
|
|
953
953
|
facts: z.ZodArray<z.ZodString, "many">;
|
|
954
954
|
}, "strip", z.ZodTypeAny, {
|
|
955
|
-
title: string;
|
|
956
955
|
key: string;
|
|
956
|
+
title: string;
|
|
957
957
|
facts: string[];
|
|
958
958
|
}, {
|
|
959
|
-
title: string;
|
|
960
959
|
key: string;
|
|
960
|
+
title: string;
|
|
961
961
|
facts: string[];
|
|
962
962
|
}>, "many">>>;
|
|
963
963
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -965,8 +965,8 @@ declare const ExtractionResultSchema: z.ZodObject<{
|
|
|
965
965
|
name: string;
|
|
966
966
|
facts: string[];
|
|
967
967
|
structuredSections?: {
|
|
968
|
-
title: string;
|
|
969
968
|
key: string;
|
|
969
|
+
title: string;
|
|
970
970
|
facts: string[];
|
|
971
971
|
}[] | null | undefined;
|
|
972
972
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -975,8 +975,8 @@ declare const ExtractionResultSchema: z.ZodObject<{
|
|
|
975
975
|
name: string;
|
|
976
976
|
facts: string[];
|
|
977
977
|
structuredSections?: {
|
|
978
|
-
title: string;
|
|
979
978
|
key: string;
|
|
979
|
+
title: string;
|
|
980
980
|
facts: string[];
|
|
981
981
|
}[] | null | undefined;
|
|
982
982
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -1047,8 +1047,8 @@ declare const ExtractionResultSchema: z.ZodObject<{
|
|
|
1047
1047
|
name: string;
|
|
1048
1048
|
facts: string[];
|
|
1049
1049
|
structuredSections?: {
|
|
1050
|
-
title: string;
|
|
1051
1050
|
key: string;
|
|
1051
|
+
title: string;
|
|
1052
1052
|
facts: string[];
|
|
1053
1053
|
}[] | null | undefined;
|
|
1054
1054
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -1102,8 +1102,8 @@ declare const ExtractionResultSchema: z.ZodObject<{
|
|
|
1102
1102
|
name: string;
|
|
1103
1103
|
facts: string[];
|
|
1104
1104
|
structuredSections?: {
|
|
1105
|
-
title: string;
|
|
1106
1105
|
key: string;
|
|
1106
|
+
title: string;
|
|
1107
1107
|
facts: string[];
|
|
1108
1108
|
}[] | null | undefined;
|
|
1109
1109
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -1172,12 +1172,12 @@ declare const ConsolidationResultSchema: z.ZodObject<{
|
|
|
1172
1172
|
title: z.ZodString;
|
|
1173
1173
|
facts: z.ZodArray<z.ZodString, "many">;
|
|
1174
1174
|
}, "strip", z.ZodTypeAny, {
|
|
1175
|
-
title: string;
|
|
1176
1175
|
key: string;
|
|
1176
|
+
title: string;
|
|
1177
1177
|
facts: string[];
|
|
1178
1178
|
}, {
|
|
1179
|
-
title: string;
|
|
1180
1179
|
key: string;
|
|
1180
|
+
title: string;
|
|
1181
1181
|
facts: string[];
|
|
1182
1182
|
}>, "many">>>;
|
|
1183
1183
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -1185,8 +1185,8 @@ declare const ConsolidationResultSchema: z.ZodObject<{
|
|
|
1185
1185
|
name: string;
|
|
1186
1186
|
facts: string[];
|
|
1187
1187
|
structuredSections?: {
|
|
1188
|
-
title: string;
|
|
1189
1188
|
key: string;
|
|
1189
|
+
title: string;
|
|
1190
1190
|
facts: string[];
|
|
1191
1191
|
}[] | null | undefined;
|
|
1192
1192
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -1195,8 +1195,8 @@ declare const ConsolidationResultSchema: z.ZodObject<{
|
|
|
1195
1195
|
name: string;
|
|
1196
1196
|
facts: string[];
|
|
1197
1197
|
structuredSections?: {
|
|
1198
|
-
title: string;
|
|
1199
1198
|
key: string;
|
|
1199
|
+
title: string;
|
|
1200
1200
|
facts: string[];
|
|
1201
1201
|
}[] | null | undefined;
|
|
1202
1202
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -1215,8 +1215,8 @@ declare const ConsolidationResultSchema: z.ZodObject<{
|
|
|
1215
1215
|
name: string;
|
|
1216
1216
|
facts: string[];
|
|
1217
1217
|
structuredSections?: {
|
|
1218
|
-
title: string;
|
|
1219
1218
|
key: string;
|
|
1219
|
+
title: string;
|
|
1220
1220
|
facts: string[];
|
|
1221
1221
|
}[] | null | undefined;
|
|
1222
1222
|
promptedByQuestion?: string | null | undefined;
|
|
@@ -1235,8 +1235,8 @@ declare const ConsolidationResultSchema: z.ZodObject<{
|
|
|
1235
1235
|
name: string;
|
|
1236
1236
|
facts: string[];
|
|
1237
1237
|
structuredSections?: {
|
|
1238
|
-
title: string;
|
|
1239
1238
|
key: string;
|
|
1239
|
+
title: string;
|
|
1240
1240
|
facts: string[];
|
|
1241
1241
|
}[] | null | undefined;
|
|
1242
1242
|
promptedByQuestion?: string | null | undefined;
|
package/dist/transfer/types.d.ts
CHANGED
|
@@ -313,13 +313,13 @@ declare const CapsuleBlockSchema: z.ZodObject<{
|
|
|
313
313
|
peerProfiles: boolean;
|
|
314
314
|
}>;
|
|
315
315
|
}, "strip", z.ZodTypeAny, {
|
|
316
|
-
schemaVersion: string;
|
|
317
316
|
includes: {
|
|
318
317
|
procedural: boolean;
|
|
319
318
|
taxonomy: boolean;
|
|
320
319
|
identityAnchors: boolean;
|
|
321
320
|
peerProfiles: boolean;
|
|
322
321
|
};
|
|
322
|
+
schemaVersion: string;
|
|
323
323
|
id: string;
|
|
324
324
|
description: string;
|
|
325
325
|
version: string;
|
|
@@ -334,13 +334,13 @@ declare const CapsuleBlockSchema: z.ZodObject<{
|
|
|
334
334
|
directAnswerEnabled: boolean;
|
|
335
335
|
};
|
|
336
336
|
}, {
|
|
337
|
-
schemaVersion: string;
|
|
338
337
|
includes: {
|
|
339
338
|
procedural: boolean;
|
|
340
339
|
taxonomy: boolean;
|
|
341
340
|
identityAnchors: boolean;
|
|
342
341
|
peerProfiles: boolean;
|
|
343
342
|
};
|
|
343
|
+
schemaVersion: string;
|
|
344
344
|
id: string;
|
|
345
345
|
description: string;
|
|
346
346
|
version: string;
|
|
@@ -464,13 +464,13 @@ declare const ExportManifestV2Schema: z.ZodObject<{
|
|
|
464
464
|
peerProfiles: boolean;
|
|
465
465
|
}>;
|
|
466
466
|
}, "strip", z.ZodTypeAny, {
|
|
467
|
-
schemaVersion: string;
|
|
468
467
|
includes: {
|
|
469
468
|
procedural: boolean;
|
|
470
469
|
taxonomy: boolean;
|
|
471
470
|
identityAnchors: boolean;
|
|
472
471
|
peerProfiles: boolean;
|
|
473
472
|
};
|
|
473
|
+
schemaVersion: string;
|
|
474
474
|
id: string;
|
|
475
475
|
description: string;
|
|
476
476
|
version: string;
|
|
@@ -485,13 +485,13 @@ declare const ExportManifestV2Schema: z.ZodObject<{
|
|
|
485
485
|
directAnswerEnabled: boolean;
|
|
486
486
|
};
|
|
487
487
|
}, {
|
|
488
|
-
schemaVersion: string;
|
|
489
488
|
includes: {
|
|
490
489
|
procedural: boolean;
|
|
491
490
|
taxonomy: boolean;
|
|
492
491
|
identityAnchors: boolean;
|
|
493
492
|
peerProfiles: boolean;
|
|
494
493
|
};
|
|
494
|
+
schemaVersion: string;
|
|
495
495
|
id: string;
|
|
496
496
|
description: string;
|
|
497
497
|
version: string;
|
|
@@ -518,13 +518,13 @@ declare const ExportManifestV2Schema: z.ZodObject<{
|
|
|
518
518
|
pluginVersion: string;
|
|
519
519
|
includesTranscripts: boolean;
|
|
520
520
|
capsule: {
|
|
521
|
-
schemaVersion: string;
|
|
522
521
|
includes: {
|
|
523
522
|
procedural: boolean;
|
|
524
523
|
taxonomy: boolean;
|
|
525
524
|
identityAnchors: boolean;
|
|
526
525
|
peerProfiles: boolean;
|
|
527
526
|
};
|
|
527
|
+
schemaVersion: string;
|
|
528
528
|
id: string;
|
|
529
529
|
description: string;
|
|
530
530
|
version: string;
|
|
@@ -551,13 +551,13 @@ declare const ExportManifestV2Schema: z.ZodObject<{
|
|
|
551
551
|
pluginVersion: string;
|
|
552
552
|
includesTranscripts: boolean;
|
|
553
553
|
capsule: {
|
|
554
|
-
schemaVersion: string;
|
|
555
554
|
includes: {
|
|
556
555
|
procedural: boolean;
|
|
557
556
|
taxonomy: boolean;
|
|
558
557
|
identityAnchors: boolean;
|
|
559
558
|
peerProfiles: boolean;
|
|
560
559
|
};
|
|
560
|
+
schemaVersion: string;
|
|
561
561
|
id: string;
|
|
562
562
|
description: string;
|
|
563
563
|
version: string;
|
|
@@ -683,13 +683,13 @@ declare const ExportBundleV2Schema: z.ZodObject<{
|
|
|
683
683
|
peerProfiles: boolean;
|
|
684
684
|
}>;
|
|
685
685
|
}, "strip", z.ZodTypeAny, {
|
|
686
|
-
schemaVersion: string;
|
|
687
686
|
includes: {
|
|
688
687
|
procedural: boolean;
|
|
689
688
|
taxonomy: boolean;
|
|
690
689
|
identityAnchors: boolean;
|
|
691
690
|
peerProfiles: boolean;
|
|
692
691
|
};
|
|
692
|
+
schemaVersion: string;
|
|
693
693
|
id: string;
|
|
694
694
|
description: string;
|
|
695
695
|
version: string;
|
|
@@ -704,13 +704,13 @@ declare const ExportBundleV2Schema: z.ZodObject<{
|
|
|
704
704
|
directAnswerEnabled: boolean;
|
|
705
705
|
};
|
|
706
706
|
}, {
|
|
707
|
-
schemaVersion: string;
|
|
708
707
|
includes: {
|
|
709
708
|
procedural: boolean;
|
|
710
709
|
taxonomy: boolean;
|
|
711
710
|
identityAnchors: boolean;
|
|
712
711
|
peerProfiles: boolean;
|
|
713
712
|
};
|
|
713
|
+
schemaVersion: string;
|
|
714
714
|
id: string;
|
|
715
715
|
description: string;
|
|
716
716
|
version: string;
|
|
@@ -737,13 +737,13 @@ declare const ExportBundleV2Schema: z.ZodObject<{
|
|
|
737
737
|
pluginVersion: string;
|
|
738
738
|
includesTranscripts: boolean;
|
|
739
739
|
capsule: {
|
|
740
|
-
schemaVersion: string;
|
|
741
740
|
includes: {
|
|
742
741
|
procedural: boolean;
|
|
743
742
|
taxonomy: boolean;
|
|
744
743
|
identityAnchors: boolean;
|
|
745
744
|
peerProfiles: boolean;
|
|
746
745
|
};
|
|
746
|
+
schemaVersion: string;
|
|
747
747
|
id: string;
|
|
748
748
|
description: string;
|
|
749
749
|
version: string;
|
|
@@ -770,13 +770,13 @@ declare const ExportBundleV2Schema: z.ZodObject<{
|
|
|
770
770
|
pluginVersion: string;
|
|
771
771
|
includesTranscripts: boolean;
|
|
772
772
|
capsule: {
|
|
773
|
-
schemaVersion: string;
|
|
774
773
|
includes: {
|
|
775
774
|
procedural: boolean;
|
|
776
775
|
taxonomy: boolean;
|
|
777
776
|
identityAnchors: boolean;
|
|
778
777
|
peerProfiles: boolean;
|
|
779
778
|
};
|
|
779
|
+
schemaVersion: string;
|
|
780
780
|
id: string;
|
|
781
781
|
description: string;
|
|
782
782
|
version: string;
|
|
@@ -815,13 +815,13 @@ declare const ExportBundleV2Schema: z.ZodObject<{
|
|
|
815
815
|
pluginVersion: string;
|
|
816
816
|
includesTranscripts: boolean;
|
|
817
817
|
capsule: {
|
|
818
|
-
schemaVersion: string;
|
|
819
818
|
includes: {
|
|
820
819
|
procedural: boolean;
|
|
821
820
|
taxonomy: boolean;
|
|
822
821
|
identityAnchors: boolean;
|
|
823
822
|
peerProfiles: boolean;
|
|
824
823
|
};
|
|
824
|
+
schemaVersion: string;
|
|
825
825
|
id: string;
|
|
826
826
|
description: string;
|
|
827
827
|
version: string;
|
|
@@ -854,13 +854,13 @@ declare const ExportBundleV2Schema: z.ZodObject<{
|
|
|
854
854
|
pluginVersion: string;
|
|
855
855
|
includesTranscripts: boolean;
|
|
856
856
|
capsule: {
|
|
857
|
-
schemaVersion: string;
|
|
858
857
|
includes: {
|
|
859
858
|
procedural: boolean;
|
|
860
859
|
taxonomy: boolean;
|
|
861
860
|
identityAnchors: boolean;
|
|
862
861
|
peerProfiles: boolean;
|
|
863
862
|
};
|
|
863
|
+
schemaVersion: string;
|
|
864
864
|
id: string;
|
|
865
865
|
description: string;
|
|
866
866
|
version: string;
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { lstat, mkdir, readdir, readFile, realpath, unlink
|
|
2
|
+
import { lstat, mkdir, readdir, readFile, realpath, unlink } from "node:fs/promises";
|
|
3
|
+
import { writeFileAtomically } from "./atomic-file.js";
|
|
3
4
|
|
|
4
5
|
const DATE_FILE_PATTERN = /^(\d{4})-(\d{2})-(\d{2})\.(jsonl|md)$/;
|
|
5
6
|
|
|
7
|
+
type ArchiveFileWriter = (archivePath: string, content: Uint8Array) => Promise<void>;
|
|
8
|
+
|
|
6
9
|
export interface ArchiveObservationsOptions {
|
|
7
10
|
memoryDir: string;
|
|
8
11
|
retentionDays?: number;
|
|
9
12
|
dryRun?: boolean;
|
|
10
13
|
now?: Date;
|
|
14
|
+
archiveFileWriter?: ArchiveFileWriter;
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
export interface ArchiveObservationsResult {
|
|
@@ -43,6 +47,10 @@ function startOfUtcDay(value: Date): number {
|
|
|
43
47
|
return Date.UTC(value.getUTCFullYear(), value.getUTCMonth(), value.getUTCDate());
|
|
44
48
|
}
|
|
45
49
|
|
|
50
|
+
async function writeArchiveFileAtomically(archivePath: string, content: Uint8Array): Promise<void> {
|
|
51
|
+
await writeFileAtomically(archivePath, content);
|
|
52
|
+
}
|
|
53
|
+
|
|
46
54
|
async function listFilesRecursive(root: string, relPrefix = ""): Promise<string[]> {
|
|
47
55
|
const out: string[] = [];
|
|
48
56
|
let entries: Array<{ name: string; isDirectory(): boolean; isFile(): boolean }>;
|
|
@@ -125,6 +133,7 @@ export async function archiveObservations(
|
|
|
125
133
|
);
|
|
126
134
|
const stamp = now.toISOString().replace(/[-:]/g, "").replace(/\.\d{3}Z$/, "Z");
|
|
127
135
|
const archiveRoot = path.join(options.memoryDir, "archive", "observations", stamp);
|
|
136
|
+
const archiveFileWriter = options.archiveFileWriter ?? writeArchiveFileAtomically;
|
|
128
137
|
const candidates =
|
|
129
138
|
retentionDays === 0
|
|
130
139
|
? []
|
|
@@ -146,7 +155,11 @@ export async function archiveObservations(
|
|
|
146
155
|
const candidateInfo = await lstat(candidate.absolutePath).catch(() => null);
|
|
147
156
|
if (!candidateInfo?.isFile() || candidateInfo.isSymbolicLink()) continue;
|
|
148
157
|
const raw = await readFile(candidate.absolutePath);
|
|
149
|
-
await
|
|
158
|
+
await archiveFileWriter(archivePath, raw);
|
|
159
|
+
const archivedRaw = await readFile(archivePath);
|
|
160
|
+
if (!archivedRaw.equals(raw)) {
|
|
161
|
+
throw new Error(`Archive copy verification failed for ${candidate.relativePath}`);
|
|
162
|
+
}
|
|
150
163
|
await unlink(candidate.absolutePath);
|
|
151
164
|
archivedFiles += 1;
|
|
152
165
|
archivedBytes += raw.byteLength;
|
|
@@ -36,7 +36,7 @@ export async function copyExistingFileToBackup(
|
|
|
36
36
|
|
|
37
37
|
export async function writeFileAtomically(
|
|
38
38
|
outputPath: string,
|
|
39
|
-
content: string,
|
|
39
|
+
content: string | Uint8Array,
|
|
40
40
|
backupPath?: string,
|
|
41
41
|
): Promise<string | undefined> {
|
|
42
42
|
const dir = path.dirname(outputPath);
|
|
@@ -46,7 +46,11 @@ export async function writeFileAtomically(
|
|
|
46
46
|
let resolvedBackupPath: string | undefined;
|
|
47
47
|
try {
|
|
48
48
|
handle = await open(tempPath, "w");
|
|
49
|
-
|
|
49
|
+
if (typeof content === "string") {
|
|
50
|
+
await handle.writeFile(content, "utf-8");
|
|
51
|
+
} else {
|
|
52
|
+
await handle.writeFile(content);
|
|
53
|
+
}
|
|
50
54
|
await handle.sync();
|
|
51
55
|
await handle.close();
|
|
52
56
|
handle = undefined;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/maintenance/atomic-file.ts"],"sourcesContent":["import path from \"node:path\";\nimport { copyFile, mkdir, open, rename, rm, stat } from \"node:fs/promises\";\n\nasync function syncDirectory(dir: string): Promise<void> {\n let handle: Awaited<ReturnType<typeof open>> | undefined;\n try {\n handle = await open(dir, \"r\");\n await handle.sync();\n } catch {\n // Directory fsync is best-effort across platforms and filesystems.\n } finally {\n await handle?.close().catch(() => undefined);\n }\n}\n\nfunction tempPathFor(outputPath: string): string {\n const suffix = `${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}`;\n return path.join(path.dirname(outputPath), `.${path.basename(outputPath)}.${suffix}.tmp`);\n}\n\nexport async function copyExistingFileToBackup(\n sourcePath: string,\n backupPath: string,\n): Promise<string | undefined> {\n try {\n await stat(sourcePath);\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === \"ENOENT\") return undefined;\n throw err;\n }\n\n await mkdir(path.dirname(backupPath), { recursive: true });\n await copyFile(sourcePath, backupPath);\n return backupPath;\n}\n\nexport async function writeFileAtomically(\n outputPath: string,\n content: string,\n backupPath?: string,\n): Promise<string | undefined> {\n const dir = path.dirname(outputPath);\n await mkdir(dir, { recursive: true });\n const tempPath = tempPathFor(outputPath);\n let handle: Awaited<ReturnType<typeof open>> | undefined;\n let resolvedBackupPath: string | undefined;\n try {\n handle = await open(tempPath, \"w\");\n await handle.writeFile(content, \"utf-8\");\n await handle.sync();\n await handle.close();\n handle = undefined;\n\n if (backupPath) {\n resolvedBackupPath = await copyExistingFileToBackup(outputPath, backupPath);\n }\n await rename(tempPath, outputPath);\n await syncDirectory(dir);\n return resolvedBackupPath;\n } catch (err) {\n await handle?.close().catch(() => undefined);\n await rm(tempPath, { force: true }).catch(() => undefined);\n throw err;\n }\n}\n\nexport async function commitPreparedFileAtomically(\n tempPath: string,\n outputPath: string,\n backupPath?: string,\n): Promise<string | undefined> {\n const dir = path.dirname(outputPath);\n let resolvedBackupPath: string | undefined;\n try {\n if (backupPath) {\n resolvedBackupPath = await copyExistingFileToBackup(outputPath, backupPath);\n }\n await rename(tempPath, outputPath);\n await syncDirectory(dir);\n return resolvedBackupPath;\n } catch (err) {\n await rm(tempPath, { force: true }).catch(() => undefined);\n throw err;\n }\n}\n"],"mappings":";AAAA,OAAO,UAAU;AACjB,SAAS,UAAU,OAAO,MAAM,QAAQ,IAAI,YAAY;AAExD,eAAe,cAAc,KAA4B;AACvD,MAAI;AACJ,MAAI;AACF,aAAS,MAAM,KAAK,KAAK,GAAG;AAC5B,UAAM,OAAO,KAAK;AAAA,EACpB,QAAQ;AAAA,EAER,UAAE;AACA,UAAM,QAAQ,MAAM,EAAE,MAAM,MAAM,MAAS;AAAA,EAC7C;AACF;AAEA,SAAS,YAAY,YAA4B;AAC/C,QAAM,SAAS,GAAG,QAAQ,GAAG,IAAI,KAAK,I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AA,IAC5E;AACA,UAAM,OAAO,UAAU,UAAU;AACjC,UAAM,cAAc,GAAG;AACvB,WAAO;AAAA,EACT,SAAS,KAAK;AACZ,UAAM,GAAG,UAAU,EAAE,OAAO,KAAK,CAAC,EAAE,MAAM,MAAM,MAAS;AACzD,UAAM;AAAA,EACR;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/maintenance/archive-observations.ts"],"sourcesContent":["import path from \"node:path\";\nimport { lstat, mkdir, readdir, readFile, realpath, unlink, writeFile } from \"node:fs/promises\";\n\nconst DATE_FILE_PATTERN = /^(\\d{4})-(\\d{2})-(\\d{2})\\.(jsonl|md)$/;\n\nexport interface ArchiveObservationsOptions {\n memoryDir: string;\n retentionDays?: number;\n dryRun?: boolean;\n now?: Date;\n}\n\nexport interface ArchiveObservationsResult {\n dryRun: boolean;\n retentionDays: number;\n scannedFiles: number;\n archivedFiles: number;\n archivedBytes: number;\n archiveRoot: string;\n archivedRelativePaths: string[];\n}\n\ninterface CandidateFile {\n absolutePath: string;\n relativePath: string;\n}\n\nfunction normalizeRetentionDays(value: number | undefined): number {\n if (!Number.isFinite(value as number)) return 30;\n return Math.max(0, Math.floor(value as number));\n}\n\nfunction extractDateFromFilename(name: string): Date | null {\n const match = DATE_FILE_PATTERN.exec(name);\n if (!match) return null;\n const iso = `${match[1]}-${match[2]}-${match[3]}T00:00:00.000Z`;\n const parsed = new Date(iso);\n if (Number.isNaN(parsed.getTime())) return null;\n return parsed;\n}\n\nfunction startOfUtcDay(value: Date): number {\n return Date.UTC(value.getUTCFullYear(), value.getUTCMonth(), value.getUTCDate());\n}\n\nasync function listFilesRecursive(root: string, relPrefix = \"\"): Promise<string[]> {\n const out: string[] = [];\n let entries: Array<{ name: string; isDirectory(): boolean; isFile(): boolean }>;\n try {\n entries = (await readdir(root, { withFileTypes: true })) as Array<{\n name: string;\n isDirectory(): boolean;\n isFile(): boolean;\n }>;\n } catch {\n return out;\n }\n\n for (const entry of entries) {\n const rel = relPrefix ? path.join(relPrefix, entry.name) : entry.name;\n const full = path.join(root, entry.name);\n if (entry.isDirectory()) {\n out.push(...(await listFilesRecursive(full, rel)));\n continue;\n }\n if (entry.isFile()) out.push(rel);\n }\n\n return out;\n}\n\nasync function collectArchiveCandidates(\n memoryDir: string,\n cutoffTimeMs: number,\n): Promise<CandidateFile[]> {\n const roots = [\"transcripts\", path.join(\"state\", \"tool-usage\"), path.join(\"summaries\", \"hourly\")];\n const out: CandidateFile[] = [];\n const memoryRoot = path.resolve(memoryDir);\n const memoryRealRoot = await realpath(memoryRoot).catch(() => memoryRoot);\n\n for (const relRoot of roots) {\n const absRoot = path.resolve(memoryRoot, relRoot);\n const rootInfo = await lstat(absRoot).catch(() => null);\n if (!rootInfo?.isDirectory() || rootInfo.isSymbolicLink()) continue;\n const absRootReal = await realpath(absRoot).catch(() => null);\n if (absRootReal === null) continue;\n const rootRelative = path.relative(memoryRealRoot, absRootReal);\n if (rootRelative === \"..\" || rootRelative.startsWith(`..${path.sep}`) || path.isAbsolute(rootRelative)) {\n continue;\n }\n const files = await listFilesRecursive(absRoot);\n for (const fileRel of files) {\n const filename = path.basename(fileRel);\n const parsedDate = extractDateFromFilename(filename);\n if (!parsedDate) continue;\n if (parsedDate.getTime() >= cutoffTimeMs) continue;\n const absolutePath = path.resolve(absRoot, fileRel);\n const relativeToMemory = path.relative(memoryRoot, absolutePath);\n if (\n relativeToMemory === \"..\" ||\n relativeToMemory.startsWith(`..${path.sep}`) ||\n path.isAbsolute(relativeToMemory)\n ) {\n continue;\n }\n out.push({\n absolutePath,\n relativePath: path.join(relRoot, fileRel),\n });\n }\n }\n\n out.sort((a, b) => a.relativePath.localeCompare(b.relativePath));\n return out;\n}\n\nexport async function archiveObservations(\n options: ArchiveObservationsOptions,\n): Promise<ArchiveObservationsResult> {\n const retentionDays = normalizeRetentionDays(options.retentionDays);\n const dryRun = options.dryRun !== false;\n const now = options.now ?? new Date();\n const cutoffDayStartUtc = startOfUtcDay(\n new Date(now.getTime() - retentionDays * 24 * 60 * 60 * 1000),\n );\n const stamp = now.toISOString().replace(/[-:]/g, \"\").replace(/\\.\\d{3}Z$/, \"Z\");\n const archiveRoot = path.join(options.memoryDir, \"archive\", \"observations\", stamp);\n const candidates =\n retentionDays === 0\n ? []\n : await collectArchiveCandidates(\n options.memoryDir,\n cutoffDayStartUtc,\n );\n\n let archivedFiles = 0;\n let archivedBytes = 0;\n const archivedRelativePaths: string[] = [];\n\n if (!dryRun && candidates.length > 0) {\n await mkdir(archiveRoot, { recursive: true });\n for (const candidate of candidates) {\n const archivePath = path.join(archiveRoot, candidate.relativePath);\n const archiveDir = path.dirname(archivePath);\n await mkdir(archiveDir, { recursive: true });\n const candidateInfo = await lstat(candidate.absolutePath).catch(() => null);\n if (!candidateInfo?.isFile() || candidateInfo.isSymbolicLink()) continue;\n const raw = await readFile(candidate.absolutePath);\n await writeFile(archivePath, raw);\n await unlink(candidate.absolutePath);\n archivedFiles += 1;\n archivedBytes += raw.byteLength;\n archivedRelativePaths.push(candidate.relativePath);\n }\n } else {\n archivedRelativePaths.push(...candidates.map((c) => c.relativePath));\n }\n\n return {\n dryRun,\n retentionDays,\n scannedFiles: candidates.length,\n archivedFiles,\n archivedBytes,\n archiveRoot,\n archivedRelativePaths,\n };\n}\n"],"mappings":";AAAA,OAAO,UAAU;AACjB,SAAS,OAAO,OAAO,SAAS,UAAU,UAAU,QAAQ,iBAAiB;AAE7E,IAAM,oBAAoB;AAwB1B,SAAS,uBAAuB,OAAmC;AACjE,MAAI,CAAC,OAAO,SAAS,KAAe,EAAG,QAAO;AAC9C,SAAO,KAAK,IAAI,GAAG,KAAK,MAAM,KAAe,CAAC;AAChD;AAEA,SAAS,wBAAwB,MAA2B;AAC1D,QAAM,QAAQ,kBAAkB,KAAK,IAAI;AACzC,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,MAAM,GAAG,MAAM,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,IAAI,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,MAAM;AAAA,IACN,QAAQ;AAAA,IACR;AAAA,EACF;AAEJ,MAAI,gBAAgB;AACpB,MAAI,gBAAgB;AACpB,QAAM,wBAAkC,CAAC;AAEzC,MAAI,CAAC,UAAU,WAAW,SAAS,GAAG;AACpC,UAAM,MAAM,aAAa,EAAE,WAAW,KAAK,CAAC;AAC5C,eAAW,aAAa,YAAY;AAClC,YAAM,cAAc,KAAK,KAAK,aAAa,UAAU,YAAY;AACjE,YAAM,aAAa,KAAK,QAAQ,WAAW;AAC3C,YAAM,MAAM,YAAY,EAAE,WAAW,KAAK,CAAC;AAC3C,YAAM,gBAAgB,MAAM,MAAM,UAAU,YAAY,EAAE,MAAM,MAAM,IAAI;AAC1E,UAAI,CAAC,eAAe,OAAO,KAAK,cAAc,eAAe,EAAG;AAChE,YAAM,MAAM,MAAM,SAAS,UAAU,YAAY;AACjD,YAAM,UAAU,aAAa,GAAG;AAChC,YAAM,OAAO,UAAU,YAAY;AACnC,uBAAiB;AACjB,uBAAiB,IAAI;AACrB,4BAAsB,KAAK,UAAU,YAAY;AAAA,IACnD;AAAA,EACF,OAAO;AACL,0BAAsB,KAAK,GAAG,WAAW,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC;AAAA,EACrE;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,cAAc,WAAW;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|