@computesdk/cli 2.6.6 → 2.6.7

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/cli-manifest.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": 1,
3
3
  "bin": "compute",
4
4
  "package": "@computesdk/cli",
5
- "version": "2.6.6",
5
+ "version": "2.6.7",
6
6
  "source": {
7
7
  "repo": "computesdk/computesdk",
8
8
  "released": false
@@ -1690,6 +1690,60 @@
1690
1690
  ],
1691
1691
  "summary": "Drop a provider's custom rate; its costs report at the platform rate again (owner/admin)"
1692
1692
  },
1693
+ {
1694
+ "path": [
1695
+ "credits"
1696
+ ],
1697
+ "aliases": [],
1698
+ "args": [],
1699
+ "flags": [
1700
+ "--api-key",
1701
+ "--base-url",
1702
+ "--org",
1703
+ "--allow-untrusted-host",
1704
+ "--json",
1705
+ "--help"
1706
+ ],
1707
+ "summary": "Your prepaid credit — managed accounts bill from it: balance, ledger, top-ups"
1708
+ },
1709
+ {
1710
+ "path": [
1711
+ "credits",
1712
+ "ledger"
1713
+ ],
1714
+ "aliases": [],
1715
+ "args": [],
1716
+ "flags": [
1717
+ "--limit",
1718
+ "--cursor",
1719
+ "--api-key",
1720
+ "--base-url",
1721
+ "--org",
1722
+ "--allow-untrusted-host",
1723
+ "--json",
1724
+ "--help"
1725
+ ],
1726
+ "summary": "Credit history, newest first: top-ups, grants, holds, charges, refunds"
1727
+ },
1728
+ {
1729
+ "path": [
1730
+ "credits",
1731
+ "topup"
1732
+ ],
1733
+ "aliases": [],
1734
+ "args": [
1735
+ "<usd>"
1736
+ ],
1737
+ "flags": [
1738
+ "--api-key",
1739
+ "--base-url",
1740
+ "--org",
1741
+ "--allow-untrusted-host",
1742
+ "--json",
1743
+ "--help"
1744
+ ],
1745
+ "summary": "Add credit — prints a Stripe checkout link to pay in your browser (owner/admin)"
1746
+ },
1693
1747
  {
1694
1748
  "path": [
1695
1749
  "instances"
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  import "dotenv/config";
5
5
  import { Command as Command4 } from "commander";
6
6
  import * as p from "@clack/prompts";
7
- import pc13 from "picocolors";
7
+ import pc14 from "picocolors";
8
8
  import { readFileSync as readFileSync6 } from "fs";
9
9
  import { fileURLToPath } from "url";
10
10
  import { dirname as dirname3, join as join5 } from "path";
@@ -2838,7 +2838,7 @@ function formatCredits(b) {
2838
2838
  const lines = [`available ${formatMoney(b.balanceMicroUsd / MICRO_USD)}`];
2839
2839
  if (b.holds.length > 0) {
2840
2840
  lines.push(
2841
- pc9.dim(`reserved ${formatMoney(b.heldMicroUsd / MICRO_USD)} across ${b.holds.length} running job${b.holds.length === 1 ? "" : "s"}`)
2841
+ pc9.dim(`reserved ${formatMoney(b.heldMicroUsd / MICRO_USD)} across ${b.holds.length} running sandbox${b.holds.length === 1 ? "" : "es"} or job${b.holds.length === 1 ? "" : "s"}`)
2842
2842
  );
2843
2843
  }
2844
2844
  return lines.join("\n");
@@ -3162,7 +3162,7 @@ function registerMarketCommands(program2) {
3162
3162
  const page = await (await client(opts)).get("/api/v1/billing/ledger", { limit: opts.limit, cursor: opts.cursor });
3163
3163
  output(opts, page, (p2) => {
3164
3164
  if (p2.entries.length === 0) {
3165
- console.log("No credit activity yet \u2014 add credits with `compute market topup`.");
3165
+ console.log("No credit activity yet \u2014 add credit with `compute credits topup <usd>`.");
3166
3166
  return;
3167
3167
  }
3168
3168
  for (const entry of p2.entries) console.log(formatLedgerRow(entry));
@@ -3250,6 +3250,63 @@ ${hints}`
3250
3250
  });
3251
3251
  }
3252
3252
 
3253
+ // src/credits.ts
3254
+ import pc10 from "picocolors";
3255
+ var MICRO_USD2 = 1e6;
3256
+ function registerCreditsCommands(program2) {
3257
+ const common2 = (cmd) => cmd.option("--api-key <key>", "API key (default: $COMPUTE_API_KEY)").option("--base-url <url>", "API base URL (default: https://platform.computesdk.com)").option("--org <slug>", "organization slug for this command (or $COMPUTE_ORG)").option("--allow-untrusted-host", "send an explicit --api-key/env key to a non-computesdk, non-localhost --base-url (stored login credentials are never sent)").option("--json", "print machine-readable JSON");
3258
+ const credits = common2(
3259
+ program2.command("credits").description("Your prepaid credit \u2014 managed accounts bill from it: balance, ledger, top-ups").configureOutput({ outputError: usageErrorOutput })
3260
+ ).action(async (opts) => {
3261
+ try {
3262
+ const balance = await (await client(opts)).get("/api/v1/billing/balance");
3263
+ output(opts, balance, (b) => console.log(formatCredits(b)));
3264
+ } catch (e) {
3265
+ fail(e, opts);
3266
+ }
3267
+ });
3268
+ common2(
3269
+ credits.command("ledger").description("Credit history, newest first: top-ups, grants, holds, charges, refunds").option("--limit <n>", "entries per page (max 200, default 50)").option("--cursor <cursor>", "continue from a previous page")
3270
+ ).action(async (opts) => {
3271
+ try {
3272
+ const page = await (await client(opts)).get(
3273
+ "/api/v1/billing/ledger",
3274
+ { limit: opts.limit, cursor: opts.cursor }
3275
+ );
3276
+ output(opts, page, (p2) => {
3277
+ if (p2.entries.length === 0) {
3278
+ console.log("No credit activity yet \u2014 add credit with `compute credits topup <usd>`.");
3279
+ return;
3280
+ }
3281
+ for (const entry of p2.entries) console.log(formatLedgerRow(entry));
3282
+ if (p2.nextCursor) console.log(pc10.dim(`more: --cursor ${p2.nextCursor}`));
3283
+ });
3284
+ } catch (e) {
3285
+ fail(e, opts);
3286
+ }
3287
+ });
3288
+ common2(
3289
+ credits.command("topup").description("Add credit \u2014 prints a Stripe checkout link to pay in your browser (owner/admin)").argument("<usd>", "amount to pay in USD (e.g. 50)")
3290
+ ).action(async (amount, opts) => {
3291
+ try {
3292
+ const result = await (await client(opts)).post("/api/v1/billing/topups", {
3293
+ amountUsd: parseTopupAmount(amount)
3294
+ });
3295
+ output(opts, result, (r) => {
3296
+ const pay = formatMoney(r.amountMicroUsd / MICRO_USD2);
3297
+ if (r.creditMicroUsd !== void 0 && r.feeBps !== void 0 && r.feeBps > 0) {
3298
+ console.log(`Pay ${pay} for ${formatMoney(r.creditMicroUsd / MICRO_USD2)} of credit (${r.feeBps / 100}% top-up fee) at:`);
3299
+ } else {
3300
+ console.log(`Pay ${pay} at:`);
3301
+ }
3302
+ console.log(r.url ?? pc10.dim("(no checkout link returned)"));
3303
+ });
3304
+ } catch (e) {
3305
+ fail(e, opts);
3306
+ }
3307
+ });
3308
+ }
3309
+
3253
3310
  // src/sandboxes.ts
3254
3311
  import * as fs from "fs";
3255
3312
  import * as os from "os";
@@ -3257,7 +3314,7 @@ import * as path from "path";
3257
3314
  import * as readline from "readline";
3258
3315
  import { Readable } from "stream";
3259
3316
  import { Option as Option3 } from "commander";
3260
- import pc10 from "picocolors";
3317
+ import pc11 from "picocolors";
3261
3318
  import * as tar from "tar";
3262
3319
 
3263
3320
  // src/current-instance.ts
@@ -3438,22 +3495,22 @@ function formatLocalTime(iso) {
3438
3495
  function printSandbox(s, verbose = false) {
3439
3496
  const p2 = s.placement;
3440
3497
  console.log(
3441
- `${pc10.cyan(s.id)} ${s.status} ${p2?.box?.provider ?? s.provider ?? "\u2014"} \xB7 ${placementLane(p2?.source)} ${p2?.size ?? "\u2014"} ${p2 ? shortRate(p2.rate) : "\u2014"}`
3498
+ `${pc11.cyan(s.id)} ${s.status} ${p2?.box?.provider ?? s.provider ?? "\u2014"} \xB7 ${placementLane(p2?.source)} ${p2?.size ?? "\u2014"} ${p2 ? shortRate(p2.rate) : "\u2014"}`
3442
3499
  );
3443
3500
  if (s.label) {
3444
3501
  console.log(` label: ${s.label} created: ${formatLocalTime(s.createdAt)}`);
3445
3502
  }
3446
- if (s.destroyError) console.log(` destroyError: ${pc10.red(s.destroyError)}`);
3503
+ if (s.destroyError) console.log(` destroyError: ${pc11.red(s.destroyError)}`);
3447
3504
  if (!verbose) return;
3448
3505
  console.log(` providerSandboxId: ${s.providerSandboxId ?? "\u2014"} commands: ${s.commandCount}`);
3449
3506
  if (s.image !== void 0) {
3450
- console.log(` image: ${s.image ?? "\u2014"}${s.requestedImage !== null && s.requestedImage !== s.image ? ` ${pc10.dim(`(requested: ${s.requestedImage})`)}` : ""}`);
3507
+ console.log(` image: ${s.image ?? "\u2014"}${s.requestedImage !== null && s.requestedImage !== s.image ? ` ${pc11.dim(`(requested: ${s.requestedImage})`)}` : ""}`);
3451
3508
  }
3452
3509
  if (p2) {
3453
3510
  const box = p2.box ? ` / ${p2.box.sizeName ?? "custom"}${p2.box.resources ? ` (${p2.box.resources.cpus ?? "?"} vCPU / ${p2.box.resources.memoryMb ?? "?"} MB)` : ""}` : "";
3454
3511
  const provider = p2.box?.provider ?? s.provider ?? "the provider";
3455
3512
  console.log(
3456
- ` placement: ${placementLane(p2.source)}${box} rate: ${formatUsdPer(p2.rate)} ${pc10.dim(billedBy(p2.source, provider))}`
3513
+ ` placement: ${placementLane(p2.source)}${box} rate: ${formatUsdPer(p2.rate)} ${pc11.dim(billedBy(p2.source, provider))}`
3457
3514
  );
3458
3515
  }
3459
3516
  const attach = "attach" in s ? s.attach : void 0;
@@ -3482,7 +3539,7 @@ function quoteRefusal(q) {
3482
3539
  function printQuote(q, timeoutMs) {
3483
3540
  const row = (label, value) => console.log(`${label.padEnd(10)} ${value}`);
3484
3541
  if (!q.ok || !q.placement) {
3485
- row("Lands on", pc10.red(`nowhere \u2014 ${quoteRefusal(q)}`));
3542
+ row("Lands on", pc11.red(`nowhere \u2014 ${quoteRefusal(q)}`));
3486
3543
  if (q.reason === "insufficient_credits" && q.topUpPath) row("Top up", q.topUpPath);
3487
3544
  } else {
3488
3545
  const p2 = q.placement;
@@ -3504,11 +3561,11 @@ function printQuote(q, timeoutMs) {
3504
3561
  function printProcess(p2) {
3505
3562
  const exit = p2.status === "exited" ? `exit=${p2.exitCode ?? "?"}${p2.signal ? ` (${p2.signal})` : ""}` : "";
3506
3563
  const stdin = p2.stdin && p2.status === "running" ? " [stdin open]" : "";
3507
- console.log(`${pc10.cyan(p2.jobId)} ${p2.status}${exit ? " " + exit : ""}${stdin} ${p2.command}`);
3564
+ console.log(`${pc11.cyan(p2.jobId)} ${p2.status}${exit ? " " + exit : ""}${stdin} ${p2.command}`);
3508
3565
  }
3509
3566
  function printSnapshot(s) {
3510
- const state = s.deletedAt !== null ? ` ${pc10.dim(`(deleted ${s.deletedAt})`)}` : "";
3511
- console.log(`${pc10.cyan(s.id)} ${s.providerSnapshotId}${state}`);
3567
+ const state = s.deletedAt !== null ? ` ${pc11.dim(`(deleted ${s.deletedAt})`)}` : "";
3568
+ console.log(`${pc11.cyan(s.id)} ${s.providerSnapshotId}${state}`);
3512
3569
  console.log(
3513
3570
  ` provider: ${s.provider}${s.region ? ` (${s.region})` : ""} label: ${s.label ?? "\u2014"} created: ${s.createdAt}${s.expiresAt ? ` expires: ${s.expiresAt}` : ""}`
3514
3571
  );
@@ -3611,7 +3668,7 @@ function resolveSandbox(argId, opts) {
3611
3668
  if (!r) throw new Error(NO_INSTANCE_HINT);
3612
3669
  if (r.source !== "argument" && !opts.json && !opts.quiet) {
3613
3670
  console.error(
3614
- pc10.dim(
3671
+ pc11.dim(
3615
3672
  `instance ${shortId(r.id)} (${r.source === "env" ? "COMPUTE_INSTANCE" : `current for ${r.dir}`})`
3616
3673
  )
3617
3674
  );
@@ -3622,7 +3679,7 @@ function resolveSandbox(argId, opts) {
3622
3679
  clearStale: (error) => {
3623
3680
  if (r.source === "file" && error instanceof PlatformApiError && error.status === 404 && readFileCurrent(org2) === r.id) {
3624
3681
  clearCurrentInstance(org2);
3625
- console.error(pc10.dim(`cleared stale current instance ${shortId(r.id)}`));
3682
+ console.error(pc11.dim(`cleared stale current instance ${shortId(r.id)}`));
3626
3683
  }
3627
3684
  }
3628
3685
  };
@@ -3730,7 +3787,7 @@ function registerCreate(command2, { providerShorthand = false } = {}) {
3730
3787
  if (opts.use !== false) {
3731
3788
  setCurrentInstance(res.sandbox.id, orgKey(opts));
3732
3789
  if (!opts.json && !opts.quiet) {
3733
- console.error(pc10.dim(`instance ${shortId(res.sandbox.id)} (current for ${dirKey()})`));
3790
+ console.error(pc11.dim(`instance ${shortId(res.sandbox.id)} (current for ${dirKey()})`));
3734
3791
  }
3735
3792
  }
3736
3793
  emitResult(opts, res.sandbox, (s) => s.id, (s) => printSandbox(s, opts.verbose));
@@ -3758,13 +3815,13 @@ async function previewPlacement(c, opts) {
3758
3815
  return;
3759
3816
  }
3760
3817
  if (!quote.ok || !quote.placement) {
3761
- console.error(pc10.dim(`\u2192 the router can't place this: ${quoteRefusal(quote)}`));
3818
+ console.error(pc11.dim(`\u2192 the router can't place this: ${quoteRefusal(quote)}`));
3762
3819
  return;
3763
3820
  }
3764
3821
  const p2 = quote.placement;
3765
3822
  const provider = p2.box?.provider ?? p2.provider;
3766
3823
  console.error(
3767
- pc10.dim(`\u2192 placing on ${provider} \xB7 ${placementLane(p2.source)} \xB7 ${p2.size ?? p2.box?.sizeName ?? "custom size"} (${billedBy(p2.source, provider)}) \u2026`)
3824
+ pc11.dim(`\u2192 placing on ${provider} \xB7 ${placementLane(p2.source)} \xB7 ${p2.size ?? p2.box?.sizeName ?? "custom size"} (${billedBy(p2.source, provider)}) \u2026`)
3768
3825
  );
3769
3826
  }
3770
3827
  function shorthandProviders(operands) {
@@ -3833,7 +3890,7 @@ function registerSandboxesCommands(program2) {
3833
3890
  (page) => page.sandboxes.map((s) => s.id).join("\n"),
3834
3891
  (page) => {
3835
3892
  page.sandboxes.forEach((s) => printSandbox(s, opts.verbose));
3836
- if (page.nextCursor) console.log(pc10.dim(`nextCursor: ${page.nextCursor}`));
3893
+ if (page.nextCursor) console.log(pc11.dim(`nextCursor: ${page.nextCursor}`));
3837
3894
  }
3838
3895
  );
3839
3896
  } catch (e) {
@@ -3906,7 +3963,7 @@ function registerSandboxesCommands(program2) {
3906
3963
  if (readFileCurrent(org2) === resolved.id) {
3907
3964
  clearCurrentInstance(org2);
3908
3965
  if (!opts.json) {
3909
- console.error(pc10.dim(`cleared current instance ${shortId(resolved.id)}`));
3966
+ console.error(pc11.dim(`cleared current instance ${shortId(resolved.id)}`));
3910
3967
  }
3911
3968
  }
3912
3969
  output(opts, res.sandbox, printSandbox);
@@ -4099,7 +4156,7 @@ function registerSandboxesCommands(program2) {
4099
4156
  data = opts.base64 ? piped.toString("base64") : piped.toString("utf8");
4100
4157
  }
4101
4158
  if (data === void 0 || data === "") {
4102
- console.error(pc10.red("Pass --data, --file, or pipe stdin"));
4159
+ console.error(pc11.red("Pass --data, --file, or pipe stdin"));
4103
4160
  process.exit(1);
4104
4161
  }
4105
4162
  if (opts.base64 && opts.data !== void 0) {
@@ -4147,7 +4204,7 @@ function registerSandboxesCommands(program2) {
4147
4204
  output(opts, res, (view) => {
4148
4205
  if (view.type === "directory") {
4149
4206
  for (const e of view.entries) {
4150
- console.log(`${e.type === "directory" ? pc10.blue("d") : " "} ${e.name}${e.size !== void 0 ? ` ${pc10.dim(String(e.size))}` : ""}`);
4207
+ console.log(`${e.type === "directory" ? pc11.blue("d") : " "} ${e.name}${e.size !== void 0 ? ` ${pc11.dim(String(e.size))}` : ""}`);
4151
4208
  }
4152
4209
  } else {
4153
4210
  console.log(`${view.path} file ${view.content.length} chars`);
@@ -4174,7 +4231,7 @@ function registerSandboxesCommands(program2) {
4174
4231
  const res = await c.get(`/api/v1/sandboxes/${resolved.id}/files`, { path: p2 });
4175
4232
  output(opts, res, (view) => {
4176
4233
  if (view.type !== "file") {
4177
- console.error(pc10.red(`${view.path} is a directory`));
4234
+ console.error(pc11.red(`${view.path} is a directory`));
4178
4235
  process.exit(1);
4179
4236
  }
4180
4237
  process.stdout.write(view.content);
@@ -4211,7 +4268,7 @@ function registerSandboxesCommands(program2) {
4211
4268
  });
4212
4269
  }
4213
4270
  if (content === void 0) {
4214
- console.error(pc10.red("Pass --content, --file, or pipe stdin"));
4271
+ console.error(pc11.red("Pass --content, --file, or pipe stdin"));
4215
4272
  process.exit(1);
4216
4273
  }
4217
4274
  const c = await client(opts);
@@ -4347,11 +4404,11 @@ async function followProcess(c, sandboxId, jobId) {
4347
4404
  exitCode = typeof payload.exitCode === "number" ? payload.exitCode : 128;
4348
4405
  return finish();
4349
4406
  } else if (event === "error") {
4350
- console.error(pc10.red(`Error: ${String(payload.error ?? "stream error")}`));
4407
+ console.error(pc11.red(`Error: ${String(payload.error ?? "stream error")}`));
4351
4408
  return finish(1);
4352
4409
  }
4353
4410
  }
4354
- console.error(pc10.yellow("stream ended before the process exited"));
4411
+ console.error(pc11.yellow("stream ended before the process exited"));
4355
4412
  return finish(2);
4356
4413
  function finish(code) {
4357
4414
  if (code !== void 0) exitCode = code;
@@ -4372,7 +4429,7 @@ async function runInstanceCommand(command2, opts) {
4372
4429
  const created = await c.post("/api/v1/sandboxes", buildCreateBody(opts));
4373
4430
  const sandbox = created.sandbox;
4374
4431
  const org2 = orgKey(opts);
4375
- console.error(pc10.dim(`instance ${sandbox.id}`));
4432
+ console.error(pc11.dim(`instance ${sandbox.id}`));
4376
4433
  const spawned = await c.post(
4377
4434
  `/api/v1/sandboxes/${sandbox.id}/processes`,
4378
4435
  { command: command2.map(shellQuote).join(" ") }
@@ -4450,7 +4507,7 @@ async function runInstanceCommand(command2, opts) {
4450
4507
  setCurrentInstance(sandbox.id, org2);
4451
4508
  if (opts.quiet) console.log(sandbox.id);
4452
4509
  else {
4453
- console.error(pc10.dim(`kept instance ${shortId(sandbox.id)} (current for ${dirKey()})`));
4510
+ console.error(pc11.dim(`kept instance ${shortId(sandbox.id)} (current for ${dirKey()})`));
4454
4511
  console.log(sandbox.id);
4455
4512
  }
4456
4513
  } else {
@@ -4458,7 +4515,7 @@ async function runInstanceCommand(command2, opts) {
4458
4515
  await c.del(`/api/v1/sandboxes/${sandbox.id}`);
4459
4516
  } catch (e) {
4460
4517
  console.error(
4461
- pc10.red(`destroy failed for ${sandbox.id}: ${e instanceof Error ? e.message : String(e)}`)
4518
+ pc11.red(`destroy failed for ${sandbox.id}: ${e instanceof Error ? e.message : String(e)}`)
4462
4519
  );
4463
4520
  if (exitCode === null || exitCode === 0) exitCode = 1;
4464
4521
  }
@@ -4486,7 +4543,7 @@ async function serveInstanceCommand(id, command2, port, opts) {
4486
4543
  if (!opts.json) {
4487
4544
  const logs = `${proc.stdout}${proc.stderr}`.trimEnd().split("\n");
4488
4545
  if (logs.length > 0 && logs[0] !== "") {
4489
- console.error(pc10.dim("--- last log lines ---"));
4546
+ console.error(pc11.dim("--- last log lines ---"));
4490
4547
  for (const line of logs.slice(-50)) console.error(safeTerm(line));
4491
4548
  }
4492
4549
  }
@@ -4541,9 +4598,9 @@ async function serveInstanceCommand(id, command2, port, opts) {
4541
4598
  });
4542
4599
  }
4543
4600
  function printServeJobFooter(sandboxId, jobId) {
4544
- console.error(pc10.dim(` job ${jobId}`));
4545
- console.error(pc10.dim(` logs: compute instances logs ${sandboxId} ${jobId}`));
4546
- console.error(pc10.dim(` kill: compute instances kill ${sandboxId} ${jobId}`));
4601
+ console.error(pc11.dim(` job ${jobId}`));
4602
+ console.error(pc11.dim(` logs: compute instances logs ${sandboxId} ${jobId}`));
4603
+ console.error(pc11.dim(` kill: compute instances kill ${sandboxId} ${jobId}`));
4547
4604
  }
4548
4605
  var CP_PROGRESS_MIN_BYTES = 10 * 1024 * 1024;
4549
4606
  function assertTransferUrl(raw) {
@@ -4701,7 +4758,7 @@ function formatBytes(n) {
4701
4758
  }
4702
4759
 
4703
4760
  // src/agents.ts
4704
- import pc11 from "picocolors";
4761
+ import pc12 from "picocolors";
4705
4762
  import { readFileSync as readFileSync4 } from "fs";
4706
4763
  function formatLocalTime2(iso) {
4707
4764
  if (iso === null) return "\u2014";
@@ -4712,7 +4769,7 @@ function formatLocalTime2(iso) {
4712
4769
  }
4713
4770
  function printAgent(a) {
4714
4771
  console.log(
4715
- `${pc11.cyan(safeTerm(a.name))} ${a.id.slice(0, 8)} ${a.harness}${a.model ? ` ${safeTerm(a.model)}` : ""} sessions: ${a.sessionCount} created: ${formatLocalTime2(a.createdAt)}`
4772
+ `${pc12.cyan(safeTerm(a.name))} ${a.id.slice(0, 8)} ${a.harness}${a.model ? ` ${safeTerm(a.model)}` : ""} sessions: ${a.sessionCount} created: ${formatLocalTime2(a.createdAt)}`
4716
4773
  );
4717
4774
  }
4718
4775
  function printAgentDetail(a) {
@@ -4723,13 +4780,13 @@ function printAgentDetail(a) {
4723
4780
  }
4724
4781
  function printSession(s) {
4725
4782
  console.log(
4726
- `${pc11.cyan(s.id)} ${s.status} sandbox: ${s.sandboxId ?? "\u2014"} ${formatLocalTime2(s.createdAt)}${s.error ? ` ${pc11.red(safeTerm(s.error))}` : ""}`
4783
+ `${pc12.cyan(s.id)} ${s.status} sandbox: ${s.sandboxId ?? "\u2014"} ${formatLocalTime2(s.createdAt)}${s.error ? ` ${pc12.red(safeTerm(s.error))}` : ""}`
4727
4784
  );
4728
4785
  }
4729
4786
  function printEvent(e) {
4730
4787
  const payload = e.payload ?? {};
4731
4788
  if (e.kind === "user") {
4732
- console.log(`${pc11.green("you")} #${e.seq} ${safeTerm(String(payload.message ?? ""))}`);
4789
+ console.log(`${pc12.green("you")} #${e.seq} ${safeTerm(String(payload.message ?? ""))}`);
4733
4790
  return;
4734
4791
  }
4735
4792
  if (e.kind === "turn") {
@@ -4737,12 +4794,12 @@ function printEvent(e) {
4737
4794
  for (const ev of events) {
4738
4795
  const o = ev;
4739
4796
  const text = o.text ?? o.message ?? o.content;
4740
- if (typeof text === "string") console.log(pc11.dim(`#${e.seq}`) + ` ${safeTerm(text)}`);
4741
- else console.log(pc11.dim(`#${e.seq} ${safeTerm(JSON.stringify(o))}`));
4797
+ if (typeof text === "string") console.log(pc12.dim(`#${e.seq}`) + ` ${safeTerm(text)}`);
4798
+ else console.log(pc12.dim(`#${e.seq} ${safeTerm(JSON.stringify(o))}`));
4742
4799
  }
4743
4800
  return;
4744
4801
  }
4745
- console.log(pc11.dim(`#${e.seq} ${e.kind} ${safeTerm(JSON.stringify(payload))}`));
4802
+ console.log(pc12.dim(`#${e.seq} ${e.kind} ${safeTerm(JSON.stringify(payload))}`));
4746
4803
  }
4747
4804
  function authOpts(cmd) {
4748
4805
  return cmd.option("--api-key <key>", "platform API key (or COMPUTE_API_KEY)").option("--base-url <url>", "platform base URL").option("--allow-untrusted-host", "allow non-computesdk.com base URLs").option("--org <slug>", "organization slug (or COMPUTE_ORG)").option("--json", "print the raw response");
@@ -4793,7 +4850,7 @@ function registerAgentsCommands(program2) {
4793
4850
  });
4794
4851
  output(opts, res, (r) => {
4795
4852
  printAgentDetail(r.agent);
4796
- console.error(pc11.dim(`agent ${r.agent.name} created \u2014 run it with \`compute agents run ${r.agent.name} "\u2026"\``));
4853
+ console.error(pc12.dim(`agent ${r.agent.name} created \u2014 run it with \`compute agents run ${r.agent.name} "\u2026"\``));
4797
4854
  });
4798
4855
  } catch (e) {
4799
4856
  fail(e, opts);
@@ -4847,7 +4904,7 @@ function registerAgentsCommands(program2) {
4847
4904
  const c = await client(opts);
4848
4905
  if (!opts.yes) {
4849
4906
  const res = await c.get(`/api/v1/agents/${encodeURIComponent(ref)}`);
4850
- console.error(`Deleting agent ${pc11.cyan(res.agent.name)} (${res.agent.id}). Pass -y to confirm.`);
4907
+ console.error(`Deleting agent ${pc12.cyan(res.agent.name)} (${res.agent.id}). Pass -y to confirm.`);
4851
4908
  process.exit(1);
4852
4909
  }
4853
4910
  await c.del(`/api/v1/agents/${encodeURIComponent(ref)}`);
@@ -4884,7 +4941,7 @@ function registerAgentsCommands(program2) {
4884
4941
  output(opts, res, (r) => {
4885
4942
  printSession(r.session);
4886
4943
  for (const e of r.events) printEvent(e);
4887
- console.error(pc11.dim(`session ${r.session.id} \u2014 continue with \`compute agents send ${r.session.id} "\u2026"\``));
4944
+ console.error(pc12.dim(`session ${r.session.id} \u2014 continue with \`compute agents send ${r.session.id} "\u2026"\``));
4888
4945
  });
4889
4946
  } catch (e) {
4890
4947
  fail(e, opts);
@@ -5280,7 +5337,7 @@ function registerManifestCommand(program2, options) {
5280
5337
  }
5281
5338
 
5282
5339
  // src/org-members.ts
5283
- import pc12 from "picocolors";
5340
+ import pc13 from "picocolors";
5284
5341
  var ORG_PATH = "/api/v1/organizations/current";
5285
5342
  var MEMBER_ROLES = ["member", "admin"];
5286
5343
  var USER_LOGIN_HINT = "This needs a user login, and org API keys have no user: run `compute login`, and drop --api-key / unset COMPUTE_API_KEY.";
@@ -5319,10 +5376,10 @@ function fail2(error, opts = {}) {
5319
5376
  process.stderr.write(JSON.stringify(envelope) + "\n");
5320
5377
  } else if (error instanceof PlatformApiError) {
5321
5378
  const code = error.code !== codeForStatus(error.status) ? ` ${error.code}` : "";
5322
- console.error(pc12.red(`Error (${error.status}${code}): ${error.message}`));
5323
- if (hint) console.error(pc12.dim(`hint: ${hint}`));
5379
+ console.error(pc13.red(`Error (${error.status}${code}): ${error.message}`));
5380
+ if (hint) console.error(pc13.dim(`hint: ${hint}`));
5324
5381
  } else {
5325
- console.error(pc12.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
5382
+ console.error(pc13.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
5326
5383
  }
5327
5384
  process.exit(1);
5328
5385
  }
@@ -5374,7 +5431,7 @@ function printUserInvitations(res) {
5374
5431
  safeTerm(i.organization.name)
5375
5432
  ])
5376
5433
  );
5377
- console.log(pc12.dim("Accept with `compute invitations accept <id>`; decline with `compute invitations decline <id> -y`."));
5434
+ console.log(pc13.dim("Accept with `compute invitations accept <id>`; decline with `compute invitations decline <id> -y`."));
5378
5435
  }
5379
5436
  function printInvitationDetail(inv) {
5380
5437
  const rows = [
@@ -5395,7 +5452,7 @@ function printInvite(res) {
5395
5452
  console.log(`Emailed ${safeTerm(inv.email)} the invitation link.`);
5396
5453
  } else {
5397
5454
  const reason = res.emailError ? ` (${safeTerm(res.emailError)})` : "";
5398
- console.log(pc12.yellow(`The invitation email was not sent${reason}; share the link instead.`));
5455
+ console.log(pc13.yellow(`The invitation email was not sent${reason}; share the link instead.`));
5399
5456
  }
5400
5457
  console.log(`Link: ${safeTerm(inv.url)}`);
5401
5458
  }
@@ -5519,7 +5576,7 @@ function registerOrgMemberCommands(org2) {
5519
5576
  output(opts, res, () => {
5520
5577
  console.log(`Left ${org3 ?? "the organization"}.`);
5521
5578
  console.log(
5522
- pc12.dim("If your login was granted for that organization, it no longer works: run `compute login` again.")
5579
+ pc13.dim("If your login was granted for that organization, it no longer works: run `compute login` again.")
5523
5580
  );
5524
5581
  });
5525
5582
  } catch (e) {
@@ -5558,7 +5615,7 @@ function registerInvitationsCommands(program2) {
5558
5615
  output(opts, res, (r) => {
5559
5616
  const slug = safeTerm(r.organization.slug);
5560
5617
  console.log(`Joined ${slug} as ${safeTerm(r.member.role)}.`);
5561
- console.log(pc12.dim(`Switch to it with \`compute org use ${slug}\`, or pass --org ${slug}.`));
5618
+ console.log(pc13.dim(`Switch to it with \`compute org use ${slug}\`, or pass --org ${slug}.`));
5562
5619
  });
5563
5620
  } catch (e) {
5564
5621
  fail2(e, opts);
@@ -5632,18 +5689,18 @@ async function runLogout() {
5632
5689
  program.option("--login", "force re-authentication").option("--logout", "clear stored credentials").option("--org <slug>", "organization slug override for this invocation (or $COMPUTE_ORG)").action(async (opts) => {
5633
5690
  if (opts.logout) {
5634
5691
  console.log();
5635
- p.intro(pc13.cyan(`@computesdk/cli v${VERSION}`));
5692
+ p.intro(pc14.cyan(`@computesdk/cli v${VERSION}`));
5636
5693
  await runLogout();
5637
5694
  p.log.success("Logged out. Stored credentials removed.");
5638
- p.outro(pc13.green("Done!"));
5695
+ p.outro(pc14.green("Done!"));
5639
5696
  process.exit(0);
5640
5697
  }
5641
5698
  if (opts.login) {
5642
5699
  console.log();
5643
- p.intro(pc13.cyan(`@computesdk/cli v${VERSION}`));
5700
+ p.intro(pc14.cyan(`@computesdk/cli v${VERSION}`));
5644
5701
  await runLogin();
5645
5702
  await printSessionLine();
5646
- p.outro(pc13.green("Authenticated!"));
5703
+ p.outro(pc14.green("Authenticated!"));
5647
5704
  process.exit(0);
5648
5705
  }
5649
5706
  program.help();
@@ -5654,23 +5711,23 @@ program.hook("preAction", (thisCommand) => {
5654
5711
  });
5655
5712
  program.command("providers").description("List all providers and their configuration status").action(async () => {
5656
5713
  console.log();
5657
- p.intro(pc13.cyan(`@computesdk/cli v${VERSION}`));
5714
+ p.intro(pc14.cyan(`@computesdk/cli v${VERSION}`));
5658
5715
  const statuses = getProviderStatus();
5659
5716
  console.log();
5660
5717
  for (const status of statuses) {
5661
- const icon = status.ready ? pc13.green("\u25CF") : pc13.gray("\u25CB");
5662
- const name = status.ready ? pc13.white(status.name) : pc13.gray(status.name);
5663
- const detail = status.ready ? pc13.green("ready") : pc13.gray(`missing: ${status.missing.join(", ")}`);
5718
+ const icon = status.ready ? pc14.green("\u25CF") : pc14.gray("\u25CB");
5719
+ const name = status.ready ? pc14.white(status.name) : pc14.gray(status.name);
5720
+ const detail = status.ready ? pc14.green("ready") : pc14.gray(`missing: ${status.missing.join(", ")}`);
5664
5721
  console.log(` ${icon} ${name} ${detail}`);
5665
5722
  }
5666
5723
  console.log();
5667
5724
  });
5668
5725
  program.command("login").description("Authenticate with ComputeSDK (OAuth device flow)").option("--base-url <url>", "platform URL to authenticate against").action(async (opts) => {
5669
5726
  console.log();
5670
- p.intro(pc13.cyan(`@computesdk/cli v${VERSION}`));
5727
+ p.intro(pc14.cyan(`@computesdk/cli v${VERSION}`));
5671
5728
  await runLogin({ baseUrl: opts.baseUrl });
5672
5729
  await printSessionLine({ baseUrl: opts.baseUrl });
5673
- p.outro(pc13.green("Authenticated!"));
5730
+ p.outro(pc14.green("Authenticated!"));
5674
5731
  });
5675
5732
  program.command("logout").description("Clear stored credentials").option("--json", "print machine-readable JSON").action(async (opts) => {
5676
5733
  await runLogout();
@@ -5679,9 +5736,9 @@ program.command("logout").description("Clear stored credentials").option("--json
5679
5736
  return;
5680
5737
  }
5681
5738
  console.log();
5682
- p.intro(pc13.cyan(`@computesdk/cli v${VERSION}`));
5739
+ p.intro(pc14.cyan(`@computesdk/cli v${VERSION}`));
5683
5740
  p.log.success("Logged out. Stored credentials removed.");
5684
- p.outro(pc13.green("Done!"));
5741
+ p.outro(pc14.green("Done!"));
5685
5742
  });
5686
5743
  async function printWhoami(options = {}) {
5687
5744
  const me = await fetchWhoami(await benchAuth({ baseUrl: options.baseUrl }));
@@ -5701,8 +5758,8 @@ org.command("list").description("List your organizations").option("--json", "pri
5701
5758
  return;
5702
5759
  }
5703
5760
  for (const o of organizations) {
5704
- const marker = o.id === me.activeOrganizationId ? pc13.green("*") : " ";
5705
- console.log(`${marker} ${pc13.cyan(o.slug)} ${o.name ?? ""} ${pc13.dim(o.id)}`);
5761
+ const marker = o.id === me.activeOrganizationId ? pc14.green("*") : " ";
5762
+ console.log(`${marker} ${pc14.cyan(o.slug)} ${o.name ?? ""} ${pc14.dim(o.id)}`);
5706
5763
  }
5707
5764
  });
5708
5765
  org.command("use <slug>").description("Set the active organization (persisted to the stored login)").action(async (slug) => {
@@ -5738,6 +5795,7 @@ registerInvitationsCommands(program);
5738
5795
  registerActionsCommands(program);
5739
5796
  registerByokCommands(program);
5740
5797
  registerMarketCommands(program);
5798
+ registerCreditsCommands(program);
5741
5799
  registerSandboxesCommands(program);
5742
5800
  registerAgentsCommands(program);
5743
5801
  program.command("bench").description("Benchmarks platform CLI (run, auth, org, benchmarks, runs, results, fork, artifacts, export, ...)").allowUnknownOption().helpOption(false).action(() => {
@@ -5755,7 +5813,7 @@ async function main() {
5755
5813
  await program.parseAsync(process.argv);
5756
5814
  }
5757
5815
  main().catch((error) => {
5758
- console.error(pc13.red(`
5816
+ console.error(pc14.red(`
5759
5817
  Error: ${error.message}`));
5760
5818
  process.exit(1);
5761
5819
  });