@genesislcap/foundation-ai 14.400.0-hide-status-pill.2

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.
Files changed (108) hide show
  1. package/README.md +279 -0
  2. package/dist/dts/ai-provider.d.ts +81 -0
  3. package/dist/dts/ai-provider.d.ts.map +1 -0
  4. package/dist/dts/index.d.ts +8 -0
  5. package/dist/dts/index.d.ts.map +1 -0
  6. package/dist/dts/interactions/criteria-interpretation.d.ts +145 -0
  7. package/dist/dts/interactions/criteria-interpretation.d.ts.map +1 -0
  8. package/dist/dts/interactions/index.d.ts +2 -0
  9. package/dist/dts/interactions/index.d.ts.map +1 -0
  10. package/dist/dts/providers/chrome-provider.d.ts +26 -0
  11. package/dist/dts/providers/chrome-provider.d.ts.map +1 -0
  12. package/dist/dts/providers/default-provider.d.ts +15 -0
  13. package/dist/dts/providers/default-provider.d.ts.map +1 -0
  14. package/dist/dts/providers/openai-provider.d.ts +25 -0
  15. package/dist/dts/providers/openai-provider.d.ts.map +1 -0
  16. package/dist/dts/transports/chrome-prompt-transport.d.ts +26 -0
  17. package/dist/dts/transports/chrome-prompt-transport.d.ts.map +1 -0
  18. package/dist/dts/transports/default-transport.d.ts +10 -0
  19. package/dist/dts/transports/default-transport.d.ts.map +1 -0
  20. package/dist/dts/transports/server-openai-transport.d.ts +22 -0
  21. package/dist/dts/transports/server-openai-transport.d.ts.map +1 -0
  22. package/dist/dts/tsdoc-metadata.json +11 -0
  23. package/dist/dts/types/config.types.d.ts +56 -0
  24. package/dist/dts/types/config.types.d.ts.map +1 -0
  25. package/dist/dts/types/criteria-types.d.ts +20 -0
  26. package/dist/dts/types/criteria-types.d.ts.map +1 -0
  27. package/dist/dts/types/index.d.ts +5 -0
  28. package/dist/dts/types/index.d.ts.map +1 -0
  29. package/dist/dts/types/status.types.d.ts +18 -0
  30. package/dist/dts/types/status.types.d.ts.map +1 -0
  31. package/dist/dts/types/transports.types.d.ts +21 -0
  32. package/dist/dts/types/transports.types.d.ts.map +1 -0
  33. package/dist/dts/utils/feature-flags.d.ts +5 -0
  34. package/dist/dts/utils/feature-flags.d.ts.map +1 -0
  35. package/dist/dts/utils/index.d.ts +4 -0
  36. package/dist/dts/utils/index.d.ts.map +1 -0
  37. package/dist/dts/utils/logger.d.ts +2 -0
  38. package/dist/dts/utils/logger.d.ts.map +1 -0
  39. package/dist/dts/utils/speech-to-text.d.ts +11 -0
  40. package/dist/dts/utils/speech-to-text.d.ts.map +1 -0
  41. package/dist/esm/ai-provider.js +111 -0
  42. package/dist/esm/index.js +3 -0
  43. package/dist/esm/interactions/criteria-interpretation.js +146 -0
  44. package/dist/esm/interactions/index.js +1 -0
  45. package/dist/esm/providers/chrome-provider.js +58 -0
  46. package/dist/esm/providers/default-provider.js +19 -0
  47. package/dist/esm/providers/openai-provider.js +46 -0
  48. package/dist/esm/transports/chrome-prompt-transport.js +100 -0
  49. package/dist/esm/transports/default-transport.js +13 -0
  50. package/dist/esm/transports/server-openai-transport.js +50 -0
  51. package/dist/esm/types/config.types.js +1 -0
  52. package/dist/esm/types/criteria-types.js +1 -0
  53. package/dist/esm/types/index.js +4 -0
  54. package/dist/esm/types/status.types.js +1 -0
  55. package/dist/esm/types/transports.types.js +1 -0
  56. package/dist/esm/utils/feature-flags.js +5 -0
  57. package/dist/esm/utils/index.js +3 -0
  58. package/dist/esm/utils/logger.js +2 -0
  59. package/dist/esm/utils/speech-to-text.js +55 -0
  60. package/dist/foundation-ai.api.json +1419 -0
  61. package/dist/foundation-ai.d.ts +219 -0
  62. package/docs/.gitattributes +2 -0
  63. package/docs/api/foundation-ai.ai_feature_flag.md +13 -0
  64. package/docs/api/foundation-ai.aiconfig.md +18 -0
  65. package/docs/api/foundation-ai.aiprovider.getstatus.md +20 -0
  66. package/docs/api/foundation-ai.aiprovider.interpretcriteria.md +67 -0
  67. package/docs/api/foundation-ai.aiprovider.md +69 -0
  68. package/docs/api/foundation-ai.aiprovider.triggerdownload.md +20 -0
  69. package/docs/api/foundation-ai.aiprovidertype.md +16 -0
  70. package/docs/api/foundation-ai.aistatus.chromeavailability.md +14 -0
  71. package/docs/api/foundation-ai.aistatus.md +99 -0
  72. package/docs/api/foundation-ai.aistatus.model.md +14 -0
  73. package/docs/api/foundation-ai.aistatus.provider.md +14 -0
  74. package/docs/api/foundation-ai.chromeaiconfig.md +104 -0
  75. package/docs/api/foundation-ai.chromeaiconfig.providertype.md +14 -0
  76. package/docs/api/foundation-ai.chromeaiconfig.temperature.md +14 -0
  77. package/docs/api/foundation-ai.chromeaiconfig.topk.md +14 -0
  78. package/docs/api/foundation-ai.chromeavailability.md +16 -0
  79. package/docs/api/foundation-ai.createaiprovider.md +57 -0
  80. package/docs/api/foundation-ai.criteriaclauseresult.field.md +14 -0
  81. package/docs/api/foundation-ai.criteriaclauseresult.md +99 -0
  82. package/docs/api/foundation-ai.criteriaclauseresult.operator.md +14 -0
  83. package/docs/api/foundation-ai.criteriaclauseresult.value.md +14 -0
  84. package/docs/api/foundation-ai.criteriagroupresult.clauses.md +11 -0
  85. package/docs/api/foundation-ai.criteriagroupresult.logic.md +11 -0
  86. package/docs/api/foundation-ai.criteriagroupresult.md +90 -0
  87. package/docs/api/foundation-ai.criteriagroupresult.negated.md +11 -0
  88. package/docs/api/foundation-ai.criteriainterpretationresult.groups.md +11 -0
  89. package/docs/api/foundation-ai.criteriainterpretationresult.md +54 -0
  90. package/docs/api/foundation-ai.criteriainterpretcontext.fields.md +11 -0
  91. package/docs/api/foundation-ai.criteriainterpretcontext.md +56 -0
  92. package/docs/api/foundation-ai.fieldlike.md +16 -0
  93. package/docs/api/foundation-ai.getaiprovider.md +35 -0
  94. package/docs/api/foundation-ai.isaifeatureenabled.md +17 -0
  95. package/docs/api/foundation-ai.isspeechrecognitionavailable.md +20 -0
  96. package/docs/api/foundation-ai.md +274 -0
  97. package/docs/api/foundation-ai.resolveaiconfig.md +57 -0
  98. package/docs/api/foundation-ai.resolveaiconfigoptions.md +94 -0
  99. package/docs/api/foundation-ai.resolveaiconfigoptions.model.md +13 -0
  100. package/docs/api/foundation-ai.resolveaiconfigoptions.preferchrome.md +13 -0
  101. package/docs/api/foundation-ai.resolveaiconfigoptions.provider.md +13 -0
  102. package/docs/api/foundation-ai.serveraiconfig.md +66 -0
  103. package/docs/api/foundation-ai.serveraiconfig.provider.md +14 -0
  104. package/docs/api/foundation-ai.startspeechrecognition.md +66 -0
  105. package/docs/api/index.md +30 -0
  106. package/docs/api-report.md.api.md +136 -0
  107. package/license.txt +46 -0
  108. package/package.json +76 -0
package/README.md ADDED
@@ -0,0 +1,279 @@
1
+ # Genesis Foundation AI
2
+
3
+ [![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lerna.js.org/)
4
+ [![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](https://www.typescriptlang.org/)
5
+
6
+ ## [API Docs](./docs/api/index.md)
7
+
8
+ Provider-agnostic AI configuration and shared utilities. Configure once at app bootstrap; use across components via dependency injection.
9
+
10
+ > **Beta – not for production**
11
+ > This package is in beta. Do not use in production. API surface and behaviour may change. It is intended for evaluation and development only.
12
+
13
+ **Supported providers:**
14
+
15
+ - **OpenAI (server proxy)** – Client calls your server at `/gwf/ai-service/chat-completions`; server calls OpenAI.
16
+ - **Chrome built-in AI** – Prompt API / Gemini Nano (no API key; Chrome 138+)
17
+
18
+ Each provider exposes capabilities such as `interpretCriteria` (natural language to structured criteria). Future capabilities (e.g. summarization) will be added as optional methods on the same interface.
19
+
20
+ ---
21
+
22
+ ## Feature flag
23
+
24
+ AI features are **disabled by default** and require the feature flag to be enabled. Add `?feature.ai` to the URL to activate:
25
+
26
+ ```
27
+ https://your-app.com/?feature.ai
28
+ ```
29
+
30
+ When the flag is off:
31
+
32
+ - `createAIProvider()` and `getAIProvider()` return a no-op provider
33
+ - `resolveAIConfig()` returns `null`
34
+ - AI components (e.g. `*-ai-criteria-search`, `*-ai-indicator`) do not render
35
+
36
+ You can check the flag programmatically:
37
+
38
+ ```ts
39
+ import { isAIFeatureEnabled, AI_FEATURE_FLAG } from '@genesislcap/foundation-ai';
40
+
41
+ if (isAIFeatureEnabled()) {
42
+ // AI features are enabled
43
+ }
44
+ ```
45
+
46
+ ---
47
+
48
+ ## Installation
49
+
50
+ Add `@genesislcap/foundation-ai` as a dependency. Run `npm run bootstrap` after changing dependencies.
51
+
52
+ ```json
53
+ {
54
+ "dependencies": {
55
+ "@genesislcap/foundation-ai": "latest"
56
+ }
57
+ }
58
+ ```
59
+
60
+ ---
61
+
62
+ ## Configuration
63
+
64
+ ### 1. Resolve config (Chrome-first or OpenAI)
65
+
66
+ Use `resolveAIConfig` to prefer Chrome when available, with server proxy as fallback:
67
+
68
+ ```ts
69
+ import { createAIProvider, resolveAIConfig, AIProvider } from '@genesislcap/foundation-ai';
70
+
71
+ // Server URL is derived from API_HOST. Use provider and model:
72
+ const aiConfig = await resolveAIConfig({
73
+ provider: 'openai',
74
+ model: 'gpt-4o-mini',
75
+ preferChrome: true,
76
+ });
77
+ ```
78
+
79
+ ### 2. Register provider in DI
80
+
81
+ Register the provider at app bootstrap (e.g. in `main.ts`):
82
+
83
+ ```ts
84
+ import { Registration } from '@microsoft/fast-foundation';
85
+
86
+ this.container.register(
87
+ Registration.instance(AIProvider, createAIProvider(aiConfig)),
88
+ );
89
+ ```
90
+
91
+ Configure once; all components using `getAIProvider()` receive the same instance.
92
+
93
+ ### 3. Use in components
94
+
95
+ ```ts
96
+ import { getAIProvider } from '@genesislcap/foundation-ai';
97
+
98
+ const aiProvider = getAIProvider();
99
+ if (aiProvider?.interpretCriteria) {
100
+ const result = await aiProvider.interpretCriteria(input, { fields: fieldMetadata });
101
+ }
102
+ ```
103
+
104
+ ---
105
+
106
+ ## Server-side web handler (OpenAI proxy)
107
+
108
+ The client posts to `/gwf/ai-service/chat-completions`. You must configure a Genesis web handler on your server to proxy these requests to OpenAI. The API key stays on the server and is never exposed to the client.
109
+
110
+ ### 1. Add a web handler script
111
+
112
+ Create a `*-web-handler.kts` file in your Genesis app's scripts folder (e.g. `src/main/genesis/scripts/`). Example for OpenAI:
113
+
114
+ ```kotlin
115
+ /**
116
+ * AI web handler - proxies OpenAI Chat Completions requests.
117
+ * API key is read from OPENAI_API_KEY env var (never exposed to client).
118
+ */
119
+ import com.fasterxml.jackson.annotation.JsonAlias
120
+ import com.fasterxml.jackson.annotation.JsonProperty
121
+ import com.fasterxml.jackson.databind.ObjectMapper
122
+ import java.net.URI
123
+ import java.net.http.HttpClient
124
+ import java.net.http.HttpRequest
125
+ import java.net.http.HttpResponse
126
+ import java.nio.charset.StandardCharsets
127
+
128
+ data class ChatCompletionsRequest(
129
+ val provider: String = "openai",
130
+ val model: String = "gpt-4o-mini",
131
+ @JsonProperty("SYSTEM_PROMPT") @JsonAlias("systemPrompt") val systemPrompt: String,
132
+ @JsonProperty("USER_PROMPT") @JsonAlias("userPrompt") val userPrompt: String,
133
+ @JsonProperty("RESPONSE_SCHEMA") @JsonAlias("responseSchema") val responseSchema: Map<String, Any>? = null,
134
+ )
135
+
136
+ data class ChatCompletionsResponse(
137
+ val content: String,
138
+ )
139
+
140
+ webHandlers("ai-service") {
141
+ val httpClient = HttpClient.newBuilder().build()
142
+ val apiKey = java.lang.System.getenv("OPENAI_API_KEY")
143
+
144
+ endpoint<ChatCompletionsRequest, ChatCompletionsResponse>(POST, "chat-completions") {
145
+ handleRequest {
146
+ val req = body
147
+ if (req.provider != "openai") {
148
+ throw IllegalStateException("Only 'openai' provider is supported for now")
149
+ }
150
+ if (apiKey.isNullOrBlank()) {
151
+ throw IllegalStateException("OPENAI_API_KEY is not configured on the server")
152
+ }
153
+ val responseFormat = req.responseSchema?.let { schema ->
154
+ mapOf(
155
+ "type" to "json_schema",
156
+ "json_schema" to mapOf(
157
+ "name" to "structured_response",
158
+ "strict" to true,
159
+ "schema" to schema,
160
+ ),
161
+ )
162
+ }
163
+ val openAiBody = mapOf(
164
+ "model" to req.model,
165
+ "messages" to listOf(
166
+ mapOf("role" to "system", "content" to req.systemPrompt),
167
+ mapOf("role" to "user", "content" to req.userPrompt),
168
+ ),
169
+ ) + (responseFormat?.let { mapOf("response_format" to it) } ?: emptyMap())
170
+
171
+ val objectMapper = ObjectMapper()
172
+ val requestBody = objectMapper.writeValueAsString(openAiBody)
173
+ val request = HttpRequest.newBuilder()
174
+ .uri(URI.create("https://api.openai.com/v1/chat/completions"))
175
+ .header("Authorization", "Bearer $apiKey")
176
+ .header("Content-Type", "application/json")
177
+ .POST(HttpRequest.BodyPublishers.ofString(requestBody, StandardCharsets.UTF_8))
178
+ .build()
179
+
180
+ val response = httpClient.send(request, HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8))
181
+
182
+ if (response.statusCode() >= 400) {
183
+ LOG.error("OpenAI API error: ${response.statusCode()} - ${response.body()}")
184
+ throw RuntimeException("OpenAI API error: ${response.statusCode()}")
185
+ }
186
+
187
+ val json = objectMapper.readTree(response.body())
188
+ val choices = json.path("choices")
189
+ val content = if (choices.isArray && !choices.isEmpty) {
190
+ choices.get(0).path("message").path("content").asText()
191
+ } else ""
192
+ ChatCompletionsResponse(content = content)
193
+ }
194
+ }
195
+ }
196
+ ```
197
+
198
+ ### 2. Set the API key
199
+
200
+ Configure `OPENAI_API_KEY` on the server (env var, system config, or secrets manager). Do not expose it to the client.
201
+
202
+ ---
203
+
204
+ ## Manual provider selection
205
+
206
+ To force a specific provider instead of using `resolveAIConfig`:
207
+
208
+ ```ts
209
+ // Server proxy (provider + model; URL derived from API_HOST)
210
+ Registration.instance(AIProvider, createAIProvider({
211
+ provider: 'openai',
212
+ model: 'gpt-4o-mini',
213
+ }));
214
+
215
+ // Chrome only (when available)
216
+ Registration.instance(AIProvider, createAIProvider({
217
+ providerType: 'chrome',
218
+ }));
219
+ ```
220
+
221
+ ---
222
+
223
+ ## Chrome built-in AI (Prompt API / Gemini Nano)
224
+
225
+ The Chrome provider uses the [Prompt API](https://developer.chrome.com/docs/ai/prompt-api) with Gemini Nano. It runs on-device; no API key and no data is sent to external services.
226
+
227
+ ### Production (deployed apps)
228
+
229
+ Chrome built-in AI is in an **origin trial**. For production domains, users do **not** need to enable any flags:
230
+
231
+ 1. [Enroll your domain](https://developer.chrome.com/origintrials/#/view_trial/2533837740349325313) in the Prompt API origin trial.
232
+ 2. Add the origin trial token (meta tag or header) to your app.
233
+ 3. The model download is triggered when your app calls `LanguageModel.create()` from a user gesture (e.g. the AI indicator "Install model" button).
234
+
235
+ ### Local development (localhost)
236
+
237
+ For testing on `localhost`, enable these Chrome flags:
238
+
239
+ - `chrome://flags/#optimization-guide-on-device-model` → **Enabled**
240
+ - `chrome://flags/#prompt-api-for-gemini-nano` → **Enabled**
241
+
242
+ Restart Chrome after changing flags.
243
+
244
+ ### Hardware and system requirements
245
+
246
+ - **OS:** Windows 10/11, macOS 13+, Linux, or ChromeOS (Chromebook Plus)
247
+ - **Storage:** At least 22 GB free (for model download)
248
+ - **GPU:** >4 GB VRAM, or **CPU:** 16 GB RAM and 4+ cores
249
+ - **Network:** Unmetered connection for initial model download only; inference runs offline
250
+
251
+ See [Chrome's Prompt API docs](https://developer.chrome.com/docs/ai/prompt-api) for full requirements.
252
+
253
+ ---
254
+
255
+ ## Speech-to-text
256
+
257
+ The package includes Web Speech API utilities for voice input:
258
+
259
+ ```ts
260
+ import { isSpeechRecognitionAvailable, startSpeechRecognition } from '@genesislcap/foundation-ai';
261
+
262
+ if (isSpeechRecognitionAvailable()) {
263
+ const stop = startSpeechRecognition(
264
+ (transcript, isFinal) => { /* handle transcript */ },
265
+ () => { /* on error */ },
266
+ );
267
+ // Call stop() to end recording
268
+ }
269
+ ```
270
+
271
+ ---
272
+
273
+ ## License
274
+
275
+ This project provides front-end dependencies and uses licensed components. Licenses are required during development. Contact [Genesis Global](https://genesis.global/contact-us/) for details.
276
+
277
+ ### Licensed components
278
+
279
+ Genesis low-code platform
@@ -0,0 +1,81 @@
1
+ import type { CriteriaInterpretContext } from './interactions';
2
+ import type { AIConfig, AIStatus, CriteriaInterpretationResult } from './types';
3
+ /**
4
+ * AI Provider interface for foundation-ai.
5
+ *
6
+ * @remarks
7
+ * General providers (OpenAI, Chrome) are configured once and expose multiple capabilities.
8
+ * Components check for optional method support before use.
9
+ *
10
+ * @beta
11
+ */
12
+ export interface AIProvider {
13
+ interpretCriteria?(input: string, context: CriteriaInterpretContext): Promise<CriteriaInterpretationResult | null>;
14
+ /**
15
+ * Returns current AI status for display (provider, model, Chrome availability).
16
+ */
17
+ getStatus?(): Promise<AIStatus | null>;
18
+ /**
19
+ * Triggers Chrome model download. Only ChromeProvider implements this.
20
+ * Must be called from a user gesture (e.g. click).
21
+ */
22
+ triggerDownload?(): Promise<void>;
23
+ }
24
+ /**
25
+ * Creates an AIProvider from config.
26
+ * Uses ChromeProvider when providerType is 'chrome'.
27
+ * Uses OpenAIProvider with ServerOpenAITransport when provider is set (server-only).
28
+ * Otherwise returns DefaultAIProvider.
29
+ * When the AI feature flag is disabled (?feature.ai), always returns DefaultAIProvider.
30
+ *
31
+ * @beta
32
+ */
33
+ export declare function createAIProvider(config?: AIConfig | null): AIProvider;
34
+ export interface ResolveAIConfigOptions {
35
+ /** Cloud provider (openai). Default: openai */
36
+ provider?: 'openai';
37
+ /** Model name (e.g. gpt-4o-mini). Default: gpt-4o-mini */
38
+ model?: string;
39
+ /** Prefer Chrome built-in AI when available */
40
+ preferChrome?: boolean;
41
+ }
42
+ /**
43
+ * Resolves AI config, optionally preferring Chrome when available.
44
+ * Use before registering AIProvider. Server URL is derived from API_HOST.
45
+ * Returns null when the AI feature flag is disabled (?feature.ai).
46
+ *
47
+ * @beta
48
+ */
49
+ export declare function resolveAIConfig(options?: ResolveAIConfigOptions): Promise<AIConfig | null>;
50
+ /**
51
+ * The DI token for the AIProvider interface.
52
+ *
53
+ * @remarks
54
+ * Register a provider implementation in app bootstrap (e.g. main.ts):
55
+ * ```ts
56
+ * Registration.singleton(AIProvider, OpenAIProvider)
57
+ * ```
58
+ *
59
+ * @internal
60
+ */
61
+ export declare const AIProvider: import("@microsoft/fast-foundation").InterfaceSymbol<AIProvider>;
62
+ /**
63
+ * Gets AIProvider from the DI container.
64
+ * When the AI feature flag is disabled (?feature.ai), returns DefaultAIProvider (no-op).
65
+ *
66
+ * @remarks
67
+ * A utility method for host applications that are not using decorators or the DI container.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * import { getAIProvider } from '@genesislcap/foundation-ai';
72
+ * ...
73
+ * private aiProvider = getAIProvider();
74
+ * ...
75
+ * const result = await this.aiProvider.interpretCriteria?.(input, context);
76
+ * ```
77
+ *
78
+ * @beta
79
+ */
80
+ export declare function getAIProvider(): AIProvider;
81
+ //# sourceMappingURL=ai-provider.d.ts.map
@@ -0,0 +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;AAM/D,OAAO,KAAK,EACV,QAAQ,EACR,QAAQ,EAER,4BAA4B,EAE7B,MAAM,SAAS,CAAC;AAIjB;;;;;;;;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;CACnC;AAUD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,IAAI,GAAG,UAAU,CAyBrE;AAED,MAAM,WAAW,sBAAsB;IACrC,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,0DAA0D;IAC1D,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,CAsB1B;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,kEAAwE,CAAC;AAEhG;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,IAAI,UAAU,CAM1C"}
@@ -0,0 +1,8 @@
1
+ export { AIProvider, createAIProvider, getAIProvider, resolveAIConfig } from './ai-provider';
2
+ export { AI_FEATURE_FLAG, isAIFeatureEnabled } from './utils/feature-flags';
3
+ export type { AIConfig, AIStatus, AIProviderType, ChromeAIConfig, ChromeAvailability, ServerAIConfig, } from './types';
4
+ export type { ResolveAIConfigOptions } from './ai-provider';
5
+ export type { CriteriaInterpretContext, FieldLike } from './interactions';
6
+ export type { CriteriaClauseResult, CriteriaGroupResult, CriteriaInterpretationResult, } from './types/criteria-types';
7
+ export { isSpeechRecognitionAvailable, startSpeechRecognition } from './utils/speech-to-text';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,eAAe,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,YAAY,EACV,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,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"}
@@ -0,0 +1,145 @@
1
+ import type { CriteriaInterpretationResult } from '../types';
2
+ /**
3
+ * Standard JSON Schema for criteria interpretation output.
4
+ * Used by Chrome Prompt API (responseConstraint) and other providers.
5
+ *
6
+ * @beta
7
+ */
8
+ export declare const CRITERIA_JSON_SCHEMA: {
9
+ readonly type: "object";
10
+ readonly properties: {
11
+ readonly groups: {
12
+ readonly type: "array";
13
+ readonly items: {
14
+ readonly type: "object";
15
+ readonly properties: {
16
+ readonly logic: {
17
+ readonly type: "string";
18
+ readonly enum: readonly ["and", "or"];
19
+ readonly description: "How clauses within the group are combined";
20
+ };
21
+ readonly negated: {
22
+ readonly type: "boolean";
23
+ readonly default: false;
24
+ readonly description: "If true, negate the entire group";
25
+ };
26
+ readonly clauses: {
27
+ readonly type: "array";
28
+ readonly items: {
29
+ readonly type: "object";
30
+ readonly properties: {
31
+ readonly field: {
32
+ readonly type: "string";
33
+ readonly description: "Field name from available metadata";
34
+ };
35
+ readonly operator: {
36
+ readonly type: "string";
37
+ readonly enum: readonly ["contains", "equals", "startsWith", "endsWith", "greaterThan", "lessThan", "greaterThanOrEqual", "lessThanOrEqual", "notEqual", "dateIsToday", "dateIsAfter", "dateIsBefore", "dateIsEqual", "dateIsGreaterEqual", "dateIsLessEqual", "dateTimeIsAfter", "dateTimeIsBefore", "dateTimeIsGreaterEqual", "dateTimeIsLessEqual"];
38
+ };
39
+ readonly value: {
40
+ readonly type: readonly ["string", "number", "boolean", "null"];
41
+ readonly description: "Value for the clause; null for dateIsToday";
42
+ };
43
+ };
44
+ readonly required: readonly ["field", "operator", "value"];
45
+ readonly additionalProperties: false;
46
+ };
47
+ };
48
+ };
49
+ readonly required: readonly ["logic", "negated", "clauses"];
50
+ readonly additionalProperties: false;
51
+ };
52
+ };
53
+ };
54
+ readonly required: readonly ["groups"];
55
+ readonly additionalProperties: false;
56
+ };
57
+ /**
58
+ * OpenAI-specific response_format wrapper for structured output.
59
+ *
60
+ * @beta
61
+ */
62
+ export declare const OPENAI_CRITERIA_RESPONSE_FORMAT: {
63
+ readonly type: "json_schema";
64
+ readonly json_schema: {
65
+ readonly name: "criteria_interpretation";
66
+ readonly strict: true;
67
+ readonly schema: {
68
+ readonly type: "object";
69
+ readonly properties: {
70
+ readonly groups: {
71
+ readonly type: "array";
72
+ readonly items: {
73
+ readonly type: "object";
74
+ readonly properties: {
75
+ readonly logic: {
76
+ readonly type: "string";
77
+ readonly enum: readonly ["and", "or"];
78
+ readonly description: "How clauses within the group are combined";
79
+ };
80
+ readonly negated: {
81
+ readonly type: "boolean";
82
+ readonly default: false;
83
+ readonly description: "If true, negate the entire group";
84
+ };
85
+ readonly clauses: {
86
+ readonly type: "array";
87
+ readonly items: {
88
+ readonly type: "object";
89
+ readonly properties: {
90
+ readonly field: {
91
+ readonly type: "string";
92
+ readonly description: "Field name from available metadata";
93
+ };
94
+ readonly operator: {
95
+ readonly type: "string";
96
+ readonly enum: readonly ["contains", "equals", "startsWith", "endsWith", "greaterThan", "lessThan", "greaterThanOrEqual", "lessThanOrEqual", "notEqual", "dateIsToday", "dateIsAfter", "dateIsBefore", "dateIsEqual", "dateIsGreaterEqual", "dateIsLessEqual", "dateTimeIsAfter", "dateTimeIsBefore", "dateTimeIsGreaterEqual", "dateTimeIsLessEqual"];
97
+ };
98
+ readonly value: {
99
+ readonly type: readonly ["string", "number", "boolean", "null"];
100
+ readonly description: "Value for the clause; null for dateIsToday";
101
+ };
102
+ };
103
+ readonly required: readonly ["field", "operator", "value"];
104
+ readonly additionalProperties: false;
105
+ };
106
+ };
107
+ };
108
+ readonly required: readonly ["logic", "negated", "clauses"];
109
+ readonly additionalProperties: false;
110
+ };
111
+ };
112
+ };
113
+ readonly required: readonly ["groups"];
114
+ readonly additionalProperties: false;
115
+ };
116
+ };
117
+ };
118
+ export type FieldLike = string | {
119
+ name?: string;
120
+ field?: string;
121
+ label?: string;
122
+ NAME?: string;
123
+ };
124
+ export interface CriteriaInterpretContext {
125
+ fields?: FieldLike[];
126
+ }
127
+ /**
128
+ * Builds the system prompt for criteria interpretation.
129
+ *
130
+ * @beta
131
+ */
132
+ export declare function buildCriteriaSystemPrompt(fields?: FieldLike[], customInstructions?: string): string;
133
+ /**
134
+ * Builds the user prompt for criteria interpretation.
135
+ *
136
+ * @beta
137
+ */
138
+ export declare function buildCriteriaUserPrompt(input: string): string;
139
+ /**
140
+ * Parses the raw response text into CriteriaInterpretationResult.
141
+ *
142
+ * @beta
143
+ */
144
+ export declare function parseCriteriaResponse(text: string | null | undefined): CriteriaInterpretationResult | null;
145
+ //# sourceMappingURL=criteria-interpretation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"criteria-interpretation.d.ts","sourceRoot":"","sources":["../../../src/interactions/criteria-interpretation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAwC7D;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BvB,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOlC,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAElG,MAAM,WAAW,wBAAwB;IACvC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;CACtB;AAUD;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,GAAE,SAAS,EAAO,EACxB,kBAAkB,CAAC,EAAE,MAAM,GAC1B,MAAM,CAaR;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC9B,4BAA4B,GAAG,IAAI,CAkBrC"}
@@ -0,0 +1,2 @@
1
+ export * from './criteria-interpretation';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/interactions/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { AIProvider } from '../ai-provider';
2
+ import type { CriteriaInterpretContext } from '../interactions';
3
+ import type { AIStatus } from '../types';
4
+ import type { ChromeAIConfig, CriteriaInterpretationResult } from '../types';
5
+ /**
6
+ * General Chrome built-in AI provider (Prompt API / Gemini Nano).
7
+ * Configure once; no apiKey required. Exposes interpretCriteria and future capabilities.
8
+ *
9
+ * @remarks
10
+ * Requires Chrome 138+
11
+ * Configure in app bootstrap:
12
+ * ```ts
13
+ * Registration.instance(AIProvider, new ChromeProvider({ providerType: 'chrome' }))
14
+ * ```
15
+ *
16
+ * @beta
17
+ */
18
+ export declare class ChromeProvider implements AIProvider {
19
+ private readonly transport;
20
+ private readonly criteriaInstructions?;
21
+ constructor(config?: ChromeAIConfig);
22
+ getStatus(): Promise<AIStatus>;
23
+ triggerDownload(): Promise<void>;
24
+ interpretCriteria(input: string, context: CriteriaInterpretContext): Promise<CriteriaInterpretationResult | null>;
25
+ }
26
+ //# sourceMappingURL=chrome-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chrome-provider.d.ts","sourceRoot":"","sources":["../../../src/providers/chrome-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAOjD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAEhE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,cAAc,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAK7E;;;;;;;;;;;;GAYG;AACH,qBAAa,cAAe,YAAW,UAAU;IAC/C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAwB;IAClD,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAS;gBAEnC,MAAM,GAAE,cAAmB;IAKjC,SAAS,IAAI,OAAO,CAAC,QAAQ,CAAC;IAS9B,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAIhC,iBAAiB,CACrB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,4BAA4B,GAAG,IAAI,CAAC;CAiBhD"}
@@ -0,0 +1,15 @@
1
+ import type { AIProvider } from '../ai-provider';
2
+ import type { CriteriaInterpretContext } from '../interactions';
3
+ import type { AIStatus } from '../types';
4
+ import type { CriteriaInterpretationResult } from '../types';
5
+ /**
6
+ * Default no-op AI provider. Used when no provider is configured.
7
+ * Components should check for capability support and show "Configure AI" state when appropriate.
8
+ *
9
+ * @beta
10
+ */
11
+ export declare class DefaultAIProvider implements AIProvider {
12
+ getStatus(): Promise<AIStatus>;
13
+ interpretCriteria(_input: string, _context: CriteriaInterpretContext): Promise<CriteriaInterpretationResult | null>;
14
+ }
15
+ //# sourceMappingURL=default-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-provider.d.ts","sourceRoot":"","sources":["../../../src/providers/default-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAE7D;;;;;GAKG;AACH,qBAAa,iBAAkB,YAAW,UAAU;IAC5C,SAAS,IAAI,OAAO,CAAC,QAAQ,CAAC;IAI9B,iBAAiB,CACrB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,wBAAwB,GACjC,OAAO,CAAC,4BAA4B,GAAG,IAAI,CAAC;CAGhD"}
@@ -0,0 +1,25 @@
1
+ import type { AIProvider } from '../ai-provider';
2
+ import type { CriteriaInterpretContext } from '../interactions';
3
+ import type { AIStatus } from '../types';
4
+ import type { AITransport } from '../types';
5
+ import type { CriteriaInterpretationResult } from '../types';
6
+ export interface OpenAIProviderConfig {
7
+ criteriaInstructions?: string;
8
+ }
9
+ /**
10
+ * General OpenAI provider. Uses an injectable transport (ServerOpenAITransport).
11
+ * Exposes interpretCriteria and future capabilities (e.g. summarize).
12
+ *
13
+ * @remarks
14
+ * Configure via createAIProvider with ServerAIConfig (provider, model).
15
+ *
16
+ * @beta
17
+ */
18
+ export declare class OpenAIProvider implements AIProvider {
19
+ private readonly transport;
20
+ private readonly criteriaInstructions?;
21
+ constructor(config: OpenAIProviderConfig, transport: AITransport);
22
+ getStatus(): Promise<AIStatus>;
23
+ interpretCriteria(input: string, context: CriteriaInterpretContext): Promise<CriteriaInterpretationResult | null>;
24
+ }
25
+ //# sourceMappingURL=openai-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-provider.d.ts","sourceRoot":"","sources":["../../../src/providers/openai-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAOjD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAEhE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAG7D,MAAM,WAAW,oBAAoB;IACnC,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;;;;;;;GAQG;AACH,qBAAa,cAAe,YAAW,UAAU;IAC/C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAc;IACxC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAS;gBAEnC,MAAM,EAAE,oBAAoB,EAAE,SAAS,EAAE,WAAW;IAK1D,SAAS,IAAI,OAAO,CAAC,QAAQ,CAAC;IAQ9B,iBAAiB,CACrB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,4BAA4B,GAAG,IAAI,CAAC;CAiBhD"}
@@ -0,0 +1,26 @@
1
+ import type { AITransport, ChromeAvailability, StructuredPromptOptions } from '../types';
2
+ /**
3
+ * Chrome Prompt API (Gemini Nano) transport.
4
+ * Uses the built-in LanguageModel API when available.
5
+ *
6
+ * @remarks
7
+ * Requires Chrome 138+
8
+ * Hardware: 16GB RAM, 4+ cores or 4GB+ VRAM, 22GB storage. Desktop only.
9
+ *
10
+ * @beta
11
+ */
12
+ export declare class ChromePromptTransport implements AITransport {
13
+ private static getLanguageModel;
14
+ /**
15
+ * Returns the raw Chrome availability state.
16
+ * Use this to show download progress and install CTA when downloadable.
17
+ */
18
+ getAvailability(): Promise<ChromeAvailability>;
19
+ /**
20
+ * Starts the model download by creating a minimal session.
21
+ * Requires user activation (e.g. click). Call from a user gesture handler.
22
+ */
23
+ triggerDownload(): Promise<void>;
24
+ sendStructuredPrompt(options: StructuredPromptOptions): Promise<string>;
25
+ }
26
+ //# sourceMappingURL=chrome-prompt-transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chrome-prompt-transport.d.ts","sourceRoot":"","sources":["../../../src/transports/chrome-prompt-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAQzF;;;;;;;;;GASG;AACH,qBAAa,qBAAsB,YAAW,WAAW;IACvD,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAM/B;;;OAGG;IACG,eAAe,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAoBpD;;;OAGG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAehC,oBAAoB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC;CAiC9E"}
@@ -0,0 +1,10 @@
1
+ import type { AITransport, StructuredPromptOptions } from '../types';
2
+ /**
3
+ * No-op transport for DefaultAIProvider.
4
+ *
5
+ * @beta
6
+ */
7
+ export declare class DefaultTransport implements AITransport {
8
+ sendStructuredPrompt(_options: StructuredPromptOptions): Promise<string>;
9
+ }
10
+ //# sourceMappingURL=default-transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-transport.d.ts","sourceRoot":"","sources":["../../../src/transports/default-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAErE;;;;GAIG;AACH,qBAAa,gBAAiB,YAAW,WAAW;IAC5C,oBAAoB,CAAC,QAAQ,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC;CAG/E"}