@assistant-ui/react 0.0.29 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/AssistantRuntime-BM_jVV3g.d.mts +23 -0
- package/dist/AssistantRuntime-CBMSAJqH.d.mts +23 -0
- package/dist/AssistantRuntime-C_BvM7ZT.d.ts +23 -0
- package/dist/AssistantRuntime-DELpXWfG.d.ts +23 -0
- package/dist/ModelConfigTypes-B9UY4zxv.d.mts +55 -0
- package/dist/ModelConfigTypes-B9UY4zxv.d.ts +55 -0
- package/dist/ModelConfigTypes-BF5HxVrH.d.mts +55 -0
- package/dist/ModelConfigTypes-BF5HxVrH.d.ts +55 -0
- package/dist/ModelConfigTypes-Cf3yjaDu.d.mts +55 -0
- package/dist/ModelConfigTypes-Cf3yjaDu.d.ts +55 -0
- package/dist/chunk-3XZUKECF.mjs +207 -0
- package/dist/chunk-3XZUKECF.mjs.map +1 -0
- package/dist/chunk-4DQ2CIAD.mjs +69 -0
- package/dist/chunk-4DQ2CIAD.mjs.map +1 -0
- package/dist/chunk-5YONSDN4.mjs +200 -0
- package/dist/chunk-5YONSDN4.mjs.map +1 -0
- package/dist/chunk-CY4TTHR7.mjs +76 -0
- package/dist/chunk-CY4TTHR7.mjs.map +1 -0
- package/dist/chunk-DKAWDNW5.mjs +22 -0
- package/dist/chunk-DKAWDNW5.mjs.map +1 -0
- package/dist/chunk-GQKH2ADD.mjs +165 -0
- package/dist/chunk-GQKH2ADD.mjs.map +1 -0
- package/dist/chunk-J5LGTIGS.mjs +10 -0
- package/dist/chunk-J5LGTIGS.mjs.map +1 -0
- package/dist/chunk-X4HBDEFP.mjs +30 -0
- package/dist/chunk-X4HBDEFP.mjs.map +1 -0
- package/dist/experimental.d.mts +120 -0
- package/dist/experimental.d.ts +120 -0
- package/dist/experimental.js +407 -0
- package/dist/experimental.js.map +1 -0
- package/dist/experimental.mjs +144 -0
- package/dist/experimental.mjs.map +1 -0
- package/dist/index.d.mts +6 -266
- package/dist/index.d.ts +6 -266
- package/dist/index.js +77 -730
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -786
- package/dist/index.mjs.map +1 -1
- package/dist/internal-dlLjX30u.d.mts +75 -0
- package/dist/internal-dlLjX30u.d.ts +75 -0
- package/dist/internal.d.mts +25 -0
- package/dist/internal.d.ts +25 -0
- package/dist/internal.js +225 -0
- package/dist/internal.js.map +1 -0
- package/dist/internal.mjs +12 -0
- package/dist/internal.mjs.map +1 -0
- package/package.json +23 -3
package/dist/index.d.ts
CHANGED
@@ -1,10 +1,11 @@
|
|
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 {
|
5
|
-
|
6
|
-
import {
|
7
|
-
|
4
|
+
import { T as TextContentPart, I as ImageContentPart, U as UIContentPart, a as ToolCallContentPart } from './ModelConfigTypes-B9UY4zxv.js';
|
5
|
+
export { g as AppendContentPart, d as AppendMessage, e as AssistantContentPart, A as AssistantMessage, b as ThreadMessage, f as UserContentPart, c as UserMessage } from './ModelConfigTypes-B9UY4zxv.js';
|
6
|
+
import { T as ThreadRuntime, A as AssistantRuntime } from './AssistantRuntime-C_BvM7ZT.js';
|
7
|
+
export { U as Unsubscribe } from './AssistantRuntime-C_BvM7ZT.js';
|
8
|
+
import 'zod';
|
8
9
|
|
9
10
|
declare const useCopyMessage: ({ copiedDuration }: {
|
10
11
|
copiedDuration?: number | undefined;
|
@@ -133,46 +134,6 @@ type MessageIfProps = RequireAtLeastOne<MessageIfFilters> & {
|
|
133
134
|
};
|
134
135
|
declare const MessageIf: FC<MessageIfProps>;
|
135
136
|
|
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
137
|
type MessageContentProps = {
|
177
138
|
components?: {
|
178
139
|
Text?: ComponentType<{
|
@@ -275,234 +236,13 @@ declare namespace index {
|
|
275
236
|
export { ContentPartInProgressIndicator as InProgressIndicator };
|
276
237
|
}
|
277
238
|
|
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
|
-
type ThreadRuntime = Readonly<ThreadState & {
|
427
|
-
subscribe: (callback: () => void) => Unsubscribe;
|
428
|
-
}>;
|
429
|
-
|
430
|
-
type AssistantRuntime = ThreadRuntime;
|
431
|
-
|
432
239
|
type ReactThreadRuntime = ThreadRuntime & {
|
433
240
|
unstable_synchronizer?: ComponentType;
|
434
241
|
};
|
435
242
|
|
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
|
-
type ChatModelRunResult = {
|
473
|
-
content: AssistantContentPart[];
|
474
|
-
};
|
475
|
-
type ChatModelRunOptions = {
|
476
|
-
messages: ThreadMessage[];
|
477
|
-
abortSignal: AbortSignal;
|
478
|
-
onUpdate: (result: ChatModelRunResult) => void;
|
479
|
-
};
|
480
|
-
type ChatModelAdapter = {
|
481
|
-
run: (options: ChatModelRunOptions) => Promise<ChatModelRunResult>;
|
482
|
-
};
|
483
|
-
|
484
|
-
declare class LocalRuntime implements AssistantRuntime {
|
485
|
-
adapter: ChatModelAdapter;
|
486
|
-
private _subscriptions;
|
487
|
-
private abortController;
|
488
|
-
private repository;
|
489
|
-
get messages(): ThreadMessage[];
|
490
|
-
get isRunning(): boolean;
|
491
|
-
constructor(adapter: ChatModelAdapter);
|
492
|
-
getBranches(messageId: string): string[];
|
493
|
-
switchToBranch(branchId: string): void;
|
494
|
-
append(message: AppendMessage): Promise<void>;
|
495
|
-
startRun(parentId: string | null): Promise<void>;
|
496
|
-
cancelRun(): void;
|
497
|
-
private notifySubscribers;
|
498
|
-
subscribe(callback: () => void): Unsubscribe;
|
499
|
-
}
|
500
|
-
|
501
|
-
declare const useLocalRuntime: (adapter: ChatModelAdapter) => LocalRuntime;
|
502
|
-
|
503
243
|
type AssistantRuntimeProviderProps = {
|
504
244
|
runtime: AssistantRuntime;
|
505
245
|
};
|
506
246
|
declare const AssistantRuntimeProvider: react.NamedExoticComponent<PropsWithChildren<AssistantRuntimeProviderProps>>;
|
507
247
|
|
508
|
-
export { index$1 as ActionBarPrimitive,
|
248
|
+
export { index$1 as ActionBarPrimitive, AssistantRuntime, AssistantRuntimeProvider, index$2 as BranchPickerPrimitive, index$4 as ComposerPrimitive, index as ContentPartPrimitive, index$3 as MessagePrimitive, type ReactThreadRuntime, TextContentPart, index$5 as ThreadPrimitive, ThreadRuntime, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useReloadMessage };
|