{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tool-solid",
  "title": "Tool (Solid)",
  "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/solid@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/markdown-solid",
    "@kind-ui/code-block-solid",
    "@kind-ui/confirmation-solid"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/solid/tool.tsx",
      "content": "import { codeSpans, toolPrimitive } from \"@kind-ui/agent-ui/core\";\nimport type { ComponentProps } from \"@solidjs/web\";\nimport { createParts } from \"@ui-sdk/solid/primitive\";\nimport { For, omit, Show } from \"solid-js\";\nimport { CodeBlock } from \"./code-block\";\nimport { Confirmation } 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(props: ToolProps) {\n  return <parts.Root {...omit(props, \"children\")}>{props.children ?? <DefaultParts />}</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\n// Text with its backticks as `code`.\nfunction Code(props: { text: string }) {\n  return (\n    <For each={codeSpans(props.text)} keyed={false}>\n      {(piece, index) => (index % 2 ? <code>{piece()}</code> : <>{piece()}</>)}\n    </For>\n  );\n}\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(props: ToolTitleProps) {\n  return (\n    <parts.Title {...omit(props, \"children\")}>\n      {props.children ?? ((state: { title: string }) => <Code text={state.title} />)}\n    </parts.Title>\n  );\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(props: ToolApprovalProps) {\n  return (\n    <parts.Approval {...omit(props, \"children\")}>\n      {props.children ??\n        ((state) => (\n          <Confirmation\n            approval={state.approval}\n            label={state.label}\n            onApprove={state.onApprove}\n            onDeny={state.onDeny}\n            onAlwaysAllow={state.onAlwaysAllow}\n            reason={state.reason}\n            approveLabel={state.approveLabel}\n            alwaysLabel={state.alwaysLabel}\n            alwaysTarget={state.alwaysTarget}\n            alwaysScope={state.alwaysScope}\n            alwaysDetail={state.alwaysDetail}\n            risk={state.risk}\n            riskText={state.riskText}\n            focusFallback={state.focusFallback}\n            motion={state.motion}\n          />\n        ))}\n    </parts.Approval>\n  );\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(props: ToolInputProps) {\n  return (\n    <parts.Input {...omit(props, \"children\")}>\n      {props.children ??\n        ((state) => (\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={state.label}\n              header={false}\n              code={state.code}\n              language=\"json\"\n              streaming={state.streaming}\n              highlight={state.highlight}\n            />\n          </>\n        ))}\n    </parts.Input>\n  );\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(props: ToolOutputProps) {\n  return (\n    <parts.Output {...omit(props, \"children\")}>\n      {props.children ??\n        ((state) => (\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            <Show\n              when={state.kind === \"markdown\"}\n              fallback={\n                <CodeBlock\n                  aria-label={state.label}\n                  header={false}\n                  code={state.text}\n                  language=\"json\"\n                  streaming={state.preliminary}\n                  highlight={state.highlight}\n                />\n              }\n            >\n              <Markdown source={state.text} streaming={state.preliminary} highlight={state.highlight} />\n            </Show>\n          </>\n        ))}\n    </parts.Output>\n  );\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(props: ToolMetaProps) {\n  return (\n    <parts.Meta {...omit(props, \"children\")}>\n      {props.children ?? ((state: { duration: string }) => state.duration)}\n    </parts.Meta>\n  );\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(props: ToolErrorProps) {\n  return (\n    <parts.Error {...omit(props, \"children\")}>\n      {props.children ?? ((state: { message: string }) => state.message)}\n    </parts.Error>\n  );\n}\n\nfunction DefaultParts() {\n  return (\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}\n",
      "type": "registry:ui",
      "target": "@ui/solid/tool.tsx"
    }
  ],
  "meta": {
    "layer": "solid"
  },
  "type": "registry:ui"
}
