@assistant-ui/react 0.0.9 → 0.0.11

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
 
@@ -21,7 +21,7 @@ type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyo
21
21
 
22
22
  type ThreadIfFilters = {
23
23
  empty: boolean | undefined;
24
- busy: boolean | undefined;
24
+ running: boolean | undefined;
25
25
  };
26
26
  type ThreadIfProps = PropsWithChildren<RequireAtLeastOne<ThreadIfFilters>>;
27
27
  declare const ThreadIf: FC<ThreadIfProps>;
@@ -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>;
@@ -91,17 +91,15 @@ declare namespace index$3 {
91
91
  export { ComposerCancel as Cancel, ComposerIf as If, ComposerInput as Input, ComposerRoot as Root, ComposerSend as Send };
92
92
  }
93
93
 
94
- type ComposerState = {
95
- isEditing: boolean;
96
- canCancel: boolean;
97
- edit: () => void;
98
- send: () => void;
99
- cancel: () => void;
94
+ type BaseComposerState = {
100
95
  value: string;
101
96
  setValue: (value: string) => void;
102
97
  };
103
- type ComposerStore = {
104
- useComposer: UseBoundStore<StoreApi<ComposerState>>;
98
+ type MessageComposerState = BaseComposerState & {
99
+ isEditing: boolean;
100
+ edit: () => void;
101
+ send: () => void;
102
+ cancel: () => boolean;
105
103
  };
106
104
 
107
105
  type ThreadMessageTextPart = {
@@ -122,14 +120,13 @@ type ThreadMessageToolCallPart = {
122
120
  args: object;
123
121
  result?: object;
124
122
  };
123
+ type CreateThreadUserMessageContent = ThreadMessageTextPart | ThreadMessageImagePart;
125
124
  type ThreadUserMessageContent = ThreadMessageTextPart | ThreadMessageImagePart | ThreadMessageUIPart;
126
125
  type ThreadAssistantMessageContent = ThreadMessageTextPart | ThreadMessageImagePart | ThreadMessageUIPart | ThreadMessageToolCallPart;
127
126
  type ThreadMessageBase = {
128
127
  id: string;
129
- parentId: string;
128
+ parentId: string | null;
130
129
  createdAt: Date;
131
- branchId: number;
132
- branchCount: number;
133
130
  };
134
131
  type ThreadUserMessage = ThreadMessageBase & {
135
132
  role: "user";
@@ -139,11 +136,14 @@ type ThreadAssistantMessage = ThreadMessageBase & {
139
136
  role: "assistant";
140
137
  content: ThreadAssistantMessageContent[];
141
138
  };
139
+ type CreateThreadMessage = {
140
+ parentId: string | null;
141
+ content: CreateThreadUserMessageContent[];
142
+ };
142
143
  type ThreadMessage = ThreadUserMessage | ThreadAssistantMessage;
143
- type CreateThreadMessage = Omit<ThreadUserMessage, "id" | "branchId" | "branchCount" | "createdAt" | "role">;
144
144
 
145
145
  type MessageProviderProps = {
146
- children?: React.ReactNode;
146
+ children?: ReactNode;
147
147
  message: ThreadMessage;
148
148
  };
149
149
  declare const MessageProvider: FC<MessageProviderProps>;
@@ -162,7 +162,7 @@ type MessageIfFilters = {
162
162
  lastOrHover: boolean | undefined;
163
163
  };
164
164
  type MessageIfProps = RequireAtLeastOne<MessageIfFilters> & {
165
- children: React.ReactNode;
165
+ children: ReactNode;
166
166
  };
167
167
  declare const MessageIf: FC<MessageIfProps>;
168
168
 
@@ -226,7 +226,7 @@ declare const ActionBarRoot: react.ForwardRefExoticComponent<Pick<Omit<react.Det
226
226
  } & {
227
227
  asChild?: boolean;
228
228
  }, "key" | keyof react.HTMLAttributes<HTMLDivElement> | "asChild"> & {
229
- hideWhenBusy?: boolean;
229
+ hideWhenRunning?: boolean;
230
230
  autohide?: "always" | "not-last" | "never";
231
231
  autohideFloat?: "always" | "single-branch" | "never";
232
232
  } & react.RefAttributes<HTMLDivElement>>;
@@ -277,14 +277,16 @@ declare const VercelRSCAssistantProvider: FC<VercelAIAssistantProviderProps>;
277
277
 
278
278
  type MessageState = {
279
279
  message: ThreadMessage;
280
+ branches: string[];
280
281
  isLast: boolean;
281
282
  isCopied: boolean;
282
283
  setIsCopied: (value: boolean) => void;
283
284
  isHovering: boolean;
284
285
  setIsHovering: (value: boolean) => void;
285
286
  };
286
- type MessageStore = ComposerStore & {
287
+ type MessageStore = {
287
288
  useMessage: UseBoundStore<StoreApi<MessageState>>;
289
+ useComposer: UseBoundStore<StoreApi<MessageComposerState>>;
288
290
  };
289
291
 
290
292
  declare const useMessageContext: () => MessageStore;
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
 
@@ -21,7 +21,7 @@ type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyo
21
21
 
22
22
  type ThreadIfFilters = {
23
23
  empty: boolean | undefined;
24
- busy: boolean | undefined;
24
+ running: boolean | undefined;
25
25
  };
26
26
  type ThreadIfProps = PropsWithChildren<RequireAtLeastOne<ThreadIfFilters>>;
27
27
  declare const ThreadIf: FC<ThreadIfProps>;
@@ -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>;
@@ -91,17 +91,15 @@ declare namespace index$3 {
91
91
  export { ComposerCancel as Cancel, ComposerIf as If, ComposerInput as Input, ComposerRoot as Root, ComposerSend as Send };
92
92
  }
93
93
 
94
- type ComposerState = {
95
- isEditing: boolean;
96
- canCancel: boolean;
97
- edit: () => void;
98
- send: () => void;
99
- cancel: () => void;
94
+ type BaseComposerState = {
100
95
  value: string;
101
96
  setValue: (value: string) => void;
102
97
  };
103
- type ComposerStore = {
104
- useComposer: UseBoundStore<StoreApi<ComposerState>>;
98
+ type MessageComposerState = BaseComposerState & {
99
+ isEditing: boolean;
100
+ edit: () => void;
101
+ send: () => void;
102
+ cancel: () => boolean;
105
103
  };
106
104
 
107
105
  type ThreadMessageTextPart = {
@@ -122,14 +120,13 @@ type ThreadMessageToolCallPart = {
122
120
  args: object;
123
121
  result?: object;
124
122
  };
123
+ type CreateThreadUserMessageContent = ThreadMessageTextPart | ThreadMessageImagePart;
125
124
  type ThreadUserMessageContent = ThreadMessageTextPart | ThreadMessageImagePart | ThreadMessageUIPart;
126
125
  type ThreadAssistantMessageContent = ThreadMessageTextPart | ThreadMessageImagePart | ThreadMessageUIPart | ThreadMessageToolCallPart;
127
126
  type ThreadMessageBase = {
128
127
  id: string;
129
- parentId: string;
128
+ parentId: string | null;
130
129
  createdAt: Date;
131
- branchId: number;
132
- branchCount: number;
133
130
  };
134
131
  type ThreadUserMessage = ThreadMessageBase & {
135
132
  role: "user";
@@ -139,11 +136,14 @@ type ThreadAssistantMessage = ThreadMessageBase & {
139
136
  role: "assistant";
140
137
  content: ThreadAssistantMessageContent[];
141
138
  };
139
+ type CreateThreadMessage = {
140
+ parentId: string | null;
141
+ content: CreateThreadUserMessageContent[];
142
+ };
142
143
  type ThreadMessage = ThreadUserMessage | ThreadAssistantMessage;
143
- type CreateThreadMessage = Omit<ThreadUserMessage, "id" | "branchId" | "branchCount" | "createdAt" | "role">;
144
144
 
145
145
  type MessageProviderProps = {
146
- children?: React.ReactNode;
146
+ children?: ReactNode;
147
147
  message: ThreadMessage;
148
148
  };
149
149
  declare const MessageProvider: FC<MessageProviderProps>;
@@ -162,7 +162,7 @@ type MessageIfFilters = {
162
162
  lastOrHover: boolean | undefined;
163
163
  };
164
164
  type MessageIfProps = RequireAtLeastOne<MessageIfFilters> & {
165
- children: React.ReactNode;
165
+ children: ReactNode;
166
166
  };
167
167
  declare const MessageIf: FC<MessageIfProps>;
168
168
 
@@ -226,7 +226,7 @@ declare const ActionBarRoot: react.ForwardRefExoticComponent<Pick<Omit<react.Det
226
226
  } & {
227
227
  asChild?: boolean;
228
228
  }, "key" | keyof react.HTMLAttributes<HTMLDivElement> | "asChild"> & {
229
- hideWhenBusy?: boolean;
229
+ hideWhenRunning?: boolean;
230
230
  autohide?: "always" | "not-last" | "never";
231
231
  autohideFloat?: "always" | "single-branch" | "never";
232
232
  } & react.RefAttributes<HTMLDivElement>>;
@@ -277,14 +277,16 @@ declare const VercelRSCAssistantProvider: FC<VercelAIAssistantProviderProps>;
277
277
 
278
278
  type MessageState = {
279
279
  message: ThreadMessage;
280
+ branches: string[];
280
281
  isLast: boolean;
281
282
  isCopied: boolean;
282
283
  setIsCopied: (value: boolean) => void;
283
284
  isHovering: boolean;
284
285
  setIsHovering: (value: boolean) => void;
285
286
  };
286
- type MessageStore = ComposerStore & {
287
+ type MessageStore = {
287
288
  useMessage: UseBoundStore<StoreApi<MessageState>>;
289
+ useComposer: UseBoundStore<StoreApi<MessageComposerState>>;
288
290
  };
289
291
 
290
292
  declare const useMessageContext: () => MessageStore;