@solidxai/core-ui 0.1.22-beta.5 → 0.1.23-beta.1
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/components/core/solid-agent/SolidAgent.module.css +65 -0
- package/dist/components/core/solid-agent/SolidAgentChat.d.ts.map +1 -1
- package/dist/components/core/solid-agent/SolidAgentChat.js +190 -64
- package/dist/components/core/solid-agent/SolidAgentChat.js.map +1 -1
- package/dist/components/core/solid-agent/SolidAgentChat.tsx +201 -5
- package/dist/components/core/solid-agent/agentEvents.d.ts.map +1 -1
- package/dist/components/core/solid-agent/agentEvents.js +21 -18
- package/dist/components/core/solid-agent/agentEvents.js.map +1 -1
- package/dist/components/core/solid-agent/agentEvents.ts +7 -3
- package/dist/components/core/solid-agent/browser/AgentBrowser.module.css +170 -0
- package/dist/components/core/solid-agent/browser/AgentBrowserScreen.d.ts +13 -0
- package/dist/components/core/solid-agent/browser/AgentBrowserScreen.d.ts.map +1 -0
- package/dist/components/core/solid-agent/browser/AgentBrowserScreen.js +138 -0
- package/dist/components/core/solid-agent/browser/AgentBrowserScreen.js.map +1 -0
- package/dist/components/core/solid-agent/browser/AgentBrowserScreen.tsx +162 -0
- package/dist/components/core/solid-agent/browser/DefaultAgentBrowserPanelWidget.d.ts +9 -0
- package/dist/components/core/solid-agent/browser/DefaultAgentBrowserPanelWidget.d.ts.map +1 -0
- package/dist/components/core/solid-agent/browser/DefaultAgentBrowserPanelWidget.js +59 -0
- package/dist/components/core/solid-agent/browser/DefaultAgentBrowserPanelWidget.js.map +1 -0
- package/dist/components/core/solid-agent/browser/DefaultAgentBrowserPanelWidget.tsx +159 -0
- package/dist/components/core/solid-agent/browser/useAgentBrowser.d.ts +6 -0
- package/dist/components/core/solid-agent/browser/useAgentBrowser.d.ts.map +1 -0
- package/dist/components/core/solid-agent/browser/useAgentBrowser.js +37 -0
- package/dist/components/core/solid-agent/browser/useAgentBrowser.js.map +1 -0
- package/dist/components/core/solid-agent/browser/useAgentBrowser.ts +38 -0
- package/dist/components/core/solid-agent/client/agentAttachmentMedia.d.ts +8 -5
- package/dist/components/core/solid-agent/client/agentAttachmentMedia.d.ts.map +1 -1
- package/dist/components/core/solid-agent/client/agentAttachmentMedia.js +71 -23
- package/dist/components/core/solid-agent/client/agentAttachmentMedia.js.map +1 -1
- package/dist/components/core/solid-agent/client/agentAttachmentMedia.ts +52 -25
- package/dist/components/core/solid-agent/client/agentBrowser.d.ts +128 -0
- package/dist/components/core/solid-agent/client/agentBrowser.d.ts.map +1 -0
- package/dist/components/core/solid-agent/client/agentBrowser.js +474 -0
- package/dist/components/core/solid-agent/client/agentBrowser.js.map +1 -0
- package/dist/components/core/solid-agent/client/agentBrowser.ts +342 -0
- package/dist/components/core/solid-agent/client/agentRuntime.d.ts +5 -0
- package/dist/components/core/solid-agent/client/agentRuntime.d.ts.map +1 -1
- package/dist/components/core/solid-agent/client/agentRuntime.js +90 -5
- package/dist/components/core/solid-agent/client/agentRuntime.js.map +1 -1
- package/dist/components/core/solid-agent/client/agentRuntime.ts +37 -1
- package/dist/components/core/solid-agent/client/agentSocket.d.ts +5 -0
- package/dist/components/core/solid-agent/client/agentSocket.d.ts.map +1 -1
- package/dist/components/core/solid-agent/client/agentSocket.js +19 -2
- package/dist/components/core/solid-agent/client/agentSocket.js.map +1 -1
- package/dist/components/core/solid-agent/client/agentSocket.ts +12 -2
- package/dist/components/core/solid-agent/humanReview.d.ts +5 -1
- package/dist/components/core/solid-agent/humanReview.d.ts.map +1 -1
- package/dist/components/core/solid-agent/humanReview.js +35 -4
- package/dist/components/core/solid-agent/humanReview.js.map +1 -1
- package/dist/components/core/solid-agent/humanReview.ts +37 -5
- package/dist/components/core/solid-agent/toolFiles.d.ts +13 -0
- package/dist/components/core/solid-agent/toolFiles.d.ts.map +1 -0
- package/dist/components/core/solid-agent/toolFiles.js +54 -0
- package/dist/components/core/solid-agent/toolFiles.js.map +1 -0
- package/dist/components/core/solid-agent/toolFiles.ts +42 -0
- package/dist/components/core/solid-agent/types.d.ts +57 -0
- package/dist/components/core/solid-agent/types.d.ts.map +1 -1
- package/dist/components/core/solid-agent/types.js.map +1 -1
- package/dist/components/core/solid-agent/types.ts +25 -1
- package/dist/components/core/solid-agent/widgets/AgentToolFiles.d.ts +9 -0
- package/dist/components/core/solid-agent/widgets/AgentToolFiles.d.ts.map +1 -0
- package/dist/components/core/solid-agent/widgets/AgentToolFiles.js +37 -0
- package/dist/components/core/solid-agent/widgets/AgentToolFiles.js.map +1 -0
- package/dist/components/core/solid-agent/widgets/AgentToolFiles.tsx +46 -0
- package/dist/components/core/solid-agent/widgets/DefaultAgentChatHeaderWidget.d.ts +1 -1
- package/dist/components/core/solid-agent/widgets/DefaultAgentChatHeaderWidget.d.ts.map +1 -1
- package/dist/components/core/solid-agent/widgets/DefaultAgentChatHeaderWidget.js +5 -5
- package/dist/components/core/solid-agent/widgets/DefaultAgentChatHeaderWidget.js.map +1 -1
- package/dist/components/core/solid-agent/widgets/DefaultAgentChatHeaderWidget.tsx +2 -6
- package/dist/components/core/solid-agent/widgets/DefaultAgentToolCallWidget.d.ts.map +1 -1
- package/dist/components/core/solid-agent/widgets/DefaultAgentToolCallWidget.js +4 -1
- package/dist/components/core/solid-agent/widgets/DefaultAgentToolCallWidget.js.map +1 -1
- package/dist/components/core/solid-agent/widgets/DefaultAgentToolCallWidget.tsx +5 -0
- package/dist/components/core/solid-agent/widgets/DefaultThinkingChatWidget.d.ts.map +1 -1
- package/dist/components/core/solid-agent/widgets/DefaultThinkingChatWidget.js +2 -3
- package/dist/components/core/solid-agent/widgets/DefaultThinkingChatWidget.js.map +1 -1
- package/dist/components/core/solid-agent/widgets/DefaultThinkingChatWidget.tsx +0 -2
- package/dist/components/core/solid-agent/widgets/solidChatWidgets.module.css +39 -3
- package/dist/helpers/registry.d.ts +2 -0
- package/dist/helpers/registry.d.ts.map +1 -1
- package/dist/helpers/registry.js +6 -0
- package/dist/helpers/registry.js.map +1 -1
- package/dist/helpers/registry.ts +6 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/index.ts +15 -0
- package/dist/redux/features/agentSlice.d.ts +5 -1
- package/dist/redux/features/agentSlice.d.ts.map +1 -1
- package/dist/redux/features/agentSlice.js +12 -1
- package/dist/redux/features/agentSlice.js.map +1 -1
- package/dist/redux/features/agentSlice.ts +11 -0
- package/dist/routes/pages/admin/core/AgentJobsInboxPage.d.ts.map +1 -1
- package/dist/routes/pages/admin/core/AgentJobsInboxPage.js +25 -8
- package/dist/routes/pages/admin/core/AgentJobsInboxPage.js.map +1 -1
- package/dist/routes/pages/admin/core/AgentJobsInboxPage.tsx +28 -4
- package/dist/types/extension-registry.d.ts +2 -0
- package/dist/types/extension-registry.d.ts.map +1 -1
- package/dist/types/extension-registry.js +2 -0
- package/dist/types/extension-registry.js.map +1 -1
- package/dist/types/extension-registry.ts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/solid-core.d.ts +27 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultAgentBrowserPanelWidget.js","sourceRoot":"","sources":["../../../../../src/components/core/solid-agent/browser/DefaultAgentBrowserPanelWidget.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AAEnI,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAE/C,2FAA2F;AAC3F,IAAM,kBAAkB,GAAG,KAAM,CAAC;AAClC,IAAM,eAAe,GAAG,IAAK,CAAC;AAE9B,SA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AChF,QAAQ,EAAE,CAAC,SAAS,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,aAC9E,KAAC,IAAI,IAAC,IAAI,EAAE,EAAE,iBAAc,MAAM,GAAG,EACpC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC,CAAC,cAAc,IACtE,CACZ,IACC,CACT,GACI,IACV,CACN,IACK,CACb,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { useEffect, useState } from \"react\";\nimport { ArrowLeft, ArrowRight, ChevronDown, ChevronUp, Globe, Hand, Maximize2, PanelRightClose, RotateCw, X } from \"lucide-react\";\nimport type { SolidAgentBrowserPanelWidgetProps } from \"../../../../types/solid-core\";\nimport { useSecondTicker } from \"./useAgentBrowser\";\nimport styles from \"./AgentBrowser.module.css\";\n\n/** How long the \"restored your earlier browser session\" note and an error stay visible. */\nconst RESTORED_NOTICE_MS = 15_000;\nconst ERROR_NOTICE_MS = 8_000;\n\nfunction timeLeft(expiresAt: string | null, now: number): string | null {\n if (!expiresAt) return null;\n const end = Date.parse(expiresAt);\n if (Number.isNaN(end)) return null;\n const seconds = Math.max(0, Math.round((end - now) / 1000));\n return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, \"0\")} left`;\n}\n\n/**\n * Default browser panel of the AgentHub chat: live view, tabs, and control of the agent's browser.\n * Register another `agentBrowserPanelWidget` (metadata `agentBrowserPanel: true`, optional `agents`)\n * to replace it; the chat keeps the layout (side pane, stacked panel, large view) and passes the\n * ready-wired `screen`.\n */\nexport const DefaultAgentBrowserPanelWidget = ({\n browser, handoff, layout, connected, collapsed, screen,\n takeControl, giveBack, navigate, navigation, dismissError, onToggleCollapsed, onExpand, onClose,\n}: SolidAgentBrowserPanelWidgetProps) => {\n const human = browser.control.mode === \"human\";\n const live = browser.state === \"live\";\n const [note, setNote] = useState(\"\");\n const [address, setAddress] = useState(browser.url ?? \"\");\n const [editingAddress, setEditingAddress] = useState(false);\n const now = useSecondTicker(!!browser.control.expiresAt || !!browser.restoredAt || !!browser.error);\n\n useEffect(() => {\n if (!editingAddress) setAddress(browser.url ?? \"\");\n }, [browser.url, editingAddress]);\n useEffect(() => {\n if (!human) setNote(\"\");\n }, [human]);\n\n const remaining = human || handoff ? timeLeft(browser.control.expiresAt, now) : null;\n const restored = browser.restoredAt !== null && now - browser.restoredAt < RESTORED_NOTICE_MS;\n const error = browser.error && now - browser.error.at < ERROR_NOTICE_MS ? browser.error : null;\n const reason = browser.control.reason ?? (handoff && handoff.toolName !== \"browser_takeover\" ? handoff.question : null);\n const stateLabel = human ? \"You have control\"\n : browser.control.pending ? \"Waiting for the agent\"\n : browser.state === \"starting\" ? \"Starting\" : live ? \"Agent in control\" : \"Not running\";\n const tabs = browser.tabs.length > 1 ? browser.tabs : [];\n\n return (\n <section className={`${styles.panel} ${styles[`panel_${layout}`] ?? \"\"}`} aria-label=\"Agent browser\">\n <header className={styles.panelHeader}>\n <Globe size={14} className={styles.panelIcon} aria-hidden=\"true\" />\n <span className={`${styles.stateBadge} ${human ? styles.stateHuman : live ? styles.stateLive : \"\"}`}>{stateLabel}</span>\n <span className={styles.panelTitle} title={browser.url ?? undefined}>{browser.title || browser.url || \"Agent browser\"}</span>\n {remaining && <span className={styles.timer} title=\"Control returns to the agent when this runs out\">{remaining}</span>}\n {onExpand && (\n <button type=\"button\" className={styles.iconBtn} title=\"Open in a larger view\" aria-label=\"Open the browser in a larger view\" onClick={onExpand}>\n <Maximize2 size={14} />\n </button>\n )}\n {onToggleCollapsed && layout === \"stacked\" && (\n <button type=\"button\" className={styles.iconBtn} title={collapsed ? \"Show the browser\" : \"Collapse the browser\"}\n aria-label={collapsed ? \"Show the browser\" : \"Collapse the browser\"} aria-expanded={!collapsed} onClick={onToggleCollapsed}>\n {collapsed ? <ChevronDown size={15} /> : <ChevronUp size={15} />}\n </button>\n )}\n {onToggleCollapsed && layout === \"side\" && (\n <button type=\"button\" className={styles.iconBtn} title=\"Hide the browser\" aria-label=\"Hide the browser\" onClick={onToggleCollapsed}>\n <PanelRightClose size={15} />\n </button>\n )}\n {onClose && (\n <button type=\"button\" className={styles.iconBtn} title=\"Close the larger view\" aria-label=\"Close the larger view\" onClick={onClose}>\n <X size={15} />\n </button>\n )}\n </header>\n\n {!collapsed && (\n <>\n {tabs.length > 0 && (\n <ul className={styles.tabs} aria-label=\"Browser tabs\">\n {tabs.map((tab) => (\n <li key={tab.tab} className={tab.tab === browser.activeTab ? styles.tabActive : styles.tab} title={tab.url ?? undefined}\n aria-current={tab.tab === browser.activeTab ? \"page\" : undefined}>\n {tab.title || tab.url || tab.tab}\n </li>\n ))}\n </ul>\n )}\n\n {human && (\n <form className={styles.navBar} onSubmit={(event) => { event.preventDefault(); if (navigate(address)) setEditingAddress(false); }}>\n <button type=\"button\" className={styles.iconBtn} title=\"Back\" aria-label=\"Back\" onClick={() => navigation(\"back\")}><ArrowLeft size={14} /></button>\n <button type=\"button\" className={styles.iconBtn} title=\"Forward\" aria-label=\"Forward\" onClick={() => navigation(\"forward\")}><ArrowRight size={14} /></button>\n <button type=\"button\" className={styles.iconBtn} title=\"Reload\" aria-label=\"Reload\" onClick={() => navigation(\"refresh\")}><RotateCw size={13} /></button>\n <input className={styles.address} value={address} aria-label=\"Address\" spellCheck={false} autoComplete=\"off\"\n onFocus={() => setEditingAddress(true)} onBlur={() => setEditingAddress(false)}\n onChange={(event) => setAddress(event.target.value)} />\n </form>\n )}\n\n {restored && <div className={styles.notice} role=\"status\">The agent reopened your earlier browser session, so sign-ins from last time are still there.</div>}\n {reason && !human && handoff && <div className={styles.callout}><strong>The agent asks:</strong> {reason}</div>}\n {reason && human && browser.control.reason && <div className={styles.callout}><strong>The agent asked:</strong> {reason}</div>}\n\n {screen}\n\n {error && (\n <div className={styles.error} role=\"alert\">\n <span>{error.message}</span>\n <button type=\"button\" className={styles.linkBtn} onClick={dismissError}>Dismiss</button>\n </div>\n )}\n\n <footer className={styles.controls}>\n {human ? (\n <>\n <textarea className={styles.note} rows={2} value={note} maxLength={2000}\n placeholder=\"Tell the agent what you did (optional)\" aria-label=\"Note for the agent\"\n onChange={(event) => setNote(event.target.value)} />\n <div className={styles.controlRow}>\n <span className={styles.hint}>Your mouse and keyboard go to the page.</span>\n <button type=\"button\" className={`${styles.btn} ${styles.btnPrimary}`} disabled={!connected}\n onClick={() => { if (giveBack(note)) setNote(\"\"); }}>\n Give back control\n </button>\n </div>\n </>\n ) : (\n <div className={styles.controlRow}>\n <span className={styles.hint}>\n {!browser.controllable ? \"Watching the agent's browser.\"\n : handoff ? \"The agent is waiting for you in the browser.\" : browser.control.pending\n ? \"You get the browser when the agent finishes its current step.\" : \"Watch the agent work, or take over the browser.\"}\n </span>\n {handoff && (\n <button type=\"button\" className={styles.btn} disabled={!connected} onClick={() => giveBack()}>\n Continue without taking control\n </button>\n )}\n {browser.controllable && (\n <button type=\"button\" className={`${styles.btn} ${handoff ? styles.btnPrimary : \"\"}`}\n disabled={!connected || !live || browser.control.pending} onClick={takeControl}>\n <Hand size={13} aria-hidden=\"true\" />\n {browser.control.pending ? \"Waiting for the agent's step…\" : \"Take control\"}\n </button>\n )}\n </div>\n )}\n </footer>\n </>\n )}\n </section>\n );\n};\n"]}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { ArrowLeft, ArrowRight, ChevronDown, ChevronUp, Globe, Hand, Maximize2, PanelRightClose, RotateCw, X } from "lucide-react";
|
|
3
|
+
import type { SolidAgentBrowserPanelWidgetProps } from "../../../../types/solid-core";
|
|
4
|
+
import { useSecondTicker } from "./useAgentBrowser";
|
|
5
|
+
import styles from "./AgentBrowser.module.css";
|
|
6
|
+
|
|
7
|
+
/** How long the "restored your earlier browser session" note and an error stay visible. */
|
|
8
|
+
const RESTORED_NOTICE_MS = 15_000;
|
|
9
|
+
const ERROR_NOTICE_MS = 8_000;
|
|
10
|
+
|
|
11
|
+
function timeLeft(expiresAt: string | null, now: number): string | null {
|
|
12
|
+
if (!expiresAt) return null;
|
|
13
|
+
const end = Date.parse(expiresAt);
|
|
14
|
+
if (Number.isNaN(end)) return null;
|
|
15
|
+
const seconds = Math.max(0, Math.round((end - now) / 1000));
|
|
16
|
+
return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")} left`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Default browser panel of the AgentHub chat: live view, tabs, and control of the agent's browser.
|
|
21
|
+
* Register another `agentBrowserPanelWidget` (metadata `agentBrowserPanel: true`, optional `agents`)
|
|
22
|
+
* to replace it; the chat keeps the layout (side pane, stacked panel, large view) and passes the
|
|
23
|
+
* ready-wired `screen`.
|
|
24
|
+
*/
|
|
25
|
+
export const DefaultAgentBrowserPanelWidget = ({
|
|
26
|
+
browser, handoff, layout, connected, collapsed, screen,
|
|
27
|
+
takeControl, giveBack, navigate, navigation, dismissError, onToggleCollapsed, onExpand, onClose,
|
|
28
|
+
}: SolidAgentBrowserPanelWidgetProps) => {
|
|
29
|
+
const human = browser.control.mode === "human";
|
|
30
|
+
const live = browser.state === "live";
|
|
31
|
+
const [note, setNote] = useState("");
|
|
32
|
+
const [address, setAddress] = useState(browser.url ?? "");
|
|
33
|
+
const [editingAddress, setEditingAddress] = useState(false);
|
|
34
|
+
const now = useSecondTicker(!!browser.control.expiresAt || !!browser.restoredAt || !!browser.error);
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (!editingAddress) setAddress(browser.url ?? "");
|
|
38
|
+
}, [browser.url, editingAddress]);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!human) setNote("");
|
|
41
|
+
}, [human]);
|
|
42
|
+
|
|
43
|
+
const remaining = human || handoff ? timeLeft(browser.control.expiresAt, now) : null;
|
|
44
|
+
const restored = browser.restoredAt !== null && now - browser.restoredAt < RESTORED_NOTICE_MS;
|
|
45
|
+
const error = browser.error && now - browser.error.at < ERROR_NOTICE_MS ? browser.error : null;
|
|
46
|
+
const reason = browser.control.reason ?? (handoff && handoff.toolName !== "browser_takeover" ? handoff.question : null);
|
|
47
|
+
const stateLabel = human ? "You have control"
|
|
48
|
+
: browser.control.pending ? "Waiting for the agent"
|
|
49
|
+
: browser.state === "starting" ? "Starting" : live ? "Agent in control" : "Not running";
|
|
50
|
+
const tabs = browser.tabs.length > 1 ? browser.tabs : [];
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<section className={`${styles.panel} ${styles[`panel_${layout}`] ?? ""}`} aria-label="Agent browser">
|
|
54
|
+
<header className={styles.panelHeader}>
|
|
55
|
+
<Globe size={14} className={styles.panelIcon} aria-hidden="true" />
|
|
56
|
+
<span className={`${styles.stateBadge} ${human ? styles.stateHuman : live ? styles.stateLive : ""}`}>{stateLabel}</span>
|
|
57
|
+
<span className={styles.panelTitle} title={browser.url ?? undefined}>{browser.title || browser.url || "Agent browser"}</span>
|
|
58
|
+
{remaining && <span className={styles.timer} title="Control returns to the agent when this runs out">{remaining}</span>}
|
|
59
|
+
{onExpand && (
|
|
60
|
+
<button type="button" className={styles.iconBtn} title="Open in a larger view" aria-label="Open the browser in a larger view" onClick={onExpand}>
|
|
61
|
+
<Maximize2 size={14} />
|
|
62
|
+
</button>
|
|
63
|
+
)}
|
|
64
|
+
{onToggleCollapsed && layout === "stacked" && (
|
|
65
|
+
<button type="button" className={styles.iconBtn} title={collapsed ? "Show the browser" : "Collapse the browser"}
|
|
66
|
+
aria-label={collapsed ? "Show the browser" : "Collapse the browser"} aria-expanded={!collapsed} onClick={onToggleCollapsed}>
|
|
67
|
+
{collapsed ? <ChevronDown size={15} /> : <ChevronUp size={15} />}
|
|
68
|
+
</button>
|
|
69
|
+
)}
|
|
70
|
+
{onToggleCollapsed && layout === "side" && (
|
|
71
|
+
<button type="button" className={styles.iconBtn} title="Hide the browser" aria-label="Hide the browser" onClick={onToggleCollapsed}>
|
|
72
|
+
<PanelRightClose size={15} />
|
|
73
|
+
</button>
|
|
74
|
+
)}
|
|
75
|
+
{onClose && (
|
|
76
|
+
<button type="button" className={styles.iconBtn} title="Close the larger view" aria-label="Close the larger view" onClick={onClose}>
|
|
77
|
+
<X size={15} />
|
|
78
|
+
</button>
|
|
79
|
+
)}
|
|
80
|
+
</header>
|
|
81
|
+
|
|
82
|
+
{!collapsed && (
|
|
83
|
+
<>
|
|
84
|
+
{tabs.length > 0 && (
|
|
85
|
+
<ul className={styles.tabs} aria-label="Browser tabs">
|
|
86
|
+
{tabs.map((tab) => (
|
|
87
|
+
<li key={tab.tab} className={tab.tab === browser.activeTab ? styles.tabActive : styles.tab} title={tab.url ?? undefined}
|
|
88
|
+
aria-current={tab.tab === browser.activeTab ? "page" : undefined}>
|
|
89
|
+
{tab.title || tab.url || tab.tab}
|
|
90
|
+
</li>
|
|
91
|
+
))}
|
|
92
|
+
</ul>
|
|
93
|
+
)}
|
|
94
|
+
|
|
95
|
+
{human && (
|
|
96
|
+
<form className={styles.navBar} onSubmit={(event) => { event.preventDefault(); if (navigate(address)) setEditingAddress(false); }}>
|
|
97
|
+
<button type="button" className={styles.iconBtn} title="Back" aria-label="Back" onClick={() => navigation("back")}><ArrowLeft size={14} /></button>
|
|
98
|
+
<button type="button" className={styles.iconBtn} title="Forward" aria-label="Forward" onClick={() => navigation("forward")}><ArrowRight size={14} /></button>
|
|
99
|
+
<button type="button" className={styles.iconBtn} title="Reload" aria-label="Reload" onClick={() => navigation("refresh")}><RotateCw size={13} /></button>
|
|
100
|
+
<input className={styles.address} value={address} aria-label="Address" spellCheck={false} autoComplete="off"
|
|
101
|
+
onFocus={() => setEditingAddress(true)} onBlur={() => setEditingAddress(false)}
|
|
102
|
+
onChange={(event) => setAddress(event.target.value)} />
|
|
103
|
+
</form>
|
|
104
|
+
)}
|
|
105
|
+
|
|
106
|
+
{restored && <div className={styles.notice} role="status">The agent reopened your earlier browser session, so sign-ins from last time are still there.</div>}
|
|
107
|
+
{reason && !human && handoff && <div className={styles.callout}><strong>The agent asks:</strong> {reason}</div>}
|
|
108
|
+
{reason && human && browser.control.reason && <div className={styles.callout}><strong>The agent asked:</strong> {reason}</div>}
|
|
109
|
+
|
|
110
|
+
{screen}
|
|
111
|
+
|
|
112
|
+
{error && (
|
|
113
|
+
<div className={styles.error} role="alert">
|
|
114
|
+
<span>{error.message}</span>
|
|
115
|
+
<button type="button" className={styles.linkBtn} onClick={dismissError}>Dismiss</button>
|
|
116
|
+
</div>
|
|
117
|
+
)}
|
|
118
|
+
|
|
119
|
+
<footer className={styles.controls}>
|
|
120
|
+
{human ? (
|
|
121
|
+
<>
|
|
122
|
+
<textarea className={styles.note} rows={2} value={note} maxLength={2000}
|
|
123
|
+
placeholder="Tell the agent what you did (optional)" aria-label="Note for the agent"
|
|
124
|
+
onChange={(event) => setNote(event.target.value)} />
|
|
125
|
+
<div className={styles.controlRow}>
|
|
126
|
+
<span className={styles.hint}>Your mouse and keyboard go to the page.</span>
|
|
127
|
+
<button type="button" className={`${styles.btn} ${styles.btnPrimary}`} disabled={!connected}
|
|
128
|
+
onClick={() => { if (giveBack(note)) setNote(""); }}>
|
|
129
|
+
Give back control
|
|
130
|
+
</button>
|
|
131
|
+
</div>
|
|
132
|
+
</>
|
|
133
|
+
) : (
|
|
134
|
+
<div className={styles.controlRow}>
|
|
135
|
+
<span className={styles.hint}>
|
|
136
|
+
{!browser.controllable ? "Watching the agent's browser."
|
|
137
|
+
: handoff ? "The agent is waiting for you in the browser." : browser.control.pending
|
|
138
|
+
? "You get the browser when the agent finishes its current step." : "Watch the agent work, or take over the browser."}
|
|
139
|
+
</span>
|
|
140
|
+
{handoff && (
|
|
141
|
+
<button type="button" className={styles.btn} disabled={!connected} onClick={() => giveBack()}>
|
|
142
|
+
Continue without taking control
|
|
143
|
+
</button>
|
|
144
|
+
)}
|
|
145
|
+
{browser.controllable && (
|
|
146
|
+
<button type="button" className={`${styles.btn} ${handoff ? styles.btnPrimary : ""}`}
|
|
147
|
+
disabled={!connected || !live || browser.control.pending} onClick={takeControl}>
|
|
148
|
+
<Hand size={13} aria-hidden="true" />
|
|
149
|
+
{browser.control.pending ? "Waiting for the agent's step…" : "Take control"}
|
|
150
|
+
</button>
|
|
151
|
+
)}
|
|
152
|
+
</div>
|
|
153
|
+
)}
|
|
154
|
+
</footer>
|
|
155
|
+
</>
|
|
156
|
+
)}
|
|
157
|
+
</section>
|
|
158
|
+
);
|
|
159
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AgentBrowserChannel, AgentBrowserView } from "../client/agentBrowser";
|
|
2
|
+
/** The browser view of a chat's runtime; an empty, unavailable view before the runtime exists. */
|
|
3
|
+
export declare function useAgentBrowser(channel: AgentBrowserChannel | null | undefined): AgentBrowserView;
|
|
4
|
+
/** The current time, refreshed every second while `active` (countdowns and short-lived notices). */
|
|
5
|
+
export declare function useSecondTicker(active: boolean): number;
|
|
6
|
+
//# sourceMappingURL=useAgentBrowser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAgentBrowser.d.ts","sourceRoot":"","sources":["../../../../../src/components/core/solid-agent/browser/useAgentBrowser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAqBpF,kGAAkG;AAClG,wBAAgB,eAAe,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,GAAG,SAAS,GAAG,gBAAgB,CAEjG;AAED,oGAAoG;AACpG,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CASvD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useEffect, useState, useSyncExternalStore } from "react";
|
|
2
|
+
var EMPTY_VIEW = {
|
|
3
|
+
sessionId: null,
|
|
4
|
+
available: false,
|
|
5
|
+
state: "none",
|
|
6
|
+
viewport: { width: 1280, height: 800 },
|
|
7
|
+
url: null,
|
|
8
|
+
title: null,
|
|
9
|
+
tabs: [],
|
|
10
|
+
activeTab: null,
|
|
11
|
+
control: { mode: "agent", pending: false, reason: null, expiresAt: null },
|
|
12
|
+
restoredAt: null,
|
|
13
|
+
watching: false,
|
|
14
|
+
hasFrame: false,
|
|
15
|
+
error: null,
|
|
16
|
+
controllable: true,
|
|
17
|
+
};
|
|
18
|
+
var noSubscription = function () { return function () { }; };
|
|
19
|
+
var emptyView = function () { return EMPTY_VIEW; };
|
|
20
|
+
/** The browser view of a chat's runtime; an empty, unavailable view before the runtime exists. */
|
|
21
|
+
export function useAgentBrowser(channel) {
|
|
22
|
+
var _a, _b, _c;
|
|
23
|
+
return useSyncExternalStore((_a = channel === null || channel === void 0 ? void 0 : channel.subscribe) !== null && _a !== void 0 ? _a : noSubscription, (_b = channel === null || channel === void 0 ? void 0 : channel.getView) !== null && _b !== void 0 ? _b : emptyView, (_c = channel === null || channel === void 0 ? void 0 : channel.getView) !== null && _c !== void 0 ? _c : emptyView);
|
|
24
|
+
}
|
|
25
|
+
/** The current time, refreshed every second while `active` (countdowns and short-lived notices). */
|
|
26
|
+
export function useSecondTicker(active) {
|
|
27
|
+
var _a = useState(function () { return Date.now(); }), now = _a[0], setNow = _a[1];
|
|
28
|
+
useEffect(function () {
|
|
29
|
+
if (!active)
|
|
30
|
+
return;
|
|
31
|
+
setNow(Date.now());
|
|
32
|
+
var timer = window.setInterval(function () { return setNow(Date.now()); }, 1000);
|
|
33
|
+
return function () { return window.clearInterval(timer); };
|
|
34
|
+
}, [active]);
|
|
35
|
+
return now;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=useAgentBrowser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAgentBrowser.js","sourceRoot":"","sources":["../../../../../src/components/core/solid-agent/browser/useAgentBrowser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAGlE,IAAM,UAAU,GAAq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MAAM,CAAC,WAAW,CAAC,cAAM,OAAA,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAlB,CAAkB,EAAE,IAAI,CAAC,CAAC;QACjE,OAAO,cAAM,OAAA,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,EAA3B,CAA2B,CAAC;IAC7C,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IACb,OAAO,GAAG,CAAC;AACf,CAAC","sourcesContent":["import { useEffect, useState, useSyncExternalStore } from \"react\";\nimport type { AgentBrowserChannel, AgentBrowserView } from \"../client/agentBrowser\";\n\nconst EMPTY_VIEW: AgentBrowserView = {\n sessionId: null,\n available: false,\n state: \"none\",\n viewport: { width: 1280, height: 800 },\n url: null,\n title: null,\n tabs: [],\n activeTab: null,\n control: { mode: \"agent\", pending: false, reason: null, expiresAt: null },\n restoredAt: null,\n watching: false,\n hasFrame: false,\n error: null,\n controllable: true,\n};\nconst noSubscription = () => () => {};\nconst emptyView = () => EMPTY_VIEW;\n\n/** The browser view of a chat's runtime; an empty, unavailable view before the runtime exists. */\nexport function useAgentBrowser(channel: AgentBrowserChannel | null | undefined): AgentBrowserView {\n return useSyncExternalStore(channel?.subscribe ?? noSubscription, channel?.getView ?? emptyView, channel?.getView ?? emptyView);\n}\n\n/** The current time, refreshed every second while `active` (countdowns and short-lived notices). */\nexport function useSecondTicker(active: boolean): number {\n const [now, setNow] = useState(() => Date.now());\n useEffect(() => {\n if (!active) return;\n setNow(Date.now());\n const timer = window.setInterval(() => setNow(Date.now()), 1000);\n return () => window.clearInterval(timer);\n }, [active]);\n return now;\n}\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useEffect, useState, useSyncExternalStore } from "react";
|
|
2
|
+
import type { AgentBrowserChannel, AgentBrowserView } from "../client/agentBrowser";
|
|
3
|
+
|
|
4
|
+
const EMPTY_VIEW: AgentBrowserView = {
|
|
5
|
+
sessionId: null,
|
|
6
|
+
available: false,
|
|
7
|
+
state: "none",
|
|
8
|
+
viewport: { width: 1280, height: 800 },
|
|
9
|
+
url: null,
|
|
10
|
+
title: null,
|
|
11
|
+
tabs: [],
|
|
12
|
+
activeTab: null,
|
|
13
|
+
control: { mode: "agent", pending: false, reason: null, expiresAt: null },
|
|
14
|
+
restoredAt: null,
|
|
15
|
+
watching: false,
|
|
16
|
+
hasFrame: false,
|
|
17
|
+
error: null,
|
|
18
|
+
controllable: true,
|
|
19
|
+
};
|
|
20
|
+
const noSubscription = () => () => {};
|
|
21
|
+
const emptyView = () => EMPTY_VIEW;
|
|
22
|
+
|
|
23
|
+
/** The browser view of a chat's runtime; an empty, unavailable view before the runtime exists. */
|
|
24
|
+
export function useAgentBrowser(channel: AgentBrowserChannel | null | undefined): AgentBrowserView {
|
|
25
|
+
return useSyncExternalStore(channel?.subscribe ?? noSubscription, channel?.getView ?? emptyView, channel?.getView ?? emptyView);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The current time, refreshed every second while `active` (countdowns and short-lived notices). */
|
|
29
|
+
export function useSecondTicker(active: boolean): number {
|
|
30
|
+
const [now, setNow] = useState(() => Date.now());
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (!active) return;
|
|
33
|
+
setNow(Date.now());
|
|
34
|
+
const timer = window.setInterval(() => setNow(Date.now()), 1000);
|
|
35
|
+
return () => window.clearInterval(timer);
|
|
36
|
+
}, [active]);
|
|
37
|
+
return now;
|
|
38
|
+
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AgentToolFileMedia } from "../toolFiles";
|
|
2
|
+
import { type AgentChatItem } from "../types";
|
|
3
|
+
/** URLs of the files a tool returned, stored on its ToolResult agentEvent. Empty while SolidX has not linked them yet. */
|
|
4
|
+
export declare function fetchToolFileMedia(agentEventId: string | number): Promise<AgentToolFileMedia[]>;
|
|
2
5
|
/**
|
|
3
|
-
* Replayed user messages only know their attachments' names
|
|
4
|
-
*
|
|
5
|
-
* such event in one request and put them
|
|
6
|
-
* when nothing is stored or the request fails.
|
|
6
|
+
* Replayed user messages only know their attachments' names, and tool calls only the names of the
|
|
7
|
+
* files the tool returned. The files themselves are stored on the agentEvent (media field
|
|
8
|
+
* `attachments`) by the agent, so fetch fresh URLs for every such event in one request and put them
|
|
9
|
+
* on the thread items. Items are returned unchanged when nothing is stored or the request fails.
|
|
7
10
|
*/
|
|
8
11
|
export declare function resolveAttachmentMedia(items: AgentChatItem[]): Promise<AgentChatItem[]>;
|
|
9
12
|
//# sourceMappingURL=agentAttachmentMedia.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentAttachmentMedia.d.ts","sourceRoot":"","sources":["../../../../../src/components/core/solid-agent/client/agentAttachmentMedia.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"agentAttachmentMedia.d.ts","sourceRoot":"","sources":["../../../../../src/components/core/solid-agent/client/agentAttachmentMedia.ts"],"names":[],"mappings":"AAGA,OAAO,EAAsB,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAA6C,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AA+CzF,0HAA0H;AAC1H,wBAAsB,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAMrG;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CA6B7F"}
|
|
@@ -48,6 +48,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
48
48
|
import qs from "qs";
|
|
49
49
|
import { solidGet } from "../../../../http/solidHttp";
|
|
50
50
|
import { normalizeAssetUrl } from "../../../../helpers/assetUrl";
|
|
51
|
+
import { mergeToolFileMedia } from "../toolFiles";
|
|
52
|
+
import { AgentEventTypes } from "../types";
|
|
51
53
|
/** Media field on the agentEvent model that stores chat attachments (solid-core metadata). */
|
|
52
54
|
var ATTACHMENTS_FIELD = "attachments";
|
|
53
55
|
/** Solid's response interceptor wraps bodies as { data: <payload> }; find the records array. */
|
|
@@ -60,15 +62,73 @@ function unwrapRecords(body) {
|
|
|
60
62
|
}
|
|
61
63
|
return [];
|
|
62
64
|
}
|
|
65
|
+
/** The stored media of each agentEvent, by event id. Throws when SolidX cannot be asked. */
|
|
66
|
+
function fetchEventMedia(eventIds) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
68
|
+
var query, response, mediaByEvent;
|
|
69
|
+
return __generator(this, function (_a) {
|
|
70
|
+
switch (_a.label) {
|
|
71
|
+
case 0:
|
|
72
|
+
query = qs.stringify({
|
|
73
|
+
filters: { id: { $in: eventIds.map(Number) } },
|
|
74
|
+
populateMedia: [ATTACHMENTS_FIELD],
|
|
75
|
+
fields: ["id"],
|
|
76
|
+
limit: eventIds.length,
|
|
77
|
+
offset: 0,
|
|
78
|
+
}, { encodeValuesOnly: true });
|
|
79
|
+
return [4 /*yield*/, solidGet("/agent-event?".concat(query))];
|
|
80
|
+
case 1:
|
|
81
|
+
response = _a.sent();
|
|
82
|
+
mediaByEvent = new Map();
|
|
83
|
+
unwrapRecords(response === null || response === void 0 ? void 0 : response.data).forEach(function (record) {
|
|
84
|
+
var _a, _b;
|
|
85
|
+
var media = (_b = (_a = record === null || record === void 0 ? void 0 : record._media) === null || _a === void 0 ? void 0 : _a[ATTACHMENTS_FIELD]) !== null && _b !== void 0 ? _b : [];
|
|
86
|
+
if (media.length)
|
|
87
|
+
mediaByEvent.set(String(record.id), media);
|
|
88
|
+
});
|
|
89
|
+
return [2 /*return*/, mediaByEvent];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function toolFileMedia(media) {
|
|
95
|
+
return media.flatMap(function (file) {
|
|
96
|
+
var url = normalizeAssetUrl(file._full_url);
|
|
97
|
+
if (!url)
|
|
98
|
+
return [];
|
|
99
|
+
var id = Number(file.id);
|
|
100
|
+
return [__assign(__assign(__assign({}, (Number.isInteger(id) ? { id: id } : {})), (file.originalFileName ? { name: file.originalFileName } : {})), { url: url })];
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/** URLs of the files a tool returned, stored on its ToolResult agentEvent. Empty while SolidX has not linked them yet. */
|
|
104
|
+
export function fetchToolFileMedia(agentEventId) {
|
|
105
|
+
var _a;
|
|
106
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
107
|
+
var _b, _c;
|
|
108
|
+
return __generator(this, function (_d) {
|
|
109
|
+
switch (_d.label) {
|
|
110
|
+
case 0:
|
|
111
|
+
_d.trys.push([0, 2, , 3]);
|
|
112
|
+
_b = toolFileMedia;
|
|
113
|
+
return [4 /*yield*/, fetchEventMedia([agentEventId])];
|
|
114
|
+
case 1: return [2 /*return*/, _b.apply(void 0, [(_a = (_d.sent()).get(String(agentEventId))) !== null && _a !== void 0 ? _a : []])];
|
|
115
|
+
case 2:
|
|
116
|
+
_c = _d.sent();
|
|
117
|
+
return [2 /*return*/, []];
|
|
118
|
+
case 3: return [2 /*return*/];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
}
|
|
63
123
|
/**
|
|
64
|
-
* Replayed user messages only know their attachments' names
|
|
65
|
-
*
|
|
66
|
-
* such event in one request and put them
|
|
67
|
-
* when nothing is stored or the request fails.
|
|
124
|
+
* Replayed user messages only know their attachments' names, and tool calls only the names of the
|
|
125
|
+
* files the tool returned. The files themselves are stored on the agentEvent (media field
|
|
126
|
+
* `attachments`) by the agent, so fetch fresh URLs for every such event in one request and put them
|
|
127
|
+
* on the thread items. Items are returned unchanged when nothing is stored or the request fails.
|
|
68
128
|
*/
|
|
69
129
|
export function resolveAttachmentMedia(items) {
|
|
70
130
|
return __awaiter(this, void 0, void 0, function () {
|
|
71
|
-
var eventIds,
|
|
131
|
+
var eventIds, mediaByEvent, _a;
|
|
72
132
|
return __generator(this, function (_b) {
|
|
73
133
|
switch (_b.label) {
|
|
74
134
|
case 0:
|
|
@@ -77,33 +137,17 @@ export function resolveAttachmentMedia(items) {
|
|
|
77
137
|
.filter(function (id) { return id !== undefined && id !== null && id !== ""; });
|
|
78
138
|
if (!eventIds.length)
|
|
79
139
|
return [2 /*return*/, items];
|
|
80
|
-
records = [];
|
|
81
140
|
_b.label = 1;
|
|
82
141
|
case 1:
|
|
83
142
|
_b.trys.push([1, 3, , 4]);
|
|
84
|
-
|
|
85
|
-
filters: { id: { $in: eventIds.map(Number) } },
|
|
86
|
-
populateMedia: [ATTACHMENTS_FIELD],
|
|
87
|
-
fields: ["id"],
|
|
88
|
-
limit: eventIds.length,
|
|
89
|
-
offset: 0,
|
|
90
|
-
}, { encodeValuesOnly: true });
|
|
91
|
-
return [4 /*yield*/, solidGet("/agent-event?".concat(query))];
|
|
143
|
+
return [4 /*yield*/, fetchEventMedia(eventIds)];
|
|
92
144
|
case 2:
|
|
93
|
-
|
|
94
|
-
records = unwrapRecords(response === null || response === void 0 ? void 0 : response.data);
|
|
145
|
+
mediaByEvent = _b.sent();
|
|
95
146
|
return [3 /*break*/, 4];
|
|
96
147
|
case 3:
|
|
97
148
|
_a = _b.sent();
|
|
98
149
|
return [2 /*return*/, items];
|
|
99
150
|
case 4:
|
|
100
|
-
mediaByEvent = new Map();
|
|
101
|
-
records.forEach(function (record) {
|
|
102
|
-
var _a, _b;
|
|
103
|
-
var media = (_b = (_a = record === null || record === void 0 ? void 0 : record._media) === null || _a === void 0 ? void 0 : _a[ATTACHMENTS_FIELD]) !== null && _b !== void 0 ? _b : [];
|
|
104
|
-
if (media.length)
|
|
105
|
-
mediaByEvent.set(String(record.id), media);
|
|
106
|
-
});
|
|
107
151
|
if (!mediaByEvent.size)
|
|
108
152
|
return [2 /*return*/, items];
|
|
109
153
|
return [2 /*return*/, items.map(function (item) {
|
|
@@ -111,6 +155,10 @@ export function resolveAttachmentMedia(items) {
|
|
|
111
155
|
var media = mediaByEvent.get(String((_a = item.eventData) === null || _a === void 0 ? void 0 : _a.agentEventId));
|
|
112
156
|
if (!media)
|
|
113
157
|
return item;
|
|
158
|
+
if (item.eventType === AgentEventTypes.toolCalling) {
|
|
159
|
+
var files = Array.isArray(item.eventData.files) ? item.eventData.files : [];
|
|
160
|
+
return __assign(__assign({}, item), { eventData: __assign(__assign({}, item.eventData), { files: mergeToolFileMedia(files, toolFileMedia(media)) }) });
|
|
161
|
+
}
|
|
114
162
|
var attachments = media.map(function (file) {
|
|
115
163
|
var _a, _b, _c;
|
|
116
164
|
return ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentAttachmentMedia.js","sourceRoot":"","sources":["../../../../../src/components/core/solid-agent/client/agentAttachmentMedia.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"agentAttachmentMedia.js","sourceRoot":"","sources":["../../../../../src/components/core/solid-agent/client/agentAttachmentMedia.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAA2B,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAgD,MAAM,UAAU,CAAC;AAEzF,8FAA8F;AAC9F,IAAM,iBAAiB,GAAG,aAAa,CAAC;AAIxC,gGAAgG;AAChG,SAAS,aAAa,CAAC,IAAS;IAC5B,IAAI,IAAI,GAAG,IAAI,C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AAI,CAAC,SAAS,KAAE,WAAW,aAAA,OAAK;wBACtE,CAAC,CAAC,EAAC;;;;CACN","sourcesContent":["import qs from \"qs\";\nimport { solidGet } from \"../../../../http/solidHttp\";\nimport { normalizeAssetUrl } from \"../../../../helpers/assetUrl\";\nimport { mergeToolFileMedia, type AgentToolFileMedia } from \"../toolFiles\";\nimport { AgentEventTypes, type AgentAttachmentMeta, type AgentChatItem } from \"../types\";\n\n/** Media field on the agentEvent model that stores chat attachments (solid-core metadata). */\nconst ATTACHMENTS_FIELD = \"attachments\";\n\ntype StoredMedia = { id?: number | string; _full_url?: string; originalFileName?: string; mimeType?: string; fileSize?: number };\n\n/** Solid's response interceptor wraps bodies as { data: <payload> }; find the records array. */\nfunction unwrapRecords(body: any): any[] {\n let node = body;\n for (let i = 0; i < 4 && node; i++) {\n if (Array.isArray(node.records)) return node.records;\n node = node.data;\n }\n return [];\n}\n\n/** The stored media of each agentEvent, by event id. Throws when SolidX cannot be asked. */\nasync function fetchEventMedia(eventIds: Array<string | number>): Promise<Map<string, StoredMedia[]>> {\n const query = qs.stringify(\n {\n filters: { id: { $in: eventIds.map(Number) } },\n populateMedia: [ATTACHMENTS_FIELD],\n fields: [\"id\"],\n limit: eventIds.length,\n offset: 0,\n },\n { encodeValuesOnly: true },\n );\n const response = await solidGet(`/agent-event?${query}`);\n const mediaByEvent = new Map<string, StoredMedia[]>();\n unwrapRecords(response?.data).forEach((record) => {\n const media: StoredMedia[] = record?._media?.[ATTACHMENTS_FIELD] ?? [];\n if (media.length) mediaByEvent.set(String(record.id), media);\n });\n return mediaByEvent;\n}\n\nfunction toolFileMedia(media: StoredMedia[]): AgentToolFileMedia[] {\n return media.flatMap((file) => {\n const url = normalizeAssetUrl(file._full_url);\n if (!url) return [];\n const id = Number(file.id);\n return [{ ...(Number.isInteger(id) ? { id } : {}), ...(file.originalFileName ? { name: file.originalFileName } : {}), url }];\n });\n}\n\n/** URLs of the files a tool returned, stored on its ToolResult agentEvent. Empty while SolidX has not linked them yet. */\nexport async function fetchToolFileMedia(agentEventId: string | number): Promise<AgentToolFileMedia[]> {\n try {\n return toolFileMedia((await fetchEventMedia([agentEventId])).get(String(agentEventId)) ?? []);\n } catch {\n return [];\n }\n}\n\n/**\n * Replayed user messages only know their attachments' names, and tool calls only the names of the\n * files the tool returned. The files themselves are stored on the agentEvent (media field\n * `attachments`) by the agent, so fetch fresh URLs for every such event in one request and put them\n * on the thread items. Items are returned unchanged when nothing is stored or the request fails.\n */\nexport async function resolveAttachmentMedia(items: AgentChatItem[]): Promise<AgentChatItem[]> {\n const eventIds = items\n .map((item) => item.eventData?.agentEventId)\n .filter((id): id is string | number => id !== undefined && id !== null && id !== \"\");\n if (!eventIds.length) return items;\n\n let mediaByEvent: Map<string, StoredMedia[]>;\n try {\n mediaByEvent = await fetchEventMedia(eventIds);\n } catch {\n return items;\n }\n if (!mediaByEvent.size) return items;\n\n return items.map((item) => {\n const media = mediaByEvent.get(String(item.eventData?.agentEventId));\n if (!media) return item;\n if (item.eventType === AgentEventTypes.toolCalling) {\n const files = Array.isArray(item.eventData.files) ? item.eventData.files : [];\n return { ...item, eventData: { ...item.eventData, files: mergeToolFileMedia(files, toolFileMedia(media)) } };\n }\n const attachments: AgentAttachmentMeta[] = media.map((file) => ({\n name: file.originalFileName ?? \"attachment\",\n mimeType: file.mimeType ?? \"\",\n size: Number(file.fileSize ?? 0),\n url: normalizeAssetUrl(file._full_url),\n }));\n return { ...item, eventData: { ...item.eventData, attachments } };\n });\n}\n"]}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import qs from "qs";
|
|
2
2
|
import { solidGet } from "../../../../http/solidHttp";
|
|
3
3
|
import { normalizeAssetUrl } from "../../../../helpers/assetUrl";
|
|
4
|
-
import
|
|
4
|
+
import { mergeToolFileMedia, type AgentToolFileMedia } from "../toolFiles";
|
|
5
|
+
import { AgentEventTypes, type AgentAttachmentMeta, type AgentChatItem } from "../types";
|
|
5
6
|
|
|
6
7
|
/** Media field on the agentEvent model that stores chat attachments (solid-core metadata). */
|
|
7
8
|
const ATTACHMENTS_FIELD = "attachments";
|
|
8
9
|
|
|
9
|
-
type StoredMedia = { _full_url?: string; originalFileName?: string; mimeType?: string; fileSize?: number };
|
|
10
|
+
type StoredMedia = { id?: number | string; _full_url?: string; originalFileName?: string; mimeType?: string; fileSize?: number };
|
|
10
11
|
|
|
11
12
|
/** Solid's response interceptor wraps bodies as { data: <payload> }; find the records array. */
|
|
12
13
|
function unwrapRecords(body: any): any[] {
|
|
@@ -18,11 +19,50 @@ function unwrapRecords(body: any): any[] {
|
|
|
18
19
|
return [];
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
/** The stored media of each agentEvent, by event id. Throws when SolidX cannot be asked. */
|
|
23
|
+
async function fetchEventMedia(eventIds: Array<string | number>): Promise<Map<string, StoredMedia[]>> {
|
|
24
|
+
const query = qs.stringify(
|
|
25
|
+
{
|
|
26
|
+
filters: { id: { $in: eventIds.map(Number) } },
|
|
27
|
+
populateMedia: [ATTACHMENTS_FIELD],
|
|
28
|
+
fields: ["id"],
|
|
29
|
+
limit: eventIds.length,
|
|
30
|
+
offset: 0,
|
|
31
|
+
},
|
|
32
|
+
{ encodeValuesOnly: true },
|
|
33
|
+
);
|
|
34
|
+
const response = await solidGet(`/agent-event?${query}`);
|
|
35
|
+
const mediaByEvent = new Map<string, StoredMedia[]>();
|
|
36
|
+
unwrapRecords(response?.data).forEach((record) => {
|
|
37
|
+
const media: StoredMedia[] = record?._media?.[ATTACHMENTS_FIELD] ?? [];
|
|
38
|
+
if (media.length) mediaByEvent.set(String(record.id), media);
|
|
39
|
+
});
|
|
40
|
+
return mediaByEvent;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function toolFileMedia(media: StoredMedia[]): AgentToolFileMedia[] {
|
|
44
|
+
return media.flatMap((file) => {
|
|
45
|
+
const url = normalizeAssetUrl(file._full_url);
|
|
46
|
+
if (!url) return [];
|
|
47
|
+
const id = Number(file.id);
|
|
48
|
+
return [{ ...(Number.isInteger(id) ? { id } : {}), ...(file.originalFileName ? { name: file.originalFileName } : {}), url }];
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** URLs of the files a tool returned, stored on its ToolResult agentEvent. Empty while SolidX has not linked them yet. */
|
|
53
|
+
export async function fetchToolFileMedia(agentEventId: string | number): Promise<AgentToolFileMedia[]> {
|
|
54
|
+
try {
|
|
55
|
+
return toolFileMedia((await fetchEventMedia([agentEventId])).get(String(agentEventId)) ?? []);
|
|
56
|
+
} catch {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
21
61
|
/**
|
|
22
|
-
* Replayed user messages only know their attachments' names
|
|
23
|
-
*
|
|
24
|
-
* such event in one request and put them
|
|
25
|
-
* when nothing is stored or the request fails.
|
|
62
|
+
* Replayed user messages only know their attachments' names, and tool calls only the names of the
|
|
63
|
+
* files the tool returned. The files themselves are stored on the agentEvent (media field
|
|
64
|
+
* `attachments`) by the agent, so fetch fresh URLs for every such event in one request and put them
|
|
65
|
+
* on the thread items. Items are returned unchanged when nothing is stored or the request fails.
|
|
26
66
|
*/
|
|
27
67
|
export async function resolveAttachmentMedia(items: AgentChatItem[]): Promise<AgentChatItem[]> {
|
|
28
68
|
const eventIds = items
|
|
@@ -30,34 +70,21 @@ export async function resolveAttachmentMedia(items: AgentChatItem[]): Promise<Ag
|
|
|
30
70
|
.filter((id): id is string | number => id !== undefined && id !== null && id !== "");
|
|
31
71
|
if (!eventIds.length) return items;
|
|
32
72
|
|
|
33
|
-
let
|
|
73
|
+
let mediaByEvent: Map<string, StoredMedia[]>;
|
|
34
74
|
try {
|
|
35
|
-
|
|
36
|
-
{
|
|
37
|
-
filters: { id: { $in: eventIds.map(Number) } },
|
|
38
|
-
populateMedia: [ATTACHMENTS_FIELD],
|
|
39
|
-
fields: ["id"],
|
|
40
|
-
limit: eventIds.length,
|
|
41
|
-
offset: 0,
|
|
42
|
-
},
|
|
43
|
-
{ encodeValuesOnly: true },
|
|
44
|
-
);
|
|
45
|
-
const response = await solidGet(`/agent-event?${query}`);
|
|
46
|
-
records = unwrapRecords(response?.data);
|
|
75
|
+
mediaByEvent = await fetchEventMedia(eventIds);
|
|
47
76
|
} catch {
|
|
48
77
|
return items;
|
|
49
78
|
}
|
|
50
|
-
|
|
51
|
-
const mediaByEvent = new Map<string, StoredMedia[]>();
|
|
52
|
-
records.forEach((record) => {
|
|
53
|
-
const media: StoredMedia[] = record?._media?.[ATTACHMENTS_FIELD] ?? [];
|
|
54
|
-
if (media.length) mediaByEvent.set(String(record.id), media);
|
|
55
|
-
});
|
|
56
79
|
if (!mediaByEvent.size) return items;
|
|
57
80
|
|
|
58
81
|
return items.map((item) => {
|
|
59
82
|
const media = mediaByEvent.get(String(item.eventData?.agentEventId));
|
|
60
83
|
if (!media) return item;
|
|
84
|
+
if (item.eventType === AgentEventTypes.toolCalling) {
|
|
85
|
+
const files = Array.isArray(item.eventData.files) ? item.eventData.files : [];
|
|
86
|
+
return { ...item, eventData: { ...item.eventData, files: mergeToolFileMedia(files, toolFileMedia(media)) } };
|
|
87
|
+
}
|
|
61
88
|
const attachments: AgentAttachmentMeta[] = media.map((file) => ({
|
|
62
89
|
name: file.originalFileName ?? "attachment",
|
|
63
90
|
mimeType: file.mimeType ?? "",
|