nexus-agents 2.54.1 → 2.55.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.
@@ -1,3 +1,8 @@
1
+ import {
2
+ CUSTOM_API_BASE_URL_ENV,
3
+ PROVIDER_ENV_KEYS,
4
+ validateCustomApiBaseUrl
5
+ } from "./chunk-R66AWJJ7.js";
1
6
  import {
2
7
  SessionMemory
3
8
  } from "./chunk-NYNBDP7M.js";
@@ -2788,13 +2793,6 @@ function createClaudeAdapter(config) {
2788
2793
  return new ClaudeAdapter(config);
2789
2794
  }
2790
2795
 
2791
- // src/adapters/sdk/types.ts
2792
- var PROVIDER_ENV_KEYS = {
2793
- anthropic: "ANTHROPIC_API_KEY",
2794
- openai: "OPENAI_API_KEY",
2795
- google: "GOOGLE_AI_API_KEY"
2796
- };
2797
-
2798
2796
  // src/adapters/sdk/sdk-adapter.ts
2799
2797
  function extractProviderFactory(mod, factoryName) {
2800
2798
  const factory = mod[factoryName];
@@ -2822,6 +2820,13 @@ function resolveApiKey(providerId, configKey) {
2822
2820
  const envVar = PROVIDER_ENV_KEYS[providerId];
2823
2821
  return process.env[envVar];
2824
2822
  }
2823
+ function resolveAndValidateCustomBaseUrl(config) {
2824
+ if (config.providerId !== "custom-openai") return void 0;
2825
+ const raw = config.baseUrl ?? process.env[CUSTOM_API_BASE_URL_ENV];
2826
+ const validated = validateCustomApiBaseUrl(raw);
2827
+ if (!validated.ok) throw validated.error;
2828
+ return validated.value.toString();
2829
+ }
2825
2830
  function mapFinishReason(reason) {
2826
2831
  switch (reason) {
2827
2832
  case "stop":
@@ -2853,6 +2858,8 @@ var SdkAdapter = class extends BaseAdapter {
2853
2858
  model;
2854
2859
  sdkFunctions;
2855
2860
  sdkConfig;
2861
+ /** Validated base URL for custom-openai provider; undefined for built-ins. */
2862
+ customBaseUrl;
2856
2863
  /** Inflight init promise for coalescing concurrent calls (Issue #1438). */
2857
2864
  initPromise;
2858
2865
  constructor(config, logger11) {
@@ -2868,6 +2875,7 @@ var SdkAdapter = class extends BaseAdapter {
2868
2875
  });
2869
2876
  this.sdkProviderId = config.providerId;
2870
2877
  this.sdkConfig = config;
2878
+ this.customBaseUrl = resolveAndValidateCustomBaseUrl(config);
2871
2879
  }
2872
2880
  /**
2873
2881
  * Lazily initialize the AI SDK model and functions.
@@ -2926,6 +2934,14 @@ var SdkAdapter = class extends BaseAdapter {
2926
2934
  const provider = factory({ apiKey });
2927
2935
  return { model: provider(this.modelId) };
2928
2936
  }
2937
+ case "custom-openai": {
2938
+ const mod = await import("@ai-sdk/openai");
2939
+ const factory = extractProviderFactory(mod, "createOpenAI");
2940
+ const opts = { apiKey };
2941
+ if (this.customBaseUrl !== void 0) opts["baseURL"] = this.customBaseUrl;
2942
+ const provider = factory(opts);
2943
+ return { model: provider(this.modelId) };
2944
+ }
2929
2945
  }
2930
2946
  }
2931
2947
  /**
@@ -3115,9 +3131,34 @@ function tryApiAdapter(config, logger11) {
3115
3131
  reason: `Using Google AI API via AI SDK (model: ${geminiModelId})`
3116
3132
  };
3117
3133
  }
3134
+ const custom = tryCustomOpenAiAdapter(logger11);
3135
+ if (custom !== null) return custom;
3118
3136
  logger11.info("No API keys available for any provider");
3119
3137
  return null;
3120
3138
  }
3139
+ function tryCustomOpenAiAdapter(logger11) {
3140
+ const customKey = resolveApiKeyFromEnv(void 0, "NEXUS_CUSTOM_API_KEY");
3141
+ const customBaseUrl = process.env["NEXUS_CUSTOM_API_BASE_URL"];
3142
+ if (customKey === void 0 || customBaseUrl === void 0 || customBaseUrl === "") {
3143
+ return null;
3144
+ }
3145
+ const customModelId = process.env["NEXUS_CUSTOM_MODEL"] ?? "gpt-4o";
3146
+ logger11.info("Using custom-openai SDK adapter", {
3147
+ model: customModelId,
3148
+ baseUrl: customBaseUrl
3149
+ });
3150
+ return {
3151
+ adapter: new SdkAdapter({
3152
+ providerId: "custom-openai",
3153
+ modelId: customModelId,
3154
+ apiKey: customKey,
3155
+ baseUrl: customBaseUrl
3156
+ }),
3157
+ source: "api",
3158
+ name: "custom-openai",
3159
+ reason: `Using custom OpenAI-compatible gateway at ${customBaseUrl} (model: ${customModelId})`
3160
+ };
3161
+ }
3121
3162
  async function selectCliFirst(config, logger11, cache) {
3122
3163
  const cliResult = await tryCliAdapter(config, logger11, cache);
3123
3164
  if (cliResult !== null) return cliResult;
@@ -12825,7 +12866,6 @@ export {
12825
12866
  CLAUDE_MODEL_ALIASES,
12826
12867
  ClaudeAdapter,
12827
12868
  createClaudeAdapter,
12828
- PROVIDER_ENV_KEYS,
12829
12869
  SdkAdapter,
12830
12870
  getGlobalEventBus,
12831
12871
  createEvent,
@@ -12936,4 +12976,4 @@ export {
12936
12976
  CONSENSUS_VOTE_OUTPUT_SCHEMA,
12937
12977
  registerConsensusVoteTool
12938
12978
  };
12939
- //# sourceMappingURL=chunk-LSHIG4SR.js.map
12979
+ //# sourceMappingURL=chunk-BPMQRYGU.js.map