@reverbia/sdk 1.0.0-next.20251219092050 → 1.0.0-next.20251219162520
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 +71 -8
- package/dist/expo/index.d.mts +6 -0
- package/dist/expo/index.d.ts +6 -0
- package/dist/expo/index.mjs +71 -8
- package/dist/react/index.cjs +833 -36
- package/dist/react/index.d.mts +353 -8
- package/dist/react/index.d.ts +353 -8
- package/dist/react/index.mjs +833 -36
- package/package.json +1 -1
package/dist/expo/index.cjs
CHANGED
|
@@ -337,7 +337,7 @@ var import_react2 = require("react");
|
|
|
337
337
|
var import_watermelondb = require("@nozbe/watermelondb");
|
|
338
338
|
var import_migrations = require("@nozbe/watermelondb/Schema/migrations");
|
|
339
339
|
var chatStorageSchema = (0, import_watermelondb.appSchema)({
|
|
340
|
-
version:
|
|
340
|
+
version: 3,
|
|
341
341
|
tables: [
|
|
342
342
|
(0, import_watermelondb.tableSchema)({
|
|
343
343
|
name: "history",
|
|
@@ -355,7 +355,8 @@ var chatStorageSchema = (0, import_watermelondb.appSchema)({
|
|
|
355
355
|
{ name: "usage", type: "string", isOptional: true },
|
|
356
356
|
{ name: "sources", type: "string", isOptional: true },
|
|
357
357
|
{ name: "response_duration", type: "number", isOptional: true },
|
|
358
|
-
{ name: "was_stopped", type: "boolean", isOptional: true }
|
|
358
|
+
{ name: "was_stopped", type: "boolean", isOptional: true },
|
|
359
|
+
{ name: "error", type: "string", isOptional: true }
|
|
359
360
|
]
|
|
360
361
|
}),
|
|
361
362
|
(0, import_watermelondb.tableSchema)({
|
|
@@ -380,6 +381,15 @@ var chatStorageMigrations = (0, import_migrations.schemaMigrations)({
|
|
|
380
381
|
columns: [{ name: "was_stopped", type: "boolean", isOptional: true }]
|
|
381
382
|
})
|
|
382
383
|
]
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
toVersion: 3,
|
|
387
|
+
steps: [
|
|
388
|
+
(0, import_migrations.addColumns)({
|
|
389
|
+
table: "history",
|
|
390
|
+
columns: [{ name: "error", type: "string", isOptional: true }]
|
|
391
|
+
})
|
|
392
|
+
]
|
|
383
393
|
}
|
|
384
394
|
]
|
|
385
395
|
});
|
|
@@ -435,6 +445,9 @@ __decorateClass([
|
|
|
435
445
|
__decorateClass([
|
|
436
446
|
(0, import_decorators.field)("was_stopped")
|
|
437
447
|
], Message.prototype, "wasStopped", 2);
|
|
448
|
+
__decorateClass([
|
|
449
|
+
(0, import_decorators.text)("error")
|
|
450
|
+
], Message.prototype, "error", 2);
|
|
438
451
|
var Conversation = class extends import_watermelondb2.Model {
|
|
439
452
|
};
|
|
440
453
|
Conversation.table = "conversations";
|
|
@@ -489,7 +502,8 @@ function messageToStored(message) {
|
|
|
489
502
|
usage: message.usage,
|
|
490
503
|
sources: message.sources,
|
|
491
504
|
responseDuration: message.responseDuration,
|
|
492
|
-
wasStopped: message.wasStopped
|
|
505
|
+
wasStopped: message.wasStopped,
|
|
506
|
+
error: message.error
|
|
493
507
|
};
|
|
494
508
|
}
|
|
495
509
|
function conversationToStored(conversation) {
|
|
@@ -579,10 +593,25 @@ async function createMessageOp(ctx, opts) {
|
|
|
579
593
|
if (opts.vector) msg._setRaw("vector", JSON.stringify(opts.vector));
|
|
580
594
|
if (opts.embeddingModel) msg._setRaw("embedding_model", opts.embeddingModel);
|
|
581
595
|
if (opts.wasStopped) msg._setRaw("was_stopped", opts.wasStopped);
|
|
596
|
+
if (opts.error) msg._setRaw("error", opts.error);
|
|
582
597
|
});
|
|
583
598
|
});
|
|
584
599
|
return messageToStored(created);
|
|
585
600
|
}
|
|
601
|
+
async function updateMessageErrorOp(ctx, uniqueId, error) {
|
|
602
|
+
let message;
|
|
603
|
+
try {
|
|
604
|
+
message = await ctx.messagesCollection.find(uniqueId);
|
|
605
|
+
} catch {
|
|
606
|
+
return null;
|
|
607
|
+
}
|
|
608
|
+
await ctx.database.write(async () => {
|
|
609
|
+
await message.update((msg) => {
|
|
610
|
+
msg._setRaw("error", error);
|
|
611
|
+
});
|
|
612
|
+
});
|
|
613
|
+
return messageToStored(message);
|
|
614
|
+
}
|
|
586
615
|
|
|
587
616
|
// src/expo/useChatStorage.ts
|
|
588
617
|
function storedToLlmapiMessage(stored) {
|
|
@@ -748,7 +777,8 @@ function useChatStorage(options) {
|
|
|
748
777
|
let messagesToSend = [];
|
|
749
778
|
if (includeHistory && !providedMessages) {
|
|
750
779
|
const storedMessages = await getMessages(convId);
|
|
751
|
-
const
|
|
780
|
+
const validMessages = storedMessages.filter((msg) => !msg.error);
|
|
781
|
+
const limitedMessages = validMessages.slice(-maxHistoryMessages);
|
|
752
782
|
messagesToSend = limitedMessages.map(storedToLlmapiMessage);
|
|
753
783
|
} else if (providedMessages) {
|
|
754
784
|
messagesToSend = providedMessages;
|
|
@@ -838,12 +868,34 @@ function useChatStorage(options) {
|
|
|
838
868
|
assistantMessage: storedAssistantMessage2
|
|
839
869
|
};
|
|
840
870
|
} catch {
|
|
871
|
+
return {
|
|
872
|
+
data: null,
|
|
873
|
+
error: "Request aborted",
|
|
874
|
+
userMessage: storedUserMessage
|
|
875
|
+
};
|
|
841
876
|
}
|
|
842
877
|
}
|
|
878
|
+
const errorMessage = result.error || "No response data received";
|
|
879
|
+
try {
|
|
880
|
+
await updateMessageErrorOp(
|
|
881
|
+
storageCtx,
|
|
882
|
+
storedUserMessage.uniqueId,
|
|
883
|
+
errorMessage
|
|
884
|
+
);
|
|
885
|
+
await createMessageOp(storageCtx, {
|
|
886
|
+
conversationId: convId,
|
|
887
|
+
role: "assistant",
|
|
888
|
+
content: "",
|
|
889
|
+
model: model || "",
|
|
890
|
+
responseDuration,
|
|
891
|
+
error: errorMessage
|
|
892
|
+
});
|
|
893
|
+
} catch {
|
|
894
|
+
}
|
|
843
895
|
return {
|
|
844
896
|
data: null,
|
|
845
|
-
error:
|
|
846
|
-
userMessage: storedUserMessage
|
|
897
|
+
error: errorMessage,
|
|
898
|
+
userMessage: { ...storedUserMessage, error: errorMessage }
|
|
847
899
|
};
|
|
848
900
|
}
|
|
849
901
|
const responseData = result.data;
|
|
@@ -2959,7 +3011,7 @@ __decorateClass([
|
|
|
2959
3011
|
], ModelPreference.prototype, "models", 2);
|
|
2960
3012
|
|
|
2961
3013
|
// src/lib/db/schema.ts
|
|
2962
|
-
var SDK_SCHEMA_VERSION =
|
|
3014
|
+
var SDK_SCHEMA_VERSION = 5;
|
|
2963
3015
|
var sdkSchema = (0, import_watermelondb8.appSchema)({
|
|
2964
3016
|
version: SDK_SCHEMA_VERSION,
|
|
2965
3017
|
tables: [
|
|
@@ -2980,7 +3032,8 @@ var sdkSchema = (0, import_watermelondb8.appSchema)({
|
|
|
2980
3032
|
{ name: "usage", type: "string", isOptional: true },
|
|
2981
3033
|
{ name: "sources", type: "string", isOptional: true },
|
|
2982
3034
|
{ name: "response_duration", type: "number", isOptional: true },
|
|
2983
|
-
{ name: "was_stopped", type: "boolean", isOptional: true }
|
|
3035
|
+
{ name: "was_stopped", type: "boolean", isOptional: true },
|
|
3036
|
+
{ name: "error", type: "string", isOptional: true }
|
|
2984
3037
|
]
|
|
2985
3038
|
}),
|
|
2986
3039
|
(0, import_watermelondb8.tableSchema)({
|
|
@@ -3047,6 +3100,16 @@ var sdkMigrations = (0, import_migrations2.schemaMigrations)({
|
|
|
3047
3100
|
]
|
|
3048
3101
|
})
|
|
3049
3102
|
]
|
|
3103
|
+
},
|
|
3104
|
+
// v4 -> v5: Added error column to history for error persistence
|
|
3105
|
+
{
|
|
3106
|
+
toVersion: 5,
|
|
3107
|
+
steps: [
|
|
3108
|
+
(0, import_migrations2.addColumns)({
|
|
3109
|
+
table: "history",
|
|
3110
|
+
columns: [{ name: "error", type: "string", isOptional: true }]
|
|
3111
|
+
})
|
|
3112
|
+
]
|
|
3050
3113
|
}
|
|
3051
3114
|
]
|
|
3052
3115
|
});
|
package/dist/expo/index.d.mts
CHANGED
|
@@ -457,6 +457,8 @@ interface StoredMessage {
|
|
|
457
457
|
sources?: SearchSource[];
|
|
458
458
|
responseDuration?: number;
|
|
459
459
|
wasStopped?: boolean;
|
|
460
|
+
/** If set, indicates the message failed with this error */
|
|
461
|
+
error?: string;
|
|
460
462
|
}
|
|
461
463
|
interface StoredConversation {
|
|
462
464
|
uniqueId: string;
|
|
@@ -481,6 +483,8 @@ interface CreateMessageOptions {
|
|
|
481
483
|
vector?: number[];
|
|
482
484
|
embeddingModel?: string;
|
|
483
485
|
wasStopped?: boolean;
|
|
486
|
+
/** If set, indicates the message failed with this error */
|
|
487
|
+
error?: string;
|
|
484
488
|
}
|
|
485
489
|
interface CreateConversationOptions {
|
|
486
490
|
conversationId?: string;
|
|
@@ -555,6 +559,7 @@ declare class Message extends Model {
|
|
|
555
559
|
sources?: SearchSource[];
|
|
556
560
|
responseDuration?: number;
|
|
557
561
|
wasStopped?: boolean;
|
|
562
|
+
error?: string;
|
|
558
563
|
}
|
|
559
564
|
declare class Conversation extends Model {
|
|
560
565
|
static table: string;
|
|
@@ -918,6 +923,7 @@ declare const sdkSchema: Readonly<{
|
|
|
918
923
|
* Migration history:
|
|
919
924
|
* - v2 → v3: Added `was_stopped` column to history table
|
|
920
925
|
* - v3 → v4: Added `modelPreferences` table for settings storage
|
|
926
|
+
* - v4 → v5: Added `error` column to history table for error persistence
|
|
921
927
|
*/
|
|
922
928
|
declare const sdkMigrations: Readonly<{
|
|
923
929
|
validated: true;
|
package/dist/expo/index.d.ts
CHANGED
|
@@ -457,6 +457,8 @@ interface StoredMessage {
|
|
|
457
457
|
sources?: SearchSource[];
|
|
458
458
|
responseDuration?: number;
|
|
459
459
|
wasStopped?: boolean;
|
|
460
|
+
/** If set, indicates the message failed with this error */
|
|
461
|
+
error?: string;
|
|
460
462
|
}
|
|
461
463
|
interface StoredConversation {
|
|
462
464
|
uniqueId: string;
|
|
@@ -481,6 +483,8 @@ interface CreateMessageOptions {
|
|
|
481
483
|
vector?: number[];
|
|
482
484
|
embeddingModel?: string;
|
|
483
485
|
wasStopped?: boolean;
|
|
486
|
+
/** If set, indicates the message failed with this error */
|
|
487
|
+
error?: string;
|
|
484
488
|
}
|
|
485
489
|
interface CreateConversationOptions {
|
|
486
490
|
conversationId?: string;
|
|
@@ -555,6 +559,7 @@ declare class Message extends Model {
|
|
|
555
559
|
sources?: SearchSource[];
|
|
556
560
|
responseDuration?: number;
|
|
557
561
|
wasStopped?: boolean;
|
|
562
|
+
error?: string;
|
|
558
563
|
}
|
|
559
564
|
declare class Conversation extends Model {
|
|
560
565
|
static table: string;
|
|
@@ -918,6 +923,7 @@ declare const sdkSchema: Readonly<{
|
|
|
918
923
|
* Migration history:
|
|
919
924
|
* - v2 → v3: Added `was_stopped` column to history table
|
|
920
925
|
* - v3 → v4: Added `modelPreferences` table for settings storage
|
|
926
|
+
* - v4 → v5: Added `error` column to history table for error persistence
|
|
921
927
|
*/
|
|
922
928
|
declare const sdkMigrations: Readonly<{
|
|
923
929
|
validated: true;
|
package/dist/expo/index.mjs
CHANGED
|
@@ -301,7 +301,7 @@ import {
|
|
|
301
301
|
addColumns
|
|
302
302
|
} from "@nozbe/watermelondb/Schema/migrations";
|
|
303
303
|
var chatStorageSchema = appSchema({
|
|
304
|
-
version:
|
|
304
|
+
version: 3,
|
|
305
305
|
tables: [
|
|
306
306
|
tableSchema({
|
|
307
307
|
name: "history",
|
|
@@ -319,7 +319,8 @@ var chatStorageSchema = appSchema({
|
|
|
319
319
|
{ name: "usage", type: "string", isOptional: true },
|
|
320
320
|
{ name: "sources", type: "string", isOptional: true },
|
|
321
321
|
{ name: "response_duration", type: "number", isOptional: true },
|
|
322
|
-
{ name: "was_stopped", type: "boolean", isOptional: true }
|
|
322
|
+
{ name: "was_stopped", type: "boolean", isOptional: true },
|
|
323
|
+
{ name: "error", type: "string", isOptional: true }
|
|
323
324
|
]
|
|
324
325
|
}),
|
|
325
326
|
tableSchema({
|
|
@@ -344,6 +345,15 @@ var chatStorageMigrations = schemaMigrations({
|
|
|
344
345
|
columns: [{ name: "was_stopped", type: "boolean", isOptional: true }]
|
|
345
346
|
})
|
|
346
347
|
]
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
toVersion: 3,
|
|
351
|
+
steps: [
|
|
352
|
+
addColumns({
|
|
353
|
+
table: "history",
|
|
354
|
+
columns: [{ name: "error", type: "string", isOptional: true }]
|
|
355
|
+
})
|
|
356
|
+
]
|
|
347
357
|
}
|
|
348
358
|
]
|
|
349
359
|
});
|
|
@@ -399,6 +409,9 @@ __decorateClass([
|
|
|
399
409
|
__decorateClass([
|
|
400
410
|
field("was_stopped")
|
|
401
411
|
], Message.prototype, "wasStopped", 2);
|
|
412
|
+
__decorateClass([
|
|
413
|
+
text("error")
|
|
414
|
+
], Message.prototype, "error", 2);
|
|
402
415
|
var Conversation = class extends Model {
|
|
403
416
|
};
|
|
404
417
|
Conversation.table = "conversations";
|
|
@@ -453,7 +466,8 @@ function messageToStored(message) {
|
|
|
453
466
|
usage: message.usage,
|
|
454
467
|
sources: message.sources,
|
|
455
468
|
responseDuration: message.responseDuration,
|
|
456
|
-
wasStopped: message.wasStopped
|
|
469
|
+
wasStopped: message.wasStopped,
|
|
470
|
+
error: message.error
|
|
457
471
|
};
|
|
458
472
|
}
|
|
459
473
|
function conversationToStored(conversation) {
|
|
@@ -543,10 +557,25 @@ async function createMessageOp(ctx, opts) {
|
|
|
543
557
|
if (opts.vector) msg._setRaw("vector", JSON.stringify(opts.vector));
|
|
544
558
|
if (opts.embeddingModel) msg._setRaw("embedding_model", opts.embeddingModel);
|
|
545
559
|
if (opts.wasStopped) msg._setRaw("was_stopped", opts.wasStopped);
|
|
560
|
+
if (opts.error) msg._setRaw("error", opts.error);
|
|
546
561
|
});
|
|
547
562
|
});
|
|
548
563
|
return messageToStored(created);
|
|
549
564
|
}
|
|
565
|
+
async function updateMessageErrorOp(ctx, uniqueId, error) {
|
|
566
|
+
let message;
|
|
567
|
+
try {
|
|
568
|
+
message = await ctx.messagesCollection.find(uniqueId);
|
|
569
|
+
} catch {
|
|
570
|
+
return null;
|
|
571
|
+
}
|
|
572
|
+
await ctx.database.write(async () => {
|
|
573
|
+
await message.update((msg) => {
|
|
574
|
+
msg._setRaw("error", error);
|
|
575
|
+
});
|
|
576
|
+
});
|
|
577
|
+
return messageToStored(message);
|
|
578
|
+
}
|
|
550
579
|
|
|
551
580
|
// src/expo/useChatStorage.ts
|
|
552
581
|
function storedToLlmapiMessage(stored) {
|
|
@@ -712,7 +741,8 @@ function useChatStorage(options) {
|
|
|
712
741
|
let messagesToSend = [];
|
|
713
742
|
if (includeHistory && !providedMessages) {
|
|
714
743
|
const storedMessages = await getMessages(convId);
|
|
715
|
-
const
|
|
744
|
+
const validMessages = storedMessages.filter((msg) => !msg.error);
|
|
745
|
+
const limitedMessages = validMessages.slice(-maxHistoryMessages);
|
|
716
746
|
messagesToSend = limitedMessages.map(storedToLlmapiMessage);
|
|
717
747
|
} else if (providedMessages) {
|
|
718
748
|
messagesToSend = providedMessages;
|
|
@@ -802,12 +832,34 @@ function useChatStorage(options) {
|
|
|
802
832
|
assistantMessage: storedAssistantMessage2
|
|
803
833
|
};
|
|
804
834
|
} catch {
|
|
835
|
+
return {
|
|
836
|
+
data: null,
|
|
837
|
+
error: "Request aborted",
|
|
838
|
+
userMessage: storedUserMessage
|
|
839
|
+
};
|
|
805
840
|
}
|
|
806
841
|
}
|
|
842
|
+
const errorMessage = result.error || "No response data received";
|
|
843
|
+
try {
|
|
844
|
+
await updateMessageErrorOp(
|
|
845
|
+
storageCtx,
|
|
846
|
+
storedUserMessage.uniqueId,
|
|
847
|
+
errorMessage
|
|
848
|
+
);
|
|
849
|
+
await createMessageOp(storageCtx, {
|
|
850
|
+
conversationId: convId,
|
|
851
|
+
role: "assistant",
|
|
852
|
+
content: "",
|
|
853
|
+
model: model || "",
|
|
854
|
+
responseDuration,
|
|
855
|
+
error: errorMessage
|
|
856
|
+
});
|
|
857
|
+
} catch {
|
|
858
|
+
}
|
|
807
859
|
return {
|
|
808
860
|
data: null,
|
|
809
|
-
error:
|
|
810
|
-
userMessage: storedUserMessage
|
|
861
|
+
error: errorMessage,
|
|
862
|
+
userMessage: { ...storedUserMessage, error: errorMessage }
|
|
811
863
|
};
|
|
812
864
|
}
|
|
813
865
|
const responseData = result.data;
|
|
@@ -2927,7 +2979,7 @@ __decorateClass([
|
|
|
2927
2979
|
], ModelPreference.prototype, "models", 2);
|
|
2928
2980
|
|
|
2929
2981
|
// src/lib/db/schema.ts
|
|
2930
|
-
var SDK_SCHEMA_VERSION =
|
|
2982
|
+
var SDK_SCHEMA_VERSION = 5;
|
|
2931
2983
|
var sdkSchema = appSchema3({
|
|
2932
2984
|
version: SDK_SCHEMA_VERSION,
|
|
2933
2985
|
tables: [
|
|
@@ -2948,7 +3000,8 @@ var sdkSchema = appSchema3({
|
|
|
2948
3000
|
{ name: "usage", type: "string", isOptional: true },
|
|
2949
3001
|
{ name: "sources", type: "string", isOptional: true },
|
|
2950
3002
|
{ name: "response_duration", type: "number", isOptional: true },
|
|
2951
|
-
{ name: "was_stopped", type: "boolean", isOptional: true }
|
|
3003
|
+
{ name: "was_stopped", type: "boolean", isOptional: true },
|
|
3004
|
+
{ name: "error", type: "string", isOptional: true }
|
|
2952
3005
|
]
|
|
2953
3006
|
}),
|
|
2954
3007
|
tableSchema3({
|
|
@@ -3015,6 +3068,16 @@ var sdkMigrations = schemaMigrations2({
|
|
|
3015
3068
|
]
|
|
3016
3069
|
})
|
|
3017
3070
|
]
|
|
3071
|
+
},
|
|
3072
|
+
// v4 -> v5: Added error column to history for error persistence
|
|
3073
|
+
{
|
|
3074
|
+
toVersion: 5,
|
|
3075
|
+
steps: [
|
|
3076
|
+
addColumns2({
|
|
3077
|
+
table: "history",
|
|
3078
|
+
columns: [{ name: "error", type: "string", isOptional: true }]
|
|
3079
|
+
})
|
|
3080
|
+
]
|
|
3018
3081
|
}
|
|
3019
3082
|
]
|
|
3020
3083
|
});
|