{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tool-approval-demo",
  "title": "Tool Approval Demo",
  "description": "A worked example of Tool Approval: Asks before an agent runs a tool. Shows what the call will do, offers Allow once, Always allow and Deny, and leaves a one-line record of the answer.",
  "dependencies": [
    "lucide-react@^1.31.0"
  ],
  "registryDependencies": [
    "https://ui.tinkererslabs.com/r/tool-approval.json"
  ],
  "files": [
    {
      "path": "components/demos/tool-approval-demo.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { RestartButton } from \"@/components/demos/restart-button\"\nimport { ToolCall } from \"@/registry/default/tool-call/tool-call\"\nimport {\n  ToolApproval,\n  type ToolApprovalDecision,\n} from \"@/registry/default/tool-approval/tool-approval\"\n\nconst wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))\n\nconst readInput = { path: \"src/app/settings/page.tsx\", lines: \"1-120\" }\nconst deleteInput = { branch: \"release/0.7\", remote: \"origin\", force: false }\n\nexport function ToolApprovalDemo() {\n  const [run, setRun] = React.useState(0)\n  const [read, setRead] = React.useState<ToolApprovalDecision | null>(null)\n  const [removal, setRemoval] = React.useState<ToolApprovalDecision | null>(\n    null\n  )\n\n  return (\n    <div className=\"grid w-full max-w-md gap-3\" key={run}>\n      <p className=\"text-muted-foreground text-sm\">\n        The agent is cleaning up after the 0.8 release.\n      </p>\n\n      <ToolApproval\n        input={readInput}\n        name=\"read_file\"\n        onDecision={async (decision) => {\n          await wait(500)\n          setRead(decision)\n        }}\n      />\n      {read && read !== \"deny\" ? (\n        <ToolCall\n          durationMs={84}\n          input={readInput}\n          name=\"read_file\"\n          output={<p>120 lines read.</p>}\n          status=\"success\"\n        />\n      ) : null}\n\n      <ToolApproval\n        destructive\n        input={deleteInput}\n        name=\"delete_branch\"\n        summary={\n          <p>\n            Deletes <code>release/0.7</code> on origin. Anyone who has not\n            pulled it loses the branch.\n          </p>\n        }\n        onDecision={async (decision) => {\n          await wait(500)\n          setRemoval(decision)\n        }}\n      />\n      {removal && removal !== \"deny\" ? (\n        <ToolCall\n          durationMs={1320}\n          input={deleteInput}\n          name=\"delete_branch\"\n          output={<p>Deleted release/0.7 on origin.</p>}\n          status=\"success\"\n        />\n      ) : null}\n\n      {read && removal ? (\n        <div className=\"flex justify-center pt-2\">\n          <RestartButton\n            onClick={() => {\n              setRead(null)\n              setRemoval(null)\n              setRun((value) => value + 1)\n            }}\n          />\n        </div>\n      ) : null}\n    </div>\n  )\n}\n",
      "type": "registry:example"
    },
    {
      "path": "components/demos/restart-button.tsx",
      "content": "\"use client\"\n\nimport { RotateCcw } from \"lucide-react\"\n\nexport function RestartButton({ onClick }: { onClick: () => void }) {\n  return (\n    <button className=\"restore-button\" type=\"button\" onClick={onClick}>\n      <RotateCcw aria-hidden=\"true\" size={15} /> Replay\n    </button>\n  )\n}\n",
      "type": "registry:example"
    }
  ],
  "type": "registry:example"
}