@isdk/ai-tool 0.0.3 → 0.0.5
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/{chunk-DGMU4VSJ.mjs → chunk-6JC4ABGE.mjs} +130 -146
- package/dist/funcs.js +129 -145
- package/dist/funcs.mjs +2 -2
- package/dist/index.js +129 -145
- package/dist/index.mjs +2 -2
- package/dist/test/util.js +1 -2
- package/dist/test/util.mjs +2 -3
- package/docs/classes/AbortError.md +11 -11
- package/docs/classes/AlreadyExistsError.md +11 -11
- package/docs/classes/BaseError.md +11 -11
- package/docs/classes/ClientTools.md +51 -51
- package/docs/classes/CommonError.md +11 -11
- package/docs/classes/EventClient.md +73 -73
- package/docs/classes/EventServer.md +71 -71
- package/docs/classes/EventToolFunc.md +41 -41
- package/docs/classes/FStringPromptTemplate.md +18 -18
- package/docs/classes/FewShotPromptTemplate.md +22 -22
- package/docs/classes/GolangPromptTemplate.md +18 -18
- package/docs/classes/HFEnvironment.md +9 -9
- package/docs/classes/HFInterpreter.md +17 -17
- package/docs/classes/HFTemplate.md +4 -4
- package/docs/classes/HfPromptTemplate.md +18 -18
- package/docs/classes/NotFoundError.md +11 -11
- package/docs/classes/NotImplementationError.md +11 -11
- package/docs/classes/PromptExampleSelector.md +8 -8
- package/docs/classes/PromptTemplate.md +17 -17
- package/docs/classes/ReadableStreamError.md +11 -11
- package/docs/classes/ResClientTools.md +57 -57
- package/docs/classes/ResServerTools.md +55 -55
- package/docs/classes/SSEChannel.md +15 -15
- package/docs/classes/ServerTools.md +48 -48
- package/docs/classes/ToolFunc.md +38 -38
- package/docs/enums/ErrorCode.md +19 -19
- package/docs/enums/XXHashAlgorithm.md +2 -2
- package/docs/interfaces/AIChatAssistantMessageParam.md +6 -6
- package/docs/interfaces/AIChatContentPartImage.md +2 -2
- package/docs/interfaces/AIChatContentPartText.md +2 -2
- package/docs/interfaces/AIChatMessageParamBase.md +1 -1
- package/docs/interfaces/AIChatMessageToolCall.md +3 -3
- package/docs/interfaces/AIChatSystemMessageParam.md +3 -3
- package/docs/interfaces/AIChatToolMessageParam.md +4 -4
- package/docs/interfaces/AIChatUserMessageParam.md +7 -7
- package/docs/interfaces/AIResult.md +4 -4
- package/docs/interfaces/AIStreamCallbacksAndOptions.md +6 -6
- package/docs/interfaces/AIStreamParser.md +1 -1
- package/docs/interfaces/AIStreamParserOptions.md +1 -1
- package/docs/interfaces/BaseFunc.md +7 -7
- package/docs/interfaces/BaseFuncItem.md +6 -6
- package/docs/interfaces/ClientFuncItem.md +10 -10
- package/docs/interfaces/DotenvExpandOptions.md +3 -3
- package/docs/interfaces/DotenvExpandOutput.md +2 -2
- package/docs/interfaces/EventClientFuncParams.md +4 -4
- package/docs/interfaces/EventServerFuncParams.md +5 -5
- package/docs/interfaces/FewShotPromptTemplateOptions.md +11 -11
- package/docs/interfaces/FuncItem.md +7 -7
- package/docs/interfaces/FuncParam.md +5 -5
- package/docs/interfaces/PromptExampleSelectorOptions.md +2 -2
- package/docs/interfaces/PromptTemplateOptions.md +6 -6
- package/docs/interfaces/RemoteFuncItem.md +10 -10
- package/docs/interfaces/ResClientFuncParams.md +2 -2
- package/docs/interfaces/ResServerFuncParams.md +5 -5
- package/docs/interfaces/SanitizeFilenameOptions.md +2 -2
- package/docs/interfaces/ServerFuncItem.md +11 -11
- package/docs/interfaces/ServerFuncParams.md +2 -2
- package/docs/modules.md +110 -110
- package/package.json +12 -13
- /package/dist/{chunk-EZFPVSGF.mjs → chunk-U5DDQYSF.mjs} +0 -0
package/dist/index.js
CHANGED
|
@@ -913,8 +913,7 @@ function tokenize(source, options = {}) {
|
|
|
913
913
|
while (predicate(src[cursorPosition])) {
|
|
914
914
|
if (src[cursorPosition] === "\\") {
|
|
915
915
|
++cursorPosition;
|
|
916
|
-
if (cursorPosition >= src.length)
|
|
917
|
-
throw new SyntaxError("Unexpected end of input");
|
|
916
|
+
if (cursorPosition >= src.length) throw new SyntaxError("Unexpected end of input");
|
|
918
917
|
const escaped = src[cursorPosition++];
|
|
919
918
|
const unescaped = ESCAPE_CHARACTERS.get(escaped);
|
|
920
919
|
if (unescaped === void 0) {
|
|
@@ -924,83 +923,81 @@ function tokenize(source, options = {}) {
|
|
|
924
923
|
continue;
|
|
925
924
|
}
|
|
926
925
|
str += src[cursorPosition++];
|
|
927
|
-
if (cursorPosition >= src.length)
|
|
928
|
-
throw new SyntaxError("Unexpected end of input");
|
|
926
|
+
if (cursorPosition >= src.length) throw new SyntaxError("Unexpected end of input");
|
|
929
927
|
}
|
|
930
928
|
return str;
|
|
931
929
|
};
|
|
932
|
-
main:
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
continue;
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
consumeWhile((char2) => /\s/.test(char2));
|
|
947
|
-
const char = src[cursorPosition];
|
|
948
|
-
if (char === "-" || char === "+") {
|
|
949
|
-
const lastTokenType2 = tokens.at(-1)?.type;
|
|
950
|
-
if (lastTokenType2 === TOKEN_TYPES.Text || lastTokenType2 === void 0) {
|
|
951
|
-
throw new SyntaxError(`Unexpected character: ${char}`);
|
|
952
|
-
}
|
|
953
|
-
switch (lastTokenType2) {
|
|
954
|
-
case TOKEN_TYPES.Identifier:
|
|
955
|
-
case TOKEN_TYPES.NumericLiteral:
|
|
956
|
-
case TOKEN_TYPES.BooleanLiteral:
|
|
957
|
-
case TOKEN_TYPES.StringLiteral:
|
|
958
|
-
case TOKEN_TYPES.CloseParen:
|
|
959
|
-
case TOKEN_TYPES.CloseSquareBracket:
|
|
960
|
-
break;
|
|
961
|
-
default: {
|
|
962
|
-
++cursorPosition;
|
|
963
|
-
const num = consumeWhile(isInteger);
|
|
964
|
-
tokens.push(
|
|
965
|
-
new Token(`${char}${num}`, num.length > 0 ? TOKEN_TYPES.NumericLiteral : TOKEN_TYPES.UnaryOperator)
|
|
966
|
-
);
|
|
967
|
-
continue;
|
|
968
|
-
}
|
|
969
|
-
}
|
|
930
|
+
main: while (cursorPosition < src.length) {
|
|
931
|
+
const lastTokenType = tokens.at(-1)?.type;
|
|
932
|
+
if (lastTokenType === void 0 || lastTokenType === TOKEN_TYPES.CloseStatement || lastTokenType === TOKEN_TYPES.CloseExpression) {
|
|
933
|
+
let text = "";
|
|
934
|
+
while (cursorPosition < src.length && // Keep going until we hit the next Jinja statement or expression
|
|
935
|
+
!(src[cursorPosition] === "{" && (src[cursorPosition + 1] === "%" || src[cursorPosition + 1] === "{"))) {
|
|
936
|
+
text += src[cursorPosition++];
|
|
937
|
+
}
|
|
938
|
+
if (text.length > 0) {
|
|
939
|
+
tokens.push(new Token(text, TOKEN_TYPES.Text));
|
|
940
|
+
continue;
|
|
970
941
|
}
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
942
|
+
}
|
|
943
|
+
consumeWhile((char2) => /\s/.test(char2));
|
|
944
|
+
const char = src[cursorPosition];
|
|
945
|
+
if (char === "-" || char === "+") {
|
|
946
|
+
const lastTokenType2 = tokens.at(-1)?.type;
|
|
947
|
+
if (lastTokenType2 === TOKEN_TYPES.Text || lastTokenType2 === void 0) {
|
|
948
|
+
throw new SyntaxError(`Unexpected character: ${char}`);
|
|
949
|
+
}
|
|
950
|
+
switch (lastTokenType2) {
|
|
951
|
+
case TOKEN_TYPES.Identifier:
|
|
952
|
+
case TOKEN_TYPES.NumericLiteral:
|
|
953
|
+
case TOKEN_TYPES.BooleanLiteral:
|
|
954
|
+
case TOKEN_TYPES.StringLiteral:
|
|
955
|
+
case TOKEN_TYPES.CloseParen:
|
|
956
|
+
case TOKEN_TYPES.CloseSquareBracket:
|
|
957
|
+
break;
|
|
958
|
+
default: {
|
|
959
|
+
++cursorPosition;
|
|
960
|
+
const num = consumeWhile(isInteger);
|
|
961
|
+
tokens.push(
|
|
962
|
+
new Token(`${char}${num}`, num.length > 0 ? TOKEN_TYPES.NumericLiteral : TOKEN_TYPES.UnaryOperator)
|
|
963
|
+
);
|
|
964
|
+
continue;
|
|
977
965
|
}
|
|
978
966
|
}
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
if (isInteger(char)) {
|
|
987
|
-
const num = consumeWhile(isInteger);
|
|
988
|
-
tokens.push(new Token(num, TOKEN_TYPES.NumericLiteral));
|
|
989
|
-
continue;
|
|
967
|
+
}
|
|
968
|
+
for (const [char2, token] of ORDERED_MAPPING_TABLE) {
|
|
969
|
+
const slice2 = src.slice(cursorPosition, cursorPosition + char2.length);
|
|
970
|
+
if (slice2 === char2) {
|
|
971
|
+
tokens.push(new Token(char2, token));
|
|
972
|
+
cursorPosition += char2.length;
|
|
973
|
+
continue main;
|
|
990
974
|
}
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
975
|
+
}
|
|
976
|
+
if (char === "'" || char === '"') {
|
|
977
|
+
++cursorPosition;
|
|
978
|
+
const str = consumeWhile((c) => c !== char);
|
|
979
|
+
tokens.push(new Token(str, TOKEN_TYPES.StringLiteral));
|
|
980
|
+
++cursorPosition;
|
|
981
|
+
continue;
|
|
982
|
+
}
|
|
983
|
+
if (isInteger(char)) {
|
|
984
|
+
const num = consumeWhile(isInteger);
|
|
985
|
+
tokens.push(new Token(num, TOKEN_TYPES.NumericLiteral));
|
|
986
|
+
continue;
|
|
987
|
+
}
|
|
988
|
+
if (isWord(char)) {
|
|
989
|
+
const word = consumeWhile(isWord);
|
|
990
|
+
const type = Object.hasOwn(KEYWORDS, word) ? KEYWORDS[word] : TOKEN_TYPES.Identifier;
|
|
991
|
+
if (type === TOKEN_TYPES.In && tokens.at(-1)?.type === TOKEN_TYPES.Not) {
|
|
992
|
+
tokens.pop();
|
|
993
|
+
tokens.push(new Token("not in", TOKEN_TYPES.NotIn));
|
|
994
|
+
} else {
|
|
995
|
+
tokens.push(new Token(word, type));
|
|
1001
996
|
}
|
|
1002
|
-
|
|
997
|
+
continue;
|
|
1003
998
|
}
|
|
999
|
+
throw new SyntaxError(`Unexpected character: ${char}`);
|
|
1000
|
+
}
|
|
1004
1001
|
return tokens;
|
|
1005
1002
|
}
|
|
1006
1003
|
|
|
@@ -2296,8 +2293,7 @@ var Interpreter = class {
|
|
|
2296
2293
|
return new StringValue(result);
|
|
2297
2294
|
}
|
|
2298
2295
|
evaluate(statement, environment) {
|
|
2299
|
-
if (statement === void 0)
|
|
2300
|
-
return new UndefinedValue();
|
|
2296
|
+
if (statement === void 0) return new UndefinedValue();
|
|
2301
2297
|
switch (statement.type) {
|
|
2302
2298
|
case "Program":
|
|
2303
2299
|
return this.evalProgram(statement, environment);
|
|
@@ -3241,22 +3237,19 @@ var SSEChannel = class {
|
|
|
3241
3237
|
* @throws Will throw an error if the channel is closed.
|
|
3242
3238
|
*/
|
|
3243
3239
|
publish(data, eventName) {
|
|
3244
|
-
if (!this.active)
|
|
3245
|
-
throwError2("Channel closed", "SSEChannel", SSEChannelAlreadyClosedErrCode);
|
|
3240
|
+
if (!this.active) throwError2("Channel closed", "SSEChannel", SSEChannelAlreadyClosedErrCode);
|
|
3246
3241
|
let output;
|
|
3247
3242
|
let id;
|
|
3248
3243
|
let _eventName = eventName;
|
|
3249
3244
|
if (!data && !eventName) {
|
|
3250
|
-
if (!this.clients.size)
|
|
3251
|
-
return;
|
|
3245
|
+
if (!this.clients.size) return;
|
|
3252
3246
|
output = "data: \n\n";
|
|
3253
3247
|
} else {
|
|
3254
3248
|
id = this.nextID++;
|
|
3255
3249
|
if (typeof data === "object") {
|
|
3256
3250
|
if (data.event) {
|
|
3257
3251
|
_eventName = data.event;
|
|
3258
|
-
if (data.data !== void 0)
|
|
3259
|
-
data = JSON.stringify(data.data);
|
|
3252
|
+
if (data.data !== void 0) data = JSON.stringify(data.data);
|
|
3260
3253
|
} else {
|
|
3261
3254
|
data = JSON.stringify(data);
|
|
3262
3255
|
}
|
|
@@ -3283,8 +3276,7 @@ var SSEChannel = class {
|
|
|
3283
3276
|
* @throws Will throw an error if the channel is closed.
|
|
3284
3277
|
*/
|
|
3285
3278
|
subscribe(req, res, events) {
|
|
3286
|
-
if (!this.active)
|
|
3287
|
-
throwError2("Channel closed", "SSEChannel", SSEChannelAlreadyClosedErrCode);
|
|
3279
|
+
if (!this.active) throwError2("Channel closed", "SSEChannel", SSEChannelAlreadyClosedErrCode);
|
|
3288
3280
|
const c = { req, res, events };
|
|
3289
3281
|
const maxStreamDuration = this.options.maxStreamDuration;
|
|
3290
3282
|
let cacheControl = "max-age=0, stale-while-revalidate=0, stale-if-error=0, no-transform";
|
|
@@ -3414,8 +3406,7 @@ function createEventStreamTransformer(customParser) {
|
|
|
3414
3406
|
const parsedMessage = customParser ? customParser(event2.data, {
|
|
3415
3407
|
event: event2.event
|
|
3416
3408
|
}) : event2.data;
|
|
3417
|
-
if (parsedMessage)
|
|
3418
|
-
controller.enqueue(parsedMessage);
|
|
3409
|
+
if (parsedMessage) controller.enqueue(parsedMessage);
|
|
3419
3410
|
}
|
|
3420
3411
|
}
|
|
3421
3412
|
);
|
|
@@ -3431,15 +3422,13 @@ function createCallbacksTransformer(cb) {
|
|
|
3431
3422
|
const callbacks = cb || {};
|
|
3432
3423
|
return new TransformStream({
|
|
3433
3424
|
async start() {
|
|
3434
|
-
if (callbacks.onStart)
|
|
3435
|
-
await callbacks.onStart();
|
|
3425
|
+
if (callbacks.onStart) await callbacks.onStart();
|
|
3436
3426
|
},
|
|
3437
3427
|
async transform(message, controller) {
|
|
3438
3428
|
const content = typeof message === "string" ? message : message.content;
|
|
3439
3429
|
controller.enqueue(textEncoder.encode(content));
|
|
3440
3430
|
aggregatedResponse += content;
|
|
3441
|
-
if (callbacks.onToken)
|
|
3442
|
-
await callbacks.onToken(content);
|
|
3431
|
+
if (callbacks.onToken) await callbacks.onToken(content);
|
|
3443
3432
|
if (callbacks.onText && typeof message === "string") {
|
|
3444
3433
|
await callbacks.onText(message);
|
|
3445
3434
|
}
|
|
@@ -3459,8 +3448,7 @@ function trimStartOfStreamHelper() {
|
|
|
3459
3448
|
return (text) => {
|
|
3460
3449
|
if (isStreamStart) {
|
|
3461
3450
|
text = text.trimStart();
|
|
3462
|
-
if (text)
|
|
3463
|
-
isStreamStart = false;
|
|
3451
|
+
if (text) isStreamStart = false;
|
|
3464
3452
|
}
|
|
3465
3453
|
return text;
|
|
3466
3454
|
};
|
|
@@ -3487,10 +3475,8 @@ function readableFromAsyncIterable(iterable) {
|
|
|
3487
3475
|
return new ReadableStream({
|
|
3488
3476
|
async pull(controller) {
|
|
3489
3477
|
const { done, value } = await it.next();
|
|
3490
|
-
if (done)
|
|
3491
|
-
|
|
3492
|
-
else
|
|
3493
|
-
controller.enqueue(value);
|
|
3478
|
+
if (done) controller.close();
|
|
3479
|
+
else controller.enqueue(value);
|
|
3494
3480
|
},
|
|
3495
3481
|
async cancel(reason) {
|
|
3496
3482
|
await it.return?.(reason);
|
|
@@ -3563,8 +3549,7 @@ var XXHashAlgorithm = /* @__PURE__ */ ((XXHashAlgorithm2) => {
|
|
|
3563
3549
|
return XXHashAlgorithm2;
|
|
3564
3550
|
})(XXHashAlgorithm || {});
|
|
3565
3551
|
function xxhash(value, hashAlgo = 111 /* xxhash64 */, seed = SEED) {
|
|
3566
|
-
if (value.buffer)
|
|
3567
|
-
value = value.buffer;
|
|
3552
|
+
if (value.buffer) value = value.buffer;
|
|
3568
3553
|
let result;
|
|
3569
3554
|
if (hashAlgo !== 112 /* xxhash32 */) {
|
|
3570
3555
|
result = h64(value, seed);
|
|
@@ -3753,8 +3738,7 @@ function isObject(value) {
|
|
|
3753
3738
|
return !!value && value.constructor === Object;
|
|
3754
3739
|
}
|
|
3755
3740
|
function getKeysPath(value) {
|
|
3756
|
-
if (!value)
|
|
3757
|
-
return [];
|
|
3741
|
+
if (!value) return [];
|
|
3758
3742
|
return getKeys(value, [], "");
|
|
3759
3743
|
}
|
|
3760
3744
|
function getKeys(obj, paths, dot = ".") {
|
|
@@ -3788,30 +3772,14 @@ function loadFileFromPaths(filename, searchPaths, extNames) {
|
|
|
3788
3772
|
if (import_path2.default.isAbsolute(filename)) {
|
|
3789
3773
|
if (fs.existsSync(filename)) {
|
|
3790
3774
|
result = filename;
|
|
3775
|
+
} else {
|
|
3776
|
+
result = tryGetFilepath(import_path2.default.basename(filename), [import_path2.default.dirname(filename)], extNames);
|
|
3791
3777
|
}
|
|
3792
3778
|
} else {
|
|
3793
3779
|
if (!searchPaths) {
|
|
3794
3780
|
searchPaths = ["."];
|
|
3795
3781
|
}
|
|
3796
|
-
|
|
3797
|
-
for (const searchPath of searchPaths) {
|
|
3798
|
-
const filePath = import_path2.default.resolve(searchPath, filename);
|
|
3799
|
-
if (exts) {
|
|
3800
|
-
for (let i = 0; i < exts.length; i++) {
|
|
3801
|
-
const extName = exts[i] !== extNames[i] ? extNames[i] : "";
|
|
3802
|
-
const filenameWithExt = filePath + extName;
|
|
3803
|
-
if (fs.existsSync(filenameWithExt)) {
|
|
3804
|
-
result = filenameWithExt;
|
|
3805
|
-
break;
|
|
3806
|
-
}
|
|
3807
|
-
}
|
|
3808
|
-
} else {
|
|
3809
|
-
if (fs.existsSync(filePath)) {
|
|
3810
|
-
result = filePath;
|
|
3811
|
-
break;
|
|
3812
|
-
}
|
|
3813
|
-
}
|
|
3814
|
-
}
|
|
3782
|
+
result = tryGetFilepath(filename, searchPaths, extNames);
|
|
3815
3783
|
}
|
|
3816
3784
|
if (result) {
|
|
3817
3785
|
result = fs.readFileSync(result);
|
|
@@ -3820,6 +3788,29 @@ function loadFileFromPaths(filename, searchPaths, extNames) {
|
|
|
3820
3788
|
}
|
|
3821
3789
|
return result;
|
|
3822
3790
|
}
|
|
3791
|
+
function tryGetFilepath(filename, searchPaths, extNames) {
|
|
3792
|
+
let result;
|
|
3793
|
+
const exts = extNames ? extNames.map((ext) => getMultiLevelExtname(filename, extNameLevel(ext))) : void 0;
|
|
3794
|
+
for (const searchPath of searchPaths) {
|
|
3795
|
+
const filePath = import_path2.default.resolve(searchPath, filename);
|
|
3796
|
+
if (exts) {
|
|
3797
|
+
for (let i = 0; i < exts.length; i++) {
|
|
3798
|
+
const extName = exts[i] !== extNames[i] ? extNames[i] : "";
|
|
3799
|
+
const filenameWithExt = filePath + extName;
|
|
3800
|
+
if (fs.existsSync(filenameWithExt)) {
|
|
3801
|
+
result = filenameWithExt;
|
|
3802
|
+
break;
|
|
3803
|
+
}
|
|
3804
|
+
}
|
|
3805
|
+
} else {
|
|
3806
|
+
if (fs.existsSync(filePath)) {
|
|
3807
|
+
result = filePath;
|
|
3808
|
+
break;
|
|
3809
|
+
}
|
|
3810
|
+
}
|
|
3811
|
+
}
|
|
3812
|
+
return result;
|
|
3813
|
+
}
|
|
3823
3814
|
function loadTextFromPaths(filename, searchPaths, extNames, encoding = "utf8") {
|
|
3824
3815
|
const result = loadFileFromPaths(filename, searchPaths, extNames);
|
|
3825
3816
|
return result.toString(encoding);
|
|
@@ -3976,27 +3967,26 @@ function jsonFilterToWhere(filter, wrapKey) {
|
|
|
3976
3967
|
}
|
|
3977
3968
|
if (Array.isArray(filter)) {
|
|
3978
3969
|
andQuery.push(generateAndClause(filter, wrapKey));
|
|
3979
|
-
} else
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3970
|
+
} else for (const [key, value] of Object.entries(filter)) {
|
|
3971
|
+
if (key === "$and") {
|
|
3972
|
+
andQuery.push(`(${generateAndClause(filter[key], wrapKey)})`);
|
|
3973
|
+
} else if (key === "$or") {
|
|
3974
|
+
andQuery.push(`(${generateOrClause(filter[key], wrapKey)})`);
|
|
3975
|
+
} else {
|
|
3976
|
+
const tValue = typeof value;
|
|
3977
|
+
if (value == null) {
|
|
3978
|
+
andQuery.push(`${wrapKey(key)} IS NULL`);
|
|
3979
|
+
} else if (tValue === "object" && !Array.isArray(value)) {
|
|
3980
|
+
andQuery.push(generateCondition(wrapKey(key), value));
|
|
3981
|
+
} else if (tValue === "string") {
|
|
3982
|
+
andQuery.push(`${wrapKey(key)}='${value}'`);
|
|
3983
|
+
} else if (tValue === "number" || tValue === "boolean") {
|
|
3984
|
+
andQuery.push(`${wrapKey(key)}=${value}`);
|
|
3985
3985
|
} else {
|
|
3986
|
-
|
|
3987
|
-
if (value == null) {
|
|
3988
|
-
andQuery.push(`${wrapKey(key)} IS NULL`);
|
|
3989
|
-
} else if (tValue === "object" && !Array.isArray(value)) {
|
|
3990
|
-
andQuery.push(generateCondition(wrapKey(key), value));
|
|
3991
|
-
} else if (tValue === "string") {
|
|
3992
|
-
andQuery.push(`${wrapKey(key)}='${value}'`);
|
|
3993
|
-
} else if (tValue === "number" || tValue === "boolean") {
|
|
3994
|
-
andQuery.push(`${wrapKey(key)}=${value}`);
|
|
3995
|
-
} else {
|
|
3996
|
-
throw new Error(`Unsupported value type for key ${key}`);
|
|
3997
|
-
}
|
|
3986
|
+
throw new Error(`Unsupported value type for key ${key}`);
|
|
3998
3987
|
}
|
|
3999
3988
|
}
|
|
3989
|
+
}
|
|
4000
3990
|
;
|
|
4001
3991
|
return andQuery.length > 1 ? andQuery.join(" AND ") : andQuery[0];
|
|
4002
3992
|
}
|
|
@@ -4195,8 +4185,7 @@ var ToolFunc = class _ToolFunc extends import_property_manager.AdvancePropertyMa
|
|
|
4195
4185
|
runSync(params) {
|
|
4196
4186
|
const isPosParams = this.params && Array.isArray(this.params);
|
|
4197
4187
|
if (Array.isArray(params)) {
|
|
4198
|
-
if (isPosParams)
|
|
4199
|
-
return this.func(...params);
|
|
4188
|
+
if (isPosParams) return this.func(...params);
|
|
4200
4189
|
throwError2("the function is not support array params, the params must be object!", this.name);
|
|
4201
4190
|
}
|
|
4202
4191
|
if (isPosParams) {
|
|
@@ -4286,8 +4275,7 @@ var ClientTools = class _ClientTools extends ToolFunc {
|
|
|
4286
4275
|
"Content-Type": "application/json"
|
|
4287
4276
|
} });
|
|
4288
4277
|
const items = await res.json();
|
|
4289
|
-
if (items)
|
|
4290
|
-
this.loadFromSync(items);
|
|
4278
|
+
if (items) this.loadFromSync(items);
|
|
4291
4279
|
} else {
|
|
4292
4280
|
throwError2("missing apiRoot to load tools", "ClientTools");
|
|
4293
4281
|
}
|
|
@@ -4471,8 +4459,7 @@ var import_transformers = require("@xenova/transformers");
|
|
|
4471
4459
|
var import_secondary_cache = require("secondary-cache");
|
|
4472
4460
|
function _lrucache({ key, value, options } = {}) {
|
|
4473
4461
|
if (key === void 0) {
|
|
4474
|
-
if (options)
|
|
4475
|
-
this.cache.setDefaultOptions(options);
|
|
4462
|
+
if (options) this.cache.setDefaultOptions(options);
|
|
4476
4463
|
} else if (value === null) {
|
|
4477
4464
|
return this.cache.del(key);
|
|
4478
4465
|
} else if (value !== void 0) {
|
|
@@ -4674,8 +4661,7 @@ async function _splitSegments({ texts, model } = {}) {
|
|
|
4674
4661
|
}
|
|
4675
4662
|
}
|
|
4676
4663
|
}
|
|
4677
|
-
if (segment.length)
|
|
4678
|
-
segments2.push([...segment]);
|
|
4664
|
+
if (segment.length) segments2.push([...segment]);
|
|
4679
4665
|
return segments2;
|
|
4680
4666
|
}
|
|
4681
4667
|
var splitSegments = new ServerTools("splitSegments", {
|
|
@@ -4898,8 +4884,7 @@ var EventClient = class extends ResClientTools {
|
|
|
4898
4884
|
for (const event2 of events) {
|
|
4899
4885
|
if (!this._forwardEvents.has(event2)) {
|
|
4900
4886
|
this._forwardEvents.add(event2);
|
|
4901
|
-
if (this.on)
|
|
4902
|
-
this.on(event2, this.ebListener);
|
|
4887
|
+
if (this.on) this.on(event2, this.ebListener);
|
|
4903
4888
|
}
|
|
4904
4889
|
}
|
|
4905
4890
|
}
|
|
@@ -4918,8 +4903,7 @@ var EventClient = class extends ResClientTools {
|
|
|
4918
4903
|
for (const event2 of events) {
|
|
4919
4904
|
if (this._forwardEvents.has(event2)) {
|
|
4920
4905
|
this._forwardEvents.delete(event2);
|
|
4921
|
-
if (this.off)
|
|
4922
|
-
this.off(event2, this.ebListener);
|
|
4906
|
+
if (this.off) this.off(event2, this.ebListener);
|
|
4923
4907
|
}
|
|
4924
4908
|
}
|
|
4925
4909
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -129,11 +129,11 @@ import {
|
|
|
129
129
|
xxhash32,
|
|
130
130
|
xxhash64,
|
|
131
131
|
xxhashAsStr
|
|
132
|
-
} from "./chunk-
|
|
132
|
+
} from "./chunk-6JC4ABGE.mjs";
|
|
133
133
|
import {
|
|
134
134
|
__export,
|
|
135
135
|
__reExport
|
|
136
|
-
} from "./chunk-
|
|
136
|
+
} from "./chunk-U5DDQYSF.mjs";
|
|
137
137
|
|
|
138
138
|
// src/index.ts
|
|
139
139
|
var src_exports = {};
|
package/dist/test/util.js
CHANGED
|
@@ -55,8 +55,7 @@ async function findPort(port, portRetryCount = 10) {
|
|
|
55
55
|
port = 0;
|
|
56
56
|
} else {
|
|
57
57
|
port = parseInt(port);
|
|
58
|
-
if (!(port >= 0))
|
|
59
|
-
port = 0;
|
|
58
|
+
if (!(port >= 0)) port = 0;
|
|
60
59
|
}
|
|
61
60
|
const server = import_net.default.createServer();
|
|
62
61
|
server.on("error", (err) => {
|
package/dist/test/util.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-U5DDQYSF.mjs";
|
|
2
2
|
|
|
3
3
|
// test/util/compare-str.ts
|
|
4
4
|
function compareStr(src, dest) {
|
|
@@ -19,8 +19,7 @@ async function findPort(port, portRetryCount = 10) {
|
|
|
19
19
|
port = 0;
|
|
20
20
|
} else {
|
|
21
21
|
port = parseInt(port);
|
|
22
|
-
if (!(port >= 0))
|
|
23
|
-
port = 0;
|
|
22
|
+
if (!(port >= 0)) port = 0;
|
|
24
23
|
}
|
|
25
24
|
const server = net.createServer();
|
|
26
25
|
server.on("error", (err) => {
|
|
@@ -86,7 +86,7 @@ fromJSON - Creates a new BaseError instance from a JSON representation.
|
|
|
86
86
|
|
|
87
87
|
#### Defined in
|
|
88
88
|
|
|
89
|
-
[packages/ai-tool/src/utils/base-error.ts:202](https://github.com/isdk/ai-tool.js/blob/
|
|
89
|
+
[packages/ai-tool/src/utils/base-error.ts:202](https://github.com/isdk/ai-tool.js/blob/7204de5b4de6ebcdc7ec35b59d21cafca7d13309/src/utils/base-error.ts#L202)
|
|
90
90
|
|
|
91
91
|
## Properties
|
|
92
92
|
|
|
@@ -102,7 +102,7 @@ The name of the function that threw the error.
|
|
|
102
102
|
|
|
103
103
|
#### Defined in
|
|
104
104
|
|
|
105
|
-
[packages/ai-tool/src/utils/base-error.ts:64](https://github.com/isdk/ai-tool.js/blob/
|
|
105
|
+
[packages/ai-tool/src/utils/base-error.ts:64](https://github.com/isdk/ai-tool.js/blob/7204de5b4de6ebcdc7ec35b59d21cafca7d13309/src/utils/base-error.ts#L64)
|
|
106
106
|
|
|
107
107
|
___
|
|
108
108
|
|
|
@@ -130,7 +130,7 @@ ___
|
|
|
130
130
|
|
|
131
131
|
#### Defined in
|
|
132
132
|
|
|
133
|
-
[packages/ai-tool/src/utils/base-error.ts:65](https://github.com/isdk/ai-tool.js/blob/
|
|
133
|
+
[packages/ai-tool/src/utils/base-error.ts:65](https://github.com/isdk/ai-tool.js/blob/7204de5b4de6ebcdc7ec35b59d21cafca7d13309/src/utils/base-error.ts#L65)
|
|
134
134
|
|
|
135
135
|
___
|
|
136
136
|
|
|
@@ -146,7 +146,7 @@ Additional data associated with the error.
|
|
|
146
146
|
|
|
147
147
|
#### Defined in
|
|
148
148
|
|
|
149
|
-
[packages/ai-tool/src/utils/base-error.ts:66](https://github.com/isdk/ai-tool.js/blob/
|
|
149
|
+
[packages/ai-tool/src/utils/base-error.ts:66](https://github.com/isdk/ai-tool.js/blob/7204de5b4de6ebcdc7ec35b59d21cafca7d13309/src/utils/base-error.ts#L66)
|
|
150
150
|
|
|
151
151
|
___
|
|
152
152
|
|
|
@@ -204,7 +204,7 @@ The error code associated with the error.
|
|
|
204
204
|
|
|
205
205
|
#### Defined in
|
|
206
206
|
|
|
207
|
-
[packages/ai-tool/src/utils/base-error.ts:201](https://github.com/isdk/ai-tool.js/blob/
|
|
207
|
+
[packages/ai-tool/src/utils/base-error.ts:201](https://github.com/isdk/ai-tool.js/blob/7204de5b4de6ebcdc7ec35b59d21cafca7d13309/src/utils/base-error.ts#L201)
|
|
208
208
|
|
|
209
209
|
___
|
|
210
210
|
|
|
@@ -239,7 +239,7 @@ https://v8.dev/docs/stack-trace-api#customizing-stack-traces
|
|
|
239
239
|
|
|
240
240
|
#### Defined in
|
|
241
241
|
|
|
242
|
-
node_modules/.pnpm/@types+node@20.
|
|
242
|
+
node_modules/.pnpm/@types+node@20.14.2/node_modules/@types/node/globals.d.ts:28
|
|
243
243
|
|
|
244
244
|
___
|
|
245
245
|
|
|
@@ -253,7 +253,7 @@ ___
|
|
|
253
253
|
|
|
254
254
|
#### Defined in
|
|
255
255
|
|
|
256
|
-
node_modules/.pnpm/@types+node@20.
|
|
256
|
+
node_modules/.pnpm/@types+node@20.14.2/node_modules/@types/node/globals.d.ts:30
|
|
257
257
|
|
|
258
258
|
## Methods
|
|
259
259
|
|
|
@@ -281,7 +281,7 @@ A new BaseError instance.
|
|
|
281
281
|
|
|
282
282
|
#### Defined in
|
|
283
283
|
|
|
284
|
-
[packages/ai-tool/src/utils/base-error.ts:129](https://github.com/isdk/ai-tool.js/blob/
|
|
284
|
+
[packages/ai-tool/src/utils/base-error.ts:129](https://github.com/isdk/ai-tool.js/blob/7204de5b4de6ebcdc7ec35b59d21cafca7d13309/src/utils/base-error.ts#L129)
|
|
285
285
|
|
|
286
286
|
___
|
|
287
287
|
|
|
@@ -303,7 +303,7 @@ A JSON representation of the error.
|
|
|
303
303
|
|
|
304
304
|
#### Defined in
|
|
305
305
|
|
|
306
|
-
[packages/ai-tool/src/utils/base-error.ts:109](https://github.com/isdk/ai-tool.js/blob/
|
|
306
|
+
[packages/ai-tool/src/utils/base-error.ts:109](https://github.com/isdk/ai-tool.js/blob/7204de5b4de6ebcdc7ec35b59d21cafca7d13309/src/utils/base-error.ts#L109)
|
|
307
307
|
|
|
308
308
|
___
|
|
309
309
|
|
|
@@ -330,7 +330,7 @@ Create .stack property on a target object
|
|
|
330
330
|
|
|
331
331
|
#### Defined in
|
|
332
332
|
|
|
333
|
-
node_modules/.pnpm/@types+node@20.
|
|
333
|
+
node_modules/.pnpm/@types+node@20.14.2/node_modules/@types/node/globals.d.ts:21
|
|
334
334
|
|
|
335
335
|
___
|
|
336
336
|
|
|
@@ -356,4 +356,4 @@ typeof [`BaseError`](BaseError.md)
|
|
|
356
356
|
|
|
357
357
|
#### Defined in
|
|
358
358
|
|
|
359
|
-
[packages/ai-tool/src/utils/base-error.ts:68](https://github.com/isdk/ai-tool.js/blob/
|
|
359
|
+
[packages/ai-tool/src/utils/base-error.ts:68](https://github.com/isdk/ai-tool.js/blob/7204de5b4de6ebcdc7ec35b59d21cafca7d13309/src/utils/base-error.ts#L68)
|
|
@@ -66,7 +66,7 @@ throw new AlreadyExistsError('user', { id: 123 })
|
|
|
66
66
|
|
|
67
67
|
#### Defined in
|
|
68
68
|
|
|
69
|
-
[packages/ai-tool/src/utils/base-error.ts:193](https://github.com/isdk/ai-tool.js/blob/
|
|
69
|
+
[packages/ai-tool/src/utils/base-error.ts:193](https://github.com/isdk/ai-tool.js/blob/7204de5b4de6ebcdc7ec35b59d21cafca7d13309/src/utils/base-error.ts#L193)
|
|
70
70
|
|
|
71
71
|
## Properties
|
|
72
72
|
|
|
@@ -82,7 +82,7 @@ The name of the function that threw the error.
|
|
|
82
82
|
|
|
83
83
|
#### Defined in
|
|
84
84
|
|
|
85
|
-
[packages/ai-tool/src/utils/base-error.ts:64](https://github.com/isdk/ai-tool.js/blob/
|
|
85
|
+
[packages/ai-tool/src/utils/base-error.ts:64](https://github.com/isdk/ai-tool.js/blob/7204de5b4de6ebcdc7ec35b59d21cafca7d13309/src/utils/base-error.ts#L64)
|
|
86
86
|
|
|
87
87
|
___
|
|
88
88
|
|
|
@@ -110,7 +110,7 @@ ___
|
|
|
110
110
|
|
|
111
111
|
#### Defined in
|
|
112
112
|
|
|
113
|
-
[packages/ai-tool/src/utils/base-error.ts:65](https://github.com/isdk/ai-tool.js/blob/
|
|
113
|
+
[packages/ai-tool/src/utils/base-error.ts:65](https://github.com/isdk/ai-tool.js/blob/7204de5b4de6ebcdc7ec35b59d21cafca7d13309/src/utils/base-error.ts#L65)
|
|
114
114
|
|
|
115
115
|
___
|
|
116
116
|
|
|
@@ -126,7 +126,7 @@ Additional data associated with the error.
|
|
|
126
126
|
|
|
127
127
|
#### Defined in
|
|
128
128
|
|
|
129
|
-
[packages/ai-tool/src/utils/base-error.ts:66](https://github.com/isdk/ai-tool.js/blob/
|
|
129
|
+
[packages/ai-tool/src/utils/base-error.ts:66](https://github.com/isdk/ai-tool.js/blob/7204de5b4de6ebcdc7ec35b59d21cafca7d13309/src/utils/base-error.ts#L66)
|
|
130
130
|
|
|
131
131
|
___
|
|
132
132
|
|
|
@@ -184,7 +184,7 @@ The error code associated with the error.
|
|
|
184
184
|
|
|
185
185
|
#### Defined in
|
|
186
186
|
|
|
187
|
-
[packages/ai-tool/src/utils/base-error.ts:192](https://github.com/isdk/ai-tool.js/blob/
|
|
187
|
+
[packages/ai-tool/src/utils/base-error.ts:192](https://github.com/isdk/ai-tool.js/blob/7204de5b4de6ebcdc7ec35b59d21cafca7d13309/src/utils/base-error.ts#L192)
|
|
188
188
|
|
|
189
189
|
___
|
|
190
190
|
|
|
@@ -219,7 +219,7 @@ https://v8.dev/docs/stack-trace-api#customizing-stack-traces
|
|
|
219
219
|
|
|
220
220
|
#### Defined in
|
|
221
221
|
|
|
222
|
-
node_modules/.pnpm/@types+node@20.
|
|
222
|
+
node_modules/.pnpm/@types+node@20.14.2/node_modules/@types/node/globals.d.ts:28
|
|
223
223
|
|
|
224
224
|
___
|
|
225
225
|
|
|
@@ -233,7 +233,7 @@ ___
|
|
|
233
233
|
|
|
234
234
|
#### Defined in
|
|
235
235
|
|
|
236
|
-
node_modules/.pnpm/@types+node@20.
|
|
236
|
+
node_modules/.pnpm/@types+node@20.14.2/node_modules/@types/node/globals.d.ts:30
|
|
237
237
|
|
|
238
238
|
## Methods
|
|
239
239
|
|
|
@@ -261,7 +261,7 @@ A new BaseError instance.
|
|
|
261
261
|
|
|
262
262
|
#### Defined in
|
|
263
263
|
|
|
264
|
-
[packages/ai-tool/src/utils/base-error.ts:129](https://github.com/isdk/ai-tool.js/blob/
|
|
264
|
+
[packages/ai-tool/src/utils/base-error.ts:129](https://github.com/isdk/ai-tool.js/blob/7204de5b4de6ebcdc7ec35b59d21cafca7d13309/src/utils/base-error.ts#L129)
|
|
265
265
|
|
|
266
266
|
___
|
|
267
267
|
|
|
@@ -283,7 +283,7 @@ A JSON representation of the error.
|
|
|
283
283
|
|
|
284
284
|
#### Defined in
|
|
285
285
|
|
|
286
|
-
[packages/ai-tool/src/utils/base-error.ts:109](https://github.com/isdk/ai-tool.js/blob/
|
|
286
|
+
[packages/ai-tool/src/utils/base-error.ts:109](https://github.com/isdk/ai-tool.js/blob/7204de5b4de6ebcdc7ec35b59d21cafca7d13309/src/utils/base-error.ts#L109)
|
|
287
287
|
|
|
288
288
|
___
|
|
289
289
|
|
|
@@ -310,7 +310,7 @@ Create .stack property on a target object
|
|
|
310
310
|
|
|
311
311
|
#### Defined in
|
|
312
312
|
|
|
313
|
-
node_modules/.pnpm/@types+node@20.
|
|
313
|
+
node_modules/.pnpm/@types+node@20.14.2/node_modules/@types/node/globals.d.ts:21
|
|
314
314
|
|
|
315
315
|
___
|
|
316
316
|
|
|
@@ -336,4 +336,4 @@ typeof [`BaseError`](BaseError.md)
|
|
|
336
336
|
|
|
337
337
|
#### Defined in
|
|
338
338
|
|
|
339
|
-
[packages/ai-tool/src/utils/base-error.ts:68](https://github.com/isdk/ai-tool.js/blob/
|
|
339
|
+
[packages/ai-tool/src/utils/base-error.ts:68](https://github.com/isdk/ai-tool.js/blob/7204de5b4de6ebcdc7ec35b59d21cafca7d13309/src/utils/base-error.ts#L68)
|