agenr 1.1.0 → 1.3.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 (165) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/README.md +12 -7
  3. package/dist/{chunk-B5C3FEPR.js → chunk-2FKQCRGD.js} +833 -29
  4. package/dist/cli.js +6040 -1932
  5. package/dist/core/recall/index.d.ts +3 -1
  6. package/dist/core/recall/index.js +1 -1
  7. package/dist/internal-recall-eval-server.js +2 -2
  8. package/package.json +10 -2
  9. package/.prettierrc +0 -5
  10. package/.vscode/launch.json +0 -77
  11. package/.vscode/tasks.json +0 -12
  12. package/AGENTS.md +0 -269
  13. package/docs/EVALS.md +0 -516
  14. package/docs/INGEST.md +0 -340
  15. package/docs/OPENCLAW-PLUGIN.md +0 -447
  16. package/docs/PLAN.md +0 -488
  17. package/docs/RECALL.md +0 -416
  18. package/docs/STORE.md +0 -246
  19. package/eslint.config.js +0 -172
  20. package/packages/openclaw-plugin/README.md +0 -12
  21. package/packages/openclaw-plugin/openclaw.plugin.json +0 -34
  22. package/packages/openclaw-plugin/package.json +0 -31
  23. package/packages/openclaw-plugin/src/index.ts +0 -1
  24. package/packages/openclaw-plugin/tsup.config.ts +0 -10
  25. package/pnpm-workspace.yaml +0 -2
  26. package/scripts/check-sim.ts +0 -89
  27. package/src/adapters/api/internal-recall-eval-server.ts +0 -204
  28. package/src/adapters/api/routes/internal-recall-eval.ts +0 -120
  29. package/src/adapters/api/validation/recall-eval-request.ts +0 -441
  30. package/src/adapters/db/client.ts +0 -206
  31. package/src/adapters/db/openclaw-plugin-queries.ts +0 -285
  32. package/src/adapters/db/queries.ts +0 -455
  33. package/src/adapters/db/recall-adapter.ts +0 -344
  34. package/src/adapters/db/row-mapping.ts +0 -216
  35. package/src/adapters/db/schema.ts +0 -399
  36. package/src/adapters/embeddings.ts +0 -286
  37. package/src/adapters/files/transcript-files.ts +0 -52
  38. package/src/adapters/llm.ts +0 -646
  39. package/src/adapters/openclaw/config.ts +0 -104
  40. package/src/adapters/openclaw/format/prompt-section.ts +0 -58
  41. package/src/adapters/openclaw/format/recall-format.ts +0 -86
  42. package/src/adapters/openclaw/hooks/before-prompt-build.ts +0 -338
  43. package/src/adapters/openclaw/hooks/before-reset.ts +0 -112
  44. package/src/adapters/openclaw/index.ts +0 -65
  45. package/src/adapters/openclaw/memory/flush-plan.ts +0 -21
  46. package/src/adapters/openclaw/memory/runtime.ts +0 -83
  47. package/src/adapters/openclaw/openclaw.plugin.json +0 -34
  48. package/src/adapters/openclaw/runtime.ts +0 -182
  49. package/src/adapters/openclaw/session/predecessor.ts +0 -319
  50. package/src/adapters/openclaw/session/sessions-store-reader.ts +0 -136
  51. package/src/adapters/openclaw/session/state.ts +0 -157
  52. package/src/adapters/openclaw/session/summary-reader.ts +0 -112
  53. package/src/adapters/openclaw/session/summary.ts +0 -373
  54. package/src/adapters/openclaw/session/tui-lane.ts +0 -59
  55. package/src/adapters/openclaw/tools.ts +0 -944
  56. package/src/adapters/openclaw/transcript/jsonl.ts +0 -53
  57. package/src/adapters/openclaw/transcript/message-content.ts +0 -300
  58. package/src/adapters/openclaw/transcript/parser.ts +0 -406
  59. package/src/adapters/openclaw/transcript/timestamps.ts +0 -99
  60. package/src/adapters/openclaw/transcript/tool-summarization.ts +0 -347
  61. package/src/adapters/openclaw/types.ts +0 -248
  62. package/src/app/evals/recall/collect-diagnostics.ts +0 -292
  63. package/src/app/evals/recall/contracts.ts +0 -345
  64. package/src/app/evals/recall/index.ts +0 -21
  65. package/src/app/evals/recall/instrumented-recall-ports.ts +0 -115
  66. package/src/app/evals/recall/normalize-response.ts +0 -78
  67. package/src/app/evals/recall/provision-fixtures.ts +0 -268
  68. package/src/app/evals/recall/run-recall-eval-case.ts +0 -134
  69. package/src/app/evals/recall/sandbox.ts +0 -92
  70. package/src/app/ingestion/index.ts +0 -9
  71. package/src/app/ingestion/ports.ts +0 -81
  72. package/src/app/ingestion/service.ts +0 -313
  73. package/src/cli/commands/db.ts +0 -117
  74. package/src/cli/commands/ingest.ts +0 -652
  75. package/src/cli/commands/init/cost-estimator.ts +0 -91
  76. package/src/cli/commands/init/external-commands.ts +0 -243
  77. package/src/cli/commands/init/index.ts +0 -17
  78. package/src/cli/commands/init/openclaw-detect.ts +0 -58
  79. package/src/cli/commands/init/session-scanner.ts +0 -83
  80. package/src/cli/commands/init/wizard.ts +0 -498
  81. package/src/cli/commands/recall.ts +0 -249
  82. package/src/cli/commands/setup.ts +0 -1411
  83. package/src/cli/main.ts +0 -41
  84. package/src/cli/ui.ts +0 -180
  85. package/src/cli.ts +0 -6
  86. package/src/config.ts +0 -357
  87. package/src/core/ingestion/dedup.ts +0 -561
  88. package/src/core/ingestion/extract.ts +0 -329
  89. package/src/core/ingestion/index.ts +0 -15
  90. package/src/core/ingestion/parser.ts +0 -271
  91. package/src/core/ingestion/pipeline.ts +0 -390
  92. package/src/core/ingestion/prompts.ts +0 -436
  93. package/src/core/ports.ts +0 -108
  94. package/src/core/recall/index.ts +0 -6
  95. package/src/core/recall/lexical.ts +0 -247
  96. package/src/core/recall/scoring.ts +0 -177
  97. package/src/core/recall/search.ts +0 -463
  98. package/src/core/recall/temporal.ts +0 -111
  99. package/src/core/recall/trace.ts +0 -124
  100. package/src/core/recall/types.ts +0 -67
  101. package/src/core/store/embedding-text.ts +0 -11
  102. package/src/core/store/hashing.ts +0 -28
  103. package/src/core/store/index.ts +0 -3
  104. package/src/core/store/pipeline.ts +0 -324
  105. package/src/core/store/validation.ts +0 -153
  106. package/src/core/types.ts +0 -112
  107. package/src/internal-recall-eval-server.ts +0 -95
  108. package/src/logger.ts +0 -83
  109. package/src/ui.ts +0 -74
  110. package/src/version.ts +0 -24
  111. package/tests/adapters/api/internal-recall-eval-server.test.ts +0 -88
  112. package/tests/adapters/api/routes/internal-recall-eval.test.ts +0 -461
  113. package/tests/adapters/api/validation/recall-eval-request.test.ts +0 -285
  114. package/tests/adapters/db/client.test.ts +0 -286
  115. package/tests/adapters/db/schema.test.ts +0 -275
  116. package/tests/adapters/embeddings.test.ts +0 -193
  117. package/tests/adapters/files/transcript-files.test.ts +0 -107
  118. package/tests/adapters/llm.test.ts +0 -453
  119. package/tests/adapters/openclaw/before-prompt-build.test.ts +0 -1160
  120. package/tests/adapters/openclaw/before-reset.test.ts +0 -287
  121. package/tests/adapters/openclaw/config.test.ts +0 -60
  122. package/tests/adapters/openclaw/flush-plan.test.ts +0 -18
  123. package/tests/adapters/openclaw/package-metadata.test.ts +0 -169
  124. package/tests/adapters/openclaw/prompt-section.test.ts +0 -25
  125. package/tests/adapters/openclaw/runtime.test.ts +0 -247
  126. package/tests/adapters/openclaw/session/predecessor.test.ts +0 -393
  127. package/tests/adapters/openclaw/session/summary.test.ts +0 -256
  128. package/tests/adapters/openclaw/session/tui-lane.test.ts +0 -32
  129. package/tests/adapters/openclaw/session-state.test.ts +0 -44
  130. package/tests/adapters/openclaw/tools.test.ts +0 -476
  131. package/tests/adapters/openclaw/transcript/parser.test.ts +0 -501
  132. package/tests/app/evals/recall/instrumented-recall-ports.test.ts +0 -120
  133. package/tests/app/evals/recall/run-recall-eval-case.test.ts +0 -508
  134. package/tests/app/ingestion/service.test.ts +0 -251
  135. package/tests/cli/commands/db.test.ts +0 -34
  136. package/tests/cli/commands/ingest.test.ts +0 -142
  137. package/tests/cli/commands/init/cost-estimator.test.ts +0 -50
  138. package/tests/cli/commands/init/external-commands.test.ts +0 -86
  139. package/tests/cli/commands/init/index.test.ts +0 -20
  140. package/tests/cli/commands/init/openclaw-detect.test.ts +0 -35
  141. package/tests/cli/commands/init/session-scanner.test.ts +0 -58
  142. package/tests/cli/commands/init/wizard.test.ts +0 -247
  143. package/tests/cli/commands/recall.test.ts +0 -82
  144. package/tests/cli/commands/setup.test.ts +0 -347
  145. package/tests/cli/fake-prompts.ts +0 -150
  146. package/tests/config.test.ts +0 -77
  147. package/tests/core/ingestion/dedup.test.ts +0 -351
  148. package/tests/core/ingestion/extract.test.ts +0 -294
  149. package/tests/core/ingestion/parser.test.ts +0 -251
  150. package/tests/core/ingestion/pipeline.test.ts +0 -592
  151. package/tests/core/ingestion/prompts.test.ts +0 -100
  152. package/tests/core/recall/lexical.test.ts +0 -91
  153. package/tests/core/recall/scoring.test.ts +0 -155
  154. package/tests/core/recall/search.integration.test.ts +0 -753
  155. package/tests/core/recall/search.test.ts +0 -262
  156. package/tests/core/recall/temporal.test.ts +0 -71
  157. package/tests/core/store/hashing.test.ts +0 -28
  158. package/tests/core/store/pipeline.test.ts +0 -295
  159. package/tests/core/store/validation.test.ts +0 -154
  160. package/tests/logger.test.ts +0 -77
  161. package/tests/ui.test.ts +0 -30
  162. package/tests/version.test.ts +0 -14
  163. package/tsconfig.json +0 -21
  164. package/tsup.config.ts +0 -12
  165. package/dist/{chunk-FLRJOP3J.js → chunk-EUPZHNOY.js} +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,67 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.3.0] - 2026-03-30
4
+
5
+ Episodic memory — session-level temporal recall for the brain.
6
+
7
+ ### Added
8
+
9
+ - **Episodic memory system (Phases 0–6).** A new `episodes` table stores narrative summaries of what happened during each session, queryable by time range and semantic similarity. Gives the brain temporal awareness — "what happened yesterday", "what were we working on last week", "sessions about schema changes" all work.
10
+ - **Episode ingest CLI.** `agenr ingest episodes <path>` scans OpenClaw session transcripts (including rotated `.reset.*` and `.deleted.*` files), generates episodic summaries, and writes episodes to the database. Supports `--recent`, `--regenerate`, `--dry-run`, `--concurrency`, `--embed-only`, and `--no-embed` flags.
11
+ - **Session discovery via `sessions.json`.** Uses OpenClaw's session registry for authoritative metadata (surface, agentId, chatType) on active sessions. Falls back to transcript-based surface reconstruction for rotated files.
12
+ - **Surface reconstruction from transcripts.** Detects session surface (webchat, telegram, signal, tui, subagent, heartbeat, cron) from Sender metadata blocks, Conversation info blocks, inbound_meta, and content heuristics. Integrated into the transcript parser to avoid double file reads.
13
+ - **Agent ID derivation from directory path.** Falls back to parsing the OpenClaw directory structure (`agents/{agentId}/sessions/`) when registry metadata is unavailable.
14
+ - **Unified recall with mode routing.** `agenr_recall` gains a `mode` parameter (`auto`, `entries`, `episodes`). Auto-routing uses three-band rules: temporal narrative → episodes, factual → entries, mixed → both. Results returned in separate sections with routing metadata.
15
+ - **Calendar-aware temporal window parser.** Parses "today", "yesterday", "this/last week", "this/last month", "N days/weeks/months ago", "in March", "March 15th", "last Friday", and ISO dates into precise calendar intervals for episode search.
16
+ - **Episode recall pipeline.** Pure temporal search via interval overlap scoring. No embedding dependency for basic temporal queries.
17
+ - **Hybrid semantic episode search (Phase 6).** Episode embeddings stored at write time, vector index (`idx_episodes_embedding`) for cosine similarity search. Three modes: pure temporal, pure semantic, and hybrid (hard temporal filter + semantic rerank).
18
+ - **Episode embedding backfill.** `agenr ingest episodes --embed-only` backfills embeddings for episodes missing them — no LLM calls, just embedding API.
19
+ - **Episode model configuration.** New `episodeModel` config field in `agenr setup` / `agenr init` for episode summary generation model override, following the existing extraction/dedup/surgeon pattern.
20
+ - **Episode writing at session start.** Predecessor episodes generated via `before_prompt_build` hook, best-effort with timeout. Backfill CLI is the canonical repair path.
21
+ - **Parallel preflight parsing.** Episode ingest Stage 1 parses transcript files concurrently to handle large session directories (600+ files) without hanging.
22
+
23
+ ### Changed
24
+
25
+ - **Continuity domain extraction.** Session handoff logic reorganized under `src/adapters/openclaw/session/continuity/` as a proper subdomain with clean public API. Continuity summaries (for session handoff) are now explicitly separate from episodic summaries (for temporal recall).
26
+ - **Renamed session summaries to continuity summaries.** Clarifies the distinction between handoff artifacts and episodic memory artifacts throughout the codebase.
27
+ - **Removed `before_reset` hook.** Does not fire for OpenClaw plugins — all episode and continuity logic uses `before_prompt_build` only.
28
+ - **Semantic memory cleanup (Ref #7).** Removed `reflection` entry type, migrated `todo` to `tasks` table, renamed `event` to `milestone`, broadened type descriptions.
29
+ - **Transcript file discovery.** Fixed regex to match rotated files with ISO timestamp dots (`.628Z`). Discovery now finds all 600+ files instead of only active `.jsonl` files.
30
+
31
+ ### Fixed
32
+
33
+ - **Episode vector search ambiguous column.** Prefixed select columns with table alias in `episodeVectorSearch()` to resolve `id` ambiguity with `vector_top_k` join.
34
+ - **Temporal parser ordinal dates.** "March 15th", "January 1st", "February 2nd" now parse correctly.
35
+ - **Subagent/cron surface classification.** Session registry detects `:subagent:` and `:cron:` in session keys for correct surface tagging.
36
+ - **Internal session skipping.** Agenr prompt pipeline sessions are filtered from episode generation.
37
+
38
+ ## [1.2.0] - 2026-03-29
39
+
40
+ The surgeon retirement pass — an autonomous agent that evaluates and retires stale knowledge entries.
41
+
42
+ ### Added
43
+
44
+ - **Surgeon retirement pass.** A standalone agent loop powered by `@mariozechner/pi-agent-core` that evaluates knowledge entries and retires semantically stale ones. Runs as `agenr surgeon run` with full dry-run and apply modes, budget governance, and completion guards.
45
+ - **7 surgeon tools.** `get_health_stats`, `query_candidates`, `inspect_entry`, `simulate_recall`, `retire_entry`, `update_entry`, and `complete_pass` — each adapted from the v0 surgeon for v1's simpler schema.
46
+ - **Recall simulation without telemetry.** The `simulate_recall` tool wraps the v1 recall pipeline with a no-op telemetry adapter and optional target-entry exclusion, so the surgeon can test retrieval impact without polluting recall metrics.
47
+ - **Surgeon CLI commands.** `agenr surgeon run`, `agenr surgeon status`, `agenr surgeon history`, and `agenr surgeon actions <run-id>` for running, inspecting, and auditing surgeon passes.
48
+ - **Surgeon status shows evaluation coverage.** `agenr surgeon status` now displays recently evaluated vs new candidates, so you can see how much work remains before running.
49
+ - **Surgeon model configuration in setup.** `agenr setup` and `agenr init` now include surgeon model overrides in the advanced task-specific model configuration flow.
50
+ - **Budget and completion governance.** Cost-based budget tracking, context-limit detection, completion guards that reject premature pass completion, and continuation prompts that keep the surgeon working when budget remains.
51
+ - **Run and action persistence.** Surgeon runs and individual actions (retirements, skips, updates) are logged to the database for auditability and recently-evaluated filtering on future runs.
52
+ - **Database backup before apply.** Surgeon creates a timestamped backup of the knowledge database (including WAL/SHM sidecars) before executing mutations in apply mode.
53
+ - **Surgeon configuration.** New `surgeon` section in `config.json` supporting model override, cost caps, daily cost limits, context limits, custom instructions, and per-pass protection thresholds.
54
+
55
+ ### Changed
56
+
57
+ - **Schema version bumped to 2.** The `surgeon_runs` table is expanded with pass type, status, token/cost tracking, model, dry-run flag, and structured summary fields. A new `surgeon_run_actions` table logs individual surgeon actions with indexed `entry_id` for efficient recently-evaluated queries. Existing databases are migrated automatically via `ALTER TABLE ADD COLUMN`.
58
+ - **Protection threshold raised to importance ≥ 9.** Entries with importance 8 are now eligible for surgeon evaluation since many entries default to importance 8 during ingestion.
59
+ - **Setup prompt updated.** The advanced model override prompt now reads "Customize task-specific models?" to reflect the addition of surgeon alongside extraction and dedup overrides.
60
+
61
+ ### Fixed
62
+
63
+ - **Tightened npm publish surface.** Root package now uses a strict `"files"` allowlist so only intended artifacts are published.
64
+
3
65
  ## [1.1.0] - 2026-03-28
4
66
 
5
67
  This release splits the OpenClaw plugin into its own publishable npm package and tightens session-start handoff reliability.
package/README.md CHANGED
@@ -130,13 +130,15 @@ Important: when agenr is running as an OpenClaw plugin, session summaries use Op
130
130
 
131
131
  The current CLI surface is intentionally small. Today the `db` group only exposes `reset`.
132
132
 
133
- | Command | What it does |
134
- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------ |
135
- | `agenr init` | Interactive first-run wizard: auth, model selection, OpenClaw detection, plugin install, and optional initial ingestion. |
136
- | `agenr setup` | Configure auth, model defaults, embeddings, and the agenr database path. |
137
- | `agenr recall <query>` | Run the hybrid recall pipeline with optional temporal and type/tag filters. |
138
- | `agenr ingest <path>` | Bulk-ingest one file or directory of OpenClaw transcript files. |
139
- | `agenr db reset` | Delete and recreate the knowledge database. |
133
+ | Command | What it does |
134
+ | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------ |
135
+ | `agenr init` | Interactive first-run wizard: auth, model selection, OpenClaw detection, plugin install, and optional initial ingestion. |
136
+ | `agenr setup` | Configure auth, model defaults, embeddings, and the agenr database path. |
137
+ | `agenr recall <query>` | Run the hybrid recall pipeline with optional temporal and type/tag filters. |
138
+ | `agenr ingest <path>` | Default durable-entry ingest shorthand. Equivalent to `agenr ingest entries <path>`. |
139
+ | `agenr ingest entries <path>` | Bulk-ingest one file or directory of OpenClaw transcript files into durable knowledge entries. |
140
+ | `agenr ingest episodes <path>` | Backfill episodic summaries from OpenClaw session transcripts, including rotated `.reset.*` and `.deleted.*` files. |
141
+ | `agenr db reset` | Delete and recreate the knowledge database. |
140
142
 
141
143
  The OpenClaw plugin also gives the agent five tools directly inside the runtime: `agenr_store`, `agenr_recall`, `agenr_retire`, `agenr_update`, and `agenr_trace`.
142
144
 
@@ -149,6 +151,9 @@ agenr recall "what decisions did we make about the API?"
149
151
  # Ingest transcripts
150
152
  agenr ingest ~/.openclaw/agents/main/sessions/
151
153
 
154
+ # Backfill episode summaries
155
+ agenr ingest episodes ~/.openclaw/agents/main/sessions/ --recent 30d
156
+
152
157
  # Reset the database
153
158
  agenr db reset
154
159
  ```