@qozara/ai-client 1.0.1 → 1.2.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/dist/index.d.ts +130 -6
- package/dist/index.js +508 -51
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
type GenAiProviderPreference = 'auto' | 'cloud' | 'byok' | 'local-browser' | 'local' | 'disabled';
|
|
2
|
+
type LegacyAiProviderPreference = 'qozara-intelligence' | 'ollama' | 'window.ai';
|
|
1
3
|
interface AgentChatMessage {
|
|
2
4
|
role: string;
|
|
3
5
|
content: string;
|
|
@@ -18,6 +20,9 @@ interface AgentChatResponse {
|
|
|
18
20
|
tool?: string;
|
|
19
21
|
arguments?: any;
|
|
20
22
|
error?: string;
|
|
23
|
+
errorCode?: string;
|
|
24
|
+
errorMessage?: string;
|
|
25
|
+
status?: number;
|
|
21
26
|
}
|
|
22
27
|
interface AiProvider {
|
|
23
28
|
readonly id: string;
|
|
@@ -27,7 +32,7 @@ interface AiProvider {
|
|
|
27
32
|
getSetupMessage(): string | null;
|
|
28
33
|
}
|
|
29
34
|
interface AiFactoryConfig {
|
|
30
|
-
providerPreference:
|
|
35
|
+
providerPreference: GenAiProviderPreference | LegacyAiProviderPreference;
|
|
31
36
|
encryptedApiKey?: string;
|
|
32
37
|
baseUrl?: string;
|
|
33
38
|
proxyUrl?: string;
|
|
@@ -36,15 +41,18 @@ interface AiFactoryConfig {
|
|
|
36
41
|
enableLocalAi?: boolean;
|
|
37
42
|
}
|
|
38
43
|
type AuthTokenGetter = () => string | null | undefined | Promise<string | null | undefined>;
|
|
44
|
+
type AuthTokenRefresher = () => string | null | undefined | Promise<string | null | undefined>;
|
|
39
45
|
|
|
40
46
|
declare class ProxyAiProvider implements AiProvider {
|
|
41
47
|
private getAuthToken?;
|
|
42
48
|
private encryptedApiKey?;
|
|
43
49
|
private byokProvider?;
|
|
50
|
+
private onAuthExpired?;
|
|
44
51
|
readonly id = "cloud-proxy";
|
|
45
52
|
private base;
|
|
46
53
|
get mode(): 'byok' | 'cloud';
|
|
47
|
-
constructor(proxyUrl?: string, getAuthToken?: AuthTokenGetter | undefined, encryptedApiKey?: string | undefined, byokProvider?: string | undefined);
|
|
54
|
+
constructor(proxyUrl?: string, getAuthToken?: AuthTokenGetter | undefined, encryptedApiKey?: string | undefined, byokProvider?: string | undefined, onAuthExpired?: AuthTokenRefresher | undefined);
|
|
55
|
+
private sendChatRequest;
|
|
48
56
|
chat(request: AgentChatRequest): Promise<AgentChatResponse>;
|
|
49
57
|
checkAvailability(): Promise<boolean>;
|
|
50
58
|
getSetupMessage(): string | null;
|
|
@@ -78,10 +86,10 @@ declare class DisabledAiProvider implements AiProvider {
|
|
|
78
86
|
error: string;
|
|
79
87
|
}>;
|
|
80
88
|
checkAvailability(): Promise<boolean>;
|
|
81
|
-
getSetupMessage():
|
|
89
|
+
getSetupMessage(): string;
|
|
82
90
|
}
|
|
83
91
|
declare class AiProviderFactory {
|
|
84
|
-
static createProvider(config: AiFactoryConfig, getAuthToken?: AuthTokenGetter): Promise<AiProvider>;
|
|
92
|
+
static createProvider(config: AiFactoryConfig, getAuthToken?: AuthTokenGetter, onAuthExpired?: AuthTokenRefresher): Promise<AiProvider>;
|
|
85
93
|
static getSetupMessage(providerId: string, config?: Partial<AiFactoryConfig>): string | null;
|
|
86
94
|
}
|
|
87
95
|
|
|
@@ -91,8 +99,9 @@ interface AgentClientChatOptions extends AgentChatRequest {
|
|
|
91
99
|
}
|
|
92
100
|
declare class AgentClient {
|
|
93
101
|
private getAuthToken?;
|
|
102
|
+
private onAuthExpired?;
|
|
94
103
|
private base;
|
|
95
|
-
constructor(baseUrl?: string, getAuthToken?: AuthTokenGetter | undefined);
|
|
104
|
+
constructor(baseUrl?: string, getAuthToken?: AuthTokenGetter | undefined, onAuthExpired?: AuthTokenRefresher | undefined);
|
|
96
105
|
/**
|
|
97
106
|
* Encrypts a personal API key using the edge proxy's KMS_SECRET.
|
|
98
107
|
* Works completely unauthenticated (zero login required).
|
|
@@ -105,4 +114,119 @@ declare class AgentClient {
|
|
|
105
114
|
chat(request: AgentClientChatOptions): Promise<AgentChatResponse>;
|
|
106
115
|
}
|
|
107
116
|
|
|
108
|
-
|
|
117
|
+
declare class LruMemoryCache<K, V> {
|
|
118
|
+
readonly capacity: number;
|
|
119
|
+
private readonly map;
|
|
120
|
+
constructor(capacity?: number);
|
|
121
|
+
get(key: K): V | undefined;
|
|
122
|
+
set(key: K, value: V): void;
|
|
123
|
+
has(key: K): boolean;
|
|
124
|
+
clear(): void;
|
|
125
|
+
get size(): number;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
type AiErrorCode = 'RATE_LIMIT_EXCEEDED' | 'AI_DISABLED' | 'NO_ITEMS_PARSED' | 'NETWORK_ERROR' | 'FORBIDDEN_NOT_REGISTERED' | 'AUTHENTICATION_REQUIRED' | 'PARSE_FAILED';
|
|
129
|
+
declare class AiError extends Error {
|
|
130
|
+
readonly code: AiErrorCode;
|
|
131
|
+
readonly cause?: unknown;
|
|
132
|
+
constructor(code: AiErrorCode, message: string, cause?: unknown);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
declare function classifyAiError(err: unknown): AiError;
|
|
136
|
+
|
|
137
|
+
interface UserAiSettings {
|
|
138
|
+
providerPreference: GenAiProviderPreference;
|
|
139
|
+
enableLocalAi?: boolean;
|
|
140
|
+
encryptedApiKey?: string;
|
|
141
|
+
byokProvider?: string;
|
|
142
|
+
ollamaBaseUrl?: string;
|
|
143
|
+
ollamaModel?: string;
|
|
144
|
+
}
|
|
145
|
+
declare const DEFAULT_USER_AI_SETTINGS: UserAiSettings;
|
|
146
|
+
declare function normalizeProviderPreference(provider?: string | null, enabled?: boolean): GenAiProviderPreference;
|
|
147
|
+
declare function isGenAiEnabled(settings?: {
|
|
148
|
+
providerPreference?: string | null;
|
|
149
|
+
provider?: string | null;
|
|
150
|
+
enabled?: boolean;
|
|
151
|
+
} | null): boolean;
|
|
152
|
+
|
|
153
|
+
declare class AiKeyEncryptionService {
|
|
154
|
+
/**
|
|
155
|
+
* Encrypts a user's personal provider API key using the edge KMS proxy.
|
|
156
|
+
* Returns a secure ciphertext string to store safely in local or cloud storage.
|
|
157
|
+
*/
|
|
158
|
+
static encryptApiKey(rawApiKey: string, proxyUrl: string, getAuthToken?: AuthTokenGetter): Promise<string>;
|
|
159
|
+
}
|
|
160
|
+
interface ValidateAndPrepareAiSettingsOptions {
|
|
161
|
+
providerPreference: GenAiProviderPreference | LegacyAiProviderPreference | string;
|
|
162
|
+
enableLocalAi?: boolean;
|
|
163
|
+
rawApiKey?: string;
|
|
164
|
+
existingEncryptedApiKey?: string;
|
|
165
|
+
byokProvider?: string;
|
|
166
|
+
ollamaBaseUrl?: string;
|
|
167
|
+
ollamaModel?: string;
|
|
168
|
+
proxyUrl?: string;
|
|
169
|
+
getAuthToken?: AuthTokenGetter;
|
|
170
|
+
probeAvailability?: boolean;
|
|
171
|
+
}
|
|
172
|
+
interface PreparedAiSettingsResult {
|
|
173
|
+
settings: UserAiSettings;
|
|
174
|
+
isReachable: boolean;
|
|
175
|
+
setupMessage: string | null;
|
|
176
|
+
}
|
|
177
|
+
declare function validateAndPrepareAiSettings(options: ValidateAndPrepareAiSettingsOptions): Promise<PreparedAiSettingsResult>;
|
|
178
|
+
|
|
179
|
+
interface ExtractedToolCall<TArgs = Record<string, any>> {
|
|
180
|
+
toolName?: string;
|
|
181
|
+
args: TArgs;
|
|
182
|
+
}
|
|
183
|
+
declare function extractToolCallData<TArgs = Record<string, any>>(response: unknown): ExtractedToolCall<TArgs> | null;
|
|
184
|
+
|
|
185
|
+
interface GenAiToolResolverConfig<TInput, TOutput, TArgs = Record<string, any>> {
|
|
186
|
+
factoryConfig: AiFactoryConfig | ((input: TInput) => AiFactoryConfig | Promise<AiFactoryConfig>);
|
|
187
|
+
getAuthToken?: AuthTokenGetter;
|
|
188
|
+
onAuthExpired?: AuthTokenRefresher;
|
|
189
|
+
cache?: LruMemoryCache<string, TOutput> | null;
|
|
190
|
+
cacheCapacity?: number;
|
|
191
|
+
getCacheKey?: (input: TInput) => string | null;
|
|
192
|
+
buildRequest: (input: TInput) => AgentChatRequest | Promise<AgentChatRequest>;
|
|
193
|
+
parseResponse: (extracted: ExtractedToolCall<TArgs> | null, rawResponse: AgentChatResponse, input: TInput) => TOutput | null | Promise<TOutput | null>;
|
|
194
|
+
}
|
|
195
|
+
declare class GenAiToolResolver<TInput, TOutput, TArgs = Record<string, any>> {
|
|
196
|
+
private readonly config;
|
|
197
|
+
readonly kind: "genai";
|
|
198
|
+
private readonly cache;
|
|
199
|
+
constructor(config: GenAiToolResolverConfig<TInput, TOutput, TArgs>);
|
|
200
|
+
clearCache(): void;
|
|
201
|
+
resolve(input: TInput): Promise<TOutput | null>;
|
|
202
|
+
}
|
|
203
|
+
declare function createGenAiToolResolver<TInput, TOutput, TArgs = Record<string, any>>(config: GenAiToolResolverConfig<TInput, TOutput, TArgs>): GenAiToolResolver<TInput, TOutput, TArgs>;
|
|
204
|
+
|
|
205
|
+
type AiResolutionSource = 'symbolic' | 'composite' | 'symbolic-fallback';
|
|
206
|
+
interface AiResolutionResult<TOutput> {
|
|
207
|
+
output: TOutput;
|
|
208
|
+
source: AiResolutionSource;
|
|
209
|
+
}
|
|
210
|
+
interface IAiResolver<TInput, TOutput, TContext = void> {
|
|
211
|
+
readonly id: string;
|
|
212
|
+
readonly kind: 'symbolic' | 'genai' | 'composite';
|
|
213
|
+
resolve(input: TInput, context: TContext): Promise<TOutput>;
|
|
214
|
+
}
|
|
215
|
+
interface CompositeAiResolverConfig<TInput, TOutput, TContext = void> {
|
|
216
|
+
id?: string;
|
|
217
|
+
symbolicResolve: (input: TInput, context: TContext) => TOutput | Promise<TOutput>;
|
|
218
|
+
shouldEscalate: (symbolicOutput: TOutput, input: TInput, context: TContext) => boolean;
|
|
219
|
+
genAiResolve?: (input: TInput, symbolicOutput: TOutput, context: TContext) => Promise<TOutput | null>;
|
|
220
|
+
onGenAiError?: (err: unknown, symbolicOutput: TOutput, input: TInput, context: TContext) => TOutput;
|
|
221
|
+
}
|
|
222
|
+
declare class CompositeAiResolver<TInput, TOutput, TContext = void> implements IAiResolver<TInput, TOutput, TContext> {
|
|
223
|
+
private readonly config;
|
|
224
|
+
readonly id: string;
|
|
225
|
+
readonly kind: "composite";
|
|
226
|
+
constructor(config: CompositeAiResolverConfig<TInput, TOutput, TContext>);
|
|
227
|
+
resolveWithMetadata(input: TInput, context: TContext): Promise<AiResolutionResult<TOutput>>;
|
|
228
|
+
resolve(input: TInput, context: TContext): Promise<TOutput>;
|
|
229
|
+
}
|
|
230
|
+
declare function createCompositeAiResolver<TInput, TOutput, TContext = void>(config: CompositeAiResolverConfig<TInput, TOutput, TContext>): CompositeAiResolver<TInput, TOutput, TContext>;
|
|
231
|
+
|
|
232
|
+
export { type AgentChatMessage, type AgentChatRequest, type AgentChatResponse, type AgentChatTool, AgentClient, type AgentClientChatOptions, AiError as AiCommandError, AiError, type AiErrorCode, type AiFactoryConfig, AiKeyEncryptionService, AiError as AiMealError, type AiProvider, AiProviderFactory, type AiResolutionResult, type AiResolutionSource, type AuthTokenGetter, type AuthTokenRefresher, CompositeAiResolver, type CompositeAiResolverConfig, DEFAULT_USER_AI_SETTINGS, DisabledAiProvider, type ExtractedToolCall, type GenAiProviderPreference, GenAiToolResolver, type GenAiToolResolverConfig, type IAiResolver, type LegacyAiProviderPreference, LocalOllamaProvider, LruMemoryCache, type PreparedAiSettingsResult, ProxyAiProvider, type UserAiSettings, type ValidateAndPrepareAiSettingsOptions, WindowAiProvider, classifyAiError, createCompositeAiResolver, createGenAiToolResolver, extractToolCallData, isGenAiEnabled, normalizeProviderPreference, validateAndPrepareAiSettings };
|
package/dist/index.js
CHANGED
|
@@ -1,51 +1,66 @@
|
|
|
1
1
|
// src/providers/ProxyAiProvider.ts
|
|
2
2
|
var ProxyAiProvider = class {
|
|
3
|
-
constructor(proxyUrl = "", getAuthToken, encryptedApiKey, byokProvider) {
|
|
3
|
+
constructor(proxyUrl = "", getAuthToken, encryptedApiKey, byokProvider, onAuthExpired) {
|
|
4
4
|
this.getAuthToken = getAuthToken;
|
|
5
5
|
this.encryptedApiKey = encryptedApiKey;
|
|
6
6
|
this.byokProvider = byokProvider;
|
|
7
|
+
this.onAuthExpired = onAuthExpired;
|
|
7
8
|
this.base = (proxyUrl || "").replace(/\/$/, "");
|
|
8
9
|
}
|
|
9
10
|
getAuthToken;
|
|
10
11
|
encryptedApiKey;
|
|
11
12
|
byokProvider;
|
|
13
|
+
onAuthExpired;
|
|
12
14
|
id = "cloud-proxy";
|
|
13
15
|
base;
|
|
14
16
|
get mode() {
|
|
15
17
|
return this.encryptedApiKey ? "byok" : "cloud";
|
|
16
18
|
}
|
|
19
|
+
async sendChatRequest(request, tokenOverride) {
|
|
20
|
+
const headers = {
|
|
21
|
+
"Content-Type": "application/json"
|
|
22
|
+
};
|
|
23
|
+
const token = tokenOverride !== void 0 ? tokenOverride : this.getAuthToken ? await this.getAuthToken() : null;
|
|
24
|
+
if (token) {
|
|
25
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
26
|
+
}
|
|
27
|
+
return fetch(`${this.base}/api/v1/agent/chat`, {
|
|
28
|
+
method: "POST",
|
|
29
|
+
headers,
|
|
30
|
+
body: JSON.stringify({
|
|
31
|
+
messages: request.messages,
|
|
32
|
+
systemPrompt: request.systemPrompt,
|
|
33
|
+
tools: request.tools,
|
|
34
|
+
ciphertext: this.encryptedApiKey,
|
|
35
|
+
byokProvider: this.byokProvider
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
}
|
|
17
39
|
async chat(request) {
|
|
18
40
|
try {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (token) {
|
|
25
|
-
headers["Authorization"] = `Bearer ${token}`;
|
|
41
|
+
let response = await this.sendChatRequest(request);
|
|
42
|
+
if (response.status === 401 && !this.encryptedApiKey && this.onAuthExpired) {
|
|
43
|
+
const refreshedToken = await this.onAuthExpired();
|
|
44
|
+
if (refreshedToken && refreshedToken.trim()) {
|
|
45
|
+
response = await this.sendChatRequest(request, refreshedToken.trim());
|
|
26
46
|
}
|
|
27
47
|
}
|
|
28
|
-
const response = await fetch(`${this.base}/api/v1/agent/chat`, {
|
|
29
|
-
method: "POST",
|
|
30
|
-
headers,
|
|
31
|
-
body: JSON.stringify({
|
|
32
|
-
messages: request.messages,
|
|
33
|
-
systemPrompt: request.systemPrompt,
|
|
34
|
-
tools: request.tools,
|
|
35
|
-
ciphertext: this.encryptedApiKey,
|
|
36
|
-
byokProvider: this.byokProvider
|
|
37
|
-
})
|
|
38
|
-
});
|
|
39
48
|
if (!response.ok) {
|
|
40
49
|
const error = await response.json().catch(() => ({}));
|
|
41
50
|
return {
|
|
42
51
|
type: "text",
|
|
43
|
-
error: error.code || error.message || error.error || `Proxy request failed (${response.status})
|
|
52
|
+
error: error.code || error.message || error.error || `Proxy request failed (${response.status})`,
|
|
53
|
+
errorCode: error.code,
|
|
54
|
+
errorMessage: error.message,
|
|
55
|
+
status: response.status
|
|
44
56
|
};
|
|
45
57
|
}
|
|
46
58
|
return await response.json();
|
|
47
59
|
} catch (error) {
|
|
48
|
-
return {
|
|
60
|
+
return {
|
|
61
|
+
type: "text",
|
|
62
|
+
error: error.message || "Network error communicating with AI proxy"
|
|
63
|
+
};
|
|
49
64
|
}
|
|
50
65
|
}
|
|
51
66
|
async checkAvailability() {
|
|
@@ -240,73 +255,151 @@ var LocalOllamaProvider = class {
|
|
|
240
255
|
}
|
|
241
256
|
};
|
|
242
257
|
|
|
258
|
+
// src/settings/normalize.ts
|
|
259
|
+
var DEFAULT_USER_AI_SETTINGS = {
|
|
260
|
+
providerPreference: "auto",
|
|
261
|
+
enableLocalAi: false,
|
|
262
|
+
byokProvider: "google",
|
|
263
|
+
ollamaBaseUrl: "http://localhost:11434/api"
|
|
264
|
+
};
|
|
265
|
+
function normalizeProviderPreference(provider, enabled) {
|
|
266
|
+
if (enabled === false) {
|
|
267
|
+
return "disabled";
|
|
268
|
+
}
|
|
269
|
+
switch ((provider || "").trim()) {
|
|
270
|
+
case "disabled":
|
|
271
|
+
return "disabled";
|
|
272
|
+
case "byok":
|
|
273
|
+
return "byok";
|
|
274
|
+
case "local":
|
|
275
|
+
case "ollama":
|
|
276
|
+
return "local";
|
|
277
|
+
case "local-browser":
|
|
278
|
+
case "window.ai":
|
|
279
|
+
return "local-browser";
|
|
280
|
+
case "cloud":
|
|
281
|
+
case "qozara-intelligence":
|
|
282
|
+
return "cloud";
|
|
283
|
+
case "auto":
|
|
284
|
+
default:
|
|
285
|
+
return "auto";
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
function isGenAiEnabled(settings) {
|
|
289
|
+
if (!settings) {
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
return normalizeProviderPreference(
|
|
293
|
+
settings.providerPreference ?? settings.provider,
|
|
294
|
+
settings.enabled
|
|
295
|
+
) !== "disabled";
|
|
296
|
+
}
|
|
297
|
+
|
|
243
298
|
// src/providers/AiProviderFactory.ts
|
|
244
299
|
var DisabledAiProvider = class {
|
|
245
300
|
id = "disabled";
|
|
246
301
|
mode = "disabled";
|
|
247
302
|
async chat() {
|
|
248
|
-
return { type: "text", error: "
|
|
303
|
+
return { type: "text", error: "GenAI is disabled" };
|
|
249
304
|
}
|
|
250
305
|
async checkAvailability() {
|
|
251
306
|
return false;
|
|
252
307
|
}
|
|
253
308
|
getSetupMessage() {
|
|
254
|
-
return
|
|
309
|
+
return "Generative AI is disabled. Natural language parsing runs 100% offline using built-in deterministic AI.";
|
|
255
310
|
}
|
|
256
311
|
};
|
|
257
312
|
var AiProviderFactory = class {
|
|
258
|
-
static async createProvider(config, getAuthToken) {
|
|
259
|
-
const {
|
|
260
|
-
|
|
313
|
+
static async createProvider(config, getAuthToken, onAuthExpired) {
|
|
314
|
+
const {
|
|
315
|
+
providerPreference,
|
|
316
|
+
encryptedApiKey,
|
|
317
|
+
baseUrl,
|
|
318
|
+
proxyUrl,
|
|
319
|
+
byokProvider,
|
|
320
|
+
enableLocalAi
|
|
321
|
+
} = config;
|
|
322
|
+
const normalizedPreference = normalizeProviderPreference(providerPreference);
|
|
323
|
+
const isLocalAiOptedIn = Boolean(enableLocalAi);
|
|
324
|
+
if (normalizedPreference === "disabled") {
|
|
261
325
|
return new DisabledAiProvider();
|
|
262
326
|
}
|
|
263
|
-
if (
|
|
264
|
-
return new ProxyAiProvider(
|
|
327
|
+
if (normalizedPreference === "byok" && encryptedApiKey && proxyUrl) {
|
|
328
|
+
return new ProxyAiProvider(
|
|
329
|
+
proxyUrl,
|
|
330
|
+
getAuthToken,
|
|
331
|
+
encryptedApiKey,
|
|
332
|
+
byokProvider,
|
|
333
|
+
onAuthExpired
|
|
334
|
+
);
|
|
265
335
|
}
|
|
266
|
-
if (
|
|
267
|
-
if (
|
|
336
|
+
if (normalizedPreference === "local") {
|
|
337
|
+
if (isLocalAiOptedIn) {
|
|
268
338
|
return new LocalOllamaProvider(baseUrl, config.ollamaModel);
|
|
269
339
|
}
|
|
270
340
|
return new DisabledAiProvider();
|
|
271
341
|
}
|
|
272
|
-
if (
|
|
342
|
+
if (normalizedPreference === "local-browser") {
|
|
273
343
|
return new WindowAiProvider();
|
|
274
344
|
}
|
|
275
|
-
if (
|
|
276
|
-
return new ProxyAiProvider(
|
|
345
|
+
if (normalizedPreference === "cloud" && proxyUrl) {
|
|
346
|
+
return new ProxyAiProvider(
|
|
347
|
+
proxyUrl,
|
|
348
|
+
getAuthToken,
|
|
349
|
+
void 0,
|
|
350
|
+
byokProvider,
|
|
351
|
+
onAuthExpired
|
|
352
|
+
);
|
|
277
353
|
}
|
|
278
|
-
if (
|
|
354
|
+
if (normalizedPreference === "auto") {
|
|
279
355
|
if (encryptedApiKey && proxyUrl) {
|
|
280
|
-
return new ProxyAiProvider(
|
|
356
|
+
return new ProxyAiProvider(
|
|
357
|
+
proxyUrl,
|
|
358
|
+
getAuthToken,
|
|
359
|
+
encryptedApiKey,
|
|
360
|
+
byokProvider,
|
|
361
|
+
onAuthExpired
|
|
362
|
+
);
|
|
281
363
|
}
|
|
282
364
|
const windowProvider = new WindowAiProvider();
|
|
283
365
|
if (await windowProvider.checkAvailability()) {
|
|
284
366
|
return windowProvider;
|
|
285
367
|
}
|
|
286
|
-
if (
|
|
368
|
+
if (isLocalAiOptedIn) {
|
|
287
369
|
const localProvider = new LocalOllamaProvider(baseUrl, config.ollamaModel);
|
|
288
370
|
if (await localProvider.checkAvailability()) {
|
|
289
371
|
return localProvider;
|
|
290
372
|
}
|
|
291
373
|
}
|
|
292
374
|
if (proxyUrl) {
|
|
293
|
-
return new ProxyAiProvider(
|
|
375
|
+
return new ProxyAiProvider(
|
|
376
|
+
proxyUrl,
|
|
377
|
+
getAuthToken,
|
|
378
|
+
void 0,
|
|
379
|
+
byokProvider,
|
|
380
|
+
onAuthExpired
|
|
381
|
+
);
|
|
294
382
|
}
|
|
295
383
|
}
|
|
296
384
|
return new DisabledAiProvider();
|
|
297
385
|
}
|
|
298
386
|
static getSetupMessage(providerId, config) {
|
|
299
|
-
switch (providerId) {
|
|
387
|
+
switch ((providerId || "").trim()) {
|
|
300
388
|
case "local":
|
|
301
389
|
case "local-ollama":
|
|
390
|
+
case "ollama":
|
|
302
391
|
return new LocalOllamaProvider(config?.baseUrl, config?.ollamaModel).getSetupMessage();
|
|
303
392
|
case "local-browser":
|
|
304
393
|
case "window-ai":
|
|
394
|
+
case "window.ai":
|
|
305
395
|
return new WindowAiProvider().getSetupMessage();
|
|
306
396
|
case "byok":
|
|
307
397
|
return "Enter your Gemini API key below. It will be encrypted and stored solely in your personal storage.";
|
|
308
398
|
case "cloud":
|
|
399
|
+
case "qozara-intelligence":
|
|
309
400
|
return "Using Qozara Intelligence (Requires registered Qozara Google account).";
|
|
401
|
+
case "disabled":
|
|
402
|
+
return "Generative AI is disabled. Natural language parsing runs 100% offline using built-in deterministic AI.";
|
|
310
403
|
default:
|
|
311
404
|
return null;
|
|
312
405
|
}
|
|
@@ -315,11 +408,13 @@ var AiProviderFactory = class {
|
|
|
315
408
|
|
|
316
409
|
// src/AgentClient.ts
|
|
317
410
|
var AgentClient = class {
|
|
318
|
-
constructor(baseUrl = "", getAuthToken) {
|
|
411
|
+
constructor(baseUrl = "", getAuthToken, onAuthExpired) {
|
|
319
412
|
this.getAuthToken = getAuthToken;
|
|
413
|
+
this.onAuthExpired = onAuthExpired;
|
|
320
414
|
this.base = (baseUrl || "").replace(/\/$/, "");
|
|
321
415
|
}
|
|
322
416
|
getAuthToken;
|
|
417
|
+
onAuthExpired;
|
|
323
418
|
base;
|
|
324
419
|
/**
|
|
325
420
|
* Encrypts a personal API key using the edge proxy's KMS_SECRET.
|
|
@@ -352,35 +447,397 @@ var AgentClient = class {
|
|
|
352
447
|
* Auth token is optional (unauthenticated clients can use BYOK or anonymous tier).
|
|
353
448
|
*/
|
|
354
449
|
async chat(request) {
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
const token = await this.getAuthToken();
|
|
450
|
+
const send = async (tokenOverride) => {
|
|
451
|
+
const headers = {
|
|
452
|
+
"Content-Type": "application/json"
|
|
453
|
+
};
|
|
454
|
+
const token = tokenOverride !== void 0 ? tokenOverride : this.getAuthToken ? await this.getAuthToken() : null;
|
|
360
455
|
if (token) {
|
|
361
456
|
headers["Authorization"] = `Bearer ${token}`;
|
|
362
457
|
}
|
|
458
|
+
return fetch(`${this.base}/api/v1/agent/chat`, {
|
|
459
|
+
method: "POST",
|
|
460
|
+
headers,
|
|
461
|
+
body: JSON.stringify(request)
|
|
462
|
+
});
|
|
463
|
+
};
|
|
464
|
+
let response = await send();
|
|
465
|
+
if (response.status === 401 && !request.ciphertext && this.onAuthExpired) {
|
|
466
|
+
const refreshedToken = await this.onAuthExpired();
|
|
467
|
+
if (refreshedToken && refreshedToken.trim()) {
|
|
468
|
+
response = await send(refreshedToken.trim());
|
|
469
|
+
}
|
|
363
470
|
}
|
|
364
|
-
const response = await fetch(`${this.base}/api/v1/agent/chat`, {
|
|
365
|
-
method: "POST",
|
|
366
|
-
headers,
|
|
367
|
-
body: JSON.stringify(request)
|
|
368
|
-
});
|
|
369
471
|
if (!response.ok) {
|
|
370
472
|
const error = await response.json().catch(() => ({}));
|
|
371
473
|
return {
|
|
372
474
|
type: "text",
|
|
373
|
-
error: error.code || error.message || error.error || `AI proxy request failed (${response.status})
|
|
475
|
+
error: error.code || error.message || error.error || `AI proxy request failed (${response.status})`,
|
|
476
|
+
errorCode: error.code,
|
|
477
|
+
errorMessage: error.message,
|
|
478
|
+
status: response.status
|
|
374
479
|
};
|
|
375
480
|
}
|
|
376
481
|
return await response.json();
|
|
377
482
|
}
|
|
378
483
|
};
|
|
484
|
+
|
|
485
|
+
// src/cache/LruMemoryCache.ts
|
|
486
|
+
var LruMemoryCache = class {
|
|
487
|
+
constructor(capacity = 50) {
|
|
488
|
+
this.capacity = capacity;
|
|
489
|
+
if (capacity <= 0) {
|
|
490
|
+
throw new Error("LruMemoryCache capacity must be greater than 0");
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
capacity;
|
|
494
|
+
map = /* @__PURE__ */ new Map();
|
|
495
|
+
get(key) {
|
|
496
|
+
if (!this.map.has(key)) {
|
|
497
|
+
return void 0;
|
|
498
|
+
}
|
|
499
|
+
const val = this.map.get(key);
|
|
500
|
+
this.map.delete(key);
|
|
501
|
+
this.map.set(key, val);
|
|
502
|
+
return val;
|
|
503
|
+
}
|
|
504
|
+
set(key, value) {
|
|
505
|
+
if (this.map.has(key)) {
|
|
506
|
+
this.map.delete(key);
|
|
507
|
+
} else if (this.map.size >= this.capacity) {
|
|
508
|
+
const oldestKey = this.map.keys().next().value;
|
|
509
|
+
if (oldestKey !== void 0) {
|
|
510
|
+
this.map.delete(oldestKey);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
this.map.set(key, value);
|
|
514
|
+
}
|
|
515
|
+
has(key) {
|
|
516
|
+
return this.map.has(key);
|
|
517
|
+
}
|
|
518
|
+
clear() {
|
|
519
|
+
this.map.clear();
|
|
520
|
+
}
|
|
521
|
+
get size() {
|
|
522
|
+
return this.map.size;
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
// src/errors/AiError.ts
|
|
527
|
+
var AiError = class extends Error {
|
|
528
|
+
constructor(code, message, cause) {
|
|
529
|
+
super(message);
|
|
530
|
+
this.code = code;
|
|
531
|
+
this.cause = cause;
|
|
532
|
+
this.name = "AiError";
|
|
533
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
534
|
+
}
|
|
535
|
+
code;
|
|
536
|
+
cause;
|
|
537
|
+
};
|
|
538
|
+
function classifyAiError(err) {
|
|
539
|
+
if (err instanceof AiError) {
|
|
540
|
+
return err;
|
|
541
|
+
}
|
|
542
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
543
|
+
if (/FORBIDDEN_403|\b403\b|Forbidden|not registered for Qozara Intelligence/i.test(msg)) {
|
|
544
|
+
return new AiError("FORBIDDEN_NOT_REGISTERED", msg, err);
|
|
545
|
+
}
|
|
546
|
+
if (/UNAUTHORIZED_401|\b401\b|Unauthorized|expired Google token/i.test(msg) || /invalid/i.test(msg) && /token/i.test(msg)) {
|
|
547
|
+
return new AiError("AUTHENTICATION_REQUIRED", msg, err);
|
|
548
|
+
}
|
|
549
|
+
if (/RATE_LIMIT|\b429\b|Too Many Requests|quota exceeded|quota reached|exhausted/i.test(msg)) {
|
|
550
|
+
return new AiError("RATE_LIMIT_EXCEEDED", msg, err);
|
|
551
|
+
}
|
|
552
|
+
if (/AI is disabled|GenAI is disabled/i.test(msg)) {
|
|
553
|
+
return new AiError("AI_DISABLED", msg, err);
|
|
554
|
+
}
|
|
555
|
+
if (/no food items|Could not extract/i.test(msg)) {
|
|
556
|
+
return new AiError("NO_ITEMS_PARSED", msg, err);
|
|
557
|
+
}
|
|
558
|
+
if (/Failed to fetch|Network error|ECONNREFUSED|ENOTFOUND|timeout|unreachable/i.test(msg)) {
|
|
559
|
+
return new AiError("NETWORK_ERROR", msg, err);
|
|
560
|
+
}
|
|
561
|
+
return new AiError("PARSE_FAILED", msg, err);
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// src/settings/index.ts
|
|
565
|
+
var AiKeyEncryptionService = class {
|
|
566
|
+
/**
|
|
567
|
+
* Encrypts a user's personal provider API key using the edge KMS proxy.
|
|
568
|
+
* Returns a secure ciphertext string to store safely in local or cloud storage.
|
|
569
|
+
*/
|
|
570
|
+
static async encryptApiKey(rawApiKey, proxyUrl, getAuthToken) {
|
|
571
|
+
const trimmedKey = (rawApiKey || "").trim();
|
|
572
|
+
if (!trimmedKey) {
|
|
573
|
+
throw new Error("API key cannot be empty");
|
|
574
|
+
}
|
|
575
|
+
const cleanUrl = (proxyUrl || "").trim().replace(/\/+$/, "");
|
|
576
|
+
if (!cleanUrl) {
|
|
577
|
+
throw new Error("AI proxy URL is required to encrypt API key");
|
|
578
|
+
}
|
|
579
|
+
const client = new AgentClient(cleanUrl, getAuthToken);
|
|
580
|
+
return await client.encryptApiKey(trimmedKey);
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
async function validateAndPrepareAiSettings(options) {
|
|
584
|
+
const pref = normalizeProviderPreference(options.providerPreference);
|
|
585
|
+
let encryptedApiKey = options.existingEncryptedApiKey;
|
|
586
|
+
if (pref === "byok" && options.rawApiKey && options.rawApiKey.trim()) {
|
|
587
|
+
encryptedApiKey = await AiKeyEncryptionService.encryptApiKey(
|
|
588
|
+
options.rawApiKey,
|
|
589
|
+
options.proxyUrl || "",
|
|
590
|
+
options.getAuthToken
|
|
591
|
+
);
|
|
592
|
+
}
|
|
593
|
+
const enableLocalAi = Boolean(options.enableLocalAi);
|
|
594
|
+
const trimmedOllamaUrl = options.ollamaBaseUrl?.trim() || void 0;
|
|
595
|
+
const trimmedOllamaModel = options.ollamaModel?.trim() || void 0;
|
|
596
|
+
const byokProvider = options.byokProvider?.trim() || "google";
|
|
597
|
+
const settings = {
|
|
598
|
+
providerPreference: pref,
|
|
599
|
+
enableLocalAi,
|
|
600
|
+
...encryptedApiKey ? { encryptedApiKey } : {},
|
|
601
|
+
byokProvider,
|
|
602
|
+
...trimmedOllamaUrl ? { ollamaBaseUrl: trimmedOllamaUrl } : {},
|
|
603
|
+
...trimmedOllamaModel ? { ollamaModel: trimmedOllamaModel } : {}
|
|
604
|
+
};
|
|
605
|
+
const setupMessage = AiProviderFactory.getSetupMessage(pref, {
|
|
606
|
+
baseUrl: trimmedOllamaUrl,
|
|
607
|
+
ollamaModel: trimmedOllamaModel
|
|
608
|
+
});
|
|
609
|
+
let isReachable = true;
|
|
610
|
+
if (pref !== "disabled" && options.probeAvailability !== false) {
|
|
611
|
+
const provider = await AiProviderFactory.createProvider(
|
|
612
|
+
{
|
|
613
|
+
providerPreference: pref,
|
|
614
|
+
enableLocalAi,
|
|
615
|
+
encryptedApiKey,
|
|
616
|
+
byokProvider,
|
|
617
|
+
baseUrl: enableLocalAi ? trimmedOllamaUrl : void 0,
|
|
618
|
+
ollamaModel: trimmedOllamaModel,
|
|
619
|
+
proxyUrl: options.proxyUrl
|
|
620
|
+
},
|
|
621
|
+
options.getAuthToken
|
|
622
|
+
);
|
|
623
|
+
isReachable = await provider.checkAvailability();
|
|
624
|
+
}
|
|
625
|
+
return {
|
|
626
|
+
settings,
|
|
627
|
+
isReachable,
|
|
628
|
+
setupMessage
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
// src/resolvers/extractToolCallData.ts
|
|
633
|
+
function parseJsonPayload(raw) {
|
|
634
|
+
if (raw === null || raw === void 0) return null;
|
|
635
|
+
if (typeof raw === "object") return raw;
|
|
636
|
+
if (typeof raw !== "string") return null;
|
|
637
|
+
const trimmed = raw.trim();
|
|
638
|
+
if (!trimmed) return null;
|
|
639
|
+
try {
|
|
640
|
+
return JSON.parse(trimmed);
|
|
641
|
+
} catch {
|
|
642
|
+
const fenceMatch = trimmed.match(/```(?:json)?\s*([\s\S]*?)\s*```/);
|
|
643
|
+
if (fenceMatch && fenceMatch[1]) {
|
|
644
|
+
try {
|
|
645
|
+
return JSON.parse(fenceMatch[1].trim());
|
|
646
|
+
} catch {
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
const firstBrace = trimmed.indexOf("{");
|
|
650
|
+
const lastBrace = trimmed.lastIndexOf("}");
|
|
651
|
+
if (firstBrace !== -1 && lastBrace > firstBrace) {
|
|
652
|
+
try {
|
|
653
|
+
return JSON.parse(trimmed.slice(firstBrace, lastBrace + 1));
|
|
654
|
+
} catch {
|
|
655
|
+
return null;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
return null;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
function extractToolCallData(response) {
|
|
662
|
+
if (!response || typeof response !== "object") {
|
|
663
|
+
return null;
|
|
664
|
+
}
|
|
665
|
+
const res = response;
|
|
666
|
+
if (res.arguments !== void 0 && res.arguments !== null) {
|
|
667
|
+
const parsed = parseJsonPayload(res.arguments);
|
|
668
|
+
if (parsed && typeof parsed === "object") {
|
|
669
|
+
return {
|
|
670
|
+
toolName: typeof res.tool === "string" ? res.tool : void 0,
|
|
671
|
+
args: parsed
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
if (Array.isArray(res.tool_calls) && res.tool_calls.length > 0) {
|
|
676
|
+
const call = res.tool_calls[0];
|
|
677
|
+
const rawArgs = call?.function?.arguments ?? call?.arguments ?? call;
|
|
678
|
+
const parsed = parseJsonPayload(rawArgs);
|
|
679
|
+
if (parsed && typeof parsed === "object") {
|
|
680
|
+
return {
|
|
681
|
+
toolName: call?.function?.name || call?.name || (typeof res.tool === "string" ? res.tool : void 0),
|
|
682
|
+
args: parsed
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
const choiceMsg = res.choices?.[0]?.message;
|
|
687
|
+
if (choiceMsg && typeof choiceMsg === "object") {
|
|
688
|
+
if (Array.isArray(choiceMsg.tool_calls) && choiceMsg.tool_calls.length > 0) {
|
|
689
|
+
const call = choiceMsg.tool_calls[0];
|
|
690
|
+
const rawArgs = call?.function?.arguments ?? call?.arguments;
|
|
691
|
+
const parsed = parseJsonPayload(rawArgs);
|
|
692
|
+
if (parsed && typeof parsed === "object") {
|
|
693
|
+
return {
|
|
694
|
+
toolName: call?.function?.name || call?.name,
|
|
695
|
+
args: parsed
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
if (choiceMsg.content) {
|
|
700
|
+
const parsed = parseJsonPayload(choiceMsg.content);
|
|
701
|
+
if (parsed && typeof parsed === "object") {
|
|
702
|
+
if (typeof parsed.tool === "string" && parsed.arguments && typeof parsed.arguments === "object") {
|
|
703
|
+
return { toolName: parsed.tool, args: parsed.arguments };
|
|
704
|
+
}
|
|
705
|
+
return { args: parsed };
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
if (res.content) {
|
|
710
|
+
const parsed = parseJsonPayload(res.content);
|
|
711
|
+
if (parsed && typeof parsed === "object") {
|
|
712
|
+
if (typeof parsed.tool === "string" && parsed.arguments && typeof parsed.arguments === "object") {
|
|
713
|
+
return { toolName: parsed.tool, args: parsed.arguments };
|
|
714
|
+
}
|
|
715
|
+
return {
|
|
716
|
+
toolName: typeof res.tool === "string" ? res.tool : void 0,
|
|
717
|
+
args: parsed
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
return null;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
// src/resolvers/GenAiToolResolver.ts
|
|
725
|
+
var GenAiToolResolver = class {
|
|
726
|
+
constructor(config) {
|
|
727
|
+
this.config = config;
|
|
728
|
+
if (config.cache === null) {
|
|
729
|
+
this.cache = null;
|
|
730
|
+
} else if (config.cache) {
|
|
731
|
+
this.cache = config.cache;
|
|
732
|
+
} else if (config.getCacheKey) {
|
|
733
|
+
this.cache = new LruMemoryCache(config.cacheCapacity ?? 50);
|
|
734
|
+
} else {
|
|
735
|
+
this.cache = null;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
config;
|
|
739
|
+
kind = "genai";
|
|
740
|
+
cache;
|
|
741
|
+
clearCache() {
|
|
742
|
+
this.cache?.clear();
|
|
743
|
+
}
|
|
744
|
+
async resolve(input) {
|
|
745
|
+
const cacheKey = this.config.getCacheKey ? this.config.getCacheKey(input) : null;
|
|
746
|
+
if (this.cache && cacheKey) {
|
|
747
|
+
const cached = this.cache.get(cacheKey);
|
|
748
|
+
if (cached !== void 0 && cached !== null) {
|
|
749
|
+
return cached;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
try {
|
|
753
|
+
const resolvedFactoryConfig = typeof this.config.factoryConfig === "function" ? await this.config.factoryConfig(input) : this.config.factoryConfig;
|
|
754
|
+
const provider = await AiProviderFactory.createProvider(
|
|
755
|
+
resolvedFactoryConfig,
|
|
756
|
+
this.config.getAuthToken,
|
|
757
|
+
this.config.onAuthExpired
|
|
758
|
+
);
|
|
759
|
+
const request = await this.config.buildRequest(input);
|
|
760
|
+
const response = await provider.chat(request);
|
|
761
|
+
if (!response) {
|
|
762
|
+
return null;
|
|
763
|
+
}
|
|
764
|
+
if (response.error) {
|
|
765
|
+
const detail = response.errorMessage ? `${response.error}: ${response.errorMessage}` : response.error;
|
|
766
|
+
throw classifyAiError(new Error(detail));
|
|
767
|
+
}
|
|
768
|
+
const extracted = extractToolCallData(response);
|
|
769
|
+
const result = await this.config.parseResponse(extracted, response, input);
|
|
770
|
+
if (result !== null && result !== void 0 && this.cache && cacheKey) {
|
|
771
|
+
this.cache.set(cacheKey, result);
|
|
772
|
+
}
|
|
773
|
+
return result ?? null;
|
|
774
|
+
} catch (err) {
|
|
775
|
+
throw classifyAiError(err);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
};
|
|
779
|
+
function createGenAiToolResolver(config) {
|
|
780
|
+
return new GenAiToolResolver(config);
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
// src/resolvers/CompositeAiResolver.ts
|
|
784
|
+
var CompositeAiResolver = class {
|
|
785
|
+
constructor(config) {
|
|
786
|
+
this.config = config;
|
|
787
|
+
this.id = config.id || "composite-ai-resolver";
|
|
788
|
+
}
|
|
789
|
+
config;
|
|
790
|
+
id;
|
|
791
|
+
kind = "composite";
|
|
792
|
+
async resolveWithMetadata(input, context) {
|
|
793
|
+
const symbolicOutput = await this.config.symbolicResolve(input, context);
|
|
794
|
+
if (!this.config.genAiResolve || !this.config.shouldEscalate(symbolicOutput, input, context)) {
|
|
795
|
+
return { output: symbolicOutput, source: "symbolic" };
|
|
796
|
+
}
|
|
797
|
+
try {
|
|
798
|
+
const genAiOutput = await this.config.genAiResolve(input, symbolicOutput, context);
|
|
799
|
+
if (genAiOutput !== null && genAiOutput !== void 0) {
|
|
800
|
+
return { output: genAiOutput, source: "composite" };
|
|
801
|
+
}
|
|
802
|
+
return { output: symbolicOutput, source: "symbolic-fallback" };
|
|
803
|
+
} catch (err) {
|
|
804
|
+
if (this.config.onGenAiError) {
|
|
805
|
+
return {
|
|
806
|
+
output: this.config.onGenAiError(err, symbolicOutput, input, context),
|
|
807
|
+
source: "symbolic-fallback"
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
throw err;
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
async resolve(input, context) {
|
|
814
|
+
const { output } = await this.resolveWithMetadata(input, context);
|
|
815
|
+
return output;
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
function createCompositeAiResolver(config) {
|
|
819
|
+
return new CompositeAiResolver(config);
|
|
820
|
+
}
|
|
379
821
|
export {
|
|
380
822
|
AgentClient,
|
|
823
|
+
AiError as AiCommandError,
|
|
824
|
+
AiError,
|
|
825
|
+
AiKeyEncryptionService,
|
|
826
|
+
AiError as AiMealError,
|
|
381
827
|
AiProviderFactory,
|
|
828
|
+
CompositeAiResolver,
|
|
829
|
+
DEFAULT_USER_AI_SETTINGS,
|
|
382
830
|
DisabledAiProvider,
|
|
831
|
+
GenAiToolResolver,
|
|
383
832
|
LocalOllamaProvider,
|
|
833
|
+
LruMemoryCache,
|
|
384
834
|
ProxyAiProvider,
|
|
385
|
-
WindowAiProvider
|
|
835
|
+
WindowAiProvider,
|
|
836
|
+
classifyAiError,
|
|
837
|
+
createCompositeAiResolver,
|
|
838
|
+
createGenAiToolResolver,
|
|
839
|
+
extractToolCallData,
|
|
840
|
+
isGenAiEnabled,
|
|
841
|
+
normalizeProviderPreference,
|
|
842
|
+
validateAndPrepareAiSettings
|
|
386
843
|
};
|