@capybara-hq/plugin-browser 0.1.0-rc.4 → 0.1.0-rc.6

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/index.mjs CHANGED
@@ -21,6 +21,7 @@ var HANDOFF_MAX_CHARS = 4096;
21
21
  var HANDOFF_KEEPALIVE_MS = 24 * 60 * 6e4;
22
22
  var DOWNLOAD_BLOCKED_PREFIX = "The browser could not be downloaded into the device: its network settings block ";
23
23
  var REPLY_TOO_LARGE_MESSAGE = "The reply was too large to send; ask for less (a smaller maxBytes).";
24
+ var FAVICON_MAX_BYTES = 8 * 1024;
24
25
 
25
26
  // src/browser.ts
26
27
  import {
@@ -34,7 +35,24 @@ var TAKEN_OVER_MESSAGE = "The user is controlling the browser; call browser_wait
34
35
  // src/browser.ts
35
36
  var START_FAILED_MESSAGE = "The browser could not start in the device; retry, and ask the user to check the device if it keeps failing.";
36
37
  var SERVICE = "browser";
38
+ var RESTARTING_MESSAGE = "The browser was just installed in the device and its service is restarting; call the tool again.";
39
+ var RESTART_ATTEMPTS = 3;
40
+ var RESTART_WAIT_MS = 3e4;
41
+ var RESTART_PAUSE_FIRST_MS = 100;
42
+ var RESTART_PAUSE_MAX_MS = 1e3;
43
+ var pause = (ms, signal) => new Promise((resolve) => {
44
+ if (signal.aborted) return resolve();
45
+ const timer = AbortSignal.timeout(ms);
46
+ const done = () => {
47
+ signal.removeEventListener("abort", done);
48
+ timer.removeEventListener("abort", done);
49
+ resolve();
50
+ };
51
+ signal.addEventListener("abort", done, { once: true });
52
+ timer.addEventListener("abort", done, { once: true });
53
+ });
37
54
  var REQUEST_TIMEOUT_MS = 9e4;
55
+ var TOOL_TIMEOUT_MS = 3e5;
38
56
  function assertOwner(call) {
39
57
  if (call.ownerAccountId === void 0 || call.accountId !== call.ownerAccountId)
40
58
  throw new ToolError(NOT_OWNER_MESSAGE);
@@ -78,6 +96,8 @@ function daemonToolError(code, message) {
78
96
  return new ToolError(
79
97
  `${message} Check the page with browser_snapshot, then retry or call browser_wait.`
80
98
  );
99
+ case "unreachable":
100
+ return new ToolError(`${message} Check the address before retrying.`);
81
101
  case "blocked":
82
102
  if (message.startsWith(DOWNLOAD_BLOCKED_PREFIX))
83
103
  return new ToolError(
@@ -120,18 +140,45 @@ function failure(deps, call, e, starting) {
120
140
  async function runRequest(deps, call, req, timeoutMs = REQUEST_TIMEOUT_MS) {
121
141
  assertOwner(call);
122
142
  let reply;
123
- try {
124
- await deps.deviceAccess.ensureService(call, await deps.serviceSpec());
125
- } catch (e) {
126
- throw failure(deps, call, e, true);
127
- }
128
- try {
129
- const body = new TextEncoder().encode(JSON.stringify(req));
130
- reply = parseReply(
131
- await deps.deviceAccess.request(call, { service: SERVICE, body, timeoutMs })
132
- );
133
- } catch (e) {
134
- throw failure(deps, call, e, false);
143
+ let exiting;
144
+ let waitUntil = 0;
145
+ let pauseMs = RESTART_PAUSE_FIRST_MS;
146
+ const waitMore = async () => {
147
+ if (call.signal.aborted || Date.now() + pauseMs > waitUntil) return false;
148
+ await pause(pauseMs, call.signal);
149
+ pauseMs = Math.min(pauseMs * 2, RESTART_PAUSE_MAX_MS);
150
+ return !call.signal.aborted;
151
+ };
152
+ for (let restarts = 0; ; ) {
153
+ let startedAt;
154
+ try {
155
+ ({ startedAt } = await deps.deviceAccess.ensureService(call, await deps.serviceSpec()));
156
+ } catch (e) {
157
+ throw failure(deps, call, e, true);
158
+ }
159
+ if (exiting !== void 0 && startedAt !== null && startedAt === exiting.startedAt) {
160
+ if (await waitMore()) continue;
161
+ if (call.signal.aborted) throw failure(deps, call, call.signal.reason, true);
162
+ throw new ToolError(RESTARTING_MESSAGE);
163
+ }
164
+ try {
165
+ const body = new TextEncoder().encode(JSON.stringify(req));
166
+ reply = parseReply(
167
+ await deps.deviceAccess.request(call, { service: SERVICE, body, timeoutMs })
168
+ );
169
+ } catch (e) {
170
+ if (exiting !== void 0 && !call.signal.aborted) {
171
+ if (await waitMore()) continue;
172
+ if (!call.signal.aborted) throw new ToolError(RESTARTING_MESSAGE);
173
+ }
174
+ throw failure(deps, call, e, false);
175
+ }
176
+ if (reply.ok || reply.error !== "restart") break;
177
+ if (restarts >= RESTART_ATTEMPTS) throw new ToolError(RESTARTING_MESSAGE);
178
+ restarts++;
179
+ exiting = { startedAt };
180
+ waitUntil = Date.now() + RESTART_WAIT_MS;
181
+ pauseMs = RESTART_PAUSE_FIRST_MS;
135
182
  }
136
183
  const hosts = Array.isArray(reply.blockedHosts) ? reply.blockedHosts.filter((h) => typeof h === "string" && h !== "") : [];
137
184
  if (hosts.length > 0)
@@ -168,6 +215,7 @@ var HANDOFF_FORM = {
168
215
  };
169
216
 
170
217
  // src/handoff.ts
218
+ var PANEL = "browser";
171
219
  var MESSAGE_MAX = Math.min(2e3, HANDOFF_MAX_CHARS);
172
220
  var HANDOFF = {
173
221
  name: "browser_handoff",
@@ -186,7 +234,8 @@ var HANDOFF = {
186
234
  additionalProperties: false
187
235
  },
188
236
  keyArgs: ["message"],
189
- defaultPolicy: "allow"
237
+ defaultPolicy: "allow",
238
+ timeoutMs: TOOL_TIMEOUT_MS
190
239
  };
191
240
  function handoffHandler(deps) {
192
241
  return async (input, call) => {
@@ -210,7 +259,9 @@ function handoffHandler(deps) {
210
259
  }
211
260
  ]
212
261
  },
213
- state: { handoff: 1 }
262
+ state: { handoff: 1 },
263
+ // the person's conversation page opens the panel, where they do it
264
+ open: { contribution: PANEL }
214
265
  };
215
266
  return asked;
216
267
  }
@@ -236,6 +287,20 @@ function registerHandoffTool(ctx, deps) {
236
287
  }
237
288
 
238
289
  // ui-src/panel/page.ts
290
+ var ICONS = {
291
+ back: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m15 18-6-6 6-6"/></svg>',
292
+ forward: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 18 6-6-6-6"/></svg>',
293
+ reload: '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12a9 9 0 1 1-3-6.7L21 8"/><path d="M21 3v5h-5"/></svg>',
294
+ close: '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M18 6 6 18M6 6l12 12"/></svg>',
295
+ plus: '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg>',
296
+ lock: '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V7a4 4 0 0 1 8 0v4"/></svg>',
297
+ more: '<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><circle cx="5" cy="12" r="1.6"/><circle cx="12" cy="12" r="1.6"/><circle cx="19" cy="12" r="1.6"/></svg>',
298
+ spin: '<svg class="spin" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" aria-hidden="true"><path d="M21 12a9 9 0 1 1-9-9"/></svg>',
299
+ dot: '<svg width="12" height="12" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4" fill="currentColor"/></svg>',
300
+ hand: '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 11V5a2 2 0 0 1 4 0v6"/><path d="M13 10V8a2 2 0 0 1 4 0v5a7 7 0 0 1-7 7h-.5A6.5 6.5 0 0 1 5 17.5L4 15a2 2 0 0 1 3.4-2L9 15"/></svg>',
301
+ pause: '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><rect x="6" y="5" width="4" height="14" rx="1"/><rect x="14" y="5" width="4" height="14" rx="1"/></svg>'
302
+ };
303
+ var bone = (style) => `<span class="bone" style="${style}"></span>`;
239
304
  var PANEL_HTML = `<!doctype html>
240
305
  <html lang="en">
241
306
  <head>
@@ -243,68 +308,181 @@ var PANEL_HTML = `<!doctype html>
243
308
  <meta name="viewport" content="width=device-width, initial-scale=1">
244
309
  <title>Browser</title>
245
310
  <style>
246
- :root { color-scheme: dark light; }
311
+ :root {
312
+ color-scheme: light;
313
+ --ground: color-mix(in srgb, var(--cb-ink, #1A1A18) 5%, var(--cb-bg, #FAF9F6));
314
+ --frame-shadow: 0 1px 2px rgba(26,26,24,.06), 0 4px 16px rgba(26,26,24,.06);
315
+ --bone: color-mix(in srgb, var(--cb-ink, #1A1A18) 7%, transparent);
316
+ --radius: 6px;
317
+ }
318
+ :root[data-theme="dark"] {
319
+ color-scheme: dark;
320
+ --ground: var(--cb-bg, #0A0A0A);
321
+ --frame-shadow: 0 0 0 1px rgba(255,255,255,.08);
322
+ }
247
323
  * { box-sizing: border-box; }
248
324
  html, body { height: 100%; }
249
325
  body {
250
- margin: 0; display: flex; flex-direction: column; overflow: hidden;
251
- background: var(--cb-bg, Canvas); color: var(--cb-ink, CanvasText);
252
- font: 12px/1.4 var(--cb-font, ui-monospace, monospace);
326
+ margin: 0; position: relative; overflow: hidden;
327
+ background: var(--cb-panel-2, Canvas); color: var(--cb-ink, CanvasText);
328
+ font-family: var(--cb-font, ui-monospace, "SF Mono", Menlo, monospace);
329
+ font-size: var(--cb-type-body-size, 13px); line-height: var(--cb-type-body-line, 20px);
253
330
  }
331
+ /* nothing before the host's tokens and language (init) */
332
+ body:not([data-ready]) { visibility: hidden; }
254
333
  [hidden] { display: none !important; }
255
- button, input {
256
- font: inherit; color: inherit; background: transparent;
257
- border: 1px solid var(--cb-line-strong, GrayText); padding: 2px 8px; min-height: 26px;
334
+ button, input { font: inherit; color: inherit; margin: 0; }
335
+ button {
336
+ display: inline-grid; place-items: center; flex: none; height: 28px; min-width: 28px;
337
+ padding: 0; border: 0; border-radius: var(--radius); background: transparent; cursor: pointer;
338
+ white-space: nowrap;
339
+ }
340
+ button:hover:not(:disabled) { background: var(--cb-hover, rgba(26,26,24,.04)); }
341
+ button:disabled { color: var(--cb-disabled, GrayText); cursor: default; }
342
+ button:focus-visible, input:focus-visible { outline: 2px solid var(--cb-focus-ring, Highlight); outline-offset: 1px; }
343
+ .primary, .secondary, .outline { padding: 0 14px; font-weight: 600; }
344
+ .primary { background: var(--cb-accent, #CC4609); color: var(--cb-on-accent, #fff); }
345
+ .primary:hover:not(:disabled) { background: var(--cb-accent-hover, var(--cb-accent, #CC4609)); }
346
+ .secondary { font-weight: 400; box-shadow: inset 0 0 0 1px var(--cb-line, #D9D8D2); }
347
+ .outline { padding: 0 12px; color: var(--cb-accent, #CC4609); box-shadow: inset 0 0 0 1px var(--cb-accent, #CC4609); }
348
+
349
+ .layer { position: absolute; inset: 0; display: flex; flex-direction: column; }
350
+ /* laid out underneath while the skeleton or the idle state shows, so the switch never reflows */
351
+ #app[data-loading], #app[data-idle] { visibility: hidden; }
352
+ .row { flex: none; display: flex; align-items: center; padding: 0 12px; }
353
+
354
+ /* tab strip */
355
+ #tabs { height: 32px; align-items: stretch; gap: 2px; overflow-x: auto; scrollbar-width: none; }
356
+ .tab { display: flex; align-items: center; gap: 6px; flex: 0 1 auto; min-width: 64px; max-width: 200px; padding: 0 10px; color: var(--cb-muted, #5E5E5A); }
357
+ .tab[data-active="true"] { color: var(--cb-ink, #1A1A18); font-weight: 500; box-shadow: inset 0 -2px 0 var(--cb-accent, #CC4609); padding-right: 6px; }
358
+ .fav { width: 14px; height: 14px; border-radius: 3px; flex: none; background: var(--cb-line-soft, #E8E7E2); }
359
+ img.fav { background: none; object-fit: contain; }
360
+ .tab[data-active="true"] span.fav { background: var(--cb-line, #D9D8D2); }
361
+ .tab .label { flex: 1; min-width: 0; display: block; height: auto; text-align: left; overflow: hidden; text-overflow: ellipsis; font-weight: inherit; }
362
+ .tab .label:hover:not(:disabled) { background: transparent; }
363
+ .tab .label:disabled { color: inherit; }
364
+ .tab .x { width: 20px; min-width: 20px; height: 20px; border-radius: 4px; color: var(--cb-muted, #5E5E5A); }
365
+ #tabs .add { align-self: center; color: var(--cb-muted, #5E5E5A); }
366
+
367
+ /* toolbar */
368
+ #bar { height: 44px; gap: 4px; }
369
+ #field { flex: 1 1 0; min-width: 0; height: 28px; margin-left: 4px; position: relative; display: flex; align-items: center; border-radius: var(--radius); background: var(--cb-hover, rgba(26,26,24,.05)); }
370
+ #field[data-edit] { background: var(--cb-panel, #fff); box-shadow: inset 0 0 0 1px var(--cb-line, #D9D8D2); }
371
+ #lock { display: inline-flex; flex: none; margin-left: 10px; color: var(--cb-muted, #5E5E5A); }
372
+ #url { flex: 1; min-width: 0; height: 100%; padding: 0 10px 0 6px; border: 0; outline: 0; background: transparent; color: transparent; caret-color: var(--cb-ink, #1A1A18); text-overflow: ellipsis; }
373
+ #lock[hidden] + #url, #lock[hidden] ~ #urltext { padding-left: 10px; }
374
+ #url:focus { color: var(--cb-ink, #1A1A18); }
375
+ #urltext { position: absolute; inset: 0 10px 0 26px; display: flex; align-items: center; pointer-events: none; white-space: nowrap; overflow: hidden; }
376
+ #lock[hidden] ~ #urltext { left: 10px; padding-left: 0; }
377
+ #urltext span:first-child { flex: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
378
+ #urltext span:last-child { color: var(--cb-muted, #5E5E5A); overflow: hidden; text-overflow: ellipsis; }
379
+ #url:focus ~ #urltext { visibility: hidden; }
380
+ #takeover, #handback { margin-left: 4px; }
381
+ /* the takeover slot is always reserved: gone only when hand back takes its place */
382
+ #takeover[hidden]:not([data-gone]) { display: inline-grid !important; visibility: hidden; }
383
+ #tabsbtn { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 0 8px; background: var(--cb-hover, rgba(26,26,24,.05)); text-align: left; }
384
+ #tabsbtn .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
385
+ #tabsbtn .count { min-width: 18px; height: 18px; padding: 0 4px; border-radius: 4px; box-shadow: inset 0 0 0 1px var(--cb-line-strong, #B5B5AE); font-size: 11px; line-height: 18px; text-align: center; color: var(--cb-muted, #5E5E5A); }
386
+ #tabsbtn, #more { display: none; }
387
+ @media (max-width: 440px) {
388
+ #tabs, #forward, #reload, #field { display: none; }
389
+ #tabsbtn { display: flex; }
390
+ #more { display: inline-grid; color: var(--cb-muted, #5E5E5A); }
391
+ }
392
+
393
+ /* status line: one fixed-height line */
394
+ #status { height: 24px; gap: 6px; margin: 0; padding: 0 16px; font-size: var(--cb-type-micro-size, 11px); line-height: var(--cb-type-micro-line, 14px); color: var(--cb-muted, #5E5E5A); white-space: nowrap; overflow: hidden; }
395
+ #status .ico { display: inline-flex; flex: none; }
396
+ #status .lead { flex: none; }
397
+ #status .detail { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
398
+ #status[data-tone="agent"] .ico, #status[data-tone="agent"] .lead { color: var(--cb-accent, #CC4609); }
399
+ #status[data-tone="user"] .ico, #status[data-tone="user"] .lead { color: var(--cb-ink, #1A1A18); }
400
+ .spin { animation: spin 1s linear infinite; }
401
+ @keyframes spin { to { transform: rotate(360deg); } }
402
+
403
+ /* needs the person: a warn strip in the status line's place */
404
+ .warn { flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 16px; background: color-mix(in srgb, var(--cb-warn, #8F6500) 8%, transparent); }
405
+ .warn > .ico { display: inline-flex; flex: none; color: var(--cb-warn, #8F6500); }
406
+ .warn .text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
407
+ .warn .title { color: var(--cb-warn, #8F6500); font-weight: 500; overflow-wrap: anywhere; }
408
+ .warn .body { font-family: var(--cb-font-prose, system-ui, sans-serif); color: var(--cb-muted, #5E5E5A); overflow-wrap: anywhere; }
409
+ .warn .actions { display: flex; gap: 6px; flex: none; }
410
+
411
+ /* the picture, contained and centred on a neutral ground */
412
+ #stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; padding: 12px; overflow: hidden; background: var(--ground); }
413
+ #view { display: block; flex: none; border-radius: var(--radius); background: #fff; box-shadow: var(--frame-shadow); outline: none; }
414
+ #stage[data-control="user"] #view { box-shadow: 0 0 0 2px var(--cb-accent, #CC4609), 0 4px 16px rgba(26,26,24,.08); }
415
+ #view:focus-visible { box-shadow: 0 0 0 2px var(--cb-focus-ring, Highlight), var(--frame-shadow); }
416
+ #flash { position: absolute; width: 24px; height: 24px; margin: -12px 0 0 -12px; border: 2px solid var(--cb-accent, #CC4609); border-radius: 50%; pointer-events: none; }
417
+ .center { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center; padding: 16px; text-align: center; background: var(--ground); }
418
+ .center h2 { margin: 0; font-size: inherit; font-weight: 600; }
419
+ .center p { margin: 0; font-family: var(--cb-font-prose, system-ui, sans-serif); color: var(--cb-muted, #5E5E5A); }
420
+ .center button { margin-top: 6px; }
421
+ /* short-lived notices float over the picture's bottom edge: they never move it */
422
+ #strips { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
423
+ .strip { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; pointer-events: auto; border-radius: var(--cb-radius-md, 8px); background: var(--cb-raised, #fff); box-shadow: var(--cb-shadow-float, 0 8px 24px rgba(26,26,24,.08)), 0 0 0 1px var(--cb-line-soft, #E8E7E2); }
424
+ .strip p { flex: 1; min-width: 0; margin: 0; overflow-wrap: anywhere; }
425
+ .strip .label { color: var(--cb-muted, #5E5E5A); }
426
+ .strip:not(:has(button)) { padding-right: 12px; }
427
+
428
+ /* menus (narrow: tabs, more) */
429
+ .menu { position: absolute; z-index: 2; min-width: 180px; max-width: calc(100% - 24px); max-height: 60%; overflow: auto; padding: 4px; border-radius: var(--cb-radius-md, 8px); background: var(--cb-raised, #fff); box-shadow: var(--cb-shadow-float, 0 8px 24px rgba(26,26,24,.08)), 0 0 0 1px var(--cb-line-soft, #E8E7E2); }
430
+ .menu button { display: flex; width: 100%; justify-content: flex-start; gap: 8px; padding: 0 8px; text-align: left; overflow: hidden; text-overflow: ellipsis; }
431
+ .menu button[aria-current="true"] { font-weight: 600; }
432
+
433
+ /* the skeleton: the panel's own shape, quietly pulsing */
434
+ .bone { display: block; flex: none; border-radius: 2px; background: var(--bone); animation: pulse 1.6s ease-in-out infinite; }
435
+ @keyframes pulse { 50% { opacity: .5; } }
436
+ #skeleton .shot { width: 100%; max-height: 100%; aspect-ratio: 16 / 10; display: flex; flex-direction: column; gap: 12px; padding: 20px; border-radius: var(--radius); background: var(--cb-panel, #fff); box-shadow: 0 1px 2px rgba(26,26,24,.06); }
437
+ :root[data-theme="dark"] #skeleton .shot { background: var(--cb-raised, #141413); box-shadow: var(--frame-shadow); }
438
+ #skeleton .narrow { display: none; }
439
+ @media (max-width: 440px) {
440
+ #skeleton .wide { display: none; }
441
+ #skeleton .narrow { display: block; }
258
442
  }
259
- button:hover:not(:disabled) { background: var(--cb-hover, transparent); }
260
- button:disabled { opacity: .5; }
261
- button.primary { background: var(--cb-accent, Highlight); color: var(--cb-on-accent, HighlightText); border-color: transparent; }
262
- #tabs { display: flex; gap: 2px; overflow-x: auto; padding: 4px 4px 0; border-bottom: 1px solid var(--cb-line, GrayText); }
263
- .tab { display: flex; align-items: center; max-width: 160px; border: 1px solid var(--cb-line, GrayText); border-bottom: 0; padding: 0 4px 0 8px; gap: 4px; min-height: 26px; }
264
- .tab[data-active="true"] { background: var(--cb-panel, Canvas); font-weight: 600; }
265
- .tab button { border: 0; padding: 0 4px; min-height: 22px; }
266
- .tab .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 0; text-align: left; padding: 0; }
267
- #bar { display: flex; gap: 4px; padding: 4px; align-items: center; }
268
- #url { flex: 1; min-width: 0; }
269
- #lock { display: inline-flex; color: var(--cb-muted, GrayText); }
270
- #status { color: var(--cb-muted, GrayText); padding: 0 8px 4px; min-height: 18px; }
271
- #status[data-control="user"] { color: var(--cb-accent, Highlight); }
272
- #stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; background: var(--cb-panel, Canvas); position: relative; overflow: hidden; }
273
- #view { background: #fff; outline: none; display: block; }
274
- #view:focus-visible { outline: 2px solid var(--cb-accent, Highlight); }
275
- #flash { position: absolute; width: 24px; height: 24px; margin: -12px 0 0 -12px; border: 2px solid var(--cb-accent, Highlight); border-radius: 50%; pointer-events: none; }
276
- .strip { display: flex; gap: 8px; align-items: center; padding: 4px 8px; border-top: 1px solid var(--cb-line, GrayText); background: var(--cb-panel, Canvas); }
277
- .strip span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
278
- .center { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center; text-align: center; padding: 16px; background: var(--cb-bg, Canvas); }
279
- .center h2 { margin: 0; font-size: 13px; }
280
- .center p { margin: 0; color: var(--cb-muted, GrayText); }
443
+ @media (prefers-reduced-motion: reduce) { .bone, .spin { animation: none; } }
281
444
  </style>
282
445
  </head>
283
446
  <body>
284
- <div id="tabs" role="tablist"></div>
285
- <div id="bar">
286
- <button type="button" id="back"></button>
287
- <button type="button" id="forward"></button>
288
- <button type="button" id="reload"></button>
289
- <span id="lock" role="img" hidden><svg width="12" height="12" viewBox="0 0 12 12" aria-hidden="true"><rect x="2" y="5" width="8" height="6" fill="currentColor"/><path d="M4 5V3.5a2 2 0 0 1 4 0V5" fill="none" stroke="currentColor" stroke-width="1.2"/></svg></span>
290
- <input id="url" type="text" spellcheck="false" autocomplete="off">
291
- <button type="button" id="takeover" class="primary"></button>
292
- <button type="button" id="handback" class="primary" hidden></button>
447
+ <div id="skeleton" class="layer" aria-busy="true">
448
+ <div class="row wide" style="height:32px;gap:8px;padding:0 22px;display:flex">${bone("width:14px;height:14px;border-radius:3px")}${bone("width:96px;height:10px")}</div>
449
+ <div class="row" style="height:44px;gap:4px">${bone("width:28px;height:28px;border-radius:6px")}<span class="wide" style="display:contents">${bone("width:28px;height:28px;border-radius:6px")}${bone("width:28px;height:28px;border-radius:6px")}</span>${bone("flex:1;height:28px;margin-left:4px;border-radius:6px")}${bone("width:56px;height:28px;margin-left:4px;border-radius:6px")}</div>
450
+ <p id="skeleton-status" class="row" role="status" style="height:24px;margin:0;padding:0 16px;font-size:11px;line-height:14px;color:var(--cb-muted,#5E5E5A)"></p>
451
+ <div style="flex:1;min-height:0;display:flex;align-items:center;justify-content:center;padding:12px;background:var(--ground)">
452
+ <div class="shot">${bone("width:40%;height:12px")}${bone("width:75%;height:10px")}${bone("width:60%;height:10px")}${bone("flex:1;border-radius:4px")}</div>
453
+ </div>
293
454
  </div>
294
- <div id="handoff" class="strip" hidden><p><span id="handoff-label"></span> <span id="handoff-message"></span></p><button type="button" id="handoff-done" class="primary"></button><button type="button" id="handoff-cancel"></button></div>
295
- <p id="status" role="status"></p>
296
- <div id="stage">
297
- <canvas id="view" tabindex="0"></canvas>
298
- <div id="flash" hidden></div>
299
- <div id="empty" class="center" hidden>
300
- <h2 id="empty-title"></h2>
301
- <p id="empty-body"></p>
302
- <button type="button" id="reconnect"></button>
455
+ <div id="app" class="layer" data-loading>
456
+ <div id="tabs" class="row" role="tablist"></div>
457
+ <div id="bar" class="row">
458
+ <button type="button" id="back">${ICONS.back}</button>
459
+ <button type="button" id="forward">${ICONS.forward}</button>
460
+ <button type="button" id="reload">${ICONS.reload}</button>
461
+ <button type="button" id="tabsbtn" aria-haspopup="menu"><span class="fav"></span><span class="name" id="tabsbtn-name"></span><span class="count" id="tabsbtn-count"></span></button>
462
+ <label id="field"><span id="lock" role="img" hidden>${ICONS.lock}</span><input id="url" type="text" spellcheck="false" autocomplete="off"><span id="urltext"><span id="urltext-host"></span><span id="urltext-path"></span></span></label>
463
+ <button type="button" id="more" aria-haspopup="menu">${ICONS.more}</button>
464
+ <button type="button" id="takeover" class="primary" hidden></button>
465
+ <button type="button" id="handback" class="outline" hidden></button>
303
466
  </div>
467
+ <p id="status" class="row" role="status"><span class="ico" id="status-icon"></span><span class="lead" id="status-lead"></span><span class="detail" id="status-detail"></span></p>
468
+ <div id="verify" class="warn" hidden><span class="ico">${ICONS.pause}</span><div class="text"><span class="title" id="verify-title"></span><span class="body" id="verify-body"></span></div><div class="actions"><button type="button" id="verify-go" class="primary"></button></div></div>
469
+ <div id="handoff" class="warn" hidden><span class="ico">${ICONS.pause}</span><div class="text"><span class="title" id="handoff-label"></span><span class="body" id="handoff-message"></span></div><div class="actions"><button type="button" id="handoff-done" class="primary"></button><button type="button" id="handoff-cancel" class="secondary"></button></div></div>
470
+ <div id="stage">
471
+ <canvas id="view" tabindex="0"></canvas>
472
+ <div id="flash" hidden></div>
473
+ <div id="strips">
474
+ <div id="blocked" class="strip" hidden><p><span id="blocked-label" class="label"></span> <span id="blocked-host"></span></p><button type="button" id="allow" class="primary"></button></div>
475
+ <div id="dialog" class="strip" hidden><p><span id="dialog-label" class="label"></span> <span id="dialog-text"></span></p></div>
476
+ <div id="notice" class="strip" role="alert" hidden><p><span id="notice-text"></span></p></div>
477
+ </div>
478
+ </div>
479
+ </div>
480
+ <div id="empty" class="layer center" hidden>
481
+ <h2 id="empty-title"></h2>
482
+ <p id="empty-body"></p>
483
+ <button type="button" id="reconnect" class="secondary"></button>
304
484
  </div>
305
- <div id="blocked" class="strip" hidden><p><span id="blocked-label"></span> <span id="blocked-host"></span></p><button type="button" id="allow" class="primary"></button></div>
306
- <div id="dialog" class="strip" hidden><p><span id="dialog-label"></span> <span id="dialog-text"></span></p></div>
307
- <div id="notice" class="strip" role="alert" hidden><p><span id="notice-text"></span></p></div>
485
+ <div id="menu" class="menu" role="menu" hidden></div>
308
486
  <script src="panel.js"></script>
309
487
  </body>
310
488
  </html>
@@ -480,7 +658,9 @@ var NAVIGATE = {
480
658
  additionalProperties: false
481
659
  },
482
660
  keyArgs: ["url", "action"],
483
- defaultPolicy: "allow"
661
+ defaultPolicy: "allow",
662
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
663
+ timeoutMs: TOOL_TIMEOUT_MS
484
664
  };
485
665
  var TABS = {
486
666
  name: "browser_tabs",
@@ -501,14 +681,18 @@ var TABS = {
501
681
  additionalProperties: false
502
682
  },
503
683
  keyArgs: ["action", "url"],
504
- defaultPolicy: "allow"
684
+ defaultPolicy: "allow",
685
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
686
+ timeoutMs: TOOL_TIMEOUT_MS
505
687
  };
506
688
  var SNAPSHOT = {
507
689
  name: "browser_snapshot",
508
690
  title: "Read the page",
509
691
  description: "Read the active page as an accessibility tree in text, with a ref (e.g. e12) on every element you can act on. Call it after opening a page and after any action that changes the page: refs from older snapshots may no longer exist. Prefer it to browser_screenshot unless the layout or an image matters.",
510
692
  inputSchema: { type: "object", properties: {}, additionalProperties: false },
511
- defaultPolicy: "allow"
693
+ defaultPolicy: "allow",
694
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
695
+ timeoutMs: TOOL_TIMEOUT_MS
512
696
  };
513
697
  var SCREENSHOT = {
514
698
  name: "browser_screenshot",
@@ -521,7 +705,9 @@ var SCREENSHOT = {
521
705
  },
522
706
  additionalProperties: false
523
707
  },
524
- defaultPolicy: "allow"
708
+ defaultPolicy: "allow",
709
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
710
+ timeoutMs: TOOL_TIMEOUT_MS
525
711
  };
526
712
  var CLICK = {
527
713
  name: "browser_click",
@@ -534,7 +720,9 @@ var CLICK = {
534
720
  additionalProperties: false
535
721
  },
536
722
  keyArgs: ["ref"],
537
- defaultPolicy: "ask"
723
+ defaultPolicy: "ask",
724
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
725
+ timeoutMs: TOOL_TIMEOUT_MS
538
726
  };
539
727
  var TYPE = {
540
728
  name: "browser_type",
@@ -551,7 +739,9 @@ var TYPE = {
551
739
  additionalProperties: false
552
740
  },
553
741
  keyArgs: ["ref", "text"],
554
- defaultPolicy: "ask"
742
+ defaultPolicy: "ask",
743
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
744
+ timeoutMs: TOOL_TIMEOUT_MS
555
745
  };
556
746
  var SELECT = {
557
747
  name: "browser_select",
@@ -572,7 +762,9 @@ var SELECT = {
572
762
  additionalProperties: false
573
763
  },
574
764
  keyArgs: ["ref", "values"],
575
- defaultPolicy: "ask"
765
+ defaultPolicy: "ask",
766
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
767
+ timeoutMs: TOOL_TIMEOUT_MS
576
768
  };
577
769
  var PRESS = {
578
770
  name: "browser_press",
@@ -590,7 +782,9 @@ var PRESS = {
590
782
  additionalProperties: false
591
783
  },
592
784
  keyArgs: ["key"],
593
- defaultPolicy: "ask"
785
+ defaultPolicy: "ask",
786
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
787
+ timeoutMs: TOOL_TIMEOUT_MS
594
788
  };
595
789
  var SCROLL = {
596
790
  name: "browser_scroll",
@@ -606,7 +800,9 @@ var SCROLL = {
606
800
  additionalProperties: false
607
801
  },
608
802
  keyArgs: ["ref", "dy"],
609
- defaultPolicy: "ask"
803
+ defaultPolicy: "ask",
804
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
805
+ timeoutMs: TOOL_TIMEOUT_MS
610
806
  };
611
807
  var HOVER = {
612
808
  name: "browser_hover",
@@ -619,7 +815,9 @@ var HOVER = {
619
815
  additionalProperties: false
620
816
  },
621
817
  keyArgs: ["ref"],
622
- defaultPolicy: "ask"
818
+ defaultPolicy: "ask",
819
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
820
+ timeoutMs: TOOL_TIMEOUT_MS
623
821
  };
624
822
  var UPLOAD = {
625
823
  name: "browser_upload",
@@ -635,7 +833,9 @@ var UPLOAD = {
635
833
  additionalProperties: false
636
834
  },
637
835
  keyArgs: ["ref", "path"],
638
- defaultPolicy: "ask"
836
+ defaultPolicy: "ask",
837
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
838
+ timeoutMs: TOOL_TIMEOUT_MS
639
839
  };
640
840
  var POINT = {
641
841
  x: {
@@ -662,7 +862,9 @@ var CLICK_AT = {
662
862
  additionalProperties: false
663
863
  },
664
864
  keyArgs: ["x", "y"],
665
- defaultPolicy: "ask"
865
+ defaultPolicy: "ask",
866
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
867
+ timeoutMs: TOOL_TIMEOUT_MS
666
868
  };
667
869
  var TYPE_AT = {
668
870
  name: "browser_type_at",
@@ -675,7 +877,9 @@ var TYPE_AT = {
675
877
  additionalProperties: false
676
878
  },
677
879
  keyArgs: ["x", "y", "text"],
678
- defaultPolicy: "ask"
880
+ defaultPolicy: "ask",
881
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
882
+ timeoutMs: TOOL_TIMEOUT_MS
679
883
  };
680
884
  var WAIT = {
681
885
  name: "browser_wait",
@@ -697,7 +901,9 @@ var WAIT = {
697
901
  additionalProperties: false
698
902
  },
699
903
  keyArgs: ["text", "timeoutMs"],
700
- defaultPolicy: "allow"
904
+ defaultPolicy: "allow",
905
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
906
+ timeoutMs: TOOL_TIMEOUT_MS
701
907
  };
702
908
  var obj = (input) => typeof input === "object" && input !== null ? input : {};
703
909
  var str = (v) => typeof v === "string" ? v : void 0;
@@ -859,7 +1065,7 @@ function registerBrowserTools(ctx, deps) {
859
1065
  // src/index.ts
860
1066
  var index_default = defineExtension({
861
1067
  name: "browser",
862
- version: "0.1.0-rc.4",
1068
+ version: "0.1.0-rc.6",
863
1069
  sdk: "^0.1.0-rc.69",
864
1070
  provides: [],
865
1071
  ui: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capybara-hq/plugin-browser",
3
- "version": "0.1.0-rc.4",
3
+ "version": "0.1.0-rc.6",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "description": "A real browser in the person's device for agents: navigate, read and act on pages through tools, with a live view in the conversation and takeover by the person",