@anuma/sdk 7.0.4-next.20261015012621 → 7.0.5

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.
@@ -26140,11 +26140,6 @@ function parseTopics(value) {
26140
26140
  }
26141
26141
 
26142
26142
  // src/lib/db/entities/operations.ts
26143
- async function assertCanWrite(ctx) {
26144
- if (ctx.canWrite && !await ctx.canWrite()) {
26145
- throw new Error("Memory source is no longer eligible");
26146
- }
26147
- }
26148
26143
  function entityToStored(e) {
26149
26144
  return {
26150
26145
  uniqueId: e.id,
@@ -26285,7 +26280,6 @@ async function linkMemoryEntitiesOp(ctx, memoryId, entityInputs, options) {
26285
26280
  let skipped = false;
26286
26281
  let entities = [];
26287
26282
  await ctx.database.write(async () => {
26288
- await assertCanWrite(ctx);
26289
26283
  const {
26290
26284
  entities: byName,
26291
26285
  operations: entityOps,
@@ -26361,7 +26355,6 @@ async function replaceMemoryEntities(ctx, memoryId, entityInputs, options) {
26361
26355
  let skipped = false;
26362
26356
  let entities = [];
26363
26357
  await ctx.database.write(async () => {
26364
- await assertCanWrite(ctx);
26365
26358
  const vaultRow = await findVaultRowInWrite(ctx, memoryId);
26366
26359
  if (options.guarded && autoLinkBlocked(vaultRow)) {
26367
26360
  skipped = true;
@@ -26422,7 +26415,6 @@ async function unlinkMemoryEntitiesOp(ctx, memoryIds) {
26422
26415
  const links = await ctx.memoryEntityCollection.query(import_watermelondb18.Q.where("memory_id", import_watermelondb18.Q.oneOf(Array.from(memoryIds)))).fetch();
26423
26416
  if (links.length === 0) return;
26424
26417
  await ctx.database.write(async () => {
26425
- await assertCanWrite(ctx);
26426
26418
  await ctx.database.batch(...links.map((l) => l.prepareDestroyPermanently()));
26427
26419
  });
26428
26420
  }
@@ -26431,7 +26423,6 @@ async function unlinkAllMemoryEntitiesForUserOp(ctx, userId) {
26431
26423
  const links = await ctx.memoryEntityCollection.query(import_watermelondb18.Q.where("user_id", userId)).fetch();
26432
26424
  if (links.length === 0) return;
26433
26425
  await ctx.database.write(async () => {
26434
- await assertCanWrite(ctx);
26435
26426
  await ctx.database.batch(...links.map((l) => l.prepareDestroyPermanently()));
26436
26427
  });
26437
26428
  }
@@ -26595,11 +26586,6 @@ function visibilityConditions(requested) {
26595
26586
  function isKinded(record) {
26596
26587
  return record.kind !== null && record.kind !== void 0;
26597
26588
  }
26598
- async function assertCanWrite2(ctx) {
26599
- if (ctx.canWrite && !await ctx.canWrite()) {
26600
- throw new Error("Memory source is no longer eligible");
26601
- }
26602
- }
26603
26589
  function assertValidKindLevel(kind, level) {
26604
26590
  const hasKind = kind !== null && kind !== void 0;
26605
26591
  if (hasKind && !MEMORY_KINDS.includes(kind)) {
@@ -26780,7 +26766,8 @@ async function createVaultMemoryOp(ctx, opts) {
26780
26766
  ctx.embeddedWalletSigner
26781
26767
  ) : opts.content;
26782
26768
  const created = await ctx.database.write(async () => {
26783
- await assertCanWrite2(ctx);
26769
+ if (ctx.canWrite && !await ctx.canWrite())
26770
+ throw new Error("Memory source is no longer eligible");
26784
26771
  return ctx.vaultMemoryCollection.create(
26785
26772
  (record) => populateNewVaultMemory(record, ctx, opts, encryptedContent, encryptedKindValue)
26786
26773
  );
@@ -26799,7 +26786,8 @@ async function createSupersedingMemoryOp(ctx, opts, targetId) {
26799
26786
  ) : opts.content;
26800
26787
  let createdRecord = null;
26801
26788
  await ctx.database.write(async () => {
26802
- await assertCanWrite2(ctx);
26789
+ if (ctx.canWrite && !await ctx.canWrite())
26790
+ throw new Error("Memory source is no longer eligible");
26803
26791
  let target;
26804
26792
  try {
26805
26793
  target = await ctx.vaultMemoryCollection.find(targetId);
@@ -26891,7 +26879,8 @@ async function createVaultMemoriesBatchOp(ctx, optionsArray) {
26891
26879
  })
26892
26880
  );
26893
26881
  const created = await ctx.database.write(async () => {
26894
- await assertCanWrite2(ctx);
26882
+ if (ctx.canWrite && !await ctx.canWrite())
26883
+ throw new Error("Memory source is no longer eligible");
26895
26884
  const prepared = optionsArray.map(
26896
26885
  (opts, i) => ctx.vaultMemoryCollection.prepareCreate(
26897
26886
  (record) => populateNewVaultMemory(record, ctx, opts, encryptedContents[i], encryptedKindValues[i])
@@ -27182,7 +27171,8 @@ async function updateVaultMemoryOp(ctx, id, opts) {
27182
27171
  const record = probe;
27183
27172
  const originalUpdatedAt = record.updatedAt.getTime();
27184
27173
  await ctx.database.write(async () => {
27185
- await assertCanWrite2(ctx);
27174
+ if (ctx.canWrite && !await ctx.canWrite())
27175
+ throw new Error("Memory source is no longer eligible");
27186
27176
  if (record.isDeleted || record.supersededBy || !isOwnedByCtxUser(ctx, record) || opts.freeFormOnly && isKinded(record)) {
27187
27177
  stale = true;
27188
27178
  return;
@@ -27293,7 +27283,6 @@ async function setMemoryEntitiesOp(ctx, memoryId, entities) {
27293
27283
  let stale = false;
27294
27284
  const originalUpdatedAt = record.updatedAt.getTime();
27295
27285
  await ctx.database.write(async (writer) => {
27296
- await assertCanWrite2(ctx);
27297
27286
  if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) {
27298
27287
  stale = true;
27299
27288
  return;
@@ -27335,7 +27324,6 @@ async function clearMemoryTopicsOverrideOp(ctx, memoryId, options) {
27335
27324
  const originalUpdatedAt = record.updatedAt.getTime();
27336
27325
  let cleared = false;
27337
27326
  await ctx.database.write(async () => {
27338
- await assertCanWrite2(ctx);
27339
27327
  if (options?.unlessTopicsRecorded && parseTopics(record.topics) !== null) return;
27340
27328
  cleared = true;
27341
27329
  await record.update((r) => {
@@ -27359,7 +27347,6 @@ async function setMemoryVisibilityOp(ctx, id, opts) {
27359
27347
  if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) return null;
27360
27348
  let stale = false;
27361
27349
  await ctx.database.write(async () => {
27362
- await assertCanWrite2(ctx);
27363
27350
  if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) {
27364
27351
  stale = true;
27365
27352
  return;
@@ -27388,7 +27375,6 @@ async function deleteVaultMemoryOp(ctx, id) {
27388
27375
  if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) return false;
27389
27376
  let stale = false;
27390
27377
  await ctx.database.write(async () => {
27391
- await assertCanWrite2(ctx);
27392
27378
  if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) {
27393
27379
  stale = true;
27394
27380
  return;
@@ -27426,7 +27412,8 @@ async function supersedeVaultMemoryOp(ctx, id, supersededById) {
27426
27412
  }
27427
27413
  let stale = false;
27428
27414
  await ctx.database.write(async () => {
27429
- await assertCanWrite2(ctx);
27415
+ if (ctx.canWrite && !await ctx.canWrite())
27416
+ throw new Error("Memory source is no longer eligible");
27430
27417
  if (record.isDeleted || record.supersededBy || !isOwnedByCtxUser(ctx, record)) {
27431
27418
  stale = true;
27432
27419
  return;
@@ -27588,7 +27575,6 @@ async function stampTopicsExtractedAtOp(ctx, memoryIds, extractedAt, version = T
27588
27575
  for (let i = 0; i < uniqueIds.length; i += CHUNK) {
27589
27576
  const chunkIds = uniqueIds.slice(i, i + CHUNK);
27590
27577
  await ctx.database.write(async () => {
27591
- await assertCanWrite2(ctx);
27592
27578
  const records = [];
27593
27579
  for (const id of chunkIds) {
27594
27580
  try {
@@ -27622,7 +27608,6 @@ async function relinkMemoryTopicsOp(ctx, memoryIds) {
27622
27608
  for (const id of Array.from(new Set(memoryIds))) {
27623
27609
  try {
27624
27610
  await ctx.database.write(async (writer) => {
27625
- await assertCanWrite2(ctx);
27626
27611
  let record;
27627
27612
  try {
27628
27613
  record = await ctx.vaultMemoryCollection.find(id);
@@ -27653,7 +27638,6 @@ async function backfillMemoryTopicsOp(ctx, memoryIds) {
27653
27638
  for (let i = 0; i < uniqueIds.length; i += CHUNK) {
27654
27639
  const chunkIds = uniqueIds.slice(i, i + CHUNK);
27655
27640
  await ctx.database.write(async () => {
27656
- await assertCanWrite2(ctx);
27657
27641
  const writes = [];
27658
27642
  for (const id of chunkIds) {
27659
27643
  let record;
@@ -27686,7 +27670,6 @@ async function deleteAllVaultMemoriesForUserOp(ctx, userId) {
27686
27670
  const records = await ctx.vaultMemoryCollection.query(import_watermelondb19.Q.where("user_id", userId), import_watermelondb19.Q.where("is_deleted", false)).fetch();
27687
27671
  if (records.length === 0) return 0;
27688
27672
  await ctx.database.write(async () => {
27689
- await assertCanWrite2(ctx);
27690
27673
  const prepared = records.map(
27691
27674
  (record) => record.prepareUpdate((r) => {
27692
27675
  r._setRaw("is_deleted", true);
@@ -27741,7 +27724,6 @@ async function archiveVaultMemoryOp(ctx, id, opts) {
27741
27724
  let stale = false;
27742
27725
  const archivedAtValue = opts?.now ?? Date.now();
27743
27726
  await ctx.database.write(async () => {
27744
- await assertCanWrite2(ctx);
27745
27727
  if (record.isDeleted || !isOwnedByCtxUser(ctx, record) || record.archivedAt !== null) {
27746
27728
  stale = true;
27747
27729
  return;
@@ -27765,7 +27747,6 @@ async function restoreVaultMemoryOp(ctx, id) {
27765
27747
  if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) return false;
27766
27748
  let stale = false;
27767
27749
  await ctx.database.write(async () => {
27768
- await assertCanWrite2(ctx);
27769
27750
  if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) {
27770
27751
  stale = true;
27771
27752
  return;
@@ -27786,7 +27767,6 @@ async function hardDeleteDecayedOp(ctx, id, opts) {
27786
27767
  const now = opts.now ?? Date.now();
27787
27768
  let stale = false;
27788
27769
  await ctx.database.write(async () => {
27789
- await assertCanWrite2(ctx);
27790
27770
  const archivedAt = record.archivedAt;
27791
27771
  if (record.isDeleted || !isOwnedByCtxUser(ctx, record) || archivedAt === null || now - archivedAt <= opts.hardDeleteWindowMs) {
27792
27772
  stale = true;
@@ -27826,7 +27806,6 @@ async function updateVaultMemoryEmbeddingOp(ctx, id, embedding, embeddingModel,
27826
27806
  }
27827
27807
  let written = false;
27828
27808
  await ctx.database.write(async () => {
27829
- await assertCanWrite2(ctx);
27830
27809
  if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) return;
27831
27810
  const originalUpdatedAt = record.updatedAt.getTime();
27832
27811
  if (originalUpdatedAt !== readUpdatedAt || record._getRaw("content") !== readStoredContent)
@@ -31498,13 +31477,6 @@ function restoreCandidates(candidates, redactor, ownNames) {
31498
31477
  ).map((c) => c.candidate);
31499
31478
  }
31500
31479
  async function extractAndRetain(messages, retainCtx, options) {
31501
- const { memoryStore, signal } = options;
31502
- if (memoryStore === null) throw new Error("Memory store is not ready");
31503
- if (memoryStore && options.folderId !== void 0 && options.folderId !== null)
31504
- throw new Error("Remote memory extraction does not support folders");
31505
- if (memoryStore && options.extract.piiRedaction && !memoryStore.masksEmbeddingInput)
31506
- throw new Error("PII-redacted extraction requires a memory store that masks embedding inputs");
31507
- signal?.throwIfAborted();
31508
31480
  const minConfidence = options.minConfidence ?? DEFAULT_MIN_CONFIDENCE;
31509
31481
  const resolvedConsolidatePii = options.consolidateOptions?.piiRedaction ?? options.extract.piiRedaction;
31510
31482
  const consolidateOptions = options.consolidateOptions !== void 0 ? {
@@ -31538,7 +31510,6 @@ async function extractAndRetain(messages, retainCtx, options) {
31538
31510
  }
31539
31511
  });
31540
31512
  const extractMs = Date.now() - tExtract;
31541
- signal?.throwIfAborted();
31542
31513
  const filtered = candidates.filter((c) => c.confidence >= minConfidence);
31543
31514
  const log = getLogger();
31544
31515
  const screened = screenCandidatesForInjection(filtered);
@@ -31586,33 +31557,16 @@ async function extractAndRetain(messages, retainCtx, options) {
31586
31557
  const results = [];
31587
31558
  const quarantinedInfo = [];
31588
31559
  let failedWrites = 0;
31589
- let auditRows;
31590
31560
  const tRetain = Date.now();
31591
31561
  for (const { candidate, isQuarantined, reason, signature } of toRetain) {
31592
31562
  try {
31593
- signal?.throwIfAborted();
31594
31563
  if (isQuarantined) {
31595
- let existingId;
31596
- if (memoryStore) {
31597
- auditRows ?? (auditRows = memoryStore.list({
31598
- scopes: [options.scope ?? "private"],
31599
- includeArchived: true,
31600
- includeQuarantined: true,
31601
- includeSuperseded: true
31602
- }));
31603
- const sourceKey = [...new Set(candidate.sourceMessageIds)].sort().join("\0");
31604
- const normalize = (value) => value.normalize("NFKC").trim().replace(/\s+/g, " ").toLowerCase();
31605
- existingId = (await auditRows).find(
31606
- (row) => row.trustTier === "quarantined" && row.scope === (options.scope ?? "private") && [...new Set(row.sourceChunkIds ?? [])].sort().join("\0") === sourceKey && normalize(row.content) === normalize(candidate.content)
31607
- )?.uniqueId ?? null;
31608
- } else {
31609
- existingId = await findQuarantinedDuplicateOp(
31610
- retainCtx.vaultCtx,
31611
- candidate.content,
31612
- candidate.sourceMessageIds,
31613
- { scope: options.scope ?? "private", folderId: options.folderId ?? null }
31614
- ).catch(() => null);
31615
- }
31564
+ const existingId = await findQuarantinedDuplicateOp(
31565
+ retainCtx.vaultCtx,
31566
+ candidate.content,
31567
+ candidate.sourceMessageIds,
31568
+ { scope: options.scope ?? "private", folderId: options.folderId ?? null }
31569
+ ).catch(() => null);
31616
31570
  if (existingId) {
31617
31571
  quarantinedInfo.push({
31618
31572
  candidate,
@@ -31623,26 +31577,18 @@ async function extractAndRetain(messages, retainCtx, options) {
31623
31577
  continue;
31624
31578
  }
31625
31579
  }
31626
- const retainOptions = {
31580
+ const result = await retain(candidate.content, retainCtx, {
31627
31581
  source: "auto-extracted",
31628
31582
  sourceChunkIds: candidate.sourceMessageIds,
31629
31583
  respectTombstones: true,
31630
31584
  ...options.scope !== void 0 && { scope: options.scope },
31585
+ ...options.folderId !== void 0 && { folderId: options.folderId },
31631
31586
  ...consolidateOptions !== void 0 && { consolidateOptions },
31632
31587
  ...candidate.eventTime !== null && { eventTime: candidate.eventTime },
31633
31588
  factType: candidate.type,
31634
31589
  ...isQuarantined && { trustTier: "quarantined", enableAutoMerge: false }
31635
- };
31636
- const result = memoryStore ? await memoryStore.retain(candidate.content, {
31637
- ...retainOptions,
31638
- canWrite: retainCtx.vaultCtx.canWrite,
31639
- signal
31640
- }) : await retain(candidate.content, retainCtx, {
31641
- ...retainOptions,
31642
- ...options.folderId !== void 0 && { folderId: options.folderId }
31643
31590
  });
31644
31591
  if (isQuarantined) {
31645
- auditRows = void 0;
31646
31592
  const info = {
31647
31593
  candidate,
31648
31594
  memoryId: result.memoryId,
@@ -31661,16 +31607,9 @@ async function extractAndRetain(messages, retainCtx, options) {
31661
31607
  }
31662
31608
  succeededCandidates.push(candidate);
31663
31609
  results.push(result);
31664
- if (result.action !== "suppressed" && candidate.entities.length > 0) {
31610
+ if (result.action !== "suppressed" && options.entityCtx && candidate.entities.length > 0) {
31665
31611
  try {
31666
- signal?.throwIfAborted();
31667
- if (memoryStore) {
31668
- await memoryStore.addTopics(result.memoryId, candidate.entities, {
31669
- unlessUserManaged: true,
31670
- canWrite: retainCtx.vaultCtx.canWrite,
31671
- signal
31672
- });
31673
- } else if (options.entityCtx && !await isMemoryTopicsUserManaged(options.entityCtx, result.memoryId)) {
31612
+ if (!await isMemoryTopicsUserManaged(options.entityCtx, result.memoryId)) {
31674
31613
  await linkMemoryEntitiesOp(options.entityCtx, result.memoryId, candidate.entities, {
31675
31614
  unlessTopicsUserManaged: true
31676
31615
  });
@@ -31918,7 +31857,7 @@ function createAutoExtractor(options) {
31918
31857
  };
31919
31858
  const consolidateOptions = options.consolidate ? { ...options.consolidate, ...subPassAuth(options.consolidate.baseUrl) } : void 0;
31920
31859
  const injectionClassifierOptions = options.injectionClassifier ? { ...options.injectionClassifier, ...subPassAuth(options.injectionClassifier.baseUrl) } : void 0;
31921
- if (!options.memoryStore && options.retainCtx.vaultCtx.entityCtx && !options.entityCtx) {
31860
+ if (options.retainCtx.vaultCtx.entityCtx && !options.entityCtx) {
31922
31861
  getLogger().warn(
31923
31862
  "[memory/extract] retainCtx.vaultCtx.entityCtx is set but extractor was created without `entityCtx` \u2014 W5 graph lane will receive no writes"
31924
31863
  );
@@ -31963,8 +31902,6 @@ function createAutoExtractor(options) {
31963
31902
  try {
31964
31903
  const { candidates, results, failedCount, outcome, failure, funnel, timings, model } = await extractAndRetain(window2, retainCtx, {
31965
31904
  extract,
31966
- memoryStore: options.memoryStore,
31967
- signal: options.signal,
31968
31905
  ...options.minConfidence !== void 0 && { minConfidence: options.minConfidence },
31969
31906
  ...options.entityCtx !== void 0 && { entityCtx: options.entityCtx },
31970
31907
  ...options.scope !== void 0 && { scope: options.scope },
@@ -34077,7 +34014,6 @@ function createLocalMemoryStore(options) {
34077
34014
  database,
34078
34015
  entityCollection: database.get("entity"),
34079
34016
  memoryEntityCollection: database.get("memory_entity"),
34080
- canWrite: options.canWrite,
34081
34017
  ...userId !== void 0 && { userId },
34082
34018
  ...options.allowUnscopedRows !== void 0 && {
34083
34019
  allowUnscopedRows: options.allowUnscopedRows
@@ -34089,21 +34025,10 @@ function createLocalMemoryStore(options) {
34089
34025
  walletAddress: options.walletAddress,
34090
34026
  signMessage: options.signMessage,
34091
34027
  embeddedWalletSigner: options.embeddedWalletSigner,
34092
- canWrite: options.canWrite,
34093
34028
  ...userId !== void 0 && { userId },
34094
34029
  ...options.singleTenant !== void 0 && { singleTenant: options.singleTenant },
34095
34030
  entityCtx
34096
34031
  };
34097
- const assertWrite = async (writeOptions) => {
34098
- writeOptions?.signal?.throwIfAborted();
34099
- if (writeOptions?.canWrite && !await writeOptions.canWrite()) {
34100
- throw new Error("Memory source is no longer eligible");
34101
- }
34102
- if (options.canWrite && !await options.canWrite()) {
34103
- throw new Error("Memory source is no longer eligible");
34104
- }
34105
- writeOptions?.signal?.throwIfAborted();
34106
- };
34107
34032
  const vaultCache = options.vaultCache ?? createVaultEmbeddingCache();
34108
34033
  const ownedBy = userId !== void 0 ? [import_watermelondb24.Q.where("user_id", userId)] : [];
34109
34034
  const linksOwnedBy = userId === void 0 ? [] : options.allowUnscopedRows ? [import_watermelondb24.Q.or(import_watermelondb24.Q.where("user_id", userId), import_watermelondb24.Q.where("user_id", null))] : [import_watermelondb24.Q.where("user_id", userId)];
@@ -34215,25 +34140,9 @@ function createLocalMemoryStore(options) {
34215
34140
  archive: (id) => archiveVaultMemoryOp(vaultCtx, id),
34216
34141
  restore: (id) => restoreVaultMemoryOp(vaultCtx, id),
34217
34142
  setTopics: (memoryId, topics) => setMemoryEntitiesOp(vaultCtx, memoryId, topics),
34218
- addTopics: (memoryId, topics, writeOptions) => database.write(async (writer) => {
34219
- await assertWrite(writeOptions);
34143
+ addTopics: (memoryId, topics) => database.write(async (writer) => {
34220
34144
  const owned = await vaultCtx.vaultMemoryCollection.query(import_watermelondb24.Q.where("id", memoryId), import_watermelondb24.Q.where("is_deleted", false), ...ownedBy).fetchCount();
34221
- return owned > 0 ? writer.callWriter(
34222
- () => linkMemoryEntitiesOp(
34223
- {
34224
- ...entityCtx,
34225
- canWrite: async () => {
34226
- await assertWrite(writeOptions);
34227
- return true;
34228
- }
34229
- },
34230
- memoryId,
34231
- topics,
34232
- {
34233
- unlessTopicsUserManaged: writeOptions?.unlessUserManaged
34234
- }
34235
- )
34236
- ) : [];
34145
+ return owned > 0 ? writer.callWriter(() => linkMemoryEntitiesOp(entityCtx, memoryId, topics)) : [];
34237
34146
  }),
34238
34147
  setVisibility: (id, visibility, visibilityOptions) => setMemoryVisibilityOp(vaultCtx, id, { visibility, ...visibilityOptions }),
34239
34148
  recall: (query, recallOptions) => recall(
@@ -34243,17 +34152,7 @@ function createLocalMemoryStore(options) {
34243
34152
  ),
34244
34153
  retain: (content, retainOptions) => retain(
34245
34154
  content,
34246
- {
34247
- vaultCtx: {
34248
- ...vaultCtx,
34249
- canWrite: async () => {
34250
- await assertWrite(retainOptions);
34251
- return true;
34252
- }
34253
- },
34254
- embeddingOptions: options.embeddingOptions,
34255
- vaultCache
34256
- },
34155
+ { vaultCtx, embeddingOptions: options.embeddingOptions, vaultCache },
34257
34156
  retainOptions
34258
34157
  ),
34259
34158
  factSource: {
@@ -35103,7 +35002,6 @@ function createDurableAutoExtractor(options) {
35103
35002
  };
35104
35003
  const folderId = options.folderId ?? null;
35105
35004
  let disposed = false;
35106
- let activeBatch = null;
35107
35005
  let running = false;
35108
35006
  let wakeRequested = false;
35109
35007
  let timer;
@@ -35140,18 +35038,14 @@ function createDurableAutoExtractor(options) {
35140
35038
  }, delay);
35141
35039
  }
35142
35040
  async function extractBatch(messages, conversationId, ids, jobScope, jobFolderId) {
35143
- if (disposed) throw new Error("Extraction session was disposed");
35144
35041
  let watchdog;
35145
35042
  let cancelled = false;
35146
- const controller = new AbortController();
35147
- activeBatch = controller;
35148
35043
  const model = options.modelForScope?.(jobScope) ?? options.extract.model;
35149
35044
  try {
35150
35045
  return await Promise.race([
35151
35046
  new Promise((resolve, reject) => {
35152
35047
  const worker = createAutoExtractor({
35153
35048
  ...options,
35154
- signal: controller.signal,
35155
35049
  retainCtx: {
35156
35050
  ...options.retainCtx,
35157
35051
  vaultCtx: {
@@ -35180,8 +35074,6 @@ function createDurableAutoExtractor(options) {
35180
35074
  ]);
35181
35075
  } finally {
35182
35076
  cancelled = true;
35183
- controller.abort();
35184
- if (activeBatch === controller) activeBatch = null;
35185
35077
  if (watchdog !== void 0) clearTimeout(watchdog);
35186
35078
  }
35187
35079
  }
@@ -35193,7 +35085,6 @@ function createDurableAutoExtractor(options) {
35193
35085
  for (const message of loaded)
35194
35086
  if (message && message.messageId > 0) sequences.set(message.uniqueId, message.messageId);
35195
35087
  await database.write(async () => {
35196
- if (disposed) return;
35197
35088
  const current = idsOf(job);
35198
35089
  const acknowledged = ids.filter((id) => current.includes(id));
35199
35090
  if (!acknowledged.length) return;
@@ -35366,7 +35257,6 @@ function createDurableAutoExtractor(options) {
35366
35257
  jobScope,
35367
35258
  jobFolderId
35368
35259
  );
35369
- if (disposed) throw new Error("Extraction session was disposed");
35370
35260
  options.onTurnComplete?.(result);
35371
35261
  return result;
35372
35262
  };
@@ -35403,7 +35293,6 @@ function createDurableAutoExtractor(options) {
35403
35293
  );
35404
35294
  scheduleAfterSuccess = true;
35405
35295
  } catch (error) {
35406
- if (disposed) break;
35407
35296
  attempts.set(job.id, attempted + 1);
35408
35297
  retry = true;
35409
35298
  reportError(error, conversationId);
@@ -35426,14 +35315,6 @@ function createDurableAutoExtractor(options) {
35426
35315
  schedule(retry ? options.retryDelayMs ?? 3e4 : 0);
35427
35316
  }
35428
35317
  }
35429
- function dispose() {
35430
- disposed = true;
35431
- activeBatch?.abort(options.signal?.reason);
35432
- if (timer !== void 0) clearTimeout(timer);
35433
- options.signal?.removeEventListener("abort", dispose);
35434
- }
35435
- if (options.signal?.aborted) dispose();
35436
- else options.signal?.addEventListener("abort", dispose, { once: true });
35437
35318
  schedule(0);
35438
35319
  return {
35439
35320
  processTurn(messages, conversationId) {
@@ -35513,7 +35394,10 @@ function createDurableAutoExtractor(options) {
35513
35394
  return true;
35514
35395
  },
35515
35396
  isProcessing: () => running,
35516
- dispose
35397
+ dispose() {
35398
+ disposed = true;
35399
+ if (timer !== void 0) clearTimeout(timer);
35400
+ }
35517
35401
  };
35518
35402
  }
35519
35403
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anuma/sdk",
3
- "version": "7.0.4-next.20261015012621",
3
+ "version": "7.0.5",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",