opencode-codebase-index 0.17.0 → 0.17.1
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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/dist/cli.cjs +1 -462
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +3 -470
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +1 -462
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -470
- package/dist/index.js.map +1 -1
- package/dist/pi-extension.cjs +1 -462
- package/dist/pi-extension.cjs.map +1 -1
- package/dist/pi-extension.js +3 -470
- package/dist/pi-extension.js.map +1 -1
- package/native/codebase-index-native.darwin-arm64.node +0 -0
- package/native/codebase-index-native.darwin-x64.node +0 -0
- package/native/codebase-index-native.win32-x64-msvc.node +0 -0
- package/package.json +2 -2
package/dist/pi-extension.js
CHANGED
|
@@ -6,13 +6,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var
|
|
10
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
11
|
-
}) : x)(function(x) {
|
|
12
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
13
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
14
|
-
});
|
|
15
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
9
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
16
10
|
try {
|
|
17
11
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
18
12
|
} catch (e) {
|
|
@@ -656,467 +650,6 @@ var require_ignore = __commonJS({
|
|
|
656
650
|
}
|
|
657
651
|
});
|
|
658
652
|
|
|
659
|
-
// node_modules/tiktoken/tiktoken_bg.cjs
|
|
660
|
-
var require_tiktoken_bg = __commonJS({
|
|
661
|
-
"node_modules/tiktoken/tiktoken_bg.cjs"(exports, module2) {
|
|
662
|
-
"use strict";
|
|
663
|
-
var wasm;
|
|
664
|
-
module2.exports.__wbg_set_wasm = function(val) {
|
|
665
|
-
wasm = val;
|
|
666
|
-
};
|
|
667
|
-
var lTextDecoder = typeof TextDecoder === "undefined" ? (0, module2.require)("util").TextDecoder : TextDecoder;
|
|
668
|
-
var cachedTextDecoder = new lTextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
669
|
-
cachedTextDecoder.decode();
|
|
670
|
-
var cachedUint8ArrayMemory0 = null;
|
|
671
|
-
function getUint8ArrayMemory0() {
|
|
672
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
673
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
674
|
-
}
|
|
675
|
-
return cachedUint8ArrayMemory0;
|
|
676
|
-
}
|
|
677
|
-
function getStringFromWasm0(ptr, len) {
|
|
678
|
-
ptr = ptr >>> 0;
|
|
679
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
680
|
-
}
|
|
681
|
-
var heap = new Array(128).fill(void 0);
|
|
682
|
-
heap.push(void 0, null, true, false);
|
|
683
|
-
var heap_next = heap.length;
|
|
684
|
-
function addHeapObject(obj) {
|
|
685
|
-
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
686
|
-
const idx = heap_next;
|
|
687
|
-
heap_next = heap[idx];
|
|
688
|
-
heap[idx] = obj;
|
|
689
|
-
return idx;
|
|
690
|
-
}
|
|
691
|
-
function handleError(f, args) {
|
|
692
|
-
try {
|
|
693
|
-
return f.apply(this, args);
|
|
694
|
-
} catch (e) {
|
|
695
|
-
wasm.__wbindgen_export_0(addHeapObject(e));
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
function getObject(idx) {
|
|
699
|
-
return heap[idx];
|
|
700
|
-
}
|
|
701
|
-
function dropObject(idx) {
|
|
702
|
-
if (idx < 132) return;
|
|
703
|
-
heap[idx] = heap_next;
|
|
704
|
-
heap_next = idx;
|
|
705
|
-
}
|
|
706
|
-
function takeObject(idx) {
|
|
707
|
-
const ret = getObject(idx);
|
|
708
|
-
dropObject(idx);
|
|
709
|
-
return ret;
|
|
710
|
-
}
|
|
711
|
-
var WASM_VECTOR_LEN = 0;
|
|
712
|
-
var lTextEncoder = typeof TextEncoder === "undefined" ? (0, module2.require)("util").TextEncoder : TextEncoder;
|
|
713
|
-
var cachedTextEncoder = new lTextEncoder("utf-8");
|
|
714
|
-
var encodeString = typeof cachedTextEncoder.encodeInto === "function" ? function(arg, view) {
|
|
715
|
-
return cachedTextEncoder.encodeInto(arg, view);
|
|
716
|
-
} : function(arg, view) {
|
|
717
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
718
|
-
view.set(buf);
|
|
719
|
-
return {
|
|
720
|
-
read: arg.length,
|
|
721
|
-
written: buf.length
|
|
722
|
-
};
|
|
723
|
-
};
|
|
724
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
725
|
-
if (realloc === void 0) {
|
|
726
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
727
|
-
const ptr2 = malloc(buf.length, 1) >>> 0;
|
|
728
|
-
getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
|
|
729
|
-
WASM_VECTOR_LEN = buf.length;
|
|
730
|
-
return ptr2;
|
|
731
|
-
}
|
|
732
|
-
let len = arg.length;
|
|
733
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
734
|
-
const mem = getUint8ArrayMemory0();
|
|
735
|
-
let offset = 0;
|
|
736
|
-
for (; offset < len; offset++) {
|
|
737
|
-
const code = arg.charCodeAt(offset);
|
|
738
|
-
if (code > 127) break;
|
|
739
|
-
mem[ptr + offset] = code;
|
|
740
|
-
}
|
|
741
|
-
if (offset !== len) {
|
|
742
|
-
if (offset !== 0) {
|
|
743
|
-
arg = arg.slice(offset);
|
|
744
|
-
}
|
|
745
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
746
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
747
|
-
const ret = encodeString(arg, view);
|
|
748
|
-
offset += ret.written;
|
|
749
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
750
|
-
}
|
|
751
|
-
WASM_VECTOR_LEN = offset;
|
|
752
|
-
return ptr;
|
|
753
|
-
}
|
|
754
|
-
function isLikeNone(x) {
|
|
755
|
-
return x === void 0 || x === null;
|
|
756
|
-
}
|
|
757
|
-
var cachedDataViewMemory0 = null;
|
|
758
|
-
function getDataViewMemory0() {
|
|
759
|
-
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
|
|
760
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
761
|
-
}
|
|
762
|
-
return cachedDataViewMemory0;
|
|
763
|
-
}
|
|
764
|
-
var cachedUint32ArrayMemory0 = null;
|
|
765
|
-
function getUint32ArrayMemory0() {
|
|
766
|
-
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
767
|
-
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
768
|
-
}
|
|
769
|
-
return cachedUint32ArrayMemory0;
|
|
770
|
-
}
|
|
771
|
-
function getArrayU32FromWasm0(ptr, len) {
|
|
772
|
-
ptr = ptr >>> 0;
|
|
773
|
-
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
774
|
-
}
|
|
775
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
776
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
777
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
778
|
-
WASM_VECTOR_LEN = arg.length;
|
|
779
|
-
return ptr;
|
|
780
|
-
}
|
|
781
|
-
function passArray32ToWasm0(arg, malloc) {
|
|
782
|
-
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
783
|
-
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
784
|
-
WASM_VECTOR_LEN = arg.length;
|
|
785
|
-
return ptr;
|
|
786
|
-
}
|
|
787
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
788
|
-
ptr = ptr >>> 0;
|
|
789
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
790
|
-
}
|
|
791
|
-
module2.exports.get_encoding = function(encoding, extend_special_tokens) {
|
|
792
|
-
if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
793
|
-
try {
|
|
794
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
795
|
-
const ptr0 = passStringToWasm0(encoding, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
796
|
-
const len0 = WASM_VECTOR_LEN;
|
|
797
|
-
wasm.get_encoding(retptr, ptr0, len0, addHeapObject(extend_special_tokens));
|
|
798
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
799
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
800
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
801
|
-
if (r2) {
|
|
802
|
-
throw takeObject(r1);
|
|
803
|
-
}
|
|
804
|
-
return Tiktoken.__wrap(r0);
|
|
805
|
-
} finally {
|
|
806
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
807
|
-
}
|
|
808
|
-
};
|
|
809
|
-
module2.exports.encoding_for_model = function(model, extend_special_tokens) {
|
|
810
|
-
if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
811
|
-
try {
|
|
812
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
813
|
-
const ptr0 = passStringToWasm0(model, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
814
|
-
const len0 = WASM_VECTOR_LEN;
|
|
815
|
-
wasm.encoding_for_model(retptr, ptr0, len0, addHeapObject(extend_special_tokens));
|
|
816
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
817
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
818
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
819
|
-
if (r2) {
|
|
820
|
-
throw takeObject(r1);
|
|
821
|
-
}
|
|
822
|
-
return Tiktoken.__wrap(r0);
|
|
823
|
-
} finally {
|
|
824
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
825
|
-
}
|
|
826
|
-
};
|
|
827
|
-
module2.exports.get_encoding_name_for_model = function(model) {
|
|
828
|
-
if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
829
|
-
let deferred3_0;
|
|
830
|
-
let deferred3_1;
|
|
831
|
-
try {
|
|
832
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
833
|
-
const ptr0 = passStringToWasm0(model, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
834
|
-
const len0 = WASM_VECTOR_LEN;
|
|
835
|
-
wasm.get_encoding_name_for_model(retptr, ptr0, len0);
|
|
836
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
837
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
838
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
839
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
840
|
-
var ptr2 = r0;
|
|
841
|
-
var len2 = r1;
|
|
842
|
-
if (r3) {
|
|
843
|
-
ptr2 = 0;
|
|
844
|
-
len2 = 0;
|
|
845
|
-
throw takeObject(r2);
|
|
846
|
-
}
|
|
847
|
-
deferred3_0 = ptr2;
|
|
848
|
-
deferred3_1 = len2;
|
|
849
|
-
return getStringFromWasm0(ptr2, len2);
|
|
850
|
-
} finally {
|
|
851
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
852
|
-
wasm.__wbindgen_export_3(deferred3_0, deferred3_1, 1);
|
|
853
|
-
}
|
|
854
|
-
};
|
|
855
|
-
var TiktokenFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
856
|
-
}, unregister: () => {
|
|
857
|
-
} } : new FinalizationRegistry((ptr) => wasm.__wbg_tiktoken_free(ptr >>> 0, 1));
|
|
858
|
-
var Tiktoken = class _Tiktoken {
|
|
859
|
-
/**
|
|
860
|
-
* @param {string} tiktoken_bfe
|
|
861
|
-
* @param {any} special_tokens
|
|
862
|
-
* @param {string} pat_str
|
|
863
|
-
*/
|
|
864
|
-
constructor(tiktoken_bfe, special_tokens, pat_str) {
|
|
865
|
-
if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
866
|
-
const ptr0 = passStringToWasm0(tiktoken_bfe, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
867
|
-
const len0 = WASM_VECTOR_LEN;
|
|
868
|
-
const ptr1 = passStringToWasm0(pat_str, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
869
|
-
const len1 = WASM_VECTOR_LEN;
|
|
870
|
-
const ret = wasm.tiktoken_new(ptr0, len0, addHeapObject(special_tokens), ptr1, len1);
|
|
871
|
-
this.__wbg_ptr = ret >>> 0;
|
|
872
|
-
TiktokenFinalization.register(this, this.__wbg_ptr, this);
|
|
873
|
-
return this;
|
|
874
|
-
}
|
|
875
|
-
/** @returns {string | undefined} */
|
|
876
|
-
get name() {
|
|
877
|
-
try {
|
|
878
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
879
|
-
wasm.tiktoken_name(retptr, this.__wbg_ptr);
|
|
880
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
881
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
882
|
-
let v1;
|
|
883
|
-
if (r0 !== 0) {
|
|
884
|
-
v1 = getStringFromWasm0(r0, r1).slice();
|
|
885
|
-
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
886
|
-
}
|
|
887
|
-
return v1;
|
|
888
|
-
} finally {
|
|
889
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
static __wrap(ptr) {
|
|
893
|
-
ptr = ptr >>> 0;
|
|
894
|
-
const obj = Object.create(_Tiktoken.prototype);
|
|
895
|
-
obj.__wbg_ptr = ptr;
|
|
896
|
-
TiktokenFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
897
|
-
return obj;
|
|
898
|
-
}
|
|
899
|
-
__destroy_into_raw() {
|
|
900
|
-
const ptr = this.__wbg_ptr;
|
|
901
|
-
this.__wbg_ptr = 0;
|
|
902
|
-
TiktokenFinalization.unregister(this);
|
|
903
|
-
return ptr;
|
|
904
|
-
}
|
|
905
|
-
free() {
|
|
906
|
-
if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
907
|
-
const ptr = this.__destroy_into_raw();
|
|
908
|
-
wasm.__wbg_tiktoken_free(ptr, 0);
|
|
909
|
-
}
|
|
910
|
-
/**
|
|
911
|
-
* @param {string} text
|
|
912
|
-
* @param {any} allowed_special
|
|
913
|
-
* @param {any} disallowed_special
|
|
914
|
-
* @returns {Uint32Array}
|
|
915
|
-
*/
|
|
916
|
-
encode(text3, allowed_special, disallowed_special) {
|
|
917
|
-
if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
918
|
-
try {
|
|
919
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
920
|
-
const ptr0 = passStringToWasm0(text3, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
921
|
-
const len0 = WASM_VECTOR_LEN;
|
|
922
|
-
wasm.tiktoken_encode(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(allowed_special), addHeapObject(disallowed_special));
|
|
923
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
924
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
925
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
926
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
927
|
-
if (r3) {
|
|
928
|
-
throw takeObject(r2);
|
|
929
|
-
}
|
|
930
|
-
var v2 = getArrayU32FromWasm0(r0, r1).slice();
|
|
931
|
-
wasm.__wbindgen_export_3(r0, r1 * 4, 4);
|
|
932
|
-
return v2;
|
|
933
|
-
} finally {
|
|
934
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
/**
|
|
938
|
-
* @param {string} text
|
|
939
|
-
* @returns {Uint32Array}
|
|
940
|
-
*/
|
|
941
|
-
encode_ordinary(text3) {
|
|
942
|
-
if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
943
|
-
try {
|
|
944
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
945
|
-
const ptr0 = passStringToWasm0(text3, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
946
|
-
const len0 = WASM_VECTOR_LEN;
|
|
947
|
-
wasm.tiktoken_encode_ordinary(retptr, this.__wbg_ptr, ptr0, len0);
|
|
948
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
949
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
950
|
-
var v2 = getArrayU32FromWasm0(r0, r1).slice();
|
|
951
|
-
wasm.__wbindgen_export_3(r0, r1 * 4, 4);
|
|
952
|
-
return v2;
|
|
953
|
-
} finally {
|
|
954
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
/**
|
|
958
|
-
* @param {string} text
|
|
959
|
-
* @param {any} allowed_special
|
|
960
|
-
* @param {any} disallowed_special
|
|
961
|
-
* @returns {any}
|
|
962
|
-
*/
|
|
963
|
-
encode_with_unstable(text3, allowed_special, disallowed_special) {
|
|
964
|
-
if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
965
|
-
try {
|
|
966
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
967
|
-
const ptr0 = passStringToWasm0(text3, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
968
|
-
const len0 = WASM_VECTOR_LEN;
|
|
969
|
-
wasm.tiktoken_encode_with_unstable(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(allowed_special), addHeapObject(disallowed_special));
|
|
970
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
971
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
972
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
973
|
-
if (r2) {
|
|
974
|
-
throw takeObject(r1);
|
|
975
|
-
}
|
|
976
|
-
return takeObject(r0);
|
|
977
|
-
} finally {
|
|
978
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
/**
|
|
982
|
-
* @param {Uint8Array} bytes
|
|
983
|
-
* @returns {number}
|
|
984
|
-
*/
|
|
985
|
-
encode_single_token(bytes) {
|
|
986
|
-
if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
987
|
-
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_1);
|
|
988
|
-
const len0 = WASM_VECTOR_LEN;
|
|
989
|
-
const ret = wasm.tiktoken_encode_single_token(this.__wbg_ptr, ptr0, len0);
|
|
990
|
-
return ret >>> 0;
|
|
991
|
-
}
|
|
992
|
-
/**
|
|
993
|
-
* @param {Uint32Array} tokens
|
|
994
|
-
* @returns {Uint8Array}
|
|
995
|
-
*/
|
|
996
|
-
decode(tokens) {
|
|
997
|
-
if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
998
|
-
try {
|
|
999
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1000
|
-
const ptr0 = passArray32ToWasm0(tokens, wasm.__wbindgen_export_1);
|
|
1001
|
-
const len0 = WASM_VECTOR_LEN;
|
|
1002
|
-
wasm.tiktoken_decode(retptr, this.__wbg_ptr, ptr0, len0);
|
|
1003
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1004
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1005
|
-
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
1006
|
-
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
1007
|
-
return v2;
|
|
1008
|
-
} finally {
|
|
1009
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
/**
|
|
1013
|
-
* @param {number} token
|
|
1014
|
-
* @returns {Uint8Array}
|
|
1015
|
-
*/
|
|
1016
|
-
decode_single_token_bytes(token) {
|
|
1017
|
-
if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
1018
|
-
try {
|
|
1019
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1020
|
-
wasm.tiktoken_decode_single_token_bytes(retptr, this.__wbg_ptr, token);
|
|
1021
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1022
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1023
|
-
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
1024
|
-
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
1025
|
-
return v1;
|
|
1026
|
-
} finally {
|
|
1027
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
/** @returns {any} */
|
|
1031
|
-
token_byte_values() {
|
|
1032
|
-
if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
1033
|
-
const ret = wasm.tiktoken_token_byte_values(this.__wbg_ptr);
|
|
1034
|
-
return takeObject(ret);
|
|
1035
|
-
}
|
|
1036
|
-
};
|
|
1037
|
-
module2.exports.Tiktoken = Tiktoken;
|
|
1038
|
-
module2.exports.__wbg_parse_def2e24ef1252aff = function() {
|
|
1039
|
-
return handleError(function(arg0, arg1) {
|
|
1040
|
-
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
1041
|
-
return addHeapObject(ret);
|
|
1042
|
-
}, arguments);
|
|
1043
|
-
};
|
|
1044
|
-
module2.exports.__wbg_stringify_f7ed6987935b4a24 = function() {
|
|
1045
|
-
return handleError(function(arg0) {
|
|
1046
|
-
const ret = JSON.stringify(getObject(arg0));
|
|
1047
|
-
return addHeapObject(ret);
|
|
1048
|
-
}, arguments);
|
|
1049
|
-
};
|
|
1050
|
-
module2.exports.__wbindgen_error_new = function(arg0, arg1) {
|
|
1051
|
-
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
1052
|
-
return addHeapObject(ret);
|
|
1053
|
-
};
|
|
1054
|
-
module2.exports.__wbindgen_is_undefined = function(arg0) {
|
|
1055
|
-
const ret = getObject(arg0) === void 0;
|
|
1056
|
-
return ret;
|
|
1057
|
-
};
|
|
1058
|
-
module2.exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
1059
|
-
takeObject(arg0);
|
|
1060
|
-
};
|
|
1061
|
-
module2.exports.__wbindgen_string_get = function(arg0, arg1) {
|
|
1062
|
-
if (wasm == null) throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
1063
|
-
const obj = getObject(arg1);
|
|
1064
|
-
const ret = typeof obj === "string" ? obj : void 0;
|
|
1065
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
1066
|
-
var len1 = WASM_VECTOR_LEN;
|
|
1067
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1068
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1069
|
-
};
|
|
1070
|
-
module2.exports.__wbindgen_throw = function(arg0, arg1) {
|
|
1071
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1072
|
-
};
|
|
1073
|
-
}
|
|
1074
|
-
});
|
|
1075
|
-
|
|
1076
|
-
// node_modules/tiktoken/tiktoken.cjs
|
|
1077
|
-
var require_tiktoken = __commonJS({
|
|
1078
|
-
"node_modules/tiktoken/tiktoken.cjs"(exports) {
|
|
1079
|
-
"use strict";
|
|
1080
|
-
var wasm = require_tiktoken_bg();
|
|
1081
|
-
var imports = {};
|
|
1082
|
-
imports["./tiktoken_bg.js"] = wasm;
|
|
1083
|
-
var path17 = __require("path");
|
|
1084
|
-
var fs = __require("fs");
|
|
1085
|
-
var candidates = __dirname.split(path17.sep).reduce((memo, _, index, array) => {
|
|
1086
|
-
const prefix = array.slice(0, index + 1).join(path17.sep) + path17.sep;
|
|
1087
|
-
if (!prefix.includes("node_modules" + path17.sep)) {
|
|
1088
|
-
memo.unshift(
|
|
1089
|
-
path17.join(
|
|
1090
|
-
prefix,
|
|
1091
|
-
"node_modules",
|
|
1092
|
-
"tiktoken",
|
|
1093
|
-
"",
|
|
1094
|
-
"./tiktoken_bg.wasm"
|
|
1095
|
-
)
|
|
1096
|
-
);
|
|
1097
|
-
}
|
|
1098
|
-
return memo;
|
|
1099
|
-
}, []);
|
|
1100
|
-
candidates.unshift(path17.join(__dirname, "./tiktoken_bg.wasm"));
|
|
1101
|
-
var bytes = null;
|
|
1102
|
-
for (const candidate of candidates) {
|
|
1103
|
-
try {
|
|
1104
|
-
bytes = fs.readFileSync(candidate);
|
|
1105
|
-
break;
|
|
1106
|
-
} catch {
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
if (bytes == null) throw new Error("Missing tiktoken_bg.wasm");
|
|
1110
|
-
var wasmModule = new WebAssembly.Module(bytes);
|
|
1111
|
-
var wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
|
1112
|
-
wasm.__wbg_set_wasm(wasmInstance.exports);
|
|
1113
|
-
exports["get_encoding"] = wasm["get_encoding"];
|
|
1114
|
-
exports["encoding_for_model"] = wasm["encoding_for_model"];
|
|
1115
|
-
exports["get_encoding_name_for_model"] = wasm["get_encoding_name_for_model"];
|
|
1116
|
-
exports["Tiktoken"] = wasm["Tiktoken"];
|
|
1117
|
-
}
|
|
1118
|
-
});
|
|
1119
|
-
|
|
1120
653
|
// src/pi-extension.ts
|
|
1121
654
|
import { Type as Type2 } from "typebox";
|
|
1122
655
|
|
|
@@ -10423,11 +9956,11 @@ function findKnowledgeBasePathIndex(knowledgeBases, inputPath, projectRoot3) {
|
|
|
10423
9956
|
}
|
|
10424
9957
|
|
|
10425
9958
|
// src/tools/utils.ts
|
|
10426
|
-
|
|
9959
|
+
import { get_encoding } from "tiktoken";
|
|
10427
9960
|
var MIN_CONTEXT_PACK_TOKEN_BUDGET = 128;
|
|
10428
9961
|
var MAX_CONTEXT_PACK_TOKEN_BUDGET = 4e3;
|
|
10429
9962
|
var DEFAULT_CONTEXT_PACK_TOKEN_BUDGET = 1200;
|
|
10430
|
-
var CONTEXT_TOKENIZER =
|
|
9963
|
+
var CONTEXT_TOKENIZER = get_encoding("cl100k_base");
|
|
10431
9964
|
function clampContextPackTokenBudget(tokenBudget) {
|
|
10432
9965
|
if (tokenBudget === void 0 || !Number.isFinite(tokenBudget)) {
|
|
10433
9966
|
return DEFAULT_CONTEXT_PACK_TOKEN_BUDGET;
|