@assistant-ui/core 0.3.5 → 0.3.6
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/index.d.ts +3 -3
- package/dist/index.js.map +1 -1
- package/dist/internal.js +1 -1
- package/dist/react/AssistantProvider.d.ts +3 -2
- package/dist/react/AssistantProvider.d.ts.map +1 -1
- package/dist/react/AssistantProvider.js +19 -26
- package/dist/react/AssistantProvider.js.map +1 -1
- package/dist/react/AssistantRuntimeProvider.d.ts +7 -2
- package/dist/react/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/react/AssistantRuntimeProvider.js +9 -7
- package/dist/react/AssistantRuntimeProvider.js.map +1 -1
- package/dist/react/providers/AttachmentByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/AttachmentByIndexProvider.js +33 -39
- package/dist/react/providers/AttachmentByIndexProvider.js.map +1 -1
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts.map +1 -1
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.js +15 -20
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.js.map +1 -1
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js +17 -20
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js.map +1 -1
- package/dist/react/providers/MessageByIdProvider.js +28 -38
- package/dist/react/providers/MessageByIdProvider.js.map +1 -1
- package/dist/react/providers/MessageByIndexProvider.js +28 -38
- package/dist/react/providers/MessageByIndexProvider.js.map +1 -1
- package/dist/react/providers/PartByIndexProvider.js +17 -20
- package/dist/react/providers/PartByIndexProvider.js.map +1 -1
- package/dist/react/providers/QueueItemByIndexProvider.js +21 -21
- package/dist/react/providers/QueueItemByIndexProvider.js.map +1 -1
- package/dist/react/providers/ReadonlyThreadProvider.js +24 -32
- package/dist/react/providers/ReadonlyThreadProvider.js.map +1 -1
- package/dist/react/providers/SuggestionByIndexProvider.js +17 -20
- package/dist/react/providers/SuggestionByIndexProvider.js.map +1 -1
- package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -1
- package/dist/react/providers/TextMessagePartProvider.js +16 -19
- package/dist/react/providers/TextMessagePartProvider.js.map +1 -1
- package/dist/react/providers/ThreadListItemByIndexProvider.js +17 -20
- package/dist/react/providers/ThreadListItemByIndexProvider.js.map +1 -1
- package/dist/react/providers/ThreadListItemRuntimeProvider.js +15 -18
- package/dist/react/providers/ThreadListItemRuntimeProvider.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +7 -3
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +5 -2
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +3 -2
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/react/runtimes/useLocalRuntime.d.ts +3 -1
- package/dist/react/runtimes/useLocalRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/useLocalRuntime.js +4 -2
- package/dist/react/runtimes/useLocalRuntime.js.map +1 -1
- package/dist/runtime/api/composer-runtime.d.ts +5 -1
- package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
- package/dist/runtime/api/composer-runtime.js +8 -1
- package/dist/runtime/api/composer-runtime.js.map +1 -1
- package/dist/runtime/api/message-runtime.js +1 -1
- package/dist/runtime/api/message-runtime.js.map +1 -1
- package/dist/runtime/api/thread-runtime.d.ts +4 -2
- package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts +2 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.js +1 -1
- package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +3 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.js +14 -3
- package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
- package/dist/runtime/interfaces/composer-runtime-core.d.ts +2 -1
- package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts +3 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/queue/external-thread-queue-adapter.d.ts +19 -6
- package/dist/runtime/queue/external-thread-queue-adapter.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.d.ts +10 -1
- package/dist/runtime/queue/message-queue.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.js +138 -36
- package/dist/runtime/queue/message-queue.js.map +1 -1
- package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.js +2 -1
- package/dist/runtime/utils/thread-message-like.js.map +1 -1
- package/dist/runtimes/external-store/external-store-adapter.d.ts +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +3 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js +7 -6
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/local/local-runtime-options.d.ts +13 -0
- package/dist/runtimes/local/local-runtime-options.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts +5 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.js +30 -14
- package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.js +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.js.map +1 -1
- package/dist/runtimes/remote-thread-list/types.d.ts +6 -3
- package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.js +11 -4
- package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
- package/dist/store/scopes/composer.d.ts +7 -3
- package/dist/store/scopes/composer.d.ts.map +1 -1
- package/dist/store/scopes/queue-item.d.ts +10 -0
- package/dist/store/scopes/queue-item.d.ts.map +1 -1
- package/dist/store/scopes/queue-item.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +5 -1
- package/src/react/AssistantProvider.tsx +20 -18
- package/src/react/AssistantRuntimeProvider.test.tsx +55 -1
- package/src/react/AssistantRuntimeProvider.tsx +12 -2
- package/src/react/providers/AttachmentByIndexProvider.tsx +15 -7
- package/src/react/providers/ChainOfThoughtByIndicesProvider.tsx +12 -4
- package/src/react/providers/ChainOfThoughtPartByIndexProvider.tsx +8 -4
- package/src/react/providers/MessageByIdProvider.tsx +8 -4
- package/src/react/providers/MessageByIndexProvider.tsx +8 -4
- package/src/react/providers/PartByIndexProvider.tsx +8 -4
- package/src/react/providers/QueueItemByIndexProvider.tsx +9 -5
- package/src/react/providers/ReadonlyThreadProvider.tsx +9 -4
- package/src/react/providers/SuggestionByIndexProvider.tsx +8 -4
- package/src/react/providers/TextMessagePartProvider.tsx +13 -4
- package/src/react/providers/ThreadListItemByIndexProvider.tsx +8 -4
- package/src/react/providers/ThreadListItemRuntimeProvider.tsx +8 -4
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +19 -4
- package/src/react/runtimes/useLocalRuntime.ts +4 -0
- package/src/runtime/api/composer-runtime.ts +11 -2
- package/src/runtime/api/message-runtime.test.ts +25 -0
- package/src/runtime/api/message-runtime.ts +1 -1
- package/src/runtime/base/base-composer-runtime-core.ts +5 -1
- package/src/runtime/base/default-thread-composer-runtime-core.ts +27 -3
- package/src/runtime/interfaces/composer-runtime-core.ts +2 -1
- package/src/runtime/interfaces/thread-runtime-core.ts +3 -1
- package/src/runtime/queue/external-thread-queue-adapter.ts +19 -3
- package/src/runtime/queue/message-queue.ts +200 -38
- package/src/runtime/utils/thread-message-like.ts +2 -4
- package/src/runtimes/external-store/external-store-thread-runtime-core.ts +10 -8
- package/src/runtimes/local/local-runtime-options.ts +15 -0
- package/src/runtimes/local/local-thread-runtime-core.test.ts +43 -0
- package/src/runtimes/local/local-thread-runtime-core.ts +48 -13
- package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +1 -1
- package/src/runtimes/remote-thread-list/empty-thread-core.ts +1 -1
- package/src/runtimes/remote-thread-list/types.ts +9 -2
- package/src/store/runtime-clients/composer-runtime-client.ts +13 -5
- package/src/store/scopes/composer.ts +6 -4
- package/src/store/scopes/queue-item.ts +8 -1
- package/src/tests/external-store-thread-runtime-core.test.ts +56 -13
- package/src/tests/framework-neutral-boundary.test.ts +221 -0
- package/src/tests/message-queue.test.ts +494 -34
- package/src/tests/thread-message-like.test.ts +66 -0
package/src/index.ts
CHANGED
|
@@ -326,7 +326,10 @@ export type { ExternalStoreSharedOptions } from "./runtimes/external-store/exter
|
|
|
326
326
|
export { pickExternalStoreSharedOptions } from "./runtimes/external-store/external-store-shared-options";
|
|
327
327
|
|
|
328
328
|
// Message queue
|
|
329
|
-
export type {
|
|
329
|
+
export type {
|
|
330
|
+
ExternalThreadQueueAdapter,
|
|
331
|
+
QueuePlacement,
|
|
332
|
+
} from "./runtime/queue/external-thread-queue-adapter";
|
|
330
333
|
export type { ExternalThreadBranchAdapter } from "./runtime/branch/external-thread-branch-adapter";
|
|
331
334
|
export {
|
|
332
335
|
createMessageQueue,
|
|
@@ -338,6 +341,7 @@ export {
|
|
|
338
341
|
export type {
|
|
339
342
|
RemoteThreadListAdapter,
|
|
340
343
|
RemoteThreadListOptions,
|
|
344
|
+
RemoteThreadListProviderComponent,
|
|
341
345
|
RemoteThreadInitializeResponse,
|
|
342
346
|
RemoteThreadMetadata,
|
|
343
347
|
RemoteThreadListResponse,
|
|
@@ -4,7 +4,11 @@ import {
|
|
|
4
4
|
type FC,
|
|
5
5
|
type PropsWithChildren,
|
|
6
6
|
} from "react";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
AuiConfig,
|
|
9
|
+
AuiProvider,
|
|
10
|
+
type AssistantClient,
|
|
11
|
+
} from "@assistant-ui/store";
|
|
8
12
|
import type { AssistantRuntime } from "../runtime/api/assistant-runtime";
|
|
9
13
|
import type { AssistantRuntimeCore } from "../runtime/interfaces/assistant-runtime-core";
|
|
10
14
|
import { RuntimeAdapter } from "./RuntimeAdapter";
|
|
@@ -16,12 +20,17 @@ export const getRenderComponent = (runtime: AssistantRuntime) => {
|
|
|
16
20
|
|
|
17
21
|
export type AssistantProviderBaseProps = PropsWithChildren<{
|
|
18
22
|
runtime: AssistantRuntime;
|
|
19
|
-
aui?: AssistantClient | null;
|
|
23
|
+
aui?: AssistantClient | null | undefined;
|
|
24
|
+
config?: AuiConfig | undefined;
|
|
20
25
|
}>;
|
|
21
26
|
|
|
22
27
|
const AssistantProviderInner: FC<
|
|
23
|
-
PropsWithChildren<{
|
|
24
|
-
|
|
28
|
+
PropsWithChildren<{
|
|
29
|
+
runtime: AssistantRuntime;
|
|
30
|
+
aui: AssistantClient | null;
|
|
31
|
+
config: AuiConfig | undefined;
|
|
32
|
+
}>
|
|
33
|
+
> = ({ runtime, aui, config, children }) => {
|
|
25
34
|
// The runtime has a stable identity but mutates in place: its options are
|
|
26
35
|
// pushed in by an unconditional effect inside <RenderComponent />, so that
|
|
27
36
|
// element must be re-created every commit for React to re-render it and
|
|
@@ -29,10 +38,10 @@ const AssistantProviderInner: FC<
|
|
|
29
38
|
// stable RenderComponent type, which silences the effect and stops option
|
|
30
39
|
// changes (e.g. unstable_enableMessageQueue) from reaching the runtime.
|
|
31
40
|
"use no memo";
|
|
32
|
-
const aui = useAui({ threads: RuntimeAdapter(runtime) });
|
|
33
41
|
const RenderComponent = getRenderComponent(runtime);
|
|
42
|
+
const merged = AuiConfig({ ...config, threads: RuntimeAdapter(runtime) });
|
|
34
43
|
return (
|
|
35
|
-
<AuiProvider
|
|
44
|
+
<AuiProvider extends={aui} config={merged}>
|
|
36
45
|
{RenderComponent && <RenderComponent />}
|
|
37
46
|
{children}
|
|
38
47
|
</AuiProvider>
|
|
@@ -40,16 +49,9 @@ const AssistantProviderInner: FC<
|
|
|
40
49
|
};
|
|
41
50
|
|
|
42
51
|
export const AssistantProviderBase: FC<AssistantProviderBaseProps> = memo(
|
|
43
|
-
({ runtime, aui = null, children }) =>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
);
|
|
49
|
-
return aui ? (
|
|
50
|
-
<AuiProvider value={aui}>{inner}</AuiProvider>
|
|
51
|
-
) : (
|
|
52
|
-
<AuiProvider value={null}>{inner}</AuiProvider>
|
|
53
|
-
);
|
|
54
|
-
},
|
|
52
|
+
({ runtime, aui = null, config, children }) => (
|
|
53
|
+
<AssistantProviderInner runtime={runtime} aui={aui} config={config}>
|
|
54
|
+
{children}
|
|
55
|
+
</AssistantProviderInner>
|
|
56
|
+
),
|
|
55
57
|
);
|
|
@@ -5,7 +5,12 @@ import { useEffect } from "react";
|
|
|
5
5
|
import { cleanup, render } from "@testing-library/react";
|
|
6
6
|
import { afterEach, describe, expect, it } from "vitest";
|
|
7
7
|
import { resource } from "@assistant-ui/tap";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
AuiConfig,
|
|
10
|
+
AuiProvider,
|
|
11
|
+
useAui,
|
|
12
|
+
type AssistantClient,
|
|
13
|
+
} from "@assistant-ui/store";
|
|
9
14
|
import type { ChatModelAdapter } from "../runtime/utils/chat-model-adapter";
|
|
10
15
|
import { AssistantRuntimeProvider } from "./AssistantRuntimeProvider";
|
|
11
16
|
import { useLocalRuntime } from "./runtimes/useLocalRuntime";
|
|
@@ -98,4 +103,53 @@ describe("AssistantRuntimeProvider aui composition", () => {
|
|
|
98
103
|
expect(aui.parentScope.getState()).toEqual({ count: 0 });
|
|
99
104
|
expect(log).toEqual(["parent tap effect", "consumer effect"]);
|
|
100
105
|
});
|
|
106
|
+
|
|
107
|
+
it("provides config scopes alongside the runtime scope", () => {
|
|
108
|
+
let aui!: AnyClient;
|
|
109
|
+
const Consumer = () => {
|
|
110
|
+
aui = useAui();
|
|
111
|
+
return null;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const App = () => {
|
|
115
|
+
const runtime = useLocalRuntime(chatModel);
|
|
116
|
+
const config = AuiConfig({
|
|
117
|
+
extraScope: makeCounterClient()(),
|
|
118
|
+
} as unknown as AuiConfig.Input);
|
|
119
|
+
return (
|
|
120
|
+
<AssistantRuntimeProvider runtime={runtime} config={config}>
|
|
121
|
+
<Consumer />
|
|
122
|
+
</AssistantRuntimeProvider>
|
|
123
|
+
);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
render(<App />);
|
|
127
|
+
|
|
128
|
+
expect(aui.threads).toBeDefined();
|
|
129
|
+
expect(aui.extraScope.getState()).toEqual({ count: 0 });
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it("keeps the runtime's threads scope when config carries a threads key", () => {
|
|
133
|
+
let aui!: AnyClient;
|
|
134
|
+
const Consumer = () => {
|
|
135
|
+
aui = useAui();
|
|
136
|
+
return null;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const App = () => {
|
|
140
|
+
const runtime = useLocalRuntime(chatModel);
|
|
141
|
+
const config = AuiConfig({
|
|
142
|
+
threads: makeCounterClient()(),
|
|
143
|
+
} as unknown as AuiConfig.Input);
|
|
144
|
+
return (
|
|
145
|
+
<AssistantRuntimeProvider runtime={runtime} config={config}>
|
|
146
|
+
<Consumer />
|
|
147
|
+
</AssistantRuntimeProvider>
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
render(<App />);
|
|
152
|
+
|
|
153
|
+
expect(aui.threads.getState().main).toBeDefined();
|
|
154
|
+
});
|
|
101
155
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ReactNode, memo } from "react";
|
|
2
|
-
import type { AssistantClient } from "@assistant-ui/store";
|
|
2
|
+
import type { AssistantClient, AuiConfig } from "@assistant-ui/store";
|
|
3
3
|
import type { AssistantRuntime } from "../runtime/api/assistant-runtime";
|
|
4
4
|
import { AssistantProviderBase } from "./AssistantProvider";
|
|
5
5
|
|
|
@@ -29,6 +29,7 @@ export const AssistantRuntimeProvider = memo(
|
|
|
29
29
|
({
|
|
30
30
|
runtime,
|
|
31
31
|
aui,
|
|
32
|
+
config,
|
|
32
33
|
children,
|
|
33
34
|
}: {
|
|
34
35
|
/**
|
|
@@ -44,10 +45,19 @@ export const AssistantRuntimeProvider = memo(
|
|
|
44
45
|
* @defaultValue null
|
|
45
46
|
*/
|
|
46
47
|
aui?: AssistantClient | null;
|
|
48
|
+
/**
|
|
49
|
+
* Optional extra scopes provided alongside the runtime's `threads`
|
|
50
|
+
* scope; build with `AuiConfig`.
|
|
51
|
+
*/
|
|
52
|
+
config?: AuiConfig;
|
|
47
53
|
children: ReactNode;
|
|
48
54
|
}) => {
|
|
49
55
|
return (
|
|
50
|
-
<AssistantProviderBase
|
|
56
|
+
<AssistantProviderBase
|
|
57
|
+
runtime={runtime}
|
|
58
|
+
aui={aui ?? null}
|
|
59
|
+
config={config}
|
|
60
|
+
>
|
|
51
61
|
{children}
|
|
52
62
|
</AssistantProviderBase>
|
|
53
63
|
);
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import type { FC, PropsWithChildren } from "react";
|
|
2
|
-
import { useAui, AuiProvider, Derived } from "@assistant-ui/store";
|
|
2
|
+
import { useAui, AuiConfig, AuiProvider, Derived } from "@assistant-ui/store";
|
|
3
3
|
|
|
4
4
|
export const MessageAttachmentByIndexProvider: FC<
|
|
5
5
|
PropsWithChildren<{
|
|
6
6
|
index: number;
|
|
7
7
|
}>
|
|
8
8
|
> = ({ index, children }) => {
|
|
9
|
-
const aui = useAui(
|
|
9
|
+
const aui = useAui();
|
|
10
|
+
const config = AuiConfig({
|
|
10
11
|
attachment: Derived({
|
|
11
12
|
source: "message",
|
|
12
13
|
query: { type: "index", index },
|
|
13
14
|
get: (aui) => aui.message.attachment({ index }),
|
|
14
15
|
}),
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
return (
|
|
18
|
+
<AuiProvider extends={aui} config={config}>
|
|
19
|
+
{children}
|
|
20
|
+
</AuiProvider>
|
|
21
|
+
);
|
|
18
22
|
};
|
|
19
23
|
|
|
20
24
|
export const ComposerAttachmentByIndexProvider: FC<
|
|
@@ -22,13 +26,17 @@ export const ComposerAttachmentByIndexProvider: FC<
|
|
|
22
26
|
index: number;
|
|
23
27
|
}>
|
|
24
28
|
> = ({ index, children }) => {
|
|
25
|
-
const aui = useAui(
|
|
29
|
+
const aui = useAui();
|
|
30
|
+
const config = AuiConfig({
|
|
26
31
|
attachment: Derived({
|
|
27
32
|
source: "composer",
|
|
28
33
|
query: { type: "index", index },
|
|
29
34
|
get: (aui) => aui.composer.attachment({ index }),
|
|
30
35
|
}),
|
|
31
36
|
});
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
return (
|
|
38
|
+
<AuiProvider extends={aui} config={config}>
|
|
39
|
+
{children}
|
|
40
|
+
</AuiProvider>
|
|
41
|
+
);
|
|
34
42
|
};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { FC, PropsWithChildren } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
useAui,
|
|
4
|
+
useAuiState,
|
|
5
|
+
AuiConfig,
|
|
6
|
+
AuiProvider,
|
|
7
|
+
} from "@assistant-ui/store";
|
|
3
8
|
import { ChainOfThoughtClient } from "../../store/clients/chain-of-thought-client";
|
|
4
9
|
import type { ChainOfThoughtPart } from "../../store/scopes/chain-of-thought";
|
|
5
10
|
|
|
@@ -16,7 +21,7 @@ export const ChainOfThoughtByIndicesProvider: FC<
|
|
|
16
21
|
|
|
17
22
|
const parentAui = useAui();
|
|
18
23
|
|
|
19
|
-
const
|
|
24
|
+
const config = AuiConfig({
|
|
20
25
|
chainOfThought: ChainOfThoughtClient({
|
|
21
26
|
parts,
|
|
22
27
|
getMessagePart: ({ index }) => {
|
|
@@ -29,6 +34,9 @@ export const ChainOfThoughtByIndicesProvider: FC<
|
|
|
29
34
|
},
|
|
30
35
|
}),
|
|
31
36
|
});
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
return (
|
|
38
|
+
<AuiProvider extends={parentAui} config={config}>
|
|
39
|
+
{children}
|
|
40
|
+
</AuiProvider>
|
|
41
|
+
);
|
|
34
42
|
};
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import type { FC, PropsWithChildren } from "react";
|
|
2
|
-
import { useAui, AuiProvider, Derived } from "@assistant-ui/store";
|
|
2
|
+
import { useAui, AuiConfig, AuiProvider, Derived } from "@assistant-ui/store";
|
|
3
3
|
|
|
4
4
|
export const ChainOfThoughtPartByIndexProvider: FC<
|
|
5
5
|
PropsWithChildren<{
|
|
6
6
|
index: number;
|
|
7
7
|
}>
|
|
8
8
|
> = ({ index, children }) => {
|
|
9
|
-
const aui = useAui(
|
|
9
|
+
const aui = useAui();
|
|
10
|
+
const config = AuiConfig({
|
|
10
11
|
part: Derived({
|
|
11
12
|
source: "chainOfThought",
|
|
12
13
|
query: { type: "index", index },
|
|
13
14
|
get: (aui) => aui.chainOfThought.part({ index }),
|
|
14
15
|
}),
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
return (
|
|
18
|
+
<AuiProvider extends={aui} config={config}>
|
|
19
|
+
{children}
|
|
20
|
+
</AuiProvider>
|
|
21
|
+
);
|
|
18
22
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { FC, PropsWithChildren } from "react";
|
|
2
|
-
import { useAui, AuiProvider, Derived } from "@assistant-ui/store";
|
|
2
|
+
import { useAui, AuiConfig, AuiProvider, Derived } from "@assistant-ui/store";
|
|
3
3
|
|
|
4
4
|
export const MessageByIdProvider: FC<
|
|
5
5
|
PropsWithChildren<{
|
|
6
6
|
id: string;
|
|
7
7
|
}>
|
|
8
8
|
> = ({ id, children }) => {
|
|
9
|
-
const aui = useAui(
|
|
9
|
+
const aui = useAui();
|
|
10
|
+
const config = AuiConfig({
|
|
10
11
|
message: Derived({
|
|
11
12
|
source: "thread",
|
|
12
13
|
query: { type: "id", id },
|
|
@@ -18,6 +19,9 @@ export const MessageByIdProvider: FC<
|
|
|
18
19
|
get: (aui) => aui.thread.message({ id }).composer(),
|
|
19
20
|
}),
|
|
20
21
|
});
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
return (
|
|
23
|
+
<AuiProvider extends={aui} config={config}>
|
|
24
|
+
{children}
|
|
25
|
+
</AuiProvider>
|
|
26
|
+
);
|
|
23
27
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { FC, PropsWithChildren } from "react";
|
|
2
|
-
import { useAui, AuiProvider, Derived } from "@assistant-ui/store";
|
|
2
|
+
import { useAui, AuiConfig, AuiProvider, Derived } from "@assistant-ui/store";
|
|
3
3
|
|
|
4
4
|
export const MessageByIndexProvider: FC<
|
|
5
5
|
PropsWithChildren<{
|
|
6
6
|
index: number;
|
|
7
7
|
}>
|
|
8
8
|
> = ({ index, children }) => {
|
|
9
|
-
const aui = useAui(
|
|
9
|
+
const aui = useAui();
|
|
10
|
+
const config = AuiConfig({
|
|
10
11
|
message: Derived({
|
|
11
12
|
source: "thread",
|
|
12
13
|
query: { type: "index", index },
|
|
@@ -18,6 +19,9 @@ export const MessageByIndexProvider: FC<
|
|
|
18
19
|
get: (aui) => aui.thread.message({ index }).composer(),
|
|
19
20
|
}),
|
|
20
21
|
});
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
return (
|
|
23
|
+
<AuiProvider extends={aui} config={config}>
|
|
24
|
+
{children}
|
|
25
|
+
</AuiProvider>
|
|
26
|
+
);
|
|
23
27
|
};
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import type { FC, PropsWithChildren } from "react";
|
|
2
|
-
import { useAui, AuiProvider, Derived } from "@assistant-ui/store";
|
|
2
|
+
import { useAui, AuiConfig, AuiProvider, Derived } from "@assistant-ui/store";
|
|
3
3
|
|
|
4
4
|
export const PartByIndexProvider: FC<
|
|
5
5
|
PropsWithChildren<{
|
|
6
6
|
index: number;
|
|
7
7
|
}>
|
|
8
8
|
> = ({ index, children }) => {
|
|
9
|
-
const aui = useAui(
|
|
9
|
+
const aui = useAui();
|
|
10
|
+
const config = AuiConfig({
|
|
10
11
|
part: Derived({
|
|
11
12
|
source: "message",
|
|
12
13
|
query: { type: "index", index },
|
|
13
14
|
get: (aui) => aui.message.part({ index }),
|
|
14
15
|
}),
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
return (
|
|
18
|
+
<AuiProvider extends={aui} config={config}>
|
|
19
|
+
{children}
|
|
20
|
+
</AuiProvider>
|
|
21
|
+
);
|
|
18
22
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FC, PropsWithChildren } from "react";
|
|
2
|
-
import { AuiProvider, Derived
|
|
2
|
+
import { useAui, AuiConfig, AuiProvider, Derived } from "@assistant-ui/store";
|
|
3
3
|
|
|
4
4
|
export type QueueItemByIndexProviderProps = PropsWithChildren<{
|
|
5
5
|
index: number;
|
|
@@ -9,13 +9,17 @@ export const QueueItemByIndexProvider: FC<QueueItemByIndexProviderProps> = ({
|
|
|
9
9
|
index,
|
|
10
10
|
children,
|
|
11
11
|
}) => {
|
|
12
|
-
const aui = useAui(
|
|
12
|
+
const aui = useAui();
|
|
13
|
+
const config = AuiConfig({
|
|
13
14
|
queueItem: Derived({
|
|
14
15
|
source: "composer",
|
|
15
|
-
query: { index },
|
|
16
|
+
query: { type: "index", index },
|
|
16
17
|
get: (aui) => aui.composer.queueItem({ index }),
|
|
17
18
|
}),
|
|
18
19
|
});
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
return (
|
|
21
|
+
<AuiProvider extends={aui} config={config}>
|
|
22
|
+
{children}
|
|
23
|
+
</AuiProvider>
|
|
24
|
+
);
|
|
21
25
|
};
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
useMemo,
|
|
6
6
|
useState,
|
|
7
7
|
} from "react";
|
|
8
|
-
import { useAui, AuiProvider, Derived } from "@assistant-ui/store";
|
|
8
|
+
import { useAui, AuiConfig, AuiProvider, Derived } from "@assistant-ui/store";
|
|
9
9
|
import type { ThreadMessage } from "../../types/message";
|
|
10
10
|
import { ReadonlyThreadRuntimeCore } from "../../runtimes/readonly/ReadonlyThreadRuntimeCore";
|
|
11
11
|
import {
|
|
@@ -72,7 +72,9 @@ export const ReadonlyThreadProvider: FC<ReadonlyThreadProvider.Props> = ({
|
|
|
72
72
|
);
|
|
73
73
|
}, [core]);
|
|
74
74
|
|
|
75
|
-
const aui = useAui(
|
|
75
|
+
const aui = useAui();
|
|
76
|
+
|
|
77
|
+
const config = AuiConfig({
|
|
76
78
|
thread: ThreadClient({ runtime: threadRuntime }),
|
|
77
79
|
composer: Derived({
|
|
78
80
|
source: "thread",
|
|
@@ -80,6 +82,9 @@ export const ReadonlyThreadProvider: FC<ReadonlyThreadProvider.Props> = ({
|
|
|
80
82
|
get: (aui) => aui.thread.composer(),
|
|
81
83
|
}),
|
|
82
84
|
});
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
return (
|
|
86
|
+
<AuiProvider extends={aui} config={config}>
|
|
87
|
+
{children}
|
|
88
|
+
</AuiProvider>
|
|
89
|
+
);
|
|
85
90
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FC, PropsWithChildren } from "react";
|
|
2
|
-
import { AuiProvider, Derived
|
|
2
|
+
import { useAui, AuiConfig, AuiProvider, Derived } from "@assistant-ui/store";
|
|
3
3
|
|
|
4
4
|
export type SuggestionByIndexProviderProps = PropsWithChildren<{
|
|
5
5
|
index: number;
|
|
@@ -9,13 +9,17 @@ export const SuggestionByIndexProvider: FC<SuggestionByIndexProviderProps> = ({
|
|
|
9
9
|
index,
|
|
10
10
|
children,
|
|
11
11
|
}) => {
|
|
12
|
-
const aui = useAui(
|
|
12
|
+
const aui = useAui();
|
|
13
|
+
const config = AuiConfig({
|
|
13
14
|
suggestion: Derived({
|
|
14
15
|
source: "suggestions",
|
|
15
16
|
query: { index },
|
|
16
17
|
get: (aui) => aui.suggestions.suggestion({ index }),
|
|
17
18
|
}),
|
|
18
19
|
});
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
return (
|
|
21
|
+
<AuiProvider extends={aui} config={config}>
|
|
22
|
+
{children}
|
|
23
|
+
</AuiProvider>
|
|
24
|
+
);
|
|
21
25
|
};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { type FC, type PropsWithChildren, useMemo } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
useAui,
|
|
4
|
+
AuiConfig,
|
|
5
|
+
AuiProvider,
|
|
6
|
+
type ClientOutput,
|
|
7
|
+
} from "@assistant-ui/store";
|
|
3
8
|
import type { PartState } from "../../store/scopes/part";
|
|
4
9
|
|
|
5
10
|
import { resource } from "@assistant-ui/tap";
|
|
@@ -42,9 +47,13 @@ export const TextMessagePartProvider: FC<
|
|
|
42
47
|
isRunning?: boolean;
|
|
43
48
|
}>
|
|
44
49
|
> = ({ text, isRunning = false, children }) => {
|
|
45
|
-
const aui = useAui(
|
|
50
|
+
const aui = useAui();
|
|
51
|
+
const config = AuiConfig({
|
|
46
52
|
part: TextMessagePartClient({ text, isRunning }),
|
|
47
53
|
});
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
return (
|
|
55
|
+
<AuiProvider extends={aui} config={config}>
|
|
56
|
+
{children}
|
|
57
|
+
</AuiProvider>
|
|
58
|
+
);
|
|
50
59
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FC, PropsWithChildren } from "react";
|
|
2
|
-
import { useAui, AuiProvider, Derived } from "@assistant-ui/store";
|
|
2
|
+
import { useAui, AuiConfig, AuiProvider, Derived } from "@assistant-ui/store";
|
|
3
3
|
|
|
4
4
|
export const ThreadListItemByIndexProvider: FC<
|
|
5
5
|
PropsWithChildren<{
|
|
@@ -7,13 +7,17 @@ export const ThreadListItemByIndexProvider: FC<
|
|
|
7
7
|
archived: boolean;
|
|
8
8
|
}>
|
|
9
9
|
> = ({ index, archived, children }) => {
|
|
10
|
-
const aui = useAui(
|
|
10
|
+
const aui = useAui();
|
|
11
|
+
const config = AuiConfig({
|
|
11
12
|
threadListItem: Derived({
|
|
12
13
|
source: "threads",
|
|
13
14
|
query: { type: "index", index, archived },
|
|
14
15
|
get: (aui) => aui.threads.item({ index, archived }),
|
|
15
16
|
}),
|
|
16
17
|
});
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
return (
|
|
19
|
+
<AuiProvider extends={aui} config={config}>
|
|
20
|
+
{children}
|
|
21
|
+
</AuiProvider>
|
|
22
|
+
);
|
|
19
23
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FC, PropsWithChildren } from "react";
|
|
2
|
-
import { useAui, AuiProvider } from "@assistant-ui/store";
|
|
2
|
+
import { useAui, AuiConfig, AuiProvider } from "@assistant-ui/store";
|
|
3
3
|
import type { ThreadListItemRuntime } from "../..";
|
|
4
4
|
import { ThreadListItemClient } from "../../store/internal";
|
|
5
5
|
|
|
@@ -8,9 +8,13 @@ export const ThreadListItemRuntimeProvider: FC<
|
|
|
8
8
|
runtime: ThreadListItemRuntime;
|
|
9
9
|
}>
|
|
10
10
|
> = ({ runtime, children }) => {
|
|
11
|
-
const aui = useAui(
|
|
11
|
+
const aui = useAui();
|
|
12
|
+
const config = AuiConfig({
|
|
12
13
|
threadListItem: ThreadListItemClient({ runtime }),
|
|
13
14
|
});
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
return (
|
|
16
|
+
<AuiProvider extends={aui} config={config}>
|
|
17
|
+
{children}
|
|
18
|
+
</AuiProvider>
|
|
19
|
+
);
|
|
16
20
|
};
|
|
@@ -14,14 +14,29 @@ import {
|
|
|
14
14
|
normalizeCursor,
|
|
15
15
|
updateStatusReducer,
|
|
16
16
|
} from "../../runtimes/remote-thread-list/remote-thread-state";
|
|
17
|
-
import type {
|
|
17
|
+
import type {
|
|
18
|
+
RemoteThreadListOptions,
|
|
19
|
+
RemoteThreadListProviderComponent,
|
|
20
|
+
} from "../../runtimes/remote-thread-list/types";
|
|
18
21
|
import { RemoteThreadListHookInstanceManager } from "./RemoteThreadListHookInstanceManager";
|
|
19
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
type ComponentType,
|
|
24
|
+
type FC,
|
|
25
|
+
Fragment,
|
|
26
|
+
type PropsWithChildren,
|
|
27
|
+
useEffect,
|
|
28
|
+
useId,
|
|
29
|
+
} from "react";
|
|
20
30
|
import { create } from "zustand";
|
|
21
31
|
import { AssistantMessageStream } from "assistant-stream";
|
|
22
32
|
import type { ModelContextProvider } from "../../model-context/types";
|
|
23
33
|
import { RuntimeAdapterProvider } from "./RuntimeAdapterProvider";
|
|
24
34
|
|
|
35
|
+
const asProviderComponent = (
|
|
36
|
+
provider: RemoteThreadListProviderComponent | undefined,
|
|
37
|
+
): ComponentType<PropsWithChildren> =>
|
|
38
|
+
(provider ?? Fragment) as ComponentType<PropsWithChildren>;
|
|
39
|
+
|
|
25
40
|
const threadNotFoundError = (threadIdOrRemoteId: string, action: string) =>
|
|
26
41
|
new Error(`Thread "${threadIdOrRemoteId}" not found while ${action}.`);
|
|
27
42
|
|
|
@@ -189,7 +204,7 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
|
189
204
|
this._notifySubscribers(),
|
|
190
205
|
);
|
|
191
206
|
this.useProvider = create(() => ({
|
|
192
|
-
Provider: options.adapter.unstable_Provider
|
|
207
|
+
Provider: asProviderComponent(options.adapter.unstable_Provider),
|
|
193
208
|
}));
|
|
194
209
|
this.__internal_setOptions(options);
|
|
195
210
|
this.switchToNewThread();
|
|
@@ -210,7 +225,7 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
|
210
225
|
|
|
211
226
|
this._options = options;
|
|
212
227
|
|
|
213
|
-
const Provider = options.adapter.unstable_Provider
|
|
228
|
+
const Provider = asProviderComponent(options.adapter.unstable_Provider);
|
|
214
229
|
if (Provider !== this.useProvider.getState().Provider) {
|
|
215
230
|
this.useProvider.setState({ Provider }, true);
|
|
216
231
|
}
|
|
@@ -84,6 +84,8 @@ export const splitLocalRuntimeOptions = <T extends LocalRuntimeOptions>(
|
|
|
84
84
|
adapters,
|
|
85
85
|
unstable_humanToolNames,
|
|
86
86
|
unstable_enableMessageQueue,
|
|
87
|
+
unstable_queueClearOnRewind,
|
|
88
|
+
unstable_queueClearOnCancel,
|
|
87
89
|
...rest
|
|
88
90
|
} = options;
|
|
89
91
|
|
|
@@ -95,6 +97,8 @@ export const splitLocalRuntimeOptions = <T extends LocalRuntimeOptions>(
|
|
|
95
97
|
adapters,
|
|
96
98
|
unstable_humanToolNames,
|
|
97
99
|
unstable_enableMessageQueue,
|
|
100
|
+
unstable_queueClearOnRewind,
|
|
101
|
+
unstable_queueClearOnCancel,
|
|
98
102
|
},
|
|
99
103
|
otherOptions: rest,
|
|
100
104
|
};
|
|
@@ -4,6 +4,7 @@ import type { QuoteInfo } from "../../types/quote";
|
|
|
4
4
|
import type { Unsubscribe } from "../../types/unsubscribe";
|
|
5
5
|
import type { RunConfig } from "../../types/message";
|
|
6
6
|
import type { QueueItemState } from "../../store/scopes/queue-item";
|
|
7
|
+
import type { QueuePlacement } from "../queue/external-thread-queue-adapter";
|
|
7
8
|
import {
|
|
8
9
|
LazyMemoizeSubject,
|
|
9
10
|
EventSubscriptionSubject,
|
|
@@ -200,9 +201,12 @@ export type ComposerRuntime = {
|
|
|
200
201
|
*/
|
|
201
202
|
cancel(): void;
|
|
202
203
|
|
|
203
|
-
/**
|
|
204
|
+
/** @deprecated Use `moveQueueItem(queueItemId, { lane: "steer", insertAfter: null })` instead. Removal after 2026-11-05. */
|
|
204
205
|
steerQueueItem(queueItemId: string): void;
|
|
205
206
|
|
|
207
|
+
/** Move a queued message between lanes or within a lane. */
|
|
208
|
+
moveQueueItem(queueItemId: string, placement: QueuePlacement): void;
|
|
209
|
+
|
|
206
210
|
/** Remove a queued message. */
|
|
207
211
|
removeQueueItem(queueItemId: string): void;
|
|
208
212
|
|
|
@@ -268,6 +272,7 @@ export abstract class ComposerRuntimeImpl implements ComposerRuntime {
|
|
|
268
272
|
this.send = this.send.bind(this);
|
|
269
273
|
this.cancel = this.cancel.bind(this);
|
|
270
274
|
this.steerQueueItem = this.steerQueueItem.bind(this);
|
|
275
|
+
this.moveQueueItem = this.moveQueueItem.bind(this);
|
|
271
276
|
this.removeQueueItem = this.removeQueueItem.bind(this);
|
|
272
277
|
this.setRole = this.setRole.bind(this);
|
|
273
278
|
this.getAttachmentByIndex = this.getAttachmentByIndex.bind(this);
|
|
@@ -322,9 +327,13 @@ export abstract class ComposerRuntimeImpl implements ComposerRuntime {
|
|
|
322
327
|
}
|
|
323
328
|
|
|
324
329
|
public steerQueueItem(queueItemId: string) {
|
|
330
|
+
this.moveQueueItem(queueItemId, { lane: "steer", insertAfter: null });
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
public moveQueueItem(queueItemId: string, placement: QueuePlacement) {
|
|
325
334
|
const core = this._core.getState();
|
|
326
335
|
if (!core) throw new Error("Composer is not available");
|
|
327
|
-
core.
|
|
336
|
+
core.moveQueueItem(queueItemId, placement);
|
|
328
337
|
}
|
|
329
338
|
|
|
330
339
|
public removeQueueItem(queueItemId: string) {
|