claudish 3.0.0 → 3.0.2
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 +71 -34
- package/package.json +1 -1
- package/scripts/extract-models.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -31033,7 +31033,7 @@ async function runPrompt(model, prompt, systemPrompt, maxTokens) {
|
|
|
31033
31033
|
headers: {
|
|
31034
31034
|
Authorization: `Bearer ${apiKey}`,
|
|
31035
31035
|
"Content-Type": "application/json",
|
|
31036
|
-
"HTTP-Referer": "https://
|
|
31036
|
+
"HTTP-Referer": "https://claudish.com",
|
|
31037
31037
|
"X-Title": "Claudish MCP"
|
|
31038
31038
|
},
|
|
31039
31039
|
body: JSON.stringify({
|
|
@@ -34312,7 +34312,7 @@ var init_config = __esm(() => {
|
|
|
34312
34312
|
CLAUDISH_SUMMARIZE_TOOLS: "CLAUDISH_SUMMARIZE_TOOLS"
|
|
34313
34313
|
};
|
|
34314
34314
|
OPENROUTER_HEADERS = {
|
|
34315
|
-
"HTTP-Referer": "https://
|
|
34315
|
+
"HTTP-Referer": "https://claudish.com",
|
|
34316
34316
|
"X-Title": "Claudish - OpenRouter Proxy"
|
|
34317
34317
|
};
|
|
34318
34318
|
});
|
|
@@ -34324,16 +34324,17 @@ __export(exports_claude_runner, {
|
|
|
34324
34324
|
checkClaudeInstalled: () => checkClaudeInstalled
|
|
34325
34325
|
});
|
|
34326
34326
|
import { spawn } from "node:child_process";
|
|
34327
|
-
import { writeFileSync as writeFileSync4, unlinkSync } from "node:fs";
|
|
34327
|
+
import { writeFileSync as writeFileSync4, unlinkSync, mkdirSync as mkdirSync2 } from "node:fs";
|
|
34328
34328
|
import { tmpdir } from "node:os";
|
|
34329
34329
|
import { join as join4 } from "node:path";
|
|
34330
34330
|
function isWindows() {
|
|
34331
34331
|
return process.platform === "win32";
|
|
34332
34332
|
}
|
|
34333
34333
|
function createStatusLineScript(tokenFilePath) {
|
|
34334
|
-
const
|
|
34334
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || tmpdir();
|
|
34335
|
+
const claudishDir = join4(homeDir, ".claudish");
|
|
34335
34336
|
const timestamp = Date.now();
|
|
34336
|
-
const scriptPath = join4(
|
|
34337
|
+
const scriptPath = join4(claudishDir, `status-${timestamp}.js`);
|
|
34337
34338
|
const escapedTokenPath = tokenFilePath.replace(/\\/g, "\\\\");
|
|
34338
34339
|
const script = `
|
|
34339
34340
|
const fs = require('fs');
|
|
@@ -34381,10 +34382,14 @@ process.stdin.on('end', () => {
|
|
|
34381
34382
|
return scriptPath;
|
|
34382
34383
|
}
|
|
34383
34384
|
function createTempSettingsFile(modelDisplay, port) {
|
|
34384
|
-
const
|
|
34385
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || tmpdir();
|
|
34386
|
+
const claudishDir = join4(homeDir, ".claudish");
|
|
34387
|
+
try {
|
|
34388
|
+
mkdirSync2(claudishDir, { recursive: true });
|
|
34389
|
+
} catch {}
|
|
34385
34390
|
const timestamp = Date.now();
|
|
34386
|
-
const tempPath = join4(
|
|
34387
|
-
const tokenFilePath = join4(
|
|
34391
|
+
const tempPath = join4(claudishDir, `settings-${timestamp}.json`);
|
|
34392
|
+
const tokenFilePath = join4(claudishDir, `tokens-${port}.json`);
|
|
34388
34393
|
let statusCommand;
|
|
34389
34394
|
if (isWindows()) {
|
|
34390
34395
|
const scriptPath = createStatusLineScript(tokenFilePath);
|
|
@@ -34705,7 +34710,7 @@ __export(exports_cli, {
|
|
|
34705
34710
|
parseArgs: () => parseArgs,
|
|
34706
34711
|
getVersion: () => getVersion
|
|
34707
34712
|
});
|
|
34708
|
-
import { readFileSync as readFileSync5, writeFileSync as writeFileSync6, existsSync as existsSync5, mkdirSync as
|
|
34713
|
+
import { readFileSync as readFileSync5, writeFileSync as writeFileSync6, existsSync as existsSync5, mkdirSync as mkdirSync3, copyFileSync } from "node:fs";
|
|
34709
34714
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
34710
34715
|
import { dirname as dirname4, join as join6 } from "node:path";
|
|
34711
34716
|
function getVersion() {
|
|
@@ -34795,6 +34800,9 @@ async function parseArgs(args) {
|
|
|
34795
34800
|
config3.interactive = true;
|
|
34796
34801
|
} else if (arg === "--debug" || arg === "-d") {
|
|
34797
34802
|
config3.debug = true;
|
|
34803
|
+
if (config3.logLevel === "info") {
|
|
34804
|
+
config3.logLevel = "debug";
|
|
34805
|
+
}
|
|
34798
34806
|
} else if (arg === "--log-level") {
|
|
34799
34807
|
const levelArg = args[++i];
|
|
34800
34808
|
if (!levelArg || !["debug", "info", "minimal"].includes(levelArg)) {
|
|
@@ -35558,15 +35566,15 @@ async function initializeClaudishSkill() {
|
|
|
35558
35566
|
}
|
|
35559
35567
|
try {
|
|
35560
35568
|
if (!existsSync5(claudeDir)) {
|
|
35561
|
-
|
|
35569
|
+
mkdirSync3(claudeDir, { recursive: true });
|
|
35562
35570
|
console.log("\uD83D\uDCC1 Created .claude/ directory");
|
|
35563
35571
|
}
|
|
35564
35572
|
if (!existsSync5(skillsDir)) {
|
|
35565
|
-
|
|
35573
|
+
mkdirSync3(skillsDir, { recursive: true });
|
|
35566
35574
|
console.log("\uD83D\uDCC1 Created .claude/skills/ directory");
|
|
35567
35575
|
}
|
|
35568
35576
|
if (!existsSync5(claudishSkillDir)) {
|
|
35569
|
-
|
|
35577
|
+
mkdirSync3(claudishSkillDir, { recursive: true });
|
|
35570
35578
|
console.log("\uD83D\uDCC1 Created .claude/skills/claudish-usage/ directory");
|
|
35571
35579
|
}
|
|
35572
35580
|
copyFileSync(sourceSkillPath, skillFile);
|
|
@@ -35712,7 +35720,7 @@ __export(exports_logger, {
|
|
|
35712
35720
|
getLogLevel: () => getLogLevel,
|
|
35713
35721
|
getLogFilePath: () => getLogFilePath
|
|
35714
35722
|
});
|
|
35715
|
-
import { writeFileSync as writeFileSync7, appendFile, existsSync as existsSync6, mkdirSync as
|
|
35723
|
+
import { writeFileSync as writeFileSync7, appendFile, existsSync as existsSync6, mkdirSync as mkdirSync4 } from "fs";
|
|
35716
35724
|
import { join as join7 } from "path";
|
|
35717
35725
|
function flushLogBuffer() {
|
|
35718
35726
|
if (!logFilePath || logBuffer.length === 0)
|
|
@@ -35754,7 +35762,7 @@ function initLogger(debugMode, level = "info") {
|
|
|
35754
35762
|
logLevel = level;
|
|
35755
35763
|
const logsDir = join7(process.cwd(), "logs");
|
|
35756
35764
|
if (!existsSync6(logsDir)) {
|
|
35757
|
-
|
|
35765
|
+
mkdirSync4(logsDir, { recursive: true });
|
|
35758
35766
|
}
|
|
35759
35767
|
const timestamp = new Date().toISOString().replace(/[:.]/g, "-").split("T").join("_").slice(0, -5);
|
|
35760
35768
|
logFilePath = join7(logsDir, `claudish_${timestamp}.log`);
|
|
@@ -39859,11 +39867,30 @@ class OpenRouterHandler {
|
|
|
39859
39867
|
const claudePayload = payload;
|
|
39860
39868
|
const target = this.targetModel;
|
|
39861
39869
|
await this.fetchContextWindow(target);
|
|
39862
|
-
logStructured(`OpenRouter Request`, { targetModel: target, originalModel: claudePayload.model });
|
|
39863
39870
|
const { claudeRequest, droppedParams } = transformOpenAIToClaude(claudePayload);
|
|
39864
39871
|
const messages = this.convertMessages(claudeRequest, target);
|
|
39865
39872
|
const tools = this.convertTools(claudeRequest);
|
|
39866
39873
|
const supportsReasoning = await doesModelSupportReasoning(target);
|
|
39874
|
+
const systemPromptLength = typeof claudeRequest.system === "string" ? claudeRequest.system.length : 0;
|
|
39875
|
+
logStructured(`OpenRouter Request`, {
|
|
39876
|
+
targetModel: target,
|
|
39877
|
+
originalModel: claudePayload.model,
|
|
39878
|
+
messageCount: messages.length,
|
|
39879
|
+
toolCount: tools.length,
|
|
39880
|
+
systemPromptLength,
|
|
39881
|
+
maxTokens: claudeRequest.max_tokens
|
|
39882
|
+
});
|
|
39883
|
+
if (getLogLevel() === "debug") {
|
|
39884
|
+
const lastUserMsg = messages.filter((m) => m.role === "user").pop();
|
|
39885
|
+
if (lastUserMsg) {
|
|
39886
|
+
const content = typeof lastUserMsg.content === "string" ? lastUserMsg.content : JSON.stringify(lastUserMsg.content);
|
|
39887
|
+
log(`[OpenRouter] Last user message: ${truncateContent(content, 500)}`);
|
|
39888
|
+
}
|
|
39889
|
+
if (tools.length > 0) {
|
|
39890
|
+
const toolNames = tools.map((t) => t.function?.name || t.name).join(", ");
|
|
39891
|
+
log(`[OpenRouter] Tools: ${toolNames}`);
|
|
39892
|
+
}
|
|
39893
|
+
}
|
|
39867
39894
|
const openRouterPayload = {
|
|
39868
39895
|
model: target,
|
|
39869
39896
|
messages,
|
|
@@ -39898,8 +39925,12 @@ class OpenRouterHandler {
|
|
|
39898
39925
|
},
|
|
39899
39926
|
body: JSON.stringify(openRouterPayload)
|
|
39900
39927
|
});
|
|
39901
|
-
|
|
39902
|
-
|
|
39928
|
+
log(`[OpenRouter] Response status: ${response.status}`);
|
|
39929
|
+
if (!response.ok) {
|
|
39930
|
+
const errorText = await response.text();
|
|
39931
|
+
log(`[OpenRouter] Error: ${errorText}`);
|
|
39932
|
+
return c.json({ error: errorText }, response.status);
|
|
39933
|
+
}
|
|
39903
39934
|
if (droppedParams.length > 0)
|
|
39904
39935
|
c.header("X-Dropped-Params", droppedParams.join(", "));
|
|
39905
39936
|
return this.handleStreamingResponse(c, response, adapter, target, claudeRequest);
|
|
@@ -40008,6 +40039,7 @@ class OpenRouterHandler {
|
|
|
40008
40039
|
const encoder = new TextEncoder;
|
|
40009
40040
|
const decoder = new TextDecoder;
|
|
40010
40041
|
const middlewareManager = this.middlewareManager;
|
|
40042
|
+
const writeTokens = (input, output) => this.writeTokenFile(input, output);
|
|
40011
40043
|
const streamMetadata = new Map;
|
|
40012
40044
|
return c.body(new ReadableStream({
|
|
40013
40045
|
async start(controller) {
|
|
@@ -40065,10 +40097,22 @@ data: ${JSON.stringify(d)}
|
|
|
40065
40097
|
send("content_block_stop", { type: "content_block_stop", index: t.blockIndex });
|
|
40066
40098
|
t.closed = true;
|
|
40067
40099
|
}
|
|
40100
|
+
if (tools.size > 0) {
|
|
40101
|
+
const toolSummary = Array.from(tools.values()).map((t) => `${t.name}(${t.arguments.length} chars)`).join(", ");
|
|
40102
|
+
log(`[OpenRouter] Tool calls: ${toolSummary}`);
|
|
40103
|
+
}
|
|
40104
|
+
if (usage) {
|
|
40105
|
+
log(`[OpenRouter] Usage: prompt=${usage.prompt_tokens || 0}, completion=${usage.completion_tokens || 0}, total=${usage.total_tokens || 0}`);
|
|
40106
|
+
writeTokens(usage.prompt_tokens || 0, usage.completion_tokens || 0);
|
|
40107
|
+
} else {
|
|
40108
|
+
log(`[OpenRouter] Warning: No usage data received from model`);
|
|
40109
|
+
}
|
|
40068
40110
|
await middlewareManager.afterStreamComplete(target, streamMetadata);
|
|
40069
40111
|
if (reason === "error") {
|
|
40112
|
+
log(`[OpenRouter] Stream error: ${err}`);
|
|
40070
40113
|
send("error", { type: "error", error: { type: "api_error", message: err } });
|
|
40071
40114
|
} else {
|
|
40115
|
+
log(`[OpenRouter] Stream complete: ${reason}`);
|
|
40072
40116
|
send("message_delta", { type: "message_delta", delta: { stop_reason: "end_turn", stop_sequence: null }, usage: { output_tokens: usage?.completion_tokens || 0 } });
|
|
40073
40117
|
send("message_stop", { type: "message_stop" });
|
|
40074
40118
|
}
|
|
@@ -40160,6 +40204,8 @@ data: ${JSON.stringify(d)}
|
|
|
40160
40204
|
if (toolSchemas.length > 0) {
|
|
40161
40205
|
const validation = validateToolArguments(t.name, t.arguments, toolSchemas);
|
|
40162
40206
|
if (!validation.valid) {
|
|
40207
|
+
log(`[OpenRouter] Tool validation FAILED: ${t.name} - missing: ${validation.missingParams.join(", ")}`);
|
|
40208
|
+
log(`[OpenRouter] Tool args received: ${truncateContent(t.arguments, 300)}`);
|
|
40163
40209
|
const errorIdx = curIdx++;
|
|
40164
40210
|
const errorMsg = `
|
|
40165
40211
|
|
|
@@ -40171,6 +40217,7 @@ data: ${JSON.stringify(d)}
|
|
|
40171
40217
|
continue;
|
|
40172
40218
|
}
|
|
40173
40219
|
}
|
|
40220
|
+
log(`[OpenRouter] Tool validated: ${t.name}`);
|
|
40174
40221
|
send("content_block_stop", { type: "content_block_stop", index: t.blockIndex });
|
|
40175
40222
|
t.closed = true;
|
|
40176
40223
|
}
|
|
@@ -40202,7 +40249,7 @@ var init_openrouter_handler = __esm(() => {
|
|
|
40202
40249
|
init_model_loader();
|
|
40203
40250
|
init_openai_compat();
|
|
40204
40251
|
OPENROUTER_HEADERS2 = {
|
|
40205
|
-
"HTTP-Referer": "https://
|
|
40252
|
+
"HTTP-Referer": "https://claudish.com",
|
|
40206
40253
|
"X-Title": "Claudish - OpenRouter Proxy"
|
|
40207
40254
|
};
|
|
40208
40255
|
});
|
|
@@ -61020,18 +61067,6 @@ async function createProxyServer(port, openrouterApiKey, model, monitorMode = fa
|
|
|
61020
61067
|
}
|
|
61021
61068
|
return null;
|
|
61022
61069
|
};
|
|
61023
|
-
const initHandler = (m) => {
|
|
61024
|
-
if (!m)
|
|
61025
|
-
return;
|
|
61026
|
-
const localHandler = getLocalProviderHandler(m);
|
|
61027
|
-
if (!localHandler && m.includes("/"))
|
|
61028
|
-
getOpenRouterHandler(m);
|
|
61029
|
-
};
|
|
61030
|
-
initHandler(model);
|
|
61031
|
-
initHandler(modelMap?.opus);
|
|
61032
|
-
initHandler(modelMap?.sonnet);
|
|
61033
|
-
initHandler(modelMap?.haiku);
|
|
61034
|
-
initHandler(modelMap?.subagent);
|
|
61035
61070
|
const getHandlerForRequest = (requestedModel) => {
|
|
61036
61071
|
if (monitorMode)
|
|
61037
61072
|
return nativeHandler;
|
|
@@ -61118,7 +61153,7 @@ __export(exports_update_checker, {
|
|
|
61118
61153
|
});
|
|
61119
61154
|
import { execSync } from "node:child_process";
|
|
61120
61155
|
import { createInterface as createInterface2 } from "node:readline";
|
|
61121
|
-
import { existsSync as existsSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync10, mkdirSync as
|
|
61156
|
+
import { existsSync as existsSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync10, mkdirSync as mkdirSync5, unlinkSync as unlinkSync2 } from "node:fs";
|
|
61122
61157
|
import { join as join10 } from "node:path";
|
|
61123
61158
|
import { tmpdir as tmpdir4, homedir as homedir2, platform } from "node:os";
|
|
61124
61159
|
function getCacheFilePath() {
|
|
@@ -61131,7 +61166,7 @@ function getCacheFilePath() {
|
|
|
61131
61166
|
}
|
|
61132
61167
|
try {
|
|
61133
61168
|
if (!existsSync7(cacheDir)) {
|
|
61134
|
-
|
|
61169
|
+
mkdirSync5(cacheDir, { recursive: true });
|
|
61135
61170
|
}
|
|
61136
61171
|
return join10(cacheDir, "update-check.json");
|
|
61137
61172
|
} catch {
|
|
@@ -61365,12 +61400,14 @@ async function runCli() {
|
|
|
61365
61400
|
}
|
|
61366
61401
|
}
|
|
61367
61402
|
const port = cliConfig.port || await findAvailablePort2(DEFAULT_PORT_RANGE2.start, DEFAULT_PORT_RANGE2.end);
|
|
61368
|
-
const
|
|
61403
|
+
const explicitModel = typeof cliConfig.model === "string" ? cliConfig.model : undefined;
|
|
61404
|
+
const modelMap = explicitModel ? undefined : {
|
|
61369
61405
|
opus: cliConfig.modelOpus,
|
|
61370
61406
|
sonnet: cliConfig.modelSonnet,
|
|
61371
61407
|
haiku: cliConfig.modelHaiku,
|
|
61372
61408
|
subagent: cliConfig.modelSubagent
|
|
61373
|
-
}
|
|
61409
|
+
};
|
|
61410
|
+
const proxy = await createProxyServer2(port, cliConfig.monitor ? undefined : cliConfig.openrouterApiKey, cliConfig.monitor ? undefined : explicitModel, cliConfig.monitor, cliConfig.anthropicApiKey, modelMap, {
|
|
61374
61411
|
summarizeTools: cliConfig.summarizeTools
|
|
61375
61412
|
});
|
|
61376
61413
|
let exitCode = 0;
|
package/package.json
CHANGED
|
@@ -135,7 +135,7 @@ export const ENV = {
|
|
|
135
135
|
// OpenRouter API Configuration
|
|
136
136
|
export const OPENROUTER_API_URL = "https://openrouter.ai/api/v1/chat/completions";
|
|
137
137
|
export const OPENROUTER_HEADERS = {
|
|
138
|
-
"HTTP-Referer": "https://
|
|
138
|
+
"HTTP-Referer": "https://claudish.com",
|
|
139
139
|
"X-Title": "Claudish - OpenRouter Proxy",
|
|
140
140
|
} as const;
|
|
141
141
|
`;
|