@drsamonline/cli 0.12.11 → 0.12.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drsamonline/cli",
3
- "version": "0.12.11",
3
+ "version": "0.12.13",
4
4
  "description": "The `sui` command line.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/cli.js CHANGED
@@ -21,7 +21,7 @@ import { auditConfig, defaultConfigPath, hashApiKey, normalizeConfig, providerHa
21
21
  import { runInit } from './onboarding.js';
22
22
  import { detectTools, writeToolConfig } from './tools.js';
23
23
  import { applyImport, diffImport, readMigrationSource, smokeTest } from './migrate.js';
24
- import { cmdBudget, cmdCatalog, cmdCompress, cmdConfig, cmdExplain, cmdKits, cmdLocal, cmdMcp, cmdProbe, cmdRecipe, cmdRedteam, cmdSandbox, cmdSavings, cmdTenants, cmdTokens, cmdVault, writeExport } from './commands-extra.js';
24
+ import { cmdBudget, cmdCatalog, cmdCompress, cmdConfig, cmdExplain, cmdFreeBudget, cmdKits, cmdLocal, cmdMcp, cmdProbe, cmdRecipe, cmdRedteam, cmdSandbox, cmdSavings, cmdTenants, cmdTokens, cmdVault, writeExport } from './commands-extra.js';
25
25
  import { kitStatus } from '@drsamonline/kits';
26
26
  import { ConfigError } from '@drsamonline/core';
27
27
 
@@ -71,6 +71,8 @@ export async function run(argv = process.argv.slice(2)) {
71
71
  return cmdUp(flags);
72
72
  case 'keys':
73
73
  return cmdKeys(flags, args);
74
+ case 'free-budget':
75
+ return cmdFreeBudget(flags);
74
76
  case 'catalog':
75
77
  return cmdCatalog(flags, args);
76
78
  case 'probe':
@@ -614,6 +616,7 @@ sui ${VERSION} — one endpoint for every LLM
614
616
  ${RUN_AS} tools point a coding tool here --set <tool-id>
615
617
  ${RUN_AS} migrate <file> import from 9router / OmniRoute / HubGate --apply --only a,b
616
618
  ${RUN_AS} catalog [q] the provider catalogue, and what is still unverified
619
+ ${RUN_AS} free-budget verified free headroom per month, and what is only a claim
617
620
  ${RUN_AS} probe [name] liveness, readiness and suitability checks (B2.3)
618
621
  ${RUN_AS} compress <file|-> [--preset lite|standard|aggressive|ultra] [--text "…"]
619
622
  ${RUN_AS} budget which preset the remaining quota would choose
@@ -12,7 +12,7 @@ import { fileURLToPath } from 'node:url';
12
12
  import { createInterface } from 'node:readline/promises';
13
13
  import { stdin, stdout } from 'node:process';
14
14
  import { ConfigError, defaultConfigPath, normalizeConfig, sanitizeConfig, suiHome } from '@drsamonline/core';
15
- import { applyVerified } from '@drsamonline/catalog';
15
+ import { applyVerified, freeBudget, formatTokens } from '@drsamonline/catalog';
16
16
  import { dedupeEntries, loadSeed, summarise } from '@drsamonline/catalog';
17
17
  import { loadKit, kitStatus } from '@drsamonline/kits';
18
18
  import { createVault } from '@drsamonline/vault';
@@ -40,6 +40,55 @@ const ROOT = join(HERE, '..', '..', '..');
40
40
  /* ------------------------------------------------------------------ catalog */
41
41
 
42
42
  /** `sui catalog [query]` — what Sui could route to, and what is still unverified. */
43
+ /**
44
+ * `sui free-budget` — how much free headroom you actually have.
45
+ *
46
+ * Two numbers, never added together: what a probe reached, and what is only a
47
+ * claim. A pool counted once however many names point at it.
48
+ */
49
+ export function cmdFreeBudget(flags) {
50
+ const entries = loadCatalogue();
51
+ const probes = Object.fromEntries(readVerified().map((v) => [v.pool_key, v]));
52
+ const budget = freeBudget(entries, probes);
53
+
54
+ if (flags.json) {
55
+ console.log(
56
+ JSON.stringify(
57
+ {
58
+ verifiedTokens: budget.verifiedTokens,
59
+ unverifiedTokens: budget.unverifiedTokens,
60
+ verified: budget.verified,
61
+ unverified: budget.unverified,
62
+ pools: budget.pools,
63
+ withoutBudget: budget.withoutBudget,
64
+ note: budget.note,
65
+ },
66
+ null,
67
+ 2,
68
+ ),
69
+ );
70
+ return;
71
+ }
72
+
73
+ console.log('');
74
+ console.log(` ${formatTokens(budget.verifiedTokens)} verified per month ← pools that answered a probe`);
75
+ console.log(` ${formatTokens(budget.unverifiedTokens)} published, unverified ← never added to the line above`);
76
+ console.log('');
77
+ console.log(
78
+ table(
79
+ ['pool', 'names', 'tokens/mo', 'state'],
80
+ [
81
+ ...budget.verified.map((p) => [p.pool_key.slice(0, 34), p.names.join(', '), formatTokens(p.tokens), 'verified']),
82
+ ...budget.unverified.map((p) => [p.pool_key.slice(0, 34), p.names.join(', '), formatTokens(p.tokens), 'unverified']),
83
+ ],
84
+ ),
85
+ );
86
+ console.log('');
87
+ console.log(` ${budget.pools} pool(s) · ${budget.withoutBudget} with no published budget recorded`);
88
+ console.log(` ${budget.note}`);
89
+ console.log('');
90
+ }
91
+
43
92
  export function cmdCatalog(flags, args) {
44
93
  const entries = loadCatalogue();
45
94
  const summary = summarise(entries);