claudish 2.6.0 → 2.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +200 -7
- package/package.json +1 -1
- package/recommended-models.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31649,11 +31649,15 @@ function fuzzyScore2(text, query) {
|
|
|
31649
31649
|
// src/cli.ts
|
|
31650
31650
|
var exports_cli = {};
|
|
31651
31651
|
__export(exports_cli, {
|
|
31652
|
-
parseArgs: () => parseArgs
|
|
31652
|
+
parseArgs: () => parseArgs,
|
|
31653
|
+
getVersion: () => getVersion
|
|
31653
31654
|
});
|
|
31654
31655
|
import { readFileSync as readFileSync3, writeFileSync as writeFileSync4, existsSync as existsSync3, mkdirSync, copyFileSync } from "node:fs";
|
|
31655
31656
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
31656
31657
|
import { dirname as dirname3, join as join4 } from "node:path";
|
|
31658
|
+
function getVersion() {
|
|
31659
|
+
return VERSION;
|
|
31660
|
+
}
|
|
31657
31661
|
async function parseArgs(args) {
|
|
31658
31662
|
const config3 = {
|
|
31659
31663
|
model: undefined,
|
|
@@ -36152,6 +36156,8 @@ class OpenRouterHandler {
|
|
|
36152
36156
|
let ping = null;
|
|
36153
36157
|
const encoder = new TextEncoder;
|
|
36154
36158
|
const decoder = new TextDecoder;
|
|
36159
|
+
const middlewareManager = this.middlewareManager;
|
|
36160
|
+
const streamMetadata = new Map;
|
|
36155
36161
|
return c.body(new ReadableStream({
|
|
36156
36162
|
async start(controller) {
|
|
36157
36163
|
const send = (e, d) => {
|
|
@@ -36173,7 +36179,6 @@ data: ${JSON.stringify(d)}
|
|
|
36173
36179
|
const toolIds = new Set;
|
|
36174
36180
|
let accTxt = 0;
|
|
36175
36181
|
let lastActivity = Date.now();
|
|
36176
|
-
const scale = 128000 / 128000;
|
|
36177
36182
|
send("message_start", {
|
|
36178
36183
|
type: "message_start",
|
|
36179
36184
|
message: {
|
|
@@ -36192,7 +36197,7 @@ data: ${JSON.stringify(d)}
|
|
|
36192
36197
|
if (!isClosed && Date.now() - lastActivity > 1000)
|
|
36193
36198
|
send("ping", { type: "ping" });
|
|
36194
36199
|
}, 1000);
|
|
36195
|
-
const finalize = (reason, err) => {
|
|
36200
|
+
const finalize = async (reason, err) => {
|
|
36196
36201
|
if (finalized)
|
|
36197
36202
|
return;
|
|
36198
36203
|
finalized = true;
|
|
@@ -36209,6 +36214,7 @@ data: ${JSON.stringify(d)}
|
|
|
36209
36214
|
send("content_block_stop", { type: "content_block_stop", index: t.blockIndex });
|
|
36210
36215
|
t.closed = true;
|
|
36211
36216
|
}
|
|
36217
|
+
await middlewareManager.afterStreamComplete(target, streamMetadata);
|
|
36212
36218
|
if (reason === "error") {
|
|
36213
36219
|
send("error", { type: "error", error: { type: "api_error", message: err } });
|
|
36214
36220
|
} else {
|
|
@@ -36244,7 +36250,7 @@ data: ${JSON.stringify(d)}
|
|
|
36244
36250
|
continue;
|
|
36245
36251
|
const dataStr = line.slice(6);
|
|
36246
36252
|
if (dataStr === "[DONE]") {
|
|
36247
|
-
finalize("done");
|
|
36253
|
+
await finalize("done");
|
|
36248
36254
|
return;
|
|
36249
36255
|
}
|
|
36250
36256
|
try {
|
|
@@ -36253,6 +36259,12 @@ data: ${JSON.stringify(d)}
|
|
|
36253
36259
|
usage = chunk.usage;
|
|
36254
36260
|
const delta = chunk.choices?.[0]?.delta;
|
|
36255
36261
|
if (delta) {
|
|
36262
|
+
await middlewareManager.afterStreamChunk({
|
|
36263
|
+
modelId: target,
|
|
36264
|
+
chunk,
|
|
36265
|
+
delta,
|
|
36266
|
+
metadata: streamMetadata
|
|
36267
|
+
});
|
|
36256
36268
|
const txt = delta.content || "";
|
|
36257
36269
|
if (txt) {
|
|
36258
36270
|
lastActivity = Date.now();
|
|
@@ -36299,9 +36311,9 @@ data: ${JSON.stringify(d)}
|
|
|
36299
36311
|
} catch (e) {}
|
|
36300
36312
|
}
|
|
36301
36313
|
}
|
|
36302
|
-
finalize("unexpected");
|
|
36314
|
+
await finalize("unexpected");
|
|
36303
36315
|
} catch (e) {
|
|
36304
|
-
finalize("error", String(e));
|
|
36316
|
+
await finalize("error", String(e));
|
|
36305
36317
|
}
|
|
36306
36318
|
},
|
|
36307
36319
|
cancel() {
|
|
@@ -36425,6 +36437,177 @@ var init_proxy_server = __esm(() => {
|
|
|
36425
36437
|
init_openrouter_handler();
|
|
36426
36438
|
});
|
|
36427
36439
|
|
|
36440
|
+
// src/update-checker.ts
|
|
36441
|
+
var exports_update_checker = {};
|
|
36442
|
+
__export(exports_update_checker, {
|
|
36443
|
+
checkForUpdates: () => checkForUpdates
|
|
36444
|
+
});
|
|
36445
|
+
import { execSync } from "node:child_process";
|
|
36446
|
+
import { createInterface as createInterface2 } from "node:readline";
|
|
36447
|
+
import { existsSync as existsSync6, readFileSync as readFileSync5, writeFileSync as writeFileSync8, mkdirSync as mkdirSync3, unlinkSync as unlinkSync2 } from "node:fs";
|
|
36448
|
+
import { join as join7 } from "node:path";
|
|
36449
|
+
import { tmpdir as tmpdir2, homedir } from "node:os";
|
|
36450
|
+
function getCacheFilePath() {
|
|
36451
|
+
const cacheDir = join7(homedir(), ".cache", "claudish");
|
|
36452
|
+
try {
|
|
36453
|
+
if (!existsSync6(cacheDir)) {
|
|
36454
|
+
mkdirSync3(cacheDir, { recursive: true });
|
|
36455
|
+
}
|
|
36456
|
+
return join7(cacheDir, "update-check.json");
|
|
36457
|
+
} catch {
|
|
36458
|
+
return join7(tmpdir2(), "claudish-update-check.json");
|
|
36459
|
+
}
|
|
36460
|
+
}
|
|
36461
|
+
function readCache() {
|
|
36462
|
+
try {
|
|
36463
|
+
const cachePath = getCacheFilePath();
|
|
36464
|
+
if (!existsSync6(cachePath)) {
|
|
36465
|
+
return null;
|
|
36466
|
+
}
|
|
36467
|
+
const data = JSON.parse(readFileSync5(cachePath, "utf-8"));
|
|
36468
|
+
return data;
|
|
36469
|
+
} catch {
|
|
36470
|
+
return null;
|
|
36471
|
+
}
|
|
36472
|
+
}
|
|
36473
|
+
function writeCache(latestVersion) {
|
|
36474
|
+
try {
|
|
36475
|
+
const cachePath = getCacheFilePath();
|
|
36476
|
+
const data = {
|
|
36477
|
+
lastCheck: Date.now(),
|
|
36478
|
+
latestVersion
|
|
36479
|
+
};
|
|
36480
|
+
writeFileSync8(cachePath, JSON.stringify(data), "utf-8");
|
|
36481
|
+
} catch {}
|
|
36482
|
+
}
|
|
36483
|
+
function isCacheValid(cache) {
|
|
36484
|
+
const age = Date.now() - cache.lastCheck;
|
|
36485
|
+
return age < CACHE_MAX_AGE_MS;
|
|
36486
|
+
}
|
|
36487
|
+
function clearCache() {
|
|
36488
|
+
try {
|
|
36489
|
+
const cachePath = getCacheFilePath();
|
|
36490
|
+
if (existsSync6(cachePath)) {
|
|
36491
|
+
unlinkSync2(cachePath);
|
|
36492
|
+
}
|
|
36493
|
+
} catch {}
|
|
36494
|
+
}
|
|
36495
|
+
function compareVersions(v1, v2) {
|
|
36496
|
+
const parts1 = v1.replace(/^v/, "").split(".").map(Number);
|
|
36497
|
+
const parts2 = v2.replace(/^v/, "").split(".").map(Number);
|
|
36498
|
+
for (let i = 0;i < Math.max(parts1.length, parts2.length); i++) {
|
|
36499
|
+
const p1 = parts1[i] || 0;
|
|
36500
|
+
const p2 = parts2[i] || 0;
|
|
36501
|
+
if (p1 > p2)
|
|
36502
|
+
return 1;
|
|
36503
|
+
if (p1 < p2)
|
|
36504
|
+
return -1;
|
|
36505
|
+
}
|
|
36506
|
+
return 0;
|
|
36507
|
+
}
|
|
36508
|
+
async function fetchLatestVersion() {
|
|
36509
|
+
try {
|
|
36510
|
+
const controller = new AbortController;
|
|
36511
|
+
const timeout = setTimeout(() => controller.abort(), 5000);
|
|
36512
|
+
const response = await fetch(NPM_REGISTRY_URL, {
|
|
36513
|
+
signal: controller.signal,
|
|
36514
|
+
headers: { Accept: "application/json" }
|
|
36515
|
+
});
|
|
36516
|
+
clearTimeout(timeout);
|
|
36517
|
+
if (!response.ok) {
|
|
36518
|
+
return null;
|
|
36519
|
+
}
|
|
36520
|
+
const data = await response.json();
|
|
36521
|
+
return data.version || null;
|
|
36522
|
+
} catch {
|
|
36523
|
+
return null;
|
|
36524
|
+
}
|
|
36525
|
+
}
|
|
36526
|
+
function promptUser(question) {
|
|
36527
|
+
return new Promise((resolve) => {
|
|
36528
|
+
const rl = createInterface2({
|
|
36529
|
+
input: process.stdin,
|
|
36530
|
+
output: process.stderr
|
|
36531
|
+
});
|
|
36532
|
+
rl.question(question, (answer) => {
|
|
36533
|
+
rl.close();
|
|
36534
|
+
const normalized = answer.toLowerCase().trim();
|
|
36535
|
+
resolve(normalized === "y" || normalized === "yes");
|
|
36536
|
+
});
|
|
36537
|
+
});
|
|
36538
|
+
}
|
|
36539
|
+
function runUpdate() {
|
|
36540
|
+
try {
|
|
36541
|
+
console.error(`
|
|
36542
|
+
[claudish] Updating...
|
|
36543
|
+
`);
|
|
36544
|
+
const result = execSync("npm install -g claudish@latest", {
|
|
36545
|
+
stdio: "inherit",
|
|
36546
|
+
encoding: "utf-8"
|
|
36547
|
+
});
|
|
36548
|
+
console.error(`
|
|
36549
|
+
[claudish] Update complete! Please restart claudish.
|
|
36550
|
+
`);
|
|
36551
|
+
return true;
|
|
36552
|
+
} catch (error46) {
|
|
36553
|
+
console.error(`
|
|
36554
|
+
[claudish] Update failed. Try manually:`);
|
|
36555
|
+
console.error(` npm install -g claudish@latest
|
|
36556
|
+
`);
|
|
36557
|
+
return false;
|
|
36558
|
+
}
|
|
36559
|
+
}
|
|
36560
|
+
async function checkForUpdates(currentVersion, options = {}) {
|
|
36561
|
+
const { quiet = false, skipPrompt = false } = options;
|
|
36562
|
+
let latestVersion = null;
|
|
36563
|
+
const cache = readCache();
|
|
36564
|
+
if (cache && isCacheValid(cache)) {
|
|
36565
|
+
latestVersion = cache.latestVersion;
|
|
36566
|
+
} else {
|
|
36567
|
+
latestVersion = await fetchLatestVersion();
|
|
36568
|
+
writeCache(latestVersion);
|
|
36569
|
+
}
|
|
36570
|
+
if (!latestVersion) {
|
|
36571
|
+
return false;
|
|
36572
|
+
}
|
|
36573
|
+
if (compareVersions(latestVersion, currentVersion) <= 0) {
|
|
36574
|
+
return false;
|
|
36575
|
+
}
|
|
36576
|
+
if (!quiet) {
|
|
36577
|
+
console.error("");
|
|
36578
|
+
console.error("━".repeat(60));
|
|
36579
|
+
console.error(` New version available: ${currentVersion} → ${latestVersion}`);
|
|
36580
|
+
console.error("━".repeat(60));
|
|
36581
|
+
console.error("");
|
|
36582
|
+
}
|
|
36583
|
+
if (skipPrompt) {
|
|
36584
|
+
if (!quiet) {
|
|
36585
|
+
console.error(` Update with: npm install -g claudish@latest
|
|
36586
|
+
`);
|
|
36587
|
+
}
|
|
36588
|
+
return false;
|
|
36589
|
+
}
|
|
36590
|
+
const shouldUpdate = await promptUser(" Would you like to update now? [y/N] ");
|
|
36591
|
+
if (!shouldUpdate) {
|
|
36592
|
+
if (!quiet) {
|
|
36593
|
+
console.error(`
|
|
36594
|
+
Skipped. Update later with: npm install -g claudish@latest
|
|
36595
|
+
`);
|
|
36596
|
+
}
|
|
36597
|
+
return false;
|
|
36598
|
+
}
|
|
36599
|
+
const success2 = runUpdate();
|
|
36600
|
+
if (success2) {
|
|
36601
|
+
clearCache();
|
|
36602
|
+
return true;
|
|
36603
|
+
}
|
|
36604
|
+
return false;
|
|
36605
|
+
}
|
|
36606
|
+
var NPM_REGISTRY_URL = "https://registry.npmjs.org/claudish/latest", CACHE_MAX_AGE_MS;
|
|
36607
|
+
var init_update_checker = __esm(() => {
|
|
36608
|
+
CACHE_MAX_AGE_MS = 24 * 60 * 60 * 1000;
|
|
36609
|
+
});
|
|
36610
|
+
|
|
36428
36611
|
// src/index.ts
|
|
36429
36612
|
var import_dotenv2 = __toESM(require_main(), 1);
|
|
36430
36613
|
import_dotenv2.config();
|
|
@@ -36436,12 +36619,13 @@ if (isMcpMode) {
|
|
|
36436
36619
|
}
|
|
36437
36620
|
async function runCli() {
|
|
36438
36621
|
const { checkClaudeInstalled: checkClaudeInstalled2, runClaudeWithProxy: runClaudeWithProxy2 } = await Promise.resolve().then(() => (init_claude_runner(), exports_claude_runner));
|
|
36439
|
-
const { parseArgs: parseArgs2 } = await Promise.resolve().then(() => (init_cli(), exports_cli));
|
|
36622
|
+
const { parseArgs: parseArgs2, getVersion: getVersion2 } = await Promise.resolve().then(() => (init_cli(), exports_cli));
|
|
36440
36623
|
const { DEFAULT_PORT_RANGE: DEFAULT_PORT_RANGE2 } = await Promise.resolve().then(() => (init_config(), exports_config));
|
|
36441
36624
|
const { selectModelInteractively: selectModelInteractively2, promptForApiKey: promptForApiKey2 } = await Promise.resolve().then(() => (init_simple_selector(), exports_simple_selector));
|
|
36442
36625
|
const { initLogger: initLogger2, getLogFilePath: getLogFilePath2 } = await Promise.resolve().then(() => (init_logger(), exports_logger));
|
|
36443
36626
|
const { findAvailablePort: findAvailablePort2 } = await Promise.resolve().then(() => (init_port_manager(), exports_port_manager));
|
|
36444
36627
|
const { createProxyServer: createProxyServer2 } = await Promise.resolve().then(() => (init_proxy_server(), exports_proxy_server));
|
|
36628
|
+
const { checkForUpdates: checkForUpdates2 } = await Promise.resolve().then(() => (init_update_checker(), exports_update_checker));
|
|
36445
36629
|
async function readStdin() {
|
|
36446
36630
|
const chunks = [];
|
|
36447
36631
|
for await (const chunk of process.stdin) {
|
|
@@ -36458,6 +36642,15 @@ async function runCli() {
|
|
|
36458
36642
|
console.log(`[claudish] Debug log: ${logFile}`);
|
|
36459
36643
|
}
|
|
36460
36644
|
}
|
|
36645
|
+
if (cliConfig.interactive && !cliConfig.jsonOutput) {
|
|
36646
|
+
const shouldExit = await checkForUpdates2(getVersion2(), {
|
|
36647
|
+
quiet: cliConfig.quiet,
|
|
36648
|
+
skipPrompt: false
|
|
36649
|
+
});
|
|
36650
|
+
if (shouldExit) {
|
|
36651
|
+
process.exit(0);
|
|
36652
|
+
}
|
|
36653
|
+
}
|
|
36461
36654
|
if (!await checkClaudeInstalled2()) {
|
|
36462
36655
|
console.error("Error: Claude Code CLI is not installed");
|
|
36463
36656
|
console.error("Install it from: https://claude.com/claude-code");
|
package/package.json
CHANGED