@neta-art/cohub-cli 1.18.0 → 1.19.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.
@@ -0,0 +1,2 @@
1
+ import type { Command } from "commander";
2
+ export declare function registerMe(program: Command): void;
@@ -0,0 +1,68 @@
1
+ import { createClient } from "../client.js";
2
+ import { handleHttp, json as outJson, jsonRequested, table } from "../output.js";
3
+ function parseInteger(value, name, min) {
4
+ const parsed = Number.parseInt(value, 10);
5
+ if (!Number.isSafeInteger(parsed) || parsed < min) {
6
+ process.stderr.write(`\n ✗ Invalid ${name}\n ${name} must be an integer ≥ ${min}\n\n`);
7
+ process.exit(1);
8
+ }
9
+ return parsed;
10
+ }
11
+ export function registerMe(program) {
12
+ const meCmd = program.command("me").description("Account-level data across your spaces");
13
+ meCmd
14
+ .command("sessions")
15
+ .alias("list-sessions")
16
+ .description("List sessions you created across all spaces")
17
+ .option("--limit <n>", "Maximum number of sessions (default 20)")
18
+ .option("--cursor <cursor>", "Pagination cursor from a previous result")
19
+ .option("--json", "Output as JSON")
20
+ .action(async (opts) => {
21
+ const client = createClient();
22
+ try {
23
+ const result = await client.user.listSessions({
24
+ limit: opts.limit ? parseInteger(opts.limit, "limit", 1) : undefined,
25
+ cursor: opts.cursor ?? null,
26
+ });
27
+ if (jsonRequested(opts))
28
+ return outJson(result);
29
+ if (result.sessions.length === 0) {
30
+ console.log(" (empty)");
31
+ return;
32
+ }
33
+ table(result.sessions, [
34
+ { key: "id", label: "ID" },
35
+ { key: "spaceId", label: "Space" },
36
+ { key: "title", label: "Title" },
37
+ { key: "totalMessages", label: "Messages" },
38
+ { key: "createdAt", label: "Created" },
39
+ ]);
40
+ }
41
+ catch (e) {
42
+ handleHttp(e);
43
+ }
44
+ });
45
+ meCmd
46
+ .command("usage [days]")
47
+ .description("Your aggregated usage across all spaces (default: 30 days)")
48
+ .option("--json", "Output as JSON")
49
+ .action(async (days, opts) => {
50
+ const client = createClient();
51
+ try {
52
+ const usage = await client.user.getUsage(days ? parseInteger(days, "days", 1) : 30);
53
+ if (jsonRequested(opts))
54
+ return outJson(usage);
55
+ console.log("\n Summary:");
56
+ table([usage.summary], [
57
+ { key: "totalTokens", label: "Tokens" },
58
+ { key: "costTotal", label: "Cost ($)" },
59
+ { key: "requestCount", label: "Requests" },
60
+ { key: "successCount", label: "Success" },
61
+ { key: "errorCount", label: "Errors" },
62
+ ]);
63
+ }
64
+ catch (e) {
65
+ handleHttp(e);
66
+ }
67
+ });
68
+ }
@@ -145,8 +145,8 @@ export function registerWorks(program) {
145
145
  .option("--draft", "Create as draft")
146
146
  .option("--disabled", "Create as disabled")
147
147
  .option("--status <status>", "Work status: draft, published, disabled")
148
- .option("--work-scope <scope>", "Scope granted to the work runtime", collectOption, [])
149
- .option("--viewer-scope <scope>", "Scope viewers may request", collectOption, [])
148
+ .option("--work-scope <scope>", "Scope granted to the work runtime (space.view, session.view, file.view, taskrun.view)", collectOption, [])
149
+ .option("--viewer-scope <scope>", "Scope viewers may request (session.prompt.readonly, session.prompt.fullaccess, generation.create, user.space.list, user.session.list, user.usage.read)", collectOption, [])
150
150
  .option("--meta <json>", "Work metadata as a JSON object")
151
151
  .option("--json", "Output as JSON")
152
152
  .action(async (slug, opts) => {
@@ -188,8 +188,8 @@ export function registerWorks(program) {
188
188
  .option("--disabled", "Set status to disabled")
189
189
  .option("--status <status>", "Work status: draft, published, disabled")
190
190
  .option("--publish-version", "Force publishing a new version")
191
- .option("--work-scope <scope>", "Scope granted to the work runtime", collectOption, [])
192
- .option("--viewer-scope <scope>", "Scope viewers may request", collectOption, [])
191
+ .option("--work-scope <scope>", "Scope granted to the work runtime (space.view, session.view, file.view, taskrun.view)", collectOption, [])
192
+ .option("--viewer-scope <scope>", "Scope viewers may request (session.prompt.readonly, session.prompt.fullaccess, generation.create, user.space.list, user.session.list, user.usage.read)", collectOption, [])
193
193
  .option("--clear-work-scopes", "Clear work runtime scopes")
194
194
  .option("--clear-viewer-scopes", "Clear viewer-requestable scopes")
195
195
  .option("--meta <json>", "Work metadata as a JSON object")
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ import { registerAuth } from "./commands/auth.js";
5
5
  import { registerChannels } from "./commands/channels.js";
6
6
  import { registerCronJobs } from "./commands/cron-jobs.js";
7
7
  import { registerGenerations } from "./commands/generations.js";
8
+ import { registerMe } from "./commands/me.js";
8
9
  import { registerModels } from "./commands/models.js";
9
10
  import { registerProfile } from "./commands/profile.js";
10
11
  import { registerSearch } from "./commands/search.js";
@@ -51,6 +52,7 @@ Environment:
51
52
  `);
52
53
  registerAuth(program);
53
54
  registerProfile(program);
55
+ registerMe(program);
54
56
  registerPrompt(program);
55
57
  registerSpaces(program);
56
58
  registerChannels(program);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neta-art/cohub-cli",
3
- "version": "1.18.0",
3
+ "version": "1.19.0",
4
4
  "description": "CLI for Cohub — spaces, sessions, and agent collaboration.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -16,7 +16,7 @@
16
16
  "@neta-art/generation": "^0.1.5",
17
17
  "commander": "^14.0.3",
18
18
  "sharp": "^0.34.5",
19
- "@neta-art/cohub": "1.29.0"
19
+ "@neta-art/cohub": "1.30.0"
20
20
  },
21
21
  "publishConfig": {
22
22
  "access": "public"