@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.cjs CHANGED
@@ -16291,6 +16291,15 @@ function selectTransport(profile, apiKey) {
16291
16291
  const ctx = { apiKey };
16292
16292
  return { fetch: profile.transform.fetch?.(ctx), headers: profile.transform.headers?.(ctx) };
16293
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
+ };
16294
16303
  if (profile.apiMode === "chat_completions") {
16295
16304
  if (profile.name === "ollama") {
16296
16305
  const ollamaBase = process.env.OLLAMA_HOST ?? profile.baseUrl;
@@ -16308,6 +16317,7 @@ function selectTransport(profile, apiKey) {
16308
16317
  const envOverride = resolveBaseUrlEnvOverride(profile.name);
16309
16318
  if (envOverride !== void 0) opts.baseUrl = envOverride;
16310
16319
  const t = applyTransform();
16320
+ assertOAuthResolved(t);
16311
16321
  if (t.fetch !== void 0) opts.fetch = t.fetch;
16312
16322
  const merged = profile.extraHeaders !== void 0 || t.headers !== void 0 ? { ...profile.extraHeaders, ...t.headers } : void 0;
16313
16323
  if (merged !== void 0) opts.extraHeaders = merged;
@@ -16328,6 +16338,7 @@ function selectTransport(profile, apiKey) {
16328
16338
  }
16329
16339
  if (profile.apiMode === "responses_api") {
16330
16340
  const t = applyTransform();
16341
+ assertOAuthResolved(t);
16331
16342
  const mergedHeaders = profile.extraHeaders !== void 0 || t.headers !== void 0 ? { ...profile.extraHeaders, ...t.headers } : void 0;
16332
16343
  return new ResponsesApiClient({
16333
16344
  apiKey,