@theokit/sdk 4.10.0 → 4.11.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.
package/dist/index.cjs CHANGED
@@ -15210,6 +15210,7 @@ var OpenAIClient = class {
15210
15210
  if (this.options.organization !== void 0) {
15211
15211
  headers["openai-organization"] = this.options.organization;
15212
15212
  }
15213
+ if (this.options.extraHeaders !== void 0) Object.assign(headers, this.options.extraHeaders);
15213
15214
  const providerId = this.options.providerName ?? this.name;
15214
15215
  let response;
15215
15216
  try {
@@ -16252,6 +16253,9 @@ function sentinelForNoAuth(profile) {
16252
16253
  function sentinelForLazyAuth(profile) {
16253
16254
  if (profile.authType === "aws_bearer") return "__bedrock_lazy_token__";
16254
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
+ }
16255
16259
  return void 0;
16256
16260
  }
16257
16261
  function filterPoolKeys(keys) {
@@ -16282,9 +16286,11 @@ function resolveApiKey2(envVars) {
16282
16286
  return void 0;
16283
16287
  }
16284
16288
  function selectTransport(profile, apiKey) {
16285
- const transformCtx = { apiKey };
16286
- const transformFetch = profile.transform?.fetch?.(transformCtx);
16287
- const transformHeaders = profile.transform?.headers?.(transformCtx);
16289
+ const applyTransform = () => {
16290
+ if (profile.transform === void 0) return {};
16291
+ const ctx = { apiKey };
16292
+ return { fetch: profile.transform.fetch?.(ctx), headers: profile.transform.headers?.(ctx) };
16293
+ };
16288
16294
  if (profile.apiMode === "chat_completions") {
16289
16295
  if (profile.name === "ollama") {
16290
16296
  const ollamaBase = process.env.OLLAMA_HOST ?? profile.baseUrl;
@@ -16301,7 +16307,10 @@ function selectTransport(profile, apiKey) {
16301
16307
  }
16302
16308
  const envOverride = resolveBaseUrlEnvOverride(profile.name);
16303
16309
  if (envOverride !== void 0) opts.baseUrl = envOverride;
16304
- if (transformFetch !== void 0) opts.fetch = transformFetch;
16310
+ const t = applyTransform();
16311
+ if (t.fetch !== void 0) opts.fetch = t.fetch;
16312
+ const merged = profile.extraHeaders !== void 0 || t.headers !== void 0 ? { ...profile.extraHeaders, ...t.headers } : void 0;
16313
+ if (merged !== void 0) opts.extraHeaders = merged;
16305
16314
  return new OpenAIClient(opts);
16306
16315
  }
16307
16316
  if (profile.apiMode === "anthropic_messages") {
@@ -16318,12 +16327,13 @@ function selectTransport(profile, apiKey) {
16318
16327
  return new BedrockAnthropicClient(realKey !== void 0 ? { apiKey: realKey } : {});
16319
16328
  }
16320
16329
  if (profile.apiMode === "responses_api") {
16321
- const mergedHeaders = profile.extraHeaders !== void 0 || transformHeaders !== void 0 ? { ...profile.extraHeaders, ...transformHeaders } : void 0;
16330
+ const t = applyTransform();
16331
+ const mergedHeaders = profile.extraHeaders !== void 0 || t.headers !== void 0 ? { ...profile.extraHeaders, ...t.headers } : void 0;
16322
16332
  return new ResponsesApiClient({
16323
16333
  apiKey,
16324
16334
  ...profile.baseUrl !== void 0 ? { baseUrl: profile.baseUrl } : {},
16325
16335
  ...mergedHeaders !== void 0 ? { extraHeaders: mergedHeaders } : {},
16326
- ...transformFetch !== void 0 ? { fetch: transformFetch } : {},
16336
+ ...t.fetch !== void 0 ? { fetch: t.fetch } : {},
16327
16337
  providerName: profile.name
16328
16338
  });
16329
16339
  }