@remnic/core 9.3.676 → 9.3.677

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 (62) hide show
  1. package/dist/access-cli.js +16 -16
  2. package/dist/access-http.js +13 -13
  3. package/dist/access-mcp.js +12 -12
  4. package/dist/access-schema.js +3 -3
  5. package/dist/access-service.js +10 -10
  6. package/dist/{chunk-OG7A6AZX.js → chunk-2DKXY243.js} +4 -4
  7. package/dist/{chunk-Q5ZU3RNY.js → chunk-57ME5VSI.js} +4 -4
  8. package/dist/{chunk-SDLJ2W7S.js → chunk-7UTCHQTB.js} +2 -2
  9. package/dist/{chunk-T2AOOHDA.js → chunk-ACYX37IM.js} +2 -2
  10. package/dist/{chunk-ZLINDOBG.js → chunk-CZMLLVU2.js} +3 -3
  11. package/dist/{chunk-DOCTITOP.js → chunk-DGEZKYVI.js} +4 -4
  12. package/dist/{chunk-Q6MIDQEL.js → chunk-EQYP3HA6.js} +2 -2
  13. package/dist/{chunk-52LZ42LI.js → chunk-ERA5RSMZ.js} +1 -1
  14. package/dist/{chunk-IPLYGWQF.js → chunk-KQAFEZQX.js} +5 -5
  15. package/dist/{chunk-SF45RQDX.js → chunk-RP64QP7G.js} +3 -3
  16. package/dist/{chunk-QLRYXOAD.js → chunk-UDJLF3BO.js} +2 -2
  17. package/dist/{chunk-R37A3BEW.js → chunk-YEQBJXVO.js} +111 -101
  18. package/dist/chunk-YEQBJXVO.js.map +1 -0
  19. package/dist/{chunk-B55KFEGS.js → chunk-YJ4J2JJ2.js} +10 -10
  20. package/dist/{chunk-XVVEKF5I.js → chunk-Z56KDLDK.js} +20 -20
  21. package/dist/{chunk-OUWAQVDJ.js → chunk-Z6SEG36L.js} +4 -4
  22. package/dist/cli.js +22 -22
  23. package/dist/{coding-graph-types-Dd2tGrnm.d.ts → coding/coding-graph-types.d.ts} +1 -1
  24. package/dist/coding/coding-graph-types.js +10 -0
  25. package/dist/coding/coding-graph-types.js.map +1 -0
  26. package/dist/coding/optional-coding-graph.d.ts +2 -2
  27. package/dist/coding/optional-coding-graph.js +1 -1
  28. package/dist/contradiction/index.js +4 -4
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.js +33 -33
  31. package/dist/lcm/index.js +3 -3
  32. package/dist/namespaces/migrate.js +8 -8
  33. package/dist/namespaces/search.js +7 -7
  34. package/dist/operator-toolkit.js +9 -9
  35. package/dist/orchestrator.js +13 -13
  36. package/dist/search/factory.js +6 -6
  37. package/dist/search/index.js +11 -11
  38. package/dist/search/lancedb-backend.js +2 -2
  39. package/dist/search/meilisearch-backend.js +2 -2
  40. package/dist/search/orama-backend.js +2 -2
  41. package/dist/transfer/autodetect.js +1 -1
  42. package/dist/transfer/backup.js +1 -1
  43. package/dist/transfer/capsule-export.js +2 -2
  44. package/package.json +7 -2
  45. package/src/orchestrator.ts +50 -197
  46. package/src/scopes/scope-plan.test.ts +360 -0
  47. package/src/scopes/scope-plan.ts +320 -0
  48. package/dist/chunk-R37A3BEW.js.map +0 -1
  49. /package/dist/{chunk-OG7A6AZX.js.map → chunk-2DKXY243.js.map} +0 -0
  50. /package/dist/{chunk-Q5ZU3RNY.js.map → chunk-57ME5VSI.js.map} +0 -0
  51. /package/dist/{chunk-SDLJ2W7S.js.map → chunk-7UTCHQTB.js.map} +0 -0
  52. /package/dist/{chunk-T2AOOHDA.js.map → chunk-ACYX37IM.js.map} +0 -0
  53. /package/dist/{chunk-ZLINDOBG.js.map → chunk-CZMLLVU2.js.map} +0 -0
  54. /package/dist/{chunk-DOCTITOP.js.map → chunk-DGEZKYVI.js.map} +0 -0
  55. /package/dist/{chunk-Q6MIDQEL.js.map → chunk-EQYP3HA6.js.map} +0 -0
  56. /package/dist/{chunk-52LZ42LI.js.map → chunk-ERA5RSMZ.js.map} +0 -0
  57. /package/dist/{chunk-IPLYGWQF.js.map → chunk-KQAFEZQX.js.map} +0 -0
  58. /package/dist/{chunk-SF45RQDX.js.map → chunk-RP64QP7G.js.map} +0 -0
  59. /package/dist/{chunk-QLRYXOAD.js.map → chunk-UDJLF3BO.js.map} +0 -0
  60. /package/dist/{chunk-B55KFEGS.js.map → chunk-YJ4J2JJ2.js.map} +0 -0
  61. /package/dist/{chunk-XVVEKF5I.js.map → chunk-Z56KDLDK.js.map} +0 -0
  62. /package/dist/{chunk-OUWAQVDJ.js.map → chunk-Z6SEG36L.js.map} +0 -0
@@ -5,6 +5,9 @@ import {
5
5
  syncWearableSource,
6
6
  wearableSourceLabel
7
7
  } from "./chunk-4SKKVWLQ.js";
8
+ import {
9
+ migrateFromEngram
10
+ } from "./chunk-7HYPN2GC.js";
8
11
  import {
9
12
  ensureContradictionScanCron,
10
13
  ensureDaySummaryCron,
@@ -14,15 +17,9 @@ import {
14
17
  ensureProceduralMiningCron,
15
18
  graphEdgeDecayCadenceToCronExpr
16
19
  } from "./chunk-666A3MOW.js";
17
- import {
18
- migrateFromEngram
19
- } from "./chunk-7HYPN2GC.js";
20
20
  import {
21
21
  LcmEngine
22
22
  } from "./chunk-3IE22DJ2.js";
23
- import {
24
- chunkTranscriptEntries
25
- } from "./chunk-TECVW3JP.js";
26
23
  import {
27
24
  cleanupConversationChunks
28
25
  } from "./chunk-T2PO5MUF.js";
@@ -33,6 +30,9 @@ import {
33
30
  import {
34
31
  SharedContextManager
35
32
  } from "./chunk-DRD2Q7HQ.js";
33
+ import {
34
+ chunkTranscriptEntries
35
+ } from "./chunk-TECVW3JP.js";
36
36
  import {
37
37
  extractTopics
38
38
  } from "./chunk-UHGBNIOS.js";
@@ -206,12 +206,12 @@ import {
206
206
  parseConsolidationResponse,
207
207
  parseOperatorAwareConsolidationResponse
208
208
  } from "./chunk-V4ZHKCGA.js";
209
- import {
210
- RoutingRulesStore
211
- } from "./chunk-X6IRLNOO.js";
212
209
  import {
213
210
  normalizeReplaySessionKey
214
211
  } from "./chunk-2PRQG7PV.js";
212
+ import {
213
+ RoutingRulesStore
214
+ } from "./chunk-X6IRLNOO.js";
215
215
  import {
216
216
  compareVerifiedEpisodeResults,
217
217
  searchVerifiedEpisodes
@@ -322,11 +322,11 @@ import {
322
322
  } from "./chunk-6VP3YUCS.js";
323
323
  import {
324
324
  NamespaceSearchRouter
325
- } from "./chunk-Q6MIDQEL.js";
325
+ } from "./chunk-EQYP3HA6.js";
326
326
  import {
327
327
  createConversationIndexRuntime,
328
328
  createSearchBackend
329
- } from "./chunk-B55KFEGS.js";
329
+ } from "./chunk-YJ4J2JJ2.js";
330
330
  import {
331
331
  NoopSearchBackend
332
332
  } from "./chunk-CYEPCZN5.js";
@@ -3488,6 +3488,81 @@ function itemCountForNamespace(result, namespace) {
3488
3488
  return result?.itemCount;
3489
3489
  }
3490
3490
 
3491
+ // src/scopes/scope-plan.ts
3492
+ function resolveScopePlan(options) {
3493
+ const { config, sessionKey } = options;
3494
+ const namespaceOverride = options.namespace?.trim() || void 0;
3495
+ const principal = typeof options.principalOverride === "string" && options.principalOverride.length > 0 ? options.principalOverride : resolvePrincipal(sessionKey, config);
3496
+ const namespaceOverrideReadable = namespaceOverride !== void 0 && canReadNamespace(principal, namespaceOverride, config);
3497
+ const readableRecallNamespaces = recallNamespacesForPrincipal(principal, config);
3498
+ const namespacesEnabled = options.namespacesEnabled;
3499
+ const codingOverlay = namespaceOverrideReadable || !namespacesEnabled ? null : resolveCodingNamespaceOverlay(
3500
+ options.codingContext ?? null,
3501
+ config.codingMode,
3502
+ config.defaultNamespace
3503
+ );
3504
+ const principalSelfNamespace = defaultNamespaceForPrincipal(principal, config);
3505
+ const codingSelfNamespace = codingOverlay ? combineNamespaces(principalSelfNamespace, codingOverlay.namespace) : null;
3506
+ const scopeProfilePlan = namespaceOverrideReadable ? null : resolveScopeProfilePlan({
3507
+ config,
3508
+ principal,
3509
+ codingContext: options.codingContext ?? null,
3510
+ codingOverlay
3511
+ });
3512
+ const profileEffectiveNamespace = scopeProfilePlan?.writeNamespace || scopeProfilePlan?.readNamespaces[0];
3513
+ const baseNamespace = namespaceOverrideReadable ? namespaceOverride : profileEffectiveNamespace ?? codingSelfNamespace ?? principalSelfNamespace;
3514
+ let readNamespaces;
3515
+ if (namespaceOverrideReadable) {
3516
+ readNamespaces = [namespaceOverride];
3517
+ } else if (scopeProfilePlan) {
3518
+ readNamespaces = expandScopeProfileReadNamespaces({
3519
+ profilePlan: scopeProfilePlan,
3520
+ principalSelfNamespace: scopeProfilePlan.baseNamespace,
3521
+ config,
3522
+ principal,
3523
+ codingOverlay,
3524
+ legacyRecallNamespaces: readableRecallNamespaces
3525
+ });
3526
+ } else if (codingOverlay && codingSelfNamespace) {
3527
+ const mapped = readableRecallNamespaces.map(
3528
+ (ns) => ns === principalSelfNamespace ? codingSelfNamespace : ns
3529
+ );
3530
+ const fallbackNs = codingOverlay.readFallbacks.map(
3531
+ (fallback) => combineNamespaces(principalSelfNamespace, fallback)
3532
+ );
3533
+ readNamespaces = Array.from(/* @__PURE__ */ new Set([...mapped, ...fallbackNs]));
3534
+ } else {
3535
+ readNamespaces = readableRecallNamespaces;
3536
+ }
3537
+ const readFallbacks = codingOverlay ? codingOverlay.readFallbacks.map((fb) => combineNamespaces(principalSelfNamespace, fb)) : [];
3538
+ const codingOverlaySelfReadable = codingOverlay !== null && (scopeProfilePlan ? scopeProfilePlan.layers.some((layer) => layer.id === "userProject" && layer.readable) : readableRecallNamespaces.includes(principalSelfNamespace));
3539
+ let lcmReadNamespaces;
3540
+ if (namespaceOverrideReadable) {
3541
+ lcmReadNamespaces = [namespaceOverride];
3542
+ } else if (scopeProfilePlan) {
3543
+ lcmReadNamespaces = readNamespaces;
3544
+ } else if (codingOverlay && codingSelfNamespace && codingOverlaySelfReadable) {
3545
+ const fallbackNs = codingOverlay.readFallbacks.map(
3546
+ (fallback) => combineNamespaces(principalSelfNamespace, fallback)
3547
+ );
3548
+ lcmReadNamespaces = [codingSelfNamespace, ...fallbackNs];
3549
+ } else {
3550
+ lcmReadNamespaces = [config.defaultNamespace];
3551
+ }
3552
+ const lcmReadSessionIds = scopeProfilePlan && !sessionKey ? [] : lcmReadSessionIdsForNamespaces(lcmReadNamespaces, sessionKey, config.defaultNamespace);
3553
+ return {
3554
+ principal,
3555
+ namespaceOverride: namespaceOverrideReadable ? namespaceOverride : void 0,
3556
+ baseNamespace,
3557
+ readNamespaces,
3558
+ readFallbacks,
3559
+ lcmReadNamespaces,
3560
+ lcmReadSessionIds,
3561
+ codingOverlay: codingOverlay ? { namespace: codingOverlay.namespace, readFallbacks: codingOverlay.readFallbacks } : null,
3562
+ scopeProfilePlan
3563
+ };
3564
+ }
3565
+
3491
3566
  // src/orchestrator.ts
3492
3567
  var BulkImportBatchPartialFailureError = class extends Error {
3493
3568
  partialResult;
@@ -7097,7 +7172,8 @@ ${r.snippet.trim()}
7097
7172
  options.abortSignal?.addEventListener("abort", onAbort, { once: true });
7098
7173
  }
7099
7174
  const principal = typeof options.principalOverride === "string" && options.principalOverride.length > 0 ? options.principalOverride : resolvePrincipal(sessionKey, this.config);
7100
- if (this.config.namespacesEnabled && !principal) {
7175
+ const namespacesEnabled = this.config.namespacesEnabled;
7176
+ if (namespacesEnabled && !principal) {
7101
7177
  throw new Error("authentication required: namespaces are enabled and no principal was supplied");
7102
7178
  }
7103
7179
  let initGateTimeoutHandle = null;
@@ -7165,7 +7241,8 @@ ${r.snippet.trim()}
7165
7241
  sessionKey,
7166
7242
  options.namespace?.trim() || void 0,
7167
7243
  options.principalOverride,
7168
- caps
7244
+ caps,
7245
+ namespacesEnabled
7169
7246
  );
7170
7247
  } catch (err) {
7171
7248
  log.debug(`direct-answer observation setup failed: ${err}`);
@@ -7220,44 +7297,19 @@ ${r.snippet.trim()}
7220
7297
  if (timeoutHandle) clearTimeout(timeoutHandle);
7221
7298
  }
7222
7299
  }
7223
- enqueueDirectAnswerObservation(prompt, sessionKey, namespaceOverride, principalOverride, caps) {
7300
+ enqueueDirectAnswerObservation(prompt, sessionKey, namespaceOverride, principalOverride, caps, namespacesEnabled) {
7224
7301
  const expectedSnapshot = this.lastRecall.get(sessionKey);
7225
7302
  if (expectedSnapshot === null) return;
7226
7303
  if (expectedSnapshot.plannerMode === "no_recall") return;
7227
- const principal = principalOverride ?? resolvePrincipal(sessionKey, this.config);
7228
- const observationCodingOverlay = namespaceOverride && canReadNamespace(principal, namespaceOverride, this.config) ? null : this.applyCodingRecallOverlay(sessionKey);
7229
- const observationPrincipalSelf = defaultNamespaceForPrincipal(principal, this.config);
7230
- const observationCodingSelf = observationCodingOverlay ? combineNamespaces(observationPrincipalSelf, observationCodingOverlay.namespace) : null;
7231
- const observationScopeProfilePlan = namespaceOverride && canReadNamespace(principal, namespaceOverride, this.config) ? null : resolveScopeProfilePlan({
7304
+ const observationScopePlan = resolveScopePlan({
7232
7305
  config: this.config,
7233
- principal,
7306
+ sessionKey,
7307
+ namespace: namespaceOverride,
7308
+ principalOverride,
7234
7309
  codingContext: sessionKey ? this.getCodingContextForSession(sessionKey) : null,
7235
- codingOverlay: observationCodingOverlay
7310
+ namespacesEnabled
7236
7311
  });
7237
- let observationNamespaces;
7238
- if (namespaceOverride && canReadNamespace(principal, namespaceOverride, this.config)) {
7239
- observationNamespaces = [namespaceOverride];
7240
- } else if (observationScopeProfilePlan) {
7241
- observationNamespaces = expandScopeProfileReadNamespaces({
7242
- profilePlan: observationScopeProfilePlan,
7243
- principalSelfNamespace: observationScopeProfilePlan.baseNamespace,
7244
- config: this.config,
7245
- principal,
7246
- codingOverlay: observationCodingOverlay,
7247
- legacyRecallNamespaces: recallNamespacesForPrincipal(principal, this.config)
7248
- });
7249
- } else if (observationCodingOverlay && observationCodingSelf) {
7250
- const base = recallNamespacesForPrincipal(principal, this.config);
7251
- const mapped = base.map(
7252
- (ns) => ns === observationPrincipalSelf ? observationCodingSelf : ns
7253
- );
7254
- const fallbackNs = observationCodingOverlay.readFallbacks.map(
7255
- (fallback) => combineNamespaces(observationPrincipalSelf, fallback)
7256
- );
7257
- observationNamespaces = Array.from(/* @__PURE__ */ new Set([...mapped, ...fallbackNs]));
7258
- } else {
7259
- observationNamespaces = recallNamespacesForPrincipal(principal, this.config);
7260
- }
7312
+ const observationNamespaces = observationScopePlan.readNamespaces;
7261
7313
  const observationQueryPolicy = buildRecallQueryPolicy(prompt, sessionKey, {
7262
7314
  cronRecallPolicyEnabled: this.config.cronRecallPolicyEnabled,
7263
7315
  cronRecallNormalizedQueryMaxChars: this.config.cronRecallNormalizedQueryMaxChars,
@@ -8385,72 +8437,30 @@ ${r.snippet.trim()}
8385
8437
  );
8386
8438
  const embeddingFetchLimit = computedFetchLimit;
8387
8439
  const principal = typeof options.principalOverride === "string" && options.principalOverride.length > 0 ? options.principalOverride : resolvePrincipal(sessionKey, this.config);
8388
- if (this.config.namespacesEnabled && !principal) {
8440
+ const namespacesEnabled = this.config.namespacesEnabled;
8441
+ if (namespacesEnabled && !principal) {
8389
8442
  throw new Error("authentication required: namespaces are enabled and no principal was supplied");
8390
8443
  }
8391
8444
  const namespaceOverride = options.namespace?.trim() || void 0;
8392
- const readableRecallNamespaces = recallNamespacesForPrincipal(
8393
- principal,
8394
- this.config
8395
- );
8396
8445
  if (namespaceOverride && !canReadNamespace(principal, namespaceOverride, this.config)) {
8397
8446
  throw new Error(
8398
8447
  `namespace override is not readable: ${namespaceOverride}`
8399
8448
  );
8400
8449
  }
8401
- const codingOverlay = namespaceOverride ? null : this.applyCodingRecallOverlay(sessionKey);
8402
- const principalSelfNamespace = defaultNamespaceForPrincipal(principal, this.config);
8403
- const codingSelfNamespace = codingOverlay ? combineNamespaces(principalSelfNamespace, codingOverlay.namespace) : null;
8404
- const scopeProfilePlan = namespaceOverride ? null : resolveScopeProfilePlan({
8450
+ const scopePlan = resolveScopePlan({
8405
8451
  config: this.config,
8406
- principal,
8452
+ sessionKey,
8453
+ namespace: options.namespace,
8454
+ principalOverride: typeof options.principalOverride === "string" && options.principalOverride.length > 0 ? options.principalOverride : void 0,
8407
8455
  codingContext: sessionKey ? this.getCodingContextForSession(sessionKey) : null,
8408
- codingOverlay
8456
+ namespacesEnabled
8409
8457
  });
8410
- const profileEffectiveNamespace = scopeProfilePlan?.writeNamespace || scopeProfilePlan?.readNamespaces[0];
8411
- const selfNamespace = namespaceOverride ?? profileEffectiveNamespace ?? codingSelfNamespace ?? principalSelfNamespace;
8412
- let recallNamespaces;
8413
- if (namespaceOverride) {
8414
- recallNamespaces = [namespaceOverride];
8415
- } else if (scopeProfilePlan) {
8416
- recallNamespaces = expandScopeProfileReadNamespaces({
8417
- profilePlan: scopeProfilePlan,
8418
- principalSelfNamespace: scopeProfilePlan.baseNamespace,
8419
- config: this.config,
8420
- principal,
8421
- codingOverlay,
8422
- legacyRecallNamespaces: readableRecallNamespaces
8423
- });
8424
- } else if (codingOverlay && codingSelfNamespace) {
8425
- const mapped = readableRecallNamespaces.map(
8426
- (ns) => ns === principalSelfNamespace ? codingSelfNamespace : ns
8427
- );
8428
- const fallbackNs = codingOverlay.readFallbacks.map(
8429
- (fallback) => combineNamespaces(principalSelfNamespace, fallback)
8430
- );
8431
- recallNamespaces = Array.from(/* @__PURE__ */ new Set([...mapped, ...fallbackNs]));
8432
- } else {
8433
- recallNamespaces = readableRecallNamespaces;
8434
- }
8435
- const codingOverlaySelfReadable = codingOverlay !== null && (scopeProfilePlan ? scopeProfilePlan.layers.some((layer) => layer.id === "userProject" && layer.readable) : readableRecallNamespaces.includes(principalSelfNamespace));
8436
- let lcmReadNamespaces;
8437
- if (namespaceOverride) {
8438
- lcmReadNamespaces = [namespaceOverride];
8439
- } else if (scopeProfilePlan) {
8440
- lcmReadNamespaces = recallNamespaces;
8441
- } else if (codingOverlay && codingSelfNamespace && codingOverlaySelfReadable) {
8442
- const fallbackNs = codingOverlay.readFallbacks.map(
8443
- (fallback) => combineNamespaces(principalSelfNamespace, fallback)
8444
- );
8445
- lcmReadNamespaces = [codingSelfNamespace, ...fallbackNs];
8446
- } else {
8447
- lcmReadNamespaces = [this.config.defaultNamespace];
8448
- }
8449
- const lcmReadSessionIds = scopeProfilePlan && !sessionKey ? [] : lcmReadSessionIdsForNamespaces(
8450
- lcmReadNamespaces,
8451
- sessionKey,
8452
- this.config.defaultNamespace
8453
- );
8458
+ const {
8459
+ readNamespaces: recallNamespaces,
8460
+ baseNamespace: selfNamespace,
8461
+ scopeProfilePlan,
8462
+ lcmReadSessionIds
8463
+ } = scopePlan;
8454
8464
  const firstNonEmptyLcmRead = async (read, isEmpty, empty) => {
8455
8465
  for (const lcmSessionId of lcmReadSessionIds) {
8456
8466
  const value = await read(lcmSessionId);
@@ -17387,4 +17397,4 @@ export {
17387
17397
  resolvePersistedMemoryRelativePath,
17388
17398
  Orchestrator
17389
17399
  };
17390
- //# sourceMappingURL=chunk-R37A3BEW.js.map
17400
+ //# sourceMappingURL=chunk-YEQBJXVO.js.map