soulsync 1.0.15 → 1.0.17
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 +44 -30
- 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';
|
|
@@ -351,33 +352,47 @@ async function startDeviceCodeFlow() {
|
|
|
351
352
|
|
|
352
353
|
module.exports = function register(api) {
|
|
353
354
|
console.log('[SoulSync] Registering plugin...');
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
if (
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
355
|
+
|
|
356
|
+
registerChatTools(api);
|
|
357
|
+
|
|
358
|
+
api.registerCli(
|
|
359
|
+
({ program }) => {
|
|
360
|
+
program
|
|
361
|
+
.command('soulsync:start')
|
|
362
|
+
.description('启动 SoulSync 同步服务')
|
|
363
|
+
.action(async () => {
|
|
364
|
+
if (!isAuthenticated()) {
|
|
365
|
+
console.log('[SoulSync] Not configured. Starting device authorization flow...');
|
|
366
|
+
|
|
367
|
+
const authMode = detectAuthMode(null);
|
|
368
|
+
let result;
|
|
369
|
+
|
|
370
|
+
if (authMode === 'oauth-local') {
|
|
371
|
+
result = await startOAuthLocal();
|
|
372
|
+
} else if (authMode === 'device-code-cli') {
|
|
373
|
+
result = await startDeviceCodeCLI();
|
|
374
|
+
} else {
|
|
375
|
+
result = await startDeviceCodeFlow();
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
if (result.success) {
|
|
379
|
+
console.log(result.message);
|
|
380
|
+
} else {
|
|
381
|
+
console.error(`[SoulSync] ${result.message}`);
|
|
382
|
+
}
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if (pythonProcess) {
|
|
387
|
+
console.log('[SoulSync] Service already running');
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
startPythonService('--start');
|
|
370
392
|
});
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
break;
|
|
375
|
-
}
|
|
376
|
-
} else {
|
|
377
|
-
console.log('[SoulSync] Already authenticated, starting sync...');
|
|
378
|
-
startPythonService('--start');
|
|
379
|
-
registerChatTools(api);
|
|
380
|
-
}
|
|
393
|
+
},
|
|
394
|
+
{ commands: ['soulsync:start'] }
|
|
395
|
+
);
|
|
381
396
|
|
|
382
397
|
function registerChatTools(api) {
|
|
383
398
|
api.registerTool({
|
|
@@ -577,7 +592,6 @@ module.exports = function register(api) {
|
|
|
577
592
|
if (isAuthenticated()) {
|
|
578
593
|
console.log('[SoulSync] Auto-starting sync service...');
|
|
579
594
|
startPythonService('--start');
|
|
580
|
-
registerChatTools(api);
|
|
581
595
|
}
|
|
582
596
|
|
|
583
597
|
console.log('[SoulSync] Plugin loaded. Run "openclaw soulsync:start" to begin.');
|