@acosmi/sdk-ts 1.3.2 → 1.4.0

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.
@@ -1,4 +1,4 @@
1
- import { P as ProviderAdapter, ak as ProviderFormat, c as ModelCapabilities, d as ChatRequest, e as ChatResponse, f as StreamEvent } from '../index-28x02ITB.cjs';
1
+ import { P as ProviderAdapter, ak as ProviderFormat, c as ModelCapabilities, d as ChatRequest, e as ChatResponse, f as StreamEvent } from '../index-CbG9NqE-.cjs';
2
2
 
3
3
  /** 实现 ProviderAdapter, 用于 Anthropic 原生模型 */
4
4
  declare class AnthropicAdapter implements ProviderAdapter {
@@ -1,4 +1,4 @@
1
- import { P as ProviderAdapter, ak as ProviderFormat, c as ModelCapabilities, d as ChatRequest, e as ChatResponse, f as StreamEvent } from '../index-28x02ITB.js';
1
+ import { P as ProviderAdapter, ak as ProviderFormat, c as ModelCapabilities, d as ChatRequest, e as ChatResponse, f as StreamEvent } from '../index-CbG9NqE-.js';
2
2
 
3
3
  /** 实现 ProviderAdapter, 用于 Anthropic 原生模型 */
4
4
  declare class AnthropicAdapter implements ProviderAdapter {
@@ -1,4 +1,4 @@
1
- import { P as ProviderAdapter, ak as ProviderFormat, c as ModelCapabilities, d as ChatRequest, e as ChatResponse, f as StreamEvent, A as AnthropicResponse } from '../index-28x02ITB.cjs';
1
+ import { P as ProviderAdapter, ak as ProviderFormat, c as ModelCapabilities, d as ChatRequest, e as ChatResponse, f as StreamEvent, A as AnthropicResponse } from '../index-CbG9NqE-.cjs';
2
2
 
3
3
  /** 实现 ProviderAdapter, 用于所有非 Anthropic 厂商 */
4
4
  declare class OpenAIAdapter implements ProviderAdapter {
@@ -1,4 +1,4 @@
1
- import { P as ProviderAdapter, ak as ProviderFormat, c as ModelCapabilities, d as ChatRequest, e as ChatResponse, f as StreamEvent, A as AnthropicResponse } from '../index-28x02ITB.js';
1
+ import { P as ProviderAdapter, ak as ProviderFormat, c as ModelCapabilities, d as ChatRequest, e as ChatResponse, f as StreamEvent, A as AnthropicResponse } from '../index-CbG9NqE-.js';
2
2
 
3
3
  /** 实现 ProviderAdapter, 用于所有非 Anthropic 厂商 */
4
4
  declare class OpenAIAdapter implements ProviderAdapter {
@@ -1024,4 +1024,4 @@ declare function getAdapter(provider: string): ProviderAdapter;
1024
1024
  */
1025
1025
  declare function getAdapterForModel(m: ManagedModel): ProviderAdapter;
1026
1026
 
1027
- export { type ChatUsage as $, type AnthropicResponse as A, BusinessError as B, type ClientRegistration as C, type ToolView as D, type EntitlementBalance as E, type DeviceRegistration as F, type GenerateSkillRequest as G, type NotificationPreference as H, type InputModality as I, type WSEvent as J, type APIResponse as K, type AnthropicContentBlock as L, type ManagedModel as M, type NotificationList as N, type Order as O, type ProviderAdapter as P, type QuotaSummary as Q, type AnthropicUsage as R, type ServerMetadata as S, type TokenResponse as T, BucketClassCommercial as U, BucketClassGeneric as V, type WalletStats as W, type BucketInfo as X, type BucketRow as Y, type ChatContentBlock as Z, type ChatMessage as _, type TokenSet as a, type ConsumeRecord as a0, type EffortConfig as a1, type GeoLoc as a2, HTTPError as a3, ModelNotFoundError as a4, NetworkError as a5, type Notification as a6, type NotificationUnreadCount as a7, type OpenAIChatChoice as a8, type OpenAIChatMessage as a9, type YudaoPageResult as aA, anthropicResponseTextContent as aB, anthropicResponseThinkingContent as aC, anthropicResponseToolUseBlocks as aD, apiResponseBusinessError as aE, apiResponseGetMessage as aF, bucketInfoIsCommercial as aG, bucketRowIsCommercial as aH, getAdapter as aI, getAdapterForModel as aJ, newThinkingConfig as aK, newWebSearchTool as aL, parseNotificationEvent as aM, parseSettlement as aN, parseSourcesEvent as aO, tokenSetIsExpired as aP, type OpenAIChatResponse as aa, type OpenAIFunctionCall as ab, type OpenAIStreamChoice as ac, type OpenAIStreamChunk as ad, type OpenAIStreamDelta as ae, type OpenAIStreamToolCall as af, type OpenAIToolCall as ag, type OpenAIUsage as ah, OrderTerminalError as ai, type OutputConfig as aj, ProviderFormat as ak, RateLimitError as al, type ServerTool as am, ServerToolTypeWebSearch as an, type SkillStoreListItem as ao, StreamError as ap, type ThinkingConfig as aq, ThinkingHigh as ar, ThinkingHighMinMaxTokens as as, ThinkingMax as at, ThinkingMaxFallbackMaxTokens as au, ThinkingOff as av, type ToolListResponse as aw, type ToolProvider as ax, type WebSearchConfig as ay, type WebSearchSource as az, type ModelCoefficient as b, type ModelCapabilities as c, type ChatRequest as d, type ChatResponse as e, type StreamEvent as f, type SourcesEvent as g, type StreamSettlement as h, type BalanceDetail as i, type EntitlementItem as j, type ConsumeRecordPage as k, type ModelByQuotaResponse as l, type ModelBucket as m, type TokenPackage as n, type PayPayload as o, type OrderStatus as p, type Transaction as q, type SkillStoreQuery as r, type SkillStoreItem as s, type SkillBrowseResponse as t, type SkillBrowseListResponse as u, type SkillSummary as v, type CertificationStatus as w, type GenerateSkillResult as x, type OptimizeSkillRequest as y, type OptimizeSkillResult as z };
1027
+ export { type ChatUsage as $, type AnthropicResponse as A, BusinessError as B, type ClientRegistration as C, type ToolView as D, type EntitlementBalance as E, type DeviceRegistration as F, type GenerateSkillRequest as G, type NotificationPreference as H, type InputModality as I, type WSEvent as J, type APIResponse as K, type AnthropicContentBlock as L, type ManagedModel as M, type NotificationList as N, type Order as O, type ProviderAdapter as P, type QuotaSummary as Q, type AnthropicUsage as R, type ServerMetadata as S, type TokenSet as T, BucketClassCommercial as U, BucketClassGeneric as V, type WalletStats as W, type BucketInfo as X, type BucketRow as Y, type ChatContentBlock as Z, type ChatMessage as _, type TokenResponse as a, type ConsumeRecord as a0, type EffortConfig as a1, type GeoLoc as a2, HTTPError as a3, ModelNotFoundError as a4, NetworkError as a5, type Notification as a6, type NotificationUnreadCount as a7, type OpenAIChatChoice as a8, type OpenAIChatMessage as a9, type YudaoPageResult as aA, anthropicResponseTextContent as aB, anthropicResponseThinkingContent as aC, anthropicResponseToolUseBlocks as aD, apiResponseBusinessError as aE, apiResponseGetMessage as aF, bucketInfoIsCommercial as aG, bucketRowIsCommercial as aH, getAdapter as aI, getAdapterForModel as aJ, newThinkingConfig as aK, newWebSearchTool as aL, parseNotificationEvent as aM, parseSettlement as aN, parseSourcesEvent as aO, tokenSetIsExpired as aP, type OpenAIChatResponse as aa, type OpenAIFunctionCall as ab, type OpenAIStreamChoice as ac, type OpenAIStreamChunk as ad, type OpenAIStreamDelta as ae, type OpenAIStreamToolCall as af, type OpenAIToolCall as ag, type OpenAIUsage as ah, OrderTerminalError as ai, type OutputConfig as aj, ProviderFormat as ak, RateLimitError as al, type ServerTool as am, ServerToolTypeWebSearch as an, type SkillStoreListItem as ao, StreamError as ap, type ThinkingConfig as aq, ThinkingHigh as ar, ThinkingHighMinMaxTokens as as, ThinkingMax as at, ThinkingMaxFallbackMaxTokens as au, ThinkingOff as av, type ToolListResponse as aw, type ToolProvider as ax, type WebSearchConfig as ay, type WebSearchSource as az, type ModelCoefficient as b, type ModelCapabilities as c, type ChatRequest as d, type ChatResponse as e, type StreamEvent as f, type SourcesEvent as g, type StreamSettlement as h, type BalanceDetail as i, type EntitlementItem as j, type ConsumeRecordPage as k, type ModelByQuotaResponse as l, type ModelBucket as m, type TokenPackage as n, type PayPayload as o, type OrderStatus as p, type Transaction as q, type SkillStoreQuery as r, type SkillStoreItem as s, type SkillBrowseResponse as t, type SkillBrowseListResponse as u, type SkillSummary as v, type CertificationStatus as w, type GenerateSkillResult as x, type OptimizeSkillRequest as y, type OptimizeSkillResult as z };
@@ -1024,4 +1024,4 @@ declare function getAdapter(provider: string): ProviderAdapter;
1024
1024
  */
1025
1025
  declare function getAdapterForModel(m: ManagedModel): ProviderAdapter;
1026
1026
 
1027
- export { type ChatUsage as $, type AnthropicResponse as A, BusinessError as B, type ClientRegistration as C, type ToolView as D, type EntitlementBalance as E, type DeviceRegistration as F, type GenerateSkillRequest as G, type NotificationPreference as H, type InputModality as I, type WSEvent as J, type APIResponse as K, type AnthropicContentBlock as L, type ManagedModel as M, type NotificationList as N, type Order as O, type ProviderAdapter as P, type QuotaSummary as Q, type AnthropicUsage as R, type ServerMetadata as S, type TokenResponse as T, BucketClassCommercial as U, BucketClassGeneric as V, type WalletStats as W, type BucketInfo as X, type BucketRow as Y, type ChatContentBlock as Z, type ChatMessage as _, type TokenSet as a, type ConsumeRecord as a0, type EffortConfig as a1, type GeoLoc as a2, HTTPError as a3, ModelNotFoundError as a4, NetworkError as a5, type Notification as a6, type NotificationUnreadCount as a7, type OpenAIChatChoice as a8, type OpenAIChatMessage as a9, type YudaoPageResult as aA, anthropicResponseTextContent as aB, anthropicResponseThinkingContent as aC, anthropicResponseToolUseBlocks as aD, apiResponseBusinessError as aE, apiResponseGetMessage as aF, bucketInfoIsCommercial as aG, bucketRowIsCommercial as aH, getAdapter as aI, getAdapterForModel as aJ, newThinkingConfig as aK, newWebSearchTool as aL, parseNotificationEvent as aM, parseSettlement as aN, parseSourcesEvent as aO, tokenSetIsExpired as aP, type OpenAIChatResponse as aa, type OpenAIFunctionCall as ab, type OpenAIStreamChoice as ac, type OpenAIStreamChunk as ad, type OpenAIStreamDelta as ae, type OpenAIStreamToolCall as af, type OpenAIToolCall as ag, type OpenAIUsage as ah, OrderTerminalError as ai, type OutputConfig as aj, ProviderFormat as ak, RateLimitError as al, type ServerTool as am, ServerToolTypeWebSearch as an, type SkillStoreListItem as ao, StreamError as ap, type ThinkingConfig as aq, ThinkingHigh as ar, ThinkingHighMinMaxTokens as as, ThinkingMax as at, ThinkingMaxFallbackMaxTokens as au, ThinkingOff as av, type ToolListResponse as aw, type ToolProvider as ax, type WebSearchConfig as ay, type WebSearchSource as az, type ModelCoefficient as b, type ModelCapabilities as c, type ChatRequest as d, type ChatResponse as e, type StreamEvent as f, type SourcesEvent as g, type StreamSettlement as h, type BalanceDetail as i, type EntitlementItem as j, type ConsumeRecordPage as k, type ModelByQuotaResponse as l, type ModelBucket as m, type TokenPackage as n, type PayPayload as o, type OrderStatus as p, type Transaction as q, type SkillStoreQuery as r, type SkillStoreItem as s, type SkillBrowseResponse as t, type SkillBrowseListResponse as u, type SkillSummary as v, type CertificationStatus as w, type GenerateSkillResult as x, type OptimizeSkillRequest as y, type OptimizeSkillResult as z };
1027
+ export { type ChatUsage as $, type AnthropicResponse as A, BusinessError as B, type ClientRegistration as C, type ToolView as D, type EntitlementBalance as E, type DeviceRegistration as F, type GenerateSkillRequest as G, type NotificationPreference as H, type InputModality as I, type WSEvent as J, type APIResponse as K, type AnthropicContentBlock as L, type ManagedModel as M, type NotificationList as N, type Order as O, type ProviderAdapter as P, type QuotaSummary as Q, type AnthropicUsage as R, type ServerMetadata as S, type TokenSet as T, BucketClassCommercial as U, BucketClassGeneric as V, type WalletStats as W, type BucketInfo as X, type BucketRow as Y, type ChatContentBlock as Z, type ChatMessage as _, type TokenResponse as a, type ConsumeRecord as a0, type EffortConfig as a1, type GeoLoc as a2, HTTPError as a3, ModelNotFoundError as a4, NetworkError as a5, type Notification as a6, type NotificationUnreadCount as a7, type OpenAIChatChoice as a8, type OpenAIChatMessage as a9, type YudaoPageResult as aA, anthropicResponseTextContent as aB, anthropicResponseThinkingContent as aC, anthropicResponseToolUseBlocks as aD, apiResponseBusinessError as aE, apiResponseGetMessage as aF, bucketInfoIsCommercial as aG, bucketRowIsCommercial as aH, getAdapter as aI, getAdapterForModel as aJ, newThinkingConfig as aK, newWebSearchTool as aL, parseNotificationEvent as aM, parseSettlement as aN, parseSourcesEvent as aO, tokenSetIsExpired as aP, type OpenAIChatResponse as aa, type OpenAIFunctionCall as ab, type OpenAIStreamChoice as ac, type OpenAIStreamChunk as ad, type OpenAIStreamDelta as ae, type OpenAIStreamToolCall as af, type OpenAIToolCall as ag, type OpenAIUsage as ah, OrderTerminalError as ai, type OutputConfig as aj, ProviderFormat as ak, RateLimitError as al, type ServerTool as am, ServerToolTypeWebSearch as an, type SkillStoreListItem as ao, StreamError as ap, type ThinkingConfig as aq, ThinkingHigh as ar, ThinkingHighMinMaxTokens as as, ThinkingMax as at, ThinkingMaxFallbackMaxTokens as au, ThinkingOff as av, type ToolListResponse as aw, type ToolProvider as ax, type WebSearchConfig as ay, type WebSearchSource as az, type ModelCoefficient as b, type ModelCapabilities as c, type ChatRequest as d, type ChatResponse as e, type StreamEvent as f, type SourcesEvent as g, type StreamSettlement as h, type BalanceDetail as i, type EntitlementItem as j, type ConsumeRecordPage as k, type ModelByQuotaResponse as l, type ModelBucket as m, type TokenPackage as n, type PayPayload as o, type OrderStatus as p, type Transaction as q, type SkillStoreQuery as r, type SkillStoreItem as s, type SkillBrowseResponse as t, type SkillBrowseListResponse as u, type SkillSummary as v, type CertificationStatus as w, type GenerateSkillResult as x, type OptimizeSkillRequest as y, type OptimizeSkillResult as z };
@@ -1058,7 +1058,7 @@ init_adapters();
1058
1058
 
1059
1059
  // src/auth.ts
1060
1060
  var authTimeoutMs = 3e4;
1061
- async function discover(serverURL, signal) {
1061
+ async function discoverWithProfile(serverURL, profile, signal) {
1062
1062
  let parsed;
1063
1063
  try {
1064
1064
  parsed = new URL(serverURL.replace(/\/+$/, ""));
@@ -1066,7 +1066,7 @@ async function discover(serverURL, signal) {
1066
1066
  throw new Error(`discover: invalid server URL: ${e instanceof Error ? e.message : String(e)}`);
1067
1067
  }
1068
1068
  const origin = `${parsed.protocol}//${parsed.host}`;
1069
- const endpoint = `${origin}/.well-known/oauth-authorization-server/desktop`;
1069
+ const endpoint = `${origin}/.well-known/oauth-authorization-server/${profile}`;
1070
1070
  const ctl = withTimeout(authTimeoutMs, signal);
1071
1071
  let resp;
1072
1072
  try {
@@ -1092,6 +1092,12 @@ async function discover(serverURL, signal) {
1092
1092
  }
1093
1093
  return meta;
1094
1094
  }
1095
+ async function discover(serverURL, signal) {
1096
+ return discoverWithProfile(serverURL, "desktop", signal);
1097
+ }
1098
+ async function discoverWebOAuthMetadata(serverURL, signal) {
1099
+ return discoverWithProfile(serverURL, "web", signal);
1100
+ }
1095
1101
  async function register(meta, appName, signal) {
1096
1102
  const regReq = {
1097
1103
  client_name: appName,
@@ -1123,12 +1129,50 @@ async function register(meta, appName, signal) {
1123
1129
  throw new Error(`register: decode: ${e instanceof Error ? e.message : String(e)}`);
1124
1130
  }
1125
1131
  }
1126
- async function generateCodeVerifier() {
1132
+ async function registerWebOAuthClient(meta, opts, signal) {
1133
+ const regReq = {
1134
+ client_name: opts.clientName,
1135
+ token_endpoint_auth_method: "none",
1136
+ grant_types: ["authorization_code", "refresh_token"],
1137
+ redirect_uris: opts.redirectURIs,
1138
+ response_types: ["code"],
1139
+ ...opts.scopes ? { scope: opts.scopes.join(" ") } : {}
1140
+ };
1141
+ const ctl = withTimeout(authTimeoutMs, signal);
1142
+ let resp;
1143
+ try {
1144
+ resp = await fetch(meta.registration_endpoint, {
1145
+ method: "POST",
1146
+ headers: { "Content-Type": "application/json" },
1147
+ body: JSON.stringify(regReq),
1148
+ signal: ctl.signal
1149
+ });
1150
+ } catch (e) {
1151
+ throw new Error(`register: ${e instanceof Error ? e.message : String(e)}`);
1152
+ } finally {
1153
+ ctl.dispose();
1154
+ }
1155
+ if (resp.status !== 200 && resp.status !== 201) {
1156
+ throw new Error(`register: HTTP ${resp.status}`);
1157
+ }
1158
+ try {
1159
+ return await resp.json();
1160
+ } catch (e) {
1161
+ throw new Error(`register: decode: ${e instanceof Error ? e.message : String(e)}`);
1162
+ }
1163
+ }
1164
+ async function randomBase64Url32() {
1127
1165
  const c = await getCrypto();
1128
1166
  const b = new Uint8Array(32);
1129
1167
  c.getRandomValues(b);
1130
1168
  return base64urlNoPad(b);
1131
1169
  }
1170
+ async function generateCodeVerifier() {
1171
+ return randomBase64Url32();
1172
+ }
1173
+ async function generateState() {
1174
+ return randomBase64Url32();
1175
+ }
1132
1176
  async function codeChallenge(verifier) {
1133
1177
  const c = await getCrypto();
1134
1178
  const buf = await c.subtle.digest("SHA-256", new TextEncoder().encode(verifier));
@@ -1162,6 +1206,7 @@ var ErrAuthDenied = "auth_denied";
1162
1206
  var ErrTimeout = "auth_timeout";
1163
1207
  var ErrTokenExchange = "token_exchange_failed";
1164
1208
  var ErrSSLProxy = "ssl_proxy_detected";
1209
+ var ErrStateMismatch = "state_mismatch";
1165
1210
  function isSSLError(err) {
1166
1211
  const msg = err instanceof Error ? err.message : String(err);
1167
1212
  return msg.includes("tls:") || msg.includes("x509:") || msg.includes("certificate");
@@ -1275,6 +1320,51 @@ async function authorize(meta, clientID, scopes, opts = {}) {
1275
1320
  function htmlEscape(s) {
1276
1321
  return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
1277
1322
  }
1323
+ async function createWebAuthorizationRequest(meta, opts) {
1324
+ const verifier = await generateCodeVerifier();
1325
+ const challenge = await codeChallenge(verifier);
1326
+ const state = await generateState();
1327
+ const authURL = new URL(meta.authorization_endpoint);
1328
+ authURL.searchParams.set("response_type", "code");
1329
+ authURL.searchParams.set("client_id", opts.clientID);
1330
+ authURL.searchParams.set("redirect_uri", opts.redirectURI);
1331
+ authURL.searchParams.set("code_challenge", challenge);
1332
+ authURL.searchParams.set("code_challenge_method", "S256");
1333
+ authURL.searchParams.set("state", state);
1334
+ authURL.searchParams.set("scope", opts.scopes.join(" "));
1335
+ if (opts.loginHint) {
1336
+ authURL.searchParams.set("login_hint", opts.loginHint);
1337
+ }
1338
+ return {
1339
+ authUrl: authURL.toString(),
1340
+ state,
1341
+ verifier,
1342
+ clientID: opts.clientID,
1343
+ redirectURI: opts.redirectURI,
1344
+ serverURL: opts.serverURL,
1345
+ createdAt: Date.now()
1346
+ };
1347
+ }
1348
+ async function completeWebAuthorizationRequest(pending, params, signal) {
1349
+ if (!params.code) {
1350
+ throw new Error("completeWebAuthorizationRequest: missing authorization code");
1351
+ }
1352
+ if (params.state !== pending.state) {
1353
+ throw new Error(
1354
+ `completeWebAuthorizationRequest: ${ErrStateMismatch}: callback state does not match pending state (possible CSRF)`
1355
+ );
1356
+ }
1357
+ const meta = await discoverWebOAuthMetadata(pending.serverURL, signal);
1358
+ const resp = await exchangeCode(
1359
+ meta,
1360
+ pending.clientID,
1361
+ params.code,
1362
+ pending.redirectURI,
1363
+ pending.verifier,
1364
+ signal
1365
+ );
1366
+ return newTokenSet(resp, pending.clientID, pending.serverURL);
1367
+ }
1278
1368
  async function exchangeCode(meta, clientID, code, redirectURI, codeVerifier, signal) {
1279
1369
  const data = new URLSearchParams({
1280
1370
  grant_type: "authorization_code",
@@ -2167,6 +2257,8 @@ var Client = class _Client {
2167
2257
  serverURL;
2168
2258
  /** Compliance API 根地址 (已 trim 尾随 /); null = 走默认 ${serverURL}/admin-api */
2169
2259
  complianceBaseURL;
2260
+ /** OAuth metadata profile — 刷新 token 时发现 metadata 用 (默认 'desktop') */
2261
+ oauthMetadataProfile;
2170
2262
  /** OAuth metadata (lazy loaded) */
2171
2263
  meta = null;
2172
2264
  /** 当前 token (内存) */
@@ -2201,6 +2293,7 @@ var Client = class _Client {
2201
2293
  constructor(cfg = {}) {
2202
2294
  this.serverURL = (cfg.serverURL ?? "https://acosmi.com").replace(/\/+$/, "");
2203
2295
  this.complianceBaseURL = cfg.complianceBaseURL ? cfg.complianceBaseURL.replace(/\/+$/, "") : null;
2296
+ this.oauthMetadataProfile = cfg.oauthMetadataProfile ?? "desktop";
2204
2297
  this.store = cfg.store ?? defaultTokenStore();
2205
2298
  this.fetchImpl = cfg.fetchImpl ?? globalThis.fetch.bind(globalThis);
2206
2299
  this.retryPolicy = effectivePolicy(cfg.retryPolicy ?? null);
@@ -2375,7 +2468,7 @@ var Client = class _Client {
2375
2468
  if (tokens) {
2376
2469
  if (!meta) {
2377
2470
  try {
2378
- meta = await discover(this.serverURL, signal);
2471
+ meta = await discoverWithProfile(this.serverURL, this.oauthMetadataProfile, signal);
2379
2472
  } catch (e) {
2380
2473
  console.warn(`[acosmi-sdk] warning: discover for revocation failed: ${e instanceof Error ? e.message : String(e)}`);
2381
2474
  }
@@ -2446,7 +2539,7 @@ var Client = class _Client {
2446
2539
  }
2447
2540
  if (this.meta == null) {
2448
2541
  try {
2449
- this.meta = await discover(this.serverURL, signal);
2542
+ this.meta = await discoverWithProfile(this.serverURL, this.oauthMetadataProfile, signal);
2450
2543
  } catch (e) {
2451
2544
  throw new Error(
2452
2545
  `discover for refresh: ${e instanceof Error ? e.message : String(e)}`
@@ -2478,7 +2571,7 @@ var Client = class _Client {
2478
2571
  throw new Error("no tokens to refresh");
2479
2572
  }
2480
2573
  if (this.meta == null) {
2481
- this.meta = await discover(this.serverURL, signal);
2574
+ this.meta = await discoverWithProfile(this.serverURL, this.oauthMetadataProfile, signal);
2482
2575
  }
2483
2576
  const tokenResp = await refreshToken(
2484
2577
  this.meta,
@@ -5397,6 +5490,7 @@ exports.ErrSealApprovalNotApproved = ErrSealApprovalNotApproved;
5397
5490
  exports.ErrSealApprovalSealMismatch = ErrSealApprovalSealMismatch;
5398
5491
  exports.ErrSealApprovalTransactorMismatch = ErrSealApprovalTransactorMismatch;
5399
5492
  exports.ErrSealUseAlreadyConsumed = ErrSealUseAlreadyConsumed;
5493
+ exports.ErrStateMismatch = ErrStateMismatch;
5400
5494
  exports.ErrTimeout = ErrTimeout;
5401
5495
  exports.ErrTokenExchange = ErrTokenExchange;
5402
5496
  exports.EventAuthURL = EventAuthURL;
@@ -5452,17 +5546,22 @@ exports.bucketRowIsCommercial = bucketRowIsCommercial;
5452
5546
  exports.buildBetas = buildBetas;
5453
5547
  exports.classifyComplianceError = classifyComplianceError;
5454
5548
  exports.commerceScopes = commerceScopes;
5549
+ exports.completeWebAuthorizationRequest = completeWebAuthorizationRequest;
5455
5550
  exports.complianceScopes = complianceScopes;
5456
5551
  exports.computeBackoff = computeBackoff;
5552
+ exports.createWebAuthorizationRequest = createWebAuthorizationRequest;
5457
5553
  exports.defaultRetryable = defaultRetryable;
5458
5554
  exports.defaultSafeToRetry = defaultSafeToRetry;
5459
5555
  exports.discover = discover;
5556
+ exports.discoverWebOAuthMetadata = discoverWebOAuthMetadata;
5557
+ exports.discoverWithProfile = discoverWithProfile;
5460
5558
  exports.effectivePolicy = effectivePolicy;
5461
5559
  exports.exchangeCode = exchangeCode;
5462
5560
  exports.extractAnthropicBlockMeta = extractAnthropicBlockMeta;
5463
5561
  exports.fileLockDefaults = fileLockDefaults;
5464
5562
  exports.findDesktopVisualUnderstandingModel = findDesktopVisualUnderstandingModel;
5465
5563
  exports.findFirstModelByInputModality = findFirstModelByInputModality;
5564
+ exports.generateState = generateState;
5466
5565
  exports.getAdapter = getAdapter;
5467
5566
  exports.getAdapterForModel = getAdapterForModel;
5468
5567
  exports.isBillingConfirmable = isBillingConfirmable;
@@ -5481,6 +5580,7 @@ exports.parseSettlement = parseSettlement;
5481
5580
  exports.parseSourcesEvent = parseSourcesEvent;
5482
5581
  exports.refreshToken = refreshToken;
5483
5582
  exports.register = register;
5583
+ exports.registerWebOAuthClient = registerWebOAuthClient;
5484
5584
  exports.revokeToken = revokeToken;
5485
5585
  exports.sanitize = sanitize_exports;
5486
5586
  exports.skillScopes = skillScopes;