@agentuity/cli 1.0.23 → 1.0.24
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/cmd/cloud/db/index.d.ts.map +1 -1
- package/dist/cmd/cloud/db/index.js +2 -0
- package/dist/cmd/cloud/db/index.js.map +1 -1
- package/dist/cmd/cloud/db/stats.d.ts +3 -0
- package/dist/cmd/cloud/db/stats.d.ts.map +1 -0
- package/dist/cmd/cloud/db/stats.js +66 -0
- package/dist/cmd/cloud/db/stats.js.map +1 -0
- package/dist/cmd/cloud/email/create.d.ts.map +1 -1
- package/dist/cmd/cloud/email/create.js +14 -6
- package/dist/cmd/cloud/email/create.js.map +1 -1
- package/dist/cmd/cloud/email/delete.js +1 -1
- package/dist/cmd/cloud/email/delete.js.map +1 -1
- package/dist/cmd/cloud/email/destination/delete.js +1 -1
- package/dist/cmd/cloud/email/destination/delete.js.map +1 -1
- package/dist/cmd/cloud/email/destination/list.js +1 -1
- package/dist/cmd/cloud/email/destination/list.js.map +1 -1
- package/dist/cmd/cloud/email/destination/url.d.ts.map +1 -1
- package/dist/cmd/cloud/email/destination/url.js +5 -4
- package/dist/cmd/cloud/email/destination/url.js.map +1 -1
- package/dist/cmd/cloud/email/get.js +1 -1
- package/dist/cmd/cloud/email/get.js.map +1 -1
- package/dist/cmd/cloud/email/inbound/get.d.ts.map +1 -1
- package/dist/cmd/cloud/email/inbound/get.js +2 -3
- package/dist/cmd/cloud/email/inbound/get.js.map +1 -1
- package/dist/cmd/cloud/email/inbound/list.d.ts.map +1 -1
- package/dist/cmd/cloud/email/inbound/list.js +1 -3
- package/dist/cmd/cloud/email/inbound/list.js.map +1 -1
- package/dist/cmd/cloud/email/inbound/schemas.d.ts +3 -1
- package/dist/cmd/cloud/email/inbound/schemas.d.ts.map +1 -1
- package/dist/cmd/cloud/email/inbound/schemas.js +3 -1
- package/dist/cmd/cloud/email/inbound/schemas.js.map +1 -1
- package/dist/cmd/cloud/email/index.d.ts.map +1 -1
- package/dist/cmd/cloud/email/index.js +2 -0
- package/dist/cmd/cloud/email/index.js.map +1 -1
- package/dist/cmd/cloud/email/list.d.ts.map +1 -1
- package/dist/cmd/cloud/email/list.js +9 -2
- package/dist/cmd/cloud/email/list.js.map +1 -1
- package/dist/cmd/cloud/email/outbound/get.js +4 -4
- package/dist/cmd/cloud/email/outbound/get.js.map +1 -1
- package/dist/cmd/cloud/email/outbound/list.js +3 -3
- package/dist/cmd/cloud/email/outbound/list.js.map +1 -1
- package/dist/cmd/cloud/email/outbound/schemas.d.ts +2 -2
- package/dist/cmd/cloud/email/outbound/schemas.js +2 -2
- package/dist/cmd/cloud/email/outbound/schemas.js.map +1 -1
- package/dist/cmd/cloud/email/send.d.ts.map +1 -1
- package/dist/cmd/cloud/email/send.js +8 -10
- package/dist/cmd/cloud/email/send.js.map +1 -1
- package/dist/cmd/cloud/email/stats.d.ts +3 -0
- package/dist/cmd/cloud/email/stats.d.ts.map +1 -0
- package/dist/cmd/cloud/email/stats.js +65 -0
- package/dist/cmd/cloud/email/stats.js.map +1 -0
- package/dist/cmd/cloud/email/util.d.ts +4 -7
- package/dist/cmd/cloud/email/util.d.ts.map +1 -1
- package/dist/cmd/cloud/email/util.js +8 -23
- package/dist/cmd/cloud/email/util.js.map +1 -1
- package/dist/cmd/cloud/index.d.ts.map +1 -1
- package/dist/cmd/cloud/index.js +2 -0
- package/dist/cmd/cloud/index.js.map +1 -1
- package/dist/cmd/cloud/queue/get.js +4 -4
- package/dist/cmd/cloud/queue/get.js.map +1 -1
- package/dist/cmd/cloud/queue/receive.d.ts.map +1 -1
- package/dist/cmd/cloud/queue/receive.js +11 -7
- package/dist/cmd/cloud/queue/receive.js.map +1 -1
- package/dist/cmd/cloud/queue/stats.js +3 -3
- package/dist/cmd/cloud/queue/stats.js.map +1 -1
- package/dist/cmd/cloud/sandbox/checkpoint/create.d.ts +3 -0
- package/dist/cmd/cloud/sandbox/checkpoint/create.d.ts.map +1 -0
- package/dist/cmd/cloud/sandbox/checkpoint/create.js +71 -0
- package/dist/cmd/cloud/sandbox/checkpoint/create.js.map +1 -0
- package/dist/cmd/cloud/sandbox/checkpoint/delete.d.ts +3 -0
- package/dist/cmd/cloud/sandbox/checkpoint/delete.d.ts.map +1 -0
- package/dist/cmd/cloud/sandbox/checkpoint/delete.js +78 -0
- package/dist/cmd/cloud/sandbox/checkpoint/delete.js.map +1 -0
- package/dist/cmd/cloud/sandbox/checkpoint/index.d.ts +2 -0
- package/dist/cmd/cloud/sandbox/checkpoint/index.d.ts.map +1 -0
- package/dist/cmd/cloud/sandbox/checkpoint/index.js +33 -0
- package/dist/cmd/cloud/sandbox/checkpoint/index.js.map +1 -0
- package/dist/cmd/cloud/sandbox/checkpoint/list.d.ts +3 -0
- package/dist/cmd/cloud/sandbox/checkpoint/list.d.ts.map +1 -0
- package/dist/cmd/cloud/sandbox/checkpoint/list.js +72 -0
- package/dist/cmd/cloud/sandbox/checkpoint/list.js.map +1 -0
- package/dist/cmd/cloud/sandbox/checkpoint/restore.d.ts +3 -0
- package/dist/cmd/cloud/sandbox/checkpoint/restore.d.ts.map +1 -0
- package/dist/cmd/cloud/sandbox/checkpoint/restore.js +61 -0
- package/dist/cmd/cloud/sandbox/checkpoint/restore.js.map +1 -0
- package/dist/cmd/cloud/sandbox/get.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/get.js +5 -3
- package/dist/cmd/cloud/sandbox/get.js.map +1 -1
- package/dist/cmd/cloud/sandbox/index.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/index.js +4 -0
- package/dist/cmd/cloud/sandbox/index.js.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/build.js +9 -9
- package/dist/cmd/cloud/sandbox/snapshot/build.js.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/get.js +3 -3
- package/dist/cmd/cloud/sandbox/snapshot/get.js.map +1 -1
- package/dist/cmd/cloud/sandbox/stats.d.ts +3 -0
- package/dist/cmd/cloud/sandbox/stats.d.ts.map +1 -0
- package/dist/cmd/cloud/sandbox/stats.js +72 -0
- package/dist/cmd/cloud/sandbox/stats.js.map +1 -0
- package/dist/cmd/cloud/schedule/create.d.ts.map +1 -1
- package/dist/cmd/cloud/schedule/create.js +3 -4
- package/dist/cmd/cloud/schedule/create.js.map +1 -1
- package/dist/cmd/cloud/schedule/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/schedule/delete.js +2 -3
- package/dist/cmd/cloud/schedule/delete.js.map +1 -1
- package/dist/cmd/cloud/schedule/delivery/get.d.ts.map +1 -1
- package/dist/cmd/cloud/schedule/delivery/get.js +3 -4
- package/dist/cmd/cloud/schedule/delivery/get.js.map +1 -1
- package/dist/cmd/cloud/schedule/delivery/list.d.ts.map +1 -1
- package/dist/cmd/cloud/schedule/delivery/list.js +2 -3
- package/dist/cmd/cloud/schedule/delivery/list.js.map +1 -1
- package/dist/cmd/cloud/schedule/destination/create.d.ts.map +1 -1
- package/dist/cmd/cloud/schedule/destination/create.js +7 -4
- package/dist/cmd/cloud/schedule/destination/create.js.map +1 -1
- package/dist/cmd/cloud/schedule/destination/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/schedule/destination/delete.js +2 -3
- package/dist/cmd/cloud/schedule/destination/delete.js.map +1 -1
- package/dist/cmd/cloud/schedule/destination/get.js +15 -13
- package/dist/cmd/cloud/schedule/destination/get.js.map +1 -1
- package/dist/cmd/cloud/schedule/destination/list.d.ts.map +1 -1
- package/dist/cmd/cloud/schedule/destination/list.js +13 -9
- package/dist/cmd/cloud/schedule/destination/list.js.map +1 -1
- package/dist/cmd/cloud/schedule/get.d.ts.map +1 -1
- package/dist/cmd/cloud/schedule/get.js +15 -11
- package/dist/cmd/cloud/schedule/get.js.map +1 -1
- package/dist/cmd/cloud/schedule/index.d.ts.map +1 -1
- package/dist/cmd/cloud/schedule/index.js +2 -0
- package/dist/cmd/cloud/schedule/index.js.map +1 -1
- package/dist/cmd/cloud/schedule/list.d.ts.map +1 -1
- package/dist/cmd/cloud/schedule/list.js +2 -3
- package/dist/cmd/cloud/schedule/list.js.map +1 -1
- package/dist/cmd/cloud/schedule/stats.d.ts +3 -0
- package/dist/cmd/cloud/schedule/stats.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/stats.js +64 -0
- package/dist/cmd/cloud/schedule/stats.js.map +1 -0
- package/dist/cmd/cloud/schedule/update.js +5 -5
- package/dist/cmd/cloud/schedule/update.js.map +1 -1
- package/dist/cmd/cloud/schedule/util.d.ts +4 -5
- package/dist/cmd/cloud/schedule/util.d.ts.map +1 -1
- package/dist/cmd/cloud/schedule/util.js +6 -6
- package/dist/cmd/cloud/schedule/util.js.map +1 -1
- package/dist/cmd/cloud/services/index.d.ts +3 -0
- package/dist/cmd/cloud/services/index.d.ts.map +1 -0
- package/dist/cmd/cloud/services/index.js +10 -0
- package/dist/cmd/cloud/services/index.js.map +1 -0
- package/dist/cmd/cloud/services/stats.d.ts +3 -0
- package/dist/cmd/cloud/services/stats.d.ts.map +1 -0
- package/dist/cmd/cloud/services/stats.js +153 -0
- package/dist/cmd/cloud/services/stats.js.map +1 -0
- package/dist/cmd/cloud/stream/index.d.ts.map +1 -1
- package/dist/cmd/cloud/stream/index.js +2 -1
- package/dist/cmd/cloud/stream/index.js.map +1 -1
- package/dist/cmd/cloud/stream/stats.d.ts +3 -0
- package/dist/cmd/cloud/stream/stats.d.ts.map +1 -0
- package/dist/cmd/cloud/stream/stats.js +64 -0
- package/dist/cmd/cloud/stream/stats.js.map +1 -0
- package/dist/cmd/cloud/task/create.d.ts.map +1 -1
- package/dist/cmd/cloud/task/create.js +0 -1
- package/dist/cmd/cloud/task/create.js.map +1 -1
- package/dist/cmd/cloud/task/get.d.ts.map +1 -1
- package/dist/cmd/cloud/task/get.js +4 -3
- package/dist/cmd/cloud/task/get.js.map +1 -1
- package/dist/cmd/cloud/task/index.d.ts.map +1 -1
- package/dist/cmd/cloud/task/index.js +2 -1
- package/dist/cmd/cloud/task/index.js.map +1 -1
- package/dist/cmd/cloud/task/list.d.ts.map +1 -1
- package/dist/cmd/cloud/task/list.js +1 -2
- package/dist/cmd/cloud/task/list.js.map +1 -1
- package/dist/cmd/cloud/task/stats.d.ts +3 -0
- package/dist/cmd/cloud/task/stats.d.ts.map +1 -0
- package/dist/cmd/cloud/task/stats.js +66 -0
- package/dist/cmd/cloud/task/stats.js.map +1 -0
- package/dist/cmd/cloud/task/update.d.ts.map +1 -1
- package/dist/cmd/cloud/task/update.js +0 -1
- package/dist/cmd/cloud/task/update.js.map +1 -1
- package/dist/cmd/cloud/task/util.d.ts +4 -7
- package/dist/cmd/cloud/task/util.d.ts.map +1 -1
- package/dist/cmd/cloud/task/util.js +6 -10
- package/dist/cmd/cloud/task/util.js.map +1 -1
- package/dist/cmd/cloud/vector/get.d.ts.map +1 -1
- package/dist/cmd/cloud/vector/get.js +17 -12
- package/dist/cmd/cloud/vector/get.js.map +1 -1
- package/dist/cmd/cloud/vector/stats.d.ts.map +1 -1
- package/dist/cmd/cloud/vector/stats.js +10 -7
- package/dist/cmd/cloud/vector/stats.js.map +1 -1
- package/dist/cmd/cloud/webhook/deliveries.d.ts.map +1 -1
- package/dist/cmd/cloud/webhook/deliveries.js +9 -3
- package/dist/cmd/cloud/webhook/deliveries.js.map +1 -1
- package/dist/cmd/cloud/webhook/destinations.d.ts.map +1 -1
- package/dist/cmd/cloud/webhook/destinations.js +20 -9
- package/dist/cmd/cloud/webhook/destinations.js.map +1 -1
- package/dist/cmd/cloud/webhook/get.js +2 -2
- package/dist/cmd/cloud/webhook/get.js.map +1 -1
- package/dist/cmd/cloud/webhook/receipts.d.ts.map +1 -1
- package/dist/cmd/cloud/webhook/receipts.js +19 -3
- package/dist/cmd/cloud/webhook/receipts.js.map +1 -1
- package/dist/tui.d.ts +4 -0
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +8 -0
- package/dist/tui.js.map +1 -1
- package/package.json +6 -6
- package/src/cmd/cloud/db/index.ts +2 -0
- package/src/cmd/cloud/db/stats.ts +80 -0
- package/src/cmd/cloud/email/create.ts +16 -6
- package/src/cmd/cloud/email/delete.ts +1 -1
- package/src/cmd/cloud/email/destination/delete.ts +1 -1
- package/src/cmd/cloud/email/destination/list.ts +1 -1
- package/src/cmd/cloud/email/destination/url.ts +5 -4
- package/src/cmd/cloud/email/get.ts +1 -1
- package/src/cmd/cloud/email/inbound/get.ts +2 -3
- package/src/cmd/cloud/email/inbound/list.ts +1 -3
- package/src/cmd/cloud/email/inbound/schemas.ts +3 -1
- package/src/cmd/cloud/email/index.ts +2 -0
- package/src/cmd/cloud/email/list.ts +9 -2
- package/src/cmd/cloud/email/outbound/get.ts +4 -4
- package/src/cmd/cloud/email/outbound/list.ts +3 -3
- package/src/cmd/cloud/email/outbound/schemas.ts +2 -2
- package/src/cmd/cloud/email/send.ts +8 -10
- package/src/cmd/cloud/email/stats.ts +77 -0
- package/src/cmd/cloud/email/util.ts +10 -29
- package/src/cmd/cloud/index.ts +2 -0
- package/src/cmd/cloud/queue/get.ts +4 -4
- package/src/cmd/cloud/queue/receive.ts +15 -7
- package/src/cmd/cloud/queue/stats.ts +3 -3
- package/src/cmd/cloud/sandbox/checkpoint/create.ts +85 -0
- package/src/cmd/cloud/sandbox/checkpoint/delete.ts +93 -0
- package/src/cmd/cloud/sandbox/checkpoint/index.ts +33 -0
- package/src/cmd/cloud/sandbox/checkpoint/list.ts +83 -0
- package/src/cmd/cloud/sandbox/checkpoint/restore.ts +72 -0
- package/src/cmd/cloud/sandbox/get.ts +6 -3
- package/src/cmd/cloud/sandbox/index.ts +4 -0
- package/src/cmd/cloud/sandbox/snapshot/build.ts +9 -9
- package/src/cmd/cloud/sandbox/snapshot/get.ts +3 -3
- package/src/cmd/cloud/sandbox/stats.ts +86 -0
- package/src/cmd/cloud/schedule/create.ts +3 -4
- package/src/cmd/cloud/schedule/delete.ts +2 -3
- package/src/cmd/cloud/schedule/delivery/get.ts +3 -4
- package/src/cmd/cloud/schedule/delivery/list.ts +2 -3
- package/src/cmd/cloud/schedule/destination/create.ts +8 -4
- package/src/cmd/cloud/schedule/destination/delete.ts +2 -3
- package/src/cmd/cloud/schedule/destination/get.ts +17 -17
- package/src/cmd/cloud/schedule/destination/list.ts +15 -10
- package/src/cmd/cloud/schedule/get.ts +17 -12
- package/src/cmd/cloud/schedule/index.ts +2 -0
- package/src/cmd/cloud/schedule/list.ts +2 -3
- package/src/cmd/cloud/schedule/stats.ts +74 -0
- package/src/cmd/cloud/schedule/update.ts +5 -5
- package/src/cmd/cloud/schedule/util.ts +13 -18
- package/src/cmd/cloud/services/index.ts +11 -0
- package/src/cmd/cloud/services/stats.ts +225 -0
- package/src/cmd/cloud/stream/index.ts +2 -1
- package/src/cmd/cloud/stream/stats.ts +74 -0
- package/src/cmd/cloud/task/create.ts +0 -1
- package/src/cmd/cloud/task/get.ts +5 -4
- package/src/cmd/cloud/task/index.ts +2 -1
- package/src/cmd/cloud/task/list.ts +1 -2
- package/src/cmd/cloud/task/stats.ts +74 -0
- package/src/cmd/cloud/task/update.ts +0 -1
- package/src/cmd/cloud/task/util.ts +12 -24
- package/src/cmd/cloud/vector/get.ts +16 -11
- package/src/cmd/cloud/vector/stats.ts +10 -8
- package/src/cmd/cloud/webhook/deliveries.ts +16 -3
- package/src/cmd/cloud/webhook/destinations.ts +22 -9
- package/src/cmd/cloud/webhook/get.ts +2 -2
- package/src/cmd/cloud/webhook/receipts.ts +16 -3
- package/src/tui.ts +9 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { getGlobalCatalystAPIClient } from '../../../config';
|
|
5
|
+
import { getCommand } from '../../../command-prefix';
|
|
6
|
+
import { getServiceStats, type ServiceStatsData } from '@agentuity/server';
|
|
7
|
+
|
|
8
|
+
function formatNumber(n: number): string {
|
|
9
|
+
if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)}M`;
|
|
10
|
+
if (n >= 1_000) return `${(n / 1_000).toFixed(1)}K`;
|
|
11
|
+
return String(n);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function displayStats(data: ServiceStatsData): void {
|
|
15
|
+
const svc = data.services.schedule;
|
|
16
|
+
if (!svc) {
|
|
17
|
+
tui.info('No schedule data found.');
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
tui.header('Schedule Statistics');
|
|
21
|
+
tui.newline();
|
|
22
|
+
console.log(
|
|
23
|
+
` ${tui.muted('Schedules:')} ${formatNumber(svc.scheduleCount)}`
|
|
24
|
+
);
|
|
25
|
+
console.log(
|
|
26
|
+
` ${tui.muted('Deliveries:')} ${formatNumber(svc.totalDeliveries)} (${svc.successDeliveries} ok, ${svc.failedDeliveries} failed)`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const statsSubcommand = createCommand({
|
|
31
|
+
name: 'stats',
|
|
32
|
+
description: 'View schedule statistics',
|
|
33
|
+
tags: ['read-only', 'requires-auth'],
|
|
34
|
+
requires: { auth: true, org: true },
|
|
35
|
+
examples: [
|
|
36
|
+
{
|
|
37
|
+
command: getCommand('cloud schedule stats'),
|
|
38
|
+
description: 'View schedule statistics',
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
schema: {
|
|
42
|
+
options: z.object({
|
|
43
|
+
start: z.string().optional().describe('Start time (ISO 8601)'),
|
|
44
|
+
end: z.string().optional().describe('End time (ISO 8601)'),
|
|
45
|
+
}),
|
|
46
|
+
},
|
|
47
|
+
idempotent: true,
|
|
48
|
+
|
|
49
|
+
async handler(ctx) {
|
|
50
|
+
const { opts, options } = ctx;
|
|
51
|
+
const client = await getGlobalCatalystAPIClient(ctx.logger, ctx.auth, ctx.config?.name);
|
|
52
|
+
const orgId = ctx.orgId ?? ctx.options.orgId ?? ctx.config?.preferences?.orgId;
|
|
53
|
+
|
|
54
|
+
if (!orgId) {
|
|
55
|
+
ctx.logger.fatal('Organization ID is required. Use --org-id or set a preferred org.');
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const data = await getServiceStats(client, orgId, {
|
|
60
|
+
service: 'schedule',
|
|
61
|
+
start: opts.start,
|
|
62
|
+
end: opts.end,
|
|
63
|
+
orgIdHeader: orgId,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
if (!options.json) {
|
|
67
|
+
displayStats(data);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return data;
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export default statsSubcommand;
|
|
@@ -21,8 +21,7 @@ export const updateSubcommand = createCommand({
|
|
|
21
21
|
name: 'update',
|
|
22
22
|
description: 'Update a schedule',
|
|
23
23
|
tags: ['mutating', 'requires-auth'],
|
|
24
|
-
requires: { auth: true
|
|
25
|
-
optional: { project: true },
|
|
24
|
+
requires: { auth: true },
|
|
26
25
|
examples: [
|
|
27
26
|
{
|
|
28
27
|
command: getCommand("cloud schedule update sched_abc123 --expression '*/5 * * * *'"),
|
|
@@ -37,17 +36,18 @@ export const updateSubcommand = createCommand({
|
|
|
37
36
|
name: z.string().optional().describe('Schedule name'),
|
|
38
37
|
expression: z.string().optional().describe('Cron expression'),
|
|
39
38
|
description: z.string().optional().describe('Schedule description'),
|
|
39
|
+
clearDescription: z.boolean().optional().describe('Clear the schedule description'),
|
|
40
40
|
}),
|
|
41
41
|
response: ScheduleUpdateResponseSchema,
|
|
42
42
|
},
|
|
43
43
|
|
|
44
44
|
async handler(ctx) {
|
|
45
45
|
const { args, opts, options } = ctx;
|
|
46
|
-
const schedule = createScheduleAdapter(ctx);
|
|
46
|
+
const schedule = await createScheduleAdapter(ctx);
|
|
47
47
|
const result = await schedule.update(args.schedule_id, {
|
|
48
48
|
name: opts.name,
|
|
49
49
|
expression: opts.expression,
|
|
50
|
-
description: opts.description,
|
|
50
|
+
description: opts.clearDescription ? '' : opts.description,
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
if (!options.json) {
|
|
@@ -58,7 +58,7 @@ export const updateSubcommand = createCommand({
|
|
|
58
58
|
Name: result.schedule.name,
|
|
59
59
|
ID: result.schedule.id,
|
|
60
60
|
Expression: result.schedule.expression,
|
|
61
|
-
Description: result.schedule.description
|
|
61
|
+
Description: result.schedule.description || '-',
|
|
62
62
|
Updated: new Date(result.schedule.updated_at).toLocaleString(),
|
|
63
63
|
},
|
|
64
64
|
],
|
|
@@ -1,34 +1,29 @@
|
|
|
1
1
|
import { ScheduleService, type Logger } from '@agentuity/core';
|
|
2
2
|
import { createServerFetchAdapter } from '@agentuity/server';
|
|
3
|
-
import type { AuthData, Config, GlobalOptions
|
|
3
|
+
import type { AuthData, Config, GlobalOptions } from '../../../types';
|
|
4
4
|
import { getCatalystUrl } from '../../../catalyst';
|
|
5
|
+
import { defaultProfileName, getDefaultRegion } from '../../../config';
|
|
5
6
|
import * as tui from '../../../tui';
|
|
6
7
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
explicitOrgId?: string
|
|
17
|
-
) {
|
|
8
|
+
export interface ScheduleContext {
|
|
9
|
+
logger: Logger;
|
|
10
|
+
auth: AuthData;
|
|
11
|
+
config: Config | null;
|
|
12
|
+
options: GlobalOptions;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function createScheduleAdapter(ctx: ScheduleContext) {
|
|
18
16
|
const orgId =
|
|
19
|
-
explicitOrgId ??
|
|
20
|
-
ctx.project?.orgId ??
|
|
21
17
|
ctx.options.orgId ??
|
|
22
18
|
(process.env.AGENTUITY_CLOUD_ORG_ID || ctx.config?.preferences?.orgId);
|
|
23
19
|
if (!orgId) {
|
|
24
|
-
tui.fatal(
|
|
25
|
-
'Organization ID is required. Either run from a project directory or use --org-id flag.'
|
|
26
|
-
);
|
|
20
|
+
tui.fatal('Organization ID is required. Use --org-id flag or set AGENTUITY_CLOUD_ORG_ID.');
|
|
27
21
|
}
|
|
28
22
|
const adapter = createServerFetchAdapter(
|
|
29
23
|
{ headers: { Authorization: `Bearer ${ctx.auth.apiKey}`, 'x-agentuity-orgid': orgId } },
|
|
30
24
|
ctx.logger
|
|
31
25
|
);
|
|
32
|
-
const
|
|
26
|
+
const region = await getDefaultRegion(ctx.config?.name ?? defaultProfileName, ctx.config);
|
|
27
|
+
const baseUrl = getCatalystUrl(region);
|
|
33
28
|
return new ScheduleService(baseUrl, adapter);
|
|
34
29
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createCommand } from '../../../types';
|
|
2
|
+
import { statsSubcommand } from './stats';
|
|
3
|
+
|
|
4
|
+
const servicesCommand = createCommand({
|
|
5
|
+
name: 'services',
|
|
6
|
+
description: 'Service usage statistics',
|
|
7
|
+
tags: ['read-only', 'requires-auth'],
|
|
8
|
+
subcommands: [statsSubcommand],
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export default servicesCommand;
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { getGlobalCatalystAPIClient } from '../../../config';
|
|
5
|
+
import { getCommand } from '../../../command-prefix';
|
|
6
|
+
import {
|
|
7
|
+
getServiceStats,
|
|
8
|
+
VALID_SERVICES,
|
|
9
|
+
type ServiceName,
|
|
10
|
+
type ServiceStatsData,
|
|
11
|
+
} from '@agentuity/server';
|
|
12
|
+
|
|
13
|
+
function formatNumber(n: number): string {
|
|
14
|
+
if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)}M`;
|
|
15
|
+
if (n >= 1_000) return `${(n / 1_000).toFixed(1)}K`;
|
|
16
|
+
return String(n);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function formatLatency(ms: number): string {
|
|
20
|
+
if (ms >= 1000) return `${(ms / 1000).toFixed(1)}s`;
|
|
21
|
+
return `${Math.round(ms)}ms`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function displayServiceStats(data: ServiceStatsData): void {
|
|
25
|
+
tui.header('Service Statistics');
|
|
26
|
+
|
|
27
|
+
const services = data.services;
|
|
28
|
+
let hasData = false;
|
|
29
|
+
|
|
30
|
+
if (services.keyvalue) {
|
|
31
|
+
hasData = true;
|
|
32
|
+
tui.newline();
|
|
33
|
+
console.log(tui.colorPrimary('Key-Value:'));
|
|
34
|
+
console.log(
|
|
35
|
+
` ${tui.muted('Namespaces:')} ${formatNumber(services.keyvalue.namespaceCount)}`
|
|
36
|
+
);
|
|
37
|
+
console.log(
|
|
38
|
+
` ${tui.muted('Keys:')} ${formatNumber(services.keyvalue.keyCount)}`
|
|
39
|
+
);
|
|
40
|
+
console.log(
|
|
41
|
+
` ${tui.muted('Total Size:')} ${tui.formatBytes(services.keyvalue.totalSizeBytes)}`
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (services.vector) {
|
|
46
|
+
hasData = true;
|
|
47
|
+
tui.newline();
|
|
48
|
+
console.log(tui.colorPrimary('Vector:'));
|
|
49
|
+
console.log(
|
|
50
|
+
` ${tui.muted('Namespaces:')} ${formatNumber(services.vector.namespaceCount)}`
|
|
51
|
+
);
|
|
52
|
+
console.log(
|
|
53
|
+
` ${tui.muted('Documents:')} ${formatNumber(services.vector.documentCount)}`
|
|
54
|
+
);
|
|
55
|
+
console.log(
|
|
56
|
+
` ${tui.muted('Total Size:')} ${tui.formatBytes(services.vector.totalSizeBytes)}`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (services.queue) {
|
|
61
|
+
hasData = true;
|
|
62
|
+
tui.newline();
|
|
63
|
+
console.log(tui.colorPrimary('Queue:'));
|
|
64
|
+
console.log(
|
|
65
|
+
` ${tui.muted('Queues:')} ${formatNumber(services.queue.queueCount)}`
|
|
66
|
+
);
|
|
67
|
+
console.log(
|
|
68
|
+
` ${tui.muted('Total Messages:')} ${formatNumber(services.queue.totalMessages)}`
|
|
69
|
+
);
|
|
70
|
+
console.log(
|
|
71
|
+
` ${tui.muted('DLQ Messages:')} ${formatNumber(services.queue.totalDlq)}`
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (services.stream) {
|
|
76
|
+
hasData = true;
|
|
77
|
+
tui.newline();
|
|
78
|
+
console.log(tui.colorPrimary('Stream:'));
|
|
79
|
+
console.log(
|
|
80
|
+
` ${tui.muted('Streams:')} ${formatNumber(services.stream.streamCount)}`
|
|
81
|
+
);
|
|
82
|
+
console.log(
|
|
83
|
+
` ${tui.muted('Total Size:')} ${tui.formatBytes(services.stream.totalSizeBytes)}`
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (services.sandbox) {
|
|
88
|
+
hasData = true;
|
|
89
|
+
const sb = services.sandbox;
|
|
90
|
+
tui.newline();
|
|
91
|
+
console.log(tui.colorPrimary('Sandbox:'));
|
|
92
|
+
console.log(
|
|
93
|
+
` ${tui.muted('Active:')} ${formatNumber(sb.totalActive)} (${sb.running} running, ${sb.idle} idle, ${sb.creating} creating)`
|
|
94
|
+
);
|
|
95
|
+
console.log(
|
|
96
|
+
` ${tui.muted('Executions:')} ${formatNumber(sb.totalExecutions)}`
|
|
97
|
+
);
|
|
98
|
+
console.log(` ${tui.muted('CPU Time:')} ${formatLatency(sb.totalCpuTimeMs)}`);
|
|
99
|
+
console.log(
|
|
100
|
+
` ${tui.muted('Memory:')} ${tui.formatBytes(sb.totalMemoryByteSec)}`
|
|
101
|
+
);
|
|
102
|
+
console.log(
|
|
103
|
+
` ${tui.muted('Network Out:')} ${tui.formatBytes(sb.totalNetworkEgressBytes)}`
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (services.email) {
|
|
108
|
+
hasData = true;
|
|
109
|
+
const em = services.email;
|
|
110
|
+
tui.newline();
|
|
111
|
+
console.log(tui.colorPrimary('Email:'));
|
|
112
|
+
console.log(
|
|
113
|
+
` ${tui.muted('Addresses:')} ${formatNumber(em.addressCount)}`
|
|
114
|
+
);
|
|
115
|
+
console.log(
|
|
116
|
+
` ${tui.muted('Inbound:')} ${formatNumber(em.inboundCount)}`
|
|
117
|
+
);
|
|
118
|
+
console.log(
|
|
119
|
+
` ${tui.muted('Outbound:')} ${formatNumber(em.outboundCount)} (${em.outboundSuccess} ok, ${em.outboundFailed} failed)`
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (services.task) {
|
|
124
|
+
hasData = true;
|
|
125
|
+
const tk = services.task;
|
|
126
|
+
tui.newline();
|
|
127
|
+
console.log(tui.colorPrimary('Task:'));
|
|
128
|
+
console.log(` ${tui.muted('Total:')} ${formatNumber(tk.total)}`);
|
|
129
|
+
console.log(` ${tui.muted('Open:')} ${formatNumber(tk.open)}`);
|
|
130
|
+
console.log(
|
|
131
|
+
` ${tui.muted('In Progress:')} ${formatNumber(tk.inProgress)}`
|
|
132
|
+
);
|
|
133
|
+
console.log(` ${tui.muted('Closed:')} ${formatNumber(tk.closed)}`);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (services.schedule) {
|
|
137
|
+
hasData = true;
|
|
138
|
+
const sc = services.schedule;
|
|
139
|
+
tui.newline();
|
|
140
|
+
console.log(tui.colorPrimary('Schedule:'));
|
|
141
|
+
console.log(
|
|
142
|
+
` ${tui.muted('Schedules:')} ${formatNumber(sc.scheduleCount)}`
|
|
143
|
+
);
|
|
144
|
+
console.log(
|
|
145
|
+
` ${tui.muted('Deliveries:')} ${formatNumber(sc.totalDeliveries)} (${sc.successDeliveries} ok, ${sc.failedDeliveries} failed)`
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (services.database) {
|
|
150
|
+
hasData = true;
|
|
151
|
+
const db = services.database;
|
|
152
|
+
tui.newline();
|
|
153
|
+
console.log(tui.colorPrimary('Database:'));
|
|
154
|
+
console.log(
|
|
155
|
+
` ${tui.muted('Databases:')} ${formatNumber(db.databaseCount)}`
|
|
156
|
+
);
|
|
157
|
+
console.log(
|
|
158
|
+
` ${tui.muted('Tables:')} ${formatNumber(db.totalTableCount)}`
|
|
159
|
+
);
|
|
160
|
+
console.log(
|
|
161
|
+
` ${tui.muted('Records:')} ${formatNumber(db.totalRecordCount)}`
|
|
162
|
+
);
|
|
163
|
+
console.log(
|
|
164
|
+
` ${tui.muted('Total Size:')} ${tui.formatBytes(db.totalSizeBytes)}`
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (!hasData) {
|
|
169
|
+
tui.info('No service usage data found.');
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export const statsSubcommand = createCommand({
|
|
174
|
+
name: 'stats',
|
|
175
|
+
description: 'View service usage statistics',
|
|
176
|
+
tags: ['read-only', 'requires-auth'],
|
|
177
|
+
requires: { auth: true, org: true },
|
|
178
|
+
examples: [
|
|
179
|
+
{
|
|
180
|
+
command: getCommand('cloud services stats'),
|
|
181
|
+
description: 'View stats for all services',
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
command: getCommand('cloud services stats --service keyvalue'),
|
|
185
|
+
description: 'View stats for key-value service only',
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
schema: {
|
|
189
|
+
options: z.object({
|
|
190
|
+
service: z
|
|
191
|
+
.string()
|
|
192
|
+
.optional()
|
|
193
|
+
.describe(`Service name to filter (${VALID_SERVICES.join(', ')})`),
|
|
194
|
+
start: z.string().optional().describe('Start time (ISO 8601)'),
|
|
195
|
+
end: z.string().optional().describe('End time (ISO 8601)'),
|
|
196
|
+
}),
|
|
197
|
+
},
|
|
198
|
+
idempotent: true,
|
|
199
|
+
|
|
200
|
+
async handler(ctx) {
|
|
201
|
+
const { opts, options } = ctx;
|
|
202
|
+
const client = await getGlobalCatalystAPIClient(ctx.logger, ctx.auth, ctx.config?.name);
|
|
203
|
+
const orgId = ctx.orgId ?? ctx.options.orgId ?? ctx.config?.preferences?.orgId;
|
|
204
|
+
|
|
205
|
+
if (!orgId) {
|
|
206
|
+
ctx.logger.fatal('Organization ID is required. Use --org-id or set a preferred org.');
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const data = await getServiceStats(client, orgId, {
|
|
211
|
+
service: opts.service as ServiceName,
|
|
212
|
+
start: opts.start,
|
|
213
|
+
end: opts.end,
|
|
214
|
+
orgIdHeader: orgId,
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
if (!options.json) {
|
|
218
|
+
displayServiceStats(data);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return data;
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
export default statsSubcommand;
|
|
@@ -3,6 +3,7 @@ import createSubcommand from './create';
|
|
|
3
3
|
import listSubcommand from './list';
|
|
4
4
|
import getSubcommand from './get';
|
|
5
5
|
import deleteSubcommand from './delete';
|
|
6
|
+
import statsSubcommand from './stats';
|
|
6
7
|
import { getCommand } from '../../../command-prefix';
|
|
7
8
|
|
|
8
9
|
export const streamCommand = createCommand({
|
|
@@ -22,7 +23,7 @@ export const streamCommand = createCommand({
|
|
|
22
23
|
{ command: getCommand('cloud stream list'), description: 'List all streams' },
|
|
23
24
|
{ command: getCommand('cloud stream get <id>'), description: 'Get stream details' },
|
|
24
25
|
],
|
|
25
|
-
subcommands: [createSubcommand, listSubcommand, getSubcommand, deleteSubcommand],
|
|
26
|
+
subcommands: [createSubcommand, listSubcommand, getSubcommand, deleteSubcommand, statsSubcommand],
|
|
26
27
|
});
|
|
27
28
|
|
|
28
29
|
export default streamCommand;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { getGlobalCatalystAPIClient } from '../../../config';
|
|
5
|
+
import { getCommand } from '../../../command-prefix';
|
|
6
|
+
import { getServiceStats, type ServiceStatsData } from '@agentuity/server';
|
|
7
|
+
|
|
8
|
+
function formatNumber(n: number): string {
|
|
9
|
+
if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)}M`;
|
|
10
|
+
if (n >= 1_000) return `${(n / 1_000).toFixed(1)}K`;
|
|
11
|
+
return String(n);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function displayStats(data: ServiceStatsData): void {
|
|
15
|
+
const svc = data.services.stream;
|
|
16
|
+
if (!svc) {
|
|
17
|
+
tui.info('No stream data found.');
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
tui.header('Stream Statistics');
|
|
21
|
+
tui.newline();
|
|
22
|
+
console.log(
|
|
23
|
+
` ${tui.muted('Streams:')} ${formatNumber(svc.streamCount)}`
|
|
24
|
+
);
|
|
25
|
+
console.log(
|
|
26
|
+
` ${tui.muted('Total Size:')} ${tui.formatBytes(svc.totalSizeBytes)}`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const statsSubcommand = createCommand({
|
|
31
|
+
name: 'stats',
|
|
32
|
+
description: 'View stream statistics',
|
|
33
|
+
tags: ['read-only', 'requires-auth'],
|
|
34
|
+
requires: { auth: true, org: true },
|
|
35
|
+
examples: [
|
|
36
|
+
{
|
|
37
|
+
command: getCommand('cloud stream stats'),
|
|
38
|
+
description: 'View stream statistics',
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
schema: {
|
|
42
|
+
options: z.object({
|
|
43
|
+
start: z.string().optional().describe('Start time (ISO 8601)'),
|
|
44
|
+
end: z.string().optional().describe('End time (ISO 8601)'),
|
|
45
|
+
}),
|
|
46
|
+
},
|
|
47
|
+
idempotent: true,
|
|
48
|
+
|
|
49
|
+
async handler(ctx) {
|
|
50
|
+
const { opts, options } = ctx;
|
|
51
|
+
const client = await getGlobalCatalystAPIClient(ctx.logger, ctx.auth, ctx.config?.name);
|
|
52
|
+
const orgId = ctx.orgId ?? ctx.options.orgId ?? ctx.config?.preferences?.orgId;
|
|
53
|
+
|
|
54
|
+
if (!orgId) {
|
|
55
|
+
ctx.logger.fatal('Organization ID is required. Use --org-id or set a preferred org.');
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const data = await getServiceStats(client, orgId, {
|
|
60
|
+
service: 'stream',
|
|
61
|
+
start: opts.start,
|
|
62
|
+
end: opts.end,
|
|
63
|
+
orgIdHeader: orgId,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
if (!options.json) {
|
|
67
|
+
displayStats(data);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return data;
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export default statsSubcommand;
|
|
@@ -24,7 +24,6 @@ export const createSubcommand = createCommand({
|
|
|
24
24
|
description: 'Create a new task',
|
|
25
25
|
tags: ['mutating', 'slow', 'requires-auth'],
|
|
26
26
|
requires: { auth: true },
|
|
27
|
-
optional: { project: true },
|
|
28
27
|
examples: [
|
|
29
28
|
{
|
|
30
29
|
command: getCommand('cloud task create "Fix login bug" --type bug --created-id agent_001'),
|
|
@@ -34,7 +34,6 @@ export const getSubcommand = createCommand({
|
|
|
34
34
|
tags: ['read-only', 'slow', 'requires-auth'],
|
|
35
35
|
idempotent: true,
|
|
36
36
|
requires: { auth: true },
|
|
37
|
-
optional: { project: true },
|
|
38
37
|
examples: [
|
|
39
38
|
{
|
|
40
39
|
command: getCommand('cloud task get task_abc123'),
|
|
@@ -103,11 +102,13 @@ export const getSubcommand = createCommand({
|
|
|
103
102
|
if (task.closed_date) {
|
|
104
103
|
tableData['Closed'] = new Date(task.closed_date).toLocaleString();
|
|
105
104
|
}
|
|
105
|
+
tui.table([tableData], Object.keys(tableData), { layout: 'vertical', padStart: ' ' });
|
|
106
|
+
|
|
106
107
|
if (task.metadata && Object.keys(task.metadata).length > 0) {
|
|
107
|
-
|
|
108
|
+
tui.newline();
|
|
109
|
+
tui.header('Metadata');
|
|
110
|
+
tui.json(task.metadata);
|
|
108
111
|
}
|
|
109
|
-
|
|
110
|
-
tui.table([tableData], Object.keys(tableData), { layout: 'vertical', padStart: ' ' });
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
return {
|
|
@@ -3,6 +3,7 @@ import { getSubcommand } from './get';
|
|
|
3
3
|
import { createSubcommand } from './create';
|
|
4
4
|
import { updateSubcommand } from './update';
|
|
5
5
|
import { listSubcommand } from './list';
|
|
6
|
+
import { statsSubcommand } from './stats';
|
|
6
7
|
import { getCommand } from '../../../command-prefix';
|
|
7
8
|
|
|
8
9
|
export const taskCommand = createCommand({
|
|
@@ -27,7 +28,7 @@ export const taskCommand = createCommand({
|
|
|
27
28
|
description: 'Update task status',
|
|
28
29
|
},
|
|
29
30
|
],
|
|
30
|
-
subcommands: [getSubcommand, createSubcommand, updateSubcommand, listSubcommand],
|
|
31
|
+
subcommands: [getSubcommand, createSubcommand, updateSubcommand, listSubcommand, statsSubcommand],
|
|
31
32
|
requires: { auth: true },
|
|
32
33
|
});
|
|
33
34
|
|
|
@@ -59,7 +59,6 @@ export const listSubcommand = createCommand({
|
|
|
59
59
|
description: 'List tasks with optional filtering and sorting',
|
|
60
60
|
tags: ['read-only', 'slow', 'requires-auth'],
|
|
61
61
|
requires: { auth: true },
|
|
62
|
-
optional: { project: true },
|
|
63
62
|
idempotent: true,
|
|
64
63
|
pagination: {
|
|
65
64
|
supported: true,
|
|
@@ -163,7 +162,7 @@ export const listSubcommand = createCommand({
|
|
|
163
162
|
]);
|
|
164
163
|
|
|
165
164
|
tui.info(
|
|
166
|
-
|
|
165
|
+
`Showing ${result.tasks.length} of ${result.total} ${tui.plural(result.total, 'task', 'tasks')} (${durationMs.toFixed(1)}ms)`
|
|
167
166
|
);
|
|
168
167
|
}
|
|
169
168
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { getGlobalCatalystAPIClient } from '../../../config';
|
|
5
|
+
import { getCommand } from '../../../command-prefix';
|
|
6
|
+
import { getServiceStats, type ServiceStatsData } from '@agentuity/server';
|
|
7
|
+
|
|
8
|
+
function formatNumber(n: number): string {
|
|
9
|
+
if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)}M`;
|
|
10
|
+
if (n >= 1_000) return `${(n / 1_000).toFixed(1)}K`;
|
|
11
|
+
return String(n);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function displayStats(data: ServiceStatsData): void {
|
|
15
|
+
const svc = data.services.task;
|
|
16
|
+
if (!svc) {
|
|
17
|
+
tui.info('No task data found.');
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
tui.header('Task Statistics');
|
|
21
|
+
tui.newline();
|
|
22
|
+
console.log(` ${tui.muted('Total:')} ${formatNumber(svc.total)}`);
|
|
23
|
+
console.log(` ${tui.muted('Open:')} ${formatNumber(svc.open)}`);
|
|
24
|
+
console.log(
|
|
25
|
+
` ${tui.muted('In Progress:')} ${formatNumber(svc.inProgress)}`
|
|
26
|
+
);
|
|
27
|
+
console.log(` ${tui.muted('Closed:')} ${formatNumber(svc.closed)}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const statsSubcommand = createCommand({
|
|
31
|
+
name: 'stats',
|
|
32
|
+
description: 'View task statistics',
|
|
33
|
+
tags: ['read-only', 'requires-auth'],
|
|
34
|
+
requires: { auth: true, org: true },
|
|
35
|
+
examples: [
|
|
36
|
+
{
|
|
37
|
+
command: getCommand('cloud task stats'),
|
|
38
|
+
description: 'View task statistics',
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
schema: {
|
|
42
|
+
options: z.object({
|
|
43
|
+
start: z.string().optional().describe('Start time (ISO 8601)'),
|
|
44
|
+
end: z.string().optional().describe('End time (ISO 8601)'),
|
|
45
|
+
}),
|
|
46
|
+
},
|
|
47
|
+
idempotent: true,
|
|
48
|
+
|
|
49
|
+
async handler(ctx) {
|
|
50
|
+
const { opts, options } = ctx;
|
|
51
|
+
const client = await getGlobalCatalystAPIClient(ctx.logger, ctx.auth, ctx.config?.name);
|
|
52
|
+
const orgId = ctx.orgId ?? ctx.options.orgId ?? ctx.config?.preferences?.orgId;
|
|
53
|
+
|
|
54
|
+
if (!orgId) {
|
|
55
|
+
ctx.logger.fatal('Organization ID is required. Use --org-id or set a preferred org.');
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const data = await getServiceStats(client, orgId, {
|
|
60
|
+
service: 'task',
|
|
61
|
+
start: opts.start,
|
|
62
|
+
end: opts.end,
|
|
63
|
+
orgIdHeader: orgId,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
if (!options.json) {
|
|
67
|
+
displayStats(data);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return data;
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export default statsSubcommand;
|
|
@@ -24,7 +24,6 @@ export const updateSubcommand = createCommand({
|
|
|
24
24
|
description: 'Update an existing task',
|
|
25
25
|
tags: ['mutating', 'slow', 'requires-auth'],
|
|
26
26
|
requires: { auth: true },
|
|
27
|
-
optional: { project: true },
|
|
28
27
|
examples: [
|
|
29
28
|
{
|
|
30
29
|
command: getCommand('cloud task update task_abc123 --status in_progress'),
|