@anuma/sdk 6.8.0 → 6.8.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.
@@ -1891,9 +1891,10 @@ async function updateMessageChunksOp(ctx, uniqueId, chunks, embeddingModel) {
1891
1891
  } catch {
1892
1892
  return null;
1893
1893
  }
1894
+ const storedChunks = chunks.map(({ text: _text, ...rest }) => rest);
1894
1895
  await ctx.database.write(async () => {
1895
1896
  await message.update((msg) => {
1896
- msg._setRaw("chunks", JSON.stringify(chunks));
1897
+ msg._setRaw("chunks", JSON.stringify(storedChunks));
1897
1898
  msg._setRaw("embedding_model", embeddingModel);
1898
1899
  });
1899
1900
  });
@@ -1991,6 +1992,16 @@ async function _updateMessageOp(ctx, uniqueId, opts) {
1991
1992
  });
1992
1993
  return messageToStored(message, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
1993
1994
  }
1995
+ function resolveChunkText(content, chunk, chunksInRow) {
1996
+ if (!chunk) return content;
1997
+ if (typeof chunk.text === "string" && chunk.text.length > 0) return chunk.text;
1998
+ const { startOffset: start, endOffset: end } = chunk;
1999
+ if (!Number.isInteger(start) || !Number.isInteger(end)) return content;
2000
+ if (start < 0 || end <= start || end > content.length) return content;
2001
+ const covered = chunksInRow?.reduce((max, c) => Math.max(max, c.endOffset ?? 0), 0) ?? 0;
2002
+ if (covered !== content.length) return content;
2003
+ return content.slice(start, end);
2004
+ }
1994
2005
  async function readJsonField(model, column, walletAddress) {
1995
2006
  const raw = model._getRaw(column);
1996
2007
  if (!raw) return void 0;
@@ -2104,7 +2115,7 @@ async function searchChunksOp(ctx, queryVector, options) {
2104
2115
  candidates.push({
2105
2116
  message,
2106
2117
  similarity,
2107
- chunkTextSource: { kind: "chunk", text: chunks[ci].text }
2118
+ chunkTextSource: { kind: "chunk", chunk: chunks[ci], siblings: chunks }
2108
2119
  });
2109
2120
  }
2110
2121
  }
@@ -2162,11 +2173,11 @@ async function searchChunksOp(ctx, queryVector, options) {
2162
2173
  const stored = { ...storedById.get(message.id) };
2163
2174
  let chunkText2;
2164
2175
  if (chunkTextSource.kind === "chunk") {
2165
- chunkText2 = chunkTextSource.text;
2176
+ chunkText2 = resolveChunkText(stored.content, chunkTextSource.chunk, chunkTextSource.siblings);
2166
2177
  } else if (chunkTextSource.kind === "chunk-cached") {
2167
2178
  const state = chunkStateByMsgId.get(message.id);
2168
2179
  const chunk = state && state.version === chunkTextSource.version ? state.chunks[chunkTextSource.chunkIndex] : void 0;
2169
- chunkText2 = chunk?.text ?? stored.content;
2180
+ chunkText2 = resolveChunkText(stored.content, chunk, state?.chunks);
2170
2181
  } else {
2171
2182
  chunkText2 = stored.content;
2172
2183
  }
@@ -7085,7 +7096,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
7085
7096
  subQueries = decomp.subQueries;
7086
7097
  }
7087
7098
  }
7088
- const { recall: recall2 } = await import("./recall-B2AIAPCM.mjs");
7099
+ const { recall: recall2 } = await import("./recall-3I5GDJZE.mjs");
7089
7100
  let recallDegraded = [];
7090
7101
  const result = await recall2(
7091
7102
  query,
@@ -2338,9 +2338,10 @@ async function updateMessageChunksOp(ctx, uniqueId, chunks, embeddingModel) {
2338
2338
  } catch {
2339
2339
  return null;
2340
2340
  }
2341
+ const storedChunks = chunks.map(({ text: _text, ...rest }) => rest);
2341
2342
  await ctx.database.write(async () => {
2342
2343
  await message.update((msg) => {
2343
- msg._setRaw("chunks", JSON.stringify(chunks));
2344
+ msg._setRaw("chunks", JSON.stringify(storedChunks));
2344
2345
  msg._setRaw("embedding_model", embeddingModel);
2345
2346
  });
2346
2347
  });
@@ -2438,6 +2439,16 @@ async function _updateMessageOp(ctx, uniqueId, opts) {
2438
2439
  });
2439
2440
  return messageToStored(message, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
2440
2441
  }
2442
+ function resolveChunkText(content, chunk, chunksInRow) {
2443
+ if (!chunk) return content;
2444
+ if (typeof chunk.text === "string" && chunk.text.length > 0) return chunk.text;
2445
+ const { startOffset: start, endOffset: end } = chunk;
2446
+ if (!Number.isInteger(start) || !Number.isInteger(end)) return content;
2447
+ if (start < 0 || end <= start || end > content.length) return content;
2448
+ const covered = chunksInRow?.reduce((max, c) => Math.max(max, c.endOffset ?? 0), 0) ?? 0;
2449
+ if (covered !== content.length) return content;
2450
+ return content.slice(start, end);
2451
+ }
2441
2452
  async function readJsonField(model, column, walletAddress) {
2442
2453
  const raw = model._getRaw(column);
2443
2454
  if (!raw) return void 0;
@@ -2551,7 +2562,7 @@ async function searchChunksOp(ctx, queryVector, options) {
2551
2562
  candidates.push({
2552
2563
  message,
2553
2564
  similarity,
2554
- chunkTextSource: { kind: "chunk", text: chunks[ci].text }
2565
+ chunkTextSource: { kind: "chunk", chunk: chunks[ci], siblings: chunks }
2555
2566
  });
2556
2567
  }
2557
2568
  }
@@ -2609,11 +2620,11 @@ async function searchChunksOp(ctx, queryVector, options) {
2609
2620
  const stored = { ...storedById.get(message.id) };
2610
2621
  let chunkText2;
2611
2622
  if (chunkTextSource.kind === "chunk") {
2612
- chunkText2 = chunkTextSource.text;
2623
+ chunkText2 = resolveChunkText(stored.content, chunkTextSource.chunk, chunkTextSource.siblings);
2613
2624
  } else if (chunkTextSource.kind === "chunk-cached") {
2614
2625
  const state = chunkStateByMsgId.get(message.id);
2615
2626
  const chunk = state && state.version === chunkTextSource.version ? state.chunks[chunkTextSource.chunkIndex] : void 0;
2616
- chunkText2 = chunk?.text ?? stored.content;
2627
+ chunkText2 = resolveChunkText(stored.content, chunk, state?.chunks);
2617
2628
  } else {
2618
2629
  chunkText2 = stored.content;
2619
2630
  }
@@ -5055,8 +5055,26 @@ interface StoredMessageWithSimilarity extends StoredMessage {
5055
5055
  * A chunk of a message with its own embedding for fine-grained search
5056
5056
  */
5057
5057
  interface MessageChunk {
5058
- /** The chunk text */
5059
- text: string;
5058
+ /**
5059
+ * The chunk text — IN MEMORY ONLY. Not persisted (sdk#880).
5060
+ *
5061
+ * `chunkText` covers a message end to end with a 50-character overlap, so the
5062
+ * chunk set of any message over 400 characters reconstructs the whole thing.
5063
+ * Storing it put a fully readable copy of the message next to its own
5064
+ * ciphertext `content` on devices with at-rest encryption enabled.
5065
+ *
5066
+ * `updateMessageChunksOp` now strips this before writing and readers rebuild
5067
+ * the snippet from {@link startOffset}/{@link endOffset} against the message's
5068
+ * own (decrypted) `content` — so the text exists exactly once, under the
5069
+ * protection `content` already has. Encrypting the column instead was
5070
+ * rejected: the client reads this column raw and `JSON.parse`s it in four
5071
+ * places, each swallowing the throw and silently scoring 0.
5072
+ *
5073
+ * Optional because rows written before that change still carry it, and
5074
+ * readers prefer a stored value when present. It is populated in memory by
5075
+ * `chunkText()` and on the way out of a search.
5076
+ */
5077
+ text?: string;
5060
5078
  /**
5061
5079
  * Embedding vector for this chunk.
5062
5080
  *
@@ -5055,8 +5055,26 @@ interface StoredMessageWithSimilarity extends StoredMessage {
5055
5055
  * A chunk of a message with its own embedding for fine-grained search
5056
5056
  */
5057
5057
  interface MessageChunk {
5058
- /** The chunk text */
5059
- text: string;
5058
+ /**
5059
+ * The chunk text — IN MEMORY ONLY. Not persisted (sdk#880).
5060
+ *
5061
+ * `chunkText` covers a message end to end with a 50-character overlap, so the
5062
+ * chunk set of any message over 400 characters reconstructs the whole thing.
5063
+ * Storing it put a fully readable copy of the message next to its own
5064
+ * ciphertext `content` on devices with at-rest encryption enabled.
5065
+ *
5066
+ * `updateMessageChunksOp` now strips this before writing and readers rebuild
5067
+ * the snippet from {@link startOffset}/{@link endOffset} against the message's
5068
+ * own (decrypted) `content` — so the text exists exactly once, under the
5069
+ * protection `content` already has. Encrypting the column instead was
5070
+ * rejected: the client reads this column raw and `JSON.parse`s it in four
5071
+ * places, each swallowing the throw and silently scoring 0.
5072
+ *
5073
+ * Optional because rows written before that change still carry it, and
5074
+ * readers prefer a stored value when present. It is populated in memory by
5075
+ * `chunkText()` and on the way out of a search.
5076
+ */
5077
+ text?: string;
5060
5078
  /**
5061
5079
  * Embedding vector for this chunk.
5062
5080
  *
@@ -178,7 +178,7 @@ import {
178
178
  updateVaultMemoryOp,
179
179
  useEncryption,
180
180
  vaultMemoryToStored
181
- } from "./chunk-POCLKALT.mjs";
181
+ } from "./chunk-NPJSO5ES.mjs";
182
182
  import {
183
183
  PiiRedactor,
184
184
  createStreamingDeAnonymizer,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  recall
3
- } from "./chunk-POCLKALT.mjs";
3
+ } from "./chunk-NPJSO5ES.mjs";
4
4
  import "./chunk-CJ32HO6Q.mjs";
5
5
  import "./chunk-GYKJOWEO.mjs";
6
6
  export {
@@ -15964,9 +15964,10 @@ async function updateMessageChunksOp(ctx, uniqueId, chunks, embeddingModel) {
15964
15964
  } catch {
15965
15965
  return null;
15966
15966
  }
15967
+ const storedChunks = chunks.map(({ text: _text, ...rest }) => rest);
15967
15968
  await ctx.database.write(async () => {
15968
15969
  await message.update((msg) => {
15969
- msg._setRaw("chunks", JSON.stringify(chunks));
15970
+ msg._setRaw("chunks", JSON.stringify(storedChunks));
15970
15971
  msg._setRaw("embedding_model", embeddingModel);
15971
15972
  });
15972
15973
  });
@@ -16061,6 +16062,16 @@ async function _updateMessageOp(ctx, uniqueId, opts) {
16061
16062
  });
16062
16063
  return messageToStored(message, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
16063
16064
  }
16065
+ function resolveChunkText(content, chunk, chunksInRow) {
16066
+ if (!chunk) return content;
16067
+ if (typeof chunk.text === "string" && chunk.text.length > 0) return chunk.text;
16068
+ const { startOffset: start, endOffset: end } = chunk;
16069
+ if (!Number.isInteger(start) || !Number.isInteger(end)) return content;
16070
+ if (start < 0 || end <= start || end > content.length) return content;
16071
+ const covered = chunksInRow?.reduce((max, c) => Math.max(max, c.endOffset ?? 0), 0) ?? 0;
16072
+ if (covered !== content.length) return content;
16073
+ return content.slice(start, end);
16074
+ }
16064
16075
  async function readJsonField(model, column, walletAddress) {
16065
16076
  const raw = model._getRaw(column);
16066
16077
  if (!raw) return void 0;
@@ -16174,7 +16185,7 @@ async function searchChunksOp(ctx, queryVector, options) {
16174
16185
  candidates.push({
16175
16186
  message,
16176
16187
  similarity,
16177
- chunkTextSource: { kind: "chunk", text: chunks[ci].text }
16188
+ chunkTextSource: { kind: "chunk", chunk: chunks[ci], siblings: chunks }
16178
16189
  });
16179
16190
  }
16180
16191
  }
@@ -16232,11 +16243,11 @@ async function searchChunksOp(ctx, queryVector, options) {
16232
16243
  const stored = { ...storedById.get(message.id) };
16233
16244
  let chunkText2;
16234
16245
  if (chunkTextSource.kind === "chunk") {
16235
- chunkText2 = chunkTextSource.text;
16246
+ chunkText2 = resolveChunkText(stored.content, chunkTextSource.chunk, chunkTextSource.siblings);
16236
16247
  } else if (chunkTextSource.kind === "chunk-cached") {
16237
16248
  const state = chunkStateByMsgId.get(message.id);
16238
16249
  const chunk = state && state.version === chunkTextSource.version ? state.chunks[chunkTextSource.chunkIndex] : void 0;
16239
- chunkText2 = chunk?.text ?? stored.content;
16250
+ chunkText2 = resolveChunkText(stored.content, chunk, state?.chunks);
16240
16251
  } else {
16241
16252
  chunkText2 = stored.content;
16242
16253
  }
@@ -20845,7 +20856,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
20845
20856
  subQueries = decomp.subQueries;
20846
20857
  }
20847
20858
  }
20848
- const { recall: recall2 } = await import("./recall-2GAPE2XH.mjs");
20859
+ const { recall: recall2 } = await import("./recall-RTW7T7KR.mjs");
20849
20860
  let recallDegraded = [];
20850
20861
  const result = await recall2(
20851
20862
  query,
@@ -16722,9 +16722,10 @@ async function updateMessageChunksOp(ctx, uniqueId, chunks, embeddingModel) {
16722
16722
  } catch {
16723
16723
  return null;
16724
16724
  }
16725
+ const storedChunks = chunks.map(({ text: _text, ...rest }) => rest);
16725
16726
  await ctx.database.write(async () => {
16726
16727
  await message.update((msg) => {
16727
- msg._setRaw("chunks", JSON.stringify(chunks));
16728
+ msg._setRaw("chunks", JSON.stringify(storedChunks));
16728
16729
  msg._setRaw("embedding_model", embeddingModel);
16729
16730
  });
16730
16731
  });
@@ -16819,6 +16820,16 @@ async function _updateMessageOp(ctx, uniqueId, opts) {
16819
16820
  });
16820
16821
  return messageToStored(message, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
16821
16822
  }
16823
+ function resolveChunkText(content, chunk, chunksInRow) {
16824
+ if (!chunk) return content;
16825
+ if (typeof chunk.text === "string" && chunk.text.length > 0) return chunk.text;
16826
+ const { startOffset: start, endOffset: end } = chunk;
16827
+ if (!Number.isInteger(start) || !Number.isInteger(end)) return content;
16828
+ if (start < 0 || end <= start || end > content.length) return content;
16829
+ const covered = chunksInRow?.reduce((max, c) => Math.max(max, c.endOffset ?? 0), 0) ?? 0;
16830
+ if (covered !== content.length) return content;
16831
+ return content.slice(start, end);
16832
+ }
16822
16833
  async function readJsonField(model, column, walletAddress) {
16823
16834
  const raw = model._getRaw(column);
16824
16835
  if (!raw) return void 0;
@@ -16932,7 +16943,7 @@ async function searchChunksOp(ctx, queryVector, options) {
16932
16943
  candidates.push({
16933
16944
  message,
16934
16945
  similarity,
16935
- chunkTextSource: { kind: "chunk", text: chunks[ci].text }
16946
+ chunkTextSource: { kind: "chunk", chunk: chunks[ci], siblings: chunks }
16936
16947
  });
16937
16948
  }
16938
16949
  }
@@ -16990,11 +17001,11 @@ async function searchChunksOp(ctx, queryVector, options) {
16990
17001
  const stored = { ...storedById.get(message.id) };
16991
17002
  let chunkText2;
16992
17003
  if (chunkTextSource.kind === "chunk") {
16993
- chunkText2 = chunkTextSource.text;
17004
+ chunkText2 = resolveChunkText(stored.content, chunkTextSource.chunk, chunkTextSource.siblings);
16994
17005
  } else if (chunkTextSource.kind === "chunk-cached") {
16995
17006
  const state = chunkStateByMsgId.get(message.id);
16996
17007
  const chunk = state && state.version === chunkTextSource.version ? state.chunks[chunkTextSource.chunkIndex] : void 0;
16997
- chunkText2 = chunk?.text ?? stored.content;
17008
+ chunkText2 = resolveChunkText(stored.content, chunk, state?.chunks);
16998
17009
  } else {
16999
17010
  chunkText2 = stored.content;
17000
17011
  }
@@ -3642,8 +3642,26 @@ interface StoredConversationSummary {
3642
3642
  * A chunk of a message with its own embedding for fine-grained search
3643
3643
  */
3644
3644
  interface MessageChunk {
3645
- /** The chunk text */
3646
- text: string;
3645
+ /**
3646
+ * The chunk text — IN MEMORY ONLY. Not persisted (sdk#880).
3647
+ *
3648
+ * `chunkText` covers a message end to end with a 50-character overlap, so the
3649
+ * chunk set of any message over 400 characters reconstructs the whole thing.
3650
+ * Storing it put a fully readable copy of the message next to its own
3651
+ * ciphertext `content` on devices with at-rest encryption enabled.
3652
+ *
3653
+ * `updateMessageChunksOp` now strips this before writing and readers rebuild
3654
+ * the snippet from {@link startOffset}/{@link endOffset} against the message's
3655
+ * own (decrypted) `content` — so the text exists exactly once, under the
3656
+ * protection `content` already has. Encrypting the column instead was
3657
+ * rejected: the client reads this column raw and `JSON.parse`s it in four
3658
+ * places, each swallowing the throw and silently scoring 0.
3659
+ *
3660
+ * Optional because rows written before that change still carry it, and
3661
+ * readers prefer a stored value when present. It is populated in memory by
3662
+ * `chunkText()` and on the way out of a search.
3663
+ */
3664
+ text?: string;
3647
3665
  /**
3648
3666
  * Embedding vector for this chunk.
3649
3667
  *
@@ -3642,8 +3642,26 @@ interface StoredConversationSummary {
3642
3642
  * A chunk of a message with its own embedding for fine-grained search
3643
3643
  */
3644
3644
  interface MessageChunk {
3645
- /** The chunk text */
3646
- text: string;
3645
+ /**
3646
+ * The chunk text — IN MEMORY ONLY. Not persisted (sdk#880).
3647
+ *
3648
+ * `chunkText` covers a message end to end with a 50-character overlap, so the
3649
+ * chunk set of any message over 400 characters reconstructs the whole thing.
3650
+ * Storing it put a fully readable copy of the message next to its own
3651
+ * ciphertext `content` on devices with at-rest encryption enabled.
3652
+ *
3653
+ * `updateMessageChunksOp` now strips this before writing and readers rebuild
3654
+ * the snippet from {@link startOffset}/{@link endOffset} against the message's
3655
+ * own (decrypted) `content` — so the text exists exactly once, under the
3656
+ * protection `content` already has. Encrypting the column instead was
3657
+ * rejected: the client reads this column raw and `JSON.parse`s it in four
3658
+ * places, each swallowing the throw and silently scoring 0.
3659
+ *
3660
+ * Optional because rows written before that change still carry it, and
3661
+ * readers prefer a stored value when present. It is populated in memory by
3662
+ * `chunkText()` and on the way out of a search.
3663
+ */
3664
+ text?: string;
3647
3665
  /**
3648
3666
  * Embedding vector for this chunk.
3649
3667
  *
@@ -141,7 +141,7 @@ import {
141
141
  updateVaultMemoryOp,
142
142
  upsertMessageOp,
143
143
  vaultMemoryToStored
144
- } from "./chunk-FS6DNUNT.mjs";
144
+ } from "./chunk-IP6PGI7H.mjs";
145
145
  import {
146
146
  createStreamingDeAnonymizer,
147
147
  notifyConsolidationFallback,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  recall
3
- } from "./chunk-FS6DNUNT.mjs";
3
+ } from "./chunk-IP6PGI7H.mjs";
4
4
  import "./chunk-KF5OU4IN.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": "6.8.0",
3
+ "version": "6.8.2",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -160,7 +160,7 @@
160
160
  "homepage": "https://github.com/anuma-ai/sdk#readme",
161
161
  "packageManager": "pnpm@10.23.0",
162
162
  "dependencies": {
163
- "@anuma/portal": "1.0.0-next.20260806040449",
163
+ "@anuma/portal": "1.0.0-next.20260811055217",
164
164
  "@babel/parser": "^7.29.2",
165
165
  "@babel/types": "^7.29.0",
166
166
  "ai": "6.0.202",