@plosson/agentio 0.2.0 → 0.2.1
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/package.json +1 -1
- package/src/commands/config.ts +8 -14
package/package.json
CHANGED
package/src/commands/config.ts
CHANGED
|
@@ -10,7 +10,6 @@ import type { Config } from '../types/config';
|
|
|
10
10
|
import type { StoredCredentials } from '../types/tokens';
|
|
11
11
|
|
|
12
12
|
const ALGORITHM = 'aes-256-gcm';
|
|
13
|
-
const DEFAULT_EXPORT_FILE = 'agentio.config';
|
|
14
13
|
|
|
15
14
|
interface ExportedData {
|
|
16
15
|
version: number;
|
|
@@ -66,10 +65,9 @@ export function registerConfigCommands(program: Command): void {
|
|
|
66
65
|
|
|
67
66
|
config
|
|
68
67
|
.command('export')
|
|
69
|
-
.description('Export configuration and credentials to
|
|
68
|
+
.description('Export configuration and credentials (as environment variables by default, or to a file)')
|
|
70
69
|
.option('--key <key>', 'Encryption key (64 hex characters). If not provided, a random key will be generated')
|
|
71
|
-
.option('--
|
|
72
|
-
.option('--env', 'Output as environment variables instead of writing to file')
|
|
70
|
+
.option('--file <path>', 'Write encrypted config to file instead of outputting AGENTIO_CONFIG')
|
|
73
71
|
.action(async (options) => {
|
|
74
72
|
try {
|
|
75
73
|
// Validate key if provided
|
|
@@ -101,19 +99,15 @@ export function registerConfigCommands(program: Command): void {
|
|
|
101
99
|
const key = deriveKeyFromPassword(encryptionKey);
|
|
102
100
|
const encrypted = encrypt(JSON.stringify(exportData), key);
|
|
103
101
|
|
|
104
|
-
if (options.
|
|
102
|
+
if (options.file) {
|
|
103
|
+
// Write to file, output just the key
|
|
104
|
+
const filePath = options.file.startsWith('/') ? options.file : join(process.cwd(), options.file);
|
|
105
|
+
await writeFile(filePath, encrypted, { mode: 0o600 });
|
|
106
|
+
console.log(`AGENTIO_KEY=${encryptionKey}`);
|
|
107
|
+
} else {
|
|
105
108
|
// Output as environment variables
|
|
106
109
|
console.log(`AGENTIO_KEY=${encryptionKey}`);
|
|
107
110
|
console.log(`AGENTIO_CONFIG=${encrypted}`);
|
|
108
|
-
} else {
|
|
109
|
-
// Write to file
|
|
110
|
-
const outputPath = join(process.cwd(), options.output);
|
|
111
|
-
await writeFile(outputPath, encrypted, { mode: 0o600 });
|
|
112
|
-
|
|
113
|
-
console.log(`Configuration exported to: ${outputPath}`);
|
|
114
|
-
console.log(`Encryption key: ${encryptionKey}`);
|
|
115
|
-
console.log('');
|
|
116
|
-
console.log('Keep this key safe! You will need it to import the configuration.');
|
|
117
111
|
}
|
|
118
112
|
} catch (error) {
|
|
119
113
|
handleError(error);
|