发布时间:2026/7/19 16:07:14
内置工具开发_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/7/19 16:07:14

事件驱动后台任务_agent-signal

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

2026/7/19 16:02:14

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

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

2026/7/20 0:18:52

互联网大厂常见Java面试题及答案汇总(2026持续更新)

金九银十即将来袭,又是一个跳槽的好季节,准备跳槽的同学都摩拳擦掌准备大面好几场,今天为大家准备了互联网面试必备的 1 到 5 年 Java 面试者都需要掌握的面试题,分别 JVM,并发编程,MySQL,Tomca…

2026/7/20 0:13:52

python数据可视化技巧的100个练习 -- 31. 类别数据的点图

重要性★★★☆☆ 难度★★☆☆☆ 你是一家零售公司的数据分析师。你的经理要求你可视化最近产品发布的客户满意度评级分布。评级是分类的,范围从“非常不满意”到“非常满意”。创建一个点图以显示每个评级类别的频率。使用 Python 进行数据处理和可视化。在代码中生成输入…

2026/7/20 0:13:52

智能体走进物理世界,千里科技携舱驾协同成果亮相WAIC 2026

在2026世界人工智能大会(WAIC 2026)举办期间,千里科技董事长、阶跃星辰董事长印奇作为特邀嘉宾出席大会开幕式并在大会主论坛(上午场)发表主题演讲《当智能体进入物理世界》。在印奇看来,"智能体"…

2026/7/20 0:13:52

ngx_output_chain_get_buf

1 定义 ngx_output_chain_get_buf 函数 定义在 src/core/ngx_output_chain.cstatic ngx_int_t ngx_output_chain_get_buf(ngx_output_chain_ctx_t *ctx, off_t bsize) {size_t size;ngx_buf_t *b, *in;ngx_uint_t recycled;in ctx->in->buf;size ctx->buf…

2026/7/19 0:00:15

Unity与Python本地通信:基于Flask的跨语言数据交换实战

1. 项目概述:为什么我们需要一个本地通信服务器?在游戏开发、数字孪生、仿真训练等众多领域,Unity作为强大的实时3D内容创作平台,其核心逻辑通常由C#驱动。然而,当我们需要进行复杂的数据分析、机器学习推理、科学计算…

2026/7/20 0:03:51

基于大数据爬虫+Hadoop+Spark的茶叶销售数据分析与可视化系统开题报告

一、课题研究背景与意义 茶叶作为我国特色农产品与核心经济作物,线上电商销售规模持续逐年扩增,各大电商平台、社交交易渠道积累了海量茶叶商品数据、交易订单数据、用户消费行为与评价数据。传统茶叶销售行业多采用小型数据库存储数据、人工统计分析的运…

2026/7/20 0:03:51

STM32H7 QSPI Flash下载算法制作指南

1. STM32H7 QSPI Flash下载算法制作概述在STM32H7系列微控制器的开发过程中,外部QSPI Flash存储器常被用于扩展存储空间。然而,MDK开发环境默认并不支持所有型号的QSPI Flash编程,这就需要我们自行制作下载算法。本文将详细介绍如何为STM32H7…

2026/7/20 0:03:51

深入解析TI PRU-ICSS:硬实时子系统架构与工业应用实践

1. 项目概述:深入理解PRU-ICSS的架构价值在嵌入式系统,尤其是工业自动化、电机驱动和实时网络通信领域,我们常常会遇到一个核心矛盾:主处理器(如Arm Cortex-A系列)需要处理复杂的操作系统、网络协议栈和用户…

2026/7/19 16:59:11

3个高效策略:快速掌握Axure中文界面配置

3个高效策略:快速掌握Axure中文界面配置 【免费下载链接】axure-cn Chinese language file for Axure RP. Axure RP 简体中文语言包。支持 Axure 11、10、9。不定期更新。 项目地址: https://gitcode.com/gh_mirrors/ax/axure-cn 还在为Axure RP的英文界面感…