@remnic/core 9.3.602 → 9.3.604
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/dist/access-cli.js +3 -3
- package/dist/{chunk-75O6YQ63.js → chunk-G6R5UD3Q.js} +10 -3
- package/dist/chunk-G6R5UD3Q.js.map +1 -0
- package/dist/{chunk-5SQ5CQJP.js → chunk-HSVJGWYS.js} +2 -2
- package/dist/{chunk-MTGOAU7A.js → chunk-OEIRQ7DB.js} +332 -296
- package/dist/chunk-OEIRQ7DB.js.map +1 -0
- package/dist/index.js +3 -3
- package/dist/orchestrator.js +3 -3
- package/dist/retrieval-agents.js +2 -2
- package/dist/schemas.d.ts +22 -22
- package/dist/temporal-index.js +1 -1
- package/dist/transfer/types.d.ts +12 -12
- package/package.json +1 -1
- package/src/orchestrator.ts +51 -8
- package/src/temporal-index.test.ts +30 -1
- package/src/temporal-index.ts +10 -3
- package/dist/chunk-75O6YQ63.js.map +0 -1
- package/dist/chunk-MTGOAU7A.js.map +0 -1
- /package/dist/{chunk-5SQ5CQJP.js.map → chunk-HSVJGWYS.js.map} +0 -0
|
@@ -70,7 +70,7 @@ import {
|
|
|
70
70
|
runDirectAgent,
|
|
71
71
|
runTemporalAgent,
|
|
72
72
|
shouldRunAgent
|
|
73
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-HSVJGWYS.js";
|
|
74
74
|
import {
|
|
75
75
|
clearIndexes,
|
|
76
76
|
deindexMemory,
|
|
@@ -82,7 +82,7 @@ import {
|
|
|
82
82
|
queryByTagsAsync,
|
|
83
83
|
recencyWindowFromPrompt,
|
|
84
84
|
resolvePromptTagPrefilterAsync
|
|
85
|
-
} from "./chunk-
|
|
85
|
+
} from "./chunk-G6R5UD3Q.js";
|
|
86
86
|
import {
|
|
87
87
|
applyRuntimeRetrievalPolicy
|
|
88
88
|
} from "./chunk-5IZL4DCV.js";
|
|
@@ -1214,7 +1214,8 @@ function filterRecallCandidates(candidates, options) {
|
|
|
1214
1214
|
return scopedByNamespace.filter((r) => !isArtifactMemoryPath(r.path)).slice(0, Math.max(0, options.limit));
|
|
1215
1215
|
}
|
|
1216
1216
|
function applyQueryAwareCandidateFilter(candidates, candidatePaths) {
|
|
1217
|
-
if (!candidatePaths
|
|
1217
|
+
if (!candidatePaths) return candidates;
|
|
1218
|
+
if (candidatePaths.size === 0) return [];
|
|
1218
1219
|
const filtered = candidates.filter(
|
|
1219
1220
|
(candidate) => candidatePaths.has(candidate.path)
|
|
1220
1221
|
);
|
|
@@ -4341,7 +4342,7 @@ ${r.snippet.trim()}
|
|
|
4341
4342
|
return mergeArtifactRecallCandidates(filteredByNamespace, targetCount);
|
|
4342
4343
|
}
|
|
4343
4344
|
scopeQueryAwarePaths(paths, recallNamespaces) {
|
|
4344
|
-
if (!paths
|
|
4345
|
+
if (!paths) return null;
|
|
4345
4346
|
const scoped = /* @__PURE__ */ new Set();
|
|
4346
4347
|
for (const memoryPath of paths) {
|
|
4347
4348
|
if (!memoryPath || isArtifactMemoryPath(memoryPath)) continue;
|
|
@@ -4350,7 +4351,7 @@ ${r.snippet.trim()}
|
|
|
4350
4351
|
}
|
|
4351
4352
|
scoped.add(memoryPath);
|
|
4352
4353
|
}
|
|
4353
|
-
return scoped
|
|
4354
|
+
return scoped;
|
|
4354
4355
|
}
|
|
4355
4356
|
async buildQueryAwarePrefilter(prompt, recallNamespaces) {
|
|
4356
4357
|
if (!this.config.queryAwareIndexingEnabled || !prompt.trim()) {
|
|
@@ -4386,7 +4387,10 @@ ${r.snippet.trim()}
|
|
|
4386
4387
|
let candidatePaths = null;
|
|
4387
4388
|
let combination = "none";
|
|
4388
4389
|
let filteredToFullSearch = false;
|
|
4389
|
-
if (
|
|
4390
|
+
if (tagSignals.matchedTags.length > 0 && tagCandidates !== null && tagCandidates.size === 0) {
|
|
4391
|
+
candidatePaths = tagCandidates;
|
|
4392
|
+
combination = "tag";
|
|
4393
|
+
} else if (temporalCandidates !== null && tagCandidates !== null) {
|
|
4390
4394
|
const intersection = new Set(
|
|
4391
4395
|
Array.from(temporalCandidates).filter(
|
|
4392
4396
|
(memoryPath) => tagCandidates.has(memoryPath)
|
|
@@ -4399,10 +4403,10 @@ ${r.snippet.trim()}
|
|
|
4399
4403
|
candidatePaths = /* @__PURE__ */ new Set([...temporalCandidates, ...tagCandidates]);
|
|
4400
4404
|
combination = "union";
|
|
4401
4405
|
}
|
|
4402
|
-
} else if (temporalCandidates) {
|
|
4406
|
+
} else if (temporalCandidates !== null) {
|
|
4403
4407
|
candidatePaths = temporalCandidates;
|
|
4404
4408
|
combination = "temporal";
|
|
4405
|
-
} else if (tagCandidates) {
|
|
4409
|
+
} else if (tagCandidates !== null) {
|
|
4406
4410
|
candidatePaths = tagCandidates;
|
|
4407
4411
|
combination = "tag";
|
|
4408
4412
|
}
|
|
@@ -4516,6 +4520,10 @@ ${r.snippet.trim()}
|
|
|
4516
4520
|
}))
|
|
4517
4521
|
});
|
|
4518
4522
|
};
|
|
4523
|
+
if (queryAwarePrefilter.candidatePaths?.size === 0) {
|
|
4524
|
+
await emitDebugSnapshot([], fetchLimit);
|
|
4525
|
+
return [];
|
|
4526
|
+
}
|
|
4519
4527
|
for (let attempt = 0; attempt < MAX_ATTEMPTS; attempt += 1) {
|
|
4520
4528
|
throwIfRecallAborted(options.abortSignal);
|
|
4521
4529
|
if (qmdRecallBudgetEnabled && Date.now() - startedAtMs >= qmdRecallBudgetMs) {
|
|
@@ -6215,6 +6223,14 @@ ${lines.join("\n\n")}`;
|
|
|
6215
6223
|
}
|
|
6216
6224
|
);
|
|
6217
6225
|
const staleQmdFallback = cachedQmd?.source === "stale" ? cachedQmd : null;
|
|
6226
|
+
const queryAwarePrefilter = await queryAwarePrefilterPromise;
|
|
6227
|
+
const queryAwarePrefilterIsEmpty = queryAwarePrefilter.candidatePaths?.size === 0;
|
|
6228
|
+
const emptyQueryAwareQmdResult = {
|
|
6229
|
+
memoryResultsLists: [[]],
|
|
6230
|
+
globalResults: [],
|
|
6231
|
+
preAugmentTopScore: 0,
|
|
6232
|
+
maxSpecializedScore: 0
|
|
6233
|
+
};
|
|
6218
6234
|
if (cachedQmd?.source === "fresh") {
|
|
6219
6235
|
recordRecallSectionMetric({
|
|
6220
6236
|
section: "qmd",
|
|
@@ -6225,6 +6241,9 @@ ${lines.join("\n\n")}`;
|
|
|
6225
6241
|
success: true,
|
|
6226
6242
|
timing: `${Math.max(0, Math.round(cachedQmd.ageMs))}ms-cache`
|
|
6227
6243
|
});
|
|
6244
|
+
if (queryAwarePrefilterIsEmpty) {
|
|
6245
|
+
return emptyQueryAwareQmdResult;
|
|
6246
|
+
}
|
|
6228
6247
|
return cachedQmd.value;
|
|
6229
6248
|
}
|
|
6230
6249
|
if (!this.qmd.isAvailable()) {
|
|
@@ -6241,6 +6260,9 @@ ${lines.join("\n\n")}`;
|
|
|
6241
6260
|
success: true,
|
|
6242
6261
|
timing: `stale-cache(reprobe-cooldown:${Math.max(0, Math.round(staleQmdFallback.ageMs))}ms)`
|
|
6243
6262
|
});
|
|
6263
|
+
if (queryAwarePrefilterIsEmpty) {
|
|
6264
|
+
return emptyQueryAwareQmdResult;
|
|
6265
|
+
}
|
|
6244
6266
|
return staleQmdFallback.value;
|
|
6245
6267
|
}
|
|
6246
6268
|
recordRecallSectionMetric({
|
|
@@ -6267,6 +6289,9 @@ ${lines.join("\n\n")}`;
|
|
|
6267
6289
|
success: true,
|
|
6268
6290
|
timing: `stale-cache(reprobe-failed:${Math.max(0, Math.round(staleQmdFallback.ageMs))}ms)`
|
|
6269
6291
|
});
|
|
6292
|
+
if (queryAwarePrefilterIsEmpty) {
|
|
6293
|
+
return emptyQueryAwareQmdResult;
|
|
6294
|
+
}
|
|
6270
6295
|
return staleQmdFallback.value;
|
|
6271
6296
|
}
|
|
6272
6297
|
recordRecallSectionMetric({
|
|
@@ -6285,9 +6310,8 @@ ${lines.join("\n\n")}`;
|
|
|
6285
6310
|
}
|
|
6286
6311
|
log.info(`QMD re-probe succeeded: ${this.qmd.debugStatus()}`);
|
|
6287
6312
|
}
|
|
6288
|
-
const queryAwarePrefilter = await queryAwarePrefilterPromise;
|
|
6289
6313
|
const maxPerAgent = this.config.parallelMaxResultsPerAgent;
|
|
6290
|
-
const specializedAgentPromise = this.config.parallelRetrievalEnabled && maxPerAgent > 0 ? Promise.all([
|
|
6314
|
+
const specializedAgentPromise = !queryAwarePrefilterIsEmpty && this.config.parallelRetrievalEnabled && maxPerAgent > 0 ? Promise.all([
|
|
6291
6315
|
shouldRunAgent("direct", retrievalQuery, 0) ? runDirectAgent(
|
|
6292
6316
|
retrievalQuery,
|
|
6293
6317
|
profileStorage.dir,
|
|
@@ -6388,6 +6412,9 @@ ${lines.join("\n\n")}`;
|
|
|
6388
6412
|
success: true,
|
|
6389
6413
|
timing: `stale-cache(${err instanceof Error ? err.message : String(err)})`
|
|
6390
6414
|
});
|
|
6415
|
+
if (queryAwarePrefilterIsEmpty) {
|
|
6416
|
+
return emptyQueryAwareQmdResult;
|
|
6417
|
+
}
|
|
6391
6418
|
return staleQmdFallback.value;
|
|
6392
6419
|
}
|
|
6393
6420
|
throw err;
|
|
@@ -7489,89 +7516,53 @@ ${tmtNode.summary}`
|
|
|
7489
7516
|
impressionRecorded = true;
|
|
7490
7517
|
} else if (!confidenceGateRejected) {
|
|
7491
7518
|
const queryAwarePrefilter = await queryAwarePrefilterPromise;
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
embeddingFetchLimit
|
|
7495
|
-
);
|
|
7496
|
-
const prefilteredEmbeddingResults = applyQueryAwareCandidateFilter(
|
|
7497
|
-
embeddingResults,
|
|
7498
|
-
queryAwarePrefilter.candidatePaths
|
|
7499
|
-
);
|
|
7500
|
-
const scopedCandidates = filterRecallCandidates(
|
|
7501
|
-
prefilteredEmbeddingResults,
|
|
7502
|
-
{
|
|
7503
|
-
namespacesEnabled: this.config.namespacesEnabled,
|
|
7504
|
-
recallNamespaces,
|
|
7505
|
-
resolveNamespace: (p) => this.namespaceFromPath(p),
|
|
7506
|
-
limit: embeddingFetchLimit
|
|
7507
|
-
}
|
|
7508
|
-
);
|
|
7509
|
-
const boostedScoped = await this.boostSearchResults(
|
|
7510
|
-
scopedCandidates,
|
|
7511
|
-
recallNamespaces,
|
|
7512
|
-
retrievalQuery,
|
|
7513
|
-
void 0,
|
|
7514
|
-
{ asOfMs }
|
|
7515
|
-
);
|
|
7516
|
-
xrayBranchPoolSize.hot_embedding = Math.max(
|
|
7517
|
-
xrayBranchPoolSize.hot_embedding,
|
|
7518
|
-
boostedScoped.length
|
|
7519
|
-
);
|
|
7520
|
-
const scoped = this.diversifyAndLimitRecallResults(
|
|
7521
|
-
"memories",
|
|
7522
|
-
boostedScoped,
|
|
7523
|
-
recallResultLimit,
|
|
7524
|
-
retrievalQuery
|
|
7525
|
-
);
|
|
7526
|
-
if (scoped.length > 0) {
|
|
7527
|
-
if (shouldPersistGraphSnapshot) {
|
|
7528
|
-
graphSnapshotFinalResults = this.buildGraphRecallRankedResults(
|
|
7529
|
-
scoped,
|
|
7530
|
-
graphSourceLabelsForPath
|
|
7531
|
-
);
|
|
7532
|
-
}
|
|
7533
|
-
recallSource = "hot_embedding";
|
|
7534
|
-
recalledMemoryCount = scoped.length;
|
|
7535
|
-
this.publishRecallResults({
|
|
7536
|
-
title: "Relevant Memories",
|
|
7537
|
-
results: scoped,
|
|
7538
|
-
sectionBuckets,
|
|
7519
|
+
if (queryAwarePrefilter.candidatePaths?.size !== 0) {
|
|
7520
|
+
const embeddingResults = await this.searchEmbeddingFallback(
|
|
7539
7521
|
retrievalQuery,
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
|
|
7522
|
+
embeddingFetchLimit
|
|
7523
|
+
);
|
|
7524
|
+
const prefilteredEmbeddingResults = applyQueryAwareCandidateFilter(
|
|
7525
|
+
embeddingResults,
|
|
7526
|
+
queryAwarePrefilter.candidatePaths
|
|
7527
|
+
);
|
|
7528
|
+
const scopedCandidates = filterRecallCandidates(
|
|
7529
|
+
prefilteredEmbeddingResults,
|
|
7530
|
+
{
|
|
7531
|
+
namespacesEnabled: this.config.namespacesEnabled,
|
|
7532
|
+
recallNamespaces,
|
|
7533
|
+
resolveNamespace: (p) => this.namespaceFromPath(p),
|
|
7534
|
+
limit: embeddingFetchLimit
|
|
7545
7535
|
}
|
|
7546
|
-
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
xrayRecalledResults = scoped;
|
|
7550
|
-
impressionRecorded = true;
|
|
7551
|
-
} else {
|
|
7552
|
-
const longTerm = await this.applyColdFallbackPipeline({
|
|
7553
|
-
prompt: retrievalQuery,
|
|
7536
|
+
);
|
|
7537
|
+
const boostedScoped = await this.boostSearchResults(
|
|
7538
|
+
scopedCandidates,
|
|
7554
7539
|
recallNamespaces,
|
|
7540
|
+
retrievalQuery,
|
|
7541
|
+
void 0,
|
|
7542
|
+
{ asOfMs }
|
|
7543
|
+
);
|
|
7544
|
+
xrayBranchPoolSize.hot_embedding = Math.max(
|
|
7545
|
+
xrayBranchPoolSize.hot_embedding,
|
|
7546
|
+
boostedScoped.length
|
|
7547
|
+
);
|
|
7548
|
+
const scoped = this.diversifyAndLimitRecallResults(
|
|
7549
|
+
"memories",
|
|
7550
|
+
boostedScoped,
|
|
7555
7551
|
recallResultLimit,
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
xrayPoolSizeSink: xrayColdPoolSink,
|
|
7560
|
-
asOfMs,
|
|
7561
|
-
...options.includeLowConfidence === true ? { includeLowConfidence: true } : {}
|
|
7562
|
-
});
|
|
7563
|
-
if (longTerm.length > 0) {
|
|
7552
|
+
retrievalQuery
|
|
7553
|
+
);
|
|
7554
|
+
if (scoped.length > 0) {
|
|
7564
7555
|
if (shouldPersistGraphSnapshot) {
|
|
7565
7556
|
graphSnapshotFinalResults = this.buildGraphRecallRankedResults(
|
|
7566
|
-
|
|
7557
|
+
scoped,
|
|
7567
7558
|
graphSourceLabelsForPath
|
|
7568
7559
|
);
|
|
7569
7560
|
}
|
|
7570
|
-
recallSource = "
|
|
7571
|
-
recalledMemoryCount =
|
|
7561
|
+
recallSource = "hot_embedding";
|
|
7562
|
+
recalledMemoryCount = scoped.length;
|
|
7572
7563
|
this.publishRecallResults({
|
|
7573
|
-
title: "
|
|
7574
|
-
results:
|
|
7564
|
+
title: "Relevant Memories",
|
|
7565
|
+
results: scoped,
|
|
7575
7566
|
sectionBuckets,
|
|
7576
7567
|
retrievalQuery,
|
|
7577
7568
|
sessionKey,
|
|
@@ -7581,10 +7572,48 @@ ${tmtNode.summary}`
|
|
|
7581
7572
|
truncated: identityInjectionTruncated
|
|
7582
7573
|
}
|
|
7583
7574
|
});
|
|
7584
|
-
recalledMemoryIds = this.extractMemoryIdsFromResults(
|
|
7585
|
-
recalledMemoryPaths =
|
|
7586
|
-
xrayRecalledResults =
|
|
7575
|
+
recalledMemoryIds = this.extractMemoryIdsFromResults(scoped);
|
|
7576
|
+
recalledMemoryPaths = scoped.map((result) => result.path).filter(Boolean);
|
|
7577
|
+
xrayRecalledResults = scoped;
|
|
7587
7578
|
impressionRecorded = true;
|
|
7579
|
+
} else {
|
|
7580
|
+
const longTerm = await this.applyColdFallbackPipeline({
|
|
7581
|
+
prompt: retrievalQuery,
|
|
7582
|
+
recallNamespaces,
|
|
7583
|
+
recallResultLimit,
|
|
7584
|
+
recallMode,
|
|
7585
|
+
queryAwarePrefilter,
|
|
7586
|
+
abortSignal: options.abortSignal,
|
|
7587
|
+
xrayPoolSizeSink: xrayColdPoolSink,
|
|
7588
|
+
asOfMs,
|
|
7589
|
+
...options.includeLowConfidence === true ? { includeLowConfidence: true } : {}
|
|
7590
|
+
});
|
|
7591
|
+
if (longTerm.length > 0) {
|
|
7592
|
+
if (shouldPersistGraphSnapshot) {
|
|
7593
|
+
graphSnapshotFinalResults = this.buildGraphRecallRankedResults(
|
|
7594
|
+
longTerm,
|
|
7595
|
+
graphSourceLabelsForPath
|
|
7596
|
+
);
|
|
7597
|
+
}
|
|
7598
|
+
recallSource = "cold_fallback";
|
|
7599
|
+
recalledMemoryCount = longTerm.length;
|
|
7600
|
+
this.publishRecallResults({
|
|
7601
|
+
title: "Long-Term Memories (Fallback)",
|
|
7602
|
+
results: longTerm,
|
|
7603
|
+
sectionBuckets,
|
|
7604
|
+
retrievalQuery,
|
|
7605
|
+
sessionKey,
|
|
7606
|
+
identityInjection: {
|
|
7607
|
+
mode: identityInjectionModeUsed,
|
|
7608
|
+
injectedChars: identityInjectedChars,
|
|
7609
|
+
truncated: identityInjectionTruncated
|
|
7610
|
+
}
|
|
7611
|
+
});
|
|
7612
|
+
recalledMemoryIds = this.extractMemoryIdsFromResults(longTerm);
|
|
7613
|
+
recalledMemoryPaths = longTerm.map((result) => result.path).filter(Boolean);
|
|
7614
|
+
xrayRecalledResults = longTerm;
|
|
7615
|
+
impressionRecorded = true;
|
|
7616
|
+
}
|
|
7588
7617
|
}
|
|
7589
7618
|
}
|
|
7590
7619
|
}
|
|
@@ -7621,178 +7650,90 @@ ${tmtNode.summary}`
|
|
|
7621
7650
|
}
|
|
7622
7651
|
} else if (recallResultLimit > 0 && !this.qmd.isAvailable()) {
|
|
7623
7652
|
const queryAwarePrefilter = await queryAwarePrefilterPromise;
|
|
7624
|
-
|
|
7625
|
-
|
|
7626
|
-
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7653
|
+
if (queryAwarePrefilter.candidatePaths?.size !== 0) {
|
|
7654
|
+
const embeddingResults = await this.searchEmbeddingFallback(
|
|
7655
|
+
retrievalQuery,
|
|
7656
|
+
embeddingFetchLimit
|
|
7657
|
+
);
|
|
7658
|
+
const prefilteredEmbeddingResults = applyQueryAwareCandidateFilter(
|
|
7659
|
+
embeddingResults,
|
|
7660
|
+
queryAwarePrefilter.candidatePaths
|
|
7661
|
+
);
|
|
7662
|
+
const scopedCandidates = filterRecallCandidates(
|
|
7663
|
+
prefilteredEmbeddingResults,
|
|
7664
|
+
{
|
|
7665
|
+
namespacesEnabled: this.config.namespacesEnabled,
|
|
7666
|
+
recallNamespaces,
|
|
7667
|
+
resolveNamespace: (p) => this.namespaceFromPath(p),
|
|
7668
|
+
limit: embeddingFetchLimit
|
|
7669
|
+
}
|
|
7670
|
+
);
|
|
7671
|
+
const boostedScoped = await this.boostSearchResults(
|
|
7672
|
+
scopedCandidates,
|
|
7636
7673
|
recallNamespaces,
|
|
7637
|
-
resolveNamespace: (p) => this.namespaceFromPath(p),
|
|
7638
|
-
limit: embeddingFetchLimit
|
|
7639
|
-
}
|
|
7640
|
-
);
|
|
7641
|
-
const boostedScoped = await this.boostSearchResults(
|
|
7642
|
-
scopedCandidates,
|
|
7643
|
-
recallNamespaces,
|
|
7644
|
-
retrievalQuery,
|
|
7645
|
-
void 0,
|
|
7646
|
-
{ asOfMs }
|
|
7647
|
-
);
|
|
7648
|
-
xrayBranchPoolSize.hot_embedding = Math.max(
|
|
7649
|
-
xrayBranchPoolSize.hot_embedding,
|
|
7650
|
-
boostedScoped.length
|
|
7651
|
-
);
|
|
7652
|
-
const scoped = this.diversifyAndLimitRecallResults(
|
|
7653
|
-
"memories",
|
|
7654
|
-
boostedScoped,
|
|
7655
|
-
recallResultLimit,
|
|
7656
|
-
retrievalQuery
|
|
7657
|
-
);
|
|
7658
|
-
if (scoped.length > 0) {
|
|
7659
|
-
if (shouldPersistGraphSnapshot) {
|
|
7660
|
-
graphSnapshotFinalResults = this.buildGraphRecallRankedResults(
|
|
7661
|
-
scoped,
|
|
7662
|
-
graphSourceLabelsForPath
|
|
7663
|
-
);
|
|
7664
|
-
}
|
|
7665
|
-
recallSource = "hot_embedding";
|
|
7666
|
-
recalledMemoryCount = scoped.length;
|
|
7667
|
-
this.publishRecallResults({
|
|
7668
|
-
title: "Relevant Memories",
|
|
7669
|
-
results: scoped,
|
|
7670
|
-
sectionBuckets,
|
|
7671
7674
|
retrievalQuery,
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
|
|
7675
|
-
|
|
7676
|
-
|
|
7675
|
+
void 0,
|
|
7676
|
+
{ asOfMs }
|
|
7677
|
+
);
|
|
7678
|
+
xrayBranchPoolSize.hot_embedding = Math.max(
|
|
7679
|
+
xrayBranchPoolSize.hot_embedding,
|
|
7680
|
+
boostedScoped.length
|
|
7681
|
+
);
|
|
7682
|
+
const scoped = this.diversifyAndLimitRecallResults(
|
|
7683
|
+
"memories",
|
|
7684
|
+
boostedScoped,
|
|
7685
|
+
recallResultLimit,
|
|
7686
|
+
retrievalQuery
|
|
7687
|
+
);
|
|
7688
|
+
if (scoped.length > 0) {
|
|
7689
|
+
if (shouldPersistGraphSnapshot) {
|
|
7690
|
+
graphSnapshotFinalResults = this.buildGraphRecallRankedResults(
|
|
7691
|
+
scoped,
|
|
7692
|
+
graphSourceLabelsForPath
|
|
7693
|
+
);
|
|
7677
7694
|
}
|
|
7678
|
-
|
|
7679
|
-
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
|
|
7685
|
-
|
|
7686
|
-
|
|
7687
|
-
|
|
7688
|
-
|
|
7689
|
-
|
|
7690
|
-
const asOfActive = typeof asOfMs === "number" && Number.isFinite(asOfMs);
|
|
7691
|
-
const activeMemories = memories.filter(
|
|
7692
|
-
(m) => {
|
|
7693
|
-
if (isArtifactMemoryPath(m.path)) return false;
|
|
7694
|
-
const status = m.frontmatter.status;
|
|
7695
|
-
if (!status || status === "active") return true;
|
|
7696
|
-
if (status === "superseded") {
|
|
7697
|
-
if (asOfActive) return true;
|
|
7698
|
-
return !shouldFilterSupersededFromRecall(m.frontmatter, supersessionOptions);
|
|
7699
|
-
}
|
|
7700
|
-
return false;
|
|
7695
|
+
recallSource = "hot_embedding";
|
|
7696
|
+
recalledMemoryCount = scoped.length;
|
|
7697
|
+
this.publishRecallResults({
|
|
7698
|
+
title: "Relevant Memories",
|
|
7699
|
+
results: scoped,
|
|
7700
|
+
sectionBuckets,
|
|
7701
|
+
retrievalQuery,
|
|
7702
|
+
sessionKey,
|
|
7703
|
+
identityInjection: {
|
|
7704
|
+
mode: identityInjectionModeUsed,
|
|
7705
|
+
injectedChars: identityInjectedChars,
|
|
7706
|
+
truncated: identityInjectionTruncated
|
|
7701
7707
|
}
|
|
7702
|
-
);
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
7722
|
-
|
|
7723
|
-
results: longTerm,
|
|
7724
|
-
sectionBuckets,
|
|
7725
|
-
retrievalQuery,
|
|
7726
|
-
sessionKey,
|
|
7727
|
-
identityInjection: {
|
|
7728
|
-
mode: identityInjectionModeUsed,
|
|
7729
|
-
injectedChars: identityInjectedChars,
|
|
7730
|
-
truncated: identityInjectionTruncated
|
|
7708
|
+
});
|
|
7709
|
+
recalledMemoryIds = this.extractMemoryIdsFromResults(scoped);
|
|
7710
|
+
recalledMemoryPaths = scoped.map((result) => result.path).filter(Boolean);
|
|
7711
|
+
xrayRecalledResults = scoped;
|
|
7712
|
+
impressionRecorded = true;
|
|
7713
|
+
} else {
|
|
7714
|
+
const memories = await this.readAllMemoriesForNamespaces(recallNamespaces);
|
|
7715
|
+
if (memories.length > 0) {
|
|
7716
|
+
const supersessionOptions = {
|
|
7717
|
+
enabled: this.config.temporalSupersessionEnabled,
|
|
7718
|
+
includeInRecall: this.config.temporalSupersessionIncludeInRecall
|
|
7719
|
+
};
|
|
7720
|
+
const asOfActive = typeof asOfMs === "number" && Number.isFinite(asOfMs);
|
|
7721
|
+
const activeMemories = memories.filter(
|
|
7722
|
+
(m) => {
|
|
7723
|
+
if (isArtifactMemoryPath(m.path)) return false;
|
|
7724
|
+
const status = m.frontmatter.status;
|
|
7725
|
+
if (!status || status === "active") return true;
|
|
7726
|
+
if (status === "superseded") {
|
|
7727
|
+
if (asOfActive) return true;
|
|
7728
|
+
return !shouldFilterSupersededFromRecall(m.frontmatter, supersessionOptions);
|
|
7731
7729
|
}
|
|
7732
|
-
|
|
7733
|
-
recalledMemoryIds = this.extractMemoryIdsFromResults(longTerm);
|
|
7734
|
-
recalledMemoryPaths = longTerm.map((result) => result.path).filter(Boolean);
|
|
7735
|
-
xrayRecalledResults = longTerm;
|
|
7736
|
-
impressionRecorded = true;
|
|
7737
|
-
}
|
|
7738
|
-
} else {
|
|
7739
|
-
const recentSorted = queryAwareScopedMemories.sort(
|
|
7740
|
-
(a, b) => new Date(b.frontmatter.updated).getTime() - new Date(a.frontmatter.updated).getTime()
|
|
7741
|
-
);
|
|
7742
|
-
const preloadedMap = new Map(
|
|
7743
|
-
queryAwareScopedMemories.filter((m) => m.path).map((m) => [m.path, m])
|
|
7744
|
-
);
|
|
7745
|
-
const recentAsResults = recentSorted.map(
|
|
7746
|
-
(m, i) => ({
|
|
7747
|
-
docid: m.frontmatter.id,
|
|
7748
|
-
path: m.path,
|
|
7749
|
-
snippet: m.content,
|
|
7750
|
-
score: 1 - i / Math.max(recentSorted.length, 1)
|
|
7751
|
-
})
|
|
7752
|
-
);
|
|
7753
|
-
const boostedRecent = (await this.boostSearchResults(
|
|
7754
|
-
recentAsResults,
|
|
7755
|
-
recallNamespaces,
|
|
7756
|
-
retrievalQuery,
|
|
7757
|
-
preloadedMap,
|
|
7758
|
-
{ asOfMs }
|
|
7759
|
-
)).sort((a, b) => b.score - a.score);
|
|
7760
|
-
xrayBranchPoolSize.recent_scan = Math.max(
|
|
7761
|
-
xrayBranchPoolSize.recent_scan,
|
|
7762
|
-
boostedRecent.length
|
|
7763
|
-
);
|
|
7764
|
-
const recent = this.diversifyAndLimitRecallResults(
|
|
7765
|
-
"memories",
|
|
7766
|
-
boostedRecent,
|
|
7767
|
-
recallResultLimit,
|
|
7768
|
-
retrievalQuery
|
|
7769
|
-
);
|
|
7770
|
-
if (recent.length > 0) {
|
|
7771
|
-
if (shouldPersistGraphSnapshot) {
|
|
7772
|
-
graphSnapshotFinalResults = this.buildGraphRecallRankedResults(
|
|
7773
|
-
recent,
|
|
7774
|
-
graphSourceLabelsForPath
|
|
7775
|
-
);
|
|
7730
|
+
return false;
|
|
7776
7731
|
}
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7782
|
-
sectionBuckets,
|
|
7783
|
-
retrievalQuery,
|
|
7784
|
-
sessionKey,
|
|
7785
|
-
identityInjection: {
|
|
7786
|
-
mode: identityInjectionModeUsed,
|
|
7787
|
-
injectedChars: identityInjectedChars,
|
|
7788
|
-
truncated: identityInjectionTruncated
|
|
7789
|
-
}
|
|
7790
|
-
});
|
|
7791
|
-
recalledMemoryIds = this.extractMemoryIdsFromResults(recent);
|
|
7792
|
-
recalledMemoryPaths = recent.map((result) => result.path).filter(Boolean);
|
|
7793
|
-
xrayRecalledResults = recent;
|
|
7794
|
-
impressionRecorded = true;
|
|
7795
|
-
} else {
|
|
7732
|
+
);
|
|
7733
|
+
const queryAwareScopedMemories = queryAwarePrefilter.candidatePaths ? activeMemories.filter(
|
|
7734
|
+
(memory) => queryAwarePrefilter.candidatePaths?.has(memory.path)
|
|
7735
|
+
) : activeMemories;
|
|
7736
|
+
if (queryAwarePrefilter.candidatePaths && queryAwareScopedMemories.length === 0) {
|
|
7796
7737
|
const longTerm = await this.applyColdFallbackPipeline({
|
|
7797
7738
|
prompt: retrievalQuery,
|
|
7798
7739
|
recallNamespaces,
|
|
@@ -7805,12 +7746,6 @@ ${tmtNode.summary}`
|
|
|
7805
7746
|
...options.includeLowConfidence === true ? { includeLowConfidence: true } : {}
|
|
7806
7747
|
});
|
|
7807
7748
|
if (longTerm.length > 0) {
|
|
7808
|
-
if (shouldPersistGraphSnapshot) {
|
|
7809
|
-
graphSnapshotFinalResults = this.buildGraphRecallRankedResults(
|
|
7810
|
-
longTerm,
|
|
7811
|
-
graphSourceLabelsForPath
|
|
7812
|
-
);
|
|
7813
|
-
}
|
|
7814
7749
|
recallSource = "cold_fallback";
|
|
7815
7750
|
recalledMemoryCount = longTerm.length;
|
|
7816
7751
|
this.publishRecallResults({
|
|
@@ -7830,45 +7765,141 @@ ${tmtNode.summary}`
|
|
|
7830
7765
|
xrayRecalledResults = longTerm;
|
|
7831
7766
|
impressionRecorded = true;
|
|
7832
7767
|
}
|
|
7833
|
-
}
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
const longTerm = await this.applyColdFallbackPipeline({
|
|
7837
|
-
prompt: retrievalQuery,
|
|
7838
|
-
recallNamespaces,
|
|
7839
|
-
recallResultLimit,
|
|
7840
|
-
recallMode,
|
|
7841
|
-
queryAwarePrefilter,
|
|
7842
|
-
abortSignal: options.abortSignal,
|
|
7843
|
-
xrayPoolSizeSink: xrayColdPoolSink,
|
|
7844
|
-
asOfMs,
|
|
7845
|
-
...options.includeLowConfidence === true ? { includeLowConfidence: true } : {}
|
|
7846
|
-
});
|
|
7847
|
-
if (longTerm.length > 0) {
|
|
7848
|
-
if (shouldPersistGraphSnapshot) {
|
|
7849
|
-
graphSnapshotFinalResults = this.buildGraphRecallRankedResults(
|
|
7850
|
-
longTerm,
|
|
7851
|
-
graphSourceLabelsForPath
|
|
7768
|
+
} else {
|
|
7769
|
+
const recentSorted = queryAwareScopedMemories.sort(
|
|
7770
|
+
(a, b) => new Date(b.frontmatter.updated).getTime() - new Date(a.frontmatter.updated).getTime()
|
|
7852
7771
|
);
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
|
|
7857
|
-
|
|
7858
|
-
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
|
|
7772
|
+
const preloadedMap = new Map(
|
|
7773
|
+
queryAwareScopedMemories.filter((m) => m.path).map((m) => [m.path, m])
|
|
7774
|
+
);
|
|
7775
|
+
const recentAsResults = recentSorted.map(
|
|
7776
|
+
(m, i) => ({
|
|
7777
|
+
docid: m.frontmatter.id,
|
|
7778
|
+
path: m.path,
|
|
7779
|
+
snippet: m.content,
|
|
7780
|
+
score: 1 - i / Math.max(recentSorted.length, 1)
|
|
7781
|
+
})
|
|
7782
|
+
);
|
|
7783
|
+
const boostedRecent = (await this.boostSearchResults(
|
|
7784
|
+
recentAsResults,
|
|
7785
|
+
recallNamespaces,
|
|
7786
|
+
retrievalQuery,
|
|
7787
|
+
preloadedMap,
|
|
7788
|
+
{ asOfMs }
|
|
7789
|
+
)).sort((a, b) => b.score - a.score);
|
|
7790
|
+
xrayBranchPoolSize.recent_scan = Math.max(
|
|
7791
|
+
xrayBranchPoolSize.recent_scan,
|
|
7792
|
+
boostedRecent.length
|
|
7793
|
+
);
|
|
7794
|
+
const recent = this.diversifyAndLimitRecallResults(
|
|
7795
|
+
"memories",
|
|
7796
|
+
boostedRecent,
|
|
7797
|
+
recallResultLimit,
|
|
7798
|
+
retrievalQuery
|
|
7799
|
+
);
|
|
7800
|
+
if (recent.length > 0) {
|
|
7801
|
+
if (shouldPersistGraphSnapshot) {
|
|
7802
|
+
graphSnapshotFinalResults = this.buildGraphRecallRankedResults(
|
|
7803
|
+
recent,
|
|
7804
|
+
graphSourceLabelsForPath
|
|
7805
|
+
);
|
|
7806
|
+
}
|
|
7807
|
+
recallSource = "recent_scan";
|
|
7808
|
+
recalledMemoryCount = recent.length;
|
|
7809
|
+
this.publishRecallResults({
|
|
7810
|
+
title: "Recent Memories",
|
|
7811
|
+
results: recent,
|
|
7812
|
+
sectionBuckets,
|
|
7813
|
+
retrievalQuery,
|
|
7814
|
+
sessionKey,
|
|
7815
|
+
identityInjection: {
|
|
7816
|
+
mode: identityInjectionModeUsed,
|
|
7817
|
+
injectedChars: identityInjectedChars,
|
|
7818
|
+
truncated: identityInjectionTruncated
|
|
7819
|
+
}
|
|
7820
|
+
});
|
|
7821
|
+
recalledMemoryIds = this.extractMemoryIdsFromResults(recent);
|
|
7822
|
+
recalledMemoryPaths = recent.map((result) => result.path).filter(Boolean);
|
|
7823
|
+
xrayRecalledResults = recent;
|
|
7824
|
+
impressionRecorded = true;
|
|
7825
|
+
} else {
|
|
7826
|
+
const longTerm = await this.applyColdFallbackPipeline({
|
|
7827
|
+
prompt: retrievalQuery,
|
|
7828
|
+
recallNamespaces,
|
|
7829
|
+
recallResultLimit,
|
|
7830
|
+
recallMode,
|
|
7831
|
+
queryAwarePrefilter,
|
|
7832
|
+
abortSignal: options.abortSignal,
|
|
7833
|
+
xrayPoolSizeSink: xrayColdPoolSink,
|
|
7834
|
+
asOfMs,
|
|
7835
|
+
...options.includeLowConfidence === true ? { includeLowConfidence: true } : {}
|
|
7836
|
+
});
|
|
7837
|
+
if (longTerm.length > 0) {
|
|
7838
|
+
if (shouldPersistGraphSnapshot) {
|
|
7839
|
+
graphSnapshotFinalResults = this.buildGraphRecallRankedResults(
|
|
7840
|
+
longTerm,
|
|
7841
|
+
graphSourceLabelsForPath
|
|
7842
|
+
);
|
|
7843
|
+
}
|
|
7844
|
+
recallSource = "cold_fallback";
|
|
7845
|
+
recalledMemoryCount = longTerm.length;
|
|
7846
|
+
this.publishRecallResults({
|
|
7847
|
+
title: "Long-Term Memories (Fallback)",
|
|
7848
|
+
results: longTerm,
|
|
7849
|
+
sectionBuckets,
|
|
7850
|
+
retrievalQuery,
|
|
7851
|
+
sessionKey,
|
|
7852
|
+
identityInjection: {
|
|
7853
|
+
mode: identityInjectionModeUsed,
|
|
7854
|
+
injectedChars: identityInjectedChars,
|
|
7855
|
+
truncated: identityInjectionTruncated
|
|
7856
|
+
}
|
|
7857
|
+
});
|
|
7858
|
+
recalledMemoryIds = this.extractMemoryIdsFromResults(longTerm);
|
|
7859
|
+
recalledMemoryPaths = longTerm.map((result) => result.path).filter(Boolean);
|
|
7860
|
+
xrayRecalledResults = longTerm;
|
|
7861
|
+
impressionRecorded = true;
|
|
7862
|
+
}
|
|
7866
7863
|
}
|
|
7864
|
+
}
|
|
7865
|
+
} else {
|
|
7866
|
+
const longTerm = await this.applyColdFallbackPipeline({
|
|
7867
|
+
prompt: retrievalQuery,
|
|
7868
|
+
recallNamespaces,
|
|
7869
|
+
recallResultLimit,
|
|
7870
|
+
recallMode,
|
|
7871
|
+
queryAwarePrefilter,
|
|
7872
|
+
abortSignal: options.abortSignal,
|
|
7873
|
+
xrayPoolSizeSink: xrayColdPoolSink,
|
|
7874
|
+
asOfMs,
|
|
7875
|
+
...options.includeLowConfidence === true ? { includeLowConfidence: true } : {}
|
|
7867
7876
|
});
|
|
7868
|
-
|
|
7869
|
-
|
|
7870
|
-
|
|
7871
|
-
|
|
7877
|
+
if (longTerm.length > 0) {
|
|
7878
|
+
if (shouldPersistGraphSnapshot) {
|
|
7879
|
+
graphSnapshotFinalResults = this.buildGraphRecallRankedResults(
|
|
7880
|
+
longTerm,
|
|
7881
|
+
graphSourceLabelsForPath
|
|
7882
|
+
);
|
|
7883
|
+
}
|
|
7884
|
+
recallSource = "cold_fallback";
|
|
7885
|
+
recalledMemoryCount = longTerm.length;
|
|
7886
|
+
this.publishRecallResults({
|
|
7887
|
+
title: "Long-Term Memories (Fallback)",
|
|
7888
|
+
results: longTerm,
|
|
7889
|
+
sectionBuckets,
|
|
7890
|
+
retrievalQuery,
|
|
7891
|
+
sessionKey,
|
|
7892
|
+
identityInjection: {
|
|
7893
|
+
mode: identityInjectionModeUsed,
|
|
7894
|
+
injectedChars: identityInjectedChars,
|
|
7895
|
+
truncated: identityInjectionTruncated
|
|
7896
|
+
}
|
|
7897
|
+
});
|
|
7898
|
+
recalledMemoryIds = this.extractMemoryIdsFromResults(longTerm);
|
|
7899
|
+
recalledMemoryPaths = longTerm.map((result) => result.path).filter(Boolean);
|
|
7900
|
+
xrayRecalledResults = longTerm;
|
|
7901
|
+
impressionRecorded = true;
|
|
7902
|
+
}
|
|
7872
7903
|
}
|
|
7873
7904
|
}
|
|
7874
7905
|
}
|
|
@@ -11718,6 +11749,7 @@ ${lines.join("\n\n")}`;
|
|
|
11718
11749
|
throwIfRecallAborted(abortSignal);
|
|
11719
11750
|
const cappedLimit = Math.max(0, limit);
|
|
11720
11751
|
if (cappedLimit === 0) return [];
|
|
11752
|
+
if (queryAwarePrefilter?.candidatePaths?.size === 0) return [];
|
|
11721
11753
|
const scopedSeedResults = queryAwarePrefilter?.candidatePaths?.size ? await this.searchScopedMemoryCandidates(
|
|
11722
11754
|
queryAwarePrefilter.candidatePaths,
|
|
11723
11755
|
prompt,
|
|
@@ -11767,6 +11799,10 @@ ${lines.join("\n\n")}`;
|
|
|
11767
11799
|
return [...mergedByPath.values()].filter((result) => !isArtifactMemoryPath(result.path)).sort((a, b) => b.score - a.score).slice(0, cappedLimit);
|
|
11768
11800
|
}
|
|
11769
11801
|
async applyColdFallbackPipeline(options) {
|
|
11802
|
+
if (options.queryAwarePrefilter?.candidatePaths?.size === 0) {
|
|
11803
|
+
if (options.xrayPoolSizeSink) options.xrayPoolSizeSink.size = 0;
|
|
11804
|
+
return [];
|
|
11805
|
+
}
|
|
11770
11806
|
const coldQmdEnabled = this.config.qmdColdTierEnabled === true;
|
|
11771
11807
|
const coldCollection = this.config.qmdColdCollection ?? "openclaw-engram-cold";
|
|
11772
11808
|
const coldMaxResults = this.config.qmdColdMaxResults ?? this.config.qmdMaxResults;
|
|
@@ -12001,7 +12037,7 @@ ${lines.join("\n\n")}`;
|
|
|
12001
12037
|
if (!s) return null;
|
|
12002
12038
|
const scoped = new Set(Array.from(s).filter((p) => resultPaths.has(p)));
|
|
12003
12039
|
if (maxCandidates === 0 || scoped.size <= maxCandidates)
|
|
12004
|
-
return scoped
|
|
12040
|
+
return scoped;
|
|
12005
12041
|
return new Set(Array.from(scoped).slice(0, maxCandidates));
|
|
12006
12042
|
};
|
|
12007
12043
|
if (temporalFromDate !== null) {
|
|
@@ -12405,4 +12441,4 @@ export {
|
|
|
12405
12441
|
resolvePersistedMemoryRelativePath,
|
|
12406
12442
|
Orchestrator
|
|
12407
12443
|
};
|
|
12408
|
-
//# sourceMappingURL=chunk-
|
|
12444
|
+
//# sourceMappingURL=chunk-OEIRQ7DB.js.map
|