chore: support custom filename in screenshot function (#349)

This commit is contained in:
おがどら 2025-05-09 03:04:18 +09:00 committed by GitHub
parent 09ba7989c3
commit 85c85bd2fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 116 additions and 10 deletions

View file

@ -20,6 +20,10 @@ import { defineTool } from './tool.js';
import * as javascript from '../javascript.js';
import { outputFile } from '../config.js';
const pdfSchema = z.object({
filename: z.string().optional().describe('File name to save the pdf to. Defaults to `page-{timestamp}.pdf` if not specified.'),
});
const pdf = defineTool({
capability: 'pdf',
@ -27,13 +31,13 @@ const pdf = defineTool({
name: 'browser_pdf_save',
title: 'Save as PDF',
description: 'Save page as PDF',
inputSchema: z.object({}),
inputSchema: pdfSchema,
type: 'readOnly',
},
handle: async context => {
handle: async (context, params) => {
const tab = context.currentTabOrDie();
const fileName = await outputFile(context.config, `page-${new Date().toISOString()}.pdf`);
const fileName = await outputFile(context.config, params.filename ?? `page-${new Date().toISOString()}.pdf`);
const code = [
`// Save page as ${fileName}`,