Create Client Tool

cognitedata/builder-skills/skills/create-client-tool

作者 cognitedata7758093d8656无许可证6 个星标收录于 2026年10月8日更新于 2026年10月8日仓库2天前更新

Scaffolds an AtlasTool for an already-approved in-app useAtlasChat UI. For EOS sidebar tools, use integrate-fusion-agent (createAgentAction) instead. Triggers: AtlasTool, useAtlasChat tool, in-app atlas client tool.

AI 生成的概览

为已获批的应用内 useAtlasChat 集成搭建 AtlasTool 客户端工具,包含 TypeBox 模式与接线。

功能
指导智能体为已具备获批应用内 useAtlasChat 集成的应用创建浏览器端 AtlasTool。内容包括阅读代码库、使用 TypeBox 参数模式与返回 output 和 details 的 execute 函数定义工具、将工具注册到 useAtlasChat 的 tools 数组,以及可选地从 message.toolCalls 渲染结构化工具结果。它产出的是说明与代码片段,本身不运行任何内容。
适用场景
适用于在已有获批 useAtlasChat 集成的应用中添加可供 Atlas Agent 调用的客户端工具。对于 EOS 侧边栏工具,文档建议改用 integrate-fusion-agent 的 createAgentAction。
运行要求
需要来自 integrate-atlas-chat 的 vendored src/atlas-agent/ 目录与 @sinclair/typebox 包,以及具备获批应用内 useAtlasChat 集成的应用。不附带脚本,仅使用 Read、Glob、Grep、Edit 和 Write。

Create a Client Tool

Scaffold an AtlasTool named $ARGUMENTS. If the app has no approved in-app useAtlasChat, implement a Fusion action via integrate-fusion-agent instead.

Prerequisite: vendored src/atlas-agent/ and @sinclair/typebox from integrate-atlas-chat.

Background

Client tools let the Atlas Agent invoke browser-side logic — charts, local state, UI panels, navigation. The agent decides when to call; the app executes and returns a result.

  1. Agent responds with a clientTool action
  2. TypeBox validates the arguments
  3. execute() runs in the browser and returns { output, details }
  4. output (string) is sent back to the agent
  5. details is available on message.toolCalls for the UI to render

Step 1 — Understand the codebase

Before writing anything, read:

  • The file where useAtlasChat is called (often src/App.tsx or a chat hook) to find where tools is passed — imports are typically from ./atlas-agent/react after integrate-atlas-chat
  • Any existing tool definitions to match the file/naming conventions

Step 2 — Define the tool

Use Type from @sinclair/typebox for the parameters schema (compile-time types + runtime validation).

ts
import { Type } from "@sinclair/typebox";import type { AtlasTool } from "./atlas-agent/types";
export const myTool: AtlasTool = {  name: "my_tool",            // snake_case — this is what the agent uses to invoke it  description:    "One sentence describing what this tool does and when the agent should call it.",  parameters: Type.Object({    exampleParam: Type.String({ description: "What this param is for" }),    optionalNum: Type.Optional(Type.Number({ description: "..." })),  }),  execute: async (args) => {    return {      output: "Plain text summary sent back to the agent",      details: {        // Any structured data you want available in the UI via message.toolCalls      },    };  },};

Adjust the ./atlas-agent/... path if the tool file is not directly under src/ next to the atlas-agent folder (for example ../atlas-agent/types from src/tools/).

TypeBox quick reference

SchemaUsage
Type.String()string
Type.Number()number
Type.Boolean()boolean
Type.Literal("foo")exact value
Type.Union([Type.Literal("a"), Type.Literal("b")])enum
Type.Array(Type.String())string[]
Type.Object({ ... })object
Type.Optional(...)mark any field optional

Always add a description on the tool and on each parameter — the agent uses those strings.


Step 3 — Wire into useAtlasChat

Find the useAtlasChat call and add the tool to the tools array:

ts
const { messages, send, ... } = useAtlasChat({  client: isLoading ? null : sdk,  agentExternalId: AGENT_EXTERNAL_ID,  tools: [myTool],   // add here});

Step 4 — Render tool results (if needed)

If the tool returns structured details, render them in the message list. message.toolCalls is a ToolCall[] — one entry per tool call (client-side and server-side) in call order.

tsx
{msg.toolCalls?.map((tc, i) => (  // tc.name    — tool name  // tc.output  — the string sent back to the agent  // tc.details — your structured data (cast to your known shape)  <MyToolOutput key={i} data={tc.details as MyToolDetails} />))}

来源与署名

来源:cognitedata/builder-skills位于skills/create-client-tool提交7758093

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架