@anuma/sdk 6.21.0 → 6.21.1

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.
@@ -18342,13 +18342,25 @@ async function synthesizeProfile(ctx, options = {}) {
18342
18342
  watermark,
18343
18343
  options.reviewedMemoryIds
18344
18344
  );
18345
+ const memoriesById = new Map(memories.map((memory) => [memory.uniqueId, memory]));
18346
+ const fallbackPriors = /* @__PURE__ */ new Map();
18347
+ if (previous) {
18348
+ for (const section of previous.sections) {
18349
+ if (section.sourceMemoryIds.length > 0 && section.sourceMemoryIds.every((id) => {
18350
+ const memory = memoriesById.get(id);
18351
+ return memory && !memory.isDeleted && !memory.supersededBy && scopes.includes(memory.scope) && (options.reviewedMemoryIds === void 0 || options.reviewedMemoryIds.includes(id)) && changeTime(memory) <= previous.vaultWatermark;
18352
+ })) {
18353
+ fallbackPriors.set(section.key, section);
18354
+ }
18355
+ }
18356
+ }
18345
18357
  const settled = await Promise.allSettled(
18346
18358
  facets.map(async (facet) => {
18347
18359
  const prior = previous?.sections.find((s) => s.key === facet.key);
18348
18360
  if (prior && !staleKeys.has(facet.key)) {
18349
18361
  return prior;
18350
18362
  }
18351
- return synthesizeFacet(facet, ctx, options, prior);
18363
+ return synthesizeFacet(facet, ctx, options, fallbackPriors.get(facet.key));
18352
18364
  })
18353
18365
  );
18354
18366
  const sections = settled.map((r, i) => {
@@ -18361,10 +18373,7 @@ async function synthesizeProfile(ctx, options = {}) {
18361
18373
  error: r.reason instanceof Error ? r.reason.message : String(r.reason)
18362
18374
  }
18363
18375
  );
18364
- return fallbackSection(
18365
- facet,
18366
- previous?.sections.find((s) => s.key === facet.key)
18367
- );
18376
+ return fallbackSection(facet, fallbackPriors.get(facet.key));
18368
18377
  });
18369
18378
  return {
18370
18379
  version: PROFILE_DOC_VERSION,
@@ -18552,7 +18561,7 @@ async function synthesizeFacet(facet, ctx, options, prior) {
18552
18561
  const { text: text12, legitimateEmpty } = extractFacetText(result.structuredOutput);
18553
18562
  if (!text12 && !legitimateEmpty && !noEvidence) {
18554
18563
  getLogger().warn(
18555
- "[memory/synthesizeProfile] facet synthesis returned degraded-empty; keeping prior section",
18564
+ "[memory/synthesizeProfile] facet synthesis returned degraded-empty; using fallback section",
18556
18565
  { facet: facet.key, recalledCount: result.basedOn.memoryIds.length }
18557
18566
  );
18558
18567
  return fallbackSection(facet, prior);
@@ -8747,8 +8747,7 @@ interface ProfileSection {
8747
8747
  interests?: string[];
8748
8748
  /** Unix ms this section was generated. */
8749
8749
  generatedAt: number;
8750
- /** True when regeneration failed and a prior section value was carried
8751
- * forward (e.g. LLM returned empty) — the caller may choose to retry. */
8750
+ /** True when regeneration failed (e.g. LLM returned empty) — the caller may choose to retry. */
8752
8751
  stale?: boolean;
8753
8752
  }
8754
8753
  /** Fingerprint of the config that produced a {@link ProfileDoc}. Delta reuse
@@ -8747,8 +8747,7 @@ interface ProfileSection {
8747
8747
  interests?: string[];
8748
8748
  /** Unix ms this section was generated. */
8749
8749
  generatedAt: number;
8750
- /** True when regeneration failed and a prior section value was carried
8751
- * forward (e.g. LLM returned empty) — the caller may choose to retry. */
8750
+ /** True when regeneration failed (e.g. LLM returned empty) — the caller may choose to retry. */
8752
8751
  stale?: boolean;
8753
8752
  }
8754
8753
  /** Fingerprint of the config that produced a {@link ProfileDoc}. Delta reuse
@@ -8520,13 +8520,25 @@ async function synthesizeProfile(ctx, options = {}) {
8520
8520
  watermark,
8521
8521
  options.reviewedMemoryIds
8522
8522
  );
8523
+ const memoriesById = new Map(memories.map((memory) => [memory.uniqueId, memory]));
8524
+ const fallbackPriors = /* @__PURE__ */ new Map();
8525
+ if (previous) {
8526
+ for (const section of previous.sections) {
8527
+ if (section.sourceMemoryIds.length > 0 && section.sourceMemoryIds.every((id) => {
8528
+ const memory = memoriesById.get(id);
8529
+ return memory && !memory.isDeleted && !memory.supersededBy && scopes.includes(memory.scope) && (options.reviewedMemoryIds === void 0 || options.reviewedMemoryIds.includes(id)) && changeTime(memory) <= previous.vaultWatermark;
8530
+ })) {
8531
+ fallbackPriors.set(section.key, section);
8532
+ }
8533
+ }
8534
+ }
8523
8535
  const settled = await Promise.allSettled(
8524
8536
  facets.map(async (facet) => {
8525
8537
  const prior = previous?.sections.find((s) => s.key === facet.key);
8526
8538
  if (prior && !staleKeys.has(facet.key)) {
8527
8539
  return prior;
8528
8540
  }
8529
- return synthesizeFacet(facet, ctx, options, prior);
8541
+ return synthesizeFacet(facet, ctx, options, fallbackPriors.get(facet.key));
8530
8542
  })
8531
8543
  );
8532
8544
  const sections = settled.map((r, i) => {
@@ -8539,10 +8551,7 @@ async function synthesizeProfile(ctx, options = {}) {
8539
8551
  error: r.reason instanceof Error ? r.reason.message : String(r.reason)
8540
8552
  }
8541
8553
  );
8542
- return fallbackSection(
8543
- facet,
8544
- previous?.sections.find((s) => s.key === facet.key)
8545
- );
8554
+ return fallbackSection(facet, fallbackPriors.get(facet.key));
8546
8555
  });
8547
8556
  return {
8548
8557
  version: PROFILE_DOC_VERSION,
@@ -8730,7 +8739,7 @@ async function synthesizeFacet(facet, ctx, options, prior) {
8730
8739
  const { text: text12, legitimateEmpty } = extractFacetText(result.structuredOutput);
8731
8740
  if (!text12 && !legitimateEmpty && !noEvidence) {
8732
8741
  getLogger().warn(
8733
- "[memory/synthesizeProfile] facet synthesis returned degraded-empty; keeping prior section",
8742
+ "[memory/synthesizeProfile] facet synthesis returned degraded-empty; using fallback section",
8734
8743
  { facet: facet.key, recalledCount: result.basedOn.memoryIds.length }
8735
8744
  );
8736
8745
  return fallbackSection(facet, prior);
@@ -19640,13 +19640,25 @@ async function synthesizeProfile(ctx, options = {}) {
19640
19640
  watermark,
19641
19641
  options.reviewedMemoryIds
19642
19642
  );
19643
+ const memoriesById = new Map(memories.map((memory) => [memory.uniqueId, memory]));
19644
+ const fallbackPriors = /* @__PURE__ */ new Map();
19645
+ if (previous) {
19646
+ for (const section of previous.sections) {
19647
+ if (section.sourceMemoryIds.length > 0 && section.sourceMemoryIds.every((id) => {
19648
+ const memory = memoriesById.get(id);
19649
+ return memory && !memory.isDeleted && !memory.supersededBy && scopes.includes(memory.scope) && (options.reviewedMemoryIds === void 0 || options.reviewedMemoryIds.includes(id)) && changeTime(memory) <= previous.vaultWatermark;
19650
+ })) {
19651
+ fallbackPriors.set(section.key, section);
19652
+ }
19653
+ }
19654
+ }
19643
19655
  const settled = await Promise.allSettled(
19644
19656
  facets.map(async (facet) => {
19645
19657
  const prior = previous?.sections.find((s) => s.key === facet.key);
19646
19658
  if (prior && !staleKeys.has(facet.key)) {
19647
19659
  return prior;
19648
19660
  }
19649
- return synthesizeFacet(facet, ctx, options, prior);
19661
+ return synthesizeFacet(facet, ctx, options, fallbackPriors.get(facet.key));
19650
19662
  })
19651
19663
  );
19652
19664
  const sections = settled.map((r, i) => {
@@ -19659,10 +19671,7 @@ async function synthesizeProfile(ctx, options = {}) {
19659
19671
  error: r.reason instanceof Error ? r.reason.message : String(r.reason)
19660
19672
  }
19661
19673
  );
19662
- return fallbackSection(
19663
- facet,
19664
- previous?.sections.find((s) => s.key === facet.key)
19665
- );
19674
+ return fallbackSection(facet, fallbackPriors.get(facet.key));
19666
19675
  });
19667
19676
  return {
19668
19677
  version: PROFILE_DOC_VERSION,
@@ -19850,7 +19859,7 @@ async function synthesizeFacet(facet, ctx, options, prior) {
19850
19859
  const { text: text12, legitimateEmpty } = extractFacetText(result.structuredOutput);
19851
19860
  if (!text12 && !legitimateEmpty && !noEvidence) {
19852
19861
  getLogger().warn(
19853
- "[memory/synthesizeProfile] facet synthesis returned degraded-empty; keeping prior section",
19862
+ "[memory/synthesizeProfile] facet synthesis returned degraded-empty; using fallback section",
19854
19863
  { facet: facet.key, recalledCount: result.basedOn.memoryIds.length }
19855
19864
  );
19856
19865
  return fallbackSection(facet, prior);
@@ -9924,8 +9924,7 @@ interface ProfileSection {
9924
9924
  interests?: string[];
9925
9925
  /** Unix ms this section was generated. */
9926
9926
  generatedAt: number;
9927
- /** True when regeneration failed and a prior section value was carried
9928
- * forward (e.g. LLM returned empty) — the caller may choose to retry. */
9927
+ /** True when regeneration failed (e.g. LLM returned empty) — the caller may choose to retry. */
9929
9928
  stale?: boolean;
9930
9929
  }
9931
9930
  /** Fingerprint of the config that produced a {@link ProfileDoc}. Delta reuse
@@ -9924,8 +9924,7 @@ interface ProfileSection {
9924
9924
  interests?: string[];
9925
9925
  /** Unix ms this section was generated. */
9926
9926
  generatedAt: number;
9927
- /** True when regeneration failed and a prior section value was carried
9928
- * forward (e.g. LLM returned empty) — the caller may choose to retry. */
9927
+ /** True when regeneration failed (e.g. LLM returned empty) — the caller may choose to retry. */
9929
9928
  stale?: boolean;
9930
9929
  }
9931
9930
  /** Fingerprint of the config that produced a {@link ProfileDoc}. Delta reuse
@@ -9338,13 +9338,25 @@ async function synthesizeProfile(ctx, options = {}) {
9338
9338
  watermark,
9339
9339
  options.reviewedMemoryIds
9340
9340
  );
9341
+ const memoriesById = new Map(memories.map((memory) => [memory.uniqueId, memory]));
9342
+ const fallbackPriors = /* @__PURE__ */ new Map();
9343
+ if (previous) {
9344
+ for (const section of previous.sections) {
9345
+ if (section.sourceMemoryIds.length > 0 && section.sourceMemoryIds.every((id) => {
9346
+ const memory = memoriesById.get(id);
9347
+ return memory && !memory.isDeleted && !memory.supersededBy && scopes.includes(memory.scope) && (options.reviewedMemoryIds === void 0 || options.reviewedMemoryIds.includes(id)) && changeTime(memory) <= previous.vaultWatermark;
9348
+ })) {
9349
+ fallbackPriors.set(section.key, section);
9350
+ }
9351
+ }
9352
+ }
9341
9353
  const settled = await Promise.allSettled(
9342
9354
  facets.map(async (facet) => {
9343
9355
  const prior = previous?.sections.find((s) => s.key === facet.key);
9344
9356
  if (prior && !staleKeys.has(facet.key)) {
9345
9357
  return prior;
9346
9358
  }
9347
- return synthesizeFacet(facet, ctx, options, prior);
9359
+ return synthesizeFacet(facet, ctx, options, fallbackPriors.get(facet.key));
9348
9360
  })
9349
9361
  );
9350
9362
  const sections = settled.map((r, i) => {
@@ -9357,10 +9369,7 @@ async function synthesizeProfile(ctx, options = {}) {
9357
9369
  error: r.reason instanceof Error ? r.reason.message : String(r.reason)
9358
9370
  }
9359
9371
  );
9360
- return fallbackSection(
9361
- facet,
9362
- previous?.sections.find((s) => s.key === facet.key)
9363
- );
9372
+ return fallbackSection(facet, fallbackPriors.get(facet.key));
9364
9373
  });
9365
9374
  return {
9366
9375
  version: PROFILE_DOC_VERSION,
@@ -9548,7 +9557,7 @@ async function synthesizeFacet(facet, ctx, options, prior) {
9548
9557
  const { text: text12, legitimateEmpty } = extractFacetText(result.structuredOutput);
9549
9558
  if (!text12 && !legitimateEmpty && !noEvidence) {
9550
9559
  getLogger().warn(
9551
- "[memory/synthesizeProfile] facet synthesis returned degraded-empty; keeping prior section",
9560
+ "[memory/synthesizeProfile] facet synthesis returned degraded-empty; using fallback section",
9552
9561
  { facet: facet.key, recalledCount: result.basedOn.memoryIds.length }
9553
9562
  );
9554
9563
  return fallbackSection(facet, prior);
@@ -31253,13 +31253,25 @@ async function synthesizeProfile(ctx, options = {}) {
31253
31253
  watermark,
31254
31254
  options.reviewedMemoryIds
31255
31255
  );
31256
+ const memoriesById = new Map(memories.map((memory) => [memory.uniqueId, memory]));
31257
+ const fallbackPriors = /* @__PURE__ */ new Map();
31258
+ if (previous) {
31259
+ for (const section of previous.sections) {
31260
+ if (section.sourceMemoryIds.length > 0 && section.sourceMemoryIds.every((id) => {
31261
+ const memory = memoriesById.get(id);
31262
+ return memory && !memory.isDeleted && !memory.supersededBy && scopes.includes(memory.scope) && (options.reviewedMemoryIds === void 0 || options.reviewedMemoryIds.includes(id)) && changeTime(memory) <= previous.vaultWatermark;
31263
+ })) {
31264
+ fallbackPriors.set(section.key, section);
31265
+ }
31266
+ }
31267
+ }
31256
31268
  const settled = await Promise.allSettled(
31257
31269
  facets.map(async (facet) => {
31258
31270
  const prior = previous?.sections.find((s) => s.key === facet.key);
31259
31271
  if (prior && !staleKeys.has(facet.key)) {
31260
31272
  return prior;
31261
31273
  }
31262
- return synthesizeFacet(facet, ctx, options, prior);
31274
+ return synthesizeFacet(facet, ctx, options, fallbackPriors.get(facet.key));
31263
31275
  })
31264
31276
  );
31265
31277
  const sections = settled.map((r, i) => {
@@ -31272,10 +31284,7 @@ async function synthesizeProfile(ctx, options = {}) {
31272
31284
  error: r.reason instanceof Error ? r.reason.message : String(r.reason)
31273
31285
  }
31274
31286
  );
31275
- return fallbackSection(
31276
- facet,
31277
- previous?.sections.find((s) => s.key === facet.key)
31278
- );
31287
+ return fallbackSection(facet, fallbackPriors.get(facet.key));
31279
31288
  });
31280
31289
  return {
31281
31290
  version: PROFILE_DOC_VERSION,
@@ -31463,7 +31472,7 @@ async function synthesizeFacet(facet, ctx, options, prior) {
31463
31472
  const { text: text12, legitimateEmpty } = extractFacetText(result.structuredOutput);
31464
31473
  if (!text12 && !legitimateEmpty && !noEvidence) {
31465
31474
  getLogger().warn(
31466
- "[memory/synthesizeProfile] facet synthesis returned degraded-empty; keeping prior section",
31475
+ "[memory/synthesizeProfile] facet synthesis returned degraded-empty; using fallback section",
31467
31476
  { facet: facet.key, recalledCount: result.basedOn.memoryIds.length }
31468
31477
  );
31469
31478
  return fallbackSection(facet, prior);
@@ -9334,8 +9334,7 @@ interface ProfileSection {
9334
9334
  interests?: string[];
9335
9335
  /** Unix ms this section was generated. */
9336
9336
  generatedAt: number;
9337
- /** True when regeneration failed and a prior section value was carried
9338
- * forward (e.g. LLM returned empty) — the caller may choose to retry. */
9337
+ /** True when regeneration failed (e.g. LLM returned empty) — the caller may choose to retry. */
9339
9338
  stale?: boolean;
9340
9339
  }
9341
9340
  /** Fingerprint of the config that produced a {@link ProfileDoc}. Delta reuse
@@ -9334,8 +9334,7 @@ interface ProfileSection {
9334
9334
  interests?: string[];
9335
9335
  /** Unix ms this section was generated. */
9336
9336
  generatedAt: number;
9337
- /** True when regeneration failed and a prior section value was carried
9338
- * forward (e.g. LLM returned empty) — the caller may choose to retry. */
9337
+ /** True when regeneration failed (e.g. LLM returned empty) — the caller may choose to retry. */
9339
9338
  stale?: boolean;
9340
9339
  }
9341
9340
  /** Fingerprint of the config that produced a {@link ProfileDoc}. Delta reuse
@@ -7370,13 +7370,25 @@ async function synthesizeProfile(ctx, options = {}) {
7370
7370
  watermark,
7371
7371
  options.reviewedMemoryIds
7372
7372
  );
7373
+ const memoriesById = new Map(memories.map((memory) => [memory.uniqueId, memory]));
7374
+ const fallbackPriors = /* @__PURE__ */ new Map();
7375
+ if (previous) {
7376
+ for (const section of previous.sections) {
7377
+ if (section.sourceMemoryIds.length > 0 && section.sourceMemoryIds.every((id) => {
7378
+ const memory = memoriesById.get(id);
7379
+ return memory && !memory.isDeleted && !memory.supersededBy && scopes.includes(memory.scope) && (options.reviewedMemoryIds === void 0 || options.reviewedMemoryIds.includes(id)) && changeTime(memory) <= previous.vaultWatermark;
7380
+ })) {
7381
+ fallbackPriors.set(section.key, section);
7382
+ }
7383
+ }
7384
+ }
7373
7385
  const settled = await Promise.allSettled(
7374
7386
  facets.map(async (facet) => {
7375
7387
  const prior = previous?.sections.find((s) => s.key === facet.key);
7376
7388
  if (prior && !staleKeys.has(facet.key)) {
7377
7389
  return prior;
7378
7390
  }
7379
- return synthesizeFacet(facet, ctx, options, prior);
7391
+ return synthesizeFacet(facet, ctx, options, fallbackPriors.get(facet.key));
7380
7392
  })
7381
7393
  );
7382
7394
  const sections = settled.map((r, i) => {
@@ -7389,10 +7401,7 @@ async function synthesizeProfile(ctx, options = {}) {
7389
7401
  error: r.reason instanceof Error ? r.reason.message : String(r.reason)
7390
7402
  }
7391
7403
  );
7392
- return fallbackSection(
7393
- facet,
7394
- previous?.sections.find((s) => s.key === facet.key)
7395
- );
7404
+ return fallbackSection(facet, fallbackPriors.get(facet.key));
7396
7405
  });
7397
7406
  return {
7398
7407
  version: PROFILE_DOC_VERSION,
@@ -7580,7 +7589,7 @@ async function synthesizeFacet(facet, ctx, options, prior) {
7580
7589
  const { text: text12, legitimateEmpty } = extractFacetText(result.structuredOutput);
7581
7590
  if (!text12 && !legitimateEmpty && !noEvidence) {
7582
7591
  getLogger().warn(
7583
- "[memory/synthesizeProfile] facet synthesis returned degraded-empty; keeping prior section",
7592
+ "[memory/synthesizeProfile] facet synthesis returned degraded-empty; using fallback section",
7584
7593
  { facet: facet.key, recalledCount: result.basedOn.memoryIds.length }
7585
7594
  );
7586
7595
  return fallbackSection(facet, prior);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anuma/sdk",
3
- "version": "6.21.0",
3
+ "version": "6.21.1",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",