@remnic/core 9.3.551 → 9.3.553

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 (54) hide show
  1. package/dist/access-cli.js +3 -3
  2. package/dist/access-http.d.ts +2 -2
  3. package/dist/access-http.js +4 -4
  4. package/dist/access-mcp.d.ts +2 -2
  5. package/dist/access-mcp.js +3 -3
  6. package/dist/{access-service-CZfksQuS.d.ts → access-service-D2J9dh_9.d.ts} +3 -1
  7. package/dist/access-service.d.ts +2 -2
  8. package/dist/access-service.js +2 -2
  9. package/dist/active-memory-bridge.d.ts +1 -1
  10. package/dist/active-memory-bridge.js +2 -2
  11. package/dist/bootstrap.d.ts +1 -1
  12. package/dist/{chunk-GSFFWOWU.js → chunk-65OLPXBU.js} +5 -4
  13. package/dist/chunk-65OLPXBU.js.map +1 -0
  14. package/dist/{chunk-DEGH5BUP.js → chunk-BUUYY2H2.js} +4 -3
  15. package/dist/chunk-BUUYY2H2.js.map +1 -0
  16. package/dist/{chunk-2R6MP5C6.js → chunk-GEL3F3RV.js} +4 -4
  17. package/dist/{chunk-YN3WHXBG.js → chunk-KS7WO6EQ.js} +36 -9
  18. package/dist/chunk-KS7WO6EQ.js.map +1 -0
  19. package/dist/{chunk-IC4GELZE.js → chunk-NINRTFSV.js} +5 -2
  20. package/dist/chunk-NINRTFSV.js.map +1 -0
  21. package/dist/{chunk-XDMLTNIG.js → chunk-NYV435HC.js} +9 -2
  22. package/dist/chunk-NYV435HC.js.map +1 -0
  23. package/dist/{chunk-HWVTS5NO.js → chunk-UZYLX7M6.js} +7 -3
  24. package/dist/chunk-UZYLX7M6.js.map +1 -0
  25. package/dist/{cli-9pwA_PXm.d.ts → cli-OrfKXNU4.d.ts} +2 -2
  26. package/dist/cli.d.ts +3 -3
  27. package/dist/cli.js +5 -5
  28. package/dist/explicit-capture.d.ts +1 -1
  29. package/dist/index.d.ts +3 -3
  30. package/dist/index.js +7 -7
  31. package/dist/mcp-memory-inspector-app.d.ts +2 -2
  32. package/dist/namespaces/principal.d.ts +5 -5
  33. package/dist/namespaces/principal.js +1 -1
  34. package/dist/{orchestrator-Co9nxRLF.d.ts → orchestrator-DTRQG75J.d.ts} +1 -1
  35. package/dist/orchestrator.d.ts +1 -1
  36. package/dist/orchestrator.js +2 -2
  37. package/dist/schemas.d.ts +22 -22
  38. package/dist/transfer/types.d.ts +12 -12
  39. package/package.json +1 -1
  40. package/src/access-http.ts +1 -0
  41. package/src/access-mcp.ts +1 -0
  42. package/src/access-service.ts +46 -8
  43. package/src/active-memory-bridge.test.ts +28 -0
  44. package/src/active-memory-bridge.ts +5 -2
  45. package/src/namespaces/principal.test.ts +20 -0
  46. package/src/namespaces/principal.ts +13 -7
  47. package/src/orchestrator.ts +13 -1
  48. package/dist/chunk-DEGH5BUP.js.map +0 -1
  49. package/dist/chunk-GSFFWOWU.js.map +0 -1
  50. package/dist/chunk-HWVTS5NO.js.map +0 -1
  51. package/dist/chunk-IC4GELZE.js.map +0 -1
  52. package/dist/chunk-XDMLTNIG.js.map +0 -1
  53. package/dist/chunk-YN3WHXBG.js.map +0 -1
  54. /package/dist/{chunk-2R6MP5C6.js.map → chunk-GEL3F3RV.js.map} +0 -0
@@ -6,7 +6,7 @@ import {
6
6
  canReadNamespace,
7
7
  defaultNamespaceForPrincipal,
8
8
  resolvePrincipal
9
- } from "./chunk-HWVTS5NO.js";
9
+ } from "./chunk-UZYLX7M6.js";
10
10
 
11
11
  // src/active-memory-bridge.ts
12
12
  function isArtifactPath(value) {
@@ -46,6 +46,9 @@ function resolveActiveMemoryNamespace(orchestrator, sessionKey, requestedNamespa
46
46
  return "default";
47
47
  }
48
48
  const principal = typeof orchestrator.resolvePrincipal === "function" ? orchestrator.resolvePrincipal(sessionKey) : resolvePrincipal(sessionKey, config);
49
+ if (config.namespacesEnabled && !principal) {
50
+ throw new Error("authentication required: namespaces are enabled and no principal was supplied");
51
+ }
49
52
  if (explicitNamespace) {
50
53
  if (!canReadNamespace(principal, explicitNamespace, config)) {
51
54
  throw new Error(`namespace ${explicitNamespace} is not readable for principal ${principal}`);
@@ -118,4 +121,4 @@ export {
118
121
  recallForActiveMemory,
119
122
  getMemoryForActiveMemory
120
123
  };
121
- //# sourceMappingURL=chunk-IC4GELZE.js.map
124
+ //# sourceMappingURL=chunk-NINRTFSV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/active-memory-bridge.ts"],"sourcesContent":["import { canReadNamespace, defaultNamespaceForPrincipal, resolvePrincipal } from \"./namespaces/principal.js\";\nimport type { MemoryFile, PluginConfig } from \"./types.js\";\nimport { collapseWhitespace, truncateCodePointSafe } from \"./whitespace.js\";\n\nexport interface ActiveMemoryMetadata {\n type?: \"fact\" | \"preference\";\n topic?: string;\n updatedAt?: string;\n sourceUri?: string;\n}\n\nexport interface ActiveMemorySearchResult {\n id: string;\n score: number;\n text: string;\n metadata?: ActiveMemoryMetadata;\n}\n\nexport interface ActiveMemorySearchOutput {\n results: ActiveMemorySearchResult[];\n truncated: boolean;\n}\n\nexport interface ActiveMemoryGetOutput {\n id?: string;\n text?: string;\n metadata?: ActiveMemoryMetadata;\n error?: \"not_found\";\n}\n\nexport interface ActiveMemoryRecallParams {\n query: string;\n limit?: number;\n sessionKey: string;\n filters?: Record<string, unknown>;\n snippetMaxChars?: number;\n}\n\ninterface ActiveMemoryScopedOrchestrator {\n config?: PluginConfig;\n resolvePrincipal?: (sessionKey?: string) => string | undefined;\n resolveSelfNamespace?: (sessionKey?: string) => string;\n}\n\ntype ActiveMemorySearchCandidate = {\n id?: string;\n score?: number;\n snippet?: string;\n text?: string;\n path?: string;\n metadata?: Record<string, unknown>;\n};\n\nfunction isArtifactPath(value: string | undefined): boolean {\n return typeof value === \"string\" && /(?:^|[\\\\/])artifacts(?:[\\\\/]|$)/i.test(value);\n}\n\nfunction clampLimit(value: number | undefined): number {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return 8;\n return Math.max(1, Math.min(50, Math.floor(value)));\n}\n\nfunction truncateSnippet(value: string, maxChars: number): string {\n const compact = collapseWhitespace(value);\n return truncateCodePointSafe(compact, maxChars);\n}\n\nfunction pickMetadata(value: Record<string, unknown> | undefined): ActiveMemoryMetadata | undefined {\n if (!value) return undefined;\n const metadata: ActiveMemoryMetadata = {};\n if (typeof value.type === \"string\") metadata.type = value.type as ActiveMemoryMetadata[\"type\"];\n if (typeof value.topic === \"string\") metadata.topic = value.topic;\n if (typeof value.updatedAt === \"string\") metadata.updatedAt = value.updatedAt;\n if (typeof value.sourceUri === \"string\") metadata.sourceUri = value.sourceUri;\n return Object.keys(metadata).length > 0 ? metadata : undefined;\n}\n\nfunction resolveActiveMemoryNamespace(\n orchestrator: ActiveMemoryScopedOrchestrator,\n sessionKey: string | undefined,\n requestedNamespace: string | undefined,\n): string {\n const explicitNamespace =\n typeof requestedNamespace === \"string\" && requestedNamespace.trim().length > 0\n ? requestedNamespace.trim()\n : undefined;\n const config = orchestrator.config;\n\n if (config?.namespacesEnabled === false) {\n if (typeof orchestrator.resolveSelfNamespace === \"function\") {\n return orchestrator.resolveSelfNamespace(sessionKey);\n }\n return \"default\";\n }\n\n if (!config) {\n if (explicitNamespace) return explicitNamespace;\n if (typeof orchestrator.resolveSelfNamespace === \"function\") {\n return orchestrator.resolveSelfNamespace(sessionKey);\n }\n return \"default\";\n }\n\n const principal =\n typeof orchestrator.resolvePrincipal === \"function\"\n ? orchestrator.resolvePrincipal(sessionKey)\n : resolvePrincipal(sessionKey, config);\n if (config.namespacesEnabled && !principal) {\n throw new Error(\"authentication required: namespaces are enabled and no principal was supplied\");\n }\n if (explicitNamespace) {\n if (!canReadNamespace(principal, explicitNamespace, config)) {\n throw new Error(`namespace ${explicitNamespace} is not readable for principal ${principal}`);\n }\n return explicitNamespace;\n }\n if (typeof orchestrator.resolveSelfNamespace === \"function\") {\n return orchestrator.resolveSelfNamespace(sessionKey);\n }\n return defaultNamespaceForPrincipal(principal, config);\n}\n\nexport async function recallForActiveMemory(\n orchestrator: {\n config?: PluginConfig;\n resolvePrincipal?: (sessionKey?: string) => string | undefined;\n resolveSelfNamespace?: (sessionKey?: string) => string;\n searchAcrossNamespaces: (params: {\n query: string;\n maxResults?: number;\n namespaces?: string[];\n mode?: string;\n }) => Promise<ActiveMemorySearchCandidate[]>;\n },\n params: ActiveMemoryRecallParams,\n): Promise<ActiveMemorySearchOutput> {\n const limit = clampLimit(params.limit);\n const requestedResults = Math.min(200, limit + 20);\n const snippetMaxChars =\n typeof params.snippetMaxChars === \"number\" && Number.isFinite(params.snippetMaxChars)\n ? Math.max(1, Math.min(4000, Math.floor(params.snippetMaxChars)))\n : 600;\n const namespace = resolveActiveMemoryNamespace(\n orchestrator,\n params.sessionKey,\n typeof params.filters?.namespace === \"string\" ? params.filters.namespace : undefined,\n );\n\n const raw = await orchestrator.searchAcrossNamespaces({\n query: params.query,\n maxResults: requestedResults,\n namespaces: [namespace],\n mode: \"search\",\n });\n const visible = raw.filter((candidate) => !isArtifactPath(candidate.path));\n\n return {\n results: visible.slice(0, limit).map((candidate, index) => ({\n id: candidate.id ?? candidate.path ?? `memory-${index + 1}`,\n score: typeof candidate.score === \"number\" ? candidate.score : 0,\n text: truncateSnippet(candidate.snippet ?? candidate.text ?? \"\", snippetMaxChars),\n metadata: pickMetadata(candidate.metadata),\n })),\n truncated: visible.length > limit,\n };\n}\n\nfunction buildActiveMemoryMetadataFromMemory(memory: MemoryFile): ActiveMemoryMetadata | undefined {\n const metadata: ActiveMemoryMetadata = {};\n if (typeof memory.frontmatter.category === \"string\") {\n const category = memory.frontmatter.category;\n if (category === \"fact\" || category === \"preference\") {\n metadata.type = category;\n }\n }\n if (Array.isArray(memory.frontmatter.tags) && memory.frontmatter.tags.length > 0) {\n metadata.topic = memory.frontmatter.tags[0];\n }\n if (typeof memory.frontmatter.updated === \"string\") metadata.updatedAt = memory.frontmatter.updated;\n if (typeof memory.frontmatter.source === \"string\") metadata.sourceUri = memory.frontmatter.source;\n return Object.keys(metadata).length > 0 ? metadata : undefined;\n}\n\nexport async function getMemoryForActiveMemory(\n orchestrator: {\n config?: PluginConfig;\n resolvePrincipal?: (sessionKey?: string) => string;\n resolveSelfNamespace?: (sessionKey?: string) => string;\n getStorageForNamespace?: (namespace: string) => Promise<{\n getMemoryById?: (id: string) => Promise<MemoryFile | null>;\n }>;\n storage?: {\n getMemoryById?: (id: string) => Promise<MemoryFile | null>;\n };\n },\n id: string,\n options: {\n namespace?: string;\n sessionKey?: string;\n } = {},\n): Promise<ActiveMemoryGetOutput> {\n const namespace = resolveActiveMemoryNamespace(\n orchestrator,\n options.sessionKey,\n options.namespace,\n );\n\n const storage =\n typeof orchestrator.getStorageForNamespace === \"function\"\n ? await orchestrator.getStorageForNamespace(namespace)\n : orchestrator.storage;\n\n const memory = await storage?.getMemoryById?.(id);\n if (!memory) return { error: \"not_found\" };\n return {\n id,\n text: collapseWhitespace(memory.content),\n metadata: buildActiveMemoryMetadataFromMemory(memory),\n };\n}\n"],"mappings":";;;;;;;;;;;AAqDA,SAAS,eAAe,OAAoC;AAC1D,SAAO,OAAO,UAAU,YAAY,mCAAmC,KAAK,KAAK;AACnF;AAEA,SAAS,WAAW,OAAmC;AACrD,MAAI,OAAO,UAAU,YAAY,CAAC,OAAO,SAAS,KAAK,EAAG,QAAO;AACjE,SAAO,KAAK,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,MAAM,KAAK,CAAC,CAAC;AACpD;AAEA,SAAS,gBAAgB,OAAe,UAA0B;AAChE,QAAM,UAAU,mBAAmB,KAAK;AACxC,SAAO,sBAAsB,SAAS,QAAQ;AAChD;AAEA,SAAS,aAAa,OAA8E;AAClG,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,WAAiC,CAAC;AACxC,MAAI,OAAO,MAAM,SAAS,SAAU,UAAS,OAAO,MAAM;AAC1D,MAAI,OAAO,MAAM,UAAU,SAAU,UAAS,QAAQ,MAAM;AAC5D,MAAI,OAAO,MAAM,cAAc,SAAU,UAAS,YAAY,MAA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,YAAY,OAAO,YAAY;AAC3F,SAAO,OAAO,KAAK,QAAQ,EAAE,SAAS,IAAI,WAAW;AACvD;AAEA,eAAsB,yBACpB,cAWA,IACA,UAGI,CAAC,GAC2B;AAChC,QAAM,YAAY;AAAA,IAChB;AAAA,IACA,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV;AAEA,QAAM,UACJ,OAAO,aAAa,2BAA2B,aAC3C,MAAM,aAAa,uBAAuB,SAAS,IACnD,aAAa;AAEnB,QAAM,SAAS,MAAM,SAAS,gBAAgB,EAAE;AAChD,MAAI,CAAC,OAAQ,QAAO,EAAE,OAAO,YAAY;AACzC,SAAO;AAAA,IACL;AAAA,IACA,MAAM,mBAAmB,OAAO,OAAO;AAAA,IACvC,UAAU,oCAAoC,MAAM;AAAA,EACtD;AACF;","names":[]}
@@ -369,7 +369,7 @@ import {
369
369
  defaultNamespaceForPrincipal,
370
370
  recallNamespacesForPrincipal,
371
371
  resolvePrincipal
372
- } from "./chunk-HWVTS5NO.js";
372
+ } from "./chunk-UZYLX7M6.js";
373
373
  import {
374
374
  selectRouteRule
375
375
  } from "./chunk-U3PN77QT.js";
@@ -3999,6 +3999,10 @@ ${r.snippet.trim()}
3999
3999
  } else {
4000
4000
  options.abortSignal?.addEventListener("abort", onAbort, { once: true });
4001
4001
  }
4002
+ const principal = typeof options.principalOverride === "string" && options.principalOverride.length > 0 ? options.principalOverride : resolvePrincipal(sessionKey, this.config);
4003
+ if (this.config.namespacesEnabled && !principal) {
4004
+ throw new Error("authentication required: namespaces are enabled and no principal was supplied");
4005
+ }
4002
4006
  let initGateTimeoutHandle = null;
4003
4007
  let onInitGateAbort = null;
4004
4008
  if (this.initPromise) {
@@ -5148,6 +5152,9 @@ ${r.snippet.trim()}
5148
5152
  );
5149
5153
  const embeddingFetchLimit = computedFetchLimit;
5150
5154
  const principal = typeof options.principalOverride === "string" && options.principalOverride.length > 0 ? options.principalOverride : resolvePrincipal(sessionKey, this.config);
5155
+ if (this.config.namespacesEnabled && !principal) {
5156
+ throw new Error("authentication required: namespaces are enabled and no principal was supplied");
5157
+ }
5151
5158
  const namespaceOverride = options.namespace?.trim() || void 0;
5152
5159
  const readableRecallNamespaces = recallNamespacesForPrincipal(
5153
5160
  principal,
@@ -12398,4 +12405,4 @@ export {
12398
12405
  resolvePersistedMemoryRelativePath,
12399
12406
  Orchestrator
12400
12407
  };
12401
- //# sourceMappingURL=chunk-XDMLTNIG.js.map
12408
+ //# sourceMappingURL=chunk-NYV435HC.js.map