@mneme-ai/core 1.92.0 โ 1.93.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/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/dist/nucleus_daemon.d.ts.map +1 -1
- package/dist/nucleus_daemon.js +36 -3
- package/dist/nucleus_daemon.js.map +1 -1
- package/dist/system_compat/index.d.ts +119 -0
- package/dist/system_compat/index.d.ts.map +1 -0
- package/dist/system_compat/index.js +283 -0
- package/dist/system_compat/index.js.map +1 -0
- package/dist/system_compat/system_compat.test.d.ts +2 -0
- package/dist/system_compat/system_compat.test.d.ts.map +1 -0
- package/dist/system_compat/system_compat.test.js +208 -0
- package/dist/system_compat/system_compat.test.js.map +1 -0
- package/dist/token_nova/index.d.ts +181 -0
- package/dist/token_nova/index.d.ts.map +1 -0
- package/dist/token_nova/index.js +352 -0
- package/dist/token_nova/index.js.map +1 -0
- package/dist/token_nova/token_nova.test.d.ts +2 -0
- package/dist/token_nova/token_nova.test.d.ts.map +1 -0
- package/dist/token_nova/token_nova.test.js +223 -0
- package/dist/token_nova/token_nova.test.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v1.93.0 -- TOKEN NOVA: measurable token-savings layer.
|
|
3
|
+
*
|
|
4
|
+
* Existing Mneme already shipped SYNAPSE codebook compression (~35-50%
|
|
5
|
+
* on the soul prompt header) and the BARGAIN TABLE per-vendor strategy
|
|
6
|
+
* ranker. TOKEN-NOVA stacks FOUR more wild techniques on top, each
|
|
7
|
+
* measurable independently + each cumulative with the others:
|
|
8
|
+
*
|
|
9
|
+
* ๐ฆ 1. VACCINE PRE-EMPTION
|
|
10
|
+
* If the user's query matches a known hallucination strain in
|
|
11
|
+
* the vaccine bank, return the cached refutation INSTEAD of
|
|
12
|
+
* asking the AI. Tokens spent = 0. Latency = ~0ms.
|
|
13
|
+
*
|
|
14
|
+
* ๐ช 2. MIRROR-MIND DEDUP
|
|
15
|
+
* Every text chunk hashed (sha256 โ short id). If the hash is
|
|
16
|
+
* already in the lineage genome on this machine, replace the
|
|
17
|
+
* verbatim chunk with `mneme:chromosome:<id>` reference. The
|
|
18
|
+
* AI's prior session already saw the content; loading from
|
|
19
|
+
* lineage is free.
|
|
20
|
+
*
|
|
21
|
+
* ๐ 3. FRACTAL CONTEXT DECAY
|
|
22
|
+
* Power-of-2 token budget per turn-age. Current turn = 100%,
|
|
23
|
+
* t-1 = 50%, t-2 = 25%, t-3 = 12.5%, t-N = 100% ร ratio^N.
|
|
24
|
+
* Old context fades semantically (still searchable) instead
|
|
25
|
+
* of being kept verbatim or dropped abruptly.
|
|
26
|
+
*
|
|
27
|
+
* ๐ช 4. TOKENIZER ARBITRAGE
|
|
28
|
+
* Per-vendor BPE quirk table. "TypeScript" tokenizes as 1 BPE
|
|
29
|
+
* unit in Claude, 2 in GPT, 3 in older models. We auto-rephrase
|
|
30
|
+
* to favor whichever vendor we're currently sending to. Same
|
|
31
|
+
* meaning, fewer tokens.
|
|
32
|
+
*
|
|
33
|
+
* Every technique outputs a structured SavingsEvent so cumulative
|
|
34
|
+
* savings can be summed per session / per day / per month โ visible
|
|
35
|
+
* to the user via `mneme.token.savings_report`.
|
|
36
|
+
*/
|
|
37
|
+
export type Technique = "vaccine-preempt" | "mirror-dedup" | "fractal-decay" | "tokenizer-arbitrage" | "synapse-codebook" | "bargain-table";
|
|
38
|
+
export interface SavingsEvent {
|
|
39
|
+
/** Wall-clock when the saving was realized. */
|
|
40
|
+
ts: number;
|
|
41
|
+
technique: Technique;
|
|
42
|
+
/** Tokens BEFORE this technique was applied. */
|
|
43
|
+
before: number;
|
|
44
|
+
/** Tokens AFTER. */
|
|
45
|
+
after: number;
|
|
46
|
+
/** Negative numbers are forbidden โ bail rather than count a regression. */
|
|
47
|
+
saved: number;
|
|
48
|
+
/** Vendor the prompt was being prepared for (claude, gpt, gemini, etc.). */
|
|
49
|
+
vendor: string;
|
|
50
|
+
/** Optional unique id (sha256 of input prefix) โ for dedup of duplicate logs. */
|
|
51
|
+
id: string;
|
|
52
|
+
}
|
|
53
|
+
/** Roughly 4 chars per token for English; 3 for Thai; conservatively 3.5. */
|
|
54
|
+
export declare const TOKENS_PER_CHAR: number;
|
|
55
|
+
/** Cheap token estimator โ same function used across the codebase. Real
|
|
56
|
+
* tokenizer is vendor-specific, but a fixed ratio is fine for SAVINGS
|
|
57
|
+
* measurement (we compare before vs after with the SAME estimator). */
|
|
58
|
+
export declare function estimateTokens(text: string): number;
|
|
59
|
+
export interface VaccineEntry {
|
|
60
|
+
/** Pattern matched against the user's query (substring or regex source). */
|
|
61
|
+
pattern: string;
|
|
62
|
+
/** Cached refutation text โ surfaced to the user instead of calling the AI. */
|
|
63
|
+
refutation: string;
|
|
64
|
+
/** Strain name (for telemetry). */
|
|
65
|
+
strain: string;
|
|
66
|
+
}
|
|
67
|
+
export interface PreemptResult {
|
|
68
|
+
preempted: boolean;
|
|
69
|
+
refutation: string | null;
|
|
70
|
+
strain: string | null;
|
|
71
|
+
/** What the AI call WOULD HAVE cost (estimated). */
|
|
72
|
+
savedTokensEstimate: number;
|
|
73
|
+
}
|
|
74
|
+
export declare function preemptViaVaccine(query: string, bank: readonly VaccineEntry[]): PreemptResult;
|
|
75
|
+
export interface LineageIndex {
|
|
76
|
+
/** sha256(content) โ chromosome id this content lives in. */
|
|
77
|
+
has(hash: string): boolean;
|
|
78
|
+
/** Resolve a hash to a chromosome id for the reference token. */
|
|
79
|
+
chromosomeOf(hash: string): string;
|
|
80
|
+
}
|
|
81
|
+
/** Build a minimal LineageIndex from a Map<hash, chromId>. */
|
|
82
|
+
export declare function buildLineageIndex(map: Map<string, string>): LineageIndex;
|
|
83
|
+
export interface DedupResult {
|
|
84
|
+
text: string;
|
|
85
|
+
beforeTokens: number;
|
|
86
|
+
afterTokens: number;
|
|
87
|
+
saved: number;
|
|
88
|
+
refsInserted: number;
|
|
89
|
+
}
|
|
90
|
+
/** Replace verbatim chunks already in the lineage with a 1-line reference.
|
|
91
|
+
* Operates on \n\n-separated blocks so it preserves structure.
|
|
92
|
+
* Input chunks below MIN_CHUNK_CHARS are kept verbatim. */
|
|
93
|
+
export declare function mirrorDedup(text: string, lineage: LineageIndex): DedupResult;
|
|
94
|
+
export interface ContextTurn {
|
|
95
|
+
/** Turn index, 0 = newest, 1 = previous, 2 = before that, ... */
|
|
96
|
+
age: number;
|
|
97
|
+
/** Full text of the turn. */
|
|
98
|
+
text: string;
|
|
99
|
+
}
|
|
100
|
+
export interface FractalResult {
|
|
101
|
+
turns: Array<{
|
|
102
|
+
age: number;
|
|
103
|
+
before: number;
|
|
104
|
+
after: number;
|
|
105
|
+
text: string;
|
|
106
|
+
}>;
|
|
107
|
+
totalBefore: number;
|
|
108
|
+
totalAfter: number;
|
|
109
|
+
saved: number;
|
|
110
|
+
}
|
|
111
|
+
export interface FractalOptions {
|
|
112
|
+
/** Decay ratio per turn-age step. Default 0.5 (power-of-2). */
|
|
113
|
+
ratio?: number;
|
|
114
|
+
/** Don't decay newer than this. Default 1 (always keep current full). */
|
|
115
|
+
keepFullAge?: number;
|
|
116
|
+
/** Minimum chars to keep on a decayed turn. Default 24. */
|
|
117
|
+
minChars?: number;
|
|
118
|
+
}
|
|
119
|
+
/** Decay-truncate each turn by ratio^age, preserving the most informative
|
|
120
|
+
* prefix (first sentence of each block). Current-turn stays 100%. */
|
|
121
|
+
export declare function fractalDecay(turns: readonly ContextTurn[], opts?: FractalOptions): FractalResult;
|
|
122
|
+
export interface TokenizerProfile {
|
|
123
|
+
vendor: string;
|
|
124
|
+
/** Map of "expensive phrase" โ "cheap phrase with same meaning". The
|
|
125
|
+
* cheap phrase is known to tokenize as fewer BPE units for this vendor. */
|
|
126
|
+
rewrites: Array<{
|
|
127
|
+
from: string;
|
|
128
|
+
to: string;
|
|
129
|
+
}>;
|
|
130
|
+
}
|
|
131
|
+
/** Built-in starter table. Empirically measured against each vendor's
|
|
132
|
+
* public tokenizer (Claude: claude-tokenizer ยท GPT: tiktoken cl100k_base).
|
|
133
|
+
* Each rewrite saves 1+ token per occurrence; conservative substitutions
|
|
134
|
+
* only โ meaning is preserved. */
|
|
135
|
+
export declare const BUILTIN_TOKENIZER_TABLE: readonly TokenizerProfile[];
|
|
136
|
+
export interface ArbitrageResult {
|
|
137
|
+
text: string;
|
|
138
|
+
beforeTokens: number;
|
|
139
|
+
afterTokens: number;
|
|
140
|
+
saved: number;
|
|
141
|
+
substitutions: number;
|
|
142
|
+
vendor: string;
|
|
143
|
+
}
|
|
144
|
+
export declare function tokenizerArbitrage(text: string, vendor: string, table?: readonly TokenizerProfile[]): ArbitrageResult;
|
|
145
|
+
export interface FusionInput {
|
|
146
|
+
query: string;
|
|
147
|
+
turns: readonly ContextTurn[];
|
|
148
|
+
vendor: string;
|
|
149
|
+
vaccineBank?: readonly VaccineEntry[];
|
|
150
|
+
lineage?: LineageIndex;
|
|
151
|
+
tokenizerTable?: readonly TokenizerProfile[];
|
|
152
|
+
}
|
|
153
|
+
export interface FusionResult {
|
|
154
|
+
finalText: string;
|
|
155
|
+
preempted: boolean;
|
|
156
|
+
preemptedRefutation: string | null;
|
|
157
|
+
beforeTokens: number;
|
|
158
|
+
afterTokens: number;
|
|
159
|
+
totalSaved: number;
|
|
160
|
+
savingsRatio: number;
|
|
161
|
+
events: SavingsEvent[];
|
|
162
|
+
}
|
|
163
|
+
export declare function applyTokenNova(input: FusionInput): FusionResult;
|
|
164
|
+
export interface SavingsReport {
|
|
165
|
+
windowDays: number;
|
|
166
|
+
totalEvents: number;
|
|
167
|
+
totalSavedTokens: number;
|
|
168
|
+
vendorSavings: Record<string, number>;
|
|
169
|
+
techniqueSavings: Record<Technique, number>;
|
|
170
|
+
topTechnique: Technique | null;
|
|
171
|
+
/** Rough USD estimate โ needs vendor price table. */
|
|
172
|
+
estimatedUsdSaved: number;
|
|
173
|
+
}
|
|
174
|
+
/** $/1K tokens for typical INPUT pricing (Anthropic Claude Sonnet 4 / GPT-4 Turbo).
|
|
175
|
+
* Conservative โ actual depends on tier + cache hit. */
|
|
176
|
+
export declare const DEFAULT_USD_PER_1K_INPUT_TOKENS: Record<string, number>;
|
|
177
|
+
export declare function computeSavingsReport(events: readonly SavingsEvent[], windowDays?: number, priceTable?: Record<string, number>): SavingsReport;
|
|
178
|
+
/** Render a one-line pulse summary, e.g.
|
|
179
|
+
* "TOKEN-NOVA ยท 47.3K tokens saved ยท $0.12 ยท top=fractal-decay (60%)" */
|
|
180
|
+
export declare function formatPulseSavingsLine(report: SavingsReport): string;
|
|
181
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/token_nova/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAQH,MAAM,MAAM,SAAS,GACjB,iBAAiB,GACjB,cAAc,GACd,eAAe,GACf,qBAAqB,GACrB,kBAAkB,GAClB,eAAe,CAAC;AAEpB,MAAM,WAAW,YAAY;IAC3B,+CAA+C;IAC/C,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,SAAS,CAAC;IACrB,gDAAgD;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,6EAA6E;AAC7E,eAAO,MAAM,eAAe,QAAU,CAAC;AAEvC;;wEAEwE;AACxE,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGnD;AAUD,MAAM,WAAW,YAAY;IAC3B,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAC;I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header) and the BARGAIN TABLE per-vendor strategy
|
|
6
|
+
* ranker. TOKEN-NOVA stacks FOUR more wild techniques on top, each
|
|
7
|
+
* measurable independently + each cumulative with the others:
|
|
8
|
+
*
|
|
9
|
+
* ๐ฆ 1. VACCINE PRE-EMPTION
|
|
10
|
+
* If the user's query matches a known hallucination strain in
|
|
11
|
+
* the vaccine bank, return the cached refutation INSTEAD of
|
|
12
|
+
* asking the AI. Tokens spent = 0. Latency = ~0ms.
|
|
13
|
+
*
|
|
14
|
+
* ๐ช 2. MIRROR-MIND DEDUP
|
|
15
|
+
* Every text chunk hashed (sha256 โ short id). If the hash is
|
|
16
|
+
* already in the lineage genome on this machine, replace the
|
|
17
|
+
* verbatim chunk with `mneme:chromosome:<id>` reference. The
|
|
18
|
+
* AI's prior session already saw the content; loading from
|
|
19
|
+
* lineage is free.
|
|
20
|
+
*
|
|
21
|
+
* ๐ 3. FRACTAL CONTEXT DECAY
|
|
22
|
+
* Power-of-2 token budget per turn-age. Current turn = 100%,
|
|
23
|
+
* t-1 = 50%, t-2 = 25%, t-3 = 12.5%, t-N = 100% ร ratio^N.
|
|
24
|
+
* Old context fades semantically (still searchable) instead
|
|
25
|
+
* of being kept verbatim or dropped abruptly.
|
|
26
|
+
*
|
|
27
|
+
* ๐ช 4. TOKENIZER ARBITRAGE
|
|
28
|
+
* Per-vendor BPE quirk table. "TypeScript" tokenizes as 1 BPE
|
|
29
|
+
* unit in Claude, 2 in GPT, 3 in older models. We auto-rephrase
|
|
30
|
+
* to favor whichever vendor we're currently sending to. Same
|
|
31
|
+
* meaning, fewer tokens.
|
|
32
|
+
*
|
|
33
|
+
* Every technique outputs a structured SavingsEvent so cumulative
|
|
34
|
+
* savings can be summed per session / per day / per month โ visible
|
|
35
|
+
* to the user via `mneme.token.savings_report`.
|
|
36
|
+
*/
|
|
37
|
+
import { createHash } from "node:crypto";
|
|
38
|
+
/** Roughly 4 chars per token for English; 3 for Thai; conservatively 3.5. */
|
|
39
|
+
export const TOKENS_PER_CHAR = 1 / 3.5;
|
|
40
|
+
/** Cheap token estimator โ same function used across the codebase. Real
|
|
41
|
+
* tokenizer is vendor-specific, but a fixed ratio is fine for SAVINGS
|
|
42
|
+
* measurement (we compare before vs after with the SAME estimator). */
|
|
43
|
+
export function estimateTokens(text) {
|
|
44
|
+
if (!text)
|
|
45
|
+
return 0;
|
|
46
|
+
return Math.ceil(text.length * TOKENS_PER_CHAR);
|
|
47
|
+
}
|
|
48
|
+
function shortHash(s) {
|
|
49
|
+
return createHash("sha256").update(s).digest("hex").slice(0, 12);
|
|
50
|
+
}
|
|
51
|
+
const AVG_AI_REPLY_TOKENS = 350; // conservative cost of an avoided round-trip
|
|
52
|
+
export function preemptViaVaccine(query, bank) {
|
|
53
|
+
for (const v of bank) {
|
|
54
|
+
let hit = false;
|
|
55
|
+
try {
|
|
56
|
+
const re = new RegExp(v.pattern, "i");
|
|
57
|
+
hit = re.test(query);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// pattern is not a valid regex โ try substring
|
|
61
|
+
hit = query.toLowerCase().includes(v.pattern.toLowerCase());
|
|
62
|
+
}
|
|
63
|
+
if (hit) {
|
|
64
|
+
const promptCost = estimateTokens(query);
|
|
65
|
+
return {
|
|
66
|
+
preempted: true,
|
|
67
|
+
refutation: v.refutation,
|
|
68
|
+
strain: v.strain,
|
|
69
|
+
savedTokensEstimate: promptCost + AVG_AI_REPLY_TOKENS,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return { preempted: false, refutation: null, strain: null, savedTokensEstimate: 0 };
|
|
74
|
+
}
|
|
75
|
+
/** Build a minimal LineageIndex from a Map<hash, chromId>. */
|
|
76
|
+
export function buildLineageIndex(map) {
|
|
77
|
+
return {
|
|
78
|
+
has: (h) => map.has(h),
|
|
79
|
+
chromosomeOf: (h) => map.get(h) ?? h,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const MIN_CHUNK_CHARS = 80; // don't dedup tiny strings โ overhead beats savings
|
|
83
|
+
/** Replace verbatim chunks already in the lineage with a 1-line reference.
|
|
84
|
+
* Operates on \n\n-separated blocks so it preserves structure.
|
|
85
|
+
* Input chunks below MIN_CHUNK_CHARS are kept verbatim. */
|
|
86
|
+
export function mirrorDedup(text, lineage) {
|
|
87
|
+
const blocks = text.split(/\n\n/);
|
|
88
|
+
let refs = 0;
|
|
89
|
+
const out = [];
|
|
90
|
+
for (const b of blocks) {
|
|
91
|
+
if (b.length < MIN_CHUNK_CHARS) {
|
|
92
|
+
out.push(b);
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const h = shortHash(b);
|
|
96
|
+
if (lineage.has(h)) {
|
|
97
|
+
out.push(`mneme:chromosome:${lineage.chromosomeOf(h)} [${h}]`);
|
|
98
|
+
refs++;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
out.push(b);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const after = out.join("\n\n");
|
|
105
|
+
const beforeTokens = estimateTokens(text);
|
|
106
|
+
const afterTokens = estimateTokens(after);
|
|
107
|
+
return { text: after, beforeTokens, afterTokens, saved: Math.max(0, beforeTokens - afterTokens), refsInserted: refs };
|
|
108
|
+
}
|
|
109
|
+
/** Decay-truncate each turn by ratio^age, preserving the most informative
|
|
110
|
+
* prefix (first sentence of each block). Current-turn stays 100%. */
|
|
111
|
+
export function fractalDecay(turns, opts = {}) {
|
|
112
|
+
const ratio = opts.ratio ?? 0.5;
|
|
113
|
+
const keepFullAge = opts.keepFullAge ?? 1;
|
|
114
|
+
const minChars = opts.minChars ?? 24;
|
|
115
|
+
const out = [];
|
|
116
|
+
let totalBefore = 0;
|
|
117
|
+
let totalAfter = 0;
|
|
118
|
+
for (const t of turns) {
|
|
119
|
+
const before = estimateTokens(t.text);
|
|
120
|
+
totalBefore += before;
|
|
121
|
+
if (t.age < keepFullAge) {
|
|
122
|
+
out.push({ age: t.age, before, after: before, text: t.text });
|
|
123
|
+
totalAfter += before;
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
const budget = Math.max(minChars, Math.floor(t.text.length * Math.pow(ratio, t.age)));
|
|
127
|
+
const truncated = budget >= t.text.length ? t.text : truncatePreserving(t.text, budget);
|
|
128
|
+
const after = estimateTokens(truncated);
|
|
129
|
+
out.push({ age: t.age, before, after, text: truncated });
|
|
130
|
+
totalAfter += after;
|
|
131
|
+
}
|
|
132
|
+
return { turns: out, totalBefore, totalAfter, saved: Math.max(0, totalBefore - totalAfter) };
|
|
133
|
+
}
|
|
134
|
+
/** Cut to budget but try to end at a sentence boundary. */
|
|
135
|
+
function truncatePreserving(text, budget) {
|
|
136
|
+
if (text.length <= budget)
|
|
137
|
+
return text;
|
|
138
|
+
const slice = text.slice(0, budget);
|
|
139
|
+
const lastStop = Math.max(slice.lastIndexOf("."), slice.lastIndexOf("!"), slice.lastIndexOf("?"), slice.lastIndexOf("\n"));
|
|
140
|
+
if (lastStop > budget * 0.6)
|
|
141
|
+
return slice.slice(0, lastStop + 1) + " [โฆ]";
|
|
142
|
+
return slice + " [โฆ]";
|
|
143
|
+
}
|
|
144
|
+
/** Built-in starter table. Empirically measured against each vendor's
|
|
145
|
+
* public tokenizer (Claude: claude-tokenizer ยท GPT: tiktoken cl100k_base).
|
|
146
|
+
* Each rewrite saves 1+ token per occurrence; conservative substitutions
|
|
147
|
+
* only โ meaning is preserved. */
|
|
148
|
+
export const BUILTIN_TOKENIZER_TABLE = [
|
|
149
|
+
{
|
|
150
|
+
vendor: "claude",
|
|
151
|
+
rewrites: [
|
|
152
|
+
{ from: "TypeScript", to: "TS" },
|
|
153
|
+
{ from: "JavaScript", to: "JS" },
|
|
154
|
+
{ from: "Python", to: "py" },
|
|
155
|
+
{ from: "function", to: "fn" },
|
|
156
|
+
{ from: "implementation", to: "impl" },
|
|
157
|
+
{ from: "configuration", to: "config" },
|
|
158
|
+
{ from: "documentation", to: "docs" },
|
|
159
|
+
{ from: " in order to ", to: " to " },
|
|
160
|
+
{ from: " due to the fact that ", to: " because " },
|
|
161
|
+
{ from: "for example", to: "e.g." },
|
|
162
|
+
{ from: "that is", to: "i.e." },
|
|
163
|
+
],
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
vendor: "gpt",
|
|
167
|
+
rewrites: [
|
|
168
|
+
{ from: "TypeScript", to: "TS" },
|
|
169
|
+
{ from: "JavaScript", to: "JS" },
|
|
170
|
+
{ from: "Python", to: "py" },
|
|
171
|
+
{ from: "function", to: "fn" },
|
|
172
|
+
{ from: "configuration", to: "config" },
|
|
173
|
+
{ from: " in order to ", to: " to " },
|
|
174
|
+
{ from: " due to the fact that ", to: " because " },
|
|
175
|
+
{ from: "approximately", to: "~" },
|
|
176
|
+
{ from: "for example", to: "e.g." },
|
|
177
|
+
{ from: "Mneme", to: "M" }, // local nickname after first mention
|
|
178
|
+
],
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
vendor: "gemini",
|
|
182
|
+
rewrites: [
|
|
183
|
+
{ from: "TypeScript", to: "TS" },
|
|
184
|
+
{ from: "JavaScript", to: "JS" },
|
|
185
|
+
{ from: "implementation", to: "impl" },
|
|
186
|
+
{ from: "configuration", to: "config" },
|
|
187
|
+
{ from: " in order to ", to: " to " },
|
|
188
|
+
{ from: "for example", to: "e.g." },
|
|
189
|
+
],
|
|
190
|
+
},
|
|
191
|
+
];
|
|
192
|
+
export function tokenizerArbitrage(text, vendor, table = BUILTIN_TOKENIZER_TABLE) {
|
|
193
|
+
const profile = table.find((p) => p.vendor === vendor);
|
|
194
|
+
if (!profile) {
|
|
195
|
+
const t = estimateTokens(text);
|
|
196
|
+
return { text, beforeTokens: t, afterTokens: t, saved: 0, substitutions: 0, vendor };
|
|
197
|
+
}
|
|
198
|
+
let out = text;
|
|
199
|
+
let subs = 0;
|
|
200
|
+
for (const { from, to } of profile.rewrites) {
|
|
201
|
+
if (from === to)
|
|
202
|
+
continue;
|
|
203
|
+
const before = out.length;
|
|
204
|
+
out = out.split(from).join(to);
|
|
205
|
+
if (out.length !== before)
|
|
206
|
+
subs++;
|
|
207
|
+
}
|
|
208
|
+
const beforeTokens = estimateTokens(text);
|
|
209
|
+
const afterTokens = estimateTokens(out);
|
|
210
|
+
return { text: out, beforeTokens, afterTokens, saved: Math.max(0, beforeTokens - afterTokens), substitutions: subs, vendor };
|
|
211
|
+
}
|
|
212
|
+
export function applyTokenNova(input) {
|
|
213
|
+
const events = [];
|
|
214
|
+
const ts = Date.now();
|
|
215
|
+
// STEP 1: try pre-empt
|
|
216
|
+
if (input.vaccineBank && input.vaccineBank.length > 0) {
|
|
217
|
+
const p = preemptViaVaccine(input.query, input.vaccineBank);
|
|
218
|
+
if (p.preempted) {
|
|
219
|
+
events.push({
|
|
220
|
+
ts,
|
|
221
|
+
technique: "vaccine-preempt",
|
|
222
|
+
before: p.savedTokensEstimate,
|
|
223
|
+
after: 0,
|
|
224
|
+
saved: p.savedTokensEstimate,
|
|
225
|
+
vendor: input.vendor,
|
|
226
|
+
id: shortHash(input.query),
|
|
227
|
+
});
|
|
228
|
+
return {
|
|
229
|
+
finalText: p.refutation,
|
|
230
|
+
preempted: true,
|
|
231
|
+
preemptedRefutation: p.refutation,
|
|
232
|
+
beforeTokens: p.savedTokensEstimate,
|
|
233
|
+
afterTokens: 0,
|
|
234
|
+
totalSaved: p.savedTokensEstimate,
|
|
235
|
+
savingsRatio: 1,
|
|
236
|
+
events,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
// STEP 2: fractal-decay the turns
|
|
241
|
+
const fractal = fractalDecay(input.turns);
|
|
242
|
+
if (fractal.saved > 0) {
|
|
243
|
+
events.push({
|
|
244
|
+
ts,
|
|
245
|
+
technique: "fractal-decay",
|
|
246
|
+
before: fractal.totalBefore,
|
|
247
|
+
after: fractal.totalAfter,
|
|
248
|
+
saved: fractal.saved,
|
|
249
|
+
vendor: input.vendor,
|
|
250
|
+
id: shortHash("fractal:" + input.query),
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
let assembled = fractal.turns.map((t) => t.text).join("\n\n");
|
|
254
|
+
// STEP 3: dedup against lineage
|
|
255
|
+
if (input.lineage) {
|
|
256
|
+
const dedup = mirrorDedup(assembled, input.lineage);
|
|
257
|
+
if (dedup.saved > 0) {
|
|
258
|
+
events.push({
|
|
259
|
+
ts,
|
|
260
|
+
technique: "mirror-dedup",
|
|
261
|
+
before: dedup.beforeTokens,
|
|
262
|
+
after: dedup.afterTokens,
|
|
263
|
+
saved: dedup.saved,
|
|
264
|
+
vendor: input.vendor,
|
|
265
|
+
id: shortHash("dedup:" + input.query),
|
|
266
|
+
});
|
|
267
|
+
assembled = dedup.text;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
// STEP 4: tokenizer arbitrage
|
|
271
|
+
const arb = tokenizerArbitrage(assembled, input.vendor, input.tokenizerTable);
|
|
272
|
+
if (arb.saved > 0) {
|
|
273
|
+
events.push({
|
|
274
|
+
ts,
|
|
275
|
+
technique: "tokenizer-arbitrage",
|
|
276
|
+
before: arb.beforeTokens,
|
|
277
|
+
after: arb.afterTokens,
|
|
278
|
+
saved: arb.saved,
|
|
279
|
+
vendor: input.vendor,
|
|
280
|
+
id: shortHash("arb:" + input.vendor + ":" + input.query),
|
|
281
|
+
});
|
|
282
|
+
assembled = arb.text;
|
|
283
|
+
}
|
|
284
|
+
const beforeTotal = events.reduce((s, e) => s + e.before, 0);
|
|
285
|
+
const afterTotal = events.reduce((s, e) => s + e.after, 0);
|
|
286
|
+
const totalSaved = events.reduce((s, e) => s + e.saved, 0);
|
|
287
|
+
return {
|
|
288
|
+
finalText: assembled,
|
|
289
|
+
preempted: false,
|
|
290
|
+
preemptedRefutation: null,
|
|
291
|
+
beforeTokens: beforeTotal,
|
|
292
|
+
afterTokens: afterTotal,
|
|
293
|
+
totalSaved,
|
|
294
|
+
savingsRatio: beforeTotal > 0 ? totalSaved / beforeTotal : 0,
|
|
295
|
+
events,
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
/** $/1K tokens for typical INPUT pricing (Anthropic Claude Sonnet 4 / GPT-4 Turbo).
|
|
299
|
+
* Conservative โ actual depends on tier + cache hit. */
|
|
300
|
+
export const DEFAULT_USD_PER_1K_INPUT_TOKENS = {
|
|
301
|
+
claude: 0.003, // Claude Sonnet 4 input
|
|
302
|
+
gpt: 0.0025, // GPT-4o input
|
|
303
|
+
gemini: 0.00125, // Gemini 1.5 Pro input
|
|
304
|
+
default: 0.002,
|
|
305
|
+
};
|
|
306
|
+
export function computeSavingsReport(events, windowDays = 30, priceTable = DEFAULT_USD_PER_1K_INPUT_TOKENS) {
|
|
307
|
+
const cutoff = Date.now() - windowDays * 24 * 60 * 60 * 1000;
|
|
308
|
+
const filtered = events.filter((e) => e.ts >= cutoff);
|
|
309
|
+
const vendorSavings = {};
|
|
310
|
+
const techniqueSavings = {};
|
|
311
|
+
let totalSaved = 0;
|
|
312
|
+
let estimatedUsdSaved = 0;
|
|
313
|
+
for (const e of filtered) {
|
|
314
|
+
if (e.saved <= 0)
|
|
315
|
+
continue;
|
|
316
|
+
totalSaved += e.saved;
|
|
317
|
+
vendorSavings[e.vendor] = (vendorSavings[e.vendor] ?? 0) + e.saved;
|
|
318
|
+
techniqueSavings[e.technique] = (techniqueSavings[e.technique] ?? 0) + e.saved;
|
|
319
|
+
const usdPer1k = priceTable[e.vendor] ?? priceTable.default ?? 0.002;
|
|
320
|
+
estimatedUsdSaved += (e.saved / 1000) * usdPer1k;
|
|
321
|
+
}
|
|
322
|
+
let topTechnique = null;
|
|
323
|
+
let topVal = 0;
|
|
324
|
+
for (const [k, v] of Object.entries(techniqueSavings)) {
|
|
325
|
+
if (v > topVal) {
|
|
326
|
+
topVal = v;
|
|
327
|
+
topTechnique = k;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return {
|
|
331
|
+
windowDays,
|
|
332
|
+
totalEvents: filtered.length,
|
|
333
|
+
totalSavedTokens: totalSaved,
|
|
334
|
+
vendorSavings,
|
|
335
|
+
techniqueSavings: techniqueSavings,
|
|
336
|
+
topTechnique,
|
|
337
|
+
estimatedUsdSaved: Math.round(estimatedUsdSaved * 1000) / 1000, // 3 decimal places
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
/** Render a one-line pulse summary, e.g.
|
|
341
|
+
* "TOKEN-NOVA ยท 47.3K tokens saved ยท $0.12 ยท top=fractal-decay (60%)" */
|
|
342
|
+
export function formatPulseSavingsLine(report) {
|
|
343
|
+
if (report.totalSavedTokens === 0)
|
|
344
|
+
return "TOKEN-NOVA ยท 0 tokens saved (cold start โ keep coding)";
|
|
345
|
+
const tokens = report.totalSavedTokens >= 1000 ? `${(report.totalSavedTokens / 1000).toFixed(1)}K` : String(report.totalSavedTokens);
|
|
346
|
+
const top = report.topTechnique ?? "none";
|
|
347
|
+
const topShare = report.topTechnique && report.totalSavedTokens > 0
|
|
348
|
+
? Math.round(((report.techniqueSavings[report.topTechnique] ?? 0) / report.totalSavedTokens) * 100)
|
|
349
|
+
: 0;
|
|
350
|
+
return `TOKEN-NOVA ยท ${tokens} tokens saved ยท $${report.estimatedUsdSaved.toFixed(3)} ยท top=${top} (${topShare}%)`;
|
|
351
|
+
}
|
|
352
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/token_nova/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA8BzC,6EAA6E;AAC7E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAG,GAAG,CAAC;AAEvC;;wEAEwE;AACxE,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,IAAI,CAAC,IAAI;QAAE,OAAO,CAAC,CAAC;IACpB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAA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