{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tool-vue",
  "title": "Tool (Vue)",
  "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/vue@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/markdown-vue",
    "@kind-ui/code-block-vue",
    "@kind-ui/confirmation-vue"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/vue/tool.ts",
      "content": "import { type Highlight, type ToolApprovalState, toolPrimitive } from \"@kind-ui/agent-ui/core\";\nimport { createParts } from \"@ui-sdk/vue/primitive\";\nimport { type Component, defineComponent, h, type Slot, type VNodeChild } from \"vue\";\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\n// A part whose default slot falls back to `fallback`, as React's default `children` do.\nconst withDefault = <State, Part extends Component = Component>(\n  part: Part,\n  name: string,\n  fallback: (scope: { state: State }) => VNodeChild,\n): Part =>\n  defineComponent({\n    name,\n    inheritAttrs: false,\n    setup(_, { attrs, slots }) {\n      return () => h(part as Component, attrs, { ...slots, default: slots.default ?? (fallback as Slot) });\n    },\n  }) as unknown as Part;\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/** The `heading`, the `label`, the call's `title` or the tool's name as words, with code as `code`, unless you fill the slot. */\nexport const ToolTitle = withDefault<{ title: string }>(parts.Title, \"ToolTitle\", ({ state }) =>\n  withCode(state.title),\n);\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. Fill the slot to render it yourself.\n */\n// Slot state is a proxy with no keys of its own, so the Confirmation's props are read one by one.\nexport const ToolApproval = withDefault<ToolApprovalState>(parts.Approval, \"ToolApproval\", ({ state }) =>\n  h(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\nconst heading = (text: string, badge: string, copy: Component) =>\n  h(\"div\", { \"data-tool-heading\": \"\" }, [\n    text,\n    h(\"span\", { \"data-tool-badge\": \"\", \"data-kind-badge\": \"\" }, badge),\n    h(copy),\n  ]);\n\n/**\n * The input as code, labeled \"Partial\" while it streams, with its copy button, unless you fill the slot. The code\n * block is named by the tool, like \"search_docs input\".\n */\nexport const ToolInput = withDefault<{\n  label: string;\n  code: string;\n  streaming: boolean;\n  highlight: Highlight | undefined;\n}>(parts.Input, \"ToolInput\", ({ state }) => [\n  heading(\"Input\", \"Partial\", ToolInputCopy),\n  h(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/**\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 fill the slot. The code block is named by the tool, like \"search_docs output\".\n */\nexport const ToolOutput = withDefault<{\n  label: string;\n  kind: \"markdown\" | \"code\";\n  text: string;\n  preliminary: boolean;\n  highlight: Highlight | undefined;\n}>(parts.Output, \"ToolOutput\", ({ state }) => [\n  heading(\"Output\", \"Preliminary\", ToolOutputCopy),\n  state.kind === \"markdown\"\n    ? h(Markdown, { source: state.text, streaming: state.preliminary, highlight: state.highlight })\n    : h(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/** How long the call took, as \"N s\", unless you fill the slot. Rendered only with `durationSeconds`. */\nexport const ToolMeta = withDefault<{ duration: string }>(\n  parts.Meta,\n  \"ToolMeta\",\n  ({ state }) => state.duration,\n);\n\n/** The `error` message while the status is `error`, unless you fill the slot. */\nexport const ToolError = withDefault<{ message: string }>(\n  parts.Error,\n  \"ToolError\",\n  ({ state }) => state.message,\n);\n\nconst defaultParts = () => [\n  h(ToolTrigger, null, () => [h(ToolIcon), h(ToolTitle), h(ToolMeta)]),\n  h(ToolContent, null, () => [h(ToolInput), h(ToolOutput), h(ToolError)]),\n  h(ToolApproval),\n];\n\n/**\n * A tool call as a step: its name and status, then its input, output or error, and its approval. A default slot\n * replaces the default parts.\n */\nexport const Tool = withDefault(parts.Root, \"Tool\", defaultParts);\n",
      "type": "registry:ui",
      "target": "@ui/vue/tool.ts"
    }
  ],
  "meta": {
    "layer": "vue"
  },
  "type": "registry:ui"
}
