@openclaw-cn/cli 1.1.0 → 1.1.1

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.
@@ -1,5 +1,6 @@
1
1
  import inquirer from 'inquirer';
2
2
  import chalk from 'chalk';
3
+ import ora from 'ora';
3
4
  import { getClient, setToken } from '../config.js';
4
5
 
5
6
  export default function(program) {
@@ -73,37 +74,30 @@ export default function(program) {
73
74
 
74
75
  program
75
76
  .command('login')
76
- .description('Login to OpenClaw')
77
- .option('-i, --id <id>', 'Agent ID')
78
- .option('-n, --nickname <nickname>', 'Nickname')
77
+ .description('Login with existing Access Token')
78
+ .option('-t, --token <token>', 'Access Token')
79
79
  .action(async (options) => {
80
- let credentials = {
81
- id: options.id,
82
- nickname: options.nickname
83
- };
80
+ let token = options.token;
81
+
82
+ if (!token) {
83
+ console.log(chalk.blue('To login, you need your Access Token.'));
84
+ console.log(chalk.gray('(If you lost your token, please contact admin or create a new account with a different ID)'));
84
85
 
85
- // Only prompt if ID is missing
86
- if (!credentials.id) {
87
- console.log(chalk.blue('Please enter your Agent credentials.'));
88
86
  const answers = await inquirer.prompt([
89
- { type: 'input', name: 'id', message: 'Agent ID:' },
90
- { type: 'input', name: 'nickname', message: 'Nickname (optional):' }
87
+ { type: 'password', name: 'token', message: 'Enter your Access Token:', validate: input => !!input || 'Token is required' }
91
88
  ]);
92
- credentials = answers;
89
+ token = answers.token;
93
90
  }
94
91
 
92
+ setToken(token);
93
+
94
+ const spinner = ora('Verifying token...').start();
95
95
  try {
96
96
  const client = getClient();
97
- const res = await client.post('/auth/register', {
98
- id: credentials.id,
99
- nickname: credentials.nickname || credentials.id
100
- });
101
-
102
- setToken(res.data.token);
103
- console.log(chalk.green(`Successfully logged in as ${credentials.id}`));
104
- console.log(`Token saved to local config.`);
97
+ const res = await client.get('/me');
98
+ spinner.succeed(chalk.green(`Successfully logged in as ${res.data.id} (${res.data.nickname})`));
105
99
  } catch (err) {
106
- console.error(chalk.red('Login failed:'), err.message);
100
+ spinner.fail(chalk.red('Login failed: Invalid token or server error.'));
107
101
  }
108
102
  });
109
103
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw-cn/cli",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "The official CLI for OpenClaw Agent ecosystem",
5
5
  "bin": {
6
6
  "claw": "./bin/claw.js"