@automattic/jetpack-ai-client 0.28.1 → 0.31.0
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 +18 -0
- package/build/chrome-ai/factory.js +2 -10
- package/build/chrome-ai/get-availability.d.ts +7 -0
- package/build/chrome-ai/get-availability.js +25 -0
- package/build/hooks/use-ai-feature/index.d.ts +1 -0
- package/package.json +20 -20
- package/src/chrome-ai/factory.ts +2 -11
- package/src/chrome-ai/get-availability.ts +44 -0
- package/src/components/ai-control/style.scss +1 -1
- package/src/components/ai-feedback/style.scss +0 -2
- package/src/components/ai-image/components/carrousel.scss +13 -14
- package/src/components/ai-image/components/usage-counter.scss +1 -1
- package/src/components/ai-status-indicator/style.scss +1 -1
- package/src/components/message/style.scss +1 -1
- package/src/components/quota-exceeded-message/style.scss +1 -1
- package/src/logo-generator/components/generator-modal.scss +1 -1
- package/src/logo-generator/components/history-carousel.scss +1 -1
- package/src/logo-generator/components/logo-presenter.scss +1 -1
- package/src/logo-generator/components/prompt.scss +1 -1
- package/src/logo-generator/components/upgrade-nudge.scss +1 -1
- package/src/logo-generator/components/visit-site-banner.scss +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.31.0] - 2025-06-02
|
|
9
|
+
### Changed
|
|
10
|
+
- Change how Chrome's built-in AI API tokens are injected. [#43682]
|
|
11
|
+
- sass: Remove unnecessary `@import` of `@wordpress/base-styles`. [#43607]
|
|
12
|
+
- Update package dependencies. [#43711]
|
|
13
|
+
|
|
14
|
+
## [0.30.0] - 2025-05-26
|
|
15
|
+
### Changed
|
|
16
|
+
- AI Assistant: Propagate the AI model used in the AI requests. [#43495]
|
|
17
|
+
- Update package dependencies. [#43578]
|
|
18
|
+
|
|
19
|
+
## [0.29.0] - 2025-05-19
|
|
20
|
+
### Added
|
|
21
|
+
- AI Assistant: Retrieve Chrome AI token from AI Features response and inject it from the frontend. [#43442]
|
|
22
|
+
|
|
8
23
|
## [0.28.1] - 2025-05-15
|
|
9
24
|
### Fixed
|
|
10
25
|
- AI Assistant: Shorten AI excerpt if the built-in AI model doesn't respect the word count limit. [#43433]
|
|
@@ -612,6 +627,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
612
627
|
- AI Client: stop using smart document visibility handling on the fetchEventSource library, so it does not restart the completion when changing tabs. [#32004]
|
|
613
628
|
- Updated package dependencies. [#31468] [#31659] [#31785]
|
|
614
629
|
|
|
630
|
+
[0.31.0]: https://github.com/Automattic/jetpack-ai-client/compare/v0.30.0...v0.31.0
|
|
631
|
+
[0.30.0]: https://github.com/Automattic/jetpack-ai-client/compare/v0.29.0...v0.30.0
|
|
632
|
+
[0.29.0]: https://github.com/Automattic/jetpack-ai-client/compare/v0.28.1...v0.29.0
|
|
615
633
|
[0.28.1]: https://github.com/Automattic/jetpack-ai-client/compare/v0.28.0...v0.28.1
|
|
616
634
|
[0.28.0]: https://github.com/Automattic/jetpack-ai-client/compare/v0.27.10...v0.28.0
|
|
617
635
|
[0.27.10]: https://github.com/Automattic/jetpack-ai-client/compare/v0.27.9...v0.27.10
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
import { getJetpackExtensionAvailability } from '@automattic/jetpack-shared-extension-utils';
|
|
2
1
|
import { PROMPT_TYPE_CHANGE_LANGUAGE, PROMPT_TYPE_SUMMARIZE } from "../constants.js";
|
|
2
|
+
import { isChromeAIAvailable } from "./get-availability.js";
|
|
3
3
|
import ChromeAISuggestionsEventSource from "./suggestions.js";
|
|
4
|
-
/**
|
|
5
|
-
* Check for the feature flag.
|
|
6
|
-
*
|
|
7
|
-
* @return boolean
|
|
8
|
-
*/
|
|
9
|
-
function shouldUseChromeAI() {
|
|
10
|
-
return getJetpackExtensionAvailability('ai-use-chrome-ai-sometimes').available === true;
|
|
11
|
-
}
|
|
12
4
|
/**
|
|
13
5
|
* This will return an instance of ChromeAISuggestionsEventSource or false.
|
|
14
6
|
*
|
|
@@ -16,7 +8,7 @@ function shouldUseChromeAI() {
|
|
|
16
8
|
* @return ChromeAISuggestionsEventSource | bool
|
|
17
9
|
*/
|
|
18
10
|
export default async function ChromeAIFactory(promptArg) {
|
|
19
|
-
if (!
|
|
11
|
+
if (!isChromeAIAvailable()) {
|
|
20
12
|
return false;
|
|
21
13
|
}
|
|
22
14
|
const context = {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { getJetpackExtensionAvailability } from '@automattic/jetpack-shared-extension-utils';
|
|
5
|
+
import { select } from '@wordpress/data';
|
|
6
|
+
/**
|
|
7
|
+
* Get the AI Assistant feature.
|
|
8
|
+
*
|
|
9
|
+
* @return {object} The AI Assistant feature.
|
|
10
|
+
*/
|
|
11
|
+
function getAiAssistantFeature() {
|
|
12
|
+
const { getAiAssistantFeature: getFeature } = select('wordpress-com/plans');
|
|
13
|
+
return getFeature();
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Check if Chrome AI can be enabled.
|
|
17
|
+
*
|
|
18
|
+
* @return {boolean} Whether Chrome AI can be enabled.
|
|
19
|
+
*/
|
|
20
|
+
export function isChromeAIAvailable() {
|
|
21
|
+
const { featuresControl } = getAiAssistantFeature();
|
|
22
|
+
return (featuresControl?.['chrome-ai']?.enabled !== false &&
|
|
23
|
+
getJetpackExtensionAvailability('ai-use-chrome-ai-sometimes').available !== false);
|
|
24
|
+
}
|
|
25
|
+
export default isChromeAIAvailable;
|
|
@@ -30,4 +30,5 @@ export default function useAiFeature(): {
|
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
32
|
featuresControl?: import("@automattic/jetpack-shared-extension-utils/store/wordpress-com/types").FeaturesControl;
|
|
33
|
+
chromeAiTokens?: import("@automattic/jetpack-shared-extension-utils/store/wordpress-com/types").ChromeAiTokens;
|
|
33
34
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@automattic/jetpack-ai-client",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.31.0",
|
|
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": {
|
|
@@ -45,30 +45,30 @@
|
|
|
45
45
|
"main": "./build/index.js",
|
|
46
46
|
"types": "./build/index.d.ts",
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@automattic/jetpack-base-styles": "^0.
|
|
49
|
-
"@automattic/jetpack-components": "^0.73.
|
|
50
|
-
"@automattic/jetpack-connection": "^0.39.
|
|
51
|
-
"@automattic/jetpack-shared-extension-utils": "^0.
|
|
48
|
+
"@automattic/jetpack-base-styles": "^0.8.0",
|
|
49
|
+
"@automattic/jetpack-components": "^0.73.4",
|
|
50
|
+
"@automattic/jetpack-connection": "^0.39.18",
|
|
51
|
+
"@automattic/jetpack-shared-extension-utils": "^0.20.3",
|
|
52
52
|
"@microsoft/fetch-event-source": "2.0.1",
|
|
53
53
|
"@types/jest": "29.5.14",
|
|
54
54
|
"@types/react": "18.3.18",
|
|
55
55
|
"@types/wordpress__block-editor": "11.5.16",
|
|
56
|
-
"@wordpress/api-fetch": "7.
|
|
57
|
-
"@wordpress/base-styles": "
|
|
58
|
-
"@wordpress/blob": "4.
|
|
59
|
-
"@wordpress/blocks": "14.
|
|
60
|
-
"@wordpress/block-editor": "14.
|
|
61
|
-
"@wordpress/components": "29.
|
|
62
|
-
"@wordpress/compose": "7.
|
|
63
|
-
"@wordpress/data": "10.
|
|
64
|
-
"@wordpress/editor": "14.
|
|
65
|
-
"@wordpress/element": "6.
|
|
66
|
-
"@wordpress/i18n": "5.
|
|
67
|
-
"@wordpress/icons": "10.
|
|
68
|
-
"@wordpress/primitives": "4.
|
|
69
|
-
"@wordpress/url": "4.
|
|
56
|
+
"@wordpress/api-fetch": "7.24.0",
|
|
57
|
+
"@wordpress/base-styles": "6.0.0",
|
|
58
|
+
"@wordpress/blob": "4.24.0",
|
|
59
|
+
"@wordpress/blocks": "14.13.0",
|
|
60
|
+
"@wordpress/block-editor": "14.19.0",
|
|
61
|
+
"@wordpress/components": "29.10.0",
|
|
62
|
+
"@wordpress/compose": "7.24.0",
|
|
63
|
+
"@wordpress/data": "10.24.0",
|
|
64
|
+
"@wordpress/editor": "14.24.0",
|
|
65
|
+
"@wordpress/element": "6.24.0",
|
|
66
|
+
"@wordpress/i18n": "5.24.0",
|
|
67
|
+
"@wordpress/icons": "10.24.0",
|
|
68
|
+
"@wordpress/primitives": "4.24.0",
|
|
69
|
+
"@wordpress/url": "4.24.0",
|
|
70
70
|
"clsx": "2.1.1",
|
|
71
|
-
"debug": "4.4.
|
|
71
|
+
"debug": "4.4.1",
|
|
72
72
|
"markdown-it": "14.1.0",
|
|
73
73
|
"react": "18.3.1",
|
|
74
74
|
"react-dom": "18.3.1",
|
package/src/chrome-ai/factory.ts
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
import { getJetpackExtensionAvailability } from '@automattic/jetpack-shared-extension-utils';
|
|
2
1
|
import { PROMPT_TYPE_CHANGE_LANGUAGE, PROMPT_TYPE_SUMMARIZE } from '../constants.ts';
|
|
3
2
|
import { PromptProp, PromptItemProps } from '../types.ts';
|
|
3
|
+
import { isChromeAIAvailable } from './get-availability.ts';
|
|
4
4
|
import ChromeAISuggestionsEventSource from './suggestions.ts';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Check for the feature flag.
|
|
8
|
-
*
|
|
9
|
-
* @return boolean
|
|
10
|
-
*/
|
|
11
|
-
function shouldUseChromeAI() {
|
|
12
|
-
return getJetpackExtensionAvailability( 'ai-use-chrome-ai-sometimes' ).available === true;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
6
|
interface PromptContext {
|
|
16
7
|
type?: string;
|
|
17
8
|
content?: string;
|
|
@@ -27,7 +18,7 @@ interface PromptContext {
|
|
|
27
18
|
* @return ChromeAISuggestionsEventSource | bool
|
|
28
19
|
*/
|
|
29
20
|
export default async function ChromeAIFactory( promptArg: PromptProp ) {
|
|
30
|
-
if ( !
|
|
21
|
+
if ( ! isChromeAIAvailable() ) {
|
|
31
22
|
return false;
|
|
32
23
|
}
|
|
33
24
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { getJetpackExtensionAvailability } from '@automattic/jetpack-shared-extension-utils';
|
|
5
|
+
import { select } from '@wordpress/data';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Types
|
|
9
|
+
*/
|
|
10
|
+
type FeatureControl = {
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type PlansSelect = {
|
|
15
|
+
getAiAssistantFeature: () => {
|
|
16
|
+
currentTier?: { value: number };
|
|
17
|
+
featuresControl?: Record< string, FeatureControl >;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Get the AI Assistant feature.
|
|
23
|
+
*
|
|
24
|
+
* @return {object} The AI Assistant feature.
|
|
25
|
+
*/
|
|
26
|
+
function getAiAssistantFeature() {
|
|
27
|
+
const { getAiAssistantFeature: getFeature } = select( 'wordpress-com/plans' ) as PlansSelect;
|
|
28
|
+
return getFeature();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Check if Chrome AI can be enabled.
|
|
33
|
+
*
|
|
34
|
+
* @return {boolean} Whether Chrome AI can be enabled.
|
|
35
|
+
*/
|
|
36
|
+
export function isChromeAIAvailable() {
|
|
37
|
+
const { featuresControl } = getAiAssistantFeature();
|
|
38
|
+
return (
|
|
39
|
+
featuresControl?.[ 'chrome-ai' ]?.enabled !== false &&
|
|
40
|
+
getJetpackExtensionAvailability( 'ai-use-chrome-ai-sometimes' ).available !== false
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default isChromeAIAvailable;
|
|
@@ -64,20 +64,6 @@ $scale-factor: 0.55;
|
|
|
64
64
|
|
|
65
65
|
&__prev,
|
|
66
66
|
&__next {
|
|
67
|
-
|
|
68
|
-
&:hover {
|
|
69
|
-
background-color: rgba( 0, 0, 0, 0.3 );
|
|
70
|
-
opacity: 1;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
&-icon {
|
|
74
|
-
fill: #fff;
|
|
75
|
-
|
|
76
|
-
&.is-disabled {
|
|
77
|
-
fill: #808080;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
67
|
cursor: pointer;
|
|
82
68
|
z-index: 1;
|
|
83
69
|
display: flex;
|
|
@@ -92,6 +78,19 @@ $scale-factor: 0.55;
|
|
|
92
78
|
width: 60px;
|
|
93
79
|
opacity: 0;
|
|
94
80
|
background: transparent;
|
|
81
|
+
|
|
82
|
+
&:hover {
|
|
83
|
+
background-color: rgba( 0, 0, 0, 0.3 );
|
|
84
|
+
opacity: 1;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&-icon {
|
|
88
|
+
fill: #fff;
|
|
89
|
+
|
|
90
|
+
&.is-disabled {
|
|
91
|
+
fill: #808080;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
95
94
|
}
|
|
96
95
|
}
|
|
97
96
|
}
|