claudish 3.0.1 → 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 +45 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -34800,6 +34800,9 @@ async function parseArgs(args) {
|
|
|
34800
34800
|
config3.interactive = true;
|
|
34801
34801
|
} else if (arg === "--debug" || arg === "-d") {
|
|
34802
34802
|
config3.debug = true;
|
|
34803
|
+
if (config3.logLevel === "info") {
|
|
34804
|
+
config3.logLevel = "debug";
|
|
34805
|
+
}
|
|
34803
34806
|
} else if (arg === "--log-level") {
|
|
34804
34807
|
const levelArg = args[++i];
|
|
34805
34808
|
if (!levelArg || !["debug", "info", "minimal"].includes(levelArg)) {
|
|
@@ -39864,11 +39867,30 @@ class OpenRouterHandler {
|
|
|
39864
39867
|
const claudePayload = payload;
|
|
39865
39868
|
const target = this.targetModel;
|
|
39866
39869
|
await this.fetchContextWindow(target);
|
|
39867
|
-
logStructured(`OpenRouter Request`, { targetModel: target, originalModel: claudePayload.model });
|
|
39868
39870
|
const { claudeRequest, droppedParams } = transformOpenAIToClaude(claudePayload);
|
|
39869
39871
|
const messages = this.convertMessages(claudeRequest, target);
|
|
39870
39872
|
const tools = this.convertTools(claudeRequest);
|
|
39871
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
|
+
}
|
|
39872
39894
|
const openRouterPayload = {
|
|
39873
39895
|
model: target,
|
|
39874
39896
|
messages,
|
|
@@ -39903,8 +39925,12 @@ class OpenRouterHandler {
|
|
|
39903
39925
|
},
|
|
39904
39926
|
body: JSON.stringify(openRouterPayload)
|
|
39905
39927
|
});
|
|
39906
|
-
|
|
39907
|
-
|
|
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
|
+
}
|
|
39908
39934
|
if (droppedParams.length > 0)
|
|
39909
39935
|
c.header("X-Dropped-Params", droppedParams.join(", "));
|
|
39910
39936
|
return this.handleStreamingResponse(c, response, adapter, target, claudeRequest);
|
|
@@ -40013,6 +40039,7 @@ class OpenRouterHandler {
|
|
|
40013
40039
|
const encoder = new TextEncoder;
|
|
40014
40040
|
const decoder = new TextDecoder;
|
|
40015
40041
|
const middlewareManager = this.middlewareManager;
|
|
40042
|
+
const writeTokens = (input, output) => this.writeTokenFile(input, output);
|
|
40016
40043
|
const streamMetadata = new Map;
|
|
40017
40044
|
return c.body(new ReadableStream({
|
|
40018
40045
|
async start(controller) {
|
|
@@ -40070,10 +40097,22 @@ data: ${JSON.stringify(d)}
|
|
|
40070
40097
|
send("content_block_stop", { type: "content_block_stop", index: t.blockIndex });
|
|
40071
40098
|
t.closed = true;
|
|
40072
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
|
+
}
|
|
40073
40110
|
await middlewareManager.afterStreamComplete(target, streamMetadata);
|
|
40074
40111
|
if (reason === "error") {
|
|
40112
|
+
log(`[OpenRouter] Stream error: ${err}`);
|
|
40075
40113
|
send("error", { type: "error", error: { type: "api_error", message: err } });
|
|
40076
40114
|
} else {
|
|
40115
|
+
log(`[OpenRouter] Stream complete: ${reason}`);
|
|
40077
40116
|
send("message_delta", { type: "message_delta", delta: { stop_reason: "end_turn", stop_sequence: null }, usage: { output_tokens: usage?.completion_tokens || 0 } });
|
|
40078
40117
|
send("message_stop", { type: "message_stop" });
|
|
40079
40118
|
}
|
|
@@ -40165,6 +40204,8 @@ data: ${JSON.stringify(d)}
|
|
|
40165
40204
|
if (toolSchemas.length > 0) {
|
|
40166
40205
|
const validation = validateToolArguments(t.name, t.arguments, toolSchemas);
|
|
40167
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)}`);
|
|
40168
40209
|
const errorIdx = curIdx++;
|
|
40169
40210
|
const errorMsg = `
|
|
40170
40211
|
|
|
@@ -40176,6 +40217,7 @@ data: ${JSON.stringify(d)}
|
|
|
40176
40217
|
continue;
|
|
40177
40218
|
}
|
|
40178
40219
|
}
|
|
40220
|
+
log(`[OpenRouter] Tool validated: ${t.name}`);
|
|
40179
40221
|
send("content_block_stop", { type: "content_block_stop", index: t.blockIndex });
|
|
40180
40222
|
t.closed = true;
|
|
40181
40223
|
}
|