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,81 @@
1
+ Codex CLI
2
+
3
+ Usage: codex [OPTIONS] [PROMPT]
4
+ codex [OPTIONS] <COMMAND> [ARGS]
5
+
6
+ Commands:
7
+ exec Run Codex non-interactively [aliases: e]
8
+ review Run a code review non-interactively
9
+ login Manage login
10
+ logout Remove stored authentication credentials
11
+ mcp Manage external MCP servers for Codex
12
+ plugin Manage Codex plugins
13
+ mcp-server Start Codex as an MCP server (stdio)
14
+ app-server [experimental] Run the app server or related tooling
15
+ app Launch the Codex desktop app (opens the app installer if missing)
16
+ completion Generate shell completion scripts
17
+ sandbox Run commands within a Codex-provided sandbox
18
+ debug Debugging tools
19
+ apply Apply the latest diff produced by Codex agent as a `git apply` to your local working
20
+ tree [aliases: a]
21
+ resume Resume a previous interactive session (picker by default; use --last to continue the
22
+ most recent)
23
+ fork Fork a previous interactive session (picker by default; use --last to fork the most
24
+ recent)
25
+ cloud [EXPERIMENTAL] Browse tasks from Codex Cloud and apply changes locally
26
+ exec-server [EXPERIMENTAL] Run the standalone exec-server service
27
+ features Inspect feature flags
28
+ help Print this message or the help of the given subcommand(s)
29
+
30
+ Arguments:
31
+ [PROMPT] Optional user prompt to start the session
32
+
33
+ Options:
34
+ -c, --config <key=value>
35
+ Override a configuration value that would otherwise be loaded from `~/.codex/config.toml`.
36
+ Use a dotted path (`foo.bar.baz`) to override nested values. The `value` portion is parsed
37
+ as TOML. If it fails to parse as TOML, the raw string is used as a literal
38
+ --enable <FEATURE>
39
+ Enable a feature (repeatable). Equivalent to `-c features.<name>=true`
40
+ --disable <FEATURE>
41
+ Disable a feature (repeatable). Equivalent to `-c features.<name>=false`
42
+ --remote <ADDR>
43
+ Connect the TUI to a remote app server websocket endpoint
44
+ --remote-auth-token-env <ENV_VAR>
45
+ Name of the environment variable containing the bearer token to send to a remote app
46
+ server websocket
47
+ -i, --image <FILE>...
48
+ Optional image(s) to attach to the initial prompt
49
+ -m, --model <MODEL>
50
+ Model the agent should use
51
+ --oss
52
+ Use open-source provider
53
+ --local-provider <OSS_PROVIDER>
54
+ Specify which local provider to use (lmstudio or ollama). If not specified with --oss,
55
+ will use config default or show selection
56
+ -p, --profile <CONFIG_PROFILE>
57
+ Configuration profile from config.toml to specify default options
58
+ -s, --sandbox <SANDBOX_MODE>
59
+ Select the sandbox policy to use when executing model-generated shell commands [possible
60
+ values: read-only, workspace-write, danger-full-access]
61
+ --full-auto
62
+ Convenience alias for low-friction sandboxed automatic execution
63
+ --dangerously-bypass-approvals-and-sandbox
64
+ Skip all confirmation prompts and execute commands without sandboxing. EXTREMELY
65
+ DANGEROUS. Intended solely for running in environments that are externally sandboxed
66
+ -C, --cd <DIR>
67
+ Tell the agent to use the specified directory as its working root
68
+ --add-dir <DIR>
69
+ Additional directories that should be writable alongside the primary workspace
70
+ -a, --ask-for-approval <APPROVAL_POLICY>
71
+ Configure when the model requires human approval before executing a command [possible
72
+ values: untrusted, on-failure, on-request, never]
73
+ --search
74
+ Enable live web search. When enabled, the native Responses `web_search` tool is available
75
+ to the model (no per‑call approval)
76
+ --no-alt-screen
77
+ Disable alternate screen mode
78
+ -h, --help
79
+ Print help (see more with '--help')
80
+ -V, --version
81
+ Print version
@@ -0,0 +1,44 @@
1
+ Usage: gemini [options] [command]
2
+
3
+ Gemini CLI - Defaults to interactive mode. Use -p/--prompt for non-interactive (headless) mode.
4
+
5
+ Commands:
6
+ gemini mcp Manage MCP servers
7
+ gemini extensions <command> Manage Gemini CLI extensions. [aliases: extension]
8
+ gemini skills <command> Manage agent skills. [aliases: skill]
9
+ gemini hooks <command> Manage Gemini CLI hooks. [aliases: hook]
10
+ gemini gemma Manage local Gemma model routing
11
+ gemini [query..] Launch Gemini CLI [default]
12
+
13
+ Positionals:
14
+ query Initial prompt. Runs in interactive mode by default; use -p/--prompt for non-interactive.
15
+
16
+ Options:
17
+ -d, --debug Run in debug mode (open debug console with F12) [boolean] [default: false]
18
+ -m, --model Model [string]
19
+ -p, --prompt Run in non-interactive (headless) mode with the given prompt. Appended to input on stdin (if any). [string]
20
+ -i, --prompt-interactive Execute the provided prompt and continue in interactive mode [string]
21
+ --skip-trust Trust the current workspace for this session. [boolean] [default: false]
22
+ -w, --worktree Start Gemini in a new git worktree. If no name is provided, one is generated automatically. [string]
23
+ -s, --sandbox Run in sandbox? [boolean]
24
+ -y, --yolo Automatically accept all actions (aka YOLO mode, see https://www.youtube.com/watch?v=xvFZjo5PgG0 for more details)? [boolean] [default: false]
25
+ --approval-mode Set the approval mode: default (prompt for approval), auto_edit (auto-approve edit tools), yolo (auto-approve all tools), plan (read-only mode) [string] [choices: "default", "auto_edit", "yolo", "plan"]
26
+ --policy Additional policy files or directories to load (comma-separated or multiple --policy) [array]
27
+ --admin-policy Additional admin policy files or directories to load (comma-separated or multiple --admin-policy) [array]
28
+ --acp Starts the agent in ACP mode [boolean]
29
+ --experimental-acp Starts the agent in ACP mode (deprecated, use --acp instead) [boolean]
30
+ --allowed-mcp-server-names Allowed MCP server names [array]
31
+ --allowed-tools [DEPRECATED: Use Policy Engine instead See https://geminicli.com/docs/core/policy-engine] Tools that are allowed to run without confirmation [array]
32
+ -e, --extensions A list of extensions to use. If not provided, all extensions are used. [array]
33
+ -l, --list-extensions List all available extensions and exit. [boolean]
34
+ -r, --resume Resume a previous session. Use "latest" for most recent or index number (e.g. --resume 5) [string]
35
+ --session-id Start a new session with a manually provided UUID. [string]
36
+ --list-sessions List available sessions for the current project and exit. [boolean]
37
+ --delete-session Delete a session by index number (use --list-sessions to see available sessions). [string]
38
+ --include-directories Additional directories to include in the workspace (comma-separated or multiple --include-directories) [array]
39
+ --screen-reader Enable screen reader mode for accessibility. [boolean]
40
+ -o, --output-format The format of the CLI output. [string] [choices: "text", "json", "stream-json"]
41
+ --raw-output Disable sanitization of model output (e.g. allow ANSI escape sequences). WARNING: This can be a security risk if the model output is untrusted. [boolean]
42
+ --accept-raw-output-risk Suppress the security warning when using --raw-output. [boolean]
43
+ -v, --version Show version number [boolean]
44
+ -h, --help Show help [boolean]
@@ -0,0 +1,337 @@
1
+ ---
2
+ type: skill
3
+ name: research
4
+ description: "Use this skill when queueing, searching, and managing long-horizon background research projects via the Total Recall REST API."
5
+ ---
6
+
7
+ # Total Recall — Background Research & Continuous Intelligence Skill
8
+
9
+ This skill governs the execution, queueing, status management, and dynamic search query retrieval of local background **Research Projects** in the Total Recall Sovereign OS. It details the underlying **multi-source intelligence gathering engine**, the web crawling and scraping pipeline, specialized domain adapters, and the Structured Semantic Syntax System (SSSS) v2 citation and frontmatter schema.
10
+
11
+ ---
12
+
13
+ ## 🎯 SYSTEM OVERVIEW & WORKFLOWS
14
+
15
+ Total Recall features a highly robust, proactive continuous intelligence system that runs as an autonomous, concurrent background daemon. Under the hood, this engine performs deep context collection, crawls live web pages, cross-verifies facts across multiple independent APIs, and compiles structured Markdown memory nodes with valid SSSS v2 metadata.
16
+
17
+ ```mermaid
18
+ flowchart TD
19
+ A[Trigger Research] --> B{Choose Execution Mode}
20
+ B -->|Proactive / Deep| C[Frontier-Orchestrated Planning]
21
+ B -->|Quick / Direct| D[Local LLM Single-Cycle Engine]
22
+
23
+ C --> E[Plan: Decompose into 3 target queries]
24
+ E --> F[Parallel Multi-Source Search & Crawl]
25
+ D --> F
26
+
27
+ F --> G{Search Fallback Chain}
28
+ G -->|Paid| H[Brave / Tavily / Exa / Serper]
29
+ G -->|Free Fallback| I[DuckDuckGo Instant / Wikipedia]
30
+
31
+ F --> J[Specialized Adapters: arXiv / npm / GitHub]
32
+
33
+ F --> K{Scraping Pipeline}
34
+ K -->|JS Pages / SPAs| L[Playwright Headless Chromium\nResource Blocking Mode]
35
+ K -->|Raw Fetch Fallback| M[Strip HTML Tags & Scripts]
36
+
37
+ H & I & J & L & M --> N[Fact Extraction & Verification]
38
+ N --> O{Assess Confidence}
39
+ O -->|>= 0.7 Fast Path| P[Direct Vault Write & Immediate Surface Recompile]
40
+ O -->|< 0.7 Inbox Path| Q[Stage as Draft Node in Inbox for Manual Review]
41
+
42
+ P --> R[Enqueue Follow-up Research for Identified Gaps]
43
+ ```
44
+
45
+ ---
46
+
47
+ ## 🎯 WHEN TO TRIGGER BACKGROUND RESEARCH
48
+
49
+ You must carefully choose when to delegate a topic to background research vs when to handle it immediately:
50
+
51
+ ### 🚀 Trigger Research If:
52
+ 1. **The topic requires high-density domain learning**: Deep framework updates (e.g., Next.js 15 routing mechanics), complete architectural standards, complex security protocols, or large open-source specifications.
53
+ 2. **You plan to run long-horizon tasks**: When executing highly demanding workflows (e.g., overnight or via the `/goal` command) and you want the system to continuously study and ingest complex material in the background.
54
+ 3. **The domain knowledge has high reuse potential**: Factual guidelines or patterns that multiple subsequent agent turns will need to reference frequently.
55
+
56
+ ### 🚫 DO NOT Trigger Research If:
57
+ 1. **You need a quick API reference**: Finding the signature of a common library function, checking standard CLI flags, or looking up simple code snippets. Use immediate web search features.
58
+ 2. **The query is highly specific or transient**: Specific bugs unique to the current file workspace that will not represent a reusable systemic memory.
59
+
60
+ ---
61
+
62
+ ## 🛡️ CORE RESEARCH MODES
63
+
64
+ The Total Recall research engine operates in two modes:
65
+
66
+ ### 1. Proactive / Deep Research (`handleProactiveResearch`)
67
+ * **Orchestration**: Leverages the frontier model (if configured in `~/.agent/config/frontier.yml`) to decompose the high-level objective into **3 distinct, specific search queries**.
68
+ * **Parallelization**: Launches parallel multi-source crawlers for each query.
69
+ * **Drafting**: Writes separate draft batch files inside `~/.agent/memory-inbox/pending/`.
70
+ * **Synthesis**: Synthesizes the aggregated draft batches using the frontier model (falling back to the local LLM if the frontier is unavailable) to produce a comprehensive final report.
71
+ * **Continuous Tracking**: Automatically registers the primary topic in the **Research Agenda** for ongoing continuous intelligence.
72
+
73
+ ### 2. Quick Research (`handleQuickResearch` / `runKnowledgeAcquisitionCycle`)
74
+ * **Speed**: Runs a fast, single-cycle research task driven by the local LLM.
75
+ * **Direct Execution**: Immediately queries available search APIs, synthesizes results, and produces a cited memory node in a single turn.
76
+
77
+ ---
78
+
79
+ ## 🌐 MULTI-API WEB SEARCH & FALLBACKS
80
+
81
+ To bypass limitations and ensure high availability, the search engine utilizes a robust, prioritized fallback chain configured in `~/.agent/config/research.yml`:
82
+
83
+ $$\text{Brave Search} \longrightarrow \text{Tavily Search} \longrightarrow \text{Exa Search} \longrightarrow \text{Serper Search} \longrightarrow \text{DuckDuckGo (Always-Free Fallback)}$$
84
+
85
+ ### 1. Paid Search Providers (Configured via API Keys)
86
+ * **Brave Search API** (*Primary*): Web search with high relevancy and structured metadata. Free tier offers 2,000 queries/month.
87
+ * **Tavily Search** (*Agent-Purpose*): Purpose-built for AI agents. Delivers clean extracted page text snippets directly, often bypassing the need for secondary scraping.
88
+ * **Exa Search** (*Neural/Semantic*): Uses semantic/meaning-based neural searches instead of simple keywords; highly recommended for fresh, recent articles.
89
+ * **Serper.dev** (*Google Fallback*): Clean Google Search API wrapping, ideal as a final fallback.
90
+
91
+ ### 2. Always-Free Web Fallbacks (No Auth Required)
92
+ * **DuckDuckGo Instant Answers**: Used automatically when paid budgets are exhausted or keys are missing. Excellent for definitions, structured entity facts, and direct calculations.
93
+ * **Daily Search Budget Tracker**: To protect free-tier developers from unexpected overage charges, Total Recall tracks daily searches in `~/.agent/config/search-usage.json`. The default limit is **50 paid searches/day** (roughly 1,500/month). When this cap is exceeded, the engine gracefully falls back to free DuckDuckGo search so that research never halts.
94
+
95
+ ---
96
+
97
+ ## 🔬 SPECIALIZED KNOWLEDGE ADAPTERS
98
+
99
+ For academic, package-ecosystem, and repository queries, the engine routes search queries through specialized adapters that bypass generic web search filters:
100
+
101
+ ### 1. arXiv API (Academic & ML Research)
102
+ * **Triggers**: Activated when query contains words like `model`, `llm`, `neural`, `ml`, `ai`, `research`, `paper`, or `algorithm`.
103
+ * **Function**: Queries academic paper repositories, parses the XML feeds without external dependencies, and extracts title, summary, publication date, and academic links.
104
+
105
+ ### 2. npm Registry & Detail API (JavaScript Ecosystem)
106
+ * **Triggers**: Activated when query contains terms like `npm`, `node`, `javascript`, `typescript`, `package`, or `library`.
107
+ * **Function**:
108
+ * **Search**: Finds the top 5 package names matching the query text.
109
+ * **Details**: Directly fetches a package's exact package metadata (dependencies, version history, license, homepage, and repository URL).
110
+
111
+ ### 3. GitHub Search API (Code & Repositories)
112
+ * **Triggers**: Activated when query contains `github`, `repo`, `open-source`, `cli`, `sdk`, or `api`.
113
+ * **Function**: Queries star-sorted repositories or issues. Authenticates using `GITHUB_TOKEN` to scale rate limits from 60 to 5,000 requests/hour.
114
+
115
+ ### 4. Wikipedia REST API (Structured Facts)
116
+ * **Triggers**: Always queried in parallel.
117
+ * **Function**: Fetches clean summaries, page IDs, timestamps, and desktop page links for entities and historical events.
118
+
119
+ ---
120
+
121
+ ## 🕷️ HEADLESS CRAWLING & SCRAPING (PLAYWRIGHT)
122
+
123
+ When a web search returns a high-relevance URL, the crawler performs deep content extraction.
124
+
125
+ ### 1. Playwright Headless Browser Mode
126
+ If `playwright` is installed, the engine launches a headless Chromium instance to fetch pages. This handles:
127
+ * **JavaScript-Rendered Pages**: SPAs, React, Next.js, and complex frontend architectures.
128
+ * **Bot Detection & Protections**: Spoofs common desktop headers and sets real device viewports (`1280x800`).
129
+ * **Performance Optimization (Resource Blocking)**: Speeds up scraping and conserves bandwidth by intercepting and **blocking** requests for:
130
+ * `image`
131
+ * `media`
132
+ * `font`
133
+ * `stylesheet`
134
+ * **Selector Traversal**: Prioritizes key readable elements (`article`, `main`, `[role="main"]`, `.content`, `#content`) before resorting to `body` text, extracting the first 8,000 characters of clean content.
135
+
136
+ ### 2. Graceful Plain Fetch Fallback
137
+ If Playwright is not installed or Chromium fails to launch, the engine falls back to a plain Node `fetch`.
138
+ * **HTML Sanitization**: Automatically strips out `<script>` tags, `<style>` blocks, and other HTML/CSS markup using regex to return clean text.
139
+
140
+ ---
141
+
142
+ ## 🧠 FACT SYNTHESIS, VERIFICATION & TRUST
143
+
144
+ Once raw data is gathered, it is processed to ensure accuracy:
145
+
146
+ 1. **Temporal Verification**: Synthesizers are injected with the current real-world date and the model's training cutoff date (e.g., *January 2025*). Sources published *after* the cutoff are prioritized to capture new developments.
147
+ 2. **Cross-Verification**: Facts must be cross-verified across multiple independent sources.
148
+ 3. **Confidence Grading**: Confidence scores (`0.0` to `1.0`) are mathematically computed:
149
+ * *Single Source*: Maximum confidence capped at `0.6`.
150
+ * *3+ Agreeing Sources*: Promoted up to `0.95` confidence.
151
+ 4. **Contradiction Analysis**: If sources disagree, the engine flags the conflict in a `contradictions` array.
152
+ 5. **Self-Multiplication (Gap Tracking)**: Unresolved questions are placed in a `further_research_needed` array. High-priority gaps are automatically added back to the Research Agenda as new pending topics.
153
+
154
+ ---
155
+
156
+ ## 🗂️ SSSS v2 MEMORY NODE CITATION SCHEMA
157
+
158
+ Fact-seeker results are saved as structured Markdown files containing valid **SSSS v2 YAML frontmatter**.
159
+
160
+ ### Confidence-Based Routing
161
+ * **High Confidence ($\ge 0.7$) [FAST PATH]**: Written directly to the active memory vault (`~/.agent/memory-vault/facts/`) as an `active` node, triggering an **immediate surface recompile** so the knowledge appears in `INSTRUCTIONS.md` within seconds.
162
+ * **Low Confidence ($< 0.7$) [INBOX PATH]**: Staged in `~/.agent/memory-inbox/pending/` as a `draft` node for manual review and subsequent promotion by the conclusion-writer.
163
+
164
+ ### SSSS v2 Frontmatter Fields Specification
165
+ ```yaml
166
+ type: memory
167
+ slug: fact-a1b2c3d4e5 # Unique kebab-case identifier
168
+ category: facts
169
+ title: "React 19 Server Components Specifications"
170
+ status: active # active (fast-path) | draft (inbox-path)
171
+ confidence: 0.92 # 0.0 to 1.0 (based on source agreement)
172
+ importance: 6 # 6 for fast-path, 4 for draft
173
+ created: "2026-05-21T06:15:00.000Z"
174
+ updated: "2026-05-21T06:15:00.000Z"
175
+ last_accessed: "2026-05-21T06:15:00.000Z"
176
+ source:
177
+ type: knowledge-acquisition
178
+ session_id: "fact-seeker-lo9z8x7c"
179
+ agent: fact-seeker
180
+ evidence_count: 4
181
+ supersedes: []
182
+ superseded_by: null
183
+ contradicts: []
184
+ tags:
185
+ - fact-seeker
186
+ - auto-researched
187
+ - cited
188
+ - fast-path
189
+ related: []
190
+ routes_to_skills: []
191
+ sentiment_polarity: descriptive
192
+ sentiment_target: external-knowledge
193
+ modality: should
194
+ subject: agent
195
+ predicate: know
196
+ object: "React 19 Server Components"
197
+ decay:
198
+ half_life_days: 60 # Facts decay and require re-verification
199
+ access_count: 1
200
+ schema_version: 2
201
+ x_memory_layer: research
202
+ x_topic: "React 19 Server Components"
203
+ x_temporal_context: "2026-05"
204
+ x_sources_count: 4
205
+ x_citations: # List of all consulted URLs and scores
206
+ - source: brave-search
207
+ type: web
208
+ title: "React 19 Release Changelog"
209
+ url: "https://react.dev/blog/2024/12/05/react-19"
210
+ published: "2024-12-05"
211
+ relevance: 0.95
212
+ accessed: "2026-05-21T06:15:00.000Z"
213
+ - source: npm
214
+ type: package-detail
215
+ title: "react@19.0.0"
216
+ url: "https://www.npmjs.com/package/react"
217
+ published: "2024-12-05"
218
+ relevance: 1.0
219
+ accessed: "2026-05-21T06:15:00.000Z"
220
+ ```
221
+
222
+ ---
223
+
224
+ ## 🌐 REST API ENDPOINT REFERENCE
225
+
226
+ All communication with the research queue must use standard shell `curl` commands directed to the local Total Recall REST brain.
227
+
228
+ * **Header Required:** `Authorization: Bearer <YOUR_PAT_TOKEN>`
229
+ * **Default Brain URL:** `http://localhost:3000` (or the value of `<YOUR_BRAIN_URL>`)
230
+
231
+ | Method | Endpoint | Query Parameters | Description |
232
+ |:---|:---|:---|:---|
233
+ | **POST** | `/api/research` | None | Enqueue a new research project topic. |
234
+ | **GET** | `/api/research` | `status`, `query`, `limit`, `offset` | Search and list enqueued research projects. |
235
+ | **PATCH** | `/api/research/:id` | None | Update priority, notes, or status of a project. |
236
+ | **DELETE** | `/api/research/:id` | None | Revoke and delete a project from the agenda. |
237
+
238
+ ### 1. Enqueue a Research Project (`POST /api/research`)
239
+ * **Payload Schema (JSON):**
240
+ * `topic` (string, **required**): Concise, highly descriptive title of the target domain/subject.
241
+ * `priority` (string, optional): `high` | `medium` | `low` (default: `medium`).
242
+ * `notes` (string, optional): Details on what information needs collection or constraints to follow.
243
+
244
+ * **curl Template:**
245
+ ```bash
246
+ curl -X POST \
247
+ -H "Authorization: Bearer <YOUR_PAT_TOKEN>" \
248
+ -H "Content-Type: application/json" \
249
+ -d '{
250
+ "topic": "TypeScript 5.8 ECMAScript module syntax compatibility",
251
+ "priority": "high",
252
+ "notes": "Verify moduleResolution options and output configurations."
253
+ }' \
254
+ <YOUR_BRAIN_URL>/api/research
255
+ ```
256
+
257
+ ### 2. Search & List Research Projects (`GET /api/research`)
258
+ Allows you to list the background research agenda, filter by status, or perform a dynamic query search across the `topic` and `notes` fields.
259
+ * **Query Parameters:**
260
+ * `status` (string, optional): `pending` | `in_progress` | `done` | `failed` | `all`
261
+ * `query` (string, optional): Search keyword query matched case-insensitively against the topic and notes.
262
+ * `limit` (number, optional): Maximum items to return (default: 100).
263
+ * `offset` (number, optional): Index offset for pagination.
264
+
265
+ * **curl Templates:**
266
+ ```bash
267
+ # A) List all research projects
268
+ curl -H "Authorization: Bearer <YOUR_PAT_TOKEN>" \
269
+ <YOUR_BRAIN_URL>/api/research
270
+
271
+ # B) Get active/running research topics
272
+ curl -H "Authorization: Bearer <YOUR_PAT_TOKEN>" \
273
+ "<YOUR_BRAIN_URL>/api/research?status=in_progress"
274
+
275
+ # C) Dynamically search queue by keywords (matches topic and notes)
276
+ curl -H "Authorization: Bearer <YOUR_PAT_TOKEN>" \
277
+ "<YOUR_BRAIN_URL>/api/research?query=TypeScript"
278
+ ```
279
+
280
+ ### 3. Update a Research Project (`PATCH /api/research/:id`)
281
+ * **curl Template:**
282
+ ```bash
283
+ curl -X PATCH \
284
+ -H "Authorization: Bearer <YOUR_PAT_TOKEN>" \
285
+ -H "Content-Type: application/json" \
286
+ -d '{"priority": "high", "notes": "Escalate priority: urgent workspace integration needed"}' \
287
+ <YOUR_BRAIN_URL>/api/research/c62fb293-1383-4a11-b0e6-1234abcd5678
288
+ ```
289
+
290
+ ### 4. Revoke / Remove a Research Project (`DELETE /api/research/:id`)
291
+ * **curl Template:**
292
+ ```bash
293
+ curl -X DELETE \
294
+ -H "Authorization: Bearer <YOUR_PAT_TOKEN>" \
295
+ <YOUR_BRAIN_URL>/api/research/c62fb293-1383-4a11-b0e6-1234abcd5678
296
+ ```
297
+
298
+ ---
299
+
300
+ ## 🛠️ CODE INTEGRATION CHEATSHEET
301
+
302
+ Here is a quick Node.js wrapper for agents wishing to query and manage research programmatically inside workspace tools:
303
+
304
+ ```javascript
305
+ import { spawnSync } from 'node:child_process';
306
+
307
+ const BRAIN_URL = process.env.TR_BRAIN || 'http://localhost:3000';
308
+ const PAT_TOKEN = process.env.TR_PAT;
309
+
310
+ function callBrain(method, path, body = null) {
311
+ const args = [
312
+ '-s',
313
+ '-X', method,
314
+ '-H', `Authorization: Bearer ${PAT_TOKEN}`,
315
+ '-H', 'Content-Type: application/json'
316
+ ];
317
+ if (body) {
318
+ args.push('-d', JSON.stringify(body));
319
+ }
320
+ args.push(`${BRAIN_URL}${path}`);
321
+
322
+ const res = spawnSync('curl', args, { encoding: 'utf8' });
323
+ if (res.error) throw res.error;
324
+ return JSON.parse(res.stdout);
325
+ }
326
+
327
+ // Example 1: Enqueue a research task
328
+ const enqueued = callBrain('POST', '/api/research', {
329
+ topic: 'Ollama model catalog specifications',
330
+ notes: 'Query local endpoint catalog model sizes.'
331
+ });
332
+ console.log('Enqueued:', enqueued.id);
333
+
334
+ // Example 2: Search active items
335
+ const results = callBrain('GET', '/api/research?query=Ollama');
336
+ console.log(`Found ${results.total} matching research tasks.`);
337
+ ```