@cortexkit/pi-magic-context 0.47.0 → 0.49.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/auto-search-worker.js +27 -22
- package/dist/embedding-activity-ew6dshfd.js +10 -0
- package/dist/embedding-backfill-b71dvfs8.js +20 -0
- package/dist/embedding-cache-7rp4gqzr.js +16 -0
- package/dist/embedding-worker.js +11 -8
- package/dist/harness-9872e0ym.js +10 -0
- package/dist/historian-calibration-extension.js +30 -4
- package/dist/index-041ex0cj.js +519 -0
- package/dist/index-0h2mkab2.js +17 -0
- package/dist/{index-2p1e8706.js → index-0vrkp1jq.js} +3 -3
- package/dist/index-135e8hvg.js +43 -0
- package/dist/{index-vgcemg0n.js → index-1evzceyw.js} +151 -2452
- package/dist/index-21v1kfs7.js +2309 -0
- package/dist/{index-n3g5mwa8.js → index-290tzwp1.js} +3 -3
- package/dist/{index-0qejsd7f.js → index-3cgbv47m.js} +289 -45
- package/dist/{index-xpbh1ypk.js → index-3mgf68pn.js} +38 -741
- package/dist/index-3rea6zd9.js +2396 -0
- package/dist/index-674f6qs2.js +16 -0
- package/dist/index-8976mezv.js +209 -0
- package/dist/index-904reqtg.js +152 -0
- package/dist/index-9p40dgkm.js +22 -0
- package/dist/index-9x1f96r8.js +11 -0
- package/dist/index-bejpsj10.js +1060 -0
- package/dist/{index-spk5vrhy.js → index-bgmv2kaf.js} +1 -16
- package/dist/{index-k3ezsjng.js → index-ehybv5nr.js} +14657 -13951
- package/dist/index-fapenpch.js +13 -0
- package/dist/index-hwqb3s7f.js +3804 -0
- package/dist/index-kjd1fj55.js +3106 -0
- package/dist/{index-td885aah.js → index-mcgehvgw.js} +181 -230
- package/dist/index-r024r8da.js +171 -0
- package/dist/{index-266qrgss.js → index-r56xgha8.js} +301 -27
- package/dist/{index-kztsbkqq.js → index-t7xfqtg6.js} +171 -168
- package/dist/index-vakawmbc.js +1262 -0
- package/dist/{index-7n8gb6j3.js → index-x3dcnxh0.js} +34 -33
- package/dist/index-xjqheg7a.js +931 -0
- package/dist/index-yarjn32j.js +3026 -0
- package/dist/index-yhzhdp3m.js +143 -0
- package/dist/index-yzcjxnt2.js +787 -0
- package/dist/{index-w76x3af7.js → index-zh1jw8qp.js} +107 -4
- package/dist/index.js +4926 -2437
- package/dist/logger-j6tecd1h.js +19 -0
- package/dist/message-index-bounded-qz5dz2se.js +120 -0
- package/dist/{message-time-backfill-d3db2etr.js → message-time-backfill-05ppypkz.js} +7 -6
- package/dist/migration-worker.js +20 -14
- package/dist/project-embedding-registry-ky7wrkr1.js +85 -0
- package/dist/raw-ordinal-warmup-worker.js +60 -0
- package/dist/{read-session-chunk-atxsyfqv.js → read-session-chunk-24sd89tf.js} +14 -6
- package/dist/read-session-raw-npx3920c.js +57 -0
- package/dist/{safe-notification-target-6cn3z99t.js → safe-notification-target-vn9kpmv4.js} +3 -2
- package/dist/search-jbh28nwy.js +40 -0
- package/dist/sqlite-3yye76ht.js +44 -0
- package/dist/sqlite-context-pragmas-gcgch6qz.js +6 -0
- package/dist/storage-memory-1z20y55x.js +71 -0
- package/dist/storage-tags-kjnsqbdb.js +127 -0
- package/dist/subagent-entry.js +35 -17
- package/dist/transformers-node-wasm.js +18415 -18415
- package/package.json +3 -3
- package/dist/index-7s8vw2y0.js +0 -5207
- package/dist/index-qaa5j277.js +0 -8544
- /package/dist/{index-en1k8h8m.js → index-5prbx026.js} +0 -0
|
@@ -1,25 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./index-
|
|
4
|
-
|
|
5
|
-
// ../plugin/src/shared/internal-initiator-marker.ts
|
|
6
|
-
var OMO_INTERNAL_INITIATOR_MARKER = "<!-- OMO_INTERNAL_INITIATOR -->";
|
|
7
|
-
|
|
8
|
-
// ../plugin/src/shared/system-directive.ts
|
|
9
|
-
var SYSTEM_DIRECTIVE_PREFIX = "[SYSTEM DIRECTIVE: MAGIC-CONTEXT";
|
|
10
|
-
function isSystemDirective(text) {
|
|
11
|
-
return text.trimStart().startsWith(SYSTEM_DIRECTIVE_PREFIX);
|
|
12
|
-
}
|
|
13
|
-
function removeSystemReminders(text) {
|
|
14
|
-
return text.replace(/<system-reminder>[\s\S]*?<\/system-reminder>/gi, "").trim();
|
|
15
|
-
}
|
|
2
|
+
log2
|
|
3
|
+
} from "./index-x3dcnxh0.js";
|
|
16
4
|
|
|
17
5
|
// ../plugin/src/hooks/magic-context/read-session-formatting.ts
|
|
18
6
|
import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
19
7
|
import { createRequire } from "node:module";
|
|
20
8
|
import { homedir } from "node:os";
|
|
21
9
|
import { dirname, join, resolve } from "node:path";
|
|
22
|
-
import { pathToFileURL } from "node:url";
|
|
10
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
23
11
|
|
|
24
12
|
// ../plugin/src/shared/commit-detection.ts
|
|
25
13
|
var HASH_HEX = "[0-9a-f]{7,12}";
|
|
@@ -32,6 +20,284 @@ function createCommitHashExtractPattern() {
|
|
|
32
20
|
return new RegExp(`\`?\\b(${HASH_HEX})\\b\`?`, "gi");
|
|
33
21
|
}
|
|
34
22
|
|
|
23
|
+
// ../plugin/src/shared/internal-initiator-marker.ts
|
|
24
|
+
var OMO_INTERNAL_INITIATOR_MARKER = "<!-- OMO_INTERNAL_INITIATOR -->";
|
|
25
|
+
|
|
26
|
+
// ../plugin/src/shared/system-directive.ts
|
|
27
|
+
var SYSTEM_DIRECTIVE_PREFIX = "[SYSTEM DIRECTIVE: MAGIC-CONTEXT";
|
|
28
|
+
function isSystemDirective(text) {
|
|
29
|
+
return text.trimStart().startsWith(SYSTEM_DIRECTIVE_PREFIX);
|
|
30
|
+
}
|
|
31
|
+
function removeSystemReminders(text) {
|
|
32
|
+
return text.replace(/<system-reminder>[\s\S]*?<\/system-reminder>/gi, "").trim();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// ../plugin/src/hooks/magic-context/token-count-exact.ts
|
|
36
|
+
var NO_RANK = 4294967295;
|
|
37
|
+
var LONG_PIECE_BYTES = 256;
|
|
38
|
+
var MERGE_CACHE_GENERATION = 50000;
|
|
39
|
+
function hasInternals(tokenizer) {
|
|
40
|
+
const value = tokenizer;
|
|
41
|
+
return !!value && value.patternRegex instanceof RegExp && value.patternRegex.global && typeof value.stringRankEncoder === "object" && value.stringRankEncoder !== null && Array.isArray(value.binaryFirstByteIndex);
|
|
42
|
+
}
|
|
43
|
+
var textEncoder = new TextEncoder;
|
|
44
|
+
var textDecoder = new TextDecoder("utf-8");
|
|
45
|
+
function isValidUtf8(bytes) {
|
|
46
|
+
let index = 0;
|
|
47
|
+
while (index < bytes.length) {
|
|
48
|
+
const first = bytes[index];
|
|
49
|
+
let size = 0;
|
|
50
|
+
let codePoint = 0;
|
|
51
|
+
if (first <= 127) {
|
|
52
|
+
size = 1;
|
|
53
|
+
codePoint = first;
|
|
54
|
+
} else if ((first & 224) === 192) {
|
|
55
|
+
size = 2;
|
|
56
|
+
codePoint = first & 31;
|
|
57
|
+
if (first <= 193)
|
|
58
|
+
return false;
|
|
59
|
+
} else if ((first & 240) === 224) {
|
|
60
|
+
size = 3;
|
|
61
|
+
codePoint = first & 15;
|
|
62
|
+
} else if ((first & 248) === 240) {
|
|
63
|
+
size = 4;
|
|
64
|
+
codePoint = first & 7;
|
|
65
|
+
if (first > 244)
|
|
66
|
+
return false;
|
|
67
|
+
} else
|
|
68
|
+
return false;
|
|
69
|
+
if (index + size > bytes.length)
|
|
70
|
+
return false;
|
|
71
|
+
for (let offset = 1;offset < size; offset += 1) {
|
|
72
|
+
const byte = bytes[index + offset];
|
|
73
|
+
if ((byte & 192) !== 128)
|
|
74
|
+
return false;
|
|
75
|
+
codePoint = codePoint << 6 | byte & 63;
|
|
76
|
+
}
|
|
77
|
+
if (size === 2 && codePoint < 128)
|
|
78
|
+
return false;
|
|
79
|
+
if (size === 3 && codePoint < 2048)
|
|
80
|
+
return false;
|
|
81
|
+
if (size === 4 && codePoint < 65536)
|
|
82
|
+
return false;
|
|
83
|
+
if (codePoint >= 55296 && codePoint <= 57343)
|
|
84
|
+
return false;
|
|
85
|
+
if (codePoint > 1114111)
|
|
86
|
+
return false;
|
|
87
|
+
index += size;
|
|
88
|
+
}
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
function binarySearchBytes(sorted, key) {
|
|
92
|
+
let low = 0;
|
|
93
|
+
let high = sorted.length - 1;
|
|
94
|
+
while (low <= high) {
|
|
95
|
+
const mid = low + high >>> 1;
|
|
96
|
+
const midKey = sorted[mid][0];
|
|
97
|
+
let compare = 0;
|
|
98
|
+
const shared = Math.min(midKey.length, key.length);
|
|
99
|
+
for (let index = 0;index < shared; index += 1) {
|
|
100
|
+
compare = midKey[index] - key[index];
|
|
101
|
+
if (compare !== 0)
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
if (compare === 0)
|
|
105
|
+
compare = midKey.length - key.length;
|
|
106
|
+
if (compare === 0)
|
|
107
|
+
return sorted[mid][1];
|
|
108
|
+
if (compare < 0)
|
|
109
|
+
low = mid + 1;
|
|
110
|
+
else
|
|
111
|
+
high = mid - 1;
|
|
112
|
+
}
|
|
113
|
+
return -1;
|
|
114
|
+
}
|
|
115
|
+
function rankOf(tokenizer, slice) {
|
|
116
|
+
if (isValidUtf8(slice)) {
|
|
117
|
+
const rank = tokenizer.stringRankEncoder[textDecoder.decode(slice)];
|
|
118
|
+
if (rank !== undefined)
|
|
119
|
+
return rank;
|
|
120
|
+
}
|
|
121
|
+
const bucket = tokenizer.binaryFirstByteIndex[slice[0]];
|
|
122
|
+
if (bucket !== null && bucket !== undefined) {
|
|
123
|
+
const rank = binarySearchBytes(bucket, slice);
|
|
124
|
+
if (rank !== -1)
|
|
125
|
+
return rank;
|
|
126
|
+
}
|
|
127
|
+
return NO_RANK;
|
|
128
|
+
}
|
|
129
|
+
function mergeByScanning(tokenizer, bytes) {
|
|
130
|
+
const starts = [];
|
|
131
|
+
const ranks = [];
|
|
132
|
+
const pairRank = (index) => {
|
|
133
|
+
const end = starts[index + 2];
|
|
134
|
+
return end === undefined ? NO_RANK : rankOf(tokenizer, bytes.subarray(starts[index], end));
|
|
135
|
+
};
|
|
136
|
+
for (let index = 0;index <= bytes.length; index += 1)
|
|
137
|
+
starts.push(index);
|
|
138
|
+
for (let index = 0;index < starts.length; index += 1)
|
|
139
|
+
ranks.push(pairRank(index));
|
|
140
|
+
while (starts.length > 1) {
|
|
141
|
+
let minRank = NO_RANK;
|
|
142
|
+
let minIndex = -1;
|
|
143
|
+
for (let index = 0;index < ranks.length - 1; index += 1) {
|
|
144
|
+
if (ranks[index] < minRank) {
|
|
145
|
+
minRank = ranks[index];
|
|
146
|
+
minIndex = index;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (minIndex === -1)
|
|
150
|
+
break;
|
|
151
|
+
starts.splice(minIndex + 1, 1);
|
|
152
|
+
ranks.splice(minIndex, 1);
|
|
153
|
+
ranks[minIndex] = pairRank(minIndex);
|
|
154
|
+
if (minIndex > 0)
|
|
155
|
+
ranks[minIndex - 1] = pairRank(minIndex - 1);
|
|
156
|
+
}
|
|
157
|
+
const tokens = [];
|
|
158
|
+
for (let index = 0;index < starts.length - 1; index += 1) {
|
|
159
|
+
const rank = rankOf(tokenizer, bytes.subarray(starts[index], starts[index + 1]));
|
|
160
|
+
if (rank !== NO_RANK)
|
|
161
|
+
tokens.push(rank);
|
|
162
|
+
}
|
|
163
|
+
return tokens;
|
|
164
|
+
}
|
|
165
|
+
function mergeWithHeap(tokenizer, bytes) {
|
|
166
|
+
const length = bytes.length;
|
|
167
|
+
const next = new Int32Array(length + 1);
|
|
168
|
+
const prev = new Int32Array(length + 1);
|
|
169
|
+
const alive = new Uint8Array(length + 1).fill(1);
|
|
170
|
+
const rank = new Float64Array(length + 1).fill(NO_RANK);
|
|
171
|
+
for (let index = 0;index <= length; index += 1) {
|
|
172
|
+
next[index] = index + 1;
|
|
173
|
+
prev[index] = index - 1;
|
|
174
|
+
}
|
|
175
|
+
const heapRank = [];
|
|
176
|
+
const heapAt = [];
|
|
177
|
+
const less = (a, b) => heapRank[a] < heapRank[b] || heapRank[a] === heapRank[b] && heapAt[a] < heapAt[b];
|
|
178
|
+
const swap = (a, b) => {
|
|
179
|
+
[heapRank[a], heapRank[b]] = [heapRank[b], heapRank[a]];
|
|
180
|
+
[heapAt[a], heapAt[b]] = [heapAt[b], heapAt[a]];
|
|
181
|
+
};
|
|
182
|
+
const push = (value, at) => {
|
|
183
|
+
heapRank.push(value);
|
|
184
|
+
heapAt.push(at);
|
|
185
|
+
let child = heapRank.length - 1;
|
|
186
|
+
while (child > 0) {
|
|
187
|
+
const parent = child - 1 >> 1;
|
|
188
|
+
if (!less(child, parent))
|
|
189
|
+
break;
|
|
190
|
+
swap(child, parent);
|
|
191
|
+
child = parent;
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
const pop = () => {
|
|
195
|
+
const last = heapRank.length - 1;
|
|
196
|
+
swap(0, last);
|
|
197
|
+
heapRank.pop();
|
|
198
|
+
heapAt.pop();
|
|
199
|
+
let parent = 0;
|
|
200
|
+
for (;; ) {
|
|
201
|
+
const left = parent * 2 + 1;
|
|
202
|
+
const right = left + 1;
|
|
203
|
+
let smallest = parent;
|
|
204
|
+
if (left < heapRank.length && less(left, smallest))
|
|
205
|
+
smallest = left;
|
|
206
|
+
if (right < heapRank.length && less(right, smallest))
|
|
207
|
+
smallest = right;
|
|
208
|
+
if (smallest === parent)
|
|
209
|
+
break;
|
|
210
|
+
swap(parent, smallest);
|
|
211
|
+
parent = smallest;
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
const pairRank = (at) => {
|
|
215
|
+
const middle = next[at];
|
|
216
|
+
if (middle >= length)
|
|
217
|
+
return NO_RANK;
|
|
218
|
+
return rankOf(tokenizer, bytes.subarray(at, next[middle]));
|
|
219
|
+
};
|
|
220
|
+
const update = (at) => {
|
|
221
|
+
rank[at] = pairRank(at);
|
|
222
|
+
if (rank[at] !== NO_RANK)
|
|
223
|
+
push(rank[at], at);
|
|
224
|
+
};
|
|
225
|
+
for (let at = 0;at < length; at += 1)
|
|
226
|
+
update(at);
|
|
227
|
+
while (heapRank.length > 0) {
|
|
228
|
+
const value = heapRank[0];
|
|
229
|
+
const at = heapAt[0];
|
|
230
|
+
pop();
|
|
231
|
+
if (!alive[at] || rank[at] !== value)
|
|
232
|
+
continue;
|
|
233
|
+
const removed = next[at];
|
|
234
|
+
alive[removed] = 0;
|
|
235
|
+
next[at] = next[removed];
|
|
236
|
+
prev[next[removed]] = at;
|
|
237
|
+
update(at);
|
|
238
|
+
if (at > 0)
|
|
239
|
+
update(prev[at]);
|
|
240
|
+
}
|
|
241
|
+
const tokens = [];
|
|
242
|
+
for (let at = 0;at < length; at = next[at]) {
|
|
243
|
+
const value = rankOf(tokenizer, bytes.subarray(at, next[at]));
|
|
244
|
+
if (value !== NO_RANK)
|
|
245
|
+
tokens.push(value);
|
|
246
|
+
}
|
|
247
|
+
return tokens;
|
|
248
|
+
}
|
|
249
|
+
var mergeCaches = new WeakMap;
|
|
250
|
+
var mergedPieces = 0;
|
|
251
|
+
function mergePiece(tokenizer, piece) {
|
|
252
|
+
let cache = mergeCaches.get(tokenizer);
|
|
253
|
+
if (!cache) {
|
|
254
|
+
cache = { current: new Map, previous: new Map };
|
|
255
|
+
mergeCaches.set(tokenizer, cache);
|
|
256
|
+
}
|
|
257
|
+
let tokens = cache.current.get(piece);
|
|
258
|
+
if (tokens)
|
|
259
|
+
return tokens;
|
|
260
|
+
tokens = cache.previous.get(piece);
|
|
261
|
+
if (!tokens) {
|
|
262
|
+
const bytes = textEncoder.encode(piece);
|
|
263
|
+
mergedPieces += 1;
|
|
264
|
+
tokens = bytes.length > LONG_PIECE_BYTES ? mergeWithHeap(tokenizer, bytes) : mergeByScanning(tokenizer, bytes);
|
|
265
|
+
}
|
|
266
|
+
if (cache.current.size >= MERGE_CACHE_GENERATION) {
|
|
267
|
+
cache.previous = cache.current;
|
|
268
|
+
cache.current = new Map;
|
|
269
|
+
}
|
|
270
|
+
cache.current.set(piece, tokens);
|
|
271
|
+
return tokens;
|
|
272
|
+
}
|
|
273
|
+
function encodeTokensExactly(tokenizer, text) {
|
|
274
|
+
if (!hasInternals(tokenizer)) {
|
|
275
|
+
return tokenizer.encode(text, "all");
|
|
276
|
+
}
|
|
277
|
+
if (text.length < 10) {
|
|
278
|
+
const direct = tokenizer.stringRankEncoder[text];
|
|
279
|
+
if (direct !== undefined)
|
|
280
|
+
return [direct];
|
|
281
|
+
}
|
|
282
|
+
const tokens = [];
|
|
283
|
+
const regex = tokenizer.patternRegex;
|
|
284
|
+
regex.lastIndex = 0;
|
|
285
|
+
for (let match = regex.exec(text);match !== null; match = regex.exec(text)) {
|
|
286
|
+
const piece = match[0];
|
|
287
|
+
const direct = tokenizer.stringRankEncoder[piece];
|
|
288
|
+
if (direct !== undefined) {
|
|
289
|
+
tokens.push(direct);
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
for (const token of mergePiece(tokenizer, piece))
|
|
293
|
+
tokens.push(token);
|
|
294
|
+
}
|
|
295
|
+
return tokens;
|
|
296
|
+
}
|
|
297
|
+
function countTokensExactly(tokenizer, text) {
|
|
298
|
+
return encodeTokensExactly(tokenizer, text).length;
|
|
299
|
+
}
|
|
300
|
+
|
|
35
301
|
// ../plugin/src/hooks/magic-context/read-session-formatting.ts
|
|
36
302
|
var MAX_COMMITS_PER_BLOCK = 5;
|
|
37
303
|
function hasMeaningfulUserText2(parts) {
|
|
@@ -144,22 +410,30 @@ var tokenizerSerializedTableBytes;
|
|
|
144
410
|
function tokenizerPackageRoots() {
|
|
145
411
|
const cwd = process.cwd();
|
|
146
412
|
const openCodeCache = join(process.env.XDG_CACHE_HOME ?? join(homedir(), ".cache"), "opencode");
|
|
147
|
-
const roots = [cwd, openCodeCache];
|
|
148
413
|
const candidates = [];
|
|
149
|
-
|
|
414
|
+
const probeRoot = (root) => {
|
|
150
415
|
for (const packageDir of TOKENIZER_PACKAGE_DIRS) {
|
|
151
416
|
candidates.push(join(root, "node_modules", ...packageDir, "node_modules", "ai-tokenizer"));
|
|
152
417
|
}
|
|
153
418
|
candidates.push(join(root, "node_modules", "ai-tokenizer"));
|
|
419
|
+
};
|
|
420
|
+
for (const root of [cwd, openCodeCache]) {
|
|
421
|
+
probeRoot(root);
|
|
154
422
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
423
|
+
const pushAncestors = (startDir) => {
|
|
424
|
+
let ancestor = startDir;
|
|
425
|
+
while (true) {
|
|
426
|
+
candidates.push(join(ancestor, "node_modules", "ai-tokenizer"));
|
|
427
|
+
const parent = dirname(ancestor);
|
|
428
|
+
if (parent === ancestor)
|
|
429
|
+
break;
|
|
430
|
+
ancestor = parent;
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
pushAncestors(process.argv[1] ? dirname(resolve(process.argv[1])) : cwd);
|
|
434
|
+
const ownDir = dirname(fileURLToPath(new URL(import.meta.url)));
|
|
435
|
+
pushAncestors(ownDir);
|
|
436
|
+
probeRoot(join(homedir(), ".omp", "plugins"));
|
|
163
437
|
return [...new Set(candidates)];
|
|
164
438
|
}
|
|
165
439
|
function packageImportTarget(value) {
|
|
@@ -222,7 +496,7 @@ function warnTokenizerFallback(error) {
|
|
|
222
496
|
return;
|
|
223
497
|
tokenizerWarningSent = true;
|
|
224
498
|
const reason = error instanceof Error ? error.message : String(error);
|
|
225
|
-
|
|
499
|
+
log2("[magic-context] ai-tokenizer is unavailable; using approximate character-based token counts for this process. Token budgets, persisted per-message counts, and protected-tail/compartment boundaries may be less accurate until restart:", reason);
|
|
226
500
|
}
|
|
227
501
|
async function preloadTokenizer() {
|
|
228
502
|
if (tokenizer)
|
|
@@ -297,7 +571,7 @@ function estimateTokens(text) {
|
|
|
297
571
|
if (!activeTokenizer)
|
|
298
572
|
return estimateTokensHeuristically(text);
|
|
299
573
|
try {
|
|
300
|
-
return activeTokenizer
|
|
574
|
+
return countTokensExactly(activeTokenizer, text);
|
|
301
575
|
} catch (error) {
|
|
302
576
|
tokenizer = undefined;
|
|
303
577
|
tokenizerLoadAttempted = true;
|