@anuma/sdk 3.9.1 → 3.9.3

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.
@@ -7243,6 +7243,16 @@ interface VaultCandidateKey {
7243
7243
  declare function getVaultCandidateKeysOp(ctx: VaultMemoryOperationsContext, options?: {
7244
7244
  scopes?: string[];
7245
7245
  folderId?: string | null;
7246
+ /**
7247
+ * Typed memory (PR1) — restrict to these fact types. Omit for no filter.
7248
+ * MUST stay in step with `getAllVaultMemoriesOp`: this op backs the
7249
+ * decrypt-last search path, and the two paths are meant to return the same
7250
+ * candidate set for the same query. Dropping it here made typed recall
7251
+ * silently path-dependent (#779).
7252
+ */
7253
+ factTypes?: string[];
7254
+ /** Include archived (decayed) memories. Default `false`, as elsewhere. */
7255
+ includeArchived?: boolean;
7246
7256
  }): Promise<VaultCandidateKey[]>;
7247
7257
  /**
7248
7258
  * Column-projected embedding lookup for a KNOWN set of ids — id + embedding +
@@ -7252,7 +7262,16 @@ declare function getVaultCandidateKeysOp(ctx: VaultMemoryOperationsContext, opti
7252
7262
  * OPFS-SQLite, falling back to the standard Q query + unsafeFetchRaw on
7253
7263
  * LokiJS (Q.unsafeSqlQuery throws there).
7254
7264
  */
7255
- declare function getVaultEmbeddingsByIdsOp(ctx: VaultMemoryOperationsContext, ids: string[]): Promise<Array<{
7265
+ declare function getVaultEmbeddingsByIdsOp(ctx: VaultMemoryOperationsContext, ids: string[],
7266
+ /**
7267
+ * Must match whatever admitted these ids. The caller has already filtered the
7268
+ * candidate set; re-applying a DEFAULT-ON exclusion here silently deletes rows
7269
+ * it deliberately admitted — which is how archived rows passed the key scan
7270
+ * and then vanished at hydration (#779).
7271
+ */
7272
+ options?: {
7273
+ includeArchived?: boolean;
7274
+ }): Promise<Array<{
7256
7275
  uniqueId: string;
7257
7276
  embedding: string | null;
7258
7277
  embeddingModel: string | null;
@@ -7270,7 +7289,11 @@ declare function getVaultEmbeddingsByIdsOp(ctx: VaultMemoryOperationsContext, id
7270
7289
  * excluded exactly as they are from recall — a caller can pass any id list and
7271
7290
  * only its own live rows come back.
7272
7291
  */
7273
- declare function getVaultMemoriesByIdsOp(ctx: VaultMemoryOperationsContext, ids: string[]): Promise<StoredVaultMemory[]>;
7292
+ declare function getVaultMemoriesByIdsOp(ctx: VaultMemoryOperationsContext, ids: string[],
7293
+ /** See {@link getVaultEmbeddingsByIdsOp} — must match what admitted these ids. */
7294
+ options?: {
7295
+ includeArchived?: boolean;
7296
+ }): Promise<StoredVaultMemory[]>;
7274
7297
  declare function getAllVaultMemoryContentsOp(ctx: VaultMemoryOperationsContext, options?: {
7275
7298
  since?: Date;
7276
7299
  }): Promise<string[]>;
@@ -153,7 +153,7 @@ import {
153
153
  updateVaultMemoryOp,
154
154
  useEncryption,
155
155
  vaultMemoryToStored
156
- } from "./chunk-GDS7GHBF.mjs";
156
+ } from "./chunk-HLBQICNL.mjs";
157
157
  import {
158
158
  PiiRedactor,
159
159
  createStreamingDeAnonymizer,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  recall
3
- } from "./chunk-GDS7GHBF.mjs";
3
+ } from "./chunk-HLBQICNL.mjs";
4
4
  import "./chunk-BOY27A2C.mjs";
5
5
  import "./chunk-GYKJOWEO.mjs";
6
6
  export {
@@ -16583,10 +16583,12 @@ async function getAllVaultMemoriesOp(ctx, options) {
16583
16583
  (raw) => vaultMemoryRawToStored(raw, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner)
16584
16584
  );
16585
16585
  }
16586
- function baseVaultSql(ctx) {
16586
+ function baseVaultSql(ctx, options) {
16587
16587
  const clauses = [
16588
16588
  '"is_deleted" = 0',
16589
- '"archived_at" is null',
16589
+ // Mirrors `baseVaultConditions`' `includeArchived` branch. Defaults to
16590
+ // excluding archived rows, so every existing caller is unchanged.
16591
+ ...options?.includeArchived ? [] : ['"archived_at" is null'],
16590
16592
  `"trust_tier" is not 'quarantined'`,
16591
16593
  '"superseded_by" is null'
16592
16594
  ];
@@ -16606,7 +16608,9 @@ async function getVaultCandidateKeysOp(ctx, options) {
16606
16608
  updatedAt: new Date(raw.updated_at)
16607
16609
  });
16608
16610
  try {
16609
- const base = baseVaultSql(ctx);
16611
+ const base = baseVaultSql(ctx, {
16612
+ ...options?.includeArchived !== void 0 && { includeArchived: options.includeArchived }
16613
+ });
16610
16614
  const clauses = [base.sql];
16611
16615
  const args = [...base.args];
16612
16616
  if (options?.scopes?.length) {
@@ -16617,6 +16621,10 @@ async function getVaultCandidateKeysOp(ctx, options) {
16617
16621
  clauses.push(options.folderId === null ? '"folder_id" is null' : '"folder_id" = ?');
16618
16622
  if (options.folderId !== null) args.push(options.folderId);
16619
16623
  }
16624
+ if (options?.factTypes?.length) {
16625
+ clauses.push(`"fact_type" in (${options.factTypes.map(() => "?").join(",")})`);
16626
+ args.push(...options.factTypes);
16627
+ }
16620
16628
  const sql = `select "id", "scope", "folder_id", "embedding_model", "updated_at" from "memory_vault" where ${clauses.join(" and ")}`;
16621
16629
  const rows = await ctx.vaultMemoryCollection.query(import_watermelondb3.Q.unsafeSqlQuery(sql, args)).unsafeFetchRaw();
16622
16630
  return rows.map(mapRaw);
@@ -16625,15 +16633,18 @@ async function getVaultCandidateKeysOp(ctx, options) {
16625
16633
  "memoryVault: getVaultCandidateKeysOp projected SQL unavailable, using full-load fallback: " + (err instanceof Error ? err.message : String(err))
16626
16634
  );
16627
16635
  const conditions = [
16628
- ...baseVaultConditions(ctx),
16636
+ ...baseVaultConditions(ctx, {
16637
+ ...options?.includeArchived !== void 0 && { includeArchived: options.includeArchived }
16638
+ }),
16629
16639
  ...options?.scopes?.length ? [import_watermelondb3.Q.where("scope", import_watermelondb3.Q.oneOf(options.scopes))] : [],
16630
- ...options?.folderId !== void 0 ? [import_watermelondb3.Q.where("folder_id", options.folderId)] : []
16640
+ ...options?.folderId !== void 0 ? [import_watermelondb3.Q.where("folder_id", options.folderId)] : [],
16641
+ ...options?.factTypes?.length ? [import_watermelondb3.Q.where("fact_type", import_watermelondb3.Q.oneOf(options.factTypes))] : []
16631
16642
  ];
16632
16643
  const rows = await ctx.vaultMemoryCollection.query(...conditions).unsafeFetchRaw();
16633
16644
  return rows.map(mapRaw);
16634
16645
  }
16635
16646
  }
16636
- async function getVaultEmbeddingsByIdsOp(ctx, ids) {
16647
+ async function getVaultEmbeddingsByIdsOp(ctx, ids, options) {
16637
16648
  if (ids.length === 0) return [];
16638
16649
  const mapRaw = (raw) => ({
16639
16650
  uniqueId: raw.id,
@@ -16641,7 +16652,9 @@ async function getVaultEmbeddingsByIdsOp(ctx, ids) {
16641
16652
  embeddingModel: raw.embedding_model ?? null
16642
16653
  });
16643
16654
  try {
16644
- const base = baseVaultSql(ctx);
16655
+ const base = baseVaultSql(ctx, {
16656
+ ...options?.includeArchived !== void 0 && { includeArchived: options.includeArchived }
16657
+ });
16645
16658
  const sql = `select "id", "embedding", "embedding_model" from "memory_vault" where ${base.sql} and "id" in (${ids.map(() => "?").join(",")})`;
16646
16659
  const rows = await ctx.vaultMemoryCollection.query(import_watermelondb3.Q.unsafeSqlQuery(sql, [...base.args, ...ids])).unsafeFetchRaw();
16647
16660
  return rows.map(mapRaw);
@@ -16649,13 +16662,25 @@ async function getVaultEmbeddingsByIdsOp(ctx, ids) {
16649
16662
  getLogger().debug(
16650
16663
  "memoryVault: getVaultEmbeddingsByIdsOp projected SQL unavailable, using full-load fallback: " + (err instanceof Error ? err.message : String(err))
16651
16664
  );
16652
- const rows = await ctx.vaultMemoryCollection.query(...baseVaultConditions(ctx), import_watermelondb3.Q.where("id", import_watermelondb3.Q.oneOf(ids))).unsafeFetchRaw();
16665
+ const rows = await ctx.vaultMemoryCollection.query(
16666
+ ...baseVaultConditions(ctx, {
16667
+ ...options?.includeArchived !== void 0 && {
16668
+ includeArchived: options.includeArchived
16669
+ }
16670
+ }),
16671
+ import_watermelondb3.Q.where("id", import_watermelondb3.Q.oneOf(ids))
16672
+ ).unsafeFetchRaw();
16653
16673
  return rows.map(mapRaw);
16654
16674
  }
16655
16675
  }
16656
- async function getVaultMemoriesByIdsOp(ctx, ids) {
16676
+ async function getVaultMemoriesByIdsOp(ctx, ids, options) {
16657
16677
  if (ids.length === 0) return [];
16658
- const conditions = [...baseVaultConditions(ctx), import_watermelondb3.Q.where("id", import_watermelondb3.Q.oneOf(ids))];
16678
+ const conditions = [
16679
+ ...baseVaultConditions(ctx, {
16680
+ ...options?.includeArchived !== void 0 && { includeArchived: options.includeArchived }
16681
+ }),
16682
+ import_watermelondb3.Q.where("id", import_watermelondb3.Q.oneOf(ids))
16683
+ ];
16659
16684
  const results = await ctx.vaultMemoryCollection.query(...conditions).unsafeFetchRaw();
16660
16685
  return mapInBatches(
16661
16686
  results,
@@ -19349,6 +19374,7 @@ async function buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, qu
19349
19374
  vaultCtx,
19350
19375
  Object.keys(queryOpts).length > 0 ? queryOpts : void 0
19351
19376
  );
19377
+ const hydrateOpts = queryOpts.includeArchived ? { includeArchived: true } : void 0;
19352
19378
  const vaultSize = keys.length;
19353
19379
  if (keys.length === 0) {
19354
19380
  return { memories: [], embeddedItems: [], queryEmbedding: [], vaultSize: 0 };
@@ -19370,7 +19396,7 @@ async function buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, qu
19370
19396
  else noVectorIds.push(k2.uniqueId);
19371
19397
  }
19372
19398
  if (missIds.length > 0) {
19373
- const rows = await getVaultEmbeddingsByIdsOp(vaultCtx, missIds);
19399
+ const rows = await getVaultEmbeddingsByIdsOp(vaultCtx, missIds, hydrateOpts);
19374
19400
  const gotVector = /* @__PURE__ */ new Set();
19375
19401
  for (const r of rows) {
19376
19402
  if (!r.embedding) continue;
@@ -19395,7 +19421,7 @@ async function buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, qu
19395
19421
  `memoryVault: projected search un-embedded lane capped at ${laneIds.length}/${noVectorIds.length}`
19396
19422
  );
19397
19423
  }
19398
- const laneRows = (await getVaultMemoriesByIdsOp(vaultCtx, laneIds)).filter(
19424
+ const laneRows = (await getVaultMemoriesByIdsOp(vaultCtx, laneIds, hydrateOpts)).filter(
19399
19425
  (m) => !isEncrypted(m.content)
19400
19426
  );
19401
19427
  if (laneRows.length > 0) {
@@ -19425,7 +19451,7 @@ async function buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, qu
19425
19451
  if (keyById.has(id)) admissionSet.add(id);
19426
19452
  }
19427
19453
  }
19428
- const admittedRows = await getVaultMemoriesByIdsOp(vaultCtx, [...admissionSet]);
19454
+ const admittedRows = await getVaultMemoriesByIdsOp(vaultCtx, [...admissionSet], hydrateOpts);
19429
19455
  const memories = admittedRows.filter((m) => !isEncrypted(m.content));
19430
19456
  if (memories.length < admittedRows.length) {
19431
19457
  getLogger().warn(
@@ -19789,7 +19815,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
19789
19815
  legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
19790
19816
  );
19791
19817
  }
19792
- const { recall: recall2 } = await import("./recall-NLJNELJY.mjs");
19818
+ const { recall: recall2 } = await import("./recall-5OW4RJVC.mjs");
19793
19819
  const result = await recall2(
19794
19820
  query,
19795
19821
  { vaultCtx, embeddingOptions, vaultCache: cache },
@@ -17389,10 +17389,12 @@ async function getAllVaultMemoriesOp(ctx, options) {
17389
17389
  (raw) => vaultMemoryRawToStored(raw, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner)
17390
17390
  );
17391
17391
  }
17392
- function baseVaultSql(ctx) {
17392
+ function baseVaultSql(ctx, options) {
17393
17393
  const clauses = [
17394
17394
  '"is_deleted" = 0',
17395
- '"archived_at" is null',
17395
+ // Mirrors `baseVaultConditions`' `includeArchived` branch. Defaults to
17396
+ // excluding archived rows, so every existing caller is unchanged.
17397
+ ...options?.includeArchived ? [] : ['"archived_at" is null'],
17396
17398
  `"trust_tier" is not 'quarantined'`,
17397
17399
  '"superseded_by" is null'
17398
17400
  ];
@@ -17412,7 +17414,9 @@ async function getVaultCandidateKeysOp(ctx, options) {
17412
17414
  updatedAt: new Date(raw.updated_at)
17413
17415
  });
17414
17416
  try {
17415
- const base = baseVaultSql(ctx);
17417
+ const base = baseVaultSql(ctx, {
17418
+ ...options?.includeArchived !== void 0 && { includeArchived: options.includeArchived }
17419
+ });
17416
17420
  const clauses = [base.sql];
17417
17421
  const args = [...base.args];
17418
17422
  if (options?.scopes?.length) {
@@ -17423,6 +17427,10 @@ async function getVaultCandidateKeysOp(ctx, options) {
17423
17427
  clauses.push(options.folderId === null ? '"folder_id" is null' : '"folder_id" = ?');
17424
17428
  if (options.folderId !== null) args.push(options.folderId);
17425
17429
  }
17430
+ if (options?.factTypes?.length) {
17431
+ clauses.push(`"fact_type" in (${options.factTypes.map(() => "?").join(",")})`);
17432
+ args.push(...options.factTypes);
17433
+ }
17426
17434
  const sql = `select "id", "scope", "folder_id", "embedding_model", "updated_at" from "memory_vault" where ${clauses.join(" and ")}`;
17427
17435
  const rows = await ctx.vaultMemoryCollection.query(import_watermelondb17.Q.unsafeSqlQuery(sql, args)).unsafeFetchRaw();
17428
17436
  return rows.map(mapRaw);
@@ -17431,15 +17439,18 @@ async function getVaultCandidateKeysOp(ctx, options) {
17431
17439
  "memoryVault: getVaultCandidateKeysOp projected SQL unavailable, using full-load fallback: " + (err instanceof Error ? err.message : String(err))
17432
17440
  );
17433
17441
  const conditions = [
17434
- ...baseVaultConditions(ctx),
17442
+ ...baseVaultConditions(ctx, {
17443
+ ...options?.includeArchived !== void 0 && { includeArchived: options.includeArchived }
17444
+ }),
17435
17445
  ...options?.scopes?.length ? [import_watermelondb17.Q.where("scope", import_watermelondb17.Q.oneOf(options.scopes))] : [],
17436
- ...options?.folderId !== void 0 ? [import_watermelondb17.Q.where("folder_id", options.folderId)] : []
17446
+ ...options?.folderId !== void 0 ? [import_watermelondb17.Q.where("folder_id", options.folderId)] : [],
17447
+ ...options?.factTypes?.length ? [import_watermelondb17.Q.where("fact_type", import_watermelondb17.Q.oneOf(options.factTypes))] : []
17437
17448
  ];
17438
17449
  const rows = await ctx.vaultMemoryCollection.query(...conditions).unsafeFetchRaw();
17439
17450
  return rows.map(mapRaw);
17440
17451
  }
17441
17452
  }
17442
- async function getVaultEmbeddingsByIdsOp(ctx, ids) {
17453
+ async function getVaultEmbeddingsByIdsOp(ctx, ids, options) {
17443
17454
  if (ids.length === 0) return [];
17444
17455
  const mapRaw = (raw) => ({
17445
17456
  uniqueId: raw.id,
@@ -17447,7 +17458,9 @@ async function getVaultEmbeddingsByIdsOp(ctx, ids) {
17447
17458
  embeddingModel: raw.embedding_model ?? null
17448
17459
  });
17449
17460
  try {
17450
- const base = baseVaultSql(ctx);
17461
+ const base = baseVaultSql(ctx, {
17462
+ ...options?.includeArchived !== void 0 && { includeArchived: options.includeArchived }
17463
+ });
17451
17464
  const sql = `select "id", "embedding", "embedding_model" from "memory_vault" where ${base.sql} and "id" in (${ids.map(() => "?").join(",")})`;
17452
17465
  const rows = await ctx.vaultMemoryCollection.query(import_watermelondb17.Q.unsafeSqlQuery(sql, [...base.args, ...ids])).unsafeFetchRaw();
17453
17466
  return rows.map(mapRaw);
@@ -17455,13 +17468,25 @@ async function getVaultEmbeddingsByIdsOp(ctx, ids) {
17455
17468
  getLogger().debug(
17456
17469
  "memoryVault: getVaultEmbeddingsByIdsOp projected SQL unavailable, using full-load fallback: " + (err instanceof Error ? err.message : String(err))
17457
17470
  );
17458
- const rows = await ctx.vaultMemoryCollection.query(...baseVaultConditions(ctx), import_watermelondb17.Q.where("id", import_watermelondb17.Q.oneOf(ids))).unsafeFetchRaw();
17471
+ const rows = await ctx.vaultMemoryCollection.query(
17472
+ ...baseVaultConditions(ctx, {
17473
+ ...options?.includeArchived !== void 0 && {
17474
+ includeArchived: options.includeArchived
17475
+ }
17476
+ }),
17477
+ import_watermelondb17.Q.where("id", import_watermelondb17.Q.oneOf(ids))
17478
+ ).unsafeFetchRaw();
17459
17479
  return rows.map(mapRaw);
17460
17480
  }
17461
17481
  }
17462
- async function getVaultMemoriesByIdsOp(ctx, ids) {
17482
+ async function getVaultMemoriesByIdsOp(ctx, ids, options) {
17463
17483
  if (ids.length === 0) return [];
17464
- const conditions = [...baseVaultConditions(ctx), import_watermelondb17.Q.where("id", import_watermelondb17.Q.oneOf(ids))];
17484
+ const conditions = [
17485
+ ...baseVaultConditions(ctx, {
17486
+ ...options?.includeArchived !== void 0 && { includeArchived: options.includeArchived }
17487
+ }),
17488
+ import_watermelondb17.Q.where("id", import_watermelondb17.Q.oneOf(ids))
17489
+ ];
17465
17490
  const results = await ctx.vaultMemoryCollection.query(...conditions).unsafeFetchRaw();
17466
17491
  return mapInBatches(
17467
17492
  results,
@@ -21450,6 +21475,7 @@ async function buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, qu
21450
21475
  vaultCtx,
21451
21476
  Object.keys(queryOpts).length > 0 ? queryOpts : void 0
21452
21477
  );
21478
+ const hydrateOpts = queryOpts.includeArchived ? { includeArchived: true } : void 0;
21453
21479
  const vaultSize = keys.length;
21454
21480
  if (keys.length === 0) {
21455
21481
  return { memories: [], embeddedItems: [], queryEmbedding: [], vaultSize: 0 };
@@ -21471,7 +21497,7 @@ async function buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, qu
21471
21497
  else noVectorIds.push(k2.uniqueId);
21472
21498
  }
21473
21499
  if (missIds.length > 0) {
21474
- const rows = await getVaultEmbeddingsByIdsOp(vaultCtx, missIds);
21500
+ const rows = await getVaultEmbeddingsByIdsOp(vaultCtx, missIds, hydrateOpts);
21475
21501
  const gotVector = /* @__PURE__ */ new Set();
21476
21502
  for (const r of rows) {
21477
21503
  if (!r.embedding) continue;
@@ -21496,7 +21522,7 @@ async function buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, qu
21496
21522
  `memoryVault: projected search un-embedded lane capped at ${laneIds.length}/${noVectorIds.length}`
21497
21523
  );
21498
21524
  }
21499
- const laneRows = (await getVaultMemoriesByIdsOp(vaultCtx, laneIds)).filter(
21525
+ const laneRows = (await getVaultMemoriesByIdsOp(vaultCtx, laneIds, hydrateOpts)).filter(
21500
21526
  (m) => !isEncrypted(m.content)
21501
21527
  );
21502
21528
  if (laneRows.length > 0) {
@@ -21526,7 +21552,7 @@ async function buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, qu
21526
21552
  if (keyById.has(id)) admissionSet.add(id);
21527
21553
  }
21528
21554
  }
21529
- const admittedRows = await getVaultMemoriesByIdsOp(vaultCtx, [...admissionSet]);
21555
+ const admittedRows = await getVaultMemoriesByIdsOp(vaultCtx, [...admissionSet], hydrateOpts);
21530
21556
  const memories = admittedRows.filter((m) => !isEncrypted(m.content));
21531
21557
  if (memories.length < admittedRows.length) {
21532
21558
  getLogger().warn(
@@ -125,7 +125,7 @@ import {
125
125
  updateVaultMemoryOp,
126
126
  upsertMessageOp,
127
127
  vaultMemoryToStored
128
- } from "./chunk-QC4WHNIJ.mjs";
128
+ } from "./chunk-ICGTS7X6.mjs";
129
129
  import {
130
130
  createStreamingDeAnonymizer,
131
131
  resolvePiiRedactor
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  recall
3
- } from "./chunk-QC4WHNIJ.mjs";
3
+ } from "./chunk-ICGTS7X6.mjs";
4
4
  import "./chunk-MIXEASUP.mjs";
5
5
  import "./chunk-3RPGXXPZ.mjs";
6
6
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anuma/sdk",
3
- "version": "3.9.1",
3
+ "version": "3.9.3",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -156,7 +156,7 @@
156
156
  "homepage": "https://github.com/anuma-ai/sdk#readme",
157
157
  "packageManager": "pnpm@10.23.0",
158
158
  "dependencies": {
159
- "@anuma/portal": "1.0.0-next.20260724210432",
159
+ "@anuma/portal": "1.0.0-next.20260726011521",
160
160
  "@babel/parser": "^7.29.2",
161
161
  "@babel/types": "^7.29.0",
162
162
  "ai": "6.0.202",