@love-moon/ai-sdk 0.2.34 → 0.2.36

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.
@@ -4,27 +4,35 @@ import { loadEnvConfig } from "./shared.js";
4
4
  const BUILT_IN_BACKENDS = new Set(["codex", "claude", "kimi", "opencode"]);
5
5
  const registryPromises = new Map();
6
6
  let externalProviderImportNonce = 0;
7
- function normalizeProviderPathEnv(value) {
8
- return String(value || "").trim();
9
- }
10
- function listProviderModulePathsFromValue(rawValue) {
11
- const raw = normalizeProviderPathEnv(rawValue);
7
+ function appendProviderModulePaths(parts, value) {
8
+ if (Array.isArray(value)) {
9
+ for (const entry of value) {
10
+ appendProviderModulePaths(parts, entry);
11
+ }
12
+ return;
13
+ }
14
+ const raw = String(value || "").trim();
12
15
  if (!raw) {
13
- return [];
16
+ return;
14
17
  }
15
- const parts = raw
16
- .split(process.platform === "win32" ? ";" : ":")
17
- .map((item) => item.trim())
18
- .filter(Boolean);
18
+ for (const item of raw.split(process.platform === "win32" ? ";" : ":")) {
19
+ const normalized = item.trim();
20
+ if (normalized) {
21
+ parts.push(normalized);
22
+ }
23
+ }
24
+ }
25
+ function listProviderModulePathsFromValue(rawValue) {
26
+ const parts = [];
27
+ appendProviderModulePaths(parts, rawValue);
19
28
  return [...new Set(parts)];
20
29
  }
21
- function resolveProviderPathEnv(options = {}) {
22
- const envValue = normalizeProviderPathEnv(process.env.AISDK_PROVIDER_PATH);
23
- if (envValue) {
24
- return envValue;
25
- }
30
+ function resolveProviderModulePaths(options = {}) {
26
31
  const envConfig = loadEnvConfig(options.configFile);
27
- return normalizeProviderPathEnv(envConfig?.AISDK_PROVIDER_PATH);
32
+ return [
33
+ ...listProviderModulePathsFromValue(process.env.AISDK_PROVIDER_PATH),
34
+ ...listProviderModulePathsFromValue(envConfig?.AISDK_PROVIDER_PATH),
35
+ ].filter((value, index, array) => array.indexOf(value) === index);
28
36
  }
29
37
  function normalizeName(value) {
30
38
  return String(value || "").trim().toLowerCase();
@@ -111,15 +119,16 @@ async function loadRegistry(modulePaths) {
111
119
  return registry;
112
120
  }
113
121
  export async function getExternalProviderRegistry(options = {}) {
114
- const providerPathEnv = resolveProviderPathEnv(options);
115
- if (!registryPromises.has(providerPathEnv)) {
116
- const loadPromise = loadRegistry(listProviderModulePathsFromValue(providerPathEnv)).catch((error) => {
117
- registryPromises.delete(providerPathEnv);
122
+ const modulePaths = resolveProviderModulePaths(options);
123
+ const cacheKey = modulePaths.join("\0");
124
+ if (!registryPromises.has(cacheKey)) {
125
+ const loadPromise = loadRegistry(modulePaths).catch((error) => {
126
+ registryPromises.delete(cacheKey);
118
127
  throw error;
119
128
  });
120
- registryPromises.set(providerPathEnv, loadPromise);
129
+ registryPromises.set(cacheKey, loadPromise);
121
130
  }
122
- return registryPromises.get(providerPathEnv);
131
+ return registryPromises.get(cacheKey);
123
132
  }
124
133
  export async function resolveExternalBackend(backend, options = {}) {
125
134
  const normalized = normalizeName(backend);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@love-moon/ai-sdk",
3
- "version": "0.2.34",
3
+ "version": "0.2.36",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -25,5 +25,5 @@
25
25
  "@types/node": "^22.10.2",
26
26
  "typescript": "^5.6.3"
27
27
  },
28
- "gitCommitId": "c3c936c"
28
+ "gitCommitId": "54d9de4"
29
29
  }