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,247 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import yaml from 'yaml';
4
+ import { resolveBrainDir, parseLayerFlag } from './agent-dir.mjs';
5
+
6
+ // Pre-defined mapping of known settings
7
+ const KEY_MAP = {
8
+ 'yolo_mode': { file: 'security', path: 'yolo_mode', type: 'boolean' },
9
+ 'enforce_local_only': { file: 'security', path: 'privacy.enforce_local_only', type: 'boolean' },
10
+ 'allow_frontier_export': { file: 'security', path: 'privacy.allow_frontier_export', type: 'string', values: ['always', 'ask_per_skill', 'never'] },
11
+ 'password_hash': { file: 'security', path: 'dashboard.password_hash', type: 'string' },
12
+ 'session_ttl_hours': { file: 'security', path: 'dashboard.session_ttl_hours', type: 'number' },
13
+ 'force_password_reset': { file: 'security', path: 'dashboard.force_password_reset', type: 'boolean' },
14
+ 'api_requests_per_minute': { file: 'security', path: 'rate_limits.api_requests_per_minute', type: 'number' },
15
+ 'sandbox_requests_per_minute': { file: 'security', path: 'rate_limits.sandbox_requests_per_minute', type: 'number' },
16
+ 'ingest_requests_per_minute': { file: 'security', path: 'rate_limits.ingest_requests_per_minute', type: 'number' },
17
+ 'host': { file: 'security', path: 'bind.host', type: 'string' },
18
+ 'port': { file: 'security', path: 'bind.port', type: 'number' },
19
+ 'allow_public_bind': { file: 'security', path: 'bind.allow_public_bind', type: 'boolean' },
20
+ 'require_https': { file: 'security', path: 'network.require_https', type: 'boolean' },
21
+ 'public_health': { file: 'security', path: 'network.public_health', type: 'boolean' },
22
+ 'allowed_origins': { file: 'security', path: 'network.allowed_origins', type: 'array' },
23
+
24
+ 'daily_cap_usd': { file: 'budget', path: 'budget.daily_cap_usd', type: 'number' },
25
+ 'weekly_cap_usd': { file: 'budget', path: 'budget.weekly_cap_usd', type: 'number' },
26
+ 'budget_enabled': { file: 'budget', path: 'budget.enabled', type: 'boolean' }
27
+ };
28
+
29
+ function resolveKeyInfo(key) {
30
+ if (KEY_MAP[key]) return KEY_MAP[key];
31
+
32
+ for (const info of Object.values(KEY_MAP)) {
33
+ if (info.path === key) return info;
34
+ }
35
+
36
+ // Fallback / dynamic inference
37
+ const isBudget = key.startsWith('budget.') || key === 'budget';
38
+ const file = isBudget ? 'budget' : 'security';
39
+ const targetPath = key;
40
+
41
+ let type = 'string';
42
+ if (key.includes('port') || key.includes('limit') || key.includes('ttl') || key.includes('cap') || key.includes('minute')) {
43
+ type = 'number';
44
+ } else if (key.includes('enable') || key.includes('allow') || key.includes('require') || key.includes('public') || key.includes('enforce') || key.includes('yolo')) {
45
+ type = 'boolean';
46
+ } else if (key.includes('origins') || key.includes('pats')) {
47
+ type = 'array';
48
+ }
49
+
50
+ return { file, path: targetPath, type };
51
+ }
52
+
53
+ function getNestedProp(obj, dottedPath) {
54
+ const parts = dottedPath.split('.');
55
+ let current = obj;
56
+ for (const part of parts) {
57
+ if (current === null || current === undefined) return undefined;
58
+ current = current[part];
59
+ }
60
+ return current;
61
+ }
62
+
63
+ function setNestedProp(obj, dottedPath, value) {
64
+ const parts = dottedPath.split('.');
65
+ let current = obj;
66
+ for (let i = 0; i < parts.length - 1; i++) {
67
+ const part = parts[i];
68
+ if (current[part] === undefined || current[part] === null || typeof current[part] !== 'object') {
69
+ current[part] = {};
70
+ }
71
+ current = current[part];
72
+ }
73
+ current[parts[parts.length - 1]] = value;
74
+ }
75
+
76
+ function castAndValidate(valueStr, type, allowedValues) {
77
+ if (valueStr === 'null' || valueStr === 'undefined' || valueStr === null) {
78
+ return null;
79
+ }
80
+
81
+ if (type === 'boolean') {
82
+ if (valueStr === 'true' || valueStr === '1' || valueStr === 'yes' || valueStr === true) return true;
83
+ if (valueStr === 'false' || valueStr === '0' || valueStr === 'no' || valueStr === false) return false;
84
+ throw new Error(`Invalid boolean value: "${valueStr}". Expected true or false.`);
85
+ }
86
+
87
+ if (type === 'number') {
88
+ const num = Number(valueStr);
89
+ if (isNaN(num)) {
90
+ throw new Error(`Invalid number value: "${valueStr}".`);
91
+ }
92
+ return num;
93
+ }
94
+
95
+ if (type === 'array') {
96
+ if (Array.isArray(valueStr)) return valueStr;
97
+ if (typeof valueStr === 'string' && valueStr.startsWith('[')) {
98
+ try {
99
+ return JSON.parse(valueStr);
100
+ } catch {}
101
+ }
102
+ return String(valueStr).split(',').map(s => s.trim()).filter(Boolean);
103
+ }
104
+
105
+ if (allowedValues && !allowedValues.includes(valueStr)) {
106
+ throw new Error(`Invalid value: "${valueStr}". Must be one of: ${allowedValues.join(', ')}.`);
107
+ }
108
+
109
+ return valueStr;
110
+ }
111
+
112
+ export default async function configCommand(args) {
113
+ const { layer, remainingArgs } = parseLayerFlag(args);
114
+ const command = remainingArgs[0] || 'get';
115
+
116
+ if (args.includes('--help') || args.includes('-h')) {
117
+ console.log(`
118
+ total-recall config [get|set] [key] [value] [options]
119
+
120
+ Manage Sovereign OS and Dashboard configuration settings directly from the CLI.
121
+
122
+ Commands:
123
+ get [key] Retrieve the value of a configuration key. If key is omitted, lists all keys.
124
+ set <key> <v> Set the value of a configuration key. Converts inputs to correct type.
125
+
126
+ Options:
127
+ --global Explicitly target the global brain configuration (~/.agent/)
128
+ --project Explicitly target the project brain configuration (<cwd>/.agent/)
129
+
130
+ Common Keys:
131
+ yolo_mode Fully autonomous mode (true | false)
132
+ allow_frontier_export Frontier export policy (always | ask_per_skill | never)
133
+ session_ttl_hours Dashboard session TTL hours (number)
134
+ api_requests_per_minute Rate limit for API endpoints (number)
135
+ daily_cap_usd Cost-control daily cap (number)
136
+ weekly_cap_usd Cost-control weekly cap (number)
137
+ budget_enabled Enable/disable cost limit checks (true | false)
138
+ allowed_origins CORS origins (e.g. "http://localhost:5173,http://localhost:3000")
139
+
140
+ Examples:
141
+ npx total-recall config get
142
+ npx total-recall config get yolo_mode
143
+ npx total-recall config set yolo_mode true --project
144
+ npx total-recall config set daily_cap_usd 10.0 --global
145
+ npx total-recall config set allowed_origins "http://localhost:8000"
146
+ `);
147
+ return;
148
+ }
149
+
150
+ const brainDir = resolveBrainDir(layer);
151
+ const configDir = path.join(brainDir, 'config');
152
+ const securityPath = path.join(configDir, 'security.yml');
153
+ const budgetPath = path.join(configDir, 'budget.yml');
154
+ const layerLabel = layer === 'project' ? '[project]' : layer === 'global' ? '[global]' : '[auto]';
155
+
156
+ // Load configs safely
157
+ let securityConfig = {};
158
+ let budgetConfig = {};
159
+
160
+ if (fs.existsSync(securityPath)) {
161
+ try {
162
+ securityConfig = yaml.parse(fs.readFileSync(securityPath, 'utf8')) || {};
163
+ } catch {}
164
+ }
165
+ if (fs.existsSync(budgetPath)) {
166
+ try {
167
+ budgetConfig = yaml.parse(fs.readFileSync(budgetPath, 'utf8')) || {};
168
+ } catch {}
169
+ }
170
+
171
+ if (command === 'get') {
172
+ const key = remainingArgs[1];
173
+ if (key) {
174
+ const info = resolveKeyInfo(key);
175
+ const targetObj = info.file === 'budget' ? budgetConfig : securityConfig;
176
+ const value = getNestedProp(targetObj, info.path);
177
+
178
+ if (args.includes('--json') || args.includes('-j')) {
179
+ console.log(JSON.stringify({ key, value }));
180
+ } else {
181
+ console.log(value !== undefined ? value : 'undefined');
182
+ }
183
+ } else {
184
+ // List all known keys
185
+ const allSettings = {};
186
+ for (const [flatKey, info] of Object.entries(KEY_MAP)) {
187
+ const targetObj = info.file === 'budget' ? budgetConfig : securityConfig;
188
+ const val = getNestedProp(targetObj, info.path);
189
+ allSettings[flatKey] = val !== undefined ? val : null;
190
+ }
191
+
192
+ if (args.includes('--json') || args.includes('-j')) {
193
+ console.log(JSON.stringify(allSettings, null, 2));
194
+ } else {
195
+ console.log(`\n ⚙️ Sovereign UI & Settings Configuration ${layerLabel}\n`);
196
+ for (const [k, v] of Object.entries(allSettings)) {
197
+ const formattedValue = typeof v === 'object' && v !== null ? JSON.stringify(v) : String(v);
198
+ console.log(` • ${k.padEnd(30)}: ${formattedValue}`);
199
+ }
200
+ console.log('\n 📍 Storage locations:');
201
+ console.log(` - Security: ${securityPath}`);
202
+ console.log(` - Budget: ${budgetPath}\n`);
203
+ }
204
+ }
205
+ return;
206
+ }
207
+
208
+ if (command === 'set') {
209
+ const key = remainingArgs[1];
210
+ let rawValue = remainingArgs[2];
211
+
212
+ if (!key) {
213
+ console.error('Error: Key is required for set command. Run total-recall config --help for usage.');
214
+ process.exit(1);
215
+ }
216
+
217
+ if (rawValue === undefined) {
218
+ console.error(`Error: Value is required for key "${key}".`);
219
+ process.exit(1);
220
+ }
221
+
222
+ const info = resolveKeyInfo(key);
223
+ const targetObj = info.file === 'budget' ? budgetConfig : securityConfig;
224
+ const targetPath = info.file === 'budget' ? budgetPath : securityPath;
225
+
226
+ try {
227
+ const parsedValue = castAndValidate(rawValue, info.type, info.values);
228
+ setNestedProp(targetObj, info.path, parsedValue);
229
+
230
+ // Write back securely
231
+ if (!fs.existsSync(configDir)) {
232
+ fs.mkdirSync(configDir, { recursive: true });
233
+ }
234
+ fs.writeFileSync(targetPath, yaml.stringify(targetObj), { encoding: 'utf8', mode: 0o600 });
235
+
236
+ console.log(`\n ✅ Success! Config key "${key}" ${layerLabel} set to: ${JSON.stringify(parsedValue)}`);
237
+ console.log(` 📍 Saved in: ${targetPath}\n`);
238
+ } catch (err) {
239
+ console.error(`\n ❌ Error setting "${key}": ${err.message}\n`);
240
+ process.exit(1);
241
+ }
242
+ return;
243
+ }
244
+
245
+ console.error(`Unknown subcommand "${command}". Run total-recall config --help for usage.`);
246
+ process.exit(1);
247
+ }