@abpjs/ui 0.2.0-next.39 → 0.2.0-next.40

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/agent.js CHANGED
@@ -200,6 +200,17 @@ var ar_default = {
200
200
  "chat.deleteTitle": "\u062D\u0630\u0641 \u0647\u0630\u0647 \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629\u061F",
201
201
  "chat.deleteBody": "\u062A\u064F\u062D\u0630\u0641 \u0631\u0633\u0627\u0626\u0644\u0647\u0627 \u0648\u0631\u062F\u0648\u062F\u0647\u0627 \u0646\u0647\u0627\u0626\u064A\u064B\u0627. \u064A\u0628\u0642\u0649 \u0645\u0627 \u063A\u064A\u0651\u0631\u0647 \u0627\u0644\u0648\u0643\u064A\u0644\u060C \u0648\u064A\u0628\u0642\u0649 \u0633\u062C\u0644 \u0645\u0627 \u0634\u063A\u0651\u0644\u0647.",
202
202
  "chat.deleted": "\u062D\u064F\u0630\u0641\u062A \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629.",
203
+ "chats.deleteAll": "\u062D\u0630\u0641 \u0643\u0644 \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0627\u062A",
204
+ "chats.deleteAllTitle": "\u062D\u0630\u0641 \u0643\u0644 \u0645\u062D\u0627\u062F\u062B\u0627\u062A\u0643\u061F",
205
+ "chats.deleteAllBody": "\u062A\u064F\u062D\u0630\u0641 \u0631\u0633\u0627\u0626\u0644\u0647\u0627 \u0648\u0631\u062F\u0648\u062F\u0647\u0627 \u0646\u0647\u0627\u0626\u064A\u064B\u0627. \u062A\u062A\u0648\u0642\u0641 \u0623\u0648\u0644\u064B\u0627 \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0627\u062A \u0627\u0644\u062A\u064A \u0645\u0627 \u0632\u0627\u0644\u062A \u062A\u0639\u0645\u0644. \u064A\u0628\u0642\u0649 \u0645\u0627 \u063A\u064A\u0651\u0631\u0647 \u0627\u0644\u0648\u0643\u0644\u0627\u0621\u060C \u0648\u064A\u0628\u0642\u0649 \u0633\u062C\u0644 \u0645\u0627 \u0634\u063A\u0651\u0644\u0648\u0647.",
206
+ "chats.deletedAll": "{count, plural, =0 {\u0644\u0627 \u0645\u062D\u0627\u062F\u062B\u0627\u062A \u0644\u062D\u0630\u0641\u0647\u0627.} one {\u062D\u064F\u0630\u0641\u062A \u0645\u062D\u0627\u062F\u062B\u0629 \u0648\u0627\u062D\u062F\u0629.} two {\u062D\u064F\u0630\u0641\u062A \u0645\u062D\u0627\u062F\u062B\u062A\u0627\u0646.} few {\u062D\u064F\u0630\u0641\u062A # \u0645\u062D\u0627\u062F\u062B\u0627\u062A.} many {\u062D\u064F\u0630\u0641\u062A # \u0645\u062D\u0627\u062F\u062B\u0629.} other {\u062D\u064F\u0630\u0641\u062A # \u0645\u062D\u0627\u062F\u062B\u0629.}}",
207
+ "chats.stillGoing": "{count, plural, one {\u0643\u0627\u0646\u062A \u0645\u062D\u0627\u062F\u062B\u0629 \u0641\u064A \u0645\u0646\u062A\u0635\u0641 \u062E\u0637\u0648\u0629: \u062A\u0648\u0642\u0641\u062A\u060C \u0641\u0627\u062D\u0630\u0641\u0647\u0627 \u0645\u0631\u0629 \u0623\u062E\u0631\u0649 \u0628\u0639\u062F \u0642\u0644\u064A\u0644.} two {\u0643\u0627\u0646\u062A \u0645\u062D\u0627\u062F\u062B\u062A\u0627\u0646 \u0641\u064A \u0645\u0646\u062A\u0635\u0641 \u062E\u0637\u0648\u0629: \u062A\u0648\u0642\u0641\u062A\u0627\u060C \u0641\u0627\u062D\u0630\u0641\u0647\u0645\u0627 \u0645\u0631\u0629 \u0623\u062E\u0631\u0649 \u0628\u0639\u062F \u0642\u0644\u064A\u0644.} few {\u0643\u0627\u0646\u062A # \u0645\u062D\u0627\u062F\u062B\u0627\u062A \u0641\u064A \u0645\u0646\u062A\u0635\u0641 \u062E\u0637\u0648\u0629: \u062A\u0648\u0642\u0641\u062A\u060C \u0641\u0627\u062D\u0630\u0641\u0647\u0627 \u0645\u0631\u0629 \u0623\u062E\u0631\u0649 \u0628\u0639\u062F \u0642\u0644\u064A\u0644.} other {\u0643\u0627\u0646\u062A # \u0645\u062D\u0627\u062F\u062B\u0629 \u0641\u064A \u0645\u0646\u062A\u0635\u0641 \u062E\u0637\u0648\u0629: \u062A\u0648\u0642\u0641\u062A\u060C \u0641\u0627\u062D\u0630\u0641\u0647\u0627 \u0645\u0631\u0629 \u0623\u062E\u0631\u0649 \u0628\u0639\u062F \u0642\u0644\u064A\u0644.}}",
208
+ "chats.mineTitle": "\u0645\u062D\u0627\u062F\u062B\u0627\u062A\u0643 \u0645\u0639 \u0627\u0644\u0648\u0643\u0644\u0627\u0621",
209
+ "chats.mineHint": "\u0627\u062D\u0630\u0641\u0647\u0627 \u0643\u0644\u0647\u0627 \u0645\u0631\u0629 \u0648\u0627\u062D\u062F\u0629 \u0645\u062A\u0649 \u0634\u0626\u062A. \u0637\u0644\u0628 \u0645\u062D\u0648 \u0628\u064A\u0627\u0646\u0627\u062A\u0643 \u064A\u062D\u0630\u0641\u0647\u0627 \u0623\u064A\u0636\u064B\u0627.",
210
+ "chats.deleteTheirs": "\u062D\u0630\u0641 \u0645\u062D\u0627\u062F\u062B\u0627\u062A\u0647 \u0645\u0639 \u0627\u0644\u0648\u0643\u0644\u0627\u0621",
211
+ "chats.deleteTheirsTitle": "\u062D\u0630\u0641 \u0643\u0644 \u0645\u062D\u0627\u062F\u062B\u0627\u062A {name} \u0645\u0639 \u0627\u0644\u0648\u0643\u0644\u0627\u0621\u061F",
212
+ "chats.deleteTheirsBody": "\u062A\u064F\u062D\u0630\u0641 \u0631\u0633\u0627\u0626\u0644\u0647 \u0648\u0631\u062F\u0648\u062F \u0627\u0644\u0648\u0643\u0644\u0627\u0621 \u0646\u0647\u0627\u0626\u064A\u064B\u0627\u060C \u0644\u0645\u0646 \u064A\u063A\u0627\u062F\u0631 \u062F\u0648\u0646 \u0645\u062D\u0648 \u0628\u064A\u0627\u0646\u0627\u062A\u0647. \u0645\u062D\u0648 \u0627\u0644\u0634\u062E\u0635 \u064A\u062D\u0630\u0641\u0647\u0627 \u0639\u0644\u0649 \u0623\u064A \u062D\u0627\u0644.",
213
+ "chats.alsoDeleteTheirs": "\u062D\u0630\u0641 \u0645\u062D\u0627\u062F\u062B\u0627\u062A\u0647 \u0645\u0639 \u0627\u0644\u0648\u0643\u0644\u0627\u0621 \u0623\u064A\u0636\u064B\u0627",
203
214
  "select.choose": "\u0627\u062E\u062A\u0631 \u0648\u0643\u064A\u0644\u064B\u0627",
204
215
  "select.none": "\u0644\u0645 \u064A\u064F\u062A\u0628\u0646\u064E\u0651 \u0623\u064A \u0648\u0643\u064A\u0644 \u0647\u0646\u0627 \u0628\u0639\u062F: \u062A\u0628\u0646\u064E\u0651 \u0648\u0627\u062D\u062F\u064B\u0627 \u0645\u0646 \u0625\u0639\u062F\u0627\u062F\u0627\u062A \u0627\u0644\u0648\u0643\u0644\u0627\u0621.",
205
216
  "select.notHere": "{key} (\u0644\u0645 \u064A\u064F\u062A\u0628\u0646\u064E\u0651 \u0647\u0646\u0627)",
@@ -437,6 +448,17 @@ var en_default = {
437
448
  "chat.deleteTitle": "Delete this chat?",
438
449
  "chat.deleteBody": "Its messages and replies go for good. What the agent changed stays, and so does the record of what it ran.",
439
450
  "chat.deleted": "Chat deleted.",
451
+ "chats.deleteAll": "Delete all chats",
452
+ "chats.deleteAllTitle": "Delete all your chats?",
453
+ "chats.deleteAllBody": "Their messages and replies go for good. Chats still working stop first. What the agents changed stays, and so does the record of what they ran.",
454
+ "chats.deletedAll": "{count, plural, =0 {No chats to delete.} one {# chat deleted.} other {# chats deleted.}}",
455
+ "chats.stillGoing": "{count, plural, one {# chat was in the middle of a step: it stopped, so delete it again in a moment.} other {# chats were in the middle of a step: they stopped, so delete them again in a moment.}}",
456
+ "chats.mineTitle": "Your chats with agents",
457
+ "chats.mineHint": "Delete them all at once, whenever you like. Asking for your data to be erased deletes them too.",
458
+ "chats.deleteTheirs": "Delete their chats with agents",
459
+ "chats.deleteTheirsTitle": "Delete all of {name}'s chats with agents?",
460
+ "chats.deleteTheirsBody": "Their messages and the agents' replies go for good, for someone leaving without being erased. Erasing a person deletes them anyway.",
461
+ "chats.alsoDeleteTheirs": "Also delete their chats with agents",
440
462
  "select.choose": "Choose an agent",
441
463
  "select.none": "No agent is taken on here yet: take one on in the Agents settings.",
442
464
  "select.notHere": "{key} (not taken on here)",
@@ -1802,40 +1824,131 @@ function ItemAgentRuns({ kind, itemKey, version = 0, onChanged, title, descripti
1802
1824
  }
1803
1825
 
1804
1826
  // src/areas/agent/AgentChat.tsx
1805
- import { createContext as createContext2, useCallback as useCallback2, useContext as useContext2, useEffect as useEffect3, useMemo as useMemo3, useRef, useState as useState13 } from "react";
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";
1827
+ import { createContext as createContext2, useCallback as useCallback3, useContext as useContext2, useEffect as useEffect4, useMemo as useMemo3, useRef, useState as useState14 } from "react";
1828
+ import { Box as Box4, chakra as chakra4, CloseButton, Drawer, HStack as HStack8, Portal, Stack as Stack13, Text as Text13, Textarea as Textarea2 } from "@chakra-ui/react";
1807
1829
  import { ArrowLeft, Bot as Bot2, Check, ChevronDown as ChevronDown2, ChevronRight as ChevronRight2, Send, Square as Square2, Trash2 } from "lucide-react";
1808
1830
  import {
1809
- Button as Button10,
1831
+ Button as Button11,
1810
1832
  DirectionalIcon as DirectionalIcon2,
1811
1833
  EmptyState,
1812
1834
  Field as Field3,
1813
1835
  HostSlot as HostSlot7,
1814
1836
  IconButton,
1815
1837
  InlineAlert as InlineAlert9,
1816
- notify as notify7,
1838
+ notify as notify8,
1817
1839
  SelectField as SelectField6,
1818
1840
  StatusPill as StatusPill6,
1819
1841
  useApiAction as useApiAction9,
1820
1842
  useApiQuery as useApiQuery9,
1821
1843
  useAreaEvents,
1822
- useAreaRequest as useAreaRequest9,
1823
- useConfirm as useConfirm2,
1844
+ useAreaRequest as useAreaRequest10,
1845
+ useConfirm as useConfirm3,
1824
1846
  useFormatters as useFormatters6,
1825
1847
  useNames
1826
1848
  } from "@abpjs/ui";
1827
- import { Fragment as Fragment4, jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
1849
+
1850
+ // src/areas/agent/AgentChatsErase.tsx
1851
+ import { useCallback as useCallback2, useEffect as useEffect3, useState as useState13 } from "react";
1852
+ import { Box as Box3 } from "@chakra-ui/react";
1853
+ import { Button as Button10, CheckboxField as CheckboxField2, errorText as errorText2, notify as notify7, Panel as Panel6, useAreaRequest as useAreaRequest9, useConfirm as useConfirm2 } from "@abpjs/ui";
1854
+ import { jsx as jsx14 } from "react/jsx-runtime";
1855
+ function useTellDeleted() {
1856
+ const t = useAgentTexts();
1857
+ return useCallback2((done) => {
1858
+ notify7.success(t("chats.deletedAll", { count: num(done.deleted) }));
1859
+ if (num(done.stillGoing) > 0) notify7.info(t("chats.stillGoing", { count: num(done.stillGoing) }));
1860
+ }, [t]);
1861
+ }
1862
+ function useDeleteAllChats() {
1863
+ const t = useAgentTexts();
1864
+ const confirm = useConfirm2();
1865
+ const request = useAreaRequest9("agent");
1866
+ const tell = useTellDeleted();
1867
+ return async () => {
1868
+ if (!await confirm({ title: t("chats.deleteAllTitle"), description: t("chats.deleteAllBody"), confirmLabel: t("chats.deleteAll"), danger: true })) return false;
1869
+ try {
1870
+ tell(await request("/chats", { method: "DELETE" }));
1871
+ return true;
1872
+ } catch (e) {
1873
+ notify7.error(errorText2(e));
1874
+ return false;
1875
+ }
1876
+ };
1877
+ }
1878
+ function MyAgentChatsPanel() {
1879
+ const t = useAgentTexts();
1880
+ const deleteAll = useDeleteAllChats();
1881
+ const [busy, setBusy] = useState13(false);
1882
+ return /* @__PURE__ */ jsx14(Panel6, { title: t("chats.mineTitle"), description: t("chats.mineHint"), "data-testid": "agent-chats-mine", children: /* @__PURE__ */ jsx14(Box3, { children: /* @__PURE__ */ jsx14(
1883
+ Button10,
1884
+ {
1885
+ size: "sm",
1886
+ danger: true,
1887
+ loading: busy,
1888
+ onClick: async () => {
1889
+ setBusy(true);
1890
+ try {
1891
+ await deleteAll();
1892
+ } finally {
1893
+ setBusy(false);
1894
+ }
1895
+ },
1896
+ "data-testid": "agent-chats-delete-all",
1897
+ children: t("chats.deleteAll")
1898
+ }
1899
+ ) }) });
1900
+ }
1901
+ function PersonAgentChatsAction({ accountId, name }) {
1902
+ const t = useAgentTexts();
1903
+ const confirm = useConfirm2();
1904
+ const request = useAreaRequest9("agent");
1905
+ const tell = useTellDeleted();
1906
+ const [busy, setBusy] = useState13(false);
1907
+ async function run() {
1908
+ if (!await confirm({
1909
+ title: t("chats.deleteTheirsTitle", { name: name ?? "" }),
1910
+ description: t("chats.deleteTheirsBody"),
1911
+ confirmLabel: t("chats.deleteTheirs"),
1912
+ danger: true
1913
+ })) return;
1914
+ setBusy(true);
1915
+ try {
1916
+ tell(await request(`/people/${encodeURIComponent(accountId)}/chats`, { method: "DELETE" }));
1917
+ } catch (e) {
1918
+ notify7.error(errorText2(e));
1919
+ } finally {
1920
+ setBusy(false);
1921
+ }
1922
+ }
1923
+ return /* @__PURE__ */ jsx14(Button10, { danger: true, loading: busy, onClick: () => void run(), "data-testid": "agent-chats-delete-theirs", children: t("chats.deleteTheirs") });
1924
+ }
1925
+ function ForgetChatsOption({ accountId, register }) {
1926
+ const t = useAgentTexts();
1927
+ const request = useAreaRequest9("agent");
1928
+ const tell = useTellDeleted();
1929
+ const [checked, setChecked] = useState13(false);
1930
+ useEffect3(() => {
1931
+ if (!checked) return void 0;
1932
+ return register(async () => {
1933
+ tell(await request(`/people/${encodeURIComponent(accountId)}/chats`, { method: "DELETE" }));
1934
+ });
1935
+ }, [checked, accountId, register, request, tell]);
1936
+ return /* @__PURE__ */ jsx14(CheckboxField2, { label: t("chats.alsoDeleteTheirs"), checked, onCheckedChange: setChecked, "data-testid": "agent-chats-also-delete" });
1937
+ }
1938
+
1939
+ // src/areas/agent/AgentChat.tsx
1940
+ import { Fragment as Fragment4, jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
1828
1941
  var ChatContext = createContext2(null);
1829
1942
  function AgentChatProvider({ children, onItemChanged }) {
1830
- const [open, setOpen] = useState13(false);
1831
- const [view, setView] = useState13({ kind: "list" });
1832
- const show = useCallback2((target = {}) => {
1943
+ const [open, setOpen] = useState14(false);
1944
+ const [view, setView] = useState14({ kind: "list" });
1945
+ const show = useCallback3((target = {}) => {
1833
1946
  setView(target.chat ? { kind: "chat", id: target.chat, opened: true } : target.item || target.scope || target.agent || target.prompt ? { kind: "new", target } : { kind: "list" });
1834
1947
  setOpen(true);
1835
1948
  }, []);
1836
- const close = useCallback2(() => setOpen(false), []);
1949
+ const close = useCallback3(() => setOpen(false), []);
1837
1950
  const value = useMemo3(() => ({ open, view, show, setView, close, onItemChanged }), [open, view, show, close, onItemChanged]);
1838
- return /* @__PURE__ */ jsx14(ChatContext.Provider, { value, children });
1951
+ return /* @__PURE__ */ jsx15(ChatContext.Provider, { value, children });
1839
1952
  }
1840
1953
  function useAgentChat() {
1841
1954
  const state = useContext2(ChatContext);
@@ -1847,8 +1960,8 @@ var EMPTY_STREAMS = 3;
1847
1960
  var NO_LIVE = { run: null, texts: {}, steps: [] };
1848
1961
  function useLiveRun(chatId, going, reload) {
1849
1962
  const events = useAreaEvents("agent");
1850
- const [live, setLive] = useState13(NO_LIVE);
1851
- useEffect3(() => {
1963
+ const [live, setLive] = useState14(NO_LIVE);
1964
+ useEffect4(() => {
1852
1965
  if (!going) return;
1853
1966
  const abort = new AbortController();
1854
1967
  let timer;
@@ -1911,15 +2024,15 @@ function AgentChatButton() {
1911
2024
  const { open } = useAgentChat();
1912
2025
  const places = useApiQuery9("agent", "/chats/places");
1913
2026
  if (!places.data?.length) return null;
1914
- return /* @__PURE__ */ jsx14(IconButton, { "aria-label": t("chat.open"), size: "sm", onClick: () => open(), "data-testid": "agent-chat-open", children: /* @__PURE__ */ jsx14(Bot2, { size: 18 }) });
2027
+ return /* @__PURE__ */ jsx15(IconButton, { "aria-label": t("chat.open"), size: "sm", onClick: () => open(), "data-testid": "agent-chat-open", children: /* @__PURE__ */ jsx15(Bot2, { size: 18 }) });
1915
2028
  }
1916
2029
  function AskAgentButton({ kind, itemKey }) {
1917
2030
  const t = useAgentTexts();
1918
2031
  const { open } = useAgentChat();
1919
2032
  const agents = useApiQuery9("agent", `${itemPath(kind, itemKey)}/agents`);
1920
2033
  if (!agents.data?.length) return null;
1921
- return /* @__PURE__ */ jsxs13(Button10, { size: "sm", variant: "ghost", onClick: () => open({ item: { kind, key: itemKey } }), "data-testid": "ask-agent", children: [
1922
- /* @__PURE__ */ jsx14(Bot2, {}),
2034
+ return /* @__PURE__ */ jsxs13(Button11, { size: "sm", variant: "ghost", onClick: () => open({ item: { kind, key: itemKey } }), "data-testid": "ask-agent", children: [
2035
+ /* @__PURE__ */ jsx15(Bot2, {}),
1923
2036
  t("runs.ask")
1924
2037
  ] });
1925
2038
  }
@@ -1929,7 +2042,7 @@ function AgentChatPanel({ itemHref }) {
1929
2042
  if (!state) throw new Error("AgentChatPanel needs AgentChatProvider around it.");
1930
2043
  const { open, view, setView, close } = state;
1931
2044
  if (!open) return null;
1932
- return /* @__PURE__ */ jsx14(ItemHrefProvider, { value: itemHref, children: /* @__PURE__ */ jsx14(
2045
+ return /* @__PURE__ */ jsx15(ItemHrefProvider, { value: itemHref, children: /* @__PURE__ */ jsx15(
1933
2046
  Drawer.Root,
1934
2047
  {
1935
2048
  open: true,
@@ -1940,9 +2053,9 @@ function AgentChatPanel({ itemHref }) {
1940
2053
  trapFocus: false,
1941
2054
  preventScroll: false,
1942
2055
  onOpenChange: (e) => !e.open && close(),
1943
- children: /* @__PURE__ */ jsx14(Portal, { children: /* @__PURE__ */ jsx14(Drawer.Positioner, { pointerEvents: "none", width: "100%", children: /* @__PURE__ */ jsxs13(Drawer.Content, { pointerEvents: "auto", borderStartWidth: "1px", borderColor: "border.muted", "data-testid": "agent-chat", children: [
1944
- view.kind === "list" ? /* @__PURE__ */ jsx14(ChatList, { onOpen: (id) => setView({ kind: "chat", id }), onNew: () => setView({ kind: "new", target: {} }) }) : view.kind === "new" ? /* @__PURE__ */ jsx14(NewChat, { target: view.target, onBack: () => setView({ kind: "list" }), onStarted: (id) => setView({ kind: "chat", id }) }) : /* @__PURE__ */ jsx14(ChatView, { id: view.id, onBack: () => setView({ kind: "list" }), onMissing: view.opened ? () => setView({ kind: "list" }) : void 0 }, view.id),
1945
- /* @__PURE__ */ jsx14(Drawer.CloseTrigger, { asChild: true, children: /* @__PURE__ */ jsx14(CloseButton, { size: "sm", "aria-label": t("chat.close") }) })
2056
+ children: /* @__PURE__ */ jsx15(Portal, { children: /* @__PURE__ */ jsx15(Drawer.Positioner, { pointerEvents: "none", width: "100%", children: /* @__PURE__ */ jsxs13(Drawer.Content, { pointerEvents: "auto", borderStartWidth: "1px", borderColor: "border.muted", "data-testid": "agent-chat", children: [
2057
+ view.kind === "list" ? /* @__PURE__ */ jsx15(ChatList, { onOpen: (id) => setView({ kind: "chat", id }), onNew: () => setView({ kind: "new", target: {} }) }) : view.kind === "new" ? /* @__PURE__ */ jsx15(NewChat, { target: view.target, onBack: () => setView({ kind: "list" }), onStarted: (id) => setView({ kind: "chat", id }) }) : /* @__PURE__ */ jsx15(ChatView, { id: view.id, onBack: () => setView({ kind: "list" }), onMissing: view.opened ? () => setView({ kind: "list" }) : void 0 }, view.id),
2058
+ /* @__PURE__ */ jsx15(Drawer.CloseTrigger, { asChild: true, children: /* @__PURE__ */ jsx15(CloseButton, { size: "sm", "aria-label": t("chat.close") }) })
1946
2059
  ] }) }) })
1947
2060
  }
1948
2061
  ) });
@@ -1950,23 +2063,29 @@ function AgentChatPanel({ itemHref }) {
1950
2063
  function Where({ chat }) {
1951
2064
  const t = useAgentTexts();
1952
2065
  const names = useNames("scopes", chat.itemKey ? [] : [chat.scopeId]);
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 ?? "" }) });
2066
+ if (chat.itemKey) return /* @__PURE__ */ jsx15(Fragment4, { children: t("chat.about", { key: chat.itemKey }) });
2067
+ return /* @__PURE__ */ jsx15(Fragment4, { children: t("chat.in", { place: names[chat.scopeId] ?? chat.scopeKey ?? "" }) });
1955
2068
  }
1956
2069
  function ChatList({ onOpen, onNew }) {
1957
2070
  const t = useAgentTexts();
1958
2071
  const fmt = useFormatters6();
1959
2072
  const chats = useApiQuery9("agent", "/chats");
2073
+ const deleteAll = useDeleteAllChats();
1960
2074
  return /* @__PURE__ */ jsxs13(Fragment4, { children: [
1961
- /* @__PURE__ */ jsx14(Drawer.Header, { pe: "12", children: /* @__PURE__ */ jsxs13(Stack13, { gap: "0.5", children: [
1962
- /* @__PURE__ */ jsx14(Drawer.Title, { children: t("chat.title") }),
1963
- /* @__PURE__ */ jsx14(Text13, { textStyle: "caption", color: "fg.muted", children: t("chat.private") })
2075
+ /* @__PURE__ */ jsx15(Drawer.Header, { pe: "12", children: /* @__PURE__ */ jsxs13(Stack13, { gap: "0.5", children: [
2076
+ /* @__PURE__ */ jsx15(Drawer.Title, { children: t("chat.title") }),
2077
+ /* @__PURE__ */ jsx15(Text13, { textStyle: "caption", color: "fg.muted", children: t("chat.private") })
1964
2078
  ] }) }),
1965
2079
  /* @__PURE__ */ jsxs13(Drawer.Body, { px: "0", children: [
1966
- /* @__PURE__ */ jsx14(Box3, { px: "5", pb: "3", children: /* @__PURE__ */ jsx14(Button10, { size: "sm", variant: "primary", onClick: onNew, "data-testid": "agent-chat-new", children: t("chat.new") }) }),
1967
- chats.error && /* @__PURE__ */ jsx14(Box3, { px: "5", children: /* @__PURE__ */ jsx14(InlineAlert9, { tone: "danger", children: chats.error }) }),
1968
- chats.data?.length === 0 && /* @__PURE__ */ jsx14(EmptyState, { size: "sm", art: "agent", title: t("chat.none"), description: t("chat.noneHint") }),
1969
- /* @__PURE__ */ jsx14(Stack13, { gap: "0", as: "ul", listStyleType: "none", "aria-label": t("chat.chats"), children: chats.data?.map((c) => /* @__PURE__ */ jsx14(Box3, { as: "li", borderTopWidth: "1px", borderColor: "border.muted", children: /* @__PURE__ */ jsxs13(
2080
+ /* @__PURE__ */ jsxs13(HStack8, { px: "5", pb: "3", justify: "space-between", children: [
2081
+ /* @__PURE__ */ jsx15(Button11, { size: "sm", variant: "primary", onClick: onNew, "data-testid": "agent-chat-new", children: t("chat.new") }),
2082
+ !!chats.data?.length && /* @__PURE__ */ jsx15(Button11, { size: "sm", variant: "ghost", onClick: async () => {
2083
+ if (await deleteAll()) await chats.reload();
2084
+ }, "data-testid": "agent-chats-delete-all", children: t("chats.deleteAll") })
2085
+ ] }),
2086
+ chats.error && /* @__PURE__ */ jsx15(Box4, { px: "5", children: /* @__PURE__ */ jsx15(InlineAlert9, { tone: "danger", children: chats.error }) }),
2087
+ chats.data?.length === 0 && /* @__PURE__ */ jsx15(EmptyState, { size: "sm", art: "agent", title: t("chat.none"), description: t("chat.noneHint") }),
2088
+ /* @__PURE__ */ jsx15(Stack13, { gap: "0", as: "ul", listStyleType: "none", "aria-label": t("chat.chats"), children: chats.data?.map((c) => /* @__PURE__ */ jsx15(Box4, { as: "li", borderTopWidth: "1px", borderColor: "border.muted", children: /* @__PURE__ */ jsxs13(
1970
2089
  chakra4.button,
1971
2090
  {
1972
2091
  type: "button",
@@ -1980,13 +2099,13 @@ function ChatList({ onOpen, onNew }) {
1980
2099
  "data-testid": "agent-chat-row",
1981
2100
  children: [
1982
2101
  /* @__PURE__ */ jsxs13(HStack8, { gap: "2", justify: "space-between", align: "start", children: [
1983
- /* @__PURE__ */ jsx14(Text13, { textStyle: "sm", fontWeight: "medium", truncate: true, dir: "auto", children: c.title }),
1984
- c.going && /* @__PURE__ */ jsx14(StatusPill6, { tone: "info", children: t("chat.going") })
2102
+ /* @__PURE__ */ jsx15(Text13, { textStyle: "sm", fontWeight: "medium", truncate: true, dir: "auto", children: c.title }),
2103
+ c.going && /* @__PURE__ */ jsx15(StatusPill6, { tone: "info", children: t("chat.going") })
1985
2104
  ] }),
1986
2105
  /* @__PURE__ */ jsxs13(Text13, { textStyle: "caption", color: "fg.muted", truncate: true, children: [
1987
2106
  c.agent?.displayName ?? c.agentKey,
1988
2107
  " \xB7 ",
1989
- /* @__PURE__ */ jsx14(Where, { chat: c }),
2108
+ /* @__PURE__ */ jsx15(Where, { chat: c }),
1990
2109
  " \xB7 ",
1991
2110
  fmt.dateTime(c.lastAt)
1992
2111
  ] })
@@ -1999,15 +2118,15 @@ function ChatList({ onOpen, onNew }) {
1999
2118
  function NewChat({ target, onBack, onStarted }) {
2000
2119
  const t = useAgentTexts();
2001
2120
  const nameOf = useNameOf();
2002
- const request = useAreaRequest9("agent");
2121
+ const request = useAreaRequest10("agent");
2003
2122
  const action = useApiAction9();
2004
2123
  const item = target.item ?? null;
2005
2124
  const places = useApiQuery9("agent", item ? null : "/chats/places");
2006
2125
  const askable = useApiQuery9("agent", item ? `${itemPath(item.kind, item.key)}/agents` : null);
2007
2126
  const scopeNames = useNames("scopes", (places.data ?? []).map((p) => p.scope.id));
2008
- const [place, setPlace] = useState13(target.scope ?? "");
2009
- const [agentId, setAgentId] = useState13("");
2010
- const [prompt, setPrompt] = useState13(target.prompt ?? "");
2127
+ const [place, setPlace] = useState14(target.scope ?? "");
2128
+ const [agentId, setAgentId] = useState14("");
2129
+ const [prompt, setPrompt] = useState14(target.prompt ?? "");
2011
2130
  const placeKey = places.data?.some((p) => p.scope.key === place) ? place : places.data?.[0]?.scope.key;
2012
2131
  const agents = item ? askable.data : places.data?.find((p) => p.scope.key === placeKey)?.agents;
2013
2132
  const chosen = agents?.find((a) => a.id === agentId)?.id ?? agents?.find((a) => a.id === target.agent || a.key === target.agent)?.id ?? agents?.[0]?.id;
@@ -2019,16 +2138,16 @@ function NewChat({ target, onBack, onStarted }) {
2019
2138
  if (chat) onStarted(chat.chat.id);
2020
2139
  }
2021
2140
  return /* @__PURE__ */ jsxs13(Fragment4, { children: [
2022
- /* @__PURE__ */ jsx14(Drawer.Header, { pe: "12", children: /* @__PURE__ */ jsxs13(HStack8, { gap: "1.5", align: "start", children: [
2023
- /* @__PURE__ */ jsx14(BackButton, { onBack }),
2141
+ /* @__PURE__ */ jsx15(Drawer.Header, { pe: "12", children: /* @__PURE__ */ jsxs13(HStack8, { gap: "1.5", align: "start", children: [
2142
+ /* @__PURE__ */ jsx15(BackButton, { onBack }),
2024
2143
  /* @__PURE__ */ jsxs13(Stack13, { gap: "0.5", children: [
2025
- /* @__PURE__ */ jsx14(Drawer.Title, { children: item ? t("chat.newAbout", { key: item.key }) : t("chat.new") }),
2026
- /* @__PURE__ */ jsx14(Text13, { textStyle: "caption", color: "fg.muted", children: t("chat.private") })
2144
+ /* @__PURE__ */ jsx15(Drawer.Title, { children: item ? t("chat.newAbout", { key: item.key }) : t("chat.new") }),
2145
+ /* @__PURE__ */ jsx15(Text13, { textStyle: "caption", color: "fg.muted", children: t("chat.private") })
2027
2146
  ] })
2028
2147
  ] }) }),
2029
- /* @__PURE__ */ jsx14(Drawer.Body, { children: /* @__PURE__ */ jsxs13(Stack13, { gap: "4", children: [
2030
- loaded && !agents?.length ? /* @__PURE__ */ jsx14(EmptyState, { size: "sm", title: item ? t("chat.noAgentsHere", { key: item.key }) : t("chat.noPlaces") }) : /* @__PURE__ */ jsxs13(Fragment4, { children: [
2031
- !item && places.data && places.data.length > 1 && /* @__PURE__ */ jsx14(Field3, { label: t("chat.place"), children: /* @__PURE__ */ jsx14(
2148
+ /* @__PURE__ */ jsx15(Drawer.Body, { children: /* @__PURE__ */ jsxs13(Stack13, { gap: "4", children: [
2149
+ loaded && !agents?.length ? /* @__PURE__ */ jsx15(EmptyState, { size: "sm", title: item ? t("chat.noAgentsHere", { key: item.key }) : t("chat.noPlaces") }) : /* @__PURE__ */ jsxs13(Fragment4, { children: [
2150
+ !item && places.data && places.data.length > 1 && /* @__PURE__ */ jsx15(Field3, { label: t("chat.place"), children: /* @__PURE__ */ jsx15(
2032
2151
  SelectField6,
2033
2152
  {
2034
2153
  value: placeKey ?? "",
@@ -2040,25 +2159,25 @@ function NewChat({ target, onBack, onStarted }) {
2040
2159
  options: places.data.map((p) => ({ value: p.scope.key, label: scopeNames[p.scope.id] ? `${scopeNames[p.scope.id]} (${p.scope.key})` : p.scope.key }))
2041
2160
  }
2042
2161
  ) }),
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) })) }) })
2162
+ agents && agents.length > 0 && /* @__PURE__ */ jsx15(Field3, { label: t("chat.agent"), children: /* @__PURE__ */ jsx15(SelectField6, { value: chosen ?? "", onChange: (e) => setAgentId(e.target.value), "data-testid": "agent-chat-agent", options: agents.map((a) => ({ value: a.id, label: agentName(a) })) }) })
2044
2163
  ] }),
2045
- action.error && /* @__PURE__ */ jsx14(InlineAlert9, { tone: "danger", children: action.error })
2164
+ action.error && /* @__PURE__ */ jsx15(InlineAlert9, { tone: "danger", children: action.error })
2046
2165
  ] }) }),
2047
- agents && agents.length > 0 && /* @__PURE__ */ jsx14(Drawer.Footer, { borderTopWidth: "1px", borderColor: "border.muted", children: /* @__PURE__ */ jsx14(Composer, { value: prompt, onChange: setPrompt, onSend: () => void start(), busy: action.busy, label: t("chat.first"), autoFocus: true }) })
2166
+ agents && agents.length > 0 && /* @__PURE__ */ jsx15(Drawer.Footer, { borderTopWidth: "1px", borderColor: "border.muted", children: /* @__PURE__ */ jsx15(Composer, { value: prompt, onChange: setPrompt, onSend: () => void start(), busy: action.busy, label: t("chat.first"), autoFocus: true }) })
2048
2167
  ] });
2049
2168
  }
2050
2169
  function ChatView({ id, onBack, onMissing }) {
2051
2170
  const t = useAgentTexts();
2052
- const confirm = useConfirm2();
2053
- const request = useAreaRequest9("agent");
2171
+ const confirm = useConfirm3();
2172
+ const request = useAreaRequest10("agent");
2054
2173
  const state = useContext2(ChatContext);
2055
2174
  const chat = useApiQuery9("agent", `/chats/${id}`);
2056
2175
  const send = useApiAction9();
2057
- const [prompt, setPrompt] = useState13("");
2176
+ const [prompt, setPrompt] = useState14("");
2058
2177
  const end = useRef(null);
2059
2178
  const { reload, setData } = chat;
2060
2179
  const c = chat.data;
2061
- useEffect3(() => {
2180
+ useEffect4(() => {
2062
2181
  if (onMissing && chat.error && !c) onMissing();
2063
2182
  }, [onMissing, chat.error, c]);
2064
2183
  const going = c ? !c.canSend : false;
@@ -2066,11 +2185,11 @@ function ChatView({ id, onBack, onMissing }) {
2066
2185
  const live = useLiveRun(id, going, reload);
2067
2186
  const liveText = Object.values(live.texts).join("").length;
2068
2187
  const wasGoing = useRef(false);
2069
- useEffect3(() => {
2188
+ useEffect4(() => {
2070
2189
  if (wasGoing.current && !going && c?.chat.itemKey && c.chat.itemKind) state?.onItemChanged?.({ kind: c.chat.itemKind, key: c.chat.itemKey });
2071
2190
  wasGoing.current = going;
2072
2191
  }, [going, c, state]);
2073
- useEffect3(() => {
2192
+ useEffect4(() => {
2074
2193
  end.current?.scrollIntoView({ block: "end" });
2075
2194
  }, [c?.runs.length, last?.state, last?.answer, liveText, live.steps.length]);
2076
2195
  async function say() {
@@ -2088,29 +2207,29 @@ function ChatView({ id, onBack, onMissing }) {
2088
2207
  return true;
2089
2208
  });
2090
2209
  if (done) {
2091
- notify7.success(t("chat.deleted"));
2210
+ notify8.success(t("chat.deleted"));
2092
2211
  onBack();
2093
2212
  }
2094
2213
  }
2095
2214
  return /* @__PURE__ */ jsxs13(Fragment4, { children: [
2096
- /* @__PURE__ */ jsx14(Drawer.Header, { pe: "12", children: /* @__PURE__ */ jsxs13(HStack8, { gap: "1.5", align: "start", w: "full", children: [
2097
- /* @__PURE__ */ jsx14(BackButton, { onBack }),
2215
+ /* @__PURE__ */ jsx15(Drawer.Header, { pe: "12", children: /* @__PURE__ */ jsxs13(HStack8, { gap: "1.5", align: "start", w: "full", children: [
2216
+ /* @__PURE__ */ jsx15(BackButton, { onBack }),
2098
2217
  /* @__PURE__ */ jsxs13(Stack13, { gap: "0.5", flex: "1", minW: "0", children: [
2099
- /* @__PURE__ */ jsx14(Drawer.Title, { truncate: true, dir: "auto", children: c?.chat.title ?? "" }),
2218
+ /* @__PURE__ */ jsx15(Drawer.Title, { truncate: true, dir: "auto", children: c?.chat.title ?? "" }),
2100
2219
  c && /* @__PURE__ */ jsxs13(Text13, { textStyle: "caption", color: "fg.muted", truncate: true, children: [
2101
2220
  c.chat.agent?.displayName ?? c.chat.agentKey,
2102
2221
  " \xB7",
2103
2222
  " ",
2104
- c.chat.itemKey ? /* @__PURE__ */ jsx14(ItemLink, { kind: c.chat.itemKind, itemKey: c.chat.itemKey, children: t("chat.about", { key: c.chat.itemKey }) }) : /* @__PURE__ */ jsx14(Where, { chat: c.chat })
2223
+ c.chat.itemKey ? /* @__PURE__ */ jsx15(ItemLink, { kind: c.chat.itemKind, itemKey: c.chat.itemKey, children: t("chat.about", { key: c.chat.itemKey }) }) : /* @__PURE__ */ jsx15(Where, { chat: c.chat })
2105
2224
  ] })
2106
2225
  ] }),
2107
- c && !going && /* @__PURE__ */ jsx14(IconButton, { danger: true, "aria-label": t("chat.delete"), size: "sm", onClick: () => void remove(), "data-testid": "agent-chat-delete", children: /* @__PURE__ */ jsx14(Trash2, { size: 16 }) })
2226
+ c && !going && /* @__PURE__ */ jsx15(IconButton, { danger: true, "aria-label": t("chat.delete"), size: "sm", onClick: () => void remove(), "data-testid": "agent-chat-delete", children: /* @__PURE__ */ jsx15(Trash2, { size: 16 }) })
2108
2227
  ] }) }),
2109
2228
  /* @__PURE__ */ jsxs13(Drawer.Body, { children: [
2110
- chat.error && /* @__PURE__ */ jsx14(InlineAlert9, { tone: "danger", children: chat.error }),
2229
+ chat.error && /* @__PURE__ */ jsx15(InlineAlert9, { tone: "danger", children: chat.error }),
2111
2230
  c && /* @__PURE__ */ jsxs13(Stack13, { gap: "5", as: "ol", listStyleType: "none", "aria-label": t("chat.messages"), children: [
2112
- /* @__PURE__ */ jsx14(Text13, { as: "li", textStyle: "caption", color: "fg.muted", textAlign: "center", children: t("chat.private") }),
2113
- c.runs.map((run) => /* @__PURE__ */ jsx14(
2231
+ /* @__PURE__ */ jsx15(Text13, { as: "li", textStyle: "caption", color: "fg.muted", textAlign: "center", children: t("chat.private") }),
2232
+ c.runs.map((run) => /* @__PURE__ */ jsx15(
2114
2233
  Turn,
2115
2234
  {
2116
2235
  run,
@@ -2122,11 +2241,11 @@ function ChatView({ id, onBack, onMissing }) {
2122
2241
  run.id
2123
2242
  ))
2124
2243
  ] }),
2125
- /* @__PURE__ */ jsx14("div", { ref: end })
2244
+ /* @__PURE__ */ jsx15("div", { ref: end })
2126
2245
  ] }),
2127
- /* @__PURE__ */ jsx14(Drawer.Footer, { borderTopWidth: "1px", borderColor: "border.muted", children: /* @__PURE__ */ jsxs13(Stack13, { gap: "1.5", w: "full", children: [
2128
- send.error && /* @__PURE__ */ jsx14(InlineAlert9, { tone: "danger", children: send.error }),
2129
- /* @__PURE__ */ jsx14(
2246
+ /* @__PURE__ */ jsx15(Drawer.Footer, { borderTopWidth: "1px", borderColor: "border.muted", children: /* @__PURE__ */ jsxs13(Stack13, { gap: "1.5", w: "full", children: [
2247
+ send.error && /* @__PURE__ */ jsx15(InlineAlert9, { tone: "danger", children: send.error }),
2248
+ /* @__PURE__ */ jsx15(
2130
2249
  Composer,
2131
2250
  {
2132
2251
  value: prompt,
@@ -2145,10 +2264,10 @@ function ChatView({ id, onBack, onMissing }) {
2145
2264
  function Turn({ run, chat, onChat, onChanged, live }) {
2146
2265
  const t = useAgentTexts();
2147
2266
  const fmt = useFormatters6();
2148
- const request = useAreaRequest9("agent");
2267
+ const request = useAreaRequest10("agent");
2149
2268
  const state = useContext2(ChatContext);
2150
2269
  const action = useApiAction9();
2151
- const [open, setOpen] = useState13(false);
2270
+ const [open, setOpen] = useState14(false);
2152
2271
  const going = GOING.has(run.state);
2153
2272
  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");
2154
2273
  const writing = live ? Object.entries(live.texts).sort(([a], [b]) => Number(b) - Number(a)).find(([, text]) => text.length > 0)?.[1] : void 0;
@@ -2168,36 +2287,36 @@ function Turn({ run, chat, onChat, onChanged, live }) {
2168
2287
  const next = await action.run(() => request(`/chats/${chat.chat.id}/runs/${run.id}/post`, { method: "POST" }));
2169
2288
  if (next) {
2170
2289
  onChat(next);
2171
- notify7.success(t("chat.postedNote", { agent, key: itemKey ?? "" }));
2290
+ notify8.success(t("chat.postedNote", { agent, key: itemKey ?? "" }));
2172
2291
  if (itemKey && itemKind) state?.onItemChanged?.({ kind: itemKind, key: itemKey });
2173
2292
  }
2174
2293
  }
2175
- return /* @__PURE__ */ jsx14(Box3, { as: "li", "data-testid": "agent-chat-turn", children: /* @__PURE__ */ jsxs13(Stack13, { gap: "2.5", children: [
2176
- run.prompt && /* @__PURE__ */ jsx14(Box3, { alignSelf: "flex-end", maxW: "85%", bg: "bg.muted", borderRadius: "l3", px: "3", py: "2", textStyle: "sm", whiteSpace: "pre-wrap", dir: "auto", "aria-label": t("chat.you"), children: run.prompt }),
2294
+ return /* @__PURE__ */ jsx15(Box4, { as: "li", "data-testid": "agent-chat-turn", children: /* @__PURE__ */ jsxs13(Stack13, { gap: "2.5", children: [
2295
+ run.prompt && /* @__PURE__ */ jsx15(Box4, { alignSelf: "flex-end", maxW: "85%", bg: "bg.muted", borderRadius: "l3", px: "3", py: "2", textStyle: "sm", whiteSpace: "pre-wrap", dir: "auto", "aria-label": t("chat.you"), children: run.prompt }),
2177
2296
  /* @__PURE__ */ jsxs13(Stack13, { gap: "1.5", children: [
2178
2297
  /* @__PURE__ */ jsxs13(HStack8, { gap: "2", wrap: "wrap", children: [
2179
- /* @__PURE__ */ jsx14(Bot2, { size: 14, "aria-hidden": true }),
2180
- /* @__PURE__ */ jsx14(Text13, { as: "span", textStyle: "sm", fontWeight: "medium", children: agent }),
2181
- run.state !== "done" && /* @__PURE__ */ jsx14(StatusPill6, { tone: RUN_TONES[run.state] ?? "neutral", children: t(`runs.states.${run.state}`) }),
2182
- run.outside && /* @__PURE__ */ jsx14(StatusPill6, { tone: "warning", children: t("runs.outside") }),
2183
- run.wide && /* @__PURE__ */ jsx14(StatusPill6, { tone: "warning", children: t("runs.wide") }),
2184
- /* @__PURE__ */ jsx14(Text13, { as: "span", textStyle: "caption", color: "fg.muted", children: fmt.dateTime(run.createdAt) }),
2185
- going && /* @__PURE__ */ jsxs13(Button10, { size: "xs", variant: "ghost", onClick: () => void stop(), loading: action.busy, "data-testid": "agent-chat-stop", children: [
2186
- /* @__PURE__ */ jsx14(Square2, {}),
2298
+ /* @__PURE__ */ jsx15(Bot2, { size: 14, "aria-hidden": true }),
2299
+ /* @__PURE__ */ jsx15(Text13, { as: "span", textStyle: "sm", fontWeight: "medium", children: agent }),
2300
+ run.state !== "done" && /* @__PURE__ */ jsx15(StatusPill6, { tone: RUN_TONES[run.state] ?? "neutral", children: t(`runs.states.${run.state}`) }),
2301
+ run.outside && /* @__PURE__ */ jsx15(StatusPill6, { tone: "warning", children: t("runs.outside") }),
2302
+ run.wide && /* @__PURE__ */ jsx15(StatusPill6, { tone: "warning", children: t("runs.wide") }),
2303
+ /* @__PURE__ */ jsx15(Text13, { as: "span", textStyle: "caption", color: "fg.muted", children: fmt.dateTime(run.createdAt) }),
2304
+ going && /* @__PURE__ */ jsxs13(Button11, { size: "xs", variant: "ghost", onClick: () => void stop(), loading: action.busy, "data-testid": "agent-chat-stop", children: [
2305
+ /* @__PURE__ */ jsx15(Square2, {}),
2187
2306
  t("runs.stop")
2188
2307
  ] })
2189
2308
  ] }),
2190
- going && !run.question && !writing && /* @__PURE__ */ jsx14(Text13, { textStyle: "caption", color: "fg.muted", "aria-live": "polite", children: run.state === "queued" ? t("chat.queued") : t("chat.working", { agent, count: tools.length }) }),
2191
- going && writing && /* @__PURE__ */ jsx14(Box3, { "aria-busy": "true", children: /* @__PURE__ */ jsx14(AgentText, { source: writing, testId: "agent-chat-writing" }) }),
2192
- run.question && /* @__PURE__ */ jsx14(AgentQuestionCard, { question: run.question, onAnswered: onChanged }),
2193
- run.answer && /* @__PURE__ */ jsx14(AgentText, { source: run.answer, testId: "agent-chat-reply" }),
2194
- !going && !run.answer && /* @__PURE__ */ jsx14(Text13, { textStyle: "caption", color: run.state === "failed" ? "fg.error" : "fg.muted", children: run.state === "stopped" ? t("chat.stopped") : run.state === "failed" ? t("chat.failed", { why: run.error ?? "" }) : t("chat.noReply") }),
2195
- tools.length > 0 && /* @__PURE__ */ jsxs13(Box3, { children: [
2196
- /* @__PURE__ */ jsxs13(Button10, { size: "xs", variant: "link", px: "0", onClick: () => setOpen(!open), "aria-expanded": open, children: [
2197
- open ? /* @__PURE__ */ jsx14(ChevronDown2, {}) : /* @__PURE__ */ jsx14(DirectionalIcon2, { children: /* @__PURE__ */ jsx14(ChevronRight2, {}) }),
2309
+ going && !run.question && !writing && /* @__PURE__ */ jsx15(Text13, { textStyle: "caption", color: "fg.muted", "aria-live": "polite", children: run.state === "queued" ? t("chat.queued") : t("chat.working", { agent, count: tools.length }) }),
2310
+ going && writing && /* @__PURE__ */ jsx15(Box4, { "aria-busy": "true", children: /* @__PURE__ */ jsx15(AgentText, { source: writing, testId: "agent-chat-writing" }) }),
2311
+ run.question && /* @__PURE__ */ jsx15(AgentQuestionCard, { question: run.question, onAnswered: onChanged }),
2312
+ run.answer && /* @__PURE__ */ jsx15(AgentText, { source: run.answer, testId: "agent-chat-reply" }),
2313
+ !going && !run.answer && /* @__PURE__ */ jsx15(Text13, { textStyle: "caption", color: run.state === "failed" ? "fg.error" : "fg.muted", children: run.state === "stopped" ? t("chat.stopped") : run.state === "failed" ? t("chat.failed", { why: run.error ?? "" }) : t("chat.noReply") }),
2314
+ tools.length > 0 && /* @__PURE__ */ jsxs13(Box4, { children: [
2315
+ /* @__PURE__ */ jsxs13(Button11, { size: "xs", variant: "link", px: "0", onClick: () => setOpen(!open), "aria-expanded": open, children: [
2316
+ open ? /* @__PURE__ */ jsx15(ChevronDown2, {}) : /* @__PURE__ */ jsx15(DirectionalIcon2, { children: /* @__PURE__ */ jsx15(ChevronRight2, {}) }),
2198
2317
  t("runs.steps", { count: tools.length })
2199
2318
  ] }),
2200
- open && /* @__PURE__ */ jsx14(Stack13, { gap: "0.5", mt: "1", as: "ol", listStyleType: "none", children: tools.map((s) => /* @__PURE__ */ jsxs13(Text13, { as: "li", textStyle: "caption", color: s.outcome === "failed" || s.outcome === "refused" ? "fg.error" : "fg.muted", children: [
2319
+ open && /* @__PURE__ */ jsx15(Stack13, { gap: "0.5", mt: "1", as: "ol", listStyleType: "none", children: tools.map((s) => /* @__PURE__ */ jsxs13(Text13, { as: "li", textStyle: "caption", color: s.outcome === "failed" || s.outcome === "refused" ? "fg.error" : "fg.muted", children: [
2201
2320
  s.name,
2202
2321
  s.target ? ` \xB7 ${s.target}` : "",
2203
2322
  ": ",
@@ -2205,19 +2324,19 @@ function Turn({ run, chat, onChat, onChanged, live }) {
2205
2324
  ] }, String(s.number))) })
2206
2325
  ] }),
2207
2326
  !going && (postable || run.postedAt || changed) && /* @__PURE__ */ jsxs13(HStack8, { gap: "1", wrap: "wrap", children: [
2208
- postable && itemKey && /* @__PURE__ */ jsx14(Button10, { size: "xs", variant: "secondary", onClick: () => void post(), loading: action.busy, "data-testid": "agent-chat-post", children: t("chat.post", { key: itemKey }) }),
2327
+ postable && itemKey && /* @__PURE__ */ jsx15(Button11, { size: "xs", variant: "secondary", onClick: () => void post(), loading: action.busy, "data-testid": "agent-chat-post", children: t("chat.post", { key: itemKey }) }),
2209
2328
  run.postedAt && itemKey && /* @__PURE__ */ jsxs13(HStack8, { gap: "1", color: "fg.muted", textStyle: "caption", px: "1", children: [
2210
- /* @__PURE__ */ jsx14(Check, { size: 12, "aria-hidden": true }),
2211
- /* @__PURE__ */ jsx14(Text13, { as: "span", children: t("chat.posted", { key: itemKey }) })
2329
+ /* @__PURE__ */ jsx15(Check, { size: 12, "aria-hidden": true }),
2330
+ /* @__PURE__ */ jsx15(Text13, { as: "span", children: t("chat.posted", { key: itemKey }) })
2212
2331
  ] }),
2213
- changed && /* @__PURE__ */ jsx14(HostSlot7, { name: "agent.run.actions", context: { run, onChanged: itemChanged } })
2332
+ changed && /* @__PURE__ */ jsx15(HostSlot7, { name: "agent.run.actions", context: { run, onChanged: itemChanged } })
2214
2333
  ] })
2215
2334
  ] })
2216
2335
  ] }) });
2217
2336
  }
2218
2337
  function BackButton({ onBack }) {
2219
2338
  const t = useAgentTexts();
2220
- return /* @__PURE__ */ jsx14(IconButton, { "aria-label": t("chat.back"), size: "sm", onClick: onBack, "data-testid": "agent-chat-back", children: /* @__PURE__ */ jsx14(DirectionalIcon2, { children: /* @__PURE__ */ jsx14(ArrowLeft, { size: 16 }) }) });
2339
+ return /* @__PURE__ */ jsx15(IconButton, { "aria-label": t("chat.back"), size: "sm", onClick: onBack, "data-testid": "agent-chat-back", children: /* @__PURE__ */ jsx15(DirectionalIcon2, { children: /* @__PURE__ */ jsx15(ArrowLeft, { size: 16 }) }) });
2221
2340
  }
2222
2341
  function Composer({ value, onChange, onSend, busy, disabled, label, hint, autoFocus }) {
2223
2342
  const t = useAgentTexts();
@@ -2228,7 +2347,7 @@ function Composer({ value, onChange, onSend, busy, disabled, label, hint, autoFo
2228
2347
  }
2229
2348
  }
2230
2349
  return /* @__PURE__ */ jsxs13(Stack13, { gap: "1.5", w: "full", children: [
2231
- /* @__PURE__ */ jsx14(
2350
+ /* @__PURE__ */ jsx15(
2232
2351
  Textarea2,
2233
2352
  {
2234
2353
  rows: 3,
@@ -2245,9 +2364,9 @@ function Composer({ value, onChange, onSend, busy, disabled, label, hint, autoFo
2245
2364
  }
2246
2365
  ),
2247
2366
  /* @__PURE__ */ jsxs13(HStack8, { justify: "space-between", gap: "2", children: [
2248
- /* @__PURE__ */ jsx14(Text13, { textStyle: "caption", color: "fg.muted", children: hint ?? t("chat.keys") }),
2249
- /* @__PURE__ */ jsxs13(Button10, { size: "sm", variant: "primary", onClick: onSend, loading: busy, disabled: disabled || !value.trim(), "data-testid": "agent-chat-send", children: [
2250
- /* @__PURE__ */ jsx14(DirectionalIcon2, { children: /* @__PURE__ */ jsx14(Send, {}) }),
2367
+ /* @__PURE__ */ jsx15(Text13, { textStyle: "caption", color: "fg.muted", children: hint ?? t("chat.keys") }),
2368
+ /* @__PURE__ */ jsxs13(Button11, { size: "sm", variant: "primary", onClick: onSend, loading: busy, disabled: disabled || !value.trim(), "data-testid": "agent-chat-send", children: [
2369
+ /* @__PURE__ */ jsx15(DirectionalIcon2, { children: /* @__PURE__ */ jsx15(Send, {}) }),
2251
2370
  t("chat.send")
2252
2371
  ] })
2253
2372
  ] })
@@ -2255,15 +2374,15 @@ function Composer({ value, onChange, onSend, busy, disabled, label, hint, autoFo
2255
2374
  }
2256
2375
 
2257
2376
  // src/areas/agent/AgentPickers.tsx
2258
- import { Box as Box4, Input as Input4, Stack as Stack14, Text as Text14 } from "@chakra-ui/react";
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";
2377
+ import { Box as Box5, Input as Input4, Stack as Stack14, Text as Text14 } from "@chakra-ui/react";
2378
+ import { EmptyState as EmptyState2, Panel as Panel7, SelectField as SelectField7, StatusPill as StatusPill7, useApiQuery as useApiQuery10 } from "@abpjs/ui";
2379
+ import { Fragment as Fragment5, jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
2261
2380
  function AgentSelect({ scope, value, onChange, disabled, anyLabel }) {
2262
2381
  const t = useAgentTexts();
2263
2382
  const nameOf = useNameOf();
2264
2383
  const agents = useApiQuery10("agent", `/scopes/${encodeURIComponent(scope)}/agents`);
2265
2384
  if (agents.error)
2266
- return /* @__PURE__ */ jsx15(Input4, { size: "sm", dir: "ltr", disabled, defaultValue: value, placeholder: t("select.key"), onBlur: (e) => onChange(e.target.value.trim() || void 0) });
2385
+ return /* @__PURE__ */ jsx16(Input4, { size: "sm", dir: "ltr", disabled, defaultValue: value, placeholder: t("select.key"), onBlur: (e) => onChange(e.target.value.trim() || void 0) });
2267
2386
  const taken = (agents.data ?? []).filter((a) => a.own || a.roleKey).map((a) => a.agent);
2268
2387
  const options = taken.map((a) => {
2269
2388
  const name = nameOf(a.names, a.key);
@@ -2271,7 +2390,7 @@ function AgentSelect({ scope, value, onChange, disabled, anyLabel }) {
2271
2390
  });
2272
2391
  if (value && !taken.some((a) => a.key === value)) options.push({ value, label: t("select.notHere", { key: value }) });
2273
2392
  return /* @__PURE__ */ jsxs14(Stack14, { gap: "1", children: [
2274
- /* @__PURE__ */ jsx15(
2393
+ /* @__PURE__ */ jsx16(
2275
2394
  SelectField7,
2276
2395
  {
2277
2396
  size: "sm",
@@ -2283,26 +2402,26 @@ function AgentSelect({ scope, value, onChange, disabled, anyLabel }) {
2283
2402
  "data-testid": "agent-select"
2284
2403
  }
2285
2404
  ),
2286
- agents.data && taken.length === 0 && /* @__PURE__ */ jsx15(Text14, { textStyle: "caption", color: "fg.muted", children: t("select.none") })
2405
+ agents.data && taken.length === 0 && /* @__PURE__ */ jsx16(Text14, { textStyle: "caption", color: "fg.muted", children: t("select.none") })
2287
2406
  ] });
2288
2407
  }
2289
2408
  function AgentBadge({ person, label }) {
2290
2409
  const t = useAgentTexts();
2291
2410
  if (person?.kind !== "agent") return null;
2292
- return /* @__PURE__ */ jsx15(StatusPill7, { tone: "info", dot: false, "data-testid": "agent-badge", children: label ?? t("agentLabel") });
2411
+ return /* @__PURE__ */ jsx16(StatusPill7, { tone: "info", dot: false, "data-testid": "agent-badge", children: label ?? t("agentLabel") });
2293
2412
  }
2294
2413
  function AgentQuestionsPanel({ itemHref }) {
2295
2414
  const t = useAgentTexts();
2296
2415
  const questions = useApiQuery10("agent", "/questions");
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: [
2416
+ return /* @__PURE__ */ jsx16(ItemHrefProvider, { value: itemHref, children: /* @__PURE__ */ jsx16(Panel7, { title: t("mine.title"), description: t("mine.hint"), "data-testid": "agent-questions", children: questions.data?.length === 0 ? /* @__PURE__ */ jsx16(EmptyState2, { size: "sm", art: "agent", title: t("mine.none") }) : /* @__PURE__ */ jsx16(Stack14, { gap: "4", as: "ul", listStyleType: "none", children: (questions.data ?? []).map((q) => /* @__PURE__ */ jsx16(Box5, { as: "li", children: /* @__PURE__ */ jsxs14(Stack14, { gap: "1.5", children: [
2298
2417
  /* @__PURE__ */ jsxs14(Text14, { textStyle: "sm", fontWeight: "medium", children: [
2299
2418
  q.agent?.displayName ?? q.agentKey,
2300
2419
  q.itemKey && /* @__PURE__ */ jsxs14(Fragment5, { children: [
2301
2420
  " \xB7 ",
2302
- /* @__PURE__ */ jsx15(ItemLink, { kind: q.itemKind, itemKey: q.itemKey })
2421
+ /* @__PURE__ */ jsx16(ItemLink, { kind: q.itemKind, itemKey: q.itemKey })
2303
2422
  ] })
2304
2423
  ] }),
2305
- /* @__PURE__ */ jsx15(AgentQuestionCard, { question: q, onAnswered: questions.reload })
2424
+ /* @__PURE__ */ jsx16(AgentQuestionCard, { question: q, onAnswered: questions.reload })
2306
2425
  ] }) }, q.id)) }) }) });
2307
2426
  }
2308
2427
  export {
@@ -2327,11 +2446,14 @@ export {
2327
2446
  AgentsAdminPage,
2328
2447
  AgentsTable,
2329
2448
  AskAgentButton,
2449
+ ForgetChatsOption,
2330
2450
  GOING,
2331
2451
  ItemAgentRuns,
2332
2452
  ItemHrefProvider,
2333
2453
  ItemLink,
2454
+ MyAgentChatsPanel,
2334
2455
  NamesField,
2456
+ PersonAgentChatsAction,
2335
2457
  RUN_TONES,
2336
2458
  ScopeAgentsScreen,
2337
2459
  ToolGroupsProvider,
@@ -2340,6 +2462,7 @@ export {
2340
2462
  num,
2341
2463
  useAgentChat,
2342
2464
  useAgentTexts,
2465
+ useDeleteAllChats,
2343
2466
  useNameOf
2344
2467
  };
2345
2468
  //# sourceMappingURL=agent.js.map