@theokit/sdk 4.10.1 → 4.11.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/index.js CHANGED
@@ -16250,6 +16250,9 @@ function sentinelForNoAuth(profile) {
16250
16250
  function sentinelForLazyAuth(profile) {
16251
16251
  if (profile.authType === "aws_bearer") return "__bedrock_lazy_token__";
16252
16252
  if (profile.authType === "gcp_oauth") return "__vertex_lazy_token__";
16253
+ if (profile.authType === "oauth_device_code" || profile.authType === "oauth_external") {
16254
+ return "__oauth_lazy_token__";
16255
+ }
16253
16256
  return void 0;
16254
16257
  }
16255
16258
  function filterPoolKeys(keys) {
@@ -16285,6 +16288,15 @@ function selectTransport(profile, apiKey) {
16285
16288
  const ctx = { apiKey };
16286
16289
  return { fetch: profile.transform.fetch?.(ctx), headers: profile.transform.headers?.(ctx) };
16287
16290
  };
16291
+ const assertOAuthResolved = (t) => {
16292
+ if (apiKey !== "__oauth_lazy_token__") return;
16293
+ const auth = t.headers?.authorization ?? t.headers?.Authorization;
16294
+ if (t.fetch === void 0 && auth === void 0) {
16295
+ throw new ConfigurationError(
16296
+ `provider "${profile.name}" uses OAuth (authType: ${profile.authType}) but no credential was resolved. Register a ProviderProfile.transform whose fetch (or headers.authorization) supplies the bearer \u2014 typically via resolveCredential() from "@theokit/sdk/auth".`
16297
+ );
16298
+ }
16299
+ };
16288
16300
  if (profile.apiMode === "chat_completions") {
16289
16301
  if (profile.name === "ollama") {
16290
16302
  const ollamaBase = process.env.OLLAMA_HOST ?? profile.baseUrl;
@@ -16302,6 +16314,7 @@ function selectTransport(profile, apiKey) {
16302
16314
  const envOverride = resolveBaseUrlEnvOverride(profile.name);
16303
16315
  if (envOverride !== void 0) opts.baseUrl = envOverride;
16304
16316
  const t = applyTransform();
16317
+ assertOAuthResolved(t);
16305
16318
  if (t.fetch !== void 0) opts.fetch = t.fetch;
16306
16319
  const merged = profile.extraHeaders !== void 0 || t.headers !== void 0 ? { ...profile.extraHeaders, ...t.headers } : void 0;
16307
16320
  if (merged !== void 0) opts.extraHeaders = merged;
@@ -16322,6 +16335,7 @@ function selectTransport(profile, apiKey) {
16322
16335
  }
16323
16336
  if (profile.apiMode === "responses_api") {
16324
16337
  const t = applyTransform();
16338
+ assertOAuthResolved(t);
16325
16339
  const mergedHeaders = profile.extraHeaders !== void 0 || t.headers !== void 0 ? { ...profile.extraHeaders, ...t.headers } : void 0;
16326
16340
  return new ResponsesApiClient({
16327
16341
  apiKey,