agentgate 0.1.3 → 0.1.4

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli.js +21 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentgate",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "description": "API gateway for AI agents with human-in-the-loop write approval",
6
6
  "main": "src/index.js",
package/src/cli.js CHANGED
@@ -12,9 +12,10 @@ function printUsage() {
12
12
  console.log(`
13
13
  agentgate - API gateway for AI agents with human-in-the-loop write approval
14
14
 
15
- Usage: agentgate <command> [options]
15
+ Usage: agentgate [command] [options]
16
16
 
17
17
  Commands:
18
+ (default) Start the agentgate server
18
19
  start Start the agentgate server
19
20
  keys list List all API keys
20
21
  keys create <name> Create a new API key
@@ -25,28 +26,36 @@ Options:
25
26
  -h, --help Show this help message
26
27
 
27
28
  Examples:
28
- agentgate start
29
+ agentgate
29
30
  agentgate start --port 8080
30
31
  agentgate keys create my-agent
31
32
  agentgate keys list
32
33
  `);
33
34
  }
34
35
 
36
+ async function startServer(args) {
37
+ // Parse port from args
38
+ const portIdx = args.findIndex(a => a === '-p' || a === '--port');
39
+ if (portIdx !== -1 && args[portIdx + 1]) {
40
+ process.env.PORT = args[portIdx + 1];
41
+ }
42
+
43
+ // Import and run the server
44
+ await import('./index.js');
45
+ }
46
+
35
47
  async function main() {
36
- if (!command || command === '-h' || command === '--help') {
48
+ if (command === '-h' || command === '--help') {
37
49
  printUsage();
38
50
  process.exit(0);
39
51
  }
40
52
 
41
- if (command === 'start') {
42
- // Parse port from args
43
- const portIdx = args.findIndex(a => a === '-p' || a === '--port');
44
- if (portIdx !== -1 && args[portIdx + 1]) {
45
- process.env.PORT = args[portIdx + 1];
46
- }
47
-
48
- // Import and run the server
49
- await import('./index.js');
53
+ // Default behavior: start the server
54
+ if (!command || command === 'start') {
55
+ await startServer(args);
56
+ } else if (command === '-p' || command === '--port') {
57
+ // Handle case where user runs: agentgate -p 8080
58
+ await startServer([command, ...args]);
50
59
  } else if (command === 'keys') {
51
60
  const subcommand = args[0];
52
61
  const { createApiKey, listApiKeys, deleteApiKey } = await import('./lib/db.js');