{"data":{"slug":"github-lobehub-lobehub-agents-skills-builtin-tool-f7b09bdc0758","title":"Builtin Tool Authoring","summary":"Create and manage LobeHub builtin tools with manifest, execution, and UI components, including defining APIs, runtime logic, and client surfaces.","url":"https:\/\/skillshunter.net\/skills\/github-lobehub-lobehub-agents-skills-builtin-tool-f7b09bdc0758","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-lobehub-lobehub-agents-skills-builtin-tool-f7b09bdc0758","markdown_url":"https:\/\/skillshunter.net\/skills\/github-lobehub-lobehub-agents-skills-builtin-tool-f7b09bdc0758.md","download_url":"https:\/\/skillshunter.net\/skills\/github-lobehub-lobehub-agents-skills-builtin-tool-f7b09bdc0758\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Ensure the `lobe-<domain>` identifier is permanent and used consistently in message history. Before submitting a PR, verify that all `<Name>ApiName` values have corresponding manifest entries, executor methods, and Inspector components. Runtime logic should be placed in `ExecutionRuntime\/`, while `client\/executor\/` should only delegate to it.","instructions":"---\nname: builtin-tool\ndescription: 'Use for LobeHub builtin agent tools: manifests, executors, runtimes, inspectors, renders, streaming and intervention.'\n---\n\n# Builtin Tool Authoring Guide\n\nA builtin tool is a package the agent runtime can call. It ships **five faces**:\n\n| Face                 | Lives in                                                                               | Audience                              |\n| -------------------- | -------------------------------------------------------------------------------------- | ------------------------------------- |\n| **Manifest + types** | `src\/{manifest,types,systemRole}.ts`                                                   | The LLM (tool spec + system prompt)   |\n| **ExecutionRuntime** | `src\/ExecutionRuntime\/`                                                                | Server \/ desktop \/ any runtime caller |\n| **Executor**         | `src\/client\/executor\/`                                                                 | Frontend (wraps stores\/services)      |\n| **Client UI**        | `src\/client\/{Inspector,Render,\u2026}\/`                                                     | Chat UI                               |\n| **Registry wiring**  | `packages\/builtin-tools\/src\/*.ts` + `src\/store\/tool\/slices\/builtin\/executors\/index.ts` | Framework                             |\n\n---\n\n## Read These First\n\n| Question                                                                             | Doc                                           |\n| ------------------------------------------------------------------------------------ | --------------------------------------------- |\n| Where do files live? What does each face do? Wiring?                                 | [architecture.md](references\/architecture.md) |\n| How do I name the tool, design APIs, write the manifest, executor, ExecutionRuntime? | [tool-design.md](references\/tool-design.md)   |\n| How do I build Inspector \/ Render \/ Placeholder \/ Streaming \/ Intervention \/ Portal? | [ui\/](references\/ui\/README.md)                |\n\n---\n\n## When to Use This Skill\n\n- Creating a new `packages\/builtin-tool-<name>\/` package\n- Adding a new API method to an existing builtin tool\n- Building or restyling any of the 6 client surfaces for a tool\n- Wiring a tool into the central registries\n- Debugging \"tool not found \/ API not found \/ render not showing \/ placeholder stuck\" errors\n\n---\n\n## Top-Level Design Principles\n\n1. **`lobe-<domain>` identifier is permanent.** It's stored in message history. Renames need legacy aliases kept alongside the new name (see the `\/\/ Legacy aliases` entries in `packages\/builtin-tool-local-system\/src\/client\/Inspector\/index.ts`, kept after `listLocalFiles`\/`searchLocalFiles` were renamed to `listFiles`\/`searchFiles`). Get it right the first time.\n2. **ApiName is an `as const` object**, not a TS enum. It doubles as the runtime list `BaseExecutor` iterates over.\n3. **Three result fields, three audiences:**\n   - `content: string` \u2192 the LLM reads it\n   - `state: Record<\u2026>` \u2192 the UI's `pluginState`; **result-domain only**, never echo all params back\n   - `error: { type, message, body? }` \u2192 both LLM and UI; `type` is a stable code\n4. **Split execution from frontend wiring.**\n   - `src\/ExecutionRuntime\/` \u2014 pure runtime, no React, no Zustand, accepts services via constructor. **The default place for new logic.**\n   - `src\/client\/executor\/` \u2014 `BaseExecutor` subclass that calls `ExecutionRuntime` (or stores\/services directly when frontend-only).\n5. **UI defaults to \"do nothing\".** Inspector is required (the header strip). Render\/Placeholder\/Streaming\/Intervention\/Portal are added **only when there's something specific to show** \u2014 empty registries are fine.\n6. **Style with `createStaticStyles + cssVar.*`** (zero-runtime). Fall back to `createStyles + token` only when you genuinely need runtime values. Use `@lobehub\/ui` components, not raw antd.\n7. **i18n keys live in `packages\/locales\/src\/default\/plugin.ts`.** Inspector titles must come from `t('builtins.<identifier>.apiName.<api>')` so something renders while args stream.\n8. **A failed long-running call should be continuable, not just inspectable.** Example: when `callSubAgent` stops halfway, the user says \"keep going\". So the fix was an optional `subAgentId` on `callSubAgent` that appends a new instruction to the same sub-agent thread \u2014 not a new \"look up that run\" API the model has to remember to call before retrying from scratch. Add a new API only when a user would ask for it on its own.\n\n---\n\n## Package Layout (preferred, post-2026 convention)\n\n```\npackages\/builtin-tool-<name>\/\n\u251c\u2500\u2500 package.json\n\u2514\u2500\u2500 src\/\n    \u251c\u2500\u2500 index.ts              # exports manifest + types + systemRole + Identifier (no React, no stores)\n    \u251c\u2500\u2500 manifest.ts           # BuiltinToolManifest with JSON Schema for every API\n    \u251c\u2500\u2500 types.ts              # ApiName const + Params\/State interfaces per API\n    \u251c\u2500\u2500 systemRole.ts         # System prompt teaching the model when\/how to use the APIs\n    \u251c\u2500\u2500 ExecutionRuntime\/     # \u2705 Default home for runtime logic (server- or anywhere-callable)\n    \u2502   \u2514\u2500\u2500 index.ts\n    \u2514\u2500\u2500 client\/\n        \u251c\u2500\u2500 index.ts          # Re-exports for the registries\n        \u251c\u2500\u2500 executor\/         # \u2705 Frontend executor \u2014 extends BaseExecutor, often delegates to ExecutionRuntime\n        \u2502   \u2514\u2500\u2500 index.ts\n        \u251c\u2500\u2500 Inspector\/        # required \u2014 header chip per API\n        \u251c\u2500\u2500 Render\/           # optional \u2014 rich result card\n        \u251c\u2500\u2500 Placeholder\/      # optional \u2014 skeleton during streaming\/execution\n        \u251c\u2500\u2500 Streaming\/        # optional \u2014 live output renderer (e.g. RunCommand, WriteFile)\n        \u251c\u2500\u2500 Intervention\/     # optional \u2014 approval \/ edit-before-run UI\n        \u251c\u2500\u2500 Portal\/           # optional \u2014 full-screen detail view\n        \u2514\u2500\u2500 components\/       # shared subcomponents used by the surfaces above\n```\n\n**Older packages** (`builtin-tool-calculator`, etc.) still have `src\/executor\/` as a sibling of `src\/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.\n\n`package.json` exports map:\n\n```json\n\"exports\": {\n  \".\":                  \".\/src\/index.ts\",\n  \".\/client\":           \".\/src\/client\/index.ts\",\n  \".\/executor\":         \".\/src\/client\/executor\/index.ts\",\n  \".\/executionRuntime\": \".\/src\/ExecutionRuntime\/index.ts\"\n}\n```\n\n---\n\n## Authoring Checklist\n\nBefore opening the PR:\n\n- [ ] Identifier follows `lobe-<domain>` and is **stable** (lives in message history).\n- [ ] Every `<Name>ApiName` value has: a manifest `api[]` entry, an executor method, an Inspector, an i18n `apiName.*` key.\n- [ ] `Params` interfaces match the JSON Schema; `State` interfaces match what the executor returns and what the UI surfaces read.\n- [ ] System prompt disambiguates confusable APIs and points to batch variants.\n- [ ] Runtime logic lives in `ExecutionRuntime\/`; the `client\/executor\/` only wires stores\/services and delegates.\n- [ ] Executor returns `{ success, content, state, error? }` via a single `toResult()` funnel \u2014 `content` always non-empty (default to `error.message`).\n- [ ] Inspector handles `isArgumentsStreaming`, `isLoading`, `partialArgs`, missing `pluginState`.\n- [ ] Render returns `null` until it has data; only created for APIs with rich results.\n- [ ] Placeholder added if the API has a perceivable execution lag (search, list, crawl).\n- [ ] Streaming added for APIs that emit incremental output (run command, write file, code execution).\n- [ ] Intervention added if `humanIntervention` is set in the manifest.\n- [ ] All registry files updated (see [architecture.md \u2192 Registry wiring](references\/architecture.md#registry-wiring)).\n- [ ] i18n keys in `packages\/locales\/src\/default\/plugin.ts` plus dev seeds in `en-US`\/`zh-CN`.\n- [ ] `bunx vitest run --silent='passed-only' 'packages\/builtin-tool-<name>'` passes.\n- [ ] `bun run type-check` passes.\n\n---\n\n## Reference Tools\n\nPick the closest neighbor and copy:\n\n| If your tool is\u2026                                                        | Read first                                                                                                     |\n| ----------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |\n| Pure-compute, no UI state                                               | `packages\/builtin-tool-calculator\/` \u2014 `ExecutionRuntime` reuses executor (mathjs\/nerdamer work everywhere)     |\n| CRUD over a domain entity                                               | `packages\/builtin-tool-task\/` \u2014 full Inspector + Render set, batch variants                                    |\n| Heavy UI (Inspector\/Render\/Placeholder\/Portal)                          | `packages\/builtin-tool-web-browsing\/` \u2014 search-style result UI, Portal for detail view                         |\n| Desktop \/ filesystem with all surfaces (incl. Streaming + Intervention) | `packages\/builtin-tool-local-system\/` \u2014 `ExecutionRuntime` injects an `ILocalSystemService`, executor calls it |\n| Server-side pure (no client executor)                                   | `packages\/builtin-tool-web-browsing\/` \u2014 only `ExecutionRuntime` is exported; the chat client doesn't run it    |\n| Needs human approval before running                                     | `packages\/builtin-tool-local-system\/src\/client\/Intervention\/` \u2014 per-API approval components                    |\n","use_cases":["Creating a new `packages\/builtin-tool-<name>\/` package","Adding a new API method to an existing builtin tool","Building or restyling any of the 6 client surfaces for a tool"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/lobehub\/lobehub\/blob\/54382b5c8e81544da454fa6d7b50f461a562c1ee\/.agents\/skills\/builtin-tool\/SKILL.md","source_commit":"54382b5c8e81544da454fa6d7b50f461a562c1ee","license":null,"version":null,"listing_approved_at":"2026-11-22","created_at":"2026-11-21T10:59:27.000000Z","updated_at":"2026-11-22T11:17:05.000000Z","seo_title":"Builtin Tool Authoring Guide","seo_description":"Learn how to create and manage LobeHub builtin tools with manifest, execution, and UI components.","seo_keywords":["builtin tool authoring","lobehub tool creation","builtin tool design","tool manifest setup","builtin tool execution"]}}