@genesislcap/foundation-ai 14.407.0-workspaces.4 → 14.408.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/dts/ai-provider.d.ts +18 -2
- package/dist/dts/ai-provider.d.ts.map +1 -1
- package/dist/dts/index.d.ts +5 -1
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/interactions/criteria-interpretation.d.ts +11 -0
- package/dist/dts/interactions/criteria-interpretation.d.ts.map +1 -1
- package/dist/dts/providers/gemini-provider.d.ts +25 -0
- package/dist/dts/providers/gemini-provider.d.ts.map +1 -0
- package/dist/dts/transports/gemini-transport.d.ts +66 -0
- package/dist/dts/transports/gemini-transport.d.ts.map +1 -0
- package/dist/dts/types/chat-transport.types.d.ts +16 -0
- package/dist/dts/types/chat-transport.types.d.ts.map +1 -0
- package/dist/dts/types/chat.types.d.ts +157 -0
- package/dist/dts/types/chat.types.d.ts.map +1 -0
- package/dist/dts/types/config.types.d.ts +16 -2
- package/dist/dts/types/config.types.d.ts.map +1 -1
- package/dist/dts/types/criteria-types.d.ts +10 -0
- package/dist/dts/types/criteria-types.d.ts.map +1 -1
- package/dist/dts/types/index.d.ts +2 -0
- package/dist/dts/types/index.d.ts.map +1 -1
- package/dist/dts/utils/speech-to-text.d.ts +11 -0
- package/dist/dts/utils/speech-to-text.d.ts.map +1 -1
- package/dist/esm/ai-provider.js +18 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/providers/gemini-provider.js +59 -0
- package/dist/esm/transports/gemini-transport.js +249 -0
- package/dist/esm/types/chat-transport.types.js +1 -0
- package/dist/esm/types/chat.types.js +1 -0
- package/dist/esm/types/index.js +2 -0
- package/dist/esm/utils/speech-to-text.js +11 -0
- package/dist/foundation-ai.api.json +2937 -240
- package/dist/foundation-ai.d.ts +357 -4
- package/docs/api/foundation-ai.aiconfig.md +2 -2
- package/docs/api/foundation-ai.aiprovider.chat.md +85 -0
- package/docs/api/foundation-ai.aiprovider.md +22 -0
- package/docs/api/foundation-ai.aiprovider.streamchat.md +85 -0
- package/docs/api/foundation-ai.aiprovidertype.md +1 -1
- package/docs/api/foundation-ai.chatanimationsconfig.enabled.md +16 -0
- package/docs/api/foundation-ai.chatanimationsconfig.md +80 -0
- package/docs/api/foundation-ai.chatanimationsconfig.userconfigurable.md +16 -0
- package/docs/api/foundation-ai.chatattachment.content.md +14 -0
- package/docs/api/foundation-ai.chatattachment.md +99 -0
- package/docs/api/foundation-ai.chatattachment.mimetype.md +14 -0
- package/docs/api/foundation-ai.chatattachment.name.md +14 -0
- package/docs/api/foundation-ai.chatconfig.acceptedfiles.md +16 -0
- package/docs/api/foundation-ai.chatconfig.allowdebugdownload.md +16 -0
- package/docs/api/foundation-ai.chatconfig.animations.md +16 -0
- package/docs/api/foundation-ai.chatconfig.loadingdelay.md +16 -0
- package/docs/api/foundation-ai.chatconfig.maxtooliterations.md +16 -0
- package/docs/api/foundation-ai.chatconfig.md +177 -0
- package/docs/api/foundation-ai.chatconfig.showthinkingsteps.md +16 -0
- package/docs/api/foundation-ai.chatconfig.showtoolcalls.md +16 -0
- package/docs/api/foundation-ai.chatinteraction.componentname.md +14 -0
- package/docs/api/foundation-ai.chatinteraction.data.md +14 -0
- package/docs/api/foundation-ai.chatinteraction.interactionid.md +14 -0
- package/docs/api/foundation-ai.chatinteraction.md +118 -0
- package/docs/api/foundation-ai.chatinteraction.resolved.md +16 -0
- package/docs/api/foundation-ai.chatmessage.attachments.md +14 -0
- package/docs/api/foundation-ai.chatmessage.content.md +14 -0
- package/docs/api/foundation-ai.chatmessage.interaction.md +14 -0
- package/docs/api/foundation-ai.chatmessage.md +175 -0
- package/docs/api/foundation-ai.chatmessage.role.md +14 -0
- package/docs/api/foundation-ai.chatmessage.thinking.md +14 -0
- package/docs/api/foundation-ai.chatmessage.toolcalls.md +14 -0
- package/docs/api/foundation-ai.chatmessage.toolresult.md +14 -0
- package/docs/api/foundation-ai.chatrequestoptions.attachments.md +14 -0
- package/docs/api/foundation-ai.chatrequestoptions.md +118 -0
- package/docs/api/foundation-ai.chatrequestoptions.signal.md +14 -0
- package/docs/api/foundation-ai.chatrequestoptions.systemprompt.md +14 -0
- package/docs/api/foundation-ai.chatrequestoptions.tools.md +14 -0
- package/docs/api/foundation-ai.chatrole.md +16 -0
- package/docs/api/foundation-ai.chatstreamchunk.delta.md +14 -0
- package/docs/api/foundation-ai.chatstreamchunk.done.md +14 -0
- package/docs/api/foundation-ai.chatstreamchunk.md +99 -0
- package/docs/api/foundation-ai.chatstreamchunk.toolcalls.md +14 -0
- package/docs/api/foundation-ai.chattoolcall.args.md +14 -0
- package/docs/api/foundation-ai.chattoolcall.id.md +14 -0
- package/docs/api/foundation-ai.chattoolcall.md +99 -0
- package/docs/api/foundation-ai.chattoolcall.name.md +14 -0
- package/docs/api/foundation-ai.chattooldefinition.description.md +14 -0
- package/docs/api/foundation-ai.chattooldefinition.md +99 -0
- package/docs/api/foundation-ai.chattooldefinition.name.md +14 -0
- package/docs/api/foundation-ai.chattooldefinition.parameters.md +14 -0
- package/docs/api/foundation-ai.chattoolhandlers.md +18 -0
- package/docs/api/foundation-ai.chattoolresult.content.md +14 -0
- package/docs/api/foundation-ai.chattoolresult.md +80 -0
- package/docs/api/foundation-ai.chattoolresult.toolcallid.md +14 -0
- package/docs/api/foundation-ai.chattransport.md +58 -0
- package/docs/api/foundation-ai.chattransport.sendchatmessage.md +83 -0
- package/docs/api/foundation-ai.chattransport.streamchatmessage.md +83 -0
- package/docs/api/foundation-ai.criteriagroupresult.clauses.md +3 -0
- package/docs/api/foundation-ai.criteriagroupresult.logic.md +3 -0
- package/docs/api/foundation-ai.criteriagroupresult.md +10 -1
- package/docs/api/foundation-ai.criteriagroupresult.negated.md +3 -0
- package/docs/api/foundation-ai.criteriainterpretationresult.groups.md +3 -0
- package/docs/api/foundation-ai.criteriainterpretationresult.md +7 -0
- package/docs/api/foundation-ai.criteriainterpretcontext.fields.md +3 -0
- package/docs/api/foundation-ai.criteriainterpretcontext.md +6 -1
- package/docs/api/foundation-ai.fieldlike.md +5 -0
- package/docs/api/foundation-ai.geminiaiconfig.apikey.md +14 -0
- package/docs/api/foundation-ai.geminiaiconfig.md +123 -0
- package/docs/api/foundation-ai.geminiaiconfig.model.md +14 -0
- package/docs/api/foundation-ai.geminiaiconfig.providertype.md +14 -0
- package/docs/api/foundation-ai.geminiaiconfig.serverendpoint.md +14 -0
- package/docs/api/foundation-ai.geminiprovider._constructor_.md +65 -0
- package/docs/api/foundation-ai.geminiprovider.chat.md +83 -0
- package/docs/api/foundation-ai.geminiprovider.getstatus.md +18 -0
- package/docs/api/foundation-ai.geminiprovider.interpretcriteria.md +67 -0
- package/docs/api/foundation-ai.geminiprovider.md +128 -0
- package/docs/api/foundation-ai.geminiprovider.streamchat.md +83 -0
- package/docs/api/foundation-ai.geminitransport._constructor_.md +53 -0
- package/docs/api/foundation-ai.geminitransport.getconfig.md +21 -0
- package/docs/api/foundation-ai.geminitransport.md +116 -0
- package/docs/api/foundation-ai.geminitransport.sendchatmessage.md +83 -0
- package/docs/api/foundation-ai.geminitransport.sendstructuredprompt.md +53 -0
- package/docs/api/foundation-ai.interactionresult.md +20 -0
- package/docs/api/foundation-ai.isspeechrecognitionavailable.md +1 -1
- package/docs/api/foundation-ai.malformedfunctioncallerror._constructor_.md +53 -0
- package/docs/api/foundation-ai.malformedfunctioncallerror.finishmessage.md +14 -0
- package/docs/api/foundation-ai.malformedfunctioncallerror.md +98 -0
- package/docs/api/foundation-ai.md +230 -1
- package/docs/api/foundation-ai.resolveaiconfigoptions.md +9 -4
- package/docs/api/foundation-ai.resolveaiconfigoptions.model.md +3 -0
- package/docs/api/foundation-ai.resolveaiconfigoptions.preferchrome.md +3 -0
- package/docs/api/foundation-ai.resolveaiconfigoptions.provider.md +5 -2
- package/docs/api/foundation-ai.startspeechrecognition.md +5 -0
- package/docs/api-report.md.api.md +192 -11
- package/package.json +11 -11
package/dist/foundation-ai.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare const AI_FEATURE_FLAG = "ai";
|
|
|
9
9
|
*
|
|
10
10
|
* @beta
|
|
11
11
|
*/
|
|
12
|
-
export declare type AIConfig = ServerAIConfig | ChromeAIConfig;
|
|
12
|
+
export declare type AIConfig = ServerAIConfig | ChromeAIConfig | GeminiAIConfig;
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* AI Provider interface for foundation-ai.
|
|
@@ -31,6 +31,16 @@ export declare interface AIProvider {
|
|
|
31
31
|
* Must be called from a user gesture (e.g. click).
|
|
32
32
|
*/
|
|
33
33
|
triggerDownload?(): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Multi-turn chat (non-streaming). Returns the assistant's response message.
|
|
36
|
+
* Providers that support chat (Gemini, OpenAI) implement this.
|
|
37
|
+
*/
|
|
38
|
+
chat?(history: ChatMessage[], userMessage: string, options?: ChatRequestOptions): Promise<ChatMessage>;
|
|
39
|
+
/**
|
|
40
|
+
* Multi-turn chat (streaming). Yields chunks as they arrive.
|
|
41
|
+
* Providers that support streaming implement this.
|
|
42
|
+
*/
|
|
43
|
+
streamChat?(history: ChatMessage[], userMessage: string, options?: ChatRequestOptions): AsyncIterable<ChatStreamChunk>;
|
|
34
44
|
}
|
|
35
45
|
|
|
36
46
|
/**
|
|
@@ -67,7 +77,7 @@ declare interface AIProviderConfig {
|
|
|
67
77
|
*
|
|
68
78
|
* @beta
|
|
69
79
|
*/
|
|
70
|
-
export declare type AIProviderType = 'openai' | 'chrome' | 'none';
|
|
80
|
+
export declare type AIProviderType = 'openai' | 'chrome' | 'gemini' | 'none';
|
|
71
81
|
|
|
72
82
|
/**
|
|
73
83
|
* AI status for display in the header indicator.
|
|
@@ -80,6 +90,190 @@ export declare interface AIStatus {
|
|
|
80
90
|
chromeAvailability?: ChromeAvailability;
|
|
81
91
|
}
|
|
82
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Transport interface for AI providers.
|
|
95
|
+
* Each provider (OpenAI, Chrome, Anthropic) implements this to handle API-specific details.
|
|
96
|
+
*
|
|
97
|
+
* @beta
|
|
98
|
+
*/
|
|
99
|
+
declare interface AITransport {
|
|
100
|
+
sendStructuredPrompt(options: StructuredPromptOptions): Promise<string>;
|
|
101
|
+
isAvailable?(): Promise<boolean>;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Configuration for the animations feature.
|
|
106
|
+
*
|
|
107
|
+
* @beta
|
|
108
|
+
*/
|
|
109
|
+
export declare interface ChatAnimationsConfig {
|
|
110
|
+
/**
|
|
111
|
+
* When true, a multiselect control is shown in the settings panel so the
|
|
112
|
+
* user can toggle individual animations on or off.
|
|
113
|
+
*/
|
|
114
|
+
userConfigurable: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Initially enabled animations. When omitted all animations are enabled by
|
|
117
|
+
* default.
|
|
118
|
+
*/
|
|
119
|
+
enabled?: string[];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* A file attachment included with a user message.
|
|
124
|
+
*
|
|
125
|
+
* @beta
|
|
126
|
+
*/
|
|
127
|
+
export declare interface ChatAttachment {
|
|
128
|
+
name: string;
|
|
129
|
+
content: string;
|
|
130
|
+
mimeType: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Display and behaviour configuration for the chat assistant.
|
|
135
|
+
*
|
|
136
|
+
* For toggle flags (`showToolCalls`, `showThinkingSteps`):
|
|
137
|
+
* - `true` — default on, user can toggle off
|
|
138
|
+
* - `false` — default off, user can toggle on
|
|
139
|
+
* - `null` / `undefined` — completely disabled, no UI control shown
|
|
140
|
+
*
|
|
141
|
+
* @beta
|
|
142
|
+
*/
|
|
143
|
+
export declare interface ChatConfig {
|
|
144
|
+
/** Show tool call details in the chat UI. */
|
|
145
|
+
showToolCalls?: boolean | null;
|
|
146
|
+
/** Show model thinking/reasoning steps. */
|
|
147
|
+
showThinkingSteps?: boolean | null;
|
|
148
|
+
/** Show a button to download the full chat history as JSON. */
|
|
149
|
+
allowDebugDownload?: boolean;
|
|
150
|
+
/** Comma-separated list of accepted file extensions for upload, e.g., ".txt,.md,.csv". If undefined or empty, file uploads are disabled. */
|
|
151
|
+
acceptedFiles?: string;
|
|
152
|
+
/**
|
|
153
|
+
* Seconds to wait before showing the loading spinner. Default: 5.
|
|
154
|
+
* Set to 0 to show the spinner immediately when a request is in flight.
|
|
155
|
+
*/
|
|
156
|
+
loadingDelay?: number;
|
|
157
|
+
/** Animations feature configuration. */
|
|
158
|
+
animations?: ChatAnimationsConfig;
|
|
159
|
+
/** Maximum number of tool call iterations per turn. Default: 50. */
|
|
160
|
+
maxToolIterations?: number;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* A user interaction component request.
|
|
165
|
+
*
|
|
166
|
+
* @beta
|
|
167
|
+
*/
|
|
168
|
+
export declare interface ChatInteraction {
|
|
169
|
+
interactionId: string;
|
|
170
|
+
componentName: string;
|
|
171
|
+
data: any;
|
|
172
|
+
/** Set to true once the interaction has been resolved. Used to render a read-only state on re-render. */
|
|
173
|
+
resolved?: boolean;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* A single message in a chat conversation.
|
|
178
|
+
*
|
|
179
|
+
* @beta
|
|
180
|
+
*/
|
|
181
|
+
export declare interface ChatMessage {
|
|
182
|
+
role: ChatRole;
|
|
183
|
+
content: string;
|
|
184
|
+
toolCalls?: ChatToolCall[];
|
|
185
|
+
toolResult?: ChatToolResult;
|
|
186
|
+
attachments?: ChatAttachment[];
|
|
187
|
+
interaction?: ChatInteraction;
|
|
188
|
+
thinking?: boolean;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Options for a chat request.
|
|
193
|
+
*
|
|
194
|
+
* @beta
|
|
195
|
+
*/
|
|
196
|
+
export declare interface ChatRequestOptions {
|
|
197
|
+
systemPrompt?: string;
|
|
198
|
+
tools?: ChatToolDefinition[];
|
|
199
|
+
attachments?: ChatAttachment[];
|
|
200
|
+
signal?: AbortSignal;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Role of a message in a chat conversation.
|
|
205
|
+
*
|
|
206
|
+
* @beta
|
|
207
|
+
*/
|
|
208
|
+
export declare type ChatRole = 'user' | 'assistant' | 'system' | 'tool';
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* A streaming chunk from a chat response.
|
|
212
|
+
*
|
|
213
|
+
* @beta
|
|
214
|
+
*/
|
|
215
|
+
export declare interface ChatStreamChunk {
|
|
216
|
+
delta: string;
|
|
217
|
+
done: boolean;
|
|
218
|
+
toolCalls?: ChatToolCall[];
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* A tool call requested by the assistant.
|
|
223
|
+
*
|
|
224
|
+
* @beta
|
|
225
|
+
*/
|
|
226
|
+
export declare interface ChatToolCall {
|
|
227
|
+
id: string;
|
|
228
|
+
name: string;
|
|
229
|
+
args: Record<string, unknown>;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* JSON Schema-based tool definition for function calling.
|
|
234
|
+
*
|
|
235
|
+
* @beta
|
|
236
|
+
*/
|
|
237
|
+
export declare interface ChatToolDefinition {
|
|
238
|
+
name: string;
|
|
239
|
+
description: string;
|
|
240
|
+
parameters: Record<string, unknown>;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Map of tool name to async handler function.
|
|
245
|
+
*
|
|
246
|
+
* @beta
|
|
247
|
+
*/
|
|
248
|
+
export declare type ChatToolHandlers = Record<string, (args: Record<string, unknown>, context: {
|
|
249
|
+
requestInteraction: <T = unknown>(componentName: string, data: any) => Promise<T>;
|
|
250
|
+
}) => Promise<unknown>>;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* The result of executing a tool call.
|
|
254
|
+
*
|
|
255
|
+
* @beta
|
|
256
|
+
*/
|
|
257
|
+
export declare interface ChatToolResult {
|
|
258
|
+
toolCallId: string;
|
|
259
|
+
content: string;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Transport interface for chat-capable AI providers.
|
|
264
|
+
*
|
|
265
|
+
* @remarks
|
|
266
|
+
* Implement alongside `AITransport` for providers that support multi-turn chat
|
|
267
|
+
* conversations (e.g. Gemini, OpenAI). The `streamChatMessage` method is optional —
|
|
268
|
+
* providers that don't support streaming may omit it.
|
|
269
|
+
*
|
|
270
|
+
* @beta
|
|
271
|
+
*/
|
|
272
|
+
export declare interface ChatTransport {
|
|
273
|
+
sendChatMessage(history: ChatMessage[], userMessage: string, options?: ChatRequestOptions): Promise<ChatMessage>;
|
|
274
|
+
streamChatMessage?(history: ChatMessage[], userMessage: string, options?: ChatRequestOptions): AsyncIterable<ChatStreamChunk>;
|
|
275
|
+
}
|
|
276
|
+
|
|
83
277
|
/**
|
|
84
278
|
* Chrome built-in AI (Prompt API / Gemini Nano) configuration.
|
|
85
279
|
*
|
|
@@ -124,20 +318,41 @@ export declare interface CriteriaClauseResult {
|
|
|
124
318
|
value: string | number | boolean | null;
|
|
125
319
|
}
|
|
126
320
|
|
|
321
|
+
/**
|
|
322
|
+
* A group of criteria clauses combined by a logical operator.
|
|
323
|
+
*
|
|
324
|
+
* @beta
|
|
325
|
+
*/
|
|
127
326
|
export declare interface CriteriaGroupResult {
|
|
128
327
|
logic: 'and' | 'or';
|
|
129
328
|
negated?: boolean;
|
|
130
329
|
clauses: CriteriaClauseResult[];
|
|
131
330
|
}
|
|
132
331
|
|
|
332
|
+
/**
|
|
333
|
+
* Top-level result returned by criteria interpretation.
|
|
334
|
+
*
|
|
335
|
+
* @beta
|
|
336
|
+
*/
|
|
133
337
|
export declare interface CriteriaInterpretationResult {
|
|
134
338
|
groups: CriteriaGroupResult[];
|
|
135
339
|
}
|
|
136
340
|
|
|
341
|
+
/**
|
|
342
|
+
* Context passed to criteria interpretation, providing available field metadata.
|
|
343
|
+
*
|
|
344
|
+
* @beta
|
|
345
|
+
*/
|
|
137
346
|
export declare interface CriteriaInterpretContext {
|
|
138
347
|
fields?: FieldLike[];
|
|
139
348
|
}
|
|
140
349
|
|
|
350
|
+
/**
|
|
351
|
+
* A field descriptor accepted by criteria interpretation utilities.
|
|
352
|
+
* Can be a plain string name or an object with common field metadata properties.
|
|
353
|
+
*
|
|
354
|
+
* @beta
|
|
355
|
+
*/
|
|
141
356
|
export declare type FieldLike = string | {
|
|
142
357
|
name?: string;
|
|
143
358
|
field?: string;
|
|
@@ -145,6 +360,94 @@ export declare type FieldLike = string | {
|
|
|
145
360
|
NAME?: string;
|
|
146
361
|
};
|
|
147
362
|
|
|
363
|
+
/**
|
|
364
|
+
* Gemini server-proxy AI configuration (client calls your server; server calls Gemini).
|
|
365
|
+
*
|
|
366
|
+
* @remarks
|
|
367
|
+
* API key stays on the server. URL defaults to /gwf/ai-service/gemini/chat.
|
|
368
|
+
*
|
|
369
|
+
* @beta
|
|
370
|
+
*/
|
|
371
|
+
export declare interface GeminiAIConfig extends AIProviderConfig {
|
|
372
|
+
providerType: 'gemini';
|
|
373
|
+
model?: string;
|
|
374
|
+
serverEndpoint?: string;
|
|
375
|
+
apiKey?: string;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Gemini AI provider. Uses {@link GeminiTransport} to handle requests.
|
|
380
|
+
* Implements criteria interpretation and multi-turn chat.
|
|
381
|
+
*
|
|
382
|
+
* @beta
|
|
383
|
+
*/
|
|
384
|
+
export declare class GeminiProvider implements AIProvider {
|
|
385
|
+
private readonly transport;
|
|
386
|
+
private readonly criteriaInstructions?;
|
|
387
|
+
constructor(config: GeminiProviderConfig, transport: GeminiTransport);
|
|
388
|
+
getStatus(): Promise<AIStatus>;
|
|
389
|
+
interpretCriteria(input: string, context: CriteriaInterpretContext): Promise<CriteriaInterpretationResult | null>;
|
|
390
|
+
chat(history: ChatMessage[], userMessage: string, options?: ChatRequestOptions): Promise<ChatMessage>;
|
|
391
|
+
streamChat(history: ChatMessage[], userMessage: string, options?: ChatRequestOptions): AsyncIterable<ChatStreamChunk>;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
declare interface GeminiProviderConfig {
|
|
395
|
+
criteriaInstructions?: string;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Transport for Gemini. Calls the Gemini REST API directly when `apiKey` is
|
|
400
|
+
* provided, otherwise falls back to a server-proxy endpoint (if `serverEndpoint`
|
|
401
|
+
* is configured).
|
|
402
|
+
*
|
|
403
|
+
* Implements `AITransport` (structured prompt) and `ChatTransport` (multi-turn chat).
|
|
404
|
+
*
|
|
405
|
+
* @beta
|
|
406
|
+
*/
|
|
407
|
+
export declare class GeminiTransport implements AITransport, ChatTransport {
|
|
408
|
+
private readonly model;
|
|
409
|
+
private readonly timeout;
|
|
410
|
+
private readonly apiKey;
|
|
411
|
+
private readonly serverEndpoint;
|
|
412
|
+
constructor(config?: GeminiTransportConfig);
|
|
413
|
+
getConfig(): {
|
|
414
|
+
provider: 'gemini';
|
|
415
|
+
model: string;
|
|
416
|
+
};
|
|
417
|
+
sendStructuredPrompt(options: StructuredPromptOptions): Promise<string>;
|
|
418
|
+
sendChatMessage(history: ChatMessage[], userMessage: string, options?: ChatRequestOptions): Promise<ChatMessage>;
|
|
419
|
+
private static readonly TOKENS_PER_MILLION;
|
|
420
|
+
private static readonly PROMPT_COST_PER_MILLION;
|
|
421
|
+
private static readonly CANDIDATE_COST_PER_MILLION;
|
|
422
|
+
private static readonly COST_DECIMAL_PLACES;
|
|
423
|
+
private logTokenUsage;
|
|
424
|
+
private toGeminiContents;
|
|
425
|
+
private fromGeminiResponse;
|
|
426
|
+
private buildEndpoint;
|
|
427
|
+
private static readonly MAX_RETRIES;
|
|
428
|
+
private static readonly RATE_LIMIT_STATUS;
|
|
429
|
+
private static readonly BACKOFF_BASE_MS;
|
|
430
|
+
private post;
|
|
431
|
+
private toDirectPayload;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
declare interface GeminiTransportConfig {
|
|
435
|
+
model?: string;
|
|
436
|
+
timeout?: number;
|
|
437
|
+
/**
|
|
438
|
+
* API key for direct calls to the Gemini API.
|
|
439
|
+
* Must be provided explicitly; callers are responsible for reading it from
|
|
440
|
+
* their environment (e.g. a build-time injected global).
|
|
441
|
+
*/
|
|
442
|
+
apiKey?: string;
|
|
443
|
+
/**
|
|
444
|
+
* Server-proxy endpoint (e.g. `/gwf/ai-service/gemini/chat`).
|
|
445
|
+
* Only used when no API key is available. When omitted and no API key
|
|
446
|
+
* is found, requests will fail.
|
|
447
|
+
*/
|
|
448
|
+
serverEndpoint?: string;
|
|
449
|
+
}
|
|
450
|
+
|
|
148
451
|
/**
|
|
149
452
|
* Gets AIProvider from the DI container.
|
|
150
453
|
* When the AI feature flag is disabled (?feature.ai), returns DefaultAIProvider (no-op).
|
|
@@ -165,6 +468,17 @@ export declare type FieldLike = string | {
|
|
|
165
468
|
*/
|
|
166
469
|
export declare function getAIProvider(): AIProvider;
|
|
167
470
|
|
|
471
|
+
/**
|
|
472
|
+
* The result of a user interaction component.
|
|
473
|
+
*
|
|
474
|
+
* @beta
|
|
475
|
+
*/
|
|
476
|
+
export declare type InteractionResult<T = unknown> = {
|
|
477
|
+
status: 'approved' | 'rejected';
|
|
478
|
+
payload?: T;
|
|
479
|
+
message?: string;
|
|
480
|
+
};
|
|
481
|
+
|
|
168
482
|
/** Returns true when AI features (beta) are enabled. Requires ?feature.ai in URL. */
|
|
169
483
|
export declare const isAIFeatureEnabled: () => boolean;
|
|
170
484
|
|
|
@@ -174,8 +488,25 @@ export declare const isAIFeatureEnabled: () => boolean;
|
|
|
174
488
|
*
|
|
175
489
|
* @beta
|
|
176
490
|
*/
|
|
491
|
+
/**
|
|
492
|
+
* Returns true if the Web Speech API is available in the current environment.
|
|
493
|
+
*
|
|
494
|
+
* @beta
|
|
495
|
+
*/
|
|
177
496
|
export declare function isSpeechRecognitionAvailable(): boolean;
|
|
178
497
|
|
|
498
|
+
/**
|
|
499
|
+
* Thrown when Gemini returns a `MALFORMED_FUNCTION_CALL` finish reason,
|
|
500
|
+
* typically because the model tried to batch multiple tool calls using
|
|
501
|
+
* Python-style syntax instead of the proper API format.
|
|
502
|
+
*
|
|
503
|
+
* @beta
|
|
504
|
+
*/
|
|
505
|
+
export declare class MalformedFunctionCallError extends Error {
|
|
506
|
+
readonly finishMessage?: string;
|
|
507
|
+
constructor(finishMessage?: string);
|
|
508
|
+
}
|
|
509
|
+
|
|
179
510
|
/**
|
|
180
511
|
* Resolves AI config, optionally preferring Chrome when available.
|
|
181
512
|
* Use before registering AIProvider. Server URL is derived from API_HOST.
|
|
@@ -185,9 +516,14 @@ export declare function isSpeechRecognitionAvailable(): boolean;
|
|
|
185
516
|
*/
|
|
186
517
|
export declare function resolveAIConfig(options?: ResolveAIConfigOptions): Promise<AIConfig | null>;
|
|
187
518
|
|
|
519
|
+
/**
|
|
520
|
+
* Options for {@link resolveAIConfig}.
|
|
521
|
+
*
|
|
522
|
+
* @beta
|
|
523
|
+
*/
|
|
188
524
|
export declare interface ResolveAIConfigOptions {
|
|
189
|
-
/** Cloud provider (openai). Default: openai */
|
|
190
|
-
provider?: 'openai';
|
|
525
|
+
/** Cloud provider (openai, gemini). Default: openai */
|
|
526
|
+
provider?: 'openai' | 'gemini';
|
|
191
527
|
/** Model name (e.g. gpt-4o-mini). Default: gpt-4o-mini */
|
|
192
528
|
model?: string;
|
|
193
529
|
/** Prefer Chrome built-in AI when available */
|
|
@@ -214,6 +550,23 @@ declare type SpeechRecognitionErrorHandler = (error: string) => void;
|
|
|
214
550
|
|
|
215
551
|
declare type SpeechRecognitionResultHandler = (transcript: string, isFinal: boolean) => void;
|
|
216
552
|
|
|
553
|
+
/**
|
|
554
|
+
* Starts continuous speech recognition, calling `onResult` with each transcript update.
|
|
555
|
+
* Returns a stop function, or null if speech recognition is unavailable.
|
|
556
|
+
*
|
|
557
|
+
* @beta
|
|
558
|
+
*/
|
|
217
559
|
export declare function startSpeechRecognition(onResult: SpeechRecognitionResultHandler, onError?: SpeechRecognitionErrorHandler): (() => void) | null;
|
|
218
560
|
|
|
561
|
+
/**
|
|
562
|
+
* Options for sending a structured prompt to an AI provider.
|
|
563
|
+
*
|
|
564
|
+
* @beta
|
|
565
|
+
*/
|
|
566
|
+
declare interface StructuredPromptOptions {
|
|
567
|
+
systemPrompt: string;
|
|
568
|
+
userPrompt: string;
|
|
569
|
+
responseSchema?: object;
|
|
570
|
+
}
|
|
571
|
+
|
|
219
572
|
export { }
|
|
@@ -12,7 +12,7 @@ Union type for provider-specific configs. Extend when adding new providers.
|
|
|
12
12
|
**Signature:**
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
|
-
export type AIConfig = ServerAIConfig | ChromeAIConfig;
|
|
15
|
+
export type AIConfig = ServerAIConfig | ChromeAIConfig | GeminiAIConfig;
|
|
16
16
|
```
|
|
17
|
-
**References:** [ServerAIConfig](./foundation-ai.serveraiconfig.md)<!-- -->, [ChromeAIConfig](./foundation-ai.chromeaiconfig.md)
|
|
17
|
+
**References:** [ServerAIConfig](./foundation-ai.serveraiconfig.md)<!-- -->, [ChromeAIConfig](./foundation-ai.chromeaiconfig.md)<!-- -->, [GeminiAIConfig](./foundation-ai.geminiaiconfig.md)
|
|
18
18
|
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-ai](./foundation-ai.md) > [AIProvider](./foundation-ai.aiprovider.md) > [chat](./foundation-ai.aiprovider.chat.md)
|
|
4
|
+
|
|
5
|
+
## AIProvider.chat() method
|
|
6
|
+
|
|
7
|
+
> This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
|
|
8
|
+
>
|
|
9
|
+
|
|
10
|
+
Multi-turn chat (non-streaming). Returns the assistant's response message. Providers that support chat (Gemini, OpenAI) implement this.
|
|
11
|
+
|
|
12
|
+
**Signature:**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
chat?(history: ChatMessage[], userMessage: string, options?: ChatRequestOptions): Promise<ChatMessage>;
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Parameters
|
|
19
|
+
|
|
20
|
+
<table><thead><tr><th>
|
|
21
|
+
|
|
22
|
+
Parameter
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
</th><th>
|
|
26
|
+
|
|
27
|
+
Type
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
</th><th>
|
|
31
|
+
|
|
32
|
+
Description
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
</th></tr></thead>
|
|
36
|
+
<tbody><tr><td>
|
|
37
|
+
|
|
38
|
+
history
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
</td><td>
|
|
42
|
+
|
|
43
|
+
[ChatMessage](./foundation-ai.chatmessage.md)<!-- -->\[\]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
</td><td>
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
</td></tr>
|
|
50
|
+
<tr><td>
|
|
51
|
+
|
|
52
|
+
userMessage
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
</td><td>
|
|
56
|
+
|
|
57
|
+
string
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
</td><td>
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
</td></tr>
|
|
64
|
+
<tr><td>
|
|
65
|
+
|
|
66
|
+
options
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
</td><td>
|
|
70
|
+
|
|
71
|
+
[ChatRequestOptions](./foundation-ai.chatrequestoptions.md)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
</td><td>
|
|
75
|
+
|
|
76
|
+
_(Optional)_
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
</td></tr>
|
|
80
|
+
</tbody></table>
|
|
81
|
+
|
|
82
|
+
**Returns:**
|
|
83
|
+
|
|
84
|
+
Promise<[ChatMessage](./foundation-ai.chatmessage.md)<!-- -->>
|
|
85
|
+
|
|
@@ -34,6 +34,17 @@ Description
|
|
|
34
34
|
</th></tr></thead>
|
|
35
35
|
<tbody><tr><td>
|
|
36
36
|
|
|
37
|
+
[chat(history, userMessage, options)?](./foundation-ai.aiprovider.chat.md)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
</td><td>
|
|
41
|
+
|
|
42
|
+
**_(BETA)_** _(Optional)_ Multi-turn chat (non-streaming). Returns the assistant's response message. Providers that support chat (Gemini, OpenAI) implement this.
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
</td></tr>
|
|
46
|
+
<tr><td>
|
|
47
|
+
|
|
37
48
|
[getStatus()?](./foundation-ai.aiprovider.getstatus.md)
|
|
38
49
|
|
|
39
50
|
|
|
@@ -53,6 +64,17 @@ Description
|
|
|
53
64
|
**_(BETA)_** _(Optional)_
|
|
54
65
|
|
|
55
66
|
|
|
67
|
+
</td></tr>
|
|
68
|
+
<tr><td>
|
|
69
|
+
|
|
70
|
+
[streamChat(history, userMessage, options)?](./foundation-ai.aiprovider.streamchat.md)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
</td><td>
|
|
74
|
+
|
|
75
|
+
**_(BETA)_** _(Optional)_ Multi-turn chat (streaming). Yields chunks as they arrive. Providers that support streaming implement this.
|
|
76
|
+
|
|
77
|
+
|
|
56
78
|
</td></tr>
|
|
57
79
|
<tr><td>
|
|
58
80
|
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-ai](./foundation-ai.md) > [AIProvider](./foundation-ai.aiprovider.md) > [streamChat](./foundation-ai.aiprovider.streamchat.md)
|
|
4
|
+
|
|
5
|
+
## AIProvider.streamChat() method
|
|
6
|
+
|
|
7
|
+
> This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
|
|
8
|
+
>
|
|
9
|
+
|
|
10
|
+
Multi-turn chat (streaming). Yields chunks as they arrive. Providers that support streaming implement this.
|
|
11
|
+
|
|
12
|
+
**Signature:**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
streamChat?(history: ChatMessage[], userMessage: string, options?: ChatRequestOptions): AsyncIterable<ChatStreamChunk>;
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Parameters
|
|
19
|
+
|
|
20
|
+
<table><thead><tr><th>
|
|
21
|
+
|
|
22
|
+
Parameter
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
</th><th>
|
|
26
|
+
|
|
27
|
+
Type
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
</th><th>
|
|
31
|
+
|
|
32
|
+
Description
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
</th></tr></thead>
|
|
36
|
+
<tbody><tr><td>
|
|
37
|
+
|
|
38
|
+
history
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
</td><td>
|
|
42
|
+
|
|
43
|
+
[ChatMessage](./foundation-ai.chatmessage.md)<!-- -->\[\]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
</td><td>
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
</td></tr>
|
|
50
|
+
<tr><td>
|
|
51
|
+
|
|
52
|
+
userMessage
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
</td><td>
|
|
56
|
+
|
|
57
|
+
string
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
</td><td>
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
</td></tr>
|
|
64
|
+
<tr><td>
|
|
65
|
+
|
|
66
|
+
options
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
</td><td>
|
|
70
|
+
|
|
71
|
+
[ChatRequestOptions](./foundation-ai.chatrequestoptions.md)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
</td><td>
|
|
75
|
+
|
|
76
|
+
_(Optional)_
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
</td></tr>
|
|
80
|
+
</tbody></table>
|
|
81
|
+
|
|
82
|
+
**Returns:**
|
|
83
|
+
|
|
84
|
+
AsyncIterable<[ChatStreamChunk](./foundation-ai.chatstreamchunk.md)<!-- -->>
|
|
85
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-ai](./foundation-ai.md) > [ChatAnimationsConfig](./foundation-ai.chatanimationsconfig.md) > [enabled](./foundation-ai.chatanimationsconfig.enabled.md)
|
|
4
|
+
|
|
5
|
+
## ChatAnimationsConfig.enabled property
|
|
6
|
+
|
|
7
|
+
> This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
|
|
8
|
+
>
|
|
9
|
+
|
|
10
|
+
Initially enabled animations. When omitted all animations are enabled by default.
|
|
11
|
+
|
|
12
|
+
**Signature:**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
enabled?: string[];
|
|
16
|
+
```
|