@arrislink/axon 1.1.2 → 1.1.3

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 +20 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -16368,11 +16368,21 @@ class AnthropicClient {
16368
16368
  body: JSON.stringify(body)
16369
16369
  });
16370
16370
  if (!response.ok) {
16371
- const errorData = await response.json().catch(() => ({}));
16372
- throw new APIError(`LLM API \u8C03\u7528\u5931\u8D25 (${response.status}): ${errorData.error?.message || response.statusText}`, response.status);
16371
+ const errorText = await response.text().catch(() => "");
16372
+ let errorData = {};
16373
+ try {
16374
+ errorData = JSON.parse(errorText);
16375
+ } catch {}
16376
+ throw new APIError(`LLM API \u8C03\u7528\u5931\u8D25 (${response.status}): ${errorData.error?.message || errorText || response.statusText}`, response.status);
16377
+ }
16378
+ const responseText = await response.text();
16379
+ let data;
16380
+ try {
16381
+ data = JSON.parse(responseText);
16382
+ } catch (err) {
16383
+ throw new APIError(`LLM API \u54CD\u5E94\u89E3\u6790\u5931\u8D25 (\u65E0\u6548\u7684 JSON): ${responseText.substring(0, 100)}...`, 500);
16373
16384
  }
16374
- const data = await response.json();
16375
- const textContent = data.content.find((c) => c.type === "text");
16385
+ const textContent = data.content?.find((c) => c.type === "text");
16376
16386
  const content = textContent?.text || "";
16377
16387
  return {
16378
16388
  content,
@@ -16763,8 +16773,7 @@ class UnifiedLLMClient {
16763
16773
  return result.content;
16764
16774
  }
16765
16775
  cleanModelName(model) {
16766
- const parts = model.split("/");
16767
- return parts.length > 1 ? parts.slice(1).join("/") : model;
16776
+ return model.replace(/^[^/]+\//, "");
16768
16777
  }
16769
16778
  async chatAnthropic(provider, messages, options) {
16770
16779
  const apiKey = this.omoConfig.getProviderApiKey(provider) || process.env["ANTHROPIC_API_KEY"];
@@ -16792,7 +16801,7 @@ class UnifiedLLMClient {
16792
16801
  provider: "anthropic",
16793
16802
  temperature: options?.temperature ?? 0.7,
16794
16803
  max_tokens: options?.maxTokens || 8000
16795
- }, provider.endpoint || "https://api.opencode.ai/v1");
16804
+ }, provider.endpoint || "https://api.antigravity.ai/v1");
16796
16805
  return this.executeAnthropicChat(client, displayModel, messages, options);
16797
16806
  }
16798
16807
  async executeAnthropicChat(client, model, messages, options) {
@@ -17007,7 +17016,7 @@ class AxonLLMClient {
17007
17016
  return;
17008
17017
  }
17009
17018
  }
17010
- if (this.omoConfig.hasProviders() && this.omoConfig.hasAntigravityAuth()) {
17019
+ if (this.mode === "fallback" && this.omoConfig.hasProviders() && this.omoConfig.hasAntigravityAuth()) {
17011
17020
  this.unifiedClient = new UnifiedLLMClient(this.omoConfig);
17012
17021
  }
17013
17022
  }
@@ -17052,10 +17061,11 @@ class AxonLLMClient {
17052
17061
  this.initClient();
17053
17062
  return await this.chat(messages, options);
17054
17063
  }
17055
- if (this.mode === "direct") {
17056
- console.warn("\uD83E\uDDE0 Axon: Direct \u6A21\u5F0F\u8C03\u7528\u5931\u8D25\uFF0C\u5C1D\u8BD5 Fallback \u6A21\u5F0F...");
17064
+ if (this.mode === "direct" || this.mode === "fallback" && this.unifiedClient) {
17065
+ console.warn("\uD83E\uDDE0 Axon: Direct/Proxy \u6A21\u5F0F\u8C03\u7528\u5931\u8D25\uFF0C\u5C1D\u8BD5\u73AF\u5883\u53D8\u91CF Fallback...");
17057
17066
  if (process.env["DEBUG"])
17058
17067
  console.error(error);
17068
+ this.unifiedClient = undefined;
17059
17069
  this.mode = "fallback";
17060
17070
  this.initClient();
17061
17071
  return await this.chat(messages, options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arrislink/axon",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "AI-Powered Development Operating System with unified LLM provider support",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",