@anuma/sdk 10.2.5 → 10.2.6

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.
@@ -982,11 +982,11 @@ async function requestPortalJson(req, endpoint, controller, deadlineAt) {
982
982
  let value;
983
983
  try {
984
984
  value = JSON.parse(candidate);
985
- } catch (err) {
985
+ } catch {
986
986
  return {
987
987
  kind: "retryable",
988
988
  code: "invalid-json",
989
- reason: `completion was not valid JSON: ${err.message}`
989
+ reason: "invalid-json"
990
990
  };
991
991
  }
992
992
  if (value === null) {
@@ -4,7 +4,7 @@ import {
4
4
  notifyConsolidationFallback,
5
5
  requiresResponsesTransport,
6
6
  resolvePiiRedactor
7
- } from "./chunk-ZIN4E7MR.mjs";
7
+ } from "./chunk-4SOUKJD5.mjs";
8
8
  import "./chunk-GYKJOWEO.mjs";
9
9
 
10
10
  // src/lib/memory/consolidate.ts
@@ -1073,11 +1073,11 @@ async function requestPortalJson(req, endpoint, controller, deadlineAt) {
1073
1073
  let value;
1074
1074
  try {
1075
1075
  value = JSON.parse(candidate);
1076
- } catch (err) {
1076
+ } catch {
1077
1077
  return {
1078
1078
  kind: "retryable",
1079
1079
  code: "invalid-json",
1080
- reason: `completion was not valid JSON: ${err.message}`
1080
+ reason: "invalid-json"
1081
1081
  };
1082
1082
  }
1083
1083
  if (value === null) {
@@ -17756,7 +17756,7 @@ async function backfillMemoryTopicsOp(ctx, memoryIds) {
17756
17756
  const chunkIds = uniqueIds.slice(i, i + CHUNK);
17757
17757
  await ctx.database.write(async () => {
17758
17758
  await assertCanWrite2(ctx);
17759
- const writes = [];
17759
+ const records = [];
17760
17760
  for (const id2 of chunkIds) {
17761
17761
  let record2;
17762
17762
  try {
@@ -17766,13 +17766,40 @@ async function backfillMemoryTopicsOp(ctx, memoryIds) {
17766
17766
  }
17767
17767
  if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2)) continue;
17768
17768
  if (parseTopics(record2.topics) !== null) continue;
17769
- const links2 = await entityCtx.memoryEntityCollection.query(import_watermelondb21.Q.where("memory_id", id2)).unsafeFetchRaw();
17770
- const entityIds = links2.map((l) => String(l.entity_id));
17771
- if (entityIds.length === 0) continue;
17772
- const entities = await entityCtx.entityCollection.query(import_watermelondb21.Q.where("id", import_watermelondb21.Q.oneOf(entityIds))).fetch();
17773
- if (entities.length === 0) continue;
17769
+ records.push(record2);
17770
+ }
17771
+ if (records.length === 0) return;
17772
+ const links2 = await entityCtx.memoryEntityCollection.query(import_watermelondb21.Q.where("memory_id", import_watermelondb21.Q.oneOf(records.map((record2) => record2.id)))).unsafeFetchRaw();
17773
+ const entityIds = Array.from(new Set(links2.map((link) => String(link.entity_id))));
17774
+ const entitiesById = /* @__PURE__ */ new Map();
17775
+ for (let j = 0; j < entityIds.length; j += CHUNK) {
17776
+ const entities = await entityCtx.entityCollection.query(import_watermelondb21.Q.where("id", import_watermelondb21.Q.oneOf(entityIds.slice(j, j + CHUNK)))).fetch();
17777
+ for (const entity of entities) entitiesById.set(entity.id, entity);
17778
+ }
17779
+ const entitiesByMemory = /* @__PURE__ */ new Map();
17780
+ for (const link of links2) {
17781
+ const entity = entitiesById.get(String(link.entity_id));
17782
+ if (!entity) continue;
17783
+ const memoryId = String(link.memory_id);
17784
+ let entities = entitiesByMemory.get(memoryId);
17785
+ if (!entities) {
17786
+ entities = /* @__PURE__ */ new Set();
17787
+ entitiesByMemory.set(memoryId, entities);
17788
+ }
17789
+ entities.add(entity);
17790
+ }
17791
+ const writes = [];
17792
+ for (const record2 of records) {
17793
+ const entities = entitiesByMemory.get(record2.id);
17794
+ if (!entities?.size) continue;
17774
17795
  const source = record2.topicsUserManaged ? "user" : "auto";
17775
- const write = await resolveMemoryTopicsWrite(entityCtx, id2, entities, [], source);
17796
+ const write = await resolveMemoryTopicsWrite(
17797
+ entityCtx,
17798
+ record2.id,
17799
+ Array.from(entities),
17800
+ [],
17801
+ source
17802
+ );
17776
17803
  if (write) writes.push(write);
17777
17804
  }
17778
17805
  if (writes.length === 0) return;
@@ -20,7 +20,7 @@ import {
20
20
  taskTypeHeader,
21
21
  validateEndpointOverride,
22
22
  withInternalFlowMarker
23
- } from "./chunk-ZIN4E7MR.mjs";
23
+ } from "./chunk-4SOUKJD5.mjs";
24
24
  import {
25
25
  BASE_URL,
26
26
  MCP_R2_DOMAIN,
@@ -16093,7 +16093,7 @@ async function backfillMemoryTopicsOp(ctx, memoryIds) {
16093
16093
  const chunkIds = uniqueIds.slice(i, i + CHUNK);
16094
16094
  await ctx.database.write(async () => {
16095
16095
  await assertCanWrite2(ctx);
16096
- const writes = [];
16096
+ const records = [];
16097
16097
  for (const id2 of chunkIds) {
16098
16098
  let record2;
16099
16099
  try {
@@ -16103,13 +16103,40 @@ async function backfillMemoryTopicsOp(ctx, memoryIds) {
16103
16103
  }
16104
16104
  if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2)) continue;
16105
16105
  if (parseTopics(record2.topics) !== null) continue;
16106
- const links2 = await entityCtx.memoryEntityCollection.query(Q6.where("memory_id", id2)).unsafeFetchRaw();
16107
- const entityIds = links2.map((l) => String(l.entity_id));
16108
- if (entityIds.length === 0) continue;
16109
- const entities = await entityCtx.entityCollection.query(Q6.where("id", Q6.oneOf(entityIds))).fetch();
16110
- if (entities.length === 0) continue;
16106
+ records.push(record2);
16107
+ }
16108
+ if (records.length === 0) return;
16109
+ const links2 = await entityCtx.memoryEntityCollection.query(Q6.where("memory_id", Q6.oneOf(records.map((record2) => record2.id)))).unsafeFetchRaw();
16110
+ const entityIds = Array.from(new Set(links2.map((link) => String(link.entity_id))));
16111
+ const entitiesById = /* @__PURE__ */ new Map();
16112
+ for (let j = 0; j < entityIds.length; j += CHUNK) {
16113
+ const entities = await entityCtx.entityCollection.query(Q6.where("id", Q6.oneOf(entityIds.slice(j, j + CHUNK)))).fetch();
16114
+ for (const entity of entities) entitiesById.set(entity.id, entity);
16115
+ }
16116
+ const entitiesByMemory = /* @__PURE__ */ new Map();
16117
+ for (const link of links2) {
16118
+ const entity = entitiesById.get(String(link.entity_id));
16119
+ if (!entity) continue;
16120
+ const memoryId = String(link.memory_id);
16121
+ let entities = entitiesByMemory.get(memoryId);
16122
+ if (!entities) {
16123
+ entities = /* @__PURE__ */ new Set();
16124
+ entitiesByMemory.set(memoryId, entities);
16125
+ }
16126
+ entities.add(entity);
16127
+ }
16128
+ const writes = [];
16129
+ for (const record2 of records) {
16130
+ const entities = entitiesByMemory.get(record2.id);
16131
+ if (!entities?.size) continue;
16111
16132
  const source = record2.topicsUserManaged ? "user" : "auto";
16112
- const write = await resolveMemoryTopicsWrite(entityCtx, id2, entities, [], source);
16133
+ const write = await resolveMemoryTopicsWrite(
16134
+ entityCtx,
16135
+ record2.id,
16136
+ Array.from(entities),
16137
+ [],
16138
+ source
16139
+ );
16113
16140
  if (write) writes.push(write);
16114
16141
  }
16115
16142
  if (writes.length === 0) return;
@@ -19639,7 +19666,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
19639
19666
  content: m.content,
19640
19667
  similarity: m.similarity
19641
19668
  }));
19642
- const { consolidateMemory: doConsolidate } = await import("./consolidate-4WLZMXOS.mjs");
19669
+ const { consolidateMemory: doConsolidate } = await import("./consolidate-7QUL3TOE.mjs");
19643
19670
  const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
19644
19671
  if (decision.action === "create") return decision.fallbackReason ? null : { create: true };
19645
19672
  if (decision.action === "supersede" && decision.content) {
@@ -982,11 +982,11 @@ async function requestPortalJson(req, endpoint, controller, deadlineAt) {
982
982
  let value;
983
983
  try {
984
984
  value = JSON.parse(candidate);
985
- } catch (err) {
985
+ } catch {
986
986
  return {
987
987
  kind: "retryable",
988
988
  code: "invalid-json",
989
- reason: `completion was not valid JSON: ${err.message}`
989
+ reason: "invalid-json"
990
990
  };
991
991
  }
992
992
  if (value === null) {
@@ -4,7 +4,7 @@ import {
4
4
  notifyConsolidationFallback,
5
5
  requiresResponsesTransport,
6
6
  resolvePiiRedactor
7
- } from "./chunk-7JYVPYGQ.mjs";
7
+ } from "./chunk-6ANL34M3.mjs";
8
8
  import "./chunk-GYKJOWEO.mjs";
9
9
 
10
10
  // src/lib/memory/consolidate.ts
@@ -1073,11 +1073,11 @@ async function requestPortalJson(req, endpoint, controller, deadlineAt) {
1073
1073
  let value;
1074
1074
  try {
1075
1075
  value = JSON.parse(candidate);
1076
- } catch (err) {
1076
+ } catch {
1077
1077
  return {
1078
1078
  kind: "retryable",
1079
1079
  code: "invalid-json",
1080
- reason: `completion was not valid JSON: ${err.message}`
1080
+ reason: "invalid-json"
1081
1081
  };
1082
1082
  }
1083
1083
  if (value === null) {
@@ -19590,7 +19590,7 @@ async function backfillMemoryTopicsOp(ctx, memoryIds) {
19590
19590
  const chunkIds = uniqueIds.slice(i, i + CHUNK);
19591
19591
  await ctx.database.write(async () => {
19592
19592
  await assertCanWrite2(ctx);
19593
- const writes = [];
19593
+ const records = [];
19594
19594
  for (const id2 of chunkIds) {
19595
19595
  let record2;
19596
19596
  try {
@@ -19600,13 +19600,40 @@ async function backfillMemoryTopicsOp(ctx, memoryIds) {
19600
19600
  }
19601
19601
  if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2)) continue;
19602
19602
  if (parseTopics(record2.topics) !== null) continue;
19603
- const links2 = await entityCtx.memoryEntityCollection.query(import_watermelondb24.Q.where("memory_id", id2)).unsafeFetchRaw();
19604
- const entityIds = links2.map((l) => String(l.entity_id));
19605
- if (entityIds.length === 0) continue;
19606
- const entities = await entityCtx.entityCollection.query(import_watermelondb24.Q.where("id", import_watermelondb24.Q.oneOf(entityIds))).fetch();
19607
- if (entities.length === 0) continue;
19603
+ records.push(record2);
19604
+ }
19605
+ if (records.length === 0) return;
19606
+ const links2 = await entityCtx.memoryEntityCollection.query(import_watermelondb24.Q.where("memory_id", import_watermelondb24.Q.oneOf(records.map((record2) => record2.id)))).unsafeFetchRaw();
19607
+ const entityIds = Array.from(new Set(links2.map((link) => String(link.entity_id))));
19608
+ const entitiesById = /* @__PURE__ */ new Map();
19609
+ for (let j = 0; j < entityIds.length; j += CHUNK) {
19610
+ const entities = await entityCtx.entityCollection.query(import_watermelondb24.Q.where("id", import_watermelondb24.Q.oneOf(entityIds.slice(j, j + CHUNK)))).fetch();
19611
+ for (const entity of entities) entitiesById.set(entity.id, entity);
19612
+ }
19613
+ const entitiesByMemory = /* @__PURE__ */ new Map();
19614
+ for (const link of links2) {
19615
+ const entity = entitiesById.get(String(link.entity_id));
19616
+ if (!entity) continue;
19617
+ const memoryId = String(link.memory_id);
19618
+ let entities = entitiesByMemory.get(memoryId);
19619
+ if (!entities) {
19620
+ entities = /* @__PURE__ */ new Set();
19621
+ entitiesByMemory.set(memoryId, entities);
19622
+ }
19623
+ entities.add(entity);
19624
+ }
19625
+ const writes = [];
19626
+ for (const record2 of records) {
19627
+ const entities = entitiesByMemory.get(record2.id);
19628
+ if (!entities?.size) continue;
19608
19629
  const source = record2.topicsUserManaged ? "user" : "auto";
19609
- const write = await resolveMemoryTopicsWrite(entityCtx, id2, entities, [], source);
19630
+ const write = await resolveMemoryTopicsWrite(
19631
+ entityCtx,
19632
+ record2.id,
19633
+ Array.from(entities),
19634
+ [],
19635
+ source
19636
+ );
19610
19637
  if (write) writes.push(write);
19611
19638
  }
19612
19639
  if (writes.length === 0) return;
@@ -19,7 +19,7 @@ import {
19
19
  taskTypeHeader,
20
20
  validateEndpointOverride,
21
21
  withInternalFlowMarker
22
- } from "./chunk-7JYVPYGQ.mjs";
22
+ } from "./chunk-6ANL34M3.mjs";
23
23
  import {
24
24
  BASE_URL,
25
25
  MCP_R2_DOMAIN,
@@ -17722,7 +17722,7 @@ async function backfillMemoryTopicsOp(ctx, memoryIds) {
17722
17722
  const chunkIds = uniqueIds.slice(i, i + CHUNK);
17723
17723
  await ctx.database.write(async () => {
17724
17724
  await assertCanWrite2(ctx);
17725
- const writes = [];
17725
+ const records = [];
17726
17726
  for (const id2 of chunkIds) {
17727
17727
  let record2;
17728
17728
  try {
@@ -17732,13 +17732,40 @@ async function backfillMemoryTopicsOp(ctx, memoryIds) {
17732
17732
  }
17733
17733
  if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2)) continue;
17734
17734
  if (parseTopics(record2.topics) !== null) continue;
17735
- const links2 = await entityCtx.memoryEntityCollection.query(Q9.where("memory_id", id2)).unsafeFetchRaw();
17736
- const entityIds = links2.map((l) => String(l.entity_id));
17737
- if (entityIds.length === 0) continue;
17738
- const entities = await entityCtx.entityCollection.query(Q9.where("id", Q9.oneOf(entityIds))).fetch();
17739
- if (entities.length === 0) continue;
17735
+ records.push(record2);
17736
+ }
17737
+ if (records.length === 0) return;
17738
+ const links2 = await entityCtx.memoryEntityCollection.query(Q9.where("memory_id", Q9.oneOf(records.map((record2) => record2.id)))).unsafeFetchRaw();
17739
+ const entityIds = Array.from(new Set(links2.map((link) => String(link.entity_id))));
17740
+ const entitiesById = /* @__PURE__ */ new Map();
17741
+ for (let j = 0; j < entityIds.length; j += CHUNK) {
17742
+ const entities = await entityCtx.entityCollection.query(Q9.where("id", Q9.oneOf(entityIds.slice(j, j + CHUNK)))).fetch();
17743
+ for (const entity of entities) entitiesById.set(entity.id, entity);
17744
+ }
17745
+ const entitiesByMemory = /* @__PURE__ */ new Map();
17746
+ for (const link of links2) {
17747
+ const entity = entitiesById.get(String(link.entity_id));
17748
+ if (!entity) continue;
17749
+ const memoryId = String(link.memory_id);
17750
+ let entities = entitiesByMemory.get(memoryId);
17751
+ if (!entities) {
17752
+ entities = /* @__PURE__ */ new Set();
17753
+ entitiesByMemory.set(memoryId, entities);
17754
+ }
17755
+ entities.add(entity);
17756
+ }
17757
+ const writes = [];
17758
+ for (const record2 of records) {
17759
+ const entities = entitiesByMemory.get(record2.id);
17760
+ if (!entities?.size) continue;
17740
17761
  const source = record2.topicsUserManaged ? "user" : "auto";
17741
- const write = await resolveMemoryTopicsWrite(entityCtx, id2, entities, [], source);
17762
+ const write = await resolveMemoryTopicsWrite(
17763
+ entityCtx,
17764
+ record2.id,
17765
+ Array.from(entities),
17766
+ [],
17767
+ source
17768
+ );
17742
17769
  if (write) writes.push(write);
17743
17770
  }
17744
17771
  if (writes.length === 0) return;
@@ -21735,7 +21762,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
21735
21762
  content: m.content,
21736
21763
  similarity: m.similarity
21737
21764
  }));
21738
- const { consolidateMemory: doConsolidate } = await import("./consolidate-3RQL75PJ.mjs");
21765
+ const { consolidateMemory: doConsolidate } = await import("./consolidate-JL4P6FXW.mjs");
21739
21766
  const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
21740
21767
  if (decision.action === "create") return decision.fallbackReason ? null : { create: true };
21741
21768
  if (decision.action === "supersede" && decision.content) {
@@ -969,11 +969,11 @@ async function requestPortalJson(req, endpoint, controller, deadlineAt) {
969
969
  let value;
970
970
  try {
971
971
  value = JSON.parse(candidate);
972
- } catch (err) {
972
+ } catch {
973
973
  return {
974
974
  kind: "retryable",
975
975
  code: "invalid-json",
976
- reason: `completion was not valid JSON: ${err.message}`
976
+ reason: "invalid-json"
977
977
  };
978
978
  }
979
979
  if (value === null) {
@@ -4,7 +4,7 @@ import {
4
4
  notifyConsolidationFallback,
5
5
  requiresResponsesTransport,
6
6
  resolvePiiRedactor
7
- } from "./chunk-QK62YWBH.mjs";
7
+ } from "./chunk-BIMEZT3O.mjs";
8
8
  import "./chunk-3RPGXXPZ.mjs";
9
9
 
10
10
  // src/lib/memory/consolidate.ts
@@ -15940,11 +15940,11 @@ async function requestPortalJson(req, endpoint, controller, deadlineAt) {
15940
15940
  let value;
15941
15941
  try {
15942
15942
  value = JSON.parse(candidate);
15943
- } catch (err) {
15943
+ } catch {
15944
15944
  return {
15945
15945
  kind: "retryable",
15946
15946
  code: "invalid-json",
15947
- reason: `completion was not valid JSON: ${err.message}`
15947
+ reason: "invalid-json"
15948
15948
  };
15949
15949
  }
15950
15950
  if (value === null) {
@@ -29818,7 +29818,7 @@ async function backfillMemoryTopicsOp(ctx, memoryIds) {
29818
29818
  const chunkIds = uniqueIds.slice(i, i + CHUNK);
29819
29819
  await ctx.database.write(async () => {
29820
29820
  await assertCanWrite2(ctx);
29821
- const writes = [];
29821
+ const records = [];
29822
29822
  for (const id of chunkIds) {
29823
29823
  let record;
29824
29824
  try {
@@ -29828,13 +29828,40 @@ async function backfillMemoryTopicsOp(ctx, memoryIds) {
29828
29828
  }
29829
29829
  if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) continue;
29830
29830
  if (parseTopics(record.topics) !== null) continue;
29831
- const links = await entityCtx.memoryEntityCollection.query(import_watermelondb19.Q.where("memory_id", id)).unsafeFetchRaw();
29832
- const entityIds = links.map((l) => String(l.entity_id));
29833
- if (entityIds.length === 0) continue;
29834
- const entities = await entityCtx.entityCollection.query(import_watermelondb19.Q.where("id", import_watermelondb19.Q.oneOf(entityIds))).fetch();
29835
- if (entities.length === 0) continue;
29831
+ records.push(record);
29832
+ }
29833
+ if (records.length === 0) return;
29834
+ const links = await entityCtx.memoryEntityCollection.query(import_watermelondb19.Q.where("memory_id", import_watermelondb19.Q.oneOf(records.map((record) => record.id)))).unsafeFetchRaw();
29835
+ const entityIds = Array.from(new Set(links.map((link) => String(link.entity_id))));
29836
+ const entitiesById = /* @__PURE__ */ new Map();
29837
+ for (let j = 0; j < entityIds.length; j += CHUNK) {
29838
+ const entities = await entityCtx.entityCollection.query(import_watermelondb19.Q.where("id", import_watermelondb19.Q.oneOf(entityIds.slice(j, j + CHUNK)))).fetch();
29839
+ for (const entity of entities) entitiesById.set(entity.id, entity);
29840
+ }
29841
+ const entitiesByMemory = /* @__PURE__ */ new Map();
29842
+ for (const link of links) {
29843
+ const entity = entitiesById.get(String(link.entity_id));
29844
+ if (!entity) continue;
29845
+ const memoryId = String(link.memory_id);
29846
+ let entities = entitiesByMemory.get(memoryId);
29847
+ if (!entities) {
29848
+ entities = /* @__PURE__ */ new Set();
29849
+ entitiesByMemory.set(memoryId, entities);
29850
+ }
29851
+ entities.add(entity);
29852
+ }
29853
+ const writes = [];
29854
+ for (const record of records) {
29855
+ const entities = entitiesByMemory.get(record.id);
29856
+ if (!entities?.size) continue;
29836
29857
  const source = record.topicsUserManaged ? "user" : "auto";
29837
- const write = await resolveMemoryTopicsWrite(entityCtx, id, entities, [], source);
29858
+ const write = await resolveMemoryTopicsWrite(
29859
+ entityCtx,
29860
+ record.id,
29861
+ Array.from(entities),
29862
+ [],
29863
+ source
29864
+ );
29838
29865
  if (write) writes.push(write);
29839
29866
  }
29840
29867
  if (writes.length === 0) return;
@@ -13,7 +13,7 @@ import {
13
13
  taskTypeHeader,
14
14
  validateEndpointOverride,
15
15
  withInternalFlowMarker
16
- } from "./chunk-QK62YWBH.mjs";
16
+ } from "./chunk-BIMEZT3O.mjs";
17
17
  import {
18
18
  BASE_URL,
19
19
  __commonJS,
@@ -28076,7 +28076,7 @@ async function backfillMemoryTopicsOp(ctx, memoryIds) {
28076
28076
  const chunkIds = uniqueIds.slice(i, i + CHUNK);
28077
28077
  await ctx.database.write(async () => {
28078
28078
  await assertCanWrite2(ctx);
28079
- const writes = [];
28079
+ const records = [];
28080
28080
  for (const id of chunkIds) {
28081
28081
  let record;
28082
28082
  try {
@@ -28086,13 +28086,40 @@ async function backfillMemoryTopicsOp(ctx, memoryIds) {
28086
28086
  }
28087
28087
  if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) continue;
28088
28088
  if (parseTopics(record.topics) !== null) continue;
28089
- const links = await entityCtx.memoryEntityCollection.query(import_watermelondb19.Q.where("memory_id", id)).unsafeFetchRaw();
28090
- const entityIds = links.map((l) => String(l.entity_id));
28091
- if (entityIds.length === 0) continue;
28092
- const entities = await entityCtx.entityCollection.query(import_watermelondb19.Q.where("id", import_watermelondb19.Q.oneOf(entityIds))).fetch();
28093
- if (entities.length === 0) continue;
28089
+ records.push(record);
28090
+ }
28091
+ if (records.length === 0) return;
28092
+ const links = await entityCtx.memoryEntityCollection.query(import_watermelondb19.Q.where("memory_id", import_watermelondb19.Q.oneOf(records.map((record) => record.id)))).unsafeFetchRaw();
28093
+ const entityIds = Array.from(new Set(links.map((link) => String(link.entity_id))));
28094
+ const entitiesById = /* @__PURE__ */ new Map();
28095
+ for (let j = 0; j < entityIds.length; j += CHUNK) {
28096
+ const entities = await entityCtx.entityCollection.query(import_watermelondb19.Q.where("id", import_watermelondb19.Q.oneOf(entityIds.slice(j, j + CHUNK)))).fetch();
28097
+ for (const entity of entities) entitiesById.set(entity.id, entity);
28098
+ }
28099
+ const entitiesByMemory = /* @__PURE__ */ new Map();
28100
+ for (const link of links) {
28101
+ const entity = entitiesById.get(String(link.entity_id));
28102
+ if (!entity) continue;
28103
+ const memoryId = String(link.memory_id);
28104
+ let entities = entitiesByMemory.get(memoryId);
28105
+ if (!entities) {
28106
+ entities = /* @__PURE__ */ new Set();
28107
+ entitiesByMemory.set(memoryId, entities);
28108
+ }
28109
+ entities.add(entity);
28110
+ }
28111
+ const writes = [];
28112
+ for (const record of records) {
28113
+ const entities = entitiesByMemory.get(record.id);
28114
+ if (!entities?.size) continue;
28094
28115
  const source = record.topicsUserManaged ? "user" : "auto";
28095
- const write = await resolveMemoryTopicsWrite(entityCtx, id, entities, [], source);
28116
+ const write = await resolveMemoryTopicsWrite(
28117
+ entityCtx,
28118
+ record.id,
28119
+ Array.from(entities),
28120
+ [],
28121
+ source
28122
+ );
28096
28123
  if (write) writes.push(write);
28097
28124
  }
28098
28125
  if (writes.length === 0) return;
@@ -31790,7 +31817,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
31790
31817
  content: m.content,
31791
31818
  similarity: m.similarity
31792
31819
  }));
31793
- const { consolidateMemory: doConsolidate } = await import("./consolidate-NW4UVA6T.mjs");
31820
+ const { consolidateMemory: doConsolidate } = await import("./consolidate-JZJYY3SZ.mjs");
31794
31821
  const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
31795
31822
  if (decision.action === "create") return decision.fallbackReason ? null : { create: true };
31796
31823
  if (decision.action === "supersede" && decision.content) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anuma/sdk",
3
- "version": "10.2.5",
3
+ "version": "10.2.6",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",