@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.
Files changed (146) hide show
  1. package/dist/index.d.ts +3 -3
  2. package/dist/index.js.map +1 -1
  3. package/dist/internal.js +1 -1
  4. package/dist/react/AssistantProvider.d.ts +3 -2
  5. package/dist/react/AssistantProvider.d.ts.map +1 -1
  6. package/dist/react/AssistantProvider.js +19 -26
  7. package/dist/react/AssistantProvider.js.map +1 -1
  8. package/dist/react/AssistantRuntimeProvider.d.ts +7 -2
  9. package/dist/react/AssistantRuntimeProvider.d.ts.map +1 -1
  10. package/dist/react/AssistantRuntimeProvider.js +9 -7
  11. package/dist/react/AssistantRuntimeProvider.js.map +1 -1
  12. package/dist/react/providers/AttachmentByIndexProvider.d.ts.map +1 -1
  13. package/dist/react/providers/AttachmentByIndexProvider.js +33 -39
  14. package/dist/react/providers/AttachmentByIndexProvider.js.map +1 -1
  15. package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts.map +1 -1
  16. package/dist/react/providers/ChainOfThoughtByIndicesProvider.js +15 -20
  17. package/dist/react/providers/ChainOfThoughtByIndicesProvider.js.map +1 -1
  18. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js +17 -20
  19. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js.map +1 -1
  20. package/dist/react/providers/MessageByIdProvider.js +28 -38
  21. package/dist/react/providers/MessageByIdProvider.js.map +1 -1
  22. package/dist/react/providers/MessageByIndexProvider.js +28 -38
  23. package/dist/react/providers/MessageByIndexProvider.js.map +1 -1
  24. package/dist/react/providers/PartByIndexProvider.js +17 -20
  25. package/dist/react/providers/PartByIndexProvider.js.map +1 -1
  26. package/dist/react/providers/QueueItemByIndexProvider.js +21 -21
  27. package/dist/react/providers/QueueItemByIndexProvider.js.map +1 -1
  28. package/dist/react/providers/ReadonlyThreadProvider.js +24 -32
  29. package/dist/react/providers/ReadonlyThreadProvider.js.map +1 -1
  30. package/dist/react/providers/SuggestionByIndexProvider.js +17 -20
  31. package/dist/react/providers/SuggestionByIndexProvider.js.map +1 -1
  32. package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -1
  33. package/dist/react/providers/TextMessagePartProvider.js +16 -19
  34. package/dist/react/providers/TextMessagePartProvider.js.map +1 -1
  35. package/dist/react/providers/ThreadListItemByIndexProvider.js +17 -20
  36. package/dist/react/providers/ThreadListItemByIndexProvider.js.map +1 -1
  37. package/dist/react/providers/ThreadListItemRuntimeProvider.js +15 -18
  38. package/dist/react/providers/ThreadListItemRuntimeProvider.js.map +1 -1
  39. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +7 -3
  40. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
  41. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +5 -2
  42. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
  43. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +3 -2
  44. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
  45. package/dist/react/runtimes/useLocalRuntime.d.ts +3 -1
  46. package/dist/react/runtimes/useLocalRuntime.d.ts.map +1 -1
  47. package/dist/react/runtimes/useLocalRuntime.js +4 -2
  48. package/dist/react/runtimes/useLocalRuntime.js.map +1 -1
  49. package/dist/runtime/api/composer-runtime.d.ts +5 -1
  50. package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
  51. package/dist/runtime/api/composer-runtime.js +8 -1
  52. package/dist/runtime/api/composer-runtime.js.map +1 -1
  53. package/dist/runtime/api/message-runtime.js +1 -1
  54. package/dist/runtime/api/message-runtime.js.map +1 -1
  55. package/dist/runtime/api/thread-runtime.d.ts +4 -2
  56. package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
  57. package/dist/runtime/base/base-composer-runtime-core.d.ts +2 -1
  58. package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
  59. package/dist/runtime/base/base-composer-runtime-core.js +1 -1
  60. package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
  61. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +3 -1
  62. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
  63. package/dist/runtime/base/default-thread-composer-runtime-core.js +14 -3
  64. package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
  65. package/dist/runtime/interfaces/composer-runtime-core.d.ts +2 -1
  66. package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -1
  67. package/dist/runtime/interfaces/thread-runtime-core.d.ts +3 -1
  68. package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
  69. package/dist/runtime/queue/external-thread-queue-adapter.d.ts +19 -6
  70. package/dist/runtime/queue/external-thread-queue-adapter.d.ts.map +1 -1
  71. package/dist/runtime/queue/message-queue.d.ts +10 -1
  72. package/dist/runtime/queue/message-queue.d.ts.map +1 -1
  73. package/dist/runtime/queue/message-queue.js +138 -36
  74. package/dist/runtime/queue/message-queue.js.map +1 -1
  75. package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
  76. package/dist/runtime/utils/thread-message-like.js +2 -1
  77. package/dist/runtime/utils/thread-message-like.js.map +1 -1
  78. package/dist/runtimes/external-store/external-store-adapter.d.ts +1 -1
  79. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +3 -1
  80. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
  81. package/dist/runtimes/external-store/external-store-thread-runtime-core.js +7 -6
  82. package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
  83. package/dist/runtimes/local/local-runtime-options.d.ts +13 -0
  84. package/dist/runtimes/local/local-runtime-options.d.ts.map +1 -1
  85. package/dist/runtimes/local/local-thread-runtime-core.d.ts +5 -1
  86. package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
  87. package/dist/runtimes/local/local-thread-runtime-core.js +30 -14
  88. package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
  89. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +1 -1
  90. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +1 -1
  91. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -1
  92. package/dist/runtimes/remote-thread-list/empty-thread-core.js +1 -1
  93. package/dist/runtimes/remote-thread-list/empty-thread-core.js.map +1 -1
  94. package/dist/runtimes/remote-thread-list/types.d.ts +6 -3
  95. package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
  96. package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
  97. package/dist/store/runtime-clients/composer-runtime-client.js +11 -4
  98. package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
  99. package/dist/store/scopes/composer.d.ts +7 -3
  100. package/dist/store/scopes/composer.d.ts.map +1 -1
  101. package/dist/store/scopes/queue-item.d.ts +10 -0
  102. package/dist/store/scopes/queue-item.d.ts.map +1 -1
  103. package/dist/store/scopes/queue-item.js.map +1 -1
  104. package/package.json +5 -5
  105. package/src/index.ts +5 -1
  106. package/src/react/AssistantProvider.tsx +20 -18
  107. package/src/react/AssistantRuntimeProvider.test.tsx +55 -1
  108. package/src/react/AssistantRuntimeProvider.tsx +12 -2
  109. package/src/react/providers/AttachmentByIndexProvider.tsx +15 -7
  110. package/src/react/providers/ChainOfThoughtByIndicesProvider.tsx +12 -4
  111. package/src/react/providers/ChainOfThoughtPartByIndexProvider.tsx +8 -4
  112. package/src/react/providers/MessageByIdProvider.tsx +8 -4
  113. package/src/react/providers/MessageByIndexProvider.tsx +8 -4
  114. package/src/react/providers/PartByIndexProvider.tsx +8 -4
  115. package/src/react/providers/QueueItemByIndexProvider.tsx +9 -5
  116. package/src/react/providers/ReadonlyThreadProvider.tsx +9 -4
  117. package/src/react/providers/SuggestionByIndexProvider.tsx +8 -4
  118. package/src/react/providers/TextMessagePartProvider.tsx +13 -4
  119. package/src/react/providers/ThreadListItemByIndexProvider.tsx +8 -4
  120. package/src/react/providers/ThreadListItemRuntimeProvider.tsx +8 -4
  121. package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +19 -4
  122. package/src/react/runtimes/useLocalRuntime.ts +4 -0
  123. package/src/runtime/api/composer-runtime.ts +11 -2
  124. package/src/runtime/api/message-runtime.test.ts +25 -0
  125. package/src/runtime/api/message-runtime.ts +1 -1
  126. package/src/runtime/base/base-composer-runtime-core.ts +5 -1
  127. package/src/runtime/base/default-thread-composer-runtime-core.ts +27 -3
  128. package/src/runtime/interfaces/composer-runtime-core.ts +2 -1
  129. package/src/runtime/interfaces/thread-runtime-core.ts +3 -1
  130. package/src/runtime/queue/external-thread-queue-adapter.ts +19 -3
  131. package/src/runtime/queue/message-queue.ts +200 -38
  132. package/src/runtime/utils/thread-message-like.ts +2 -4
  133. package/src/runtimes/external-store/external-store-thread-runtime-core.ts +10 -8
  134. package/src/runtimes/local/local-runtime-options.ts +15 -0
  135. package/src/runtimes/local/local-thread-runtime-core.test.ts +43 -0
  136. package/src/runtimes/local/local-thread-runtime-core.ts +48 -13
  137. package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +1 -1
  138. package/src/runtimes/remote-thread-list/empty-thread-core.ts +1 -1
  139. package/src/runtimes/remote-thread-list/types.ts +9 -2
  140. package/src/store/runtime-clients/composer-runtime-client.ts +13 -5
  141. package/src/store/scopes/composer.ts +6 -4
  142. package/src/store/scopes/queue-item.ts +8 -1
  143. package/src/tests/external-store-thread-runtime-core.test.ts +56 -13
  144. package/src/tests/framework-neutral-boundary.test.ts +221 -0
  145. package/src/tests/message-queue.test.ts +494 -34
  146. 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 { ExternalThreadQueueAdapter } from "./runtime/queue/external-thread-queue-adapter";
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 { useAui, AuiProvider, type AssistantClient } from "@assistant-ui/store";
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<{ runtime: AssistantRuntime }>
24
- > = ({ runtime, children }) => {
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 value={aui}>
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
- const inner = (
45
- <AssistantProviderInner runtime={runtime}>
46
- {children}
47
- </AssistantProviderInner>
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 { AuiProvider, useAui, type AssistantClient } from "@assistant-ui/store";
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 runtime={runtime} aui={aui ?? null}>
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
- return <AuiProvider value={aui}>{children}</AuiProvider>;
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
- return <AuiProvider value={aui}>{children}</AuiProvider>;
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 { useAui, useAuiState, AuiProvider } from "@assistant-ui/store";
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 aui = useAui({
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
- return <AuiProvider value={aui}>{children}</AuiProvider>;
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
- return <AuiProvider value={aui}>{children}</AuiProvider>;
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
- return <AuiProvider value={aui}>{children}</AuiProvider>;
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
- return <AuiProvider value={aui}>{children}</AuiProvider>;
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
- return <AuiProvider value={aui}>{children}</AuiProvider>;
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, useAui } from "@assistant-ui/store";
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
- return <AuiProvider value={aui}>{children}</AuiProvider>;
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
- return <AuiProvider value={aui}>{children}</AuiProvider>;
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, useAui } from "@assistant-ui/store";
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
- return <AuiProvider value={aui}>{children}</AuiProvider>;
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 { useAui, AuiProvider, type ClientOutput } from "@assistant-ui/store";
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
- return <AuiProvider value={aui}>{children}</AuiProvider>;
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
- return <AuiProvider value={aui}>{children}</AuiProvider>;
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
- return <AuiProvider value={aui}>{children}</AuiProvider>;
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 { RemoteThreadListOptions } from "../../runtimes/remote-thread-list/types";
17
+ import type {
18
+ RemoteThreadListOptions,
19
+ RemoteThreadListProviderComponent,
20
+ } from "../../runtimes/remote-thread-list/types";
18
21
  import { RemoteThreadListHookInstanceManager } from "./RemoteThreadListHookInstanceManager";
19
- import { type FC, Fragment, useEffect, useId } from "react";
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 ?? Fragment,
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 ?? Fragment;
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
- /** Promote a queued message so it processes next. */
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.steerQueueItem(queueItemId);
336
+ core.moveQueueItem(queueItemId, placement);
328
337
  }
329
338
 
330
339
  public removeQueueItem(queueItemId: string) {