@nodaro/cli 1.30.0 → 1.31.0

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/index.js CHANGED
@@ -37,7 +37,7 @@ var require_package = __commonJS({
37
37
  "package.json"(exports$1, module) {
38
38
  module.exports = {
39
39
  name: "@nodaro/cli",
40
- version: "1.30.0",
40
+ version: "1.31.0",
41
41
  description: "Command-line interface for Nodaro \u2014 list and run workflows, inspect jobs and executions, manage projects from the terminal.",
42
42
  type: "module",
43
43
  license: "Apache-2.0",
@@ -78,7 +78,7 @@ var require_package = __commonJS({
78
78
  "@inquirer/confirm": "^6.0.12",
79
79
  "@inquirer/input": "^5.0.12",
80
80
  "@inquirer/select": "^5.1.4",
81
- "@nodaro/sdk": "^2.27.0",
81
+ "@nodaro/sdk": "^2.28.0",
82
82
  "@nodaro/shared": "^3.32.0",
83
83
  commander: "^12.1.0",
84
84
  picocolors: "^1.1.1",
@@ -406,7 +406,7 @@ function saveWorkspace(profileName, workspaceId) {
406
406
  }
407
407
 
408
408
  // src/client.ts
409
- var CLI_VERSION = "1.30.0" ;
409
+ var CLI_VERSION = "1.31.0" ;
410
410
  function buildClient(profileName) {
411
411
  const { name, profile } = getProfile(profileName);
412
412
  if (!profile) {
@@ -530,6 +530,146 @@ function projectsCommand() {
530
530
  });
531
531
  return cmd;
532
532
  }
533
+ function idList(value) {
534
+ return value.split(/[\s,]+/).filter(Boolean);
535
+ }
536
+ function sessionsCommand() {
537
+ const cmd = new Command("sessions").description(
538
+ "generation sessions inside projects: list, read, create, rename, archive, import, remove, delete"
539
+ );
540
+ cmd.command("list").description("your sessions, newest first").option("--project <id>", "only this project's sessions").option("--tool <tool>", "only this tool's sessions, e.g. create-image").option("--archived", "include archived sessions").option("--limit <n>", "page size (1-100)").option("--cursor <cursor>", "the previous page's next").option("--profile <name>").option("--json").action(async (opts) => {
541
+ try {
542
+ const client = buildClient(opts.profile);
543
+ const page = await client.sessions.list({
544
+ projectId: opts.project,
545
+ tool: opts.tool,
546
+ includeArchived: opts.archived,
547
+ limit: opts.limit ? Number(opts.limit) : void 0,
548
+ cursor: opts.cursor
549
+ });
550
+ if (opts.json) {
551
+ emit(page, opts);
552
+ return;
553
+ }
554
+ table(
555
+ page.data.map((s) => ({
556
+ id: s.id,
557
+ title: s.title ?? "(untitled)",
558
+ tool: s.tool,
559
+ items: s.itemCount,
560
+ updatedAt: s.updatedAt
561
+ })),
562
+ ["id", "title", "tool", "items", "updatedAt"]
563
+ );
564
+ if (page.next) dim(`next: --cursor ${page.next}`);
565
+ } catch (err) {
566
+ handleError(err);
567
+ }
568
+ });
569
+ cmd.command("get <id>").description("show one session").option("--profile <name>").option("--json").action(async (id, opts) => {
570
+ try {
571
+ const result = await buildClient(opts.profile).sessions.get(id);
572
+ if (opts.json) emit(result.data, opts);
573
+ else detail(result.data);
574
+ } catch (err) {
575
+ handleError(err);
576
+ }
577
+ });
578
+ cmd.command("items <id>").description("a session's items, born-in and imported, newest first").option("--limit <n>", "page size (1-100)").option("--cursor <cursor>", "the previous page's next").option("--profile <name>").option("--json").action(async (id, opts) => {
579
+ try {
580
+ const page = await buildClient(opts.profile).sessions.items(id, {
581
+ limit: opts.limit ? Number(opts.limit) : void 0,
582
+ cursor: opts.cursor
583
+ });
584
+ if (opts.json) {
585
+ emit(page, opts);
586
+ return;
587
+ }
588
+ table(
589
+ page.data.map((i) => ({
590
+ jobId: i.jobId,
591
+ status: i.job.status,
592
+ imported: i.imported ? `from ${i.importedFrom?.title ?? i.importedFrom?.sessionId ?? "?"}` : "",
593
+ addedAt: i.addedAt
594
+ })),
595
+ ["jobId", "status", "imported", "addedAt"]
596
+ );
597
+ if (page.next) dim(`next: --cursor ${page.next}`);
598
+ } catch (err) {
599
+ handleError(err);
600
+ }
601
+ });
602
+ cmd.command("create").description("open a session (its project is fixed once set)").requiredOption("--tool <tool>", "the creation tool, e.g. create-image").option("--project <id>", "one of your projects").option("--title <title>").option("--profile <name>").option("--json").action(async (opts) => {
603
+ try {
604
+ const result = await buildClient(opts.profile).sessions.create({
605
+ tool: opts.tool,
606
+ projectId: opts.project,
607
+ title: opts.title
608
+ });
609
+ if (opts.json) {
610
+ emit(result.data, opts);
611
+ return;
612
+ }
613
+ success(`created session ${result.data.id}`);
614
+ } catch (err) {
615
+ handleError(err);
616
+ }
617
+ });
618
+ cmd.command("update <id>").description("rename or archive a session").option("--title <title>", "new title").option("--untitled", "clear the title").option("--archive", "archive it").option("--unarchive", "bring it back").option("--profile <name>").option("--json").action(async (id, opts) => {
619
+ try {
620
+ const title = opts.untitled ? null : opts.title;
621
+ const archived = opts.archive ? true : opts.unarchive ? false : void 0;
622
+ if (title === void 0 && archived === void 0) {
623
+ throw new Error("nothing to update \u2014 provide --title, --untitled, --archive or --unarchive");
624
+ }
625
+ const result = await buildClient(opts.profile).sessions.update(id, { title, archived });
626
+ if (opts.json) {
627
+ emit(result.data, opts);
628
+ return;
629
+ }
630
+ success(`updated session ${result.data.id}`);
631
+ } catch (err) {
632
+ handleError(err);
633
+ }
634
+ });
635
+ cmd.command("import <id>").description("import some of your jobs into a session \u2014 links, not copies; all-or-nothing").requiredOption("--jobs <ids>", "job ids, comma- or space-separated (up to 100)").option("--profile <name>").option("--json").action(async (id, opts) => {
636
+ try {
637
+ const result = await buildClient(opts.profile).sessions.importItems(id, { jobIds: idList(opts.jobs) });
638
+ if (opts.json) {
639
+ emit(result.data, opts);
640
+ return;
641
+ }
642
+ success(`imported ${result.data.imported} of ${result.data.requested}`);
643
+ } catch (err) {
644
+ handleError(err);
645
+ }
646
+ });
647
+ cmd.command("remove <id> <jobId>").description("remove one item from a session (the link only \u2014 the job stays)").option("--profile <name>").option("--json").action(async (id, jobId, opts) => {
648
+ try {
649
+ await buildClient(opts.profile).sessions.removeItem(id, jobId);
650
+ if (opts.json) {
651
+ emit({ success: true, id, jobId }, opts);
652
+ return;
653
+ }
654
+ success(`removed ${jobId} from session ${id}`);
655
+ } catch (err) {
656
+ handleError(err);
657
+ }
658
+ });
659
+ cmd.command("delete <id>").description("delete a session and its links (its jobs are kept)").option("--profile <name>").option("--json").action(async (id, opts) => {
660
+ try {
661
+ await buildClient(opts.profile).sessions.delete(id);
662
+ if (opts.json) {
663
+ emit({ success: true, id }, opts);
664
+ return;
665
+ }
666
+ success(`Deleted session ${id}`);
667
+ } catch (err) {
668
+ handleError(err);
669
+ }
670
+ });
671
+ return cmd;
672
+ }
533
673
 
534
674
  // src/util.ts
535
675
  function collectVariadic(value, previous) {
@@ -6158,6 +6298,7 @@ program.hook("preAction", () => {
6158
6298
  });
6159
6299
  program.addCommand(authCommand());
6160
6300
  program.addCommand(projectsCommand());
6301
+ program.addCommand(sessionsCommand());
6161
6302
  program.addCommand(workflowsCommand());
6162
6303
  program.addCommand(appsCommand());
6163
6304
  program.addCommand(nodesCommand());