@clawchatsai/connector 0.0.3 → 0.0.5

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/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * Spec: specs/multitenant-p2p.md sections 6.1-6.2
11
11
  */
12
- export declare const PLUGIN_ID = "tunnel";
12
+ export declare const PLUGIN_ID = "connector";
13
13
  export declare const PLUGIN_VERSION = "0.0.1";
14
14
  interface PluginServiceContext {
15
15
  stateDir: string;
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ import { dispatchRpc } from './shim.js';
18
18
  import { checkForUpdates, performUpdate } from './updater.js';
19
19
  // Inline from shared/api-version.ts to avoid rootDir conflict
20
20
  const CURRENT_API_VERSION = 1;
21
- export const PLUGIN_ID = 'tunnel';
21
+ export const PLUGIN_ID = 'connector';
22
22
  export const PLUGIN_VERSION = '0.0.1';
23
23
  /** Max DataChannel message size (~256KB, leave room for envelope) */
24
24
  const MAX_DC_MESSAGE_SIZE = 256 * 1024;
@@ -506,6 +506,64 @@ async function handleReset() {
506
506
  console.error(`Reset failed: ${e.message}`);
507
507
  }
508
508
  }
509
+ async function handleImport(sourcePath, opts) {
510
+ const resolvedSource = path.resolve(sourcePath);
511
+ if (!fs.existsSync(resolvedSource)) {
512
+ console.error(`Source path not found: ${resolvedSource}`);
513
+ return;
514
+ }
515
+ const stat = fs.statSync(resolvedSource);
516
+ if (!stat.isDirectory()) {
517
+ console.error(`Source must be a directory: ${resolvedSource}`);
518
+ return;
519
+ }
520
+ // Destination: ~/.openclaw/shellchats/data/
521
+ const destDataDir = path.join(CONFIG_DIR, 'data');
522
+ fs.mkdirSync(destDataDir, { recursive: true });
523
+ // Import .db files
524
+ const dbFiles = fs.readdirSync(resolvedSource).filter(f => f.endsWith('.db'));
525
+ if (dbFiles.length === 0) {
526
+ console.log('No .db files found in source directory.');
527
+ }
528
+ else {
529
+ console.log(`Importing ${dbFiles.length} database(s) from ${resolvedSource}...`);
530
+ let imported = 0;
531
+ let skipped = 0;
532
+ for (const file of dbFiles) {
533
+ const src = path.join(resolvedSource, file);
534
+ const dst = path.join(destDataDir, file);
535
+ if (fs.existsSync(dst) && !opts.force) {
536
+ console.log(` Skipping ${file} (already exists — use --force to overwrite)`);
537
+ skipped++;
538
+ }
539
+ else {
540
+ fs.copyFileSync(src, dst);
541
+ console.log(` ✓ ${file}`);
542
+ imported++;
543
+ }
544
+ }
545
+ console.log(`Databases: ${imported} imported, ${skipped} skipped.`);
546
+ }
547
+ // Also try to migrate config.json from the parent directory
548
+ // e.g. if source is ~/.openclaw/shellchat/data/, config is at ~/.openclaw/shellchat/config.json
549
+ const parentConfigPath = path.join(path.dirname(resolvedSource), 'config.json');
550
+ if (fs.existsSync(parentConfigPath)) {
551
+ if (fs.existsSync(CONFIG_FILE) && !opts.force) {
552
+ console.log(' Skipping config.json (already exists — use --force to overwrite)');
553
+ }
554
+ else {
555
+ try {
556
+ fs.mkdirSync(CONFIG_DIR, { recursive: true });
557
+ fs.copyFileSync(parentConfigPath, CONFIG_FILE);
558
+ console.log(' ✓ config.json (plugin credentials migrated)');
559
+ }
560
+ catch (e) {
561
+ console.error(` Failed to migrate config.json: ${e.message}`);
562
+ }
563
+ }
564
+ }
565
+ console.log('Done.');
566
+ }
509
567
  // ---------------------------------------------------------------------------
510
568
  // Plugin definition
511
569
  // ---------------------------------------------------------------------------
@@ -516,7 +574,7 @@ const plugin = {
516
574
  register(api) {
517
575
  // Background service: signaling + gateway bridge + future WebRTC
518
576
  api.registerService({
519
- id: 'shellchats-service',
577
+ id: 'connector-service',
520
578
  start: (ctx) => startShellChat(ctx, api),
521
579
  stop: (ctx) => stopShellChat(ctx),
522
580
  });
@@ -532,6 +590,9 @@ const plugin = {
532
590
  cmd.command('reset')
533
591
  .description('Disconnect and remove all ShellChats data')
534
592
  .action(() => handleReset());
593
+ cmd.command('import <path>')
594
+ .description('Import databases from a folder (e.g. migrate from old data directory). Use --force to overwrite existing files.')
595
+ .action((srcPath) => handleImport(String(srcPath), { force: process.argv.includes('--force') }));
535
596
  });
536
597
  // Slash command for status from any channel
537
598
  api.registerCommand({
@@ -1,7 +1,7 @@
1
1
  {
2
- "id": "shellchat",
3
- "name": "ShellChat",
4
- "description": "Connects your OpenClaw gateway to ShellChat via WebRTC P2P",
2
+ "id": "connector",
3
+ "name": "ShellChats",
4
+ "description": "Connects your OpenClaw gateway to ShellChats via WebRTC P2P",
5
5
  "kind": "integration",
6
6
  "configSchema": {
7
7
  "type": "object",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawchatsai/connector",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "type": "module",
5
5
  "description": "ShellChat OpenClaw plugin — P2P tunnel + local API bridge",
6
6
  "main": "dist/index.js",