@agentuity/cli 0.1.19 → 0.1.21

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.
Files changed (168) hide show
  1. package/dist/cmd/auth/index.d.ts.map +1 -1
  2. package/dist/cmd/auth/index.js +2 -0
  3. package/dist/cmd/auth/index.js.map +1 -1
  4. package/dist/cmd/auth/machine/index.d.ts +2 -0
  5. package/dist/cmd/auth/machine/index.d.ts.map +1 -0
  6. package/dist/cmd/auth/machine/index.js +16 -0
  7. package/dist/cmd/auth/machine/index.js.map +1 -0
  8. package/dist/cmd/auth/machine/setup.d.ts +2 -0
  9. package/dist/cmd/auth/machine/setup.d.ts.map +1 -0
  10. package/dist/cmd/auth/machine/setup.js +87 -0
  11. package/dist/cmd/auth/machine/setup.js.map +1 -0
  12. package/dist/cmd/cloud/db/index.js +1 -1
  13. package/dist/cmd/cloud/db/index.js.map +1 -1
  14. package/dist/cmd/cloud/index.d.ts.map +1 -1
  15. package/dist/cmd/cloud/index.js +2 -0
  16. package/dist/cmd/cloud/index.js.map +1 -1
  17. package/dist/cmd/cloud/keyvalue/create-namespace.d.ts.map +1 -1
  18. package/dist/cmd/cloud/keyvalue/create-namespace.js +2 -1
  19. package/dist/cmd/cloud/keyvalue/create-namespace.js.map +1 -1
  20. package/dist/cmd/cloud/keyvalue/delete-namespace.d.ts.map +1 -1
  21. package/dist/cmd/cloud/keyvalue/delete-namespace.js +2 -1
  22. package/dist/cmd/cloud/keyvalue/delete-namespace.js.map +1 -1
  23. package/dist/cmd/cloud/keyvalue/delete.d.ts.map +1 -1
  24. package/dist/cmd/cloud/keyvalue/delete.js +2 -1
  25. package/dist/cmd/cloud/keyvalue/delete.js.map +1 -1
  26. package/dist/cmd/cloud/keyvalue/get.d.ts.map +1 -1
  27. package/dist/cmd/cloud/keyvalue/get.js +2 -1
  28. package/dist/cmd/cloud/keyvalue/get.js.map +1 -1
  29. package/dist/cmd/cloud/keyvalue/keys.d.ts.map +1 -1
  30. package/dist/cmd/cloud/keyvalue/keys.js +2 -1
  31. package/dist/cmd/cloud/keyvalue/keys.js.map +1 -1
  32. package/dist/cmd/cloud/keyvalue/list-namespaces.d.ts.map +1 -1
  33. package/dist/cmd/cloud/keyvalue/list-namespaces.js +2 -1
  34. package/dist/cmd/cloud/keyvalue/list-namespaces.js.map +1 -1
  35. package/dist/cmd/cloud/keyvalue/repl.js +1 -1
  36. package/dist/cmd/cloud/keyvalue/repl.js.map +1 -1
  37. package/dist/cmd/cloud/keyvalue/search.d.ts.map +1 -1
  38. package/dist/cmd/cloud/keyvalue/search.js +2 -1
  39. package/dist/cmd/cloud/keyvalue/search.js.map +1 -1
  40. package/dist/cmd/cloud/keyvalue/set.d.ts.map +1 -1
  41. package/dist/cmd/cloud/keyvalue/set.js +2 -1
  42. package/dist/cmd/cloud/keyvalue/set.js.map +1 -1
  43. package/dist/cmd/cloud/keyvalue/stats.d.ts.map +1 -1
  44. package/dist/cmd/cloud/keyvalue/stats.js +2 -1
  45. package/dist/cmd/cloud/keyvalue/stats.js.map +1 -1
  46. package/dist/cmd/cloud/keyvalue/util.d.ts +5 -6
  47. package/dist/cmd/cloud/keyvalue/util.d.ts.map +1 -1
  48. package/dist/cmd/cloud/keyvalue/util.js +8 -4
  49. package/dist/cmd/cloud/keyvalue/util.js.map +1 -1
  50. package/dist/cmd/cloud/machine/delete.d.ts +2 -0
  51. package/dist/cmd/cloud/machine/delete.d.ts.map +1 -0
  52. package/dist/cmd/cloud/machine/delete.js +84 -0
  53. package/dist/cmd/cloud/machine/delete.js.map +1 -0
  54. package/dist/cmd/cloud/machine/deployments.d.ts +2 -0
  55. package/dist/cmd/cloud/machine/deployments.d.ts.map +1 -0
  56. package/dist/cmd/cloud/machine/deployments.js +86 -0
  57. package/dist/cmd/cloud/machine/deployments.js.map +1 -0
  58. package/dist/cmd/cloud/machine/get.d.ts +2 -0
  59. package/dist/cmd/cloud/machine/get.d.ts.map +1 -0
  60. package/dist/cmd/cloud/machine/get.js +104 -0
  61. package/dist/cmd/cloud/machine/get.js.map +1 -0
  62. package/dist/cmd/cloud/machine/index.d.ts +2 -0
  63. package/dist/cmd/cloud/machine/index.d.ts.map +1 -0
  64. package/dist/cmd/cloud/machine/index.js +22 -0
  65. package/dist/cmd/cloud/machine/index.js.map +1 -0
  66. package/dist/cmd/cloud/machine/list.d.ts +2 -0
  67. package/dist/cmd/cloud/machine/list.d.ts.map +1 -0
  68. package/dist/cmd/cloud/machine/list.js +73 -0
  69. package/dist/cmd/cloud/machine/list.js.map +1 -0
  70. package/dist/cmd/cloud/queue/index.js +1 -1
  71. package/dist/cmd/cloud/queue/index.js.map +1 -1
  72. package/dist/cmd/cloud/redis/index.js +1 -1
  73. package/dist/cmd/cloud/redis/index.js.map +1 -1
  74. package/dist/cmd/cloud/sandbox/get.d.ts.map +1 -1
  75. package/dist/cmd/cloud/sandbox/get.js +25 -18
  76. package/dist/cmd/cloud/sandbox/get.js.map +1 -1
  77. package/dist/cmd/cloud/sandbox/index.js +1 -1
  78. package/dist/cmd/cloud/sandbox/index.js.map +1 -1
  79. package/dist/cmd/cloud/sandbox/list.d.ts.map +1 -1
  80. package/dist/cmd/cloud/sandbox/list.js +40 -9
  81. package/dist/cmd/cloud/sandbox/list.js.map +1 -1
  82. package/dist/cmd/cloud/sandbox/snapshot/get.d.ts.map +1 -1
  83. package/dist/cmd/cloud/sandbox/snapshot/get.js +16 -0
  84. package/dist/cmd/cloud/sandbox/snapshot/get.js.map +1 -1
  85. package/dist/cmd/cloud/storage/index.js +1 -1
  86. package/dist/cmd/cloud/storage/index.js.map +1 -1
  87. package/dist/cmd/cloud/stream/index.js +1 -1
  88. package/dist/cmd/cloud/stream/index.js.map +1 -1
  89. package/dist/cmd/cloud/vector/delete-namespace.d.ts.map +1 -1
  90. package/dist/cmd/cloud/vector/delete-namespace.js +2 -1
  91. package/dist/cmd/cloud/vector/delete-namespace.js.map +1 -1
  92. package/dist/cmd/cloud/vector/delete.d.ts.map +1 -1
  93. package/dist/cmd/cloud/vector/delete.js +2 -1
  94. package/dist/cmd/cloud/vector/delete.js.map +1 -1
  95. package/dist/cmd/cloud/vector/get.d.ts.map +1 -1
  96. package/dist/cmd/cloud/vector/get.js +2 -1
  97. package/dist/cmd/cloud/vector/get.js.map +1 -1
  98. package/dist/cmd/cloud/vector/index.js +1 -1
  99. package/dist/cmd/cloud/vector/index.js.map +1 -1
  100. package/dist/cmd/cloud/vector/list-namespaces.d.ts.map +1 -1
  101. package/dist/cmd/cloud/vector/list-namespaces.js +2 -1
  102. package/dist/cmd/cloud/vector/list-namespaces.js.map +1 -1
  103. package/dist/cmd/cloud/vector/search.d.ts.map +1 -1
  104. package/dist/cmd/cloud/vector/search.js +2 -1
  105. package/dist/cmd/cloud/vector/search.js.map +1 -1
  106. package/dist/cmd/cloud/vector/stats.d.ts.map +1 -1
  107. package/dist/cmd/cloud/vector/stats.js +2 -1
  108. package/dist/cmd/cloud/vector/stats.js.map +1 -1
  109. package/dist/cmd/cloud/vector/upsert.d.ts.map +1 -1
  110. package/dist/cmd/cloud/vector/upsert.js +2 -1
  111. package/dist/cmd/cloud/vector/upsert.js.map +1 -1
  112. package/dist/cmd/cloud/vector/util.d.ts +7 -8
  113. package/dist/cmd/cloud/vector/util.d.ts.map +1 -1
  114. package/dist/cmd/cloud/vector/util.js +7 -7
  115. package/dist/cmd/cloud/vector/util.js.map +1 -1
  116. package/dist/cmd/setup/index.d.ts.map +1 -1
  117. package/dist/cmd/setup/index.js +7 -2
  118. package/dist/cmd/setup/index.js.map +1 -1
  119. package/dist/config.d.ts +7 -2
  120. package/dist/config.d.ts.map +1 -1
  121. package/dist/config.js +13 -4
  122. package/dist/config.js.map +1 -1
  123. package/dist/env-util.d.ts +1 -1
  124. package/dist/env-util.d.ts.map +1 -1
  125. package/dist/env-util.js +1 -1
  126. package/dist/env-util.js.map +1 -1
  127. package/package.json +6 -6
  128. package/src/cmd/auth/index.ts +2 -0
  129. package/src/cmd/auth/machine/index.ts +16 -0
  130. package/src/cmd/auth/machine/setup.ts +104 -0
  131. package/src/cmd/cloud/db/index.ts +1 -1
  132. package/src/cmd/cloud/index.ts +2 -0
  133. package/src/cmd/cloud/keyvalue/create-namespace.ts +2 -1
  134. package/src/cmd/cloud/keyvalue/delete-namespace.ts +2 -1
  135. package/src/cmd/cloud/keyvalue/delete.ts +2 -1
  136. package/src/cmd/cloud/keyvalue/get.ts +2 -1
  137. package/src/cmd/cloud/keyvalue/keys.ts +2 -1
  138. package/src/cmd/cloud/keyvalue/list-namespaces.ts +2 -1
  139. package/src/cmd/cloud/keyvalue/repl.ts +1 -1
  140. package/src/cmd/cloud/keyvalue/search.ts +2 -1
  141. package/src/cmd/cloud/keyvalue/set.ts +2 -1
  142. package/src/cmd/cloud/keyvalue/stats.ts +2 -1
  143. package/src/cmd/cloud/keyvalue/util.ts +15 -7
  144. package/src/cmd/cloud/machine/delete.ts +91 -0
  145. package/src/cmd/cloud/machine/deployments.ts +94 -0
  146. package/src/cmd/cloud/machine/get.ts +110 -0
  147. package/src/cmd/cloud/machine/index.ts +22 -0
  148. package/src/cmd/cloud/machine/list.ts +80 -0
  149. package/src/cmd/cloud/queue/index.ts +1 -1
  150. package/src/cmd/cloud/redis/index.ts +1 -1
  151. package/src/cmd/cloud/sandbox/get.ts +28 -19
  152. package/src/cmd/cloud/sandbox/index.ts +1 -1
  153. package/src/cmd/cloud/sandbox/list.ts +44 -9
  154. package/src/cmd/cloud/sandbox/snapshot/get.ts +18 -0
  155. package/src/cmd/cloud/storage/index.ts +1 -1
  156. package/src/cmd/cloud/stream/index.ts +1 -1
  157. package/src/cmd/cloud/vector/delete-namespace.ts +2 -1
  158. package/src/cmd/cloud/vector/delete.ts +2 -1
  159. package/src/cmd/cloud/vector/get.ts +2 -1
  160. package/src/cmd/cloud/vector/index.ts +1 -1
  161. package/src/cmd/cloud/vector/list-namespaces.ts +2 -1
  162. package/src/cmd/cloud/vector/search.ts +2 -1
  163. package/src/cmd/cloud/vector/stats.ts +2 -1
  164. package/src/cmd/cloud/vector/upsert.ts +2 -1
  165. package/src/cmd/cloud/vector/util.ts +15 -12
  166. package/src/cmd/setup/index.ts +7 -2
  167. package/src/config.ts +19 -4
  168. package/src/env-util.ts +1 -1
@@ -13,7 +13,8 @@ export const keysSubcommand = createCommand({
13
13
  aliases: ['ls', 'list'],
14
14
  description: 'List all keys in a keyvalue namespace',
15
15
  tags: ['read-only', 'slow', 'requires-auth'],
16
- requires: { auth: true },
16
+ requires: { auth: true, region: true },
17
+ optional: { project: true },
17
18
  idempotent: true,
18
19
  examples: [
19
20
  { command: getCommand('kv keys production'), description: 'List all keys in production' },
@@ -10,7 +10,8 @@ export const listNamespacesSubcommand = createCommand({
10
10
  aliases: ['namespaces', 'ns'],
11
11
  description: 'List all keyvalue namespaces',
12
12
  tags: ['read-only', 'fast', 'requires-auth'],
13
- requires: { auth: true },
13
+ requires: { auth: true, region: true },
14
+ optional: { project: true },
14
15
  examples: [
15
16
  { command: getCommand('kv list-namespaces'), description: 'List all namespaces' },
16
17
  { command: getCommand('kv namespaces'), description: 'List namespaces (using alias)' },
@@ -11,7 +11,7 @@ export const replSubcommand = createCommand({
11
11
  description: 'Start an interactive repl for working with keyvalue database',
12
12
  tags: ['slow', 'requires-auth'],
13
13
  idempotent: false,
14
- requires: { auth: true },
14
+ requires: { auth: true, region: true },
15
15
  optional: { project: true },
16
16
  examples: [{ command: getCommand('kv repl'), description: 'Start interactive KV session' }],
17
17
 
@@ -20,7 +20,8 @@ export const searchSubcommand = createCommand({
20
20
  name: 'search',
21
21
  description: 'Search for keys matching a keyword in a keyvalue namespace',
22
22
  tags: ['read-only', 'slow', 'requires-auth'],
23
- requires: { auth: true },
23
+ requires: { auth: true, region: true },
24
+ optional: { project: true },
24
25
  idempotent: true,
25
26
  examples: [
26
27
  {
@@ -19,7 +19,8 @@ export const setSubcommand = createCommand({
19
19
  description: 'Set a key and value in the keyvalue storage',
20
20
  tags: ['mutating', 'updates-resource', 'slow', 'requires-auth'],
21
21
  idempotent: true,
22
- requires: { auth: true },
22
+ requires: { auth: true, region: true },
23
+ optional: { project: true },
23
24
  examples: [
24
25
  {
25
26
  command: getCommand(
@@ -26,7 +26,8 @@ export const statsSubcommand = createCommand({
26
26
  name: 'stats',
27
27
  description: 'Get statistics for keyvalue storage',
28
28
  tags: ['read-only', 'fast', 'requires-auth'],
29
- requires: { auth: true },
29
+ requires: { auth: true, region: true },
30
+ optional: { project: true },
30
31
  idempotent: true,
31
32
  examples: [
32
33
  { command: getCommand('kv stats'), description: 'Show stats for all namespaces' },
@@ -1,25 +1,33 @@
1
1
  import { KeyValueStorageService, type Logger } from '@agentuity/core';
2
2
  import { createServerFetchAdapter, getServiceUrls } from '@agentuity/server';
3
- import { getDefaultRegion } from '../../../config';
4
- import type { AuthData, Config } from '../../../types';
3
+ import type { AuthData, GlobalOptions, ProjectConfig } from '../../../types';
4
+ import * as tui from '../../../tui';
5
5
 
6
- export async function createStorageAdapter(ctx: {
6
+ export function createStorageAdapter(ctx: {
7
7
  logger: Logger;
8
- config: Config | null;
9
8
  auth: AuthData;
10
- project?: { region: string };
9
+ region: string;
10
+ project?: ProjectConfig;
11
+ options: GlobalOptions;
11
12
  }) {
13
+ const orgId = ctx.project?.orgId ?? ctx.options.orgId;
14
+ if (!orgId) {
15
+ tui.fatal(
16
+ 'Organization ID is required. Either run from a project directory or use --org-id flag.'
17
+ );
18
+ }
19
+
12
20
  const adapter = createServerFetchAdapter(
13
21
  {
14
22
  headers: {
15
23
  Authorization: `Bearer ${ctx.auth.apiKey}`,
24
+ 'x-agentuity-orgid': orgId,
16
25
  },
17
26
  },
18
27
  ctx.logger
19
28
  );
20
29
 
21
- const region = ctx.project?.region || (await getDefaultRegion(ctx.config?.name, ctx.config));
22
- const urls = getServiceUrls(region);
30
+ const urls = getServiceUrls(ctx.region);
23
31
  const baseUrl = urls.catalyst;
24
32
  return new KeyValueStorageService(baseUrl, adapter);
25
33
  }
@@ -0,0 +1,91 @@
1
+ import { z } from 'zod';
2
+ import { createSubcommand } from '../../../types';
3
+ import * as tui from '../../../tui';
4
+ import { machineDelete, machineGet } from '@agentuity/server';
5
+ import { getCommand } from '../../../command-prefix';
6
+ import { ErrorCode } from '../../../errors';
7
+ import { getGlobalCatalystAPIClient } from '../../../config';
8
+ import enquirer from 'enquirer';
9
+
10
+ const MachineDeleteResponseSchema = z.object({
11
+ success: z.boolean().describe('Whether the deletion succeeded'),
12
+ machineId: z.string().describe('The deleted machine ID'),
13
+ });
14
+
15
+ export const deleteSubcommand = createSubcommand({
16
+ name: 'delete',
17
+ description: 'Delete an organization managed machine',
18
+ tags: ['mutating', 'destructive', 'slow', 'requires-auth'],
19
+ examples: [
20
+ {
21
+ command: `${getCommand('cloud machine delete')} mach_abc123xyz`,
22
+ description: 'Delete a machine (with confirmation)',
23
+ },
24
+ {
25
+ command: `${getCommand('cloud machine delete')} mach_abc123xyz --confirm`,
26
+ description: 'Delete a machine without confirmation',
27
+ },
28
+ ],
29
+ aliases: ['rm', 'remove'],
30
+ requires: { auth: true, org: true },
31
+ idempotent: false,
32
+ schema: {
33
+ args: z.object({
34
+ machine_id: z.string().describe('Machine ID'),
35
+ }),
36
+ options: z.object({
37
+ confirm: z.boolean().optional().default(false).describe('Skip confirmation prompt'),
38
+ }),
39
+ response: MachineDeleteResponseSchema,
40
+ },
41
+ async handler(ctx) {
42
+ const { args, opts, options, logger, auth, config, orgId } = ctx;
43
+
44
+ const catalystClient = await getGlobalCatalystAPIClient(logger, auth, config?.name, orgId);
45
+
46
+ try {
47
+ const machine = await machineGet(catalystClient, args.machine_id);
48
+
49
+ if (!opts.confirm) {
50
+ if (process.stdin.isTTY) {
51
+ tui.newline();
52
+ tui.warn(`You are about to delete machine ${tui.bold(machine.id)}`);
53
+ if (machine.orgName) {
54
+ tui.info(`Organization: ${machine.orgName}`);
55
+ }
56
+ tui.newline();
57
+
58
+ const response = await enquirer.prompt<{ confirm: boolean }>({
59
+ type: 'confirm',
60
+ name: 'confirm',
61
+ message: 'Are you sure you want to delete this machine?',
62
+ initial: false,
63
+ });
64
+
65
+ if (!response.confirm) {
66
+ tui.info('Deletion cancelled.');
67
+ return { success: false, machineId: args.machine_id };
68
+ }
69
+ } else {
70
+ tui.error('Non-interactive sessions require --confirm flag to delete a machine.');
71
+ return { success: false, machineId: args.machine_id };
72
+ }
73
+ }
74
+
75
+ await tui.spinner({
76
+ type: 'simple',
77
+ message: 'Deleting machine...',
78
+ callback: () => machineDelete(catalystClient, args.machine_id),
79
+ clearOnSuccess: true,
80
+ });
81
+
82
+ if (!options.json) {
83
+ tui.success(`Machine ${args.machine_id} deleted successfully.`);
84
+ }
85
+
86
+ return { success: true, machineId: args.machine_id };
87
+ } catch (ex) {
88
+ tui.fatal(`Failed to delete machine: ${ex}`, ErrorCode.API_ERROR);
89
+ }
90
+ },
91
+ });
@@ -0,0 +1,94 @@
1
+ import { z } from 'zod';
2
+ import { createSubcommand } from '../../../types';
3
+ import * as tui from '../../../tui';
4
+ import { machineDeployments } from '@agentuity/server';
5
+ import { getCommand } from '../../../command-prefix';
6
+ import { ErrorCode } from '../../../errors';
7
+ import { getGlobalCatalystAPIClient } from '../../../config';
8
+
9
+ const MachineDeploymentResponseSchema = z.array(
10
+ z.object({
11
+ id: z.string().describe('Deployment ID'),
12
+ identifier: z.string().optional().describe('Deployment identifier'),
13
+ state: z.string().optional().describe('Deployment state'),
14
+ projectName: z.string().optional().describe('Project name'),
15
+ projectId: z.string().optional().describe('Project ID'),
16
+ paused: z.boolean().describe('Whether the deployment is paused'),
17
+ domainSuffix: z.string().describe('Domain suffix'),
18
+ url: z.string().describe('URL to the deployment'),
19
+ })
20
+ );
21
+
22
+ export const deploymentsSubcommand = createSubcommand({
23
+ name: 'deployments',
24
+ description: 'List deployments running on a specific organization managed machine',
25
+ tags: ['read-only', 'slow', 'requires-auth'],
26
+ examples: [
27
+ {
28
+ command: `${getCommand('cloud machine deployments')} machine_abc123xyz`,
29
+ description: 'List deployments on a machine',
30
+ },
31
+ ],
32
+ aliases: ['deps', 'deployment'],
33
+ requires: { auth: true, org: true },
34
+ idempotent: true,
35
+ schema: {
36
+ args: z.object({
37
+ machine_id: z.string().describe('Machine ID'),
38
+ }),
39
+ response: MachineDeploymentResponseSchema,
40
+ },
41
+ async handler(ctx) {
42
+ const { args, options, logger, auth, config, orgId } = ctx;
43
+
44
+ const catalystClient = await getGlobalCatalystAPIClient(logger, auth, config?.name, orgId);
45
+
46
+ try {
47
+ const deployments = await machineDeployments(catalystClient, args.machine_id);
48
+
49
+ const result = deployments.map((d) => ({
50
+ id: d.id,
51
+ identifier: d.identifier,
52
+ state: d.state,
53
+ projectName: d.project?.name,
54
+ projectId: d.project?.id,
55
+ paused: d.paused,
56
+ domainSuffix: d.domainSuffix,
57
+ url:
58
+ d.customDomains?.length > 0
59
+ ? d.customDomains.map((domain) => `https://${domain}`).join(',')
60
+ : d.identifier
61
+ ? `https://d${d.identifier}.${d.domainSuffix}`
62
+ : d.project?.identifier
63
+ ? `https://p${d.project?.identifier}.${d.domainSuffix}`
64
+ : '',
65
+ }));
66
+
67
+ if (!options.json) {
68
+ if (deployments.length === 0) {
69
+ tui.info('No deployments found on this machine.');
70
+ } else {
71
+ const tableData = result.map((d) => ({
72
+ ID: d.id,
73
+ State: d.state || 'unknown',
74
+ Project: d.projectName ? `${d.projectName} (${d.projectId})` : '-',
75
+ Paused: d.paused ? 'Yes' : 'No',
76
+ URL: d.url,
77
+ }));
78
+
79
+ tui.table(tableData, [
80
+ { name: 'ID', alignment: 'left' },
81
+ { name: 'State', alignment: 'left' },
82
+ { name: 'Project', alignment: 'left' },
83
+ { name: 'Paused', alignment: 'center' },
84
+ { name: 'URL', alignment: 'left' },
85
+ ]);
86
+ }
87
+ }
88
+
89
+ return result;
90
+ } catch (ex) {
91
+ tui.fatal(`Failed to get machine deployments: ${ex}`, ErrorCode.API_ERROR);
92
+ }
93
+ },
94
+ });
@@ -0,0 +1,110 @@
1
+ import { z } from 'zod';
2
+ import { createSubcommand } from '../../../types';
3
+ import * as tui from '../../../tui';
4
+ import { machineGet } from '@agentuity/server';
5
+ import { getCommand } from '../../../command-prefix';
6
+ import { ErrorCode } from '../../../errors';
7
+ import { getGlobalCatalystAPIClient } from '../../../config';
8
+
9
+ const MachineGetResponseSchema = z.object({
10
+ id: z.string().describe('Machine ID'),
11
+ status: z.string().describe('Machine status'),
12
+ provider: z.string().describe('Cloud provider'),
13
+ region: z.string().describe('Region'),
14
+ instanceId: z.string().nullable().optional().describe('Cloud instance ID'),
15
+ privateIPv4: z.string().nullable().optional().describe('Private IPv4 of the machine'),
16
+ availabilityZone: z.string().nullable().optional().describe('Availability zone of the machine'),
17
+ deploymentCount: z.number().describe('The number of deployments'),
18
+ orgId: z.string().nullable().optional().describe('Organization ID'),
19
+ orgName: z.string().nullable().optional().describe('Organization name'),
20
+ createdAt: z.string().describe('Creation timestamp'),
21
+ updatedAt: z.string().nullable().optional().describe('Last update timestamp'),
22
+ startedAt: z.string().nullable().optional().describe('Start timestamp'),
23
+ stoppedAt: z.string().nullable().optional().describe('Stop timestamp'),
24
+ error: z.string().nullable().optional().describe('Error message if any'),
25
+ });
26
+
27
+ export const getSubcommand = createSubcommand({
28
+ name: 'get',
29
+ description: 'Get details about a specific organization managed machine',
30
+ tags: ['read-only', 'fast', 'requires-auth'],
31
+ examples: [
32
+ {
33
+ command: `${getCommand('cloud machine get')} machine_abc123xyz`,
34
+ description: 'Get machine details by ID',
35
+ },
36
+ ],
37
+ aliases: ['show'],
38
+ requires: { auth: true, org: true },
39
+ idempotent: true,
40
+ schema: {
41
+ args: z.object({
42
+ machine_id: z.string().describe('Machine ID'),
43
+ }),
44
+ response: MachineGetResponseSchema,
45
+ },
46
+ async handler(ctx) {
47
+ const { args, options, logger, auth, config, orgId } = ctx;
48
+
49
+ const catalystClient = await getGlobalCatalystAPIClient(logger, auth, config?.name, orgId);
50
+
51
+ try {
52
+ const machine = await machineGet(catalystClient, args.machine_id);
53
+
54
+ if (!options.json) {
55
+ const tableData: Record<string, string> = {
56
+ ID: machine.id,
57
+ Status: machine.status,
58
+ Provider: machine.provider,
59
+ Region: machine.region,
60
+ };
61
+
62
+ if (machine.instanceId) {
63
+ tableData['Instance ID'] = machine.instanceId;
64
+ }
65
+ if (machine.privateIPv4) {
66
+ tableData['Private IP'] = machine.privateIPv4;
67
+ }
68
+ if (machine.availabilityZone) {
69
+ tableData['Availability Zone'] = machine.availabilityZone;
70
+ }
71
+ tableData['Deployments'] = (machine.deploymentCount ?? 0).toString();
72
+ tableData['Created'] = new Date(machine.createdAt).toLocaleString();
73
+ if (machine.updatedAt) {
74
+ tableData['Updated'] = new Date(machine.updatedAt).toLocaleString();
75
+ }
76
+ if (machine.startedAt) {
77
+ tableData['Started'] = new Date(machine.startedAt).toLocaleString();
78
+ }
79
+ if (machine.stoppedAt) {
80
+ tableData['Stopped'] = new Date(machine.stoppedAt).toLocaleString();
81
+ }
82
+ if (machine.error) {
83
+ tableData['Error'] = machine.error;
84
+ }
85
+
86
+ tui.table([tableData], Object.keys(tableData), { layout: 'vertical', padStart: ' ' });
87
+ }
88
+
89
+ return {
90
+ id: machine.id,
91
+ status: machine.status,
92
+ provider: machine.provider,
93
+ region: machine.region,
94
+ instanceId: machine.instanceId ?? undefined,
95
+ orgId: machine.orgId ?? undefined,
96
+ orgName: machine.orgName ?? undefined,
97
+ createdAt: machine.createdAt,
98
+ updatedAt: machine.updatedAt ?? undefined,
99
+ startedAt: machine.startedAt ?? undefined,
100
+ stoppedAt: machine.stoppedAt ?? undefined,
101
+ error: machine.error ?? undefined,
102
+ deploymentCount: machine.deploymentCount ?? 0,
103
+ privateIPv4: machine.privateIPv4,
104
+ availabilityZone: machine.availabilityZone,
105
+ };
106
+ } catch (ex) {
107
+ tui.fatal(`Failed to get machine: ${ex}`, ErrorCode.API_ERROR);
108
+ }
109
+ },
110
+ });
@@ -0,0 +1,22 @@
1
+ import { createCommand } from '../../../types';
2
+ import { listSubcommand } from './list';
3
+ import { getSubcommand } from './get';
4
+ import { deploymentsSubcommand } from './deployments';
5
+ import { deleteSubcommand } from './delete';
6
+ import { getCommand } from '../../../command-prefix';
7
+
8
+ export const machineCommand = createCommand({
9
+ name: 'machine',
10
+ description: 'Manage organization managed machines',
11
+ tags: ['read-only', 'fast', 'requires-auth'],
12
+ aliases: ['machines'],
13
+ examples: [
14
+ { command: getCommand('cloud machine list'), description: 'List all machines' },
15
+ { command: getCommand('cloud machine get <id>'), description: 'Get machine details' },
16
+ {
17
+ command: getCommand('cloud machine deployments <id>'),
18
+ description: 'List deployments on a machine',
19
+ },
20
+ ],
21
+ subcommands: [listSubcommand, getSubcommand, deploymentsSubcommand, deleteSubcommand],
22
+ });
@@ -0,0 +1,80 @@
1
+ import { z } from 'zod';
2
+ import { createSubcommand } from '../../../types';
3
+ import * as tui from '../../../tui';
4
+ import { machineList } from '@agentuity/server';
5
+ import { getCommand } from '../../../command-prefix';
6
+ import { ErrorCode } from '../../../errors';
7
+ import { getGlobalCatalystAPIClient } from '../../../config';
8
+
9
+ const MachineListResponseSchema = z.array(
10
+ z.object({
11
+ id: z.string().describe('Machine ID'),
12
+ status: z.string().describe('Machine status'),
13
+ provider: z.string().describe('Cloud provider'),
14
+ region: z.string().describe('Region'),
15
+ orgName: z.string().nullable().optional().describe('Organization name'),
16
+ createdAt: z.string().describe('Creation timestamp'),
17
+ })
18
+ );
19
+
20
+ export const listSubcommand = createSubcommand({
21
+ name: 'list',
22
+ description: 'List organization managed machines',
23
+ tags: ['read-only', 'slow', 'requires-auth'],
24
+ examples: [
25
+ {
26
+ command: getCommand('cloud machine list'),
27
+ description: 'List all machines',
28
+ },
29
+ ],
30
+ aliases: ['ls'],
31
+ requires: { auth: true, org: true },
32
+ idempotent: true,
33
+ schema: {
34
+ response: MachineListResponseSchema,
35
+ },
36
+ async handler(ctx) {
37
+ const { options, logger, auth, config, orgId } = ctx;
38
+
39
+ const catalystClient = await getGlobalCatalystAPIClient(logger, auth, config?.name, orgId);
40
+
41
+ try {
42
+ const machines = await machineList(catalystClient);
43
+
44
+ const result = machines.map((m) => ({
45
+ id: m.id,
46
+ status: m.status,
47
+ provider: m.provider,
48
+ region: m.region,
49
+ orgName: m.orgName ?? undefined,
50
+ createdAt: m.createdAt,
51
+ }));
52
+
53
+ if (!options.json) {
54
+ if (machines.length === 0) {
55
+ tui.info('No machines found.');
56
+ } else {
57
+ const tableData = machines.map((m) => ({
58
+ ID: m.id,
59
+ Status: m.status,
60
+ Provider: m.provider,
61
+ Region: m.region,
62
+ Created: new Date(m.createdAt).toLocaleString(),
63
+ }));
64
+
65
+ tui.table(tableData, [
66
+ { name: 'ID', alignment: 'left' },
67
+ { name: 'Status', alignment: 'left' },
68
+ { name: 'Provider', alignment: 'left' },
69
+ { name: 'Region', alignment: 'left' },
70
+ { name: 'Created', alignment: 'left' },
71
+ ]);
72
+ }
73
+ }
74
+
75
+ return result;
76
+ } catch (ex) {
77
+ tui.fatal(`Failed to list machines: ${ex}`, ErrorCode.API_ERROR);
78
+ }
79
+ },
80
+ });
@@ -19,7 +19,7 @@ import { getCommand } from '../../../command-prefix';
19
19
  export const command = createCommand({
20
20
  name: 'queue',
21
21
  aliases: ['queues'],
22
- description: 'Manage message queues',
22
+ description: 'Manage managed message queues',
23
23
  tags: ['requires-auth'],
24
24
  examples: [
25
25
  {
@@ -4,7 +4,7 @@ import { getCommand } from '../../../command-prefix';
4
4
 
5
5
  export const redisCommand = createCommand({
6
6
  name: 'redis',
7
- description: 'Manage Redis resources',
7
+ description: 'Manage Redis managed resources',
8
8
  tags: ['slow', 'requires-auth'],
9
9
  examples: [
10
10
  { command: getCommand('cloud redis show'), description: 'Show Redis connection URL' },
@@ -12,6 +12,22 @@ const SandboxResourcesSchema = z.object({
12
12
  disk: z.string().optional().describe('Disk limit (e.g., "1Gi", "10Gi")'),
13
13
  });
14
14
 
15
+ const SandboxRuntimeInfoSchema = z.object({
16
+ id: z.string().describe('Runtime ID'),
17
+ name: z.string().describe('Runtime name'),
18
+ iconUrl: z.string().optional().describe('URL for runtime icon'),
19
+ brandColor: z.string().optional().describe('Brand color for the runtime'),
20
+ tags: z.array(z.string()).optional().describe('Runtime tags'),
21
+ });
22
+
23
+ const SandboxSnapshotInfoSchema = z.object({
24
+ id: z.string().describe('Snapshot ID'),
25
+ name: z.string().optional().describe('Snapshot name'),
26
+ tag: z.string().optional().describe('Snapshot tag'),
27
+ fullName: z.string().optional().describe('Full name with org slug'),
28
+ public: z.boolean().describe('Whether snapshot is public'),
29
+ });
30
+
15
31
  const SandboxGetResponseSchema = z.object({
16
32
  sandboxId: z.string().describe('Sandbox ID'),
17
33
  name: z.string().optional().describe('Sandbox name'),
@@ -19,10 +35,8 @@ const SandboxGetResponseSchema = z.object({
19
35
  status: z.string().describe('Current status'),
20
36
  createdAt: z.string().describe('Creation timestamp'),
21
37
  region: z.string().optional().describe('Region where sandbox is running'),
22
- runtimeId: z.string().optional().describe('Runtime ID'),
23
- runtimeName: z.string().optional().describe('Runtime name'),
24
- snapshotId: z.string().optional().describe('Snapshot ID sandbox was created from'),
25
- snapshotTag: z.string().optional().describe('Snapshot tag sandbox was created from'),
38
+ runtime: SandboxRuntimeInfoSchema.optional().describe('Runtime information'),
39
+ snapshot: SandboxSnapshotInfoSchema.optional().describe('Snapshot information'),
26
40
  executions: z.number().describe('Number of executions'),
27
41
  stdoutStreamUrl: z.string().optional().describe('URL to stdout output stream'),
28
42
  stderrStreamUrl: z.string().optional().describe('URL to stderr output stream'),
@@ -73,15 +87,6 @@ export const getSubcommand = createCommand({
73
87
  ? tui.colorError
74
88
  : tui.colorMuted;
75
89
 
76
- const snapshotDisplay =
77
- result.snapshotId || result.snapshotTag
78
- ? result.snapshotTag
79
- ? result.snapshotId
80
- ? `${result.snapshotTag} ${tui.muted('(' + result.snapshotId + ')')}`
81
- : result.snapshotTag
82
- : result.snapshotId
83
- : undefined;
84
-
85
90
  let streamDisplay: string | undefined;
86
91
  if (
87
92
  result.stdoutStreamUrl &&
@@ -106,9 +111,15 @@ export const getSubcommand = createCommand({
106
111
  if (result.description) tableData['Description'] = result.description;
107
112
  tableData['Status'] = statusColor(result.status);
108
113
  tableData['Created'] = result.createdAt;
109
- if (result.runtimeName) tableData['Runtime'] = result.runtimeName;
114
+ if (result.runtime?.name) tableData['Runtime'] = result.runtime.name;
110
115
  if (result.region) tableData['Region'] = result.region;
111
- if (snapshotDisplay) tableData['Snapshot'] = snapshotDisplay;
116
+ if (result.snapshot?.id) {
117
+ const snapshotDisplay =
118
+ result.snapshot.public && result.snapshot.fullName
119
+ ? result.snapshot.fullName
120
+ : result.snapshot.tag || result.snapshot.id;
121
+ tableData['Snapshot'] = snapshotDisplay;
122
+ }
112
123
  tableData['Executions'] = result.executions;
113
124
  if (streamDisplay) {
114
125
  tableData['Stream'] = streamDisplay;
@@ -141,10 +152,8 @@ export const getSubcommand = createCommand({
141
152
  status: result.status,
142
153
  createdAt: result.createdAt,
143
154
  region: result.region,
144
- runtimeId: result.runtimeId,
145
- runtimeName: result.runtimeName,
146
- snapshotId: result.snapshotId,
147
- snapshotTag: result.snapshotTag,
155
+ runtime: result.runtime,
156
+ snapshot: result.snapshot,
148
157
  executions: result.executions,
149
158
  stdoutStreamUrl: result.stdoutStreamUrl,
150
159
  stderrStreamUrl: result.stderrStreamUrl,
@@ -21,7 +21,7 @@ import { getCommand } from '../../../command-prefix';
21
21
  export const command = createCommand({
22
22
  name: 'sandbox',
23
23
  aliases: ['sb'],
24
- description: 'Manage sandboxes for isolated code execution',
24
+ description: 'Manage sandboxes for managed isolated code execution',
25
25
  tags: ['slow', 'requires-auth'],
26
26
  examples: [
27
27
  {