@laxture/vibe-pm 0.1.0 → 0.1.4
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/i18n/index.d.ts +1 -1
- package/dist/index.js +52 -794
- package/dist/memory/memory-system.d.ts +1 -1
- package/dist/memory/types.d.ts +1 -1
- package/dist/token/index.d.ts +0 -1
- package/dist/tui/data/task-status.d.ts +1 -1
- package/dist/tui/data/token-data.d.ts +1 -1
- package/dist/tui/index.js +20 -794
- package/package.json +15 -3
package/dist/index.js
CHANGED
|
@@ -32,751 +32,6 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
32
32
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
33
33
|
var __require = import.meta.require;
|
|
34
34
|
|
|
35
|
-
// node_modules/tiktoken/tiktoken_bg.cjs
|
|
36
|
-
var require_tiktoken_bg = __commonJS((exports, module) => {
|
|
37
|
-
var wasm;
|
|
38
|
-
exports.__wbg_set_wasm = function(val) {
|
|
39
|
-
wasm = val;
|
|
40
|
-
};
|
|
41
|
-
var lTextDecoder = typeof TextDecoder === "undefined" ? (0, module.require)("util").TextDecoder : TextDecoder;
|
|
42
|
-
var cachedTextDecoder = new lTextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
43
|
-
cachedTextDecoder.decode();
|
|
44
|
-
var cachedUint8ArrayMemory0 = null;
|
|
45
|
-
function getUint8ArrayMemory0() {
|
|
46
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
47
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
48
|
-
}
|
|
49
|
-
return cachedUint8ArrayMemory0;
|
|
50
|
-
}
|
|
51
|
-
function getStringFromWasm0(ptr, len) {
|
|
52
|
-
ptr = ptr >>> 0;
|
|
53
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
54
|
-
}
|
|
55
|
-
var heap = new Array(128).fill(undefined);
|
|
56
|
-
heap.push(undefined, null, true, false);
|
|
57
|
-
var heap_next = heap.length;
|
|
58
|
-
function addHeapObject(obj) {
|
|
59
|
-
if (heap_next === heap.length)
|
|
60
|
-
heap.push(heap.length + 1);
|
|
61
|
-
const idx = heap_next;
|
|
62
|
-
heap_next = heap[idx];
|
|
63
|
-
heap[idx] = obj;
|
|
64
|
-
return idx;
|
|
65
|
-
}
|
|
66
|
-
function handleError(f, args) {
|
|
67
|
-
try {
|
|
68
|
-
return f.apply(this, args);
|
|
69
|
-
} catch (e) {
|
|
70
|
-
wasm.__wbindgen_export_0(addHeapObject(e));
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
function getObject(idx) {
|
|
74
|
-
return heap[idx];
|
|
75
|
-
}
|
|
76
|
-
function dropObject(idx) {
|
|
77
|
-
if (idx < 132)
|
|
78
|
-
return;
|
|
79
|
-
heap[idx] = heap_next;
|
|
80
|
-
heap_next = idx;
|
|
81
|
-
}
|
|
82
|
-
function takeObject(idx) {
|
|
83
|
-
const ret = getObject(idx);
|
|
84
|
-
dropObject(idx);
|
|
85
|
-
return ret;
|
|
86
|
-
}
|
|
87
|
-
var WASM_VECTOR_LEN = 0;
|
|
88
|
-
var lTextEncoder = typeof TextEncoder === "undefined" ? (0, module.require)("util").TextEncoder : TextEncoder;
|
|
89
|
-
var cachedTextEncoder = new lTextEncoder("utf-8");
|
|
90
|
-
var encodeString = typeof cachedTextEncoder.encodeInto === "function" ? function(arg, view) {
|
|
91
|
-
return cachedTextEncoder.encodeInto(arg, view);
|
|
92
|
-
} : function(arg, view) {
|
|
93
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
94
|
-
view.set(buf);
|
|
95
|
-
return {
|
|
96
|
-
read: arg.length,
|
|
97
|
-
written: buf.length
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
101
|
-
if (realloc === undefined) {
|
|
102
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
103
|
-
const ptr2 = malloc(buf.length, 1) >>> 0;
|
|
104
|
-
getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
|
|
105
|
-
WASM_VECTOR_LEN = buf.length;
|
|
106
|
-
return ptr2;
|
|
107
|
-
}
|
|
108
|
-
let len = arg.length;
|
|
109
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
110
|
-
const mem = getUint8ArrayMemory0();
|
|
111
|
-
let offset = 0;
|
|
112
|
-
for (;offset < len; offset++) {
|
|
113
|
-
const code = arg.charCodeAt(offset);
|
|
114
|
-
if (code > 127)
|
|
115
|
-
break;
|
|
116
|
-
mem[ptr + offset] = code;
|
|
117
|
-
}
|
|
118
|
-
if (offset !== len) {
|
|
119
|
-
if (offset !== 0) {
|
|
120
|
-
arg = arg.slice(offset);
|
|
121
|
-
}
|
|
122
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
123
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
124
|
-
const ret = encodeString(arg, view);
|
|
125
|
-
offset += ret.written;
|
|
126
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
127
|
-
}
|
|
128
|
-
WASM_VECTOR_LEN = offset;
|
|
129
|
-
return ptr;
|
|
130
|
-
}
|
|
131
|
-
function isLikeNone(x) {
|
|
132
|
-
return x === undefined || x === null;
|
|
133
|
-
}
|
|
134
|
-
var cachedDataViewMemory0 = null;
|
|
135
|
-
function getDataViewMemory0() {
|
|
136
|
-
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
|
|
137
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
138
|
-
}
|
|
139
|
-
return cachedDataViewMemory0;
|
|
140
|
-
}
|
|
141
|
-
var cachedUint32ArrayMemory0 = null;
|
|
142
|
-
function getUint32ArrayMemory0() {
|
|
143
|
-
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
144
|
-
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
145
|
-
}
|
|
146
|
-
return cachedUint32ArrayMemory0;
|
|
147
|
-
}
|
|
148
|
-
function getArrayU32FromWasm0(ptr, len) {
|
|
149
|
-
ptr = ptr >>> 0;
|
|
150
|
-
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
151
|
-
}
|
|
152
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
153
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
154
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
155
|
-
WASM_VECTOR_LEN = arg.length;
|
|
156
|
-
return ptr;
|
|
157
|
-
}
|
|
158
|
-
function passArray32ToWasm0(arg, malloc) {
|
|
159
|
-
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
160
|
-
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
161
|
-
WASM_VECTOR_LEN = arg.length;
|
|
162
|
-
return ptr;
|
|
163
|
-
}
|
|
164
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
165
|
-
ptr = ptr >>> 0;
|
|
166
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
167
|
-
}
|
|
168
|
-
exports.get_encoding = function(encoding, extend_special_tokens) {
|
|
169
|
-
if (wasm == null)
|
|
170
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
171
|
-
try {
|
|
172
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
173
|
-
const ptr0 = passStringToWasm0(encoding, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
174
|
-
const len0 = WASM_VECTOR_LEN;
|
|
175
|
-
wasm.get_encoding(retptr, ptr0, len0, addHeapObject(extend_special_tokens));
|
|
176
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
177
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
178
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
179
|
-
if (r2) {
|
|
180
|
-
throw takeObject(r1);
|
|
181
|
-
}
|
|
182
|
-
return Tiktoken.__wrap(r0);
|
|
183
|
-
} finally {
|
|
184
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
exports.encoding_for_model = function(model, extend_special_tokens) {
|
|
188
|
-
if (wasm == null)
|
|
189
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
190
|
-
try {
|
|
191
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
192
|
-
const ptr0 = passStringToWasm0(model, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
193
|
-
const len0 = WASM_VECTOR_LEN;
|
|
194
|
-
wasm.encoding_for_model(retptr, ptr0, len0, addHeapObject(extend_special_tokens));
|
|
195
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
196
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
197
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
198
|
-
if (r2) {
|
|
199
|
-
throw takeObject(r1);
|
|
200
|
-
}
|
|
201
|
-
return Tiktoken.__wrap(r0);
|
|
202
|
-
} finally {
|
|
203
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
exports.get_encoding_name_for_model = function(model) {
|
|
207
|
-
if (wasm == null)
|
|
208
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
209
|
-
let deferred3_0;
|
|
210
|
-
let deferred3_1;
|
|
211
|
-
try {
|
|
212
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
213
|
-
const ptr0 = passStringToWasm0(model, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
214
|
-
const len0 = WASM_VECTOR_LEN;
|
|
215
|
-
wasm.get_encoding_name_for_model(retptr, ptr0, len0);
|
|
216
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
217
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
218
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
219
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
220
|
-
var ptr2 = r0;
|
|
221
|
-
var len2 = r1;
|
|
222
|
-
if (r3) {
|
|
223
|
-
ptr2 = 0;
|
|
224
|
-
len2 = 0;
|
|
225
|
-
throw takeObject(r2);
|
|
226
|
-
}
|
|
227
|
-
deferred3_0 = ptr2;
|
|
228
|
-
deferred3_1 = len2;
|
|
229
|
-
return getStringFromWasm0(ptr2, len2);
|
|
230
|
-
} finally {
|
|
231
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
232
|
-
wasm.__wbindgen_export_3(deferred3_0, deferred3_1, 1);
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
var TiktokenFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((ptr) => wasm.__wbg_tiktoken_free(ptr >>> 0, 1));
|
|
236
|
-
|
|
237
|
-
class Tiktoken {
|
|
238
|
-
constructor(tiktoken_bfe, special_tokens, pat_str) {
|
|
239
|
-
if (wasm == null)
|
|
240
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
241
|
-
const ptr0 = passStringToWasm0(tiktoken_bfe, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
242
|
-
const len0 = WASM_VECTOR_LEN;
|
|
243
|
-
const ptr1 = passStringToWasm0(pat_str, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
244
|
-
const len1 = WASM_VECTOR_LEN;
|
|
245
|
-
const ret = wasm.tiktoken_new(ptr0, len0, addHeapObject(special_tokens), ptr1, len1);
|
|
246
|
-
this.__wbg_ptr = ret >>> 0;
|
|
247
|
-
TiktokenFinalization.register(this, this.__wbg_ptr, this);
|
|
248
|
-
return this;
|
|
249
|
-
}
|
|
250
|
-
get name() {
|
|
251
|
-
try {
|
|
252
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
253
|
-
wasm.tiktoken_name(retptr, this.__wbg_ptr);
|
|
254
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
255
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
256
|
-
let v1;
|
|
257
|
-
if (r0 !== 0) {
|
|
258
|
-
v1 = getStringFromWasm0(r0, r1).slice();
|
|
259
|
-
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
260
|
-
}
|
|
261
|
-
return v1;
|
|
262
|
-
} finally {
|
|
263
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
static __wrap(ptr) {
|
|
267
|
-
ptr = ptr >>> 0;
|
|
268
|
-
const obj = Object.create(Tiktoken.prototype);
|
|
269
|
-
obj.__wbg_ptr = ptr;
|
|
270
|
-
TiktokenFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
271
|
-
return obj;
|
|
272
|
-
}
|
|
273
|
-
__destroy_into_raw() {
|
|
274
|
-
const ptr = this.__wbg_ptr;
|
|
275
|
-
this.__wbg_ptr = 0;
|
|
276
|
-
TiktokenFinalization.unregister(this);
|
|
277
|
-
return ptr;
|
|
278
|
-
}
|
|
279
|
-
free() {
|
|
280
|
-
if (wasm == null)
|
|
281
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
282
|
-
const ptr = this.__destroy_into_raw();
|
|
283
|
-
wasm.__wbg_tiktoken_free(ptr, 0);
|
|
284
|
-
}
|
|
285
|
-
encode(text, allowed_special, disallowed_special) {
|
|
286
|
-
if (wasm == null)
|
|
287
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
288
|
-
try {
|
|
289
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
290
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
291
|
-
const len0 = WASM_VECTOR_LEN;
|
|
292
|
-
wasm.tiktoken_encode(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(allowed_special), addHeapObject(disallowed_special));
|
|
293
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
294
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
295
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
296
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
297
|
-
if (r3) {
|
|
298
|
-
throw takeObject(r2);
|
|
299
|
-
}
|
|
300
|
-
var v2 = getArrayU32FromWasm0(r0, r1).slice();
|
|
301
|
-
wasm.__wbindgen_export_3(r0, r1 * 4, 4);
|
|
302
|
-
return v2;
|
|
303
|
-
} finally {
|
|
304
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
encode_ordinary(text) {
|
|
308
|
-
if (wasm == null)
|
|
309
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
310
|
-
try {
|
|
311
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
312
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
313
|
-
const len0 = WASM_VECTOR_LEN;
|
|
314
|
-
wasm.tiktoken_encode_ordinary(retptr, this.__wbg_ptr, ptr0, len0);
|
|
315
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
316
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
317
|
-
var v2 = getArrayU32FromWasm0(r0, r1).slice();
|
|
318
|
-
wasm.__wbindgen_export_3(r0, r1 * 4, 4);
|
|
319
|
-
return v2;
|
|
320
|
-
} finally {
|
|
321
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
encode_with_unstable(text, allowed_special, disallowed_special) {
|
|
325
|
-
if (wasm == null)
|
|
326
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
327
|
-
try {
|
|
328
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
329
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
330
|
-
const len0 = WASM_VECTOR_LEN;
|
|
331
|
-
wasm.tiktoken_encode_with_unstable(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(allowed_special), addHeapObject(disallowed_special));
|
|
332
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
333
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
334
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
335
|
-
if (r2) {
|
|
336
|
-
throw takeObject(r1);
|
|
337
|
-
}
|
|
338
|
-
return takeObject(r0);
|
|
339
|
-
} finally {
|
|
340
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
encode_single_token(bytes) {
|
|
344
|
-
if (wasm == null)
|
|
345
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
346
|
-
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_1);
|
|
347
|
-
const len0 = WASM_VECTOR_LEN;
|
|
348
|
-
const ret = wasm.tiktoken_encode_single_token(this.__wbg_ptr, ptr0, len0);
|
|
349
|
-
return ret >>> 0;
|
|
350
|
-
}
|
|
351
|
-
decode(tokens) {
|
|
352
|
-
if (wasm == null)
|
|
353
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
354
|
-
try {
|
|
355
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
356
|
-
const ptr0 = passArray32ToWasm0(tokens, wasm.__wbindgen_export_1);
|
|
357
|
-
const len0 = WASM_VECTOR_LEN;
|
|
358
|
-
wasm.tiktoken_decode(retptr, this.__wbg_ptr, ptr0, len0);
|
|
359
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
360
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
361
|
-
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
362
|
-
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
363
|
-
return v2;
|
|
364
|
-
} finally {
|
|
365
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
decode_single_token_bytes(token) {
|
|
369
|
-
if (wasm == null)
|
|
370
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
371
|
-
try {
|
|
372
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
373
|
-
wasm.tiktoken_decode_single_token_bytes(retptr, this.__wbg_ptr, token);
|
|
374
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
375
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
376
|
-
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
377
|
-
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
378
|
-
return v1;
|
|
379
|
-
} finally {
|
|
380
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
token_byte_values() {
|
|
384
|
-
if (wasm == null)
|
|
385
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
386
|
-
const ret = wasm.tiktoken_token_byte_values(this.__wbg_ptr);
|
|
387
|
-
return takeObject(ret);
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
exports.Tiktoken = Tiktoken;
|
|
391
|
-
exports.__wbg_parse_def2e24ef1252aff = function() {
|
|
392
|
-
return handleError(function(arg0, arg1) {
|
|
393
|
-
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
394
|
-
return addHeapObject(ret);
|
|
395
|
-
}, arguments);
|
|
396
|
-
};
|
|
397
|
-
exports.__wbg_stringify_f7ed6987935b4a24 = function() {
|
|
398
|
-
return handleError(function(arg0) {
|
|
399
|
-
const ret = JSON.stringify(getObject(arg0));
|
|
400
|
-
return addHeapObject(ret);
|
|
401
|
-
}, arguments);
|
|
402
|
-
};
|
|
403
|
-
exports.__wbindgen_error_new = function(arg0, arg1) {
|
|
404
|
-
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
405
|
-
return addHeapObject(ret);
|
|
406
|
-
};
|
|
407
|
-
exports.__wbindgen_is_undefined = function(arg0) {
|
|
408
|
-
const ret = getObject(arg0) === undefined;
|
|
409
|
-
return ret;
|
|
410
|
-
};
|
|
411
|
-
exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
412
|
-
takeObject(arg0);
|
|
413
|
-
};
|
|
414
|
-
exports.__wbindgen_string_get = function(arg0, arg1) {
|
|
415
|
-
if (wasm == null)
|
|
416
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
417
|
-
const obj = getObject(arg1);
|
|
418
|
-
const ret = typeof obj === "string" ? obj : undefined;
|
|
419
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
420
|
-
var len1 = WASM_VECTOR_LEN;
|
|
421
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
422
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
423
|
-
};
|
|
424
|
-
exports.__wbindgen_throw = function(arg0, arg1) {
|
|
425
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
426
|
-
};
|
|
427
|
-
});
|
|
428
|
-
|
|
429
|
-
// node_modules/tiktoken/lite/tiktoken_bg.cjs
|
|
430
|
-
var require_tiktoken_bg2 = __commonJS((exports, module) => {
|
|
431
|
-
var wasm2;
|
|
432
|
-
exports.__wbg_set_wasm = function(val) {
|
|
433
|
-
wasm2 = val;
|
|
434
|
-
};
|
|
435
|
-
var lTextDecoder = typeof TextDecoder === "undefined" ? (0, module.require)("util").TextDecoder : TextDecoder;
|
|
436
|
-
var cachedTextDecoder = new lTextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
437
|
-
cachedTextDecoder.decode();
|
|
438
|
-
var cachedUint8ArrayMemory0 = null;
|
|
439
|
-
function getUint8ArrayMemory0() {
|
|
440
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
441
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm2.memory.buffer);
|
|
442
|
-
}
|
|
443
|
-
return cachedUint8ArrayMemory0;
|
|
444
|
-
}
|
|
445
|
-
function getStringFromWasm0(ptr, len) {
|
|
446
|
-
ptr = ptr >>> 0;
|
|
447
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
448
|
-
}
|
|
449
|
-
var heap = new Array(128).fill(undefined);
|
|
450
|
-
heap.push(undefined, null, true, false);
|
|
451
|
-
var heap_next = heap.length;
|
|
452
|
-
function addHeapObject(obj) {
|
|
453
|
-
if (heap_next === heap.length)
|
|
454
|
-
heap.push(heap.length + 1);
|
|
455
|
-
const idx = heap_next;
|
|
456
|
-
heap_next = heap[idx];
|
|
457
|
-
heap[idx] = obj;
|
|
458
|
-
return idx;
|
|
459
|
-
}
|
|
460
|
-
function handleError(f, args) {
|
|
461
|
-
try {
|
|
462
|
-
return f.apply(this, args);
|
|
463
|
-
} catch (e) {
|
|
464
|
-
wasm2.__wbindgen_export_0(addHeapObject(e));
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
function getObject(idx) {
|
|
468
|
-
return heap[idx];
|
|
469
|
-
}
|
|
470
|
-
function dropObject(idx) {
|
|
471
|
-
if (idx < 132)
|
|
472
|
-
return;
|
|
473
|
-
heap[idx] = heap_next;
|
|
474
|
-
heap_next = idx;
|
|
475
|
-
}
|
|
476
|
-
function takeObject(idx) {
|
|
477
|
-
const ret = getObject(idx);
|
|
478
|
-
dropObject(idx);
|
|
479
|
-
return ret;
|
|
480
|
-
}
|
|
481
|
-
var WASM_VECTOR_LEN = 0;
|
|
482
|
-
var lTextEncoder = typeof TextEncoder === "undefined" ? (0, module.require)("util").TextEncoder : TextEncoder;
|
|
483
|
-
var cachedTextEncoder = new lTextEncoder("utf-8");
|
|
484
|
-
var encodeString = typeof cachedTextEncoder.encodeInto === "function" ? function(arg, view) {
|
|
485
|
-
return cachedTextEncoder.encodeInto(arg, view);
|
|
486
|
-
} : function(arg, view) {
|
|
487
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
488
|
-
view.set(buf);
|
|
489
|
-
return {
|
|
490
|
-
read: arg.length,
|
|
491
|
-
written: buf.length
|
|
492
|
-
};
|
|
493
|
-
};
|
|
494
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
495
|
-
if (realloc === undefined) {
|
|
496
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
497
|
-
const ptr2 = malloc(buf.length, 1) >>> 0;
|
|
498
|
-
getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
|
|
499
|
-
WASM_VECTOR_LEN = buf.length;
|
|
500
|
-
return ptr2;
|
|
501
|
-
}
|
|
502
|
-
let len = arg.length;
|
|
503
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
504
|
-
const mem = getUint8ArrayMemory0();
|
|
505
|
-
let offset = 0;
|
|
506
|
-
for (;offset < len; offset++) {
|
|
507
|
-
const code = arg.charCodeAt(offset);
|
|
508
|
-
if (code > 127)
|
|
509
|
-
break;
|
|
510
|
-
mem[ptr + offset] = code;
|
|
511
|
-
}
|
|
512
|
-
if (offset !== len) {
|
|
513
|
-
if (offset !== 0) {
|
|
514
|
-
arg = arg.slice(offset);
|
|
515
|
-
}
|
|
516
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
517
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
518
|
-
const ret = encodeString(arg, view);
|
|
519
|
-
offset += ret.written;
|
|
520
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
521
|
-
}
|
|
522
|
-
WASM_VECTOR_LEN = offset;
|
|
523
|
-
return ptr;
|
|
524
|
-
}
|
|
525
|
-
function isLikeNone(x) {
|
|
526
|
-
return x === undefined || x === null;
|
|
527
|
-
}
|
|
528
|
-
var cachedDataViewMemory0 = null;
|
|
529
|
-
function getDataViewMemory0() {
|
|
530
|
-
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm2.memory.buffer) {
|
|
531
|
-
cachedDataViewMemory0 = new DataView(wasm2.memory.buffer);
|
|
532
|
-
}
|
|
533
|
-
return cachedDataViewMemory0;
|
|
534
|
-
}
|
|
535
|
-
var cachedUint32ArrayMemory0 = null;
|
|
536
|
-
function getUint32ArrayMemory0() {
|
|
537
|
-
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
538
|
-
cachedUint32ArrayMemory0 = new Uint32Array(wasm2.memory.buffer);
|
|
539
|
-
}
|
|
540
|
-
return cachedUint32ArrayMemory0;
|
|
541
|
-
}
|
|
542
|
-
function getArrayU32FromWasm0(ptr, len) {
|
|
543
|
-
ptr = ptr >>> 0;
|
|
544
|
-
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
545
|
-
}
|
|
546
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
547
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
548
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
549
|
-
WASM_VECTOR_LEN = arg.length;
|
|
550
|
-
return ptr;
|
|
551
|
-
}
|
|
552
|
-
function passArray32ToWasm0(arg, malloc) {
|
|
553
|
-
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
554
|
-
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
555
|
-
WASM_VECTOR_LEN = arg.length;
|
|
556
|
-
return ptr;
|
|
557
|
-
}
|
|
558
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
559
|
-
ptr = ptr >>> 0;
|
|
560
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
561
|
-
}
|
|
562
|
-
var TiktokenFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((ptr) => wasm2.__wbg_tiktoken_free(ptr >>> 0, 1));
|
|
563
|
-
|
|
564
|
-
class Tiktoken {
|
|
565
|
-
constructor(tiktoken_bfe, special_tokens, pat_str) {
|
|
566
|
-
if (wasm2 == null)
|
|
567
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
568
|
-
const ptr0 = passStringToWasm0(tiktoken_bfe, wasm2.__wbindgen_export_1, wasm2.__wbindgen_export_2);
|
|
569
|
-
const len0 = WASM_VECTOR_LEN;
|
|
570
|
-
const ptr1 = passStringToWasm0(pat_str, wasm2.__wbindgen_export_1, wasm2.__wbindgen_export_2);
|
|
571
|
-
const len1 = WASM_VECTOR_LEN;
|
|
572
|
-
const ret = wasm2.tiktoken_new(ptr0, len0, addHeapObject(special_tokens), ptr1, len1);
|
|
573
|
-
this.__wbg_ptr = ret >>> 0;
|
|
574
|
-
TiktokenFinalization.register(this, this.__wbg_ptr, this);
|
|
575
|
-
return this;
|
|
576
|
-
}
|
|
577
|
-
get name() {
|
|
578
|
-
try {
|
|
579
|
-
const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
|
|
580
|
-
wasm2.tiktoken_name(retptr, this.__wbg_ptr);
|
|
581
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
582
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
583
|
-
let v1;
|
|
584
|
-
if (r0 !== 0) {
|
|
585
|
-
v1 = getStringFromWasm0(r0, r1).slice();
|
|
586
|
-
wasm2.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
587
|
-
}
|
|
588
|
-
return v1;
|
|
589
|
-
} finally {
|
|
590
|
-
wasm2.__wbindgen_add_to_stack_pointer(16);
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
__destroy_into_raw() {
|
|
594
|
-
const ptr = this.__wbg_ptr;
|
|
595
|
-
this.__wbg_ptr = 0;
|
|
596
|
-
TiktokenFinalization.unregister(this);
|
|
597
|
-
return ptr;
|
|
598
|
-
}
|
|
599
|
-
free() {
|
|
600
|
-
if (wasm2 == null)
|
|
601
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
602
|
-
const ptr = this.__destroy_into_raw();
|
|
603
|
-
wasm2.__wbg_tiktoken_free(ptr, 0);
|
|
604
|
-
}
|
|
605
|
-
encode(text, allowed_special, disallowed_special) {
|
|
606
|
-
if (wasm2 == null)
|
|
607
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
608
|
-
try {
|
|
609
|
-
const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
|
|
610
|
-
const ptr0 = passStringToWasm0(text, wasm2.__wbindgen_export_1, wasm2.__wbindgen_export_2);
|
|
611
|
-
const len0 = WASM_VECTOR_LEN;
|
|
612
|
-
wasm2.tiktoken_encode(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(allowed_special), addHeapObject(disallowed_special));
|
|
613
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
614
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
615
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
616
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
617
|
-
if (r3) {
|
|
618
|
-
throw takeObject(r2);
|
|
619
|
-
}
|
|
620
|
-
var v2 = getArrayU32FromWasm0(r0, r1).slice();
|
|
621
|
-
wasm2.__wbindgen_export_3(r0, r1 * 4, 4);
|
|
622
|
-
return v2;
|
|
623
|
-
} finally {
|
|
624
|
-
wasm2.__wbindgen_add_to_stack_pointer(16);
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
encode_ordinary(text) {
|
|
628
|
-
if (wasm2 == null)
|
|
629
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
630
|
-
try {
|
|
631
|
-
const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
|
|
632
|
-
const ptr0 = passStringToWasm0(text, wasm2.__wbindgen_export_1, wasm2.__wbindgen_export_2);
|
|
633
|
-
const len0 = WASM_VECTOR_LEN;
|
|
634
|
-
wasm2.tiktoken_encode_ordinary(retptr, this.__wbg_ptr, ptr0, len0);
|
|
635
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
636
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
637
|
-
var v2 = getArrayU32FromWasm0(r0, r1).slice();
|
|
638
|
-
wasm2.__wbindgen_export_3(r0, r1 * 4, 4);
|
|
639
|
-
return v2;
|
|
640
|
-
} finally {
|
|
641
|
-
wasm2.__wbindgen_add_to_stack_pointer(16);
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
encode_with_unstable(text, allowed_special, disallowed_special) {
|
|
645
|
-
if (wasm2 == null)
|
|
646
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
647
|
-
try {
|
|
648
|
-
const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
|
|
649
|
-
const ptr0 = passStringToWasm0(text, wasm2.__wbindgen_export_1, wasm2.__wbindgen_export_2);
|
|
650
|
-
const len0 = WASM_VECTOR_LEN;
|
|
651
|
-
wasm2.tiktoken_encode_with_unstable(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(allowed_special), addHeapObject(disallowed_special));
|
|
652
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
653
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
654
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
655
|
-
if (r2) {
|
|
656
|
-
throw takeObject(r1);
|
|
657
|
-
}
|
|
658
|
-
return takeObject(r0);
|
|
659
|
-
} finally {
|
|
660
|
-
wasm2.__wbindgen_add_to_stack_pointer(16);
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
encode_single_token(bytes2) {
|
|
664
|
-
if (wasm2 == null)
|
|
665
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
666
|
-
const ptr0 = passArray8ToWasm0(bytes2, wasm2.__wbindgen_export_1);
|
|
667
|
-
const len0 = WASM_VECTOR_LEN;
|
|
668
|
-
const ret = wasm2.tiktoken_encode_single_token(this.__wbg_ptr, ptr0, len0);
|
|
669
|
-
return ret >>> 0;
|
|
670
|
-
}
|
|
671
|
-
decode(tokens) {
|
|
672
|
-
if (wasm2 == null)
|
|
673
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
674
|
-
try {
|
|
675
|
-
const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
|
|
676
|
-
const ptr0 = passArray32ToWasm0(tokens, wasm2.__wbindgen_export_1);
|
|
677
|
-
const len0 = WASM_VECTOR_LEN;
|
|
678
|
-
wasm2.tiktoken_decode(retptr, this.__wbg_ptr, ptr0, len0);
|
|
679
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
680
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
681
|
-
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
682
|
-
wasm2.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
683
|
-
return v2;
|
|
684
|
-
} finally {
|
|
685
|
-
wasm2.__wbindgen_add_to_stack_pointer(16);
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
decode_single_token_bytes(token) {
|
|
689
|
-
if (wasm2 == null)
|
|
690
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
691
|
-
try {
|
|
692
|
-
const retptr = wasm2.__wbindgen_add_to_stack_pointer(-16);
|
|
693
|
-
wasm2.tiktoken_decode_single_token_bytes(retptr, this.__wbg_ptr, token);
|
|
694
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
695
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
696
|
-
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
697
|
-
wasm2.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
698
|
-
return v1;
|
|
699
|
-
} finally {
|
|
700
|
-
wasm2.__wbindgen_add_to_stack_pointer(16);
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
token_byte_values() {
|
|
704
|
-
if (wasm2 == null)
|
|
705
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
706
|
-
const ret = wasm2.tiktoken_token_byte_values(this.__wbg_ptr);
|
|
707
|
-
return takeObject(ret);
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
exports.Tiktoken = Tiktoken;
|
|
711
|
-
exports.__wbg_parse_def2e24ef1252aff = function() {
|
|
712
|
-
return handleError(function(arg0, arg1) {
|
|
713
|
-
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
714
|
-
return addHeapObject(ret);
|
|
715
|
-
}, arguments);
|
|
716
|
-
};
|
|
717
|
-
exports.__wbg_stringify_f7ed6987935b4a24 = function() {
|
|
718
|
-
return handleError(function(arg0) {
|
|
719
|
-
const ret = JSON.stringify(getObject(arg0));
|
|
720
|
-
return addHeapObject(ret);
|
|
721
|
-
}, arguments);
|
|
722
|
-
};
|
|
723
|
-
exports.__wbindgen_error_new = function(arg0, arg1) {
|
|
724
|
-
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
725
|
-
return addHeapObject(ret);
|
|
726
|
-
};
|
|
727
|
-
exports.__wbindgen_is_undefined = function(arg0) {
|
|
728
|
-
const ret = getObject(arg0) === undefined;
|
|
729
|
-
return ret;
|
|
730
|
-
};
|
|
731
|
-
exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
732
|
-
takeObject(arg0);
|
|
733
|
-
};
|
|
734
|
-
exports.__wbindgen_string_get = function(arg0, arg1) {
|
|
735
|
-
if (wasm2 == null)
|
|
736
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
737
|
-
const obj = getObject(arg1);
|
|
738
|
-
const ret = typeof obj === "string" ? obj : undefined;
|
|
739
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm2.__wbindgen_export_1, wasm2.__wbindgen_export_2);
|
|
740
|
-
var len1 = WASM_VECTOR_LEN;
|
|
741
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
742
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
743
|
-
};
|
|
744
|
-
exports.__wbindgen_throw = function(arg0, arg1) {
|
|
745
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
746
|
-
};
|
|
747
|
-
});
|
|
748
|
-
|
|
749
|
-
// node_modules/tiktoken/lite/tiktoken.cjs
|
|
750
|
-
var require_tiktoken = __commonJS((exports) => {
|
|
751
|
-
var __dirname = "/home/runner/work/opencode-vibe-pm/opencode-vibe-pm/node_modules/tiktoken/lite";
|
|
752
|
-
var wasm2 = require_tiktoken_bg2();
|
|
753
|
-
var imports2 = {};
|
|
754
|
-
imports2["./tiktoken_bg.js"] = wasm2;
|
|
755
|
-
var path8 = __require("path");
|
|
756
|
-
var fs8 = __require("fs");
|
|
757
|
-
var candidates2 = __dirname.split(path8.sep).reduce((memo, _, index, array) => {
|
|
758
|
-
const prefix = array.slice(0, index + 1).join(path8.sep) + path8.sep;
|
|
759
|
-
if (!prefix.includes("node_modules" + path8.sep)) {
|
|
760
|
-
memo.unshift(path8.join(prefix, "node_modules", "tiktoken", "lite", "./tiktoken_bg.wasm"));
|
|
761
|
-
}
|
|
762
|
-
return memo;
|
|
763
|
-
}, []);
|
|
764
|
-
candidates2.unshift(path8.join(__dirname, "./tiktoken_bg.wasm"));
|
|
765
|
-
var bytes2 = null;
|
|
766
|
-
for (const candidate of candidates2) {
|
|
767
|
-
try {
|
|
768
|
-
bytes2 = fs8.readFileSync(candidate);
|
|
769
|
-
break;
|
|
770
|
-
} catch {}
|
|
771
|
-
}
|
|
772
|
-
if (bytes2 == null)
|
|
773
|
-
throw new Error("Missing tiktoken_bg.wasm");
|
|
774
|
-
var wasmModule2 = new WebAssembly.Module(bytes2);
|
|
775
|
-
var wasmInstance2 = new WebAssembly.Instance(wasmModule2, imports2);
|
|
776
|
-
wasm2.__wbg_set_wasm(wasmInstance2.exports);
|
|
777
|
-
exports.Tiktoken = wasm2["Tiktoken"];
|
|
778
|
-
});
|
|
779
|
-
|
|
780
35
|
// node_modules/@anthropic-ai/tokenizer/dist/cjs/claude.json
|
|
781
36
|
var require_claude = __commonJS((exports, module) => {
|
|
782
37
|
module.exports = {
|
|
@@ -800,7 +55,7 @@ var require_cjs = __commonJS((exports) => {
|
|
|
800
55
|
};
|
|
801
56
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
802
57
|
exports.getTokenizer = exports.countTokens = undefined;
|
|
803
|
-
var lite_1 =
|
|
58
|
+
var lite_1 = __require("tiktoken/lite");
|
|
804
59
|
var claude_json_1 = __importDefault(require_claude());
|
|
805
60
|
function countTokens(text) {
|
|
806
61
|
const tokenizer = getTokenizer();
|
|
@@ -816,7 +71,7 @@ var require_cjs = __commonJS((exports) => {
|
|
|
816
71
|
});
|
|
817
72
|
|
|
818
73
|
// src/core/plugin.ts
|
|
819
|
-
import * as
|
|
74
|
+
import * as path7 from "path";
|
|
820
75
|
|
|
821
76
|
// src/core/config.ts
|
|
822
77
|
import * as fs from "fs";
|
|
@@ -1345,10 +600,25 @@ Create project term dictionary docs/regulation/dictionary.md (if not exists).
|
|
|
1345
600
|
title: "Integration: DCP",
|
|
1346
601
|
type: "question",
|
|
1347
602
|
instruction: `
|
|
1348
|
-
Configure DCP plugin.
|
|
1349
|
-
1.
|
|
1350
|
-
|
|
1351
|
-
|
|
603
|
+
Configure DCP (Dynamic Context Pruning) plugin.
|
|
604
|
+
1. Use bash to check global and project-level opencode configs for the plugin "@tarquinen/opencode-dcp":
|
|
605
|
+
- ~/.config/opencode/opencode.json (global config)
|
|
606
|
+
- ./.opencode/opencode.json (project config)
|
|
607
|
+
2. If not installed \u2192 suggest installation. Command: "opencode plugin @tarquinen/opencode-dcp@latest --global"
|
|
608
|
+
3. Configure DCP: merge the following config into "~/.config/opencode/dcp.jsonc" or "~/.config/opencode/dcp.json"
|
|
609
|
+
(if neither exists, create dcp.jsonc)
|
|
610
|
+
\`\`\`json
|
|
611
|
+
{
|
|
612
|
+
"compress": {
|
|
613
|
+
"protectTags": true
|
|
614
|
+
},
|
|
615
|
+
"protectedFilePatterns": [
|
|
616
|
+
"docs/flow/*",
|
|
617
|
+
"docs/regulation/*",
|
|
618
|
+
"docs/spec/*"
|
|
619
|
+
]
|
|
620
|
+
}
|
|
621
|
+
\`\`\``,
|
|
1352
622
|
checkInstalled: "opencode-dynamic-context-pruning",
|
|
1353
623
|
checkPaths: ["~/.config/opencode/opencode.json", ".opencode/opencode.json"],
|
|
1354
624
|
params: {
|
|
@@ -1746,9 +1016,23 @@ ${tableRows}
|
|
|
1746
1016
|
type: "question",
|
|
1747
1017
|
instruction: `
|
|
1748
1018
|
\u914D\u7F6E DCP (Dynamic Context Pruning) \u63D2\u4EF6\u3002
|
|
1749
|
-
1. \u7528 bash \u68C0\u67E5\u5168\u5C40\u548C\u9879\u76EE\u7EA7 opencode \u914D\u7F6E\
|
|
1750
|
-
|
|
1751
|
-
|
|
1019
|
+
1. \u7528 bash \u68C0\u67E5\u5168\u5C40\u548C\u9879\u76EE\u7EA7 opencode \u914D\u7F6E, \u662F\u5426\u5305\u542B\u4E86\u63D2\u4EF6\u914D\u7F6E"@tarquinen/opencode-dcp"\uFF1A
|
|
1020
|
+
- ~/.config/opencode/opencode.json\uFF08\u9879\u76EE\u7EA7\u914D\u7F6E\uFF09
|
|
1021
|
+
- ./.opencode/opencode.json\uFF08\u9879\u76EE\u7EA7\u914D\u7F6E\uFF09
|
|
1022
|
+
2. \u82E5\u672A\u5B89\u88C5 \u2192 \u5EFA\u8BAE\u7528\u6237\u5B89\u88C5\u3002\u5B89\u88C5\u65B9\u5F0F\uFF1A"opencode plugin @tarquinen/opencode-dcp@latest --global"
|
|
1023
|
+
3. \u914D\u7F6Edcp, \u5C06\u4EE5\u4E0B\u914D\u7F6E\u5408\u5E76\u5230"~/.config/opencode/dcp.jsonc" \u6216 "~/.config/opencode/dcp.json" (\u5982\u90FD\u672A\u5B58\u5728, \u521B\u5EFAdcp.jsonc)
|
|
1024
|
+
\`\`\`json
|
|
1025
|
+
{
|
|
1026
|
+
"compress": {
|
|
1027
|
+
"protectTags": true
|
|
1028
|
+
},
|
|
1029
|
+
"protectedFilePatterns": [
|
|
1030
|
+
"docs/flow/*",
|
|
1031
|
+
"docs/regulation/*",
|
|
1032
|
+
"docs/spec/*"
|
|
1033
|
+
]
|
|
1034
|
+
}
|
|
1035
|
+
\`\`\``,
|
|
1752
1036
|
checkInstalled: "opencode-dynamic-context-pruning",
|
|
1753
1037
|
checkPaths: ["~/.config/opencode/opencode.json", ".opencode/opencode.json"],
|
|
1754
1038
|
params: {
|
|
@@ -2099,7 +1383,10 @@ function registerCommands(opencodeConfig) {
|
|
|
2099
1383
|
const commands = opencodeConfig.command ??= {};
|
|
2100
1384
|
const descMap = i18n().tool.commandDesc;
|
|
2101
1385
|
for (const cmd of COMMANDS) {
|
|
2102
|
-
commands[cmd.name] = {
|
|
1386
|
+
commands[cmd.name] = {
|
|
1387
|
+
template: cmd.template || "",
|
|
1388
|
+
description: descMap[cmd.name] ?? cmd.name
|
|
1389
|
+
};
|
|
2103
1390
|
}
|
|
2104
1391
|
}
|
|
2105
1392
|
function registerFlowCommands(opencodeConfig, projectDir) {
|
|
@@ -3272,46 +2559,16 @@ class FlowEngine {
|
|
|
3272
2559
|
return map;
|
|
3273
2560
|
}
|
|
3274
2561
|
}
|
|
3275
|
-
// node_modules/tiktoken/tiktoken.cjs
|
|
3276
|
-
var __dirname = "/home/runner/work/opencode-vibe-pm/opencode-vibe-pm/node_modules/tiktoken";
|
|
3277
|
-
var wasm = require_tiktoken_bg();
|
|
3278
|
-
var imports = {};
|
|
3279
|
-
imports["./tiktoken_bg.js"] = wasm;
|
|
3280
|
-
var path7 = __require("path");
|
|
3281
|
-
var fs7 = __require("fs");
|
|
3282
|
-
var candidates = __dirname.split(path7.sep).reduce((memo, _, index, array) => {
|
|
3283
|
-
const prefix = array.slice(0, index + 1).join(path7.sep) + path7.sep;
|
|
3284
|
-
if (!prefix.includes("node_modules" + path7.sep)) {
|
|
3285
|
-
memo.unshift(path7.join(prefix, "node_modules", "tiktoken", "", "./tiktoken_bg.wasm"));
|
|
3286
|
-
}
|
|
3287
|
-
return memo;
|
|
3288
|
-
}, []);
|
|
3289
|
-
candidates.unshift(path7.join(__dirname, "./tiktoken_bg.wasm"));
|
|
3290
|
-
var bytes = null;
|
|
3291
|
-
for (const candidate of candidates) {
|
|
3292
|
-
try {
|
|
3293
|
-
bytes = fs7.readFileSync(candidate);
|
|
3294
|
-
break;
|
|
3295
|
-
} catch {}
|
|
3296
|
-
}
|
|
3297
|
-
if (bytes == null)
|
|
3298
|
-
throw new Error("Missing tiktoken_bg.wasm");
|
|
3299
|
-
var wasmModule = new WebAssembly.Module(bytes);
|
|
3300
|
-
var wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
|
3301
|
-
wasm.__wbg_set_wasm(wasmInstance.exports);
|
|
3302
|
-
var $get_encoding = wasm["get_encoding"];
|
|
3303
|
-
var $encoding_for_model = wasm["encoding_for_model"];
|
|
3304
|
-
var $get_encoding_name_for_model = wasm["get_encoding_name_for_model"];
|
|
3305
|
-
var $Tiktoken = wasm["Tiktoken"];
|
|
3306
|
-
|
|
3307
2562
|
// src/token/backends/tiktoken.ts
|
|
2563
|
+
import { get_encoding, encoding_for_model } from "tiktoken";
|
|
2564
|
+
|
|
3308
2565
|
class TiktokenBackend {
|
|
3309
2566
|
encoder;
|
|
3310
2567
|
constructor(modelID) {
|
|
3311
2568
|
try {
|
|
3312
|
-
this.encoder =
|
|
2569
|
+
this.encoder = encoding_for_model(modelID);
|
|
3313
2570
|
} catch {
|
|
3314
|
-
this.encoder =
|
|
2571
|
+
this.encoder = get_encoding("cl100k_base");
|
|
3315
2572
|
}
|
|
3316
2573
|
}
|
|
3317
2574
|
countTokens(text) {
|
|
@@ -3479,12 +2736,12 @@ class LlamaTokenizer {
|
|
|
3479
2736
|
if (this.vocabByString.has(c)) {
|
|
3480
2737
|
tokenIds.push(this.vocabByString.get(c));
|
|
3481
2738
|
} else {
|
|
3482
|
-
const
|
|
3483
|
-
for (let j = 0;j <
|
|
3484
|
-
const hex = this.vocabByString.get(utf8ByteToHex(
|
|
2739
|
+
const bytes = this.utf8Encoder.encode(c);
|
|
2740
|
+
for (let j = 0;j < bytes.length; j++) {
|
|
2741
|
+
const hex = this.vocabByString.get(utf8ByteToHex(bytes[j]));
|
|
3485
2742
|
tokenIds.push(hex);
|
|
3486
2743
|
if (!(hex >= 0)) {
|
|
3487
|
-
console.log("Encountered unknown character " + c + " (partial UTF-8 byte " +
|
|
2744
|
+
console.log("Encountered unknown character " + c + " (partial UTF-8 byte " + bytes[j] + " + hex + " + utf8ByteToHex(bytes[j]) + ")");
|
|
3488
2745
|
tokenIds[tokenIds.length - 1] = 0;
|
|
3489
2746
|
}
|
|
3490
2747
|
}
|
|
@@ -4722,11 +3979,12 @@ class TokenCounter {
|
|
|
4722
3979
|
this.backend.dispose();
|
|
4723
3980
|
}
|
|
4724
3981
|
}
|
|
3982
|
+
|
|
4725
3983
|
// src/core/plugin.ts
|
|
4726
3984
|
var VibePMPlugin = async (ctx) => {
|
|
4727
3985
|
ensureDefaultConfig(ctx.directory);
|
|
4728
3986
|
const config = loadConfig(ctx.directory);
|
|
4729
|
-
const dataDir =
|
|
3987
|
+
const dataDir = path7.resolve(ctx.directory, config.dataDir);
|
|
4730
3988
|
const pluginCtx = {
|
|
4731
3989
|
config,
|
|
4732
3990
|
projectDir: ctx.directory,
|