@sriinnu/fiche 0.18.0-bootstrap.0 → 0.19.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 +134 -0
- package/LICENSE +22 -0
- package/NOTICE +13 -0
- package/PRIVACY.md +41 -0
- package/README.md +289 -0
- package/SECURITY.md +53 -0
- package/assets/JETBRAINS_MONO_LICENSE.txt +89 -0
- package/assets/SPLEEN_LICENSE.txt +24 -0
- package/assets/UNIFONT_LICENSE.txt +476 -0
- package/assets/fiche-logo-dark.svg +61 -0
- package/assets/fiche-logo-light.svg +61 -0
- package/assets/fiche-logo.svg +71 -0
- package/assets/fiche-mark.svg +48 -0
- package/bin/cli.js +7 -0
- package/bin/mcp.js +8 -0
- package/dist/calibrate.d.ts +30 -0
- package/dist/calibrate.js +588 -0
- package/dist/core/anthropic-vision.d.ts +28 -0
- package/dist/core/anthropic-vision.js +34 -0
- package/dist/core/applicability.d.ts +63 -0
- package/dist/core/applicability.js +151 -0
- package/dist/core/atlas-gray-jbmono10.d.ts +26 -0
- package/dist/core/atlas-gray-jbmono10.js +64 -0
- package/dist/core/atlas-gray-jbmono12.d.ts +26 -0
- package/dist/core/atlas-gray-jbmono12.js +64 -0
- package/dist/core/atlas-gray-jbmono14.d.ts +26 -0
- package/dist/core/atlas-gray-jbmono14.js +64 -0
- package/dist/core/atlas-gray.d.ts +26 -0
- package/dist/core/atlas-gray.js +64 -0
- package/dist/core/atlas-jbmono10.d.ts +34 -0
- package/dist/core/atlas-jbmono10.js +71 -0
- package/dist/core/atlas-jbmono12.d.ts +34 -0
- package/dist/core/atlas-jbmono12.js +71 -0
- package/dist/core/atlas-jbmono14.d.ts +34 -0
- package/dist/core/atlas-jbmono14.js +71 -0
- package/dist/core/atlas.d.ts +34 -0
- package/dist/core/atlas.js +71 -0
- package/dist/core/baseline.d.ts +121 -0
- package/dist/core/baseline.js +200 -0
- package/dist/core/calibration.d.ts +86 -0
- package/dist/core/calibration.js +547 -0
- package/dist/core/casi-delta.d.ts +63 -0
- package/dist/core/casi-delta.js +1271 -0
- package/dist/core/claude-model-profiles.d.ts +53 -0
- package/dist/core/claude-model-profiles.js +160 -0
- package/dist/core/client-tool-round.d.ts +31 -0
- package/dist/core/client-tool-round.js +58 -0
- package/dist/core/codex-cache.d.ts +20 -0
- package/dist/core/codex-cache.js +59 -0
- package/dist/core/context-mmu.d.ts +350 -0
- package/dist/core/context-mmu.js +3028 -0
- package/dist/core/cpt-fit.d.ts +70 -0
- package/dist/core/cpt-fit.js +197 -0
- package/dist/core/env.d.ts +8 -0
- package/dist/core/env.js +15 -0
- package/dist/core/export.d.ts +127 -0
- package/dist/core/export.js +385 -0
- package/dist/core/factsheet.d.ts +77 -0
- package/dist/core/factsheet.js +494 -0
- package/dist/core/gemini-model-profiles.d.ts +20 -0
- package/dist/core/gemini-model-profiles.js +134 -0
- package/dist/core/google.d.ts +76 -0
- package/dist/core/google.js +1380 -0
- package/dist/core/gpt-model-profiles.d.ts +218 -0
- package/dist/core/gpt-model-profiles.js +570 -0
- package/dist/core/gpt-tokens.d.ts +14 -0
- package/dist/core/gpt-tokens.js +165 -0
- package/dist/core/history.d.ts +197 -0
- package/dist/core/history.js +1003 -0
- package/dist/core/index.d.ts +16 -0
- package/dist/core/index.js +16 -0
- package/dist/core/library.d.ts +80 -0
- package/dist/core/library.js +131 -0
- package/dist/core/measurement.d.ts +34 -0
- package/dist/core/measurement.js +280 -0
- package/dist/core/messages-chat-bridge.d.ts +23 -0
- package/dist/core/messages-chat-bridge.js +747 -0
- package/dist/core/messages-responses-bridge.d.ts +11 -0
- package/dist/core/messages-responses-bridge.js +893 -0
- package/dist/core/openai-history.d.ts +184 -0
- package/dist/core/openai-history.js +1279 -0
- package/dist/core/openai-savings.d.ts +57 -0
- package/dist/core/openai-savings.js +116 -0
- package/dist/core/openai.d.ts +68 -0
- package/dist/core/openai.js +2523 -0
- package/dist/core/pin.d.ts +199 -0
- package/dist/core/pin.js +1353 -0
- package/dist/core/png.d.ts +14 -0
- package/dist/core/png.js +188 -0
- package/dist/core/prefix-tape.d.ts +102 -0
- package/dist/core/prefix-tape.js +315 -0
- package/dist/core/price-id.d.ts +10 -0
- package/dist/core/price-id.js +26 -0
- package/dist/core/prices.generated.d.ts +36 -0
- package/dist/core/prices.generated.js +369 -0
- package/dist/core/pricing.d.ts +134 -0
- package/dist/core/pricing.js +335 -0
- package/dist/core/profile-base.d.ts +30 -0
- package/dist/core/profile-base.js +67 -0
- package/dist/core/provider-router.d.ts +51 -0
- package/dist/core/provider-router.js +121 -0
- package/dist/core/proxy.d.ts +252 -0
- package/dist/core/proxy.js +2929 -0
- package/dist/core/reader-tier.d.ts +24 -0
- package/dist/core/reader-tier.js +118 -0
- package/dist/core/render.d.ts +280 -0
- package/dist/core/render.js +1302 -0
- package/dist/core/request-guard.d.ts +31 -0
- package/dist/core/request-guard.js +126 -0
- package/dist/core/request-transform.d.ts +43 -0
- package/dist/core/request-transform.js +173 -0
- package/dist/core/schema-compiler.d.ts +64 -0
- package/dist/core/schema-compiler.js +1696 -0
- package/dist/core/schema-strip.d.ts +29 -0
- package/dist/core/schema-strip.js +173 -0
- package/dist/core/session-state.d.ts +219 -0
- package/dist/core/session-state.js +929 -0
- package/dist/core/stage-plugins.d.ts +45 -0
- package/dist/core/stage-plugins.js +205 -0
- package/dist/core/text-history.d.ts +74 -0
- package/dist/core/text-history.js +612 -0
- package/dist/core/text-hygiene.d.ts +160 -0
- package/dist/core/text-hygiene.js +2259 -0
- package/dist/core/toon.d.ts +29 -0
- package/dist/core/toon.js +425 -0
- package/dist/core/tracker.d.ts +223 -0
- package/dist/core/tracker.js +290 -0
- package/dist/core/transform.d.ts +589 -0
- package/dist/core/transform.js +3153 -0
- package/dist/core/types.d.ts +87 -0
- package/dist/core/types.js +8 -0
- package/dist/core/upstream-hosts.d.ts +127 -0
- package/dist/core/upstream-hosts.js +398 -0
- package/dist/core/vision-cost.d.ts +63 -0
- package/dist/core/vision-cost.js +137 -0
- package/dist/dashboard/fragments.d.ts +87 -0
- package/dist/dashboard/fragments.js +1515 -0
- package/dist/dashboard/types.d.ts +217 -0
- package/dist/dashboard/types.js +3 -0
- package/dist/dashboard/vendor.d.ts +3 -0
- package/dist/dashboard/vendor.js +6 -0
- package/dist/dashboard.d.ts +372 -0
- package/dist/dashboard.js +2731 -0
- package/dist/export-collect.d.ts +36 -0
- package/dist/export-collect.js +59 -0
- package/dist/file-tracker.d.ts +42 -0
- package/dist/file-tracker.js +234 -0
- package/dist/kosha-sync.d.ts +74 -0
- package/dist/kosha-sync.js +272 -0
- package/dist/launchd-socket.d.ts +22 -0
- package/dist/launchd-socket.js +210 -0
- package/dist/mcp/cli.d.ts +2 -0
- package/dist/mcp/cli.js +55 -0
- package/dist/mcp/server.d.ts +48 -0
- package/dist/mcp/server.js +987 -0
- package/dist/mmu-store.d.ts +31 -0
- package/dist/mmu-store.js +179 -0
- package/dist/node-fetch.d.ts +22 -0
- package/dist/node-fetch.js +489 -0
- package/dist/node.d.ts +9 -0
- package/dist/node.js +244396 -0
- package/dist/request-decoding.d.ts +30 -0
- package/dist/request-decoding.js +85 -0
- package/dist/sessions.d.ts +179 -0
- package/dist/sessions.js +837 -0
- package/dist/stats.d.ts +114 -0
- package/dist/stats.js +439 -0
- package/dist/turn-report.d.ts +65 -0
- package/dist/turn-report.js +724 -0
- package/dist/warp/app-launch.d.ts +26 -0
- package/dist/warp/app-launch.js +155 -0
- package/dist/warp/ca.d.ts +74 -0
- package/dist/warp/ca.js +416 -0
- package/dist/warp/connect.d.ts +42 -0
- package/dist/warp/connect.js +686 -0
- package/dist/warp/der.d.ts +57 -0
- package/dist/warp/der.js +151 -0
- package/dist/warp/index.d.ts +79 -0
- package/dist/warp/index.js +650 -0
- package/dist/warp/resolve.d.ts +12 -0
- package/dist/warp/resolve.js +49 -0
- package/dist/warp/route.d.ts +71 -0
- package/dist/warp/route.js +134 -0
- package/dist/worker.d.ts +71 -0
- package/dist/worker.js +174 -0
- package/docs/SECURITY_MODEL.md +84 -0
- package/package.json +115 -3
- package/plugins/fiche-companion/README.md +42 -0
- package/plugins/fiche-companion/assets/logo.svg +48 -0
- package/plugins/fiche-companion/hooks.json +11 -0
- package/plugins/fiche-companion/mcp_config.json +8 -0
- package/plugins/fiche-companion/plugin.json +18 -0
- package/plugins/fiche-companion/scripts/claude-statusline.mjs +35 -0
- package/plugins/fiche-companion/scripts/post-invocation.mjs +122 -0
- package/plugins/fiche-companion/scripts/resolve-turn-report.mjs +132 -0
- package/plugins/fiche-companion/skills/fiche/SKILL.md +61 -0
|
@@ -0,0 +1,570 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-model GPT rendering + vision-cost profiles.
|
|
3
|
+
*
|
|
4
|
+
* One place to retune when a new model ships with different image tokenization,
|
|
5
|
+
* a different downscale threshold (max safe portrait-strip width), or a different
|
|
6
|
+
* max image height. Unknown models preserve the conservative legacy fallback;
|
|
7
|
+
* named profiles may deliberately select different fonts and geometry.
|
|
8
|
+
*
|
|
9
|
+
* Retune without a code change via the INKLING_GPT_PROFILES env var (JSON map of
|
|
10
|
+
* model-id PREFIX -> partial profile; longest matching prefix wins, checked
|
|
11
|
+
* BEFORE the built-in table). Partial fields fall back to the built-in match, so
|
|
12
|
+
* you can override just one knob:
|
|
13
|
+
*
|
|
14
|
+
* INKLING_GPT_PROFILES='{"gpt-5.6-sol":{"vision":{"regime":"patch","multiplier":1,"patchCap":12000},"stripCols":120,"maxHeightPx":1900}}'
|
|
15
|
+
* INKLING_GPT_PROFILES='{"gpt-5.6-sol":{"style":{"grid":true,"gridCols":4}}}'
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* GPT strip height, DECOUPLED from render.ts's MAX_HEIGHT_PX (which is Anthropic's
|
|
19
|
+
* 1568-edge / ~1.15 MP clamp). Named profiles may override this where their image
|
|
20
|
+
* sizing and font geometry differ.
|
|
21
|
+
*/
|
|
22
|
+
import { readBrandEnv } from './env.js';
|
|
23
|
+
import {} from './render.js';
|
|
24
|
+
import { calibratedBandToProfile, getCalibratedProfile } from './calibration.js';
|
|
25
|
+
import { hasGeminiMeasuredProfile, resolveGeminiProfile } from './gemini-model-profiles.js';
|
|
26
|
+
import { isClaudeModel, resolveClaudeProfile } from './claude-model-profiles.js';
|
|
27
|
+
import { BASE_HISTORY, BASE_PRICING, BASE_STYLE, NATIVE_14PX_HISTORY } from './profile-base.js';
|
|
28
|
+
export { calibratedBandToProfile };
|
|
29
|
+
export const GPT_MAX_HEIGHT_PX = 1932;
|
|
30
|
+
/** Default downscale-safe strip width (768px). Exported as the global cols default. */
|
|
31
|
+
export const DEFAULT_GPT_STRIP_COLS = 152;
|
|
32
|
+
const C = DEFAULT_GPT_STRIP_COLS;
|
|
33
|
+
const H = GPT_MAX_HEIGHT_PX;
|
|
34
|
+
/** gpt-5 family list prices: cached input $0.125 / input $1.25 / output $10 per 1M. */
|
|
35
|
+
const GPT5_PRICING = { cacheReadRate: 0.1, outputRate: 8 };
|
|
36
|
+
/**
|
|
37
|
+
* Conservative fallback for unrecognized models: tile 85/170 over-states cost,
|
|
38
|
+
* which biases the gate toward pass-through (safe). Matches gpt-4o/4.1/4.5.
|
|
39
|
+
*/
|
|
40
|
+
export const DEFAULT_GPT_PROFILE = {
|
|
41
|
+
vision: { regime: 'tile', base: 85, perTile: 170 },
|
|
42
|
+
...BASE_PRICING,
|
|
43
|
+
stripCols: C,
|
|
44
|
+
maxHeightPx: H,
|
|
45
|
+
minCompressTokens: 500,
|
|
46
|
+
factSheetFormat: 'full',
|
|
47
|
+
history: BASE_HISTORY,
|
|
48
|
+
style: BASE_STYLE,
|
|
49
|
+
};
|
|
50
|
+
const GPT56_SOL_PROFILE = {
|
|
51
|
+
cacheWriteRate: 1.25,
|
|
52
|
+
cacheBreakpoints: true,
|
|
53
|
+
// GPT-5.6 / GPT-6.1 Sol original detail bills the submitted 32px patches without a patch cap.
|
|
54
|
+
vision: { regime: 'patch', multiplier: 1 },
|
|
55
|
+
...GPT5_PRICING,
|
|
56
|
+
// Sol pins an exact static slab, so the gate compares against the measured
|
|
57
|
+
// baseline rather than re-tokenizing the rendered text.
|
|
58
|
+
exactStaticBaseline: true,
|
|
59
|
+
// Match the native 14px reader profile. Sol remains opt-in: its two-fixture
|
|
60
|
+
// pilot retained gist/guard and had no unsupported inventions, but one exact
|
|
61
|
+
// identifier was truncated.
|
|
62
|
+
stripCols: 84,
|
|
63
|
+
// 1954px permits 149 rows at an actual 1945px, filling 61 patch rows.
|
|
64
|
+
maxHeightPx: 1954,
|
|
65
|
+
minCompressTokens: 500,
|
|
66
|
+
factSheetFormat: 'full',
|
|
67
|
+
history: {
|
|
68
|
+
...NATIVE_14PX_HISTORY,
|
|
69
|
+
// Taller 1954px pages: more chars/image, so Sol can hold a larger budget
|
|
70
|
+
// without the 512px latency cliff that Grok/Qwen hit.
|
|
71
|
+
maxImages: 64,
|
|
72
|
+
// Prefix-stable per-segment factsheets avoid re-rendering earlier prefix
|
|
73
|
+
// parts when new chunks seal.
|
|
74
|
+
factSheetScope: 'per-segment',
|
|
75
|
+
},
|
|
76
|
+
style: {
|
|
77
|
+
...BASE_STYLE,
|
|
78
|
+
font: 'jetbrains-mono-14',
|
|
79
|
+
cellWBonus: 0,
|
|
80
|
+
cellHBonus: 0,
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
const GPT6_PROFILE = {
|
|
84
|
+
...DEFAULT_GPT_PROFILE,
|
|
85
|
+
imageDetail: 'original',
|
|
86
|
+
vision: { regime: 'patch', multiplier: 1.2 },
|
|
87
|
+
stripCols: 152,
|
|
88
|
+
cacheReadRate: 0.1,
|
|
89
|
+
cacheWriteRate: 1.25,
|
|
90
|
+
cacheBreakpoints: true,
|
|
91
|
+
outputRate: 5,
|
|
92
|
+
exactStaticBaseline: true,
|
|
93
|
+
factSheetFormat: 'compact',
|
|
94
|
+
history: {
|
|
95
|
+
...BASE_HISTORY,
|
|
96
|
+
maxImages: 200,
|
|
97
|
+
keepTail: 1,
|
|
98
|
+
keepRecentPairs: 1,
|
|
99
|
+
minCollapseTokens: 0,
|
|
100
|
+
minCollapsePrefix: 1,
|
|
101
|
+
collapseChunk: 1,
|
|
102
|
+
freezeChunk: 1,
|
|
103
|
+
reflow: true,
|
|
104
|
+
factSheetOverflow: 'native-opaque',
|
|
105
|
+
maxCachePaybackReads: 10,
|
|
106
|
+
responsesMode: 'mixed',
|
|
107
|
+
framing: 'compact',
|
|
108
|
+
factSheetScope: 'per-segment',
|
|
109
|
+
},
|
|
110
|
+
style: {
|
|
111
|
+
...BASE_STYLE,
|
|
112
|
+
font: 'spleen-5x8',
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
/** True for the patch-billed mini/nano family (incl. o4-mini). */
|
|
116
|
+
const isMiniNanoPatch = (m) => /^(?:gpt-5(?:\.\d+)?|gpt-4\.1)-(?:mini|nano)/.test(m) || /^o4-mini/.test(m);
|
|
117
|
+
/** Grok ids inkling has a measured profile for. */
|
|
118
|
+
const isGrokModel = (m) => /^grok-/.test(m);
|
|
119
|
+
/** Qwen 3.8 27B ids — the only Qwen geometry inkling has measured. Other Qwen
|
|
120
|
+
* variants deliberately do NOT match: the family-id guard below refuses them
|
|
121
|
+
* instead of gating an unmeasured model with this profile. */
|
|
122
|
+
const isQwenModel = (m) => /qwen3\.8-27b/i.test(m);
|
|
123
|
+
/** Shared GPT geometry for the small patch-billed models; only the patch
|
|
124
|
+
* multiplier and the family list prices differ between the rules below. */
|
|
125
|
+
const miniNanoProfile = (multiplier, pricing) => ({
|
|
126
|
+
vision: { regime: 'patch', multiplier, patchCap: 1536 },
|
|
127
|
+
...pricing,
|
|
128
|
+
stripCols: C,
|
|
129
|
+
maxHeightPx: H,
|
|
130
|
+
minCompressTokens: 500,
|
|
131
|
+
factSheetFormat: 'full',
|
|
132
|
+
history: BASE_HISTORY,
|
|
133
|
+
style: BASE_STYLE,
|
|
134
|
+
});
|
|
135
|
+
/** True for GPT-5.6 / GPT-6+ Sol optical reader models (incl. gpt-6-sol, gpt-6.1-sol, gpt-6.2-sol, future 6.x/7+). */
|
|
136
|
+
export const isGptSolModel = (m) => /^gpt-(?:5\.6|(?:[6-9]|\d{2,})(?:\.\d+)?)-sol(?:-|$)/.test(m);
|
|
137
|
+
/**
|
|
138
|
+
* Built-in profiles, evaluated in order (first match wins). Precedence and
|
|
139
|
+
* numbers reproduce the previous hardcoded `resolveVisionCost` EXACTLY:
|
|
140
|
+
* mini/nano -> patch (nano 2.46 / mini 1.62, cap 1536), BEFORE 5.x flagship.
|
|
141
|
+
*/
|
|
142
|
+
const BUILTIN_RULES = [
|
|
143
|
+
// Exact Sol variant observed on production traffic. Do not match bare 5.6/6.1
|
|
144
|
+
// or sibling variants (for example gpt-5.6-terra): model-specific visual
|
|
145
|
+
// tuning must not leak across variants merely because they share a version
|
|
146
|
+
// number. Evaluated before the generic GPT-6+ family rule so gpt-6-sol and
|
|
147
|
+
// future gpt-6.x-sol / gpt-7+-sol inherit Sol's native 14px profile rather
|
|
148
|
+
// than GPT6_PROFILE's 5x8 Spleen.
|
|
149
|
+
{
|
|
150
|
+
test: isGptSolModel,
|
|
151
|
+
profile: GPT56_SOL_PROFILE,
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
test: (m) => /^gpt-(?:[6-9]|\d{2,})(?:[.-]|$)/.test(m),
|
|
155
|
+
profile: GPT6_PROFILE,
|
|
156
|
+
},
|
|
157
|
+
// nano patch models: ceil(patches * 2.46), cap 1536
|
|
158
|
+
{
|
|
159
|
+
test: (m) => isMiniNanoPatch(m) && /nano/.test(m) && /^gpt-5/.test(m),
|
|
160
|
+
profile: miniNanoProfile(2.46, GPT5_PRICING),
|
|
161
|
+
},
|
|
162
|
+
// gpt-4.1-nano: same tokenization, older (less aggressive) cache discount.
|
|
163
|
+
{
|
|
164
|
+
test: (m) => isMiniNanoPatch(m) && /nano/.test(m),
|
|
165
|
+
profile: miniNanoProfile(2.46, BASE_PRICING),
|
|
166
|
+
},
|
|
167
|
+
// mini / o4-mini patch models: ceil(patches * 1.62), cap 1536
|
|
168
|
+
{
|
|
169
|
+
test: (m) => isMiniNanoPatch(m) && /^gpt-5/.test(m),
|
|
170
|
+
profile: miniNanoProfile(1.62, GPT5_PRICING),
|
|
171
|
+
},
|
|
172
|
+
// gpt-4.1-mini / o4-mini: same tokenization, older cache discount.
|
|
173
|
+
{
|
|
174
|
+
test: isMiniNanoPatch,
|
|
175
|
+
profile: miniNanoProfile(1.62, BASE_PRICING),
|
|
176
|
+
},
|
|
177
|
+
// 5.x flagship (gpt-5.4/5.5/…, no -mini/-nano): patch, multiplier 1, detail:original cap
|
|
178
|
+
{
|
|
179
|
+
test: (m) => /^gpt-5\.\d/.test(m),
|
|
180
|
+
profile: { vision: { regime: 'patch', multiplier: 1, patchCap: 10000 }, ...GPT5_PRICING, stripCols: C, maxHeightPx: H, minCompressTokens: 500, factSheetFormat: 'full', history: BASE_HISTORY, style: BASE_STYLE },
|
|
181
|
+
},
|
|
182
|
+
// gpt-5 / gpt-5-chat-latest: tile 70/140
|
|
183
|
+
{
|
|
184
|
+
test: (m) => /^gpt-5/.test(m),
|
|
185
|
+
profile: { vision: { regime: 'tile', base: 70, perTile: 140 }, ...GPT5_PRICING, stripCols: C, maxHeightPx: H, minCompressTokens: 500, factSheetFormat: 'full', history: BASE_HISTORY, style: BASE_STYLE },
|
|
186
|
+
},
|
|
187
|
+
// o1 / o3 reasoning: tile 75/150
|
|
188
|
+
{
|
|
189
|
+
test: (m) => /^o[13]/.test(m),
|
|
190
|
+
profile: { vision: { regime: 'tile', base: 75, perTile: 150 }, ...BASE_PRICING, stripCols: C, maxHeightPx: H, minCompressTokens: 500, factSheetFormat: 'full', history: BASE_HISTORY, style: BASE_STYLE },
|
|
191
|
+
},
|
|
192
|
+
// Grok remains opt-in. Native 14px / 84 cols / maxH 512 is the densest best
|
|
193
|
+
// rung from the JB Mono 8–16px blind sweep (eval/grok-density/native-sweep).
|
|
194
|
+
{
|
|
195
|
+
test: isGrokModel,
|
|
196
|
+
profile: {
|
|
197
|
+
// Measured 2026-07-09 on grok-4.5: image-token delta ≈ 1000 per megapixel
|
|
198
|
+
// across several page sizes (768x336 → 268, 764x980 → 748, etc.).
|
|
199
|
+
vision: { regime: 'mpix', tokensPerMegapixel: 1000 },
|
|
200
|
+
// xAI model pricing metadata: cachedPromptTokenPrice/promptTextTokenPrice
|
|
201
|
+
// = 5000/20000; completionTextTokenPrice/promptTextTokenPrice = 60000/20000.
|
|
202
|
+
cacheReadRate: 0.25,
|
|
203
|
+
outputRate: 3,
|
|
204
|
+
// Native 14px was the densest best rung on the Grok JB Mono 8–16px blind
|
|
205
|
+
// sweep (4/8 exact, 4 confab, 48% savings). 84 × 9px + pad = 764px ≤ 768.
|
|
206
|
+
// No rung was fully clean; 14px tied 15/16px on exact and beat smaller cells.
|
|
207
|
+
stripCols: 84,
|
|
208
|
+
maxHeightPx: 512,
|
|
209
|
+
minCompressTokens: 500,
|
|
210
|
+
factSheetFormat: 'full',
|
|
211
|
+
// pairs only groups INDEX-CONTIGUOUS tool rounds. Codex puts an assistant
|
|
212
|
+
// message between rounds, so every round is its own run and leftover
|
|
213
|
+
// history stays text — which is why grok-4.6 showed ~0 saved. mixed
|
|
214
|
+
// groups safe messages with completed pairs.
|
|
215
|
+
history: { ...NATIVE_14PX_HISTORY },
|
|
216
|
+
style: {
|
|
217
|
+
...BASE_STYLE,
|
|
218
|
+
font: 'jetbrains-mono-14',
|
|
219
|
+
aa: true,
|
|
220
|
+
grid: false,
|
|
221
|
+
gridCols: 0,
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
// Qwen 3.8 27B (Workers AI / open weights). Native 14px / 84 cols / maxH 512 is required
|
|
226
|
+
// because 5x8 bitmap glyphs are illegible to Qwen vision (0/15 hex vs 11/15 on 14px).
|
|
227
|
+
// Workers AI hard-rejects requests over 32 images, so providerImageCap makes the
|
|
228
|
+
// history budget dynamic: 32 minus every image already in the request.
|
|
229
|
+
{
|
|
230
|
+
test: isQwenModel,
|
|
231
|
+
profile: {
|
|
232
|
+
vision: { regime: 'mpix', tokensPerMegapixel: 1000 },
|
|
233
|
+
cacheReadRate: 0.25,
|
|
234
|
+
outputRate: 3,
|
|
235
|
+
providerImageCap: 32,
|
|
236
|
+
stripCols: 84,
|
|
237
|
+
maxHeightPx: 512,
|
|
238
|
+
minCompressTokens: 500,
|
|
239
|
+
factSheetFormat: 'full',
|
|
240
|
+
history: { ...NATIVE_14PX_HISTORY },
|
|
241
|
+
style: {
|
|
242
|
+
...BASE_STYLE,
|
|
243
|
+
font: 'jetbrains-mono-14',
|
|
244
|
+
aa: true,
|
|
245
|
+
grid: false,
|
|
246
|
+
gridCols: 0,
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
];
|
|
251
|
+
/**
|
|
252
|
+
* Families whose profile test is NARROWER than the ids that name them, with the
|
|
253
|
+
* test each one owns. Claude and GPT need no entry: every id that mentions them
|
|
254
|
+
* resolves to one of their profiles.
|
|
255
|
+
*/
|
|
256
|
+
const FAMILY_ID_GUARDS = [
|
|
257
|
+
{ mentions: /gemini/, matches: hasGeminiMeasuredProfile },
|
|
258
|
+
{ mentions: /grok/, matches: isGrokModel },
|
|
259
|
+
{ mentions: /qwen/, matches: isQwenModel },
|
|
260
|
+
];
|
|
261
|
+
/** True when the operator declared this id in INKLING_GPT_PROFILES. The guards
|
|
262
|
+
* above catch implicit fallback to another provider's formula; an explicit
|
|
263
|
+
* declaration supplies geometry and vision cost, so it clears them. */
|
|
264
|
+
function hasDeclaredProfile(m) {
|
|
265
|
+
const env = envProfiles();
|
|
266
|
+
if (env.size === 0)
|
|
267
|
+
return false;
|
|
268
|
+
const ids = candidateIds(m);
|
|
269
|
+
for (const k of env.keys())
|
|
270
|
+
if (ids.some((id) => id.startsWith(k)))
|
|
271
|
+
return true;
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* True when an id NAMES a known provider family but does not match that
|
|
276
|
+
* family's profile test — for example `gemini-3.6-pro`, when 3.6 Flash is the
|
|
277
|
+
* only Gemini geometry inkling has measured. Such an id would fall through to
|
|
278
|
+
* DEFAULT_GPT_PROFILE and be gated with OpenAI's tile math, i.e. priced with
|
|
279
|
+
* the wrong provider's formula, so applicability refuses it instead of
|
|
280
|
+
* compressing against numbers that do not apply to it.
|
|
281
|
+
*
|
|
282
|
+
* (DEFAULT_GPT_PROFILE is a legitimate *OpenAI* fallback — gpt-4o and friends
|
|
283
|
+
* are deliberately gated with its conservative tile cost — so resolving to the
|
|
284
|
+
* default is only a problem when the id is not an OpenAI id at all.)
|
|
285
|
+
*/
|
|
286
|
+
export function isMisresolvedModelId(model) {
|
|
287
|
+
const m = (model ?? '').toLowerCase();
|
|
288
|
+
if (hasDeclaredProfile(m))
|
|
289
|
+
return false;
|
|
290
|
+
const cal = getCalibratedProfile(model);
|
|
291
|
+
if (cal && cal.scores.passed && cal.band !== 'text-only')
|
|
292
|
+
return false;
|
|
293
|
+
// Must cover every spelling resolveGptProfile() tries, or guard and resolver
|
|
294
|
+
// disagree: `openrouter/gemini-3.6-flash` resolves to the measured Gemini
|
|
295
|
+
// profile via its unqualified id, so it must not be refused here.
|
|
296
|
+
const ids = candidateIds(m);
|
|
297
|
+
return FAMILY_ID_GUARDS.some((g) => ids.some((id) => g.mentions.test(id)) && !ids.some((id) => g.matches(id)));
|
|
298
|
+
}
|
|
299
|
+
function resolveBuiltin(m) {
|
|
300
|
+
// Claude first, and by whole-id match rather than a rule in the table below:
|
|
301
|
+
// Anthropic geometry and pixel billing differ from GPT's, so a Claude model
|
|
302
|
+
// that fell through to a GPT rule (or to DEFAULT_GPT_PROFILE) would have its
|
|
303
|
+
// image cost overstated, flipping the slab gate to not_profitable and leaving
|
|
304
|
+
// it text-only.
|
|
305
|
+
if (isClaudeModel(m))
|
|
306
|
+
return resolveClaudeProfile(m);
|
|
307
|
+
for (const rule of BUILTIN_RULES)
|
|
308
|
+
if (rule.test(m))
|
|
309
|
+
return rule.profile;
|
|
310
|
+
return DEFAULT_GPT_PROFILE;
|
|
311
|
+
}
|
|
312
|
+
// --- env override (INKLING_GPT_PROFILES) -----------------------------------
|
|
313
|
+
// Parsed lazily and memoized on the raw env string so tests can mutate
|
|
314
|
+
// process.env and have it re-read, without re-parsing on every hot-path call.
|
|
315
|
+
let envRaw = null;
|
|
316
|
+
let envMap = new Map();
|
|
317
|
+
function isValidVision(v) {
|
|
318
|
+
if (!v || typeof v !== 'object')
|
|
319
|
+
return false;
|
|
320
|
+
const o = v;
|
|
321
|
+
if (o.regime === 'tile')
|
|
322
|
+
return Number.isFinite(o.base) && Number.isFinite(o.perTile);
|
|
323
|
+
if (o.regime === 'patch') {
|
|
324
|
+
return Number.isFinite(o.multiplier) &&
|
|
325
|
+
(o.patchCap === undefined || (Number.isFinite(o.patchCap) && o.patchCap > 0));
|
|
326
|
+
}
|
|
327
|
+
if (o.regime === 'patch28')
|
|
328
|
+
return true;
|
|
329
|
+
if (o.regime === 'mpix') {
|
|
330
|
+
return Number.isFinite(o.tokensPerMegapixel) && o.tokensPerMegapixel > 0;
|
|
331
|
+
}
|
|
332
|
+
if (o.regime === 'flat') {
|
|
333
|
+
if (!Number.isFinite(o.tokens) || o.tokens <= 0)
|
|
334
|
+
return false;
|
|
335
|
+
if (o.exact === undefined)
|
|
336
|
+
return true;
|
|
337
|
+
const e = o.exact;
|
|
338
|
+
return !!e && typeof e === 'object' &&
|
|
339
|
+
Number.isFinite(e.widthPx) && e.widthPx > 0 &&
|
|
340
|
+
Number.isFinite(e.heightPx) && e.heightPx > 0 &&
|
|
341
|
+
Number.isFinite(e.tokens) && e.tokens > 0;
|
|
342
|
+
}
|
|
343
|
+
return false;
|
|
344
|
+
}
|
|
345
|
+
/** Price ratios must be positive and finite; anything else keeps the built-in. */
|
|
346
|
+
function rate(v, fallback) {
|
|
347
|
+
return Number.isFinite(v) && v > 0 ? v : fallback;
|
|
348
|
+
}
|
|
349
|
+
function posInt(v, fallback) {
|
|
350
|
+
return Number.isFinite(v) && v > 0 ? Math.floor(v) : fallback;
|
|
351
|
+
}
|
|
352
|
+
function nonNegativeInt(v, fallback) {
|
|
353
|
+
return Number.isFinite(v) && v >= 0 ? Math.floor(v) : fallback;
|
|
354
|
+
}
|
|
355
|
+
function renderFont(v, fallback) {
|
|
356
|
+
return v === 'spleen-5x8' || v === 'jetbrains-mono-10' || v === 'jetbrains-mono-12' || v === 'jetbrains-mono-14'
|
|
357
|
+
? v
|
|
358
|
+
: fallback;
|
|
359
|
+
}
|
|
360
|
+
function factSheetFormat(v, fallback) {
|
|
361
|
+
return v === 'full' || v === 'compact' ? v : fallback;
|
|
362
|
+
}
|
|
363
|
+
function responsesMode(v, fallback) {
|
|
364
|
+
return v === 'pairs' || v === 'mixed' ? v : fallback;
|
|
365
|
+
}
|
|
366
|
+
function historyFraming(v, fallback) {
|
|
367
|
+
return v === 'full' || v === 'compact' ? v : fallback;
|
|
368
|
+
}
|
|
369
|
+
function factSheetScope(v, fallback) {
|
|
370
|
+
return v === 'per-segment' || v === 'combined' ? v : fallback;
|
|
371
|
+
}
|
|
372
|
+
function parseEnvProfiles(raw) {
|
|
373
|
+
const out = new Map();
|
|
374
|
+
if (!raw)
|
|
375
|
+
return out;
|
|
376
|
+
let obj;
|
|
377
|
+
try {
|
|
378
|
+
obj = JSON.parse(raw);
|
|
379
|
+
}
|
|
380
|
+
catch {
|
|
381
|
+
return out; // malformed env never throws — fall back to built-ins
|
|
382
|
+
}
|
|
383
|
+
if (!obj || typeof obj !== 'object')
|
|
384
|
+
return out;
|
|
385
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
386
|
+
if (!v || typeof v !== 'object')
|
|
387
|
+
continue;
|
|
388
|
+
const key = k.toLowerCase();
|
|
389
|
+
// An exact override key may be a prefix of the real model id. Resolve the
|
|
390
|
+
// known family explicitly so `{"gpt-5.6-sol":{...}}` inherits Sol's font
|
|
391
|
+
// and geometry even when a suffixed runtime id is expected.
|
|
392
|
+
const base = isGptSolModel(key)
|
|
393
|
+
? GPT56_SOL_PROFILE
|
|
394
|
+
: resolveBuiltin(key);
|
|
395
|
+
const p = v;
|
|
396
|
+
const styleIn = p.style;
|
|
397
|
+
const historyIn = p.history;
|
|
398
|
+
const baseStyle = base.style;
|
|
399
|
+
const baseHistory = base.history;
|
|
400
|
+
const style = {
|
|
401
|
+
font: renderFont(styleIn?.font, baseStyle.font),
|
|
402
|
+
cellWBonus: nonNegativeInt(styleIn?.cellWBonus, baseStyle.cellWBonus),
|
|
403
|
+
cellHBonus: nonNegativeInt(styleIn?.cellHBonus, baseStyle.cellHBonus),
|
|
404
|
+
aa: styleIn && typeof styleIn.aa === 'boolean' ? styleIn.aa : baseStyle.aa,
|
|
405
|
+
grid: styleIn && typeof styleIn.grid === 'boolean' ? styleIn.grid : baseStyle.grid,
|
|
406
|
+
gridCols: nonNegativeInt(styleIn?.gridCols, baseStyle.gridCols),
|
|
407
|
+
colorCycle: styleIn && typeof styleIn.colorCycle === 'boolean'
|
|
408
|
+
? styleIn.colorCycle
|
|
409
|
+
: baseStyle.colorCycle,
|
|
410
|
+
markerScale: posInt(styleIn?.markerScale, baseStyle.markerScale),
|
|
411
|
+
markerRed: styleIn && typeof styleIn.markerRed === 'boolean'
|
|
412
|
+
? styleIn.markerRed
|
|
413
|
+
: baseStyle.markerRed,
|
|
414
|
+
inkDilate: nonNegativeInt(styleIn?.inkDilate, baseStyle.inkDilate),
|
|
415
|
+
};
|
|
416
|
+
const history = {
|
|
417
|
+
maxImages: posInt(historyIn?.maxImages, baseHistory.maxImages),
|
|
418
|
+
keepTail: nonNegativeInt(historyIn?.keepTail, baseHistory.keepTail),
|
|
419
|
+
keepRecentPairs: nonNegativeInt(historyIn?.keepRecentPairs, baseHistory.keepRecentPairs),
|
|
420
|
+
minCollapseTokens: nonNegativeInt(historyIn?.minCollapseTokens, baseHistory.minCollapseTokens),
|
|
421
|
+
minCollapsePrefix: historyIn?.minCollapsePrefix === undefined
|
|
422
|
+
? baseHistory.minCollapsePrefix
|
|
423
|
+
: nonNegativeInt(historyIn.minCollapsePrefix, baseHistory.minCollapsePrefix ?? 10),
|
|
424
|
+
collapseChunk: historyIn?.collapseChunk === undefined
|
|
425
|
+
? baseHistory.collapseChunk
|
|
426
|
+
: nonNegativeInt(historyIn.collapseChunk, baseHistory.collapseChunk ?? 10),
|
|
427
|
+
freezeChunk: historyIn?.freezeChunk === undefined
|
|
428
|
+
? baseHistory.freezeChunk
|
|
429
|
+
: nonNegativeInt(historyIn.freezeChunk, baseHistory.freezeChunk ?? 10),
|
|
430
|
+
reflow: typeof historyIn?.reflow === 'boolean' ? historyIn.reflow : baseHistory.reflow,
|
|
431
|
+
factSheetOverflow: historyIn?.factSheetOverflow === 'native-opaque' ? historyIn.factSheetOverflow : baseHistory.factSheetOverflow,
|
|
432
|
+
maxCachePaybackReads: historyIn?.maxCachePaybackReads === undefined
|
|
433
|
+
? baseHistory.maxCachePaybackReads
|
|
434
|
+
: nonNegativeInt(historyIn.maxCachePaybackReads, baseHistory.maxCachePaybackReads ?? 10),
|
|
435
|
+
responsesMode: responsesMode(historyIn?.responsesMode, baseHistory.responsesMode),
|
|
436
|
+
framing: historyFraming(historyIn?.framing, baseHistory.framing),
|
|
437
|
+
factSheetScope: factSheetScope(historyIn?.factSheetScope, baseHistory.factSheetScope),
|
|
438
|
+
};
|
|
439
|
+
// History geometry: only materialised when the override actually asks for
|
|
440
|
+
// it, so a profile that says nothing about history keeps `undefined` and
|
|
441
|
+
// transform.ts falls through to the dense geometry unchanged.
|
|
442
|
+
const historyStyleIn = p.historyStyle;
|
|
443
|
+
const historyStyle = historyStyleIn === undefined
|
|
444
|
+
? base.historyStyle
|
|
445
|
+
: { ...style, font: renderFont(historyStyleIn.font, style.font) };
|
|
446
|
+
const historyStripCols = p.historyStripCols === undefined
|
|
447
|
+
? base.historyStripCols
|
|
448
|
+
: posInt(p.historyStripCols, base.historyStripCols ?? base.stripCols);
|
|
449
|
+
out.set(key, {
|
|
450
|
+
imageDetail: p.imageDetail === 'high' || p.imageDetail === 'original' ? p.imageDetail : base.imageDetail,
|
|
451
|
+
vision: isValidVision(p.vision) ? p.vision : base.vision,
|
|
452
|
+
cacheReadRate: rate(p.cacheReadRate, base.cacheReadRate),
|
|
453
|
+
cacheWriteRate: rate(p.cacheWriteRate, base.cacheWriteRate ?? 1),
|
|
454
|
+
// `false` must stick. Keeping the built-in `true` made INKLING_GPT_PROFILES
|
|
455
|
+
// unable to stop explicit breakpoint injection (ChatGPT Codex 400).
|
|
456
|
+
cacheBreakpoints: typeof p.cacheBreakpoints === 'boolean' ? p.cacheBreakpoints : base.cacheBreakpoints,
|
|
457
|
+
outputRate: rate(p.outputRate, base.outputRate),
|
|
458
|
+
stripCols: posInt(p.stripCols, base.stripCols),
|
|
459
|
+
maxHeightPx: posInt(p.maxHeightPx, base.maxHeightPx),
|
|
460
|
+
visionTier: p.visionTier === 'high-res' || p.visionTier === 'standard' ? p.visionTier : base.visionTier,
|
|
461
|
+
minCompressTokens: p.minCompressTokens === undefined
|
|
462
|
+
? base.minCompressTokens
|
|
463
|
+
: nonNegativeInt(p.minCompressTokens, base.minCompressTokens ?? 0),
|
|
464
|
+
factSheetFormat: factSheetFormat(p.factSheetFormat, base.factSheetFormat),
|
|
465
|
+
history,
|
|
466
|
+
style,
|
|
467
|
+
historyStripCols,
|
|
468
|
+
historyStyle,
|
|
469
|
+
maxSerializedRequestBytes: p.maxSerializedRequestBytes === undefined
|
|
470
|
+
? base.maxSerializedRequestBytes
|
|
471
|
+
: posInt(p.maxSerializedRequestBytes, base.maxSerializedRequestBytes ?? 0) || undefined,
|
|
472
|
+
exactStaticBaseline: typeof p.exactStaticBaseline === 'boolean'
|
|
473
|
+
? p.exactStaticBaseline
|
|
474
|
+
: base.exactStaticBaseline,
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
return out;
|
|
478
|
+
}
|
|
479
|
+
function envProfiles() {
|
|
480
|
+
const raw = readBrandEnv('GPT_PROFILES') || '';
|
|
481
|
+
if (raw !== envRaw) {
|
|
482
|
+
envRaw = raw;
|
|
483
|
+
envMap = parseEnvProfiles(raw);
|
|
484
|
+
}
|
|
485
|
+
return envMap;
|
|
486
|
+
}
|
|
487
|
+
/** Pricing fields an operator set EXPLICITLY in INKLING_GPT_PROFILES for this
|
|
488
|
+
* model (longest matching key), or undefined. The kosha-backed resolver lets
|
|
489
|
+
* these win, so an existing override keeps working when the price source
|
|
490
|
+
* changes. Built-in profile values are not overrides. */
|
|
491
|
+
export function envPricingOverride(model) {
|
|
492
|
+
const raw = readBrandEnv('GPT_PROFILES') || '';
|
|
493
|
+
if (!raw)
|
|
494
|
+
return undefined;
|
|
495
|
+
let parsed;
|
|
496
|
+
try {
|
|
497
|
+
parsed = JSON.parse(raw);
|
|
498
|
+
}
|
|
499
|
+
catch {
|
|
500
|
+
return undefined;
|
|
501
|
+
}
|
|
502
|
+
if (!parsed || typeof parsed !== 'object')
|
|
503
|
+
return undefined;
|
|
504
|
+
const m = (model ?? '').toLowerCase().replace(/\[[^\]]*\]/g, '');
|
|
505
|
+
const ids = candidateIds(m);
|
|
506
|
+
let best;
|
|
507
|
+
let bestLen = -1;
|
|
508
|
+
for (const [k, v] of Object.entries(parsed)) {
|
|
509
|
+
const key = k.toLowerCase();
|
|
510
|
+
if (!v || typeof v !== 'object')
|
|
511
|
+
continue;
|
|
512
|
+
if (ids.some((id) => id.startsWith(key)) && key.length > bestLen) {
|
|
513
|
+
best = v;
|
|
514
|
+
bestLen = key.length;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
if (!best)
|
|
518
|
+
return undefined;
|
|
519
|
+
const out = {};
|
|
520
|
+
for (const f of ['cacheReadRate', 'cacheWriteRate', 'outputRate']) {
|
|
521
|
+
const v = best[f];
|
|
522
|
+
if (typeof v === 'number' && Number.isFinite(v) && v > 0)
|
|
523
|
+
out[f] = v;
|
|
524
|
+
}
|
|
525
|
+
return Object.keys(out).length > 0 ? out : undefined;
|
|
526
|
+
}
|
|
527
|
+
/** Vendor segments select an upstream, not a geometry, so both spellings of an
|
|
528
|
+
* id must resolve to one profile — otherwise `moonshotai/kimi-k3` skips its measured
|
|
529
|
+
* entry and lands on DEFAULT_GPT_PROFILE's OpenAI tile math. Mirrors
|
|
530
|
+
* unqualifiedModelId() in applicability.ts. */
|
|
531
|
+
function candidateIds(m) {
|
|
532
|
+
const slash = m.lastIndexOf('/');
|
|
533
|
+
return slash >= 0 ? [m, m.slice(slash + 1)] : [m];
|
|
534
|
+
}
|
|
535
|
+
export function resolveGptProfile(model) {
|
|
536
|
+
// Match applicability.ts: bracketed transport variants (for example [1m])
|
|
537
|
+
// do not define a different visual reader profile.
|
|
538
|
+
const m = (model ?? '').toLowerCase().replace(/\[[^\]]*\]/g, '');
|
|
539
|
+
const ids = candidateIds(m);
|
|
540
|
+
const geminiId = ids.find(hasGeminiMeasuredProfile);
|
|
541
|
+
if (geminiId)
|
|
542
|
+
return resolveGeminiProfile(geminiId);
|
|
543
|
+
const env = envProfiles();
|
|
544
|
+
if (env.size > 0) {
|
|
545
|
+
let best;
|
|
546
|
+
let bestLen = -1;
|
|
547
|
+
for (const [k, p] of env) {
|
|
548
|
+
// Longest matching key wins. Equal-length keys fall to env insertion
|
|
549
|
+
// order, not candidate order — the outer loop is over keys.
|
|
550
|
+
for (const id of ids) {
|
|
551
|
+
if (id.startsWith(k) && k.length > bestLen) {
|
|
552
|
+
best = p;
|
|
553
|
+
bestLen = k.length;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
if (best)
|
|
558
|
+
return best;
|
|
559
|
+
}
|
|
560
|
+
const qualified = ids.length > 1 ? resolveBuiltin(ids[0]) : undefined;
|
|
561
|
+
const base = qualified && qualified !== DEFAULT_GPT_PROFILE
|
|
562
|
+
? qualified
|
|
563
|
+
: resolveBuiltin(ids[ids.length - 1]);
|
|
564
|
+
const cal = getCalibratedProfile(model);
|
|
565
|
+
if (cal && cal.scores.passed && cal.band !== 'text-only') {
|
|
566
|
+
return calibratedBandToProfile(cal.band, base, { cols: cal.cols, maxHeightPx: cal.maxHeightPx });
|
|
567
|
+
}
|
|
568
|
+
return base;
|
|
569
|
+
}
|
|
570
|
+
//# sourceMappingURL=gpt-model-profiles.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Maximum string length tokenized via synchronous pure-JS BPE; longer payloads use fast estimate. */
|
|
2
|
+
export declare const EXACT_BPE_MAX_CHARS = 256000;
|
|
3
|
+
/**
|
|
4
|
+
* Strictly linear O(N) check for an unbroken non-whitespace run >= `limit`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function hasLongNonWhitespaceRun(s: string, limit?: number): boolean;
|
|
7
|
+
export declare function hasLongUnbrokenBpeChunk(s: string, limit?: number): boolean;
|
|
8
|
+
/** o200k token count of `text`; 0 for empty text or a tokenizer error. */
|
|
9
|
+
export declare function gptTokenCount(text: string): number;
|
|
10
|
+
/** Test hook: characters represented by the memo, never above 8 Mi. */
|
|
11
|
+
export declare function gptTokenMemoChars(): number;
|
|
12
|
+
/** Test hook: forget memoised counts. */
|
|
13
|
+
export declare function clearGptTokenMemo(): void;
|
|
14
|
+
//# sourceMappingURL=gpt-tokens.d.ts.map
|