fss-link 1.4.7 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/fss-link.js +565 -170
- package/package.json +1 -1
package/bundle/fss-link.js
CHANGED
|
@@ -22379,7 +22379,7 @@ async function createContentGeneratorConfig(config, authType) {
|
|
|
22379
22379
|
async function createContentGenerator(config, gcConfig, sessionId2) {
|
|
22380
22380
|
if (DEBUG_CONTENT)
|
|
22381
22381
|
console.log(`\u{1F41B} DEBUG createContentGenerator: authType=${config.authType}, apiKey=${config.apiKey}, baseUrl=${config.baseUrl}`);
|
|
22382
|
-
const version = "1.
|
|
22382
|
+
const version = "1.5.1";
|
|
22383
22383
|
const userAgent = `FSS-Link/${version} (${process.platform}; ${process.arch})`;
|
|
22384
22384
|
const baseHeaders = {
|
|
22385
22385
|
"User-Agent": userAgent
|
|
@@ -25325,7 +25325,7 @@ function formatBytes(bytes) {
|
|
|
25325
25325
|
function isFileTooLarge(size) {
|
|
25326
25326
|
return size > MAX_FILE_SIZE;
|
|
25327
25327
|
}
|
|
25328
|
-
var MAX_FILE_SIZE, MAX_TOTAL_CONTENT_SIZE, MAX_OUTPUT_SIZE, MAX_DIRECTORY_ENTRIES, MAX_GLOB_RESULTS;
|
|
25328
|
+
var MAX_FILE_SIZE, MAX_TOTAL_CONTENT_SIZE, MAX_OUTPUT_SIZE, MAX_DIRECTORY_ENTRIES, MAX_GLOB_RESULTS, PROCESS_TIMEOUT, MAX_GREP_OUTPUT_SIZE, MAX_GLOB_OUTPUT_SIZE, MAX_LS_OUTPUT_SIZE, MAX_CONTEXT_PER_MATCH_MULTI;
|
|
25329
25329
|
var init_toolLimits = __esm({
|
|
25330
25330
|
"packages/core/dist/src/utils/toolLimits.js"() {
|
|
25331
25331
|
"use strict";
|
|
@@ -25334,6 +25334,11 @@ var init_toolLimits = __esm({
|
|
|
25334
25334
|
MAX_OUTPUT_SIZE = 8 * 1024;
|
|
25335
25335
|
MAX_DIRECTORY_ENTRIES = 500;
|
|
25336
25336
|
MAX_GLOB_RESULTS = 1e3;
|
|
25337
|
+
PROCESS_TIMEOUT = 3e4;
|
|
25338
|
+
MAX_GREP_OUTPUT_SIZE = 16 * 1024;
|
|
25339
|
+
MAX_GLOB_OUTPUT_SIZE = 8 * 1024;
|
|
25340
|
+
MAX_LS_OUTPUT_SIZE = 8 * 1024;
|
|
25341
|
+
MAX_CONTEXT_PER_MATCH_MULTI = 2;
|
|
25337
25342
|
}
|
|
25338
25343
|
});
|
|
25339
25344
|
|
|
@@ -25461,7 +25466,14 @@ var init_ls = __esm({
|
|
|
25461
25466
|
}
|
|
25462
25467
|
const showMetadata = this.params.show_metadata ?? true;
|
|
25463
25468
|
const showIcons = this.params.show_file_icons ?? true;
|
|
25464
|
-
const
|
|
25469
|
+
const SAFETY_MARGIN = 512;
|
|
25470
|
+
const outputBudget = MAX_LS_OUTPUT_SIZE - SAFETY_MARGIN;
|
|
25471
|
+
const lines = [];
|
|
25472
|
+
let currentSize = 0;
|
|
25473
|
+
let entriesDisplayed = 0;
|
|
25474
|
+
let entriesSkippedForBudget = 0;
|
|
25475
|
+
for (let i = 0; i < entries.length; i++) {
|
|
25476
|
+
const entry = entries[i];
|
|
25465
25477
|
let line = "";
|
|
25466
25478
|
if (showIcons) {
|
|
25467
25479
|
const icon = entry.isDirectory ? "\u{1F4C1}" : getFileTypeIcon(entry.path, entry.isDirectory ? "directory" : "text");
|
|
@@ -25479,8 +25491,16 @@ var init_ls = __esm({
|
|
|
25479
25491
|
const time = formatRelativeTime(entry.modifiedTime);
|
|
25480
25492
|
line += ` (${time})`;
|
|
25481
25493
|
}
|
|
25482
|
-
|
|
25483
|
-
|
|
25494
|
+
const lineSize = line.length + 1;
|
|
25495
|
+
if (currentSize + lineSize > outputBudget) {
|
|
25496
|
+
entriesSkippedForBudget = entries.length - i;
|
|
25497
|
+
break;
|
|
25498
|
+
}
|
|
25499
|
+
lines.push(line);
|
|
25500
|
+
currentSize += lineSize;
|
|
25501
|
+
entriesDisplayed++;
|
|
25502
|
+
}
|
|
25503
|
+
const directoryContent = lines.join("\n");
|
|
25484
25504
|
let resultMessage = `Directory listing for ${this.params.path}:
|
|
25485
25505
|
${directoryContent}`;
|
|
25486
25506
|
if (wasTruncated) {
|
|
@@ -25490,6 +25510,15 @@ ${directoryContent}`;
|
|
|
25490
25510
|
resultMessage += `
|
|
25491
25511
|
|
|
25492
25512
|
NOTE: Directory has too many entries. Consider using glob patterns to filter results or listing specific subdirectories.`;
|
|
25513
|
+
}
|
|
25514
|
+
if (entriesSkippedForBudget > 0) {
|
|
25515
|
+
resultMessage += `
|
|
25516
|
+
|
|
25517
|
+
[${entriesSkippedForBudget} entries truncated to fit 8KB budget]`;
|
|
25518
|
+
resultMessage += `
|
|
25519
|
+
Showing ${entriesDisplayed} of ${entries.length} entries`;
|
|
25520
|
+
resultMessage += `
|
|
25521
|
+
Refine with: more specific path or use glob patterns`;
|
|
25493
25522
|
}
|
|
25494
25523
|
const ignoredMessages = [];
|
|
25495
25524
|
if (gitIgnoredCount > 0) {
|
|
@@ -25503,17 +25532,44 @@ NOTE: Directory has too many entries. Consider using glob patterns to filter res
|
|
|
25503
25532
|
|
|
25504
25533
|
(${ignoredMessages.join(", ")})`;
|
|
25505
25534
|
}
|
|
25506
|
-
|
|
25535
|
+
const currentOutputSize = resultMessage.length;
|
|
25536
|
+
const budgetUsagePercent = Math.round(currentOutputSize / MAX_LS_OUTPUT_SIZE * 100);
|
|
25537
|
+
resultMessage += `
|
|
25538
|
+
|
|
25539
|
+
--- Directory Listing Metadata ---`;
|
|
25540
|
+
resultMessage += `
|
|
25541
|
+
Entries shown: ${entriesDisplayed}`;
|
|
25542
|
+
if (wasTruncated) {
|
|
25543
|
+
resultMessage += ` (${totalEntries - entries.length} additional entries beyond ${MAX_DIRECTORY_ENTRIES} limit)`;
|
|
25544
|
+
}
|
|
25545
|
+
if (ignoredMessages.length > 0) {
|
|
25546
|
+
resultMessage += `
|
|
25547
|
+
Ignored: ${ignoredMessages.join(", ")}`;
|
|
25548
|
+
}
|
|
25549
|
+
resultMessage += `
|
|
25550
|
+
Output budget: ${budgetUsagePercent}% of ${(MAX_LS_OUTPUT_SIZE / 1024).toFixed(0)}KB limit`;
|
|
25551
|
+
if (budgetUsagePercent > 80) {
|
|
25552
|
+
resultMessage += ` \u26A0\uFE0F NEAR LIMIT`;
|
|
25553
|
+
}
|
|
25554
|
+
if (resultMessage.length > MAX_LS_OUTPUT_SIZE) {
|
|
25555
|
+
const overage = resultMessage.length - MAX_LS_OUTPUT_SIZE;
|
|
25556
|
+
console.warn(`LSLogic: Final output exceeded budget by ${overage} chars. Emergency truncation applied.`);
|
|
25557
|
+
resultMessage = resultMessage.slice(0, MAX_LS_OUTPUT_SIZE);
|
|
25558
|
+
resultMessage += `
|
|
25559
|
+
|
|
25560
|
+
[EMERGENCY TRUNCATION: Output exceeded ${(MAX_LS_OUTPUT_SIZE / 1024).toFixed(0)}KB budget]`;
|
|
25561
|
+
}
|
|
25562
|
+
let displayMessage = `Listed ${entriesDisplayed} item(s)`;
|
|
25507
25563
|
if (wasTruncated) {
|
|
25508
25564
|
displayMessage += ` (truncated from ${totalEntries})`;
|
|
25509
25565
|
}
|
|
25510
|
-
displayMessage += ".";
|
|
25511
25566
|
if (ignoredMessages.length > 0) {
|
|
25512
25567
|
displayMessage += ` (${ignoredMessages.join(", ")})`;
|
|
25513
25568
|
if (entries.length === 0 && gitIgnoredCount > 0 && this.params.path.includes("scraped_content")) {
|
|
25514
25569
|
displayMessage += ` - Use 'ls scraped_content' or 'bash ls scraped_content/' to view web scraper output files`;
|
|
25515
25570
|
}
|
|
25516
25571
|
}
|
|
25572
|
+
displayMessage += ` \u2022 ${budgetUsagePercent}% budget`;
|
|
25517
25573
|
return {
|
|
25518
25574
|
llmContent: resultMessage,
|
|
25519
25575
|
returnDisplay: displayMessage
|
|
@@ -32552,7 +32608,7 @@ import fsPromises from "fs/promises";
|
|
|
32552
32608
|
import path16 from "path";
|
|
32553
32609
|
import { EOL } from "os";
|
|
32554
32610
|
import { spawn as spawn2 } from "child_process";
|
|
32555
|
-
var
|
|
32611
|
+
var GREP_PROCESS_TIMEOUT, MANY_MATCHES_THRESHOLD, GrepToolInvocation, GrepTool;
|
|
32556
32612
|
var init_grep = __esm({
|
|
32557
32613
|
"packages/core/dist/src/tools/grep.js"() {
|
|
32558
32614
|
"use strict";
|
|
@@ -32562,9 +32618,9 @@ var init_grep = __esm({
|
|
|
32562
32618
|
init_errors();
|
|
32563
32619
|
init_gitUtils();
|
|
32564
32620
|
init_fileUtils();
|
|
32565
|
-
|
|
32566
|
-
|
|
32567
|
-
|
|
32621
|
+
init_toolLimits();
|
|
32622
|
+
GREP_PROCESS_TIMEOUT = PROCESS_TIMEOUT;
|
|
32623
|
+
MANY_MATCHES_THRESHOLD = 20;
|
|
32568
32624
|
GrepToolInvocation = class extends BaseToolInvocation {
|
|
32569
32625
|
config;
|
|
32570
32626
|
constructor(config, params) {
|
|
@@ -32861,9 +32917,32 @@ Found ${fileSearchResult.matches.length} ${fileSearchResult.matches.length === 1
|
|
|
32861
32917
|
let llmContent = `${headerText}:
|
|
32862
32918
|
---
|
|
32863
32919
|
`;
|
|
32864
|
-
|
|
32920
|
+
const SAFETY_MARGIN = 1024;
|
|
32921
|
+
const outputBudget = MAX_GREP_OUTPUT_SIZE - SAFETY_MARGIN;
|
|
32922
|
+
let outputSize = llmContent.length;
|
|
32923
|
+
let filesShown = 0;
|
|
32924
|
+
let filesSkipped = 0;
|
|
32925
|
+
let matchesShown = 0;
|
|
32926
|
+
for (let i = 0; i < fileRankings.length; i++) {
|
|
32927
|
+
const fileRank = fileRankings[i];
|
|
32865
32928
|
const filePath = fileRank.filePath;
|
|
32866
32929
|
const matches = matchesByFile[filePath];
|
|
32930
|
+
const estimatedFileSize = this.estimateFileOutputSize(filePath, matches, this.params.showFileInfo ?? false);
|
|
32931
|
+
if (outputSize + estimatedFileSize > outputBudget) {
|
|
32932
|
+
filesSkipped = fileRankings.length - i;
|
|
32933
|
+
const lastDir = path16.dirname(filePath);
|
|
32934
|
+
llmContent += `
|
|
32935
|
+
[${filesSkipped} ${filesSkipped === 1 ? "file" : "files"} truncated to fit 16KB budget \u2014 refine with:]
|
|
32936
|
+
`;
|
|
32937
|
+
llmContent += ` \u2022 path="${lastDir}" for focused directory search
|
|
32938
|
+
`;
|
|
32939
|
+
llmContent += ` \u2022 pattern="more specific term" to reduce matches
|
|
32940
|
+
`;
|
|
32941
|
+
llmContent += ` \u2022 Use Read tool on top files for complete content
|
|
32942
|
+
|
|
32943
|
+
`;
|
|
32944
|
+
break;
|
|
32945
|
+
}
|
|
32867
32946
|
let fileHeader = `File: ${filePath}`;
|
|
32868
32947
|
const showFileInfo = this.params.showFileInfo ?? false;
|
|
32869
32948
|
if (showFileInfo) {
|
|
@@ -32881,22 +32960,30 @@ Found ${fileSearchResult.matches.length} ${fileSearchResult.matches.length === 1
|
|
|
32881
32960
|
}
|
|
32882
32961
|
llmContent += `${fileHeader}
|
|
32883
32962
|
`;
|
|
32884
|
-
|
|
32963
|
+
outputSize += fileHeader.length + 1;
|
|
32964
|
+
for (const match2 of matches) {
|
|
32885
32965
|
if (match2.contextLines && match2.contextStartLine) {
|
|
32886
32966
|
match2.contextLines.forEach((contextLine, idx) => {
|
|
32887
32967
|
const lineNum = match2.contextStartLine + idx;
|
|
32888
32968
|
const isMatchLine = lineNum === match2.lineNumber;
|
|
32889
32969
|
const marker = isMatchLine ? " \u2190 MATCH" : "";
|
|
32890
|
-
|
|
32970
|
+
const lineOutput = `L${lineNum}: ${contextLine.trim()}${marker}
|
|
32891
32971
|
`;
|
|
32972
|
+
llmContent += lineOutput;
|
|
32973
|
+
outputSize += lineOutput.length;
|
|
32892
32974
|
});
|
|
32893
32975
|
} else {
|
|
32894
32976
|
const trimmedLine = match2.line.trim();
|
|
32895
|
-
|
|
32977
|
+
const lineOutput = `L${match2.lineNumber}: ${trimmedLine}
|
|
32896
32978
|
`;
|
|
32979
|
+
llmContent += lineOutput;
|
|
32980
|
+
outputSize += lineOutput.length;
|
|
32897
32981
|
}
|
|
32898
|
-
|
|
32982
|
+
matchesShown++;
|
|
32983
|
+
}
|
|
32899
32984
|
llmContent += "---\n";
|
|
32985
|
+
outputSize += 4;
|
|
32986
|
+
filesShown++;
|
|
32900
32987
|
}
|
|
32901
32988
|
if (searchTruncated) {
|
|
32902
32989
|
llmContent += `
|
|
@@ -32909,19 +32996,51 @@ WARNING: Results truncated to prevent context overflow. To see more results:
|
|
|
32909
32996
|
if (metrics2.filesSkippedTooLarge > 0) {
|
|
32910
32997
|
llmContent += `
|
|
32911
32998
|
|
|
32912
|
-
NOTE: ${metrics2.filesSkippedTooLarge} ${metrics2.filesSkippedTooLarge === 1 ? "file was" : "files were"} skipped due to size (>${formatFileSize(
|
|
32999
|
+
NOTE: ${metrics2.filesSkippedTooLarge} ${metrics2.filesSkippedTooLarge === 1 ? "file was" : "files were"} skipped due to size (>${formatFileSize(MAX_FILE_SIZE)}). Large files are excluded to prevent memory exhaustion.`;
|
|
32913
33000
|
}
|
|
32914
|
-
if (metrics2.totalContentProcessed >=
|
|
33001
|
+
if (metrics2.totalContentProcessed >= MAX_TOTAL_CONTENT_SIZE * 0.9) {
|
|
32915
33002
|
const processedMB = (metrics2.totalContentProcessed / (1024 * 1024)).toFixed(2);
|
|
32916
|
-
const limitMB = (
|
|
33003
|
+
const limitMB = (MAX_TOTAL_CONTENT_SIZE / (1024 * 1024)).toFixed(0);
|
|
32917
33004
|
llmContent += `
|
|
32918
33005
|
|
|
32919
33006
|
NOTE: Search stopped after processing ${processedMB} MB of content (approaching ${limitMB} MB limit). Use more specific patterns or narrower paths for complete results.`;
|
|
33007
|
+
}
|
|
33008
|
+
const finalOutputSize = llmContent.length;
|
|
33009
|
+
const budgetUsagePercent = Math.round(finalOutputSize / MAX_GREP_OUTPUT_SIZE * 100);
|
|
33010
|
+
llmContent += `
|
|
33011
|
+
|
|
33012
|
+
--- Search Metadata ---
|
|
33013
|
+
`;
|
|
33014
|
+
llmContent += `Strategy: ${metrics2.strategy || "unknown"}
|
|
33015
|
+
`;
|
|
33016
|
+
llmContent += `Files searched: ${metrics2.filesSearched}
|
|
33017
|
+
`;
|
|
33018
|
+
llmContent += `Matches shown: ${matchesShown} of ${matchCount} found`;
|
|
33019
|
+
if (filesSkipped > 0) {
|
|
33020
|
+
llmContent += ` (${filesSkipped} files truncated)`;
|
|
33021
|
+
}
|
|
33022
|
+
llmContent += `
|
|
33023
|
+
`;
|
|
33024
|
+
llmContent += `Output budget: ${budgetUsagePercent}% of ${(MAX_GREP_OUTPUT_SIZE / 1024).toFixed(0)}KB limit`;
|
|
33025
|
+
if (budgetUsagePercent > 80) {
|
|
33026
|
+
llmContent += ` \u26A0\uFE0F NEAR LIMIT`;
|
|
33027
|
+
}
|
|
33028
|
+
llmContent += `
|
|
33029
|
+
`;
|
|
33030
|
+
const finalSize = llmContent.length;
|
|
33031
|
+
if (finalSize > MAX_GREP_OUTPUT_SIZE) {
|
|
33032
|
+
const overage = finalSize - MAX_GREP_OUTPUT_SIZE;
|
|
33033
|
+
console.warn(`GrepLogic: Final output exceeded budget by ${overage} chars despite progressive reduction. Emergency truncation applied.`);
|
|
33034
|
+
llmContent = llmContent.slice(0, MAX_GREP_OUTPUT_SIZE);
|
|
33035
|
+
llmContent += `
|
|
33036
|
+
|
|
33037
|
+
[EMERGENCY TRUNCATION: Output exceeded ${(MAX_GREP_OUTPUT_SIZE / 1024).toFixed(0)}KB budget]`;
|
|
32920
33038
|
}
|
|
32921
33039
|
let displayText = `Found ${matchCount} ${matchTerm}`;
|
|
32922
33040
|
if (searchTruncated) {
|
|
32923
33041
|
displayText += ` (truncated from ${totalMatchesFound}+)`;
|
|
32924
33042
|
}
|
|
33043
|
+
displayText += ` \u2022 ${budgetUsagePercent}% budget`;
|
|
32925
33044
|
return {
|
|
32926
33045
|
llmContent: llmContent.trim(),
|
|
32927
33046
|
returnDisplay: displayText
|
|
@@ -32971,6 +33090,27 @@ NOTE: Search stopped after processing ${processedMB} MB of content (approaching
|
|
|
32971
33090
|
};
|
|
32972
33091
|
}
|
|
32973
33092
|
}
|
|
33093
|
+
/**
|
|
33094
|
+
* Estimates the output size for a file's matches
|
|
33095
|
+
* Used for budget-aware output generation
|
|
33096
|
+
*/
|
|
33097
|
+
estimateFileOutputSize(filePath, matches, showFileInfo) {
|
|
33098
|
+
let estimatedSize = 0;
|
|
33099
|
+
if (showFileInfo) {
|
|
33100
|
+
estimatedSize += 100;
|
|
33101
|
+
} else {
|
|
33102
|
+
estimatedSize += 50 + filePath.length;
|
|
33103
|
+
}
|
|
33104
|
+
for (const match2 of matches) {
|
|
33105
|
+
if (match2.contextLines) {
|
|
33106
|
+
estimatedSize += match2.contextLines.length * 70;
|
|
33107
|
+
} else {
|
|
33108
|
+
estimatedSize += 90;
|
|
33109
|
+
}
|
|
33110
|
+
}
|
|
33111
|
+
estimatedSize += 5;
|
|
33112
|
+
return estimatedSize;
|
|
33113
|
+
}
|
|
32974
33114
|
/**
|
|
32975
33115
|
* Parses the standard output of grep-like commands (git grep, system grep).
|
|
32976
33116
|
* Expects format: filePath:lineNumber:lineContent
|
|
@@ -33225,12 +33365,12 @@ NOTE: Search stopped after processing ${processedMB} MB of content (approaching
|
|
|
33225
33365
|
filesSearched++;
|
|
33226
33366
|
try {
|
|
33227
33367
|
const stats = await fsPromises.stat(fileAbsolutePath);
|
|
33228
|
-
if (stats.size >
|
|
33368
|
+
if (stats.size > MAX_FILE_SIZE) {
|
|
33229
33369
|
filesSkippedTooLarge++;
|
|
33230
|
-
console.debug(`GrepLogic: Skipping large file ${fileAbsolutePath} (${stats.size} bytes > ${
|
|
33370
|
+
console.debug(`GrepLogic: Skipping large file ${fileAbsolutePath} (${stats.size} bytes > ${MAX_FILE_SIZE} limit)`);
|
|
33231
33371
|
continue;
|
|
33232
33372
|
}
|
|
33233
|
-
if (totalContentProcessed + stats.size >
|
|
33373
|
+
if (totalContentProcessed + stats.size > MAX_TOTAL_CONTENT_SIZE) {
|
|
33234
33374
|
console.debug(`GrepLogic: Stopping search - total content limit reached (${totalContentProcessed} bytes processed)`);
|
|
33235
33375
|
break;
|
|
33236
33376
|
}
|
|
@@ -33238,10 +33378,11 @@ NOTE: Search stopped after processing ${processedMB} MB of content (approaching
|
|
|
33238
33378
|
totalContentProcessed += content.length;
|
|
33239
33379
|
const lines = content.split(/\r?\n/);
|
|
33240
33380
|
const relPath = path16.relative(absolutePath, fileAbsolutePath) || path16.basename(fileAbsolutePath);
|
|
33241
|
-
lines.
|
|
33381
|
+
for (let index = 0; index < lines.length; index++) {
|
|
33242
33382
|
if (allMatches.length >= maxResults) {
|
|
33243
|
-
|
|
33383
|
+
break;
|
|
33244
33384
|
}
|
|
33385
|
+
const line = lines[index];
|
|
33245
33386
|
if (regex2.test(line)) {
|
|
33246
33387
|
const match2 = {
|
|
33247
33388
|
filePath: relPath,
|
|
@@ -33256,7 +33397,7 @@ NOTE: Search stopped after processing ${processedMB} MB of content (approaching
|
|
|
33256
33397
|
}
|
|
33257
33398
|
allMatches.push(match2);
|
|
33258
33399
|
}
|
|
33259
|
-
}
|
|
33400
|
+
}
|
|
33260
33401
|
if (allMatches.length >= maxResults) {
|
|
33261
33402
|
console.debug(`GrepLogic: Reached maxResults limit (${maxResults}) - stopping search after ${filesSearched} files`);
|
|
33262
33403
|
break;
|
|
@@ -33267,6 +33408,20 @@ NOTE: Search stopped after processing ${processedMB} MB of content (approaching
|
|
|
33267
33408
|
}
|
|
33268
33409
|
}
|
|
33269
33410
|
}
|
|
33411
|
+
if (allMatches.length > MANY_MATCHES_THRESHOLD && (contextBefore > MAX_CONTEXT_PER_MATCH_MULTI || contextAfter > MAX_CONTEXT_PER_MATCH_MULTI)) {
|
|
33412
|
+
console.debug(`GrepLogic: Many matches found (${allMatches.length}), reducing context to ${MAX_CONTEXT_PER_MATCH_MULTI} lines per side to prevent output explosion`);
|
|
33413
|
+
for (const match2 of allMatches) {
|
|
33414
|
+
if (match2.contextLines && match2.contextStartLine !== void 0) {
|
|
33415
|
+
const matchLineIndex = match2.lineNumber - match2.contextStartLine;
|
|
33416
|
+
const reducedBefore = Math.min(MAX_CONTEXT_PER_MATCH_MULTI, matchLineIndex);
|
|
33417
|
+
const reducedAfter = Math.min(MAX_CONTEXT_PER_MATCH_MULTI, match2.contextLines.length - matchLineIndex - 1);
|
|
33418
|
+
const startIndex = matchLineIndex - reducedBefore;
|
|
33419
|
+
const endIndex = matchLineIndex + reducedAfter + 1;
|
|
33420
|
+
match2.contextLines = match2.contextLines.slice(startIndex, endIndex);
|
|
33421
|
+
match2.contextStartLine = match2.lineNumber - reducedBefore;
|
|
33422
|
+
}
|
|
33423
|
+
}
|
|
33424
|
+
}
|
|
33270
33425
|
return {
|
|
33271
33426
|
matches: allMatches,
|
|
33272
33427
|
filesSearched,
|
|
@@ -33637,20 +33792,42 @@ var init_glob2 = __esm({
|
|
|
33637
33792
|
if (wasTruncated) {
|
|
33638
33793
|
sortedAbsolutePaths = sortedAbsolutePaths.slice(0, MAX_GLOB_RESULTS);
|
|
33639
33794
|
}
|
|
33795
|
+
const SAFETY_MARGIN = 512;
|
|
33796
|
+
const outputBudget = MAX_GLOB_OUTPUT_SIZE - SAFETY_MARGIN;
|
|
33640
33797
|
let fileListDescription;
|
|
33641
33798
|
let totalSize = 0;
|
|
33799
|
+
let filesDisplayed = sortedAbsolutePaths.length;
|
|
33800
|
+
let filesSkippedForBudget = 0;
|
|
33642
33801
|
const showMetadata = this.params.showMetadata ?? false;
|
|
33643
33802
|
const groupByType = this.params.groupByType ?? false;
|
|
33644
33803
|
if (showMetadata || groupByType) {
|
|
33645
33804
|
const filesWithMetadata = await this.processFilesWithMetadata(sortedAbsolutePaths);
|
|
33646
33805
|
totalSize = filesWithMetadata.reduce((sum, file) => sum + file.metadata.size, 0);
|
|
33647
33806
|
if (this.params.groupByType) {
|
|
33648
|
-
|
|
33807
|
+
const { output, filesShown, filesSkipped } = this.formatGroupedFilesWithBudget(filesWithMetadata, outputBudget);
|
|
33808
|
+
fileListDescription = output;
|
|
33809
|
+
filesDisplayed = filesShown;
|
|
33810
|
+
filesSkippedForBudget = filesSkipped;
|
|
33649
33811
|
} else {
|
|
33650
|
-
|
|
33812
|
+
const { output, filesShown, filesSkipped } = this.formatFilesWithBudget(filesWithMetadata, outputBudget, showMetadata);
|
|
33813
|
+
fileListDescription = output;
|
|
33814
|
+
filesDisplayed = filesShown;
|
|
33815
|
+
filesSkippedForBudget = filesSkipped;
|
|
33651
33816
|
}
|
|
33652
33817
|
} else {
|
|
33653
|
-
|
|
33818
|
+
const pathList = [];
|
|
33819
|
+
let estimatedSize = 0;
|
|
33820
|
+
for (let i = 0; i < sortedAbsolutePaths.length; i++) {
|
|
33821
|
+
const pathLine = sortedAbsolutePaths[i] + "\n";
|
|
33822
|
+
if (estimatedSize + pathLine.length > outputBudget) {
|
|
33823
|
+
filesSkippedForBudget = sortedAbsolutePaths.length - i;
|
|
33824
|
+
filesDisplayed = i;
|
|
33825
|
+
break;
|
|
33826
|
+
}
|
|
33827
|
+
pathList.push(sortedAbsolutePaths[i]);
|
|
33828
|
+
estimatedSize += pathLine.length;
|
|
33829
|
+
}
|
|
33830
|
+
fileListDescription = pathList.join("\n");
|
|
33654
33831
|
}
|
|
33655
33832
|
const fileCount = sortedAbsolutePaths.length;
|
|
33656
33833
|
let resultMessage = `Found ${fileCount} file(s)`;
|
|
@@ -33685,6 +33862,42 @@ NOTE: Pattern matched too many files. Use more specific patterns to see all resu
|
|
|
33685
33862
|
- Narrow file types: '**/*.test.ts' instead of '**/*.ts'`;
|
|
33686
33863
|
resultMessage += `
|
|
33687
33864
|
- Target specific subdirectories`;
|
|
33865
|
+
}
|
|
33866
|
+
if (filesSkippedForBudget > 0) {
|
|
33867
|
+
resultMessage += `
|
|
33868
|
+
|
|
33869
|
+
[${filesSkippedForBudget} files truncated to fit 8KB budget]`;
|
|
33870
|
+
resultMessage += `
|
|
33871
|
+
Showing ${filesDisplayed} of ${sortedAbsolutePaths.length} matching files`;
|
|
33872
|
+
resultMessage += `
|
|
33873
|
+
Refine with: more specific pattern or narrower path`;
|
|
33874
|
+
}
|
|
33875
|
+
const currentOutputSize = resultMessage.length;
|
|
33876
|
+
const budgetUsagePercent = Math.round(currentOutputSize / MAX_GLOB_OUTPUT_SIZE * 100);
|
|
33877
|
+
resultMessage += `
|
|
33878
|
+
|
|
33879
|
+
--- File Discovery Metadata ---`;
|
|
33880
|
+
resultMessage += `
|
|
33881
|
+
Files shown: ${filesDisplayed}`;
|
|
33882
|
+
if (wasTruncated) {
|
|
33883
|
+
resultMessage += ` (${totalResults - fileCount} additional matches beyond ${MAX_GLOB_RESULTS} limit)`;
|
|
33884
|
+
}
|
|
33885
|
+
if (gitIgnoredCount > 0) {
|
|
33886
|
+
resultMessage += `
|
|
33887
|
+
Git-ignored: ${gitIgnoredCount}`;
|
|
33888
|
+
}
|
|
33889
|
+
resultMessage += `
|
|
33890
|
+
Output budget: ${budgetUsagePercent}% of ${(MAX_GLOB_OUTPUT_SIZE / 1024).toFixed(0)}KB limit`;
|
|
33891
|
+
if (budgetUsagePercent > 80) {
|
|
33892
|
+
resultMessage += ` \u26A0\uFE0F NEAR LIMIT`;
|
|
33893
|
+
}
|
|
33894
|
+
if (resultMessage.length > MAX_GLOB_OUTPUT_SIZE) {
|
|
33895
|
+
const overage = resultMessage.length - MAX_GLOB_OUTPUT_SIZE;
|
|
33896
|
+
console.warn(`GlobLogic: Final output exceeded budget by ${overage} chars. Emergency truncation applied.`);
|
|
33897
|
+
resultMessage = resultMessage.slice(0, MAX_GLOB_OUTPUT_SIZE);
|
|
33898
|
+
resultMessage += `
|
|
33899
|
+
|
|
33900
|
+
[EMERGENCY TRUNCATION: Output exceeded ${(MAX_GLOB_OUTPUT_SIZE / 1024).toFixed(0)}KB budget]`;
|
|
33688
33901
|
}
|
|
33689
33902
|
let displayText = `Found ${fileCount} matching file(s)`;
|
|
33690
33903
|
if (wasTruncated) {
|
|
@@ -33693,6 +33906,7 @@ NOTE: Pattern matched too many files. Use more specific patterns to see all resu
|
|
|
33693
33906
|
if (gitIgnoredCount > 0) {
|
|
33694
33907
|
displayText += ` (${gitIgnoredCount} git-ignored)`;
|
|
33695
33908
|
}
|
|
33909
|
+
displayText += ` \u2022 ${budgetUsagePercent}% budget`;
|
|
33696
33910
|
return {
|
|
33697
33911
|
llmContent: resultMessage,
|
|
33698
33912
|
returnDisplay: displayText
|
|
@@ -33753,17 +33967,56 @@ NOTE: Pattern matched too many files. Use more specific patterns to see all resu
|
|
|
33753
33967
|
}
|
|
33754
33968
|
return results;
|
|
33755
33969
|
}
|
|
33756
|
-
|
|
33757
|
-
|
|
33970
|
+
getGroupName(ext2, fileType) {
|
|
33971
|
+
if ([".ts", ".tsx"].includes(ext2))
|
|
33972
|
+
return "TypeScript Files";
|
|
33973
|
+
if ([".js", ".jsx"].includes(ext2))
|
|
33974
|
+
return "JavaScript Files";
|
|
33975
|
+
if ([".test.ts", ".test.js", ".spec.ts", ".spec.js"].some((e2) => ext2.includes(e2)))
|
|
33976
|
+
return "Test Files";
|
|
33977
|
+
if ([".md", ".txt"].includes(ext2))
|
|
33978
|
+
return "Documentation";
|
|
33979
|
+
if (fileType === "image")
|
|
33980
|
+
return "Images";
|
|
33981
|
+
if ([".json", ".yaml", ".yml"].includes(ext2))
|
|
33982
|
+
return "Configuration";
|
|
33983
|
+
return "Other Files";
|
|
33984
|
+
}
|
|
33985
|
+
/**
|
|
33986
|
+
* Format files with metadata, respecting output budget
|
|
33987
|
+
* Returns truncated output with count of files shown/skipped
|
|
33988
|
+
*/
|
|
33989
|
+
formatFilesWithBudget(files, budget, showMetadata) {
|
|
33990
|
+
const lines = [];
|
|
33991
|
+
let currentSize = 0;
|
|
33992
|
+
let filesShown = 0;
|
|
33993
|
+
for (const file of files) {
|
|
33758
33994
|
const { path: path83, metadata } = file;
|
|
33759
33995
|
const icon = metadata.icon;
|
|
33760
33996
|
const size = formatFileSize(metadata.size);
|
|
33761
|
-
const
|
|
33997
|
+
const lines_info = metadata.totalLines ? ` (${metadata.totalLines} lines, ${size}` : ` (${size}`;
|
|
33762
33998
|
const time = formatRelativeTime(metadata.lastModified);
|
|
33763
|
-
|
|
33764
|
-
|
|
33999
|
+
const line = showMetadata ? `${icon} ${path83}${lines_info}, ${time})
|
|
34000
|
+
` : `${path83}
|
|
34001
|
+
`;
|
|
34002
|
+
if (currentSize + line.length > budget) {
|
|
34003
|
+
break;
|
|
34004
|
+
}
|
|
34005
|
+
lines.push(line.trimEnd());
|
|
34006
|
+
currentSize += line.length;
|
|
34007
|
+
filesShown++;
|
|
34008
|
+
}
|
|
34009
|
+
return {
|
|
34010
|
+
output: lines.join("\n"),
|
|
34011
|
+
filesShown,
|
|
34012
|
+
filesSkipped: files.length - filesShown
|
|
34013
|
+
};
|
|
33765
34014
|
}
|
|
33766
|
-
|
|
34015
|
+
/**
|
|
34016
|
+
* Format grouped files, respecting output budget
|
|
34017
|
+
* Returns truncated output with count of files shown/skipped
|
|
34018
|
+
*/
|
|
34019
|
+
formatGroupedFilesWithBudget(files, budget) {
|
|
33767
34020
|
const groups = /* @__PURE__ */ new Map();
|
|
33768
34021
|
files.forEach((file) => {
|
|
33769
34022
|
const ext2 = path17.extname(file.path).toLowerCase();
|
|
@@ -33774,36 +34027,46 @@ NOTE: Pattern matched too many files. Use more specific patterns to see all resu
|
|
|
33774
34027
|
groups.get(groupName).push(file);
|
|
33775
34028
|
});
|
|
33776
34029
|
const groupStrings = [];
|
|
34030
|
+
let currentSize = 0;
|
|
34031
|
+
let totalFilesShown = 0;
|
|
34032
|
+
let budgetExceeded = false;
|
|
33777
34033
|
for (const [groupName, groupFiles2] of groups) {
|
|
34034
|
+
if (budgetExceeded)
|
|
34035
|
+
break;
|
|
33778
34036
|
const totalSize = groupFiles2.reduce((sum, f) => sum + f.metadata.size, 0);
|
|
33779
34037
|
const header = `${groupName} (${groupFiles2.length} files, ${formatFileSize(totalSize)}):`;
|
|
33780
|
-
|
|
34038
|
+
if (currentSize + header.length > budget) {
|
|
34039
|
+
budgetExceeded = true;
|
|
34040
|
+
break;
|
|
34041
|
+
}
|
|
34042
|
+
const fileLines = [];
|
|
34043
|
+
let groupSize = header.length + 1;
|
|
34044
|
+
for (const file of groupFiles2) {
|
|
33781
34045
|
const { path: path83, metadata } = file;
|
|
33782
34046
|
const icon = metadata.icon;
|
|
33783
34047
|
const size = formatFileSize(metadata.size);
|
|
33784
34048
|
const lines = metadata.totalLines ? ` (${metadata.totalLines} lines, ${size}` : ` (${size}`;
|
|
33785
34049
|
const time = formatRelativeTime(metadata.lastModified);
|
|
33786
|
-
|
|
33787
|
-
|
|
33788
|
-
|
|
33789
|
-
|
|
34050
|
+
const line = `${icon} ${path83}${lines}, ${time})`;
|
|
34051
|
+
if (currentSize + groupSize + line.length + 1 > budget) {
|
|
34052
|
+
budgetExceeded = true;
|
|
34053
|
+
break;
|
|
34054
|
+
}
|
|
34055
|
+
fileLines.push(line);
|
|
34056
|
+
groupSize += line.length + 1;
|
|
34057
|
+
totalFilesShown++;
|
|
34058
|
+
}
|
|
34059
|
+
if (fileLines.length > 0) {
|
|
34060
|
+
groupStrings.push(`${header}
|
|
34061
|
+
${fileLines.join("\n")}`);
|
|
34062
|
+
currentSize += groupSize + 1;
|
|
34063
|
+
}
|
|
33790
34064
|
}
|
|
33791
|
-
return
|
|
33792
|
-
|
|
33793
|
-
|
|
33794
|
-
|
|
33795
|
-
|
|
33796
|
-
if ([".js", ".jsx"].includes(ext2))
|
|
33797
|
-
return "JavaScript Files";
|
|
33798
|
-
if ([".test.ts", ".test.js", ".spec.ts", ".spec.js"].some((e2) => ext2.includes(e2)))
|
|
33799
|
-
return "Test Files";
|
|
33800
|
-
if ([".md", ".txt"].includes(ext2))
|
|
33801
|
-
return "Documentation";
|
|
33802
|
-
if (fileType === "image")
|
|
33803
|
-
return "Images";
|
|
33804
|
-
if ([".json", ".yaml", ".yml"].includes(ext2))
|
|
33805
|
-
return "Configuration";
|
|
33806
|
-
return "Other Files";
|
|
34065
|
+
return {
|
|
34066
|
+
output: groupStrings.join("\n\n"),
|
|
34067
|
+
filesShown: totalFilesShown,
|
|
34068
|
+
filesSkipped: files.length - totalFilesShown
|
|
34069
|
+
};
|
|
33807
34070
|
}
|
|
33808
34071
|
};
|
|
33809
34072
|
GlobTool = class _GlobTool extends BaseDeclarativeTool {
|
|
@@ -85596,6 +85859,18 @@ var init_provider_database = __esm({
|
|
|
85596
85859
|
await safeExecWithLocking(this.db, `
|
|
85597
85860
|
UPDATE model_configs SET endpoint_id = ? WHERE id = ?
|
|
85598
85861
|
`, [endpointId, modelId]);
|
|
85862
|
+
}
|
|
85863
|
+
/**
|
|
85864
|
+
* Update the provider_id for a custom endpoint
|
|
85865
|
+
* This creates the reverse link: endpoint → model (bidirectional reference)
|
|
85866
|
+
*/
|
|
85867
|
+
async updateEndpointProviderId(endpointId, providerId) {
|
|
85868
|
+
if (!this.db) {
|
|
85869
|
+
throw new Error("Database not initialized");
|
|
85870
|
+
}
|
|
85871
|
+
await safeExecWithLocking(this.db, `
|
|
85872
|
+
UPDATE custom_endpoints SET provider_id = ? WHERE id = ?
|
|
85873
|
+
`, [providerId, endpointId]);
|
|
85599
85874
|
}
|
|
85600
85875
|
/**
|
|
85601
85876
|
* Get the custom endpoint for a model (if any)
|
|
@@ -86173,6 +86448,13 @@ var init_unified_database = __esm({
|
|
|
86173
86448
|
await this.ensureInitialized();
|
|
86174
86449
|
await this.providerDb.linkModelToEndpoint(modelId, endpointId);
|
|
86175
86450
|
}
|
|
86451
|
+
/**
|
|
86452
|
+
* Update endpoint provider_id (reverse link: endpoint → model)
|
|
86453
|
+
*/
|
|
86454
|
+
async updateEndpointProviderId(endpointId, providerId) {
|
|
86455
|
+
await this.ensureInitialized();
|
|
86456
|
+
await this.providerDb.updateEndpointProviderId(endpointId, providerId);
|
|
86457
|
+
}
|
|
86176
86458
|
/**
|
|
86177
86459
|
* Get custom endpoint for a model
|
|
86178
86460
|
*/
|
|
@@ -86683,6 +86965,9 @@ var init_database = __esm({
|
|
|
86683
86965
|
async linkModelToEndpoint(modelId, endpointId) {
|
|
86684
86966
|
await this.unifiedDb.linkModelToEndpoint(modelId, endpointId);
|
|
86685
86967
|
}
|
|
86968
|
+
async updateEndpointProviderId(endpointId, providerId) {
|
|
86969
|
+
await this.unifiedDb.updateEndpointProviderId(endpointId, providerId);
|
|
86970
|
+
}
|
|
86686
86971
|
async getEndpointForModel(modelId) {
|
|
86687
86972
|
return await this.unifiedDb.getEndpointForModel(modelId);
|
|
86688
86973
|
}
|
|
@@ -96074,7 +96359,7 @@ async function getPackageJson() {
|
|
|
96074
96359
|
// packages/cli/src/utils/version.ts
|
|
96075
96360
|
async function getCliVersion() {
|
|
96076
96361
|
const pkgJson = await getPackageJson();
|
|
96077
|
-
return "1.
|
|
96362
|
+
return "1.5.1";
|
|
96078
96363
|
}
|
|
96079
96364
|
|
|
96080
96365
|
// packages/cli/src/ui/commands/aboutCommand.ts
|
|
@@ -96126,7 +96411,7 @@ import open4 from "open";
|
|
|
96126
96411
|
import process11 from "node:process";
|
|
96127
96412
|
|
|
96128
96413
|
// packages/cli/src/generated/git-commit.ts
|
|
96129
|
-
var GIT_COMMIT_INFO = "
|
|
96414
|
+
var GIT_COMMIT_INFO = "7684208c";
|
|
96130
96415
|
|
|
96131
96416
|
// packages/cli/src/ui/commands/bugCommand.ts
|
|
96132
96417
|
init_dist2();
|
|
@@ -120423,6 +120708,9 @@ import { useState as useState33, useEffect as useEffect32 } from "react";
|
|
|
120423
120708
|
import { Box as Box19, Text as Text26, useInput as useInput4 } from "ink";
|
|
120424
120709
|
|
|
120425
120710
|
// packages/cli/src/utils/modelFetcher.ts
|
|
120711
|
+
init_dist2();
|
|
120712
|
+
var modelCache = /* @__PURE__ */ new Map();
|
|
120713
|
+
var MODEL_CACHE_TTL = 5 * 60 * 1e3;
|
|
120426
120714
|
async function fetchModelsFromCustomEndpoint(baseUrl, providerType, apiKey) {
|
|
120427
120715
|
const normalizedBase = baseUrl.replace(/\/+$/, "");
|
|
120428
120716
|
const url2 = `${normalizedBase}/models`;
|
|
@@ -120475,7 +120763,18 @@ async function fetchModelsFromCustomEndpoint(baseUrl, providerType, apiKey) {
|
|
|
120475
120763
|
throw new Error("Connection timeout (10s) - endpoint did not respond");
|
|
120476
120764
|
}
|
|
120477
120765
|
if (error.message.includes("fetch failed")) {
|
|
120478
|
-
|
|
120766
|
+
let causeMsg = "";
|
|
120767
|
+
if (error.cause) {
|
|
120768
|
+
const cause = error.cause;
|
|
120769
|
+
if (cause instanceof Error) {
|
|
120770
|
+
causeMsg = ` (cause: ${cause.message})`;
|
|
120771
|
+
} else if (typeof cause === "string") {
|
|
120772
|
+
causeMsg = ` (cause: ${cause})`;
|
|
120773
|
+
} else {
|
|
120774
|
+
causeMsg = ` (cause: ${JSON.stringify(cause)})`;
|
|
120775
|
+
}
|
|
120776
|
+
}
|
|
120777
|
+
throw new Error(`Network error - cannot reach ${normalizedBase}: ${error.message}${causeMsg}`);
|
|
120479
120778
|
}
|
|
120480
120779
|
throw error;
|
|
120481
120780
|
}
|
|
@@ -120483,6 +120782,39 @@ async function fetchModelsFromCustomEndpoint(baseUrl, providerType, apiKey) {
|
|
|
120483
120782
|
throw new Error(`Connection failed: ${String(error)}`);
|
|
120484
120783
|
}
|
|
120485
120784
|
}
|
|
120785
|
+
async function fetchModelsFromProvider(provider, endpoint, apiKey, forceRefresh = false) {
|
|
120786
|
+
const cacheKey = `${provider}:${endpoint || "default"}`;
|
|
120787
|
+
if (!forceRefresh) {
|
|
120788
|
+
const cached = modelCache.get(cacheKey);
|
|
120789
|
+
if (cached && Date.now() - cached.timestamp < MODEL_CACHE_TTL) {
|
|
120790
|
+
console.error(`[DEBUG] Using cached models for ${cacheKey}`);
|
|
120791
|
+
return cached.models;
|
|
120792
|
+
}
|
|
120793
|
+
}
|
|
120794
|
+
let fetchUrl;
|
|
120795
|
+
if (endpoint) {
|
|
120796
|
+
fetchUrl = endpoint;
|
|
120797
|
+
} else {
|
|
120798
|
+
switch (provider) {
|
|
120799
|
+
case AuthType.OLLAMA:
|
|
120800
|
+
fetchUrl = "http://localhost:11434";
|
|
120801
|
+
break;
|
|
120802
|
+
case AuthType.LM_STUDIO:
|
|
120803
|
+
fetchUrl = "http://localhost:1234/v1";
|
|
120804
|
+
break;
|
|
120805
|
+
default:
|
|
120806
|
+
throw new Error(`No default endpoint for provider: ${provider}`);
|
|
120807
|
+
}
|
|
120808
|
+
}
|
|
120809
|
+
console.error(`[DEBUG] Fetching models from ${provider} at ${fetchUrl}`);
|
|
120810
|
+
const models = await fetchModelsFromCustomEndpoint(fetchUrl, provider, apiKey);
|
|
120811
|
+
modelCache.set(cacheKey, {
|
|
120812
|
+
models,
|
|
120813
|
+
timestamp: Date.now()
|
|
120814
|
+
});
|
|
120815
|
+
console.error(`[DEBUG] Cached ${models.length} models for ${cacheKey}`);
|
|
120816
|
+
return models;
|
|
120817
|
+
}
|
|
120486
120818
|
|
|
120487
120819
|
// packages/cli/src/ui/components/shared/PasteAwareTextInput.tsx
|
|
120488
120820
|
import TextInput from "ink-text-input";
|
|
@@ -120515,15 +120847,23 @@ function AddCustomEndpointDialog({
|
|
|
120515
120847
|
const [selectedProviderIndex, setSelectedProviderIndex] = useState33(0);
|
|
120516
120848
|
const [availableModels, setAvailableModels] = useState33([]);
|
|
120517
120849
|
const [selectedModelIndex, setSelectedModelIndex] = useState33(0);
|
|
120850
|
+
const [scrollOffset, setScrollOffset] = useState33(0);
|
|
120518
120851
|
const [fetchError, setFetchError] = useState33(null);
|
|
120852
|
+
const VISIBLE_MODELS = 15;
|
|
120519
120853
|
const providerOptions = [
|
|
120520
120854
|
{ label: "OpenAI-compatible API", value: AuthType.USE_OPENAI },
|
|
120521
120855
|
{ label: "Ollama", value: AuthType.OLLAMA },
|
|
120522
120856
|
{ label: "LM Studio", value: AuthType.LM_STUDIO }
|
|
120523
120857
|
];
|
|
120858
|
+
const getProviderLabel = (type2) => {
|
|
120859
|
+
if (!type2) return "Unknown";
|
|
120860
|
+
const option2 = providerOptions.find((opt) => opt.value === type2);
|
|
120861
|
+
return option2?.label || "Unknown";
|
|
120862
|
+
};
|
|
120524
120863
|
useEffect32(() => {
|
|
120525
120864
|
if (step === "model-fetch" && url2 && providerType) {
|
|
120526
|
-
|
|
120865
|
+
const currentApiKey = apiKey || void 0;
|
|
120866
|
+
fetchModelsFromCustomEndpoint(url2, providerType, currentApiKey).then((models) => {
|
|
120527
120867
|
setAvailableModels(models);
|
|
120528
120868
|
setFetchError(null);
|
|
120529
120869
|
setStep("model-select");
|
|
@@ -120531,7 +120871,7 @@ function AddCustomEndpointDialog({
|
|
|
120531
120871
|
setFetchError(err instanceof Error ? err.message : String(err));
|
|
120532
120872
|
});
|
|
120533
120873
|
}
|
|
120534
|
-
}, [step, url2, providerType
|
|
120874
|
+
}, [step, url2, providerType]);
|
|
120535
120875
|
useInput4((input, key) => {
|
|
120536
120876
|
if (key.escape && step !== "name" && step !== "model-fetch") {
|
|
120537
120877
|
if (step === "url") {
|
|
@@ -120569,11 +120909,19 @@ function AddCustomEndpointDialog({
|
|
|
120569
120909
|
}
|
|
120570
120910
|
if (step === "model-select") {
|
|
120571
120911
|
if (key.upArrow && selectedModelIndex > 0) {
|
|
120572
|
-
|
|
120912
|
+
const newIndex = selectedModelIndex - 1;
|
|
120913
|
+
setSelectedModelIndex(newIndex);
|
|
120914
|
+
if (newIndex < scrollOffset) {
|
|
120915
|
+
setScrollOffset(newIndex);
|
|
120916
|
+
}
|
|
120573
120917
|
return;
|
|
120574
120918
|
}
|
|
120575
120919
|
if (key.downArrow && selectedModelIndex < availableModels.length - 1) {
|
|
120576
|
-
|
|
120920
|
+
const newIndex = selectedModelIndex + 1;
|
|
120921
|
+
setSelectedModelIndex(newIndex);
|
|
120922
|
+
if (newIndex >= scrollOffset + VISIBLE_MODELS) {
|
|
120923
|
+
setScrollOffset(newIndex - VISIBLE_MODELS + 1);
|
|
120924
|
+
}
|
|
120577
120925
|
return;
|
|
120578
120926
|
}
|
|
120579
120927
|
if (key.return) {
|
|
@@ -120589,7 +120937,7 @@ function AddCustomEndpointDialog({
|
|
|
120589
120937
|
if (input === "r" || input === "R") {
|
|
120590
120938
|
setFetchError(null);
|
|
120591
120939
|
setStep("apikey");
|
|
120592
|
-
|
|
120940
|
+
queueMicrotask(() => setStep("model-fetch"));
|
|
120593
120941
|
return;
|
|
120594
120942
|
}
|
|
120595
120943
|
if (input === "u" || input === "U") {
|
|
@@ -120705,7 +121053,7 @@ function AddCustomEndpointDialog({
|
|
|
120705
121053
|
"Endpoint: ",
|
|
120706
121054
|
/* @__PURE__ */ jsx25(Text26, { color: Colors.AccentGreen, children: name2 }),
|
|
120707
121055
|
" (",
|
|
120708
|
-
|
|
121056
|
+
getProviderLabel(providerType),
|
|
120709
121057
|
")"
|
|
120710
121058
|
] }) }),
|
|
120711
121059
|
/* @__PURE__ */ jsx25(Box19, { marginTop: 1, children: /* @__PURE__ */ jsx25(Text26, { children: "Enter API key if required (leave empty if none):" }) }),
|
|
@@ -120737,7 +121085,7 @@ function AddCustomEndpointDialog({
|
|
|
120737
121085
|
] }) }),
|
|
120738
121086
|
/* @__PURE__ */ jsx25(Box19, { marginTop: 1, children: /* @__PURE__ */ jsxs22(Text26, { children: [
|
|
120739
121087
|
"Provider: ",
|
|
120740
|
-
/* @__PURE__ */ jsx25(Text26, { color: Colors.AccentCyan, children:
|
|
121088
|
+
/* @__PURE__ */ jsx25(Text26, { color: Colors.AccentCyan, children: getProviderLabel(providerType) })
|
|
120741
121089
|
] }) }),
|
|
120742
121090
|
/* @__PURE__ */ jsx25(Box19, { marginTop: 1, children: /* @__PURE__ */ jsxs22(Text26, { children: [
|
|
120743
121091
|
"API Key: ",
|
|
@@ -120782,8 +121130,14 @@ function AddCustomEndpointDialog({
|
|
|
120782
121130
|
] }) }),
|
|
120783
121131
|
/* @__PURE__ */ jsx25(Box19, { marginTop: 1, children: /* @__PURE__ */ jsx25(Text26, { children: "Choose a model to use:" }) }),
|
|
120784
121132
|
/* @__PURE__ */ jsxs22(Box19, { marginTop: 1, flexDirection: "column", children: [
|
|
120785
|
-
|
|
120786
|
-
|
|
121133
|
+
scrollOffset > 0 && /* @__PURE__ */ jsxs22(Text26, { color: Colors.Gray, children: [
|
|
121134
|
+
"\u2191 ",
|
|
121135
|
+
scrollOffset,
|
|
121136
|
+
" more above"
|
|
121137
|
+
] }),
|
|
121138
|
+
availableModels.slice(scrollOffset, scrollOffset + VISIBLE_MODELS).map((model, displayIndex) => {
|
|
121139
|
+
const actualIndex = scrollOffset + displayIndex;
|
|
121140
|
+
const isSelected = actualIndex === selectedModelIndex;
|
|
120787
121141
|
const prefix = isSelected ? ">" : " ";
|
|
120788
121142
|
return /* @__PURE__ */ jsxs22(
|
|
120789
121143
|
Text26,
|
|
@@ -120805,10 +121159,10 @@ function AddCustomEndpointDialog({
|
|
|
120805
121159
|
model.id
|
|
120806
121160
|
);
|
|
120807
121161
|
}),
|
|
120808
|
-
availableModels.length
|
|
120809
|
-
"
|
|
120810
|
-
availableModels.length -
|
|
120811
|
-
" more
|
|
121162
|
+
scrollOffset + VISIBLE_MODELS < availableModels.length && /* @__PURE__ */ jsxs22(Text26, { color: Colors.Gray, children: [
|
|
121163
|
+
"\u2193 ",
|
|
121164
|
+
availableModels.length - (scrollOffset + VISIBLE_MODELS),
|
|
121165
|
+
" more below"
|
|
120812
121166
|
] })
|
|
120813
121167
|
] }),
|
|
120814
121168
|
/* @__PURE__ */ jsx25(Box19, { marginTop: 1, children: /* @__PURE__ */ jsx25(Text26, { color: Colors.Gray, children: "\u2191/\u2193 to navigate, Enter to confirm, Esc to cancel" }) })
|
|
@@ -121098,17 +121452,9 @@ function AuthDialog({
|
|
|
121098
121452
|
);
|
|
121099
121453
|
if (endpointId && modelId) {
|
|
121100
121454
|
await db.linkModelToEndpoint(modelId, endpointId);
|
|
121101
|
-
await db.
|
|
121102
|
-
modelId,
|
|
121103
|
-
// Set provider_id to the model ID
|
|
121104
|
-
name2,
|
|
121105
|
-
url2,
|
|
121106
|
-
`Custom ${providerType} endpoint`,
|
|
121107
|
-
false
|
|
121108
|
-
);
|
|
121109
|
-
console.log(`\u{1F4BE} [AUTH-DIALOG] Linked custom_endpoints.provider_id=${modelId} for endpoint ${endpointId}`);
|
|
121455
|
+
await db.updateEndpointProviderId(endpointId, modelId);
|
|
121110
121456
|
await db.forceSave();
|
|
121111
|
-
console.log(`\u{1F4BE} [AUTH-DIALOG]
|
|
121457
|
+
console.log(`\u{1F4BE} [AUTH-DIALOG] Bidirectional link created: model ${modelId} \u2194 endpoint ${endpointId}`);
|
|
121112
121458
|
}
|
|
121113
121459
|
onSelect(providerType, "User" /* User */);
|
|
121114
121460
|
};
|
|
@@ -121481,85 +121827,104 @@ function EnhancedModelSelectionDialog({
|
|
|
121481
121827
|
onBack,
|
|
121482
121828
|
onCancel
|
|
121483
121829
|
}) {
|
|
121484
|
-
const [
|
|
121830
|
+
const [allModels, setAllModels] = useState37([]);
|
|
121485
121831
|
const [selectedIndex, setSelectedIndex] = useState37(0);
|
|
121832
|
+
const [scrollOffset, setScrollOffset] = useState37(0);
|
|
121486
121833
|
const [loading, setLoading] = useState37(true);
|
|
121487
121834
|
const [error, setError] = useState37(null);
|
|
121488
121835
|
const [switching, setSwitching] = useState37(false);
|
|
121489
|
-
const
|
|
121490
|
-
|
|
121491
|
-
|
|
121492
|
-
|
|
121493
|
-
|
|
121494
|
-
|
|
121495
|
-
const
|
|
121496
|
-
|
|
121497
|
-
|
|
121498
|
-
|
|
121499
|
-
|
|
121500
|
-
|
|
121501
|
-
|
|
121836
|
+
const VISIBLE_MODELS = 15;
|
|
121837
|
+
useEffect35(() => {
|
|
121838
|
+
const loadAndFetchModels = async () => {
|
|
121839
|
+
setLoading(true);
|
|
121840
|
+
setError(null);
|
|
121841
|
+
try {
|
|
121842
|
+
const modelManager = getModelManager();
|
|
121843
|
+
const allDbModels = await modelManager.getAllModels();
|
|
121844
|
+
const existing = allDbModels.filter(
|
|
121845
|
+
(m) => m.authType === providerType && (!endpointUrl || m.endpointUrl === endpointUrl)
|
|
121846
|
+
);
|
|
121847
|
+
const activeModel = allDbModels.find((m) => m.isActive);
|
|
121848
|
+
const activeModelId = activeModel?.modelName;
|
|
121849
|
+
console.error(`[DEBUG] Fetching models for ${providerType} from ${endpointUrl || "default"}`);
|
|
121850
|
+
const fetched = await fetchModelsFromProvider(providerType, endpointUrl);
|
|
121851
|
+
const existingModelNames = new Set(existing.map((m) => m.modelName));
|
|
121852
|
+
const merged = fetched.map((fm) => ({
|
|
121853
|
+
...fm,
|
|
121854
|
+
isNew: !existingModelNames.has(fm.id),
|
|
121855
|
+
isExisting: existingModelNames.has(fm.id),
|
|
121856
|
+
isActive: fm.id === activeModelId
|
|
121857
|
+
}));
|
|
121858
|
+
merged.sort((a, b) => {
|
|
121859
|
+
if (a.isActive && !b.isActive) return -1;
|
|
121860
|
+
if (!a.isActive && b.isActive) return 1;
|
|
121861
|
+
if (a.isExisting && !b.isExisting) return -1;
|
|
121862
|
+
if (!a.isExisting && b.isExisting) return 1;
|
|
121863
|
+
return 0;
|
|
121864
|
+
});
|
|
121865
|
+
setAllModels(merged);
|
|
121866
|
+
setLoading(false);
|
|
121867
|
+
} catch (err) {
|
|
121868
|
+
setError(err instanceof Error ? err.message : "Failed to fetch models");
|
|
121502
121869
|
setLoading(false);
|
|
121503
|
-
return;
|
|
121504
|
-
}
|
|
121505
|
-
filtered.sort((a, b) => {
|
|
121506
|
-
if (a.isFavorite && !b.isFavorite) return -1;
|
|
121507
|
-
if (!a.isFavorite && b.isFavorite) return 1;
|
|
121508
|
-
if (a.isActive && !b.isActive) return -1;
|
|
121509
|
-
if (!a.isActive && b.isActive) return 1;
|
|
121510
|
-
return a.modelName.localeCompare(b.modelName);
|
|
121511
|
-
});
|
|
121512
|
-
const activeIndex = filtered.findIndex((m) => m.isActive);
|
|
121513
|
-
if (activeIndex !== -1) {
|
|
121514
|
-
setSelectedIndex(activeIndex);
|
|
121515
121870
|
}
|
|
121516
|
-
|
|
121517
|
-
|
|
121518
|
-
} catch (err) {
|
|
121519
|
-
setError(err instanceof Error ? err.message : "Failed to load models");
|
|
121520
|
-
setLoading(false);
|
|
121521
|
-
}
|
|
121522
|
-
};
|
|
121523
|
-
useEffect35(() => {
|
|
121524
|
-
loadModels();
|
|
121871
|
+
};
|
|
121872
|
+
loadAndFetchModels();
|
|
121525
121873
|
}, [providerType, endpointUrl]);
|
|
121526
121874
|
useInput6((input, key) => {
|
|
121527
121875
|
if (loading || switching) return;
|
|
121528
|
-
if (key.escape) {
|
|
121876
|
+
if (key.escape || input === "b" || input === "B") {
|
|
121529
121877
|
onBack();
|
|
121530
121878
|
return;
|
|
121531
121879
|
}
|
|
121532
|
-
if (
|
|
121533
|
-
const
|
|
121534
|
-
|
|
121535
|
-
|
|
121536
|
-
|
|
121537
|
-
loadModels();
|
|
121538
|
-
}).catch((err) => {
|
|
121539
|
-
console.error("Failed to toggle favorite:", err);
|
|
121540
|
-
});
|
|
121880
|
+
if (key.upArrow && selectedIndex > 0) {
|
|
121881
|
+
const newIndex = selectedIndex - 1;
|
|
121882
|
+
setSelectedIndex(newIndex);
|
|
121883
|
+
if (newIndex < scrollOffset) {
|
|
121884
|
+
setScrollOffset(newIndex);
|
|
121541
121885
|
}
|
|
121542
121886
|
return;
|
|
121543
121887
|
}
|
|
121544
|
-
if (
|
|
121545
|
-
|
|
121546
|
-
|
|
121547
|
-
|
|
121548
|
-
|
|
121549
|
-
modelManager.switchToModel(selectedModel.id).then(() => {
|
|
121550
|
-
onComplete();
|
|
121551
|
-
}).catch((err) => {
|
|
121552
|
-
setError(err instanceof Error ? err.message : "Failed to switch model");
|
|
121553
|
-
setSwitching(false);
|
|
121554
|
-
});
|
|
121888
|
+
if (key.downArrow && selectedIndex < allModels.length - 1) {
|
|
121889
|
+
const newIndex = selectedIndex + 1;
|
|
121890
|
+
setSelectedIndex(newIndex);
|
|
121891
|
+
if (newIndex >= scrollOffset + VISIBLE_MODELS) {
|
|
121892
|
+
setScrollOffset(newIndex - VISIBLE_MODELS + 1);
|
|
121555
121893
|
}
|
|
121556
121894
|
return;
|
|
121557
121895
|
}
|
|
121558
|
-
if (key.
|
|
121559
|
-
|
|
121560
|
-
|
|
121561
|
-
|
|
121562
|
-
|
|
121896
|
+
if (key.return && allModels.length > 0) {
|
|
121897
|
+
const selectedModel = allModels[selectedIndex];
|
|
121898
|
+
setSwitching(true);
|
|
121899
|
+
const modelManager = getModelManager();
|
|
121900
|
+
(async () => {
|
|
121901
|
+
try {
|
|
121902
|
+
if (selectedModel.isNew) {
|
|
121903
|
+
console.error(`[DEBUG] Auto-adding new model: ${selectedModel.id}`);
|
|
121904
|
+
await modelManager.configureModel(
|
|
121905
|
+
providerType,
|
|
121906
|
+
selectedModel.id,
|
|
121907
|
+
endpointUrl,
|
|
121908
|
+
void 0,
|
|
121909
|
+
// No API key needed for already configured endpoints
|
|
121910
|
+
selectedModel.id
|
|
121911
|
+
// Use model ID as display name
|
|
121912
|
+
);
|
|
121913
|
+
}
|
|
121914
|
+
const allDbModels = await modelManager.getAllModels();
|
|
121915
|
+
const dbModel = allDbModels.find((m) => m.modelName === selectedModel.id);
|
|
121916
|
+
if (dbModel?.id) {
|
|
121917
|
+
await modelManager.switchToModel(dbModel.id);
|
|
121918
|
+
onComplete();
|
|
121919
|
+
} else {
|
|
121920
|
+
throw new Error("Failed to find model after adding");
|
|
121921
|
+
}
|
|
121922
|
+
} catch (err) {
|
|
121923
|
+
setError(err instanceof Error ? err.message : "Failed to switch model");
|
|
121924
|
+
setSwitching(false);
|
|
121925
|
+
}
|
|
121926
|
+
})();
|
|
121927
|
+
return;
|
|
121563
121928
|
}
|
|
121564
121929
|
});
|
|
121565
121930
|
if (loading) {
|
|
@@ -121572,11 +121937,8 @@ function EnhancedModelSelectionDialog({
|
|
|
121572
121937
|
padding: 1,
|
|
121573
121938
|
width: "100%",
|
|
121574
121939
|
children: [
|
|
121575
|
-
/* @__PURE__ */
|
|
121576
|
-
|
|
121577
|
-
endpointLabel
|
|
121578
|
-
] }),
|
|
121579
|
-
/* @__PURE__ */ jsx29(Box23, { marginTop: 1, children: /* @__PURE__ */ jsx29(Text30, { children: "Loading models..." }) })
|
|
121940
|
+
/* @__PURE__ */ jsx29(Text30, { bold: true, color: Colors.AccentBlue, children: "Model Selection" }),
|
|
121941
|
+
/* @__PURE__ */ jsx29(Box23, { marginTop: 1, children: /* @__PURE__ */ jsx29(Text30, { children: "Loading configured models..." }) })
|
|
121580
121942
|
]
|
|
121581
121943
|
}
|
|
121582
121944
|
);
|
|
@@ -121594,7 +121956,7 @@ function EnhancedModelSelectionDialog({
|
|
|
121594
121956
|
/* @__PURE__ */ jsx29(Text30, { bold: true, color: Colors.AccentBlue, children: "Switching Model" }),
|
|
121595
121957
|
/* @__PURE__ */ jsx29(Box23, { marginTop: 1, children: /* @__PURE__ */ jsxs26(Text30, { children: [
|
|
121596
121958
|
"Activating ",
|
|
121597
|
-
|
|
121959
|
+
allModels[selectedIndex]?.id,
|
|
121598
121960
|
"..."
|
|
121599
121961
|
] }) })
|
|
121600
121962
|
]
|
|
@@ -121613,11 +121975,14 @@ function EnhancedModelSelectionDialog({
|
|
|
121613
121975
|
children: [
|
|
121614
121976
|
/* @__PURE__ */ jsx29(Text30, { bold: true, color: Colors.AccentRed, children: "Model Selection Error" }),
|
|
121615
121977
|
/* @__PURE__ */ jsx29(Box23, { marginTop: 1, children: /* @__PURE__ */ jsx29(Text30, { children: error }) }),
|
|
121616
|
-
/* @__PURE__ */ jsx29(Box23, { marginTop: 1, children: /* @__PURE__ */ jsx29(Text30, { color: Colors.Gray, children: "Press Esc to
|
|
121978
|
+
/* @__PURE__ */ jsx29(Box23, { marginTop: 1, children: /* @__PURE__ */ jsx29(Text30, { color: Colors.Gray, children: "Press Esc to cancel" }) })
|
|
121617
121979
|
]
|
|
121618
121980
|
}
|
|
121619
121981
|
);
|
|
121620
121982
|
}
|
|
121983
|
+
const visibleModels = allModels.slice(scrollOffset, scrollOffset + VISIBLE_MODELS);
|
|
121984
|
+
const modelsAbove = scrollOffset;
|
|
121985
|
+
const modelsBelow = Math.max(0, allModels.length - (scrollOffset + VISIBLE_MODELS));
|
|
121621
121986
|
return /* @__PURE__ */ jsxs26(
|
|
121622
121987
|
Box23,
|
|
121623
121988
|
{
|
|
@@ -121629,15 +121994,35 @@ function EnhancedModelSelectionDialog({
|
|
|
121629
121994
|
children: [
|
|
121630
121995
|
/* @__PURE__ */ jsxs26(Text30, { bold: true, color: Colors.AccentBlue, children: [
|
|
121631
121996
|
"Model Selection - ",
|
|
121632
|
-
|
|
121997
|
+
providerType
|
|
121633
121998
|
] }),
|
|
121634
|
-
/* @__PURE__ */ jsx29(Box23, { marginTop: 1, children: /* @__PURE__ */
|
|
121635
|
-
|
|
121636
|
-
|
|
121999
|
+
endpointLabel && /* @__PURE__ */ jsx29(Box23, { marginTop: 1, children: /* @__PURE__ */ jsxs26(Text30, { color: Colors.Gray, children: [
|
|
122000
|
+
"Endpoint: ",
|
|
122001
|
+
endpointLabel
|
|
122002
|
+
] }) }),
|
|
122003
|
+
/* @__PURE__ */ jsx29(Box23, { marginTop: 1, children: /* @__PURE__ */ jsxs26(Text30, { children: [
|
|
122004
|
+
"Select a model (",
|
|
122005
|
+
allModels.length,
|
|
122006
|
+
" available):"
|
|
122007
|
+
] }) }),
|
|
122008
|
+
modelsAbove > 0 && /* @__PURE__ */ jsx29(Box23, { marginTop: 1, children: /* @__PURE__ */ jsxs26(Text30, { color: Colors.Gray, children: [
|
|
122009
|
+
"\u2191 ",
|
|
122010
|
+
modelsAbove,
|
|
122011
|
+
" more above"
|
|
122012
|
+
] }) }),
|
|
122013
|
+
/* @__PURE__ */ jsx29(Box23, { marginTop: 1, flexDirection: "column", children: visibleModels.map((model, visibleIndex) => {
|
|
122014
|
+
const actualIndex = scrollOffset + visibleIndex;
|
|
122015
|
+
const isSelected = actualIndex === selectedIndex;
|
|
121637
122016
|
const prefix = isSelected ? ">" : " ";
|
|
121638
|
-
|
|
121639
|
-
|
|
121640
|
-
|
|
122017
|
+
let statusIcon = "";
|
|
122018
|
+
if (model.isActive) {
|
|
122019
|
+
statusIcon = "\u25CF ";
|
|
122020
|
+
} else if (model.isNew) {
|
|
122021
|
+
statusIcon = "\u{1F195} ";
|
|
122022
|
+
} else if (model.isExisting) {
|
|
122023
|
+
statusIcon = "\u2713 ";
|
|
122024
|
+
}
|
|
122025
|
+
const label = `${prefix} ${statusIcon}${model.id}`;
|
|
121641
122026
|
return /* @__PURE__ */ jsx29(
|
|
121642
122027
|
Text30,
|
|
121643
122028
|
{
|
|
@@ -121645,15 +122030,16 @@ function EnhancedModelSelectionDialog({
|
|
|
121645
122030
|
bold: isSelected,
|
|
121646
122031
|
children: label
|
|
121647
122032
|
},
|
|
121648
|
-
model.id
|
|
122033
|
+
model.id
|
|
121649
122034
|
);
|
|
121650
122035
|
}) }),
|
|
121651
|
-
/* @__PURE__ */ jsx29(Box23, { marginTop: 1, children: /* @__PURE__ */
|
|
121652
|
-
|
|
121653
|
-
|
|
121654
|
-
"
|
|
121655
|
-
|
|
121656
|
-
|
|
122036
|
+
modelsBelow > 0 && /* @__PURE__ */ jsx29(Box23, { marginTop: 1, children: /* @__PURE__ */ jsxs26(Text30, { color: Colors.Gray, children: [
|
|
122037
|
+
"\u2193 ",
|
|
122038
|
+
modelsBelow,
|
|
122039
|
+
" more below"
|
|
122040
|
+
] }) }),
|
|
122041
|
+
/* @__PURE__ */ jsx29(Box23, { marginTop: 1, children: /* @__PURE__ */ jsx29(Text30, { color: Colors.Gray, children: "\u2191/\u2193 to navigate, Enter to select, Esc/b to go back" }) }),
|
|
122042
|
+
/* @__PURE__ */ jsx29(Box23, { marginTop: 1, children: /* @__PURE__ */ jsx29(Text30, { color: Colors.Gray, children: "\u{1F195} = new model, \u2713 = existing, \u25CF = currently active" }) })
|
|
121657
122043
|
]
|
|
121658
122044
|
}
|
|
121659
122045
|
);
|
|
@@ -123358,14 +123744,18 @@ async function loadCliConfig(settings, extensions, sessionId2, argv, cwd3 = proc
|
|
|
123358
123744
|
const { SearchEngineConfigProvider: SearchEngineConfigProvider2 } = await Promise.resolve().then(() => (init_SearchEngineConfigProvider(), SearchEngineConfigProvider_exports));
|
|
123359
123745
|
const configProvider = SearchEngineConfigProvider2.getInstance();
|
|
123360
123746
|
const config2 = await configProvider.loadConfiguration();
|
|
123361
|
-
|
|
123362
|
-
|
|
123363
|
-
|
|
123364
|
-
|
|
123365
|
-
|
|
123366
|
-
|
|
123747
|
+
if (debugMode) {
|
|
123748
|
+
console.log("[API KEY DEBUG] Search engine config loaded at startup:", {
|
|
123749
|
+
hasBrave: !!config2.braveApiKey,
|
|
123750
|
+
hasTavily: !!config2.tavilyApiKey,
|
|
123751
|
+
braveEnvSet: !!process16.env["BRAVE_SEARCH_API_KEY"],
|
|
123752
|
+
tavilyEnvSet: !!process16.env["TAVILY_API_KEY"]
|
|
123753
|
+
});
|
|
123754
|
+
}
|
|
123367
123755
|
} catch (error) {
|
|
123368
|
-
|
|
123756
|
+
if (debugMode) {
|
|
123757
|
+
console.error("[API KEY DEBUG] Failed to load search engine config at startup:", error);
|
|
123758
|
+
}
|
|
123369
123759
|
}
|
|
123370
123760
|
const webScraperConfigLoader = () => {
|
|
123371
123761
|
try {
|
|
@@ -131452,6 +131842,11 @@ main().catch((error) => {
|
|
|
131452
131842
|
* Copyright 2025 FSS Coding
|
|
131453
131843
|
* SPDX-License-Identifier: Apache-2.0
|
|
131454
131844
|
*/
|
|
131845
|
+
/**
|
|
131846
|
+
* @license
|
|
131847
|
+
* Copyright 2025 Google LLC
|
|
131848
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
131849
|
+
*/
|
|
131455
131850
|
/*! Bundled license information:
|
|
131456
131851
|
|
|
131457
131852
|
js-yaml/dist/js-yaml.mjs:
|