total-recall-brain 3.1.0

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 (170) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +173 -0
  3. package/bin/antigravity.mjs +212 -0
  4. package/bin/init.mjs +36 -0
  5. package/bin/oci-sniper.sh +69 -0
  6. package/bin/total-recall.mjs +229 -0
  7. package/docs/ARCHITECTURE.md +251 -0
  8. package/docs/IDE_INTEGRATION.md +112 -0
  9. package/package.json +71 -0
  10. package/scaffold/.agent/skills/total-recall/SKILL.md +195 -0
  11. package/scaffold/.agent/skills/total-recall/evals/evals.json +20 -0
  12. package/scaffold/.agent/skills/total-recall/memory-vault/concepts/cli-help-reference.md +145 -0
  13. package/scaffold/.agent/skills/total-recall/memory-vault/invariants/operating-instructions.md +75 -0
  14. package/scaffold/.agent/skills/total-recall/memory-vault/preferences/always-websearch-gap.md +16 -0
  15. package/scaffold/.agent/skills/total-recall/memory-vault/preferences/topic-research-sop.md +17 -0
  16. package/scaffold/.agent/skills/total-recall/references/api-reference.md +187 -0
  17. package/scaffold/.agent/skills/total-recall/references/architecture-reference.md +81 -0
  18. package/scaffold/.agent/skills/total-recall/references/cli-reference.md +103 -0
  19. package/scaffold/.agent/skills/total-recall/references/ssss-reference.md +88 -0
  20. package/scaffold/.agent/skills/total-recall/references/troubleshooting.md +68 -0
  21. package/scaffold/.agent/skills/total-recall/scripts/sync-repo.mjs +83 -0
  22. package/scaffold/.agent/skills/total-recall/skills/cli-agents/SKILL.md +122 -0
  23. package/scaffold/.agent/skills/total-recall/skills/cli-agents/agents.yml +27 -0
  24. package/scaffold/.agent/skills/total-recall/skills/cli-agents/references/antigravity.txt +20 -0
  25. package/scaffold/.agent/skills/total-recall/skills/cli-agents/references/claude.txt +58 -0
  26. package/scaffold/.agent/skills/total-recall/skills/cli-agents/references/codex.txt +81 -0
  27. package/scaffold/.agent/skills/total-recall/skills/cli-agents/references/gemini.txt +44 -0
  28. package/scaffold/.agent/skills/total-recall/skills/research/SKILL.md +337 -0
  29. package/scaffold/.agent/skills/total-recall/skills/skill/SKILL.md +281 -0
  30. package/scaffold/.agent/skills/total-recall/skills/skill/assets/skill-template/SKILL.md +20 -0
  31. package/scaffold/.agent/skills/total-recall/skills/skill/evals/evals.json +20 -0
  32. package/scaffold/.agent/skills/total-recall/skills/skill/hooks/on-skill-add.sh +14 -0
  33. package/scaffold/.agent/skills/total-recall/skills/skill/hooks/on-skill-delete.sh +14 -0
  34. package/scaffold/.agent/skills/total-recall/skills/skill/learnings/.gitkeep +0 -0
  35. package/scaffold/.agent/skills/total-recall/skills/skill/references/.gitkeep +0 -0
  36. package/scaffold/.agent/skills/total-recall/skills/skill/scripts/.gitkeep +0 -0
  37. package/scaffold/.agent/skills/total-recall/skills/skill/scripts/create-skill.sh +65 -0
  38. package/scaffold/.agent/skills/total-recall/skills/skill/scripts/enforce-skill-optimization.mjs +135 -0
  39. package/scaffold/.agent/skills/total-recall/skills/skill/scripts/find-skills.mjs +124 -0
  40. package/scaffold/.agent/skills/total-recall/skills/skill/scripts/scan-skill.mjs +207 -0
  41. package/scaffold/.agent/skills/total-recall/skills/skill/scripts/skill-watcher.mjs +64 -0
  42. package/scaffold/.agent/skills/total-recall/skills/skill/subagents/audit-all-skills.md +62 -0
  43. package/scaffold/.agent/skills/total-recall/skills/ssss/SKILL.md +27 -0
  44. package/scaffold/.agent/skills/total-recall/skills/ssss/evals/evals.json +17 -0
  45. package/scaffold/.agent/skills/total-recall/skills/ssss/references/ssss-spec.md +117 -0
  46. package/scaffold/.agent/skills/total-recall/skills/ssss/scripts/validate-schema.mjs +54 -0
  47. package/scaffold/.agent/skills/total-recall/skills/ssss/subagents/audit-ssss-node.md +9 -0
  48. package/scaffold/.agent/skills/total-recall/subagents/total-recall-diagnostician.md +13 -0
  49. package/src/cli/agent-dir.mjs +105 -0
  50. package/src/cli/backup.mjs +313 -0
  51. package/src/cli/brain.mjs +224 -0
  52. package/src/cli/chat.mjs +74 -0
  53. package/src/cli/config.mjs +247 -0
  54. package/src/cli/connect.mjs +872 -0
  55. package/src/cli/daemon.mjs +228 -0
  56. package/src/cli/deploy-ui.mjs +1793 -0
  57. package/src/cli/deploy.mjs +1726 -0
  58. package/src/cli/doctor.mjs +254 -0
  59. package/src/cli/dream.mjs +80 -0
  60. package/src/cli/forget.mjs +92 -0
  61. package/src/cli/friction.mjs +21 -0
  62. package/src/cli/generate-pat.mjs +65 -0
  63. package/src/cli/hash-password.mjs +22 -0
  64. package/src/cli/help.mjs +153 -0
  65. package/src/cli/import-rules.mjs +102 -0
  66. package/src/cli/ingest/index.mjs +318 -0
  67. package/src/cli/ingest/parsers/chrome-bookmarks.mjs +238 -0
  68. package/src/cli/ingest/parsers/google-keep.mjs +147 -0
  69. package/src/cli/ingest/parsers/search-history.mjs +142 -0
  70. package/src/cli/ingest/parsers/youtube-history.mjs +181 -0
  71. package/src/cli/ingest/utils/dedup.mjs +69 -0
  72. package/src/cli/ingest/utils/takeout-walker.mjs +101 -0
  73. package/src/cli/ingest.mjs +102 -0
  74. package/src/cli/init.mjs +736 -0
  75. package/src/cli/integration-dispatcher.mjs +128 -0
  76. package/src/cli/lint.mjs +166 -0
  77. package/src/cli/map.mjs +194 -0
  78. package/src/cli/migrate.mjs +87 -0
  79. package/src/cli/rebuild.mjs +88 -0
  80. package/src/cli/recall.mjs +219 -0
  81. package/src/cli/relay.mjs +518 -0
  82. package/src/cli/remember.mjs +306 -0
  83. package/src/cli/research.mjs +381 -0
  84. package/src/cli/reset-password.mjs +75 -0
  85. package/src/cli/restore.mjs +135 -0
  86. package/src/cli/setup.mjs +616 -0
  87. package/src/cli/share.mjs +180 -0
  88. package/src/cli/skill.mjs +313 -0
  89. package/src/cli/snapshot.mjs +108 -0
  90. package/src/cli/start.mjs +63 -0
  91. package/src/cli/status.mjs +296 -0
  92. package/src/cli/sync.mjs +383 -0
  93. package/src/cli/uninstall.mjs +613 -0
  94. package/src/cli/upgrade.mjs +141 -0
  95. package/src/cli/wizard.html +3682 -0
  96. package/src/core/blackboard.mjs +54 -0
  97. package/src/core/clarity-rewriter.mjs +770 -0
  98. package/src/core/conclusion-writer.mjs +259 -0
  99. package/src/core/config.mjs +277 -0
  100. package/src/core/conflict-detector.mjs +536 -0
  101. package/src/core/crypto.mjs +107 -0
  102. package/src/core/daemon-control.mjs +158 -0
  103. package/src/core/daemon-loop.mjs +364 -0
  104. package/src/core/dream.mjs +347 -0
  105. package/src/core/drift-detector.mjs +143 -0
  106. package/src/core/embeddings.mjs +632 -0
  107. package/src/core/emergency-alerts.mjs +137 -0
  108. package/src/core/evolution.mjs +107 -0
  109. package/src/core/fact-seeker.mjs +1602 -0
  110. package/src/core/friction.mjs +95 -0
  111. package/src/core/import-rules.mjs +308 -0
  112. package/src/core/inference-engine.mjs +367 -0
  113. package/src/core/logger.mjs +75 -0
  114. package/src/core/memory-layers.mjs +96 -0
  115. package/src/core/migrate.mjs +116 -0
  116. package/src/core/notifications.mjs +77 -0
  117. package/src/core/operation-validator.mjs +272 -0
  118. package/src/core/optimizer.mjs +330 -0
  119. package/src/core/pattern_detector.mjs +113 -0
  120. package/src/core/post-mortem.mjs +413 -0
  121. package/src/core/protect-instructions.mjs +148 -0
  122. package/src/core/quick-capture.mjs +145 -0
  123. package/src/core/research-queue.mjs +431 -0
  124. package/src/core/research.mjs +461 -0
  125. package/src/core/runtime.mjs +515 -0
  126. package/src/core/sandbox.mjs +163 -0
  127. package/src/core/scheduler.mjs +569 -0
  128. package/src/core/schema.mjs +333 -0
  129. package/src/core/search.mjs +219 -0
  130. package/src/core/semantic-index.mjs +276 -0
  131. package/src/core/session-watcher.mjs +850 -0
  132. package/src/core/snapshot.mjs +133 -0
  133. package/src/core/source-adapters.mjs +1038 -0
  134. package/src/core/steering.mjs +137 -0
  135. package/src/core/surface.mjs +444 -0
  136. package/src/core/task_runner.mjs +125 -0
  137. package/src/core/tts.mjs +142 -0
  138. package/src/core/usage-tracker.mjs +349 -0
  139. package/src/core/vault-cache.mjs +76 -0
  140. package/src/core/vault.mjs +273 -0
  141. package/src/core/watchdog.mjs +236 -0
  142. package/src/server/api.mjs +944 -0
  143. package/src/server/auth.mjs +410 -0
  144. package/src/server/index.mjs +868 -0
  145. package/src/server/keys.mjs +181 -0
  146. package/src/server/rest.mjs +1652 -0
  147. package/src/server/route-manifest.json +77 -0
  148. package/src/server/routes/_shared.mjs +93 -0
  149. package/src/server/routes/keys.mjs +55 -0
  150. package/src/server/routes/memory.mjs +249 -0
  151. package/src/server/routes/sessions.mjs +336 -0
  152. package/src/server/routes/share.mjs +138 -0
  153. package/src/server/tools.mjs +618 -0
  154. package/templates/Caddyfile +37 -0
  155. package/templates/com.totalrecall.backup.plist +42 -0
  156. package/templates/com.totalrecall.daemon.plist +40 -0
  157. package/templates/com.totalrecall.duckdns.plist +23 -0
  158. package/templates/com.totalrecall.server.plist +46 -0
  159. package/templates/default-config/budget.yml +6 -0
  160. package/templates/default-config/runtime.yml +11 -0
  161. package/templates/default-config/security.yml +53 -0
  162. package/templates/default-config/voice.yml +34 -0
  163. package/templates/obsidian-queries/conflicts.md +26 -0
  164. package/templates/obsidian-queries/daily.md +17 -0
  165. package/templates/obsidian-queries/index.md +38 -0
  166. package/templates/obsidian-queries/skills.md +14 -0
  167. package/templates/onboarding-interview.md +72 -0
  168. package/templates/skill_engineering.md +40 -0
  169. package/templates/total-recall-daemon.service +21 -0
  170. package/templates/total-recall-server.service +20 -0
@@ -0,0 +1,75 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import os from 'os';
4
+ import bcrypt from 'bcrypt';
5
+ import yaml from 'yaml';
6
+ import { BCRYPT_COST } from '../server/auth.mjs';
7
+ import { brainDir } from '../core/config.mjs';
8
+
9
+ export default async function resetPassword(args) {
10
+ if (args.includes('--help') || args.includes('-h') || args.length === 0) {
11
+ console.log(`
12
+ total-recall reset-password "new_password"
13
+
14
+ Resets the dashboard admin password in ~/.agent/skills/total-recall/config/security.yml.
15
+ Sets force_password_reset to true so you will be prompted to change it upon first login.
16
+ `);
17
+ return;
18
+ }
19
+
20
+ const password = args.join(' ');
21
+ if (password.length < 8) {
22
+ console.error('Error: Password must be at least 8 characters.');
23
+ process.exit(1);
24
+ }
25
+
26
+ const configDir = path.join(brainDir, 'config');
27
+ const securityPath = path.join(configDir, 'security.yml');
28
+
29
+ // Enforce directories exist
30
+ if (!fs.existsSync(configDir)) {
31
+ fs.mkdirSync(configDir, { recursive: true });
32
+ }
33
+
34
+ let config = {};
35
+ if (fs.existsSync(securityPath)) {
36
+ try {
37
+ config = yaml.parse(fs.readFileSync(securityPath, 'utf8')) || {};
38
+ } catch (e) {
39
+ console.warn('Warning: Could not parse existing security.yml, starting fresh.');
40
+ }
41
+ }
42
+
43
+ // Ensure default structures are present
44
+ if (!config.dashboard) {
45
+ config.dashboard = {};
46
+ }
47
+ if (!config.api) {
48
+ config.api = { pats: [], allow_static_pats: false };
49
+ }
50
+ if (!config.network) {
51
+ config.network = { require_https: true, public_health: false, allowed_origins: [] };
52
+ }
53
+ if (!config.bind) {
54
+ config.bind = { host: '127.0.0.1', port: 3000, allow_public_bind: false };
55
+ }
56
+
57
+ console.log('Hashing password...');
58
+ const hash = await bcrypt.hash(password, BCRYPT_COST);
59
+
60
+
61
+ config.dashboard.password_hash = hash;
62
+ const isDefault = password === 'totalrecall';
63
+ config.dashboard.force_password_reset = isDefault;
64
+
65
+ fs.writeFileSync(securityPath, yaml.stringify(config), { encoding: 'utf8', mode: 0o600 });
66
+
67
+ console.log(`\n ✅ Success! Dashboard admin password reset.`);
68
+ console.log(` 📍 Saved to: ${securityPath}`);
69
+ if (isDefault) {
70
+ console.log(` 🔑 Next login password: "${password}" (you will be forced to change it on login)`);
71
+ console.log(` 👉 Access your dashboard and enter this password to log in and set your permanent password.\n`);
72
+ } else {
73
+ console.log(` 🔑 Next login password: "${password}" (you can sign in directly now!)\n`);
74
+ }
75
+ }
@@ -0,0 +1,135 @@
1
+ /**
2
+ * total-recall restore
3
+ *
4
+ * Restore VFS from an encrypted or unencrypted backup tarball.
5
+ *
6
+ * Usage:
7
+ * npx total-recall restore --from <path>
8
+ *
9
+ * Options:
10
+ * --from <path> Path to backup file (required)
11
+ * --yes Skip confirmation prompt
12
+ * --help Show this help
13
+ */
14
+
15
+ import { spawn, spawnSync, execFileSync } from 'node:child_process';
16
+ import fs from 'node:fs';
17
+ import os from 'node:os';
18
+ import path from 'node:path';
19
+ import { createInterface } from 'node:readline';
20
+
21
+ import { resolveAgentDir, parseLayerFlag } from './agent-dir.mjs';
22
+
23
+ /** Parent of the skill dir — where the tarball gets extracted to */
24
+ function getExtractDir(layer = 'auto') {
25
+ return path.join(resolveAgentDir(layer), 'skills');
26
+ }
27
+
28
+ function commandExists(cmd) {
29
+ if (!cmd || !/^[a-zA-Z0-9_-]+$/.test(cmd)) {
30
+ return false;
31
+ }
32
+ try {
33
+ execFileSync('which', [cmd], { stdio: 'ignore' });
34
+ return true;
35
+ } catch { return false; }
36
+ }
37
+
38
+ function parseArgs(args) {
39
+ const { layer, remainingArgs } = parseLayerFlag(args);
40
+ const opts = { from: null, yes: false, help: false, layer };
41
+ for (let i = 0; i < remainingArgs.length; i++) {
42
+ switch (remainingArgs[i]) {
43
+ case '--from': opts.from = remainingArgs[++i]; break;
44
+ case '--yes': case '-y': opts.yes = true; break;
45
+ case '--help': case '-h': opts.help = true; break;
46
+ }
47
+ }
48
+ return opts;
49
+ }
50
+
51
+ function printHelp() {
52
+ console.log(`
53
+ total-recall restore — Restore VFS from a backup tarball
54
+
55
+ Usage: total-recall restore --from <path>
56
+
57
+ Options:
58
+ --from <path> Path to backup file (required)
59
+ --yes, -y Skip confirmation prompt
60
+ --help, -h Show this help
61
+ `);
62
+ }
63
+
64
+ async function confirm(message) {
65
+ const rl = createInterface({ input: process.stdin, output: process.stderr });
66
+ return new Promise((resolve) => {
67
+ rl.question(message, (answer) => { rl.close(); resolve(answer.toLowerCase().startsWith('y')); });
68
+ });
69
+ }
70
+
71
+ export default async function restore(args) {
72
+ const opts = parseArgs(args);
73
+ if (opts.help) { printHelp(); return; }
74
+
75
+ if (!opts.from) {
76
+ console.error(' ❌ --from <path> is required');
77
+ printHelp();
78
+ process.exit(1);
79
+ }
80
+
81
+ if (!fs.existsSync(opts.from)) {
82
+ console.error(` ❌ Backup file not found: ${opts.from}`);
83
+ process.exit(1);
84
+ }
85
+
86
+ const isEncrypted = opts.from.endsWith('.gpg');
87
+ const extractDir = getExtractDir(opts.layer);
88
+
89
+ if (!opts.yes) {
90
+ console.error(`\n ⚠️ This will overwrite .agent/skills/total-recall/ with the contents of:`);
91
+ console.error(` ${opts.from}`);
92
+ const ok = await confirm(' Continue? (y/N) ');
93
+ if (!ok) { console.error(' Aborted.'); return; }
94
+ }
95
+
96
+ // Ensure the extract target exists
97
+ fs.mkdirSync(extractDir, { recursive: true });
98
+
99
+ console.error(`\n 📦 Restoring from backup...`);
100
+ console.error(` Source: ${opts.from}`);
101
+ console.error(` Encrypted: ${isEncrypted}`);
102
+
103
+ try {
104
+ if (isEncrypted) {
105
+ if (!commandExists('gpg')) { console.error(' ❌ gpg not found'); process.exit(1); }
106
+
107
+ const gpg = spawn('gpg', ['--decrypt', '--batch', opts.from], { stdio: ['ignore', 'pipe', 'inherit'] });
108
+ const tar = spawn('tar', ['-xf', '-', '-C', extractDir], { stdio: ['pipe', 'inherit', 'inherit'] });
109
+
110
+ gpg.stdout.pipe(tar.stdin);
111
+
112
+ const [gpgExit, tarExit] = await Promise.all([
113
+ new Promise((resolve) => gpg.on('close', resolve)),
114
+ new Promise((resolve) => tar.on('close', resolve))
115
+ ]);
116
+
117
+ if (gpgExit !== 0) throw new Error(`gpg failed (exit ${gpgExit})`);
118
+ if (tarExit !== 0) throw new Error(`tar failed (exit ${tarExit})`);
119
+ } else {
120
+ const result = spawnSync('tar', ['-xzf', opts.from, '-C', extractDir], { stdio: 'inherit' });
121
+ if (result.status !== 0) throw new Error(`tar failed (exit ${result.status})`);
122
+ }
123
+
124
+ console.error(' ✅ Files extracted');
125
+
126
+ // Reindex after restore
127
+ console.error(' 🔄 Rebuilding indexes...');
128
+ const { default: compile } = await import('./compile.mjs');
129
+ await compile(['--quiet']);
130
+ console.error(' ✅ Restore complete\n');
131
+ } catch (err) {
132
+ console.error(` ❌ Restore failed: ${err.message}`);
133
+ process.exit(1);
134
+ }
135
+ }