@pedropaulovc/playwright-core 1.59.0-next → 1.59.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/reinstall_chrome_beta_linux.sh +0 -0
- package/bin/reinstall_chrome_beta_mac.sh +0 -0
- package/bin/reinstall_chrome_stable_linux.sh +0 -0
- package/bin/reinstall_chrome_stable_mac.sh +0 -0
- package/bin/reinstall_msedge_beta_linux.sh +0 -0
- package/bin/reinstall_msedge_beta_mac.sh +0 -0
- package/bin/reinstall_msedge_dev_linux.sh +0 -0
- package/bin/reinstall_msedge_dev_mac.sh +0 -0
- package/bin/reinstall_msedge_stable_linux.sh +0 -0
- package/bin/reinstall_msedge_stable_mac.sh +0 -0
- package/lib/cli/program.js +3 -5
- package/lib/client/page.js +0 -2
- package/lib/server/trace/viewer/traceExporter.js +413 -118
- package/lib/utilsBundle.js +3 -0
- package/lib/utilsBundleImpl/xdg-open +0 -0
- package/package.json +2 -2
- package/types/types.d.ts +327 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-DwzBH9eL.js +0 -32
- package/lib/vite/traceViewer/assets/defaultSettingsView-CdCX8877.js +0 -266
- package/lib/vite/traceViewer/index.f4OcrOqs.js +0 -2
- package/lib/vite/traceViewer/uiMode.qcahlSup.js +0 -5
package/lib/utilsBundle.js
CHANGED
|
@@ -63,6 +63,9 @@ const wsServer = require("./utilsBundleImpl").wsServer;
|
|
|
63
63
|
const wsReceiver = require("./utilsBundleImpl").wsReceiver;
|
|
64
64
|
const wsSender = require("./utilsBundleImpl").wsSender;
|
|
65
65
|
const yaml = require("./utilsBundleImpl").yaml;
|
|
66
|
+
program.exitOverride((err) => {
|
|
67
|
+
process.stdout.write("", () => process.stderr.write("", () => process.exit(err.exitCode)));
|
|
68
|
+
});
|
|
66
69
|
function ms(ms2) {
|
|
67
70
|
if (!isFinite(ms2))
|
|
68
71
|
return "-";
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pedropaulovc/playwright-core",
|
|
3
|
-
"version": "1.59.0-next",
|
|
3
|
+
"version": "1.59.0-next.1",
|
|
4
4
|
"description": "A high-level API to automate web browsers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/
|
|
7
|
+
"url": "git+https://github.com/pedropaulovc/playwright.git"
|
|
8
8
|
},
|
|
9
9
|
"homepage": "https://playwright.dev",
|
|
10
10
|
"engines": {
|
package/types/types.d.ts
CHANGED
|
@@ -27,6 +27,13 @@ type ElementHandleWaitForSelectorOptionsNotHidden = ElementHandleWaitForSelector
|
|
|
27
27
|
state?: 'visible'|'attached';
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
+
// @ts-ignore this will be any if zod is not installed
|
|
31
|
+
import { ZodTypeAny, z } from 'zod';
|
|
32
|
+
// @ts-ignore this will be any if zod is not installed
|
|
33
|
+
import * as z3 from 'zod/v3';
|
|
34
|
+
type ZodSchema = ZodTypeAny | z3.ZodTypeAny;
|
|
35
|
+
type InferZodSchema<T extends ZodSchema> = T extends z3.ZodTypeAny ? z3.infer<T> : T extends ZodTypeAny ? z.infer<T> : never;
|
|
36
|
+
|
|
30
37
|
/**
|
|
31
38
|
* Page provides methods to interact with a single tab in a [Browser](https://playwright.dev/docs/api/class-browser),
|
|
32
39
|
* or an [extension background page](https://developer.chrome.com/extensions/background_pages) in Chromium. One
|
|
@@ -2088,6 +2095,89 @@ export interface Page {
|
|
|
2088
2095
|
url?: string;
|
|
2089
2096
|
}): Promise<ElementHandle>;
|
|
2090
2097
|
|
|
2098
|
+
/**
|
|
2099
|
+
* Initialize page agent with the llm provider and cache.
|
|
2100
|
+
* @param options
|
|
2101
|
+
*/
|
|
2102
|
+
agent(options?: {
|
|
2103
|
+
cache?: {
|
|
2104
|
+
/**
|
|
2105
|
+
* Cache file to use/generate code for performed actions into. Cache is not used if not specified (default).
|
|
2106
|
+
*/
|
|
2107
|
+
cacheFile?: string;
|
|
2108
|
+
|
|
2109
|
+
/**
|
|
2110
|
+
* When specified, generated entries are written into the `cacheOutFile` instead of updating the `cacheFile`.
|
|
2111
|
+
*/
|
|
2112
|
+
cacheOutFile?: string;
|
|
2113
|
+
};
|
|
2114
|
+
|
|
2115
|
+
expect?: {
|
|
2116
|
+
/**
|
|
2117
|
+
* Default timeout for expect calls in milliseconds, defaults to 5000ms.
|
|
2118
|
+
*/
|
|
2119
|
+
timeout?: number;
|
|
2120
|
+
};
|
|
2121
|
+
|
|
2122
|
+
/**
|
|
2123
|
+
* Limits to use for the agentic loop.
|
|
2124
|
+
*/
|
|
2125
|
+
limits?: {
|
|
2126
|
+
/**
|
|
2127
|
+
* Maximum number of tokens to consume. The agentic loop will stop after input + output tokens exceed this value.
|
|
2128
|
+
* Defaults to unlimited.
|
|
2129
|
+
*/
|
|
2130
|
+
maxTokens?: number;
|
|
2131
|
+
|
|
2132
|
+
/**
|
|
2133
|
+
* Maximum number of agentic actions to generate, defaults to 10.
|
|
2134
|
+
*/
|
|
2135
|
+
maxActions?: number;
|
|
2136
|
+
|
|
2137
|
+
/**
|
|
2138
|
+
* Maximum number retries per action, defaults to 3.
|
|
2139
|
+
*/
|
|
2140
|
+
maxActionRetries?: number;
|
|
2141
|
+
};
|
|
2142
|
+
|
|
2143
|
+
provider?: {
|
|
2144
|
+
/**
|
|
2145
|
+
* API to use.
|
|
2146
|
+
*/
|
|
2147
|
+
api: "openai"|"openai-compatible"|"anthropic"|"google";
|
|
2148
|
+
|
|
2149
|
+
/**
|
|
2150
|
+
* Endpoint to use if different from default.
|
|
2151
|
+
*/
|
|
2152
|
+
apiEndpoint?: string;
|
|
2153
|
+
|
|
2154
|
+
/**
|
|
2155
|
+
* API key for the LLM provider.
|
|
2156
|
+
*/
|
|
2157
|
+
apiKey: string;
|
|
2158
|
+
|
|
2159
|
+
/**
|
|
2160
|
+
* Amount of time to wait for the provider to respond to each request.
|
|
2161
|
+
*/
|
|
2162
|
+
apiTimeout?: number;
|
|
2163
|
+
|
|
2164
|
+
/**
|
|
2165
|
+
* Model identifier within the provider. Required in non-cache mode.
|
|
2166
|
+
*/
|
|
2167
|
+
model: string;
|
|
2168
|
+
};
|
|
2169
|
+
|
|
2170
|
+
/**
|
|
2171
|
+
* Secrets to hide from the LLM.
|
|
2172
|
+
*/
|
|
2173
|
+
secrets?: { [key: string]: string; };
|
|
2174
|
+
|
|
2175
|
+
/**
|
|
2176
|
+
* System prompt for the agent's loop.
|
|
2177
|
+
*/
|
|
2178
|
+
systemPrompt?: string;
|
|
2179
|
+
}): Promise<PageAgent>;
|
|
2180
|
+
|
|
2091
2181
|
/**
|
|
2092
2182
|
* Brings page to front (activates tab).
|
|
2093
2183
|
*/
|
|
@@ -5204,6 +5294,243 @@ export interface Page {
|
|
|
5204
5294
|
[Symbol.asyncDispose](): Promise<void>;
|
|
5205
5295
|
}
|
|
5206
5296
|
|
|
5297
|
+
/**
|
|
5298
|
+
*
|
|
5299
|
+
*/
|
|
5300
|
+
export interface PageAgent {
|
|
5301
|
+
/**
|
|
5302
|
+
* Extract information from the page using the agentic loop, return it in a given Zod format.
|
|
5303
|
+
*
|
|
5304
|
+
* **Usage**
|
|
5305
|
+
*
|
|
5306
|
+
* ```js
|
|
5307
|
+
* await agent.extract('List of items in the cart', z.object({
|
|
5308
|
+
* title: z.string().describe('Item title to extract'),
|
|
5309
|
+
* price: z.string().describe('Item price to extract'),
|
|
5310
|
+
* }).array());
|
|
5311
|
+
* ```
|
|
5312
|
+
*
|
|
5313
|
+
* @param query Task to perform using agentic loop.
|
|
5314
|
+
* @param schema
|
|
5315
|
+
* @param options
|
|
5316
|
+
*/
|
|
5317
|
+
extract<Schema extends ZodSchema>(query: string, schema: Schema): Promise<{ result: InferZodSchema<Schema>, usage: { turns: number, inputTokens: number, outputTokens: number } }>;
|
|
5318
|
+
/**
|
|
5319
|
+
* Emitted when the agent makes a turn.
|
|
5320
|
+
*/
|
|
5321
|
+
on(event: 'turn', listener: (data: {
|
|
5322
|
+
role: string;
|
|
5323
|
+
|
|
5324
|
+
message: string;
|
|
5325
|
+
|
|
5326
|
+
usage?: {
|
|
5327
|
+
inputTokens: number;
|
|
5328
|
+
|
|
5329
|
+
outputTokens: number;
|
|
5330
|
+
};
|
|
5331
|
+
}) => any): this;
|
|
5332
|
+
|
|
5333
|
+
/**
|
|
5334
|
+
* Adds an event listener that will be automatically removed after it is triggered once. See `addListener` for more information about this event.
|
|
5335
|
+
*/
|
|
5336
|
+
once(event: 'turn', listener: (data: {
|
|
5337
|
+
role: string;
|
|
5338
|
+
|
|
5339
|
+
message: string;
|
|
5340
|
+
|
|
5341
|
+
usage?: {
|
|
5342
|
+
inputTokens: number;
|
|
5343
|
+
|
|
5344
|
+
outputTokens: number;
|
|
5345
|
+
};
|
|
5346
|
+
}) => any): this;
|
|
5347
|
+
|
|
5348
|
+
/**
|
|
5349
|
+
* Emitted when the agent makes a turn.
|
|
5350
|
+
*/
|
|
5351
|
+
addListener(event: 'turn', listener: (data: {
|
|
5352
|
+
role: string;
|
|
5353
|
+
|
|
5354
|
+
message: string;
|
|
5355
|
+
|
|
5356
|
+
usage?: {
|
|
5357
|
+
inputTokens: number;
|
|
5358
|
+
|
|
5359
|
+
outputTokens: number;
|
|
5360
|
+
};
|
|
5361
|
+
}) => any): this;
|
|
5362
|
+
|
|
5363
|
+
/**
|
|
5364
|
+
* Removes an event listener added by `on` or `addListener`.
|
|
5365
|
+
*/
|
|
5366
|
+
removeListener(event: 'turn', listener: (data: {
|
|
5367
|
+
role: string;
|
|
5368
|
+
|
|
5369
|
+
message: string;
|
|
5370
|
+
|
|
5371
|
+
usage?: {
|
|
5372
|
+
inputTokens: number;
|
|
5373
|
+
|
|
5374
|
+
outputTokens: number;
|
|
5375
|
+
};
|
|
5376
|
+
}) => any): this;
|
|
5377
|
+
|
|
5378
|
+
/**
|
|
5379
|
+
* Removes an event listener added by `on` or `addListener`.
|
|
5380
|
+
*/
|
|
5381
|
+
off(event: 'turn', listener: (data: {
|
|
5382
|
+
role: string;
|
|
5383
|
+
|
|
5384
|
+
message: string;
|
|
5385
|
+
|
|
5386
|
+
usage?: {
|
|
5387
|
+
inputTokens: number;
|
|
5388
|
+
|
|
5389
|
+
outputTokens: number;
|
|
5390
|
+
};
|
|
5391
|
+
}) => any): this;
|
|
5392
|
+
|
|
5393
|
+
/**
|
|
5394
|
+
* Emitted when the agent makes a turn.
|
|
5395
|
+
*/
|
|
5396
|
+
prependListener(event: 'turn', listener: (data: {
|
|
5397
|
+
role: string;
|
|
5398
|
+
|
|
5399
|
+
message: string;
|
|
5400
|
+
|
|
5401
|
+
usage?: {
|
|
5402
|
+
inputTokens: number;
|
|
5403
|
+
|
|
5404
|
+
outputTokens: number;
|
|
5405
|
+
};
|
|
5406
|
+
}) => any): this;
|
|
5407
|
+
|
|
5408
|
+
/**
|
|
5409
|
+
* Dispose this agent.
|
|
5410
|
+
*/
|
|
5411
|
+
dispose(): Promise<void>;
|
|
5412
|
+
|
|
5413
|
+
/**
|
|
5414
|
+
* Expect certain condition to be met.
|
|
5415
|
+
*
|
|
5416
|
+
* **Usage**
|
|
5417
|
+
*
|
|
5418
|
+
* ```js
|
|
5419
|
+
* await agent.expect('"0 items" to be reported');
|
|
5420
|
+
* ```
|
|
5421
|
+
*
|
|
5422
|
+
* @param expectation Expectation to assert.
|
|
5423
|
+
* @param options
|
|
5424
|
+
*/
|
|
5425
|
+
expect(expectation: string, options?: {
|
|
5426
|
+
/**
|
|
5427
|
+
* All the agentic actions are converted to the Playwright calls and are cached. By default, they are cached globally
|
|
5428
|
+
* with the `task` as a key. This option allows controlling the cache key explicitly.
|
|
5429
|
+
*/
|
|
5430
|
+
cacheKey?: string;
|
|
5431
|
+
|
|
5432
|
+
/**
|
|
5433
|
+
* Maximum number of retries when generating each action, defaults to context-wide value specified in `agent`
|
|
5434
|
+
* property.
|
|
5435
|
+
*/
|
|
5436
|
+
maxActionRetries?: number;
|
|
5437
|
+
|
|
5438
|
+
/**
|
|
5439
|
+
* Maximum number of agentic actions to generate, defaults to context-wide value specified in `agent` property.
|
|
5440
|
+
*/
|
|
5441
|
+
maxActions?: number;
|
|
5442
|
+
|
|
5443
|
+
/**
|
|
5444
|
+
* Maximum number of tokens to consume. The agentic loop will stop after input + output tokens exceed this value.
|
|
5445
|
+
* Defaults to context-wide value specified in `agent` property.
|
|
5446
|
+
*/
|
|
5447
|
+
maxTokens?: number;
|
|
5448
|
+
|
|
5449
|
+
/**
|
|
5450
|
+
* Expect timeout in milliseconds. Defaults to `5000`. The default value can be changed via `expect.timeout` option in
|
|
5451
|
+
* the config, or by specifying the `expect` property of the
|
|
5452
|
+
* [`expect`](https://playwright.dev/docs/api/class-page#page-agent-option-expect) option. Pass `0` to disable
|
|
5453
|
+
* timeout.
|
|
5454
|
+
*/
|
|
5455
|
+
timeout?: number;
|
|
5456
|
+
}): Promise<void>;
|
|
5457
|
+
|
|
5458
|
+
/**
|
|
5459
|
+
* Perform action using agentic loop.
|
|
5460
|
+
*
|
|
5461
|
+
* **Usage**
|
|
5462
|
+
*
|
|
5463
|
+
* ```js
|
|
5464
|
+
* await agent.perform('Click submit button');
|
|
5465
|
+
* ```
|
|
5466
|
+
*
|
|
5467
|
+
* @param task Task to perform using agentic loop.
|
|
5468
|
+
* @param options
|
|
5469
|
+
*/
|
|
5470
|
+
perform(task: string, options?: {
|
|
5471
|
+
/**
|
|
5472
|
+
* All the agentic actions are converted to the Playwright calls and are cached. By default, they are cached globally
|
|
5473
|
+
* with the `task` as a key. This option allows controlling the cache key explicitly.
|
|
5474
|
+
*/
|
|
5475
|
+
cacheKey?: string;
|
|
5476
|
+
|
|
5477
|
+
/**
|
|
5478
|
+
* Maximum number of retries when generating each action, defaults to context-wide value specified in `agent`
|
|
5479
|
+
* property.
|
|
5480
|
+
*/
|
|
5481
|
+
maxActionRetries?: number;
|
|
5482
|
+
|
|
5483
|
+
/**
|
|
5484
|
+
* Maximum number of agentic actions to generate, defaults to context-wide value specified in `agent` property.
|
|
5485
|
+
*/
|
|
5486
|
+
maxActions?: number;
|
|
5487
|
+
|
|
5488
|
+
/**
|
|
5489
|
+
* Maximum number of tokens to consume. The agentic loop will stop after input + output tokens exceed this value.
|
|
5490
|
+
* Defaults to context-wide value specified in `agent` property.
|
|
5491
|
+
*/
|
|
5492
|
+
maxTokens?: number;
|
|
5493
|
+
|
|
5494
|
+
/**
|
|
5495
|
+
* Perform timeout in milliseconds. Defaults to `5000`. The default value can be changed via `actionTimeout` option in
|
|
5496
|
+
* the config, or by using the
|
|
5497
|
+
* [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout)
|
|
5498
|
+
* or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods.
|
|
5499
|
+
* Pass `0` to disable timeout.
|
|
5500
|
+
*/
|
|
5501
|
+
timeout?: number;
|
|
5502
|
+
}): Promise<{
|
|
5503
|
+
usage: {
|
|
5504
|
+
turns: number;
|
|
5505
|
+
|
|
5506
|
+
inputTokens: number;
|
|
5507
|
+
|
|
5508
|
+
outputTokens: number;
|
|
5509
|
+
};
|
|
5510
|
+
}>;
|
|
5511
|
+
|
|
5512
|
+
/**
|
|
5513
|
+
* Returns the current token usage for this agent.
|
|
5514
|
+
*
|
|
5515
|
+
* **Usage**
|
|
5516
|
+
*
|
|
5517
|
+
* ```js
|
|
5518
|
+
* const usage = await agent.usage();
|
|
5519
|
+
* console.log(`Tokens used: ${usage.inputTokens} in, ${usage.outputTokens} out`);
|
|
5520
|
+
* ```
|
|
5521
|
+
*
|
|
5522
|
+
*/
|
|
5523
|
+
usage(): Promise<{
|
|
5524
|
+
turns: number;
|
|
5525
|
+
|
|
5526
|
+
inputTokens: number;
|
|
5527
|
+
|
|
5528
|
+
outputTokens: number;
|
|
5529
|
+
}>;
|
|
5530
|
+
|
|
5531
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
5532
|
+
}
|
|
5533
|
+
|
|
5207
5534
|
/**
|
|
5208
5535
|
* At every point of time, page exposes its current frame tree via the
|
|
5209
5536
|
* [page.mainFrame()](https://playwright.dev/docs/api/class-page#page-main-frame) and
|