@playwright/mcp 0.0.9 → 0.0.10

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/lib/index.js CHANGED
@@ -14,84 +14,49 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- var desc = Object.getOwnPropertyDescriptor(m, k);
20
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
- desc = { enumerable: true, get: function() { return m[k]; } };
22
- }
23
- Object.defineProperty(o, k2, desc);
24
- }) : (function(o, m, k, k2) {
25
- if (k2 === undefined) k2 = k;
26
- o[k2] = m[k];
27
- }));
28
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
- Object.defineProperty(o, "default", { enumerable: true, value: v });
30
- }) : function(o, v) {
31
- o["default"] = v;
32
- });
33
- var __importStar = (this && this.__importStar) || (function () {
34
- var ownKeys = function(o) {
35
- ownKeys = Object.getOwnPropertyNames || function (o) {
36
- var ar = [];
37
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
38
- return ar;
39
- };
40
- return ownKeys(o);
41
- };
42
- return function (mod) {
43
- if (mod && mod.__esModule) return mod;
44
- var result = {};
45
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
46
- __setModuleDefault(result, mod);
47
- return result;
48
- };
49
- })();
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
50
20
  Object.defineProperty(exports, "__esModule", { value: true });
51
21
  exports.createServer = createServer;
52
22
  const server_1 = require("./server");
53
- const snapshot = __importStar(require("./tools/snapshot"));
54
- const common = __importStar(require("./tools/common"));
55
- const screenshot = __importStar(require("./tools/screenshot"));
23
+ const common_1 = __importDefault(require("./tools/common"));
24
+ const files_1 = __importDefault(require("./tools/files"));
25
+ const install_1 = __importDefault(require("./tools/install"));
26
+ const keyboard_1 = __importDefault(require("./tools/keyboard"));
27
+ const navigate_1 = __importDefault(require("./tools/navigate"));
28
+ const pdf_1 = __importDefault(require("./tools/pdf"));
29
+ const snapshot_1 = __importDefault(require("./tools/snapshot"));
30
+ const tabs_1 = __importDefault(require("./tools/tabs"));
31
+ const screen_1 = __importDefault(require("./tools/screen"));
56
32
  const console_1 = require("./resources/console");
57
- const commonTools = [
58
- common.pressKey,
59
- common.wait,
60
- common.pdf,
61
- common.close,
62
- common.install,
63
- ];
64
33
  const snapshotTools = [
65
- common.navigate(true),
66
- common.goBack(true),
67
- common.goForward(true),
68
- common.chooseFile(true),
69
- snapshot.snapshot,
70
- snapshot.click,
71
- snapshot.hover,
72
- snapshot.type,
73
- snapshot.selectOption,
74
- snapshot.screenshot,
75
- ...commonTools,
34
+ ...common_1.default,
35
+ ...(0, files_1.default)(true),
36
+ ...install_1.default,
37
+ ...(0, keyboard_1.default)(true),
38
+ ...(0, navigate_1.default)(true),
39
+ ...pdf_1.default,
40
+ ...snapshot_1.default,
41
+ ...(0, tabs_1.default)(true),
76
42
  ];
77
43
  const screenshotTools = [
78
- common.navigate(false),
79
- common.goBack(false),
80
- common.goForward(false),
81
- common.chooseFile(false),
82
- screenshot.screenshot,
83
- screenshot.moveMouse,
84
- screenshot.click,
85
- screenshot.drag,
86
- screenshot.type,
87
- ...commonTools,
44
+ ...common_1.default,
45
+ ...(0, files_1.default)(false),
46
+ ...install_1.default,
47
+ ...(0, keyboard_1.default)(false),
48
+ ...(0, navigate_1.default)(false),
49
+ ...pdf_1.default,
50
+ ...screen_1.default,
51
+ ...(0, tabs_1.default)(false),
88
52
  ];
89
53
  const resources = [
90
54
  console_1.console,
91
55
  ];
92
56
  const packageJSON = require('../package.json');
93
57
  function createServer(options) {
94
- const tools = options?.vision ? screenshotTools : snapshotTools;
58
+ const allTools = options?.vision ? screenshotTools : snapshotTools;
59
+ const tools = allTools.filter(tool => !options?.capabilities || tool.capability === 'core' || options.capabilities.includes(tool.capability));
95
60
  return (0, server_1.createServerWithTools)({
96
61
  name: 'Playwright',
97
62
  version: packageJSON.version,
package/lib/program.js CHANGED
@@ -33,6 +33,7 @@ commander_1.program
33
33
  .version('Version ' + packageJSON.version)
34
34
  .name(packageJSON.name)
35
35
  .option('--browser <browser>', 'Browser or chrome channel to use, possible values: chrome, firefox, webkit, msedge.')
36
+ .option('--caps <caps>', 'Comma-separated list of capabilities to enable, possible values: tabs, pdf, history, wait, files, install. Default is all.')
36
37
  .option('--cdp-endpoint <endpoint>', 'CDP endpoint to connect to.')
37
38
  .option('--executable-path <path>', 'Path to the browser executable.')
38
39
  .option('--headless', 'Run browser in headless mode, headed by default')
@@ -79,6 +80,7 @@ commander_1.program
79
80
  launchOptions,
80
81
  vision: !!options.vision,
81
82
  cdpEndpoint: options.cdpEndpoint,
83
+ capabilities: options.caps?.split(',').map((c) => c.trim()),
82
84
  }));
83
85
  setupExitWatchdog(serverList);
84
86
  if (options.port) {
@@ -23,7 +23,7 @@ exports.console = {
23
23
  mimeType: 'text/plain',
24
24
  },
25
25
  read: async (context, uri) => {
26
- const messages = await context.console();
26
+ const messages = await context.currentTab().console();
27
27
  const log = messages.map(message => `[${message.type().toUpperCase()}] ${message.text()}`).join('\n');
28
28
  return [{
29
29
  uri,
@@ -14,70 +14,14 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
17
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.install = exports.chooseFile = exports.close = exports.pdf = exports.pressKey = exports.wait = exports.goForward = exports.goBack = exports.navigate = void 0;
22
- const os_1 = __importDefault(require("os"));
23
- const path_1 = __importDefault(require("path"));
24
18
  const zod_1 = require("zod");
25
19
  const zod_to_json_schema_1 = require("zod-to-json-schema");
26
- const utils_1 = require("./utils");
27
- const navigateSchema = zod_1.z.object({
28
- url: zod_1.z.string().describe('The URL to navigate to'),
29
- });
30
- const navigate = snapshot => ({
31
- schema: {
32
- name: 'browser_navigate',
33
- description: 'Navigate to a URL',
34
- inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(navigateSchema),
35
- },
36
- handle: async (context, params) => {
37
- const validatedParams = navigateSchema.parse(params);
38
- const page = await context.createPage();
39
- await page.goto(validatedParams.url, { waitUntil: 'domcontentloaded' });
40
- // Cap load event to 5 seconds, the page is operational at this point.
41
- await page.waitForLoadState('load', { timeout: 5000 }).catch(() => { });
42
- if (snapshot)
43
- return (0, utils_1.captureAriaSnapshot)(context);
44
- return {
45
- content: [{
46
- type: 'text',
47
- text: `Navigated to ${validatedParams.url}`,
48
- }],
49
- };
50
- },
51
- });
52
- exports.navigate = navigate;
53
- const goBackSchema = zod_1.z.object({});
54
- const goBack = snapshot => ({
55
- schema: {
56
- name: 'browser_go_back',
57
- description: 'Go back to the previous page',
58
- inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(goBackSchema),
59
- },
60
- handle: async (context) => {
61
- return await (0, utils_1.runAndWait)(context, 'Navigated back', async (page) => page.goBack(), snapshot);
62
- },
63
- });
64
- exports.goBack = goBack;
65
- const goForwardSchema = zod_1.z.object({});
66
- const goForward = snapshot => ({
67
- schema: {
68
- name: 'browser_go_forward',
69
- description: 'Go forward to the next page',
70
- inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(goForwardSchema),
71
- },
72
- handle: async (context) => {
73
- return await (0, utils_1.runAndWait)(context, 'Navigated forward', async (page) => page.goForward(), snapshot);
74
- },
75
- });
76
- exports.goForward = goForward;
77
20
  const waitSchema = zod_1.z.object({
78
21
  time: zod_1.z.number().describe('The time to wait in seconds'),
79
22
  });
80
- exports.wait = {
23
+ const wait = {
24
+ capability: 'wait',
81
25
  schema: {
82
26
  name: 'browser_wait',
83
27
  description: 'Wait for a specified time in seconds',
@@ -94,43 +38,9 @@ exports.wait = {
94
38
  };
95
39
  },
96
40
  };
97
- const pressKeySchema = zod_1.z.object({
98
- key: zod_1.z.string().describe('Name of the key to press or a character to generate, such as `ArrowLeft` or `a`'),
99
- });
100
- exports.pressKey = {
101
- schema: {
102
- name: 'browser_press_key',
103
- description: 'Press a key on the keyboard',
104
- inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(pressKeySchema),
105
- },
106
- handle: async (context, params) => {
107
- const validatedParams = pressKeySchema.parse(params);
108
- return await (0, utils_1.runAndWait)(context, `Pressed key ${validatedParams.key}`, async (page) => {
109
- await page.keyboard.press(validatedParams.key);
110
- });
111
- },
112
- };
113
- const pdfSchema = zod_1.z.object({});
114
- exports.pdf = {
115
- schema: {
116
- name: 'browser_save_as_pdf',
117
- description: 'Save page as PDF',
118
- inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(pdfSchema),
119
- },
120
- handle: async (context) => {
121
- const page = context.existingPage();
122
- const fileName = path_1.default.join(os_1.default.tmpdir(), (0, utils_1.sanitizeForFilePath)(`page-${new Date().toISOString()}`)) + '.pdf';
123
- await page.pdf({ path: fileName });
124
- return {
125
- content: [{
126
- type: 'text',
127
- text: `Saved as ${fileName}`,
128
- }],
129
- };
130
- },
131
- };
132
41
  const closeSchema = zod_1.z.object({});
133
- exports.close = {
42
+ const close = {
43
+ capability: 'core',
134
44
  schema: {
135
45
  name: 'browser_close',
136
46
  description: 'Close the page',
@@ -146,36 +56,7 @@ exports.close = {
146
56
  };
147
57
  },
148
58
  };
149
- const chooseFileSchema = zod_1.z.object({
150
- paths: zod_1.z.array(zod_1.z.string()).describe('The absolute paths to the files to upload. Can be a single file or multiple files.'),
151
- });
152
- const chooseFile = snapshot => ({
153
- schema: {
154
- name: 'browser_choose_file',
155
- description: 'Choose one or multiple files to upload',
156
- inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(chooseFileSchema),
157
- },
158
- handle: async (context, params) => {
159
- const validatedParams = chooseFileSchema.parse(params);
160
- return await (0, utils_1.runAndWait)(context, `Chose files ${validatedParams.paths.join(', ')}`, async () => {
161
- await context.submitFileChooser(validatedParams.paths);
162
- }, snapshot);
163
- },
164
- });
165
- exports.chooseFile = chooseFile;
166
- exports.install = {
167
- schema: {
168
- name: 'browser_install',
169
- description: 'Install the browser specified in the config. Call this if you get an error about the browser not being installed.',
170
- inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(zod_1.z.object({})),
171
- },
172
- handle: async (context) => {
173
- const channel = await context.install();
174
- return {
175
- content: [{
176
- type: 'text',
177
- text: `Browser ${channel} installed`,
178
- }],
179
- };
180
- },
181
- };
59
+ exports.default = [
60
+ close,
61
+ wait,
62
+ ];
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const zod_1 = require("zod");
19
+ const zod_to_json_schema_1 = require("zod-to-json-schema");
20
+ const uploadFileSchema = zod_1.z.object({
21
+ paths: zod_1.z.array(zod_1.z.string()).describe('The absolute paths to the files to upload. Can be a single file or multiple files.'),
22
+ });
23
+ const uploadFile = captureSnapshot => ({
24
+ capability: 'files',
25
+ schema: {
26
+ name: 'browser_file_upload',
27
+ description: 'Upload one or multiple files',
28
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(uploadFileSchema),
29
+ },
30
+ handle: async (context, params) => {
31
+ const validatedParams = uploadFileSchema.parse(params);
32
+ const tab = context.currentTab();
33
+ return await tab.runAndWait(async () => {
34
+ await tab.submitFileChooser(validatedParams.paths);
35
+ }, {
36
+ status: `Chose files ${validatedParams.paths.join(', ')}`,
37
+ captureSnapshot,
38
+ noClearFileChooser: true,
39
+ });
40
+ },
41
+ });
42
+ exports.default = (captureSnapshot) => [
43
+ uploadFile(captureSnapshot),
44
+ ];
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const child_process_1 = require("child_process");
22
+ const path_1 = __importDefault(require("path"));
23
+ const zod_1 = require("zod");
24
+ const zod_to_json_schema_1 = require("zod-to-json-schema");
25
+ const install = {
26
+ capability: 'install',
27
+ schema: {
28
+ name: 'browser_install',
29
+ description: 'Install the browser specified in the config. Call this if you get an error about the browser not being installed.',
30
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(zod_1.z.object({})),
31
+ },
32
+ handle: async (context) => {
33
+ const channel = context.options.launchOptions?.channel ?? context.options.browserName ?? 'chrome';
34
+ const cli = path_1.default.join(require.resolve('playwright/package.json'), '..', 'cli.js');
35
+ const child = (0, child_process_1.fork)(cli, ['install', channel], {
36
+ stdio: 'pipe',
37
+ });
38
+ const output = [];
39
+ child.stdout?.on('data', data => output.push(data.toString()));
40
+ child.stderr?.on('data', data => output.push(data.toString()));
41
+ await new Promise((resolve, reject) => {
42
+ child.on('close', code => {
43
+ if (code === 0)
44
+ resolve();
45
+ else
46
+ reject(new Error(`Failed to install browser: ${output.join('')}`));
47
+ });
48
+ });
49
+ return {
50
+ content: [{
51
+ type: 'text',
52
+ text: `Browser ${channel} installed`,
53
+ }],
54
+ };
55
+ },
56
+ };
57
+ exports.default = [
58
+ install,
59
+ ];
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const zod_1 = require("zod");
22
+ const zod_to_json_schema_1 = __importDefault(require("zod-to-json-schema"));
23
+ const pressKeySchema = zod_1.z.object({
24
+ key: zod_1.z.string().describe('Name of the key to press or a character to generate, such as `ArrowLeft` or `a`'),
25
+ });
26
+ const pressKey = captureSnapshot => ({
27
+ capability: 'core',
28
+ schema: {
29
+ name: 'browser_press_key',
30
+ description: 'Press a key on the keyboard',
31
+ inputSchema: (0, zod_to_json_schema_1.default)(pressKeySchema),
32
+ },
33
+ handle: async (context, params) => {
34
+ const validatedParams = pressKeySchema.parse(params);
35
+ return await context.currentTab().runAndWait(async (tab) => {
36
+ await tab.page.keyboard.press(validatedParams.key);
37
+ }, {
38
+ status: `Pressed key ${validatedParams.key}`,
39
+ captureSnapshot,
40
+ });
41
+ },
42
+ });
43
+ exports.default = (captureSnapshot) => [
44
+ pressKey(captureSnapshot),
45
+ ];
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const zod_1 = require("zod");
19
+ const zod_to_json_schema_1 = require("zod-to-json-schema");
20
+ const navigateSchema = zod_1.z.object({
21
+ url: zod_1.z.string().describe('The URL to navigate to'),
22
+ });
23
+ const navigate = captureSnapshot => ({
24
+ capability: 'core',
25
+ schema: {
26
+ name: 'browser_navigate',
27
+ description: 'Navigate to a URL',
28
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(navigateSchema),
29
+ },
30
+ handle: async (context, params) => {
31
+ const validatedParams = navigateSchema.parse(params);
32
+ const currentTab = await context.ensureTab();
33
+ return await currentTab.run(async (tab) => {
34
+ await tab.navigate(validatedParams.url);
35
+ }, {
36
+ status: `Navigated to ${validatedParams.url}`,
37
+ captureSnapshot,
38
+ });
39
+ },
40
+ });
41
+ const goBackSchema = zod_1.z.object({});
42
+ const goBack = snapshot => ({
43
+ capability: 'history',
44
+ schema: {
45
+ name: 'browser_navigate_back',
46
+ description: 'Go back to the previous page',
47
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(goBackSchema),
48
+ },
49
+ handle: async (context) => {
50
+ return await context.currentTab().runAndWait(async (tab) => {
51
+ await tab.page.goBack();
52
+ }, {
53
+ status: 'Navigated back',
54
+ captureSnapshot: snapshot,
55
+ });
56
+ },
57
+ });
58
+ const goForwardSchema = zod_1.z.object({});
59
+ const goForward = snapshot => ({
60
+ capability: 'history',
61
+ schema: {
62
+ name: 'browser_navigate_forward',
63
+ description: 'Go forward to the next page',
64
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(goForwardSchema),
65
+ },
66
+ handle: async (context) => {
67
+ return await context.currentTab().runAndWait(async (tab) => {
68
+ await tab.page.goForward();
69
+ }, {
70
+ status: 'Navigated forward',
71
+ captureSnapshot: snapshot,
72
+ });
73
+ },
74
+ });
75
+ exports.default = (captureSnapshot) => [
76
+ navigate(captureSnapshot),
77
+ goBack(captureSnapshot),
78
+ goForward(captureSnapshot),
79
+ ];
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const os_1 = __importDefault(require("os"));
22
+ const path_1 = __importDefault(require("path"));
23
+ const zod_1 = require("zod");
24
+ const zod_to_json_schema_1 = require("zod-to-json-schema");
25
+ const utils_1 = require("./utils");
26
+ const pdfSchema = zod_1.z.object({});
27
+ const pdf = {
28
+ capability: 'pdf',
29
+ schema: {
30
+ name: 'browser_pdf_save',
31
+ description: 'Save page as PDF',
32
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(pdfSchema),
33
+ },
34
+ handle: async (context) => {
35
+ const tab = context.currentTab();
36
+ const fileName = path_1.default.join(os_1.default.tmpdir(), (0, utils_1.sanitizeForFilePath)(`page-${new Date().toISOString()}`)) + '.pdf';
37
+ await tab.page.pdf({ path: fileName });
38
+ return {
39
+ content: [{
40
+ type: 'text',
41
+ text: `Saved as ${fileName}`,
42
+ }],
43
+ };
44
+ },
45
+ };
46
+ exports.default = [
47
+ pdf,
48
+ ];