@hasna/assistants 0.6.27 → 0.6.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +428 -738
- package/dist/index.js.map +14 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17773,434 +17773,6 @@ var init_src = __esm(() => {
|
|
|
17773
17773
|
init_utils();
|
|
17774
17774
|
});
|
|
17775
17775
|
|
|
17776
|
-
// node_modules/.pnpm/tiktoken@1.0.22/node_modules/tiktoken/tiktoken_bg.cjs
|
|
17777
|
-
var require_tiktoken_bg = __commonJS((exports, module) => {
|
|
17778
|
-
var wasm;
|
|
17779
|
-
exports.__wbg_set_wasm = function(val) {
|
|
17780
|
-
wasm = val;
|
|
17781
|
-
};
|
|
17782
|
-
var lTextDecoder = typeof TextDecoder === "undefined" ? (0, module.require)("util").TextDecoder : TextDecoder;
|
|
17783
|
-
var cachedTextDecoder = new lTextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
17784
|
-
cachedTextDecoder.decode();
|
|
17785
|
-
var cachedUint8ArrayMemory0 = null;
|
|
17786
|
-
function getUint8ArrayMemory0() {
|
|
17787
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
17788
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
17789
|
-
}
|
|
17790
|
-
return cachedUint8ArrayMemory0;
|
|
17791
|
-
}
|
|
17792
|
-
function getStringFromWasm0(ptr, len) {
|
|
17793
|
-
ptr = ptr >>> 0;
|
|
17794
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
17795
|
-
}
|
|
17796
|
-
var heap = new Array(128).fill(undefined);
|
|
17797
|
-
heap.push(undefined, null, true, false);
|
|
17798
|
-
var heap_next = heap.length;
|
|
17799
|
-
function addHeapObject(obj) {
|
|
17800
|
-
if (heap_next === heap.length)
|
|
17801
|
-
heap.push(heap.length + 1);
|
|
17802
|
-
const idx = heap_next;
|
|
17803
|
-
heap_next = heap[idx];
|
|
17804
|
-
heap[idx] = obj;
|
|
17805
|
-
return idx;
|
|
17806
|
-
}
|
|
17807
|
-
function handleError(f, args) {
|
|
17808
|
-
try {
|
|
17809
|
-
return f.apply(this, args);
|
|
17810
|
-
} catch (e) {
|
|
17811
|
-
wasm.__wbindgen_export_0(addHeapObject(e));
|
|
17812
|
-
}
|
|
17813
|
-
}
|
|
17814
|
-
function getObject(idx) {
|
|
17815
|
-
return heap[idx];
|
|
17816
|
-
}
|
|
17817
|
-
function dropObject(idx) {
|
|
17818
|
-
if (idx < 132)
|
|
17819
|
-
return;
|
|
17820
|
-
heap[idx] = heap_next;
|
|
17821
|
-
heap_next = idx;
|
|
17822
|
-
}
|
|
17823
|
-
function takeObject(idx) {
|
|
17824
|
-
const ret = getObject(idx);
|
|
17825
|
-
dropObject(idx);
|
|
17826
|
-
return ret;
|
|
17827
|
-
}
|
|
17828
|
-
var WASM_VECTOR_LEN = 0;
|
|
17829
|
-
var lTextEncoder = typeof TextEncoder === "undefined" ? (0, module.require)("util").TextEncoder : TextEncoder;
|
|
17830
|
-
var cachedTextEncoder = new lTextEncoder("utf-8");
|
|
17831
|
-
var encodeString = typeof cachedTextEncoder.encodeInto === "function" ? function(arg, view) {
|
|
17832
|
-
return cachedTextEncoder.encodeInto(arg, view);
|
|
17833
|
-
} : function(arg, view) {
|
|
17834
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
17835
|
-
view.set(buf);
|
|
17836
|
-
return {
|
|
17837
|
-
read: arg.length,
|
|
17838
|
-
written: buf.length
|
|
17839
|
-
};
|
|
17840
|
-
};
|
|
17841
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
17842
|
-
if (realloc === undefined) {
|
|
17843
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
17844
|
-
const ptr2 = malloc(buf.length, 1) >>> 0;
|
|
17845
|
-
getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
|
|
17846
|
-
WASM_VECTOR_LEN = buf.length;
|
|
17847
|
-
return ptr2;
|
|
17848
|
-
}
|
|
17849
|
-
let len = arg.length;
|
|
17850
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
17851
|
-
const mem = getUint8ArrayMemory0();
|
|
17852
|
-
let offset = 0;
|
|
17853
|
-
for (;offset < len; offset++) {
|
|
17854
|
-
const code = arg.charCodeAt(offset);
|
|
17855
|
-
if (code > 127)
|
|
17856
|
-
break;
|
|
17857
|
-
mem[ptr + offset] = code;
|
|
17858
|
-
}
|
|
17859
|
-
if (offset !== len) {
|
|
17860
|
-
if (offset !== 0) {
|
|
17861
|
-
arg = arg.slice(offset);
|
|
17862
|
-
}
|
|
17863
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
17864
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
17865
|
-
const ret = encodeString(arg, view);
|
|
17866
|
-
offset += ret.written;
|
|
17867
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
17868
|
-
}
|
|
17869
|
-
WASM_VECTOR_LEN = offset;
|
|
17870
|
-
return ptr;
|
|
17871
|
-
}
|
|
17872
|
-
function isLikeNone(x) {
|
|
17873
|
-
return x === undefined || x === null;
|
|
17874
|
-
}
|
|
17875
|
-
var cachedDataViewMemory0 = null;
|
|
17876
|
-
function getDataViewMemory0() {
|
|
17877
|
-
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
|
|
17878
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
17879
|
-
}
|
|
17880
|
-
return cachedDataViewMemory0;
|
|
17881
|
-
}
|
|
17882
|
-
var cachedUint32ArrayMemory0 = null;
|
|
17883
|
-
function getUint32ArrayMemory0() {
|
|
17884
|
-
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
17885
|
-
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
17886
|
-
}
|
|
17887
|
-
return cachedUint32ArrayMemory0;
|
|
17888
|
-
}
|
|
17889
|
-
function getArrayU32FromWasm0(ptr, len) {
|
|
17890
|
-
ptr = ptr >>> 0;
|
|
17891
|
-
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
17892
|
-
}
|
|
17893
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
17894
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
17895
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
17896
|
-
WASM_VECTOR_LEN = arg.length;
|
|
17897
|
-
return ptr;
|
|
17898
|
-
}
|
|
17899
|
-
function passArray32ToWasm0(arg, malloc) {
|
|
17900
|
-
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
17901
|
-
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
17902
|
-
WASM_VECTOR_LEN = arg.length;
|
|
17903
|
-
return ptr;
|
|
17904
|
-
}
|
|
17905
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
17906
|
-
ptr = ptr >>> 0;
|
|
17907
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
17908
|
-
}
|
|
17909
|
-
exports.get_encoding = function(encoding, extend_special_tokens) {
|
|
17910
|
-
if (wasm == null)
|
|
17911
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
17912
|
-
try {
|
|
17913
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
17914
|
-
const ptr0 = passStringToWasm0(encoding, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
17915
|
-
const len0 = WASM_VECTOR_LEN;
|
|
17916
|
-
wasm.get_encoding(retptr, ptr0, len0, addHeapObject(extend_special_tokens));
|
|
17917
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
17918
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
17919
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
17920
|
-
if (r2) {
|
|
17921
|
-
throw takeObject(r1);
|
|
17922
|
-
}
|
|
17923
|
-
return Tiktoken.__wrap(r0);
|
|
17924
|
-
} finally {
|
|
17925
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
17926
|
-
}
|
|
17927
|
-
};
|
|
17928
|
-
exports.encoding_for_model = function(model, extend_special_tokens) {
|
|
17929
|
-
if (wasm == null)
|
|
17930
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
17931
|
-
try {
|
|
17932
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
17933
|
-
const ptr0 = passStringToWasm0(model, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
17934
|
-
const len0 = WASM_VECTOR_LEN;
|
|
17935
|
-
wasm.encoding_for_model(retptr, ptr0, len0, addHeapObject(extend_special_tokens));
|
|
17936
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
17937
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
17938
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
17939
|
-
if (r2) {
|
|
17940
|
-
throw takeObject(r1);
|
|
17941
|
-
}
|
|
17942
|
-
return Tiktoken.__wrap(r0);
|
|
17943
|
-
} finally {
|
|
17944
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
17945
|
-
}
|
|
17946
|
-
};
|
|
17947
|
-
exports.get_encoding_name_for_model = function(model) {
|
|
17948
|
-
if (wasm == null)
|
|
17949
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
17950
|
-
let deferred3_0;
|
|
17951
|
-
let deferred3_1;
|
|
17952
|
-
try {
|
|
17953
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
17954
|
-
const ptr0 = passStringToWasm0(model, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
17955
|
-
const len0 = WASM_VECTOR_LEN;
|
|
17956
|
-
wasm.get_encoding_name_for_model(retptr, ptr0, len0);
|
|
17957
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
17958
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
17959
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
17960
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
17961
|
-
var ptr2 = r0;
|
|
17962
|
-
var len2 = r1;
|
|
17963
|
-
if (r3) {
|
|
17964
|
-
ptr2 = 0;
|
|
17965
|
-
len2 = 0;
|
|
17966
|
-
throw takeObject(r2);
|
|
17967
|
-
}
|
|
17968
|
-
deferred3_0 = ptr2;
|
|
17969
|
-
deferred3_1 = len2;
|
|
17970
|
-
return getStringFromWasm0(ptr2, len2);
|
|
17971
|
-
} finally {
|
|
17972
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
17973
|
-
wasm.__wbindgen_export_3(deferred3_0, deferred3_1, 1);
|
|
17974
|
-
}
|
|
17975
|
-
};
|
|
17976
|
-
var TiktokenFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((ptr) => wasm.__wbg_tiktoken_free(ptr >>> 0, 1));
|
|
17977
|
-
|
|
17978
|
-
class Tiktoken {
|
|
17979
|
-
constructor(tiktoken_bfe, special_tokens, pat_str) {
|
|
17980
|
-
if (wasm == null)
|
|
17981
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
17982
|
-
const ptr0 = passStringToWasm0(tiktoken_bfe, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
17983
|
-
const len0 = WASM_VECTOR_LEN;
|
|
17984
|
-
const ptr1 = passStringToWasm0(pat_str, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
17985
|
-
const len1 = WASM_VECTOR_LEN;
|
|
17986
|
-
const ret = wasm.tiktoken_new(ptr0, len0, addHeapObject(special_tokens), ptr1, len1);
|
|
17987
|
-
this.__wbg_ptr = ret >>> 0;
|
|
17988
|
-
TiktokenFinalization.register(this, this.__wbg_ptr, this);
|
|
17989
|
-
return this;
|
|
17990
|
-
}
|
|
17991
|
-
get name() {
|
|
17992
|
-
try {
|
|
17993
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
17994
|
-
wasm.tiktoken_name(retptr, this.__wbg_ptr);
|
|
17995
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
17996
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
17997
|
-
let v1;
|
|
17998
|
-
if (r0 !== 0) {
|
|
17999
|
-
v1 = getStringFromWasm0(r0, r1).slice();
|
|
18000
|
-
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
18001
|
-
}
|
|
18002
|
-
return v1;
|
|
18003
|
-
} finally {
|
|
18004
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
18005
|
-
}
|
|
18006
|
-
}
|
|
18007
|
-
static __wrap(ptr) {
|
|
18008
|
-
ptr = ptr >>> 0;
|
|
18009
|
-
const obj = Object.create(Tiktoken.prototype);
|
|
18010
|
-
obj.__wbg_ptr = ptr;
|
|
18011
|
-
TiktokenFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
18012
|
-
return obj;
|
|
18013
|
-
}
|
|
18014
|
-
__destroy_into_raw() {
|
|
18015
|
-
const ptr = this.__wbg_ptr;
|
|
18016
|
-
this.__wbg_ptr = 0;
|
|
18017
|
-
TiktokenFinalization.unregister(this);
|
|
18018
|
-
return ptr;
|
|
18019
|
-
}
|
|
18020
|
-
free() {
|
|
18021
|
-
if (wasm == null)
|
|
18022
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
18023
|
-
const ptr = this.__destroy_into_raw();
|
|
18024
|
-
wasm.__wbg_tiktoken_free(ptr, 0);
|
|
18025
|
-
}
|
|
18026
|
-
encode(text, allowed_special, disallowed_special) {
|
|
18027
|
-
if (wasm == null)
|
|
18028
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
18029
|
-
try {
|
|
18030
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
18031
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
18032
|
-
const len0 = WASM_VECTOR_LEN;
|
|
18033
|
-
wasm.tiktoken_encode(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(allowed_special), addHeapObject(disallowed_special));
|
|
18034
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
18035
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
18036
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
18037
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
18038
|
-
if (r3) {
|
|
18039
|
-
throw takeObject(r2);
|
|
18040
|
-
}
|
|
18041
|
-
var v2 = getArrayU32FromWasm0(r0, r1).slice();
|
|
18042
|
-
wasm.__wbindgen_export_3(r0, r1 * 4, 4);
|
|
18043
|
-
return v2;
|
|
18044
|
-
} finally {
|
|
18045
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
18046
|
-
}
|
|
18047
|
-
}
|
|
18048
|
-
encode_ordinary(text) {
|
|
18049
|
-
if (wasm == null)
|
|
18050
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
18051
|
-
try {
|
|
18052
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
18053
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
18054
|
-
const len0 = WASM_VECTOR_LEN;
|
|
18055
|
-
wasm.tiktoken_encode_ordinary(retptr, this.__wbg_ptr, ptr0, len0);
|
|
18056
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
18057
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
18058
|
-
var v2 = getArrayU32FromWasm0(r0, r1).slice();
|
|
18059
|
-
wasm.__wbindgen_export_3(r0, r1 * 4, 4);
|
|
18060
|
-
return v2;
|
|
18061
|
-
} finally {
|
|
18062
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
18063
|
-
}
|
|
18064
|
-
}
|
|
18065
|
-
encode_with_unstable(text, allowed_special, disallowed_special) {
|
|
18066
|
-
if (wasm == null)
|
|
18067
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
18068
|
-
try {
|
|
18069
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
18070
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
18071
|
-
const len0 = WASM_VECTOR_LEN;
|
|
18072
|
-
wasm.tiktoken_encode_with_unstable(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(allowed_special), addHeapObject(disallowed_special));
|
|
18073
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
18074
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
18075
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
18076
|
-
if (r2) {
|
|
18077
|
-
throw takeObject(r1);
|
|
18078
|
-
}
|
|
18079
|
-
return takeObject(r0);
|
|
18080
|
-
} finally {
|
|
18081
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
18082
|
-
}
|
|
18083
|
-
}
|
|
18084
|
-
encode_single_token(bytes) {
|
|
18085
|
-
if (wasm == null)
|
|
18086
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
18087
|
-
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_1);
|
|
18088
|
-
const len0 = WASM_VECTOR_LEN;
|
|
18089
|
-
const ret = wasm.tiktoken_encode_single_token(this.__wbg_ptr, ptr0, len0);
|
|
18090
|
-
return ret >>> 0;
|
|
18091
|
-
}
|
|
18092
|
-
decode(tokens) {
|
|
18093
|
-
if (wasm == null)
|
|
18094
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
18095
|
-
try {
|
|
18096
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
18097
|
-
const ptr0 = passArray32ToWasm0(tokens, wasm.__wbindgen_export_1);
|
|
18098
|
-
const len0 = WASM_VECTOR_LEN;
|
|
18099
|
-
wasm.tiktoken_decode(retptr, this.__wbg_ptr, ptr0, len0);
|
|
18100
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
18101
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
18102
|
-
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
18103
|
-
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
18104
|
-
return v2;
|
|
18105
|
-
} finally {
|
|
18106
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
18107
|
-
}
|
|
18108
|
-
}
|
|
18109
|
-
decode_single_token_bytes(token) {
|
|
18110
|
-
if (wasm == null)
|
|
18111
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
18112
|
-
try {
|
|
18113
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
18114
|
-
wasm.tiktoken_decode_single_token_bytes(retptr, this.__wbg_ptr, token);
|
|
18115
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
18116
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
18117
|
-
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
18118
|
-
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
18119
|
-
return v1;
|
|
18120
|
-
} finally {
|
|
18121
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
18122
|
-
}
|
|
18123
|
-
}
|
|
18124
|
-
token_byte_values() {
|
|
18125
|
-
if (wasm == null)
|
|
18126
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
18127
|
-
const ret = wasm.tiktoken_token_byte_values(this.__wbg_ptr);
|
|
18128
|
-
return takeObject(ret);
|
|
18129
|
-
}
|
|
18130
|
-
}
|
|
18131
|
-
exports.Tiktoken = Tiktoken;
|
|
18132
|
-
exports.__wbg_parse_def2e24ef1252aff = function() {
|
|
18133
|
-
return handleError(function(arg0, arg1) {
|
|
18134
|
-
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
18135
|
-
return addHeapObject(ret);
|
|
18136
|
-
}, arguments);
|
|
18137
|
-
};
|
|
18138
|
-
exports.__wbg_stringify_f7ed6987935b4a24 = function() {
|
|
18139
|
-
return handleError(function(arg0) {
|
|
18140
|
-
const ret = JSON.stringify(getObject(arg0));
|
|
18141
|
-
return addHeapObject(ret);
|
|
18142
|
-
}, arguments);
|
|
18143
|
-
};
|
|
18144
|
-
exports.__wbindgen_error_new = function(arg0, arg1) {
|
|
18145
|
-
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
18146
|
-
return addHeapObject(ret);
|
|
18147
|
-
};
|
|
18148
|
-
exports.__wbindgen_is_undefined = function(arg0) {
|
|
18149
|
-
const ret = getObject(arg0) === undefined;
|
|
18150
|
-
return ret;
|
|
18151
|
-
};
|
|
18152
|
-
exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
18153
|
-
takeObject(arg0);
|
|
18154
|
-
};
|
|
18155
|
-
exports.__wbindgen_string_get = function(arg0, arg1) {
|
|
18156
|
-
if (wasm == null)
|
|
18157
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
18158
|
-
const obj = getObject(arg1);
|
|
18159
|
-
const ret = typeof obj === "string" ? obj : undefined;
|
|
18160
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
18161
|
-
var len1 = WASM_VECTOR_LEN;
|
|
18162
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
18163
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
18164
|
-
};
|
|
18165
|
-
exports.__wbindgen_throw = function(arg0, arg1) {
|
|
18166
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
18167
|
-
};
|
|
18168
|
-
});
|
|
18169
|
-
|
|
18170
|
-
// node_modules/.pnpm/tiktoken@1.0.22/node_modules/tiktoken/tiktoken.cjs
|
|
18171
|
-
var require_tiktoken = __commonJS((exports) => {
|
|
18172
|
-
var __dirname = "/Users/hasna/Workspace/dev/hasna/opensource/opensourcedev/opensource-oldpal/node_modules/.pnpm/tiktoken@1.0.22/node_modules/tiktoken";
|
|
18173
|
-
var wasm = require_tiktoken_bg();
|
|
18174
|
-
var imports = {};
|
|
18175
|
-
imports["./tiktoken_bg.js"] = wasm;
|
|
18176
|
-
var path = __require("path");
|
|
18177
|
-
var fs2 = __require("fs");
|
|
18178
|
-
var candidates = __dirname.split(path.sep).reduce((memo, _, index, array) => {
|
|
18179
|
-
const prefix = array.slice(0, index + 1).join(path.sep) + path.sep;
|
|
18180
|
-
if (!prefix.includes("node_modules" + path.sep)) {
|
|
18181
|
-
memo.unshift(path.join(prefix, "node_modules", "tiktoken", "", "./tiktoken_bg.wasm"));
|
|
18182
|
-
}
|
|
18183
|
-
return memo;
|
|
18184
|
-
}, []);
|
|
18185
|
-
candidates.unshift(path.join(__dirname, "./tiktoken_bg.wasm"));
|
|
18186
|
-
var bytes = null;
|
|
18187
|
-
for (const candidate of candidates) {
|
|
18188
|
-
try {
|
|
18189
|
-
bytes = fs2.readFileSync(candidate);
|
|
18190
|
-
break;
|
|
18191
|
-
} catch {}
|
|
18192
|
-
}
|
|
18193
|
-
if (bytes == null)
|
|
18194
|
-
throw new Error("Missing tiktoken_bg.wasm");
|
|
18195
|
-
var wasmModule = new WebAssembly.Module(bytes);
|
|
18196
|
-
var wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
|
18197
|
-
wasm.__wbg_set_wasm(wasmInstance.exports);
|
|
18198
|
-
exports.get_encoding = wasm["get_encoding"];
|
|
18199
|
-
exports.encoding_for_model = wasm["encoding_for_model"];
|
|
18200
|
-
exports.get_encoding_name_for_model = wasm["get_encoding_name_for_model"];
|
|
18201
|
-
exports.Tiktoken = wasm["Tiktoken"];
|
|
18202
|
-
});
|
|
18203
|
-
|
|
18204
17776
|
// packages/core/src/errors/codes.ts
|
|
18205
17777
|
var ErrorCodes;
|
|
18206
17778
|
var init_codes = __esm(() => {
|
|
@@ -37166,45 +36738,18 @@ init_src();
|
|
|
37166
36738
|
// packages/core/src/context/token-counter.ts
|
|
37167
36739
|
var MESSAGE_OVERHEAD_TOKENS = 4;
|
|
37168
36740
|
var CHARS_PER_TOKEN = 4;
|
|
37169
|
-
var tiktokenEncoder = null;
|
|
37170
|
-
var tiktokenLoadAttempted = false;
|
|
37171
|
-
function loadTiktoken() {
|
|
37172
|
-
if (tiktokenLoadAttempted)
|
|
37173
|
-
return tiktokenEncoder;
|
|
37174
|
-
tiktokenLoadAttempted = true;
|
|
37175
|
-
try {
|
|
37176
|
-
const tiktoken = require_tiktoken();
|
|
37177
|
-
try {
|
|
37178
|
-
tiktokenEncoder = tiktoken.encoding_for_model("gpt-4");
|
|
37179
|
-
} catch {
|
|
37180
|
-
tiktokenEncoder = tiktoken.get_encoding("cl100k_base");
|
|
37181
|
-
}
|
|
37182
|
-
} catch (error) {
|
|
37183
|
-
console.warn("Token counting using estimation (tiktoken unavailable)");
|
|
37184
|
-
tiktokenEncoder = null;
|
|
37185
|
-
}
|
|
37186
|
-
return tiktokenEncoder;
|
|
37187
|
-
}
|
|
37188
36741
|
|
|
37189
36742
|
class TokenCounter {
|
|
37190
36743
|
cache = new Map;
|
|
37191
36744
|
maxCacheEntries = 1e4;
|
|
37192
|
-
constructor(_model) {
|
|
37193
|
-
loadTiktoken();
|
|
37194
|
-
}
|
|
36745
|
+
constructor(_model) {}
|
|
37195
36746
|
count(text) {
|
|
37196
36747
|
if (!text)
|
|
37197
36748
|
return 0;
|
|
37198
36749
|
const cached = this.cache.get(text);
|
|
37199
36750
|
if (cached !== undefined)
|
|
37200
36751
|
return cached;
|
|
37201
|
-
|
|
37202
|
-
const encoder = loadTiktoken();
|
|
37203
|
-
if (encoder) {
|
|
37204
|
-
tokens = encoder.encode(text).length;
|
|
37205
|
-
} else {
|
|
37206
|
-
tokens = Math.ceil(text.length / CHARS_PER_TOKEN);
|
|
37207
|
-
}
|
|
36752
|
+
const tokens = Math.ceil(text.length / CHARS_PER_TOKEN);
|
|
37208
36753
|
if (text.length < 1e4) {
|
|
37209
36754
|
this.cache.set(text, tokens);
|
|
37210
36755
|
if (this.cache.size > this.maxCacheEntries) {
|
|
@@ -38163,7 +37708,7 @@ function isErrorResult(result) {
|
|
|
38163
37708
|
// packages/core/src/tools/connector.ts
|
|
38164
37709
|
init_errors();
|
|
38165
37710
|
import { homedir as homedir2 } from "os";
|
|
38166
|
-
import { join as join3, delimiter } from "path";
|
|
37711
|
+
import { join as join3, delimiter, dirname as dirname2 } from "path";
|
|
38167
37712
|
import { readdirSync, statSync, existsSync as existsSync2, mkdirSync, writeFileSync, readFileSync as readFileSync2 } from "fs";
|
|
38168
37713
|
function resolveTimeout(resolve) {
|
|
38169
37714
|
resolve({ exitCode: 1 });
|
|
@@ -38210,7 +37755,7 @@ class ConnectorBridge {
|
|
|
38210
37755
|
static saveDiskCache() {
|
|
38211
37756
|
try {
|
|
38212
37757
|
const cachePath = ConnectorBridge.getCachePath();
|
|
38213
|
-
const cacheDir =
|
|
37758
|
+
const cacheDir = dirname2(cachePath);
|
|
38214
37759
|
if (!existsSync2(cacheDir)) {
|
|
38215
37760
|
mkdirSync(cacheDir, { recursive: true });
|
|
38216
37761
|
}
|
|
@@ -38261,6 +37806,7 @@ class ConnectorBridge {
|
|
|
38261
37806
|
return Array.from(connectorNames);
|
|
38262
37807
|
}
|
|
38263
37808
|
fastDiscover(connectorNames) {
|
|
37809
|
+
this.connectors.clear();
|
|
38264
37810
|
if (ConnectorBridge.cache.size > 0) {
|
|
38265
37811
|
const connectors2 = [];
|
|
38266
37812
|
const allowList2 = connectorNames && connectorNames.length > 0 ? new Set(connectorNames) : null;
|
|
@@ -38321,13 +37867,15 @@ class ConnectorBridge {
|
|
|
38321
37867
|
ConnectorBridge.saveDiskCache();
|
|
38322
37868
|
}
|
|
38323
37869
|
const discovered = [];
|
|
37870
|
+
const nextConnectors = new Map;
|
|
38324
37871
|
for (const name of names) {
|
|
38325
37872
|
const connector = ConnectorBridge.cache.get(name);
|
|
38326
37873
|
if (connector) {
|
|
38327
37874
|
discovered.push(connector);
|
|
38328
|
-
|
|
37875
|
+
nextConnectors.set(connector.name, connector);
|
|
38329
37876
|
}
|
|
38330
37877
|
}
|
|
37878
|
+
this.connectors = nextConnectors;
|
|
38331
37879
|
return discovered;
|
|
38332
37880
|
}
|
|
38333
37881
|
createMinimalConnector(name, cli) {
|
|
@@ -38906,7 +38454,7 @@ ${stderr || stdout}`.trim(), {
|
|
|
38906
38454
|
}
|
|
38907
38455
|
|
|
38908
38456
|
// packages/core/src/tools/filesystem.ts
|
|
38909
|
-
import { join as join4, resolve as resolve3, dirname as
|
|
38457
|
+
import { join as join4, resolve as resolve3, dirname as dirname3, sep } from "path";
|
|
38910
38458
|
init_errors();
|
|
38911
38459
|
var {Glob } = globalThis.Bun;
|
|
38912
38460
|
|
|
@@ -39211,7 +38759,7 @@ class FilesystemTools {
|
|
|
39211
38759
|
retryable: false
|
|
39212
38760
|
});
|
|
39213
38761
|
}
|
|
39214
|
-
const dir =
|
|
38762
|
+
const dir = dirname3(validated.resolved);
|
|
39215
38763
|
await Bun.$`mkdir -p ${dir}`.quiet();
|
|
39216
38764
|
await Bun.write(validated.resolved, content);
|
|
39217
38765
|
return `Successfully wrote ${content.length} characters to ${validated.resolved}`;
|
|
@@ -40795,7 +40343,7 @@ Respond with ALLOW or DENY on the first line, followed by a short reason.`,
|
|
|
40795
40343
|
|
|
40796
40344
|
// packages/core/src/skills/loader.ts
|
|
40797
40345
|
init_src();
|
|
40798
|
-
import { join as join8, basename, dirname as
|
|
40346
|
+
import { join as join8, basename, dirname as dirname4 } from "path";
|
|
40799
40347
|
import { homedir as homedir5 } from "os";
|
|
40800
40348
|
var {Glob: Glob2 } = globalThis.Bun;
|
|
40801
40349
|
|
|
@@ -40846,7 +40394,7 @@ class SkillLoader {
|
|
|
40846
40394
|
try {
|
|
40847
40395
|
const content = await Bun.file(filePath).text();
|
|
40848
40396
|
const { frontmatter, content: markdownContent } = parseFrontmatter(content);
|
|
40849
|
-
const dirName = basename(
|
|
40397
|
+
const dirName = basename(dirname4(filePath));
|
|
40850
40398
|
const name = frontmatter.name || dirName;
|
|
40851
40399
|
let description = frontmatter.description || "";
|
|
40852
40400
|
if (!description && markdownContent) {
|
|
@@ -40933,7 +40481,7 @@ class SkillLoader {
|
|
|
40933
40481
|
|
|
40934
40482
|
// packages/core/src/skills/executor.ts
|
|
40935
40483
|
init_src();
|
|
40936
|
-
import { dirname as
|
|
40484
|
+
import { dirname as dirname5 } from "path";
|
|
40937
40485
|
|
|
40938
40486
|
class SkillExecutor {
|
|
40939
40487
|
constructor() {}
|
|
@@ -40954,7 +40502,7 @@ ARGUMENTS: ${args.join(" ")}`;
|
|
|
40954
40502
|
if (matches.length === 0) {
|
|
40955
40503
|
return content;
|
|
40956
40504
|
}
|
|
40957
|
-
const skillDir =
|
|
40505
|
+
const skillDir = dirname5(skillFilePath);
|
|
40958
40506
|
let result = content;
|
|
40959
40507
|
for (const match of matches) {
|
|
40960
40508
|
const fullMatch = match[0];
|
|
@@ -42227,14 +41775,24 @@ function splitArgs(input) {
|
|
|
42227
41775
|
const args = [];
|
|
42228
41776
|
let current = "";
|
|
42229
41777
|
let quote = null;
|
|
41778
|
+
let escaped = false;
|
|
42230
41779
|
for (let i = 0;i < input.length; i += 1) {
|
|
42231
41780
|
const char = input[i];
|
|
42232
41781
|
if (quote) {
|
|
41782
|
+
if (escaped) {
|
|
41783
|
+
current += char;
|
|
41784
|
+
escaped = false;
|
|
41785
|
+
continue;
|
|
41786
|
+
}
|
|
41787
|
+
if (char === "\\") {
|
|
41788
|
+
escaped = true;
|
|
41789
|
+
continue;
|
|
41790
|
+
}
|
|
42233
41791
|
if (char === quote) {
|
|
42234
41792
|
quote = null;
|
|
42235
|
-
|
|
42236
|
-
current += char;
|
|
41793
|
+
continue;
|
|
42237
41794
|
}
|
|
41795
|
+
current += char;
|
|
42238
41796
|
continue;
|
|
42239
41797
|
}
|
|
42240
41798
|
if (char === '"' || char === "'") {
|
|
@@ -42254,6 +41812,9 @@ function splitArgs(input) {
|
|
|
42254
41812
|
args.push(current);
|
|
42255
41813
|
return args;
|
|
42256
41814
|
}
|
|
41815
|
+
function singleLine(value) {
|
|
41816
|
+
return value.replace(/[\r\n]+/g, " ").replace(/\s+/g, " ").trim();
|
|
41817
|
+
}
|
|
42257
41818
|
|
|
42258
41819
|
class BuiltinCommands {
|
|
42259
41820
|
tokenUsage = {
|
|
@@ -42976,7 +42537,8 @@ Suggestions:
|
|
|
42976
42537
|
content: "",
|
|
42977
42538
|
handler: async (args, context) => {
|
|
42978
42539
|
const usage = this.tokenUsage;
|
|
42979
|
-
const
|
|
42540
|
+
const rawPercent = usage.maxContextTokens > 0 ? Math.round(usage.totalTokens / usage.maxContextTokens * 100) : 0;
|
|
42541
|
+
const usedPercent = Math.max(0, Math.min(100, rawPercent));
|
|
42980
42542
|
let message = `
|
|
42981
42543
|
**Token Usage**
|
|
42982
42544
|
|
|
@@ -42988,8 +42550,8 @@ Suggestions:
|
|
|
42988
42550
|
message += `Total: ${usage.totalTokens.toLocaleString()} / ${usage.maxContextTokens.toLocaleString()} (${usedPercent}%)
|
|
42989
42551
|
`;
|
|
42990
42552
|
const barLength = 30;
|
|
42991
|
-
const filledLength = Math.round(usedPercent / 100 * barLength);
|
|
42992
|
-
const bar = "\u2588".repeat(filledLength) + "\u2591".repeat(barLength - filledLength);
|
|
42553
|
+
const filledLength = Math.max(0, Math.min(barLength, Math.round(usedPercent / 100 * barLength)));
|
|
42554
|
+
const bar = "\u2588".repeat(filledLength) + "\u2591".repeat(Math.max(0, barLength - filledLength));
|
|
42993
42555
|
message += `
|
|
42994
42556
|
[${bar}] ${usedPercent}%
|
|
42995
42557
|
`;
|
|
@@ -43039,7 +42601,8 @@ Context summarization is not available.
|
|
|
43039
42601
|
return { handled: true };
|
|
43040
42602
|
}
|
|
43041
42603
|
const { config, state } = info;
|
|
43042
|
-
const
|
|
42604
|
+
const rawPercent = config.maxContextTokens > 0 ? Math.round(state.totalTokens / config.maxContextTokens * 100) : 0;
|
|
42605
|
+
const usedPercent = Math.max(0, Math.min(100, rawPercent));
|
|
43043
42606
|
let message = `
|
|
43044
42607
|
**Context Status**
|
|
43045
42608
|
|
|
@@ -43063,8 +42626,8 @@ Context summarization is not available.
|
|
|
43063
42626
|
}
|
|
43064
42627
|
}
|
|
43065
42628
|
const barLength = 30;
|
|
43066
|
-
const filledLength = Math.round(usedPercent / 100 * barLength);
|
|
43067
|
-
const bar = "\u2588".repeat(filledLength) + "\u2591".repeat(barLength - filledLength);
|
|
42629
|
+
const filledLength = Math.max(0, Math.min(barLength, Math.round(usedPercent / 100 * barLength)));
|
|
42630
|
+
const bar = "\u2588".repeat(filledLength) + "\u2591".repeat(Math.max(0, barLength - filledLength));
|
|
43068
42631
|
message += `
|
|
43069
42632
|
[${bar}] ${usedPercent}%
|
|
43070
42633
|
`;
|
|
@@ -43088,12 +42651,12 @@ No context entries for project "${project.name}".
|
|
|
43088
42651
|
return { handled: true };
|
|
43089
42652
|
}
|
|
43090
42653
|
let output = `
|
|
43091
|
-
**Context Entries (${project.name})**
|
|
42654
|
+
**Context Entries (${singleLine(project.name)})**
|
|
43092
42655
|
|
|
43093
42656
|
`;
|
|
43094
42657
|
for (const entry of project.context) {
|
|
43095
|
-
const label = entry.label ? ` (${entry.label})` : "";
|
|
43096
|
-
output += `- ${entry.id} [${entry.type}] ${entry.value}${label}
|
|
42658
|
+
const label = entry.label ? ` (${singleLine(entry.label)})` : "";
|
|
42659
|
+
output += `- ${entry.id} [${entry.type}] ${singleLine(entry.value)}${label}
|
|
43097
42660
|
`;
|
|
43098
42661
|
}
|
|
43099
42662
|
context.emit("text", output);
|
|
@@ -43240,7 +42803,7 @@ No projects found. Use /projects new <name>.
|
|
|
43240
42803
|
`;
|
|
43241
42804
|
for (const project of projects) {
|
|
43242
42805
|
const marker = project.id === activeId ? "*" : " ";
|
|
43243
|
-
output += `${marker} ${project.name} (${project.id})
|
|
42806
|
+
output += `${marker} ${singleLine(project.name)} (${project.id})
|
|
43244
42807
|
`;
|
|
43245
42808
|
}
|
|
43246
42809
|
context.emit("text", output);
|
|
@@ -43302,13 +42865,13 @@ No projects found. Use /projects new <name>.
|
|
|
43302
42865
|
return { handled: true };
|
|
43303
42866
|
}
|
|
43304
42867
|
let output = `
|
|
43305
|
-
**Project: ${project.name}**
|
|
42868
|
+
**Project: ${singleLine(project.name)}**
|
|
43306
42869
|
|
|
43307
42870
|
`;
|
|
43308
42871
|
output += `ID: ${project.id}
|
|
43309
42872
|
`;
|
|
43310
42873
|
if (project.description) {
|
|
43311
|
-
output += `Description: ${project.description}
|
|
42874
|
+
output += `Description: ${singleLine(project.description)}
|
|
43312
42875
|
`;
|
|
43313
42876
|
}
|
|
43314
42877
|
output += `Context entries: ${project.context.length}
|
|
@@ -43434,11 +42997,11 @@ No plans for project "${project.name}".
|
|
|
43434
42997
|
return { handled: true };
|
|
43435
42998
|
}
|
|
43436
42999
|
let output = `
|
|
43437
|
-
**Plans (${project.name})**
|
|
43000
|
+
**Plans (${singleLine(project.name)})**
|
|
43438
43001
|
|
|
43439
43002
|
`;
|
|
43440
43003
|
for (const plan of project.plans) {
|
|
43441
|
-
output += `- ${plan.id} ${plan.title} (${plan.steps.length} steps)
|
|
43004
|
+
output += `- ${plan.id} ${singleLine(plan.title)} (${plan.steps.length} steps)
|
|
43442
43005
|
`;
|
|
43443
43006
|
}
|
|
43444
43007
|
context.emit("text", output);
|
|
@@ -43473,6 +43036,10 @@ No plans for project "${project.name}".
|
|
|
43473
43036
|
context.emit("done");
|
|
43474
43037
|
return { handled: true };
|
|
43475
43038
|
}
|
|
43039
|
+
context.emit("text", `Failed to create plan "${plan.title}".
|
|
43040
|
+
`);
|
|
43041
|
+
context.emit("done");
|
|
43042
|
+
return { handled: true };
|
|
43476
43043
|
}
|
|
43477
43044
|
if (sub === "show") {
|
|
43478
43045
|
const id = parts[1];
|
|
@@ -43490,7 +43057,7 @@ No plans for project "${project.name}".
|
|
|
43490
43057
|
return { handled: true };
|
|
43491
43058
|
}
|
|
43492
43059
|
let output = `
|
|
43493
|
-
**Plan: ${plan.title}**
|
|
43060
|
+
**Plan: ${singleLine(plan.title)}**
|
|
43494
43061
|
|
|
43495
43062
|
`;
|
|
43496
43063
|
output += `ID: ${plan.id}
|
|
@@ -43500,7 +43067,7 @@ No plans for project "${project.name}".
|
|
|
43500
43067
|
`;
|
|
43501
43068
|
} else {
|
|
43502
43069
|
for (const step of plan.steps) {
|
|
43503
|
-
output += `- ${step.id} [${step.status}] ${step.text}
|
|
43070
|
+
output += `- ${step.id} [${step.status}] ${singleLine(step.text)}
|
|
43504
43071
|
`;
|
|
43505
43072
|
}
|
|
43506
43073
|
}
|
|
@@ -43543,6 +43110,10 @@ No plans for project "${project.name}".
|
|
|
43543
43110
|
context.emit("done");
|
|
43544
43111
|
return { handled: true };
|
|
43545
43112
|
}
|
|
43113
|
+
context.emit("text", `Failed to add step to plan ${planId}.
|
|
43114
|
+
`);
|
|
43115
|
+
context.emit("done");
|
|
43116
|
+
return { handled: true };
|
|
43546
43117
|
}
|
|
43547
43118
|
if (sub === "set") {
|
|
43548
43119
|
const planId = parts[1];
|
|
@@ -43591,6 +43162,10 @@ No plans for project "${project.name}".
|
|
|
43591
43162
|
context.emit("done");
|
|
43592
43163
|
return { handled: true };
|
|
43593
43164
|
}
|
|
43165
|
+
context.emit("text", `Failed to update step ${stepId}.
|
|
43166
|
+
`);
|
|
43167
|
+
context.emit("done");
|
|
43168
|
+
return { handled: true };
|
|
43594
43169
|
}
|
|
43595
43170
|
if (sub === "remove") {
|
|
43596
43171
|
const planId = parts[1];
|
|
@@ -43627,6 +43202,10 @@ No plans for project "${project.name}".
|
|
|
43627
43202
|
context.emit("done");
|
|
43628
43203
|
return { handled: true };
|
|
43629
43204
|
}
|
|
43205
|
+
context.emit("text", `Failed to remove step ${stepId} from plan ${planId}.
|
|
43206
|
+
`);
|
|
43207
|
+
context.emit("done");
|
|
43208
|
+
return { handled: true };
|
|
43630
43209
|
}
|
|
43631
43210
|
if (sub === "delete" || sub === "rm") {
|
|
43632
43211
|
const planId = parts[1];
|
|
@@ -43655,6 +43234,10 @@ No plans for project "${project.name}".
|
|
|
43655
43234
|
context.emit("done");
|
|
43656
43235
|
return { handled: true };
|
|
43657
43236
|
}
|
|
43237
|
+
context.emit("text", `Failed to delete plan ${planId}.
|
|
43238
|
+
`);
|
|
43239
|
+
context.emit("done");
|
|
43240
|
+
return { handled: true };
|
|
43658
43241
|
}
|
|
43659
43242
|
context.emit("text", `Unknown /plans command. Use /plans help.
|
|
43660
43243
|
`);
|
|
@@ -43758,7 +43341,7 @@ Energy restored.
|
|
|
43758
43341
|
message += `No skills loaded.
|
|
43759
43342
|
`;
|
|
43760
43343
|
message += `
|
|
43761
|
-
Add skills to ~/.assistants/
|
|
43344
|
+
Add skills to ~/.assistants/shared/skills/ or .assistants/skills/
|
|
43762
43345
|
`;
|
|
43763
43346
|
} else {
|
|
43764
43347
|
for (const skill of context.skills) {
|
|
@@ -43785,7 +43368,8 @@ ${context.skills.length} skill(s) available.
|
|
|
43785
43368
|
content: "",
|
|
43786
43369
|
handler: async (args, context) => {
|
|
43787
43370
|
const usage = this.tokenUsage;
|
|
43788
|
-
const
|
|
43371
|
+
const rawPercent = usage.maxContextTokens > 0 ? Math.round(usage.totalTokens / usage.maxContextTokens * 100) : 0;
|
|
43372
|
+
const usedPercent = Math.max(0, Math.min(100, rawPercent));
|
|
43789
43373
|
let message = `
|
|
43790
43374
|
**Session Status**
|
|
43791
43375
|
|
|
@@ -43849,14 +43433,15 @@ ${context.skills.length} skill(s) available.
|
|
|
43849
43433
|
`;
|
|
43850
43434
|
}
|
|
43851
43435
|
const barLength = 30;
|
|
43852
|
-
const filledLength = Math.round(usedPercent / 100 * barLength);
|
|
43853
|
-
const bar = "\u2588".repeat(filledLength) + "\u2591".repeat(barLength - filledLength);
|
|
43436
|
+
const filledLength = Math.max(0, Math.min(barLength, Math.round(usedPercent / 100 * barLength)));
|
|
43437
|
+
const bar = "\u2588".repeat(filledLength) + "\u2591".repeat(Math.max(0, barLength - filledLength));
|
|
43854
43438
|
message += `
|
|
43855
43439
|
[${bar}] ${usedPercent}%
|
|
43856
43440
|
`;
|
|
43857
43441
|
const contextInfo = context.getContextInfo?.();
|
|
43858
43442
|
if (contextInfo) {
|
|
43859
|
-
const
|
|
43443
|
+
const contextRawPercent = contextInfo.config.maxContextTokens > 0 ? Math.round(contextInfo.state.totalTokens / contextInfo.config.maxContextTokens * 100) : 0;
|
|
43444
|
+
const contextUsedPercent = Math.max(0, Math.min(100, contextRawPercent));
|
|
43860
43445
|
message += `
|
|
43861
43446
|
**Context Summary:**
|
|
43862
43447
|
`;
|
|
@@ -44108,6 +43693,13 @@ Keep it concise but comprehensive.`
|
|
|
44108
43693
|
} else {
|
|
44109
43694
|
at = parts[0];
|
|
44110
43695
|
}
|
|
43696
|
+
if (kind === "cron" && !cron) {
|
|
43697
|
+
context.emit("text", `Usage:
|
|
43698
|
+
/schedule cron "<expr>" <command>
|
|
43699
|
+
`);
|
|
43700
|
+
context.emit("done");
|
|
43701
|
+
return { handled: true };
|
|
43702
|
+
}
|
|
44111
43703
|
const command = parts.slice(commandStart).join(" ").trim();
|
|
44112
43704
|
if (!command) {
|
|
44113
43705
|
context.emit("text", `Error: command is required.
|
|
@@ -44132,6 +43724,12 @@ Keep it concise but comprehensive.`
|
|
|
44132
43724
|
schedule.nextRunAt = computeNextRun(schedule, now2);
|
|
44133
43725
|
if (!schedule.nextRunAt) {
|
|
44134
43726
|
context.emit("text", `Error: unable to compute next run time.
|
|
43727
|
+
`);
|
|
43728
|
+
context.emit("done");
|
|
43729
|
+
return { handled: true };
|
|
43730
|
+
}
|
|
43731
|
+
if (schedule.nextRunAt <= now2) {
|
|
43732
|
+
context.emit("text", `Error: scheduled time must be in the future.
|
|
44135
43733
|
`);
|
|
44136
43734
|
context.emit("done");
|
|
44137
43735
|
return { handled: true };
|
|
@@ -44161,6 +43759,7 @@ Keep it concise but comprehensive.`
|
|
|
44161
43759
|
context.emit("done");
|
|
44162
43760
|
return { handled: true };
|
|
44163
43761
|
}
|
|
43762
|
+
const escapeCell = (value) => value.replace(/\|/g, "\\|").replace(/\s+/g, " ").trim();
|
|
44164
43763
|
let output = `
|
|
44165
43764
|
| ID | Status | Next Run | Command |
|
|
44166
43765
|
`;
|
|
@@ -44168,7 +43767,7 @@ Keep it concise but comprehensive.`
|
|
|
44168
43767
|
`;
|
|
44169
43768
|
for (const schedule of schedules.sort((a, b) => (a.nextRunAt || 0) - (b.nextRunAt || 0))) {
|
|
44170
43769
|
const next = schedule.nextRunAt ? new Date(schedule.nextRunAt).toISOString() : "n/a";
|
|
44171
|
-
output += `| ${schedule.id} | ${schedule.status} | ${next} | ${schedule.command} |
|
|
43770
|
+
output += `| ${schedule.id} | ${schedule.status} | ${next} | ${escapeCell(schedule.command)} |
|
|
44172
43771
|
`;
|
|
44173
43772
|
}
|
|
44174
43773
|
context.emit("text", output);
|
|
@@ -44266,14 +43865,32 @@ ${lines.join(`
|
|
|
44266
43865
|
context.emit("done");
|
|
44267
43866
|
return { handled: true };
|
|
44268
43867
|
}
|
|
44269
|
-
|
|
44270
|
-
|
|
44271
|
-
|
|
44272
|
-
|
|
44273
|
-
|
|
44274
|
-
|
|
44275
|
-
|
|
44276
|
-
|
|
43868
|
+
let computedNext;
|
|
43869
|
+
const updated = await updateSchedule(context.cwd, id, (schedule) => {
|
|
43870
|
+
computedNext = computeNextRun(schedule, Date.now());
|
|
43871
|
+
if (!computedNext) {
|
|
43872
|
+
return schedule;
|
|
43873
|
+
}
|
|
43874
|
+
return {
|
|
43875
|
+
...schedule,
|
|
43876
|
+
status: "active",
|
|
43877
|
+
updatedAt: Date.now(),
|
|
43878
|
+
nextRunAt: computedNext
|
|
43879
|
+
};
|
|
43880
|
+
});
|
|
43881
|
+
if (!updated) {
|
|
43882
|
+
context.emit("text", `Schedule ${id} not found.
|
|
43883
|
+
`);
|
|
43884
|
+
context.emit("done");
|
|
43885
|
+
return { handled: true };
|
|
43886
|
+
}
|
|
43887
|
+
if (!computedNext) {
|
|
43888
|
+
context.emit("text", `Failed to compute next run for schedule ${id}.
|
|
43889
|
+
`);
|
|
43890
|
+
context.emit("done");
|
|
43891
|
+
return { handled: true };
|
|
43892
|
+
}
|
|
43893
|
+
context.emit("text", `Resumed schedule ${id}.
|
|
44277
43894
|
`);
|
|
44278
43895
|
context.emit("done");
|
|
44279
43896
|
return { handled: true };
|
|
@@ -44306,13 +43923,15 @@ Connector "${connectorName}" not found.
|
|
|
44306
43923
|
context.emit("done");
|
|
44307
43924
|
return { handled: true };
|
|
44308
43925
|
}
|
|
43926
|
+
const cli = connector.cli || `connect-${connector.name}`;
|
|
43927
|
+
const description = connector.description?.trim() || "No description provided.";
|
|
44309
43928
|
let message2 = `
|
|
44310
43929
|
**${connector.name}** Connector
|
|
44311
43930
|
|
|
44312
43931
|
`;
|
|
44313
|
-
message2 += `CLI: \`${
|
|
43932
|
+
message2 += `CLI: \`${cli}\`
|
|
44314
43933
|
`;
|
|
44315
|
-
message2 += `Description: ${
|
|
43934
|
+
message2 += `Description: ${description}
|
|
44316
43935
|
|
|
44317
43936
|
`;
|
|
44318
43937
|
try {
|
|
@@ -44346,9 +43965,15 @@ Connector "${connectorName}" not found.
|
|
|
44346
43965
|
message2 += `
|
|
44347
43966
|
**Available Commands:**
|
|
44348
43967
|
`;
|
|
44349
|
-
|
|
44350
|
-
|
|
43968
|
+
const commands = connector.commands || [];
|
|
43969
|
+
if (commands.length === 0) {
|
|
43970
|
+
message2 += ` (no commands discovered)
|
|
43971
|
+
`;
|
|
43972
|
+
} else {
|
|
43973
|
+
for (const cmd of commands) {
|
|
43974
|
+
message2 += ` ${cmd.name} - ${cmd.description}
|
|
44351
43975
|
`;
|
|
43976
|
+
}
|
|
44352
43977
|
}
|
|
44353
43978
|
message2 += `
|
|
44354
43979
|
**Usage:**
|
|
@@ -44375,21 +44000,18 @@ Connector "${connectorName}" not found.
|
|
|
44375
44000
|
message += " `bun add -g connect-<name>`\n\n";
|
|
44376
44001
|
message += "Then run `/connectors` again to verify it is detected.\n";
|
|
44377
44002
|
} else {
|
|
44378
|
-
const
|
|
44379
|
-
for (const connector of context.connectors) {
|
|
44003
|
+
const checkAuth = async (connector) => {
|
|
44380
44004
|
let status = "\u25CB";
|
|
44381
44005
|
let timeoutId = null;
|
|
44382
44006
|
try {
|
|
44007
|
+
const cli = connector.cli || `connect-${connector.name}`;
|
|
44383
44008
|
const timeoutPromise = new Promise((resolve5) => {
|
|
44384
44009
|
timeoutId = setTimeout(resolveAuthTimeout, 1000, resolve5);
|
|
44385
44010
|
});
|
|
44386
44011
|
const result = await Promise.race([
|
|
44387
|
-
Bun.$`${
|
|
44012
|
+
Bun.$`${cli} auth status --format json`.quiet().nothrow(),
|
|
44388
44013
|
timeoutPromise
|
|
44389
44014
|
]);
|
|
44390
|
-
if (timeoutId) {
|
|
44391
|
-
clearTimeout(timeoutId);
|
|
44392
|
-
}
|
|
44393
44015
|
if (result.exitCode === 0) {
|
|
44394
44016
|
try {
|
|
44395
44017
|
const parsed = JSON.parse(result.stdout.toString());
|
|
@@ -44405,8 +44027,10 @@ Connector "${connectorName}" not found.
|
|
|
44405
44027
|
clearTimeout(timeoutId);
|
|
44406
44028
|
}
|
|
44407
44029
|
}
|
|
44408
|
-
|
|
44409
|
-
}
|
|
44030
|
+
return status;
|
|
44031
|
+
};
|
|
44032
|
+
const statuses = await Promise.all(context.connectors.map((connector) => checkAuth(connector)));
|
|
44033
|
+
const escapeCell = (value) => value.replace(/\|/g, "\\|").replace(/\s+/g, " ").trim();
|
|
44410
44034
|
message += `| Status | Connector | Commands |
|
|
44411
44035
|
`;
|
|
44412
44036
|
message += `|--------|-----------|----------|
|
|
@@ -44414,8 +44038,8 @@ Connector "${connectorName}" not found.
|
|
|
44414
44038
|
for (let i = 0;i < context.connectors.length; i++) {
|
|
44415
44039
|
const connector = context.connectors[i];
|
|
44416
44040
|
const status = statuses[i];
|
|
44417
|
-
const cmdCount = connector.commands
|
|
44418
|
-
message += `| ${status} | ${connector.name
|
|
44041
|
+
const cmdCount = connector.commands?.length ?? 0;
|
|
44042
|
+
message += `| ${status} | ${escapeCell(connector.name)} | ${cmdCount} commands |
|
|
44419
44043
|
`;
|
|
44420
44044
|
}
|
|
44421
44045
|
message += `
|
|
@@ -44482,7 +44106,8 @@ No security events recorded.
|
|
|
44482
44106
|
message += `| --- | --- | --- | --- |
|
|
44483
44107
|
`;
|
|
44484
44108
|
for (const event of events) {
|
|
44485
|
-
const
|
|
44109
|
+
const rawDetail = event.details?.reason || event.details?.path || event.details?.command || event.details?.tool || "n/a";
|
|
44110
|
+
const detail = String(rawDetail).replace(/\|/g, "\\|").replace(/\s+/g, " ").trim();
|
|
44486
44111
|
message += `| ${event.timestamp} | ${event.severity} | ${event.eventType} | ${detail} |
|
|
44487
44112
|
`;
|
|
44488
44113
|
}
|
|
@@ -44696,7 +44321,7 @@ async function createLLMClient(config) {
|
|
|
44696
44321
|
}
|
|
44697
44322
|
|
|
44698
44323
|
// packages/core/src/heartbeat/manager.ts
|
|
44699
|
-
import { dirname as
|
|
44324
|
+
import { dirname as dirname6 } from "path";
|
|
44700
44325
|
import { mkdirSync as mkdirSync5 } from "fs";
|
|
44701
44326
|
import { readFile as readFile4, writeFile as writeFile3 } from "fs/promises";
|
|
44702
44327
|
|
|
@@ -44718,7 +44343,7 @@ class HeartbeatManager {
|
|
|
44718
44343
|
errorsEncountered: 0,
|
|
44719
44344
|
uptimeSeconds: 0
|
|
44720
44345
|
};
|
|
44721
|
-
const dir =
|
|
44346
|
+
const dir = dirname6(config.persistPath);
|
|
44722
44347
|
mkdirSync5(dir, { recursive: true });
|
|
44723
44348
|
}
|
|
44724
44349
|
start(sessionId) {
|
|
@@ -44792,7 +44417,7 @@ class HeartbeatManager {
|
|
|
44792
44417
|
}
|
|
44793
44418
|
}
|
|
44794
44419
|
// packages/core/src/heartbeat/persistence.ts
|
|
44795
|
-
import { dirname as
|
|
44420
|
+
import { dirname as dirname7 } from "path";
|
|
44796
44421
|
import { mkdirSync as mkdirSync6 } from "fs";
|
|
44797
44422
|
import { readFile as readFile5, writeFile as writeFile4, unlink as unlink3 } from "fs/promises";
|
|
44798
44423
|
|
|
@@ -44800,7 +44425,7 @@ class StatePersistence {
|
|
|
44800
44425
|
path;
|
|
44801
44426
|
constructor(path2) {
|
|
44802
44427
|
this.path = path2;
|
|
44803
|
-
mkdirSync6(
|
|
44428
|
+
mkdirSync6(dirname7(path2), { recursive: true });
|
|
44804
44429
|
}
|
|
44805
44430
|
async save(state) {
|
|
44806
44431
|
try {
|
|
@@ -45019,7 +44644,7 @@ class EnergyManager {
|
|
|
45019
44644
|
}
|
|
45020
44645
|
}
|
|
45021
44646
|
// packages/core/src/energy/storage.ts
|
|
45022
|
-
import { dirname as
|
|
44647
|
+
import { dirname as dirname8 } from "path";
|
|
45023
44648
|
import { mkdirSync as mkdirSync7 } from "fs";
|
|
45024
44649
|
import { readFile as readFile6, writeFile as writeFile5 } from "fs/promises";
|
|
45025
44650
|
|
|
@@ -45027,7 +44652,7 @@ class EnergyStorage {
|
|
|
45027
44652
|
path;
|
|
45028
44653
|
constructor(path2) {
|
|
45029
44654
|
this.path = path2;
|
|
45030
|
-
mkdirSync7(
|
|
44655
|
+
mkdirSync7(dirname8(path2), { recursive: true });
|
|
45031
44656
|
}
|
|
45032
44657
|
async save(state) {
|
|
45033
44658
|
try {
|
|
@@ -46231,7 +45856,7 @@ class AgentLoop {
|
|
|
46231
45856
|
this.currentAllowedTools = null;
|
|
46232
45857
|
this.isRunning = false;
|
|
46233
45858
|
this.setHeartbeatState("idle");
|
|
46234
|
-
this.drainScheduledQueue();
|
|
45859
|
+
await this.drainScheduledQueue();
|
|
46235
45860
|
}
|
|
46236
45861
|
}
|
|
46237
45862
|
async handleExplicitToolCommand(userMessage) {
|
|
@@ -48297,6 +47922,15 @@ function extractBlockSections(text, blocks) {
|
|
|
48297
47922
|
i = parsed.nextIndex;
|
|
48298
47923
|
continue;
|
|
48299
47924
|
}
|
|
47925
|
+
const cardMatch = line.match(/^(\s*):::card(.*)$/);
|
|
47926
|
+
if (cardMatch) {
|
|
47927
|
+
const indent = cardMatch[1] ?? "";
|
|
47928
|
+
const parsed = parseDelimitedBlock(lines, i, indent);
|
|
47929
|
+
const warning = parsed?.warning || "Card blocks must be inside :::grid.";
|
|
47930
|
+
output.push(createMalformedBlock(blocks, indent, "block", warning));
|
|
47931
|
+
i = parsed ? parsed.nextIndex : i + 1;
|
|
47932
|
+
continue;
|
|
47933
|
+
}
|
|
48300
47934
|
output.push(line);
|
|
48301
47935
|
i += 1;
|
|
48302
47936
|
}
|
|
@@ -48317,7 +47951,18 @@ function extractCards(body) {
|
|
|
48317
47951
|
}
|
|
48318
47952
|
const indent = match[1] ?? "";
|
|
48319
47953
|
const attrs = parseAttributes(match[2] ?? "");
|
|
48320
|
-
|
|
47954
|
+
let type = String(attrs.type || "note");
|
|
47955
|
+
const normalizedType = type.toLowerCase();
|
|
47956
|
+
if (!ALLOWED_BLOCK_TYPES.has(normalizedType)) {
|
|
47957
|
+
cards.push({
|
|
47958
|
+
type: "warning",
|
|
47959
|
+
title: "Malformed card",
|
|
47960
|
+
body: `Unknown card type "${type}". Using note.`
|
|
47961
|
+
});
|
|
47962
|
+
type = "note";
|
|
47963
|
+
} else {
|
|
47964
|
+
type = normalizedType;
|
|
47965
|
+
}
|
|
48321
47966
|
const title = attrs.title ? String(attrs.title) : undefined;
|
|
48322
47967
|
const bodyLines = [];
|
|
48323
47968
|
let closed = false;
|
|
@@ -48450,7 +48095,7 @@ function renderCard(card, maxWidth, indent = "", forceWidth = false) {
|
|
|
48450
48095
|
}
|
|
48451
48096
|
function renderCardGrid(cards, columns, maxWidth, indent = "") {
|
|
48452
48097
|
const gap = 2;
|
|
48453
|
-
const totalWidth = maxWidth
|
|
48098
|
+
const totalWidth = maxWidth;
|
|
48454
48099
|
let effectiveColumns = columns;
|
|
48455
48100
|
if (totalWidth) {
|
|
48456
48101
|
const minCardWidth = 18;
|
|
@@ -48510,7 +48155,7 @@ function renderBox(header, lines, type, maxWidth, indent = "", forceWidth = fals
|
|
|
48510
48155
|
}
|
|
48511
48156
|
function renderBoxLines(header, lines, type, maxWidth, indent = "", forceWidth = false) {
|
|
48512
48157
|
const headerStyled = styleHeader(header, type);
|
|
48513
|
-
const maxInnerWidth = maxWidth ? Math.max(
|
|
48158
|
+
const maxInnerWidth = maxWidth ? Math.max(1, maxWidth - 4) : undefined;
|
|
48514
48159
|
const headerLine = maxInnerWidth ? truncateAnsi(headerStyled, maxInnerWidth) : headerStyled;
|
|
48515
48160
|
const wrappedLines = maxInnerWidth ? wrapAnsiLines(lines, maxInnerWidth) : lines;
|
|
48516
48161
|
const contentWidth = Math.max(stripAnsi2(headerLine).length, ...wrappedLines.map((line) => stripAnsi2(line).length), 0);
|
|
@@ -48595,8 +48240,7 @@ function renderTable(header, rows, maxWidth) {
|
|
|
48595
48240
|
widths[i] = len;
|
|
48596
48241
|
}
|
|
48597
48242
|
}
|
|
48598
|
-
const
|
|
48599
|
-
const availableCellWidth = maxWidth ? Math.max(colCount * minCellWidth, maxWidth - (colCount - 1) * 3 - 4) : undefined;
|
|
48243
|
+
const availableCellWidth = maxWidth ? Math.max(colCount, maxWidth - (colCount - 1) * 3 - 4) : undefined;
|
|
48600
48244
|
if (availableCellWidth) {
|
|
48601
48245
|
const total = widths.reduce((sum, width) => sum + width, 0);
|
|
48602
48246
|
if (total > availableCellWidth) {
|
|
@@ -48685,8 +48329,9 @@ function renderReport(body, maxWidth, indent = "") {
|
|
|
48685
48329
|
output.push(indent + source_default.bold("Progress Overview"));
|
|
48686
48330
|
const parsed = progressLines.map((line) => line.trim().replace(/^-/, "").trim()).map((line) => line.match(/^(.+?):\s*(\d{1,3})%?$/)).filter((match) => Boolean(match)).map((match) => ({ label: match[1].trim(), value: Math.max(0, Math.min(100, Number(match[2]))) }));
|
|
48687
48331
|
if (parsed.length > 0) {
|
|
48688
|
-
const
|
|
48689
|
-
const
|
|
48332
|
+
const maxLabelWidth = maxWidth ? Math.max(4, maxWidth - 14) : 24;
|
|
48333
|
+
const labelWidth = Math.min(maxLabelWidth, Math.max(...parsed.map((p) => p.label.length), 10));
|
|
48334
|
+
const barWidth = maxWidth ? Math.max(4, Math.min(30, maxWidth - labelWidth - 8)) : 24;
|
|
48690
48335
|
for (const entry of parsed) {
|
|
48691
48336
|
output.push(indent + renderProgressLine(entry.label, entry.value, labelWidth, barWidth));
|
|
48692
48337
|
}
|
|
@@ -48855,6 +48500,156 @@ function truncateAnsi(line, width) {
|
|
|
48855
48500
|
return current + suffix;
|
|
48856
48501
|
}
|
|
48857
48502
|
|
|
48503
|
+
// packages/terminal/src/components/toolDisplay.ts
|
|
48504
|
+
function truncateToolResult(toolResult, maxLines = 15, maxChars = 3000) {
|
|
48505
|
+
const toolName = toolResult.toolName || "tool";
|
|
48506
|
+
let content = String(toolResult.content || "");
|
|
48507
|
+
const formatted = formatToolResultNicely(toolName, content, toolResult.isError);
|
|
48508
|
+
if (formatted) {
|
|
48509
|
+
return formatted;
|
|
48510
|
+
}
|
|
48511
|
+
const prefix = toolResult.isError ? `Error: ` : "";
|
|
48512
|
+
content = stripAnsi3(content);
|
|
48513
|
+
content = content.replace(/\t/g, " ");
|
|
48514
|
+
const lines = content.split(`
|
|
48515
|
+
`);
|
|
48516
|
+
if (lines.length > maxLines) {
|
|
48517
|
+
content = lines.slice(0, maxLines).join(`
|
|
48518
|
+
`) + `
|
|
48519
|
+
... (${lines.length - maxLines} more lines)`;
|
|
48520
|
+
}
|
|
48521
|
+
if (content.length > maxChars) {
|
|
48522
|
+
content = content.slice(0, maxChars) + "...";
|
|
48523
|
+
}
|
|
48524
|
+
return prefix + content.trim();
|
|
48525
|
+
}
|
|
48526
|
+
function formatToolResultNicely(toolName, content, isError) {
|
|
48527
|
+
if (isError) {
|
|
48528
|
+
if (content.includes("ENOENT") || content.includes("no such file")) {
|
|
48529
|
+
return "\u26A0 File not found";
|
|
48530
|
+
}
|
|
48531
|
+
if (content.includes("EACCES") || content.includes("permission denied")) {
|
|
48532
|
+
return "\u26A0 Permission denied";
|
|
48533
|
+
}
|
|
48534
|
+
if (content.includes("ETIMEDOUT") || content.includes("timeout")) {
|
|
48535
|
+
return "\u26A0 Request timed out";
|
|
48536
|
+
}
|
|
48537
|
+
return null;
|
|
48538
|
+
}
|
|
48539
|
+
switch (toolName) {
|
|
48540
|
+
case "schedule":
|
|
48541
|
+
return formatScheduleResult(content);
|
|
48542
|
+
case "submit_feedback":
|
|
48543
|
+
return formatFeedbackResult(content);
|
|
48544
|
+
case "read":
|
|
48545
|
+
return formatReadResult(content);
|
|
48546
|
+
case "write":
|
|
48547
|
+
return formatWriteResult(content);
|
|
48548
|
+
case "glob":
|
|
48549
|
+
return formatGlobResult(content);
|
|
48550
|
+
case "grep":
|
|
48551
|
+
return formatGrepResult(content);
|
|
48552
|
+
case "bash":
|
|
48553
|
+
return formatBashResult(content);
|
|
48554
|
+
case "web_search":
|
|
48555
|
+
return formatSearchResult(content);
|
|
48556
|
+
default:
|
|
48557
|
+
return null;
|
|
48558
|
+
}
|
|
48559
|
+
}
|
|
48560
|
+
function formatScheduleResult(content) {
|
|
48561
|
+
const trimmed = content.trim().toLowerCase();
|
|
48562
|
+
if (trimmed === "no schedules found." || trimmed.includes("no schedules")) {
|
|
48563
|
+
return "\uD83D\uDCC5 No scheduled tasks";
|
|
48564
|
+
}
|
|
48565
|
+
if (trimmed.includes("created") || trimmed.includes("scheduled")) {
|
|
48566
|
+
return "\u2713 Schedule created";
|
|
48567
|
+
}
|
|
48568
|
+
if (trimmed.includes("deleted") || trimmed.includes("removed")) {
|
|
48569
|
+
return "\u2713 Schedule deleted";
|
|
48570
|
+
}
|
|
48571
|
+
if (trimmed.includes("paused")) {
|
|
48572
|
+
return "\u23F8 Schedule paused";
|
|
48573
|
+
}
|
|
48574
|
+
if (trimmed.includes("resumed")) {
|
|
48575
|
+
return "\u25B6 Schedule resumed";
|
|
48576
|
+
}
|
|
48577
|
+
if (content.includes("id:") || content.includes("command:")) {
|
|
48578
|
+
const lines = content.split(`
|
|
48579
|
+
`).filter((line) => line.trim());
|
|
48580
|
+
return `\uD83D\uDCC5 ${lines.length} scheduled task${lines.length !== 1 ? "s" : ""}`;
|
|
48581
|
+
}
|
|
48582
|
+
return null;
|
|
48583
|
+
}
|
|
48584
|
+
function formatFeedbackResult(content) {
|
|
48585
|
+
if (content.includes("submitted") || content.includes("created")) {
|
|
48586
|
+
return "\u2713 Feedback submitted";
|
|
48587
|
+
}
|
|
48588
|
+
return null;
|
|
48589
|
+
}
|
|
48590
|
+
function formatReadResult(content) {
|
|
48591
|
+
const lines = content.split(`
|
|
48592
|
+
`).length;
|
|
48593
|
+
if (lines > 20) {
|
|
48594
|
+
return `\uD83D\uDCC4 Read ${lines} lines`;
|
|
48595
|
+
}
|
|
48596
|
+
return null;
|
|
48597
|
+
}
|
|
48598
|
+
function formatWriteResult(content) {
|
|
48599
|
+
if (content.includes("written") || content.includes("saved") || content.includes("created")) {
|
|
48600
|
+
return "\u2713 File saved";
|
|
48601
|
+
}
|
|
48602
|
+
return null;
|
|
48603
|
+
}
|
|
48604
|
+
function formatGlobResult(content) {
|
|
48605
|
+
const lines = content.split(`
|
|
48606
|
+
`).filter((line) => line.trim());
|
|
48607
|
+
if (lines.length === 0) {
|
|
48608
|
+
return "\uD83D\uDD0D No files found";
|
|
48609
|
+
}
|
|
48610
|
+
if (lines.length > 10) {
|
|
48611
|
+
return `\uD83D\uDD0D Found ${lines.length} files`;
|
|
48612
|
+
}
|
|
48613
|
+
return null;
|
|
48614
|
+
}
|
|
48615
|
+
function formatGrepResult(content) {
|
|
48616
|
+
const lines = content.split(`
|
|
48617
|
+
`).filter((line) => line.trim());
|
|
48618
|
+
if (lines.length === 0) {
|
|
48619
|
+
return "\uD83D\uDD0D No matches found";
|
|
48620
|
+
}
|
|
48621
|
+
if (lines.length > 10) {
|
|
48622
|
+
return `\uD83D\uDD0D Found ${lines.length} matches`;
|
|
48623
|
+
}
|
|
48624
|
+
return null;
|
|
48625
|
+
}
|
|
48626
|
+
function formatBashResult(content) {
|
|
48627
|
+
const trimmed = content.trim();
|
|
48628
|
+
if (!trimmed) {
|
|
48629
|
+
return "\u2713 Command completed";
|
|
48630
|
+
}
|
|
48631
|
+
if (trimmed.length < 100 && !trimmed.includes(`
|
|
48632
|
+
`)) {
|
|
48633
|
+
return null;
|
|
48634
|
+
}
|
|
48635
|
+
const lines = trimmed.split(`
|
|
48636
|
+
`).length;
|
|
48637
|
+
if (lines > 20) {
|
|
48638
|
+
return `\u2713 Output: ${lines} lines`;
|
|
48639
|
+
}
|
|
48640
|
+
return null;
|
|
48641
|
+
}
|
|
48642
|
+
function formatSearchResult(content) {
|
|
48643
|
+
const resultCount = (content.match(/https?:\/\//g) || []).length;
|
|
48644
|
+
if (resultCount > 0) {
|
|
48645
|
+
return `\uD83D\uDD0D Found ${resultCount} result${resultCount !== 1 ? "s" : ""}`;
|
|
48646
|
+
}
|
|
48647
|
+
return null;
|
|
48648
|
+
}
|
|
48649
|
+
function stripAnsi3(text) {
|
|
48650
|
+
return text.replace(/\x1B\[[0-9;]*m/g, "");
|
|
48651
|
+
}
|
|
48652
|
+
|
|
48858
48653
|
// packages/terminal/src/components/messageLines.ts
|
|
48859
48654
|
function estimateToolPanelLines(toolCalls, toolResults, hasContent) {
|
|
48860
48655
|
if (!toolCalls || toolCalls.length === 0) {
|
|
@@ -48878,14 +48673,12 @@ function estimateToolPanelLines(toolCalls, toolResults, hasContent) {
|
|
|
48878
48673
|
return lines;
|
|
48879
48674
|
}
|
|
48880
48675
|
function estimateToolResultLines(result, maxLines = 4) {
|
|
48881
|
-
const content =
|
|
48676
|
+
const content = truncateToolResult(result, maxLines, 400);
|
|
48882
48677
|
if (!content)
|
|
48883
48678
|
return 1;
|
|
48884
|
-
const lines = content
|
|
48679
|
+
const lines = stripAnsi4(content).split(`
|
|
48885
48680
|
`);
|
|
48886
|
-
|
|
48887
|
-
return Math.max(1, lines.length);
|
|
48888
|
-
return maxLines + 1;
|
|
48681
|
+
return Math.max(1, lines.length);
|
|
48889
48682
|
}
|
|
48890
48683
|
function estimateMessageLines(message, maxWidth) {
|
|
48891
48684
|
if (message.role === "system") {
|
|
@@ -48900,6 +48693,11 @@ function estimateMessageLines(message, maxWidth) {
|
|
|
48900
48693
|
if (message.role === "assistant" && message.toolCalls?.length) {
|
|
48901
48694
|
lines += estimateToolPanelLines(message.toolCalls, message.toolResults, hasContent);
|
|
48902
48695
|
}
|
|
48696
|
+
if (message.role === "user" || message.role === "assistant") {
|
|
48697
|
+
if (!isContinuationChunk(message.id)) {
|
|
48698
|
+
lines += 2;
|
|
48699
|
+
}
|
|
48700
|
+
}
|
|
48903
48701
|
return lines;
|
|
48904
48702
|
}
|
|
48905
48703
|
function countWrappedLines(lines, maxWidth) {
|
|
@@ -48908,15 +48706,48 @@ function countWrappedLines(lines, maxWidth) {
|
|
|
48908
48706
|
}
|
|
48909
48707
|
let total = 0;
|
|
48910
48708
|
for (const line of lines) {
|
|
48911
|
-
const visible =
|
|
48709
|
+
const visible = stripAnsi4(line).length;
|
|
48912
48710
|
const wrapped = Math.max(1, Math.ceil(visible / maxWidth));
|
|
48913
48711
|
total += wrapped;
|
|
48914
48712
|
}
|
|
48915
48713
|
return total;
|
|
48916
48714
|
}
|
|
48917
|
-
function
|
|
48715
|
+
function stripAnsi4(text) {
|
|
48918
48716
|
return text.replace(/\x1B\[[0-9;]*m/g, "");
|
|
48919
48717
|
}
|
|
48718
|
+
function estimateActivityEntryLines(entry, wrapWidth, renderWidth) {
|
|
48719
|
+
if (entry.type === "text") {
|
|
48720
|
+
const content = entry.content ?? "";
|
|
48721
|
+
if (!content.trim())
|
|
48722
|
+
return 0;
|
|
48723
|
+
const rendered = renderMarkdown(content, { maxWidth: renderWidth });
|
|
48724
|
+
const lines = stripAnsi4(rendered).split(`
|
|
48725
|
+
`);
|
|
48726
|
+
const wrapped = countWrappedLines(lines, wrapWidth);
|
|
48727
|
+
return Math.max(1, wrapped) + 2;
|
|
48728
|
+
}
|
|
48729
|
+
if (entry.type === "tool_call") {
|
|
48730
|
+
return 4;
|
|
48731
|
+
}
|
|
48732
|
+
if (entry.type === "tool_result") {
|
|
48733
|
+
const content = entry.toolResult ? truncateToolResult(entry.toolResult) : "";
|
|
48734
|
+
const lines = content.split(`
|
|
48735
|
+
`);
|
|
48736
|
+
const wrapped = countWrappedLines(lines, wrapWidth);
|
|
48737
|
+
return Math.max(1, wrapped) + 2;
|
|
48738
|
+
}
|
|
48739
|
+
return 0;
|
|
48740
|
+
}
|
|
48741
|
+
function estimateActivityLogLines(entries, wrapWidth, renderWidth) {
|
|
48742
|
+
return entries.reduce((sum, entry) => sum + estimateActivityEntryLines(entry, wrapWidth, renderWidth), 0);
|
|
48743
|
+
}
|
|
48744
|
+
function isContinuationChunk(id) {
|
|
48745
|
+
const match = id.match(/::chunk-(\d+)$/);
|
|
48746
|
+
if (!match)
|
|
48747
|
+
return false;
|
|
48748
|
+
const idx = Number(match[1]);
|
|
48749
|
+
return Number.isFinite(idx) && idx > 0;
|
|
48750
|
+
}
|
|
48920
48751
|
|
|
48921
48752
|
// packages/terminal/src/components/Messages.tsx
|
|
48922
48753
|
var jsx_dev_runtime3 = __toESM(require_jsx_dev_runtime(), 1);
|
|
@@ -48934,24 +48765,37 @@ function Messages3({
|
|
|
48934
48765
|
const [now2, setNow] = import_react24.useState(Date.now());
|
|
48935
48766
|
const { stdout } = use_stdout_default();
|
|
48936
48767
|
const columns = stdout?.columns ?? 80;
|
|
48937
|
-
const messageWidth = Math.max(
|
|
48938
|
-
const
|
|
48768
|
+
const messageWidth = Math.max(1, columns - 2);
|
|
48769
|
+
const wrapWidth = messageWidth;
|
|
48770
|
+
const items = import_react24.useMemo(() => {
|
|
48771
|
+
const output = [];
|
|
48772
|
+
for (const message of messages) {
|
|
48773
|
+
output.push({ kind: "message", message });
|
|
48774
|
+
}
|
|
48775
|
+
for (const entry of activityLog) {
|
|
48776
|
+
output.push({ kind: "activity", entry });
|
|
48777
|
+
}
|
|
48778
|
+
for (const message of streamingMessages) {
|
|
48779
|
+
output.push({ kind: "streaming", message });
|
|
48780
|
+
}
|
|
48781
|
+
return output;
|
|
48782
|
+
}, [messages, activityLog, streamingMessages]);
|
|
48939
48783
|
const lineSpans = import_react24.useMemo(() => {
|
|
48940
48784
|
let cursor = 0;
|
|
48941
|
-
return
|
|
48942
|
-
const lines = estimateMessageLines(message, messageWidth);
|
|
48785
|
+
return items.map((item, index) => {
|
|
48786
|
+
const lines = item.kind === "activity" ? estimateActivityEntryLines(item.entry, wrapWidth, messageWidth) : estimateMessageLines(item.message, messageWidth);
|
|
48943
48787
|
const start = cursor;
|
|
48944
48788
|
cursor += lines;
|
|
48945
|
-
return {
|
|
48789
|
+
return { item, index, start, end: cursor, lines };
|
|
48946
48790
|
});
|
|
48947
|
-
}, [
|
|
48791
|
+
}, [items, wrapWidth, messageWidth]);
|
|
48948
48792
|
const totalLines = lineSpans.length > 0 ? lineSpans[lineSpans.length - 1].end : 0;
|
|
48949
48793
|
const endLine = Math.max(0, totalLines - scrollOffsetLines);
|
|
48950
48794
|
const startLine = Math.max(0, endLine - maxVisibleLines);
|
|
48951
48795
|
const visibleSpans = lineSpans.filter((span) => span.end > startLine && span.start < endLine);
|
|
48952
|
-
const
|
|
48953
|
-
const
|
|
48954
|
-
const visibleStreaming = visibleSpans.filter((span) => span.
|
|
48796
|
+
const visibleMessages = visibleSpans.filter((span) => span.item.kind === "message").map((span) => span.item.message);
|
|
48797
|
+
const visibleActivity = visibleSpans.filter((span) => span.item.kind === "activity").map((span) => span.item.entry);
|
|
48798
|
+
const visibleStreaming = visibleSpans.filter((span) => span.item.kind === "streaming").map((span) => span.item.message);
|
|
48955
48799
|
const showCurrentResponse = Boolean(currentResponse) && streamingMessages.length === 0;
|
|
48956
48800
|
const groupedMessages = groupConsecutiveToolMessages(visibleMessages);
|
|
48957
48801
|
const historicalItems = groupedMessages.map((group) => {
|
|
@@ -49002,7 +48846,7 @@ function Messages3({
|
|
|
49002
48846
|
messages: item.group.messages
|
|
49003
48847
|
}, item.id, false, undefined, this);
|
|
49004
48848
|
}),
|
|
49005
|
-
|
|
48849
|
+
visibleActivity.map((entry) => {
|
|
49006
48850
|
if (entry.type === "text" && entry.content) {
|
|
49007
48851
|
return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
|
|
49008
48852
|
marginY: 1,
|
|
@@ -49175,10 +49019,10 @@ function MessageBubble({ message, queuedMessageIds }) {
|
|
|
49175
49019
|
dimColor: true,
|
|
49176
49020
|
children: [
|
|
49177
49021
|
"\u23F3 ",
|
|
49178
|
-
message.content
|
|
49022
|
+
message.content ?? ""
|
|
49179
49023
|
]
|
|
49180
49024
|
}, undefined, true, undefined, this) : /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
|
|
49181
|
-
children: message.content
|
|
49025
|
+
children: message.content ?? ""
|
|
49182
49026
|
}, undefined, false, undefined, this)
|
|
49183
49027
|
]
|
|
49184
49028
|
}, undefined, true, undefined, this);
|
|
@@ -49222,7 +49066,7 @@ function startsWithListOrTable(content) {
|
|
|
49222
49066
|
const lines = content.split(`
|
|
49223
49067
|
`);
|
|
49224
49068
|
for (const line of lines) {
|
|
49225
|
-
const trimmed = line.trimStart();
|
|
49069
|
+
const trimmed = stripAnsi5(line).trimStart();
|
|
49226
49070
|
if (!trimmed)
|
|
49227
49071
|
continue;
|
|
49228
49072
|
if (/^[-*\u2022]\s+/.test(trimmed))
|
|
@@ -49231,10 +49075,21 @@ function startsWithListOrTable(content) {
|
|
|
49231
49075
|
return true;
|
|
49232
49076
|
if (trimmed.startsWith("|"))
|
|
49233
49077
|
return true;
|
|
49078
|
+
if (trimmed.startsWith("```"))
|
|
49079
|
+
return true;
|
|
49080
|
+
if (trimmed.startsWith(":::"))
|
|
49081
|
+
return true;
|
|
49082
|
+
if (/^[\u250C\u2510\u2514\u2518\u251C\u2524\u252C\u2534\u253C\u2502]/.test(trimmed))
|
|
49083
|
+
return true;
|
|
49084
|
+
if (/^[\u256D\u256E\u2570\u256F\u2502]/.test(trimmed))
|
|
49085
|
+
return true;
|
|
49234
49086
|
return false;
|
|
49235
49087
|
}
|
|
49236
49088
|
return false;
|
|
49237
49089
|
}
|
|
49090
|
+
function stripAnsi5(text) {
|
|
49091
|
+
return text.replace(/\x1B\[[0-9;]*m/g, "");
|
|
49092
|
+
}
|
|
49238
49093
|
function ToolCallPanel({
|
|
49239
49094
|
toolCalls,
|
|
49240
49095
|
toolResults
|
|
@@ -49243,7 +49098,8 @@ function ToolCallPanel({
|
|
|
49243
49098
|
return null;
|
|
49244
49099
|
const { stdout } = use_stdout_default();
|
|
49245
49100
|
const columns = stdout?.columns ?? 80;
|
|
49246
|
-
const panelWidth = Math.max(
|
|
49101
|
+
const panelWidth = Math.max(1, columns - 2);
|
|
49102
|
+
const innerWidth = Math.max(1, panelWidth - 4);
|
|
49247
49103
|
const resultMap = new Map;
|
|
49248
49104
|
for (const result of toolResults || []) {
|
|
49249
49105
|
resultMap.set(result.toolCallId, result);
|
|
@@ -49256,7 +49112,7 @@ function ToolCallPanel({
|
|
|
49256
49112
|
borderStyle: "round",
|
|
49257
49113
|
borderColor,
|
|
49258
49114
|
paddingX: 1,
|
|
49259
|
-
width:
|
|
49115
|
+
width: panelWidth,
|
|
49260
49116
|
children: [
|
|
49261
49117
|
/* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
|
|
49262
49118
|
justifyContent: "space-between",
|
|
@@ -49282,8 +49138,9 @@ function ToolCallPanel({
|
|
|
49282
49138
|
const statusColor = result ? result.isError ? "red" : "green" : "yellow";
|
|
49283
49139
|
const displayName = getToolDisplayName(toolCall);
|
|
49284
49140
|
const context2 = getToolContext(toolCall);
|
|
49285
|
-
const maxLine =
|
|
49141
|
+
const maxLine = Math.max(16, innerWidth - 2);
|
|
49286
49142
|
const summaryLine = truncate(formatToolCall(toolCall), maxLine);
|
|
49143
|
+
const resultText = result ? indentMultiline(truncateToolResult(result, 4, 400), " ") : "";
|
|
49287
49144
|
return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
|
|
49288
49145
|
flexDirection: "column",
|
|
49289
49146
|
marginTop: 1,
|
|
@@ -49321,7 +49178,7 @@ function ToolCallPanel({
|
|
|
49321
49178
|
dimColor: true,
|
|
49322
49179
|
children: [
|
|
49323
49180
|
"\u21B3 ",
|
|
49324
|
-
|
|
49181
|
+
resultText
|
|
49325
49182
|
]
|
|
49326
49183
|
}, undefined, true, undefined, this)
|
|
49327
49184
|
}, undefined, false, undefined, this)
|
|
@@ -49481,150 +49338,13 @@ function truncate(text, maxLength) {
|
|
|
49481
49338
|
return text;
|
|
49482
49339
|
return text.slice(0, maxLength - 3) + "...";
|
|
49483
49340
|
}
|
|
49484
|
-
function
|
|
49485
|
-
const
|
|
49486
|
-
|
|
49487
|
-
|
|
49488
|
-
|
|
49489
|
-
|
|
49490
|
-
}
|
|
49491
|
-
const prefix = toolResult.isError ? `Error: ` : "";
|
|
49492
|
-
content = content.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "");
|
|
49493
|
-
content = content.replace(/\t/g, " ");
|
|
49494
|
-
const lines = content.split(`
|
|
49341
|
+
function indentMultiline(text, padding) {
|
|
49342
|
+
const parts = text.split(`
|
|
49343
|
+
`);
|
|
49344
|
+
if (parts.length <= 1)
|
|
49345
|
+
return text;
|
|
49346
|
+
return [parts[0], ...parts.slice(1).map((line) => `${padding}${line}`)].join(`
|
|
49495
49347
|
`);
|
|
49496
|
-
if (lines.length > maxLines) {
|
|
49497
|
-
content = lines.slice(0, maxLines).join(`
|
|
49498
|
-
`) + `
|
|
49499
|
-
... (${lines.length - maxLines} more lines)`;
|
|
49500
|
-
}
|
|
49501
|
-
if (content.length > maxChars) {
|
|
49502
|
-
content = content.slice(0, maxChars) + "...";
|
|
49503
|
-
}
|
|
49504
|
-
return prefix + content.trim();
|
|
49505
|
-
}
|
|
49506
|
-
function formatToolResultNicely(toolName, content, isError) {
|
|
49507
|
-
if (isError) {
|
|
49508
|
-
if (content.includes("ENOENT") || content.includes("no such file")) {
|
|
49509
|
-
return "\u26A0 File not found";
|
|
49510
|
-
}
|
|
49511
|
-
if (content.includes("EACCES") || content.includes("permission denied")) {
|
|
49512
|
-
return "\u26A0 Permission denied";
|
|
49513
|
-
}
|
|
49514
|
-
if (content.includes("ETIMEDOUT") || content.includes("timeout")) {
|
|
49515
|
-
return "\u26A0 Request timed out";
|
|
49516
|
-
}
|
|
49517
|
-
return null;
|
|
49518
|
-
}
|
|
49519
|
-
switch (toolName) {
|
|
49520
|
-
case "schedule":
|
|
49521
|
-
return formatScheduleResult(content);
|
|
49522
|
-
case "submit_feedback":
|
|
49523
|
-
return formatFeedbackResult(content);
|
|
49524
|
-
case "read":
|
|
49525
|
-
return formatReadResult(content);
|
|
49526
|
-
case "write":
|
|
49527
|
-
return formatWriteResult(content);
|
|
49528
|
-
case "glob":
|
|
49529
|
-
return formatGlobResult(content);
|
|
49530
|
-
case "grep":
|
|
49531
|
-
return formatGrepResult(content);
|
|
49532
|
-
case "bash":
|
|
49533
|
-
return formatBashResult(content);
|
|
49534
|
-
case "web_search":
|
|
49535
|
-
return formatSearchResult(content);
|
|
49536
|
-
default:
|
|
49537
|
-
return null;
|
|
49538
|
-
}
|
|
49539
|
-
}
|
|
49540
|
-
function formatScheduleResult(content) {
|
|
49541
|
-
const trimmed = content.trim().toLowerCase();
|
|
49542
|
-
if (trimmed === "no schedules found." || trimmed.includes("no schedules")) {
|
|
49543
|
-
return "\uD83D\uDCC5 No scheduled tasks";
|
|
49544
|
-
}
|
|
49545
|
-
if (trimmed.includes("created") || trimmed.includes("scheduled")) {
|
|
49546
|
-
return "\u2713 Schedule created";
|
|
49547
|
-
}
|
|
49548
|
-
if (trimmed.includes("deleted") || trimmed.includes("removed")) {
|
|
49549
|
-
return "\u2713 Schedule deleted";
|
|
49550
|
-
}
|
|
49551
|
-
if (trimmed.includes("paused")) {
|
|
49552
|
-
return "\u23F8 Schedule paused";
|
|
49553
|
-
}
|
|
49554
|
-
if (trimmed.includes("resumed")) {
|
|
49555
|
-
return "\u25B6 Schedule resumed";
|
|
49556
|
-
}
|
|
49557
|
-
if (content.includes("id:") || content.includes("command:")) {
|
|
49558
|
-
const lines = content.split(`
|
|
49559
|
-
`).filter((l) => l.trim());
|
|
49560
|
-
return `\uD83D\uDCC5 ${lines.length} scheduled task${lines.length !== 1 ? "s" : ""}`;
|
|
49561
|
-
}
|
|
49562
|
-
return null;
|
|
49563
|
-
}
|
|
49564
|
-
function formatFeedbackResult(content) {
|
|
49565
|
-
if (content.includes("submitted") || content.includes("created")) {
|
|
49566
|
-
return "\u2713 Feedback submitted";
|
|
49567
|
-
}
|
|
49568
|
-
return null;
|
|
49569
|
-
}
|
|
49570
|
-
function formatReadResult(content) {
|
|
49571
|
-
const lines = content.split(`
|
|
49572
|
-
`).length;
|
|
49573
|
-
if (lines > 20) {
|
|
49574
|
-
return `\uD83D\uDCC4 Read ${lines} lines`;
|
|
49575
|
-
}
|
|
49576
|
-
return null;
|
|
49577
|
-
}
|
|
49578
|
-
function formatWriteResult(content) {
|
|
49579
|
-
if (content.includes("written") || content.includes("saved") || content.includes("created")) {
|
|
49580
|
-
return "\u2713 File saved";
|
|
49581
|
-
}
|
|
49582
|
-
return null;
|
|
49583
|
-
}
|
|
49584
|
-
function formatGlobResult(content) {
|
|
49585
|
-
const lines = content.split(`
|
|
49586
|
-
`).filter((l) => l.trim());
|
|
49587
|
-
if (lines.length === 0) {
|
|
49588
|
-
return "\uD83D\uDD0D No files found";
|
|
49589
|
-
}
|
|
49590
|
-
if (lines.length > 10) {
|
|
49591
|
-
return `\uD83D\uDD0D Found ${lines.length} files`;
|
|
49592
|
-
}
|
|
49593
|
-
return null;
|
|
49594
|
-
}
|
|
49595
|
-
function formatGrepResult(content) {
|
|
49596
|
-
const lines = content.split(`
|
|
49597
|
-
`).filter((l) => l.trim());
|
|
49598
|
-
if (lines.length === 0) {
|
|
49599
|
-
return "\uD83D\uDD0D No matches found";
|
|
49600
|
-
}
|
|
49601
|
-
if (lines.length > 10) {
|
|
49602
|
-
return `\uD83D\uDD0D Found ${lines.length} matches`;
|
|
49603
|
-
}
|
|
49604
|
-
return null;
|
|
49605
|
-
}
|
|
49606
|
-
function formatBashResult(content) {
|
|
49607
|
-
const trimmed = content.trim();
|
|
49608
|
-
if (!trimmed) {
|
|
49609
|
-
return "\u2713 Command completed";
|
|
49610
|
-
}
|
|
49611
|
-
if (trimmed.length < 100 && !trimmed.includes(`
|
|
49612
|
-
`)) {
|
|
49613
|
-
return null;
|
|
49614
|
-
}
|
|
49615
|
-
const lines = trimmed.split(`
|
|
49616
|
-
`).length;
|
|
49617
|
-
if (lines > 20) {
|
|
49618
|
-
return `\u2713 Output: ${lines} lines`;
|
|
49619
|
-
}
|
|
49620
|
-
return null;
|
|
49621
|
-
}
|
|
49622
|
-
function formatSearchResult(content) {
|
|
49623
|
-
const resultCount = (content.match(/https?:\/\//g) || []).length;
|
|
49624
|
-
if (resultCount > 0) {
|
|
49625
|
-
return `\uD83D\uDD0D Found ${resultCount} result${resultCount !== 1 ? "s" : ""}`;
|
|
49626
|
-
}
|
|
49627
|
-
return null;
|
|
49628
49348
|
}
|
|
49629
49349
|
|
|
49630
49350
|
// packages/terminal/src/components/Status.tsx
|
|
@@ -49666,7 +49386,8 @@ function Status({
|
|
|
49666
49386
|
};
|
|
49667
49387
|
let contextInfo = "";
|
|
49668
49388
|
if (tokenUsage && tokenUsage.maxContextTokens > 0) {
|
|
49669
|
-
const
|
|
49389
|
+
const rawPercent = Math.round(tokenUsage.totalTokens / tokenUsage.maxContextTokens * 100);
|
|
49390
|
+
const percent = Math.max(0, Math.min(100, rawPercent));
|
|
49670
49391
|
contextInfo = `${percent}%`;
|
|
49671
49392
|
}
|
|
49672
49393
|
const sessionInfo = sessionIndex && sessionCount && sessionCount > 1 ? `${sessionIndex}/${sessionCount}` : "";
|
|
@@ -49948,6 +49669,9 @@ function SessionSelector({
|
|
|
49948
49669
|
onCancel
|
|
49949
49670
|
}) {
|
|
49950
49671
|
const [selectedIndex, setSelectedIndex] = import_react28.useState(0);
|
|
49672
|
+
import_react28.useEffect(() => {
|
|
49673
|
+
setSelectedIndex((prev) => Math.min(prev, sessions.length));
|
|
49674
|
+
}, [sessions.length]);
|
|
49951
49675
|
use_input_default((input, key) => {
|
|
49952
49676
|
if (input === "n" || input === "N") {
|
|
49953
49677
|
onNew();
|
|
@@ -50085,30 +49809,15 @@ function wrapTextLines(text, wrapChars) {
|
|
|
50085
49809
|
}
|
|
50086
49810
|
return lines;
|
|
50087
49811
|
}
|
|
50088
|
-
function
|
|
49812
|
+
function stripAnsi6(text) {
|
|
50089
49813
|
return text.replace(/\x1B\[[0-9;]*m/g, "");
|
|
50090
49814
|
}
|
|
50091
|
-
function truncateActivityContent(content, maxLines = 15, maxChars = 3000) {
|
|
50092
|
-
let output = content.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "");
|
|
50093
|
-
output = output.replace(/\t/g, " ");
|
|
50094
|
-
const lines = output.split(`
|
|
50095
|
-
`);
|
|
50096
|
-
if (lines.length > maxLines) {
|
|
50097
|
-
output = lines.slice(0, maxLines).join(`
|
|
50098
|
-
`) + `
|
|
50099
|
-
... (${lines.length - maxLines} more lines)`;
|
|
50100
|
-
}
|
|
50101
|
-
if (output.length > maxChars) {
|
|
50102
|
-
output = output.slice(0, maxChars) + "...";
|
|
50103
|
-
}
|
|
50104
|
-
return output;
|
|
50105
|
-
}
|
|
50106
49815
|
function chunkRenderedLines(lines, chunkLines) {
|
|
50107
49816
|
const chunks = [];
|
|
50108
49817
|
let current = [];
|
|
50109
49818
|
let i = 0;
|
|
50110
|
-
const isBoxStart = (line) =>
|
|
50111
|
-
const isBoxEnd = (line) =>
|
|
49819
|
+
const isBoxStart = (line) => stripAnsi6(line).trimStart().startsWith("\u250C");
|
|
49820
|
+
const isBoxEnd = (line) => stripAnsi6(line).trimStart().startsWith("\u2514");
|
|
50112
49821
|
while (i < lines.length) {
|
|
50113
49822
|
const line = lines[i];
|
|
50114
49823
|
if (isBoxStart(line)) {
|
|
@@ -50589,36 +50298,17 @@ function App2({ cwd: cwd2, version }) {
|
|
|
50589
50298
|
const queuedCount = activeQueue.filter((msg) => msg.mode === "queued").length;
|
|
50590
50299
|
const inlineCount = activeInline.length;
|
|
50591
50300
|
const showWelcome = messages.length === 0 && !isProcessing;
|
|
50592
|
-
const
|
|
50593
|
-
const
|
|
50301
|
+
const renderWidth = columns ? Math.max(1, columns - 2) : undefined;
|
|
50302
|
+
const wrapChars = renderWidth ?? MESSAGE_WRAP_CHARS;
|
|
50594
50303
|
const activityLogLineCount = import_react29.useMemo(() => {
|
|
50595
50304
|
if (activityLog.length === 0)
|
|
50596
50305
|
return 0;
|
|
50597
|
-
|
|
50598
|
-
for (const entry of activityLog) {
|
|
50599
|
-
if (entry.type === "text" && entry.content) {
|
|
50600
|
-
const rendered = renderMarkdown(entry.content, { maxWidth: renderWidth });
|
|
50601
|
-
const entryLines = wrapTextLines(stripAnsi4(rendered), wrapChars).length;
|
|
50602
|
-
lines += entryLines + 2;
|
|
50603
|
-
continue;
|
|
50604
|
-
}
|
|
50605
|
-
if (entry.type === "tool_call" && entry.toolCall) {
|
|
50606
|
-
lines += 4;
|
|
50607
|
-
continue;
|
|
50608
|
-
}
|
|
50609
|
-
if (entry.type === "tool_result" && entry.toolResult) {
|
|
50610
|
-
const truncated = truncateActivityContent(String(entry.toolResult.content ?? ""));
|
|
50611
|
-
const entryLines = wrapTextLines(truncated, wrapChars).length;
|
|
50612
|
-
lines += entryLines + 2;
|
|
50613
|
-
continue;
|
|
50614
|
-
}
|
|
50615
|
-
}
|
|
50616
|
-
return lines;
|
|
50306
|
+
return estimateActivityLogLines(activityLog, wrapChars, renderWidth);
|
|
50617
50307
|
}, [activityLog, renderWidth, wrapChars]);
|
|
50618
50308
|
const reservedLines = import_react29.useMemo(() => {
|
|
50619
50309
|
let lines = 0;
|
|
50620
50310
|
if (showWelcome) {
|
|
50621
|
-
lines +=
|
|
50311
|
+
lines += 4;
|
|
50622
50312
|
}
|
|
50623
50313
|
if (backgroundProcessingCount > 0) {
|
|
50624
50314
|
lines += 1;
|
|
@@ -50698,7 +50388,7 @@ function App2({ cwd: cwd2, version }) {
|
|
|
50698
50388
|
}
|
|
50699
50389
|
prevDisplayLineCountRef.current = totalLineCount;
|
|
50700
50390
|
}, [totalLineCount, autoScroll]);
|
|
50701
|
-
const maxVisibleLines = rows ? Math.max(
|
|
50391
|
+
const maxVisibleLines = rows ? Math.max(1, rows - reservedLines) : 20;
|
|
50702
50392
|
import_react29.useEffect(() => {
|
|
50703
50393
|
const maxOffset = Math.max(0, totalLineCount - maxVisibleLines);
|
|
50704
50394
|
setScrollOffset((prev) => Math.min(prev, maxOffset));
|
|
@@ -51415,4 +51105,4 @@ if (options.print !== null) {
|
|
|
51415
51105
|
});
|
|
51416
51106
|
}
|
|
51417
51107
|
|
|
51418
|
-
//# debugId=
|
|
51108
|
+
//# debugId=635A1CBC05837E5664756E2164756E21
|