@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.cjs CHANGED
@@ -16253,6 +16253,9 @@ function sentinelForNoAuth(profile) {
16253
16253
  function sentinelForLazyAuth(profile) {
16254
16254
  if (profile.authType === "aws_bearer") return "__bedrock_lazy_token__";
16255
16255
  if (profile.authType === "gcp_oauth") return "__vertex_lazy_token__";
16256
+ if (profile.authType === "oauth_device_code" || profile.authType === "oauth_external") {
16257
+ return "__oauth_lazy_token__";
16258
+ }
16256
16259
  return void 0;
16257
16260
  }
16258
16261
  function filterPoolKeys(keys) {
@@ -16288,6 +16291,15 @@ function selectTransport(profile, apiKey) {
16288
16291
  const ctx = { apiKey };
16289
16292
  return { fetch: profile.transform.fetch?.(ctx), headers: profile.transform.headers?.(ctx) };
16290
16293
  };
16294
+ const assertOAuthResolved = (t) => {
16295
+ if (apiKey !== "__oauth_lazy_token__") return;
16296
+ const auth = t.headers?.authorization ?? t.headers?.Authorization;
16297
+ if (t.fetch === void 0 && auth === void 0) {
16298
+ throw new exports.ConfigurationError(
16299
+ `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".`
16300
+ );
16301
+ }
16302
+ };
16291
16303
  if (profile.apiMode === "chat_completions") {
16292
16304
  if (profile.name === "ollama") {
16293
16305
  const ollamaBase = process.env.OLLAMA_HOST ?? profile.baseUrl;
@@ -16305,6 +16317,7 @@ function selectTransport(profile, apiKey) {
16305
16317
  const envOverride = resolveBaseUrlEnvOverride(profile.name);
16306
16318
  if (envOverride !== void 0) opts.baseUrl = envOverride;
16307
16319
  const t = applyTransform();
16320
+ assertOAuthResolved(t);
16308
16321
  if (t.fetch !== void 0) opts.fetch = t.fetch;
16309
16322
  const merged = profile.extraHeaders !== void 0 || t.headers !== void 0 ? { ...profile.extraHeaders, ...t.headers } : void 0;
16310
16323
  if (merged !== void 0) opts.extraHeaders = merged;
@@ -16325,6 +16338,7 @@ function selectTransport(profile, apiKey) {
16325
16338
  }
16326
16339
  if (profile.apiMode === "responses_api") {
16327
16340
  const t = applyTransform();
16341
+ assertOAuthResolved(t);
16328
16342
  const mergedHeaders = profile.extraHeaders !== void 0 || t.headers !== void 0 ? { ...profile.extraHeaders, ...t.headers } : void 0;
16329
16343
  return new ResponsesApiClient({
16330
16344
  apiKey,