{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tool",
  "title": "Tool",
  "description": "A tool call as a step, from its streamed input to its output or error.",
  "dependencies": [
    "@kind-ui/agent-ui@0.9.0",
    "@ui-sdk/core@0.1.0-beta.17",
    "@ui-sdk/react@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/markdown",
    "@kind-ui/code-block",
    "@kind-ui/confirmation"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/react/tool.tsx",
      "content": "\"use client\";\n\nimport { toolPrimitive } from \"@kind-ui/agent-ui/core\";\nimport { createParts } from \"@ui-sdk/react/primitive\";\nimport type { ComponentProps } from \"react\";\nimport { CodeBlock } from \"./code-block\";\nimport { Confirmation, withCode } from \"./confirmation\";\nimport { Markdown } from \"./markdown\";\n\nconst parts = createParts(toolPrimitive, {\n  root: \"div\",\n  trigger: \"button\",\n  icon: \"span\",\n  title: \"span\",\n  meta: \"span\",\n  approval: \"span\",\n  content: \"div\",\n  input: \"div\",\n  \"input-copy\": \"button\",\n  output: \"div\",\n  \"output-copy\": \"button\",\n  error: \"p\",\n});\n\nexport type ToolProps = ComponentProps<typeof parts.Root>;\n\n/**\n * A tool call as a step: its name and status, then its input, output or error, and its approval. Any `children`\n * replace the default parts.\n */\nexport function Tool({ children, ...props }: ToolProps) {\n  return <parts.Root {...props}>{children !== undefined ? children : DEFAULT_PARTS}</parts.Root>;\n}\n\nexport const ToolTrigger = parts.Trigger;\nexport const ToolIcon = parts.Icon;\nexport const ToolContent = parts.Content;\nexport const ToolInputCopy = parts.InputCopy;\nexport const ToolOutputCopy = parts.OutputCopy;\n\nexport type ToolTitleProps = ComponentProps<typeof parts.Title>;\n\n/** The `heading`, the `label`, the call's `title` or the tool's name as words, with code as `code`, unless you pass children. */\nexport function ToolTitle({ children = ({ title }) => withCode(title), ...props }: ToolTitleProps) {\n  return <parts.Title {...props}>{children}</parts.Title>;\n}\n\nexport type ToolApprovalProps = ComponentProps<typeof parts.Approval>;\n\n/**\n * A Confirmation for the call's approval while it has one: Deny, Always allow and Approve while `onDeny`,\n * `onAlwaysAllow` and `onApprove` are set and the request is open, then what was decided. Pass children to render it yourself.\n */\nexport function ToolApproval({\n  children = (confirmation) => <Confirmation {...confirmation} />,\n  ...props\n}: ToolApprovalProps) {\n  return <parts.Approval {...props}>{children}</parts.Approval>;\n}\n\nexport type ToolInputProps = ComponentProps<typeof parts.Input>;\n\n/**\n * The input as code, labeled \"Partial\" while it streams, with its copy button, unless you pass children. The code\n * block is named by the tool, like \"search_docs input\".\n */\nexport function ToolInput({\n  children = ({ label, code, streaming, highlight }) => (\n    <>\n      <div data-tool-heading=\"\">\n        Input\n        <span data-tool-badge=\"\" data-kind-badge=\"\">\n          Partial\n        </span>\n        <ToolInputCopy />\n      </div>\n      <CodeBlock\n        aria-label={label}\n        header={false}\n        code={code}\n        language=\"json\"\n        streaming={streaming}\n        highlight={highlight}\n      />\n    </>\n  ),\n  ...props\n}: ToolInputProps) {\n  return <parts.Input {...props}>{children}</parts.Input>;\n}\n\nexport type ToolOutputProps = ComponentProps<typeof parts.Output>;\n\n/**\n * The output, once there is one: text as markdown, any other value as code. Labeled \"Preliminary\" until it's final,\n * with its copy button, unless you pass children. The code block is named by the tool, like \"search_docs output\".\n */\nexport function ToolOutput({\n  children = ({ label, kind, text, preliminary, highlight }) => (\n    <>\n      <div data-tool-heading=\"\">\n        Output\n        <span data-tool-badge=\"\" data-kind-badge=\"\">\n          Preliminary\n        </span>\n        <ToolOutputCopy />\n      </div>\n      {kind === \"markdown\" ? (\n        <Markdown source={text} streaming={preliminary} highlight={highlight} />\n      ) : (\n        <CodeBlock\n          aria-label={label}\n          header={false}\n          code={text}\n          language=\"json\"\n          streaming={preliminary}\n          highlight={highlight}\n        />\n      )}\n    </>\n  ),\n  ...props\n}: ToolOutputProps) {\n  return <parts.Output {...props}>{children}</parts.Output>;\n}\n\nexport type ToolMetaProps = ComponentProps<typeof parts.Meta>;\n\n/** How long the call took, as \"N s\", unless you pass children. Rendered only with `durationSeconds`. */\nexport function ToolMeta({ children = ({ duration }) => duration, ...props }: ToolMetaProps) {\n  return <parts.Meta {...props}>{children}</parts.Meta>;\n}\n\nexport type ToolErrorProps = ComponentProps<typeof parts.Error>;\n\n/** The `error` message while the status is `error`, unless you pass children. */\nexport function ToolError({ children = ({ message }) => message, ...props }: ToolErrorProps) {\n  return <parts.Error {...props}>{children}</parts.Error>;\n}\n\n// Shared, so an update to the call doesn't render the default parts' wrappers again.\nconst DEFAULT_PARTS = (\n  <>\n    <ToolTrigger>\n      <ToolIcon />\n      <ToolTitle />\n      <ToolMeta />\n    </ToolTrigger>\n    <ToolContent>\n      <ToolInput />\n      <ToolOutput />\n      <ToolError />\n    </ToolContent>\n    <ToolApproval />\n  </>\n);\n",
      "type": "registry:ui",
      "target": "@ui/tool.tsx"
    }
  ],
  "meta": {
    "layer": "react"
  },
  "type": "registry:ui"
}
