qidao-openclaw-plugin 1.2.2 → 1.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qidao-openclaw-plugin",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "description": "OpenClaw 栖岛聊天 Channel 插件 - 连接到栖岛聊天服务",
@@ -0,0 +1,27 @@
1
+ /**
2
+ * 栖岛聊天认证 CLI 命令
3
+ */
4
+
5
+ export function registerAuthCommand(api) {
6
+ api.registerCli(
7
+ ({ program }) => {
8
+ program
9
+ .command('qidao-auth')
10
+ .description('栖岛聊天二维码认证')
11
+ .action(async () => {
12
+ console.log('🔐 开始栖岛聊天认证流程...');
13
+ console.log('');
14
+ console.log('请使用以下步骤完成认证:');
15
+ console.log('1. 访问栖岛官方网站');
16
+ console.log('2. 扫描二维码登录');
17
+ console.log('3. 获取您的 chatId');
18
+ console.log('');
19
+ console.log('然后运行:');
20
+ console.log(' openclaw config set channels.qidao.chatId <您的chatId>');
21
+ console.log(' openclaw config set channels.qidao.enabled true');
22
+ console.log(' openclaw gateway restart');
23
+ });
24
+ },
25
+ { commands: ['qidao-auth'] }
26
+ );
27
+ }
package/src/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  import { QidaoChannel } from './qidao-channel.js';
6
+ import { registerAuthCommand } from './auth-cli.js';
6
7
 
7
8
  let connection = null;
8
9
 
@@ -28,7 +29,7 @@ const qidaoChannel = {
28
29
 
29
30
  return {
30
31
  accountId: 'default',
31
- enabled: qidaoConfig.enabled ?? false,
32
+ enabled: qidaoConfig.enabled !== false,
32
33
  chatId: qidaoConfig.chatId,
33
34
  userId: qidaoConfig.userId,
34
35
  serverUrl: qidaoConfig.serverUrl ?? 'wss://oc.qidao.chat/ws',
@@ -40,14 +41,32 @@ const qidaoChannel = {
40
41
  configure: async ({ cfg, prompter }) => {
41
42
  const qidaoConfig = cfg.channels?.qidao ?? {};
42
43
 
43
- const chatId = await prompter.text({
44
- message: '请输入栖岛 Chat ID:',
45
- default: qidaoConfig.chatId?.toString() || '',
44
+ // 如果已经有 chatId,询问是否重新认证
45
+ if (qidaoConfig.chatId) {
46
+ const reauth = await prompter.confirm({
47
+ message: `已配置 chatId: ${qidaoConfig.chatId},是否重新认证?`,
48
+ default: false,
49
+ });
50
+
51
+ if (!reauth) {
52
+ return { cfg, accountId: 'default' };
53
+ }
54
+ }
55
+
56
+ // 提示用户将进行二维码认证
57
+ await prompter.text({
58
+ message: '请按回车开始二维码认证流程...',
59
+ default: '',
46
60
  });
47
61
 
48
- const userId = await prompter.text({
49
- message: '请输入栖岛 User ID (可选):',
50
- default: qidaoConfig.userId?.toString() || '',
62
+ // TODO: 这里需要实现二维码认证流程
63
+ // 由于 OpenClaw onboarding 是同步配置流程,
64
+ // 二维码认证需要异步操作(打开浏览器、轮询状态等)
65
+ // 暂时让用户手动输入 chatId
66
+
67
+ const chatId = await prompter.text({
68
+ message: '请输入栖岛 Chat ID (通过扫码获取):',
69
+ default: qidaoConfig.chatId?.toString() || '',
51
70
  });
52
71
 
53
72
  const serverUrl = await prompter.text({
@@ -62,7 +81,6 @@ const qidaoChannel = {
62
81
  qidao: {
63
82
  enabled: true,
64
83
  chatId: parseInt(chatId),
65
- userId: userId ? parseInt(userId) : undefined,
66
84
  serverUrl,
67
85
  },
68
86
  },
@@ -99,6 +117,9 @@ export default function register(api) {
99
117
 
100
118
  api.registerChannel({ plugin: qidaoChannel });
101
119
 
120
+ // 注册认证命令
121
+ registerAuthCommand(api);
122
+
102
123
  setImmediate(async () => {
103
124
  try {
104
125
  const cfg = api.getGatewayConfig?.() || {};