@abpjs/ui 0.2.0-next.32 → 0.2.0-next.33
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 +21 -0
- package/dist/agent.d.ts +30 -4
- package/dist/agent.js +311 -102
- package/dist/agent.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/languages.d.ts +162 -0
- package/dist/languages.js +771 -0
- package/dist/languages.js.map +1 -0
- package/package.json +6 -1
package/dist/agent.js
CHANGED
|
@@ -5,12 +5,12 @@ import { Stack as Stack10 } from "@chakra-ui/react";
|
|
|
5
5
|
import { PageHeader } from "@abpjs/ui";
|
|
6
6
|
|
|
7
7
|
// src/areas/agent/AgentsAdmin.tsx
|
|
8
|
-
import { useState as
|
|
8
|
+
import { useState as useState10 } from "react";
|
|
9
9
|
import { Stack as Stack9, Text as Text10 } from "@chakra-ui/react";
|
|
10
|
-
import { Button as Button7, HostSlot as HostSlot5, InlineAlert as InlineAlert7, Panel as Panel3, SwitchField as SwitchField3, useApiAction as
|
|
10
|
+
import { Button as Button7, HostSlot as HostSlot5, InlineAlert as InlineAlert7, Panel as Panel3, SwitchField as SwitchField3, useApiAction as useApiAction6, useApiQuery as useApiQuery6, useAreaRequest as useAreaRequest6, useSlotSaves as useSlotSaves2 } from "@abpjs/ui";
|
|
11
11
|
|
|
12
12
|
// src/areas/agent/AgentEditor.tsx
|
|
13
|
-
import { useState as
|
|
13
|
+
import { useState as useState9 } from "react";
|
|
14
14
|
import { HStack as HStack5, Stack as Stack8, Text as Text9 } from "@chakra-ui/react";
|
|
15
15
|
import { HostSlot as HostSlot4, Panel as Panel2, PropertyList } from "@abpjs/ui";
|
|
16
16
|
|
|
@@ -226,18 +226,34 @@ var ar_default = {
|
|
|
226
226
|
"graph.outside": "\u062D\u064F\u0641\u0638\u062A \u0628\u0639\u062F \u0645\u062D\u062A\u0648\u0649 \u062E\u0627\u0631\u062C\u064A",
|
|
227
227
|
"graph.hidden": "{count, plural, one {\u062D\u0642\u064A\u0642\u0629 \u0623\u062E\u0631\u0649 \u062A\u0623\u062A\u064A} two {\u062D\u0642\u064A\u0642\u062A\u0627\u0646 \u0623\u062E\u0631\u064A\u0627\u0646 \u062A\u0623\u062A\u064A\u0627\u0646} few {# \u062D\u0642\u0627\u0626\u0642 \u0623\u062E\u0631\u0649 \u062A\u0623\u062A\u064A} other {# \u062D\u0642\u064A\u0642\u0629 \u0623\u062E\u0631\u0649 \u062A\u0623\u062A\u064A}} \u0645\u0646 \u0645\u0644\u0627\u062D\u0638\u0627\u062A \u0644\u0627 \u064A\u062D\u0642 \u0644\u0643 \u0642\u0631\u0627\u0621\u062A\u0647\u0627.",
|
|
228
228
|
"permissions.title": "\u0648\u0643\u0644\u0627\u0621 \u062A\u0633\u0645\u062D \u0644\u0647\u0645 \u062F\u0627\u0626\u0645\u064B\u0627",
|
|
229
|
-
"permissions.hint": "\
|
|
229
|
+
"permissions.hint": "\u0648\u0643\u0644\u0627\u0621 \u064A\u0633\u062A\u062E\u062F\u0645\u0648\u0646 \u0647\u0630\u0647 \u0627\u0644\u0623\u062F\u0648\u0627\u062A \u062F\u0648\u0646 \u0623\u0646 \u064A\u0633\u0623\u0644\u0648\u0643\u060C \u0641\u064A \u0627\u0644\u062A\u0634\u063A\u064A\u0644\u0627\u062A \u0627\u0644\u062A\u064A \u062A\u0628\u062F\u0624\u0647\u0627 \u0641\u064A \u0630\u0644\u0643 \u0627\u0644\u0645\u0634\u0631\u0648\u0639. \u0625\u0646 \u0623\u0632\u0644\u062A \u0623\u062D\u062F\u0647\u0645 \u0639\u0627\u062F \u064A\u0633\u0623\u0644\u0643.",
|
|
230
230
|
"permissions.agentTitle": "\u0645\u0633\u0645\u0648\u062D \u0628\u0647\u0627 \u062F\u0627\u0626\u0645\u064B\u0627 \u0645\u0646 \u0623\u0634\u062E\u0627\u0635",
|
|
231
|
-
"permissions.agentHint": "\u0623\
|
|
231
|
+
"permissions.agentHint": "\u0623\u0634\u062E\u0627\u0635 \u0633\u0645\u062D\u0648\u0627 \u0644\u0647\u0630\u0627 \u0627\u0644\u0648\u0643\u064A\u0644 \u0628\u0627\u0633\u062A\u062E\u062F\u0627\u0645 \u0647\u0630\u0647 \u0627\u0644\u0623\u062F\u0648\u0627\u062A \u062F\u0648\u0646 \u0623\u0646 \u064A\u0633\u0623\u0644\u0647\u0645\u060C \u0641\u064A \u0627\u0644\u062A\u0634\u063A\u064A\u0644\u0627\u062A \u0627\u0644\u062A\u064A \u064A\u0628\u062F\u0624\u0648\u0646\u0647\u0627 \u0641\u064A \u0630\u0644\u0643 \u0627\u0644\u0645\u0634\u0631\u0648\u0639. \u0625\u0632\u0627\u0644\u0629 \u0623\u062D\u062F\u0647\u0645 \u062A\u062C\u0639\u0644\u0647 \u064A\u0633\u0623\u0644\u0647\u0645 \u0645\u0646 \u062C\u062F\u064A\u062F.",
|
|
232
232
|
"permissions.empty": "\u0644\u0627 \u0634\u064A\u0621.",
|
|
233
|
-
"permissions.
|
|
234
|
-
"permissions.
|
|
235
|
-
"permissions.
|
|
236
|
-
"permissions.
|
|
233
|
+
"permissions.agent": "\u0627\u0644\u0648\u0643\u064A\u0644",
|
|
234
|
+
"permissions.person": "\u0627\u0644\u0634\u062E\u0635",
|
|
235
|
+
"permissions.madeBy": "\u0623\u0646\u0634\u0623\u0647 {name}",
|
|
236
|
+
"permissions.tools": "\u0627\u0644\u0623\u062F\u0648\u0627\u062A",
|
|
237
|
+
"permissions.toolSeparator": "\u060C ",
|
|
238
|
+
"permissions.project": "\u0627\u0644\u0645\u0634\u0631\u0648\u0639",
|
|
239
|
+
"permissions.since": "\u0645\u0646\u0630",
|
|
237
240
|
"permissions.used": "\u0622\u062E\u0631 \u0627\u0633\u062A\u062E\u062F\u0627\u0645 {at}",
|
|
238
241
|
"permissions.unused": "\u0644\u0645 \u064A\u064F\u0633\u062A\u062E\u062F\u0645 \u0628\u0639\u062F",
|
|
239
|
-
"permissions.
|
|
240
|
-
"permissions.
|
|
242
|
+
"permissions.remove": "\u0625\u0632\u0627\u0644\u0629",
|
|
243
|
+
"permissions.removeLabel": "\u0625\u0632\u0627\u0644\u0629 {name} \u0641\u064A {scope}",
|
|
244
|
+
"permissions.removeTitle": "\u0625\u064A\u0642\u0627\u0641 \u0627\u0644\u0633\u0645\u0627\u062D \u0644\u0640{name} \u0641\u064A {scope}\u061F",
|
|
245
|
+
"permissions.removeHint": "\u0633\u064A\u0633\u0623\u0644\u0643 \u0645\u0646 \u062C\u062F\u064A\u062F \u0642\u0628\u0644 \u0627\u0633\u062A\u062E\u062F\u0627\u0645 \u0647\u0630\u0647 \u0627\u0644\u0623\u062F\u0648\u0627\u062A.",
|
|
246
|
+
"permissions.removePersonTitle": "\u0625\u0632\u0627\u0644\u0629 \u0645\u0627 \u064A\u0633\u0645\u062D \u0628\u0647 {name} \u0641\u064A {scope}\u061F",
|
|
247
|
+
"permissions.removePersonHint": "\u0633\u064A\u0633\u0623\u0644\u0647\u0645 \u0645\u0646 \u062C\u062F\u064A\u062F \u0642\u0628\u0644 \u0627\u0633\u062A\u062E\u062F\u0627\u0645 \u0647\u0630\u0647 \u0627\u0644\u0623\u062F\u0648\u0627\u062A.",
|
|
248
|
+
"permissions.allowAgent": "\u0627\u0644\u0633\u0645\u0627\u062D \u0644\u0648\u0643\u064A\u0644",
|
|
249
|
+
"permissions.allowTitle": "\u0627\u0644\u0633\u0645\u0627\u062D \u0644\u0648\u0643\u064A\u0644",
|
|
250
|
+
"permissions.allowDescription": "\u0627\u062E\u062A\u0631 \u0627\u0644\u0623\u062F\u0648\u0627\u062A \u0627\u0644\u062A\u064A \u064A\u0645\u0643\u0646\u0647 \u0627\u0633\u062A\u062E\u062F\u0627\u0645\u0647\u0627 \u062F\u0648\u0646 \u0623\u0646 \u064A\u0633\u0623\u0644\u0643\u060C \u0641\u064A \u0627\u0644\u062A\u0634\u063A\u064A\u0644\u0627\u062A \u0627\u0644\u062A\u064A \u062A\u0628\u062F\u0624\u0647\u0627 \u0641\u064A \u0630\u0644\u0643 \u0627\u0644\u0645\u0634\u0631\u0648\u0639.",
|
|
251
|
+
"permissions.toolsWithoutAsking": "\u0623\u062F\u0648\u0627\u062A \u062F\u0648\u0646 \u0633\u0624\u0627\u0644",
|
|
252
|
+
"permissions.alreadyAllowed": "{tool} (\u0645\u0633\u0645\u0648\u062D \u0628\u0647\u0627 \u0645\u0646 \u0642\u0628\u0644)",
|
|
253
|
+
"permissions.allowHint": "\u064A\u0628\u0642\u0649 \u064A\u0633\u0623\u0644 \u0623\u0648\u0644\u064B\u0627 \u0625\u0646 \u0642\u0631\u0623 \u0627\u0644\u062A\u0634\u063A\u064A\u0644 \u0645\u062D\u062A\u0648\u0649 \u062E\u0627\u0631\u062C\u064A\u064B\u0627\u060C \u0643\u0631\u0633\u0627\u0644\u0629 \u0639\u0645\u064A\u0644\u060C \u0623\u0648 \u062A\u062C\u0627\u0648\u0632 \u0645\u0634\u0631\u0648\u0639\u0647.",
|
|
254
|
+
"permissions.allow": "\u0627\u0633\u0645\u062D",
|
|
255
|
+
"permissions.allowed": "\u0633\u064F\u0645\u062D \u0644\u0640{name}.",
|
|
256
|
+
"permissions.nothingToAllow": "\u0644\u0627 \u0634\u064A\u0621 \u0644\u0644\u0633\u0645\u0627\u062D \u0628\u0647 \u0628\u0639\u062F: \u0644\u0627 \u064A\u0645\u0644\u0643 \u0623\u064A \u0648\u0643\u064A\u0644 \u0641\u064A \u0645\u0634\u0627\u0631\u064A\u0639\u0643 \u0623\u062F\u0648\u0627\u062A \u062A\u0633\u0623\u0644 \u0623\u0648\u0644\u064B\u0627.",
|
|
241
257
|
"tools.groups.host": "{product}",
|
|
242
258
|
"tools.groups.plugins": "\u0627\u0644\u0625\u0636\u0627\u0641\u0627\u062A",
|
|
243
259
|
"chat.close": "\u0625\u063A\u0644\u0627\u0642",
|
|
@@ -447,18 +463,34 @@ var en_default = {
|
|
|
447
463
|
"graph.outside": "Kept after outside content",
|
|
448
464
|
"graph.hidden": "{count, plural, one {# more fact comes} other {# more facts come}} from notes you can't read.",
|
|
449
465
|
"permissions.title": "Agents you always allow",
|
|
450
|
-
"permissions.hint": "
|
|
466
|
+
"permissions.hint": "Agents that use these tools without asking you, in the runs you start in that project. Remove one and it asks you again.",
|
|
451
467
|
"permissions.agentTitle": "Always allowed by people",
|
|
452
|
-
"permissions.agentHint": "
|
|
468
|
+
"permissions.agentHint": "People who let this agent use these tools without asking them, in the runs they start in that project. Removing one makes it ask them again.",
|
|
453
469
|
"permissions.empty": "None.",
|
|
454
|
-
"permissions.
|
|
455
|
-
"permissions.
|
|
456
|
-
"permissions.
|
|
457
|
-
"permissions.
|
|
470
|
+
"permissions.agent": "Agent",
|
|
471
|
+
"permissions.person": "Person",
|
|
472
|
+
"permissions.madeBy": "Made by {name}",
|
|
473
|
+
"permissions.tools": "Tools",
|
|
474
|
+
"permissions.toolSeparator": ", ",
|
|
475
|
+
"permissions.project": "Project",
|
|
476
|
+
"permissions.since": "Since",
|
|
458
477
|
"permissions.used": "last used {at}",
|
|
459
478
|
"permissions.unused": "not used yet",
|
|
460
|
-
"permissions.
|
|
461
|
-
"permissions.
|
|
479
|
+
"permissions.remove": "Remove",
|
|
480
|
+
"permissions.removeLabel": "Remove {name} in {scope}",
|
|
481
|
+
"permissions.removeTitle": "Stop allowing {name} in {scope}?",
|
|
482
|
+
"permissions.removeHint": "It will ask you again before using these tools.",
|
|
483
|
+
"permissions.removePersonTitle": "Remove what {name} allows in {scope}?",
|
|
484
|
+
"permissions.removePersonHint": "It will ask them again before using these tools.",
|
|
485
|
+
"permissions.allowAgent": "Allow an agent",
|
|
486
|
+
"permissions.allowTitle": "Allow an agent",
|
|
487
|
+
"permissions.allowDescription": "Choose the tools it may use without asking you, in the runs you start in that project.",
|
|
488
|
+
"permissions.toolsWithoutAsking": "Tools without asking",
|
|
489
|
+
"permissions.alreadyAllowed": "{tool} (already allowed)",
|
|
490
|
+
"permissions.allowHint": "It still asks first when a run has read outside content, like a customer's message, or reached beyond its project.",
|
|
491
|
+
"permissions.allow": "Allow",
|
|
492
|
+
"permissions.allowed": "{name} is allowed.",
|
|
493
|
+
"permissions.nothingToAllow": "There's nothing to allow yet: no agent in your projects has tools that ask first.",
|
|
462
494
|
"tools.groups.host": "{product}",
|
|
463
495
|
"tools.groups.plugins": "Plugins",
|
|
464
496
|
"chat.close": "Close",
|
|
@@ -1100,60 +1132,237 @@ function AgentMemoriesPanel({ agent, onSaved }) {
|
|
|
1100
1132
|
}
|
|
1101
1133
|
|
|
1102
1134
|
// src/areas/agent/AgentPermissions.tsx
|
|
1135
|
+
import { Fragment as Fragment2, useMemo as useMemo2, useState as useState7 } from "react";
|
|
1103
1136
|
import { Stack as Stack6, Text as Text7 } from "@chakra-ui/react";
|
|
1104
|
-
import {
|
|
1105
|
-
|
|
1137
|
+
import {
|
|
1138
|
+
Button as Button5,
|
|
1139
|
+
CheckboxField,
|
|
1140
|
+
DataTable as DataTable4,
|
|
1141
|
+
errorText,
|
|
1142
|
+
FormDialog,
|
|
1143
|
+
FormField,
|
|
1144
|
+
InlineAlert as InlineAlert5,
|
|
1145
|
+
notify as notify4,
|
|
1146
|
+
Panel,
|
|
1147
|
+
SelectField as SelectField3,
|
|
1148
|
+
useAbpLocale as useAbpLocale2,
|
|
1149
|
+
useApiAction as useApiAction4,
|
|
1150
|
+
useApiQuery as useApiQuery4,
|
|
1151
|
+
useAreaRequest as useAreaRequest4,
|
|
1152
|
+
useConfirm,
|
|
1153
|
+
useFormatters as useFormatters4
|
|
1154
|
+
} from "@abpjs/ui";
|
|
1155
|
+
import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1156
|
+
function rowsOf(list, locale) {
|
|
1157
|
+
const rows = /* @__PURE__ */ new Map();
|
|
1158
|
+
for (const p of list ?? []) {
|
|
1159
|
+
const id = `${p.personId}/${p.agentId}/${p.scopeId}`;
|
|
1160
|
+
const row = rows.get(id) ?? {
|
|
1161
|
+
id,
|
|
1162
|
+
personId: p.personId,
|
|
1163
|
+
person: p.person,
|
|
1164
|
+
agentId: p.agentId,
|
|
1165
|
+
agentKey: p.agentKey,
|
|
1166
|
+
agent: p.agent,
|
|
1167
|
+
agentNames: p.agentNames,
|
|
1168
|
+
madeBy: p.madeBy,
|
|
1169
|
+
scopeId: p.scopeId,
|
|
1170
|
+
scopeKey: p.scopeKey,
|
|
1171
|
+
tools: [],
|
|
1172
|
+
since: p.createdAt,
|
|
1173
|
+
lastUsedAt: null
|
|
1174
|
+
};
|
|
1175
|
+
row.tools.push({ name: p.tool, title: p.toolTitle || p.tool });
|
|
1176
|
+
if (p.createdAt < row.since) row.since = p.createdAt;
|
|
1177
|
+
if (p.lastUsedAt && (!row.lastUsedAt || p.lastUsedAt > row.lastUsedAt)) row.lastUsedAt = p.lastUsedAt;
|
|
1178
|
+
rows.set(id, row);
|
|
1179
|
+
}
|
|
1180
|
+
for (const row of rows.values()) row.tools.sort((a, b) => a.title.localeCompare(b.title, locale));
|
|
1181
|
+
return [...rows.values()];
|
|
1182
|
+
}
|
|
1106
1183
|
function AgentPermissionsPanel({ agentId }) {
|
|
1107
1184
|
const t = useAgentTexts();
|
|
1108
1185
|
const fmt = useFormatters4();
|
|
1186
|
+
const { locale } = useAbpLocale2();
|
|
1109
1187
|
const confirm = useConfirm();
|
|
1110
1188
|
const request = useAreaRequest4("agent");
|
|
1111
1189
|
const list = useApiQuery4("agent", agentId ? `/agents/${agentId}/permissions` : "/me/permissions");
|
|
1112
|
-
|
|
1113
|
-
|
|
1190
|
+
const rows = useMemo2(() => rowsOf(list.data, locale), [list.data, locale]);
|
|
1191
|
+
const nameOf = useNameOf();
|
|
1192
|
+
const [allowing, setAllowing] = useState7(false);
|
|
1193
|
+
const title = t(agentId ? "permissions.agentTitle" : "permissions.title");
|
|
1194
|
+
const whoOf = (r) => agentId ? r.person?.displayName || "" : nameOf(r.agentNames, r.agent?.displayName || r.agentKey);
|
|
1195
|
+
async function remove(r) {
|
|
1196
|
+
const ok = await confirm({
|
|
1197
|
+
title: t(agentId ? "permissions.removePersonTitle" : "permissions.removeTitle", { name: whoOf(r), scope: r.scopeKey ?? "" }),
|
|
1198
|
+
description: t(agentId ? "permissions.removePersonHint" : "permissions.removeHint"),
|
|
1199
|
+
confirmLabel: t("permissions.remove"),
|
|
1200
|
+
danger: true
|
|
1201
|
+
});
|
|
1202
|
+
if (!ok) return;
|
|
1114
1203
|
try {
|
|
1115
|
-
await request("/permissions/remove", { method: "POST", body: { personId:
|
|
1204
|
+
await request("/permissions/remove", { method: "POST", body: { personId: r.personId, agentId: r.agentId, scopeId: r.scopeId } });
|
|
1116
1205
|
await list.reload();
|
|
1117
1206
|
} catch (e) {
|
|
1118
1207
|
notify4.error(errorText(e));
|
|
1119
1208
|
}
|
|
1120
1209
|
}
|
|
1121
|
-
return /* @__PURE__ */ jsxs6(
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1210
|
+
return /* @__PURE__ */ jsxs6(
|
|
1211
|
+
Panel,
|
|
1212
|
+
{
|
|
1213
|
+
title,
|
|
1214
|
+
description: t(agentId ? "permissions.agentHint" : "permissions.hint"),
|
|
1215
|
+
actions: agentId ? void 0 : /* @__PURE__ */ jsx7(Button5, { size: "sm", onClick: () => setAllowing(true), children: t("permissions.allowAgent") }),
|
|
1216
|
+
flush: true,
|
|
1217
|
+
"data-testid": "agent-permissions",
|
|
1218
|
+
children: [
|
|
1219
|
+
/* @__PURE__ */ jsx7(InlineAlert5, { tone: "danger", children: list.error }),
|
|
1220
|
+
/* @__PURE__ */ jsx7(
|
|
1221
|
+
DataTable4,
|
|
1132
1222
|
{
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
"
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1223
|
+
"aria-label": title,
|
|
1224
|
+
rows,
|
|
1225
|
+
loading: list.loading,
|
|
1226
|
+
getRowId: (r) => r.id,
|
|
1227
|
+
empty: t("permissions.empty"),
|
|
1228
|
+
columns: [
|
|
1229
|
+
{
|
|
1230
|
+
id: "who",
|
|
1231
|
+
header: t(agentId ? "permissions.person" : "permissions.agent"),
|
|
1232
|
+
cell: (r) => /* @__PURE__ */ jsxs6(Stack6, { gap: "0.5", children: [
|
|
1233
|
+
/* @__PURE__ */ jsx7(Text7, { fontWeight: "medium", children: whoOf(r) }),
|
|
1234
|
+
!agentId && r.madeBy && /* @__PURE__ */ jsx7(Text7, { textStyle: "caption", color: "fg.muted", children: t("permissions.madeBy", { name: r.madeBy.displayName }) })
|
|
1235
|
+
] })
|
|
1236
|
+
},
|
|
1237
|
+
{
|
|
1238
|
+
id: "tools",
|
|
1239
|
+
header: t("permissions.tools"),
|
|
1240
|
+
// Each title kept apart from the text around it: a host's titles may be in another script than the page's.
|
|
1241
|
+
cell: (r) => /* @__PURE__ */ jsx7(Text7, { children: r.tools.map((x, i) => /* @__PURE__ */ jsxs6(Fragment2, { children: [
|
|
1242
|
+
i > 0 && t("permissions.toolSeparator"),
|
|
1243
|
+
/* @__PURE__ */ jsx7(Text7, { as: "span", unicodeBidi: "isolate", children: x.title })
|
|
1244
|
+
] }, x.name)) })
|
|
1245
|
+
},
|
|
1246
|
+
{ id: "scope", header: t("permissions.project"), cell: (r) => /* @__PURE__ */ jsx7(Text7, { dir: "ltr", children: r.scopeKey ?? "" }) },
|
|
1247
|
+
{
|
|
1248
|
+
id: "since",
|
|
1249
|
+
header: t("permissions.since"),
|
|
1250
|
+
cell: (r) => /* @__PURE__ */ jsxs6(Stack6, { gap: "0.5", children: [
|
|
1251
|
+
/* @__PURE__ */ jsx7(Text7, { children: fmt.dateTime(r.since, { dateStyle: "medium" }) }),
|
|
1252
|
+
/* @__PURE__ */ jsx7(Text7, { textStyle: "caption", color: "fg.muted", children: r.lastUsedAt ? t("permissions.used", { at: fmt.dateTime(r.lastUsedAt, { dateStyle: "medium" }) }) : t("permissions.unused") })
|
|
1253
|
+
] })
|
|
1254
|
+
},
|
|
1255
|
+
{
|
|
1256
|
+
id: "actions",
|
|
1257
|
+
header: "",
|
|
1258
|
+
cell: (r) => /* @__PURE__ */ jsx7(Button5, { size: "sm", variant: "ghost", "aria-label": t("permissions.removeLabel", { name: whoOf(r), scope: r.scopeKey ?? "" }), onClick: () => void remove(r), children: t("permissions.remove") })
|
|
1259
|
+
}
|
|
1260
|
+
]
|
|
1261
|
+
}
|
|
1262
|
+
),
|
|
1263
|
+
allowing && /* @__PURE__ */ jsx7(AllowAgentDialog, { onClose: () => setAllowing(false), onSaved: list.reload })
|
|
1264
|
+
]
|
|
1265
|
+
}
|
|
1266
|
+
);
|
|
1267
|
+
}
|
|
1268
|
+
function AllowAgentDialog({ onClose, onSaved }) {
|
|
1269
|
+
const t = useAgentTexts();
|
|
1270
|
+
const nameOf = useNameOf();
|
|
1271
|
+
const request = useAreaRequest4("agent");
|
|
1272
|
+
const action = useApiAction4();
|
|
1273
|
+
const places = useApiQuery4("agent", "/me/permissions/allowable");
|
|
1274
|
+
const agents = useMemo2(() => {
|
|
1275
|
+
const seen = /* @__PURE__ */ new Map();
|
|
1276
|
+
for (const p of places.data ?? []) {
|
|
1277
|
+
for (const a of p.agents) {
|
|
1278
|
+
if (!seen.has(a.agent.id)) seen.set(a.agent.id, { id: a.agent.id, label: nameOf(a.agent.names, a.agent.account?.displayName || a.agent.key) });
|
|
1148
1279
|
}
|
|
1149
|
-
|
|
1150
|
-
|
|
1280
|
+
}
|
|
1281
|
+
return [...seen.values()];
|
|
1282
|
+
}, [places.data, nameOf]);
|
|
1283
|
+
const [agentPick, setAgentPick] = useState7(null);
|
|
1284
|
+
const [scopePick, setScopePick] = useState7(null);
|
|
1285
|
+
const [picked, setPicked] = useState7([]);
|
|
1286
|
+
const agentId = agentPick ?? agents[0]?.id ?? null;
|
|
1287
|
+
const scopes = (places.data ?? []).filter((p) => p.agents.some((a) => a.agent.id === agentId));
|
|
1288
|
+
const scopeId = scopePick && scopes.some((p) => p.scope.id === scopePick) ? scopePick : scopes[0]?.scope.id ?? null;
|
|
1289
|
+
const tools = scopes.find((p) => p.scope.id === scopeId)?.agents.find((a) => a.agent.id === agentId)?.tools ?? [];
|
|
1290
|
+
const chosen = picked.filter((name) => tools.some((x) => x.name === name && !x.given));
|
|
1291
|
+
const label = agents.find((a) => a.id === agentId)?.label ?? "";
|
|
1292
|
+
async function save() {
|
|
1293
|
+
if (!agentId || !scopeId || chosen.length === 0) return;
|
|
1294
|
+
const done = await action.run(async () => {
|
|
1295
|
+
await request("/me/permissions", { method: "POST", body: { agentId, scopeId, tools: chosen } });
|
|
1296
|
+
return true;
|
|
1297
|
+
});
|
|
1298
|
+
if (done) {
|
|
1299
|
+
notify4.success(t("permissions.allowed", { name: label }));
|
|
1300
|
+
await onSaved();
|
|
1301
|
+
onClose();
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
const none = !places.loading && !places.error && agents.length === 0;
|
|
1305
|
+
return /* @__PURE__ */ jsx7(
|
|
1306
|
+
FormDialog,
|
|
1307
|
+
{
|
|
1308
|
+
open: true,
|
|
1309
|
+
onOpenChange: (open) => !open && onClose(),
|
|
1310
|
+
title: t("permissions.allowTitle"),
|
|
1311
|
+
description: t("permissions.allowDescription"),
|
|
1312
|
+
submitLabel: t("permissions.allow"),
|
|
1313
|
+
onSubmit: save,
|
|
1314
|
+
busy: action.busy,
|
|
1315
|
+
error: action.error ?? places.error,
|
|
1316
|
+
submitDisabled: chosen.length === 0,
|
|
1317
|
+
children: none ? /* @__PURE__ */ jsx7(Text7, { textStyle: "sm", color: "fg.muted", children: t("permissions.nothingToAllow") }) : /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
1318
|
+
/* @__PURE__ */ jsx7(FormField, { label: t("permissions.agent"), loading: places.loading, children: /* @__PURE__ */ jsx7(
|
|
1319
|
+
SelectField3,
|
|
1320
|
+
{
|
|
1321
|
+
value: agentId ?? "",
|
|
1322
|
+
options: agents.map((a) => ({ value: a.id, label: a.label })),
|
|
1323
|
+
loading: places.loading,
|
|
1324
|
+
onChange: (e) => {
|
|
1325
|
+
setAgentPick(e.target.value);
|
|
1326
|
+
setScopePick(null);
|
|
1327
|
+
setPicked([]);
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
) }),
|
|
1331
|
+
/* @__PURE__ */ jsx7(FormField, { label: t("permissions.project"), loading: places.loading, children: /* @__PURE__ */ jsx7(
|
|
1332
|
+
SelectField3,
|
|
1333
|
+
{
|
|
1334
|
+
value: scopeId ?? "",
|
|
1335
|
+
options: scopes.map((p) => ({ value: p.scope.id, label: p.scope.key })),
|
|
1336
|
+
loading: places.loading,
|
|
1337
|
+
onChange: (e) => {
|
|
1338
|
+
setScopePick(e.target.value);
|
|
1339
|
+
setPicked([]);
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
) }),
|
|
1343
|
+
/* @__PURE__ */ jsxs6(Stack6, { gap: "1.5", role: "group", "aria-labelledby": "agent-allow-tools", children: [
|
|
1344
|
+
/* @__PURE__ */ jsx7(Text7, { id: "agent-allow-tools", textStyle: "sm", fontWeight: "medium", children: t("permissions.toolsWithoutAsking") }),
|
|
1345
|
+
tools.map((x) => /* @__PURE__ */ jsx7(
|
|
1346
|
+
CheckboxField,
|
|
1347
|
+
{
|
|
1348
|
+
label: x.given ? t("permissions.alreadyAllowed", { tool: x.title }) : x.title,
|
|
1349
|
+
checked: x.given || picked.includes(x.name),
|
|
1350
|
+
disabled: x.given,
|
|
1351
|
+
onCheckedChange: (c) => setPicked(c ? [...picked, x.name] : picked.filter((n) => n !== x.name))
|
|
1352
|
+
},
|
|
1353
|
+
x.name
|
|
1354
|
+
)),
|
|
1355
|
+
/* @__PURE__ */ jsx7(Text7, { textStyle: "caption", color: "fg.muted", children: t("permissions.allowHint") })
|
|
1356
|
+
] })
|
|
1357
|
+
] })
|
|
1358
|
+
}
|
|
1359
|
+
);
|
|
1151
1360
|
}
|
|
1152
1361
|
|
|
1153
1362
|
// src/areas/agent/AgentTools.tsx
|
|
1154
|
-
import { useState as
|
|
1363
|
+
import { useState as useState8 } from "react";
|
|
1155
1364
|
import { Stack as Stack7, Text as Text8 } from "@chakra-ui/react";
|
|
1156
|
-
import { Button as Button6, DataTable as DataTable5, HostSlot as HostSlot3, InlineAlert as InlineAlert6, notify as notify5, SelectField as
|
|
1365
|
+
import { Button as Button6, DataTable as DataTable5, HostSlot as HostSlot3, InlineAlert as InlineAlert6, notify as notify5, SelectField as SelectField4, StatusPill as StatusPill4, useApiAction as useApiAction5, useApiQuery as useApiQuery5, useAreaRequest as useAreaRequest5 } from "@abpjs/ui";
|
|
1157
1366
|
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1158
1367
|
var isSandbox = (x) => x.name.startsWith("sandbox_");
|
|
1159
1368
|
function optionsOf(x, t) {
|
|
@@ -1171,8 +1380,8 @@ function AgentToolsPanel({ agent, onSaved, version = 0 }) {
|
|
|
1171
1380
|
const t = useAgentTexts();
|
|
1172
1381
|
const request = useAreaRequest5("agent");
|
|
1173
1382
|
const tools = useApiQuery5("agent", `/agents/${agent.id}/tools?v=${version}`);
|
|
1174
|
-
const action =
|
|
1175
|
-
const [settings, setSettings] =
|
|
1383
|
+
const action = useApiAction5();
|
|
1384
|
+
const [settings, setSettings] = useState8(agent.tools ?? {});
|
|
1176
1385
|
const changed = JSON.stringify(settings) !== JSON.stringify(agent.tools ?? {});
|
|
1177
1386
|
const groupOf = useToolGroupOf();
|
|
1178
1387
|
const rows = tools.data ?? [];
|
|
@@ -1230,7 +1439,7 @@ function AgentToolsPanel({ agent, onSaved, version = 0 }) {
|
|
|
1230
1439
|
{
|
|
1231
1440
|
id: "setting",
|
|
1232
1441
|
header: t("tools.setting"),
|
|
1233
|
-
cell: (x) => /* @__PURE__ */ jsx8(
|
|
1442
|
+
cell: (x) => /* @__PURE__ */ jsx8(SelectField4, { size: "sm", value: settings[x.name] ?? "", "aria-label": t("tools.setting"), onChange: (e) => set(x.name, e.target.value), options: optionsOf(x, t) })
|
|
1234
1443
|
}
|
|
1235
1444
|
]
|
|
1236
1445
|
}
|
|
@@ -1247,7 +1456,7 @@ import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
|
1247
1456
|
function AgentEditor({ agent, onSaved, permissions = true, variant = "site" }) {
|
|
1248
1457
|
const t = useAgentTexts();
|
|
1249
1458
|
const nameOf = useNameOf();
|
|
1250
|
-
const [toolsVersion, setToolsVersion] =
|
|
1459
|
+
const [toolsVersion, setToolsVersion] = useState9(0);
|
|
1251
1460
|
return /* @__PURE__ */ jsxs8(Stack8, { gap: "section", children: [
|
|
1252
1461
|
/* @__PURE__ */ jsx9(Panel2, { title: t("editTitle", { name: nameOf(agent.names, agent.key) }), actions: /* @__PURE__ */ jsx9(AgentPause, { agent, onChanged: onSaved }), "data-testid": "agent-edit", children: /* @__PURE__ */ jsxs8(Stack8, { gap: variant === "scope" ? "section" : "stack", children: [
|
|
1253
1462
|
variant === "site" && /* @__PURE__ */ jsx9(
|
|
@@ -1290,9 +1499,9 @@ function AgentsAdmin({ itemHref }) {
|
|
|
1290
1499
|
const request = useAreaRequest6("agent");
|
|
1291
1500
|
const settings = useApiQuery6("agent", "/settings");
|
|
1292
1501
|
const agents = useApiQuery6("agent", "/agents");
|
|
1293
|
-
const [selected, setSelected] =
|
|
1294
|
-
const [creating, setCreating] =
|
|
1295
|
-
const toggle =
|
|
1502
|
+
const [selected, setSelected] = useState10(null);
|
|
1503
|
+
const [creating, setCreating] = useState10(false);
|
|
1504
|
+
const toggle = useApiAction6();
|
|
1296
1505
|
const slots = useSlotSaves2();
|
|
1297
1506
|
async function turn(enabled) {
|
|
1298
1507
|
const s2 = await toggle.run(async () => {
|
|
@@ -1373,9 +1582,9 @@ function agentPages(options) {
|
|
|
1373
1582
|
}
|
|
1374
1583
|
|
|
1375
1584
|
// src/areas/agent/ScopeAgents.tsx
|
|
1376
|
-
import { useState as
|
|
1585
|
+
import { useState as useState11 } from "react";
|
|
1377
1586
|
import { HStack as HStack6, Stack as Stack11, Text as Text11 } from "@chakra-ui/react";
|
|
1378
|
-
import { Button as Button8, InlineAlert as InlineAlert8, notify as notify6, Panel as Panel4, SelectField as
|
|
1587
|
+
import { Button as Button8, InlineAlert as InlineAlert8, notify as notify6, Panel as Panel4, SelectField as SelectField5, useApiAction as useApiAction7, useApiQuery as useApiQuery7, useAreaRequest as useAreaRequest7 } from "@abpjs/ui";
|
|
1379
1588
|
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1380
1589
|
function ScopeAgentsScreen({ scope, roles, header, itemHref, subtitle }) {
|
|
1381
1590
|
const t = useAgentTexts();
|
|
@@ -1383,10 +1592,10 @@ function ScopeAgentsScreen({ scope, roles, header, itemHref, subtitle }) {
|
|
|
1383
1592
|
const request = useAreaRequest7("agent");
|
|
1384
1593
|
const base = `/scopes/${encodeURIComponent(scope)}/agents`;
|
|
1385
1594
|
const agents = useApiQuery7("agent", base);
|
|
1386
|
-
const [selected, setSelected] =
|
|
1387
|
-
const [creating, setCreating] =
|
|
1388
|
-
const [roleFor, setRoleFor] =
|
|
1389
|
-
const action =
|
|
1595
|
+
const [selected, setSelected] = useState11(null);
|
|
1596
|
+
const [creating, setCreating] = useState11(false);
|
|
1597
|
+
const [roleFor, setRoleFor] = useState11({});
|
|
1598
|
+
const action = useApiAction7();
|
|
1390
1599
|
const byId = new Map((agents.data ?? []).map((a) => [a.agent.id, a]));
|
|
1391
1600
|
async function take(agent, on) {
|
|
1392
1601
|
const name = nameOf(agent.names, agent.key);
|
|
@@ -1444,7 +1653,7 @@ function ScopeAgentsScreen({ scope, roles, header, itemHref, subtitle }) {
|
|
|
1444
1653
|
/* @__PURE__ */ jsx12(Button8, { size: "xs", variant: "ghost", disabled: action.busy, onClick: () => void take(a, false), children: t("takeOff") })
|
|
1445
1654
|
] }) : /* @__PURE__ */ jsxs11(HStack6, { gap: "2", onClick: (e) => e.stopPropagation(), children: [
|
|
1446
1655
|
/* @__PURE__ */ jsx12(
|
|
1447
|
-
|
|
1656
|
+
SelectField5,
|
|
1448
1657
|
{
|
|
1449
1658
|
size: "xs",
|
|
1450
1659
|
width: "auto",
|
|
@@ -1470,10 +1679,10 @@ function ScopeAgentsScreen({ scope, roles, header, itemHref, subtitle }) {
|
|
|
1470
1679
|
}
|
|
1471
1680
|
|
|
1472
1681
|
// src/areas/agent/AgentRuns.tsx
|
|
1473
|
-
import { useEffect as useEffect2, useState as
|
|
1682
|
+
import { useEffect as useEffect2, useState as useState12 } from "react";
|
|
1474
1683
|
import { Box as Box2, HStack as HStack7, Stack as Stack12, Text as Text12 } from "@chakra-ui/react";
|
|
1475
1684
|
import { Bot, ChevronDown, ChevronRight, Square } from "lucide-react";
|
|
1476
|
-
import { Button as Button9, DirectionalIcon, HostSlot as HostSlot6, Panel as Panel5, StatusPill as StatusPill5, useApiAction as
|
|
1685
|
+
import { Button as Button9, DirectionalIcon, HostSlot as HostSlot6, Panel as Panel5, StatusPill as StatusPill5, useApiAction as useApiAction8, useApiQuery as useApiQuery8, useAreaRequest as useAreaRequest8, useFormatters as useFormatters5, useOptionalHost as useOptionalHost2 } from "@abpjs/ui";
|
|
1477
1686
|
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1478
1687
|
function AgentText({ source, testId }) {
|
|
1479
1688
|
const drawn = Boolean(useOptionalHost2()?.slots?.["agent.markdown"]);
|
|
@@ -1484,7 +1693,7 @@ function AgentQuestionCard({ question, onAnswered }) {
|
|
|
1484
1693
|
const t = useAgentTexts();
|
|
1485
1694
|
const fmt = useFormatters5();
|
|
1486
1695
|
const request = useAreaRequest8("agent");
|
|
1487
|
-
const action =
|
|
1696
|
+
const action = useApiAction8();
|
|
1488
1697
|
const answers = ["allow", "allow-run", ...question.canAlways ? ["always"] : [], "refuse"];
|
|
1489
1698
|
async function answer(a) {
|
|
1490
1699
|
if (await action.run(() => request(`/questions/${question.id}/answer`, { method: "POST", body: { answer: a } }))) await onAnswered();
|
|
@@ -1516,8 +1725,8 @@ function RunRow({ run, onChanged }) {
|
|
|
1516
1725
|
const t = useAgentTexts();
|
|
1517
1726
|
const fmt = useFormatters5();
|
|
1518
1727
|
const request = useAreaRequest8("agent");
|
|
1519
|
-
const action =
|
|
1520
|
-
const [open, setOpen] =
|
|
1728
|
+
const action = useApiAction8();
|
|
1729
|
+
const [open, setOpen] = useState12(false);
|
|
1521
1730
|
const going = GOING.has(run.state);
|
|
1522
1731
|
const tools = run.steps.filter((s) => s.kind === "tool");
|
|
1523
1732
|
async function stop() {
|
|
@@ -1580,7 +1789,7 @@ function ItemAgentRuns({ kind, itemKey, version = 0, onChanged, title, descripti
|
|
|
1580
1789
|
const timer = setInterval(() => void reload(), 2e3);
|
|
1581
1790
|
return () => clearInterval(timer);
|
|
1582
1791
|
}, [going, reload]);
|
|
1583
|
-
const [wasGoing, setWasGoing] =
|
|
1792
|
+
const [wasGoing, setWasGoing] = useState12(false);
|
|
1584
1793
|
useEffect2(() => {
|
|
1585
1794
|
if (wasGoing && !going) onChanged?.();
|
|
1586
1795
|
setWasGoing(going);
|
|
@@ -1593,7 +1802,7 @@ function ItemAgentRuns({ kind, itemKey, version = 0, onChanged, title, descripti
|
|
|
1593
1802
|
}
|
|
1594
1803
|
|
|
1595
1804
|
// src/areas/agent/AgentChat.tsx
|
|
1596
|
-
import { createContext as createContext2, useCallback as useCallback2, useContext as useContext2, useEffect as useEffect3, useMemo as
|
|
1805
|
+
import { createContext as createContext2, useCallback as useCallback2, useContext as useContext2, useEffect as useEffect3, useMemo as useMemo3, useRef, useState as useState13 } from "react";
|
|
1597
1806
|
import { Box as Box3, chakra as chakra4, CloseButton, Drawer, HStack as HStack8, Portal, Stack as Stack13, Text as Text13, Textarea as Textarea2 } from "@chakra-ui/react";
|
|
1598
1807
|
import { ArrowLeft, Bot as Bot2, Check, ChevronDown as ChevronDown2, ChevronRight as ChevronRight2, Send, Square as Square2, Trash2 } from "lucide-react";
|
|
1599
1808
|
import {
|
|
@@ -1605,9 +1814,9 @@ import {
|
|
|
1605
1814
|
IconButton,
|
|
1606
1815
|
InlineAlert as InlineAlert9,
|
|
1607
1816
|
notify as notify7,
|
|
1608
|
-
SelectField as
|
|
1817
|
+
SelectField as SelectField6,
|
|
1609
1818
|
StatusPill as StatusPill6,
|
|
1610
|
-
useApiAction as
|
|
1819
|
+
useApiAction as useApiAction9,
|
|
1611
1820
|
useApiQuery as useApiQuery9,
|
|
1612
1821
|
useAreaEvents,
|
|
1613
1822
|
useAreaRequest as useAreaRequest9,
|
|
@@ -1615,17 +1824,17 @@ import {
|
|
|
1615
1824
|
useFormatters as useFormatters6,
|
|
1616
1825
|
useNames
|
|
1617
1826
|
} from "@abpjs/ui";
|
|
1618
|
-
import { Fragment as
|
|
1827
|
+
import { Fragment as Fragment4, jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1619
1828
|
var ChatContext = createContext2(null);
|
|
1620
1829
|
function AgentChatProvider({ children, onItemChanged }) {
|
|
1621
|
-
const [open, setOpen] =
|
|
1622
|
-
const [view, setView] =
|
|
1830
|
+
const [open, setOpen] = useState13(false);
|
|
1831
|
+
const [view, setView] = useState13({ kind: "list" });
|
|
1623
1832
|
const show = useCallback2((target = {}) => {
|
|
1624
1833
|
setView(target.chat ? { kind: "chat", id: target.chat, opened: true } : target.item || target.scope || target.agent || target.prompt ? { kind: "new", target } : { kind: "list" });
|
|
1625
1834
|
setOpen(true);
|
|
1626
1835
|
}, []);
|
|
1627
1836
|
const close = useCallback2(() => setOpen(false), []);
|
|
1628
|
-
const value =
|
|
1837
|
+
const value = useMemo3(() => ({ open, view, show, setView, close, onItemChanged }), [open, view, show, close, onItemChanged]);
|
|
1629
1838
|
return /* @__PURE__ */ jsx14(ChatContext.Provider, { value, children });
|
|
1630
1839
|
}
|
|
1631
1840
|
function useAgentChat() {
|
|
@@ -1638,7 +1847,7 @@ var EMPTY_STREAMS = 3;
|
|
|
1638
1847
|
var NO_LIVE = { run: null, texts: {}, steps: [] };
|
|
1639
1848
|
function useLiveRun(chatId, going, reload) {
|
|
1640
1849
|
const events = useAreaEvents("agent");
|
|
1641
|
-
const [live, setLive] =
|
|
1850
|
+
const [live, setLive] = useState13(NO_LIVE);
|
|
1642
1851
|
useEffect3(() => {
|
|
1643
1852
|
if (!going) return;
|
|
1644
1853
|
const abort = new AbortController();
|
|
@@ -1741,14 +1950,14 @@ function AgentChatPanel({ itemHref }) {
|
|
|
1741
1950
|
function Where({ chat }) {
|
|
1742
1951
|
const t = useAgentTexts();
|
|
1743
1952
|
const names = useNames("scopes", chat.itemKey ? [] : [chat.scopeId]);
|
|
1744
|
-
if (chat.itemKey) return /* @__PURE__ */ jsx14(
|
|
1745
|
-
return /* @__PURE__ */ jsx14(
|
|
1953
|
+
if (chat.itemKey) return /* @__PURE__ */ jsx14(Fragment4, { children: t("chat.about", { key: chat.itemKey }) });
|
|
1954
|
+
return /* @__PURE__ */ jsx14(Fragment4, { children: t("chat.in", { place: names[chat.scopeId] ?? chat.scopeKey ?? "" }) });
|
|
1746
1955
|
}
|
|
1747
1956
|
function ChatList({ onOpen, onNew }) {
|
|
1748
1957
|
const t = useAgentTexts();
|
|
1749
1958
|
const fmt = useFormatters6();
|
|
1750
1959
|
const chats = useApiQuery9("agent", "/chats");
|
|
1751
|
-
return /* @__PURE__ */ jsxs13(
|
|
1960
|
+
return /* @__PURE__ */ jsxs13(Fragment4, { children: [
|
|
1752
1961
|
/* @__PURE__ */ jsx14(Drawer.Header, { pe: "12", children: /* @__PURE__ */ jsxs13(Stack13, { gap: "0.5", children: [
|
|
1753
1962
|
/* @__PURE__ */ jsx14(Drawer.Title, { children: t("chat.title") }),
|
|
1754
1963
|
/* @__PURE__ */ jsx14(Text13, { textStyle: "caption", color: "fg.muted", children: t("chat.private") })
|
|
@@ -1791,14 +2000,14 @@ function NewChat({ target, onBack, onStarted }) {
|
|
|
1791
2000
|
const t = useAgentTexts();
|
|
1792
2001
|
const nameOf = useNameOf();
|
|
1793
2002
|
const request = useAreaRequest9("agent");
|
|
1794
|
-
const action =
|
|
2003
|
+
const action = useApiAction9();
|
|
1795
2004
|
const item = target.item ?? null;
|
|
1796
2005
|
const places = useApiQuery9("agent", item ? null : "/chats/places");
|
|
1797
2006
|
const askable = useApiQuery9("agent", item ? `${itemPath(item.kind, item.key)}/agents` : null);
|
|
1798
2007
|
const scopeNames = useNames("scopes", (places.data ?? []).map((p) => p.scope.id));
|
|
1799
|
-
const [place, setPlace] =
|
|
1800
|
-
const [agentId, setAgentId] =
|
|
1801
|
-
const [prompt, setPrompt] =
|
|
2008
|
+
const [place, setPlace] = useState13(target.scope ?? "");
|
|
2009
|
+
const [agentId, setAgentId] = useState13("");
|
|
2010
|
+
const [prompt, setPrompt] = useState13(target.prompt ?? "");
|
|
1802
2011
|
const placeKey = places.data?.some((p) => p.scope.key === place) ? place : places.data?.[0]?.scope.key;
|
|
1803
2012
|
const agents = item ? askable.data : places.data?.find((p) => p.scope.key === placeKey)?.agents;
|
|
1804
2013
|
const chosen = agents?.find((a) => a.id === agentId)?.id ?? agents?.find((a) => a.id === target.agent || a.key === target.agent)?.id ?? agents?.[0]?.id;
|
|
@@ -1809,7 +2018,7 @@ function NewChat({ target, onBack, onStarted }) {
|
|
|
1809
2018
|
const chat = await action.run(() => request("/chats", { method: "POST", body: { agentId: chosen, prompt, ...item ? { kind: item.kind, key: item.key } : { scope: placeKey } } }));
|
|
1810
2019
|
if (chat) onStarted(chat.chat.id);
|
|
1811
2020
|
}
|
|
1812
|
-
return /* @__PURE__ */ jsxs13(
|
|
2021
|
+
return /* @__PURE__ */ jsxs13(Fragment4, { children: [
|
|
1813
2022
|
/* @__PURE__ */ jsx14(Drawer.Header, { pe: "12", children: /* @__PURE__ */ jsxs13(HStack8, { gap: "1.5", align: "start", children: [
|
|
1814
2023
|
/* @__PURE__ */ jsx14(BackButton, { onBack }),
|
|
1815
2024
|
/* @__PURE__ */ jsxs13(Stack13, { gap: "0.5", children: [
|
|
@@ -1818,9 +2027,9 @@ function NewChat({ target, onBack, onStarted }) {
|
|
|
1818
2027
|
] })
|
|
1819
2028
|
] }) }),
|
|
1820
2029
|
/* @__PURE__ */ jsx14(Drawer.Body, { children: /* @__PURE__ */ jsxs13(Stack13, { gap: "4", children: [
|
|
1821
|
-
loaded && !agents?.length ? /* @__PURE__ */ jsx14(EmptyState, { size: "sm", title: item ? t("chat.noAgentsHere", { key: item.key }) : t("chat.noPlaces") }) : /* @__PURE__ */ jsxs13(
|
|
2030
|
+
loaded && !agents?.length ? /* @__PURE__ */ jsx14(EmptyState, { size: "sm", title: item ? t("chat.noAgentsHere", { key: item.key }) : t("chat.noPlaces") }) : /* @__PURE__ */ jsxs13(Fragment4, { children: [
|
|
1822
2031
|
!item && places.data && places.data.length > 1 && /* @__PURE__ */ jsx14(Field3, { label: t("chat.place"), children: /* @__PURE__ */ jsx14(
|
|
1823
|
-
|
|
2032
|
+
SelectField6,
|
|
1824
2033
|
{
|
|
1825
2034
|
value: placeKey ?? "",
|
|
1826
2035
|
onChange: (e) => {
|
|
@@ -1831,7 +2040,7 @@ function NewChat({ target, onBack, onStarted }) {
|
|
|
1831
2040
|
options: places.data.map((p) => ({ value: p.scope.key, label: scopeNames[p.scope.id] ? `${scopeNames[p.scope.id]} (${p.scope.key})` : p.scope.key }))
|
|
1832
2041
|
}
|
|
1833
2042
|
) }),
|
|
1834
|
-
agents && agents.length > 0 && /* @__PURE__ */ jsx14(Field3, { label: t("chat.agent"), children: /* @__PURE__ */ jsx14(
|
|
2043
|
+
agents && agents.length > 0 && /* @__PURE__ */ jsx14(Field3, { label: t("chat.agent"), children: /* @__PURE__ */ jsx14(SelectField6, { value: chosen ?? "", onChange: (e) => setAgentId(e.target.value), "data-testid": "agent-chat-agent", options: agents.map((a) => ({ value: a.id, label: agentName(a) })) }) })
|
|
1835
2044
|
] }),
|
|
1836
2045
|
action.error && /* @__PURE__ */ jsx14(InlineAlert9, { tone: "danger", children: action.error })
|
|
1837
2046
|
] }) }),
|
|
@@ -1844,8 +2053,8 @@ function ChatView({ id, onBack, onMissing }) {
|
|
|
1844
2053
|
const request = useAreaRequest9("agent");
|
|
1845
2054
|
const state = useContext2(ChatContext);
|
|
1846
2055
|
const chat = useApiQuery9("agent", `/chats/${id}`);
|
|
1847
|
-
const send =
|
|
1848
|
-
const [prompt, setPrompt] =
|
|
2056
|
+
const send = useApiAction9();
|
|
2057
|
+
const [prompt, setPrompt] = useState13("");
|
|
1849
2058
|
const end = useRef(null);
|
|
1850
2059
|
const { reload, setData } = chat;
|
|
1851
2060
|
const c = chat.data;
|
|
@@ -1883,7 +2092,7 @@ function ChatView({ id, onBack, onMissing }) {
|
|
|
1883
2092
|
onBack();
|
|
1884
2093
|
}
|
|
1885
2094
|
}
|
|
1886
|
-
return /* @__PURE__ */ jsxs13(
|
|
2095
|
+
return /* @__PURE__ */ jsxs13(Fragment4, { children: [
|
|
1887
2096
|
/* @__PURE__ */ jsx14(Drawer.Header, { pe: "12", children: /* @__PURE__ */ jsxs13(HStack8, { gap: "1.5", align: "start", w: "full", children: [
|
|
1888
2097
|
/* @__PURE__ */ jsx14(BackButton, { onBack }),
|
|
1889
2098
|
/* @__PURE__ */ jsxs13(Stack13, { gap: "0.5", flex: "1", minW: "0", children: [
|
|
@@ -1938,8 +2147,8 @@ function Turn({ run, chat, onChat, onChanged, live }) {
|
|
|
1938
2147
|
const fmt = useFormatters6();
|
|
1939
2148
|
const request = useAreaRequest9("agent");
|
|
1940
2149
|
const state = useContext2(ChatContext);
|
|
1941
|
-
const action =
|
|
1942
|
-
const [open, setOpen] =
|
|
2150
|
+
const action = useApiAction9();
|
|
2151
|
+
const [open, setOpen] = useState13(false);
|
|
1943
2152
|
const going = GOING.has(run.state);
|
|
1944
2153
|
const tools = live && live.steps.length > 0 ? live.steps.map((s) => ({ name: s.tool, target: s.target, outcome: s.outcome ?? "started", number: s.step })) : run.steps.filter((s) => s.kind === "tool");
|
|
1945
2154
|
const writing = live ? Object.entries(live.texts).sort(([a], [b]) => Number(b) - Number(a)).find(([, text]) => text.length > 0)?.[1] : void 0;
|
|
@@ -2047,8 +2256,8 @@ function Composer({ value, onChange, onSend, busy, disabled, label, hint, autoFo
|
|
|
2047
2256
|
|
|
2048
2257
|
// src/areas/agent/AgentPickers.tsx
|
|
2049
2258
|
import { Box as Box4, Input as Input4, Stack as Stack14, Text as Text14 } from "@chakra-ui/react";
|
|
2050
|
-
import { EmptyState as EmptyState2, Panel as Panel6, SelectField as
|
|
2051
|
-
import { Fragment as
|
|
2259
|
+
import { EmptyState as EmptyState2, Panel as Panel6, SelectField as SelectField7, StatusPill as StatusPill7, useApiQuery as useApiQuery10 } from "@abpjs/ui";
|
|
2260
|
+
import { Fragment as Fragment5, jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2052
2261
|
function AgentSelect({ scope, value, onChange, disabled, anyLabel }) {
|
|
2053
2262
|
const t = useAgentTexts();
|
|
2054
2263
|
const nameOf = useNameOf();
|
|
@@ -2063,7 +2272,7 @@ function AgentSelect({ scope, value, onChange, disabled, anyLabel }) {
|
|
|
2063
2272
|
if (value && !taken.some((a) => a.key === value)) options.push({ value, label: t("select.notHere", { key: value }) });
|
|
2064
2273
|
return /* @__PURE__ */ jsxs14(Stack14, { gap: "1", children: [
|
|
2065
2274
|
/* @__PURE__ */ jsx15(
|
|
2066
|
-
|
|
2275
|
+
SelectField7,
|
|
2067
2276
|
{
|
|
2068
2277
|
size: "sm",
|
|
2069
2278
|
disabled,
|
|
@@ -2088,7 +2297,7 @@ function AgentQuestionsPanel({ itemHref }) {
|
|
|
2088
2297
|
return /* @__PURE__ */ jsx15(ItemHrefProvider, { value: itemHref, children: /* @__PURE__ */ jsx15(Panel6, { title: t("mine.title"), description: t("mine.hint"), "data-testid": "agent-questions", children: questions.data?.length === 0 ? /* @__PURE__ */ jsx15(EmptyState2, { size: "sm", art: "agent", title: t("mine.none") }) : /* @__PURE__ */ jsx15(Stack14, { gap: "4", as: "ul", listStyleType: "none", children: (questions.data ?? []).map((q) => /* @__PURE__ */ jsx15(Box4, { as: "li", children: /* @__PURE__ */ jsxs14(Stack14, { gap: "1.5", children: [
|
|
2089
2298
|
/* @__PURE__ */ jsxs14(Text14, { textStyle: "sm", fontWeight: "medium", children: [
|
|
2090
2299
|
q.agent?.displayName ?? q.agentKey,
|
|
2091
|
-
q.itemKey && /* @__PURE__ */ jsxs14(
|
|
2300
|
+
q.itemKey && /* @__PURE__ */ jsxs14(Fragment5, { children: [
|
|
2092
2301
|
" \xB7 ",
|
|
2093
2302
|
/* @__PURE__ */ jsx15(ItemLink, { kind: q.itemKind, itemKey: q.itemKey })
|
|
2094
2303
|
] })
|