@agentuity/cli 0.0.58 → 0.0.60
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/cli.d.ts.map +1 -1
- package/dist/cli.js +14 -1
- package/dist/cli.js.map +1 -1
- package/dist/cmd/ai/capabilities/show.d.ts.map +1 -1
- package/dist/cmd/ai/capabilities/show.js +11 -4
- package/dist/cmd/ai/capabilities/show.js.map +1 -1
- package/dist/cmd/build/bundler.d.ts +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.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.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/db/create.d.ts +2 -0
- package/dist/cmd/cloud/db/create.d.ts.map +1 -0
- package/dist/cmd/cloud/db/create.js +68 -0
- package/dist/cmd/cloud/db/create.js.map +1 -0
- package/dist/cmd/cloud/db/delete.d.ts +2 -0
- package/dist/cmd/cloud/db/delete.d.ts.map +1 -0
- package/dist/cmd/cloud/db/delete.js +106 -0
- package/dist/cmd/cloud/db/delete.js.map +1 -0
- package/dist/cmd/cloud/db/get.d.ts +2 -0
- package/dist/cmd/cloud/db/get.d.ts.map +1 -0
- package/dist/cmd/cloud/db/get.js +66 -0
- package/dist/cmd/cloud/db/get.js.map +1 -0
- package/dist/cmd/cloud/db/index.d.ts +2 -0
- package/dist/cmd/cloud/db/index.d.ts.map +1 -0
- package/dist/cmd/cloud/db/index.js +14 -0
- package/dist/cmd/cloud/db/index.js.map +1 -0
- package/dist/cmd/cloud/db/list.d.ts +2 -0
- package/dist/cmd/cloud/db/list.d.ts.map +1 -0
- package/dist/cmd/cloud/db/list.js +75 -0
- package/dist/cmd/cloud/db/list.js.map +1 -0
- package/dist/cmd/cloud/db/sql.d.ts +2 -0
- package/dist/cmd/cloud/db/sql.d.ts.map +1 -0
- package/dist/cmd/cloud/db/sql.js +102 -0
- package/dist/cmd/cloud/db/sql.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/env/get.d.ts.map +1 -1
- package/dist/cmd/cloud/env/get.js +2 -3
- package/dist/cmd/cloud/env/get.js.map +1 -1
- package/dist/cmd/cloud/env/list.d.ts.map +1 -1
- package/dist/cmd/cloud/env/list.js +1 -2
- package/dist/cmd/cloud/env/list.js.map +1 -1
- package/dist/cmd/cloud/index.d.ts.map +1 -1
- package/dist/cmd/cloud/index.js +12 -4
- package/dist/cmd/cloud/index.js.map +1 -1
- package/dist/cmd/cloud/secret/get.d.ts.map +1 -1
- package/dist/cmd/cloud/secret/get.js +2 -3
- package/dist/cmd/cloud/secret/get.js.map +1 -1
- package/dist/cmd/cloud/secret/list.d.ts.map +1 -1
- package/dist/cmd/cloud/secret/list.js +1 -2
- package/dist/cmd/cloud/secret/list.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/storage/create.d.ts +2 -0
- package/dist/cmd/cloud/storage/create.d.ts.map +1 -0
- package/dist/cmd/cloud/storage/create.js +61 -0
- package/dist/cmd/cloud/storage/create.js.map +1 -0
- package/dist/cmd/cloud/storage/delete.d.ts +2 -0
- package/dist/cmd/cloud/storage/delete.d.ts.map +1 -0
- package/dist/cmd/cloud/storage/delete.js +167 -0
- package/dist/cmd/cloud/storage/delete.js.map +1 -0
- package/dist/cmd/cloud/storage/download.d.ts +2 -0
- package/dist/cmd/cloud/storage/download.d.ts.map +1 -0
- package/dist/cmd/cloud/storage/download.js +131 -0
- package/dist/cmd/cloud/storage/download.js.map +1 -0
- package/dist/cmd/cloud/storage/get.d.ts +2 -0
- package/dist/cmd/cloud/storage/get.d.ts.map +1 -0
- package/dist/cmd/cloud/storage/get.js +86 -0
- package/dist/cmd/cloud/storage/get.js.map +1 -0
- package/dist/cmd/cloud/storage/index.d.ts +2 -0
- package/dist/cmd/cloud/storage/index.d.ts.map +1 -0
- package/dist/cmd/cloud/storage/index.js +22 -0
- package/dist/cmd/cloud/storage/index.js.map +1 -0
- package/dist/cmd/cloud/storage/list.d.ts +2 -0
- package/dist/cmd/cloud/storage/list.d.ts.map +1 -0
- package/dist/cmd/cloud/storage/list.js +170 -0
- package/dist/cmd/cloud/storage/list.js.map +1 -0
- package/dist/cmd/cloud/storage/upload.d.ts +2 -0
- package/dist/cmd/cloud/storage/upload.d.ts.map +1 -0
- package/dist/cmd/cloud/storage/upload.js +133 -0
- package/dist/cmd/cloud/storage/upload.js.map +1 -0
- package/dist/cmd/cloud/storage/utils.d.ts +18 -0
- package/dist/cmd/cloud/storage/utils.d.ts.map +1 -0
- package/dist/cmd/cloud/storage/utils.js +21 -0
- package/dist/cmd/cloud/storage/utils.js.map +1 -0
- 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.js +3 -3
- 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 +12 -2
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +61 -31
- 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/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +6 -6
- package/src/cli.ts +15 -1
- package/src/cmd/ai/capabilities/show.ts +11 -4
- 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/db/create.ts +72 -0
- package/src/cmd/cloud/db/delete.ts +118 -0
- package/src/cmd/cloud/db/get.ts +75 -0
- package/src/cmd/cloud/db/index.ts +14 -0
- package/src/cmd/cloud/db/list.ts +83 -0
- package/src/cmd/cloud/db/sql.ts +125 -0
- package/src/cmd/cloud/deployment/index.ts +2 -0
- package/src/cmd/cloud/deployment/logs.ts +75 -0
- package/src/cmd/cloud/env/get.ts +2 -3
- package/src/cmd/cloud/env/list.ts +1 -2
- package/src/cmd/cloud/index.ts +13 -4
- package/src/cmd/cloud/secret/get.ts +2 -3
- package/src/cmd/cloud/secret/list.ts +1 -2
- package/src/cmd/cloud/session/logs.ts +12 -11
- package/src/cmd/cloud/storage/create.ts +65 -0
- package/src/cmd/cloud/storage/delete.ts +195 -0
- package/src/cmd/cloud/storage/download.ts +154 -0
- package/src/cmd/cloud/storage/get.ts +97 -0
- package/src/cmd/cloud/storage/index.ts +22 -0
- package/src/cmd/cloud/storage/list.ts +197 -0
- package/src/cmd/cloud/storage/upload.ts +150 -0
- package/src/cmd/cloud/storage/utils.ts +26 -0
- 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 +3 -3
- package/src/cmd/index.ts +38 -42
- package/src/schema-parser.ts +3 -1
- package/src/tui.ts +73 -36
- package/src/utils/date.ts +57 -0
- package/src/version.ts +1 -1
- 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/dist/cmd/cloud/resource/add.d.ts +0 -2
- package/dist/cmd/cloud/resource/add.d.ts.map +0 -1
- package/dist/cmd/cloud/resource/add.js +0 -70
- package/dist/cmd/cloud/resource/add.js.map +0 -1
- package/dist/cmd/cloud/resource/delete.d.ts.map +0 -1
- package/dist/cmd/cloud/resource/delete.js +0 -126
- package/dist/cmd/cloud/resource/delete.js.map +0 -1
- package/dist/cmd/cloud/resource/index.d.ts +0 -2
- package/dist/cmd/cloud/resource/index.d.ts.map +0 -1
- package/dist/cmd/cloud/resource/index.js +0 -12
- package/dist/cmd/cloud/resource/index.js.map +0 -1
- package/dist/cmd/cloud/resource/list.d.ts.map +0 -1
- package/dist/cmd/cloud/resource/list.js +0 -100
- package/dist/cmd/cloud/resource/list.js.map +0 -1
- package/src/cmd/cloud/agents/index.ts +0 -148
- package/src/cmd/cloud/resource/add.ts +0 -75
- package/src/cmd/cloud/resource/delete.ts +0 -141
- package/src/cmd/cloud/resource/index.ts +0 -12
- package/src/cmd/cloud/resource/list.ts +0 -105
- /package/dist/cmd/cloud/{resource → agent}/list.d.ts +0 -0
- /package/dist/cmd/cloud/{resource → apikey}/delete.d.ts +0 -0
- /package/dist/cmd/cloud/{agents → apikey}/index.d.ts +0 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SQL } from 'bun';
|
|
3
|
+
import { listResources, type ResourceList } from '@agentuity/server';
|
|
4
|
+
import { createSubcommand } from '../../../types';
|
|
5
|
+
import * as tui from '../../../tui';
|
|
6
|
+
import { getCatalystAPIClient } from '../../../config';
|
|
7
|
+
import { getCommand } from '../../../command-prefix';
|
|
8
|
+
import { ErrorCode } from '../../../errors';
|
|
9
|
+
|
|
10
|
+
interface DatabaseResource {
|
|
11
|
+
name: string;
|
|
12
|
+
username?: string | null;
|
|
13
|
+
password?: string | null;
|
|
14
|
+
url?: string | null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const DBSQLResponseSchema = z.object({
|
|
18
|
+
rows: z.array(z.record(z.string(), z.unknown())).describe('Query results'),
|
|
19
|
+
rowCount: z.number().describe('Number of rows returned'),
|
|
20
|
+
executionTime: z.number().optional().describe('Query execution time in ms'),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const sqlSubcommand = createSubcommand({
|
|
24
|
+
name: 'sql',
|
|
25
|
+
aliases: ['exec', 'query'],
|
|
26
|
+
description: 'Execute SQL query on a database',
|
|
27
|
+
tags: ['slow', 'requires-auth'],
|
|
28
|
+
requires: { auth: true, org: true, region: true },
|
|
29
|
+
idempotent: false,
|
|
30
|
+
examples: [
|
|
31
|
+
`${getCommand('cloud db sql')} my-database "SELECT * FROM users LIMIT 10"`,
|
|
32
|
+
`${getCommand('cloud db exec')} my-database "SELECT COUNT(*) FROM orders" --json`,
|
|
33
|
+
`${getCommand('cloud db query')} my-database "SELECT * FROM products WHERE price > 100"`,
|
|
34
|
+
],
|
|
35
|
+
schema: {
|
|
36
|
+
args: z.object({
|
|
37
|
+
name: z.string().describe('Database name'),
|
|
38
|
+
query: z.string().describe('SQL query to execute'),
|
|
39
|
+
}),
|
|
40
|
+
options: z.object({}),
|
|
41
|
+
response: DBSQLResponseSchema,
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
async handler(ctx) {
|
|
45
|
+
const { logger, args, options, orgId, region, config, auth } = ctx;
|
|
46
|
+
|
|
47
|
+
const catalystClient = getCatalystAPIClient(config, logger, auth);
|
|
48
|
+
|
|
49
|
+
const resources: ResourceList = await tui.spinner({
|
|
50
|
+
message: `Fetching database ${args.name}`,
|
|
51
|
+
clearOnSuccess: true,
|
|
52
|
+
callback: async () => {
|
|
53
|
+
return listResources(catalystClient, orgId, region);
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const db: DatabaseResource | undefined = resources.db.find(
|
|
58
|
+
(d: DatabaseResource) => d.name === args.name
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
if (!db) {
|
|
62
|
+
tui.fatal(`Database '${args.name}' not found`, ErrorCode.RESOURCE_NOT_FOUND);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!db.url) {
|
|
66
|
+
tui.fatal(`Database '${args.name}' has no connection URL`, ErrorCode.RUNTIME_ERROR);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let database: SQL | undefined;
|
|
70
|
+
let rows: Record<string, unknown>[];
|
|
71
|
+
let executionTime: number | undefined;
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
// Add sslmode=require if not already present in URL
|
|
75
|
+
let connectionUrl = db.url;
|
|
76
|
+
if (!connectionUrl.includes('sslmode=') && !connectionUrl.includes('ssl=')) {
|
|
77
|
+
const separator = connectionUrl.includes('?') ? '&' : '?';
|
|
78
|
+
connectionUrl = `${connectionUrl}${separator}sslmode=require`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
database = new SQL(connectionUrl);
|
|
82
|
+
|
|
83
|
+
const startTime = performance.now();
|
|
84
|
+
const result = await tui.spinner({
|
|
85
|
+
message: `Executing query on ${args.name}`,
|
|
86
|
+
clearOnSuccess: true,
|
|
87
|
+
callback: async () => {
|
|
88
|
+
return database!.unsafe(args.query);
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
executionTime = performance.now() - startTime;
|
|
92
|
+
|
|
93
|
+
rows = result;
|
|
94
|
+
} catch (error) {
|
|
95
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
96
|
+
tui.fatal(`Query execution failed: ${message}`, ErrorCode.RUNTIME_ERROR);
|
|
97
|
+
} finally {
|
|
98
|
+
if (database) {
|
|
99
|
+
await database.close();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (!options.json) {
|
|
104
|
+
if (rows.length === 0) {
|
|
105
|
+
tui.info('No rows returned');
|
|
106
|
+
} else {
|
|
107
|
+
if (process.stdout.isTTY) {
|
|
108
|
+
tui.newline();
|
|
109
|
+
tui.success(
|
|
110
|
+
`Query returned ${rows.length} row${rows.length !== 1 ? 's' : ''} (${executionTime?.toFixed(2)}ms):`
|
|
111
|
+
);
|
|
112
|
+
tui.newline();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
tui.table(rows);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
rows,
|
|
121
|
+
rowCount: rows.length,
|
|
122
|
+
executionTime,
|
|
123
|
+
};
|
|
124
|
+
},
|
|
125
|
+
});
|
|
@@ -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/env/get.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { z } from 'zod';
|
|
|
2
2
|
import { createSubcommand } from '../../../types';
|
|
3
3
|
import * as tui from '../../../tui';
|
|
4
4
|
import { projectGet } from '@agentuity/server';
|
|
5
|
-
import { maskSecret } from '../../../env-util';
|
|
6
5
|
import { getCommand } from '../../../command-prefix';
|
|
7
6
|
import { ErrorCode } from '../../../errors';
|
|
8
7
|
|
|
@@ -50,13 +49,13 @@ export const getSubcommand = createSubcommand({
|
|
|
50
49
|
// Display the value, masked if requested
|
|
51
50
|
if (process.stdout.isTTY) {
|
|
52
51
|
if (opts?.mask) {
|
|
53
|
-
tui.success(`${args.key}=${maskSecret(value)}`);
|
|
52
|
+
tui.success(`${args.key}=${tui.maskSecret(value)}`);
|
|
54
53
|
} else {
|
|
55
54
|
tui.success(`${args.key}=${value}`);
|
|
56
55
|
}
|
|
57
56
|
} else {
|
|
58
57
|
if (opts?.mask) {
|
|
59
|
-
console.log(`${args.key}=${maskSecret(value)}`);
|
|
58
|
+
console.log(`${args.key}=${tui.maskSecret(value)}`);
|
|
60
59
|
} else {
|
|
61
60
|
console.log(`${args.key}=${value}`);
|
|
62
61
|
}
|
|
@@ -2,7 +2,6 @@ import { z } from 'zod';
|
|
|
2
2
|
import { createSubcommand } from '../../../types';
|
|
3
3
|
import * as tui from '../../../tui';
|
|
4
4
|
import { projectGet } from '@agentuity/server';
|
|
5
|
-
import { maskSecret } from '../../../env-util';
|
|
6
5
|
import { getCommand } from '../../../command-prefix';
|
|
7
6
|
|
|
8
7
|
const EnvListResponseSchema = z.record(
|
|
@@ -55,7 +54,7 @@ export const listSubcommand = createSubcommand({
|
|
|
55
54
|
const shouldMask = opts?.mask === true;
|
|
56
55
|
for (const key of sortedKeys) {
|
|
57
56
|
const value = env[key];
|
|
58
|
-
const displayValue = shouldMask ? maskSecret(value) : value;
|
|
57
|
+
const displayValue = shouldMask ? tui.maskSecret(value) : value;
|
|
59
58
|
if (process.stdout.isTTY) {
|
|
60
59
|
console.log(`${tui.bold(key)}=${displayValue}`);
|
|
61
60
|
} else {
|
package/src/cmd/cloud/index.ts
CHANGED
|
@@ -1,28 +1,37 @@
|
|
|
1
1
|
import { createCommand } from '../../types';
|
|
2
2
|
import { deploySubcommand } from './deploy';
|
|
3
|
-
import {
|
|
3
|
+
import { dbCommand } from './db';
|
|
4
|
+
import { storageCommand } from './storage';
|
|
4
5
|
import { sessionCommand } from './session';
|
|
5
6
|
import { sshSubcommand } from './ssh';
|
|
6
7
|
import { scpSubcommand } from './scp';
|
|
7
8
|
import { deploymentCommand } from './deployment';
|
|
8
9
|
import keyvalueCommand from './keyvalue';
|
|
9
|
-
import
|
|
10
|
+
import { agentCommand } from './agent';
|
|
10
11
|
import objectstoreCommand from './objectstore';
|
|
11
12
|
import envCommand from './env';
|
|
12
13
|
import secretCommand from './secret';
|
|
14
|
+
import apikeyCommand from './apikey';
|
|
15
|
+
import streamCommand from './stream';
|
|
16
|
+
import vectorCommand from './vector';
|
|
17
|
+
|
|
13
18
|
|
|
14
19
|
export const command = createCommand({
|
|
15
20
|
name: 'cloud',
|
|
16
21
|
description: 'Cloud related commands',
|
|
17
22
|
tags: ['slow', 'requires-auth'],
|
|
18
23
|
subcommands: [
|
|
24
|
+
apikeyCommand,
|
|
19
25
|
keyvalueCommand,
|
|
20
|
-
|
|
26
|
+
agentCommand,
|
|
21
27
|
objectstoreCommand,
|
|
28
|
+
streamCommand,
|
|
29
|
+
vectorCommand,
|
|
22
30
|
envCommand,
|
|
23
31
|
secretCommand,
|
|
24
32
|
deploySubcommand,
|
|
25
|
-
|
|
33
|
+
dbCommand,
|
|
34
|
+
storageCommand,
|
|
26
35
|
sessionCommand,
|
|
27
36
|
sshSubcommand,
|
|
28
37
|
scpSubcommand,
|
|
@@ -2,7 +2,6 @@ import { z } from 'zod';
|
|
|
2
2
|
import { createSubcommand } from '../../../types';
|
|
3
3
|
import * as tui from '../../../tui';
|
|
4
4
|
import { projectGet } from '@agentuity/server';
|
|
5
|
-
import { maskSecret } from '../../../env-util';
|
|
6
5
|
import { getCommand } from '../../../command-prefix';
|
|
7
6
|
import { ErrorCode } from '../../../errors';
|
|
8
7
|
|
|
@@ -53,14 +52,14 @@ export const getSubcommand = createSubcommand({
|
|
|
53
52
|
if (process.stdout.isTTY) {
|
|
54
53
|
// Display the value, masked by default
|
|
55
54
|
if (opts?.mask) {
|
|
56
|
-
tui.success(`${args.key}=${maskSecret(value)}`);
|
|
55
|
+
tui.success(`${args.key}=${tui.maskSecret(value)}`);
|
|
57
56
|
} else {
|
|
58
57
|
tui.success(`${args.key}=${value}`);
|
|
59
58
|
}
|
|
60
59
|
} else {
|
|
61
60
|
// Display the value, masked by default
|
|
62
61
|
if (opts?.mask) {
|
|
63
|
-
console.log(`${args.key}=${maskSecret(value)}`);
|
|
62
|
+
console.log(`${args.key}=${tui.maskSecret(value)}`);
|
|
64
63
|
} else {
|
|
65
64
|
console.log(`${args.key}=${value}`);
|
|
66
65
|
}
|
|
@@ -2,7 +2,6 @@ import { z } from 'zod';
|
|
|
2
2
|
import { createSubcommand } from '../../../types';
|
|
3
3
|
import * as tui from '../../../tui';
|
|
4
4
|
import { projectGet } from '@agentuity/server';
|
|
5
|
-
import { maskSecret } from '../../../env-util';
|
|
6
5
|
import { getCommand } from '../../../command-prefix';
|
|
7
6
|
|
|
8
7
|
const SecretListResponseSchema = z.record(z.string(), z.string().describe('Secret value'));
|
|
@@ -52,7 +51,7 @@ export const listSubcommand = createSubcommand({
|
|
|
52
51
|
const shouldMask = opts?.mask !== false;
|
|
53
52
|
for (const key of sortedKeys) {
|
|
54
53
|
const value = secrets[key];
|
|
55
|
-
const displayValue = shouldMask ? maskSecret(value) : value;
|
|
54
|
+
const displayValue = shouldMask ? tui.maskSecret(value) : value;
|
|
56
55
|
if (process.stdout.isTTY) {
|
|
57
56
|
console.log(`${tui.bold(key)}=${displayValue}`);
|
|
58
57
|
} else {
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createResources } from '@agentuity/server';
|
|
3
|
+
import { createSubcommand as defineSubcommand } from '../../../types';
|
|
4
|
+
import * as tui from '../../../tui';
|
|
5
|
+
import { getCatalystAPIClient } from '../../../config';
|
|
6
|
+
import { getCommand } from '../../../command-prefix';
|
|
7
|
+
import { isDryRunMode, outputDryRun } from '../../../explain';
|
|
8
|
+
|
|
9
|
+
export const createSubcommand = defineSubcommand({
|
|
10
|
+
name: 'create',
|
|
11
|
+
aliases: ['new'],
|
|
12
|
+
description: 'Create a new storage resource',
|
|
13
|
+
tags: ['mutating', 'creates-resource', 'slow', 'requires-auth', 'requires-deployment'],
|
|
14
|
+
idempotent: false,
|
|
15
|
+
requires: { auth: true, org: true, region: true },
|
|
16
|
+
examples: [
|
|
17
|
+
getCommand('cloud storage create'),
|
|
18
|
+
getCommand('cloud storage new'),
|
|
19
|
+
getCommand('--dry-run cloud storage create'),
|
|
20
|
+
],
|
|
21
|
+
schema: {
|
|
22
|
+
response: z.object({
|
|
23
|
+
success: z.boolean().describe('Whether creation succeeded'),
|
|
24
|
+
name: z.string().describe('Created storage bucket name'),
|
|
25
|
+
}),
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
async handler(ctx) {
|
|
29
|
+
const { logger, orgId, region, config, auth, options } = ctx;
|
|
30
|
+
|
|
31
|
+
// Handle dry-run mode
|
|
32
|
+
if (isDryRunMode(options)) {
|
|
33
|
+
const message = `Would create storage bucket in region: ${region}`;
|
|
34
|
+
outputDryRun(message, options);
|
|
35
|
+
if (!options.json) {
|
|
36
|
+
tui.newline();
|
|
37
|
+
tui.info('[DRY RUN] Storage creation skipped');
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
success: false,
|
|
41
|
+
name: 'dry-run-bucket',
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const catalystClient = getCatalystAPIClient(config, logger, auth);
|
|
46
|
+
|
|
47
|
+
const created = await tui.spinner({
|
|
48
|
+
message: `Creating storage in ${region}`,
|
|
49
|
+
clearOnSuccess: true,
|
|
50
|
+
callback: async () => {
|
|
51
|
+
return createResources(catalystClient, orgId, region!, [{ type: 's3' }]);
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
if (created.length > 0) {
|
|
56
|
+
tui.success(`Created storage: ${tui.bold(created[0].name)}`);
|
|
57
|
+
return {
|
|
58
|
+
success: true,
|
|
59
|
+
name: created[0].name,
|
|
60
|
+
};
|
|
61
|
+
} else {
|
|
62
|
+
tui.fatal('Failed to create storage');
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
});
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { listResources, deleteResources } from '@agentuity/server';
|
|
3
|
+
import enquirer from 'enquirer';
|
|
4
|
+
import { createSubcommand } from '../../../types';
|
|
5
|
+
import * as tui from '../../../tui';
|
|
6
|
+
import { getCatalystAPIClient } from '../../../config';
|
|
7
|
+
import { getCommand } from '../../../command-prefix';
|
|
8
|
+
import { isDryRunMode, outputDryRun } from '../../../explain';
|
|
9
|
+
import { ErrorCode } from '../../../errors';
|
|
10
|
+
import { createS3Client } from './utils';
|
|
11
|
+
|
|
12
|
+
export const deleteSubcommand = createSubcommand({
|
|
13
|
+
name: 'delete',
|
|
14
|
+
aliases: ['rm', 'del', 'remove'],
|
|
15
|
+
description: 'Delete a storage resource or file',
|
|
16
|
+
tags: ['destructive', 'deletes-resource', 'slow', 'requires-auth', 'requires-deployment'],
|
|
17
|
+
idempotent: false,
|
|
18
|
+
requires: { auth: true, org: true, region: true },
|
|
19
|
+
examples: [
|
|
20
|
+
getCommand('cloud storage delete my-bucket'),
|
|
21
|
+
getCommand('cloud storage rm my-bucket file.txt'),
|
|
22
|
+
getCommand('cloud storage delete'),
|
|
23
|
+
getCommand('--dry-run cloud storage delete my-bucket'),
|
|
24
|
+
],
|
|
25
|
+
schema: {
|
|
26
|
+
args: z.object({
|
|
27
|
+
name: z.string().optional().describe('Bucket name'),
|
|
28
|
+
filename: z.string().optional().describe('File path to delete from bucket'),
|
|
29
|
+
}),
|
|
30
|
+
options: z.object({
|
|
31
|
+
confirm: z.boolean().optional().describe('Skip confirmation prompts'),
|
|
32
|
+
}),
|
|
33
|
+
response: z.object({
|
|
34
|
+
success: z.boolean().describe('Whether deletion succeeded'),
|
|
35
|
+
name: z.string().describe('Deleted bucket or file name'),
|
|
36
|
+
}),
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
async handler(ctx) {
|
|
40
|
+
const { logger, args, opts, config, orgId, region, auth, options } = ctx;
|
|
41
|
+
|
|
42
|
+
const catalystClient = getCatalystAPIClient(config, logger, auth);
|
|
43
|
+
|
|
44
|
+
const resources = await tui.spinner({
|
|
45
|
+
message: `Fetching storage for ${orgId} in ${region}`,
|
|
46
|
+
clearOnSuccess: true,
|
|
47
|
+
callback: async () => {
|
|
48
|
+
return listResources(catalystClient, orgId, region!);
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
let bucketName = args.name;
|
|
53
|
+
|
|
54
|
+
if (!bucketName) {
|
|
55
|
+
if (resources.s3.length === 0) {
|
|
56
|
+
tui.info('No storage buckets found to delete');
|
|
57
|
+
return { success: false, name: '' };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const response = await enquirer.prompt<{ bucket: string }>({
|
|
61
|
+
type: 'select',
|
|
62
|
+
name: 'bucket',
|
|
63
|
+
message: 'Select storage bucket to delete:',
|
|
64
|
+
choices: resources.s3.map((s3) => ({
|
|
65
|
+
name: s3.bucket_name,
|
|
66
|
+
message: s3.bucket_name,
|
|
67
|
+
})),
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
bucketName = response.bucket;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// If filename is provided, delete the file from the bucket
|
|
74
|
+
if (args.filename) {
|
|
75
|
+
const bucket = resources.s3.find((s3) => s3.bucket_name === bucketName);
|
|
76
|
+
|
|
77
|
+
if (!bucket) {
|
|
78
|
+
tui.fatal(`Storage bucket '${bucketName}' not found`, ErrorCode.RESOURCE_NOT_FOUND);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!bucket.access_key || !bucket.secret_key || !bucket.endpoint) {
|
|
82
|
+
tui.fatal(
|
|
83
|
+
`Storage bucket '${bucketName}' is missing credentials`,
|
|
84
|
+
ErrorCode.CONFIG_INVALID
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Handle dry-run mode
|
|
89
|
+
if (isDryRunMode(options)) {
|
|
90
|
+
outputDryRun(`Would delete file ${args.filename} from bucket ${bucketName}`, options);
|
|
91
|
+
if (!options.json) {
|
|
92
|
+
tui.newline();
|
|
93
|
+
tui.info('[DRY RUN] File deletion skipped');
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
success: false,
|
|
97
|
+
name: args.filename,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (!opts.confirm) {
|
|
102
|
+
tui.warning(
|
|
103
|
+
`You are about to delete file: ${tui.bold(args.filename)} from bucket: ${tui.bold(bucketName)}`
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
const confirm = await enquirer.prompt<{ confirm: boolean }>({
|
|
107
|
+
type: 'confirm',
|
|
108
|
+
name: 'confirm',
|
|
109
|
+
message: 'Are you sure you want to delete this file?',
|
|
110
|
+
initial: false,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
if (!confirm.confirm) {
|
|
114
|
+
tui.info('Deletion cancelled');
|
|
115
|
+
return { success: false, name: args.filename };
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const s3Client = createS3Client({
|
|
120
|
+
endpoint: bucket.endpoint,
|
|
121
|
+
access_key: bucket.access_key,
|
|
122
|
+
secret_key: bucket.secret_key,
|
|
123
|
+
region: bucket.region,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
await tui.spinner({
|
|
127
|
+
message: `Deleting ${args.filename} from ${bucketName}`,
|
|
128
|
+
clearOnSuccess: true,
|
|
129
|
+
callback: async () => {
|
|
130
|
+
await s3Client.delete(args.filename!);
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
if (!options.json) {
|
|
135
|
+
tui.success(`Deleted file: ${tui.bold(args.filename)} from ${tui.bold(bucketName)}`);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return {
|
|
139
|
+
success: true,
|
|
140
|
+
name: args.filename,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Otherwise, delete the bucket
|
|
145
|
+
// Handle dry-run mode
|
|
146
|
+
if (isDryRunMode(options)) {
|
|
147
|
+
outputDryRun(`Would delete storage bucket: ${bucketName}`, options);
|
|
148
|
+
if (!options.json) {
|
|
149
|
+
tui.newline();
|
|
150
|
+
tui.info('[DRY RUN] Storage bucket deletion skipped');
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
success: false,
|
|
154
|
+
name: bucketName,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (!opts.confirm) {
|
|
159
|
+
tui.warning(`You are about to delete storage bucket: ${tui.bold(bucketName)}`);
|
|
160
|
+
|
|
161
|
+
const confirm = await enquirer.prompt<{ confirm: boolean }>({
|
|
162
|
+
type: 'confirm',
|
|
163
|
+
name: 'confirm',
|
|
164
|
+
message: 'Are you sure you want to delete this storage bucket?',
|
|
165
|
+
initial: false,
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
if (!confirm.confirm) {
|
|
169
|
+
tui.info('Deletion cancelled');
|
|
170
|
+
return { success: false, name: bucketName };
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const deleted = await tui.spinner({
|
|
175
|
+
message: `Deleting storage bucket ${bucketName}`,
|
|
176
|
+
clearOnSuccess: true,
|
|
177
|
+
callback: async () => {
|
|
178
|
+
return deleteResources(catalystClient, orgId, region!, [
|
|
179
|
+
{ type: 's3', name: bucketName },
|
|
180
|
+
]);
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
if (deleted.length > 0) {
|
|
185
|
+
tui.success(`Deleted storage bucket: ${tui.bold(deleted[0])}`);
|
|
186
|
+
return {
|
|
187
|
+
success: true,
|
|
188
|
+
name: deleted[0],
|
|
189
|
+
};
|
|
190
|
+
} else {
|
|
191
|
+
tui.error('Failed to delete storage bucket');
|
|
192
|
+
return { success: false, name: bucketName };
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
});
|