@zhixuan92/multi-model-agent-core 4.7.9 → 4.7.11
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/README.md +1 -72
- package/dist/bounded-execution/stall-watchdog.d.ts.map +1 -1
- package/dist/bounded-execution/stall-watchdog.js +28 -4
- package/dist/bounded-execution/stall-watchdog.js.map +1 -1
- package/dist/config/schema.d.ts +0 -2
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +0 -2
- package/dist/config/schema.js.map +1 -1
- package/dist/events/task-envelope.d.ts +11 -1
- package/dist/events/task-envelope.d.ts.map +1 -1
- package/dist/events/task-envelope.js +35 -4
- package/dist/events/task-envelope.js.map +1 -1
- package/dist/index.d.ts +0 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -8
- package/dist/index.js.map +1 -1
- package/dist/{review → lifecycle/handlers}/parse-review-report.d.ts +1 -1
- package/dist/lifecycle/handlers/parse-review-report.d.ts.map +1 -0
- package/dist/{review → lifecycle/handlers}/parse-review-report.js +2 -2
- package/dist/lifecycle/handlers/parse-review-report.js.map +1 -0
- package/dist/lifecycle/handlers/quality-review-prompt.d.ts +6 -0
- package/dist/lifecycle/handlers/quality-review-prompt.d.ts.map +1 -0
- package/dist/lifecycle/handlers/quality-review-prompt.js +42 -0
- package/dist/lifecycle/handlers/quality-review-prompt.js.map +1 -0
- package/dist/lifecycle/handlers/review-stage.js +4 -4
- package/dist/lifecycle/handlers/review-stage.js.map +1 -1
- package/dist/lifecycle/handlers/rework-prompt.d.ts +6 -0
- package/dist/lifecycle/handlers/rework-prompt.d.ts.map +1 -0
- package/dist/lifecycle/handlers/rework-prompt.js +18 -0
- package/dist/lifecycle/handlers/rework-prompt.js.map +1 -0
- package/dist/lifecycle/handlers/rework-stage.js +2 -2
- package/dist/lifecycle/handlers/rework-stage.js.map +1 -1
- package/dist/lifecycle/handlers/spec-review-prompt.d.ts +7 -0
- package/dist/lifecycle/handlers/spec-review-prompt.d.ts.map +1 -0
- package/dist/lifecycle/handlers/spec-review-prompt.js +39 -0
- package/dist/lifecycle/handlers/spec-review-prompt.js.map +1 -0
- package/dist/{review → lifecycle/handlers}/tier-policy.d.ts +1 -1
- package/dist/lifecycle/handlers/tier-policy.d.ts.map +1 -0
- package/dist/lifecycle/handlers/tier-policy.js.map +1 -0
- package/dist/lifecycle/lifecycle-driver.d.ts.map +1 -1
- package/dist/lifecycle/lifecycle-driver.js +14 -4
- package/dist/lifecycle/lifecycle-driver.js.map +1 -1
- package/dist/lifecycle/review-verdict-mapping.d.ts.map +1 -0
- package/dist/lifecycle/review-verdict-mapping.js.map +1 -0
- package/dist/lifecycle/task-executor.js +1 -1
- package/dist/lifecycle/task-executor.js.map +1 -1
- package/dist/lifecycle/tool-config-types.d.ts +0 -6
- package/dist/lifecycle/tool-config-types.d.ts.map +1 -1
- package/dist/providers/codex-cli-session.d.ts.map +1 -1
- package/dist/providers/codex-cli-session.js +39 -22
- package/dist/providers/codex-cli-session.js.map +1 -1
- package/dist/reporting/report-parser-slots/research-report.d.ts +0 -3
- package/dist/reporting/report-parser-slots/research-report.d.ts.map +1 -1
- package/dist/reporting/report-parser-slots/research-report.js +0 -5
- package/dist/reporting/report-parser-slots/research-report.js.map +1 -1
- package/dist/research/web-fetch.d.ts +24 -4
- package/dist/research/web-fetch.d.ts.map +1 -1
- package/dist/research/web-fetch.js +57 -42
- package/dist/research/web-fetch.js.map +1 -1
- package/dist/stores/batch-registry.d.ts +0 -15
- package/dist/stores/batch-registry.d.ts.map +1 -1
- package/dist/stores/batch-registry.js +2 -0
- package/dist/stores/batch-registry.js.map +1 -1
- package/dist/stores/project-context-registry.d.ts +4 -11
- package/dist/stores/project-context-registry.d.ts.map +1 -1
- package/dist/stores/project-context-registry.js +4 -6
- package/dist/stores/project-context-registry.js.map +1 -1
- package/dist/tools/audit/tool-config.d.ts.map +1 -1
- package/dist/tools/audit/tool-config.js +1 -5
- package/dist/tools/audit/tool-config.js.map +1 -1
- package/dist/tools/debug/tool-config.d.ts.map +1 -1
- package/dist/tools/debug/tool-config.js +1 -5
- package/dist/tools/debug/tool-config.js.map +1 -1
- package/dist/tools/delegate/tool-config.d.ts.map +1 -1
- package/dist/tools/delegate/tool-config.js +0 -6
- package/dist/tools/delegate/tool-config.js.map +1 -1
- package/dist/tools/execute-plan/tool-config.d.ts.map +1 -1
- package/dist/tools/execute-plan/tool-config.js +0 -6
- package/dist/tools/execute-plan/tool-config.js.map +1 -1
- package/dist/tools/investigate/tool-config.d.ts.map +1 -1
- package/dist/tools/investigate/tool-config.js +0 -4
- package/dist/tools/investigate/tool-config.js.map +1 -1
- package/dist/tools/review/tool-config.d.ts.map +1 -1
- package/dist/tools/review/tool-config.js +1 -5
- package/dist/tools/review/tool-config.js.map +1 -1
- package/dist/tools/shared/severity-ladder.d.ts +2 -0
- package/dist/tools/shared/severity-ladder.d.ts.map +1 -0
- package/dist/tools/shared/severity-ladder.js +9 -0
- package/dist/tools/shared/severity-ladder.js.map +1 -0
- package/dist/types/config.d.ts +0 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types.d.ts +0 -10
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -49
- package/dist/review/index.d.ts +0 -5
- package/dist/review/index.d.ts.map +0 -1
- package/dist/review/index.js +0 -8
- package/dist/review/index.js.map +0 -1
- package/dist/review/parse-review-report.d.ts.map +0 -1
- package/dist/review/parse-review-report.js.map +0 -1
- package/dist/review/review-types.d.ts +0 -2
- package/dist/review/review-types.d.ts.map +0 -1
- package/dist/review/review-types.js +0 -6
- package/dist/review/review-types.js.map +0 -1
- package/dist/review/review-verdict-mapping.d.ts.map +0 -1
- package/dist/review/review-verdict-mapping.js.map +0 -1
- package/dist/review/skipped-result.d.ts +0 -8
- package/dist/review/skipped-result.d.ts.map +0 -1
- package/dist/review/skipped-result.js +0 -4
- package/dist/review/skipped-result.js.map +0 -1
- package/dist/review/templates/annotator-audit.d.ts +0 -3
- package/dist/review/templates/annotator-audit.d.ts.map +0 -1
- package/dist/review/templates/annotator-audit.js +0 -20
- package/dist/review/templates/annotator-audit.js.map +0 -1
- package/dist/review/templates/annotator-debug.d.ts +0 -3
- package/dist/review/templates/annotator-debug.d.ts.map +0 -1
- package/dist/review/templates/annotator-debug.js +0 -19
- package/dist/review/templates/annotator-debug.js.map +0 -1
- package/dist/review/templates/annotator-investigate.d.ts +0 -3
- package/dist/review/templates/annotator-investigate.d.ts.map +0 -1
- package/dist/review/templates/annotator-investigate.js +0 -17
- package/dist/review/templates/annotator-investigate.js.map +0 -1
- package/dist/review/templates/annotator-review.d.ts +0 -3
- package/dist/review/templates/annotator-review.d.ts.map +0 -1
- package/dist/review/templates/annotator-review.js +0 -22
- package/dist/review/templates/annotator-review.js.map +0 -1
- package/dist/review/templates/annotator-shared.d.ts +0 -23
- package/dist/review/templates/annotator-shared.d.ts.map +0 -1
- package/dist/review/templates/annotator-shared.js +0 -51
- package/dist/review/templates/annotator-shared.js.map +0 -1
- package/dist/review/templates/finding-criteria.d.ts +0 -15
- package/dist/review/templates/finding-criteria.d.ts.map +0 -1
- package/dist/review/templates/finding-criteria.js +0 -39
- package/dist/review/templates/finding-criteria.js.map +0 -1
- package/dist/review/templates/quality-review-audit.d.ts +0 -3
- package/dist/review/templates/quality-review-audit.d.ts.map +0 -1
- package/dist/review/templates/quality-review-audit.js +0 -10
- package/dist/review/templates/quality-review-audit.js.map +0 -1
- package/dist/review/templates/quality-review-debug.d.ts +0 -3
- package/dist/review/templates/quality-review-debug.d.ts.map +0 -1
- package/dist/review/templates/quality-review-debug.js +0 -10
- package/dist/review/templates/quality-review-debug.js.map +0 -1
- package/dist/review/templates/quality-review-investigate.d.ts +0 -3
- package/dist/review/templates/quality-review-investigate.d.ts.map +0 -1
- package/dist/review/templates/quality-review-investigate.js +0 -10
- package/dist/review/templates/quality-review-investigate.js.map +0 -1
- package/dist/review/templates/quality-review-review.d.ts +0 -3
- package/dist/review/templates/quality-review-review.d.ts.map +0 -1
- package/dist/review/templates/quality-review-review.js +0 -10
- package/dist/review/templates/quality-review-review.js.map +0 -1
- package/dist/review/templates/quality-review.d.ts +0 -9
- package/dist/review/templates/quality-review.d.ts.map +0 -1
- package/dist/review/templates/quality-review.js +0 -89
- package/dist/review/templates/quality-review.js.map +0 -1
- package/dist/review/templates/rework.d.ts +0 -3
- package/dist/review/templates/rework.d.ts.map +0 -1
- package/dist/review/templates/rework.js +0 -48
- package/dist/review/templates/rework.js.map +0 -1
- package/dist/review/templates/shared.d.ts +0 -67
- package/dist/review/templates/shared.d.ts.map +0 -1
- package/dist/review/templates/shared.js +0 -2
- package/dist/review/templates/shared.js.map +0 -1
- package/dist/review/templates/spec-review.d.ts +0 -10
- package/dist/review/templates/spec-review.d.ts.map +0 -1
- package/dist/review/templates/spec-review.js +0 -75
- package/dist/review/templates/spec-review.js.map +0 -1
- package/dist/review/tier-policy.d.ts.map +0 -1
- package/dist/review/tier-policy.js.map +0 -1
- package/dist/stores/context-block-project-cap.d.ts +0 -14
- package/dist/stores/context-block-project-cap.d.ts.map +0 -1
- package/dist/stores/context-block-project-cap.js +0 -80
- package/dist/stores/context-block-project-cap.js.map +0 -1
- package/dist/stores/file-backed-context-block-store.d.ts +0 -81
- package/dist/stores/file-backed-context-block-store.d.ts.map +0 -1
- package/dist/stores/file-backed-context-block-store.js +0 -410
- package/dist/stores/file-backed-context-block-store.js.map +0 -1
- package/dist/stores/index.d.ts +0 -4
- package/dist/stores/index.d.ts.map +0 -1
- package/dist/stores/index.js +0 -5
- package/dist/stores/index.js.map +0 -1
- package/dist/tool-surface/discover.d.ts +0 -29
- package/dist/tool-surface/discover.d.ts.map +0 -1
- package/dist/tool-surface/discover.js +0 -102
- package/dist/tool-surface/discover.js.map +0 -1
- package/dist/tool-surface/include-utils.d.ts +0 -27
- package/dist/tool-surface/include-utils.d.ts.map +0 -1
- package/dist/tool-surface/include-utils.js +0 -90
- package/dist/tool-surface/include-utils.js.map +0 -1
- package/dist/tool-surface/index.d.ts +0 -6
- package/dist/tool-surface/index.d.ts.map +0 -1
- package/dist/tool-surface/index.js +0 -7
- package/dist/tool-surface/index.js.map +0 -1
- package/dist/tool-surface/manifest.d.ts +0 -94
- package/dist/tool-surface/manifest.d.ts.map +0 -1
- package/dist/tool-surface/manifest.js +0 -234
- package/dist/tool-surface/manifest.js.map +0 -1
- package/dist/tool-surface/openapi-generator.d.ts +0 -15
- package/dist/tool-surface/openapi-generator.d.ts.map +0 -1
- package/dist/tool-surface/openapi-generator.js +0 -259
- package/dist/tool-surface/openapi-generator.js.map +0 -1
- package/dist/tool-surface/skill-installer-common.d.ts +0 -48
- package/dist/tool-surface/skill-installer-common.d.ts.map +0 -1
- package/dist/tool-surface/skill-installer-common.js +0 -195
- package/dist/tool-surface/skill-installer-common.js.map +0 -1
- package/dist/tool-surface/skill-installer.d.ts +0 -10
- package/dist/tool-surface/skill-installer.d.ts.map +0 -1
- package/dist/tool-surface/skill-installer.js +0 -20
- package/dist/tool-surface/skill-installer.js.map +0 -1
- package/dist/tool-surface/skill-installers/claude-code.d.ts +0 -43
- package/dist/tool-surface/skill-installers/claude-code.d.ts.map +0 -1
- package/dist/tool-surface/skill-installers/claude-code.js +0 -65
- package/dist/tool-surface/skill-installers/claude-code.js.map +0 -1
- package/dist/tool-surface/skill-installers/codex-cli.d.ts +0 -27
- package/dist/tool-surface/skill-installers/codex-cli.d.ts.map +0 -1
- package/dist/tool-surface/skill-installers/codex-cli.js +0 -84
- package/dist/tool-surface/skill-installers/codex-cli.js.map +0 -1
- package/dist/tool-surface/skill-installers/cursor.d.ts +0 -72
- package/dist/tool-surface/skill-installers/cursor.d.ts.map +0 -1
- package/dist/tool-surface/skill-installers/cursor.js +0 -81
- package/dist/tool-surface/skill-installers/cursor.js.map +0 -1
- package/dist/tool-surface/skill-installers/gemini-cli.d.ts +0 -66
- package/dist/tool-surface/skill-installers/gemini-cli.d.ts.map +0 -1
- package/dist/tool-surface/skill-installers/gemini-cli.js +0 -111
- package/dist/tool-surface/skill-installers/gemini-cli.js.map +0 -1
- package/dist/tool-surface/skill-manifest-sync.d.ts +0 -11
- package/dist/tool-surface/skill-manifest-sync.d.ts.map +0 -1
- package/dist/tool-surface/skill-manifest-sync.js +0 -65
- package/dist/tool-surface/skill-manifest-sync.js.map +0 -1
- /package/dist/{review → lifecycle/handlers}/tier-policy.js +0 -0
- /package/dist/{review → lifecycle}/review-verdict-mapping.d.ts +0 -0
- /package/dist/{review → lifecycle}/review-verdict-mapping.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-block-project-cap.d.ts","sourceRoot":"","sources":["../../src/stores/context-block-project-cap.ts"],"names":[],"mappings":"AAyBA;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAgBlE;AAED,wBAAgB,eAAe,CAC7B,iBAAiB,EAAE,MAAM,EACzB,WAAW,EAAE,MAAM,EACnB,eAAe,GAAE,WAAW,CAAC,MAAM,CAAa,GAC/C;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAoBnC"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Outer LRU sweep for the context-block project directory.
|
|
3
|
-
*
|
|
4
|
-
* Walks all project-hash subdirectories under `contextBlocksRoot`. If the
|
|
5
|
-
* count exceeds `maxProjects`, removes (rm -rf) the oldest-mtime project
|
|
6
|
-
* directories until the count is at or below cap. mtime of the project
|
|
7
|
-
* directory is used as the recency signal — directory mtime updates
|
|
8
|
-
* whenever a file inside is added/removed, so it tracks last activity.
|
|
9
|
-
*
|
|
10
|
-
* For empty project dirs (no files), the dir's own mtime is the signal,
|
|
11
|
-
* which is stable from creation; they typically rank lower than active
|
|
12
|
-
* projects and fall off first.
|
|
13
|
-
*
|
|
14
|
-
* Active-aware: when `protectedHashes` is supplied, no entry in that set
|
|
15
|
-
* is evicted regardless of mtime rank. Callers pass it for projects that
|
|
16
|
-
* are currently registered in the in-memory `ProjectContextRegistry`, so
|
|
17
|
-
* a startup sweep cannot wipe a directory the running daemon is about to
|
|
18
|
-
* write to. Startup-only callers may pass an empty set safely.
|
|
19
|
-
*
|
|
20
|
-
* No-op when the count is at or under cap. Synchronous (called once at
|
|
21
|
-
* daemon startup, low expected cost).
|
|
22
|
-
*/
|
|
23
|
-
import * as fs from 'node:fs';
|
|
24
|
-
import * as path from 'node:path';
|
|
25
|
-
/**
|
|
26
|
-
* Per-project recency signal — the value used to decide LRU ordering.
|
|
27
|
-
* For non-empty dirs: max(mtime of any file). For empty dirs: dir mtime.
|
|
28
|
-
*
|
|
29
|
-
* This helper is exported so the storage migration (A1.7) can use the
|
|
30
|
-
* same calculation. Without sharing, the two code paths can drift and
|
|
31
|
-
* different "recent" projects survive a sweep vs a migration.
|
|
32
|
-
*/
|
|
33
|
-
export function computeProjectRecencyMs(projectDir) {
|
|
34
|
-
let mtimeMs = 0;
|
|
35
|
-
try {
|
|
36
|
-
const files = fs.readdirSync(projectDir);
|
|
37
|
-
if (files.length === 0) {
|
|
38
|
-
mtimeMs = fs.statSync(projectDir).mtimeMs;
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
for (const f of files) {
|
|
42
|
-
try {
|
|
43
|
-
const m = fs.statSync(path.join(projectDir, f)).mtimeMs;
|
|
44
|
-
if (m > mtimeMs)
|
|
45
|
-
mtimeMs = m;
|
|
46
|
-
}
|
|
47
|
-
catch { /* skip */ }
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
catch { /* skip */ }
|
|
52
|
-
return mtimeMs;
|
|
53
|
-
}
|
|
54
|
-
export function sweepProjectCap(contextBlocksRoot, maxProjects, protectedHashes = new Set()) {
|
|
55
|
-
if (!fs.existsSync(contextBlocksRoot))
|
|
56
|
-
return { kept: 0, evicted: 0 };
|
|
57
|
-
const entries = fs.readdirSync(contextBlocksRoot, { withFileTypes: true });
|
|
58
|
-
const projects = entries
|
|
59
|
-
.filter(e => e.isDirectory())
|
|
60
|
-
.map(e => ({ name: e.name, mtimeMs: computeProjectRecencyMs(path.join(contextBlocksRoot, e.name)) }));
|
|
61
|
-
if (projects.length <= maxProjects)
|
|
62
|
-
return { kept: projects.length, evicted: 0 };
|
|
63
|
-
// Pin protected (active) projects to the keep set unconditionally —
|
|
64
|
-
// they count against `maxProjects` but cannot be selected for eviction.
|
|
65
|
-
// The remaining slots are filled by mtime-LRU over the rest.
|
|
66
|
-
const protectedProjects = projects.filter(p => protectedHashes.has(p.name));
|
|
67
|
-
const others = projects.filter(p => !protectedHashes.has(p.name));
|
|
68
|
-
others.sort((a, b) => b.mtimeMs - a.mtimeMs);
|
|
69
|
-
const remainingSlots = Math.max(0, maxProjects - protectedProjects.length);
|
|
70
|
-
const keepOthers = others.slice(0, remainingSlots);
|
|
71
|
-
const drop = others.slice(remainingSlots);
|
|
72
|
-
for (const p of drop) {
|
|
73
|
-
try {
|
|
74
|
-
fs.rmSync(path.join(contextBlocksRoot, p.name), { recursive: true, force: true });
|
|
75
|
-
}
|
|
76
|
-
catch { /* skip */ }
|
|
77
|
-
}
|
|
78
|
-
return { kept: protectedProjects.length + keepOthers.length, evicted: drop.length };
|
|
79
|
-
}
|
|
80
|
-
//# sourceMappingURL=context-block-project-cap.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-block-project-cap.js","sourceRoot":"","sources":["../../src/stores/context-block-project-cap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CAAC,UAAkB;IACxD,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC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AC"}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { type ContextBlockStore, type RegisteredBlock } from './context-block-tool.js';
|
|
2
|
-
export interface FileBackedContextBlockStoreOptions {
|
|
3
|
-
/** Idle TTL in milliseconds. Defaults to 7 days. */
|
|
4
|
-
ttlMs?: number;
|
|
5
|
-
/** How often `register()` opportunistically sweeps. Defaults to 1 hour. */
|
|
6
|
-
gcCheckIntervalMs?: number;
|
|
7
|
-
/** Max bytes per block (UTF-8). Defaults to 1 MiB. */
|
|
8
|
-
maxBlockBytes?: number;
|
|
9
|
-
/** Max total bytes on disk. Defaults to 100 MiB. */
|
|
10
|
-
maxTotalBytes?: number;
|
|
11
|
-
/** Override `os.homedir()` — used by tests for filesystem isolation. */
|
|
12
|
-
homeDir?: string;
|
|
13
|
-
maxBlocksPerProject?: number;
|
|
14
|
-
}
|
|
15
|
-
export declare class FileBackedContextBlockStore implements ContextBlockStore {
|
|
16
|
-
/** Absolute root: `<homeDir>/.multi-model/context-blocks/<sha256(projectCwd)>`.
|
|
17
|
-
* Public so tests can read meta files directly without re-deriving the path. */
|
|
18
|
-
readonly rootDir: string;
|
|
19
|
-
private _ttlMs;
|
|
20
|
-
private gcCheckIntervalMs;
|
|
21
|
-
private maxBlockBytes;
|
|
22
|
-
private maxTotalBytes;
|
|
23
|
-
private lastSweepMs;
|
|
24
|
-
/** Pin counts are kept in memory only — they're an active-batch
|
|
25
|
-
* protection signal, not a persistence concern. Lost on restart;
|
|
26
|
-
* TTL-based GC handles the recovery side. */
|
|
27
|
-
private pinCounts;
|
|
28
|
-
private readonly maxBlocksPerProject;
|
|
29
|
-
constructor(projectCwd: string, opts?: FileBackedContextBlockStoreOptions);
|
|
30
|
-
register(content: string, opts?: {
|
|
31
|
-
ttlMs?: number;
|
|
32
|
-
id?: string;
|
|
33
|
-
}): RegisteredBlock;
|
|
34
|
-
get(id: string): string | undefined;
|
|
35
|
-
delete(id: string): boolean;
|
|
36
|
-
pin(id: string): void;
|
|
37
|
-
unpin(id: string): void;
|
|
38
|
-
refcount(id: string): number;
|
|
39
|
-
runIdleSweep(now: number, idleTtlMs: number): number;
|
|
40
|
-
get ttlMs(): number;
|
|
41
|
-
/** Number of entries currently on disk (counted by id, not by file —
|
|
42
|
-
* orphan halves count once). */
|
|
43
|
-
get size(): number;
|
|
44
|
-
/** Delete every block. Used by project-registry on idle eviction. */
|
|
45
|
-
clear(): void;
|
|
46
|
-
/** Sum of all on-disk content bytes (no caching — fresh read each call).
|
|
47
|
-
* Used by tests + `evictUntilFits`. */
|
|
48
|
-
totalBytesOnDisk(): number;
|
|
49
|
-
private ensureRoot;
|
|
50
|
-
private contentPath;
|
|
51
|
-
private metaPath;
|
|
52
|
-
private listIds;
|
|
53
|
-
private readMeta;
|
|
54
|
-
private deleteFiles;
|
|
55
|
-
/**
|
|
56
|
-
* Atomic write: temp-file → fsync → rename. Recovers cleanly from
|
|
57
|
-
* daemon SIGKILL mid-write — readers either see the old content or
|
|
58
|
-
* the new content, never a partial write. The .tmp suffix uses a
|
|
59
|
-
* random nonce so concurrent writers don't collide.
|
|
60
|
-
*
|
|
61
|
-
* Defensive: `ensureRoot()` runs once at construction, but the
|
|
62
|
-
* rootDir can disappear between construction and write — e.g. an
|
|
63
|
-
* external rm, a maintenance script, or (historically) a startup-time
|
|
64
|
-
* project-cap sweep that ran in a different process. Re-creating the
|
|
65
|
-
* dir here is idempotent and cheap; the alternative is an ENOENT that
|
|
66
|
-
* crashes the entire batch and burns its findings.
|
|
67
|
-
*/
|
|
68
|
-
private atomicWrite;
|
|
69
|
-
/** TTL pass first; if still at or above maxBlocksPerProject, evict oldest-mtime block(s) until under cap. */
|
|
70
|
-
private sweepInnerLruIfNeeded;
|
|
71
|
-
/**
|
|
72
|
-
* Oldest-first eviction loop until total disk usage + incoming bytes
|
|
73
|
-
* fits under maxTotalBytes. Pinned entries are skipped (matches
|
|
74
|
-
* in-memory store semantics — pinned blocks are held by an active
|
|
75
|
-
* batch and shouldn't be evicted mid-run).
|
|
76
|
-
*/
|
|
77
|
-
private evictUntilFits;
|
|
78
|
-
/** Scan this project's meta files for one whose recorded sha256 matches `sha256`. Returns the id, or null. */
|
|
79
|
-
private findByContentSha;
|
|
80
|
-
}
|
|
81
|
-
//# sourceMappingURL=file-backed-context-block-store.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-backed-context-block-store.d.ts","sourceRoot":"","sources":["../../src/stores/file-backed-context-block-store.ts"],"names":[],"mappings":"AA0CA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACrB,MAAM,yBAAyB,CAAC;AAcjC,MAAM,WAAW,kCAAkC;IACjD,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,qBAAa,2BAA4B,YAAW,iBAAiB;IACnE;qFACiF;IACjF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,WAAW,CAAK;IACxB;;kDAE8C;IAC9C,OAAO,CAAC,SAAS,CAA6B;IAC9C,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAS;gBAEjC,UAAU,EAAE,MAAM,EAAE,IAAI,GAAE,kCAAuC;IAqB7E,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,eAAe;IA0DtF,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAoBnC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAO3B,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAIrB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAMvB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAI5B,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM;IAuBpD,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;qCACiC;IACjC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,qEAAqE;IACrE,KAAK,IAAI,IAAI;IAKb;4CACwC;IACxC,gBAAgB,IAAI,MAAM;IAc1B,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,OAAO;IAef,OAAO,CAAC,QAAQ;IAkBhB,OAAO,CAAC,WAAW;IAKnB;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,WAAW;IAanB,6GAA6G;IAC7G,OAAO,CAAC,qBAAqB;IAqC7B;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAwBtB,8GAA8G;IAC9G,OAAO,CAAC,gBAAgB;CAczB"}
|
|
@@ -1,410 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* FileBackedContextBlockStore — disk-backed implementation of
|
|
3
|
-
* `ContextBlockStore` so context blocks survive daemon restarts.
|
|
4
|
-
*
|
|
5
|
-
* Per the wire-telemetry-gaps plan, Gap 4: round-over-round audit is the
|
|
6
|
-
* documented use case for context blocks; a memory-only store loses
|
|
7
|
-
* everything on `npm run serve` cycles, breaking the recipe. This store
|
|
8
|
-
* persists to disk and reloads lazily on first access.
|
|
9
|
-
*
|
|
10
|
-
* Layout: `<homeDir>/.multi-model/context-blocks/<sha256(projectCwd)>/<id>.txt`
|
|
11
|
-
* (content) + `<id>.meta.json` ({ createdAt, ttlMs, lengthChars, sha256 }).
|
|
12
|
-
* Storing in the user home (not the project tree) keeps repos clean —
|
|
13
|
-
* no `.gitignore` entries needed — while the per-project hash subdir
|
|
14
|
-
* preserves project isolation.
|
|
15
|
-
*
|
|
16
|
-
* Operational properties:
|
|
17
|
-
* - **Authoritative cwd**: per-project subdir is `sha256(path.resolve(projectCwd))`.
|
|
18
|
-
* NOT daemon cwd, NOT task cwd.
|
|
19
|
-
* - **Permissions**: directories `0700`, files `0600`. Audit findings
|
|
20
|
-
* can carry sensitive code excerpts; user-only access by default.
|
|
21
|
-
* - **TTL**: 7 days default. Enforced on `get()` (lazy delete on
|
|
22
|
-
* stale read), at the start of `register()` (opportunistic GC if
|
|
23
|
-
* last sweep was over `gcCheckIntervalMs` ago), and via
|
|
24
|
-
* `runIdleSweep()` for periodic timer-driven sweeps.
|
|
25
|
-
* - **Size caps**: per-block 1 MiB, per-store 100 MiB total — measured
|
|
26
|
-
* via `Buffer.byteLength(content, 'utf8')` so multi-byte content
|
|
27
|
-
* can't sneak past the cap. Oldest-first eviction when total cap
|
|
28
|
-
* is exceeded.
|
|
29
|
-
* - **Atomic writes**: temp-file → fsync → rename. GC treats orphaned
|
|
30
|
-
* pairs (content without metadata or vice versa) as corrupt and
|
|
31
|
-
* deletes both — recovers cleanly from daemon SIGKILL mid-write.
|
|
32
|
-
*
|
|
33
|
-
* Pinning is a no-op on this implementation — disk persistence is
|
|
34
|
-
* stronger than the in-memory pin contract. The `pin`/`unpin` methods
|
|
35
|
-
* exist on the interface for API symmetry and to satisfy the LRU-skip
|
|
36
|
-
* contract that batch-registry expects, but disk eviction always
|
|
37
|
-
* respects TTL only.
|
|
38
|
-
*/
|
|
39
|
-
import { createHash, randomUUID } from 'node:crypto';
|
|
40
|
-
import * as fs from 'node:fs';
|
|
41
|
-
import * as os from 'node:os';
|
|
42
|
-
import * as path from 'node:path';
|
|
43
|
-
const DEFAULT_TTL_MS = 7 * 24 * 60 * 60 * 1000;
|
|
44
|
-
const DEFAULT_GC_INTERVAL_MS = 60 * 60 * 1000;
|
|
45
|
-
const DEFAULT_MAX_BLOCK_BYTES = 1 * 1024 * 1024;
|
|
46
|
-
const DEFAULT_MAX_TOTAL_BYTES = 100 * 1024 * 1024;
|
|
47
|
-
export class FileBackedContextBlockStore {
|
|
48
|
-
/** Absolute root: `<homeDir>/.multi-model/context-blocks/<sha256(projectCwd)>`.
|
|
49
|
-
* Public so tests can read meta files directly without re-deriving the path. */
|
|
50
|
-
rootDir;
|
|
51
|
-
_ttlMs;
|
|
52
|
-
gcCheckIntervalMs;
|
|
53
|
-
maxBlockBytes;
|
|
54
|
-
maxTotalBytes;
|
|
55
|
-
lastSweepMs = 0;
|
|
56
|
-
/** Pin counts are kept in memory only — they're an active-batch
|
|
57
|
-
* protection signal, not a persistence concern. Lost on restart;
|
|
58
|
-
* TTL-based GC handles the recovery side. */
|
|
59
|
-
pinCounts = new Map();
|
|
60
|
-
maxBlocksPerProject;
|
|
61
|
-
constructor(projectCwd, opts = {}) {
|
|
62
|
-
const home = opts.homeDir ?? os.homedir();
|
|
63
|
-
let canonical;
|
|
64
|
-
try {
|
|
65
|
-
canonical = fs.realpathSync(path.resolve(projectCwd));
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
// Path doesn't exist on disk yet — fall back to absolute. The store is
|
|
69
|
-
// still usable for callers who pass a future cwd; symlink-collapse
|
|
70
|
-
// semantics only kick in once the path exists.
|
|
71
|
-
canonical = path.resolve(projectCwd);
|
|
72
|
-
}
|
|
73
|
-
const projectHash = createHash('sha256').update(canonical).digest('hex');
|
|
74
|
-
this.rootDir = path.join(home, '.multi-model', 'context-blocks', projectHash);
|
|
75
|
-
this._ttlMs = opts.ttlMs ?? DEFAULT_TTL_MS;
|
|
76
|
-
this.gcCheckIntervalMs = opts.gcCheckIntervalMs ?? DEFAULT_GC_INTERVAL_MS;
|
|
77
|
-
this.maxBlockBytes = opts.maxBlockBytes ?? DEFAULT_MAX_BLOCK_BYTES;
|
|
78
|
-
this.maxTotalBytes = opts.maxTotalBytes ?? DEFAULT_MAX_TOTAL_BYTES;
|
|
79
|
-
this.maxBlocksPerProject = opts.maxBlocksPerProject ?? 500;
|
|
80
|
-
this.ensureRoot();
|
|
81
|
-
}
|
|
82
|
-
register(content, opts = {}) {
|
|
83
|
-
const sha256 = createHash('sha256').update(content).digest('hex');
|
|
84
|
-
// 4.2.3+: fall back to the class-level _ttlMs default (configured at
|
|
85
|
-
// construction) rather than a hardcoded constant. Earlier draft of
|
|
86
|
-
// the plan literally said `?? 28_800_000` which broke the
|
|
87
|
-
// "lazy-deletes on get when entry is past TTL" pre-existing test —
|
|
88
|
-
// that test constructs the store with `ttlMs: 1` and then calls
|
|
89
|
-
// `register('x')` (no opts), expecting the per-call TTL to inherit
|
|
90
|
-
// the class default.
|
|
91
|
-
const ttlMs = opts.ttlMs ?? this._ttlMs;
|
|
92
|
-
// DEDUPE: look for existing block in this project with matching content sha
|
|
93
|
-
if (!opts.id) {
|
|
94
|
-
const existing = this.findByContentSha(sha256);
|
|
95
|
-
if (existing) {
|
|
96
|
-
// Bump mtime + reset TTL on the existing block
|
|
97
|
-
const now = Date.now();
|
|
98
|
-
const metaContent = JSON.parse(fs.readFileSync(this.metaPath(existing), 'utf8'));
|
|
99
|
-
metaContent.ttlMs = ttlMs;
|
|
100
|
-
metaContent.createdAt = now;
|
|
101
|
-
fs.writeFileSync(this.metaPath(existing), JSON.stringify(metaContent), { mode: 0o600 });
|
|
102
|
-
fs.utimesSync(this.contentPath(existing), now / 1000, now / 1000);
|
|
103
|
-
fs.utimesSync(this.metaPath(existing), now / 1000, now / 1000);
|
|
104
|
-
return { id: existing, lengthChars: content.length, sha256 };
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
const byteSize = Buffer.byteLength(content, 'utf8');
|
|
108
|
-
if (byteSize > this.maxBlockBytes) {
|
|
109
|
-
throw new Error(`Context block exceeds per-block cap of ${this.maxBlockBytes} bytes (got ${byteSize}).`);
|
|
110
|
-
}
|
|
111
|
-
const id = opts.id ?? randomUUID();
|
|
112
|
-
const now = Date.now();
|
|
113
|
-
const meta = {
|
|
114
|
-
createdAt: now,
|
|
115
|
-
ttlMs,
|
|
116
|
-
lengthChars: content.length,
|
|
117
|
-
sha256,
|
|
118
|
-
};
|
|
119
|
-
// Opportunistic GC + size-cap enforcement before we write.
|
|
120
|
-
if (now - this.lastSweepMs > this.gcCheckIntervalMs) {
|
|
121
|
-
this.runIdleSweep(now, this._ttlMs);
|
|
122
|
-
this.lastSweepMs = now;
|
|
123
|
-
}
|
|
124
|
-
this.evictUntilFits(byteSize);
|
|
125
|
-
this.sweepInnerLruIfNeeded();
|
|
126
|
-
this.atomicWrite(this.contentPath(id), content);
|
|
127
|
-
this.atomicWrite(this.metaPath(id), JSON.stringify(meta) + '\n');
|
|
128
|
-
return { id, lengthChars: content.length, sha256 };
|
|
129
|
-
}
|
|
130
|
-
get(id) {
|
|
131
|
-
const meta = this.readMeta(id);
|
|
132
|
-
if (!meta)
|
|
133
|
-
return undefined;
|
|
134
|
-
const now = Date.now();
|
|
135
|
-
if (now - meta.createdAt > meta.ttlMs) {
|
|
136
|
-
// Expired: lazy-delete (matches in-memory store semantics)
|
|
137
|
-
this.deleteFiles(id);
|
|
138
|
-
return undefined;
|
|
139
|
-
}
|
|
140
|
-
try {
|
|
141
|
-
return fs.readFileSync(this.contentPath(id), 'utf8');
|
|
142
|
-
}
|
|
143
|
-
catch {
|
|
144
|
-
// Content missing but meta present — orphan; clean up.
|
|
145
|
-
this.deleteFiles(id);
|
|
146
|
-
return undefined;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
delete(id) {
|
|
150
|
-
const existed = fs.existsSync(this.contentPath(id)) || fs.existsSync(this.metaPath(id));
|
|
151
|
-
this.deleteFiles(id);
|
|
152
|
-
this.pinCounts.delete(id);
|
|
153
|
-
return existed;
|
|
154
|
-
}
|
|
155
|
-
pin(id) {
|
|
156
|
-
this.pinCounts.set(id, (this.pinCounts.get(id) ?? 0) + 1);
|
|
157
|
-
}
|
|
158
|
-
unpin(id) {
|
|
159
|
-
const cur = this.pinCounts.get(id) ?? 0;
|
|
160
|
-
if (cur <= 1)
|
|
161
|
-
this.pinCounts.delete(id);
|
|
162
|
-
else
|
|
163
|
-
this.pinCounts.set(id, cur - 1);
|
|
164
|
-
}
|
|
165
|
-
refcount(id) {
|
|
166
|
-
return this.pinCounts.get(id) ?? 0;
|
|
167
|
-
}
|
|
168
|
-
runIdleSweep(now, idleTtlMs) {
|
|
169
|
-
let evicted = 0;
|
|
170
|
-
for (const id of this.listIds()) {
|
|
171
|
-
if ((this.pinCounts.get(id) ?? 0) > 0)
|
|
172
|
-
continue;
|
|
173
|
-
const meta = this.readMeta(id);
|
|
174
|
-
if (!meta) {
|
|
175
|
-
// Orphan content (no meta) — corrupt half-write recovery
|
|
176
|
-
this.deleteFiles(id);
|
|
177
|
-
evicted++;
|
|
178
|
-
continue;
|
|
179
|
-
}
|
|
180
|
-
// Use the entry's stored ttlMs (may differ from caller's idleTtlMs)
|
|
181
|
-
// OR caller's idleTtlMs, whichever is shorter — caller wins for
|
|
182
|
-
// explicit forced sweeps.
|
|
183
|
-
const effectiveTtl = Math.min(meta.ttlMs, idleTtlMs);
|
|
184
|
-
if (now - meta.createdAt > effectiveTtl) {
|
|
185
|
-
this.deleteFiles(id);
|
|
186
|
-
evicted++;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return evicted;
|
|
190
|
-
}
|
|
191
|
-
get ttlMs() {
|
|
192
|
-
return this._ttlMs;
|
|
193
|
-
}
|
|
194
|
-
/** Number of entries currently on disk (counted by id, not by file —
|
|
195
|
-
* orphan halves count once). */
|
|
196
|
-
get size() {
|
|
197
|
-
return this.listIds().length;
|
|
198
|
-
}
|
|
199
|
-
/** Delete every block. Used by project-registry on idle eviction. */
|
|
200
|
-
clear() {
|
|
201
|
-
for (const id of this.listIds())
|
|
202
|
-
this.deleteFiles(id);
|
|
203
|
-
this.pinCounts.clear();
|
|
204
|
-
}
|
|
205
|
-
/** Sum of all on-disk content bytes (no caching — fresh read each call).
|
|
206
|
-
* Used by tests + `evictUntilFits`. */
|
|
207
|
-
totalBytesOnDisk() {
|
|
208
|
-
let total = 0;
|
|
209
|
-
for (const id of this.listIds()) {
|
|
210
|
-
try {
|
|
211
|
-
total += fs.statSync(this.contentPath(id)).size;
|
|
212
|
-
}
|
|
213
|
-
catch {
|
|
214
|
-
// missing file — skip
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
return total;
|
|
218
|
-
}
|
|
219
|
-
// ── private helpers ────────────────────────────────────────────────
|
|
220
|
-
ensureRoot() {
|
|
221
|
-
fs.mkdirSync(this.rootDir, { recursive: true, mode: 0o700 });
|
|
222
|
-
}
|
|
223
|
-
contentPath(id) {
|
|
224
|
-
return path.join(this.rootDir, `${id}.txt`);
|
|
225
|
-
}
|
|
226
|
-
metaPath(id) {
|
|
227
|
-
return path.join(this.rootDir, `${id}.meta.json`);
|
|
228
|
-
}
|
|
229
|
-
listIds() {
|
|
230
|
-
let entries;
|
|
231
|
-
try {
|
|
232
|
-
entries = fs.readdirSync(this.rootDir);
|
|
233
|
-
}
|
|
234
|
-
catch {
|
|
235
|
-
return [];
|
|
236
|
-
}
|
|
237
|
-
const ids = new Set();
|
|
238
|
-
for (const name of entries) {
|
|
239
|
-
if (name.endsWith('.meta.json'))
|
|
240
|
-
ids.add(name.slice(0, -'.meta.json'.length));
|
|
241
|
-
else if (name.endsWith('.txt'))
|
|
242
|
-
ids.add(name.slice(0, -'.txt'.length));
|
|
243
|
-
}
|
|
244
|
-
return [...ids];
|
|
245
|
-
}
|
|
246
|
-
readMeta(id) {
|
|
247
|
-
try {
|
|
248
|
-
const raw = fs.readFileSync(this.metaPath(id), 'utf8');
|
|
249
|
-
const parsed = JSON.parse(raw);
|
|
250
|
-
if (typeof parsed.createdAt === 'number'
|
|
251
|
-
&& typeof parsed.ttlMs === 'number'
|
|
252
|
-
&& typeof parsed.lengthChars === 'number'
|
|
253
|
-
&& typeof parsed.sha256 === 'string') {
|
|
254
|
-
return parsed;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
catch {
|
|
258
|
-
// unreadable / corrupt
|
|
259
|
-
}
|
|
260
|
-
return undefined;
|
|
261
|
-
}
|
|
262
|
-
deleteFiles(id) {
|
|
263
|
-
try {
|
|
264
|
-
fs.unlinkSync(this.contentPath(id));
|
|
265
|
-
}
|
|
266
|
-
catch { /* ignore */ }
|
|
267
|
-
try {
|
|
268
|
-
fs.unlinkSync(this.metaPath(id));
|
|
269
|
-
}
|
|
270
|
-
catch { /* ignore */ }
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Atomic write: temp-file → fsync → rename. Recovers cleanly from
|
|
274
|
-
* daemon SIGKILL mid-write — readers either see the old content or
|
|
275
|
-
* the new content, never a partial write. The .tmp suffix uses a
|
|
276
|
-
* random nonce so concurrent writers don't collide.
|
|
277
|
-
*
|
|
278
|
-
* Defensive: `ensureRoot()` runs once at construction, but the
|
|
279
|
-
* rootDir can disappear between construction and write — e.g. an
|
|
280
|
-
* external rm, a maintenance script, or (historically) a startup-time
|
|
281
|
-
* project-cap sweep that ran in a different process. Re-creating the
|
|
282
|
-
* dir here is idempotent and cheap; the alternative is an ENOENT that
|
|
283
|
-
* crashes the entire batch and burns its findings.
|
|
284
|
-
*/
|
|
285
|
-
atomicWrite(targetPath, content) {
|
|
286
|
-
fs.mkdirSync(path.dirname(targetPath), { recursive: true, mode: 0o700 });
|
|
287
|
-
const tmpPath = `${targetPath}.tmp.${process.pid}.${randomUUID()}`;
|
|
288
|
-
const fd = fs.openSync(tmpPath, 'w', 0o600);
|
|
289
|
-
try {
|
|
290
|
-
fs.writeSync(fd, content);
|
|
291
|
-
fs.fsyncSync(fd);
|
|
292
|
-
}
|
|
293
|
-
finally {
|
|
294
|
-
fs.closeSync(fd);
|
|
295
|
-
}
|
|
296
|
-
fs.renameSync(tmpPath, targetPath);
|
|
297
|
-
}
|
|
298
|
-
/** TTL pass first; if still at or above maxBlocksPerProject, evict oldest-mtime block(s) until under cap. */
|
|
299
|
-
sweepInnerLruIfNeeded() {
|
|
300
|
-
if (!fs.existsSync(this.rootDir))
|
|
301
|
-
return;
|
|
302
|
-
// TTL pass
|
|
303
|
-
const now = Date.now();
|
|
304
|
-
const files = fs.readdirSync(this.rootDir);
|
|
305
|
-
for (const file of files) {
|
|
306
|
-
if (!file.endsWith('.meta.json'))
|
|
307
|
-
continue;
|
|
308
|
-
try {
|
|
309
|
-
const meta = JSON.parse(fs.readFileSync(path.join(this.rootDir, file), 'utf8'));
|
|
310
|
-
if (typeof meta.createdAt === 'number' && typeof meta.ttlMs === 'number' && now > meta.createdAt + meta.ttlMs) {
|
|
311
|
-
const id = file.slice(0, -'.meta.json'.length);
|
|
312
|
-
try {
|
|
313
|
-
fs.unlinkSync(path.join(this.rootDir, `${id}.txt`));
|
|
314
|
-
}
|
|
315
|
-
catch { }
|
|
316
|
-
try {
|
|
317
|
-
fs.unlinkSync(path.join(this.rootDir, `${id}.meta.json`));
|
|
318
|
-
}
|
|
319
|
-
catch { }
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
catch { /* skip malformed */ }
|
|
323
|
-
}
|
|
324
|
-
// LRU pass
|
|
325
|
-
let blockIds = fs.readdirSync(this.rootDir)
|
|
326
|
-
.filter(f => f.endsWith('.txt'))
|
|
327
|
-
.map(f => f.slice(0, -'.txt'.length));
|
|
328
|
-
while (blockIds.length >= this.maxBlocksPerProject) {
|
|
329
|
-
// Find oldest-mtime block
|
|
330
|
-
let oldestId = null;
|
|
331
|
-
let oldestMtime = Infinity;
|
|
332
|
-
for (const id of blockIds) {
|
|
333
|
-
try {
|
|
334
|
-
const m = fs.statSync(path.join(this.rootDir, `${id}.txt`)).mtimeMs;
|
|
335
|
-
if (m < oldestMtime) {
|
|
336
|
-
oldestMtime = m;
|
|
337
|
-
oldestId = id;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
catch { /* skip */ }
|
|
341
|
-
}
|
|
342
|
-
if (!oldestId)
|
|
343
|
-
break;
|
|
344
|
-
try {
|
|
345
|
-
fs.unlinkSync(path.join(this.rootDir, `${oldestId}.txt`));
|
|
346
|
-
}
|
|
347
|
-
catch { }
|
|
348
|
-
try {
|
|
349
|
-
fs.unlinkSync(path.join(this.rootDir, `${oldestId}.meta.json`));
|
|
350
|
-
}
|
|
351
|
-
catch { }
|
|
352
|
-
blockIds = blockIds.filter(i => i !== oldestId);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Oldest-first eviction loop until total disk usage + incoming bytes
|
|
357
|
-
* fits under maxTotalBytes. Pinned entries are skipped (matches
|
|
358
|
-
* in-memory store semantics — pinned blocks are held by an active
|
|
359
|
-
* batch and shouldn't be evicted mid-run).
|
|
360
|
-
*/
|
|
361
|
-
evictUntilFits(incomingBytes) {
|
|
362
|
-
let total = this.totalBytesOnDisk();
|
|
363
|
-
if (total + incomingBytes <= this.maxTotalBytes)
|
|
364
|
-
return;
|
|
365
|
-
const candidates = [];
|
|
366
|
-
for (const id of this.listIds()) {
|
|
367
|
-
if ((this.pinCounts.get(id) ?? 0) > 0)
|
|
368
|
-
continue;
|
|
369
|
-
const meta = this.readMeta(id);
|
|
370
|
-
if (!meta)
|
|
371
|
-
continue;
|
|
372
|
-
let bytes = 0;
|
|
373
|
-
try {
|
|
374
|
-
bytes = fs.statSync(this.contentPath(id)).size;
|
|
375
|
-
}
|
|
376
|
-
catch {
|
|
377
|
-
continue;
|
|
378
|
-
}
|
|
379
|
-
candidates.push({ id, createdAt: meta.createdAt, bytes });
|
|
380
|
-
}
|
|
381
|
-
// Oldest-first
|
|
382
|
-
candidates.sort((a, b) => a.createdAt - b.createdAt);
|
|
383
|
-
for (const c of candidates) {
|
|
384
|
-
if (total + incomingBytes <= this.maxTotalBytes)
|
|
385
|
-
break;
|
|
386
|
-
this.deleteFiles(c.id);
|
|
387
|
-
total -= c.bytes;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
/** Scan this project's meta files for one whose recorded sha256 matches `sha256`. Returns the id, or null. */
|
|
391
|
-
findByContentSha(sha256) {
|
|
392
|
-
if (!fs.existsSync(this.rootDir))
|
|
393
|
-
return null;
|
|
394
|
-
const files = fs.readdirSync(this.rootDir);
|
|
395
|
-
for (const file of files) {
|
|
396
|
-
if (!file.endsWith('.meta.json'))
|
|
397
|
-
continue;
|
|
398
|
-
try {
|
|
399
|
-
const meta = JSON.parse(fs.readFileSync(path.join(this.rootDir, file), 'utf8'));
|
|
400
|
-
if (meta.sha256 === sha256)
|
|
401
|
-
return file.slice(0, -'.meta.json'.length);
|
|
402
|
-
}
|
|
403
|
-
catch {
|
|
404
|
-
// Skip malformed meta files
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
return null;
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
//# sourceMappingURL=file-backed-context-block-store.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-backed-context-block-store.js","sourceRoot":"","sources":["../../src/stores/file-backed-context-block-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAMlC,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAC/C,MAAM,sBAAsB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAC9C,MAAM,uBAAuB,GAAG,CAAC,GAAG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AK,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;gBAAE,SAAS;YAC3C,IAAI,CAAC;gBACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;gBAChF,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM;oBAAE,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YACzE,CAAC;YAAC,MAAM,CAAC;gBACP,4BAA4B;YAC9B,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
package/dist/stores/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stores/index.ts"],"names":[],"mappings":"AAEA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC"}
|
package/dist/stores/index.js
DELETED
package/dist/stores/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/stores/index.ts"],"names":[],"mappings":"AAAA,wEAAwE;AAExE,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { Client } from './manifest.js';
|
|
2
|
-
export declare const SUPPORTED_SKILLS: readonly ["multi-model-agent", "mma-delegate", "mma-audit", "mma-review", "mma-debug", "mma-execute-plan", "mma-retry", "mma-context-blocks", "mma-investigate", "mma-research", "mma-explore"];
|
|
3
|
-
/** Thrown when a skill's SKILL.md cannot be read from the bundled skills directory. */
|
|
4
|
-
export declare class SkillNotFoundError extends Error {
|
|
5
|
-
readonly code: "skill_not_found";
|
|
6
|
-
constructor(skillName: string, checkedPath: string);
|
|
7
|
-
}
|
|
8
|
-
export declare function skillsRootCandidates(here: string): string[];
|
|
9
|
-
export declare function pickSkillsRoot(here: string, exists?: (p: string) => boolean): string;
|
|
10
|
-
/**
|
|
11
|
-
* Return the absolute path to the skills root directory. Production: the
|
|
12
|
-
* bundled `packages/server/src/skills/` (or its dist mirror). Tests pass
|
|
13
|
-
* a fixture path explicitly.
|
|
14
|
-
*/
|
|
15
|
-
export declare function getSkillsRoot(skillsRoot?: string): string;
|
|
16
|
-
/**
|
|
17
|
-
* Read the content of a skill's SKILL.md file. Returns null if the file
|
|
18
|
-
* does not exist; propagates other I/O errors so callers can distinguish
|
|
19
|
-
* "skill not found" from "can't access skill".
|
|
20
|
-
*/
|
|
21
|
-
export declare function readSkillContent(skillName: string, skillsRoot?: string): string | null;
|
|
22
|
-
/**
|
|
23
|
-
* Return the per-client install directories where skills are written as
|
|
24
|
-
* subdirectories. Only includes clients that use the per-skill directory
|
|
25
|
-
* model (claude-code and codex). Gemini and Cursor bundle skills into a
|
|
26
|
-
* single file/extension and are not included.
|
|
27
|
-
*/
|
|
28
|
-
export declare function discoverPerClientInstallDirs(homeDir?: string): Partial<Record<Client, string>>;
|
|
29
|
-
//# sourceMappingURL=discover.d.ts.map
|