cc-hub-cli 1.1.16 → 1.1.17

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.
Files changed (2) hide show
  1. package/dist/index.js +43 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -674,6 +674,7 @@ function transformKimiResponseToAnthropic(kimiResponse, originalModel) {
674
674
  tool_calls: "tool_use",
675
675
  content_filter: "stop_sequence"
676
676
  };
677
+ const cachedTokens = kimiResponse.usage?.prompt_tokens_details?.cached_tokens ?? kimiResponse.usage?.cached_tokens ?? 0;
677
678
  return {
678
679
  id: kimiResponse.id ?? `msg_${Date.now()}`,
679
680
  type: "message",
@@ -683,9 +684,9 @@ function transformKimiResponseToAnthropic(kimiResponse, originalModel) {
683
684
  stop_reason: finishMap[choice.finish_reason] ?? "end_turn",
684
685
  stop_sequence: null,
685
686
  usage: {
686
- input_tokens: (kimiResponse.usage?.prompt_tokens ?? 0) - (kimiResponse.usage?.prompt_tokens_details?.cached_tokens ?? 0),
687
+ input_tokens: (kimiResponse.usage?.prompt_tokens ?? 0) - cachedTokens,
687
688
  output_tokens: kimiResponse.usage?.completion_tokens ?? 0,
688
- cache_read_input_tokens: kimiResponse.usage?.prompt_tokens_details?.cached_tokens ?? 0,
689
+ cache_read_input_tokens: cachedTokens,
689
690
  cache_creation_input_tokens: kimiResponse.usage?.prompt_tokens_details?.cache_creation_tokens ?? 0
690
691
  }
691
692
  };
@@ -694,17 +695,17 @@ function transformKimiResponseToAnthropic(kimiResponse, originalModel) {
694
695
  // src/provider/server.ts
695
696
  import http from "http";
696
697
  import os3 from "os";
697
- function getKimiHeaders() {
698
+ function getKimiHeaders(claudeVersion) {
698
699
  const platform = os3.platform();
699
700
  const stainlessOS = platform === "darwin" ? "MacOS" : platform === "win32" ? "Windows" : "Linux";
700
701
  return {
701
702
  "X-Stainless-OS": stainlessOS,
702
- "X-Stainless-Package-Version": "1.1.16",
703
+ "X-Stainless-Package-Version": "1.1.17",
703
704
  "X-Stainless-Runtime": "node",
704
- "User-Agent": "claude-code/1.0"
705
+ "User-Agent": `claude-code/${claudeVersion}`
705
706
  };
706
707
  }
707
- async function startOpenAIProxy(targetUrl, apiKey, model, models = [], modelMappings = {}, provider = "openai") {
708
+ async function startOpenAIProxy(targetUrl, apiKey, model, models = [], modelMappings = {}, provider = "openai", claudeVersion = "0.0.0") {
708
709
  const base = targetUrl.replace(/\/+$/, "");
709
710
  const server = http.createServer(async (req, res) => {
710
711
  debug(`Proxy request: ${req.method} ${req.url}`);
@@ -747,7 +748,7 @@ async function startOpenAIProxy(targetUrl, apiKey, model, models = [], modelMapp
747
748
  headers: {
748
749
  "Content-Type": "application/json",
749
750
  "Authorization": `Bearer ${apiKey}`,
750
- ...provider === "kimi" ? getKimiHeaders() : {}
751
+ ...provider === "kimi" ? getKimiHeaders(claudeVersion) : {}
751
752
  },
752
753
  body: JSON.stringify(openaiBody)
753
754
  });
@@ -778,7 +779,7 @@ data: ${errText}
778
779
  headers: {
779
780
  "Content-Type": "application/json",
780
781
  "Authorization": `Bearer ${apiKey}`,
781
- ...provider === "kimi" ? getKimiHeaders() : {}
782
+ ...provider === "kimi" ? getKimiHeaders(claudeVersion) : {}
782
783
  },
783
784
  body: JSON.stringify(openaiBody)
784
785
  });
@@ -992,6 +993,29 @@ var DesktopProfileSyncer = class {
992
993
 
993
994
  // src/platform/binary-resolver.ts
994
995
  import { spawnSync } from "child_process";
996
+ var cachedVersion;
997
+ function getClaudeVersion() {
998
+ if (cachedVersion) return cachedVersion;
999
+ debug("binary-resolver: detecting Claude version");
1000
+ try {
1001
+ const result = spawnSync("claude", ["--version"], {
1002
+ shell: process.platform === "win32",
1003
+ encoding: "utf-8"
1004
+ });
1005
+ if (result.status === 0 && result.stdout) {
1006
+ const match = result.stdout.trim().match(/^(\d+\.\d+\.\d+)/);
1007
+ if (match) {
1008
+ cachedVersion = match[1];
1009
+ debug(`binary-resolver: detected Claude version ${cachedVersion}`);
1010
+ return cachedVersion;
1011
+ }
1012
+ }
1013
+ } catch {
1014
+ }
1015
+ cachedVersion = "0.0.0";
1016
+ debug("binary-resolver: could not detect Claude version, using default");
1017
+ return cachedVersion;
1018
+ }
995
1019
  var SystemBinaryResolver = class {
996
1020
  constructor(app) {
997
1021
  this.app = app;
@@ -1234,7 +1258,8 @@ function execClaude(profileName, p, extraArgs) {
1234
1258
  firstModel || "gpt-4o",
1235
1259
  allModels,
1236
1260
  {},
1237
- p.provider
1261
+ p.provider,
1262
+ getClaudeVersion()
1238
1263
  ).then(({ baseUrl, stop }) => {
1239
1264
  env.ANTHROPIC_BASE_URL = baseUrl;
1240
1265
  debug(`execClaude: proxy running at ${baseUrl}`);
@@ -2796,7 +2821,15 @@ function proxyCommand() {
2796
2821
  }
2797
2822
  models = [defaultModel];
2798
2823
  }
2799
- const { baseUrl, stop } = await startOpenAIProxy(targetUrl, apiKey, defaultModel, models, modelMappings);
2824
+ const { baseUrl, stop } = await startOpenAIProxy(
2825
+ targetUrl,
2826
+ apiKey,
2827
+ defaultModel,
2828
+ models,
2829
+ modelMappings,
2830
+ "openai",
2831
+ getClaudeVersion()
2832
+ );
2800
2833
  console.log(`Proxy running at ${baseUrl}`);
2801
2834
  console.log("Press Ctrl+C to stop");
2802
2835
  process.on("SIGINT", () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-hub-cli",
3
- "version": "1.1.16",
3
+ "version": "1.1.17",
4
4
  "description": "Manage Claude CLI profiles, hooks, and sessions",
5
5
  "type": "module",
6
6
  "bin": {