@gopherhole/cli 0.1.7 → 0.1.8

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 +125 -3
  2. package/package.json +1 -1
  3. package/src/index.ts +133 -3
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.3';
22
+ const VERSION = '0.1.8';
23
23
  // ASCII art banner
24
24
  function showBanner(context) {
25
25
  const gopher = [
@@ -727,6 +727,125 @@ ${chalk_1.default.bold('Examples:')}
727
727
  process.exit(1);
728
728
  }
729
729
  });
730
+ agents
731
+ .command('config <agentId>')
732
+ .description(`Configure agent settings
733
+
734
+ ${chalk_1.default.bold('Examples:')}
735
+ $ gopherhole agents config agent-abc123 --auto-approve
736
+ $ gopherhole agents config agent-abc123 --no-auto-approve
737
+ $ gopherhole agents config agent-abc123 --price 0.01 --price-unit request
738
+ $ gopherhole agents config agent-abc123 --visibility public
739
+ `)
740
+ .option('--auto-approve', 'Enable auto-approve (instant access for marketplace)')
741
+ .option('--no-auto-approve', 'Disable auto-approve (require manual approval)')
742
+ .option('--price <amount>', 'Set price per unit (e.g., 0.01)')
743
+ .option('--price-unit <unit>', 'Price unit: request, message, task, month, 1000-tokens')
744
+ .option('--clear-price', 'Remove pricing (make free)')
745
+ .option('--visibility <level>', 'Set visibility: public, unlisted, private')
746
+ .option('--category <category>', 'Set category')
747
+ .option('--tags <tags>', 'Set tags (comma-separated)')
748
+ .option('--description <text>', 'Update description')
749
+ .action(async (agentId, options) => {
750
+ const sessionId = config.get('sessionId');
751
+ if (!sessionId) {
752
+ console.log(chalk_1.default.yellow('Not logged in.'));
753
+ console.log(chalk_1.default.gray('Run: gopherhole login'));
754
+ process.exit(1);
755
+ }
756
+ // Build update body
757
+ const body = {};
758
+ if (options.autoApprove === true) {
759
+ body.auto_approve = true;
760
+ }
761
+ else if (options.autoApprove === false) {
762
+ body.auto_approve = false;
763
+ }
764
+ if (options.price !== undefined) {
765
+ body.price_amount = parseFloat(options.price);
766
+ body.price_currency = 'USD';
767
+ body.price_unit = options.priceUnit || 'request';
768
+ }
769
+ if (options.clearPrice) {
770
+ body.price_amount = null;
771
+ body.price_currency = null;
772
+ body.price_unit = null;
773
+ }
774
+ if (options.priceUnit && options.price === undefined && !options.clearPrice) {
775
+ body.price_unit = options.priceUnit;
776
+ }
777
+ if (options.visibility) {
778
+ body.visibility = options.visibility;
779
+ }
780
+ if (options.category) {
781
+ body.category = options.category;
782
+ }
783
+ if (options.tags) {
784
+ body.tags = options.tags.split(',').map((t) => t.trim());
785
+ }
786
+ if (options.description) {
787
+ body.description = options.description;
788
+ }
789
+ if (Object.keys(body).length === 0) {
790
+ console.log(chalk_1.default.yellow('No changes specified.'));
791
+ console.log(chalk_1.default.gray('Use --help to see available options.'));
792
+ return;
793
+ }
794
+ const spinner = (0, ora_1.default)('Updating agent config...').start();
795
+ log('PATCH /agents/' + agentId, body);
796
+ try {
797
+ const res = await fetch(`${API_URL}/agents/${agentId}`, {
798
+ method: 'PATCH',
799
+ headers: {
800
+ 'Content-Type': 'application/json',
801
+ 'X-Session-ID': sessionId,
802
+ },
803
+ body: JSON.stringify(body),
804
+ });
805
+ if (!res.ok) {
806
+ const err = await res.json();
807
+ logError('config', err);
808
+ throw new Error(err.error || 'Failed to update agent');
809
+ }
810
+ spinner.succeed('Agent config updated');
811
+ // Show what was changed
812
+ const changes = [];
813
+ if (body.auto_approve !== undefined) {
814
+ changes.push(` Auto-approve: ${body.auto_approve ? brand.green('enabled ⚡') : chalk_1.default.gray('disabled')}`);
815
+ }
816
+ if (body.price_amount !== undefined) {
817
+ if (body.price_amount === null) {
818
+ changes.push(` Pricing: ${brand.green('FREE')}`);
819
+ }
820
+ else {
821
+ changes.push(` Pricing: ${chalk_1.default.blue(`$${body.price_amount} per ${body.price_unit}`)}`);
822
+ }
823
+ }
824
+ if (body.visibility) {
825
+ changes.push(` Visibility: ${body.visibility}`);
826
+ }
827
+ if (body.category) {
828
+ changes.push(` Category: ${body.category}`);
829
+ }
830
+ if (body.tags) {
831
+ changes.push(` Tags: ${body.tags.join(', ')}`);
832
+ }
833
+ if (body.description) {
834
+ const desc = body.description;
835
+ changes.push(` Description: ${chalk_1.default.gray(desc.slice(0, 50))}${desc.length > 50 ? '...' : ''}`);
836
+ }
837
+ if (changes.length > 0) {
838
+ console.log('');
839
+ console.log(chalk_1.default.bold('Changes:'));
840
+ changes.forEach(c => console.log(c));
841
+ console.log('');
842
+ }
843
+ }
844
+ catch (err) {
845
+ spinner.fail(chalk_1.default.red(err.message));
846
+ process.exit(1);
847
+ }
848
+ });
730
849
  // ========== INIT COMMAND ==========
731
850
  program
732
851
  .command('init')
@@ -1001,7 +1120,8 @@ ${chalk_1.default.bold('Examples:')}
1001
1120
  const stars = '★'.repeat(Math.round(agent.avgRating)) + '☆'.repeat(5 - Math.round(agent.avgRating));
1002
1121
  const pricing = agent.pricing === 'free' ? brand.green('FREE') :
1003
1122
  agent.pricing === 'paid' ? chalk_1.default.blue('PAID') : chalk_1.default.gray('CONTACT');
1004
- console.log(` ${chalk_1.default.bold(agent.name)} ${chalk_1.default.yellow(stars)} (${agent.ratingCount})`);
1123
+ const instant = agent.autoApprove ? chalk_1.default.magenta('⚡INSTANT') : '';
1124
+ console.log(` ${chalk_1.default.bold(agent.name)} ${chalk_1.default.yellow(stars)} (${agent.ratingCount}) ${instant}`);
1005
1125
  console.log(` ${chalk_1.default.gray(agent.description || 'No description')}`);
1006
1126
  console.log(` ${chalk_1.default.cyan(agent.id)} | ${pricing} | ${agent.category || 'uncategorized'}`);
1007
1127
  console.log('');
@@ -1053,7 +1173,8 @@ discover
1053
1173
  console.log(chalk_1.default.bold('\n⭐ Featured Agents:\n'));
1054
1174
  for (const agent of data.featured) {
1055
1175
  const stars = '★'.repeat(Math.round(agent.avgRating)) + '☆'.repeat(5 - Math.round(agent.avgRating));
1056
- console.log(` ${chalk_1.default.bold(agent.name)} ${chalk_1.default.yellow(stars)}`);
1176
+ const instant = agent.autoApprove ? chalk_1.default.magenta('⚡INSTANT') : '';
1177
+ console.log(` ${chalk_1.default.bold(agent.name)} ${chalk_1.default.yellow(stars)} ${instant}`);
1057
1178
  console.log(` ${chalk_1.default.gray(agent.description || 'No description')}`);
1058
1179
  console.log(` ${chalk_1.default.cyan(agent.id)}`);
1059
1180
  console.log('');
@@ -1093,6 +1214,7 @@ ${chalk_1.default.bold('Example:')}
1093
1214
  console.log(` ${chalk_1.default.bold('Pricing:')} ${agent.pricing}`);
1094
1215
  console.log(` ${chalk_1.default.bold('Category:')} ${agent.category || 'None'}`);
1095
1216
  console.log(` ${chalk_1.default.bold('By:')} ${agent.tenantName}`);
1217
+ console.log(` ${chalk_1.default.bold('Access:')} ${agent.autoApprove ? chalk_1.default.magenta('⚡ Instant (no approval needed)') : chalk_1.default.gray('Requires approval')}`);
1096
1218
  if (agent.tags.length > 0) {
1097
1219
  console.log(` ${chalk_1.default.bold('Tags:')} ${agent.tags.join(', ')}`);
1098
1220
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gopherhole/cli",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
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.3';
21
+ const VERSION = '0.1.8';
22
22
 
23
23
  // ASCII art banner
24
24
  function showBanner(context?: string) {
@@ -809,6 +809,133 @@ ${chalk.bold('Examples:')}
809
809
  }
810
810
  });
811
811
 
812
+ agents
813
+ .command('config <agentId>')
814
+ .description(`Configure agent settings
815
+
816
+ ${chalk.bold('Examples:')}
817
+ $ gopherhole agents config agent-abc123 --auto-approve
818
+ $ gopherhole agents config agent-abc123 --no-auto-approve
819
+ $ gopherhole agents config agent-abc123 --price 0.01 --price-unit request
820
+ $ gopherhole agents config agent-abc123 --visibility public
821
+ `)
822
+ .option('--auto-approve', 'Enable auto-approve (instant access for marketplace)')
823
+ .option('--no-auto-approve', 'Disable auto-approve (require manual approval)')
824
+ .option('--price <amount>', 'Set price per unit (e.g., 0.01)')
825
+ .option('--price-unit <unit>', 'Price unit: request, message, task, month, 1000-tokens')
826
+ .option('--clear-price', 'Remove pricing (make free)')
827
+ .option('--visibility <level>', 'Set visibility: public, unlisted, private')
828
+ .option('--category <category>', 'Set category')
829
+ .option('--tags <tags>', 'Set tags (comma-separated)')
830
+ .option('--description <text>', 'Update description')
831
+ .action(async (agentId, options) => {
832
+ const sessionId = config.get('sessionId') as string;
833
+ if (!sessionId) {
834
+ console.log(chalk.yellow('Not logged in.'));
835
+ console.log(chalk.gray('Run: gopherhole login'));
836
+ process.exit(1);
837
+ }
838
+
839
+ // Build update body
840
+ const body: Record<string, unknown> = {};
841
+
842
+ if (options.autoApprove === true) {
843
+ body.auto_approve = true;
844
+ } else if (options.autoApprove === false) {
845
+ body.auto_approve = false;
846
+ }
847
+
848
+ if (options.price !== undefined) {
849
+ body.price_amount = parseFloat(options.price);
850
+ body.price_currency = 'USD';
851
+ body.price_unit = options.priceUnit || 'request';
852
+ }
853
+ if (options.clearPrice) {
854
+ body.price_amount = null;
855
+ body.price_currency = null;
856
+ body.price_unit = null;
857
+ }
858
+ if (options.priceUnit && options.price === undefined && !options.clearPrice) {
859
+ body.price_unit = options.priceUnit;
860
+ }
861
+ if (options.visibility) {
862
+ body.visibility = options.visibility;
863
+ }
864
+ if (options.category) {
865
+ body.category = options.category;
866
+ }
867
+ if (options.tags) {
868
+ body.tags = options.tags.split(',').map((t: string) => t.trim());
869
+ }
870
+ if (options.description) {
871
+ body.description = options.description;
872
+ }
873
+
874
+ if (Object.keys(body).length === 0) {
875
+ console.log(chalk.yellow('No changes specified.'));
876
+ console.log(chalk.gray('Use --help to see available options.'));
877
+ return;
878
+ }
879
+
880
+ const spinner = ora('Updating agent config...').start();
881
+ log('PATCH /agents/' + agentId, body);
882
+
883
+ try {
884
+ const res = await fetch(`${API_URL}/agents/${agentId}`, {
885
+ method: 'PATCH',
886
+ headers: {
887
+ 'Content-Type': 'application/json',
888
+ 'X-Session-ID': sessionId,
889
+ },
890
+ body: JSON.stringify(body),
891
+ });
892
+
893
+ if (!res.ok) {
894
+ const err = await res.json();
895
+ logError('config', err);
896
+ throw new Error(err.error || 'Failed to update agent');
897
+ }
898
+
899
+ spinner.succeed('Agent config updated');
900
+
901
+ // Show what was changed
902
+ const changes: string[] = [];
903
+ if (body.auto_approve !== undefined) {
904
+ changes.push(` Auto-approve: ${body.auto_approve ? brand.green('enabled ⚡') : chalk.gray('disabled')}`);
905
+ }
906
+ if (body.price_amount !== undefined) {
907
+ if (body.price_amount === null) {
908
+ changes.push(` Pricing: ${brand.green('FREE')}`);
909
+ } else {
910
+ changes.push(` Pricing: ${chalk.blue(`$${body.price_amount} per ${body.price_unit}`)}`);
911
+ }
912
+ }
913
+ if (body.visibility) {
914
+ changes.push(` Visibility: ${body.visibility}`);
915
+ }
916
+ if (body.category) {
917
+ changes.push(` Category: ${body.category}`);
918
+ }
919
+ if (body.tags) {
920
+ changes.push(` Tags: ${(body.tags as string[]).join(', ')}`);
921
+ }
922
+ if (body.description) {
923
+ const desc = body.description as string;
924
+ changes.push(` Description: ${chalk.gray(desc.slice(0, 50))}${desc.length > 50 ? '...' : ''}`);
925
+ }
926
+
927
+ if (changes.length > 0) {
928
+ console.log('');
929
+ console.log(chalk.bold('Changes:'));
930
+ changes.forEach(c => console.log(c));
931
+ console.log('');
932
+ }
933
+ } catch (err) {
934
+ spinner.fail(chalk.red((err as Error).message));
935
+ process.exit(1);
936
+ }
937
+ });
938
+
812
939
  // ========== INIT COMMAND ==========
813
940
 
814
941
  program
@@ -1114,8 +1241,9 @@ ${chalk.bold('Examples:')}
1114
1241
  const stars = '★'.repeat(Math.round(agent.avgRating)) + '☆'.repeat(5 - Math.round(agent.avgRating));
1115
1242
  const pricing = agent.pricing === 'free' ? brand.green('FREE') :
1116
1243
  agent.pricing === 'paid' ? chalk.blue('PAID') : chalk.gray('CONTACT');
1244
+ const instant = agent.autoApprove ? chalk.magenta('⚡INSTANT') : '';
1117
1245
 
1118
- console.log(` ${chalk.bold(agent.name)} ${chalk.yellow(stars)} (${agent.ratingCount})`);
1246
+ console.log(` ${chalk.bold(agent.name)} ${chalk.yellow(stars)} (${agent.ratingCount}) ${instant}`);
1119
1247
  console.log(` ${chalk.gray(agent.description || 'No description')}`);
1120
1248
  console.log(` ${chalk.cyan(agent.id)} | ${pricing} | ${agent.category || 'uncategorized'}`);
1121
1249
  console.log('');
@@ -1174,7 +1302,8 @@ discover
1174
1302
  console.log(chalk.bold('\n⭐ Featured Agents:\n'));
1175
1303
  for (const agent of data.featured) {
1176
1304
  const stars = '★'.repeat(Math.round(agent.avgRating)) + '☆'.repeat(5 - Math.round(agent.avgRating));
1177
- console.log(` ${chalk.bold(agent.name)} ${chalk.yellow(stars)}`);
1305
+ const instant = agent.autoApprove ? chalk.magenta('⚡INSTANT') : '';
1306
+ console.log(` ${chalk.bold(agent.name)} ${chalk.yellow(stars)} ${instant}`);
1178
1307
  console.log(` ${chalk.gray(agent.description || 'No description')}`);
1179
1308
  console.log(` ${chalk.cyan(agent.id)}`);
1180
1309
  console.log('');
@@ -1217,6 +1346,7 @@ ${chalk.bold('Example:')}
1217
1346
  console.log(` ${chalk.bold('Pricing:')} ${agent.pricing}`);
1218
1347
  console.log(` ${chalk.bold('Category:')} ${agent.category || 'None'}`);
1219
1348
  console.log(` ${chalk.bold('By:')} ${agent.tenantName}`);
1349
+ console.log(` ${chalk.bold('Access:')} ${agent.autoApprove ? chalk.magenta('⚡ Instant (no approval needed)') : chalk.gray('Requires approval')}`);
1220
1350
 
1221
1351
  if (agent.tags.length > 0) {
1222
1352
  console.log(` ${chalk.bold('Tags:')} ${agent.tags.join(', ')}`);