feat(context): add recall fusion and zvec workspace adapters

Introduce RRF-based recall fusion for personal/episodic/temporal paths,
zvec-grep workspace shadow probing for code executors, and a local
headroom proxy starter aligned with the fusion plan defaults.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-09-09 21:28:04 +08:00
parent 49a1a68a29
commit 40e4a527fe
11 changed files with 677 additions and 1 deletions
@@ -1,6 +1,11 @@
import { getActiveSnapshot } from '../user-model-service/snapshot.mjs';
import { createUmsPool, isUmsDatabaseConfigured } from '../user-model-service/db.mjs';
import { resolveCanonicalUserId } from '../user-model-service/canonical-user.mjs';
import {
buildRecallFusionResolvedEvent,
fuseRecallCandidates,
resolveRecallFusionMode,
} from '../recall-fusion.mjs';
import { buildContextPlan } from './context-planner.mjs';
import { queryTemporalRecall } from './recall.mjs';
@@ -164,12 +169,30 @@ export async function resolveRuntimeContext(input) {
}
}
let recallFusion = null;
if (resolveRecallFusionMode() !== 'off' && temporalRecall) {
const temporalItems = [
...(Array.isArray(temporalRecall.items) ? temporalRecall.items : []),
...(Array.isArray(temporalRecall.groups)
? temporalRecall.groups.flatMap((group) => group.items ?? [])
: []),
];
if (temporalItems.length > 0) {
recallFusion = buildRecallFusionResolvedEvent(fuseRecallCandidates({
query,
temporalItems,
limit: plan.output?.max_items ?? 20,
}));
}
}
const injectionEnabled = Boolean(blocks.temporal || blocks.snapshot);
return {
enabled: true,
plan,
temporalRecall,
userSnapshot,
recallFusion,
injectionEnabled,
blocks,
injectionText: [blocks.snapshot, blocks.temporal].filter(Boolean).join('\n\n'),