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.
Files changed (2) hide show
  1. package/index.js +44 -30
  2. 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
- const isLocalTTY = process.stdin.isTTY && !process.env.SSH_CLIENT && !process.env.SSH_TTY;
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
- const mode = detectAuthMode(api);
356
- console.log(`[SoulSync] Detected auth mode: ${mode}`);
357
-
358
- if (!isAuthenticated()) {
359
- switch (mode) {
360
- case 'oauth-local':
361
- console.log('[SoulSync] Starting OAuth local flow...');
362
- startOAuthLocal().then(result => {
363
- if (result.success) registerChatTools(api);
364
- });
365
- break;
366
- case 'device-code-cli':
367
- console.log('[SoulSync] Starting device code CLI flow...');
368
- startDeviceCodeCLI().then(result => {
369
- console.log('[SoulSync]', result.message);
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
- break;
372
- case 'device-code-chat':
373
- console.log('[SoulSync] Waiting for user to say "connect SoulSync"...');
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.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "soulsync",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "SoulSync plugin for OpenClaw - cross-bot memory synchronization",
5
5
  "main": "index.js",
6
6
  "repository": {