@jaypie/mcp 0.7.26 → 0.7.28

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.
@@ -9,7 +9,7 @@ import { gt } from 'semver';
9
9
  /**
10
10
  * Docs Suite - Documentation services (skill, version, release_notes)
11
11
  */
12
- const BUILD_VERSION_STRING = "@jaypie/mcp@0.7.26#907a8705"
12
+ const BUILD_VERSION_STRING = "@jaypie/mcp@0.7.28#0f3649d0"
13
13
  ;
14
14
  const __filename$1 = fileURLToPath(import.meta.url);
15
15
  const __dirname$1 = path.dirname(__filename$1);
@@ -2,7 +2,7 @@ import { fabricService } from '@jaypie/fabric';
2
2
  import * as fs from 'node:fs/promises';
3
3
  import * as path from 'node:path';
4
4
  import { fileURLToPath } from 'node:url';
5
- import { debugLlmCall, validateLlmSetup } from './llm.js';
5
+ import { inferProvider, debugLlmCall, validateLlmSetup } from './llm.js';
6
6
 
7
7
  /**
8
8
  * LLM Suite - Unified LLM debugging and inspection
@@ -52,14 +52,16 @@ const llmService = fabricService({
52
52
  return validateLlmSetup();
53
53
  }
54
54
  case "debug_call": {
55
- if (!p.provider)
56
- throw new Error("provider is required");
55
+ const provider = p.provider ||
56
+ (p.model ? inferProvider(p.model) : undefined);
57
+ if (!provider)
58
+ throw new Error("provider is required (or use a model name that starts with claude-, gemini-, gpt-, o1-, o3-, o4-, or chatgpt-)");
57
59
  if (!p.message)
58
60
  throw new Error("message is required");
59
61
  const result = await debugLlmCall({
60
62
  message: p.message,
61
63
  model: p.model,
62
- provider: p.provider,
64
+ provider,
63
65
  }, log);
64
66
  if (!result.success)
65
67
  throw new Error(result.error);
@@ -71,5 +73,5 @@ const llmService = fabricService({
71
73
  },
72
74
  });
73
75
 
74
- export { debugLlmCall, llmService, validateLlmSetup };
76
+ export { debugLlmCall, inferProvider, llmService, validateLlmSetup };
75
77
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/suites/llm/index.ts"],"sourcesContent":["/**\n * LLM Suite - Unified LLM debugging and inspection\n */\nimport { fabricService } from \"@jaypie/fabric\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { debugLlmCall, validateLlmSetup, type LlmProvider } from \"./llm.js\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\n// Silent logger for direct execution\nconst log = {\n error: () => {},\n info: () => {},\n};\n\nasync function getHelp(): Promise<string> {\n return fs.readFile(path.join(__dirname, \"help.md\"), \"utf-8\");\n}\n\n// Flattened input type for the unified LLM service\ninterface LlmInput {\n command?: string;\n message?: string;\n model?: string;\n provider?: string;\n}\n\nexport const llmService = fabricService({\n alias: \"llm\",\n description:\n \"Debug LLM provider responses. Commands: debug_call. Call with no args for help.\",\n input: {\n command: {\n description: \"Command to execute (omit for help)\",\n required: false,\n type: String,\n },\n message: {\n description: \"Message to send to the LLM provider\",\n required: false,\n type: String,\n },\n model: {\n description:\n \"Model to use (provider-specific, e.g., gpt-4, claude-3-sonnet)\",\n required: false,\n type: String,\n },\n provider: {\n description: \"LLM provider: anthropic, openai, google, openrouter\",\n required: false,\n type: String,\n },\n },\n service: async (params: LlmInput) => {\n const { command } = params;\n\n if (!command || command === \"help\") {\n return getHelp();\n }\n\n const p = params;\n\n switch (command) {\n case \"validate\": {\n return validateLlmSetup();\n }\n\n case \"debug_call\": {\n if (!p.provider) throw new Error(\"provider is required\");\n if (!p.message) throw new Error(\"message is required\");\n const result = await debugLlmCall(\n {\n message: p.message,\n model: p.model,\n provider: p.provider as LlmProvider,\n },\n log,\n );\n if (!result.success) throw new Error(result.error);\n return result;\n }\n\n default:\n throw new Error(`Unknown command: ${command}. Use llm() for help.`);\n }\n },\n});\n\n// Re-export types and functions for testing\nexport * from \"./llm.js\";\n"],"names":["__dirname"],"mappings":";;;;;;AAAA;;AAEG;AAQH,MAAMA,WAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa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,KAAK,YAAY,EAAE;gBACjB,IAAI,CAAC,CAAC,CAAC,QAAQ;AAAE,oBAAA,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC;gBACxD,IAAI,CAAC,CAAC,CAAC,OAAO;AAAE,oBAAA,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC;AACtD,gBAAA,MAAM,MAAM,GAAG,MAAM,YAAY,CAC/B;oBACE,OAAO,EAAE,CAAC,CAAC,OAAO;oBAClB,KAAK,EAAE,CAAC,CAAC,KAAK;oBACd,QAAQ,EAAE,CAAC,CAAC,QAAuB;iBACpC,EACD,GAAG,CACJ;gBACD,IAAI,CAAC,MAAM,CAAC,OAAO;AAAE,oBAAA,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;AAClD,gBAAA,OAAO,MAAM;YACf;AAEA,YAAA;AACE,gBAAA,MAAM,IAAI,KAAK,CAAC,oBAAoB,OAAO,CAAA,qBAAA,CAAuB,CAAC;;IAEzE,CAAC;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/suites/llm/index.ts"],"sourcesContent":["/**\n * LLM Suite - Unified LLM debugging and inspection\n */\nimport { fabricService } from \"@jaypie/fabric\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport {\n debugLlmCall,\n inferProvider,\n validateLlmSetup,\n type LlmProvider,\n} from \"./llm.js\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\n// Silent logger for direct execution\nconst log = {\n error: () => {},\n info: () => {},\n};\n\nasync function getHelp(): Promise<string> {\n return fs.readFile(path.join(__dirname, \"help.md\"), \"utf-8\");\n}\n\n// Flattened input type for the unified LLM service\ninterface LlmInput {\n command?: string;\n message?: string;\n model?: string;\n provider?: string;\n}\n\nexport const llmService = fabricService({\n alias: \"llm\",\n description:\n \"Debug LLM provider responses. Commands: debug_call. Call with no args for help.\",\n input: {\n command: {\n description: \"Command to execute (omit for help)\",\n required: false,\n type: String,\n },\n message: {\n description: \"Message to send to the LLM provider\",\n required: false,\n type: String,\n },\n model: {\n description:\n \"Model to use (provider-specific, e.g., gpt-4, claude-3-sonnet)\",\n required: false,\n type: String,\n },\n provider: {\n description: \"LLM provider: anthropic, openai, google, openrouter\",\n required: false,\n type: String,\n },\n },\n service: async (params: LlmInput) => {\n const { command } = params;\n\n if (!command || command === \"help\") {\n return getHelp();\n }\n\n const p = params;\n\n switch (command) {\n case \"validate\": {\n return validateLlmSetup();\n }\n\n case \"debug_call\": {\n const provider =\n (p.provider as LlmProvider) ||\n (p.model ? inferProvider(p.model) : undefined);\n if (!provider)\n throw new Error(\n \"provider is required (or use a model name that starts with claude-, gemini-, gpt-, o1-, o3-, o4-, or chatgpt-)\",\n );\n if (!p.message) throw new Error(\"message is required\");\n const result = await debugLlmCall(\n {\n message: p.message,\n model: p.model,\n provider,\n },\n log,\n );\n if (!result.success) throw new Error(result.error);\n return result;\n }\n\n default:\n throw new Error(`Unknown command: ${command}. Use llm() for help.`);\n }\n },\n});\n\n// Re-export types and functions for testing\nexport * from \"./llm.js\";\n"],"names":["__dirname"],"mappings":";;;;;;AAAA;;AAEG;AAaH,MAAMA,WAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE9D;AACA,MAAM,GAAG,GAAG;AACV,IAAA,KAAK,EAAE,MAAK,EAAE,CAAC;AACf,IAAA,IAAI,EAAE,MAAK,EAAE,CAAC;CACf;AAED,eAAe,OAAO,GAAA;AACpB,IAAA,OAAO,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAACA,WAAS,EAAE,SAAS,CAAC,EAAE,OAAO,CAAC;AAC9D;AAUO,MAAM,UAAU,GAAG,aAAa,CAAC;AACtC,IAAA,KAAK,EAAE,KAAK;AACZ,IAAA,WAAW,EACT,iFAAiF;AACnF,IAAA,KAAK,EAAE;AACL,QAAA,OAAO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,CAAC,KAAK;oBACd,QAAQ;iBACT,EACD,GAAG,CACJ;gBACD,IAAI,CAAC,MAAM,CAAC,OAAO;AAAE,oBAAA,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;AAClD,gBAAA,OAAO,MAAM;YACf;AAEA,YAAA;AACE,gBAAA,MAAM,IAAI,KAAK,CAAC,oBAAoB,OAAO,CAAA,qBAAA,CAAuB,CAAC;;IAEzE,CAAC;AACF,CAAA;;;;"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * LLM debugging utilities for inspecting raw provider responses
3
3
  */
4
- export type LlmProvider = "anthropic" | "gemini" | "openai" | "openrouter";
4
+ export type LlmProvider = "anthropic" | "google" | "openai" | "openrouter";
5
5
  export interface LlmDebugCallParams {
6
6
  provider: LlmProvider;
7
7
  model?: string;
@@ -37,6 +37,10 @@ interface Logger {
37
37
  info: (message: string, ...args: unknown[]) => void;
38
38
  error: (message: string, ...args: unknown[]) => void;
39
39
  }
40
+ /**
41
+ * Infer provider from model string prefix
42
+ */
43
+ export declare function inferProvider(model: string): LlmProvider | undefined;
40
44
  /**
41
45
  * Validate LLM setup without making API calls
42
46
  */
@@ -3,10 +3,27 @@ import { LLM, Llm } from '@jaypie/llm';
3
3
  /**
4
4
  * LLM debugging utilities for inspecting raw provider responses
5
5
  */
6
+ /**
7
+ * Infer provider from model string prefix
8
+ */
9
+ function inferProvider(model) {
10
+ const m = model.toLowerCase();
11
+ if (m.startsWith("claude-"))
12
+ return "anthropic";
13
+ if (m.startsWith("gemini-"))
14
+ return "google";
15
+ if (m.startsWith("chatgpt-") ||
16
+ m.startsWith("gpt-") ||
17
+ m.startsWith("o1-") ||
18
+ m.startsWith("o3-") ||
19
+ m.startsWith("o4-"))
20
+ return "openai";
21
+ return undefined;
22
+ }
6
23
  // Default models for each provider
7
24
  const DEFAULT_MODELS = {
8
25
  anthropic: LLM.PROVIDER.ANTHROPIC.MODEL.SMALL,
9
- gemini: LLM.PROVIDER.GEMINI.MODEL.SMALL,
26
+ google: LLM.PROVIDER.GEMINI.MODEL.SMALL,
10
27
  openai: LLM.PROVIDER.OPENAI.MODEL.SMALL,
11
28
  openrouter: LLM.PROVIDER.OPENROUTER.MODEL.SMALL,
12
29
  };
@@ -84,5 +101,5 @@ async function debugLlmCall(params, log) {
84
101
  }
85
102
  }
86
103
 
87
- export { debugLlmCall, validateLlmSetup };
104
+ export { debugLlmCall, inferProvider, validateLlmSetup };
88
105
  //# sourceMappingURL=llm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"llm.js","sources":["../../../src/suites/llm/llm.ts"],"sourcesContent":["/**\n * LLM debugging utilities for inspecting raw provider responses\n */\n\nimport { LLM, Llm } from \"@jaypie/llm\";\n\nexport type LlmProvider = \"anthropic\" | \"gemini\" | \"openai\" | \"openrouter\";\n\nexport interface LlmDebugCallParams {\n provider: LlmProvider;\n model?: string;\n message: string;\n}\n\nexport interface LlmDebugCallResult {\n success: boolean;\n provider: string;\n model: string;\n content?: string;\n reasoning?: string[];\n reasoningTokens?: number;\n history?: unknown[];\n rawResponses?: unknown[];\n usage?: unknown[];\n error?: string;\n}\n\n// Validation types\nexport interface LlmProviderStatus {\n available: boolean;\n}\n\nexport interface LlmValidationResult {\n success: boolean;\n providers: {\n anthropic: LlmProviderStatus;\n google: LlmProviderStatus;\n openai: LlmProviderStatus;\n openrouter: LlmProviderStatus;\n };\n availableCount: number;\n totalProviders: number;\n}\n\ninterface Logger {\n info: (message: string, ...args: unknown[]) => void;\n error: (message: string, ...args: unknown[]) => void;\n}\n\n// Default models for each provider\nconst DEFAULT_MODELS: Record<LlmProvider, string> = {\n anthropic: LLM.PROVIDER.ANTHROPIC.MODEL.SMALL,\n gemini: LLM.PROVIDER.GEMINI.MODEL.SMALL,\n openai: LLM.PROVIDER.OPENAI.MODEL.SMALL,\n openrouter: LLM.PROVIDER.OPENROUTER.MODEL.SMALL,\n};\n\nconst TOTAL_PROVIDERS = 4;\n\n/**\n * Validate LLM setup without making API calls\n */\nexport function validateLlmSetup(): LlmValidationResult {\n const anthropicAvailable = Boolean(process.env.ANTHROPIC_API_KEY);\n const googleAvailable = Boolean(\n process.env.GOOGLE_API_KEY || process.env.GEMINI_API_KEY,\n );\n const openaiAvailable = Boolean(process.env.OPENAI_API_KEY);\n const openrouterAvailable = Boolean(process.env.OPENROUTER_API_KEY);\n\n const availableCount = [\n anthropicAvailable,\n googleAvailable,\n openaiAvailable,\n openrouterAvailable,\n ].filter(Boolean).length;\n\n return {\n availableCount,\n providers: {\n anthropic: { available: anthropicAvailable },\n google: { available: googleAvailable },\n openai: { available: openaiAvailable },\n openrouter: { available: openrouterAvailable },\n },\n success: availableCount > 0,\n totalProviders: TOTAL_PROVIDERS,\n };\n}\n\n/**\n * Make a debug LLM call and return the raw response data for inspection\n */\nexport async function debugLlmCall(\n params: LlmDebugCallParams,\n log: Logger,\n): Promise<LlmDebugCallResult> {\n const { provider, message } = params;\n const model = params.model || DEFAULT_MODELS[provider];\n\n log.info(`Making debug LLM call to ${provider} with model ${model}`);\n\n try {\n const llm = new Llm(provider, { model });\n\n const result = await llm.operate(message, {\n user: \"[jaypie-mcp] Debug LLM Call\",\n });\n\n if (result.error) {\n return {\n success: false,\n provider,\n model,\n error: `${result.error.title}: ${result.error.detail || \"Unknown error\"}`,\n };\n }\n\n // Calculate total reasoning tokens\n const reasoningTokens = result.usage.reduce(\n (sum, u) => sum + (u.reasoning || 0),\n 0,\n );\n\n return {\n success: true,\n provider,\n model,\n content:\n typeof result.content === \"string\"\n ? result.content\n : JSON.stringify(result.content),\n reasoning: result.reasoning,\n reasoningTokens,\n history: result.history,\n rawResponses: result.responses,\n usage: result.usage,\n };\n } catch (error) {\n log.error(`Error calling ${provider}:`, error);\n return {\n success: false,\n provider,\n model,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n}\n"],"names":[],"mappings":";;AAAA;;AAEG;AA+CH;AACA,MAAM,cAAc,GAAgC;IAClD,SAAS,EAAE,GAAG,CAAC,QAAQ,C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EAAE;QACd,GAAG,CAAC,KAAK,CAAC,CAAA,cAAA,EAAiB,QAAQ,CAAA,CAAA,CAAG,EAAE,KAAK,CAAC;QAC9C,OAAO;AACL,YAAA,OAAO,EAAE,KAAK;YACd,QAAQ;YACR,KAAK;AACL,YAAA,KAAK,EAAE,KAAK,YAAY,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC;SAC9D;IACH;AACF;;;;"}
1
+ {"version":3,"file":"llm.js","sources":["../../../src/suites/llm/llm.ts"],"sourcesContent":["/**\n * LLM debugging utilities for inspecting raw provider responses\n */\n\nimport { LLM, Llm } from \"@jaypie/llm\";\n\nexport type LlmProvider = \"anthropic\" | \"google\" | \"openai\" | \"openrouter\";\n\nexport interface LlmDebugCallParams {\n provider: LlmProvider;\n model?: string;\n message: string;\n}\n\nexport interface LlmDebugCallResult {\n success: boolean;\n provider: string;\n model: string;\n content?: string;\n reasoning?: string[];\n reasoningTokens?: number;\n history?: unknown[];\n rawResponses?: unknown[];\n usage?: unknown[];\n error?: string;\n}\n\n// Validation types\nexport interface LlmProviderStatus {\n available: boolean;\n}\n\nexport interface LlmValidationResult {\n success: boolean;\n providers: {\n anthropic: LlmProviderStatus;\n google: LlmProviderStatus;\n openai: LlmProviderStatus;\n openrouter: LlmProviderStatus;\n };\n availableCount: number;\n totalProviders: number;\n}\n\ninterface Logger {\n info: (message: string, ...args: unknown[]) => void;\n error: (message: string, ...args: unknown[]) => void;\n}\n\n/**\n * Infer provider from model string prefix\n */\nexport function inferProvider(model: string): LlmProvider | undefined {\n const m = model.toLowerCase();\n if (m.startsWith(\"claude-\")) return \"anthropic\";\n if (m.startsWith(\"gemini-\")) return \"google\";\n if (\n m.startsWith(\"chatgpt-\") ||\n m.startsWith(\"gpt-\") ||\n m.startsWith(\"o1-\") ||\n m.startsWith(\"o3-\") ||\n m.startsWith(\"o4-\")\n )\n return \"openai\";\n return undefined;\n}\n\n// Default models for each provider\nconst DEFAULT_MODELS: Record<LlmProvider, string> = {\n anthropic: LLM.PROVIDER.ANTHROPIC.MODEL.SMALL,\n google: LLM.PROVIDER.GEMINI.MODEL.SMALL,\n openai: LLM.PROVIDER.OPENAI.MODEL.SMALL,\n openrouter: LLM.PROVIDER.OPENROUTER.MODEL.SMALL,\n};\n\nconst TOTAL_PROVIDERS = 4;\n\n/**\n * Validate LLM setup without making API calls\n */\nexport function validateLlmSetup(): LlmValidationResult {\n const anthropicAvailable = Boolean(process.env.ANTHROPIC_API_KEY);\n const googleAvailable = Boolean(\n process.env.GOOGLE_API_KEY || process.env.GEMINI_API_KEY,\n );\n const openaiAvailable = Boolean(process.env.OPENAI_API_KEY);\n const openrouterAvailable = Boolean(process.env.OPENROUTER_API_KEY);\n\n const availableCount = [\n anthropicAvailable,\n googleAvailable,\n openaiAvailable,\n openrouterAvailable,\n ].filter(Boolean).length;\n\n return {\n availableCount,\n providers: {\n anthropic: { available: anthropicAvailable },\n google: { available: googleAvailable },\n openai: { available: openaiAvailable },\n openrouter: { available: openrouterAvailable },\n },\n success: availableCount > 0,\n totalProviders: TOTAL_PROVIDERS,\n };\n}\n\n/**\n * Make a debug LLM call and return the raw response data for inspection\n */\nexport async function debugLlmCall(\n params: LlmDebugCallParams,\n log: Logger,\n): Promise<LlmDebugCallResult> {\n const { provider, message } = params;\n const model = params.model || DEFAULT_MODELS[provider];\n\n log.info(`Making debug LLM call to ${provider} with model ${model}`);\n\n try {\n const llm = new Llm(provider, { model });\n\n const result = await llm.operate(message, {\n user: \"[jaypie-mcp] Debug LLM Call\",\n });\n\n if (result.error) {\n return {\n success: false,\n provider,\n model,\n error: `${result.error.title}: ${result.error.detail || \"Unknown error\"}`,\n };\n }\n\n // Calculate total reasoning tokens\n const reasoningTokens = result.usage.reduce(\n (sum, u) => sum + (u.reasoning || 0),\n 0,\n );\n\n return {\n success: true,\n provider,\n model,\n content:\n typeof result.content === \"string\"\n ? result.content\n : JSON.stringify(result.content),\n reasoning: result.reasoning,\n reasoningTokens,\n history: result.history,\n rawResponses: result.responses,\n usage: result.usage,\n };\n } catch (error) {\n log.error(`Error calling ${provider}:`, error);\n return {\n success: false,\n provider,\n model,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n}\n"],"names":[],"mappings":";;AAAA;;AAEG;AA+CH;;AAEG;AACG,SAAU,aAAa,CAAC,KAAa,EAAA;AACzC,IAAA,MAAM,CAAC,GAAG,KAAK,CAAC,WAAW,EAAE;AAC7B,IAAA,IAAI,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC;AAAE,QAAA,OAAO,WAAW;AAC/C,IAAA,IAAI,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC;AAAE,QAAA,OAAO,QAAQ;AAC5C,IAAA,IACE,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC;AACxB,QAAA,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC;AACpB,QAAA,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC;AACnB,QAAA,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC;AACnB,QAAA,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC;AAEnB,QAAA,OAAO,QAAQ;AACjB,IAAA,OAAO,SAAS;AAClB;AAEA;AACA,MAAM,cAAc,GAAgC;IAClD,SAAS,EAAE,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK;IAC7C,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK;IACvC,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK;IACvC,UAAU,EAAE,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK;CAChD;AAED,MAAM,eAAe,GAAG,CAAC;AAEzB;;AAEG;SACa,gBAAgB,GAAA;IAC9B,MAAM,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;AACjE,IAAA,MAAM,eAAe,GA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SAAA,CAAC;AAEF,QAAA,IAAI,MAAM,CAAC,KAAK,EAAE;YAChB,OAAO;AACL,gBAAA,OAAO,EAAE,KAAK;gBACd,QAAQ;gBACR,KAAK;AACL,gBAAA,KAAK,EAAE,CAAA,EAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAA,EAAA,EAAK,MAAM,CAAC,KAAK,CAAC,MAAM,IAAI,eAAe,CAAA,CAAE;aAC1E;QACH;;QAGA,MAAM,eAAe,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CACzC,CAAC,GAAG,EAAE,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,EACpC,CAAC,CACF;QAED,OAAO;AACL,YAAA,OAAO,EAAE,IAAI;YACb,QAAQ;YACR,KAAK;AACL,YAAA,OAAO,EACL,OAAO,MAAM,CAAC,OAAO,KAAK;kBACtB,MAAM,CAAC;kBACP,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC;YACpC,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,eAAe;YACf,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,YAAY,EAAE,MAAM,CAAC,SAAS;YAC9B,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB;IACH;IAAE,OAAO,KAAK,EAAE;QACd,GAAG,CAAC,KAAK,CAAC,CAAA,cAAA,EAAiB,QAAQ,CAAA,CAAA,CAAG,EAAE,KAAK,CAAC;QAC9C,OAAO;AACL,YAAA,OAAO,EAAE,KAAK;YACd,QAAQ;YACR,KAAK;AACL,YAAA,KAAK,EAAE,KAAK,YAAY,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC;SAC9D;IACH;AACF;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jaypie/mcp",
3
- "version": "0.7.26",
3
+ "version": "0.7.28",
4
4
  "description": "Jaypie MCP",
5
5
  "repository": {
6
6
  "type": "git",
@@ -0,0 +1,11 @@
1
+ ---
2
+ version: 1.2.13
3
+ date: 2026-02-23
4
+ summary: Fix Gemini provider returning code-fenced JSON when format is specified
5
+ ---
6
+
7
+ ## Changes
8
+
9
+ - Strip markdown code fences from Gemini responses before JSON parsing when `format` or `response` is specified
10
+ - Fixes `operate()` path (GeminiAdapter) and `send()` path (GeminiProvider)
11
+ - Gemini sometimes returns `` ```json\n{...}\n``` `` despite `responseMimeType: "application/json"`
@@ -0,0 +1,12 @@
1
+ ---
2
+ version: 1.2.14
3
+ date: 2026-02-23
4
+ summary: Rename Google LLM provider to "google", fix model dropped when passed as first arg
5
+ ---
6
+
7
+ ## Changes
8
+
9
+ - Canonical provider name changed from `"gemini"` to `"google"`
10
+ - `"gemini"` is still accepted as a legacy alias with a deprecation warning
11
+ - Provider auto-detection from model names continues to work (e.g., `gemini-3-pro-preview` → `"google"`)
12
+ - Fix: `new Llm("gemini-3-flash-preview")` now preserves the model instead of falling back to provider default (#213)
@@ -0,0 +1,9 @@
1
+ ---
2
+ version: 0.7.27
3
+ date: 2026-02-23
4
+ summary: Add release notes for @jaypie/llm 1.2.13
5
+ ---
6
+
7
+ ## Changes
8
+
9
+ - Add release notes for `@jaypie/llm` 1.2.13 (Gemini code-fence fix)
@@ -0,0 +1,10 @@
1
+ ---
2
+ version: 0.7.28
3
+ date: 2026-02-23
4
+ summary: LLM tool infers provider from model name, aligns on "google" provider
5
+ ---
6
+
7
+ ## Changes
8
+
9
+ - LLM `debug_call` no longer requires `provider` when model name is recognizable (e.g., `gemini-*`, `claude-*`, `gpt-*`)
10
+ - Provider name aligned to `"google"` (was `"gemini"`)
package/skills/llm.md CHANGED
@@ -23,14 +23,14 @@ console.log(response.content); // "4"
23
23
  |----------|----------------|---------------|
24
24
  | OpenAI | "openai", "gpt", /^o\d/ | gpt-5.1 |
25
25
  | Anthropic | "anthropic", "claude", "haiku", "opus", "sonnet" | claude-sonnet-4-5 |
26
- | Gemini | "gemini", "google" | gemini-3-pro-preview |
26
+ | Google | "google", "gemini" | gemini-3-pro-preview |
27
27
  | OpenRouter | "openrouter" | z-ai/glm-4.7 |
28
28
 
29
29
  ```typescript
30
30
  // Provider auto-detected from model
31
31
  await Llm.operate(input, { model: "gpt-5.1" }); // OpenAI
32
32
  await Llm.operate(input, { model: "claude-opus-4" }); // Anthropic
33
- await Llm.operate(input, { model: "gemini-3" }); // Gemini
33
+ await Llm.operate(input, { model: "gemini-3" }); // Google
34
34
  ```
35
35
 
36
36
  ## Core Methods
@@ -271,7 +271,7 @@ const llm = new Llm("anthropic", {
271
271
  model: "claude-sonnet-4",
272
272
  fallback: [
273
273
  { provider: "openai", model: "gpt-4o" },
274
- { provider: "gemini", model: "gemini-2.0-flash" },
274
+ { provider: "google", model: "gemini-2.0-flash" },
275
275
  ],
276
276
  });
277
277
 
@@ -395,7 +395,7 @@ interface LlmOperateOptions {
395
395
  }
396
396
 
397
397
  interface LlmFallbackConfig {
398
- provider: string; // Provider name (e.g., "openai", "anthropic", "gemini")
398
+ provider: string; // Provider name (e.g., "openai", "anthropic", "google")
399
399
  model?: string; // Model to use (optional, uses provider default)
400
400
  apiKey?: string; // API key (optional, uses environment variable)
401
401
  }
@@ -0,0 +1,103 @@
1
+ ---
2
+ description: Template string replacement with {{key}} syntax
3
+ related: llm, style, tests
4
+ ---
5
+
6
+ # Placeholders
7
+
8
+ Replace `{{key}}` tokens in template strings with values from a data object. Supports nested paths and function templates.
9
+
10
+ ## Import
11
+
12
+ ```typescript
13
+ import { placeholders } from "@jaypie/kit";
14
+ // or
15
+ import { placeholders } from "jaypie";
16
+ ```
17
+
18
+ ## Signature
19
+
20
+ ```typescript
21
+ function placeholders(
22
+ template: string | (() => string),
23
+ data?: Record<string, unknown>,
24
+ ): string
25
+ ```
26
+
27
+ ## Syntax
28
+
29
+ - Double curly braces: `{{key}}`
30
+ - Dot notation: `{{user.name}}`
31
+ - Bracket notation: `{{items[0].city}}`
32
+ - Whitespace trimmed: `{{ name }}` resolves same as `{{name}}`
33
+ - Unmatched keys remain: `{{missing}}` passes through unchanged
34
+
35
+ ## Examples
36
+
37
+ ```typescript
38
+ // Simple replacement
39
+ placeholders("Hello, {{name}}!", { name: "Alice" });
40
+ // "Hello, Alice!"
41
+
42
+ // Nested paths
43
+ placeholders("Email: {{user.profile.email}}", {
44
+ user: { profile: { email: "alice@example.com" } },
45
+ });
46
+ // "Email: alice@example.com"
47
+
48
+ // Array access
49
+ placeholders("First: {{items[0]}}", { items: ["alpha", "beta"] });
50
+ // "First: alpha"
51
+
52
+ // Function template (lazy evaluation)
53
+ placeholders(() => `Generated at {{time}}`, { time: "12:00" });
54
+ // "Generated at 12:00"
55
+
56
+ // Missing keys pass through
57
+ placeholders("{{known}} and {{unknown}}", { known: "yes" });
58
+ // "yes and {{unknown}}"
59
+ ```
60
+
61
+ ## LLM Integration
62
+
63
+ `@jaypie/llm` applies placeholders to `input`, `instructions`, and `system` when `data` is provided.
64
+
65
+ ```typescript
66
+ import Llm from "@jaypie/llm";
67
+
68
+ const response = await Llm.operate("Summarize {{topic}}", {
69
+ model: "claude-sonnet-4",
70
+ data: { topic: "climate change" },
71
+ system: "You are an expert on {{topic}}",
72
+ instructions: "Focus on {{aspect}}",
73
+ });
74
+ ```
75
+
76
+ ### Placeholder Control Flags
77
+
78
+ Disable substitution per-field:
79
+
80
+ ```typescript
81
+ await Llm.operate("Hello {{name}}", {
82
+ data: { name: "Alice" },
83
+ placeholders: {
84
+ input: true, // default: true
85
+ instructions: true, // default: true
86
+ system: false, // skip system prompt substitution
87
+ },
88
+ });
89
+ ```
90
+
91
+ All three default to `true` when `data` is provided.
92
+
93
+ ## Testing
94
+
95
+ Mocked automatically via `@jaypie/testkit/mock` when mocking `jaypie` or `@jaypie/kit`.
96
+
97
+ ```typescript
98
+ vi.mock("jaypie", async () => import("@jaypie/testkit/mock"));
99
+
100
+ // The mock passes through with the same signature
101
+ import { placeholders } from "jaypie";
102
+ expect(placeholders("{{x}}", { x: "y" })).toBe("y");
103
+ ```