@agentuity/cli 0.1.10 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cmd/cloud/sandbox/snapshot/build.d.ts +5 -0
- package/dist/cmd/cloud/sandbox/snapshot/build.d.ts.map +1 -0
- package/dist/cmd/cloud/sandbox/snapshot/build.js +574 -0
- package/dist/cmd/cloud/sandbox/snapshot/build.js.map +1 -0
- package/dist/cmd/cloud/sandbox/snapshot/generate.d.ts +3 -0
- package/dist/cmd/cloud/sandbox/snapshot/generate.d.ts.map +1 -0
- package/dist/cmd/cloud/sandbox/snapshot/generate.js +127 -0
- package/dist/cmd/cloud/sandbox/snapshot/generate.js.map +1 -0
- package/dist/cmd/cloud/sandbox/snapshot/get.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/get.js +16 -0
- package/dist/cmd/cloud/sandbox/snapshot/get.js.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/index.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/index.js +19 -1
- package/dist/cmd/cloud/sandbox/snapshot/index.js.map +1 -1
- package/dist/cmd/project/auth/shared.js +1 -1
- package/dist/cmd/project/auth/shared.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +7 -3
- package/dist/config.js.map +1 -1
- package/dist/utils/apt-validator.js +3 -3
- package/dist/utils/apt-validator.js.map +1 -1
- package/package.json +6 -6
- package/src/cmd/cloud/sandbox/snapshot/build.ts +696 -0
- package/src/cmd/cloud/sandbox/snapshot/generate.ts +134 -0
- package/src/cmd/cloud/sandbox/snapshot/get.ts +19 -0
- package/src/cmd/cloud/sandbox/snapshot/index.ts +19 -1
- package/src/cmd/project/auth/shared.ts +1 -1
- package/src/config.ts +8 -3
- package/src/utils/apt-validator.ts +3 -3
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../../types';
|
|
3
|
+
import { getCommand } from '../../../../command-prefix';
|
|
4
|
+
|
|
5
|
+
const TEMPLATE_YAML = `# yaml-language-server: $schema=https://agentuity.dev/schema/cli/v1/agentuity-snapshot.json
|
|
6
|
+
#
|
|
7
|
+
# Agentuity Snapshot Build File
|
|
8
|
+
# =============================
|
|
9
|
+
# This file defines a reproducible sandbox environment.
|
|
10
|
+
# Build with: agentuity cloud sandbox snapshot build <directory>
|
|
11
|
+
#
|
|
12
|
+
# For documentation, see: https://agentuity.dev/Services/Sandbox
|
|
13
|
+
|
|
14
|
+
# Required: Schema version (must be 1)
|
|
15
|
+
version: 1
|
|
16
|
+
|
|
17
|
+
# Required: Runtime environment
|
|
18
|
+
# Format: name:tag (e.g., bun:1, node:20, python:3.12)
|
|
19
|
+
# Run 'agentuity cloud sandbox runtime list' to see available runtimes
|
|
20
|
+
runtime: bun:1
|
|
21
|
+
|
|
22
|
+
# Optional: Snapshot name (alphanumeric, underscores, dashes only)
|
|
23
|
+
# If not provided, a unique name will be auto-generated
|
|
24
|
+
# name: my-snapshot
|
|
25
|
+
|
|
26
|
+
# Optional: Human-readable description
|
|
27
|
+
# Can be overridden with --description flag
|
|
28
|
+
description: My sandbox snapshot
|
|
29
|
+
|
|
30
|
+
# Optional: Apt packages to install
|
|
31
|
+
# Packages are validated against Debian stable repositories
|
|
32
|
+
# Supports version pinning: package=version or package=version* (prefix match)
|
|
33
|
+
# dependencies:
|
|
34
|
+
# - curl
|
|
35
|
+
# - ffmpeg
|
|
36
|
+
# - imagemagick=8:6.9*
|
|
37
|
+
|
|
38
|
+
# Optional: Files to include from the build context directory
|
|
39
|
+
# Supports glob patterns and negative patterns (prefix with !)
|
|
40
|
+
# Files are placed in /home/agentuity/ in the sandbox
|
|
41
|
+
# files:
|
|
42
|
+
# - "*.js" # All JS files in root
|
|
43
|
+
# - src/** # All files in src/ recursively
|
|
44
|
+
# - config/*.json # All JSON files in config/
|
|
45
|
+
# - "!**/*.test.js" # Exclude test files
|
|
46
|
+
# - "!node_modules/**" # Exclude node_modules
|
|
47
|
+
|
|
48
|
+
# Optional: Environment variables
|
|
49
|
+
# Use \${VAR} syntax for build-time substitution via --env flag
|
|
50
|
+
# env:
|
|
51
|
+
# NODE_ENV: production
|
|
52
|
+
# API_URL: https://api.example.com
|
|
53
|
+
# SECRET_KEY: \${SECRET_KEY} # Substituted from: --env SECRET_KEY=value
|
|
54
|
+
|
|
55
|
+
# Optional: Custom metadata
|
|
56
|
+
# Use \${VAR} syntax for build-time substitution via --metadata flag
|
|
57
|
+
# Stored with the snapshot for reference
|
|
58
|
+
# metadata:
|
|
59
|
+
# version: \${VERSION} # Substituted from: --metadata VERSION=1.0.0
|
|
60
|
+
# author: team-name
|
|
61
|
+
# build_date: \${BUILD_DATE}
|
|
62
|
+
`;
|
|
63
|
+
|
|
64
|
+
const TEMPLATE_JSON = {
|
|
65
|
+
$schema: 'https://agentuity.dev/schema/cli/v1/agentuity-snapshot.json',
|
|
66
|
+
version: 1,
|
|
67
|
+
runtime: 'bun:1',
|
|
68
|
+
name: 'my-snapshot',
|
|
69
|
+
description: 'My sandbox snapshot',
|
|
70
|
+
dependencies: ['curl'],
|
|
71
|
+
files: ['src/**', '*.js', '!**/*.test.js'],
|
|
72
|
+
env: {
|
|
73
|
+
NODE_ENV: 'production',
|
|
74
|
+
},
|
|
75
|
+
metadata: {
|
|
76
|
+
version: '1.0.0',
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const GenerateResponseSchema = z.object({
|
|
81
|
+
format: z.enum(['yaml', 'json']).describe('Output format'),
|
|
82
|
+
content: z.string().describe('Generated template content'),
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
export const generateSubcommand = createCommand({
|
|
86
|
+
name: 'generate',
|
|
87
|
+
aliases: ['gen', 'init'],
|
|
88
|
+
description: 'Generate a template snapshot build file',
|
|
89
|
+
tags: [],
|
|
90
|
+
requires: {},
|
|
91
|
+
examples: [
|
|
92
|
+
{
|
|
93
|
+
command: getCommand('cloud sandbox snapshot generate'),
|
|
94
|
+
description: 'Generate a YAML template (default)',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
command: getCommand('cloud sandbox snapshot generate --format json'),
|
|
98
|
+
description: 'Generate a JSON template',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
command: getCommand('cloud sandbox snapshot generate > agentuity-snapshot.yaml'),
|
|
102
|
+
description: 'Save template to a file',
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
schema: {
|
|
106
|
+
options: z.object({
|
|
107
|
+
format: z.enum(['yaml', 'json']).default('yaml').describe('Output format (yaml or json)'),
|
|
108
|
+
}),
|
|
109
|
+
response: GenerateResponseSchema,
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
async handler(ctx) {
|
|
113
|
+
const { opts, options } = ctx;
|
|
114
|
+
const format = opts.format;
|
|
115
|
+
|
|
116
|
+
let content: string;
|
|
117
|
+
if (format === 'json') {
|
|
118
|
+
content = JSON.stringify(TEMPLATE_JSON, null, 2);
|
|
119
|
+
} else {
|
|
120
|
+
content = TEMPLATE_YAML;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (!options.json) {
|
|
124
|
+
console.log(content);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
format,
|
|
129
|
+
content,
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
export default generateSubcommand;
|
|
@@ -21,6 +21,7 @@ const SandboxInfoSchema = z.object({
|
|
|
21
21
|
|
|
22
22
|
const SnapshotGetResponseSchema = z.object({
|
|
23
23
|
snapshotId: z.string().describe('Snapshot ID'),
|
|
24
|
+
name: z.string().describe('Snapshot name'),
|
|
24
25
|
tag: z.string().nullable().optional().describe('Snapshot tag'),
|
|
25
26
|
sizeBytes: z.number().describe('Snapshot size in bytes'),
|
|
26
27
|
fileCount: z.number().describe('Number of files'),
|
|
@@ -28,6 +29,11 @@ const SnapshotGetResponseSchema = z.object({
|
|
|
28
29
|
createdAt: z.string().describe('Creation timestamp'),
|
|
29
30
|
downloadUrl: z.string().optional().describe('Presigned download URL'),
|
|
30
31
|
files: z.array(SnapshotFileSchema).nullable().optional().describe('Files in snapshot'),
|
|
32
|
+
userMetadata: z
|
|
33
|
+
.record(z.string(), z.string())
|
|
34
|
+
.nullable()
|
|
35
|
+
.optional()
|
|
36
|
+
.describe('User-defined metadata'),
|
|
31
37
|
sandboxes: z
|
|
32
38
|
.array(SandboxInfoSchema)
|
|
33
39
|
.optional()
|
|
@@ -73,6 +79,7 @@ export const getSubcommand = createCommand({
|
|
|
73
79
|
|
|
74
80
|
if (!options.json) {
|
|
75
81
|
tui.info(`Snapshot: ${tui.bold(snapshot.snapshotId)}`);
|
|
82
|
+
console.log(` ${tui.muted('Name:')} ${snapshot.name}`);
|
|
76
83
|
if (snapshot.tag) {
|
|
77
84
|
console.log(` ${tui.muted('Tag:')} ${snapshot.tag}`);
|
|
78
85
|
}
|
|
@@ -83,6 +90,18 @@ export const getSubcommand = createCommand({
|
|
|
83
90
|
console.log(` ${tui.muted('Parent:')} ${snapshot.parentSnapshotId}`);
|
|
84
91
|
}
|
|
85
92
|
|
|
93
|
+
if (
|
|
94
|
+
snapshot.userMetadata &&
|
|
95
|
+
typeof snapshot.userMetadata === 'object' &&
|
|
96
|
+
Object.keys(snapshot.userMetadata).length > 0
|
|
97
|
+
) {
|
|
98
|
+
console.log('');
|
|
99
|
+
tui.info('Metadata:');
|
|
100
|
+
for (const [key, value] of Object.entries(snapshot.userMetadata)) {
|
|
101
|
+
console.log(` ${tui.muted('•')} ${key}=${value}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
86
105
|
if (snapshot.files && snapshot.files.length > 0) {
|
|
87
106
|
console.log('');
|
|
88
107
|
tui.info('Files:');
|
|
@@ -4,6 +4,8 @@ import { listSubcommand } from './list';
|
|
|
4
4
|
import { getSubcommand } from './get';
|
|
5
5
|
import { deleteSubcommand } from './delete';
|
|
6
6
|
import { tagSubcommand } from './tag';
|
|
7
|
+
import { buildSubcommand } from './build';
|
|
8
|
+
import { generateSubcommand } from './generate';
|
|
7
9
|
import { getCommand } from '../../../../command-prefix';
|
|
8
10
|
|
|
9
11
|
export const snapshotCommand = createCommand({
|
|
@@ -20,8 +22,24 @@ export const snapshotCommand = createCommand({
|
|
|
20
22
|
command: getCommand('cloud sandbox snapshot list'),
|
|
21
23
|
description: 'List all snapshots',
|
|
22
24
|
},
|
|
25
|
+
{
|
|
26
|
+
command: getCommand('cloud sandbox snapshot build .'),
|
|
27
|
+
description: 'Build a snapshot from a declarative file',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
command: getCommand('cloud sandbox snapshot generate > agentuity-snapshot.yaml'),
|
|
31
|
+
description: 'Generate a template build file',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
subcommands: [
|
|
35
|
+
createSubcommand,
|
|
36
|
+
listSubcommand,
|
|
37
|
+
getSubcommand,
|
|
38
|
+
deleteSubcommand,
|
|
39
|
+
tagSubcommand,
|
|
40
|
+
buildSubcommand,
|
|
41
|
+
generateSubcommand,
|
|
23
42
|
],
|
|
24
|
-
subcommands: [createSubcommand, listSubcommand, getSubcommand, deleteSubcommand, tagSubcommand],
|
|
25
43
|
requires: { auth: true, org: true },
|
|
26
44
|
});
|
|
27
45
|
|
|
@@ -262,7 +262,7 @@ export async function detectOrmSetup(projectDir: string): Promise<OrmSetup> {
|
|
|
262
262
|
* @returns SQL DDL statements for auth tables
|
|
263
263
|
*/
|
|
264
264
|
export async function generateAuthSchemaSql(logger: Logger, projectDir: string): Promise<string> {
|
|
265
|
-
const schemaPath = path.join(projectDir, 'node_modules/@agentuity/auth/
|
|
265
|
+
const schemaPath = path.join(projectDir, 'node_modules/@agentuity/auth/dist/schema.js');
|
|
266
266
|
|
|
267
267
|
if (!(await Bun.file(schemaPath).exists())) {
|
|
268
268
|
throw new Error(
|
package/src/config.ts
CHANGED
|
@@ -732,7 +732,12 @@ export async function getDefaultRegion(profileName = 'production'): Promise<stri
|
|
|
732
732
|
return process.env.AGENTUITY_REGION;
|
|
733
733
|
}
|
|
734
734
|
|
|
735
|
-
// 2.
|
|
735
|
+
// 2. Local profile always uses 'local' region
|
|
736
|
+
if (profileName === 'local') {
|
|
737
|
+
return 'local';
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
// 3. Check cached regions file (sorted by distance)
|
|
736
741
|
try {
|
|
737
742
|
const cachePath = join(getDefaultConfigDir(), `regions-${profileName}.json`);
|
|
738
743
|
const file = Bun.file(cachePath);
|
|
@@ -746,8 +751,8 @@ export async function getDefaultRegion(profileName = 'production'): Promise<stri
|
|
|
746
751
|
// Fall through to default
|
|
747
752
|
}
|
|
748
753
|
|
|
749
|
-
//
|
|
750
|
-
return
|
|
754
|
+
// 4. Final fallback
|
|
755
|
+
return 'usc';
|
|
751
756
|
}
|
|
752
757
|
|
|
753
758
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StructuredError, type Logger } from '@agentuity/core';
|
|
2
2
|
import type { Config } from '../types';
|
|
3
|
-
import {
|
|
3
|
+
import { getAPIBaseURL } from '@agentuity/server';
|
|
4
4
|
import { getUserAgent } from '../api';
|
|
5
5
|
import { getDefaultConfigDir } from '../config';
|
|
6
6
|
import { join, dirname } from 'node:path';
|
|
@@ -145,8 +145,8 @@ export async function validateAptDependencies(
|
|
|
145
145
|
packages.length - uncachedPackages.length
|
|
146
146
|
);
|
|
147
147
|
|
|
148
|
-
const
|
|
149
|
-
const url = `${
|
|
148
|
+
const apiBaseUrl = getAPIBaseURL(region, config?.overrides ?? undefined);
|
|
149
|
+
const url = `${apiBaseUrl}/cli/validate/apt-dependencies`;
|
|
150
150
|
|
|
151
151
|
const response = await fetch(url, {
|
|
152
152
|
method: 'POST',
|