@qearlyao/familiar 0.1.0
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/.env.example +31 -0
- package/HEARTBEAT.md +23 -0
- package/LICENSE +21 -0
- package/MEMORY.md +1 -0
- package/README.md +245 -0
- package/SOUL.md +13 -0
- package/USER.md +13 -0
- package/config.example.toml +221 -0
- package/dist/agent-events.js +167 -0
- package/dist/agent.js +590 -0
- package/dist/browser-tools.js +638 -0
- package/dist/chat-log.js +130 -0
- package/dist/cli.js +168 -0
- package/dist/config.js +804 -0
- package/dist/data-retention.js +54 -0
- package/dist/discord.js +1203 -0
- package/dist/generated-media.js +86 -0
- package/dist/image-derivatives.js +102 -0
- package/dist/image-gen.js +440 -0
- package/dist/inbound-attachments.js +266 -0
- package/dist/index.js +10 -0
- package/dist/media-understanding.js +120 -0
- package/dist/memory/diary/ambient-injector.js +180 -0
- package/dist/memory/diary/ambient.js +124 -0
- package/dist/memory/diary/chunks.js +231 -0
- package/dist/memory/diary/index.js +3 -0
- package/dist/memory/diary/indexer.js +93 -0
- package/dist/memory/doctor.js +250 -0
- package/dist/memory/index/chunk-indexer.js +151 -0
- package/dist/memory/index/embedding-provider.js +119 -0
- package/dist/memory/index/fts-query.js +18 -0
- package/dist/memory/index/retrieval.js +246 -0
- package/dist/memory/index/schema.js +157 -0
- package/dist/memory/index/store.js +513 -0
- package/dist/memory/index/vec.js +72 -0
- package/dist/memory/index/vector-codec.js +27 -0
- package/dist/memory/lcm/backfill.js +247 -0
- package/dist/memory/lcm/condense.js +146 -0
- package/dist/memory/lcm/context-transformer.js +662 -0
- package/dist/memory/lcm/context.js +421 -0
- package/dist/memory/lcm/eviction-score.js +38 -0
- package/dist/memory/lcm/index.js +6 -0
- package/dist/memory/lcm/indexer.js +200 -0
- package/dist/memory/lcm/normalize.js +235 -0
- package/dist/memory/lcm/schema.js +188 -0
- package/dist/memory/lcm/segment-manager.js +136 -0
- package/dist/memory/lcm/store.js +722 -0
- package/dist/memory/lcm/summarizer.js +258 -0
- package/dist/memory/lcm/types.js +1 -0
- package/dist/memory/operator.js +477 -0
- package/dist/memory/service.js +202 -0
- package/dist/memory/tools.js +205 -0
- package/dist/models.js +165 -0
- package/dist/persona.js +54 -0
- package/dist/runtime.js +493 -0
- package/dist/scheduler.js +200 -0
- package/dist/settings.js +116 -0
- package/dist/skills.js +38 -0
- package/dist/tts.js +143 -0
- package/dist/web-auth.js +105 -0
- package/dist/web-events.js +114 -0
- package/dist/web-http.js +29 -0
- package/dist/web-static.js +106 -0
- package/dist/web-tools.js +940 -0
- package/dist/web-types.js +2 -0
- package/dist/web.js +844 -0
- package/package.json +60 -0
- package/web/dist/assets/index-ClgkMgaq.css +2 -0
- package/web/dist/assets/index-Cu2QquuR.js +59 -0
- package/web/dist/favicon.svg +1 -0
- package/web/dist/icons.svg +24 -0
- package/web/dist/index.html +20 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { lstat, readdir, rm } from "node:fs/promises";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
export async function runDataRetention(config, now = Date.now()) {
|
|
4
|
+
if (config.data.transcripts.retentionDays > 0) {
|
|
5
|
+
console.warn("data.transcripts.retention_days is configured; transcript replay may lose restart context after retention.");
|
|
6
|
+
}
|
|
7
|
+
return {
|
|
8
|
+
chat: await removeOldFiles(resolve(config.workspace.dataDir, "chat"), config.data.chat.retentionDays, now),
|
|
9
|
+
transcripts: await removeOldFiles(resolve(config.workspace.dataDir, "transcripts"), config.data.transcripts.retentionDays, now),
|
|
10
|
+
payloads: await removeOldFiles(resolve(config.workspace.dataDir, "payloads"), config.data.payloads.retentionDays, now),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
async function removeOldFiles(root, retentionDays, now) {
|
|
14
|
+
if (retentionDays <= 0)
|
|
15
|
+
return 0;
|
|
16
|
+
const cutoff = now - retentionDays * 86_400_000;
|
|
17
|
+
let removed = 0;
|
|
18
|
+
for (const path of await listFiles(root)) {
|
|
19
|
+
const fileStat = await lstat(path).catch((error) => {
|
|
20
|
+
if (isEnoent(error))
|
|
21
|
+
return null;
|
|
22
|
+
throw error;
|
|
23
|
+
});
|
|
24
|
+
if (!fileStat?.isFile() || fileStat.mtimeMs > cutoff)
|
|
25
|
+
continue;
|
|
26
|
+
await rm(path).catch((error) => {
|
|
27
|
+
if (!isEnoent(error))
|
|
28
|
+
throw error;
|
|
29
|
+
});
|
|
30
|
+
removed += 1;
|
|
31
|
+
}
|
|
32
|
+
return removed;
|
|
33
|
+
}
|
|
34
|
+
async function listFiles(root) {
|
|
35
|
+
let entries;
|
|
36
|
+
try {
|
|
37
|
+
entries = await readdir(root, { withFileTypes: true });
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (isEnoent(error))
|
|
41
|
+
return [];
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
const nested = await Promise.all(entries.map(async (entry) => {
|
|
45
|
+
const path = join(root, entry.name);
|
|
46
|
+
if (entry.isDirectory())
|
|
47
|
+
return listFiles(path);
|
|
48
|
+
return entry.isFile() ? [path] : [];
|
|
49
|
+
}));
|
|
50
|
+
return nested.flat();
|
|
51
|
+
}
|
|
52
|
+
function isEnoent(error) {
|
|
53
|
+
return !!error && typeof error === "object" && "code" in error && error.code === "ENOENT";
|
|
54
|
+
}
|