@secondlayer/cli 10.2.0 → 10.2.1

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/dist/cli.js CHANGED
@@ -34787,7 +34787,7 @@ init_esm();
34787
34787
  // package.json
34788
34788
  var package_default = {
34789
34789
  name: "@secondlayer/cli",
34790
- version: "10.2.0",
34790
+ version: "10.2.1",
34791
34791
  repository: {
34792
34792
  type: "git",
34793
34793
  url: "git+https://github.com/ryanwaits/secondlayer.git",
@@ -35406,94 +35406,71 @@ function registerContextCommand(program2) {
35406
35406
  });
35407
35407
  }
35408
35408
  // src/commands/status.ts
35409
- init_config2();
35410
35409
  init_http();
35411
35410
  init_output();
35411
+ init_resolve_auth();
35412
35412
  function registerStatusCommand(program2) {
35413
- program2.command("status").description("Show system status").option("--json", "Output as JSON").action(async (options3) => {
35414
- const config = await loadConfig2();
35413
+ program2.command("status").description("Show local instance status").option("--json", "Output as JSON").action(async (options3) => {
35415
35414
  try {
35416
- const local = process.env.INSTANCE_MODE === "oss" || (process.env.SL_API_URL ?? "").includes("127.0.0.1") || (process.env.SL_API_URL ?? "").includes("localhost");
35417
- const status = local ? await httpPlatform("/public/status") : await httpPlatform("/status");
35415
+ const status = await httpPlatformAnon("/public/status");
35418
35416
  output({
35419
35417
  json: options3.json,
35420
35418
  data: status,
35421
- human: () => printStatus(status)
35419
+ human: () => printPublicStatus(status)
35422
35420
  });
35423
- } catch (err) {
35424
- if (err instanceof CliHttpError && err.code === "SESSION_EXPIRED") {
35425
- console.error("Not logged in. Run: sl login");
35426
- process.exit(1);
35427
- }
35421
+ } catch {
35428
35422
  console.log("");
35429
35423
  console.log(blue("System Status"));
35430
35424
  console.log(` ${red("NOT RUNNING")}`);
35431
35425
  console.log("");
35432
- if (config.network === "local") {
35433
- console.log(dim(" API service is not running."));
35434
- console.log(dim(" Start with: sl local start"));
35435
- } else {
35436
- console.log(dim(" Can't reach the platform API."));
35437
- console.log(dim(" Check your connection or try again."));
35438
- }
35426
+ console.log(dim(` Can't reach ${resolveApiUrl()}/public/status.`));
35427
+ console.log(dim(" Start with: docker compose up -d"));
35439
35428
  console.log("");
35440
35429
  process.exit(1);
35441
35430
  }
35442
35431
  });
35443
35432
  }
35444
- function printStatus(status) {
35433
+ function printPublicStatus(status) {
35434
+ const overall = String(status.status ?? "unknown");
35435
+ const color = overall === "healthy" ? green : red;
35445
35436
  console.log("");
35446
- const statusColor = status.status === "healthy" ? green : red;
35447
35437
  console.log(blue("System Status"));
35448
- console.log(` ${statusColor(status.status.toUpperCase())}${status.network ? dim(` (${status.network})`) : ""}`);
35438
+ console.log(` ${color(overall.toUpperCase())}`);
35449
35439
  console.log("");
35450
- console.log(blue("Database"));
35451
- const dbColor = status.database.status === "ok" ? green : red;
35452
- console.log(` Status: ${dbColor(status.database.status)}`);
35453
- console.log("");
35454
- console.log(blue("Index Progress"));
35455
- if (status.indexProgress.length === 0) {
35456
- console.log(dim(" No data indexed yet"));
35457
- } else {
35458
- for (const p2 of status.indexProgress) {
35459
- const behind = p2.highestSeenBlock - p2.lastIndexedBlock;
35460
- const behindStr = behind > 0 ? yellow(` (${behind} behind)`) : green(" (synced)");
35461
- console.log(` ${p2.network}: block ${p2.lastIndexedBlock}${behindStr}`);
35462
- if (status.chainTip && status.chainTip > 0) {
35463
- const pct = Math.min(p2.lastIndexedBlock / status.chainTip * 100, 100);
35464
- const barWidth = 30;
35465
- const filled = Math.round(pct / 100 * barWidth);
35466
- const empty = barWidth - filled;
35467
- const bar = `${"█".repeat(filled)}${"░".repeat(empty)}`;
35468
- const pctStr = `${pct.toFixed(1)}%`;
35469
- const color = pct >= 99.9 ? green : pct >= 50 ? yellow : red;
35470
- console.log(` ${dim("chain:")} ${color(bar)} ${color(pctStr)} ${dim(`(tip: ${status.chainTip.toLocaleString()})`)}`);
35471
- }
35472
- const contiguous = p2.lastContiguousBlock ?? 0;
35473
- if (status.integrity === "complete") {
35474
- console.log(` ${dim("contiguous:")} ${contiguous} ${green("(complete)")}`);
35475
- } else {
35476
- const gapCount = status.gaps?.length ?? 0;
35477
- const missing = status.totalMissingBlocks ?? 0;
35478
- console.log(` ${dim("contiguous:")} ${contiguous} ${yellow(`(${gapCount} gaps, ${missing} missing blocks)`)}`);
35479
- if (status.gaps) {
35480
- for (const gap of status.gaps.slice(0, 5)) {
35481
- const range = gap.gapStart === gap.gapEnd ? `${gap.gapStart}` : `${gap.gapStart}-${gap.gapEnd}`;
35482
- console.log(` ${dim("gap:")} ${range} ${dim(`(${gap.size} block${gap.size > 1 ? "s" : ""})`)}`);
35483
- }
35484
- }
35485
- }
35440
+ const tip = status.chainTip;
35441
+ if (typeof tip === "number") {
35442
+ console.log(blue("Chain"));
35443
+ console.log(` tip: ${tip.toLocaleString()}`);
35444
+ const integrity = status.chainIntegrity;
35445
+ if (integrity) {
35446
+ console.log(` integrity: ${integrity.ok ? green("ok") : yellow("check")}`);
35486
35447
  }
35448
+ console.log("");
35487
35449
  }
35488
- console.log("");
35489
- if (status.activeSubgraphs !== undefined) {
35490
- console.log(blue("Activity"));
35491
- console.log(formatKeyValue([
35492
- [" Active Subgraphs", status.activeSubgraphs.toString()]
35493
- ]));
35450
+ const streams = status.streams;
35451
+ if (streams) {
35452
+ console.log(blue("Streams"));
35453
+ console.log(` ${streams.status ?? "unknown"}`);
35454
+ if (typeof streams.tip?.lag_seconds === "number") {
35455
+ console.log(` lag: ${streams.tip.lag_seconds}s`);
35456
+ }
35457
+ console.log("");
35458
+ }
35459
+ const index = status.index;
35460
+ if (index) {
35461
+ console.log(blue("Index"));
35462
+ console.log(` ${index.status ?? "unknown"}`);
35463
+ const bad = (index.decoders ?? []).filter((d2) => d2.status !== "ok");
35464
+ if (bad.length > 0) {
35465
+ for (const d2 of bad.slice(0, 8)) {
35466
+ console.log(` ${yellow(d2.decoder)} ${d2.status}`);
35467
+ }
35468
+ }
35494
35469
  console.log("");
35495
35470
  }
35496
- console.log(dim(`Last updated: ${status.timestamp}`));
35471
+ if (typeof status.timestamp === "string") {
35472
+ console.log(dim(`Last updated: ${status.timestamp}`));
35473
+ }
35497
35474
  }
35498
35475
  // src/commands/subscriptions.ts
35499
35476
  init_api_client();
@@ -37316,7 +37293,6 @@ function registerKeysCommand(program2) {
37316
37293
  });
37317
37294
  }
37318
37295
  // src/commands/doctor.ts
37319
- init_api_client();
37320
37296
  init_config2();
37321
37297
 
37322
37298
  // src/lib/health.ts
@@ -37462,50 +37438,31 @@ async function checkHealth() {
37462
37438
  init_http();
37463
37439
  init_network();
37464
37440
  init_output();
37441
+ init_resolve_auth();
37465
37442
  function registerDoctorCommand(program2) {
37466
37443
  program2.command("doctor").description("Run diagnostics on the full stack").option("--json", "Output as JSON").action(async (options3) => {
37467
37444
  const config = await loadConfig2();
37468
37445
  if (config.network === "local") {
37469
37446
  await runLocalDoctor(options3.json);
37470
- } else {
37471
- await runHostedDoctor(options3.json);
37447
+ return;
37472
37448
  }
37449
+ await runInstanceDoctor(options3.json);
37473
37450
  });
37474
37451
  }
37475
- async function runHostedDoctor(jsonOutput) {
37452
+ async function runInstanceDoctor(jsonOutput) {
37476
37453
  const config = await loadConfig2();
37477
- const apiUrl = process.env.SL_PLATFORM_API_URL ?? process.env.SL_API_URL ?? "http://127.0.0.1:3800";
37454
+ const apiUrl = resolveApiUrl();
37478
37455
  const issues = [];
37479
37456
  const results = { network: config.network, apiUrl };
37480
37457
  let apiHealthy = false;
37481
37458
  let statusData = null;
37482
37459
  try {
37483
- statusData = await httpPlatform("/status");
37460
+ statusData = await httpPlatformAnon("/public/status");
37484
37461
  apiHealthy = true;
37485
- } catch (err) {
37486
- if (err instanceof CliHttpError) {
37487
- if (err.code === "SESSION_EXPIRED") {
37488
- issues.push("Not authenticated. Run: sl login");
37489
- } else {
37490
- issues.push(`API error: ${err.code}`);
37491
- }
37492
- } else {
37493
- issues.push(`Cannot reach API at ${apiUrl}`);
37494
- }
37462
+ } catch {
37463
+ issues.push(`Cannot reach ${apiUrl}/public/status`);
37495
37464
  }
37496
37465
  results.apiHealthy = apiHealthy;
37497
- let authOk = false;
37498
- let account = null;
37499
- try {
37500
- account = await getAccountProfile();
37501
- authOk = true;
37502
- } catch (err) {
37503
- if (err instanceof CliHttpError && err.code === "SESSION_EXPIRED") {
37504
- issues.push("Not authenticated. Run: sl login");
37505
- }
37506
- }
37507
- results.authOk = authOk;
37508
- results.account = account;
37509
37466
  if (jsonOutput) {
37510
37467
  console.log(JSON.stringify({ ...results, status: statusData, issues }, null, 2));
37511
37468
  return;
@@ -37517,28 +37474,18 @@ async function runHostedDoctor(jsonOutput) {
37517
37474
  console.log(blue("API"));
37518
37475
  console.log(` ${apiHealthy ? green("✓") : red("✗")} ${apiHealthy ? green("reachable") : red("unreachable")}`);
37519
37476
  console.log("");
37520
- console.log(blue("Auth"));
37521
- if (authOk && account) {
37522
- console.log(` ${green("✓")} Authenticated`);
37523
- console.log(formatKeyValue([
37524
- [" Email", account.email ?? dim("unknown")],
37525
- [" Plan", account.plan ?? dim("unknown")]
37526
- ]));
37527
- } else {
37528
- console.log(` ${red("✗")} Not authenticated`);
37529
- }
37530
- console.log("");
37531
37477
  if (statusData) {
37532
- const progress = statusData.indexProgress;
37533
- if (progress?.length) {
37534
- console.log(blue("Index Progress"));
37535
- for (const p2 of progress) {
37536
- const behind = p2.highestSeenBlock - p2.lastIndexedBlock;
37537
- const behindStr = behind > 0 ? yellow(` (${behind} behind)`) : green(" (synced)");
37538
- console.log(` ${p2.network}: block ${p2.lastIndexedBlock}${behindStr}`);
37539
- }
37540
- console.log("");
37541
- }
37478
+ const tip = statusData.chainTip;
37479
+ const streams = statusData.streams;
37480
+ const index = statusData.index;
37481
+ console.log(blue("Instance"));
37482
+ if (typeof tip === "number")
37483
+ console.log(` tip: ${tip.toLocaleString()}`);
37484
+ if (streams?.status)
37485
+ console.log(` streams: ${streams.status}`);
37486
+ if (index?.status)
37487
+ console.log(` index: ${index.status}`);
37488
+ console.log("");
37542
37489
  }
37543
37490
  console.log(blue("Issues"));
37544
37491
  if (issues.length === 0) {
@@ -39890,5 +39837,5 @@ registerAccountCommand(program);
39890
39837
  registerKeysCommand(program);
39891
39838
  program.parse();
39892
39839
 
39893
- //# debugId=E414197C37677A7F64756E2164756E21
39840
+ //# debugId=60FAFC7C2FFCA95764756E2164756E21
39894
39841
  //# sourceMappingURL=cli.js.map