@assistant-ui/react 0.0.10 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { FC, PropsWithChildren, ReactNode, ComponentType } from 'react';
2
+ import { FC, ReactNode, PropsWithChildren, ComponentType } from 'react';
3
3
  import { TextareaAutosizeProps } from 'react-textarea-autosize';
4
4
  import { UseChatHelpers, UseAssistantHelpers } from 'ai/react';
5
5
  import { UseBoundStore, StoreApi } from 'zustand';
@@ -11,7 +11,7 @@ declare const ThreadRoot: react.ForwardRefExoticComponent<Pick<Omit<react.Detail
11
11
  }, "key" | keyof react.HTMLAttributes<HTMLDivElement> | "asChild"> & react.RefAttributes<HTMLDivElement>>;
12
12
 
13
13
  type ThreadEmptyProps = {
14
- children: React.ReactNode;
14
+ children: ReactNode;
15
15
  };
16
16
  declare const ThreadEmpty: FC<ThreadEmptyProps>;
17
17
 
@@ -36,15 +36,15 @@ declare const ThreadViewport: react.ForwardRefExoticComponent<Pick<Omit<react.De
36
36
 
37
37
  type ThreadMessagesProps = {
38
38
  components: {
39
- Message: React.ComponentType;
40
- UserMessage?: React.ComponentType;
41
- EditComposer?: React.ComponentType;
42
- AssistantMessage?: React.ComponentType;
39
+ Message: ComponentType;
40
+ UserMessage?: ComponentType;
41
+ EditComposer?: ComponentType;
42
+ AssistantMessage?: ComponentType;
43
43
  } | {
44
- Message?: React.ComponentType;
45
- UserMessage: React.ComponentType;
46
- EditComposer?: React.ComponentType;
47
- AssistantMessage: React.ComponentType;
44
+ Message?: ComponentType;
45
+ UserMessage: ComponentType;
46
+ EditComposer?: ComponentType;
47
+ AssistantMessage: ComponentType;
48
48
  };
49
49
  };
50
50
  declare const ThreadMessages: FC<ThreadMessagesProps>;
@@ -97,10 +97,9 @@ type BaseComposerState = {
97
97
  };
98
98
  type MessageComposerState = BaseComposerState & {
99
99
  isEditing: boolean;
100
- canCancel: true;
101
100
  edit: () => void;
102
101
  send: () => void;
103
- cancel: () => void;
102
+ cancel: () => boolean;
104
103
  };
105
104
 
106
105
  type ThreadMessageTextPart = {
@@ -121,14 +120,13 @@ type ThreadMessageToolCallPart = {
121
120
  args: object;
122
121
  result?: object;
123
122
  };
123
+ type CreateThreadUserMessageContent = ThreadMessageTextPart | ThreadMessageImagePart;
124
124
  type ThreadUserMessageContent = ThreadMessageTextPart | ThreadMessageImagePart | ThreadMessageUIPart;
125
125
  type ThreadAssistantMessageContent = ThreadMessageTextPart | ThreadMessageImagePart | ThreadMessageUIPart | ThreadMessageToolCallPart;
126
126
  type ThreadMessageBase = {
127
127
  id: string;
128
- parentId: string;
128
+ parentId: string | null;
129
129
  createdAt: Date;
130
- branchId: number;
131
- branchCount: number;
132
130
  };
133
131
  type ThreadUserMessage = ThreadMessageBase & {
134
132
  role: "user";
@@ -138,11 +136,14 @@ type ThreadAssistantMessage = ThreadMessageBase & {
138
136
  role: "assistant";
139
137
  content: ThreadAssistantMessageContent[];
140
138
  };
139
+ type CreateThreadMessage = {
140
+ parentId: string | null;
141
+ content: CreateThreadUserMessageContent[];
142
+ };
141
143
  type ThreadMessage = ThreadUserMessage | ThreadAssistantMessage;
142
- type CreateThreadMessage = Omit<ThreadUserMessage, "id" | "branchId" | "branchCount" | "createdAt" | "role">;
143
144
 
144
145
  type MessageProviderProps = {
145
- children?: React.ReactNode;
146
+ children?: ReactNode;
146
147
  message: ThreadMessage;
147
148
  };
148
149
  declare const MessageProvider: FC<MessageProviderProps>;
@@ -161,7 +162,7 @@ type MessageIfFilters = {
161
162
  lastOrHover: boolean | undefined;
162
163
  };
163
164
  type MessageIfProps = RequireAtLeastOne<MessageIfFilters> & {
164
- children: React.ReactNode;
165
+ children: ReactNode;
165
166
  };
166
167
  declare const MessageIf: FC<MessageIfProps>;
167
168
 
@@ -255,27 +256,28 @@ declare namespace index {
255
256
  export { ActionBarCopy as Copy, ActionBarEdit as Edit, ActionBarReload as Reload, ActionBarRoot as Root };
256
257
  }
257
258
 
258
- type VercelAIAssistantProviderProps$1 = PropsWithChildren<{
259
+ type VercelAIAssistantProviderProps = PropsWithChildren<{
259
260
  chat: UseChatHelpers;
260
261
  } | {
261
262
  assistant: UseAssistantHelpers;
262
263
  }>;
263
- declare const VercelAIAssistantProvider: FC<VercelAIAssistantProviderProps$1>;
264
+ declare const VercelAIAssistantProvider: FC<VercelAIAssistantProviderProps>;
264
265
 
265
- type RSCMessage = {
266
+ type VercelRSCMessage = {
266
267
  id: string;
267
268
  role: "user" | "assistant";
268
269
  display: ReactNode;
269
270
  createdAt?: Date;
270
271
  };
271
- type VercelAIAssistantProviderProps = PropsWithChildren<{
272
- messages: RSCMessage[];
272
+ type VercelRSCAssistantProviderProps = PropsWithChildren<{
273
+ messages: VercelRSCMessage[];
273
274
  append: (message: CreateThreadMessage) => Promise<void>;
274
275
  }>;
275
- declare const VercelRSCAssistantProvider: FC<VercelAIAssistantProviderProps>;
276
+ declare const VercelRSCAssistantProvider: FC<VercelRSCAssistantProviderProps>;
276
277
 
277
278
  type MessageState = {
278
279
  message: ThreadMessage;
280
+ branches: string[];
279
281
  isLast: boolean;
280
282
  isCopied: boolean;
281
283
  setIsCopied: (value: boolean) => void;
@@ -301,4 +303,4 @@ declare const useGoToNextBranch: () => (() => void) | null;
301
303
 
302
304
  declare const useGoToPreviousBranch: () => (() => void) | null;
303
305
 
304
- export { index as ActionBarPrimitive, index$1 as BranchPickerPrimitive, index$3 as ComposerPrimitive, index$2 as MessagePrimitive, index$4 as ThreadPrimitive, VercelAIAssistantProvider, VercelRSCAssistantProvider as unstable_VercelRSCAssistantProvider, useMessageContext as unstable_useMessageContext, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useReloadMessage };
306
+ export { index as ActionBarPrimitive, index$1 as BranchPickerPrimitive, index$3 as ComposerPrimitive, type CreateThreadMessage, type CreateThreadUserMessageContent, index$2 as MessagePrimitive, type VercelRSCMessage as RSCMessage, type ThreadMessageImagePart, type ThreadMessageTextPart, index$4 as ThreadPrimitive, VercelAIAssistantProvider, type VercelAIAssistantProviderProps, VercelRSCAssistantProvider, type VercelRSCAssistantProviderProps, useMessageContext as unstable_useMessageContext, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useReloadMessage };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { FC, PropsWithChildren, ReactNode, ComponentType } from 'react';
2
+ import { FC, ReactNode, PropsWithChildren, ComponentType } from 'react';
3
3
  import { TextareaAutosizeProps } from 'react-textarea-autosize';
4
4
  import { UseChatHelpers, UseAssistantHelpers } from 'ai/react';
5
5
  import { UseBoundStore, StoreApi } from 'zustand';
@@ -11,7 +11,7 @@ declare const ThreadRoot: react.ForwardRefExoticComponent<Pick<Omit<react.Detail
11
11
  }, "key" | keyof react.HTMLAttributes<HTMLDivElement> | "asChild"> & react.RefAttributes<HTMLDivElement>>;
12
12
 
13
13
  type ThreadEmptyProps = {
14
- children: React.ReactNode;
14
+ children: ReactNode;
15
15
  };
16
16
  declare const ThreadEmpty: FC<ThreadEmptyProps>;
17
17
 
@@ -36,15 +36,15 @@ declare const ThreadViewport: react.ForwardRefExoticComponent<Pick<Omit<react.De
36
36
 
37
37
  type ThreadMessagesProps = {
38
38
  components: {
39
- Message: React.ComponentType;
40
- UserMessage?: React.ComponentType;
41
- EditComposer?: React.ComponentType;
42
- AssistantMessage?: React.ComponentType;
39
+ Message: ComponentType;
40
+ UserMessage?: ComponentType;
41
+ EditComposer?: ComponentType;
42
+ AssistantMessage?: ComponentType;
43
43
  } | {
44
- Message?: React.ComponentType;
45
- UserMessage: React.ComponentType;
46
- EditComposer?: React.ComponentType;
47
- AssistantMessage: React.ComponentType;
44
+ Message?: ComponentType;
45
+ UserMessage: ComponentType;
46
+ EditComposer?: ComponentType;
47
+ AssistantMessage: ComponentType;
48
48
  };
49
49
  };
50
50
  declare const ThreadMessages: FC<ThreadMessagesProps>;
@@ -97,10 +97,9 @@ type BaseComposerState = {
97
97
  };
98
98
  type MessageComposerState = BaseComposerState & {
99
99
  isEditing: boolean;
100
- canCancel: true;
101
100
  edit: () => void;
102
101
  send: () => void;
103
- cancel: () => void;
102
+ cancel: () => boolean;
104
103
  };
105
104
 
106
105
  type ThreadMessageTextPart = {
@@ -121,14 +120,13 @@ type ThreadMessageToolCallPart = {
121
120
  args: object;
122
121
  result?: object;
123
122
  };
123
+ type CreateThreadUserMessageContent = ThreadMessageTextPart | ThreadMessageImagePart;
124
124
  type ThreadUserMessageContent = ThreadMessageTextPart | ThreadMessageImagePart | ThreadMessageUIPart;
125
125
  type ThreadAssistantMessageContent = ThreadMessageTextPart | ThreadMessageImagePart | ThreadMessageUIPart | ThreadMessageToolCallPart;
126
126
  type ThreadMessageBase = {
127
127
  id: string;
128
- parentId: string;
128
+ parentId: string | null;
129
129
  createdAt: Date;
130
- branchId: number;
131
- branchCount: number;
132
130
  };
133
131
  type ThreadUserMessage = ThreadMessageBase & {
134
132
  role: "user";
@@ -138,11 +136,14 @@ type ThreadAssistantMessage = ThreadMessageBase & {
138
136
  role: "assistant";
139
137
  content: ThreadAssistantMessageContent[];
140
138
  };
139
+ type CreateThreadMessage = {
140
+ parentId: string | null;
141
+ content: CreateThreadUserMessageContent[];
142
+ };
141
143
  type ThreadMessage = ThreadUserMessage | ThreadAssistantMessage;
142
- type CreateThreadMessage = Omit<ThreadUserMessage, "id" | "branchId" | "branchCount" | "createdAt" | "role">;
143
144
 
144
145
  type MessageProviderProps = {
145
- children?: React.ReactNode;
146
+ children?: ReactNode;
146
147
  message: ThreadMessage;
147
148
  };
148
149
  declare const MessageProvider: FC<MessageProviderProps>;
@@ -161,7 +162,7 @@ type MessageIfFilters = {
161
162
  lastOrHover: boolean | undefined;
162
163
  };
163
164
  type MessageIfProps = RequireAtLeastOne<MessageIfFilters> & {
164
- children: React.ReactNode;
165
+ children: ReactNode;
165
166
  };
166
167
  declare const MessageIf: FC<MessageIfProps>;
167
168
 
@@ -255,27 +256,28 @@ declare namespace index {
255
256
  export { ActionBarCopy as Copy, ActionBarEdit as Edit, ActionBarReload as Reload, ActionBarRoot as Root };
256
257
  }
257
258
 
258
- type VercelAIAssistantProviderProps$1 = PropsWithChildren<{
259
+ type VercelAIAssistantProviderProps = PropsWithChildren<{
259
260
  chat: UseChatHelpers;
260
261
  } | {
261
262
  assistant: UseAssistantHelpers;
262
263
  }>;
263
- declare const VercelAIAssistantProvider: FC<VercelAIAssistantProviderProps$1>;
264
+ declare const VercelAIAssistantProvider: FC<VercelAIAssistantProviderProps>;
264
265
 
265
- type RSCMessage = {
266
+ type VercelRSCMessage = {
266
267
  id: string;
267
268
  role: "user" | "assistant";
268
269
  display: ReactNode;
269
270
  createdAt?: Date;
270
271
  };
271
- type VercelAIAssistantProviderProps = PropsWithChildren<{
272
- messages: RSCMessage[];
272
+ type VercelRSCAssistantProviderProps = PropsWithChildren<{
273
+ messages: VercelRSCMessage[];
273
274
  append: (message: CreateThreadMessage) => Promise<void>;
274
275
  }>;
275
- declare const VercelRSCAssistantProvider: FC<VercelAIAssistantProviderProps>;
276
+ declare const VercelRSCAssistantProvider: FC<VercelRSCAssistantProviderProps>;
276
277
 
277
278
  type MessageState = {
278
279
  message: ThreadMessage;
280
+ branches: string[];
279
281
  isLast: boolean;
280
282
  isCopied: boolean;
281
283
  setIsCopied: (value: boolean) => void;
@@ -301,4 +303,4 @@ declare const useGoToNextBranch: () => (() => void) | null;
301
303
 
302
304
  declare const useGoToPreviousBranch: () => (() => void) | null;
303
305
 
304
- export { index as ActionBarPrimitive, index$1 as BranchPickerPrimitive, index$3 as ComposerPrimitive, index$2 as MessagePrimitive, index$4 as ThreadPrimitive, VercelAIAssistantProvider, VercelRSCAssistantProvider as unstable_VercelRSCAssistantProvider, useMessageContext as unstable_useMessageContext, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useReloadMessage };
306
+ export { index as ActionBarPrimitive, index$1 as BranchPickerPrimitive, index$3 as ComposerPrimitive, type CreateThreadMessage, type CreateThreadUserMessageContent, index$2 as MessagePrimitive, type VercelRSCMessage as RSCMessage, type ThreadMessageImagePart, type ThreadMessageTextPart, index$4 as ThreadPrimitive, VercelAIAssistantProvider, type VercelAIAssistantProviderProps, VercelRSCAssistantProvider, type VercelRSCAssistantProviderProps, useMessageContext as unstable_useMessageContext, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useReloadMessage };