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

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
@@ -34,7 +34,10 @@ var TAKEN_OVER_MESSAGE = "The user is controlling the browser; call browser_wait
34
34
  // src/browser.ts
35
35
  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
36
  var SERVICE = "browser";
37
+ var RESTARTING_MESSAGE = "The browser was just installed in the device and its service is restarting; call the tool again.";
38
+ var RESTART_ATTEMPTS = 3;
37
39
  var REQUEST_TIMEOUT_MS = 9e4;
40
+ var TOOL_TIMEOUT_MS = 3e5;
38
41
  function assertOwner(call) {
39
42
  if (call.ownerAccountId === void 0 || call.accountId !== call.ownerAccountId)
40
43
  throw new ToolError(NOT_OWNER_MESSAGE);
@@ -120,18 +123,28 @@ function failure(deps, call, e, starting) {
120
123
  async function runRequest(deps, call, req, timeoutMs = REQUEST_TIMEOUT_MS) {
121
124
  assertOwner(call);
122
125
  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);
126
+ let restarting = false;
127
+ for (let restarts = 0; ; restarts++) {
128
+ try {
129
+ await deps.deviceAccess.ensureService(call, await deps.serviceSpec());
130
+ } catch (e) {
131
+ throw failure(deps, call, e, true);
132
+ }
133
+ try {
134
+ const body = new TextEncoder().encode(JSON.stringify(req));
135
+ reply = parseReply(
136
+ await deps.deviceAccess.request(call, { service: SERVICE, body, timeoutMs })
137
+ );
138
+ } catch (e) {
139
+ if (restarting && !call.signal.aborted) {
140
+ if (restarts < RESTART_ATTEMPTS) continue;
141
+ throw new ToolError(RESTARTING_MESSAGE);
142
+ }
143
+ throw failure(deps, call, e, false);
144
+ }
145
+ if (reply.ok || reply.error !== "restart") break;
146
+ if (restarts >= RESTART_ATTEMPTS) throw new ToolError(RESTARTING_MESSAGE);
147
+ restarting = true;
135
148
  }
136
149
  const hosts = Array.isArray(reply.blockedHosts) ? reply.blockedHosts.filter((h) => typeof h === "string" && h !== "") : [];
137
150
  if (hosts.length > 0)
@@ -168,6 +181,7 @@ var HANDOFF_FORM = {
168
181
  };
169
182
 
170
183
  // src/handoff.ts
184
+ var PANEL = "browser";
171
185
  var MESSAGE_MAX = Math.min(2e3, HANDOFF_MAX_CHARS);
172
186
  var HANDOFF = {
173
187
  name: "browser_handoff",
@@ -186,7 +200,8 @@ var HANDOFF = {
186
200
  additionalProperties: false
187
201
  },
188
202
  keyArgs: ["message"],
189
- defaultPolicy: "allow"
203
+ defaultPolicy: "allow",
204
+ timeoutMs: TOOL_TIMEOUT_MS
190
205
  };
191
206
  function handoffHandler(deps) {
192
207
  return async (input, call) => {
@@ -210,7 +225,9 @@ function handoffHandler(deps) {
210
225
  }
211
226
  ]
212
227
  },
213
- state: { handoff: 1 }
228
+ state: { handoff: 1 },
229
+ // the person's conversation page opens the panel, where they do it
230
+ open: { contribution: PANEL }
214
231
  };
215
232
  return asked;
216
233
  }
@@ -236,6 +253,20 @@ function registerHandoffTool(ctx, deps) {
236
253
  }
237
254
 
238
255
  // ui-src/panel/page.ts
256
+ var ICONS = {
257
+ 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>',
258
+ 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>',
259
+ 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>',
260
+ 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>',
261
+ 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>',
262
+ 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>',
263
+ 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>',
264
+ 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>',
265
+ dot: '<svg width="12" height="12" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4" fill="currentColor"/></svg>',
266
+ 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>',
267
+ 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>'
268
+ };
269
+ var bone = (style) => `<span class="bone" style="${style}"></span>`;
239
270
  var PANEL_HTML = `<!doctype html>
240
271
  <html lang="en">
241
272
  <head>
@@ -243,68 +274,179 @@ var PANEL_HTML = `<!doctype html>
243
274
  <meta name="viewport" content="width=device-width, initial-scale=1">
244
275
  <title>Browser</title>
245
276
  <style>
246
- :root { color-scheme: dark light; }
277
+ :root {
278
+ color-scheme: light;
279
+ --ground: color-mix(in srgb, var(--cb-ink, #1A1A18) 5%, var(--cb-bg, #FAF9F6));
280
+ --frame-shadow: 0 1px 2px rgba(26,26,24,.06), 0 4px 16px rgba(26,26,24,.06);
281
+ --bone: color-mix(in srgb, var(--cb-ink, #1A1A18) 7%, transparent);
282
+ --radius: 6px;
283
+ }
284
+ :root[data-theme="dark"] {
285
+ color-scheme: dark;
286
+ --ground: var(--cb-bg, #0A0A0A);
287
+ --frame-shadow: 0 0 0 1px rgba(255,255,255,.08);
288
+ }
247
289
  * { box-sizing: border-box; }
248
290
  html, body { height: 100%; }
249
291
  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);
292
+ margin: 0; position: relative; overflow: hidden;
293
+ background: var(--cb-panel-2, Canvas); color: var(--cb-ink, CanvasText);
294
+ font-family: var(--cb-font, ui-monospace, "SF Mono", Menlo, monospace);
295
+ font-size: var(--cb-type-body-size, 13px); line-height: var(--cb-type-body-line, 20px);
253
296
  }
297
+ /* nothing before the host's tokens and language (init) */
298
+ body:not([data-ready]) { visibility: hidden; }
254
299
  [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;
300
+ button, input { font: inherit; color: inherit; margin: 0; }
301
+ button {
302
+ display: inline-grid; place-items: center; flex: none; height: 28px; min-width: 28px;
303
+ padding: 0; border: 0; border-radius: var(--radius); background: transparent; cursor: pointer;
304
+ white-space: nowrap;
258
305
  }
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); }
306
+ button:hover:not(:disabled) { background: var(--cb-hover, rgba(26,26,24,.04)); }
307
+ button:disabled { color: var(--cb-disabled, GrayText); cursor: default; }
308
+ button:focus-visible, input:focus-visible { outline: 2px solid var(--cb-focus-ring, Highlight); outline-offset: 1px; }
309
+ .primary, .secondary, .outline { padding: 0 14px; font-weight: 600; }
310
+ .primary { background: var(--cb-accent, #CC4609); color: var(--cb-on-accent, #fff); }
311
+ .primary:hover:not(:disabled) { background: var(--cb-accent-hover, var(--cb-accent, #CC4609)); }
312
+ .secondary { font-weight: 400; box-shadow: inset 0 0 0 1px var(--cb-line, #D9D8D2); }
313
+ .outline { padding: 0 12px; color: var(--cb-accent, #CC4609); box-shadow: inset 0 0 0 1px var(--cb-accent, #CC4609); }
314
+
315
+ .layer { position: absolute; inset: 0; display: flex; flex-direction: column; }
316
+ #app[data-loading] { visibility: hidden; }
317
+ .row { flex: none; display: flex; align-items: center; padding: 0 12px; }
318
+
319
+ /* tab strip */
320
+ #tabs { height: 32px; align-items: stretch; gap: 2px; overflow-x: auto; scrollbar-width: none; }
321
+ .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); }
322
+ .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; }
323
+ .fav { width: 14px; height: 14px; border-radius: 3px; flex: none; background: var(--cb-line-soft, #E8E7E2); }
324
+ .tab[data-active="true"] .fav { background: var(--cb-line, #D9D8D2); }
325
+ .tab .label { flex: 1; min-width: 0; display: block; height: auto; text-align: left; overflow: hidden; text-overflow: ellipsis; font-weight: inherit; }
326
+ .tab .label:hover:not(:disabled) { background: transparent; }
327
+ .tab .label:disabled { color: inherit; }
328
+ .tab .x { width: 20px; min-width: 20px; height: 20px; border-radius: 4px; color: var(--cb-muted, #5E5E5A); }
329
+ #tabs .add { align-self: center; color: var(--cb-muted, #5E5E5A); }
330
+
331
+ /* toolbar */
332
+ #bar { height: 44px; gap: 4px; }
333
+ #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)); }
334
+ #field[data-edit] { background: var(--cb-panel, #fff); box-shadow: inset 0 0 0 1px var(--cb-line, #D9D8D2); }
335
+ #lock { display: inline-flex; flex: none; margin-left: 10px; color: var(--cb-muted, #5E5E5A); }
336
+ #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; }
337
+ #lock[hidden] + #url, #lock[hidden] ~ #urltext { padding-left: 10px; }
338
+ #url:focus { color: var(--cb-ink, #1A1A18); }
339
+ #urltext { position: absolute; inset: 0 10px 0 26px; display: flex; align-items: center; pointer-events: none; white-space: nowrap; overflow: hidden; }
340
+ #lock[hidden] ~ #urltext { left: 10px; padding-left: 0; }
341
+ #urltext span:first-child { flex: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
342
+ #urltext span:last-child { color: var(--cb-muted, #5E5E5A); overflow: hidden; text-overflow: ellipsis; }
343
+ #url:focus ~ #urltext { visibility: hidden; }
344
+ #takeover, #handback { margin-left: 4px; }
345
+ /* the takeover slot is always reserved: gone only when hand back takes its place */
346
+ #takeover[hidden]:not([data-gone]) { display: inline-grid !important; visibility: hidden; }
347
+ #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; }
348
+ #tabsbtn .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
349
+ #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); }
350
+ #tabsbtn, #more { display: none; }
351
+ @media (max-width: 440px) {
352
+ #tabs, #forward, #reload, #field { display: none; }
353
+ #tabsbtn { display: flex; }
354
+ #more { display: inline-grid; color: var(--cb-muted, #5E5E5A); }
355
+ }
356
+
357
+ /* status line: one fixed-height line */
358
+ #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; }
359
+ #status .ico { display: inline-flex; flex: none; }
360
+ #status .lead { flex: none; }
361
+ #status .detail { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
362
+ #status[data-tone="agent"] .ico, #status[data-tone="agent"] .lead { color: var(--cb-accent, #CC4609); }
363
+ #status[data-tone="user"] .ico, #status[data-tone="user"] .lead { color: var(--cb-ink, #1A1A18); }
364
+ .spin { animation: spin 1s linear infinite; }
365
+ @keyframes spin { to { transform: rotate(360deg); } }
366
+
367
+ /* needs the person: a warn strip in the status line's place */
368
+ .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); }
369
+ .warn > .ico { display: inline-flex; flex: none; color: var(--cb-warn, #8F6500); }
370
+ .warn .text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
371
+ .warn .title { color: var(--cb-warn, #8F6500); font-weight: 500; overflow-wrap: anywhere; }
372
+ .warn .body { font-family: var(--cb-font-prose, system-ui, sans-serif); color: var(--cb-muted, #5E5E5A); overflow-wrap: anywhere; }
373
+ .warn .actions { display: flex; gap: 6px; flex: none; }
374
+
375
+ /* the picture, contained and centred on a neutral ground */
376
+ #stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; padding: 12px; overflow: hidden; background: var(--ground); }
377
+ #view { display: block; flex: none; border-radius: var(--radius); background: #fff; box-shadow: var(--frame-shadow); outline: none; }
378
+ #stage[data-control="user"] #view { box-shadow: 0 0 0 2px var(--cb-accent, #CC4609), 0 4px 16px rgba(26,26,24,.08); }
379
+ #view:focus-visible { box-shadow: 0 0 0 2px var(--cb-focus-ring, Highlight), var(--frame-shadow); }
380
+ #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; }
381
+ .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(--cb-panel-2, Canvas); }
382
+ .center h2 { margin: 0; font-size: inherit; font-weight: 600; }
383
+ .center p { margin: 0; font-family: var(--cb-font-prose, system-ui, sans-serif); color: var(--cb-muted, #5E5E5A); }
384
+ .center button { margin-top: 6px; }
385
+ /* short-lived notices float over the picture's bottom edge: they never move it */
386
+ #strips { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
387
+ .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); }
388
+ .strip p { flex: 1; min-width: 0; margin: 0; overflow-wrap: anywhere; }
389
+ .strip .label { color: var(--cb-muted, #5E5E5A); }
390
+ .strip:not(:has(button)) { padding-right: 12px; }
391
+
392
+ /* menus (narrow: tabs, more) */
393
+ .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); }
394
+ .menu button { display: flex; width: 100%; justify-content: flex-start; gap: 8px; padding: 0 8px; text-align: left; overflow: hidden; text-overflow: ellipsis; }
395
+ .menu button[aria-current="true"] { font-weight: 600; }
396
+
397
+ /* the skeleton: the panel's own shape, quietly pulsing */
398
+ .bone { display: block; flex: none; border-radius: 2px; background: var(--bone); animation: pulse 1.6s ease-in-out infinite; }
399
+ @keyframes pulse { 50% { opacity: .5; } }
400
+ #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); }
401
+ :root[data-theme="dark"] #skeleton .shot { background: var(--cb-raised, #141413); box-shadow: var(--frame-shadow); }
402
+ #skeleton .narrow { display: none; }
403
+ @media (max-width: 440px) {
404
+ #skeleton .wide { display: none; }
405
+ #skeleton .narrow { display: block; }
406
+ }
407
+ @media (prefers-reduced-motion: reduce) { .bone, .spin { animation: none; } }
281
408
  </style>
282
409
  </head>
283
410
  <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>
411
+ <div id="skeleton" class="layer" aria-busy="true">
412
+ <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>
413
+ <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>
414
+ <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>
415
+ <div style="flex:1;min-height:0;display:flex;align-items:center;justify-content:center;padding:12px;background:var(--ground)">
416
+ <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>
417
+ </div>
293
418
  </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>
419
+ <div id="app" class="layer" data-loading>
420
+ <div id="tabs" class="row" role="tablist"></div>
421
+ <div id="bar" class="row">
422
+ <button type="button" id="back">${ICONS.back}</button>
423
+ <button type="button" id="forward">${ICONS.forward}</button>
424
+ <button type="button" id="reload">${ICONS.reload}</button>
425
+ <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>
426
+ <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>
427
+ <button type="button" id="more" aria-haspopup="menu">${ICONS.more}</button>
428
+ <button type="button" id="takeover" class="primary" hidden></button>
429
+ <button type="button" id="handback" class="outline" hidden></button>
430
+ </div>
431
+ <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>
432
+ <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>
433
+ <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>
434
+ <div id="stage">
435
+ <canvas id="view" tabindex="0"></canvas>
436
+ <div id="flash" hidden></div>
437
+ <div id="empty" class="center" hidden>
438
+ <h2 id="empty-title"></h2>
439
+ <p id="empty-body"></p>
440
+ <button type="button" id="reconnect" class="secondary"></button>
441
+ </div>
442
+ <div id="strips">
443
+ <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>
444
+ <div id="dialog" class="strip" hidden><p><span id="dialog-label" class="label"></span> <span id="dialog-text"></span></p></div>
445
+ <div id="notice" class="strip" role="alert" hidden><p><span id="notice-text"></span></p></div>
446
+ </div>
303
447
  </div>
304
448
  </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>
449
+ <div id="menu" class="menu" role="menu" hidden></div>
308
450
  <script src="panel.js"></script>
309
451
  </body>
310
452
  </html>
@@ -480,7 +622,9 @@ var NAVIGATE = {
480
622
  additionalProperties: false
481
623
  },
482
624
  keyArgs: ["url", "action"],
483
- defaultPolicy: "allow"
625
+ defaultPolicy: "allow",
626
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
627
+ timeoutMs: TOOL_TIMEOUT_MS
484
628
  };
485
629
  var TABS = {
486
630
  name: "browser_tabs",
@@ -501,14 +645,18 @@ var TABS = {
501
645
  additionalProperties: false
502
646
  },
503
647
  keyArgs: ["action", "url"],
504
- defaultPolicy: "allow"
648
+ defaultPolicy: "allow",
649
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
650
+ timeoutMs: TOOL_TIMEOUT_MS
505
651
  };
506
652
  var SNAPSHOT = {
507
653
  name: "browser_snapshot",
508
654
  title: "Read the page",
509
655
  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
656
  inputSchema: { type: "object", properties: {}, additionalProperties: false },
511
- defaultPolicy: "allow"
657
+ defaultPolicy: "allow",
658
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
659
+ timeoutMs: TOOL_TIMEOUT_MS
512
660
  };
513
661
  var SCREENSHOT = {
514
662
  name: "browser_screenshot",
@@ -521,7 +669,9 @@ var SCREENSHOT = {
521
669
  },
522
670
  additionalProperties: false
523
671
  },
524
- defaultPolicy: "allow"
672
+ defaultPolicy: "allow",
673
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
674
+ timeoutMs: TOOL_TIMEOUT_MS
525
675
  };
526
676
  var CLICK = {
527
677
  name: "browser_click",
@@ -534,7 +684,9 @@ var CLICK = {
534
684
  additionalProperties: false
535
685
  },
536
686
  keyArgs: ["ref"],
537
- defaultPolicy: "ask"
687
+ defaultPolicy: "ask",
688
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
689
+ timeoutMs: TOOL_TIMEOUT_MS
538
690
  };
539
691
  var TYPE = {
540
692
  name: "browser_type",
@@ -551,7 +703,9 @@ var TYPE = {
551
703
  additionalProperties: false
552
704
  },
553
705
  keyArgs: ["ref", "text"],
554
- defaultPolicy: "ask"
706
+ defaultPolicy: "ask",
707
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
708
+ timeoutMs: TOOL_TIMEOUT_MS
555
709
  };
556
710
  var SELECT = {
557
711
  name: "browser_select",
@@ -572,7 +726,9 @@ var SELECT = {
572
726
  additionalProperties: false
573
727
  },
574
728
  keyArgs: ["ref", "values"],
575
- defaultPolicy: "ask"
729
+ defaultPolicy: "ask",
730
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
731
+ timeoutMs: TOOL_TIMEOUT_MS
576
732
  };
577
733
  var PRESS = {
578
734
  name: "browser_press",
@@ -590,7 +746,9 @@ var PRESS = {
590
746
  additionalProperties: false
591
747
  },
592
748
  keyArgs: ["key"],
593
- defaultPolicy: "ask"
749
+ defaultPolicy: "ask",
750
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
751
+ timeoutMs: TOOL_TIMEOUT_MS
594
752
  };
595
753
  var SCROLL = {
596
754
  name: "browser_scroll",
@@ -606,7 +764,9 @@ var SCROLL = {
606
764
  additionalProperties: false
607
765
  },
608
766
  keyArgs: ["ref", "dy"],
609
- defaultPolicy: "ask"
767
+ defaultPolicy: "ask",
768
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
769
+ timeoutMs: TOOL_TIMEOUT_MS
610
770
  };
611
771
  var HOVER = {
612
772
  name: "browser_hover",
@@ -619,7 +779,9 @@ var HOVER = {
619
779
  additionalProperties: false
620
780
  },
621
781
  keyArgs: ["ref"],
622
- defaultPolicy: "ask"
782
+ defaultPolicy: "ask",
783
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
784
+ timeoutMs: TOOL_TIMEOUT_MS
623
785
  };
624
786
  var UPLOAD = {
625
787
  name: "browser_upload",
@@ -635,7 +797,9 @@ var UPLOAD = {
635
797
  additionalProperties: false
636
798
  },
637
799
  keyArgs: ["ref", "path"],
638
- defaultPolicy: "ask"
800
+ defaultPolicy: "ask",
801
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
802
+ timeoutMs: TOOL_TIMEOUT_MS
639
803
  };
640
804
  var POINT = {
641
805
  x: {
@@ -662,7 +826,9 @@ var CLICK_AT = {
662
826
  additionalProperties: false
663
827
  },
664
828
  keyArgs: ["x", "y"],
665
- defaultPolicy: "ask"
829
+ defaultPolicy: "ask",
830
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
831
+ timeoutMs: TOOL_TIMEOUT_MS
666
832
  };
667
833
  var TYPE_AT = {
668
834
  name: "browser_type_at",
@@ -675,7 +841,9 @@ var TYPE_AT = {
675
841
  additionalProperties: false
676
842
  },
677
843
  keyArgs: ["x", "y", "text"],
678
- defaultPolicy: "ask"
844
+ defaultPolicy: "ask",
845
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
846
+ timeoutMs: TOOL_TIMEOUT_MS
679
847
  };
680
848
  var WAIT = {
681
849
  name: "browser_wait",
@@ -697,7 +865,9 @@ var WAIT = {
697
865
  additionalProperties: false
698
866
  },
699
867
  keyArgs: ["text", "timeoutMs"],
700
- defaultPolicy: "allow"
868
+ defaultPolicy: "allow",
869
+ // any tool may start the device first (see TOOL_TIMEOUT_MS)
870
+ timeoutMs: TOOL_TIMEOUT_MS
701
871
  };
702
872
  var obj = (input) => typeof input === "object" && input !== null ? input : {};
703
873
  var str = (v) => typeof v === "string" ? v : void 0;
@@ -859,7 +1029,7 @@ function registerBrowserTools(ctx, deps) {
859
1029
  // src/index.ts
860
1030
  var index_default = defineExtension({
861
1031
  name: "browser",
862
- version: "0.1.0-rc.4",
1032
+ version: "0.1.0-rc.5",
863
1033
  sdk: "^0.1.0-rc.69",
864
1034
  provides: [],
865
1035
  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.5",
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",