@neta-art/cohub-cli 1.17.5 → 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.
- package/dist/commands/me.d.ts +2 -0
- package/dist/commands/me.js +68 -0
- package/dist/commands/spaces.js +18 -0
- package/dist/commands/works.js +4 -4
- package/dist/index.js +2 -0
- package/package.json +2 -2
|
@@ -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
|
+
}
|
package/dist/commands/spaces.js
CHANGED
|
@@ -26,6 +26,21 @@ function parseInteger(value, name, options = {}) {
|
|
|
26
26
|
function collectOption(value, previous = []) {
|
|
27
27
|
return [...previous, value];
|
|
28
28
|
}
|
|
29
|
+
function parseEnvOptions(values) {
|
|
30
|
+
if (!values?.length)
|
|
31
|
+
return undefined;
|
|
32
|
+
const env = {};
|
|
33
|
+
for (const value of values) {
|
|
34
|
+
const index = value.indexOf("=");
|
|
35
|
+
if (index <= 0)
|
|
36
|
+
return error("Invalid env", "Use --env KEY=value");
|
|
37
|
+
const name = value.slice(0, index).trim();
|
|
38
|
+
if (!name)
|
|
39
|
+
return error("Invalid env", "Env name is required");
|
|
40
|
+
env[name] = value.slice(index + 1);
|
|
41
|
+
}
|
|
42
|
+
return env;
|
|
43
|
+
}
|
|
29
44
|
function parseChoice(value, name, choices) {
|
|
30
45
|
if (choices.includes(value))
|
|
31
46
|
return value;
|
|
@@ -218,6 +233,7 @@ async function sendPrompt(command, words, opts) {
|
|
|
218
233
|
provider: opts.provider,
|
|
219
234
|
accessMode: opts.readOnly ? "read_only" : "full_access",
|
|
220
235
|
intent: opts.steer ? "steer" : undefined,
|
|
236
|
+
env: parseEnvOptions(opts.env),
|
|
221
237
|
schedule,
|
|
222
238
|
labelRefs: opts.label?.length ? opts.label : undefined,
|
|
223
239
|
});
|
|
@@ -249,6 +265,7 @@ export function registerPrompt(program) {
|
|
|
249
265
|
.option("--cron <expression>", "Repeat using a 5-field cron expression")
|
|
250
266
|
.option("--timezone <tz>", "IANA timezone for --cron, e.g. Asia/Shanghai")
|
|
251
267
|
.option("--label <ref>", "Attach a label, e.g. Bug or Area/Frontend", collectOption, [])
|
|
268
|
+
.option("--env <key=value>", "Set an environment variable for this turn", collectOption, [])
|
|
252
269
|
.option("--image <path>", "Attach an image", collectOption, [])
|
|
253
270
|
.option("--json", "Output as JSON")
|
|
254
271
|
.action((words, opts) => sendPrompt(program, words, opts));
|
|
@@ -410,6 +427,7 @@ export function registerSpaces(program) {
|
|
|
410
427
|
.option("--cron <expression>", "Repeat using a 5-field cron expression")
|
|
411
428
|
.option("--timezone <tz>", "IANA timezone for --cron, e.g. Asia/Shanghai")
|
|
412
429
|
.option("--label <ref>", "Attach a label, e.g. Bug or Area/Frontend", collectOption, [])
|
|
430
|
+
.option("--env <key=value>", "Set an environment variable for this turn", collectOption, [])
|
|
413
431
|
.option("--image <path>", "Attach an image", collectOption, [])
|
|
414
432
|
.option("--json", "Output as JSON")
|
|
415
433
|
.action((words, opts) => sendPrompt(spacesCmd, words, opts));
|
package/dist/commands/works.js
CHANGED
|
@@ -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.
|
|
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.
|
|
19
|
+
"@neta-art/cohub": "1.30.0"
|
|
20
20
|
},
|
|
21
21
|
"publishConfig": {
|
|
22
22
|
"access": "public"
|