@rayss-dev/openclaude 0.31.1-by-rayss → 0.31.2-by-rayss
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/acp.mjs +3628 -3484
- package/dist/cli.mjs +39 -39
- package/dist/sdk.mjs +1416 -55
- package/package.json +1 -1
package/dist/sdk.mjs
CHANGED
|
@@ -10131,7 +10131,7 @@ var init_version = __esm(() => {
|
|
|
10131
10131
|
import_semver = __toESM(require_semver2(), 1);
|
|
10132
10132
|
fallbackBuildVersion = (() => {
|
|
10133
10133
|
try {
|
|
10134
|
-
return "0.31.
|
|
10134
|
+
return "0.31.2-by-rayss";
|
|
10135
10135
|
} catch {
|
|
10136
10136
|
return "0.0.0";
|
|
10137
10137
|
}
|
|
@@ -70361,7 +70361,7 @@ function getAttributionHeader(fingerprint, policy) {
|
|
|
70361
70361
|
if (!policy.generate) {
|
|
70362
70362
|
return "";
|
|
70363
70363
|
}
|
|
70364
|
-
const version2 = `${"0.31.
|
|
70364
|
+
const version2 = `${"0.31.2-by-rayss"}.${fingerprint}`;
|
|
70365
70365
|
const entrypoint = process.env.CLAUDE_CODE_ENTRYPOINT ?? "unknown";
|
|
70366
70366
|
const cch = "";
|
|
70367
70367
|
const workload = getWorkload();
|
|
@@ -103997,7 +103997,7 @@ var init_metadata = __esm(() => {
|
|
|
103997
103997
|
COMPOUND_OPERATOR_REGEX = /\s*(?:&&|\|\||[;|])\s*/;
|
|
103998
103998
|
WHITESPACE_REGEX = /\s+/;
|
|
103999
103999
|
getVersionBase = memoize_default(() => {
|
|
104000
|
-
const match = "0.31.
|
|
104000
|
+
const match = "0.31.2-by-rayss".match(/^\d+\.\d+\.\d+(?:-[a-z]+)?/);
|
|
104001
104001
|
return match ? match[0] : undefined;
|
|
104002
104002
|
});
|
|
104003
104003
|
buildEnvContext = memoize_default(async () => {
|
|
@@ -104037,9 +104037,9 @@ var init_metadata = __esm(() => {
|
|
|
104037
104037
|
isGithubAction: isEnvTruthy(process.env.GITHUB_ACTIONS),
|
|
104038
104038
|
isClaudeCodeAction: isEnvTruthy(process.env.CLAUDE_CODE_ACTION),
|
|
104039
104039
|
isClaudeAiAuth: isClaudeAISubscriber(),
|
|
104040
|
-
version: "0.31.
|
|
104040
|
+
version: "0.31.2-by-rayss",
|
|
104041
104041
|
versionBase: getVersionBase(),
|
|
104042
|
-
buildTime: "2026-10-
|
|
104042
|
+
buildTime: "2026-10-08T13:31:49.092Z",
|
|
104043
104043
|
deploymentEnvironment: env2.detectDeploymentEnvironment(),
|
|
104044
104044
|
...isEnvTruthy(process.env.GITHUB_ACTIONS) && {
|
|
104045
104045
|
githubEventName: process.env.GITHUB_EVENT_NAME,
|
|
@@ -112213,11 +112213,11 @@ var init_effort = __esm(() => {
|
|
|
112213
112213
|
|
|
112214
112214
|
// src/utils/userAgent.ts
|
|
112215
112215
|
function getClaudeCodeUserAgent() {
|
|
112216
|
-
return `claude-code/${"0.31.
|
|
112216
|
+
return `claude-code/${"0.31.2-by-rayss"}`;
|
|
112217
112217
|
}
|
|
112218
112218
|
function getOpenClaudeUserAgent() {
|
|
112219
112219
|
try {
|
|
112220
|
-
return `openclaude/${"0.31.
|
|
112220
|
+
return `openclaude/${"0.31.2-by-rayss"}`;
|
|
112221
112221
|
} catch {
|
|
112222
112222
|
return "openclaude/0.0.0";
|
|
112223
112223
|
}
|
|
@@ -112229,7 +112229,7 @@ function getUserAgent() {
|
|
|
112229
112229
|
const clientApp = process.env.CLAUDE_AGENT_SDK_CLIENT_APP ? `, client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}` : "";
|
|
112230
112230
|
const workload = getWorkload();
|
|
112231
112231
|
const workloadSuffix = workload ? `, workload/${workload}` : "";
|
|
112232
|
-
return `claude-cli/${"0.31.
|
|
112232
|
+
return `claude-cli/${"0.31.2-by-rayss"} (${process.env.USER_TYPE}, ${process.env.CLAUDE_CODE_ENTRYPOINT ?? "cli"}${agentSdkVersion}${clientApp}${workloadSuffix})`;
|
|
112233
112233
|
}
|
|
112234
112234
|
function getMCPUserAgent() {
|
|
112235
112235
|
const parts = [];
|
|
@@ -112243,7 +112243,7 @@ function getMCPUserAgent() {
|
|
|
112243
112243
|
parts.push(`client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}`);
|
|
112244
112244
|
}
|
|
112245
112245
|
const suffix = parts.length > 0 ? ` (${parts.join(", ")})` : "";
|
|
112246
|
-
return `claude-code/${"0.31.
|
|
112246
|
+
return `claude-code/${"0.31.2-by-rayss"}${suffix}`;
|
|
112247
112247
|
}
|
|
112248
112248
|
function getWebFetchUserAgent() {
|
|
112249
112249
|
const supportUrl = isFirstPartyAnthropicProvider() ? "https://support.anthropic.com/" : "https://github.com/rayss868/openclaude";
|
|
@@ -156938,7 +156938,7 @@ function computeFingerprint(messageText2, version2) {
|
|
|
156938
156938
|
}
|
|
156939
156939
|
function computeFingerprintFromMessages(messages) {
|
|
156940
156940
|
const firstMessageText = extractFirstMessageText(messages);
|
|
156941
|
-
return computeFingerprint(firstMessageText, "0.31.
|
|
156941
|
+
return computeFingerprint(firstMessageText, "0.31.2-by-rayss");
|
|
156942
156942
|
}
|
|
156943
156943
|
var FINGERPRINT_SALT = "59cf53e54c78";
|
|
156944
156944
|
var init_fingerprint = () => {};
|
|
@@ -158305,7 +158305,7 @@ var init_client2 = __esm(() => {
|
|
|
158305
158305
|
const client = new Client({
|
|
158306
158306
|
name: "claude-code",
|
|
158307
158307
|
title: "OpenClaude",
|
|
158308
|
-
version: "0.31.
|
|
158308
|
+
version: "0.31.2-by-rayss",
|
|
158309
158309
|
description: "OpenClaude — coding-agent CLI for any LLM provider",
|
|
158310
158310
|
websiteUrl: PRODUCT_URL
|
|
158311
158311
|
}, {
|
|
@@ -168431,6 +168431,1283 @@ function parseSlashCommand(input) {
|
|
|
168431
168431
|
};
|
|
168432
168432
|
}
|
|
168433
168433
|
|
|
168434
|
+
// node_modules/fuse.js/dist/fuse.mjs
|
|
168435
|
+
function isArray3(value) {
|
|
168436
|
+
return !Array.isArray ? getTag2(value) === "[object Array]" : Array.isArray(value);
|
|
168437
|
+
}
|
|
168438
|
+
function baseToString2(value) {
|
|
168439
|
+
if (typeof value == "string") {
|
|
168440
|
+
return value;
|
|
168441
|
+
}
|
|
168442
|
+
let result = value + "";
|
|
168443
|
+
return result == "0" && 1 / value == -INFINITY4 ? "-0" : result;
|
|
168444
|
+
}
|
|
168445
|
+
function toString5(value) {
|
|
168446
|
+
return value == null ? "" : baseToString2(value);
|
|
168447
|
+
}
|
|
168448
|
+
function isString2(value) {
|
|
168449
|
+
return typeof value === "string";
|
|
168450
|
+
}
|
|
168451
|
+
function isNumber2(value) {
|
|
168452
|
+
return typeof value === "number";
|
|
168453
|
+
}
|
|
168454
|
+
function isBoolean2(value) {
|
|
168455
|
+
return value === true || value === false || isObjectLike2(value) && getTag2(value) == "[object Boolean]";
|
|
168456
|
+
}
|
|
168457
|
+
function isObject5(value) {
|
|
168458
|
+
return typeof value === "object";
|
|
168459
|
+
}
|
|
168460
|
+
function isObjectLike2(value) {
|
|
168461
|
+
return isObject5(value) && value !== null;
|
|
168462
|
+
}
|
|
168463
|
+
function isDefined(value) {
|
|
168464
|
+
return value !== undefined && value !== null;
|
|
168465
|
+
}
|
|
168466
|
+
function isBlank(value) {
|
|
168467
|
+
return !value.trim().length;
|
|
168468
|
+
}
|
|
168469
|
+
function getTag2(value) {
|
|
168470
|
+
return value == null ? value === undefined ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(value);
|
|
168471
|
+
}
|
|
168472
|
+
|
|
168473
|
+
class KeyStore {
|
|
168474
|
+
constructor(keys2) {
|
|
168475
|
+
this._keys = [];
|
|
168476
|
+
this._keyMap = {};
|
|
168477
|
+
let totalWeight = 0;
|
|
168478
|
+
keys2.forEach((key) => {
|
|
168479
|
+
let obj = createKey(key);
|
|
168480
|
+
this._keys.push(obj);
|
|
168481
|
+
this._keyMap[obj.id] = obj;
|
|
168482
|
+
totalWeight += obj.weight;
|
|
168483
|
+
});
|
|
168484
|
+
this._keys.forEach((key) => {
|
|
168485
|
+
key.weight /= totalWeight;
|
|
168486
|
+
});
|
|
168487
|
+
}
|
|
168488
|
+
get(keyId) {
|
|
168489
|
+
return this._keyMap[keyId];
|
|
168490
|
+
}
|
|
168491
|
+
keys() {
|
|
168492
|
+
return this._keys;
|
|
168493
|
+
}
|
|
168494
|
+
toJSON() {
|
|
168495
|
+
return JSON.stringify(this._keys);
|
|
168496
|
+
}
|
|
168497
|
+
}
|
|
168498
|
+
function createKey(key) {
|
|
168499
|
+
let path11 = null;
|
|
168500
|
+
let id = null;
|
|
168501
|
+
let src = null;
|
|
168502
|
+
let weight = 1;
|
|
168503
|
+
let getFn = null;
|
|
168504
|
+
if (isString2(key) || isArray3(key)) {
|
|
168505
|
+
src = key;
|
|
168506
|
+
path11 = createKeyPath(key);
|
|
168507
|
+
id = createKeyId(key);
|
|
168508
|
+
} else {
|
|
168509
|
+
if (!hasOwn.call(key, "name")) {
|
|
168510
|
+
throw new Error(MISSING_KEY_PROPERTY("name"));
|
|
168511
|
+
}
|
|
168512
|
+
const name = key.name;
|
|
168513
|
+
src = name;
|
|
168514
|
+
if (hasOwn.call(key, "weight")) {
|
|
168515
|
+
weight = key.weight;
|
|
168516
|
+
if (weight <= 0) {
|
|
168517
|
+
throw new Error(INVALID_KEY_WEIGHT_VALUE(name));
|
|
168518
|
+
}
|
|
168519
|
+
}
|
|
168520
|
+
path11 = createKeyPath(name);
|
|
168521
|
+
id = createKeyId(name);
|
|
168522
|
+
getFn = key.getFn;
|
|
168523
|
+
}
|
|
168524
|
+
return { path: path11, id, weight, src, getFn };
|
|
168525
|
+
}
|
|
168526
|
+
function createKeyPath(key) {
|
|
168527
|
+
return isArray3(key) ? key : key.split(".");
|
|
168528
|
+
}
|
|
168529
|
+
function createKeyId(key) {
|
|
168530
|
+
return isArray3(key) ? key.join(".") : key;
|
|
168531
|
+
}
|
|
168532
|
+
function get2(obj, path11) {
|
|
168533
|
+
let list2 = [];
|
|
168534
|
+
let arr = false;
|
|
168535
|
+
const deepGet = (obj2, path12, index) => {
|
|
168536
|
+
if (!isDefined(obj2)) {
|
|
168537
|
+
return;
|
|
168538
|
+
}
|
|
168539
|
+
if (!path12[index]) {
|
|
168540
|
+
list2.push(obj2);
|
|
168541
|
+
} else {
|
|
168542
|
+
let key = path12[index];
|
|
168543
|
+
const value = obj2[key];
|
|
168544
|
+
if (!isDefined(value)) {
|
|
168545
|
+
return;
|
|
168546
|
+
}
|
|
168547
|
+
if (index === path12.length - 1 && (isString2(value) || isNumber2(value) || isBoolean2(value))) {
|
|
168548
|
+
list2.push(toString5(value));
|
|
168549
|
+
} else if (isArray3(value)) {
|
|
168550
|
+
arr = true;
|
|
168551
|
+
for (let i3 = 0, len = value.length;i3 < len; i3 += 1) {
|
|
168552
|
+
deepGet(value[i3], path12, index + 1);
|
|
168553
|
+
}
|
|
168554
|
+
} else if (path12.length) {
|
|
168555
|
+
deepGet(value, path12, index + 1);
|
|
168556
|
+
}
|
|
168557
|
+
}
|
|
168558
|
+
};
|
|
168559
|
+
deepGet(obj, isString2(path11) ? path11.split(".") : path11, 0);
|
|
168560
|
+
return arr ? list2 : list2[0];
|
|
168561
|
+
}
|
|
168562
|
+
function norm(weight = 1, mantissa = 3) {
|
|
168563
|
+
const cache = new Map;
|
|
168564
|
+
const m = Math.pow(10, mantissa);
|
|
168565
|
+
return {
|
|
168566
|
+
get(value) {
|
|
168567
|
+
const numTokens = value.match(SPACE).length;
|
|
168568
|
+
if (cache.has(numTokens)) {
|
|
168569
|
+
return cache.get(numTokens);
|
|
168570
|
+
}
|
|
168571
|
+
const norm2 = 1 / Math.pow(numTokens, 0.5 * weight);
|
|
168572
|
+
const n2 = parseFloat(Math.round(norm2 * m) / m);
|
|
168573
|
+
cache.set(numTokens, n2);
|
|
168574
|
+
return n2;
|
|
168575
|
+
},
|
|
168576
|
+
clear() {
|
|
168577
|
+
cache.clear();
|
|
168578
|
+
}
|
|
168579
|
+
};
|
|
168580
|
+
}
|
|
168581
|
+
|
|
168582
|
+
class FuseIndex {
|
|
168583
|
+
constructor({
|
|
168584
|
+
getFn = Config.getFn,
|
|
168585
|
+
fieldNormWeight = Config.fieldNormWeight
|
|
168586
|
+
} = {}) {
|
|
168587
|
+
this.norm = norm(fieldNormWeight, 3);
|
|
168588
|
+
this.getFn = getFn;
|
|
168589
|
+
this.isCreated = false;
|
|
168590
|
+
this.setIndexRecords();
|
|
168591
|
+
}
|
|
168592
|
+
setSources(docs = []) {
|
|
168593
|
+
this.docs = docs;
|
|
168594
|
+
}
|
|
168595
|
+
setIndexRecords(records = []) {
|
|
168596
|
+
this.records = records;
|
|
168597
|
+
}
|
|
168598
|
+
setKeys(keys2 = []) {
|
|
168599
|
+
this.keys = keys2;
|
|
168600
|
+
this._keysMap = {};
|
|
168601
|
+
keys2.forEach((key, idx) => {
|
|
168602
|
+
this._keysMap[key.id] = idx;
|
|
168603
|
+
});
|
|
168604
|
+
}
|
|
168605
|
+
create() {
|
|
168606
|
+
if (this.isCreated || !this.docs.length) {
|
|
168607
|
+
return;
|
|
168608
|
+
}
|
|
168609
|
+
this.isCreated = true;
|
|
168610
|
+
if (isString2(this.docs[0])) {
|
|
168611
|
+
this.docs.forEach((doc2, docIndex) => {
|
|
168612
|
+
this._addString(doc2, docIndex);
|
|
168613
|
+
});
|
|
168614
|
+
} else {
|
|
168615
|
+
this.docs.forEach((doc2, docIndex) => {
|
|
168616
|
+
this._addObject(doc2, docIndex);
|
|
168617
|
+
});
|
|
168618
|
+
}
|
|
168619
|
+
this.norm.clear();
|
|
168620
|
+
}
|
|
168621
|
+
add(doc2) {
|
|
168622
|
+
const idx = this.size();
|
|
168623
|
+
if (isString2(doc2)) {
|
|
168624
|
+
this._addString(doc2, idx);
|
|
168625
|
+
} else {
|
|
168626
|
+
this._addObject(doc2, idx);
|
|
168627
|
+
}
|
|
168628
|
+
}
|
|
168629
|
+
removeAt(idx) {
|
|
168630
|
+
this.records.splice(idx, 1);
|
|
168631
|
+
for (let i3 = idx, len = this.size();i3 < len; i3 += 1) {
|
|
168632
|
+
this.records[i3].i -= 1;
|
|
168633
|
+
}
|
|
168634
|
+
}
|
|
168635
|
+
getValueForItemAtKeyId(item, keyId) {
|
|
168636
|
+
return item[this._keysMap[keyId]];
|
|
168637
|
+
}
|
|
168638
|
+
size() {
|
|
168639
|
+
return this.records.length;
|
|
168640
|
+
}
|
|
168641
|
+
_addString(doc2, docIndex) {
|
|
168642
|
+
if (!isDefined(doc2) || isBlank(doc2)) {
|
|
168643
|
+
return;
|
|
168644
|
+
}
|
|
168645
|
+
let record2 = {
|
|
168646
|
+
v: doc2,
|
|
168647
|
+
i: docIndex,
|
|
168648
|
+
n: this.norm.get(doc2)
|
|
168649
|
+
};
|
|
168650
|
+
this.records.push(record2);
|
|
168651
|
+
}
|
|
168652
|
+
_addObject(doc2, docIndex) {
|
|
168653
|
+
let record2 = { i: docIndex, $: {} };
|
|
168654
|
+
this.keys.forEach((key, keyIndex) => {
|
|
168655
|
+
let value = key.getFn ? key.getFn(doc2) : this.getFn(doc2, key.path);
|
|
168656
|
+
if (!isDefined(value)) {
|
|
168657
|
+
return;
|
|
168658
|
+
}
|
|
168659
|
+
if (isArray3(value)) {
|
|
168660
|
+
let subRecords = [];
|
|
168661
|
+
const stack = [{ nestedArrIndex: -1, value }];
|
|
168662
|
+
while (stack.length) {
|
|
168663
|
+
const { nestedArrIndex, value: value2 } = stack.pop();
|
|
168664
|
+
if (!isDefined(value2)) {
|
|
168665
|
+
continue;
|
|
168666
|
+
}
|
|
168667
|
+
if (isString2(value2) && !isBlank(value2)) {
|
|
168668
|
+
let subRecord = {
|
|
168669
|
+
v: value2,
|
|
168670
|
+
i: nestedArrIndex,
|
|
168671
|
+
n: this.norm.get(value2)
|
|
168672
|
+
};
|
|
168673
|
+
subRecords.push(subRecord);
|
|
168674
|
+
} else if (isArray3(value2)) {
|
|
168675
|
+
value2.forEach((item, k) => {
|
|
168676
|
+
stack.push({
|
|
168677
|
+
nestedArrIndex: k,
|
|
168678
|
+
value: item
|
|
168679
|
+
});
|
|
168680
|
+
});
|
|
168681
|
+
}
|
|
168682
|
+
}
|
|
168683
|
+
record2.$[keyIndex] = subRecords;
|
|
168684
|
+
} else if (isString2(value) && !isBlank(value)) {
|
|
168685
|
+
let subRecord = {
|
|
168686
|
+
v: value,
|
|
168687
|
+
n: this.norm.get(value)
|
|
168688
|
+
};
|
|
168689
|
+
record2.$[keyIndex] = subRecord;
|
|
168690
|
+
}
|
|
168691
|
+
});
|
|
168692
|
+
this.records.push(record2);
|
|
168693
|
+
}
|
|
168694
|
+
toJSON() {
|
|
168695
|
+
return {
|
|
168696
|
+
keys: this.keys,
|
|
168697
|
+
records: this.records
|
|
168698
|
+
};
|
|
168699
|
+
}
|
|
168700
|
+
}
|
|
168701
|
+
function createIndex(keys2, docs, { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}) {
|
|
168702
|
+
const myIndex = new FuseIndex({ getFn, fieldNormWeight });
|
|
168703
|
+
myIndex.setKeys(keys2.map(createKey));
|
|
168704
|
+
myIndex.setSources(docs);
|
|
168705
|
+
myIndex.create();
|
|
168706
|
+
return myIndex;
|
|
168707
|
+
}
|
|
168708
|
+
function parseIndex(data, { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}) {
|
|
168709
|
+
const { keys: keys2, records } = data;
|
|
168710
|
+
const myIndex = new FuseIndex({ getFn, fieldNormWeight });
|
|
168711
|
+
myIndex.setKeys(keys2);
|
|
168712
|
+
myIndex.setIndexRecords(records);
|
|
168713
|
+
return myIndex;
|
|
168714
|
+
}
|
|
168715
|
+
function computeScore$1(pattern, {
|
|
168716
|
+
errors: errors3 = 0,
|
|
168717
|
+
currentLocation = 0,
|
|
168718
|
+
expectedLocation = 0,
|
|
168719
|
+
distance = Config.distance,
|
|
168720
|
+
ignoreLocation = Config.ignoreLocation
|
|
168721
|
+
} = {}) {
|
|
168722
|
+
const accuracy = errors3 / pattern.length;
|
|
168723
|
+
if (ignoreLocation) {
|
|
168724
|
+
return accuracy;
|
|
168725
|
+
}
|
|
168726
|
+
const proximity = Math.abs(expectedLocation - currentLocation);
|
|
168727
|
+
if (!distance) {
|
|
168728
|
+
return proximity ? 1 : accuracy;
|
|
168729
|
+
}
|
|
168730
|
+
return accuracy + proximity / distance;
|
|
168731
|
+
}
|
|
168732
|
+
function convertMaskToIndices(matchmask = [], minMatchCharLength = Config.minMatchCharLength) {
|
|
168733
|
+
let indices = [];
|
|
168734
|
+
let start = -1;
|
|
168735
|
+
let end = -1;
|
|
168736
|
+
let i3 = 0;
|
|
168737
|
+
for (let len = matchmask.length;i3 < len; i3 += 1) {
|
|
168738
|
+
let match = matchmask[i3];
|
|
168739
|
+
if (match && start === -1) {
|
|
168740
|
+
start = i3;
|
|
168741
|
+
} else if (!match && start !== -1) {
|
|
168742
|
+
end = i3 - 1;
|
|
168743
|
+
if (end - start + 1 >= minMatchCharLength) {
|
|
168744
|
+
indices.push([start, end]);
|
|
168745
|
+
}
|
|
168746
|
+
start = -1;
|
|
168747
|
+
}
|
|
168748
|
+
}
|
|
168749
|
+
if (matchmask[i3 - 1] && i3 - start >= minMatchCharLength) {
|
|
168750
|
+
indices.push([start, i3 - 1]);
|
|
168751
|
+
}
|
|
168752
|
+
return indices;
|
|
168753
|
+
}
|
|
168754
|
+
function search(text, pattern, patternAlphabet, {
|
|
168755
|
+
location = Config.location,
|
|
168756
|
+
distance = Config.distance,
|
|
168757
|
+
threshold = Config.threshold,
|
|
168758
|
+
findAllMatches = Config.findAllMatches,
|
|
168759
|
+
minMatchCharLength = Config.minMatchCharLength,
|
|
168760
|
+
includeMatches = Config.includeMatches,
|
|
168761
|
+
ignoreLocation = Config.ignoreLocation
|
|
168762
|
+
} = {}) {
|
|
168763
|
+
if (pattern.length > MAX_BITS) {
|
|
168764
|
+
throw new Error(PATTERN_LENGTH_TOO_LARGE(MAX_BITS));
|
|
168765
|
+
}
|
|
168766
|
+
const patternLen = pattern.length;
|
|
168767
|
+
const textLen = text.length;
|
|
168768
|
+
const expectedLocation = Math.max(0, Math.min(location, textLen));
|
|
168769
|
+
let currentThreshold = threshold;
|
|
168770
|
+
let bestLocation = expectedLocation;
|
|
168771
|
+
const computeMatches = minMatchCharLength > 1 || includeMatches;
|
|
168772
|
+
const matchMask = computeMatches ? Array(textLen) : [];
|
|
168773
|
+
let index;
|
|
168774
|
+
while ((index = text.indexOf(pattern, bestLocation)) > -1) {
|
|
168775
|
+
let score = computeScore$1(pattern, {
|
|
168776
|
+
currentLocation: index,
|
|
168777
|
+
expectedLocation,
|
|
168778
|
+
distance,
|
|
168779
|
+
ignoreLocation
|
|
168780
|
+
});
|
|
168781
|
+
currentThreshold = Math.min(score, currentThreshold);
|
|
168782
|
+
bestLocation = index + patternLen;
|
|
168783
|
+
if (computeMatches) {
|
|
168784
|
+
let i3 = 0;
|
|
168785
|
+
while (i3 < patternLen) {
|
|
168786
|
+
matchMask[index + i3] = 1;
|
|
168787
|
+
i3 += 1;
|
|
168788
|
+
}
|
|
168789
|
+
}
|
|
168790
|
+
}
|
|
168791
|
+
bestLocation = -1;
|
|
168792
|
+
let lastBitArr = [];
|
|
168793
|
+
let finalScore = 1;
|
|
168794
|
+
let binMax = patternLen + textLen;
|
|
168795
|
+
const mask = 1 << patternLen - 1;
|
|
168796
|
+
for (let i3 = 0;i3 < patternLen; i3 += 1) {
|
|
168797
|
+
let binMin = 0;
|
|
168798
|
+
let binMid = binMax;
|
|
168799
|
+
while (binMin < binMid) {
|
|
168800
|
+
const score2 = computeScore$1(pattern, {
|
|
168801
|
+
errors: i3,
|
|
168802
|
+
currentLocation: expectedLocation + binMid,
|
|
168803
|
+
expectedLocation,
|
|
168804
|
+
distance,
|
|
168805
|
+
ignoreLocation
|
|
168806
|
+
});
|
|
168807
|
+
if (score2 <= currentThreshold) {
|
|
168808
|
+
binMin = binMid;
|
|
168809
|
+
} else {
|
|
168810
|
+
binMax = binMid;
|
|
168811
|
+
}
|
|
168812
|
+
binMid = Math.floor((binMax - binMin) / 2 + binMin);
|
|
168813
|
+
}
|
|
168814
|
+
binMax = binMid;
|
|
168815
|
+
let start = Math.max(1, expectedLocation - binMid + 1);
|
|
168816
|
+
let finish = findAllMatches ? textLen : Math.min(expectedLocation + binMid, textLen) + patternLen;
|
|
168817
|
+
let bitArr = Array(finish + 2);
|
|
168818
|
+
bitArr[finish + 1] = (1 << i3) - 1;
|
|
168819
|
+
for (let j = finish;j >= start; j -= 1) {
|
|
168820
|
+
let currentLocation = j - 1;
|
|
168821
|
+
let charMatch = patternAlphabet[text.charAt(currentLocation)];
|
|
168822
|
+
if (computeMatches) {
|
|
168823
|
+
matchMask[currentLocation] = +!!charMatch;
|
|
168824
|
+
}
|
|
168825
|
+
bitArr[j] = (bitArr[j + 1] << 1 | 1) & charMatch;
|
|
168826
|
+
if (i3) {
|
|
168827
|
+
bitArr[j] |= (lastBitArr[j + 1] | lastBitArr[j]) << 1 | 1 | lastBitArr[j + 1];
|
|
168828
|
+
}
|
|
168829
|
+
if (bitArr[j] & mask) {
|
|
168830
|
+
finalScore = computeScore$1(pattern, {
|
|
168831
|
+
errors: i3,
|
|
168832
|
+
currentLocation,
|
|
168833
|
+
expectedLocation,
|
|
168834
|
+
distance,
|
|
168835
|
+
ignoreLocation
|
|
168836
|
+
});
|
|
168837
|
+
if (finalScore <= currentThreshold) {
|
|
168838
|
+
currentThreshold = finalScore;
|
|
168839
|
+
bestLocation = currentLocation;
|
|
168840
|
+
if (bestLocation <= expectedLocation) {
|
|
168841
|
+
break;
|
|
168842
|
+
}
|
|
168843
|
+
start = Math.max(1, 2 * expectedLocation - bestLocation);
|
|
168844
|
+
}
|
|
168845
|
+
}
|
|
168846
|
+
}
|
|
168847
|
+
const score = computeScore$1(pattern, {
|
|
168848
|
+
errors: i3 + 1,
|
|
168849
|
+
currentLocation: expectedLocation,
|
|
168850
|
+
expectedLocation,
|
|
168851
|
+
distance,
|
|
168852
|
+
ignoreLocation
|
|
168853
|
+
});
|
|
168854
|
+
if (score > currentThreshold) {
|
|
168855
|
+
break;
|
|
168856
|
+
}
|
|
168857
|
+
lastBitArr = bitArr;
|
|
168858
|
+
}
|
|
168859
|
+
const result = {
|
|
168860
|
+
isMatch: bestLocation >= 0,
|
|
168861
|
+
score: Math.max(0.001, finalScore)
|
|
168862
|
+
};
|
|
168863
|
+
if (computeMatches) {
|
|
168864
|
+
const indices = convertMaskToIndices(matchMask, minMatchCharLength);
|
|
168865
|
+
if (!indices.length) {
|
|
168866
|
+
result.isMatch = false;
|
|
168867
|
+
} else if (includeMatches) {
|
|
168868
|
+
result.indices = indices;
|
|
168869
|
+
}
|
|
168870
|
+
}
|
|
168871
|
+
return result;
|
|
168872
|
+
}
|
|
168873
|
+
function createPatternAlphabet(pattern) {
|
|
168874
|
+
let mask = {};
|
|
168875
|
+
for (let i3 = 0, len = pattern.length;i3 < len; i3 += 1) {
|
|
168876
|
+
const char = pattern.charAt(i3);
|
|
168877
|
+
mask[char] = (mask[char] || 0) | 1 << len - i3 - 1;
|
|
168878
|
+
}
|
|
168879
|
+
return mask;
|
|
168880
|
+
}
|
|
168881
|
+
|
|
168882
|
+
class BitapSearch {
|
|
168883
|
+
constructor(pattern, {
|
|
168884
|
+
location = Config.location,
|
|
168885
|
+
threshold = Config.threshold,
|
|
168886
|
+
distance = Config.distance,
|
|
168887
|
+
includeMatches = Config.includeMatches,
|
|
168888
|
+
findAllMatches = Config.findAllMatches,
|
|
168889
|
+
minMatchCharLength = Config.minMatchCharLength,
|
|
168890
|
+
isCaseSensitive = Config.isCaseSensitive,
|
|
168891
|
+
ignoreDiacritics = Config.ignoreDiacritics,
|
|
168892
|
+
ignoreLocation = Config.ignoreLocation
|
|
168893
|
+
} = {}) {
|
|
168894
|
+
this.options = {
|
|
168895
|
+
location,
|
|
168896
|
+
threshold,
|
|
168897
|
+
distance,
|
|
168898
|
+
includeMatches,
|
|
168899
|
+
findAllMatches,
|
|
168900
|
+
minMatchCharLength,
|
|
168901
|
+
isCaseSensitive,
|
|
168902
|
+
ignoreDiacritics,
|
|
168903
|
+
ignoreLocation
|
|
168904
|
+
};
|
|
168905
|
+
pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
|
|
168906
|
+
pattern = ignoreDiacritics ? stripDiacritics(pattern) : pattern;
|
|
168907
|
+
this.pattern = pattern;
|
|
168908
|
+
this.chunks = [];
|
|
168909
|
+
if (!this.pattern.length) {
|
|
168910
|
+
return;
|
|
168911
|
+
}
|
|
168912
|
+
const addChunk = (pattern2, startIndex) => {
|
|
168913
|
+
this.chunks.push({
|
|
168914
|
+
pattern: pattern2,
|
|
168915
|
+
alphabet: createPatternAlphabet(pattern2),
|
|
168916
|
+
startIndex
|
|
168917
|
+
});
|
|
168918
|
+
};
|
|
168919
|
+
const len = this.pattern.length;
|
|
168920
|
+
if (len > MAX_BITS) {
|
|
168921
|
+
let i3 = 0;
|
|
168922
|
+
const remainder = len % MAX_BITS;
|
|
168923
|
+
const end = len - remainder;
|
|
168924
|
+
while (i3 < end) {
|
|
168925
|
+
addChunk(this.pattern.substr(i3, MAX_BITS), i3);
|
|
168926
|
+
i3 += MAX_BITS;
|
|
168927
|
+
}
|
|
168928
|
+
if (remainder) {
|
|
168929
|
+
const startIndex = len - MAX_BITS;
|
|
168930
|
+
addChunk(this.pattern.substr(startIndex), startIndex);
|
|
168931
|
+
}
|
|
168932
|
+
} else {
|
|
168933
|
+
addChunk(this.pattern, 0);
|
|
168934
|
+
}
|
|
168935
|
+
}
|
|
168936
|
+
searchIn(text) {
|
|
168937
|
+
const { isCaseSensitive, ignoreDiacritics, includeMatches } = this.options;
|
|
168938
|
+
text = isCaseSensitive ? text : text.toLowerCase();
|
|
168939
|
+
text = ignoreDiacritics ? stripDiacritics(text) : text;
|
|
168940
|
+
if (this.pattern === text) {
|
|
168941
|
+
let result2 = {
|
|
168942
|
+
isMatch: true,
|
|
168943
|
+
score: 0
|
|
168944
|
+
};
|
|
168945
|
+
if (includeMatches) {
|
|
168946
|
+
result2.indices = [[0, text.length - 1]];
|
|
168947
|
+
}
|
|
168948
|
+
return result2;
|
|
168949
|
+
}
|
|
168950
|
+
const {
|
|
168951
|
+
location,
|
|
168952
|
+
distance,
|
|
168953
|
+
threshold,
|
|
168954
|
+
findAllMatches,
|
|
168955
|
+
minMatchCharLength,
|
|
168956
|
+
ignoreLocation
|
|
168957
|
+
} = this.options;
|
|
168958
|
+
let allIndices = [];
|
|
168959
|
+
let totalScore = 0;
|
|
168960
|
+
let hasMatches = false;
|
|
168961
|
+
this.chunks.forEach(({ pattern, alphabet, startIndex }) => {
|
|
168962
|
+
const { isMatch, score, indices } = search(text, pattern, alphabet, {
|
|
168963
|
+
location: location + startIndex,
|
|
168964
|
+
distance,
|
|
168965
|
+
threshold,
|
|
168966
|
+
findAllMatches,
|
|
168967
|
+
minMatchCharLength,
|
|
168968
|
+
includeMatches,
|
|
168969
|
+
ignoreLocation
|
|
168970
|
+
});
|
|
168971
|
+
if (isMatch) {
|
|
168972
|
+
hasMatches = true;
|
|
168973
|
+
}
|
|
168974
|
+
totalScore += score;
|
|
168975
|
+
if (isMatch && indices) {
|
|
168976
|
+
allIndices = [...allIndices, ...indices];
|
|
168977
|
+
}
|
|
168978
|
+
});
|
|
168979
|
+
let result = {
|
|
168980
|
+
isMatch: hasMatches,
|
|
168981
|
+
score: hasMatches ? totalScore / this.chunks.length : 1
|
|
168982
|
+
};
|
|
168983
|
+
if (hasMatches && includeMatches) {
|
|
168984
|
+
result.indices = allIndices;
|
|
168985
|
+
}
|
|
168986
|
+
return result;
|
|
168987
|
+
}
|
|
168988
|
+
}
|
|
168989
|
+
|
|
168990
|
+
class BaseMatch {
|
|
168991
|
+
constructor(pattern) {
|
|
168992
|
+
this.pattern = pattern;
|
|
168993
|
+
}
|
|
168994
|
+
static isMultiMatch(pattern) {
|
|
168995
|
+
return getMatch(pattern, this.multiRegex);
|
|
168996
|
+
}
|
|
168997
|
+
static isSingleMatch(pattern) {
|
|
168998
|
+
return getMatch(pattern, this.singleRegex);
|
|
168999
|
+
}
|
|
169000
|
+
search() {}
|
|
169001
|
+
}
|
|
169002
|
+
function getMatch(pattern, exp) {
|
|
169003
|
+
const matches = pattern.match(exp);
|
|
169004
|
+
return matches ? matches[1] : null;
|
|
169005
|
+
}
|
|
169006
|
+
function parseQuery(pattern, options2 = {}) {
|
|
169007
|
+
return pattern.split(OR_TOKEN).map((item) => {
|
|
169008
|
+
let query2 = item.trim().split(SPACE_RE).filter((item2) => item2 && !!item2.trim());
|
|
169009
|
+
let results = [];
|
|
169010
|
+
for (let i3 = 0, len = query2.length;i3 < len; i3 += 1) {
|
|
169011
|
+
const queryItem = query2[i3];
|
|
169012
|
+
let found = false;
|
|
169013
|
+
let idx = -1;
|
|
169014
|
+
while (!found && ++idx < searchersLen) {
|
|
169015
|
+
const searcher = searchers[idx];
|
|
169016
|
+
let token = searcher.isMultiMatch(queryItem);
|
|
169017
|
+
if (token) {
|
|
169018
|
+
results.push(new searcher(token, options2));
|
|
169019
|
+
found = true;
|
|
169020
|
+
}
|
|
169021
|
+
}
|
|
169022
|
+
if (found) {
|
|
169023
|
+
continue;
|
|
169024
|
+
}
|
|
169025
|
+
idx = -1;
|
|
169026
|
+
while (++idx < searchersLen) {
|
|
169027
|
+
const searcher = searchers[idx];
|
|
169028
|
+
let token = searcher.isSingleMatch(queryItem);
|
|
169029
|
+
if (token) {
|
|
169030
|
+
results.push(new searcher(token, options2));
|
|
169031
|
+
break;
|
|
169032
|
+
}
|
|
169033
|
+
}
|
|
169034
|
+
}
|
|
169035
|
+
return results;
|
|
169036
|
+
});
|
|
169037
|
+
}
|
|
169038
|
+
|
|
169039
|
+
class ExtendedSearch {
|
|
169040
|
+
constructor(pattern, {
|
|
169041
|
+
isCaseSensitive = Config.isCaseSensitive,
|
|
169042
|
+
ignoreDiacritics = Config.ignoreDiacritics,
|
|
169043
|
+
includeMatches = Config.includeMatches,
|
|
169044
|
+
minMatchCharLength = Config.minMatchCharLength,
|
|
169045
|
+
ignoreLocation = Config.ignoreLocation,
|
|
169046
|
+
findAllMatches = Config.findAllMatches,
|
|
169047
|
+
location = Config.location,
|
|
169048
|
+
threshold = Config.threshold,
|
|
169049
|
+
distance = Config.distance
|
|
169050
|
+
} = {}) {
|
|
169051
|
+
this.query = null;
|
|
169052
|
+
this.options = {
|
|
169053
|
+
isCaseSensitive,
|
|
169054
|
+
ignoreDiacritics,
|
|
169055
|
+
includeMatches,
|
|
169056
|
+
minMatchCharLength,
|
|
169057
|
+
findAllMatches,
|
|
169058
|
+
ignoreLocation,
|
|
169059
|
+
location,
|
|
169060
|
+
threshold,
|
|
169061
|
+
distance
|
|
169062
|
+
};
|
|
169063
|
+
pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
|
|
169064
|
+
pattern = ignoreDiacritics ? stripDiacritics(pattern) : pattern;
|
|
169065
|
+
this.pattern = pattern;
|
|
169066
|
+
this.query = parseQuery(this.pattern, this.options);
|
|
169067
|
+
}
|
|
169068
|
+
static condition(_, options2) {
|
|
169069
|
+
return options2.useExtendedSearch;
|
|
169070
|
+
}
|
|
169071
|
+
searchIn(text) {
|
|
169072
|
+
const query2 = this.query;
|
|
169073
|
+
if (!query2) {
|
|
169074
|
+
return {
|
|
169075
|
+
isMatch: false,
|
|
169076
|
+
score: 1
|
|
169077
|
+
};
|
|
169078
|
+
}
|
|
169079
|
+
const { includeMatches, isCaseSensitive, ignoreDiacritics } = this.options;
|
|
169080
|
+
text = isCaseSensitive ? text : text.toLowerCase();
|
|
169081
|
+
text = ignoreDiacritics ? stripDiacritics(text) : text;
|
|
169082
|
+
let numMatches = 0;
|
|
169083
|
+
let allIndices = [];
|
|
169084
|
+
let totalScore = 0;
|
|
169085
|
+
for (let i3 = 0, qLen = query2.length;i3 < qLen; i3 += 1) {
|
|
169086
|
+
const searchers2 = query2[i3];
|
|
169087
|
+
allIndices.length = 0;
|
|
169088
|
+
numMatches = 0;
|
|
169089
|
+
for (let j = 0, pLen = searchers2.length;j < pLen; j += 1) {
|
|
169090
|
+
const searcher = searchers2[j];
|
|
169091
|
+
const { isMatch, indices, score } = searcher.search(text);
|
|
169092
|
+
if (isMatch) {
|
|
169093
|
+
numMatches += 1;
|
|
169094
|
+
totalScore += score;
|
|
169095
|
+
if (includeMatches) {
|
|
169096
|
+
const type = searcher.constructor.type;
|
|
169097
|
+
if (MultiMatchSet.has(type)) {
|
|
169098
|
+
allIndices = [...allIndices, ...indices];
|
|
169099
|
+
} else {
|
|
169100
|
+
allIndices.push(indices);
|
|
169101
|
+
}
|
|
169102
|
+
}
|
|
169103
|
+
} else {
|
|
169104
|
+
totalScore = 0;
|
|
169105
|
+
numMatches = 0;
|
|
169106
|
+
allIndices.length = 0;
|
|
169107
|
+
break;
|
|
169108
|
+
}
|
|
169109
|
+
}
|
|
169110
|
+
if (numMatches) {
|
|
169111
|
+
let result = {
|
|
169112
|
+
isMatch: true,
|
|
169113
|
+
score: totalScore / numMatches
|
|
169114
|
+
};
|
|
169115
|
+
if (includeMatches) {
|
|
169116
|
+
result.indices = allIndices;
|
|
169117
|
+
}
|
|
169118
|
+
return result;
|
|
169119
|
+
}
|
|
169120
|
+
}
|
|
169121
|
+
return {
|
|
169122
|
+
isMatch: false,
|
|
169123
|
+
score: 1
|
|
169124
|
+
};
|
|
169125
|
+
}
|
|
169126
|
+
}
|
|
169127
|
+
function register(...args) {
|
|
169128
|
+
registeredSearchers.push(...args);
|
|
169129
|
+
}
|
|
169130
|
+
function createSearcher(pattern, options2) {
|
|
169131
|
+
for (let i3 = 0, len = registeredSearchers.length;i3 < len; i3 += 1) {
|
|
169132
|
+
let searcherClass = registeredSearchers[i3];
|
|
169133
|
+
if (searcherClass.condition(pattern, options2)) {
|
|
169134
|
+
return new searcherClass(pattern, options2);
|
|
169135
|
+
}
|
|
169136
|
+
}
|
|
169137
|
+
return new BitapSearch(pattern, options2);
|
|
169138
|
+
}
|
|
169139
|
+
function parse9(query2, options2, { auto = true } = {}) {
|
|
169140
|
+
const next = (query3) => {
|
|
169141
|
+
let keys2 = Object.keys(query3);
|
|
169142
|
+
const isQueryPath = isPath(query3);
|
|
169143
|
+
if (!isQueryPath && keys2.length > 1 && !isExpression(query3)) {
|
|
169144
|
+
return next(convertToExplicit(query3));
|
|
169145
|
+
}
|
|
169146
|
+
if (isLeaf(query3)) {
|
|
169147
|
+
const key = isQueryPath ? query3[KeyType.PATH] : keys2[0];
|
|
169148
|
+
const pattern = isQueryPath ? query3[KeyType.PATTERN] : query3[key];
|
|
169149
|
+
if (!isString2(pattern)) {
|
|
169150
|
+
throw new Error(LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key));
|
|
169151
|
+
}
|
|
169152
|
+
const obj = {
|
|
169153
|
+
keyId: createKeyId(key),
|
|
169154
|
+
pattern
|
|
169155
|
+
};
|
|
169156
|
+
if (auto) {
|
|
169157
|
+
obj.searcher = createSearcher(pattern, options2);
|
|
169158
|
+
}
|
|
169159
|
+
return obj;
|
|
169160
|
+
}
|
|
169161
|
+
let node = {
|
|
169162
|
+
children: [],
|
|
169163
|
+
operator: keys2[0]
|
|
169164
|
+
};
|
|
169165
|
+
keys2.forEach((key) => {
|
|
169166
|
+
const value = query3[key];
|
|
169167
|
+
if (isArray3(value)) {
|
|
169168
|
+
value.forEach((item) => {
|
|
169169
|
+
node.children.push(next(item));
|
|
169170
|
+
});
|
|
169171
|
+
}
|
|
169172
|
+
});
|
|
169173
|
+
return node;
|
|
169174
|
+
};
|
|
169175
|
+
if (!isExpression(query2)) {
|
|
169176
|
+
query2 = convertToExplicit(query2);
|
|
169177
|
+
}
|
|
169178
|
+
return next(query2);
|
|
169179
|
+
}
|
|
169180
|
+
function computeScore(results, { ignoreFieldNorm = Config.ignoreFieldNorm }) {
|
|
169181
|
+
results.forEach((result) => {
|
|
169182
|
+
let totalScore = 1;
|
|
169183
|
+
result.matches.forEach(({ key, norm: norm2, score }) => {
|
|
169184
|
+
const weight = key ? key.weight : null;
|
|
169185
|
+
totalScore *= Math.pow(score === 0 && weight ? Number.EPSILON : score, (weight || 1) * (ignoreFieldNorm ? 1 : norm2));
|
|
169186
|
+
});
|
|
169187
|
+
result.score = totalScore;
|
|
169188
|
+
});
|
|
169189
|
+
}
|
|
169190
|
+
function transformMatches(result, data) {
|
|
169191
|
+
const matches = result.matches;
|
|
169192
|
+
data.matches = [];
|
|
169193
|
+
if (!isDefined(matches)) {
|
|
169194
|
+
return;
|
|
169195
|
+
}
|
|
169196
|
+
matches.forEach((match) => {
|
|
169197
|
+
if (!isDefined(match.indices) || !match.indices.length) {
|
|
169198
|
+
return;
|
|
169199
|
+
}
|
|
169200
|
+
const { indices, value } = match;
|
|
169201
|
+
let obj = {
|
|
169202
|
+
indices,
|
|
169203
|
+
value
|
|
169204
|
+
};
|
|
169205
|
+
if (match.key) {
|
|
169206
|
+
obj.key = match.key.src;
|
|
169207
|
+
}
|
|
169208
|
+
if (match.idx > -1) {
|
|
169209
|
+
obj.refIndex = match.idx;
|
|
169210
|
+
}
|
|
169211
|
+
data.matches.push(obj);
|
|
169212
|
+
});
|
|
169213
|
+
}
|
|
169214
|
+
function transformScore(result, data) {
|
|
169215
|
+
data.score = result.score;
|
|
169216
|
+
}
|
|
169217
|
+
function format4(results, docs, {
|
|
169218
|
+
includeMatches = Config.includeMatches,
|
|
169219
|
+
includeScore = Config.includeScore
|
|
169220
|
+
} = {}) {
|
|
169221
|
+
const transformers = [];
|
|
169222
|
+
if (includeMatches)
|
|
169223
|
+
transformers.push(transformMatches);
|
|
169224
|
+
if (includeScore)
|
|
169225
|
+
transformers.push(transformScore);
|
|
169226
|
+
return results.map((result) => {
|
|
169227
|
+
const { idx } = result;
|
|
169228
|
+
const data = {
|
|
169229
|
+
item: docs[idx],
|
|
169230
|
+
refIndex: idx
|
|
169231
|
+
};
|
|
169232
|
+
if (transformers.length) {
|
|
169233
|
+
transformers.forEach((transformer) => {
|
|
169234
|
+
transformer(result, data);
|
|
169235
|
+
});
|
|
169236
|
+
}
|
|
169237
|
+
return data;
|
|
169238
|
+
});
|
|
169239
|
+
}
|
|
169240
|
+
|
|
169241
|
+
class Fuse {
|
|
169242
|
+
constructor(docs, options2 = {}, index) {
|
|
169243
|
+
this.options = { ...Config, ...options2 };
|
|
169244
|
+
if (this.options.useExtendedSearch && false) {}
|
|
169245
|
+
this._keyStore = new KeyStore(this.options.keys);
|
|
169246
|
+
this.setCollection(docs, index);
|
|
169247
|
+
}
|
|
169248
|
+
setCollection(docs, index) {
|
|
169249
|
+
this._docs = docs;
|
|
169250
|
+
if (index && !(index instanceof FuseIndex)) {
|
|
169251
|
+
throw new Error(INCORRECT_INDEX_TYPE);
|
|
169252
|
+
}
|
|
169253
|
+
this._myIndex = index || createIndex(this.options.keys, this._docs, {
|
|
169254
|
+
getFn: this.options.getFn,
|
|
169255
|
+
fieldNormWeight: this.options.fieldNormWeight
|
|
169256
|
+
});
|
|
169257
|
+
}
|
|
169258
|
+
add(doc2) {
|
|
169259
|
+
if (!isDefined(doc2)) {
|
|
169260
|
+
return;
|
|
169261
|
+
}
|
|
169262
|
+
this._docs.push(doc2);
|
|
169263
|
+
this._myIndex.add(doc2);
|
|
169264
|
+
}
|
|
169265
|
+
remove(predicate = () => false) {
|
|
169266
|
+
const results = [];
|
|
169267
|
+
for (let i3 = 0, len = this._docs.length;i3 < len; i3 += 1) {
|
|
169268
|
+
const doc2 = this._docs[i3];
|
|
169269
|
+
if (predicate(doc2, i3)) {
|
|
169270
|
+
this.removeAt(i3);
|
|
169271
|
+
i3 -= 1;
|
|
169272
|
+
len -= 1;
|
|
169273
|
+
results.push(doc2);
|
|
169274
|
+
}
|
|
169275
|
+
}
|
|
169276
|
+
return results;
|
|
169277
|
+
}
|
|
169278
|
+
removeAt(idx) {
|
|
169279
|
+
this._docs.splice(idx, 1);
|
|
169280
|
+
this._myIndex.removeAt(idx);
|
|
169281
|
+
}
|
|
169282
|
+
getIndex() {
|
|
169283
|
+
return this._myIndex;
|
|
169284
|
+
}
|
|
169285
|
+
search(query2, { limit = -1 } = {}) {
|
|
169286
|
+
const {
|
|
169287
|
+
includeMatches,
|
|
169288
|
+
includeScore,
|
|
169289
|
+
shouldSort,
|
|
169290
|
+
sortFn,
|
|
169291
|
+
ignoreFieldNorm
|
|
169292
|
+
} = this.options;
|
|
169293
|
+
let results = isString2(query2) ? isString2(this._docs[0]) ? this._searchStringList(query2) : this._searchObjectList(query2) : this._searchLogical(query2);
|
|
169294
|
+
computeScore(results, { ignoreFieldNorm });
|
|
169295
|
+
if (shouldSort) {
|
|
169296
|
+
results.sort(sortFn);
|
|
169297
|
+
}
|
|
169298
|
+
if (isNumber2(limit) && limit > -1) {
|
|
169299
|
+
results = results.slice(0, limit);
|
|
169300
|
+
}
|
|
169301
|
+
return format4(results, this._docs, {
|
|
169302
|
+
includeMatches,
|
|
169303
|
+
includeScore
|
|
169304
|
+
});
|
|
169305
|
+
}
|
|
169306
|
+
_searchStringList(query2) {
|
|
169307
|
+
const searcher = createSearcher(query2, this.options);
|
|
169308
|
+
const { records } = this._myIndex;
|
|
169309
|
+
const results = [];
|
|
169310
|
+
records.forEach(({ v: text, i: idx, n: norm2 }) => {
|
|
169311
|
+
if (!isDefined(text)) {
|
|
169312
|
+
return;
|
|
169313
|
+
}
|
|
169314
|
+
const { isMatch, score, indices } = searcher.searchIn(text);
|
|
169315
|
+
if (isMatch) {
|
|
169316
|
+
results.push({
|
|
169317
|
+
item: text,
|
|
169318
|
+
idx,
|
|
169319
|
+
matches: [{ score, value: text, norm: norm2, indices }]
|
|
169320
|
+
});
|
|
169321
|
+
}
|
|
169322
|
+
});
|
|
169323
|
+
return results;
|
|
169324
|
+
}
|
|
169325
|
+
_searchLogical(query2) {
|
|
169326
|
+
const expression = parse9(query2, this.options);
|
|
169327
|
+
const evaluate = (node, item, idx) => {
|
|
169328
|
+
if (!node.children) {
|
|
169329
|
+
const { keyId, searcher } = node;
|
|
169330
|
+
const matches = this._findMatches({
|
|
169331
|
+
key: this._keyStore.get(keyId),
|
|
169332
|
+
value: this._myIndex.getValueForItemAtKeyId(item, keyId),
|
|
169333
|
+
searcher
|
|
169334
|
+
});
|
|
169335
|
+
if (matches && matches.length) {
|
|
169336
|
+
return [
|
|
169337
|
+
{
|
|
169338
|
+
idx,
|
|
169339
|
+
item,
|
|
169340
|
+
matches
|
|
169341
|
+
}
|
|
169342
|
+
];
|
|
169343
|
+
}
|
|
169344
|
+
return [];
|
|
169345
|
+
}
|
|
169346
|
+
const res = [];
|
|
169347
|
+
for (let i3 = 0, len = node.children.length;i3 < len; i3 += 1) {
|
|
169348
|
+
const child = node.children[i3];
|
|
169349
|
+
const result = evaluate(child, item, idx);
|
|
169350
|
+
if (result.length) {
|
|
169351
|
+
res.push(...result);
|
|
169352
|
+
} else if (node.operator === LogicalOperator.AND) {
|
|
169353
|
+
return [];
|
|
169354
|
+
}
|
|
169355
|
+
}
|
|
169356
|
+
return res;
|
|
169357
|
+
};
|
|
169358
|
+
const records = this._myIndex.records;
|
|
169359
|
+
const resultMap = {};
|
|
169360
|
+
const results = [];
|
|
169361
|
+
records.forEach(({ $: item, i: idx }) => {
|
|
169362
|
+
if (isDefined(item)) {
|
|
169363
|
+
let expResults = evaluate(expression, item, idx);
|
|
169364
|
+
if (expResults.length) {
|
|
169365
|
+
if (!resultMap[idx]) {
|
|
169366
|
+
resultMap[idx] = { idx, item, matches: [] };
|
|
169367
|
+
results.push(resultMap[idx]);
|
|
169368
|
+
}
|
|
169369
|
+
expResults.forEach(({ matches }) => {
|
|
169370
|
+
resultMap[idx].matches.push(...matches);
|
|
169371
|
+
});
|
|
169372
|
+
}
|
|
169373
|
+
}
|
|
169374
|
+
});
|
|
169375
|
+
return results;
|
|
169376
|
+
}
|
|
169377
|
+
_searchObjectList(query2) {
|
|
169378
|
+
const searcher = createSearcher(query2, this.options);
|
|
169379
|
+
const { keys: keys2, records } = this._myIndex;
|
|
169380
|
+
const results = [];
|
|
169381
|
+
records.forEach(({ $: item, i: idx }) => {
|
|
169382
|
+
if (!isDefined(item)) {
|
|
169383
|
+
return;
|
|
169384
|
+
}
|
|
169385
|
+
let matches = [];
|
|
169386
|
+
keys2.forEach((key, keyIndex) => {
|
|
169387
|
+
matches.push(...this._findMatches({
|
|
169388
|
+
key,
|
|
169389
|
+
value: item[keyIndex],
|
|
169390
|
+
searcher
|
|
169391
|
+
}));
|
|
169392
|
+
});
|
|
169393
|
+
if (matches.length) {
|
|
169394
|
+
results.push({
|
|
169395
|
+
idx,
|
|
169396
|
+
item,
|
|
169397
|
+
matches
|
|
169398
|
+
});
|
|
169399
|
+
}
|
|
169400
|
+
});
|
|
169401
|
+
return results;
|
|
169402
|
+
}
|
|
169403
|
+
_findMatches({ key, value, searcher }) {
|
|
169404
|
+
if (!isDefined(value)) {
|
|
169405
|
+
return [];
|
|
169406
|
+
}
|
|
169407
|
+
let matches = [];
|
|
169408
|
+
if (isArray3(value)) {
|
|
169409
|
+
value.forEach(({ v: text, i: idx, n: norm2 }) => {
|
|
169410
|
+
if (!isDefined(text)) {
|
|
169411
|
+
return;
|
|
169412
|
+
}
|
|
169413
|
+
const { isMatch, score, indices } = searcher.searchIn(text);
|
|
169414
|
+
if (isMatch) {
|
|
169415
|
+
matches.push({
|
|
169416
|
+
score,
|
|
169417
|
+
key,
|
|
169418
|
+
value: text,
|
|
169419
|
+
idx,
|
|
169420
|
+
norm: norm2,
|
|
169421
|
+
indices
|
|
169422
|
+
});
|
|
169423
|
+
}
|
|
169424
|
+
});
|
|
169425
|
+
} else {
|
|
169426
|
+
const { v: text, n: norm2 } = value;
|
|
169427
|
+
const { isMatch, score, indices } = searcher.searchIn(text);
|
|
169428
|
+
if (isMatch) {
|
|
169429
|
+
matches.push({ score, key, value: text, norm: norm2, indices });
|
|
169430
|
+
}
|
|
169431
|
+
}
|
|
169432
|
+
return matches;
|
|
169433
|
+
}
|
|
169434
|
+
}
|
|
169435
|
+
var INFINITY4, INCORRECT_INDEX_TYPE = "Incorrect 'index' type", LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = (key) => `Invalid value for key ${key}`, PATTERN_LENGTH_TOO_LARGE = (max2) => `Pattern length exceeds max of ${max2}.`, MISSING_KEY_PROPERTY = (name) => `Missing ${name} property in key`, INVALID_KEY_WEIGHT_VALUE = (key) => `Property 'weight' in key '${key}' must be a positive integer`, hasOwn, MatchOptions, BasicOptions, FuzzyOptions, AdvancedOptions, Config, SPACE, MAX_BITS = 32, stripDiacritics, ExactMatch, InverseExactMatch, PrefixExactMatch, InversePrefixExactMatch, SuffixExactMatch, InverseSuffixExactMatch, FuzzyMatch, IncludeMatch, searchers, searchersLen, SPACE_RE, OR_TOKEN = "|", MultiMatchSet, registeredSearchers, LogicalOperator, KeyType, isExpression = (query2) => !!(query2[LogicalOperator.AND] || query2[LogicalOperator.OR]), isPath = (query2) => !!query2[KeyType.PATH], isLeaf = (query2) => !isArray3(query2) && isObject5(query2) && !isExpression(query2), convertToExplicit = (query2) => ({
|
|
169436
|
+
[LogicalOperator.AND]: Object.keys(query2).map((key) => ({
|
|
169437
|
+
[key]: query2[key]
|
|
169438
|
+
}))
|
|
169439
|
+
});
|
|
169440
|
+
var init_fuse = __esm(() => {
|
|
169441
|
+
INFINITY4 = 1 / 0;
|
|
169442
|
+
hasOwn = Object.prototype.hasOwnProperty;
|
|
169443
|
+
MatchOptions = {
|
|
169444
|
+
includeMatches: false,
|
|
169445
|
+
findAllMatches: false,
|
|
169446
|
+
minMatchCharLength: 1
|
|
169447
|
+
};
|
|
169448
|
+
BasicOptions = {
|
|
169449
|
+
isCaseSensitive: false,
|
|
169450
|
+
ignoreDiacritics: false,
|
|
169451
|
+
includeScore: false,
|
|
169452
|
+
keys: [],
|
|
169453
|
+
shouldSort: true,
|
|
169454
|
+
sortFn: (a2, b) => a2.score === b.score ? a2.idx < b.idx ? -1 : 1 : a2.score < b.score ? -1 : 1
|
|
169455
|
+
};
|
|
169456
|
+
FuzzyOptions = {
|
|
169457
|
+
location: 0,
|
|
169458
|
+
threshold: 0.6,
|
|
169459
|
+
distance: 100
|
|
169460
|
+
};
|
|
169461
|
+
AdvancedOptions = {
|
|
169462
|
+
useExtendedSearch: false,
|
|
169463
|
+
getFn: get2,
|
|
169464
|
+
ignoreLocation: false,
|
|
169465
|
+
ignoreFieldNorm: false,
|
|
169466
|
+
fieldNormWeight: 1
|
|
169467
|
+
};
|
|
169468
|
+
Config = {
|
|
169469
|
+
...BasicOptions,
|
|
169470
|
+
...MatchOptions,
|
|
169471
|
+
...FuzzyOptions,
|
|
169472
|
+
...AdvancedOptions
|
|
169473
|
+
};
|
|
169474
|
+
SPACE = /[^ ]+/g;
|
|
169475
|
+
stripDiacritics = String.prototype.normalize ? (str) => str.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g, "") : (str) => str;
|
|
169476
|
+
ExactMatch = class ExactMatch extends BaseMatch {
|
|
169477
|
+
constructor(pattern) {
|
|
169478
|
+
super(pattern);
|
|
169479
|
+
}
|
|
169480
|
+
static get type() {
|
|
169481
|
+
return "exact";
|
|
169482
|
+
}
|
|
169483
|
+
static get multiRegex() {
|
|
169484
|
+
return /^="(.*)"$/;
|
|
169485
|
+
}
|
|
169486
|
+
static get singleRegex() {
|
|
169487
|
+
return /^=(.*)$/;
|
|
169488
|
+
}
|
|
169489
|
+
search(text) {
|
|
169490
|
+
const isMatch = text === this.pattern;
|
|
169491
|
+
return {
|
|
169492
|
+
isMatch,
|
|
169493
|
+
score: isMatch ? 0 : 1,
|
|
169494
|
+
indices: [0, this.pattern.length - 1]
|
|
169495
|
+
};
|
|
169496
|
+
}
|
|
169497
|
+
};
|
|
169498
|
+
InverseExactMatch = class InverseExactMatch extends BaseMatch {
|
|
169499
|
+
constructor(pattern) {
|
|
169500
|
+
super(pattern);
|
|
169501
|
+
}
|
|
169502
|
+
static get type() {
|
|
169503
|
+
return "inverse-exact";
|
|
169504
|
+
}
|
|
169505
|
+
static get multiRegex() {
|
|
169506
|
+
return /^!"(.*)"$/;
|
|
169507
|
+
}
|
|
169508
|
+
static get singleRegex() {
|
|
169509
|
+
return /^!(.*)$/;
|
|
169510
|
+
}
|
|
169511
|
+
search(text) {
|
|
169512
|
+
const index = text.indexOf(this.pattern);
|
|
169513
|
+
const isMatch = index === -1;
|
|
169514
|
+
return {
|
|
169515
|
+
isMatch,
|
|
169516
|
+
score: isMatch ? 0 : 1,
|
|
169517
|
+
indices: [0, text.length - 1]
|
|
169518
|
+
};
|
|
169519
|
+
}
|
|
169520
|
+
};
|
|
169521
|
+
PrefixExactMatch = class PrefixExactMatch extends BaseMatch {
|
|
169522
|
+
constructor(pattern) {
|
|
169523
|
+
super(pattern);
|
|
169524
|
+
}
|
|
169525
|
+
static get type() {
|
|
169526
|
+
return "prefix-exact";
|
|
169527
|
+
}
|
|
169528
|
+
static get multiRegex() {
|
|
169529
|
+
return /^\^"(.*)"$/;
|
|
169530
|
+
}
|
|
169531
|
+
static get singleRegex() {
|
|
169532
|
+
return /^\^(.*)$/;
|
|
169533
|
+
}
|
|
169534
|
+
search(text) {
|
|
169535
|
+
const isMatch = text.startsWith(this.pattern);
|
|
169536
|
+
return {
|
|
169537
|
+
isMatch,
|
|
169538
|
+
score: isMatch ? 0 : 1,
|
|
169539
|
+
indices: [0, this.pattern.length - 1]
|
|
169540
|
+
};
|
|
169541
|
+
}
|
|
169542
|
+
};
|
|
169543
|
+
InversePrefixExactMatch = class InversePrefixExactMatch extends BaseMatch {
|
|
169544
|
+
constructor(pattern) {
|
|
169545
|
+
super(pattern);
|
|
169546
|
+
}
|
|
169547
|
+
static get type() {
|
|
169548
|
+
return "inverse-prefix-exact";
|
|
169549
|
+
}
|
|
169550
|
+
static get multiRegex() {
|
|
169551
|
+
return /^!\^"(.*)"$/;
|
|
169552
|
+
}
|
|
169553
|
+
static get singleRegex() {
|
|
169554
|
+
return /^!\^(.*)$/;
|
|
169555
|
+
}
|
|
169556
|
+
search(text) {
|
|
169557
|
+
const isMatch = !text.startsWith(this.pattern);
|
|
169558
|
+
return {
|
|
169559
|
+
isMatch,
|
|
169560
|
+
score: isMatch ? 0 : 1,
|
|
169561
|
+
indices: [0, text.length - 1]
|
|
169562
|
+
};
|
|
169563
|
+
}
|
|
169564
|
+
};
|
|
169565
|
+
SuffixExactMatch = class SuffixExactMatch extends BaseMatch {
|
|
169566
|
+
constructor(pattern) {
|
|
169567
|
+
super(pattern);
|
|
169568
|
+
}
|
|
169569
|
+
static get type() {
|
|
169570
|
+
return "suffix-exact";
|
|
169571
|
+
}
|
|
169572
|
+
static get multiRegex() {
|
|
169573
|
+
return /^"(.*)"\$$/;
|
|
169574
|
+
}
|
|
169575
|
+
static get singleRegex() {
|
|
169576
|
+
return /^(.*)\$$/;
|
|
169577
|
+
}
|
|
169578
|
+
search(text) {
|
|
169579
|
+
const isMatch = text.endsWith(this.pattern);
|
|
169580
|
+
return {
|
|
169581
|
+
isMatch,
|
|
169582
|
+
score: isMatch ? 0 : 1,
|
|
169583
|
+
indices: [text.length - this.pattern.length, text.length - 1]
|
|
169584
|
+
};
|
|
169585
|
+
}
|
|
169586
|
+
};
|
|
169587
|
+
InverseSuffixExactMatch = class InverseSuffixExactMatch extends BaseMatch {
|
|
169588
|
+
constructor(pattern) {
|
|
169589
|
+
super(pattern);
|
|
169590
|
+
}
|
|
169591
|
+
static get type() {
|
|
169592
|
+
return "inverse-suffix-exact";
|
|
169593
|
+
}
|
|
169594
|
+
static get multiRegex() {
|
|
169595
|
+
return /^!"(.*)"\$$/;
|
|
169596
|
+
}
|
|
169597
|
+
static get singleRegex() {
|
|
169598
|
+
return /^!(.*)\$$/;
|
|
169599
|
+
}
|
|
169600
|
+
search(text) {
|
|
169601
|
+
const isMatch = !text.endsWith(this.pattern);
|
|
169602
|
+
return {
|
|
169603
|
+
isMatch,
|
|
169604
|
+
score: isMatch ? 0 : 1,
|
|
169605
|
+
indices: [0, text.length - 1]
|
|
169606
|
+
};
|
|
169607
|
+
}
|
|
169608
|
+
};
|
|
169609
|
+
FuzzyMatch = class FuzzyMatch extends BaseMatch {
|
|
169610
|
+
constructor(pattern, {
|
|
169611
|
+
location = Config.location,
|
|
169612
|
+
threshold = Config.threshold,
|
|
169613
|
+
distance = Config.distance,
|
|
169614
|
+
includeMatches = Config.includeMatches,
|
|
169615
|
+
findAllMatches = Config.findAllMatches,
|
|
169616
|
+
minMatchCharLength = Config.minMatchCharLength,
|
|
169617
|
+
isCaseSensitive = Config.isCaseSensitive,
|
|
169618
|
+
ignoreDiacritics = Config.ignoreDiacritics,
|
|
169619
|
+
ignoreLocation = Config.ignoreLocation
|
|
169620
|
+
} = {}) {
|
|
169621
|
+
super(pattern);
|
|
169622
|
+
this._bitapSearch = new BitapSearch(pattern, {
|
|
169623
|
+
location,
|
|
169624
|
+
threshold,
|
|
169625
|
+
distance,
|
|
169626
|
+
includeMatches,
|
|
169627
|
+
findAllMatches,
|
|
169628
|
+
minMatchCharLength,
|
|
169629
|
+
isCaseSensitive,
|
|
169630
|
+
ignoreDiacritics,
|
|
169631
|
+
ignoreLocation
|
|
169632
|
+
});
|
|
169633
|
+
}
|
|
169634
|
+
static get type() {
|
|
169635
|
+
return "fuzzy";
|
|
169636
|
+
}
|
|
169637
|
+
static get multiRegex() {
|
|
169638
|
+
return /^"(.*)"$/;
|
|
169639
|
+
}
|
|
169640
|
+
static get singleRegex() {
|
|
169641
|
+
return /^(.*)$/;
|
|
169642
|
+
}
|
|
169643
|
+
search(text) {
|
|
169644
|
+
return this._bitapSearch.searchIn(text);
|
|
169645
|
+
}
|
|
169646
|
+
};
|
|
169647
|
+
IncludeMatch = class IncludeMatch extends BaseMatch {
|
|
169648
|
+
constructor(pattern) {
|
|
169649
|
+
super(pattern);
|
|
169650
|
+
}
|
|
169651
|
+
static get type() {
|
|
169652
|
+
return "include";
|
|
169653
|
+
}
|
|
169654
|
+
static get multiRegex() {
|
|
169655
|
+
return /^'"(.*)"$/;
|
|
169656
|
+
}
|
|
169657
|
+
static get singleRegex() {
|
|
169658
|
+
return /^'(.*)$/;
|
|
169659
|
+
}
|
|
169660
|
+
search(text) {
|
|
169661
|
+
let location = 0;
|
|
169662
|
+
let index;
|
|
169663
|
+
const indices = [];
|
|
169664
|
+
const patternLen = this.pattern.length;
|
|
169665
|
+
while ((index = text.indexOf(this.pattern, location)) > -1) {
|
|
169666
|
+
location = index + patternLen;
|
|
169667
|
+
indices.push([index, location - 1]);
|
|
169668
|
+
}
|
|
169669
|
+
const isMatch = !!indices.length;
|
|
169670
|
+
return {
|
|
169671
|
+
isMatch,
|
|
169672
|
+
score: isMatch ? 0 : 1,
|
|
169673
|
+
indices
|
|
169674
|
+
};
|
|
169675
|
+
}
|
|
169676
|
+
};
|
|
169677
|
+
searchers = [
|
|
169678
|
+
ExactMatch,
|
|
169679
|
+
IncludeMatch,
|
|
169680
|
+
PrefixExactMatch,
|
|
169681
|
+
InversePrefixExactMatch,
|
|
169682
|
+
InverseSuffixExactMatch,
|
|
169683
|
+
SuffixExactMatch,
|
|
169684
|
+
InverseExactMatch,
|
|
169685
|
+
FuzzyMatch
|
|
169686
|
+
];
|
|
169687
|
+
searchersLen = searchers.length;
|
|
169688
|
+
SPACE_RE = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/;
|
|
169689
|
+
MultiMatchSet = new Set([FuzzyMatch.type, IncludeMatch.type]);
|
|
169690
|
+
registeredSearchers = [];
|
|
169691
|
+
LogicalOperator = {
|
|
169692
|
+
AND: "$and",
|
|
169693
|
+
OR: "$or"
|
|
169694
|
+
};
|
|
169695
|
+
KeyType = {
|
|
169696
|
+
PATH: "$path",
|
|
169697
|
+
PATTERN: "$val"
|
|
169698
|
+
};
|
|
169699
|
+
Fuse.version = "7.1.0";
|
|
169700
|
+
Fuse.createIndex = createIndex;
|
|
169701
|
+
Fuse.parseIndex = parseIndex;
|
|
169702
|
+
Fuse.config = Config;
|
|
169703
|
+
{
|
|
169704
|
+
Fuse.parseQuery = parse9;
|
|
169705
|
+
}
|
|
169706
|
+
{
|
|
169707
|
+
register(ExtendedSearch);
|
|
169708
|
+
}
|
|
169709
|
+
});
|
|
169710
|
+
|
|
168434
169711
|
// src/utils/suggestions/skillUsageTracking.ts
|
|
168435
169712
|
function recordSkillUsage(skillName) {
|
|
168436
169713
|
const now = Date.now();
|
|
@@ -168459,6 +169736,86 @@ var init_skillUsageTracking = __esm(() => {
|
|
|
168459
169736
|
lastWriteBySkill = new Map;
|
|
168460
169737
|
});
|
|
168461
169738
|
|
|
169739
|
+
// src/utils/suggestions/commandSuggestions.ts
|
|
169740
|
+
function warnBrokenCommand(label, err2) {
|
|
169741
|
+
if (warnedBrokenCommands.has(label)) {
|
|
169742
|
+
return;
|
|
169743
|
+
}
|
|
169744
|
+
warnedBrokenCommands.add(label);
|
|
169745
|
+
logForDebugging(`command suggestion: skipped metadata for "${label}" — getter threw: ${err2 instanceof Error ? err2.message : String(err2)}`, { level: "warn" });
|
|
169746
|
+
}
|
|
169747
|
+
function safeIsHidden(command) {
|
|
169748
|
+
try {
|
|
169749
|
+
return Boolean(command.isHidden);
|
|
169750
|
+
} catch (err2) {
|
|
169751
|
+
warnBrokenCommand(safeCommandName(command) ?? "unknown", err2);
|
|
169752
|
+
return false;
|
|
169753
|
+
}
|
|
169754
|
+
}
|
|
169755
|
+
function safeCommandName(command) {
|
|
169756
|
+
try {
|
|
169757
|
+
return getCommandName(command);
|
|
169758
|
+
} catch {
|
|
169759
|
+
return null;
|
|
169760
|
+
}
|
|
169761
|
+
}
|
|
169762
|
+
function safeCommandAliases(command, commandName) {
|
|
169763
|
+
try {
|
|
169764
|
+
return command.aliases;
|
|
169765
|
+
} catch (err2) {
|
|
169766
|
+
warnBrokenCommand(commandName, err2);
|
|
169767
|
+
return;
|
|
169768
|
+
}
|
|
169769
|
+
}
|
|
169770
|
+
function findClosestSkillNames(commandName, commands, limit = 3) {
|
|
169771
|
+
const query2 = commandName.toLowerCase().trim();
|
|
169772
|
+
if (!query2) {
|
|
169773
|
+
return [];
|
|
169774
|
+
}
|
|
169775
|
+
const candidates = [];
|
|
169776
|
+
for (const command of commands) {
|
|
169777
|
+
const name = safeCommandName(command);
|
|
169778
|
+
if (name === null || safeIsHidden(command)) {
|
|
169779
|
+
continue;
|
|
169780
|
+
}
|
|
169781
|
+
candidates.push({
|
|
169782
|
+
name,
|
|
169783
|
+
aliasKey: safeCommandAliases(command, name)?.map((alias) => alias.toLowerCase()) ?? []
|
|
169784
|
+
});
|
|
169785
|
+
}
|
|
169786
|
+
const fuse = new Fuse(candidates, {
|
|
169787
|
+
includeScore: true,
|
|
169788
|
+
threshold: 0.45,
|
|
169789
|
+
location: 0,
|
|
169790
|
+
distance: 100,
|
|
169791
|
+
keys: [
|
|
169792
|
+
{ name: "name", weight: 3 },
|
|
169793
|
+
{ name: "aliasKey", weight: 2 }
|
|
169794
|
+
]
|
|
169795
|
+
});
|
|
169796
|
+
const seen = new Set;
|
|
169797
|
+
const result = [];
|
|
169798
|
+
for (const { item } of fuse.search(query2)) {
|
|
169799
|
+
if (seen.has(item.name)) {
|
|
169800
|
+
continue;
|
|
169801
|
+
}
|
|
169802
|
+
seen.add(item.name);
|
|
169803
|
+
result.push(item.name);
|
|
169804
|
+
if (result.length >= limit) {
|
|
169805
|
+
break;
|
|
169806
|
+
}
|
|
169807
|
+
}
|
|
169808
|
+
return result;
|
|
169809
|
+
}
|
|
169810
|
+
var warnedBrokenCommands;
|
|
169811
|
+
var init_commandSuggestions = __esm(() => {
|
|
169812
|
+
init_fuse();
|
|
169813
|
+
init_commands();
|
|
169814
|
+
init_debug();
|
|
169815
|
+
init_skillUsageTracking();
|
|
169816
|
+
warnedBrokenCommands = new Set;
|
|
169817
|
+
});
|
|
169818
|
+
|
|
168462
169819
|
// src/utils/telemetry/events.ts
|
|
168463
169820
|
async function logOTelEvent(_eventName, _metadata = {}) {}
|
|
168464
169821
|
function redactIfDisabled(_content) {
|
|
@@ -168636,7 +169993,8 @@ async function processSlashCommand(inputString, precedingInputBlocks, imageConte
|
|
|
168636
169993
|
logEvent("tengu_input_slash_invalid", {
|
|
168637
169994
|
input: commandName
|
|
168638
169995
|
});
|
|
168639
|
-
const
|
|
169996
|
+
const closest = findClosestSkillNames(commandName, context2.options.commands);
|
|
169997
|
+
const unknownMessage = `Unknown skill: ${commandName}` + (closest.length > 0 ? `. Did you mean: ${closest.map((name) => `/${name}`).join(", ")}?` : "");
|
|
168640
169998
|
return {
|
|
168641
169999
|
messages: [
|
|
168642
170000
|
createSyntheticUserCaveatMessage(),
|
|
@@ -169133,6 +170491,7 @@ var init_processSlashCommand = __esm(() => {
|
|
|
169133
170491
|
init_permissions3();
|
|
169134
170492
|
init_pluginIdentifier();
|
|
169135
170493
|
init_pluginOnlyPolicy();
|
|
170494
|
+
init_commandSuggestions();
|
|
169136
170495
|
init_skillUsageTracking();
|
|
169137
170496
|
init_pluginTelemetry();
|
|
169138
170497
|
init_tokens();
|
|
@@ -170118,6 +171477,7 @@ var init_SkillTool = __esm(() => {
|
|
|
170118
171477
|
init_frontmatterParser();
|
|
170119
171478
|
init_messages();
|
|
170120
171479
|
init_model();
|
|
171480
|
+
init_commandSuggestions();
|
|
170121
171481
|
init_skillUsageTracking();
|
|
170122
171482
|
init_uuid();
|
|
170123
171483
|
init_runAgent();
|
|
@@ -170201,9 +171561,10 @@ var init_SkillTool = __esm(() => {
|
|
|
170201
171561
|
const commands = await getAllCommands(context2);
|
|
170202
171562
|
const foundCommand = findCommand(normalizedCommandName, commands);
|
|
170203
171563
|
if (!foundCommand) {
|
|
171564
|
+
const closest = findClosestSkillNames(normalizedCommandName, commands);
|
|
170204
171565
|
return {
|
|
170205
171566
|
result: false,
|
|
170206
|
-
message: `Unknown skill: ${normalizedCommandName}
|
|
171567
|
+
message: `Unknown skill: ${normalizedCommandName}` + (closest.length > 0 ? `. Did you mean: ${closest.map((name) => `/${name}`).join(", ")}?` : ""),
|
|
170207
171568
|
errorCode: 2
|
|
170208
171569
|
};
|
|
170209
171570
|
}
|
|
@@ -178193,7 +179554,7 @@ var require_TreeWalker = __commonJS((exports, module) => {
|
|
|
178193
179554
|
return null;
|
|
178194
179555
|
}
|
|
178195
179556
|
} },
|
|
178196
|
-
toString: { value: function
|
|
179557
|
+
toString: { value: function toString6() {
|
|
178197
179558
|
return "[object TreeWalker]";
|
|
178198
179559
|
} }
|
|
178199
179560
|
});
|
|
@@ -178334,7 +179695,7 @@ var require_NodeIterator = __commonJS((exports, module) => {
|
|
|
178334
179695
|
return traverse(this, false);
|
|
178335
179696
|
} },
|
|
178336
179697
|
detach: { value: function detach() {} },
|
|
178337
|
-
toString: { value: function
|
|
179698
|
+
toString: { value: function toString6() {
|
|
178338
179699
|
return "[object NodeIterator]";
|
|
178339
179700
|
} }
|
|
178340
179701
|
});
|
|
@@ -178539,7 +179900,7 @@ var require_events2 = __commonJS((exports, module) => {
|
|
|
178539
179900
|
var require_style_parser = __commonJS((exports) => {
|
|
178540
179901
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
178541
179902
|
exports.hyphenate = exports.parse = undefined;
|
|
178542
|
-
function
|
|
179903
|
+
function parse10(value) {
|
|
178543
179904
|
const styles4 = [];
|
|
178544
179905
|
let i3 = 0;
|
|
178545
179906
|
let parenDepth = 0;
|
|
@@ -178593,7 +179954,7 @@ var require_style_parser = __commonJS((exports) => {
|
|
|
178593
179954
|
}
|
|
178594
179955
|
return styles4;
|
|
178595
179956
|
}
|
|
178596
|
-
exports.parse =
|
|
179957
|
+
exports.parse = parse10;
|
|
178597
179958
|
function hyphenate(value) {
|
|
178598
179959
|
return value.replace(/[a-z][A-Z]/g, (v) => {
|
|
178599
179960
|
return v.charAt(0) + "-" + v.charAt(1);
|
|
@@ -178604,7 +179965,7 @@ var require_style_parser = __commonJS((exports) => {
|
|
|
178604
179965
|
|
|
178605
179966
|
// node_modules/@mixmark-io/domino/lib/CSSStyleDeclaration.js
|
|
178606
179967
|
var require_CSSStyleDeclaration = __commonJS((exports, module) => {
|
|
178607
|
-
var { parse:
|
|
179968
|
+
var { parse: parse10 } = require_style_parser();
|
|
178608
179969
|
module.exports = function(elt) {
|
|
178609
179970
|
const style = new CSSStyleDeclaration(elt);
|
|
178610
179971
|
const handler = {
|
|
@@ -178640,7 +180001,7 @@ var require_CSSStyleDeclaration = __commonJS((exports, module) => {
|
|
|
178640
180001
|
if (!value) {
|
|
178641
180002
|
return result;
|
|
178642
180003
|
}
|
|
178643
|
-
const styleValues =
|
|
180004
|
+
const styleValues = parse10(value);
|
|
178644
180005
|
if (styleValues.length < 2) {
|
|
178645
180006
|
return result;
|
|
178646
180007
|
}
|
|
@@ -190305,11 +191666,11 @@ var require_turndown_cjs = __commonJS((exports, module) => {
|
|
|
190305
191666
|
function Node(node, options2) {
|
|
190306
191667
|
node.isBlock = isBlock(node);
|
|
190307
191668
|
node.isCode = node.nodeName === "CODE" || node.parentNode.isCode;
|
|
190308
|
-
node.isBlank =
|
|
191669
|
+
node.isBlank = isBlank2(node);
|
|
190309
191670
|
node.flankingWhitespace = flankingWhitespace(node, options2);
|
|
190310
191671
|
return node;
|
|
190311
191672
|
}
|
|
190312
|
-
function
|
|
191673
|
+
function isBlank2(node) {
|
|
190313
191674
|
return !isVoid(node) && !isMeaningfulWhenBlank(node) && /^\s*$/i.test(node.textContent) && !hasVoid(node) && !hasMeaningfulWhenBlank(node);
|
|
190314
191675
|
}
|
|
190315
191676
|
function flankingWhitespace(node, options2) {
|
|
@@ -194675,15 +196036,15 @@ var require_commonjs = __commonJS((exports) => {
|
|
|
194675
196036
|
|
|
194676
196037
|
// node_modules/needle/lib/querystring.js
|
|
194677
196038
|
var require_querystring = __commonJS((exports) => {
|
|
194678
|
-
var
|
|
196039
|
+
var toString6 = Object.prototype.toString;
|
|
194679
196040
|
function stringify(obj, prefix) {
|
|
194680
196041
|
if (prefix && (obj === null || typeof obj == "undefined")) {
|
|
194681
196042
|
return prefix + "=";
|
|
194682
|
-
} else if (
|
|
196043
|
+
} else if (toString6.call(obj) == "[object Array]") {
|
|
194683
196044
|
return stringifyArray(obj, prefix);
|
|
194684
|
-
} else if (
|
|
196045
|
+
} else if (toString6.call(obj) == "[object Object]") {
|
|
194685
196046
|
return stringifyObject(obj, prefix);
|
|
194686
|
-
} else if (
|
|
196047
|
+
} else if (toString6.call(obj) == "[object Date]") {
|
|
194687
196048
|
return obj.toISOString();
|
|
194688
196049
|
} else if (prefix) {
|
|
194689
196050
|
return prefix + "=" + encodeURIComponent(String(obj));
|
|
@@ -201164,7 +202525,7 @@ var require_search = __commonJS((exports) => {
|
|
|
201164
202525
|
var NEWS_REGEX = /;DDG\.duckbar\.load\('news', ({"ads":.+"vqd":{".+":"\d-\d+-\d+"}})\);DDG\.duckbar\.load\('videos/;
|
|
201165
202526
|
var VIDEOS_REGEX = /;DDG\.duckbar\.load\('videos', ({"ads":.+"vqd":{".+":"\d-\d+-\d+"}})\);DDG\.duckbar\.loadModule\('related_searches/;
|
|
201166
202527
|
var RELATED_SEARCHES_REGEX = /DDG\.duckbar\.loadModule\('related_searches', ({"ads":.+"vqd":{".+":"\d-\d+-\d+"}})\);DDG\.duckbar\.load\('products/;
|
|
201167
|
-
async function
|
|
202528
|
+
async function search2(query3, options2, needleOptions) {
|
|
201168
202529
|
if (!query3)
|
|
201169
202530
|
throw new Error("Query cannot be empty!");
|
|
201170
202531
|
if (!options2)
|
|
@@ -201225,21 +202586,21 @@ var require_search = __commonJS((exports) => {
|
|
|
201225
202586
|
vqd,
|
|
201226
202587
|
results: []
|
|
201227
202588
|
};
|
|
201228
|
-
for (const
|
|
201229
|
-
if ("n" in
|
|
202589
|
+
for (const search3 of searchResults) {
|
|
202590
|
+
if ("n" in search3)
|
|
201230
202591
|
continue;
|
|
201231
202592
|
let bang;
|
|
201232
|
-
if (
|
|
201233
|
-
const [prefix, title, domain2] =
|
|
202593
|
+
if (search3.b) {
|
|
202594
|
+
const [prefix, title, domain2] = search3.b.split("\t");
|
|
201234
202595
|
bang = { prefix, title, domain: domain2 };
|
|
201235
202596
|
}
|
|
201236
202597
|
results.results.push({
|
|
201237
|
-
title:
|
|
201238
|
-
description: (0, html_entities_1.decode)(
|
|
201239
|
-
rawDescription:
|
|
201240
|
-
hostname:
|
|
201241
|
-
icon: `https://external-content.duckduckgo.com/ip3/${
|
|
201242
|
-
url:
|
|
202598
|
+
title: search3.t,
|
|
202599
|
+
description: (0, html_entities_1.decode)(search3.a),
|
|
202600
|
+
rawDescription: search3.a,
|
|
202601
|
+
hostname: search3.i,
|
|
202602
|
+
icon: `https://external-content.duckduckgo.com/ip3/${search3.i}.ico`,
|
|
202603
|
+
url: search3.u,
|
|
201243
202604
|
bang
|
|
201244
202605
|
});
|
|
201245
202606
|
}
|
|
@@ -201296,7 +202657,7 @@ var require_search = __commonJS((exports) => {
|
|
|
201296
202657
|
}
|
|
201297
202658
|
return results;
|
|
201298
202659
|
}
|
|
201299
|
-
exports.search =
|
|
202660
|
+
exports.search = search2;
|
|
201300
202661
|
function sanityCheck(options2) {
|
|
201301
202662
|
options2 = Object.assign({}, defaultOptions2, options2);
|
|
201302
202663
|
if (!(options2.safeSearch in util_1.SafeSearchType))
|
|
@@ -201836,10 +203197,10 @@ var init_duckduckgo = __esm(() => {
|
|
|
201836
203197
|
},
|
|
201837
203198
|
async search(input, signal) {
|
|
201838
203199
|
const start = performance.now();
|
|
201839
|
-
let
|
|
203200
|
+
let search2;
|
|
201840
203201
|
let SafeSearchType;
|
|
201841
203202
|
try {
|
|
201842
|
-
({ search, SafeSearchType } = await Promise.resolve().then(() => __toESM(require_lib5(), 1)));
|
|
203203
|
+
({ search: search2, SafeSearchType } = await Promise.resolve().then(() => __toESM(require_lib5(), 1)));
|
|
201843
203204
|
} catch {
|
|
201844
203205
|
throw new Error("duck-duck-scrape package not installed. Run: npm install duck-duck-scrape");
|
|
201845
203206
|
}
|
|
@@ -201850,7 +203211,7 @@ var init_duckduckgo = __esm(() => {
|
|
|
201850
203211
|
if (signal?.aborted)
|
|
201851
203212
|
throw new DOMException("Aborted", "AbortError");
|
|
201852
203213
|
try {
|
|
201853
|
-
const response = await withWebSearchTimeout((combinedSignal) =>
|
|
203214
|
+
const response = await withWebSearchTimeout((combinedSignal) => search2(input.query, { safeSearch: SafeSearchType.STRICT }, { signal: combinedSignal }), signal, { providerName: "DuckDuckGo" });
|
|
201854
203215
|
const hits = applyDomainFilters(response.results.map((r) => ({
|
|
201855
203216
|
title: r.title || r.url,
|
|
201856
203217
|
url: r.url,
|
|
@@ -206096,11 +207457,11 @@ var init_AskUserQuestionTool = __esm(() => {
|
|
|
206096
207457
|
return DESCRIPTION2;
|
|
206097
207458
|
},
|
|
206098
207459
|
async prompt() {
|
|
206099
|
-
const
|
|
206100
|
-
if (
|
|
207460
|
+
const format5 = getQuestionPreviewFormat();
|
|
207461
|
+
if (format5 === undefined) {
|
|
206101
207462
|
return ASK_USER_QUESTION_TOOL_PROMPT;
|
|
206102
207463
|
}
|
|
206103
|
-
return ASK_USER_QUESTION_TOOL_PROMPT + PREVIEW_FEATURE_PROMPT[
|
|
207464
|
+
return ASK_USER_QUESTION_TOOL_PROMPT + PREVIEW_FEATURE_PROMPT[format5];
|
|
206104
207465
|
},
|
|
206105
207466
|
get inputSchema() {
|
|
206106
207467
|
return inputSchema25();
|
|
@@ -226840,7 +228201,7 @@ var init_prefetch = __esm(() => {
|
|
|
226840
228201
|
|
|
226841
228202
|
// src/utils/attachments.ts
|
|
226842
228203
|
import { readdir as readdir16, stat as stat23 } from "fs/promises";
|
|
226843
|
-
import nodePath2, { dirname as dirname40, parse as
|
|
228204
|
+
import nodePath2, { dirname as dirname40, parse as parse10, relative as relative12, resolve as resolve28 } from "path";
|
|
226844
228205
|
import { randomUUID as randomUUID16 } from "crypto";
|
|
226845
228206
|
function shouldIncludeSkillListingAttachment(querySource) {
|
|
226846
228207
|
return !(typeof querySource === "string" && SKILL_LISTING_SUPPRESSED_QUERY_SOURCES.has(querySource));
|
|
@@ -227322,7 +228683,7 @@ function getDirectoriesToProcess(targetPath, originalCwd) {
|
|
|
227322
228683
|
const targetDir = dirname40(resolve28(targetPath));
|
|
227323
228684
|
const nestedDirs = [];
|
|
227324
228685
|
let currentDir = targetDir;
|
|
227325
|
-
while (currentDir !== originalCwd && currentDir !==
|
|
228686
|
+
while (currentDir !== originalCwd && currentDir !== parse10(currentDir).root) {
|
|
227326
228687
|
if (isPathUnder(currentDir, originalCwd)) {
|
|
227327
228688
|
nestedDirs.push(currentDir);
|
|
227328
228689
|
}
|
|
@@ -227331,7 +228692,7 @@ function getDirectoriesToProcess(targetPath, originalCwd) {
|
|
|
227331
228692
|
nestedDirs.reverse();
|
|
227332
228693
|
const cwdLevelDirs = [];
|
|
227333
228694
|
currentDir = originalCwd;
|
|
227334
|
-
while (currentDir !==
|
|
228695
|
+
while (currentDir !== parse10(currentDir).root) {
|
|
227335
228696
|
cwdLevelDirs.push(currentDir);
|
|
227336
228697
|
currentDir = dirname40(currentDir);
|
|
227337
228698
|
}
|
|
@@ -228001,7 +229362,7 @@ async function* getAttachmentMessages(input, toolUseContext, ideSelection, queue
|
|
|
228001
229362
|
}
|
|
228002
229363
|
}
|
|
228003
229364
|
async function tryGetPDFReference(filename) {
|
|
228004
|
-
const ext =
|
|
229365
|
+
const ext = parse10(filename).ext.toLowerCase();
|
|
228005
229366
|
if (!isPDFExtension(ext)) {
|
|
228006
229367
|
return null;
|
|
228007
229368
|
}
|
|
@@ -228035,7 +229396,7 @@ async function generateFileAttachment(filename, toolUseContext, successEventName
|
|
|
228035
229396
|
return null;
|
|
228036
229397
|
}
|
|
228037
229398
|
if (mode === "at-mention" && !isFileWithinReadSizeLimit(filename, getDefaultFileReadingLimits().maxSizeBytes)) {
|
|
228038
|
-
const ext =
|
|
229399
|
+
const ext = parse10(filename).ext.toLowerCase();
|
|
228039
229400
|
if (!isPDFExtension(ext)) {
|
|
228040
229401
|
try {
|
|
228041
229402
|
const stats = await getFsImplementation().stat(filename);
|
|
@@ -236855,7 +238216,7 @@ function getAnthropicEnvMetadata() {
|
|
|
236855
238216
|
function getBuildAgeMinutes() {
|
|
236856
238217
|
if (false)
|
|
236857
238218
|
;
|
|
236858
|
-
const buildTime = new Date("2026-10-
|
|
238219
|
+
const buildTime = new Date("2026-10-08T13:31:49.092Z").getTime();
|
|
236859
238220
|
if (isNaN(buildTime))
|
|
236860
238221
|
return;
|
|
236861
238222
|
return Math.floor((Date.now() - buildTime) / 60000);
|
|
@@ -265795,7 +267156,7 @@ var init_sessionStorage = __esm(() => {
|
|
|
265795
267156
|
init_slowOperations();
|
|
265796
267157
|
init_transcriptFileLock();
|
|
265797
267158
|
init_uuid();
|
|
265798
|
-
VERSION3 = typeof MACRO !== "undefined" ? "0.31.
|
|
267159
|
+
VERSION3 = typeof MACRO !== "undefined" ? "0.31.2-by-rayss" : "unknown";
|
|
265799
267160
|
MAX_TOMBSTONE_REWRITE_BYTES = 50 * 1024 * 1024;
|
|
265800
267161
|
TRANSCRIPT_COPY_CHUNK_BYTES = 64 * 1024;
|
|
265801
267162
|
transcriptRewriteHooksForTesting = {};
|
|
@@ -267266,7 +268627,7 @@ var init_filesystem = __esm(() => {
|
|
|
267266
268627
|
});
|
|
267267
268628
|
getBundledSkillsRoot = memoize_default(function getBundledSkillsRoot2() {
|
|
267268
268629
|
const nonce = randomBytes10(16).toString("hex");
|
|
267269
|
-
return join94(getClaudeTempDir(), "bundled-skills", "0.31.
|
|
268630
|
+
return join94(getClaudeTempDir(), "bundled-skills", "0.31.2-by-rayss", nonce);
|
|
267270
268631
|
});
|
|
267271
268632
|
getResolvedWorkingDirPaths = memoize_default(getPathsForPermissionCheck);
|
|
267272
268633
|
});
|
|
@@ -281805,7 +283166,7 @@ function buildSystemInitMessage(inputs) {
|
|
|
281805
283166
|
slash_commands: inputs.commands.filter((c7) => c7.userInvocable !== false).map((c7) => c7.name),
|
|
281806
283167
|
apiKeySource: getAnthropicApiKeyWithSource().source,
|
|
281807
283168
|
betas: getSdkBetas(),
|
|
281808
|
-
claude_code_version: "0.31.
|
|
283169
|
+
claude_code_version: "0.31.2-by-rayss",
|
|
281809
283170
|
output_style: outputStyle,
|
|
281810
283171
|
agents: inputs.agents.map((agent) => agent.agentType),
|
|
281811
283172
|
skills: inputs.skills.filter((s) => s.userInvocable !== false).map((skill) => skill.name),
|
|
@@ -284397,8 +285758,8 @@ function safelyAccess(fn) {
|
|
|
284397
285758
|
}
|
|
284398
285759
|
}
|
|
284399
285760
|
function checkCriticalImportsForStubs(criticalImports) {
|
|
284400
|
-
for (const { name, get:
|
|
284401
|
-
const mod =
|
|
285761
|
+
for (const { name, get: get3 } of criticalImports) {
|
|
285762
|
+
const mod = get3();
|
|
284402
285763
|
if (mod && "__stub" in mod && mod.__stub === true) {
|
|
284403
285764
|
throw new Error(`SDK init error: "${name}" resolved to a build stub at runtime. ` + `This means a TUI/CLI dependency leaked into the SDK bundle. ` + `Report this at https://github.com/rayss868/openclaude/issues`);
|
|
284404
285765
|
}
|
|
@@ -286429,4 +287790,4 @@ export {
|
|
|
286429
287790
|
AbortError
|
|
286430
287791
|
};
|
|
286431
287792
|
|
|
286432
|
-
//# debugId=
|
|
287793
|
+
//# debugId=4114905C61A7F2F064756E2164756E21
|