@agentuity/cli 0.0.48 → 0.0.50
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/bin/cli.ts +26 -5
- package/dist/banner.d.ts +1 -1
- package/dist/banner.d.ts.map +1 -1
- package/dist/cli-logger.d.ts +27 -0
- package/dist/cli-logger.d.ts.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cmd/agents/index.d.ts +2 -0
- package/dist/cmd/agents/index.d.ts.map +1 -0
- package/dist/cmd/auth/index.d.ts.map +1 -1
- package/dist/cmd/auth/login.d.ts.map +1 -1
- package/dist/cmd/auth/logout.d.ts.map +1 -1
- package/dist/cmd/auth/signup.d.ts.map +1 -1
- package/dist/cmd/auth/ssh/add.d.ts.map +1 -1
- package/dist/cmd/auth/ssh/delete.d.ts.map +1 -1
- package/dist/cmd/auth/ssh/index.d.ts +1 -2
- package/dist/cmd/auth/ssh/index.d.ts.map +1 -1
- package/dist/cmd/auth/ssh/list.d.ts.map +1 -1
- package/dist/cmd/auth/whoami.d.ts.map +1 -1
- package/dist/cmd/bundle/ast.d.ts +3 -1
- package/dist/cmd/bundle/ast.d.ts.map +1 -1
- package/dist/cmd/bundle/index.d.ts.map +1 -1
- package/dist/cmd/bundle/plugin.d.ts.map +1 -1
- package/dist/cmd/capabilities/index.d.ts +4 -0
- package/dist/cmd/capabilities/index.d.ts.map +1 -0
- package/dist/cmd/capabilities/show.d.ts +20 -0
- package/dist/cmd/capabilities/show.d.ts.map +1 -0
- package/dist/cmd/cloud/deploy.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/index.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/list.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/remove.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/rollback.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/show.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/undeploy.d.ts.map +1 -1
- package/dist/cmd/cloud/deployment/utils.d.ts +4 -2
- package/dist/cmd/cloud/deployment/utils.d.ts.map +1 -1
- package/dist/cmd/cloud/domain.d.ts.map +1 -1
- package/dist/cmd/cloud/index.d.ts.map +1 -1
- package/dist/cmd/cloud/resource/add.d.ts.map +1 -1
- package/dist/cmd/cloud/resource/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/resource/index.d.ts +1 -2
- package/dist/cmd/cloud/resource/index.d.ts.map +1 -1
- package/dist/cmd/cloud/resource/list.d.ts.map +1 -1
- package/dist/cmd/cloud/scp/download.d.ts.map +1 -1
- package/dist/cmd/cloud/scp/index.d.ts +1 -2
- package/dist/cmd/cloud/scp/index.d.ts.map +1 -1
- package/dist/cmd/cloud/scp/upload.d.ts.map +1 -1
- package/dist/cmd/cloud/session/get.d.ts +2 -0
- package/dist/cmd/cloud/session/get.d.ts.map +1 -0
- package/dist/cmd/cloud/session/index.d.ts +2 -0
- package/dist/cmd/cloud/session/index.d.ts.map +1 -0
- package/dist/cmd/cloud/session/list.d.ts +2 -0
- package/dist/cmd/cloud/session/list.d.ts.map +1 -0
- package/dist/cmd/cloud/session/logs.d.ts +2 -0
- package/dist/cmd/cloud/session/logs.d.ts.map +1 -0
- package/dist/cmd/cloud/ssh.d.ts.map +1 -1
- package/dist/cmd/dev/agents.d.ts +2 -0
- package/dist/cmd/dev/agents.d.ts.map +1 -0
- package/dist/cmd/dev/index.d.ts.map +1 -1
- package/dist/cmd/dev/sync.d.ts +12 -0
- package/dist/cmd/dev/sync.d.ts.map +1 -0
- package/dist/cmd/env/delete.d.ts.map +1 -1
- package/dist/cmd/env/get.d.ts.map +1 -1
- package/dist/cmd/env/import.d.ts.map +1 -1
- package/dist/cmd/env/index.d.ts.map +1 -1
- package/dist/cmd/env/list.d.ts.map +1 -1
- package/dist/cmd/env/pull.d.ts.map +1 -1
- package/dist/cmd/env/push.d.ts.map +1 -1
- package/dist/cmd/env/set.d.ts.map +1 -1
- package/dist/cmd/index.d.ts.map +1 -1
- package/dist/cmd/kv/create-namespace.d.ts +3 -0
- package/dist/cmd/kv/create-namespace.d.ts.map +1 -0
- package/dist/cmd/kv/delete-namespace.d.ts +3 -0
- package/dist/cmd/kv/delete-namespace.d.ts.map +1 -0
- package/dist/cmd/kv/delete.d.ts +3 -0
- package/dist/cmd/kv/delete.d.ts.map +1 -0
- package/dist/cmd/kv/get.d.ts +3 -0
- package/dist/cmd/kv/get.d.ts.map +1 -0
- package/dist/cmd/kv/index.d.ts +2 -0
- package/dist/cmd/kv/index.d.ts.map +1 -0
- package/dist/cmd/kv/keys.d.ts +3 -0
- package/dist/cmd/kv/keys.d.ts.map +1 -0
- package/dist/cmd/kv/list-namespaces.d.ts +3 -0
- package/dist/cmd/kv/list-namespaces.d.ts.map +1 -0
- package/dist/cmd/kv/repl.d.ts +3 -0
- package/dist/cmd/kv/repl.d.ts.map +1 -0
- package/dist/cmd/kv/search.d.ts +3 -0
- package/dist/cmd/kv/search.d.ts.map +1 -0
- package/dist/cmd/kv/set.d.ts +3 -0
- package/dist/cmd/kv/set.d.ts.map +1 -0
- package/dist/cmd/kv/stats.d.ts +3 -0
- package/dist/cmd/kv/stats.d.ts.map +1 -0
- package/dist/cmd/kv/util.d.ts +8 -0
- package/dist/cmd/kv/util.d.ts.map +1 -0
- package/dist/cmd/objectstore/delete-bucket.d.ts +3 -0
- package/dist/cmd/objectstore/delete-bucket.d.ts.map +1 -0
- package/dist/cmd/objectstore/delete.d.ts +3 -0
- package/dist/cmd/objectstore/delete.d.ts.map +1 -0
- package/dist/cmd/objectstore/get.d.ts +3 -0
- package/dist/cmd/objectstore/get.d.ts.map +1 -0
- package/dist/cmd/objectstore/index.d.ts +2 -0
- package/dist/cmd/objectstore/index.d.ts.map +1 -0
- package/dist/cmd/objectstore/list-buckets.d.ts +3 -0
- package/dist/cmd/objectstore/list-buckets.d.ts.map +1 -0
- package/dist/cmd/objectstore/list-keys.d.ts +3 -0
- package/dist/cmd/objectstore/list-keys.d.ts.map +1 -0
- package/dist/cmd/objectstore/put.d.ts +3 -0
- package/dist/cmd/objectstore/put.d.ts.map +1 -0
- package/dist/cmd/objectstore/repl.d.ts +3 -0
- package/dist/cmd/objectstore/repl.d.ts.map +1 -0
- package/dist/cmd/objectstore/url.d.ts +3 -0
- package/dist/cmd/objectstore/url.d.ts.map +1 -0
- package/dist/cmd/objectstore/util.d.ts +8 -0
- package/dist/cmd/objectstore/util.d.ts.map +1 -0
- package/dist/cmd/profile/create.d.ts.map +1 -1
- package/dist/cmd/profile/delete.d.ts.map +1 -1
- package/dist/cmd/profile/index.d.ts.map +1 -1
- package/dist/cmd/profile/list.d.ts +1 -2
- package/dist/cmd/profile/list.d.ts.map +1 -1
- package/dist/cmd/profile/show.d.ts.map +1 -1
- package/dist/cmd/profile/use.d.ts.map +1 -1
- package/dist/cmd/project/create.d.ts.map +1 -1
- package/dist/cmd/project/delete.d.ts.map +1 -1
- package/dist/cmd/project/index.d.ts.map +1 -1
- package/dist/cmd/project/list.d.ts.map +1 -1
- package/dist/cmd/project/show.d.ts.map +1 -1
- package/dist/cmd/project/template-flow.d.ts +1 -1
- package/dist/cmd/project/template-flow.d.ts.map +1 -1
- package/dist/cmd/prompt/index.d.ts +4 -0
- package/dist/cmd/prompt/index.d.ts.map +1 -0
- package/dist/cmd/prompt/llm.d.ts +3 -0
- package/dist/cmd/prompt/llm.d.ts.map +1 -0
- package/dist/cmd/repl/index.d.ts +3 -0
- package/dist/cmd/repl/index.d.ts.map +1 -0
- package/dist/cmd/schema/index.d.ts +4 -0
- package/dist/cmd/schema/index.d.ts.map +1 -0
- package/dist/cmd/schema/show.d.ts +3 -0
- package/dist/cmd/schema/show.d.ts.map +1 -0
- package/dist/cmd/secret/delete.d.ts.map +1 -1
- package/dist/cmd/secret/get.d.ts.map +1 -1
- package/dist/cmd/secret/import.d.ts.map +1 -1
- package/dist/cmd/secret/index.d.ts.map +1 -1
- package/dist/cmd/secret/list.d.ts.map +1 -1
- package/dist/cmd/secret/pull.d.ts.map +1 -1
- package/dist/cmd/secret/push.d.ts.map +1 -1
- package/dist/cmd/secret/set.d.ts.map +1 -1
- package/dist/cmd/version/index.d.ts.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/errors.d.ts +83 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/explain.d.ts +47 -0
- package/dist/explain.d.ts.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/json.d.ts +3 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/output.d.ts +136 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/repl.d.ts +120 -0
- package/dist/repl.d.ts.map +1 -0
- package/dist/schema-generator.d.ts +67 -0
- package/dist/schema-generator.d.ts.map +1 -0
- package/dist/tui.d.ts +35 -1
- package/dist/tui.d.ts.map +1 -1
- package/dist/types.d.ts +77 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/format.d.ts +9 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/package.json +12 -4
- package/src/banner.ts +7 -7
- package/src/cli-logger.ts +80 -0
- package/src/cli.ts +192 -58
- package/src/cmd/agents/index.ts +147 -0
- package/src/cmd/auth/index.ts +1 -0
- package/src/cmd/auth/login.ts +7 -2
- package/src/cmd/auth/logout.ts +4 -0
- package/src/cmd/auth/signup.ts +7 -2
- package/src/cmd/auth/ssh/add.ts +20 -3
- package/src/cmd/auth/ssh/delete.ts +57 -4
- package/src/cmd/auth/ssh/index.ts +4 -3
- package/src/cmd/auth/ssh/list.ts +38 -27
- package/src/cmd/auth/whoami.ts +32 -21
- package/src/cmd/bundle/ast.test.ts +2 -2
- package/src/cmd/bundle/ast.ts +112 -22
- package/src/cmd/bundle/index.ts +20 -0
- package/src/cmd/bundle/plugin.ts +60 -14
- package/src/cmd/capabilities/index.ts +12 -0
- package/src/cmd/capabilities/show.ts +256 -0
- package/src/cmd/cloud/deploy.ts +54 -0
- package/src/cmd/cloud/deployment/index.ts +1 -0
- package/src/cmd/cloud/deployment/list.ts +66 -25
- package/src/cmd/cloud/deployment/remove.ts +26 -2
- package/src/cmd/cloud/deployment/rollback.ts +35 -4
- package/src/cmd/cloud/deployment/show.ts +37 -2
- package/src/cmd/cloud/deployment/undeploy.ts +12 -1
- package/src/cmd/cloud/deployment/utils.ts +5 -2
- package/src/cmd/cloud/domain.ts +3 -2
- package/src/cmd/cloud/index.ts +10 -1
- package/src/cmd/cloud/resource/add.ts +19 -0
- package/src/cmd/cloud/resource/delete.ts +24 -3
- package/src/cmd/cloud/resource/index.ts +4 -3
- package/src/cmd/cloud/resource/list.ts +36 -10
- package/src/cmd/cloud/scp/download.ts +27 -1
- package/src/cmd/cloud/scp/index.ts +4 -3
- package/src/cmd/cloud/scp/upload.ts +27 -1
- package/src/cmd/cloud/session/get.ts +164 -0
- package/src/cmd/cloud/session/index.ts +11 -0
- package/src/cmd/cloud/session/list.ts +145 -0
- package/src/cmd/cloud/session/logs.ts +68 -0
- package/src/cmd/cloud/ssh.ts +12 -0
- package/src/cmd/dev/agents.ts +122 -0
- package/src/cmd/dev/index.ts +106 -8
- package/src/cmd/dev/sync.ts +414 -0
- package/src/cmd/dev/templates.ts +1 -1
- package/src/cmd/env/delete.ts +17 -0
- package/src/cmd/env/get.ts +17 -1
- package/src/cmd/env/import.ts +47 -3
- package/src/cmd/env/index.ts +1 -0
- package/src/cmd/env/list.ts +13 -1
- package/src/cmd/env/pull.ts +20 -0
- package/src/cmd/env/push.ts +33 -1
- package/src/cmd/env/set.ts +25 -1
- package/src/cmd/index.ts +9 -2
- package/src/cmd/kv/create-namespace.ts +45 -0
- package/src/cmd/kv/delete-namespace.ts +73 -0
- package/src/cmd/kv/delete.ts +51 -0
- package/src/cmd/kv/get.ts +65 -0
- package/src/cmd/kv/index.ts +31 -0
- package/src/cmd/kv/keys.ts +57 -0
- package/src/cmd/kv/list-namespaces.ts +43 -0
- package/src/cmd/kv/repl.ts +284 -0
- package/src/cmd/kv/search.ts +80 -0
- package/src/cmd/kv/set.ts +63 -0
- package/src/cmd/kv/stats.ts +96 -0
- package/src/cmd/kv/util.ts +32 -0
- package/src/cmd/objectstore/delete-bucket.ts +72 -0
- package/src/cmd/objectstore/delete.ts +59 -0
- package/src/cmd/objectstore/get.ts +64 -0
- package/src/cmd/objectstore/index.ts +27 -0
- package/src/cmd/objectstore/list-buckets.ts +45 -0
- package/src/cmd/objectstore/list-keys.ts +60 -0
- package/src/cmd/objectstore/put.ts +62 -0
- package/src/cmd/objectstore/repl.ts +235 -0
- package/src/cmd/objectstore/url.ts +59 -0
- package/src/cmd/objectstore/util.ts +28 -0
- package/src/cmd/profile/create.ts +28 -2
- package/src/cmd/profile/delete.ts +17 -2
- package/src/cmd/profile/index.ts +1 -0
- package/src/cmd/profile/list.ts +7 -3
- package/src/cmd/profile/show.ts +20 -5
- package/src/cmd/profile/use.ts +8 -0
- package/src/cmd/project/create.ts +31 -0
- package/src/cmd/project/delete.ts +24 -2
- package/src/cmd/project/index.ts +1 -0
- package/src/cmd/project/list.ts +24 -10
- package/src/cmd/project/show.ts +28 -9
- package/src/cmd/project/template-flow.ts +10 -6
- package/src/cmd/prompt/index.ts +12 -0
- package/src/cmd/prompt/llm.ts +368 -0
- package/src/cmd/repl/index.ts +477 -0
- package/src/cmd/schema/index.ts +12 -0
- package/src/cmd/schema/show.ts +27 -0
- package/src/cmd/secret/delete.ts +17 -0
- package/src/cmd/secret/get.ts +20 -1
- package/src/cmd/secret/import.ts +45 -2
- package/src/cmd/secret/index.ts +1 -0
- package/src/cmd/secret/list.ts +10 -1
- package/src/cmd/secret/pull.ts +20 -0
- package/src/cmd/secret/push.ts +33 -1
- package/src/cmd/secret/set.ts +20 -0
- package/src/cmd/version/index.ts +15 -2
- package/src/config.ts +17 -4
- package/src/errors.ts +222 -0
- package/src/explain.ts +126 -0
- package/src/index.ts +51 -0
- package/src/json.ts +28 -0
- package/src/output.ts +307 -0
- package/src/repl.ts +1507 -0
- package/src/schema-generator.ts +389 -0
- package/src/tui.ts +178 -13
- package/src/types.ts +75 -22
- package/src/utils/format.ts +17 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createSubcommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { sessionGet } from '@agentuity/server';
|
|
5
|
+
import { getCommand } from '../../../command-prefix';
|
|
6
|
+
import { ErrorCode } from '../../../errors';
|
|
7
|
+
import { getCatalystAPIClient } from '../../../config';
|
|
8
|
+
|
|
9
|
+
const SessionGetResponseSchema = z.object({
|
|
10
|
+
id: z.string().describe('Session ID'),
|
|
11
|
+
created_at: z.string().describe('Creation timestamp'),
|
|
12
|
+
start_time: z.string().describe('Start time'),
|
|
13
|
+
end_time: z.string().nullable().describe('End time'),
|
|
14
|
+
duration: z.number().nullable().describe('Duration in nanoseconds'),
|
|
15
|
+
org_id: z.string().describe('Organization ID'),
|
|
16
|
+
project_id: z.string().describe('Project ID'),
|
|
17
|
+
deployment_id: z.string().describe('Deployment ID'),
|
|
18
|
+
agent_ids: z.array(z.string()).describe('Agent IDs'),
|
|
19
|
+
trigger: z.string().describe('Trigger type'),
|
|
20
|
+
env: z.string().describe('Environment'),
|
|
21
|
+
devmode: z.boolean().describe('Dev mode'),
|
|
22
|
+
pending: z.boolean().describe('Pending'),
|
|
23
|
+
success: z.boolean().describe('Success'),
|
|
24
|
+
error: z.string().nullable().describe('Error message'),
|
|
25
|
+
method: z.string().describe('HTTP method'),
|
|
26
|
+
url: z.string().describe('Request URL'),
|
|
27
|
+
route_id: z.string().describe('Route ID'),
|
|
28
|
+
thread_id: z.string().describe('Thread ID'),
|
|
29
|
+
agentNames: z.array(z.string()).describe('Agent names'),
|
|
30
|
+
evalRuns: z.array(z.object({
|
|
31
|
+
id: z.string(),
|
|
32
|
+
created_at: z.string(),
|
|
33
|
+
eval_id: z.string(),
|
|
34
|
+
pending: z.boolean(),
|
|
35
|
+
success: z.boolean(),
|
|
36
|
+
error: z.string().nullable(),
|
|
37
|
+
result: z.string().nullable(),
|
|
38
|
+
})).describe('Eval runs'),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export const getSubcommand = createSubcommand({
|
|
42
|
+
name: 'get',
|
|
43
|
+
description: 'Get details about a specific session',
|
|
44
|
+
tags: ['read-only', 'fast', 'requires-auth'],
|
|
45
|
+
examples: [`${getCommand('cloud session get')} sess_abc123xyz`],
|
|
46
|
+
requires: { auth: true },
|
|
47
|
+
idempotent: true,
|
|
48
|
+
schema: {
|
|
49
|
+
args: z.object({
|
|
50
|
+
session_id: z.string().describe('Session ID'),
|
|
51
|
+
}),
|
|
52
|
+
response: SessionGetResponseSchema,
|
|
53
|
+
},
|
|
54
|
+
async handler(ctx) {
|
|
55
|
+
const { config, logger, auth, args, options } = ctx;
|
|
56
|
+
const catalystClient = getCatalystAPIClient(config, logger, auth);
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const enriched = await sessionGet(catalystClient, { id: args.session_id });
|
|
60
|
+
const session = enriched.session;
|
|
61
|
+
|
|
62
|
+
const result = {
|
|
63
|
+
id: session.id,
|
|
64
|
+
created_at: session.created_at,
|
|
65
|
+
start_time: session.start_time,
|
|
66
|
+
end_time: session.end_time,
|
|
67
|
+
duration: session.duration,
|
|
68
|
+
org_id: session.org_id,
|
|
69
|
+
project_id: session.project_id,
|
|
70
|
+
deployment_id: session.deployment_id,
|
|
71
|
+
agent_ids: session.agent_ids,
|
|
72
|
+
trigger: session.trigger,
|
|
73
|
+
env: session.env,
|
|
74
|
+
devmode: session.devmode,
|
|
75
|
+
pending: session.pending,
|
|
76
|
+
success: session.success,
|
|
77
|
+
error: session.error,
|
|
78
|
+
method: session.method,
|
|
79
|
+
url: session.url,
|
|
80
|
+
route_id: session.route_id,
|
|
81
|
+
thread_id: session.thread_id,
|
|
82
|
+
agentNames: enriched.agentNames,
|
|
83
|
+
evalRuns: enriched.evalRuns.map(run => ({
|
|
84
|
+
id: run.id,
|
|
85
|
+
eval_id: run.eval_id,
|
|
86
|
+
created_at: run.created_at,
|
|
87
|
+
pending: run.pending,
|
|
88
|
+
success: run.success,
|
|
89
|
+
error: run.error,
|
|
90
|
+
result: run.result,
|
|
91
|
+
})),
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
if (options.json) {
|
|
95
|
+
console.log(JSON.stringify(result, null, 2));
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
tui.banner(`Session ${session.id}`, `Status: ${session.success ? 'Success' : 'Failed'}`);
|
|
100
|
+
|
|
101
|
+
console.log(tui.bold('ID: ') + session.id);
|
|
102
|
+
console.log(tui.bold('Project: ') + session.project_id);
|
|
103
|
+
console.log(tui.bold('Deployment: ') + (session.deployment_id || '-'));
|
|
104
|
+
console.log(tui.bold('Created: ') + new Date(session.created_at).toLocaleString());
|
|
105
|
+
console.log(tui.bold('Start: ') + new Date(session.start_time).toLocaleString());
|
|
106
|
+
if (session.end_time) {
|
|
107
|
+
console.log(tui.bold('End: ') + new Date(session.end_time).toLocaleString());
|
|
108
|
+
}
|
|
109
|
+
if (session.duration) {
|
|
110
|
+
console.log(
|
|
111
|
+
tui.bold('Duration: ') + `${(session.duration / 1_000_000).toFixed(0)}ms`
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
console.log(tui.bold('Method: ') + session.method);
|
|
115
|
+
console.log(tui.bold('URL: ') + tui.link(session.url, session.url));
|
|
116
|
+
console.log(tui.bold('Trigger: ') + session.trigger);
|
|
117
|
+
console.log(tui.bold('Environment: ') + session.env);
|
|
118
|
+
console.log(tui.bold('Dev Mode: ') + (session.devmode ? 'Yes' : 'No'));
|
|
119
|
+
console.log(tui.bold('Success: ') + (session.success ? '✓' : '✗'));
|
|
120
|
+
console.log(tui.bold('Pending: ') + (session.pending ? 'Yes' : 'No'));
|
|
121
|
+
if (session.error) {
|
|
122
|
+
console.log(tui.bold('Error: ') + tui.error(session.error));
|
|
123
|
+
}
|
|
124
|
+
if (enriched.agentNames.length > 0) {
|
|
125
|
+
const agentDisplay = enriched.agentNames.map((name, idx) => {
|
|
126
|
+
const agentId = session.agent_ids[idx];
|
|
127
|
+
return `${name} ${tui.muted(`(${agentId})`)}`;
|
|
128
|
+
}).join(', ');
|
|
129
|
+
console.log(tui.bold('Agents: ') + agentDisplay);
|
|
130
|
+
}
|
|
131
|
+
console.log(tui.bold('Route ID: ') + session.route_id);
|
|
132
|
+
console.log(tui.bold('Thread ID: ') + session.thread_id);
|
|
133
|
+
|
|
134
|
+
if (enriched.evalRuns.length > 0) {
|
|
135
|
+
console.log('');
|
|
136
|
+
console.log(tui.bold('Eval Runs:'));
|
|
137
|
+
const evalTableData = enriched.evalRuns.map((run) => ({
|
|
138
|
+
ID: run.id,
|
|
139
|
+
'Eval ID': run.eval_id,
|
|
140
|
+
Success: run.success ? '✓' : '✗',
|
|
141
|
+
Pending: run.pending ? '⏳' : '✓',
|
|
142
|
+
Error: run.error || 'No',
|
|
143
|
+
Created: new Date(run.created_at).toLocaleString(),
|
|
144
|
+
}));
|
|
145
|
+
|
|
146
|
+
tui.table(evalTableData, [
|
|
147
|
+
{ name: 'ID', alignment: 'left' },
|
|
148
|
+
{ name: 'Eval ID', alignment: 'left' },
|
|
149
|
+
{ name: 'Success', alignment: 'center' },
|
|
150
|
+
{ name: 'Pending', alignment: 'center' },
|
|
151
|
+
{ name: 'Error', alignment: 'left' },
|
|
152
|
+
{ name: 'Created', alignment: 'left' },
|
|
153
|
+
]);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return result;
|
|
157
|
+
} catch (ex) {
|
|
158
|
+
tui.fatal(
|
|
159
|
+
`Failed to get session: ${ex instanceof Error ? ex.message : String(ex)}`,
|
|
160
|
+
ErrorCode.API_ERROR
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createCommand } from '../../../types';
|
|
2
|
+
import { getSubcommand } from './get';
|
|
3
|
+
import { listSubcommand } from './list';
|
|
4
|
+
import { logsSubcommand } from './logs';
|
|
5
|
+
|
|
6
|
+
export const sessionCommand = createCommand({
|
|
7
|
+
name: 'session',
|
|
8
|
+
description: 'Manage sessions',
|
|
9
|
+
tags: ['requires-auth'],
|
|
10
|
+
subcommands: [getSubcommand, listSubcommand, logsSubcommand],
|
|
11
|
+
});
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createSubcommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { sessionList } from '@agentuity/server';
|
|
5
|
+
import { getCommand } from '../../../command-prefix';
|
|
6
|
+
import { ErrorCode } from '../../../errors';
|
|
7
|
+
import { getCatalystAPIClient } from '../../../config';
|
|
8
|
+
|
|
9
|
+
const SessionListResponseSchema = z.array(
|
|
10
|
+
z.object({
|
|
11
|
+
id: z.string().describe('Session ID'),
|
|
12
|
+
created_at: z.string().describe('Creation timestamp'),
|
|
13
|
+
success: z.boolean().describe('Whether the session succeeded'),
|
|
14
|
+
duration: z.number().nullable().describe('Duration in nanoseconds'),
|
|
15
|
+
method: z.string().describe('HTTP method'),
|
|
16
|
+
url: z.string().describe('Request URL'),
|
|
17
|
+
trigger: z.string().describe('Trigger type'),
|
|
18
|
+
env: z.string().describe('Environment'),
|
|
19
|
+
})
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export const listSubcommand = createSubcommand({
|
|
23
|
+
name: 'list',
|
|
24
|
+
description: 'List recent sessions',
|
|
25
|
+
tags: ['read-only', 'fast', 'requires-auth'],
|
|
26
|
+
examples: [
|
|
27
|
+
`${getCommand('cloud session list')} # List 10 most recent sessions`,
|
|
28
|
+
`${getCommand('cloud session list')} --count=25 # List 25 most recent sessions`,
|
|
29
|
+
`${getCommand('cloud session list')} --project-id=proj_* # Filter by project`,
|
|
30
|
+
`${getCommand('cloud session list')} --deployment-id=* # Filter by deployment`,
|
|
31
|
+
`${getCommand('cloud session list')} --success=true # Only successful sessions`,
|
|
32
|
+
`${getCommand('cloud session list')} --devmode=false # Only production sessions`,
|
|
33
|
+
`${getCommand('cloud session list')} --trigger=api # Only API triggered sessions`,
|
|
34
|
+
`${getCommand('cloud session list')} --env=production # Only production environment`,
|
|
35
|
+
],
|
|
36
|
+
aliases: ['ls'],
|
|
37
|
+
requires: { auth: true },
|
|
38
|
+
optional: { project: true },
|
|
39
|
+
idempotent: true,
|
|
40
|
+
pagination: {
|
|
41
|
+
supported: true,
|
|
42
|
+
defaultLimit: 10,
|
|
43
|
+
maxLimit: 100,
|
|
44
|
+
parameters: {
|
|
45
|
+
limit: 'count',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
schema: {
|
|
49
|
+
options: z.object({
|
|
50
|
+
count: z.coerce
|
|
51
|
+
.number()
|
|
52
|
+
.int()
|
|
53
|
+
.min(1)
|
|
54
|
+
.max(100)
|
|
55
|
+
.default(10)
|
|
56
|
+
.describe('Number of sessions to list (1–100)'),
|
|
57
|
+
projectId: z.string().optional().describe('Filter by project ID'),
|
|
58
|
+
deploymentId: z.string().optional().describe('Filter by deployment ID'),
|
|
59
|
+
trigger: z.string().optional().describe('Filter by trigger type (api, cron, webhook)'),
|
|
60
|
+
env: z.string().optional().describe('Filter by environment'),
|
|
61
|
+
threadId: z.string().optional().describe('Filter by thread ID'),
|
|
62
|
+
agentIdentifier: z.string().optional().describe('Filter by agent identifier'),
|
|
63
|
+
devmode: z.coerce.boolean().optional().describe('Filter by dev mode (true/false)'),
|
|
64
|
+
success: z.coerce.boolean().optional().describe('Filter by success status (true/false)'),
|
|
65
|
+
startAfter: z.string().optional().describe('Filter by start time after (ISO 8601)'),
|
|
66
|
+
startBefore: z.string().optional().describe('Filter by start time before (ISO 8601)'),
|
|
67
|
+
}),
|
|
68
|
+
response: SessionListResponseSchema,
|
|
69
|
+
},
|
|
70
|
+
async handler(ctx) {
|
|
71
|
+
const { config, logger, auth, project, opts, options } = ctx;
|
|
72
|
+
const catalystClient = getCatalystAPIClient(config, logger, auth);
|
|
73
|
+
|
|
74
|
+
const projectId = opts.projectId || project?.projectId;
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
const sessions = await sessionList(catalystClient, {
|
|
78
|
+
count: opts.count,
|
|
79
|
+
projectId,
|
|
80
|
+
deploymentId: opts.deploymentId,
|
|
81
|
+
trigger: opts.trigger,
|
|
82
|
+
env: opts.env,
|
|
83
|
+
devmode: opts.devmode,
|
|
84
|
+
success: opts.success,
|
|
85
|
+
threadId: opts.threadId,
|
|
86
|
+
agentIdentifier: opts.agentIdentifier,
|
|
87
|
+
startAfter: opts.startAfter,
|
|
88
|
+
startBefore: opts.startBefore,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const result = sessions.map((s) => ({
|
|
92
|
+
id: s.id,
|
|
93
|
+
created_at: s.created_at,
|
|
94
|
+
success: s.success,
|
|
95
|
+
duration: s.duration,
|
|
96
|
+
method: s.method,
|
|
97
|
+
url: s.url,
|
|
98
|
+
trigger: s.trigger,
|
|
99
|
+
env: s.env,
|
|
100
|
+
}));
|
|
101
|
+
|
|
102
|
+
if (options.json) {
|
|
103
|
+
console.log(JSON.stringify(result, null, 2));
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (sessions.length === 0) {
|
|
108
|
+
tui.info('No sessions found.');
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const tableData = sessions.map((s) => {
|
|
113
|
+
const urlPath = new URL(s.url).pathname;
|
|
114
|
+
return {
|
|
115
|
+
ID: s.id,
|
|
116
|
+
Created: new Date(s.created_at).toLocaleString(),
|
|
117
|
+
Success: s.success ? '✓' : '✗',
|
|
118
|
+
Duration: s.duration ? `${(s.duration / 1_000_000).toFixed(0)}ms` : '-',
|
|
119
|
+
Method: s.method,
|
|
120
|
+
Path: urlPath.length > 50 ? urlPath.substring(0, 47) + '...' : urlPath,
|
|
121
|
+
Trigger: s.trigger,
|
|
122
|
+
Env: s.env,
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
tui.table(tableData, [
|
|
127
|
+
{ name: 'ID', alignment: 'left' },
|
|
128
|
+
{ name: 'Created', alignment: 'left' },
|
|
129
|
+
{ name: 'Success', alignment: 'center' },
|
|
130
|
+
{ name: 'Duration', alignment: 'right' },
|
|
131
|
+
{ name: 'Method', alignment: 'left' },
|
|
132
|
+
{ name: 'Path', alignment: 'left' },
|
|
133
|
+
{ name: 'Trigger', alignment: 'left' },
|
|
134
|
+
{ name: 'Env', alignment: 'left' },
|
|
135
|
+
]);
|
|
136
|
+
|
|
137
|
+
return result;
|
|
138
|
+
} catch (ex) {
|
|
139
|
+
tui.fatal(
|
|
140
|
+
`Failed to list sessions: ${ex instanceof Error ? ex.message : String(ex)}`,
|
|
141
|
+
ErrorCode.API_ERROR
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createSubcommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { sessionLogs } from '@agentuity/server';
|
|
5
|
+
import { getCommand } from '../../../command-prefix';
|
|
6
|
+
import { ErrorCode } from '../../../errors';
|
|
7
|
+
|
|
8
|
+
const SessionLogsResponseSchema = z.array(
|
|
9
|
+
z.object({
|
|
10
|
+
body: z.string().describe('Log body'),
|
|
11
|
+
severity: z.string().describe('Log severity'),
|
|
12
|
+
timestamp: z.string().describe('Log timestamp'),
|
|
13
|
+
})
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export const logsSubcommand = createSubcommand({
|
|
17
|
+
name: 'logs',
|
|
18
|
+
description: 'Get logs for a specific session',
|
|
19
|
+
tags: ['read-only', 'slow', 'requires-auth'],
|
|
20
|
+
examples: [`${getCommand('cloud session logs')} sess_abc123xyz`],
|
|
21
|
+
requires: { auth: true, apiClient: true },
|
|
22
|
+
optional: { project: true },
|
|
23
|
+
idempotent: true,
|
|
24
|
+
schema: {
|
|
25
|
+
args: z.object({
|
|
26
|
+
session_id: z.string().describe('Session ID'),
|
|
27
|
+
}),
|
|
28
|
+
options: z.object({
|
|
29
|
+
projectId: z.string().optional().describe('Project ID (for display purposes)'),
|
|
30
|
+
deploymentId: z.string().optional().describe('Deployment ID (for display purposes)'),
|
|
31
|
+
}),
|
|
32
|
+
response: SessionLogsResponseSchema,
|
|
33
|
+
},
|
|
34
|
+
async handler(ctx) {
|
|
35
|
+
const { apiClient, args } = ctx;
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
const logs = await sessionLogs(apiClient, { id: args.session_id });
|
|
39
|
+
|
|
40
|
+
if (logs.length === 0) {
|
|
41
|
+
tui.info('No logs found for this session.');
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
tui.banner(`Logs for Session ${args.session_id}`, `${logs.length} log entries`);
|
|
46
|
+
|
|
47
|
+
for (const log of logs) {
|
|
48
|
+
const timestamp = new Date(log.timestamp).toLocaleTimeString();
|
|
49
|
+
const severity = log.severity.padEnd(5);
|
|
50
|
+
const severityColor =
|
|
51
|
+
log.severity === 'ERROR'
|
|
52
|
+
? tui.error(severity)
|
|
53
|
+
: log.severity === 'WARN'
|
|
54
|
+
? tui.warning(severity)
|
|
55
|
+
: tui.muted(severity);
|
|
56
|
+
|
|
57
|
+
console.log(`${tui.muted(timestamp)} ${severityColor} ${log.body}`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return logs;
|
|
61
|
+
} catch (ex) {
|
|
62
|
+
tui.fatal(
|
|
63
|
+
`Failed to get session logs: ${ex instanceof Error ? ex.message : String(ex)}`,
|
|
64
|
+
ErrorCode.API_ERROR
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
});
|
package/src/cmd/cloud/ssh.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { createSubcommand } from '../../types';
|
|
3
3
|
import * as tui from '../../tui';
|
|
4
4
|
import { getIONHost } from '../../config';
|
|
5
|
+
import { getCommand } from '../../command-prefix';
|
|
5
6
|
|
|
6
7
|
const args = z.object({
|
|
7
8
|
identifier: z.string().optional().describe('The project or deployment id to use'),
|
|
@@ -15,9 +16,20 @@ const options = z.object({
|
|
|
15
16
|
export const sshSubcommand = createSubcommand({
|
|
16
17
|
name: 'ssh',
|
|
17
18
|
description: 'SSH into a cloud project',
|
|
19
|
+
tags: ['read-only', 'slow', 'requires-auth', 'requires-deployment'],
|
|
20
|
+
idempotent: true,
|
|
21
|
+
examples: [
|
|
22
|
+
`${getCommand('cloud ssh')} # SSH into current project`,
|
|
23
|
+
`${getCommand('cloud ssh')} proj_abc123xyz # SSH into specific project`,
|
|
24
|
+
`${getCommand('cloud ssh')} deploy_abc123xyz # SSH into specific deployment`,
|
|
25
|
+
`${getCommand('cloud ssh')} 'ps aux' # Run command and exit`,
|
|
26
|
+
`${getCommand('cloud ssh')} proj_abc123xyz 'tail -f /var/log/app.log'`,
|
|
27
|
+
`${getCommand('cloud ssh')} --show # Show SSH command without executing`,
|
|
28
|
+
],
|
|
18
29
|
toplevel: true,
|
|
19
30
|
requires: { auth: true, apiClient: true },
|
|
20
31
|
optional: { project: true },
|
|
32
|
+
prerequisites: ['cloud deploy'],
|
|
21
33
|
schema: { args, options },
|
|
22
34
|
|
|
23
35
|
async handler(ctx) {
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createSubcommand } from '../../types';
|
|
3
|
+
import * as tui from '../../tui';
|
|
4
|
+
import { APIResponseSchema } from '@agentuity/server';
|
|
5
|
+
import { abbreviate, abbreviateDescription } from '../../utils/format';
|
|
6
|
+
|
|
7
|
+
const AgentSchema = z.object({
|
|
8
|
+
id: z.string(),
|
|
9
|
+
name: z.string(),
|
|
10
|
+
description: z.string().nullable(),
|
|
11
|
+
identifier: z.string(),
|
|
12
|
+
version: z.string().nullable(),
|
|
13
|
+
deploymentId: z.string().nullable(),
|
|
14
|
+
devmode: z.boolean(),
|
|
15
|
+
metadata: z.record(z.string(), z.unknown()).nullable(),
|
|
16
|
+
createdAt: z.string(),
|
|
17
|
+
updatedAt: z.string(),
|
|
18
|
+
evals: z.array(
|
|
19
|
+
z.object({
|
|
20
|
+
id: z.string(),
|
|
21
|
+
name: z.string(),
|
|
22
|
+
description: z.string().nullable(),
|
|
23
|
+
identifier: z.string().nullable(),
|
|
24
|
+
deploymentId: z.string().nullable(),
|
|
25
|
+
version: z.string().nullable(),
|
|
26
|
+
devmode: z.boolean(),
|
|
27
|
+
createdAt: z.string(),
|
|
28
|
+
updatedAt: z.string(),
|
|
29
|
+
})
|
|
30
|
+
),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const AgentsResponseSchema = APIResponseSchema(z.array(AgentSchema));
|
|
34
|
+
|
|
35
|
+
export const agentsSubcommand = createSubcommand({
|
|
36
|
+
name: 'agents',
|
|
37
|
+
description: 'Show devmode agent results',
|
|
38
|
+
requires: { auth: true, apiClient: true, project: true },
|
|
39
|
+
schema: {
|
|
40
|
+
options: z.object({
|
|
41
|
+
deploymentId: z.string().optional().describe('Filter by deployment ID'),
|
|
42
|
+
format: z
|
|
43
|
+
.enum(['json', 'table'])
|
|
44
|
+
.optional()
|
|
45
|
+
.default('table')
|
|
46
|
+
.describe('Output format: json or table'),
|
|
47
|
+
verbose: z.boolean().optional().default(false).describe('Show full IDs and descriptions'),
|
|
48
|
+
}),
|
|
49
|
+
},
|
|
50
|
+
async handler(ctx) {
|
|
51
|
+
const { opts, apiClient, project } = ctx;
|
|
52
|
+
const projectId = project.projectId;
|
|
53
|
+
const format = opts?.format ?? 'table';
|
|
54
|
+
const verbose = opts?.verbose ?? false;
|
|
55
|
+
|
|
56
|
+
const deploymentId = opts?.deploymentId;
|
|
57
|
+
const queryParams = deploymentId ? `?deploymentId=${deploymentId}` : '';
|
|
58
|
+
const response = await tui.spinner('Fetching agents', async () => {
|
|
59
|
+
return apiClient.request(
|
|
60
|
+
'GET',
|
|
61
|
+
`/cli/agent/${projectId}${queryParams}`,
|
|
62
|
+
AgentsResponseSchema
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
if (!response.success) {
|
|
67
|
+
tui.fatal(`Failed to fetch agents: ${response.message ?? 'Unknown error'}`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const agents = response.data;
|
|
71
|
+
|
|
72
|
+
if (format === 'json') {
|
|
73
|
+
console.log(JSON.stringify(agents, null, 2));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
tui.info(`Agents (${agents.length})`);
|
|
78
|
+
if (agents.length === 0) {
|
|
79
|
+
tui.muted('No agents found');
|
|
80
|
+
} else {
|
|
81
|
+
console.table(
|
|
82
|
+
agents.map((agent) => ({
|
|
83
|
+
name: agent.name,
|
|
84
|
+
id: verbose ? agent.id : abbreviate(agent.id, 20),
|
|
85
|
+
identifier: verbose ? agent.identifier : abbreviate(agent.identifier, 20),
|
|
86
|
+
deployment: abbreviate(agent.deploymentId, 20),
|
|
87
|
+
version: verbose
|
|
88
|
+
? (agent.version ?? 'N/A')
|
|
89
|
+
: (abbreviate(agent.version, 20) ?? 'N/A'),
|
|
90
|
+
evals: agent.evals.length,
|
|
91
|
+
createdAt: new Date(agent.createdAt).toLocaleString(),
|
|
92
|
+
})),
|
|
93
|
+
['name', 'id', 'identifier', 'deployment', 'version', 'evals', 'createdAt']
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
// Show evals for each agent
|
|
97
|
+
for (const agent of agents) {
|
|
98
|
+
if (agent.evals.length > 0) {
|
|
99
|
+
console.log(`\n Evals for ${agent.name}:`);
|
|
100
|
+
console.table(
|
|
101
|
+
agent.evals.map((evalItem) => ({
|
|
102
|
+
name: evalItem.name,
|
|
103
|
+
id: verbose ? evalItem.id : abbreviate(evalItem.id, 20),
|
|
104
|
+
identifier: verbose
|
|
105
|
+
? (evalItem.identifier ?? 'N/A')
|
|
106
|
+
: (abbreviate(evalItem.identifier, 20) ?? 'N/A'),
|
|
107
|
+
deployment: abbreviate(evalItem.deploymentId, 20),
|
|
108
|
+
version: verbose
|
|
109
|
+
? (evalItem.version ?? 'N/A')
|
|
110
|
+
: (abbreviate(evalItem.version, 20) ?? 'N/A'),
|
|
111
|
+
description: verbose
|
|
112
|
+
? (evalItem.description ?? 'N/A')
|
|
113
|
+
: abbreviateDescription(evalItem.description),
|
|
114
|
+
createdAt: new Date(evalItem.createdAt).toLocaleString(),
|
|
115
|
+
})),
|
|
116
|
+
['name', 'id', 'identifier', 'deployment', 'version', 'description', 'createdAt']
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
});
|