@solidxai/core-ui 0.1.22-beta.5 → 0.1.22

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.
Files changed (32) hide show
  1. package/dist/components/core/solid-agent/browser/AgentBrowser.module.css +170 -0
  2. package/dist/components/core/solid-agent/browser/AgentBrowserScreen.d.ts +13 -0
  3. package/dist/components/core/solid-agent/browser/AgentBrowserScreen.d.ts.map +1 -0
  4. package/dist/components/core/solid-agent/browser/AgentBrowserScreen.js +138 -0
  5. package/dist/components/core/solid-agent/browser/AgentBrowserScreen.js.map +1 -0
  6. package/dist/components/core/solid-agent/browser/AgentBrowserScreen.tsx +162 -0
  7. package/dist/components/core/solid-agent/browser/DefaultAgentBrowserPanelWidget.d.ts +9 -0
  8. package/dist/components/core/solid-agent/browser/DefaultAgentBrowserPanelWidget.d.ts.map +1 -0
  9. package/dist/components/core/solid-agent/browser/DefaultAgentBrowserPanelWidget.js +59 -0
  10. package/dist/components/core/solid-agent/browser/DefaultAgentBrowserPanelWidget.js.map +1 -0
  11. package/dist/components/core/solid-agent/browser/DefaultAgentBrowserPanelWidget.tsx +159 -0
  12. package/dist/components/core/solid-agent/browser/useAgentBrowser.d.ts +6 -0
  13. package/dist/components/core/solid-agent/browser/useAgentBrowser.d.ts.map +1 -0
  14. package/dist/components/core/solid-agent/browser/useAgentBrowser.js +37 -0
  15. package/dist/components/core/solid-agent/browser/useAgentBrowser.js.map +1 -0
  16. package/dist/components/core/solid-agent/browser/useAgentBrowser.ts +38 -0
  17. package/dist/components/core/solid-agent/client/agentBrowser.d.ts +128 -0
  18. package/dist/components/core/solid-agent/client/agentBrowser.d.ts.map +1 -0
  19. package/dist/components/core/solid-agent/client/agentBrowser.js +474 -0
  20. package/dist/components/core/solid-agent/client/agentBrowser.js.map +1 -0
  21. package/dist/components/core/solid-agent/client/agentBrowser.ts +342 -0
  22. package/dist/components/core/solid-agent/toolFiles.d.ts +13 -0
  23. package/dist/components/core/solid-agent/toolFiles.d.ts.map +1 -0
  24. package/dist/components/core/solid-agent/toolFiles.js +54 -0
  25. package/dist/components/core/solid-agent/toolFiles.js.map +1 -0
  26. package/dist/components/core/solid-agent/toolFiles.ts +42 -0
  27. package/dist/components/core/solid-agent/widgets/AgentToolFiles.d.ts +9 -0
  28. package/dist/components/core/solid-agent/widgets/AgentToolFiles.d.ts.map +1 -0
  29. package/dist/components/core/solid-agent/widgets/AgentToolFiles.js +37 -0
  30. package/dist/components/core/solid-agent/widgets/AgentToolFiles.js.map +1 -0
  31. package/dist/components/core/solid-agent/widgets/AgentToolFiles.tsx +46 -0
  32. 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,SAAS,QAAQ,CAAC,SAAwB,EAAE,GAAW;IACnD,IAAI,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IAC5B,IAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAClC,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACnC,IAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE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,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,GAAqB;IACjC,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,KAAK;IAChB,KAAK,EAAE,MAAM;IACb,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE;IACtC,GAAG,EAAE,IAAI;IACT,KAAK,EAAE,IAAI;IACX,IAAI,EAAE,EAAE;IACR,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE;IACzE,UAAU,EAAE,IAAI;IAChB,QAAQ,EAAE,KAAK;IACf,QAAQ,EAAE,KAAK;IACf,KAAK,EAAE,IAAI;IACX,YAAY,EAAE,IAAI;CACrB,CAAC;AACF,IAAM,cAAc,GAAG,cAAM,OAAA,cAAO,CAAC,EAAR,CAAQ,CAAC;AACtC,IAAM,SAAS,GAAG,cAAM,OAAA,UAAU,EAAV,CAAU,CAAC;AAEnC,kGAAkG;AAClG,MAAM,UAAU,eAAe,CAAC,OAA+C;;IAC3E,OAAO,oBAAoB,CAAC,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,mCAAI,cAAc,EAAE,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,mCAAI,SAAS,EAAE,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,mCAAI,SAAS,CAAC,CAAC;AACpI,CAAC;AAED,oGAAoG;AACpG,MAAM,UAAU,eAAe,CAAC,MAAe;IACrC,IAAA,KAAgB,QAAQ,CAAC,cAAM,OAAA,IAAI,CAAC,GAAG,EAAE,EAAV,CAAU,CAAC,EAAzC,GAAG,QAAA,EAAE,MAAM,QAA8B,CAAC;IACjD,SAAS,CAAC;QACN,IAAI,CAAC,MAAM;YAAE,OAAO;QACpB,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QACnB,IAAM,KAAK,GAAG,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
+ }
@@ -0,0 +1,128 @@
1
+ import type { AgentAction, AgentBrowserInputEvent } from "../types";
2
+ /**
3
+ * The live view of a session's browser (AgentHub browser tools).
4
+ *
5
+ * Kept outside Redux: frames are large base64 JPEGs at several per second. Status, tabs and control
6
+ * state form a small immutable view for React (`subscribe`/`getView`, made for useSyncExternalStore);
7
+ * frames go to `onFrame` listeners that draw them straight onto a canvas.
8
+ *
9
+ * The preview is a per-socket subscription. Viewers call `watch()` while they show the screen; the
10
+ * channel asks for the preview once the browser is live and stops it shortly after the last viewer
11
+ * leaves. A reconnect or a session switch (`sessionStarted`) subscribes again.
12
+ */
13
+ export type AgentBrowserState = "none" | "starting" | "live" | "state_saved" | "released";
14
+ export type AgentBrowserControlMode = "agent" | "human";
15
+ export type AgentBrowserTab = {
16
+ tab: string;
17
+ url: string | null;
18
+ title: string | null;
19
+ };
20
+ export type AgentBrowserControl = {
21
+ mode: AgentBrowserControlMode;
22
+ /** The user asked for the browser and waits for the agent's current step to finish. */
23
+ pending: boolean;
24
+ /** Why the agent handed the browser over (browser_handoff). */
25
+ reason: string | null;
26
+ /** ISO time when control returns to the agent automatically. */
27
+ expiresAt: string | null;
28
+ };
29
+ export type AgentBrowserError = {
30
+ code: string;
31
+ message: string;
32
+ at: number;
33
+ };
34
+ export type AgentBrowserView = {
35
+ sessionId: string | null;
36
+ /** False once the agent said it has no browser tools. */
37
+ available: boolean;
38
+ state: AgentBrowserState;
39
+ viewport: {
40
+ width: number;
41
+ height: number;
42
+ };
43
+ url: string | null;
44
+ title: string | null;
45
+ tabs: AgentBrowserTab[];
46
+ activeTab: string | null;
47
+ control: AgentBrowserControl;
48
+ /** When the agent last reopened a saved browser session (sign-ins and cookies restored). */
49
+ restoredAt: number | null;
50
+ /** The preview subscription is active on this socket. */
51
+ watching: boolean;
52
+ hasFrame: boolean;
53
+ error: AgentBrowserError | null;
54
+ /** False when the browser is only shown: the server sent browser_status with control false, so there is no "Take control". */
55
+ controllable: boolean;
56
+ };
57
+ /** `seq` grows with every frame the channel accepts, also across preview restarts and reconnects. */
58
+ export type AgentBrowserFrame = {
59
+ tab: string | null;
60
+ url: string | null;
61
+ title: string | null;
62
+ format: string;
63
+ data: string;
64
+ seq: number;
65
+ };
66
+ /** What the channel needs from AgentSocket. */
67
+ export type AgentBrowserSocket = {
68
+ readonly currentSessionId: string | null;
69
+ sendNow(action: AgentAction): boolean;
70
+ };
71
+ /** Whether the panel should show: the browser runs, or the user has (or is offered) it. */
72
+ export declare function isBrowserActive(view: AgentBrowserView): boolean;
73
+ type Timers = {
74
+ setTimeout: (callback: () => void, ms: number) => unknown;
75
+ clearTimeout: (handle: any) => void;
76
+ now: () => number;
77
+ };
78
+ export declare class AgentBrowserChannel {
79
+ private view;
80
+ private listeners;
81
+ private frameListeners;
82
+ private frame;
83
+ private frameCount;
84
+ /** The relay's number of the last frame of the current subscription; a new subscription counts from 1 again. */
85
+ private streamSeq;
86
+ /** This socket's number for its current subscription, which the runtime echoes on the frames. */
87
+ private stream;
88
+ private watchers;
89
+ /** The session whose preview this socket subscribed to, if any. */
90
+ private previewSession;
91
+ private stopTimer;
92
+ private readonly socket;
93
+ private readonly timers;
94
+ constructor(socket: AgentBrowserSocket, timers?: Partial<Timers>);
95
+ readonly getView: () => AgentBrowserView;
96
+ readonly subscribe: (listener: () => void) => () => void;
97
+ onFrame(listener: (frame: AgentBrowserFrame) => void): () => void;
98
+ get latestFrame(): AgentBrowserFrame | null;
99
+ /** Applies one inbound frame. Returns false for frames that are not about the browser. */
100
+ handle(eventType: string, data: Record<string, any>): boolean;
101
+ /** The socket (re)confirmed a session. A new socket has no preview yet; another session starts empty. */
102
+ sessionStarted(sessionId: string | null): void;
103
+ /** Forget the current session's browser (new chat, switched conversation, expired session). */
104
+ reset(): void;
105
+ /** Keep the preview running while the returned release function has not been called. */
106
+ watch(): () => void;
107
+ requestControl(): boolean;
108
+ /** Give the browser back, or continue a handoff without taking it. The note goes to the agent. */
109
+ release(note?: string | null): boolean;
110
+ /** Forwards one input event while the user has the browser. Dropped (false) otherwise. */
111
+ sendInput(event: AgentBrowserInputEvent): boolean;
112
+ navigate(url: string): boolean;
113
+ navigation(action: "back" | "forward" | "refresh"): boolean;
114
+ clearError(): void;
115
+ dispose(): void;
116
+ private sendForSession;
117
+ private wantsPreview;
118
+ private syncPreview;
119
+ private applyStatus;
120
+ private applyFrame;
121
+ private applyTabs;
122
+ private applyControl;
123
+ private applyError;
124
+ private cancelStop;
125
+ private setView;
126
+ }
127
+ export {};
128
+ //# sourceMappingURL=agentBrowser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentBrowser.d.ts","sourceRoot":"","sources":["../../../../../src/components/core/solid-agent/client/agentBrowser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAEpE;;;;;;;;;;GAUG;AAEH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,aAAa,GAAG,UAAU,CAAC;AAC1F,MAAM,MAAM,uBAAuB,GAAG,OAAO,GAAG,OAAO,CAAC;AACxD,MAAM,MAAM,eAAe,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AACxF,MAAM,MAAM,mBAAmB,GAAG;IAC9B,IAAI,EAAE,uBAAuB,CAAC;IAC9B,uFAAuF;IACvF,OAAO,EAAE,OAAO,CAAC;IACjB,+DAA+D;IAC/D,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,gEAAgE;IAChE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC;AACF,MAAM,MAAM,iBAAiB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MA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