@opencode/plugin-browser 2.3.1 → 2.4.0

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/tools.d.ts CHANGED
@@ -3,9 +3,17 @@ import type { Context } from "@opencode/plugin/effect/plugin";
3
3
  import { Tool } from "@opencode/schema/tool";
4
4
  import { Effect } from "effect";
5
5
  import { Browser } from "./rpc.js";
6
- export declare const register: (ctx: Pick<Context, "location" | "skill" | "tool">, connection: {
7
- target: (sessionID: string & import("effect/Brand").Brand<"SessionID">, action: {
6
+ export declare const register: (ctx: Pick<Context, "location" | "permission" | "skill" | "tool">, connection: {
7
+ refuse: (tool: Tool.Context, operations: readonly string[]) => Effect.Effect<undefined, Tool.Error, never>;
8
+ authorize: (tool: Tool.Context, action: {
8
9
  readonly type: "tabs.list";
10
+ } | {
11
+ readonly type: "preview";
12
+ readonly path: string;
13
+ } | {
14
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
15
+ readonly type: "navigate.path";
16
+ readonly path: string;
9
17
  } | {
10
18
  readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
11
19
  readonly type: "back";
@@ -87,12 +95,258 @@ export declare const register: (ctx: Pick<Context, "location" | "skill" | "tool"
87
95
  readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
88
96
  readonly type: "press";
89
97
  readonly key: string;
98
+ } | {
99
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
100
+ readonly ref: string & import("effect/Brand").Brand<"Browser.Ref">;
101
+ readonly type: "select";
102
+ readonly values: readonly string[];
103
+ } | {
104
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
105
+ readonly type: "stop";
106
+ } | {
107
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
108
+ readonly type: "tabs.close";
109
+ } | {
110
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
111
+ readonly type: "tabs.focus";
112
+ } | {
113
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
114
+ readonly type: "trace.stop";
115
+ } | {
116
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
117
+ readonly ref: string & import("effect/Brand").Brand<"Browser.Ref">;
118
+ readonly type: "click";
119
+ readonly button?: "left" | "middle" | "right" | undefined;
120
+ readonly count?: 1 | 2 | undefined;
121
+ readonly modifiers?: readonly ("Alt" | "Control" | "Meta" | "Shift")[] | undefined;
122
+ } | {
123
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
124
+ readonly type: "console";
125
+ readonly level?: "debug" | "error" | "info" | "warning" | undefined;
126
+ readonly limit?: number | undefined;
127
+ } | {
128
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
129
+ readonly fileID: string & import("effect/Brand").Brand<"Browser.FileID">;
130
+ readonly type: "cpu.analyze";
131
+ readonly limit?: number | undefined;
132
+ } | {
133
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
134
+ readonly type: "dialog";
135
+ readonly action: "accept" | "dismiss" | "get";
136
+ readonly promptText?: string | undefined;
137
+ } | {
138
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
139
+ readonly frameID?: string | undefined;
140
+ readonly type: "evaluate";
141
+ readonly ref?: (string & import("effect/Brand").Brand<"Browser.Ref">) | undefined;
142
+ readonly script: string;
143
+ } | {
144
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
145
+ readonly frameID?: string | undefined;
146
+ readonly maxChars?: number | undefined;
147
+ readonly interactive?: boolean | undefined;
148
+ readonly maxLines?: number | undefined;
149
+ readonly type: "find";
150
+ readonly text: string;
151
+ } | {
152
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
153
+ readonly type: "heap.compare";
154
+ readonly before: string & import("effect/Brand").Brand<"Browser.FileID">;
155
+ readonly after: string & import("effect/Brand").Brand<"Browser.FileID">;
156
+ readonly limit?: number | undefined;
157
+ } | {
158
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
159
+ readonly fileID: string & import("effect/Brand").Brand<"Browser.FileID">;
160
+ readonly type: "heap.object";
161
+ readonly id: number;
162
+ readonly limit?: number | undefined;
163
+ } | {
164
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
165
+ readonly fileID: string & import("effect/Brand").Brand<"Browser.FileID">;
166
+ readonly type: "heap.query";
167
+ readonly name?: string | undefined;
168
+ readonly limit?: number | undefined;
169
+ } | {
170
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
171
+ readonly fileID: string & import("effect/Brand").Brand<"Browser.FileID">;
172
+ readonly type: "heap.summary";
173
+ readonly limit?: number | undefined;
174
+ } | {
175
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
176
+ readonly includeBody?: boolean | undefined;
177
+ readonly includeResponseBody?: boolean | undefined;
178
+ readonly maxBodyChars?: number | undefined;
179
+ readonly type: "network.get";
180
+ readonly id: string;
181
+ } | {
182
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
183
+ readonly type: "network.list";
184
+ readonly urlContains?: string | undefined;
185
+ readonly resourceType?: "document" | "eventsource" | "fetch" | "font" | "image" | "manifest" | "media" | "other" | "script" | "stylesheet" | "websocket" | "xhr" | undefined;
186
+ readonly limit?: number | undefined;
187
+ } | {
188
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
189
+ readonly type: "reload";
190
+ readonly ignoreCache?: boolean | undefined;
191
+ } | {
192
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
193
+ readonly type: "screenshot";
194
+ readonly ref?: (string & import("effect/Brand").Brand<"Browser.Ref">) | undefined;
195
+ readonly fullPage?: boolean | undefined;
196
+ readonly format?: "jpeg" | "png" | "webp" | undefined;
197
+ readonly quality?: number | undefined;
198
+ readonly maxWidth?: number | undefined;
199
+ } | {
200
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
201
+ readonly type: "scroll";
202
+ readonly deltaX?: number | undefined;
203
+ readonly deltaY: number;
204
+ } | {
205
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
206
+ readonly frameID?: string | undefined;
207
+ readonly maxChars?: number | undefined;
208
+ readonly interactive?: boolean | undefined;
209
+ readonly maxLines?: number | undefined;
210
+ readonly type: "snapshot";
211
+ readonly ref?: (string & import("effect/Brand").Brand<"Browser.Ref">) | undefined;
212
+ readonly depth?: number | undefined;
213
+ readonly boxes?: boolean | undefined;
214
+ } | {
215
+ readonly type: "tabs.open";
216
+ readonly url?: string | undefined;
217
+ readonly focus?: boolean | undefined;
218
+ } | {
219
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
220
+ readonly fileID: string & import("effect/Brand").Brand<"Browser.FileID">;
221
+ readonly type: "trace.analyze";
222
+ readonly limit?: number | undefined;
223
+ } | {
224
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
225
+ readonly type: "trace.start";
226
+ readonly durationMs?: number | undefined;
227
+ } | {
228
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
229
+ readonly frameID?: string | undefined;
230
+ readonly type: "wait";
231
+ readonly condition: "delay" | "load" | "text" | "textGone" | "url";
232
+ readonly text?: string | undefined;
233
+ readonly url?: string | undefined;
234
+ readonly timeoutMs?: number | undefined;
235
+ } | ({
236
+ readonly [x: string]: unknown;
237
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
238
+ readonly frameID?: string | undefined;
239
+ readonly condition?: "delay" | "element" | "elementGone" | "load" | "text" | "textGone" | "url" | undefined;
240
+ readonly text?: string | undefined;
241
+ readonly textGone?: string | undefined;
242
+ readonly selector?: string | undefined;
243
+ readonly ref?: (string & import("effect/Brand").Brand<"Browser.Ref">) | undefined;
244
+ readonly state?: "attached" | "detached" | "domcontentloaded" | "hidden" | "load" | "networkidle" | "visible" | undefined;
245
+ readonly url?: string | undefined;
246
+ readonly delayMs?: number | undefined;
247
+ readonly time?: number | undefined;
248
+ readonly ms?: number | undefined;
249
+ readonly timeoutMs?: number | undefined;
250
+ readonly timeout?: number | undefined;
251
+ } & {
252
+ readonly type: "wait";
253
+ }), operations?: readonly string[] | undefined) => Effect.Effect<{
254
+ connected: false;
255
+ message: string;
256
+ } | {
257
+ message?: undefined;
258
+ connected: true;
259
+ }, Tool.Error, never>;
260
+ target: (sessionID: string & import("effect/Brand").Brand<"SessionID">, action: {
261
+ readonly type: "tabs.list";
90
262
  } | {
91
263
  readonly type: "preview";
92
264
  readonly path: string;
93
265
  } | {
94
266
  readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
95
- readonly type: "reload";
267
+ readonly type: "navigate.path";
268
+ readonly path: string;
269
+ } | {
270
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
271
+ readonly type: "back";
272
+ } | {
273
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
274
+ readonly ref: string & import("effect/Brand").Brand<"Browser.Ref">;
275
+ readonly type: "check";
276
+ readonly checked: boolean;
277
+ } | {
278
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
279
+ readonly type: "cpu.start";
280
+ } | {
281
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
282
+ readonly type: "cpu.stop";
283
+ } | {
284
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
285
+ readonly type: "drag";
286
+ readonly from: string & import("effect/Brand").Brand<"Browser.Ref">;
287
+ readonly to: string & import("effect/Brand").Brand<"Browser.Ref">;
288
+ } | {
289
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
290
+ readonly ref: string & import("effect/Brand").Brand<"Browser.Ref">;
291
+ readonly type: "files.drop";
292
+ readonly paths: readonly string[];
293
+ } | {
294
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
295
+ readonly fileID: string & import("effect/Brand").Brand<"Browser.FileID">;
296
+ readonly type: "files.get";
297
+ } | {
298
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
299
+ readonly type: "files.list";
300
+ } | {
301
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
302
+ readonly ref: string & import("effect/Brand").Brand<"Browser.Ref">;
303
+ readonly type: "files.upload";
304
+ readonly paths: readonly string[];
305
+ } | {
306
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
307
+ readonly ref: string & import("effect/Brand").Brand<"Browser.Ref">;
308
+ readonly type: "fill";
309
+ readonly text: string;
310
+ } | {
311
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
312
+ readonly type: "fill_form";
313
+ readonly fields: readonly ({
314
+ readonly ref: string & import("effect/Brand").Brand<"Browser.Ref">;
315
+ readonly type: "text";
316
+ readonly value: string;
317
+ } | {
318
+ readonly ref: string & import("effect/Brand").Brand<"Browser.Ref">;
319
+ readonly type: "select";
320
+ readonly values: readonly string[];
321
+ } | {
322
+ readonly ref: string & import("effect/Brand").Brand<"Browser.Ref">;
323
+ readonly type: "check";
324
+ readonly checked: boolean;
325
+ })[];
326
+ } | {
327
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
328
+ readonly type: "forward";
329
+ } | {
330
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
331
+ readonly type: "frames";
332
+ } | {
333
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
334
+ readonly type: "heap.snapshot";
335
+ } | {
336
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
337
+ readonly ref: string & import("effect/Brand").Brand<"Browser.Ref">;
338
+ readonly type: "hover";
339
+ } | {
340
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
341
+ readonly type: "lighthouse";
342
+ } | {
343
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
344
+ readonly type: "navigate";
345
+ readonly url: string;
346
+ } | {
347
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
348
+ readonly type: "press";
349
+ readonly key: string;
96
350
  } | {
97
351
  readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
98
352
  readonly ref: string & import("effect/Brand").Brand<"Browser.Ref">;
@@ -141,6 +395,9 @@ export declare const register: (ctx: Pick<Context, "location" | "skill" | "tool"
141
395
  } | {
142
396
  readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
143
397
  readonly frameID?: string | undefined;
398
+ readonly maxChars?: number | undefined;
399
+ readonly interactive?: boolean | undefined;
400
+ readonly maxLines?: number | undefined;
144
401
  readonly type: "find";
145
402
  readonly text: string;
146
403
  } | {
@@ -168,16 +425,21 @@ export declare const register: (ctx: Pick<Context, "location" | "skill" | "tool"
168
425
  readonly limit?: number | undefined;
169
426
  } | {
170
427
  readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
171
- readonly type: "network.get";
172
- readonly id: string;
173
428
  readonly includeBody?: boolean | undefined;
429
+ readonly includeResponseBody?: boolean | undefined;
174
430
  readonly maxBodyChars?: number | undefined;
431
+ readonly type: "network.get";
432
+ readonly id: string;
175
433
  } | {
176
434
  readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
177
435
  readonly type: "network.list";
178
436
  readonly urlContains?: string | undefined;
179
437
  readonly resourceType?: "document" | "eventsource" | "fetch" | "font" | "image" | "manifest" | "media" | "other" | "script" | "stylesheet" | "websocket" | "xhr" | undefined;
180
438
  readonly limit?: number | undefined;
439
+ } | {
440
+ readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
441
+ readonly type: "reload";
442
+ readonly ignoreCache?: boolean | undefined;
181
443
  } | {
182
444
  readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
183
445
  readonly type: "screenshot";
@@ -194,6 +456,9 @@ export declare const register: (ctx: Pick<Context, "location" | "skill" | "tool"
194
456
  } | {
195
457
  readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
196
458
  readonly frameID?: string | undefined;
459
+ readonly maxChars?: number | undefined;
460
+ readonly interactive?: boolean | undefined;
461
+ readonly maxLines?: number | undefined;
197
462
  readonly type: "snapshot";
198
463
  readonly ref?: (string & import("effect/Brand").Brand<"Browser.Ref">) | undefined;
199
464
  readonly depth?: number | undefined;
@@ -215,8 +480,9 @@ export declare const register: (ctx: Pick<Context, "location" | "skill" | "tool"
215
480
  readonly tabID: string & import("effect/Brand").Brand<"Browser.TabID">;
216
481
  readonly frameID?: string | undefined;
217
482
  readonly type: "wait";
218
- readonly condition: "load" | "text" | "textGone";
483
+ readonly condition: "delay" | "load" | "text" | "textGone" | "url";
219
484
  readonly text?: string | undefined;
485
+ readonly url?: string | undefined;
220
486
  readonly timeoutMs?: number | undefined;
221
487
  }) => Effect.Effect<{
222
488
  tab: Browser.Tab | undefined;
@@ -227,4 +493,42 @@ export declare const register: (ctx: Pick<Context, "location" | "skill" | "tool"
227
493
  request: (files: readonly Browser.File[], target?: Browser.Target) => Effect.Effect<Browser.Result, Tool.Error, never>;
228
494
  }, Tool.Error, never>;
229
495
  }) => Effect.Effect<void, never, import("effect/Scope").Scope>;
230
- export declare function normalizeAction(action: Browser.Action): Browser.Action;
496
+ export declare function normalizeAction(action: Exclude<Browser.Input, {
497
+ readonly type: "wait";
498
+ }>): Exclude<Browser.Action, {
499
+ type: "wait";
500
+ }>;
501
+ type WaitInput = Extract<Browser.Input, {
502
+ readonly type: "wait";
503
+ }>;
504
+ type WaitAction = Extract<Browser.Action, {
505
+ readonly type: "wait";
506
+ }>;
507
+ export type WaitPlan = {
508
+ readonly timeoutMs: number;
509
+ readonly waited: Browser.Waited["waited"];
510
+ } & ({
511
+ readonly kind: "desktop";
512
+ readonly action: WaitAction;
513
+ } | {
514
+ readonly kind: "delay";
515
+ } | {
516
+ readonly kind: "url";
517
+ readonly url: string;
518
+ } | {
519
+ readonly kind: "element";
520
+ readonly element: {
521
+ readonly selector: string;
522
+ } | {
523
+ readonly ref: Browser.Ref;
524
+ };
525
+ readonly gone: boolean;
526
+ readonly frameID?: string;
527
+ });
528
+ /**
529
+ * What a wait call asks for. Models write Playwright-style keys (text with timeout, state, selector, url, time, ms), so
530
+ * the condition is read from whichever one is present. A call with only a duration pauses; one with nothing waits for
531
+ * loading.
532
+ */
533
+ export declare function waitPlan(input: WaitInput): WaitPlan;
534
+ export declare function asyncBody(script: string): string;