@tokenzero/cli 0.1.8 → 0.2.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.
Files changed (2) hide show
  1. package/bin/tokenzero.mjs +32 -1
  2. package/package.json +1 -1
package/bin/tokenzero.mjs CHANGED
@@ -710,7 +710,7 @@ function canonical(obj) {
710
710
  }
711
711
 
712
712
  // cli/src/main.ts
713
- var VERSION = "0.1.8";
713
+ var VERSION = "0.2.0";
714
714
  var BAKED_URL = true ? "https://tokenzero.sh" : "__TOKENZERO_DEFAULT_URL__";
715
715
  function parseArgs(argv) {
716
716
  const a = { _: [], flags: {} };
@@ -1118,6 +1118,34 @@ ${bold(f.title)}
1118
1118
  process.exitCode = 1;
1119
1119
  }
1120
1120
  }
1121
+ async function cmdDoctor(a) {
1122
+ const saved = loadCreds();
1123
+ const base = baseUrl(a) || saved?.url || "https://tokenzero.sh";
1124
+ const key = a.flags.key || process.env.TOKENZERO_KEY || saved?.api_key || "";
1125
+ const r = await api(base, "/v1/doctor", { headers: key ? { "x-tokenzero-key": key } : {} });
1126
+ if (r.status !== 200) {
1127
+ err(red(`doctor: ${r.status} ${JSON.stringify(r.body).slice(0, 200)}`));
1128
+ process.exitCode = 1;
1129
+ return;
1130
+ }
1131
+ if (a.flags.json) {
1132
+ out(JSON.stringify(r.body, null, 2));
1133
+ return;
1134
+ }
1135
+ const d = r.body;
1136
+ out(`${bold("tokenzero doctor")} \xB7 ${base} \xB7 gateway v${d.version} \xB7 ${d.authenticated ? "workspace key accepted" : "no workspace key (pass --key or set TOKENZERO_KEY for quota and settings checks)"}`);
1137
+ for (const c2 of d.checks) {
1138
+ const tag = c2.status === "pass" ? green("[PASS]") : c2.status === "warn" ? yellow("[WARN]") : dim("[INFO]");
1139
+ out(` ${tag} ${c2.label}: ${c2.detail}`);
1140
+ }
1141
+ out(dim(` OPENAI_BASE_URL=${d.snippets.openai_base_url}`));
1142
+ out(dim(` ANTHROPIC_BASE_URL=${d.snippets.anthropic_base_url}`));
1143
+ out(dim(` dashboard: ${d.snippets.dashboard_url}`));
1144
+ if (!d.ok) {
1145
+ out(yellow(` something needs attention; support: ${d.support.support_page} (${d.support.sla_target_response_minutes}-minute response target)`));
1146
+ process.exitCode = 1;
1147
+ }
1148
+ }
1121
1149
  async function cmdUsage(a) {
1122
1150
  const saved = loadCreds();
1123
1151
  const base = baseUrl(a) || saved?.url || "";
@@ -1269,6 +1297,7 @@ function help() {
1269
1297
  ${bold("tokenzero audit")} [dir] [--json | --format markdown] [--diff file|-] [--fail-over PCT]
1270
1298
  Static token-waste audit. Runs locally; nothing is uploaded. --fail-over makes it a CI gate.
1271
1299
  ${bold("tokenzero usage")} [--json] Routed spend vs the free tier, savings, fee preview.
1300
+ ${bold("tokenzero doctor")} [--key K] [--json] Six-check connection and receipt doctor: gateway, signer, pricing, key, quota, settings.
1272
1301
  ${bold("tokenzero verify")} <request_id> Verify a savings receipt's signature offline.
1273
1302
  ${bold("tokenzero verify --chain")} [--limit N] Verify the workspace's append-only receipt chain (signatures, seq, prev hashes).
1274
1303
  ${bold("tokenzero rotate-key")} [--yes] Issue a new workspace key; rewrites it in .env. Old key dies immediately.
@@ -1294,6 +1323,8 @@ async function main() {
1294
1323
  return cmdAudit(a);
1295
1324
  case "usage":
1296
1325
  return cmdUsage(a);
1326
+ case "doctor":
1327
+ return cmdDoctor(a);
1297
1328
  case "verify":
1298
1329
  return cmdVerify(a);
1299
1330
  case "rotate-key":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenzero/cli",
3
- "version": "0.1.8",
3
+ "version": "0.2.0",
4
4
  "description": "TokenZero CLI: connect a project to the TokenZero BYOK gateway, audit LLM token waste locally, check usage and verify signed savings receipts.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",