@jvittechs/jai1-cli 0.1.74 → 0.1.75

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.
package/dist/cli.js CHANGED
@@ -33,7 +33,7 @@ var NetworkError = class extends Jai1Error {
33
33
  // package.json
34
34
  var package_default = {
35
35
  name: "@jvittechs/jai1-cli",
36
- version: "0.1.74",
36
+ version: "0.1.75",
37
37
  description: "A unified CLI tool for JV-IT TECHS developers to manage Jai1 Framework. Please contact TeamAI for usage instructions.",
38
38
  type: "module",
39
39
  bin: {
@@ -1451,7 +1451,7 @@ var IDEOverviewView = ({
1451
1451
  }
1452
1452
  }, { isActive: true });
1453
1453
  const currentTab = tabs[selectedTabIndex];
1454
- const currentItems = currentTab ? ideContext.items.filter((item) => item.type === currentTab.type) : [];
1454
+ const currentItems = currentTab ? ideContext?.items?.filter((item) => item.type === currentTab.type) ?? [] : [];
1455
1455
  const formatSize = (bytes) => {
1456
1456
  if (bytes < 1024) return `${bytes}B`;
1457
1457
  if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)}KB`;
@@ -1998,7 +1998,7 @@ var ContextApp = ({ initialIDE, initialType, onExit }) => {
1998
1998
  setScrollPosition(0);
1999
1999
  };
2000
2000
  const currentIDEContext = ideContexts.find((ctx) => ctx.ide === selectedIDE);
2001
- const currentItems = currentIDEContext?.items.filter((item) => item.type === selectedType) || [];
2001
+ const currentItems = currentIDEContext?.items?.filter((item) => item.type === selectedType) ?? [];
2002
2002
  const renderContent = () => {
2003
2003
  if (loading) {
2004
2004
  return /* @__PURE__ */ React9.createElement(Box7, { padding: 1 }, /* @__PURE__ */ React9.createElement(Text8, null, "\u0110ang qu\xE9t context..."));
@@ -3742,7 +3742,8 @@ var LlmProxyService = class {
3742
3742
  if (!response.ok) {
3743
3743
  throw new Error(`Failed to fetch models: ${response.statusText}`);
3744
3744
  }
3745
- return response.json();
3745
+ const result = await response.json();
3746
+ return result ?? { data: [] };
3746
3747
  }
3747
3748
  /**
3748
3749
  * Fetch user limits
@@ -3757,7 +3758,7 @@ var LlmProxyService = class {
3757
3758
  throw new Error(`Failed to fetch limits: ${response.statusText}`);
3758
3759
  }
3759
3760
  const result = await response.json();
3760
- return result.data;
3761
+ return result?.data ?? { allowedModels: [], rateLimits: {} };
3761
3762
  }
3762
3763
  /**
3763
3764
  * Fetch usage statistics
@@ -3771,7 +3772,8 @@ var LlmProxyService = class {
3771
3772
  if (!response.ok) {
3772
3773
  throw new Error(`Failed to fetch usage: ${response.statusText}`);
3773
3774
  }
3774
- return response.json();
3775
+ const result = await response.json();
3776
+ return result ?? { data: [] };
3775
3777
  }
3776
3778
  /**
3777
3779
  * Get models with usage information
@@ -3784,12 +3786,14 @@ var LlmProxyService = class {
3784
3786
  // Today only
3785
3787
  ]);
3786
3788
  const today = (/* @__PURE__ */ new Date()).toLocaleDateString("en-CA", { timeZone: "Asia/Ho_Chi_Minh" });
3787
- return modelsRes.data.map((model) => {
3788
- const allowed = limits.allowedModels.includes(model.id);
3789
- const dailyLimit = limits.rateLimits[model.id] ?? limits.rateLimits[model.id.toLowerCase()];
3790
- const usageRecord = usage.data.find(
3789
+ const modelsData = modelsRes.data ?? [];
3790
+ return modelsData.map((model) => {
3791
+ const allowed = limits.allowedModels?.includes(model.id) ?? false;
3792
+ const dailyLimit = limits.rateLimits?.[model.id] ?? limits.rateLimits?.[model.id.toLowerCase()];
3793
+ const usageData = usage.data ?? [];
3794
+ const usageRecord = usageData.find(
3791
3795
  (u) => u.model === model.id && u.date === today
3792
- ) || usage.data.find(
3796
+ ) || usageData.find(
3793
3797
  (u) => u.model.toLowerCase() === model.id.toLowerCase() && u.date === today
3794
3798
  );
3795
3799
  const usedToday = usageRecord?.count || 0;