@jigyasudham/veto 2.9.0 → 3.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.
Files changed (106) hide show
  1. package/README.md +83 -4
  2. package/dist/cli/statusline.d.ts +9 -0
  3. package/dist/cli/statusline.d.ts.map +1 -1
  4. package/dist/cli/statusline.js +59 -3
  5. package/dist/cli/statusline.js.map +1 -1
  6. package/dist/cli.js +166 -5
  7. package/dist/cli.js.map +1 -1
  8. package/dist/memory/config.d.ts +10 -0
  9. package/dist/memory/config.d.ts.map +1 -1
  10. package/dist/memory/config.js +48 -8
  11. package/dist/memory/config.js.map +1 -1
  12. package/dist/memory/local.d.ts.map +1 -1
  13. package/dist/memory/local.js +32 -10
  14. package/dist/memory/local.js.map +1 -1
  15. package/dist/server/handlers/core.d.ts.map +1 -1
  16. package/dist/server/handlers/core.js +14 -1
  17. package/dist/server/handlers/core.js.map +1 -1
  18. package/dist/server/handlers/session.d.ts.map +1 -1
  19. package/dist/server/handlers/session.js +51 -2
  20. package/dist/server/handlers/session.js.map +1 -1
  21. package/dist/tools/definitions.d.ts +23 -3
  22. package/dist/tools/definitions.d.ts.map +1 -1
  23. package/dist/tools/definitions.js +11 -3
  24. package/dist/tools/definitions.js.map +1 -1
  25. package/dist/transcripts/adapters/claude.d.ts +27 -0
  26. package/dist/transcripts/adapters/claude.d.ts.map +1 -0
  27. package/dist/transcripts/adapters/claude.js +194 -0
  28. package/dist/transcripts/adapters/claude.js.map +1 -0
  29. package/dist/transcripts/archive.d.ts +23 -0
  30. package/dist/transcripts/archive.d.ts.map +1 -0
  31. package/dist/transcripts/archive.js +101 -0
  32. package/dist/transcripts/archive.js.map +1 -0
  33. package/dist/transcripts/cache.d.ts +66 -0
  34. package/dist/transcripts/cache.d.ts.map +1 -0
  35. package/dist/transcripts/cache.js +0 -0
  36. package/dist/transcripts/cache.js.map +1 -0
  37. package/dist/transcripts/chunk.d.ts +26 -0
  38. package/dist/transcripts/chunk.d.ts.map +1 -0
  39. package/dist/transcripts/chunk.js +54 -0
  40. package/dist/transcripts/chunk.js.map +1 -0
  41. package/dist/transcripts/config.d.ts +52 -0
  42. package/dist/transcripts/config.d.ts.map +1 -0
  43. package/dist/transcripts/config.js +135 -0
  44. package/dist/transcripts/config.js.map +1 -0
  45. package/dist/transcripts/embed.d.ts +58 -0
  46. package/dist/transcripts/embed.d.ts.map +1 -0
  47. package/dist/transcripts/embed.js +303 -0
  48. package/dist/transcripts/embed.js.map +1 -0
  49. package/dist/transcripts/expand.d.ts +20 -0
  50. package/dist/transcripts/expand.d.ts.map +1 -0
  51. package/dist/transcripts/expand.js +97 -0
  52. package/dist/transcripts/expand.js.map +1 -0
  53. package/dist/transcripts/ingest.d.ts +17 -0
  54. package/dist/transcripts/ingest.d.ts.map +1 -0
  55. package/dist/transcripts/ingest.js +120 -0
  56. package/dist/transcripts/ingest.js.map +1 -0
  57. package/dist/transcripts/manage.d.ts +42 -0
  58. package/dist/transcripts/manage.d.ts.map +1 -0
  59. package/dist/transcripts/manage.js +123 -0
  60. package/dist/transcripts/manage.js.map +1 -0
  61. package/dist/transcripts/mapping.d.ts +23 -0
  62. package/dist/transcripts/mapping.d.ts.map +1 -0
  63. package/dist/transcripts/mapping.js +42 -0
  64. package/dist/transcripts/mapping.js.map +1 -0
  65. package/dist/transcripts/mask.d.ts +26 -0
  66. package/dist/transcripts/mask.d.ts.map +1 -0
  67. package/dist/transcripts/mask.js +121 -0
  68. package/dist/transcripts/mask.js.map +1 -0
  69. package/dist/transcripts/on-save.d.ts +12 -0
  70. package/dist/transcripts/on-save.d.ts.map +1 -0
  71. package/dist/transcripts/on-save.js +37 -0
  72. package/dist/transcripts/on-save.js.map +1 -0
  73. package/dist/transcripts/pyramid.d.ts +38 -0
  74. package/dist/transcripts/pyramid.d.ts.map +1 -0
  75. package/dist/transcripts/pyramid.js +113 -0
  76. package/dist/transcripts/pyramid.js.map +1 -0
  77. package/dist/transcripts/recall.d.ts +46 -0
  78. package/dist/transcripts/recall.d.ts.map +1 -0
  79. package/dist/transcripts/recall.js +107 -0
  80. package/dist/transcripts/recall.js.map +1 -0
  81. package/dist/transcripts/schema.d.ts +79 -0
  82. package/dist/transcripts/schema.d.ts.map +1 -0
  83. package/dist/transcripts/schema.js +178 -0
  84. package/dist/transcripts/schema.js.map +1 -0
  85. package/dist/transcripts/search.d.ts +57 -0
  86. package/dist/transcripts/search.d.ts.map +1 -0
  87. package/dist/transcripts/search.js +332 -0
  88. package/dist/transcripts/search.js.map +1 -0
  89. package/dist/transcripts/store.d.ts +21 -0
  90. package/dist/transcripts/store.d.ts.map +1 -0
  91. package/dist/transcripts/store.js +105 -0
  92. package/dist/transcripts/store.js.map +1 -0
  93. package/dist/transcripts/toc.d.ts +18 -0
  94. package/dist/transcripts/toc.d.ts.map +1 -0
  95. package/dist/transcripts/toc.js +96 -0
  96. package/dist/transcripts/toc.js.map +1 -0
  97. package/dist/transcripts/tokenize.d.ts +14 -0
  98. package/dist/transcripts/tokenize.d.ts.map +1 -0
  99. package/dist/transcripts/tokenize.js +70 -0
  100. package/dist/transcripts/tokenize.js.map +1 -0
  101. package/dist/transcripts/vectors.d.ts +40 -0
  102. package/dist/transcripts/vectors.d.ts.map +1 -0
  103. package/dist/transcripts/vectors.js +203 -0
  104. package/dist/transcripts/vectors.js.map +1 -0
  105. package/package.json +3 -2
  106. package/server.json +2 -2
@@ -0,0 +1,66 @@
1
+ export type DocCache = {
2
+ /** Highest doc id; arrays below are indexed by doc id, so length is maxId+1. */
3
+ maxId: number;
4
+ /** Token count per doc, for BM25 length normalization. */
5
+ len: Int32Array;
6
+ project: (string | null)[];
7
+ session: string[];
8
+ /** Doc count and average length, for BM25's corpus statistics. */
9
+ count: number;
10
+ avgdl: number;
11
+ };
12
+ /**
13
+ * How many leading dimensions the cheap first pass scores.
14
+ *
15
+ * potion applies PCA, so dimensions arrive ordered by variance and a prefix is
16
+ * unusually informative. Scoring a prefix costs a quarter of a full dot
17
+ * product and, combined with the tail norm, yields an exact upper bound via
18
+ * Cauchy-Schwarz: |tail contribution| <= ||q_tail|| * ||d_tail||. Chunks whose
19
+ * BEST possible score cannot reach the current cutoff are skipped without ever
20
+ * being fully scored — exact, never a recall loss, unlike an ANN index.
21
+ */
22
+ export declare const PREFIX_DIMS = 64;
23
+ export type VectorCache = {
24
+ dim: number;
25
+ count: number;
26
+ /** count * dim, row-major — one contiguous allocation, not one per chunk. */
27
+ data: Int8Array;
28
+ /** L2 norm of each int8 row. */
29
+ norms: Float32Array;
30
+ /** L2 norm of dims [PREFIX_DIMS, dim) per row — the tail a prefix scan has
31
+ * not yet seen. Enables an exact Cauchy-Schwarz bound (see PREFIX_DIMS). */
32
+ tailNorms: Float32Array;
33
+ docIds: Int32Array;
34
+ chunkIdx: Int32Array;
35
+ };
36
+ /** Drop both caches. MUST be called after anything that mutates the index. */
37
+ export declare function resetCaches(): void;
38
+ export declare function getDocCache(): DocCache;
39
+ export declare function getVectorCache(): VectorCache;
40
+ /**
41
+ * A lookup table of in-scope doc ids, built from the cached metadata rather
42
+ * than a per-query SQL round trip. Returns null when no filter applies.
43
+ *
44
+ * Memoized per scope: building it walks every doc id doing string comparisons,
45
+ * which at 41k docs is a real per-query cost, and consecutive queries almost
46
+ * always share a scope. Cleared with the caches it is derived from.
47
+ */
48
+ export declare function scopeMask(docs: DocCache, opts: {
49
+ projectDir?: string;
50
+ sourceSessionId?: string;
51
+ }): Uint8Array | null;
52
+ /**
53
+ * Reusable per-document accumulators for the vector scan.
54
+ *
55
+ * Allocating these per query costs hundreds of kilobytes of zero-fill on every
56
+ * search. They are handed back dirty by contract — the caller resets only the
57
+ * entries it touched, which is proportional to matches rather than to the id
58
+ * space.
59
+ */
60
+ export declare function scoreScratch(maxId: number): {
61
+ score: Float32Array;
62
+ chunk: Int32Array;
63
+ };
64
+ /** Sentinel for "this document has not been scored in this query". */
65
+ export declare const EMPTY_SCORE = -2;
66
+ //# sourceMappingURL=cache.d.ts.map
@@ -0,0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E,CAAC;QACvD,aAAa,GAAG,IAAI,YAAY,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC9D,aAAa,GAAG,IAAI,UAAU,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,aAAc,EAAE,CAAC;AACzD,CAAC;AAED,sEAAsE;AACtE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,CAAC"}
@@ -0,0 +1,26 @@
1
+ /** Bump on ANY boundary change — forces stored vectors to be re-derived. */
2
+ export declare const CHUNKER_VERSION = 1;
3
+ /** Validated by the paraphrase-gate prototype. Not a tuning knob: changing
4
+ * these invalidates the experiment that justified the semantic layer. */
5
+ export declare const WINDOW_CHARS = 240;
6
+ export declare const STRIDE_CHARS = 120;
7
+ /** Input-size guard, not a tuning knob (C2). A pathological event must not be
8
+ * able to emit unbounded rows; the tail is dropped and stays lexically
9
+ * searchable via BM25, which indexes the whole text regardless. */
10
+ export declare const MAX_WINDOWS_PER_EVENT = 64;
11
+ export type Chunk = {
12
+ index: number;
13
+ /** UTF-16 offsets into the source text, so a hit can aim a snippet (C6). */
14
+ start: number;
15
+ end: number;
16
+ text: string;
17
+ };
18
+ /**
19
+ * Split `text` into overlapping windows.
20
+ *
21
+ * Events at or under the window emit exactly one chunk covering the whole
22
+ * text — the median event is ~205 chars, so most events produce a single row
23
+ * and the vector count stays proportional to content, not to event count.
24
+ */
25
+ export declare function chunkText(text: string): Chunk[];
26
+ //# sourceMappingURL=chunk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk.d.ts","sourceRoot":"","sources":["../../src/transcripts/chunk.ts"],"names":[],"mappings":"AAYA,4EAA4E;AAC5E,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC;0EAC0E;AAC1E,eAAO,MAAM,YAAY,MAAM,CAAC;AAChC,eAAO,MAAM,YAAY,MAAM,CAAC;AAEhC;;oEAEoE;AACpE,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,MAAM,MAAM,KAAK,GAAG;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAWF;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,EAAE,CAc/C"}
@@ -0,0 +1,54 @@
1
+ // Chunking for the semantic layer (VERSION-3 item 6, Phase B).
2
+ //
3
+ // One vector per event demonstrably FAILS the paraphrase gate: mean-pooling a
4
+ // 1,936-char event dilutes the one sentence that answers the question down to
5
+ // ~5% of the vector, and it never surfaces. Splitting events into overlapping
6
+ // windows and scoring each event by its BEST window fixed that — the whole
7
+ // reason this file exists (council outcome 9b0595ad, spec §11 amendment).
8
+ //
9
+ // Boundaries here are a compatibility surface: they are pinned by golden tests
10
+ // (C1), and CHUNKER_VERSION must be bumped if any of it changes, because
11
+ // stored vectors are only meaningful against the chunker that produced them.
12
+ /** Bump on ANY boundary change — forces stored vectors to be re-derived. */
13
+ export const CHUNKER_VERSION = 1;
14
+ /** Validated by the paraphrase-gate prototype. Not a tuning knob: changing
15
+ * these invalidates the experiment that justified the semantic layer. */
16
+ export const WINDOW_CHARS = 240;
17
+ export const STRIDE_CHARS = 120;
18
+ /** Input-size guard, not a tuning knob (C2). A pathological event must not be
19
+ * able to emit unbounded rows; the tail is dropped and stays lexically
20
+ * searchable via BM25, which indexes the whole text regardless. */
21
+ export const MAX_WINDOWS_PER_EVENT = 64;
22
+ /** Never split a surrogate pair: a lone surrogate would corrupt normalization
23
+ * and produce a vector for text that does not exist. Boundaries move forward
24
+ * off a low surrogate, which keeps the result deterministic. */
25
+ function safeBoundary(text, i) {
26
+ if (i <= 0 || i >= text.length)
27
+ return i;
28
+ const c = text.charCodeAt(i);
29
+ return c >= 0xdc00 && c <= 0xdfff ? i + 1 : i;
30
+ }
31
+ /**
32
+ * Split `text` into overlapping windows.
33
+ *
34
+ * Events at or under the window emit exactly one chunk covering the whole
35
+ * text — the median event is ~205 chars, so most events produce a single row
36
+ * and the vector count stays proportional to content, not to event count.
37
+ */
38
+ export function chunkText(text) {
39
+ if (text.length === 0)
40
+ return [];
41
+ if (text.length <= WINDOW_CHARS) {
42
+ return [{ index: 0, start: 0, end: text.length, text }];
43
+ }
44
+ const out = [];
45
+ for (let raw = 0; raw < text.length && out.length < MAX_WINDOWS_PER_EVENT; raw += STRIDE_CHARS) {
46
+ const start = safeBoundary(text, raw);
47
+ const end = safeBoundary(text, Math.min(start + WINDOW_CHARS, text.length));
48
+ out.push({ index: out.length, start, end, text: text.slice(start, end) });
49
+ if (end >= text.length)
50
+ break;
51
+ }
52
+ return out;
53
+ }
54
+ //# sourceMappingURL=chunk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk.js","sourceRoot":"","sources":["../../src/transcripts/chunk.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,EAAE;AACF,8EAA8E;AAC9E,8EAA8E;AAC9E,8EAA8E;AAC9E,2EAA2E;AAC3E,0EAA0E;AAC1E,EAAE;AACF,+EAA+E;AAC/E,yEAAyE;AACzE,6EAA6E;AAE7E,4EAA4E;AAC5E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC;AAEjC;0EAC0E;AAC1E,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAChC,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAEhC;;oEAEoE;AACpE,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAUxC;;iEAEiE;AACjE,SAAS,YAAY,CAAC,IAAY,EAAE,CAAS;IAC3C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM;QAAE,OAAO,CAAC,CAAC;IACzC,MAAM,C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T_VERSION = 1;
3
+ export declare const DEFAULT_RETENTION_DAYS = 180;
4
+ /**
5
+ * Platform-appropriate, NON-cloud-synced data dir for transcript archives.
6
+ * Deliberately not ~/.veto: on consumer Windows that can be redirected into
7
+ * OneDrive. %LOCALAPPDATA% / Application Support / $XDG_DATA_HOME are local.
8
+ */
9
+ export declare function defaultTranscriptsDir(): string;
10
+ /** The effective archive dir: user override when set, else the platform default. */
11
+ export declare function effectiveTranscriptsDir(cfg?: TranscriptsConfig): string;
12
+ /** True only when capture is enabled AND consent matches the current version. */
13
+ export declare function isCaptureEnabled(cfg?: TranscriptsConfig): boolean;
14
+ /** Enabled under an older consent version → capture is paused pending re-consent. */
15
+ export declare function needsReconsent(cfg?: TranscriptsConfig): boolean;
16
+ export type EnableResult = {
17
+ dir: string;
18
+ retention_days: number;
19
+ consent_version: number;
20
+ reconsented: boolean;
21
+ };
22
+ /** Turn capture ON and record consent (version + timestamp). Idempotent. */
23
+ export declare function enableCapture(): EnableResult;
24
+ /** Turn capture OFF. The consent record is retained as an audit trail. */
25
+ export declare function disableCapture(): void;
26
+ /**
27
+ * Returns a one-time note the FIRST time a real capture happens, then null
28
+ * forever after (records first_capture_at). Lets the save response tell the user
29
+ * capture is working without nagging on every save.
30
+ */
31
+ export declare function firstCaptureNote(): string | null;
32
+ export type CaptureStatus = {
33
+ enabled: boolean;
34
+ effective: boolean;
35
+ needsReconsent: boolean;
36
+ dir: string;
37
+ usingDefaultDir: boolean;
38
+ retention_days: number;
39
+ consent_version: number | null;
40
+ consent_at: string | null;
41
+ cloudSyncWarning: string | null;
42
+ };
43
+ export declare function captureStatus(): CaptureStatus;
44
+ /**
45
+ * Heuristic: warn if the archive path looks like it lives inside a cloud-synced
46
+ * tree, so "machine-local forever" isn't quietly violated. Names the provider
47
+ * when matched; null when the path looks local.
48
+ */
49
+ export declare function detectCloudSync(dir: string): string | null;
50
+ /** Plain-language consent disclosure shown at enable time (what/where/retention/sensitivity/control). */
51
+ export declare function consentText(dir: string, retentionDays: number): string;
52
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/transcripts/config.ts"],"names":[],"mappings":"AAUA,OAAO,EAAwB,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGnF,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAU9C;AAED,oFAAoF;AACpF,wBAAgB,uBAAuB,CAAC,GAAG,GAAE,iBAA2C,GAAG,MAAM,CAEhG;AAED,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,GAAG,GAAE,iBAA2C,GAAG,OAAO,CAE1F;AAED,qFAAqF;AACrF,wBAAgB,cAAc,CAAC,GAAG,GAAE,iBAA2C,GAAG,OAAO,CAExF;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,4EAA4E;AAC5E,wBAAgB,aAAa,IAAI,YAAY,CAa5C;AAED,0EAA0E;AAC1E,wBAAgB,cAAc,IAAI,IAAI,CAGrC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,IAAI,CAMhD;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,EAAE,OAAO,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,eAAe,EAAE,OAAO,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC,CAAC;AAEF,wBAAgB,aAAa,IAAI,aAAa,CAc7C;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAY1D;AAED,yGAAyG;AACzG,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAwBtE"}
@@ -0,0 +1,135 @@
1
+ // Transcript-capture consent & config (VERSION-3 item 6, Step 1).
2
+ //
3
+ // Capture is OFF until `veto transcripts enable` is run. Enabling records the
4
+ // current consent version + timestamp; a later bump of CONSENT_VERSION forces a
5
+ // re-consent (the disclosure materially changed). All settings persist in the
6
+ // shared ~/.veto/config.json under `transcripts` — no DB table, so Step 1
7
+ // touches neither veto.db nor the (not-yet-created) sidecar transcripts.db.
8
+ import { homedir } from 'node:os';
9
+ import { join } from 'node:path';
10
+ import { getConfig, setConfig } from '../memory/config.js';
11
+ // Bump when the consent disclosure materially changes → users are re-prompted.
12
+ export const CONSENT_VERSION = 1;
13
+ export const DEFAULT_RETENTION_DAYS = 180;
14
+ /**
15
+ * Platform-appropriate, NON-cloud-synced data dir for transcript archives.
16
+ * Deliberately not ~/.veto: on consumer Windows that can be redirected into
17
+ * OneDrive. %LOCALAPPDATA% / Application Support / $XDG_DATA_HOME are local.
18
+ */
19
+ export function defaultTranscriptsDir() {
20
+ if (process.platform === 'win32') {
21
+ const base = process.env.LOCALAPPDATA || join(homedir(), 'AppData', 'Local');
22
+ return join(base, 'veto', 'transcripts');
23
+ }
24
+ if (process.platform === 'darwin') {
25
+ return join(homedir(), 'Library', 'Application Support', 'veto', 'transcripts');
26
+ }
27
+ const base = process.env.XDG_DATA_HOME || join(homedir(), '.local', 'share');
28
+ return join(base, 'veto', 'transcripts');
29
+ }
30
+ /** The effective archive dir: user override when set, else the platform default. */
31
+ export function effectiveTranscriptsDir(cfg = getConfig().transcripts) {
32
+ return cfg.dir && cfg.dir.trim() ? cfg.dir : defaultTranscriptsDir();
33
+ }
34
+ /** True only when capture is enabled AND consent matches the current version. */
35
+ export function isCaptureEnabled(cfg = getConfig().transcripts) {
36
+ return cfg.enabled && cfg.consent_version === CONSENT_VERSION;
37
+ }
38
+ /** Enabled under an older consent version → capture is paused pending re-consent. */
39
+ export function needsReconsent(cfg = getConfig().transcripts) {
40
+ return cfg.enabled && cfg.consent_version !== CONSENT_VERSION;
41
+ }
42
+ /** Turn capture ON and record consent (version + timestamp). Idempotent. */
43
+ export function enableCapture() {
44
+ const current = getConfig().transcripts;
45
+ const reconsented = current.enabled && current.consent_version !== CONSENT_VERSION;
46
+ const retention_days = current.retention_days > 0 ? current.retention_days : DEFAULT_RETENTION_DAYS;
47
+ const next = {
48
+ ...current,
49
+ enabled: true,
50
+ retention_days,
51
+ consent_version: CONSENT_VERSION,
52
+ consent_at: new Date().toISOString(),
53
+ };
54
+ setConfig({ transcripts: next });
55
+ return { dir: effectiveTranscriptsDir(next), retention_days, consent_version: CONSENT_VERSION, reconsented };
56
+ }
57
+ /** Turn capture OFF. The consent record is retained as an audit trail. */
58
+ export function disableCapture() {
59
+ const current = getConfig().transcripts;
60
+ setConfig({ transcripts: { ...current, enabled: false } });
61
+ }
62
+ /**
63
+ * Returns a one-time note the FIRST time a real capture happens, then null
64
+ * forever after (records first_capture_at). Lets the save response tell the user
65
+ * capture is working without nagging on every save.
66
+ */
67
+ export function firstCaptureNote() {
68
+ const current = getConfig().transcripts;
69
+ if (current.first_capture_at)
70
+ return null;
71
+ setConfig({ transcripts: { ...current, first_capture_at: new Date().toISOString() } });
72
+ return 'Veto archived this session to your local transcript store (opt-in, on this machine only). '
73
+ + 'Recall past detail later with veto_session_replay; manage with `veto transcripts`.';
74
+ }
75
+ export function captureStatus() {
76
+ const cfg = getConfig().transcripts;
77
+ const dir = effectiveTranscriptsDir(cfg);
78
+ return {
79
+ enabled: cfg.enabled,
80
+ effective: isCaptureEnabled(cfg),
81
+ needsReconsent: needsReconsent(cfg),
82
+ dir,
83
+ usingDefaultDir: !(cfg.dir && cfg.dir.trim()),
84
+ retention_days: cfg.retention_days > 0 ? cfg.retention_days : DEFAULT_RETENTION_DAYS,
85
+ consent_version: cfg.consent_at ? cfg.consent_version : null,
86
+ consent_at: cfg.consent_at,
87
+ cloudSyncWarning: detectCloudSync(dir),
88
+ };
89
+ }
90
+ /**
91
+ * Heuristic: warn if the archive path looks like it lives inside a cloud-synced
92
+ * tree, so "machine-local forever" isn't quietly violated. Names the provider
93
+ * when matched; null when the path looks local.
94
+ */
95
+ export function detectCloudSync(dir) {
96
+ const p = dir.toLowerCase();
97
+ const markers = [
98
+ [/onedrive/, 'OneDrive'],
99
+ [/dropbox/, 'Dropbox'],
100
+ [/google ?drive|[\\/]my drive/, 'Google Drive'],
101
+ [/[\\/]icloud|com~apple~clouddocs/, 'iCloud'],
102
+ ];
103
+ for (const [re, name] of markers) {
104
+ if (re.test(p))
105
+ return name;
106
+ }
107
+ return null;
108
+ }
109
+ /** Plain-language consent disclosure shown at enable time (what/where/retention/sensitivity/control). */
110
+ export function consentText(dir, retentionDays) {
111
+ return [
112
+ 'Veto transcript capture — what you are turning on:',
113
+ '',
114
+ ' • WHAT: when you save a session, Veto takes a COPY of your host CLI\'s own',
115
+ ' conversation transcript — the AI\'s underlying memory of that session:',
116
+ ' every message you sent, every reply, and all tool activity — and builds',
117
+ ' a searchable index over it so a future session can recall exact detail.',
118
+ ' • THE COPY IS SEPARATE: the original file is left untouched, but Veto\'s copy',
119
+ ' lives on independently. Clearing your AI client\'s history, or the client',
120
+ ' rotating its own logs, will NOT remove it. Only `veto transcripts purge`',
121
+ ' (or the retention window below) deletes a Veto archive.',
122
+ ' • WHERE: archives are stored on THIS machine only, at:',
123
+ ` ${dir}`,
124
+ ' Nothing is uploaded, sent to a server, or shared. No API keys involved.',
125
+ ` • RETENTION: archives older than ${retentionDays} days are pruned automatically`,
126
+ ' (configurable). You can change or turn this off at any time.',
127
+ ' • SENSITIVITY: an archive inherits the sensitivity of everything you typed or',
128
+ ' pasted during that session — including secrets and third parties\' data.',
129
+ ' Detected secrets are masked in the search index and never returned to an',
130
+ ' AI, but treat the archive itself as private data.',
131
+ ' • CONTROL: `veto transcripts disable` stops capture; `veto transcripts purge`',
132
+ ' deletes archives. Capture stays OFF until you enable it.',
133
+ ].join('\n');
134
+ }
135
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/transcripts/config.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,EAAE;AACF,8EAA8E;AAC9E,gFAAgF;AAChF,8EAA8E;AAC9E,0EAA0E;AAC1E,4EAA4E;AAE5E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,SAAS,EAA0B,MAAM,qBAAqB,CAAC;AAEnF,+EAA+E;AAC/E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC;AAEjC,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAE1C;;;;GAIG;AACH,MAAM,UAAU,qBAAqB;IACnC,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QAC7E,OAAO,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;IAC3C,CAAC;IACD,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;IAClF,CAAC;IACD,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,I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AAe,CAAC,CAAC,CAAC,IAAI;QAC5D,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,gBAAgB,EAAE,eAAe,CAAC,GAAG,CAAC;KACvC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;IAC5B,MAAM,OAAO,GAA4B;QACvC,CAAC,UAAU,EAAE,UAAU,CAAC;QACxB,CAAC,SAAS,EAAE,SAAS,CAAC;QACtB,CAAC,6BAA6B,EAAE,cAAc,CAAC;QAC/C,CAAC,iCAAiC,EAAE,QAAQ,CAAC;KAC9C,CAAC;IACF,KAAK,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,OAAO,EAAE,CAAC;QACjC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;IAC9B,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,yGAAyG;AACzG,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,aAAqB;IAC5D,OAAO;QACL,oDAAoD;QACpD,EAAE;QACF,8EAA8E;QAC9E,4EAA4E;QAC5E,6EAA6E;QAC7E,6EAA6E;QAC7E,iFAAiF;QACjF,+EAA+E;QAC/E,8EAA8E;QAC9E,6DAA6D;QAC7D,0DAA0D;QAC1D,SAAS,GAAG,EAAE;QACd,6EAA6E;QAC7E,sCAAsC,aAAa,gCAAgC;QACnF,kEAAkE;QAClE,iFAAiF;QACjF,8EAA8E;QAC9E,8EAA8E;QAC9E,uDAAuD;QACvD,iFAAiF;QACjF,8DAA8D;KAC/D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,58 @@
1
+ type Header = {
2
+ format: string;
3
+ upstream: {
4
+ model_id: string;
5
+ revision: string;
6
+ };
7
+ vocab_size: number;
8
+ dim: number;
9
+ inference: {
10
+ add_special_tokens: boolean;
11
+ pooling: string;
12
+ normalize: boolean;
13
+ per_token_weights: unknown;
14
+ };
15
+ tokenizer: {
16
+ strip_accents_effective: boolean;
17
+ };
18
+ };
19
+ type Model = {
20
+ header: Header;
21
+ dim: number;
22
+ /** Row-major int8 table, vocab_size * dim. */
23
+ table: Int8Array;
24
+ /** One scale per row: row_f32 = table[row] * scales[row]. */
25
+ scales: Float32Array;
26
+ vocab: Map<string, number>;
27
+ unkId: number | undefined;
28
+ prefix: string;
29
+ maxWordChars: number;
30
+ lowercase: boolean;
31
+ stripAccents: boolean;
32
+ cleanText: boolean;
33
+ handleChineseChars: boolean;
34
+ };
35
+ /** Token ids for `text`, with no special tokens added (the shipped contract). */
36
+ export declare function tokenizeForEmbedding(text: string, model?: Model): number[];
37
+ /**
38
+ * Embed `text` into a unit-length vector.
39
+ *
40
+ * Gather each token's row, dequantize it by that row's scale, mean-pool, then
41
+ * L2-normalize. Text with no tokens (empty or punctuation-free-of-vocab)
42
+ * yields the zero vector rather than NaN — upstream's behaviour, and the
43
+ * reason the epsilon is in the denominator.
44
+ */
45
+ export declare function embed(text: string, model?: Model): Float32Array;
46
+ /** Cosine similarity of two unit vectors — a dot product, given the inputs. */
47
+ export declare function cosine(a: Float32Array, b: Float32Array): number;
48
+ /** True when the model package resolves and its payload passes validation. */
49
+ export declare function embeddingsAvailable(): boolean;
50
+ /** Upstream model id + revision of the loaded payload, for recall provenance. */
51
+ export declare function modelProvenance(): {
52
+ model_id: string;
53
+ revision: string;
54
+ };
55
+ /** Drop the cached table. Tests only — production loads once per process. */
56
+ export declare function resetModelCache(): void;
57
+ export {};
58
+ //# sourceMappingURL=embed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../../src/transcripts/embed.ts"],"names":[],"mappings":"AA6BA,KAAK,MAAM,GAAG;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ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