@agentuity/cli 0.0.43 → 0.0.45
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/AGENTS.md +1 -1
- package/README.md +1 -1
- package/dist/api.d.ts +3 -3
- package/dist/api.d.ts.map +1 -1
- package/dist/auth.d.ts +10 -2
- package/dist/auth.d.ts.map +1 -1
- package/dist/banner.d.ts.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cmd/auth/api.d.ts +4 -4
- package/dist/cmd/auth/api.d.ts.map +1 -1
- package/dist/cmd/auth/index.d.ts.map +1 -1
- package/dist/cmd/auth/login.d.ts.map +1 -1
- package/dist/cmd/auth/signup.d.ts.map +1 -1
- package/dist/cmd/auth/ssh/add.d.ts +2 -0
- package/dist/cmd/auth/ssh/add.d.ts.map +1 -0
- package/dist/cmd/auth/ssh/api.d.ts +16 -0
- package/dist/cmd/auth/ssh/api.d.ts.map +1 -0
- package/dist/cmd/auth/ssh/delete.d.ts +2 -0
- package/dist/cmd/auth/ssh/delete.d.ts.map +1 -0
- package/dist/cmd/auth/ssh/index.d.ts +3 -0
- package/dist/cmd/auth/ssh/index.d.ts.map +1 -0
- package/dist/cmd/auth/ssh/list.d.ts +2 -0
- package/dist/cmd/auth/ssh/list.d.ts.map +1 -0
- package/dist/cmd/auth/whoami.d.ts.map +1 -1
- package/dist/cmd/bundle/ast.d.ts +14 -3
- package/dist/cmd/bundle/ast.d.ts.map +1 -1
- package/dist/cmd/bundle/ast.test.d.ts +2 -0
- package/dist/cmd/bundle/ast.test.d.ts.map +1 -0
- package/dist/cmd/bundle/bundler.d.ts +6 -1
- package/dist/cmd/bundle/bundler.d.ts.map +1 -1
- package/dist/cmd/bundle/file.d.ts.map +1 -1
- package/dist/cmd/bundle/fix-duplicate-exports.d.ts +2 -0
- package/dist/cmd/bundle/fix-duplicate-exports.d.ts.map +1 -0
- package/dist/cmd/bundle/fix-duplicate-exports.test.d.ts +2 -0
- package/dist/cmd/bundle/fix-duplicate-exports.test.d.ts.map +1 -0
- package/dist/cmd/bundle/plugin.d.ts +2 -0
- package/dist/cmd/bundle/plugin.d.ts.map +1 -1
- package/dist/cmd/cloud/deploy.d.ts.map +1 -1
- package/dist/cmd/cloud/domain.d.ts +17 -0
- package/dist/cmd/cloud/domain.d.ts.map +1 -0
- package/dist/cmd/cloud/index.d.ts.map +1 -1
- package/dist/cmd/cloud/resource/add.d.ts +2 -0
- package/dist/cmd/cloud/resource/add.d.ts.map +1 -0
- package/dist/cmd/cloud/resource/delete.d.ts +2 -0
- package/dist/cmd/cloud/resource/delete.d.ts.map +1 -0
- package/dist/cmd/cloud/resource/index.d.ts +3 -0
- package/dist/cmd/cloud/resource/index.d.ts.map +1 -0
- package/dist/cmd/cloud/resource/list.d.ts +2 -0
- package/dist/cmd/cloud/resource/list.d.ts.map +1 -0
- package/dist/cmd/cloud/scp/download.d.ts +2 -0
- package/dist/cmd/cloud/scp/download.d.ts.map +1 -0
- package/dist/cmd/cloud/scp/index.d.ts +3 -0
- package/dist/cmd/cloud/scp/index.d.ts.map +1 -0
- package/dist/cmd/cloud/scp/upload.d.ts +2 -0
- package/dist/cmd/cloud/scp/upload.d.ts.map +1 -0
- package/dist/cmd/cloud/ssh.d.ts +2 -0
- package/dist/cmd/cloud/ssh.d.ts.map +1 -0
- package/dist/cmd/dev/api.d.ts +18 -0
- package/dist/cmd/dev/api.d.ts.map +1 -0
- package/dist/cmd/dev/download.d.ts +11 -0
- package/dist/cmd/dev/download.d.ts.map +1 -0
- package/dist/cmd/dev/index.d.ts.map +1 -1
- package/dist/cmd/dev/templates.d.ts +3 -0
- package/dist/cmd/dev/templates.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/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/profile/show.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/list.d.ts.map +1 -1
- package/dist/cmd/project/show.d.ts.map +1 -1
- package/dist/cmd/project/template-flow.d.ts +4 -0
- package/dist/cmd/project/template-flow.d.ts.map +1 -1
- 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/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/config.d.ts +9 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/crypto/box.d.ts +65 -0
- package/dist/crypto/box.d.ts.map +1 -0
- package/dist/crypto/box.test.d.ts +2 -0
- package/dist/crypto/box.test.d.ts.map +1 -0
- package/dist/download.d.ts.map +1 -1
- package/dist/steps.d.ts +4 -1
- package/dist/steps.d.ts.map +1 -1
- package/dist/terminal.d.ts.map +1 -1
- package/dist/tui.d.ts +31 -1
- package/dist/tui.d.ts.map +1 -1
- package/dist/types.d.ts +249 -126
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/detectSubagent.d.ts +15 -0
- package/dist/utils/detectSubagent.d.ts.map +1 -0
- package/dist/utils/zip.d.ts +7 -0
- package/dist/utils/zip.d.ts.map +1 -0
- package/package.json +11 -3
- package/src/api-errors.md +2 -2
- package/src/api.ts +12 -7
- package/src/auth.ts +116 -7
- package/src/banner.ts +13 -6
- package/src/cli.ts +695 -63
- package/src/cmd/auth/api.ts +10 -16
- package/src/cmd/auth/index.ts +2 -1
- package/src/cmd/auth/login.ts +24 -8
- package/src/cmd/auth/signup.ts +15 -11
- package/src/cmd/auth/ssh/add.ts +263 -0
- package/src/cmd/auth/ssh/api.ts +94 -0
- package/src/cmd/auth/ssh/delete.ts +102 -0
- package/src/cmd/auth/ssh/index.ts +10 -0
- package/src/cmd/auth/ssh/list.ts +74 -0
- package/src/cmd/auth/whoami.ts +13 -13
- package/src/cmd/bundle/ast.test.ts +565 -0
- package/src/cmd/bundle/ast.ts +457 -44
- package/src/cmd/bundle/bundler.ts +255 -57
- package/src/cmd/bundle/file.ts +6 -12
- package/src/cmd/bundle/fix-duplicate-exports.test.ts +387 -0
- package/src/cmd/bundle/fix-duplicate-exports.ts +204 -0
- package/src/cmd/bundle/index.ts +9 -9
- package/src/cmd/bundle/patch/aisdk.ts +1 -1
- package/src/cmd/bundle/plugin.ts +373 -53
- package/src/cmd/cloud/deploy.ts +300 -93
- package/src/cmd/cloud/domain.ts +92 -0
- package/src/cmd/cloud/index.ts +4 -1
- package/src/cmd/cloud/resource/add.ts +56 -0
- package/src/cmd/cloud/resource/delete.ts +120 -0
- package/src/cmd/cloud/resource/index.ts +11 -0
- package/src/cmd/cloud/resource/list.ts +69 -0
- package/src/cmd/cloud/scp/download.ts +59 -0
- package/src/cmd/cloud/scp/index.ts +9 -0
- package/src/cmd/cloud/scp/upload.ts +62 -0
- package/src/cmd/cloud/ssh.ts +68 -0
- package/src/cmd/dev/api.ts +46 -0
- package/src/cmd/dev/download.ts +111 -0
- package/src/cmd/dev/index.ts +360 -34
- package/src/cmd/dev/templates.ts +84 -0
- package/src/cmd/env/delete.ts +5 -20
- package/src/cmd/env/get.ts +5 -18
- package/src/cmd/env/import.ts +5 -20
- package/src/cmd/env/list.ts +5 -18
- package/src/cmd/env/pull.ts +10 -23
- package/src/cmd/env/push.ts +5 -23
- package/src/cmd/env/set.ts +5 -20
- package/src/cmd/index.ts +2 -2
- package/src/cmd/profile/show.ts +15 -6
- package/src/cmd/project/create.ts +7 -2
- package/src/cmd/project/delete.ts +75 -18
- package/src/cmd/project/download.ts +2 -2
- package/src/cmd/project/list.ts +8 -8
- package/src/cmd/project/show.ts +3 -7
- package/src/cmd/project/template-flow.ts +170 -72
- package/src/cmd/secret/delete.ts +5 -20
- package/src/cmd/secret/get.ts +5 -18
- package/src/cmd/secret/import.ts +5 -20
- package/src/cmd/secret/list.ts +5 -18
- package/src/cmd/secret/pull.ts +10 -23
- package/src/cmd/secret/push.ts +5 -23
- package/src/cmd/secret/set.ts +5 -20
- package/src/config.ts +224 -24
- package/src/crypto/box.test.ts +431 -0
- package/src/crypto/box.ts +477 -0
- package/src/download.ts +1 -0
- package/src/env-util.test.ts +1 -1
- package/src/steps.ts +65 -6
- package/src/terminal.ts +24 -23
- package/src/tui.ts +192 -61
- package/src/types.ts +291 -201
- package/src/utils/detectSubagent.ts +31 -0
- package/src/utils/zip.ts +38 -0
- package/dist/cmd/example/create-user.d.ts +0 -2
- package/dist/cmd/example/create-user.d.ts.map +0 -1
- package/dist/cmd/example/create.d.ts +0 -2
- package/dist/cmd/example/create.d.ts.map +0 -1
- package/dist/cmd/example/deploy.d.ts +0 -2
- package/dist/cmd/example/deploy.d.ts.map +0 -1
- package/dist/cmd/example/index.d.ts +0 -2
- package/dist/cmd/example/index.d.ts.map +0 -1
- package/dist/cmd/example/list.d.ts +0 -2
- package/dist/cmd/example/list.d.ts.map +0 -1
- package/dist/cmd/example/optional-auth.d.ts +0 -3
- package/dist/cmd/example/optional-auth.d.ts.map +0 -1
- package/dist/cmd/example/run-command.d.ts +0 -2
- package/dist/cmd/example/run-command.d.ts.map +0 -1
- package/dist/cmd/example/sound.d.ts +0 -3
- package/dist/cmd/example/sound.d.ts.map +0 -1
- package/dist/cmd/example/spinner.d.ts +0 -2
- package/dist/cmd/example/spinner.d.ts.map +0 -1
- package/dist/cmd/example/steps.d.ts +0 -2
- package/dist/cmd/example/steps.d.ts.map +0 -1
- package/dist/cmd/example/version.d.ts +0 -2
- package/dist/cmd/example/version.d.ts.map +0 -1
- package/src/cmd/example/create-user.ts +0 -38
- package/src/cmd/example/create.ts +0 -31
- package/src/cmd/example/deploy.ts +0 -36
- package/src/cmd/example/index.ts +0 -29
- package/src/cmd/example/list.ts +0 -32
- package/src/cmd/example/optional-auth.ts +0 -38
- package/src/cmd/example/run-command.ts +0 -45
- package/src/cmd/example/sound.ts +0 -14
- package/src/cmd/example/spinner.ts +0 -44
- package/src/cmd/example/steps.ts +0 -66
- package/src/cmd/example/version.ts +0 -13
package/src/auth.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import enquirer from 'enquirer';
|
|
3
|
-
import { getDefaultConfigDir, getAuth, saveConfig, loadConfig } from './config';
|
|
3
|
+
import { getDefaultConfigDir, getAuth, saveConfig, loadConfig, saveOrgId } from './config';
|
|
4
4
|
import { getCommand } from './command-prefix';
|
|
5
5
|
import type { CommandContext, AuthData } from './types';
|
|
6
6
|
import * as tui from './tui';
|
|
7
|
+
import { defaultProfileName } from './config';
|
|
8
|
+
import { listOrganizations } from '@agentuity/server';
|
|
9
|
+
import { APIClient, getAPIBaseURL, type APIClient as APIClientType } from './api';
|
|
7
10
|
|
|
8
11
|
export function isTTY(): boolean {
|
|
9
12
|
return process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
@@ -22,7 +25,7 @@ export async function isAuthenticated(): Promise<boolean> {
|
|
|
22
25
|
return auth.expires > new Date();
|
|
23
26
|
}
|
|
24
27
|
|
|
25
|
-
export async function requireAuth(ctx: CommandContext<
|
|
28
|
+
export async function requireAuth(ctx: CommandContext<undefined>): Promise<AuthData> {
|
|
26
29
|
const { logger } = ctx;
|
|
27
30
|
const auth = await getAuth();
|
|
28
31
|
|
|
@@ -69,7 +72,17 @@ export async function requireAuth(ctx: CommandContext<false>): Promise<AuthData>
|
|
|
69
72
|
|
|
70
73
|
// Import and run login flow
|
|
71
74
|
const { loginCommand } = await import('./cmd/auth/login');
|
|
72
|
-
|
|
75
|
+
|
|
76
|
+
// Ensure apiClient is available for login handler
|
|
77
|
+
const loginCtx = ctx as unknown as Record<string, unknown>;
|
|
78
|
+
if (!loginCtx.apiClient) {
|
|
79
|
+
const apiUrl = getAPIBaseURL(ctx.config ?? null);
|
|
80
|
+
loginCtx.apiClient = new APIClient(apiUrl, ctx.logger, ctx.config ?? null);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (loginCommand.handler) {
|
|
84
|
+
await loginCommand.handler(loginCtx as CommandContext);
|
|
85
|
+
}
|
|
73
86
|
|
|
74
87
|
// After login completes, verify we have auth
|
|
75
88
|
const newAuth = await getAuth();
|
|
@@ -82,7 +95,7 @@ export async function requireAuth(ctx: CommandContext<false>): Promise<AuthData>
|
|
|
82
95
|
}
|
|
83
96
|
|
|
84
97
|
export async function optionalAuth(
|
|
85
|
-
ctx: CommandContext<
|
|
98
|
+
ctx: CommandContext<undefined>,
|
|
86
99
|
continueText?: string
|
|
87
100
|
): Promise<AuthData | null> {
|
|
88
101
|
const auth = await getAuth();
|
|
@@ -103,7 +116,7 @@ export async function optionalAuth(
|
|
|
103
116
|
tui.showSignupBenefits();
|
|
104
117
|
|
|
105
118
|
if (!config) {
|
|
106
|
-
ctx.config = { name:
|
|
119
|
+
ctx.config = { name: defaultProfileName };
|
|
107
120
|
} else {
|
|
108
121
|
ctx.config = config;
|
|
109
122
|
}
|
|
@@ -141,7 +154,17 @@ export async function optionalAuth(
|
|
|
141
154
|
|
|
142
155
|
// Import and run login flow
|
|
143
156
|
const { loginCommand } = await import('./cmd/auth/login');
|
|
144
|
-
|
|
157
|
+
|
|
158
|
+
// Ensure apiClient is available for login handler
|
|
159
|
+
const loginCtx1 = ctx as unknown as Record<string, unknown>;
|
|
160
|
+
if (!loginCtx1.apiClient) {
|
|
161
|
+
const apiUrl = getAPIBaseURL(ctx.config ?? null);
|
|
162
|
+
loginCtx1.apiClient = new APIClient(apiUrl, ctx.logger, ctx.config ?? null);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (loginCommand.handler) {
|
|
166
|
+
await loginCommand.handler(loginCtx1 as CommandContext);
|
|
167
|
+
}
|
|
145
168
|
return getAuth();
|
|
146
169
|
}
|
|
147
170
|
|
|
@@ -173,10 +196,96 @@ export async function optionalAuth(
|
|
|
173
196
|
|
|
174
197
|
// Import and run login flow
|
|
175
198
|
const { loginCommand } = await import('./cmd/auth/login');
|
|
176
|
-
|
|
199
|
+
|
|
200
|
+
// Ensure apiClient is available for login handler
|
|
201
|
+
const loginCtx2 = ctx as unknown as Record<string, unknown>;
|
|
202
|
+
if (!loginCtx2.apiClient) {
|
|
203
|
+
const apiUrl = getAPIBaseURL(ctx.config ?? null);
|
|
204
|
+
loginCtx2.apiClient = new APIClient(apiUrl, ctx.logger, ctx.config ?? null);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (loginCommand.handler) {
|
|
208
|
+
await loginCommand.handler(loginCtx2 as CommandContext);
|
|
209
|
+
}
|
|
177
210
|
return getAuth();
|
|
178
211
|
}
|
|
179
212
|
}
|
|
180
213
|
|
|
181
214
|
return null;
|
|
182
215
|
}
|
|
216
|
+
|
|
217
|
+
export async function requireOrg(
|
|
218
|
+
ctx: CommandContext & { apiClient: APIClientType }
|
|
219
|
+
): Promise<string> {
|
|
220
|
+
const { options, config, apiClient } = ctx;
|
|
221
|
+
|
|
222
|
+
// Check if org is provided via --org-id flag
|
|
223
|
+
if (options.orgId) {
|
|
224
|
+
return options.orgId;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Check if org is saved in config preferences
|
|
228
|
+
if (config?.preferences?.orgId) {
|
|
229
|
+
return config.preferences.orgId;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Fetch organizations
|
|
233
|
+
const orgs = await tui.spinner('Fetching organizations', async () => {
|
|
234
|
+
return listOrganizations(apiClient);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
if (orgs.length === 0) {
|
|
238
|
+
tui.fatal('No organizations found for your account');
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Use selectOrganization which handles single org and prompting
|
|
242
|
+
// Pass the saved preference as initial selection
|
|
243
|
+
const orgId = await tui.selectOrganization(orgs, config?.preferences?.orgId);
|
|
244
|
+
|
|
245
|
+
// Save selected org to config if different
|
|
246
|
+
if (orgId !== config?.preferences?.orgId) {
|
|
247
|
+
await saveOrgId(orgId);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return orgId;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export async function optionalOrg(
|
|
254
|
+
ctx: CommandContext & { apiClient?: APIClientType; auth?: AuthData }
|
|
255
|
+
): Promise<string | undefined> {
|
|
256
|
+
const { options, config, apiClient, auth } = ctx;
|
|
257
|
+
|
|
258
|
+
// If not authenticated or no API client, skip org selection
|
|
259
|
+
if (!auth || !apiClient) {
|
|
260
|
+
return undefined;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// Check if org is provided via --org-id flag
|
|
264
|
+
if (options.orgId) {
|
|
265
|
+
return options.orgId;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Check if org is saved in config preferences
|
|
269
|
+
if (config?.preferences?.orgId) {
|
|
270
|
+
return config.preferences.orgId;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Fetch organizations
|
|
274
|
+
const orgs = await tui.spinner('Fetching organizations', async () => {
|
|
275
|
+
return listOrganizations(apiClient);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
if (orgs.length === 0) {
|
|
279
|
+
return undefined;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// Use selectOrganization which handles single org and prompting
|
|
283
|
+
const orgId = await tui.selectOrganization(orgs, config?.preferences?.orgId);
|
|
284
|
+
|
|
285
|
+
// Save selected org to config if different
|
|
286
|
+
if (orgId !== config?.preferences?.orgId) {
|
|
287
|
+
await saveOrgId(orgId);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
return orgId;
|
|
291
|
+
}
|
package/src/banner.ts
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { getVersion } from './version';
|
|
2
|
-
|
|
3
|
-
function shouldUseColors(): boolean {
|
|
4
|
-
return !process.env.NO_COLOR && process.env.TERM !== 'dumb' && !!process.stdout.isTTY;
|
|
5
|
-
}
|
|
2
|
+
import { shouldUseColors, isDarkMode } from './tui';
|
|
6
3
|
|
|
7
4
|
export function showBanner(version?: string): void {
|
|
8
5
|
const _version = version ?? getVersion();
|
|
9
6
|
const USE_COLORS = shouldUseColors();
|
|
10
|
-
const
|
|
7
|
+
const dark = isDarkMode();
|
|
8
|
+
const CYAN = USE_COLORS
|
|
9
|
+
? dark
|
|
10
|
+
? Bun.color('cyan', 'ansi-16m')
|
|
11
|
+
: Bun.color('#008B8B', 'ansi-16m')
|
|
12
|
+
: '';
|
|
13
|
+
const WHITE = USE_COLORS
|
|
14
|
+
? dark
|
|
15
|
+
? Bun.color('white', 'ansi-16m')
|
|
16
|
+
: Bun.color('black', 'ansi-16m')
|
|
17
|
+
: '';
|
|
11
18
|
const RESET = USE_COLORS ? '\x1b[0m' : '';
|
|
12
19
|
|
|
13
20
|
const width = 52; // Content width between pipes
|
|
@@ -16,7 +23,7 @@ export function showBanner(version?: string): void {
|
|
|
16
23
|
|
|
17
24
|
const lines = [
|
|
18
25
|
'╭────────────────────────────────────────────────────╮',
|
|
19
|
-
|
|
26
|
+
`│ ⨺ Agentuity ${WHITE}Build, manage and deploy AI agents${CYAN} │`,
|
|
20
27
|
'│ │',
|
|
21
28
|
`│${versionLabel}${_version.padEnd(versionPadding)} │`,
|
|
22
29
|
'│ Docs: https://agentuity.dev │',
|