@genesislcap/foundation-ai 14.420.0 → 14.421.1-FUI-2511.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- 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 +4 -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 +8 -5
- package/dist/dts/transports/gemini-transport.d.ts.map +1 -1
- package/dist/dts/types/chat.types.d.ts +194 -9
- 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/dts/utils/feature-flags.d.ts +2 -2
- package/dist/dts/utils/feature-flags.d.ts.map +1 -1
- package/dist/esm/ai-provider.js +8 -3
- package/dist/esm/index.js +2 -0
- package/dist/esm/providers/gemini-provider.js +6 -0
- package/dist/esm/transports/gemini-transport.js +46 -13
- package/dist/esm/types/chat.types.js +8 -1
- package/dist/esm/types/config.types.js +5 -1
- package/dist/esm/utils/feature-flags.js +10 -3
- package/dist/foundation-ai.api.json +1000 -205
- package/dist/foundation-ai.d.ts +252 -37
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -21,12 +21,18 @@ Each provider exposes capabilities such as `interpretCriteria` (natural language
|
|
|
21
21
|
|
|
22
22
|
## Feature flag
|
|
23
23
|
|
|
24
|
-
AI features are **disabled by default
|
|
24
|
+
AI features are **disabled by default**. Enable them via URL parameter or environment variable:
|
|
25
25
|
|
|
26
|
+
**URL parameter** — append `?feature.ai` to any URL (useful for testing without rebuilding):
|
|
26
27
|
```
|
|
27
28
|
https://your-app.com/?feature.ai
|
|
28
29
|
```
|
|
29
30
|
|
|
31
|
+
**Environment variable** — set `GENX_ENABLE_AI=true` in your app's `.env` file to enable permanently without a URL parameter:
|
|
32
|
+
```
|
|
33
|
+
GENX_ENABLE_AI=true
|
|
34
|
+
```
|
|
35
|
+
|
|
30
36
|
When the flag is off:
|
|
31
37
|
|
|
32
38
|
- `createAIProvider()` and `getAIProvider()` return a no-op provider
|
|
@@ -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,CAAC;IAEhD;;OAEG;IACH,SAAS,CAAC,IAAI,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IAEvC;;;OAGG;IACH,eAAe,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAElC;;;;;;OAMG;IACH,MAAM,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAExE;;;OAGG;IACH,IAAI,CAAC,CACH,OAAO,EAAE,WAAW,EAAE,EACtB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,WAAW,CAAC,CAAC;IAExB;;;OAGG;IACH,UAAU,CAAC,CACT,OAAO,EAAE,WAAW,EAAE,EACtB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,aAAa,CAAC,eAAe,CAAC,CAAC;CACnC;AAcD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,IAAI,GAAG,UAAU,CAmCrE;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,uDAAuD;IACvD,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC/B,qHAAqH;IACrH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAgC1B;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,kEAAwE,CAAC;AAEhG;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,IAAI,UAAU,CAM1C"}
|
package/dist/dts/index.d.ts
CHANGED
|
@@ -2,8 +2,10 @@ 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
|
|
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, ChatToolCallUnknown, ChatToolDefinition, ChatToolHandlers, ChatToolResult, ChatUiConfig, ChatSuggestionsConfig, InteractionResult, SubAgentRequestOptions, } from './types/chat.types';
|
|
8
|
+
export { isChatToolCallUnknown } from './types/chat.types';
|
|
7
9
|
export type { ChatTransport } from './types/chat-transport.types';
|
|
8
10
|
export type { ResolveAIConfigOptions } from './ai-provider';
|
|
9
11
|
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,oBAAoB,EACpB,cAAc,EACd,UAAU,EACV,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,
|
|
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,OAAO,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AACrD,YAAY,EACV,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,eAAe,EACf,oBAAoB,EACpB,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,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,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAG5E,MAAM,WAAW,oBAAoB;IACnC,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,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
|
+
{"version":3,"file":"gemini-provider.d.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,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;
|
|
@@ -59,6 +60,8 @@ export declare class GeminiTransport implements AITransport, ChatTransport {
|
|
|
59
60
|
private buildEndpoint;
|
|
60
61
|
private static readonly MAX_RETRIES;
|
|
61
62
|
private static readonly RATE_LIMIT_STATUS;
|
|
63
|
+
private static readonly SERVICE_UNAVAILABLE_STATUS;
|
|
64
|
+
private static readonly RETRYABLE_STATUSES;
|
|
62
65
|
private static readonly BACKOFF_BASE_MS;
|
|
63
66
|
private post;
|
|
64
67
|
private toDirectPayload;
|
|
@@ -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;IAkE1B,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,0BAA0B,CAAO;IACzD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAGxC;IACF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAQ;YAEjC,IAAI;IAgDlB,OAAO,CAAC,eAAe;CAexB"}
|
|
@@ -3,17 +3,58 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @beta
|
|
5
5
|
*/
|
|
6
|
-
export type ChatRole = 'user' | 'assistant' | 'system' | 'tool';
|
|
6
|
+
export type ChatRole = 'user' | 'assistant' | 'system' | 'tool' | 'system-event';
|
|
7
7
|
/**
|
|
8
8
|
* A tool call requested by the assistant.
|
|
9
9
|
*
|
|
10
10
|
* @beta
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
type ChatToolCallBase = {
|
|
13
13
|
id: string;
|
|
14
14
|
name: string;
|
|
15
15
|
args: Record<string, unknown>;
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Set by the driver when this tool call is a fold lifecycle event.
|
|
18
|
+
* Used by the template to render fold opens/closes distinctly.
|
|
19
|
+
* Not sent to the AI provider.
|
|
20
|
+
*/
|
|
21
|
+
foldEvent?: 'open' | 'close';
|
|
22
|
+
/**
|
|
23
|
+
* UI-only breadcrumb path of fold names the tool lives inside, e.g. ['trading_tools'].
|
|
24
|
+
* Set by the driver from the active fold stack when a tool call is appended.
|
|
25
|
+
* Not sent to the AI provider.
|
|
26
|
+
*/
|
|
27
|
+
foldPath?: string[];
|
|
28
|
+
/**
|
|
29
|
+
* Full message history from the sub-agent run that produced this tool call's result.
|
|
30
|
+
* Populated by SubAgentRunner when a tool handler delegates to a sub-agent.
|
|
31
|
+
* UI-only — not sent to the AI provider.
|
|
32
|
+
*/
|
|
33
|
+
subAgentTrace?: ChatMessage[];
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* A tool call for a tool name the driver could not resolve to any handler.
|
|
37
|
+
* `availableTools` lists every tool name registered at the time of the call.
|
|
38
|
+
* Not sent to the AI provider.
|
|
39
|
+
*
|
|
40
|
+
* @beta
|
|
41
|
+
*/
|
|
42
|
+
export type ChatToolCallUnknown = ChatToolCallBase & {
|
|
43
|
+
unknown: true;
|
|
44
|
+
availableTools: string[];
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* A tool call requested by the assistant.
|
|
48
|
+
*
|
|
49
|
+
* @beta
|
|
50
|
+
*/
|
|
51
|
+
export type ChatToolCall = ChatToolCallBase | ChatToolCallUnknown;
|
|
52
|
+
/**
|
|
53
|
+
* Type guard that narrows a `ChatToolCall` to `ChatToolCallUnknown`.
|
|
54
|
+
*
|
|
55
|
+
* @beta
|
|
56
|
+
*/
|
|
57
|
+
export declare function isChatToolCallUnknown(tc: ChatToolCall): tc is ChatToolCallUnknown;
|
|
17
58
|
/**
|
|
18
59
|
* The result of executing a tool call.
|
|
19
60
|
*
|
|
@@ -42,8 +83,8 @@ export interface ChatInteraction {
|
|
|
42
83
|
interactionId: string;
|
|
43
84
|
componentName: string;
|
|
44
85
|
data: any;
|
|
45
|
-
/**
|
|
46
|
-
resolved?:
|
|
86
|
+
/** The result when the interaction has been resolved. Truthy check indicates resolved state; value is available for widgets to display. */
|
|
87
|
+
resolved?: InteractionResult<unknown>;
|
|
47
88
|
}
|
|
48
89
|
/**
|
|
49
90
|
* A file attachment included with a user message.
|
|
@@ -68,6 +109,14 @@ export interface ChatMessage {
|
|
|
68
109
|
attachments?: ChatAttachment[];
|
|
69
110
|
interaction?: ChatInteraction;
|
|
70
111
|
thinking?: boolean;
|
|
112
|
+
/** Name of the agent that produced this message. Set by OrchestratingDriver. */
|
|
113
|
+
agentName?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Total prompt tokens consumed for the request that produced this message.
|
|
116
|
+
* Set by transports that return usage metadata (e.g. Gemini). Used to display
|
|
117
|
+
* context window utilisation in the UI.
|
|
118
|
+
*/
|
|
119
|
+
inputTokens?: number;
|
|
71
120
|
}
|
|
72
121
|
/**
|
|
73
122
|
* JSON Schema-based tool definition for function calling.
|
|
@@ -79,13 +128,55 @@ export interface ChatToolDefinition {
|
|
|
79
128
|
description: string;
|
|
80
129
|
parameters: Record<string, unknown>;
|
|
81
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Options passed to `requestSubAgent` at call time.
|
|
133
|
+
*
|
|
134
|
+
* @beta
|
|
135
|
+
*/
|
|
136
|
+
export interface SubAgentRequestOptions {
|
|
137
|
+
/** Plain-language description of what this specific invocation should do. */
|
|
138
|
+
task?: string;
|
|
139
|
+
/** Per-call override of the config-level historyCap. */
|
|
140
|
+
historyCap?: number;
|
|
141
|
+
/** Extra dynamic data injected as a primer message before the task. */
|
|
142
|
+
context?: Record<string, unknown>;
|
|
143
|
+
}
|
|
82
144
|
/**
|
|
83
145
|
* Map of tool name to async handler function.
|
|
84
146
|
*
|
|
147
|
+
* Optionally parameterised with the sub-agents available to this handler set.
|
|
148
|
+
* Pass the config objects (not string literals) so the name union is derived
|
|
149
|
+
* from the actual configs:
|
|
150
|
+
*
|
|
151
|
+
* ```ts
|
|
152
|
+
* const mySubAgent = { name: 'my_sub_agent', ... } satisfies AgentConfig;
|
|
153
|
+
* type MyHandlers = ChatToolHandlers<typeof mySubAgent>;
|
|
154
|
+
* // requestSubAgent's name param is now typed as 'my_sub_agent'
|
|
155
|
+
* ```
|
|
156
|
+
*
|
|
157
|
+
* Multiple sub-agents: `ChatToolHandlers<typeof agentA | typeof agentB>`.
|
|
158
|
+
* Default (`{ name: string }`) leaves the name param as `string` — no breaking change.
|
|
159
|
+
*
|
|
85
160
|
* @beta
|
|
86
161
|
*/
|
|
87
|
-
export type ChatToolHandlers
|
|
162
|
+
export type ChatToolHandlers<TSubAgent extends {
|
|
163
|
+
name: string;
|
|
164
|
+
} = {
|
|
165
|
+
name: string;
|
|
166
|
+
}> = Record<string, (args: Record<string, unknown>, context: {
|
|
88
167
|
requestInteraction: <T = unknown>(componentName: string, data: any) => Promise<T>;
|
|
168
|
+
/**
|
|
169
|
+
* Delegate to a named sub-agent declared on the parent agent config.
|
|
170
|
+
* Returns the sub-agent's structured result (when `completeSubAgent` was called) or
|
|
171
|
+
* its final assistant message text as a fallback.
|
|
172
|
+
*/
|
|
173
|
+
requestSubAgent?: <T = never>(name: TSubAgent['name'], options?: SubAgentRequestOptions) => Promise<T | string>;
|
|
174
|
+
/**
|
|
175
|
+
* Signal explicit completion from within a sub-agent tool handler.
|
|
176
|
+
* The resolved value is returned to the parent handler as the structured result of
|
|
177
|
+
* `requestSubAgent`. Only available inside sub-agent tool handlers.
|
|
178
|
+
*/
|
|
179
|
+
completeSubAgent?: (result: unknown) => void;
|
|
89
180
|
}) => Promise<unknown>>;
|
|
90
181
|
/**
|
|
91
182
|
* Options for a chat request.
|
|
@@ -98,6 +189,18 @@ export interface ChatRequestOptions {
|
|
|
98
189
|
attachments?: ChatAttachment[];
|
|
99
190
|
signal?: AbortSignal;
|
|
100
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* The result returned by a driver after processing a user turn.
|
|
194
|
+
*
|
|
195
|
+
* @beta
|
|
196
|
+
*/
|
|
197
|
+
export type ChatDriverResult = {
|
|
198
|
+
reason: 'done';
|
|
199
|
+
} | {
|
|
200
|
+
reason: 'agent-handoff';
|
|
201
|
+
summary: string;
|
|
202
|
+
remainingTask: string;
|
|
203
|
+
};
|
|
101
204
|
/**
|
|
102
205
|
* A streaming chunk from a chat response.
|
|
103
206
|
*
|
|
@@ -126,7 +229,7 @@ export interface ChatAnimationsConfig {
|
|
|
126
229
|
enabled?: string[];
|
|
127
230
|
}
|
|
128
231
|
/**
|
|
129
|
-
*
|
|
232
|
+
* UI display configuration for the chat assistant.
|
|
130
233
|
*
|
|
131
234
|
* For toggle flags (`showToolCalls`, `showThinkingSteps`):
|
|
132
235
|
* - `true` — default on, user can toggle off
|
|
@@ -135,7 +238,7 @@ export interface ChatAnimationsConfig {
|
|
|
135
238
|
*
|
|
136
239
|
* @beta
|
|
137
240
|
*/
|
|
138
|
-
export interface
|
|
241
|
+
export interface ChatUiConfig {
|
|
139
242
|
/** Show tool call details in the chat UI. */
|
|
140
243
|
showToolCalls?: boolean | null;
|
|
141
244
|
/** Show model thinking/reasoning steps. */
|
|
@@ -151,7 +254,89 @@ export interface ChatConfig {
|
|
|
151
254
|
loadingDelay?: number;
|
|
152
255
|
/** Animations feature configuration. */
|
|
153
256
|
animations?: ChatAnimationsConfig;
|
|
154
|
-
/**
|
|
257
|
+
/**
|
|
258
|
+
* When `true`, shows the `slot="splash"` content when there are no messages.
|
|
259
|
+
* The host element reflects a `showing-splash` boolean attribute that consumers
|
|
260
|
+
* can use as a CSS hook to animate the splash in and out. Default: `false`.
|
|
261
|
+
*/
|
|
262
|
+
showSplash?: boolean;
|
|
263
|
+
/**
|
|
264
|
+
* Show an inline divider in the message list when the active specialist changes.
|
|
265
|
+
* Also shown automatically when showToolCalls is true.
|
|
266
|
+
* - `true` — default on, user can toggle off
|
|
267
|
+
* - `false` — default off, user can toggle on
|
|
268
|
+
* - `null` / `undefined` — completely disabled, no UI control shown
|
|
269
|
+
*/
|
|
270
|
+
showAgentSwitchIndicator?: boolean | null;
|
|
271
|
+
/**
|
|
272
|
+
* Show a context window usage indicator in the settings panel.
|
|
273
|
+
* Visible when the settings panel is open and token usage data is available.
|
|
274
|
+
* - `true` or `undefined` (default) — shown when data is available
|
|
275
|
+
* - `false` — hidden
|
|
276
|
+
*/
|
|
277
|
+
showContextUsage?: boolean;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Agent engine configuration for the chat assistant.
|
|
281
|
+
*
|
|
282
|
+
* @beta
|
|
283
|
+
*/
|
|
284
|
+
export interface ChatAgentConfig {
|
|
285
|
+
/** Maximum number of tool call iterations within one agent's loop. Default: 50. */
|
|
155
286
|
maxToolIterations?: number;
|
|
287
|
+
/** Maximum number of agent-to-agent handoffs per user turn. Default: 3. */
|
|
288
|
+
maxHandoffs?: number;
|
|
289
|
+
/** Number of recent messages passed to the classifier for context. Default: 4. */
|
|
290
|
+
classifierHistoryLength?: number;
|
|
291
|
+
/** Number of retries on classifier failure before erroring. Default: 2. */
|
|
292
|
+
classifierRetries?: number;
|
|
293
|
+
/**
|
|
294
|
+
* Maximum number of consecutive fold open/close operations without a real tool call before
|
|
295
|
+
* the driver injects a guidance message. Default: 5.
|
|
296
|
+
*/
|
|
297
|
+
maxFoldOperations?: number;
|
|
156
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* Display and engine configuration for the chat assistant.
|
|
301
|
+
*
|
|
302
|
+
* @beta
|
|
303
|
+
*/
|
|
304
|
+
export interface ChatConfig {
|
|
305
|
+
/** UI display settings — toggles, file upload, animations, etc. */
|
|
306
|
+
ui?: ChatUiConfig;
|
|
307
|
+
/** Agent engine settings — iteration limits, handoff caps, classifier tuning. */
|
|
308
|
+
agent?: ChatAgentConfig;
|
|
309
|
+
/** Query suggestions feature configuration. */
|
|
310
|
+
suggestions?: ChatSuggestionsConfig;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Configuration for the chat suggestions feature.
|
|
314
|
+
*
|
|
315
|
+
* @beta
|
|
316
|
+
*/
|
|
317
|
+
export type ChatSuggestionsConfig = {
|
|
318
|
+
/** Suggestions are disabled. */
|
|
319
|
+
behavior: 'never';
|
|
320
|
+
/** Not applicable when behavior is 'never'. */
|
|
321
|
+
count?: never;
|
|
322
|
+
/** Not applicable when behavior is 'never'. */
|
|
323
|
+
prompt?: never;
|
|
324
|
+
} | {
|
|
325
|
+
/**
|
|
326
|
+
* 'initial': Show suggestions on first load before any messages are sent.
|
|
327
|
+
* 'always': Show suggestions after every assistant response.
|
|
328
|
+
*/
|
|
329
|
+
behavior: 'initial' | 'always';
|
|
330
|
+
/**
|
|
331
|
+
* Number of suggestions to generate.
|
|
332
|
+
* @default 3
|
|
333
|
+
*/
|
|
334
|
+
count?: number;
|
|
335
|
+
/**
|
|
336
|
+
* Custom prompt to steer the suggestion generation. If omitted, a
|
|
337
|
+
* default prompt is used.
|
|
338
|
+
*/
|
|
339
|
+
prompt?: string;
|
|
340
|
+
};
|
|
341
|
+
export {};
|
|
157
342
|
//# 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,CAAC;
|
|
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,KAAK,gBAAgB,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,O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CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;OAMG;IACH,wBAAwB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1C;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,mFAAmF;IACnF,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,2EAA2E;IAC3E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kFAAkF;IAClF,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,2EAA2E;IAC3E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;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,EA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AM,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,cAAc,GAAG,cAAc,GAAG,cAAc,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** Feature flag name for AI functionality (beta). Enable via ?feature.ai in URL. */
|
|
1
|
+
/** Feature flag name for AI functionality (beta). Enable via ?feature.ai in URL or GENX_ENABLE_AI env var. */
|
|
2
2
|
export declare const AI_FEATURE_FLAG = "ai";
|
|
3
|
-
/** Returns true when AI features (beta) are enabled
|
|
3
|
+
/** Returns true when AI features (beta) are enabled via ?feature.ai URL param or GENX_ENABLE_AI=true env var. */
|
|
4
4
|
export declare const isAIFeatureEnabled: () => boolean;
|
|
5
5
|
//# sourceMappingURL=feature-flags.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-flags.d.ts","sourceRoot":"","sources":["../../../src/utils/feature-flags.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"feature-flags.d.ts","sourceRoot":"","sources":["../../../src/utils/feature-flags.ts"],"names":[],"mappings":"AAEA,8GAA8G;AAC9G,eAAO,MAAM,eAAe,OAAO,CAAC;AAUpC,iHAAiH;AACjH,eAAO,MAAM,kBAAkB,QAAO,OAA6D,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,6 @@ 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';
|
|
6
|
+
export { isChatToolCallUnknown } from './types/chat.types';
|
|
5
7
|
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);
|