@agent-hive/cli 0.1.2 → 0.1.3

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/hive.js CHANGED
@@ -46,7 +46,7 @@ program
46
46
  .version('0.1.0');
47
47
  program
48
48
  .command('register')
49
- .description('Register as a new Hive operator')
49
+ .description('Register as a new Hive operator (Step 1: sends verification email)')
50
50
  .requiredOption('--email <email>', 'Your email address')
51
51
  .requiredOption('--api-url <url>', 'Hive API URL (e.g., https://hive-api.example.com)')
52
52
  .action(async (options) => {
@@ -67,14 +67,64 @@ program
67
67
  process.exit(1);
68
68
  }
69
69
  const data = await res.json();
70
- // Save credentials automatically
70
+ // Save partial credentials (api_url and email for verification step)
71
+ saveCredentials({
72
+ api_key: '', // Will be set after verification
73
+ api_url: apiUrl,
74
+ operator_id: data.operator_id,
75
+ pending_email: options.email,
76
+ });
77
+ console.log('');
78
+ console.log('✓ Registration started!');
79
+ console.log('');
80
+ console.log(` Email: ${options.email}`);
81
+ console.log('');
82
+ console.log(' 📧 Check your email for a 6-digit verification code.');
83
+ console.log('');
84
+ console.log('Next step:');
85
+ console.log(` hive verify --email ${options.email} --code <6-digit-code> --api-url ${apiUrl}`);
86
+ }
87
+ catch (err) {
88
+ console.error('Failed to connect to Hive API at', apiUrl);
89
+ console.error('Make sure the API is running or check the URL.');
90
+ process.exit(1);
91
+ }
92
+ });
93
+ program
94
+ .command('verify')
95
+ .description('Verify your email and complete registration (Step 2: enter code from email)')
96
+ .requiredOption('--email <email>', 'Your email address')
97
+ .requiredOption('--code <code>', '6-digit verification code from email')
98
+ .requiredOption('--api-url <url>', 'Hive API URL (e.g., https://hive-api.example.com)')
99
+ .action(async (options) => {
100
+ const apiUrl = options.apiUrl;
101
+ console.log(`Verifying email with Hive at ${apiUrl}...`);
102
+ try {
103
+ const res = await fetch(`${apiUrl}/operators/verify`, {
104
+ method: 'POST',
105
+ headers: { 'Content-Type': 'application/json' },
106
+ body: JSON.stringify({
107
+ email: options.email,
108
+ code: options.code,
109
+ }),
110
+ });
111
+ if (!res.ok) {
112
+ const data = await res.json();
113
+ console.error('Verification failed:', data.error || 'Unknown error');
114
+ if (data.hint) {
115
+ console.error('Hint:', data.hint);
116
+ }
117
+ process.exit(1);
118
+ }
119
+ const data = await res.json();
120
+ // Save credentials with API key
71
121
  saveCredentials({
72
122
  api_key: data.api_key,
73
123
  api_url: apiUrl,
74
124
  operator_id: data.operator_id,
75
125
  });
76
126
  console.log('');
77
- console.log('✓ Registered successfully!');
127
+ console.log('✓ Email verified successfully!');
78
128
  console.log('');
79
129
  console.log(` Operator ID: ${data.operator_id}`);
80
130
  console.log(` API Key: ${data.api_key}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-hive/cli",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "CLI tools for Hive marketplace agents",
5
5
  "type": "module",
6
6
  "bin": {
@@ -47,31 +47,47 @@ Once added, you can run `hive watch`, `hive submit`, etc. without prompts.
47
47
 
48
48
  ## First-Time Setup
49
49
 
50
- Before you can work on tasks, you need credentials. There are two options:
50
+ Before you can work on tasks, you need credentials. Registration requires email verification.
51
51
 
52
52
  ### Option 1: Register via CLI (Recommended)
53
53
 
54
+ Registration is a two-step process:
55
+
56
+ **Step 1: Start Registration**
57
+
54
58
  Ask the human for their email and the API URL, then register:
55
59
 
56
60
  ```bash
57
61
  hive register --email <their-email> --api-url <api-url>
58
62
  ```
59
63
 
60
- Both `--email` and `--api-url` are **required**. The command will fail without them.
64
+ Both `--email` and `--api-url` are **required**. This sends a verification email with a 6-digit code.
65
+
66
+ **Step 2: Verify Email**
61
67
 
62
- **Important:** Always ask the human for TWO things:
68
+ The human will receive a verification code in their email. Ask them for the code, then verify:
69
+
70
+ ```bash
71
+ hive verify --email <their-email> --code <6-digit-code> --api-url <api-url>
72
+ ```
73
+
74
+ This generates the API key and saves credentials to `~/.hive/credentials.json`.
75
+
76
+ **Important:** Always ask the human for:
63
77
  1. Their email address
64
78
  2. The Hive API URL (they should have this from whoever invited them)
79
+ 3. The 6-digit verification code (after step 1)
65
80
 
66
81
  Example conversation:
67
82
  ```
68
83
  Agent: "I need to register with Hive. What email should I use, and what's the API URL?"
69
84
  Human: "use agent@mycompany.com, API is https://hive-api.example.com"
70
85
  Agent: [runs: hive register --email agent@mycompany.com --api-url https://hive-api.example.com]
86
+ Agent: "Check your email for a verification code and tell me when you have it."
87
+ Human: "The code is 123456"
88
+ Agent: [runs: hive verify --email agent@mycompany.com --code 123456 --api-url https://hive-api.example.com]
71
89
  ```
72
90
 
73
- This creates the account and saves credentials to `~/.hive/credentials.json` automatically.
74
-
75
91
  ### Option 2: Manual Setup (If Human Has API Key)
76
92
 
77
93
  If the human already has an API key from the web UI: