@agentuity/cli 0.1.9 → 0.1.10
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/README.md +2 -2
- package/bin/cli.ts +8 -0
- package/dist/cache/index.d.ts +2 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +2 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/resource-region.d.ts +46 -0
- package/dist/cache/resource-region.d.ts.map +1 -0
- package/dist/cache/resource-region.js +115 -0
- package/dist/cache/resource-region.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +44 -32
- 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 +12 -15
- package/dist/cmd/ai/capabilities/show.js.map +1 -1
- package/dist/cmd/ai/prompt/llm.js +5 -5
- package/dist/cmd/ai/prompt/llm.js.map +1 -1
- package/dist/cmd/auth/logout.d.ts.map +1 -1
- package/dist/cmd/auth/logout.js +5 -2
- package/dist/cmd/auth/logout.js.map +1 -1
- package/dist/cmd/build/ast.d.ts.map +1 -1
- package/dist/cmd/build/ast.js +87 -1
- package/dist/cmd/build/ast.js.map +1 -1
- package/dist/cmd/build/vite/vite-asset-server-config.d.ts.map +1 -1
- package/dist/cmd/build/vite/vite-asset-server-config.js +8 -3
- package/dist/cmd/build/vite/vite-asset-server-config.js.map +1 -1
- package/dist/cmd/build/vite/vite-asset-server.d.ts.map +1 -1
- package/dist/cmd/build/vite/vite-asset-server.js +5 -3
- package/dist/cmd/build/vite/vite-asset-server.js.map +1 -1
- package/dist/cmd/cloud/db/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/db/delete.js +69 -11
- package/dist/cmd/cloud/db/delete.js.map +1 -1
- package/dist/cmd/cloud/db/get.d.ts.map +1 -1
- package/dist/cmd/cloud/db/get.js +23 -7
- package/dist/cmd/cloud/db/get.js.map +1 -1
- package/dist/cmd/cloud/db/list.d.ts.map +1 -1
- package/dist/cmd/cloud/db/list.js +15 -7
- package/dist/cmd/cloud/db/list.js.map +1 -1
- package/dist/cmd/cloud/db/logs.d.ts.map +1 -1
- package/dist/cmd/cloud/db/logs.js +24 -4
- package/dist/cmd/cloud/db/logs.js.map +1 -1
- package/dist/cmd/cloud/deploy.d.ts.map +1 -1
- package/dist/cmd/cloud/deploy.js +38 -0
- package/dist/cmd/cloud/deploy.js.map +1 -1
- package/dist/cmd/cloud/env/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/env/delete.js +30 -13
- package/dist/cmd/cloud/env/delete.js.map +1 -1
- package/dist/cmd/cloud/env/get.d.ts.map +1 -1
- package/dist/cmd/cloud/env/get.js +27 -30
- package/dist/cmd/cloud/env/get.js.map +1 -1
- package/dist/cmd/cloud/env/import.d.ts.map +1 -1
- package/dist/cmd/cloud/env/import.js +41 -48
- package/dist/cmd/cloud/env/import.js.map +1 -1
- package/dist/cmd/cloud/env/index.d.ts.map +1 -1
- package/dist/cmd/cloud/env/index.js +6 -2
- package/dist/cmd/cloud/env/index.js.map +1 -1
- package/dist/cmd/cloud/env/list.d.ts.map +1 -1
- package/dist/cmd/cloud/env/list.js +51 -28
- package/dist/cmd/cloud/env/list.js.map +1 -1
- package/dist/cmd/cloud/env/pull.d.ts.map +1 -1
- package/dist/cmd/cloud/env/pull.js +3 -3
- package/dist/cmd/cloud/env/pull.js.map +1 -1
- package/dist/cmd/cloud/env/push.d.ts.map +1 -1
- package/dist/cmd/cloud/env/push.js +31 -11
- package/dist/cmd/cloud/env/push.js.map +1 -1
- package/dist/cmd/cloud/env/set.d.ts.map +1 -1
- package/dist/cmd/cloud/env/set.js +41 -26
- package/dist/cmd/cloud/env/set.js.map +1 -1
- package/dist/cmd/cloud/index.d.ts.map +1 -1
- package/dist/cmd/cloud/index.js +0 -2
- package/dist/cmd/cloud/index.js.map +1 -1
- package/dist/cmd/cloud/region-lookup.d.ts +18 -0
- package/dist/cmd/cloud/region-lookup.d.ts.map +1 -0
- package/dist/cmd/cloud/region-lookup.js +64 -0
- package/dist/cmd/cloud/region-lookup.js.map +1 -0
- package/dist/cmd/cloud/sandbox/cp.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/cp.js +5 -3
- package/dist/cmd/cloud/sandbox/cp.js.map +1 -1
- package/dist/cmd/cloud/sandbox/create.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/create.js +43 -6
- package/dist/cmd/cloud/sandbox/create.js.map +1 -1
- package/dist/cmd/cloud/sandbox/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/delete.js +5 -3
- package/dist/cmd/cloud/sandbox/delete.js.map +1 -1
- package/dist/cmd/cloud/sandbox/download.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/download.js +4 -3
- package/dist/cmd/cloud/sandbox/download.js.map +1 -1
- package/dist/cmd/cloud/sandbox/env.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/env.js +4 -3
- package/dist/cmd/cloud/sandbox/env.js.map +1 -1
- package/dist/cmd/cloud/sandbox/exec.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/exec.js +4 -3
- package/dist/cmd/cloud/sandbox/exec.js.map +1 -1
- package/dist/cmd/cloud/sandbox/execution/get.js +4 -4
- package/dist/cmd/cloud/sandbox/execution/get.js.map +1 -1
- package/dist/cmd/cloud/sandbox/execution/index.js +1 -1
- package/dist/cmd/cloud/sandbox/execution/index.js.map +1 -1
- package/dist/cmd/cloud/sandbox/execution/list.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/execution/list.js +4 -3
- package/dist/cmd/cloud/sandbox/execution/list.js.map +1 -1
- package/dist/cmd/cloud/sandbox/get.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/get.js +9 -4
- package/dist/cmd/cloud/sandbox/get.js.map +1 -1
- package/dist/cmd/cloud/sandbox/index.js +1 -1
- package/dist/cmd/cloud/sandbox/index.js.map +1 -1
- package/dist/cmd/cloud/sandbox/list.js +4 -4
- package/dist/cmd/cloud/sandbox/list.js.map +1 -1
- package/dist/cmd/cloud/sandbox/ls.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/ls.js +4 -3
- package/dist/cmd/cloud/sandbox/ls.js.map +1 -1
- package/dist/cmd/cloud/sandbox/mkdir.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/mkdir.js +4 -3
- package/dist/cmd/cloud/sandbox/mkdir.js.map +1 -1
- package/dist/cmd/cloud/sandbox/rm.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/rm.js +4 -3
- package/dist/cmd/cloud/sandbox/rm.js.map +1 -1
- package/dist/cmd/cloud/sandbox/rmdir.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/rmdir.js +4 -3
- package/dist/cmd/cloud/sandbox/rmdir.js.map +1 -1
- package/dist/cmd/cloud/sandbox/run.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/run.js +44 -6
- package/dist/cmd/cloud/sandbox/run.js.map +1 -1
- package/dist/cmd/cloud/sandbox/runtime/index.js +1 -1
- package/dist/cmd/cloud/sandbox/runtime/index.js.map +1 -1
- package/dist/cmd/cloud/sandbox/runtime/list.js +4 -4
- package/dist/cmd/cloud/sandbox/runtime/list.js.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/create.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/create.js +5 -3
- package/dist/cmd/cloud/sandbox/snapshot/create.js.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/delete.js +4 -4
- package/dist/cmd/cloud/sandbox/snapshot/delete.js.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/get.js +4 -4
- package/dist/cmd/cloud/sandbox/snapshot/get.js.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/index.js +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/index.js.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/list.js +4 -4
- package/dist/cmd/cloud/sandbox/snapshot/list.js.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/tag.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/tag.js +4 -4
- package/dist/cmd/cloud/sandbox/snapshot/tag.js.map +1 -1
- package/dist/cmd/cloud/sandbox/upload.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/upload.js +4 -3
- package/dist/cmd/cloud/sandbox/upload.js.map +1 -1
- package/dist/cmd/cloud/sandbox/util.d.ts +13 -0
- package/dist/cmd/cloud/sandbox/util.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/util.js +40 -1
- package/dist/cmd/cloud/sandbox/util.js.map +1 -1
- package/dist/cmd/cloud/scp/download.d.ts.map +1 -1
- package/dist/cmd/cloud/scp/download.js +6 -2
- package/dist/cmd/cloud/scp/download.js.map +1 -1
- package/dist/cmd/cloud/scp/upload.d.ts.map +1 -1
- package/dist/cmd/cloud/scp/upload.js +6 -2
- package/dist/cmd/cloud/scp/upload.js.map +1 -1
- package/dist/cmd/cloud/session/get.js +4 -4
- package/dist/cmd/cloud/session/get.js.map +1 -1
- package/dist/cmd/cloud/session/list.js +4 -4
- package/dist/cmd/cloud/session/list.js.map +1 -1
- package/dist/cmd/cloud/ssh.d.ts.map +1 -1
- package/dist/cmd/cloud/ssh.js +7 -2
- package/dist/cmd/cloud/ssh.js.map +1 -1
- package/dist/cmd/cloud/storage/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/storage/delete.js +46 -10
- package/dist/cmd/cloud/storage/delete.js.map +1 -1
- package/dist/cmd/cloud/storage/download.d.ts.map +1 -1
- package/dist/cmd/cloud/storage/download.js +19 -6
- package/dist/cmd/cloud/storage/download.js.map +1 -1
- package/dist/cmd/cloud/storage/get.d.ts.map +1 -1
- package/dist/cmd/cloud/storage/get.js +19 -6
- package/dist/cmd/cloud/storage/get.js.map +1 -1
- package/dist/cmd/cloud/storage/list.d.ts.map +1 -1
- package/dist/cmd/cloud/storage/list.js +17 -7
- package/dist/cmd/cloud/storage/list.js.map +1 -1
- package/dist/cmd/cloud/storage/upload.d.ts.map +1 -1
- package/dist/cmd/cloud/storage/upload.js +19 -6
- package/dist/cmd/cloud/storage/upload.js.map +1 -1
- package/dist/cmd/cloud/thread/delete.js +4 -4
- package/dist/cmd/cloud/thread/delete.js.map +1 -1
- package/dist/cmd/cloud/thread/get.js +4 -4
- package/dist/cmd/cloud/thread/get.js.map +1 -1
- package/dist/cmd/cloud/thread/list.js +4 -4
- package/dist/cmd/cloud/thread/list.js.map +1 -1
- package/dist/cmd/project/auth/init.d.ts.map +1 -1
- package/dist/cmd/project/auth/init.js +6 -3
- package/dist/cmd/project/auth/init.js.map +1 -1
- package/dist/cmd/project/auth/shared.d.ts +6 -2
- package/dist/cmd/project/auth/shared.d.ts.map +1 -1
- package/dist/cmd/project/auth/shared.js +40 -12
- package/dist/cmd/project/auth/shared.js.map +1 -1
- package/dist/config.d.ts +37 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +51 -8
- package/dist/config.js.map +1 -1
- package/dist/env-util.d.ts +25 -2
- package/dist/env-util.d.ts.map +1 -1
- package/dist/env-util.js +44 -4
- package/dist/env-util.js.map +1 -1
- package/dist/utils/apt-validator.d.ts +20 -0
- package/dist/utils/apt-validator.d.ts.map +1 -0
- package/dist/utils/apt-validator.js +157 -0
- package/dist/utils/apt-validator.js.map +1 -0
- package/package.json +6 -6
- package/src/cache/index.ts +11 -0
- package/src/cache/resource-region.ts +183 -0
- package/src/cli.ts +47 -38
- package/src/cmd/ai/capabilities/show.ts +12 -15
- package/src/cmd/ai/prompt/llm.ts +5 -5
- package/src/cmd/auth/logout.ts +5 -2
- package/src/cmd/build/ast.ts +160 -1
- package/src/cmd/build/vite/vite-asset-server-config.ts +7 -3
- package/src/cmd/build/vite/vite-asset-server.ts +6 -3
- package/src/cmd/cloud/db/delete.ts +83 -11
- package/src/cmd/cloud/db/get.ts +29 -7
- package/src/cmd/cloud/db/list.ts +16 -7
- package/src/cmd/cloud/db/logs.ts +33 -4
- package/src/cmd/cloud/deploy.ts +49 -0
- package/src/cmd/cloud/env/delete.ts +36 -12
- package/src/cmd/cloud/env/get.ts +28 -27
- package/src/cmd/cloud/env/import.ts +43 -56
- package/src/cmd/cloud/env/index.ts +6 -2
- package/src/cmd/cloud/env/list.ts +57 -30
- package/src/cmd/cloud/env/pull.ts +9 -3
- package/src/cmd/cloud/env/push.ts +44 -11
- package/src/cmd/cloud/env/set.ts +49 -30
- package/src/cmd/cloud/index.ts +0 -2
- package/src/cmd/cloud/region-lookup.ts +89 -0
- package/src/cmd/cloud/sandbox/cp.ts +5 -3
- package/src/cmd/cloud/sandbox/create.ts +50 -6
- package/src/cmd/cloud/sandbox/delete.ts +6 -3
- package/src/cmd/cloud/sandbox/download.ts +4 -3
- package/src/cmd/cloud/sandbox/env.ts +4 -3
- package/src/cmd/cloud/sandbox/exec.ts +4 -3
- package/src/cmd/cloud/sandbox/execution/get.ts +4 -4
- package/src/cmd/cloud/sandbox/execution/index.ts +1 -1
- package/src/cmd/cloud/sandbox/execution/list.ts +4 -3
- package/src/cmd/cloud/sandbox/get.ts +10 -4
- package/src/cmd/cloud/sandbox/index.ts +1 -1
- package/src/cmd/cloud/sandbox/list.ts +4 -4
- package/src/cmd/cloud/sandbox/ls.ts +4 -3
- package/src/cmd/cloud/sandbox/mkdir.ts +4 -3
- package/src/cmd/cloud/sandbox/rm.ts +4 -3
- package/src/cmd/cloud/sandbox/rmdir.ts +4 -3
- package/src/cmd/cloud/sandbox/run.ts +51 -6
- package/src/cmd/cloud/sandbox/runtime/index.ts +1 -1
- package/src/cmd/cloud/sandbox/runtime/list.ts +4 -4
- package/src/cmd/cloud/sandbox/snapshot/create.ts +11 -5
- package/src/cmd/cloud/sandbox/snapshot/delete.ts +4 -4
- package/src/cmd/cloud/sandbox/snapshot/get.ts +4 -4
- package/src/cmd/cloud/sandbox/snapshot/index.ts +1 -1
- package/src/cmd/cloud/sandbox/snapshot/list.ts +4 -4
- package/src/cmd/cloud/sandbox/snapshot/tag.ts +7 -5
- package/src/cmd/cloud/sandbox/upload.ts +4 -3
- package/src/cmd/cloud/sandbox/util.ts +60 -1
- package/src/cmd/cloud/scp/download.ts +14 -2
- package/src/cmd/cloud/scp/upload.ts +14 -2
- package/src/cmd/cloud/session/get.ts +4 -4
- package/src/cmd/cloud/session/list.ts +4 -4
- package/src/cmd/cloud/ssh.ts +15 -2
- package/src/cmd/cloud/storage/delete.ts +61 -10
- package/src/cmd/cloud/storage/download.ts +31 -6
- package/src/cmd/cloud/storage/get.ts +31 -6
- package/src/cmd/cloud/storage/list.ts +18 -7
- package/src/cmd/cloud/storage/upload.ts +31 -6
- package/src/cmd/cloud/thread/delete.ts +4 -4
- package/src/cmd/cloud/thread/get.ts +4 -4
- package/src/cmd/cloud/thread/list.ts +4 -4
- package/src/cmd/project/auth/init.ts +7 -3
- package/src/cmd/project/auth/shared.ts +52 -13
- package/src/config.ts +64 -8
- package/src/env-util.ts +50 -5
- package/src/utils/apt-validator.ts +215 -0
- package/dist/cmd/cloud/secret/delete.d.ts +0 -2
- package/dist/cmd/cloud/secret/delete.d.ts.map +0 -1
- package/dist/cmd/cloud/secret/delete.js +0 -53
- package/dist/cmd/cloud/secret/delete.js.map +0 -1
- package/dist/cmd/cloud/secret/get.d.ts +0 -2
- package/dist/cmd/cloud/secret/get.d.ts.map +0 -1
- package/dist/cmd/cloud/secret/get.js +0 -73
- package/dist/cmd/cloud/secret/get.js.map +0 -1
- package/dist/cmd/cloud/secret/import.d.ts +0 -2
- package/dist/cmd/cloud/secret/import.d.ts.map +0 -1
- package/dist/cmd/cloud/secret/import.js +0 -91
- package/dist/cmd/cloud/secret/import.js.map +0 -1
- package/dist/cmd/cloud/secret/index.d.ts +0 -3
- package/dist/cmd/cloud/secret/index.d.ts.map +0 -1
- package/dist/cmd/cloud/secret/index.js +0 -33
- package/dist/cmd/cloud/secret/index.js.map +0 -1
- package/dist/cmd/cloud/secret/list.d.ts +0 -2
- package/dist/cmd/cloud/secret/list.d.ts.map +0 -1
- package/dist/cmd/cloud/secret/list.js +0 -65
- package/dist/cmd/cloud/secret/list.js.map +0 -1
- package/dist/cmd/cloud/secret/pull.d.ts +0 -2
- package/dist/cmd/cloud/secret/pull.d.ts.map +0 -1
- package/dist/cmd/cloud/secret/pull.js +0 -82
- package/dist/cmd/cloud/secret/pull.js.map +0 -1
- package/dist/cmd/cloud/secret/push.d.ts +0 -2
- package/dist/cmd/cloud/secret/push.d.ts.map +0 -1
- package/dist/cmd/cloud/secret/push.js +0 -61
- package/dist/cmd/cloud/secret/push.js.map +0 -1
- package/dist/cmd/cloud/secret/set.d.ts +0 -2
- package/dist/cmd/cloud/secret/set.d.ts.map +0 -1
- package/dist/cmd/cloud/secret/set.js +0 -63
- package/dist/cmd/cloud/secret/set.js.map +0 -1
- package/src/cmd/cloud/secret/delete.ts +0 -65
- package/src/cmd/cloud/secret/get.ts +0 -77
- package/src/cmd/cloud/secret/import.ts +0 -110
- package/src/cmd/cloud/secret/index.ts +0 -33
- package/src/cmd/cloud/secret/list.ts +0 -70
- package/src/cmd/cloud/secret/pull.ts +0 -92
- package/src/cmd/cloud/secret/push.ts +0 -69
- package/src/cmd/cloud/secret/set.ts +0 -76
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { createCommand } from '../../../types';
|
|
3
3
|
import * as tui from '../../../tui';
|
|
4
|
-
import {
|
|
4
|
+
import { cacheSandboxRegion } from './util';
|
|
5
5
|
import { getCommand } from '../../../command-prefix';
|
|
6
6
|
import { sandboxGet } from '@agentuity/server';
|
|
7
|
+
import { getGlobalCatalystAPIClient } from '../../../config';
|
|
7
8
|
|
|
8
9
|
const SandboxResourcesSchema = z.object({
|
|
9
10
|
memory: z.string().optional().describe('Memory limit (e.g., "512Mi", "1Gi")'),
|
|
@@ -35,7 +36,7 @@ export const getSubcommand = createCommand({
|
|
|
35
36
|
aliases: ['info', 'show'],
|
|
36
37
|
description: 'Get information about a sandbox',
|
|
37
38
|
tags: ['read-only', 'fast', 'requires-auth'],
|
|
38
|
-
requires: { auth: true,
|
|
39
|
+
requires: { auth: true, org: true },
|
|
39
40
|
idempotent: true,
|
|
40
41
|
examples: [
|
|
41
42
|
{
|
|
@@ -51,11 +52,16 @@ export const getSubcommand = createCommand({
|
|
|
51
52
|
},
|
|
52
53
|
|
|
53
54
|
async handler(ctx) {
|
|
54
|
-
const { args, options, auth,
|
|
55
|
-
const client =
|
|
55
|
+
const { args, options, auth, logger, orgId, config } = ctx;
|
|
56
|
+
const client = await getGlobalCatalystAPIClient(logger, auth, config?.name);
|
|
56
57
|
|
|
57
58
|
const result = await sandboxGet(client, { sandboxId: args.sandboxId, orgId });
|
|
58
59
|
|
|
60
|
+
// Cache the region for future lookups
|
|
61
|
+
if (result.region) {
|
|
62
|
+
await cacheSandboxRegion(config?.name, args.sandboxId, result.region);
|
|
63
|
+
}
|
|
64
|
+
|
|
59
65
|
if (!options.json) {
|
|
60
66
|
const statusColor =
|
|
61
67
|
result.status === 'running'
|
|
@@ -3,7 +3,7 @@ import { createCommand } from '../../../types';
|
|
|
3
3
|
import * as tui from '../../../tui';
|
|
4
4
|
import { getCommand } from '../../../command-prefix';
|
|
5
5
|
import { sandboxList } from '@agentuity/server';
|
|
6
|
-
import {
|
|
6
|
+
import { getGlobalCatalystAPIClient } from '../../../config';
|
|
7
7
|
import type { SandboxStatus } from '@agentuity/core';
|
|
8
8
|
|
|
9
9
|
const SandboxInfoSchema = z.object({
|
|
@@ -30,7 +30,7 @@ export const listSubcommand = createCommand({
|
|
|
30
30
|
aliases: ['ls'],
|
|
31
31
|
description: 'List sandboxes with optional filtering',
|
|
32
32
|
tags: ['read-only', 'slow', 'requires-auth'],
|
|
33
|
-
requires: { auth: true,
|
|
33
|
+
requires: { auth: true, org: true },
|
|
34
34
|
optional: { project: true },
|
|
35
35
|
idempotent: true,
|
|
36
36
|
pagination: {
|
|
@@ -74,8 +74,8 @@ export const listSubcommand = createCommand({
|
|
|
74
74
|
},
|
|
75
75
|
|
|
76
76
|
async handler(ctx) {
|
|
77
|
-
const { opts, options, auth, project,
|
|
78
|
-
const client =
|
|
77
|
+
const { opts, options, auth, project, logger, orgId, config } = ctx;
|
|
78
|
+
const client = await getGlobalCatalystAPIClient(logger, auth, config?.name);
|
|
79
79
|
|
|
80
80
|
const projectId = opts.projectId || project?.projectId;
|
|
81
81
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { createCommand } from '../../../types';
|
|
3
3
|
import * as tui from '../../../tui';
|
|
4
|
-
import { createSandboxClient } from './util';
|
|
4
|
+
import { getSandboxRegion, createSandboxClient } from './util';
|
|
5
5
|
import { getCommand } from '../../../command-prefix';
|
|
6
6
|
import { sandboxListFiles } from '@agentuity/server';
|
|
7
7
|
|
|
@@ -23,7 +23,7 @@ export const lsSubcommand = createCommand({
|
|
|
23
23
|
aliases: ['lsf'],
|
|
24
24
|
description: 'List files in a sandbox directory',
|
|
25
25
|
tags: ['slow', 'requires-auth'],
|
|
26
|
-
requires: { auth: true,
|
|
26
|
+
requires: { auth: true, org: true },
|
|
27
27
|
examples: [
|
|
28
28
|
{
|
|
29
29
|
command: getCommand('cloud sandbox files sbx_abc123'),
|
|
@@ -61,7 +61,8 @@ export const lsSubcommand = createCommand({
|
|
|
61
61
|
},
|
|
62
62
|
|
|
63
63
|
async handler(ctx) {
|
|
64
|
-
const { args, opts, options, auth,
|
|
64
|
+
const { args, opts, options, auth, config, logger, orgId } = ctx;
|
|
65
|
+
const region = await getSandboxRegion(logger, auth, config?.name, args.sandboxId, orgId);
|
|
65
66
|
const client = createSandboxClient(logger, auth, region);
|
|
66
67
|
|
|
67
68
|
const result = await sandboxListFiles(client, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { createCommand } from '../../../types';
|
|
3
3
|
import * as tui from '../../../tui';
|
|
4
|
-
import { createSandboxClient } from './util';
|
|
4
|
+
import { createSandboxClient, getSandboxRegion } from './util';
|
|
5
5
|
import { getCommand } from '../../../command-prefix';
|
|
6
6
|
import { sandboxMkDir } from '@agentuity/server';
|
|
7
7
|
|
|
@@ -14,7 +14,7 @@ export const mkdirSubcommand = createCommand({
|
|
|
14
14
|
name: 'mkdir',
|
|
15
15
|
description: 'Create a directory in a sandbox',
|
|
16
16
|
tags: ['slow', 'requires-auth'],
|
|
17
|
-
requires: { auth: true,
|
|
17
|
+
requires: { auth: true, org: true },
|
|
18
18
|
examples: [
|
|
19
19
|
{
|
|
20
20
|
command: getCommand('cloud sandbox mkdir sbx_abc123 /path/to/dir'),
|
|
@@ -44,7 +44,8 @@ export const mkdirSubcommand = createCommand({
|
|
|
44
44
|
},
|
|
45
45
|
|
|
46
46
|
async handler(ctx) {
|
|
47
|
-
const { args, opts, options, auth,
|
|
47
|
+
const { args, opts, options, auth, logger, orgId, config } = ctx;
|
|
48
|
+
const region = await getSandboxRegion(logger, auth, config?.name, args.sandboxId, orgId);
|
|
48
49
|
const client = createSandboxClient(logger, auth, region);
|
|
49
50
|
|
|
50
51
|
await sandboxMkDir(client, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { createCommand } from '../../../types';
|
|
3
3
|
import * as tui from '../../../tui';
|
|
4
|
-
import { createSandboxClient } from './util';
|
|
4
|
+
import { getSandboxRegion, createSandboxClient } from './util';
|
|
5
5
|
import { getCommand } from '../../../command-prefix';
|
|
6
6
|
import { sandboxRmFile } from '@agentuity/server';
|
|
7
7
|
|
|
@@ -14,7 +14,7 @@ export const rmSubcommand = createCommand({
|
|
|
14
14
|
name: 'rm',
|
|
15
15
|
description: 'Remove a file from a sandbox',
|
|
16
16
|
tags: ['slow', 'requires-auth'],
|
|
17
|
-
requires: { auth: true,
|
|
17
|
+
requires: { auth: true, org: true },
|
|
18
18
|
examples: [
|
|
19
19
|
{
|
|
20
20
|
command: getCommand('cloud sandbox rm sbx_abc123 /path/to/file.txt'),
|
|
@@ -31,7 +31,8 @@ export const rmSubcommand = createCommand({
|
|
|
31
31
|
},
|
|
32
32
|
|
|
33
33
|
async handler(ctx) {
|
|
34
|
-
const { args, options, auth,
|
|
34
|
+
const { args, options, auth, logger, orgId, config } = ctx;
|
|
35
|
+
const region = await getSandboxRegion(logger, auth, config?.name, args.sandboxId, orgId);
|
|
35
36
|
const client = createSandboxClient(logger, auth, region);
|
|
36
37
|
|
|
37
38
|
await sandboxRmFile(client, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { createCommand } from '../../../types';
|
|
3
3
|
import * as tui from '../../../tui';
|
|
4
|
-
import { createSandboxClient } from './util';
|
|
4
|
+
import { createSandboxClient, getSandboxRegion } from './util';
|
|
5
5
|
import { getCommand } from '../../../command-prefix';
|
|
6
6
|
import { sandboxRmDir } from '@agentuity/server';
|
|
7
7
|
|
|
@@ -14,7 +14,7 @@ export const rmdirSubcommand = createCommand({
|
|
|
14
14
|
name: 'rmdir',
|
|
15
15
|
description: 'Remove a directory from a sandbox',
|
|
16
16
|
tags: ['slow', 'requires-auth'],
|
|
17
|
-
requires: { auth: true,
|
|
17
|
+
requires: { auth: true, org: true },
|
|
18
18
|
examples: [
|
|
19
19
|
{
|
|
20
20
|
command: getCommand('cloud sandbox rmdir sbx_abc123 /path/to/dir'),
|
|
@@ -44,7 +44,8 @@ export const rmdirSubcommand = createCommand({
|
|
|
44
44
|
},
|
|
45
45
|
|
|
46
46
|
async handler(ctx) {
|
|
47
|
-
const { args, opts, options, auth,
|
|
47
|
+
const { args, opts, options, auth, logger, orgId, config } = ctx;
|
|
48
|
+
const region = await getSandboxRegion(logger, auth, config?.name, args.sandboxId, orgId);
|
|
48
49
|
const client = createSandboxClient(logger, auth, region);
|
|
49
50
|
|
|
50
51
|
await sandboxRmDir(client, {
|
|
@@ -2,9 +2,11 @@ import { z } from 'zod';
|
|
|
2
2
|
import { Writable } from 'node:stream';
|
|
3
3
|
import { createCommand } from '../../../types';
|
|
4
4
|
import * as tui from '../../../tui';
|
|
5
|
-
import { createSandboxClient, parseFileArgs } from './util';
|
|
5
|
+
import { createSandboxClient, parseFileArgs, cacheSandboxRegion } from './util';
|
|
6
6
|
import { getCommand } from '../../../command-prefix';
|
|
7
7
|
import { sandboxRun } from '@agentuity/server';
|
|
8
|
+
import { validateAptDependencies } from '../../../utils/apt-validator';
|
|
9
|
+
import { ErrorCode } from '../../../errors';
|
|
8
10
|
|
|
9
11
|
const SandboxRunResponseSchema = z.object({
|
|
10
12
|
sandboxId: z.string().describe('Sandbox ID'),
|
|
@@ -37,10 +39,7 @@ export const runSubcommand = createCommand({
|
|
|
37
39
|
command: z.array(z.string()).describe('Command and arguments to execute'),
|
|
38
40
|
}),
|
|
39
41
|
options: z.object({
|
|
40
|
-
runtime: z
|
|
41
|
-
.string()
|
|
42
|
-
.optional()
|
|
43
|
-
.describe('Runtime name (e.g., "bun:1", "python:3.14")'),
|
|
42
|
+
runtime: z.string().optional().describe('Runtime name (e.g., "bun:1", "python:3.14")'),
|
|
44
43
|
runtimeId: z.string().optional().describe('Runtime ID (e.g., "srt_xxx")'),
|
|
45
44
|
name: z.string().optional().describe('Sandbox name'),
|
|
46
45
|
description: z.string().optional().describe('Sandbox description'),
|
|
@@ -69,10 +68,53 @@ export const runSubcommand = createCommand({
|
|
|
69
68
|
},
|
|
70
69
|
|
|
71
70
|
async handler(ctx) {
|
|
72
|
-
const { args, opts, options, auth, region, logger, orgId } = ctx;
|
|
71
|
+
const { args, opts, options, auth, region, config, logger, orgId } = ctx;
|
|
73
72
|
const client = createSandboxClient(logger, auth, region);
|
|
74
73
|
const started = Date.now();
|
|
75
74
|
|
|
75
|
+
// Validate apt dependencies before running sandbox
|
|
76
|
+
if (opts.dependency && opts.dependency.length > 0) {
|
|
77
|
+
const aptValidation = await tui.spinner({
|
|
78
|
+
message: 'Validating apt dependencies...',
|
|
79
|
+
type: 'simple',
|
|
80
|
+
callback: async () => {
|
|
81
|
+
return await validateAptDependencies(opts.dependency!, region, config, logger);
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
if (aptValidation.invalid.length > 0) {
|
|
86
|
+
if (options.json) {
|
|
87
|
+
return {
|
|
88
|
+
sandboxId: '',
|
|
89
|
+
exitCode: 1,
|
|
90
|
+
durationMs: 0,
|
|
91
|
+
errors: aptValidation.invalid.map((pkg) => ({
|
|
92
|
+
type: 'invalid-apt-dependency',
|
|
93
|
+
package: pkg.package,
|
|
94
|
+
error: pkg.error,
|
|
95
|
+
searchUrl: pkg.searchUrl,
|
|
96
|
+
availableVersions: pkg.availableVersions,
|
|
97
|
+
})),
|
|
98
|
+
} as never;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
tui.error('Invalid apt dependencies:');
|
|
102
|
+
tui.newline();
|
|
103
|
+
for (const pkg of aptValidation.invalid) {
|
|
104
|
+
tui.bullet(`${tui.bold(pkg.package)}: ${pkg.error}`);
|
|
105
|
+
if (pkg.availableVersions && pkg.availableVersions.length > 0) {
|
|
106
|
+
tui.muted(` Available versions: ${pkg.availableVersions.join(', ')}`);
|
|
107
|
+
}
|
|
108
|
+
tui.muted(` Search: ${tui.link(pkg.searchUrl)}`);
|
|
109
|
+
}
|
|
110
|
+
tui.newline();
|
|
111
|
+
tui.fatal(
|
|
112
|
+
'Fix the apt dependencies and try again. Search for valid packages at: https://packages.debian.org/stable/',
|
|
113
|
+
ErrorCode.CONFIG_INVALID
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
76
118
|
const envMap: Record<string, string> = {};
|
|
77
119
|
if (opts.env) {
|
|
78
120
|
for (const e of opts.env) {
|
|
@@ -142,6 +184,9 @@ export const runSubcommand = createCommand({
|
|
|
142
184
|
logger,
|
|
143
185
|
});
|
|
144
186
|
|
|
187
|
+
// Cache the region for future lookups (sandbox is destroyed after run but cache helps with lookups during execution)
|
|
188
|
+
await cacheSandboxRegion(config?.name, result.sandboxId, region);
|
|
189
|
+
|
|
145
190
|
const duration = Date.now() - started;
|
|
146
191
|
const output = outputChunks.join('');
|
|
147
192
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { createCommand } from '../../../../types';
|
|
3
3
|
import * as tui from '../../../../tui';
|
|
4
|
-
import { createSandboxClient } from '../util';
|
|
5
4
|
import { getCommand } from '../../../../command-prefix';
|
|
6
5
|
import { runtimeList } from '@agentuity/server';
|
|
6
|
+
import { getGlobalCatalystAPIClient } from '../../../../config';
|
|
7
7
|
|
|
8
8
|
const RuntimeInfoSchema = z.object({
|
|
9
9
|
id: z.string().describe('Runtime ID'),
|
|
@@ -21,7 +21,7 @@ export const listSubcommand = createCommand({
|
|
|
21
21
|
aliases: ['ls'],
|
|
22
22
|
description: 'List available sandbox runtimes',
|
|
23
23
|
tags: ['read-only', 'slow', 'requires-auth'],
|
|
24
|
-
requires: { auth: true,
|
|
24
|
+
requires: { auth: true, org: true },
|
|
25
25
|
idempotent: true,
|
|
26
26
|
examples: [
|
|
27
27
|
{
|
|
@@ -38,8 +38,8 @@ export const listSubcommand = createCommand({
|
|
|
38
38
|
},
|
|
39
39
|
|
|
40
40
|
async handler(ctx) {
|
|
41
|
-
const { opts, options, auth,
|
|
42
|
-
const client =
|
|
41
|
+
const { opts, options, auth, logger, orgId, config } = ctx;
|
|
42
|
+
const client = await getGlobalCatalystAPIClient(logger, auth, config?.name);
|
|
43
43
|
|
|
44
44
|
const result = await runtimeList(client, {
|
|
45
45
|
orgId,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { createCommand } from '../../../../types';
|
|
3
3
|
import * as tui from '../../../../tui';
|
|
4
|
-
import { createSandboxClient } from '../util';
|
|
4
|
+
import { getSandboxRegion, createSandboxClient } from '../util';
|
|
5
5
|
import { getCommand } from '../../../../command-prefix';
|
|
6
6
|
import { snapshotCreate } from '@agentuity/server';
|
|
7
7
|
|
|
@@ -23,7 +23,7 @@ export const createSubcommand = createCommand({
|
|
|
23
23
|
name: 'create',
|
|
24
24
|
description: 'Create a snapshot from a sandbox',
|
|
25
25
|
tags: ['slow', 'requires-auth'],
|
|
26
|
-
requires: { auth: true,
|
|
26
|
+
requires: { auth: true, org: true },
|
|
27
27
|
examples: [
|
|
28
28
|
{
|
|
29
29
|
command: getCommand('cloud sandbox snapshot create sbx_abc123'),
|
|
@@ -34,7 +34,9 @@ export const createSubcommand = createCommand({
|
|
|
34
34
|
description: 'Create a tagged snapshot',
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
|
-
command: getCommand(
|
|
37
|
+
command: getCommand(
|
|
38
|
+
'cloud sandbox snapshot create sbx_abc123 --name "My Snapshot" --description "Initial setup"'
|
|
39
|
+
),
|
|
38
40
|
description: 'Create a named snapshot with description',
|
|
39
41
|
},
|
|
40
42
|
],
|
|
@@ -54,7 +56,7 @@ export const createSubcommand = createCommand({
|
|
|
54
56
|
},
|
|
55
57
|
|
|
56
58
|
async handler(ctx) {
|
|
57
|
-
const { args, opts, options, auth,
|
|
59
|
+
const { args, opts, options, auth, logger, orgId, config } = ctx;
|
|
58
60
|
|
|
59
61
|
if (opts.name && !SNAPSHOT_NAME_REGEX.test(opts.name)) {
|
|
60
62
|
logger.fatal(
|
|
@@ -64,7 +66,9 @@ export const createSubcommand = createCommand({
|
|
|
64
66
|
|
|
65
67
|
if (opts.tag) {
|
|
66
68
|
if (opts.tag.length > MAX_SNAPSHOT_TAG_LENGTH) {
|
|
67
|
-
logger.fatal(
|
|
69
|
+
logger.fatal(
|
|
70
|
+
`Invalid snapshot tag: must be at most ${MAX_SNAPSHOT_TAG_LENGTH} characters`
|
|
71
|
+
);
|
|
68
72
|
}
|
|
69
73
|
if (!SNAPSHOT_TAG_REGEX.test(opts.tag)) {
|
|
70
74
|
logger.fatal(
|
|
@@ -73,6 +77,8 @@ export const createSubcommand = createCommand({
|
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
79
|
|
|
80
|
+
const profileName = config?.name;
|
|
81
|
+
const region = await getSandboxRegion(logger, auth, profileName, args.sandboxId, orgId);
|
|
76
82
|
const client = createSandboxClient(logger, auth, region);
|
|
77
83
|
|
|
78
84
|
const snapshot = await snapshotCreate(client, {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { createCommand } from '../../../../types';
|
|
3
3
|
import * as tui from '../../../../tui';
|
|
4
|
-
import { createSandboxClient } from '../util';
|
|
5
4
|
import { getCommand } from '../../../../command-prefix';
|
|
6
5
|
import { snapshotDelete } from '@agentuity/server';
|
|
6
|
+
import { getGlobalCatalystAPIClient } from '../../../../config';
|
|
7
7
|
|
|
8
8
|
const SnapshotDeleteResponseSchema = z.object({
|
|
9
9
|
success: z.boolean().describe('Whether the operation succeeded'),
|
|
@@ -16,7 +16,7 @@ export const deleteSubcommand = createCommand({
|
|
|
16
16
|
aliases: ['del', 'rm', 'remove'],
|
|
17
17
|
description: 'Delete a snapshot',
|
|
18
18
|
tags: ['destructive', 'deletes-resource', 'slow', 'requires-auth'],
|
|
19
|
-
requires: { auth: true,
|
|
19
|
+
requires: { auth: true, org: true },
|
|
20
20
|
idempotent: true,
|
|
21
21
|
examples: [
|
|
22
22
|
{
|
|
@@ -39,7 +39,7 @@ export const deleteSubcommand = createCommand({
|
|
|
39
39
|
},
|
|
40
40
|
|
|
41
41
|
async handler(ctx) {
|
|
42
|
-
const { args, options, opts, auth,
|
|
42
|
+
const { args, options, opts, auth, logger, orgId, config } = ctx;
|
|
43
43
|
|
|
44
44
|
if (!opts.confirm) {
|
|
45
45
|
const confirmed = await tui.confirm(`Delete snapshot "${args.snapshotId}"?`, false);
|
|
@@ -53,7 +53,7 @@ export const deleteSubcommand = createCommand({
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
const client =
|
|
56
|
+
const client = await getGlobalCatalystAPIClient(logger, auth, config?.name);
|
|
57
57
|
|
|
58
58
|
await snapshotDelete(client, {
|
|
59
59
|
snapshotId: args.snapshotId,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { createCommand } from '../../../../types';
|
|
3
3
|
import * as tui from '../../../../tui';
|
|
4
|
-
import { createSandboxClient } from '../util';
|
|
5
4
|
import { getCommand } from '../../../../command-prefix';
|
|
6
5
|
import { snapshotGet, sandboxList } from '@agentuity/server';
|
|
7
6
|
import type { SnapshotFileInfo } from '@agentuity/server';
|
|
8
7
|
import type { SandboxInfo } from '@agentuity/core';
|
|
8
|
+
import { getGlobalCatalystAPIClient } from '../../../../config';
|
|
9
9
|
|
|
10
10
|
const SnapshotFileSchema = z.object({
|
|
11
11
|
path: z.string(),
|
|
@@ -39,7 +39,7 @@ export const getSubcommand = createCommand({
|
|
|
39
39
|
aliases: ['info', 'show'],
|
|
40
40
|
description: 'Get snapshot details',
|
|
41
41
|
tags: ['slow', 'requires-auth'],
|
|
42
|
-
requires: { auth: true,
|
|
42
|
+
requires: { auth: true, org: true },
|
|
43
43
|
examples: [
|
|
44
44
|
{
|
|
45
45
|
command: getCommand('cloud sandbox snapshot get snp_abc123'),
|
|
@@ -54,8 +54,8 @@ export const getSubcommand = createCommand({
|
|
|
54
54
|
},
|
|
55
55
|
|
|
56
56
|
async handler(ctx) {
|
|
57
|
-
const { args, options, auth,
|
|
58
|
-
const client =
|
|
57
|
+
const { args, options, auth, logger, orgId, config } = ctx;
|
|
58
|
+
const client = await getGlobalCatalystAPIClient(logger, auth, config?.name);
|
|
59
59
|
|
|
60
60
|
const snapshot = await snapshotGet(client, {
|
|
61
61
|
snapshotId: args.snapshotId,
|
|
@@ -22,7 +22,7 @@ export const snapshotCommand = createCommand({
|
|
|
22
22
|
},
|
|
23
23
|
],
|
|
24
24
|
subcommands: [createSubcommand, listSubcommand, getSubcommand, deleteSubcommand, tagSubcommand],
|
|
25
|
-
requires: { auth: true,
|
|
25
|
+
requires: { auth: true, org: true },
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
export default snapshotCommand;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { createCommand } from '../../../../types';
|
|
3
3
|
import * as tui from '../../../../tui';
|
|
4
|
-
import { createSandboxClient } from '../util';
|
|
5
4
|
import { getCommand } from '../../../../command-prefix';
|
|
6
5
|
import { snapshotList } from '@agentuity/server';
|
|
6
|
+
import { getGlobalCatalystAPIClient } from '../../../../config';
|
|
7
7
|
|
|
8
8
|
const SnapshotInfoSchema = z.object({
|
|
9
9
|
snapshotId: z.string(),
|
|
@@ -26,7 +26,7 @@ export const listSubcommand = createCommand({
|
|
|
26
26
|
aliases: ['ls'],
|
|
27
27
|
description: 'List snapshots',
|
|
28
28
|
tags: ['slow', 'requires-auth'],
|
|
29
|
-
requires: { auth: true,
|
|
29
|
+
requires: { auth: true, org: true },
|
|
30
30
|
examples: [
|
|
31
31
|
{
|
|
32
32
|
command: getCommand('cloud sandbox snapshot list'),
|
|
@@ -47,8 +47,8 @@ export const listSubcommand = createCommand({
|
|
|
47
47
|
},
|
|
48
48
|
|
|
49
49
|
async handler(ctx) {
|
|
50
|
-
const { opts, options, auth,
|
|
51
|
-
const client =
|
|
50
|
+
const { opts, options, auth, logger, orgId, config } = ctx;
|
|
51
|
+
const client = await getGlobalCatalystAPIClient(logger, auth, config?.name);
|
|
52
52
|
|
|
53
53
|
const result = await snapshotList(client, {
|
|
54
54
|
sandboxId: opts.sandbox,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { createCommand } from '../../../../types';
|
|
3
3
|
import * as tui from '../../../../tui';
|
|
4
|
-
import { createSandboxClient } from '../util';
|
|
5
4
|
import { getCommand } from '../../../../command-prefix';
|
|
6
5
|
import { snapshotTag } from '@agentuity/server';
|
|
6
|
+
import { getGlobalCatalystAPIClient } from '../../../../config';
|
|
7
7
|
|
|
8
8
|
const SNAPSHOT_TAG_REGEX = /^[a-zA-Z0-9_][a-zA-Z0-9._-]*$/;
|
|
9
9
|
const MAX_SNAPSHOT_TAG_LENGTH = 128;
|
|
@@ -17,7 +17,7 @@ export const tagSubcommand = createCommand({
|
|
|
17
17
|
name: 'tag',
|
|
18
18
|
description: 'Add or update a tag on a snapshot',
|
|
19
19
|
tags: ['slow', 'requires-auth'],
|
|
20
|
-
requires: { auth: true,
|
|
20
|
+
requires: { auth: true, org: true },
|
|
21
21
|
examples: [
|
|
22
22
|
{
|
|
23
23
|
command: getCommand('cloud sandbox snapshot tag snp_abc123 latest'),
|
|
@@ -40,8 +40,8 @@ export const tagSubcommand = createCommand({
|
|
|
40
40
|
},
|
|
41
41
|
|
|
42
42
|
async handler(ctx) {
|
|
43
|
-
const { args, opts, options, auth,
|
|
44
|
-
const client =
|
|
43
|
+
const { args, opts, options, auth, logger, orgId, config } = ctx;
|
|
44
|
+
const client = await getGlobalCatalystAPIClient(logger, auth, config?.name);
|
|
45
45
|
|
|
46
46
|
if (!args.tag && !opts.clear) {
|
|
47
47
|
throw new Error('Either provide a tag name or use --clear to remove the tag');
|
|
@@ -49,7 +49,9 @@ export const tagSubcommand = createCommand({
|
|
|
49
49
|
|
|
50
50
|
if (args.tag) {
|
|
51
51
|
if (args.tag.length > MAX_SNAPSHOT_TAG_LENGTH) {
|
|
52
|
-
logger.fatal(
|
|
52
|
+
logger.fatal(
|
|
53
|
+
`Invalid snapshot tag: must be at most ${MAX_SNAPSHOT_TAG_LENGTH} characters`
|
|
54
|
+
);
|
|
53
55
|
}
|
|
54
56
|
if (!SNAPSHOT_TAG_REGEX.test(args.tag)) {
|
|
55
57
|
logger.fatal(
|
|
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { readFileSync, statSync } from 'node:fs';
|
|
3
3
|
import { createCommand } from '../../../types';
|
|
4
4
|
import * as tui from '../../../tui';
|
|
5
|
-
import { createSandboxClient } from './util';
|
|
5
|
+
import { createSandboxClient, getSandboxRegion } from './util';
|
|
6
6
|
import { getCommand } from '../../../command-prefix';
|
|
7
7
|
import { sandboxUploadArchive } from '@agentuity/server';
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ export const uploadSubcommand = createCommand({
|
|
|
11
11
|
aliases: ['ul'],
|
|
12
12
|
description: 'Upload a compressed archive to a sandbox and extract it',
|
|
13
13
|
tags: ['slow', 'requires-auth'],
|
|
14
|
-
requires: { auth: true,
|
|
14
|
+
requires: { auth: true, org: true },
|
|
15
15
|
examples: [
|
|
16
16
|
{
|
|
17
17
|
command: getCommand('cloud sandbox upload sbx_abc123 ./archive.tar.gz'),
|
|
@@ -45,8 +45,9 @@ export const uploadSubcommand = createCommand({
|
|
|
45
45
|
},
|
|
46
46
|
|
|
47
47
|
async handler(ctx) {
|
|
48
|
-
const { args, opts, options, auth,
|
|
48
|
+
const { args, opts, options, auth, logger, orgId, config } = ctx;
|
|
49
49
|
|
|
50
|
+
const region = await getSandboxRegion(logger, auth, config?.name, args.sandboxId, orgId);
|
|
50
51
|
const client = createSandboxClient(logger, auth, region);
|
|
51
52
|
|
|
52
53
|
const stat = statSync(args.archive);
|
|
@@ -1,14 +1,73 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import type { Logger, FileToWrite } from '@agentuity/core';
|
|
4
|
-
import { APIClient, getServiceUrls } from '@agentuity/server';
|
|
4
|
+
import { APIClient, getServiceUrls, sandboxGet } from '@agentuity/server';
|
|
5
5
|
import type { AuthData } from '../../../types';
|
|
6
|
+
import { getGlobalCatalystAPIClient } from '../../../config';
|
|
7
|
+
import { getResourceRegion, setResourceRegion, deleteResourceRegion } from '../../../cache';
|
|
8
|
+
import * as tui from '../../../tui';
|
|
9
|
+
import { ErrorCode } from '../../../errors';
|
|
6
10
|
|
|
7
11
|
export function createSandboxClient(logger: Logger, auth: AuthData, region: string): APIClient {
|
|
8
12
|
const urls = getServiceUrls(region);
|
|
9
13
|
return new APIClient(urls.catalyst, logger, auth.apiKey);
|
|
10
14
|
}
|
|
11
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Look up the region for a sandbox, using cache-first strategy.
|
|
18
|
+
* Falls back to API lookup if not in cache.
|
|
19
|
+
*/
|
|
20
|
+
export async function getSandboxRegion(
|
|
21
|
+
logger: Logger,
|
|
22
|
+
auth: AuthData,
|
|
23
|
+
profileName = 'production',
|
|
24
|
+
sandboxId: string,
|
|
25
|
+
orgId: string
|
|
26
|
+
): Promise<string> {
|
|
27
|
+
// Check cache first
|
|
28
|
+
const cachedRegion = await getResourceRegion('sandbox', profileName, sandboxId);
|
|
29
|
+
if (cachedRegion) {
|
|
30
|
+
logger.trace(`[sandbox] Found cached region for ${sandboxId}: ${cachedRegion}`);
|
|
31
|
+
return cachedRegion;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Fallback to API lookup using global client
|
|
35
|
+
logger.trace(`[sandbox] Cache miss for ${sandboxId}, fetching from API`);
|
|
36
|
+
const globalClient = await getGlobalCatalystAPIClient(logger, auth, profileName);
|
|
37
|
+
|
|
38
|
+
const sandbox = await sandboxGet(globalClient, { sandboxId, orgId });
|
|
39
|
+
if (!sandbox.region) {
|
|
40
|
+
tui.fatal(`Sandbox '${sandboxId}' has no region information`, ErrorCode.RESOURCE_NOT_FOUND);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Cache the result
|
|
44
|
+
await setResourceRegion('sandbox', profileName, sandboxId, sandbox.region);
|
|
45
|
+
logger.trace(`[sandbox] Cached region for ${sandboxId}: ${sandbox.region}`);
|
|
46
|
+
|
|
47
|
+
return sandbox.region;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Cache the region for a sandbox after create/run operations
|
|
52
|
+
*/
|
|
53
|
+
export async function cacheSandboxRegion(
|
|
54
|
+
profileName = 'production',
|
|
55
|
+
sandboxId: string,
|
|
56
|
+
region: string
|
|
57
|
+
): Promise<void> {
|
|
58
|
+
await setResourceRegion('sandbox', profileName, sandboxId, region);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Clear cached region for a sandbox after delete
|
|
63
|
+
*/
|
|
64
|
+
export async function clearSandboxRegionCache(
|
|
65
|
+
profileName = 'production',
|
|
66
|
+
sandboxId: string
|
|
67
|
+
): Promise<void> {
|
|
68
|
+
await deleteResourceRegion('sandbox', profileName, sandboxId);
|
|
69
|
+
}
|
|
70
|
+
|
|
12
71
|
/**
|
|
13
72
|
* Parse --file arguments and read file contents.
|
|
14
73
|
*
|