import BetaNotice from '@/components/BetaNotice' import CodeEditor from '@/components/CodeEditor' import { useLanguage } from '@/i18n/context' export default function CustomTools() { const { isZh } = useLanguage() return (

{isZh ? '自定义工具' : 'Custom Tools'}

{isZh ? '通过注册自定义工具,扩展 AI Agent 的能力边界。使用 Zod 定义严格的输入接口,让 AI 安全调用你的业务逻辑。' : 'Extend AI Agent capabilities by registering custom tools. Use Zod to define strict input schemas for safe business logic calls.'}

{isZh ? '工具注册' : 'Tool Registration'}

{isZh ? '每个自定义工具需要定义四个核心属性:name、description、input schema 和 execute 函数。' : 'Each custom tool requires four core properties: name, description, input schema, and execute function.'}

{isZh ? '页面过滤器' : 'Page Filter'}

{isZh ? '通过 pageFilter 属性控制工具在哪些页面可见,提升安全性和用户体验。' : 'Control tool visibility on specific pages via the pageFilter property to enhance security and UX.'}

{ // 审批逻辑 }, // 可选:页面过滤器 pageFilter: { // 只在订单管理页面显示 include: ['/admin/orders', '/admin/orders/*'], // 排除特定页面 exclude: ['/admin/orders/archived'] } })`} language="javascript" />

{isZh ? '最佳实践' : 'Best Practices'}

{isZh ? '⚡ 性能优化' : '⚡ Performance Optimization'}

  • {isZh ? '• 使用 pageFilter 减少不必要的工具加载' : '• Use pageFilter to reduce unnecessary tool loading'}
  • {isZh ? '• 在 execute 函数中实现适当的缓存机制' : '• Implement appropriate caching in execute functions'}
  • {isZh ? '• 避免在工具中执行耗时的同步操作' : '• Avoid long-running sync operations in tools'}
) }