{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "app-assistant-tool-call",
  "type": "registry:block",
  "title": "App, assistant tool call",
  "description": "One tool call in an assistant thread: name, one-line summary and status, with the arguments and result in a disclosure. Four states; duration is text you supply.",
  "categories": [
    "app"
  ],
  "dependencies": [
    "lucide-react@^1.49.0",
    "zod@^4.6.5"
  ],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/block-kit.json",
    "https://ui.klarhimmel.com/r/editing.json",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/app-assistant-tool-call/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/app-assistant-tool-call/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, t } from '../_shared/schema';\n\nconst schema = z.object({\n  state: z.enum(['pending', 'running', 'succeeded', 'failed']),\n  open: z.boolean(),\n  name: t(60),\n  summary: t(120),\n  args: t(20000),\n  result: t(20000),\n  error: t(20000),\n  duration: t(20).optional(),\n  labels: z.object({ pending: t(20), running: t(20), succeeded: t(20), failed: t(20), args: t(30), result: t(30), error: t(30), empty: t(40) }),\n});\n\nexport const spec = defineSpec({\n  type: 'app-assistant-tool-call',\n  aliases: ['app/assistant-tool-call'],\n  name: 'App, assistant tool call',\n  category: 'app',\n  role: 'body',\n  description: 'One tool call in an assistant thread: name, one-line summary and status, with the arguments and result in a disclosure. Four states; duration is text you supply.',\n  schema,\n  defaults: {\n    \"state\": \"succeeded\",\n    \"open\": true,\n    \"name\": \"tool.name_the_call\",\n    \"summary\": \"Say in one line what the call asked for\",\n    \"args\": \"{\\n  \\\"first\\\": \\\"Name a setting\\\",\\n  \\\"second\\\": \\\"Name a value\\\",\\n  \\\"third\\\": \\\"Name an option\\\"\\n}\",\n    \"result\": \"{\\n  \\\"first\\\": \\\"Name a count\\\",\\n  \\\"second\\\": \\\"Name a total\\\",\\n  \\\"third\\\": { \\\"key\\\": \\\"Name a part\\\", \\\"share\\\": 0.0 }\\n}\",\n    \"error\": \"{\\n  \\\"status\\\": 000,\\n  \\\"code\\\": \\\"name_the_error\\\",\\n  \\\"message\\\": \\\"Say what went wrong and what to do.\\\"\\n}\",\n    \"duration\": \"0.0 s\",\n    \"labels\": {\n      \"pending\": \"Waiting\",\n      \"running\": \"Running\",\n      \"succeeded\": \"Done\",\n      \"failed\": \"Failed\",\n      \"args\": \"Arguments\",\n      \"result\": \"Result\",\n      \"error\": \"Error\",\n      \"empty\": \"Nothing to show\"\n    }\n  },\n});\n"
    },
    {
      "path": "src/blocks/app-assistant-tool-call/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/app-assistant-tool-call/index.tsx",
      "content": "import { useEffect, useId, useState, type ReactNode } from 'react';\nimport { Check, ChevronRight, CircleAlert, Clock, LoaderCircle, Wrench } from 'lucide-react';\nimport { Text, withHeadingLevel } from '../../editing';\nimport { cn } from '../../lib/utils';\nimport { Container, Opt, Section, useEditing } from '../_shared/kit';\nimport { spec } from './spec';\nimport type { BlockProps } from '../types';\nimport type { z } from 'zod';\n\nexport { spec };\ntype Props = z.infer<typeof spec.schema>;\n\nconst ICON = { pending: Clock, running: LoaderCircle, succeeded: Check, failed: CircleAlert } as const;\nconst TONE = { pending: 'text-kh-muted', running: 'text-kh-accent-ink', succeeded: 'text-kh-ink', failed: 'text-kh-ink' } as const;\n\n/** The call card. The disclosure starts from `props.open`, follows it when the prop changes, and the person can toggle it. */\nexport function ToolCall({ props }: { props: Props }) {\n  const id = useId();\n  const editing = useEditing();\n  const [open, setOpen] = useState(props.open);\n  useEffect(() => setOpen(props.open), [props.open]);\n  const Icon = ICON[props.state];\n  const failed = props.state === 'failed';\n  const shown = open || editing;\n  const done = props.state === 'succeeded' || failed;\n  return (\n    <div data-state={props.state} className={cn('min-w-0 overflow-hidden rounded-kh-lg border bg-kh-surface-2 text-kh-small', failed ? 'border-kh-danger' : 'border-kh-line')}>\n      <button\n        type=\"button\"\n        aria-expanded={shown}\n        aria-controls={`${id}-p`}\n        onClick={() => setOpen((o) => !o)}\n        className=\"flex w-full min-w-0 flex-wrap items-center gap-x-3 gap-y-1 px-3 py-2.5 text-left hover:bg-kh-surface-3 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-(--kh-focus)\"\n      >\n        <ChevronRight aria-hidden className={cn('size-4 shrink-0 text-kh-muted transition-transform', shown && 'rotate-90')} />\n        <Wrench aria-hidden className=\"size-4 shrink-0 text-kh-muted\" />\n        <Text path={['name']} value={props.name} as=\"span\" className=\"min-w-0 font-kh-mono text-kh-caption font-medium [overflow-wrap:anywhere]\" />\n        <Text path={['summary']} value={props.summary} as=\"span\" className=\"min-w-0 flex-1 basis-48 text-kh-muted\" />\n        <span className={cn('ml-auto inline-flex items-center gap-1.5 text-kh-caption font-medium', TONE[props.state])}>\n          <Icon aria-hidden className={cn('size-3.5', failed && 'text-kh-danger', props.state === 'running' && 'motion-safe:animate-spin')} />\n          <Text path={['labels', props.state]} value={props.labels[props.state]} as=\"span\" />\n          {(done || editing) && <Opt path={['duration']} value={props.duration} as=\"span\" className=\"font-normal text-kh-muted\" placeholder=\"Duration\" />}\n        </span>\n      </button>\n      <div id={`${id}-p`} hidden={!shown} className=\"flex flex-col gap-3 border-t border-kh-line bg-kh-surface p-3\">\n        <Code label={props.labels.args} labelPath={['labels', 'args']}>\n          {props.args || editing ? <Text path={['args']} value={props.args} as=\"code\" className=\"whitespace-pre-wrap [overflow-wrap:anywhere]\" /> : <span className=\"text-kh-muted\">{props.labels.empty}</span>}\n        </Code>\n        {(props.state === 'succeeded' || editing) && (\n          <Code label={props.labels.result} labelPath={['labels', 'result']}>\n            {props.result || editing ? <Text path={['result']} value={props.result} as=\"code\" className=\"whitespace-pre-wrap [overflow-wrap:anywhere]\" /> : <span className=\"text-kh-muted\">{props.labels.empty}</span>}\n          </Code>\n        )}\n        {(failed || editing) && (\n          <Code label={props.labels.error} labelPath={['labels', 'error']} danger>\n            <Text path={['error']} value={props.error} as=\"code\" className=\"whitespace-pre-wrap [overflow-wrap:anywhere]\" />\n          </Code>\n        )}\n        {editing && (\n          <ul className=\"flex flex-wrap gap-x-4 gap-y-1 text-kh-caption text-kh-muted\">\n            {(['pending', 'running', 'succeeded', 'failed'] as const).filter((k) => k !== props.state).map((k) => (\n              <li key={k}>\n                <Text path={['labels', k]} value={props.labels[k]} as=\"span\" />\n              </li>\n            ))}\n            <li>\n              <Text path={['labels', 'empty']} value={props.labels.empty} as=\"span\" />\n            </li>\n          </ul>\n        )}\n      </div>\n    </div>\n  );\n}\n\n/** A labelled block of code text. Tall content scrolls inside it; it is focusable so a keyboard can scroll it. */\nfunction Code({ label, labelPath, danger, children }: { label: string; labelPath: (string | number)[]; danger?: boolean; children: ReactNode }) {\n  const id = useId();\n  return (\n    <div className=\"min-w-0\">\n      <p id={id} className=\"mb-1 flex items-center gap-1.5 text-kh-caption font-medium text-kh-muted\">\n        {danger && <CircleAlert aria-hidden className=\"size-3.5 text-kh-danger\" />}\n        <Text path={labelPath} value={label} as=\"span\" />\n      </p>\n      <pre\n        tabIndex={0}\n        role=\"region\"\n        aria-labelledby={id}\n        className={cn(\n          'max-h-64 overflow-auto rounded-kh bg-kh-surface-2 px-3 py-2.5 font-kh-mono text-kh-caption leading-relaxed text-kh-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--kh-focus)',\n          danger && 'border border-kh-danger',\n        )}\n      >\n        {children}\n      </pre>\n    </div>\n  );\n}\n\nfunction AppAssistantToolCall({ props }: BlockProps<Props>) {\n  return (\n    <Section>\n      <Container width=\"narrow\">\n        <ToolCall props={props} />\n      </Container>\n    </Section>\n  );\n}\n\nexport default withHeadingLevel(AppAssistantToolCall);\n"
    }
  ]
}
