内置工具开发_builtin-tool

发布时间:2026/9/10 18:55:21

内置工具开发_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
延伸阅读

更多相关文章

2026/9/7 2:40:55

事件驱动后台任务_agent-signal

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

2026/9/10 3:40:10

RAG 系统端到端时延优化:从查询到回复的每一毫秒都值得争取

RAG 系统端到端时延优化:从查询到回复的每一毫秒都值得争取 一、"检索 200ms、LLM 生成 3 秒"——用户的等待时间由最慢的环节决定 RAG 系统的端到端延迟 查询理解 Embedding 编码 向量检索 重排序 上下文拼接 LLM 生成。这六个环节中,L…

2026/9/10 18:54:07

Hadoop与3D打印结合的制造业大数据分析实践

1. 项目背景与核心价值 当制造业遇上大数据和增材制造技术,一场生产效率革命正在悄然发生。这个项目将Hadoop分布式计算框架与3D打印技术相结合,构建了一套面向制造领域的数据分析解决方案。在实际生产环境中,我们每天需要处理来自数百台3D打…

2026/9/10 18:54:07

基于深度学习的人脸门禁与IPC安防监控系统实战指南

简介:面向深度学习与智能安防方向的毕业设计、课程设计开发者,这份源码项目融合人脸门禁与IPC网络摄像监控,可完成实时人脸识别、身份验证、异常告警等典型安防场景,适用于RKNN嵌入式平台快速验证。压缩包共71个文件,大…

2026/9/10 18:54:07

大模型API请求全链路:从Harness编排到KV Cache优化

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/9/10 18:49:07

医疗知识图谱问答系统实战:Python+Neo4j实现KBQA

简介:这是一份面向课程设计与知识图谱入门学习的医疗知识图谱问答系统Python工程,适合希望快速搭建轻量级问答Demo的开发者。项目包含设计报告Word、完整源码、医疗数据与运行截图,围绕“构建医疗知识图谱—实现简单对话系统”展开&#xff0…

2026/9/10 16:39:38

超人会飞不算本事:系统稳定依赖清晰规则与边界设计

开头先不绕弯子。“#斯坦李吐槽dc 所以超人是无缘无故会飞的嘛哈哈哈哈哈哈哈锤哥真是技术人才啊!#雷神 #复联”这类调侃式短标题,第一波冲击力在于它把两个宇宙的角色塞进同一个吐槽箱里,但细想一下就能发现,它真正碰到的根本不是…

2026/9/10 11:16:38

超人VS蜘蛛侠:拆解超级IP的影响力与传播方法论

把“蜘蛛侠 vs 超人”放在 CSDN 上聊,可能很多人第一反应是走错片场了。但如果把这两个角色看成“两个持续运营了 80 多年的文化产品”,你会发现,这场比较本质上是两个不同 IP 策略的长期结果对比:超人赢在定义了整个超级英雄题材…

2026/9/9 16:31:09

基于CNN的调制信号识别:MATLAB实现时频图分类实战

简介:本资源是一套面向通信工程与信号处理方向学习者、研究者的深度学习实践方案,聚焦调制信号自动检测与识别这一典型无线通信任务,解决传统方法依赖人工特征、低信噪比下性能下降等痛点。压缩包共12个文件(10.73MB)&…

2026/9/10 0:00:55

目录对比去重实战:用哈希算法精准清理重复文件

我电脑里现在还有一块换了三次机的“数据墓地”硬盘,里面存着2016年以前所有旧笔记本的完整备份。平时不觉得有什么,直到前阵子想把它整理归档,发现同一个安装包、同一批照片、同一份论文草稿,在几个不同的备份目录里反复出现。更…

2026/9/10 0:00:55

Leaflet离线地图完整Demo合集:内网部署与坐标纠偏实战

简介:这是一份面向Web GIS开发者的LeafLet离线地图示例合集,帮助开发者快速掌握离线地图从搭建到交互的完整流程。压缩包共723个文件,大小14.06MB,以319个js脚本、175个html页面和29个css样式文件为主体,配合png/svg图…

2026/9/10 0:00:55

MATLAB读取Rinex 3.02观测文件:多系统GNSS数据解析实战

简介:基于MATLAB开发的Rinex3.02版观测文件(o文件)读取代码包,面向卫星定位导航方向的学习者与研究人员,用于解决新版观测文件的数据解析、历元提取与时间转换问题。压缩包共4个文件,包含两个m脚本、一个19…

2026/9/10 12:32:02

USB Type-C PCB布局分区设计:电源、高速信号与PD协议全攻略

做硬件这行,Type-C接口算是典型的“看着简单,做起来全坑”的东西。光引脚就24个,高低速信号、电源、控制线全部塞在一个小小的连接器里,如果PCB布局不做规划,打样回来基本就是“插上没反应”、“高速掉线”、“静电一打…

2026/9/10 15:19:50

系统编程学习原型如何补齐稳定性边界

系统编程学习原型如何补齐稳定性边界预算有限时&#xff0c;我先优化明显多余的复制&#xff0c;而不是猜测性地换容器。用借用传递只读数据通常就能减少分配&#xff1a; fn parse(line: &str) -> Result<Item, Error> { /* ... */ }用基准确认热点确实在分配&am…

2026/9/10 15:49:53

雨花区哪家财务公司代理记账比较好?

在雨花区&#xff0c;企业处理财税事务常常面临诸多挑战&#xff0c;选择一家靠谱的财务公司至关重要。湖南巨勤财务管理咨询有限公司就是本地正规实体财税服务机构&#xff0c;深耕本地工商财税行业多年&#xff0c;熟悉当地工商局、税务局最新政策与申报流程。主营公司注册、…

还想了解更多?直接咨询顾问

免费诊断 + 免费方案 + 透明报价。

全国咨询热线400-8866-253
免费获取方案
咨询二维码