trainfabric 0.1.59 → 0.1.61

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 +30 -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.59";
9367
+ var CLI_VERSION = "0.1.61";
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");
@@ -9634,6 +9634,15 @@ function saveConfig(config) {
9634
9634
  function printJson(value) {
9635
9635
  console.log(JSON.stringify(value, null, 2));
9636
9636
  }
9637
+ function redactSecret(value) {
9638
+ if (!value) {
9639
+ return value;
9640
+ }
9641
+ if (value.length <= 12) {
9642
+ return "<redacted>";
9643
+ }
9644
+ return `${value.slice(0, 8)}\u2026${value.slice(-4)}`;
9645
+ }
9637
9646
  function shouldEmitJsonError() {
9638
9647
  return process.argv.includes("--json") && !process.argv.includes("--summary");
9639
9648
  }
@@ -10206,7 +10215,7 @@ program2.command("orgs:list").option("--json", "print raw JSON output; this is t
10206
10215
  program2.command("projects:list").option("--json", "print raw JSON output; this is the default").description("List projects in the active organization").action(async () => {
10207
10216
  printJson(await createClient(loadConfig()).projects.list());
10208
10217
  });
10209
- program2.command("projects:create").requiredOption("--name <name>").option("--org <organizationId>").description("Create a project").action(async (options) => {
10218
+ program2.command("projects:create").requiredOption("--name <name>").option("--org <organizationId>").option("--json", "print raw JSON output; this is the default").description("Create a project").action(async (options) => {
10210
10219
  printJson(
10211
10220
  await createClient(loadConfig()).projects.create({
10212
10221
  name: normalizeHumanName(options.name, "Project name"),
@@ -10226,7 +10235,7 @@ program2.command("projects:delete").argument("<projectId>").option("--json", "pr
10226
10235
  await client.projects.delete(normalizedProjectId);
10227
10236
  printJson({ deleted: true, id: normalizedProjectId });
10228
10237
  });
10229
- program2.command("datasets:validate").argument("<file>").description("Validate a local dataset file").action(async (file) => {
10238
+ program2.command("datasets:validate").argument("<file>").option("--json", "print raw JSON output; this is the default").description("Validate a local dataset file").action(async (file) => {
10230
10239
  assertReadableFile(file, "Dataset path");
10231
10240
  const validation = await createClient(loadConfig()).datasets.validate({
10232
10241
  path: file,
@@ -10243,7 +10252,7 @@ program2.command("datasets:list").option("--project <projectId>").option("--json
10243
10252
  program2.command("datasets:get").argument("<datasetId>").option("--json", "print raw JSON output; this is the default").description("Fetch dataset detail").action(async (datasetId) => {
10244
10253
  printJson(await createClient(loadConfig()).datasets.get(normalizeId(datasetId, "dataset", "Dataset ID")));
10245
10254
  });
10246
- program2.command("datasets:delete").argument("<datasetId>").description("Delete a dataset").action(async (datasetId) => {
10255
+ program2.command("datasets:delete").argument("<datasetId>").option("--json", "print raw JSON output; this is the default").description("Delete a dataset").action(async (datasetId) => {
10247
10256
  const normalizedDatasetId = normalizeId(datasetId, "dataset", "Dataset ID");
10248
10257
  const client = createClient(loadConfig());
10249
10258
  try {
@@ -10376,13 +10385,13 @@ program2.command("runs:configuration").argument("<runId>").option("--json", "pri
10376
10385
  program2.command("runs:explanation").argument("<runId>").option("--json", "print raw JSON output; this is the default").description("Fetch run planning explanation").action(async (runId) => {
10377
10386
  printJson(await createClient(loadConfig()).runs.explanation(normalizeId(runId, "run", "Run ID")));
10378
10387
  });
10379
- program2.command("runs:cancel").argument("<runId>").description("Cancel a run").action(async (runId) => {
10388
+ program2.command("runs:cancel").argument("<runId>").option("--json", "print raw JSON output; this is the default").description("Cancel a run").action(async (runId) => {
10380
10389
  printJson(await createClient(loadConfig()).runs.cancel(normalizeId(runId, "run", "Run ID")));
10381
10390
  });
10382
10391
  program2.command("runs:resume").argument("<runId>").option("--json", "print raw JSON output; this is the default").description("Resume a run from the latest checkpoint").action(async (runId) => {
10383
10392
  printJson(await createClient(loadConfig()).runs.resume(normalizeId(runId, "run", "Run ID")));
10384
10393
  });
10385
- program2.command("runs:terminate").argument("<runId>").description("Terminate a queued, launchable, or active run").action(async (runId) => {
10394
+ program2.command("runs:terminate").argument("<runId>").option("--json", "print raw JSON output; this is the default").description("Terminate a queued, launchable, or active run").action(async (runId) => {
10386
10395
  printJson(await createClient(loadConfig()).runs.terminate(normalizeId(runId, "run", "Run ID")));
10387
10396
  });
10388
10397
  program2.command("cluster:capacity").option("--json", "print raw JSON output; this is the default").description("Fetch cluster capacity view").action(async () => {
@@ -10411,14 +10420,20 @@ program2.command("deployments:create").requiredOption("--model <modelId>").optio
10411
10420
  try {
10412
10421
  printJson(await client.deployments.create({ modelId }));
10413
10422
  } catch (error) {
10414
- printJson({ error: error instanceof Error ? error.message : String(error) });
10423
+ printJson({
10424
+ error: {
10425
+ code: "command_failed",
10426
+ message: error instanceof Error ? error.message : String(error)
10427
+ },
10428
+ ok: false
10429
+ });
10415
10430
  process.exitCode = 1;
10416
10431
  }
10417
10432
  });
10418
10433
  program2.command("deployments:get").argument("<deploymentId>").option("--json", "print raw JSON output; this is the default").description("Fetch a deployment").action(async (deploymentId) => {
10419
10434
  printJson(await createClient(loadConfig()).deployments.get(normalizeId(deploymentId, "deployment", "Deployment ID")));
10420
10435
  });
10421
- program2.command("deployments:delete").argument("<deploymentId>").description("Delete a pending or cataloged deployment").action(async (deploymentId) => {
10436
+ program2.command("deployments:delete").argument("<deploymentId>").option("--json", "print raw JSON output; this is the default").description("Delete a pending or cataloged deployment").action(async (deploymentId) => {
10422
10437
  const normalizedDeploymentId = normalizeId(deploymentId, "deployment", "Deployment ID");
10423
10438
  await createClient(loadConfig()).deployments.delete(normalizedDeploymentId);
10424
10439
  printJson({ deleted: true, id: normalizedDeploymentId });
@@ -10476,7 +10491,7 @@ program2.command("treasury:funding-preview").requiredOption("--estimated-supplie
10476
10491
  })
10477
10492
  );
10478
10493
  });
10479
- program2.command("api-keys:create").requiredOption("--name <name>").option("--owner-type <ownerType>", "user or service_account", "user").option("--owner-id <ownerId>").option("--scopes <scopes>", "comma-separated scopes", "org:read,project:read,project:write,dataset:read,dataset:write,run:read,run:write").description("Create a scoped API key").action(async (options) => {
10494
+ program2.command("api-keys:create").requiredOption("--name <name>").option("--owner-type <ownerType>", "user or service_account", "user").option("--owner-id <ownerId>").option("--scopes <scopes>", "comma-separated scopes", "org:read,project:read,project:write,dataset:read,dataset:write,run:read,run:write").option("--json", "print raw JSON output; this is the default").option("--show-secret", "print the full one-time secret instead of a redacted preview").description("Create a scoped API key").action(async (options) => {
10480
10495
  const config = loadConfig();
10481
10496
  const session = await createClient(config).auth.me();
10482
10497
  const apiKey = await createClient(config).apiKeys.create({
@@ -10485,17 +10500,17 @@ program2.command("api-keys:create").requiredOption("--name <name>").option("--ow
10485
10500
  ownerId: options.ownerId ?? session.user.id,
10486
10501
  scopes: parseApiKeyScopes(String(options.scopes))
10487
10502
  });
10488
- printJson(apiKey);
10503
+ printJson(options.showSecret ? apiKey : { ...apiKey, secret: redactSecret(apiKey.secret), secretRedacted: true });
10489
10504
  });
10490
10505
  program2.command("api-keys:list").option("--json", "print raw JSON output; this is the default").description("List API keys").action(async () => {
10491
10506
  printJson(await createClient(loadConfig()).apiKeys.list());
10492
10507
  });
10493
- program2.command("api-keys:revoke").argument("<apiKeyId>").description("Revoke an API key").action(async (apiKeyId) => {
10508
+ program2.command("api-keys:revoke").argument("<apiKeyId>").option("--json", "print raw JSON output; this is the default").description("Revoke an API key").action(async (apiKeyId) => {
10494
10509
  const normalizedApiKeyId = normalizeId(apiKeyId, "apiKey", "API key ID");
10495
10510
  await createClient(loadConfig()).apiKeys.revoke(normalizedApiKeyId);
10496
- console.log(`Revoked API key ${normalizedApiKeyId}.`);
10511
+ printJson({ revoked: true, id: normalizedApiKeyId });
10497
10512
  });
10498
- program2.command("service-accounts:create").requiredOption("--name <name>").option("--scopes <scopes>", "comma-separated scopes", "org:read,project:read,project:write,dataset:read,dataset:write,run:read,run:write").description("Create a service account").action(async (options) => {
10513
+ program2.command("service-accounts:create").requiredOption("--name <name>").option("--scopes <scopes>", "comma-separated scopes", "org:read,project:read,project:write,dataset:read,dataset:write,run:read,run:write").option("--json", "print raw JSON output; this is the default").description("Create a service account").action(async (options) => {
10499
10514
  printJson(
10500
10515
  await createClient(loadConfig()).serviceAccounts.create({
10501
10516
  name: normalizeHumanName(options.name, "Service account name"),
@@ -10506,10 +10521,10 @@ program2.command("service-accounts:create").requiredOption("--name <name>").opti
10506
10521
  program2.command("service-accounts:list").option("--json", "print raw JSON output; this is the default").description("List service accounts").action(async () => {
10507
10522
  printJson(await createClient(loadConfig()).serviceAccounts.list());
10508
10523
  });
10509
- program2.command("service-accounts:revoke").argument("<serviceAccountId>").description("Revoke a service account").action(async (serviceAccountId) => {
10524
+ program2.command("service-accounts:revoke").argument("<serviceAccountId>").option("--json", "print raw JSON output; this is the default").description("Revoke a service account").action(async (serviceAccountId) => {
10510
10525
  const normalizedServiceAccountId = normalizeId(serviceAccountId, "serviceAccount", "Service account ID");
10511
10526
  await createClient(loadConfig()).serviceAccounts.revoke(normalizedServiceAccountId);
10512
- console.log(`Revoked service account ${normalizedServiceAccountId}.`);
10527
+ printJson({ revoked: true, id: normalizedServiceAccountId });
10513
10528
  });
10514
10529
  void program2.parseAsync(process.argv).catch((error) => {
10515
10530
  const message = error instanceof Error ? error.message : String(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trainfabric",
3
- "version": "0.1.59",
3
+ "version": "0.1.61",
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",