@atlaskit/rovo-agent-components 4.5.1 → 4.7.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 +35 -0
- package/dist/cjs/ui/agent-dropdown-menu/index.js +12 -12
- package/dist/cjs/ui/agent-identity/derive-agent-identity.js +69 -0
- package/dist/cjs/ui/agent-verification-dropdown-item/__generated__/testAgentVerificationDropdownItemQuery.graphql.js +2 -2
- package/dist/es2019/ui/agent-identity/derive-agent-identity.js +65 -0
- package/dist/es2019/ui/agent-verification-dropdown-item/__generated__/testAgentVerificationDropdownItemQuery.graphql.js +2 -2
- package/dist/esm/ui/agent-dropdown-menu/index.js +12 -12
- package/dist/esm/ui/agent-identity/derive-agent-identity.js +64 -0
- package/dist/esm/ui/agent-verification-dropdown-item/__generated__/testAgentVerificationDropdownItemQuery.graphql.js +2 -2
- package/dist/types/ui/agent-identity/derive-agent-identity.d.ts +60 -0
- package/dist/types/ui/agent-verification-dropdown-item/__generated__/testAgentVerificationDropdownItemQuery.graphql.d.ts +1 -1
- package/dist/types-ts4.5/ui/agent-identity/derive-agent-identity.d.ts +60 -0
- package/dist/types-ts4.5/ui/agent-verification-dropdown-item/__generated__/testAgentVerificationDropdownItemQuery.graphql.d.ts +1 -1
- package/package.json +10 -9
- package/ui/agent-identity/derive-agent-identity/package.json +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @atlaskit/rovo-agent-components
|
|
2
2
|
|
|
3
|
+
## 4.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`c5948348a4e51`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c5948348a4e51) -
|
|
8
|
+
TREX-1373 (part 3/3): add @typescript-eslint/no-explicit-any OXLint suppression comments across
|
|
9
|
+
rovo-\* and misc packages. Includes OXLint override and Mithril ratchet to prevent new
|
|
10
|
+
suppressions.
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
16
|
+
## 4.6.0
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
20
|
+
- [`2f13c6822ad55`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2f13c6822ad55) -
|
|
21
|
+
[TREX-1413] Add presentational `AgentResponseHat` (above assistant messages) and `AgentInputHat`
|
|
22
|
+
(above the chat prompt input) components for per-turn agent attribution. Both render under the
|
|
23
|
+
`rovo_chat_agent_identity_ui` feature gate; data wiring (selected agent, dismiss callback) is
|
|
24
|
+
intentionally not yet connected and will land with TREX-1410/TREX-1411.
|
|
25
|
+
|
|
26
|
+
Also:
|
|
27
|
+
- Adds shared `deriveAgentIdentity` helper in `@atlaskit/rovo-agent-components` (subpath:
|
|
28
|
+
`ui/agent-identity/derive-agent-identity`) that centralises specialist-vs-default detection,
|
|
29
|
+
visible/accessible name derivation, and Forge prop gating via `rovo_agent_support_a2a_avatar`.
|
|
30
|
+
Both hats consume this helper to avoid drift.
|
|
31
|
+
- Extends `Message.author` in `@atlassian/conversation-assistant-service-api` with
|
|
32
|
+
`external_config_reference`, `identity_account_id`, `creator_type`, and `icon` so
|
|
33
|
+
`AgentResponseHat` receives the right inputs once TREX-1411 wires live data. Also marks the
|
|
34
|
+
existing `named_id` field as `@deprecated` in favour of `external_config_reference` for OOTB
|
|
35
|
+
avatar lookup.
|
|
36
|
+
- Adds storybook examples (`73-agent-response`, `74-chat-prompt-input`) for visual validation.
|
|
37
|
+
|
|
3
38
|
## 4.5.1
|
|
4
39
|
|
|
5
40
|
### Patch Changes
|
|
@@ -106,13 +106,13 @@ var AgentDropdownMenu = exports.AgentDropdownMenu = function AgentDropdownMenu(_
|
|
|
106
106
|
var fetchData = /*#__PURE__*/function () {
|
|
107
107
|
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
108
108
|
var _yield$loadAgentPermi, isCreateEnabled, isEditEnabled, isDeleteEnabled;
|
|
109
|
-
return _regenerator.default.wrap(function
|
|
109
|
+
return _regenerator.default.wrap(function (_context) {
|
|
110
110
|
while (1) switch (_context.prev = _context.next) {
|
|
111
111
|
case 0:
|
|
112
112
|
setIsLoading(true);
|
|
113
|
-
_context.next =
|
|
113
|
+
_context.next = 1;
|
|
114
114
|
return loadAgentPermissions();
|
|
115
|
-
case
|
|
115
|
+
case 1:
|
|
116
116
|
_yield$loadAgentPermi = _context.sent;
|
|
117
117
|
isCreateEnabled = _yield$loadAgentPermi.isCreateEnabled;
|
|
118
118
|
isEditEnabled = _yield$loadAgentPermi.isEditEnabled;
|
|
@@ -123,7 +123,7 @@ var AgentDropdownMenu = exports.AgentDropdownMenu = function AgentDropdownMenu(_
|
|
|
123
123
|
isEditEnabled: isEditEnabled,
|
|
124
124
|
isDeleteEnabled: isDeleteEnabled
|
|
125
125
|
});
|
|
126
|
-
case
|
|
126
|
+
case 2:
|
|
127
127
|
case "end":
|
|
128
128
|
return _context.stop();
|
|
129
129
|
}
|
|
@@ -203,25 +203,25 @@ var AgentDropdownMenu = exports.AgentDropdownMenu = function AgentDropdownMenu(_
|
|
|
203
203
|
}, formatMessage(_messages.default.viewAgentFullProfile)), !isForgeAgent && isCreateAgentsEnabled && /*#__PURE__*/_react.default.createElement(_dropdownMenu.DropdownItem, {
|
|
204
204
|
onClick: ( /*#__PURE__*/function () {
|
|
205
205
|
var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(e) {
|
|
206
|
-
return _regenerator.default.wrap(function
|
|
206
|
+
return _regenerator.default.wrap(function (_context2) {
|
|
207
207
|
while (1) switch (_context2.prev = _context2.next) {
|
|
208
208
|
case 0:
|
|
209
209
|
if ((0, _platformFeatureFlags.fg)('rovo_agent_versioning_enabled')) {
|
|
210
210
|
e.stopPropagation();
|
|
211
211
|
}
|
|
212
212
|
setIsDuplicating(true);
|
|
213
|
-
_context2.prev =
|
|
214
|
-
_context2.next =
|
|
213
|
+
_context2.prev = 1;
|
|
214
|
+
_context2.next = 2;
|
|
215
215
|
return onDuplicateAgent === null || onDuplicateAgent === void 0 ? void 0 : onDuplicateAgent(e);
|
|
216
|
-
case
|
|
217
|
-
_context2.prev =
|
|
216
|
+
case 2:
|
|
217
|
+
_context2.prev = 2;
|
|
218
218
|
setIsDuplicating(false);
|
|
219
|
-
return _context2.finish(
|
|
220
|
-
case
|
|
219
|
+
return _context2.finish(2);
|
|
220
|
+
case 3:
|
|
221
221
|
case "end":
|
|
222
222
|
return _context2.stop();
|
|
223
223
|
}
|
|
224
|
-
}, _callee2, null, [[
|
|
224
|
+
}, _callee2, null, [[1,, 2, 3]]);
|
|
225
225
|
}));
|
|
226
226
|
return function (_x) {
|
|
227
227
|
return _ref5.apply(this, arguments);
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.deriveAgentIdentity = deriveAgentIdentity;
|
|
7
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
8
|
+
var _isAgentCreatorType = require("../../common/utils/is-agent-creator-type");
|
|
9
|
+
var _isForgeAgent = require("../../common/utils/is-forge-agent");
|
|
10
|
+
/**
|
|
11
|
+
* Shared identity-derivation helper used by AgentInputHat (above the prompt
|
|
12
|
+
* input) and AgentResponseHat (above an assistant message). Both components
|
|
13
|
+
* need to translate raw agent identity props into the inputs that AgentAvatar
|
|
14
|
+
* expects, plus an accessible/visible name pair, with the same fallback
|
|
15
|
+
* semantics. Centralising the logic here avoids drift between the two hats —
|
|
16
|
+
* historically every change to one needed a paired change to the other.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** Raw identity input — typically a subset of `Agent` or `message.author`. */
|
|
20
|
+
|
|
21
|
+
/** Derived props ready to forward to AgentAvatar + the visible name slot. */
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Derive `AgentAvatar` inputs and visible/accessible labels from raw identity.
|
|
25
|
+
*
|
|
26
|
+
* Behaviour:
|
|
27
|
+
* - Specialist path (`agentId` is a non-empty string): visible text is the
|
|
28
|
+
* supplied `agentName`, omitted entirely if absent (no "Rovo" text next to
|
|
29
|
+
* a specialist avatar). Accessible label falls back to the agent id so the
|
|
30
|
+
* avatar is never announced as "Rovo".
|
|
31
|
+
* - Default Rovo path (no `agentId`): visible and accessible labels are the
|
|
32
|
+
* localized default name (typically "Rovo").
|
|
33
|
+
* - Forge identity props are gated internally via `rovo_agent_support_a2a_avatar`
|
|
34
|
+
* so callers don't have to.
|
|
35
|
+
*/
|
|
36
|
+
function deriveAgentIdentity(_ref) {
|
|
37
|
+
var agentId = _ref.agentId,
|
|
38
|
+
agentName = _ref.agentName,
|
|
39
|
+
agentNamedId = _ref.agentNamedId,
|
|
40
|
+
agentIdentityAccountId = _ref.agentIdentityAccountId,
|
|
41
|
+
imageUrl = _ref.imageUrl,
|
|
42
|
+
creatorType = _ref.creatorType,
|
|
43
|
+
isForgeAgentOverride = _ref.isForgeAgent,
|
|
44
|
+
forgeAgentIconUrl = _ref.forgeAgentIconUrl,
|
|
45
|
+
defaultName = _ref.defaultName;
|
|
46
|
+
var trimmedAgentId = typeof agentId === 'string' ? agentId.trim() : undefined;
|
|
47
|
+
var specialistAgentId = trimmedAgentId && trimmedAgentId.length > 0 ? trimmedAgentId : undefined;
|
|
48
|
+
var trimmedAgentName = agentName === null || agentName === void 0 ? void 0 : agentName.trim();
|
|
49
|
+
var visibleName = specialistAgentId ? trimmedAgentName || undefined : defaultName;
|
|
50
|
+
var accessibleName = specialistAgentId ? trimmedAgentName || specialistAgentId : defaultName;
|
|
51
|
+
var a2aGateOn = (0, _platformFeatureFlags.fg)('rovo_agent_support_a2a_avatar');
|
|
52
|
+
|
|
53
|
+
// Prefer the explicit override; otherwise validate creatorType via the
|
|
54
|
+
// type guard so the call site doesn't need an unsafe cast.
|
|
55
|
+
var isForgeAgent = isForgeAgentOverride !== undefined ? isForgeAgentOverride : creatorType && (0, _isAgentCreatorType.isAgentCreatorType)(creatorType) ? (0, _isForgeAgent.isForgeAgentByCreatorType)(creatorType) : undefined;
|
|
56
|
+
return {
|
|
57
|
+
specialistAgentId: specialistAgentId,
|
|
58
|
+
visibleName: visibleName,
|
|
59
|
+
accessibleName: accessibleName,
|
|
60
|
+
avatarProps: {
|
|
61
|
+
agentId: specialistAgentId,
|
|
62
|
+
agentNamedId: agentNamedId,
|
|
63
|
+
agentIdentityAccountId: agentIdentityAccountId,
|
|
64
|
+
imageUrl: imageUrl,
|
|
65
|
+
isForgeAgent: a2aGateOn ? isForgeAgent : undefined,
|
|
66
|
+
forgeAgentIconUrl: a2aGateOn ? forgeAgentIconUrl : undefined
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
/**
|
|
8
|
-
* @generated SignedSource<<
|
|
8
|
+
* @generated SignedSource<<6976169d85be7545c35821ac2ecd2c10>>
|
|
9
9
|
* @relayHash c95a4b89f332b56ac41d44591442026c
|
|
10
10
|
* @lightSyntaxTransform
|
|
11
11
|
* @nogrep
|
|
@@ -183,5 +183,5 @@ var node = function () {
|
|
|
183
183
|
}
|
|
184
184
|
};
|
|
185
185
|
}();
|
|
186
|
-
node.hash = "
|
|
186
|
+
node.hash = "5f2bdb1cf9fe006560907bc0bd0c1fed";
|
|
187
187
|
var _default = exports.default = node;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared identity-derivation helper used by AgentInputHat (above the prompt
|
|
3
|
+
* input) and AgentResponseHat (above an assistant message). Both components
|
|
4
|
+
* need to translate raw agent identity props into the inputs that AgentAvatar
|
|
5
|
+
* expects, plus an accessible/visible name pair, with the same fallback
|
|
6
|
+
* semantics. Centralising the logic here avoids drift between the two hats —
|
|
7
|
+
* historically every change to one needed a paired change to the other.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
|
+
import { isAgentCreatorType } from '../../common/utils/is-agent-creator-type';
|
|
12
|
+
import { isForgeAgentByCreatorType } from '../../common/utils/is-forge-agent';
|
|
13
|
+
|
|
14
|
+
/** Raw identity input — typically a subset of `Agent` or `message.author`. */
|
|
15
|
+
|
|
16
|
+
/** Derived props ready to forward to AgentAvatar + the visible name slot. */
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Derive `AgentAvatar` inputs and visible/accessible labels from raw identity.
|
|
20
|
+
*
|
|
21
|
+
* Behaviour:
|
|
22
|
+
* - Specialist path (`agentId` is a non-empty string): visible text is the
|
|
23
|
+
* supplied `agentName`, omitted entirely if absent (no "Rovo" text next to
|
|
24
|
+
* a specialist avatar). Accessible label falls back to the agent id so the
|
|
25
|
+
* avatar is never announced as "Rovo".
|
|
26
|
+
* - Default Rovo path (no `agentId`): visible and accessible labels are the
|
|
27
|
+
* localized default name (typically "Rovo").
|
|
28
|
+
* - Forge identity props are gated internally via `rovo_agent_support_a2a_avatar`
|
|
29
|
+
* so callers don't have to.
|
|
30
|
+
*/
|
|
31
|
+
export function deriveAgentIdentity({
|
|
32
|
+
agentId,
|
|
33
|
+
agentName,
|
|
34
|
+
agentNamedId,
|
|
35
|
+
agentIdentityAccountId,
|
|
36
|
+
imageUrl,
|
|
37
|
+
creatorType,
|
|
38
|
+
isForgeAgent: isForgeAgentOverride,
|
|
39
|
+
forgeAgentIconUrl,
|
|
40
|
+
defaultName
|
|
41
|
+
}) {
|
|
42
|
+
const trimmedAgentId = typeof agentId === 'string' ? agentId.trim() : undefined;
|
|
43
|
+
const specialistAgentId = trimmedAgentId && trimmedAgentId.length > 0 ? trimmedAgentId : undefined;
|
|
44
|
+
const trimmedAgentName = agentName === null || agentName === void 0 ? void 0 : agentName.trim();
|
|
45
|
+
const visibleName = specialistAgentId ? trimmedAgentName || undefined : defaultName;
|
|
46
|
+
const accessibleName = specialistAgentId ? trimmedAgentName || specialistAgentId : defaultName;
|
|
47
|
+
const a2aGateOn = fg('rovo_agent_support_a2a_avatar');
|
|
48
|
+
|
|
49
|
+
// Prefer the explicit override; otherwise validate creatorType via the
|
|
50
|
+
// type guard so the call site doesn't need an unsafe cast.
|
|
51
|
+
const isForgeAgent = isForgeAgentOverride !== undefined ? isForgeAgentOverride : creatorType && isAgentCreatorType(creatorType) ? isForgeAgentByCreatorType(creatorType) : undefined;
|
|
52
|
+
return {
|
|
53
|
+
specialistAgentId,
|
|
54
|
+
visibleName,
|
|
55
|
+
accessibleName,
|
|
56
|
+
avatarProps: {
|
|
57
|
+
agentId: specialistAgentId,
|
|
58
|
+
agentNamedId,
|
|
59
|
+
agentIdentityAccountId,
|
|
60
|
+
imageUrl,
|
|
61
|
+
isForgeAgent: a2aGateOn ? isForgeAgent : undefined,
|
|
62
|
+
forgeAgentIconUrl: a2aGateOn ? forgeAgentIconUrl : undefined
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @generated SignedSource<<
|
|
2
|
+
* @generated SignedSource<<6976169d85be7545c35821ac2ecd2c10>>
|
|
3
3
|
* @relayHash c95a4b89f332b56ac41d44591442026c
|
|
4
4
|
* @lightSyntaxTransform
|
|
5
5
|
* @nogrep
|
|
@@ -177,5 +177,5 @@ const node = function () {
|
|
|
177
177
|
}
|
|
178
178
|
};
|
|
179
179
|
}();
|
|
180
|
-
node.hash = "
|
|
180
|
+
node.hash = "5f2bdb1cf9fe006560907bc0bd0c1fed";
|
|
181
181
|
export default node;
|
|
@@ -97,13 +97,13 @@ export var AgentDropdownMenu = function AgentDropdownMenu(_ref2) {
|
|
|
97
97
|
var fetchData = /*#__PURE__*/function () {
|
|
98
98
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
99
99
|
var _yield$loadAgentPermi, isCreateEnabled, isEditEnabled, isDeleteEnabled;
|
|
100
|
-
return _regeneratorRuntime.wrap(function
|
|
100
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
101
101
|
while (1) switch (_context.prev = _context.next) {
|
|
102
102
|
case 0:
|
|
103
103
|
setIsLoading(true);
|
|
104
|
-
_context.next =
|
|
104
|
+
_context.next = 1;
|
|
105
105
|
return loadAgentPermissions();
|
|
106
|
-
case
|
|
106
|
+
case 1:
|
|
107
107
|
_yield$loadAgentPermi = _context.sent;
|
|
108
108
|
isCreateEnabled = _yield$loadAgentPermi.isCreateEnabled;
|
|
109
109
|
isEditEnabled = _yield$loadAgentPermi.isEditEnabled;
|
|
@@ -114,7 +114,7 @@ export var AgentDropdownMenu = function AgentDropdownMenu(_ref2) {
|
|
|
114
114
|
isEditEnabled: isEditEnabled,
|
|
115
115
|
isDeleteEnabled: isDeleteEnabled
|
|
116
116
|
});
|
|
117
|
-
case
|
|
117
|
+
case 2:
|
|
118
118
|
case "end":
|
|
119
119
|
return _context.stop();
|
|
120
120
|
}
|
|
@@ -194,25 +194,25 @@ export var AgentDropdownMenu = function AgentDropdownMenu(_ref2) {
|
|
|
194
194
|
}, formatMessage(messages.viewAgentFullProfile)), !isForgeAgent && isCreateAgentsEnabled && /*#__PURE__*/React.createElement(DropdownItem, {
|
|
195
195
|
onClick: ( /*#__PURE__*/function () {
|
|
196
196
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(e) {
|
|
197
|
-
return _regeneratorRuntime.wrap(function
|
|
197
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
198
198
|
while (1) switch (_context2.prev = _context2.next) {
|
|
199
199
|
case 0:
|
|
200
200
|
if (fg('rovo_agent_versioning_enabled')) {
|
|
201
201
|
e.stopPropagation();
|
|
202
202
|
}
|
|
203
203
|
setIsDuplicating(true);
|
|
204
|
-
_context2.prev =
|
|
205
|
-
_context2.next =
|
|
204
|
+
_context2.prev = 1;
|
|
205
|
+
_context2.next = 2;
|
|
206
206
|
return onDuplicateAgent === null || onDuplicateAgent === void 0 ? void 0 : onDuplicateAgent(e);
|
|
207
|
-
case
|
|
208
|
-
_context2.prev =
|
|
207
|
+
case 2:
|
|
208
|
+
_context2.prev = 2;
|
|
209
209
|
setIsDuplicating(false);
|
|
210
|
-
return _context2.finish(
|
|
211
|
-
case
|
|
210
|
+
return _context2.finish(2);
|
|
211
|
+
case 3:
|
|
212
212
|
case "end":
|
|
213
213
|
return _context2.stop();
|
|
214
214
|
}
|
|
215
|
-
}, _callee2, null, [[
|
|
215
|
+
}, _callee2, null, [[1,, 2, 3]]);
|
|
216
216
|
}));
|
|
217
217
|
return function (_x) {
|
|
218
218
|
return _ref5.apply(this, arguments);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared identity-derivation helper used by AgentInputHat (above the prompt
|
|
3
|
+
* input) and AgentResponseHat (above an assistant message). Both components
|
|
4
|
+
* need to translate raw agent identity props into the inputs that AgentAvatar
|
|
5
|
+
* expects, plus an accessible/visible name pair, with the same fallback
|
|
6
|
+
* semantics. Centralising the logic here avoids drift between the two hats —
|
|
7
|
+
* historically every change to one needed a paired change to the other.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
|
+
import { isAgentCreatorType } from '../../common/utils/is-agent-creator-type';
|
|
12
|
+
import { isForgeAgentByCreatorType } from '../../common/utils/is-forge-agent';
|
|
13
|
+
|
|
14
|
+
/** Raw identity input — typically a subset of `Agent` or `message.author`. */
|
|
15
|
+
|
|
16
|
+
/** Derived props ready to forward to AgentAvatar + the visible name slot. */
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Derive `AgentAvatar` inputs and visible/accessible labels from raw identity.
|
|
20
|
+
*
|
|
21
|
+
* Behaviour:
|
|
22
|
+
* - Specialist path (`agentId` is a non-empty string): visible text is the
|
|
23
|
+
* supplied `agentName`, omitted entirely if absent (no "Rovo" text next to
|
|
24
|
+
* a specialist avatar). Accessible label falls back to the agent id so the
|
|
25
|
+
* avatar is never announced as "Rovo".
|
|
26
|
+
* - Default Rovo path (no `agentId`): visible and accessible labels are the
|
|
27
|
+
* localized default name (typically "Rovo").
|
|
28
|
+
* - Forge identity props are gated internally via `rovo_agent_support_a2a_avatar`
|
|
29
|
+
* so callers don't have to.
|
|
30
|
+
*/
|
|
31
|
+
export function deriveAgentIdentity(_ref) {
|
|
32
|
+
var agentId = _ref.agentId,
|
|
33
|
+
agentName = _ref.agentName,
|
|
34
|
+
agentNamedId = _ref.agentNamedId,
|
|
35
|
+
agentIdentityAccountId = _ref.agentIdentityAccountId,
|
|
36
|
+
imageUrl = _ref.imageUrl,
|
|
37
|
+
creatorType = _ref.creatorType,
|
|
38
|
+
isForgeAgentOverride = _ref.isForgeAgent,
|
|
39
|
+
forgeAgentIconUrl = _ref.forgeAgentIconUrl,
|
|
40
|
+
defaultName = _ref.defaultName;
|
|
41
|
+
var trimmedAgentId = typeof agentId === 'string' ? agentId.trim() : undefined;
|
|
42
|
+
var specialistAgentId = trimmedAgentId && trimmedAgentId.length > 0 ? trimmedAgentId : undefined;
|
|
43
|
+
var trimmedAgentName = agentName === null || agentName === void 0 ? void 0 : agentName.trim();
|
|
44
|
+
var visibleName = specialistAgentId ? trimmedAgentName || undefined : defaultName;
|
|
45
|
+
var accessibleName = specialistAgentId ? trimmedAgentName || specialistAgentId : defaultName;
|
|
46
|
+
var a2aGateOn = fg('rovo_agent_support_a2a_avatar');
|
|
47
|
+
|
|
48
|
+
// Prefer the explicit override; otherwise validate creatorType via the
|
|
49
|
+
// type guard so the call site doesn't need an unsafe cast.
|
|
50
|
+
var isForgeAgent = isForgeAgentOverride !== undefined ? isForgeAgentOverride : creatorType && isAgentCreatorType(creatorType) ? isForgeAgentByCreatorType(creatorType) : undefined;
|
|
51
|
+
return {
|
|
52
|
+
specialistAgentId: specialistAgentId,
|
|
53
|
+
visibleName: visibleName,
|
|
54
|
+
accessibleName: accessibleName,
|
|
55
|
+
avatarProps: {
|
|
56
|
+
agentId: specialistAgentId,
|
|
57
|
+
agentNamedId: agentNamedId,
|
|
58
|
+
agentIdentityAccountId: agentIdentityAccountId,
|
|
59
|
+
imageUrl: imageUrl,
|
|
60
|
+
isForgeAgent: a2aGateOn ? isForgeAgent : undefined,
|
|
61
|
+
forgeAgentIconUrl: a2aGateOn ? forgeAgentIconUrl : undefined
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @generated SignedSource<<
|
|
2
|
+
* @generated SignedSource<<6976169d85be7545c35821ac2ecd2c10>>
|
|
3
3
|
* @relayHash c95a4b89f332b56ac41d44591442026c
|
|
4
4
|
* @lightSyntaxTransform
|
|
5
5
|
* @nogrep
|
|
@@ -177,5 +177,5 @@ var node = function () {
|
|
|
177
177
|
}
|
|
178
178
|
};
|
|
179
179
|
}();
|
|
180
|
-
node.hash = "
|
|
180
|
+
node.hash = "5f2bdb1cf9fe006560907bc0bd0c1fed";
|
|
181
181
|
export default node;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared identity-derivation helper used by AgentInputHat (above the prompt
|
|
3
|
+
* input) and AgentResponseHat (above an assistant message). Both components
|
|
4
|
+
* need to translate raw agent identity props into the inputs that AgentAvatar
|
|
5
|
+
* expects, plus an accessible/visible name pair, with the same fallback
|
|
6
|
+
* semantics. Centralising the logic here avoids drift between the two hats —
|
|
7
|
+
* historically every change to one needed a paired change to the other.
|
|
8
|
+
*/
|
|
9
|
+
/** Raw identity input — typically a subset of `Agent` or `message.author`. */
|
|
10
|
+
export type AgentIdentityInput = {
|
|
11
|
+
/** Specialist agent id. Falsy/empty/whitespace = default Rovo turn. */
|
|
12
|
+
agentId?: string;
|
|
13
|
+
agentName?: string;
|
|
14
|
+
agentNamedId?: string;
|
|
15
|
+
agentIdentityAccountId?: string;
|
|
16
|
+
imageUrl?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Raw backend `creator_type` (e.g. "FORGE", "REMOTE_A2A"). Validated via
|
|
19
|
+
* `isAgentCreatorType` internally so callers don't need an unsafe cast.
|
|
20
|
+
* Ignored when `isForgeAgent` is provided explicitly.
|
|
21
|
+
*/
|
|
22
|
+
creatorType?: string;
|
|
23
|
+
/** Pre-resolved Forge/REMOTE_A2A flag. Takes precedence over `creatorType`. */
|
|
24
|
+
isForgeAgent?: boolean;
|
|
25
|
+
forgeAgentIconUrl?: string;
|
|
26
|
+
/** Localized fallback used when the default Rovo path renders text. */
|
|
27
|
+
defaultName: string;
|
|
28
|
+
};
|
|
29
|
+
/** Derived props ready to forward to AgentAvatar + the visible name slot. */
|
|
30
|
+
export type DerivedAgentIdentity = {
|
|
31
|
+
/** Non-empty agentId when on the specialist path; undefined otherwise. */
|
|
32
|
+
specialistAgentId: string | undefined;
|
|
33
|
+
/** Visible label to render in the hat's text slot, or undefined to omit. */
|
|
34
|
+
visibleName: string | undefined;
|
|
35
|
+
/** Always-non-empty accessible label for the avatar. */
|
|
36
|
+
accessibleName: string;
|
|
37
|
+
/** Props to spread onto AgentAvatar — only meaningful on the specialist path. */
|
|
38
|
+
avatarProps: {
|
|
39
|
+
agentId: string | undefined;
|
|
40
|
+
agentNamedId: string | undefined;
|
|
41
|
+
agentIdentityAccountId: string | undefined;
|
|
42
|
+
imageUrl: string | undefined;
|
|
43
|
+
isForgeAgent: boolean | undefined;
|
|
44
|
+
forgeAgentIconUrl: string | undefined;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Derive `AgentAvatar` inputs and visible/accessible labels from raw identity.
|
|
49
|
+
*
|
|
50
|
+
* Behaviour:
|
|
51
|
+
* - Specialist path (`agentId` is a non-empty string): visible text is the
|
|
52
|
+
* supplied `agentName`, omitted entirely if absent (no "Rovo" text next to
|
|
53
|
+
* a specialist avatar). Accessible label falls back to the agent id so the
|
|
54
|
+
* avatar is never announced as "Rovo".
|
|
55
|
+
* - Default Rovo path (no `agentId`): visible and accessible labels are the
|
|
56
|
+
* localized default name (typically "Rovo").
|
|
57
|
+
* - Forge identity props are gated internally via `rovo_agent_support_a2a_avatar`
|
|
58
|
+
* so callers don't have to.
|
|
59
|
+
*/
|
|
60
|
+
export declare function deriveAgentIdentity({ agentId, agentName, agentNamedId, agentIdentityAccountId, imageUrl, creatorType, isForgeAgent: isForgeAgentOverride, forgeAgentIconUrl, defaultName, }: AgentIdentityInput): DerivedAgentIdentity;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared identity-derivation helper used by AgentInputHat (above the prompt
|
|
3
|
+
* input) and AgentResponseHat (above an assistant message). Both components
|
|
4
|
+
* need to translate raw agent identity props into the inputs that AgentAvatar
|
|
5
|
+
* expects, plus an accessible/visible name pair, with the same fallback
|
|
6
|
+
* semantics. Centralising the logic here avoids drift between the two hats —
|
|
7
|
+
* historically every change to one needed a paired change to the other.
|
|
8
|
+
*/
|
|
9
|
+
/** Raw identity input — typically a subset of `Agent` or `message.author`. */
|
|
10
|
+
export type AgentIdentityInput = {
|
|
11
|
+
/** Specialist agent id. Falsy/empty/whitespace = default Rovo turn. */
|
|
12
|
+
agentId?: string;
|
|
13
|
+
agentName?: string;
|
|
14
|
+
agentNamedId?: string;
|
|
15
|
+
agentIdentityAccountId?: string;
|
|
16
|
+
imageUrl?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Raw backend `creator_type` (e.g. "FORGE", "REMOTE_A2A"). Validated via
|
|
19
|
+
* `isAgentCreatorType` internally so callers don't need an unsafe cast.
|
|
20
|
+
* Ignored when `isForgeAgent` is provided explicitly.
|
|
21
|
+
*/
|
|
22
|
+
creatorType?: string;
|
|
23
|
+
/** Pre-resolved Forge/REMOTE_A2A flag. Takes precedence over `creatorType`. */
|
|
24
|
+
isForgeAgent?: boolean;
|
|
25
|
+
forgeAgentIconUrl?: string;
|
|
26
|
+
/** Localized fallback used when the default Rovo path renders text. */
|
|
27
|
+
defaultName: string;
|
|
28
|
+
};
|
|
29
|
+
/** Derived props ready to forward to AgentAvatar + the visible name slot. */
|
|
30
|
+
export type DerivedAgentIdentity = {
|
|
31
|
+
/** Non-empty agentId when on the specialist path; undefined otherwise. */
|
|
32
|
+
specialistAgentId: string | undefined;
|
|
33
|
+
/** Visible label to render in the hat's text slot, or undefined to omit. */
|
|
34
|
+
visibleName: string | undefined;
|
|
35
|
+
/** Always-non-empty accessible label for the avatar. */
|
|
36
|
+
accessibleName: string;
|
|
37
|
+
/** Props to spread onto AgentAvatar — only meaningful on the specialist path. */
|
|
38
|
+
avatarProps: {
|
|
39
|
+
agentId: string | undefined;
|
|
40
|
+
agentNamedId: string | undefined;
|
|
41
|
+
agentIdentityAccountId: string | undefined;
|
|
42
|
+
imageUrl: string | undefined;
|
|
43
|
+
isForgeAgent: boolean | undefined;
|
|
44
|
+
forgeAgentIconUrl: string | undefined;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Derive `AgentAvatar` inputs and visible/accessible labels from raw identity.
|
|
49
|
+
*
|
|
50
|
+
* Behaviour:
|
|
51
|
+
* - Specialist path (`agentId` is a non-empty string): visible text is the
|
|
52
|
+
* supplied `agentName`, omitted entirely if absent (no "Rovo" text next to
|
|
53
|
+
* a specialist avatar). Accessible label falls back to the agent id so the
|
|
54
|
+
* avatar is never announced as "Rovo".
|
|
55
|
+
* - Default Rovo path (no `agentId`): visible and accessible labels are the
|
|
56
|
+
* localized default name (typically "Rovo").
|
|
57
|
+
* - Forge identity props are gated internally via `rovo_agent_support_a2a_avatar`
|
|
58
|
+
* so callers don't have to.
|
|
59
|
+
*/
|
|
60
|
+
export declare function deriveAgentIdentity({ agentId, agentName, agentNamedId, agentIdentityAccountId, imageUrl, creatorType, isForgeAgent: isForgeAgentOverride, forgeAgentIconUrl, defaultName, }: AgentIdentityInput): DerivedAgentIdentity;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/rovo-agent-components",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "This package host public components related to rovo agents, the components here are needed for other public atlaskit packages",
|
|
5
5
|
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-monorepo",
|
|
6
6
|
"atlassian": {
|
|
@@ -41,22 +41,22 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@atlaskit/afm-i18n-platform-ai-mate-rovo-agent-components": "2.10.0",
|
|
43
43
|
"@atlaskit/analytics-next": "^11.2.0",
|
|
44
|
-
"@atlaskit/avatar": "^25.
|
|
44
|
+
"@atlaskit/avatar": "^25.15.0",
|
|
45
45
|
"@atlaskit/button": "^23.11.0",
|
|
46
46
|
"@atlaskit/css": "^0.19.0",
|
|
47
|
-
"@atlaskit/dropdown-menu": "^16.
|
|
48
|
-
"@atlaskit/flag": "^17.
|
|
47
|
+
"@atlaskit/dropdown-menu": "^16.9.0",
|
|
48
|
+
"@atlaskit/flag": "^17.12.0",
|
|
49
49
|
"@atlaskit/heading": "^5.4.0",
|
|
50
|
-
"@atlaskit/icon": "^35.
|
|
50
|
+
"@atlaskit/icon": "^35.3.0",
|
|
51
51
|
"@atlaskit/link": "^3.4.0",
|
|
52
52
|
"@atlaskit/logo": "^20.1.0",
|
|
53
53
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
54
54
|
"@atlaskit/primitives": "^19.0.0",
|
|
55
|
-
"@atlaskit/rovo-agent-analytics": "^1.
|
|
55
|
+
"@atlaskit/rovo-agent-analytics": "^1.10.0",
|
|
56
56
|
"@atlaskit/skeleton": "^2.1.0",
|
|
57
57
|
"@atlaskit/spinner": "^19.1.0",
|
|
58
|
-
"@atlaskit/tokens": "^13.
|
|
59
|
-
"@atlaskit/tooltip": "^22.
|
|
58
|
+
"@atlaskit/tokens": "^13.1.0",
|
|
59
|
+
"@atlaskit/tooltip": "^22.5.0",
|
|
60
60
|
"@babel/runtime": "^7.0.0",
|
|
61
61
|
"@compiled/react": "^0.20.0",
|
|
62
62
|
"react-dom": "^18.2.0",
|
|
@@ -73,7 +73,8 @@
|
|
|
73
73
|
"@atlassian/testing-library": "^0.6.0",
|
|
74
74
|
"@testing-library/react": "^16.3.0",
|
|
75
75
|
"@testing-library/user-event": "^14.4.3",
|
|
76
|
-
"@types/relay-test-utils": "^
|
|
76
|
+
"@types/relay-test-utils": "^19.0.0",
|
|
77
|
+
"react": "^18.2.0",
|
|
77
78
|
"react-intl": "^6.6.2",
|
|
78
79
|
"relay-test-utils": "^20.1.1",
|
|
79
80
|
"wait-for-expect": "^1.2.0"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/rovo-agent-components/ui/agent-identity/derive-agent-identity",
|
|
3
|
+
"main": "../../../dist/cjs/ui/agent-identity/derive-agent-identity.js",
|
|
4
|
+
"module": "../../../dist/esm/ui/agent-identity/derive-agent-identity.js",
|
|
5
|
+
"module:es2019": "../../../dist/es2019/ui/agent-identity/derive-agent-identity.js",
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"*.compiled.css"
|
|
8
|
+
],
|
|
9
|
+
"types": "../../../dist/types/ui/agent-identity/derive-agent-identity.d.ts",
|
|
10
|
+
"typesVersions": {
|
|
11
|
+
">=4.5 <5.9": {
|
|
12
|
+
"*": [
|
|
13
|
+
"../../../dist/types-ts4.5/ui/agent-identity/derive-agent-identity.d.ts"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|