@assistant-ui/react 0.5.18 → 0.5.20
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/dist/ModelConfigTypes-ComYH1b6.d.mts +156 -0
- package/dist/ModelConfigTypes-ComYH1b6.d.ts +156 -0
- package/dist/chunk-BV6Y7C43.mjs +61 -0
- package/dist/chunk-BV6Y7C43.mjs.map +1 -0
- package/dist/edge.d.mts +5 -90
- package/dist/edge.d.ts +5 -90
- package/dist/edge.mjs +44 -56
- package/dist/edge.mjs.map +1 -1
- package/dist/index.d.mts +36 -13
- package/dist/index.d.ts +36 -13
- package/dist/index.js +342 -282
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +307 -240
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.mts +128 -0
- package/dist/internal.d.ts +128 -0
- package/dist/internal.js +619 -0
- package/dist/internal.js.map +1 -0
- package/dist/internal.mjs +531 -0
- package/dist/internal.mjs.map +1 -0
- package/dist/styles/index.css +3 -3
- package/dist/styles/index.css.map +1 -1
- package/dist/styles/tailwindcss/thread.css +1 -1
- package/internal/README.md +1 -0
- package/internal/package.json +5 -0
- package/package.json +12 -1
@@ -0,0 +1,128 @@
|
|
1
|
+
import { M as ModelConfigProvider, c as ModelConfig, d as ThreadMessage, C as CoreMessage, A as AppendMessage, e as ContentPartStatus, f as TextContentPart } from './ModelConfigTypes-ComYH1b6.mjs';
|
2
|
+
import * as react from 'react';
|
3
|
+
import { ComponentType } from 'react';
|
4
|
+
import * as class_variance_authority from 'class-variance-authority';
|
5
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
6
|
+
import '@ai-sdk/provider';
|
7
|
+
import 'zod';
|
8
|
+
import 'json-schema';
|
9
|
+
|
10
|
+
type Unsubscribe = () => void;
|
11
|
+
|
12
|
+
declare class ProxyConfigProvider implements ModelConfigProvider {
|
13
|
+
private _providers;
|
14
|
+
getModelConfig(): ModelConfig;
|
15
|
+
registerModelConfigProvider(provider: ModelConfigProvider): () => void;
|
16
|
+
}
|
17
|
+
|
18
|
+
declare class MessageRepository {
|
19
|
+
private messages;
|
20
|
+
private head;
|
21
|
+
private root;
|
22
|
+
private performOp;
|
23
|
+
getMessages(): ThreadMessage[];
|
24
|
+
addOrUpdateMessage(parentId: string | null, message: ThreadMessage): void;
|
25
|
+
getMessage(messageId: string): {
|
26
|
+
parentId: string | null;
|
27
|
+
message: ThreadMessage;
|
28
|
+
};
|
29
|
+
appendOptimisticMessage(parentId: string | null, message: CoreMessage): string;
|
30
|
+
deleteMessage(messageId: string, replacementId?: string | null | undefined): void;
|
31
|
+
getBranches(messageId: string): string[];
|
32
|
+
switchToBranch(messageId: string): void;
|
33
|
+
resetHead(messageId: string | null): void;
|
34
|
+
}
|
35
|
+
|
36
|
+
type ReactThreadRuntime = ThreadRuntime & {
|
37
|
+
unstable_synchronizer?: ComponentType;
|
38
|
+
};
|
39
|
+
|
40
|
+
type AddToolResultOptions = {
|
41
|
+
messageId: string;
|
42
|
+
toolCallId: string;
|
43
|
+
result: any;
|
44
|
+
};
|
45
|
+
type RuntimeCapabilities = {
|
46
|
+
switchToBranch: boolean;
|
47
|
+
edit: boolean;
|
48
|
+
reload: boolean;
|
49
|
+
cancel: boolean;
|
50
|
+
copy: boolean;
|
51
|
+
};
|
52
|
+
type ThreadActionsState = Readonly<{
|
53
|
+
capabilities: Readonly<RuntimeCapabilities>;
|
54
|
+
getBranches: (messageId: string) => readonly string[];
|
55
|
+
switchToBranch: (branchId: string) => void;
|
56
|
+
append: (message: AppendMessage) => void;
|
57
|
+
startRun: (parentId: string | null) => void;
|
58
|
+
cancelRun: () => void;
|
59
|
+
addToolResult: (options: AddToolResultOptions) => void;
|
60
|
+
}>;
|
61
|
+
|
62
|
+
type ThreadState = Readonly<{
|
63
|
+
isRunning: boolean;
|
64
|
+
isDisabled: boolean;
|
65
|
+
}>;
|
66
|
+
|
67
|
+
type TextContentPartState = Readonly<{
|
68
|
+
status: ContentPartStatus;
|
69
|
+
part: TextContentPart;
|
70
|
+
}>;
|
71
|
+
|
72
|
+
type ThreadRuntime = Readonly<ThreadState & Omit<ThreadActionsState, "getRuntime"> & {
|
73
|
+
messages: readonly ThreadMessage[];
|
74
|
+
subscribe: (callback: () => void) => Unsubscribe;
|
75
|
+
}>;
|
76
|
+
|
77
|
+
type ThreadRuntimeWithSubscribe = {
|
78
|
+
readonly thread: ThreadRuntime;
|
79
|
+
subscribe: (callback: () => void) => Unsubscribe;
|
80
|
+
};
|
81
|
+
type AssistantRuntime = ThreadRuntimeWithSubscribe & {
|
82
|
+
switchToThread: (threadId: string | null) => void;
|
83
|
+
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
84
|
+
};
|
85
|
+
|
86
|
+
declare abstract class BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> implements AssistantRuntime {
|
87
|
+
private _thread;
|
88
|
+
constructor(_thread: TThreadRuntime);
|
89
|
+
get thread(): TThreadRuntime;
|
90
|
+
set thread(thread: TThreadRuntime);
|
91
|
+
abstract registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;
|
92
|
+
abstract switchToThread(threadId: string | null): void;
|
93
|
+
private _subscriptions;
|
94
|
+
subscribe(callback: () => void): Unsubscribe;
|
95
|
+
private subscriptionHandler;
|
96
|
+
}
|
97
|
+
|
98
|
+
declare const useSmooth: (state: TextContentPartState, smooth?: boolean) => TextContentPartState;
|
99
|
+
|
100
|
+
declare const withSmoothContextProvider: <C extends React.ComponentType<any>>(Component: C) => C;
|
101
|
+
declare const useSmoothStatus: () => {
|
102
|
+
type: "running";
|
103
|
+
} | {
|
104
|
+
type: "complete";
|
105
|
+
} | {
|
106
|
+
type: "incomplete";
|
107
|
+
reason: "cancelled" | "length" | "content-filter" | "other" | "error";
|
108
|
+
error?: unknown;
|
109
|
+
} | {
|
110
|
+
type: "requires-action";
|
111
|
+
reason: "tool-calls";
|
112
|
+
};
|
113
|
+
|
114
|
+
declare const TooltipIconButton: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
115
|
+
ref?: ((instance: HTMLButtonElement | null) => void | react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | react.RefObject<HTMLButtonElement> | null | undefined;
|
116
|
+
} & {
|
117
|
+
asChild?: boolean;
|
118
|
+
}, "ref"> & class_variance_authority.VariantProps<(props?: ({
|
119
|
+
variant?: "default" | "outline" | "ghost" | null | undefined;
|
120
|
+
size?: "default" | "icon" | null | undefined;
|
121
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string> & {
|
122
|
+
tooltip: string;
|
123
|
+
side?: "top" | "bottom" | "left" | "right";
|
124
|
+
} & react.RefAttributes<HTMLButtonElement>>;
|
125
|
+
|
126
|
+
declare const generateId: (size?: number) => string;
|
127
|
+
|
128
|
+
export { BaseAssistantRuntime, MessageRepository, ProxyConfigProvider, TooltipIconButton, generateId, useSmooth, useSmoothStatus, withSmoothContextProvider };
|
@@ -0,0 +1,128 @@
|
|
1
|
+
import { M as ModelConfigProvider, c as ModelConfig, d as ThreadMessage, C as CoreMessage, A as AppendMessage, e as ContentPartStatus, f as TextContentPart } from './ModelConfigTypes-ComYH1b6.js';
|
2
|
+
import * as react from 'react';
|
3
|
+
import { ComponentType } from 'react';
|
4
|
+
import * as class_variance_authority from 'class-variance-authority';
|
5
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
6
|
+
import '@ai-sdk/provider';
|
7
|
+
import 'zod';
|
8
|
+
import 'json-schema';
|
9
|
+
|
10
|
+
type Unsubscribe = () => void;
|
11
|
+
|
12
|
+
declare class ProxyConfigProvider implements ModelConfigProvider {
|
13
|
+
private _providers;
|
14
|
+
getModelConfig(): ModelConfig;
|
15
|
+
registerModelConfigProvider(provider: ModelConfigProvider): () => void;
|
16
|
+
}
|
17
|
+
|
18
|
+
declare class MessageRepository {
|
19
|
+
private messages;
|
20
|
+
private head;
|
21
|
+
private root;
|
22
|
+
private performOp;
|
23
|
+
getMessages(): ThreadMessage[];
|
24
|
+
addOrUpdateMessage(parentId: string | null, message: ThreadMessage): void;
|
25
|
+
getMessage(messageId: string): {
|
26
|
+
parentId: string | null;
|
27
|
+
message: ThreadMessage;
|
28
|
+
};
|
29
|
+
appendOptimisticMessage(parentId: string | null, message: CoreMessage): string;
|
30
|
+
deleteMessage(messageId: string, replacementId?: string | null | undefined): void;
|
31
|
+
getBranches(messageId: string): string[];
|
32
|
+
switchToBranch(messageId: string): void;
|
33
|
+
resetHead(messageId: string | null): void;
|
34
|
+
}
|
35
|
+
|
36
|
+
type ReactThreadRuntime = ThreadRuntime & {
|
37
|
+
unstable_synchronizer?: ComponentType;
|
38
|
+
};
|
39
|
+
|
40
|
+
type AddToolResultOptions = {
|
41
|
+
messageId: string;
|
42
|
+
toolCallId: string;
|
43
|
+
result: any;
|
44
|
+
};
|
45
|
+
type RuntimeCapabilities = {
|
46
|
+
switchToBranch: boolean;
|
47
|
+
edit: boolean;
|
48
|
+
reload: boolean;
|
49
|
+
cancel: boolean;
|
50
|
+
copy: boolean;
|
51
|
+
};
|
52
|
+
type ThreadActionsState = Readonly<{
|
53
|
+
capabilities: Readonly<RuntimeCapabilities>;
|
54
|
+
getBranches: (messageId: string) => readonly string[];
|
55
|
+
switchToBranch: (branchId: string) => void;
|
56
|
+
append: (message: AppendMessage) => void;
|
57
|
+
startRun: (parentId: string | null) => void;
|
58
|
+
cancelRun: () => void;
|
59
|
+
addToolResult: (options: AddToolResultOptions) => void;
|
60
|
+
}>;
|
61
|
+
|
62
|
+
type ThreadState = Readonly<{
|
63
|
+
isRunning: boolean;
|
64
|
+
isDisabled: boolean;
|
65
|
+
}>;
|
66
|
+
|
67
|
+
type TextContentPartState = Readonly<{
|
68
|
+
status: ContentPartStatus;
|
69
|
+
part: TextContentPart;
|
70
|
+
}>;
|
71
|
+
|
72
|
+
type ThreadRuntime = Readonly<ThreadState & Omit<ThreadActionsState, "getRuntime"> & {
|
73
|
+
messages: readonly ThreadMessage[];
|
74
|
+
subscribe: (callback: () => void) => Unsubscribe;
|
75
|
+
}>;
|
76
|
+
|
77
|
+
type ThreadRuntimeWithSubscribe = {
|
78
|
+
readonly thread: ThreadRuntime;
|
79
|
+
subscribe: (callback: () => void) => Unsubscribe;
|
80
|
+
};
|
81
|
+
type AssistantRuntime = ThreadRuntimeWithSubscribe & {
|
82
|
+
switchToThread: (threadId: string | null) => void;
|
83
|
+
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
84
|
+
};
|
85
|
+
|
86
|
+
declare abstract class BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> implements AssistantRuntime {
|
87
|
+
private _thread;
|
88
|
+
constructor(_thread: TThreadRuntime);
|
89
|
+
get thread(): TThreadRuntime;
|
90
|
+
set thread(thread: TThreadRuntime);
|
91
|
+
abstract registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;
|
92
|
+
abstract switchToThread(threadId: string | null): void;
|
93
|
+
private _subscriptions;
|
94
|
+
subscribe(callback: () => void): Unsubscribe;
|
95
|
+
private subscriptionHandler;
|
96
|
+
}
|
97
|
+
|
98
|
+
declare const useSmooth: (state: TextContentPartState, smooth?: boolean) => TextContentPartState;
|
99
|
+
|
100
|
+
declare const withSmoothContextProvider: <C extends React.ComponentType<any>>(Component: C) => C;
|
101
|
+
declare const useSmoothStatus: () => {
|
102
|
+
type: "running";
|
103
|
+
} | {
|
104
|
+
type: "complete";
|
105
|
+
} | {
|
106
|
+
type: "incomplete";
|
107
|
+
reason: "cancelled" | "length" | "content-filter" | "other" | "error";
|
108
|
+
error?: unknown;
|
109
|
+
} | {
|
110
|
+
type: "requires-action";
|
111
|
+
reason: "tool-calls";
|
112
|
+
};
|
113
|
+
|
114
|
+
declare const TooltipIconButton: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
115
|
+
ref?: ((instance: HTMLButtonElement | null) => void | react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | react.RefObject<HTMLButtonElement> | null | undefined;
|
116
|
+
} & {
|
117
|
+
asChild?: boolean;
|
118
|
+
}, "ref"> & class_variance_authority.VariantProps<(props?: ({
|
119
|
+
variant?: "default" | "outline" | "ghost" | null | undefined;
|
120
|
+
size?: "default" | "icon" | null | undefined;
|
121
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string> & {
|
122
|
+
tooltip: string;
|
123
|
+
side?: "top" | "bottom" | "left" | "right";
|
124
|
+
} & react.RefAttributes<HTMLButtonElement>>;
|
125
|
+
|
126
|
+
declare const generateId: (size?: number) => string;
|
127
|
+
|
128
|
+
export { BaseAssistantRuntime, MessageRepository, ProxyConfigProvider, TooltipIconButton, generateId, useSmooth, useSmoothStatus, withSmoothContextProvider };
|