@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,342 @@
|
|
|
1
|
+
import type { AgentAction, AgentBrowserInputEvent } from "../types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The live view of a session's browser (AgentHub browser tools).
|
|
5
|
+
*
|
|
6
|
+
* Kept outside Redux: frames are large base64 JPEGs at several per second. Status, tabs and control
|
|
7
|
+
* state form a small immutable view for React (`subscribe`/`getView`, made for useSyncExternalStore);
|
|
8
|
+
* frames go to `onFrame` listeners that draw them straight onto a canvas.
|
|
9
|
+
*
|
|
10
|
+
* The preview is a per-socket subscription. Viewers call `watch()` while they show the screen; the
|
|
11
|
+
* channel asks for the preview once the browser is live and stops it shortly after the last viewer
|
|
12
|
+
* leaves. A reconnect or a session switch (`sessionStarted`) subscribes again.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export type AgentBrowserState = "none" | "starting" | "live" | "state_saved" | "released";
|
|
16
|
+
export type AgentBrowserControlMode = "agent" | "human";
|
|
17
|
+
export type AgentBrowserTab = { tab: string; url: string | null; title: string | null };
|
|
18
|
+
export type AgentBrowserControl = {
|
|
19
|
+
mode: AgentBrowserControlMode;
|
|
20
|
+
/** The user asked for the browser and waits for the agent's current step to finish. */
|
|
21
|
+
pending: boolean;
|
|
22
|
+
/** Why the agent handed the browser over (browser_handoff). */
|
|
23
|
+
reason: string | null;
|
|
24
|
+
/** ISO time when control returns to the agent automatically. */
|
|
25
|
+
expiresAt: string | null;
|
|
26
|
+
};
|
|
27
|
+
export type AgentBrowserError = { code: string; message: string; at: number };
|
|
28
|
+
|
|
29
|
+
export type AgentBrowserView = {
|
|
30
|
+
sessionId: string | null;
|
|
31
|
+
/** False once the agent said it has no browser tools. */
|
|
32
|
+
available: boolean;
|
|
33
|
+
state: AgentBrowserState;
|
|
34
|
+
viewport: { width: number; height: number };
|
|
35
|
+
url: string | null;
|
|
36
|
+
title: string | null;
|
|
37
|
+
tabs: AgentBrowserTab[];
|
|
38
|
+
activeTab: string | null;
|
|
39
|
+
control: AgentBrowserControl;
|
|
40
|
+
/** When the agent last reopened a saved browser session (sign-ins and cookies restored). */
|
|
41
|
+
restoredAt: number | null;
|
|
42
|
+
/** The preview subscription is active on this socket. */
|
|
43
|
+
watching: boolean;
|
|
44
|
+
hasFrame: boolean;
|
|
45
|
+
error: AgentBrowserError | null;
|
|
46
|
+
/** False when the browser is only shown: the server sent browser_status with control false, so there is no "Take control". */
|
|
47
|
+
controllable: boolean;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/** `seq` grows with every frame the channel accepts, also across preview restarts and reconnects. */
|
|
51
|
+
export type AgentBrowserFrame = { tab: string | null; url: string | null; title: string | null; format: string; data: string; seq: number };
|
|
52
|
+
|
|
53
|
+
/** What the channel needs from AgentSocket. */
|
|
54
|
+
export type AgentBrowserSocket = {
|
|
55
|
+
readonly currentSessionId: string | null;
|
|
56
|
+
sendNow(action: AgentAction): boolean;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const STATES: readonly AgentBrowserState[] = ["none", "starting", "live", "state_saved", "released"];
|
|
60
|
+
const DEFAULT_VIEWPORT = { width: 1280, height: 800 };
|
|
61
|
+
/** Moving the screen between the side pane and the large view must not drop the preview. */
|
|
62
|
+
const STOP_DELAY_MS = 800;
|
|
63
|
+
const OFFLINE: Omit<AgentBrowserError, "at"> = { code: "offline", message: "The chat is not connected to the agent. Try again once it reconnects." };
|
|
64
|
+
|
|
65
|
+
function initialView(sessionId: string | null, available = true): AgentBrowserView {
|
|
66
|
+
return {
|
|
67
|
+
sessionId,
|
|
68
|
+
available,
|
|
69
|
+
state: "none",
|
|
70
|
+
viewport: DEFAULT_VIEWPORT,
|
|
71
|
+
url: null,
|
|
72
|
+
title: null,
|
|
73
|
+
tabs: [],
|
|
74
|
+
activeTab: null,
|
|
75
|
+
control: { mode: "agent", pending: false, reason: null, expiresAt: null },
|
|
76
|
+
restoredAt: null,
|
|
77
|
+
watching: false,
|
|
78
|
+
hasFrame: false,
|
|
79
|
+
error: null,
|
|
80
|
+
controllable: true,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const text = (value: unknown): string | null => (typeof value === "string" && value ? value : null);
|
|
85
|
+
|
|
86
|
+
/** Whether the panel should show: the browser runs, or the user has (or is offered) it. */
|
|
87
|
+
export function isBrowserActive(view: AgentBrowserView): boolean {
|
|
88
|
+
return view.available && (view.state === "live" || view.state === "starting" || view.control.mode === "human");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
type Timers = { setTimeout: (callback: () => void, ms: number) => unknown; clearTimeout: (handle: any) => void; now: () => number };
|
|
92
|
+
|
|
93
|
+
export class AgentBrowserChannel {
|
|
94
|
+
private view: AgentBrowserView = initialView(null);
|
|
95
|
+
private listeners = new Set<() => void>();
|
|
96
|
+
private frameListeners = new Set<(frame: AgentBrowserFrame) => void>();
|
|
97
|
+
private frame: AgentBrowserFrame | null = null;
|
|
98
|
+
private frameCount = 0;
|
|
99
|
+
/** The relay's number of the last frame of the current subscription; a new subscription counts from 1 again. */
|
|
100
|
+
private streamSeq = 0;
|
|
101
|
+
/** This socket's number for its current subscription, which the runtime echoes on the frames. */
|
|
102
|
+
private stream = 0;
|
|
103
|
+
private watchers = 0;
|
|
104
|
+
/** The session whose preview this socket subscribed to, if any. */
|
|
105
|
+
private previewSession: string | null = null;
|
|
106
|
+
private stopTimer: unknown = null;
|
|
107
|
+
private readonly socket: AgentBrowserSocket;
|
|
108
|
+
private readonly timers: Timers;
|
|
109
|
+
|
|
110
|
+
constructor(socket: AgentBrowserSocket, timers?: Partial<Timers>) {
|
|
111
|
+
this.socket = socket;
|
|
112
|
+
this.timers = {
|
|
113
|
+
setTimeout: timers?.setTimeout ?? ((callback, ms) => setTimeout(callback, ms)),
|
|
114
|
+
clearTimeout: timers?.clearTimeout ?? ((handle) => clearTimeout(handle)),
|
|
115
|
+
now: timers?.now ?? (() => Date.now()),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
readonly getView = (): AgentBrowserView => this.view;
|
|
120
|
+
|
|
121
|
+
readonly subscribe = (listener: () => void) => {
|
|
122
|
+
this.listeners.add(listener);
|
|
123
|
+
return () => { this.listeners.delete(listener); };
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
onFrame(listener: (frame: AgentBrowserFrame) => void) {
|
|
127
|
+
this.frameListeners.add(listener);
|
|
128
|
+
return () => { this.frameListeners.delete(listener); };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
get latestFrame(): AgentBrowserFrame | null {
|
|
132
|
+
return this.frame;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Applies one inbound frame. Returns false for frames that are not about the browser. */
|
|
136
|
+
handle(eventType: string, data: Record<string, any>): boolean {
|
|
137
|
+
switch (eventType) {
|
|
138
|
+
case "browser_status": this.applyStatus(data); return true;
|
|
139
|
+
case "browser_frame": this.applyFrame(data); return true;
|
|
140
|
+
case "browser_tabs": this.applyTabs(data); return true;
|
|
141
|
+
case "browser_control_state": this.applyControl(data); return true;
|
|
142
|
+
case "browser_error": this.applyError(data); return true;
|
|
143
|
+
default: return false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** The socket (re)confirmed a session. A new socket has no preview yet; another session starts empty. */
|
|
148
|
+
sessionStarted(sessionId: string | null) {
|
|
149
|
+
this.previewSession = null;
|
|
150
|
+
this.streamSeq = 0;
|
|
151
|
+
if (sessionId !== this.view.sessionId) {
|
|
152
|
+
this.frame = null;
|
|
153
|
+
this.setView(initialView(sessionId, this.view.available));
|
|
154
|
+
} else if (this.view.watching) {
|
|
155
|
+
this.setView({ ...this.view, watching: false });
|
|
156
|
+
}
|
|
157
|
+
this.syncPreview();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** Forget the current session's browser (new chat, switched conversation, expired session). */
|
|
161
|
+
reset() {
|
|
162
|
+
this.cancelStop();
|
|
163
|
+
if (this.previewSession) this.socket.sendNow({ action: "browser_preview_stop", session_id: this.previewSession });
|
|
164
|
+
this.previewSession = null;
|
|
165
|
+
this.streamSeq = 0;
|
|
166
|
+
this.frame = null;
|
|
167
|
+
this.setView(initialView(null, this.view.available));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** Keep the preview running while the returned release function has not been called. */
|
|
171
|
+
watch(): () => void {
|
|
172
|
+
this.watchers += 1;
|
|
173
|
+
this.cancelStop();
|
|
174
|
+
this.syncPreview();
|
|
175
|
+
let released = false;
|
|
176
|
+
return () => {
|
|
177
|
+
if (released) return;
|
|
178
|
+
released = true;
|
|
179
|
+
this.watchers -= 1;
|
|
180
|
+
if (this.watchers > 0) return;
|
|
181
|
+
this.cancelStop();
|
|
182
|
+
this.stopTimer = this.timers.setTimeout(() => {
|
|
183
|
+
this.stopTimer = null;
|
|
184
|
+
this.syncPreview();
|
|
185
|
+
}, STOP_DELAY_MS);
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
requestControl(): boolean {
|
|
190
|
+
return this.sendForSession((session_id) => ({ action: "browser_control_request", session_id }));
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** Give the browser back, or continue a handoff without taking it. The note goes to the agent. */
|
|
194
|
+
release(note?: string | null): boolean {
|
|
195
|
+
const trimmed = typeof note === "string" ? note.trim() : "";
|
|
196
|
+
return this.sendForSession((session_id) => ({ action: "browser_control_release", session_id, note: trimmed || null }));
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** Forwards one input event while the user has the browser. Dropped (false) otherwise. */
|
|
200
|
+
sendInput(event: AgentBrowserInputEvent): boolean {
|
|
201
|
+
if (this.view.control.mode !== "human") return false;
|
|
202
|
+
const sessionId = this.socket.currentSessionId;
|
|
203
|
+
return !!sessionId && this.socket.sendNow({ action: "browser_input", session_id: sessionId, event });
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
navigate(url: string): boolean {
|
|
207
|
+
const target = url.trim();
|
|
208
|
+
if (!target) return false;
|
|
209
|
+
return this.sendInput({ kind: "navigation", url: /^[a-z][a-z\d+.-]*:/i.test(target) ? target : `https://${target}` });
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
navigation(action: "back" | "forward" | "refresh"): boolean {
|
|
213
|
+
return this.sendInput({ kind: "navigation", action });
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
clearError() {
|
|
217
|
+
if (this.view.error) this.setView({ ...this.view, error: null });
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
dispose() {
|
|
221
|
+
this.cancelStop();
|
|
222
|
+
this.listeners.clear();
|
|
223
|
+
this.frameListeners.clear();
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
private sendForSession(build: (sessionId: string) => AgentAction): boolean {
|
|
227
|
+
const sessionId = this.socket.currentSessionId;
|
|
228
|
+
if (sessionId && this.socket.sendNow(build(sessionId))) return true;
|
|
229
|
+
this.setView({ ...this.view, error: { ...OFFLINE, at: this.timers.now() } });
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
private wantsPreview() {
|
|
234
|
+
return this.watchers > 0 && isBrowserActive(this.view);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
private syncPreview() {
|
|
238
|
+
const sessionId = this.socket.currentSessionId;
|
|
239
|
+
if (this.wantsPreview()) {
|
|
240
|
+
if (!sessionId || this.previewSession === sessionId) return;
|
|
241
|
+
this.stream += 1;
|
|
242
|
+
if (this.socket.sendNow({ action: "browser_preview_start", session_id: sessionId, stream: this.stream })) {
|
|
243
|
+
this.previewSession = sessionId;
|
|
244
|
+
this.streamSeq = 0;
|
|
245
|
+
this.setView({ ...this.view, watching: true });
|
|
246
|
+
}
|
|
247
|
+
} else if (this.watchers === 0 && this.previewSession) {
|
|
248
|
+
this.socket.sendNow({ action: "browser_preview_stop", session_id: this.previewSession });
|
|
249
|
+
this.previewSession = null;
|
|
250
|
+
this.streamSeq = 0;
|
|
251
|
+
this.setView({ ...this.view, watching: false });
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
private applyStatus(data: Record<string, any>) {
|
|
256
|
+
const state: AgentBrowserState = STATES.includes(data.state) ? data.state : this.view.state;
|
|
257
|
+
const width = Number(data.viewport?.width);
|
|
258
|
+
const height = Number(data.viewport?.height);
|
|
259
|
+
const ended = state === "none" || state === "released" || state === "state_saved";
|
|
260
|
+
if (ended) this.frame = null;
|
|
261
|
+
this.setView({
|
|
262
|
+
...this.view,
|
|
263
|
+
state,
|
|
264
|
+
viewport: width > 0 && height > 0 ? { width, height } : this.view.viewport,
|
|
265
|
+
url: text(data.url) ?? (ended ? null : this.view.url),
|
|
266
|
+
title: ended ? null : this.view.title,
|
|
267
|
+
activeTab: text(data.active_tab) ?? this.view.activeTab,
|
|
268
|
+
tabs: ended ? [] : this.view.tabs,
|
|
269
|
+
hasFrame: ended ? false : this.view.hasFrame,
|
|
270
|
+
// Only an explicit "control: false" makes the browser view-only; a server that never sends it keeps control.
|
|
271
|
+
controllable: data.control === false ? false : data.control === true ? true : this.view.controllable,
|
|
272
|
+
control: data.control_mode === "human" || data.control_mode === "agent"
|
|
273
|
+
? { ...this.view.control, mode: data.control_mode } : this.view.control,
|
|
274
|
+
restoredAt: data.restored === true ? this.timers.now() : this.view.restoredAt,
|
|
275
|
+
});
|
|
276
|
+
this.syncPreview();
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
private applyFrame(data: Record<string, any>) {
|
|
280
|
+
if (typeof data.data !== "string" || !data.data || !this.previewSession) return;
|
|
281
|
+
// A frame still on the way from an earlier subscription carries that subscription's number. Taking its
|
|
282
|
+
// seq would hide the new subscription's frames, which the relay may number from 1 again.
|
|
283
|
+
if (data.stream !== undefined && data.stream !== this.stream) return;
|
|
284
|
+
const seq = Number(data.seq) || 0;
|
|
285
|
+
// The relay numbers the frames of one subscription; an older one can still arrive after a newer one.
|
|
286
|
+
if (seq > 0 && seq < this.streamSeq) return;
|
|
287
|
+
if (seq > 0) this.streamSeq = seq;
|
|
288
|
+
this.frameCount += 1;
|
|
289
|
+
const frame: AgentBrowserFrame = {
|
|
290
|
+
tab: text(data.tab), url: text(data.url), title: text(data.title),
|
|
291
|
+
format: text(data.format) ?? "jpeg", data: data.data, seq: this.frameCount,
|
|
292
|
+
};
|
|
293
|
+
this.frame = frame;
|
|
294
|
+
const url = frame.url ?? this.view.url;
|
|
295
|
+
const title = frame.title ?? this.view.title;
|
|
296
|
+
if (!this.view.hasFrame || url !== this.view.url || title !== this.view.title) {
|
|
297
|
+
this.setView({ ...this.view, hasFrame: true, url, title });
|
|
298
|
+
}
|
|
299
|
+
this.frameListeners.forEach((listener) => listener(frame));
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
private applyTabs(data: Record<string, any>) {
|
|
303
|
+
const tabs: AgentBrowserTab[] = Array.isArray(data.tabs)
|
|
304
|
+
? data.tabs.flatMap((tab: any) => tab && typeof tab.tab === "string"
|
|
305
|
+
? [{ tab: tab.tab, url: text(tab.url), title: text(tab.title) }] : [])
|
|
306
|
+
: [];
|
|
307
|
+
this.setView({ ...this.view, tabs, activeTab: text(data.active_tab) ?? null });
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
private applyControl(data: Record<string, any>) {
|
|
311
|
+
const control: AgentBrowserControl = {
|
|
312
|
+
mode: data.control_mode === "human" ? "human" : "agent",
|
|
313
|
+
pending: data.pending === true,
|
|
314
|
+
reason: text(data.reason),
|
|
315
|
+
expiresAt: text(data.expires_at),
|
|
316
|
+
};
|
|
317
|
+
this.setView({ ...this.view, control, error: control.mode === "human" ? null : this.view.error });
|
|
318
|
+
this.syncPreview();
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
private applyError(data: Record<string, any>) {
|
|
322
|
+
const code = text(data.code) ?? "browser_error";
|
|
323
|
+
const error = { code, message: text(data.message) ?? "The browser could not do that.", at: this.timers.now() };
|
|
324
|
+
if (code === "no_browser") {
|
|
325
|
+
this.previewSession = null;
|
|
326
|
+
this.streamSeq = 0;
|
|
327
|
+
this.setView({ ...this.view, available: false, watching: false, error });
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
this.setView({ ...this.view, error });
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
private cancelStop() {
|
|
334
|
+
if (this.stopTimer != null) this.timers.clearTimeout(this.stopTimer);
|
|
335
|
+
this.stopTimer = null;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
private setView(view: AgentBrowserView) {
|
|
339
|
+
this.view = view;
|
|
340
|
+
this.listeners.forEach((listener) => listener());
|
|
341
|
+
}
|
|
342
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type AgentState } from "../../../../redux/features/agentSlice";
|
|
2
2
|
import { type AgentRuntimeType, type AgentAttachment, type AgentContext, type AgentMessageContext, type AgentSessionOptions } from "../types";
|
|
3
|
+
import { AgentBrowserChannel } from "./agentBrowser";
|
|
3
4
|
import { AgentSocket } from "./agentSocket";
|
|
4
5
|
/**
|
|
5
6
|
* A live connection to one agent backend. The "solidx" runtime is shared by the floating window and
|
|
@@ -30,6 +31,8 @@ export declare class AgentRuntime {
|
|
|
30
31
|
readonly agentRuntime: AgentRuntimeType;
|
|
31
32
|
private persistSession;
|
|
32
33
|
readonly socket: AgentSocket;
|
|
34
|
+
/** Live view and control of the session's browser (AgentHub browser tools). */
|
|
35
|
+
readonly browser: AgentBrowserChannel;
|
|
33
36
|
private pendingDelta;
|
|
34
37
|
private frame;
|
|
35
38
|
private unsubscribers;
|
|
@@ -72,6 +75,8 @@ export declare class AgentRuntime {
|
|
|
72
75
|
dispose(): void;
|
|
73
76
|
private loadHistory;
|
|
74
77
|
private handleFrame;
|
|
78
|
+
/** Fetches the stored URLs of the screenshots and downloads a tool just returned. */
|
|
79
|
+
private resolveToolFiles;
|
|
75
80
|
private publish;
|
|
76
81
|
private lastTurnCompleteContent;
|
|
77
82
|
private lastTurnCompleteTime;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentRuntime.d.ts","sourceRoot":"","sources":["../../../../../src/components/core/solid-agent/client/agentRuntime.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"agentRuntime.d.ts","sourceRoot":"","sources":["../../../../../src/components/core/solid-agent/client/agentRuntime.ts"],"names":[],"mappings":"AAEA,OAAO,EAQH,KAAK,UAAU,EAClB,MAAM,uCAAuC,CAAC;AAO/C,OAAO,EAAmB,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAuB,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,mBAAmB,EAAuB,MAAM,UAAU,CAAC;AAEzM,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGrD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C;;;;;;GAMG;AAEH,KAAK,QAAQ,GAAG,CAAC,MAAM,EAAE,GAA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../helpers/eventBus";
|
|
49
49
|
import { getAgentChatWidgetCatalog } from "../../../../helpers/registry";
|
|
50
|
-
import { agentConnectionChanged, agentEventReceived, agentHistoryLoaded, agentHistoryLoadingChanged, agentThreadReset, agentUserMessageAdded, } from "../../../../redux/features/agentSlice";
|
|
50
|
+
import { agentConnectionChanged, agentEventReceived, agentHistoryLoaded, agentHistoryLoadingChanged, agentThreadReset, agentToolFilesResolved, agentUserMessageAdded, } from "../../../../redux/features/agentSlice";
|
|
51
51
|
import { historyToItems, isSameAssistantContent, normalizeAgentFrame } from "../agentEvents";
|
|
52
52
|
import { parseWidgetContent } from "../thread/inlineWidget";
|
|
53
53
|
import { humanReviewAllowsChoice, humanReviewId } from "../humanReview";
|
|
@@ -55,7 +55,8 @@ import { SOLID_AGENT_EVENTS } from "../sdk/solidAgent";
|
|
|
55
55
|
import { emitBeforeUserMessageSend } from "./beforeUserMessageSend";
|
|
56
56
|
import { emitAgentPublicEvent } from "./agentPublicEvents";
|
|
57
57
|
import { AgentEventTypes } from "../types";
|
|
58
|
-
import { resolveAttachmentMedia } from "./agentAttachmentMedia";
|
|
58
|
+
import { fetchToolFileMedia, resolveAttachmentMedia } from "./agentAttachmentMedia";
|
|
59
|
+
import { AgentBrowserChannel } from "./agentBrowser";
|
|
59
60
|
import { clearAllAgentAuth } from "./agentAuth";
|
|
60
61
|
import { fetchSessionHistory, uploadAgentAttachments } from "./agentRest";
|
|
61
62
|
import { AgentSocket } from "./agentSocket";
|
|
@@ -161,6 +162,8 @@ export function setStoredSessionOptions(provider, opts) {
|
|
|
161
162
|
// Storage blocked
|
|
162
163
|
}
|
|
163
164
|
}
|
|
165
|
+
/** Linking tool files to their event can lag the live ToolResult frame by a moment. */
|
|
166
|
+
var TOOL_FILE_RETRY_MS = [0, 1500, 4000];
|
|
164
167
|
var AgentRuntime = /** @class */ (function () {
|
|
165
168
|
function AgentRuntime(agentUrl, dispatch, getState, agentRuntime, persistSession, sessionOwnerKey, agentName) {
|
|
166
169
|
var _this = this;
|
|
@@ -203,6 +206,13 @@ var AgentRuntime = /** @class */ (function () {
|
|
|
203
206
|
writable: true,
|
|
204
207
|
value: void 0
|
|
205
208
|
});
|
|
209
|
+
/** Live view and control of the session's browser (AgentHub browser tools). */
|
|
210
|
+
Object.defineProperty(this, "browser", {
|
|
211
|
+
enumerable: true,
|
|
212
|
+
configurable: true,
|
|
213
|
+
writable: true,
|
|
214
|
+
value: void 0
|
|
215
|
+
});
|
|
206
216
|
Object.defineProperty(this, "pendingDelta", {
|
|
207
217
|
enumerable: true,
|
|
208
218
|
configurable: true,
|
|
@@ -297,7 +307,9 @@ var AgentRuntime = /** @class */ (function () {
|
|
|
297
307
|
speed: (_b = getStoredSpeed(initialProvider)) !== null && _b !== void 0 ? _b : undefined,
|
|
298
308
|
};
|
|
299
309
|
this.socket = new AgentSocket(agentUrl, persistSession ? readSessionId(this.sessionKey) : null, agentRuntime === "agentHub", initialProvider, initialModel, initialOptions, agentRuntime === "agentHub" ? getAgentChatWidgetCatalog(agentName) : []);
|
|
310
|
+
this.browser = new AgentBrowserChannel(this.socket);
|
|
300
311
|
this.socket.setOnSessionExpired(function () {
|
|
312
|
+
_this.browser.reset();
|
|
301
313
|
if (_this.persistSession)
|
|
302
314
|
writeSessionId(_this.sessionKey, null);
|
|
303
315
|
if (_this.frame != null) {
|
|
@@ -525,6 +537,7 @@ var AgentRuntime = /** @class */ (function () {
|
|
|
525
537
|
if (provider && opts)
|
|
526
538
|
setStoredSessionOptions(provider, opts);
|
|
527
539
|
this.lastContext = undefined;
|
|
540
|
+
this.browser.reset();
|
|
528
541
|
this.dispatch(agentThreadReset());
|
|
529
542
|
this.socket.newSession(__assign(__assign({}, (provider ? { provider: provider, model: model } : {})), (opts || {})));
|
|
530
543
|
}
|
|
@@ -572,6 +585,7 @@ var AgentRuntime = /** @class */ (function () {
|
|
|
572
585
|
setStoredProviderAndModel(provider, model);
|
|
573
586
|
if (provider && opts)
|
|
574
587
|
setStoredSessionOptions(provider, opts);
|
|
588
|
+
this.browser.reset();
|
|
575
589
|
this.dispatch(agentThreadReset());
|
|
576
590
|
this.dispatch(agentHistoryLoadingChanged(true));
|
|
577
591
|
this.socket.resume(sessionId, __assign(__assign({}, (provider ? { provider: provider, model: model } : {})), (opts || {})));
|
|
@@ -621,6 +635,7 @@ var AgentRuntime = /** @class */ (function () {
|
|
|
621
635
|
this.unsubscribers.forEach(function (off) { return off(); });
|
|
622
636
|
if (this.frame != null)
|
|
623
637
|
cancelAnimationFrame(this.frame);
|
|
638
|
+
this.browser.dispose();
|
|
624
639
|
this.socket.close();
|
|
625
640
|
}
|
|
626
641
|
});
|
|
@@ -700,6 +715,9 @@ var AgentRuntime = /** @class */ (function () {
|
|
|
700
715
|
var _this = this;
|
|
701
716
|
var _a, _b, _c, _d, _e;
|
|
702
717
|
var event = normalizeAgentFrame(frame);
|
|
718
|
+
// Browser frames stay out of Redux and the SDK events.
|
|
719
|
+
if (event.eventType.startsWith("browser_") && this.browser.handle(event.eventType, event.eventData))
|
|
720
|
+
return;
|
|
703
721
|
if (event.eventType === AgentEventTypes.sessionStarted) {
|
|
704
722
|
var state = this.getState();
|
|
705
723
|
if ((state === null || state === void 0 ? void 0 : state.pendingReview) || (state === null || state === void 0 ? void 0 : state.reviewResuming)) {
|
|
@@ -707,6 +725,7 @@ var AgentRuntime = /** @class */ (function () {
|
|
|
707
725
|
this.dispatch(agentThreadReset());
|
|
708
726
|
}
|
|
709
727
|
var sessionId = (_b = (_a = frame.session_id) !== null && _a !== void 0 ? _a : event.eventData.session_id) !== null && _b !== void 0 ? _b : null;
|
|
728
|
+
this.browser.sessionStarted(sessionId);
|
|
710
729
|
this.publish(this.hadPriorSession ? "onSessionResumed" : "onSessionStarted", { sessionId: sessionId });
|
|
711
730
|
this.hadPriorSession = true;
|
|
712
731
|
}
|
|
@@ -752,6 +771,72 @@ var AgentRuntime = /** @class */ (function () {
|
|
|
752
771
|
this.flushTokens();
|
|
753
772
|
this.dispatch(agentEventReceived(event));
|
|
754
773
|
this.emitSdkEvents(event);
|
|
774
|
+
if (event.eventType === AgentEventTypes.toolResult && this.persistSession)
|
|
775
|
+
this.resolveToolFiles(event.eventData);
|
|
776
|
+
}
|
|
777
|
+
});
|
|
778
|
+
/** Fetches the stored URLs of the screenshots and downloads a tool just returned. */
|
|
779
|
+
Object.defineProperty(AgentRuntime.prototype, "resolveToolFiles", {
|
|
780
|
+
enumerable: false,
|
|
781
|
+
configurable: true,
|
|
782
|
+
writable: true,
|
|
783
|
+
value: function (eventData) {
|
|
784
|
+
var _this = this;
|
|
785
|
+
var agentEventId = eventData.agentEventId;
|
|
786
|
+
var stored = Array.isArray(eventData.files) && eventData.files.some(function (file) { return (file === null || file === void 0 ? void 0 : file.mediaId) != null; });
|
|
787
|
+
if (agentEventId == null || !stored)
|
|
788
|
+
return;
|
|
789
|
+
var generation = this.historyGeneration;
|
|
790
|
+
void (function () { return __awaiter(_this, void 0, void 0, function () {
|
|
791
|
+
var _loop_1, this_1, _i, TOOL_FILE_RETRY_MS_1, delay, state_1;
|
|
792
|
+
return __generator(this, function (_a) {
|
|
793
|
+
switch (_a.label) {
|
|
794
|
+
case 0:
|
|
795
|
+
_loop_1 = function (delay) {
|
|
796
|
+
var media;
|
|
797
|
+
return __generator(this, function (_b) {
|
|
798
|
+
switch (_b.label) {
|
|
799
|
+
case 0:
|
|
800
|
+
if (!delay) return [3 /*break*/, 2];
|
|
801
|
+
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, delay); })];
|
|
802
|
+
case 1:
|
|
803
|
+
_b.sent();
|
|
804
|
+
_b.label = 2;
|
|
805
|
+
case 2:
|
|
806
|
+
if (generation !== this_1.historyGeneration)
|
|
807
|
+
return [2 /*return*/, { value: void 0 }];
|
|
808
|
+
return [4 /*yield*/, fetchToolFileMedia(agentEventId)];
|
|
809
|
+
case 3:
|
|
810
|
+
media = _b.sent();
|
|
811
|
+
if (generation !== this_1.historyGeneration)
|
|
812
|
+
return [2 /*return*/, { value: void 0 }];
|
|
813
|
+
if (media.length) {
|
|
814
|
+
this_1.dispatch(agentToolFilesResolved({ agentEventId: agentEventId, media: media }));
|
|
815
|
+
return [2 /*return*/, { value: void 0 }];
|
|
816
|
+
}
|
|
817
|
+
return [2 /*return*/];
|
|
818
|
+
}
|
|
819
|
+
});
|
|
820
|
+
};
|
|
821
|
+
this_1 = this;
|
|
822
|
+
_i = 0, TOOL_FILE_RETRY_MS_1 = TOOL_FILE_RETRY_MS;
|
|
823
|
+
_a.label = 1;
|
|
824
|
+
case 1:
|
|
825
|
+
if (!(_i < TOOL_FILE_RETRY_MS_1.length)) return [3 /*break*/, 4];
|
|
826
|
+
delay = TOOL_FILE_RETRY_MS_1[_i];
|
|
827
|
+
return [5 /*yield**/, _loop_1(delay)];
|
|
828
|
+
case 2:
|
|
829
|
+
state_1 = _a.sent();
|
|
830
|
+
if (typeof state_1 === "object")
|
|
831
|
+
return [2 /*return*/, state_1.value];
|
|
832
|
+
_a.label = 3;
|
|
833
|
+
case 3:
|
|
834
|
+
_i++;
|
|
835
|
+
return [3 /*break*/, 1];
|
|
836
|
+
case 4: return [2 /*return*/];
|
|
837
|
+
}
|
|
838
|
+
});
|
|
839
|
+
}); })();
|
|
755
840
|
}
|
|
756
841
|
});
|
|
757
842
|
Object.defineProperty(AgentRuntime.prototype, "publish", {
|
|
@@ -781,14 +866,14 @@ var AgentRuntime = /** @class */ (function () {
|
|
|
781
866
|
if (provider)
|
|
782
867
|
setStoredProviderAndModel(provider, model !== null && model !== void 0 ? model : undefined);
|
|
783
868
|
eventBus.emit(SOLID_AGENT_EVENTS.sessionChanged, { sessionId: sessionId, agentType: this.agentRuntime, provider: provider, model: model });
|
|
784
|
-
var
|
|
869
|
+
var state_2 = this.getState();
|
|
785
870
|
var historyId = (_h = (_g = event.frame.history_session_id) !== null && _g !== void 0 ? _g : event.eventData.history_session_id) !== null && _h !== void 0 ? _h : sessionId;
|
|
786
871
|
if (historyId !== this.historySessionId) {
|
|
787
872
|
this.resetHistoryLoads();
|
|
788
873
|
this.historySessionId = historyId;
|
|
789
874
|
}
|
|
790
|
-
if (event.eventType === AgentEventTypes.sessionStarted &&
|
|
791
|
-
|
|
875
|
+
if (event.eventType === AgentEventTypes.sessionStarted && state_2 &&
|
|
876
|
+
state_2.items.every(function (item) { var _a, _b; return item.id === humanReviewId((_b = (_a = state_2.pendingReview) === null || _a === void 0 ? void 0 : _a.requestId) !== null && _b !== void 0 ? _b : 0); }) && historyId) {
|
|
792
877
|
void this.loadHistory(historyId, 1);
|
|
793
878
|
}
|
|
794
879
|
else if (event.eventType === AgentEventTypes.sessionStarted)
|