claudish 7.19.0 → 7.19.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 +59 -19
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -651,7 +651,7 @@ var init_onepassword_config = __esm(() => {
|
|
|
651
651
|
});
|
|
652
652
|
|
|
653
653
|
// src/version.ts
|
|
654
|
-
var VERSION = "7.19.
|
|
654
|
+
var VERSION = "7.19.2";
|
|
655
655
|
|
|
656
656
|
// src/logger.ts
|
|
657
657
|
var exports_logger = {};
|
|
@@ -31745,6 +31745,14 @@ var init_web_search_detector = __esm(() => {
|
|
|
31745
31745
|
WEB_SEARCH_NAMES = new Set(["web_search", "brave_web_search", "tavily_search"]);
|
|
31746
31746
|
});
|
|
31747
31747
|
|
|
31748
|
+
// src/handlers/shared/stream-parsers/message-start-usage.ts
|
|
31749
|
+
function messageStartUsage(priorInputTokens) {
|
|
31750
|
+
return {
|
|
31751
|
+
input_tokens: priorInputTokens && priorInputTokens > 0 ? priorInputTokens : 100,
|
|
31752
|
+
output_tokens: 1
|
|
31753
|
+
};
|
|
31754
|
+
}
|
|
31755
|
+
|
|
31748
31756
|
// src/handlers/shared/stream-parsers/openai-sse.ts
|
|
31749
31757
|
function validateToolArguments(toolName, argsStr, toolSchemas, textContent) {
|
|
31750
31758
|
const result = validateAndRepairToolCall(toolName, argsStr, toolSchemas, textContent);
|
|
@@ -31774,7 +31782,7 @@ function createStreamingState() {
|
|
|
31774
31782
|
accumulatedText: ""
|
|
31775
31783
|
};
|
|
31776
31784
|
}
|
|
31777
|
-
function createStreamingResponseHandler(c, response, adapter, target, middlewareManager, onTokenUpdate, toolSchemas, toolNameMap) {
|
|
31785
|
+
function createStreamingResponseHandler(c, response, adapter, target, middlewareManager, onTokenUpdate, toolSchemas, toolNameMap, priorInputTokens) {
|
|
31778
31786
|
log(`[Streaming] ===== HANDLER STARTED for ${target} =====`);
|
|
31779
31787
|
let isClosed = false;
|
|
31780
31788
|
let ping = null;
|
|
@@ -31803,7 +31811,7 @@ data: ${JSON.stringify(d)}
|
|
|
31803
31811
|
model: target,
|
|
31804
31812
|
stop_reason: null,
|
|
31805
31813
|
stop_sequence: null,
|
|
31806
|
-
usage:
|
|
31814
|
+
usage: messageStartUsage(priorInputTokens)
|
|
31807
31815
|
}
|
|
31808
31816
|
});
|
|
31809
31817
|
send("ping", { type: "ping" });
|
|
@@ -31916,7 +31924,10 @@ data: ${JSON.stringify(d)}
|
|
|
31916
31924
|
send("message_delta", {
|
|
31917
31925
|
type: "message_delta",
|
|
31918
31926
|
delta: { stop_reason: stopReason, stop_sequence: null },
|
|
31919
|
-
usage: {
|
|
31927
|
+
usage: {
|
|
31928
|
+
...state.usage?.prompt_tokens ? { input_tokens: state.usage.prompt_tokens } : {},
|
|
31929
|
+
output_tokens: state.usage?.completion_tokens || 0
|
|
31930
|
+
}
|
|
31920
31931
|
});
|
|
31921
31932
|
send("message_stop", { type: "message_stop" });
|
|
31922
31933
|
}
|
|
@@ -31927,7 +31938,7 @@ data: ${JSON.stringify(d)}
|
|
|
31927
31938
|
} else {
|
|
31928
31939
|
const estimatedOutputTokens = Math.ceil(state.accumulatedText.length / 4);
|
|
31929
31940
|
log(`[Streaming] No usage data from provider, estimating: ~${estimatedOutputTokens} output tokens`);
|
|
31930
|
-
onTokenUpdate(100, estimatedOutputTokens);
|
|
31941
|
+
onTokenUpdate(priorInputTokens || 100, estimatedOutputTokens);
|
|
31931
31942
|
}
|
|
31932
31943
|
}
|
|
31933
31944
|
if (!isClosed) {
|
|
@@ -37545,7 +37556,7 @@ data: ${JSON.stringify(data)}
|
|
|
37545
37556
|
model: opts.modelName,
|
|
37546
37557
|
stop_reason: null,
|
|
37547
37558
|
stop_sequence: null,
|
|
37548
|
-
usage:
|
|
37559
|
+
usage: messageStartUsage(opts.priorInputTokens)
|
|
37549
37560
|
}
|
|
37550
37561
|
});
|
|
37551
37562
|
send("ping", { type: "ping" });
|
|
@@ -37589,7 +37600,10 @@ data: ${JSON.stringify(data)}
|
|
|
37589
37600
|
send("message_delta", {
|
|
37590
37601
|
type: "message_delta",
|
|
37591
37602
|
delta: { stop_reason: hasToolCalls ? "tool_use" : "end_turn", stop_sequence: null },
|
|
37592
|
-
usage: {
|
|
37603
|
+
usage: {
|
|
37604
|
+
...inputTokens > 0 ? { input_tokens: inputTokens } : {},
|
|
37605
|
+
output_tokens: outputTokens
|
|
37606
|
+
}
|
|
37593
37607
|
});
|
|
37594
37608
|
send("message_stop", { type: "message_stop" });
|
|
37595
37609
|
}
|
|
@@ -37792,7 +37806,7 @@ data: ${JSON.stringify(data)}
|
|
|
37792
37806
|
model: opts.modelName,
|
|
37793
37807
|
stop_reason: null,
|
|
37794
37808
|
stop_sequence: null,
|
|
37795
|
-
usage:
|
|
37809
|
+
usage: messageStartUsage(opts.priorInputTokens)
|
|
37796
37810
|
}
|
|
37797
37811
|
});
|
|
37798
37812
|
send("ping", { type: "ping" });
|
|
@@ -37813,7 +37827,10 @@ data: ${JSON.stringify(data)}
|
|
|
37813
37827
|
send("message_delta", {
|
|
37814
37828
|
type: "message_delta",
|
|
37815
37829
|
delta: { stop_reason: "end_turn", stop_sequence: null },
|
|
37816
|
-
usage: {
|
|
37830
|
+
usage: {
|
|
37831
|
+
...promptTokens > 0 ? { input_tokens: promptTokens } : {},
|
|
37832
|
+
output_tokens: completionTokens
|
|
37833
|
+
}
|
|
37817
37834
|
});
|
|
37818
37835
|
send("message_stop", { type: "message_stop" });
|
|
37819
37836
|
}
|
|
@@ -37965,7 +37982,7 @@ data: ${JSON.stringify(data)}
|
|
|
37965
37982
|
model: opts.modelName,
|
|
37966
37983
|
stop_reason: null,
|
|
37967
37984
|
stop_sequence: null,
|
|
37968
|
-
usage:
|
|
37985
|
+
usage: messageStartUsage(opts.priorInputTokens)
|
|
37969
37986
|
}
|
|
37970
37987
|
});
|
|
37971
37988
|
send("ping", { type: "ping" });
|
|
@@ -38228,6 +38245,13 @@ data: ${JSON.stringify(data)}
|
|
|
38228
38245
|
} catch {}
|
|
38229
38246
|
}
|
|
38230
38247
|
}
|
|
38248
|
+
},
|
|
38249
|
+
cancel() {
|
|
38250
|
+
isClosed = true;
|
|
38251
|
+
if (pingInterval) {
|
|
38252
|
+
clearInterval(pingInterval);
|
|
38253
|
+
pingInterval = null;
|
|
38254
|
+
}
|
|
38231
38255
|
}
|
|
38232
38256
|
});
|
|
38233
38257
|
return new Response(stream, {
|
|
@@ -38255,6 +38279,7 @@ class TokenTracker {
|
|
|
38255
38279
|
sessionTotalCost = 0;
|
|
38256
38280
|
sessionInputTokens = 0;
|
|
38257
38281
|
sessionOutputTokens = 0;
|
|
38282
|
+
lastInputTokens = 0;
|
|
38258
38283
|
modelNameOverride;
|
|
38259
38284
|
quotaRemaining;
|
|
38260
38285
|
constructor(port, config2) {
|
|
@@ -38271,10 +38296,11 @@ class TokenTracker {
|
|
|
38271
38296
|
this.quotaRemaining = fraction;
|
|
38272
38297
|
}
|
|
38273
38298
|
rewrite() {
|
|
38274
|
-
this.writeFile(this.
|
|
38299
|
+
this.writeFile(this.getLastInputTokens(), this.sessionOutputTokens);
|
|
38275
38300
|
}
|
|
38276
38301
|
update(inputTokens, outputTokens) {
|
|
38277
38302
|
this.sessionInputTokens = inputTokens;
|
|
38303
|
+
this.lastInputTokens = inputTokens;
|
|
38278
38304
|
this.sessionOutputTokens += outputTokens;
|
|
38279
38305
|
const pricing = this.getPricing();
|
|
38280
38306
|
const cost = inputTokens / 1e6 * pricing.inputCostPer1M + outputTokens / 1e6 * pricing.outputCostPer1M;
|
|
@@ -38283,6 +38309,7 @@ class TokenTracker {
|
|
|
38283
38309
|
}
|
|
38284
38310
|
accumulateBoth(inputTokens, outputTokens) {
|
|
38285
38311
|
this.sessionInputTokens += inputTokens;
|
|
38312
|
+
this.lastInputTokens = this.sessionInputTokens;
|
|
38286
38313
|
this.sessionOutputTokens += outputTokens;
|
|
38287
38314
|
const pricing = this.getPricing();
|
|
38288
38315
|
const cost = this.sessionInputTokens / 1e6 * pricing.inputCostPer1M + this.sessionOutputTokens / 1e6 * pricing.outputCostPer1M;
|
|
@@ -38291,6 +38318,7 @@ class TokenTracker {
|
|
|
38291
38318
|
}
|
|
38292
38319
|
updateWithDelta(inputTokens, outputTokens) {
|
|
38293
38320
|
let incrementalInputTokens;
|
|
38321
|
+
this.lastInputTokens = inputTokens;
|
|
38294
38322
|
if (inputTokens >= this.sessionInputTokens) {
|
|
38295
38323
|
incrementalInputTokens = inputTokens - this.sessionInputTokens;
|
|
38296
38324
|
this.sessionInputTokens = inputTokens;
|
|
@@ -38306,10 +38334,11 @@ class TokenTracker {
|
|
|
38306
38334
|
const pricing = this.getPricing();
|
|
38307
38335
|
const cost = incrementalInputTokens / 1e6 * pricing.inputCostPer1M + outputTokens / 1e6 * pricing.outputCostPer1M;
|
|
38308
38336
|
this.sessionTotalCost += cost;
|
|
38309
|
-
this.writeFile(
|
|
38337
|
+
this.writeFile(inputTokens, this.sessionOutputTokens, pricing.isEstimate);
|
|
38310
38338
|
}
|
|
38311
38339
|
updateWithActualCost(inputTokens, outputTokens, actualCost) {
|
|
38312
38340
|
this.sessionInputTokens = inputTokens;
|
|
38341
|
+
this.lastInputTokens = inputTokens;
|
|
38313
38342
|
this.sessionOutputTokens += outputTokens;
|
|
38314
38343
|
if (typeof actualCost === "number" && actualCost > 0) {
|
|
38315
38344
|
this.sessionTotalCost += actualCost;
|
|
@@ -38325,6 +38354,7 @@ class TokenTracker {
|
|
|
38325
38354
|
updateLocal(inputTokens, outputTokens) {
|
|
38326
38355
|
if (inputTokens > 0) {
|
|
38327
38356
|
this.sessionInputTokens = inputTokens;
|
|
38357
|
+
this.lastInputTokens = inputTokens;
|
|
38328
38358
|
}
|
|
38329
38359
|
this.sessionOutputTokens += outputTokens;
|
|
38330
38360
|
this.writeFile(this.sessionInputTokens, this.sessionOutputTokens);
|
|
@@ -38338,6 +38368,9 @@ class TokenTracker {
|
|
|
38338
38368
|
getInputTokens() {
|
|
38339
38369
|
return this.sessionInputTokens;
|
|
38340
38370
|
}
|
|
38371
|
+
getLastInputTokens() {
|
|
38372
|
+
return this.lastInputTokens || this.sessionInputTokens;
|
|
38373
|
+
}
|
|
38341
38374
|
getOutputTokens() {
|
|
38342
38375
|
return this.sessionOutputTokens;
|
|
38343
38376
|
}
|
|
@@ -38879,16 +38912,18 @@ class ComposedHandler {
|
|
|
38879
38912
|
}
|
|
38880
38913
|
};
|
|
38881
38914
|
const streamFormat = this.provider.overrideStreamFormat?.() ?? this.explicitAdapter?.getStreamFormat() ?? this.modelAdapter?.getStreamFormat() ?? this.getAdapter().getStreamFormat();
|
|
38915
|
+
const priorInputTokens = this.tokenTracker.getLastInputTokens();
|
|
38882
38916
|
switch (streamFormat) {
|
|
38883
38917
|
case "openai-sse":
|
|
38884
|
-
return createStreamingResponseHandler(c, response, adapter, this.bareModelName, this.middlewareManager, onTokenUpdate, claudeRequest.tools, toolNameMap);
|
|
38918
|
+
return createStreamingResponseHandler(c, response, adapter, this.bareModelName, this.middlewareManager, onTokenUpdate, claudeRequest.tools, toolNameMap, priorInputTokens);
|
|
38885
38919
|
case "openai-responses-sse":
|
|
38886
38920
|
return createResponsesStreamHandler(c, response, {
|
|
38887
38921
|
modelName: this.bareModelName,
|
|
38888
38922
|
onTokenUpdate,
|
|
38889
38923
|
toolNameMap: adapter.getToolNameMap(),
|
|
38890
38924
|
contextWindow: lookupModelForProvider(this.bareModelName, this.provider.name),
|
|
38891
|
-
onApiError
|
|
38925
|
+
onApiError,
|
|
38926
|
+
priorInputTokens
|
|
38892
38927
|
});
|
|
38893
38928
|
case "anthropic-sse":
|
|
38894
38929
|
return createAnthropicPassthroughStream(c, response, {
|
|
@@ -38908,13 +38943,15 @@ class ComposedHandler {
|
|
|
38908
38943
|
middlewareManager: this.middlewareManager,
|
|
38909
38944
|
onTokenUpdate,
|
|
38910
38945
|
onToolCall,
|
|
38911
|
-
unwrapResponse: this.options.unwrapGeminiResponse
|
|
38946
|
+
unwrapResponse: this.options.unwrapGeminiResponse,
|
|
38947
|
+
priorInputTokens
|
|
38912
38948
|
});
|
|
38913
38949
|
}
|
|
38914
38950
|
case "ollama-jsonl":
|
|
38915
38951
|
return createOllamaJsonlStream(c, response, {
|
|
38916
38952
|
modelName: this.bareModelName,
|
|
38917
|
-
onTokenUpdate
|
|
38953
|
+
onTokenUpdate,
|
|
38954
|
+
priorInputTokens
|
|
38918
38955
|
});
|
|
38919
38956
|
default:
|
|
38920
38957
|
throw new Error(`Unknown stream format: ${streamFormat}`);
|
|
@@ -71147,7 +71184,8 @@ __export(exports_claude_runner, {
|
|
|
71147
71184
|
isProxyAuthMode: () => isProxyAuthMode,
|
|
71148
71185
|
computeMainThreadContextWindow: () => computeMainThreadContextWindow,
|
|
71149
71186
|
checkClaudeInstalled: () => checkClaudeInstalled,
|
|
71150
|
-
buildClaudishSettingsOverlay: () => buildClaudishSettingsOverlay
|
|
71187
|
+
buildClaudishSettingsOverlay: () => buildClaudishSettingsOverlay,
|
|
71188
|
+
MIN_AUTO_COMPACT_WINDOW: () => MIN_AUTO_COMPACT_WINDOW
|
|
71151
71189
|
});
|
|
71152
71190
|
import { spawn as spawn4 } from "child_process";
|
|
71153
71191
|
import {
|
|
@@ -71477,11 +71515,13 @@ async function runClaudeWithProxy(config3, proxyUrl, onCleanup) {
|
|
|
71477
71515
|
env.ANTHROPIC_AUTH_TOKEN = "placeholder-token-not-used-proxy-handles-auth";
|
|
71478
71516
|
if (!process.env[ENV.CLAUDE_CODE_AUTO_COMPACT_WINDOW]) {
|
|
71479
71517
|
const autoCompactWindow = await computeMainThreadContextWindow(config3);
|
|
71480
|
-
if (autoCompactWindow
|
|
71518
|
+
if (autoCompactWindow >= MIN_AUTO_COMPACT_WINDOW) {
|
|
71481
71519
|
env[ENV.CLAUDE_CODE_AUTO_COMPACT_WINDOW] = String(autoCompactWindow);
|
|
71482
71520
|
if (!config3.quiet) {
|
|
71483
71521
|
console.error(`[claudish] Auto-compact window: ${autoCompactWindow.toLocaleString()} tokens ` + "(Claude Code compacts before the backend's real limit)");
|
|
71484
71522
|
}
|
|
71523
|
+
} else if (autoCompactWindow > 0 && !config3.quiet) {
|
|
71524
|
+
console.error(`[claudish] Model's real context window (${autoCompactWindow.toLocaleString()}) is below ` + `Claude Code's ${MIN_AUTO_COMPACT_WINDOW.toLocaleString()}-token auto-compact floor \u2014 ` + "leaving CLAUDE_CODE_AUTO_COMPACT_WINDOW unset so native auto-compaction stays on.");
|
|
71485
71525
|
}
|
|
71486
71526
|
}
|
|
71487
71527
|
}
|
|
@@ -71666,7 +71706,7 @@ async function checkClaudeInstalled() {
|
|
|
71666
71706
|
const binary = await findClaudeBinary();
|
|
71667
71707
|
return binary !== null;
|
|
71668
71708
|
}
|
|
71669
|
-
var restoreTerminal = null;
|
|
71709
|
+
var restoreTerminal = null, MIN_AUTO_COMPACT_WINDOW = 200000;
|
|
71670
71710
|
var init_claude_runner = __esm(() => {
|
|
71671
71711
|
init_model_catalog();
|
|
71672
71712
|
init_config();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claudish",
|
|
3
|
-
"version": "7.19.
|
|
3
|
+
"version": "7.19.2",
|
|
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.19.
|
|
64
|
-
"@claudish/magmux-darwin-x64": "7.19.
|
|
65
|
-
"@claudish/magmux-linux-arm64": "7.19.
|
|
66
|
-
"@claudish/magmux-linux-x64": "7.19.
|
|
63
|
+
"@claudish/magmux-darwin-arm64": "7.19.2",
|
|
64
|
+
"@claudish/magmux-darwin-x64": "7.19.2",
|
|
65
|
+
"@claudish/magmux-linux-arm64": "7.19.2",
|
|
66
|
+
"@claudish/magmux-linux-x64": "7.19.2"
|
|
67
67
|
},
|
|
68
68
|
"author": "Jack Rudenko <i@madappgang.com>",
|
|
69
69
|
"license": "MIT",
|