@gopherhole/cli 0.1.21 → 0.1.23

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 (3) hide show
  1. package/dist/index.js +41 -57
  2. package/package.json +1 -1
  3. package/src/index.ts +45 -57
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ const brand = {
19
19
  greenDark: chalk_1.default.hex('#16a34a'), // gopher-600 - emphasis
20
20
  };
21
21
  // Version
22
- const VERSION = '0.1.14';
22
+ const VERSION = '0.1.23';
23
23
  // ASCII art banner
24
24
  function showBanner(context) {
25
25
  const gopher = [
@@ -285,7 +285,7 @@ ${chalk_1.default.bold('Example:')}
285
285
  -H "Content-Type: application/json" \\
286
286
  -d '{
287
287
  "jsonrpc": "2.0",
288
- "method": "message/send",
288
+ "method": "SendMessage",
289
289
  "params": {
290
290
  "message": { "role": "user", "parts": [{ "kind": "text", "text": "Hello!" }] },
291
291
  "configuration": { "agentId": "echo" }
@@ -895,62 +895,46 @@ ${chalk_1.default.bold('Example:')}
895
895
  // Check if logged in
896
896
  if (!sessionId) {
897
897
  console.log(chalk_1.default.yellow('Not logged in yet.\n'));
898
- const { action } = await inquirer_1.default.prompt([
899
- {
900
- type: 'list',
901
- name: 'action',
902
- message: 'Choose:',
903
- choices: [
904
- { name: 'Create account', value: 'signup' },
905
- { name: 'Log in', value: 'login' },
906
- ],
907
- },
898
+ // OTP-based auth flow
899
+ const { email } = await inquirer_1.default.prompt([
900
+ { type: 'input', name: 'email', message: 'Email:', validate: (v) => v.includes('@') || 'Enter a valid email' },
908
901
  ]);
909
- if (action === 'signup') {
910
- const { name, email, password } = await inquirer_1.default.prompt([
911
- { type: 'input', name: 'name', message: 'Name:' },
912
- { type: 'input', name: 'email', message: 'Email:' },
913
- { type: 'password', name: 'password', message: 'Password:' },
914
- ]);
915
- const spinner = (0, ora_1.default)('Creating account...').start();
916
- const res = await fetch(`${API_URL}/auth/signup`, {
917
- method: 'POST',
918
- headers: { 'Content-Type': 'application/json' },
919
- body: JSON.stringify({ name, email, password }),
920
- });
921
- if (!res.ok) {
922
- spinner.fail('Signup failed');
923
- process.exit(1);
924
- }
925
- const data = await res.json();
926
- config.set('sessionId', data.sessionId);
927
- config.set('user', data.user);
928
- config.set('tenant', data.tenant);
929
- sessionId = data.sessionId;
930
- spinner.succeed('Account created!');
902
+ let spinner = (0, ora_1.default)('Sending verification code...').start();
903
+ const sendRes = await fetch(`${API_URL}/auth/send-code`, {
904
+ method: 'POST',
905
+ headers: { 'Content-Type': 'application/json' },
906
+ body: JSON.stringify({ email }),
907
+ });
908
+ if (!sendRes.ok) {
909
+ const err = await sendRes.json().catch(() => ({}));
910
+ spinner.fail(err.error || 'Failed to send code');
911
+ process.exit(1);
931
912
  }
932
- else {
933
- const { email, password } = await inquirer_1.default.prompt([
934
- { type: 'input', name: 'email', message: 'Email:' },
935
- { type: 'password', name: 'password', message: 'Password:' },
936
- ]);
937
- const spinner = (0, ora_1.default)('Logging in...').start();
938
- const res = await fetch(`${API_URL}/auth/login`, {
939
- method: 'POST',
940
- headers: { 'Content-Type': 'application/json' },
941
- body: JSON.stringify({ email, password }),
942
- });
943
- if (!res.ok) {
944
- spinner.fail('Login failed');
945
- process.exit(1);
946
- }
947
- const data = await res.json();
948
- config.set('sessionId', data.sessionId);
949
- config.set('user', data.user);
950
- config.set('tenant', data.tenant);
951
- sessionId = data.sessionId;
952
- spinner.succeed('Logged in!');
913
+ const sendData = await sendRes.json();
914
+ spinner.succeed('Code sent! Check your email.');
915
+ if (sendData.isNewUser) {
916
+ console.log(chalk_1.default.gray(' No account found - we\'ll create one for you.\n'));
917
+ }
918
+ const { code } = await inquirer_1.default.prompt([
919
+ { type: 'input', name: 'code', message: 'Enter 6-digit code:', validate: (v) => /^\d{6}$/.test(v) || 'Enter 6 digits' },
920
+ ]);
921
+ spinner = (0, ora_1.default)('Verifying...').start();
922
+ const verifyRes = await fetch(`${API_URL}/auth/verify-code`, {
923
+ method: 'POST',
924
+ headers: { 'Content-Type': 'application/json' },
925
+ body: JSON.stringify({ email, code }),
926
+ });
927
+ if (!verifyRes.ok) {
928
+ const err = await verifyRes.json().catch(() => ({}));
929
+ spinner.fail(err.error || 'Verification failed');
930
+ process.exit(1);
953
931
  }
932
+ const data = await verifyRes.json();
933
+ config.set('sessionId', data.sessionId);
934
+ config.set('user', data.user);
935
+ config.set('tenant', data.tenant);
936
+ sessionId = data.sessionId;
937
+ spinner.succeed(data.isNewUser ? 'Account created!' : 'Logged in!');
954
938
  }
955
939
  console.log('');
956
940
  // Create agent
@@ -1058,7 +1042,7 @@ ${chalk_1.default.bold('Examples:')}
1058
1042
  process.exit(1);
1059
1043
  }
1060
1044
  const spinner = (0, ora_1.default)(`Sending to ${agentId}...`).start();
1061
- log('POST /a2a message/send', { to: agentId, message });
1045
+ log('POST /a2a SendMessage', { to: agentId, message });
1062
1046
  try {
1063
1047
  const res = await fetch(`${API_URL}/../a2a`, {
1064
1048
  method: 'POST',
@@ -1068,7 +1052,7 @@ ${chalk_1.default.bold('Examples:')}
1068
1052
  },
1069
1053
  body: JSON.stringify({
1070
1054
  jsonrpc: '2.0',
1071
- method: 'message/send',
1055
+ method: 'SendMessage',
1072
1056
  params: {
1073
1057
  message: { role: 'user', parts: [{ kind: 'text', text: message }] },
1074
1058
  configuration: { agentId },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gopherhole/cli",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "description": "GopherHole CLI - Connect AI agents to the world",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
package/src/index.ts CHANGED
@@ -18,7 +18,7 @@ const brand = {
18
18
  };
19
19
 
20
20
  // Version
21
- const VERSION = '0.1.14';
21
+ const VERSION = '0.1.23';
22
22
 
23
23
  // ASCII art banner
24
24
  function showBanner(context?: string) {
@@ -316,7 +316,7 @@ ${chalk.bold('Example:')}
316
316
  -H "Content-Type: application/json" \\
317
317
  -d '{
318
318
  "jsonrpc": "2.0",
319
- "method": "message/send",
319
+ "method": "SendMessage",
320
320
  "params": {
321
321
  "message": { "role": "user", "parts": [{ "kind": "text", "text": "Hello!" }] },
322
322
  "configuration": { "agentId": "echo" }
@@ -999,68 +999,56 @@ ${chalk.bold('Example:')}
999
999
  if (!sessionId) {
1000
1000
  console.log(chalk.yellow('Not logged in yet.\n'));
1001
1001
 
1002
- const { action } = await inquirer.prompt([
1003
- {
1004
- type: 'list',
1005
- name: 'action',
1006
- message: 'Choose:',
1007
- choices: [
1008
- { name: 'Create account', value: 'signup' },
1009
- { name: 'Log in', value: 'login' },
1010
- ],
1011
- },
1002
+ // OTP-based auth flow
1003
+ const { email } = await inquirer.prompt([
1004
+ { type: 'input', name: 'email', message: 'Email:', validate: (v: string) => v.includes('@') || 'Enter a valid email' },
1012
1005
  ]);
1013
1006
 
1014
- if (action === 'signup') {
1015
- const { name, email, password } = await inquirer.prompt([
1016
- { type: 'input', name: 'name', message: 'Name:' },
1017
- { type: 'input', name: 'email', message: 'Email:' },
1018
- { type: 'password', name: 'password', message: 'Password:' },
1019
- ]);
1007
+ let spinner = ora('Sending verification code...').start();
1020
1008
 
1021
- const spinner = ora('Creating account...').start();
1022
- const res = await fetch(`${API_URL}/auth/signup`, {
1023
- method: 'POST',
1024
- headers: { 'Content-Type': 'application/json' },
1025
- body: JSON.stringify({ name, email, password }),
1026
- });
1009
+ const sendRes = await fetch(`${API_URL}/auth/send-code`, {
1010
+ method: 'POST',
1011
+ headers: { 'Content-Type': 'application/json' },
1012
+ body: JSON.stringify({ email }),
1013
+ });
1027
1014
 
1028
- if (!res.ok) {
1029
- spinner.fail('Signup failed');
1030
- process.exit(1);
1031
- }
1015
+ if (!sendRes.ok) {
1016
+ const err = await sendRes.json().catch(() => ({}));
1017
+ spinner.fail(err.error || 'Failed to send code');
1018
+ process.exit(1);
1019
+ }
1032
1020
 
1033
- const data = await res.json();
1034
- config.set('sessionId', data.sessionId);
1035
- config.set('user', data.user);
1036
- config.set('tenant', data.tenant);
1037
- sessionId = data.sessionId;
1038
- spinner.succeed('Account created!');
1039
- } else {
1040
- const { email, password } = await inquirer.prompt([
1041
- { type: 'input', name: 'email', message: 'Email:' },
1042
- { type: 'password', name: 'password', message: 'Password:' },
1043
- ]);
1021
+ const sendData = await sendRes.json();
1022
+ spinner.succeed('Code sent! Check your email.');
1023
+
1024
+ if (sendData.isNewUser) {
1025
+ console.log(chalk.gray(' No account found - we\'ll create one for you.\n'));
1026
+ }
1044
1027
 
1045
- const spinner = ora('Logging in...').start();
1046
- const res = await fetch(`${API_URL}/auth/login`, {
1047
- method: 'POST',
1048
- headers: { 'Content-Type': 'application/json' },
1049
- body: JSON.stringify({ email, password }),
1050
- });
1028
+ const { code } = await inquirer.prompt([
1029
+ { type: 'input', name: 'code', message: 'Enter 6-digit code:', validate: (v: string) => /^\d{6}$/.test(v) || 'Enter 6 digits' },
1030
+ ]);
1051
1031
 
1052
- if (!res.ok) {
1053
- spinner.fail('Login failed');
1054
- process.exit(1);
1055
- }
1032
+ spinner = ora('Verifying...').start();
1056
1033
 
1057
- const data = await res.json();
1058
- config.set('sessionId', data.sessionId);
1059
- config.set('user', data.user);
1060
- config.set('tenant', data.tenant);
1061
- sessionId = data.sessionId;
1062
- spinner.succeed('Logged in!');
1034
+ const verifyRes = await fetch(`${API_URL}/auth/verify-code`, {
1035
+ method: 'POST',
1036
+ headers: { 'Content-Type': 'application/json' },
1037
+ body: JSON.stringify({ email, code }),
1038
+ });
1039
+
1040
+ if (!verifyRes.ok) {
1041
+ const err = await verifyRes.json().catch(() => ({}));
1042
+ spinner.fail(err.error || 'Verification failed');
1043
+ process.exit(1);
1063
1044
  }
1045
+
1046
+ const data = await verifyRes.json();
1047
+ config.set('sessionId', data.sessionId);
1048
+ config.set('user', data.user);
1049
+ config.set('tenant', data.tenant);
1050
+ sessionId = data.sessionId;
1051
+ spinner.succeed(data.isNewUser ? 'Account created!' : 'Logged in!');
1064
1052
  }
1065
1053
 
1066
1054
  console.log('');
@@ -1181,7 +1169,7 @@ ${chalk.bold('Examples:')}
1181
1169
  }
1182
1170
 
1183
1171
  const spinner = ora(`Sending to ${agentId}...`).start();
1184
- log('POST /a2a message/send', { to: agentId, message });
1172
+ log('POST /a2a SendMessage', { to: agentId, message });
1185
1173
 
1186
1174
  try {
1187
1175
  const res = await fetch(`${API_URL}/../a2a`, {
@@ -1192,7 +1180,7 @@ ${chalk.bold('Examples:')}
1192
1180
  },
1193
1181
  body: JSON.stringify({
1194
1182
  jsonrpc: '2.0',
1195
- method: 'message/send',
1183
+ method: 'SendMessage',
1196
1184
  params: {
1197
1185
  message: { role: 'user', parts: [{ kind: 'text', text: message }] },
1198
1186
  configuration: { agentId },