2025-04-28 15:04:59 -07:00
|
|
|
/**
|
|
|
|
* Copyright (c) Microsoft Corporation.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2025-04-28 20:17:16 -07:00
|
|
|
import type * as playwright from 'playwright';
|
|
|
|
|
2025-07-16 16:40:00 -07:00
|
|
|
export type ToolCapability = 'core' | 'core-tabs' | 'core-install' | 'vision' | 'pdf';
|
2025-04-28 15:04:59 -07:00
|
|
|
|
|
|
|
export type Config = {
|
|
|
|
/**
|
|
|
|
* The browser to use.
|
|
|
|
*/
|
|
|
|
browser?: {
|
|
|
|
/**
|
|
|
|
* The type of browser to use.
|
|
|
|
*/
|
2025-04-28 20:17:16 -07:00
|
|
|
browserName?: 'chromium' | 'firefox' | 'webkit';
|
2025-04-28 15:04:59 -07:00
|
|
|
|
2025-05-12 18:18:53 -07:00
|
|
|
/**
|
|
|
|
* Keep the browser profile in memory, do not save it to disk.
|
|
|
|
*/
|
2025-05-13 13:14:04 -07:00
|
|
|
isolated?: boolean;
|
2025-05-12 18:18:53 -07:00
|
|
|
|
2025-04-28 15:04:59 -07:00
|
|
|
/**
|
2025-04-28 20:17:16 -07:00
|
|
|
* Path to a user data directory for browser profile persistence.
|
2025-04-29 08:53:03 -07:00
|
|
|
* Temporary directory is created by default.
|
2025-04-28 15:04:59 -07:00
|
|
|
*/
|
2025-04-28 20:17:16 -07:00
|
|
|
userDataDir?: string;
|
2025-04-28 15:04:59 -07:00
|
|
|
|
|
|
|
/**
|
2025-04-28 20:17:16 -07:00
|
|
|
* Launch options passed to
|
|
|
|
* @see https://playwright.dev/docs/api/class-browsertype#browser-type-launch-persistent-context
|
|
|
|
*
|
|
|
|
* This is useful for settings options like `channel`, `headless`, `executablePath`, etc.
|
2025-04-28 15:04:59 -07:00
|
|
|
*/
|
2025-05-09 14:16:04 +02:00
|
|
|
launchOptions?: playwright.LaunchOptions;
|
2025-04-28 15:04:59 -07:00
|
|
|
|
|
|
|
/**
|
2025-04-28 20:17:16 -07:00
|
|
|
* Context options for the browser context.
|
|
|
|
*
|
|
|
|
* This is useful for settings options like `viewport`.
|
2025-04-28 15:04:59 -07:00
|
|
|
*/
|
2025-04-28 20:17:16 -07:00
|
|
|
contextOptions?: playwright.BrowserContextOptions;
|
2025-04-28 15:04:59 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Chrome DevTools Protocol endpoint to connect to an existing browser instance in case of Chromium family browsers.
|
|
|
|
*/
|
|
|
|
cdpEndpoint?: string;
|
2025-04-28 16:14:16 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remote endpoint to connect to an existing Playwright server.
|
|
|
|
*/
|
|
|
|
remoteEndpoint?: string;
|
2025-04-28 15:04:59 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
server?: {
|
|
|
|
/**
|
|
|
|
* The port to listen on for SSE or MCP transport.
|
|
|
|
*/
|
|
|
|
port?: number;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The host to bind the server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.
|
|
|
|
*/
|
|
|
|
host?: string;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* List of enabled tool capabilities. Possible values:
|
|
|
|
* - 'core': Core browser automation features.
|
|
|
|
* - 'pdf': PDF generation and manipulation.
|
2025-07-16 16:40:00 -07:00
|
|
|
* - 'vision': Coordinate-based interactions.
|
2025-04-28 15:04:59 -07:00
|
|
|
*/
|
|
|
|
capabilities?: ToolCapability[];
|
|
|
|
|
2025-07-22 20:06:03 -07:00
|
|
|
/**
|
|
|
|
* Whether to save the Playwright session into the output directory.
|
|
|
|
*/
|
|
|
|
saveSession?: boolean;
|
|
|
|
|
2025-05-14 18:08:44 -07:00
|
|
|
/**
|
|
|
|
* Whether to save the Playwright trace of the session into the output directory.
|
|
|
|
*/
|
|
|
|
saveTrace?: boolean;
|
|
|
|
|
2025-04-28 16:35:33 -07:00
|
|
|
/**
|
|
|
|
* The directory to save output files.
|
|
|
|
*/
|
|
|
|
outputDir?: string;
|
2025-04-28 17:21:23 -07:00
|
|
|
|
2025-05-05 11:28:14 -07:00
|
|
|
network?: {
|
|
|
|
/**
|
|
|
|
* List of origins to allow the browser to request. Default is to allow all. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.
|
|
|
|
*/
|
|
|
|
allowedOrigins?: string[];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* List of origins to block the browser to request. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.
|
|
|
|
*/
|
|
|
|
blockedOrigins?: string[];
|
|
|
|
};
|
|
|
|
|
2025-04-28 17:21:23 -07:00
|
|
|
/**
|
2025-05-27 01:25:09 -07:00
|
|
|
* Whether to send image responses to the client. Can be "allow", "omit", or "auto". Defaults to "auto", which sends images if the client can display them.
|
2025-04-28 17:21:23 -07:00
|
|
|
*/
|
2025-07-16 18:32:07 -07:00
|
|
|
imageResponses?: 'allow' | 'omit';
|
2025-04-28 15:04:59 -07:00
|
|
|
};
|