@theokit/sdk-memory 0.2.0 → 0.2.2

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/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { mkdir, readFile, readdir, stat, access, unlink } from 'fs/promises';
2
2
  import { join, resolve, relative } from 'path';
3
3
  import { Security } from '@theokit/sdk';
4
- import { replaceFileAtomic, withCwdMutex, atomicWriteJson, openSqliteResilient, sanitizeFts5Query } from '@theokit/sdk/internal/persistence';
4
+ import { replaceFileAtomic, withCwdMutex, atomicWriteJson, openSqliteResilient, sanitizeFts5Query } from '@theokit/sdk/persistence';
5
5
  import { sanitizeIdentifier, safePathJoin } from '@theokit/sdk/path-safety';
6
6
  import { createHash } from 'crypto';
7
7
  import { AuthenticationError, RateLimitError, ConfigurationError, NetworkError, UnknownAgentError } from '@theokit/sdk/errors';
@@ -384,7 +384,12 @@ async function runActiveMemory(args) {
384
384
  hits: []
385
385
  });
386
386
  }
387
- const cached = args.cache?.get(args.userText, cfg.queryMode);
387
+ const tenantCtx = {
388
+ namespace: args.namespace,
389
+ userId: args.userId,
390
+ scope: args.scope
391
+ };
392
+ const cached = args.cache?.get(args.userText, cfg.queryMode, tenantCtx);
388
393
  if (cached !== void 0) return endRecallSpan(span, args, cached);
389
394
  const query = buildQuery(args.userText, args.priorMessages, cfg.queryMode, cfg.recentUserTurns);
390
395
  if (query.trim().length === 0) {
@@ -481,7 +486,12 @@ function notifyBreaker(breaker, key, status) {
481
486
  else if (status === "ok" || status === "no-recall") breaker.recordSuccess(key);
482
487
  }
483
488
  async function finalize(args, queryMode, result) {
484
- args.cache?.set(args.userText, queryMode, result);
489
+ const tenantCtx = {
490
+ namespace: args.namespace,
491
+ userId: args.userId,
492
+ scope: args.scope
493
+ };
494
+ args.cache?.set(args.userText, queryMode, result, tenantCtx);
485
495
  if (args.persistTranscripts === true && args.cwd !== void 0) {
486
496
  await persistActiveMemoryTranscript(args.cwd, {
487
497
  runId: args.runId ?? `run-${Date.now()}`,