@assistant-ui/react 0.5.55 → 0.5.57
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.mts +44 -17
- package/dist/index.d.ts +44 -17
- package/dist/index.js +19 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
@@ -341,9 +341,9 @@ type ExternalStoreAdapterBase<T> = {
|
|
341
341
|
onEdit?: ((message: AppendMessage) => Promise<void>) | undefined;
|
342
342
|
onReload?: ((parentId: string | null) => Promise<void>) | undefined;
|
343
343
|
onCancel?: (() => Promise<void>) | undefined;
|
344
|
-
onNewThread?: (() => Promise<void> | void) | undefined;
|
345
344
|
onAddToolResult?: ((options: AddToolResultOptions) => Promise<void> | void) | undefined;
|
346
|
-
|
345
|
+
onSwitchToThread?: ((threadId: string) => Promise<void> | void) | undefined;
|
346
|
+
onSwitchToNewThread?: (() => Promise<void> | void) | undefined;
|
347
347
|
onSpeak?: ((message: ThreadMessage) => SpeechSynthesisAdapter.Utterance) | undefined;
|
348
348
|
convertMessage?: ExternalStoreMessageConverter<T> | undefined;
|
349
349
|
adapters?: {
|
@@ -603,7 +603,8 @@ type AssistantRuntime = ThreadRuntimeWithSubscribe & {
|
|
603
603
|
/**
|
604
604
|
* @deprecated Use `switchToNewThread` instead. This will be removed in 0.6.0.
|
605
605
|
*/
|
606
|
-
switchToThread
|
606
|
+
switchToThread(threadId: null): void;
|
607
|
+
switchToThread(threadId: string): void;
|
607
608
|
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
608
609
|
};
|
609
610
|
|
@@ -618,9 +619,13 @@ type TextContentPartProviderProps = {
|
|
618
619
|
declare const TextContentPartProvider: FC<PropsWithChildren<TextContentPartProviderProps>>;
|
619
620
|
|
620
621
|
type AssistantActionsState = Readonly<{
|
621
|
-
|
622
|
+
/**
|
623
|
+
* @deprecated Use `switchToNewThread` instead. This will be removed in 0.6.0.
|
624
|
+
*/
|
625
|
+
switchToThread(threadId: null): void;
|
626
|
+
switchToThread(threadId: string): void;
|
627
|
+
switchToNewThread: () => void;
|
622
628
|
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
623
|
-
getRuntime: () => AssistantRuntime;
|
624
629
|
}>;
|
625
630
|
|
626
631
|
type AssistantToolUIsState = Readonly<{
|
@@ -695,43 +700,49 @@ declare const useToolUIsStore: {
|
|
695
700
|
};
|
696
701
|
declare const useAssistantActions: {
|
697
702
|
(): Readonly<{
|
698
|
-
switchToThread
|
703
|
+
switchToThread(threadId: null): void;
|
704
|
+
switchToThread(threadId: string): void;
|
705
|
+
switchToNewThread: () => void;
|
699
706
|
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
700
|
-
getRuntime: () => AssistantRuntime;
|
701
707
|
}>;
|
702
708
|
<TSelected>(selector: (state: Readonly<{
|
703
|
-
switchToThread
|
709
|
+
switchToThread(threadId: null): void;
|
710
|
+
switchToThread(threadId: string): void;
|
711
|
+
switchToNewThread: () => void;
|
704
712
|
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
705
|
-
getRuntime: () => AssistantRuntime;
|
706
713
|
}>) => TSelected): TSelected;
|
707
714
|
(options: {
|
708
715
|
optional: true;
|
709
716
|
}): Readonly<{
|
710
|
-
switchToThread
|
717
|
+
switchToThread(threadId: null): void;
|
718
|
+
switchToThread(threadId: string): void;
|
719
|
+
switchToNewThread: () => void;
|
711
720
|
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
712
|
-
getRuntime: () => AssistantRuntime;
|
713
721
|
}> | null;
|
714
722
|
<TSelected>(options: {
|
715
723
|
optional: true;
|
716
724
|
selector?: (state: Readonly<{
|
717
|
-
switchToThread
|
725
|
+
switchToThread(threadId: null): void;
|
726
|
+
switchToThread(threadId: string): void;
|
727
|
+
switchToNewThread: () => void;
|
718
728
|
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
719
|
-
getRuntime: () => AssistantRuntime;
|
720
729
|
}>) => TSelected;
|
721
730
|
}): TSelected | null;
|
722
731
|
};
|
723
732
|
declare const useAssistantActionsStore: {
|
724
733
|
(): ReadonlyStore<Readonly<{
|
725
|
-
switchToThread
|
734
|
+
switchToThread(threadId: null): void;
|
735
|
+
switchToThread(threadId: string): void;
|
736
|
+
switchToNewThread: () => void;
|
726
737
|
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
727
|
-
getRuntime: () => AssistantRuntime;
|
728
738
|
}>>;
|
729
739
|
(options: {
|
730
740
|
optional: true;
|
731
741
|
}): ReadonlyStore<Readonly<{
|
732
|
-
switchToThread
|
742
|
+
switchToThread(threadId: null): void;
|
743
|
+
switchToThread(threadId: string): void;
|
744
|
+
switchToNewThread: () => void;
|
733
745
|
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
734
|
-
getRuntime: () => AssistantRuntime;
|
735
746
|
}>> | null;
|
736
747
|
};
|
737
748
|
|
@@ -910,6 +921,7 @@ declare const useThreadComposer: {
|
|
910
921
|
type: "thread";
|
911
922
|
value: string;
|
912
923
|
setValue: (value: string) => void;
|
924
|
+
attachmentAccept: string;
|
913
925
|
attachments: readonly ThreadComposerAttachment[];
|
914
926
|
addAttachment: (file: File) => void;
|
915
927
|
removeAttachment: (attachmentId: string) => void;
|
@@ -928,6 +940,7 @@ declare const useThreadComposer: {
|
|
928
940
|
type: "thread";
|
929
941
|
value: string;
|
930
942
|
setValue: (value: string) => void;
|
943
|
+
attachmentAccept: string;
|
931
944
|
attachments: readonly ThreadComposerAttachment[];
|
932
945
|
addAttachment: (file: File) => void;
|
933
946
|
removeAttachment: (attachmentId: string) => void;
|
@@ -948,6 +961,7 @@ declare const useThreadComposer: {
|
|
948
961
|
type: "thread";
|
949
962
|
value: string;
|
950
963
|
setValue: (value: string) => void;
|
964
|
+
attachmentAccept: string;
|
951
965
|
attachments: readonly ThreadComposerAttachment[];
|
952
966
|
addAttachment: (file: File) => void;
|
953
967
|
removeAttachment: (attachmentId: string) => void;
|
@@ -968,6 +982,7 @@ declare const useThreadComposer: {
|
|
968
982
|
type: "thread";
|
969
983
|
value: string;
|
970
984
|
setValue: (value: string) => void;
|
985
|
+
attachmentAccept: string;
|
971
986
|
attachments: readonly ThreadComposerAttachment[];
|
972
987
|
addAttachment: (file: File) => void;
|
973
988
|
removeAttachment: (attachmentId: string) => void;
|
@@ -989,6 +1004,7 @@ declare const useThreadComposerStore: {
|
|
989
1004
|
type: "thread";
|
990
1005
|
value: string;
|
991
1006
|
setValue: (value: string) => void;
|
1007
|
+
attachmentAccept: string;
|
992
1008
|
attachments: readonly ThreadComposerAttachment[];
|
993
1009
|
addAttachment: (file: File) => void;
|
994
1010
|
removeAttachment: (attachmentId: string) => void;
|
@@ -1009,6 +1025,7 @@ declare const useThreadComposerStore: {
|
|
1009
1025
|
type: "thread";
|
1010
1026
|
value: string;
|
1011
1027
|
setValue: (value: string) => void;
|
1028
|
+
attachmentAccept: string;
|
1012
1029
|
attachments: readonly ThreadComposerAttachment[];
|
1013
1030
|
addAttachment: (file: File) => void;
|
1014
1031
|
removeAttachment: (attachmentId: string) => void;
|
@@ -1383,6 +1400,7 @@ declare const useComposer: {
|
|
1383
1400
|
type: "thread";
|
1384
1401
|
value: string;
|
1385
1402
|
setValue: (value: string) => void;
|
1403
|
+
attachmentAccept: string;
|
1386
1404
|
attachments: readonly ThreadComposerAttachment[];
|
1387
1405
|
addAttachment: (file: File) => void;
|
1388
1406
|
removeAttachment: (attachmentId: string) => void;
|
@@ -1413,6 +1431,7 @@ declare const useComposer: {
|
|
1413
1431
|
type: "thread";
|
1414
1432
|
value: string;
|
1415
1433
|
setValue: (value: string) => void;
|
1434
|
+
attachmentAccept: string;
|
1416
1435
|
attachments: readonly ThreadComposerAttachment[];
|
1417
1436
|
addAttachment: (file: File) => void;
|
1418
1437
|
removeAttachment: (attachmentId: string) => void;
|
@@ -1445,6 +1464,7 @@ declare const useComposer: {
|
|
1445
1464
|
type: "thread";
|
1446
1465
|
value: string;
|
1447
1466
|
setValue: (value: string) => void;
|
1467
|
+
attachmentAccept: string;
|
1448
1468
|
attachments: readonly ThreadComposerAttachment[];
|
1449
1469
|
addAttachment: (file: File) => void;
|
1450
1470
|
removeAttachment: (attachmentId: string) => void;
|
@@ -1477,6 +1497,7 @@ declare const useComposer: {
|
|
1477
1497
|
type: "thread";
|
1478
1498
|
value: string;
|
1479
1499
|
setValue: (value: string) => void;
|
1500
|
+
attachmentAccept: string;
|
1480
1501
|
attachments: readonly ThreadComposerAttachment[];
|
1481
1502
|
addAttachment: (file: File) => void;
|
1482
1503
|
removeAttachment: (attachmentId: string) => void;
|
@@ -1510,6 +1531,7 @@ declare const useComposerStore: {
|
|
1510
1531
|
type: "thread";
|
1511
1532
|
value: string;
|
1512
1533
|
setValue: (value: string) => void;
|
1534
|
+
attachmentAccept: string;
|
1513
1535
|
attachments: readonly ThreadComposerAttachment[];
|
1514
1536
|
addAttachment: (file: File) => void;
|
1515
1537
|
removeAttachment: (attachmentId: string) => void;
|
@@ -1542,6 +1564,7 @@ declare const useComposerStore: {
|
|
1542
1564
|
type: "thread";
|
1543
1565
|
value: string;
|
1544
1566
|
setValue: (value: string) => void;
|
1567
|
+
attachmentAccept: string;
|
1545
1568
|
attachments: readonly ThreadComposerAttachment[];
|
1546
1569
|
addAttachment: (file: File) => void;
|
1547
1570
|
removeAttachment: (attachmentId: string) => void;
|
@@ -1564,6 +1587,7 @@ type ThreadComposerState = Readonly<{
|
|
1564
1587
|
value: string;
|
1565
1588
|
/** @deprecated Use `setText` instead. */
|
1566
1589
|
setValue: (value: string) => void;
|
1590
|
+
attachmentAccept: string;
|
1567
1591
|
attachments: readonly ThreadComposerAttachment[];
|
1568
1592
|
addAttachment: (file: File) => void;
|
1569
1593
|
removeAttachment: (attachmentId: string) => void;
|
@@ -1587,6 +1611,9 @@ type CreateAppendMessage = string | {
|
|
1587
1611
|
};
|
1588
1612
|
declare const useAppendMessage: () => (message: CreateAppendMessage) => void;
|
1589
1613
|
|
1614
|
+
/**
|
1615
|
+
* @deprecated Use `useRuntimeActions().switchToNewThread()` instead. This will be removed in 0.6.0.
|
1616
|
+
*/
|
1590
1617
|
declare const useSwitchToNewThread: () => () => void;
|
1591
1618
|
|
1592
1619
|
type AssistantToolProps<TArgs extends Record<string, unknown>, TResult> = Tool<TArgs, TResult> & {
|
package/dist/index.d.ts
CHANGED
@@ -341,9 +341,9 @@ type ExternalStoreAdapterBase<T> = {
|
|
341
341
|
onEdit?: ((message: AppendMessage) => Promise<void>) | undefined;
|
342
342
|
onReload?: ((parentId: string | null) => Promise<void>) | undefined;
|
343
343
|
onCancel?: (() => Promise<void>) | undefined;
|
344
|
-
onNewThread?: (() => Promise<void> | void) | undefined;
|
345
344
|
onAddToolResult?: ((options: AddToolResultOptions) => Promise<void> | void) | undefined;
|
346
|
-
|
345
|
+
onSwitchToThread?: ((threadId: string) => Promise<void> | void) | undefined;
|
346
|
+
onSwitchToNewThread?: (() => Promise<void> | void) | undefined;
|
347
347
|
onSpeak?: ((message: ThreadMessage) => SpeechSynthesisAdapter.Utterance) | undefined;
|
348
348
|
convertMessage?: ExternalStoreMessageConverter<T> | undefined;
|
349
349
|
adapters?: {
|
@@ -603,7 +603,8 @@ type AssistantRuntime = ThreadRuntimeWithSubscribe & {
|
|
603
603
|
/**
|
604
604
|
* @deprecated Use `switchToNewThread` instead. This will be removed in 0.6.0.
|
605
605
|
*/
|
606
|
-
switchToThread
|
606
|
+
switchToThread(threadId: null): void;
|
607
|
+
switchToThread(threadId: string): void;
|
607
608
|
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
608
609
|
};
|
609
610
|
|
@@ -618,9 +619,13 @@ type TextContentPartProviderProps = {
|
|
618
619
|
declare const TextContentPartProvider: FC<PropsWithChildren<TextContentPartProviderProps>>;
|
619
620
|
|
620
621
|
type AssistantActionsState = Readonly<{
|
621
|
-
|
622
|
+
/**
|
623
|
+
* @deprecated Use `switchToNewThread` instead. This will be removed in 0.6.0.
|
624
|
+
*/
|
625
|
+
switchToThread(threadId: null): void;
|
626
|
+
switchToThread(threadId: string): void;
|
627
|
+
switchToNewThread: () => void;
|
622
628
|
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
623
|
-
getRuntime: () => AssistantRuntime;
|
624
629
|
}>;
|
625
630
|
|
626
631
|
type AssistantToolUIsState = Readonly<{
|
@@ -695,43 +700,49 @@ declare const useToolUIsStore: {
|
|
695
700
|
};
|
696
701
|
declare const useAssistantActions: {
|
697
702
|
(): Readonly<{
|
698
|
-
switchToThread
|
703
|
+
switchToThread(threadId: null): void;
|
704
|
+
switchToThread(threadId: string): void;
|
705
|
+
switchToNewThread: () => void;
|
699
706
|
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
700
|
-
getRuntime: () => AssistantRuntime;
|
701
707
|
}>;
|
702
708
|
<TSelected>(selector: (state: Readonly<{
|
703
|
-
switchToThread
|
709
|
+
switchToThread(threadId: null): void;
|
710
|
+
switchToThread(threadId: string): void;
|
711
|
+
switchToNewThread: () => void;
|
704
712
|
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
705
|
-
getRuntime: () => AssistantRuntime;
|
706
713
|
}>) => TSelected): TSelected;
|
707
714
|
(options: {
|
708
715
|
optional: true;
|
709
716
|
}): Readonly<{
|
710
|
-
switchToThread
|
717
|
+
switchToThread(threadId: null): void;
|
718
|
+
switchToThread(threadId: string): void;
|
719
|
+
switchToNewThread: () => void;
|
711
720
|
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
712
|
-
getRuntime: () => AssistantRuntime;
|
713
721
|
}> | null;
|
714
722
|
<TSelected>(options: {
|
715
723
|
optional: true;
|
716
724
|
selector?: (state: Readonly<{
|
717
|
-
switchToThread
|
725
|
+
switchToThread(threadId: null): void;
|
726
|
+
switchToThread(threadId: string): void;
|
727
|
+
switchToNewThread: () => void;
|
718
728
|
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
719
|
-
getRuntime: () => AssistantRuntime;
|
720
729
|
}>) => TSelected;
|
721
730
|
}): TSelected | null;
|
722
731
|
};
|
723
732
|
declare const useAssistantActionsStore: {
|
724
733
|
(): ReadonlyStore<Readonly<{
|
725
|
-
switchToThread
|
734
|
+
switchToThread(threadId: null): void;
|
735
|
+
switchToThread(threadId: string): void;
|
736
|
+
switchToNewThread: () => void;
|
726
737
|
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
727
|
-
getRuntime: () => AssistantRuntime;
|
728
738
|
}>>;
|
729
739
|
(options: {
|
730
740
|
optional: true;
|
731
741
|
}): ReadonlyStore<Readonly<{
|
732
|
-
switchToThread
|
742
|
+
switchToThread(threadId: null): void;
|
743
|
+
switchToThread(threadId: string): void;
|
744
|
+
switchToNewThread: () => void;
|
733
745
|
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
734
|
-
getRuntime: () => AssistantRuntime;
|
735
746
|
}>> | null;
|
736
747
|
};
|
737
748
|
|
@@ -910,6 +921,7 @@ declare const useThreadComposer: {
|
|
910
921
|
type: "thread";
|
911
922
|
value: string;
|
912
923
|
setValue: (value: string) => void;
|
924
|
+
attachmentAccept: string;
|
913
925
|
attachments: readonly ThreadComposerAttachment[];
|
914
926
|
addAttachment: (file: File) => void;
|
915
927
|
removeAttachment: (attachmentId: string) => void;
|
@@ -928,6 +940,7 @@ declare const useThreadComposer: {
|
|
928
940
|
type: "thread";
|
929
941
|
value: string;
|
930
942
|
setValue: (value: string) => void;
|
943
|
+
attachmentAccept: string;
|
931
944
|
attachments: readonly ThreadComposerAttachment[];
|
932
945
|
addAttachment: (file: File) => void;
|
933
946
|
removeAttachment: (attachmentId: string) => void;
|
@@ -948,6 +961,7 @@ declare const useThreadComposer: {
|
|
948
961
|
type: "thread";
|
949
962
|
value: string;
|
950
963
|
setValue: (value: string) => void;
|
964
|
+
attachmentAccept: string;
|
951
965
|
attachments: readonly ThreadComposerAttachment[];
|
952
966
|
addAttachment: (file: File) => void;
|
953
967
|
removeAttachment: (attachmentId: string) => void;
|
@@ -968,6 +982,7 @@ declare const useThreadComposer: {
|
|
968
982
|
type: "thread";
|
969
983
|
value: string;
|
970
984
|
setValue: (value: string) => void;
|
985
|
+
attachmentAccept: string;
|
971
986
|
attachments: readonly ThreadComposerAttachment[];
|
972
987
|
addAttachment: (file: File) => void;
|
973
988
|
removeAttachment: (attachmentId: string) => void;
|
@@ -989,6 +1004,7 @@ declare const useThreadComposerStore: {
|
|
989
1004
|
type: "thread";
|
990
1005
|
value: string;
|
991
1006
|
setValue: (value: string) => void;
|
1007
|
+
attachmentAccept: string;
|
992
1008
|
attachments: readonly ThreadComposerAttachment[];
|
993
1009
|
addAttachment: (file: File) => void;
|
994
1010
|
removeAttachment: (attachmentId: string) => void;
|
@@ -1009,6 +1025,7 @@ declare const useThreadComposerStore: {
|
|
1009
1025
|
type: "thread";
|
1010
1026
|
value: string;
|
1011
1027
|
setValue: (value: string) => void;
|
1028
|
+
attachmentAccept: string;
|
1012
1029
|
attachments: readonly ThreadComposerAttachment[];
|
1013
1030
|
addAttachment: (file: File) => void;
|
1014
1031
|
removeAttachment: (attachmentId: string) => void;
|
@@ -1383,6 +1400,7 @@ declare const useComposer: {
|
|
1383
1400
|
type: "thread";
|
1384
1401
|
value: string;
|
1385
1402
|
setValue: (value: string) => void;
|
1403
|
+
attachmentAccept: string;
|
1386
1404
|
attachments: readonly ThreadComposerAttachment[];
|
1387
1405
|
addAttachment: (file: File) => void;
|
1388
1406
|
removeAttachment: (attachmentId: string) => void;
|
@@ -1413,6 +1431,7 @@ declare const useComposer: {
|
|
1413
1431
|
type: "thread";
|
1414
1432
|
value: string;
|
1415
1433
|
setValue: (value: string) => void;
|
1434
|
+
attachmentAccept: string;
|
1416
1435
|
attachments: readonly ThreadComposerAttachment[];
|
1417
1436
|
addAttachment: (file: File) => void;
|
1418
1437
|
removeAttachment: (attachmentId: string) => void;
|
@@ -1445,6 +1464,7 @@ declare const useComposer: {
|
|
1445
1464
|
type: "thread";
|
1446
1465
|
value: string;
|
1447
1466
|
setValue: (value: string) => void;
|
1467
|
+
attachmentAccept: string;
|
1448
1468
|
attachments: readonly ThreadComposerAttachment[];
|
1449
1469
|
addAttachment: (file: File) => void;
|
1450
1470
|
removeAttachment: (attachmentId: string) => void;
|
@@ -1477,6 +1497,7 @@ declare const useComposer: {
|
|
1477
1497
|
type: "thread";
|
1478
1498
|
value: string;
|
1479
1499
|
setValue: (value: string) => void;
|
1500
|
+
attachmentAccept: string;
|
1480
1501
|
attachments: readonly ThreadComposerAttachment[];
|
1481
1502
|
addAttachment: (file: File) => void;
|
1482
1503
|
removeAttachment: (attachmentId: string) => void;
|
@@ -1510,6 +1531,7 @@ declare const useComposerStore: {
|
|
1510
1531
|
type: "thread";
|
1511
1532
|
value: string;
|
1512
1533
|
setValue: (value: string) => void;
|
1534
|
+
attachmentAccept: string;
|
1513
1535
|
attachments: readonly ThreadComposerAttachment[];
|
1514
1536
|
addAttachment: (file: File) => void;
|
1515
1537
|
removeAttachment: (attachmentId: string) => void;
|
@@ -1542,6 +1564,7 @@ declare const useComposerStore: {
|
|
1542
1564
|
type: "thread";
|
1543
1565
|
value: string;
|
1544
1566
|
setValue: (value: string) => void;
|
1567
|
+
attachmentAccept: string;
|
1545
1568
|
attachments: readonly ThreadComposerAttachment[];
|
1546
1569
|
addAttachment: (file: File) => void;
|
1547
1570
|
removeAttachment: (attachmentId: string) => void;
|
@@ -1564,6 +1587,7 @@ type ThreadComposerState = Readonly<{
|
|
1564
1587
|
value: string;
|
1565
1588
|
/** @deprecated Use `setText` instead. */
|
1566
1589
|
setValue: (value: string) => void;
|
1590
|
+
attachmentAccept: string;
|
1567
1591
|
attachments: readonly ThreadComposerAttachment[];
|
1568
1592
|
addAttachment: (file: File) => void;
|
1569
1593
|
removeAttachment: (attachmentId: string) => void;
|
@@ -1587,6 +1611,9 @@ type CreateAppendMessage = string | {
|
|
1587
1611
|
};
|
1588
1612
|
declare const useAppendMessage: () => (message: CreateAppendMessage) => void;
|
1589
1613
|
|
1614
|
+
/**
|
1615
|
+
* @deprecated Use `useRuntimeActions().switchToNewThread()` instead. This will be removed in 0.6.0.
|
1616
|
+
*/
|
1590
1617
|
declare const useSwitchToNewThread: () => () => void;
|
1591
1618
|
|
1592
1619
|
type AssistantToolProps<TArgs extends Record<string, unknown>, TResult> = Tool<TArgs, TResult> & {
|
package/dist/index.js
CHANGED
@@ -157,6 +157,7 @@ var makeThreadComposerStore = (useThreadRuntime2) => {
|
|
157
157
|
setValue(value) {
|
158
158
|
get().setText(value);
|
159
159
|
},
|
160
|
+
attachmentAccept: runtime.composer.attachmentAccept,
|
160
161
|
attachments: runtime.composer.attachments,
|
161
162
|
addAttachment: (file) => {
|
162
163
|
useThreadRuntime2.getState().composer.addAttachment(file);
|
@@ -1835,23 +1836,24 @@ var ExternalStoreRuntime = (_class9 = class extends BaseAssistantRuntime {
|
|
1835
1836
|
return this._proxyConfigProvider.registerModelConfigProvider(provider);
|
1836
1837
|
}
|
1837
1838
|
async switchToNewThread() {
|
1838
|
-
if (!this.store.
|
1839
|
+
if (!this.store.onSwitchToNewThread)
|
1839
1840
|
throw new Error("Runtime does not support switching to new threads.");
|
1840
1841
|
this.thread = new ExternalStoreThreadRuntime({
|
1841
|
-
|
1842
|
-
|
1842
|
+
...this.store,
|
1843
|
+
messages: []
|
1843
1844
|
});
|
1844
|
-
await this.store.
|
1845
|
+
await this.store.onSwitchToNewThread();
|
1845
1846
|
}
|
1846
1847
|
async switchToThread(threadId) {
|
1847
1848
|
if (threadId !== null) {
|
1848
|
-
if (!this.store.
|
1849
|
+
if (!this.store.onSwitchToThread)
|
1849
1850
|
throw new Error("Runtime does not support switching threads.");
|
1850
1851
|
this.thread = new ExternalStoreThreadRuntime({
|
1851
|
-
|
1852
|
-
|
1852
|
+
...this.store,
|
1853
|
+
messages: []
|
1854
|
+
// ignore messages until rerender
|
1853
1855
|
});
|
1854
|
-
this.store.
|
1856
|
+
this.store.onSwitchToThread(threadId);
|
1855
1857
|
} else {
|
1856
1858
|
this.switchToNewThread();
|
1857
1859
|
}
|
@@ -2266,10 +2268,11 @@ var ThreadProvider = ({
|
|
2266
2268
|
);
|
2267
2269
|
}
|
2268
2270
|
const composerState = context.useComposer.getState();
|
2269
|
-
if (thread.composer.isEmpty !== composerState.isEmpty || thread.composer.text !== composerState.text || thread.composer.attachments !== composerState.attachments || state.capabilities.cancel !== composerState.canCancel) {
|
2271
|
+
if (thread.composer.isEmpty !== composerState.isEmpty || thread.composer.text !== composerState.text || thread.composer.attachmentAccept !== composerState.attachmentAccept || thread.composer.attachments !== composerState.attachments || state.capabilities.cancel !== composerState.canCancel) {
|
2270
2272
|
writableStore(context.useComposer).setState({
|
2271
2273
|
isEmpty: thread.composer.isEmpty,
|
2272
2274
|
text: thread.composer.text,
|
2275
|
+
attachmentAccept: thread.composer.attachmentAccept,
|
2273
2276
|
attachments: thread.composer.attachments,
|
2274
2277
|
canCancel: state.capabilities.cancel
|
2275
2278
|
});
|
@@ -2298,6 +2301,7 @@ var ThreadProvider = ({
|
|
2298
2301
|
var makeAssistantActionsStore = (runtimeRef) => _zustand.create.call(void 0,
|
2299
2302
|
() => Object.freeze({
|
2300
2303
|
switchToThread: () => runtimeRef.current.switchToThread(null),
|
2304
|
+
switchToNewThread: () => runtimeRef.current.switchToNewThread(),
|
2301
2305
|
registerModelConfigProvider: (provider) => runtimeRef.current.registerModelConfigProvider(provider),
|
2302
2306
|
getRuntime: () => runtimeRef.current
|
2303
2307
|
})
|
@@ -2441,7 +2445,7 @@ var useSwitchToNewThread = () => {
|
|
2441
2445
|
const assistantActionsStore = useAssistantActionsStore();
|
2442
2446
|
const threadComposerStore = useThreadComposerStore();
|
2443
2447
|
const switchToNewThread = _react.useCallback.call(void 0, () => {
|
2444
|
-
assistantActionsStore.getState().
|
2448
|
+
assistantActionsStore.getState().switchToNewThread();
|
2445
2449
|
threadComposerStore.getState().focus();
|
2446
2450
|
}, [assistantActionsStore, threadComposerStore]);
|
2447
2451
|
return switchToNewThread;
|
@@ -2504,13 +2508,13 @@ var makeAssistantToolUI = (tool) => {
|
|
2504
2508
|
// src/model-config/useAssistantInstructions.tsx
|
2505
2509
|
|
2506
2510
|
var useAssistantInstructions = (instruction) => {
|
2507
|
-
const
|
2511
|
+
const actionsStore = useAssistantActionsStore();
|
2508
2512
|
_react.useEffect.call(void 0, () => {
|
2509
2513
|
const config = {
|
2510
2514
|
system: instruction
|
2511
2515
|
};
|
2512
|
-
return
|
2513
|
-
}, [
|
2516
|
+
return actionsStore.getState().registerModelConfigProvider({ getModelConfig: () => config });
|
2517
|
+
}, [actionsStore, instruction]);
|
2514
2518
|
};
|
2515
2519
|
|
2516
2520
|
// src/primitive-hooks/actionBar/useActionBarCopy.tsx
|
@@ -2740,10 +2744,10 @@ var useComposerSend = () => {
|
|
2740
2744
|
var useComposerAddAttachment = () => {
|
2741
2745
|
const disabled = useComposer((c) => !c.isEditing);
|
2742
2746
|
const threadComposerStore = useThreadComposerStore();
|
2743
|
-
const threadRuntimeStore =
|
2747
|
+
const threadRuntimeStore = useThreadComposerStore();
|
2744
2748
|
const callback = _react.useCallback.call(void 0, () => {
|
2745
2749
|
const { addAttachment } = threadComposerStore.getState();
|
2746
|
-
const { attachmentAccept } = threadRuntimeStore.getState()
|
2750
|
+
const { attachmentAccept } = threadRuntimeStore.getState();
|
2747
2751
|
const input = document.createElement("input");
|
2748
2752
|
input.type = "file";
|
2749
2753
|
if (attachmentAccept !== "*") {
|