demian-cli 1.0.8 → 1.0.9

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/tui.mjs CHANGED
@@ -23573,11 +23573,18 @@ function providerModelProfiles(providerName, providerConfig) {
23573
23573
  return out;
23574
23574
  }
23575
23575
  function providerModelOptions(providerName, providerConfig) {
23576
- return providerModelProfiles(providerName, providerConfig).filter((profile) => !profile.hidden).map((profile) => profile.displayName ?? profile.name ?? profile.model);
23576
+ return providerModelProfiles(providerName, providerConfig).filter((profile) => !profile.hidden).map((profile) => displayModelForProfile(profile));
23577
23577
  }
23578
23578
  function defaultModelForProvider(providerName, providerConfig) {
23579
23579
  return providerModelProfiles(providerName, providerConfig)[0]?.model ?? "";
23580
23580
  }
23581
+ function displayModelForProfile(profile) {
23582
+ return profile.displayName?.trim() || profile.name?.trim() || profile.model;
23583
+ }
23584
+ function defaultDisplayModelForProvider(providerName, providerConfig) {
23585
+ const profile = providerModelProfiles(providerName, providerConfig)[0];
23586
+ return profile ? displayModelForProfile(profile) : defaultModelForProvider(providerName, providerConfig);
23587
+ }
23581
23588
  function resolveConfiguredApiKey(providerConfig) {
23582
23589
  if (providerConfig.apiKey) return { value: providerConfig.apiKey };
23583
23590
  for (const envName of [providerConfig.apiKeyEnv, ...providerConfig.apiKeyEnvAliases ?? []]) {
@@ -23614,7 +23621,7 @@ function mergeModelProfile(providerConfig, profile) {
23614
23621
  ...providerConfig,
23615
23622
  ...definedOnly({
23616
23623
  baseURL: profile.baseURL,
23617
- apiKey: profile.apiKey,
23624
+ apiKey: nonEmptyString(profile.apiKey),
23618
23625
  apiKeyEnv: profile.apiKeyEnv,
23619
23626
  apiKeyEnvAliases: profile.apiKeyEnvAliases,
23620
23627
  auth: profile.auth,
@@ -23629,6 +23636,9 @@ function mergeModelProfile(providerConfig, profile) {
23629
23636
  function definedOnly(input2) {
23630
23637
  return Object.fromEntries(Object.entries(input2).filter(([, value]) => value !== void 0));
23631
23638
  }
23639
+ function nonEmptyString(value) {
23640
+ return typeof value === "string" && value.length > 0 ? value : void 0;
23641
+ }
23632
23642
  function fallbackModelForProvider(providerName, providerConfig) {
23633
23643
  if (typeof providerConfig.model === "string" && providerConfig.model.trim()) return providerConfig.model.trim();
23634
23644
  if (providerName === "openai") return "gpt-5.5";
@@ -23932,6 +23942,7 @@ var init_config = __esm({
23932
23942
  defaultProvider: "brave",
23933
23943
  providers: {
23934
23944
  brave: {
23945
+ apiKey: "",
23935
23946
  apiKeyEnv: "BRAVE_SEARCH_API_KEY",
23936
23947
  endpoint: "https://api.search.brave.com/res/v1/web/search",
23937
23948
  count: 10,
@@ -23940,12 +23951,14 @@ var init_config = __esm({
23940
23951
  safeSearch: "moderate"
23941
23952
  },
23942
23953
  tavily: {
23954
+ apiKey: "",
23943
23955
  apiKeyEnv: "TAVILY_API_KEY",
23944
23956
  endpoint: "https://api.tavily.com/search",
23945
23957
  maxResults: 5,
23946
23958
  searchDepth: "basic"
23947
23959
  },
23948
23960
  exa: {
23961
+ apiKey: "",
23949
23962
  apiKeyEnv: "EXA_API_KEY",
23950
23963
  endpoint: "https://api.exa.ai/search",
23951
23964
  numResults: 5,
@@ -24000,6 +24013,7 @@ var init_config = __esm({
24000
24013
  openai: {
24001
24014
  type: "openai-compatible",
24002
24015
  baseURL: "https://api.openai.com/v1",
24016
+ apiKey: "",
24003
24017
  apiKeyEnv: "OPENAI_API_KEY",
24004
24018
  catalog: {
24005
24019
  type: "openai-models",
@@ -24009,6 +24023,7 @@ var init_config = __esm({
24009
24023
  anthropic: {
24010
24024
  type: "anthropic",
24011
24025
  baseURL: "https://api.anthropic.com/v1",
24026
+ apiKey: "",
24012
24027
  apiKeyEnv: "ANTHROPIC_API_KEY",
24013
24028
  catalog: {
24014
24029
  type: "anthropic-models",
@@ -24018,6 +24033,7 @@ var init_config = __esm({
24018
24033
  gemini: {
24019
24034
  type: "openai-compatible",
24020
24035
  baseURL: "https://generativelanguage.googleapis.com/v1beta/openai/",
24036
+ apiKey: "",
24021
24037
  apiKeyEnv: "GEMINI_API_KEY",
24022
24038
  apiKeyEnvAliases: ["GOOGLE_API_KEY"],
24023
24039
  catalog: {
@@ -24028,6 +24044,7 @@ var init_config = __esm({
24028
24044
  groq: {
24029
24045
  type: "openai-compatible",
24030
24046
  baseURL: "https://api.groq.com/openai/v1",
24047
+ apiKey: "",
24031
24048
  apiKeyEnv: "GROQ_API_KEY",
24032
24049
  catalog: {
24033
24050
  type: "groq-models",
@@ -24043,6 +24060,7 @@ var init_config = __esm({
24043
24060
  displayName: "Azure example",
24044
24061
  model: "azure-deployment-name",
24045
24062
  baseURL: "https://example.openai.azure.com/openai/v1",
24063
+ apiKey: "",
24046
24064
  apiKeyEnv: "AZURE_OPENAI_API_KEY"
24047
24065
  }
24048
24066
  ]
@@ -24051,6 +24069,7 @@ var init_config = __esm({
24051
24069
  type: "openai-compatible",
24052
24070
  baseURL: "http://localhost:1234/v1",
24053
24071
  apiKey: "lm-studio",
24072
+ modelProfiles: [],
24054
24073
  catalog: {
24055
24074
  type: "openai-compatible-models",
24056
24075
  endpoint: "http://localhost:1234/v1/models"
@@ -24060,6 +24079,7 @@ var init_config = __esm({
24060
24079
  type: "openai-compatible",
24061
24080
  baseURL: "http://localhost:11434/v1",
24062
24081
  apiKey: "ollama",
24082
+ modelProfiles: [],
24063
24083
  quirks: { omitTemperature: true },
24064
24084
  catalog: {
24065
24085
  type: "openai-compatible-models",
@@ -24069,7 +24089,9 @@ var init_config = __esm({
24069
24089
  "ollama-cloud": {
24070
24090
  type: "ollama",
24071
24091
  baseURL: "https://ollama.com/api",
24092
+ apiKey: "",
24072
24093
  apiKeyEnv: "OLLAMA_API_KEY",
24094
+ modelProfiles: [],
24073
24095
  catalog: {
24074
24096
  type: "ollama-tags",
24075
24097
  endpoint: "https://ollama.com/api/tags"
@@ -24079,6 +24101,7 @@ var init_config = __esm({
24079
24101
  type: "openai-compatible",
24080
24102
  baseURL: "http://localhost:8080/v1",
24081
24103
  apiKey: "llama.cpp",
24104
+ modelProfiles: [],
24082
24105
  catalog: {
24083
24106
  type: "openai-compatible-models",
24084
24107
  endpoint: "http://localhost:8080/v1/models"
@@ -24088,6 +24111,7 @@ var init_config = __esm({
24088
24111
  type: "openai-compatible",
24089
24112
  baseURL: "http://localhost:8000/v1",
24090
24113
  apiKey: "vllm",
24114
+ modelProfiles: [],
24091
24115
  catalog: {
24092
24116
  type: "openai-compatible-models",
24093
24117
  endpoint: "http://localhost:8000/v1/models"
@@ -30877,7 +30901,7 @@ async function runExaSearch(config, options) {
30877
30901
  return searchResult("exa", options.query, results, json.value);
30878
30902
  }
30879
30903
  function resolveApiKey(provider, config) {
30880
- const value = config.apiKey ?? (config.apiKeyEnv ? process.env[config.apiKeyEnv] : void 0);
30904
+ const value = config.apiKey || (config.apiKeyEnv ? process.env[config.apiKeyEnv] : void 0);
30881
30905
  if (value) return { ok: true, value };
30882
30906
  return toolFail(`Missing API key for web_search provider "${provider}". Set webSearch.providers.${provider}.apiKey or set ${config.apiKeyEnv ?? "the configured apiKeyEnv"}.`);
30883
30907
  }
@@ -33864,7 +33888,7 @@ function providerOptions(config, catalogs = {}) {
33864
33888
  isDefault: model.isDefault
33865
33889
  })) : providerModelProfiles(name, provider);
33866
33890
  const modelProfiles = profiles.map((profile) => {
33867
- const displayName = profile.displayName ?? profile.name ?? profile.model;
33891
+ const displayName = displayModelForProfile(profile);
33868
33892
  return {
33869
33893
  ...profile,
33870
33894
  label: available ? displayName : unavailableLabel(displayName),
@@ -33872,7 +33896,7 @@ function providerOptions(config, catalogs = {}) {
33872
33896
  };
33873
33897
  });
33874
33898
  const models = modelProfiles.length ? [...new Set(modelProfiles.map((item) => item.model).filter((item) => typeof item === "string" && item.trim()))] : providerModelOptions(name, provider);
33875
- const defaultModel = defaultModelForProvider(name, provider);
33899
+ const defaultModel = defaultDisplayModelForProvider(name, provider);
33876
33900
  return {
33877
33901
  name,
33878
33902
  label: available ? name : unavailableLabel(name),
@@ -33935,13 +33959,18 @@ function createInteractiveModelSelection(config, flags = {}, saved) {
33935
33959
  }
33936
33960
  const usesSavedProvider = !flags.provider && savedProviderExists && providerName === savedProviderName;
33937
33961
  const savedModel = usesSavedProvider && saved?.model ? saved.model : void 0;
33938
- const model = flags.model ?? savedModel ?? defaultModelForProvider(providerName, providerConfig);
33962
+ const profiles = providerModelProfiles(providerName, providerConfig);
33963
+ const savedProfile = savedModel ? profiles.find((profile) => profile.model === savedModel || profile.displayName === savedModel || profile.name === savedModel) : void 0;
33964
+ const defaultModel = displayModelForProfile(profiles[0] ?? { name: "", displayName: "", model: "" }) || defaultDisplayModelForProvider(providerName, providerConfig);
33965
+ const flagProfile = flags.model ? profiles.find((profile) => profile.model === flags.model || profile.displayName === flags.model || profile.name === flags.model) : void 0;
33966
+ const selectedProfile = flags.model ? flagProfile : savedModel ? savedProfile : profiles[0];
33967
+ const model = flags.model ?? (savedProfile ? displayModelForProfile(savedProfile) : savedModel) ?? defaultModel;
33939
33968
  return {
33940
33969
  providerName,
33941
33970
  providerSource: flags.provider ? "flag" : usesSavedProvider ? "saved" : "config",
33942
33971
  model,
33943
33972
  modelSource: flags.model ? "flag" : savedModel ? "saved" : "config",
33944
- modelProfileName: providerModelProfiles(providerName, providerConfig).find((profile) => profile.model === model || profile.displayName === model || profile.name === model)?.name
33973
+ modelProfileName: selectedProfile?.name
33945
33974
  };
33946
33975
  }
33947
33976
  function providerCatalogAvailable(catalog) {
@@ -34492,18 +34521,21 @@ function defaultUserConfig(defaultProvider = detectDefaultProvider()) {
34492
34521
  openai: {
34493
34522
  type: "openai-compatible",
34494
34523
  baseURL: "https://api.openai.com/v1",
34524
+ apiKey: "",
34495
34525
  apiKeyEnv: "OPENAI_API_KEY",
34496
34526
  catalog: { type: "openai-models", endpoint: "https://api.openai.com/v1/models" }
34497
34527
  },
34498
34528
  anthropic: {
34499
34529
  type: "anthropic",
34500
34530
  baseURL: "https://api.anthropic.com/v1",
34531
+ apiKey: "",
34501
34532
  apiKeyEnv: "ANTHROPIC_API_KEY",
34502
34533
  catalog: { type: "anthropic-models", endpoint: "https://api.anthropic.com/v1/models" }
34503
34534
  },
34504
34535
  gemini: {
34505
34536
  type: "openai-compatible",
34506
34537
  baseURL: "https://generativelanguage.googleapis.com/v1beta/openai/",
34538
+ apiKey: "",
34507
34539
  apiKeyEnv: "GEMINI_API_KEY",
34508
34540
  apiKeyEnvAliases: ["GOOGLE_API_KEY"],
34509
34541
  catalog: { type: "gemini-openai-models", endpoint: "https://generativelanguage.googleapis.com/v1beta/openai/models" }
@@ -34511,6 +34543,7 @@ function defaultUserConfig(defaultProvider = detectDefaultProvider()) {
34511
34543
  groq: {
34512
34544
  type: "openai-compatible",
34513
34545
  baseURL: "https://api.groq.com/openai/v1",
34546
+ apiKey: "",
34514
34547
  apiKeyEnv: "GROQ_API_KEY",
34515
34548
  catalog: { type: "groq-models", endpoint: "https://api.groq.com/openai/v1/models" }
34516
34549
  },
@@ -34523,6 +34556,7 @@ function defaultUserConfig(defaultProvider = detectDefaultProvider()) {
34523
34556
  displayName: "Azure example",
34524
34557
  model: "azure-deployment-name",
34525
34558
  baseURL: "https://example.openai.azure.com/openai/v1",
34559
+ apiKey: "",
34526
34560
  apiKeyEnv: "AZURE_OPENAI_API_KEY"
34527
34561
  }
34528
34562
  ]
@@ -34531,31 +34565,37 @@ function defaultUserConfig(defaultProvider = detectDefaultProvider()) {
34531
34565
  type: "openai-compatible",
34532
34566
  baseURL: "http://localhost:1234/v1",
34533
34567
  apiKey: "lm-studio",
34568
+ modelProfiles: [],
34534
34569
  catalog: { type: "openai-compatible-models", endpoint: "http://localhost:1234/v1/models" }
34535
34570
  },
34536
34571
  "ollama-local": {
34537
34572
  type: "openai-compatible",
34538
34573
  baseURL: "http://localhost:11434/v1",
34539
34574
  apiKey: "ollama",
34575
+ modelProfiles: [],
34540
34576
  quirks: { omitTemperature: true },
34541
34577
  catalog: { type: "openai-compatible-models", endpoint: "http://localhost:11434/v1/models" }
34542
34578
  },
34543
34579
  "ollama-cloud": {
34544
34580
  type: "ollama",
34545
34581
  baseURL: "https://ollama.com/api",
34582
+ apiKey: "",
34546
34583
  apiKeyEnv: "OLLAMA_API_KEY",
34584
+ modelProfiles: [],
34547
34585
  catalog: { type: "ollama-tags", endpoint: "https://ollama.com/api/tags" }
34548
34586
  },
34549
34587
  llamacpp: {
34550
34588
  type: "openai-compatible",
34551
34589
  baseURL: "http://localhost:8080/v1",
34552
34590
  apiKey: "llama.cpp",
34591
+ modelProfiles: [],
34553
34592
  catalog: { type: "openai-compatible-models", endpoint: "http://localhost:8080/v1/models" }
34554
34593
  },
34555
34594
  vllm: {
34556
34595
  type: "openai-compatible",
34557
34596
  baseURL: "http://localhost:8000/v1",
34558
34597
  apiKey: "vllm",
34598
+ modelProfiles: [],
34559
34599
  catalog: { type: "openai-compatible-models", endpoint: "http://localhost:8000/v1/models" }
34560
34600
  },
34561
34601
  codex: {
@@ -34627,7 +34667,7 @@ async function addModelProfile(options) {
34627
34667
  displayName,
34628
34668
  model: options.model,
34629
34669
  ...options.baseURL ? { baseURL: options.baseURL } : {},
34630
- ...options.apiKey ? { apiKey: options.apiKey } : {},
34670
+ ...options.apiKey !== void 0 || options.apiKeyEnv ? { apiKey: options.apiKey ?? "" } : {},
34631
34671
  ...options.apiKeyEnv ? { apiKeyEnv: options.apiKeyEnv } : {}
34632
34672
  };
34633
34673
  if (existingByName >= 0) profiles[existingByName] = next;
@@ -34649,18 +34689,15 @@ async function readConfigObject(filePath) {
34649
34689
  }
34650
34690
  function providerPreset(options) {
34651
34691
  const preset = options.preset ?? options.name;
34652
- const auth = {
34653
- ...options.apiKey ? { apiKey: options.apiKey } : {},
34654
- ...options.apiKeyEnv ? { apiKeyEnv: options.apiKeyEnv } : {}
34655
- };
34692
+ const auth = apiKeyAuthFields(options);
34656
34693
  const openAIAuth = options.authHeader ? { auth: { type: "api-key", header: options.authHeader } } : {};
34657
- if (preset === "openai") return { type: "openai-compatible", baseURL: options.baseURL ?? "https://api.openai.com/v1", apiKeyEnv: "OPENAI_API_KEY", ...auth, ...openAIAuth, catalog: { type: "openai-models", endpoint: `${(options.baseURL ?? "https://api.openai.com/v1").replace(/\/+$/, "")}/models` } };
34658
- if (preset === "anthropic") return { type: "anthropic", baseURL: options.baseURL ?? "https://api.anthropic.com/v1", apiKeyEnv: "ANTHROPIC_API_KEY", ...auth, catalog: { type: "anthropic-models", endpoint: `${(options.baseURL ?? "https://api.anthropic.com/v1").replace(/\/+$/, "")}/models` } };
34694
+ if (preset === "openai") return { type: "openai-compatible", baseURL: options.baseURL ?? "https://api.openai.com/v1", ...apiKeyAuthFields(options, "OPENAI_API_KEY"), ...openAIAuth, catalog: { type: "openai-models", endpoint: `${(options.baseURL ?? "https://api.openai.com/v1").replace(/\/+$/, "")}/models` } };
34695
+ if (preset === "anthropic") return { type: "anthropic", baseURL: options.baseURL ?? "https://api.anthropic.com/v1", ...apiKeyAuthFields(options, "ANTHROPIC_API_KEY"), catalog: { type: "anthropic-models", endpoint: `${(options.baseURL ?? "https://api.anthropic.com/v1").replace(/\/+$/, "")}/models` } };
34659
34696
  if (preset === "gemini") {
34660
34697
  const geminiBase = options.baseURL ?? "https://generativelanguage.googleapis.com/v1beta/openai/";
34661
- return { type: "openai-compatible", baseURL: geminiBase, apiKeyEnv: "GEMINI_API_KEY", apiKeyEnvAliases: ["GOOGLE_API_KEY"], ...auth, ...openAIAuth, catalog: { type: "gemini-openai-models", endpoint: `${geminiBase.replace(/\/+$/, "")}/models` } };
34698
+ return { type: "openai-compatible", baseURL: geminiBase, ...apiKeyAuthFields(options, "GEMINI_API_KEY"), apiKeyEnvAliases: ["GOOGLE_API_KEY"], ...openAIAuth, catalog: { type: "gemini-openai-models", endpoint: `${geminiBase.replace(/\/+$/, "")}/models` } };
34662
34699
  }
34663
- if (preset === "groq") return { type: "openai-compatible", baseURL: options.baseURL ?? "https://api.groq.com/openai/v1", apiKeyEnv: "GROQ_API_KEY", ...auth, ...openAIAuth, catalog: { type: "groq-models", endpoint: `${(options.baseURL ?? "https://api.groq.com/openai/v1").replace(/\/+$/, "")}/models` } };
34700
+ if (preset === "groq") return { type: "openai-compatible", baseURL: options.baseURL ?? "https://api.groq.com/openai/v1", ...apiKeyAuthFields(options, "GROQ_API_KEY"), ...openAIAuth, catalog: { type: "groq-models", endpoint: `${(options.baseURL ?? "https://api.groq.com/openai/v1").replace(/\/+$/, "")}/models` } };
34664
34701
  if (preset === "azure") {
34665
34702
  return {
34666
34703
  type: "openai-compatible",
@@ -34672,16 +34709,17 @@ function providerPreset(options) {
34672
34709
  displayName: "Azure example",
34673
34710
  model: "azure-deployment-name",
34674
34711
  baseURL: options.baseURL ?? "https://example.openai.azure.com/openai/v1",
34712
+ ...options.apiKey ? {} : { apiKey: "" },
34675
34713
  apiKeyEnv: options.apiKeyEnv ?? "AZURE_OPENAI_API_KEY"
34676
34714
  }
34677
34715
  ]
34678
34716
  };
34679
34717
  }
34680
- if (preset === "lmstudio") return { type: "openai-compatible", baseURL: options.baseURL ?? "http://localhost:1234/v1", apiKey: options.apiKey ?? "lm-studio", catalog: { type: "openai-compatible-models", endpoint: `${(options.baseURL ?? "http://localhost:1234/v1").replace(/\/+$/, "")}/models` } };
34681
- if (preset === "ollama-local" || preset === "ollama") return { type: "openai-compatible", baseURL: options.baseURL ?? "http://localhost:11434/v1", apiKey: options.apiKey ?? "ollama", quirks: { omitTemperature: true }, catalog: { type: "openai-compatible-models", endpoint: `${(options.baseURL ?? "http://localhost:11434/v1").replace(/\/+$/, "")}/models` } };
34682
- if (preset === "ollama-cloud") return { type: "ollama", baseURL: options.baseURL ?? "https://ollama.com/api", ...auth, catalog: { type: "ollama-tags", endpoint: `${(options.baseURL ?? "https://ollama.com/api").replace(/\/+$/, "")}/tags` } };
34683
- if (preset === "llamacpp") return { type: "openai-compatible", baseURL: options.baseURL ?? "http://localhost:8080/v1", apiKey: options.apiKey ?? "llama.cpp", catalog: { type: "openai-compatible-models", endpoint: `${(options.baseURL ?? "http://localhost:8080/v1").replace(/\/+$/, "")}/models` } };
34684
- if (preset === "vllm") return { type: "openai-compatible", baseURL: options.baseURL ?? "http://localhost:8000/v1", apiKey: options.apiKey ?? "vllm", catalog: { type: "openai-compatible-models", endpoint: `${(options.baseURL ?? "http://localhost:8000/v1").replace(/\/+$/, "")}/models` } };
34718
+ if (preset === "lmstudio") return { type: "openai-compatible", baseURL: options.baseURL ?? "http://localhost:1234/v1", apiKey: options.apiKey ?? "lm-studio", modelProfiles: [], catalog: { type: "openai-compatible-models", endpoint: `${(options.baseURL ?? "http://localhost:1234/v1").replace(/\/+$/, "")}/models` } };
34719
+ if (preset === "ollama-local" || preset === "ollama") return { type: "openai-compatible", baseURL: options.baseURL ?? "http://localhost:11434/v1", apiKey: options.apiKey ?? "ollama", modelProfiles: [], quirks: { omitTemperature: true }, catalog: { type: "openai-compatible-models", endpoint: `${(options.baseURL ?? "http://localhost:11434/v1").replace(/\/+$/, "")}/models` } };
34720
+ if (preset === "ollama-cloud") return { type: "ollama", baseURL: options.baseURL ?? "https://ollama.com/api", ...apiKeyAuthFields(options, "OLLAMA_API_KEY"), modelProfiles: [], catalog: { type: "ollama-tags", endpoint: `${(options.baseURL ?? "https://ollama.com/api").replace(/\/+$/, "")}/tags` } };
34721
+ if (preset === "llamacpp") return { type: "openai-compatible", baseURL: options.baseURL ?? "http://localhost:8080/v1", apiKey: options.apiKey ?? "llama.cpp", modelProfiles: [], catalog: { type: "openai-compatible-models", endpoint: `${(options.baseURL ?? "http://localhost:8080/v1").replace(/\/+$/, "")}/models` } };
34722
+ if (preset === "vllm") return { type: "openai-compatible", baseURL: options.baseURL ?? "http://localhost:8000/v1", apiKey: options.apiKey ?? "vllm", modelProfiles: [], catalog: { type: "openai-compatible-models", endpoint: `${(options.baseURL ?? "http://localhost:8000/v1").replace(/\/+$/, "")}/models` } };
34685
34723
  if (preset === "codex") return { type: "codex", baseURL: options.baseURL ?? "https://chatgpt.com/backend-api/codex", authStore: "auto", allowApiKeyFallback: false, promptCacheKey: "root-session", catalog: { type: "codex-oauth-models" } };
34686
34724
  if (preset === "claudecode") return { type: "claudecode", runtime: "agent-sdk", cliPath: "~/.local/bin/claude", cwdMode: "session", historyPolicy: "passthrough-resume", onInvalidResume: "fresh", attachmentFallback: "block", allowSubagents: false, sanitizeApiKeyEnv: true, authPreflight: true, useBareMode: false, usageLedgerScope: "process", sessionLock: true, abortPolicy: "record-only", catalog: { type: "claudecode-supported-models" } };
34687
34725
  if ((options.type ?? preset) === "openai-compatible") {
@@ -34690,14 +34728,20 @@ function providerPreset(options) {
34690
34728
  return {
34691
34729
  type: "openai-compatible",
34692
34730
  baseURL,
34693
- ...options.apiKey ? { apiKey: options.apiKey } : {},
34694
- ...options.apiKeyEnv ? { apiKeyEnv: options.apiKeyEnv } : {},
34731
+ ...auth,
34695
34732
  ...openAIAuth,
34696
34733
  catalog: { type: "openai-compatible-models", endpoint: `${baseURL.replace(/\/+$/, "")}/models` }
34697
34734
  };
34698
34735
  }
34699
34736
  throw new Error(`Unknown provider preset: ${preset}`);
34700
34737
  }
34738
+ function apiKeyAuthFields(options, defaultApiKeyEnv) {
34739
+ const apiKeyEnv = options.apiKeyEnv ?? defaultApiKeyEnv;
34740
+ return {
34741
+ ...options.apiKey !== void 0 || apiKeyEnv ? { apiKey: options.apiKey ?? "" } : {},
34742
+ ...apiKeyEnv ? { apiKeyEnv } : {}
34743
+ };
34744
+ }
34701
34745
  async function writeJsonAtomic(filePath, content) {
34702
34746
  await mkdir(path3.dirname(filePath), { recursive: true, mode: 448 });
34703
34747
  const temp = `${filePath}.${process.pid}.${Date.now()}.tmp`;