clawon 0.1.7 → 0.1.9

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Clawon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -21,6 +21,7 @@ Local backups are stored in `~/.clawon/backups/` as standard `.tar.gz` archives.
21
21
  # Create a backup
22
22
  npx clawon local backup
23
23
  npx clawon local backup --tag "before migration"
24
+ npx clawon local backup --include-memory-db # Include SQLite memory index
24
25
 
25
26
  # List all local backups
26
27
  npx clawon local list
@@ -43,6 +44,7 @@ npx clawon login --api-key <your-key>
43
44
  npx clawon backup
44
45
  npx clawon backup --tag "stable config"
45
46
  npx clawon backup --dry-run # Preview without uploading
47
+ npx clawon backup --include-memory-db # Requires Pro account
46
48
 
47
49
  # List cloud backups
48
50
  npx clawon list
@@ -63,6 +65,7 @@ npx clawon activity # Recent events
63
65
 
64
66
  ```bash
65
67
  npx clawon discover # Show exactly which files would be backed up
68
+ npx clawon discover --include-memory-db # Include SQLite memory index
66
69
  npx clawon status # Connection status and file count
67
70
  npx clawon logout # Remove local credentials
68
71
  ```
@@ -93,7 +96,7 @@ These are **always excluded**, even if they match an include pattern:
93
96
  | `openclaw.json` | May contain credentials |
94
97
  | `agents/*/sessions/**` | Ephemeral session data |
95
98
  | `memory/lancedb/**` | Vector database (binary, large) |
96
- | `memory/*.sqlite` | SQLite databases |
99
+ | `memory/*.sqlite` | SQLite databases (use `--include-memory-db` to include) |
97
100
  | `*.lock`, `*.wal`, `*.shm` | Database lock files |
98
101
  | `node_modules/**` | Dependencies |
99
102
 
package/dist/index.js CHANGED
@@ -61,7 +61,10 @@ function matchGlob(filePath, pattern) {
61
61
  let regexPattern = pattern.replace(/\./g, "\\.").replace(/\*\*\//g, "(.*/)?").replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*");
62
62
  return new RegExp(`^${regexPattern}$`).test(filePath);
63
63
  }
64
- function shouldInclude(relativePath) {
64
+ function shouldInclude(relativePath, includeMemoryDb = false) {
65
+ if (includeMemoryDb && matchGlob(relativePath, "memory/*.sqlite")) {
66
+ return true;
67
+ }
65
68
  for (const pattern of EXCLUDE_PATTERNS) {
66
69
  if (matchGlob(relativePath, pattern)) return false;
67
70
  }
@@ -70,7 +73,7 @@ function shouldInclude(relativePath) {
70
73
  }
71
74
  return false;
72
75
  }
73
- function discoverFiles(baseDir) {
76
+ function discoverFiles(baseDir, includeMemoryDb = false) {
74
77
  const files = [];
75
78
  function walk(dir, relativePath = "") {
76
79
  if (!fs.existsSync(dir)) return;
@@ -81,7 +84,7 @@ function discoverFiles(baseDir) {
81
84
  if (entry.isDirectory()) {
82
85
  walk(fullPath, relPath);
83
86
  } else if (entry.isFile()) {
84
- if (shouldInclude(relPath)) {
87
+ if (shouldInclude(relPath, includeMemoryDb)) {
85
88
  const stats = fs.statSync(fullPath);
86
89
  files.push({
87
90
  path: relPath,
@@ -94,12 +97,13 @@ function discoverFiles(baseDir) {
94
97
  walk(baseDir);
95
98
  return files;
96
99
  }
97
- async function createLocalArchive(files, openclawDir, outputPath, tag) {
100
+ async function createLocalArchive(files, openclawDir, outputPath, tag, includeMemoryDb) {
98
101
  const meta = {
99
102
  version: 2,
100
103
  created: (/* @__PURE__ */ new Date()).toISOString(),
101
104
  ...tag ? { tag } : {},
102
- file_count: files.length
105
+ file_count: files.length,
106
+ ...includeMemoryDb ? { include_memory_db: true } : {}
103
107
  };
104
108
  const metaPath = path.join(openclawDir, "_clawon_meta.json");
105
109
  fs.writeFileSync(metaPath, JSON.stringify(meta, null, 2));
@@ -170,12 +174,17 @@ program.command("login").description("Connect to Clawon with your API key").requ
170
174
  });
171
175
  console.log("\u2713 Logged in");
172
176
  console.log(` Profile ID: ${connectJson.profileId}`);
177
+ trackCliEvent(connectJson.profileId, "cli_login");
173
178
  } catch (e) {
174
179
  console.error(`\u2717 Login failed: ${e.message}`);
175
180
  process.exit(1);
176
181
  }
177
182
  });
178
- program.command("backup").description("Backup your OpenClaw workspace to the cloud").option("--dry-run", "Show what would be backed up without uploading").option("--tag <label>", "Add a label to this backup").action(async (opts) => {
183
+ program.command("backup").description("Backup your OpenClaw workspace to the cloud").option("--dry-run", "Show what would be backed up without uploading").option("--tag <label>", "Add a label to this backup").option("--include-memory-db", "Include SQLite memory index").action(async (opts) => {
184
+ if (opts.includeMemoryDb) {
185
+ console.error("\u2717 Memory DB backup requires a Pro account. Use `clawon local backup --include-memory-db` for local backups.");
186
+ process.exit(1);
187
+ }
179
188
  const cfg = readConfig();
180
189
  if (!cfg) {
181
190
  console.error("\u2717 Not logged in. Run: clawon login --api-key <key>");
@@ -247,7 +256,8 @@ program.command("backup").description("Backup your OpenClaw workspace to the clo
247
256
  console.log(` Size: ${(totalSize / 1024).toFixed(1)} KB`);
248
257
  trackCliEvent(cfg.profileId, "cloud_backup_created", {
249
258
  file_count: files.length,
250
- total_bytes: totalSize
259
+ total_bytes: totalSize,
260
+ include_memory_db: !!opts.includeMemoryDb
251
261
  });
252
262
  } catch (e) {
253
263
  const msg = e.message;
@@ -350,6 +360,7 @@ program.command("list").description("List your backups").option("--limit <n>", "
350
360
  }
351
361
  console.log(`
352
362
  Total: ${snapshots.length} backup(s)`);
363
+ trackCliEvent(cfg.profileId, "cli_list_viewed", { count: snapshots.length });
353
364
  } catch (e) {
354
365
  console.error(`\u2717 Failed to list backups: ${e.message}`);
355
366
  process.exit(1);
@@ -407,6 +418,7 @@ program.command("activity").description("Show recent activity").option("--limit
407
418
  const details = formatEventDetails(ev.payload);
408
419
  console.log(`${date.padEnd(20)} | ${label.padEnd(18)} | ${details}`);
409
420
  }
421
+ trackCliEvent(cfg.profileId, "cli_activity_viewed");
410
422
  } catch (e) {
411
423
  console.error(`\u2717 Failed to load activity: ${e.message}`);
412
424
  process.exit(1);
@@ -446,17 +458,18 @@ program.command("delete [id]").description("Delete a snapshot").option("--oldest
446
458
  snapshotId
447
459
  });
448
460
  console.log(`\u2713 Deleted snapshot ${snapshotId}`);
461
+ trackCliEvent(cfg.profileId, "cloud_backup_deleted");
449
462
  } catch (e) {
450
463
  console.error(`\u2717 Delete failed: ${e.message}`);
451
464
  process.exit(1);
452
465
  }
453
466
  });
454
- program.command("discover").description("Preview which files would be included in a backup").action(async () => {
467
+ program.command("discover").description("Preview which files would be included in a backup").option("--include-memory-db", "Include SQLite memory index").action(async (opts) => {
455
468
  if (!fs.existsSync(OPENCLAW_DIR)) {
456
469
  console.error(`\u2717 OpenClaw directory not found: ${OPENCLAW_DIR}`);
457
470
  process.exit(1);
458
471
  }
459
- const files = discoverFiles(OPENCLAW_DIR);
472
+ const files = discoverFiles(OPENCLAW_DIR, !!opts.includeMemoryDb);
460
473
  if (files.length === 0) {
461
474
  console.log("No files matched the include patterns.");
462
475
  return;
@@ -480,6 +493,8 @@ program.command("discover").description("Preview which files would be included i
480
493
  console.log(`
481
494
  Total: ${files.length} files (${(totalSize / 1024).toFixed(1)} KB)`);
482
495
  console.log(`Source: ${OPENCLAW_DIR}`);
496
+ const cfg = readConfig();
497
+ trackCliEvent(cfg?.profileId || "anonymous", "cli_discover", { file_count: files.length, include_memory_db: !!opts.includeMemoryDb });
483
498
  });
484
499
  program.command("files").description("List files in a backup").option("--snapshot <id>", "Snapshot ID (default: latest)").action(async (opts) => {
485
500
  const cfg = readConfig();
@@ -516,19 +531,20 @@ program.command("files").description("List files in a backup").option("--snapsho
516
531
  }
517
532
  console.log(`
518
533
  Total: ${files.length} files`);
534
+ trackCliEvent(cfg.profileId, "cli_files_viewed", { file_count: files.length });
519
535
  } catch (e) {
520
536
  console.error(`\u2717 Failed to list files: ${e.message}`);
521
537
  process.exit(1);
522
538
  }
523
539
  });
524
540
  var local = program.command("local").description("Local backup and restore (no cloud required)");
525
- local.command("backup").description("Save a local backup of your OpenClaw workspace").option("--tag <label>", "Add a label to this backup").action(async (opts) => {
541
+ local.command("backup").description("Save a local backup of your OpenClaw workspace").option("--tag <label>", "Add a label to this backup").option("--include-memory-db", "Include SQLite memory index").action(async (opts) => {
526
542
  if (!fs.existsSync(OPENCLAW_DIR)) {
527
543
  console.error(`\u2717 OpenClaw directory not found: ${OPENCLAW_DIR}`);
528
544
  process.exit(1);
529
545
  }
530
546
  console.log("Discovering files...");
531
- const files = discoverFiles(OPENCLAW_DIR);
547
+ const files = discoverFiles(OPENCLAW_DIR, !!opts.includeMemoryDb);
532
548
  if (files.length === 0) {
533
549
  console.error("\u2717 No files found to backup");
534
550
  process.exit(1);
@@ -540,7 +556,7 @@ local.command("backup").description("Save a local backup of your OpenClaw worksp
540
556
  const filename = `backup-${timestamp}.tar.gz`;
541
557
  const filePath = path.join(BACKUPS_DIR, filename);
542
558
  console.log("Creating archive...");
543
- await createLocalArchive(files, OPENCLAW_DIR, filePath, opts.tag);
559
+ await createLocalArchive(files, OPENCLAW_DIR, filePath, opts.tag, opts.includeMemoryDb);
544
560
  const archiveSize = fs.statSync(filePath).size;
545
561
  console.log(`
546
562
  \u2713 Local backup saved!`);
@@ -551,7 +567,8 @@ local.command("backup").description("Save a local backup of your OpenClaw worksp
551
567
  const cfg = readConfig();
552
568
  trackCliEvent(cfg?.profileId || "anonymous", "local_backup_created", {
553
569
  file_count: files.length,
554
- total_bytes: totalSize
570
+ total_bytes: totalSize,
571
+ include_memory_db: !!opts.includeMemoryDb
555
572
  });
556
573
  });
557
574
  local.command("list").description("List local backups").action(async () => {
@@ -584,6 +601,8 @@ local.command("list").description("List local backups").action(async () => {
584
601
  }
585
602
  console.log(`
586
603
  Total: ${entries.length} backup(s)`);
604
+ const cfg = readConfig();
605
+ trackCliEvent(cfg?.profileId || "anonymous", "local_list_viewed", { count: entries.length });
587
606
  console.log(`
588
607
  Restore a backup:`);
589
608
  console.log(` clawon local restore Restore the latest backup (#1)`);
@@ -662,11 +681,14 @@ program.command("status").description("Show current status").action(async () =>
662
681
  } else {
663
682
  console.log(`\u2717 OpenClaw not found: ${OPENCLAW_DIR}`);
664
683
  }
684
+ trackCliEvent(cfg?.profileId || "anonymous", "cli_status_viewed");
665
685
  });
666
686
  program.command("logout").description("Remove local credentials").action(() => {
687
+ const cfg = readConfig();
667
688
  if (fs.existsSync(CONFIG_PATH)) {
668
689
  fs.unlinkSync(CONFIG_PATH);
669
690
  console.log("\u2713 Logged out");
691
+ trackCliEvent(cfg?.profileId || "anonymous", "cli_logout");
670
692
  } else {
671
693
  console.log("Already logged out");
672
694
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawon",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Backup and restore your OpenClaw workspace",
5
5
  "type": "module",
6
6
  "bin": {