@computesdk/cli 2.6.2 → 2.6.4

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/README.md CHANGED
@@ -24,7 +24,7 @@ tokens renew automatically.
24
24
  ## Commands
25
25
 
26
26
  ```
27
- compute actions … # Actions API — repos, dispatch, runs, logs, vault
27
+ compute actions … # Actions API — repos, dispatch, runs, schedule, logs, vault
28
28
  compute market … # buy and sell on the compute market (cap, bids, credits, listings)
29
29
  compute sandboxes … # platform sandbox control plane
30
30
  compute bench … # benchmarks CLI (run, auth, org, results, …)
@@ -55,6 +55,58 @@ compute sandboxes exec sb1 uname -a
55
55
  compute sandboxes spawn sb1 --cwd /app -e NODE_ENV=production -- npm run dev
56
56
  ```
57
57
 
58
+ ## Actions schedule
59
+
60
+ ```bash
61
+ compute actions schedule # now through seven days later, local timezone
62
+ compute actions schedule --repo acme/widgets --tz America/Chicago
63
+ compute actions schedule --reliability # only reliability runs and scheduled fires
64
+ compute actions schedule --from 2026-11-01T00:00:00Z --to 2026-11-08T00:00:00Z \
65
+ --workflow .github/workflows/ci.yml --workflow .github/workflows/nightly.yml
66
+ compute actions schedule --event push --status failed --limit 50 --json
67
+ ```
68
+
69
+ Reads `GET /api/v1/actions/schedule`. `--from` is inclusive and `--to` exclusive;
70
+ the maximum window is 45 days. If `--to` is omitted it is seven days after
71
+ `--from` (or now). `--tz` is an IANA zone, defaults to the local zone, and controls
72
+ display times and API day buckets. Invalid zones fall back to UTC on the API.
73
+
74
+ Human output lists upcoming fires with their workflow, repository and cron
75
+ description, then past runs with event and status. Upcoming previews contain at
76
+ most 100 fires per schedule; `+N more` reports the remainder in the window.
77
+ Reliability activity is hidden by default. `--reliability` shows only reliability
78
+ runs and workflows, matching the dashboard toggle; pagination hints retain it.
79
+ Incomplete counts produce a warning to choose a smaller window.
80
+
81
+ `--repo` takes `owner/repo`; `--workflow` takes file paths, not display names, and
82
+ is repeatable. `--event` and `--status` accept multiple values. Status filters
83
+ are conclusions (`passed`, `failed`, `running`, `cancelled`, `none`) and exclude
84
+ upcoming fires. `--limit` pages actual runs (default 100, maximum 500).
85
+ When another page exists, copy the printed `--cursor` command: it preserves the
86
+ resolved window, timezone and filters, including a leading `compute --org <slug>`
87
+ override (a command-local `--org` takes precedence). Credentials are never printed; reuse the
88
+ same API-key environment or supply the same `--api-key` separately.
89
+
90
+ `--json` returns the complete API response, including `days`, `runs`, `upcoming`,
91
+ `nextCursor`, and truncation/count flags, without human headings or hints.
92
+
93
+ ## Managed-agent persistence
94
+
95
+ `compute agents run <agent>` starts a conversation. On platforms with managed
96
+ Archil storage, the first run provisions the agent's disk automatically.
97
+ After its turn finishes, `compute agents stop <sessionId>` flushes storage and
98
+ releases compute. Resume that conversation, including Pi history and workspace:
99
+
100
+ ```sh
101
+ compute agents run my-agent --resume <sessionId>
102
+ compute agents run my-agent "Continue the task" --resume <sessionId>
103
+ ```
104
+
105
+ Resume preserves the session ID and event journal but acquires a new sandbox.
106
+ Only one session per agent can be active at a time. Legacy sessions without
107
+ persistent state cannot be recovered retroactively. Requires the platform's
108
+ managed-volume/resume API; no account storage credentials are needed in the CLI.
109
+
58
110
  ## Migrating from @computesdk/cli 1.x
59
111
 
60
112
  v2 removes the legacy console authentication and its commands:
package/dist/index.js CHANGED
@@ -330,6 +330,75 @@ function sanitizePathPart(name) {
330
330
  if (base === "" || base === "." || base === "..") return "artifact";
331
331
  return base;
332
332
  }
333
+ function scheduleQuery(opts) {
334
+ const from = opts.from === void 0 ? /* @__PURE__ */ new Date() : new Date(opts.from);
335
+ const to = opts.to === void 0 ? new Date(from.getTime() + 7 * 864e5) : new Date(opts.to);
336
+ if (!Number.isFinite(from.getTime()) || !Number.isFinite(to.getTime())) {
337
+ throw new PlatformClientError("invalid_argument", "--from and --to must be valid timestamps.");
338
+ }
339
+ return {
340
+ from: from.toISOString(),
341
+ to: to.toISOString(),
342
+ repo: opts.repo,
343
+ workflow: opts.workflow,
344
+ event: opts.event,
345
+ status: opts.status,
346
+ reliability: opts.reliability ? "1" : void 0,
347
+ timeZone: opts.tz ?? Intl.DateTimeFormat().resolvedOptions().timeZone,
348
+ limit: opts.limit,
349
+ cursor: opts.cursor
350
+ };
351
+ }
352
+ function nextScheduleCommand(data, opts) {
353
+ const args = ["compute", "actions", "schedule", "--from", data.from, "--to", data.to, "--tz", data.timeZone];
354
+ for (const key of ["repo", "workflow", "event", "status", "limit", "org", "baseUrl"]) {
355
+ const value = opts[key];
356
+ if (value === void 0) continue;
357
+ for (const item of Array.isArray(value) ? value : [value]) args.push(`--${key === "baseUrl" ? "base-url" : key}`, item);
358
+ }
359
+ if (opts.reliability) args.push("--reliability");
360
+ if (opts.allowUntrustedHost) args.push("--allow-untrusted-host");
361
+ args.push("--cursor", data.nextCursor);
362
+ return args.map((value) => /^[A-Za-z0-9_./:@%+=,-]+$/.test(value) ? value : `'${value.replace(/'/g, "'\\''")}'`).join(" ");
363
+ }
364
+ function formatSchedule(data, nextCommand) {
365
+ const time = new Intl.DateTimeFormat("en-CA", {
366
+ timeZone: data.timeZone,
367
+ year: "numeric",
368
+ month: "2-digit",
369
+ day: "2-digit",
370
+ hour: "2-digit",
371
+ minute: "2-digit",
372
+ second: "2-digit",
373
+ hourCycle: "h23",
374
+ timeZoneName: "short"
375
+ });
376
+ const lines = [pc2.bold(`Upcoming fires (${safeTerm(data.timeZone)})`)];
377
+ const fires = data.upcoming.flatMap((schedule) => schedule.occurrences.map((at) => ({ at, schedule }))).sort((a, b) => a.at.localeCompare(b.at));
378
+ if (fires.length === 0) lines.push("No upcoming fires.");
379
+ for (const { at, schedule } of fires) {
380
+ lines.push([time.format(new Date(at)), safeTerm(schedule.workflowName || schedule.workflowPath), safeTerm(schedule.repoFullName), safeTerm(schedule.description)].join(" "));
381
+ }
382
+ for (const schedule of data.upcoming) {
383
+ const remaining = schedule.occurrenceCount - schedule.occurrences.length;
384
+ if (remaining > 0) lines.push(`+${remaining.toLocaleString("en-US")} more scheduled for ${safeTerm(schedule.workflowName || schedule.workflowPath)} ${safeTerm(schedule.repoFullName)} ${safeTerm(schedule.description)}`);
385
+ }
386
+ lines.push("", pc2.bold(`Past runs (${safeTerm(data.timeZone)})`));
387
+ if (data.runs.length === 0) lines.push("No past runs found.");
388
+ for (const run of data.runs) {
389
+ lines.push([
390
+ time.format(new Date(run.startedAt ?? run.createdAt)),
391
+ safeTerm(run.workflowName || run.workflowPath),
392
+ safeTerm(run.repoFullName),
393
+ safeTerm(run.event),
394
+ conclusionLabel(safeTerm(run.status === "completed" ? run.conclusion : run.status))
395
+ ].join(" "));
396
+ }
397
+ if (data.countsTruncated) lines.push("Warning: some schedule totals reached the safety limit; use a smaller window for exact counts.");
398
+ if (nextCommand) lines.push("", `Next page (reuse the same credentials):
399
+ ${safeTerm(nextCommand)}`);
400
+ return lines.join("\n");
401
+ }
333
402
  async function client(opts) {
334
403
  return new ActionsClient(await resolveActionsAuth(opts));
335
404
  }
@@ -1039,6 +1108,18 @@ function registerActionsCommands(program2) {
1039
1108
  fail(e, opts);
1040
1109
  }
1041
1110
  });
1111
+ common(
1112
+ actions.command("schedule").description("List upcoming scheduled fires and past runs in a time window").option("--reliability", "show only reliability runs and workflows (hidden by default)").option("--from <timestamp>", "inclusive start timestamp (default: now)").option("--to <timestamp>", "exclusive end timestamp (default: seven days after --from)").option("--repo <repo>", "repository in owner/repo format").option("--workflow <path...>", "workflow file paths; repeatable").option("--event <event...>", "trigger events: schedule, push, pull_request, workflow_dispatch").option("--status <status...>", "run conclusions: passed, failed, running, cancelled, none (excludes upcoming)").option("--tz <zone>", "IANA time zone (default: local)").option("--limit <n>", "past-run page size (default 100, max 500)").option("--cursor <cursor>", "nextCursor from a prior page; keep the window and filters unchanged")
1113
+ ).action(async (opts) => {
1114
+ opts.org ?? (opts.org = program2.opts().org);
1115
+ try {
1116
+ const query = scheduleQuery(opts);
1117
+ const data = await (await client(opts)).get("/api/v1/actions/schedule", query);
1118
+ output(opts, data, (result) => console.log(formatSchedule(result, result.nextCursor ? nextScheduleCommand(result, opts) : void 0)));
1119
+ } catch (e) {
1120
+ fail(e, opts);
1121
+ }
1122
+ });
1042
1123
  common(
1043
1124
  actions.command("history").description("Recent run history for a workflow \u2014 per-job/step failure rates (is this failure flaky?)").argument("<repo>", "repository in owner/repo format").requiredOption("--workflow <path|name>", "workflow path or name").option("--branch <branch...>", "narrow the window to branches/refs").option("--job <job>", "narrow the rollup to one job name or workflow job id").option("--limit <n>", "runs in the window (default 10, max 50)")
1044
1125
  ).action(async (repo, opts) => {
@@ -3710,13 +3791,13 @@ function registerAgentsCommands(program2) {
3710
3791
  }
3711
3792
  );
3712
3793
  authOpts(
3713
- cmd.command("run <ref> [message]").description("Start a session on a routed sandbox and optionally send a first message").option("--size <size>", "platform size for the session's sandbox")
3794
+ cmd.command("run <ref> [message]").description("Start a session on a routed sandbox and optionally send a first message").option("--resume <sessionId>", "resume a stopped conversation on a new sandbox using its persistent disk").option("--size <size>", "platform size for the session's sandbox")
3714
3795
  ).action(async (ref, message, opts) => {
3715
3796
  try {
3716
3797
  const c = await client(opts);
3717
3798
  const res = await c.post(
3718
3799
  `/api/v1/agents/${encodeURIComponent(ref)}/sessions`,
3719
- { message, size: opts.size }
3800
+ { message, size: opts.size, resumeSessionId: opts.resume }
3720
3801
  );
3721
3802
  output(opts, res, (r) => {
3722
3803
  printSession(r.session);