@assistant-ui/core 0.3.5 → 0.3.7
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 +4 -4
- 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/RuntimeAdapter.js +1 -1
- package/dist/react/RuntimeAdapter.js.map +1 -1
- package/dist/react/client/Interactables.js +1 -1
- package/dist/react/client/Interactables.js.map +1 -1
- package/dist/react/client/Tools.d.ts +1 -1
- package/dist/react/client/Tools.js +1 -1
- package/dist/react/client/Tools.js.map +1 -1
- package/dist/react/index.d.ts +9 -9
- package/dist/react/index.js +4 -4
- package/dist/react/model-context/interactableTool.d.ts +1 -1
- package/dist/react/model-context/useAssistantTool.d.ts +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/createMessageConverter.d.ts +1 -1
- package/dist/react/runtimes/createRuntimeExtras.d.ts +4 -1
- package/dist/react/runtimes/createRuntimeExtras.d.ts.map +1 -1
- package/dist/react/runtimes/createRuntimeExtras.js +6 -17
- package/dist/react/runtimes/createRuntimeExtras.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/react/types/scopes/dataRenderers.d.ts +1 -1
- package/dist/react/types/scopes/interactables.d.ts +1 -1
- package/dist/react/types/scopes/tools.d.ts +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/runtime-extras-brand.d.ts +21 -0
- package/dist/runtime/utils/runtime-extras-brand.d.ts.map +1 -0
- package/dist/runtime/utils/runtime-extras-brand.js +37 -0
- package/dist/runtime/utils/runtime-extras-brand.js.map +1 -0
- 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/clients/runtime-adapter.d.ts.map +1 -1
- package/dist/store/clients/runtime-adapter.js +1 -1
- package/dist/store/clients/runtime-adapter.js.map +1 -1
- package/dist/store/clients/suggestions.js +1 -1
- package/dist/store/clients/suggestions.js.map +1 -1
- package/dist/store/clients/thread-message-client.js +1 -1
- package/dist/store/clients/thread-message-client.js.map +1 -1
- package/dist/store/index.d.ts +10 -1
- package/dist/store/index.js +7 -1
- package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.js +12 -5
- package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.js +1 -1
- package/dist/store/runtime-clients/message-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.js +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.js +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.js +1 -1
- package/dist/store/runtime-clients/thread-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 +15 -15
- 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/RuntimeAdapter.test.ts +85 -0
- package/src/react/RuntimeAdapter.ts +1 -1
- package/src/react/client/Interactables.test.ts +3 -2
- package/src/react/client/Interactables.ts +4 -4
- package/src/react/client/Tools.ts +4 -4
- package/src/react/index.ts +1 -0
- 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/createRuntimeExtras.test.ts +14 -1
- package/src/react/runtimes/createRuntimeExtras.ts +15 -26
- 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/runtime-extras-brand.ts +47 -0
- 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/clients/runtime-adapter.ts +2 -5
- package/src/store/clients/suggestions.ts +1 -1
- package/src/store/clients/thread-message-client.ts +1 -1
- package/src/store/index.ts +31 -0
- package/src/store/runtime-clients/composer-runtime-client.ts +15 -10
- package/src/store/runtime-clients/message-runtime-client.ts +2 -5
- package/src/store/runtime-clients/thread-list-item-runtime-client.ts +2 -1
- package/src/store/runtime-clients/thread-list-runtime-client.ts +2 -5
- package/src/store/runtime-clients/thread-runtime-client.ts +2 -2
- 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 +257 -0
- package/src/tests/message-queue.test.ts +494 -34
- package/src/tests/thread-message-like.test.ts +66 -0
- package/LICENSE +0 -21
|
@@ -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
|
);
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { flushTapSync } from "@assistant-ui/tap";
|
|
3
|
+
import { AuiConfig, createAssistantClient } from "@assistant-ui/store/client";
|
|
4
|
+
import { RuntimeAdapter } from "../store";
|
|
5
|
+
import { ExternalStoreRuntimeCore } from "../runtimes/internal";
|
|
6
|
+
import { AssistantRuntimeImpl } from "../runtime/internal";
|
|
7
|
+
import type { ExternalStoreAdapter } from "../runtimes/external-store/external-store-adapter";
|
|
8
|
+
|
|
9
|
+
type DemoMessage = { role: "user" | "assistant"; text: string };
|
|
10
|
+
|
|
11
|
+
const createRuntime = (
|
|
12
|
+
overrides?: Partial<ExternalStoreAdapter<DemoMessage>>,
|
|
13
|
+
) => {
|
|
14
|
+
const onNew = vi.fn(async () => {});
|
|
15
|
+
const adapter: ExternalStoreAdapter<DemoMessage> = {
|
|
16
|
+
messages: [{ role: "user", text: "hi" }],
|
|
17
|
+
convertMessage: (message) => ({
|
|
18
|
+
role: message.role,
|
|
19
|
+
content: [{ type: "text", text: message.text }],
|
|
20
|
+
}),
|
|
21
|
+
onNew,
|
|
22
|
+
...overrides,
|
|
23
|
+
};
|
|
24
|
+
const runtime = new AssistantRuntimeImpl(
|
|
25
|
+
new ExternalStoreRuntimeCore(adapter),
|
|
26
|
+
);
|
|
27
|
+
return { runtime, onNew };
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
describe("RuntimeAdapter via the neutral store entry", () => {
|
|
31
|
+
it("mounts a runtime into a standalone client without React", () => {
|
|
32
|
+
const { runtime } = createRuntime();
|
|
33
|
+
const handle = createAssistantClient(
|
|
34
|
+
AuiConfig({ threads: RuntimeAdapter(runtime) }),
|
|
35
|
+
);
|
|
36
|
+
const aui = handle.getClient();
|
|
37
|
+
|
|
38
|
+
const messages = aui.thread.getState().messages;
|
|
39
|
+
expect(messages).toHaveLength(1);
|
|
40
|
+
expect(messages[0]!.content[0]).toMatchObject({
|
|
41
|
+
type: "text",
|
|
42
|
+
text: "hi",
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
expect(aui.threads.getState().mainThreadId).toBeDefined();
|
|
46
|
+
expect(aui.tools.getState()).toBeDefined();
|
|
47
|
+
expect(aui.dataRenderers.getState()).toBeDefined();
|
|
48
|
+
|
|
49
|
+
handle.destroy();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("routes composer sends to the external store adapter", async () => {
|
|
53
|
+
const { runtime, onNew } = createRuntime();
|
|
54
|
+
const handle = createAssistantClient(
|
|
55
|
+
AuiConfig({ threads: RuntimeAdapter(runtime) }),
|
|
56
|
+
);
|
|
57
|
+
const aui = handle.getClient();
|
|
58
|
+
|
|
59
|
+
flushTapSync(() => aui.composer.setText("hello"));
|
|
60
|
+
flushTapSync(() => aui.composer.send());
|
|
61
|
+
await new Promise((resolve) => setTimeout(resolve));
|
|
62
|
+
|
|
63
|
+
expect(onNew).toHaveBeenCalledTimes(1);
|
|
64
|
+
expect(onNew.mock.calls[0]![0]).toMatchObject({
|
|
65
|
+
content: [{ type: "text", text: "hello" }],
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
handle.destroy();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("registers the client's model context on the runtime", () => {
|
|
72
|
+
const { runtime } = createRuntime();
|
|
73
|
+
const register = vi.spyOn(runtime, "registerModelContextProvider");
|
|
74
|
+
|
|
75
|
+
const handle = createAssistantClient(
|
|
76
|
+
AuiConfig({ threads: RuntimeAdapter(runtime) }),
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
// Dev mode double-mounts the root (StrictMode emulation), so assert
|
|
80
|
+
// presence rather than an exact count
|
|
81
|
+
expect(register).toHaveBeenCalled();
|
|
82
|
+
|
|
83
|
+
handle.destroy();
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -9,8 +9,9 @@ import type { ThreadMessage } from "../../types/message";
|
|
|
9
9
|
|
|
10
10
|
const clientHolder: { client: unknown } = { client: null };
|
|
11
11
|
|
|
12
|
-
vi.mock("@assistant-ui/store", async (importOriginal) => {
|
|
13
|
-
const actual =
|
|
12
|
+
vi.mock("@assistant-ui/store/client", async (importOriginal) => {
|
|
13
|
+
const actual =
|
|
14
|
+
await importOriginal<typeof import("@assistant-ui/store/client")>();
|
|
14
15
|
return {
|
|
15
16
|
...actual,
|
|
16
17
|
useAssistantClientRef: () => ({
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useState, useEffect, useCallback, useRef, useMemo } from "react";
|
|
2
2
|
import { resource } from "@assistant-ui/tap";
|
|
3
|
+
import type { ClientOutput } from "@assistant-ui/store";
|
|
3
4
|
import {
|
|
4
|
-
useAssistantClientRef,
|
|
5
|
-
type ClientOutput,
|
|
6
5
|
attachTransformScopes,
|
|
7
|
-
|
|
6
|
+
useAssistantClientRef,
|
|
7
|
+
} from "@assistant-ui/store/client";
|
|
8
8
|
import type {
|
|
9
9
|
Unstable_InteractablesState,
|
|
10
10
|
Unstable_InteractableRegistration,
|
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
Unstable_InteractablesConfig,
|
|
14
14
|
} from "../types/scopes/interactables";
|
|
15
15
|
import { toJSONSchema, toPartialJSONSchema } from "assistant-stream";
|
|
16
|
-
import { ModelContext } from "../../store";
|
|
16
|
+
import { ModelContext } from "../../store/clients/model-context-client";
|
|
17
17
|
import {
|
|
18
18
|
buildInteractableModelContext,
|
|
19
19
|
type PartialJSONSchema,
|
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
withKey,
|
|
6
6
|
type ResourceElement,
|
|
7
7
|
} from "@assistant-ui/tap";
|
|
8
|
+
import type { ClientOutput } from "@assistant-ui/store";
|
|
8
9
|
import {
|
|
9
|
-
useAssistantClientRef,
|
|
10
|
-
type ClientOutput,
|
|
11
10
|
attachTransformScopes,
|
|
12
|
-
|
|
11
|
+
useAssistantClientRef,
|
|
12
|
+
} from "@assistant-ui/store/client";
|
|
13
13
|
import type { McpAppResourceOutput, ToolsState } from "../types/scopes/tools";
|
|
14
14
|
import type { Tool } from "assistant-stream";
|
|
15
15
|
import {
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
type Toolkit,
|
|
19
19
|
} from "../model-context/toolbox";
|
|
20
20
|
import type { ToolCallMessagePartComponent } from "../types/MessagePartComponentTypes";
|
|
21
|
-
import { ModelContext } from "../../store";
|
|
21
|
+
import { ModelContext } from "../../store/clients/model-context-client";
|
|
22
22
|
|
|
23
23
|
export type { McpAppResourceOutput };
|
|
24
24
|
|
package/src/react/index.ts
CHANGED
|
@@ -228,6 +228,7 @@ export {
|
|
|
228
228
|
} from "./runtimes/useStreamingTiming";
|
|
229
229
|
export {
|
|
230
230
|
createRuntimeExtras,
|
|
231
|
+
unstable_createRuntimeExtrasFromBrand,
|
|
231
232
|
type RuntimeExtras,
|
|
232
233
|
} from "./runtimes/createRuntimeExtras";
|
|
233
234
|
export { RemoteThreadListHookInstanceManager } from "./runtimes/RemoteThreadListHookInstanceManager";
|
|
@@ -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
|
};
|