@larkup/cli 0.3.20 → 0.3.22

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 (44) hide show
  1. package/dist/{analytics-store-4EI56OLE.js → analytics-store-6SZQ7JBE.js} +1 -1
  2. package/dist/bowser-KBMRPWZW.js +2100 -0
  3. package/dist/{chunk-CUA3FHFQ.js → chunk-3HURSQNH.js} +39 -26
  4. package/dist/{chunk-AKBEY3S4.js → chunk-4Y7OLVDR.js} +4 -4
  5. package/dist/{chunk-YOPP3ETL.js → chunk-5LXQQ3B5.js} +111 -80
  6. package/dist/{chunk-2QWAEE6L.js → chunk-5UNSW2YQ.js} +2 -2
  7. package/dist/{chunk-HYYSI5FE.js → chunk-5YXDD2GC.js} +183 -174
  8. package/dist/{chunk-ZH2A3TFQ.js → chunk-CQRTVM3R.js} +99 -1154
  9. package/dist/{chunk-54YIZOXQ.js → chunk-G4JLV4D2.js} +58 -26
  10. package/dist/chunk-G542PEOG.js +215 -0
  11. package/dist/chunk-JKTTCUZ3.js +653 -0
  12. package/dist/chunk-M4T7TRRC.js +2461 -0
  13. package/dist/chunk-MEKWGOS5.js +76 -0
  14. package/dist/{chunk-6VBJAFWY.js → chunk-MTXSOKLF.js} +97 -77
  15. package/dist/chunk-NMIRIGDS.js +1445 -0
  16. package/dist/chunk-SUBMQE2G.js +1280 -0
  17. package/dist/{chunk-SMQUSHD4.js → chunk-TBMEIDA5.js} +39 -2
  18. package/dist/{chunk-FMBWCTFV.js → chunk-TEVXZRMI.js} +1222 -87
  19. package/dist/{chunk-VZAREDRR.js → chunk-TX2W2TDD.js} +3 -3
  20. package/dist/{chunk-6HRBZ7QP.js → chunk-VMIDDBSU.js} +3 -3
  21. package/dist/{chunk-DTRGAEFR.js → chunk-YL567TPU.js} +4 -4
  22. package/dist/{dist-es-CM7567P2.js → dist-es-64SQQSB2.js} +8 -8
  23. package/dist/{dist-es-DC3KLBPR.js → dist-es-EYJKNFZZ.js} +9 -9
  24. package/dist/{dist-es-PY4YS7TC.js → dist-es-GCJ2YN2W.js} +12 -9
  25. package/dist/{dist-es-KY7QTIEX.js → dist-es-HOKTEA4H.js} +22 -22
  26. package/dist/{dist-es-ZDCXFYRX.js → dist-es-I5PEXU6M.js} +5 -5
  27. package/dist/{dist-es-IS5PH45I.js → dist-es-IBDQOMV4.js} +67 -43
  28. package/dist/{dist-es-M6OXVHSI.js → dist-es-KLJ57YTV.js} +2 -2
  29. package/dist/{dist-es-3SVFRI6P.js → dist-es-RSHHKZQR.js} +251 -237
  30. package/dist/{dist-es-OB4H2RSG.js → dist-es-SM3XZOJI.js} +10 -10
  31. package/dist/{dist-es-FEVR73CQ.js → dist-es-WKOKSFRW.js} +8 -8
  32. package/dist/{chunk-PFTSXAZG.js → event-streams-DE7Y6VJA.js} +59 -40
  33. package/dist/{event-streams-KOWL2S4G.js → event-streams-DO25HTN4.js} +2 -3
  34. package/dist/index.js +22 -27
  35. package/dist/{loadSso-OLMNBQ4H.js → loadSso-RBMT5EPI.js} +68 -62
  36. package/dist/{signin-NBTUJ5KD.js → signin-S7FYOH5Y.js} +79 -66
  37. package/dist/{sso-oidc-WNK6HQX7.js → sso-oidc-YVLODDDB.js} +71 -65
  38. package/dist/{sts-TGY2Y4DZ.js → sts-R6CUYWGQ.js} +77 -71
  39. package/dist/{tool-loader-GFMXFTMW.js → tool-loader-ZRVSMB4T.js} +2 -2
  40. package/dist/{tool-registry-K74GICK5.js → tool-registry-FLO7V4FK.js} +1 -1
  41. package/package.json +13 -13
  42. package/dist/bowser-GZLEN3PD.js +0 -2821
  43. package/dist/chunk-GYXT77I3.js +0 -515
  44. package/dist/chunk-TFGGCUFR.js +0 -126
@@ -6899,6 +6899,43 @@ var ALL_MODELS = [
6899
6899
  }
6900
6900
  ];
6901
6901
 
6902
+ // ../../packages/core/src/models-cache.ts
6903
+ var cachedModels;
6904
+ var refreshedAt = 0;
6905
+ var pendingRefresh;
6906
+ var CACHE_TTL_MS = 5 * 6e4;
6907
+ async function loadGatewayModels(fetcher = fetch) {
6908
+ const response = await fetcher("https://ai-gateway.vercel.sh/v1/models", {
6909
+ signal: AbortSignal.timeout(3e3)
6910
+ });
6911
+ if (!response.ok) throw new Error(`Model catalog unavailable (${response.status}).`);
6912
+ const payload = await response.json();
6913
+ if (!Array.isArray(payload.data)) throw new Error("Invalid model catalog.");
6914
+ const models = payload.data.filter(
6915
+ (model) => model && typeof model.id === "string" && typeof model.name === "string" && typeof model.owned_by === "string" && typeof model.type === "string"
6916
+ );
6917
+ if (!models.some((model) => model.type === "language")) throw new Error("Empty model catalog.");
6918
+ return models;
6919
+ }
6920
+ async function getAllModels() {
6921
+ if (cachedModels && Date.now() - refreshedAt < CACHE_TTL_MS) return cachedModels;
6922
+ if (!pendingRefresh)
6923
+ pendingRefresh = loadGatewayModels().then((models) => {
6924
+ cachedModels = models;
6925
+ refreshedAt = Date.now();
6926
+ return models;
6927
+ }).catch(() => {
6928
+ refreshedAt = Date.now();
6929
+ return cachedModels ?? (cachedModels = ALL_MODELS);
6930
+ }).finally(() => {
6931
+ pendingRefresh = void 0;
6932
+ });
6933
+ return pendingRefresh;
6934
+ }
6935
+ function getCachedGatewayModel(modelId) {
6936
+ return cachedModels?.find((model) => model.id === modelId) ?? ALL_MODELS.find((model) => model.id === modelId);
6937
+ }
6938
+
6902
6939
  // ../../packages/core/src/analytics-store.ts
6903
6940
  var writeChain2 = Promise.resolve();
6904
6941
  function serialize2(fn) {
@@ -6941,7 +6978,7 @@ function trackUsageEvent(event) {
6941
6978
  }
6942
6979
  function estimateCost(modelId, promptTokens, completionTokens) {
6943
6980
  if (modelId.startsWith("custom:")) return 0;
6944
- const model = ALL_MODELS.find((m) => m.id === modelId);
6981
+ const model = getCachedGatewayModel(modelId);
6945
6982
  if (!model || !model.pricing) return 0;
6946
6983
  const inputPrice = parseFloat(model.pricing.input || "0");
6947
6984
  const outputPrice = parseFloat(model.pricing.output || "0");
@@ -7050,7 +7087,7 @@ export {
7050
7087
  createProject,
7051
7088
  setActiveProject,
7052
7089
  resetLocalProjects,
7053
- ALL_MODELS,
7090
+ getAllModels,
7054
7091
  readUsageEvents,
7055
7092
  trackUsageEvent,
7056
7093
  estimateCost,