@nuvin/nuvin-core 1.6.1 → 1.6.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/VERSION CHANGED
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "1.6.1",
3
- "commit": "3d1a9e0"
2
+ "version": "1.6.2",
3
+ "commit": "43b45f7"
4
4
  }
package/dist/index.d.ts CHANGED
@@ -2096,6 +2096,7 @@ type AnthropicAISDKOptions = {
2096
2096
  apiUrl?: string;
2097
2097
  baseURL?: string;
2098
2098
  httpLogFile?: string;
2099
+ retry?: Partial<RetryConfig>;
2099
2100
  onTokenUpdate?: (newCredentials: {
2100
2101
  access: string;
2101
2102
  refresh: string;
@@ -2105,12 +2106,11 @@ type AnthropicAISDKOptions = {
2105
2106
  declare class AnthropicAISDKLLM {
2106
2107
  private readonly opts;
2107
2108
  private provider?;
2108
- private refreshPromise;
2109
+ private transport?;
2110
+ private authTransport?;
2109
2111
  constructor(opts?: AnthropicAISDKOptions);
2110
- private refreshAccessToken;
2111
- private updateCredentials;
2112
- private ensureValidToken;
2113
- private createFetchWithRetry;
2112
+ private getAuthTransport;
2113
+ private getTransport;
2114
2114
  private getProvider;
2115
2115
  private getModel;
2116
2116
  private transformMessages;
package/dist/index.js CHANGED
@@ -1205,7 +1205,10 @@ var AgentOrchestrator = class {
1205
1205
  content: contentStr,
1206
1206
  timestamp: this.clock.iso(),
1207
1207
  tool_call_id: tr.id,
1208
- name: tr.name
1208
+ name: tr.name,
1209
+ status: tr.status,
1210
+ durationMs: tr.durationMs,
1211
+ metadata: tr.metadata
1209
1212
  });
1210
1213
  this.metrics?.recordToolCall?.();
1211
1214
  await this.events?.emit({
@@ -5234,66 +5237,6 @@ var GithubAuthTransport = class {
5234
5237
  }
5235
5238
  };
5236
5239
 
5237
- // src/transports/base-bearer-auth-transport.ts
5238
- var BaseBearerAuthTransport = class {
5239
- inner;
5240
- apiKey;
5241
- baseUrl;
5242
- version;
5243
- customHeaders;
5244
- constructor(inner, apiKey, baseUrl, version, customHeaders) {
5245
- this.inner = inner;
5246
- this.apiKey = apiKey;
5247
- this.baseUrl = baseUrl ?? this.getDefaultBaseUrl();
5248
- this.version = version;
5249
- this.customHeaders = customHeaders;
5250
- }
5251
- buildFullUrl(path9) {
5252
- if (path9.startsWith("/")) {
5253
- return `${this.baseUrl}${path9}`;
5254
- }
5255
- return path9;
5256
- }
5257
- makeAuthHeaders(headers) {
5258
- const base = headers ? { ...headers } : {};
5259
- if (!base["User-Agent"] && this.version) {
5260
- base["User-Agent"] = `nuvin-cli/${this.version}`;
5261
- }
5262
- if (this.apiKey && this.apiKey.trim() !== "" && !this.customHeaders?.Authorization) {
5263
- base.Authorization = `Bearer ${this.apiKey}`;
5264
- }
5265
- if (this.customHeaders) {
5266
- Object.assign(base, this.customHeaders);
5267
- }
5268
- return base;
5269
- }
5270
- async get(url, headers, signal) {
5271
- const fullUrl = this.buildFullUrl(url);
5272
- return this.inner.get(fullUrl, this.makeAuthHeaders(headers), signal);
5273
- }
5274
- async post(url, body, headers, signal) {
5275
- const fullUrl = this.buildFullUrl(url);
5276
- return this.inner.post(fullUrl, body, this.makeAuthHeaders(headers), signal);
5277
- }
5278
- };
5279
-
5280
- // src/transports/simple-bearer-transport.ts
5281
- var SimpleBearerAuthTransport = class extends BaseBearerAuthTransport {
5282
- defaultUrl;
5283
- constructor(inner, defaultBaseUrl, apiKey, baseUrl, version, customHeaders) {
5284
- super(inner, apiKey, baseUrl ?? defaultBaseUrl, version, customHeaders);
5285
- this.defaultUrl = defaultBaseUrl;
5286
- }
5287
- getDefaultBaseUrl() {
5288
- return this.defaultUrl;
5289
- }
5290
- };
5291
-
5292
- // src/transports/transport-factory.ts
5293
- function createTransport(inner, defaultBaseUrl, apiKey, baseUrl, version, customHeaders) {
5294
- return new SimpleBearerAuthTransport(inner, defaultBaseUrl, apiKey, baseUrl, version, customHeaders);
5295
- }
5296
-
5297
5240
  // src/transports/backoff.ts
5298
5241
  function calculateBackoff(attempt, baseDelayMs, maxDelayMs, multiplier, jitterFactor) {
5299
5242
  const exponentialDelay = baseDelayMs * multiplier ** attempt;
@@ -5494,6 +5437,247 @@ var RetryTransport = class {
5494
5437
  }
5495
5438
  };
5496
5439
 
5440
+ // src/transports/anthropic-transport.ts
5441
+ var CLIENT_ID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e";
5442
+ var DEFAULT_BASE_URL = "https://api.anthropic.com/v1";
5443
+ var AnthropicAuthTransport = class {
5444
+ inner;
5445
+ baseUrl;
5446
+ retryConfig;
5447
+ apiKey;
5448
+ oauth;
5449
+ onTokenUpdate;
5450
+ refreshPromise = null;
5451
+ constructor(inner, opts) {
5452
+ this.inner = inner;
5453
+ this.apiKey = opts.apiKey;
5454
+ this.oauth = opts.oauth;
5455
+ this.baseUrl = opts.baseUrl ?? DEFAULT_BASE_URL;
5456
+ this.onTokenUpdate = opts.onTokenUpdate;
5457
+ this.retryConfig = opts.retry;
5458
+ }
5459
+ async refreshAccessToken() {
5460
+ if (!this.oauth) {
5461
+ return { type: "failed" };
5462
+ }
5463
+ try {
5464
+ const response = await fetch("https://console.anthropic.com/v1/oauth/token", {
5465
+ method: "POST",
5466
+ headers: {
5467
+ "Content-Type": "application/json"
5468
+ },
5469
+ body: JSON.stringify({
5470
+ grant_type: "refresh_token",
5471
+ refresh_token: this.oauth.refresh,
5472
+ client_id: CLIENT_ID
5473
+ })
5474
+ });
5475
+ if (!response.ok) {
5476
+ return { type: "failed" };
5477
+ }
5478
+ const json = await response.json();
5479
+ return {
5480
+ type: "success",
5481
+ access: json.access_token,
5482
+ refresh: json.refresh_token,
5483
+ expires: Date.now() + json.expires_in * 1e3
5484
+ };
5485
+ } catch {
5486
+ return { type: "failed" };
5487
+ }
5488
+ }
5489
+ updateCredentials(result) {
5490
+ if (result.type === "success" && result.access && result.refresh && result.expires) {
5491
+ if (this.oauth) {
5492
+ this.oauth.access = result.access;
5493
+ this.oauth.refresh = result.refresh;
5494
+ this.oauth.expires = result.expires;
5495
+ }
5496
+ this.onTokenUpdate?.({
5497
+ access: result.access,
5498
+ refresh: result.refresh,
5499
+ expires: result.expires
5500
+ });
5501
+ }
5502
+ }
5503
+ async ensureValidToken() {
5504
+ if (!this.oauth) return;
5505
+ if (this.refreshPromise) {
5506
+ const result = await this.refreshPromise;
5507
+ if (result.type === "failed") {
5508
+ throw new Error("Token refresh failed");
5509
+ }
5510
+ return;
5511
+ }
5512
+ this.refreshPromise = this.refreshAccessToken();
5513
+ try {
5514
+ const result = await this.refreshPromise;
5515
+ if (result.type === "success") {
5516
+ this.updateCredentials(result);
5517
+ } else {
5518
+ throw new Error("Token refresh failed");
5519
+ }
5520
+ } finally {
5521
+ this.refreshPromise = null;
5522
+ }
5523
+ }
5524
+ buildFullUrl(path9) {
5525
+ if (path9.startsWith("/")) {
5526
+ return `${this.baseUrl}${path9}`;
5527
+ }
5528
+ return path9;
5529
+ }
5530
+ makeAuthHeaders(headers) {
5531
+ const base = {
5532
+ "anthropic-version": "2023-06-01",
5533
+ "anthropic-beta": "oauth-2025-04-20,fine-grained-tool-streaming-2025-05-14",
5534
+ ...headers || {}
5535
+ };
5536
+ if (this.oauth) {
5537
+ base.authorization = `Bearer ${this.oauth.access}`;
5538
+ } else if (this.apiKey) {
5539
+ base["x-api-key"] = this.apiKey;
5540
+ }
5541
+ return base;
5542
+ }
5543
+ async get(url, headers, signal) {
5544
+ const fullUrl = this.buildFullUrl(url);
5545
+ let res = await this.inner.get(fullUrl, this.makeAuthHeaders(headers), signal);
5546
+ if ((res.status === 401 || res.status === 403) && this.oauth) {
5547
+ await this.ensureValidToken();
5548
+ res = await this.inner.get(fullUrl, this.makeAuthHeaders(headers), signal);
5549
+ }
5550
+ return res;
5551
+ }
5552
+ async post(url, body, headers, signal) {
5553
+ const fullUrl = this.buildFullUrl(url);
5554
+ let res = await this.inner.post(fullUrl, body, this.makeAuthHeaders(headers), signal);
5555
+ if ((res.status === 401 || res.status === 403) && this.oauth) {
5556
+ await this.ensureValidToken();
5557
+ res = await this.inner.post(fullUrl, body, this.makeAuthHeaders(headers), signal);
5558
+ }
5559
+ return res;
5560
+ }
5561
+ createRetryTransport() {
5562
+ return new RetryTransport(this, this.retryConfig);
5563
+ }
5564
+ createFetchFunction() {
5565
+ const makeRequest = async (url, init) => {
5566
+ let currentInit = init;
5567
+ if (this.oauth) {
5568
+ const headers = new Headers(currentInit?.headers);
5569
+ headers.delete("x-api-key");
5570
+ headers.set("authorization", `Bearer ${this.oauth.access}`);
5571
+ headers.set("user-agent", "ai-sdk/anthropic/2.0.30 ai-sdk/provider-utils/3.0.12");
5572
+ currentInit = { ...currentInit, headers };
5573
+ }
5574
+ const response = await fetch(url, currentInit);
5575
+ if ((response.status === 401 || response.status === 403) && this.oauth) {
5576
+ await this.ensureValidToken();
5577
+ const headers = new Headers(currentInit?.headers);
5578
+ headers.set("authorization", `Bearer ${this.oauth.access}`);
5579
+ currentInit = { ...currentInit, headers };
5580
+ return fetch(url, currentInit);
5581
+ }
5582
+ return response;
5583
+ };
5584
+ const retryTransport = new RetryTransport(
5585
+ {
5586
+ get: async (url, headers, signal) => {
5587
+ return makeRequest(url, { method: "GET", headers, signal });
5588
+ },
5589
+ post: async (url, body, headers, signal) => {
5590
+ return makeRequest(url, {
5591
+ method: "POST",
5592
+ headers,
5593
+ body: typeof body === "string" ? body : JSON.stringify(body),
5594
+ signal
5595
+ });
5596
+ }
5597
+ },
5598
+ this.retryConfig
5599
+ );
5600
+ return async (url, init) => {
5601
+ const urlStr = typeof url === "string" ? url : url instanceof URL ? url.toString() : url.url;
5602
+ const method = init?.method?.toUpperCase() ?? "GET";
5603
+ const headers = init?.headers ? Object.fromEntries(new Headers(init.headers).entries()) : void 0;
5604
+ if (method === "GET") {
5605
+ return retryTransport.get(urlStr, headers, init?.signal ?? void 0);
5606
+ }
5607
+ return retryTransport.post(urlStr, init?.body, headers, init?.signal ?? void 0);
5608
+ };
5609
+ }
5610
+ getBaseUrl() {
5611
+ return this.baseUrl;
5612
+ }
5613
+ getOAuth() {
5614
+ return this.oauth;
5615
+ }
5616
+ getApiKey() {
5617
+ return this.apiKey;
5618
+ }
5619
+ };
5620
+
5621
+ // src/transports/base-bearer-auth-transport.ts
5622
+ var BaseBearerAuthTransport = class {
5623
+ inner;
5624
+ apiKey;
5625
+ baseUrl;
5626
+ version;
5627
+ customHeaders;
5628
+ constructor(inner, apiKey, baseUrl, version, customHeaders) {
5629
+ this.inner = inner;
5630
+ this.apiKey = apiKey;
5631
+ this.baseUrl = baseUrl ?? this.getDefaultBaseUrl();
5632
+ this.version = version;
5633
+ this.customHeaders = customHeaders;
5634
+ }
5635
+ buildFullUrl(path9) {
5636
+ if (path9.startsWith("/")) {
5637
+ return `${this.baseUrl}${path9}`;
5638
+ }
5639
+ return path9;
5640
+ }
5641
+ makeAuthHeaders(headers) {
5642
+ const base = headers ? { ...headers } : {};
5643
+ if (!base["User-Agent"] && this.version) {
5644
+ base["User-Agent"] = `nuvin-cli/${this.version}`;
5645
+ }
5646
+ if (this.apiKey && this.apiKey.trim() !== "" && !this.customHeaders?.Authorization) {
5647
+ base.Authorization = `Bearer ${this.apiKey}`;
5648
+ }
5649
+ if (this.customHeaders) {
5650
+ Object.assign(base, this.customHeaders);
5651
+ }
5652
+ return base;
5653
+ }
5654
+ async get(url, headers, signal) {
5655
+ const fullUrl = this.buildFullUrl(url);
5656
+ return this.inner.get(fullUrl, this.makeAuthHeaders(headers), signal);
5657
+ }
5658
+ async post(url, body, headers, signal) {
5659
+ const fullUrl = this.buildFullUrl(url);
5660
+ return this.inner.post(fullUrl, body, this.makeAuthHeaders(headers), signal);
5661
+ }
5662
+ };
5663
+
5664
+ // src/transports/simple-bearer-transport.ts
5665
+ var SimpleBearerAuthTransport = class extends BaseBearerAuthTransport {
5666
+ defaultUrl;
5667
+ constructor(inner, defaultBaseUrl, apiKey, baseUrl, version, customHeaders) {
5668
+ super(inner, apiKey, baseUrl ?? defaultBaseUrl, version, customHeaders);
5669
+ this.defaultUrl = defaultBaseUrl;
5670
+ }
5671
+ getDefaultBaseUrl() {
5672
+ return this.defaultUrl;
5673
+ }
5674
+ };
5675
+
5676
+ // src/transports/transport-factory.ts
5677
+ function createTransport(inner, defaultBaseUrl, apiKey, baseUrl, version, customHeaders) {
5678
+ return new SimpleBearerAuthTransport(inner, defaultBaseUrl, apiKey, baseUrl, version, customHeaders);
5679
+ }
5680
+
5497
5681
  // src/llm-providers/model-limits.ts
5498
5682
  function normalizeModelLimits(provider, model) {
5499
5683
  switch (provider.toLowerCase()) {
@@ -5696,126 +5880,68 @@ import {
5696
5880
  jsonSchema,
5697
5881
  APICallError
5698
5882
  } from "ai";
5699
- var CLIENT_ID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e";
5700
5883
  var AnthropicAISDKLLM = class {
5701
5884
  opts;
5702
5885
  provider;
5703
- refreshPromise = null;
5886
+ transport;
5887
+ authTransport;
5704
5888
  constructor(opts = {}) {
5705
5889
  this.opts = opts;
5706
5890
  }
5707
- async refreshAccessToken() {
5708
- if (!this.opts.oauth) {
5709
- return { type: "failed" };
5710
- }
5711
- try {
5712
- const response = await fetch("https://console.anthropic.com/v1/oauth/token", {
5713
- method: "POST",
5714
- headers: {
5715
- "Content-Type": "application/json"
5716
- },
5717
- body: JSON.stringify({
5718
- grant_type: "refresh_token",
5719
- refresh_token: this.opts.oauth.refresh,
5720
- client_id: CLIENT_ID
5721
- })
5891
+ getAuthTransport() {
5892
+ if (!this.authTransport) {
5893
+ const base = new FetchTransport({
5894
+ persistFile: this.opts.httpLogFile,
5895
+ logLevel: "INFO",
5896
+ enableConsoleLog: false,
5897
+ maxFileSize: 5 * 1024 * 1024,
5898
+ captureResponseBody: true
5722
5899
  });
5723
- if (!response.ok) {
5724
- return { type: "failed" };
5725
- }
5726
- const json = await response.json();
5727
- return {
5728
- type: "success",
5729
- access: json.access_token,
5730
- refresh: json.refresh_token,
5731
- expires: Date.now() + json.expires_in * 1e3
5732
- };
5733
- } catch (_error) {
5734
- return { type: "failed" };
5735
- }
5736
- }
5737
- updateCredentials(result) {
5738
- if (result.type === "success" && result.access && result.refresh && result.expires) {
5739
- if (this.opts.oauth) {
5740
- this.opts.oauth.access = result.access;
5741
- this.opts.oauth.refresh = result.refresh;
5742
- this.opts.oauth.expires = result.expires;
5743
- }
5744
- this.opts.onTokenUpdate?.({
5745
- access: result.access,
5746
- refresh: result.refresh,
5747
- expires: result.expires
5900
+ this.authTransport = new AnthropicAuthTransport(base, {
5901
+ apiKey: this.opts.apiKey,
5902
+ oauth: this.opts.oauth ? {
5903
+ access: this.opts.oauth.access,
5904
+ refresh: this.opts.oauth.refresh,
5905
+ expires: this.opts.oauth.expires
5906
+ } : void 0,
5907
+ baseUrl: this.opts.baseURL || this.opts.apiUrl,
5908
+ retry: this.opts.retry,
5909
+ onTokenUpdate: this.opts.onTokenUpdate
5748
5910
  });
5749
5911
  }
5912
+ return this.authTransport;
5750
5913
  }
5751
- async ensureValidToken() {
5752
- if (!this.opts.oauth) return;
5753
- if (this.refreshPromise) {
5754
- const result = await this.refreshPromise;
5755
- if (result.type === "failed") {
5756
- throw new Error("Token refresh failed");
5757
- }
5758
- return;
5759
- }
5760
- this.refreshPromise = this.refreshAccessToken();
5761
- try {
5762
- const result = await this.refreshPromise;
5763
- if (result.type === "success") {
5764
- this.updateCredentials(result);
5765
- this.provider = void 0;
5766
- } else {
5767
- throw new Error("Token refresh failed");
5768
- }
5769
- } finally {
5770
- this.refreshPromise = null;
5914
+ getTransport() {
5915
+ if (!this.transport) {
5916
+ this.transport = this.getAuthTransport().createRetryTransport();
5771
5917
  }
5918
+ return this.transport;
5772
5919
  }
5773
- createFetchWithRetry() {
5774
- return async (url, init) => {
5775
- if (init?.headers && this.opts.oauth) {
5776
- const headers = new Headers(init.headers);
5777
- headers.delete("x-api-key");
5778
- headers.set("authorization", `Bearer ${this.opts.oauth.access}`);
5779
- headers.set("user-agent", "ai-sdk/anthropic/2.0.30 ai-sdk/provider-utils/3.0.12");
5780
- init = { ...init, headers };
5781
- }
5782
- const response = await fetch(url, init);
5783
- if ((response.status === 401 || response.status === 403) && this.opts.oauth) {
5784
- await this.ensureValidToken();
5785
- if (init?.headers) {
5786
- const headers = new Headers(init.headers);
5787
- headers.set("authorization", `Bearer ${this.opts.oauth.access}`);
5788
- init = { ...init, headers };
5789
- }
5790
- return fetch(url, init);
5791
- }
5792
- return response;
5793
- };
5794
- }
5795
- async getProvider() {
5920
+ getProvider() {
5796
5921
  if (this.provider) {
5797
5922
  return this.provider;
5798
5923
  }
5924
+ const authTransport = this.getAuthTransport();
5799
5925
  if (this.opts.oauth) {
5800
5926
  this.provider = createAnthropic({
5801
5927
  apiKey: "sk-ant-oauth-placeholder",
5802
- baseURL: this.opts.baseURL || this.opts.apiUrl,
5928
+ baseURL: authTransport.getBaseUrl(),
5803
5929
  headers: {
5804
5930
  authorization: `Bearer ${this.opts.oauth.access}`,
5805
5931
  "anthropic-beta": "oauth-2025-04-20,claude-code-20250219,interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14"
5806
5932
  },
5807
- fetch: this.createFetchWithRetry()
5933
+ fetch: authTransport.createFetchFunction()
5808
5934
  });
5809
5935
  } else {
5810
5936
  this.provider = createAnthropic({
5811
5937
  apiKey: this.opts.apiKey,
5812
- baseURL: this.opts.baseURL || this.opts.apiUrl
5938
+ baseURL: authTransport.getBaseUrl()
5813
5939
  });
5814
5940
  }
5815
5941
  return this.provider;
5816
5942
  }
5817
- async getModel(modelName) {
5818
- const provider = await this.getProvider();
5943
+ getModel(modelName) {
5944
+ const provider = this.getProvider();
5819
5945
  return provider(modelName);
5820
5946
  }
5821
5947
  transformMessages(messages) {
@@ -6049,7 +6175,7 @@ var AnthropicAISDKLLM = class {
6049
6175
  }
6050
6176
  async generateCompletion(params, signal) {
6051
6177
  try {
6052
- const model = await this.getModel(params.model);
6178
+ const model = this.getModel(params.model);
6053
6179
  const messages = this.transformMessages(params.messages);
6054
6180
  const tools = this.transformTools(params.tools);
6055
6181
  const toolChoice = tools ? this.transformToolChoice(params.tool_choice) : void 0;
@@ -6083,7 +6209,7 @@ var AnthropicAISDKLLM = class {
6083
6209
  }
6084
6210
  async streamCompletion(params, handlers = {}, signal) {
6085
6211
  let streamError = null;
6086
- const model = await this.getModel(params.model);
6212
+ const model = this.getModel(params.model);
6087
6213
  const messages = this.transformMessages(params.messages);
6088
6214
  const tools = this.transformTools(params.tools);
6089
6215
  const toolChoice = tools ? this.transformToolChoice(params.tool_choice) : void 0;
@@ -6134,45 +6260,17 @@ var AnthropicAISDKLLM = class {
6134
6260
  }
6135
6261
  }
6136
6262
  async getModels(signal) {
6137
- const baseURL = this.opts.baseURL || this.opts.apiUrl || "https://api.anthropic.com/v1";
6138
- const url = `${baseURL}/models`;
6139
- const headers = {
6140
- "anthropic-version": "2023-06-01",
6141
- "anthropic-beta": " oauth-2025-04-20,fine-grained-tool-streaming-2025-05-14"
6142
- };
6143
- if (this.opts.oauth) {
6144
- headers.authorization = `Bearer ${this.opts.oauth.access}`;
6145
- } else if (this.opts.apiKey) {
6146
- headers["x-api-key"] = this.opts.apiKey;
6147
- } else {
6263
+ const authTransport = this.getAuthTransport();
6264
+ if (!authTransport.getApiKey() && !authTransport.getOAuth()) {
6148
6265
  throw new LLMError("No API key or OAuth credentials provided", 401, false);
6149
6266
  }
6150
6267
  try {
6151
- const response = await fetch(url, {
6152
- method: "GET",
6153
- headers,
6154
- signal
6155
- });
6156
- if (!response.ok) {
6157
- if ((response.status === 401 || response.status === 403) && this.opts.oauth) {
6158
- await this.ensureValidToken();
6159
- headers.authorization = `Bearer ${this.opts.oauth.access}`;
6160
- const retryResponse = await fetch(url, {
6161
- method: "GET",
6162
- headers,
6163
- signal
6164
- });
6165
- if (!retryResponse.ok) {
6166
- const text2 = await retryResponse.text();
6167
- throw new LLMError(text2 || `Failed to fetch models: ${retryResponse.status}`, retryResponse.status);
6168
- }
6169
- const data2 = await retryResponse.json();
6170
- return data2.data.map((model) => normalizeModelInfo("anthropic", model));
6171
- }
6172
- const text = await response.text();
6173
- throw new LLMError(text || `Failed to fetch models: ${response.status}`, response.status);
6268
+ const res = await this.getTransport().get("/models", void 0, signal);
6269
+ if (!res.ok) {
6270
+ const text = await res.text();
6271
+ throw new LLMError(text || `Failed to fetch models: ${res.status}`, res.status);
6174
6272
  }
6175
- const data = await response.json();
6273
+ const data = await res.json();
6176
6274
  return data.data.map((model) => normalizeModelInfo("anthropic", model));
6177
6275
  } catch (error) {
6178
6276
  if (error instanceof LLMError) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuvin/nuvin-core",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "description": "",
5
5
  "private": false,
6
6
  "main": "dist/index.js",