@agentuity/cli 0.0.57 → 0.0.59
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/build/bundler.d.ts +1 -1
- package/dist/cmd/build/bundler.js +8 -9
- package/dist/cmd/build/bundler.js.map +1 -1
- package/dist/cmd/cloud/agent/get.d.ts +2 -0
- package/dist/cmd/cloud/agent/get.d.ts.map +1 -0
- package/dist/cmd/cloud/agent/get.js +97 -0
- package/dist/cmd/cloud/agent/get.js.map +1 -0
- package/dist/cmd/cloud/agent/index.d.ts +2 -0
- package/dist/cmd/cloud/agent/index.d.ts.map +1 -0
- package/dist/cmd/cloud/agent/index.js +11 -0
- package/dist/cmd/cloud/agent/index.js.map +1 -0
- package/dist/cmd/cloud/agent/list.d.ts +2 -0
- package/dist/cmd/cloud/agent/list.d.ts.map +1 -0
- package/dist/cmd/cloud/agent/list.js +101 -0
- package/dist/cmd/cloud/agent/list.js.map +1 -0
- package/dist/cmd/cloud/agent/schema.d.ts +4 -0
- package/dist/cmd/cloud/agent/schema.d.ts.map +1 -0
- package/dist/cmd/cloud/agent/schema.js +22 -0
- package/dist/cmd/cloud/agent/schema.js.map +1 -0
- package/dist/cmd/cloud/apikey/create.d.ts +2 -0
- package/dist/cmd/cloud/apikey/create.d.ts.map +1 -0
- package/dist/cmd/cloud/apikey/create.js +100 -0
- package/dist/cmd/cloud/apikey/create.js.map +1 -0
- package/dist/cmd/cloud/apikey/delete.d.ts +2 -0
- package/dist/cmd/cloud/apikey/delete.d.ts.map +1 -0
- package/dist/cmd/cloud/apikey/delete.js +55 -0
- package/dist/cmd/cloud/apikey/delete.js.map +1 -0
- package/dist/cmd/cloud/apikey/get.d.ts +2 -0
- package/dist/cmd/cloud/apikey/get.d.ts.map +1 -0
- package/dist/cmd/cloud/apikey/get.js +57 -0
- package/dist/cmd/cloud/apikey/get.js.map +1 -0
- package/dist/cmd/cloud/apikey/index.d.ts.map +1 -0
- package/dist/cmd/cloud/apikey/index.js +13 -0
- package/dist/cmd/cloud/apikey/index.js.map +1 -0
- package/dist/cmd/cloud/apikey/list.d.ts +2 -0
- package/dist/cmd/cloud/apikey/list.d.ts.map +1 -0
- package/dist/cmd/cloud/apikey/list.js +53 -0
- package/dist/cmd/cloud/apikey/list.js.map +1 -0
- package/dist/cmd/cloud/deployment/index.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/index.js +2 -0
- package/dist/cmd/cloud/deployment/index.js.map +1 -1
- package/dist/cmd/cloud/deployment/logs.d.ts +2 -0
- package/dist/cmd/cloud/deployment/logs.d.ts.map +1 -0
- package/dist/cmd/cloud/deployment/logs.js +70 -0
- package/dist/cmd/cloud/deployment/logs.js.map +1 -0
- package/dist/cmd/cloud/index.d.ts.map +1 -1
- package/dist/cmd/cloud/index.js +8 -2
- package/dist/cmd/cloud/index.js.map +1 -1
- package/dist/cmd/cloud/session/get.js.map +1 -1
- package/dist/cmd/cloud/session/logs.d.ts.map +1 -1
- package/dist/cmd/cloud/session/logs.js +12 -9
- package/dist/cmd/cloud/session/logs.js.map +1 -1
- package/dist/cmd/cloud/stream/delete.d.ts +3 -0
- package/dist/cmd/cloud/stream/delete.d.ts.map +1 -0
- package/dist/cmd/cloud/stream/delete.js +42 -0
- package/dist/cmd/cloud/stream/delete.js.map +1 -0
- package/dist/cmd/cloud/stream/get.d.ts +3 -0
- package/dist/cmd/cloud/stream/get.d.ts.map +1 -0
- package/dist/cmd/cloud/stream/get.js +110 -0
- package/dist/cmd/cloud/stream/get.js.map +1 -0
- package/dist/cmd/cloud/stream/index.d.ts +3 -0
- package/dist/cmd/cloud/stream/index.d.ts.map +1 -0
- package/dist/cmd/cloud/stream/index.js +13 -0
- package/dist/cmd/cloud/stream/index.js.map +1 -0
- package/dist/cmd/cloud/stream/list.d.ts +3 -0
- package/dist/cmd/cloud/stream/list.d.ts.map +1 -0
- package/dist/cmd/cloud/stream/list.js +131 -0
- package/dist/cmd/cloud/stream/list.js.map +1 -0
- package/dist/cmd/cloud/stream/util.d.ts +8 -0
- package/dist/cmd/cloud/stream/util.d.ts.map +1 -0
- package/dist/cmd/cloud/stream/util.js +19 -0
- package/dist/cmd/cloud/stream/util.js.map +1 -0
- package/dist/cmd/cloud/vector/delete.d.ts +3 -0
- package/dist/cmd/cloud/vector/delete.d.ts.map +1 -0
- package/dist/cmd/cloud/vector/delete.js +90 -0
- package/dist/cmd/cloud/vector/delete.js.map +1 -0
- package/dist/cmd/cloud/vector/get.d.ts +3 -0
- package/dist/cmd/cloud/vector/get.d.ts.map +1 -0
- package/dist/cmd/cloud/vector/get.js +80 -0
- package/dist/cmd/cloud/vector/get.js.map +1 -0
- package/dist/cmd/cloud/vector/index.d.ts +3 -0
- package/dist/cmd/cloud/vector/index.d.ts.map +1 -0
- package/dist/cmd/cloud/vector/index.js +14 -0
- package/dist/cmd/cloud/vector/index.js.map +1 -0
- package/dist/cmd/cloud/vector/search.d.ts +3 -0
- package/dist/cmd/cloud/vector/search.d.ts.map +1 -0
- package/dist/cmd/cloud/vector/search.js +136 -0
- package/dist/cmd/cloud/vector/search.js.map +1 -0
- package/dist/cmd/cloud/vector/util.d.ts +8 -0
- package/dist/cmd/cloud/vector/util.d.ts.map +1 -0
- package/dist/cmd/cloud/vector/util.js +18 -0
- package/dist/cmd/cloud/vector/util.js.map +1 -0
- package/dist/cmd/dev/agents.d.ts.map +1 -1
- package/dist/cmd/dev/agents.js +3 -2
- package/dist/cmd/dev/agents.js.map +1 -1
- package/dist/cmd/dev/index.d.ts.map +1 -1
- package/dist/cmd/dev/index.js +103 -55
- package/dist/cmd/dev/index.js.map +1 -1
- package/dist/cmd/index.d.ts.map +1 -1
- package/dist/cmd/index.js +38 -42
- package/dist/cmd/index.js.map +1 -1
- package/dist/schema-parser.d.ts.map +1 -1
- package/dist/schema-parser.js +3 -1
- package/dist/schema-parser.js.map +1 -1
- package/dist/tui.d.ts +10 -1
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +67 -41
- package/dist/tui.js.map +1 -1
- package/dist/utils/date.d.ts +14 -0
- package/dist/utils/date.d.ts.map +1 -0
- package/dist/utils/date.js +51 -0
- package/dist/utils/date.js.map +1 -0
- package/package.json +6 -6
- package/src/cmd/build/bundler.ts +8 -8
- package/src/cmd/cloud/agent/get.ts +105 -0
- package/src/cmd/cloud/agent/index.ts +11 -0
- package/src/cmd/cloud/agent/list.ts +107 -0
- package/src/cmd/cloud/agent/schema.ts +25 -0
- package/src/cmd/cloud/apikey/create.ts +114 -0
- package/src/cmd/cloud/apikey/delete.ts +66 -0
- package/src/cmd/cloud/apikey/get.ts +62 -0
- package/src/cmd/cloud/apikey/index.ts +13 -0
- package/src/cmd/cloud/apikey/list.ts +58 -0
- package/src/cmd/cloud/deployment/index.ts +2 -0
- package/src/cmd/cloud/deployment/logs.ts +75 -0
- package/src/cmd/cloud/index.ts +8 -2
- package/src/cmd/cloud/session/get.ts +5 -5
- package/src/cmd/cloud/session/logs.ts +12 -11
- package/src/cmd/cloud/stream/delete.ts +49 -0
- package/src/cmd/cloud/stream/get.ts +118 -0
- package/src/cmd/cloud/stream/index.ts +14 -0
- package/src/cmd/cloud/stream/list.ts +146 -0
- package/src/cmd/cloud/stream/util.ts +32 -0
- package/src/cmd/cloud/vector/delete.ts +105 -0
- package/src/cmd/cloud/vector/get.ts +94 -0
- package/src/cmd/cloud/vector/index.ts +15 -0
- package/src/cmd/cloud/vector/search.ts +156 -0
- package/src/cmd/cloud/vector/util.ts +28 -0
- package/src/cmd/dev/agents.ts +4 -3
- package/src/cmd/dev/index.ts +114 -59
- package/src/cmd/index.ts +38 -42
- package/src/schema-parser.ts +3 -1
- package/src/tui.ts +80 -48
- package/src/utils/date.ts +57 -0
- package/dist/cmd/cloud/agents/index.d.ts.map +0 -1
- package/dist/cmd/cloud/agents/index.js +0 -133
- package/dist/cmd/cloud/agents/index.js.map +0 -1
- package/src/cmd/cloud/agents/index.ts +0 -148
- /package/dist/cmd/cloud/{agents → apikey}/index.d.ts +0 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createSubcommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { projectAgentList } from '@agentuity/server';
|
|
5
|
+
import Table from 'cli-table3';
|
|
6
|
+
import { abbreviate, abbreviateDescription } from '../../../utils/format';
|
|
7
|
+
import { getCommand } from '../../../command-prefix';
|
|
8
|
+
import { AgentSchema } from './schema';
|
|
9
|
+
|
|
10
|
+
export const listSubcommand = createSubcommand({
|
|
11
|
+
name: 'list',
|
|
12
|
+
description: 'List agents for a project',
|
|
13
|
+
aliases: ['ls'],
|
|
14
|
+
requires: { auth: true, apiClient: true, project: true },
|
|
15
|
+
examples: [
|
|
16
|
+
getCommand('cloud agent list'),
|
|
17
|
+
getCommand('cloud agent list --verbose'),
|
|
18
|
+
getCommand('--json cloud agent list'),
|
|
19
|
+
],
|
|
20
|
+
schema: {
|
|
21
|
+
options: z.object({
|
|
22
|
+
deploymentId: z.string().optional().describe('Filter by deployment ID'),
|
|
23
|
+
verbose: z.boolean().optional().default(false).describe('Show full descriptions'),
|
|
24
|
+
}),
|
|
25
|
+
response: z.array(AgentSchema),
|
|
26
|
+
},
|
|
27
|
+
async handler(ctx) {
|
|
28
|
+
const { opts, apiClient, project, options } = ctx;
|
|
29
|
+
const projectId = project.projectId;
|
|
30
|
+
const verbose = opts?.verbose ?? false;
|
|
31
|
+
|
|
32
|
+
const agents = await tui.spinner({
|
|
33
|
+
message: 'Fetching agents',
|
|
34
|
+
clearOnSuccess: true,
|
|
35
|
+
callback: async () => {
|
|
36
|
+
return projectAgentList(apiClient, projectId, {
|
|
37
|
+
deploymentId: opts?.deploymentId,
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (options.json) {
|
|
43
|
+
return agents;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
tui.info(`Agents (${agents.length})`);
|
|
47
|
+
if (agents.length === 0) {
|
|
48
|
+
console.log(tui.muted('No agents found'));
|
|
49
|
+
} else {
|
|
50
|
+
const table = new Table({
|
|
51
|
+
head: [
|
|
52
|
+
tui.heading('Name'),
|
|
53
|
+
tui.heading('ID'),
|
|
54
|
+
tui.heading('Description'),
|
|
55
|
+
tui.heading('Evals'),
|
|
56
|
+
tui.heading('Created'),
|
|
57
|
+
],
|
|
58
|
+
colAligns: ['left', 'left', 'left', 'center', 'left'],
|
|
59
|
+
wordWrap: true,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
for (const agent of agents) {
|
|
63
|
+
table.push([
|
|
64
|
+
agent.name,
|
|
65
|
+
agent.identifier,
|
|
66
|
+
verbose ? (agent.description ?? 'N/A') : abbreviateDescription(agent.description),
|
|
67
|
+
agent.evals.length,
|
|
68
|
+
new Date(agent.createdAt).toLocaleString(),
|
|
69
|
+
]);
|
|
70
|
+
}
|
|
71
|
+
console.log(table.toString());
|
|
72
|
+
|
|
73
|
+
// Show evals for each agent
|
|
74
|
+
for (const agent of agents) {
|
|
75
|
+
if (agent.evals.length > 0) {
|
|
76
|
+
console.log(`\n Evals for ${agent.name}:`);
|
|
77
|
+
const evalTable = new Table({
|
|
78
|
+
head: [
|
|
79
|
+
tui.heading('Name'),
|
|
80
|
+
tui.heading('ID'),
|
|
81
|
+
tui.heading('Description'),
|
|
82
|
+
tui.heading('Created'),
|
|
83
|
+
],
|
|
84
|
+
colAligns: ['left', 'left', 'left', 'left'],
|
|
85
|
+
wordWrap: true,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
for (const evalItem of agent.evals) {
|
|
89
|
+
evalTable.push([
|
|
90
|
+
evalItem.name,
|
|
91
|
+
verbose
|
|
92
|
+
? (evalItem.identifier ?? 'N/A')
|
|
93
|
+
: (abbreviate(evalItem.identifier, 20) ?? 'N/A'),
|
|
94
|
+
verbose
|
|
95
|
+
? (evalItem.description ?? 'N/A')
|
|
96
|
+
: abbreviateDescription(evalItem.description),
|
|
97
|
+
new Date(evalItem.createdAt).toLocaleString(),
|
|
98
|
+
]);
|
|
99
|
+
}
|
|
100
|
+
console.log(evalTable.toString());
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return agents;
|
|
106
|
+
},
|
|
107
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Agent } from '@agentuity/server';
|
|
3
|
+
|
|
4
|
+
export const AgentSchema: z.ZodType<Agent> = z.object({
|
|
5
|
+
id: z.string(),
|
|
6
|
+
name: z.string(),
|
|
7
|
+
description: z.string().nullable(),
|
|
8
|
+
identifier: z.string(),
|
|
9
|
+
deploymentId: z.string().nullable(),
|
|
10
|
+
devmode: z.boolean(),
|
|
11
|
+
metadata: z.record(z.string(), z.unknown()).nullable(),
|
|
12
|
+
createdAt: z.string(),
|
|
13
|
+
updatedAt: z.string(),
|
|
14
|
+
evals: z.array(
|
|
15
|
+
z.object({
|
|
16
|
+
id: z.string(),
|
|
17
|
+
name: z.string(),
|
|
18
|
+
description: z.string().nullable(),
|
|
19
|
+
identifier: z.string().nullable(),
|
|
20
|
+
devmode: z.boolean(),
|
|
21
|
+
createdAt: z.string(),
|
|
22
|
+
updatedAt: z.string(),
|
|
23
|
+
})
|
|
24
|
+
),
|
|
25
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createSubcommand as createSubcommandHelper } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { apikeyCreate } from '@agentuity/server';
|
|
5
|
+
import { getCommand } from '../../../command-prefix';
|
|
6
|
+
import { parseExpiresAt } from '../../../utils/date';
|
|
7
|
+
|
|
8
|
+
const APIKeyCreateResponseSchema = z.object({
|
|
9
|
+
id: z.string().describe('the API key id'),
|
|
10
|
+
value: z.string().describe('the API key value'),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const createSubcommand = createSubcommandHelper({
|
|
14
|
+
name: 'create',
|
|
15
|
+
aliases: ['new'],
|
|
16
|
+
description: 'Create a new API key',
|
|
17
|
+
tags: ['destructive', 'creates-resource', 'slow', 'requires-auth'],
|
|
18
|
+
examples: [
|
|
19
|
+
getCommand('cloud apikey create --name "My API Key" --expires-at 1y'),
|
|
20
|
+
getCommand('cloud apikey create --name "Short-lived Key" --expires-at 30d'),
|
|
21
|
+
getCommand(
|
|
22
|
+
'cloud apikey create --name "Production Key" --expires-at 2026-01-01T00:00:00Z --confirm'
|
|
23
|
+
),
|
|
24
|
+
],
|
|
25
|
+
requires: { auth: true, apiClient: true, org: true },
|
|
26
|
+
optional: { project: true },
|
|
27
|
+
idempotent: false,
|
|
28
|
+
schema: {
|
|
29
|
+
options: z.object({
|
|
30
|
+
name: z.string().describe('the name for the API key'),
|
|
31
|
+
'expires-at': z
|
|
32
|
+
.string()
|
|
33
|
+
.describe(
|
|
34
|
+
'expiration date as ISO 8601 (2025-12-31T23:59:59Z) or duration (1h, 2d, 30d, 1y)'
|
|
35
|
+
),
|
|
36
|
+
confirm: z
|
|
37
|
+
.boolean()
|
|
38
|
+
.optional()
|
|
39
|
+
.describe('Skip confirmation prompts (required for non-TTY)'),
|
|
40
|
+
}),
|
|
41
|
+
response: APIKeyCreateResponseSchema,
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
async handler(ctx) {
|
|
45
|
+
const { opts, apiClient, project, orgId, options } = ctx;
|
|
46
|
+
|
|
47
|
+
const skipConfirm = opts?.confirm === true;
|
|
48
|
+
|
|
49
|
+
const projectId = project?.projectId ?? null;
|
|
50
|
+
|
|
51
|
+
// Parse expires-at (duration or ISO date)
|
|
52
|
+
let expiresAt: string;
|
|
53
|
+
try {
|
|
54
|
+
expiresAt = parseExpiresAt(opts['expires-at']);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
if (error instanceof Error) {
|
|
57
|
+
tui.fatal(error.message);
|
|
58
|
+
}
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Require --confirm flag when not in a TTY
|
|
63
|
+
if (!process.stdout.isTTY && !skipConfirm) {
|
|
64
|
+
tui.fatal('--confirm is required in non-interactive mode');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Confirm creation in interactive mode
|
|
68
|
+
if (!skipConfirm) {
|
|
69
|
+
const scope = projectId ? `project ${projectId}` : `organization ${orgId}`;
|
|
70
|
+
const confirmed = await tui.confirm(`Create API key "${opts.name}" for ${scope}?`);
|
|
71
|
+
if (!confirmed) {
|
|
72
|
+
tui.fatal('Operation cancelled');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let result: Awaited<ReturnType<typeof apikeyCreate>>;
|
|
77
|
+
try {
|
|
78
|
+
result = await tui.spinner('Creating API key', () => {
|
|
79
|
+
return apikeyCreate(apiClient, {
|
|
80
|
+
name: opts.name,
|
|
81
|
+
expiresAt: expiresAt,
|
|
82
|
+
projectId: projectId,
|
|
83
|
+
orgId: orgId,
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
} catch (error) {
|
|
87
|
+
if (error instanceof Error) {
|
|
88
|
+
tui.fatal(error.message);
|
|
89
|
+
}
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (!options.json) {
|
|
94
|
+
tui.newline();
|
|
95
|
+
tui.success('API key created successfully!');
|
|
96
|
+
tui.newline();
|
|
97
|
+
tui.warn('Make sure to copy the API key value now. You will not be able to see it again.');
|
|
98
|
+
tui.newline();
|
|
99
|
+
|
|
100
|
+
const rows = [
|
|
101
|
+
{
|
|
102
|
+
ID: result.id,
|
|
103
|
+
Name: opts.name,
|
|
104
|
+
Value: result.value,
|
|
105
|
+
'Expires At': expiresAt,
|
|
106
|
+
},
|
|
107
|
+
];
|
|
108
|
+
|
|
109
|
+
tui.table(rows);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return result;
|
|
113
|
+
},
|
|
114
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createSubcommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { apikeyDelete } from '@agentuity/server';
|
|
5
|
+
import { getCommand } from '../../../command-prefix';
|
|
6
|
+
import { ErrorCode } from '../../../errors';
|
|
7
|
+
|
|
8
|
+
const APIKeyDeleteResponseSchema = z.object({
|
|
9
|
+
success: z.boolean().describe('Whether the operation succeeded'),
|
|
10
|
+
id: z.string().describe('API key id that was deleted'),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const deleteSubcommand = createSubcommand({
|
|
14
|
+
name: 'delete',
|
|
15
|
+
aliases: ['del', 'rm'],
|
|
16
|
+
description: 'Delete an API key (soft delete)',
|
|
17
|
+
tags: ['destructive', 'deletes-resource', 'slow', 'requires-auth'],
|
|
18
|
+
idempotent: true,
|
|
19
|
+
examples: [
|
|
20
|
+
getCommand('cloud apikey delete <id>'),
|
|
21
|
+
getCommand('cloud apikey del <id>'),
|
|
22
|
+
getCommand('cloud apikey rm <id>'),
|
|
23
|
+
],
|
|
24
|
+
requires: { auth: true, apiClient: true },
|
|
25
|
+
schema: {
|
|
26
|
+
args: z.object({
|
|
27
|
+
id: z.string().describe('the API key id to delete'),
|
|
28
|
+
}),
|
|
29
|
+
response: APIKeyDeleteResponseSchema,
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
async handler(ctx) {
|
|
33
|
+
const { args, apiClient, options } = ctx;
|
|
34
|
+
|
|
35
|
+
let rowsAffected: Awaited<ReturnType<typeof apikeyDelete>>;
|
|
36
|
+
try {
|
|
37
|
+
rowsAffected = await tui.spinner('Deleting API key', () => {
|
|
38
|
+
return apikeyDelete(apiClient, args.id);
|
|
39
|
+
});
|
|
40
|
+
} catch (error) {
|
|
41
|
+
if (error instanceof Error && error.message.includes('not found')) {
|
|
42
|
+
tui.fatal(
|
|
43
|
+
`API key '${args.id}' not found or is not a custom key`,
|
|
44
|
+
ErrorCode.RESOURCE_NOT_FOUND
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (rowsAffected === 0) {
|
|
51
|
+
tui.fatal(
|
|
52
|
+
`API key '${args.id}' not found or is not a custom key`,
|
|
53
|
+
ErrorCode.RESOURCE_NOT_FOUND
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!options.json) {
|
|
58
|
+
tui.success(`API key '${args.id}' deleted successfully`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
success: true,
|
|
63
|
+
id: args.id,
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createSubcommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { apikeyGet } from '@agentuity/server';
|
|
5
|
+
import { getCommand } from '../../../command-prefix';
|
|
6
|
+
import { ErrorCode } from '../../../errors';
|
|
7
|
+
|
|
8
|
+
export const getSubcommand = createSubcommand({
|
|
9
|
+
name: 'get',
|
|
10
|
+
description: 'Get a specific API key by id',
|
|
11
|
+
tags: ['read-only', 'fast', 'requires-auth'],
|
|
12
|
+
examples: [getCommand('cloud apikey get <id>')],
|
|
13
|
+
requires: { auth: true, apiClient: true },
|
|
14
|
+
idempotent: true,
|
|
15
|
+
schema: {
|
|
16
|
+
args: z.object({
|
|
17
|
+
id: z.string().describe('the API key id'),
|
|
18
|
+
}),
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
async handler(ctx) {
|
|
22
|
+
const { args, apiClient, options } = ctx;
|
|
23
|
+
|
|
24
|
+
let apiKey: Awaited<ReturnType<typeof apikeyGet>>;
|
|
25
|
+
try {
|
|
26
|
+
apiKey = await tui.spinner('Fetching API key', () => {
|
|
27
|
+
return apikeyGet(apiClient, args.id);
|
|
28
|
+
});
|
|
29
|
+
} catch (error) {
|
|
30
|
+
if (error instanceof Error && error.message.includes('not found')) {
|
|
31
|
+
tui.fatal(`API key '${args.id}' not found`, ErrorCode.RESOURCE_NOT_FOUND);
|
|
32
|
+
}
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!options.json) {
|
|
37
|
+
if (process.stdout.isTTY) {
|
|
38
|
+
tui.newline();
|
|
39
|
+
tui.success('API Key Details:');
|
|
40
|
+
tui.newline();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const rows = [
|
|
44
|
+
{
|
|
45
|
+
ID: apiKey.id,
|
|
46
|
+
Name: apiKey.name,
|
|
47
|
+
Type: apiKey.type,
|
|
48
|
+
'Organization ID': apiKey.orgId,
|
|
49
|
+
Project: apiKey.project?.name ?? '-',
|
|
50
|
+
'Project ID': apiKey.project?.id ?? '-',
|
|
51
|
+
'Last Used': apiKey.lastUsedAt || 'Never',
|
|
52
|
+
'Expires At': apiKey.expiresAt ?? 'Never',
|
|
53
|
+
'Created At': apiKey.createdAt,
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
tui.table(rows);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return apiKey;
|
|
61
|
+
},
|
|
62
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createCommand } from '../../../types';
|
|
2
|
+
import { createSubcommand } from './create';
|
|
3
|
+
import { listSubcommand } from './list';
|
|
4
|
+
import { getSubcommand } from './get';
|
|
5
|
+
import { deleteSubcommand } from './delete';
|
|
6
|
+
|
|
7
|
+
export const command = createCommand({
|
|
8
|
+
name: 'apikey',
|
|
9
|
+
description: 'Manage API keys',
|
|
10
|
+
tags: ['fast', 'requires-auth'],
|
|
11
|
+
subcommands: [createSubcommand, listSubcommand, getSubcommand, deleteSubcommand],
|
|
12
|
+
});
|
|
13
|
+
export default command;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createSubcommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { apikeyList } from '@agentuity/server';
|
|
5
|
+
import { getCommand } from '../../../command-prefix';
|
|
6
|
+
|
|
7
|
+
export const listSubcommand = createSubcommand({
|
|
8
|
+
name: 'list',
|
|
9
|
+
aliases: ['ls'],
|
|
10
|
+
description: 'List all API keys',
|
|
11
|
+
tags: ['read-only', 'fast', 'requires-auth'],
|
|
12
|
+
examples: [getCommand('cloud apikey list'), getCommand('cloud apikey ls')],
|
|
13
|
+
requires: { auth: true, apiClient: true },
|
|
14
|
+
idempotent: true,
|
|
15
|
+
schema: {
|
|
16
|
+
options: z.object({
|
|
17
|
+
orgId: z.string().optional().describe('filter by organization id'),
|
|
18
|
+
projectId: z.string().optional().describe('filter by project id'),
|
|
19
|
+
}),
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
async handler(ctx) {
|
|
23
|
+
const { opts, apiClient, options } = ctx;
|
|
24
|
+
|
|
25
|
+
const apiKeys = await tui.spinner('Fetching API keys', () => {
|
|
26
|
+
return apikeyList(apiClient, {
|
|
27
|
+
orgId: opts?.orgId,
|
|
28
|
+
projectId: opts?.projectId,
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (!options.json) {
|
|
33
|
+
if (apiKeys.length === 0) {
|
|
34
|
+
tui.info('No API keys found');
|
|
35
|
+
} else {
|
|
36
|
+
if (process.stdout.isTTY) {
|
|
37
|
+
tui.newline();
|
|
38
|
+
tui.success(`API Keys (${apiKeys.length}):`);
|
|
39
|
+
tui.newline();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const rows = apiKeys.map((key) => ({
|
|
43
|
+
ID: key.id,
|
|
44
|
+
Name: key.name,
|
|
45
|
+
Type: key.type,
|
|
46
|
+
Project: key.project?.name ?? '-',
|
|
47
|
+
'Last Used': key.lastUsedAt || 'Never',
|
|
48
|
+
'Expires At': key.expiresAt ?? 'Never',
|
|
49
|
+
'Created At': key.createdAt,
|
|
50
|
+
}));
|
|
51
|
+
|
|
52
|
+
tui.table(rows);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return apiKeys;
|
|
57
|
+
},
|
|
58
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createCommand } from '../../../types';
|
|
2
2
|
import { listSubcommand } from './list';
|
|
3
|
+
import { logsSubcommand } from './logs';
|
|
3
4
|
import { showSubcommand } from './show';
|
|
4
5
|
import { removeSubcommand } from './remove';
|
|
5
6
|
import { rollbackSubcommand } from './rollback';
|
|
@@ -12,6 +13,7 @@ export const deploymentCommand = createCommand({
|
|
|
12
13
|
aliases: ['deployments', 'dep'],
|
|
13
14
|
subcommands: [
|
|
14
15
|
listSubcommand,
|
|
16
|
+
logsSubcommand,
|
|
15
17
|
showSubcommand,
|
|
16
18
|
removeSubcommand,
|
|
17
19
|
rollbackSubcommand,
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createSubcommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { projectDeploymentLogs, DeploymentLogSchema } from '@agentuity/server';
|
|
5
|
+
import { resolveProjectId } from './utils';
|
|
6
|
+
import { getCommand } from '../../../command-prefix';
|
|
7
|
+
import { ErrorCode } from '../../../errors';
|
|
8
|
+
|
|
9
|
+
export const logsSubcommand = createSubcommand({
|
|
10
|
+
name: 'logs',
|
|
11
|
+
aliases: ['log'],
|
|
12
|
+
description: 'View logs for a specific deployment',
|
|
13
|
+
tags: ['read-only', 'fast', 'requires-auth', 'requires-deployment'],
|
|
14
|
+
examples: [
|
|
15
|
+
`${getCommand('cloud deployment logs')} deploy_abc123xyz`,
|
|
16
|
+
`${getCommand('cloud deployment logs')} deploy_abc123xyz --limit=50`,
|
|
17
|
+
`${getCommand('cloud deployment logs')} deploy_abc123xyz --no-timestamps # hide timestamps`,
|
|
18
|
+
`${getCommand('cloud deployment logs')} deploy_abc123xyz --project-id=proj_abc123xyz`,
|
|
19
|
+
],
|
|
20
|
+
requires: { auth: true, apiClient: true },
|
|
21
|
+
optional: { project: true },
|
|
22
|
+
prerequisites: ['cloud deploy'],
|
|
23
|
+
schema: {
|
|
24
|
+
args: z.object({
|
|
25
|
+
deployment_id: z.string().describe('Deployment ID'),
|
|
26
|
+
}),
|
|
27
|
+
options: z.object({
|
|
28
|
+
projectId: z.string().optional().describe('Project ID'),
|
|
29
|
+
limit: z.coerce
|
|
30
|
+
.number()
|
|
31
|
+
.int()
|
|
32
|
+
.min(1)
|
|
33
|
+
.default(100)
|
|
34
|
+
.describe('Maximum number of logs to return'),
|
|
35
|
+
timestamps: z.boolean().default(true).describe('Show timestamps in output'),
|
|
36
|
+
}),
|
|
37
|
+
response: z.array(DeploymentLogSchema),
|
|
38
|
+
},
|
|
39
|
+
idempotent: true,
|
|
40
|
+
async handler(ctx) {
|
|
41
|
+
const { apiClient, args, options } = ctx;
|
|
42
|
+
const limit = ctx.opts.limit;
|
|
43
|
+
const showTimestamps = ctx.opts.timestamps;
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
const projectId = resolveProjectId(ctx, { projectId: ctx.opts.projectId });
|
|
47
|
+
const logs = await projectDeploymentLogs(apiClient, projectId, args.deployment_id, limit);
|
|
48
|
+
|
|
49
|
+
if (!options.json) {
|
|
50
|
+
if (logs.length === 0) {
|
|
51
|
+
tui.info('No logs found for this deployment');
|
|
52
|
+
} else {
|
|
53
|
+
for (const log of logs) {
|
|
54
|
+
const severityColor = tui.getSeverityColor(log.severity);
|
|
55
|
+
if (showTimestamps) {
|
|
56
|
+
const timestamp = new Date(log.timestamp).toLocaleString();
|
|
57
|
+
console.log(
|
|
58
|
+
`${tui.muted(timestamp)} ${severityColor(log.severity.padEnd(5))} ${log.body}`
|
|
59
|
+
);
|
|
60
|
+
} else {
|
|
61
|
+
console.log(`${severityColor(log.severity.padEnd(5))} ${log.body}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return logs;
|
|
68
|
+
} catch (ex) {
|
|
69
|
+
tui.fatal(
|
|
70
|
+
`Failed to fetch deployment logs: ${ex instanceof Error ? ex.message : String(ex)}`,
|
|
71
|
+
ErrorCode.API_ERROR
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
});
|
package/src/cmd/cloud/index.ts
CHANGED
|
@@ -6,19 +6,25 @@ import { sshSubcommand } from './ssh';
|
|
|
6
6
|
import { scpSubcommand } from './scp';
|
|
7
7
|
import { deploymentCommand } from './deployment';
|
|
8
8
|
import keyvalueCommand from './keyvalue';
|
|
9
|
-
import
|
|
9
|
+
import { agentCommand } from './agent';
|
|
10
10
|
import objectstoreCommand from './objectstore';
|
|
11
11
|
import envCommand from './env';
|
|
12
12
|
import secretCommand from './secret';
|
|
13
|
+
import apikeyCommand from './apikey';
|
|
14
|
+
import streamCommand from './stream';
|
|
15
|
+
import vectorCommand from './vector';
|
|
13
16
|
|
|
14
17
|
export const command = createCommand({
|
|
15
18
|
name: 'cloud',
|
|
16
19
|
description: 'Cloud related commands',
|
|
17
20
|
tags: ['slow', 'requires-auth'],
|
|
18
21
|
subcommands: [
|
|
22
|
+
apikeyCommand,
|
|
19
23
|
keyvalueCommand,
|
|
20
|
-
|
|
24
|
+
agentCommand,
|
|
21
25
|
objectstoreCommand,
|
|
26
|
+
streamCommand,
|
|
27
|
+
vectorCommand,
|
|
22
28
|
envCommand,
|
|
23
29
|
secretCommand,
|
|
24
30
|
deploySubcommand,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { createSubcommand } from '../../../types';
|
|
3
3
|
import * as tui from '../../../tui';
|
|
4
|
-
import { sessionGet, type SpanNode } from '@agentuity/server';
|
|
4
|
+
import { sessionGet, type SpanNode, type EvalRun, type AgentInfo } from '@agentuity/server';
|
|
5
5
|
import { getCommand } from '../../../command-prefix';
|
|
6
6
|
import { ErrorCode } from '../../../errors';
|
|
7
7
|
import { getCatalystAPIClient } from '../../../config';
|
|
@@ -95,7 +95,7 @@ function printTimeline(node: SpanNode, prefix: string, isLast = true): void {
|
|
|
95
95
|
|
|
96
96
|
const childPrefix = prefix + (isLast ? ' ' : '│ ');
|
|
97
97
|
const children = node.children ?? [];
|
|
98
|
-
children.forEach((child, index) => {
|
|
98
|
+
children.forEach((child: SpanNode, index: number) => {
|
|
99
99
|
printTimeline(child, childPrefix, index === children.length - 1);
|
|
100
100
|
});
|
|
101
101
|
}
|
|
@@ -142,7 +142,7 @@ export const getSubcommand = createSubcommand({
|
|
|
142
142
|
route_id: session.route_id,
|
|
143
143
|
thread_id: session.thread_id,
|
|
144
144
|
agents: enriched.agents,
|
|
145
|
-
eval_runs: enriched.evalRuns.map((run) => ({
|
|
145
|
+
eval_runs: enriched.evalRuns.map((run: EvalRun) => ({
|
|
146
146
|
id: run.id,
|
|
147
147
|
eval_id: run.eval_id,
|
|
148
148
|
created_at: run.created_at,
|
|
@@ -189,7 +189,7 @@ export const getSubcommand = createSubcommand({
|
|
|
189
189
|
}
|
|
190
190
|
if (enriched.agents.length > 0) {
|
|
191
191
|
const agentDisplay = enriched.agents
|
|
192
|
-
.map((agent) => `${agent.name} ${tui.muted(`(${agent.identifier})`)}`)
|
|
192
|
+
.map((agent: AgentInfo) => `${agent.name} ${tui.muted(`(${agent.identifier})`)}`)
|
|
193
193
|
.join(', ');
|
|
194
194
|
console.log(tui.bold('Agents: ') + agentDisplay);
|
|
195
195
|
}
|
|
@@ -206,7 +206,7 @@ export const getSubcommand = createSubcommand({
|
|
|
206
206
|
if (enriched.evalRuns.length > 0) {
|
|
207
207
|
console.log('');
|
|
208
208
|
console.log(tui.bold('Eval Runs:'));
|
|
209
|
-
const evalTableData = enriched.evalRuns.map((run) => ({
|
|
209
|
+
const evalTableData = enriched.evalRuns.map((run: EvalRun) => ({
|
|
210
210
|
ID: run.id,
|
|
211
211
|
'Eval ID': run.eval_id,
|
|
212
212
|
Success: run.success ? tui.colorSuccess('✓') : tui.colorError('✗'),
|
|
@@ -15,9 +15,13 @@ const SessionLogsResponseSchema = z.array(
|
|
|
15
15
|
|
|
16
16
|
export const logsSubcommand = createSubcommand({
|
|
17
17
|
name: 'logs',
|
|
18
|
+
aliases: ['log'],
|
|
18
19
|
description: 'Get logs for a specific session',
|
|
19
20
|
tags: ['read-only', 'slow', 'requires-auth'],
|
|
20
|
-
examples: [
|
|
21
|
+
examples: [
|
|
22
|
+
`${getCommand('cloud session logs')} sess_abc123xyz`,
|
|
23
|
+
`${getCommand('cloud session logs')} --no-timestamps # hide timestamps`,
|
|
24
|
+
],
|
|
21
25
|
requires: { auth: true, apiClient: true },
|
|
22
26
|
optional: { project: true },
|
|
23
27
|
idempotent: true,
|
|
@@ -28,11 +32,13 @@ export const logsSubcommand = createSubcommand({
|
|
|
28
32
|
options: z.object({
|
|
29
33
|
projectId: z.string().optional().describe('Project ID (for display purposes)'),
|
|
30
34
|
deploymentId: z.string().optional().describe('Deployment ID (for display purposes)'),
|
|
35
|
+
timestamps: z.boolean().default(true).describe('Show timestamps in output'),
|
|
31
36
|
}),
|
|
32
37
|
response: SessionLogsResponseSchema,
|
|
33
38
|
},
|
|
34
39
|
async handler(ctx) {
|
|
35
40
|
const { apiClient, args, options } = ctx;
|
|
41
|
+
const showTimestamps = ctx.opts.timestamps ?? true;
|
|
36
42
|
|
|
37
43
|
try {
|
|
38
44
|
const logs = await sessionLogs(apiClient, { id: args.session_id });
|
|
@@ -41,19 +47,14 @@ export const logsSubcommand = createSubcommand({
|
|
|
41
47
|
if (logs.length === 0) {
|
|
42
48
|
tui.info('No logs found for this session.');
|
|
43
49
|
} else {
|
|
44
|
-
tui.banner(`Logs for Session ${args.session_id}`, `${logs.length} log entries`);
|
|
45
|
-
|
|
46
50
|
for (const log of logs) {
|
|
47
|
-
const timestamp =
|
|
51
|
+
const timestamp = showTimestamps
|
|
52
|
+
? `${tui.muted(new Date(log.timestamp).toLocaleTimeString())} `
|
|
53
|
+
: '';
|
|
48
54
|
const severity = log.severity.padEnd(5);
|
|
49
|
-
const severityColor =
|
|
50
|
-
log.severity === 'ERROR'
|
|
51
|
-
? tui.error(severity)
|
|
52
|
-
: log.severity === 'WARN'
|
|
53
|
-
? tui.warning(severity)
|
|
54
|
-
: tui.muted(severity);
|
|
55
|
+
const severityColor = tui.getSeverityColor(log.severity)(severity);
|
|
55
56
|
|
|
56
|
-
console.log(`${
|
|
57
|
+
console.log(`${timestamp}${severityColor} ${log.body}`);
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
}
|