@fro.bot/systematic 2.14.4 → 2.14.5

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 +18 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -634,6 +634,7 @@ function emptyAvailability() {
634
634
  var MAX_CACHE_FILE_BYTES = 16 * 1024 * 1024;
635
635
  var DEFAULT_API_TIMEOUT_MS = 1500;
636
636
  var MODELS_JSON_FILENAME = "models.json";
637
+ var availabilityCache = new WeakMap;
637
638
  function resolveCacheDir() {
638
639
  const xdgCacheHome = process.env.XDG_CACHE_HOME?.trim();
639
640
  const cacheBase = xdgCacheHome && path5.isAbsolute(xdgCacheHome) ? xdgCacheHome : path5.join(os2.homedir(), ".cache");
@@ -739,9 +740,19 @@ function buildSetFromProviders(providers) {
739
740
  return result;
740
741
  }
741
742
  async function getAvailableModels(client, options = {}) {
743
+ const cached = availabilityCache.get(client);
744
+ if (cached !== undefined) {
745
+ return cached;
746
+ }
747
+ const cacheAndReturn = (envelope) => {
748
+ if (envelope.status !== "unknown") {
749
+ availabilityCache.set(client, envelope);
750
+ }
751
+ return envelope;
752
+ };
742
753
  const timeoutMs = options.apiTimeoutMs === undefined ? DEFAULT_API_TIMEOUT_MS : options.apiTimeoutMs;
743
754
  if (typeof client.config?.providers !== "function") {
744
- return readFallbackCache();
755
+ return cacheAndReturn(readFallbackCache());
745
756
  }
746
757
  const apiCall = client.config.providers();
747
758
  let response;
@@ -757,24 +768,24 @@ async function getAvailableModels(client, options = {}) {
757
768
  const raced = await Promise.race([apiCall, timeoutPromise]);
758
769
  if (raced === TIMEOUT_SENTINEL) {
759
770
  console.warn(`[systematic] client.config.providers() exceeded ${timeoutMs}ms; falling back to models.json cache.`);
760
- return readFallbackCache();
771
+ return cacheAndReturn(readFallbackCache());
761
772
  }
762
773
  response = raced;
763
774
  }
764
775
  } catch {
765
- return readFallbackCache();
776
+ return cacheAndReturn(readFallbackCache());
766
777
  }
767
778
  if (response.error !== undefined || response.data === undefined) {
768
- return readFallbackCache();
779
+ return cacheAndReturn(readFallbackCache());
769
780
  }
770
781
  const models = buildSetFromProviders(response.data.providers);
771
782
  if (models.size === 0) {
772
- return emptyAvailability();
783
+ return cacheAndReturn(emptyAvailability());
773
784
  }
774
- return {
785
+ return cacheAndReturn({
775
786
  status: "api",
776
787
  models
777
- };
788
+ });
778
789
  }
779
790
 
780
791
  // src/lib/config-handler.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fro.bot/systematic",
3
- "version": "2.14.4",
3
+ "version": "2.14.5",
4
4
  "description": "Structured engineering workflows for OpenCode",
5
5
  "type": "module",
6
6
  "homepage": "https://fro.bot/systematic",