@edihasaj/recall 0.6.7 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -1
- package/dist/chunk-37K4DPRI.js +17 -0
- package/dist/chunk-37K4DPRI.js.map +1 -0
- package/dist/chunk-AKODTKWM.js +123 -0
- package/dist/chunk-AKODTKWM.js.map +1 -0
- package/dist/{chunk-4P3NKEIJ.js → chunk-CPOANMKD.js} +18 -9
- package/dist/{chunk-4P3NKEIJ.js.map → chunk-CPOANMKD.js.map} +1 -1
- package/dist/{chunk-AJAAK4FK.js → chunk-GNXTOM5K.js} +159 -9
- package/dist/chunk-GNXTOM5K.js.map +1 -0
- package/dist/chunk-JRIM7VBY.js +2346 -0
- package/dist/chunk-JRIM7VBY.js.map +1 -0
- package/dist/chunk-PG2ZVVAT.js +6525 -0
- package/dist/chunk-PG2ZVVAT.js.map +1 -0
- package/dist/{chunk-LFWG3CBM.js → chunk-PH6YNVHR.js} +206 -2381
- package/dist/chunk-PH6YNVHR.js.map +1 -0
- package/dist/chunk-QDA5M3AJ.js +2617 -0
- package/dist/chunk-QDA5M3AJ.js.map +1 -0
- package/dist/chunk-QSJKGEID.js +235 -0
- package/dist/chunk-QSJKGEID.js.map +1 -0
- package/dist/chunk-UBPGOOAN.js +462 -0
- package/dist/chunk-UBPGOOAN.js.map +1 -0
- package/dist/{chunk-XUM7JEJU.js → chunk-YL23MKB3.js} +10 -4
- package/dist/{chunk-XUM7JEJU.js.map → chunk-YL23MKB3.js.map} +1 -1
- package/dist/chunk-Z6RT5BUO.js +282 -0
- package/dist/chunk-Z6RT5BUO.js.map +1 -0
- package/dist/{cleanup-JM3CGHUV.js → cleanup-YGHZIYLJ.js} +6 -3
- package/dist/cli.js +160 -26
- package/dist/cli.js.map +1 -1
- package/dist/daemon.js +662 -42
- package/dist/daemon.js.map +1 -1
- package/dist/{dispatcher-C5S7SYY6.js → dispatcher-5MDL3QQT.js} +6 -3
- package/dist/embeddings-GKNH2E3N.js +48 -0
- package/dist/ingest-JWXX22QX.js +19 -0
- package/dist/mcp.js +9 -4
- package/dist/mcp.js.map +1 -1
- package/dist/{quality-YTQKAEY6.js → quality-2JOLSIC3.js} +4 -3
- package/dist/quality-2JOLSIC3.js.map +1 -0
- package/dist/retrieval-GLAEYWGA.js +13 -0
- package/dist/retrieval-GLAEYWGA.js.map +1 -0
- package/dist/store-2BPQPOOZ.js +31 -0
- package/dist/store-2BPQPOOZ.js.map +1 -0
- package/dist/{tasks-KHLJT7MP.js → tasks-6J3LULYO.js} +6 -3
- package/dist/tasks-6J3LULYO.js.map +1 -0
- package/dist/{usage-DU4TKVJH.js → usage-YBS74UEU.js} +8 -4
- package/dist/{usage-DU4TKVJH.js.map → usage-YBS74UEU.js.map} +1 -1
- package/dist/webui/assets/index-BJt1Lf-q.css +1 -0
- package/dist/webui/assets/index-Bfhwll2B.js +5224 -0
- package/dist/webui/assets/index-Bfhwll2B.js.map +1 -0
- package/dist/webui/index.html +15 -0
- package/dist/webui/recall-icon.png +0 -0
- package/drizzle/0008_premium_red_hulk.sql +44 -0
- package/drizzle/meta/0008_snapshot.json +2491 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +8 -3
- package/dist/chunk-A6XEULA4.js +0 -470
- package/dist/chunk-A6XEULA4.js.map +0 -1
- package/dist/chunk-AJAAK4FK.js.map +0 -1
- package/dist/chunk-DSNYEUZW.js +0 -2993
- package/dist/chunk-DSNYEUZW.js.map +0 -1
- package/dist/chunk-LFWG3CBM.js.map +0 -1
- /package/dist/{cleanup-JM3CGHUV.js.map → cleanup-YGHZIYLJ.js.map} +0 -0
- /package/dist/{dispatcher-C5S7SYY6.js.map → dispatcher-5MDL3QQT.js.map} +0 -0
- /package/dist/{quality-YTQKAEY6.js.map → embeddings-GKNH2E3N.js.map} +0 -0
- /package/dist/{tasks-KHLJT7MP.js.map → ingest-JWXX22QX.js.map} +0 -0
package/README.md
CHANGED
|
@@ -11,6 +11,46 @@ Recall is a local repo-memory compiler for coding agents. It learns from correct
|
|
|
11
11
|
- Website: <https://recallmemory.dev/>
|
|
12
12
|
- Releases: <https://github.com/edihasaj/recall/releases>
|
|
13
13
|
- Contributing: [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
14
|
+
- Comparison vs other memory systems: [`benchmark/COMPARISON.md`](benchmark/COMPARISON.md)
|
|
15
|
+
|
|
16
|
+
## Why Recall?
|
|
17
|
+
|
|
18
|
+
You correct your agent. Next session it forgets. You correct it again. Recall captures the *durable rules* hidden in those corrections — once — and re-injects them every session via lifecycle hooks. Local-first, no cloud, no API keys required for the common path.
|
|
19
|
+
|
|
20
|
+
The story in 3 lines:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
recall correct -r owner/repo "don't use npm, use pnpm" # one correction
|
|
24
|
+
# next session start:
|
|
25
|
+
# → SessionStart hook fires, injects: "- use pnpm as the package manager"
|
|
26
|
+
# → your agent never reaches for npm again
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Web Dashboard
|
|
30
|
+
|
|
31
|
+
The bundled web dashboard (open via the menu bar item *Open Dashboard in Browser*, or `recall webui start`) is the fastest way to see what Recall has learned: memories, the knowledge graph, recent activity, and live sessions across every agent that hits the daemon.
|
|
32
|
+
|
|
33
|
+

|
|
34
|
+
|
|
35
|
+
| Knowledge graph | Timeline | Sessions |
|
|
36
|
+
| --- | --- | --- |
|
|
37
|
+
|  |  |  |
|
|
38
|
+
|
|
39
|
+
- **Graph** — 2D layered view by entity kind plus a 3D force layout (toggle in the toolbar). Repo + kind dropdowns and a contains-match name search filter the visible set; click a node to drill into linked memories and neighbours.
|
|
40
|
+
- **Timeline** — filterable feed of every daemon event (compile, query, scan, correction, feedback, tool calls…). Click a row to expand the full request/result JSON; jump straight to the linked memories or pivot into the session view.
|
|
41
|
+
- **Sessions** — every distinct session Recall has seen across MCP, hooks, and CLI traffic, with duration, event count, and type breakdown. Expand a session to see its events inline or hand it off to the Timeline filtered by `session_id`.
|
|
42
|
+
|
|
43
|
+
## Benchmarks — Recall vs agentmemory
|
|
44
|
+
|
|
45
|
+
LongMemEval-S, N=500 non-abstention. Same dataset agentmemory publishes.
|
|
46
|
+
|
|
47
|
+
| System | R@5 | R@10 | R@20 | NDCG@10 | MRR |
|
|
48
|
+
|---|---|---|---|---|---|
|
|
49
|
+
| agentmemory BM25 + vector | 95.2 % | **98.6 %** | 99.4 % | 87.9 | **88.2** |
|
|
50
|
+
| Recall — same model (all-MiniLM-L6-v2) | **96.6 %** | 97.6 % | **99.8 %** | 87.0 | 86.8 |
|
|
51
|
+
| **Recall shipped (multilingual-e5-small)** | **97.4 %** | **99.4 %** | **99.6 %** | **90.1** | **89.5** |
|
|
52
|
+
|
|
53
|
+
The MiniLM row isolates the system contribution (same embedding model agentmemory uses); the e5 row is what Recall actually ships with. Full numbers, per-type breakdown, ablation, methodology → [`benchmark/COMPARISON.md`](benchmark/COMPARISON.md).
|
|
14
54
|
|
|
15
55
|
## Install
|
|
16
56
|
|
|
@@ -22,6 +62,14 @@ recall setup --yes
|
|
|
22
62
|
recall doctor
|
|
23
63
|
```
|
|
24
64
|
|
|
65
|
+
### Bash one-liner (macOS, Linux)
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
curl -fsSL https://recallmemory.dev/install.sh | bash
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Runs `npm i -g @edihasaj/recall` + `recall setup --yes` for you, then prints next steps for the optional background service.
|
|
72
|
+
|
|
25
73
|
### npm (macOS, Linux)
|
|
26
74
|
|
|
27
75
|
```bash
|
|
@@ -34,6 +82,14 @@ recall daemon install # launchd on macOS, systemd --user on Linux
|
|
|
34
82
|
|
|
35
83
|
On Linux, `recall daemon install` writes `~/.config/systemd/user/recall-daemon.service` and enables it. Logs: `journalctl --user -u recall-daemon`.
|
|
36
84
|
|
|
85
|
+
### PowerShell (Windows)
|
|
86
|
+
|
|
87
|
+
```powershell
|
|
88
|
+
irm https://recallmemory.dev/install.ps1 | iex
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Installs the `@edihasaj/recall` CLI via npm, downloads the system-tray companion (`recall-tray-<arch>.exe`) into `%LOCALAPPDATA%\Programs\Recall`, registers a per-user Run-key entry for autostart, and launches the tray. Supports `arm64` and `amd64`. Logs land in `%LOCALAPPDATA%\Recall\`.
|
|
92
|
+
|
|
37
93
|
### GitHub Releases
|
|
38
94
|
|
|
39
95
|
Download `Recall.app.zip` from [the latest release](https://github.com/edihasaj/recall/releases/latest), unzip it, move `Recall.app` into `/Applications`, then run setup:
|
|
@@ -224,7 +280,7 @@ Start HTTP daemon:
|
|
|
224
280
|
node dist/daemon.js
|
|
225
281
|
```
|
|
226
282
|
|
|
227
|
-
Install as a user service (launchd on macOS, `systemd --user` on Linux):
|
|
283
|
+
Install as a user service (launchd on macOS, `systemd --user` on Linux; on Windows the tray app supervises the daemon — see the PowerShell installer above):
|
|
228
284
|
|
|
229
285
|
```bash
|
|
230
286
|
recall daemon install
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sql
|
|
3
|
+
} from "./chunk-QDA5M3AJ.js";
|
|
4
|
+
|
|
5
|
+
// node_modules/drizzle-orm/sql/expressions/select.js
|
|
6
|
+
function asc(column) {
|
|
7
|
+
return sql`${column} asc`;
|
|
8
|
+
}
|
|
9
|
+
function desc(column) {
|
|
10
|
+
return sql`${column} desc`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
asc,
|
|
15
|
+
desc
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=chunk-37K4DPRI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../node_modules/src/sql/expressions/select.ts"],"sourcesContent":["import type { AnyColumn } from '../../column.ts';\nimport type { SQL, SQLWrapper } from '../sql.ts';\nimport { sql } from '../sql.ts';\n\n/**\n * Used in sorting, this specifies that the given\n * column or expression should be sorted in ascending\n * order. By the SQL standard, ascending order is the\n * default, so it is not usually necessary to specify\n * ascending sort order.\n *\n * ## Examples\n *\n * ```ts\n * // Return cars, starting with the oldest models\n * // and going in ascending order to the newest.\n * db.select().from(cars)\n * .orderBy(asc(cars.year));\n * ```\n *\n * @see desc to sort in descending order\n */\nexport function asc(column: AnyColumn | SQLWrapper): SQL {\n\treturn sql`${column} asc`;\n}\n\n/**\n * Used in sorting, this specifies that the given\n * column or expression should be sorted in descending\n * order.\n *\n * ## Examples\n *\n * ```ts\n * // Select users, with the most recently created\n * // records coming first.\n * db.select().from(users)\n * .orderBy(desc(users.createdAt));\n * ```\n *\n * @see asc to sort in ascending order\n */\nexport function desc(column: AnyColumn | SQLWrapper): SQL {\n\treturn sql`${column} desc`;\n}\n"],"mappings":";;;;;AAsBO,SAAS,IAAI,QAAqC;AACxD,SAAO,MAAM,MAAM;AACpB;AAkBO,SAAS,KAAK,QAAqC;AACzD,SAAO,MAAM,MAAM;AACpB;","names":[]}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import {
|
|
2
|
+
listEntitiesForMemory,
|
|
3
|
+
listMemoryIdsForEntity,
|
|
4
|
+
neighborsOf
|
|
5
|
+
} from "./chunk-Z6RT5BUO.js";
|
|
6
|
+
import {
|
|
7
|
+
getMemory
|
|
8
|
+
} from "./chunk-UBPGOOAN.js";
|
|
9
|
+
import {
|
|
10
|
+
hybridSearch,
|
|
11
|
+
searchMemoryFtsIndex
|
|
12
|
+
} from "./chunk-JRIM7VBY.js";
|
|
13
|
+
|
|
14
|
+
// src/graph/retrieval.ts
|
|
15
|
+
var SEED_WEIGHT = 1;
|
|
16
|
+
var GRAPH_WEIGHT = 0.6;
|
|
17
|
+
var ENTITY_OVERLAP_BONUS = 0.15;
|
|
18
|
+
var HOP_DECAY = 0.55;
|
|
19
|
+
async function graphQuery(db, query, embeddingConfig, options = {}) {
|
|
20
|
+
const seedLimit = options.seedLimit ?? 10;
|
|
21
|
+
const hops = Math.max(0, Math.min(4, options.hops ?? 2));
|
|
22
|
+
const limit = options.limit ?? 15;
|
|
23
|
+
let seedHits;
|
|
24
|
+
if (embeddingConfig) {
|
|
25
|
+
const hybrid = await hybridSearch(db, query, embeddingConfig, {
|
|
26
|
+
repo: options.repo,
|
|
27
|
+
limit: seedLimit
|
|
28
|
+
});
|
|
29
|
+
seedHits = hybrid.map((h) => ({ memory: h.memory, score: h.score }));
|
|
30
|
+
} else {
|
|
31
|
+
const fts = searchMemoryFtsIndex(db, query, {
|
|
32
|
+
repo: options.repo,
|
|
33
|
+
limit: seedLimit
|
|
34
|
+
});
|
|
35
|
+
seedHits = fts.map((row, i) => {
|
|
36
|
+
const mem = getMemory(db, row.memory_id);
|
|
37
|
+
if (!mem) return null;
|
|
38
|
+
const score = 1 / (1 + Math.abs(row.lexical_rank) + i);
|
|
39
|
+
return { memory: mem, score };
|
|
40
|
+
}).filter((x) => x !== null);
|
|
41
|
+
}
|
|
42
|
+
const entityMap = /* @__PURE__ */ new Map();
|
|
43
|
+
const seedEntityIds = /* @__PURE__ */ new Set();
|
|
44
|
+
for (const seed of seedHits) {
|
|
45
|
+
const ents = listEntitiesForMemory(db, seed.memory.id);
|
|
46
|
+
for (const e of ents) {
|
|
47
|
+
entityMap.set(e.id, e);
|
|
48
|
+
seedEntityIds.add(e.id);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const expandedEntityIds = new Set(seedEntityIds);
|
|
52
|
+
const entityHopDistance = /* @__PURE__ */ new Map();
|
|
53
|
+
for (const id of seedEntityIds) entityHopDistance.set(id, 0);
|
|
54
|
+
if (hops > 0 && seedEntityIds.size > 0) {
|
|
55
|
+
for (const seedId of seedEntityIds) {
|
|
56
|
+
const walk = neighborsOf(db, seedId, {
|
|
57
|
+
hops,
|
|
58
|
+
relationTypes: options.relationTypes
|
|
59
|
+
});
|
|
60
|
+
for (const ent of walk.entities) {
|
|
61
|
+
entityMap.set(ent.id, ent);
|
|
62
|
+
if (!expandedEntityIds.has(ent.id)) {
|
|
63
|
+
expandedEntityIds.add(ent.id);
|
|
64
|
+
entityHopDistance.set(ent.id, 1);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const hits = /* @__PURE__ */ new Map();
|
|
70
|
+
for (const seed of seedHits) {
|
|
71
|
+
const ents = listEntitiesForMemory(db, seed.memory.id);
|
|
72
|
+
hits.set(seed.memory.id, {
|
|
73
|
+
memory: seed.memory,
|
|
74
|
+
via: "seed",
|
|
75
|
+
score: seed.score * SEED_WEIGHT,
|
|
76
|
+
hops: 0,
|
|
77
|
+
shared_entities: ents
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
if (hops > 0) {
|
|
81
|
+
for (const entId of expandedEntityIds) {
|
|
82
|
+
const hop = entityHopDistance.get(entId) ?? 1;
|
|
83
|
+
const ent = entityMap.get(entId);
|
|
84
|
+
if (!ent) continue;
|
|
85
|
+
const decay = Math.pow(HOP_DECAY, hop);
|
|
86
|
+
const memIds = listMemoryIdsForEntity(db, entId);
|
|
87
|
+
for (const memId of memIds) {
|
|
88
|
+
const existing = hits.get(memId);
|
|
89
|
+
if (existing) {
|
|
90
|
+
if (!existing.shared_entities.find((e) => e.id === entId)) {
|
|
91
|
+
existing.shared_entities.push(ent);
|
|
92
|
+
existing.score += ENTITY_OVERLAP_BONUS * decay;
|
|
93
|
+
}
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const mem = getMemory(db, memId);
|
|
97
|
+
if (!mem) continue;
|
|
98
|
+
if (options.repo && mem.repo && mem.repo !== options.repo) continue;
|
|
99
|
+
hits.set(memId, {
|
|
100
|
+
memory: mem,
|
|
101
|
+
via: "graph",
|
|
102
|
+
score: GRAPH_WEIGHT * decay,
|
|
103
|
+
hops: hop,
|
|
104
|
+
shared_entities: [ent]
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const sorted = Array.from(hits.values()).sort((a, b) => b.score - a.score).slice(0, limit);
|
|
110
|
+
const entitiesOut = {};
|
|
111
|
+
for (const [id, row] of entityMap) entitiesOut[id] = row;
|
|
112
|
+
return {
|
|
113
|
+
hits: sorted,
|
|
114
|
+
seed_count: seedHits.length,
|
|
115
|
+
expanded_entities: expandedEntityIds.size,
|
|
116
|
+
entities: entitiesOut
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export {
|
|
121
|
+
graphQuery
|
|
122
|
+
};
|
|
123
|
+
//# sourceMappingURL=chunk-AKODTKWM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/graph/retrieval.ts"],"sourcesContent":["/**\n * Graph-aware retrieval. Pipeline:\n * 1. Seed: run the existing hybrid (FTS + vector) search to get the\n * most-relevant memories for the query.\n * 2. Pivot: collect the entities those seed memories mention.\n * 3. Expand: walk the entity graph N hops. Each new memory mentioned\n * by an expanded entity becomes a candidate.\n * 4. Re-rank: combine seed score + graph distance + entity overlap.\n *\n * This is what makes a question like \"how does the api handle session\n * expiry\" surface memories that don't textually match \"expiry\" but mention\n * `jose` or `auth-middleware.ts`, which the seed memory connected to.\n */\nimport { hybridSearch } from \"../embeddings/embeddings.js\";\nimport { searchMemoryFtsIndex } from \"../vector/sqlite-fts.js\";\nimport type { RecallDb } from \"../db/client.js\";\nimport type { EmbeddingConfig, MemoryItem } from \"../types.js\";\nimport { getMemory } from \"../models/memory.js\";\nimport {\n listEntitiesForMemory,\n listMemoryIdsForEntity,\n neighborsOf,\n type EntityRow,\n type RelationType,\n} from \"./store.js\";\n\nexport interface GraphRetrievalOptions {\n repo?: string;\n /** Initial seed pool (FTS/hybrid). */\n seedLimit?: number;\n /** Max graph hops from each seed entity. */\n hops?: number;\n /** Final result cap. */\n limit?: number;\n /** Restrict graph walk to specific relation types (optional). */\n relationTypes?: RelationType[];\n}\n\nexport interface GraphRetrievalHit {\n memory: MemoryItem;\n /** 'seed' if surfaced by hybrid, 'graph' if added by graph expansion. */\n via: \"seed\" | \"graph\";\n /** Final blended score (0..~2). */\n score: number;\n /** Hops from a seed entity (0 for seed memories). */\n hops: number;\n /** Entities of this memory that the query also touches via the graph. */\n shared_entities: EntityRow[];\n}\n\nexport interface GraphRetrievalResult {\n hits: GraphRetrievalHit[];\n seed_count: number;\n expanded_entities: number;\n /** Map of entity id → entity row, for callers that want to render a graph. */\n entities: Record<string, EntityRow>;\n}\n\nconst SEED_WEIGHT = 1.0;\nconst GRAPH_WEIGHT = 0.6;\nconst ENTITY_OVERLAP_BONUS = 0.15;\nconst HOP_DECAY = 0.55;\n\n/**\n * Hybrid + graph retrieval. Always returns at least the hybrid seeds (so\n * callers can swap a plain hybrid call with this one without surprises).\n */\nexport async function graphQuery(\n db: RecallDb,\n query: string,\n embeddingConfig: EmbeddingConfig | null,\n options: GraphRetrievalOptions = {},\n): Promise<GraphRetrievalResult> {\n const seedLimit = options.seedLimit ?? 10;\n const hops = Math.max(0, Math.min(4, options.hops ?? 2));\n const limit = options.limit ?? 15;\n\n // --- Step 1: seeds via hybrid (falls back to FTS-only when no embedder) ---\n let seedHits: Array<{ memory: MemoryItem; score: number }>;\n if (embeddingConfig) {\n const hybrid = await hybridSearch(db, query, embeddingConfig, {\n repo: options.repo,\n limit: seedLimit,\n });\n seedHits = hybrid.map((h) => ({ memory: h.memory, score: h.score }));\n } else {\n const fts = searchMemoryFtsIndex(db, query, {\n repo: options.repo,\n limit: seedLimit,\n });\n seedHits = fts\n .map((row, i) => {\n const mem = getMemory(db, row.memory_id);\n if (!mem) return null;\n const score = 1 / (1 + Math.abs(row.lexical_rank) + i);\n return { memory: mem, score };\n })\n .filter((x): x is { memory: MemoryItem; score: number } => x !== null);\n }\n\n // --- Step 2: collect seed entities ---\n const entityMap = new Map<string, EntityRow>();\n const seedEntityIds = new Set<string>();\n for (const seed of seedHits) {\n const ents = listEntitiesForMemory(db, seed.memory.id);\n for (const e of ents) {\n entityMap.set(e.id, e);\n seedEntityIds.add(e.id);\n }\n }\n\n // --- Step 3: expand graph ---\n const expandedEntityIds = new Set<string>(seedEntityIds);\n const entityHopDistance = new Map<string, number>();\n for (const id of seedEntityIds) entityHopDistance.set(id, 0);\n\n if (hops > 0 && seedEntityIds.size > 0) {\n for (const seedId of seedEntityIds) {\n const walk = neighborsOf(db, seedId, {\n hops,\n relationTypes: options.relationTypes,\n });\n for (const ent of walk.entities) {\n entityMap.set(ent.id, ent);\n if (!expandedEntityIds.has(ent.id)) {\n expandedEntityIds.add(ent.id);\n // Approximate hop distance via shortest seen so far. We don't\n // track exact BFS layers per pair (cheaper to over-estimate),\n // so use 1 as the floor for any non-seed entity. Anything deeper\n // gets a softer multiplier through HOP_DECAY ^ hops.\n entityHopDistance.set(ent.id, 1);\n }\n }\n }\n }\n\n // --- Step 4: collect candidate memories ---\n // For every expanded entity, pull its memories. Seeds are already in\n // there; we'll blend graph and seed scores.\n const hits = new Map<string, GraphRetrievalHit>();\n\n for (const seed of seedHits) {\n const ents = listEntitiesForMemory(db, seed.memory.id);\n hits.set(seed.memory.id, {\n memory: seed.memory,\n via: \"seed\",\n score: seed.score * SEED_WEIGHT,\n hops: 0,\n shared_entities: ents,\n });\n }\n\n // Only pull memories from the graph when hops > 0. At hops=0 the\n // caller wants \"seeds only\" — the entity map is still returned for\n // visualisation, but we don't expand into other memories.\n if (hops > 0) {\n for (const entId of expandedEntityIds) {\n const hop = entityHopDistance.get(entId) ?? 1;\n const ent = entityMap.get(entId);\n if (!ent) continue;\n const decay = Math.pow(HOP_DECAY, hop);\n\n const memIds = listMemoryIdsForEntity(db, entId);\n for (const memId of memIds) {\n const existing = hits.get(memId);\n if (existing) {\n // Memory already in hits — bump score with graph overlap bonus.\n // Avoid double-counting the *same* entity twice.\n if (!existing.shared_entities.find((e) => e.id === entId)) {\n existing.shared_entities.push(ent);\n existing.score += ENTITY_OVERLAP_BONUS * decay;\n }\n continue;\n }\n const mem = getMemory(db, memId);\n if (!mem) continue;\n if (options.repo && mem.repo && mem.repo !== options.repo) continue;\n hits.set(memId, {\n memory: mem,\n via: \"graph\",\n score: GRAPH_WEIGHT * decay,\n hops: hop,\n shared_entities: [ent],\n });\n }\n }\n }\n\n const sorted = Array.from(hits.values())\n .sort((a, b) => b.score - a.score)\n .slice(0, limit);\n\n const entitiesOut: Record<string, EntityRow> = {};\n for (const [id, row] of entityMap) entitiesOut[id] = row;\n\n return {\n hits: sorted,\n seed_count: seedHits.length,\n expanded_entities: expandedEntityIds.size,\n entities: entitiesOut,\n };\n}\n"],"mappings":"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","names":[]}
|
|
@@ -15,20 +15,30 @@ import {
|
|
|
15
15
|
signalOutcomeFallback,
|
|
16
16
|
startSessionLifecycle,
|
|
17
17
|
toolCallTouchesMemory
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-PG2ZVVAT.js";
|
|
19
19
|
import {
|
|
20
20
|
detectCorrections,
|
|
21
|
-
hookCallDedupeKey,
|
|
22
21
|
isHighRiskRule,
|
|
23
22
|
isTriggerTemplateRule,
|
|
24
23
|
peekTasks,
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
redactSensitiveText
|
|
25
|
+
} from "./chunk-PH6YNVHR.js";
|
|
26
|
+
import {
|
|
27
|
+
hookCallDedupeKey,
|
|
28
|
+
queryMemories
|
|
29
|
+
} from "./chunk-UBPGOOAN.js";
|
|
30
|
+
import {
|
|
31
|
+
desc
|
|
32
|
+
} from "./chunk-37K4DPRI.js";
|
|
33
|
+
import {
|
|
27
34
|
tagActivitySource
|
|
28
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-JRIM7VBY.js";
|
|
29
36
|
import {
|
|
30
|
-
|
|
31
|
-
|
|
37
|
+
and,
|
|
38
|
+
eq,
|
|
39
|
+
hookCalls,
|
|
40
|
+
sql
|
|
41
|
+
} from "./chunk-QDA5M3AJ.js";
|
|
32
42
|
|
|
33
43
|
// src/backups/snapshot.ts
|
|
34
44
|
import { copyFileSync, existsSync, mkdirSync, readdirSync, rmSync, statSync } from "fs";
|
|
@@ -95,7 +105,6 @@ function restoreBackup(date, options = {}) {
|
|
|
95
105
|
}
|
|
96
106
|
|
|
97
107
|
// src/hooks/calls.ts
|
|
98
|
-
import { and, desc, eq, sql } from "drizzle-orm";
|
|
99
108
|
import { randomUUID } from "crypto";
|
|
100
109
|
function recordHookCall(db, input) {
|
|
101
110
|
if (input.dedupe_key) {
|
|
@@ -978,4 +987,4 @@ export {
|
|
|
978
987
|
readCodexSessionEndInputFromStdin,
|
|
979
988
|
dispatchCodexNotify
|
|
980
989
|
};
|
|
981
|
-
//# sourceMappingURL=chunk-
|
|
990
|
+
//# sourceMappingURL=chunk-CPOANMKD.js.map
|