@assistant-ui/react 0.5.20 → 0.5.21

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,64 @@
1
- import { LanguageModelV1LogProbs } from '@ai-sdk/provider';
2
- import { ReactNode } from 'react';
3
1
  import { z } from 'zod';
4
2
  import { JSONSchema7 } from 'json-schema';
3
+ import { LanguageModelV1LogProbs } from '@ai-sdk/provider';
4
+ import { ReactNode } from 'react';
5
+
6
+ declare const LanguageModelV1CallSettingsSchema: z.ZodObject<{
7
+ maxTokens: z.ZodOptional<z.ZodNumber>;
8
+ temperature: z.ZodOptional<z.ZodNumber>;
9
+ topP: z.ZodOptional<z.ZodNumber>;
10
+ presencePenalty: z.ZodOptional<z.ZodNumber>;
11
+ frequencyPenalty: z.ZodOptional<z.ZodNumber>;
12
+ seed: z.ZodOptional<z.ZodNumber>;
13
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodString>>>;
14
+ }, "strip", z.ZodTypeAny, {
15
+ maxTokens?: number | undefined;
16
+ temperature?: number | undefined;
17
+ topP?: number | undefined;
18
+ presencePenalty?: number | undefined;
19
+ frequencyPenalty?: number | undefined;
20
+ seed?: number | undefined;
21
+ headers?: Record<string, string | undefined> | undefined;
22
+ }, {
23
+ maxTokens?: number | undefined;
24
+ temperature?: number | undefined;
25
+ topP?: number | undefined;
26
+ presencePenalty?: number | undefined;
27
+ frequencyPenalty?: number | undefined;
28
+ seed?: number | undefined;
29
+ headers?: Record<string, string | undefined> | undefined;
30
+ }>;
31
+ type LanguageModelV1CallSettings = z.infer<typeof LanguageModelV1CallSettingsSchema>;
32
+ declare const LanguageModelConfigSchema: z.ZodObject<{
33
+ apiKey: z.ZodOptional<z.ZodString>;
34
+ baseUrl: z.ZodOptional<z.ZodString>;
35
+ modelName: z.ZodOptional<z.ZodString>;
36
+ }, "strip", z.ZodTypeAny, {
37
+ apiKey?: string | undefined;
38
+ baseUrl?: string | undefined;
39
+ modelName?: string | undefined;
40
+ }, {
41
+ apiKey?: string | undefined;
42
+ baseUrl?: string | undefined;
43
+ modelName?: string | undefined;
44
+ }>;
45
+ type LanguageModelConfig = z.infer<typeof LanguageModelConfigSchema>;
46
+ type ToolExecuteFunction<TArgs, TResult> = (args: TArgs) => TResult | Promise<TResult>;
47
+ type Tool<TArgs extends Record<string, unknown> = Record<string | number, unknown>, TResult = unknown> = {
48
+ description?: string | undefined;
49
+ parameters: z.ZodSchema<TArgs> | JSONSchema7;
50
+ execute?: ToolExecuteFunction<TArgs, TResult>;
51
+ };
52
+ type ModelConfig = {
53
+ priority?: number | undefined;
54
+ system?: string | undefined;
55
+ tools?: Record<string, Tool<any, any>> | undefined;
56
+ callSettings?: LanguageModelV1CallSettings | undefined;
57
+ config?: LanguageModelConfig | undefined;
58
+ };
59
+ type ModelConfigProvider = {
60
+ getModelConfig: () => ModelConfig;
61
+ };
5
62
 
6
63
  type TextContentPart = {
7
64
  type: "text";
@@ -48,6 +105,10 @@ type ContentPartStatus = {
48
105
  reason: "cancelled" | "length" | "content-filter" | "other" | "error";
49
106
  error?: unknown;
50
107
  };
108
+ type ToolCallContentPartStatus = {
109
+ type: "requires-action";
110
+ reason: "tool-calls";
111
+ } | ContentPartStatus;
51
112
  type MessageStatus = {
52
113
  type: "running";
53
114
  } | {
@@ -96,61 +157,4 @@ type CoreAssistantMessage = {
96
157
  };
97
158
  type CoreMessage = CoreSystemMessage | CoreUserMessage | CoreAssistantMessage;
98
159
 
99
- declare const LanguageModelV1CallSettingsSchema: z.ZodObject<{
100
- maxTokens: z.ZodOptional<z.ZodNumber>;
101
- temperature: z.ZodOptional<z.ZodNumber>;
102
- topP: z.ZodOptional<z.ZodNumber>;
103
- presencePenalty: z.ZodOptional<z.ZodNumber>;
104
- frequencyPenalty: z.ZodOptional<z.ZodNumber>;
105
- seed: z.ZodOptional<z.ZodNumber>;
106
- headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodString>>>;
107
- }, "strip", z.ZodTypeAny, {
108
- maxTokens?: number | undefined;
109
- temperature?: number | undefined;
110
- topP?: number | undefined;
111
- presencePenalty?: number | undefined;
112
- frequencyPenalty?: number | undefined;
113
- seed?: number | undefined;
114
- headers?: Record<string, string | undefined> | undefined;
115
- }, {
116
- maxTokens?: number | undefined;
117
- temperature?: number | undefined;
118
- topP?: number | undefined;
119
- presencePenalty?: number | undefined;
120
- frequencyPenalty?: number | undefined;
121
- seed?: number | undefined;
122
- headers?: Record<string, string | undefined> | undefined;
123
- }>;
124
- type LanguageModelV1CallSettings = z.infer<typeof LanguageModelV1CallSettingsSchema>;
125
- declare const LanguageModelConfigSchema: z.ZodObject<{
126
- apiKey: z.ZodOptional<z.ZodString>;
127
- baseUrl: z.ZodOptional<z.ZodString>;
128
- modelName: z.ZodOptional<z.ZodString>;
129
- }, "strip", z.ZodTypeAny, {
130
- apiKey?: string | undefined;
131
- baseUrl?: string | undefined;
132
- modelName?: string | undefined;
133
- }, {
134
- apiKey?: string | undefined;
135
- baseUrl?: string | undefined;
136
- modelName?: string | undefined;
137
- }>;
138
- type LanguageModelConfig = z.infer<typeof LanguageModelConfigSchema>;
139
- type ToolExecuteFunction<TArgs, TResult> = (args: TArgs) => TResult | Promise<TResult>;
140
- type Tool<TArgs extends Record<string, unknown> = Record<string | number, unknown>, TResult = unknown> = {
141
- description?: string | undefined;
142
- parameters: z.ZodSchema<TArgs> | JSONSchema7;
143
- execute?: ToolExecuteFunction<TArgs, TResult>;
144
- };
145
- type ModelConfig = {
146
- priority?: number | undefined;
147
- system?: string | undefined;
148
- tools?: Record<string, Tool<any, any>> | undefined;
149
- callSettings?: LanguageModelV1CallSettings | undefined;
150
- config?: LanguageModelConfig | undefined;
151
- };
152
- type ModelConfigProvider = {
153
- getModelConfig: () => ModelConfig;
154
- };
155
-
156
- export type { AppendMessage as A, CoreMessage as C, LanguageModelV1CallSettings as L, ModelConfigProvider as M, Tool as T, ThreadRoundtrip as a, LanguageModelConfig as b, ModelConfig as c, ThreadMessage as d, ContentPartStatus as e, TextContentPart as f };
160
+ export type { AppendMessage as A, ContentPartStatus as C, ImageContentPart as I, LanguageModelV1CallSettings as L, MessageStatus as M, ThreadAssistantContentPart as T, UIContentPart as U, ThreadRoundtrip as a, ThreadMessage as b, ModelConfig as c, TextContentPart as d, ToolCallContentPart as e, ToolCallContentPartStatus as f, CoreMessage as g, ModelConfigProvider as h, Tool as i, CoreToolCallContentPart as j, ThreadUserContentPart as k, ThreadSystemMessage as l, ThreadAssistantMessage as m, ThreadUserMessage as n, CoreUserContentPart as o, CoreAssistantContentPart as p, CoreSystemMessage as q, CoreUserMessage as r, CoreAssistantMessage as s, LanguageModelConfig as t };
@@ -1,7 +1,64 @@
1
- import { LanguageModelV1LogProbs } from '@ai-sdk/provider';
2
- import { ReactNode } from 'react';
3
1
  import { z } from 'zod';
4
2
  import { JSONSchema7 } from 'json-schema';
3
+ import { LanguageModelV1LogProbs } from '@ai-sdk/provider';
4
+ import { ReactNode } from 'react';
5
+
6
+ declare const LanguageModelV1CallSettingsSchema: z.ZodObject<{
7
+ maxTokens: z.ZodOptional<z.ZodNumber>;
8
+ temperature: z.ZodOptional<z.ZodNumber>;
9
+ topP: z.ZodOptional<z.ZodNumber>;
10
+ presencePenalty: z.ZodOptional<z.ZodNumber>;
11
+ frequencyPenalty: z.ZodOptional<z.ZodNumber>;
12
+ seed: z.ZodOptional<z.ZodNumber>;
13
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodString>>>;
14
+ }, "strip", z.ZodTypeAny, {
15
+ maxTokens?: number | undefined;
16
+ temperature?: number | undefined;
17
+ topP?: number | undefined;
18
+ presencePenalty?: number | undefined;
19
+ frequencyPenalty?: number | undefined;
20
+ seed?: number | undefined;
21
+ headers?: Record<string, string | undefined> | undefined;
22
+ }, {
23
+ maxTokens?: number | undefined;
24
+ temperature?: number | undefined;
25
+ topP?: number | undefined;
26
+ presencePenalty?: number | undefined;
27
+ frequencyPenalty?: number | undefined;
28
+ seed?: number | undefined;
29
+ headers?: Record<string, string | undefined> | undefined;
30
+ }>;
31
+ type LanguageModelV1CallSettings = z.infer<typeof LanguageModelV1CallSettingsSchema>;
32
+ declare const LanguageModelConfigSchema: z.ZodObject<{
33
+ apiKey: z.ZodOptional<z.ZodString>;
34
+ baseUrl: z.ZodOptional<z.ZodString>;
35
+ modelName: z.ZodOptional<z.ZodString>;
36
+ }, "strip", z.ZodTypeAny, {
37
+ apiKey?: string | undefined;
38
+ baseUrl?: string | undefined;
39
+ modelName?: string | undefined;
40
+ }, {
41
+ apiKey?: string | undefined;
42
+ baseUrl?: string | undefined;
43
+ modelName?: string | undefined;
44
+ }>;
45
+ type LanguageModelConfig = z.infer<typeof LanguageModelConfigSchema>;
46
+ type ToolExecuteFunction<TArgs, TResult> = (args: TArgs) => TResult | Promise<TResult>;
47
+ type Tool<TArgs extends Record<string, unknown> = Record<string | number, unknown>, TResult = unknown> = {
48
+ description?: string | undefined;
49
+ parameters: z.ZodSchema<TArgs> | JSONSchema7;
50
+ execute?: ToolExecuteFunction<TArgs, TResult>;
51
+ };
52
+ type ModelConfig = {
53
+ priority?: number | undefined;
54
+ system?: string | undefined;
55
+ tools?: Record<string, Tool<any, any>> | undefined;
56
+ callSettings?: LanguageModelV1CallSettings | undefined;
57
+ config?: LanguageModelConfig | undefined;
58
+ };
59
+ type ModelConfigProvider = {
60
+ getModelConfig: () => ModelConfig;
61
+ };
5
62
 
6
63
  type TextContentPart = {
7
64
  type: "text";
@@ -48,6 +105,10 @@ type ContentPartStatus = {
48
105
  reason: "cancelled" | "length" | "content-filter" | "other" | "error";
49
106
  error?: unknown;
50
107
  };
108
+ type ToolCallContentPartStatus = {
109
+ type: "requires-action";
110
+ reason: "tool-calls";
111
+ } | ContentPartStatus;
51
112
  type MessageStatus = {
52
113
  type: "running";
53
114
  } | {
@@ -96,61 +157,4 @@ type CoreAssistantMessage = {
96
157
  };
97
158
  type CoreMessage = CoreSystemMessage | CoreUserMessage | CoreAssistantMessage;
98
159
 
99
- declare const LanguageModelV1CallSettingsSchema: z.ZodObject<{
100
- maxTokens: z.ZodOptional<z.ZodNumber>;
101
- temperature: z.ZodOptional<z.ZodNumber>;
102
- topP: z.ZodOptional<z.ZodNumber>;
103
- presencePenalty: z.ZodOptional<z.ZodNumber>;
104
- frequencyPenalty: z.ZodOptional<z.ZodNumber>;
105
- seed: z.ZodOptional<z.ZodNumber>;
106
- headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodString>>>;
107
- }, "strip", z.ZodTypeAny, {
108
- maxTokens?: number | undefined;
109
- temperature?: number | undefined;
110
- topP?: number | undefined;
111
- presencePenalty?: number | undefined;
112
- frequencyPenalty?: number | undefined;
113
- seed?: number | undefined;
114
- headers?: Record<string, string | undefined> | undefined;
115
- }, {
116
- maxTokens?: number | undefined;
117
- temperature?: number | undefined;
118
- topP?: number | undefined;
119
- presencePenalty?: number | undefined;
120
- frequencyPenalty?: number | undefined;
121
- seed?: number | undefined;
122
- headers?: Record<string, string | undefined> | undefined;
123
- }>;
124
- type LanguageModelV1CallSettings = z.infer<typeof LanguageModelV1CallSettingsSchema>;
125
- declare const LanguageModelConfigSchema: z.ZodObject<{
126
- apiKey: z.ZodOptional<z.ZodString>;
127
- baseUrl: z.ZodOptional<z.ZodString>;
128
- modelName: z.ZodOptional<z.ZodString>;
129
- }, "strip", z.ZodTypeAny, {
130
- apiKey?: string | undefined;
131
- baseUrl?: string | undefined;
132
- modelName?: string | undefined;
133
- }, {
134
- apiKey?: string | undefined;
135
- baseUrl?: string | undefined;
136
- modelName?: string | undefined;
137
- }>;
138
- type LanguageModelConfig = z.infer<typeof LanguageModelConfigSchema>;
139
- type ToolExecuteFunction<TArgs, TResult> = (args: TArgs) => TResult | Promise<TResult>;
140
- type Tool<TArgs extends Record<string, unknown> = Record<string | number, unknown>, TResult = unknown> = {
141
- description?: string | undefined;
142
- parameters: z.ZodSchema<TArgs> | JSONSchema7;
143
- execute?: ToolExecuteFunction<TArgs, TResult>;
144
- };
145
- type ModelConfig = {
146
- priority?: number | undefined;
147
- system?: string | undefined;
148
- tools?: Record<string, Tool<any, any>> | undefined;
149
- callSettings?: LanguageModelV1CallSettings | undefined;
150
- config?: LanguageModelConfig | undefined;
151
- };
152
- type ModelConfigProvider = {
153
- getModelConfig: () => ModelConfig;
154
- };
155
-
156
- export type { AppendMessage as A, CoreMessage as C, LanguageModelV1CallSettings as L, ModelConfigProvider as M, Tool as T, ThreadRoundtrip as a, LanguageModelConfig as b, ModelConfig as c, ThreadMessage as d, ContentPartStatus as e, TextContentPart as f };
160
+ export type { AppendMessage as A, ContentPartStatus as C, ImageContentPart as I, LanguageModelV1CallSettings as L, MessageStatus as M, ThreadAssistantContentPart as T, UIContentPart as U, ThreadRoundtrip as a, ThreadMessage as b, ModelConfig as c, TextContentPart as d, ToolCallContentPart as e, ToolCallContentPartStatus as f, CoreMessage as g, ModelConfigProvider as h, Tool as i, CoreToolCallContentPart as j, ThreadUserContentPart as k, ThreadSystemMessage as l, ThreadAssistantMessage as m, ThreadUserMessage as n, CoreUserContentPart as o, CoreAssistantContentPart as p, CoreSystemMessage as q, CoreUserMessage as r, CoreAssistantMessage as s, LanguageModelConfig as t };
@@ -0,0 +1,156 @@
1
+ import { h as ModelConfigProvider, c as ModelConfig, b as ThreadMessage, g as CoreMessage, C as ContentPartStatus, f as ToolCallContentPartStatus, d as TextContentPart, I as ImageContentPart, U as UIContentPart, e as ToolCallContentPart, A as AppendMessage } from './AssistantTypes-D93BmqD5.mjs';
2
+ import * as react from 'react';
3
+ import { ComponentType } from 'react';
4
+ import * as class_variance_authority from 'class-variance-authority';
5
+ import { VariantProps } from 'class-variance-authority';
6
+ import * as class_variance_authority_types from 'class-variance-authority/types';
7
+ import { Primitive } from '@radix-ui/react-primitive';
8
+
9
+ type Unsubscribe = () => void;
10
+
11
+ type ReactThreadRuntime = ThreadRuntime & {
12
+ unstable_synchronizer?: ComponentType;
13
+ };
14
+
15
+ declare abstract class BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> implements AssistantRuntime {
16
+ private _thread;
17
+ constructor(_thread: TThreadRuntime);
18
+ get thread(): TThreadRuntime;
19
+ set thread(thread: TThreadRuntime);
20
+ abstract registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;
21
+ abstract switchToThread(threadId: string | null): void;
22
+ private _subscriptions;
23
+ subscribe(callback: () => void): Unsubscribe;
24
+ private subscriptionHandler;
25
+ }
26
+
27
+ declare class ProxyConfigProvider implements ModelConfigProvider {
28
+ private _providers;
29
+ getModelConfig(): ModelConfig;
30
+ registerModelConfigProvider(provider: ModelConfigProvider): () => void;
31
+ }
32
+
33
+ declare class MessageRepository {
34
+ private messages;
35
+ private head;
36
+ private root;
37
+ private performOp;
38
+ getMessages(): ThreadMessage[];
39
+ addOrUpdateMessage(parentId: string | null, message: ThreadMessage): void;
40
+ getMessage(messageId: string): {
41
+ parentId: string | null;
42
+ message: ThreadMessage;
43
+ };
44
+ appendOptimisticMessage(parentId: string | null, message: CoreMessage): string;
45
+ deleteMessage(messageId: string, replacementId?: string | null | undefined): void;
46
+ getBranches(messageId: string): string[];
47
+ switchToBranch(messageId: string): void;
48
+ resetHead(messageId: string | null): void;
49
+ }
50
+
51
+ type TextContentPartState = Readonly<{
52
+ status: ContentPartStatus;
53
+ part: TextContentPart;
54
+ }>;
55
+ type ContentPartState = Readonly<{
56
+ status: ContentPartStatus | ToolCallContentPartStatus;
57
+ part: TextContentPart | ImageContentPart | UIContentPart | ToolCallContentPart;
58
+ }>;
59
+
60
+ declare const useSmooth: (state: TextContentPartState, smooth?: boolean) => TextContentPartState;
61
+
62
+ declare const withSmoothContextProvider: <C extends React.ComponentType<any>>(Component: C) => C;
63
+ declare const useSmoothStatus: () => {
64
+ type: "running";
65
+ } | {
66
+ type: "complete";
67
+ } | {
68
+ type: "incomplete";
69
+ reason: "cancelled" | "length" | "content-filter" | "other" | "error";
70
+ error?: unknown;
71
+ } | {
72
+ type: "requires-action";
73
+ reason: "tool-calls";
74
+ };
75
+
76
+ declare const buttonVariants: (props?: ({
77
+ variant?: "default" | "outline" | "ghost" | null | undefined;
78
+ size?: "default" | "icon" | null | undefined;
79
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
80
+ type ButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button> & VariantProps<typeof buttonVariants>;
81
+
82
+ type TooltipIconButtonProps = ButtonProps & {
83
+ tooltip: string;
84
+ side?: "top" | "bottom" | "left" | "right";
85
+ };
86
+ declare const TooltipIconButton: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
87
+ 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;
88
+ } & {
89
+ asChild?: boolean;
90
+ }, "ref"> & class_variance_authority.VariantProps<(props?: ({
91
+ variant?: "default" | "outline" | "ghost" | null | undefined;
92
+ size?: "default" | "icon" | null | undefined;
93
+ } & class_variance_authority_types.ClassProp) | undefined) => string> & {
94
+ tooltip: string;
95
+ side?: "top" | "bottom" | "left" | "right";
96
+ } & react.RefAttributes<HTMLButtonElement>>;
97
+
98
+ declare const generateId: (size?: number) => string;
99
+
100
+ type internal_BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> = BaseAssistantRuntime<TThreadRuntime>;
101
+ declare const internal_BaseAssistantRuntime: typeof BaseAssistantRuntime;
102
+ type internal_MessageRepository = MessageRepository;
103
+ declare const internal_MessageRepository: typeof MessageRepository;
104
+ type internal_ProxyConfigProvider = ProxyConfigProvider;
105
+ declare const internal_ProxyConfigProvider: typeof ProxyConfigProvider;
106
+ declare const internal_TooltipIconButton: typeof TooltipIconButton;
107
+ declare const internal_generateId: typeof generateId;
108
+ declare const internal_useSmooth: typeof useSmooth;
109
+ declare const internal_useSmoothStatus: typeof useSmoothStatus;
110
+ declare const internal_withSmoothContextProvider: typeof withSmoothContextProvider;
111
+ declare namespace internal {
112
+ export { internal_BaseAssistantRuntime as BaseAssistantRuntime, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider, internal_TooltipIconButton as TooltipIconButton, internal_generateId as generateId, internal_useSmooth as useSmooth, internal_useSmoothStatus as useSmoothStatus, internal_withSmoothContextProvider as withSmoothContextProvider };
113
+ }
114
+
115
+ type AddToolResultOptions = {
116
+ messageId: string;
117
+ toolCallId: string;
118
+ result: any;
119
+ };
120
+ type RuntimeCapabilities = {
121
+ switchToBranch: boolean;
122
+ edit: boolean;
123
+ reload: boolean;
124
+ cancel: boolean;
125
+ copy: boolean;
126
+ };
127
+ type ThreadActionsState = Readonly<{
128
+ capabilities: Readonly<RuntimeCapabilities>;
129
+ getBranches: (messageId: string) => readonly string[];
130
+ switchToBranch: (branchId: string) => void;
131
+ append: (message: AppendMessage) => void;
132
+ startRun: (parentId: string | null) => void;
133
+ cancelRun: () => void;
134
+ addToolResult: (options: AddToolResultOptions) => void;
135
+ }>;
136
+
137
+ type ThreadRuntime = Readonly<ThreadState & Omit<ThreadActionsState, "getRuntime"> & {
138
+ messages: readonly ThreadMessage[];
139
+ subscribe: (callback: () => void) => Unsubscribe;
140
+ }>;
141
+
142
+ type ThreadRuntimeWithSubscribe = {
143
+ readonly thread: ThreadRuntime;
144
+ subscribe: (callback: () => void) => Unsubscribe;
145
+ };
146
+ type AssistantRuntime = ThreadRuntimeWithSubscribe & {
147
+ switchToThread: (threadId: string | null) => void;
148
+ registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
149
+ };
150
+
151
+ type ThreadState = Readonly<{
152
+ isRunning: boolean;
153
+ isDisabled: boolean;
154
+ }>;
155
+
156
+ export { type AddToolResultOptions as A, BaseAssistantRuntime as B, type ContentPartState as C, MessageRepository as M, ProxyConfigProvider as P, type ReactThreadRuntime as R, type ThreadRuntime as T, type Unsubscribe as U, type AssistantRuntime as a, type ThreadState as b, type ThreadActionsState as c, type TooltipIconButtonProps as d, type ButtonProps as e, TooltipIconButton as f, generateId as g, useSmoothStatus as h, internal as i, useSmooth as u, withSmoothContextProvider as w };
@@ -0,0 +1,156 @@
1
+ import { h as ModelConfigProvider, c as ModelConfig, b as ThreadMessage, g as CoreMessage, C as ContentPartStatus, f as ToolCallContentPartStatus, d as TextContentPart, I as ImageContentPart, U as UIContentPart, e as ToolCallContentPart, A as AppendMessage } from './AssistantTypes-D93BmqD5.js';
2
+ import * as react from 'react';
3
+ import { ComponentType } from 'react';
4
+ import * as class_variance_authority from 'class-variance-authority';
5
+ import { VariantProps } from 'class-variance-authority';
6
+ import * as class_variance_authority_types from 'class-variance-authority/types';
7
+ import { Primitive } from '@radix-ui/react-primitive';
8
+
9
+ type Unsubscribe = () => void;
10
+
11
+ type ReactThreadRuntime = ThreadRuntime & {
12
+ unstable_synchronizer?: ComponentType;
13
+ };
14
+
15
+ declare abstract class BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> implements AssistantRuntime {
16
+ private _thread;
17
+ constructor(_thread: TThreadRuntime);
18
+ get thread(): TThreadRuntime;
19
+ set thread(thread: TThreadRuntime);
20
+ abstract registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;
21
+ abstract switchToThread(threadId: string | null): void;
22
+ private _subscriptions;
23
+ subscribe(callback: () => void): Unsubscribe;
24
+ private subscriptionHandler;
25
+ }
26
+
27
+ declare class ProxyConfigProvider implements ModelConfigProvider {
28
+ private _providers;
29
+ getModelConfig(): ModelConfig;
30
+ registerModelConfigProvider(provider: ModelConfigProvider): () => void;
31
+ }
32
+
33
+ declare class MessageRepository {
34
+ private messages;
35
+ private head;
36
+ private root;
37
+ private performOp;
38
+ getMessages(): ThreadMessage[];
39
+ addOrUpdateMessage(parentId: string | null, message: ThreadMessage): void;
40
+ getMessage(messageId: string): {
41
+ parentId: string | null;
42
+ message: ThreadMessage;
43
+ };
44
+ appendOptimisticMessage(parentId: string | null, message: CoreMessage): string;
45
+ deleteMessage(messageId: string, replacementId?: string | null | undefined): void;
46
+ getBranches(messageId: string): string[];
47
+ switchToBranch(messageId: string): void;
48
+ resetHead(messageId: string | null): void;
49
+ }
50
+
51
+ type TextContentPartState = Readonly<{
52
+ status: ContentPartStatus;
53
+ part: TextContentPart;
54
+ }>;
55
+ type ContentPartState = Readonly<{
56
+ status: ContentPartStatus | ToolCallContentPartStatus;
57
+ part: TextContentPart | ImageContentPart | UIContentPart | ToolCallContentPart;
58
+ }>;
59
+
60
+ declare const useSmooth: (state: TextContentPartState, smooth?: boolean) => TextContentPartState;
61
+
62
+ declare const withSmoothContextProvider: <C extends React.ComponentType<any>>(Component: C) => C;
63
+ declare const useSmoothStatus: () => {
64
+ type: "running";
65
+ } | {
66
+ type: "complete";
67
+ } | {
68
+ type: "incomplete";
69
+ reason: "cancelled" | "length" | "content-filter" | "other" | "error";
70
+ error?: unknown;
71
+ } | {
72
+ type: "requires-action";
73
+ reason: "tool-calls";
74
+ };
75
+
76
+ declare const buttonVariants: (props?: ({
77
+ variant?: "default" | "outline" | "ghost" | null | undefined;
78
+ size?: "default" | "icon" | null | undefined;
79
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
80
+ type ButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button> & VariantProps<typeof buttonVariants>;
81
+
82
+ type TooltipIconButtonProps = ButtonProps & {
83
+ tooltip: string;
84
+ side?: "top" | "bottom" | "left" | "right";
85
+ };
86
+ declare const TooltipIconButton: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
87
+ 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;
88
+ } & {
89
+ asChild?: boolean;
90
+ }, "ref"> & class_variance_authority.VariantProps<(props?: ({
91
+ variant?: "default" | "outline" | "ghost" | null | undefined;
92
+ size?: "default" | "icon" | null | undefined;
93
+ } & class_variance_authority_types.ClassProp) | undefined) => string> & {
94
+ tooltip: string;
95
+ side?: "top" | "bottom" | "left" | "right";
96
+ } & react.RefAttributes<HTMLButtonElement>>;
97
+
98
+ declare const generateId: (size?: number) => string;
99
+
100
+ type internal_BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> = BaseAssistantRuntime<TThreadRuntime>;
101
+ declare const internal_BaseAssistantRuntime: typeof BaseAssistantRuntime;
102
+ type internal_MessageRepository = MessageRepository;
103
+ declare const internal_MessageRepository: typeof MessageRepository;
104
+ type internal_ProxyConfigProvider = ProxyConfigProvider;
105
+ declare const internal_ProxyConfigProvider: typeof ProxyConfigProvider;
106
+ declare const internal_TooltipIconButton: typeof TooltipIconButton;
107
+ declare const internal_generateId: typeof generateId;
108
+ declare const internal_useSmooth: typeof useSmooth;
109
+ declare const internal_useSmoothStatus: typeof useSmoothStatus;
110
+ declare const internal_withSmoothContextProvider: typeof withSmoothContextProvider;
111
+ declare namespace internal {
112
+ export { internal_BaseAssistantRuntime as BaseAssistantRuntime, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider, internal_TooltipIconButton as TooltipIconButton, internal_generateId as generateId, internal_useSmooth as useSmooth, internal_useSmoothStatus as useSmoothStatus, internal_withSmoothContextProvider as withSmoothContextProvider };
113
+ }
114
+
115
+ type AddToolResultOptions = {
116
+ messageId: string;
117
+ toolCallId: string;
118
+ result: any;
119
+ };
120
+ type RuntimeCapabilities = {
121
+ switchToBranch: boolean;
122
+ edit: boolean;
123
+ reload: boolean;
124
+ cancel: boolean;
125
+ copy: boolean;
126
+ };
127
+ type ThreadActionsState = Readonly<{
128
+ capabilities: Readonly<RuntimeCapabilities>;
129
+ getBranches: (messageId: string) => readonly string[];
130
+ switchToBranch: (branchId: string) => void;
131
+ append: (message: AppendMessage) => void;
132
+ startRun: (parentId: string | null) => void;
133
+ cancelRun: () => void;
134
+ addToolResult: (options: AddToolResultOptions) => void;
135
+ }>;
136
+
137
+ type ThreadRuntime = Readonly<ThreadState & Omit<ThreadActionsState, "getRuntime"> & {
138
+ messages: readonly ThreadMessage[];
139
+ subscribe: (callback: () => void) => Unsubscribe;
140
+ }>;
141
+
142
+ type ThreadRuntimeWithSubscribe = {
143
+ readonly thread: ThreadRuntime;
144
+ subscribe: (callback: () => void) => Unsubscribe;
145
+ };
146
+ type AssistantRuntime = ThreadRuntimeWithSubscribe & {
147
+ switchToThread: (threadId: string | null) => void;
148
+ registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
149
+ };
150
+
151
+ type ThreadState = Readonly<{
152
+ isRunning: boolean;
153
+ isDisabled: boolean;
154
+ }>;
155
+
156
+ export { type AddToolResultOptions as A, BaseAssistantRuntime as B, type ContentPartState as C, MessageRepository as M, ProxyConfigProvider as P, type ReactThreadRuntime as R, type ThreadRuntime as T, type Unsubscribe as U, type AssistantRuntime as a, type ThreadState as b, type ThreadActionsState as c, type TooltipIconButtonProps as d, type ButtonProps as e, TooltipIconButton as f, generateId as g, useSmoothStatus as h, internal as i, useSmooth as u, withSmoothContextProvider as w };