@assistant-ui/react 0.0.29 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. package/dist/AssistantRuntime-BM_jVV3g.d.mts +23 -0
  2. package/dist/AssistantRuntime-CBMSAJqH.d.mts +23 -0
  3. package/dist/AssistantRuntime-C_BvM7ZT.d.ts +23 -0
  4. package/dist/AssistantRuntime-DELpXWfG.d.ts +23 -0
  5. package/dist/ModelConfigTypes-B9UY4zxv.d.mts +55 -0
  6. package/dist/ModelConfigTypes-B9UY4zxv.d.ts +55 -0
  7. package/dist/ModelConfigTypes-BF5HxVrH.d.mts +55 -0
  8. package/dist/ModelConfigTypes-BF5HxVrH.d.ts +55 -0
  9. package/dist/ModelConfigTypes-Cf3yjaDu.d.mts +55 -0
  10. package/dist/ModelConfigTypes-Cf3yjaDu.d.ts +55 -0
  11. package/dist/ModelConfigTypes-CzmXY3sn.d.mts +55 -0
  12. package/dist/ModelConfigTypes-CzmXY3sn.d.ts +55 -0
  13. package/dist/Thread-BMASJT4a.d.ts +15 -0
  14. package/dist/Thread-UEVsUmvl.d.mts +15 -0
  15. package/dist/chunk-3XZUKECF.mjs +207 -0
  16. package/dist/chunk-3XZUKECF.mjs.map +1 -0
  17. package/dist/chunk-4DQ2CIAD.mjs +69 -0
  18. package/dist/chunk-4DQ2CIAD.mjs.map +1 -0
  19. package/dist/chunk-5YONSDN4.mjs +200 -0
  20. package/dist/chunk-5YONSDN4.mjs.map +1 -0
  21. package/dist/chunk-CY4TTHR7.mjs +76 -0
  22. package/dist/chunk-CY4TTHR7.mjs.map +1 -0
  23. package/dist/chunk-DKAWDNW5.mjs +22 -0
  24. package/dist/chunk-DKAWDNW5.mjs.map +1 -0
  25. package/dist/chunk-GQKH2ADD.mjs +165 -0
  26. package/dist/chunk-GQKH2ADD.mjs.map +1 -0
  27. package/dist/chunk-J5LGTIGS.mjs +10 -0
  28. package/dist/chunk-J5LGTIGS.mjs.map +1 -0
  29. package/dist/chunk-NSBOH42A.mjs +200 -0
  30. package/dist/chunk-NSBOH42A.mjs.map +1 -0
  31. package/dist/chunk-X4HBDEFP.mjs +30 -0
  32. package/dist/chunk-X4HBDEFP.mjs.map +1 -0
  33. package/dist/experimental.d.mts +86 -0
  34. package/dist/experimental.d.ts +86 -0
  35. package/dist/experimental.js +123 -0
  36. package/dist/experimental.js.map +1 -0
  37. package/dist/experimental.mjs +34 -0
  38. package/dist/experimental.mjs.map +1 -0
  39. package/dist/index.d.mts +11 -230
  40. package/dist/index.d.ts +11 -230
  41. package/dist/index.js +189 -577
  42. package/dist/index.js.map +1 -1
  43. package/dist/index.mjs +140 -757
  44. package/dist/index.mjs.map +1 -1
  45. package/dist/internal-dlLjX30u.d.mts +75 -0
  46. package/dist/internal-dlLjX30u.d.ts +75 -0
  47. package/dist/internal.d.mts +25 -0
  48. package/dist/internal.d.ts +25 -0
  49. package/dist/internal.js +225 -0
  50. package/dist/internal.js.map +1 -0
  51. package/dist/internal.mjs +10 -0
  52. package/dist/internal.mjs.map +1 -0
  53. package/package.json +23 -3
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/experimental.ts
21
+ var experimental_exports = {};
22
+ __export(experimental_exports, {
23
+ useAssistantContext: () => useAssistantContext,
24
+ useAssistantInstructions: () => useAssistantInstructions,
25
+ useComposerContext: () => useComposerContext,
26
+ useContentPartContext: () => useContentPartContext,
27
+ useMessageContext: () => useMessageContext,
28
+ useThreadContext: () => useThreadContext
29
+ });
30
+ module.exports = __toCommonJS(experimental_exports);
31
+
32
+ // src/context/AssistantContext.ts
33
+ var import_react = require("react");
34
+ var AssistantContext = (0, import_react.createContext)(
35
+ null
36
+ );
37
+ var useAssistantContext = () => {
38
+ const context = (0, import_react.useContext)(AssistantContext);
39
+ if (!context)
40
+ throw new Error(
41
+ "This component must be used within an AssistantRuntimeProvider."
42
+ );
43
+ return context;
44
+ };
45
+
46
+ // src/context/ThreadContext.ts
47
+ var import_react2 = require("react");
48
+ var ThreadContext = (0, import_react2.createContext)(null);
49
+ var useThreadContext = () => {
50
+ const context = (0, import_react2.useContext)(ThreadContext);
51
+ if (!context)
52
+ throw new Error("This component must be used within an AssistantRuntimeProvider.");
53
+ return context;
54
+ };
55
+
56
+ // src/context/ComposerContext.ts
57
+ var import_react4 = require("react");
58
+
59
+ // src/context/MessageContext.ts
60
+ var import_react3 = require("react");
61
+ var MessageContext = (0, import_react3.createContext)(null);
62
+ var useMessageContext = () => {
63
+ const context = (0, import_react3.useContext)(MessageContext);
64
+ if (!context)
65
+ throw new Error(
66
+ "This component can only be used inside a component passed to <ThreadPrimitive.Messages components={...} />."
67
+ );
68
+ return context;
69
+ };
70
+
71
+ // src/context/ComposerContext.ts
72
+ var useComposerContext = () => {
73
+ const { useComposer } = useThreadContext();
74
+ const { useComposer: useEditComposer } = (0, import_react4.useContext)(MessageContext) ?? {};
75
+ return (0, import_react4.useMemo)(
76
+ () => ({
77
+ useComposer: useEditComposer ?? useComposer,
78
+ type: useEditComposer ? "edit" : "new"
79
+ }),
80
+ [useEditComposer, useComposer]
81
+ );
82
+ };
83
+
84
+ // src/context/ContentPartContext.ts
85
+ var import_react5 = require("react");
86
+ var ContentPartContext = (0, import_react5.createContext)(
87
+ null
88
+ );
89
+ var useContentPartContext = () => {
90
+ const context = (0, import_react5.useContext)(ContentPartContext);
91
+ if (!context)
92
+ throw new Error(
93
+ "This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >."
94
+ );
95
+ return context;
96
+ };
97
+
98
+ // src/model-config/useAssistantInstructions.tsx
99
+ var import_react6 = require("react");
100
+ var useAssistantInstructions = (instruction) => {
101
+ const { useModelConfig } = useAssistantContext();
102
+ const addContextProvider = useModelConfig(
103
+ (s) => s.registerModelConfigProvider
104
+ );
105
+ (0, import_react6.useEffect)(
106
+ () => addContextProvider(() => {
107
+ return {
108
+ system: instruction
109
+ };
110
+ }),
111
+ [addContextProvider, instruction]
112
+ );
113
+ };
114
+ // Annotate the CommonJS export names for ESM import in node:
115
+ 0 && (module.exports = {
116
+ useAssistantContext,
117
+ useAssistantInstructions,
118
+ useComposerContext,
119
+ useContentPartContext,
120
+ useMessageContext,
121
+ useThreadContext
122
+ });
123
+ //# sourceMappingURL=experimental.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/experimental.ts","../src/context/AssistantContext.ts","../src/context/ThreadContext.ts","../src/context/ComposerContext.ts","../src/context/MessageContext.ts","../src/context/ContentPartContext.ts","../src/model-config/useAssistantInstructions.tsx"],"sourcesContent":["export type {\n ImageContentPart,\n ToolCallContentPart,\n UIContentPart,\n} from \"./utils/AssistantTypes\";\n\nexport type { ModelConfigProvider } from \"./utils/ModelConfigTypes\";\n\nexport * from \"./context\";\nexport { useAssistantInstructions } from \"./model-config/useAssistantInstructions\";\n","import { createContext, useContext } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\nimport type { AssistantModelConfigState } from \"./stores/AssistantModelConfig\";\n\nexport type AssistantContextValue = {\n useModelConfig: UseBoundStore<StoreApi<AssistantModelConfigState>>;\n};\n\nexport const AssistantContext = createContext<AssistantContextValue | null>(\n null,\n);\n\nexport const useAssistantContext = (): AssistantContextValue => {\n const context = useContext(AssistantContext);\n if (!context)\n throw new Error(\n \"This component must be used within an AssistantRuntimeProvider.\",\n );\n return context;\n};\n","import { createContext, useContext } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\nimport type { ComposerState } from \"./stores/Composer\";\nimport type { ThreadState } from \"./stores/Thread\";\nimport type { ThreadViewportState } from \"./stores/ThreadViewport\";\n\nexport type ThreadContextValue = {\n useThread: UseBoundStore<StoreApi<ThreadState>>;\n useComposer: UseBoundStore<StoreApi<ComposerState>>;\n useViewport: UseBoundStore<StoreApi<ThreadViewportState>>;\n};\n\nexport const ThreadContext = createContext<ThreadContextValue | null>(null);\n\nexport const useThreadContext = (): ThreadContextValue => {\n const context = useContext(ThreadContext);\n if (!context)\n throw new Error(\"This component must be used within an AssistantRuntimeProvider.\");\n return context;\n};\n","import { useContext, useMemo } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\nimport { MessageContext } from \"./MessageContext\";\nimport { useThreadContext } from \"./ThreadContext\";\nimport type { ComposerState } from \"./stores/Composer\";\nimport type { EditComposerState } from \"./stores/MessageComposer\";\n\nexport type ComposerContextValue = {\n useComposer: UseBoundStore<StoreApi<EditComposerState | ComposerState>>;\n type: \"edit\" | \"new\";\n};\n\nexport const useComposerContext = (): ComposerContextValue => {\n const { useComposer } = useThreadContext();\n const { useComposer: useEditComposer } = useContext(MessageContext) ?? {};\n return useMemo(\n () => ({\n useComposer: (useEditComposer ?? useComposer) as UseBoundStore<\n StoreApi<EditComposerState | ComposerState>\n >,\n type: useEditComposer ? (\"edit\" as const) : (\"new\" as const),\n }),\n [useEditComposer, useComposer],\n );\n};\n","import { createContext, useContext } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\nimport type { MessageState } from \"./stores/Message\";\nimport type { EditComposerState } from \"./stores/MessageComposer\";\n\nexport type MessageContextValue = {\n useMessage: UseBoundStore<StoreApi<MessageState>>;\n useComposer: UseBoundStore<StoreApi<EditComposerState>>;\n};\n\nexport const MessageContext = createContext<MessageContextValue | null>(null);\n\nexport const useMessageContext = () => {\n const context = useContext(MessageContext);\n if (!context)\n throw new Error(\n \"This component can only be used inside a component passed to <ThreadPrimitive.Messages components={...} />.\",\n );\n return context;\n};\n","import { createContext, useContext } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\nimport type { ContentPartState } from \"./stores/ContentPart\";\n\nexport type ContentPartContextValue = {\n useContentPart: UseBoundStore<StoreApi<ContentPartState>>;\n};\n\nexport const ContentPartContext = createContext<ContentPartContextValue | null>(\n null,\n);\n\nexport const useContentPartContext = (): ContentPartContextValue => {\n const context = useContext(ContentPartContext);\n if (!context)\n throw new Error(\n \"This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >.\",\n );\n return context;\n};\n","\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useAssistantContext } from \"../context/AssistantContext\";\n\nexport const useAssistantInstructions = (instruction: string) => {\n const { useModelConfig } = useAssistantContext();\n const addContextProvider = useModelConfig(\n (s) => s.registerModelConfigProvider,\n );\n useEffect(\n () =>\n addContextProvider(() => {\n return {\n system: instruction,\n };\n }),\n [addContextProvider, instruction],\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA0C;AAQnC,IAAM,uBAAmB;AAAA,EAC9B;AACF;AAEO,IAAM,sBAAsB,MAA6B;AAC9D,QAAM,cAAU,yBAAW,gBAAgB;AAC3C,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,SAAO;AACT;;;ACnBA,IAAAA,gBAA0C;AAYnC,IAAM,oBAAgB,6BAAyC,IAAI;AAEnE,IAAM,mBAAmB,MAA0B;AACxD,QAAM,cAAU,0BAAW,aAAa;AACxC,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,iEAAiE;AACnF,SAAO;AACT;;;ACnBA,IAAAC,gBAAoC;;;ACApC,IAAAC,gBAA0C;AAUnC,IAAM,qBAAiB,6BAA0C,IAAI;AAErE,IAAM,oBAAoB,MAAM;AACrC,QAAM,cAAU,0BAAW,cAAc;AACzC,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,SAAO;AACT;;;ADPO,IAAM,qBAAqB,MAA4B;AAC5D,QAAM,EAAE,YAAY,IAAI,iBAAiB;AACzC,QAAM,EAAE,aAAa,gBAAgB,QAAI,0BAAW,cAAc,KAAK,CAAC;AACxE,aAAO;AAAA,IACL,OAAO;AAAA,MACL,aAAc,mBAAmB;AAAA,MAGjC,MAAM,kBAAmB,SAAoB;AAAA,IAC/C;AAAA,IACA,CAAC,iBAAiB,WAAW;AAAA,EAC/B;AACF;;;AExBA,IAAAC,gBAA0C;AAQnC,IAAM,yBAAqB;AAAA,EAChC;AACF;AAEO,IAAM,wBAAwB,MAA+B;AAClE,QAAM,cAAU,0BAAW,kBAAkB;AAC7C,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,SAAO;AACT;;;ACjBA,IAAAC,gBAA0B;AAGnB,IAAM,2BAA2B,CAAC,gBAAwB;AAC/D,QAAM,EAAE,eAAe,IAAI,oBAAoB;AAC/C,QAAM,qBAAqB;AAAA,IACzB,CAAC,MAAM,EAAE;AAAA,EACX;AACA;AAAA,IACE,MACE,mBAAmB,MAAM;AACvB,aAAO;AAAA,QACL,QAAQ;AAAA,MACV;AAAA,IACF,CAAC;AAAA,IACH,CAAC,oBAAoB,WAAW;AAAA,EAClC;AACF;","names":["import_react","import_react","import_react","import_react","import_react"]}
@@ -0,0 +1,34 @@
1
+ import {
2
+ useAssistantContext,
3
+ useComposerContext,
4
+ useContentPartContext,
5
+ useMessageContext,
6
+ useThreadContext
7
+ } from "./chunk-CY4TTHR7.mjs";
8
+ import "./chunk-J5LGTIGS.mjs";
9
+
10
+ // src/model-config/useAssistantInstructions.tsx
11
+ import { useEffect } from "react";
12
+ var useAssistantInstructions = (instruction) => {
13
+ const { useModelConfig } = useAssistantContext();
14
+ const addContextProvider = useModelConfig(
15
+ (s) => s.registerModelConfigProvider
16
+ );
17
+ useEffect(
18
+ () => addContextProvider(() => {
19
+ return {
20
+ system: instruction
21
+ };
22
+ }),
23
+ [addContextProvider, instruction]
24
+ );
25
+ };
26
+ export {
27
+ useAssistantContext,
28
+ useAssistantInstructions,
29
+ useComposerContext,
30
+ useContentPartContext,
31
+ useMessageContext,
32
+ useThreadContext
33
+ };
34
+ //# sourceMappingURL=experimental.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/model-config/useAssistantInstructions.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 addContextProvider = useModelConfig(\n (s) => s.registerModelConfigProvider,\n );\n useEffect(\n () =>\n addContextProvider(() => {\n return {\n system: instruction,\n };\n }),\n [addContextProvider, instruction],\n );\n};\n"],"mappings":";;;;;;;;;;AAEA,SAAS,iBAAiB;AAGnB,IAAM,2BAA2B,CAAC,gBAAwB;AAC/D,QAAM,EAAE,eAAe,IAAI,oBAAoB;AAC/C,QAAM,qBAAqB;AAAA,IACzB,CAAC,MAAM,EAAE;AAAA,EACX;AACA;AAAA,IACE,MACE,mBAAmB,MAAM;AACvB,aAAO;AAAA,QACL,QAAQ;AAAA,MACV;AAAA,IACF,CAAC;AAAA,IACH,CAAC,oBAAoB,WAAW;AAAA,EAClC;AACF;","names":[]}
package/dist/index.d.mts CHANGED
@@ -1,10 +1,10 @@
1
1
  import * as react from 'react';
2
2
  import { FC, ReactNode, PropsWithChildren, ComponentType } from 'react';
3
3
  import { TextareaAutosizeProps } from 'react-textarea-autosize';
4
- import { UseChatHelpers, UseAssistantHelpers } from '@ai-sdk/react';
5
- import * as react_jsx_runtime from 'react/jsx-runtime';
6
- import { UseBoundStore, StoreApi } from 'zustand';
7
- import { Message } from 'ai';
4
+ import { T as TextContentPart, I as ImageContentPart, U as UIContentPart, a as ToolCallContentPart, M as ModelConfigProvider, b as ThreadMessage, c as ModelConfig, A as AssistantContentPart, d as AppendMessage } from './ModelConfigTypes-CzmXY3sn.mjs';
5
+ export { h as AppendContentPart, e as AssistantMessage, g as UserContentPart, f as UserMessage } from './ModelConfigTypes-CzmXY3sn.mjs';
6
+ import { T as ThreadState, U as Unsubscribe } from './Thread-UEVsUmvl.mjs';
7
+ import 'zod';
8
8
 
9
9
  declare const useCopyMessage: ({ copiedDuration }: {
10
10
  copiedDuration?: number | undefined;
@@ -133,46 +133,6 @@ type MessageIfProps = RequireAtLeastOne<MessageIfFilters> & {
133
133
  };
134
134
  declare const MessageIf: FC<MessageIfProps>;
135
135
 
136
- type TextContentPart = {
137
- type: "text";
138
- text: string;
139
- };
140
- type ImageContentPart = {
141
- type: "image";
142
- image: string;
143
- };
144
- type UIContentPart = {
145
- type: "ui";
146
- display: ReactNode;
147
- };
148
- type ToolCallContentPart = {
149
- type: "tool-call";
150
- name: string;
151
- args: object;
152
- result?: object;
153
- };
154
- type UserContentPart = TextContentPart | ImageContentPart | UIContentPart;
155
- type AssistantContentPart = TextContentPart | UIContentPart | ToolCallContentPart;
156
- type AppendContentPart = TextContentPart | ImageContentPart;
157
- type BaseMessage = {
158
- id: string;
159
- createdAt: Date;
160
- };
161
- type UserMessage = BaseMessage & {
162
- role: "user";
163
- content: UserContentPart[];
164
- };
165
- type AssistantMessage = BaseMessage & {
166
- role: "assistant";
167
- content: AssistantContentPart[];
168
- status: "in_progress" | "done" | "error";
169
- };
170
- type AppendMessage = {
171
- parentId: string | null;
172
- content: AppendContentPart[];
173
- };
174
- type ThreadMessage = UserMessage | AssistantMessage;
175
-
176
136
  type MessageContentProps = {
177
137
  components?: {
178
138
  Text?: ComponentType<{
@@ -275,206 +235,25 @@ declare namespace index {
275
235
  export { ContentPartInProgressIndicator as InProgressIndicator };
276
236
  }
277
237
 
278
- type VercelRSCMessage = {
279
- id: string;
280
- role: "user" | "assistant";
281
- display: ReactNode;
282
- createdAt?: Date;
283
- };
284
-
285
- type RSCMessageConverter<T> = {
286
- convertMessage: (message: T) => VercelRSCMessage;
287
- };
288
- type VercelRSCAdapterBase<T> = {
289
- messages: T[];
290
- append: (message: AppendMessage) => Promise<void>;
291
- edit?: (message: AppendMessage) => Promise<void>;
292
- reload?: (parentId: string | null) => Promise<void>;
293
- convertMessage?: (message: T) => VercelRSCMessage;
294
- };
295
- type VercelRSCAdapter<T = VercelRSCMessage> = VercelRSCAdapterBase<T> & (T extends VercelRSCMessage ? object : RSCMessageConverter<T>);
296
-
297
- declare class VercelRSCRuntime<T extends WeakKey = VercelRSCMessage> implements AssistantRuntime, ReactThreadRuntime {
298
- adapter: VercelRSCAdapter<T>;
299
- private useAdapter;
300
- private _subscriptions;
301
- isRunning: boolean;
302
- messages: ThreadMessage[];
303
- constructor(adapter: VercelRSCAdapter<T>);
304
- private withRunning;
305
- getBranches(): readonly string[];
306
- switchToBranch(): void;
307
- append(message: AppendMessage): Promise<void>;
308
- startRun(parentId: string | null): Promise<void>;
309
- cancelRun(): void;
310
- subscribe(callback: () => void): () => void;
311
- onAdapterUpdated(): void;
312
- private updateData;
313
- unstable_synchronizer: () => null;
314
- }
315
-
316
- declare const useVercelRSCRuntime: <T extends WeakKey>(adapter: VercelRSCAdapter<T>) => VercelRSCRuntime<T>;
317
-
318
- declare const getVercelRSCMessage: <T>(message: ThreadMessage) => T | undefined;
319
-
320
- type VercelHelpers = UseChatHelpers | UseAssistantHelpers;
321
-
322
- declare class VercelAIRuntime implements AssistantRuntime, ReactThreadRuntime {
323
- vercel: VercelHelpers;
324
- private _subscriptions;
325
- private repository;
326
- private assistantOptimisticId;
327
- private useVercel;
328
- messages: ThreadMessage[];
329
- isRunning: boolean;
330
- constructor(vercel: VercelHelpers);
331
- getBranches(messageId: string): string[];
332
- switchToBranch(branchId: string): void;
333
- append(message: AppendMessage): Promise<void>;
334
- startRun(parentId: string | null): Promise<void>;
335
- cancelRun(): void;
336
- subscribe(callback: () => void): () => void;
337
- private updateVercelMessages;
338
- onVercelUpdated(): void;
339
- private updateData;
340
- unstable_synchronizer: () => null;
341
- }
342
-
343
- declare const useVercelUseChatRuntime: (chatHelpers: UseChatHelpers) => VercelAIRuntime;
344
-
345
- declare const useVercelUseAssistantRuntime: (assistantHelpers: UseAssistantHelpers) => VercelAIRuntime;
346
-
347
- declare const getVercelAIMessage: (message: ThreadMessage) => Message[] | undefined;
348
-
349
- type ContentPartState = Readonly<{
350
- status: "in_progress" | "done" | "error";
351
- part: ThreadMessage["content"][number];
352
- }>;
353
-
354
- type MessageState = Readonly<{
355
- message: Readonly<ThreadMessage>;
356
- parentId: string | null;
357
- branches: readonly string[];
358
- isLast: boolean;
359
- inProgressIndicator: ReactNode | null;
360
- setInProgressIndicator: (value: ReactNode | null) => void;
361
- isCopied: boolean;
362
- setIsCopied: (value: boolean) => void;
363
- isHovering: boolean;
364
- setIsHovering: (value: boolean) => void;
365
- }>;
366
-
367
- type BaseComposerState = Readonly<{
368
- value: string;
369
- setValue: (value: string) => void;
370
- }>;
371
-
372
- type EditComposerState = BaseComposerState & Readonly<{
373
- isEditing: boolean;
374
- edit: () => void;
375
- send: () => void;
376
- cancel: () => boolean;
377
- }>;
378
-
379
- type ThreadState = {
380
- messages: readonly ThreadMessage[];
381
- isRunning: boolean;
382
- getBranches: (messageId: string) => readonly string[];
383
- switchToBranch: (branchId: string) => void;
384
- append: (message: AppendMessage) => void;
385
- startRun: (parentId: string | null) => void;
386
- cancelRun: () => void;
387
- };
388
-
389
- type ComposerState = BaseComposerState & Readonly<{
390
- isEditing: true;
391
- send: () => void;
392
- cancel: () => boolean;
393
- }>;
394
-
395
- type ThreadViewportState = {
396
- isAtBottom: boolean;
397
- scrollToBottom: () => void;
398
- onScrollToBottom: (callback: () => void) => () => void;
399
- };
400
-
401
- type ThreadContextValue = {
402
- useThread: UseBoundStore<StoreApi<ThreadState>>;
403
- useComposer: UseBoundStore<StoreApi<ComposerState>>;
404
- useViewport: UseBoundStore<StoreApi<ThreadViewportState>>;
405
- };
406
- declare const useThreadContext: () => ThreadContextValue;
407
-
408
- type ComposerContextValue = {
409
- useComposer: UseBoundStore<StoreApi<EditComposerState | ComposerState>>;
410
- type: "edit" | "new";
411
- };
412
- declare const useComposerContext: () => ComposerContextValue;
413
-
414
- type MessageContextValue = {
415
- useMessage: UseBoundStore<StoreApi<MessageState>>;
416
- useComposer: UseBoundStore<StoreApi<EditComposerState>>;
417
- };
418
- declare const useMessageContext: () => MessageContextValue;
419
-
420
- type ContentPartContextValue = {
421
- useContentPart: UseBoundStore<StoreApi<ContentPartState>>;
422
- };
423
- declare const useContentPartContext: () => ContentPartContextValue;
424
-
425
- type Unsubscribe = () => void;
426
238
  type ThreadRuntime = Readonly<ThreadState & {
427
239
  subscribe: (callback: () => void) => Unsubscribe;
428
240
  }>;
429
241
 
430
- type AssistantRuntime = ThreadRuntime;
242
+ type AssistantRuntime = ThreadRuntime & {
243
+ registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
244
+ };
431
245
 
432
246
  type ReactThreadRuntime = ThreadRuntime & {
433
247
  unstable_synchronizer?: ComponentType;
434
248
  };
435
249
 
436
- declare class MessageRepository {
437
- private messages;
438
- private head;
439
- private root;
440
- private performOp;
441
- getMessages(): ThreadMessage[];
442
- addOrUpdateMessage(parentId: string | null, message: ThreadMessage): void;
443
- appendOptimisticMessage(parentId: string | null, message: Omit<ThreadMessage, "id" | "createdAt">): string;
444
- deleteMessage(messageId: string, replacementId?: string | null | undefined): void;
445
- getBranches(messageId: string): string[];
446
- switchToBranch(messageId: string): void;
447
- resetHead(messageId: string | null): void;
448
- }
449
-
450
- /**
451
- * @deprecated Will be removed in 0.1.0.
452
- */
453
- type VercelAIAssistantProviderProps = PropsWithChildren<{
454
- chat: UseChatHelpers;
455
- } | {
456
- assistant: UseAssistantHelpers;
457
- }>;
458
- /**
459
- * @deprecated `const runtime = useVercelUseChatRuntime(chat)` and `<AssistantRuntimeProvider runtime={...} />`. Will be removed in 0.1.0.
460
- */
461
- declare const VercelAIAssistantProvider: FC<VercelAIAssistantProviderProps>;
462
-
463
- /**
464
- * @deprecated Will be removed in 0.1.0.
465
- */
466
- type VercelRSCAssistantProviderProps<T> = PropsWithChildren<VercelRSCAdapter<T>>;
467
- /**
468
- * @deprecated Replaced with `const runtime = useVercelRSCRuntime({ messages, append })` and `<AssistantRuntimeProvider runtime={runtime} />`. Will be removed in 0.1.0.
469
- */
470
- declare const VercelRSCAssistantProvider: <T extends WeakKey = VercelRSCMessage>({ children, ...adapter }: VercelRSCAssistantProviderProps<T>) => react_jsx_runtime.JSX.Element;
471
-
472
250
  type ChatModelRunResult = {
473
251
  content: AssistantContentPart[];
474
252
  };
475
253
  type ChatModelRunOptions = {
476
254
  messages: ThreadMessage[];
477
255
  abortSignal: AbortSignal;
256
+ config: ModelConfig;
478
257
  onUpdate: (result: ChatModelRunResult) => void;
479
258
  };
480
259
  type ChatModelAdapter = {
@@ -484,6 +263,7 @@ type ChatModelAdapter = {
484
263
  declare class LocalRuntime implements AssistantRuntime {
485
264
  adapter: ChatModelAdapter;
486
265
  private _subscriptions;
266
+ private _configProviders;
487
267
  private abortController;
488
268
  private repository;
489
269
  get messages(): ThreadMessage[];
@@ -496,6 +276,7 @@ declare class LocalRuntime implements AssistantRuntime {
496
276
  cancelRun(): void;
497
277
  private notifySubscribers;
498
278
  subscribe(callback: () => void): Unsubscribe;
279
+ registerModelConfigProvider(provider: ModelConfigProvider): () => boolean;
499
280
  }
500
281
 
501
282
  declare const useLocalRuntime: (adapter: ChatModelAdapter) => LocalRuntime;
@@ -505,4 +286,4 @@ type AssistantRuntimeProviderProps = {
505
286
  };
506
287
  declare const AssistantRuntimeProvider: react.NamedExoticComponent<PropsWithChildren<AssistantRuntimeProviderProps>>;
507
288
 
508
- export { index$1 as ActionBarPrimitive, type AppendContentPart, type AppendMessage, type AssistantContentPart, type AssistantMessage, type AssistantRuntime, AssistantRuntimeProvider, index$2 as BranchPickerPrimitive, index$4 as ComposerPrimitive, index as ContentPartPrimitive, index$3 as MessagePrimitive, type VercelRSCMessage as RSCMessage, type ReactThreadRuntime, type TextContentPart, type ThreadMessage, index$5 as ThreadPrimitive, type ThreadRuntime, type UserContentPart, type UserMessage, VercelAIAssistantProvider, type VercelAIAssistantProviderProps, type VercelRSCAdapter, VercelRSCAssistantProvider, type VercelRSCAssistantProviderProps, type VercelRSCMessage, getVercelAIMessage, getVercelRSCMessage, type ChatModelAdapter as unstable_ChatModelAdapter, type ChatModelRunOptions as unstable_ChatModelRunOptions, type ComposerContextValue as unstable_ComposerContextValue, type ComposerState as unstable_ComposerState, type ContentPartContextValue as unstable_ContentPartContextValue, type ContentPartState as unstable_ContentPartState, type EditComposerState as unstable_EditComposerState, type ImageContentPart as unstable_ImageContentPart, type MessageContextValue as unstable_MessageContextValue, MessageRepository as unstable_MessageRepository, type MessageState as unstable_MessageState, type ThreadContextValue as unstable_ThreadContextValue, type ThreadState as unstable_ThreadState, type ThreadViewportState as unstable_ThreadViewportState, type ToolCallContentPart as unstable_ToolCallContentPart, type UIContentPart as unstable_UIContentPart, useComposerContext as unstable_useComposerContext, useContentPartContext as unstable_useContentPartContext, useLocalRuntime as unstable_useLocalRuntime, useMessageContext as unstable_useMessageContext, useThreadContext as unstable_useThreadContext, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useReloadMessage, useVercelRSCRuntime, useVercelUseAssistantRuntime, useVercelUseChatRuntime };
289
+ 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, index$3 as MessagePrimitive, type ReactThreadRuntime, TextContentPart, ThreadMessage, index$5 as ThreadPrimitive, type ThreadRuntime, Unsubscribe, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useLocalRuntime, useReloadMessage };