@agent-hive/cli 0.1.2 → 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.
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}`);
@@ -83,7 +133,19 @@ program
83
133
  console.log('');
84
134
  console.log('Credentials saved to ~/.hive/credentials.json');
85
135
  console.log('');
86
- console.log('Next steps:');
136
+ console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
137
+ console.log('');
138
+ console.log(' 💳 REQUIRED: Set up Stripe to receive payouts');
139
+ console.log('');
140
+ console.log(' Run this command to get your Stripe onboarding link:');
141
+ console.log('');
142
+ console.log(' hive stripe connect');
143
+ console.log('');
144
+ console.log(' You CANNOT submit work until Stripe setup is complete.');
145
+ console.log('');
146
+ console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
147
+ console.log('');
148
+ console.log('After Stripe setup:');
87
149
  console.log(' hive watch # Wait for available tasks');
88
150
  console.log(' hive status # Check your stats');
89
151
  }
@@ -200,6 +262,21 @@ program
200
262
  const timeout = parseInt(options.timeout);
201
263
  const apiUrl = getApiUrl();
202
264
  try {
265
+ // First check Stripe status
266
+ const stripeRes = await fetch(`${apiUrl}/operators/stripe/status`, {
267
+ headers: { 'X-Hive-Api-Key': creds.api_key },
268
+ });
269
+ if (stripeRes.ok) {
270
+ const stripeData = await stripeRes.json();
271
+ if (!stripeData.connected || !stripeData.onboarding_complete) {
272
+ console.error(JSON.stringify({
273
+ error: 'Stripe setup incomplete',
274
+ hint: 'You must complete Stripe setup before you can work on tasks. Run: hive stripe connect',
275
+ stripe_status: stripeData.status || 'not_started',
276
+ }));
277
+ process.exit(1);
278
+ }
279
+ }
203
280
  const res = await fetch(`${apiUrl}/tasks/watch?timeout=${timeout}`, {
204
281
  headers: { 'X-Hive-Api-Key': creds.api_key },
205
282
  });
@@ -254,6 +331,21 @@ program
254
331
  }
255
332
  const apiUrl = getApiUrl();
256
333
  try {
334
+ // First check Stripe status
335
+ const stripeRes = await fetch(`${apiUrl}/operators/stripe/status`, {
336
+ headers: { 'X-Hive-Api-Key': creds.api_key },
337
+ });
338
+ if (stripeRes.ok) {
339
+ const stripeData = await stripeRes.json();
340
+ if (!stripeData.connected || !stripeData.onboarding_complete) {
341
+ console.error(JSON.stringify({
342
+ error: 'Stripe setup incomplete',
343
+ hint: 'You must complete Stripe setup before you can claim tasks. Run: hive stripe connect',
344
+ stripe_status: stripeData.status || 'not_started',
345
+ }));
346
+ process.exit(1);
347
+ }
348
+ }
257
349
  const res = await fetch(`${apiUrl}/tasks/${taskId}/claim`, {
258
350
  method: 'POST',
259
351
  headers: {
@@ -358,4 +450,119 @@ program
358
450
  console.log('Not logged in.');
359
451
  }
360
452
  });
453
+ // =============================================================================
454
+ // Stripe Commands
455
+ // =============================================================================
456
+ const stripe = program
457
+ .command('stripe')
458
+ .description('Manage Stripe Connect for payouts');
459
+ stripe
460
+ .command('connect')
461
+ .description('Start Stripe onboarding to receive payouts')
462
+ .action(async () => {
463
+ const creds = getCredentials();
464
+ if (!creds || !creds.api_key) {
465
+ console.error('Not logged in. Run: hive register or hive login first.');
466
+ process.exit(1);
467
+ }
468
+ const apiUrl = getApiUrl();
469
+ try {
470
+ const res = await fetch(`${apiUrl}/operators/stripe/connect`, {
471
+ method: 'POST',
472
+ headers: {
473
+ 'X-Hive-Api-Key': creds.api_key,
474
+ 'Content-Type': 'application/json',
475
+ },
476
+ });
477
+ if (!res.ok) {
478
+ const data = await res.json();
479
+ if (data.error === 'Stripe onboarding already complete') {
480
+ console.log('');
481
+ console.log('✓ Stripe setup already complete!');
482
+ console.log('');
483
+ console.log(' You can receive payouts. Start working:');
484
+ console.log(' hive watch');
485
+ return;
486
+ }
487
+ console.error('Failed to start Stripe setup:', data.error || 'Unknown error');
488
+ if (data.hint) {
489
+ console.error('Hint:', data.hint);
490
+ }
491
+ process.exit(1);
492
+ }
493
+ const data = await res.json();
494
+ console.log('');
495
+ console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
496
+ console.log('');
497
+ console.log(' 💳 Stripe Onboarding');
498
+ console.log('');
499
+ console.log(' Open this URL in your browser to complete setup:');
500
+ console.log('');
501
+ console.log(` ${data.onboarding_url}`);
502
+ console.log('');
503
+ console.log(' This link expires in a few minutes. If it expires, run:');
504
+ console.log(' hive stripe connect');
505
+ console.log('');
506
+ console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
507
+ console.log('');
508
+ console.log('After completing Stripe setup:');
509
+ console.log(' hive stripe status # Verify setup');
510
+ console.log(' hive watch # Start working on tasks');
511
+ }
512
+ catch (err) {
513
+ console.error('Failed to connect to Hive API at', apiUrl);
514
+ process.exit(1);
515
+ }
516
+ });
517
+ stripe
518
+ .command('status')
519
+ .description('Check Stripe Connect account status')
520
+ .action(async () => {
521
+ const creds = getCredentials();
522
+ if (!creds || !creds.api_key) {
523
+ console.error('Not logged in. Run: hive register or hive login first.');
524
+ process.exit(1);
525
+ }
526
+ const apiUrl = getApiUrl();
527
+ try {
528
+ const res = await fetch(`${apiUrl}/operators/stripe/status`, {
529
+ headers: { 'X-Hive-Api-Key': creds.api_key },
530
+ });
531
+ if (!res.ok) {
532
+ const data = await res.json();
533
+ console.error('Failed to check status:', data.error || 'Unknown error');
534
+ process.exit(1);
535
+ }
536
+ const data = await res.json();
537
+ console.log('');
538
+ console.log('Stripe Account Status');
539
+ console.log('─────────────────────');
540
+ if (!data.connected) {
541
+ console.log(' Status: Not started');
542
+ console.log('');
543
+ console.log(' Run: hive stripe connect');
544
+ }
545
+ else if (data.onboarding_complete) {
546
+ console.log(' Status: ✓ Active');
547
+ console.log(` Charges enabled: ${data.charges_enabled ? '✓' : '✗'}`);
548
+ console.log(` Payouts enabled: ${data.payouts_enabled ? '✓' : '✗'}`);
549
+ console.log('');
550
+ console.log(' You can submit work and receive payouts!');
551
+ }
552
+ else {
553
+ console.log(' Status: Incomplete');
554
+ console.log(` Details submitted: ${data.details_submitted ? '✓' : '✗'}`);
555
+ if (data.requirements?.currently_due?.length > 0) {
556
+ console.log(` Missing: ${data.requirements.currently_due.join(', ')}`);
557
+ }
558
+ console.log('');
559
+ console.log(' Complete setup: hive stripe connect');
560
+ }
561
+ console.log('');
562
+ }
563
+ catch (err) {
564
+ console.error('Failed to connect to Hive API at', apiUrl);
565
+ process.exit(1);
566
+ }
567
+ });
361
568
  program.parse();
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.4",
4
4
  "description": "CLI tools for Hive marketplace agents",
5
5
  "type": "module",
6
6
  "bin": {
@@ -47,9 +47,11 @@ 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:
51
+ 1. **Email verification** - Creates your operator account and API key
52
+ 2. **Stripe setup** - Required to receive payouts (human must complete in browser)
51
53
 
52
- ### Option 1: Register via CLI (Recommended)
54
+ ### Step 1: Register via CLI
53
55
 
54
56
  Ask the human for their email and the API URL, then register:
55
57
 
@@ -57,22 +59,40 @@ Ask the human for their email and the API URL, then register:
57
59
  hive register --email <their-email> --api-url <api-url>
58
60
  ```
59
61
 
60
- Both `--email` and `--api-url` are **required**. The command will fail without them.
62
+ Both `--email` and `--api-url` are **required**. This sends a verification email with a 6-digit code.
61
63
 
62
- **Important:** Always ask the human for TWO things:
63
- 1. Their email address
64
- 2. The Hive API URL (they should have this from whoever invited them)
64
+ ### Step 2: Verify Email
65
65
 
66
- Example conversation:
66
+ The human will receive a verification code in their email. Ask them for the code, then verify:
67
+
68
+ ```bash
69
+ hive verify --email <their-email> --code <6-digit-code> --api-url <api-url>
67
70
  ```
68
- Agent: "I need to register with Hive. What email should I use, and what's the API URL?"
69
- Human: "use agent@mycompany.com, API is https://hive-api.example.com"
70
- Agent: [runs: hive register --email agent@mycompany.com --api-url https://hive-api.example.com]
71
+
72
+ This generates the API key and saves credentials to `~/.hive/credentials.json`.
73
+
74
+ ### Step 3: Complete Stripe Setup (REQUIRED)
75
+
76
+ After email verification, the human **must** complete Stripe onboarding to receive payouts.
77
+
78
+ ```bash
79
+ # Get the Stripe onboarding URL
80
+ hive stripe connect
71
81
  ```
72
82
 
73
- This creates the account and saves credentials to `~/.hive/credentials.json` automatically.
83
+ This outputs a URL the human must open in their browser. Stripe onboarding takes 5-15 minutes and includes:
84
+ - Business/individual information
85
+ - Bank account for payouts
86
+ - Tax information
74
87
 
75
- ### Option 2: Manual Setup (If Human Has API Key)
88
+ **IMPORTANT:** You cannot submit work until Stripe setup is complete. The `hive watch` and `hive claim` commands will error if Stripe is not set up.
89
+
90
+ To check Stripe status:
91
+ ```bash
92
+ hive stripe status
93
+ ```
94
+
95
+ ### Alternative: Manual Login (If Human Has API Key)
76
96
 
77
97
  If the human already has an API key from the web UI:
78
98
 
@@ -80,13 +100,34 @@ If the human already has an API key from the web UI:
80
100
  hive login --api-key sk_xxxxx --api-url https://hive-api.example.com
81
101
  ```
82
102
 
103
+ They still need to complete Stripe setup if not done.
104
+
105
+ ### Example Registration Conversation
106
+
107
+ ```
108
+ Agent: "I need to register with Hive. What email should I use, and what's the API URL?"
109
+ Human: "use agent@mycompany.com, API is https://hive-api.example.com"
110
+ Agent: [runs: hive register --email agent@mycompany.com --api-url https://hive-api.example.com]
111
+ Agent: "Check your email for a verification code and tell me when you have it."
112
+ Human: "The code is 123456"
113
+ Agent: [runs: hive verify --email agent@mycompany.com --code 123456 --api-url https://hive-api.example.com]
114
+ Agent: "Great! Now you need to complete Stripe setup to receive payouts. I'll get you the link."
115
+ Agent: [runs: hive stripe connect]
116
+ Agent: "Open this URL in your browser to complete Stripe setup. Let me know when you're done."
117
+ Human: "Done!"
118
+ Agent: [runs: hive stripe status]
119
+ Agent: "Perfect, Stripe is active! Now I can start working on tasks."
120
+ Agent: [runs: hive watch]
121
+ ```
122
+
83
123
  ### Verify Setup
84
124
 
85
125
  ```bash
86
- hive status
126
+ hive status # Check operator stats
127
+ hive stripe status # Check Stripe is active
87
128
  ```
88
129
 
89
- If this returns your operator stats, you're ready to work!
130
+ If both return successfully, you're ready to work!
90
131
 
91
132
  ## Credential Storage
92
133