@corbat-tech/coco 2.4.0 → 2.4.1

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/cli/index.js CHANGED
@@ -1363,10 +1363,12 @@ var init_openai = __esm({
1363
1363
  provider: this.id
1364
1364
  });
1365
1365
  }
1366
+ const defaultHeaders = this.id === "kimi-code" ? { "User-Agent": "claude-code" } : {};
1366
1367
  this.client = new OpenAI({
1367
1368
  apiKey,
1368
1369
  baseURL: config.baseUrl,
1369
- timeout: config.timeout ?? 12e4
1370
+ timeout: config.timeout ?? 12e4,
1371
+ defaultHeaders
1370
1372
  });
1371
1373
  }
1372
1374
  /**
@@ -4533,7 +4535,7 @@ function getBaseUrl(provider) {
4533
4535
  case "huggingface":
4534
4536
  return process.env["HF_BASE_URL"] ?? "https://api-inference.huggingface.co/v1";
4535
4537
  case "qwen":
4536
- return process.env["DASHSCOPE_BASE_URL"] ?? "https://dashscope.aliyuncs.com/compatible-mode/v1";
4538
+ return process.env["DASHSCOPE_BASE_URL"] ?? "https://dashscope-intl.aliyuncs.com/compatible-mode/v1";
4537
4539
  default:
4538
4540
  return void 0;
4539
4541
  }
@@ -4791,7 +4793,7 @@ async function createProvider(type, config = {}) {
4791
4793
  break;
4792
4794
  case "qwen":
4793
4795
  provider = new OpenAIProvider("qwen", "Alibaba Qwen");
4794
- mergedConfig.baseUrl = mergedConfig.baseUrl ?? "https://dashscope.aliyuncs.com/compatible-mode/v1";
4796
+ mergedConfig.baseUrl = mergedConfig.baseUrl ?? "https://dashscope-intl.aliyuncs.com/compatible-mode/v1";
4795
4797
  break;
4796
4798
  default:
4797
4799
  throw new ProviderError(`Unknown provider type: ${type}`, {
@@ -24196,9 +24198,9 @@ var PROVIDER_DEFINITIONS = {
24196
24198
  emoji: "\u{1F7E6}",
24197
24199
  description: "Qwen models via Alibaba DashScope \u2014 strong coding at low cost",
24198
24200
  envVar: "DASHSCOPE_API_KEY",
24199
- apiKeyUrl: "https://dashscope.aliyuncs.com",
24201
+ apiKeyUrl: "https://modelstudio.console.alibabacloud.com",
24200
24202
  docsUrl: "https://help.aliyun.com/zh/model-studio/developer-reference/",
24201
- baseUrl: "https://dashscope.aliyuncs.com/compatible-mode/v1",
24203
+ baseUrl: "https://dashscope-intl.aliyuncs.com/compatible-mode/v1",
24202
24204
  supportsCustomModels: true,
24203
24205
  openaiCompatible: true,
24204
24206
  paymentType: "api",
@@ -28512,6 +28514,18 @@ async function testConnection(provider, apiKey, model, baseUrl) {
28512
28514
  p25.log.message(chalk25.dim(" \u2022 Ensure your account has credits"));
28513
28515
  p25.log.message(chalk25.dim(" \u2022 Try model: moonshot-v1-8k (most compatible)"));
28514
28516
  }
28517
+ if (provider.id === "qwen") {
28518
+ p25.log.message(chalk25.dim("\n\u{1F7E6} Alibaba Qwen specific:"));
28519
+ p25.log.message(chalk25.dim(" \u2022 International console: modelstudio.console.alibabacloud.com"));
28520
+ p25.log.message(chalk25.dim(" \u2022 International API endpoint: dashscope-intl.aliyuncs.com"));
28521
+ p25.log.message(chalk25.dim(" \u2022 China domestic endpoint: dashscope.aliyuncs.com"));
28522
+ p25.log.message(
28523
+ chalk25.dim(
28524
+ " \u2022 If using China endpoint, set: DASHSCOPE_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1"
28525
+ )
28526
+ );
28527
+ p25.log.message(chalk25.dim(" \u2022 Ensure your account has API access enabled"));
28528
+ }
28515
28529
  return false;
28516
28530
  }
28517
28531
  spinner19.stop(chalk25.green("\u2705 Connected successfully!"));
@@ -28822,10 +28836,6 @@ async function selectProviderInteractively(providers, currentProviderId) {
28822
28836
  line += chalk25.bgBlue.white(truncate(provider.description, descWidth, "\u2026"));
28823
28837
  process.stdout.write(line + "\n");
28824
28838
  totalLines++;
28825
- if (provider.description.length > descWidth) {
28826
- process.stdout.write(chalk25.bgBlue.white(` ${provider.description}`) + "\n");
28827
- totalLines++;
28828
- }
28829
28839
  } else {
28830
28840
  const marker = isCurrent ? chalk25.green(" \u25CF ") : chalk25.dim(" \u25CB ");
28831
28841
  const status = provider.isConfigured ? chalk25.green("\u2713") : chalk25.dim("\u25CB");
@@ -43682,9 +43692,28 @@ async function startRepl(options = {}) {
43682
43692
  if (!input && !hasPendingImage()) continue;
43683
43693
  let agentMessage = null;
43684
43694
  if (input && isSlashCommand(input)) {
43695
+ const prevProviderType = session.config.provider.type;
43696
+ const prevProviderModel = session.config.provider.model;
43685
43697
  const { command, args } = parseSlashCommand(input);
43686
43698
  const commandResult = await executeSlashCommand(command, args, session);
43687
43699
  if (commandResult.shouldExit) break;
43700
+ if (session.config.provider.type !== prevProviderType || session.config.provider.model !== prevProviderModel) {
43701
+ try {
43702
+ const newInternalId = getInternalProviderId(session.config.provider.type);
43703
+ provider = await createProvider(newInternalId, {
43704
+ model: session.config.provider.model || void 0,
43705
+ maxTokens: session.config.provider.maxTokens
43706
+ });
43707
+ setAgentProvider(provider);
43708
+ initializeContextManager(session, provider);
43709
+ } catch (err) {
43710
+ session.config.provider.type = prevProviderType;
43711
+ session.config.provider.model = prevProviderModel;
43712
+ renderError(
43713
+ `Failed to switch provider: ${err instanceof Error ? err.message : String(err)}`
43714
+ );
43715
+ }
43716
+ }
43688
43717
  if (commandResult.forkPrompt) {
43689
43718
  agentMessage = commandResult.forkPrompt;
43690
43719
  } else if (hasPendingImage()) {