soulsync 1.0.14 → 1.0.16
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/index.js +27 -12
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -77,9 +77,10 @@ async function getUserGreeting(token, deviceName) {
|
|
|
77
77
|
|
|
78
78
|
function detectAuthMode(api) {
|
|
79
79
|
const hasChatAPI = api && typeof api.registerTool === 'function';
|
|
80
|
-
|
|
81
|
-
const isSSH = process.env.SSH_CLIENT || process.env.SSH_TTY;
|
|
82
|
-
|
|
80
|
+
|
|
81
|
+
const isSSH = process.env.SSH_CONNECTION || process.env.SSH_CLIENT || process.env.SSH_TTY;
|
|
82
|
+
const isLocalTTY = process.stdin.isTTY && !isSSH;
|
|
83
|
+
|
|
83
84
|
if (!hasChatAPI && isLocalTTY) return 'oauth-local';
|
|
84
85
|
if (!hasChatAPI && isSSH) return 'device-code-cli';
|
|
85
86
|
return 'device-code-chat';
|
|
@@ -402,13 +403,13 @@ module.exports = function register(api) {
|
|
|
402
403
|
|
|
403
404
|
api.registerTool({
|
|
404
405
|
name: 'soulsync_connect',
|
|
405
|
-
description: '
|
|
406
|
+
description: '连接 SoulSync 灵魂同步服务。当用户说"安装soulsync"、"配置soulsync"、"连接soulsync"、"设置同步"、"开启灵魂同步"时调用。无需账号密码,会提供浏览器授权链接。',
|
|
406
407
|
input_schema: { type: 'object', properties: {}, required: [] }
|
|
407
408
|
}, async () => {
|
|
408
409
|
if (isAuthenticated()) {
|
|
409
|
-
return 'SoulSync
|
|
410
|
+
return 'SoulSync 已连接。使用 soulsync_status 查看状态。';
|
|
410
411
|
}
|
|
411
|
-
|
|
412
|
+
|
|
412
413
|
const result = await startDeviceCodeFlow();
|
|
413
414
|
return result.message;
|
|
414
415
|
});
|
|
@@ -527,20 +528,34 @@ module.exports = function register(api) {
|
|
|
527
528
|
program
|
|
528
529
|
.command('soulsync:start')
|
|
529
530
|
.description('启动 SoulSync 同步服务')
|
|
530
|
-
.action(() => {
|
|
531
|
+
.action(async () => {
|
|
531
532
|
if (!isAuthenticated()) {
|
|
532
533
|
console.log('[SoulSync] Not configured. Starting device authorization flow...');
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
534
|
+
|
|
535
|
+
const authMode = detectAuthMode(null);
|
|
536
|
+
let result;
|
|
537
|
+
|
|
538
|
+
if (authMode === 'oauth-local') {
|
|
539
|
+
result = await startOAuthLocal();
|
|
540
|
+
} else if (authMode === 'device-code-cli') {
|
|
541
|
+
result = await startDeviceCodeCLI();
|
|
542
|
+
} else {
|
|
543
|
+
result = await startDeviceCodeFlow();
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
if (result.success) {
|
|
547
|
+
console.log(result.message);
|
|
548
|
+
} else {
|
|
549
|
+
console.error(`[SoulSync] ${result.message}`);
|
|
550
|
+
}
|
|
536
551
|
return;
|
|
537
552
|
}
|
|
538
|
-
|
|
553
|
+
|
|
539
554
|
if (pythonProcess) {
|
|
540
555
|
console.log('[SoulSync] Service already running');
|
|
541
556
|
return;
|
|
542
557
|
}
|
|
543
|
-
|
|
558
|
+
|
|
544
559
|
startPythonService('--start');
|
|
545
560
|
});
|
|
546
561
|
},
|