@smart-cloud/ai-kit-core 1.4.7 → 1.4.8

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.
@@ -0,0 +1 @@
1
+ export declare const TEXT_DOMAIN = "smartcloud-ai-kit";
@@ -0,0 +1,3 @@
1
+ export declare const AiKitFeatureIcon: React.FC<React.SVGProps<SVGSVGElement>>;
2
+ export declare const AiKitChatbotIcon: React.FC<React.SVGProps<SVGSVGElement>>;
3
+ export declare const AiKitDocSearchIcon: React.FC<React.SVGProps<SVGSVGElement>>;
package/dist/index.d.ts CHANGED
@@ -1,613 +1,40 @@
1
- import { SubscriptionType, WpSuitePluginBase } from '@smart-cloud/wpsuite-core';
2
- import { StoreDescriptor } from '@wordpress/data';
3
-
4
- interface AiKitConfig {
5
- mode?: AiModePreference;
6
- backendTransport?: BackendTransport;
7
- backendApiName?: string;
8
- backendBaseUrl?: string;
9
- subscriptionType?: SubscriptionType;
10
- enableChatbot?: boolean;
11
- chatbot?: AiChatbotProps;
12
- }
13
- /**
14
- * Ensures we only keep runtime keys that are part of AiKitConfig.
15
- *
16
- * Defensive: upstream getConfig("ai-kit") or persisted site.settings may include
17
- * additional keys, but the admin UI and core should only operate on AiKitConfig.
18
- */
19
- declare const sanitizeAiKitConfig: (input: unknown) => AiKitConfig;
20
- declare const actions: {
21
- setShowChatbotPreview(showChatbotPreview: boolean): {
22
- type: string;
23
- showChatbotPreview: boolean;
24
- };
25
- setLanguage(language: string | undefined | null): {
26
- type: string;
27
- language: string | null | undefined;
28
- };
29
- setDirection(direction: "ltr" | "rtl" | "auto" | undefined | null): {
30
- type: string;
31
- direction: "ltr" | "rtl" | "auto" | null | undefined;
32
- };
33
- setConfig: (config: AiKitConfig) => {
34
- type: "SET_CONFIG";
35
- config: AiKitConfig;
36
- };
37
- };
38
- interface CustomTranslations {
39
- [key: string]: Record<string, string>;
40
- }
41
- interface State {
42
- config: AiKitConfig | null;
43
- showChatbotPreview: boolean;
44
- language: string | undefined | null;
45
- direction: "ltr" | "rtl" | "auto" | undefined | null;
46
- customTranslations: CustomTranslations | null;
47
- }
48
- type Store = StoreDescriptor;
49
- type StoreSelectors = {
50
- getConfig(): AiKitConfig | null;
51
- isShowChatbotPreview(): boolean;
52
- getCustomTranslations(): CustomTranslations | null;
53
- getLanguage(): string | undefined | null;
54
- getDirection(): "ltr" | "rtl" | "auto" | undefined | null;
55
- getState(): State;
56
- };
57
- type StoreActions = Omit<typeof actions, "setConfig"> & {
58
- setConfig?: typeof actions.setConfig;
59
- };
60
- declare const getStoreDispatch: (store: Store) => Omit<StoreActions, "setConfig">;
61
- declare const getStoreSelect: (store: Store) => StoreSelectors;
62
- declare const reloadConfig: (store: Store) => Promise<void>;
63
- declare const observeStore: (observableStore: Store, selector: (state: State) => boolean | number | string | null | undefined, onChange: (nextValue: boolean | number | string | null | undefined, previousValue: boolean | number | string | null | undefined) => void) => () => void;
64
-
65
- type ContextKind = "admin" | "frontend";
66
- type AiModePreference = "local-only" | "backend-fallback" | "backend-only";
67
- type BuiltInAiFeature = "prompt" | "summarizer" | "writer" | "rewriter" | "proofreader" | "language-detector" | "translator";
68
- type CapabilitySource = "on-device" | "backend" | "none";
69
- type BackendTransport = "gatey" | "fetch";
70
- interface AiKit {
71
- features: AiKitFeatures;
72
- settings: AiKitSettings;
73
- nonce: string;
74
- restUrl: string;
75
- view: "settings" | "diagnostics";
76
- }
77
- interface AiKitFeatures {
78
- readonly store: Promise<Store>;
79
- readonly write: Features["write"];
80
- readonly rewrite: Features["rewrite"];
81
- readonly proofread: Features["proofread"];
82
- readonly summarize: Features["summarize"];
83
- readonly translate: Features["translate"];
84
- readonly detectLanguage: Features["detectLanguage"];
85
- readonly prompt: Features["prompt"];
86
- readonly sendChatMessage: Features["sendChatMessage"];
87
- readonly sendFeedbackMessage: Features["sendFeedbackMessage"];
88
- readonly sendSearchMessage: Features["sendSearchMessage"];
89
- readonly renderFeature: (args: AiFeatureArgs) => Promise<AiWorkerHandle>;
90
- readonly renderSearchComponent: (args: DocSearchArgs) => Promise<AiWorkerHandle>;
91
- }
92
- interface AiKitSettings {
93
- /**
94
- * Context injected into supported Chrome APIs (Writer/Rewriter/Summarizer) and/or backend.
95
- */
96
- sharedContext?: string;
97
- /**
98
- * Optional language configuration used to resolve default input/output languages.
99
- * Keep this lightweight: most users will rely on defaults.
100
- */
101
- defaultOutputLanguage?: AiKitLanguageCode;
102
- /** Optional URL to custom translations JSON file. */
103
- customTranslationsUrl?: string;
104
- /** Chat optimization: number of seconds a successful reCAPTCHA assessment remains valid for the current chat session. */
105
- reCaptchaChatTtlSeconds?: number;
106
- /** Whether to show "Powered by WPSuite AI-Kit" branding in UIs. */
107
- enablePoweredBy?: boolean;
108
- /** Whether to enable server-side debug logging for AI-Kit. */
109
- debugLoggingEnabled?: boolean;
110
- }
111
- interface DeviceAvailability {
112
- available: boolean;
113
- status?: Availability | "api-not-present" | "unknown-feature" | "error";
114
- reason?: string;
115
- error?: Error;
116
- }
117
- interface CapabilityDecision {
118
- feature: BuiltInAiFeature;
119
- source: CapabilitySource;
120
- mode: AiModePreference;
121
- onDeviceAvailable: boolean;
122
- onDeviceStatus?: DeviceAvailability["status"];
123
- onDeviceReason?: DeviceAvailability["reason"];
124
- backendAvailable: boolean;
125
- backendTransport?: BackendTransport;
126
- backendApiName?: string;
127
- backendBaseUrl?: string;
128
- backendReason?: string;
129
- reason: string;
130
- }
131
- interface BackendCallOptions {
132
- signal?: AbortSignal;
133
- headers?: Record<string, string>;
134
- query?: Record<string, string | number | boolean>;
135
- /**
136
- * Optional status callback for progress / UI feedback.
137
- */
138
- onStatus?: (event: AiKitStatusEvent) => void;
139
- }
140
- type AiKitLanguageCode = "ar" | "en" | "zh" | "nl" | "fr" | "de" | "he" | "hi" | "hu" | "id" | "it" | "ja" | "ko" | "no" | "pl" | "pt" | "ru" | "es" | "sv" | "th" | "tr" | "uk";
141
- type AiKitLanguageRef = "site" | "admin" | "content" | AiKitLanguageCode;
142
- type AiKitLanguageProfile = "singleSite" | "englishAdminSingleFrontend" | "multilingual" | "custom";
143
- type OnDeviceUnsupportedLanguageStrategy = "prefer-backend" | "pivot-translate";
144
- type AiKitStatusStep = "decide" | "on-device:init" | "on-device:download" | "on-device:ready" | "on-device:run" | "backend:request" | "backend:waiting" | "backend:response" | "done" | "error";
145
- interface AiKitStatusEvent {
146
- feature: BuiltInAiFeature;
147
- context: ContextKind;
148
- step: AiKitStatusStep;
149
- /** Where the work is happening. */
150
- source?: CapabilitySource;
151
- /** 0..1 for progress events (e.g. download). */
152
- progress?: number;
153
- loaded?: number;
154
- total?: number;
155
- message?: string;
156
- silent?: boolean;
157
- }
158
- declare class BackendError extends Error {
159
- readonly decision?: CapabilityDecision | undefined;
160
- readonly status?: number | undefined;
161
- constructor(message: string, decision?: CapabilityDecision | undefined, status?: number | undefined);
162
- }
163
- type AiWorkerHandle = {
164
- container: HTMLDivElement;
165
- close: () => void;
166
- unmount: () => void;
167
- };
168
- type AiFeatureArgs = AiFeatureProps & {
169
- target?: string | HTMLElement;
170
- };
171
- type AiFeatureMode = "proofread" | "translate" | "write" | "rewrite" | "summarize" | "generatePostMetadata" | "generateImageMetadata";
172
- type AiWorkerProps = {
173
- store: Store;
174
- variation?: "default" | "modal";
175
- language?: string;
176
- showOpenButton?: boolean;
177
- openButtonTitle?: string;
178
- openButtonIcon?: string;
179
- showOpenButtonTitle?: boolean;
180
- showOpenButtonIcon?: boolean;
181
- direction?: "ltr" | "rtl" | "auto";
182
- colorMode?: "light" | "dark" | "auto";
183
- colors?: Record<string, string>;
184
- primaryColor?: string;
185
- primaryShade?: {
186
- light?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
187
- dark?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
188
- };
189
- themeOverrides?: string;
190
- title?: string;
191
- onClose: () => void;
192
- };
193
- type HistoryStorageMode = "localstorage" | "sessionstorage" | "nostorage";
194
- type OpenButtonIconLayout = "top" | "bottom" | "left" | "right";
195
- type OpenButtonPosition = "bottom-right" | "bottom-left" | "top-right" | "top-left";
196
- type AiChatbotLabels = Partial<{
197
- modalTitle: string;
198
- userLabel: string;
199
- assistantLabel: string;
200
- assistantThinkingLabel: string;
201
- askMeLabel: string;
202
- sendLabel: string;
203
- cancelLabel: string;
204
- resetLabel: string;
205
- confirmLabel: string;
206
- clickAgainToConfirmLabel: string;
207
- notSentLabel: string;
208
- editLabel: string;
209
- readyLabel: string;
210
- readyEmptyLabel: string;
211
- addLabel: string;
212
- addImageLabel: string;
213
- removeImageLabel: string;
214
- closeChatLabel: string;
215
- maximizeLabel: string;
216
- restoreSizeLabel: string;
217
- referencesLabel: string;
218
- referenceLabel: string;
219
- acceptResponseLabel: string;
220
- rejectResponseLabel: string;
221
- placeholder: string;
222
- emptyResponseLabel: string;
223
- unexpectedErrorLabel: string;
224
- }>;
225
- type AiChatbotProps = AiWorkerProps & {
226
- context?: ContextKind;
227
- placeholder?: string;
228
- maxImages?: number;
229
- maxImageBytes?: number;
230
- previewMode?: boolean;
231
- /**
232
- * Chat history persistence:
233
- * - "localstorage" (default)
234
- * - "sessionstorage"
235
- * - "nostorage"
236
- */
237
- historyStorage?: HistoryStorageMode;
238
- /**
239
- * Empty chat history after X days
240
- */
241
- emptyHistoryAfterDays?: number;
242
- /**
243
- * UI labels override (admin UI will populate later)
244
- */
245
- labels?: AiChatbotLabels;
246
- /**
247
- * Open button icon layout relative to text.
248
- * Default: "top"
249
- */
250
- openButtonIconLayout?: OpenButtonIconLayout;
251
- /**
252
- * Open button position in the viewport.
253
- * Default: "bottom-right"
254
- * Options: "bottom-right" | "bottom-left" | "top-right" | "top-left"
255
- */
256
- openButtonPosition?: OpenButtonPosition;
257
- };
258
- type AiFeatureOptions = {
259
- text?: string;
260
- instructions?: string;
261
- inputLanguage?: AiKitLanguageCode | "auto";
262
- outputLanguage?: AiKitLanguageCode | "auto";
263
- tone?: WriterTone | RewriterTone;
264
- length?: WriterLength | RewriterLength | SummarizerLength;
265
- type?: SummarizerType;
266
- outputFormat?: "plain-text" | "markdown" | "html";
267
- };
268
- type AiFeatureProps = AiWorkerProps & {
269
- mode: AiFeatureMode;
270
- context?: ContextKind;
271
- modeOverride?: AiModePreference;
272
- autoRun?: boolean;
273
- onDeviceTimeout?: number;
274
- editable?: boolean;
275
- acceptButtonTitle?: string;
276
- showRegenerateOnBackendButton?: boolean;
277
- optionsDisplay?: "collapse" | "horizontal" | "vertical";
278
- default?: AiFeatureOptions & {
279
- getText?: Promise<string> | (() => Promise<string>);
280
- image?: Blob;
281
- };
282
- allowOverride?: {
283
- text?: boolean;
284
- instructions?: boolean;
285
- tone?: boolean;
286
- length?: boolean;
287
- type?: boolean;
288
- outputLanguage?: boolean;
289
- outputFormat?: boolean;
290
- };
291
- onAccept?: (result: unknown) => void;
292
- onOptionsChanged?: (options: AiFeatureOptions) => void;
293
- };
294
- interface SummarizeArgs {
295
- text: string;
296
- context?: string;
297
- sharedContext?: string;
298
- type?: SummarizerType;
299
- format?: SummarizerFormat;
300
- length?: SummarizerLength;
301
- outputLanguage?: AiKitLanguageCode;
302
- }
303
- interface SummarizeResult {
304
- result: string;
305
- }
306
- interface WriteArgs {
307
- prompt: string;
308
- context?: string;
309
- sharedContext?: string;
310
- tone?: WriterTone;
311
- format?: WriterFormat;
312
- length?: WriterLength;
313
- outputLanguage?: AiKitLanguageCode;
314
- }
315
- interface WriteResult {
316
- result: string;
317
- }
318
- interface RewriteArgs {
319
- text: string;
320
- context?: string;
321
- sharedContext?: string;
322
- tone?: RewriterTone;
323
- format?: RewriterFormat;
324
- length?: RewriterLength;
325
- outputLanguage?: AiKitLanguageCode;
326
- }
327
- interface RewriteResult {
328
- result: string;
329
- }
330
- interface ProofreadArgs {
331
- text: string;
332
- expectedInputLanguages?: AiKitLanguageCode[];
333
- includeCorrectionTypes?: boolean;
334
- includeCorrectionExplanations?: boolean;
335
- correctionExplanationLanguage?: AiKitLanguageCode;
336
- }
337
- /**
338
- * ProofreadResult is provided by dom-chromium-ai:
339
- * interface ProofreadResult { correctedInput: string; corrections: ProofreadCorrection[] }
340
- */
341
- interface ProofreadOutput {
342
- result: ProofreadResult;
343
- }
344
- interface DetectLanguageArgs {
345
- text: string;
346
- }
347
- interface DetectLanguageOutput {
348
- result: {
349
- candidates: LanguageDetectionResult[];
350
- };
351
- }
352
- interface TranslateArgs {
353
- text: string;
354
- sourceLanguage: AiKitLanguageCode;
355
- targetLanguage: AiKitLanguageCode;
356
- }
357
- interface TranslateResult {
358
- result: string;
359
- }
360
- type PromptMessages = Array<{
361
- role: "system" | "user" | "assistant";
362
- content: string;
363
- }>;
364
- /**
365
- * Visual inputs supported by Chrome Prompt API multimodal prompting.
366
- * Note: For backend uploads we only handle Blob/File inputs.
367
- */
368
- type PromptImageInput = Blob | File | HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap | VideoFrame | ImageData;
369
- /**
370
- * Audio input for multimodal prompting.
371
- * Backend supports base64-encoded audio with format specification.
372
- */
373
- type PromptAudioInput = {
374
- format: string;
375
- data: string;
376
- };
377
- interface PromptArgs {
378
- messages: PromptMessages;
379
- sharedContext?: string;
380
- outputLanguage?: AiKitLanguageCode;
381
- /**
382
- * Optional multimodal images.
383
- * - On-device: passed as { type: "image", value: ... } parts.
384
- * - Backend: only Blob/File inputs are handled (inline data URLs or signed upload).
385
- */
386
- images?: PromptImageInput[];
387
- /**
388
- * Optional multimodal audio.
389
- * - Backend only (Nova models support audio input)
390
- * - Formats: audio/webm, audio/mp3, audio/wav, audio/flac, audio/aac
391
- */
392
- audio?: PromptAudioInput;
393
- /**
394
- * Optional response constraint schema.
395
- */
396
- responseConstraint?: {
397
- type: "object";
398
- properties: Record<string, unknown>;
399
- required: string[];
400
- additionalProperties: boolean;
401
- };
402
- /**
403
- * Optional on-device tuning:
404
- */
405
- topK?: number;
406
- temperature?: number;
407
- }
408
- interface PromptResult {
409
- result: string;
410
- sessionId?: string;
411
- metadata?: {
412
- messageId: string;
413
- };
414
- }
415
- interface RetrievedDoc {
416
- docId: string;
417
- title?: string;
418
- description?: string;
419
- author?: string;
420
- sourceUrl?: string;
421
- }
422
- interface RetrievedChunk {
423
- docId: string;
424
- chunkId: string;
425
- snippet?: string;
426
- }
427
- interface ProcessedCitations {
428
- docs: Array<RetrievedDoc>;
429
- chunks: Array<RetrievedChunk>;
430
- anchors?: Array<{
431
- span: {
432
- start: number;
433
- end: number;
434
- };
435
- chunkIds: Array<string>;
436
- }>;
437
- }
438
- interface SearchResult {
439
- result: string;
440
- sessionId?: string;
441
- citations?: ProcessedCitations;
442
- metadata?: {
443
- modelId?: string;
444
- requestId?: string;
445
- inputTokens?: number;
446
- outputTokens?: number;
447
- usedKB?: boolean;
448
- kbId?: string;
449
- citationCount?: number;
450
- fallbackReason?: string;
451
- };
452
- }
453
- interface SearchMessageArgs {
454
- /** Search query in the user's language (required if no audio). */
455
- query?: string;
456
- /** Optional audio query (alternative to text query). Blob will be uploaded to S3. */
457
- audio?: Blob;
458
- /** Optional backend session for future optimizations. */
459
- sessionId?: string;
460
- /** Optional shared context (defaults to AiKit settings sharedContext). */
461
- sharedContext?: string;
462
- knowledgeBaseId?: string;
463
- /**
464
- * Optional on-device tuning:
465
- */
466
- topK?: number;
467
- temperature?: number;
468
- /** User-selected category filters (when provided, skips model-based filter selection) */
469
- userSelectedCategories?: string[];
470
- /** User-selected subcategory filters */
471
- userSelectedSubcategories?: string[];
472
- /** User-selected tag filters */
473
- userSelectedTags?: string[];
474
- }
475
- interface ChatMessageArgs {
476
- sessionId?: string;
477
- message?: string;
478
- audio?: Blob;
479
- sharedContext?: string;
480
- images?: PromptImageInput[];
481
- /**
482
- * Optional on-device tuning:
483
- */
484
- topK?: number;
485
- temperature?: number;
486
- }
487
- interface FeedbackMessageArgs {
488
- feedbackType: "accepted" | "rejected";
489
- feedbackMessageId: string;
490
- sessionId: string;
491
- }
492
- type DocSearchProps = AiWorkerProps & {
493
- context?: ContextKind;
494
- autoRun?: boolean;
495
- /** Title shown above the search input (optional). */
496
- title?: string;
497
- /** Optional search input. */
498
- getSearchText?: () => string;
499
- /** Optional base64 icon (SVG or PNG) for the search button. */
500
- searchButtonIcon?: string;
501
- showSearchButtonTitle?: boolean;
502
- showSearchButtonIcon?: boolean;
503
- /** Whether to render document cards under the summary. */
504
- showSources?: boolean;
505
- /** Max number of results to return. */
506
- topK?: number;
507
- /** Max snippet length shown per chunk. */
508
- snippetMaxChars?: number;
509
- /** Optional callback when clicking on a document card. */
510
- onClickDoc?: (doc: RetrievedDoc) => void;
511
- /** Enable user-selectable category and tag filters */
512
- enableUserFilters?: boolean;
513
- /** Available categories (category -> subcategories map) for user selection */
514
- availableCategories?: Record<string, string[]>;
515
- /** Available tags for user selection */
516
- availableTags?: string[];
517
- };
518
- type DocSearchArgs = DocSearchProps & {
519
- target?: string | HTMLElement;
520
- };
521
- type AnyCreateCoreOptions = LanguageModelCreateCoreOptions | SummarizerCreateCoreOptions | WriterCreateCoreOptions | RewriterCreateCoreOptions | ProofreaderCreateCoreOptions | LanguageDetectorCreateCoreOptions | TranslatorCreateCoreOptions;
522
- interface Capabilities {
523
- MIN_CHROME_VERSION?: Partial<Record<BuiltInAiFeature, number>>;
524
- isOnDeviceLanguageSupported: (outputLanguage: AiKitLanguageCode) => boolean;
525
- checkOnDeviceAvailability: (feature: BuiltInAiFeature, availabilityOptions?: AnyCreateCoreOptions) => Promise<DeviceAvailability>;
526
- decideCapability: (feature: BuiltInAiFeature, availabilityOptions?: AnyCreateCoreOptions, modeOverride?: AiModePreference) => Promise<CapabilityDecision>;
527
- resolveBackend: () => Promise<{
528
- available: boolean;
529
- transport?: BackendTransport;
530
- apiName?: string;
531
- baseUrl?: string;
532
- reason?: string;
533
- }>;
534
- willUseOnDevice: (feature: BuiltInAiFeature, availabilityOptions?: AnyCreateCoreOptions) => Promise<boolean>;
535
- willUseBackend: (feature: BuiltInAiFeature, availabilityOptions?: AnyCreateCoreOptions) => Promise<boolean>;
536
- }
537
- interface Backend<TResponse> {
538
- dispatchFeatureBackend: (decision: CapabilityDecision, context: ContextKind, feature: BuiltInAiFeature, requestBody: unknown, options: BackendCallOptions) => Promise<TResponse>;
539
- dispatchCustomBackend: (decision: CapabilityDecision, context: ContextKind, customPath: string, method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", requestBody: unknown, options: BackendCallOptions) => Promise<TResponse>;
540
- }
541
- type FeatureOptions = BackendCallOptions & {
542
- context?: ContextKind;
543
- modeOverride?: AiModePreference;
544
- onDeviceTimeoutOverride?: number;
545
- silent?: boolean;
546
- };
547
- interface Features {
548
- getWriteOptions: (args: Partial<WriteArgs>) => Promise<WriterCreateCoreOptions>;
549
- write: (args: WriteArgs, options?: FeatureOptions) => Promise<WriteResult>;
550
- getRewriteOptions: (args: Partial<RewriteArgs>) => Promise<RewriterCreateCoreOptions>;
551
- rewrite: (args: RewriteArgs, options?: FeatureOptions) => Promise<RewriteResult>;
552
- getProofreadOptions: () => Promise<ProofreaderCreateCoreOptions>;
553
- proofread: (args: ProofreadArgs, options?: FeatureOptions) => Promise<ProofreadOutput>;
554
- getSummarizeOptions: (args: Partial<SummarizeArgs>) => Promise<SummarizerCreateCoreOptions>;
555
- summarize: (args: SummarizeArgs, options?: FeatureOptions) => Promise<SummarizeResult>;
556
- getTranslateOptions: (args: Partial<TranslateArgs>) => Promise<TranslatorCreateCoreOptions>;
557
- translate: (args: TranslateArgs, options?: FeatureOptions) => Promise<TranslateResult>;
558
- detectLanguage: (args: DetectLanguageArgs, options?: FeatureOptions) => Promise<DetectLanguageOutput>;
559
- getPromptOptions: (args: Partial<PromptArgs>) => Promise<LanguageModelCreateCoreOptions>;
560
- prompt: (args: PromptArgs, options?: FeatureOptions) => Promise<PromptResult>;
561
- sendChatMessage: (args: ChatMessageArgs, options?: FeatureOptions) => Promise<PromptResult>;
562
- sendFeedbackMessage: (args: FeedbackMessageArgs, options?: FeatureOptions) => Promise<PromptResult>;
563
- sendSearchMessage: (args: SearchMessageArgs, options?: FeatureOptions) => Promise<SearchResult>;
564
- }
565
-
566
- type AiKitReadyEvent = "wpsuite:ai-kit:ready";
567
- type AiKitErrorEvent = "wpsuite:ai-kit:error";
568
- type AiKitPlugin = WpSuitePluginBase & AiKit;
569
- declare function getAiKitPlugin(): AiKitPlugin;
570
- declare function waitForAiKitReady(timeoutMs?: number): Promise<void>;
571
- declare function getStore(timeoutMs?: number): Promise<Store>;
572
-
573
- declare const TEXT_DOMAIN = "smartcloud-ai-kit";
574
-
575
- declare const AiKitFeatureIcon: React.FC<React.SVGProps<SVGSVGElement>>;
576
- declare const AiKitChatbotIcon: React.FC<React.SVGProps<SVGSVGElement>>;
577
- declare const AiKitDocSearchIcon: React.FC<React.SVGProps<SVGSVGElement>>;
578
-
579
- declare const LANGUAGE_OPTIONS: {
1
+ import { getAiKitPlugin, getStore, waitForAiKitReady, type AiKitErrorEvent, type AiKitPlugin, type AiKitReadyEvent } from "./runtime";
2
+ import { AiFeatureArgs, DocSearchArgs, AiKitLanguageCode, AiWorkerHandle, type Backend, type Capabilities, type Features } from "./types";
3
+ import { TEXT_DOMAIN } from "./constants";
4
+ export { getAiKitPlugin, getStore, TEXT_DOMAIN, waitForAiKitReady, type AiKitErrorEvent, type AiKitPlugin, type AiKitReadyEvent, };
5
+ export { getStoreDispatch, getStoreSelect, observeStore, sanitizeAiKitConfig, reloadConfig, type AiKitConfig, type CustomTranslations, type State, type Store, } from "./store";
6
+ export * from "./icons";
7
+ export * from "./types";
8
+ export declare const LANGUAGE_OPTIONS: {
580
9
  label: string;
581
10
  value: AiKitLanguageCode;
582
11
  }[];
583
- declare const getMinChromeVersions: () => Promise<Partial<Record<BuiltInAiFeature, number>> | undefined>;
584
- declare const isOnDeviceLanguageSupported: (...args: Parameters<Capabilities["isOnDeviceLanguageSupported"]>) => Promise<boolean>;
585
- declare const decideCapability: (...args: Parameters<Capabilities["decideCapability"]>) => Promise<CapabilityDecision>;
586
- declare const checkOnDeviceAvailability: (...args: Parameters<Capabilities["checkOnDeviceAvailability"]>) => Promise<DeviceAvailability>;
587
- declare const resolveBackend: (...args: Parameters<Capabilities["resolveBackend"]>) => Promise<{
12
+ export declare const getMinChromeVersions: () => Promise<Partial<Record<import("./types").BuiltInAiFeature, number>> | undefined>;
13
+ export declare const isOnDeviceLanguageSupported: (...args: Parameters<Capabilities["isOnDeviceLanguageSupported"]>) => Promise<boolean>;
14
+ export declare const decideCapability: (...args: Parameters<Capabilities["decideCapability"]>) => Promise<import("./types").CapabilityDecision>;
15
+ export declare const checkOnDeviceAvailability: (...args: Parameters<Capabilities["checkOnDeviceAvailability"]>) => Promise<import("./types").DeviceAvailability>;
16
+ export declare const resolveBackend: (...args: Parameters<Capabilities["resolveBackend"]>) => Promise<{
588
17
  available: boolean;
589
- transport?: BackendTransport;
18
+ transport?: import("./types").BackendTransport;
590
19
  apiName?: string;
591
20
  baseUrl?: string;
592
21
  reason?: string;
593
22
  }>;
594
- declare const dispatchBackend: (...args: Parameters<Backend<unknown>["dispatchCustomBackend"]>) => Promise<unknown>;
595
- declare const getWriteOptions: (...args: Parameters<Features["getWriteOptions"]>) => Promise<WriterCreateCoreOptions>;
596
- declare const write: (...args: Parameters<Features["write"]>) => Promise<WriteResult>;
597
- declare const getRewriteOptions: (...args: Parameters<Features["getRewriteOptions"]>) => Promise<RewriterCreateCoreOptions>;
598
- declare const rewrite: (...args: Parameters<Features["rewrite"]>) => Promise<RewriteResult>;
599
- declare const getProofreadOptions: (...args: Parameters<Features["getProofreadOptions"]>) => Promise<ProofreaderCreateCoreOptions>;
600
- declare const proofread: (...args: Parameters<Features["proofread"]>) => Promise<ProofreadOutput>;
601
- declare const getSummarizeOptions: (...args: Parameters<Features["getSummarizeOptions"]>) => Promise<SummarizerCreateCoreOptions>;
602
- declare const summarize: (...args: Parameters<Features["summarize"]>) => Promise<SummarizeResult>;
603
- declare const getTranslateOptions: (...args: Parameters<Features["getTranslateOptions"]>) => Promise<TranslatorCreateCoreOptions>;
604
- declare const translate: (...args: Parameters<Features["translate"]>) => Promise<TranslateResult>;
605
- declare const detectLanguage: (...args: Parameters<Features["detectLanguage"]>) => Promise<DetectLanguageOutput>;
606
- declare const getPromptOptions: (...args: Parameters<Features["getPromptOptions"]>) => Promise<LanguageModelCreateCoreOptions>;
607
- declare const prompt: (...args: Parameters<Features["prompt"]>) => Promise<PromptResult>;
608
- declare const sendChatMessage: (...args: Parameters<Features["sendChatMessage"]>) => Promise<PromptResult>;
609
- declare const sendFeedbackMessage: (...args: Parameters<Features["sendFeedbackMessage"]>) => Promise<PromptResult>;
610
- declare const sendSearchMessage: (...args: Parameters<Features["sendSearchMessage"]>) => Promise<SearchResult>;
611
- declare const initializeAiKit: (renderFeature: (args: AiFeatureArgs) => Promise<AiWorkerHandle>, renderSearchComponent?: (args: DocSearchArgs) => Promise<AiWorkerHandle>) => AiKitPlugin;
612
-
613
- export { type AiChatbotLabels, type AiChatbotProps, type AiFeatureArgs, type AiFeatureMode, type AiFeatureOptions, type AiFeatureProps, type AiKit, AiKitChatbotIcon, type AiKitConfig, AiKitDocSearchIcon, type AiKitErrorEvent, AiKitFeatureIcon, type AiKitFeatures, type AiKitLanguageCode, type AiKitLanguageProfile, type AiKitLanguageRef, type AiKitPlugin, type AiKitReadyEvent, type AiKitSettings, type AiKitStatusEvent, type AiKitStatusStep, type AiModePreference, type AiWorkerHandle, type AiWorkerProps, type AnyCreateCoreOptions, type Backend, type BackendCallOptions, BackendError, type BackendTransport, type BuiltInAiFeature, type Capabilities, type CapabilityDecision, type CapabilitySource, type ChatMessageArgs, type ContextKind, type CustomTranslations, type DetectLanguageArgs, type DetectLanguageOutput, type DeviceAvailability, type DocSearchArgs, type DocSearchProps, type FeatureOptions, type Features, type FeedbackMessageArgs, type HistoryStorageMode, LANGUAGE_OPTIONS, type OnDeviceUnsupportedLanguageStrategy, type OpenButtonIconLayout, type OpenButtonPosition, type ProcessedCitations, type PromptArgs, type PromptAudioInput, type PromptImageInput, type PromptMessages, type PromptResult, type ProofreadArgs, type ProofreadOutput, type RetrievedChunk, type RetrievedDoc, type RewriteArgs, type RewriteResult, type SearchMessageArgs, type SearchResult, type State, type Store, type SummarizeArgs, type SummarizeResult, TEXT_DOMAIN, type TranslateArgs, type TranslateResult, type WriteArgs, type WriteResult, checkOnDeviceAvailability, decideCapability, detectLanguage, dispatchBackend, getAiKitPlugin, getMinChromeVersions, getPromptOptions, getProofreadOptions, getRewriteOptions, getStore, getStoreDispatch, getStoreSelect, getSummarizeOptions, getTranslateOptions, getWriteOptions, initializeAiKit, isOnDeviceLanguageSupported, observeStore, prompt, proofread, reloadConfig, resolveBackend, rewrite, sanitizeAiKitConfig, sendChatMessage, sendFeedbackMessage, sendSearchMessage, summarize, translate, waitForAiKitReady, write };
23
+ export declare const dispatchBackend: (...args: Parameters<Backend<unknown>["dispatchCustomBackend"]>) => Promise<unknown>;
24
+ export declare const getWriteOptions: (...args: Parameters<Features["getWriteOptions"]>) => Promise<WriterCreateCoreOptions>;
25
+ export declare const write: (...args: Parameters<Features["write"]>) => Promise<import("./types").WriteResult>;
26
+ export declare const getRewriteOptions: (...args: Parameters<Features["getRewriteOptions"]>) => Promise<RewriterCreateCoreOptions>;
27
+ export declare const rewrite: (...args: Parameters<Features["rewrite"]>) => Promise<import("./types").RewriteResult>;
28
+ export declare const getProofreadOptions: (...args: Parameters<Features["getProofreadOptions"]>) => Promise<ProofreaderCreateCoreOptions>;
29
+ export declare const proofread: (...args: Parameters<Features["proofread"]>) => Promise<import("./types").ProofreadOutput>;
30
+ export declare const getSummarizeOptions: (...args: Parameters<Features["getSummarizeOptions"]>) => Promise<SummarizerCreateCoreOptions>;
31
+ export declare const summarize: (...args: Parameters<Features["summarize"]>) => Promise<import("./types").SummarizeResult>;
32
+ export declare const getTranslateOptions: (...args: Parameters<Features["getTranslateOptions"]>) => Promise<TranslatorCreateCoreOptions>;
33
+ export declare const translate: (...args: Parameters<Features["translate"]>) => Promise<import("./types").TranslateResult>;
34
+ export declare const detectLanguage: (...args: Parameters<Features["detectLanguage"]>) => Promise<import("./types").DetectLanguageOutput>;
35
+ export declare const getPromptOptions: (...args: Parameters<Features["getPromptOptions"]>) => Promise<LanguageModelCreateCoreOptions>;
36
+ export declare const prompt: (...args: Parameters<Features["prompt"]>) => Promise<import("./types").PromptResult>;
37
+ export declare const sendChatMessage: (...args: Parameters<Features["sendChatMessage"]>) => Promise<import("./types").PromptResult>;
38
+ export declare const sendFeedbackMessage: (...args: Parameters<Features["sendFeedbackMessage"]>) => Promise<import("./types").PromptResult>;
39
+ export declare const sendSearchMessage: (...args: Parameters<Features["sendSearchMessage"]>) => Promise<import("./types").SearchResult>;
40
+ export declare const initializeAiKit: (renderFeature: (args: AiFeatureArgs) => Promise<AiWorkerHandle>, renderSearchComponent?: (args: DocSearchArgs) => Promise<AiWorkerHandle>) => AiKitPlugin;
@@ -0,0 +1,17 @@
1
+ import type { BackendCallOptions, BuiltInAiFeature, CapabilityDecision, ContextKind } from "../types";
2
+ /**
3
+ * Adds X-Recaptcha-Token header for frontend calls when configured.
4
+ */
5
+ export declare function withRecaptchaHeaders(context: ContextKind, headers: Record<string, string>, opts?: {
6
+ cacheKey?: string;
7
+ }): Promise<Record<string, string>>;
8
+ /**
9
+ * Dispatch feature backend call using an already computed decision.
10
+ * Callers should compute decision via decideCapability() once, then call this.
11
+ */
12
+ export declare function dispatchFeatureBackend<TResponse>(decision: CapabilityDecision, context: ContextKind, feature: BuiltInAiFeature, requestBody: unknown, options?: BackendCallOptions): Promise<TResponse>;
13
+ /**
14
+ * Dispatch feature backend call using an already computed decision.
15
+ * Callers should compute decision via decideCapability() once, then call this.
16
+ */
17
+ export declare function dispatchCustomBackend<TResponse>(decision: CapabilityDecision, context: ContextKind, customPath: string, method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", requestBody: unknown, options?: BackendCallOptions): Promise<TResponse>;