claudish 7.41.0 → 7.42.0
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 +33 -99
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -729,7 +729,7 @@ var init_onepassword_config = __esm(() => {
|
|
|
729
729
|
});
|
|
730
730
|
|
|
731
731
|
// src/version.ts
|
|
732
|
-
var VERSION = "7.
|
|
732
|
+
var VERSION = "7.42.0";
|
|
733
733
|
|
|
734
734
|
// src/logger.ts
|
|
735
735
|
var exports_logger = {};
|
|
@@ -33389,7 +33389,8 @@ function createStreamingState() {
|
|
|
33389
33389
|
tools: new Map,
|
|
33390
33390
|
toolIds: new Set,
|
|
33391
33391
|
lastActivity: Date.now(),
|
|
33392
|
-
accumulatedText: ""
|
|
33392
|
+
accumulatedText: "",
|
|
33393
|
+
finishReason: null
|
|
33393
33394
|
};
|
|
33394
33395
|
}
|
|
33395
33396
|
function createStreamingResponseHandler(c, response, adapter, target, middlewareManager, onTokenUpdate, toolSchemas, toolNameMap, priorInputTokens, behavior) {
|
|
@@ -33547,7 +33548,12 @@ data: ${JSON.stringify(d)}
|
|
|
33547
33548
|
send("error", { type: "error", error: { type: "api_error", message: err } });
|
|
33548
33549
|
} else {
|
|
33549
33550
|
const hasStructuredTools = Array.from(state.tools.values()).some((t) => t.started);
|
|
33550
|
-
const
|
|
33551
|
+
const truncated = state.finishReason === "length";
|
|
33552
|
+
const refused = state.finishReason === "content_filter";
|
|
33553
|
+
const stopReason = refused ? "refusal" : truncated ? "max_tokens" : textToolCalls.length > 0 || hasStructuredTools ? "tool_use" : "end_turn";
|
|
33554
|
+
if (truncated || refused) {
|
|
33555
|
+
log(`[Streaming] Upstream finish_reason=${state.finishReason} \u2192 stop_reason=${stopReason} (${state.accumulatedText.length} chars produced)`);
|
|
33556
|
+
}
|
|
33551
33557
|
send("message_delta", {
|
|
33552
33558
|
type: "message_delta",
|
|
33553
33559
|
delta: { stop_reason: stopReason, stop_sequence: null },
|
|
@@ -33610,6 +33616,8 @@ data: ${JSON.stringify(d)}
|
|
|
33610
33616
|
}
|
|
33611
33617
|
const delta = chunk.choices?.[0]?.delta;
|
|
33612
33618
|
const finishReason = chunk.choices?.[0]?.finish_reason;
|
|
33619
|
+
if (finishReason)
|
|
33620
|
+
state.finishReason = finishReason;
|
|
33613
33621
|
if (delta?.content || finishReason) {
|
|
33614
33622
|
log(`[Streaming] Chunk: content=${delta?.content?.length || 0} chars, finish_reason=${finishReason || "null"}`);
|
|
33615
33623
|
}
|
|
@@ -33622,8 +33630,9 @@ data: ${JSON.stringify(d)}
|
|
|
33622
33630
|
metadata: streamMetadata
|
|
33623
33631
|
});
|
|
33624
33632
|
}
|
|
33625
|
-
|
|
33626
|
-
|
|
33633
|
+
const reasoningText = delta.reasoning_content || delta.reasoning;
|
|
33634
|
+
if (reasoningText) {
|
|
33635
|
+
behavior?.onAssistantText?.(reasoningText, "reasoning");
|
|
33627
33636
|
state.lastActivity = Date.now();
|
|
33628
33637
|
if (!state.reasoningStarted) {
|
|
33629
33638
|
state.reasoningIdx = state.curIdx++;
|
|
@@ -33637,7 +33646,7 @@ data: ${JSON.stringify(d)}
|
|
|
33637
33646
|
send("content_block_delta", {
|
|
33638
33647
|
type: "content_block_delta",
|
|
33639
33648
|
index: state.reasoningIdx,
|
|
33640
|
-
delta: { type: "thinking_delta", thinking:
|
|
33649
|
+
delta: { type: "thinking_delta", thinking: reasoningText }
|
|
33641
33650
|
});
|
|
33642
33651
|
}
|
|
33643
33652
|
const txt = delta.content || "";
|
|
@@ -33906,54 +33915,14 @@ var init_openai_compat = __esm(() => {
|
|
|
33906
33915
|
});
|
|
33907
33916
|
|
|
33908
33917
|
// src/adapters/gemini-api-format.ts
|
|
33909
|
-
var
|
|
33918
|
+
var GeminiAPIFormat;
|
|
33910
33919
|
var init_gemini_api_format = __esm(() => {
|
|
33911
33920
|
init_gemini_schema();
|
|
33912
33921
|
init_openai_compat();
|
|
33913
33922
|
init_logger();
|
|
33914
33923
|
init_base_api_format();
|
|
33915
|
-
REASONING_PATTERNS = [
|
|
33916
|
-
/^Wait,?\s+I(?:'m|\s+am)\s+\w+ing\b/i,
|
|
33917
|
-
/^Wait,?\s+(?:if|that|the|this|I\s+(?:need|should|will|have|already))/i,
|
|
33918
|
-
/^Wait[.!]?\s*$/i,
|
|
33919
|
-
/^Let\s+me\s+(think|check|verify|see|look|analyze|consider|first|start)/i,
|
|
33920
|
-
/^Let's\s+(check|see|look|start|first|try|think|verify|examine|analyze)/i,
|
|
33921
|
-
/^I\s+need\s+to\s+/i,
|
|
33922
|
-
/^O[kK](?:ay)?[.,!]?\s*(?:so|let|I|now|first)?/i,
|
|
33923
|
-
/^[Hh]mm+/,
|
|
33924
|
-
/^So[,.]?\s+(?:I|let|first|now|the)/i,
|
|
33925
|
-
/^(?:First|Next|Then|Now)[,.]?\s+(?:I|let|we)/i,
|
|
33926
|
-
/^(?:Thinking\s+about|Considering)/i,
|
|
33927
|
-
/^I(?:'ll|\s+will)\s+(?:first|now|start|begin|try|check|fix|look|examine|modify|create|update|read|investigate|adjust|improve|integrate|mark|also|verify|need|rethink|add|help|use|run|search|find|explore|analyze|review|test|implement|write|make|set|get|see|open|close|save|load|fetch|call|send|build|compile|execute|process|handle|parse|format|validate|clean|clear|remove|delete|move|copy|rename|install|configure|setup|initialize|prepare|work|continue|proceed|ensure|confirm)/i,
|
|
33928
|
-
/^I\s+should\s+/i,
|
|
33929
|
-
/^I\s+will\s+(?:first|now|start|verify|check|create|modify|look|need|also|add|help|use|run|search|find|explore|analyze|review|test|implement|write)/i,
|
|
33930
|
-
/^(?:Debug|Checking|Verifying|Looking\s+at):/i,
|
|
33931
|
-
/^I\s+also\s+(?:notice|need|see|want)/i,
|
|
33932
|
-
/^The\s+(?:goal|issue|problem|idea|plan)\s+is/i,
|
|
33933
|
-
/^In\s+the\s+(?:old|current|previous|new|existing)\s+/i,
|
|
33934
|
-
/^`[^`]+`\s+(?:is|has|does|needs|should|will|doesn't|hasn't)/i
|
|
33935
|
-
];
|
|
33936
|
-
REASONING_CONTINUATION_PATTERNS = [
|
|
33937
|
-
/^And\s+(?:then|I|now|so)/i,
|
|
33938
|
-
/^And\s+I(?:'ll|\s+will)/i,
|
|
33939
|
-
/^But\s+(?:I|first|wait|actually|the|if)/i,
|
|
33940
|
-
/^Actually[,.]?\s+/i,
|
|
33941
|
-
/^Also[,.]?\s+(?:I|the|check|note)/i,
|
|
33942
|
-
/^\d+\.\s+(?:I|First|Check|Run|Create|Update|Read|Modify|Add|Fix|Look)/i,
|
|
33943
|
-
/^-\s+(?:I|First|Check|Run|Create|Update|Read|Modify|Add|Fix)/i,
|
|
33944
|
-
/^Or\s+(?:I|just|we|maybe|perhaps)/i,
|
|
33945
|
-
/^Since\s+(?:I|the|this|we|it)/i,
|
|
33946
|
-
/^Because\s+(?:I|the|this|we|it)/i,
|
|
33947
|
-
/^If\s+(?:I|the|this|we|it)\s+/i,
|
|
33948
|
-
/^This\s+(?:is|means|requires|should|will|confirms|suggests)/i,
|
|
33949
|
-
/^That\s+(?:means|is|should|will|explains|confirms)/i,
|
|
33950
|
-
/^Lines?\s+\d+/i,
|
|
33951
|
-
/^The\s+`[^`]+`\s+(?:is|has|contains|needs|should)/i
|
|
33952
|
-
];
|
|
33953
33924
|
GeminiAPIFormat = class GeminiAPIFormat extends BaseAPIFormat {
|
|
33954
33925
|
toolCallMap = new Map;
|
|
33955
|
-
inReasoningBlock = false;
|
|
33956
|
-
reasoningBlockDepth = 0;
|
|
33957
33926
|
convertMessages(claudeRequest, _filterIdentityFn) {
|
|
33958
33927
|
const messages = [];
|
|
33959
33928
|
if (claudeRequest.messages) {
|
|
@@ -34163,58 +34132,12 @@ CRITICAL INSTRUCTION FOR OUTPUT FORMAT:
|
|
|
34163
34132
|
}
|
|
34164
34133
|
}
|
|
34165
34134
|
processTextContent(textContent, _accumulatedText) {
|
|
34166
|
-
|
|
34167
|
-
return { cleanedText: textContent, extractedToolCalls: [], wasTransformed: false };
|
|
34168
|
-
}
|
|
34169
|
-
const lines = textContent.split(`
|
|
34170
|
-
`);
|
|
34171
|
-
const cleanedLines = [];
|
|
34172
|
-
let wasFiltered = false;
|
|
34173
|
-
for (const line of lines) {
|
|
34174
|
-
const trimmed2 = line.trim();
|
|
34175
|
-
if (!trimmed2) {
|
|
34176
|
-
cleanedLines.push(line);
|
|
34177
|
-
continue;
|
|
34178
|
-
}
|
|
34179
|
-
if (this.isReasoningLine(trimmed2)) {
|
|
34180
|
-
log(`[GeminiAPIFormat] Filtered reasoning: "${trimmed2.substring(0, 50)}..."`);
|
|
34181
|
-
wasFiltered = true;
|
|
34182
|
-
this.inReasoningBlock = true;
|
|
34183
|
-
this.reasoningBlockDepth++;
|
|
34184
|
-
continue;
|
|
34185
|
-
}
|
|
34186
|
-
if (this.inReasoningBlock && this.isReasoningContinuation(trimmed2)) {
|
|
34187
|
-
log(`[GeminiAPIFormat] Filtered reasoning continuation: "${trimmed2.substring(0, 50)}..."`);
|
|
34188
|
-
wasFiltered = true;
|
|
34189
|
-
continue;
|
|
34190
|
-
}
|
|
34191
|
-
if (this.inReasoningBlock && trimmed2.length > 20 && !this.isReasoningContinuation(trimmed2)) {
|
|
34192
|
-
this.inReasoningBlock = false;
|
|
34193
|
-
this.reasoningBlockDepth = 0;
|
|
34194
|
-
}
|
|
34195
|
-
cleanedLines.push(line);
|
|
34196
|
-
}
|
|
34197
|
-
const cleanedText = cleanedLines.join(`
|
|
34198
|
-
`);
|
|
34199
|
-
return {
|
|
34200
|
-
cleanedText: wasFiltered ? cleanedText : textContent,
|
|
34201
|
-
extractedToolCalls: [],
|
|
34202
|
-
wasTransformed: wasFiltered
|
|
34203
|
-
};
|
|
34204
|
-
}
|
|
34205
|
-
isReasoningLine(line) {
|
|
34206
|
-
return REASONING_PATTERNS.some((pattern) => pattern.test(line));
|
|
34207
|
-
}
|
|
34208
|
-
isReasoningContinuation(line) {
|
|
34209
|
-
return REASONING_CONTINUATION_PATTERNS.some((pattern) => pattern.test(line));
|
|
34135
|
+
return { cleanedText: textContent, extractedToolCalls: [], wasTransformed: false };
|
|
34210
34136
|
}
|
|
34211
34137
|
getStreamFormat() {
|
|
34212
34138
|
return "gemini-sse";
|
|
34213
34139
|
}
|
|
34214
|
-
reset() {
|
|
34215
|
-
this.inReasoningBlock = false;
|
|
34216
|
-
this.reasoningBlockDepth = 0;
|
|
34217
|
-
}
|
|
34140
|
+
reset() {}
|
|
34218
34141
|
getContextWindow() {
|
|
34219
34142
|
return 1048576;
|
|
34220
34143
|
}
|
|
@@ -39917,6 +39840,7 @@ data: ${JSON.stringify(data)}
|
|
|
39917
39840
|
const toolCalls = new Map;
|
|
39918
39841
|
let accumulatedText = "";
|
|
39919
39842
|
let lastActivity = Date.now();
|
|
39843
|
+
let truncated = false;
|
|
39920
39844
|
send("message_start", {
|
|
39921
39845
|
type: "message_start",
|
|
39922
39846
|
message: {
|
|
@@ -39968,9 +39892,13 @@ data: ${JSON.stringify(data)}
|
|
|
39968
39892
|
send("error", { type: "error", error: { type: "api_error", message: err } });
|
|
39969
39893
|
} else {
|
|
39970
39894
|
const hasToolCalls = toolCalls.size > 0;
|
|
39895
|
+
const stopReason = truncated ? "max_tokens" : hasToolCalls ? "tool_use" : "end_turn";
|
|
39896
|
+
if (truncated) {
|
|
39897
|
+
log("[GeminiSSE] finishReason=MAX_TOKENS \u2192 stop_reason=max_tokens");
|
|
39898
|
+
}
|
|
39971
39899
|
send("message_delta", {
|
|
39972
39900
|
type: "message_delta",
|
|
39973
|
-
delta: { stop_reason:
|
|
39901
|
+
delta: { stop_reason: stopReason, stop_sequence: null },
|
|
39974
39902
|
usage: {
|
|
39975
39903
|
...inputTokens > 0 ? { input_tokens: inputTokens } : {},
|
|
39976
39904
|
output_tokens: outputTokens
|
|
@@ -40019,8 +39947,9 @@ data: ${JSON.stringify(data)}
|
|
|
40019
39947
|
if (candidate?.content?.parts) {
|
|
40020
39948
|
for (const part of candidate.content.parts) {
|
|
40021
39949
|
lastActivity = Date.now();
|
|
40022
|
-
|
|
40023
|
-
|
|
39950
|
+
const isThoughtPart = part.thought === true;
|
|
39951
|
+
const thinkingContent = isThoughtPart ? part.text ?? "" : part.thoughtText;
|
|
39952
|
+
if (thinkingContent) {
|
|
40024
39953
|
if (!thinkingStarted) {
|
|
40025
39954
|
thinkingIdx = curIdx++;
|
|
40026
39955
|
send("content_block_start", {
|
|
@@ -40036,7 +39965,7 @@ data: ${JSON.stringify(data)}
|
|
|
40036
39965
|
delta: { type: "thinking_delta", thinking: thinkingContent }
|
|
40037
39966
|
});
|
|
40038
39967
|
}
|
|
40039
|
-
if (part.text) {
|
|
39968
|
+
if (part.text && !isThoughtPart) {
|
|
40040
39969
|
if (thinkingStarted) {
|
|
40041
39970
|
send("content_block_stop", {
|
|
40042
39971
|
type: "content_block_stop",
|
|
@@ -40048,6 +39977,10 @@ data: ${JSON.stringify(data)}
|
|
|
40048
39977
|
if (opts.adapter) {
|
|
40049
39978
|
const res = opts.adapter.processTextContent(part.text, accumulatedText);
|
|
40050
39979
|
cleanedText = res.cleanedText || "";
|
|
39980
|
+
if (!cleanedText) {
|
|
39981
|
+
log(`[gemini-sse] adapter emptied ${part.text.length} chars of visible text \u2014 passing the original through`);
|
|
39982
|
+
cleanedText = part.text;
|
|
39983
|
+
}
|
|
40051
39984
|
accumulatedText += cleanedText;
|
|
40052
39985
|
} else {
|
|
40053
39986
|
accumulatedText += cleanedText;
|
|
@@ -40125,6 +40058,7 @@ data: ${JSON.stringify(data)}
|
|
|
40125
40058
|
}
|
|
40126
40059
|
if (candidate?.finishReason) {
|
|
40127
40060
|
if (candidate.finishReason === "STOP" || candidate.finishReason === "MAX_TOKENS") {
|
|
40061
|
+
truncated = candidate.finishReason === "MAX_TOKENS";
|
|
40128
40062
|
await finalize("done");
|
|
40129
40063
|
return;
|
|
40130
40064
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claudish",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.42.0",
|
|
4
4
|
"description": "Run Claude Code with any model - OpenRouter, Ollama, LM Studio & local models",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"ai"
|
|
61
61
|
],
|
|
62
62
|
"optionalDependencies": {
|
|
63
|
-
"@claudish/magmux-darwin-arm64": "7.
|
|
64
|
-
"@claudish/magmux-darwin-x64": "7.
|
|
65
|
-
"@claudish/magmux-linux-arm64": "7.
|
|
66
|
-
"@claudish/magmux-linux-x64": "7.
|
|
63
|
+
"@claudish/magmux-darwin-arm64": "7.42.0",
|
|
64
|
+
"@claudish/magmux-darwin-x64": "7.42.0",
|
|
65
|
+
"@claudish/magmux-linux-arm64": "7.42.0",
|
|
66
|
+
"@claudish/magmux-linux-x64": "7.42.0"
|
|
67
67
|
},
|
|
68
68
|
"author": "Jack Rudenko <i@madappgang.com>",
|
|
69
69
|
"license": "MIT",
|