@automattic/jetpack-ai-client 0.16.1 → 0.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/build/ask-question/index.d.ts +3 -3
- package/build/ask-question/index.js +3 -3
- package/build/ask-question/sync.d.ts +3 -3
- package/build/ask-question/sync.js +3 -3
- package/build/audio-transcription/index.d.ts +3 -3
- package/build/audio-transcription/index.js +3 -3
- package/build/components/ai-control/ai-control.d.ts +1 -1
- package/build/components/ai-control/ai-control.js +1 -1
- package/build/components/ai-control/block-ai-control.d.ts +3 -3
- package/build/components/ai-control/block-ai-control.js +3 -3
- package/build/components/ai-control/extension-ai-control.d.ts +3 -3
- package/build/components/ai-control/extension-ai-control.js +3 -3
- package/build/components/ai-status-indicator/index.d.ts +1 -1
- package/build/components/ai-status-indicator/index.js +1 -1
- package/build/components/audio-duration-display/index.d.ts +1 -1
- package/build/components/audio-duration-display/index.js +1 -1
- package/build/components/audio-duration-display/lib/media.d.ts +2 -2
- package/build/components/audio-duration-display/lib/media.js +2 -2
- package/build/components/message/index.d.ts +4 -4
- package/build/components/message/index.js +4 -4
- package/build/data-flow/context.d.ts +2 -2
- package/build/data-flow/context.js +2 -2
- package/build/data-flow/use-ai-context.d.ts +1 -1
- package/build/data-flow/use-ai-context.js +1 -1
- package/build/data-flow/with-ai-assistant-data.d.ts +1 -1
- package/build/data-flow/with-ai-assistant-data.js +1 -1
- package/build/hooks/use-ai-suggestions/index.d.ts +3 -3
- package/build/hooks/use-ai-suggestions/index.js +11 -11
- package/build/hooks/use-audio-transcription/index.d.ts +1 -1
- package/build/hooks/use-audio-transcription/index.js +2 -2
- package/build/hooks/use-audio-validation/index.d.ts +1 -1
- package/build/hooks/use-audio-validation/index.js +1 -1
- package/build/hooks/use-image-generator/index.js +9 -9
- package/build/hooks/use-media-recording/index.d.ts +1 -1
- package/build/hooks/use-media-recording/index.js +4 -4
- package/build/hooks/use-save-to-media-library/index.d.ts +1 -1
- package/build/hooks/use-save-to-media-library/index.js +1 -1
- package/build/hooks/use-transcription-post-processing/index.d.ts +1 -1
- package/build/hooks/use-transcription-post-processing/index.js +1 -1
- package/build/jwt/index.d.ts +1 -1
- package/build/jwt/index.js +1 -1
- package/build/libs/markdown/html-to-markdown.d.ts +1 -1
- package/build/libs/markdown/html-to-markdown.js +1 -1
- package/build/libs/markdown/markdown-to-html.d.ts +4 -4
- package/build/libs/markdown/markdown-to-html.js +4 -4
- package/build/logo-generator/lib/logo-storage.d.ts +17 -17
- package/build/logo-generator/lib/logo-storage.js +17 -17
- package/build/logo-generator/lib/media-exists.d.ts +2 -2
- package/build/logo-generator/lib/media-exists.js +2 -2
- package/build/logo-generator/lib/set-site-logo.d.ts +3 -3
- package/build/logo-generator/lib/set-site-logo.js +3 -3
- package/build/logo-generator/lib/wpcom-limited-request.d.ts +1 -1
- package/build/logo-generator/lib/wpcom-limited-request.js +1 -1
- package/build/logo-generator/store/actions.d.ts +3 -3
- package/build/logo-generator/store/actions.js +3 -3
- package/build/logo-generator/store/reducer.d.ts +22 -22
- package/build/logo-generator/store/reducer.js +22 -22
- package/build/logo-generator/store/selectors.d.ts +20 -20
- package/build/logo-generator/store/selectors.js +20 -20
- package/build/suggestions-event-source/index.d.ts +1 -1
- package/build/suggestions-event-source/index.js +1 -1
- package/package.json +22 -21
- package/src/ask-question/index.ts +3 -3
- package/src/ask-question/sync.ts +3 -3
- package/src/audio-transcription/index.ts +3 -3
- package/src/components/ai-control/ai-control.tsx +1 -1
- package/src/components/ai-control/block-ai-control.tsx +3 -3
- package/src/components/ai-control/extension-ai-control.tsx +3 -3
- package/src/components/ai-status-indicator/index.tsx +1 -1
- package/src/components/audio-duration-display/index.tsx +1 -1
- package/src/components/audio-duration-display/lib/media.ts +2 -2
- package/src/components/message/index.tsx +4 -4
- package/src/data-flow/context.tsx +2 -2
- package/src/data-flow/use-ai-context.ts +1 -1
- package/src/data-flow/with-ai-assistant-data.tsx +1 -1
- package/src/hooks/use-ai-suggestions/index.ts +11 -11
- package/src/hooks/use-audio-transcription/index.ts +2 -2
- package/src/hooks/use-audio-validation/index.ts +1 -1
- package/src/hooks/use-image-generator/index.ts +9 -9
- package/src/hooks/use-media-recording/index.ts +4 -4
- package/src/hooks/use-save-to-media-library/index.ts +1 -1
- package/src/hooks/use-transcription-post-processing/index.ts +1 -1
- package/src/jwt/index.ts +1 -1
- package/src/libs/markdown/html-to-markdown.ts +1 -1
- package/src/libs/markdown/markdown-to-html.ts +4 -4
- package/src/logo-generator/lib/logo-storage.ts +17 -17
- package/src/logo-generator/lib/media-exists.ts +2 -2
- package/src/logo-generator/lib/set-site-logo.ts +3 -3
- package/src/logo-generator/lib/wpcom-limited-request.ts +1 -1
- package/src/logo-generator/store/actions.ts +3 -3
- package/src/logo-generator/store/reducer.ts +22 -22
- package/src/logo-generator/store/selectors.ts +20 -20
- package/src/suggestions-event-source/index.ts +1 -1
|
@@ -4,115 +4,115 @@ declare const selectors: {
|
|
|
4
4
|
/**
|
|
5
5
|
* Return the AI Assistant feature.
|
|
6
6
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
7
|
-
* @
|
|
7
|
+
* @return {Partial<AiFeatureProps>} The AI Assistant feature data.
|
|
8
8
|
*/
|
|
9
9
|
getAiAssistantFeature(state: LogoGeneratorStateProp): Partial<AiFeatureProps>;
|
|
10
10
|
/**
|
|
11
11
|
* Return the site details.
|
|
12
|
-
* @param {LogoGeneratorStateProp} state
|
|
13
|
-
* @
|
|
12
|
+
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
13
|
+
* @return {Partial<SiteDetails> | undefined} The site details.
|
|
14
14
|
*/
|
|
15
15
|
getSiteDetails(state: LogoGeneratorStateProp): Partial<SiteDetails> | undefined;
|
|
16
16
|
/**
|
|
17
17
|
* Get the isRequesting flag for the AI Assistant feature.
|
|
18
18
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
19
|
-
* @
|
|
19
|
+
* @return {boolean} The isRequesting flag.
|
|
20
20
|
*/
|
|
21
21
|
getIsRequestingAiAssistantFeature(state: LogoGeneratorStateProp): boolean;
|
|
22
22
|
/**
|
|
23
23
|
* Get the logos history.
|
|
24
24
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
25
|
-
* @
|
|
25
|
+
* @return {Array<Logo>} The logos history array.
|
|
26
26
|
*/
|
|
27
27
|
getLogos(state: LogoGeneratorStateProp): Array<Logo>;
|
|
28
28
|
/**
|
|
29
29
|
* Get the selected logo index.
|
|
30
30
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
31
|
-
* @
|
|
31
|
+
* @return {number | null} The selected logo index.
|
|
32
32
|
*/
|
|
33
33
|
getSelectedLogoIndex(state: LogoGeneratorStateProp): number | null;
|
|
34
34
|
/**
|
|
35
35
|
* Get the selected logo.
|
|
36
36
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
37
|
-
* @
|
|
37
|
+
* @return {Logo} The selected logo.
|
|
38
38
|
*/
|
|
39
39
|
getSelectedLogo(state: LogoGeneratorStateProp): Logo;
|
|
40
40
|
/**
|
|
41
41
|
* Get the isSavingToLibrary flag.
|
|
42
42
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
43
|
-
* @
|
|
43
|
+
* @return {boolean} The isSavingToLibrary flag.
|
|
44
44
|
*/
|
|
45
45
|
getIsSavingLogoToLibrary(state: LogoGeneratorStateProp): boolean;
|
|
46
46
|
/**
|
|
47
47
|
* Get the isApplyingLogo flag.
|
|
48
48
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
49
|
-
* @
|
|
49
|
+
* @return {boolean} The isApplyingLogo flag.
|
|
50
50
|
*/
|
|
51
51
|
getIsApplyingLogo(state: LogoGeneratorStateProp): boolean;
|
|
52
52
|
/**
|
|
53
53
|
* Get the isEnhancingPrompt flag.
|
|
54
54
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
55
|
-
* @
|
|
55
|
+
* @return {boolean} The isEnhancingPrompt flag.
|
|
56
56
|
*/
|
|
57
57
|
getIsEnhancingPrompt(state: LogoGeneratorStateProp): boolean;
|
|
58
58
|
/**
|
|
59
59
|
* Get the isRequestingImage flag.
|
|
60
60
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
61
|
-
* @
|
|
61
|
+
* @return {boolean} The isRequestingImage flag.
|
|
62
62
|
*/
|
|
63
63
|
getIsRequestingImage(state: LogoGeneratorStateProp): boolean;
|
|
64
64
|
/**
|
|
65
65
|
* Get an aggregated isBusy flag, based on the loading states of the app.
|
|
66
66
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
67
|
-
* @
|
|
67
|
+
* @return {boolean} The isBusy flag.
|
|
68
68
|
*/
|
|
69
69
|
getIsBusy(state: LogoGeneratorStateProp): boolean;
|
|
70
70
|
/**
|
|
71
71
|
* Get the requireUpgrade value from aiAssistantFeature
|
|
72
72
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
73
|
-
* @
|
|
73
|
+
* @return {boolean} The requireUpgrade flag.
|
|
74
74
|
*/
|
|
75
75
|
getRequireUpgrade(state: LogoGeneratorStateProp): boolean;
|
|
76
76
|
/**
|
|
77
77
|
* Get the featureFetchError value.
|
|
78
78
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
79
|
-
* @
|
|
79
|
+
* @return {RequestError} The featureFetchError value.
|
|
80
80
|
*/
|
|
81
81
|
getFeatureFetchError(state: LogoGeneratorStateProp): RequestError;
|
|
82
82
|
/**
|
|
83
83
|
* Get the firstLogoPromptFetchError value.
|
|
84
84
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
85
|
-
* @
|
|
85
|
+
* @return {RequestError} The firstLogoPromptFetchError value.
|
|
86
86
|
*/
|
|
87
87
|
getFirstLogoPromptFetchError(state: LogoGeneratorStateProp): RequestError;
|
|
88
88
|
/**
|
|
89
89
|
* Get the enhancePromptFetchError value.
|
|
90
90
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
91
|
-
* @
|
|
91
|
+
* @return {RequestError} The enhancePromptFetchError value.
|
|
92
92
|
*/
|
|
93
93
|
getEnhancePromptFetchError(state: LogoGeneratorStateProp): RequestError;
|
|
94
94
|
/**
|
|
95
95
|
* Get the logoFetchError value.
|
|
96
96
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
97
|
-
* @
|
|
97
|
+
* @return {RequestError} The logoFetchError value.
|
|
98
98
|
*/
|
|
99
99
|
getLogoFetchError(state: LogoGeneratorStateProp): RequestError;
|
|
100
100
|
/**
|
|
101
101
|
* Get the saveToLibraryError value.
|
|
102
102
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
103
|
-
* @
|
|
103
|
+
* @return {RequestError} The saveToLibraryError value.
|
|
104
104
|
*/
|
|
105
105
|
getSaveToLibraryError(state: LogoGeneratorStateProp): RequestError;
|
|
106
106
|
/**
|
|
107
107
|
* Get the logoUpdateError value.
|
|
108
108
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
109
|
-
* @
|
|
109
|
+
* @return {RequestError} The logoUpdateError value.
|
|
110
110
|
*/
|
|
111
111
|
getLogoUpdateError(state: LogoGeneratorStateProp): RequestError;
|
|
112
112
|
/**
|
|
113
113
|
* Get the context value.
|
|
114
114
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
115
|
-
* @
|
|
115
|
+
* @return {string} The context value.
|
|
116
116
|
*/
|
|
117
117
|
getContext(state: LogoGeneratorStateProp): string;
|
|
118
118
|
};
|
|
@@ -6,7 +6,7 @@ const selectors = {
|
|
|
6
6
|
/**
|
|
7
7
|
* Return the AI Assistant feature.
|
|
8
8
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
9
|
-
* @
|
|
9
|
+
* @return {Partial<AiFeatureProps>} The AI Assistant feature data.
|
|
10
10
|
*/
|
|
11
11
|
getAiAssistantFeature(state) {
|
|
12
12
|
// Clean up the _meta property.
|
|
@@ -16,8 +16,8 @@ const selectors = {
|
|
|
16
16
|
},
|
|
17
17
|
/**
|
|
18
18
|
* Return the site details.
|
|
19
|
-
* @param {LogoGeneratorStateProp} state
|
|
20
|
-
* @
|
|
19
|
+
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
20
|
+
* @return {Partial<SiteDetails> | undefined} The site details.
|
|
21
21
|
*/
|
|
22
22
|
getSiteDetails(state) {
|
|
23
23
|
return state.siteDetails;
|
|
@@ -25,7 +25,7 @@ const selectors = {
|
|
|
25
25
|
/**
|
|
26
26
|
* Get the isRequesting flag for the AI Assistant feature.
|
|
27
27
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
28
|
-
* @
|
|
28
|
+
* @return {boolean} The isRequesting flag.
|
|
29
29
|
*/
|
|
30
30
|
getIsRequestingAiAssistantFeature(state) {
|
|
31
31
|
return state.features.aiAssistantFeature?._meta?.isRequesting ?? false;
|
|
@@ -33,7 +33,7 @@ const selectors = {
|
|
|
33
33
|
/**
|
|
34
34
|
* Get the logos history.
|
|
35
35
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
36
|
-
* @
|
|
36
|
+
* @return {Array<Logo>} The logos history array.
|
|
37
37
|
*/
|
|
38
38
|
getLogos(state) {
|
|
39
39
|
return state.history ?? [];
|
|
@@ -41,7 +41,7 @@ const selectors = {
|
|
|
41
41
|
/**
|
|
42
42
|
* Get the selected logo index.
|
|
43
43
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
44
|
-
* @
|
|
44
|
+
* @return {number | null} The selected logo index.
|
|
45
45
|
*/
|
|
46
46
|
getSelectedLogoIndex(state) {
|
|
47
47
|
return state.selectedLogoIndex ?? null;
|
|
@@ -49,7 +49,7 @@ const selectors = {
|
|
|
49
49
|
/**
|
|
50
50
|
* Get the selected logo.
|
|
51
51
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
52
|
-
* @
|
|
52
|
+
* @return {Logo} The selected logo.
|
|
53
53
|
*/
|
|
54
54
|
getSelectedLogo(state) {
|
|
55
55
|
return state.history?.[state.selectedLogoIndex] ?? null;
|
|
@@ -57,7 +57,7 @@ const selectors = {
|
|
|
57
57
|
/**
|
|
58
58
|
* Get the isSavingToLibrary flag.
|
|
59
59
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
60
|
-
* @
|
|
60
|
+
* @return {boolean} The isSavingToLibrary flag.
|
|
61
61
|
*/
|
|
62
62
|
getIsSavingLogoToLibrary(state) {
|
|
63
63
|
return state._meta?.isSavingLogoToLibrary ?? false;
|
|
@@ -65,7 +65,7 @@ const selectors = {
|
|
|
65
65
|
/**
|
|
66
66
|
* Get the isApplyingLogo flag.
|
|
67
67
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
68
|
-
* @
|
|
68
|
+
* @return {boolean} The isApplyingLogo flag.
|
|
69
69
|
*/
|
|
70
70
|
getIsApplyingLogo(state) {
|
|
71
71
|
return state._meta?.isApplyingLogo ?? false;
|
|
@@ -73,7 +73,7 @@ const selectors = {
|
|
|
73
73
|
/**
|
|
74
74
|
* Get the isEnhancingPrompt flag.
|
|
75
75
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
76
|
-
* @
|
|
76
|
+
* @return {boolean} The isEnhancingPrompt flag.
|
|
77
77
|
*/
|
|
78
78
|
getIsEnhancingPrompt(state) {
|
|
79
79
|
return state._meta?.isEnhancingPrompt ?? false;
|
|
@@ -81,7 +81,7 @@ const selectors = {
|
|
|
81
81
|
/**
|
|
82
82
|
* Get the isRequestingImage flag.
|
|
83
83
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
84
|
-
* @
|
|
84
|
+
* @return {boolean} The isRequestingImage flag.
|
|
85
85
|
*/
|
|
86
86
|
getIsRequestingImage(state) {
|
|
87
87
|
return state._meta?.isRequestingImage ?? false;
|
|
@@ -89,7 +89,7 @@ const selectors = {
|
|
|
89
89
|
/**
|
|
90
90
|
* Get an aggregated isBusy flag, based on the loading states of the app.
|
|
91
91
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
92
|
-
* @
|
|
92
|
+
* @return {boolean} The isBusy flag.
|
|
93
93
|
*/
|
|
94
94
|
getIsBusy(state) {
|
|
95
95
|
return (selectors.getIsApplyingLogo(state) ||
|
|
@@ -100,7 +100,7 @@ const selectors = {
|
|
|
100
100
|
/**
|
|
101
101
|
* Get the requireUpgrade value from aiAssistantFeature
|
|
102
102
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
103
|
-
* @
|
|
103
|
+
* @return {boolean} The requireUpgrade flag.
|
|
104
104
|
*/
|
|
105
105
|
getRequireUpgrade(state) {
|
|
106
106
|
const feature = state.features.aiAssistantFeature;
|
|
@@ -116,7 +116,7 @@ const selectors = {
|
|
|
116
116
|
/**
|
|
117
117
|
* Get the featureFetchError value.
|
|
118
118
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
119
|
-
* @
|
|
119
|
+
* @return {RequestError} The featureFetchError value.
|
|
120
120
|
*/
|
|
121
121
|
getFeatureFetchError(state) {
|
|
122
122
|
return state._meta?.featureFetchError ?? null;
|
|
@@ -124,7 +124,7 @@ const selectors = {
|
|
|
124
124
|
/**
|
|
125
125
|
* Get the firstLogoPromptFetchError value.
|
|
126
126
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
127
|
-
* @
|
|
127
|
+
* @return {RequestError} The firstLogoPromptFetchError value.
|
|
128
128
|
*/
|
|
129
129
|
getFirstLogoPromptFetchError(state) {
|
|
130
130
|
return state._meta?.firstLogoPromptFetchError ?? null;
|
|
@@ -132,7 +132,7 @@ const selectors = {
|
|
|
132
132
|
/**
|
|
133
133
|
* Get the enhancePromptFetchError value.
|
|
134
134
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
135
|
-
* @
|
|
135
|
+
* @return {RequestError} The enhancePromptFetchError value.
|
|
136
136
|
*/
|
|
137
137
|
getEnhancePromptFetchError(state) {
|
|
138
138
|
return state._meta?.enhancePromptFetchError ?? null;
|
|
@@ -140,7 +140,7 @@ const selectors = {
|
|
|
140
140
|
/**
|
|
141
141
|
* Get the logoFetchError value.
|
|
142
142
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
143
|
-
* @
|
|
143
|
+
* @return {RequestError} The logoFetchError value.
|
|
144
144
|
*/
|
|
145
145
|
getLogoFetchError(state) {
|
|
146
146
|
return state._meta?.logoFetchError ?? null;
|
|
@@ -148,7 +148,7 @@ const selectors = {
|
|
|
148
148
|
/**
|
|
149
149
|
* Get the saveToLibraryError value.
|
|
150
150
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
151
|
-
* @
|
|
151
|
+
* @return {RequestError} The saveToLibraryError value.
|
|
152
152
|
*/
|
|
153
153
|
getSaveToLibraryError(state) {
|
|
154
154
|
return state._meta?.saveToLibraryError ?? null;
|
|
@@ -156,7 +156,7 @@ const selectors = {
|
|
|
156
156
|
/**
|
|
157
157
|
* Get the logoUpdateError value.
|
|
158
158
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
159
|
-
* @
|
|
159
|
+
* @return {RequestError} The logoUpdateError value.
|
|
160
160
|
*/
|
|
161
161
|
getLogoUpdateError(state) {
|
|
162
162
|
return state._meta?.logoUpdateError ?? null;
|
|
@@ -164,7 +164,7 @@ const selectors = {
|
|
|
164
164
|
/**
|
|
165
165
|
* Get the context value.
|
|
166
166
|
* @param {LogoGeneratorStateProp} state - The app state tree.
|
|
167
|
-
* @
|
|
167
|
+
* @return {string} The context value.
|
|
168
168
|
*/
|
|
169
169
|
getContext(state) {
|
|
170
170
|
return state._meta?.context ?? '';
|
|
@@ -25,7 +25,7 @@ type FunctionCallProps = {
|
|
|
25
25
|
* when the stream is closed.
|
|
26
26
|
* It also emits a 'suggestion' event with the full suggestion received so far
|
|
27
27
|
*
|
|
28
|
-
* @
|
|
28
|
+
* @return {EventSource} The event source
|
|
29
29
|
* @fires SuggestionsEventSource#suggestion - The full suggestion has been received so far
|
|
30
30
|
* @fires SuggestionsEventSource#message - A message has been received
|
|
31
31
|
* @fires SuggestionsEventSource#chunk - A chunk of data has been received
|
|
@@ -19,7 +19,7 @@ const debug = debugFactory('jetpack-ai-client:suggestions-event-source');
|
|
|
19
19
|
* when the stream is closed.
|
|
20
20
|
* It also emits a 'suggestion' event with the full suggestion received so far
|
|
21
21
|
*
|
|
22
|
-
* @
|
|
22
|
+
* @return {EventSource} The event source
|
|
23
23
|
* @fires SuggestionsEventSource#suggestion - The full suggestion has been received so far
|
|
24
24
|
* @fires SuggestionsEventSource#message - A message has been received
|
|
25
25
|
* @fires SuggestionsEventSource#chunk - A chunk of data has been received
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@automattic/jetpack-ai-client",
|
|
4
|
-
"version": "0.16.
|
|
4
|
+
"version": "0.16.3",
|
|
5
5
|
"description": "A JS client for consuming Jetpack AI services",
|
|
6
6
|
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/ai-client/#readme",
|
|
7
7
|
"bugs": {
|
|
@@ -23,14 +23,15 @@
|
|
|
23
23
|
},
|
|
24
24
|
"type": "module",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@storybook/addon-actions": "8.
|
|
27
|
-
"@storybook/blocks": "8.
|
|
28
|
-
"@storybook/preview-api": "8.
|
|
29
|
-
"@storybook/react": "8.
|
|
30
|
-
"@types/markdown-it": "14.
|
|
31
|
-
"@types/turndown": "5.0.
|
|
26
|
+
"@storybook/addon-actions": "8.2.9",
|
|
27
|
+
"@storybook/blocks": "8.2.9",
|
|
28
|
+
"@storybook/preview-api": "8.2.9",
|
|
29
|
+
"@storybook/react": "8.2.9",
|
|
30
|
+
"@types/markdown-it": "14.1.2",
|
|
31
|
+
"@types/turndown": "5.0.5",
|
|
32
32
|
"jest": "^29.6.2",
|
|
33
33
|
"jest-environment-jsdom": "29.7.0",
|
|
34
|
+
"storybook": "8.2.9",
|
|
34
35
|
"typescript": "5.0.4"
|
|
35
36
|
},
|
|
36
37
|
"exports": {
|
|
@@ -42,21 +43,21 @@
|
|
|
42
43
|
"main": "./build/index.js",
|
|
43
44
|
"types": "./build/index.d.ts",
|
|
44
45
|
"dependencies": {
|
|
45
|
-
"@automattic/jetpack-base-styles": "^0.6.
|
|
46
|
-
"@automattic/jetpack-connection": "^0.
|
|
47
|
-
"@automattic/jetpack-shared-extension-utils": "^0.15.
|
|
46
|
+
"@automattic/jetpack-base-styles": "^0.6.29",
|
|
47
|
+
"@automattic/jetpack-connection": "^0.35.3",
|
|
48
|
+
"@automattic/jetpack-shared-extension-utils": "^0.15.4",
|
|
48
49
|
"@microsoft/fetch-event-source": "2.0.1",
|
|
49
|
-
"@types/react": "18.3.
|
|
50
|
-
"@types/wordpress__block-editor": "11.5.
|
|
51
|
-
"@wordpress/api-fetch": "7.
|
|
52
|
-
"@wordpress/blob": "4.
|
|
53
|
-
"@wordpress/block-editor": "
|
|
54
|
-
"@wordpress/components": "28.
|
|
55
|
-
"@wordpress/compose": "7.
|
|
56
|
-
"@wordpress/data": "10.
|
|
57
|
-
"@wordpress/element": "6.
|
|
58
|
-
"@wordpress/i18n": "5.
|
|
59
|
-
"@wordpress/icons": "10.
|
|
50
|
+
"@types/react": "18.3.3",
|
|
51
|
+
"@types/wordpress__block-editor": "11.5.15",
|
|
52
|
+
"@wordpress/api-fetch": "7.5.0",
|
|
53
|
+
"@wordpress/blob": "4.5.0",
|
|
54
|
+
"@wordpress/block-editor": "14.0.0",
|
|
55
|
+
"@wordpress/components": "28.5.0",
|
|
56
|
+
"@wordpress/compose": "7.5.0",
|
|
57
|
+
"@wordpress/data": "10.5.0",
|
|
58
|
+
"@wordpress/element": "6.5.0",
|
|
59
|
+
"@wordpress/i18n": "5.5.0",
|
|
60
|
+
"@wordpress/icons": "10.5.0",
|
|
60
61
|
"clsx": "2.1.1",
|
|
61
62
|
"debug": "4.3.4",
|
|
62
63
|
"markdown-it": "14.0.0",
|
|
@@ -46,9 +46,9 @@ const debug = debugFactory( 'jetpack-ai-client:ask-question' );
|
|
|
46
46
|
* An asynchronous function that asks a question
|
|
47
47
|
* and returns an event source with suggestions.
|
|
48
48
|
*
|
|
49
|
-
* @param {PromptProp}
|
|
50
|
-
* @param {AskQuestionOptionsArgProps} options
|
|
51
|
-
* @
|
|
49
|
+
* @param {PromptProp} question - The question to ask. It can be a simple string or an array of PromptMessageItemProps objects.
|
|
50
|
+
* @param {AskQuestionOptionsArgProps} options - An optional object for additional configuration:
|
|
51
|
+
* @return {Promise<SuggestionsEventSource>} A promise that resolves to an instance of the SuggestionsEventSource
|
|
52
52
|
* @example
|
|
53
53
|
* const question = "What is the meaning of life?";
|
|
54
54
|
* const options = {
|
package/src/ask-question/sync.ts
CHANGED
|
@@ -19,9 +19,9 @@ const debug = debugFactory( 'jetpack-ai-client:ask-question-sync' );
|
|
|
19
19
|
/**
|
|
20
20
|
* A function that asks a question without streaming.
|
|
21
21
|
*
|
|
22
|
-
* @param {PromptProp}
|
|
23
|
-
* @param {AskQuestionOptionsArgProps} options
|
|
24
|
-
* @
|
|
22
|
+
* @param {PromptProp} question - The question to ask. It can be a simple string or an array of PromptMessageItemProps objects.
|
|
23
|
+
* @param {AskQuestionOptionsArgProps} options - An optional object for additional configuration: postId, feature, model.
|
|
24
|
+
* @return {Promise<ResponseData>} - A promise that resolves to an instance of the ResponseData
|
|
25
25
|
* @example
|
|
26
26
|
* const question = "What is the meaning of life?";
|
|
27
27
|
* const options = {
|
|
@@ -12,10 +12,10 @@ const debug = debugFactory( 'jetpack-ai-client:audio-transcription' );
|
|
|
12
12
|
/**
|
|
13
13
|
* A function that takes an audio blob and transcribes it.
|
|
14
14
|
*
|
|
15
|
-
* @param {Blob}
|
|
16
|
-
* @param {string}
|
|
15
|
+
* @param {Blob} audio - The audio to be transcribed, from a recording or from a file.
|
|
16
|
+
* @param {string} feature - The feature name that is calling the transcription.
|
|
17
17
|
* @param {AbortSignal} requestAbortSignal - The signal to abort the request.
|
|
18
|
-
* @
|
|
18
|
+
* @return {Promise<string>} - The promise of a string containing the transcribed audio.
|
|
19
19
|
*/
|
|
20
20
|
export default async function transcribeAudio(
|
|
21
21
|
audio: Blob,
|
|
@@ -35,7 +35,7 @@ type AIControlProps = {
|
|
|
35
35
|
* Base AIControl component. Contains the main structure of the control component and slots for banner, error, actions and message.
|
|
36
36
|
*
|
|
37
37
|
* @param {AIControlProps} props - Component props
|
|
38
|
-
* @
|
|
38
|
+
* @return {ReactElement} Rendered component
|
|
39
39
|
*/
|
|
40
40
|
export default function AIControl( {
|
|
41
41
|
className,
|
|
@@ -53,9 +53,9 @@ const debug = debugFactory( 'jetpack-ai-client:block-ai-control' );
|
|
|
53
53
|
/**
|
|
54
54
|
* BlockAIControl component. Used by the AI Assistant block, adding logic and components to the base AIControl component.
|
|
55
55
|
*
|
|
56
|
-
* @param {BlockAIControlProps}
|
|
57
|
-
* @param {React.MutableRefObject} ref
|
|
58
|
-
* @
|
|
56
|
+
* @param {BlockAIControlProps} props - Component props
|
|
57
|
+
* @param {React.MutableRefObject} ref - Ref to the component
|
|
58
|
+
* @return {ReactElement} Rendered component
|
|
59
59
|
*/
|
|
60
60
|
export function BlockAIControl(
|
|
61
61
|
{
|
|
@@ -45,9 +45,9 @@ type ExtensionAIControlProps = {
|
|
|
45
45
|
/**
|
|
46
46
|
* ExtensionAIControl component. Used by the AI Assistant inline extensions, adding logic and components to the base AIControl component.
|
|
47
47
|
*
|
|
48
|
-
* @param {ExtensionAIControlProps} props
|
|
49
|
-
* @param {React.MutableRefObject}
|
|
50
|
-
* @
|
|
48
|
+
* @param {ExtensionAIControlProps} props - Component props
|
|
49
|
+
* @param {React.MutableRefObject} ref - Ref to the component
|
|
50
|
+
* @return {ReactElement} Rendered component
|
|
51
51
|
*/
|
|
52
52
|
export function ExtensionAIControl(
|
|
53
53
|
{
|
|
@@ -21,7 +21,7 @@ export type AiStatusIndicatorProps = {
|
|
|
21
21
|
* AiStatusIndicator component.
|
|
22
22
|
*
|
|
23
23
|
* @param {AiStatusIndicatorProps} props - component props.
|
|
24
|
-
* @
|
|
24
|
+
* @return {React.ReactElement} - rendered component.
|
|
25
25
|
*/
|
|
26
26
|
export default function AiStatusIndicator( { state }: AiStatusIndicatorProps ): React.ReactElement {
|
|
27
27
|
return (
|
|
@@ -16,7 +16,7 @@ type AudioDurationDisplayProps = {
|
|
|
16
16
|
* AudioDurationDisplay component.
|
|
17
17
|
*
|
|
18
18
|
* @param {AudioDurationDisplayProps} props - Component props.
|
|
19
|
-
* @
|
|
19
|
+
* @return {React.ReactElement} Rendered component.
|
|
20
20
|
*/
|
|
21
21
|
export default function AudioDurationDisplay( {
|
|
22
22
|
duration,
|
|
@@ -19,9 +19,9 @@ type FormatTimeOptions = {
|
|
|
19
19
|
* Formats the given time in milliseconds into a string with the format HH:MM:SS.DD,
|
|
20
20
|
* adding hours and minutes only when needed.
|
|
21
21
|
*
|
|
22
|
-
* @param {number}
|
|
22
|
+
* @param {number} time - The time in milliseconds to format.
|
|
23
23
|
* @param {FormatTimeOptions} options - The arguments.
|
|
24
|
-
* @
|
|
24
|
+
* @return {string} The formatted time string.
|
|
25
25
|
* @example
|
|
26
26
|
* const formattedTime1 = formatTime( 1234567, { addDecimalPart: true } ); // Returns "20:34.56"
|
|
27
27
|
* const formattedTime2 = formatTime( 45123 ); // Returns "00.45"
|
|
@@ -67,7 +67,7 @@ const messageIconsMap = {
|
|
|
67
67
|
* React component to render a block message.
|
|
68
68
|
*
|
|
69
69
|
* @param {MessageProps} props - Component props.
|
|
70
|
-
* @
|
|
70
|
+
* @return {React.ReactElement } Banner component.
|
|
71
71
|
*/
|
|
72
72
|
export default function Message( {
|
|
73
73
|
severity = MESSAGE_SEVERITY_INFO,
|
|
@@ -99,7 +99,7 @@ export default function Message( {
|
|
|
99
99
|
/**
|
|
100
100
|
* React component to render a guideline message.
|
|
101
101
|
*
|
|
102
|
-
* @
|
|
102
|
+
* @return {React.ReactElement } - Message component.
|
|
103
103
|
*/
|
|
104
104
|
export function GuidelineMessage(): React.ReactElement {
|
|
105
105
|
return (
|
|
@@ -118,7 +118,7 @@ export function GuidelineMessage(): React.ReactElement {
|
|
|
118
118
|
* React component to render an upgrade message for free tier users
|
|
119
119
|
*
|
|
120
120
|
* @param {number} requestsRemaining - Number of requests remaining.
|
|
121
|
-
* @
|
|
121
|
+
* @return {React.ReactElement } - Message component.
|
|
122
122
|
*/
|
|
123
123
|
export function UpgradeMessage( {
|
|
124
124
|
requestsRemaining,
|
|
@@ -157,7 +157,7 @@ export function UpgradeMessage( {
|
|
|
157
157
|
* React component to render an error message
|
|
158
158
|
*
|
|
159
159
|
* @param {number} requestsRemaining - Number of requests remaining.
|
|
160
|
-
* @
|
|
160
|
+
* @return {React.ReactElement } - Message component.
|
|
161
161
|
*/
|
|
162
162
|
export function ErrorMessage( {
|
|
163
163
|
error,
|
|
@@ -58,7 +58,7 @@ type AiDataContextProviderProps = {
|
|
|
58
58
|
/**
|
|
59
59
|
* AI Data Context
|
|
60
60
|
*
|
|
61
|
-
* @
|
|
61
|
+
* @return {AiDataContextProps} Context.
|
|
62
62
|
*/
|
|
63
63
|
export const AiDataContext = createContext< AiDataContextProps | object >( {} );
|
|
64
64
|
|
|
@@ -66,7 +66,7 @@ export const AiDataContext = createContext< AiDataContextProps | object >( {} );
|
|
|
66
66
|
* AI Data Context Provider
|
|
67
67
|
*
|
|
68
68
|
* @param {AiDataContextProviderProps} props - Component props.
|
|
69
|
-
* @
|
|
69
|
+
* @return {React.ReactElement} Context provider.
|
|
70
70
|
* @example
|
|
71
71
|
* <AiDataContextProvider value={ value }>
|
|
72
72
|
* { children }
|
|
@@ -41,7 +41,7 @@ export type UseAiContextOptions = {
|
|
|
41
41
|
* and to subscribe to the request events (onDone, onSuggestion).
|
|
42
42
|
*
|
|
43
43
|
* @param {UseAiContextOptions} options - the hook options.
|
|
44
|
-
* @
|
|
44
|
+
* @return {AiDataContextProps} the AI Assistant data context.
|
|
45
45
|
*/
|
|
46
46
|
export default function useAiContext( {
|
|
47
47
|
onDone,
|
|
@@ -15,7 +15,7 @@ import { AiDataContextProvider } from './index.js';
|
|
|
15
15
|
* AI Assistant Data context to the wrapped component.
|
|
16
16
|
*
|
|
17
17
|
* @param {React.ReactElement} WrappedComponent - component to wrap.
|
|
18
|
-
* @
|
|
18
|
+
* @return {React.ReactElement} Wrapped component, with the AI Assistant Data context.
|
|
19
19
|
*/
|
|
20
20
|
const withAiDataProvider = createHigherOrderComponent(
|
|
21
21
|
( WrappedComponent: React.ComponentType ) => {
|