@~lyre/ai-agents 0.4.0 → 0.5.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 +10 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -60,6 +60,12 @@ var PROVIDERS = {
60
60
  // Grok
61
61
  google: (apiKey, id) => createGoogleGenerativeAI({ apiKey })(id)
62
62
  };
63
+ var PROVIDER_ENV = {
64
+ anthropic: "ANTHROPIC_API_KEY",
65
+ openai: "OPENAI_API_KEY",
66
+ xai: "XAI_API_KEY",
67
+ google: "GOOGLE_GENERATIVE_AI_API_KEY"
68
+ };
63
69
  var SUPPORTED_PROVIDERS = Object.keys(PROVIDERS);
64
70
  function resolveModelString(model, apiKey) {
65
71
  const slash = model.indexOf("/");
@@ -67,7 +73,10 @@ function resolveModelString(model, apiKey) {
67
73
  const provider = model.slice(0, slash);
68
74
  const modelId = model.slice(slash + 1);
69
75
  const factory = PROVIDERS[provider];
70
- if (factory && apiKey && modelId) return factory(apiKey, modelId);
76
+ if (!factory || !modelId) return model;
77
+ const envKey = typeof process !== "undefined" ? process.env?.[PROVIDER_ENV[provider]] : void 0;
78
+ const key = envKey || apiKey;
79
+ if (key) return factory(key, modelId);
71
80
  return model;
72
81
  }
73
82
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@~lyre/ai-agents",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Multi-provider AI agents SDK for SvelteKit + Node. Thin agent/tool/run/runStream surface over the Vercel AI SDK — OpenAI, Anthropic, Google Gemini, Mistral, Cohere. Zod-typed tools, full streaming event surface, optional HTML sanitizer.",
5
5
  "type": "module",
6
6
  "sideEffects": false,