@amd-gaia/agent-ui 0.26.1-rc.2 → 0.27.0-rc.2
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/assets/AdvancedSettings-DHERtrno.js +1 -0
- package/dist/assets/AutomationsSettings-4FWcRau9.js +1 -0
- package/dist/assets/ConnectorsPane-BGI8nBUb.css +1 -0
- package/dist/assets/ConnectorsPane-Dkat1zLC.js +1 -0
- package/dist/assets/DocumentLibrary-Dll55N7l.js +5 -0
- package/dist/assets/DocumentLibrary-fEMoY7lH.css +1 -0
- package/dist/assets/FileBrowser-1goNp4CP.css +1 -0
- package/dist/assets/FileBrowser-wFHqH6K_.js +4 -0
- package/dist/assets/MemoryDashboard-BuUBoNq8.js +1 -0
- package/dist/assets/MemoryDashboard-RpfLag-v.css +1 -0
- package/dist/assets/MessagingSettings-DomiT2rX.js +1 -0
- package/dist/assets/MobileAccessModal-B2gaE8nk.js +2 -0
- package/dist/assets/{MobileAccessModal-CX4NZmr4.css → MobileAccessModal-BrZMaERi.css} +1 -1
- package/dist/assets/ScheduleManager-8UE81KlQ.js +1 -0
- package/dist/assets/ScheduleManager-BZzEH2-W.css +1 -0
- package/dist/assets/Temml-CCjoacWt.woff2 +0 -0
- package/dist/assets/index-BiETDNik.css +1 -0
- package/dist/assets/index-HCZ86cyP.js +220 -0
- package/dist/assets/useFocusTrap-BFi0chLf.js +6 -0
- package/dist/assets/zap-DjkIffnX.js +1 -0
- package/dist/index.html +3 -3
- package/dist/sw.js +1 -1
- package/main.cjs +130 -40
- package/package.json +5 -3
- package/preload.cjs +28 -0
- package/services/browser-pane/bridge-error.cjs +20 -0
- package/services/browser-pane/bridge-server.cjs +496 -0
- package/services/browser-pane/cdp-session.cjs +375 -0
- package/services/browser-pane/contract.d.ts +448 -0
- package/services/browser-pane/dev-servers.cjs +478 -0
- package/services/browser-pane/input.cjs +375 -0
- package/services/browser-pane/ipc.cjs +267 -0
- package/services/browser-pane/navigation-policy.cjs +255 -0
- package/services/browser-pane/pane-host.cjs +1686 -0
- package/services/browser-pane/picker-world.js +360 -0
- package/services/browser-pane/picker.cjs +261 -0
- package/services/browser-pane/service-ports.cjs +66 -0
- package/services/dev-qa-mode.cjs +32 -0
- package/dist/assets/AdvancedSettings-C-9ErldS.js +0 -1
- package/dist/assets/AutomationsSettings-CL3K4hLZ.js +0 -1
- package/dist/assets/ConnectorsPane-DpGR78cA.js +0 -1
- package/dist/assets/ConnectorsPane-w-HLcq3n.css +0 -1
- package/dist/assets/DocumentLibrary-BKZdx6rJ.css +0 -1
- package/dist/assets/DocumentLibrary-N7tBbt9v.js +0 -5
- package/dist/assets/FileBrowser-CO2p3xa2.js +0 -4
- package/dist/assets/FileBrowser-CrRQXiPo.css +0 -1
- package/dist/assets/MemoryDashboard-1OIrKFIa.js +0 -1
- package/dist/assets/MemoryDashboard-B4AO_CU8.css +0 -1
- package/dist/assets/MessagingSettings-0AJnsoWA.js +0 -1
- package/dist/assets/MobileAccessModal-CnPB1BEN.js +0 -2
- package/dist/assets/ScheduleManager-BYOhqnfv.js +0 -1
- package/dist/assets/ScheduleManager-DQBnf_IN.css +0 -1
- package/dist/assets/index-Bkx-QRv4.css +0 -1
- package/dist/assets/index-C-3wCH_s.js +0 -116
- package/dist/assets/useT-DuzpQY8p.js +0 -6
- package/dist/assets/zap-gF9QDKfa.js +0 -1
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
// Copyright(C) 2026 Advanced Micro Devices, Inc. All rights reserved.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
// The browser pane's shared shapes. The .cjs services reference them through
|
|
5
|
+
// JSDoc imports and the renderer imports them as types.
|
|
6
|
+
|
|
7
|
+
export type TabId = string & { readonly __brand: "TabId" };
|
|
8
|
+
|
|
9
|
+
/** Whose tabs: a chat's session id, or null for the new-chat screen until its first message makes the chat. */
|
|
10
|
+
export type ChatKey = string | null;
|
|
11
|
+
|
|
12
|
+
/** Why the pane refused or could not show something; cleared by the tab's next navigation. */
|
|
13
|
+
export type PaneNotice =
|
|
14
|
+
| { kind: "blocked"; url: string; message: string }
|
|
15
|
+
| { kind: "load-failed"; url: string; message: string }
|
|
16
|
+
| { kind: "permission-denied"; permission: string; origin: string };
|
|
17
|
+
|
|
18
|
+
/** Who may drive a tab: shared with the agent, held by the user (the agent is paused), or private (hidden from the agent). */
|
|
19
|
+
export type TabControl = "shared" | "user" | "private";
|
|
20
|
+
|
|
21
|
+
/** A screen to emulate. size null fills the pane; colorScheme null follows the system. */
|
|
22
|
+
export interface ViewportChoice {
|
|
23
|
+
size: { width: number; height: number; mobile: boolean } | null;
|
|
24
|
+
colorScheme: "light" | "dark" | null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** The emulated screen, and who chose it. A user's choice wins over the agent's. */
|
|
28
|
+
export interface ViewportState extends ViewportChoice {
|
|
29
|
+
source: "user" | "agent";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** A box the page opened with alert(), confirm() or prompt(), or the pane's "leave this page?" for beforeunload. */
|
|
33
|
+
export type PageDialogType = "alert" | "confirm" | "prompt" | "beforeunload";
|
|
34
|
+
|
|
35
|
+
/** The box a tab's page is waiting on. The page is frozen until someone answers it. */
|
|
36
|
+
export interface PageDialog {
|
|
37
|
+
type: PageDialogType;
|
|
38
|
+
message: string;
|
|
39
|
+
/** The prompt's starting text; "" for other boxes. */
|
|
40
|
+
defaultText: string;
|
|
41
|
+
/** The page or frame that opened it. */
|
|
42
|
+
url: string;
|
|
43
|
+
/** "agent" when it opened during the agent's op on this tab: dismissed when that agent's turn ends unanswered. */
|
|
44
|
+
openedBy: "agent" | "page";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface TabState {
|
|
48
|
+
id: TabId;
|
|
49
|
+
/** null while the tab shows the new tab page and has no page of its own. */
|
|
50
|
+
url: string | null;
|
|
51
|
+
title: string;
|
|
52
|
+
loading: boolean;
|
|
53
|
+
canGoBack: boolean;
|
|
54
|
+
canGoForward: boolean;
|
|
55
|
+
devToolsOpen: boolean;
|
|
56
|
+
notice: PaneNotice | null;
|
|
57
|
+
/** The chat session whose agent opened this tab, or null when the user did. */
|
|
58
|
+
openedBy: string | null;
|
|
59
|
+
/** True while an agent op runs on this tab, and briefly after; drives the "GAIA is reading" strip. */
|
|
60
|
+
agentBusy: boolean;
|
|
61
|
+
/** True while the agent clicks or types here, and between its steps; drives "GAIA is using this tab". */
|
|
62
|
+
agentActing: boolean;
|
|
63
|
+
control: TabControl;
|
|
64
|
+
/** null when the page fills the pane at the system color scheme. */
|
|
65
|
+
viewport: ViewportState | null;
|
|
66
|
+
/** The box the page waits on, or null. One at a time per tab. */
|
|
67
|
+
dialog: PageDialog | null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface RecentPage {
|
|
71
|
+
url: string;
|
|
72
|
+
title: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Main owns this and pushes all of it on every change. The renderer only mirrors it. */
|
|
76
|
+
export interface PaneState {
|
|
77
|
+
/** The chat the window shows; tabs and activeTabId are that chat's alone. */
|
|
78
|
+
chat: ChatKey;
|
|
79
|
+
visible: boolean;
|
|
80
|
+
occluded: boolean;
|
|
81
|
+
/** Empty only for a chat that never opened the pane; closing a chat's last tab leaves a new tab page. */
|
|
82
|
+
tabs: TabState[];
|
|
83
|
+
/** null while the chat has no tabs. */
|
|
84
|
+
activeTabId: TabId | null;
|
|
85
|
+
/** The shown chat's recently visited pages, newest first. */
|
|
86
|
+
recent: RecentPage[];
|
|
87
|
+
/** True while the user picks elements on the active tab (Cmd+Shift+S). */
|
|
88
|
+
picking: boolean;
|
|
89
|
+
/** Dev servers GAIA started this run, for the toolbar's Dev servers menu. */
|
|
90
|
+
devServers: DevServerState[];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// ─── Dev servers ────────────────────────────────────────────────────────
|
|
94
|
+
|
|
95
|
+
/** One launch.json configuration as Python resolved it (gaia/browser/dev_servers.py). Never a shell string. */
|
|
96
|
+
export interface DevServerSpec {
|
|
97
|
+
name: string;
|
|
98
|
+
argv: string[];
|
|
99
|
+
/** Absolute; Python checked it is inside the chat's allowed folders. */
|
|
100
|
+
cwd: string;
|
|
101
|
+
port: number;
|
|
102
|
+
/** Only names in bridge/dev_server_env.json; the app's own environment passes through an allowlist too. */
|
|
103
|
+
env: Record<string, string>;
|
|
104
|
+
/** http://localhost:<port><path> */
|
|
105
|
+
url: string;
|
|
106
|
+
readyTimeoutMs: number;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** starting until the port answers; failed when it exits first; exited when it ends later on its own. */
|
|
110
|
+
export type DevServerStatus = "starting" | "ready" | "failed" | "exited" | "stopped";
|
|
111
|
+
|
|
112
|
+
export interface DevServerState {
|
|
113
|
+
/** Python's handle: sha256 of cwd and name, 16 hex digits. */
|
|
114
|
+
key: string;
|
|
115
|
+
name: string;
|
|
116
|
+
argv: string[];
|
|
117
|
+
cwd: string;
|
|
118
|
+
port: number;
|
|
119
|
+
env: Record<string, string>;
|
|
120
|
+
url: string;
|
|
121
|
+
status: DevServerStatus;
|
|
122
|
+
/** null once it is no longer running. */
|
|
123
|
+
pid: number | null;
|
|
124
|
+
startedAt: number;
|
|
125
|
+
exitCode: number | null;
|
|
126
|
+
logFile: string;
|
|
127
|
+
/** Session ids of the chats using it: the one that started it first. Deleting the last one stops it. */
|
|
128
|
+
chats: string[];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** The placeholder's rect in CSS pixels, from getBoundingClientRect. */
|
|
132
|
+
export interface CssRect {
|
|
133
|
+
x: number;
|
|
134
|
+
y: number;
|
|
135
|
+
width: number;
|
|
136
|
+
height: number;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export type HistoryAction = "back" | "forward" | "reload" | "stop";
|
|
140
|
+
|
|
141
|
+
// ─── Element picker ─────────────────────────────────────────────────────
|
|
142
|
+
|
|
143
|
+
/** The computed styles a pick carries. Mirrors STYLE_PROPS in picker.cjs and gaia/browser/picked.py. */
|
|
144
|
+
export type PickedStyleProp =
|
|
145
|
+
| "display" | "position" | "width" | "height" | "margin" | "padding" | "gap"
|
|
146
|
+
| "color" | "background-color" | "font-family" | "font-size" | "font-weight" | "line-height"
|
|
147
|
+
| "border" | "border-radius" | "box-shadow" | "opacity" | "z-index";
|
|
148
|
+
|
|
149
|
+
/** A React component from the page's main world; source only where the dev build stamps it. */
|
|
150
|
+
export interface PickedComponent {
|
|
151
|
+
name: string;
|
|
152
|
+
source: { file: string; line: number } | null;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** One element the user picked, as main builds it (picker.cjs). */
|
|
156
|
+
export interface PickedElement {
|
|
157
|
+
/** "p1", "p2" ...: stamped on the element as data-gaia-pick, so browser_click("p1") clicks it. */
|
|
158
|
+
ref: string;
|
|
159
|
+
url: string;
|
|
160
|
+
title: string;
|
|
161
|
+
tag: string;
|
|
162
|
+
/** tag.class, as the outline's label shows it. */
|
|
163
|
+
label: string;
|
|
164
|
+
/** Shortest unique: #id, [data-testid], then a tag:nth-of-type path. */
|
|
165
|
+
selector: string;
|
|
166
|
+
role: string;
|
|
167
|
+
name: string;
|
|
168
|
+
text: string;
|
|
169
|
+
/** CSS px, relative to the viewport when picked. */
|
|
170
|
+
rect: CssRect;
|
|
171
|
+
component: PickedComponent | null;
|
|
172
|
+
/** At most 1536 characters; descendants past depth 2 folded to a comment. */
|
|
173
|
+
outerHTML: string;
|
|
174
|
+
/** Only values that differ from the usual default. */
|
|
175
|
+
styles: Partial<Record<PickedStyleProp, string>>;
|
|
176
|
+
/** PNG crop, base64, at most 800 px wide; null when it had no size or could not be taken. */
|
|
177
|
+
crop: string | null;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* One chip as the chat request carries it (`page_elements`), validated by
|
|
182
|
+
* gaia/browser/picked.py. A toggle that is off sends null; the crop travels
|
|
183
|
+
* as an uploaded file.
|
|
184
|
+
*/
|
|
185
|
+
export interface PageElementWire extends Omit<PickedElement, "crop" | "outerHTML" | "styles"> {
|
|
186
|
+
outerHTML: string | null;
|
|
187
|
+
styles: Partial<Record<PickedStyleProp, string>> | null;
|
|
188
|
+
cropUrl: string | null;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** The current selection of one picking run. A later event for the same run replaces it. */
|
|
192
|
+
export interface PickEvent {
|
|
193
|
+
run: number;
|
|
194
|
+
elements: PickedElement[];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** Commands main sends the window: the toggle shortcut pressed inside a pane page, or a chat's agent showing a page. */
|
|
198
|
+
export type PaneCommand = { kind: "toggle" } | { kind: "show"; chat: string };
|
|
199
|
+
|
|
200
|
+
/** window.gaiaBrowserPane (preload.cjs). Present only in the desktop app. */
|
|
201
|
+
export interface GaiaBrowserPaneAPI {
|
|
202
|
+
getState(): Promise<PaneState>;
|
|
203
|
+
/** Returns its unsubscribe. */
|
|
204
|
+
onState(cb: (state: PaneState) => void): () => void;
|
|
205
|
+
onCommand(cb: (command: PaneCommand) => void): () => void;
|
|
206
|
+
setBounds(rect: CssRect): void;
|
|
207
|
+
/** The chat this window shows and whether its pane is open. Only that chat's agent may use the pane. */
|
|
208
|
+
setView(chat: ChatKey, visible: boolean): void;
|
|
209
|
+
/** The new-chat screen's first message made this chat: its tabs become the chat's. */
|
|
210
|
+
claimDraft(sessionId: string): void;
|
|
211
|
+
/** The user deleted this chat: its tabs close, its dev servers stop, and its id is refused from now on. */
|
|
212
|
+
forgetChat(sessionId: string): void;
|
|
213
|
+
/** Hides the live page under an app overlay. Resolves with a still frame of it, or null when no page shows. */
|
|
214
|
+
setOccluded(occluded: boolean): Promise<string | null>;
|
|
215
|
+
openTab(url: string | null): Promise<TabId>;
|
|
216
|
+
closeTab(tabId: TabId): Promise<void>;
|
|
217
|
+
selectTab(tabId: TabId): Promise<void>;
|
|
218
|
+
navigate(tabId: TabId, url: string): Promise<void>;
|
|
219
|
+
history(tabId: TabId, action: HistoryAction): Promise<void>;
|
|
220
|
+
toggleDevTools(tabId: TabId): Promise<void>;
|
|
221
|
+
clearBrowsingData(): Promise<void>;
|
|
222
|
+
openExternal(tabId: TabId): Promise<void>;
|
|
223
|
+
/** Pause and Resume on the strip, and marking a tab private. */
|
|
224
|
+
setControl(tabId: TabId, control: TabControl): Promise<void>;
|
|
225
|
+
/** The Responsive control. null fills the pane again and lets the agent choose. */
|
|
226
|
+
setViewport(tabId: TabId, choice: ViewportChoice | null): Promise<void>;
|
|
227
|
+
/** Select element (Cmd+Shift+S): starts picking on the active tab, or ends it. */
|
|
228
|
+
togglePicking(): Promise<void>;
|
|
229
|
+
onPicked(cb: (event: PickEvent) => void): () => void;
|
|
230
|
+
/** Stop in the Dev servers menu. */
|
|
231
|
+
stopDevServer(key: string): Promise<void>;
|
|
232
|
+
/** The user's answer to the box in the pane. text is the prompt's answer; null keeps its starting text. */
|
|
233
|
+
answerDialog(tabId: TabId, accept: boolean, text: string | null): Promise<void>;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// ─── Bridge (the agent, in Python, to main) ─────────────────────────────
|
|
237
|
+
// Served by bridge-server.cjs, called by gaia/browser/_pane_bridge.py.
|
|
238
|
+
// POST /v1/<op>, `Authorization: Bearer <token>`, a JSON body, a JSON reply.
|
|
239
|
+
|
|
240
|
+
/** Written at mode 0600 to the discovery file on start; removed on quit. */
|
|
241
|
+
export interface BridgeDiscovery {
|
|
242
|
+
port: number;
|
|
243
|
+
/** 32 random bytes, hex. */
|
|
244
|
+
token: string;
|
|
245
|
+
pid: number;
|
|
246
|
+
protocol: number;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** null in a request means the chat's active tab, the one the user is looking at. Any other chat's tab is no_such_tab. */
|
|
250
|
+
export type TabRef = TabId | null;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Loopback needs no entry. Any other origin the op may read or land on, as
|
|
254
|
+
* URL.origin spells it, approved for this one call by Python's site gate.
|
|
255
|
+
*/
|
|
256
|
+
export type AllowedOrigins = string[];
|
|
257
|
+
|
|
258
|
+
/** A tab as the agent sees it. Only its own chat's tabs, and never private ones. */
|
|
259
|
+
export interface TabSummary {
|
|
260
|
+
id: TabId;
|
|
261
|
+
url: string | null;
|
|
262
|
+
title: string;
|
|
263
|
+
active: boolean;
|
|
264
|
+
openedBy: string | null;
|
|
265
|
+
control: "shared" | "user";
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export interface TabsReply {
|
|
269
|
+
tabs: TabSummary[];
|
|
270
|
+
/** null while the user looks at a private tab, or the chat has no tabs. */
|
|
271
|
+
activeTabId: TabId | null;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** The only keys the agent may press; anything else is refused before it reaches the page. */
|
|
275
|
+
export type AllowedKey =
|
|
276
|
+
| "Enter" | "Escape" | "Tab" | "Backspace" | "Space"
|
|
277
|
+
| "PageDown" | "PageUp" | "Home" | "End"
|
|
278
|
+
| "ArrowLeft" | "ArrowUp" | "ArrowRight" | "ArrowDown";
|
|
279
|
+
|
|
280
|
+
/** One trusted input action. fill picks a <select> option by its label. */
|
|
281
|
+
export type ActAction =
|
|
282
|
+
| { kind: "click" }
|
|
283
|
+
| { kind: "fill"; text: string; pressEnter: boolean }
|
|
284
|
+
| { kind: "press"; key: AllowedKey };
|
|
285
|
+
|
|
286
|
+
/** Built by Python from its snapshot ref table, never from model text. frameId null is the main frame; any frame, cross-site too. */
|
|
287
|
+
export interface ActTarget {
|
|
288
|
+
frameId: string | null;
|
|
289
|
+
selector: string;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export interface FrameEval {
|
|
293
|
+
/** null for the main frame, else "processId:routingId". Main comes first. */
|
|
294
|
+
frameId: string | null;
|
|
295
|
+
url: string;
|
|
296
|
+
ok: boolean;
|
|
297
|
+
value?: unknown;
|
|
298
|
+
error?: string;
|
|
299
|
+
/** Set when the frame was not read because its site isn't approved: that origin, or null when it has no http(s) one. */
|
|
300
|
+
unapproved?: string | null;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export interface LogEntry {
|
|
304
|
+
/** Rises by one per entry in each tab; the reader's cursor. */
|
|
305
|
+
seq: number;
|
|
306
|
+
at: number;
|
|
307
|
+
level: "log" | "info" | "warning" | "error";
|
|
308
|
+
/** At most 500 characters. */
|
|
309
|
+
text: string;
|
|
310
|
+
/** url:line */
|
|
311
|
+
source?: string;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export interface NetworkEntry {
|
|
315
|
+
seq: number;
|
|
316
|
+
at: number;
|
|
317
|
+
method: string;
|
|
318
|
+
/** At most 300 characters. */
|
|
319
|
+
url: string;
|
|
320
|
+
/** null when the request failed before a response. */
|
|
321
|
+
status: number | null;
|
|
322
|
+
resourceType: string;
|
|
323
|
+
durationMs: number | null;
|
|
324
|
+
failure?: string;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export interface BridgeOps {
|
|
328
|
+
hello: { req: Record<string, never>; res: { protocol: number; appVersion: string; ops: BridgeOp[] } };
|
|
329
|
+
/** not_in_desktop is an answer here, so Python uses its headless browser; every later op sends sessionId and fails with not_in_desktop once the user switches chats. */
|
|
330
|
+
attach: {
|
|
331
|
+
req: { sessionId: string };
|
|
332
|
+
res: { status: "attached"; tabId: TabId | null; paneVisible: boolean } | { status: "not_in_desktop" };
|
|
333
|
+
};
|
|
334
|
+
tabs: {
|
|
335
|
+
req:
|
|
336
|
+
| { sessionId: string; op: "list" }
|
|
337
|
+
| { sessionId: string; op: "open"; url: string; allowedOrigins: AllowedOrigins }
|
|
338
|
+
| { sessionId: string; op: "select"; tabId: TabId };
|
|
339
|
+
res: TabsReply;
|
|
340
|
+
};
|
|
341
|
+
navigate: {
|
|
342
|
+
req: { sessionId: string; tabId: TabRef; to: string | "back" | "forward" | "reload"; allowedOrigins: AllowedOrigins };
|
|
343
|
+
res: { tabId: TabId; url: string; title: string };
|
|
344
|
+
};
|
|
345
|
+
/** The script is Python's own (the snapshot or find script), never model text. */
|
|
346
|
+
evaluate: {
|
|
347
|
+
req: { sessionId: string; tabId: TabRef; script: string; args: unknown; frames: "main" | "all"; allowedOrigins: AllowedOrigins };
|
|
348
|
+
res: { tabId: TabId; url: string; frames: FrameEval[] };
|
|
349
|
+
};
|
|
350
|
+
origin: {
|
|
351
|
+
req: { sessionId: string; tabId: TabRef };
|
|
352
|
+
/** frameOrigins: the http(s) origins of the page's frames, other than the page's own, in document order. */
|
|
353
|
+
res: { tabId: TabId; url: string | null; origin: string | null; hasCookies: boolean; frameOrigins: string[] };
|
|
354
|
+
};
|
|
355
|
+
screenshot: {
|
|
356
|
+
req: { sessionId: string; tabId: TabRef; clip: { frameId: string | null; selector: string } | null; maxWidth: number; allowedOrigins: AllowedOrigins };
|
|
357
|
+
res: { png: string; width: number; height: number; url: string };
|
|
358
|
+
};
|
|
359
|
+
logs: {
|
|
360
|
+
req: {
|
|
361
|
+
sessionId: string;
|
|
362
|
+
tabId: TabRef;
|
|
363
|
+
kind: "console" | "network";
|
|
364
|
+
afterSeq: number;
|
|
365
|
+
errorsOnly: boolean;
|
|
366
|
+
pattern: string | null;
|
|
367
|
+
limit: number;
|
|
368
|
+
allowedOrigins: AllowedOrigins;
|
|
369
|
+
};
|
|
370
|
+
res: { entries: (LogEntry | NetworkEntry)[]; lastSeq: number; dropped: number; url: string };
|
|
371
|
+
};
|
|
372
|
+
/** Refused with user_active in a tab the user holds or touched in the last 4 s. A press may have no target: the focused element gets it. */
|
|
373
|
+
act: {
|
|
374
|
+
req: { sessionId: string; tabId: TabRef; action: ActAction; target: ActTarget | null; allowedOrigins: AllowedOrigins };
|
|
375
|
+
res: { tabId: TabId; url: string; title: string; adoptedTabId?: TabId; dialog?: PageDialog };
|
|
376
|
+
};
|
|
377
|
+
/**
|
|
378
|
+
* The page's box. get reads it for the site gate; answer is refused with
|
|
379
|
+
* off_scope when accepting a non-alert box on a site not in allowedOrigins;
|
|
380
|
+
* release dismisses the boxes this chat's agent opened and left (turn end).
|
|
381
|
+
*/
|
|
382
|
+
dialog: {
|
|
383
|
+
req:
|
|
384
|
+
| { sessionId: string; op: "get"; tabId: TabRef }
|
|
385
|
+
| { sessionId: string; op: "answer"; tabId: TabRef; accept: boolean; text: string | null; allowedOrigins: AllowedOrigins }
|
|
386
|
+
| { sessionId: string; op: "release" };
|
|
387
|
+
res:
|
|
388
|
+
| { tabId: TabId; dialog: PageDialog | null }
|
|
389
|
+
| { tabId: TabId; answered: PageDialog; url: string; title: string; dialog: PageDialog | null }
|
|
390
|
+
| { dismissed: number };
|
|
391
|
+
};
|
|
392
|
+
/** The model's expression in the page's main world (browser_eval). Refused with unsupported off loopback; page errors come back as ok false. */
|
|
393
|
+
script: {
|
|
394
|
+
req: { sessionId: string; tabId: TabRef; expression: string };
|
|
395
|
+
res:
|
|
396
|
+
| { tabId: TabId; url: string; ok: true; json: string; truncated: boolean }
|
|
397
|
+
| { tabId: TabId; url: string; ok: false; error: string; dialog?: PageDialog };
|
|
398
|
+
};
|
|
399
|
+
/** applied is false when the user picked the viewport; theirs stays. */
|
|
400
|
+
viewport: {
|
|
401
|
+
req: { sessionId: string; tabId: TabRef } & ViewportChoice;
|
|
402
|
+
res: { tabId: TabId; applied: boolean; viewport: ViewportState | null };
|
|
403
|
+
};
|
|
404
|
+
/** ensure is idempotent: the same spec returns the running server, a changed one restarts it. */
|
|
405
|
+
devServers: {
|
|
406
|
+
req:
|
|
407
|
+
| { sessionId: string; op: "list" }
|
|
408
|
+
| { sessionId: string; op: "ensure"; key: string; spec: DevServerSpec; searchPath: string | null }
|
|
409
|
+
| { sessionId: string; op: "stop"; key: string }
|
|
410
|
+
| { sessionId: string; op: "logs"; key: string; errorsOnly: boolean; pattern: string | null; limit: number };
|
|
411
|
+
res:
|
|
412
|
+
| { servers: DevServerState[] }
|
|
413
|
+
| { server: DevServerState; reused: boolean; ms: number }
|
|
414
|
+
| { server: DevServerState }
|
|
415
|
+
| { server: DevServerState; lines: string[]; matched: number; total: number };
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
export type BridgeOp = keyof BridgeOps;
|
|
420
|
+
|
|
421
|
+
/** Python maps each onto an exception in _pane_bridge.py; a test keeps the two lists equal. */
|
|
422
|
+
export type BridgeErrorCode =
|
|
423
|
+
| "unauthorized"
|
|
424
|
+
| "forbidden"
|
|
425
|
+
| "bad_request"
|
|
426
|
+
| "unknown_op"
|
|
427
|
+
| "internal"
|
|
428
|
+
| "no_such_tab"
|
|
429
|
+
| "no_page"
|
|
430
|
+
| "unsupported"
|
|
431
|
+
| "blocked_navigation"
|
|
432
|
+
| "off_scope"
|
|
433
|
+
| "navigation_failed"
|
|
434
|
+
| "blocked_url"
|
|
435
|
+
| "element_not_found"
|
|
436
|
+
| "not_in_desktop"
|
|
437
|
+
| "timeout"
|
|
438
|
+
| "user_active"
|
|
439
|
+
| "private_tab"
|
|
440
|
+
| "not_actionable"
|
|
441
|
+
| "dialog_open"
|
|
442
|
+
| "dev_server_failed"
|
|
443
|
+
| "port_in_use"
|
|
444
|
+
| "no_such_server";
|
|
445
|
+
|
|
446
|
+
export interface BridgeErrorReply {
|
|
447
|
+
error: { code: BridgeErrorCode; message: string; data: Record<string, unknown> };
|
|
448
|
+
}
|