claudish 5.19.0 → 6.0.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.
Files changed (2) hide show
  1. package/dist/index.js +407 -422
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -33242,14 +33242,14 @@ var init_openai_tools = __esm(() => {
33242
33242
  init_transform();
33243
33243
  });
33244
33244
 
33245
- // src/adapters/base-adapter.ts
33245
+ // src/adapters/base-api-format.ts
33246
33246
  function matchesModelFamily(modelId, family) {
33247
33247
  const lower = modelId.toLowerCase();
33248
33248
  const fam = family.toLowerCase();
33249
33249
  return lower.startsWith(fam) || lower.includes(`/${fam}`);
33250
33250
  }
33251
33251
 
33252
- class BaseModelAdapter {
33252
+ class BaseAPIFormat {
33253
33253
  modelId;
33254
33254
  toolNameMap = new Map;
33255
33255
  constructor(modelId) {
@@ -33342,12 +33342,12 @@ class BaseModelAdapter {
33342
33342
  }
33343
33343
  }
33344
33344
  }
33345
- var DefaultAdapter;
33346
- var init_base_adapter = __esm(() => {
33345
+ var DefaultAPIFormat;
33346
+ var init_base_api_format = __esm(() => {
33347
33347
  init_tool_name_utils();
33348
33348
  init_remote_provider_types();
33349
33349
  init_openai_tools();
33350
- DefaultAdapter = class DefaultAdapter extends BaseModelAdapter {
33350
+ DefaultAPIFormat = class DefaultAPIFormat extends BaseAPIFormat {
33351
33351
  processTextContent(textContent, accumulatedText) {
33352
33352
  return {
33353
33353
  cleanedText: textContent,
@@ -33359,17 +33359,17 @@ var init_base_adapter = __esm(() => {
33359
33359
  return false;
33360
33360
  }
33361
33361
  getName() {
33362
- return "DefaultAdapter";
33362
+ return "DefaultAPIFormat";
33363
33363
  }
33364
33364
  };
33365
33365
  });
33366
33366
 
33367
- // src/adapters/grok-adapter.ts
33368
- var GrokAdapter;
33369
- var init_grok_adapter = __esm(() => {
33370
- init_base_adapter();
33367
+ // src/adapters/grok-model-dialect.ts
33368
+ var GrokModelDialect;
33369
+ var init_grok_model_dialect = __esm(() => {
33370
+ init_base_api_format();
33371
33371
  init_logger();
33372
- GrokAdapter = class GrokAdapter extends BaseModelAdapter {
33372
+ GrokModelDialect = class GrokModelDialect extends BaseAPIFormat {
33373
33373
  xmlBuffer = "";
33374
33374
  processTextContent(textContent, accumulatedText) {
33375
33375
  this.xmlBuffer += textContent;
@@ -33420,9 +33420,9 @@ var init_grok_adapter = __esm(() => {
33420
33420
  const { budget_tokens } = originalRequest.thinking;
33421
33421
  const effort = budget_tokens >= 20000 ? "high" : "low";
33422
33422
  request.reasoning_effort = effort;
33423
- log(`[GrokAdapter] Mapped budget ${budget_tokens} -> reasoning_effort: ${effort}`);
33423
+ log(`[GrokModelDialect] Mapped budget ${budget_tokens} -> reasoning_effort: ${effort}`);
33424
33424
  } else {
33425
- log(`[GrokAdapter] Model ${modelId} does not support reasoning params. Stripping.`);
33425
+ log(`[GrokModelDialect] Model ${modelId} does not support reasoning params. Stripping.`);
33426
33426
  }
33427
33427
  delete request.thinking;
33428
33428
  }
@@ -33447,7 +33447,7 @@ var init_grok_adapter = __esm(() => {
33447
33447
  return matchesModelFamily(modelId, "grok") || modelId.toLowerCase().includes("x-ai/");
33448
33448
  }
33449
33449
  getName() {
33450
- return "GrokAdapter";
33450
+ return "GrokModelDialect";
33451
33451
  }
33452
33452
  getContextWindow() {
33453
33453
  const model = this.modelId.toLowerCase();
@@ -34459,10 +34459,10 @@ var init_openai_compat = __esm(() => {
34459
34459
  init_openai_sse();
34460
34460
  });
34461
34461
 
34462
- // src/adapters/gemini-adapter.ts
34463
- var REASONING_PATTERNS, REASONING_CONTINUATION_PATTERNS, GeminiAdapter;
34464
- var init_gemini_adapter = __esm(() => {
34465
- init_base_adapter();
34462
+ // src/adapters/gemini-api-format.ts
34463
+ var REASONING_PATTERNS, REASONING_CONTINUATION_PATTERNS, GeminiAPIFormat;
34464
+ var init_gemini_api_format = __esm(() => {
34465
+ init_base_api_format();
34466
34466
  init_gemini_schema();
34467
34467
  init_openai_compat();
34468
34468
  init_logger();
@@ -34504,7 +34504,7 @@ var init_gemini_adapter = __esm(() => {
34504
34504
  /^Lines?\s+\d+/i,
34505
34505
  /^The\s+`[^`]+`\s+(?:is|has|contains|needs|should)/i
34506
34506
  ];
34507
- GeminiAdapter = class GeminiAdapter extends BaseModelAdapter {
34507
+ GeminiAPIFormat = class GeminiAPIFormat extends BaseAPIFormat {
34508
34508
  toolCallMap = new Map;
34509
34509
  inReasoningBlock = false;
34510
34510
  reasoningBlockDepth = 0;
@@ -34544,7 +34544,7 @@ var init_gemini_adapter = __esm(() => {
34544
34544
  } else if (block.type === "tool_result") {
34545
34545
  const toolInfo = this.toolCallMap.get(block.tool_use_id);
34546
34546
  if (!toolInfo) {
34547
- log(`[GeminiAdapter] Warning: No function name found for tool_use_id ${block.tool_use_id}`);
34547
+ log(`[GeminiAPIFormat] Warning: No function name found for tool_use_id ${block.tool_use_id}`);
34548
34548
  continue;
34549
34549
  }
34550
34550
  parts.push({
@@ -34573,7 +34573,7 @@ var init_gemini_adapter = __esm(() => {
34573
34573
  let thoughtSignature = toolInfo?.thoughtSignature;
34574
34574
  if (!thoughtSignature) {
34575
34575
  thoughtSignature = "skip_thought_signature_validator";
34576
- log(`[GeminiAdapter] Using dummy thoughtSignature for tool ${block.name} (${block.id})`);
34576
+ log(`[GeminiAPIFormat] Using dummy thoughtSignature for tool ${block.name} (${block.id})`);
34577
34577
  }
34578
34578
  const functionCallPart = {
34579
34579
  functionCall: {
@@ -34641,7 +34641,7 @@ CRITICAL INSTRUCTION FOR OUTPUT FORMAT:
34641
34641
  registerToolCall(toolId, name, thoughtSignature) {
34642
34642
  this.toolCallMap.set(toolId, { name, thoughtSignature });
34643
34643
  if (thoughtSignature) {
34644
- log(`[GeminiAdapter] Captured thoughtSignature for tool ${name} (${toolId})`);
34644
+ log(`[GeminiAPIFormat] Captured thoughtSignature for tool ${name} (${toolId})`);
34645
34645
  }
34646
34646
  }
34647
34647
  processTextContent(textContent, _accumulatedText) {
@@ -34659,14 +34659,14 @@ CRITICAL INSTRUCTION FOR OUTPUT FORMAT:
34659
34659
  continue;
34660
34660
  }
34661
34661
  if (this.isReasoningLine(trimmed)) {
34662
- log(`[GeminiAdapter] Filtered reasoning: "${trimmed.substring(0, 50)}..."`);
34662
+ log(`[GeminiAPIFormat] Filtered reasoning: "${trimmed.substring(0, 50)}..."`);
34663
34663
  wasFiltered = true;
34664
34664
  this.inReasoningBlock = true;
34665
34665
  this.reasoningBlockDepth++;
34666
34666
  continue;
34667
34667
  }
34668
34668
  if (this.inReasoningBlock && this.isReasoningContinuation(trimmed)) {
34669
- log(`[GeminiAdapter] Filtered reasoning continuation: "${trimmed.substring(0, 50)}..."`);
34669
+ log(`[GeminiAPIFormat] Filtered reasoning continuation: "${trimmed.substring(0, 50)}..."`);
34670
34670
  wasFiltered = true;
34671
34671
  continue;
34672
34672
  }
@@ -34704,7 +34704,7 @@ CRITICAL INSTRUCTION FOR OUTPUT FORMAT:
34704
34704
  return matchesModelFamily(modelId, "gemini") || modelId.toLowerCase().includes("google/");
34705
34705
  }
34706
34706
  getName() {
34707
- return "GeminiAdapter";
34707
+ return "GeminiAPIFormat";
34708
34708
  }
34709
34709
  extractThoughtSignaturesFromReasoningDetails(reasoningDetails) {
34710
34710
  const extracted = new Map;
@@ -34738,11 +34738,11 @@ CRITICAL INSTRUCTION FOR OUTPUT FORMAT:
34738
34738
  };
34739
34739
  });
34740
34740
 
34741
- // src/adapters/codex-adapter.ts
34742
- var CodexAdapter;
34743
- var init_codex_adapter = __esm(() => {
34744
- init_base_adapter();
34745
- CodexAdapter = class CodexAdapter extends BaseModelAdapter {
34741
+ // src/adapters/codex-api-format.ts
34742
+ var CodexAPIFormat;
34743
+ var init_codex_api_format = __esm(() => {
34744
+ init_base_api_format();
34745
+ CodexAPIFormat = class CodexAPIFormat extends BaseAPIFormat {
34746
34746
  constructor(modelId) {
34747
34747
  super(modelId);
34748
34748
  }
@@ -34757,7 +34757,7 @@ var init_codex_adapter = __esm(() => {
34757
34757
  return matchesModelFamily(modelId, "codex");
34758
34758
  }
34759
34759
  getName() {
34760
- return "CodexAdapter";
34760
+ return "CodexAPIFormat";
34761
34761
  }
34762
34762
  getStreamFormat() {
34763
34763
  return "openai-responses-sse";
@@ -34871,12 +34871,12 @@ var init_codex_adapter = __esm(() => {
34871
34871
  };
34872
34872
  });
34873
34873
 
34874
- // src/adapters/openai-adapter.ts
34875
- var OpenAIAdapter;
34876
- var init_openai_adapter = __esm(() => {
34877
- init_base_adapter();
34874
+ // src/adapters/openai-api-format.ts
34875
+ var OpenAIAPIFormat;
34876
+ var init_openai_api_format = __esm(() => {
34877
+ init_base_api_format();
34878
34878
  init_logger();
34879
- OpenAIAdapter = class OpenAIAdapter extends BaseModelAdapter {
34879
+ OpenAIAPIFormat = class OpenAIAPIFormat extends BaseAPIFormat {
34880
34880
  constructor(modelId) {
34881
34881
  super(modelId);
34882
34882
  }
@@ -34902,7 +34902,7 @@ var init_openai_adapter = __esm(() => {
34902
34902
  effort = "high";
34903
34903
  request.reasoning_effort = effort;
34904
34904
  delete request.thinking;
34905
- log(`[OpenAIAdapter] Mapped budget ${budget_tokens} -> reasoning_effort: ${effort}`);
34905
+ log(`[OpenAIAPIFormat] Mapped budget ${budget_tokens} -> reasoning_effort: ${effort}`);
34906
34906
  }
34907
34907
  this.truncateToolNames(request);
34908
34908
  if (request.messages) {
@@ -34914,7 +34914,7 @@ var init_openai_adapter = __esm(() => {
34914
34914
  return modelId.startsWith("oai/") || modelId.includes("o1") || modelId.includes("o3");
34915
34915
  }
34916
34916
  getName() {
34917
- return "OpenAIAdapter";
34917
+ return "OpenAIAPIFormat";
34918
34918
  }
34919
34919
  getContextWindow() {
34920
34920
  const model = this.modelId.toLowerCase();
@@ -34975,17 +34975,17 @@ var init_openai_adapter = __esm(() => {
34975
34975
  else if (budget_tokens >= 32000)
34976
34976
  effort = "high";
34977
34977
  payload.reasoning_effort = effort;
34978
- log(`[OpenAIAdapter] Mapped thinking.budget_tokens ${budget_tokens} -> reasoning_effort: ${effort}`);
34978
+ log(`[OpenAIAPIFormat] Mapped thinking.budget_tokens ${budget_tokens} -> reasoning_effort: ${effort}`);
34979
34979
  }
34980
34980
  return payload;
34981
34981
  }
34982
34982
  };
34983
34983
  });
34984
34984
 
34985
- // src/adapters/qwen-adapter.ts
34986
- var QWEN_SPECIAL_TOKENS, QwenAdapter;
34987
- var init_qwen_adapter = __esm(() => {
34988
- init_base_adapter();
34985
+ // src/adapters/qwen-model-dialect.ts
34986
+ var QWEN_SPECIAL_TOKENS, QwenModelDialect;
34987
+ var init_qwen_model_dialect = __esm(() => {
34988
+ init_base_api_format();
34989
34989
  init_logger();
34990
34990
  QWEN_SPECIAL_TOKENS = [
34991
34991
  "<|im_start|>",
@@ -34995,7 +34995,7 @@ var init_qwen_adapter = __esm(() => {
34995
34995
  `assistant
34996
34996
  `
34997
34997
  ];
34998
- QwenAdapter = class QwenAdapter extends BaseModelAdapter {
34998
+ QwenModelDialect = class QwenModelDialect extends BaseAPIFormat {
34999
34999
  processTextContent(textContent, accumulatedText) {
35000
35000
  let cleanedText = textContent;
35001
35001
  for (const token of QWEN_SPECIAL_TOKENS) {
@@ -35022,7 +35022,7 @@ var init_qwen_adapter = __esm(() => {
35022
35022
  const { budget_tokens } = originalRequest.thinking;
35023
35023
  request.enable_thinking = true;
35024
35024
  request.thinking_budget = budget_tokens;
35025
- log(`[QwenAdapter] Mapped budget ${budget_tokens} -> enable_thinking: true, thinking_budget: ${budget_tokens}`);
35025
+ log(`[QwenModelDialect] Mapped budget ${budget_tokens} -> enable_thinking: true, thinking_budget: ${budget_tokens}`);
35026
35026
  delete request.thinking;
35027
35027
  }
35028
35028
  return request;
@@ -35031,17 +35031,17 @@ var init_qwen_adapter = __esm(() => {
35031
35031
  return matchesModelFamily(modelId, "qwen") || matchesModelFamily(modelId, "alibaba");
35032
35032
  }
35033
35033
  getName() {
35034
- return "QwenAdapter";
35034
+ return "QwenModelDialect";
35035
35035
  }
35036
35036
  };
35037
35037
  });
35038
35038
 
35039
- // src/adapters/minimax-adapter.ts
35040
- var MiniMaxAdapter;
35041
- var init_minimax_adapter = __esm(() => {
35042
- init_base_adapter();
35039
+ // src/adapters/minimax-model-dialect.ts
35040
+ var MiniMaxModelDialect;
35041
+ var init_minimax_model_dialect = __esm(() => {
35042
+ init_base_api_format();
35043
35043
  init_logger();
35044
- MiniMaxAdapter = class MiniMaxAdapter extends BaseModelAdapter {
35044
+ MiniMaxModelDialect = class MiniMaxModelDialect extends BaseAPIFormat {
35045
35045
  processTextContent(textContent, accumulatedText) {
35046
35046
  return {
35047
35047
  cleanedText: textContent,
@@ -35052,7 +35052,7 @@ var init_minimax_adapter = __esm(() => {
35052
35052
  prepareRequest(request, originalRequest) {
35053
35053
  if (originalRequest.thinking) {
35054
35054
  request.reasoning_split = true;
35055
- log(`[MiniMaxAdapter] Enabled reasoning_split: true`);
35055
+ log(`[MiniMaxModelDialect] Enabled reasoning_split: true`);
35056
35056
  delete request.thinking;
35057
35057
  }
35058
35058
  return request;
@@ -35061,17 +35061,17 @@ var init_minimax_adapter = __esm(() => {
35061
35061
  return matchesModelFamily(modelId, "minimax");
35062
35062
  }
35063
35063
  getName() {
35064
- return "MiniMaxAdapter";
35064
+ return "MiniMaxModelDialect";
35065
35065
  }
35066
35066
  };
35067
35067
  });
35068
35068
 
35069
- // src/adapters/deepseek-adapter.ts
35070
- var DeepSeekAdapter;
35071
- var init_deepseek_adapter = __esm(() => {
35072
- init_base_adapter();
35069
+ // src/adapters/deepseek-model-dialect.ts
35070
+ var DeepSeekModelDialect;
35071
+ var init_deepseek_model_dialect = __esm(() => {
35072
+ init_base_api_format();
35073
35073
  init_logger();
35074
- DeepSeekAdapter = class DeepSeekAdapter extends BaseModelAdapter {
35074
+ DeepSeekModelDialect = class DeepSeekModelDialect extends BaseAPIFormat {
35075
35075
  processTextContent(textContent, accumulatedText) {
35076
35076
  return {
35077
35077
  cleanedText: textContent,
@@ -35081,7 +35081,7 @@ var init_deepseek_adapter = __esm(() => {
35081
35081
  }
35082
35082
  prepareRequest(request, originalRequest) {
35083
35083
  if (originalRequest.thinking) {
35084
- log(`[DeepSeekAdapter] Stripping thinking object (not supported by API)`);
35084
+ log(`[DeepSeekModelDialect] Stripping thinking object (not supported by API)`);
35085
35085
  delete request.thinking;
35086
35086
  }
35087
35087
  return request;
@@ -35090,15 +35090,15 @@ var init_deepseek_adapter = __esm(() => {
35090
35090
  return matchesModelFamily(modelId, "deepseek");
35091
35091
  }
35092
35092
  getName() {
35093
- return "DeepSeekAdapter";
35093
+ return "DeepSeekModelDialect";
35094
35094
  }
35095
35095
  };
35096
35096
  });
35097
35097
 
35098
- // src/adapters/glm-adapter.ts
35099
- var GLM_CONTEXT_WINDOWS, GLM_VISION_MODELS, GLMAdapter;
35100
- var init_glm_adapter = __esm(() => {
35101
- init_base_adapter();
35098
+ // src/adapters/glm-model-dialect.ts
35099
+ var GLM_CONTEXT_WINDOWS, GLM_VISION_MODELS, GLMModelDialect;
35100
+ var init_glm_model_dialect = __esm(() => {
35101
+ init_base_api_format();
35102
35102
  init_logger();
35103
35103
  GLM_CONTEXT_WINDOWS = [
35104
35104
  ["glm-5-turbo", 202752],
@@ -35120,7 +35120,7 @@ var init_glm_adapter = __esm(() => {
35120
35120
  ["glm-", 131072]
35121
35121
  ];
35122
35122
  GLM_VISION_MODELS = ["glm-4v", "glm-4v-plus", "glm-4.5v", "glm-4.6v", "glm-5"];
35123
- GLMAdapter = class GLMAdapter extends BaseModelAdapter {
35123
+ GLMModelDialect = class GLMModelDialect extends BaseAPIFormat {
35124
35124
  processTextContent(textContent, accumulatedText) {
35125
35125
  return {
35126
35126
  cleanedText: textContent,
@@ -35130,7 +35130,7 @@ var init_glm_adapter = __esm(() => {
35130
35130
  }
35131
35131
  prepareRequest(request, originalRequest) {
35132
35132
  if (originalRequest.thinking) {
35133
- log(`[GLMAdapter] Stripping thinking object (not supported by GLM API)`);
35133
+ log(`[GLMModelDialect] Stripping thinking object (not supported by GLM API)`);
35134
35134
  delete request.thinking;
35135
35135
  }
35136
35136
  return request;
@@ -35139,7 +35139,7 @@ var init_glm_adapter = __esm(() => {
35139
35139
  return matchesModelFamily(modelId, "glm-") || matchesModelFamily(modelId, "chatglm-") || modelId.toLowerCase().includes("zhipu/");
35140
35140
  }
35141
35141
  getName() {
35142
- return "GLMAdapter";
35142
+ return "GLMModelDialect";
35143
35143
  }
35144
35144
  getContextWindow() {
35145
35145
  const lower = this.modelId.toLowerCase();
@@ -35156,12 +35156,12 @@ var init_glm_adapter = __esm(() => {
35156
35156
  };
35157
35157
  });
35158
35158
 
35159
- // src/adapters/xiaomi-adapter.ts
35160
- var XiaomiAdapter;
35161
- var init_xiaomi_adapter = __esm(() => {
35162
- init_base_adapter();
35159
+ // src/adapters/xiaomi-model-dialect.ts
35160
+ var XiaomiModelDialect;
35161
+ var init_xiaomi_model_dialect = __esm(() => {
35162
+ init_base_api_format();
35163
35163
  init_logger();
35164
- XiaomiAdapter = class XiaomiAdapter extends BaseModelAdapter {
35164
+ XiaomiModelDialect = class XiaomiModelDialect extends BaseAPIFormat {
35165
35165
  processTextContent(textContent, accumulatedText) {
35166
35166
  return {
35167
35167
  cleanedText: textContent,
@@ -35174,7 +35174,7 @@ var init_xiaomi_adapter = __esm(() => {
35174
35174
  }
35175
35175
  prepareRequest(request, originalRequest) {
35176
35176
  if (originalRequest.thinking) {
35177
- log(`[XiaomiAdapter] Stripping thinking object (not supported by Xiaomi API)`);
35177
+ log(`[XiaomiModelDialect] Stripping thinking object (not supported by Xiaomi API)`);
35178
35178
  delete request.thinking;
35179
35179
  }
35180
35180
  this.truncateToolNames(request);
@@ -35187,33 +35187,34 @@ var init_xiaomi_adapter = __esm(() => {
35187
35187
  return matchesModelFamily(modelId, "xiaomi") || matchesModelFamily(modelId, "mimo");
35188
35188
  }
35189
35189
  getName() {
35190
- return "XiaomiAdapter";
35190
+ return "XiaomiModelDialect";
35191
35191
  }
35192
35192
  };
35193
35193
  });
35194
35194
 
35195
- // src/adapters/adapter-manager.ts
35196
- var exports_adapter_manager = {};
35197
- __export(exports_adapter_manager, {
35198
- AdapterManager: () => AdapterManager
35195
+ // src/adapters/dialect-manager.ts
35196
+ var exports_dialect_manager = {};
35197
+ __export(exports_dialect_manager, {
35198
+ DialectManager: () => DialectManager,
35199
+ AdapterManager: () => DialectManager
35199
35200
  });
35200
35201
 
35201
- class AdapterManager {
35202
+ class DialectManager {
35202
35203
  adapters;
35203
35204
  defaultAdapter;
35204
35205
  constructor(modelId) {
35205
35206
  this.adapters = [
35206
- new GrokAdapter(modelId),
35207
- new GeminiAdapter(modelId),
35208
- new CodexAdapter(modelId),
35209
- new OpenAIAdapter(modelId),
35210
- new QwenAdapter(modelId),
35211
- new MiniMaxAdapter(modelId),
35212
- new DeepSeekAdapter(modelId),
35213
- new GLMAdapter(modelId),
35214
- new XiaomiAdapter(modelId)
35207
+ new GrokModelDialect(modelId),
35208
+ new GeminiAPIFormat(modelId),
35209
+ new CodexAPIFormat(modelId),
35210
+ new OpenAIAPIFormat(modelId),
35211
+ new QwenModelDialect(modelId),
35212
+ new MiniMaxModelDialect(modelId),
35213
+ new DeepSeekModelDialect(modelId),
35214
+ new GLMModelDialect(modelId),
35215
+ new XiaomiModelDialect(modelId)
35215
35216
  ];
35216
- this.defaultAdapter = new DefaultAdapter(modelId);
35217
+ this.defaultAdapter = new DefaultAPIFormat(modelId);
35217
35218
  }
35218
35219
  getAdapter() {
35219
35220
  for (const adapter of this.adapters) {
@@ -35227,17 +35228,17 @@ class AdapterManager {
35227
35228
  return this.getAdapter() !== this.defaultAdapter;
35228
35229
  }
35229
35230
  }
35230
- var init_adapter_manager = __esm(() => {
35231
- init_base_adapter();
35232
- init_grok_adapter();
35233
- init_gemini_adapter();
35234
- init_codex_adapter();
35235
- init_openai_adapter();
35236
- init_qwen_adapter();
35237
- init_minimax_adapter();
35238
- init_deepseek_adapter();
35239
- init_glm_adapter();
35240
- init_xiaomi_adapter();
35231
+ var init_dialect_manager = __esm(() => {
35232
+ init_base_api_format();
35233
+ init_grok_model_dialect();
35234
+ init_gemini_api_format();
35235
+ init_codex_api_format();
35236
+ init_openai_api_format();
35237
+ init_qwen_model_dialect();
35238
+ init_minimax_model_dialect();
35239
+ init_deepseek_model_dialect();
35240
+ init_glm_model_dialect();
35241
+ init_xiaomi_model_dialect();
35241
35242
  });
35242
35243
 
35243
35244
  // src/cli.ts
@@ -36186,31 +36187,31 @@ async function probeModelRouting(models, jsonOutput) {
36186
36187
  const { resolveRemoteProvider: resolveRemoteProvider2 } = await Promise.resolve().then(() => (init_remote_provider_registry(), exports_remote_provider_registry));
36187
36188
  const resolvedSpec = resolveRemoteProvider2(firstReadyRoute.modelSpec);
36188
36189
  const modelName = resolvedSpec?.modelName || parsed.model;
36189
- let formatAdapterName = "OpenAIAdapter";
36190
+ let formatAdapterName = "OpenAIAPIFormat";
36190
36191
  let declaredStreamFormat = "openai-sse";
36191
36192
  const anthropicCompatProviders = ["minimax", "minimax-coding", "kimi", "kimi-coding", "zai"];
36192
36193
  const isMinimaxModel = modelName.toLowerCase().includes("minimax");
36193
36194
  if (anthropicCompatProviders.includes(providerName)) {
36194
- formatAdapterName = "AnthropicPassthroughAdapter";
36195
+ formatAdapterName = "AnthropicAPIFormat";
36195
36196
  declaredStreamFormat = "anthropic-sse";
36196
36197
  } else if ((providerName === "opencode-zen" || providerName === "opencode-zen-go") && isMinimaxModel) {
36197
- formatAdapterName = "AnthropicPassthroughAdapter";
36198
+ formatAdapterName = "AnthropicAPIFormat";
36198
36199
  declaredStreamFormat = "anthropic-sse";
36199
36200
  } else if (providerName === "gemini" || providerName === "gemini-codeassist") {
36200
- formatAdapterName = "GeminiAdapter";
36201
+ formatAdapterName = "GeminiAPIFormat";
36201
36202
  declaredStreamFormat = "gemini-sse";
36202
36203
  } else if (providerName === "ollamacloud") {
36203
- formatAdapterName = "OllamaCloudAdapter";
36204
+ formatAdapterName = "OllamaAPIFormat";
36204
36205
  declaredStreamFormat = "openai-sse";
36205
36206
  } else if (providerName === "litellm") {
36206
- formatAdapterName = "LiteLLMAdapter";
36207
+ formatAdapterName = "LiteLLMAPIFormat";
36207
36208
  declaredStreamFormat = "openai-sse";
36208
36209
  } else {
36209
- formatAdapterName = "OpenAIAdapter";
36210
+ formatAdapterName = "OpenAIAPIFormat";
36210
36211
  declaredStreamFormat = "openai-sse";
36211
36212
  }
36212
- const { AdapterManager: AdapterManager2 } = await Promise.resolve().then(() => (init_adapter_manager(), exports_adapter_manager));
36213
- const adapterManager = new AdapterManager2(modelName);
36213
+ const { DialectManager: DialectManager2 } = await Promise.resolve().then(() => (init_dialect_manager(), exports_dialect_manager));
36214
+ const adapterManager = new DialectManager2(modelName);
36214
36215
  const modelTranslator = adapterManager.getAdapter();
36215
36216
  const modelTranslatorName = modelTranslator.getName();
36216
36217
  const TRANSPORT_OVERRIDES = {
@@ -36218,7 +36219,7 @@ async function probeModelRouting(models, jsonOutput) {
36218
36219
  openrouter: "openai-sse"
36219
36220
  };
36220
36221
  const transportOverride = TRANSPORT_OVERRIDES[providerName] || null;
36221
- const modelTranslatorFormat = modelTranslatorName !== "DefaultAdapter" ? modelTranslator.getStreamFormat() : null;
36222
+ const modelTranslatorFormat = modelTranslatorName !== "DefaultAPIFormat" ? modelTranslator.getStreamFormat() : null;
36222
36223
  const effectiveStreamFormat = transportOverride || modelTranslatorFormat || declaredStreamFormat;
36223
36224
  wiring = {
36224
36225
  formatAdapter: formatAdapterName,
@@ -36890,7 +36891,7 @@ async function fetchGLMCodingModels() {
36890
36891
  return [];
36891
36892
  }
36892
36893
  }
36893
- var __filename4, __dirname4, VERSION = "5.19.0", CACHE_MAX_AGE_DAYS2 = 2, CLAUDISH_CACHE_DIR2, BUNDLED_MODELS_PATH, CACHED_MODELS_PATH, ALL_MODELS_JSON_PATH;
36894
+ var __filename4, __dirname4, VERSION = "6.0.0", CACHE_MAX_AGE_DAYS2 = 2, CLAUDISH_CACHE_DIR2, BUNDLED_MODELS_PATH, CACHED_MODELS_PATH, ALL_MODELS_JSON_PATH;
36894
36895
  var init_cli = __esm(() => {
36895
36896
  init_config();
36896
36897
  init_model_loader();
@@ -41951,7 +41952,7 @@ function recordStats(partial2) {
41951
41952
  estimated_cost: partial2.estimated_cost ?? 0,
41952
41953
  is_free_model: partial2.is_free_model ?? false,
41953
41954
  token_strategy: partial2.token_strategy ?? "standard",
41954
- adapter_name: partial2.adapter_name ?? "DefaultAdapter",
41955
+ adapter_name: partial2.adapter_name ?? "DefaultAPIFormat",
41955
41956
  middleware_names: partial2.middleware_names ?? [],
41956
41957
  fallback_used: partial2.fallback_used ?? false,
41957
41958
  invocation_mode: partial2.invocation_mode ?? "auto-route",
@@ -98491,10 +98492,10 @@ function App() {
98491
98492
  const isInputMode = mode === "input_key" || mode === "input_endpoint";
98492
98493
  const isRoutingInput = mode === "add_routing_pattern" || mode === "add_routing_chain";
98493
98494
  const HEADER_H = 1;
98494
- const TABS_H = 2;
98495
+ const TABS_H = 3;
98495
98496
  const FOOTER_H = 1;
98496
98497
  const DETAIL_H = 5;
98497
- const contentH = Math.max(4, height2 - HEADER_H - TABS_H - DETAIL_H - FOOTER_H);
98498
+ const contentH = Math.max(4, height2 - HEADER_H - TABS_H - DETAIL_H - FOOTER_H - 1);
98498
98499
  function TabBar() {
98499
98500
  const tabs = [
98500
98501
  { label: "Providers", value: "providers", num: "1" },
@@ -98509,43 +98510,56 @@ function App() {
98509
98510
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
98510
98511
  height: 1,
98511
98512
  flexDirection: "row",
98512
- paddingX: 1,
98513
98513
  children: [
98514
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
98515
+ width: 1,
98516
+ height: 1,
98517
+ backgroundColor: C2.bg
98518
+ }, undefined, false, undefined, this),
98514
98519
  tabs.map((t2, i) => {
98515
98520
  const active = activeTab === t2.value;
98516
- return /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("text", {
98521
+ return /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
98522
+ flexDirection: "row",
98523
+ height: 1,
98517
98524
  children: [
98518
- i > 0 && /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98519
- fg: C2.bg,
98520
- children: " "
98525
+ i > 0 && /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
98526
+ width: 2,
98527
+ height: 1,
98528
+ backgroundColor: C2.bg
98521
98529
  }, undefined, false, undefined, this),
98522
- active ? /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98523
- fg: C2.tabActiveFg,
98524
- backgroundColor: C2.tabActiveBg,
98525
- bold: true,
98526
- children: ` ${t2.num}. ${t2.label} `
98527
- }, undefined, false, undefined, this) : /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98528
- fg: C2.tabInactiveFg,
98529
- backgroundColor: C2.tabInactiveBg,
98530
- bold: true,
98531
- children: ` ${t2.num}. ${t2.label} `
98530
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
98531
+ height: 1,
98532
+ backgroundColor: active ? C2.tabActiveBg : C2.tabInactiveBg,
98533
+ paddingX: 1,
98534
+ children: /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("text", {
98535
+ children: /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98536
+ fg: active ? C2.tabActiveFg : C2.tabInactiveFg,
98537
+ bold: true,
98538
+ children: `${t2.num}. ${t2.label}`
98539
+ }, undefined, false, undefined, this)
98540
+ }, undefined, false, undefined, this)
98532
98541
  }, undefined, false, undefined, this)
98533
98542
  ]
98534
98543
  }, t2.value, true, undefined, this);
98535
98544
  }),
98536
- statusMsg && /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("text", {
98537
- children: [
98538
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98539
- fg: C2.dim,
98540
- children: " \u2500 "
98541
- }, undefined, false, undefined, this),
98542
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98543
- fg: statusMsg.startsWith("Key saved") || statusMsg.startsWith("Rule added") || statusMsg.startsWith("Endpoint") || statusMsg.startsWith("Telemetry") || statusMsg.startsWith("Usage") || statusMsg.startsWith("Stats buffer") ? C2.green : C2.yellow,
98544
- bold: true,
98545
- children: statusMsg
98546
- }, undefined, false, undefined, this)
98547
- ]
98548
- }, undefined, true, undefined, this)
98545
+ statusMsg && /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
98546
+ height: 1,
98547
+ backgroundColor: C2.bg,
98548
+ paddingX: 1,
98549
+ children: /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("text", {
98550
+ children: [
98551
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98552
+ fg: C2.dim,
98553
+ children: "\u2500 "
98554
+ }, undefined, false, undefined, this),
98555
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98556
+ fg: statusMsg.startsWith("Key saved") || statusMsg.startsWith("Rule added") || statusMsg.startsWith("Endpoint") || statusMsg.startsWith("Telemetry") || statusMsg.startsWith("Usage") || statusMsg.startsWith("Stats buffer") ? C2.green : C2.yellow,
98557
+ bold: true,
98558
+ children: statusMsg
98559
+ }, undefined, false, undefined, this)
98560
+ ]
98561
+ }, undefined, true, undefined, this)
98562
+ }, undefined, false, undefined, this)
98549
98563
  ]
98550
98564
  }, undefined, true, undefined, this),
98551
98565
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
@@ -98570,7 +98584,12 @@ function App() {
98570
98584
  const getRow = (p, idx) => {
98571
98585
  const isReady = !!(config3.apiKeys?.[p.apiKeyEnvVar] || process.env[p.apiKeyEnvVar]);
98572
98586
  const selected = idx === providerIndex;
98573
- const keyDisplay = isReady ? maskKey2(config3.apiKeys?.[p.apiKeyEnvVar]) || maskKey2(process.env[p.apiKeyEnvVar]) : "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500";
98587
+ const cfgMask = maskKey2(config3.apiKeys?.[p.apiKeyEnvVar]);
98588
+ const envMask = maskKey2(process.env[p.apiKeyEnvVar]);
98589
+ const hasCfg = cfgMask !== "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500";
98590
+ const hasEnv = envMask !== "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500";
98591
+ const keyDisplay = isReady ? hasCfg ? cfgMask : envMask : "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500";
98592
+ const src = hasEnv && hasCfg ? "e+c" : hasEnv ? "env" : hasCfg ? "cfg" : "";
98574
98593
  const namePad = p.displayName.padEnd(14).substring(0, 14);
98575
98594
  const isFirstUnready = !isReady && !separatorRendered;
98576
98595
  if (isFirstUnready)
@@ -98614,22 +98633,25 @@ function App() {
98614
98633
  children: " "
98615
98634
  }, undefined, false, undefined, this),
98616
98635
  isReady ? /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98617
- fg: C2.black,
98618
- backgroundColor: C2.brightGreen,
98636
+ fg: C2.green,
98619
98637
  bold: true,
98620
- children: " ready "
98638
+ children: "ready "
98621
98639
  }, undefined, false, undefined, this) : /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98622
98640
  fg: C2.dim,
98623
- children: " not set "
98641
+ children: "not set"
98624
98642
  }, undefined, false, undefined, this),
98625
98643
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98626
98644
  fg: C2.dim,
98627
98645
  children: " "
98628
98646
  }, undefined, false, undefined, this),
98629
98647
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98630
- fg: isReady ? C2.green : C2.dim,
98648
+ fg: isReady ? C2.cyan : C2.dim,
98631
98649
  children: keyDisplay
98632
98650
  }, undefined, false, undefined, this),
98651
+ src ? /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98652
+ fg: C2.dim,
98653
+ children: ` (${src})`
98654
+ }, undefined, false, undefined, this) : null,
98633
98655
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98634
98656
  fg: C2.dim,
98635
98657
  children: " "
@@ -98807,54 +98829,38 @@ function App() {
98807
98829
  }, undefined, false, undefined, this)
98808
98830
  ]
98809
98831
  }, undefined, true, undefined, this),
98810
- selectedProvider.keyUrl && /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("text", {
98832
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("text", {
98811
98833
  children: [
98812
98834
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98813
98835
  fg: C2.blue,
98814
98836
  bold: true,
98815
- children: "Get Key: "
98837
+ children: "Desc: "
98816
98838
  }, undefined, false, undefined, this),
98817
98839
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98818
- fg: C2.cyan,
98819
- children: selectedProvider.keyUrl
98840
+ fg: C2.white,
98841
+ children: selectedProvider.description
98820
98842
  }, undefined, false, undefined, this)
98821
98843
  ]
98822
- }, undefined, true, undefined, this)
98823
- ]
98824
- }, undefined, true, undefined, this);
98825
- }
98826
- function RoutingChain({ chain, description }) {
98827
- return /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("text", {
98828
- children: [
98829
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98830
- fg: C2.dim,
98831
- children: " "
98832
- }, undefined, false, undefined, this),
98833
- chain.map((p, i) => /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98844
+ }, undefined, true, undefined, this),
98845
+ selectedProvider.keyUrl && /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("text", {
98834
98846
  children: [
98835
98847
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98836
- fg: C2.black,
98837
- backgroundColor: C2.cyan,
98848
+ fg: C2.blue,
98838
98849
  bold: true,
98839
- children: ` ${p} `
98850
+ children: "Get Key: "
98840
98851
  }, undefined, false, undefined, this),
98841
- i < chain.length - 1 && /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98842
- fg: C2.dim,
98843
- children: " \u2192 "
98852
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98853
+ fg: C2.cyan,
98854
+ children: selectedProvider.keyUrl
98844
98855
  }, undefined, false, undefined, this)
98845
98856
  ]
98846
- }, p, true, undefined, this)),
98847
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98848
- fg: C2.dim,
98849
- children: " \u2014 "
98850
- }, undefined, false, undefined, this),
98851
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98852
- fg: C2.fgMuted,
98853
- children: description
98854
- }, undefined, false, undefined, this)
98857
+ }, undefined, true, undefined, this)
98855
98858
  ]
98856
98859
  }, undefined, true, undefined, this);
98857
98860
  }
98861
+ function chainStr(chain) {
98862
+ return chain.join(" \u2192 ");
98863
+ }
98858
98864
  function RoutingContent() {
98859
98865
  const innerH = contentH - 2;
98860
98866
  return /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
@@ -98866,79 +98872,46 @@ function App() {
98866
98872
  flexDirection: "column",
98867
98873
  paddingX: 1,
98868
98874
  children: [
98869
- ruleEntries.length === 0 && !isRoutingInput && /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(import_jsx_dev_runtime2.Fragment, {
98875
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("text", {
98870
98876
  children: [
98871
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("text", {
98872
- children: [
98873
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98874
- fg: C2.fgMuted,
98875
- children: "No custom rules. Press "
98876
- }, undefined, false, undefined, this),
98877
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98878
- fg: C2.black,
98879
- backgroundColor: C2.green,
98880
- bold: true,
98881
- children: " a "
98882
- }, undefined, false, undefined, this),
98883
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98884
- fg: C2.fgMuted,
98885
- children: " to add one. Default: LiteLLM \u2192 Zen \u2192 Native \u2192 OpenRouter"
98886
- }, undefined, false, undefined, this)
98887
- ]
98888
- }, undefined, true, undefined, this),
98889
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("text", {
98890
- children: " "
98891
- }, undefined, false, undefined, this),
98892
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("text", {
98893
- children: /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98894
- fg: C2.blue,
98895
- bold: true,
98896
- children: "Examples"
98897
- }, undefined, false, undefined, this)
98898
- }, undefined, false, undefined, this),
98899
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("text", {
98900
- children: /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98901
- fg: C2.white,
98902
- bold: true,
98903
- children: " kimi-*"
98904
- }, undefined, false, undefined, this)
98905
- }, undefined, false, undefined, this),
98906
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(RoutingChain, {
98907
- chain: ["kimi", "openrouter"],
98908
- description: "Try Kimi first, fall back to OpenRouter"
98909
- }, undefined, false, undefined, this),
98910
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("text", {
98911
- children: /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98912
- fg: C2.white,
98913
- bold: true,
98914
- children: " gpt-*"
98915
- }, undefined, false, undefined, this)
98916
- }, undefined, false, undefined, this),
98917
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(RoutingChain, {
98918
- chain: ["oai", "litellm"],
98919
- description: "Use OpenAI direct, then LiteLLM proxy"
98877
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98878
+ fg: C2.dim,
98879
+ children: " * "
98920
98880
  }, undefined, false, undefined, this),
98921
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("text", {
98922
- children: /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98923
- fg: C2.white,
98924
- bold: true,
98925
- children: " gemini-*"
98926
- }, undefined, false, undefined, this)
98881
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98882
+ fg: C2.fgMuted,
98883
+ children: "LiteLLM \u2192 Zen Go \u2192 Subscription \u2192 Provider Direct \u2192 OpenRouter"
98927
98884
  }, undefined, false, undefined, this),
98928
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(RoutingChain, {
98929
- chain: ["google", "zen", "openrouter"],
98930
- description: "Gemini direct \u2192 Zen free tier \u2192 OpenRouter"
98885
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98886
+ fg: C2.dim,
98887
+ children: " (built-in)"
98888
+ }, undefined, false, undefined, this)
98889
+ ]
98890
+ }, undefined, true, undefined, this),
98891
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("text", {
98892
+ children: " "
98893
+ }, undefined, false, undefined, this),
98894
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("text", {
98895
+ children: /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98896
+ fg: C2.blue,
98897
+ bold: true,
98898
+ children: " PATTERN CHAIN"
98899
+ }, undefined, false, undefined, this)
98900
+ }, undefined, false, undefined, this),
98901
+ ruleEntries.length === 0 && !isRoutingInput && /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("text", {
98902
+ children: [
98903
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98904
+ fg: C2.fgMuted,
98905
+ children: " No custom rules. Press "
98931
98906
  }, undefined, false, undefined, this),
98932
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("text", {
98933
- children: /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98934
- fg: C2.white,
98935
- bold: true,
98936
- children: " *"
98937
- }, undefined, false, undefined, this)
98907
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98908
+ fg: C2.green,
98909
+ bold: true,
98910
+ children: "a"
98938
98911
  }, undefined, false, undefined, this),
98939
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(RoutingChain, {
98940
- chain: ["zen", "openrouter"],
98941
- description: "Catch-all: try free Zen first"
98912
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98913
+ fg: C2.fgMuted,
98914
+ children: " to add one."
98942
98915
  }, undefined, false, undefined, this)
98943
98916
  ]
98944
98917
  }, undefined, true, undefined, this),
@@ -98973,20 +98946,12 @@ function App() {
98973
98946
  }, undefined, false, undefined, this),
98974
98947
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98975
98948
  fg: C2.dim,
98976
- children: " \u2192 "
98949
+ children: " "
98977
98950
  }, undefined, false, undefined, this),
98978
- chain.map((p, i) => /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98979
- children: [
98980
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98981
- fg: sel ? C2.cyan : C2.dim,
98982
- children: p
98983
- }, undefined, false, undefined, this),
98984
- i < chain.length - 1 && /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98985
- fg: C2.dim,
98986
- children: " \u2192 "
98987
- }, undefined, false, undefined, this)
98988
- ]
98989
- }, p, true, undefined, this))
98951
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
98952
+ fg: sel ? C2.cyan : C2.fgMuted,
98953
+ children: chainStr(chain)
98954
+ }, undefined, false, undefined, this)
98990
98955
  ]
98991
98956
  }, undefined, true, undefined, this)
98992
98957
  }, pat, false, undefined, this);
@@ -99127,51 +99092,79 @@ function App() {
99127
99092
  border: true,
99128
99093
  borderStyle: "single",
99129
99094
  borderColor: C2.dim,
99130
- title: " How Routing Works ",
99095
+ title: " Examples ",
99131
99096
  backgroundColor: C2.bgAlt,
99132
99097
  flexDirection: "column",
99133
99098
  paddingX: 1,
99134
99099
  children: [
99135
99100
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("text", {
99136
99101
  children: [
99102
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
99103
+ fg: C2.dim,
99104
+ children: "kimi-* "
99105
+ }, undefined, false, undefined, this),
99137
99106
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
99138
99107
  fg: C2.fgMuted,
99139
- children: "Claudish matches model names against "
99108
+ children: "kimi \u2192 or"
99140
99109
  }, undefined, false, undefined, this),
99141
99110
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
99142
- fg: C2.blue,
99143
- bold: true,
99144
- children: "Patterns"
99111
+ fg: C2.dim,
99112
+ children: " "
99113
+ }, undefined, false, undefined, this),
99114
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
99115
+ fg: C2.dim,
99116
+ children: "gpt-* "
99145
99117
  }, undefined, false, undefined, this),
99146
99118
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
99147
99119
  fg: C2.fgMuted,
99148
- children: " (like "
99120
+ children: "oai \u2192 litellm"
99149
99121
  }, undefined, false, undefined, this),
99150
99122
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
99151
- fg: C2.white,
99152
- children: "gpt-*"
99123
+ fg: C2.dim,
99124
+ children: " "
99125
+ }, undefined, false, undefined, this),
99126
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
99127
+ fg: C2.dim,
99128
+ children: "gemini-* "
99153
99129
  }, undefined, false, undefined, this),
99154
99130
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
99155
99131
  fg: C2.fgMuted,
99156
- children: ") and tries providers in the "
99132
+ children: "google \u2192 zen \u2192 or"
99133
+ }, undefined, false, undefined, this)
99134
+ ]
99135
+ }, undefined, true, undefined, this),
99136
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("text", {
99137
+ children: [
99138
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
99139
+ fg: C2.dim,
99140
+ children: "glm-* "
99157
99141
  }, undefined, false, undefined, this),
99158
99142
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
99159
- fg: C2.blue,
99160
- bold: true,
99161
- children: "Chain"
99143
+ fg: C2.fgMuted,
99144
+ children: "glm \u2192 zen \u2192 or"
99145
+ }, undefined, false, undefined, this),
99146
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
99147
+ fg: C2.dim,
99148
+ children: " "
99149
+ }, undefined, false, undefined, this),
99150
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
99151
+ fg: C2.dim,
99152
+ children: "deepseek-* "
99162
99153
  }, undefined, false, undefined, this),
99163
99154
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
99164
99155
  fg: C2.fgMuted,
99165
- children: " in order."
99156
+ children: "zen \u2192 or"
99157
+ }, undefined, false, undefined, this),
99158
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
99159
+ fg: C2.dim,
99160
+ children: " "
99161
+ }, undefined, false, undefined, this),
99162
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
99163
+ fg: C2.dim,
99164
+ children: "Pattern: glob (* = any)"
99166
99165
  }, undefined, false, undefined, this)
99167
99166
  ]
99168
99167
  }, undefined, true, undefined, this),
99169
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("text", {
99170
- children: /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
99171
- fg: C2.fgMuted,
99172
- children: "The first provider that responds successfully is used."
99173
- }, undefined, false, undefined, this)
99174
- }, undefined, false, undefined, this),
99175
99168
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("text", {
99176
99169
  children: [
99177
99170
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
@@ -99181,7 +99174,7 @@ function App() {
99181
99174
  }, undefined, false, undefined, this),
99182
99175
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
99183
99176
  fg: C2.fgMuted,
99184
- children: ` rule${ruleEntries.length !== 1 ? "s" : ""} configured`
99177
+ children: ` custom rule${ruleEntries.length !== 1 ? "s" : ""}`
99185
99178
  }, undefined, false, undefined, this)
99186
99179
  ]
99187
99180
  }, undefined, true, undefined, this)
@@ -99438,18 +99431,21 @@ function App() {
99438
99431
  children: keys.map(([color, key, label], i) => /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
99439
99432
  children: [
99440
99433
  i > 0 && /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
99441
- children: " "
99434
+ fg: C2.dim,
99435
+ children: " \u2502 "
99442
99436
  }, undefined, false, undefined, this),
99443
99437
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
99444
- fg: C2.black,
99445
- backgroundColor: color,
99438
+ fg: color,
99446
99439
  bold: true,
99447
- children: ` ${key} `
99440
+ children: key
99448
99441
  }, undefined, false, undefined, this),
99449
99442
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
99450
- fg: C2.white,
99451
- children: ` ${label}`
99452
- }, undefined, false, undefined, this)
99443
+ fg: C2.fgMuted,
99444
+ children: [
99445
+ " ",
99446
+ label
99447
+ ]
99448
+ }, undefined, true, undefined, this)
99453
99449
  ]
99454
99450
  }, i, true, undefined, this))
99455
99451
  }, undefined, false, undefined, this)
@@ -100147,7 +100143,7 @@ class OpentUiDiagOutput {
100147
100143
  if (this.messages.length > 4) {
100148
100144
  this.messages = this.messages.slice(-4);
100149
100145
  }
100150
- this.runner.showDiag(this.messages);
100146
+ this.runner.showDiag(this.messages).catch(() => {});
100151
100147
  }
100152
100148
  cleanup() {
100153
100149
  this.runner.hideDiag();
@@ -100295,17 +100291,8 @@ class PtyDiagRunner {
100295
100291
  autoHideTimer = null;
100296
100292
  reactRoot = null;
100297
100293
  rawStdinHandler = null;
100294
+ rendererInitializing = false;
100298
100295
  async run(command, args, env2) {
100299
- this.renderer = await createCliRenderer({
100300
- useAlternateScreen: false,
100301
- experimental_splitHeight: 0,
100302
- exitOnCtrlC: false,
100303
- useMouse: false,
100304
- useKittyKeyboard: null,
100305
- targetFps: 10
100306
- });
100307
- this.reactRoot = createRoot(this.renderer);
100308
- this.renderDiagPanel();
100309
100296
  const cols = process.stdout.columns || 80;
100310
100297
  const rows = process.stdout.rows || 24;
100311
100298
  this.bunProc = Bun.spawn([command, ...args], {
@@ -100320,62 +100307,62 @@ class PtyDiagRunner {
100320
100307
  cwd: process.cwd(),
100321
100308
  env: env2
100322
100309
  });
100323
- await new Promise((resolve4) => setTimeout(resolve4, 500));
100324
- const isTerminalResponse = (data) => {
100325
- if (data.startsWith("\x1BP"))
100326
- return true;
100327
- if (/^\x1b\[\??[\d;]*[Rcyn]/.test(data))
100328
- return true;
100329
- if (/^\x1b\[[\?>][\d;]*c/.test(data))
100330
- return true;
100331
- return false;
100332
- };
100310
+ const startTime = Date.now();
100311
+ const GRACE_PERIOD_MS = 2000;
100333
100312
  this.rawStdinHandler = (chunk) => {
100334
100313
  if (!this.bunProc?.terminal)
100335
100314
  return;
100336
100315
  const str = typeof chunk === "string" ? chunk : chunk.toString("binary");
100337
- if (isTerminalResponse(str))
100338
- return;
100316
+ if (Date.now() - startTime < GRACE_PERIOD_MS) {
100317
+ if (str.includes("\x1B"))
100318
+ return;
100319
+ }
100339
100320
  this.bunProc.terminal.write(str);
100340
100321
  };
100341
100322
  process.stdin.on("data", this.rawStdinHandler);
100342
- if (this.renderer.prependInputHandler) {
100343
- this.renderer.prependInputHandler((sequence) => {
100344
- if (sequence === "\x1B" && this.renderer && this.renderer.experimental_splitHeight > 0) {
100345
- this.hideDiag();
100346
- return true;
100347
- }
100348
- return false;
100349
- });
100350
- }
100351
- this.renderer.on("resize", () => {
100352
- if (this.bunProc?.terminal && this.renderer) {
100353
- const newCols = this.renderer.terminalWidth || process.stdout.columns || 80;
100354
- const newRows = Math.max(1, (this.renderer.terminalHeight || process.stdout.rows || 24) - this.renderer.experimental_splitHeight);
100323
+ const resizeHandler = () => {
100324
+ if (this.bunProc?.terminal) {
100355
100325
  try {
100356
- this.bunProc.terminal.resize(newCols, newRows);
100326
+ this.bunProc.terminal.resize(process.stdout.columns || 80, process.stdout.rows || 24);
100357
100327
  } catch {}
100358
100328
  }
100359
- });
100329
+ };
100330
+ process.on("SIGWINCH", resizeHandler);
100360
100331
  await this.bunProc.exited;
100361
100332
  const exitCode = this.bunProc.exitCode ?? 1;
100333
+ process.removeListener("SIGWINCH", resizeHandler);
100362
100334
  this.cleanup();
100363
100335
  return exitCode;
100364
100336
  }
100365
- showDiag(messages) {
100366
- if (!this.renderer)
100367
- return;
100337
+ async showDiag(messages) {
100368
100338
  this.messages = messages.slice(-4);
100369
- this.renderDiagPanel();
100370
- if (this.renderer.experimental_splitHeight === 0) {
100371
- this.renderer.experimental_splitHeight = 5;
100339
+ if (!this.renderer && !this.rendererInitializing) {
100340
+ this.rendererInitializing = true;
100341
+ try {
100342
+ this.renderer = await createCliRenderer({
100343
+ useAlternateScreen: false,
100344
+ experimental_splitHeight: 5,
100345
+ exitOnCtrlC: false,
100346
+ useMouse: false,
100347
+ useKittyKeyboard: null,
100348
+ targetFps: 10
100349
+ });
100350
+ this.reactRoot = createRoot(this.renderer);
100351
+ this.renderDiagPanel();
100352
+ } catch {
100353
+ this.rendererInitializing = false;
100354
+ return;
100355
+ }
100356
+ this.rendererInitializing = false;
100357
+ } else if (this.renderer) {
100358
+ if (this.renderer.experimental_splitHeight === 0) {
100359
+ this.renderer.experimental_splitHeight = 5;
100360
+ }
100361
+ this.renderDiagPanel();
100372
100362
  }
100373
- if (this.autoHideTimer) {
100363
+ if (this.autoHideTimer)
100374
100364
  clearTimeout(this.autoHideTimer);
100375
- }
100376
- this.autoHideTimer = setTimeout(() => {
100377
- this.hideDiag();
100378
- }, 1e4);
100365
+ this.autoHideTimer = setTimeout(() => this.hideDiag(), 1e4);
100379
100366
  }
100380
100367
  hideDiag() {
100381
100368
  if (!this.renderer)
@@ -100404,11 +100391,9 @@ class PtyDiagRunner {
100404
100391
  try {
100405
100392
  this.bunProc.kill();
100406
100393
  } catch {}
100407
- if (this.bunProc.terminal) {
100408
- try {
100409
- this.bunProc.terminal.close();
100410
- } catch {}
100411
- }
100394
+ try {
100395
+ this.bunProc.terminal?.close();
100396
+ } catch {}
100412
100397
  this.bunProc = null;
100413
100398
  }
100414
100399
  if (this.renderer && !this.renderer.isDestroyed) {
@@ -100423,9 +100408,7 @@ async function tryCreatePtyRunner() {
100423
100408
  try {
100424
100409
  if (typeof Bun === "undefined")
100425
100410
  return null;
100426
- const test = Bun.spawn(["true"], {
100427
- terminal: { cols: 1, rows: 1 }
100428
- });
100411
+ const test = Bun.spawn(["true"], { terminal: { cols: 1, rows: 1 } });
100429
100412
  await test.exited;
100430
100413
  return new PtyDiagRunner;
100431
100414
  } catch {
@@ -103022,7 +103005,7 @@ var init_openrouter_queue = __esm(() => {
103022
103005
  });
103023
103006
 
103024
103007
  // src/providers/transport/openrouter.ts
103025
- class OpenRouterProvider {
103008
+ class OpenRouterProviderTransport {
103026
103009
  name = "openrouter";
103027
103010
  displayName = "OpenRouter";
103028
103011
  streamFormat = "openai-sse";
@@ -103062,17 +103045,17 @@ var init_openrouter2 = __esm(() => {
103062
103045
  init_model_loader();
103063
103046
  });
103064
103047
 
103065
- // src/adapters/openrouter-adapter.ts
103066
- var OpenRouterAdapter;
103067
- var init_openrouter_adapter = __esm(() => {
103068
- init_base_adapter();
103069
- init_adapter_manager();
103048
+ // src/adapters/openrouter-api-format.ts
103049
+ var OpenRouterAPIFormat;
103050
+ var init_openrouter_api_format = __esm(() => {
103051
+ init_base_api_format();
103052
+ init_dialect_manager();
103070
103053
  init_transform();
103071
- OpenRouterAdapter = class OpenRouterAdapter extends BaseModelAdapter {
103054
+ OpenRouterAPIFormat = class OpenRouterAPIFormat extends BaseAPIFormat {
103072
103055
  innerAdapter;
103073
103056
  constructor(modelId) {
103074
103057
  super(modelId);
103075
- const manager = new AdapterManager(modelId);
103058
+ const manager = new DialectManager(modelId);
103076
103059
  this.innerAdapter = manager.getAdapter();
103077
103060
  }
103078
103061
  modelSupportsReasoning() {
@@ -103086,7 +103069,7 @@ var init_openrouter_adapter = __esm(() => {
103086
103069
  return true;
103087
103070
  }
103088
103071
  getName() {
103089
- return `OpenRouterAdapter(${this.innerAdapter.getName()})`;
103072
+ return `OpenRouterAPIFormat(${this.innerAdapter.getName()})`;
103090
103073
  }
103091
103074
  reset() {
103092
103075
  super.reset();
@@ -103564,16 +103547,16 @@ var init_local = __esm(() => {
103564
103547
  // src/adapters/local-adapter.ts
103565
103548
  var LocalModelAdapter;
103566
103549
  var init_local_adapter = __esm(() => {
103567
- init_base_adapter();
103568
- init_adapter_manager();
103550
+ init_base_api_format();
103551
+ init_dialect_manager();
103569
103552
  init_logger();
103570
- LocalModelAdapter = class LocalModelAdapter extends BaseModelAdapter {
103553
+ LocalModelAdapter = class LocalModelAdapter extends BaseAPIFormat {
103571
103554
  innerAdapter;
103572
103555
  providerName;
103573
103556
  constructor(modelId, providerName) {
103574
103557
  super(modelId);
103575
103558
  this.providerName = providerName;
103576
- const manager = new AdapterManager(modelId);
103559
+ const manager = new DialectManager(modelId);
103577
103560
  this.innerAdapter = manager.getAdapter();
103578
103561
  }
103579
103562
  processTextContent(textContent, accumulatedText) {
@@ -105062,9 +105045,9 @@ class ComposedHandler {
105062
105045
  this.options = options;
105063
105046
  this.explicitAdapter = options.adapter;
105064
105047
  this.isInteractive = options.isInteractive ?? false;
105065
- this.adapterManager = new AdapterManager(targetModel);
105048
+ this.adapterManager = new DialectManager(targetModel);
105066
105049
  const resolvedModelAdapter = this.adapterManager.getAdapter();
105067
- if (resolvedModelAdapter.getName() !== "DefaultAdapter") {
105050
+ if (resolvedModelAdapter.getName() !== "DefaultAPIFormat") {
105068
105051
  this.modelAdapter = resolvedModelAdapter;
105069
105052
  }
105070
105053
  this.middlewareManager = new MiddlewareManager;
@@ -105547,7 +105530,7 @@ function getRecoveryHint(status, errorText, providerName) {
105547
105530
  return `Unexpected HTTP ${status} from ${providerName}.`;
105548
105531
  }
105549
105532
  var init_composed_handler = __esm(() => {
105550
- init_adapter_manager();
105533
+ init_dialect_manager();
105551
105534
  init_middleware();
105552
105535
  init_token_tracker();
105553
105536
  init_transform();
@@ -105956,7 +105939,7 @@ var init_gemini_queue = __esm(() => {
105956
105939
  });
105957
105940
 
105958
105941
  // src/providers/transport/gemini-apikey.ts
105959
- class GeminiApiKeyProvider {
105942
+ class GeminiProviderTransport {
105960
105943
  name = "gemini";
105961
105944
  displayName = "Gemini API";
105962
105945
  streamFormat = "gemini-sse";
@@ -105989,7 +105972,7 @@ var init_gemini_apikey = __esm(() => {
105989
105972
  // src/providers/transport/gemini-codeassist.ts
105990
105973
  import { randomUUID } from "crypto";
105991
105974
 
105992
- class GeminiCodeAssistProvider {
105975
+ class GeminiCodeAssistProviderTransport {
105993
105976
  name = "gemini-codeassist";
105994
105977
  displayName = "Gemini Free";
105995
105978
  streamFormat = "gemini-sse";
@@ -106034,7 +106017,7 @@ var init_gemini_codeassist = __esm(() => {
106034
106017
  });
106035
106018
 
106036
106019
  // src/providers/transport/openai.ts
106037
- class OpenAIProvider {
106020
+ class OpenAIProviderTransport {
106038
106021
  name;
106039
106022
  displayName;
106040
106023
  streamFormat;
@@ -106046,7 +106029,7 @@ class OpenAIProvider {
106046
106029
  this.modelName = modelName;
106047
106030
  this.apiKey = apiKey;
106048
106031
  this.name = provider.name;
106049
- this.displayName = OpenAIProvider.formatDisplayName(provider.name);
106032
+ this.displayName = OpenAIProviderTransport.formatDisplayName(provider.name);
106050
106033
  this.streamFormat = modelName.toLowerCase().includes("codex") ? "openai-responses-sse" : "openai-sse";
106051
106034
  }
106052
106035
  getEndpoint() {
@@ -106114,7 +106097,7 @@ var init_openai = __esm(() => {
106114
106097
  });
106115
106098
 
106116
106099
  // src/providers/transport/anthropic-compat.ts
106117
- class AnthropicCompatProvider {
106100
+ class AnthropicProviderTransport {
106118
106101
  name;
106119
106102
  displayName;
106120
106103
  streamFormat = "anthropic-sse";
@@ -106124,7 +106107,7 @@ class AnthropicCompatProvider {
106124
106107
  this.provider = provider;
106125
106108
  this.apiKey = apiKey;
106126
106109
  this.name = provider.name;
106127
- this.displayName = AnthropicCompatProvider.formatDisplayName(provider.name);
106110
+ this.displayName = AnthropicProviderTransport.formatDisplayName(provider.name);
106128
106111
  }
106129
106112
  getEndpoint() {
106130
106113
  return `${this.provider.baseUrl}${this.provider.apiPath}`;
@@ -106181,11 +106164,11 @@ var init_anthropic_compat = __esm(() => {
106181
106164
  init_logger();
106182
106165
  });
106183
106166
 
106184
- // src/adapters/anthropic-passthrough-adapter.ts
106185
- var AnthropicPassthroughAdapter;
106186
- var init_anthropic_passthrough_adapter = __esm(() => {
106187
- init_base_adapter();
106188
- AnthropicPassthroughAdapter = class AnthropicPassthroughAdapter extends BaseModelAdapter {
106167
+ // src/adapters/anthropic-api-format.ts
106168
+ var AnthropicAPIFormat;
106169
+ var init_anthropic_api_format = __esm(() => {
106170
+ init_base_api_format();
106171
+ AnthropicAPIFormat = class AnthropicAPIFormat extends BaseAPIFormat {
106189
106172
  providerName;
106190
106173
  constructor(modelId, providerName) {
106191
106174
  super(modelId);
@@ -106202,7 +106185,7 @@ var init_anthropic_passthrough_adapter = __esm(() => {
106202
106185
  return false;
106203
106186
  }
106204
106187
  getName() {
106205
- return "AnthropicPassthroughAdapter";
106188
+ return "AnthropicAPIFormat";
106206
106189
  }
106207
106190
  convertMessages(claudeRequest, _filterFn) {
106208
106191
  const messages = claudeRequest.messages || [];
@@ -106287,7 +106270,7 @@ var init_anthropic_passthrough_adapter = __esm(() => {
106287
106270
  });
106288
106271
 
106289
106272
  // src/providers/transport/ollamacloud.ts
106290
- class OllamaCloudProvider {
106273
+ class OllamaProviderTransport {
106291
106274
  name = "ollamacloud";
106292
106275
  displayName = "OllamaCloud";
106293
106276
  streamFormat = "ollama-jsonl";
@@ -106308,12 +106291,13 @@ class OllamaCloudProvider {
106308
106291
  return headers;
106309
106292
  }
106310
106293
  }
106294
+ var init_ollamacloud = () => {};
106311
106295
 
106312
- // src/adapters/ollamacloud-adapter.ts
106313
- var OllamaCloudAdapter;
106314
- var init_ollamacloud_adapter = __esm(() => {
106315
- init_base_adapter();
106316
- OllamaCloudAdapter = class OllamaCloudAdapter extends BaseModelAdapter {
106296
+ // src/adapters/ollama-api-format.ts
106297
+ var OllamaAPIFormat;
106298
+ var init_ollama_api_format = __esm(() => {
106299
+ init_base_api_format();
106300
+ OllamaAPIFormat = class OllamaAPIFormat extends BaseAPIFormat {
106317
106301
  constructor(modelId) {
106318
106302
  super(modelId);
106319
106303
  }
@@ -106328,7 +106312,7 @@ var init_ollamacloud_adapter = __esm(() => {
106328
106312
  return false;
106329
106313
  }
106330
106314
  getName() {
106331
- return "OllamaCloudAdapter";
106315
+ return "OllamaAPIFormat";
106332
106316
  }
106333
106317
  convertMessages(claudeRequest, _filterFn) {
106334
106318
  const messages = [];
@@ -106404,7 +106388,7 @@ var init_ollamacloud_adapter = __esm(() => {
106404
106388
  });
106405
106389
 
106406
106390
  // src/providers/transport/litellm.ts
106407
- class LiteLLMProvider {
106391
+ class LiteLLMProviderTransport {
106408
106392
  name = "litellm";
106409
106393
  displayName = "LiteLLM";
106410
106394
  streamFormat = "openai-sse";
@@ -106456,17 +106440,17 @@ var init_litellm2 = __esm(() => {
106456
106440
  ];
106457
106441
  });
106458
106442
 
106459
- // src/adapters/litellm-adapter.ts
106443
+ // src/adapters/litellm-api-format.ts
106460
106444
  import { existsSync as existsSync21, readFileSync as readFileSync19 } from "fs";
106461
106445
  import { createHash as createHash5 } from "crypto";
106462
106446
  import { homedir as homedir21 } from "os";
106463
106447
  import { join as join24 } from "path";
106464
- var INLINE_IMAGE_MODEL_PATTERNS, LiteLLMAdapter;
106465
- var init_litellm_adapter = __esm(() => {
106466
- init_base_adapter();
106448
+ var INLINE_IMAGE_MODEL_PATTERNS, LiteLLMAPIFormat;
106449
+ var init_litellm_api_format = __esm(() => {
106450
+ init_base_api_format();
106467
106451
  init_logger();
106468
106452
  INLINE_IMAGE_MODEL_PATTERNS = ["minimax"];
106469
- LiteLLMAdapter = class LiteLLMAdapter extends DefaultAdapter {
106453
+ LiteLLMAPIFormat = class LiteLLMAPIFormat extends DefaultAPIFormat {
106470
106454
  baseUrl;
106471
106455
  visionSupported;
106472
106456
  needsInlineImages;
@@ -106477,7 +106461,7 @@ var init_litellm_adapter = __esm(() => {
106477
106461
  this.needsInlineImages = INLINE_IMAGE_MODEL_PATTERNS.some((p) => modelId.toLowerCase().includes(p));
106478
106462
  }
106479
106463
  getName() {
106480
- return "LiteLLMAdapter";
106464
+ return "LiteLLMAPIFormat";
106481
106465
  }
106482
106466
  shouldHandle(modelId) {
106483
106467
  return false;
@@ -106502,7 +106486,7 @@ var init_litellm_adapter = __esm(() => {
106502
106486
  if (base64Match) {
106503
106487
  inlineImages += `
106504
106488
  [Image base64:${base64Match[1]}]`;
106505
- log(`[LiteLLMAdapter] Converted image_url to inline base64 for ${this.modelId}`);
106489
+ log(`[LiteLLMAPIFormat] Converted image_url to inline base64 for ${this.modelId}`);
106506
106490
  }
106507
106491
  } else if (url2) {
106508
106492
  inlineImages += `
@@ -106562,7 +106546,7 @@ var init_litellm_adapter = __esm(() => {
106562
106546
  const cacheData = JSON.parse(readFileSync19(cachePath, "utf-8"));
106563
106547
  const model = cacheData.models?.find((m2) => m2.name === this.modelId);
106564
106548
  if (model && model.supportsVision === false) {
106565
- log(`[LiteLLMAdapter] Model ${this.modelId} does not support vision`);
106549
+ log(`[LiteLLMAPIFormat] Model ${this.modelId} does not support vision`);
106566
106550
  return false;
106567
106551
  }
106568
106552
  return true;
@@ -106741,7 +106725,7 @@ function parseVertexModel(modelId) {
106741
106725
  return { publisher: parts[0], model: parts.slice(1).join("/") };
106742
106726
  }
106743
106727
 
106744
- class VertexOAuthProvider {
106728
+ class VertexProviderTransport {
106745
106729
  name = "vertex";
106746
106730
  displayName = "Vertex AI";
106747
106731
  streamFormat;
@@ -106820,24 +106804,25 @@ var init_provider_profiles = __esm(() => {
106820
106804
  init_composed_handler();
106821
106805
  init_gemini_apikey();
106822
106806
  init_gemini_codeassist();
106823
- init_gemini_adapter();
106807
+ init_gemini_api_format();
106824
106808
  init_openai();
106825
- init_openai_adapter();
106809
+ init_openai_api_format();
106826
106810
  init_anthropic_compat();
106827
- init_anthropic_passthrough_adapter();
106828
- init_ollamacloud_adapter();
106811
+ init_anthropic_api_format();
106812
+ init_ollamacloud();
106813
+ init_ollama_api_format();
106829
106814
  init_litellm2();
106830
- init_litellm_adapter();
106815
+ init_litellm_api_format();
106831
106816
  init_vertex_oauth();
106832
- init_base_adapter();
106817
+ init_base_api_format();
106833
106818
  init_remote_provider_registry();
106834
106819
  init_vertex_auth();
106835
106820
  init_logger();
106836
106821
  init_api_key_provenance();
106837
106822
  geminiProfile = {
106838
106823
  createHandler(ctx) {
106839
- const transport = new GeminiApiKeyProvider(ctx.provider, ctx.modelName, ctx.apiKey);
106840
- const adapter = new GeminiAdapter(ctx.modelName);
106824
+ const transport = new GeminiProviderTransport(ctx.provider, ctx.modelName, ctx.apiKey);
106825
+ const adapter = new GeminiAPIFormat(ctx.modelName);
106841
106826
  const handler = new ComposedHandler(transport, ctx.targetModel, ctx.modelName, ctx.port, {
106842
106827
  adapter,
106843
106828
  ...ctx.sharedOpts
@@ -106848,8 +106833,8 @@ var init_provider_profiles = __esm(() => {
106848
106833
  };
106849
106834
  geminiCodeAssistProfile = {
106850
106835
  createHandler(ctx) {
106851
- const transport = new GeminiCodeAssistProvider(ctx.modelName);
106852
- const adapter = new GeminiAdapter(ctx.modelName);
106836
+ const transport = new GeminiCodeAssistProviderTransport(ctx.modelName);
106837
+ const adapter = new GeminiAPIFormat(ctx.modelName);
106853
106838
  const handler = new ComposedHandler(transport, ctx.targetModel, ctx.modelName, ctx.port, {
106854
106839
  adapter,
106855
106840
  unwrapGeminiResponse: true,
@@ -106861,8 +106846,8 @@ var init_provider_profiles = __esm(() => {
106861
106846
  };
106862
106847
  openaiProfile = {
106863
106848
  createHandler(ctx) {
106864
- const transport = new OpenAIProvider(ctx.provider, ctx.modelName, ctx.apiKey);
106865
- const adapter = new OpenAIAdapter(ctx.modelName);
106849
+ const transport = new OpenAIProviderTransport(ctx.provider, ctx.modelName, ctx.apiKey);
106850
+ const adapter = new OpenAIAPIFormat(ctx.modelName);
106866
106851
  const handler = new ComposedHandler(transport, ctx.targetModel, ctx.modelName, ctx.port, {
106867
106852
  adapter,
106868
106853
  tokenStrategy: "delta-aware",
@@ -106874,8 +106859,8 @@ var init_provider_profiles = __esm(() => {
106874
106859
  };
106875
106860
  anthropicCompatProfile = {
106876
106861
  createHandler(ctx) {
106877
- const transport = new AnthropicCompatProvider(ctx.provider, ctx.apiKey);
106878
- const adapter = new AnthropicPassthroughAdapter(ctx.modelName, ctx.provider.name);
106862
+ const transport = new AnthropicProviderTransport(ctx.provider, ctx.apiKey);
106863
+ const adapter = new AnthropicAPIFormat(ctx.modelName, ctx.provider.name);
106879
106864
  const handler = new ComposedHandler(transport, ctx.targetModel, ctx.modelName, ctx.port, {
106880
106865
  adapter,
106881
106866
  ...ctx.sharedOpts
@@ -106886,8 +106871,8 @@ var init_provider_profiles = __esm(() => {
106886
106871
  };
106887
106872
  glmProfile = {
106888
106873
  createHandler(ctx) {
106889
- const transport = new OpenAIProvider(ctx.provider, ctx.modelName, ctx.apiKey);
106890
- const adapter = new OpenAIAdapter(ctx.modelName);
106874
+ const transport = new OpenAIProviderTransport(ctx.provider, ctx.modelName, ctx.apiKey);
106875
+ const adapter = new OpenAIAPIFormat(ctx.modelName);
106891
106876
  const handler = new ComposedHandler(transport, ctx.targetModel, ctx.modelName, ctx.port, {
106892
106877
  adapter,
106893
106878
  tokenStrategy: "delta-aware",
@@ -106902,8 +106887,8 @@ var init_provider_profiles = __esm(() => {
106902
106887
  const zenApiKey = ctx.apiKey || "public";
106903
106888
  const isGoProvider = ctx.provider.name === "opencode-zen-go";
106904
106889
  if (ctx.modelName.toLowerCase().includes("minimax")) {
106905
- const transport2 = new AnthropicCompatProvider(ctx.provider, zenApiKey);
106906
- const adapter2 = new AnthropicPassthroughAdapter(ctx.modelName, ctx.provider.name);
106890
+ const transport2 = new AnthropicProviderTransport(ctx.provider, zenApiKey);
106891
+ const adapter2 = new AnthropicAPIFormat(ctx.modelName, ctx.provider.name);
106907
106892
  const handler2 = new ComposedHandler(transport2, ctx.targetModel, ctx.modelName, ctx.port, {
106908
106893
  adapter: adapter2,
106909
106894
  ...ctx.sharedOpts
@@ -106911,8 +106896,8 @@ var init_provider_profiles = __esm(() => {
106911
106896
  log(`[Proxy] Created OpenCode Zen${isGoProvider ? " Go" : ""} (Anthropic composed): ${ctx.modelName}`);
106912
106897
  return handler2;
106913
106898
  }
106914
- const transport = new OpenAIProvider(ctx.provider, ctx.modelName, zenApiKey);
106915
- const adapter = new OpenAIAdapter(ctx.modelName);
106899
+ const transport = new OpenAIProviderTransport(ctx.provider, ctx.modelName, zenApiKey);
106900
+ const adapter = new OpenAIAPIFormat(ctx.modelName);
106916
106901
  const handler = new ComposedHandler(transport, ctx.targetModel, ctx.modelName, ctx.port, {
106917
106902
  adapter,
106918
106903
  tokenStrategy: "delta-aware",
@@ -106924,8 +106909,8 @@ var init_provider_profiles = __esm(() => {
106924
106909
  };
106925
106910
  ollamaCloudProfile = {
106926
106911
  createHandler(ctx) {
106927
- const transport = new OllamaCloudProvider(ctx.provider, ctx.apiKey);
106928
- const adapter = new OllamaCloudAdapter(ctx.modelName);
106912
+ const transport = new OllamaProviderTransport(ctx.provider, ctx.apiKey);
106913
+ const adapter = new OllamaAPIFormat(ctx.modelName);
106929
106914
  const handler = new ComposedHandler(transport, ctx.targetModel, ctx.modelName, ctx.port, {
106930
106915
  adapter,
106931
106916
  tokenStrategy: "accumulate-both",
@@ -106943,8 +106928,8 @@ var init_provider_profiles = __esm(() => {
106943
106928
  logStderr("Or use: claudish --litellm-url https://your-instance.com --model litellm@model 'task'");
106944
106929
  return null;
106945
106930
  }
106946
- const transport = new LiteLLMProvider(ctx.provider.baseUrl, ctx.apiKey, ctx.modelName);
106947
- const adapter = new LiteLLMAdapter(ctx.modelName, ctx.provider.baseUrl);
106931
+ const transport = new LiteLLMProviderTransport(ctx.provider.baseUrl, ctx.apiKey, ctx.modelName);
106932
+ const adapter = new LiteLLMAPIFormat(ctx.modelName, ctx.provider.baseUrl);
106948
106933
  const handler = new ComposedHandler(transport, ctx.targetModel, ctx.modelName, ctx.port, {
106949
106934
  adapter,
106950
106935
  ...ctx.sharedOpts
@@ -106960,8 +106945,8 @@ var init_provider_profiles = __esm(() => {
106960
106945
  if (hasApiKey) {
106961
106946
  const geminiConfig = getRegisteredRemoteProviders().find((p) => p.name === "gemini");
106962
106947
  const expressProvider = geminiConfig || ctx.provider;
106963
- const transport = new GeminiApiKeyProvider(expressProvider, ctx.modelName, process.env.VERTEX_API_KEY);
106964
- const adapter = new GeminiAdapter(ctx.modelName);
106948
+ const transport = new GeminiProviderTransport(expressProvider, ctx.modelName, process.env.VERTEX_API_KEY);
106949
+ const adapter = new GeminiAPIFormat(ctx.modelName);
106965
106950
  const handler = new ComposedHandler(transport, ctx.targetModel, ctx.modelName, ctx.port, {
106966
106951
  adapter,
106967
106952
  ...ctx.sharedOpts
@@ -106976,15 +106961,15 @@ var init_provider_profiles = __esm(() => {
106976
106961
  return null;
106977
106962
  }
106978
106963
  const parsed = parseVertexModel(ctx.modelName);
106979
- const transport = new VertexOAuthProvider(vertexConfig, parsed);
106964
+ const transport = new VertexProviderTransport(vertexConfig, parsed);
106980
106965
  let adapter;
106981
106966
  if (parsed.publisher === "google") {
106982
- adapter = new GeminiAdapter(ctx.modelName);
106967
+ adapter = new GeminiAPIFormat(ctx.modelName);
106983
106968
  } else if (parsed.publisher === "anthropic") {
106984
- adapter = new AnthropicPassthroughAdapter(parsed.model, "vertex");
106969
+ adapter = new AnthropicAPIFormat(parsed.model, "vertex");
106985
106970
  } else {
106986
106971
  const modelId = parsed.publisher === "mistralai" ? parsed.model : `${parsed.publisher}/${parsed.model}`;
106987
- adapter = new DefaultAdapter(modelId);
106972
+ adapter = new DefaultAPIFormat(modelId);
106988
106973
  }
106989
106974
  const handler = new ComposedHandler(transport, ctx.targetModel, ctx.modelName, ctx.port, {
106990
106975
  adapter,
@@ -107031,8 +107016,8 @@ async function createProxyServer(port, openrouterApiKey, model, monitorMode = fa
107031
107016
  const parsed = parseModelSpec(targetModel);
107032
107017
  const modelId = targetModel.includes("@") ? parsed.model : targetModel;
107033
107018
  if (!openRouterHandlers.has(modelId)) {
107034
- const orProvider = new OpenRouterProvider(openrouterApiKey || "", modelId);
107035
- const orAdapter = new OpenRouterAdapter(modelId);
107019
+ const orProvider = new OpenRouterProviderTransport(openrouterApiKey || "", modelId);
107020
+ const orAdapter = new OpenRouterAPIFormat(modelId);
107036
107021
  openRouterHandlers.set(modelId, new ComposedHandler(orProvider, modelId, modelId, port, {
107037
107022
  adapter: orAdapter,
107038
107023
  isInteractive: options.isInteractive,
@@ -107320,7 +107305,7 @@ var init_proxy_server = __esm(() => {
107320
107305
  init_logger();
107321
107306
  init_native_handler();
107322
107307
  init_openrouter2();
107323
- init_openrouter_adapter();
107308
+ init_openrouter_api_format();
107324
107309
  init_local();
107325
107310
  init_local_adapter();
107326
107311
  init_composed_handler();