@agentuity/cli 0.0.42 → 0.0.44
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/bin/cli.ts +7 -5
- 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 +2 -0
- package/dist/cmd/auth/whoami.d.ts.map +1 -0
- 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/index.d.ts +1 -1
- package/dist/cmd/bundle/index.d.ts.map +1 -1
- 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 -0
- 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 -0
- 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 +2 -0
- package/dist/cmd/env/delete.d.ts.map +1 -0
- package/dist/cmd/env/get.d.ts +2 -0
- package/dist/cmd/env/get.d.ts.map +1 -0
- package/dist/cmd/env/import.d.ts +2 -0
- package/dist/cmd/env/import.d.ts.map +1 -0
- package/dist/cmd/env/index.d.ts +2 -0
- package/dist/cmd/env/index.d.ts.map +1 -0
- package/dist/cmd/env/list.d.ts.map +1 -0
- package/dist/cmd/env/pull.d.ts +2 -0
- package/dist/cmd/env/pull.d.ts.map +1 -0
- package/dist/cmd/env/push.d.ts +2 -0
- package/dist/cmd/env/push.d.ts.map +1 -0
- package/dist/cmd/env/set.d.ts +2 -0
- package/dist/cmd/env/set.d.ts.map +1 -0
- 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/download.d.ts +1 -1
- package/dist/cmd/project/download.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 +5 -1
- package/dist/cmd/project/template-flow.d.ts.map +1 -1
- package/dist/cmd/secret/delete.d.ts +2 -0
- package/dist/cmd/secret/delete.d.ts.map +1 -0
- package/dist/cmd/secret/get.d.ts +2 -0
- package/dist/cmd/secret/get.d.ts.map +1 -0
- package/dist/cmd/secret/import.d.ts +2 -0
- package/dist/cmd/secret/import.d.ts.map +1 -0
- package/dist/cmd/secret/index.d.ts +2 -0
- package/dist/cmd/secret/index.d.ts.map +1 -0
- package/dist/cmd/secret/list.d.ts +2 -0
- package/dist/cmd/secret/list.d.ts.map +1 -0
- package/dist/cmd/secret/pull.d.ts +2 -0
- package/dist/cmd/secret/pull.d.ts.map +1 -0
- package/dist/cmd/secret/push.d.ts +2 -0
- package/dist/cmd/secret/push.d.ts.map +1 -0
- package/dist/cmd/secret/set.d.ts +2 -0
- package/dist/cmd/secret/set.d.ts.map +1 -0
- package/dist/cmd/version/index.d.ts.map +1 -1
- package/dist/config.d.ts +11 -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/env-util.d.ts +67 -0
- package/dist/env-util.d.ts.map +1 -0
- package/dist/env-util.test.d.ts +2 -0
- package/dist/env-util.test.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/schema-parser.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 +32 -2
- package/dist/tui.d.ts.map +1 -1
- package/dist/types.d.ts +250 -127
- 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 +709 -36
- package/src/cmd/auth/api.ts +10 -16
- package/src/cmd/auth/index.ts +3 -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 +69 -0
- 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 +11 -11
- package/src/cmd/bundle/patch/aisdk.ts +1 -1
- package/src/cmd/bundle/plugin.ts +373 -53
- package/src/cmd/cloud/deploy.ts +336 -0
- package/src/cmd/cloud/domain.ts +92 -0
- package/src/cmd/cloud/index.ts +11 -0
- 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 +362 -34
- package/src/cmd/dev/templates.ts +84 -0
- package/src/cmd/env/delete.ts +47 -0
- package/src/cmd/env/get.ts +53 -0
- package/src/cmd/env/import.ts +102 -0
- package/src/cmd/env/index.ts +22 -0
- package/src/cmd/env/list.ts +56 -0
- package/src/cmd/env/pull.ts +80 -0
- package/src/cmd/env/push.ts +37 -0
- package/src/cmd/env/set.ts +71 -0
- 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 +3 -3
- package/src/cmd/project/list.ts +8 -8
- package/src/cmd/project/show.ts +3 -7
- package/src/cmd/project/template-flow.ts +186 -48
- package/src/cmd/secret/delete.ts +40 -0
- package/src/cmd/secret/get.ts +54 -0
- package/src/cmd/secret/import.ts +64 -0
- package/src/cmd/secret/index.ts +22 -0
- package/src/cmd/secret/list.ts +56 -0
- package/src/cmd/secret/pull.ts +78 -0
- package/src/cmd/secret/push.ts +37 -0
- package/src/cmd/secret/set.ts +45 -0
- package/src/cmd/version/index.ts +2 -1
- package/src/config.ts +257 -27
- 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 +194 -0
- package/src/env-util.ts +290 -0
- package/src/index.ts +5 -1
- package/src/schema-parser.ts +2 -3
- package/src/steps.ts +144 -10
- package/src/terminal.ts +24 -23
- package/src/tui.ts +208 -68
- package/src/types.ts +292 -202
- 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.map +0 -1
- package/dist/cmd/example/index.d.ts.map +0 -1
- 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/dist/logger.d.ts +0 -24
- package/dist/logger.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/logger.ts +0 -235
- /package/dist/cmd/{example → cloud}/deploy.d.ts +0 -0
- /package/dist/cmd/{example → cloud}/index.d.ts +0 -0
- /package/dist/cmd/{example → env}/list.d.ts +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createSubcommand } from '../../types';
|
|
3
|
+
import * as tui from '../../tui';
|
|
4
|
+
import { projectEnvUpdate } from '@agentuity/server';
|
|
5
|
+
import {
|
|
6
|
+
findEnvFile,
|
|
7
|
+
readEnvFile,
|
|
8
|
+
writeEnvFile,
|
|
9
|
+
filterAgentuitySdkKeys,
|
|
10
|
+
mergeEnvVars,
|
|
11
|
+
} from '../../env-util';
|
|
12
|
+
|
|
13
|
+
export const importSubcommand = createSubcommand({
|
|
14
|
+
name: 'import',
|
|
15
|
+
description: 'Import secrets from a file to cloud and local .env.production',
|
|
16
|
+
requires: { auth: true, project: true, apiClient: true },
|
|
17
|
+
schema: {
|
|
18
|
+
args: z.object({
|
|
19
|
+
file: z.string().describe('path to the .env file to import'),
|
|
20
|
+
}),
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
async handler(ctx) {
|
|
24
|
+
const { args, apiClient, project, projectDir } = ctx;
|
|
25
|
+
|
|
26
|
+
// Read the import file
|
|
27
|
+
const importedSecrets = await readEnvFile(args.file);
|
|
28
|
+
|
|
29
|
+
if (Object.keys(importedSecrets).length === 0) {
|
|
30
|
+
tui.warning(`No secrets found in ${args.file}`);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Filter out AGENTUITY_ prefixed keys
|
|
35
|
+
const filteredSecrets = filterAgentuitySdkKeys(importedSecrets);
|
|
36
|
+
|
|
37
|
+
if (Object.keys(filteredSecrets).length === 0) {
|
|
38
|
+
tui.warning('No valid secrets to import (all were AGENTUITY_ prefixed)');
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Push to cloud (using secrets field)
|
|
43
|
+
await tui.spinner('Importing secrets to cloud', () => {
|
|
44
|
+
return projectEnvUpdate(apiClient, {
|
|
45
|
+
id: project.projectId,
|
|
46
|
+
secrets: filteredSecrets,
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Merge with local .env.production file
|
|
51
|
+
const localEnvPath = await findEnvFile(projectDir);
|
|
52
|
+
const localEnv = await readEnvFile(localEnvPath);
|
|
53
|
+
const mergedEnv = mergeEnvVars(localEnv, filteredSecrets);
|
|
54
|
+
|
|
55
|
+
await writeEnvFile(localEnvPath, mergedEnv, {
|
|
56
|
+
skipKeys: Object.keys(mergedEnv).filter((k) => k.startsWith('AGENTUITY_')),
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const count = Object.keys(filteredSecrets).length;
|
|
60
|
+
tui.success(
|
|
61
|
+
`Imported ${count} secret${count !== 1 ? 's' : ''} from ${args.file} to cloud and ${localEnvPath}`
|
|
62
|
+
);
|
|
63
|
+
},
|
|
64
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createCommand } from '../../types';
|
|
2
|
+
import { pullSubcommand } from './pull';
|
|
3
|
+
import { pushSubcommand } from './push';
|
|
4
|
+
import { setSubcommand } from './set';
|
|
5
|
+
import { getSubcommand } from './get';
|
|
6
|
+
import { deleteSubcommand } from './delete';
|
|
7
|
+
import { importSubcommand } from './import';
|
|
8
|
+
import { listSubcommand } from './list';
|
|
9
|
+
|
|
10
|
+
export const command = createCommand({
|
|
11
|
+
name: 'secret',
|
|
12
|
+
description: 'Manage secrets for your project',
|
|
13
|
+
subcommands: [
|
|
14
|
+
listSubcommand,
|
|
15
|
+
pullSubcommand,
|
|
16
|
+
pushSubcommand,
|
|
17
|
+
setSubcommand,
|
|
18
|
+
getSubcommand,
|
|
19
|
+
deleteSubcommand,
|
|
20
|
+
importSubcommand,
|
|
21
|
+
],
|
|
22
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createSubcommand } from '../../types';
|
|
3
|
+
import * as tui from '../../tui';
|
|
4
|
+
import { projectGet } from '@agentuity/server';
|
|
5
|
+
import { maskSecret } from '../../env-util';
|
|
6
|
+
|
|
7
|
+
export const listSubcommand = createSubcommand({
|
|
8
|
+
name: 'list',
|
|
9
|
+
aliases: ['ls'],
|
|
10
|
+
description: 'List all secrets',
|
|
11
|
+
requires: { auth: true, project: true, apiClient: true },
|
|
12
|
+
schema: {
|
|
13
|
+
options: z.object({
|
|
14
|
+
mask: z
|
|
15
|
+
.boolean()
|
|
16
|
+
.default(!!process.stdout.isTTY)
|
|
17
|
+
.describe('mask the values in output (default: true in TTY for secrets)'),
|
|
18
|
+
}),
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
async handler(ctx) {
|
|
22
|
+
const { opts, apiClient, project } = ctx;
|
|
23
|
+
|
|
24
|
+
// Fetch project with unmasked secrets
|
|
25
|
+
const projectData = await tui.spinner('Fetching secrets', () => {
|
|
26
|
+
return projectGet(apiClient, { id: project.projectId, mask: false });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const secrets = projectData.secrets || {};
|
|
30
|
+
|
|
31
|
+
if (Object.keys(secrets).length === 0) {
|
|
32
|
+
tui.info('No secrets found');
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Display the secrets
|
|
37
|
+
if (process.stdout.isTTY) {
|
|
38
|
+
tui.newline();
|
|
39
|
+
tui.success(`Secrets (${Object.keys(secrets).length}):`);
|
|
40
|
+
tui.newline();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const sortedKeys = Object.keys(secrets).sort();
|
|
44
|
+
// For secrets, masking is enabled by default in TTY (can be disabled with --no-mask)
|
|
45
|
+
const shouldMask = opts?.mask !== false;
|
|
46
|
+
for (const key of sortedKeys) {
|
|
47
|
+
const value = secrets[key];
|
|
48
|
+
const displayValue = shouldMask ? maskSecret(value) : value;
|
|
49
|
+
if (process.stdout.isTTY) {
|
|
50
|
+
console.log(`${tui.bold(key)}=${displayValue}`);
|
|
51
|
+
} else {
|
|
52
|
+
console.log(`${key}=${displayValue}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { createSubcommand } from '../../types';
|
|
4
|
+
import * as tui from '../../tui';
|
|
5
|
+
import { projectGet } from '@agentuity/server';
|
|
6
|
+
import {
|
|
7
|
+
findEnvFile,
|
|
8
|
+
findExistingEnvFile,
|
|
9
|
+
readEnvFile,
|
|
10
|
+
writeEnvFile,
|
|
11
|
+
mergeEnvVars,
|
|
12
|
+
} from '../../env-util';
|
|
13
|
+
|
|
14
|
+
export const pullSubcommand = createSubcommand({
|
|
15
|
+
name: 'pull',
|
|
16
|
+
description: 'Pull secrets from cloud to local .env.production file',
|
|
17
|
+
requires: { auth: true, project: true, apiClient: true },
|
|
18
|
+
schema: {
|
|
19
|
+
options: z.object({
|
|
20
|
+
force: z.boolean().default(false).describe('overwrite local values with cloud values'),
|
|
21
|
+
}),
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
async handler(ctx) {
|
|
25
|
+
const { opts, apiClient, project, projectDir } = ctx;
|
|
26
|
+
|
|
27
|
+
// Fetch project with unmasked secrets
|
|
28
|
+
const projectData = await tui.spinner('Pulling secrets from cloud', () => {
|
|
29
|
+
return projectGet(apiClient, { id: project.projectId, mask: false });
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const cloudSecrets = projectData.secrets || {};
|
|
33
|
+
|
|
34
|
+
// Read current local env from existing file (.env.production or .env)
|
|
35
|
+
const existingEnvPath = await findExistingEnvFile(projectDir);
|
|
36
|
+
const localEnv = await readEnvFile(existingEnvPath);
|
|
37
|
+
|
|
38
|
+
// Target file is always .env.production
|
|
39
|
+
const targetEnvPath = await findEnvFile(projectDir);
|
|
40
|
+
|
|
41
|
+
// Merge: cloud values override local if force=true, otherwise keep local
|
|
42
|
+
let mergedEnv: Record<string, string>;
|
|
43
|
+
if (opts?.force) {
|
|
44
|
+
// Cloud values take priority
|
|
45
|
+
mergedEnv = mergeEnvVars(localEnv, cloudSecrets);
|
|
46
|
+
} else {
|
|
47
|
+
// Local values take priority (only add new keys from cloud)
|
|
48
|
+
mergedEnv = mergeEnvVars(cloudSecrets, localEnv);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Write to .env.production (skip AGENTUITY_ keys)
|
|
52
|
+
await writeEnvFile(targetEnvPath, mergedEnv, {
|
|
53
|
+
skipKeys: Object.keys(mergedEnv).filter((k) => k.startsWith('AGENTUITY_')),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Write AGENTUITY_SDK_KEY to .env if present and missing locally
|
|
57
|
+
if (projectData.api_key) {
|
|
58
|
+
const dotEnvPath = join(projectDir, '.env');
|
|
59
|
+
const dotEnv = await readEnvFile(dotEnvPath);
|
|
60
|
+
|
|
61
|
+
if (!dotEnv.AGENTUITY_SDK_KEY) {
|
|
62
|
+
dotEnv.AGENTUITY_SDK_KEY = projectData.api_key;
|
|
63
|
+
await writeEnvFile(dotEnvPath, dotEnv, {
|
|
64
|
+
addComment: (key) => {
|
|
65
|
+
if (key === 'AGENTUITY_SDK_KEY') {
|
|
66
|
+
return 'AGENTUITY_SDK_KEY is a sensitive value and should not be committed to version control.';
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
tui.info(`Wrote AGENTUITY_SDK_KEY to ${dotEnvPath}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const count = Object.keys(cloudSecrets).length;
|
|
76
|
+
tui.success(`Pulled ${count} secret${count !== 1 ? 's' : ''} to ${targetEnvPath}`);
|
|
77
|
+
},
|
|
78
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createSubcommand } from '../../types';
|
|
2
|
+
import * as tui from '../../tui';
|
|
3
|
+
import { projectEnvUpdate } from '@agentuity/server';
|
|
4
|
+
import { findEnvFile, readEnvFile, filterAgentuitySdkKeys } from '../../env-util';
|
|
5
|
+
|
|
6
|
+
export const pushSubcommand = createSubcommand({
|
|
7
|
+
name: 'push',
|
|
8
|
+
description: 'Push secrets from local .env.production file to cloud',
|
|
9
|
+
requires: { auth: true, project: true, apiClient: true },
|
|
10
|
+
|
|
11
|
+
async handler(ctx) {
|
|
12
|
+
const { apiClient, project, projectDir } = ctx;
|
|
13
|
+
|
|
14
|
+
// Read local env file
|
|
15
|
+
const envFilePath = await findEnvFile(projectDir);
|
|
16
|
+
const localEnv = await readEnvFile(envFilePath);
|
|
17
|
+
|
|
18
|
+
// Filter out AGENTUITY_ prefixed keys (don't push SDK keys)
|
|
19
|
+
const filteredSecrets = filterAgentuitySdkKeys(localEnv);
|
|
20
|
+
|
|
21
|
+
if (Object.keys(filteredSecrets).length === 0) {
|
|
22
|
+
tui.warning('No secrets to push');
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Push to cloud (using secrets field)
|
|
27
|
+
await tui.spinner('Pushing secrets to cloud', () => {
|
|
28
|
+
return projectEnvUpdate(apiClient, {
|
|
29
|
+
id: project.projectId,
|
|
30
|
+
secrets: filteredSecrets,
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const count = Object.keys(filteredSecrets).length;
|
|
35
|
+
tui.success(`Pushed ${count} secret${count !== 1 ? 's' : ''} to cloud`);
|
|
36
|
+
},
|
|
37
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createSubcommand } from '../../types';
|
|
3
|
+
import * as tui from '../../tui';
|
|
4
|
+
import { projectEnvUpdate } from '@agentuity/server';
|
|
5
|
+
import { findEnvFile, readEnvFile, writeEnvFile, filterAgentuitySdkKeys } from '../../env-util';
|
|
6
|
+
|
|
7
|
+
export const setSubcommand = createSubcommand({
|
|
8
|
+
name: 'set',
|
|
9
|
+
description: 'Set a secret',
|
|
10
|
+
requires: { auth: true, project: true, apiClient: true },
|
|
11
|
+
schema: {
|
|
12
|
+
args: z.object({
|
|
13
|
+
key: z.string().min(1, 'key must not be empty').describe('the secret key'),
|
|
14
|
+
value: z.string().min(1, 'value must not be empty').describe('the secret value'),
|
|
15
|
+
}),
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
async handler(ctx) {
|
|
19
|
+
const { args, apiClient, project, projectDir } = ctx;
|
|
20
|
+
|
|
21
|
+
// Validate key doesn't start with AGENTUITY_
|
|
22
|
+
if (args.key.startsWith('AGENTUITY_')) {
|
|
23
|
+
tui.fatal('Cannot set AGENTUITY_ prefixed variables. These are reserved for system use.');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Set in cloud (using secrets field)
|
|
27
|
+
await tui.spinner('Setting secret in cloud', () => {
|
|
28
|
+
return projectEnvUpdate(apiClient, {
|
|
29
|
+
id: project.projectId,
|
|
30
|
+
secrets: { [args.key]: args.value },
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Update local .env.production file
|
|
35
|
+
const envFilePath = await findEnvFile(projectDir);
|
|
36
|
+
const currentEnv = await readEnvFile(envFilePath);
|
|
37
|
+
currentEnv[args.key] = args.value;
|
|
38
|
+
|
|
39
|
+
// Filter out AGENTUITY_ keys before writing
|
|
40
|
+
const filteredEnv = filterAgentuitySdkKeys(currentEnv);
|
|
41
|
+
await writeEnvFile(envFilePath, filteredEnv);
|
|
42
|
+
|
|
43
|
+
tui.success(`Secret '${args.key}' set successfully (cloud + ${envFilePath})`);
|
|
44
|
+
},
|
|
45
|
+
});
|
package/src/cmd/version/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createCommand } from '../../types';
|
|
2
2
|
import { getVersion } from '../../version';
|
|
3
|
-
import {
|
|
3
|
+
import { createLogger } from '@agentuity/server';
|
|
4
4
|
|
|
5
5
|
export const command = createCommand({
|
|
6
6
|
name: 'version',
|
|
@@ -10,6 +10,7 @@ export const command = createCommand({
|
|
|
10
10
|
try {
|
|
11
11
|
console.log(getVersion());
|
|
12
12
|
} catch (error) {
|
|
13
|
+
const logger = createLogger();
|
|
13
14
|
logger.fatal('Failed to retrieve version: %s', error);
|
|
14
15
|
}
|
|
15
16
|
},
|