@nodaro/cli 1.17.0 → 1.18.1
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 +141 -5
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -29,7 +29,7 @@ var require_package = __commonJS({
|
|
|
29
29
|
"package.json"(exports$1, module) {
|
|
30
30
|
module.exports = {
|
|
31
31
|
name: "@nodaro/cli",
|
|
32
|
-
version: "1.
|
|
32
|
+
version: "1.18.1",
|
|
33
33
|
description: "Command-line interface for Nodaro \u2014 list and run workflows, inspect jobs and executions, manage projects from the terminal.",
|
|
34
34
|
type: "module",
|
|
35
35
|
license: "Apache-2.0",
|
|
@@ -70,11 +70,11 @@ var require_package = __commonJS({
|
|
|
70
70
|
"@inquirer/confirm": "^6.0.12",
|
|
71
71
|
"@inquirer/input": "^5.0.12",
|
|
72
72
|
"@inquirer/select": "^5.1.4",
|
|
73
|
-
"@nodaro/sdk": "^1.
|
|
74
|
-
"@nodaro/shared": "^2.
|
|
73
|
+
"@nodaro/sdk": "^1.28.0",
|
|
74
|
+
"@nodaro/shared": "^2.21.1",
|
|
75
75
|
commander: "^12.1.0",
|
|
76
76
|
picocolors: "^1.1.1",
|
|
77
|
-
"@nodaro/prompts": "^1.
|
|
77
|
+
"@nodaro/prompts": "^1.15.0"
|
|
78
78
|
},
|
|
79
79
|
devDependencies: {
|
|
80
80
|
tsup: "^8.5.0",
|
|
@@ -398,7 +398,7 @@ function saveWorkspace(profileName, workspaceId) {
|
|
|
398
398
|
}
|
|
399
399
|
|
|
400
400
|
// src/client.ts
|
|
401
|
-
var CLI_VERSION = "1.
|
|
401
|
+
var CLI_VERSION = "1.18.1" ;
|
|
402
402
|
function buildClient(profileName) {
|
|
403
403
|
const { name, profile } = getProfile(profileName);
|
|
404
404
|
if (!profile) {
|
|
@@ -556,6 +556,15 @@ async function watchUntilTerminal(opts) {
|
|
|
556
556
|
info(`[${elapsed(start)}s] ${opts.label} \u2192 ${status}`);
|
|
557
557
|
lastStatus = status;
|
|
558
558
|
}
|
|
559
|
+
if (status === "pending_review") {
|
|
560
|
+
if (opts.json) emit(result.data, opts);
|
|
561
|
+
else {
|
|
562
|
+
info("awaiting review (a human decision is pending; not a failure)");
|
|
563
|
+
dim(`check later: nodaro jobs get ${opts.label}`);
|
|
564
|
+
process.exit(3);
|
|
565
|
+
}
|
|
566
|
+
return result;
|
|
567
|
+
}
|
|
559
568
|
if (TERMINAL.has(status)) {
|
|
560
569
|
if (opts.json) emit(result.data, opts);
|
|
561
570
|
else if (status === "completed") success(`completed in ${elapsed(start)}s`);
|
|
@@ -4325,6 +4334,67 @@ function orgCommand() {
|
|
|
4325
4334
|
handleError(err);
|
|
4326
4335
|
}
|
|
4327
4336
|
});
|
|
4337
|
+
cmd.command("usage <orgId>").description("credits by workspace, member, model or day for a date range").option("--from <YYYY-MM-DD>", "inclusive start date").option("--to <YYYY-MM-DD>", "inclusive end date").option("--tz <iana>", "IANA time zone (default: your local zone)").option("--group-by <dim>", "workspace | member | model | day | none", "day").option("--workspace <id>", "narrow to one workspace").option("--user <id>", "narrow to one member").option("--limit <n>", "rows page size (with --group-by none)", (v) => Number(v)).option("--cursor <cursor>", "continue a rows page").option("--csv", "write the report as CSV to stdout").option("--profile <name>").option("--json").action(
|
|
4338
|
+
async (orgId, opts) => {
|
|
4339
|
+
try {
|
|
4340
|
+
const client = buildClient(opts.profile);
|
|
4341
|
+
const tz = opts.tz ?? Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
4342
|
+
const common = { from: opts.from, to: opts.to, tz, workspaceId: opts.workspace, userId: opts.user };
|
|
4343
|
+
if (opts.csv) {
|
|
4344
|
+
process.stdout.write(
|
|
4345
|
+
await client.organizations.usageCsv(orgId, {
|
|
4346
|
+
...common,
|
|
4347
|
+
groupBy: opts.groupBy
|
|
4348
|
+
})
|
|
4349
|
+
);
|
|
4350
|
+
return;
|
|
4351
|
+
}
|
|
4352
|
+
if (opts.groupBy === "none") {
|
|
4353
|
+
const page = await client.organizations.usageRows(orgId, { ...common, limit: opts.limit, cursor: opts.cursor });
|
|
4354
|
+
if (opts.json) {
|
|
4355
|
+
emit(page, opts);
|
|
4356
|
+
return;
|
|
4357
|
+
}
|
|
4358
|
+
table(
|
|
4359
|
+
page.data.map((e) => ({
|
|
4360
|
+
at: e.createdAt,
|
|
4361
|
+
member: e.member?.displayName ?? e.member?.email ?? e.member?.userId ?? "",
|
|
4362
|
+
model: e.model,
|
|
4363
|
+
status: e.status,
|
|
4364
|
+
credits: e.credits
|
|
4365
|
+
})),
|
|
4366
|
+
["at", "member", "model", "status", "credits"]
|
|
4367
|
+
);
|
|
4368
|
+
if (page.nextCursor) dim(`more: --cursor ${page.nextCursor}`);
|
|
4369
|
+
return;
|
|
4370
|
+
}
|
|
4371
|
+
const { data: report } = await client.organizations.usage(orgId, {
|
|
4372
|
+
...common,
|
|
4373
|
+
groupBy: opts.groupBy
|
|
4374
|
+
});
|
|
4375
|
+
if (opts.json) {
|
|
4376
|
+
emit(report, opts);
|
|
4377
|
+
return;
|
|
4378
|
+
}
|
|
4379
|
+
table(
|
|
4380
|
+
report.rows.map((r) => ({
|
|
4381
|
+
group: r.workspace ? r.workspace.name ?? r.workspace.slug ?? r.workspace.id : r.member ? r.member.displayName ?? r.member.email ?? r.member.userId : r.model ?? r.day ?? r.key,
|
|
4382
|
+
runs: r.runCount,
|
|
4383
|
+
credits: r.credits,
|
|
4384
|
+
settled: r.settledCredits,
|
|
4385
|
+
in_flight: r.inFlightCredits
|
|
4386
|
+
})),
|
|
4387
|
+
["group", "runs", "credits", "settled", "in_flight"]
|
|
4388
|
+
);
|
|
4389
|
+
dim(
|
|
4390
|
+
`total: ${report.totals.credits} credits (${report.totals.settledCredits} settled, ${report.totals.inFlightCredits} in flight, ${report.totals.platformAbsorbedCredits} platform-absorbed overrun, ${report.totals.appMarkupAbsorbedCredits} app-markup absorbed)`
|
|
4391
|
+
);
|
|
4392
|
+
if (report.truncated) warn("report truncated at 5000 groups \u2014 narrow the window");
|
|
4393
|
+
} catch (err) {
|
|
4394
|
+
handleError(err);
|
|
4395
|
+
}
|
|
4396
|
+
}
|
|
4397
|
+
);
|
|
4328
4398
|
return cmd;
|
|
4329
4399
|
}
|
|
4330
4400
|
function workspaceCommand() {
|
|
@@ -4453,6 +4523,72 @@ function workspaceCommand() {
|
|
|
4453
4523
|
handleError(err);
|
|
4454
4524
|
}
|
|
4455
4525
|
});
|
|
4526
|
+
cmd.command("usage [id]").description("credits by member, model or day for a workspace (yours if id omitted)").option("--from <YYYY-MM-DD>", "inclusive start date").option("--to <YYYY-MM-DD>", "inclusive end date").option("--tz <iana>", "IANA time zone (default: your local zone)").option("--group-by <dim>", "member | model | day | none", "day").option("--user <id>", "narrow to one member (admins only)").option("--limit <n>", "rows page size (with --group-by none)", (v) => Number(v)).option("--cursor <cursor>", "continue a rows page").option("--csv", "write the report as CSV to stdout").option("--profile <name>").option("--json").action(
|
|
4527
|
+
async (id, opts) => {
|
|
4528
|
+
try {
|
|
4529
|
+
const workspaceId = id ?? resolveWorkspace(getProfile(opts.profile).profile).workspaceId;
|
|
4530
|
+
if (!workspaceId) {
|
|
4531
|
+
handleError(new Error("no workspace selected; pass an id or run nodaro workspace use <id>"));
|
|
4532
|
+
return;
|
|
4533
|
+
}
|
|
4534
|
+
const client = buildClient(opts.profile);
|
|
4535
|
+
const tz = opts.tz ?? Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
4536
|
+
const common = { from: opts.from, to: opts.to, tz, userId: opts.user };
|
|
4537
|
+
if (opts.csv) {
|
|
4538
|
+
process.stdout.write(
|
|
4539
|
+
await client.workspaces.usageCsv(workspaceId, {
|
|
4540
|
+
...common,
|
|
4541
|
+
groupBy: opts.groupBy
|
|
4542
|
+
})
|
|
4543
|
+
);
|
|
4544
|
+
return;
|
|
4545
|
+
}
|
|
4546
|
+
if (opts.groupBy === "none") {
|
|
4547
|
+
const page = await client.workspaces.usageRows(workspaceId, { ...common, limit: opts.limit, cursor: opts.cursor });
|
|
4548
|
+
if (opts.json) {
|
|
4549
|
+
emit(page, opts);
|
|
4550
|
+
return;
|
|
4551
|
+
}
|
|
4552
|
+
table(
|
|
4553
|
+
page.data.map((e) => ({
|
|
4554
|
+
at: e.createdAt,
|
|
4555
|
+
member: e.member?.displayName ?? e.member?.email ?? e.member?.userId ?? "",
|
|
4556
|
+
model: e.model,
|
|
4557
|
+
status: e.status,
|
|
4558
|
+
credits: e.credits
|
|
4559
|
+
})),
|
|
4560
|
+
["at", "member", "model", "status", "credits"]
|
|
4561
|
+
);
|
|
4562
|
+
if (page.nextCursor) dim(`more: --cursor ${page.nextCursor}`);
|
|
4563
|
+
return;
|
|
4564
|
+
}
|
|
4565
|
+
const { data: report } = await client.workspaces.usage(workspaceId, {
|
|
4566
|
+
...common,
|
|
4567
|
+
groupBy: opts.groupBy
|
|
4568
|
+
});
|
|
4569
|
+
if (opts.json) {
|
|
4570
|
+
emit(report, opts);
|
|
4571
|
+
return;
|
|
4572
|
+
}
|
|
4573
|
+
table(
|
|
4574
|
+
report.rows.map((r) => ({
|
|
4575
|
+
group: r.member ? r.member.displayName ?? r.member.email ?? r.member.userId : r.model ?? r.day ?? r.key,
|
|
4576
|
+
runs: r.runCount,
|
|
4577
|
+
credits: r.credits,
|
|
4578
|
+
settled: r.settledCredits,
|
|
4579
|
+
in_flight: r.inFlightCredits
|
|
4580
|
+
})),
|
|
4581
|
+
["group", "runs", "credits", "settled", "in_flight"]
|
|
4582
|
+
);
|
|
4583
|
+
dim(
|
|
4584
|
+
`total: ${report.totals.credits} credits (${report.totals.settledCredits} settled, ${report.totals.inFlightCredits} in flight, ${report.totals.platformAbsorbedCredits} platform-absorbed overrun, ${report.totals.appMarkupAbsorbedCredits} app-markup absorbed)`
|
|
4585
|
+
);
|
|
4586
|
+
if (report.truncated) warn("report truncated at 5000 groups \u2014 narrow the window");
|
|
4587
|
+
} catch (err) {
|
|
4588
|
+
handleError(err);
|
|
4589
|
+
}
|
|
4590
|
+
}
|
|
4591
|
+
);
|
|
4456
4592
|
return cmd;
|
|
4457
4593
|
}
|
|
4458
4594
|
var SOURCE_LABELS = {
|