@plosson/agentio 0.1.30 → 0.1.31

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plosson/agentio",
3
- "version": "0.1.30",
3
+ "version": "0.1.31",
4
4
  "description": "CLI for LLM agents to interact with communication and tracking services",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -3,7 +3,7 @@ import { createCipheriv, createDecipheriv, randomBytes, scryptSync } from 'crypt
3
3
  import { readFile, writeFile } from 'fs/promises';
4
4
  import { existsSync } from 'fs';
5
5
  import { join } from 'path';
6
- import { loadConfig, saveConfig } from '../config/config-manager';
6
+ import { loadConfig, saveConfig, setEnv, unsetEnv, listEnv } from '../config/config-manager';
7
7
  import { getAllCredentials, setAllCredentials } from '../auth/token-store';
8
8
  import { CliError, handleError } from '../utils/errors';
9
9
  import type { Config } from '../types/config';
@@ -245,4 +245,55 @@ export function registerConfigCommands(program: Command): void {
245
245
  handleError(error);
246
246
  }
247
247
  });
248
+
249
+ // Environment variable management
250
+ const env = config
251
+ .command('env')
252
+ .description('Manage environment variables')
253
+ .action(async () => {
254
+ try {
255
+ const vars = await listEnv();
256
+ const entries = Object.entries(vars).sort(([a], [b]) => a.localeCompare(b));
257
+ if (entries.length === 0) {
258
+ console.log('No environment variables configured');
259
+ return;
260
+ }
261
+ for (const [key, value] of entries) {
262
+ console.log(`${key}=${value}`);
263
+ }
264
+ } catch (error) {
265
+ handleError(error);
266
+ }
267
+ });
268
+
269
+ env
270
+ .command('set')
271
+ .description('Set an environment variable')
272
+ .argument('<key>', 'Variable name')
273
+ .argument('<value>', 'Variable value')
274
+ .action(async (key, value) => {
275
+ try {
276
+ await setEnv(key, value);
277
+ console.log(`Set ${key}`);
278
+ } catch (error) {
279
+ handleError(error);
280
+ }
281
+ });
282
+
283
+ env
284
+ .command('unset')
285
+ .description('Remove an environment variable')
286
+ .argument('<key>', 'Variable name')
287
+ .action(async (key) => {
288
+ try {
289
+ const removed = await unsetEnv(key);
290
+ if (removed) {
291
+ console.log(`Removed ${key}`);
292
+ } else {
293
+ throw new CliError('NOT_FOUND', `Variable not found: ${key}`);
294
+ }
295
+ } catch (error) {
296
+ handleError(error);
297
+ }
298
+ });
248
299
  }
@@ -142,4 +142,33 @@ export async function listProfiles(service?: ServiceName): Promise<{
142
142
  }));
143
143
  }
144
144
 
145
+ export async function getEnv(key: string): Promise<string | undefined> {
146
+ const config = await loadConfig();
147
+ return config.env?.[key];
148
+ }
149
+
150
+ export async function setEnv(key: string, value: string): Promise<void> {
151
+ const config = await loadConfig();
152
+ if (!config.env) {
153
+ config.env = {};
154
+ }
155
+ config.env[key] = value;
156
+ await saveConfig(config);
157
+ }
158
+
159
+ export async function unsetEnv(key: string): Promise<boolean> {
160
+ const config = await loadConfig();
161
+ if (!config.env || !(key in config.env)) {
162
+ return false;
163
+ }
164
+ delete config.env[key];
165
+ await saveConfig(config);
166
+ return true;
167
+ }
168
+
169
+ export async function listEnv(): Promise<Record<string, string>> {
170
+ const config = await loadConfig();
171
+ return config.env || {};
172
+ }
173
+
145
174
  export { CONFIG_DIR, CONFIG_FILE };
@@ -17,6 +17,7 @@ export interface Config {
17
17
  discourse?: string;
18
18
  sql?: string;
19
19
  };
20
+ env?: Record<string, string>;
20
21
  }
21
22
 
22
23
  export type ServiceName = 'gmail' | 'gchat' | 'jira' | 'slack' | 'telegram' | 'discourse' | 'sql';