@theokit/sdk 4.11.0 → 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
@@ -16288,6 +16288,15 @@ function selectTransport(profile, apiKey) {
16288
16288
  const ctx = { apiKey };
16289
16289
  return { fetch: profile.transform.fetch?.(ctx), headers: profile.transform.headers?.(ctx) };
16290
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
+ };
16291
16300
  if (profile.apiMode === "chat_completions") {
16292
16301
  if (profile.name === "ollama") {
16293
16302
  const ollamaBase = process.env.OLLAMA_HOST ?? profile.baseUrl;
@@ -16305,6 +16314,7 @@ function selectTransport(profile, apiKey) {
16305
16314
  const envOverride = resolveBaseUrlEnvOverride(profile.name);
16306
16315
  if (envOverride !== void 0) opts.baseUrl = envOverride;
16307
16316
  const t = applyTransform();
16317
+ assertOAuthResolved(t);
16308
16318
  if (t.fetch !== void 0) opts.fetch = t.fetch;
16309
16319
  const merged = profile.extraHeaders !== void 0 || t.headers !== void 0 ? { ...profile.extraHeaders, ...t.headers } : void 0;
16310
16320
  if (merged !== void 0) opts.extraHeaders = merged;
@@ -16325,6 +16335,7 @@ function selectTransport(profile, apiKey) {
16325
16335
  }
16326
16336
  if (profile.apiMode === "responses_api") {
16327
16337
  const t = applyTransform();
16338
+ assertOAuthResolved(t);
16328
16339
  const mergedHeaders = profile.extraHeaders !== void 0 || t.headers !== void 0 ? { ...profile.extraHeaders, ...t.headers } : void 0;
16329
16340
  return new ResponsesApiClient({
16330
16341
  apiKey,