@qmediat.io/gemini-code-context-mcp 1.12.1 → 1.13.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/CHANGELOG.md +114 -0
- package/dist/cache/cache-manager.d.ts +20 -0
- package/dist/cache/cache-manager.d.ts.map +1 -1
- package/dist/cache/cache-manager.js +96 -16
- package/dist/cache/cache-manager.js.map +1 -1
- package/dist/cache/files-uploader.d.ts.map +1 -1
- package/dist/cache/files-uploader.js +57 -30
- package/dist/cache/files-uploader.js.map +1 -1
- package/dist/config.d.ts +11 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/indexer/workspace-scanner.d.ts +63 -0
- package/dist/indexer/workspace-scanner.d.ts.map +1 -1
- package/dist/indexer/workspace-scanner.js +66 -7
- package/dist/indexer/workspace-scanner.js.map +1 -1
- package/dist/manifest/db.d.ts +101 -0
- package/dist/manifest/db.d.ts.map +1 -1
- package/dist/manifest/db.js +231 -10
- package/dist/manifest/db.js.map +1 -1
- package/dist/tools/ask.tool.d.ts +10 -0
- package/dist/tools/ask.tool.d.ts.map +1 -1
- package/dist/tools/ask.tool.js +68 -9
- package/dist/tools/ask.tool.js.map +1 -1
- package/dist/tools/code.tool.d.ts +10 -0
- package/dist/tools/code.tool.d.ts.map +1 -1
- package/dist/tools/code.tool.js +39 -1
- package/dist/tools/code.tool.js.map +1 -1
- package/dist/tools/reindex.tool.d.ts.map +1 -1
- package/dist/tools/reindex.tool.js +4 -0
- package/dist/tools/reindex.tool.js.map +1 -1
- package/dist/tools/status.tool.d.ts.map +1 -1
- package/dist/tools/status.tool.js +46 -0
- package/dist/tools/status.tool.js.map +1 -1
- package/dist/types.d.ts +36 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/run-pool.d.ts +15 -0
- package/dist/utils/run-pool.d.ts.map +1 -0
- package/dist/utils/run-pool.js +36 -0
- package/dist/utils/run-pool.js.map +1 -0
- package/package.json +1 -1
package/dist/config.js
CHANGED
|
@@ -64,6 +64,7 @@ export function loadConfig() {
|
|
|
64
64
|
tpmThrottleLimit,
|
|
65
65
|
workspaceGuardRatio,
|
|
66
66
|
forceMaxOutputTokens: readBoolEnv('GEMINI_CODE_CONTEXT_FORCE_MAX_OUTPUT'),
|
|
67
|
+
forceRescan: readBoolEnv('GEMINI_CODE_CONTEXT_FORCE_RESCAN'),
|
|
67
68
|
};
|
|
68
69
|
}
|
|
69
70
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAqB,WAAW,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAqB,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAgF1E,SAAS,UAAU,CAAC,IAAY,EAAE,QAAgB;IAChD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC9C,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACnC,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC3C,CAAC;AAED,SAAS,YAAY,CAAC,IAAY,EAAE,QAAgB;IAClD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC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G,YAAY,CAAC,2CAA2C,EAAE,GAAG,CAAC,CAAC;IAChF,MAAM,mBAAmB,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEpE,OAAO;QACL,IAAI;QACJ,YAAY;QACZ,cAAc,EAAE,WAAW;QAC3B,eAAe,EAAE,UAAU,CAAC,uCAAuC,EAAE,IAAI,CAAC;QAC1E,cAAc,EAAE,UAAU,CAAC,sCAAsC,EAAE,IAAI,CAAC;QACxE,oBAAoB,EAAE,UAAU,CAAC,+BAA+B,EAAE,IAAI,CAAC;QACvE,gBAAgB,EAAE,UAAU,CAAC,mCAAmC,EAAE,SAAS,CAAC;QAC5E,gBAAgB,EAAE,WAAW,CAAC,+BAA+B,CAAC;QAC9D,gBAAgB;QAChB,mBAAmB;QACnB,oBAAoB,EAAE,WAAW,CAAC,sCAAsC,CAAC;QACzE,WAAW,EAAE,WAAW,CAAC,kCAAkC,CAAC;KAC7D,CAAC;AACJ,CAAC"}
|
|
@@ -3,18 +3,73 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Respects default include extensions + exclude directories, plus user overrides
|
|
5
5
|
* passed via `MatchConfig`. Enforces a soft file-count cap and a per-file size cap.
|
|
6
|
+
*
|
|
7
|
+
* v1.13.0+: when `manifestMemo` is supplied, files whose `(mtime_ms, size)`
|
|
8
|
+
* match the previously-stored values reuse the stored content hash and skip
|
|
9
|
+
* re-hashing — typically ~95% of files on a warm rescan, cutting scan
|
|
10
|
+
* wall-clock by ≥10× on large workspaces.
|
|
11
|
+
*/
|
|
12
|
+
import type { FileRow } from '../types.js';
|
|
13
|
+
/**
|
|
14
|
+
* v1.13.0+: build the per-file fingerprint map the scanner consults to skip
|
|
15
|
+
* re-hashing. Rows lacking `mtimeMs` or `size` (pre-1.13 manifests, or rows
|
|
16
|
+
* the uploader hasn't refreshed yet) are dropped — those files always
|
|
17
|
+
* re-hash on the next scan.
|
|
6
18
|
*/
|
|
19
|
+
export declare function buildScanMemo(rows: readonly FileRow[]): Map<string, ScanMemoEntry>;
|
|
20
|
+
/**
|
|
21
|
+
* v1.13.0+: per-file fingerprint stored on the previous scan, used by the
|
|
22
|
+
* scan memo to skip re-hashing when nothing material has changed.
|
|
23
|
+
*
|
|
24
|
+
* `contentHash` is the SHA256 we'd have computed; `mtimeMs` is the file's
|
|
25
|
+
* mtime in ms; `size` is the byte count. ALL THREE must match for the memo
|
|
26
|
+
* to fire — `mtime` alone would mis-cache the (rare) case where two writes
|
|
27
|
+
* within a 1-second resolution window leave the same `mtime` but different
|
|
28
|
+
* content. Size adds a second gate that catches that.
|
|
29
|
+
*/
|
|
30
|
+
export interface ScanMemoEntry {
|
|
31
|
+
contentHash: string;
|
|
32
|
+
mtimeMs: number;
|
|
33
|
+
size: number;
|
|
34
|
+
}
|
|
7
35
|
export interface ScanOptions {
|
|
8
36
|
includeGlobs?: readonly string[];
|
|
9
37
|
excludeGlobs?: readonly string[];
|
|
10
38
|
maxFiles: number;
|
|
11
39
|
maxFileSizeBytes: number;
|
|
40
|
+
/**
|
|
41
|
+
* Concurrency for the per-file `stat` + `hashFile` loop. v1.13.0 default
|
|
42
|
+
* (20) measured ~6× faster than the serial loop on a 670k-token workspace.
|
|
43
|
+
* Capped low enough that small workspaces don't pay setup overhead.
|
|
44
|
+
*/
|
|
45
|
+
hashConcurrency?: number;
|
|
46
|
+
/**
|
|
47
|
+
* v1.13.0+: scan-memo lookup. Map keyed by relpath (POSIX-style, matches
|
|
48
|
+
* what the scanner produces). When `mtimeMs` and `size` from `stat()`
|
|
49
|
+
* match the entry, the scanner reuses `contentHash` and skips reading the
|
|
50
|
+
* file from disk. Pass empty (or `undefined`) to force a fresh hash for
|
|
51
|
+
* every file — equivalent to `forceRescan`.
|
|
52
|
+
*/
|
|
53
|
+
manifestMemo?: ReadonlyMap<string, ScanMemoEntry>;
|
|
54
|
+
/**
|
|
55
|
+
* v1.13.0+: bypass the scan memo and re-hash every file. Useful when the
|
|
56
|
+
* caller suspects the manifest is stale (e.g. after a manual filesystem
|
|
57
|
+
* mutation outside the dev workflow) and wants a forced verification scan.
|
|
58
|
+
*/
|
|
59
|
+
forceRescan?: boolean;
|
|
12
60
|
}
|
|
13
61
|
export interface ScannedFile {
|
|
14
62
|
relpath: string;
|
|
15
63
|
absolutePath: string;
|
|
16
64
|
size: number;
|
|
17
65
|
contentHash: string;
|
|
66
|
+
/** v1.13.0+: file mtime in ms, used by the scan memo on subsequent scans. */
|
|
67
|
+
mtimeMs: number;
|
|
68
|
+
/**
|
|
69
|
+
* v1.13.0+: did the scan memo fire for this file? Operators can sum these
|
|
70
|
+
* to see how often the warm path is exercised.
|
|
71
|
+
*/
|
|
72
|
+
memoHit: boolean;
|
|
18
73
|
}
|
|
19
74
|
export interface ScanResult {
|
|
20
75
|
workspaceRoot: string;
|
|
@@ -22,6 +77,14 @@ export interface ScanResult {
|
|
|
22
77
|
filesHash: string;
|
|
23
78
|
skippedTooLarge: number;
|
|
24
79
|
truncated: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* v1.13.0+: count of files that hit the scan memo (mtime+size unchanged
|
|
82
|
+
* since last scan, content hash reused without reading the file). Useful
|
|
83
|
+
* for status/observability — when this is near zero on what should be a
|
|
84
|
+
* warm scan, something is invalidating the memo (e.g. a build step
|
|
85
|
+
* touching every file).
|
|
86
|
+
*/
|
|
87
|
+
memoHitCount: number;
|
|
25
88
|
}
|
|
26
89
|
export declare function scanWorkspace(workspaceRoot: string, options: ScanOptions): Promise<ScanResult>;
|
|
27
90
|
//# sourceMappingURL=workspace-scanner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-scanner.d.ts","sourceRoot":"","sources":["../../src/indexer/workspace-scanner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"workspace-scanner.d.ts","sourceRoot":"","sources":["../../src/indexer/workspace-scanner.ts"],"names":[],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AAM,EACrB,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,CAAC,CA8ErB"}
|
|
@@ -3,11 +3,36 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Respects default include extensions + exclude directories, plus user overrides
|
|
5
5
|
* passed via `MatchConfig`. Enforces a soft file-count cap and a per-file size cap.
|
|
6
|
+
*
|
|
7
|
+
* v1.13.0+: when `manifestMemo` is supplied, files whose `(mtime_ms, size)`
|
|
8
|
+
* match the previously-stored values reuse the stored content hash and skip
|
|
9
|
+
* re-hashing — typically ~95% of files on a warm rescan, cutting scan
|
|
10
|
+
* wall-clock by ≥10× on large workspaces.
|
|
6
11
|
*/
|
|
7
12
|
import { readdir, stat } from 'node:fs/promises';
|
|
8
13
|
import { join, sep as pathSep, relative } from 'node:path';
|
|
14
|
+
import { runPool } from '../utils/run-pool.js';
|
|
9
15
|
import { defaultMatchConfig, isFileIncluded, isPathExcluded } from './globs.js';
|
|
10
16
|
import { hashFile, mergeHashes } from './hasher.js';
|
|
17
|
+
/**
|
|
18
|
+
* v1.13.0+: build the per-file fingerprint map the scanner consults to skip
|
|
19
|
+
* re-hashing. Rows lacking `mtimeMs` or `size` (pre-1.13 manifests, or rows
|
|
20
|
+
* the uploader hasn't refreshed yet) are dropped — those files always
|
|
21
|
+
* re-hash on the next scan.
|
|
22
|
+
*/
|
|
23
|
+
export function buildScanMemo(rows) {
|
|
24
|
+
const memo = new Map();
|
|
25
|
+
for (const row of rows) {
|
|
26
|
+
if (typeof row.mtimeMs !== 'number' || typeof row.size !== 'number')
|
|
27
|
+
continue;
|
|
28
|
+
memo.set(row.relpath, {
|
|
29
|
+
contentHash: row.contentHash,
|
|
30
|
+
mtimeMs: row.mtimeMs,
|
|
31
|
+
size: row.size,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return memo;
|
|
35
|
+
}
|
|
11
36
|
/**
|
|
12
37
|
* Normalise a path separator to POSIX-style `/`.
|
|
13
38
|
*
|
|
@@ -52,18 +77,51 @@ export async function scanWorkspace(workspaceRoot, options) {
|
|
|
52
77
|
absolutes.sort();
|
|
53
78
|
const truncated = absolutes.length > options.maxFiles;
|
|
54
79
|
const picked = truncated ? absolutes.slice(0, options.maxFiles) : absolutes;
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
80
|
+
const memo = options.forceRescan ? undefined : options.manifestMemo;
|
|
81
|
+
const concurrency = Math.max(1, options.hashConcurrency ?? 20);
|
|
82
|
+
const settled = await runPool(picked, concurrency, async (absolutePath) => {
|
|
58
83
|
const stats = await stat(absolutePath);
|
|
59
84
|
if (stats.size > options.maxFileSizeBytes) {
|
|
85
|
+
return { skipped: true };
|
|
86
|
+
}
|
|
87
|
+
const rel = toPosix(relative(workspaceRoot, absolutePath));
|
|
88
|
+
const memoEntry = memo?.get(rel);
|
|
89
|
+
const memoHit = memoEntry !== undefined &&
|
|
90
|
+
memoEntry.mtimeMs === stats.mtimeMs &&
|
|
91
|
+
memoEntry.size === stats.size;
|
|
92
|
+
const hash = memoHit
|
|
93
|
+
? memoEntry.contentHash
|
|
94
|
+
: await hashFile(absolutePath, stats);
|
|
95
|
+
return {
|
|
96
|
+
file: {
|
|
97
|
+
relpath: rel,
|
|
98
|
+
absolutePath,
|
|
99
|
+
size: stats.size,
|
|
100
|
+
contentHash: hash,
|
|
101
|
+
mtimeMs: stats.mtimeMs,
|
|
102
|
+
memoHit,
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
// Drain the settled array preserving input order so `filesHash` stays
|
|
107
|
+
// deterministic. Any rejection (a `stat`/`hashFile` throw) bubbles —
|
|
108
|
+
// workspace scanning has no per-file recovery story; an unreadable file
|
|
109
|
+
// means the rescan is broken and the caller needs to surface that.
|
|
110
|
+
const files = [];
|
|
111
|
+
let skippedTooLarge = 0;
|
|
112
|
+
let memoHitCount = 0;
|
|
113
|
+
for (const result of settled) {
|
|
114
|
+
if (result.status === 'rejected') {
|
|
115
|
+
throw result.reason instanceof Error ? result.reason : new Error(String(result.reason));
|
|
116
|
+
}
|
|
117
|
+
const entry = result.value;
|
|
118
|
+
if ('skipped' in entry) {
|
|
60
119
|
skippedTooLarge += 1;
|
|
61
120
|
continue;
|
|
62
121
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
files.push({ relpath: rel, absolutePath, size: stats.size, contentHash: hash });
|
|
122
|
+
files.push(entry.file);
|
|
123
|
+
if (entry.file.memoHit)
|
|
124
|
+
memoHitCount += 1;
|
|
67
125
|
}
|
|
68
126
|
const filesHash = mergeHashes(files.map((f) => ({ relpath: f.relpath, hash: f.contentHash })));
|
|
69
127
|
return {
|
|
@@ -72,6 +130,7 @@ export async function scanWorkspace(workspaceRoot, options) {
|
|
|
72
130
|
filesHash,
|
|
73
131
|
skippedTooLarge,
|
|
74
132
|
truncated,
|
|
133
|
+
memoHitCount,
|
|
75
134
|
};
|
|
76
135
|
}
|
|
77
136
|
//# sourceMappingURL=workspace-scanner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-scanner.js","sourceRoot":"","sources":["../../src/indexer/workspace-scanner.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"workspace-scanner.js","sourceRoot":"","sources":["../../src/indexer/workspace-scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,GAAG,IAAI,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAoB,kBAAkB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAClG,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,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AM,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YACjC,MAAM,MAAM,CAAC,MAAM,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1F,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC3B,IAAI,SAAS,IAAI,KAAK,EAAE,CAAC;YACvB,eAAe,IAAI,CAAC,CAAC;YACrB,SAAS;QACX,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO;YAAE,YAAY,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC;IAE/F,OAAO;QACL,aAAa;QACb,KAAK;QACL,SAAS;QACT,eAAe;QACf,SAAS;QACT,YAAY;KACb,CAAC;AACJ,CAAC"}
|
package/dist/manifest/db.d.ts
CHANGED
|
@@ -13,6 +13,46 @@ export declare class ManifestDb {
|
|
|
13
13
|
upsertWorkspace(ws: WorkspaceRow): void;
|
|
14
14
|
deleteWorkspace(workspaceRoot: string): void;
|
|
15
15
|
getFiles(workspaceRoot: string): FileRow[];
|
|
16
|
+
/**
|
|
17
|
+
* v1.13.0+ memo-seeder. Used by `prepareContext`'s inline / implicit /
|
|
18
|
+
* small-workspace branches — those paths skip the uploader entirely (which
|
|
19
|
+
* is the only writer of `upsertFile`), so without this the scan memo would
|
|
20
|
+
* silently degrade to cold every call (every file re-hashes — defeating
|
|
21
|
+
* the v1.13.0 perf headline).
|
|
22
|
+
*
|
|
23
|
+
* Conditional preservation of `file_id` / `uploaded_at` / `expires_at`
|
|
24
|
+
* (round-3 fix for the v1.13.0 silent-corruption HIGH found by Gemini /
|
|
25
|
+
* GPT / Copilot in the round-2 review):
|
|
26
|
+
*
|
|
27
|
+
* - **content_hash UNCHANGED** → preserve the upload metadata. A prior
|
|
28
|
+
* explicit-cache run uploaded these bytes to Files API; a switch back
|
|
29
|
+
* to `cachingMode: 'explicit'` should hit dedup and skip re-upload.
|
|
30
|
+
* - **content_hash CHANGED** → null out `file_id` / `uploaded_at` /
|
|
31
|
+
* `expires_at`. The previous fileId points to an upload of OLD bytes
|
|
32
|
+
* on Google's servers; preserving it would let `findFileRowByHash`
|
|
33
|
+
* return that stale fileId for the NEW content — silently feeding
|
|
34
|
+
* OLD bytes into Gemini under the file's NEW relpath.
|
|
35
|
+
*
|
|
36
|
+
* The pre-fix version preserved unconditionally, locking in a stale-fileId
|
|
37
|
+
* row whenever an edit landed between an explicit run and an implicit run.
|
|
38
|
+
* Two corruption scenarios were reachable:
|
|
39
|
+
* (A) same-relpath self-corruption: file edited mid-session, subsequent
|
|
40
|
+
* explicit run reuses the stale fileId for the changed file.
|
|
41
|
+
* (B) cross-file leak: a different file with the same NEW content_hash
|
|
42
|
+
* hits the dedup query and gets routed through the stale fileId.
|
|
43
|
+
*
|
|
44
|
+
* The CASE-based clear closes both. Confirmed by /6step round-3 analysis:
|
|
45
|
+
* `findFileRowByHash` returns rows where `content_hash = ?` and `file_id IS
|
|
46
|
+
* NOT NULL` — the conditional null-out ensures any stale fileId is gone
|
|
47
|
+
* BEFORE the dedup query could return it.
|
|
48
|
+
*/
|
|
49
|
+
refreshFileFingerprints(rows: ReadonlyArray<{
|
|
50
|
+
workspaceRoot: string;
|
|
51
|
+
relpath: string;
|
|
52
|
+
contentHash: string;
|
|
53
|
+
mtimeMs: number;
|
|
54
|
+
size: number;
|
|
55
|
+
}>): void;
|
|
16
56
|
upsertFile(file: FileRow): void;
|
|
17
57
|
deleteFile(workspaceRoot: string, relpath: string): void;
|
|
18
58
|
/** Find a file ID for a content hash already uploaded (dedupe helper). */
|
|
@@ -68,6 +108,16 @@ export declare class ManifestDb {
|
|
|
68
108
|
uncachedTokens: number;
|
|
69
109
|
costUsdMicro: number;
|
|
70
110
|
durationMs: number;
|
|
111
|
+
/**
|
|
112
|
+
* v1.13.0+: caching mode used for the call. `'inline'` is the
|
|
113
|
+
* forced-inline outcome (e.g. `code({ codeExecution: true })`), added in
|
|
114
|
+
* the v1.13.0 round-2 review fix (FN2) so telemetry distinguishes
|
|
115
|
+
* "user asked for explicit and got it" from "user asked for explicit but
|
|
116
|
+
* the runtime forced inline".
|
|
117
|
+
*/
|
|
118
|
+
cachingMode?: 'explicit' | 'implicit' | 'inline' | null;
|
|
119
|
+
/** v1.13.0+: `usage_metadata.cachedContentTokenCount` from the Gemini response. */
|
|
120
|
+
cachedContentTokenCount?: number | null;
|
|
71
121
|
}): void;
|
|
72
122
|
/**
|
|
73
123
|
* Drop a reservation row when the tool call failed before producing any
|
|
@@ -108,5 +158,56 @@ export declare class ManifestDb {
|
|
|
108
158
|
inFlightReservedMicros: number;
|
|
109
159
|
last24hCostMicros: number;
|
|
110
160
|
};
|
|
161
|
+
/**
|
|
162
|
+
* v1.13.0+: caching telemetry aggregation for the `status` tool.
|
|
163
|
+
*
|
|
164
|
+
* Surfaces caching mode adoption, implicit-cache hit rate (when applicable),
|
|
165
|
+
* and explicit-cache rebuild count over the last 24 h. Hit rate is computed
|
|
166
|
+
* as `sum(cached_content_token_count) / (sum(cached_content_token_count) +
|
|
167
|
+
* sum(uncached_tokens))` across implicit-mode calls — the ratio of input
|
|
168
|
+
* tokens that Gemini's automatic implicit cache served vs the ones we paid
|
|
169
|
+
* full input rate for. Settled rows only (`duration_ms > 0`) so in-flight
|
|
170
|
+
* reservations don't skew the hit rate downward.
|
|
171
|
+
*
|
|
172
|
+
* `mode` is the dominant caching mode in the window:
|
|
173
|
+
* - `'explicit'` if all metric rows used explicit (or no caching mode set)
|
|
174
|
+
* - `'implicit'` if all metric rows used implicit
|
|
175
|
+
* - `'inline'` if all metric rows used the forced-inline path (e.g.
|
|
176
|
+
* `code({ codeExecution: true })` — the user requested
|
|
177
|
+
* explicit but the runtime forbade `cachedContent` + tools
|
|
178
|
+
* simultaneously). Distinguished from `'explicit'` so the
|
|
179
|
+
* v1.14.0 default-flip telemetry isn't biased toward
|
|
180
|
+
* "explicit adoption" by codeExecution traffic.
|
|
181
|
+
* - `'mixed'` if 2+ of the above modes appear (operator changed
|
|
182
|
+
* defaults mid-day, codeExecution + non-codeExecution
|
|
183
|
+
* traffic, etc.)
|
|
184
|
+
* - `null` if no calls in the window
|
|
185
|
+
*
|
|
186
|
+
* Rows older than v1.13.0 lack `caching_mode` (NULL) and are treated as
|
|
187
|
+
* `'explicit'` for the dominant-mode tally.
|
|
188
|
+
*
|
|
189
|
+
* Upgrade-day note (v1.12.x → v1.13.0): if pre-upgrade calls landed inside
|
|
190
|
+
* the 24h window AND post-upgrade traffic is exclusively forced-inline
|
|
191
|
+
* (e.g. `code({ codeExecution: true })`), `mode` returns `'mixed'` because
|
|
192
|
+
* the legacy NULL rows COALESCE into the explicit tally. This self-corrects
|
|
193
|
+
* once the legacy rows fall out of the 24h window. Operators surprised by
|
|
194
|
+
* `'mixed'` post-upgrade should look at `inlineCallCount` and
|
|
195
|
+
* `explicitRebuildCount` to confirm the actual post-upgrade traffic shape.
|
|
196
|
+
*/
|
|
197
|
+
cacheStatsLast24h(nowMs: number): {
|
|
198
|
+
mode: 'explicit' | 'implicit' | 'inline' | 'mixed' | null;
|
|
199
|
+
callCount: number;
|
|
200
|
+
implicitCallsTotal: number;
|
|
201
|
+
implicitCallsWithHit: number;
|
|
202
|
+
implicitCachedTokens: number;
|
|
203
|
+
implicitUncachedTokens: number;
|
|
204
|
+
implicitHitRate: number;
|
|
205
|
+
explicitRebuildCount: number;
|
|
206
|
+
/** v1.13.0 round-2 (FN2 fix): forced-inline call count. Useful for
|
|
207
|
+
* understanding why explicit-rebuild count differs from explicit-call
|
|
208
|
+
* count (codeExecution calls request explicit, get inline, never trigger
|
|
209
|
+
* caches.create). */
|
|
210
|
+
inlineCallCount: number;
|
|
211
|
+
};
|
|
111
212
|
}
|
|
112
213
|
//# sourceMappingURL=db.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/manifest/db.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/manifest/db.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAiIzE,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAe;gBAEtB,YAAY,CAAC,EAAE,MAAM;IA8BjC,KAAK,IAAI,IAAI;IAIb,YAAY,CAAC,aAAa,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAOxD,eAAe,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI;IA6BvC,eAAe,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;IAO5C,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,EAAE;IAO1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,uBAAuB,CACrB,IAAI,EAAE,aAAa,CAAC;QAClB,aAAa,EAAE,MAAM,CAAC;QACtB,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,GACD,IAAI;IA2CP,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;IA2B/B,UAAU,CAAC,aA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