@assistant-ui/react 0.5.19 → 0.5.21
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/AssistantTypes-D93BmqD5.d.mts +160 -0
- package/dist/AssistantTypes-D93BmqD5.d.ts +160 -0
- package/dist/Thread-BbLf1cc4.d.mts +156 -0
- package/dist/Thread-jfAlPLli.d.ts +156 -0
- package/dist/chunk-2RKUKZSZ.mjs +761 -0
- package/dist/chunk-2RKUKZSZ.mjs.map +1 -0
- package/dist/chunk-BJPOCE4O.mjs +11 -0
- package/dist/chunk-BJPOCE4O.mjs.map +1 -0
- package/dist/chunk-QBS6JLLN.mjs +63 -0
- package/dist/chunk-QBS6JLLN.mjs.map +1 -0
- package/dist/chunk-V66MVXBH.mjs +608 -0
- package/dist/chunk-V66MVXBH.mjs.map +1 -0
- package/dist/edge.d.mts +5 -90
- package/dist/edge.d.ts +5 -90
- package/dist/edge.js +1 -0
- package/dist/edge.js.map +1 -1
- package/dist/edge.mjs +49 -799
- package/dist/edge.mjs.map +1 -1
- package/dist/index.d.mts +17 -293
- package/dist/index.d.ts +17 -293
- package/dist/index.js +341 -283
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +313 -1601
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.mts +9 -0
- package/dist/internal.d.ts +9 -0
- package/dist/internal.js +620 -0
- package/dist/internal.js.map +1 -0
- package/dist/internal.mjs +24 -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/dist/tailwindcss/index.js +1 -0
- package/dist/tailwindcss/index.js.map +1 -1
- package/dist/tailwindcss/index.mjs +3 -0
- package/dist/tailwindcss/index.mjs.map +1 -1
- package/internal/README.md +1 -0
- package/internal/package.json +5 -0
- package/package.json +12 -1
@@ -0,0 +1,160 @@
|
|
1
|
+
import { z } from 'zod';
|
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
|
+
};
|
62
|
+
|
63
|
+
type TextContentPart = {
|
64
|
+
type: "text";
|
65
|
+
text: string;
|
66
|
+
};
|
67
|
+
type ImageContentPart = {
|
68
|
+
type: "image";
|
69
|
+
image: string;
|
70
|
+
};
|
71
|
+
type UIContentPart = {
|
72
|
+
type: "ui";
|
73
|
+
display: ReactNode;
|
74
|
+
};
|
75
|
+
type CoreToolCallContentPart<TArgs extends Record<string, unknown> = Record<string | number, unknown>, TResult = unknown> = {
|
76
|
+
type: "tool-call";
|
77
|
+
toolCallId: string;
|
78
|
+
toolName: string;
|
79
|
+
args: TArgs;
|
80
|
+
result?: TResult | undefined;
|
81
|
+
isError?: boolean | undefined;
|
82
|
+
};
|
83
|
+
type ToolCallContentPart<TArgs extends Record<string, unknown> = Record<string | number, unknown>, TResult = unknown> = CoreToolCallContentPart<TArgs, TResult> & {
|
84
|
+
argsText: string;
|
85
|
+
};
|
86
|
+
type ThreadUserContentPart = TextContentPart | ImageContentPart | UIContentPart;
|
87
|
+
type ThreadAssistantContentPart = TextContentPart | ToolCallContentPart | UIContentPart;
|
88
|
+
type MessageCommonProps = {
|
89
|
+
id: string;
|
90
|
+
createdAt: Date;
|
91
|
+
};
|
92
|
+
type ThreadRoundtrip = {
|
93
|
+
logprobs?: LanguageModelV1LogProbs | undefined;
|
94
|
+
usage?: {
|
95
|
+
promptTokens: number;
|
96
|
+
completionTokens: number;
|
97
|
+
} | undefined;
|
98
|
+
};
|
99
|
+
type ContentPartStatus = {
|
100
|
+
type: "running";
|
101
|
+
} | {
|
102
|
+
type: "complete";
|
103
|
+
} | {
|
104
|
+
type: "incomplete";
|
105
|
+
reason: "cancelled" | "length" | "content-filter" | "other" | "error";
|
106
|
+
error?: unknown;
|
107
|
+
};
|
108
|
+
type ToolCallContentPartStatus = {
|
109
|
+
type: "requires-action";
|
110
|
+
reason: "tool-calls";
|
111
|
+
} | ContentPartStatus;
|
112
|
+
type MessageStatus = {
|
113
|
+
type: "running";
|
114
|
+
} | {
|
115
|
+
type: "requires-action";
|
116
|
+
reason: "tool-calls";
|
117
|
+
} | {
|
118
|
+
type: "complete";
|
119
|
+
reason: "stop" | "unknown";
|
120
|
+
} | {
|
121
|
+
type: "incomplete";
|
122
|
+
reason: "cancelled" | "tool-calls" | "length" | "content-filter" | "other" | "error";
|
123
|
+
error?: unknown;
|
124
|
+
};
|
125
|
+
type ThreadSystemMessage = MessageCommonProps & {
|
126
|
+
role: "system";
|
127
|
+
content: [TextContentPart];
|
128
|
+
};
|
129
|
+
type ThreadUserMessage = MessageCommonProps & {
|
130
|
+
role: "user";
|
131
|
+
content: ThreadUserContentPart[];
|
132
|
+
};
|
133
|
+
type ThreadAssistantMessage = MessageCommonProps & {
|
134
|
+
role: "assistant";
|
135
|
+
content: ThreadAssistantContentPart[];
|
136
|
+
status: MessageStatus;
|
137
|
+
roundtrips?: ThreadRoundtrip[] | undefined;
|
138
|
+
};
|
139
|
+
type AppendMessage = CoreMessage & {
|
140
|
+
parentId: string | null;
|
141
|
+
};
|
142
|
+
type ThreadMessage = ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage;
|
143
|
+
/** Core Message Types (without UI content parts) */
|
144
|
+
type CoreUserContentPart = TextContentPart | ImageContentPart;
|
145
|
+
type CoreAssistantContentPart = TextContentPart | CoreToolCallContentPart;
|
146
|
+
type CoreSystemMessage = {
|
147
|
+
role: "system";
|
148
|
+
content: [TextContentPart];
|
149
|
+
};
|
150
|
+
type CoreUserMessage = {
|
151
|
+
role: "user";
|
152
|
+
content: CoreUserContentPart[];
|
153
|
+
};
|
154
|
+
type CoreAssistantMessage = {
|
155
|
+
role: "assistant";
|
156
|
+
content: CoreAssistantContentPart[];
|
157
|
+
};
|
158
|
+
type CoreMessage = CoreSystemMessage | CoreUserMessage | CoreAssistantMessage;
|
159
|
+
|
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,160 @@
|
|
1
|
+
import { z } from 'zod';
|
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
|
+
};
|
62
|
+
|
63
|
+
type TextContentPart = {
|
64
|
+
type: "text";
|
65
|
+
text: string;
|
66
|
+
};
|
67
|
+
type ImageContentPart = {
|
68
|
+
type: "image";
|
69
|
+
image: string;
|
70
|
+
};
|
71
|
+
type UIContentPart = {
|
72
|
+
type: "ui";
|
73
|
+
display: ReactNode;
|
74
|
+
};
|
75
|
+
type CoreToolCallContentPart<TArgs extends Record<string, unknown> = Record<string | number, unknown>, TResult = unknown> = {
|
76
|
+
type: "tool-call";
|
77
|
+
toolCallId: string;
|
78
|
+
toolName: string;
|
79
|
+
args: TArgs;
|
80
|
+
result?: TResult | undefined;
|
81
|
+
isError?: boolean | undefined;
|
82
|
+
};
|
83
|
+
type ToolCallContentPart<TArgs extends Record<string, unknown> = Record<string | number, unknown>, TResult = unknown> = CoreToolCallContentPart<TArgs, TResult> & {
|
84
|
+
argsText: string;
|
85
|
+
};
|
86
|
+
type ThreadUserContentPart = TextContentPart | ImageContentPart | UIContentPart;
|
87
|
+
type ThreadAssistantContentPart = TextContentPart | ToolCallContentPart | UIContentPart;
|
88
|
+
type MessageCommonProps = {
|
89
|
+
id: string;
|
90
|
+
createdAt: Date;
|
91
|
+
};
|
92
|
+
type ThreadRoundtrip = {
|
93
|
+
logprobs?: LanguageModelV1LogProbs | undefined;
|
94
|
+
usage?: {
|
95
|
+
promptTokens: number;
|
96
|
+
completionTokens: number;
|
97
|
+
} | undefined;
|
98
|
+
};
|
99
|
+
type ContentPartStatus = {
|
100
|
+
type: "running";
|
101
|
+
} | {
|
102
|
+
type: "complete";
|
103
|
+
} | {
|
104
|
+
type: "incomplete";
|
105
|
+
reason: "cancelled" | "length" | "content-filter" | "other" | "error";
|
106
|
+
error?: unknown;
|
107
|
+
};
|
108
|
+
type ToolCallContentPartStatus = {
|
109
|
+
type: "requires-action";
|
110
|
+
reason: "tool-calls";
|
111
|
+
} | ContentPartStatus;
|
112
|
+
type MessageStatus = {
|
113
|
+
type: "running";
|
114
|
+
} | {
|
115
|
+
type: "requires-action";
|
116
|
+
reason: "tool-calls";
|
117
|
+
} | {
|
118
|
+
type: "complete";
|
119
|
+
reason: "stop" | "unknown";
|
120
|
+
} | {
|
121
|
+
type: "incomplete";
|
122
|
+
reason: "cancelled" | "tool-calls" | "length" | "content-filter" | "other" | "error";
|
123
|
+
error?: unknown;
|
124
|
+
};
|
125
|
+
type ThreadSystemMessage = MessageCommonProps & {
|
126
|
+
role: "system";
|
127
|
+
content: [TextContentPart];
|
128
|
+
};
|
129
|
+
type ThreadUserMessage = MessageCommonProps & {
|
130
|
+
role: "user";
|
131
|
+
content: ThreadUserContentPart[];
|
132
|
+
};
|
133
|
+
type ThreadAssistantMessage = MessageCommonProps & {
|
134
|
+
role: "assistant";
|
135
|
+
content: ThreadAssistantContentPart[];
|
136
|
+
status: MessageStatus;
|
137
|
+
roundtrips?: ThreadRoundtrip[] | undefined;
|
138
|
+
};
|
139
|
+
type AppendMessage = CoreMessage & {
|
140
|
+
parentId: string | null;
|
141
|
+
};
|
142
|
+
type ThreadMessage = ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage;
|
143
|
+
/** Core Message Types (without UI content parts) */
|
144
|
+
type CoreUserContentPart = TextContentPart | ImageContentPart;
|
145
|
+
type CoreAssistantContentPart = TextContentPart | CoreToolCallContentPart;
|
146
|
+
type CoreSystemMessage = {
|
147
|
+
role: "system";
|
148
|
+
content: [TextContentPart];
|
149
|
+
};
|
150
|
+
type CoreUserMessage = {
|
151
|
+
role: "user";
|
152
|
+
content: CoreUserContentPart[];
|
153
|
+
};
|
154
|
+
type CoreAssistantMessage = {
|
155
|
+
role: "assistant";
|
156
|
+
content: CoreAssistantContentPart[];
|
157
|
+
};
|
158
|
+
type CoreMessage = CoreSystemMessage | CoreUserMessage | CoreAssistantMessage;
|
159
|
+
|
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 };
|