@genesislcap/foundation-ai 14.409.0-FUI-2495.2 → 14.409.0-FUI-2495.3
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 +10 -2
- package/dist/dts/ai-provider.d.ts.map +1 -1
- package/dist/dts/index.d.ts +3 -2
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/providers/gemini-provider.d.ts +1 -0
- package/dist/dts/providers/gemini-provider.d.ts.map +1 -1
- package/dist/dts/transports/gemini-transport.d.ts +6 -5
- package/dist/dts/transports/gemini-transport.d.ts.map +1 -1
- package/dist/dts/types/chat.types.d.ts +31 -0
- package/dist/dts/types/chat.types.d.ts.map +1 -1
- package/dist/dts/types/config.types.d.ts +10 -1
- package/dist/dts/types/config.types.d.ts.map +1 -1
- package/dist/esm/ai-provider.js +8 -3
- package/dist/esm/index.js +1 -0
- package/dist/esm/providers/gemini-provider.js +6 -0
- package/dist/esm/transports/gemini-transport.js +29 -10
- package/dist/esm/types/config.types.js +5 -1
- package/dist/foundation-ai.api.json +265 -6
- package/dist/foundation-ai.d.ts +59 -6
- package/package.json +11 -11
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CriteriaInterpretContext } from './interactions';
|
|
2
|
-
import type
|
|
2
|
+
import { type AIConfig, type AIStatus, type CriteriaInterpretationResult } from './types';
|
|
3
3
|
import type { ChatMessage, ChatRequestOptions, ChatStreamChunk } from './types/chat.types';
|
|
4
4
|
/**
|
|
5
5
|
* AI Provider interface for foundation-ai.
|
|
@@ -21,6 +21,14 @@ export interface AIProvider {
|
|
|
21
21
|
* Must be called from a user gesture (e.g. click).
|
|
22
22
|
*/
|
|
23
23
|
triggerDownload?(): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Stateless one-off prompt. No conversation history is maintained.
|
|
26
|
+
* Returns the plain text response.
|
|
27
|
+
* Use this for side-calls (suggestions, summarisation, classification) that
|
|
28
|
+
* should not interact with any ongoing conversation context.
|
|
29
|
+
* Providers that support chat implement this.
|
|
30
|
+
*/
|
|
31
|
+
prompt?(message: string, options?: ChatRequestOptions): Promise<string>;
|
|
24
32
|
/**
|
|
25
33
|
* Multi-turn chat (non-streaming). Returns the assistant's response message.
|
|
26
34
|
* Providers that support chat (Gemini, OpenAI) implement this.
|
|
@@ -50,7 +58,7 @@ export declare function createAIProvider(config?: AIConfig | null): AIProvider;
|
|
|
50
58
|
export interface ResolveAIConfigOptions {
|
|
51
59
|
/** Cloud provider (openai, gemini). Default: openai */
|
|
52
60
|
provider?: 'openai' | 'gemini';
|
|
53
|
-
/** Model name
|
|
61
|
+
/** Model name. OpenAI default: gpt-4o-mini. Gemini: only {@link SUPPORTED_GEMINI_MODEL_IDS} (default flash-lite). */
|
|
54
62
|
model?: string;
|
|
55
63
|
/** Prefer Chrome built-in AI when available */
|
|
56
64
|
preferChrome?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-provider.d.ts","sourceRoot":"","sources":["../../src/ai-provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAQ/D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"ai-provider.d.ts","sourceRoot":"","sources":["../../src/ai-provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAQ/D,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,QAAQ,EAEb,KAAK,4BAA4B,EAIlC,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAI3F;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAU;IACzB,iBAAiB,CAAC,CAChB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,4BAA4B,GAAG,IAAI,CAAC,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getAIProvider, resolveAIConfig } from './
|
|
|
2
2
|
export { GeminiProvider } from './providers/gemini-provider';
|
|
3
3
|
export { GeminiTransport, MalformedFunctionCallError } from './transports/gemini-transport';
|
|
4
4
|
export { AI_FEATURE_FLAG, isAIFeatureEnabled } from './utils/feature-flags';
|
|
5
|
-
export
|
|
6
|
-
export type {
|
|
5
|
+
export { SUPPORTED_GEMINI_MODEL_IDS } from './types';
|
|
6
|
+
export type { AIConfig, AIStatus, AIProviderType, ChromeAIConfig, ChromeAvailability, GeminiAIConfig, GeminiModelId, ServerAIConfig, } from './types';
|
|
7
|
+
export type { ChatAgentConfig, ChatAnimationsConfig, ChatAttachment, ChatConfig, ChatDriverResult, ChatMessage, ChatInteraction, ChatRequestOptions, ChatRole, ChatStreamChunk, ChatToolCall, ChatToolDefinition, ChatToolHandlers, ChatToolResult, ChatUiConfig, ChatSuggestionsConfig, InteractionResult, } from './types/chat.types';
|
|
7
8
|
export type { ChatTransport } from './types/chat-transport.types';
|
|
8
9
|
export type { ResolveAIConfigOptions } from './ai-provider';
|
|
9
10
|
export type { CriteriaInterpretContext, FieldLike } from './interactions';
|
package/dist/dts/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,YAAY,EACV,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,eAAe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AChB,cAAc,EACd,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,YAAY,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC5D,YAAY,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC1E,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -19,6 +19,7 @@ export declare class GeminiProvider implements AIProvider {
|
|
|
19
19
|
constructor(config: GeminiProviderConfig, transport: GeminiTransport);
|
|
20
20
|
getStatus(): Promise<AIStatus>;
|
|
21
21
|
interpretCriteria(input: string, context: CriteriaInterpretContext): Promise<CriteriaInterpretationResult | null>;
|
|
22
|
+
prompt(message: string, options?: ChatRequestOptions): Promise<string>;
|
|
22
23
|
chat(history: ChatMessage[], userMessage: string, options?: ChatRequestOptions): Promise<ChatMessage>;
|
|
23
24
|
streamChat(history: ChatMessage[], userMessage: string, options?: ChatRequestOptions): AsyncIterable<ChatStreamChunk>;
|
|
24
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gemini-provider.d.ts","sourceRoot":"","sources":["../../../src/providers/gemini-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAOhE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC5F,OA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nC,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;;;;GAKG;AACH,qBAAa,cAAe,YAAW,UAAU;IAC/C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;IAC5C,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAS;gBAEnC,MAAM,EAAE,oBAAoB,EAAE,SAAS,EAAE,eAAe;IAK9D,SAAS,IAAI,OAAO,CAAC,QAAQ,CAAC;IAK9B,iBAAiB,CACrB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,4BAA4B,GAAG,IAAI,CAAC;IAkBzC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;IAKtE,IAAI,CACR,OAAO,EAAE,WAAW,EAAE,EACtB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,WAAW,CAAC;IAIhB,UAAU,CACf,OAAO,EAAE,WAAW,EAAE,EACtB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,aAAa,CAAC,eAAe,CAAC;CAYlC"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AITransport, type GeminiModelId, type StructuredPromptOptions } from '../types';
|
|
2
2
|
import type { ChatTransport } from '../types/chat-transport.types';
|
|
3
3
|
import type { ChatMessage, ChatRequestOptions } from '../types/chat.types';
|
|
4
4
|
export interface GeminiTransportConfig {
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Defaults to `gemini-2.5-flash-lite`. Only {@link SUPPORTED_GEMINI_MODEL_IDS} are accepted.
|
|
7
|
+
*/
|
|
8
|
+
model?: GeminiModelId;
|
|
6
9
|
timeout?: number;
|
|
7
10
|
/**
|
|
8
11
|
* API key for direct calls to the Gemini API.
|
|
@@ -45,13 +48,11 @@ export declare class GeminiTransport implements AITransport, ChatTransport {
|
|
|
45
48
|
constructor(config?: GeminiTransportConfig);
|
|
46
49
|
getConfig(): {
|
|
47
50
|
provider: 'gemini';
|
|
48
|
-
model:
|
|
51
|
+
model: GeminiModelId;
|
|
49
52
|
};
|
|
50
53
|
sendStructuredPrompt(options: StructuredPromptOptions): Promise<string>;
|
|
51
54
|
sendChatMessage(history: ChatMessage[], userMessage: string, options?: ChatRequestOptions): Promise<ChatMessage>;
|
|
52
55
|
private static readonly TOKENS_PER_MILLION;
|
|
53
|
-
private static readonly PROMPT_COST_PER_MILLION;
|
|
54
|
-
private static readonly CANDIDATE_COST_PER_MILLION;
|
|
55
56
|
private static readonly COST_DECIMAL_PLACES;
|
|
56
57
|
private logTokenUsage;
|
|
57
58
|
private toGeminiContents;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gemini-transport.d.ts","sourceRoot":"","sources":["../../../src/transports/gemini-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"gemini-transport.d.ts","sourceRoot":"","sources":["../../../src/transports/gemini-transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC7B,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAEV,WAAW,EACX,kBAAkB,EAEnB,MAAM,qBAAqB,CAAC;AA6B7B,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAUD;;;;;;GAMG;AACH,qBAAa,0BAA2B,SAAQ,KAAK;IACvC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM;gBAAtB,aAAa,CAAC,EAAE,MAAM;CAI5C;AAED;;;;;;;;GAQG;AACH,qBAAa,eAAgB,YAAW,WAAW,EAAE,aAAa;IAChE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAC5C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAqB;gBAExC,MAAM,GAAE,qBAA0B;IAe9C,SAAS,IAAI;QAAE,QAAQ,EAAE,QAAQ,CAAC;QAAC,KAAK,EAAE,aAAa,CAAA;KAAE;IAMnD,oBAAoB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC;IAgBvE,eAAe,CACnB,OAAO,EAAE,WAAW,EAAE,EACtB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,WAAW,CAAC;IA4BvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAa;IACvD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAK;IAEhD,OAAO,CAAC,aAAa;IAoBrB,OAAO,CAAC,gBAAgB;IAgDxB,OAAO,CAAC,kBAAkB;IAwD1B,OAAO,CAAC,aAAa;IAyBrB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAK;IACxC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAO;IAChD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAQ;YAEjC,IAAI;IAgDlB,OAAO,CAAC,eAAe;CAexB"}
|
|
@@ -199,5 +199,36 @@ export interface ChatConfig {
|
|
|
199
199
|
ui?: ChatUiConfig;
|
|
200
200
|
/** Agent engine settings — iteration limits, handoff caps, classifier tuning. */
|
|
201
201
|
agent?: ChatAgentConfig;
|
|
202
|
+
/** Query suggestions feature configuration. */
|
|
203
|
+
suggestions?: ChatSuggestionsConfig;
|
|
202
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* Configuration for the chat suggestions feature.
|
|
207
|
+
*
|
|
208
|
+
* @beta
|
|
209
|
+
*/
|
|
210
|
+
export type ChatSuggestionsConfig = {
|
|
211
|
+
/** Suggestions are disabled. */
|
|
212
|
+
behavior: 'never';
|
|
213
|
+
/** Not applicable when behavior is 'never'. */
|
|
214
|
+
count?: never;
|
|
215
|
+
/** Not applicable when behavior is 'never'. */
|
|
216
|
+
prompt?: never;
|
|
217
|
+
} | {
|
|
218
|
+
/**
|
|
219
|
+
* 'initial': Show suggestions on first load before any messages are sent.
|
|
220
|
+
* 'always': Show suggestions after every assistant response.
|
|
221
|
+
*/
|
|
222
|
+
behavior: 'initial' | 'always';
|
|
223
|
+
/**
|
|
224
|
+
* Number of suggestions to generate.
|
|
225
|
+
* @default 3
|
|
226
|
+
*/
|
|
227
|
+
count?: number;
|
|
228
|
+
/**
|
|
229
|
+
* Custom prompt to steer the suggestion generation. If omitted, a
|
|
230
|
+
* default prompt is used.
|
|
231
|
+
*/
|
|
232
|
+
prompt?: string;
|
|
233
|
+
};
|
|
203
234
|
//# sourceMappingURL=chat.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.types.d.ts","sourceRoot":"","sources":["../../../src/types/chat.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,GAAG,cAAc,CAAC;AAEjF;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,OA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;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,mEAAmE;IACnE,EAAE,CAAC,EAAE,YAAY,CAAC;IAClB,iFAAiF;IACjF,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,qBAAqB,CAAC;CACrC;AAED;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAC7B;IACE,gCAAgC;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,+CAA+C;IAC/C,MAAM,CAAC,EAAE,KAAK,CAAC;CAChB,GACD;IACE;;;OAGG;IACH,QAAQ,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC/B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
* @beta
|
|
5
5
|
*/
|
|
6
6
|
export type AIProviderType = 'openai' | 'chrome' | 'gemini' | 'none';
|
|
7
|
+
/**
|
|
8
|
+
* Gemini REST model ids supported by {@link GeminiTransport}.
|
|
9
|
+
*
|
|
10
|
+
* @beta
|
|
11
|
+
*/
|
|
12
|
+
export type GeminiModelId = 'gemini-2.5-flash' | 'gemini-2.5-flash-lite';
|
|
13
|
+
/** @beta */
|
|
14
|
+
export declare const SUPPORTED_GEMINI_MODEL_IDS: readonly GeminiModelId[];
|
|
7
15
|
/**
|
|
8
16
|
* Base provider-level configuration.
|
|
9
17
|
*
|
|
@@ -56,7 +64,8 @@ export interface ChromeAIConfig extends AIProviderConfig {
|
|
|
56
64
|
*/
|
|
57
65
|
export interface GeminiAIConfig extends AIProviderConfig {
|
|
58
66
|
providerType: 'gemini';
|
|
59
|
-
|
|
67
|
+
/** Defaults to `gemini-2.5-flash-lite`. Only {@link SUPPORTED_GEMINI_MODEL_IDS} are accepted at runtime. */
|
|
68
|
+
model?: GeminiModelId;
|
|
60
69
|
serverEndpoint?: string;
|
|
61
70
|
apiKey?: string;
|
|
62
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.types.d.ts","sourceRoot":"","sources":["../../../src/types/config.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;AAErE;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,6DAA6D;AAC7D,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;AAErE;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAe,SAAQ,gBAAgB;IACtD,QAAQ,EAAE,oBAAoB,CAAC;CAChC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,cAAe,SAAQ,gBAAgB;IACtD,YAAY,CAAC,EAAE,QAAQ,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,cAAe,SAAQ,gBAAgB;IACtD,YAAY,EAAE,QAAQ,CAAC;IACvB,KAAK,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"config.types.d.ts","sourceRoot":"","sources":["../../../src/types/config.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;AAErE;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,kBAAkB,GAAG,uBAAuB,CAAC;AAEzE,YAAY;AACZ,eAAO,MAAM,0BAA0B,EAAE,SAAS,aAAa,EAGrD,CAAC;AAEX;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,6DAA6D;AAC7D,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;AAErE;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAe,SAAQ,gBAAgB;IACtD,QAAQ,EAAE,oBAAoB,CAAC;CAChC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,cAAe,SAAQ,gBAAgB;IACtD,YAAY,CAAC,EAAE,QAAQ,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,cAAe,SAAQ,gBAAgB;IACtD,YAAY,EAAE,QAAQ,CAAC;IACvB,4GAA4G;IAC5G,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,cAAc,GAAG,cAAc,GAAG,cAAc,CAAC"}
|
package/dist/esm/ai-provider.js
CHANGED
|
@@ -7,6 +7,7 @@ import { OpenAIProvider } from './providers/openai-provider';
|
|
|
7
7
|
import { ChromePromptTransport } from './transports/chrome-prompt-transport';
|
|
8
8
|
import { GeminiTransport } from './transports/gemini-transport';
|
|
9
9
|
import { ServerOpenAITransport } from './transports/server-openai-transport';
|
|
10
|
+
import { SUPPORTED_GEMINI_MODEL_IDS, } from './types';
|
|
10
11
|
import { logger } from './utils';
|
|
11
12
|
import { isAIFeatureEnabled } from './utils/feature-flags';
|
|
12
13
|
function isChromeConfig(config) {
|
|
@@ -74,7 +75,7 @@ export function resolveAIConfig() {
|
|
|
74
75
|
logger.warn('resolveAIConfig: AI feature flag disabled');
|
|
75
76
|
return null;
|
|
76
77
|
}
|
|
77
|
-
const { provider = 'openai', model
|
|
78
|
+
const { provider = 'openai', model, preferChrome = true } = options;
|
|
78
79
|
if (preferChrome) {
|
|
79
80
|
const transport = new ChromePromptTransport();
|
|
80
81
|
const availability = yield transport.getAvailability();
|
|
@@ -86,9 +87,13 @@ export function resolveAIConfig() {
|
|
|
86
87
|
logger.warn('resolveAIConfig: Chrome not available', availability);
|
|
87
88
|
}
|
|
88
89
|
if (provider === 'gemini') {
|
|
89
|
-
|
|
90
|
+
const geminiModel = model !== null && model !== void 0 ? model : 'gemini-2.5-flash-lite';
|
|
91
|
+
if (!SUPPORTED_GEMINI_MODEL_IDS.includes(geminiModel)) {
|
|
92
|
+
throw new Error(`resolveAIConfig: unsupported Gemini model "${geminiModel}". Use one of: ${SUPPORTED_GEMINI_MODEL_IDS.join(', ')}.`);
|
|
93
|
+
}
|
|
94
|
+
return { providerType: 'gemini', model: geminiModel };
|
|
90
95
|
}
|
|
91
|
-
return { provider, model };
|
|
96
|
+
return { provider, model: model !== null && model !== void 0 ? model : 'gpt-4o-mini' };
|
|
92
97
|
});
|
|
93
98
|
}
|
|
94
99
|
/**
|
package/dist/esm/index.js
CHANGED
|
@@ -2,4 +2,5 @@ export { AIProvider, createAIProvider, getAIProvider, resolveAIConfig } from './
|
|
|
2
2
|
export { GeminiProvider } from './providers/gemini-provider';
|
|
3
3
|
export { GeminiTransport, MalformedFunctionCallError } from './transports/gemini-transport';
|
|
4
4
|
export { AI_FEATURE_FLAG, isAIFeatureEnabled } from './utils/feature-flags';
|
|
5
|
+
export { SUPPORTED_GEMINI_MODEL_IDS } from './types';
|
|
5
6
|
export { isSpeechRecognitionAvailable, startSpeechRecognition } from './utils/speech-to-text';
|
|
@@ -38,6 +38,12 @@ export class GeminiProvider {
|
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
+
prompt(message, options) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const response = yield this.transport.sendChatMessage([], message, options);
|
|
44
|
+
return response.content;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
41
47
|
chat(history, userMessage, options) {
|
|
42
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
49
|
return this.transport.sendChatMessage(history, userMessage, options);
|
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
+
import { SUPPORTED_GEMINI_MODEL_IDS, } from '../types';
|
|
3
|
+
import { logger } from '../utils/logger';
|
|
2
4
|
const GEMINI_DIRECT_URL = (model) => `https://generativelanguage.googleapis.com/v1beta/models/${model}:generateContent`;
|
|
3
|
-
const DEFAULT_MODEL = 'gemini-2.
|
|
5
|
+
const DEFAULT_MODEL = 'gemini-2.5-flash-lite';
|
|
4
6
|
const DEFAULT_TIMEOUT = 180000; // 3 minutes
|
|
7
|
+
function assertSupportedGeminiModel(model) {
|
|
8
|
+
if (!SUPPORTED_GEMINI_MODEL_IDS.includes(model)) {
|
|
9
|
+
throw new Error(`GeminiTransport: unsupported model "${model}". Use one of: ${SUPPORTED_GEMINI_MODEL_IDS.join(', ')}.`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Paid Standard tier for supported models — https://ai.google.dev/gemini-api/docs/pricing
|
|
14
|
+
*/
|
|
15
|
+
function estimatedGeminiPaidRatesUsdPerMillion(model) {
|
|
16
|
+
if (model === 'gemini-2.5-flash-lite') {
|
|
17
|
+
return { promptPerMillion: 0.1, candidatePerMillion: 0.4 };
|
|
18
|
+
}
|
|
19
|
+
return { promptPerMillion: 0.3, candidatePerMillion: 2.5 };
|
|
20
|
+
}
|
|
5
21
|
/**
|
|
6
22
|
* Thrown when Gemini returns a `MALFORMED_FUNCTION_CALL` finish reason,
|
|
7
23
|
* typically because the model tried to batch multiple tool calls using
|
|
@@ -28,7 +44,12 @@ export class MalformedFunctionCallError extends Error {
|
|
|
28
44
|
export class GeminiTransport {
|
|
29
45
|
constructor(config = {}) {
|
|
30
46
|
var _a, _b;
|
|
31
|
-
|
|
47
|
+
const model = (_a = config.model) !== null && _a !== void 0 ? _a : DEFAULT_MODEL;
|
|
48
|
+
assertSupportedGeminiModel(model);
|
|
49
|
+
this.model = model;
|
|
50
|
+
if (model === 'gemini-2.5-flash') {
|
|
51
|
+
logger.warn('GeminiTransport: using gemini-2.5-flash — higher cost than flash-lite; use for harder reasoning or agent tasks.');
|
|
52
|
+
}
|
|
32
53
|
this.timeout = (_b = config.timeout) !== null && _b !== void 0 ? _b : DEFAULT_TIMEOUT;
|
|
33
54
|
this.apiKey = config.apiKey;
|
|
34
55
|
this.serverEndpoint = config.serverEndpoint;
|
|
@@ -75,11 +96,11 @@ export class GeminiTransport {
|
|
|
75
96
|
});
|
|
76
97
|
}
|
|
77
98
|
logTokenUsage(promptTokens, candidateTokens) {
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
|
|
99
|
+
const { promptPerMillion, candidatePerMillion } = estimatedGeminiPaidRatesUsdPerMillion(this.model);
|
|
100
|
+
const promptCost = (promptTokens / GeminiTransport.TOKENS_PER_MILLION) * promptPerMillion;
|
|
101
|
+
const candidateCost = (candidateTokens / GeminiTransport.TOKENS_PER_MILLION) * candidatePerMillion;
|
|
81
102
|
const totalCost = promptCost + candidateCost;
|
|
82
|
-
console.log(
|
|
103
|
+
console.log(`--- Gemini Token Usage (${this.model}) ---`);
|
|
83
104
|
console.log(`Prompt Tokens: ${promptTokens} ($${promptCost.toFixed(GeminiTransport.COST_DECIMAL_PLACES)})`);
|
|
84
105
|
console.log(`Candidate Tokens: ${candidateTokens} ($${candidateCost.toFixed(GeminiTransport.COST_DECIMAL_PLACES)})`);
|
|
85
106
|
console.log(`Total Cost: $${totalCost.toFixed(GeminiTransport.COST_DECIMAL_PLACES)}`);
|
|
@@ -89,7 +110,7 @@ export class GeminiTransport {
|
|
|
89
110
|
var _a, _b;
|
|
90
111
|
const contents = [];
|
|
91
112
|
for (const msg of history) {
|
|
92
|
-
if (msg.role === 'system' || msg.thinking)
|
|
113
|
+
if (msg.role === 'system' || msg.role === 'system-event' || msg.thinking)
|
|
93
114
|
continue;
|
|
94
115
|
const role = msg.role === 'user' ? 'user' : 'model';
|
|
95
116
|
if (msg.toolResult) {
|
|
@@ -163,7 +184,7 @@ export class GeminiTransport {
|
|
|
163
184
|
}
|
|
164
185
|
// For tool-call responses, surface thought parts as `content` so the UI can
|
|
165
186
|
// render them as a collapsible thinking block. Fall back to text narration
|
|
166
|
-
// (textParts) for models that don't emit native thought parts (e.g.
|
|
187
|
+
// (textParts) for models that don't emit native thought parts (e.g. some Flash models)
|
|
167
188
|
// but do narrate alongside tool calls when prompted to do so.
|
|
168
189
|
// For final answers, surface only the response text.
|
|
169
190
|
return toolCalls.length > 0
|
|
@@ -241,8 +262,6 @@ export class GeminiTransport {
|
|
|
241
262
|
}
|
|
242
263
|
// ── Private helpers ────────────────────────────────────────────────────
|
|
243
264
|
GeminiTransport.TOKENS_PER_MILLION = 1000000;
|
|
244
|
-
GeminiTransport.PROMPT_COST_PER_MILLION = 0.1;
|
|
245
|
-
GeminiTransport.CANDIDATE_COST_PER_MILLION = 0.4;
|
|
246
265
|
GeminiTransport.COST_DECIMAL_PLACES = 6;
|
|
247
266
|
GeminiTransport.MAX_RETRIES = 5;
|
|
248
267
|
GeminiTransport.RATE_LIMIT_STATUS = 429;
|
|
@@ -474,6 +474,73 @@
|
|
|
474
474
|
],
|
|
475
475
|
"name": "interpretCriteria"
|
|
476
476
|
},
|
|
477
|
+
{
|
|
478
|
+
"kind": "MethodSignature",
|
|
479
|
+
"canonicalReference": "@genesislcap/foundation-ai!AIProvider#prompt:member(1)",
|
|
480
|
+
"docComment": "/**\n * Stateless one-off prompt. No conversation history is maintained. Returns the plain text response. Use this for side-calls (suggestions, summarisation, classification) that should not interact with any ongoing conversation context. Providers that support chat implement this.\n */\n",
|
|
481
|
+
"excerptTokens": [
|
|
482
|
+
{
|
|
483
|
+
"kind": "Content",
|
|
484
|
+
"text": "prompt?(message: "
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
"kind": "Content",
|
|
488
|
+
"text": "string"
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
"kind": "Content",
|
|
492
|
+
"text": ", options?: "
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
"kind": "Reference",
|
|
496
|
+
"text": "ChatRequestOptions",
|
|
497
|
+
"canonicalReference": "@genesislcap/foundation-ai!ChatRequestOptions:interface"
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
"kind": "Content",
|
|
501
|
+
"text": "): "
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
"kind": "Reference",
|
|
505
|
+
"text": "Promise",
|
|
506
|
+
"canonicalReference": "!Promise:interface"
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
"kind": "Content",
|
|
510
|
+
"text": "<string>"
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
"kind": "Content",
|
|
514
|
+
"text": ";"
|
|
515
|
+
}
|
|
516
|
+
],
|
|
517
|
+
"isOptional": true,
|
|
518
|
+
"returnTypeTokenRange": {
|
|
519
|
+
"startIndex": 5,
|
|
520
|
+
"endIndex": 7
|
|
521
|
+
},
|
|
522
|
+
"releaseTag": "Beta",
|
|
523
|
+
"overloadIndex": 1,
|
|
524
|
+
"parameters": [
|
|
525
|
+
{
|
|
526
|
+
"parameterName": "message",
|
|
527
|
+
"parameterTypeTokenRange": {
|
|
528
|
+
"startIndex": 1,
|
|
529
|
+
"endIndex": 2
|
|
530
|
+
},
|
|
531
|
+
"isOptional": false
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
"parameterName": "options",
|
|
535
|
+
"parameterTypeTokenRange": {
|
|
536
|
+
"startIndex": 3,
|
|
537
|
+
"endIndex": 4
|
|
538
|
+
},
|
|
539
|
+
"isOptional": true
|
|
540
|
+
}
|
|
541
|
+
],
|
|
542
|
+
"name": "prompt"
|
|
543
|
+
},
|
|
477
544
|
{
|
|
478
545
|
"kind": "MethodSignature",
|
|
479
546
|
"canonicalReference": "@genesislcap/foundation-ai!AIProvider#streamChat:member(1)",
|
|
@@ -1074,6 +1141,34 @@
|
|
|
1074
1141
|
"endIndex": 2
|
|
1075
1142
|
}
|
|
1076
1143
|
},
|
|
1144
|
+
{
|
|
1145
|
+
"kind": "PropertySignature",
|
|
1146
|
+
"canonicalReference": "@genesislcap/foundation-ai!ChatConfig#suggestions:member",
|
|
1147
|
+
"docComment": "/**\n * Query suggestions feature configuration.\n */\n",
|
|
1148
|
+
"excerptTokens": [
|
|
1149
|
+
{
|
|
1150
|
+
"kind": "Content",
|
|
1151
|
+
"text": "suggestions?: "
|
|
1152
|
+
},
|
|
1153
|
+
{
|
|
1154
|
+
"kind": "Reference",
|
|
1155
|
+
"text": "ChatSuggestionsConfig",
|
|
1156
|
+
"canonicalReference": "@genesislcap/foundation-ai!ChatSuggestionsConfig:type"
|
|
1157
|
+
},
|
|
1158
|
+
{
|
|
1159
|
+
"kind": "Content",
|
|
1160
|
+
"text": ";"
|
|
1161
|
+
}
|
|
1162
|
+
],
|
|
1163
|
+
"isReadonly": false,
|
|
1164
|
+
"isOptional": true,
|
|
1165
|
+
"releaseTag": "Beta",
|
|
1166
|
+
"name": "suggestions",
|
|
1167
|
+
"propertyTypeTokenRange": {
|
|
1168
|
+
"startIndex": 1,
|
|
1169
|
+
"endIndex": 2
|
|
1170
|
+
}
|
|
1171
|
+
},
|
|
1077
1172
|
{
|
|
1078
1173
|
"kind": "PropertySignature",
|
|
1079
1174
|
"canonicalReference": "@genesislcap/foundation-ai!ChatConfig#ui:member",
|
|
@@ -1771,6 +1866,32 @@
|
|
|
1771
1866
|
],
|
|
1772
1867
|
"extendsTokenRanges": []
|
|
1773
1868
|
},
|
|
1869
|
+
{
|
|
1870
|
+
"kind": "TypeAlias",
|
|
1871
|
+
"canonicalReference": "@genesislcap/foundation-ai!ChatSuggestionsConfig:type",
|
|
1872
|
+
"docComment": "/**\n * Configuration for the chat suggestions feature.\n *\n * @beta\n */\n",
|
|
1873
|
+
"excerptTokens": [
|
|
1874
|
+
{
|
|
1875
|
+
"kind": "Content",
|
|
1876
|
+
"text": "export type ChatSuggestionsConfig = "
|
|
1877
|
+
},
|
|
1878
|
+
{
|
|
1879
|
+
"kind": "Content",
|
|
1880
|
+
"text": "{\n behavior: 'never';\n count?: never;\n prompt?: never;\n} | {\n behavior: 'initial' | 'always';\n count?: number;\n prompt?: string;\n}"
|
|
1881
|
+
},
|
|
1882
|
+
{
|
|
1883
|
+
"kind": "Content",
|
|
1884
|
+
"text": ";"
|
|
1885
|
+
}
|
|
1886
|
+
],
|
|
1887
|
+
"fileUrlPath": "src/types/chat.types.ts",
|
|
1888
|
+
"releaseTag": "Beta",
|
|
1889
|
+
"name": "ChatSuggestionsConfig",
|
|
1890
|
+
"typeTokenRange": {
|
|
1891
|
+
"startIndex": 1,
|
|
1892
|
+
"endIndex": 2
|
|
1893
|
+
}
|
|
1894
|
+
},
|
|
1774
1895
|
{
|
|
1775
1896
|
"kind": "Interface",
|
|
1776
1897
|
"canonicalReference": "@genesislcap/foundation-ai!ChatToolCall:interface",
|
|
@@ -3102,15 +3223,16 @@
|
|
|
3102
3223
|
{
|
|
3103
3224
|
"kind": "PropertySignature",
|
|
3104
3225
|
"canonicalReference": "@genesislcap/foundation-ai!GeminiAIConfig#model:member",
|
|
3105
|
-
"docComment": "",
|
|
3226
|
+
"docComment": "/**\n * Defaults to `gemini-2.5-flash-lite`. Only {@link SUPPORTED_GEMINI_MODEL_IDS} are accepted at runtime.\n */\n",
|
|
3106
3227
|
"excerptTokens": [
|
|
3107
3228
|
{
|
|
3108
3229
|
"kind": "Content",
|
|
3109
3230
|
"text": "model?: "
|
|
3110
3231
|
},
|
|
3111
3232
|
{
|
|
3112
|
-
"kind": "
|
|
3113
|
-
"text": "
|
|
3233
|
+
"kind": "Reference",
|
|
3234
|
+
"text": "GeminiModelId",
|
|
3235
|
+
"canonicalReference": "@genesislcap/foundation-ai!GeminiModelId:type"
|
|
3114
3236
|
},
|
|
3115
3237
|
{
|
|
3116
3238
|
"kind": "Content",
|
|
@@ -3188,6 +3310,32 @@
|
|
|
3188
3310
|
}
|
|
3189
3311
|
]
|
|
3190
3312
|
},
|
|
3313
|
+
{
|
|
3314
|
+
"kind": "TypeAlias",
|
|
3315
|
+
"canonicalReference": "@genesislcap/foundation-ai!GeminiModelId:type",
|
|
3316
|
+
"docComment": "/**\n * Gemini REST model ids supported by {@link GeminiTransport}.\n *\n * @beta\n */\n",
|
|
3317
|
+
"excerptTokens": [
|
|
3318
|
+
{
|
|
3319
|
+
"kind": "Content",
|
|
3320
|
+
"text": "export type GeminiModelId = "
|
|
3321
|
+
},
|
|
3322
|
+
{
|
|
3323
|
+
"kind": "Content",
|
|
3324
|
+
"text": "'gemini-2.5-flash' | 'gemini-2.5-flash-lite'"
|
|
3325
|
+
},
|
|
3326
|
+
{
|
|
3327
|
+
"kind": "Content",
|
|
3328
|
+
"text": ";"
|
|
3329
|
+
}
|
|
3330
|
+
],
|
|
3331
|
+
"fileUrlPath": "src/types/config.types.ts",
|
|
3332
|
+
"releaseTag": "Beta",
|
|
3333
|
+
"name": "GeminiModelId",
|
|
3334
|
+
"typeTokenRange": {
|
|
3335
|
+
"startIndex": 1,
|
|
3336
|
+
"endIndex": 2
|
|
3337
|
+
}
|
|
3338
|
+
},
|
|
3191
3339
|
{
|
|
3192
3340
|
"kind": "Class",
|
|
3193
3341
|
"canonicalReference": "@genesislcap/foundation-ai!GeminiProvider:class",
|
|
@@ -3487,6 +3635,76 @@
|
|
|
3487
3635
|
"isAbstract": false,
|
|
3488
3636
|
"name": "interpretCriteria"
|
|
3489
3637
|
},
|
|
3638
|
+
{
|
|
3639
|
+
"kind": "Method",
|
|
3640
|
+
"canonicalReference": "@genesislcap/foundation-ai!GeminiProvider#prompt:member(1)",
|
|
3641
|
+
"docComment": "",
|
|
3642
|
+
"excerptTokens": [
|
|
3643
|
+
{
|
|
3644
|
+
"kind": "Content",
|
|
3645
|
+
"text": "prompt(message: "
|
|
3646
|
+
},
|
|
3647
|
+
{
|
|
3648
|
+
"kind": "Content",
|
|
3649
|
+
"text": "string"
|
|
3650
|
+
},
|
|
3651
|
+
{
|
|
3652
|
+
"kind": "Content",
|
|
3653
|
+
"text": ", options?: "
|
|
3654
|
+
},
|
|
3655
|
+
{
|
|
3656
|
+
"kind": "Reference",
|
|
3657
|
+
"text": "ChatRequestOptions",
|
|
3658
|
+
"canonicalReference": "@genesislcap/foundation-ai!ChatRequestOptions:interface"
|
|
3659
|
+
},
|
|
3660
|
+
{
|
|
3661
|
+
"kind": "Content",
|
|
3662
|
+
"text": "): "
|
|
3663
|
+
},
|
|
3664
|
+
{
|
|
3665
|
+
"kind": "Reference",
|
|
3666
|
+
"text": "Promise",
|
|
3667
|
+
"canonicalReference": "!Promise:interface"
|
|
3668
|
+
},
|
|
3669
|
+
{
|
|
3670
|
+
"kind": "Content",
|
|
3671
|
+
"text": "<string>"
|
|
3672
|
+
},
|
|
3673
|
+
{
|
|
3674
|
+
"kind": "Content",
|
|
3675
|
+
"text": ";"
|
|
3676
|
+
}
|
|
3677
|
+
],
|
|
3678
|
+
"isStatic": false,
|
|
3679
|
+
"returnTypeTokenRange": {
|
|
3680
|
+
"startIndex": 5,
|
|
3681
|
+
"endIndex": 7
|
|
3682
|
+
},
|
|
3683
|
+
"releaseTag": "Beta",
|
|
3684
|
+
"isProtected": false,
|
|
3685
|
+
"overloadIndex": 1,
|
|
3686
|
+
"parameters": [
|
|
3687
|
+
{
|
|
3688
|
+
"parameterName": "message",
|
|
3689
|
+
"parameterTypeTokenRange": {
|
|
3690
|
+
"startIndex": 1,
|
|
3691
|
+
"endIndex": 2
|
|
3692
|
+
},
|
|
3693
|
+
"isOptional": false
|
|
3694
|
+
},
|
|
3695
|
+
{
|
|
3696
|
+
"parameterName": "options",
|
|
3697
|
+
"parameterTypeTokenRange": {
|
|
3698
|
+
"startIndex": 3,
|
|
3699
|
+
"endIndex": 4
|
|
3700
|
+
},
|
|
3701
|
+
"isOptional": true
|
|
3702
|
+
}
|
|
3703
|
+
],
|
|
3704
|
+
"isOptional": false,
|
|
3705
|
+
"isAbstract": false,
|
|
3706
|
+
"name": "prompt"
|
|
3707
|
+
},
|
|
3490
3708
|
{
|
|
3491
3709
|
"kind": "Method",
|
|
3492
3710
|
"canonicalReference": "@genesislcap/foundation-ai!GeminiProvider#streamChat:member(1)",
|
|
@@ -3673,7 +3891,16 @@
|
|
|
3673
3891
|
},
|
|
3674
3892
|
{
|
|
3675
3893
|
"kind": "Content",
|
|
3676
|
-
"text": "{\n provider: 'gemini';\n model:
|
|
3894
|
+
"text": "{\n provider: 'gemini';\n model: "
|
|
3895
|
+
},
|
|
3896
|
+
{
|
|
3897
|
+
"kind": "Reference",
|
|
3898
|
+
"text": "GeminiModelId",
|
|
3899
|
+
"canonicalReference": "@genesislcap/foundation-ai!GeminiModelId:type"
|
|
3900
|
+
},
|
|
3901
|
+
{
|
|
3902
|
+
"kind": "Content",
|
|
3903
|
+
"text": ";\n }"
|
|
3677
3904
|
},
|
|
3678
3905
|
{
|
|
3679
3906
|
"kind": "Content",
|
|
@@ -3683,7 +3910,7 @@
|
|
|
3683
3910
|
"isStatic": false,
|
|
3684
3911
|
"returnTypeTokenRange": {
|
|
3685
3912
|
"startIndex": 1,
|
|
3686
|
-
"endIndex":
|
|
3913
|
+
"endIndex": 4
|
|
3687
3914
|
},
|
|
3688
3915
|
"releaseTag": "Beta",
|
|
3689
3916
|
"isProtected": false,
|
|
@@ -4159,7 +4386,7 @@
|
|
|
4159
4386
|
{
|
|
4160
4387
|
"kind": "PropertySignature",
|
|
4161
4388
|
"canonicalReference": "@genesislcap/foundation-ai!ResolveAIConfigOptions#model:member",
|
|
4162
|
-
"docComment": "/**\n * Model name
|
|
4389
|
+
"docComment": "/**\n * Model name. OpenAI default: gpt-4o-mini. Gemini: only {@link SUPPORTED_GEMINI_MODEL_IDS} (default flash-lite).\n */\n",
|
|
4163
4390
|
"excerptTokens": [
|
|
4164
4391
|
{
|
|
4165
4392
|
"kind": "Content",
|
|
@@ -4362,6 +4589,38 @@
|
|
|
4362
4589
|
}
|
|
4363
4590
|
],
|
|
4364
4591
|
"name": "startSpeechRecognition"
|
|
4592
|
+
},
|
|
4593
|
+
{
|
|
4594
|
+
"kind": "Variable",
|
|
4595
|
+
"canonicalReference": "@genesislcap/foundation-ai!SUPPORTED_GEMINI_MODEL_IDS:var",
|
|
4596
|
+
"docComment": "/**\n * @beta\n */\n",
|
|
4597
|
+
"excerptTokens": [
|
|
4598
|
+
{
|
|
4599
|
+
"kind": "Content",
|
|
4600
|
+
"text": "SUPPORTED_GEMINI_MODEL_IDS: "
|
|
4601
|
+
},
|
|
4602
|
+
{
|
|
4603
|
+
"kind": "Content",
|
|
4604
|
+
"text": "readonly "
|
|
4605
|
+
},
|
|
4606
|
+
{
|
|
4607
|
+
"kind": "Reference",
|
|
4608
|
+
"text": "GeminiModelId",
|
|
4609
|
+
"canonicalReference": "@genesislcap/foundation-ai!GeminiModelId:type"
|
|
4610
|
+
},
|
|
4611
|
+
{
|
|
4612
|
+
"kind": "Content",
|
|
4613
|
+
"text": "[]"
|
|
4614
|
+
}
|
|
4615
|
+
],
|
|
4616
|
+
"fileUrlPath": "src/types/config.types.ts",
|
|
4617
|
+
"isReadonly": true,
|
|
4618
|
+
"releaseTag": "Beta",
|
|
4619
|
+
"name": "SUPPORTED_GEMINI_MODEL_IDS",
|
|
4620
|
+
"variableTypeTokenRange": {
|
|
4621
|
+
"startIndex": 1,
|
|
4622
|
+
"endIndex": 4
|
|
4623
|
+
}
|
|
4365
4624
|
}
|
|
4366
4625
|
]
|
|
4367
4626
|
}
|
package/dist/foundation-ai.d.ts
CHANGED
|
@@ -31,6 +31,14 @@ 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
|
+
* Stateless one-off prompt. No conversation history is maintained.
|
|
36
|
+
* Returns the plain text response.
|
|
37
|
+
* Use this for side-calls (suggestions, summarisation, classification) that
|
|
38
|
+
* should not interact with any ongoing conversation context.
|
|
39
|
+
* Providers that support chat implement this.
|
|
40
|
+
*/
|
|
41
|
+
prompt?(message: string, options?: ChatRequestOptions): Promise<string>;
|
|
34
42
|
/**
|
|
35
43
|
* Multi-turn chat (non-streaming). Returns the assistant's response message.
|
|
36
44
|
* Providers that support chat (Gemini, OpenAI) implement this.
|
|
@@ -156,6 +164,8 @@ export declare interface ChatConfig {
|
|
|
156
164
|
ui?: ChatUiConfig;
|
|
157
165
|
/** Agent engine settings — iteration limits, handoff caps, classifier tuning. */
|
|
158
166
|
agent?: ChatAgentConfig;
|
|
167
|
+
/** Query suggestions feature configuration. */
|
|
168
|
+
suggestions?: ChatSuggestionsConfig;
|
|
159
169
|
}
|
|
160
170
|
|
|
161
171
|
/**
|
|
@@ -231,6 +241,36 @@ export declare interface ChatStreamChunk {
|
|
|
231
241
|
toolCalls?: ChatToolCall[];
|
|
232
242
|
}
|
|
233
243
|
|
|
244
|
+
/**
|
|
245
|
+
* Configuration for the chat suggestions feature.
|
|
246
|
+
*
|
|
247
|
+
* @beta
|
|
248
|
+
*/
|
|
249
|
+
export declare type ChatSuggestionsConfig = {
|
|
250
|
+
/** Suggestions are disabled. */
|
|
251
|
+
behavior: 'never';
|
|
252
|
+
/** Not applicable when behavior is 'never'. */
|
|
253
|
+
count?: never;
|
|
254
|
+
/** Not applicable when behavior is 'never'. */
|
|
255
|
+
prompt?: never;
|
|
256
|
+
} | {
|
|
257
|
+
/**
|
|
258
|
+
* 'initial': Show suggestions on first load before any messages are sent.
|
|
259
|
+
* 'always': Show suggestions after every assistant response.
|
|
260
|
+
*/
|
|
261
|
+
behavior: 'initial' | 'always';
|
|
262
|
+
/**
|
|
263
|
+
* Number of suggestions to generate.
|
|
264
|
+
* @default 3
|
|
265
|
+
*/
|
|
266
|
+
count?: number;
|
|
267
|
+
/**
|
|
268
|
+
* Custom prompt to steer the suggestion generation. If omitted, a
|
|
269
|
+
* default prompt is used.
|
|
270
|
+
*/
|
|
271
|
+
prompt?: string;
|
|
272
|
+
};
|
|
273
|
+
|
|
234
274
|
/**
|
|
235
275
|
* A tool call requested by the assistant.
|
|
236
276
|
*
|
|
@@ -419,11 +459,19 @@ export declare type FieldLike = string | {
|
|
|
419
459
|
*/
|
|
420
460
|
export declare interface GeminiAIConfig extends AIProviderConfig {
|
|
421
461
|
providerType: 'gemini';
|
|
422
|
-
|
|
462
|
+
/** Defaults to `gemini-2.5-flash-lite`. Only {@link SUPPORTED_GEMINI_MODEL_IDS} are accepted at runtime. */
|
|
463
|
+
model?: GeminiModelId;
|
|
423
464
|
serverEndpoint?: string;
|
|
424
465
|
apiKey?: string;
|
|
425
466
|
}
|
|
426
467
|
|
|
468
|
+
/**
|
|
469
|
+
* Gemini REST model ids supported by {@link GeminiTransport}.
|
|
470
|
+
*
|
|
471
|
+
* @beta
|
|
472
|
+
*/
|
|
473
|
+
export declare type GeminiModelId = 'gemini-2.5-flash' | 'gemini-2.5-flash-lite';
|
|
474
|
+
|
|
427
475
|
/**
|
|
428
476
|
* Gemini AI provider. Uses {@link GeminiTransport} to handle requests.
|
|
429
477
|
* Implements criteria interpretation and multi-turn chat.
|
|
@@ -436,6 +484,7 @@ export declare class GeminiProvider implements AIProvider {
|
|
|
436
484
|
constructor(config: GeminiProviderConfig, transport: GeminiTransport);
|
|
437
485
|
getStatus(): Promise<AIStatus>;
|
|
438
486
|
interpretCriteria(input: string, context: CriteriaInterpretContext): Promise<CriteriaInterpretationResult | null>;
|
|
487
|
+
prompt(message: string, options?: ChatRequestOptions): Promise<string>;
|
|
439
488
|
chat(history: ChatMessage[], userMessage: string, options?: ChatRequestOptions): Promise<ChatMessage>;
|
|
440
489
|
streamChat(history: ChatMessage[], userMessage: string, options?: ChatRequestOptions): AsyncIterable<ChatStreamChunk>;
|
|
441
490
|
}
|
|
@@ -461,13 +510,11 @@ export declare class GeminiTransport implements AITransport, ChatTransport {
|
|
|
461
510
|
constructor(config?: GeminiTransportConfig);
|
|
462
511
|
getConfig(): {
|
|
463
512
|
provider: 'gemini';
|
|
464
|
-
model:
|
|
513
|
+
model: GeminiModelId;
|
|
465
514
|
};
|
|
466
515
|
sendStructuredPrompt(options: StructuredPromptOptions): Promise<string>;
|
|
467
516
|
sendChatMessage(history: ChatMessage[], userMessage: string, options?: ChatRequestOptions): Promise<ChatMessage>;
|
|
468
517
|
private static readonly TOKENS_PER_MILLION;
|
|
469
|
-
private static readonly PROMPT_COST_PER_MILLION;
|
|
470
|
-
private static readonly CANDIDATE_COST_PER_MILLION;
|
|
471
518
|
private static readonly COST_DECIMAL_PLACES;
|
|
472
519
|
private logTokenUsage;
|
|
473
520
|
private toGeminiContents;
|
|
@@ -481,7 +528,10 @@ export declare class GeminiTransport implements AITransport, ChatTransport {
|
|
|
481
528
|
}
|
|
482
529
|
|
|
483
530
|
declare interface GeminiTransportConfig {
|
|
484
|
-
|
|
531
|
+
/**
|
|
532
|
+
* Defaults to `gemini-2.5-flash-lite`. Only {@link SUPPORTED_GEMINI_MODEL_IDS} are accepted.
|
|
533
|
+
*/
|
|
534
|
+
model?: GeminiModelId;
|
|
485
535
|
timeout?: number;
|
|
486
536
|
/**
|
|
487
537
|
* API key for direct calls to the Gemini API.
|
|
@@ -573,7 +623,7 @@ export declare function resolveAIConfig(options?: ResolveAIConfigOptions): Promi
|
|
|
573
623
|
export declare interface ResolveAIConfigOptions {
|
|
574
624
|
/** Cloud provider (openai, gemini). Default: openai */
|
|
575
625
|
provider?: 'openai' | 'gemini';
|
|
576
|
-
/** Model name
|
|
626
|
+
/** Model name. OpenAI default: gpt-4o-mini. Gemini: only {@link SUPPORTED_GEMINI_MODEL_IDS} (default flash-lite). */
|
|
577
627
|
model?: string;
|
|
578
628
|
/** Prefer Chrome built-in AI when available */
|
|
579
629
|
preferChrome?: boolean;
|
|
@@ -618,4 +668,7 @@ declare interface StructuredPromptOptions {
|
|
|
618
668
|
responseSchema?: object;
|
|
619
669
|
}
|
|
620
670
|
|
|
671
|
+
/** @beta */
|
|
672
|
+
export declare const SUPPORTED_GEMINI_MODEL_IDS: readonly GeminiModelId[];
|
|
673
|
+
|
|
621
674
|
export { }
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genesislcap/foundation-ai",
|
|
3
3
|
"description": "Genesis Foundation AI - Provider-agnostic AI configuration and shared utilities",
|
|
4
|
-
"version": "14.409.0-FUI-2495.
|
|
4
|
+
"version": "14.409.0-FUI-2495.3",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "SEE LICENSE IN license.txt",
|
|
7
7
|
"main": "dist/esm/index.js",
|
|
@@ -51,17 +51,17 @@
|
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@genesislcap/foundation-testing": "14.409.0-FUI-2495.
|
|
55
|
-
"@genesislcap/genx": "14.409.0-FUI-2495.
|
|
56
|
-
"@genesislcap/rollup-builder": "14.409.0-FUI-2495.
|
|
57
|
-
"@genesislcap/ts-builder": "14.409.0-FUI-2495.
|
|
58
|
-
"@genesislcap/uvu-playwright-builder": "14.409.0-FUI-2495.
|
|
59
|
-
"@genesislcap/vite-builder": "14.409.0-FUI-2495.
|
|
60
|
-
"@genesislcap/webpack-builder": "14.409.0-FUI-2495.
|
|
54
|
+
"@genesislcap/foundation-testing": "14.409.0-FUI-2495.3",
|
|
55
|
+
"@genesislcap/genx": "14.409.0-FUI-2495.3",
|
|
56
|
+
"@genesislcap/rollup-builder": "14.409.0-FUI-2495.3",
|
|
57
|
+
"@genesislcap/ts-builder": "14.409.0-FUI-2495.3",
|
|
58
|
+
"@genesislcap/uvu-playwright-builder": "14.409.0-FUI-2495.3",
|
|
59
|
+
"@genesislcap/vite-builder": "14.409.0-FUI-2495.3",
|
|
60
|
+
"@genesislcap/webpack-builder": "14.409.0-FUI-2495.3"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@genesislcap/foundation-logger": "14.409.0-FUI-2495.
|
|
64
|
-
"@genesislcap/foundation-utils": "14.409.0-FUI-2495.
|
|
63
|
+
"@genesislcap/foundation-logger": "14.409.0-FUI-2495.3",
|
|
64
|
+
"@genesislcap/foundation-utils": "14.409.0-FUI-2495.3",
|
|
65
65
|
"@microsoft/fast-foundation": "2.50.0"
|
|
66
66
|
},
|
|
67
67
|
"repository": {
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"publishConfig": {
|
|
73
73
|
"access": "public"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "e45ebf76f89b1217749fed0261f118b952c789bf"
|
|
76
76
|
}
|