内置工具开发_builtin-tool
以下为本文档的中文说明LobeHub内置工具包构建指南专门用于开发和集成LobeHub平台中可被代理调用的工具。该技能定义了内置工具的五大核心组件Manifest与类型定义为LLM提供工具规范和系统提示、ExecutionRuntime执行运行时负责服务器端和桌面端的实际调用、Executor执行器客户端侧的交互逻辑、Inspector检查器用于调试和验证工具行为、以及Render渲染器负责工具输出在界面中的呈现。此外还涵盖流式处理、干预机制、Portal集成和工具注册表等高级功能。使用场景主要包括为LobeHub平台添加新的Agent可调用工具、开发工具包的各面层组件、配置工具的Manifest和类型系统、实现工具的流式响应处理、以及将工具注册到工具注册表中供代理发现和使用。核心原则强调五面一体的架构设计——每个工具由五个独立但协同的组件构成分别服务于LLM、运行时、客户端、调试和UI渲染等不同层面。这种分层架构确保了工具的灵活性、可测试性和可维护性。Builtin Tool Authoring GuideA builtin tool is a package the agent runtime can call. It shipsfive faces:FaceLives inAudienceManifest typessrc/{manifest,types,systemRole}.tsThe LLM (tool spec system prompt)ExecutionRuntimesrc/ExecutionRuntime/Server / desktop / any runtime callerExecutorsrc/client/executor/Frontend (wraps stores/services)Client UIsrc/client/{Inspector,Render,…}/Chat UIRegistry wiringpackages/builtin-tools/src/*.tssrc/store/tool/slices/builtin/executors/index.tsFrameworkRead These FirstQuestionDocWhere do files live? What does each face do? Wiring?architecture.mdHow do I name the tool, design APIs, write the manifest, executor, ExecutionRuntime?tool-design.mdHow do I build Inspector / Render / Placeholder / Streaming / Intervention / Portal?ui/When to Use This SkillCreating a newpackages/builtin-tool-name/packageAdding a new API method to an existing builtin toolBuilding or restyling any of the 6 client surfaces for a toolWiring a tool into the central registriesDebugging “tool not found / API not found / render not showing / placeholder stuck” errorsTop-Level Design Principleslobe-domainidentifier is permanent.It’s stored in message history. Renames needdeprecatedaliases (seepackages/builtin-tools/src/inspectors.ts:88-89). Get it right the first time.ApiName is anas constobject, not a TS enum. It doubles as the runtime listBaseExecutoriterates over.Three result fields, three audiences:content: string→ the LLM reads itstate: Record…→ the UI’spluginState;result-domain only, never echo all params backerror: { type, message, body? }→ both LLM and UI;typeis a stable codeSplit execution from frontend wiring.src/ExecutionRuntime/— pure runtime, no React, no Zustand, accepts services via constructor.The default place for new logic.src/client/executor/—BaseExecutorsubclass that callsExecutionRuntime(or stores/services directly when frontend-only).UI defaults to “do nothing”.Inspector is required (the header strip). Render/Placeholder/Streaming/Intervention/Portal are addedonly when there’s something specific to show— empty registries are fine.Style withcreateStaticStyles cssVar.*(zero-runtime). Fall back tocreateStyles tokenonly when you genuinely need runtime values. Uselobehub/uicomponents, not raw antd.i18n keys live insrc/locales/default/plugin.ts.Inspector titles must come fromt(builtins.identifier.apiName.api)so something renders while args stream.Package Layout (preferred, post-2026 convention)packages/builtin-tool-name/ ├── package.json └── src/ ├── index.ts # exports manifest types systemRole Identifier (no React, no stores) ├── manifest.ts # BuiltinToolManifest with JSON Schema for every API ├── types.ts # ApiName const Params/State interfaces per API ├── systemRole.ts # System prompt teaching the model when/how to use the APIs ├── ExecutionRuntime/ # ✅ Default home for runtime logic (server- or anywhere-callable) │ └── index.ts └── client/ ├── index.ts # Re-exports for the registries ├── executor/ # ✅ Frontend executor — extends BaseExecutor, often delegates to ExecutionRuntime │ └── index.ts ├── Inspector/ # required — header chip per API ├── Render/ # optional — rich result card ├── Placeholder/ # optional — skeleton during streaming/execution ├── Streaming/ # optional — live output renderer (e.g. RunCommand, WriteFile) ├── Intervention/ # optional — approval / edit-before-run UI ├── Portal/ # optional — full-screen detail view └── components/ # shared subcomponents used by the surfaces aboveOlder packages(builtin-tool-task,builtin-tool-calculator, etc.) still havesrc/executor/as a sibling ofsrc/client/. That’s grandfathered;don’t relocate without a deliberate refactor. New packages and new APIs added to existing packages should follow the layout above.package.jsonexports map:exports:{.:./src/index.ts,./client:./src/client/index.ts,./executor:./src/client/executor/index.ts,./executionRuntime:./src/ExecutionRuntime/index.ts}Authoring ChecklistBefore opening the PR:Identifier followslobe-domainand isstable(lives in message history).EveryNameApiNamevalue has: a manifestapi[]entry, an executor method, an Inspector, an i18napiName.*key.Paramsinterfaces match the JSON Schema;Stateinterfaces match what the executor returns and what the UI surfaces read.System prompt disambiguates confusable APIs and points to batch variants.Runtime logic lives inExecutionRuntime/; theclient/executor/only wires stores/services and delegates.Executor returns{ success, content, state, error? }via a singletoResult()funnel —contentalways non-empty (default toerror.message).Inspector handlesisArgumentsStreaming,isLoading,partialArgs, missingpluginState.Render returnsnulluntil it has data; only created for APIs with rich results.Placeholder added if the API has a perceivable execution lag (search, list, crawl).Streaming added for APIs that emit incremental output (run command, write file, code execution).Intervention added ifhumanInterventionis set in the manifest.All registry files updated (see architecture.md → Registry wiring).i18n keys insrc/locales/default/plugin.tsplus dev seeds inen-US/zh-CN.bunx vitest run --silentpassed-only packages/builtin-tool-namepasses.bun run type-checkpasses.Reference ToolsPick the closest neighbor and copy:If your tool is…Read firstPure-compute, no UI statepackages/builtin-tool-calculator/—ExecutionRuntimereuses executor (mathjs/nerdamer work everywhere)CRUD over a domain entitypackages/builtin-tool-task/— full Inspector Render set, batch variantsHeavy UI (Inspector/Render/Placeholder/Portal)packages/builtin-tool-web-browsing/— search-style result UI, Portal for detail viewDesktop / filesystem with all surfaces (incl. Streaming Intervention)packages/builtin-tool-local-system/—ExecutionRuntimeinjects anILocalSystemService, executor calls itServer-side pure (no client executor)packages/builtin-tool-web-browsing/— onlyExecutionRuntimeis exported; the chat client doesn’t run itNeeds human approval before runningpackages/builtin-tool-local-system/src/client/Intervention/— per-API approval components

相关新闻

Replication Manager完全指南:MySQL/MariaDB高可用性解决方案入门

Replication Manager完全指南:MySQL/MariaDB高可用性解决方案入门

Replication Manager完全指南:MySQL/MariaDB高可用性解决方案入门 【免费下载链接】replication-manager Signal 18 repman - Replication Manager for MySQL / MariaDB / Percona Server 项目地址: https://gitcode.com/gh_mirrors/re/replication-manager …

2026/7/23 22:40:45 阅读更多 →
事件驱动后台任务_agent-signal

事件驱动后台任务_agent-signal

以下为本文档的中文说明Agent Signal 是 LobeHub 开发的一个事件驱动型后台任务技能,用于在不阻塞前台对话的情况下实现 Agent 的异步处理。它的核心架构遵循一个一致的数据流模式:从信号源(Source)捕获事件、信号解释&#xff08…

2026/7/21 10:17:12 阅读更多 →
私域运营知识库_private-domain-operations-knowledge-builder

私域运营知识库_private-domain-operations-knowledge-builder

以下为本文档的中文说明private-domain-operations-knowledge-builder(私域运营知识构建器)是一个专注于私域流量运营领域的专业知识管理技能。私域运营是指企业通过自有渠道(如微信群、企业微信、公众号、小程序、APP 等)直接触达…

2026/7/21 5:47:03 阅读更多 →

最新新闻

具身智能重构高墙透明治理:视频孪生+无感空间感知,打造司法监所全域穿透防线

具身智能重构高墙透明治理:视频孪生+无感空间感知,打造司法监所全域穿透防线

具身智能重构高墙透明治理:视频孪生无感空间感知,打造司法监所全域穿透防线技术出品:镜像视界(浙江)科技有限公司一、行业现状与高墙管控核心桎梏随着数字法治、智慧司法建设纵深推进,看守所、监狱、留置场…

2026/7/23 22:40:28 阅读更多 →
一位直博生的 AI 编程困境,会语法,却写不出项目?|AI悦创VibeCoding/Python一对一辅导分享

一位直博生的 AI 编程困境,会语法,却写不出项目?|AI悦创VibeCoding/Python一对一辅导分享

你好,我是悦创。 会 C、Python 语法,为什么一遇到真实项目,还是不知道从哪里下手? 这场会议里,一位 985 大三、已直博清华的同学也遇到了同样的问题:局部代码能看懂,自己写却一片空白&#xff1…

2026/7/23 22:40:28 阅读更多 →
ShortGPT: Layers in Large Language Models are More Redundant Than You Expect 解读

ShortGPT: Layers in Large Language Models are More Redundant Than You Expect 解读

一、论文基本信息 论文题目:ShortGPT: Layers in Large Language Models are More Redundant Than You Expect 核心方法: ShortGPT:面向选择题、困惑度评估等场景的静态层剪枝; ShortGPT-gen:面向自回归生成任务的动…

2026/7/23 22:40:28 阅读更多 →
非结构化数据满天飞,90%的敏感数据藏在文档堆里,怎么让AI真正分得清?

非结构化数据满天飞,90%的敏感数据藏在文档堆里,怎么让AI真正分得清?

“这份合同能不能发给客户?” 某科技公司的销售总监老张最近遇到了一个尴尬的时刻——客户催着要合同初稿,他盯着文件上的"内部资料"水印,犹豫了三分钟,最后还是点了发送。发完之后心里不踏实,跑去问信息安…

2026/7/23 22:40:28 阅读更多 →
AI辅助数学建模全流程实战:从读题到代码生成

AI辅助数学建模全流程实战:从读题到代码生成

1. 项目概述:AI辅助数学建模全流程实战参加数学建模竞赛却不知从何下手?这是很多大学生和研究生初次参赛时的共同困扰。去年带队参加泰迪杯时,我发现队员们在读题、选题、建模和编程四个关键环节普遍存在卡点。传统的人工解题模式需要大量专业…

2026/7/23 22:40:28 阅读更多 →
移动车载工业路由器跨国大规模配置更新架构:基于事务回滚与双向校验的深度实践代码解析

移动车载工业路由器跨国大规模配置更新架构:基于事务回滚与双向校验的深度实践代码解析

摘要:随着国内特种车辆与旅居车的大规模出口,网络设备在海外的连通性维护成为电气架构师必须面对的技术挑战。当车辆远赴重洋,海外本地通信运营商的基站频段变更、接入点名称规范调整,随时可能导致车载数字座舱大面积断网。如果依…

2026/7/23 22:39:28 阅读更多 →

日新闻

从单点好评到指数级传播:AI副业主理人必须掌握的4层口碑渗透模型(含ROI测算表)

从单点好评到指数级传播:AI副业主理人必须掌握的4层口碑渗透模型(含ROI测算表)

更多请点击: https://intelliparadigm.com 第一章:从单点好评到指数级传播:AI副业主理人必须掌握的4层口碑渗透模型(含ROI测算表) 当AI副业主理人不再仅满足于单次服务交付,而是主动构建可复用、可裂变、可…

2026/7/23 0:00:25 阅读更多 →
AI写作开头钩子设计:为什么你的AI文案完读率不足18%?——基于2,346篇A/B测试报告的归因分析

AI写作开头钩子设计:为什么你的AI文案完读率不足18%?——基于2,346篇A/B测试报告的归因分析

更多请点击: https://codechina.net 第一章:AI写作开头钩子设计:为什么你的AI文案完读率不足18%?——基于2,346篇A/B测试报告的归因分析 在对2,346篇跨行业AI生成文案的A/B测试数据进行聚类分析后,我们发现&#xff1…

2026/7/23 0:01:26 阅读更多 →
Chitchatter完整指南:免费开源的终极点对点安全聊天工具

Chitchatter完整指南:免费开源的终极点对点安全聊天工具

Chitchatter完整指南:免费开源的终极点对点安全聊天工具 【免费下载链接】chitchatter Secure peer-to-peer chat that is serverless, decentralized, and ephemeral 项目地址: https://gitcode.com/gh_mirrors/ch/chitchatter Chitchatter是一款革命性的安…

2026/7/23 0:01:26 阅读更多 →

周新闻

Go语言静态资源打包方案对比与实践指南

Go语言静态资源打包方案对比与实践指南

1. 项目背景与核心需求在Go语言开发中,我们经常需要处理静态资源文件的打包问题。无论是Web应用的模板文件、前端资源,还是配置文件、证书等,都需要随程序一起分发。传统做法是将这些文件与编译后的二进制文件放在同一目录下,但这…

2026/7/22 8:58:19 阅读更多 →
Go语言实现高性能LDAP认证服务的架构与实践

Go语言实现高性能LDAP认证服务的架构与实践

1. 项目背景与核心价值LDAP(轻量级目录访问协议)作为企业级身份认证的黄金标准,已经服务了超过80%的财富500强公司。我在金融科技领域实施统一认证体系时,发现传统Java方案存在启动慢、内存占用高等痛点。而Go语言凭借其协程并发模…

2026/7/22 19:43:43 阅读更多 →
【AI面试官实战指南】:用ChatGPT模拟10类高频技术岗面试,3天提升应答精准度92%

【AI面试官实战指南】:用ChatGPT模拟10类高频技术岗面试,3天提升应答精准度92%

更多请点击: https://intelliparadigm.com 第一章:AI面试官实战指南的核心价值与适用场景 AI面试官并非替代人类HR的“黑箱工具”,而是以可解释、可审计、可迭代的方式,赋能招聘全链路的关键基础设施。其核心价值在于将主观经验沉…

2026/7/23 17:49:47 阅读更多 →

月新闻