trainfabric 0.1.50 → 0.1.52

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/index.cjs +48 -15
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -9364,7 +9364,7 @@ function buildComputeSpec(options) {
9364
9364
 
9365
9365
  // src/index.ts
9366
9366
  var DEFAULT_TRAINFABRIC_API_URL2 = "https://api.trainfabric.com";
9367
- var CLI_VERSION = "0.1.50";
9367
+ var CLI_VERSION = "0.1.52";
9368
9368
  var CONFIG_DIR = import_node_path3.default.join(import_node_os2.default.homedir(), ".trainfabric");
9369
9369
  var CONFIG_PATH = import_node_path3.default.join(CONFIG_DIR, "config.json");
9370
9370
  var FALLBACK_SECRET_PATH = import_node_path3.default.join(CONFIG_DIR, "session.enc");
@@ -9709,6 +9709,27 @@ function printUsageSummary(usage) {
9709
9709
  console.log(` ${item.label}: ${formatUsd(item.amountUsd)} - ${item.description}`);
9710
9710
  }
9711
9711
  }
9712
+ function printInvoiceSummary(invoices) {
9713
+ if (invoices.length === 0) {
9714
+ console.log("No invoices found.");
9715
+ return;
9716
+ }
9717
+ for (const invoice of invoices) {
9718
+ console.log(`${invoice.id}${invoice.runId ? ` (${invoice.runId})` : ""}`);
9719
+ console.log(` status: ${invoice.status}`);
9720
+ console.log(` amount due: ${formatUsd(invoice.amountDueUsd)}`);
9721
+ if (typeof invoice.usageChargeUsd === "number" || typeof invoice.customerChargeUsd === "number") {
9722
+ console.log(` run charge: ${formatUsd(invoice.usageChargeUsd ?? invoice.customerChargeUsd)}`);
9723
+ }
9724
+ if (typeof invoice.creditAppliedUsd === "number") {
9725
+ console.log(` credits applied: ${formatUsd(invoice.creditAppliedUsd)}`);
9726
+ }
9727
+ if (invoice.settlementNote) {
9728
+ console.log(` note: ${invoice.settlementNote}`);
9729
+ }
9730
+ console.log("");
9731
+ }
9732
+ }
9712
9733
  function summarizeRunDetail(detail) {
9713
9734
  return {
9714
9735
  runId: detail.run.id,
@@ -10176,10 +10197,10 @@ program2.command("config:clear-api-key").description("Clear the stored API key")
10176
10197
  }
10177
10198
  printJson(visibleConfig(config));
10178
10199
  });
10179
- program2.command("orgs:list").description("List accessible organizations").action(async () => {
10200
+ program2.command("orgs:list").option("--json", "print raw JSON output; this is the default").description("List accessible organizations").action(async () => {
10180
10201
  printJson(await createClient(loadConfig()).organizations.list());
10181
10202
  });
10182
- program2.command("projects:list").description("List projects in the active organization").action(async () => {
10203
+ program2.command("projects:list").option("--json", "print raw JSON output; this is the default").description("List projects in the active organization").action(async () => {
10183
10204
  printJson(await createClient(loadConfig()).projects.list());
10184
10205
  });
10185
10206
  program2.command("projects:create").requiredOption("--name <name>").option("--org <organizationId>").description("Create a project").action(async (options) => {
@@ -10366,7 +10387,7 @@ program2.command("models:list").option("--json", "print raw JSON output; this is
10366
10387
  program2.command("models:export").argument("<modelId>").description("Fetch the export package path for a model").action(async (modelId) => {
10367
10388
  printJson(await createClient(loadConfig()).models.export(normalizeId(modelId, "model", "Model ID")));
10368
10389
  });
10369
- program2.command("deployments:list").description("List deployments").action(async () => {
10390
+ program2.command("deployments:list").option("--json", "print raw JSON output; this is the default").description("List deployments").action(async () => {
10370
10391
  printJson(await createClient(loadConfig()).deployments.list());
10371
10392
  });
10372
10393
  program2.command("deployments:create").requiredOption("--model <modelId>").option("--project <projectId>", "accepted for consistency; deployment project is inferred from the model").description("Create a hosted deployment for a model. Requires TRAINING_DEPLOYMENT_BASE_URL to be configured on the backend.").action(async (options) => {
@@ -10392,10 +10413,10 @@ program2.command("deployments:delete").argument("<deploymentId>").description("D
10392
10413
  await createClient(loadConfig()).deployments.delete(normalizedDeploymentId);
10393
10414
  printJson({ deleted: true, id: normalizedDeploymentId });
10394
10415
  });
10395
- program2.command("billing:summary").description("Fetch billing summary").action(async () => {
10416
+ program2.command("billing:summary").option("--json", "print raw JSON output; this is the default").description("Fetch billing summary").action(async () => {
10396
10417
  printJson(await createClient(loadConfig()).billing.getSummary());
10397
10418
  });
10398
- program2.command("billing:usage").option("--unit <unit>", "normalized_tflop_seconds, reserved_gpu_seconds, or usd").option("--run <runId>", "filter usage records to one run").description("List billing usage records").action(async (options) => {
10419
+ program2.command("billing:usage").option("--json", "print raw JSON output; this is the default").option("--unit <unit>", "normalized_tflop_seconds, reserved_gpu_seconds, or usd").option("--run <runId>", "filter usage records to one run").description("List billing usage records").action(async (options) => {
10399
10420
  const runId = normalizeOptionalId(options.run, "run", "Run ID");
10400
10421
  const unit = normalizeOptionalBillingUnit(options.unit);
10401
10422
  const client = createClient(loadConfig());
@@ -10404,24 +10425,36 @@ program2.command("billing:usage").option("--unit <unit>", "normalized_tflop_seco
10404
10425
  printJson(unit ? { ...summary, unit, usage: summary.usage.filter((entry) => entry.unit === unit) } : summary);
10405
10426
  return;
10406
10427
  }
10407
- printJson(await client.billing.getUsage(unit));
10428
+ const usage = await client.billing.getUsage(unit);
10429
+ printJson({
10430
+ recordCount: usage.length,
10431
+ responseShape: "usage_summary",
10432
+ runId: null,
10433
+ unit: unit ?? "all",
10434
+ usage
10435
+ });
10408
10436
  });
10409
- program2.command("billing:invoices").description("List invoices").action(async () => {
10410
- printJson(await createClient(loadConfig()).billing.listInvoices());
10437
+ program2.command("billing:invoices").option("--json", "print raw JSON output; this is the default unless --summary is used").option("--summary", "print a human-readable invoice reconciliation summary").description("List invoices").action(async (options) => {
10438
+ const invoices = await createClient(loadConfig()).billing.listInvoices();
10439
+ if (options.summary) {
10440
+ printInvoiceSummary(invoices);
10441
+ return;
10442
+ }
10443
+ printJson(invoices);
10411
10444
  });
10412
- program2.command("billing:margin").description("Fetch margin summary").action(async () => {
10445
+ program2.command("billing:margin").option("--json", "print raw JSON output; this is the default").description("Fetch margin summary").action(async () => {
10413
10446
  printJson(await createClient(loadConfig()).billing.getMarginSummary());
10414
10447
  });
10415
- program2.command("treasury:suppliers").description("List supplier adapters").action(async () => {
10448
+ program2.command("treasury:suppliers").option("--json", "print raw JSON output; this is the default").description("List supplier adapters").action(async () => {
10416
10449
  printJson(await createClient(loadConfig()).treasury.listSuppliers());
10417
10450
  });
10418
- program2.command("treasury:verifications").description("List supplier verifications").action(async () => {
10451
+ program2.command("treasury:verifications").option("--json", "print raw JSON output; this is the default").description("List supplier verifications").action(async () => {
10419
10452
  printJson(await createClient(loadConfig()).treasury.listSupplierVerifications());
10420
10453
  });
10421
- program2.command("treasury:billing").description("List supplier billing records").action(async () => {
10454
+ program2.command("treasury:billing").option("--json", "print raw JSON output; this is the default").description("List supplier billing records").action(async () => {
10422
10455
  printJson(await createClient(loadConfig()).treasury.listSupplierBillings());
10423
10456
  });
10424
- program2.command("treasury:funding").description("List supplier funding summaries").action(async () => {
10457
+ program2.command("treasury:funding").option("--json", "print raw JSON output; this is the default").description("List supplier funding summaries").action(async () => {
10425
10458
  printJson(await createClient(loadConfig()).treasury.listSupplierFunding());
10426
10459
  });
10427
10460
  program2.command("treasury:funding-preview").requiredOption("--estimated-supplier-cost <usd>").option("--supplier <supplierId>").option("--pool <poolId>").description("Preview treasury funding readiness for a supplier-backed launch").action(async (options) => {
@@ -10460,7 +10493,7 @@ program2.command("service-accounts:create").requiredOption("--name <name>").opti
10460
10493
  })
10461
10494
  );
10462
10495
  });
10463
- program2.command("service-accounts:list").description("List service accounts").action(async () => {
10496
+ program2.command("service-accounts:list").option("--json", "print raw JSON output; this is the default").description("List service accounts").action(async () => {
10464
10497
  printJson(await createClient(loadConfig()).serviceAccounts.list());
10465
10498
  });
10466
10499
  program2.command("service-accounts:revoke").argument("<serviceAccountId>").description("Revoke a service account").action(async (serviceAccountId) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trainfabric",
3
- "version": "0.1.50",
3
+ "version": "0.1.52",
4
4
  "description": "Trainfabric CLI for launching GPU training jobs on the hosted Trainfabric backend.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",