@reverbia/sdk 1.0.0-next.20251217144159 → 1.0.0-next.20251218151654
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.
- package/dist/expo/index.cjs +313 -269
- package/dist/expo/index.d.mts +130 -414
- package/dist/expo/index.d.ts +130 -414
- package/dist/expo/index.mjs +299 -248
- package/dist/index.cjs +46 -2
- package/dist/index.d.mts +175 -2
- package/dist/index.d.ts +175 -2
- package/dist/index.mjs +41 -1
- package/dist/react/index.cjs +424 -331
- package/dist/react/index.d.mts +136 -453
- package/dist/react/index.d.ts +136 -453
- package/dist/react/index.mjs +404 -304
- package/package.json +2 -2
package/dist/expo/index.mjs
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result) __defProp(target, key, result);
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
11
|
+
|
|
1
12
|
// src/expo/useChat.ts
|
|
2
13
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
14
|
|
|
@@ -283,7 +294,137 @@ function useChat(options) {
|
|
|
283
294
|
// src/expo/useChatStorage.ts
|
|
284
295
|
import { useCallback as useCallback2, useState as useState2, useMemo } from "react";
|
|
285
296
|
|
|
286
|
-
// src/lib/
|
|
297
|
+
// src/lib/db/chat/schema.ts
|
|
298
|
+
import { appSchema, tableSchema } from "@nozbe/watermelondb";
|
|
299
|
+
import {
|
|
300
|
+
schemaMigrations,
|
|
301
|
+
addColumns
|
|
302
|
+
} from "@nozbe/watermelondb/Schema/migrations";
|
|
303
|
+
var chatStorageSchema = appSchema({
|
|
304
|
+
version: 2,
|
|
305
|
+
tables: [
|
|
306
|
+
tableSchema({
|
|
307
|
+
name: "history",
|
|
308
|
+
columns: [
|
|
309
|
+
{ name: "message_id", type: "number" },
|
|
310
|
+
{ name: "conversation_id", type: "string", isIndexed: true },
|
|
311
|
+
{ name: "role", type: "string", isIndexed: true },
|
|
312
|
+
{ name: "content", type: "string" },
|
|
313
|
+
{ name: "model", type: "string", isOptional: true },
|
|
314
|
+
{ name: "files", type: "string", isOptional: true },
|
|
315
|
+
{ name: "created_at", type: "number", isIndexed: true },
|
|
316
|
+
{ name: "updated_at", type: "number" },
|
|
317
|
+
{ name: "vector", type: "string", isOptional: true },
|
|
318
|
+
{ name: "embedding_model", type: "string", isOptional: true },
|
|
319
|
+
{ name: "usage", type: "string", isOptional: true },
|
|
320
|
+
{ name: "sources", type: "string", isOptional: true },
|
|
321
|
+
{ name: "response_duration", type: "number", isOptional: true },
|
|
322
|
+
{ name: "was_stopped", type: "boolean", isOptional: true }
|
|
323
|
+
]
|
|
324
|
+
}),
|
|
325
|
+
tableSchema({
|
|
326
|
+
name: "conversations",
|
|
327
|
+
columns: [
|
|
328
|
+
{ name: "conversation_id", type: "string", isIndexed: true },
|
|
329
|
+
{ name: "title", type: "string" },
|
|
330
|
+
{ name: "created_at", type: "number" },
|
|
331
|
+
{ name: "updated_at", type: "number" },
|
|
332
|
+
{ name: "is_deleted", type: "boolean", isIndexed: true }
|
|
333
|
+
]
|
|
334
|
+
})
|
|
335
|
+
]
|
|
336
|
+
});
|
|
337
|
+
var chatStorageMigrations = schemaMigrations({
|
|
338
|
+
migrations: [
|
|
339
|
+
{
|
|
340
|
+
toVersion: 2,
|
|
341
|
+
steps: [
|
|
342
|
+
addColumns({
|
|
343
|
+
table: "history",
|
|
344
|
+
columns: [{ name: "was_stopped", type: "boolean", isOptional: true }]
|
|
345
|
+
})
|
|
346
|
+
]
|
|
347
|
+
}
|
|
348
|
+
]
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
// src/lib/db/chat/models.ts
|
|
352
|
+
import { Model } from "@nozbe/watermelondb";
|
|
353
|
+
import { field, text, date, json } from "@nozbe/watermelondb/decorators";
|
|
354
|
+
var Message = class extends Model {
|
|
355
|
+
};
|
|
356
|
+
Message.table = "history";
|
|
357
|
+
Message.associations = {
|
|
358
|
+
conversations: { type: "belongs_to", key: "conversation_id" }
|
|
359
|
+
};
|
|
360
|
+
__decorateClass([
|
|
361
|
+
field("message_id")
|
|
362
|
+
], Message.prototype, "messageId", 2);
|
|
363
|
+
__decorateClass([
|
|
364
|
+
text("conversation_id")
|
|
365
|
+
], Message.prototype, "conversationId", 2);
|
|
366
|
+
__decorateClass([
|
|
367
|
+
text("role")
|
|
368
|
+
], Message.prototype, "role", 2);
|
|
369
|
+
__decorateClass([
|
|
370
|
+
text("content")
|
|
371
|
+
], Message.prototype, "content", 2);
|
|
372
|
+
__decorateClass([
|
|
373
|
+
text("model")
|
|
374
|
+
], Message.prototype, "model", 2);
|
|
375
|
+
__decorateClass([
|
|
376
|
+
json("files", (json3) => json3)
|
|
377
|
+
], Message.prototype, "files", 2);
|
|
378
|
+
__decorateClass([
|
|
379
|
+
date("created_at")
|
|
380
|
+
], Message.prototype, "createdAt", 2);
|
|
381
|
+
__decorateClass([
|
|
382
|
+
date("updated_at")
|
|
383
|
+
], Message.prototype, "updatedAt", 2);
|
|
384
|
+
__decorateClass([
|
|
385
|
+
json("vector", (json3) => json3)
|
|
386
|
+
], Message.prototype, "vector", 2);
|
|
387
|
+
__decorateClass([
|
|
388
|
+
text("embedding_model")
|
|
389
|
+
], Message.prototype, "embeddingModel", 2);
|
|
390
|
+
__decorateClass([
|
|
391
|
+
json("usage", (json3) => json3)
|
|
392
|
+
], Message.prototype, "usage", 2);
|
|
393
|
+
__decorateClass([
|
|
394
|
+
json("sources", (json3) => json3)
|
|
395
|
+
], Message.prototype, "sources", 2);
|
|
396
|
+
__decorateClass([
|
|
397
|
+
field("response_duration")
|
|
398
|
+
], Message.prototype, "responseDuration", 2);
|
|
399
|
+
__decorateClass([
|
|
400
|
+
field("was_stopped")
|
|
401
|
+
], Message.prototype, "wasStopped", 2);
|
|
402
|
+
var Conversation = class extends Model {
|
|
403
|
+
};
|
|
404
|
+
Conversation.table = "conversations";
|
|
405
|
+
Conversation.associations = {
|
|
406
|
+
history: { type: "has_many", foreignKey: "conversation_id" }
|
|
407
|
+
};
|
|
408
|
+
__decorateClass([
|
|
409
|
+
text("conversation_id")
|
|
410
|
+
], Conversation.prototype, "conversationId", 2);
|
|
411
|
+
__decorateClass([
|
|
412
|
+
text("title")
|
|
413
|
+
], Conversation.prototype, "title", 2);
|
|
414
|
+
__decorateClass([
|
|
415
|
+
date("created_at")
|
|
416
|
+
], Conversation.prototype, "createdAt", 2);
|
|
417
|
+
__decorateClass([
|
|
418
|
+
date("updated_at")
|
|
419
|
+
], Conversation.prototype, "updatedAt", 2);
|
|
420
|
+
__decorateClass([
|
|
421
|
+
field("is_deleted")
|
|
422
|
+
], Conversation.prototype, "isDeleted", 2);
|
|
423
|
+
|
|
424
|
+
// src/lib/db/chat/types.ts
|
|
425
|
+
function generateConversationId() {
|
|
426
|
+
return `conv_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
|
|
427
|
+
}
|
|
287
428
|
function convertUsageToStored(usage) {
|
|
288
429
|
if (!usage) return void 0;
|
|
289
430
|
return {
|
|
@@ -293,11 +434,8 @@ function convertUsageToStored(usage) {
|
|
|
293
434
|
costMicroUsd: usage.cost_micro_usd
|
|
294
435
|
};
|
|
295
436
|
}
|
|
296
|
-
function generateConversationId() {
|
|
297
|
-
return `conv_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
|
|
298
|
-
}
|
|
299
437
|
|
|
300
|
-
// src/lib/
|
|
438
|
+
// src/lib/db/chat/operations.ts
|
|
301
439
|
import { Q } from "@nozbe/watermelondb";
|
|
302
440
|
function messageToStored(message) {
|
|
303
441
|
return {
|
|
@@ -1734,10 +1872,83 @@ function useModels(options = {}) {
|
|
|
1734
1872
|
import { useCallback as useCallback5, useState as useState5, useMemo as useMemo2, useRef as useRef4 } from "react";
|
|
1735
1873
|
import { postApiV1ChatCompletions } from "@reverbia/sdk";
|
|
1736
1874
|
|
|
1737
|
-
// src/lib/
|
|
1738
|
-
import {
|
|
1875
|
+
// src/lib/db/memory/schema.ts
|
|
1876
|
+
import { appSchema as appSchema2, tableSchema as tableSchema2 } from "@nozbe/watermelondb";
|
|
1877
|
+
var memoryStorageSchema = appSchema2({
|
|
1878
|
+
version: 1,
|
|
1879
|
+
tables: [
|
|
1880
|
+
tableSchema2({
|
|
1881
|
+
name: "memories",
|
|
1882
|
+
columns: [
|
|
1883
|
+
{ name: "type", type: "string", isIndexed: true },
|
|
1884
|
+
{ name: "namespace", type: "string", isIndexed: true },
|
|
1885
|
+
{ name: "key", type: "string", isIndexed: true },
|
|
1886
|
+
{ name: "value", type: "string" },
|
|
1887
|
+
{ name: "raw_evidence", type: "string" },
|
|
1888
|
+
{ name: "confidence", type: "number" },
|
|
1889
|
+
{ name: "pii", type: "boolean", isIndexed: true },
|
|
1890
|
+
{ name: "composite_key", type: "string", isIndexed: true },
|
|
1891
|
+
{ name: "unique_key", type: "string", isIndexed: true },
|
|
1892
|
+
{ name: "created_at", type: "number", isIndexed: true },
|
|
1893
|
+
{ name: "updated_at", type: "number" },
|
|
1894
|
+
{ name: "embedding", type: "string", isOptional: true },
|
|
1895
|
+
{ name: "embedding_model", type: "string", isOptional: true },
|
|
1896
|
+
{ name: "is_deleted", type: "boolean", isIndexed: true }
|
|
1897
|
+
]
|
|
1898
|
+
})
|
|
1899
|
+
]
|
|
1900
|
+
});
|
|
1901
|
+
|
|
1902
|
+
// src/lib/db/memory/models.ts
|
|
1903
|
+
import { Model as Model2 } from "@nozbe/watermelondb";
|
|
1904
|
+
import { field as field2, text as text2, date as date2, json as json2 } from "@nozbe/watermelondb/decorators";
|
|
1905
|
+
var Memory = class extends Model2 {
|
|
1906
|
+
};
|
|
1907
|
+
Memory.table = "memories";
|
|
1908
|
+
__decorateClass([
|
|
1909
|
+
text2("type")
|
|
1910
|
+
], Memory.prototype, "type", 2);
|
|
1911
|
+
__decorateClass([
|
|
1912
|
+
text2("namespace")
|
|
1913
|
+
], Memory.prototype, "namespace", 2);
|
|
1914
|
+
__decorateClass([
|
|
1915
|
+
text2("key")
|
|
1916
|
+
], Memory.prototype, "key", 2);
|
|
1917
|
+
__decorateClass([
|
|
1918
|
+
text2("value")
|
|
1919
|
+
], Memory.prototype, "value", 2);
|
|
1920
|
+
__decorateClass([
|
|
1921
|
+
text2("raw_evidence")
|
|
1922
|
+
], Memory.prototype, "rawEvidence", 2);
|
|
1923
|
+
__decorateClass([
|
|
1924
|
+
field2("confidence")
|
|
1925
|
+
], Memory.prototype, "confidence", 2);
|
|
1926
|
+
__decorateClass([
|
|
1927
|
+
field2("pii")
|
|
1928
|
+
], Memory.prototype, "pii", 2);
|
|
1929
|
+
__decorateClass([
|
|
1930
|
+
text2("composite_key")
|
|
1931
|
+
], Memory.prototype, "compositeKey", 2);
|
|
1932
|
+
__decorateClass([
|
|
1933
|
+
text2("unique_key")
|
|
1934
|
+
], Memory.prototype, "uniqueKey", 2);
|
|
1935
|
+
__decorateClass([
|
|
1936
|
+
date2("created_at")
|
|
1937
|
+
], Memory.prototype, "createdAt", 2);
|
|
1938
|
+
__decorateClass([
|
|
1939
|
+
date2("updated_at")
|
|
1940
|
+
], Memory.prototype, "updatedAt", 2);
|
|
1941
|
+
__decorateClass([
|
|
1942
|
+
json2("embedding", (json3) => json3)
|
|
1943
|
+
], Memory.prototype, "embedding", 2);
|
|
1944
|
+
__decorateClass([
|
|
1945
|
+
text2("embedding_model")
|
|
1946
|
+
], Memory.prototype, "embeddingModel", 2);
|
|
1947
|
+
__decorateClass([
|
|
1948
|
+
field2("is_deleted")
|
|
1949
|
+
], Memory.prototype, "isDeleted", 2);
|
|
1739
1950
|
|
|
1740
|
-
// src/lib/
|
|
1951
|
+
// src/lib/db/memory/types.ts
|
|
1741
1952
|
function generateCompositeKey(namespace, key) {
|
|
1742
1953
|
return `${namespace}:${key}`;
|
|
1743
1954
|
}
|
|
@@ -1763,7 +1974,8 @@ function cosineSimilarity(a, b) {
|
|
|
1763
1974
|
return dotProduct / denominator;
|
|
1764
1975
|
}
|
|
1765
1976
|
|
|
1766
|
-
// src/lib/
|
|
1977
|
+
// src/lib/db/memory/operations.ts
|
|
1978
|
+
import { Q as Q2 } from "@nozbe/watermelondb";
|
|
1767
1979
|
function memoryToStored(memory) {
|
|
1768
1980
|
return {
|
|
1769
1981
|
uniqueId: memory.id,
|
|
@@ -2141,7 +2353,7 @@ var DEFAULT_COMPLETION_MODEL = "openai/gpt-4o";
|
|
|
2141
2353
|
|
|
2142
2354
|
// src/expo/useMemoryStorage.ts
|
|
2143
2355
|
import { postApiV1Embeddings } from "@reverbia/sdk";
|
|
2144
|
-
async function generateEmbeddingForTextApi(
|
|
2356
|
+
async function generateEmbeddingForTextApi(text4, options) {
|
|
2145
2357
|
const token = options.getToken ? await options.getToken() : null;
|
|
2146
2358
|
if (!token) {
|
|
2147
2359
|
throw new Error("No auth token available for embedding generation");
|
|
@@ -2149,7 +2361,7 @@ async function generateEmbeddingForTextApi(text, options) {
|
|
|
2149
2361
|
const response = await postApiV1Embeddings({
|
|
2150
2362
|
baseUrl: options.baseUrl,
|
|
2151
2363
|
body: {
|
|
2152
|
-
input:
|
|
2364
|
+
input: text4,
|
|
2153
2365
|
model: options.model
|
|
2154
2366
|
},
|
|
2155
2367
|
headers: {
|
|
@@ -2166,8 +2378,8 @@ async function generateEmbeddingForTextApi(text, options) {
|
|
|
2166
2378
|
return embedding;
|
|
2167
2379
|
}
|
|
2168
2380
|
async function generateEmbeddingForMemoryApi(memory, options) {
|
|
2169
|
-
const
|
|
2170
|
-
return generateEmbeddingForTextApi(
|
|
2381
|
+
const text4 = `${memory.type}: ${memory.namespace}/${memory.key} = ${memory.value}. Evidence: ${memory.rawEvidence}`;
|
|
2382
|
+
return generateEmbeddingForTextApi(text4, options);
|
|
2171
2383
|
}
|
|
2172
2384
|
function useMemoryStorage(options) {
|
|
2173
2385
|
const {
|
|
@@ -2692,38 +2904,53 @@ function useMemoryStorage(options) {
|
|
|
2692
2904
|
};
|
|
2693
2905
|
}
|
|
2694
2906
|
|
|
2695
|
-
// src/lib/
|
|
2696
|
-
import { appSchema, tableSchema } from "@nozbe/watermelondb";
|
|
2697
|
-
import {
|
|
2698
|
-
|
|
2699
|
-
|
|
2907
|
+
// src/lib/db/schema.ts
|
|
2908
|
+
import { appSchema as appSchema3, tableSchema as tableSchema3 } from "@nozbe/watermelondb";
|
|
2909
|
+
import {
|
|
2910
|
+
schemaMigrations as schemaMigrations2,
|
|
2911
|
+
addColumns as addColumns2,
|
|
2912
|
+
createTable
|
|
2913
|
+
} from "@nozbe/watermelondb/Schema/migrations";
|
|
2914
|
+
|
|
2915
|
+
// src/lib/db/settings/models.ts
|
|
2916
|
+
import { Model as Model3 } from "@nozbe/watermelondb";
|
|
2917
|
+
import { text as text3 } from "@nozbe/watermelondb/decorators";
|
|
2918
|
+
var ModelPreference = class extends Model3 {
|
|
2919
|
+
};
|
|
2920
|
+
ModelPreference.table = "modelPreferences";
|
|
2921
|
+
__decorateClass([
|
|
2922
|
+
text3("wallet_address")
|
|
2923
|
+
], ModelPreference.prototype, "walletAddress", 2);
|
|
2924
|
+
__decorateClass([
|
|
2925
|
+
text3("models")
|
|
2926
|
+
], ModelPreference.prototype, "models", 2);
|
|
2927
|
+
|
|
2928
|
+
// src/lib/db/schema.ts
|
|
2929
|
+
var SDK_SCHEMA_VERSION = 4;
|
|
2930
|
+
var sdkSchema = appSchema3({
|
|
2931
|
+
version: SDK_SCHEMA_VERSION,
|
|
2700
2932
|
tables: [
|
|
2701
|
-
|
|
2933
|
+
// Chat storage tables
|
|
2934
|
+
tableSchema3({
|
|
2702
2935
|
name: "history",
|
|
2703
2936
|
columns: [
|
|
2704
2937
|
{ name: "message_id", type: "number" },
|
|
2705
|
-
// Sequential ID within conversation
|
|
2706
2938
|
{ name: "conversation_id", type: "string", isIndexed: true },
|
|
2707
2939
|
{ name: "role", type: "string", isIndexed: true },
|
|
2708
|
-
// 'user' | 'assistant' | 'system'
|
|
2709
2940
|
{ name: "content", type: "string" },
|
|
2710
2941
|
{ name: "model", type: "string", isOptional: true },
|
|
2711
2942
|
{ name: "files", type: "string", isOptional: true },
|
|
2712
|
-
// JSON stringified FileMetadata[]
|
|
2713
2943
|
{ name: "created_at", type: "number", isIndexed: true },
|
|
2714
2944
|
{ name: "updated_at", type: "number" },
|
|
2715
2945
|
{ name: "vector", type: "string", isOptional: true },
|
|
2716
|
-
// JSON stringified number[]
|
|
2717
2946
|
{ name: "embedding_model", type: "string", isOptional: true },
|
|
2718
2947
|
{ name: "usage", type: "string", isOptional: true },
|
|
2719
|
-
// JSON stringified ChatCompletionUsage
|
|
2720
2948
|
{ name: "sources", type: "string", isOptional: true },
|
|
2721
|
-
// JSON stringified SearchSource[]
|
|
2722
2949
|
{ name: "response_duration", type: "number", isOptional: true },
|
|
2723
2950
|
{ name: "was_stopped", type: "boolean", isOptional: true }
|
|
2724
2951
|
]
|
|
2725
2952
|
}),
|
|
2726
|
-
|
|
2953
|
+
tableSchema3({
|
|
2727
2954
|
name: "conversations",
|
|
2728
2955
|
columns: [
|
|
2729
2956
|
{ name: "conversation_id", type: "string", isIndexed: true },
|
|
@@ -2732,249 +2959,70 @@ var chatStorageSchema = appSchema({
|
|
|
2732
2959
|
{ name: "updated_at", type: "number" },
|
|
2733
2960
|
{ name: "is_deleted", type: "boolean", isIndexed: true }
|
|
2734
2961
|
]
|
|
2735
|
-
})
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
var chatStorageMigrations = schemaMigrations({
|
|
2739
|
-
migrations: [
|
|
2740
|
-
{
|
|
2741
|
-
toVersion: 2,
|
|
2742
|
-
steps: [
|
|
2743
|
-
addColumns({
|
|
2744
|
-
table: "history",
|
|
2745
|
-
columns: [
|
|
2746
|
-
{ name: "was_stopped", type: "boolean", isOptional: true }
|
|
2747
|
-
]
|
|
2748
|
-
})
|
|
2749
|
-
]
|
|
2750
|
-
}
|
|
2751
|
-
]
|
|
2752
|
-
});
|
|
2753
|
-
|
|
2754
|
-
// src/lib/chatStorage/models.ts
|
|
2755
|
-
import { Model } from "@nozbe/watermelondb";
|
|
2756
|
-
var Message = class extends Model {
|
|
2757
|
-
/** Sequential message ID within conversation */
|
|
2758
|
-
get messageId() {
|
|
2759
|
-
return this._getRaw("message_id");
|
|
2760
|
-
}
|
|
2761
|
-
/** Links message to its conversation */
|
|
2762
|
-
get conversationId() {
|
|
2763
|
-
return this._getRaw("conversation_id");
|
|
2764
|
-
}
|
|
2765
|
-
/** Who sent the message: 'user' | 'assistant' | 'system' */
|
|
2766
|
-
get role() {
|
|
2767
|
-
return this._getRaw("role");
|
|
2768
|
-
}
|
|
2769
|
-
/** The message text content */
|
|
2770
|
-
get content() {
|
|
2771
|
-
return this._getRaw("content");
|
|
2772
|
-
}
|
|
2773
|
-
/** LLM model used (e.g., GPT-4, Claude) */
|
|
2774
|
-
get model() {
|
|
2775
|
-
const value = this._getRaw("model");
|
|
2776
|
-
return value ? value : void 0;
|
|
2777
|
-
}
|
|
2778
|
-
/** Optional attached files */
|
|
2779
|
-
get files() {
|
|
2780
|
-
const raw = this._getRaw("files");
|
|
2781
|
-
if (!raw) return void 0;
|
|
2782
|
-
try {
|
|
2783
|
-
return JSON.parse(raw);
|
|
2784
|
-
} catch {
|
|
2785
|
-
return void 0;
|
|
2786
|
-
}
|
|
2787
|
-
}
|
|
2788
|
-
/** Created timestamp */
|
|
2789
|
-
get createdAt() {
|
|
2790
|
-
return new Date(this._getRaw("created_at"));
|
|
2791
|
-
}
|
|
2792
|
-
/** Updated timestamp */
|
|
2793
|
-
get updatedAt() {
|
|
2794
|
-
return new Date(this._getRaw("updated_at"));
|
|
2795
|
-
}
|
|
2796
|
-
/** Embedding vector for semantic search */
|
|
2797
|
-
get vector() {
|
|
2798
|
-
const raw = this._getRaw("vector");
|
|
2799
|
-
if (!raw) return void 0;
|
|
2800
|
-
try {
|
|
2801
|
-
return JSON.parse(raw);
|
|
2802
|
-
} catch {
|
|
2803
|
-
return void 0;
|
|
2804
|
-
}
|
|
2805
|
-
}
|
|
2806
|
-
/** Model used to generate embedding */
|
|
2807
|
-
get embeddingModel() {
|
|
2808
|
-
const value = this._getRaw("embedding_model");
|
|
2809
|
-
return value ? value : void 0;
|
|
2810
|
-
}
|
|
2811
|
-
/** Token counts and cost */
|
|
2812
|
-
get usage() {
|
|
2813
|
-
const raw = this._getRaw("usage");
|
|
2814
|
-
if (!raw) return void 0;
|
|
2815
|
-
try {
|
|
2816
|
-
return JSON.parse(raw);
|
|
2817
|
-
} catch {
|
|
2818
|
-
return void 0;
|
|
2819
|
-
}
|
|
2820
|
-
}
|
|
2821
|
-
/** Web search sources */
|
|
2822
|
-
get sources() {
|
|
2823
|
-
const raw = this._getRaw("sources");
|
|
2824
|
-
if (!raw) return void 0;
|
|
2825
|
-
try {
|
|
2826
|
-
return JSON.parse(raw);
|
|
2827
|
-
} catch {
|
|
2828
|
-
return void 0;
|
|
2829
|
-
}
|
|
2830
|
-
}
|
|
2831
|
-
/** Response time in seconds */
|
|
2832
|
-
get responseDuration() {
|
|
2833
|
-
const value = this._getRaw("response_duration");
|
|
2834
|
-
return value !== null && value !== void 0 ? value : void 0;
|
|
2835
|
-
}
|
|
2836
|
-
/** Whether the message generation was stopped by the user */
|
|
2837
|
-
get wasStopped() {
|
|
2838
|
-
return this._getRaw("was_stopped");
|
|
2839
|
-
}
|
|
2840
|
-
};
|
|
2841
|
-
Message.table = "history";
|
|
2842
|
-
Message.associations = {
|
|
2843
|
-
conversations: { type: "belongs_to", key: "conversation_id" }
|
|
2844
|
-
};
|
|
2845
|
-
var Conversation = class extends Model {
|
|
2846
|
-
/** Unique conversation identifier */
|
|
2847
|
-
get conversationId() {
|
|
2848
|
-
return this._getRaw("conversation_id");
|
|
2849
|
-
}
|
|
2850
|
-
/** Conversation title */
|
|
2851
|
-
get title() {
|
|
2852
|
-
return this._getRaw("title");
|
|
2853
|
-
}
|
|
2854
|
-
/** Created timestamp */
|
|
2855
|
-
get createdAt() {
|
|
2856
|
-
return new Date(this._getRaw("created_at"));
|
|
2857
|
-
}
|
|
2858
|
-
/** Updated timestamp */
|
|
2859
|
-
get updatedAt() {
|
|
2860
|
-
return new Date(this._getRaw("updated_at"));
|
|
2861
|
-
}
|
|
2862
|
-
/** Soft delete flag */
|
|
2863
|
-
get isDeleted() {
|
|
2864
|
-
return this._getRaw("is_deleted");
|
|
2865
|
-
}
|
|
2866
|
-
};
|
|
2867
|
-
Conversation.table = "conversations";
|
|
2868
|
-
Conversation.associations = {
|
|
2869
|
-
history: { type: "has_many", foreignKey: "conversation_id" }
|
|
2870
|
-
};
|
|
2871
|
-
|
|
2872
|
-
// src/lib/memoryStorage/schema.ts
|
|
2873
|
-
import { appSchema as appSchema2, tableSchema as tableSchema2 } from "@nozbe/watermelondb";
|
|
2874
|
-
var memoryStorageSchema = appSchema2({
|
|
2875
|
-
version: 1,
|
|
2876
|
-
tables: [
|
|
2877
|
-
tableSchema2({
|
|
2962
|
+
}),
|
|
2963
|
+
// Memory storage tables
|
|
2964
|
+
tableSchema3({
|
|
2878
2965
|
name: "memories",
|
|
2879
2966
|
columns: [
|
|
2880
|
-
// Memory type classification
|
|
2881
2967
|
{ name: "type", type: "string", isIndexed: true },
|
|
2882
|
-
// 'identity' | 'preference' | 'project' | 'skill' | 'constraint'
|
|
2883
|
-
// Hierarchical key structure
|
|
2884
2968
|
{ name: "namespace", type: "string", isIndexed: true },
|
|
2885
2969
|
{ name: "key", type: "string", isIndexed: true },
|
|
2886
2970
|
{ name: "value", type: "string" },
|
|
2887
|
-
// Evidence and confidence
|
|
2888
2971
|
{ name: "raw_evidence", type: "string" },
|
|
2889
2972
|
{ name: "confidence", type: "number" },
|
|
2890
2973
|
{ name: "pii", type: "boolean", isIndexed: true },
|
|
2891
|
-
// Composite keys for efficient lookups
|
|
2892
2974
|
{ name: "composite_key", type: "string", isIndexed: true },
|
|
2893
|
-
// namespace:key
|
|
2894
2975
|
{ name: "unique_key", type: "string", isIndexed: true },
|
|
2895
|
-
// namespace:key:value
|
|
2896
|
-
// Timestamps
|
|
2897
2976
|
{ name: "created_at", type: "number", isIndexed: true },
|
|
2898
2977
|
{ name: "updated_at", type: "number" },
|
|
2899
|
-
// Vector embeddings for semantic search
|
|
2900
2978
|
{ name: "embedding", type: "string", isOptional: true },
|
|
2901
|
-
// JSON stringified number[]
|
|
2902
2979
|
{ name: "embedding_model", type: "string", isOptional: true },
|
|
2903
|
-
// Soft delete flag
|
|
2904
2980
|
{ name: "is_deleted", type: "boolean", isIndexed: true }
|
|
2905
2981
|
]
|
|
2982
|
+
}),
|
|
2983
|
+
// Settings storage tables
|
|
2984
|
+
tableSchema3({
|
|
2985
|
+
name: "modelPreferences",
|
|
2986
|
+
columns: [
|
|
2987
|
+
{ name: "wallet_address", type: "string", isIndexed: true },
|
|
2988
|
+
{ name: "models", type: "string", isOptional: true }
|
|
2989
|
+
]
|
|
2906
2990
|
})
|
|
2907
2991
|
]
|
|
2908
2992
|
});
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
/** Confidence score (0-1) */
|
|
2934
|
-
get confidence() {
|
|
2935
|
-
return this._getRaw("confidence");
|
|
2936
|
-
}
|
|
2937
|
-
/** Whether this memory contains PII */
|
|
2938
|
-
get pii() {
|
|
2939
|
-
return this._getRaw("pii");
|
|
2940
|
-
}
|
|
2941
|
-
/** Composite key (namespace:key) for efficient lookups */
|
|
2942
|
-
get compositeKey() {
|
|
2943
|
-
return this._getRaw("composite_key");
|
|
2944
|
-
}
|
|
2945
|
-
/** Unique key (namespace:key:value) for deduplication */
|
|
2946
|
-
get uniqueKey() {
|
|
2947
|
-
return this._getRaw("unique_key");
|
|
2948
|
-
}
|
|
2949
|
-
/** Created timestamp */
|
|
2950
|
-
get createdAt() {
|
|
2951
|
-
return new Date(this._getRaw("created_at"));
|
|
2952
|
-
}
|
|
2953
|
-
/** Updated timestamp */
|
|
2954
|
-
get updatedAt() {
|
|
2955
|
-
return new Date(this._getRaw("updated_at"));
|
|
2956
|
-
}
|
|
2957
|
-
/** Embedding vector for semantic search */
|
|
2958
|
-
get embedding() {
|
|
2959
|
-
const raw = this._getRaw("embedding");
|
|
2960
|
-
if (!raw) return void 0;
|
|
2961
|
-
try {
|
|
2962
|
-
return JSON.parse(raw);
|
|
2963
|
-
} catch {
|
|
2964
|
-
return void 0;
|
|
2993
|
+
var sdkMigrations = schemaMigrations2({
|
|
2994
|
+
migrations: [
|
|
2995
|
+
// v2 -> v3: Added was_stopped column to history
|
|
2996
|
+
{
|
|
2997
|
+
toVersion: 3,
|
|
2998
|
+
steps: [
|
|
2999
|
+
addColumns2({
|
|
3000
|
+
table: "history",
|
|
3001
|
+
columns: [{ name: "was_stopped", type: "boolean", isOptional: true }]
|
|
3002
|
+
})
|
|
3003
|
+
]
|
|
3004
|
+
},
|
|
3005
|
+
// v3 -> v4: Added settings storage (modelPreferences table)
|
|
3006
|
+
{
|
|
3007
|
+
toVersion: 4,
|
|
3008
|
+
steps: [
|
|
3009
|
+
createTable({
|
|
3010
|
+
name: "modelPreferences",
|
|
3011
|
+
columns: [
|
|
3012
|
+
{ name: "wallet_address", type: "string", isIndexed: true },
|
|
3013
|
+
{ name: "models", type: "string", isOptional: true }
|
|
3014
|
+
]
|
|
3015
|
+
})
|
|
3016
|
+
]
|
|
2965
3017
|
}
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
return this._getRaw("is_deleted");
|
|
2975
|
-
}
|
|
2976
|
-
};
|
|
2977
|
-
Memory.table = "memories";
|
|
3018
|
+
]
|
|
3019
|
+
});
|
|
3020
|
+
var sdkModelClasses = [
|
|
3021
|
+
Message,
|
|
3022
|
+
Conversation,
|
|
3023
|
+
Memory,
|
|
3024
|
+
ModelPreference
|
|
3025
|
+
];
|
|
2978
3026
|
export {
|
|
2979
3027
|
Conversation as ChatConversation,
|
|
2980
3028
|
Message as ChatMessage,
|
|
@@ -2985,6 +3033,9 @@ export {
|
|
|
2985
3033
|
generateConversationId,
|
|
2986
3034
|
generateUniqueKey,
|
|
2987
3035
|
memoryStorageSchema,
|
|
3036
|
+
sdkMigrations,
|
|
3037
|
+
sdkModelClasses,
|
|
3038
|
+
sdkSchema,
|
|
2988
3039
|
useChat,
|
|
2989
3040
|
useChatStorage,
|
|
2990
3041
|
useImageGeneration,
|