@anuma/sdk 7.6.0 → 8.0.0

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.
@@ -16426,6 +16426,7 @@ __export(index_exports, {
16426
16426
  decryptDataBytes: () => decryptDataBytes,
16427
16427
  decryptDataBytesFromBytes: () => decryptDataBytesFromBytes,
16428
16428
  decryptDataWithKey: () => decryptDataWithKey,
16429
+ decryptMessageEmbeddingFields: () => decryptMessageEmbeddingFields,
16429
16430
  defaultServerToolsFilter: () => defaultServerToolsFilter,
16430
16431
  deleteAllVaultMemoriesForUserOp: () => deleteAllVaultMemoriesForUserOp,
16431
16432
  deleteConversationOp: () => deleteConversationOp,
@@ -16549,6 +16550,7 @@ __export(index_exports, {
16549
16550
  sdkMigrations: () => sdkMigrations,
16550
16551
  sdkModelClasses: () => sdkModelClasses,
16551
16552
  sdkSchema: () => sdkSchema,
16553
+ sealLegacyMessageEmbeddingsOp: () => sealLegacyMessageEmbeddingsOp,
16552
16554
  searchChunksOp: () => searchChunksOp,
16553
16555
  searchMediaOp: () => searchMediaOp,
16554
16556
  searchMessagesOp: () => searchMessagesOp,
@@ -18594,16 +18596,19 @@ async function updateMessageEmbeddingOp(ctx, uniqueId, vector, embeddingModel) {
18594
18596
  } catch {
18595
18597
  return null;
18596
18598
  }
18599
+ const address = ctx.walletAddress;
18597
18600
  await ctx.database.write(async () => {
18601
+ const key = await resolveMessageEmbeddingKey(address, message.content);
18602
+ const storedVector = await serializeMessageEmbedding(key, vector);
18598
18603
  await message.update((msg) => {
18599
- msg._setRaw("vector", JSON.stringify(vector));
18604
+ msg._setRaw("vector", storedVector);
18600
18605
  if (msg.origin === "chunks_discarded" && vector.length > 0) {
18601
18606
  msg._setRaw("origin", "message");
18602
18607
  }
18603
18608
  msg._setRaw("embedding_model", embeddingModel);
18604
18609
  });
18605
18610
  });
18606
- return messageToStored(message, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
18611
+ return messageToStored(message, ctx.walletAddress);
18607
18612
  }
18608
18613
  async function updateMessageChunksOp(ctx, uniqueId, chunks, embeddingModel) {
18609
18614
  let message;
@@ -18613,16 +18618,123 @@ async function updateMessageChunksOp(ctx, uniqueId, chunks, embeddingModel) {
18613
18618
  return null;
18614
18619
  }
18615
18620
  const storedChunks = chunks.map(({ text: _text, ...rest }) => rest);
18621
+ const address = ctx.walletAddress;
18616
18622
  await ctx.database.write(async () => {
18623
+ const key = await resolveMessageEmbeddingKey(address, message.content);
18624
+ const serializedChunks = await serializeMessageEmbedding(key, storedChunks);
18617
18625
  await message.update((msg) => {
18618
- msg._setRaw("chunks", JSON.stringify(storedChunks));
18626
+ msg._setRaw("chunks", serializedChunks);
18619
18627
  if (msg.origin === "chunks_discarded" && storedChunks.length > 0 && storedChunks.every((chunk) => chunk.vector.length > 0)) {
18620
18628
  msg._setRaw("origin", "message");
18621
18629
  }
18622
18630
  msg._setRaw("embedding_model", embeddingModel);
18623
18631
  });
18624
18632
  });
18625
- return messageToStored(message, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
18633
+ return messageToStored(message, ctx.walletAddress);
18634
+ }
18635
+ async function resolveMessageEmbeddingKey(address, content) {
18636
+ if (!address || !isEncrypted(content)) return null;
18637
+ const key = await getEncryptionKey(address, "v3");
18638
+ const contentKey = content.startsWith("enc:v2:") ? await getEncryptionKey(address, "v2") : key;
18639
+ try {
18640
+ await decryptDataWithKey(content.slice("enc:vN:".length), contentKey);
18641
+ } catch {
18642
+ throw new Error("Cannot decrypt the message with the cached wallet key");
18643
+ }
18644
+ return key;
18645
+ }
18646
+ async function serializeMessageEmbedding(key, value) {
18647
+ const json4 = JSON.stringify(value);
18648
+ return key ? `enc:v3:${await encryptDataWithKey(json4, key)}` : json4;
18649
+ }
18650
+ async function decryptMessageEmbeddingFields(raw, walletAddress) {
18651
+ const result = { ...raw };
18652
+ for (const column of ["vector", "chunks"]) {
18653
+ const value = raw[column];
18654
+ if (typeof value !== "string" || !value.startsWith("enc:")) continue;
18655
+ const decrypted = walletAddress ? await decryptField(value, walletAddress) : value;
18656
+ result[column] = decrypted.startsWith("enc:") ? void 0 : decrypted;
18657
+ }
18658
+ return result;
18659
+ }
18660
+ async function sealLegacyMessageEmbeddingsOp(ctx) {
18661
+ if (!ctx.walletAddress) return 0;
18662
+ const candidateIds = await ctx.messagesCollection.query(
18663
+ import_watermelondb2.Q.where("content", import_watermelondb2.Q.like("enc:%")),
18664
+ import_watermelondb2.Q.or(
18665
+ ...["vector", "chunks"].map(
18666
+ (column) => import_watermelondb2.Q.and(
18667
+ import_watermelondb2.Q.where(column, import_watermelondb2.Q.notEq(null)),
18668
+ import_watermelondb2.Q.where(column, import_watermelondb2.Q.notEq("")),
18669
+ import_watermelondb2.Q.where(column, import_watermelondb2.Q.notLike("enc:%"))
18670
+ )
18671
+ )
18672
+ )
18673
+ ).fetchIds();
18674
+ let sealed = 0;
18675
+ let undecryptable = 0;
18676
+ for (let start = 0; start < candidateIds.length; start += 50) {
18677
+ const pageIds = candidateIds.slice(start, start + 50);
18678
+ await ctx.database.write(async () => {
18679
+ const pageMessages = await ctx.messagesCollection.query(import_watermelondb2.Q.where("id", import_watermelondb2.Q.oneOf(pageIds))).fetch();
18680
+ for (const message of pageMessages) {
18681
+ if (!isEncrypted(message.content)) continue;
18682
+ const content = await decryptFieldDetailed(message.content, ctx.walletAddress);
18683
+ if (content.status === "key_missing") {
18684
+ throw new Error("Cannot decrypt the message with the cached wallet key");
18685
+ }
18686
+ if (content.status !== "ok") {
18687
+ undecryptable++;
18688
+ continue;
18689
+ }
18690
+ const plaintext = content.value;
18691
+ const key = await resolveMessageEmbeddingKey(ctx.walletAddress, message.content);
18692
+ const updates = {};
18693
+ for (const column of ["vector", "chunks"]) {
18694
+ const value = message._getRaw(column);
18695
+ if (typeof value !== "string" || value.startsWith("enc:") || !value) continue;
18696
+ let parsed;
18697
+ try {
18698
+ parsed = JSON.parse(value);
18699
+ } catch {
18700
+ updates[column] = null;
18701
+ continue;
18702
+ }
18703
+ if (!Array.isArray(parsed)) {
18704
+ updates[column] = null;
18705
+ continue;
18706
+ }
18707
+ if (column === "chunks") {
18708
+ const chunks = parsed;
18709
+ if (chunks.some(
18710
+ (chunk) => !chunk || !Number.isInteger(chunk.startOffset) || !Number.isInteger(chunk.endOffset) || chunk.startOffset < 0 || chunk.endOffset <= chunk.startOffset || chunk.endOffset > plaintext.length
18711
+ )) {
18712
+ updates.chunks = null;
18713
+ updates.vector = null;
18714
+ updates.origin = message.origin === "tool_result" ? "tool_result" : "chunks_discarded";
18715
+ break;
18716
+ }
18717
+ parsed = chunks.map(({ text: _text, ...rest }) => rest);
18718
+ }
18719
+ updates[column] = await serializeMessageEmbedding(key, parsed);
18720
+ }
18721
+ if (Object.keys(updates).length === 0) continue;
18722
+ const updatedAt = Number(message._getRaw("updated_at"));
18723
+ const discarded = updates.origin !== void 0;
18724
+ await message.update((msg) => {
18725
+ for (const [column, value] of Object.entries(updates)) msg._setRaw(column, value);
18726
+ msg._setRaw("updated_at", discarded ? Math.max(Date.now(), updatedAt + 1) : updatedAt);
18727
+ });
18728
+ sealed++;
18729
+ }
18730
+ });
18731
+ }
18732
+ if (undecryptable > 0) {
18733
+ getLogger().warn(
18734
+ `Skipped ${undecryptable} message embeddings that the cached wallet key cannot decrypt`
18735
+ );
18736
+ }
18737
+ return sealed;
18626
18738
  }
18627
18739
  var RAW_REPAIR_PAGE_SIZE = 100;
18628
18740
  function chunksWithoutText(raw) {
@@ -39569,6 +39681,7 @@ async function preprocessFiles(files, options = {}) {
39569
39681
  }
39570
39682
 
39571
39683
  // src/server/pg-adapter.ts
39684
+ var import_node_crypto = require("crypto");
39572
39685
  var import_stepsForMigration = __toESM(require_stepsForMigration());
39573
39686
  function makeQualify(pgSchema) {
39574
39687
  if (pgSchema === "public") {
@@ -39585,7 +39698,7 @@ function paramList(params, values) {
39585
39698
  }
39586
39699
  var operators = {
39587
39700
  eq: "=",
39588
- notEq: "!=",
39701
+ notEq: "is distinct from",
39589
39702
  gt: ">",
39590
39703
  gte: ">=",
39591
39704
  weakGt: ">",
@@ -39636,6 +39749,11 @@ function encodeWhere(params, table, associations, clause) {
39636
39749
  throw new Error(`Unknown clause type: ${clause.type}`);
39637
39750
  }
39638
39751
  }
39752
+ function hasSql(clauses) {
39753
+ return clauses.some(
39754
+ (clause) => clause.type === "sql" || "conditions" in clause && hasSql(clause.conditions)
39755
+ );
39756
+ }
39639
39757
  function encodeQuery(query, qualify, countMode = false, idsOnly = false) {
39640
39758
  const { table, description, associations } = query;
39641
39759
  if (description.sql) {
@@ -39718,7 +39836,7 @@ function schemaToCreateSQL(schema, pgSchema = "public") {
39718
39836
  const def = ` default ${columnDefault(col)}`;
39719
39837
  cols.push(`"${col.name}" ${pgType}${nullable}${def}`);
39720
39838
  if (col.isIndexed) {
39721
- const indexName = pgSchema === "public" ? `"${tableName}_${col.name}"` : `"${pgSchema}_${tableName}_${col.name}"`;
39839
+ const indexName = `"${tableName}_${col.name}"`;
39722
39840
  indexes.push(
39723
39841
  `create index if not exists ${indexName} on ${qualify(tableName)} ("${col.name}");`
39724
39842
  );
@@ -39745,14 +39863,73 @@ var _PostgreSQLAdapter = class _PostgreSQLAdapter {
39745
39863
  this.dbName = options.dbName;
39746
39864
  this.migrations = options.migrations;
39747
39865
  this.pool = options.pool;
39748
- this._pgSchema = options.pgSchema ?? "public";
39866
+ this._pgSchema = `anuma_${(0, import_node_crypto.createHash)("sha256").update(JSON.stringify([options.pgSchema ?? "public", this.dbName])).digest("hex").slice(0, 48)}`;
39749
39867
  this.qualify = makeQualify(this._pgSchema);
39750
- this.initialized = this._initialize();
39868
+ this.initialized = this._initialize(
39869
+ options.pgSchema ?? "public",
39870
+ options.migrateLegacySchema ?? false
39871
+ );
39751
39872
  }
39752
- async _initialize() {
39753
- if (this._pgSchema !== "public") {
39754
- await this.pool.query(`create schema if not exists "${this._pgSchema}"`);
39873
+ async _hasLegacyData(pgSchema, executor) {
39874
+ const legacyStorage = `"${pgSchema.replace(/"/g, '""')}"."local_storage"`;
39875
+ const { rows } = await executor.query(
39876
+ "select to_regclass($1) as legacy, to_regclass($2) as isolated",
39877
+ [legacyStorage, this.qualify("local_storage")]
39878
+ );
39879
+ if (!rows[0]?.legacy) return false;
39880
+ if (rows[0].isolated) {
39881
+ const { rows: version2 } = await executor.query(
39882
+ `select "value" from ${this.qualify("local_storage")} where "key" = $1`,
39883
+ [_PostgreSQLAdapter.SCHEMA_VERSION_KEY]
39884
+ );
39885
+ if (Number(version2[0]?.value) > 0) return false;
39755
39886
  }
39887
+ const { rows: version } = await executor.query(
39888
+ `select "value" from ${legacyStorage} where "key" = $1`,
39889
+ [_PostgreSQLAdapter.SCHEMA_VERSION_KEY]
39890
+ );
39891
+ return Number(version[0]?.value) > 0;
39892
+ }
39893
+ async _upgradeLegacySchema(pgSchema, migrateLegacySchema) {
39894
+ if (!migrateLegacySchema) {
39895
+ if (await this._hasLegacyData(pgSchema, this.pool)) {
39896
+ throw new Error(
39897
+ "PostgreSQLAdapter found legacy data. Set migrateLegacySchema to true only for the database that owns all legacy records."
39898
+ );
39899
+ }
39900
+ return;
39901
+ }
39902
+ if (!this.pool.connect) {
39903
+ throw new Error("PostgreSQLAdapter legacy migration requires pool.connect");
39904
+ }
39905
+ const client2 = await this.pool.connect();
39906
+ try {
39907
+ await client2.query("BEGIN");
39908
+ await client2.query("select pg_advisory_xact_lock(hashtext($1))", [
39909
+ `PostgreSQLAdapter:${pgSchema}`
39910
+ ]);
39911
+ if (await this._hasLegacyData(pgSchema, client2)) {
39912
+ await client2.query(`create schema if not exists "${this._pgSchema}"`);
39913
+ const { rows } = await client2.query(
39914
+ "select tablename from pg_catalog.pg_tables where schemaname = $1 and tablename = any($2::text[])",
39915
+ [pgSchema, [...Object.keys(this.schema.tables), "local_storage"]]
39916
+ );
39917
+ for (const row of rows) {
39918
+ const table = `"${pgSchema.replace(/"/g, '""')}"."${String(row.tablename).replace(/"/g, '""')}"`;
39919
+ await client2.query(`alter table ${table} set schema "${this._pgSchema}"`);
39920
+ }
39921
+ }
39922
+ await client2.query("COMMIT");
39923
+ } catch (error) {
39924
+ await client2.query("ROLLBACK");
39925
+ throw error;
39926
+ } finally {
39927
+ client2.release();
39928
+ }
39929
+ }
39930
+ async _initialize(pgSchema, migrateLegacySchema) {
39931
+ await this._upgradeLegacySchema(pgSchema, migrateLegacySchema);
39932
+ await this.pool.query(`create schema if not exists "${this._pgSchema}"`);
39756
39933
  await this.pool.query(
39757
39934
  `create table if not exists ${this.qualify("local_storage")} ("key" text primary key, "value" text not null);`
39758
39935
  );
@@ -39821,7 +39998,7 @@ var _PostgreSQLAdapter = class _PostgreSQLAdapter {
39821
39998
  );
39822
39999
  for (const col of ts.columnArray) {
39823
40000
  if (col.isIndexed) {
39824
- const indexName = this._pgSchema === "public" ? `"${ts.name}_${col.name}"` : `"${this._pgSchema}_${ts.name}_${col.name}"`;
40001
+ const indexName = `"${ts.name}_${col.name}"`;
39825
40002
  await this.pool.query(
39826
40003
  `create index if not exists ${indexName} on ${this.qualify(ts.name)} ("${col.name}");`
39827
40004
  );
@@ -39839,7 +40016,7 @@ var _PostgreSQLAdapter = class _PostgreSQLAdapter {
39839
40016
  `alter table ${this.qualify(table)} add column if not exists "${col.name}" ${pgType}${nullable}${def};`
39840
40017
  );
39841
40018
  if (col.isIndexed) {
39842
- const indexName = this._pgSchema === "public" ? `"${table}_${col.name}"` : `"${this._pgSchema}_${table}_${col.name}"`;
40019
+ const indexName = `"${table}_${col.name}"`;
39843
40020
  await this.pool.query(
39844
40021
  `create index if not exists ${indexName} on ${this.qualify(table)} ("${col.name}");`
39845
40022
  );
@@ -39848,26 +40025,34 @@ var _PostgreSQLAdapter = class _PostgreSQLAdapter {
39848
40025
  break;
39849
40026
  }
39850
40027
  case "sql": {
39851
- if (this._pgSchema !== "public" && this.pool.connect) {
39852
- const client2 = await this.pool.connect();
39853
- try {
39854
- await client2.query("BEGIN");
39855
- await client2.query(`SET LOCAL search_path TO "${this._pgSchema}", public`);
39856
- await client2.query(step.sql);
39857
- await client2.query("COMMIT");
39858
- } catch (err) {
39859
- await client2.query("ROLLBACK");
39860
- throw err;
39861
- } finally {
39862
- client2.release();
39863
- }
39864
- } else {
39865
- await this.pool.query(step.sql);
39866
- }
40028
+ await this._withSchema((client2) => client2.query(step.sql));
39867
40029
  break;
39868
40030
  }
39869
40031
  }
39870
40032
  }
40033
+ async _withSchema(run) {
40034
+ if (!this.pool.connect) {
40035
+ throw new Error("PostgreSQLAdapter raw SQL requires pool.connect for database isolation");
40036
+ }
40037
+ const client2 = await this.pool.connect();
40038
+ try {
40039
+ await client2.query("BEGIN");
40040
+ await client2.query(`SET LOCAL search_path TO "${this._pgSchema}"`);
40041
+ const result = await run(client2);
40042
+ await client2.query("COMMIT");
40043
+ return result;
40044
+ } catch (err) {
40045
+ await client2.query("ROLLBACK");
40046
+ throw err;
40047
+ } finally {
40048
+ client2.release();
40049
+ }
40050
+ }
40051
+ async _query(query, countMode = false, idsOnly = false) {
40052
+ const [sql, values] = encodeQuery(query, this.qualify, countMode, idsOnly);
40053
+ const description = query.description;
40054
+ return description.sql || hasSql(description.where) ? this._withSchema((client2) => client2.query(sql, values)) : this.pool.query(sql, values);
40055
+ }
39871
40056
  async _resetAndRecreate(targetVersion) {
39872
40057
  for (const tableName of Object.keys(this.schema.tables)) {
39873
40058
  await this.pool.query(`drop table if exists ${this.qualify(tableName)} cascade;`);
@@ -39911,8 +40096,7 @@ var _PostgreSQLAdapter = class _PostgreSQLAdapter {
39911
40096
  this._fromPromise(
39912
40097
  (async () => {
39913
40098
  await this._ready();
39914
- const [sql, values] = encodeQuery(query, this.qualify);
39915
- const { rows } = await this.pool.query(sql, values);
40099
+ const { rows } = await this._query(query);
39916
40100
  return rows.map(rowToRaw);
39917
40101
  })(),
39918
40102
  callback
@@ -39922,8 +40106,7 @@ var _PostgreSQLAdapter = class _PostgreSQLAdapter {
39922
40106
  this._fromPromise(
39923
40107
  (async () => {
39924
40108
  await this._ready();
39925
- const [sql, values] = encodeQuery(query, this.qualify, false, true);
39926
- const { rows } = await this.pool.query(sql, values);
40109
+ const { rows } = await this._query(query, false, true);
39927
40110
  return rows.map((r) => r.id);
39928
40111
  })(),
39929
40112
  callback
@@ -39934,8 +40117,7 @@ var _PostgreSQLAdapter = class _PostgreSQLAdapter {
39934
40117
  this._fromPromise(
39935
40118
  (async () => {
39936
40119
  await this._ready();
39937
- const [sql, values] = encodeQuery(query, this.qualify);
39938
- const { rows } = await this.pool.query(sql, values);
40120
+ const { rows } = await this._query(query);
39939
40121
  return rows;
39940
40122
  })(),
39941
40123
  callback
@@ -39945,8 +40127,7 @@ var _PostgreSQLAdapter = class _PostgreSQLAdapter {
39945
40127
  this._fromPromise(
39946
40128
  (async () => {
39947
40129
  await this._ready();
39948
- const [sql, values] = encodeQuery(query, this.qualify, true);
39949
- const { rows } = await this.pool.query(sql, values);
40130
+ const { rows } = await this._query(query, true);
39950
40131
  return Number(rows[0]?.count ?? 0);
39951
40132
  })(),
39952
40133
  callback
@@ -40070,7 +40251,7 @@ var _PostgreSQLAdapter = class _PostgreSQLAdapter {
40070
40251
  this._fromPromise(
40071
40252
  (async () => {
40072
40253
  await this._ready();
40073
- await this.pool.query(ops.sqlString);
40254
+ await this._withSchema((client2) => client2.query(ops.sqlString));
40074
40255
  })(),
40075
40256
  callback
40076
40257
  );
@@ -40080,9 +40261,11 @@ var _PostgreSQLAdapter = class _PostgreSQLAdapter {
40080
40261
  this._fromPromise(
40081
40262
  (async () => {
40082
40263
  await this._ready();
40083
- for (const [sql, args] of ops.sqls) {
40084
- await this.pool.query(sql, args);
40085
- }
40264
+ await this._withSchema(async (client2) => {
40265
+ for (const [sql, args] of ops.sqls) {
40266
+ await client2.query(sql, args);
40267
+ }
40268
+ });
40086
40269
  })(),
40087
40270
  callback
40088
40271
  );
@@ -40291,6 +40474,7 @@ function serverPlatformStorage() {
40291
40474
  decryptDataBytes,
40292
40475
  decryptDataBytesFromBytes,
40293
40476
  decryptDataWithKey,
40477
+ decryptMessageEmbeddingFields,
40294
40478
  defaultServerToolsFilter,
40295
40479
  deleteAllVaultMemoriesForUserOp,
40296
40480
  deleteConversationOp,
@@ -40414,6 +40598,7 @@ function serverPlatformStorage() {
40414
40598
  sdkMigrations,
40415
40599
  sdkModelClasses,
40416
40600
  sdkSchema,
40601
+ sealLegacyMessageEmbeddingsOp,
40417
40602
  searchChunksOp,
40418
40603
  searchMediaOp,
40419
40604
  searchMessagesOp,
@@ -3817,6 +3817,10 @@ declare function upsertMessageOp(ctx: StorageOperationsContext, opts: CreateMess
3817
3817
  declare function getMessageOp(ctx: StorageOperationsContext, uniqueId: string): Promise<StoredMessage | null>;
3818
3818
  declare function updateMessageEmbeddingOp(ctx: StorageOperationsContext, uniqueId: string, vector: number[], embeddingModel: string): Promise<StoredMessage | null>;
3819
3819
  declare function updateMessageChunksOp(ctx: StorageOperationsContext, uniqueId: string, chunks: MessageChunk[], embeddingModel: string): Promise<StoredMessage | null>;
3820
+ /** Decrypts raw message embedding columns with the cached wallet key. */
3821
+ declare function decryptMessageEmbeddingFields(raw: Record<string, unknown>, walletAddress?: string): Promise<Record<string, unknown>>;
3822
+ /** Seals legacy message embedding columns and discards chunks with invalid plaintext offsets. */
3823
+ declare function sealLegacyMessageEmbeddingsOp(ctx: StorageOperationsContext): Promise<number>;
3820
3824
  /**
3821
3825
  * Removes the plaintext `text` that rows chunked before sdk#889 still carry in
3822
3826
  * their `chunks` column. Since #889 `updateMessageChunksOp` never writes it, so
@@ -10943,7 +10947,7 @@ interface PgPoolLike {
10943
10947
  query(text: string, values?: unknown[]): Promise<{
10944
10948
  rows: Record<string, unknown>[];
10945
10949
  }>;
10946
- /** Optional. When provided, batch operations run inside a transaction on a dedicated connection. */
10950
+ /** Optional for regular operations; required for raw SQL and transactional batches. */
10947
10951
  connect?(): Promise<PgClientLike>;
10948
10952
  }
10949
10953
  interface PostgreSQLAdapterOptions {
@@ -10951,12 +10955,10 @@ interface PostgreSQLAdapterOptions {
10951
10955
  schema: AppSchema;
10952
10956
  migrations?: SchemaMigrations;
10953
10957
  dbName: string;
10954
- /**
10955
- * PostgreSQL schema (namespace) for all SDK tables.
10956
- * Defaults to "public". Use a custom schema (e.g. "sdk") to avoid
10957
- * conflicts with existing tables in the same database.
10958
- */
10958
+ /** Namespace key combined with dbName to derive the isolated schema; defaults to "public". */
10959
10959
  pgSchema?: string;
10960
+ /** Move legacy tables only when this database owns all records in the legacy schema. */
10961
+ migrateLegacySchema?: boolean;
10960
10962
  }
10961
10963
  /**
10962
10964
  * Generate CREATE TABLE statements from a WatermelonDB AppSchema.
@@ -10994,11 +10996,15 @@ declare class PostgreSQLAdapter implements DatabaseAdapter {
10994
10996
  private initialized;
10995
10997
  constructor(options: PostgreSQLAdapterOptions);
10996
10998
  private static SCHEMA_VERSION_KEY;
10999
+ private _hasLegacyData;
11000
+ private _upgradeLegacySchema;
10997
11001
  private _initialize;
10998
11002
  private _getStoredSchemaVersion;
10999
11003
  private _setStoredSchemaVersion;
11000
11004
  private _migrate;
11001
11005
  private _applyMigrationStep;
11006
+ private _withSchema;
11007
+ private _query;
11002
11008
  private _resetAndRecreate;
11003
11009
  private _ready;
11004
11010
  private _fromPromise;
@@ -11038,4 +11044,4 @@ declare class PostgreSQLAdapter implements DatabaseAdapter {
11038
11044
  */
11039
11045
  declare function serverPlatformStorage(): PlatformStorage;
11040
11046
 
11041
- export { type AnalyzeStyleOptions, type AnalyzeStyleResult, type ApiResponse, type ApiType, type AutoExecutedToolResult, type AutoExtractMessage, type AutoExtractor, type Budget, type BuildPromptOptions, type BuildPromptResult, type CachedChunkVectors, type CachedServerTools, type ChatCompletionUsage, type ChatRole, type ChunkSearchResult, type ChunkSearchStats, type ChunkVectorCache, type ChunkingOptions, type ConnectorGuidance, type ConnectorGuidanceInput, type ConsolidationAction, type ConsolidationFallbackReason, Conversation, ConversationSummary, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateDecaySweeperOptions, type CreateMediaOptions, type CreateMessageOptions, type CreateModelPreferenceOptions, type CreateProjectOptions, type CreateUserPreferenceOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_ANALYSIS_PROMPT, DEFAULT_ANALYZE_AFTER_MESSAGES, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_DECAY_POLICY, DEFAULT_DOCUMENT_PATTERN, DEFAULT_EXCLUDED_SERVER_TOOLS, DEFAULT_MAX_CLASSIFIER_CALLS_PER_SWEEP, DEFAULT_MAX_INPUT_MESSAGES, DEFAULT_MAX_PROFILE_LENGTH, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_MIN_MESSAGES, DEFAULT_PERSONALITY_SETTINGS, DEFAULT_PROFILE_FACETS, DEFAULT_PROFILE_FACT_TYPE_WEIGHTS, DEFAULT_PROFILE_PROOF_ALPHA, DEFAULT_PROFILE_TREND_MULTIPLIERS, DEFAULT_PROMPT_TEMPLATES, DEFAULT_REFRESH_EVERY_MESSAGES, DEFAULT_SERVER_TOOLS_MATCH_OPTIONS, DEFAULT_SUMMARY_MIN_WINDOW_MESSAGES, DEFAULT_SUMMARY_MODEL, DEFAULT_SUMMARY_TOKEN_THRESHOLD, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type DecayCandidateRaw, type DecayClassifier, type DecayInput, type DecayPolicy, type DecaySweepResult, type DecaySweeper, type DecayVerdict, type DurableAutoExtractorOptions, ENTITY_FANOUT, type EmbeddedWalletSignerFn, type EmbeddingRepairOptions, type EmbeddingRepairResult, EncryptionKeyMissingError, ExcelProcessor, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type ExtractionFunnel, type ExtractionMessageSource, type ExtractionSourceMessage, type ExtractionSourceStatus, type ExtractionTimings, type FactType, type FileMetadata, type FileProcessingReason, type FileProcessingStatus, type FileProcessor, type FileTypeQuery, type FileWithData, type FlushResult, type GetConversationsPageOptions, type GraphTraversalOptions, HARD_DELETE_WINDOW_MS, INFERENCE_ID_HEADER, type InjectionClassifierOptions, type InjectionReason, type LazyStoredConversation, type LlmDecayClassifierOptions, type LlmNeighborRefinerOptions, type LlmTokenUsage, type LocalMemoryStoreOptions, MAX_HOPS, MAX_MESSAGES_PER_SUMMARIZATION, MEDIUM_TTL_MS, MEMORY_KINDS, MEMORY_LEVELS, Media, type MediaDimensions, type MediaFilterOptions, type MediaMetadata, type MediaOperationsContext, type MediaRole, type MediaType, type MemoriesNeedingTopicExtraction, type MemoryContextItem, type MemoryContextLane, type MemoryContextOptions, type MemoryContextResult, type MemoryDecay, type MemoryDecaySweeperOptions, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryLevel, MemoryLevelError, type MemoryListOptions, type MemoryMaintenance, type MemoryQuarantinedEvent, type MemoryRecallOptions, type MemoryRetainOptions, type MemoryStore, type MemorySubscribeOptions, type MemoryToVerify, type MemoryTopic, type MemoryTopicBacklog, type MemoryTopicMaintenance, type MemoryUpdate, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MemoryVerification, Message, type MessageChunk, type MessageFeedback, type MessageOrigin, type ModelCallEndEvent, type ModelCallStartEvent, ModelPreference, NEVER_TTL_MS, NODE_BUDGET, type NeighborRefiner, type NowSource, type ObservationTrend, type ObservationTrendInput, type OperationExecutor, PAST_EVENT_GRACE_MS, PROFILE_DOC_VERSION, type ParsedServerToolsResponse, PdfProcessor, type PersonalitySettings, type PersonalitySliders, type PersonalityStyle, type PgClientLike, type PgPoolLike, type PhotoIngestResult, type PhotoMediaRef, type PlatformStorage, type PortalLlmAuth, type PortalLlmFailure, type PortalLlmFailureReason, PostgreSQLAdapter, type PostgreSQLAdapterOptions, type PreprocessingOptions, type PreprocessingResult, type ProcessedFileResult, ProcessorRegistry, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type ProfileUpdate, Project, type ProjectOperationsContext, type PromptContext, type PromptPreProcessor, type PromptPreProcessorContext, type PromptSection, type PromptTemplates, type PublishedPhotoMemory, type QuarantinedMemoryInfo, type QueueEncryptionContext, QueueManager, type QueueStatus, type QueuedOperation, type QueuedOperationType, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankedMemory, type RankedProfileCandidate, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallEmptyReason, type RecallOptions, type RecallResult, type RecallTelemetryCallbacks, type RecallToolCallbacks, type RecallToolOptions, type RecallTruncation, type RecencyOptions, type ReflectOptions, type ReflectResult, type RequestEncryptionKeyOptions, RerankerUnavailableError, type ResumeStreamOptions, type ResumeStreamResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, type RunEndEvent, type RunErrorEvent, type RunHooks, type RunStartEvent, type RunTerminalState, type RunToolLoopOptions, type RunToolLoopResult, SDK_SCHEMA_VERSION, SERVER_TOOL_DEPENDENCY_SETS, SHORT_TTL_MS, SLIDER_CONFIG, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type ScoreProfileSalienceOptions, type ScreenResult, type ScreenedCandidate, type SearchSource, type SelectServerToolsForPromptOptions, type ServerTool, type ServerToolCallEvent, type ServerToolsFilterFunction, type ServerToolsOptions, type ServerToolsResponse, type SettingsStorageOperationsContext, type SignMessageFn, type StepFinishEvent, type StockPriceClassification, type StockPricePreProcessorOptions, type StorageOperationsContext, type StoredConversation, type StoredConversationSummary, type StoredFileWithContext, type StoredMedia, type StoredMessage, type StoredMessageWithSimilarity, type StoredModelPreference, type StoredProject, type StoredUserPreference, type StoredVaultMemory, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type StreamSmoothingConfig, type StreamingTransport, type StreamingTransportOptions, type StreamingTransportResult, type StyleAnalysisSchedule, type SynthesizeProfileOptions, TOOL_CATALOG, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, TextProcessor, type ToolConfig, type ToolExecutor, type ToolMatchOptions, type ToolMatchResult, type ToolSet, type ToolUseEndEvent, type ToolUseStartEvent, type TopicExtractOptions, type TopicExtractionBatchDiagnostics, type TopicExtractionInput, type TopicExtractionRunResult, type TopicSkipReason, type TurnCompleteEvent, type TurnSkippedEvent, type UncheckedReason, type UnverifiableReason, type UpdateMediaOptions, type UpdateModelPreferenceOptions, type UpdateProjectOptions, type UpdateUserPreferenceOptions, type UpdateVaultMemoryOptions, UserPreference, type UserPreferencesStorageOperationsContext, VAULT_SIZE_HOP_CAP, type VaultEmbeddingCache, type VaultEmbeddingExpectation, VaultMemory, type VaultMemoryKind, type VaultMemoryOperationsContext, type VaultMemoryVisibility, type VaultSaveOperation, type VaultSearchResult, type VerificationSources, type VerifyMemoriesForPublishOptions, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, WordProcessor, ZipProcessor, type ZipProcessorOptions, activatedToolSetNames, analyzeStyle, archiveVaultMemoryOp, assembleMemoryContext, backfillMemoryTopicsOp, buildConnectorGuidance, buildDeniedToolsRider, buildSystemPrompt, capHopsForDensity, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyDecay, classifyInjectionCandidates, classifyObservationTrend, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, cleanupConversationSummary, clearAllEncryptionKeys, clearAllEncryptionState, clearAllKeyPairs, clearEncryptionKey, clearKeyPair, clearLazyTitleCache, clearMessagesOp, clearServerToolsCache, composeHooks, createAutoExtractor, createChunkVectorCache, createConversationOp, createCryptoPricePreProcessor, createDecaySweeper, createDurableAutoExtractor, createLlmDecayClassifier, createLlmNeighborRefiner, createLocalMemoryStore, createMediaBatchOp, createMediaOp, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageOp, createMessageSourceResolver, createPlatformCursorStore, createProjectOp, createRecallTool, createServerToolsFilter, createStockPricePreProcessor, createSummaryContext, createVaultEmbeddingCache, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, decryptData, decryptDataBatch, decryptDataBytes, decryptDataBytesFromBytes, decryptDataWithKey, defaultServerToolsFilter, deleteAllVaultMemoriesForUserOp, deleteConversationOp, deleteConversationSummaryOp, deleteMediaByConversationOp, deleteMediaByMessageOp, deleteMediaOp, deleteMessageOp, deleteModelPreferenceOp, deleteProjectOp, deleteUserPreferenceOp, deleteVaultMemoryOp, deriveKeyFromSignatureBytes, eagerEmbedContent, embedAllMessages, embedMessage, encryptData, encryptDataBatch, encryptDataBytes, encryptDataWithKey, encryptToolCallEventsOp, estimateMessagesTokens, estimateTokens, exportPublicKey, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, findMatchingTools, formatFileProcessingNotes, generateConversationId, generateEmbedding, generateEmbeddings, generateMediaId, generateProjectId, getAIGeneratedMediaOp, getAllFilesOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getAudioOp, getCachedServerTools, getConversationOp, getConversationSummaryOp, getConversationsByProjectLazyOp, getConversationsByProjectOp, getConversationsLazyOp, getConversationsOp, getConversationsPageOp, getDecayCandidatesRawOp, getDocumentsOp, getEncryptionKey, getImagesOp, getMediaByConversationOp, getMediaByIdOp, getMediaByIdsOp, getMediaByMessageOp, getMediaByModelOp, getMediaByRoleOp, getMediaBySourceUrlOp, getMediaByTypeOp, getMediaCountOp, getMediaCountsByTypeOp, getMediaOp, getMediaTypeFromMime, getMemoriesNeedingTopicExtractionOp, getMessageOp, getMessagesOp, getModelPreferenceOp, getProjectConversationCountOp, getProjectConversationsOp, getProjectOp, getProjectsOp, getRecentMediaOp, getServerTools, getSupportedFileTypes, getToolsChecksum, getUnfiledVaultMemoriesOp, getUserPreferenceOp, getUserUploadedMediaOp, getVaultMemoryOp, getVideosOp, hardDeleteDecayedOp, hardDeleteMediaOp, hasEncryptionKey, hasKeyPair, ingestPublishedPhotoMemoriesOp, injectionSignatureCatalog, isDegradedTopicSkip, isRerankerAvailable, isSupportedFile, isSupportedMediaType, makeSyntheticStoredConversation, makeSyntheticStoredMessage, maybeSummarizeHistory, mediaToStored, migrateFromModelPreferencesOp, onKeyAvailable, parseMedia, preEmbedVaultMemories, preprocessFiles, progressiveSummarize, projectToStored, queueManager, rankProfileCandidates, recall, reflect, refreshEncryptionKeyIfMatches, relinkMemoryTopicsOp, relinkMisclassifiedVideosOp, renderTemplate, requestEncryptionKey, requestKeyPair, restoreVaultMemoryOp, resumeStream, retain, runToolLoop, sanitizeQuotes, schemaToCreateSQL, scoreProfileSalience, screenCandidatesForInjection, sdkMigrations, sdkModelClasses, sdkSchema, searchChunksOp, searchMediaOp, searchMessagesOp, searchVaultMemories, seedEncryptionKeys, selectServerToolsForPrompt, serverPlatformStorage, setMemoryVisibilityOp, setModelPreferenceOp, setUserPreferenceOp, shouldAnalyzeStyle, shouldChunkMessage, shouldRecallMemory, shouldRefreshTools, splitMessagesAtThreshold, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, stripLegacyChunkTextOp, summarizeObservationTrends, summaryToSystemMessage, supersedeVaultMemoryOp, synthesizeProfile, toolSetSystemPrompts, traverseGraphLane, ttlForType, updateConversationProjectOp, updateConversationTitleOp, updateMediaMessageIdBatchOp, updateMediaOp, updateMessageChunksOp, updateMessageEmbeddingOp, updateMessageErrorOp, updateMessageFeedbackOp, updateModelsOp, updatePersonalityOp, updateProfileOp, updateProjectNameOp, updateProjectOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertConversationSummaryOp, upsertMessageOp, verifyMemoriesForPublish };
11047
+ export { type AnalyzeStyleOptions, type AnalyzeStyleResult, type ApiResponse, type ApiType, type AutoExecutedToolResult, type AutoExtractMessage, type AutoExtractor, type Budget, type BuildPromptOptions, type BuildPromptResult, type CachedChunkVectors, type CachedServerTools, type ChatCompletionUsage, type ChatRole, type ChunkSearchResult, type ChunkSearchStats, type ChunkVectorCache, type ChunkingOptions, type ConnectorGuidance, type ConnectorGuidanceInput, type ConsolidationAction, type ConsolidationFallbackReason, Conversation, ConversationSummary, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateDecaySweeperOptions, type CreateMediaOptions, type CreateMessageOptions, type CreateModelPreferenceOptions, type CreateProjectOptions, type CreateUserPreferenceOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_ANALYSIS_PROMPT, DEFAULT_ANALYZE_AFTER_MESSAGES, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_DECAY_POLICY, DEFAULT_DOCUMENT_PATTERN, DEFAULT_EXCLUDED_SERVER_TOOLS, DEFAULT_MAX_CLASSIFIER_CALLS_PER_SWEEP, DEFAULT_MAX_INPUT_MESSAGES, DEFAULT_MAX_PROFILE_LENGTH, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_MIN_MESSAGES, DEFAULT_PERSONALITY_SETTINGS, DEFAULT_PROFILE_FACETS, DEFAULT_PROFILE_FACT_TYPE_WEIGHTS, DEFAULT_PROFILE_PROOF_ALPHA, DEFAULT_PROFILE_TREND_MULTIPLIERS, DEFAULT_PROMPT_TEMPLATES, DEFAULT_REFRESH_EVERY_MESSAGES, DEFAULT_SERVER_TOOLS_MATCH_OPTIONS, DEFAULT_SUMMARY_MIN_WINDOW_MESSAGES, DEFAULT_SUMMARY_MODEL, DEFAULT_SUMMARY_TOKEN_THRESHOLD, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type DecayCandidateRaw, type DecayClassifier, type DecayInput, type DecayPolicy, type DecaySweepResult, type DecaySweeper, type DecayVerdict, type DurableAutoExtractorOptions, ENTITY_FANOUT, type EmbeddedWalletSignerFn, type EmbeddingRepairOptions, type EmbeddingRepairResult, EncryptionKeyMissingError, ExcelProcessor, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type ExtractionFunnel, type ExtractionMessageSource, type ExtractionSourceMessage, type ExtractionSourceStatus, type ExtractionTimings, type FactType, type FileMetadata, type FileProcessingReason, type FileProcessingStatus, type FileProcessor, type FileTypeQuery, type FileWithData, type FlushResult, type GetConversationsPageOptions, type GraphTraversalOptions, HARD_DELETE_WINDOW_MS, INFERENCE_ID_HEADER, type InjectionClassifierOptions, type InjectionReason, type LazyStoredConversation, type LlmDecayClassifierOptions, type LlmNeighborRefinerOptions, type LlmTokenUsage, type LocalMemoryStoreOptions, MAX_HOPS, MAX_MESSAGES_PER_SUMMARIZATION, MEDIUM_TTL_MS, MEMORY_KINDS, MEMORY_LEVELS, Media, type MediaDimensions, type MediaFilterOptions, type MediaMetadata, type MediaOperationsContext, type MediaRole, type MediaType, type MemoriesNeedingTopicExtraction, type MemoryContextItem, type MemoryContextLane, type MemoryContextOptions, type MemoryContextResult, type MemoryDecay, type MemoryDecaySweeperOptions, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryLevel, MemoryLevelError, type MemoryListOptions, type MemoryMaintenance, type MemoryQuarantinedEvent, type MemoryRecallOptions, type MemoryRetainOptions, type MemoryStore, type MemorySubscribeOptions, type MemoryToVerify, type MemoryTopic, type MemoryTopicBacklog, type MemoryTopicMaintenance, type MemoryUpdate, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MemoryVerification, Message, type MessageChunk, type MessageFeedback, type MessageOrigin, type ModelCallEndEvent, type ModelCallStartEvent, ModelPreference, NEVER_TTL_MS, NODE_BUDGET, type NeighborRefiner, type NowSource, type ObservationTrend, type ObservationTrendInput, type OperationExecutor, PAST_EVENT_GRACE_MS, PROFILE_DOC_VERSION, type ParsedServerToolsResponse, PdfProcessor, type PersonalitySettings, type PersonalitySliders, type PersonalityStyle, type PgClientLike, type PgPoolLike, type PhotoIngestResult, type PhotoMediaRef, type PlatformStorage, type PortalLlmAuth, type PortalLlmFailure, type PortalLlmFailureReason, PostgreSQLAdapter, type PostgreSQLAdapterOptions, type PreprocessingOptions, type PreprocessingResult, type ProcessedFileResult, ProcessorRegistry, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type ProfileUpdate, Project, type ProjectOperationsContext, type PromptContext, type PromptPreProcessor, type PromptPreProcessorContext, type PromptSection, type PromptTemplates, type PublishedPhotoMemory, type QuarantinedMemoryInfo, type QueueEncryptionContext, QueueManager, type QueueStatus, type QueuedOperation, type QueuedOperationType, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankedMemory, type RankedProfileCandidate, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallEmptyReason, type RecallOptions, type RecallResult, type RecallTelemetryCallbacks, type RecallToolCallbacks, type RecallToolOptions, type RecallTruncation, type RecencyOptions, type ReflectOptions, type ReflectResult, type RequestEncryptionKeyOptions, RerankerUnavailableError, type ResumeStreamOptions, type ResumeStreamResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, type RunEndEvent, type RunErrorEvent, type RunHooks, type RunStartEvent, type RunTerminalState, type RunToolLoopOptions, type RunToolLoopResult, SDK_SCHEMA_VERSION, SERVER_TOOL_DEPENDENCY_SETS, SHORT_TTL_MS, SLIDER_CONFIG, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type ScoreProfileSalienceOptions, type ScreenResult, type ScreenedCandidate, type SearchSource, type SelectServerToolsForPromptOptions, type ServerTool, type ServerToolCallEvent, type ServerToolsFilterFunction, type ServerToolsOptions, type ServerToolsResponse, type SettingsStorageOperationsContext, type SignMessageFn, type StepFinishEvent, type StockPriceClassification, type StockPricePreProcessorOptions, type StorageOperationsContext, type StoredConversation, type StoredConversationSummary, type StoredFileWithContext, type StoredMedia, type StoredMessage, type StoredMessageWithSimilarity, type StoredModelPreference, type StoredProject, type StoredUserPreference, type StoredVaultMemory, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type StreamSmoothingConfig, type StreamingTransport, type StreamingTransportOptions, type StreamingTransportResult, type StyleAnalysisSchedule, type SynthesizeProfileOptions, TOOL_CATALOG, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, TextProcessor, type ToolConfig, type ToolExecutor, type ToolMatchOptions, type ToolMatchResult, type ToolSet, type ToolUseEndEvent, type ToolUseStartEvent, type TopicExtractOptions, type TopicExtractionBatchDiagnostics, type TopicExtractionInput, type TopicExtractionRunResult, type TopicSkipReason, type TurnCompleteEvent, type TurnSkippedEvent, type UncheckedReason, type UnverifiableReason, type UpdateMediaOptions, type UpdateModelPreferenceOptions, type UpdateProjectOptions, type UpdateUserPreferenceOptions, type UpdateVaultMemoryOptions, UserPreference, type UserPreferencesStorageOperationsContext, VAULT_SIZE_HOP_CAP, type VaultEmbeddingCache, type VaultEmbeddingExpectation, VaultMemory, type VaultMemoryKind, type VaultMemoryOperationsContext, type VaultMemoryVisibility, type VaultSaveOperation, type VaultSearchResult, type VerificationSources, type VerifyMemoriesForPublishOptions, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, WordProcessor, ZipProcessor, type ZipProcessorOptions, activatedToolSetNames, analyzeStyle, archiveVaultMemoryOp, assembleMemoryContext, backfillMemoryTopicsOp, buildConnectorGuidance, buildDeniedToolsRider, buildSystemPrompt, capHopsForDensity, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyDecay, classifyInjectionCandidates, classifyObservationTrend, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, cleanupConversationSummary, clearAllEncryptionKeys, clearAllEncryptionState, clearAllKeyPairs, clearEncryptionKey, clearKeyPair, clearLazyTitleCache, clearMessagesOp, clearServerToolsCache, composeHooks, createAutoExtractor, createChunkVectorCache, createConversationOp, createCryptoPricePreProcessor, createDecaySweeper, createDurableAutoExtractor, createLlmDecayClassifier, createLlmNeighborRefiner, createLocalMemoryStore, createMediaBatchOp, createMediaOp, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageOp, createMessageSourceResolver, createPlatformCursorStore, createProjectOp, createRecallTool, createServerToolsFilter, createStockPricePreProcessor, createSummaryContext, createVaultEmbeddingCache, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, decryptData, decryptDataBatch, decryptDataBytes, decryptDataBytesFromBytes, decryptDataWithKey, decryptMessageEmbeddingFields, defaultServerToolsFilter, deleteAllVaultMemoriesForUserOp, deleteConversationOp, deleteConversationSummaryOp, deleteMediaByConversationOp, deleteMediaByMessageOp, deleteMediaOp, deleteMessageOp, deleteModelPreferenceOp, deleteProjectOp, deleteUserPreferenceOp, deleteVaultMemoryOp, deriveKeyFromSignatureBytes, eagerEmbedContent, embedAllMessages, embedMessage, encryptData, encryptDataBatch, encryptDataBytes, encryptDataWithKey, encryptToolCallEventsOp, estimateMessagesTokens, estimateTokens, exportPublicKey, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, findMatchingTools, formatFileProcessingNotes, generateConversationId, generateEmbedding, generateEmbeddings, generateMediaId, generateProjectId, getAIGeneratedMediaOp, getAllFilesOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getAudioOp, getCachedServerTools, getConversationOp, getConversationSummaryOp, getConversationsByProjectLazyOp, getConversationsByProjectOp, getConversationsLazyOp, getConversationsOp, getConversationsPageOp, getDecayCandidatesRawOp, getDocumentsOp, getEncryptionKey, getImagesOp, getMediaByConversationOp, getMediaByIdOp, getMediaByIdsOp, getMediaByMessageOp, getMediaByModelOp, getMediaByRoleOp, getMediaBySourceUrlOp, getMediaByTypeOp, getMediaCountOp, getMediaCountsByTypeOp, getMediaOp, getMediaTypeFromMime, getMemoriesNeedingTopicExtractionOp, getMessageOp, getMessagesOp, getModelPreferenceOp, getProjectConversationCountOp, getProjectConversationsOp, getProjectOp, getProjectsOp, getRecentMediaOp, getServerTools, getSupportedFileTypes, getToolsChecksum, getUnfiledVaultMemoriesOp, getUserPreferenceOp, getUserUploadedMediaOp, getVaultMemoryOp, getVideosOp, hardDeleteDecayedOp, hardDeleteMediaOp, hasEncryptionKey, hasKeyPair, ingestPublishedPhotoMemoriesOp, injectionSignatureCatalog, isDegradedTopicSkip, isRerankerAvailable, isSupportedFile, isSupportedMediaType, makeSyntheticStoredConversation, makeSyntheticStoredMessage, maybeSummarizeHistory, mediaToStored, migrateFromModelPreferencesOp, onKeyAvailable, parseMedia, preEmbedVaultMemories, preprocessFiles, progressiveSummarize, projectToStored, queueManager, rankProfileCandidates, recall, reflect, refreshEncryptionKeyIfMatches, relinkMemoryTopicsOp, relinkMisclassifiedVideosOp, renderTemplate, requestEncryptionKey, requestKeyPair, restoreVaultMemoryOp, resumeStream, retain, runToolLoop, sanitizeQuotes, schemaToCreateSQL, scoreProfileSalience, screenCandidatesForInjection, sdkMigrations, sdkModelClasses, sdkSchema, sealLegacyMessageEmbeddingsOp, searchChunksOp, searchMediaOp, searchMessagesOp, searchVaultMemories, seedEncryptionKeys, selectServerToolsForPrompt, serverPlatformStorage, setMemoryVisibilityOp, setModelPreferenceOp, setUserPreferenceOp, shouldAnalyzeStyle, shouldChunkMessage, shouldRecallMemory, shouldRefreshTools, splitMessagesAtThreshold, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, stripLegacyChunkTextOp, summarizeObservationTrends, summaryToSystemMessage, supersedeVaultMemoryOp, synthesizeProfile, toolSetSystemPrompts, traverseGraphLane, ttlForType, updateConversationProjectOp, updateConversationTitleOp, updateMediaMessageIdBatchOp, updateMediaOp, updateMessageChunksOp, updateMessageEmbeddingOp, updateMessageErrorOp, updateMessageFeedbackOp, updateModelsOp, updatePersonalityOp, updateProfileOp, updateProjectNameOp, updateProjectOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertConversationSummaryOp, upsertMessageOp, verifyMemoriesForPublish };
@@ -3817,6 +3817,10 @@ declare function upsertMessageOp(ctx: StorageOperationsContext, opts: CreateMess
3817
3817
  declare function getMessageOp(ctx: StorageOperationsContext, uniqueId: string): Promise<StoredMessage | null>;
3818
3818
  declare function updateMessageEmbeddingOp(ctx: StorageOperationsContext, uniqueId: string, vector: number[], embeddingModel: string): Promise<StoredMessage | null>;
3819
3819
  declare function updateMessageChunksOp(ctx: StorageOperationsContext, uniqueId: string, chunks: MessageChunk[], embeddingModel: string): Promise<StoredMessage | null>;
3820
+ /** Decrypts raw message embedding columns with the cached wallet key. */
3821
+ declare function decryptMessageEmbeddingFields(raw: Record<string, unknown>, walletAddress?: string): Promise<Record<string, unknown>>;
3822
+ /** Seals legacy message embedding columns and discards chunks with invalid plaintext offsets. */
3823
+ declare function sealLegacyMessageEmbeddingsOp(ctx: StorageOperationsContext): Promise<number>;
3820
3824
  /**
3821
3825
  * Removes the plaintext `text` that rows chunked before sdk#889 still carry in
3822
3826
  * their `chunks` column. Since #889 `updateMessageChunksOp` never writes it, so
@@ -10943,7 +10947,7 @@ interface PgPoolLike {
10943
10947
  query(text: string, values?: unknown[]): Promise<{
10944
10948
  rows: Record<string, unknown>[];
10945
10949
  }>;
10946
- /** Optional. When provided, batch operations run inside a transaction on a dedicated connection. */
10950
+ /** Optional for regular operations; required for raw SQL and transactional batches. */
10947
10951
  connect?(): Promise<PgClientLike>;
10948
10952
  }
10949
10953
  interface PostgreSQLAdapterOptions {
@@ -10951,12 +10955,10 @@ interface PostgreSQLAdapterOptions {
10951
10955
  schema: AppSchema;
10952
10956
  migrations?: SchemaMigrations;
10953
10957
  dbName: string;
10954
- /**
10955
- * PostgreSQL schema (namespace) for all SDK tables.
10956
- * Defaults to "public". Use a custom schema (e.g. "sdk") to avoid
10957
- * conflicts with existing tables in the same database.
10958
- */
10958
+ /** Namespace key combined with dbName to derive the isolated schema; defaults to "public". */
10959
10959
  pgSchema?: string;
10960
+ /** Move legacy tables only when this database owns all records in the legacy schema. */
10961
+ migrateLegacySchema?: boolean;
10960
10962
  }
10961
10963
  /**
10962
10964
  * Generate CREATE TABLE statements from a WatermelonDB AppSchema.
@@ -10994,11 +10996,15 @@ declare class PostgreSQLAdapter implements DatabaseAdapter {
10994
10996
  private initialized;
10995
10997
  constructor(options: PostgreSQLAdapterOptions);
10996
10998
  private static SCHEMA_VERSION_KEY;
10999
+ private _hasLegacyData;
11000
+ private _upgradeLegacySchema;
10997
11001
  private _initialize;
10998
11002
  private _getStoredSchemaVersion;
10999
11003
  private _setStoredSchemaVersion;
11000
11004
  private _migrate;
11001
11005
  private _applyMigrationStep;
11006
+ private _withSchema;
11007
+ private _query;
11002
11008
  private _resetAndRecreate;
11003
11009
  private _ready;
11004
11010
  private _fromPromise;
@@ -11038,4 +11044,4 @@ declare class PostgreSQLAdapter implements DatabaseAdapter {
11038
11044
  */
11039
11045
  declare function serverPlatformStorage(): PlatformStorage;
11040
11046
 
11041
- export { type AnalyzeStyleOptions, type AnalyzeStyleResult, type ApiResponse, type ApiType, type AutoExecutedToolResult, type AutoExtractMessage, type AutoExtractor, type Budget, type BuildPromptOptions, type BuildPromptResult, type CachedChunkVectors, type CachedServerTools, type ChatCompletionUsage, type ChatRole, type ChunkSearchResult, type ChunkSearchStats, type ChunkVectorCache, type ChunkingOptions, type ConnectorGuidance, type ConnectorGuidanceInput, type ConsolidationAction, type ConsolidationFallbackReason, Conversation, ConversationSummary, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateDecaySweeperOptions, type CreateMediaOptions, type CreateMessageOptions, type CreateModelPreferenceOptions, type CreateProjectOptions, type CreateUserPreferenceOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_ANALYSIS_PROMPT, DEFAULT_ANALYZE_AFTER_MESSAGES, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_DECAY_POLICY, DEFAULT_DOCUMENT_PATTERN, DEFAULT_EXCLUDED_SERVER_TOOLS, DEFAULT_MAX_CLASSIFIER_CALLS_PER_SWEEP, DEFAULT_MAX_INPUT_MESSAGES, DEFAULT_MAX_PROFILE_LENGTH, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_MIN_MESSAGES, DEFAULT_PERSONALITY_SETTINGS, DEFAULT_PROFILE_FACETS, DEFAULT_PROFILE_FACT_TYPE_WEIGHTS, DEFAULT_PROFILE_PROOF_ALPHA, DEFAULT_PROFILE_TREND_MULTIPLIERS, DEFAULT_PROMPT_TEMPLATES, DEFAULT_REFRESH_EVERY_MESSAGES, DEFAULT_SERVER_TOOLS_MATCH_OPTIONS, DEFAULT_SUMMARY_MIN_WINDOW_MESSAGES, DEFAULT_SUMMARY_MODEL, DEFAULT_SUMMARY_TOKEN_THRESHOLD, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type DecayCandidateRaw, type DecayClassifier, type DecayInput, type DecayPolicy, type DecaySweepResult, type DecaySweeper, type DecayVerdict, type DurableAutoExtractorOptions, ENTITY_FANOUT, type EmbeddedWalletSignerFn, type EmbeddingRepairOptions, type EmbeddingRepairResult, EncryptionKeyMissingError, ExcelProcessor, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type ExtractionFunnel, type ExtractionMessageSource, type ExtractionSourceMessage, type ExtractionSourceStatus, type ExtractionTimings, type FactType, type FileMetadata, type FileProcessingReason, type FileProcessingStatus, type FileProcessor, type FileTypeQuery, type FileWithData, type FlushResult, type GetConversationsPageOptions, type GraphTraversalOptions, HARD_DELETE_WINDOW_MS, INFERENCE_ID_HEADER, type InjectionClassifierOptions, type InjectionReason, type LazyStoredConversation, type LlmDecayClassifierOptions, type LlmNeighborRefinerOptions, type LlmTokenUsage, type LocalMemoryStoreOptions, MAX_HOPS, MAX_MESSAGES_PER_SUMMARIZATION, MEDIUM_TTL_MS, MEMORY_KINDS, MEMORY_LEVELS, Media, type MediaDimensions, type MediaFilterOptions, type MediaMetadata, type MediaOperationsContext, type MediaRole, type MediaType, type MemoriesNeedingTopicExtraction, type MemoryContextItem, type MemoryContextLane, type MemoryContextOptions, type MemoryContextResult, type MemoryDecay, type MemoryDecaySweeperOptions, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryLevel, MemoryLevelError, type MemoryListOptions, type MemoryMaintenance, type MemoryQuarantinedEvent, type MemoryRecallOptions, type MemoryRetainOptions, type MemoryStore, type MemorySubscribeOptions, type MemoryToVerify, type MemoryTopic, type MemoryTopicBacklog, type MemoryTopicMaintenance, type MemoryUpdate, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MemoryVerification, Message, type MessageChunk, type MessageFeedback, type MessageOrigin, type ModelCallEndEvent, type ModelCallStartEvent, ModelPreference, NEVER_TTL_MS, NODE_BUDGET, type NeighborRefiner, type NowSource, type ObservationTrend, type ObservationTrendInput, type OperationExecutor, PAST_EVENT_GRACE_MS, PROFILE_DOC_VERSION, type ParsedServerToolsResponse, PdfProcessor, type PersonalitySettings, type PersonalitySliders, type PersonalityStyle, type PgClientLike, type PgPoolLike, type PhotoIngestResult, type PhotoMediaRef, type PlatformStorage, type PortalLlmAuth, type PortalLlmFailure, type PortalLlmFailureReason, PostgreSQLAdapter, type PostgreSQLAdapterOptions, type PreprocessingOptions, type PreprocessingResult, type ProcessedFileResult, ProcessorRegistry, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type ProfileUpdate, Project, type ProjectOperationsContext, type PromptContext, type PromptPreProcessor, type PromptPreProcessorContext, type PromptSection, type PromptTemplates, type PublishedPhotoMemory, type QuarantinedMemoryInfo, type QueueEncryptionContext, QueueManager, type QueueStatus, type QueuedOperation, type QueuedOperationType, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankedMemory, type RankedProfileCandidate, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallEmptyReason, type RecallOptions, type RecallResult, type RecallTelemetryCallbacks, type RecallToolCallbacks, type RecallToolOptions, type RecallTruncation, type RecencyOptions, type ReflectOptions, type ReflectResult, type RequestEncryptionKeyOptions, RerankerUnavailableError, type ResumeStreamOptions, type ResumeStreamResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, type RunEndEvent, type RunErrorEvent, type RunHooks, type RunStartEvent, type RunTerminalState, type RunToolLoopOptions, type RunToolLoopResult, SDK_SCHEMA_VERSION, SERVER_TOOL_DEPENDENCY_SETS, SHORT_TTL_MS, SLIDER_CONFIG, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type ScoreProfileSalienceOptions, type ScreenResult, type ScreenedCandidate, type SearchSource, type SelectServerToolsForPromptOptions, type ServerTool, type ServerToolCallEvent, type ServerToolsFilterFunction, type ServerToolsOptions, type ServerToolsResponse, type SettingsStorageOperationsContext, type SignMessageFn, type StepFinishEvent, type StockPriceClassification, type StockPricePreProcessorOptions, type StorageOperationsContext, type StoredConversation, type StoredConversationSummary, type StoredFileWithContext, type StoredMedia, type StoredMessage, type StoredMessageWithSimilarity, type StoredModelPreference, type StoredProject, type StoredUserPreference, type StoredVaultMemory, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type StreamSmoothingConfig, type StreamingTransport, type StreamingTransportOptions, type StreamingTransportResult, type StyleAnalysisSchedule, type SynthesizeProfileOptions, TOOL_CATALOG, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, TextProcessor, type ToolConfig, type ToolExecutor, type ToolMatchOptions, type ToolMatchResult, type ToolSet, type ToolUseEndEvent, type ToolUseStartEvent, type TopicExtractOptions, type TopicExtractionBatchDiagnostics, type TopicExtractionInput, type TopicExtractionRunResult, type TopicSkipReason, type TurnCompleteEvent, type TurnSkippedEvent, type UncheckedReason, type UnverifiableReason, type UpdateMediaOptions, type UpdateModelPreferenceOptions, type UpdateProjectOptions, type UpdateUserPreferenceOptions, type UpdateVaultMemoryOptions, UserPreference, type UserPreferencesStorageOperationsContext, VAULT_SIZE_HOP_CAP, type VaultEmbeddingCache, type VaultEmbeddingExpectation, VaultMemory, type VaultMemoryKind, type VaultMemoryOperationsContext, type VaultMemoryVisibility, type VaultSaveOperation, type VaultSearchResult, type VerificationSources, type VerifyMemoriesForPublishOptions, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, WordProcessor, ZipProcessor, type ZipProcessorOptions, activatedToolSetNames, analyzeStyle, archiveVaultMemoryOp, assembleMemoryContext, backfillMemoryTopicsOp, buildConnectorGuidance, buildDeniedToolsRider, buildSystemPrompt, capHopsForDensity, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyDecay, classifyInjectionCandidates, classifyObservationTrend, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, cleanupConversationSummary, clearAllEncryptionKeys, clearAllEncryptionState, clearAllKeyPairs, clearEncryptionKey, clearKeyPair, clearLazyTitleCache, clearMessagesOp, clearServerToolsCache, composeHooks, createAutoExtractor, createChunkVectorCache, createConversationOp, createCryptoPricePreProcessor, createDecaySweeper, createDurableAutoExtractor, createLlmDecayClassifier, createLlmNeighborRefiner, createLocalMemoryStore, createMediaBatchOp, createMediaOp, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageOp, createMessageSourceResolver, createPlatformCursorStore, createProjectOp, createRecallTool, createServerToolsFilter, createStockPricePreProcessor, createSummaryContext, createVaultEmbeddingCache, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, decryptData, decryptDataBatch, decryptDataBytes, decryptDataBytesFromBytes, decryptDataWithKey, defaultServerToolsFilter, deleteAllVaultMemoriesForUserOp, deleteConversationOp, deleteConversationSummaryOp, deleteMediaByConversationOp, deleteMediaByMessageOp, deleteMediaOp, deleteMessageOp, deleteModelPreferenceOp, deleteProjectOp, deleteUserPreferenceOp, deleteVaultMemoryOp, deriveKeyFromSignatureBytes, eagerEmbedContent, embedAllMessages, embedMessage, encryptData, encryptDataBatch, encryptDataBytes, encryptDataWithKey, encryptToolCallEventsOp, estimateMessagesTokens, estimateTokens, exportPublicKey, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, findMatchingTools, formatFileProcessingNotes, generateConversationId, generateEmbedding, generateEmbeddings, generateMediaId, generateProjectId, getAIGeneratedMediaOp, getAllFilesOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getAudioOp, getCachedServerTools, getConversationOp, getConversationSummaryOp, getConversationsByProjectLazyOp, getConversationsByProjectOp, getConversationsLazyOp, getConversationsOp, getConversationsPageOp, getDecayCandidatesRawOp, getDocumentsOp, getEncryptionKey, getImagesOp, getMediaByConversationOp, getMediaByIdOp, getMediaByIdsOp, getMediaByMessageOp, getMediaByModelOp, getMediaByRoleOp, getMediaBySourceUrlOp, getMediaByTypeOp, getMediaCountOp, getMediaCountsByTypeOp, getMediaOp, getMediaTypeFromMime, getMemoriesNeedingTopicExtractionOp, getMessageOp, getMessagesOp, getModelPreferenceOp, getProjectConversationCountOp, getProjectConversationsOp, getProjectOp, getProjectsOp, getRecentMediaOp, getServerTools, getSupportedFileTypes, getToolsChecksum, getUnfiledVaultMemoriesOp, getUserPreferenceOp, getUserUploadedMediaOp, getVaultMemoryOp, getVideosOp, hardDeleteDecayedOp, hardDeleteMediaOp, hasEncryptionKey, hasKeyPair, ingestPublishedPhotoMemoriesOp, injectionSignatureCatalog, isDegradedTopicSkip, isRerankerAvailable, isSupportedFile, isSupportedMediaType, makeSyntheticStoredConversation, makeSyntheticStoredMessage, maybeSummarizeHistory, mediaToStored, migrateFromModelPreferencesOp, onKeyAvailable, parseMedia, preEmbedVaultMemories, preprocessFiles, progressiveSummarize, projectToStored, queueManager, rankProfileCandidates, recall, reflect, refreshEncryptionKeyIfMatches, relinkMemoryTopicsOp, relinkMisclassifiedVideosOp, renderTemplate, requestEncryptionKey, requestKeyPair, restoreVaultMemoryOp, resumeStream, retain, runToolLoop, sanitizeQuotes, schemaToCreateSQL, scoreProfileSalience, screenCandidatesForInjection, sdkMigrations, sdkModelClasses, sdkSchema, searchChunksOp, searchMediaOp, searchMessagesOp, searchVaultMemories, seedEncryptionKeys, selectServerToolsForPrompt, serverPlatformStorage, setMemoryVisibilityOp, setModelPreferenceOp, setUserPreferenceOp, shouldAnalyzeStyle, shouldChunkMessage, shouldRecallMemory, shouldRefreshTools, splitMessagesAtThreshold, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, stripLegacyChunkTextOp, summarizeObservationTrends, summaryToSystemMessage, supersedeVaultMemoryOp, synthesizeProfile, toolSetSystemPrompts, traverseGraphLane, ttlForType, updateConversationProjectOp, updateConversationTitleOp, updateMediaMessageIdBatchOp, updateMediaOp, updateMessageChunksOp, updateMessageEmbeddingOp, updateMessageErrorOp, updateMessageFeedbackOp, updateModelsOp, updatePersonalityOp, updateProfileOp, updateProjectNameOp, updateProjectOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertConversationSummaryOp, upsertMessageOp, verifyMemoriesForPublish };
11047
+ export { type AnalyzeStyleOptions, type AnalyzeStyleResult, type ApiResponse, type ApiType, type AutoExecutedToolResult, type AutoExtractMessage, type AutoExtractor, type Budget, type BuildPromptOptions, type BuildPromptResult, type CachedChunkVectors, type CachedServerTools, type ChatCompletionUsage, type ChatRole, type ChunkSearchResult, type ChunkSearchStats, type ChunkVectorCache, type ChunkingOptions, type ConnectorGuidance, type ConnectorGuidanceInput, type ConsolidationAction, type ConsolidationFallbackReason, Conversation, ConversationSummary, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateDecaySweeperOptions, type CreateMediaOptions, type CreateMessageOptions, type CreateModelPreferenceOptions, type CreateProjectOptions, type CreateUserPreferenceOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_ANALYSIS_PROMPT, DEFAULT_ANALYZE_AFTER_MESSAGES, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_DECAY_POLICY, DEFAULT_DOCUMENT_PATTERN, DEFAULT_EXCLUDED_SERVER_TOOLS, DEFAULT_MAX_CLASSIFIER_CALLS_PER_SWEEP, DEFAULT_MAX_INPUT_MESSAGES, DEFAULT_MAX_PROFILE_LENGTH, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_MIN_MESSAGES, DEFAULT_PERSONALITY_SETTINGS, DEFAULT_PROFILE_FACETS, DEFAULT_PROFILE_FACT_TYPE_WEIGHTS, DEFAULT_PROFILE_PROOF_ALPHA, DEFAULT_PROFILE_TREND_MULTIPLIERS, DEFAULT_PROMPT_TEMPLATES, DEFAULT_REFRESH_EVERY_MESSAGES, DEFAULT_SERVER_TOOLS_MATCH_OPTIONS, DEFAULT_SUMMARY_MIN_WINDOW_MESSAGES, DEFAULT_SUMMARY_MODEL, DEFAULT_SUMMARY_TOKEN_THRESHOLD, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type DecayCandidateRaw, type DecayClassifier, type DecayInput, type DecayPolicy, type DecaySweepResult, type DecaySweeper, type DecayVerdict, type DurableAutoExtractorOptions, ENTITY_FANOUT, type EmbeddedWalletSignerFn, type EmbeddingRepairOptions, type EmbeddingRepairResult, EncryptionKeyMissingError, ExcelProcessor, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type ExtractionFunnel, type ExtractionMessageSource, type ExtractionSourceMessage, type ExtractionSourceStatus, type ExtractionTimings, type FactType, type FileMetadata, type FileProcessingReason, type FileProcessingStatus, type FileProcessor, type FileTypeQuery, type FileWithData, type FlushResult, type GetConversationsPageOptions, type GraphTraversalOptions, HARD_DELETE_WINDOW_MS, INFERENCE_ID_HEADER, type InjectionClassifierOptions, type InjectionReason, type LazyStoredConversation, type LlmDecayClassifierOptions, type LlmNeighborRefinerOptions, type LlmTokenUsage, type LocalMemoryStoreOptions, MAX_HOPS, MAX_MESSAGES_PER_SUMMARIZATION, MEDIUM_TTL_MS, MEMORY_KINDS, MEMORY_LEVELS, Media, type MediaDimensions, type MediaFilterOptions, type MediaMetadata, type MediaOperationsContext, type MediaRole, type MediaType, type MemoriesNeedingTopicExtraction, type MemoryContextItem, type MemoryContextLane, type MemoryContextOptions, type MemoryContextResult, type MemoryDecay, type MemoryDecaySweeperOptions, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryLevel, MemoryLevelError, type MemoryListOptions, type MemoryMaintenance, type MemoryQuarantinedEvent, type MemoryRecallOptions, type MemoryRetainOptions, type MemoryStore, type MemorySubscribeOptions, type MemoryToVerify, type MemoryTopic, type MemoryTopicBacklog, type MemoryTopicMaintenance, type MemoryUpdate, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MemoryVerification, Message, type MessageChunk, type MessageFeedback, type MessageOrigin, type ModelCallEndEvent, type ModelCallStartEvent, ModelPreference, NEVER_TTL_MS, NODE_BUDGET, type NeighborRefiner, type NowSource, type ObservationTrend, type ObservationTrendInput, type OperationExecutor, PAST_EVENT_GRACE_MS, PROFILE_DOC_VERSION, type ParsedServerToolsResponse, PdfProcessor, type PersonalitySettings, type PersonalitySliders, type PersonalityStyle, type PgClientLike, type PgPoolLike, type PhotoIngestResult, type PhotoMediaRef, type PlatformStorage, type PortalLlmAuth, type PortalLlmFailure, type PortalLlmFailureReason, PostgreSQLAdapter, type PostgreSQLAdapterOptions, type PreprocessingOptions, type PreprocessingResult, type ProcessedFileResult, ProcessorRegistry, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type ProfileUpdate, Project, type ProjectOperationsContext, type PromptContext, type PromptPreProcessor, type PromptPreProcessorContext, type PromptSection, type PromptTemplates, type PublishedPhotoMemory, type QuarantinedMemoryInfo, type QueueEncryptionContext, QueueManager, type QueueStatus, type QueuedOperation, type QueuedOperationType, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankedMemory, type RankedProfileCandidate, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallEmptyReason, type RecallOptions, type RecallResult, type RecallTelemetryCallbacks, type RecallToolCallbacks, type RecallToolOptions, type RecallTruncation, type RecencyOptions, type ReflectOptions, type ReflectResult, type RequestEncryptionKeyOptions, RerankerUnavailableError, type ResumeStreamOptions, type ResumeStreamResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, type RunEndEvent, type RunErrorEvent, type RunHooks, type RunStartEvent, type RunTerminalState, type RunToolLoopOptions, type RunToolLoopResult, SDK_SCHEMA_VERSION, SERVER_TOOL_DEPENDENCY_SETS, SHORT_TTL_MS, SLIDER_CONFIG, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type ScoreProfileSalienceOptions, type ScreenResult, type ScreenedCandidate, type SearchSource, type SelectServerToolsForPromptOptions, type ServerTool, type ServerToolCallEvent, type ServerToolsFilterFunction, type ServerToolsOptions, type ServerToolsResponse, type SettingsStorageOperationsContext, type SignMessageFn, type StepFinishEvent, type StockPriceClassification, type StockPricePreProcessorOptions, type StorageOperationsContext, type StoredConversation, type StoredConversationSummary, type StoredFileWithContext, type StoredMedia, type StoredMessage, type StoredMessageWithSimilarity, type StoredModelPreference, type StoredProject, type StoredUserPreference, type StoredVaultMemory, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type StreamSmoothingConfig, type StreamingTransport, type StreamingTransportOptions, type StreamingTransportResult, type StyleAnalysisSchedule, type SynthesizeProfileOptions, TOOL_CATALOG, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, TextProcessor, type ToolConfig, type ToolExecutor, type ToolMatchOptions, type ToolMatchResult, type ToolSet, type ToolUseEndEvent, type ToolUseStartEvent, type TopicExtractOptions, type TopicExtractionBatchDiagnostics, type TopicExtractionInput, type TopicExtractionRunResult, type TopicSkipReason, type TurnCompleteEvent, type TurnSkippedEvent, type UncheckedReason, type UnverifiableReason, type UpdateMediaOptions, type UpdateModelPreferenceOptions, type UpdateProjectOptions, type UpdateUserPreferenceOptions, type UpdateVaultMemoryOptions, UserPreference, type UserPreferencesStorageOperationsContext, VAULT_SIZE_HOP_CAP, type VaultEmbeddingCache, type VaultEmbeddingExpectation, VaultMemory, type VaultMemoryKind, type VaultMemoryOperationsContext, type VaultMemoryVisibility, type VaultSaveOperation, type VaultSearchResult, type VerificationSources, type VerifyMemoriesForPublishOptions, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, WordProcessor, ZipProcessor, type ZipProcessorOptions, activatedToolSetNames, analyzeStyle, archiveVaultMemoryOp, assembleMemoryContext, backfillMemoryTopicsOp, buildConnectorGuidance, buildDeniedToolsRider, buildSystemPrompt, capHopsForDensity, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyDecay, classifyInjectionCandidates, classifyObservationTrend, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, cleanupConversationSummary, clearAllEncryptionKeys, clearAllEncryptionState, clearAllKeyPairs, clearEncryptionKey, clearKeyPair, clearLazyTitleCache, clearMessagesOp, clearServerToolsCache, composeHooks, createAutoExtractor, createChunkVectorCache, createConversationOp, createCryptoPricePreProcessor, createDecaySweeper, createDurableAutoExtractor, createLlmDecayClassifier, createLlmNeighborRefiner, createLocalMemoryStore, createMediaBatchOp, createMediaOp, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageOp, createMessageSourceResolver, createPlatformCursorStore, createProjectOp, createRecallTool, createServerToolsFilter, createStockPricePreProcessor, createSummaryContext, createVaultEmbeddingCache, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, decryptData, decryptDataBatch, decryptDataBytes, decryptDataBytesFromBytes, decryptDataWithKey, decryptMessageEmbeddingFields, defaultServerToolsFilter, deleteAllVaultMemoriesForUserOp, deleteConversationOp, deleteConversationSummaryOp, deleteMediaByConversationOp, deleteMediaByMessageOp, deleteMediaOp, deleteMessageOp, deleteModelPreferenceOp, deleteProjectOp, deleteUserPreferenceOp, deleteVaultMemoryOp, deriveKeyFromSignatureBytes, eagerEmbedContent, embedAllMessages, embedMessage, encryptData, encryptDataBatch, encryptDataBytes, encryptDataWithKey, encryptToolCallEventsOp, estimateMessagesTokens, estimateTokens, exportPublicKey, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, findMatchingTools, formatFileProcessingNotes, generateConversationId, generateEmbedding, generateEmbeddings, generateMediaId, generateProjectId, getAIGeneratedMediaOp, getAllFilesOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getAudioOp, getCachedServerTools, getConversationOp, getConversationSummaryOp, getConversationsByProjectLazyOp, getConversationsByProjectOp, getConversationsLazyOp, getConversationsOp, getConversationsPageOp, getDecayCandidatesRawOp, getDocumentsOp, getEncryptionKey, getImagesOp, getMediaByConversationOp, getMediaByIdOp, getMediaByIdsOp, getMediaByMessageOp, getMediaByModelOp, getMediaByRoleOp, getMediaBySourceUrlOp, getMediaByTypeOp, getMediaCountOp, getMediaCountsByTypeOp, getMediaOp, getMediaTypeFromMime, getMemoriesNeedingTopicExtractionOp, getMessageOp, getMessagesOp, getModelPreferenceOp, getProjectConversationCountOp, getProjectConversationsOp, getProjectOp, getProjectsOp, getRecentMediaOp, getServerTools, getSupportedFileTypes, getToolsChecksum, getUnfiledVaultMemoriesOp, getUserPreferenceOp, getUserUploadedMediaOp, getVaultMemoryOp, getVideosOp, hardDeleteDecayedOp, hardDeleteMediaOp, hasEncryptionKey, hasKeyPair, ingestPublishedPhotoMemoriesOp, injectionSignatureCatalog, isDegradedTopicSkip, isRerankerAvailable, isSupportedFile, isSupportedMediaType, makeSyntheticStoredConversation, makeSyntheticStoredMessage, maybeSummarizeHistory, mediaToStored, migrateFromModelPreferencesOp, onKeyAvailable, parseMedia, preEmbedVaultMemories, preprocessFiles, progressiveSummarize, projectToStored, queueManager, rankProfileCandidates, recall, reflect, refreshEncryptionKeyIfMatches, relinkMemoryTopicsOp, relinkMisclassifiedVideosOp, renderTemplate, requestEncryptionKey, requestKeyPair, restoreVaultMemoryOp, resumeStream, retain, runToolLoop, sanitizeQuotes, schemaToCreateSQL, scoreProfileSalience, screenCandidatesForInjection, sdkMigrations, sdkModelClasses, sdkSchema, sealLegacyMessageEmbeddingsOp, searchChunksOp, searchMediaOp, searchMessagesOp, searchVaultMemories, seedEncryptionKeys, selectServerToolsForPrompt, serverPlatformStorage, setMemoryVisibilityOp, setModelPreferenceOp, setUserPreferenceOp, shouldAnalyzeStyle, shouldChunkMessage, shouldRecallMemory, shouldRefreshTools, splitMessagesAtThreshold, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, stripLegacyChunkTextOp, summarizeObservationTrends, summaryToSystemMessage, supersedeVaultMemoryOp, synthesizeProfile, toolSetSystemPrompts, traverseGraphLane, ttlForType, updateConversationProjectOp, updateConversationTitleOp, updateMediaMessageIdBatchOp, updateMediaOp, updateMessageChunksOp, updateMessageEmbeddingOp, updateMessageErrorOp, updateMessageFeedbackOp, updateModelsOp, updatePersonalityOp, updateProfileOp, updateProjectNameOp, updateProjectOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertConversationSummaryOp, upsertMessageOp, verifyMemoriesForPublish };