@bike4mind/cli 0.2.1-feat-cli-usage-command.16999 → 0.2.1-gh-5708.17006

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.
@@ -7,7 +7,7 @@ import {
7
7
  getSettingsMap,
8
8
  getSettingsValue,
9
9
  secureParameters
10
- } from "./chunk-U3GPYBTD.js";
10
+ } from "./chunk-32ZKFK7T.js";
11
11
  import {
12
12
  KnowledgeType,
13
13
  SupportedFabFileMimeTypes
@@ -1118,8 +1118,12 @@ var BaseBedrockBackend = class {
1118
1118
  await callback(streamedText, { inputTokens, outputTokens, toolsUsed });
1119
1119
  }
1120
1120
  } catch (error) {
1121
- console.error(`[BaseBedrockBackend] Error invoking model ${model}:`, error);
1122
1121
  if (error instanceof Error) {
1122
+ if (error.message.includes("aborted")) {
1123
+ console.log("[BaseBedrockBackend] Request aborted, skipping error logging");
1124
+ return;
1125
+ }
1126
+ console.error(`[BaseBedrockBackend] Error invoking model ${model}:`, error);
1123
1127
  console.error(`[BaseBedrockBackend] Error details:`, {
1124
1128
  name: error.name,
1125
1129
  message: error.message,
@@ -9952,7 +9956,7 @@ function shouldTriggerFallback(error) {
9952
9956
  return true;
9953
9957
  }
9954
9958
  }
9955
- if ("code" in error && error.code === "ECONNRESET") {
9959
+ if ("code" in error && error.code === "ECONNRESET" && !message.includes("aborted")) {
9956
9960
  return true;
9957
9961
  }
9958
9962
  if (error.name === "TypeError" && message.includes("terminated")) {
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  BadRequestError,
4
4
  secureParameters
5
- } from "./chunk-U3GPYBTD.js";
5
+ } from "./chunk-32ZKFK7T.js";
6
6
  import {
7
7
  GenericCreditDeductTransaction,
8
8
  ImageEditUsageTransaction,
@@ -6,7 +6,7 @@ import {
6
6
  getSettingsByNames,
7
7
  obfuscateApiKey,
8
8
  secureParameters
9
- } from "./chunk-U3GPYBTD.js";
9
+ } from "./chunk-32ZKFK7T.js";
10
10
  import {
11
11
  ApiKeyType,
12
12
  MementoTier,
@@ -2,8 +2,8 @@
2
2
  import {
3
3
  createFabFile,
4
4
  createFabFileSchema
5
- } from "./chunk-F3ETXO5N.js";
6
- import "./chunk-U3GPYBTD.js";
5
+ } from "./chunk-2JUM6JMD.js";
6
+ import "./chunk-32ZKFK7T.js";
7
7
  import "./chunk-AMDXHL6S.js";
8
8
  import "./chunk-WR6YZRQV.js";
9
9
  import "./chunk-PDX44BCA.js";
package/dist/index.js CHANGED
@@ -4,9 +4,9 @@ import {
4
4
  getEffectiveApiKey,
5
5
  getOpenWeatherKey,
6
6
  getSerperKey
7
- } from "./chunk-QXGU6KYI.js";
8
- import "./chunk-LZMRYJ3B.js";
9
- import "./chunk-F3ETXO5N.js";
7
+ } from "./chunk-ENGYJWJO.js";
8
+ import "./chunk-3WT5ANLB.js";
9
+ import "./chunk-2JUM6JMD.js";
10
10
  import {
11
11
  BFLImageService,
12
12
  BaseStorage,
@@ -15,7 +15,7 @@ import {
15
15
  OpenAIBackend,
16
16
  OpenAIImageService,
17
17
  XAIImageService
18
- } from "./chunk-U3GPYBTD.js";
18
+ } from "./chunk-32ZKFK7T.js";
19
19
  import {
20
20
  Logger
21
21
  } from "./chunk-AMDXHL6S.js";
@@ -29,7 +29,6 @@ import {
29
29
  AuthEvents,
30
30
  BFL_IMAGE_MODELS,
31
31
  BFL_SAFETY_TOLERANCE,
32
- CREDIT_DEDUCT_TRANSACTION_TYPES,
33
32
  ChatCompletionCreateInputSchema,
34
33
  ChatModels,
35
34
  CollectionType,
@@ -178,10 +177,6 @@ var COMMANDS = [
178
177
  {
179
178
  name: "trusted",
180
179
  description: "List all trusted tools"
181
- },
182
- {
183
- name: "usage",
184
- description: "Show credit usage and balance"
185
180
  }
186
181
  ];
187
182
 
@@ -8760,13 +8755,10 @@ var ApiClient = class {
8760
8755
  }
8761
8756
  };
8762
8757
 
8763
- // src/index.tsx
8764
- import { isAxiosError as isAxiosError2 } from "axios";
8765
-
8766
8758
  // package.json
8767
8759
  var package_default = {
8768
8760
  name: "@bike4mind/cli",
8769
- version: "0.2.1-feat-cli-usage-command.16999+815cdcd08",
8761
+ version: "0.2.1-gh-5708.17006+d19dd128c",
8770
8762
  type: "module",
8771
8763
  description: "Interactive CLI tool for Bike4Mind with ReAct agents",
8772
8764
  license: "UNLICENSED",
@@ -8863,10 +8855,10 @@ var package_default = {
8863
8855
  },
8864
8856
  devDependencies: {
8865
8857
  "@bike4mind/agents": "0.1.0",
8866
- "@bike4mind/common": "2.36.1-feat-cli-usage-command.16999+815cdcd08",
8867
- "@bike4mind/mcp": "1.19.4-feat-cli-usage-command.16999+815cdcd08",
8868
- "@bike4mind/services": "2.29.1-feat-cli-usage-command.16999+815cdcd08",
8869
- "@bike4mind/utils": "2.0.3-feat-cli-usage-command.16999+815cdcd08",
8858
+ "@bike4mind/common": "2.36.1-gh-5708.17006+d19dd128c",
8859
+ "@bike4mind/mcp": "1.19.4-gh-5708.17006+d19dd128c",
8860
+ "@bike4mind/services": "2.29.1-gh-5708.17006+d19dd128c",
8861
+ "@bike4mind/utils": "2.0.3-gh-5708.17006+d19dd128c",
8870
8862
  "@types/diff": "^5.0.9",
8871
8863
  "@types/jsonwebtoken": "^9.0.4",
8872
8864
  "@types/node": "^22.9.0",
@@ -8877,14 +8869,9 @@ var package_default = {
8877
8869
  tsx: "^4.21.0",
8878
8870
  typescript: "^5.9.3"
8879
8871
  },
8880
- gitHead: "815cdcd0897c92e3713ce3e04c930b70332cb318"
8872
+ gitHead: "d19dd128c3d1e13f9521f05f22dc9059e7c15194"
8881
8873
  };
8882
8874
 
8883
- // src/config/constants.ts
8884
- var USAGE_DAYS = 30;
8885
- var MODEL_NAME_COLUMN_WIDTH = 18;
8886
- var USAGE_CACHE_TTL = 5 * 60 * 1e3;
8887
-
8888
8875
  // src/index.tsx
8889
8876
  process.removeAllListeners("warning");
8890
8877
  process.on("warning", (warning) => {
@@ -8895,7 +8882,6 @@ process.on("warning", (warning) => {
8895
8882
  });
8896
8883
  var exitTimestamp = null;
8897
8884
  var EXIT_TIMEOUT_MS = 2e3;
8898
- var usageCache = null;
8899
8885
  function CliApp() {
8900
8886
  const { exit } = useApp();
8901
8887
  const [state, setState] = useState3({
@@ -9260,7 +9246,6 @@ Available commands:
9260
9246
  /login - Authenticate with your B4M account
9261
9247
  /logout - Clear authentication and sign out
9262
9248
  /whoami - Show current authenticated user
9263
- /usage - Show credit usage and balance
9264
9249
  /save <name> - Save current session
9265
9250
  /sessions - List saved sessions
9266
9251
  /config - Show configuration
@@ -9431,103 +9416,6 @@ Tool Permissions:
9431
9416
  console.log(`Expires: ${new Date(authTokens.expiresAt).toLocaleString()}`);
9432
9417
  console.log("");
9433
9418
  break;
9434
- case "usage": {
9435
- const usageAuthTokens = await state.configStore.getAuthTokens();
9436
- if (!usageAuthTokens || new Date(usageAuthTokens.expiresAt) <= /* @__PURE__ */ new Date()) {
9437
- console.log("\nNot authenticated. Run /login to authenticate.\n");
9438
- return;
9439
- }
9440
- console.log("\nFetching usage data...");
9441
- const now = Date.now();
9442
- let currentCredits;
9443
- let transactions;
9444
- if (usageCache && now - usageCache.timestamp < USAGE_CACHE_TTL) {
9445
- currentCredits = usageCache.data.currentCredits;
9446
- transactions = usageCache.data.transactions;
9447
- console.log("(using cached data)\n");
9448
- } else {
9449
- try {
9450
- const config = await state.configStore.get();
9451
- const apiBaseURL = getApiUrl(config.apiConfig);
9452
- const apiClient = new ApiClient(apiBaseURL, state.configStore);
9453
- const [identifyResponse, transactionsResponse] = await Promise.all([
9454
- apiClient.get("/api/identify"),
9455
- apiClient.get(`/api/credits/transactions?days=${USAGE_DAYS}`)
9456
- ]);
9457
- currentCredits = identifyResponse.user.currentCredits;
9458
- transactions = transactionsResponse || [];
9459
- usageCache = {
9460
- data: { currentCredits, transactions },
9461
- timestamp: now
9462
- };
9463
- } catch (error) {
9464
- if (isAxiosError2(error)) {
9465
- if (error.response?.status === 401) {
9466
- console.log("\n\u274C Authentication failed. Run /login to re-authenticate.\n");
9467
- } else if (error.response?.status === 403) {
9468
- console.log("\n\u274C Access denied. You may not have permission to view usage data.\n");
9469
- } else if (error.response?.status === 404) {
9470
- console.log("\n\u274C Usage endpoint not available on this server.\n");
9471
- } else if (error.code === "ECONNREFUSED" || error.code === "ENOTFOUND") {
9472
- console.log("\n\u274C Cannot connect to server. Check your API configuration with /api-info\n");
9473
- } else {
9474
- console.log(`
9475
- \u274C Error fetching usage data: ${error.message}
9476
- `);
9477
- }
9478
- } else if (error instanceof Error) {
9479
- console.log(`
9480
- \u274C Error: ${error.message}
9481
- `);
9482
- } else {
9483
- console.log("\n\u274C Unexpected error fetching usage data. Please try again.\n");
9484
- }
9485
- break;
9486
- }
9487
- }
9488
- const deductTransactions = transactions.filter(
9489
- (t) => CREDIT_DEDUCT_TRANSACTION_TYPES.includes(t.type)
9490
- );
9491
- const totalCreditsUsed = deductTransactions.reduce((sum2, t) => sum2 + Math.abs(t.credits), 0);
9492
- const dailyBurnRate = Math.round(totalCreditsUsed / USAGE_DAYS);
9493
- let daysRemainingStr;
9494
- if (dailyBurnRate === 0) {
9495
- daysRemainingStr = "N/A (no usage)";
9496
- } else {
9497
- const daysRemaining = Math.floor(currentCredits / dailyBurnRate);
9498
- daysRemainingStr = `~${daysRemaining.toLocaleString()} days`;
9499
- }
9500
- const usageByModel = {};
9501
- for (const t of deductTransactions) {
9502
- const modelName = t.metadata?.modelName || ("model" in t ? t.model : null) || "Unknown";
9503
- usageByModel[modelName] = (usageByModel[modelName] || 0) + Math.abs(t.credits);
9504
- }
9505
- const sortedModels = Object.entries(usageByModel).sort((a, b) => b[1] - a[1]);
9506
- console.log("\n Credit Usage Summary");
9507
- console.log("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n");
9508
- console.log(`Credits Balance: ${currentCredits.toLocaleString()}`);
9509
- console.log(`Daily Burn Rate: ${dailyBurnRate.toLocaleString()} credits/day`);
9510
- console.log(`Days Remaining: ${daysRemainingStr}`);
9511
- if (currentCredits === 0) {
9512
- console.log("\n\u26A0\uFE0F You have no credits remaining.");
9513
- console.log("\u{1F4A1} Visit bike4mind.io to purchase more credits.\n");
9514
- break;
9515
- }
9516
- if (sortedModels.length > 0) {
9517
- console.log(`
9518
- Usage by Model (Last ${USAGE_DAYS} days):`);
9519
- for (const [model, credits] of sortedModels) {
9520
- const percentage = totalCreditsUsed > 0 ? Math.round(credits / totalCreditsUsed * 100) : 0;
9521
- const paddedModel = model.padEnd(MODEL_NAME_COLUMN_WIDTH);
9522
- console.log(` ${paddedModel}${credits.toLocaleString()} credits (${percentage}%)`);
9523
- }
9524
- } else {
9525
- console.log(`
9526
- No usage data available for the last ${USAGE_DAYS} days.`);
9527
- }
9528
- console.log("");
9529
- break;
9530
- }
9531
9419
  default:
9532
9420
  console.log(`Unknown command: /${command}`);
9533
9421
  console.log("Type /help for available commands");
@@ -2,8 +2,8 @@
2
2
  import {
3
3
  findMostSimilarMemento,
4
4
  getRelevantMementos
5
- } from "./chunk-QXGU6KYI.js";
6
- import "./chunk-U3GPYBTD.js";
5
+ } from "./chunk-ENGYJWJO.js";
6
+ import "./chunk-32ZKFK7T.js";
7
7
  import "./chunk-AMDXHL6S.js";
8
8
  import "./chunk-WR6YZRQV.js";
9
9
  import "./chunk-PDX44BCA.js";
@@ -117,7 +117,7 @@ import {
117
117
  validateMermaidSyntax,
118
118
  warmUpSettingsCache,
119
119
  withRetry
120
- } from "./chunk-U3GPYBTD.js";
120
+ } from "./chunk-32ZKFK7T.js";
121
121
  import {
122
122
  Logger,
123
123
  NotificationDeduplicator,
@@ -2,8 +2,8 @@
2
2
  import {
3
3
  SubtractCreditsSchema,
4
4
  subtractCredits
5
- } from "./chunk-LZMRYJ3B.js";
6
- import "./chunk-U3GPYBTD.js";
5
+ } from "./chunk-3WT5ANLB.js";
6
+ import "./chunk-32ZKFK7T.js";
7
7
  import "./chunk-AMDXHL6S.js";
8
8
  import "./chunk-WR6YZRQV.js";
9
9
  import "./chunk-PDX44BCA.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bike4mind/cli",
3
- "version": "0.2.1-feat-cli-usage-command.16999+815cdcd08",
3
+ "version": "0.2.1-gh-5708.17006+d19dd128c",
4
4
  "type": "module",
5
5
  "description": "Interactive CLI tool for Bike4Mind with ReAct agents",
6
6
  "license": "UNLICENSED",
@@ -97,10 +97,10 @@
97
97
  },
98
98
  "devDependencies": {
99
99
  "@bike4mind/agents": "0.1.0",
100
- "@bike4mind/common": "2.36.1-feat-cli-usage-command.16999+815cdcd08",
101
- "@bike4mind/mcp": "1.19.4-feat-cli-usage-command.16999+815cdcd08",
102
- "@bike4mind/services": "2.29.1-feat-cli-usage-command.16999+815cdcd08",
103
- "@bike4mind/utils": "2.0.3-feat-cli-usage-command.16999+815cdcd08",
100
+ "@bike4mind/common": "2.36.1-gh-5708.17006+d19dd128c",
101
+ "@bike4mind/mcp": "1.19.4-gh-5708.17006+d19dd128c",
102
+ "@bike4mind/services": "2.29.1-gh-5708.17006+d19dd128c",
103
+ "@bike4mind/utils": "2.0.3-gh-5708.17006+d19dd128c",
104
104
  "@types/diff": "^5.0.9",
105
105
  "@types/jsonwebtoken": "^9.0.4",
106
106
  "@types/node": "^22.9.0",
@@ -111,5 +111,5 @@
111
111
  "tsx": "^4.21.0",
112
112
  "typescript": "^5.9.3"
113
113
  },
114
- "gitHead": "815cdcd0897c92e3713ce3e04c930b70332cb318"
114
+ "gitHead": "d19dd128c3d1e13f9521f05f22dc9059e7c15194"
115
115
  }