@adecore/agents-react 0.64.1 → 0.65.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/dist/chat/ui/intelligent-ui/render-context.d.ts +1 -0
- package/dist/chat/ui/intelligent-ui/renderers/content.d.ts +1 -1
- package/dist/chat/ui/intelligent-ui/renderers/content.js +118 -94
- package/package.json +9 -9
- package/src/chat/ui/intelligent-ui/UiReply.tsx +2 -1
- package/src/chat/ui/intelligent-ui/render-context.ts +2 -0
- package/src/chat/ui/intelligent-ui/renderers/content.tsx +34 -10
|
@@ -999,7 +999,7 @@ function _temp2(source, index) {
|
|
|
999
999
|
return [source.id, index + 1];
|
|
1000
1000
|
}
|
|
1001
1001
|
export function UiSourceCitation(t0) {
|
|
1002
|
-
const $ = _c(
|
|
1002
|
+
const $ = _c(28);
|
|
1003
1003
|
const {
|
|
1004
1004
|
number,
|
|
1005
1005
|
title,
|
|
@@ -1085,50 +1085,75 @@ export function UiSourceCitation(t0) {
|
|
|
1085
1085
|
}
|
|
1086
1086
|
let t8;
|
|
1087
1087
|
if ($[20] !== url) {
|
|
1088
|
-
t8 =
|
|
1088
|
+
t8 = url !== undefined && /*#__PURE__*/_jsx("span", {
|
|
1089
|
+
className: "truncate text-text-faint",
|
|
1090
|
+
children: uiUrlDomain(url)
|
|
1091
|
+
});
|
|
1089
1092
|
$[20] = url;
|
|
1090
1093
|
$[21] = t8;
|
|
1091
1094
|
} else {
|
|
1092
1095
|
t8 = $[21];
|
|
1093
1096
|
}
|
|
1094
1097
|
let t9;
|
|
1095
|
-
if ($[22] !== t8) {
|
|
1096
|
-
t9 = /*#__PURE__*/
|
|
1097
|
-
className: "truncate text-text-faint",
|
|
1098
|
-
children: t8
|
|
1099
|
-
});
|
|
1100
|
-
$[22] = t8;
|
|
1101
|
-
$[23] = t9;
|
|
1102
|
-
} else {
|
|
1103
|
-
t9 = $[23];
|
|
1104
|
-
}
|
|
1105
|
-
let t10;
|
|
1106
|
-
if ($[24] !== t7 || $[25] !== t9) {
|
|
1107
|
-
t10 = /*#__PURE__*/_jsxs(PreviewCard.Popup, {
|
|
1098
|
+
if ($[22] !== t7 || $[23] !== t8) {
|
|
1099
|
+
t9 = /*#__PURE__*/_jsxs(PreviewCard.Popup, {
|
|
1108
1100
|
side: "top",
|
|
1109
1101
|
align: "center",
|
|
1110
1102
|
sideOffset: 4,
|
|
1111
1103
|
className: "flex max-w-72 flex-col px-2.5 py-1.5 text-xs",
|
|
1112
|
-
children: [t7,
|
|
1104
|
+
children: [t7, t8]
|
|
1113
1105
|
});
|
|
1114
|
-
$[
|
|
1115
|
-
$[
|
|
1116
|
-
$[
|
|
1106
|
+
$[22] = t7;
|
|
1107
|
+
$[23] = t8;
|
|
1108
|
+
$[24] = t9;
|
|
1117
1109
|
} else {
|
|
1118
|
-
|
|
1110
|
+
t9 = $[24];
|
|
1119
1111
|
}
|
|
1120
|
-
let
|
|
1121
|
-
if ($[
|
|
1122
|
-
|
|
1123
|
-
children: [t6,
|
|
1112
|
+
let t10;
|
|
1113
|
+
if ($[25] !== t6 || $[26] !== t9) {
|
|
1114
|
+
t10 = /*#__PURE__*/_jsxs(PreviewCard.Root, {
|
|
1115
|
+
children: [t6, t9]
|
|
1124
1116
|
});
|
|
1117
|
+
$[25] = t6;
|
|
1118
|
+
$[26] = t9;
|
|
1125
1119
|
$[27] = t10;
|
|
1126
|
-
$[28] = t6;
|
|
1127
|
-
$[29] = t11;
|
|
1128
1120
|
} else {
|
|
1129
|
-
|
|
1121
|
+
t10 = $[27];
|
|
1130
1122
|
}
|
|
1131
|
-
return
|
|
1123
|
+
return t10;
|
|
1124
|
+
}
|
|
1125
|
+
/* Where a Source points and how its row reads: an address by its domain, a host node by what the host calls it. */
|
|
1126
|
+
function sourceFace(props, context) {
|
|
1127
|
+
const {
|
|
1128
|
+
title,
|
|
1129
|
+
url,
|
|
1130
|
+
node
|
|
1131
|
+
} = props;
|
|
1132
|
+
if (url !== undefined) {
|
|
1133
|
+
const {
|
|
1134
|
+
openUrl
|
|
1135
|
+
} = context;
|
|
1136
|
+
return {
|
|
1137
|
+
title,
|
|
1138
|
+
detail: uiUrlDomain(url),
|
|
1139
|
+
whole: url,
|
|
1140
|
+
open: openUrl === undefined ? undefined : () => openUrl(url)
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
const target = {
|
|
1144
|
+
type: 'Node',
|
|
1145
|
+
id: node ?? ''
|
|
1146
|
+
};
|
|
1147
|
+
const link = context.link?.(target);
|
|
1148
|
+
const {
|
|
1149
|
+
openLink
|
|
1150
|
+
} = context;
|
|
1151
|
+
return {
|
|
1152
|
+
title: link?.label ?? title,
|
|
1153
|
+
detail: link?.detail,
|
|
1154
|
+
whole: link?.detail,
|
|
1155
|
+
open: link?.state === 'chip' && openLink !== undefined ? () => openLink(target) : undefined
|
|
1156
|
+
};
|
|
1132
1157
|
}
|
|
1133
1158
|
/*
|
|
1134
1159
|
* Opens through the host and loads nothing before, not even an icon. The row itself takes focus
|
|
@@ -1151,130 +1176,129 @@ export function SourceRenderer(t0) {
|
|
|
1151
1176
|
t2 = $[2];
|
|
1152
1177
|
}
|
|
1153
1178
|
const number = t2;
|
|
1179
|
+
let t3;
|
|
1180
|
+
if ($[3] !== context || $[4] !== node.props) {
|
|
1181
|
+
t3 = sourceFace(node.props, context);
|
|
1182
|
+
$[3] = context;
|
|
1183
|
+
$[4] = node.props;
|
|
1184
|
+
$[5] = t3;
|
|
1185
|
+
} else {
|
|
1186
|
+
t3 = $[5];
|
|
1187
|
+
}
|
|
1154
1188
|
const {
|
|
1155
1189
|
title,
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
} = context;
|
|
1190
|
+
detail,
|
|
1191
|
+
whole,
|
|
1192
|
+
open
|
|
1193
|
+
} = t3;
|
|
1161
1194
|
const [measureDomain, domainCut] = useTruncated();
|
|
1162
|
-
let
|
|
1163
|
-
if ($[
|
|
1164
|
-
|
|
1195
|
+
let t4;
|
|
1196
|
+
if ($[6] !== number) {
|
|
1197
|
+
t4 = /*#__PURE__*/_jsx("span", {
|
|
1165
1198
|
className: "grid size-5 shrink-0 place-items-center rounded-md bg-ui-inset text-2xs font-semibold text-text tabular-nums",
|
|
1166
1199
|
children: number
|
|
1167
1200
|
});
|
|
1168
|
-
$[
|
|
1169
|
-
$[
|
|
1201
|
+
$[6] = number;
|
|
1202
|
+
$[7] = t4;
|
|
1170
1203
|
} else {
|
|
1171
|
-
|
|
1204
|
+
t4 = $[7];
|
|
1172
1205
|
}
|
|
1173
|
-
let
|
|
1174
|
-
if ($[
|
|
1175
|
-
|
|
1206
|
+
let t5;
|
|
1207
|
+
if ($[8] !== title) {
|
|
1208
|
+
t5 = /*#__PURE__*/_jsx("span", {
|
|
1176
1209
|
className: "font-medium wrap-anywhere text-text",
|
|
1177
1210
|
children: title
|
|
1178
1211
|
});
|
|
1179
|
-
$[
|
|
1180
|
-
$[
|
|
1181
|
-
} else {
|
|
1182
|
-
t4 = $[6];
|
|
1183
|
-
}
|
|
1184
|
-
let t5;
|
|
1185
|
-
if ($[7] !== url) {
|
|
1186
|
-
t5 = uiUrlDomain(url);
|
|
1187
|
-
$[7] = url;
|
|
1188
|
-
$[8] = t5;
|
|
1212
|
+
$[8] = title;
|
|
1213
|
+
$[9] = t5;
|
|
1189
1214
|
} else {
|
|
1190
|
-
t5 = $[
|
|
1215
|
+
t5 = $[9];
|
|
1191
1216
|
}
|
|
1192
1217
|
let t6;
|
|
1193
|
-
if ($[
|
|
1194
|
-
t6 = /*#__PURE__*/_jsx("span", {
|
|
1218
|
+
if ($[10] !== detail || $[11] !== measureDomain) {
|
|
1219
|
+
t6 = detail !== undefined && /*#__PURE__*/_jsx("span", {
|
|
1195
1220
|
ref: measureDomain,
|
|
1196
1221
|
className: "truncate text-text-muted",
|
|
1197
|
-
children:
|
|
1222
|
+
children: detail
|
|
1198
1223
|
});
|
|
1199
|
-
$[
|
|
1200
|
-
$[
|
|
1201
|
-
$[
|
|
1224
|
+
$[10] = detail;
|
|
1225
|
+
$[11] = measureDomain;
|
|
1226
|
+
$[12] = t6;
|
|
1202
1227
|
} else {
|
|
1203
|
-
t6 = $[
|
|
1228
|
+
t6 = $[12];
|
|
1204
1229
|
}
|
|
1205
1230
|
let t7;
|
|
1206
|
-
if ($[
|
|
1231
|
+
if ($[13] !== t5 || $[14] !== t6) {
|
|
1207
1232
|
t7 = /*#__PURE__*/_jsxs("span", {
|
|
1208
1233
|
className: "flex min-w-0 grow flex-col",
|
|
1209
|
-
children: [
|
|
1234
|
+
children: [t5, t6]
|
|
1210
1235
|
});
|
|
1211
|
-
$[
|
|
1212
|
-
$[
|
|
1213
|
-
$[
|
|
1236
|
+
$[13] = t5;
|
|
1237
|
+
$[14] = t6;
|
|
1238
|
+
$[15] = t7;
|
|
1214
1239
|
} else {
|
|
1215
|
-
t7 = $[
|
|
1240
|
+
t7 = $[15];
|
|
1216
1241
|
}
|
|
1217
1242
|
let t8;
|
|
1218
|
-
if ($[
|
|
1243
|
+
if ($[16] !== t4 || $[17] !== t7) {
|
|
1219
1244
|
t8 = /*#__PURE__*/_jsxs(_Fragment, {
|
|
1220
|
-
children: [
|
|
1245
|
+
children: [t4, t7]
|
|
1221
1246
|
});
|
|
1222
|
-
$[
|
|
1223
|
-
$[
|
|
1224
|
-
$[
|
|
1247
|
+
$[16] = t4;
|
|
1248
|
+
$[17] = t7;
|
|
1249
|
+
$[18] = t8;
|
|
1225
1250
|
} else {
|
|
1226
|
-
t8 = $[
|
|
1251
|
+
t8 = $[18];
|
|
1227
1252
|
}
|
|
1228
1253
|
const face = t8;
|
|
1229
1254
|
let t9;
|
|
1230
|
-
if ($[
|
|
1255
|
+
if ($[19] !== title) {
|
|
1231
1256
|
t9 = /*#__PURE__*/_jsx("span", {
|
|
1232
1257
|
className: "block",
|
|
1233
1258
|
children: title
|
|
1234
1259
|
});
|
|
1235
|
-
$[
|
|
1236
|
-
$[
|
|
1260
|
+
$[19] = title;
|
|
1261
|
+
$[20] = t9;
|
|
1237
1262
|
} else {
|
|
1238
|
-
t9 = $[
|
|
1263
|
+
t9 = $[20];
|
|
1239
1264
|
}
|
|
1240
1265
|
let t10;
|
|
1241
|
-
if ($[
|
|
1242
|
-
t10 = /*#__PURE__*/_jsx("span", {
|
|
1266
|
+
if ($[21] !== whole) {
|
|
1267
|
+
t10 = whole !== undefined && /*#__PURE__*/_jsx("span", {
|
|
1243
1268
|
className: "block text-text-muted",
|
|
1244
|
-
children:
|
|
1269
|
+
children: whole
|
|
1245
1270
|
});
|
|
1246
|
-
$[
|
|
1247
|
-
$[
|
|
1271
|
+
$[21] = whole;
|
|
1272
|
+
$[22] = t10;
|
|
1248
1273
|
} else {
|
|
1249
|
-
t10 = $[
|
|
1274
|
+
t10 = $[22];
|
|
1250
1275
|
}
|
|
1251
1276
|
let t11;
|
|
1252
|
-
if ($[
|
|
1277
|
+
if ($[23] !== t10 || $[24] !== t9) {
|
|
1253
1278
|
t11 = /*#__PURE__*/_jsxs(_Fragment, {
|
|
1254
1279
|
children: [t9, t10]
|
|
1255
1280
|
});
|
|
1256
|
-
$[
|
|
1257
|
-
$[
|
|
1258
|
-
$[
|
|
1281
|
+
$[23] = t10;
|
|
1282
|
+
$[24] = t9;
|
|
1283
|
+
$[25] = t11;
|
|
1259
1284
|
} else {
|
|
1260
|
-
t11 = $[
|
|
1285
|
+
t11 = $[25];
|
|
1261
1286
|
}
|
|
1262
1287
|
let t12;
|
|
1263
|
-
if ($[
|
|
1264
|
-
t12 =
|
|
1288
|
+
if ($[26] !== domainCut || $[27] !== face || $[28] !== open) {
|
|
1289
|
+
t12 = open === undefined ? /*#__PURE__*/_jsx("span", {
|
|
1265
1290
|
tabIndex: domainCut ? 0 : undefined,
|
|
1266
1291
|
className: "chat-ui-flat-inner flex min-h-8 items-start gap-2.5 rounded-lg px-1.5 py-1.5 text-2xs",
|
|
1267
1292
|
children: face
|
|
1268
1293
|
}) : /*#__PURE__*/_jsx("button", {
|
|
1269
1294
|
type: "button",
|
|
1270
1295
|
className: "chat-ui-flat-inner flex min-h-8 w-full items-start gap-2.5 rounded-lg px-1.5 py-1.5 text-left text-2xs hover:bg-text/4",
|
|
1271
|
-
onClick:
|
|
1296
|
+
onClick: open,
|
|
1272
1297
|
children: face
|
|
1273
1298
|
});
|
|
1274
|
-
$[
|
|
1275
|
-
$[
|
|
1276
|
-
$[
|
|
1277
|
-
$[28] = url;
|
|
1299
|
+
$[26] = domainCut;
|
|
1300
|
+
$[27] = face;
|
|
1301
|
+
$[28] = open;
|
|
1278
1302
|
$[29] = t12;
|
|
1279
1303
|
} else {
|
|
1280
1304
|
t12 = $[29];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adecore/agents-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.65.0",
|
|
4
4
|
"description": "React agent chat threads, composers, approvals, provider accounts and usage views.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -72,12 +72,12 @@
|
|
|
72
72
|
"test:visuals": "bun --config=integration.bunfig.toml --conditions=source test ./src/chat/visual-viewport.integration.test.ts"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@adecore/agent-contracts": "0.
|
|
76
|
-
"@adecore/editor": "0.
|
|
77
|
-
"@adecore/editor-react": "0.
|
|
78
|
-
"@adecore/intelligent-ui": "0.
|
|
79
|
-
"@adecore/merge": "0.
|
|
80
|
-
"@adecore/utils": "0.
|
|
75
|
+
"@adecore/agent-contracts": "0.65.0",
|
|
76
|
+
"@adecore/editor": "0.65.0",
|
|
77
|
+
"@adecore/editor-react": "0.65.0",
|
|
78
|
+
"@adecore/intelligent-ui": "0.65.0",
|
|
79
|
+
"@adecore/merge": "0.65.0",
|
|
80
|
+
"@adecore/utils": "0.65.0",
|
|
81
81
|
"@codemirror/commands": "^6.11.1",
|
|
82
82
|
"@codemirror/language": "^6.13.1",
|
|
83
83
|
"@codemirror/state": "^6.7.6",
|
|
@@ -101,14 +101,14 @@
|
|
|
101
101
|
"zustand": "^5.0.16"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
|
-
"@adecore/ui": "^0.
|
|
104
|
+
"@adecore/ui": "^0.65.0",
|
|
105
105
|
"i18next": "^26.4.2",
|
|
106
106
|
"react": "^19.3.0",
|
|
107
107
|
"react-dom": "^19.3.0",
|
|
108
108
|
"react-i18next": "^17.0.15"
|
|
109
109
|
},
|
|
110
110
|
"devDependencies": {
|
|
111
|
-
"@adecore/ui": "0.
|
|
111
|
+
"@adecore/ui": "0.65.0",
|
|
112
112
|
"@types/bun": "^1.4.4",
|
|
113
113
|
"@types/react": "^19.3.0",
|
|
114
114
|
"@types/react-dom": "^19.3.0",
|
|
@@ -9,6 +9,8 @@ export interface UiLink {
|
|
|
9
9
|
state: 'chip' | 'plain';
|
|
10
10
|
/* What the host calls the target, such as the title of a node or the subject of a commit. */
|
|
11
11
|
label?: string;
|
|
12
|
+
/* A second line under the label where the link stands as a row, such as a cited Source. */
|
|
13
|
+
detail?: string;
|
|
12
14
|
/* Why a plain link is not a chip, in its tooltip. */
|
|
13
15
|
reason?: string;
|
|
14
16
|
/* The stable code of that reason, which a client words itself where it knows it. */
|
|
@@ -282,7 +282,8 @@ interface UiSourceCitationProps {
|
|
|
282
282
|
/* The number of the Source, as its row in the list counts it. */
|
|
283
283
|
number: number;
|
|
284
284
|
title: string;
|
|
285
|
-
|
|
285
|
+
/* Absent for a source that cites a host node, which shows its title alone. */
|
|
286
|
+
url?: string;
|
|
286
287
|
/* Shows the Source row the number stands for. Without it the number is no button. */
|
|
287
288
|
onReveal?: () => void;
|
|
288
289
|
className?: string;
|
|
@@ -314,20 +315,41 @@ export function UiSourceCitation({ number, title, url, onReveal, className }: Ui
|
|
|
314
315
|
</PreviewCard.Trigger>
|
|
315
316
|
<PreviewCard.Popup side="top" align="center" sideOffset={4} className="flex max-w-72 flex-col px-2.5 py-1.5 text-xs">
|
|
316
317
|
<span className="line-clamp-2 text-text">{title}</span>
|
|
317
|
-
<span className="truncate text-text-faint">{uiUrlDomain(url)}</span>
|
|
318
|
+
{url !== undefined && <span className="truncate text-text-faint">{uiUrlDomain(url)}</span>}
|
|
318
319
|
</PreviewCard.Popup>
|
|
319
320
|
</PreviewCard.Root>
|
|
320
321
|
);
|
|
321
322
|
}
|
|
322
323
|
|
|
324
|
+
/* Where a Source points and how its row reads: an address by its domain, a host node by what the host calls it. */
|
|
325
|
+
function sourceFace(props: UiProps<'Source'>, context: UiRendererProps<UiProps<'Source'>>['context']) {
|
|
326
|
+
const { title, url, node } = props;
|
|
327
|
+
|
|
328
|
+
if (url !== undefined) {
|
|
329
|
+
const { openUrl } = context;
|
|
330
|
+
|
|
331
|
+
return { title, detail: uiUrlDomain(url), whole: url, open: openUrl === undefined ? undefined : () => openUrl(url) };
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const target = { type: 'Node' as const, id: node ?? '' };
|
|
335
|
+
const link = context.link?.(target);
|
|
336
|
+
const { openLink } = context;
|
|
337
|
+
|
|
338
|
+
return {
|
|
339
|
+
title: link?.label ?? title,
|
|
340
|
+
detail: link?.detail,
|
|
341
|
+
whole: link?.detail,
|
|
342
|
+
open: link?.state === 'chip' && openLink !== undefined ? () => openLink(target) : undefined
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
|
|
323
346
|
/*
|
|
324
347
|
* Opens through the host and loads nothing before, not even an icon. The row itself takes focus
|
|
325
348
|
* when a citation reveals it, apart from the button that opens it.
|
|
326
349
|
*/
|
|
327
350
|
export function SourceRenderer({ node, context }: UiRendererProps<UiProps<'Source'>>) {
|
|
328
351
|
const number = useContext(SourceNumbers).get(node.id);
|
|
329
|
-
const { title,
|
|
330
|
-
const { openUrl } = context;
|
|
352
|
+
const { title, detail, whole, open } = sourceFace(node.props, context);
|
|
331
353
|
const [measureDomain, domainCut] = useTruncated<HTMLSpanElement>();
|
|
332
354
|
|
|
333
355
|
const face = (
|
|
@@ -335,9 +357,11 @@ export function SourceRenderer({ node, context }: UiRendererProps<UiProps<'Sourc
|
|
|
335
357
|
<span className="grid size-5 shrink-0 place-items-center rounded-md bg-ui-inset text-2xs font-semibold text-text tabular-nums">{number}</span>
|
|
336
358
|
<span className="flex min-w-0 grow flex-col">
|
|
337
359
|
<span className="font-medium wrap-anywhere text-text">{title}</span>
|
|
338
|
-
|
|
339
|
-
{
|
|
340
|
-
|
|
360
|
+
{detail !== undefined && (
|
|
361
|
+
<span ref={measureDomain} className="truncate text-text-muted">
|
|
362
|
+
{detail}
|
|
363
|
+
</span>
|
|
364
|
+
)}
|
|
341
365
|
</span>
|
|
342
366
|
</>
|
|
343
367
|
);
|
|
@@ -349,11 +373,11 @@ export function SourceRenderer({ node, context }: UiRendererProps<UiProps<'Sourc
|
|
|
349
373
|
label={
|
|
350
374
|
<>
|
|
351
375
|
<span className="block">{title}</span>
|
|
352
|
-
<span className="block text-text-muted">{
|
|
376
|
+
{whole !== undefined && <span className="block text-text-muted">{whole}</span>}
|
|
353
377
|
</>
|
|
354
378
|
}
|
|
355
379
|
>
|
|
356
|
-
{
|
|
380
|
+
{open === undefined ? (
|
|
357
381
|
<span
|
|
358
382
|
tabIndex={domainCut ? 0 : undefined}
|
|
359
383
|
className="chat-ui-flat-inner flex min-h-8 items-start gap-2.5 rounded-lg px-1.5 py-1.5 text-2xs"
|
|
@@ -364,7 +388,7 @@ export function SourceRenderer({ node, context }: UiRendererProps<UiProps<'Sourc
|
|
|
364
388
|
<button
|
|
365
389
|
type="button"
|
|
366
390
|
className="chat-ui-flat-inner flex min-h-8 w-full items-start gap-2.5 rounded-lg px-1.5 py-1.5 text-left text-2xs hover:bg-text/4"
|
|
367
|
-
onClick={
|
|
391
|
+
onClick={open}
|
|
368
392
|
>
|
|
369
393
|
{face}
|
|
370
394
|
</button>
|