ai-speedometer 2.0.4 → 2.1.0

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.
@@ -1,4 +1,9 @@
1
- #!/usr/bin/env bun
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
+ */
2
7
  // @bun
3
8
  var __defProp = Object.defineProperty;
4
9
  var __export = (target, all) => {
@@ -1474,61 +1479,85 @@ var getXDGPaths = () => ({
1474
1479
  }
1475
1480
  return merged;
1476
1481
  }, getOpencodeGlobalConfigProviders = async () => {
1482
+ return getAuthenticatedProviders();
1483
+ }, getAuthenticatedProviders = async () => {
1477
1484
  try {
1478
- const globalConfig = readOpencodeGlobalConfig();
1479
- if (!globalConfig.provider || Object.keys(globalConfig.provider).length === 0)
1480
- return [];
1481
- const allModelsDevProviders = await getAllProviders();
1482
- const result = [];
1483
- for (const [providerId, entry] of Object.entries(globalConfig.provider)) {
1484
- const apiKey = entry.options?.apiKey;
1485
- if (!apiKey)
1486
- continue;
1487
- const mdProvider = allModelsDevProviders.find((p) => p.id === providerId);
1488
- let models = [];
1489
- if (entry.models && Object.keys(entry.models).length > 0) {
1490
- models = Object.entries(entry.models).map(([modelKey, m]) => ({
1491
- id: `${providerId}_${m.id ?? modelKey}`,
1492
- name: m.name ?? m.id ?? modelKey
1493
- }));
1494
- } else if (mdProvider) {
1495
- models = mdProvider.models.map((m) => ({ id: `${providerId}_${m.id}`, name: m.name }));
1485
+ const [allModelsDevProviders, authData, globalConfig] = await Promise.all([
1486
+ getAllProviders(),
1487
+ readAuthJson(),
1488
+ Promise.resolve(readOpencodeGlobalConfig())
1489
+ ]);
1490
+ const database = new Map;
1491
+ for (const mdProvider of allModelsDevProviders) {
1492
+ const modelMap = new Map;
1493
+ for (const m of mdProvider.models) {
1494
+ modelMap.set(`${mdProvider.id}_${m.id}`, { id: `${mdProvider.id}_${m.id}`, name: m.name });
1496
1495
  }
1497
- const npm = entry.npm ?? mdProvider?.type;
1498
- const type = npm?.includes("anthropic") ? "anthropic" : mdProvider?.type ?? "openai-compatible";
1499
- result.push({
1500
- id: providerId,
1501
- name: entry.name ?? mdProvider?.name ?? providerId,
1502
- type,
1503
- baseUrl: entry.options?.baseURL ?? entry.api ?? mdProvider?.baseUrl ?? "",
1504
- apiKey,
1505
- models
1496
+ database.set(mdProvider.id, {
1497
+ id: mdProvider.id,
1498
+ name: mdProvider.name,
1499
+ type: mdProvider.type,
1500
+ baseUrl: mdProvider.baseUrl,
1501
+ models: modelMap
1506
1502
  });
1507
1503
  }
1508
- return result;
1509
- } catch (error) {
1510
- console.warn("Warning: Could not load opencode global config providers:", error.message);
1511
- return [];
1512
- }
1513
- }, getAuthenticatedProviders = async () => {
1514
- const authData = await readAuthJson();
1515
- const allProviders = await getAllProviders();
1516
- const authenticatedProviders = [];
1517
- for (const [providerId, authInfo] of Object.entries(authData)) {
1518
- const providerInfo = allProviders.find((p) => p.id === providerId);
1519
- if (providerInfo && authInfo.type === "api" && authInfo.key) {
1520
- const models = await getModelsForProvider(providerId);
1521
- authenticatedProviders.push({
1522
- id: providerId,
1523
- name: providerInfo.name,
1524
- type: providerInfo.type,
1525
- baseUrl: providerInfo.baseUrl,
1504
+ for (const [providerID, entry] of Object.entries(globalConfig.provider ?? {})) {
1505
+ const existing = database.get(providerID);
1506
+ const modelMap = existing ? new Map(existing.models) : new Map;
1507
+ for (const [modelKey, m] of Object.entries(entry.models ?? {})) {
1508
+ const resolvedId = `${providerID}_${m.id ?? modelKey}`;
1509
+ modelMap.set(resolvedId, { id: resolvedId, name: m.name ?? m.id ?? modelKey });
1510
+ }
1511
+ database.set(providerID, {
1512
+ id: providerID,
1513
+ name: entry.name ?? existing?.name ?? providerID,
1514
+ type: existing?.type ?? "openai-compatible",
1515
+ baseUrl: entry.options?.baseURL ?? entry.api ?? existing?.baseUrl ?? "",
1516
+ models: modelMap,
1517
+ npm: entry.npm
1518
+ });
1519
+ }
1520
+ const providerMap = new Map;
1521
+ for (const [providerID, authInfo] of Object.entries(authData)) {
1522
+ if (authInfo.type !== "api" || !authInfo.key)
1523
+ continue;
1524
+ const dbEntry = database.get(providerID);
1525
+ if (!dbEntry)
1526
+ continue;
1527
+ const configEntry = globalConfig.provider?.[providerID];
1528
+ const npm = dbEntry.npm ?? configEntry?.npm;
1529
+ const type = npm?.includes("anthropic") ? "anthropic" : dbEntry.type;
1530
+ providerMap.set(providerID, {
1531
+ id: providerID,
1532
+ name: dbEntry.name,
1533
+ type,
1534
+ baseUrl: dbEntry.baseUrl,
1526
1535
  apiKey: authInfo.key,
1527
- models: models.map((model) => ({ name: model.name, id: `${providerId}_${model.id}` }))
1536
+ models: Array.from(dbEntry.models.values())
1528
1537
  });
1529
1538
  }
1539
+ for (const [providerID, entry] of Object.entries(globalConfig.provider ?? {})) {
1540
+ if (!entry.options?.apiKey)
1541
+ continue;
1542
+ const dbEntry = database.get(providerID);
1543
+ if (!dbEntry)
1544
+ continue;
1545
+ const npm = dbEntry.npm ?? entry.npm;
1546
+ const type = npm?.includes("anthropic") ? "anthropic" : dbEntry.type;
1547
+ providerMap.set(providerID, {
1548
+ id: providerID,
1549
+ name: dbEntry.name,
1550
+ type,
1551
+ baseUrl: dbEntry.baseUrl,
1552
+ apiKey: entry.options.apiKey,
1553
+ models: Array.from(dbEntry.models.values())
1554
+ });
1555
+ }
1556
+ return Array.from(providerMap.values());
1557
+ } catch (error) {
1558
+ console.warn("Warning: Could not load providers:", error.message);
1559
+ return [];
1530
1560
  }
1531
- return authenticatedProviders;
1532
1561
  }, getCustomProviders = async () => [], verifyProvider = async (providerId) => {
1533
1562
  try {
1534
1563
  const allProviders = await getAllProviders();
@@ -1549,7 +1578,7 @@ var getXDGPaths = () => ({
1549
1578
  }
1550
1579
  return true;
1551
1580
  }, getAllAvailableProviders = async (includeAllProviders = false) => {
1552
- const [authenticatedProviders, customProvidersFromConfig, customVerifiedProviders, opencodeGlobalProviders] = await Promise.all([
1581
+ const [opencodeProviders, customProvidersFromConfig, customVerifiedProviders] = await Promise.all([
1553
1582
  getAuthenticatedProviders(),
1554
1583
  (async () => {
1555
1584
  try {
@@ -1566,18 +1595,16 @@ var getXDGPaths = () => ({
1566
1595
  console.warn("Warning: Could not load custom verified providers:", error.message);
1567
1596
  return [];
1568
1597
  }
1569
- })(),
1570
- getOpencodeGlobalConfigProviders()
1598
+ })()
1571
1599
  ]);
1572
1600
  const providerMap = new Map;
1573
1601
  customVerifiedProviders.forEach((p) => providerMap.set(p.id, p));
1574
- opencodeGlobalProviders.forEach((p) => providerMap.set(p.id, p));
1602
+ opencodeProviders.forEach((p) => providerMap.set(p.id, p));
1575
1603
  customProvidersFromConfig.forEach((p) => providerMap.set(p.id, p));
1576
- authenticatedProviders.forEach((p) => providerMap.set(p.id, p));
1577
1604
  if (includeAllProviders) {
1578
1605
  try {
1579
1606
  const allModelsDevProviders = await getAllProviders();
1580
- const authenticatedIds = new Set(authenticatedProviders.map((p) => p.id));
1607
+ const authenticatedIds = new Set(opencodeProviders.map((p) => p.id));
1581
1608
  const customIds = new Set(customProvidersFromConfig.map((p) => p.id));
1582
1609
  const customVerifiedIds = new Set(customVerifiedProviders.map((p) => p.id));
1583
1610
  allModelsDevProviders.forEach((provider) => {
@@ -2127,14 +2154,15 @@ var package_default;
2127
2154
  var init_package = __esm(() => {
2128
2155
  package_default = {
2129
2156
  name: "ai-speedometer",
2130
- version: "2.0.4",
2157
+ version: "2.1.0",
2131
2158
  description: "A comprehensive CLI tool for benchmarking AI models across multiple providers with parallel execution and professional metrics",
2132
2159
  bin: {
2133
2160
  "ai-speedometer": "dist/ai-speedometer",
2134
2161
  aispeed: "dist/ai-speedometer"
2135
2162
  },
2136
2163
  engines: {
2137
- bun: ">=1.0.0"
2164
+ bun: ">=1.0.0",
2165
+ node: ">=18.0.0"
2138
2166
  },
2139
2167
  scripts: {
2140
2168
  start: "bun src/index.ts",
@@ -2143,7 +2171,7 @@ var init_package = __esm(() => {
2143
2171
  "test:watch": "bun test --watch",
2144
2172
  "test:update": "bun test --update-snapshots",
2145
2173
  typecheck: "bun tsc --noEmit",
2146
- build: "bun build src/index.ts --outdir dist --target bun --external '@opentui/core' --external '@opentui/react' --external 'react' --external 'react-reconciler' && printf '#!/usr/bin/env bun\\n' | cat - dist/index.js > dist/ai-speedometer && chmod +x dist/ai-speedometer && rm dist/index.js",
2174
+ 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",
2147
2175
  prepublishOnly: "bun run build"
2148
2176
  },
2149
2177
  keywords: [
@@ -2174,6 +2202,7 @@ var init_package = __esm(() => {
2174
2202
  files: [
2175
2203
  "dist/",
2176
2204
  "docs/",
2205
+ "scripts/",
2177
2206
  "README.md",
2178
2207
  "ai-benchmark-config.json.template"
2179
2208
  ],
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "ai-speedometer",
3
- "version": "2.0.4",
3
+ "version": "2.1.0",
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",
7
7
  "aispeed": "dist/ai-speedometer"
8
8
  },
9
9
  "engines": {
10
- "bun": ">=1.0.0"
10
+ "bun": ">=1.0.0",
11
+ "node": ">=18.0.0"
11
12
  },
12
13
  "scripts": {
13
14
  "start": "bun src/index.ts",
@@ -16,7 +17,7 @@
16
17
  "test:watch": "bun test --watch",
17
18
  "test:update": "bun test --update-snapshots",
18
19
  "typecheck": "bun tsc --noEmit",
19
- "build": "bun build src/index.ts --outdir dist --target bun --external '@opentui/core' --external '@opentui/react' --external 'react' --external 'react-reconciler' && printf '#!/usr/bin/env bun\\n' | cat - dist/index.js > dist/ai-speedometer && chmod +x dist/ai-speedometer && rm dist/index.js",
20
+ "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",
20
21
  "prepublishOnly": "bun run build"
21
22
  },
22
23
  "keywords": [
@@ -47,6 +48,7 @@
47
48
  "files": [
48
49
  "dist/",
49
50
  "docs/",
51
+ "scripts/",
50
52
  "README.md",
51
53
  "ai-benchmark-config.json.template"
52
54
  ],
@@ -0,0 +1,6 @@
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
+ */