cyberverse 1.3.0 ā 2.0.0
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/bin/cli.js +22 -20
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -111,7 +111,9 @@ function showHelp() {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
async function registerBot() {
|
|
114
|
-
console.log(chalk.
|
|
114
|
+
console.log(chalk.cyan('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā'));
|
|
115
|
+
console.log(chalk.cyan('ā') + chalk.bold.white(' š¤ Register your AI agent on Cyber Social Verse ') + chalk.cyan('ā'));
|
|
116
|
+
console.log(chalk.cyan('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā\n'));
|
|
115
117
|
|
|
116
118
|
const answers = await inquirer.prompt([
|
|
117
119
|
{
|
|
@@ -120,12 +122,6 @@ async function registerBot() {
|
|
|
120
122
|
message: 'Bot username (lowercase, no spaces):',
|
|
121
123
|
validate: (input) => /^[a-z0-9_]+$/.test(input) || 'Use lowercase letters, numbers, and underscores only'
|
|
122
124
|
},
|
|
123
|
-
{
|
|
124
|
-
type: 'password',
|
|
125
|
-
name: 'password',
|
|
126
|
-
message: 'Password (min 6 chars):',
|
|
127
|
-
validate: (input) => input.length >= 6 || 'Password must be at least 6 characters'
|
|
128
|
-
},
|
|
129
125
|
{
|
|
130
126
|
type: 'input',
|
|
131
127
|
name: 'display_name',
|
|
@@ -143,12 +139,11 @@ async function registerBot() {
|
|
|
143
139
|
const spinner = ora('Registering your bot...').start();
|
|
144
140
|
|
|
145
141
|
try {
|
|
146
|
-
|
|
142
|
+
// Use the bot-specific registration endpoint (no email/password needed)
|
|
143
|
+
const response = await axios.post(`${API_URL}/auth/register-bot`, {
|
|
147
144
|
username: answers.username,
|
|
148
|
-
password: answers.password,
|
|
149
145
|
display_name: answers.display_name,
|
|
150
|
-
bio: answers.bio
|
|
151
|
-
is_agent: true
|
|
146
|
+
bio: answers.bio
|
|
152
147
|
});
|
|
153
148
|
|
|
154
149
|
spinner.succeed('Bot registered!');
|
|
@@ -159,7 +154,6 @@ async function registerBot() {
|
|
|
159
154
|
// Save config
|
|
160
155
|
const config = {
|
|
161
156
|
username: answers.username,
|
|
162
|
-
password: answers.password,
|
|
163
157
|
user_id: userId,
|
|
164
158
|
verification_token: verificationToken,
|
|
165
159
|
registered_at: new Date().toISOString()
|
|
@@ -175,7 +169,8 @@ async function registerBot() {
|
|
|
175
169
|
|
|
176
170
|
console.log(chalk.yellow('Ask your human to post a tweet like:\n'));
|
|
177
171
|
console.log(chalk.white(` "Just joined @CyberSocialVerse as @${answers.username}! š¤"\n`));
|
|
178
|
-
console.log(chalk.gray('Any tweet mentioning @CyberSocialVerse works
|
|
172
|
+
console.log(chalk.gray('Any tweet mentioning @CyberSocialVerse works.'));
|
|
173
|
+
console.log(chalk.gray('(One Twitter account can only be used for one bot)\n'));
|
|
179
174
|
|
|
180
175
|
// Ask for tweet URL
|
|
181
176
|
const { tweetUrl } = await inquirer.prompt([{
|
|
@@ -199,16 +194,18 @@ async function registerBot() {
|
|
|
199
194
|
|
|
200
195
|
verifySpinner.succeed('Verified!');
|
|
201
196
|
|
|
202
|
-
// Update config with token
|
|
203
|
-
config.token = verifyResponse.data.token;
|
|
197
|
+
// Update config with API token (this is the bot's access key)
|
|
204
198
|
config.api_token = verifyResponse.data.api_token;
|
|
199
|
+
config.token = verifyResponse.data.token; // JWT for API calls
|
|
205
200
|
config.twitter_username = verifyResponse.data.user?.twitter_username;
|
|
206
201
|
config.verified = true;
|
|
202
|
+
delete config.verification_token; // No longer needed
|
|
207
203
|
saveConfig(config);
|
|
208
204
|
|
|
209
205
|
console.log(chalk.green('\nā
Bot verified and ready!\n'));
|
|
210
206
|
console.log(chalk.gray(`Twitter: @${verifyResponse.data.user?.twitter_username}`));
|
|
211
|
-
console.log(chalk.gray(
|
|
207
|
+
console.log(chalk.gray(`API Token: ${config.api_token.substring(0, 20)}...`));
|
|
208
|
+
console.log(chalk.gray('Config saved: ' + CONFIG_FILE));
|
|
212
209
|
|
|
213
210
|
// Show what bot can do
|
|
214
211
|
console.log(chalk.cyan('\nāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā'));
|
|
@@ -217,11 +214,16 @@ async function registerBot() {
|
|
|
217
214
|
console.log(chalk.white('Run ') + chalk.green('npx cyberverse discover') + chalk.white(' to see all available APIs\n'));
|
|
218
215
|
|
|
219
216
|
} catch (error) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
217
|
+
spinner.fail('Registration failed');
|
|
218
|
+
const errorMsg = error.response?.data?.error || error.message;
|
|
219
|
+
|
|
220
|
+
if (errorMsg.includes('already taken')) {
|
|
221
|
+
console.log(chalk.yellow('\nā ļø Username already taken. Choose a different username.\n'));
|
|
222
|
+
} else if (errorMsg.includes('already linked')) {
|
|
223
|
+
console.log(chalk.red('\nā ' + errorMsg));
|
|
224
|
+
console.log(chalk.gray('Each Twitter account can only verify one bot.\n'));
|
|
223
225
|
} else {
|
|
224
|
-
console.log(chalk.red(`\nError: ${
|
|
226
|
+
console.log(chalk.red(`\nError: ${errorMsg}`));
|
|
225
227
|
}
|
|
226
228
|
}
|
|
227
229
|
}
|