feat(agent): add read_pdf_pages tool and PDF page context support

This commit is contained in:
yiling
2026-07-19 09:45:14 +08:00
parent 68a0fb7319
commit f68ba70656
22 changed files with 753 additions and 6 deletions
@@ -76,6 +76,11 @@ const BUILTIN_TOOLS = [
name: () => m.agent_tool_screenshot_name(),
description: () => m.agent_tool_screenshot_desc(),
},
{
id: 'read_pdf_pages',
name: () => m.agent_tool_read_pdf_pages_name(),
description: () => m.agent_tool_read_pdf_pages_desc(),
},
{
id: 'list_assets',
name: () => m.agent_tool_list_assets_name(),
+2
View File
@@ -389,6 +389,8 @@
"agent_tool_analyze_image_desc": "Allows the agent to view and analyze the visual contents of an image file.",
"agent_tool_screenshot_name": "Video Frame Extraction",
"agent_tool_screenshot_desc": "Allows the agent to extract still image frames from video files for analysis.",
"agent_tool_read_pdf_pages_name": "Read PDF Pages",
"agent_tool_read_pdf_pages_desc": "Allows the agent to convert and view specific pages of a PDF document as images.",
"agent_tool_list_assets_name": "Browse Shumai",
"agent_tool_list_assets_desc": "Allows the agent to list folders and browse files in Shumai.",
"agent_tool_create_folder_name": "Create Folder",
+2
View File
@@ -389,6 +389,8 @@
"agent_tool_analyze_image_desc": "允许智能体查看和分析图片文件的视觉内容。",
"agent_tool_screenshot_name": "提取视频帧",
"agent_tool_screenshot_desc": "允许智能体从视频文件中提取静态画面进行分析。",
"agent_tool_read_pdf_pages_name": "读取 PDF 页面",
"agent_tool_read_pdf_pages_desc": "允许智能体将 PDF 文件的指定页面转换为图片并查看。",
"agent_tool_list_assets_name": "浏览 Shumai",
"agent_tool_list_assets_desc": "允许智能体列出文件夹并浏览 Shumai 中的文件。",
"agent_tool_create_folder_name": "创建文件夹",
+2
View File
@@ -371,6 +371,8 @@ export * from "./agent_tool_analyze_image_name.js";
export * from "./agent_tool_analyze_image_desc.js";
export * from "./agent_tool_screenshot_name.js";
export * from "./agent_tool_screenshot_desc.js";
export * from "./agent_tool_read_pdf_pages_name.js";
export * from "./agent_tool_read_pdf_pages_desc.js";
export * from "./agent_tool_list_assets_name.js";
export * from "./agent_tool_list_assets_desc.js";
export * from "./agent_tool_create_folder_name.js";
+2
View File
@@ -373,6 +373,8 @@ export * from './agent_tool_analyze_image_name.js'
export * from './agent_tool_analyze_image_desc.js'
export * from './agent_tool_screenshot_name.js'
export * from './agent_tool_screenshot_desc.js'
export * from './agent_tool_read_pdf_pages_name.js'
export * from './agent_tool_read_pdf_pages_desc.js'
export * from './agent_tool_list_assets_name.js'
export * from './agent_tool_list_assets_desc.js'
export * from './agent_tool_create_folder_name.js'
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Allows the agent to convert and view specific pages of a PDF document as images." |
*
* @param {Agent_Tool_Read_Pdf_Pages_DescInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const agent_tool_read_pdf_pages_desc: ((inputs?: Agent_Tool_Read_Pdf_Pages_DescInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Agent_Tool_Read_Pdf_Pages_DescInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Agent_Tool_Read_Pdf_Pages_DescInputs = {};
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Agent_Tool_Read_Pdf_Pages_DescInputs */
const en_agent_tool_read_pdf_pages_desc = /** @type {(inputs: Agent_Tool_Read_Pdf_Pages_DescInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Allows the agent to convert and view specific pages of a PDF document as images.`)
};
const zh_agent_tool_read_pdf_pages_desc = /** @type {(inputs: Agent_Tool_Read_Pdf_Pages_DescInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`允许智能体将 PDF 文件的指定页面转换为图片并查看。`)
};
/**
* | output |
* | --- |
* | "Allows the agent to convert and view specific pages of a PDF document as images." |
*
* @param {Agent_Tool_Read_Pdf_Pages_DescInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const agent_tool_read_pdf_pages_desc = /** @type {((inputs?: Agent_Tool_Read_Pdf_Pages_DescInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Agent_Tool_Read_Pdf_Pages_DescInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_agent_tool_read_pdf_pages_desc(inputs)
return zh_agent_tool_read_pdf_pages_desc(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Read PDF Pages" |
*
* @param {Agent_Tool_Read_Pdf_Pages_NameInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const agent_tool_read_pdf_pages_name: ((inputs?: Agent_Tool_Read_Pdf_Pages_NameInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Agent_Tool_Read_Pdf_Pages_NameInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Agent_Tool_Read_Pdf_Pages_NameInputs = {};
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Agent_Tool_Read_Pdf_Pages_NameInputs */
const en_agent_tool_read_pdf_pages_name = /** @type {(inputs: Agent_Tool_Read_Pdf_Pages_NameInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Read PDF Pages`)
};
const zh_agent_tool_read_pdf_pages_name = /** @type {(inputs: Agent_Tool_Read_Pdf_Pages_NameInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`读取 PDF 页面`)
};
/**
* | output |
* | --- |
* | "Read PDF Pages" |
*
* @param {Agent_Tool_Read_Pdf_Pages_NameInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const agent_tool_read_pdf_pages_name = /** @type {((inputs?: Agent_Tool_Read_Pdf_Pages_NameInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Agent_Tool_Read_Pdf_Pages_NameInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_agent_tool_read_pdf_pages_name(inputs)
return zh_agent_tool_read_pdf_pages_name(inputs)
});