cc-hub-cli 1.0.6 → 1.0.8

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 +45 -16
  2. package/package.json +9 -3
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  // src/index.ts
4
4
  import { Command as Command6 } from "commander";
5
+ import { createRequire } from "module";
5
6
 
6
7
  // src/profiles.ts
7
8
  import { Command as Command2 } from "commander";
@@ -318,6 +319,42 @@ async function startOpenAIProxy(targetUrl, apiKey, model, models = []) {
318
319
  }
319
320
  const isStream = !!parsed.stream;
320
321
  const openaiBody = transformAnthropicToOpenAI({ ...parsed, stream: false });
322
+ if (isStream) {
323
+ res.writeHead(200, {
324
+ "Content-Type": "text/event-stream",
325
+ "Cache-Control": "no-cache",
326
+ "Connection": "keep-alive"
327
+ });
328
+ const keepalive = setInterval(() => res.write(": keepalive\n\n"), 15e3);
329
+ try {
330
+ const upstream2 = await fetch(`${base}/v1/chat/completions`, {
331
+ method: "POST",
332
+ headers: {
333
+ "Content-Type": "application/json",
334
+ "Authorization": `Bearer ${apiKey}`
335
+ },
336
+ body: JSON.stringify(openaiBody)
337
+ });
338
+ if (!upstream2.ok) {
339
+ const errText = await upstream2.text();
340
+ res.write(`event: error
341
+ data: ${errText}
342
+
343
+ `);
344
+ res.end();
345
+ return;
346
+ }
347
+ const data2 = await upstream2.json();
348
+ const anthropicResponse2 = transformOpenAIResponseToAnthropic(data2, parsed.model ?? model);
349
+ for (const chunk of synthesizeAnthropicSSE(anthropicResponse2)) {
350
+ res.write(chunk);
351
+ }
352
+ res.end();
353
+ } finally {
354
+ clearInterval(keepalive);
355
+ }
356
+ return;
357
+ }
321
358
  const upstream = await fetch(`${base}/v1/chat/completions`, {
322
359
  method: "POST",
323
360
  headers: {
@@ -334,20 +371,8 @@ async function startOpenAIProxy(targetUrl, apiKey, model, models = []) {
334
371
  }
335
372
  const data = await upstream.json();
336
373
  const anthropicResponse = transformOpenAIResponseToAnthropic(data, parsed.model ?? model);
337
- if (isStream) {
338
- res.writeHead(200, {
339
- "Content-Type": "text/event-stream",
340
- "Cache-Control": "no-cache",
341
- "Connection": "keep-alive"
342
- });
343
- for (const chunk of synthesizeAnthropicSSE(anthropicResponse)) {
344
- res.write(chunk);
345
- }
346
- res.end();
347
- } else {
348
- res.writeHead(200, { "Content-Type": "application/json" });
349
- res.end(JSON.stringify(anthropicResponse));
350
- }
374
+ res.writeHead(200, { "Content-Type": "application/json" });
375
+ res.end(JSON.stringify(anthropicResponse));
351
376
  return;
352
377
  }
353
378
  res.writeHead(404, { "Content-Type": "application/json" });
@@ -675,7 +700,9 @@ function execClaude(profileName, p, extraArgs) {
675
700
  const env = {
676
701
  ...process.env,
677
702
  ANTHROPIC_AUTH_TOKEN: p.token || void 0,
678
- ANTHROPIC_BASE_URL: p.url || void 0
703
+ ANTHROPIC_BASE_URL: p.url || void 0,
704
+ CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS: "1",
705
+ CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS: "1"
679
706
  };
680
707
  const nonAnthropicModels = models.filter((m) => !isAnthropicModel(m));
681
708
  if (nonAnthropicModels.length > 0) {
@@ -1578,8 +1605,10 @@ function completeCommand() {
1578
1605
  }
1579
1606
 
1580
1607
  // src/index.ts
1608
+ var _require = createRequire(import.meta.url);
1609
+ var { version } = _require("../package.json");
1581
1610
  var program = new Command6();
1582
- program.name("cc-hub").description("Manage Claude CLI profiles, hooks, and sessions").version("1.0.0");
1611
+ program.name("cc-hub").description("Manage Claude CLI profiles, hooks, and sessions").version(version);
1583
1612
  program.addCommand(profileCommand());
1584
1613
  program.addCommand(useCommand());
1585
1614
  program.addCommand(runCommand());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-hub-cli",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Manage Claude CLI profiles, hooks, and sessions",
5
5
  "type": "module",
6
6
  "bin": {
@@ -10,7 +10,11 @@
10
10
  "build": "tsup",
11
11
  "dev": "tsup --watch",
12
12
  "start": "node dist/index.js",
13
- "prepublishOnly": "npm run build"
13
+ "prepublishOnly": "npm run build",
14
+ "test": "vitest run",
15
+ "test:watch": "vitest",
16
+ "test:coverage": "vitest run --coverage",
17
+ "test:build": "npm test && npm run build"
14
18
  },
15
19
  "repository": {
16
20
  "type": "git",
@@ -29,7 +33,9 @@
29
33
  },
30
34
  "devDependencies": {
31
35
  "tsup": "^8.4.0",
32
- "typescript": "^5.7.0"
36
+ "typescript": "^5.7.0",
37
+ "vitest": "^3.0.0",
38
+ "@vitest/coverage-v8": "^3.0.0"
33
39
  },
34
40
  "engines": {
35
41
  "node": ">=18"