ai-speedometer 2.3.2 → 2.3.4

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/ai-speedometer +81 -40
  2. package/package.json +2 -2
@@ -1,9 +1,4 @@
1
- #!/bin/sh -
2
- ':'; /*-
3
- test1=$(bun --version 2>&1) && exec bun "$0" "$@"
4
- test2=$(node --version 2>&1) && exec node "$0" "$@"
5
- exec printf '%s\n' "$test1" "$test2" 1>&2
6
- */
1
+ #!/usr/bin/env bun
7
2
  // @bun
8
3
  var __defProp = Object.defineProperty;
9
4
  var __returnValue = (v) => v;
@@ -22,6 +17,28 @@ var __export = (target, all) => {
22
17
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
23
18
  var __require = import.meta.require;
24
19
 
20
+ // ../../node_modules/.bun/xdg-basedir@5.1.0/node_modules/xdg-basedir/index.js
21
+ import os from "os";
22
+ import path from "path";
23
+ var homeDirectory, env, xdgData, xdgConfig, xdgState, xdgCache, xdgRuntime, xdgDataDirectories, xdgConfigDirectories;
24
+ var init_xdg_basedir = __esm(() => {
25
+ homeDirectory = os.homedir();
26
+ ({ env } = process);
27
+ xdgData = env.XDG_DATA_HOME || (homeDirectory ? path.join(homeDirectory, ".local", "share") : undefined);
28
+ xdgConfig = env.XDG_CONFIG_HOME || (homeDirectory ? path.join(homeDirectory, ".config") : undefined);
29
+ xdgState = env.XDG_STATE_HOME || (homeDirectory ? path.join(homeDirectory, ".local", "state") : undefined);
30
+ xdgCache = env.XDG_CACHE_HOME || (homeDirectory ? path.join(homeDirectory, ".cache") : undefined);
31
+ xdgRuntime = env.XDG_RUNTIME_DIR || undefined;
32
+ xdgDataDirectories = (env.XDG_DATA_DIRS || "/usr/local/share/:/usr/share/").split(":");
33
+ if (xdgData) {
34
+ xdgDataDirectories.unshift(xdgData);
35
+ }
36
+ xdgConfigDirectories = (env.XDG_CONFIG_DIRS || "/etc/xdg").split(":");
37
+ if (xdgConfig) {
38
+ xdgConfigDirectories.unshift(xdgConfig);
39
+ }
40
+ });
41
+
25
42
  // ../core/custom-verified-providers.json
26
43
  var custom_verified_providers_default;
27
44
  var init_custom_verified_providers = __esm(() => {
@@ -160,8 +177,8 @@ __export(exports_models_dev, {
160
177
  clearCache: () => clearCache
161
178
  });
162
179
  import fs from "fs";
163
- import path from "path";
164
- import { homedir } from "os";
180
+ import path2 from "path";
181
+ import { homedir as homedir2 } from "os";
165
182
  function ensureCacheDir() {
166
183
  try {
167
184
  if (!fs.existsSync(CACHE_DIR)) {
@@ -212,7 +229,7 @@ async function fetchFromAPI() {
212
229
  }
213
230
  function getCustomProvidersJson() {
214
231
  let data = custom_verified_providers_default;
215
- const customProvidersPath = path.join(process.cwd(), "custom-verified-providers.json");
232
+ const customProvidersPath = path2.join(process.cwd(), "custom-verified-providers.json");
216
233
  if (fs.existsSync(customProvidersPath)) {
217
234
  try {
218
235
  data = JSON.parse(fs.readFileSync(customProvidersPath, "utf8"));
@@ -349,11 +366,13 @@ function clearCache() {
349
366
  console.warn("Warning: Could not clear cache:", error.message);
350
367
  }
351
368
  }
352
- var CACHE_DIR, CACHE_FILE, FALLBACK_PROVIDERS;
369
+ var cacheBase, CACHE_DIR, CACHE_FILE, FALLBACK_PROVIDERS;
353
370
  var init_models_dev = __esm(() => {
371
+ init_xdg_basedir();
354
372
  init_custom_verified_providers();
355
- CACHE_DIR = path.join(homedir(), ".cache", "ai-speedometer");
356
- CACHE_FILE = path.join(CACHE_DIR, "models.json");
373
+ cacheBase = process.env.XDG_CACHE_HOME || xdgCache || path2.join(homedir2(), ".cache");
374
+ CACHE_DIR = path2.join(cacheBase, "ai-speedometer");
375
+ CACHE_FILE = path2.join(CACHE_DIR, "models.json");
357
376
  FALLBACK_PROVIDERS = [
358
377
  {
359
378
  id: "openai",
@@ -413,15 +432,15 @@ __export(exports_ai_config, {
413
432
  addCustomProvider: () => addCustomProvider
414
433
  });
415
434
  import fs2 from "fs";
416
- import path2 from "path";
417
- import { homedir as homedir2 } from "os";
435
+ import path3 from "path";
436
+ import { homedir as homedir3 } from "os";
418
437
  var getAIConfigPaths = () => {
419
- const aiConfigDir = process.env.XDG_CONFIG_HOME || path2.join(homedir2(), ".config");
420
- const aiSpeedometerConfigDir = path2.join(aiConfigDir, "ai-speedometer");
438
+ const aiConfigDir = process.env.XDG_CONFIG_HOME || xdgConfig || path3.join(homedir3(), ".config");
439
+ const aiSpeedometerConfigDir = path3.join(aiConfigDir, "ai-speedometer");
421
440
  return {
422
441
  configDir: aiSpeedometerConfigDir,
423
- configJson: path2.join(aiSpeedometerConfigDir, "ai-benchmark-config.json"),
424
- recentModelsCache: path2.join(aiSpeedometerConfigDir, "recent-models.json")
442
+ configJson: path3.join(aiSpeedometerConfigDir, "ai-benchmark-config.json"),
443
+ recentModelsCache: path3.join(aiSpeedometerConfigDir, "recent-models.json")
425
444
  };
426
445
  }, ensureAIConfigDirectory = () => {
427
446
  const { configDir } = getAIConfigPaths();
@@ -569,7 +588,9 @@ var getAIConfigPaths = () => {
569
588
  const paths = getAIConfigPaths();
570
589
  return { ...paths, configExists: fs2.existsSync(paths.configJson) };
571
590
  };
572
- var init_ai_config = () => {};
591
+ var init_ai_config = __esm(() => {
592
+ init_xdg_basedir();
593
+ });
573
594
 
574
595
  // ../../node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/scanner.js
575
596
  function createScanner(text, ignoreTrivia = false) {
@@ -1418,16 +1439,15 @@ __export(exports_opencode_integration, {
1418
1439
  addApiKey: () => addApiKey
1419
1440
  });
1420
1441
  import fs3 from "fs";
1421
- import path3 from "path";
1422
- import { homedir as homedir3 } from "os";
1442
+ import path4 from "path";
1423
1443
  var getXDGPaths = () => ({
1424
- data: path3.join(process.env.XDG_DATA_HOME || path3.join(homedir3(), ".local", "share"), "opencode"),
1425
- config: path3.join(process.env.XDG_CONFIG_HOME || path3.join(homedir3(), ".config"), "opencode")
1444
+ data: path4.join(process.env.XDG_DATA_HOME || xdgData || path4.join(path4.join(process.env.HOME || process.env.USERPROFILE || "."), ".local", "share"), "opencode"),
1445
+ config: path4.join(process.env.XDG_CONFIG_HOME || xdgConfig || path4.join(path4.join(process.env.HOME || process.env.USERPROFILE || "."), ".config"), "opencode")
1426
1446
  }), getFilePaths = () => {
1427
1447
  const paths = getXDGPaths();
1428
1448
  return {
1429
- authJson: path3.join(paths.data, "auth.json"),
1430
- opencodeJson: path3.join(paths.config, "opencode.json")
1449
+ authJson: path4.join(paths.data, "auth.json"),
1450
+ opencodeJson: path4.join(paths.config, "opencode.json")
1431
1451
  };
1432
1452
  }, ensureDirectories = () => {
1433
1453
  const paths = getXDGPaths();
@@ -1457,7 +1477,9 @@ var getXDGPaths = () => ({
1457
1477
  try {
1458
1478
  ensureDirectories();
1459
1479
  fs3.writeFileSync(authJson, JSON.stringify(authData, null, 2));
1460
- fs3.chmodSync(authJson, 384);
1480
+ try {
1481
+ fs3.chmodSync(authJson, 384);
1482
+ } catch {}
1461
1483
  return true;
1462
1484
  } catch (error) {
1463
1485
  console.error("Error writing auth.json:", error.message);
@@ -1470,11 +1492,11 @@ var getXDGPaths = () => ({
1470
1492
  console.warn("Warning: opencode.json is no longer used. Use ai-benchmark-config.json instead.");
1471
1493
  return { provider: {} };
1472
1494
  }, readOpencodeGlobalConfig = () => {
1473
- const configDir = path3.join(process.env.XDG_CONFIG_HOME || path3.join(homedir3(), ".config"), "opencode");
1495
+ const configDir = path4.join(process.env.XDG_CONFIG_HOME || path4.join(homedir(), ".config"), "opencode");
1474
1496
  const candidates = ["config.json", "opencode.json", "opencode.jsonc"];
1475
1497
  let merged = {};
1476
1498
  for (const filename of candidates) {
1477
- const filePath = path3.join(configDir, filename);
1499
+ const filePath = path4.join(configDir, filename);
1478
1500
  try {
1479
1501
  if (!fs3.existsSync(filePath))
1480
1502
  continue;
@@ -1712,6 +1734,7 @@ var getXDGPaths = () => ({
1712
1734
  };
1713
1735
  };
1714
1736
  var init_opencode_integration = __esm(() => {
1737
+ init_xdg_basedir();
1715
1738
  init_models_dev();
1716
1739
  init_ai_config();
1717
1740
  init_main();
@@ -1719,6 +1742,7 @@ var init_opencode_integration = __esm(() => {
1719
1742
 
1720
1743
  // ../core/src/constants.ts
1721
1744
  import { execSync } from "child_process";
1745
+ import { readFileSync } from "fs";
1722
1746
  function getOpencodeSystemPrompt(modelId) {
1723
1747
  const mid = modelId.toLowerCase();
1724
1748
  if (mid.includes("gpt-4") || mid.includes("o1") || mid.includes("o3"))
@@ -1759,10 +1783,10 @@ function getOpencodeVersion() {
1759
1783
  return v;
1760
1784
  } catch {
1761
1785
  try {
1762
- return execSync(`grep -E '^\\s*"version"' /home/idc/proj/opencode/packages/opencode/package.json | sed 's/.*: "\\([^"]*\\)".*/\\1/'`, {
1763
- encoding: "utf8",
1764
- stdio: ["ignore", "pipe", "ignore"]
1765
- }).trim();
1786
+ const pkgJson = readFileSync("/home/idc/proj/opencode/packages/opencode/package.json", "utf8");
1787
+ const parsed = JSON.parse(pkgJson);
1788
+ if (parsed.version)
1789
+ return parsed.version;
1766
1790
  } catch {}
1767
1791
  }
1768
1792
  return "1.14.37";
@@ -2864,7 +2888,6 @@ async function benchmarkSingleModelRest(model, logger) {
2864
2888
  model: actualModelId,
2865
2889
  messages: [...systemMessages, userMessage],
2866
2890
  max_tokens: 500,
2867
- temperature: 0.7,
2868
2891
  stream: true,
2869
2892
  stream_options: { include_usage: true },
2870
2893
  tools,
@@ -2875,7 +2898,7 @@ async function benchmarkSingleModelRest(model, logger) {
2875
2898
  { parts: systemMessages.map((m) => ({ text: m.content })) },
2876
2899
  { parts: [{ text: userMessage.content }] }
2877
2900
  ];
2878
- body["generationConfig"] = { maxOutputTokens: 500, temperature: 0.7 };
2901
+ body["generationConfig"] = { maxOutputTokens: 500 };
2879
2902
  delete body["messages"];
2880
2903
  delete body["max_tokens"];
2881
2904
  delete body["stream"];
@@ -2884,6 +2907,7 @@ async function benchmarkSingleModelRest(model, logger) {
2884
2907
  delete body["tool_choice"];
2885
2908
  } else if (model.providerType === "anthropic") {
2886
2909
  delete body["stream_options"];
2910
+ body["tool_choice"] = { type: "auto" };
2887
2911
  body["system"] = systemMessages.map((m) => m.content).join(`
2888
2912
 
2889
2913
  `);
@@ -2897,11 +2921,24 @@ async function benchmarkSingleModelRest(model, logger) {
2897
2921
  };
2898
2922
  });
2899
2923
  }
2900
- const response = await fetch(url, {
2924
+ let response = await fetch(url, {
2901
2925
  method: "POST",
2902
2926
  headers,
2903
2927
  body: JSON.stringify(body)
2904
2928
  });
2929
+ if (!response.ok && (response.status === 400 || response.status === 422)) {
2930
+ const errText = await response.text();
2931
+ if (errText.includes("2013") || errText.includes("invalid params") || errText.includes("invalid chat setting")) {
2932
+ delete body["tools"];
2933
+ delete body["tool_choice"];
2934
+ delete body["stream_options"];
2935
+ response = await fetch(url, {
2936
+ method: "POST",
2937
+ headers,
2938
+ body: JSON.stringify(body)
2939
+ });
2940
+ }
2941
+ }
2905
2942
  if (!response.ok) {
2906
2943
  const errBody = await response.text();
2907
2944
  let errDetail = "";
@@ -3274,11 +3311,13 @@ function createRunId() {
3274
3311
  return generateRunId();
3275
3312
  }
3276
3313
  function getLogPath(runId) {
3277
- return join(homedir4(), ".local", "share", "ai-speedometer", "logs", `${runId}.log`);
3314
+ const baseDir = process.env.XDG_DATA_HOME || xdgData || join(homedir4(), ".local", "share");
3315
+ return join(baseDir, "ai-speedometer", "logs", `${runId}.log`);
3278
3316
  }
3279
3317
  async function createBenchLogger(runId) {
3280
3318
  const logPath = getLogPath(runId);
3281
- const logDir = join(homedir4(), ".local", "share", "ai-speedometer", "logs");
3319
+ const baseDir = process.env.XDG_DATA_HOME || xdgData || join(homedir4(), ".local", "share");
3320
+ const logDir = join(baseDir, "ai-speedometer", "logs");
3282
3321
  await mkdir(logDir, { recursive: true });
3283
3322
  let currentApiKey = "";
3284
3323
  let buffer = "";
@@ -3306,7 +3345,9 @@ async function createBenchLogger(runId) {
3306
3345
  }
3307
3346
  };
3308
3347
  }
3309
- var init_logger = () => {};
3348
+ var init_logger = __esm(() => {
3349
+ init_xdg_basedir();
3350
+ });
3310
3351
 
3311
3352
  // src/tui/context/AppContext.tsx
3312
3353
  import { createContext, useContext, useReducer, useEffect } from "react";
@@ -4131,7 +4172,7 @@ var package_default;
4131
4172
  var init_package = __esm(() => {
4132
4173
  package_default = {
4133
4174
  name: "ai-speedometer",
4134
- version: "2.3.2",
4175
+ version: "2.3.4",
4135
4176
  description: "A comprehensive CLI tool for benchmarking AI models across multiple providers with parallel execution and professional metrics",
4136
4177
  bin: {
4137
4178
  "ai-speedometer": "dist/ai-speedometer",
@@ -4143,7 +4184,7 @@ var init_package = __esm(() => {
4143
4184
  scripts: {
4144
4185
  start: "bun src/index.ts",
4145
4186
  dev: "bun --watch src/index.ts",
4146
- build: "bun build src/index.ts --outdir dist --target bun --external '@opentui/core' --external '@opentui/react' --external 'react' --external 'react-reconciler' && cat ../../scripts/shebang dist/index.js > dist/ai-speedometer && chmod +x dist/ai-speedometer && rm dist/index.js",
4187
+ build: "node ../../scripts/build-tui.mjs",
4147
4188
  typecheck: "bun tsc --noEmit",
4148
4189
  prepublishOnly: "bun run build"
4149
4190
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-speedometer",
3
- "version": "2.3.2",
3
+ "version": "2.3.4",
4
4
  "description": "A comprehensive CLI tool for benchmarking AI models across multiple providers with parallel execution and professional metrics",
5
5
  "bin": {
6
6
  "ai-speedometer": "dist/ai-speedometer",
@@ -12,7 +12,7 @@
12
12
  "scripts": {
13
13
  "start": "bun src/index.ts",
14
14
  "dev": "bun --watch src/index.ts",
15
- "build": "bun build src/index.ts --outdir dist --target bun --external '@opentui/core' --external '@opentui/react' --external 'react' --external 'react-reconciler' && cat ../../scripts/shebang dist/index.js > dist/ai-speedometer && chmod +x dist/ai-speedometer && rm dist/index.js",
15
+ "build": "node ../../scripts/build-tui.mjs",
16
16
  "typecheck": "bun tsc --noEmit",
17
17
  "prepublishOnly": "bun run build"
18
18
  },