@assistant-ui/react 0.5.98 → 0.5.99
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/api/AssistantRuntime.d.ts +4 -4
- package/dist/api/AssistantRuntime.d.ts.map +1 -1
- package/dist/api/AssistantRuntime.js +7 -7
- package/dist/api/AssistantRuntime.js.map +1 -1
- package/dist/api/AssistantRuntime.mjs +7 -9
- package/dist/api/AssistantRuntime.mjs.map +1 -1
- package/dist/api/ComposerRuntime.d.ts +7 -0
- package/dist/api/ComposerRuntime.d.ts.map +1 -1
- package/dist/api/ComposerRuntime.js +13 -0
- package/dist/api/ComposerRuntime.js.map +1 -1
- package/dist/api/ComposerRuntime.mjs +13 -0
- package/dist/api/ComposerRuntime.mjs.map +1 -1
- package/dist/api/MessageRuntime.d.ts.map +1 -1
- package/dist/api/MessageRuntime.js +0 -5
- package/dist/api/MessageRuntime.js.map +1 -1
- package/dist/api/MessageRuntime.mjs +0 -5
- package/dist/api/MessageRuntime.mjs.map +1 -1
- package/dist/api/RuntimePathTypes.d.ts +16 -1
- package/dist/api/RuntimePathTypes.d.ts.map +1 -1
- package/dist/api/RuntimePathTypes.js.map +1 -1
- package/dist/api/ThreadListItemRuntime.d.ts +29 -0
- package/dist/api/ThreadListItemRuntime.d.ts.map +1 -0
- package/dist/api/ThreadListItemRuntime.js +61 -0
- package/dist/api/ThreadListItemRuntime.js.map +1 -0
- package/dist/api/ThreadListItemRuntime.mjs +36 -0
- package/dist/api/ThreadListItemRuntime.mjs.map +1 -0
- package/dist/api/ThreadListRuntime.d.ts +51 -0
- package/dist/api/ThreadListRuntime.d.ts.map +1 -0
- package/dist/api/ThreadListRuntime.js +128 -0
- package/dist/api/ThreadListRuntime.js.map +1 -0
- package/dist/api/ThreadListRuntime.mjs +105 -0
- package/dist/api/ThreadListRuntime.mjs.map +1 -0
- package/dist/api/ThreadRuntime.d.ts +3 -0
- package/dist/api/ThreadRuntime.d.ts.map +1 -1
- package/dist/api/ThreadRuntime.js +1 -1
- package/dist/api/ThreadRuntime.js.map +1 -1
- package/dist/api/ThreadRuntime.mjs +1 -1
- package/dist/api/ThreadRuntime.mjs.map +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/context/providers/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/context/providers/AssistantRuntimeProvider.js +7 -9
- package/dist/context/providers/AssistantRuntimeProvider.js.map +1 -1
- package/dist/context/providers/AssistantRuntimeProvider.mjs +7 -9
- package/dist/context/providers/AssistantRuntimeProvider.mjs.map +1 -1
- package/dist/context/providers/AttachmentRuntimeProvider.d.ts +6 -5
- package/dist/context/providers/AttachmentRuntimeProvider.d.ts.map +1 -1
- package/dist/context/providers/AttachmentRuntimeProvider.js.map +1 -1
- package/dist/context/providers/AttachmentRuntimeProvider.mjs.map +1 -1
- package/dist/context/providers/ContentPartRuntimeProvider.d.ts +6 -5
- package/dist/context/providers/ContentPartRuntimeProvider.d.ts.map +1 -1
- package/dist/context/providers/ContentPartRuntimeProvider.js +1 -4
- package/dist/context/providers/ContentPartRuntimeProvider.js.map +1 -1
- package/dist/context/providers/ContentPartRuntimeProvider.mjs +1 -4
- package/dist/context/providers/ContentPartRuntimeProvider.mjs.map +1 -1
- package/dist/context/providers/MessageRuntimeProvider.d.ts +6 -5
- package/dist/context/providers/MessageRuntimeProvider.d.ts.map +1 -1
- package/dist/context/providers/MessageRuntimeProvider.js.map +1 -1
- package/dist/context/providers/MessageRuntimeProvider.mjs.map +1 -1
- package/dist/context/providers/TextContentPartProvider.d.ts +7 -6
- package/dist/context/providers/TextContentPartProvider.d.ts.map +1 -1
- package/dist/context/providers/TextContentPartProvider.js +5 -1
- package/dist/context/providers/TextContentPartProvider.js.map +1 -1
- package/dist/context/providers/TextContentPartProvider.mjs +5 -1
- package/dist/context/providers/TextContentPartProvider.mjs.map +1 -1
- package/dist/context/providers/ThreadListItemRuntimeProvider.d.ts +13 -0
- package/dist/context/providers/ThreadListItemRuntimeProvider.d.ts.map +1 -0
- package/dist/context/providers/ThreadListItemRuntimeProvider.js +62 -0
- package/dist/context/providers/ThreadListItemRuntimeProvider.js.map +1 -0
- package/dist/context/providers/ThreadListItemRuntimeProvider.mjs +39 -0
- package/dist/context/providers/ThreadListItemRuntimeProvider.mjs.map +1 -0
- package/dist/context/react/AssistantContext.d.ts +35 -11
- package/dist/context/react/AssistantContext.d.ts.map +1 -1
- package/dist/context/react/AssistantContext.js +4 -4
- package/dist/context/react/AssistantContext.js.map +1 -1
- package/dist/context/react/AssistantContext.mjs +3 -3
- package/dist/context/react/AssistantContext.mjs.map +1 -1
- package/dist/context/react/ThreadListItemContext.d.ts +58 -0
- package/dist/context/react/ThreadListItemContext.d.ts.map +1 -0
- package/dist/context/react/ThreadListItemContext.js +53 -0
- package/dist/context/react/ThreadListItemContext.js.map +1 -0
- package/dist/context/react/ThreadListItemContext.mjs +25 -0
- package/dist/context/react/ThreadListItemContext.mjs.map +1 -0
- package/dist/context/react/index.d.ts +1 -1
- package/dist/context/react/index.d.ts.map +1 -1
- package/dist/context/react/index.js +2 -2
- package/dist/context/react/index.js.map +1 -1
- package/dist/context/react/index.mjs +2 -2
- package/dist/context/react/index.mjs.map +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/internal.mjs.map +1 -1
- package/dist/primitives/index.d.ts +2 -0
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +6 -0
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/index.mjs +4 -0
- package/dist/primitives/index.mjs.map +1 -1
- package/dist/primitives/threadList/ThreadListItems.d.ts +11 -0
- package/dist/primitives/threadList/ThreadListItems.d.ts.map +1 -0
- package/dist/primitives/threadList/ThreadListItems.js +72 -0
- package/dist/primitives/threadList/ThreadListItems.js.map +1 -0
- package/dist/primitives/threadList/ThreadListItems.mjs +48 -0
- package/dist/primitives/threadList/ThreadListItems.mjs.map +1 -0
- package/dist/primitives/threadList/ThreadListNew.d.ts +13 -0
- package/dist/primitives/threadList/ThreadListNew.d.ts.map +1 -0
- package/dist/primitives/threadList/ThreadListNew.js +43 -0
- package/dist/primitives/threadList/ThreadListNew.js.map +1 -0
- package/dist/primitives/threadList/ThreadListNew.mjs +21 -0
- package/dist/primitives/threadList/ThreadListNew.mjs.map +1 -0
- package/dist/primitives/threadList/index.d.ts +3 -0
- package/dist/primitives/threadList/index.d.ts.map +1 -0
- package/dist/primitives/threadList/index.js +34 -0
- package/dist/primitives/threadList/index.js.map +1 -0
- package/dist/primitives/threadList/index.mjs +8 -0
- package/dist/primitives/threadList/index.mjs.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemArchive.d.ts +13 -0
- package/dist/primitives/threadListItem/ThreadListItemArchive.d.ts.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemArchive.js +43 -0
- package/dist/primitives/threadListItem/ThreadListItemArchive.js.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemArchive.mjs +21 -0
- package/dist/primitives/threadListItem/ThreadListItemArchive.mjs.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemDelete.d.ts +13 -0
- package/dist/primitives/threadListItem/ThreadListItemDelete.d.ts.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemDelete.js +43 -0
- package/dist/primitives/threadListItem/ThreadListItemDelete.js.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemDelete.mjs +21 -0
- package/dist/primitives/threadListItem/ThreadListItemDelete.mjs.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.d.ts +13 -0
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.d.ts.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.js +43 -0
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.js.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.mjs +21 -0
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.mjs.map +1 -0
- package/dist/primitives/threadListItem/index.d.ts +4 -0
- package/dist/primitives/threadListItem/index.d.ts.map +1 -0
- package/dist/primitives/threadListItem/index.js +37 -0
- package/dist/primitives/threadListItem/index.js.map +1 -0
- package/dist/primitives/threadListItem/index.mjs +10 -0
- package/dist/primitives/threadListItem/index.mjs.map +1 -0
- package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts +5 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.js +14 -5
- package/dist/runtimes/composer/BaseComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs +14 -5
- package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js +2 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs +2 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/core/AssistantRuntimeCore.d.ts +2 -2
- package/dist/runtimes/core/AssistantRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/AssistantRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/BaseAssistantRuntimeCore.d.ts +2 -2
- package/dist/runtimes/core/BaseAssistantRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/BaseAssistantRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/BaseAssistantRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/core/ComposerRuntimeCore.d.ts +3 -0
- package/dist/runtimes/core/ComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/ComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/{ThreadManagerRuntimeCore.d.ts → ThreadListRuntimeCore.d.ts} +7 -6
- package/dist/runtimes/core/ThreadListRuntimeCore.d.ts.map +1 -0
- package/dist/runtimes/core/{ThreadManagerRuntimeCore.js → ThreadListRuntimeCore.js} +4 -4
- package/dist/runtimes/core/ThreadListRuntimeCore.js.map +1 -0
- package/dist/runtimes/core/ThreadListRuntimeCore.mjs +1 -0
- package/dist/runtimes/core/subscribeToMainThread.js +2 -2
- package/dist/runtimes/core/subscribeToMainThread.js.map +1 -1
- package/dist/runtimes/core/subscribeToMainThread.mjs +2 -2
- package/dist/runtimes/core/subscribeToMainThread.mjs.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts +8 -8
- package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreAdapter.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.d.ts +2 -2
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.js +8 -8
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.mjs +8 -8
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts +35 -0
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts.map +1 -0
- package/dist/runtimes/external-store/{ExternalStoreThreadManagementAdapter.js → ExternalStoreThreadListRuntimeCore.js} +17 -8
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js.map +1 -0
- package/dist/runtimes/external-store/{ExternalStoreThreadManagementAdapter.mjs → ExternalStoreThreadListRuntimeCore.mjs} +13 -4
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.mjs.map +1 -0
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts +1 -1
- package/dist/runtimes/local/LocalRuntimeCore.d.ts +2 -2
- package/dist/runtimes/local/LocalRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalRuntimeCore.js +7 -7
- package/dist/runtimes/local/LocalRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalRuntimeCore.mjs +7 -7
- package/dist/runtimes/local/LocalRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/local/{LocalThreadManagerRuntimeCore.d.ts → LocalThreadListRuntimeCore.d.ts} +16 -6
- package/dist/runtimes/local/LocalThreadListRuntimeCore.d.ts.map +1 -0
- package/dist/runtimes/local/{LocalThreadManagerRuntimeCore.js → LocalThreadListRuntimeCore.js} +11 -8
- package/dist/runtimes/local/LocalThreadListRuntimeCore.js.map +1 -0
- package/dist/runtimes/local/{LocalThreadManagerRuntimeCore.mjs → LocalThreadListRuntimeCore.mjs} +7 -4
- package/dist/runtimes/local/LocalThreadListRuntimeCore.mjs.map +1 -0
- package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.js +2 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.mjs +2 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.mjs.map +1 -1
- package/dist/types/AssistantTypes.d.ts +2 -0
- package/dist/types/AssistantTypes.d.ts.map +1 -1
- package/dist/types/AssistantTypes.js.map +1 -1
- package/package.json +7 -7
- package/src/api/AssistantRuntime.ts +9 -12
- package/src/api/ComposerRuntime.ts +17 -0
- package/src/api/MessageRuntime.ts +0 -9
- package/src/api/RuntimePathTypes.ts +10 -1
- package/src/api/ThreadListItemRuntime.ts +67 -0
- package/src/api/ThreadListRuntime.ts +159 -0
- package/src/api/ThreadRuntime.ts +2 -1
- package/src/api/index.ts +1 -4
- package/src/context/providers/AssistantRuntimeProvider.tsx +7 -9
- package/src/context/providers/AttachmentRuntimeProvider.tsx +6 -4
- package/src/context/providers/ContentPartRuntimeProvider.tsx +8 -7
- package/src/context/providers/MessageRuntimeProvider.tsx +6 -4
- package/src/context/providers/TextContentPartProvider.tsx +11 -7
- package/src/context/providers/ThreadListItemRuntimeProvider.tsx +54 -0
- package/src/context/react/AssistantContext.ts +4 -4
- package/src/context/react/ThreadListItemContext.ts +39 -0
- package/src/context/react/index.ts +2 -2
- package/src/internal.ts +1 -1
- package/src/primitives/index.ts +2 -0
- package/src/primitives/threadList/ThreadListItems.tsx +73 -0
- package/src/primitives/threadList/ThreadListNew.ts +25 -0
- package/src/primitives/threadList/index.ts +2 -0
- package/src/primitives/threadListItem/ThreadListItemArchive.ts +25 -0
- package/src/primitives/threadListItem/ThreadListItemDelete.ts +25 -0
- package/src/primitives/threadListItem/ThreadListItemUnarchive.ts +25 -0
- package/src/primitives/threadListItem/index.ts +3 -0
- package/src/runtimes/composer/BaseComposerRuntimeCore.tsx +19 -5
- package/src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx +3 -2
- package/src/runtimes/core/AssistantRuntimeCore.tsx +2 -2
- package/src/runtimes/core/BaseAssistantRuntimeCore.tsx +2 -2
- package/src/runtimes/core/ComposerRuntimeCore.tsx +4 -0
- package/src/runtimes/core/{ThreadManagerRuntimeCore.tsx → ThreadListRuntimeCore.tsx} +7 -5
- package/src/runtimes/core/subscribeToMainThread.ts +2 -2
- package/src/runtimes/external-store/ExternalStoreAdapter.tsx +8 -8
- package/src/runtimes/external-store/ExternalStoreRuntimeCore.tsx +8 -8
- package/src/runtimes/external-store/{ExternalStoreThreadManagementAdapter.tsx → ExternalStoreThreadListRuntimeCore.tsx} +16 -6
- package/src/runtimes/local/LocalRuntimeCore.tsx +7 -7
- package/src/runtimes/local/{LocalThreadManagerRuntimeCore.tsx → LocalThreadListRuntimeCore.tsx} +11 -7
- package/src/runtimes/local/LocalThreadRuntimeCore.tsx +2 -1
- package/src/types/AssistantTypes.ts +3 -0
- package/dist/api/ThreadManagerRuntime.d.ts +0 -32
- package/dist/api/ThreadManagerRuntime.d.ts.map +0 -1
- package/dist/api/ThreadManagerRuntime.js +0 -73
- package/dist/api/ThreadManagerRuntime.js.map +0 -1
- package/dist/api/ThreadManagerRuntime.mjs +0 -48
- package/dist/api/ThreadManagerRuntime.mjs.map +0 -1
- package/dist/runtimes/core/ThreadManagerRuntimeCore.d.ts.map +0 -1
- package/dist/runtimes/core/ThreadManagerRuntimeCore.js.map +0 -1
- package/dist/runtimes/core/ThreadManagerRuntimeCore.mjs +0 -1
- package/dist/runtimes/external-store/ExternalStoreThreadManagementAdapter.d.ts +0 -25
- package/dist/runtimes/external-store/ExternalStoreThreadManagementAdapter.d.ts.map +0 -1
- package/dist/runtimes/external-store/ExternalStoreThreadManagementAdapter.js.map +0 -1
- package/dist/runtimes/external-store/ExternalStoreThreadManagementAdapter.mjs.map +0 -1
- package/dist/runtimes/local/LocalThreadManagerRuntimeCore.d.ts.map +0 -1
- package/dist/runtimes/local/LocalThreadManagerRuntimeCore.js.map +0 -1
- package/dist/runtimes/local/LocalThreadManagerRuntimeCore.mjs.map +0 -1
- package/src/api/ThreadManagerRuntime.ts +0 -80
- /package/dist/runtimes/core/{ThreadManagerRuntimeCore.mjs.map → ThreadListRuntimeCore.mjs.map} +0 -0
@@ -14,10 +14,12 @@ import {
|
|
14
14
|
ContentPartState,
|
15
15
|
} from "../../api/ContentPartRuntime";
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
export namespace TextContentPartProvider {
|
18
|
+
export type Props = PropsWithChildren<{
|
19
|
+
text: string;
|
20
|
+
isRunning?: boolean | undefined;
|
21
|
+
}>;
|
22
|
+
}
|
21
23
|
|
22
24
|
const COMPLETE_STATUS: ContentPartStatus = {
|
23
25
|
type: "complete",
|
@@ -27,9 +29,11 @@ const RUNNING_STATUS: ContentPartStatus = {
|
|
27
29
|
type: "running",
|
28
30
|
};
|
29
31
|
|
30
|
-
export const TextContentPartProvider: FC<
|
31
|
-
|
32
|
-
|
32
|
+
export const TextContentPartProvider: FC<TextContentPartProvider.Props> = ({
|
33
|
+
children,
|
34
|
+
text,
|
35
|
+
isRunning,
|
36
|
+
}) => {
|
33
37
|
const [context] = useState<ContentPartContextValue>(() => {
|
34
38
|
const useContentPartRuntime = create(
|
35
39
|
// TODO
|
@@ -0,0 +1,54 @@
|
|
1
|
+
"use client";
|
2
|
+
|
3
|
+
import { type FC, type PropsWithChildren, useEffect, useState } from "react";
|
4
|
+
import { create } from "zustand";
|
5
|
+
import {
|
6
|
+
ThreadListItemContext,
|
7
|
+
type ThreadListItemContextValue,
|
8
|
+
} from "../react/ThreadListItemContext";
|
9
|
+
import { writableStore } from "../ReadonlyStore";
|
10
|
+
import { ThreadListItemRuntime } from "../../api/ThreadListItemRuntime";
|
11
|
+
|
12
|
+
export namespace ThreadListItemRuntimeProvider {
|
13
|
+
export type Props = PropsWithChildren<{
|
14
|
+
runtime: ThreadListItemRuntime;
|
15
|
+
}>;
|
16
|
+
}
|
17
|
+
|
18
|
+
const useThreadListItemRuntimeStore = (runtime: ThreadListItemRuntime) => {
|
19
|
+
const [store] = useState(() => create(() => runtime));
|
20
|
+
|
21
|
+
useEffect(() => {
|
22
|
+
writableStore(store).setState(runtime, true);
|
23
|
+
}, [runtime, store]);
|
24
|
+
|
25
|
+
return store;
|
26
|
+
};
|
27
|
+
|
28
|
+
export const useThreadListItemStore = (runtime: ThreadListItemRuntime) => {
|
29
|
+
const [store] = useState(() => create(() => runtime.getState()));
|
30
|
+
useEffect(() => {
|
31
|
+
const updateState = () =>
|
32
|
+
writableStore(store).setState(runtime.getState(), true);
|
33
|
+
updateState();
|
34
|
+
return runtime.subscribe(updateState);
|
35
|
+
}, [runtime, store]);
|
36
|
+
|
37
|
+
return store;
|
38
|
+
};
|
39
|
+
|
40
|
+
export const ThreadListItemRuntimeProvider: FC<
|
41
|
+
ThreadListItemRuntimeProvider.Props
|
42
|
+
> = ({ runtime, children }) => {
|
43
|
+
const useThreadListItemRuntime = useThreadListItemRuntimeStore(runtime);
|
44
|
+
const useThreadListItem = useThreadListItemStore(runtime);
|
45
|
+
const [context] = useState<ThreadListItemContextValue>(() => {
|
46
|
+
return { useThreadListItemRuntime, useThreadListItem };
|
47
|
+
});
|
48
|
+
|
49
|
+
return (
|
50
|
+
<ThreadListItemContext.Provider value={context}>
|
51
|
+
{children}
|
52
|
+
</ThreadListItemContext.Provider>
|
53
|
+
);
|
54
|
+
};
|
@@ -7,12 +7,12 @@ import { createContextHook } from "./utils/createContextHook";
|
|
7
7
|
import { createContextStoreHook } from "./utils/createContextStoreHook";
|
8
8
|
import { UseBoundStore } from "zustand";
|
9
9
|
import { AssistantRuntime } from "../../api/AssistantRuntime";
|
10
|
-
import {
|
10
|
+
import { ThreadListState } from "../../api/ThreadListRuntime";
|
11
11
|
|
12
12
|
export type AssistantContextValue = {
|
13
13
|
useToolUIs: UseBoundStore<ReadonlyStore<AssistantToolUIsState>>;
|
14
14
|
useAssistantRuntime: UseBoundStore<ReadonlyStore<AssistantRuntime>>;
|
15
|
-
|
15
|
+
useThreadList: UseBoundStore<ReadonlyStore<ThreadListState>>;
|
16
16
|
|
17
17
|
/**
|
18
18
|
* @deprecated Use `useAssistantRuntime` instead. This will be removed in 0.6.0.
|
@@ -68,7 +68,7 @@ export const { useToolUIs, useToolUIsStore } = createContextStoreHook(
|
|
68
68
|
"useToolUIs",
|
69
69
|
);
|
70
70
|
|
71
|
-
export const {
|
71
|
+
export const { useThreadList } = createContextStoreHook(
|
72
72
|
useAssistantContext,
|
73
|
-
"
|
73
|
+
"useThreadList",
|
74
74
|
);
|
@@ -0,0 +1,39 @@
|
|
1
|
+
"use client";
|
2
|
+
|
3
|
+
import { createContext } from "react";
|
4
|
+
import { ReadonlyStore } from "../ReadonlyStore";
|
5
|
+
import { createContextStoreHook } from "./utils/createContextStoreHook";
|
6
|
+
import { createContextHook } from "./utils/createContextHook";
|
7
|
+
import { UseBoundStore } from "zustand";
|
8
|
+
import { ThreadListItemRuntime } from "../../api/ThreadListItemRuntime";
|
9
|
+
import { ThreadListItemState } from "../../api/ThreadListItemRuntime";
|
10
|
+
|
11
|
+
export type ThreadListItemContextValue = {
|
12
|
+
useThreadListItemRuntime: UseBoundStore<ReadonlyStore<ThreadListItemRuntime>>;
|
13
|
+
useThreadListItem: UseBoundStore<ReadonlyStore<ThreadListItemState>>;
|
14
|
+
};
|
15
|
+
|
16
|
+
export const ThreadListItemContext =
|
17
|
+
createContext<ThreadListItemContextValue | null>(null);
|
18
|
+
|
19
|
+
export const useThreadListItemContext = createContextHook(
|
20
|
+
ThreadListItemContext,
|
21
|
+
"a component passed to <ThreadListPrimitive.Items components={...}>",
|
22
|
+
);
|
23
|
+
|
24
|
+
export function useThreadListItemRuntime(options?: {
|
25
|
+
optional?: false | undefined;
|
26
|
+
}): ThreadListItemRuntime;
|
27
|
+
export function useThreadListItemRuntime(options?: {
|
28
|
+
optional?: boolean | undefined;
|
29
|
+
}): ThreadListItemRuntime | null;
|
30
|
+
export function useThreadListItemRuntime(options?: {
|
31
|
+
optional?: boolean | undefined;
|
32
|
+
}) {
|
33
|
+
const context = useThreadListItemContext(options);
|
34
|
+
if (!context) return null;
|
35
|
+
return context.useThreadListItemRuntime();
|
36
|
+
}
|
37
|
+
|
38
|
+
export const { useThreadListItem, useThreadListItemStore } =
|
39
|
+
createContextStoreHook(useThreadListItemContext, "useThreadListItem");
|
@@ -1,6 +1,6 @@
|
|
1
1
|
export {
|
2
2
|
useAssistantRuntime,
|
3
|
-
|
3
|
+
useThreadList,
|
4
4
|
useToolUIs,
|
5
5
|
useToolUIsStore,
|
6
6
|
|
@@ -150,7 +150,7 @@ export {
|
|
150
150
|
useAttachment,
|
151
151
|
useAttachmentRuntime,
|
152
152
|
|
153
|
-
// TODO decide if we want to export/drop these?
|
153
|
+
// TODO decide if we want to export/drop these?
|
154
154
|
// useEditComposerAttachment,
|
155
155
|
// useEditComposerAttachmentRuntime,
|
156
156
|
// useMessageAttachment,
|
package/src/internal.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
export type { ThreadRuntimeCore } from "./runtimes/core/ThreadRuntimeCore";
|
2
|
-
export type {
|
2
|
+
export type { ThreadListRuntimeCore } from "./runtimes/core/ThreadListRuntimeCore";
|
3
3
|
export { DefaultThreadComposerRuntimeCore } from "./runtimes/composer/DefaultThreadComposerRuntimeCore";
|
4
4
|
export { ProxyConfigProvider } from "./utils/ProxyConfigProvider";
|
5
5
|
export { MessageRepository } from "./runtimes/utils/MessageRepository";
|
package/src/primitives/index.ts
CHANGED
@@ -6,6 +6,8 @@ export * as ComposerPrimitive from "./composer";
|
|
6
6
|
export * as ContentPartPrimitive from "./contentPart";
|
7
7
|
export * as MessagePrimitive from "./message";
|
8
8
|
export * as ThreadPrimitive from "./thread";
|
9
|
+
export * as ThreadListPrimitive from "./threadList";
|
10
|
+
export * as ThreadListItemPrimitive from "./threadListItem";
|
9
11
|
|
10
12
|
export type * from "./actionBar/types";
|
11
13
|
export type * from "./assistantModal/types";
|
@@ -0,0 +1,73 @@
|
|
1
|
+
"use client";
|
2
|
+
|
3
|
+
import { ComponentType, FC, memo, useMemo } from "react";
|
4
|
+
import { ThreadListItemRuntimeProvider } from "../../context/providers/ThreadListItemRuntimeProvider";
|
5
|
+
import { useAssistantRuntime, useThreadList } from "../../context";
|
6
|
+
|
7
|
+
export namespace MessagePrimitiveContent {
|
8
|
+
export type Props = {
|
9
|
+
archived?: boolean | undefined;
|
10
|
+
components: {
|
11
|
+
ThreadListItem: ComponentType;
|
12
|
+
};
|
13
|
+
};
|
14
|
+
}
|
15
|
+
|
16
|
+
type ThreadListItemProps = {
|
17
|
+
partIndex: number;
|
18
|
+
archived: boolean;
|
19
|
+
components: MessagePrimitiveContent.Props["components"];
|
20
|
+
};
|
21
|
+
|
22
|
+
const ThreadListItemImpl: FC<ThreadListItemProps> = ({
|
23
|
+
partIndex,
|
24
|
+
archived,
|
25
|
+
components,
|
26
|
+
}) => {
|
27
|
+
const assistantRuntime = useAssistantRuntime();
|
28
|
+
const runtime = useMemo(
|
29
|
+
() =>
|
30
|
+
archived
|
31
|
+
? assistantRuntime.threadList.getThreadListArchivedItemByIndex(
|
32
|
+
partIndex,
|
33
|
+
)
|
34
|
+
: assistantRuntime.threadList.getThreadListItemByIndex(partIndex),
|
35
|
+
[assistantRuntime, partIndex],
|
36
|
+
);
|
37
|
+
|
38
|
+
const ThreadListItemComponent = components.ThreadListItem;
|
39
|
+
|
40
|
+
return (
|
41
|
+
<ThreadListItemRuntimeProvider runtime={runtime}>
|
42
|
+
<ThreadListItemComponent />
|
43
|
+
</ThreadListItemRuntimeProvider>
|
44
|
+
);
|
45
|
+
};
|
46
|
+
|
47
|
+
const ThreadListItem = memo(
|
48
|
+
ThreadListItemImpl,
|
49
|
+
(prev, next) =>
|
50
|
+
prev.partIndex === next.partIndex &&
|
51
|
+
prev.archived === next.archived &&
|
52
|
+
prev.components.ThreadListItem === next.components.ThreadListItem,
|
53
|
+
);
|
54
|
+
|
55
|
+
export const ThreadListPrimitiveItems: FC<MessagePrimitiveContent.Props> = ({
|
56
|
+
archived = false,
|
57
|
+
components,
|
58
|
+
}) => {
|
59
|
+
const contentLength = useThreadList((s) =>
|
60
|
+
archived ? s.archivedThreads.length : s.threads.length,
|
61
|
+
);
|
62
|
+
|
63
|
+
return Array.from({ length: contentLength }, (_, index) => (
|
64
|
+
<ThreadListItem
|
65
|
+
key={index}
|
66
|
+
partIndex={index}
|
67
|
+
archived={archived}
|
68
|
+
components={components}
|
69
|
+
/>
|
70
|
+
));
|
71
|
+
};
|
72
|
+
|
73
|
+
ThreadListPrimitiveItems.displayName = "ThreadListPrimitive.Items";
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"use client";
|
2
|
+
|
3
|
+
import {
|
4
|
+
ActionButtonElement,
|
5
|
+
ActionButtonProps,
|
6
|
+
createActionButton,
|
7
|
+
} from "../../utils/createActionButton";
|
8
|
+
import { useAssistantRuntime } from "../../context";
|
9
|
+
|
10
|
+
const useThreadListNew = () => {
|
11
|
+
const runtime = useAssistantRuntime();
|
12
|
+
return () => {
|
13
|
+
runtime.switchToNewThread();
|
14
|
+
};
|
15
|
+
};
|
16
|
+
|
17
|
+
export namespace ThreadListPrimitiveNew {
|
18
|
+
export type Element = ActionButtonElement;
|
19
|
+
export type Props = ActionButtonProps<typeof useThreadListNew>;
|
20
|
+
}
|
21
|
+
|
22
|
+
export const ThreadListPrimitiveNew = createActionButton(
|
23
|
+
"ThreadListPrimitive.New",
|
24
|
+
useThreadListNew,
|
25
|
+
);
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"use client";
|
2
|
+
|
3
|
+
import {
|
4
|
+
ActionButtonElement,
|
5
|
+
ActionButtonProps,
|
6
|
+
createActionButton,
|
7
|
+
} from "../../utils/createActionButton";
|
8
|
+
import { useThreadListItemRuntime } from "../../context/react/ThreadListItemContext";
|
9
|
+
|
10
|
+
const useThreadListItemArchive = () => {
|
11
|
+
const runtime = useThreadListItemRuntime();
|
12
|
+
return () => {
|
13
|
+
runtime.archive();
|
14
|
+
};
|
15
|
+
};
|
16
|
+
|
17
|
+
export namespace ThreadListItemPrimitiveArchive {
|
18
|
+
export type Element = ActionButtonElement;
|
19
|
+
export type Props = ActionButtonProps<typeof useThreadListItemArchive>;
|
20
|
+
}
|
21
|
+
|
22
|
+
export const ThreadListItemPrimitiveArchive = createActionButton(
|
23
|
+
"ThreadListItemPrimitive.Archive",
|
24
|
+
useThreadListItemArchive,
|
25
|
+
);
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"use client";
|
2
|
+
|
3
|
+
import {
|
4
|
+
ActionButtonElement,
|
5
|
+
ActionButtonProps,
|
6
|
+
createActionButton,
|
7
|
+
} from "../../utils/createActionButton";
|
8
|
+
import { useThreadListItemRuntime } from "../../context/react/ThreadListItemContext";
|
9
|
+
|
10
|
+
const useThreadListItemDelete = () => {
|
11
|
+
const runtime = useThreadListItemRuntime();
|
12
|
+
return () => {
|
13
|
+
runtime.delete();
|
14
|
+
};
|
15
|
+
};
|
16
|
+
|
17
|
+
export namespace ThreadListItemPrimitiveDelete {
|
18
|
+
export type Element = ActionButtonElement;
|
19
|
+
export type Props = ActionButtonProps<typeof useThreadListItemDelete>;
|
20
|
+
}
|
21
|
+
|
22
|
+
export const ThreadListItemPrimitiveDelete = createActionButton(
|
23
|
+
"ThreadListItemPrimitive.Delete",
|
24
|
+
useThreadListItemDelete,
|
25
|
+
);
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"use client";
|
2
|
+
|
3
|
+
import {
|
4
|
+
ActionButtonElement,
|
5
|
+
ActionButtonProps,
|
6
|
+
createActionButton,
|
7
|
+
} from "../../utils/createActionButton";
|
8
|
+
import { useThreadListItemRuntime } from "../../context/react/ThreadListItemContext";
|
9
|
+
|
10
|
+
const useThreadListItemUnarchive = () => {
|
11
|
+
const runtime = useThreadListItemRuntime();
|
12
|
+
return () => {
|
13
|
+
runtime.unarchive();
|
14
|
+
};
|
15
|
+
};
|
16
|
+
|
17
|
+
export namespace ThreadListItemPrimitiveUnarchive {
|
18
|
+
export type Element = ActionButtonElement;
|
19
|
+
export type Props = ActionButtonProps<typeof useThreadListItemUnarchive>;
|
20
|
+
}
|
21
|
+
|
22
|
+
export const ThreadListItemPrimitiveUnarchive = createActionButton(
|
23
|
+
"ThreadListItemPrimitive.Unarchive",
|
24
|
+
useThreadListItemUnarchive,
|
25
|
+
);
|
@@ -6,6 +6,7 @@ import {
|
|
6
6
|
import { AppendMessage, Unsubscribe } from "../../types";
|
7
7
|
import { AttachmentAdapter } from "../attachment";
|
8
8
|
import { ComposerRuntimeCore } from "../core/ComposerRuntimeCore";
|
9
|
+
import { MessageRole } from "../../types/AssistantTypes";
|
9
10
|
|
10
11
|
const isAttachmentComplete = (a: Attachment): a is CompleteAttachment =>
|
11
12
|
a.status.type === "complete";
|
@@ -20,14 +21,15 @@ export abstract class BaseComposerRuntimeCore implements ComposerRuntimeCore {
|
|
20
21
|
}
|
21
22
|
|
22
23
|
private _attachments: readonly Attachment[] = [];
|
23
|
-
protected set attachments(value: readonly Attachment[]) {
|
24
|
-
this._attachments = value;
|
25
|
-
this.notifySubscribers();
|
26
|
-
}
|
27
24
|
public get attachments() {
|
28
25
|
return this._attachments;
|
29
26
|
}
|
30
27
|
|
28
|
+
protected setAttachments(value: readonly Attachment[]) {
|
29
|
+
this._attachments = value;
|
30
|
+
this.notifySubscribers();
|
31
|
+
}
|
32
|
+
|
31
33
|
public abstract get canCancel(): boolean;
|
32
34
|
|
33
35
|
public get isEmpty() {
|
@@ -40,6 +42,17 @@ export abstract class BaseComposerRuntimeCore implements ComposerRuntimeCore {
|
|
40
42
|
return this._text;
|
41
43
|
}
|
42
44
|
|
45
|
+
private _role: MessageRole = "user";
|
46
|
+
|
47
|
+
get role() {
|
48
|
+
return this._role;
|
49
|
+
}
|
50
|
+
|
51
|
+
setRole(role: MessageRole) {
|
52
|
+
this._role = role;
|
53
|
+
this.notifySubscribers();
|
54
|
+
}
|
55
|
+
|
43
56
|
setText(value: string) {
|
44
57
|
this._text = value;
|
45
58
|
this.notifySubscribers();
|
@@ -47,6 +60,7 @@ export abstract class BaseComposerRuntimeCore implements ComposerRuntimeCore {
|
|
47
60
|
|
48
61
|
reset() {
|
49
62
|
this._text = "";
|
63
|
+
this._role = "user";
|
50
64
|
this._attachments = [];
|
51
65
|
this.notifySubscribers();
|
52
66
|
}
|
@@ -69,7 +83,7 @@ export abstract class BaseComposerRuntimeCore implements ComposerRuntimeCore {
|
|
69
83
|
: [];
|
70
84
|
|
71
85
|
const message: Omit<AppendMessage, "parentId"> = {
|
72
|
-
role:
|
86
|
+
role: this.role,
|
73
87
|
content: this.text ? [{ type: "text", text: this.text }] : [],
|
74
88
|
attachments,
|
75
89
|
};
|
@@ -28,11 +28,12 @@ export class DefaultEditComposerRuntimeCore extends BaseComposerRuntimeCore {
|
|
28
28
|
this._previousText = getThreadMessageText(message);
|
29
29
|
this.setText(this._previousText);
|
30
30
|
|
31
|
+
this.setRole(message.role);
|
32
|
+
this.setAttachments(message.attachments ?? []);
|
33
|
+
|
31
34
|
this._nonTextParts = message.content.filter(
|
32
35
|
(part) => part.type !== "text" && part.type !== "ui",
|
33
36
|
);
|
34
|
-
|
35
|
-
this.attachments = message.attachments ?? [];
|
36
37
|
}
|
37
38
|
|
38
39
|
public async handleSend(message: Omit<AppendMessage, "parentId">) {
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import type { ModelConfigProvider } from "../../types/ModelConfigTypes";
|
2
2
|
import type { Unsubscribe } from "../../types/Unsubscribe";
|
3
|
-
import {
|
3
|
+
import { ThreadListRuntimeCore } from "./ThreadListRuntimeCore";
|
4
4
|
|
5
5
|
export type AssistantRuntimeCore = {
|
6
|
-
readonly
|
6
|
+
readonly threadList: ThreadListRuntimeCore;
|
7
7
|
|
8
8
|
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
9
9
|
};
|
@@ -2,11 +2,11 @@ import { type ModelConfigProvider } from "../../types/ModelConfigTypes";
|
|
2
2
|
import type { Unsubscribe } from "../../types/Unsubscribe";
|
3
3
|
import type { AssistantRuntimeCore } from "./AssistantRuntimeCore";
|
4
4
|
import { ProxyConfigProvider } from "../../utils/ProxyConfigProvider";
|
5
|
-
import {
|
5
|
+
import { ThreadListRuntimeCore } from "./ThreadListRuntimeCore";
|
6
6
|
|
7
7
|
export abstract class BaseAssistantRuntimeCore implements AssistantRuntimeCore {
|
8
8
|
protected readonly _proxyConfigProvider = new ProxyConfigProvider();
|
9
|
-
public abstract get
|
9
|
+
public abstract get threadList(): ThreadListRuntimeCore;
|
10
10
|
|
11
11
|
constructor() {}
|
12
12
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import type { Attachment, PendingAttachment, Unsubscribe } from "../../types";
|
2
|
+
import { MessageRole } from "../../types/AssistantTypes";
|
2
3
|
|
3
4
|
export type ComposerRuntimeCore = Readonly<{
|
4
5
|
attachments: readonly Attachment[];
|
@@ -15,6 +16,9 @@ export type ComposerRuntimeCore = Readonly<{
|
|
15
16
|
text: string;
|
16
17
|
setText: (value: string) => void;
|
17
18
|
|
19
|
+
role: MessageRole;
|
20
|
+
setRole: (role: MessageRole) => void;
|
21
|
+
|
18
22
|
/**
|
19
23
|
* @deprecated This method will be removed in 0.6.0. Submit feedback if you need this functionality.
|
20
24
|
*/
|
@@ -1,16 +1,18 @@
|
|
1
1
|
import { Unsubscribe } from "../../types";
|
2
2
|
import { ThreadRuntimeCore } from "./ThreadRuntimeCore";
|
3
3
|
|
4
|
-
export type
|
4
|
+
export type ThreadListMetadata = Readonly<{
|
5
5
|
threadId: string;
|
6
6
|
title?: string;
|
7
|
-
}
|
7
|
+
}>;
|
8
8
|
|
9
|
-
export type
|
9
|
+
export type ThreadListRuntimeCore = {
|
10
10
|
mainThread: ThreadRuntimeCore;
|
11
11
|
|
12
|
-
threads: readonly
|
13
|
-
archivedThreads: readonly
|
12
|
+
threads: readonly ThreadListMetadata[];
|
13
|
+
archivedThreads: readonly ThreadListMetadata[];
|
14
|
+
|
15
|
+
getThreadMetadataById(threadId: string): ThreadListMetadata | undefined;
|
14
16
|
|
15
17
|
switchToThread(threadId: string): void;
|
16
18
|
switchToNewThread(): void;
|
@@ -12,7 +12,7 @@ export const subscribeToMainThread = (
|
|
12
12
|
let cleanup: Unsubscribe | undefined;
|
13
13
|
const inner = () => {
|
14
14
|
cleanup?.();
|
15
|
-
cleanup = runtime.
|
15
|
+
cleanup = runtime.threadList.mainThread.subscribe(callback);
|
16
16
|
|
17
17
|
if (!first) {
|
18
18
|
callback();
|
@@ -20,7 +20,7 @@ export const subscribeToMainThread = (
|
|
20
20
|
first = false;
|
21
21
|
};
|
22
22
|
|
23
|
-
const unsubscribe = runtime.
|
23
|
+
const unsubscribe = runtime.threadList.mainThread.subscribe(inner);
|
24
24
|
inner();
|
25
25
|
|
26
26
|
return () => {
|
@@ -6,13 +6,13 @@ import {
|
|
6
6
|
} from "../core/ThreadRuntimeCore";
|
7
7
|
import { FeedbackAdapter } from "../feedback/FeedbackAdapter";
|
8
8
|
import { SpeechSynthesisAdapter } from "../speech/SpeechAdapterTypes";
|
9
|
-
import {
|
9
|
+
import { ThreadListMetadata } from "../core/ThreadListRuntimeCore";
|
10
10
|
import { ThreadMessageLike } from "./ThreadMessageLike";
|
11
11
|
|
12
|
-
export type
|
12
|
+
export type ExternalStoreThreadListAdapter = {
|
13
13
|
threadId?: string | undefined;
|
14
|
-
threads?: readonly
|
15
|
-
archivedThreads?: readonly
|
14
|
+
threads?: readonly ThreadListMetadata[] | undefined;
|
15
|
+
archivedThreads?: readonly ThreadListMetadata[] | undefined;
|
16
16
|
onSwitchToNewThread?: (() => Promise<void> | void) | undefined;
|
17
17
|
onSwitchToThread?: ((threadId: string) => Promise<void> | void) | undefined;
|
18
18
|
onRename?: (
|
@@ -35,16 +35,16 @@ type ExternalStoreMessageConverterAdapter<T> = {
|
|
35
35
|
|
36
36
|
type ExternalStoreAdapterBase<T> = {
|
37
37
|
/**
|
38
|
-
* @deprecated Use `
|
38
|
+
* @deprecated Use `adapterst.threadList.threadId` instead. This will be removed in 0.6.0.
|
39
39
|
*/
|
40
40
|
threadId?: string | undefined;
|
41
41
|
|
42
42
|
/**
|
43
|
-
* @deprecated Use `adapters.
|
43
|
+
* @deprecated Use `adapters..threadList.onSwitchToThread` instead. This will be removed in 0.6.0.
|
44
44
|
*/
|
45
45
|
onSwitchToThread?: ((threadId: string) => Promise<void> | void) | undefined;
|
46
46
|
/**
|
47
|
-
* @deprecated Use `adapters.
|
47
|
+
* @deprecated Use `adapters.threadList.onSwitchToNewThread` instead. This will be removed in 0.6.0.
|
48
48
|
*/
|
49
49
|
onSwitchToNewThread?: (() => Promise<void> | void) | undefined;
|
50
50
|
|
@@ -68,7 +68,7 @@ type ExternalStoreAdapterBase<T> = {
|
|
68
68
|
attachments?: AttachmentAdapter | undefined;
|
69
69
|
speech?: SpeechSynthesisAdapter | undefined;
|
70
70
|
feedback?: FeedbackAdapter | undefined;
|
71
|
-
|
71
|
+
threadList?: ExternalStoreThreadListAdapter | undefined;
|
72
72
|
}
|
73
73
|
| undefined;
|
74
74
|
unstable_capabilities?:
|
@@ -1,27 +1,27 @@
|
|
1
1
|
import { BaseAssistantRuntimeCore } from "../../internal";
|
2
|
-
import {
|
2
|
+
import { ExternalStoreThreadListRuntimeCore } from "./ExternalStoreThreadListRuntimeCore";
|
3
3
|
import { ExternalStoreAdapter } from "./ExternalStoreAdapter";
|
4
4
|
import { ExternalStoreThreadRuntimeCore } from "./ExternalStoreThreadRuntimeCore";
|
5
5
|
|
6
|
-
const
|
6
|
+
const getThreadListAdapter = (store: ExternalStoreAdapter<any>) => {
|
7
7
|
return {
|
8
8
|
threadId: store.threadId,
|
9
9
|
onSwitchToNewThread: store.onSwitchToNewThread,
|
10
10
|
onSwitchToThread: store.onSwitchToThread,
|
11
|
-
...store.adapters?.
|
11
|
+
...store.adapters?.threadList,
|
12
12
|
};
|
13
13
|
};
|
14
14
|
|
15
15
|
export class ExternalStoreRuntimeCore extends BaseAssistantRuntimeCore {
|
16
|
-
public readonly
|
16
|
+
public readonly threadList;
|
17
17
|
|
18
18
|
private _store: ExternalStoreAdapter<any>;
|
19
19
|
|
20
20
|
constructor(store: ExternalStoreAdapter<any>) {
|
21
21
|
super();
|
22
22
|
this._store = store;
|
23
|
-
this.
|
24
|
-
|
23
|
+
this.threadList = new ExternalStoreThreadListRuntimeCore(
|
24
|
+
getThreadListAdapter(store),
|
25
25
|
(threadId) =>
|
26
26
|
new ExternalStoreThreadRuntimeCore(
|
27
27
|
this._proxyConfigProvider,
|
@@ -33,7 +33,7 @@ export class ExternalStoreRuntimeCore extends BaseAssistantRuntimeCore {
|
|
33
33
|
|
34
34
|
public setStore(store: ExternalStoreAdapter<any>) {
|
35
35
|
this._store = store;
|
36
|
-
this.
|
37
|
-
this.
|
36
|
+
this.threadList.setAdapter(getThreadListAdapter(store));
|
37
|
+
this.threadList.mainThread.setStore(store);
|
38
38
|
}
|
39
39
|
}
|