@assistant-ui/react 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,69 @@
1
+ import {
2
+ useAssistantContext,
3
+ useComposerContext,
4
+ useContentPartContext,
5
+ useMessageContext,
6
+ useThreadContext
7
+ } from "./chunk-KIP3YFVM.mjs";
8
+
9
+ // src/model-config/useAssistantInstructions.tsx
10
+ import { useEffect } from "react";
11
+ var useAssistantInstructions = (instruction) => {
12
+ const { useModelConfig } = useAssistantContext();
13
+ const registerModelConfigProvider = useModelConfig(
14
+ (s) => s.registerModelConfigProvider
15
+ );
16
+ useEffect(() => {
17
+ const config = {
18
+ system: instruction
19
+ };
20
+ return registerModelConfigProvider(() => config);
21
+ }, [registerModelConfigProvider, instruction]);
22
+ };
23
+
24
+ // src/model-config/useAssistantTool.tsx
25
+ import { useEffect as useEffect2 } from "react";
26
+ var useAssistantTool = (tool) => {
27
+ const { useModelConfig, useToolRenderers } = useAssistantContext();
28
+ const registerModelConfigProvider = useModelConfig(
29
+ (s) => s.registerModelConfigProvider
30
+ );
31
+ const setToolRenderer = useToolRenderers((s) => s.setToolRenderer);
32
+ useEffect2(() => {
33
+ const { name, render, ...rest } = tool;
34
+ const config = {
35
+ tools: {
36
+ [tool.name]: rest
37
+ }
38
+ };
39
+ const unsub1 = registerModelConfigProvider(() => config);
40
+ const unsub2 = render ? setToolRenderer(name, render) : void 0;
41
+ return () => {
42
+ unsub1();
43
+ unsub2?.();
44
+ };
45
+ }, [registerModelConfigProvider, setToolRenderer, tool]);
46
+ };
47
+
48
+ // src/model-config/useAssistantToolRenderer.tsx
49
+ import { useEffect as useEffect3 } from "react";
50
+ var useAssistantToolRenderer = (tool) => {
51
+ const { useToolRenderers } = useAssistantContext();
52
+ const setToolRenderer = useToolRenderers((s) => s.setToolRenderer);
53
+ useEffect3(() => {
54
+ if (!tool) return;
55
+ const { name, render } = tool;
56
+ return setToolRenderer(name, render);
57
+ }, [setToolRenderer, tool]);
58
+ };
59
+ export {
60
+ useAssistantContext,
61
+ useAssistantInstructions,
62
+ useAssistantTool,
63
+ useAssistantToolRenderer,
64
+ useComposerContext,
65
+ useContentPartContext,
66
+ useMessageContext,
67
+ useThreadContext
68
+ };
69
+ //# sourceMappingURL=experimental.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/model-config/useAssistantInstructions.tsx","../src/model-config/useAssistantTool.tsx","../src/model-config/useAssistantToolRenderer.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useAssistantContext } from \"../context/AssistantContext\";\n\nexport const useAssistantInstructions = (instruction: string) => {\n const { useModelConfig } = useAssistantContext();\n const registerModelConfigProvider = useModelConfig(\n (s) => s.registerModelConfigProvider,\n );\n useEffect(() => {\n const config = {\n system: instruction,\n };\n return registerModelConfigProvider(() => config);\n }, [registerModelConfigProvider, instruction]);\n};\n","\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useAssistantContext } from \"../context/AssistantContext\";\nimport type { Tool } from \"../utils/ModelConfigTypes\";\nimport type { ToolRenderComponent } from \"./ToolRenderComponent\";\n\nexport type UseAssistantTool<TArgs, TResult> = Tool<TArgs, TResult> & {\n name: string;\n render?: ToolRenderComponent<TArgs, TResult>;\n};\n\nexport const useAssistantTool = <TArgs, TResult>(\n tool: UseAssistantTool<TArgs, TResult>,\n) => {\n const { useModelConfig, useToolRenderers } = useAssistantContext();\n const registerModelConfigProvider = useModelConfig(\n (s) => s.registerModelConfigProvider,\n );\n const setToolRenderer = useToolRenderers((s) => s.setToolRenderer);\n useEffect(() => {\n const { name, render, ...rest } = tool;\n const config = {\n tools: {\n [tool.name]: rest,\n },\n };\n const unsub1 = registerModelConfigProvider(() => config);\n const unsub2 = render ? setToolRenderer(name, render) : undefined;\n return () => {\n unsub1();\n unsub2?.();\n };\n }, [registerModelConfigProvider, setToolRenderer, tool]);\n};\n","\"use client\";\nimport { useEffect } from \"react\";\nimport { useAssistantContext } from \"../context/AssistantContext\";\nimport type { ToolRenderComponent } from \"./ToolRenderComponent\";\n\ntype UseAssistantToolRenderer<TArgs, TResult> = {\n name: string;\n render: ToolRenderComponent<TArgs, TResult>;\n};\n\nexport const useAssistantToolRenderer = (\n // biome-ignore lint/suspicious/noExplicitAny: intentional any\n tool: UseAssistantToolRenderer<any, any> | null,\n) => {\n const { useToolRenderers } = useAssistantContext();\n const setToolRenderer = useToolRenderers((s) => s.setToolRenderer);\n useEffect(() => {\n if (!tool) return;\n const { name, render } = tool;\n return setToolRenderer(name, render);\n }, [setToolRenderer, tool]);\n};\n"],"mappings":";;;;;;;;;AAEA,SAAS,iBAAiB;AAGnB,IAAM,2BAA2B,CAAC,gBAAwB;AAC/D,QAAM,EAAE,eAAe,IAAI,oBAAoB;AAC/C,QAAM,8BAA8B;AAAA,IAClC,CAAC,MAAM,EAAE;AAAA,EACX;AACA,YAAU,MAAM;AACd,UAAM,SAAS;AAAA,MACb,QAAQ;AAAA,IACV;AACA,WAAO,4BAA4B,MAAM,MAAM;AAAA,EACjD,GAAG,CAAC,6BAA6B,WAAW,CAAC;AAC/C;;;ACdA,SAAS,aAAAA,kBAAiB;AAUnB,IAAM,mBAAmB,CAC9B,SACG;AACH,QAAM,EAAE,gBAAgB,iBAAiB,IAAI,oBAAoB;AACjE,QAAM,8BAA8B;AAAA,IAClC,CAAC,MAAM,EAAE;AAAA,EACX;AACA,QAAM,kBAAkB,iBAAiB,CAAC,MAAM,EAAE,eAAe;AACjE,EAAAC,WAAU,MAAM;AACd,UAAM,EAAE,MAAM,QAAQ,GAAG,KAAK,IAAI;AAClC,UAAM,SAAS;AAAA,MACb,OAAO;AAAA,QACL,CAAC,KAAK,IAAI,GAAG;AAAA,MACf;AAAA,IACF;AACA,UAAM,SAAS,4BAA4B,MAAM,MAAM;AACvD,UAAM,SAAS,SAAS,gBAAgB,MAAM,MAAM,IAAI;AACxD,WAAO,MAAM;AACX,aAAO;AACP,eAAS;AAAA,IACX;AAAA,EACF,GAAG,CAAC,6BAA6B,iBAAiB,IAAI,CAAC;AACzD;;;ACjCA,SAAS,aAAAC,kBAAiB;AASnB,IAAM,2BAA2B,CAEtC,SACG;AACH,QAAM,EAAE,iBAAiB,IAAI,oBAAoB;AACjD,QAAM,kBAAkB,iBAAiB,CAAC,MAAM,EAAE,eAAe;AACjE,EAAAC,WAAU,MAAM;AACd,QAAI,CAAC,KAAM;AACX,UAAM,EAAE,MAAM,OAAO,IAAI;AACzB,WAAO,gBAAgB,MAAM,MAAM;AAAA,EACrC,GAAG,CAAC,iBAAiB,IAAI,CAAC;AAC5B;","names":["useEffect","useEffect","useEffect","useEffect"]}
@@ -0,0 +1,334 @@
1
+ import * as react from 'react';
2
+ import { FC, ReactNode, PropsWithChildren, ComponentType } from 'react';
3
+ import { TextareaAutosizeProps } from 'react-textarea-autosize';
4
+ import { T as TextContentPart, I as ImageContentPart, U as UIContentPart, a as ToolCallContentPart, b as ThreadState, c as Unsubscribe, M as ModelConfigProvider, d as ThreadMessage, e as ModelConfig, A as AssistantContentPart, f as AppendMessage } from './Thread-DcmnmkmV.mjs';
5
+ export { j as AppendContentPart, g as AssistantMessage, i as UserContentPart, h as UserMessage } from './Thread-DcmnmkmV.mjs';
6
+ import { ComponentPropsWithoutRef, Primitive } from '@radix-ui/react-primitive';
7
+ import 'zod';
8
+
9
+ declare const useCopyMessage: ({ copiedDuration }: {
10
+ copiedDuration?: number | undefined;
11
+ }) => (() => void) | null;
12
+
13
+ declare const useReloadMessage: () => (() => void) | null;
14
+
15
+ declare const useBeginMessageEdit: () => (() => void) | null;
16
+
17
+ declare const useGoToNextBranch: () => (() => void) | null;
18
+
19
+ declare const useGoToPreviousBranch: () => (() => void) | null;
20
+
21
+ declare const ThreadRoot: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
22
+ ref?: ((instance: HTMLDivElement | null) => void) | react.RefObject<HTMLDivElement> | null | undefined;
23
+ } & {
24
+ asChild?: boolean;
25
+ }, "key" | keyof react.HTMLAttributes<HTMLDivElement> | "asChild"> & react.RefAttributes<HTMLDivElement>>;
26
+
27
+ type ThreadEmptyProps = {
28
+ children: ReactNode;
29
+ };
30
+ declare const ThreadEmpty: FC<ThreadEmptyProps>;
31
+
32
+ type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
33
+ [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
34
+ }[Keys];
35
+
36
+ type ThreadIfFilters = {
37
+ empty: boolean | undefined;
38
+ running: boolean | undefined;
39
+ };
40
+ type ThreadIfProps = PropsWithChildren<RequireAtLeastOne<ThreadIfFilters>>;
41
+ declare const ThreadIf: FC<ThreadIfProps>;
42
+
43
+ declare const ThreadViewport: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
44
+ ref?: ((instance: HTMLDivElement | null) => void) | react.RefObject<HTMLDivElement> | null | undefined;
45
+ } & {
46
+ asChild?: boolean;
47
+ }, "key" | keyof react.HTMLAttributes<HTMLDivElement> | "asChild"> & {
48
+ autoScroll?: boolean;
49
+ } & react.RefAttributes<HTMLDivElement>>;
50
+
51
+ type ThreadMessagesProps = {
52
+ components: {
53
+ Message: ComponentType;
54
+ UserMessage?: ComponentType;
55
+ EditComposer?: ComponentType;
56
+ AssistantMessage?: ComponentType;
57
+ } | {
58
+ Message?: ComponentType;
59
+ UserMessage: ComponentType;
60
+ EditComposer?: ComponentType;
61
+ AssistantMessage: ComponentType;
62
+ };
63
+ };
64
+ declare const ThreadMessages: FC<ThreadMessagesProps>;
65
+
66
+ declare const ThreadScrollToBottom: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
67
+ ref?: ((instance: HTMLButtonElement | null) => void) | react.RefObject<HTMLButtonElement> | null | undefined;
68
+ } & {
69
+ asChild?: boolean;
70
+ }, "key" | "asChild" | keyof react.ButtonHTMLAttributes<HTMLButtonElement>> & react.RefAttributes<HTMLButtonElement>>;
71
+
72
+ declare const ThreadSuggestion: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
73
+ ref?: ((instance: HTMLButtonElement | null) => void) | react.RefObject<HTMLButtonElement> | null | undefined;
74
+ } & {
75
+ asChild?: boolean;
76
+ }, "key" | "asChild" | keyof react.ButtonHTMLAttributes<HTMLButtonElement>> & {
77
+ prompt: string;
78
+ method: "replace";
79
+ autoSend?: boolean;
80
+ } & react.RefAttributes<HTMLButtonElement>>;
81
+
82
+ declare namespace index$5 {
83
+ export { ThreadEmpty as Empty, ThreadIf as If, ThreadMessages as Messages, ThreadRoot as Root, ThreadScrollToBottom as ScrollToBottom, ThreadSuggestion as Suggestion, ThreadViewport as Viewport };
84
+ }
85
+
86
+ declare const ComposerRoot: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, "ref"> & {
87
+ ref?: ((instance: HTMLFormElement | null) => void) | react.RefObject<HTMLFormElement> | null | undefined;
88
+ } & {
89
+ asChild?: boolean;
90
+ }, "key" | "asChild" | keyof react.FormHTMLAttributes<HTMLFormElement>> & react.RefAttributes<HTMLFormElement>>;
91
+
92
+ declare const ComposerInput: react.ForwardRefExoticComponent<TextareaAutosizeProps & {
93
+ asChild?: boolean;
94
+ } & react.RefAttributes<HTMLTextAreaElement>>;
95
+
96
+ declare const ComposerSend: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
97
+ ref?: ((instance: HTMLButtonElement | null) => void) | react.RefObject<HTMLButtonElement> | null | undefined;
98
+ } & {
99
+ asChild?: boolean;
100
+ }, "key" | "asChild" | keyof react.ButtonHTMLAttributes<HTMLButtonElement>> & react.RefAttributes<HTMLButtonElement>>;
101
+
102
+ declare const ComposerCancel: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
103
+ ref?: ((instance: HTMLButtonElement | null) => void) | react.RefObject<HTMLButtonElement> | null | undefined;
104
+ } & {
105
+ asChild?: boolean;
106
+ }, "key" | "asChild" | keyof react.ButtonHTMLAttributes<HTMLButtonElement>> & react.RefAttributes<HTMLButtonElement>>;
107
+
108
+ type ComposerIfFilters = {
109
+ editing: boolean | undefined;
110
+ };
111
+ type ComposerIfProps = PropsWithChildren<RequireAtLeastOne<ComposerIfFilters>>;
112
+ declare const ComposerIf: FC<ComposerIfProps>;
113
+
114
+ declare namespace index$4 {
115
+ export { ComposerCancel as Cancel, ComposerIf as If, ComposerInput as Input, ComposerRoot as Root, ComposerSend as Send };
116
+ }
117
+
118
+ declare const MessageRoot: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
119
+ ref?: ((instance: HTMLDivElement | null) => void) | react.RefObject<HTMLDivElement> | null | undefined;
120
+ } & {
121
+ asChild?: boolean;
122
+ }, "key" | keyof react.HTMLAttributes<HTMLDivElement> | "asChild"> & react.RefAttributes<HTMLDivElement>>;
123
+
124
+ type MessageIfFilters = {
125
+ user: boolean | undefined;
126
+ assistant: boolean | undefined;
127
+ hasBranches: boolean | undefined;
128
+ copied: boolean | undefined;
129
+ lastOrHover: boolean | undefined;
130
+ };
131
+ type MessageIfProps = RequireAtLeastOne<MessageIfFilters> & {
132
+ children: ReactNode;
133
+ };
134
+ declare const MessageIf: FC<MessageIfProps>;
135
+
136
+ type MessageContentProps = {
137
+ components?: {
138
+ Text?: ComponentType<{
139
+ part: TextContentPart;
140
+ status: "done" | "in_progress" | "error";
141
+ }>;
142
+ Image?: ComponentType<{
143
+ part: ImageContentPart;
144
+ status: "done" | "in_progress" | "error";
145
+ }>;
146
+ UI?: ComponentType<{
147
+ part: UIContentPart;
148
+ status: "done" | "in_progress" | "error";
149
+ }>;
150
+ tools?: {
151
+ by_name?: Record<string, ComponentType<{
152
+ part: ToolCallContentPart;
153
+ status: "done" | "in_progress" | "error";
154
+ }>>;
155
+ Fallback?: ComponentType<{
156
+ part: ToolCallContentPart;
157
+ status: "done" | "in_progress" | "error";
158
+ }>;
159
+ };
160
+ };
161
+ };
162
+ declare const MessageContent: FC<MessageContentProps>;
163
+
164
+ declare const MessageInProgress: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
165
+ ref?: ((instance: HTMLSpanElement | null) => void) | react.RefObject<HTMLSpanElement> | null | undefined;
166
+ } & {
167
+ asChild?: boolean;
168
+ }, "key" | "asChild" | keyof react.HTMLAttributes<HTMLSpanElement>> & react.RefAttributes<HTMLSpanElement>>;
169
+
170
+ declare namespace index$3 {
171
+ export { MessageContent as Content, MessageIf as If, MessageInProgress as InProgress, MessageRoot as Root };
172
+ }
173
+
174
+ declare const BranchPickerNext: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
175
+ ref?: ((instance: HTMLButtonElement | null) => void) | react.RefObject<HTMLButtonElement> | null | undefined;
176
+ } & {
177
+ asChild?: boolean;
178
+ }, "key" | "asChild" | keyof react.ButtonHTMLAttributes<HTMLButtonElement>> & react.RefAttributes<HTMLButtonElement>>;
179
+
180
+ declare const BranchPickerPrevious: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
181
+ ref?: ((instance: HTMLButtonElement | null) => void) | react.RefObject<HTMLButtonElement> | null | undefined;
182
+ } & {
183
+ asChild?: boolean;
184
+ }, "key" | "asChild" | keyof react.ButtonHTMLAttributes<HTMLButtonElement>> & react.RefAttributes<HTMLButtonElement>>;
185
+
186
+ declare const BranchPickerCount: FC;
187
+
188
+ declare const BranchPickerNumber: FC;
189
+
190
+ declare const BranchPickerRoot: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
191
+ ref?: ((instance: HTMLDivElement | null) => void) | react.RefObject<HTMLDivElement> | null | undefined;
192
+ } & {
193
+ asChild?: boolean;
194
+ }, "key" | keyof react.HTMLAttributes<HTMLDivElement> | "asChild"> & {
195
+ hideWhenSingleBranch?: boolean;
196
+ } & react.RefAttributes<HTMLDivElement>>;
197
+
198
+ declare namespace index$2 {
199
+ export { BranchPickerCount as Count, BranchPickerNext as Next, BranchPickerNumber as Number, BranchPickerPrevious as Previous, BranchPickerRoot as Root };
200
+ }
201
+
202
+ declare const ActionBarRoot: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
203
+ ref?: ((instance: HTMLDivElement | null) => void) | react.RefObject<HTMLDivElement> | null | undefined;
204
+ } & {
205
+ asChild?: boolean;
206
+ }, "key" | keyof react.HTMLAttributes<HTMLDivElement> | "asChild"> & {
207
+ hideWhenRunning?: boolean;
208
+ autohide?: "always" | "not-last" | "never";
209
+ autohideFloat?: "always" | "single-branch" | "never";
210
+ } & react.RefAttributes<HTMLDivElement>>;
211
+
212
+ type ActionBarCopyProps = {
213
+ copiedDuration?: number;
214
+ };
215
+ declare const ActionBarCopy: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
216
+ ref?: ((instance: HTMLButtonElement | null) => void) | react.RefObject<HTMLButtonElement> | null | undefined;
217
+ } & {
218
+ asChild?: boolean;
219
+ }, "key" | "asChild" | keyof react.ButtonHTMLAttributes<HTMLButtonElement>> & ActionBarCopyProps & react.RefAttributes<HTMLButtonElement>>;
220
+
221
+ declare const ActionBarReload: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
222
+ ref?: ((instance: HTMLButtonElement | null) => void) | react.RefObject<HTMLButtonElement> | null | undefined;
223
+ } & {
224
+ asChild?: boolean;
225
+ }, "key" | "asChild" | keyof react.ButtonHTMLAttributes<HTMLButtonElement>> & react.RefAttributes<HTMLButtonElement>>;
226
+
227
+ declare const ActionBarEdit: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
228
+ ref?: ((instance: HTMLButtonElement | null) => void) | react.RefObject<HTMLButtonElement> | null | undefined;
229
+ } & {
230
+ asChild?: boolean;
231
+ }, "key" | "asChild" | keyof react.ButtonHTMLAttributes<HTMLButtonElement>> & react.RefAttributes<HTMLButtonElement>>;
232
+
233
+ declare namespace index$1 {
234
+ export { ActionBarCopy as Copy, ActionBarEdit as Edit, ActionBarReload as Reload, ActionBarRoot as Root };
235
+ }
236
+
237
+ declare const ContentPartInProgressIndicator: FC;
238
+
239
+ type PrimitiveSpanProps = ComponentPropsWithoutRef<typeof Primitive.span>;
240
+ type ContentPartTextProps = Omit<PrimitiveSpanProps, "children">;
241
+ declare const ContentPartText: react.ForwardRefExoticComponent<ContentPartTextProps & react.RefAttributes<HTMLSpanElement>>;
242
+
243
+ declare const ContentPartImage: react.ForwardRefExoticComponent<Pick<Omit<react.DetailedHTMLProps<react.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "ref"> & {
244
+ ref?: ((instance: HTMLImageElement | null) => void) | react.RefObject<HTMLImageElement> | null | undefined;
245
+ } & {
246
+ asChild?: boolean;
247
+ }, "key" | "asChild" | keyof react.ImgHTMLAttributes<HTMLImageElement>> & react.RefAttributes<HTMLImageElement>>;
248
+
249
+ declare const ContentPartDisplay: FC;
250
+
251
+ declare namespace index {
252
+ export { ContentPartDisplay as Display, ContentPartImage as Image, ContentPartInProgressIndicator as InProgressIndicator, ContentPartText as Text };
253
+ }
254
+
255
+ type ThreadRuntime = Readonly<ThreadState & {
256
+ subscribe: (callback: () => void) => Unsubscribe;
257
+ }>;
258
+
259
+ type AssistantRuntime = ThreadRuntime & {
260
+ registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
261
+ };
262
+
263
+ type ReactThreadRuntime = ThreadRuntime & {
264
+ unstable_synchronizer?: ComponentType;
265
+ };
266
+
267
+ type ChatModelRunResult = {
268
+ content: AssistantContentPart[];
269
+ };
270
+ type ChatModelRunOptions = {
271
+ messages: ThreadMessage[];
272
+ abortSignal: AbortSignal;
273
+ config: ModelConfig;
274
+ onUpdate: (result: ChatModelRunResult) => void;
275
+ };
276
+ type ChatModelAdapter = {
277
+ run: (options: ChatModelRunOptions) => Promise<ChatModelRunResult>;
278
+ };
279
+
280
+ declare class LocalRuntime implements AssistantRuntime {
281
+ adapter: ChatModelAdapter;
282
+ private _subscriptions;
283
+ private _configProviders;
284
+ private abortController;
285
+ private repository;
286
+ get messages(): ThreadMessage[];
287
+ get isRunning(): boolean;
288
+ constructor(adapter: ChatModelAdapter);
289
+ getBranches(messageId: string): string[];
290
+ switchToBranch(branchId: string): void;
291
+ append(message: AppendMessage): Promise<void>;
292
+ startRun(parentId: string | null): Promise<void>;
293
+ cancelRun(): void;
294
+ private notifySubscribers;
295
+ subscribe(callback: () => void): Unsubscribe;
296
+ registerModelConfigProvider(provider: ModelConfigProvider): () => boolean;
297
+ }
298
+
299
+ declare const useLocalRuntime: (adapter: ChatModelAdapter) => LocalRuntime;
300
+
301
+ type AssistantRuntimeProviderProps = {
302
+ runtime: AssistantRuntime;
303
+ };
304
+ declare const AssistantRuntimeProvider: react.NamedExoticComponent<PropsWithChildren<AssistantRuntimeProviderProps>>;
305
+
306
+ declare class ProxyConfigProvider {
307
+ private _providers;
308
+ getModelConfig(): ModelConfig;
309
+ registerModelConfigProvider(provider: ModelConfigProvider): () => void;
310
+ }
311
+
312
+ declare class MessageRepository {
313
+ private messages;
314
+ private head;
315
+ private root;
316
+ private performOp;
317
+ getMessages(): ThreadMessage[];
318
+ addOrUpdateMessage(parentId: string | null, message: ThreadMessage): void;
319
+ appendOptimisticMessage(parentId: string | null, message: Omit<ThreadMessage, "id" | "createdAt">): string;
320
+ deleteMessage(messageId: string, replacementId?: string | null | undefined): void;
321
+ getBranches(messageId: string): string[];
322
+ switchToBranch(messageId: string): void;
323
+ resetHead(messageId: string | null): void;
324
+ }
325
+
326
+ type internal_MessageRepository = MessageRepository;
327
+ declare const internal_MessageRepository: typeof MessageRepository;
328
+ type internal_ProxyConfigProvider = ProxyConfigProvider;
329
+ declare const internal_ProxyConfigProvider: typeof ProxyConfigProvider;
330
+ declare namespace internal {
331
+ export { internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider };
332
+ }
333
+
334
+ export { index$1 as ActionBarPrimitive, AppendMessage, AssistantContentPart, type AssistantRuntime, AssistantRuntimeProvider, index$2 as BranchPickerPrimitive, type ChatModelAdapter, type ChatModelRunOptions, index$4 as ComposerPrimitive, index as ContentPartPrimitive, internal as INTERNAL, index$3 as MessagePrimitive, type ReactThreadRuntime, TextContentPart, ThreadMessage, index$5 as ThreadPrimitive, type ThreadRuntime, Unsubscribe, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useLocalRuntime, useReloadMessage };