@smart-cloud/ai-kit-core 1.4.6 → 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.
- package/dist/constants.d.ts +1 -0
- package/dist/icons.d.ts +3 -0
- package/dist/index.cjs +8 -8
- package/dist/index.d.ts +32 -605
- package/dist/index.js +4 -4
- package/dist/protected/backend.d.ts +17 -0
- package/dist/protected/capabilities.d.ts +25 -0
- package/dist/protected/chunking-utils.d.ts +22 -0
- package/dist/protected/features.d.ts +17 -0
- package/dist/public/backend.d.ts +3 -0
- package/dist/public/capabilities.d.ts +14 -0
- package/dist/public/features.d.ts +17 -0
- package/dist/runtime.d.ts +8 -0
- package/dist/store.d.ts +65 -0
- package/dist/{index.d.cts → types.d.ts} +61 -173
- package/package.json +19 -17
|
@@ -1,80 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 {
|
|
1
|
+
import { Store } from "./store";
|
|
2
|
+
export type ContextKind = "admin" | "frontend";
|
|
3
|
+
export type AiModePreference = "local-only" | "backend-fallback" | "backend-only";
|
|
4
|
+
export type BuiltInAiFeature = "prompt" | "summarizer" | "writer" | "rewriter" | "proofreader" | "language-detector" | "translator";
|
|
5
|
+
export type CapabilitySource = "on-device" | "backend" | "none";
|
|
6
|
+
export type BackendTransport = "gatey" | "fetch";
|
|
7
|
+
export interface AiKit {
|
|
71
8
|
features: AiKitFeatures;
|
|
72
9
|
settings: AiKitSettings;
|
|
73
10
|
nonce: string;
|
|
74
11
|
restUrl: string;
|
|
75
12
|
view: "settings" | "diagnostics";
|
|
76
13
|
}
|
|
77
|
-
interface AiKitFeatures {
|
|
14
|
+
export interface AiKitFeatures {
|
|
78
15
|
readonly store: Promise<Store>;
|
|
79
16
|
readonly write: Features["write"];
|
|
80
17
|
readonly rewrite: Features["rewrite"];
|
|
@@ -89,7 +26,7 @@ interface AiKitFeatures {
|
|
|
89
26
|
readonly renderFeature: (args: AiFeatureArgs) => Promise<AiWorkerHandle>;
|
|
90
27
|
readonly renderSearchComponent: (args: DocSearchArgs) => Promise<AiWorkerHandle>;
|
|
91
28
|
}
|
|
92
|
-
interface AiKitSettings {
|
|
29
|
+
export interface AiKitSettings {
|
|
93
30
|
/**
|
|
94
31
|
* Context injected into supported Chrome APIs (Writer/Rewriter/Summarizer) and/or backend.
|
|
95
32
|
*/
|
|
@@ -108,13 +45,13 @@ interface AiKitSettings {
|
|
|
108
45
|
/** Whether to enable server-side debug logging for AI-Kit. */
|
|
109
46
|
debugLoggingEnabled?: boolean;
|
|
110
47
|
}
|
|
111
|
-
interface DeviceAvailability {
|
|
48
|
+
export interface DeviceAvailability {
|
|
112
49
|
available: boolean;
|
|
113
50
|
status?: Availability | "api-not-present" | "unknown-feature" | "error";
|
|
114
51
|
reason?: string;
|
|
115
52
|
error?: Error;
|
|
116
53
|
}
|
|
117
|
-
interface CapabilityDecision {
|
|
54
|
+
export interface CapabilityDecision {
|
|
118
55
|
feature: BuiltInAiFeature;
|
|
119
56
|
source: CapabilitySource;
|
|
120
57
|
mode: AiModePreference;
|
|
@@ -128,7 +65,7 @@ interface CapabilityDecision {
|
|
|
128
65
|
backendReason?: string;
|
|
129
66
|
reason: string;
|
|
130
67
|
}
|
|
131
|
-
interface BackendCallOptions {
|
|
68
|
+
export interface BackendCallOptions {
|
|
132
69
|
signal?: AbortSignal;
|
|
133
70
|
headers?: Record<string, string>;
|
|
134
71
|
query?: Record<string, string | number | boolean>;
|
|
@@ -137,12 +74,12 @@ interface BackendCallOptions {
|
|
|
137
74
|
*/
|
|
138
75
|
onStatus?: (event: AiKitStatusEvent) => void;
|
|
139
76
|
}
|
|
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 {
|
|
77
|
+
export type AiKitLanguageCode = "ar" | "en" | "zh" | "nl" | "fr" | "de" | "he" | "hi" | "hu" | "id" | "it" | "ja" | "ko" | "no" | "pl" | "pt" | "ru" | "es" | "sv" | "th" | "tr" | "uk";
|
|
78
|
+
export type AiKitLanguageRef = "site" | "admin" | "content" | AiKitLanguageCode;
|
|
79
|
+
export type AiKitLanguageProfile = "singleSite" | "englishAdminSingleFrontend" | "multilingual" | "custom";
|
|
80
|
+
export type OnDeviceUnsupportedLanguageStrategy = "prefer-backend" | "pivot-translate";
|
|
81
|
+
export type AiKitStatusStep = "decide" | "on-device:init" | "on-device:download" | "on-device:ready" | "on-device:run" | "backend:request" | "backend:waiting" | "backend:response" | "done" | "error";
|
|
82
|
+
export interface AiKitStatusEvent {
|
|
146
83
|
feature: BuiltInAiFeature;
|
|
147
84
|
context: ContextKind;
|
|
148
85
|
step: AiKitStatusStep;
|
|
@@ -155,21 +92,21 @@ interface AiKitStatusEvent {
|
|
|
155
92
|
message?: string;
|
|
156
93
|
silent?: boolean;
|
|
157
94
|
}
|
|
158
|
-
declare class BackendError extends Error {
|
|
95
|
+
export declare class BackendError extends Error {
|
|
159
96
|
readonly decision?: CapabilityDecision | undefined;
|
|
160
97
|
readonly status?: number | undefined;
|
|
161
98
|
constructor(message: string, decision?: CapabilityDecision | undefined, status?: number | undefined);
|
|
162
99
|
}
|
|
163
|
-
type AiWorkerHandle = {
|
|
100
|
+
export type AiWorkerHandle = {
|
|
164
101
|
container: HTMLDivElement;
|
|
165
102
|
close: () => void;
|
|
166
103
|
unmount: () => void;
|
|
167
104
|
};
|
|
168
|
-
type AiFeatureArgs = AiFeatureProps & {
|
|
105
|
+
export type AiFeatureArgs = AiFeatureProps & {
|
|
169
106
|
target?: string | HTMLElement;
|
|
170
107
|
};
|
|
171
|
-
type AiFeatureMode = "proofread" | "translate" | "write" | "rewrite" | "summarize" | "generatePostMetadata" | "generateImageMetadata";
|
|
172
|
-
type AiWorkerProps = {
|
|
108
|
+
export type AiFeatureMode = "proofread" | "translate" | "write" | "rewrite" | "summarize" | "generatePostMetadata" | "generateImageMetadata";
|
|
109
|
+
export type AiWorkerProps = {
|
|
173
110
|
store: Store;
|
|
174
111
|
variation?: "default" | "modal";
|
|
175
112
|
language?: string;
|
|
@@ -190,10 +127,10 @@ type AiWorkerProps = {
|
|
|
190
127
|
title?: string;
|
|
191
128
|
onClose: () => void;
|
|
192
129
|
};
|
|
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<{
|
|
130
|
+
export type HistoryStorageMode = "localstorage" | "sessionstorage" | "nostorage";
|
|
131
|
+
export type OpenButtonIconLayout = "top" | "bottom" | "left" | "right";
|
|
132
|
+
export type OpenButtonPosition = "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
133
|
+
export type AiChatbotLabels = Partial<{
|
|
197
134
|
modalTitle: string;
|
|
198
135
|
userLabel: string;
|
|
199
136
|
assistantLabel: string;
|
|
@@ -222,7 +159,7 @@ type AiChatbotLabels = Partial<{
|
|
|
222
159
|
emptyResponseLabel: string;
|
|
223
160
|
unexpectedErrorLabel: string;
|
|
224
161
|
}>;
|
|
225
|
-
type AiChatbotProps = AiWorkerProps & {
|
|
162
|
+
export type AiChatbotProps = AiWorkerProps & {
|
|
226
163
|
context?: ContextKind;
|
|
227
164
|
placeholder?: string;
|
|
228
165
|
maxImages?: number;
|
|
@@ -255,7 +192,7 @@ type AiChatbotProps = AiWorkerProps & {
|
|
|
255
192
|
*/
|
|
256
193
|
openButtonPosition?: OpenButtonPosition;
|
|
257
194
|
};
|
|
258
|
-
type AiFeatureOptions = {
|
|
195
|
+
export type AiFeatureOptions = {
|
|
259
196
|
text?: string;
|
|
260
197
|
instructions?: string;
|
|
261
198
|
inputLanguage?: AiKitLanguageCode | "auto";
|
|
@@ -265,7 +202,7 @@ type AiFeatureOptions = {
|
|
|
265
202
|
type?: SummarizerType;
|
|
266
203
|
outputFormat?: "plain-text" | "markdown" | "html";
|
|
267
204
|
};
|
|
268
|
-
type AiFeatureProps = AiWorkerProps & {
|
|
205
|
+
export type AiFeatureProps = AiWorkerProps & {
|
|
269
206
|
mode: AiFeatureMode;
|
|
270
207
|
context?: ContextKind;
|
|
271
208
|
modeOverride?: AiModePreference;
|
|
@@ -291,7 +228,7 @@ type AiFeatureProps = AiWorkerProps & {
|
|
|
291
228
|
onAccept?: (result: unknown) => void;
|
|
292
229
|
onOptionsChanged?: (options: AiFeatureOptions) => void;
|
|
293
230
|
};
|
|
294
|
-
interface SummarizeArgs {
|
|
231
|
+
export interface SummarizeArgs {
|
|
295
232
|
text: string;
|
|
296
233
|
context?: string;
|
|
297
234
|
sharedContext?: string;
|
|
@@ -300,10 +237,10 @@ interface SummarizeArgs {
|
|
|
300
237
|
length?: SummarizerLength;
|
|
301
238
|
outputLanguage?: AiKitLanguageCode;
|
|
302
239
|
}
|
|
303
|
-
interface SummarizeResult {
|
|
240
|
+
export interface SummarizeResult {
|
|
304
241
|
result: string;
|
|
305
242
|
}
|
|
306
|
-
interface WriteArgs {
|
|
243
|
+
export interface WriteArgs {
|
|
307
244
|
prompt: string;
|
|
308
245
|
context?: string;
|
|
309
246
|
sharedContext?: string;
|
|
@@ -312,10 +249,10 @@ interface WriteArgs {
|
|
|
312
249
|
length?: WriterLength;
|
|
313
250
|
outputLanguage?: AiKitLanguageCode;
|
|
314
251
|
}
|
|
315
|
-
interface WriteResult {
|
|
252
|
+
export interface WriteResult {
|
|
316
253
|
result: string;
|
|
317
254
|
}
|
|
318
|
-
interface RewriteArgs {
|
|
255
|
+
export interface RewriteArgs {
|
|
319
256
|
text: string;
|
|
320
257
|
context?: string;
|
|
321
258
|
sharedContext?: string;
|
|
@@ -324,10 +261,10 @@ interface RewriteArgs {
|
|
|
324
261
|
length?: RewriterLength;
|
|
325
262
|
outputLanguage?: AiKitLanguageCode;
|
|
326
263
|
}
|
|
327
|
-
interface RewriteResult {
|
|
264
|
+
export interface RewriteResult {
|
|
328
265
|
result: string;
|
|
329
266
|
}
|
|
330
|
-
interface ProofreadArgs {
|
|
267
|
+
export interface ProofreadArgs {
|
|
331
268
|
text: string;
|
|
332
269
|
expectedInputLanguages?: AiKitLanguageCode[];
|
|
333
270
|
includeCorrectionTypes?: boolean;
|
|
@@ -338,26 +275,26 @@ interface ProofreadArgs {
|
|
|
338
275
|
* ProofreadResult is provided by dom-chromium-ai:
|
|
339
276
|
* interface ProofreadResult { correctedInput: string; corrections: ProofreadCorrection[] }
|
|
340
277
|
*/
|
|
341
|
-
interface ProofreadOutput {
|
|
278
|
+
export interface ProofreadOutput {
|
|
342
279
|
result: ProofreadResult;
|
|
343
280
|
}
|
|
344
|
-
interface DetectLanguageArgs {
|
|
281
|
+
export interface DetectLanguageArgs {
|
|
345
282
|
text: string;
|
|
346
283
|
}
|
|
347
|
-
interface DetectLanguageOutput {
|
|
284
|
+
export interface DetectLanguageOutput {
|
|
348
285
|
result: {
|
|
349
286
|
candidates: LanguageDetectionResult[];
|
|
350
287
|
};
|
|
351
288
|
}
|
|
352
|
-
interface TranslateArgs {
|
|
289
|
+
export interface TranslateArgs {
|
|
353
290
|
text: string;
|
|
354
291
|
sourceLanguage: AiKitLanguageCode;
|
|
355
292
|
targetLanguage: AiKitLanguageCode;
|
|
356
293
|
}
|
|
357
|
-
interface TranslateResult {
|
|
294
|
+
export interface TranslateResult {
|
|
358
295
|
result: string;
|
|
359
296
|
}
|
|
360
|
-
type PromptMessages = Array<{
|
|
297
|
+
export type PromptMessages = Array<{
|
|
361
298
|
role: "system" | "user" | "assistant";
|
|
362
299
|
content: string;
|
|
363
300
|
}>;
|
|
@@ -365,16 +302,16 @@ type PromptMessages = Array<{
|
|
|
365
302
|
* Visual inputs supported by Chrome Prompt API multimodal prompting.
|
|
366
303
|
* Note: For backend uploads we only handle Blob/File inputs.
|
|
367
304
|
*/
|
|
368
|
-
type PromptImageInput = Blob | File | HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap | VideoFrame | ImageData;
|
|
305
|
+
export type PromptImageInput = Blob | File | HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap | VideoFrame | ImageData;
|
|
369
306
|
/**
|
|
370
307
|
* Audio input for multimodal prompting.
|
|
371
308
|
* Backend supports base64-encoded audio with format specification.
|
|
372
309
|
*/
|
|
373
|
-
type PromptAudioInput = {
|
|
310
|
+
export type PromptAudioInput = {
|
|
374
311
|
format: string;
|
|
375
312
|
data: string;
|
|
376
313
|
};
|
|
377
|
-
interface PromptArgs {
|
|
314
|
+
export interface PromptArgs {
|
|
378
315
|
messages: PromptMessages;
|
|
379
316
|
sharedContext?: string;
|
|
380
317
|
outputLanguage?: AiKitLanguageCode;
|
|
@@ -405,26 +342,26 @@ interface PromptArgs {
|
|
|
405
342
|
topK?: number;
|
|
406
343
|
temperature?: number;
|
|
407
344
|
}
|
|
408
|
-
interface PromptResult {
|
|
345
|
+
export interface PromptResult {
|
|
409
346
|
result: string;
|
|
410
347
|
sessionId?: string;
|
|
411
348
|
metadata?: {
|
|
412
349
|
messageId: string;
|
|
413
350
|
};
|
|
414
351
|
}
|
|
415
|
-
interface RetrievedDoc {
|
|
352
|
+
export interface RetrievedDoc {
|
|
416
353
|
docId: string;
|
|
417
354
|
title?: string;
|
|
418
355
|
description?: string;
|
|
419
356
|
author?: string;
|
|
420
357
|
sourceUrl?: string;
|
|
421
358
|
}
|
|
422
|
-
interface RetrievedChunk {
|
|
359
|
+
export interface RetrievedChunk {
|
|
423
360
|
docId: string;
|
|
424
361
|
chunkId: string;
|
|
425
362
|
snippet?: string;
|
|
426
363
|
}
|
|
427
|
-
interface ProcessedCitations {
|
|
364
|
+
export interface ProcessedCitations {
|
|
428
365
|
docs: Array<RetrievedDoc>;
|
|
429
366
|
chunks: Array<RetrievedChunk>;
|
|
430
367
|
anchors?: Array<{
|
|
@@ -435,7 +372,7 @@ interface ProcessedCitations {
|
|
|
435
372
|
chunkIds: Array<string>;
|
|
436
373
|
}>;
|
|
437
374
|
}
|
|
438
|
-
interface SearchResult {
|
|
375
|
+
export interface SearchResult {
|
|
439
376
|
result: string;
|
|
440
377
|
sessionId?: string;
|
|
441
378
|
citations?: ProcessedCitations;
|
|
@@ -450,7 +387,7 @@ interface SearchResult {
|
|
|
450
387
|
fallbackReason?: string;
|
|
451
388
|
};
|
|
452
389
|
}
|
|
453
|
-
interface SearchMessageArgs {
|
|
390
|
+
export interface SearchMessageArgs {
|
|
454
391
|
/** Search query in the user's language (required if no audio). */
|
|
455
392
|
query?: string;
|
|
456
393
|
/** Optional audio query (alternative to text query). Blob will be uploaded to S3. */
|
|
@@ -472,7 +409,7 @@ interface SearchMessageArgs {
|
|
|
472
409
|
/** User-selected tag filters */
|
|
473
410
|
userSelectedTags?: string[];
|
|
474
411
|
}
|
|
475
|
-
interface ChatMessageArgs {
|
|
412
|
+
export interface ChatMessageArgs {
|
|
476
413
|
sessionId?: string;
|
|
477
414
|
message?: string;
|
|
478
415
|
audio?: Blob;
|
|
@@ -484,12 +421,12 @@ interface ChatMessageArgs {
|
|
|
484
421
|
topK?: number;
|
|
485
422
|
temperature?: number;
|
|
486
423
|
}
|
|
487
|
-
interface FeedbackMessageArgs {
|
|
424
|
+
export interface FeedbackMessageArgs {
|
|
488
425
|
feedbackType: "accepted" | "rejected";
|
|
489
426
|
feedbackMessageId: string;
|
|
490
427
|
sessionId: string;
|
|
491
428
|
}
|
|
492
|
-
type DocSearchProps = AiWorkerProps & {
|
|
429
|
+
export type DocSearchProps = AiWorkerProps & {
|
|
493
430
|
context?: ContextKind;
|
|
494
431
|
autoRun?: boolean;
|
|
495
432
|
/** Title shown above the search input (optional). */
|
|
@@ -515,11 +452,11 @@ type DocSearchProps = AiWorkerProps & {
|
|
|
515
452
|
/** Available tags for user selection */
|
|
516
453
|
availableTags?: string[];
|
|
517
454
|
};
|
|
518
|
-
type DocSearchArgs = DocSearchProps & {
|
|
455
|
+
export type DocSearchArgs = DocSearchProps & {
|
|
519
456
|
target?: string | HTMLElement;
|
|
520
457
|
};
|
|
521
|
-
type AnyCreateCoreOptions = LanguageModelCreateCoreOptions | SummarizerCreateCoreOptions | WriterCreateCoreOptions | RewriterCreateCoreOptions | ProofreaderCreateCoreOptions | LanguageDetectorCreateCoreOptions | TranslatorCreateCoreOptions;
|
|
522
|
-
interface Capabilities {
|
|
458
|
+
export type AnyCreateCoreOptions = LanguageModelCreateCoreOptions | SummarizerCreateCoreOptions | WriterCreateCoreOptions | RewriterCreateCoreOptions | ProofreaderCreateCoreOptions | LanguageDetectorCreateCoreOptions | TranslatorCreateCoreOptions;
|
|
459
|
+
export interface Capabilities {
|
|
523
460
|
MIN_CHROME_VERSION?: Partial<Record<BuiltInAiFeature, number>>;
|
|
524
461
|
isOnDeviceLanguageSupported: (outputLanguage: AiKitLanguageCode) => boolean;
|
|
525
462
|
checkOnDeviceAvailability: (feature: BuiltInAiFeature, availabilityOptions?: AnyCreateCoreOptions) => Promise<DeviceAvailability>;
|
|
@@ -534,17 +471,17 @@ interface Capabilities {
|
|
|
534
471
|
willUseOnDevice: (feature: BuiltInAiFeature, availabilityOptions?: AnyCreateCoreOptions) => Promise<boolean>;
|
|
535
472
|
willUseBackend: (feature: BuiltInAiFeature, availabilityOptions?: AnyCreateCoreOptions) => Promise<boolean>;
|
|
536
473
|
}
|
|
537
|
-
interface Backend<TResponse> {
|
|
474
|
+
export interface Backend<TResponse> {
|
|
538
475
|
dispatchFeatureBackend: (decision: CapabilityDecision, context: ContextKind, feature: BuiltInAiFeature, requestBody: unknown, options: BackendCallOptions) => Promise<TResponse>;
|
|
539
476
|
dispatchCustomBackend: (decision: CapabilityDecision, context: ContextKind, customPath: string, method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", requestBody: unknown, options: BackendCallOptions) => Promise<TResponse>;
|
|
540
477
|
}
|
|
541
|
-
type FeatureOptions = BackendCallOptions & {
|
|
478
|
+
export type FeatureOptions = BackendCallOptions & {
|
|
542
479
|
context?: ContextKind;
|
|
543
480
|
modeOverride?: AiModePreference;
|
|
544
481
|
onDeviceTimeoutOverride?: number;
|
|
545
482
|
silent?: boolean;
|
|
546
483
|
};
|
|
547
|
-
interface Features {
|
|
484
|
+
export interface Features {
|
|
548
485
|
getWriteOptions: (args: Partial<WriteArgs>) => Promise<WriterCreateCoreOptions>;
|
|
549
486
|
write: (args: WriteArgs, options?: FeatureOptions) => Promise<WriteResult>;
|
|
550
487
|
getRewriteOptions: (args: Partial<RewriteArgs>) => Promise<RewriterCreateCoreOptions>;
|
|
@@ -562,52 +499,3 @@ interface Features {
|
|
|
562
499
|
sendFeedbackMessage: (args: FeedbackMessageArgs, options?: FeatureOptions) => Promise<PromptResult>;
|
|
563
500
|
sendSearchMessage: (args: SearchMessageArgs, options?: FeatureOptions) => Promise<SearchResult>;
|
|
564
501
|
}
|
|
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: {
|
|
580
|
-
label: string;
|
|
581
|
-
value: AiKitLanguageCode;
|
|
582
|
-
}[];
|
|
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<{
|
|
588
|
-
available: boolean;
|
|
589
|
-
transport?: BackendTransport;
|
|
590
|
-
apiName?: string;
|
|
591
|
-
baseUrl?: string;
|
|
592
|
-
reason?: string;
|
|
593
|
-
}>;
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smart-cloud/ai-kit-core",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.8",
|
|
4
4
|
"description": "AI Kit Core Package",
|
|
5
5
|
"author": "Smart Cloud Solutions Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,10 +19,12 @@
|
|
|
19
19
|
"dist"
|
|
20
20
|
],
|
|
21
21
|
"scripts": {
|
|
22
|
-
"build": "
|
|
22
|
+
"build": "yarn build:js && yarn build:types",
|
|
23
|
+
"build:js": "tsup --minify",
|
|
24
|
+
"build:types": "tsc -p tsconfig.types.json",
|
|
23
25
|
"lint": "eslint 'src/**/*.ts' --report-unused-disable-directives --max-warnings 0",
|
|
24
26
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
25
|
-
"publish": "WPSUITE_PREMIUM=true
|
|
27
|
+
"publish": "WPSUITE_PREMIUM=true yarn build && npm publish --access=public"
|
|
26
28
|
},
|
|
27
29
|
"publishConfig": {
|
|
28
30
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -30,27 +32,27 @@
|
|
|
30
32
|
},
|
|
31
33
|
"dependencies": {
|
|
32
34
|
"@smart-cloud/gatey-core": "^2.2.2",
|
|
33
|
-
"@smart-cloud/wpsuite-core": "^2.2.
|
|
34
|
-
"aws-amplify": "^6.16.
|
|
35
|
+
"@smart-cloud/wpsuite-core": "^2.2.11",
|
|
36
|
+
"aws-amplify": "^6.16.4"
|
|
35
37
|
},
|
|
36
38
|
"peerDependencies": {
|
|
37
|
-
"@wordpress/data": "^10.
|
|
38
|
-
"@wordpress/i18n": "^6.
|
|
39
|
+
"@wordpress/data": "^10.44.0",
|
|
40
|
+
"@wordpress/i18n": "^6.17.0",
|
|
39
41
|
"react": "^18.3.1"
|
|
40
42
|
},
|
|
41
43
|
"devDependencies": {
|
|
42
44
|
"@eslint/js": "^10.0.1",
|
|
43
|
-
"@types/dom-chromium-ai": "^0.0.
|
|
44
|
-
"@types/node": "^25.
|
|
45
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
46
|
-
"@typescript-eslint/parser": "^8.
|
|
47
|
-
"@wordpress/data": "^10.
|
|
48
|
-
"@wordpress/i18n": "^6.
|
|
49
|
-
"eslint": "^10.
|
|
50
|
-
"globals": "^17.
|
|
45
|
+
"@types/dom-chromium-ai": "^0.0.16",
|
|
46
|
+
"@types/node": "^25.6.0",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^8.58.2",
|
|
48
|
+
"@typescript-eslint/parser": "^8.58.2",
|
|
49
|
+
"@wordpress/data": "^10.44.0",
|
|
50
|
+
"@wordpress/i18n": "^6.17.0",
|
|
51
|
+
"eslint": "^10.2.1",
|
|
52
|
+
"globals": "^17.5.0",
|
|
51
53
|
"react": "^18.3.1",
|
|
52
54
|
"tsup": "^8.5.1",
|
|
53
|
-
"typescript": "^
|
|
54
|
-
"typescript-eslint": "^8.
|
|
55
|
+
"typescript": "^6.0.3",
|
|
56
|
+
"typescript-eslint": "^8.58.2"
|
|
55
57
|
}
|
|
56
58
|
}
|