@scenemesh/entity-engine-aimodule 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +854 -0
- package/dist/ai-core-LBGYFGOK.mjs +17 -0
- package/dist/ai-core-LBGYFGOK.mjs.map +1 -0
- package/dist/ai-core-UGJWSCQN.js +17 -0
- package/dist/ai-core-UGJWSCQN.js.map +1 -0
- package/dist/ai-core-manager-B3Z34RHA.mjs +9 -0
- package/dist/ai-core-manager-B3Z34RHA.mjs.map +1 -0
- package/dist/ai-core-manager-W7SSDCG5.js +9 -0
- package/dist/ai-core-manager-W7SSDCG5.js.map +1 -0
- package/dist/ai-embeddings-5ED5LDXX.mjs +17 -0
- package/dist/ai-embeddings-5ED5LDXX.mjs.map +1 -0
- package/dist/ai-embeddings-WCXZMMTZ.js +17 -0
- package/dist/ai-embeddings-WCXZMMTZ.js.map +1 -0
- package/dist/ai-form-renderer-24IWNMX5.js +233 -0
- package/dist/ai-form-renderer-24IWNMX5.js.map +1 -0
- package/dist/ai-form-renderer-BORQABF2.mjs +233 -0
- package/dist/ai-form-renderer-BORQABF2.mjs.map +1 -0
- package/dist/ai-provider-3PSCVEEN.mjs +17 -0
- package/dist/ai-provider-3PSCVEEN.mjs.map +1 -0
- package/dist/ai-provider-WMPMVZFL.js +17 -0
- package/dist/ai-provider-WMPMVZFL.js.map +1 -0
- package/dist/ai-renderer-7WGGWH5D.mjs +134 -0
- package/dist/ai-renderer-7WGGWH5D.mjs.map +1 -0
- package/dist/ai-renderer-OILYWAJV.js +134 -0
- package/dist/ai-renderer-OILYWAJV.js.map +1 -0
- package/dist/ai-settings-DGCFPK3U.js +15 -0
- package/dist/ai-settings-DGCFPK3U.js.map +1 -0
- package/dist/ai-settings-DTXEAB64.mjs +15 -0
- package/dist/ai-settings-DTXEAB64.mjs.map +1 -0
- package/dist/ai-structured-EGZ26ZS4.mjs +13 -0
- package/dist/ai-structured-EGZ26ZS4.mjs.map +1 -0
- package/dist/ai-structured-N2FZLO4A.js +13 -0
- package/dist/ai-structured-N2FZLO4A.js.map +1 -0
- package/dist/ai-tools-B3R77HZ3.js +19 -0
- package/dist/ai-tools-B3R77HZ3.js.map +1 -0
- package/dist/ai-tools-JAPVYQGE.mjs +19 -0
- package/dist/ai-tools-JAPVYQGE.mjs.map +1 -0
- package/dist/ai.module-GAHVCBTP.js +7 -0
- package/dist/ai.module-GAHVCBTP.js.map +1 -0
- package/dist/ai.module-TTPMTPB3.mjs +7 -0
- package/dist/ai.module-TTPMTPB3.mjs.map +1 -0
- package/dist/chunk-25C2NRSD.mjs +611 -0
- package/dist/chunk-25C2NRSD.mjs.map +1 -0
- package/dist/chunk-4JQ7UOXH.js +427 -0
- package/dist/chunk-4JQ7UOXH.js.map +1 -0
- package/dist/chunk-6IUKES2L.js +290 -0
- package/dist/chunk-6IUKES2L.js.map +1 -0
- package/dist/chunk-COWPK7XN.mjs +834 -0
- package/dist/chunk-COWPK7XN.mjs.map +1 -0
- package/dist/chunk-CTEXPMVZ.js +512 -0
- package/dist/chunk-CTEXPMVZ.js.map +1 -0
- package/dist/chunk-DXQTHA75.js +573 -0
- package/dist/chunk-DXQTHA75.js.map +1 -0
- package/dist/chunk-DZFQ6I23.js +72 -0
- package/dist/chunk-DZFQ6I23.js.map +1 -0
- package/dist/chunk-J323UTPE.mjs +650 -0
- package/dist/chunk-J323UTPE.mjs.map +1 -0
- package/dist/chunk-LHNNALVF.js +834 -0
- package/dist/chunk-LHNNALVF.js.map +1 -0
- package/dist/chunk-O7SZSMXV.js +1621 -0
- package/dist/chunk-O7SZSMXV.js.map +1 -0
- package/dist/chunk-OTNOFOVW.js +650 -0
- package/dist/chunk-OTNOFOVW.js.map +1 -0
- package/dist/chunk-PRIGZEI4.mjs +72 -0
- package/dist/chunk-PRIGZEI4.mjs.map +1 -0
- package/dist/chunk-SBSZ3IPB.mjs +573 -0
- package/dist/chunk-SBSZ3IPB.mjs.map +1 -0
- package/dist/chunk-SXPA6SSD.mjs +1621 -0
- package/dist/chunk-SXPA6SSD.mjs.map +1 -0
- package/dist/chunk-T5A4KAVS.mjs +512 -0
- package/dist/chunk-T5A4KAVS.mjs.map +1 -0
- package/dist/chunk-TDRKKUNT.mjs +357 -0
- package/dist/chunk-TDRKKUNT.mjs.map +1 -0
- package/dist/chunk-TJFNODPE.js +357 -0
- package/dist/chunk-TJFNODPE.js.map +1 -0
- package/dist/chunk-V2SSI3SL.mjs +427 -0
- package/dist/chunk-V2SSI3SL.mjs.map +1 -0
- package/dist/chunk-X42L6MTY.mjs +290 -0
- package/dist/chunk-X42L6MTY.mjs.map +1 -0
- package/dist/chunk-YSVMY77H.js +611 -0
- package/dist/chunk-YSVMY77H.js.map +1 -0
- package/dist/core-ANYRS6EF.mjs +73 -0
- package/dist/core-ANYRS6EF.mjs.map +1 -0
- package/dist/core-K5K34DCS.js +73 -0
- package/dist/core-K5K34DCS.js.map +1 -0
- package/dist/core-index.d.mts +1668 -0
- package/dist/core-index.d.ts +1668 -0
- package/dist/core-index.js +101 -0
- package/dist/core-index.js.map +1 -0
- package/dist/core-index.mjs +101 -0
- package/dist/core-index.mjs.map +1 -0
- package/dist/index.d.mts +2911 -0
- package/dist/index.d.ts +2911 -0
- package/dist/index.js +1177 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1177 -0
- package/dist/index.mjs.map +1 -0
- package/dist/tools-352X7A6X.mjs +366 -0
- package/dist/tools-352X7A6X.mjs.map +1 -0
- package/dist/tools-YLEX6GNO.js +366 -0
- package/dist/tools-YLEX6GNO.js.map +1 -0
- package/dist/ui-index.d.mts +627 -0
- package/dist/ui-index.d.ts +627 -0
- package/dist/ui-index.js +2354 -0
- package/dist/ui-index.js.map +1 -0
- package/dist/ui-index.mjs +2353 -0
- package/dist/ui-index.mjs.map +1 -0
- package/package.json +105 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,2911 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import { ToolSet, LanguageModel, CoreMessage, FinishReason, LanguageModelUsage, GenerateTextResult, LanguageModelRequestMetadata, LanguageModelResponseMetadata, TextStreamPart, StreamTextResult, GenerateObjectResult, StreamObjectResult, Tool, dynamicTool, NoSuchToolError, InvalidToolInputError, TypedToolCall, TypedToolResult, EmbeddingModel, ImageModel, Provider, UIMessage, DataUIPart, FileUIPart } from 'ai';
|
|
4
|
+
export { CoreMessage, DataUIPart, EmbeddingModel, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextResult, ImageModel, InvalidToolInputError, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, NoSuchToolError, Provider, StreamObjectResult, StreamTextResult, TextStreamPart, TextUIPart, Tool, ToolResultPart, ToolSet, TypedToolCall, TypedToolResult, UIMessage, UIMessagePart, cosineSimilarity, createProviderRegistry, customProvider, defaultSettingsMiddleware, embed, embedMany, generateObject, generateText, smoothStream, streamObject, streamText, tool, wrapLanguageModel } from 'ai';
|
|
5
|
+
import { IEntityModule, IEntityModel, IEntityView, IEntityServlet, EntityView, IEntityNamedRenderer, EntityWidget, ImportEntityData } from '@scenemesh/entity-engine';
|
|
6
|
+
export { UseChatOptions as ChatOptions, UseChatHelpers as ChatReturn, UseCompletionOptions as CompletionOptions, UseCompletionHelpers as CompletionReturn, Experimental_UseObjectOptions as ObjectOptions, Experimental_UseObjectHelpers as ObjectReturn } from '@ai-sdk/react';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Complete AI Integration
|
|
10
|
+
*
|
|
11
|
+
* Core AI functionality implementation:
|
|
12
|
+
* - generateText: Text generation
|
|
13
|
+
* - streamText: Streaming text generation
|
|
14
|
+
* - generateObject: Structured object generation
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Complete generateText options interface
|
|
19
|
+
*/
|
|
20
|
+
interface GenerateTextOptions<TOOLS extends ToolSet = {}> {
|
|
21
|
+
model: LanguageModel;
|
|
22
|
+
system?: string;
|
|
23
|
+
prompt?: string | Array<any>;
|
|
24
|
+
messages?: CoreMessage[];
|
|
25
|
+
tools?: TOOLS;
|
|
26
|
+
toolChoice?: 'auto' | 'none' | 'required' | {
|
|
27
|
+
type: 'tool';
|
|
28
|
+
toolName: string;
|
|
29
|
+
};
|
|
30
|
+
activeTools?: Array<keyof TOOLS>;
|
|
31
|
+
maxOutputTokens?: number;
|
|
32
|
+
temperature?: number;
|
|
33
|
+
topP?: number;
|
|
34
|
+
topK?: number;
|
|
35
|
+
presencePenalty?: number;
|
|
36
|
+
frequencyPenalty?: number;
|
|
37
|
+
stopSequences?: string[];
|
|
38
|
+
seed?: number;
|
|
39
|
+
maxRetries?: number;
|
|
40
|
+
stopWhen?: any;
|
|
41
|
+
prepareStep?: (options: {
|
|
42
|
+
steps: Array<any>;
|
|
43
|
+
stepNumber: number;
|
|
44
|
+
model: LanguageModel;
|
|
45
|
+
messages: Array<any>;
|
|
46
|
+
}) => any | Promise<any>;
|
|
47
|
+
abortSignal?: AbortSignal;
|
|
48
|
+
headers?: Record<string, string>;
|
|
49
|
+
experimental_telemetry?: {
|
|
50
|
+
isEnabled?: boolean;
|
|
51
|
+
recordInputs?: boolean;
|
|
52
|
+
recordOutputs?: boolean;
|
|
53
|
+
functionId?: string;
|
|
54
|
+
metadata?: Record<string, string | number | boolean | Array<null | undefined | string> | Array<null | undefined | number> | Array<null | undefined | boolean>>;
|
|
55
|
+
};
|
|
56
|
+
experimental_context?: unknown;
|
|
57
|
+
experimental_download?: (requestedDownloads: Array<{
|
|
58
|
+
url: URL;
|
|
59
|
+
isUrlSupportedByModel: boolean;
|
|
60
|
+
}>) => Promise<Array<null | {
|
|
61
|
+
data: Uint8Array;
|
|
62
|
+
mediaType?: string;
|
|
63
|
+
}>>;
|
|
64
|
+
experimental_repairToolCall?: (options: {
|
|
65
|
+
system?: string;
|
|
66
|
+
messages: Array<any>;
|
|
67
|
+
toolCall: any;
|
|
68
|
+
tools: TOOLS;
|
|
69
|
+
parameterSchema: (options: {
|
|
70
|
+
toolName: string;
|
|
71
|
+
}) => any;
|
|
72
|
+
error: any;
|
|
73
|
+
}) => Promise<any | null>;
|
|
74
|
+
experimental_output?: {
|
|
75
|
+
format: 'text' | 'object';
|
|
76
|
+
schema?: any;
|
|
77
|
+
};
|
|
78
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
79
|
+
onStepFinish?: (result: {
|
|
80
|
+
finishReason: FinishReason;
|
|
81
|
+
usage: LanguageModelUsage;
|
|
82
|
+
text: string;
|
|
83
|
+
toolCalls: Array<any>;
|
|
84
|
+
toolResults: Array<any>;
|
|
85
|
+
warnings?: Array<any>;
|
|
86
|
+
response?: {
|
|
87
|
+
id: string;
|
|
88
|
+
model: string;
|
|
89
|
+
timestamp: Date;
|
|
90
|
+
headers?: Record<string, string>;
|
|
91
|
+
body?: unknown;
|
|
92
|
+
};
|
|
93
|
+
isContinued: boolean;
|
|
94
|
+
providerMetadata?: Record<string, Record<string, any>>;
|
|
95
|
+
}) => Promise<void> | void;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Complete streamText options interface
|
|
99
|
+
*/
|
|
100
|
+
interface StreamTextOptions<TOOLS extends ToolSet = {}> extends Omit<GenerateTextOptions<TOOLS>, 'onStepFinish'> {
|
|
101
|
+
experimental_generateMessageId?: () => string;
|
|
102
|
+
experimental_transform?: any | any[];
|
|
103
|
+
includeRawChunks?: boolean;
|
|
104
|
+
onChunk?: (event: {
|
|
105
|
+
chunk: TextStreamPart<TOOLS>;
|
|
106
|
+
}) => Promise<void> | void;
|
|
107
|
+
onError?: (event: {
|
|
108
|
+
error: unknown;
|
|
109
|
+
}) => Promise<void> | void;
|
|
110
|
+
onStepFinish?: (result: {
|
|
111
|
+
stepType: 'initial' | 'continue' | 'tool-result';
|
|
112
|
+
finishReason: FinishReason;
|
|
113
|
+
usage: LanguageModelUsage;
|
|
114
|
+
text: string;
|
|
115
|
+
reasoning?: string;
|
|
116
|
+
sources: Array<{
|
|
117
|
+
sourceType: 'url';
|
|
118
|
+
id: string;
|
|
119
|
+
url: string;
|
|
120
|
+
title?: string;
|
|
121
|
+
providerMetadata?: any;
|
|
122
|
+
}>;
|
|
123
|
+
files: Array<{
|
|
124
|
+
base64: string;
|
|
125
|
+
uint8Array: Uint8Array;
|
|
126
|
+
mediaType: string;
|
|
127
|
+
}>;
|
|
128
|
+
toolCalls: Array<any>;
|
|
129
|
+
toolResults: Array<any>;
|
|
130
|
+
warnings?: Array<any>;
|
|
131
|
+
response?: {
|
|
132
|
+
id: string;
|
|
133
|
+
model: string;
|
|
134
|
+
timestamp: Date;
|
|
135
|
+
headers?: Record<string, string>;
|
|
136
|
+
messages: Array<any>;
|
|
137
|
+
};
|
|
138
|
+
isContinued: boolean;
|
|
139
|
+
providerMetadata?: Record<string, Record<string, any>>;
|
|
140
|
+
}) => Promise<void> | void;
|
|
141
|
+
onFinish?: (result: {
|
|
142
|
+
finishReason: FinishReason;
|
|
143
|
+
usage: LanguageModelUsage;
|
|
144
|
+
totalUsage: LanguageModelUsage;
|
|
145
|
+
providerMetadata?: Record<string, Record<string, any>>;
|
|
146
|
+
text: string;
|
|
147
|
+
reasoning?: string;
|
|
148
|
+
reasoningDetails: Array<{
|
|
149
|
+
type: 'text' | 'redacted';
|
|
150
|
+
text?: string;
|
|
151
|
+
signature?: string;
|
|
152
|
+
data?: string;
|
|
153
|
+
}>;
|
|
154
|
+
sources: Array<{
|
|
155
|
+
sourceType: 'url';
|
|
156
|
+
id: string;
|
|
157
|
+
url: string;
|
|
158
|
+
title?: string;
|
|
159
|
+
providerMetadata?: any;
|
|
160
|
+
}>;
|
|
161
|
+
files: Array<{
|
|
162
|
+
base64: string;
|
|
163
|
+
uint8Array: Uint8Array;
|
|
164
|
+
mediaType: string;
|
|
165
|
+
}>;
|
|
166
|
+
toolCalls: Array<any>;
|
|
167
|
+
toolResults: Array<any>;
|
|
168
|
+
warnings?: Array<any>;
|
|
169
|
+
response?: {
|
|
170
|
+
id: string;
|
|
171
|
+
model: string;
|
|
172
|
+
timestamp: Date;
|
|
173
|
+
headers?: Record<string, string>;
|
|
174
|
+
messages: Array<any>;
|
|
175
|
+
};
|
|
176
|
+
steps: Array<any>;
|
|
177
|
+
}) => Promise<void> | void;
|
|
178
|
+
onAbort?: (event: {
|
|
179
|
+
steps: Array<any>;
|
|
180
|
+
}) => Promise<void> | void;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Result types
|
|
184
|
+
*/
|
|
185
|
+
type GenerateResult<TOOLS extends ToolSet = {}> = GenerateTextResult<TOOLS, any> & {
|
|
186
|
+
content: Array<any>;
|
|
187
|
+
text: string;
|
|
188
|
+
reasoning: Array<any>;
|
|
189
|
+
reasoningText: string | undefined;
|
|
190
|
+
sources: Array<any>;
|
|
191
|
+
files: Array<any>;
|
|
192
|
+
toolCalls: Array<any>;
|
|
193
|
+
toolResults: Array<any>;
|
|
194
|
+
finishReason: 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other' | 'unknown';
|
|
195
|
+
usage: LanguageModelUsage;
|
|
196
|
+
totalUsage: LanguageModelUsage;
|
|
197
|
+
request?: LanguageModelRequestMetadata;
|
|
198
|
+
response?: LanguageModelResponseMetadata;
|
|
199
|
+
warnings?: Array<any>;
|
|
200
|
+
providerMetadata?: any;
|
|
201
|
+
experimental_output?: any;
|
|
202
|
+
steps: Array<any>;
|
|
203
|
+
};
|
|
204
|
+
type StreamResult<TOOLS extends ToolSet = {}> = StreamTextResult<TOOLS, any> & {
|
|
205
|
+
content: Promise<Array<any>>;
|
|
206
|
+
finishReason: Promise<'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other' | 'unknown'>;
|
|
207
|
+
usage: Promise<LanguageModelUsage>;
|
|
208
|
+
totalUsage: Promise<LanguageModelUsage>;
|
|
209
|
+
providerMetadata: Promise<any>;
|
|
210
|
+
text: Promise<string>;
|
|
211
|
+
reasoning: Promise<Array<any>>;
|
|
212
|
+
reasoningText: Promise<string | undefined>;
|
|
213
|
+
sources: Promise<Array<any>>;
|
|
214
|
+
files: Promise<Array<any>>;
|
|
215
|
+
toolCalls: Promise<Array<any>>;
|
|
216
|
+
toolResults: Promise<Array<any>>;
|
|
217
|
+
request: Promise<LanguageModelRequestMetadata>;
|
|
218
|
+
response: Promise<LanguageModelResponseMetadata & {
|
|
219
|
+
messages: Array<any>;
|
|
220
|
+
}>;
|
|
221
|
+
warnings: Promise<Array<any> | undefined>;
|
|
222
|
+
steps: Promise<Array<any>>;
|
|
223
|
+
textStream: AsyncIterable<string> & ReadableStream<string>;
|
|
224
|
+
fullStream: AsyncIterable<any> & ReadableStream<any>;
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* Complete AI integration class
|
|
228
|
+
*/
|
|
229
|
+
declare class AISDKIntegration extends EventEmitter {
|
|
230
|
+
private initialized;
|
|
231
|
+
private requestCounter;
|
|
232
|
+
constructor();
|
|
233
|
+
/**
|
|
234
|
+
* Initialize the AI integration
|
|
235
|
+
*/
|
|
236
|
+
initialize(): Promise<void>;
|
|
237
|
+
/**
|
|
238
|
+
* Generate request ID
|
|
239
|
+
*/
|
|
240
|
+
private generateRequestId;
|
|
241
|
+
/**
|
|
242
|
+
* Text generation
|
|
243
|
+
*/
|
|
244
|
+
generateText<TOOLS extends ToolSet = {}>(options: GenerateTextOptions<TOOLS>): Promise<GenerateResult<TOOLS>>;
|
|
245
|
+
/**
|
|
246
|
+
* Streaming text generation
|
|
247
|
+
*/
|
|
248
|
+
streamText<TOOLS extends ToolSet = {}>(options: StreamTextOptions<TOOLS>): StreamTextResult<TOOLS, any>;
|
|
249
|
+
/**
|
|
250
|
+
* Generate structured object
|
|
251
|
+
*/
|
|
252
|
+
generateObject<SCHEMA>(options: {
|
|
253
|
+
model: LanguageModel;
|
|
254
|
+
output?: 'object' | 'array' | 'enum' | 'no-schema';
|
|
255
|
+
mode?: 'auto' | 'json' | 'tool';
|
|
256
|
+
schema?: SCHEMA;
|
|
257
|
+
schemaName?: string;
|
|
258
|
+
schemaDescription?: string;
|
|
259
|
+
enum?: string[];
|
|
260
|
+
system?: string;
|
|
261
|
+
prompt?: string;
|
|
262
|
+
messages?: CoreMessage[];
|
|
263
|
+
maxOutputTokens?: number;
|
|
264
|
+
temperature?: number;
|
|
265
|
+
topP?: number;
|
|
266
|
+
topK?: number;
|
|
267
|
+
presencePenalty?: number;
|
|
268
|
+
frequencyPenalty?: number;
|
|
269
|
+
seed?: number;
|
|
270
|
+
maxRetries?: number;
|
|
271
|
+
abortSignal?: AbortSignal;
|
|
272
|
+
headers?: Record<string, string>;
|
|
273
|
+
experimental_repairText?: (options: {
|
|
274
|
+
text: string;
|
|
275
|
+
error: any;
|
|
276
|
+
}) => Promise<string>;
|
|
277
|
+
experimental_download?: (requestedDownloads: Array<{
|
|
278
|
+
url: URL;
|
|
279
|
+
isUrlSupportedByModel: boolean;
|
|
280
|
+
}>) => Promise<Array<null | {
|
|
281
|
+
data: Uint8Array;
|
|
282
|
+
mediaType?: string;
|
|
283
|
+
}>>;
|
|
284
|
+
experimental_telemetry?: {
|
|
285
|
+
isEnabled?: boolean;
|
|
286
|
+
recordInputs?: boolean;
|
|
287
|
+
recordOutputs?: boolean;
|
|
288
|
+
functionId?: string;
|
|
289
|
+
metadata?: Record<string, any>;
|
|
290
|
+
};
|
|
291
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
292
|
+
}): Promise<GenerateObjectResult<SCHEMA>>;
|
|
293
|
+
/**
|
|
294
|
+
* Streaming structured object generation
|
|
295
|
+
*/
|
|
296
|
+
streamObject<SCHEMA>(options: {
|
|
297
|
+
model: LanguageModel;
|
|
298
|
+
output?: 'object' | 'array' | 'enum' | 'no-schema';
|
|
299
|
+
mode?: 'auto' | 'json' | 'tool';
|
|
300
|
+
schema?: SCHEMA;
|
|
301
|
+
schemaName?: string;
|
|
302
|
+
schemaDescription?: string;
|
|
303
|
+
enum?: string[];
|
|
304
|
+
system?: string;
|
|
305
|
+
prompt?: string;
|
|
306
|
+
messages?: CoreMessage[];
|
|
307
|
+
maxOutputTokens?: number;
|
|
308
|
+
temperature?: number;
|
|
309
|
+
topP?: number;
|
|
310
|
+
topK?: number;
|
|
311
|
+
presencePenalty?: number;
|
|
312
|
+
frequencyPenalty?: number;
|
|
313
|
+
seed?: number;
|
|
314
|
+
maxRetries?: number;
|
|
315
|
+
abortSignal?: AbortSignal;
|
|
316
|
+
headers?: Record<string, string>;
|
|
317
|
+
experimental_repairText?: (options: {
|
|
318
|
+
text: string;
|
|
319
|
+
error: any;
|
|
320
|
+
}) => Promise<string>;
|
|
321
|
+
experimental_download?: (requestedDownloads: Array<{
|
|
322
|
+
url: URL;
|
|
323
|
+
isUrlSupportedByModel: boolean;
|
|
324
|
+
}>) => Promise<Array<null | {
|
|
325
|
+
data: Uint8Array;
|
|
326
|
+
mediaType?: string;
|
|
327
|
+
}>>;
|
|
328
|
+
experimental_telemetry?: {
|
|
329
|
+
isEnabled?: boolean;
|
|
330
|
+
recordInputs?: boolean;
|
|
331
|
+
recordOutputs?: boolean;
|
|
332
|
+
functionId?: string;
|
|
333
|
+
metadata?: Record<string, any>;
|
|
334
|
+
};
|
|
335
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
336
|
+
onError?: (event: {
|
|
337
|
+
error: unknown;
|
|
338
|
+
}) => Promise<void> | void;
|
|
339
|
+
onFinish?: (result: {
|
|
340
|
+
usage: LanguageModelUsage;
|
|
341
|
+
providerMetadata?: Record<string, Record<string, any>>;
|
|
342
|
+
object?: SCHEMA;
|
|
343
|
+
error?: unknown;
|
|
344
|
+
warnings?: Array<any>;
|
|
345
|
+
response?: {
|
|
346
|
+
id: string;
|
|
347
|
+
model: string;
|
|
348
|
+
timestamp: Date;
|
|
349
|
+
headers?: Record<string, string>;
|
|
350
|
+
};
|
|
351
|
+
}) => void;
|
|
352
|
+
}): StreamObjectResult<any, any, any>;
|
|
353
|
+
/**
|
|
354
|
+
* Create tool
|
|
355
|
+
*/
|
|
356
|
+
createTool<TParameters, TResult>(description: string, inputSchema: z.ZodSchema<TParameters>, execute?: (parameters: TParameters) => Promise<TResult> | TResult): Tool<TParameters, TResult>;
|
|
357
|
+
/**
|
|
358
|
+
* Create smooth stream
|
|
359
|
+
*/
|
|
360
|
+
createSmoothStream(): (options: {
|
|
361
|
+
tools: ToolSet;
|
|
362
|
+
}) => TransformStream<TextStreamPart<ToolSet>, TextStreamPart<ToolSet>>;
|
|
363
|
+
/**
|
|
364
|
+
* Check initialization status
|
|
365
|
+
*/
|
|
366
|
+
isInitialized(): boolean;
|
|
367
|
+
/**
|
|
368
|
+
* Get statistics
|
|
369
|
+
*/
|
|
370
|
+
getStats(): {
|
|
371
|
+
requestCount: number;
|
|
372
|
+
isInitialized: boolean;
|
|
373
|
+
};
|
|
374
|
+
/**
|
|
375
|
+
* Reset statistics
|
|
376
|
+
*/
|
|
377
|
+
resetStats(): void;
|
|
378
|
+
/**
|
|
379
|
+
* Destroy instance
|
|
380
|
+
*/
|
|
381
|
+
destroy(): void;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* AI Tool Calling Complete Integration
|
|
386
|
+
*
|
|
387
|
+
* Complete tool calling functionality:
|
|
388
|
+
* - Basic tool calling and execution
|
|
389
|
+
* - Multi-step calling system (stopWhen, stepCountIs)
|
|
390
|
+
* - Dynamic tools (dynamicTool)
|
|
391
|
+
* - Tool selection strategies (toolChoice)
|
|
392
|
+
* - Error handling and tool repair
|
|
393
|
+
* - MCP tool integration
|
|
394
|
+
* - Complete type safety system
|
|
395
|
+
*/
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Complete tool choice strategy definition
|
|
399
|
+
*/
|
|
400
|
+
type ToolChoice<TOOLS extends ToolSet = {}> = 'auto' | 'required' | 'none' | {
|
|
401
|
+
type: 'tool';
|
|
402
|
+
toolName: Extract<keyof TOOLS, string>;
|
|
403
|
+
};
|
|
404
|
+
/**
|
|
405
|
+
* 停止条件类型 - 支持各种停止策略
|
|
406
|
+
*/
|
|
407
|
+
type StopCondition<_TOOLS extends ToolSet = {}> = ((options: {
|
|
408
|
+
stepNumber: number;
|
|
409
|
+
steps: Array<any>;
|
|
410
|
+
}) => boolean) | {
|
|
411
|
+
type: 'stepCount';
|
|
412
|
+
value: number;
|
|
413
|
+
} | {
|
|
414
|
+
type: 'custom';
|
|
415
|
+
condition: (context: any) => boolean;
|
|
416
|
+
};
|
|
417
|
+
/**
|
|
418
|
+
* 工具执行选项 - 完整参数
|
|
419
|
+
*/
|
|
420
|
+
interface ToolExecutionOptions {
|
|
421
|
+
toolCallId: string;
|
|
422
|
+
messages: CoreMessage[];
|
|
423
|
+
abortSignal?: AbortSignal;
|
|
424
|
+
experimental_context?: unknown;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* 工具定义接口 - 支持所有官方功能
|
|
428
|
+
*/
|
|
429
|
+
interface AdvancedTool<TParameters = any, TResult = any> {
|
|
430
|
+
description?: string;
|
|
431
|
+
inputSchema: z.ZodSchema<TParameters>;
|
|
432
|
+
execute?: (parameters: TParameters, options: ToolExecutionOptions) => Promise<TResult> | TResult | AsyncIterable<TResult>;
|
|
433
|
+
toModelOutput?: (result: TResult) => {
|
|
434
|
+
type: 'content';
|
|
435
|
+
value: Array<{
|
|
436
|
+
type: 'text' | 'image';
|
|
437
|
+
text?: string;
|
|
438
|
+
data?: string;
|
|
439
|
+
mediaType?: string;
|
|
440
|
+
}>;
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* 动态工具接口 - 完全匹配 AI SDK 的 dynamicTool 返回类型
|
|
445
|
+
*/
|
|
446
|
+
type DynamicTool = ReturnType<typeof dynamicTool>;
|
|
447
|
+
/**
|
|
448
|
+
* 步骤结果类型 - 完整步骤信息
|
|
449
|
+
*/
|
|
450
|
+
interface StepResult<TOOLS extends ToolSet = {}> {
|
|
451
|
+
stepType: 'initial' | 'continue' | 'tool-result';
|
|
452
|
+
stepNumber: number;
|
|
453
|
+
text: string;
|
|
454
|
+
reasoning?: string;
|
|
455
|
+
toolCalls: Array<TypedToolCall<TOOLS>>;
|
|
456
|
+
toolResults: Array<TypedToolResult<TOOLS>>;
|
|
457
|
+
finishReason: FinishReason;
|
|
458
|
+
usage: LanguageModelUsage;
|
|
459
|
+
warnings?: Array<any>;
|
|
460
|
+
response?: LanguageModelResponseMetadata;
|
|
461
|
+
isContinued: boolean;
|
|
462
|
+
providerMetadata?: Record<string, Record<string, any>>;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* 工具调用选项 - 完整参数集合
|
|
466
|
+
*/
|
|
467
|
+
interface ToolCallOptions<TOOLS extends ToolSet = {}> {
|
|
468
|
+
model: LanguageModel;
|
|
469
|
+
system?: string;
|
|
470
|
+
prompt?: string;
|
|
471
|
+
messages?: CoreMessage[];
|
|
472
|
+
tools: TOOLS;
|
|
473
|
+
toolChoice?: ToolChoice<TOOLS>;
|
|
474
|
+
activeTools?: Array<keyof TOOLS>;
|
|
475
|
+
stopWhen?: StopCondition<TOOLS> | Array<StopCondition<TOOLS>>;
|
|
476
|
+
maxSteps?: number;
|
|
477
|
+
maxOutputTokens?: number;
|
|
478
|
+
temperature?: number;
|
|
479
|
+
topP?: number;
|
|
480
|
+
topK?: number;
|
|
481
|
+
presencePenalty?: number;
|
|
482
|
+
frequencyPenalty?: number;
|
|
483
|
+
seed?: number;
|
|
484
|
+
maxRetries?: number;
|
|
485
|
+
abortSignal?: AbortSignal;
|
|
486
|
+
headers?: Record<string, string>;
|
|
487
|
+
experimental_context?: unknown;
|
|
488
|
+
experimental_telemetry?: {
|
|
489
|
+
isEnabled?: boolean;
|
|
490
|
+
recordInputs?: boolean;
|
|
491
|
+
recordOutputs?: boolean;
|
|
492
|
+
functionId?: string;
|
|
493
|
+
metadata?: Record<string, any>;
|
|
494
|
+
};
|
|
495
|
+
experimental_repairToolCall?: (options: {
|
|
496
|
+
toolCall: any;
|
|
497
|
+
tools: TOOLS;
|
|
498
|
+
error: NoSuchToolError | InvalidToolInputError;
|
|
499
|
+
messages: CoreMessage[];
|
|
500
|
+
system?: string;
|
|
501
|
+
inputSchema: (options: {
|
|
502
|
+
toolName: string;
|
|
503
|
+
}) => any;
|
|
504
|
+
}) => Promise<any | null>;
|
|
505
|
+
onStepFinish?: (result: StepResult<TOOLS>) => Promise<void> | void;
|
|
506
|
+
prepareStep?: (options: {
|
|
507
|
+
stepNumber: number;
|
|
508
|
+
steps: Array<StepResult<TOOLS>>;
|
|
509
|
+
model: LanguageModel;
|
|
510
|
+
messages: CoreMessage[];
|
|
511
|
+
}) => Promise<{
|
|
512
|
+
model?: LanguageModel;
|
|
513
|
+
toolChoice?: ToolChoice<TOOLS>;
|
|
514
|
+
activeTools?: Array<keyof TOOLS>;
|
|
515
|
+
system?: string;
|
|
516
|
+
messages?: CoreMessage[];
|
|
517
|
+
} | void> | {
|
|
518
|
+
model?: LanguageModel;
|
|
519
|
+
toolChoice?: ToolChoice<TOOLS>;
|
|
520
|
+
activeTools?: Array<keyof TOOLS>;
|
|
521
|
+
system?: string;
|
|
522
|
+
messages?: CoreMessage[];
|
|
523
|
+
} | void;
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* MCP客户端配置
|
|
527
|
+
*/
|
|
528
|
+
interface MCPClientConfig {
|
|
529
|
+
transport: {
|
|
530
|
+
type: 'sse';
|
|
531
|
+
url: string;
|
|
532
|
+
headers?: Record<string, string>;
|
|
533
|
+
} | {
|
|
534
|
+
type: 'stdio';
|
|
535
|
+
command: string;
|
|
536
|
+
args?: string[];
|
|
537
|
+
} | {
|
|
538
|
+
type: 'custom';
|
|
539
|
+
transport: any;
|
|
540
|
+
};
|
|
541
|
+
schemas?: Record<string, {
|
|
542
|
+
inputSchema: z.ZodSchema<any>;
|
|
543
|
+
}>;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* MCP客户端接口
|
|
547
|
+
*/
|
|
548
|
+
interface MCPClient {
|
|
549
|
+
tools(config?: {
|
|
550
|
+
schemas?: Record<string, {
|
|
551
|
+
inputSchema: z.ZodSchema<any>;
|
|
552
|
+
}>;
|
|
553
|
+
}): Promise<ToolSet>;
|
|
554
|
+
close(): Promise<void>;
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Complete tools integration class
|
|
558
|
+
*/
|
|
559
|
+
declare class AIToolsIntegration extends EventEmitter {
|
|
560
|
+
private initialized;
|
|
561
|
+
private requestCounter;
|
|
562
|
+
private registeredTools;
|
|
563
|
+
private dynamicTools;
|
|
564
|
+
private mcpClients;
|
|
565
|
+
constructor();
|
|
566
|
+
/**
|
|
567
|
+
* 初始化
|
|
568
|
+
*/
|
|
569
|
+
initialize(): Promise<void>;
|
|
570
|
+
/**
|
|
571
|
+
* 生成请求ID
|
|
572
|
+
*/
|
|
573
|
+
private generateRequestId;
|
|
574
|
+
/**
|
|
575
|
+
* Create tool - following official specifications
|
|
576
|
+
*/
|
|
577
|
+
createTool(description: string, inputSchema: z.ZodSchema<any>, execute?: (parameters: any, options?: any) => Promise<any> | any): any;
|
|
578
|
+
/**
|
|
579
|
+
* 创建动态工具 - 完全基于 AI SDK 的 dynamicTool
|
|
580
|
+
*/
|
|
581
|
+
createDynamicTool(description: string, inputSchema: z.ZodSchema<any>, execute?: (input: unknown, options: ToolExecutionOptions) => Promise<unknown>): DynamicTool;
|
|
582
|
+
/**
|
|
583
|
+
* 注册工具到集成器
|
|
584
|
+
*/
|
|
585
|
+
registerTool<TParameters, TResult>(name: string, toolInstance: AdvancedTool<TParameters, TResult>): void;
|
|
586
|
+
/**
|
|
587
|
+
* 获取已注册的工具
|
|
588
|
+
*/
|
|
589
|
+
getRegisteredTools(): Record<string, AdvancedTool>;
|
|
590
|
+
/**
|
|
591
|
+
* 注册动态工具
|
|
592
|
+
*/
|
|
593
|
+
registerDynamicTool(name: string, dynamicToolInstance: DynamicTool): void;
|
|
594
|
+
/**
|
|
595
|
+
* 使用工具执行文本生成 - 遵循官方 generateText + tools 模式
|
|
596
|
+
* 这是 AI SDK 工具调用的标准方式
|
|
597
|
+
*/
|
|
598
|
+
generateTextWithTools<TOOLS extends ToolSet = {}>(options: ToolCallOptions<TOOLS>): Promise<{
|
|
599
|
+
text: string;
|
|
600
|
+
steps: Array<StepResult<TOOLS>>;
|
|
601
|
+
toolCalls: Array<TypedToolCall<TOOLS>>;
|
|
602
|
+
toolResults: Array<TypedToolResult<TOOLS>>;
|
|
603
|
+
finishReason: FinishReason;
|
|
604
|
+
usage: LanguageModelUsage;
|
|
605
|
+
totalUsage: LanguageModelUsage;
|
|
606
|
+
content: Array<any>;
|
|
607
|
+
reasoning?: Array<any>;
|
|
608
|
+
reasoningText?: string;
|
|
609
|
+
sources?: Array<any>;
|
|
610
|
+
files?: Array<any>;
|
|
611
|
+
warnings?: Array<any>;
|
|
612
|
+
response?: any;
|
|
613
|
+
providerMetadata?: any;
|
|
614
|
+
}>;
|
|
615
|
+
/**
|
|
616
|
+
* 使用工具执行流式文本生成 - 遵循官方 streamText + tools 模式
|
|
617
|
+
*/
|
|
618
|
+
streamTextWithTools<TOOLS extends ToolSet = {}>(options: ToolCallOptions<TOOLS>): Promise<StreamTextResult<TOOLS, any>>;
|
|
619
|
+
/**
|
|
620
|
+
* 创建步骤计数停止条件
|
|
621
|
+
*/
|
|
622
|
+
createStepCountCondition(maxSteps: number): StopCondition<any>;
|
|
623
|
+
/**
|
|
624
|
+
* 创建自定义停止条件
|
|
625
|
+
*/
|
|
626
|
+
createCustomStopCondition<TOOLS extends ToolSet = {}>(condition: (options: {
|
|
627
|
+
stepNumber: number;
|
|
628
|
+
steps: Array<StepResult<TOOLS>>;
|
|
629
|
+
}) => boolean): StopCondition<TOOLS>;
|
|
630
|
+
/**
|
|
631
|
+
* 解析停止条件
|
|
632
|
+
*/
|
|
633
|
+
private parseStopCondition;
|
|
634
|
+
/**
|
|
635
|
+
* 创建结构化输出修复器
|
|
636
|
+
*/
|
|
637
|
+
createStructuredRepairFunction<TOOLS extends ToolSet = {}>(repairModel: LanguageModel): (options: {
|
|
638
|
+
toolCall: any;
|
|
639
|
+
tools: TOOLS;
|
|
640
|
+
error: NoSuchToolError | InvalidToolInputError;
|
|
641
|
+
inputSchema: (options: {
|
|
642
|
+
toolName: string;
|
|
643
|
+
}) => any;
|
|
644
|
+
}) => Promise<any>;
|
|
645
|
+
/**
|
|
646
|
+
* 创建重新询问修复器
|
|
647
|
+
*/
|
|
648
|
+
createReaskRepairFunction<TOOLS extends ToolSet = {}>(repairModel: LanguageModel): (options: {
|
|
649
|
+
toolCall: any;
|
|
650
|
+
tools: TOOLS;
|
|
651
|
+
error: NoSuchToolError | InvalidToolInputError;
|
|
652
|
+
messages: CoreMessage[];
|
|
653
|
+
system?: string;
|
|
654
|
+
}) => Promise<{
|
|
655
|
+
toolCallType: "function";
|
|
656
|
+
toolCallId: any;
|
|
657
|
+
toolName: any;
|
|
658
|
+
input: string;
|
|
659
|
+
} | null>;
|
|
660
|
+
/**
|
|
661
|
+
* 创建MCP客户端
|
|
662
|
+
*/
|
|
663
|
+
createMCPClient(config: MCPClientConfig): Promise<MCPClient>;
|
|
664
|
+
/**
|
|
665
|
+
* 关闭所有MCP客户端
|
|
666
|
+
*/
|
|
667
|
+
closeAllMCPClients(): Promise<void>;
|
|
668
|
+
/**
|
|
669
|
+
* Create simple tool call configuration
|
|
670
|
+
*/
|
|
671
|
+
createSimpleToolCall<TOOLS extends ToolSet = {}>(model: LanguageModel, tools: TOOLS, prompt: string, options?: Partial<ToolCallOptions<TOOLS>>): ToolCallOptions<TOOLS>;
|
|
672
|
+
/**
|
|
673
|
+
* 创建多步工具调用配置 - 使用 stopWhen 参数
|
|
674
|
+
*/
|
|
675
|
+
createMultiStepToolCall<TOOLS extends ToolSet = {}>(model: LanguageModel, tools: TOOLS, prompt: string, maxSteps?: number, options?: Partial<ToolCallOptions<TOOLS>>): ToolCallOptions<TOOLS>;
|
|
676
|
+
/**
|
|
677
|
+
* 直接执行单个工具 - 用于测试或直接调用
|
|
678
|
+
*/
|
|
679
|
+
executeSingleTool<TOOLS extends ToolSet = {}>(toolName: keyof TOOLS, input: any, tools: TOOLS, options?: {
|
|
680
|
+
messages?: CoreMessage[];
|
|
681
|
+
abortSignal?: AbortSignal;
|
|
682
|
+
experimental_context?: unknown;
|
|
683
|
+
}): Promise<any>;
|
|
684
|
+
/**
|
|
685
|
+
* 获取响应消息 - 官方文档重点推荐的功能
|
|
686
|
+
* 用于将助手和工具消息添加到对话历史
|
|
687
|
+
*/
|
|
688
|
+
extractResponseMessages(result: {
|
|
689
|
+
response?: {
|
|
690
|
+
messages: Array<any>;
|
|
691
|
+
};
|
|
692
|
+
}): Array<any>;
|
|
693
|
+
/**
|
|
694
|
+
* 将响应消息添加到对话历史 - 官方文档示例
|
|
695
|
+
*/
|
|
696
|
+
addResponseMessagesToHistory(messages: Array<any>, result: {
|
|
697
|
+
response?: {
|
|
698
|
+
messages: Array<any>;
|
|
699
|
+
};
|
|
700
|
+
}): Array<any>;
|
|
701
|
+
/**
|
|
702
|
+
* 批量工具调用验证
|
|
703
|
+
*/
|
|
704
|
+
validateBatchToolCalls<TOOLS extends ToolSet = {}>(toolCalls: Array<TypedToolCall<TOOLS>>, tools: TOOLS): Array<{
|
|
705
|
+
toolCall: TypedToolCall<TOOLS>;
|
|
706
|
+
valid: boolean;
|
|
707
|
+
error?: string;
|
|
708
|
+
}>;
|
|
709
|
+
/**
|
|
710
|
+
* 工具调用结果验证
|
|
711
|
+
*/
|
|
712
|
+
validateToolCall<TOOLS extends ToolSet = {}>(toolCall: TypedToolCall<TOOLS>, tools: TOOLS): {
|
|
713
|
+
valid: boolean;
|
|
714
|
+
error?: string;
|
|
715
|
+
};
|
|
716
|
+
/**
|
|
717
|
+
* 工具调用统计分析
|
|
718
|
+
*/
|
|
719
|
+
analyzeToolUsage<TOOLS extends ToolSet = {}>(steps: Array<StepResult<TOOLS>>): {
|
|
720
|
+
totalToolCalls: number;
|
|
721
|
+
totalToolResults: number;
|
|
722
|
+
toolUsageByName: Record<string, number>;
|
|
723
|
+
avgToolCallsPerStep: number;
|
|
724
|
+
stepTypes: Record<string, number>;
|
|
725
|
+
};
|
|
726
|
+
/**
|
|
727
|
+
* 提取步骤中的所有工具调用
|
|
728
|
+
*/
|
|
729
|
+
extractToolCallsFromSteps<TOOLS extends ToolSet = {}>(steps: Array<StepResult<TOOLS>>): Array<TypedToolCall<TOOLS>>;
|
|
730
|
+
/**
|
|
731
|
+
* 提取步骤中的所有工具结果
|
|
732
|
+
*/
|
|
733
|
+
extractToolResultsFromSteps<TOOLS extends ToolSet = {}>(steps: Array<StepResult<TOOLS>>): Array<TypedToolResult<TOOLS>>;
|
|
734
|
+
/**
|
|
735
|
+
* 检查初始化状态
|
|
736
|
+
*/
|
|
737
|
+
isInitialized(): boolean;
|
|
738
|
+
/**
|
|
739
|
+
* 获取统计信息
|
|
740
|
+
*/
|
|
741
|
+
getStats(): {
|
|
742
|
+
requestCount: number;
|
|
743
|
+
isInitialized: boolean;
|
|
744
|
+
registeredTools: number;
|
|
745
|
+
dynamicTools: number;
|
|
746
|
+
mcpClients: number;
|
|
747
|
+
};
|
|
748
|
+
/**
|
|
749
|
+
* 重置统计信息
|
|
750
|
+
*/
|
|
751
|
+
resetStats(): void;
|
|
752
|
+
/**
|
|
753
|
+
* 销毁实例
|
|
754
|
+
*/
|
|
755
|
+
destroy(): Promise<void>;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* AI Embeddings Complete Integration
|
|
760
|
+
*
|
|
761
|
+
* Complete embeddings functionality:
|
|
762
|
+
* - embed: Single value embedding
|
|
763
|
+
* - embedMany: Batch embedding
|
|
764
|
+
* - cosineSimilarity: Similarity calculation
|
|
765
|
+
* - All configuration parameters supported
|
|
766
|
+
* - Provider-specific configurations
|
|
767
|
+
*/
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* Complete embedding model configuration
|
|
771
|
+
*/
|
|
772
|
+
interface EmbeddingModelConfig {
|
|
773
|
+
model: EmbeddingModel;
|
|
774
|
+
providerOptions?: Record<string, any>;
|
|
775
|
+
maxRetries?: number;
|
|
776
|
+
abortSignal?: AbortSignal;
|
|
777
|
+
headers?: Record<string, string>;
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* 批量嵌入配置 - embedMany 专用参数
|
|
781
|
+
*/
|
|
782
|
+
interface EmbedManyConfig extends EmbeddingModelConfig {
|
|
783
|
+
maxParallelCalls?: number;
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* 单值嵌入选项 - embed() 完整参数
|
|
787
|
+
*/
|
|
788
|
+
interface EmbedOptions extends EmbeddingModelConfig {
|
|
789
|
+
value: string;
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* 批量嵌入选项 - embedMany() 完整参数
|
|
793
|
+
*/
|
|
794
|
+
interface EmbedManyOptions extends EmbedManyConfig {
|
|
795
|
+
values: string[];
|
|
796
|
+
}
|
|
797
|
+
/**
|
|
798
|
+
* 嵌入结果类型 - 官方规范
|
|
799
|
+
*/
|
|
800
|
+
interface EmbedResult {
|
|
801
|
+
embedding: number[];
|
|
802
|
+
usage: LanguageModelUsage;
|
|
803
|
+
request?: LanguageModelRequestMetadata;
|
|
804
|
+
response?: LanguageModelResponseMetadata;
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* 批量嵌入结果类型 - 官方规范
|
|
808
|
+
*/
|
|
809
|
+
interface EmbedManyResult {
|
|
810
|
+
embeddings: number[][];
|
|
811
|
+
usage: LanguageModelUsage;
|
|
812
|
+
request?: LanguageModelRequestMetadata;
|
|
813
|
+
response?: LanguageModelResponseMetadata;
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* 相似度计算结果
|
|
817
|
+
*/
|
|
818
|
+
interface SimilarityResult {
|
|
819
|
+
similarity: number;
|
|
820
|
+
vector1: number[];
|
|
821
|
+
vector2: number[];
|
|
822
|
+
method: 'cosine' | 'euclidean' | 'dot';
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* 嵌入提供商信息 - 基于官方文档表格
|
|
826
|
+
*/
|
|
827
|
+
interface EmbeddingProviderInfo {
|
|
828
|
+
provider: string;
|
|
829
|
+
model: string;
|
|
830
|
+
dimensions: number;
|
|
831
|
+
description?: string;
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* Supported embedding models
|
|
835
|
+
*/
|
|
836
|
+
declare const SupportedEmbeddingModels: Record<string, EmbeddingProviderInfo>;
|
|
837
|
+
/**
|
|
838
|
+
* Complete embeddings integration class
|
|
839
|
+
*/
|
|
840
|
+
declare class AIEmbeddingsIntegration extends EventEmitter {
|
|
841
|
+
private initialized;
|
|
842
|
+
private requestCounter;
|
|
843
|
+
private embeddingCache;
|
|
844
|
+
private usageStats;
|
|
845
|
+
constructor();
|
|
846
|
+
/**
|
|
847
|
+
* 初始化
|
|
848
|
+
*/
|
|
849
|
+
initialize(): Promise<void>;
|
|
850
|
+
/**
|
|
851
|
+
* 生成请求ID
|
|
852
|
+
*/
|
|
853
|
+
private generateRequestId;
|
|
854
|
+
/**
|
|
855
|
+
* Embed single value - embed() API
|
|
856
|
+
*/
|
|
857
|
+
embed(options: EmbedOptions): Promise<EmbedResult>;
|
|
858
|
+
/**
|
|
859
|
+
* Embed single value - complete embed() implementation
|
|
860
|
+
*/
|
|
861
|
+
embedSingleValue(options: EmbedOptions): Promise<EmbedResult>;
|
|
862
|
+
/**
|
|
863
|
+
* Embed multiple values - embedMany() API
|
|
864
|
+
*/
|
|
865
|
+
embedMany(options: EmbedManyOptions): Promise<EmbedManyResult>;
|
|
866
|
+
/**
|
|
867
|
+
* Embed multiple values - complete embedMany() implementation
|
|
868
|
+
*/
|
|
869
|
+
embedManyValues(options: EmbedManyOptions): Promise<EmbedManyResult>;
|
|
870
|
+
/**
|
|
871
|
+
* Cosine similarity calculation - cosineSimilarity() implementation
|
|
872
|
+
*/
|
|
873
|
+
calculateCosineSimilarity(vector1: number[], vector2: number[]): number;
|
|
874
|
+
/**
|
|
875
|
+
* 批量相似度计算
|
|
876
|
+
*/
|
|
877
|
+
calculateSimilarities(targetVector: number[], vectors: number[][], method?: 'cosine' | 'euclidean' | 'dot'): SimilarityResult[];
|
|
878
|
+
/**
|
|
879
|
+
* 欧几里得距离相似度
|
|
880
|
+
*/
|
|
881
|
+
private calculateEuclideanSimilarity;
|
|
882
|
+
/**
|
|
883
|
+
* 点积相似度
|
|
884
|
+
*/
|
|
885
|
+
private calculateDotProduct;
|
|
886
|
+
/**
|
|
887
|
+
* Find most similar embeddings
|
|
888
|
+
*/
|
|
889
|
+
findMostSimilar(queryVector: number[], candidateVectors: number[][], topK?: number, method?: 'cosine' | 'euclidean' | 'dot'): Array<{
|
|
890
|
+
index: number;
|
|
891
|
+
similarity: number;
|
|
892
|
+
vector: number[];
|
|
893
|
+
}>;
|
|
894
|
+
/**
|
|
895
|
+
* 文本相似性搜索
|
|
896
|
+
*/
|
|
897
|
+
searchSimilarTexts(queryText: string, candidateTexts: string[], model: EmbeddingModel, topK?: number, options?: Partial<EmbeddingModelConfig>): Promise<Array<{
|
|
898
|
+
index: number;
|
|
899
|
+
text: string;
|
|
900
|
+
similarity: number;
|
|
901
|
+
}>>;
|
|
902
|
+
/**
|
|
903
|
+
* Generate cache key
|
|
904
|
+
*/
|
|
905
|
+
private generateCacheKey;
|
|
906
|
+
/**
|
|
907
|
+
* Record usage statistics
|
|
908
|
+
*/
|
|
909
|
+
private recordUsage;
|
|
910
|
+
/**
|
|
911
|
+
* 获取支持的模型信息
|
|
912
|
+
*/
|
|
913
|
+
getSupportedModels(): EmbeddingProviderInfo[];
|
|
914
|
+
/**
|
|
915
|
+
* 根据提供商筛选模型
|
|
916
|
+
*/
|
|
917
|
+
getModelsByProvider(provider: string): EmbeddingProviderInfo[];
|
|
918
|
+
/**
|
|
919
|
+
* 获取使用统计
|
|
920
|
+
*/
|
|
921
|
+
getUsageStats(): Record<string, {
|
|
922
|
+
totalEmbeddings: number;
|
|
923
|
+
totalTokens: number;
|
|
924
|
+
lastUsed: Date;
|
|
925
|
+
}>;
|
|
926
|
+
/**
|
|
927
|
+
* 清理缓存
|
|
928
|
+
*/
|
|
929
|
+
clearCache(): void;
|
|
930
|
+
/**
|
|
931
|
+
* 获取缓存统计
|
|
932
|
+
*/
|
|
933
|
+
getCacheStats(): {
|
|
934
|
+
size: number;
|
|
935
|
+
keys: string[];
|
|
936
|
+
};
|
|
937
|
+
/**
|
|
938
|
+
* 检查初始化状态
|
|
939
|
+
*/
|
|
940
|
+
isInitialized(): boolean;
|
|
941
|
+
/**
|
|
942
|
+
* 获取统计信息
|
|
943
|
+
*/
|
|
944
|
+
getStats(): {
|
|
945
|
+
isInitialized: boolean;
|
|
946
|
+
requestCount: number;
|
|
947
|
+
cacheSize: number;
|
|
948
|
+
totalUsage: {
|
|
949
|
+
embeddings: number;
|
|
950
|
+
tokens: number;
|
|
951
|
+
};
|
|
952
|
+
};
|
|
953
|
+
/**
|
|
954
|
+
* 销毁实例
|
|
955
|
+
*/
|
|
956
|
+
destroy(): void;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
/**
|
|
960
|
+
* AI Structured Data Complete Integration
|
|
961
|
+
*
|
|
962
|
+
* Core structured data functionality:
|
|
963
|
+
* - generateObject: Structured object generation
|
|
964
|
+
* - streamObject: Streaming structured object generation
|
|
965
|
+
*
|
|
966
|
+
* Supports all output strategies: object, array, enum, no-schema
|
|
967
|
+
*/
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* Complete generateObject options interface
|
|
971
|
+
*/
|
|
972
|
+
interface GenerateObjectOptions<T = any> {
|
|
973
|
+
model: LanguageModel;
|
|
974
|
+
output?: 'object' | 'array' | 'enum' | 'no-schema';
|
|
975
|
+
mode?: 'auto' | 'json' | 'tool';
|
|
976
|
+
schema?: z.ZodSchema<T> | any;
|
|
977
|
+
schemaName?: string;
|
|
978
|
+
schemaDescription?: string;
|
|
979
|
+
enum?: string[];
|
|
980
|
+
system?: string;
|
|
981
|
+
prompt?: string | Array<any>;
|
|
982
|
+
messages?: CoreMessage[];
|
|
983
|
+
maxOutputTokens?: number;
|
|
984
|
+
temperature?: number;
|
|
985
|
+
topP?: number;
|
|
986
|
+
topK?: number;
|
|
987
|
+
presencePenalty?: number;
|
|
988
|
+
frequencyPenalty?: number;
|
|
989
|
+
seed?: number;
|
|
990
|
+
maxRetries?: number;
|
|
991
|
+
abortSignal?: AbortSignal;
|
|
992
|
+
headers?: Record<string, string>;
|
|
993
|
+
experimental_repairText?: (options: {
|
|
994
|
+
text: string;
|
|
995
|
+
error: any;
|
|
996
|
+
}) => Promise<string>;
|
|
997
|
+
experimental_download?: (requestedDownloads: Array<{
|
|
998
|
+
url: URL;
|
|
999
|
+
isUrlSupportedByModel: boolean;
|
|
1000
|
+
}>) => Promise<Array<null | {
|
|
1001
|
+
data: Uint8Array;
|
|
1002
|
+
mediaType?: string;
|
|
1003
|
+
}>>;
|
|
1004
|
+
experimental_telemetry?: {
|
|
1005
|
+
isEnabled?: boolean;
|
|
1006
|
+
recordInputs?: boolean;
|
|
1007
|
+
recordOutputs?: boolean;
|
|
1008
|
+
functionId?: string;
|
|
1009
|
+
metadata?: Record<string, string | number | boolean | Array<null | undefined | string> | Array<null | undefined | number> | Array<null | undefined | boolean>>;
|
|
1010
|
+
};
|
|
1011
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
1012
|
+
}
|
|
1013
|
+
/**
|
|
1014
|
+
* streamObject 完整参数接口 - 基于 streamObject.md 规范
|
|
1015
|
+
*/
|
|
1016
|
+
interface StreamObjectOptions<T = any> extends GenerateObjectOptions<T> {
|
|
1017
|
+
onError?: (event: {
|
|
1018
|
+
error: unknown;
|
|
1019
|
+
}) => Promise<void> | void;
|
|
1020
|
+
onFinish?: (result: {
|
|
1021
|
+
usage: LanguageModelUsage;
|
|
1022
|
+
providerMetadata?: Record<string, Record<string, any>>;
|
|
1023
|
+
object?: T;
|
|
1024
|
+
error?: unknown;
|
|
1025
|
+
warnings?: Array<any>;
|
|
1026
|
+
response?: {
|
|
1027
|
+
id: string;
|
|
1028
|
+
model: string;
|
|
1029
|
+
timestamp: Date;
|
|
1030
|
+
headers?: Record<string, string>;
|
|
1031
|
+
};
|
|
1032
|
+
}) => void;
|
|
1033
|
+
}
|
|
1034
|
+
/**
|
|
1035
|
+
* generateObject 返回结果类型 - 基于 generateObject().md 规范
|
|
1036
|
+
*/
|
|
1037
|
+
type GenerateObjectResultType<T> = {
|
|
1038
|
+
object: T;
|
|
1039
|
+
finishReason: 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other' | 'unknown';
|
|
1040
|
+
usage: LanguageModelUsage;
|
|
1041
|
+
request?: LanguageModelRequestMetadata;
|
|
1042
|
+
response?: LanguageModelResponseMetadata & {
|
|
1043
|
+
body?: unknown;
|
|
1044
|
+
};
|
|
1045
|
+
reasoning?: string;
|
|
1046
|
+
warnings?: Array<any>;
|
|
1047
|
+
providerMetadata?: any;
|
|
1048
|
+
toJsonResponse: (init?: any) => Response;
|
|
1049
|
+
};
|
|
1050
|
+
/**
|
|
1051
|
+
* streamObject 返回结果类型 - 基于 streamObject.md 规范
|
|
1052
|
+
*/
|
|
1053
|
+
type StreamObjectResultType<T> = {
|
|
1054
|
+
usage: Promise<LanguageModelUsage>;
|
|
1055
|
+
providerMetadata: Promise<Record<string, Record<string, any>> | undefined>;
|
|
1056
|
+
object: Promise<T>;
|
|
1057
|
+
partialObjectStream: AsyncIterable<any> & ReadableStream<any>;
|
|
1058
|
+
elementStream: AsyncIterable<T> & ReadableStream<T>;
|
|
1059
|
+
textStream: AsyncIterable<string> & ReadableStream<string>;
|
|
1060
|
+
fullStream: AsyncIterable<any> & ReadableStream<any>;
|
|
1061
|
+
request: Promise<LanguageModelRequestMetadata>;
|
|
1062
|
+
response: Promise<LanguageModelResponseMetadata>;
|
|
1063
|
+
warnings?: Array<any>;
|
|
1064
|
+
pipeTextStreamToResponse: (response: any, init?: any) => void;
|
|
1065
|
+
toTextStreamResponse: (init?: any) => Response;
|
|
1066
|
+
pipeObjectStreamToResponse?: (response: any, init?: any) => void;
|
|
1067
|
+
toObjectStreamResponse?: (init?: any) => Response;
|
|
1068
|
+
};
|
|
1069
|
+
/**
|
|
1070
|
+
* Complete structured data integration class
|
|
1071
|
+
*/
|
|
1072
|
+
declare class AIStructuredDataIntegration extends EventEmitter {
|
|
1073
|
+
private initialized;
|
|
1074
|
+
private requestCounter;
|
|
1075
|
+
constructor();
|
|
1076
|
+
/**
|
|
1077
|
+
* 初始化
|
|
1078
|
+
*/
|
|
1079
|
+
initialize(): Promise<void>;
|
|
1080
|
+
/**
|
|
1081
|
+
* 生成请求ID
|
|
1082
|
+
*/
|
|
1083
|
+
private generateRequestId;
|
|
1084
|
+
/**
|
|
1085
|
+
* Generate structured object - supports all output strategies
|
|
1086
|
+
*/
|
|
1087
|
+
generateObject<T = any>(options: GenerateObjectOptions<T>): Promise<GenerateObjectResultType<T>>;
|
|
1088
|
+
/**
|
|
1089
|
+
* Stream structured object generation - supports all output strategies and stream modes
|
|
1090
|
+
*/
|
|
1091
|
+
streamObject<T = any>(options: StreamObjectOptions<T>): StreamObjectResultType<T>;
|
|
1092
|
+
/**
|
|
1093
|
+
* 辅助方法:将流导入响应 - 标准实现
|
|
1094
|
+
*/
|
|
1095
|
+
private pipeStreamToResponse;
|
|
1096
|
+
/**
|
|
1097
|
+
* 消费异步迭代器并写入响应
|
|
1098
|
+
*/
|
|
1099
|
+
private consumeAsyncIterator;
|
|
1100
|
+
/**
|
|
1101
|
+
* Generate object - default object output strategy
|
|
1102
|
+
*/
|
|
1103
|
+
generateObjectData<T>(model: LanguageModel, schema: z.ZodSchema<T>, prompt: string, options?: Partial<GenerateObjectOptions<T>>): Promise<GenerateObjectResultType<T>>;
|
|
1104
|
+
/**
|
|
1105
|
+
* 生成数组 - array 输出策略
|
|
1106
|
+
*/
|
|
1107
|
+
generateArray<T>(model: LanguageModel, elementSchema: z.ZodSchema<T>, prompt: string, options?: Partial<GenerateObjectOptions<T>>): Promise<GenerateObjectResultType<T[]>>;
|
|
1108
|
+
/**
|
|
1109
|
+
* 生成枚举值 - enum 输出策略
|
|
1110
|
+
*/
|
|
1111
|
+
generateEnum(model: LanguageModel, enumValues: string[], prompt: string, options?: Partial<GenerateObjectOptions<string>>): Promise<GenerateObjectResultType<string>>;
|
|
1112
|
+
/**
|
|
1113
|
+
* 生成无模式JSON - no-schema 输出策略
|
|
1114
|
+
*/
|
|
1115
|
+
generateFreeformJSON(model: LanguageModel, prompt: string, options?: Partial<GenerateObjectOptions<any>>): Promise<GenerateObjectResultType<any>>;
|
|
1116
|
+
/**
|
|
1117
|
+
* 流式生成对象 - 默认 object 输出策略
|
|
1118
|
+
*/
|
|
1119
|
+
streamObjectData<T>(model: LanguageModel, schema: z.ZodSchema<T>, prompt: string, options?: Partial<StreamObjectOptions<T>>): StreamObjectResultType<T>;
|
|
1120
|
+
/**
|
|
1121
|
+
* 流式生成数组 - array 输出策略
|
|
1122
|
+
*/
|
|
1123
|
+
streamArray<T>(model: LanguageModel, elementSchema: z.ZodSchema<T>, prompt: string, options?: Partial<StreamObjectOptions<T>>): StreamObjectResultType<T[]>;
|
|
1124
|
+
/**
|
|
1125
|
+
* 流式生成枚举值 - enum 输出策略
|
|
1126
|
+
*/
|
|
1127
|
+
streamEnum(model: LanguageModel, enumValues: string[], prompt: string, options?: Partial<StreamObjectOptions<string>>): StreamObjectResultType<string>;
|
|
1128
|
+
/**
|
|
1129
|
+
* 流式生成无模式JSON - no-schema 输出策略
|
|
1130
|
+
*/
|
|
1131
|
+
streamFreeformJSON(model: LanguageModel, prompt: string, options?: Partial<StreamObjectOptions<any>>): StreamObjectResultType<any>;
|
|
1132
|
+
/**
|
|
1133
|
+
* Check initialization status
|
|
1134
|
+
*/
|
|
1135
|
+
isInitialized(): boolean;
|
|
1136
|
+
/**
|
|
1137
|
+
* Get statistics
|
|
1138
|
+
*/
|
|
1139
|
+
getStats(): {
|
|
1140
|
+
requestCount: number;
|
|
1141
|
+
isInitialized: boolean;
|
|
1142
|
+
};
|
|
1143
|
+
/**
|
|
1144
|
+
* 重置统计信息
|
|
1145
|
+
*/
|
|
1146
|
+
resetStats(): void;
|
|
1147
|
+
/**
|
|
1148
|
+
* 销毁实例
|
|
1149
|
+
*/
|
|
1150
|
+
destroy(): void;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
/**
|
|
1154
|
+
* AI Settings Complete Integration
|
|
1155
|
+
*
|
|
1156
|
+
* Complete settings functionality:
|
|
1157
|
+
* - All common setting parameters
|
|
1158
|
+
* - Provider-specific configurations
|
|
1159
|
+
* - Settings validation and presets
|
|
1160
|
+
* - Dynamic settings management
|
|
1161
|
+
*/
|
|
1162
|
+
|
|
1163
|
+
/**
|
|
1164
|
+
* 通用模型设置 - 基于 Settings.md 官方规范
|
|
1165
|
+
*/
|
|
1166
|
+
interface CommonModelSettings {
|
|
1167
|
+
maxOutputTokens?: number;
|
|
1168
|
+
temperature?: number;
|
|
1169
|
+
topP?: number;
|
|
1170
|
+
topK?: number;
|
|
1171
|
+
presencePenalty?: number;
|
|
1172
|
+
frequencyPenalty?: number;
|
|
1173
|
+
stopSequences?: string[];
|
|
1174
|
+
seed?: number;
|
|
1175
|
+
maxRetries?: number;
|
|
1176
|
+
abortSignal?: AbortSignal;
|
|
1177
|
+
headers?: Record<string, string>;
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* JSON值类型 - 严格按照AI SDK官方规范
|
|
1181
|
+
*/
|
|
1182
|
+
type JSONValue = string | number | boolean | null | {
|
|
1183
|
+
[key: string]: JSONValue;
|
|
1184
|
+
} | JSONValue[];
|
|
1185
|
+
/**
|
|
1186
|
+
* 提供商特定设置 - 严格按照AI SDK官方规范
|
|
1187
|
+
* 必须兼容SharedV2ProviderOptions类型,格式为Record<string, Record<string, JSONValue>>
|
|
1188
|
+
*/
|
|
1189
|
+
interface ProviderSpecificSettings {
|
|
1190
|
+
[key: string]: Record<string, JSONValue>;
|
|
1191
|
+
}
|
|
1192
|
+
/**
|
|
1193
|
+
* 完整的模型设置配置
|
|
1194
|
+
*/
|
|
1195
|
+
interface ModelSettings extends CommonModelSettings {
|
|
1196
|
+
providerOptions?: ProviderSpecificSettings;
|
|
1197
|
+
}
|
|
1198
|
+
/**
|
|
1199
|
+
* 设置预设定义
|
|
1200
|
+
*/
|
|
1201
|
+
interface SettingsPreset {
|
|
1202
|
+
name: string;
|
|
1203
|
+
description: string;
|
|
1204
|
+
settings: ModelSettings;
|
|
1205
|
+
tags?: string[];
|
|
1206
|
+
useCases?: string[];
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* 设置验证结果
|
|
1210
|
+
*/
|
|
1211
|
+
interface SettingsValidationResult {
|
|
1212
|
+
isValid: boolean;
|
|
1213
|
+
errors: Array<{
|
|
1214
|
+
field: string;
|
|
1215
|
+
message: string;
|
|
1216
|
+
value: any;
|
|
1217
|
+
}>;
|
|
1218
|
+
warnings: Array<{
|
|
1219
|
+
field: string;
|
|
1220
|
+
message: string;
|
|
1221
|
+
value: any;
|
|
1222
|
+
}>;
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* 动态设置配置
|
|
1226
|
+
*/
|
|
1227
|
+
interface DynamicSettingsConfig {
|
|
1228
|
+
conditions: Array<{
|
|
1229
|
+
name: string;
|
|
1230
|
+
condition: (context: any) => boolean;
|
|
1231
|
+
settings: Partial<ModelSettings>;
|
|
1232
|
+
}>;
|
|
1233
|
+
default: ModelSettings;
|
|
1234
|
+
fallback?: ModelSettings;
|
|
1235
|
+
}
|
|
1236
|
+
/**
|
|
1237
|
+
* 预定义的设置预设 - 基于官方文档建议和最佳实践
|
|
1238
|
+
*/
|
|
1239
|
+
declare const BuiltinSettingsPresets: Record<string, SettingsPreset>;
|
|
1240
|
+
/**
|
|
1241
|
+
* AI SDK Settings 完整集成类
|
|
1242
|
+
*/
|
|
1243
|
+
declare class AISettingsManagement extends EventEmitter {
|
|
1244
|
+
private initialized;
|
|
1245
|
+
private customPresets;
|
|
1246
|
+
private dynamicConfigs;
|
|
1247
|
+
private settingsHistory;
|
|
1248
|
+
constructor();
|
|
1249
|
+
/**
|
|
1250
|
+
* 初始化
|
|
1251
|
+
*/
|
|
1252
|
+
initialize(): Promise<void>;
|
|
1253
|
+
/**
|
|
1254
|
+
* 验证模型设置 - 官方规范验证
|
|
1255
|
+
*/
|
|
1256
|
+
validateSettings(settings: ModelSettings): SettingsValidationResult;
|
|
1257
|
+
/**
|
|
1258
|
+
* 获取所有可用预设
|
|
1259
|
+
*/
|
|
1260
|
+
getAllPresets(): Record<string, SettingsPreset>;
|
|
1261
|
+
/**
|
|
1262
|
+
* 获取特定预设
|
|
1263
|
+
*/
|
|
1264
|
+
getPreset(name: string): SettingsPreset | null;
|
|
1265
|
+
/**
|
|
1266
|
+
* 创建自定义预设
|
|
1267
|
+
*/
|
|
1268
|
+
createPreset(name: string, preset: SettingsPreset): void;
|
|
1269
|
+
/**
|
|
1270
|
+
* 根据标签搜索预设
|
|
1271
|
+
*/
|
|
1272
|
+
findPresetsByTag(tag: string): SettingsPreset[];
|
|
1273
|
+
/**
|
|
1274
|
+
* 根据使用场景搜索预设
|
|
1275
|
+
*/
|
|
1276
|
+
findPresetsByUseCase(useCase: string): SettingsPreset[];
|
|
1277
|
+
/**
|
|
1278
|
+
* 注册动态设置配置
|
|
1279
|
+
*/
|
|
1280
|
+
registerDynamicConfig(name: string, config: DynamicSettingsConfig): void;
|
|
1281
|
+
/**
|
|
1282
|
+
* 根据上下文解析动态设置
|
|
1283
|
+
*/
|
|
1284
|
+
resolveDynamicSettings(configName: string, context: any): ModelSettings;
|
|
1285
|
+
/**
|
|
1286
|
+
* 合并设置对象
|
|
1287
|
+
*/
|
|
1288
|
+
mergeSettings(...settingsArray: Partial<ModelSettings>[]): ModelSettings;
|
|
1289
|
+
/**
|
|
1290
|
+
* 创建提供商特定设置
|
|
1291
|
+
*/
|
|
1292
|
+
createProviderSettings(providerId: string, settings: Record<string, any>): {
|
|
1293
|
+
providerOptions: ProviderSpecificSettings;
|
|
1294
|
+
};
|
|
1295
|
+
/**
|
|
1296
|
+
* 创建超时设置
|
|
1297
|
+
*/
|
|
1298
|
+
createTimeoutSettings(timeoutMs: number): {
|
|
1299
|
+
abortSignal: AbortSignal;
|
|
1300
|
+
};
|
|
1301
|
+
/**
|
|
1302
|
+
* 创建确定性设置
|
|
1303
|
+
*/
|
|
1304
|
+
createDeterministicSettings(seed?: number): ModelSettings;
|
|
1305
|
+
/**
|
|
1306
|
+
* 创建创意设置
|
|
1307
|
+
*/
|
|
1308
|
+
createCreativeSettings(): ModelSettings;
|
|
1309
|
+
/**
|
|
1310
|
+
* 记录设置使用历史
|
|
1311
|
+
*/
|
|
1312
|
+
recordSettingsUsage(settings: ModelSettings, context?: any): void;
|
|
1313
|
+
/**
|
|
1314
|
+
* 分析设置使用模式
|
|
1315
|
+
*/
|
|
1316
|
+
analyzeSettingsUsage(): {
|
|
1317
|
+
totalRecords: number;
|
|
1318
|
+
mostUsedSettings: Array<{
|
|
1319
|
+
setting: string;
|
|
1320
|
+
count: number;
|
|
1321
|
+
}>;
|
|
1322
|
+
averageValues: Partial<ModelSettings>;
|
|
1323
|
+
timeRange: {
|
|
1324
|
+
earliest: Date;
|
|
1325
|
+
latest: Date;
|
|
1326
|
+
} | null;
|
|
1327
|
+
};
|
|
1328
|
+
/**
|
|
1329
|
+
* 获取系统默认设置 - 统一配置入口
|
|
1330
|
+
* 返回AI_SYSTEM_DEFAULTS作为唯一配置源
|
|
1331
|
+
*/
|
|
1332
|
+
getDefaultSettings(): ModelSettings;
|
|
1333
|
+
/**
|
|
1334
|
+
* 获取系统级配置 - 包含所有配置项
|
|
1335
|
+
*/
|
|
1336
|
+
getSystemDefaults(): {
|
|
1337
|
+
readonly defaultProvider: "qwen";
|
|
1338
|
+
readonly defaultModel: "qwen-plus-2025-01-25";
|
|
1339
|
+
readonly defaultEmbeddingModel: "text-embedding-v1";
|
|
1340
|
+
readonly temperature: 0.7;
|
|
1341
|
+
readonly maxOutputTokens: 4000;
|
|
1342
|
+
readonly topP: 0.95;
|
|
1343
|
+
readonly presencePenalty: 0;
|
|
1344
|
+
readonly frequencyPenalty: 0;
|
|
1345
|
+
readonly systemPrompt: "你是一个专业的SceneMesh AI实体数据助手。你在SceneMesh Entity Engine平台生态系统中运行。\n\n你是与数据管理用户协作的智能助手,帮助解决他们的实体数据管理问题和需求。每次用户发送消息时,系统可能会自动附加一些关于当前数据状态的信息,如用户正在查看的实体数据、最近的数据操作历史、当前数据查询状态、实时系统指标等。这些信息可能与数据管理任务相关,也可能无关,由你来判断其相关性。\n\n你是一个智能代理 - 请持续工作直到完全解决用户的查询,然后结束你的回合并交还给用户。只有在确信问题已得到解决时才终止你的回合。在回复用户之前,请自主地尽最大努力解决查询。\n\n你的主要目标是遵循用户在每条消息中的指示,这些指示用 <user_query> 标签表示。\n\n<tools>\n你拥有各种实体数据管理和分析工具来解决数据操作任务。在使用工具时请遵循以下规则:\n\n1. **准确使用工具**:确保提供所有必要的参数,按照下文列出的工具格式准确调用。\n\n2. **避免引用不可用的工具**:对话中可能会引用不再可用的工具,绝对不要调用未明确定义的工具。\n\n3. **使用自然的数据管理语言描述工具行为**:在与用户交流时,不要提及具体的工具名称,而是用自然的数据管理语言描述正在执行的操作。例如:\"我正在查询你的用户实体数据\"而不是\"我正在调用entity_query工具\"。\n\n4. **优先使用工具获取信息**:如果你需要的额外信息可以通过工具调用获得,请优先使用工具而不是询问用户。\n\n5. **立即执行计划**:如果你制定了一个数据分析或操作计划,请立即执行,不要等待用户确认。只有在需要用户无法通过其他方式获得的信息,或需要用户在不同选项间做出选择时,才应该停止。\n\n6. **使用标准工具调用**:按照系统提供的工具格式进行调用。当需要使用工具时,直接调用,不要解释调用过程或格式。\n\n7. **主动验证实体数据**:如果你对实体数据的内容或结构不确定,请使用工具进行验证和分析,不要猜测或编造答案。\n\n8. **全面的数据探索**:你可以自主地查询尽可能多的相关实体数据源,以完全解决用户的数据管理查询,而不仅仅是查询一个实体。\n\n9. **实体模型和数据引用**:实体模型包含有关如何改进数据结构的有价值信息。它们对于回答关于数据关系的问题也很有用。当提及实体模型时,应该使用标识符格式。例如 ee-base-user 或 ee-base-product\n</tools>\n\n<maximize_context_understanding>\n在收集信息时要**全面深入**。确保在回复之前掌握**完整的数据架构图景**。根据需要使用额外的工具调用或澄清性问题。\n\n**追溯每个实体字段**到其定义和关联方式,确保你完全理解它。\n\n超越第一个看似相关的结果。**探索**替代的数据模型、边缘情况和不同的查询角度,直到你对该实体主题有**全面的覆盖**。\n\n实体语义搜索是你的**主要探索工具**:\n- **关键**:从捕获整体数据架构意图的广泛、高层次查询开始(例如\"用户实体结构\"或\"产品数据关联\"),而不是低层次的字段名称。\n- 将多部分问题分解为专注的子查询(例如\"用户实体如何关联订单?\"或\"产品数据在哪个表格中?\")。\n- **必须**:使用不同的措辞运行多次搜索;首次结果往往会遗漏关键数据细节。\n- 持续搜索新的实体领域,直到你**确信**没有重要信息遗漏。\n\n如果你执行了可能部分满足用户查询的数据分析,但不够自信,请在结束回合前收集更多信息或使用更多工具。\n\n优先自己寻找答案,而不是向用户寻求帮助。\n</maximize_context_understanding>\n\n<making_entity_analysis>\n在进行实体数据分析时,除非用户特别要求,否则不要向用户输出原始数据。而应使用实体数据分析工具来实施分析。\n\n确保你生成的数据洞察能立即为用户所用,这一点**极其重要**。为确保这一点,请仔细遵循以下指示:\n\n1. 添加所有必要的实体背景、数据源引用、字段定义和关联依据。\n2. 如果你从头开始创建数据报告,请创建适当的实体结构文件(如实体数据字典)和有用的技术说明文档。\n3. 如果你正在构建数据视图,请提供现代化和美观的界面,融入最佳的用户体验实践。\n4. 绝不生成超长的数据哈希值或任何非实体内容的二进制数据。这些对数据管理用户无用且成本高昂。\n5. 如果你在实体分析中引入了错误,请修复明显的错误(或你能轻易确定如何修复的错误)。不要做没有根据的猜测。同一实体分析不要循环超过3次错误修复。第三次时,你应该停止并询问用户接下来该怎么做。\n6. 如果你建议的合理实体分析没有被分析引擎接受,你应该尝试重新应用该分析。\n</making_entity_analysis>\n\n使用相关的工具回答用户的请求(如果可用)。检查所有必需的参数是否已提供或可以从上下文合理推断。如果没有相关工具或缺少必需参数的值,请要求用户提供这些值;否则继续进行工具调用。如果用户为参数提供了特定值(例如在引号中提供),请确保准确使用该值。不要编造可选参数的值或询问可选参数。仔细分析请求中的描述性术语,因为它们可能指示应包含的必需参数值,即使没有明确引用。\n\n<summarization>\n如果你看到名为\"<most_important_user_query>\"的部分,你应该将该查询视为要回答的查询,并忽略之前的用户查询。如果要求你总结对话,你绝对不能使用任何工具,即使它们可用。你必须回答\"<most_important_user_query>\"查询。\n</summarization>\n\n<memories>\n你可能会获得一个实体数据记忆列表。这些记忆来自与助手的过往数据管理对话。\n\n它们可能正确也可能不正确,因此如果认为相关就遵循它们,但一旦你注意到用户纠正了你基于记忆所做的事情,或你遇到与现有记忆矛盾或补充的信息,**关键是**你必须立即使用 update_memory 工具更新/删除记忆。你绝对不能使用 update_memory 工具创建与实施计划、助手完成的数据迁移或其他特定任务相关的记忆。\n\n如果用户**曾经**与你的记忆相矛盾,那么最好删除该记忆而不是更新记忆。\n\n你可以根据工具描述中的标准创建、更新或删除记忆。\n\n<memory_citation>\n当你在生成内容、回复用户查询或执行实体数据操作时使用记忆,你必须**始终**引用记忆。为此,请使用以下格式:[[memory:MEMORY_ID]]。你应该将记忆引用自然地融入回应中,而不仅仅作为脚注。\n\n例如:\"我将使用你偏好的数据显示格式 [[memory:MEMORY_ID]] 来展示实体数据分析。\"\n\n当你因为记忆而拒绝用户的明确请求时,你必须在对话中提及如果记忆不正确,用户可以纠正你,你将更新你的记忆。\n</memory_citation>\n</memories>\n\n# 可用工具\n\n以下是你可以调用的实体数据管理工具,应该根据用户需求选择合适的工具进行调用:\n\n## recordGetFieldInfo\n获取当前表单的字段信息和结构\n//\n// ### 何时使用此工具\n//\n**何时使用**:\n- 任何数据操作前的必要步骤\n- 了解当前表单的实际字段结构\n- 获取字段名称、标题和类型信息\n- 确定可用的字段进行数据填充\n\n**何时不使用**:\n- 不涉及表单操作的纯信息查询\n- 已经确定知道字段结构的情况\n//\n// ### 示例\n//\n// <example>\n// 用户请求: \"帮我创建一个产品\"\n//\n// <reasoning>\n// 必须首先调用recordGetFieldInfo()了解当前表单是否为产品表单,以及有哪些字段可以填充。\n// </reasoning>\n// </example>\n//\n// <example>\n// 用户请求: \"填写用户信息\"\n//\n// <reasoning>\n// 先调用recordGetFieldInfo()查看当前表单类型和字段,确认是否为用户表单。\n// </reasoning>\n// </example>\n//\n**工具调用格式**:\n- **工具名称**: recordGetFieldInfo\n- **参数**: 无需参数\n\n## recordGetValues\n获取当前表单的所有字段值\n//\n// ### 何时使用此工具\n//\n**何时使用**:\n- 查看当前表单的填写状态\n- 在修改前获取现有数据\n- 向用户显示当前表单内容\n- 验证数据填充结果\n\n**何时不使用**:\n- 仅需要获取字段结构信息(使用recordGetFieldInfo)\n- 不涉及表单数据的纯信息查询\n//\n// ### 示例\n//\n// <example>\n// 用户请求: \"显示当前表单的内容\"\n//\n// <reasoning>\n// 使用recordGetValues()获取所有字段的当前值并展示给用户。\n// </reasoning>\n// </example>\n//\n**工具调用格式**:\n- **工具名称**: recordGetValues\n- **参数**: 无需参数\n\n## recordSetValues\n设置表单字段值\n//\n// ### 何时使用此工具\n//\n**何时使用**:\n- 根据用户请求填充表单字段\n- 创建新的数据记录\n- 修改现有表单内容\n- 批量设置多个字段值\n\n**何时不使用**:\n- 在不了解字段结构的情况下(应先调用recordGetFieldInfo)\n- 仅需要查看数据而不修改\n//\n// ### 示例\n//\n// <example>\n// 用户请求: \"帮我创建一个产品叫小白\"\n//\n// <reasoning>\n// 先调用recordGetFieldInfo()了解字段结构,然后使用recordSetValues()设置产品相关字段,如name字段设为\"小白\"。\n// </reasoning>\n// </example>\n//\n// <example>\n// 用户请求: \"修改用户信息,姓名改为张三,邮箱改为zhangsan@example.com\"\n//\n// <reasoning>\n// 使用recordSetValues()批量设置多个字段:name设为\"张三\",email设为\"zhangsan@example.com\"。\n// </reasoning>\n// </example>\n//\n**工具调用格式**:\n- **工具名称**: recordSetValues\n- **参数**:\n - values: 字段值对象,键必须是recordGetFieldInfo返回的确切字段名\n\n## recordResetForm\n重置表单到初始状态\n//\n// ### 何时使用此工具\n//\n**何时使用**:\n- 用户明确要求清空表单\n- 重置表单到初始状态\n- 清除所有已填写的内容\n\n**何时不使用**:\n- 仅需要修改个别字段值\n- 用户没有明确要求重置的情况\n//\n// ### 示例\n//\n// <example>\n// 用户请求: \"清空表单内容\"\n//\n// <reasoning>\n// 使用recordResetForm()将表单重置到初始状态,清除所有已填写的数据。\n// </reasoning>\n// </example>\n//\n**工具调用格式**:\n- **工具名称**: recordResetForm\n- **参数**: 无需参数\n\n## recordValidateForm\n验证表单数据的有效性\n//\n// ### 何时使用此工具\n//\n**何时使用**:\n- 在提交表单前验证数据\n- 检查必填字段是否已填写\n- 验证数据格式是否正确\n- 用户要求验证表单内容\n\n**何时不使用**:\n- 仅需要设置或获取数据\n- 不涉及数据验证的操作\n//\n// ### 示例\n//\n// <example>\n// 用户请求: \"检查表单是否填写完整\"\n//\n// <reasoning>\n// 使用recordValidateForm()验证当前表单数据的有效性,检查必填字段和格式规则。\n// </reasoning>\n// </example>\n//\n**工具调用格式**:\n- **工具名称**: recordValidateForm\n- **参数**: 无需参数\n\n## 辅助工具\n\n除了主要的表单操作工具外,还有一些辅助工具可供使用:\n\n### getWeather\n获取指定地点的天气信息\n**工具调用格式**:\n- **工具名称**: getWeather\n- **参数**:\n - location: 地点名称(如\"北京\"、\"上海\"等)\n\n### getLocation \n获取用户当前位置信息\n**工具调用格式**:\n- **工具名称**: getLocation\n- **参数**: 无需参数\n\n### entityQuery\n执行实体数据查询操作\n**工具调用格式**:\n- **工具名称**: entityQuery\n- **参数**:\n - query: 要执行的查询语句或条件\n\n## 核心工作流程\n\n当用户提出数据操作请求时,请严格按照以下三步骤流程:\n\n### 第一步:动态发现表单结构\n**必须**首先调用 recordGetFieldInfo() 来了解:\n- 当前表单的实际字段结构和字段名称\n- 字段标题和类型信息\n- 可用的操作字段\n\n### 第二步:理解上下文和用户意图\n- 分析字段标题理解当前表单类型(产品、用户、事件等)\n- 根据实际表单结构调整回复\n- 如果用户请求与当前表单不符,友好说明并提供选项\n\n### 第三步:执行相应操作\n- 使用 recordSetValues()设置字段值,**仅使用**第一步获取的确切字段名称\n- 根据需要调用其他工具如 recordGetValues()recordValidateForm()等\n- 确保操作基于真实的字段结构,不要假设字段存在\n\n## 重要原则\n\n1. **永远先调用 recordGetFieldInfo()** - 任何数据操作前的必要步骤\n2. **使用准确的字段名称** - 绝不猜测或翻译字段名\n3. **适配实际表单** - 基于真实发现的字段结构操作\n4. **智能上下文识别** - 通过字段标题理解表单业务类型";
|
|
1346
|
+
readonly enableTools: true;
|
|
1347
|
+
readonly enableEmbeddings: true;
|
|
1348
|
+
};
|
|
1349
|
+
/**
|
|
1350
|
+
* 检查初始化状态
|
|
1351
|
+
*/
|
|
1352
|
+
isInitialized(): boolean;
|
|
1353
|
+
/**
|
|
1354
|
+
* 获取统计信息
|
|
1355
|
+
*/
|
|
1356
|
+
getStats(): {
|
|
1357
|
+
isInitialized: boolean;
|
|
1358
|
+
builtinPresets: number;
|
|
1359
|
+
customPresets: number;
|
|
1360
|
+
dynamicConfigs: number;
|
|
1361
|
+
historyRecords: number;
|
|
1362
|
+
};
|
|
1363
|
+
/**
|
|
1364
|
+
* 清理历史记录
|
|
1365
|
+
*/
|
|
1366
|
+
clearHistory(): void;
|
|
1367
|
+
/**
|
|
1368
|
+
* 导出设置配置
|
|
1369
|
+
*/
|
|
1370
|
+
exportSettings(): {
|
|
1371
|
+
customPresets: Record<string, SettingsPreset>;
|
|
1372
|
+
dynamicConfigs: Record<string, DynamicSettingsConfig>;
|
|
1373
|
+
history: Array<{
|
|
1374
|
+
timestamp: Date;
|
|
1375
|
+
settings: ModelSettings;
|
|
1376
|
+
context?: any;
|
|
1377
|
+
}>;
|
|
1378
|
+
};
|
|
1379
|
+
/**
|
|
1380
|
+
* 销毁实例
|
|
1381
|
+
*/
|
|
1382
|
+
destroy(): void;
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
/**
|
|
1386
|
+
* AI Provider and Model Management
|
|
1387
|
+
*
|
|
1388
|
+
* Manages custom providers, model registry, and global configuration.
|
|
1389
|
+
* Includes model aliases, settings, and limitations.
|
|
1390
|
+
*/
|
|
1391
|
+
|
|
1392
|
+
/**
|
|
1393
|
+
* Custom provider configuration
|
|
1394
|
+
*/
|
|
1395
|
+
interface CustomProviderConfig {
|
|
1396
|
+
languageModels?: Record<string, LanguageModel | {
|
|
1397
|
+
model: LanguageModel;
|
|
1398
|
+
middleware?: any;
|
|
1399
|
+
settings?: {
|
|
1400
|
+
maxOutputTokens?: number;
|
|
1401
|
+
temperature?: number;
|
|
1402
|
+
topP?: number;
|
|
1403
|
+
topK?: number;
|
|
1404
|
+
presencePenalty?: number;
|
|
1405
|
+
frequencyPenalty?: number;
|
|
1406
|
+
seed?: number;
|
|
1407
|
+
providerOptions?: Record<string, any>;
|
|
1408
|
+
};
|
|
1409
|
+
}>;
|
|
1410
|
+
embeddingModels?: Record<string, EmbeddingModel>;
|
|
1411
|
+
imageModels?: Record<string, ImageModel>;
|
|
1412
|
+
fallbackProvider?: Provider;
|
|
1413
|
+
}
|
|
1414
|
+
/**
|
|
1415
|
+
* Provider registry configuration
|
|
1416
|
+
*/
|
|
1417
|
+
interface ProviderRegistryConfig {
|
|
1418
|
+
providers: Record<string, Provider>;
|
|
1419
|
+
options?: {
|
|
1420
|
+
separator?: string;
|
|
1421
|
+
};
|
|
1422
|
+
}
|
|
1423
|
+
/**
|
|
1424
|
+
* Model alias configuration
|
|
1425
|
+
*/
|
|
1426
|
+
interface ModelAliasConfig {
|
|
1427
|
+
alias: string;
|
|
1428
|
+
providerId: string;
|
|
1429
|
+
modelId: string;
|
|
1430
|
+
settings?: any;
|
|
1431
|
+
middleware?: any;
|
|
1432
|
+
}
|
|
1433
|
+
/**
|
|
1434
|
+
* Global provider configuration
|
|
1435
|
+
*/
|
|
1436
|
+
interface GlobalProviderConfig {
|
|
1437
|
+
defaultProvider: Provider;
|
|
1438
|
+
modelPrefixes?: Record<string, Provider>;
|
|
1439
|
+
}
|
|
1440
|
+
/**
|
|
1441
|
+
* Provider health check results
|
|
1442
|
+
*/
|
|
1443
|
+
interface ProviderHealthStatus {
|
|
1444
|
+
providerId: string;
|
|
1445
|
+
isHealthy: boolean;
|
|
1446
|
+
latency?: number;
|
|
1447
|
+
error?: string;
|
|
1448
|
+
lastCheck: Date;
|
|
1449
|
+
}
|
|
1450
|
+
/**
|
|
1451
|
+
* Model usage statistics
|
|
1452
|
+
*/
|
|
1453
|
+
interface ModelUsageStats {
|
|
1454
|
+
modelId: string;
|
|
1455
|
+
providerId: string;
|
|
1456
|
+
totalCalls: number;
|
|
1457
|
+
totalTokens: number;
|
|
1458
|
+
averageLatency: number;
|
|
1459
|
+
errorRate: number;
|
|
1460
|
+
lastUsed: Date;
|
|
1461
|
+
}
|
|
1462
|
+
/**
|
|
1463
|
+
* AI Provider Management Integration Class
|
|
1464
|
+
*/
|
|
1465
|
+
declare class AIProviderManagement extends EventEmitter {
|
|
1466
|
+
private initialized;
|
|
1467
|
+
private registry;
|
|
1468
|
+
private customProviders;
|
|
1469
|
+
private modelAliases;
|
|
1470
|
+
private healthStatus;
|
|
1471
|
+
private usageStats;
|
|
1472
|
+
private defaultLanguageModel;
|
|
1473
|
+
private defaultEmbeddingModel;
|
|
1474
|
+
private globalProvider;
|
|
1475
|
+
private embeddingModelConfigs;
|
|
1476
|
+
private modelSettingsPresets;
|
|
1477
|
+
private embeddingsIntegration;
|
|
1478
|
+
private settingsManagement;
|
|
1479
|
+
constructor();
|
|
1480
|
+
/**
|
|
1481
|
+
* 初始化
|
|
1482
|
+
*/
|
|
1483
|
+
initialize(): Promise<void>;
|
|
1484
|
+
/**
|
|
1485
|
+
* 设置默认提供商 - 从环境变量加载配置
|
|
1486
|
+
*/
|
|
1487
|
+
private setupDefaultProviders;
|
|
1488
|
+
/**
|
|
1489
|
+
* Create custom provider
|
|
1490
|
+
*/
|
|
1491
|
+
createCustomProvider(id: string, config: CustomProviderConfig): Provider;
|
|
1492
|
+
/**
|
|
1493
|
+
* Create model alias
|
|
1494
|
+
*/
|
|
1495
|
+
createModelAlias(aliasConfig: ModelAliasConfig): any;
|
|
1496
|
+
/**
|
|
1497
|
+
* Create model with predefined settings
|
|
1498
|
+
*/
|
|
1499
|
+
createModelWithSettings(originalModel: LanguageModel, settings: {
|
|
1500
|
+
maxOutputTokens?: number;
|
|
1501
|
+
temperature?: number;
|
|
1502
|
+
topP?: number;
|
|
1503
|
+
topK?: number;
|
|
1504
|
+
presencePenalty?: number;
|
|
1505
|
+
frequencyPenalty?: number;
|
|
1506
|
+
seed?: number;
|
|
1507
|
+
providerOptions?: Record<string, any>;
|
|
1508
|
+
}): any;
|
|
1509
|
+
/**
|
|
1510
|
+
* Create provider registry
|
|
1511
|
+
*/
|
|
1512
|
+
createProviderRegistry(config: ProviderRegistryConfig): any;
|
|
1513
|
+
/**
|
|
1514
|
+
* Get language model from registry
|
|
1515
|
+
*/
|
|
1516
|
+
getLanguageModel(modelId?: string): LanguageModel | null;
|
|
1517
|
+
/**
|
|
1518
|
+
* Get text embedding model from registry
|
|
1519
|
+
*/
|
|
1520
|
+
getTextEmbeddingModel(modelId?: string): EmbeddingModel | null;
|
|
1521
|
+
/**
|
|
1522
|
+
* 从注册表获取图像模型 - 官方用法
|
|
1523
|
+
*/
|
|
1524
|
+
getImageModel(modelId: string): ImageModel | null;
|
|
1525
|
+
/**
|
|
1526
|
+
* Set global default provider
|
|
1527
|
+
*/
|
|
1528
|
+
setGlobalProvider(provider: Provider): void;
|
|
1529
|
+
/**
|
|
1530
|
+
* Get current global provider
|
|
1531
|
+
*/
|
|
1532
|
+
getGlobalProvider(): Provider | null;
|
|
1533
|
+
/**
|
|
1534
|
+
* Check provider health status
|
|
1535
|
+
*/
|
|
1536
|
+
checkProviderHealth(providerId: string): Promise<ProviderHealthStatus>;
|
|
1537
|
+
/**
|
|
1538
|
+
* Check health status of all providers
|
|
1539
|
+
*/
|
|
1540
|
+
checkAllProvidersHealth(): Promise<ProviderHealthStatus[]>;
|
|
1541
|
+
/**
|
|
1542
|
+
* Record model usage statistics
|
|
1543
|
+
*/
|
|
1544
|
+
private recordModelUsage;
|
|
1545
|
+
/**
|
|
1546
|
+
* Smart model selection based on health and load
|
|
1547
|
+
*/
|
|
1548
|
+
selectBestModel(modelIds: string[], criteria?: {
|
|
1549
|
+
prioritizeHealth?: boolean;
|
|
1550
|
+
prioritizeLatency?: boolean;
|
|
1551
|
+
prioritizeReliability?: boolean;
|
|
1552
|
+
}): Promise<string | null>;
|
|
1553
|
+
/**
|
|
1554
|
+
* Create model chain with fallback
|
|
1555
|
+
*/
|
|
1556
|
+
createModelChain(primaryModelId: string, fallbackModelIds: string[]): {
|
|
1557
|
+
execute: <T>(operation: (model: LanguageModel) => Promise<T>) => Promise<T>;
|
|
1558
|
+
};
|
|
1559
|
+
/**
|
|
1560
|
+
* Get all registered providers
|
|
1561
|
+
*/
|
|
1562
|
+
getRegisteredProviders(): string[];
|
|
1563
|
+
/**
|
|
1564
|
+
* Get model aliases
|
|
1565
|
+
*/
|
|
1566
|
+
getModelAliases(): Record<string, ModelAliasConfig>;
|
|
1567
|
+
/**
|
|
1568
|
+
* Get usage statistics
|
|
1569
|
+
*/
|
|
1570
|
+
getUsageStats(): ModelUsageStats[];
|
|
1571
|
+
/**
|
|
1572
|
+
* Get health status report
|
|
1573
|
+
*/
|
|
1574
|
+
getHealthReport(): {
|
|
1575
|
+
totalProviders: number;
|
|
1576
|
+
healthyProviders: number;
|
|
1577
|
+
unhealthyProviders: number;
|
|
1578
|
+
statuses: ProviderHealthStatus[];
|
|
1579
|
+
};
|
|
1580
|
+
/**
|
|
1581
|
+
* Clean up resources
|
|
1582
|
+
*/
|
|
1583
|
+
cleanup(): Promise<void>;
|
|
1584
|
+
/**
|
|
1585
|
+
* Check initialization status
|
|
1586
|
+
*/
|
|
1587
|
+
isInitialized(): boolean;
|
|
1588
|
+
/**
|
|
1589
|
+
* Get statistics
|
|
1590
|
+
*/
|
|
1591
|
+
getStats(): {
|
|
1592
|
+
isInitialized: boolean;
|
|
1593
|
+
customProviders: number;
|
|
1594
|
+
modelAliases: number;
|
|
1595
|
+
totalUsage: number;
|
|
1596
|
+
hasRegistry: boolean;
|
|
1597
|
+
hasGlobalProvider: boolean;
|
|
1598
|
+
};
|
|
1599
|
+
/**
|
|
1600
|
+
* Get embeddings integration instance
|
|
1601
|
+
*/
|
|
1602
|
+
getEmbeddingsIntegration(): AIEmbeddingsIntegration;
|
|
1603
|
+
/**
|
|
1604
|
+
* Configure embedding model parameters
|
|
1605
|
+
*/
|
|
1606
|
+
configureEmbeddingModel(providerId: string, modelId: string, config: EmbeddingModelConfig): void;
|
|
1607
|
+
/**
|
|
1608
|
+
* Get embedding model configuration
|
|
1609
|
+
*/
|
|
1610
|
+
getEmbeddingModelConfig(providerId: string, modelId: string): EmbeddingModelConfig | null;
|
|
1611
|
+
/**
|
|
1612
|
+
* Get all supported embedding models
|
|
1613
|
+
*/
|
|
1614
|
+
getSupportedEmbeddingModels(): any;
|
|
1615
|
+
/**
|
|
1616
|
+
* Get embedding models by provider
|
|
1617
|
+
*/
|
|
1618
|
+
getEmbeddingModelsByProvider(provider: string): any[];
|
|
1619
|
+
/**
|
|
1620
|
+
* Get settings management instance
|
|
1621
|
+
*/
|
|
1622
|
+
getSettingsManagement(): AISettingsManagement;
|
|
1623
|
+
/**
|
|
1624
|
+
* Apply settings preset to model configuration
|
|
1625
|
+
*/
|
|
1626
|
+
applySettingsPreset(modelId: string, presetName: string, additionalSettings?: Partial<ModelSettings>): ModelSettings;
|
|
1627
|
+
/**
|
|
1628
|
+
* Create model instance with custom settings
|
|
1629
|
+
*/
|
|
1630
|
+
createModelWithCustomSettings(baseModel: LanguageModel, settings: ModelSettings): any;
|
|
1631
|
+
/**
|
|
1632
|
+
* Get model applied settings
|
|
1633
|
+
*/
|
|
1634
|
+
getModelSettings(modelId: string): ModelSettings | null;
|
|
1635
|
+
/**
|
|
1636
|
+
* Create optimized model for specific use case
|
|
1637
|
+
*/
|
|
1638
|
+
createOptimizedModel(baseModel: LanguageModel, useCase: 'creative' | 'analytical' | 'deterministic' | 'fast' | 'long-form' | 'code'): any;
|
|
1639
|
+
/**
|
|
1640
|
+
* Destroy instance - enhanced version
|
|
1641
|
+
*/
|
|
1642
|
+
destroy(): Promise<void>;
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
/**
|
|
1646
|
+
* AI Core配置
|
|
1647
|
+
*/
|
|
1648
|
+
interface AICoreConfig$1 {
|
|
1649
|
+
components?: {
|
|
1650
|
+
aiSDK?: boolean;
|
|
1651
|
+
providerManagement?: boolean;
|
|
1652
|
+
toolsIntegration?: boolean;
|
|
1653
|
+
embeddingsIntegration?: boolean;
|
|
1654
|
+
settingsManagement?: boolean;
|
|
1655
|
+
structuredData?: boolean;
|
|
1656
|
+
};
|
|
1657
|
+
aiSDK?: {
|
|
1658
|
+
defaultSettings?: {
|
|
1659
|
+
temperature?: number;
|
|
1660
|
+
maxOutputTokens?: number;
|
|
1661
|
+
topP?: number;
|
|
1662
|
+
topK?: number;
|
|
1663
|
+
};
|
|
1664
|
+
};
|
|
1665
|
+
providers?: {
|
|
1666
|
+
autoHealthCheck?: boolean;
|
|
1667
|
+
healthCheckInterval?: number;
|
|
1668
|
+
fallbackEnabled?: boolean;
|
|
1669
|
+
};
|
|
1670
|
+
tools?: {
|
|
1671
|
+
enableMCP?: boolean;
|
|
1672
|
+
enableDynamic?: boolean;
|
|
1673
|
+
maxSteps?: number;
|
|
1674
|
+
timeout?: number;
|
|
1675
|
+
};
|
|
1676
|
+
embeddings?: {
|
|
1677
|
+
defaultModel?: string;
|
|
1678
|
+
batchSize?: number;
|
|
1679
|
+
maxParallelCalls?: number;
|
|
1680
|
+
};
|
|
1681
|
+
settings?: {
|
|
1682
|
+
enablePresets?: boolean;
|
|
1683
|
+
enableValidation?: boolean;
|
|
1684
|
+
enableDynamic?: boolean;
|
|
1685
|
+
};
|
|
1686
|
+
monitoring?: {
|
|
1687
|
+
enabled?: boolean;
|
|
1688
|
+
collectMetrics?: boolean;
|
|
1689
|
+
enableEvents?: boolean;
|
|
1690
|
+
logLevel?: 'error' | 'warn' | 'info' | 'debug';
|
|
1691
|
+
};
|
|
1692
|
+
entity?: {
|
|
1693
|
+
enabled?: boolean;
|
|
1694
|
+
autoToolGeneration?: boolean;
|
|
1695
|
+
contextExtraction?: boolean;
|
|
1696
|
+
permissionChecking?: boolean;
|
|
1697
|
+
};
|
|
1698
|
+
}
|
|
1699
|
+
/**
|
|
1700
|
+
* AI Core统计信息
|
|
1701
|
+
*/
|
|
1702
|
+
interface AICoreStats$1 {
|
|
1703
|
+
isInitialized: boolean;
|
|
1704
|
+
initializationTime: number;
|
|
1705
|
+
uptime: number;
|
|
1706
|
+
components: {
|
|
1707
|
+
aiSDK: boolean;
|
|
1708
|
+
providerManagement: boolean;
|
|
1709
|
+
toolsIntegration: boolean;
|
|
1710
|
+
embeddingsIntegration: boolean;
|
|
1711
|
+
settingsManagement: boolean;
|
|
1712
|
+
structuredData: boolean;
|
|
1713
|
+
};
|
|
1714
|
+
usage: {
|
|
1715
|
+
totalRequests: number;
|
|
1716
|
+
successfulRequests: number;
|
|
1717
|
+
failedRequests: number;
|
|
1718
|
+
averageLatency: number;
|
|
1719
|
+
totalTokens: number;
|
|
1720
|
+
errorRate: number;
|
|
1721
|
+
};
|
|
1722
|
+
providers: {
|
|
1723
|
+
totalProviders: number;
|
|
1724
|
+
healthyProviders: number;
|
|
1725
|
+
unhealthyProviders: number;
|
|
1726
|
+
totalModels: number;
|
|
1727
|
+
};
|
|
1728
|
+
performance: {
|
|
1729
|
+
memoryUsage: NodeJS.MemoryUsage;
|
|
1730
|
+
cpuUsage: NodeJS.CpuUsage;
|
|
1731
|
+
gcStats?: any;
|
|
1732
|
+
};
|
|
1733
|
+
}
|
|
1734
|
+
/**
|
|
1735
|
+
* 组件健康状态
|
|
1736
|
+
*/
|
|
1737
|
+
interface ComponentHealth {
|
|
1738
|
+
name: string;
|
|
1739
|
+
status: 'healthy' | 'degraded' | 'unhealthy';
|
|
1740
|
+
lastCheck: Date;
|
|
1741
|
+
error?: string;
|
|
1742
|
+
details?: Record<string, any>;
|
|
1743
|
+
}
|
|
1744
|
+
/**
|
|
1745
|
+
* AI Core Manager - 统一的AI功能管理器
|
|
1746
|
+
*/
|
|
1747
|
+
declare class AICoreManager extends EventEmitter {
|
|
1748
|
+
private initialized;
|
|
1749
|
+
private config;
|
|
1750
|
+
private startTime;
|
|
1751
|
+
private initializationTime;
|
|
1752
|
+
private stats;
|
|
1753
|
+
aiSDK: AISDKIntegration;
|
|
1754
|
+
providerManagement: AIProviderManagement;
|
|
1755
|
+
toolsIntegration: AIToolsIntegration;
|
|
1756
|
+
embeddingsIntegration: AIEmbeddingsIntegration;
|
|
1757
|
+
settingsManagement: AISettingsManagement;
|
|
1758
|
+
structuredData: AIStructuredDataIntegration;
|
|
1759
|
+
private componentHealth;
|
|
1760
|
+
private healthCheckInterval?;
|
|
1761
|
+
constructor(config?: AICoreConfig$1);
|
|
1762
|
+
/**
|
|
1763
|
+
* 初始化AI Core Manager
|
|
1764
|
+
*/
|
|
1765
|
+
initialize(): Promise<void>;
|
|
1766
|
+
/**
|
|
1767
|
+
* 创建所有组件实例
|
|
1768
|
+
*/
|
|
1769
|
+
private createComponents;
|
|
1770
|
+
/**
|
|
1771
|
+
* 初始化所有组件
|
|
1772
|
+
*/
|
|
1773
|
+
private initializeComponents;
|
|
1774
|
+
/**
|
|
1775
|
+
* 设置组件间的依赖关系
|
|
1776
|
+
*/
|
|
1777
|
+
private setupComponentRelationships;
|
|
1778
|
+
/**
|
|
1779
|
+
* 启动监控系统
|
|
1780
|
+
*/
|
|
1781
|
+
private startMonitoring;
|
|
1782
|
+
/**
|
|
1783
|
+
* 执行健康检查
|
|
1784
|
+
*/
|
|
1785
|
+
private performHealthCheck;
|
|
1786
|
+
/**
|
|
1787
|
+
* 更新组件健康状态
|
|
1788
|
+
*/
|
|
1789
|
+
private updateComponentHealth;
|
|
1790
|
+
/**
|
|
1791
|
+
* 更新性能统计
|
|
1792
|
+
*/
|
|
1793
|
+
private updatePerformanceStats;
|
|
1794
|
+
/**
|
|
1795
|
+
* 更新平均延迟
|
|
1796
|
+
*/
|
|
1797
|
+
private updateAverageLatency;
|
|
1798
|
+
/**
|
|
1799
|
+
* 更新错误率
|
|
1800
|
+
*/
|
|
1801
|
+
private updateErrorRate;
|
|
1802
|
+
/**
|
|
1803
|
+
* 更新Provider统计
|
|
1804
|
+
*/
|
|
1805
|
+
private updateProviderStats;
|
|
1806
|
+
/**
|
|
1807
|
+
* 获取完整的统计信息
|
|
1808
|
+
*/
|
|
1809
|
+
getStats(): AICoreStats$1;
|
|
1810
|
+
/**
|
|
1811
|
+
* 获取组件健康状态
|
|
1812
|
+
*/
|
|
1813
|
+
getComponentHealth(): ComponentHealth[];
|
|
1814
|
+
/**
|
|
1815
|
+
* 获取整体健康状态
|
|
1816
|
+
*/
|
|
1817
|
+
getOverallHealth(): {
|
|
1818
|
+
status: 'healthy' | 'degraded' | 'unhealthy';
|
|
1819
|
+
components: ComponentHealth[];
|
|
1820
|
+
summary: string;
|
|
1821
|
+
};
|
|
1822
|
+
/**
|
|
1823
|
+
* 获取AI默认设置 - 从设置管理器统一获取
|
|
1824
|
+
*/
|
|
1825
|
+
getDefaultSettings(): ModelSettings;
|
|
1826
|
+
/**
|
|
1827
|
+
* 获取配置信息
|
|
1828
|
+
*/
|
|
1829
|
+
getConfig(): AICoreConfig$1;
|
|
1830
|
+
/**
|
|
1831
|
+
* 热重载配置
|
|
1832
|
+
*/
|
|
1833
|
+
updateConfig(newConfig: Partial<AICoreConfig$1>): Promise<void>;
|
|
1834
|
+
/**
|
|
1835
|
+
* 重启指定组件
|
|
1836
|
+
*/
|
|
1837
|
+
restartComponent(componentName: string): Promise<void>;
|
|
1838
|
+
/**
|
|
1839
|
+
* 优雅关闭
|
|
1840
|
+
*/
|
|
1841
|
+
gracefulShutdown(): Promise<void>;
|
|
1842
|
+
/**
|
|
1843
|
+
* 深度合并对象
|
|
1844
|
+
*/
|
|
1845
|
+
private deepMerge;
|
|
1846
|
+
/**
|
|
1847
|
+
* 检查初始化状态
|
|
1848
|
+
*/
|
|
1849
|
+
isInitialized(): boolean;
|
|
1850
|
+
}
|
|
1851
|
+
|
|
1852
|
+
/**
|
|
1853
|
+
* Entity Engine AI Module - Core Module Export
|
|
1854
|
+
*
|
|
1855
|
+
* 导出所有核心AI功能,包括Provider管理、工具集成、嵌入向量等
|
|
1856
|
+
* 这个模块专门为后端和无UI环境设计
|
|
1857
|
+
*/
|
|
1858
|
+
|
|
1859
|
+
/**
|
|
1860
|
+
* 创建完整的AI Core实例的便捷函数
|
|
1861
|
+
*/
|
|
1862
|
+
declare function createAICore(config?: {
|
|
1863
|
+
providers?: CustomProviderConfig[];
|
|
1864
|
+
settings?: Partial<ModelSettings>;
|
|
1865
|
+
enableEmbeddings?: boolean;
|
|
1866
|
+
enableTools?: boolean;
|
|
1867
|
+
}): Promise<{
|
|
1868
|
+
aiSDK: AISDKIntegration;
|
|
1869
|
+
providerManagement: AIProviderManagement;
|
|
1870
|
+
toolsIntegration: AIToolsIntegration;
|
|
1871
|
+
embeddingsIntegration: AIEmbeddingsIntegration;
|
|
1872
|
+
settingsManagement: AISettingsManagement;
|
|
1873
|
+
structuredData: AIStructuredDataIntegration;
|
|
1874
|
+
}>;
|
|
1875
|
+
declare const CORE_VERSION = "1.0.0";
|
|
1876
|
+
|
|
1877
|
+
/**
|
|
1878
|
+
* Entity Engine AI - Complete Type Definitions
|
|
1879
|
+
*
|
|
1880
|
+
* Complete type system for AI integration
|
|
1881
|
+
* 确保所有功能的类型安全性
|
|
1882
|
+
*/
|
|
1883
|
+
|
|
1884
|
+
/**
|
|
1885
|
+
* Standard UI message types
|
|
1886
|
+
* 不添加任何非标准字段,确保完全兼容
|
|
1887
|
+
*/
|
|
1888
|
+
type StandardUIMessage = UIMessage;
|
|
1889
|
+
/**
|
|
1890
|
+
* 消息角色类型
|
|
1891
|
+
*/
|
|
1892
|
+
type MessageRole = 'system' | 'user' | 'assistant';
|
|
1893
|
+
/**
|
|
1894
|
+
* 消息状态类型
|
|
1895
|
+
*/
|
|
1896
|
+
type MessageStatus = 'submitted' | 'streaming' | 'ready' | 'error';
|
|
1897
|
+
/**
|
|
1898
|
+
* Tool call status types
|
|
1899
|
+
* 支持流式工具调用的完整状态,包括input-streaming
|
|
1900
|
+
*/
|
|
1901
|
+
type ToolCallState = 'input-streaming' | 'input-available' | 'output-available' | 'output-error';
|
|
1902
|
+
/**
|
|
1903
|
+
* 工具类型定义
|
|
1904
|
+
*/
|
|
1905
|
+
interface ToolDefinition {
|
|
1906
|
+
name: string;
|
|
1907
|
+
description: string;
|
|
1908
|
+
inputSchema: z.ZodSchema;
|
|
1909
|
+
type: 'server-side' | 'client-side' | 'user-interaction';
|
|
1910
|
+
}
|
|
1911
|
+
/**
|
|
1912
|
+
* 工具执行结果
|
|
1913
|
+
*/
|
|
1914
|
+
interface ToolExecutionResult {
|
|
1915
|
+
toolCallId: string;
|
|
1916
|
+
toolName: string;
|
|
1917
|
+
result: any;
|
|
1918
|
+
error?: string;
|
|
1919
|
+
executionTime?: number;
|
|
1920
|
+
}
|
|
1921
|
+
/**
|
|
1922
|
+
* 用户交互工具选项
|
|
1923
|
+
*/
|
|
1924
|
+
interface UserInteractionToolOptions {
|
|
1925
|
+
title: string;
|
|
1926
|
+
description?: string;
|
|
1927
|
+
actions: Array<{
|
|
1928
|
+
label: string;
|
|
1929
|
+
value: any;
|
|
1930
|
+
variant?: 'default' | 'destructive' | 'outline' | 'secondary';
|
|
1931
|
+
}>;
|
|
1932
|
+
}
|
|
1933
|
+
/**
|
|
1934
|
+
* Chat configuration options
|
|
1935
|
+
*/
|
|
1936
|
+
interface ChatOptions<TMessage extends StandardUIMessage = StandardUIMessage> {
|
|
1937
|
+
/** 聊天ID */
|
|
1938
|
+
id?: string;
|
|
1939
|
+
/** 初始消息 */
|
|
1940
|
+
initialMessages?: TMessage[];
|
|
1941
|
+
/** Transport configuration */
|
|
1942
|
+
transport?: any;
|
|
1943
|
+
/** API端点 - 向后兼容 */
|
|
1944
|
+
api?: string;
|
|
1945
|
+
/** 请求头 - 向后兼容 */
|
|
1946
|
+
headers?: Record<string, string> | (() => Record<string, string>);
|
|
1947
|
+
/** 请求体 - 向后兼容 */
|
|
1948
|
+
body?: Record<string, any> | (() => Record<string, any>);
|
|
1949
|
+
/** 凭据模式 - 向后兼容 */
|
|
1950
|
+
credentials?: RequestCredentials;
|
|
1951
|
+
/** 工具调用回调 */
|
|
1952
|
+
onToolCall?: (options: {
|
|
1953
|
+
toolCall: any;
|
|
1954
|
+
}) => void | Promise<void>;
|
|
1955
|
+
/** 自动发送条件 */
|
|
1956
|
+
sendAutomaticallyWhen?: (options: {
|
|
1957
|
+
messages: TMessage[];
|
|
1958
|
+
}) => boolean | PromiseLike<boolean>;
|
|
1959
|
+
/** 完成回调 */
|
|
1960
|
+
onFinish?: (options: {
|
|
1961
|
+
message: TMessage;
|
|
1962
|
+
messages: TMessage[];
|
|
1963
|
+
isAbort: boolean;
|
|
1964
|
+
isDisconnect: boolean;
|
|
1965
|
+
isError: boolean;
|
|
1966
|
+
}) => void;
|
|
1967
|
+
/** 错误回调 */
|
|
1968
|
+
onError?: (error: Error) => void;
|
|
1969
|
+
/** 数据回调 */
|
|
1970
|
+
onData?: (dataPart: DataUIPart<any>) => void;
|
|
1971
|
+
/** UI更新节流 */
|
|
1972
|
+
experimental_throttle?: number;
|
|
1973
|
+
/** 是否恢复流 */
|
|
1974
|
+
resume?: boolean;
|
|
1975
|
+
/** 视图控制器实例 - 支持客户端工具调用 */
|
|
1976
|
+
viewController?: any;
|
|
1977
|
+
}
|
|
1978
|
+
/**
|
|
1979
|
+
* 聊天对话框属性 - 扩展支持更多UI功能
|
|
1980
|
+
*/
|
|
1981
|
+
interface ChatDialogProps {
|
|
1982
|
+
/** 聊天选项 */
|
|
1983
|
+
chatOptions?: ChatOptions;
|
|
1984
|
+
/** 对话框标题 */
|
|
1985
|
+
title?: string;
|
|
1986
|
+
/** 对话框描述 */
|
|
1987
|
+
description?: string;
|
|
1988
|
+
/** 是否打开 */
|
|
1989
|
+
open?: boolean;
|
|
1990
|
+
/** 打开状态变化回调 */
|
|
1991
|
+
onOpenChange?: (open: boolean) => void;
|
|
1992
|
+
/** 输入框占位符 */
|
|
1993
|
+
placeholder?: string;
|
|
1994
|
+
/** 自定义样式类 */
|
|
1995
|
+
className?: string;
|
|
1996
|
+
/** 是否显示头部 */
|
|
1997
|
+
showHeader?: boolean;
|
|
1998
|
+
/** 是否允许文件上传 */
|
|
1999
|
+
allowFileUpload?: boolean;
|
|
2000
|
+
/** 接受的文件类型 */
|
|
2001
|
+
acceptedFileTypes?: string[];
|
|
2002
|
+
/** 最大文件大小 */
|
|
2003
|
+
maxFileSize?: number;
|
|
2004
|
+
/** 工具渲染器 */
|
|
2005
|
+
toolRenderers?: Record<string, React.ComponentType<any>>;
|
|
2006
|
+
/** 消息渲染器 */
|
|
2007
|
+
messageRenderer?: React.ComponentType<any>;
|
|
2008
|
+
/** 主题配置 */
|
|
2009
|
+
theme?: ThemeConfig | string;
|
|
2010
|
+
/** 启用推理显示 */
|
|
2011
|
+
enableReasoning?: boolean;
|
|
2012
|
+
/** 启用生成式UI */
|
|
2013
|
+
enableGenerativeUI?: boolean;
|
|
2014
|
+
/** 默认显示推理 */
|
|
2015
|
+
showReasoningByDefault?: boolean;
|
|
2016
|
+
/** 页面上下文信息 */
|
|
2017
|
+
pageContext?: any;
|
|
2018
|
+
}
|
|
2019
|
+
/**
|
|
2020
|
+
* 消息气泡属性 - 扩展支持更多显示选项
|
|
2021
|
+
*/
|
|
2022
|
+
interface MessageBubbleProps {
|
|
2023
|
+
/** 消息对象 */
|
|
2024
|
+
message: UIMessage;
|
|
2025
|
+
/** 是否显示头像 */
|
|
2026
|
+
showAvatar?: boolean;
|
|
2027
|
+
/** 是否显示时间戳 */
|
|
2028
|
+
showTimestamp?: boolean;
|
|
2029
|
+
/** 工具结果回调 */
|
|
2030
|
+
onToolResult?: (result: any) => void;
|
|
2031
|
+
/** 启用推理显示 */
|
|
2032
|
+
enableReasoning?: boolean;
|
|
2033
|
+
/** 启用生成式UI */
|
|
2034
|
+
enableGenerativeUI?: boolean;
|
|
2035
|
+
/** 默认显示推理 */
|
|
2036
|
+
showReasoningByDefault?: boolean;
|
|
2037
|
+
}
|
|
2038
|
+
/**
|
|
2039
|
+
* 文件查看器属性
|
|
2040
|
+
*/
|
|
2041
|
+
interface FileViewerProps {
|
|
2042
|
+
/** 文件对象 */
|
|
2043
|
+
file: FileUIPart;
|
|
2044
|
+
/** 是否显示下载按钮 */
|
|
2045
|
+
showDownload?: boolean;
|
|
2046
|
+
/** 是否显示删除按钮 */
|
|
2047
|
+
showRemove?: boolean;
|
|
2048
|
+
/** 删除回调 */
|
|
2049
|
+
onRemove?: (file: FileUIPart) => void;
|
|
2050
|
+
/** 自定义样式类 */
|
|
2051
|
+
className?: string;
|
|
2052
|
+
}
|
|
2053
|
+
/**
|
|
2054
|
+
* 自定义Transport配置
|
|
2055
|
+
*/
|
|
2056
|
+
interface CustomTransportOptions {
|
|
2057
|
+
/** API端点 */
|
|
2058
|
+
api?: string;
|
|
2059
|
+
/** 请求头 */
|
|
2060
|
+
headers?: Record<string, string> | (() => Record<string, string>);
|
|
2061
|
+
/** 请求体 */
|
|
2062
|
+
body?: Record<string, any> | (() => Record<string, any>);
|
|
2063
|
+
/** 凭据模式 */
|
|
2064
|
+
credentials?: RequestCredentials | (() => RequestCredentials);
|
|
2065
|
+
/** 请求准备函数 */
|
|
2066
|
+
prepareSendMessagesRequest?: (options: any) => any;
|
|
2067
|
+
/** 重连请求准备函数 */
|
|
2068
|
+
prepareReconnectToStreamRequest?: (options: any) => any;
|
|
2069
|
+
}
|
|
2070
|
+
/**
|
|
2071
|
+
* 自定义数据部分类型
|
|
2072
|
+
*/
|
|
2073
|
+
interface CustomDataParts {
|
|
2074
|
+
/** 天气数据 */
|
|
2075
|
+
weather: {
|
|
2076
|
+
city: string;
|
|
2077
|
+
weather?: string;
|
|
2078
|
+
temperature?: number;
|
|
2079
|
+
status: 'loading' | 'success' | 'error';
|
|
2080
|
+
};
|
|
2081
|
+
/** 通知数据 */
|
|
2082
|
+
notification: {
|
|
2083
|
+
message: string;
|
|
2084
|
+
level: 'info' | 'warning' | 'error' | 'success';
|
|
2085
|
+
duration?: number;
|
|
2086
|
+
};
|
|
2087
|
+
/** 进度数据 */
|
|
2088
|
+
progress: {
|
|
2089
|
+
current: number;
|
|
2090
|
+
total: number;
|
|
2091
|
+
label?: string;
|
|
2092
|
+
};
|
|
2093
|
+
/** 状态数据 */
|
|
2094
|
+
status: {
|
|
2095
|
+
type: 'processing' | 'complete' | 'error' | 'cancelled';
|
|
2096
|
+
message: string;
|
|
2097
|
+
details?: any;
|
|
2098
|
+
};
|
|
2099
|
+
}
|
|
2100
|
+
/**
|
|
2101
|
+
* 扩展的UI消息类型,包含自定义数据部分
|
|
2102
|
+
*/
|
|
2103
|
+
type CustomUIMessage = UIMessage;
|
|
2104
|
+
/**
|
|
2105
|
+
* 扩展的UI消息类型 - 向后兼容
|
|
2106
|
+
*/
|
|
2107
|
+
type ExtendedUIMessage = UIMessage;
|
|
2108
|
+
/**
|
|
2109
|
+
* 主题配置
|
|
2110
|
+
*/
|
|
2111
|
+
interface ThemeConfig {
|
|
2112
|
+
/** 主题模式 */
|
|
2113
|
+
mode: 'light' | 'dark' | 'system';
|
|
2114
|
+
/** 主色调 */
|
|
2115
|
+
primaryColor?: string;
|
|
2116
|
+
/** 圆角大小 */
|
|
2117
|
+
borderRadius?: 'none' | 'sm' | 'md' | 'lg' | 'xl';
|
|
2118
|
+
/** 字体族 */
|
|
2119
|
+
fontFamily?: string;
|
|
2120
|
+
/** 动画持续时间 */
|
|
2121
|
+
animationDuration?: 'fast' | 'normal' | 'slow';
|
|
2122
|
+
}
|
|
2123
|
+
/**
|
|
2124
|
+
* 样式变体
|
|
2125
|
+
*/
|
|
2126
|
+
interface StyleVariants {
|
|
2127
|
+
/** 消息气泡变体 */
|
|
2128
|
+
messageBubble?: 'default' | 'minimal' | 'rounded' | 'bordered';
|
|
2129
|
+
/** 输入框变体 */
|
|
2130
|
+
inputField?: 'default' | 'filled' | 'outlined' | 'underlined';
|
|
2131
|
+
/** 按钮变体 */
|
|
2132
|
+
button?: 'default' | 'ghost' | 'outline' | 'solid';
|
|
2133
|
+
}
|
|
2134
|
+
/**
|
|
2135
|
+
* 聊天事件类型
|
|
2136
|
+
*/
|
|
2137
|
+
interface ChatEvents {
|
|
2138
|
+
/** 消息发送 */
|
|
2139
|
+
'message:sent': {
|
|
2140
|
+
message: UIMessage;
|
|
2141
|
+
};
|
|
2142
|
+
/** 消息接收 */
|
|
2143
|
+
'message:received': {
|
|
2144
|
+
message: UIMessage;
|
|
2145
|
+
};
|
|
2146
|
+
/** 工具调用 */
|
|
2147
|
+
'tool:called': {
|
|
2148
|
+
toolName: string;
|
|
2149
|
+
input: any;
|
|
2150
|
+
};
|
|
2151
|
+
/** 工具结果 */
|
|
2152
|
+
'tool:result': {
|
|
2153
|
+
toolName: string;
|
|
2154
|
+
output: any;
|
|
2155
|
+
};
|
|
2156
|
+
/** 错误发生 */
|
|
2157
|
+
'error:occurred': {
|
|
2158
|
+
error: Error;
|
|
2159
|
+
};
|
|
2160
|
+
/** 流开始 */
|
|
2161
|
+
'stream:started': {
|
|
2162
|
+
timestamp: number;
|
|
2163
|
+
};
|
|
2164
|
+
/** 流结束 */
|
|
2165
|
+
'stream:ended': {
|
|
2166
|
+
timestamp: number;
|
|
2167
|
+
duration: number;
|
|
2168
|
+
};
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
/**
|
|
2172
|
+
* Entity Engine AI - Warning System
|
|
2173
|
+
*
|
|
2174
|
+
* Global warning handling system compliant with AI SDK standards
|
|
2175
|
+
*/
|
|
2176
|
+
/**
|
|
2177
|
+
* Warning type
|
|
2178
|
+
*/
|
|
2179
|
+
type WarningType = 'unsupported-setting' | 'unsupported-tool' | 'deprecated-feature' | 'validation-error' | 'performance-warning' | 'unknown';
|
|
2180
|
+
/**
|
|
2181
|
+
* Warning object
|
|
2182
|
+
*/
|
|
2183
|
+
interface Warning {
|
|
2184
|
+
type: WarningType;
|
|
2185
|
+
message: string;
|
|
2186
|
+
details?: Record<string, any>;
|
|
2187
|
+
timestamp: number;
|
|
2188
|
+
source?: string;
|
|
2189
|
+
}
|
|
2190
|
+
/**
|
|
2191
|
+
* Warning handler function type
|
|
2192
|
+
*/
|
|
2193
|
+
type WarningHandler = (warnings: Warning[]) => void;
|
|
2194
|
+
/**
|
|
2195
|
+
* Warn about unsupported setting
|
|
2196
|
+
*/
|
|
2197
|
+
declare function warnUnsupportedSetting(setting: string, model?: string): void;
|
|
2198
|
+
/**
|
|
2199
|
+
* Warn about unsupported tool
|
|
2200
|
+
*/
|
|
2201
|
+
declare function warnUnsupportedTool(toolName: string, model?: string): void;
|
|
2202
|
+
/**
|
|
2203
|
+
* Warn about deprecated feature
|
|
2204
|
+
*/
|
|
2205
|
+
declare function warnDeprecatedFeature(feature: string, replacement?: string): void;
|
|
2206
|
+
/**
|
|
2207
|
+
* Warn about validation error
|
|
2208
|
+
*/
|
|
2209
|
+
declare function warnValidationError(message: string, details?: Record<string, any>): void;
|
|
2210
|
+
/**
|
|
2211
|
+
* Warn about performance issue
|
|
2212
|
+
*/
|
|
2213
|
+
declare function warnPerformance(message: string, details?: Record<string, any>): void;
|
|
2214
|
+
/**
|
|
2215
|
+
* Emit general warning
|
|
2216
|
+
*/
|
|
2217
|
+
declare function warn(message: string, details?: Record<string, any>): void;
|
|
2218
|
+
/**
|
|
2219
|
+
* Set warning handler
|
|
2220
|
+
*/
|
|
2221
|
+
declare function setWarningHandler(handler: WarningHandler | boolean): void;
|
|
2222
|
+
/**
|
|
2223
|
+
* Get all warnings
|
|
2224
|
+
*/
|
|
2225
|
+
declare function getWarnings(): Warning[];
|
|
2226
|
+
/**
|
|
2227
|
+
* Clear warnings
|
|
2228
|
+
*/
|
|
2229
|
+
declare function clearWarnings(): void;
|
|
2230
|
+
/**
|
|
2231
|
+
* Get warning statistics
|
|
2232
|
+
*/
|
|
2233
|
+
declare function getWarningStats(): Record<WarningType, number>;
|
|
2234
|
+
|
|
2235
|
+
/**
|
|
2236
|
+
* Entity Engine AI - Streaming Utils
|
|
2237
|
+
*
|
|
2238
|
+
* Stream processing utilities for message stream reading and processing
|
|
2239
|
+
*/
|
|
2240
|
+
|
|
2241
|
+
/**
|
|
2242
|
+
* Read UI message stream options
|
|
2243
|
+
*/
|
|
2244
|
+
interface ReadUIMessageStreamOptions {
|
|
2245
|
+
stream: ReadableStream;
|
|
2246
|
+
message?: UIMessage;
|
|
2247
|
+
onMessage?: (message: UIMessage) => void;
|
|
2248
|
+
onError?: (error: Error) => void;
|
|
2249
|
+
onComplete?: (finalMessage: UIMessage) => void;
|
|
2250
|
+
}
|
|
2251
|
+
/**
|
|
2252
|
+
* UI message stream reader
|
|
2253
|
+
*/
|
|
2254
|
+
declare class UIMessageStreamReader {
|
|
2255
|
+
private options;
|
|
2256
|
+
private reader;
|
|
2257
|
+
private currentMessage;
|
|
2258
|
+
private isReading;
|
|
2259
|
+
constructor(options: ReadUIMessageStreamOptions);
|
|
2260
|
+
/**
|
|
2261
|
+
* Start reading stream
|
|
2262
|
+
*/
|
|
2263
|
+
read(): AsyncIterableIterator<UIMessage>;
|
|
2264
|
+
/**
|
|
2265
|
+
* Process stream chunk
|
|
2266
|
+
*/
|
|
2267
|
+
private processChunk;
|
|
2268
|
+
/**
|
|
2269
|
+
* Handle stream data
|
|
2270
|
+
*/
|
|
2271
|
+
private handleStreamData;
|
|
2272
|
+
/**
|
|
2273
|
+
* Handle message start
|
|
2274
|
+
*/
|
|
2275
|
+
private handleMessageStart;
|
|
2276
|
+
/**
|
|
2277
|
+
* Handle message delta
|
|
2278
|
+
*/
|
|
2279
|
+
private handleMessageDelta;
|
|
2280
|
+
/**
|
|
2281
|
+
* Handle message stop
|
|
2282
|
+
*/
|
|
2283
|
+
private handleMessageStop;
|
|
2284
|
+
/**
|
|
2285
|
+
* Handle text delta
|
|
2286
|
+
*/
|
|
2287
|
+
private handleTextDelta;
|
|
2288
|
+
/**
|
|
2289
|
+
* Handle tool call
|
|
2290
|
+
*/
|
|
2291
|
+
private handleToolCall;
|
|
2292
|
+
/**
|
|
2293
|
+
* Handle tool result
|
|
2294
|
+
*/
|
|
2295
|
+
private handleToolResult;
|
|
2296
|
+
/**
|
|
2297
|
+
* Generate ID
|
|
2298
|
+
*/
|
|
2299
|
+
private generateId;
|
|
2300
|
+
/**
|
|
2301
|
+
* Stop reading
|
|
2302
|
+
*/
|
|
2303
|
+
stop(): Promise<void>;
|
|
2304
|
+
/**
|
|
2305
|
+
* Cleanup resources
|
|
2306
|
+
*/
|
|
2307
|
+
private cleanup;
|
|
2308
|
+
}
|
|
2309
|
+
/**
|
|
2310
|
+
* Read UI message stream
|
|
2311
|
+
*/
|
|
2312
|
+
declare function readUIMessageStream(options: ReadUIMessageStreamOptions): AsyncIterableIterator<UIMessage>;
|
|
2313
|
+
/**
|
|
2314
|
+
* Stream resume options
|
|
2315
|
+
*/
|
|
2316
|
+
interface StreamResumeOptions {
|
|
2317
|
+
chatId: string;
|
|
2318
|
+
messageId?: string;
|
|
2319
|
+
endpoint?: string;
|
|
2320
|
+
headers?: Record<string, string>;
|
|
2321
|
+
}
|
|
2322
|
+
/**
|
|
2323
|
+
* Resume stream
|
|
2324
|
+
*/
|
|
2325
|
+
declare function resumeStream({ chatId, messageId, endpoint, headers, }: StreamResumeOptions): Promise<ReadableStream>;
|
|
2326
|
+
/**
|
|
2327
|
+
* Stream state
|
|
2328
|
+
*/
|
|
2329
|
+
type StreamState = 'idle' | 'connecting' | 'streaming' | 'complete' | 'error' | 'aborted';
|
|
2330
|
+
/**
|
|
2331
|
+
* Stream state manager
|
|
2332
|
+
*/
|
|
2333
|
+
declare class StreamStateManager {
|
|
2334
|
+
private state;
|
|
2335
|
+
private listeners;
|
|
2336
|
+
private abortController;
|
|
2337
|
+
/**
|
|
2338
|
+
* Get current state
|
|
2339
|
+
*/
|
|
2340
|
+
getState(): StreamState;
|
|
2341
|
+
/**
|
|
2342
|
+
* Set state
|
|
2343
|
+
*/
|
|
2344
|
+
setState(newState: StreamState): void;
|
|
2345
|
+
/**
|
|
2346
|
+
* Listen to state changes
|
|
2347
|
+
*/
|
|
2348
|
+
onStateChange(listener: (state: StreamState) => void): () => void;
|
|
2349
|
+
/**
|
|
2350
|
+
* Start stream
|
|
2351
|
+
*/
|
|
2352
|
+
startStream(): AbortController;
|
|
2353
|
+
/**
|
|
2354
|
+
* Abort stream
|
|
2355
|
+
*/
|
|
2356
|
+
abortStream(): void;
|
|
2357
|
+
/**
|
|
2358
|
+
* Complete stream
|
|
2359
|
+
*/
|
|
2360
|
+
completeStream(): void;
|
|
2361
|
+
/**
|
|
2362
|
+
* Stream error
|
|
2363
|
+
*/
|
|
2364
|
+
errorStream(): void;
|
|
2365
|
+
/**
|
|
2366
|
+
* Reset state
|
|
2367
|
+
*/
|
|
2368
|
+
reset(): void;
|
|
2369
|
+
/**
|
|
2370
|
+
* Notify listeners
|
|
2371
|
+
*/
|
|
2372
|
+
private notifyListeners;
|
|
2373
|
+
/**
|
|
2374
|
+
* Dispose
|
|
2375
|
+
*/
|
|
2376
|
+
dispose(): void;
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
/**
|
|
2380
|
+
* 🎯 Entity Engine AIUI - Message Persistence Utils
|
|
2381
|
+
*
|
|
2382
|
+
* 消息持久化工具,支持消息验证、ID生成和存储管理
|
|
2383
|
+
*/
|
|
2384
|
+
|
|
2385
|
+
/**
|
|
2386
|
+
* ID生成器选项
|
|
2387
|
+
*/
|
|
2388
|
+
interface IdGeneratorOptions {
|
|
2389
|
+
prefix?: string;
|
|
2390
|
+
size?: number;
|
|
2391
|
+
}
|
|
2392
|
+
/**
|
|
2393
|
+
* 创建ID生成器
|
|
2394
|
+
*/
|
|
2395
|
+
declare function createIdGenerator(options?: IdGeneratorOptions): () => string;
|
|
2396
|
+
/**
|
|
2397
|
+
* 生成唯一ID
|
|
2398
|
+
*/
|
|
2399
|
+
declare function generateId(): string;
|
|
2400
|
+
/**
|
|
2401
|
+
* 消息验证选项
|
|
2402
|
+
*/
|
|
2403
|
+
interface ValidateUIMessagesOptions<T extends Record<string, any> = any> {
|
|
2404
|
+
messages: UIMessage[];
|
|
2405
|
+
tools?: T;
|
|
2406
|
+
dataPartsSchema?: z.ZodSchema;
|
|
2407
|
+
metadataSchema?: z.ZodSchema;
|
|
2408
|
+
}
|
|
2409
|
+
/**
|
|
2410
|
+
* 验证UI消息
|
|
2411
|
+
*/
|
|
2412
|
+
declare function validateUIMessages<T extends Record<string, any>>({ messages, tools, dataPartsSchema, metadataSchema, }: ValidateUIMessagesOptions<T>): Promise<UIMessage[]>;
|
|
2413
|
+
/**
|
|
2414
|
+
* 类型验证错误类
|
|
2415
|
+
*/
|
|
2416
|
+
declare class TypeValidationError extends Error {
|
|
2417
|
+
readonly details?: any | undefined;
|
|
2418
|
+
constructor(message: string, details?: any | undefined);
|
|
2419
|
+
}
|
|
2420
|
+
/**
|
|
2421
|
+
* 消息存储接口
|
|
2422
|
+
*/
|
|
2423
|
+
interface MessageStore {
|
|
2424
|
+
createChat(): Promise<string>;
|
|
2425
|
+
loadChat(id: string): Promise<UIMessage[]>;
|
|
2426
|
+
saveChat(options: {
|
|
2427
|
+
chatId: string;
|
|
2428
|
+
messages: UIMessage[];
|
|
2429
|
+
}): Promise<void>;
|
|
2430
|
+
deleteChat(id: string): Promise<void>;
|
|
2431
|
+
listChats(): Promise<Array<{
|
|
2432
|
+
id: string;
|
|
2433
|
+
title?: string;
|
|
2434
|
+
updatedAt: Date;
|
|
2435
|
+
}>>;
|
|
2436
|
+
}
|
|
2437
|
+
/**
|
|
2438
|
+
* 内存消息存储(用于开发和测试)
|
|
2439
|
+
*/
|
|
2440
|
+
declare class InMemoryMessageStore implements MessageStore {
|
|
2441
|
+
private chats;
|
|
2442
|
+
private metadata;
|
|
2443
|
+
createChat(): Promise<string>;
|
|
2444
|
+
loadChat(id: string): Promise<UIMessage[]>;
|
|
2445
|
+
saveChat({ chatId, messages }: {
|
|
2446
|
+
chatId: string;
|
|
2447
|
+
messages: UIMessage[];
|
|
2448
|
+
}): Promise<void>;
|
|
2449
|
+
deleteChat(id: string): Promise<void>;
|
|
2450
|
+
listChats(): Promise<Array<{
|
|
2451
|
+
id: string;
|
|
2452
|
+
title?: string;
|
|
2453
|
+
updatedAt: Date;
|
|
2454
|
+
}>>;
|
|
2455
|
+
private extractTitle;
|
|
2456
|
+
}
|
|
2457
|
+
/**
|
|
2458
|
+
* 本地存储消息存储
|
|
2459
|
+
*/
|
|
2460
|
+
declare class LocalStorageMessageStore implements MessageStore {
|
|
2461
|
+
private readonly keyPrefix;
|
|
2462
|
+
createChat(): Promise<string>;
|
|
2463
|
+
loadChat(id: string): Promise<UIMessage[]>;
|
|
2464
|
+
saveChat({ chatId, messages }: {
|
|
2465
|
+
chatId: string;
|
|
2466
|
+
messages: UIMessage[];
|
|
2467
|
+
}): Promise<void>;
|
|
2468
|
+
deleteChat(id: string): Promise<void>;
|
|
2469
|
+
listChats(): Promise<Array<{
|
|
2470
|
+
id: string;
|
|
2471
|
+
title?: string;
|
|
2472
|
+
updatedAt: Date;
|
|
2473
|
+
}>>;
|
|
2474
|
+
private extractTitle;
|
|
2475
|
+
}
|
|
2476
|
+
|
|
2477
|
+
/**
|
|
2478
|
+
* Entity Engine AI - Utility Functions
|
|
2479
|
+
*
|
|
2480
|
+
* Collection of utility functions for common operations
|
|
2481
|
+
*/
|
|
2482
|
+
|
|
2483
|
+
/**
|
|
2484
|
+
* Extract text content from message
|
|
2485
|
+
*/
|
|
2486
|
+
declare function extractMessageText(message: ExtendedUIMessage): string;
|
|
2487
|
+
/**
|
|
2488
|
+
* Check if message contains tool calls
|
|
2489
|
+
*/
|
|
2490
|
+
declare function hasToolCalls(message: ExtendedUIMessage): boolean;
|
|
2491
|
+
/**
|
|
2492
|
+
* Get tool calls list from message
|
|
2493
|
+
*/
|
|
2494
|
+
declare function getToolCalls(message: ExtendedUIMessage): Array<{
|
|
2495
|
+
toolName: string;
|
|
2496
|
+
state: string;
|
|
2497
|
+
input?: any;
|
|
2498
|
+
output?: any;
|
|
2499
|
+
}>;
|
|
2500
|
+
/**
|
|
2501
|
+
* Check if message contains file attachments
|
|
2502
|
+
*/
|
|
2503
|
+
declare function hasFileAttachments(message: ExtendedUIMessage): boolean;
|
|
2504
|
+
/**
|
|
2505
|
+
* Get file attachments list from message
|
|
2506
|
+
*/
|
|
2507
|
+
declare function getFileAttachments(message: ExtendedUIMessage): any[];
|
|
2508
|
+
/**
|
|
2509
|
+
* Format timestamp
|
|
2510
|
+
*/
|
|
2511
|
+
declare function formatTimestamp(timestamp?: number, options?: {
|
|
2512
|
+
format?: 'short' | 'long' | 'relative';
|
|
2513
|
+
includeDate?: boolean;
|
|
2514
|
+
}): string;
|
|
2515
|
+
/**
|
|
2516
|
+
* Format relative time
|
|
2517
|
+
*/
|
|
2518
|
+
declare function formatRelativeTime(timestamp: number): string;
|
|
2519
|
+
/**
|
|
2520
|
+
* Format file size
|
|
2521
|
+
*/
|
|
2522
|
+
declare function formatFileSize(bytes: number): string;
|
|
2523
|
+
/**
|
|
2524
|
+
* Get file extension
|
|
2525
|
+
*/
|
|
2526
|
+
declare function getFileExtension(filename: string): string;
|
|
2527
|
+
/**
|
|
2528
|
+
* Check if file type is accepted
|
|
2529
|
+
*/
|
|
2530
|
+
declare function isFileTypeAccepted(file: File, acceptedTypes: string[]): boolean;
|
|
2531
|
+
/**
|
|
2532
|
+
* Create file URL
|
|
2533
|
+
*/
|
|
2534
|
+
declare function createFileUrl(file: File): string;
|
|
2535
|
+
/**
|
|
2536
|
+
* Revoke file URL
|
|
2537
|
+
*/
|
|
2538
|
+
declare function revokeFileUrl(url: string): void;
|
|
2539
|
+
/**
|
|
2540
|
+
* Truncate text
|
|
2541
|
+
*/
|
|
2542
|
+
declare function truncateText(text: string, maxLength: number): string;
|
|
2543
|
+
/**
|
|
2544
|
+
* Highlight search terms
|
|
2545
|
+
*/
|
|
2546
|
+
declare function highlightSearchTerms(text: string, searchTerms: string[]): string;
|
|
2547
|
+
/**
|
|
2548
|
+
* Convert camelCase to space-separated
|
|
2549
|
+
*/
|
|
2550
|
+
declare function camelToSpaced(str: string): string;
|
|
2551
|
+
/**
|
|
2552
|
+
* Check if string is valid URL
|
|
2553
|
+
*/
|
|
2554
|
+
declare function isValidUrl(string: string): boolean;
|
|
2555
|
+
/**
|
|
2556
|
+
* Check if string is valid JSON
|
|
2557
|
+
*/
|
|
2558
|
+
declare function isValidJson(string: string): boolean;
|
|
2559
|
+
/**
|
|
2560
|
+
* Safe JSON parse
|
|
2561
|
+
*/
|
|
2562
|
+
declare function safeJsonParse<T>(string: string, fallback: T): T;
|
|
2563
|
+
/**
|
|
2564
|
+
* Combine CSS class names (simplified clsx)
|
|
2565
|
+
*/
|
|
2566
|
+
declare function cn(...classes: (string | undefined | null | false)[]): string;
|
|
2567
|
+
/**
|
|
2568
|
+
* Safely execute async function
|
|
2569
|
+
*/
|
|
2570
|
+
declare function safeAsync<T>(fn: () => Promise<T>, fallback?: T): Promise<{
|
|
2571
|
+
data?: T;
|
|
2572
|
+
error?: Error;
|
|
2573
|
+
}>;
|
|
2574
|
+
/**
|
|
2575
|
+
* Create error message
|
|
2576
|
+
*/
|
|
2577
|
+
declare function createErrorMessage(error: unknown): string;
|
|
2578
|
+
/**
|
|
2579
|
+
* Debounce function
|
|
2580
|
+
*/
|
|
2581
|
+
declare function debounce<T extends (...args: any[]) => any>(func: T, delay: number): (...args: Parameters<T>) => void;
|
|
2582
|
+
/**
|
|
2583
|
+
* Throttle function
|
|
2584
|
+
*/
|
|
2585
|
+
declare function throttle<T extends (...args: any[]) => any>(func: T, delay: number): (...args: Parameters<T>) => void;
|
|
2586
|
+
/**
|
|
2587
|
+
* Safe localStorage operations
|
|
2588
|
+
*/
|
|
2589
|
+
declare const storage: {
|
|
2590
|
+
get<T>(key: string, fallback?: T): T | null;
|
|
2591
|
+
set<T>(key: string, value: T): boolean;
|
|
2592
|
+
remove(key: string): boolean;
|
|
2593
|
+
clear(): boolean;
|
|
2594
|
+
};
|
|
2595
|
+
|
|
2596
|
+
/**
|
|
2597
|
+
* AI Core 完整配置类型
|
|
2598
|
+
*/
|
|
2599
|
+
interface AICoreConfig {
|
|
2600
|
+
providers?: {
|
|
2601
|
+
openai?: CustomProviderConfig;
|
|
2602
|
+
anthropic?: CustomProviderConfig;
|
|
2603
|
+
custom?: Record<string, CustomProviderConfig>;
|
|
2604
|
+
};
|
|
2605
|
+
settings?: {
|
|
2606
|
+
default?: ModelSettings;
|
|
2607
|
+
presets?: Record<string, SettingsPreset>;
|
|
2608
|
+
};
|
|
2609
|
+
features?: {
|
|
2610
|
+
embeddings?: boolean;
|
|
2611
|
+
tools?: boolean;
|
|
2612
|
+
structuredData?: boolean;
|
|
2613
|
+
healthChecking?: boolean;
|
|
2614
|
+
};
|
|
2615
|
+
monitoring?: {
|
|
2616
|
+
enabled?: boolean;
|
|
2617
|
+
metrics?: boolean;
|
|
2618
|
+
logging?: {
|
|
2619
|
+
level?: 'error' | 'warn' | 'info' | 'debug';
|
|
2620
|
+
destination?: 'console' | 'file' | 'custom';
|
|
2621
|
+
};
|
|
2622
|
+
};
|
|
2623
|
+
}
|
|
2624
|
+
/**
|
|
2625
|
+
* AI Core 实例接口
|
|
2626
|
+
*/
|
|
2627
|
+
interface AICoreInstance {
|
|
2628
|
+
aiSDK: AISDKIntegration;
|
|
2629
|
+
providerManagement: AIProviderManagement;
|
|
2630
|
+
toolsIntegration: AIToolsIntegration;
|
|
2631
|
+
embeddingsIntegration: AIEmbeddingsIntegration;
|
|
2632
|
+
settingsManagement: AISettingsManagement;
|
|
2633
|
+
structuredData: AIStructuredDataIntegration;
|
|
2634
|
+
isInitialized(): boolean;
|
|
2635
|
+
getStats(): AICoreStats;
|
|
2636
|
+
destroy(): Promise<void>;
|
|
2637
|
+
}
|
|
2638
|
+
/**
|
|
2639
|
+
* AI Core 统计信息
|
|
2640
|
+
*/
|
|
2641
|
+
interface AICoreStats {
|
|
2642
|
+
isInitialized: boolean;
|
|
2643
|
+
initializationTime?: number;
|
|
2644
|
+
components: {
|
|
2645
|
+
aiSDK: boolean;
|
|
2646
|
+
providerManagement: boolean;
|
|
2647
|
+
toolsIntegration: boolean;
|
|
2648
|
+
embeddingsIntegration: boolean;
|
|
2649
|
+
settingsManagement: boolean;
|
|
2650
|
+
structuredData: boolean;
|
|
2651
|
+
};
|
|
2652
|
+
usage: {
|
|
2653
|
+
totalRequests: number;
|
|
2654
|
+
totalTokens: number;
|
|
2655
|
+
averageLatency: number;
|
|
2656
|
+
errorRate: number;
|
|
2657
|
+
};
|
|
2658
|
+
providerHealth: {
|
|
2659
|
+
totalProviders: number;
|
|
2660
|
+
healthyProviders: number;
|
|
2661
|
+
unhealthyProviders: number;
|
|
2662
|
+
};
|
|
2663
|
+
}
|
|
2664
|
+
/**
|
|
2665
|
+
* 事件类型定义
|
|
2666
|
+
*/
|
|
2667
|
+
interface AICoreEvents {
|
|
2668
|
+
'core:initializing': {
|
|
2669
|
+
timestamp: Date;
|
|
2670
|
+
};
|
|
2671
|
+
'core:initialized': {
|
|
2672
|
+
timestamp: Date;
|
|
2673
|
+
duration: number;
|
|
2674
|
+
};
|
|
2675
|
+
'core:initialization_failed': {
|
|
2676
|
+
timestamp: Date;
|
|
2677
|
+
error: Error;
|
|
2678
|
+
};
|
|
2679
|
+
'component:ready': {
|
|
2680
|
+
component: string;
|
|
2681
|
+
timestamp: Date;
|
|
2682
|
+
};
|
|
2683
|
+
'component:error': {
|
|
2684
|
+
component: string;
|
|
2685
|
+
error: Error;
|
|
2686
|
+
timestamp: Date;
|
|
2687
|
+
};
|
|
2688
|
+
'request:started': {
|
|
2689
|
+
requestId: string;
|
|
2690
|
+
type: string;
|
|
2691
|
+
timestamp: Date;
|
|
2692
|
+
};
|
|
2693
|
+
'request:completed': {
|
|
2694
|
+
requestId: string;
|
|
2695
|
+
duration: number;
|
|
2696
|
+
tokens?: number;
|
|
2697
|
+
};
|
|
2698
|
+
'request:failed': {
|
|
2699
|
+
requestId: string;
|
|
2700
|
+
error: Error;
|
|
2701
|
+
duration: number;
|
|
2702
|
+
};
|
|
2703
|
+
'provider:health_changed': {
|
|
2704
|
+
providerId: string;
|
|
2705
|
+
isHealthy: boolean;
|
|
2706
|
+
};
|
|
2707
|
+
'provider:added': {
|
|
2708
|
+
providerId: string;
|
|
2709
|
+
type: string;
|
|
2710
|
+
};
|
|
2711
|
+
'provider:removed': {
|
|
2712
|
+
providerId: string;
|
|
2713
|
+
};
|
|
2714
|
+
}
|
|
2715
|
+
/**
|
|
2716
|
+
* 联合到交集类型
|
|
2717
|
+
*/
|
|
2718
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
2719
|
+
/**
|
|
2720
|
+
* 提取函数参数类型
|
|
2721
|
+
*/
|
|
2722
|
+
type ExtractParameters<T> = T extends (...args: infer P) => any ? P : never;
|
|
2723
|
+
/**
|
|
2724
|
+
* 提取函数返回类型
|
|
2725
|
+
*/
|
|
2726
|
+
type ExtractReturnType<T> = T extends (...args: any[]) => infer R ? R : never;
|
|
2727
|
+
/**
|
|
2728
|
+
* 可选的Promise
|
|
2729
|
+
*/
|
|
2730
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
2731
|
+
/**
|
|
2732
|
+
* 字符串字面量类型
|
|
2733
|
+
*/
|
|
2734
|
+
type Prettify<T> = {
|
|
2735
|
+
[K in keyof T]: T[K];
|
|
2736
|
+
} & {};
|
|
2737
|
+
/**
|
|
2738
|
+
* Version compatibility check
|
|
2739
|
+
*/
|
|
2740
|
+
interface VersionCompatibility {
|
|
2741
|
+
aiSDKVersion: string;
|
|
2742
|
+
entityEngineVersion: string;
|
|
2743
|
+
compatible: boolean;
|
|
2744
|
+
warnings?: string[];
|
|
2745
|
+
errors?: string[];
|
|
2746
|
+
}
|
|
2747
|
+
/**
|
|
2748
|
+
* 功能支持矩阵
|
|
2749
|
+
*/
|
|
2750
|
+
interface FeatureSupport {
|
|
2751
|
+
streamText: boolean;
|
|
2752
|
+
generateText: boolean;
|
|
2753
|
+
generateObject: boolean;
|
|
2754
|
+
streamObject: boolean;
|
|
2755
|
+
embeddings: boolean;
|
|
2756
|
+
tools: boolean;
|
|
2757
|
+
multiStep: boolean;
|
|
2758
|
+
customProviders: boolean;
|
|
2759
|
+
}
|
|
2760
|
+
|
|
2761
|
+
/**
|
|
2762
|
+
* Entity Engine AI Module - Type Definitions
|
|
2763
|
+
*
|
|
2764
|
+
* Consolidates all type definitions from Core and UI modules, providing unified type interface
|
|
2765
|
+
*/
|
|
2766
|
+
|
|
2767
|
+
/**
|
|
2768
|
+
* AI Module error type
|
|
2769
|
+
*/
|
|
2770
|
+
declare class aimoduleError extends Error {
|
|
2771
|
+
code: string;
|
|
2772
|
+
details?: any | undefined;
|
|
2773
|
+
constructor(message: string, code: string, details?: any | undefined);
|
|
2774
|
+
}
|
|
2775
|
+
/**
|
|
2776
|
+
* Runtime error
|
|
2777
|
+
*/
|
|
2778
|
+
declare class aimoduleRuntimeError extends aimoduleError {
|
|
2779
|
+
constructor(message: string, details?: any);
|
|
2780
|
+
}
|
|
2781
|
+
/**
|
|
2782
|
+
* Deep partial type
|
|
2783
|
+
*/
|
|
2784
|
+
type DeepPartial<T> = {
|
|
2785
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
2786
|
+
};
|
|
2787
|
+
/**
|
|
2788
|
+
* Required fields type
|
|
2789
|
+
*/
|
|
2790
|
+
type RequiredFields<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
2791
|
+
/**
|
|
2792
|
+
* Optional fields type
|
|
2793
|
+
*/
|
|
2794
|
+
type OptionalFields<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
2795
|
+
|
|
2796
|
+
declare class EntityAIModule implements IEntityModule {
|
|
2797
|
+
readonly info: {
|
|
2798
|
+
name: string;
|
|
2799
|
+
description: string;
|
|
2800
|
+
provider: string;
|
|
2801
|
+
version: string;
|
|
2802
|
+
url: string;
|
|
2803
|
+
dependencies: string[];
|
|
2804
|
+
};
|
|
2805
|
+
private static instance;
|
|
2806
|
+
coreManager: any;
|
|
2807
|
+
private streamManager;
|
|
2808
|
+
private apiHandlers;
|
|
2809
|
+
constructor();
|
|
2810
|
+
/**
|
|
2811
|
+
* 获取单例实例 - 用于servlet依赖注入
|
|
2812
|
+
*/
|
|
2813
|
+
static getInstance(): EntityAIModule | null;
|
|
2814
|
+
setupConfig(args: {
|
|
2815
|
+
models: IEntityModel[];
|
|
2816
|
+
views: IEntityView[];
|
|
2817
|
+
eventHandlers: any[];
|
|
2818
|
+
actionHandlers: any[];
|
|
2819
|
+
servlets: IEntityServlet[];
|
|
2820
|
+
}): Promise<void>;
|
|
2821
|
+
setupComponents(args: {
|
|
2822
|
+
views: EntityView[];
|
|
2823
|
+
renderers: IEntityNamedRenderer[];
|
|
2824
|
+
widgets: EntityWidget[];
|
|
2825
|
+
}): Promise<void>;
|
|
2826
|
+
setupData(args: {
|
|
2827
|
+
entities: ImportEntityData[];
|
|
2828
|
+
}): Promise<void>;
|
|
2829
|
+
private initializeAICore;
|
|
2830
|
+
/**
|
|
2831
|
+
* 加载环境变量 - 在模块构造时立即执行
|
|
2832
|
+
* 确保在所有AI服务初始化之前环境变量就已经可用
|
|
2833
|
+
*/
|
|
2834
|
+
private loadEnvironmentVariables;
|
|
2835
|
+
private adaptEntityRequestToAI;
|
|
2836
|
+
/**
|
|
2837
|
+
* 将Web API Response适配到Entity Engine响应格式
|
|
2838
|
+
*/
|
|
2839
|
+
private adaptWebResponseToEntity;
|
|
2840
|
+
private adaptAIResponseToEntity;
|
|
2841
|
+
}
|
|
2842
|
+
|
|
2843
|
+
declare function createEntityAIModule(): Promise<EntityAIModule>;
|
|
2844
|
+
declare const VERSION = "1.0.0";
|
|
2845
|
+
declare const PACKAGE_NAME = "@scenemesh/entity-engine-aimodule";
|
|
2846
|
+
declare const AI_SDK_COMPATIBLE_VERSION = "^5.0.10";
|
|
2847
|
+
/**
|
|
2848
|
+
* Create a complete AI core instance with optional configuration
|
|
2849
|
+
*/
|
|
2850
|
+
declare function createaimodule(config?: {
|
|
2851
|
+
providers?: CustomProviderConfig[];
|
|
2852
|
+
settings?: Partial<ModelSettings>;
|
|
2853
|
+
enableEmbeddings?: boolean;
|
|
2854
|
+
enableTools?: boolean;
|
|
2855
|
+
}): Promise<{
|
|
2856
|
+
core: {
|
|
2857
|
+
aiSDK: AISDKIntegration;
|
|
2858
|
+
providerManagement: AIProviderManagement;
|
|
2859
|
+
toolsIntegration: AIToolsIntegration;
|
|
2860
|
+
embeddingsIntegration: AIEmbeddingsIntegration;
|
|
2861
|
+
settingsManagement: AISettingsManagement;
|
|
2862
|
+
structuredData: AIStructuredDataIntegration;
|
|
2863
|
+
};
|
|
2864
|
+
api: {
|
|
2865
|
+
generateText: (options: GenerateTextOptions) => Promise<GenerateResult>;
|
|
2866
|
+
streamText: (options: StreamTextOptions) => StreamResult;
|
|
2867
|
+
generateObject: (options: GenerateObjectOptions<any>) => Promise<GenerateObjectResultType<any>>;
|
|
2868
|
+
streamObject: (options: StreamObjectOptions<any>) => StreamObjectResultType<any>;
|
|
2869
|
+
};
|
|
2870
|
+
}>;
|
|
2871
|
+
/**
|
|
2872
|
+
* 快速创建AI实例(仅核心功能)
|
|
2873
|
+
* Quick create AI instance (core only)
|
|
2874
|
+
*/
|
|
2875
|
+
declare function createQuickAI(providers?: CustomProviderConfig[]): Promise<{
|
|
2876
|
+
core: {
|
|
2877
|
+
aiSDK: AISDKIntegration;
|
|
2878
|
+
providerManagement: AIProviderManagement;
|
|
2879
|
+
toolsIntegration: AIToolsIntegration;
|
|
2880
|
+
embeddingsIntegration: AIEmbeddingsIntegration;
|
|
2881
|
+
settingsManagement: AISettingsManagement;
|
|
2882
|
+
structuredData: AIStructuredDataIntegration;
|
|
2883
|
+
};
|
|
2884
|
+
api: {
|
|
2885
|
+
generateText: (options: GenerateTextOptions) => Promise<GenerateResult>;
|
|
2886
|
+
streamText: (options: StreamTextOptions) => StreamResult;
|
|
2887
|
+
generateObject: (options: GenerateObjectOptions<any>) => Promise<GenerateObjectResultType<any>>;
|
|
2888
|
+
streamObject: (options: StreamObjectOptions<any>) => StreamObjectResultType<any>;
|
|
2889
|
+
};
|
|
2890
|
+
}>;
|
|
2891
|
+
/**
|
|
2892
|
+
* 向后兼容的默认导出包含所有主要功能
|
|
2893
|
+
* Backward compatible default export with all main functionality
|
|
2894
|
+
*/
|
|
2895
|
+
declare const EntityEngineAIModule: {
|
|
2896
|
+
create: typeof createaimodule;
|
|
2897
|
+
createQuick: typeof createQuickAI;
|
|
2898
|
+
VERSION: string;
|
|
2899
|
+
PACKAGE_NAME: string;
|
|
2900
|
+
AI_SDK_COMPATIBLE_VERSION: string;
|
|
2901
|
+
Core: {
|
|
2902
|
+
AIProviderManagement: Promise<typeof AIProviderManagement>;
|
|
2903
|
+
AISDKIntegration: Promise<typeof AISDKIntegration>;
|
|
2904
|
+
AIToolsIntegration: Promise<typeof AIToolsIntegration>;
|
|
2905
|
+
AIEmbeddingsIntegration: Promise<typeof AIEmbeddingsIntegration>;
|
|
2906
|
+
AISettingsManagement: Promise<typeof AISettingsManagement>;
|
|
2907
|
+
AIStructuredDataIntegration: Promise<typeof AIStructuredDataIntegration>;
|
|
2908
|
+
};
|
|
2909
|
+
};
|
|
2910
|
+
|
|
2911
|
+
export { type AICoreConfig, type AICoreEvents, type AICoreInstance, AICoreManager, type AICoreStats, AIEmbeddingsIntegration, AIProviderManagement, AISDKIntegration, AISettingsManagement, AIStructuredDataIntegration, AIToolsIntegration, AI_SDK_COMPATIBLE_VERSION, type AdvancedTool, BuiltinSettingsPresets, CORE_VERSION, type ChatDialogProps, type ChatEvents, type CommonModelSettings, type CustomDataParts, type CustomProviderConfig, type CustomTransportOptions, type CustomUIMessage, type DeepPartial, type DynamicSettingsConfig, type DynamicTool, type EmbedManyConfig, type EmbedManyOptions, type EmbedManyResult, type EmbedOptions, type EmbedResult, type EmbeddingModelConfig, type EmbeddingProviderInfo, EntityAIModule, EntityEngineAIModule, type ExtendedUIMessage, type ExtractParameters, type ExtractReturnType, type FeatureSupport, type FileViewerProps, type GenerateObjectOptions, type GenerateObjectResultType, type GenerateResult, type GenerateTextOptions, type GlobalProviderConfig, type IdGeneratorOptions, InMemoryMessageStore, LocalStorageMessageStore, type MCPClient, type MCPClientConfig, type MaybePromise, type MessageBubbleProps, type MessageRole, type MessageStatus, type MessageStore, type ModelAliasConfig, type ModelSettings, type ModelUsageStats, type OptionalFields, PACKAGE_NAME, type Prettify, type ProviderHealthStatus, type ProviderRegistryConfig, type ProviderSpecificSettings, type ReadUIMessageStreamOptions, type RequiredFields, type SettingsPreset, type SettingsValidationResult, type SimilarityResult, type StandardUIMessage, type StepResult, type StopCondition, type StreamObjectOptions, type StreamObjectResultType, type StreamResult, type StreamResumeOptions, type StreamState, StreamStateManager, type StreamTextOptions, type StyleVariants, SupportedEmbeddingModels, type ThemeConfig, type ToolCallOptions, type ToolCallState, type ToolChoice, type ToolDefinition, type ToolExecutionOptions, type ToolExecutionResult, TypeValidationError, UIMessageStreamReader, type UnionToIntersection, type UserInteractionToolOptions, VERSION, type ValidateUIMessagesOptions, type VersionCompatibility, type Warning, type WarningHandler, type WarningType, aimoduleError, aimoduleRuntimeError, camelToSpaced, clearWarnings, cn, createAICore, createEntityAIModule, createErrorMessage, createFileUrl, createIdGenerator, createQuickAI, createaimodule, debounce, extractMessageText, formatFileSize, formatRelativeTime, formatTimestamp, generateId, getFileAttachments, getFileExtension, getToolCalls, getWarningStats, getWarnings, hasFileAttachments, hasToolCalls, highlightSearchTerms, isFileTypeAccepted, isValidJson, isValidUrl, readUIMessageStream, resumeStream, revokeFileUrl, safeAsync, safeJsonParse, setWarningHandler, storage, throttle, truncateText, validateUIMessages, warn, warnDeprecatedFeature, warnPerformance, warnUnsupportedSetting, warnUnsupportedTool, warnValidationError };
|