@remnic/core 9.3.633 → 9.3.635
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 +24 -24
- package/dist/access-http.d.ts +1 -1
- package/dist/access-http.js +22 -3
- package/dist/access-mcp.d.ts +1 -1
- package/dist/access-mcp.js +21 -2
- package/dist/{access-service-C9_EpVHd.d.ts → access-service-GVOE5U3C.d.ts} +3 -0
- package/dist/access-service.d.ts +1 -1
- package/dist/access-service.js +20 -1
- package/dist/{chunk-2ROPI5OE.js → chunk-6GC5SGFE.js} +4 -4
- package/dist/{chunk-6GDHLVJC.js → chunk-AV5ZEH4M.js} +4 -4
- package/dist/{chunk-32U3N7H5.js → chunk-BK35NOJL.js} +3 -3
- package/dist/{chunk-TZVQQTG4.js → chunk-DEDTFRH2.js} +6 -6
- package/dist/{chunk-5PT5I6JQ.js → chunk-JYFO32V4.js} +7 -7
- package/dist/{chunk-ZJR7VG5L.js → chunk-LASA46TQ.js} +2 -2
- package/dist/{chunk-XG4NAWAV.js → chunk-NFNQ7TWF.js} +3 -3
- package/dist/{chunk-XG4NAWAV.js.map → chunk-NFNQ7TWF.js.map} +1 -1
- package/dist/{chunk-YRMKDTKF.js → chunk-RAGXUVQW.js} +3 -3
- package/dist/{chunk-EWLQPEO6.js → chunk-RN7MUWON.js} +4 -4
- package/dist/{chunk-WR64DQFE.js → chunk-SQZ42MKH.js} +4 -4
- package/dist/{chunk-WLZBVYC6.js → chunk-TFICNXXU.js} +28 -28
- package/dist/{chunk-IFVFQRZ2.js → chunk-VTH5SKQW.js} +2 -2
- package/dist/{chunk-DOBJH4I6.js → chunk-XM6M6DHG.js} +78 -10
- package/dist/chunk-XM6M6DHG.js.map +1 -0
- package/dist/{chunk-VTR3MNYF.js → chunk-YCX45GOQ.js} +4 -4
- package/dist/{cli-CuVEQWKr.d.ts → cli-B-fHk59D.d.ts} +1 -1
- package/dist/cli.d.ts +2 -2
- package/dist/cli.js +26 -26
- package/dist/direct-answer-wiring.js +2 -2
- package/dist/harmonic-retrieval.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +41 -41
- package/dist/mcp-memory-inspector-app.d.ts +1 -1
- package/dist/namespaces/migrate.js +8 -8
- package/dist/namespaces/search.js +6 -6
- package/dist/operator-toolkit.js +19 -19
- package/dist/orchestrator.js +23 -23
- package/dist/qmd.js +2 -2
- package/dist/retrieval-agents.js +2 -2
- package/dist/search/embed-helper.js +2 -2
- package/dist/search/factory.js +5 -5
- package/dist/search/index.js +5 -5
- package/dist/search/lancedb-backend.js +1 -1
- package/dist/search/meilisearch-backend.js +1 -1
- package/dist/search/orama-backend.js +1 -1
- package/package.json +1 -1
- package/src/access-mcp.ts +1 -1
- package/src/access-service-namespace.test.ts +312 -0
- package/src/access-service.ts +97 -11
- package/dist/chunk-DOBJH4I6.js.map +0 -1
- /package/dist/{chunk-2ROPI5OE.js.map → chunk-6GC5SGFE.js.map} +0 -0
- /package/dist/{chunk-6GDHLVJC.js.map → chunk-AV5ZEH4M.js.map} +0 -0
- /package/dist/{chunk-32U3N7H5.js.map → chunk-BK35NOJL.js.map} +0 -0
- /package/dist/{chunk-TZVQQTG4.js.map → chunk-DEDTFRH2.js.map} +0 -0
- /package/dist/{chunk-5PT5I6JQ.js.map → chunk-JYFO32V4.js.map} +0 -0
- /package/dist/{chunk-ZJR7VG5L.js.map → chunk-LASA46TQ.js.map} +0 -0
- /package/dist/{chunk-YRMKDTKF.js.map → chunk-RAGXUVQW.js.map} +0 -0
- /package/dist/{chunk-EWLQPEO6.js.map → chunk-RN7MUWON.js.map} +0 -0
- /package/dist/{chunk-WR64DQFE.js.map → chunk-SQZ42MKH.js.map} +0 -0
- /package/dist/{chunk-WLZBVYC6.js.map → chunk-TFICNXXU.js.map} +0 -0
- /package/dist/{chunk-IFVFQRZ2.js.map → chunk-VTH5SKQW.js.map} +0 -0
- /package/dist/{chunk-VTR3MNYF.js.map → chunk-YCX45GOQ.js.map} +0 -0
package/src/access-service.ts
CHANGED
|
@@ -54,6 +54,7 @@ import {
|
|
|
54
54
|
} from "./memory-lifecycle-ledger-utils.js";
|
|
55
55
|
import { getMemoryProjectionPath } from "./memory-projection-store.js";
|
|
56
56
|
import { canReadNamespace, canWriteNamespace, defaultNamespaceForPrincipal, recallNamespacesForPrincipal, resolvePrincipal } from "./namespaces/principal.js";
|
|
57
|
+
import { namespaceCollectionName } from "./namespaces/search.js";
|
|
57
58
|
import type { LastRecallSnapshot } from "./recall-state.js";
|
|
58
59
|
import type {
|
|
59
60
|
GraphRecallSnapshot,
|
|
@@ -1322,6 +1323,75 @@ export class EngramAccessService {
|
|
|
1322
1323
|
return resolved;
|
|
1323
1324
|
}
|
|
1324
1325
|
|
|
1326
|
+
private resolveReadableNamespacesForSearch(namespace: string | undefined, principal?: string): string[] {
|
|
1327
|
+
const requested = namespace?.trim();
|
|
1328
|
+
if (requested) {
|
|
1329
|
+
return [this.resolveReadableNamespace(requested, principal)];
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
if (!this.orchestrator.config.namespacesEnabled) {
|
|
1333
|
+
return [this.resolveNamespace(undefined)];
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
if (!principal) {
|
|
1337
|
+
throw new EngramAccessInputError(
|
|
1338
|
+
"authentication required: namespaces are enabled and no principal was supplied",
|
|
1339
|
+
);
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
return recallNamespacesForPrincipal(principal, this.orchestrator.config)
|
|
1343
|
+
.filter((ns) => canReadNamespace(principal, ns, this.orchestrator.config));
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
private resolveAllReadableConfiguredNamespaces(principal: string): string[] {
|
|
1347
|
+
const config = this.orchestrator.config;
|
|
1348
|
+
const candidates = [
|
|
1349
|
+
config.defaultNamespace,
|
|
1350
|
+
config.sharedNamespace,
|
|
1351
|
+
...config.namespacePolicies.map((policy) => policy.name),
|
|
1352
|
+
];
|
|
1353
|
+
return [...new Set(candidates)]
|
|
1354
|
+
.filter((namespace) => canReadNamespace(principal, namespace, config));
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
private resolveMemorySearchNamespacesForCollection(
|
|
1358
|
+
collection: string | undefined,
|
|
1359
|
+
namespaces: string[],
|
|
1360
|
+
collectionPrincipal?: string,
|
|
1361
|
+
): string[] {
|
|
1362
|
+
if (!this.orchestrator.config.namespacesEnabled) {
|
|
1363
|
+
return namespaces;
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
const baseCollection = this.orchestrator.config.qmdCollection;
|
|
1367
|
+
if (!collection || collection === "global" || collection === baseCollection) {
|
|
1368
|
+
return namespaces;
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
const candidates = collectionPrincipal
|
|
1372
|
+
? this.resolveAllReadableConfiguredNamespaces(collectionPrincipal)
|
|
1373
|
+
: namespaces;
|
|
1374
|
+
const matchedNamespaces = candidates.filter((namespace) => {
|
|
1375
|
+
const canonical = namespaceCollectionName(baseCollection, namespace, {
|
|
1376
|
+
defaultNamespace: this.orchestrator.config.defaultNamespace,
|
|
1377
|
+
useLegacyDefaultCollection: false,
|
|
1378
|
+
});
|
|
1379
|
+
const legacyDefault = namespaceCollectionName(baseCollection, namespace, {
|
|
1380
|
+
defaultNamespace: this.orchestrator.config.defaultNamespace,
|
|
1381
|
+
useLegacyDefaultCollection: true,
|
|
1382
|
+
});
|
|
1383
|
+
return collection === canonical || collection === legacyDefault;
|
|
1384
|
+
});
|
|
1385
|
+
|
|
1386
|
+
if (matchedNamespaces.length > 0) {
|
|
1387
|
+
return matchedNamespaces;
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
throw new EngramAccessInputError(
|
|
1391
|
+
"collection is not namespace-scoped for the requested principal",
|
|
1392
|
+
);
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1325
1395
|
private async buildRecallDebug(
|
|
1326
1396
|
snapshot: LastRecallSnapshot | null,
|
|
1327
1397
|
namespace: string,
|
|
@@ -4864,18 +4934,34 @@ export class EngramAccessService {
|
|
|
4864
4934
|
collection?: string;
|
|
4865
4935
|
principal?: string;
|
|
4866
4936
|
}): Promise<{ query: string; results: Array<{ path: string; score: number; snippet: string }>; count: number }> {
|
|
4867
|
-
const { query, namespace, maxResults,
|
|
4868
|
-
const
|
|
4869
|
-
|
|
4937
|
+
const { query, namespace, maxResults, principal } = request;
|
|
4938
|
+
const collection = request.collection?.trim();
|
|
4939
|
+
if (request.collection !== undefined && !collection) {
|
|
4940
|
+
throw new EngramAccessInputError("collection must be a non-empty string");
|
|
4941
|
+
}
|
|
4870
4942
|
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4943
|
+
let results: Array<{ path: string; score: number; snippet?: string }>;
|
|
4944
|
+
if (!this.orchestrator.config.namespacesEnabled) {
|
|
4945
|
+
this.resolveReadableNamespace(namespace, principal);
|
|
4946
|
+
results = collection === "global"
|
|
4947
|
+
? await this.orchestrator.qmd.searchGlobal(query, maxResults)
|
|
4948
|
+
: await this.orchestrator.qmd.search(query, collection, maxResults);
|
|
4949
|
+
} else {
|
|
4950
|
+
const readableNamespaces = this.resolveReadableNamespacesForSearch(namespace, principal);
|
|
4951
|
+
const namespaces = this.resolveMemorySearchNamespacesForCollection(
|
|
4952
|
+
collection,
|
|
4953
|
+
readableNamespaces,
|
|
4954
|
+
namespace?.trim() ? undefined : principal,
|
|
4955
|
+
);
|
|
4956
|
+
results = namespaces.length === 0
|
|
4957
|
+
? []
|
|
4958
|
+
: await this.orchestrator.searchAcrossNamespaces({
|
|
4959
|
+
query,
|
|
4960
|
+
namespaces,
|
|
4961
|
+
maxResults,
|
|
4962
|
+
mode: "search",
|
|
4963
|
+
});
|
|
4964
|
+
}
|
|
4879
4965
|
|
|
4880
4966
|
return {
|
|
4881
4967
|
query,
|