@jaypie/llm 1.2.12 → 1.2.14

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.
@@ -32,7 +32,7 @@ export declare const PROVIDER: {
32
32
  readonly TINY: "gemini-3-flash-preview";
33
33
  };
34
34
  readonly MODEL_MATCH_WORDS: readonly ["gemini", "google"];
35
- readonly NAME: "gemini";
35
+ readonly NAME: "google";
36
36
  readonly ROLE: {
37
37
  readonly MODEL: "model";
38
38
  readonly USER: "user";
@@ -81,7 +81,7 @@ const PROVIDER = {
81
81
  TINY: FIRST_CLASS_PROVIDER.GEMINI.TINY,
82
82
  },
83
83
  MODEL_MATCH_WORDS: ["gemini", "google"],
84
- NAME: "gemini",
84
+ NAME: "google",
85
85
  ROLE: {
86
86
  MODEL: "model",
87
87
  USER: "user",
@@ -196,7 +196,7 @@ function determineModelProvider(input) {
196
196
  provider: PROVIDER.ANTHROPIC.NAME,
197
197
  };
198
198
  }
199
- if (input === PROVIDER.GEMINI.NAME) {
199
+ if (input === PROVIDER.GEMINI.NAME || input === "gemini") {
200
200
  return {
201
201
  model: PROVIDER.GEMINI.MODEL.DEFAULT,
202
202
  provider: PROVIDER.GEMINI.NAME,
@@ -2097,7 +2097,17 @@ class GeminiAdapter extends BaseProviderAdapter {
2097
2097
  return JSON.parse(textContent);
2098
2098
  }
2099
2099
  catch {
2100
- // If parsing fails, return the original string
2100
+ // Strip markdown code fences and retry (Gemini sometimes wraps JSON in fences)
2101
+ const jsonMatch = textContent.match(/```(?:json)?\s*([\s\S]*?)\s*```/) ||
2102
+ textContent.match(/\{[\s\S]*\}/);
2103
+ if (jsonMatch) {
2104
+ try {
2105
+ return JSON.parse(jsonMatch[1] || jsonMatch[0]);
2106
+ }
2107
+ catch {
2108
+ // Fall through to return original string
2109
+ }
2110
+ }
2101
2111
  return textContent;
2102
2112
  }
2103
2113
  }
@@ -5143,6 +5153,17 @@ class GeminiProvider {
5143
5153
  return JSON.parse(text);
5144
5154
  }
5145
5155
  catch {
5156
+ // Strip markdown code fences and retry (Gemini sometimes wraps JSON in fences)
5157
+ const jsonMatch = text.match(/```(?:json)?\s*([\s\S]*?)\s*```/) ||
5158
+ text.match(/\{[\s\S]*\}/);
5159
+ if (jsonMatch) {
5160
+ try {
5161
+ return JSON.parse(jsonMatch[1] || jsonMatch[0]);
5162
+ }
5163
+ catch {
5164
+ // Fall through to return original text
5165
+ }
5166
+ }
5146
5167
  return text || "";
5147
5168
  }
5148
5169
  }
@@ -5518,6 +5539,10 @@ class Llm {
5518
5539
  const { fallback, model } = options;
5519
5540
  let finalProvider = providerName;
5520
5541
  let finalModel = model;
5542
+ // Legacy: accept "gemini" but warn
5543
+ if (providerName === "gemini") {
5544
+ log$2.warn(`Provider "gemini" is deprecated, use "${PROVIDER.GEMINI.NAME}" instead`);
5545
+ }
5521
5546
  if (model) {
5522
5547
  const modelDetermined = determineModelProvider(model);
5523
5548
  finalModel = modelDetermined.model;
@@ -5532,6 +5557,10 @@ class Llm {
5532
5557
  throw new errors.ConfigurationError(`Unable to determine provider from: ${providerName}`);
5533
5558
  }
5534
5559
  finalProvider = providerDetermined.provider;
5560
+ // When providerName is actually a model name, extract the model (#213)
5561
+ if (!finalModel && providerName !== providerDetermined.provider) {
5562
+ finalModel = providerDetermined.model;
5563
+ }
5535
5564
  }
5536
5565
  // Handle conflicts: if both providerName and model specify different providers
5537
5566
  if (model && providerName !== DEFAULT.PROVIDER.NAME) {