outlet-orm 7.0.0 → 9.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/README.md +130 -2
- package/package.json +1 -1
- package/src/AI/AIPromptEnhancer.js +170 -0
- package/src/AI/AIQueryBuilder.js +234 -0
- package/src/AI/AIQueryOptimizer.js +185 -0
- package/src/AI/AISeeder.js +181 -0
- package/src/AI/AiBridgeManager.js +287 -0
- package/src/AI/Builders/TextBuilder.js +170 -0
- package/src/AI/Contracts/AudioProviderContract.js +29 -0
- package/src/AI/Contracts/ChatProviderContract.js +38 -0
- package/src/AI/Contracts/EmbeddingsProviderContract.js +19 -0
- package/src/AI/Contracts/ImageProviderContract.js +19 -0
- package/src/AI/Contracts/ModelsProviderContract.js +26 -0
- package/src/AI/Contracts/ToolContract.js +25 -0
- package/src/AI/Facades/AiBridge.js +79 -0
- package/src/AI/MCPServer.js +113 -0
- package/src/AI/Providers/ClaudeProvider.js +64 -0
- package/src/AI/Providers/CustomOpenAIProvider.js +238 -0
- package/src/AI/Providers/GeminiProvider.js +68 -0
- package/src/AI/Providers/GrokProvider.js +46 -0
- package/src/AI/Providers/MistralProvider.js +21 -0
- package/src/AI/Providers/OllamaProvider.js +249 -0
- package/src/AI/Providers/OllamaTurboProvider.js +32 -0
- package/src/AI/Providers/OnnProvider.js +46 -0
- package/src/AI/Providers/OpenAIProvider.js +471 -0
- package/src/AI/Support/AudioNormalizer.js +37 -0
- package/src/AI/Support/ChatNormalizer.js +42 -0
- package/src/AI/Support/Document.js +77 -0
- package/src/AI/Support/DocumentAttachmentMapper.js +101 -0
- package/src/AI/Support/EmbeddingsNormalizer.js +30 -0
- package/src/AI/Support/Exceptions/ProviderError.js +22 -0
- package/src/AI/Support/FileSecurity.js +56 -0
- package/src/AI/Support/ImageNormalizer.js +62 -0
- package/src/AI/Support/JsonSchemaValidator.js +73 -0
- package/src/AI/Support/Message.js +40 -0
- package/src/AI/Support/StreamChunk.js +45 -0
- package/src/AI/Support/ToolChatRunner.js +160 -0
- package/src/AI/Support/ToolRegistry.js +62 -0
- package/src/AI/Tools/SystemInfoTool.js +25 -0
- package/src/index.js +67 -1
- package/types/index.d.ts +326 -0
package/src/index.js
CHANGED
|
@@ -33,6 +33,39 @@ const MCPServer = require('./AI/MCPServer');
|
|
|
33
33
|
const AISafetyGuardrails = require('./AI/AISafetyGuardrails');
|
|
34
34
|
const PromptGenerator = require('./AI/PromptGenerator');
|
|
35
35
|
|
|
36
|
+
// AI Bridge (v8.0.0) — Multi-provider LLM abstraction
|
|
37
|
+
const AiBridgeManager = require('./AI/AiBridgeManager');
|
|
38
|
+
const AiBridgeFacade = require('./AI/Facades/AiBridge');
|
|
39
|
+
const TextBuilder = require('./AI/Builders/TextBuilder');
|
|
40
|
+
const ChatProviderContract = require('./AI/Contracts/ChatProviderContract');
|
|
41
|
+
const EmbeddingsProviderContract = require('./AI/Contracts/EmbeddingsProviderContract');
|
|
42
|
+
const ImageProviderContract = require('./AI/Contracts/ImageProviderContract');
|
|
43
|
+
const AudioProviderContract = require('./AI/Contracts/AudioProviderContract');
|
|
44
|
+
const ModelsProviderContract = require('./AI/Contracts/ModelsProviderContract');
|
|
45
|
+
const ToolContract = require('./AI/Contracts/ToolContract');
|
|
46
|
+
const OpenAIProvider = require('./AI/Providers/OpenAIProvider');
|
|
47
|
+
const OllamaProvider = require('./AI/Providers/OllamaProvider');
|
|
48
|
+
const OllamaTurboProvider = require('./AI/Providers/OllamaTurboProvider');
|
|
49
|
+
const ClaudeProvider = require('./AI/Providers/ClaudeProvider');
|
|
50
|
+
const GeminiProvider = require('./AI/Providers/GeminiProvider');
|
|
51
|
+
const GrokProvider = require('./AI/Providers/GrokProvider');
|
|
52
|
+
const MistralProvider = require('./AI/Providers/MistralProvider');
|
|
53
|
+
const OnnProvider = require('./AI/Providers/OnnProvider');
|
|
54
|
+
const CustomOpenAIProvider = require('./AI/Providers/CustomOpenAIProvider');
|
|
55
|
+
const StreamChunk = require('./AI/Support/StreamChunk');
|
|
56
|
+
const Message = require('./AI/Support/Message');
|
|
57
|
+
const Document = require('./AI/Support/Document');
|
|
58
|
+
const ProviderError = require('./AI/Support/Exceptions/ProviderError');
|
|
59
|
+
const ToolRegistry = require('./AI/Support/ToolRegistry');
|
|
60
|
+
const ToolChatRunner = require('./AI/Support/ToolChatRunner');
|
|
61
|
+
const SystemInfoTool = require('./AI/Tools/SystemInfoTool');
|
|
62
|
+
|
|
63
|
+
// AI ORM Features (v8.0.0) — NL→SQL, AI Seeding, Optimization
|
|
64
|
+
const AIQueryBuilder = require('./AI/AIQueryBuilder');
|
|
65
|
+
const AISeeder = require('./AI/AISeeder');
|
|
66
|
+
const AIQueryOptimizer = require('./AI/AIQueryOptimizer');
|
|
67
|
+
const AIPromptEnhancer = require('./AI/AIPromptEnhancer');
|
|
68
|
+
|
|
36
69
|
module.exports = {
|
|
37
70
|
// Core
|
|
38
71
|
Model,
|
|
@@ -75,5 +108,38 @@ module.exports = {
|
|
|
75
108
|
// AI (v7.0.0)
|
|
76
109
|
MCPServer,
|
|
77
110
|
AISafetyGuardrails,
|
|
78
|
-
PromptGenerator
|
|
111
|
+
PromptGenerator,
|
|
112
|
+
|
|
113
|
+
// AI Bridge (v8.0.0)
|
|
114
|
+
AiBridgeManager,
|
|
115
|
+
AiBridgeFacade,
|
|
116
|
+
TextBuilder,
|
|
117
|
+
ChatProviderContract,
|
|
118
|
+
EmbeddingsProviderContract,
|
|
119
|
+
ImageProviderContract,
|
|
120
|
+
AudioProviderContract,
|
|
121
|
+
ModelsProviderContract,
|
|
122
|
+
ToolContract,
|
|
123
|
+
OpenAIProvider,
|
|
124
|
+
OllamaProvider,
|
|
125
|
+
OllamaTurboProvider,
|
|
126
|
+
ClaudeProvider,
|
|
127
|
+
GeminiProvider,
|
|
128
|
+
GrokProvider,
|
|
129
|
+
MistralProvider,
|
|
130
|
+
OnnProvider,
|
|
131
|
+
CustomOpenAIProvider,
|
|
132
|
+
StreamChunk,
|
|
133
|
+
Message,
|
|
134
|
+
Document,
|
|
135
|
+
ProviderError,
|
|
136
|
+
ToolRegistry,
|
|
137
|
+
ToolChatRunner,
|
|
138
|
+
SystemInfoTool,
|
|
139
|
+
|
|
140
|
+
// AI ORM Features (v8.0.0)
|
|
141
|
+
AIQueryBuilder,
|
|
142
|
+
AISeeder,
|
|
143
|
+
AIQueryOptimizer,
|
|
144
|
+
AIPromptEnhancer
|
|
79
145
|
};
|
package/types/index.d.ts
CHANGED
|
@@ -1043,4 +1043,330 @@ declare module 'outlet-orm' {
|
|
|
1043
1043
|
/** Generate a seeder file from a blueprint */
|
|
1044
1044
|
static generateSeeder(blueprint: PromptBlueprint, outputDir: string): string;
|
|
1045
1045
|
}
|
|
1046
|
+
|
|
1047
|
+
// ==================== AI Bridge (v8.0.0) ====================
|
|
1048
|
+
|
|
1049
|
+
/** Normalized chat response */
|
|
1050
|
+
export interface ChatResponse {
|
|
1051
|
+
output_text?: string;
|
|
1052
|
+
choices?: Array<{ message: { content: string; tool_calls?: any[] }; finish_reason?: string }>;
|
|
1053
|
+
content?: Array<{ text: string }>;
|
|
1054
|
+
message?: { content: string };
|
|
1055
|
+
usage?: { prompt_tokens?: number; completion_tokens?: number; total_tokens?: number };
|
|
1056
|
+
[key: string]: any;
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
/** Streaming chunk value object */
|
|
1060
|
+
export class StreamChunk {
|
|
1061
|
+
text: string;
|
|
1062
|
+
usage: Record<string, any> | null;
|
|
1063
|
+
finishReason: string | null;
|
|
1064
|
+
chunkType: 'delta' | 'end' | 'tool_call' | 'tool_result';
|
|
1065
|
+
toolCalls: any[] | null;
|
|
1066
|
+
toolResults: any[] | null;
|
|
1067
|
+
static delta(text: string, extra?: Partial<StreamChunk>): StreamChunk;
|
|
1068
|
+
static end(usage?: Record<string, any>, finishReason?: string): StreamChunk;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
/** Message value object */
|
|
1072
|
+
export class Message {
|
|
1073
|
+
role: string;
|
|
1074
|
+
content: string;
|
|
1075
|
+
static user(content: string): Message;
|
|
1076
|
+
static system(content: string): Message;
|
|
1077
|
+
static assistant(content: string): Message;
|
|
1078
|
+
toJSON(): { role: string; content: string };
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
/** Document attachment */
|
|
1082
|
+
export class Document {
|
|
1083
|
+
kind: string;
|
|
1084
|
+
data: any;
|
|
1085
|
+
meta: Record<string, any>;
|
|
1086
|
+
static local(filePath: string, meta?: Record<string, any>): Document;
|
|
1087
|
+
static base64(data: string, mimeType: string): Document;
|
|
1088
|
+
static url(url: string): Document;
|
|
1089
|
+
static text(text: string): Document;
|
|
1090
|
+
static raw(data: any): Document;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
/** Provider error */
|
|
1094
|
+
export class ProviderError extends Error {
|
|
1095
|
+
statusCode: number | null;
|
|
1096
|
+
providerName: string;
|
|
1097
|
+
static notFound(name: string): ProviderError;
|
|
1098
|
+
static unsupported(provider: string, capability: string): ProviderError;
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
/** Chat provider base contract */
|
|
1102
|
+
export abstract class ChatProviderContract {
|
|
1103
|
+
chat(messages: Array<{ role: string; content: string }>, options?: Record<string, any>): Promise<ChatResponse>;
|
|
1104
|
+
stream(messages: Array<{ role: string; content: string }>, options?: Record<string, any>): AsyncGenerator<StreamChunk>;
|
|
1105
|
+
supportsStreaming(): boolean;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
/** Embeddings provider base contract */
|
|
1109
|
+
export abstract class EmbeddingsProviderContract {
|
|
1110
|
+
embeddings(inputs: string | string[], options?: Record<string, any>): Promise<number[][]>;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
/** Image provider base contract */
|
|
1114
|
+
export abstract class ImageProviderContract {
|
|
1115
|
+
generateImage(prompt: string, options?: Record<string, any>): Promise<{ url?: string; b64_json?: string }[]>;
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
/** Audio provider base contract */
|
|
1119
|
+
export abstract class AudioProviderContract {
|
|
1120
|
+
textToSpeech(text: string, options?: Record<string, any>): Promise<{ b64: string; mime: string }>;
|
|
1121
|
+
speechToText(audioSource: string | Buffer, options?: Record<string, any>): Promise<{ text: string }>;
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
/** Models provider base contract */
|
|
1125
|
+
export abstract class ModelsProviderContract {
|
|
1126
|
+
listModels(): Promise<any[]>;
|
|
1127
|
+
getModel(modelId: string): Promise<any>;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
/** Tool contract for function calling */
|
|
1131
|
+
export abstract class ToolContract {
|
|
1132
|
+
name(): string;
|
|
1133
|
+
description(): string;
|
|
1134
|
+
schema(): Record<string, any>;
|
|
1135
|
+
execute(args: Record<string, any>): Promise<any>;
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
/** Built-in system info tool */
|
|
1139
|
+
export class SystemInfoTool extends ToolContract {
|
|
1140
|
+
name(): string;
|
|
1141
|
+
description(): string;
|
|
1142
|
+
schema(): Record<string, any>;
|
|
1143
|
+
execute(): Promise<{ node_version: string; platform: string; arch: string; uptime: number }>;
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
/** Tool registry */
|
|
1147
|
+
export class ToolRegistry {
|
|
1148
|
+
register(tool: ToolContract): void;
|
|
1149
|
+
get(name: string): ToolContract | undefined;
|
|
1150
|
+
has(name: string): boolean;
|
|
1151
|
+
all(): ToolContract[];
|
|
1152
|
+
readonly size: number;
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
/** Tool chat runner — executes tool loops */
|
|
1156
|
+
export class ToolChatRunner {
|
|
1157
|
+
constructor(manager: AiBridgeManager, registry: ToolRegistry);
|
|
1158
|
+
run(provider: string, messages: Array<{ role: string; content: string }>, options?: { maxToolIterations?: number; model?: string }): Promise<ChatResponse>;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
/** OpenAI provider options */
|
|
1162
|
+
export interface OpenAIProviderConfig {
|
|
1163
|
+
api_key: string;
|
|
1164
|
+
model?: string;
|
|
1165
|
+
endpoint?: string;
|
|
1166
|
+
responses_endpoint?: string;
|
|
1167
|
+
embeddings_endpoint?: string;
|
|
1168
|
+
images_endpoint?: string;
|
|
1169
|
+
audio_tts_endpoint?: string;
|
|
1170
|
+
audio_stt_endpoint?: string;
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
export class OpenAIProvider extends ChatProviderContract {
|
|
1174
|
+
constructor(config: OpenAIProviderConfig);
|
|
1175
|
+
chat(messages: Array<{ role: string; content: string }>, options?: Record<string, any>): Promise<ChatResponse>;
|
|
1176
|
+
stream(messages: Array<{ role: string; content: string }>, options?: Record<string, any>): AsyncGenerator<StreamChunk>;
|
|
1177
|
+
embeddings(inputs: string | string[], options?: Record<string, any>): Promise<number[][]>;
|
|
1178
|
+
generateImage(prompt: string, options?: Record<string, any>): Promise<any[]>;
|
|
1179
|
+
textToSpeech(text: string, options?: Record<string, any>): Promise<{ b64: string; mime: string }>;
|
|
1180
|
+
speechToText(audioSource: string | Buffer, options?: Record<string, any>): Promise<{ text: string }>;
|
|
1181
|
+
listModels(): Promise<any[]>;
|
|
1182
|
+
getModel(modelId: string): Promise<any>;
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
export class OllamaProvider extends ChatProviderContract {
|
|
1186
|
+
constructor(config: { endpoint?: string; model?: string });
|
|
1187
|
+
chat(messages: Array<{ role: string; content: string }>, options?: Record<string, any>): Promise<ChatResponse>;
|
|
1188
|
+
stream(messages: Array<{ role: string; content: string }>, options?: Record<string, any>): AsyncGenerator<StreamChunk>;
|
|
1189
|
+
embeddings(inputs: string | string[], options?: Record<string, any>): Promise<number[][]>;
|
|
1190
|
+
generateImage(prompt: string, options?: Record<string, any>): Promise<any[]>;
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
export class OllamaTurboProvider extends OllamaProvider {
|
|
1194
|
+
constructor(config: { api_key: string; endpoint?: string; model?: string });
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
export class ClaudeProvider extends ChatProviderContract {
|
|
1198
|
+
constructor(config: { api_key: string; model?: string; endpoint?: string });
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
export class GeminiProvider extends ChatProviderContract {
|
|
1202
|
+
constructor(config: { api_key: string; model?: string; endpoint?: string });
|
|
1203
|
+
embeddings(inputs: string | string[], options?: Record<string, any>): Promise<number[][]>;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
export class GrokProvider extends ChatProviderContract {
|
|
1207
|
+
constructor(config: { api_key: string; model?: string; endpoint?: string });
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
export class MistralProvider extends OpenAIProvider {
|
|
1211
|
+
constructor(config: { api_key: string; model?: string });
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
export class OnnProvider extends ChatProviderContract {
|
|
1215
|
+
constructor(config: { api_key: string; model?: string; endpoint?: string });
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
export interface CustomOpenAIProviderConfig {
|
|
1219
|
+
api_key: string;
|
|
1220
|
+
base_url: string;
|
|
1221
|
+
model?: string;
|
|
1222
|
+
auth_header?: string;
|
|
1223
|
+
auth_prefix?: string;
|
|
1224
|
+
extra_headers?: Record<string, string>;
|
|
1225
|
+
paths?: {
|
|
1226
|
+
chat?: string;
|
|
1227
|
+
embeddings?: string;
|
|
1228
|
+
models?: string;
|
|
1229
|
+
images?: string;
|
|
1230
|
+
audio_tts?: string;
|
|
1231
|
+
audio_stt?: string;
|
|
1232
|
+
};
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
export class CustomOpenAIProvider extends ChatProviderContract {
|
|
1236
|
+
constructor(config: CustomOpenAIProviderConfig);
|
|
1237
|
+
chat(messages: Array<{ role: string; content: string }>, options?: Record<string, any>): Promise<ChatResponse>;
|
|
1238
|
+
stream(messages: Array<{ role: string; content: string }>, options?: Record<string, any>): AsyncGenerator<StreamChunk>;
|
|
1239
|
+
embeddings(inputs: string | string[], options?: Record<string, any>): Promise<number[][]>;
|
|
1240
|
+
generateImage(prompt: string, options?: Record<string, any>): Promise<any[]>;
|
|
1241
|
+
textToSpeech(text: string, options?: Record<string, any>): Promise<{ b64: string; mime: string }>;
|
|
1242
|
+
speechToText(audioSource: string | Buffer, options?: Record<string, any>): Promise<{ text: string }>;
|
|
1243
|
+
listModels(): Promise<any[]>;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
/** AiBridge manager configuration */
|
|
1247
|
+
export interface AiBridgeConfig {
|
|
1248
|
+
default?: string;
|
|
1249
|
+
openai?: OpenAIProviderConfig;
|
|
1250
|
+
ollama?: { endpoint?: string; model?: string };
|
|
1251
|
+
ollama_turbo?: { api_key: string; endpoint?: string; model?: string };
|
|
1252
|
+
claude?: { api_key: string; model?: string; endpoint?: string };
|
|
1253
|
+
gemini?: { api_key: string; model?: string; endpoint?: string };
|
|
1254
|
+
grok?: { api_key: string; model?: string; endpoint?: string };
|
|
1255
|
+
mistral?: { api_key: string; model?: string };
|
|
1256
|
+
onn?: { api_key: string; model?: string; endpoint?: string };
|
|
1257
|
+
openai_custom?: CustomOpenAIProviderConfig;
|
|
1258
|
+
openrouter?: { api_key: string; base_url?: string; model?: string };
|
|
1259
|
+
[key: string]: any;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
/** TextBuilder — fluent API for building AI requests */
|
|
1263
|
+
export class TextBuilder {
|
|
1264
|
+
constructor(manager: AiBridgeManager);
|
|
1265
|
+
using(provider: string, model?: string): this;
|
|
1266
|
+
withPrompt(text: string, attachments?: Document[]): this;
|
|
1267
|
+
withSystemPrompt(text: string): this;
|
|
1268
|
+
withMaxTokens(n: number): this;
|
|
1269
|
+
usingTemperature(t: number): this;
|
|
1270
|
+
usingTopP(p: number): this;
|
|
1271
|
+
withApiKey(key: string): this;
|
|
1272
|
+
withEndpoint(url: string): this;
|
|
1273
|
+
withBaseUrl(url: string): this;
|
|
1274
|
+
withChatEndpoint(url: string): this;
|
|
1275
|
+
withAuthHeader(header: string): this;
|
|
1276
|
+
withExtraHeaders(headers: Record<string, string>): this;
|
|
1277
|
+
withPaths(paths: Record<string, string>): this;
|
|
1278
|
+
asText(): Promise<string>;
|
|
1279
|
+
asRaw(): Promise<ChatResponse>;
|
|
1280
|
+
asStream(): AsyncGenerator<StreamChunk>;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
/** AiBridge Manager — central orchestrator for multi-provider AI */
|
|
1284
|
+
export class AiBridgeManager {
|
|
1285
|
+
constructor(config?: AiBridgeConfig);
|
|
1286
|
+
provider(name: string): ChatProviderContract;
|
|
1287
|
+
registerProvider(name: string, provider: ChatProviderContract): void;
|
|
1288
|
+
chat(provider: string, messages: Array<{ role: string; content: string }>, options?: Record<string, any>): Promise<ChatResponse>;
|
|
1289
|
+
stream(provider: string, messages: Array<{ role: string; content: string }>, options?: Record<string, any>): AsyncGenerator<StreamChunk>;
|
|
1290
|
+
streamEvents(provider: string, messages: Array<{ role: string; content: string }>, options?: Record<string, any>): AsyncGenerator<StreamChunk>;
|
|
1291
|
+
embeddings(provider: string, inputs: string | string[], options?: Record<string, any>): Promise<number[][]>;
|
|
1292
|
+
models(provider: string): Promise<any[]>;
|
|
1293
|
+
model(provider: string, modelId: string): Promise<any>;
|
|
1294
|
+
image(provider: string, prompt: string, options?: Record<string, any>): Promise<any[]>;
|
|
1295
|
+
tts(provider: string, text: string, options?: Record<string, any>): Promise<{ b64: string; mime: string }>;
|
|
1296
|
+
stt(provider: string, audioSource: string | Buffer, options?: Record<string, any>): Promise<{ text: string }>;
|
|
1297
|
+
text(): TextBuilder;
|
|
1298
|
+
registerTool(tool: ToolContract): void;
|
|
1299
|
+
tool(name: string): ToolContract | undefined;
|
|
1300
|
+
tools(): ToolContract[];
|
|
1301
|
+
chatWithTools(provider: string, messages: Array<{ role: string; content: string }>, options?: Record<string, any>): Promise<ChatResponse>;
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
// ==================== AI ORM Features (v8.0.0) ====================
|
|
1305
|
+
|
|
1306
|
+
/** NL→SQL query result */
|
|
1307
|
+
export interface AIQueryResult {
|
|
1308
|
+
sql: string;
|
|
1309
|
+
params: any[];
|
|
1310
|
+
results: any[];
|
|
1311
|
+
explanation: string;
|
|
1312
|
+
error?: string;
|
|
1313
|
+
raw_response: ChatResponse;
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
/** AIQueryBuilder — natural language to SQL conversion */
|
|
1317
|
+
export class AIQueryBuilder {
|
|
1318
|
+
constructor(manager: AiBridgeManager, connection: DatabaseConnection);
|
|
1319
|
+
using(provider: string, model: string): this;
|
|
1320
|
+
safeMode(safe: boolean): this;
|
|
1321
|
+
query(question: string, options?: { model?: string; max_tokens?: number; temperature?: number }): Promise<AIQueryResult>;
|
|
1322
|
+
toSql(question: string, options?: Record<string, any>): Promise<{ sql: string; params: any[]; explanation: string }>;
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
/** AI seed result */
|
|
1326
|
+
export interface AISeedResult {
|
|
1327
|
+
records: Record<string, any>[];
|
|
1328
|
+
inserted: number;
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
/** AISeeder — AI-powered data seeding */
|
|
1332
|
+
export class AISeeder {
|
|
1333
|
+
constructor(manager: AiBridgeManager, connection: DatabaseConnection);
|
|
1334
|
+
using(provider: string, model: string): this;
|
|
1335
|
+
seed(table: string, count?: number, context?: { description?: string; locale?: string; domain?: string }): Promise<AISeedResult>;
|
|
1336
|
+
generate(table: string, count?: number, context?: { description?: string; locale?: string; domain?: string }): Promise<Record<string, any>[]>;
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
/** Query optimization result */
|
|
1340
|
+
export interface OptimizationResult {
|
|
1341
|
+
original: string;
|
|
1342
|
+
optimized: string;
|
|
1343
|
+
suggestions: Array<{ type: string; description: string; impact: 'high' | 'medium' | 'low' }>;
|
|
1344
|
+
explanation: string;
|
|
1345
|
+
indexes: string[];
|
|
1346
|
+
raw_response: ChatResponse;
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
/** AIQueryOptimizer — AI-powered SQL query optimization */
|
|
1350
|
+
export class AIQueryOptimizer {
|
|
1351
|
+
constructor(manager: AiBridgeManager, connection?: DatabaseConnection);
|
|
1352
|
+
using(provider: string, model: string): this;
|
|
1353
|
+
optimize(sql: string, options?: { schema?: string; dialect?: string; model?: string }): Promise<OptimizationResult>;
|
|
1354
|
+
explain(sql: string): Promise<{ plan: any[]; analysis: string }>;
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
/** AI-generated schema */
|
|
1358
|
+
export interface AISchema {
|
|
1359
|
+
tables: Record<string, { columns: string[] }>;
|
|
1360
|
+
relations: Array<{ type: string; from: string; to: string; pivot?: string }>;
|
|
1361
|
+
seedHints: Record<string, string>;
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
/** AIPromptEnhancer — LLM-powered schema/code generation */
|
|
1365
|
+
export class AIPromptEnhancer {
|
|
1366
|
+
constructor(manager: AiBridgeManager);
|
|
1367
|
+
using(provider: string, model: string): this;
|
|
1368
|
+
generateSchema(description: string, options?: { model?: string }): Promise<AISchema>;
|
|
1369
|
+
generateModelCode(tableName: string, tableSchema: { columns: string[] }, relations?: any[]): Promise<string>;
|
|
1370
|
+
generateMigrationCode(tableName: string, tableSchema: { columns: string[] }): Promise<string>;
|
|
1371
|
+
}
|
|
1046
1372
|
}
|