Tool Result
Terminal Output
ToolResult.vue<script setup lang="ts">
import { ToolResult, ToolResultOutput, AgentCode } from 'beui-vue'
import { computed, onBeforeUnmount, onMounted, shallowRef, watch, ref } from 'vue'
function useAgentVariant(selected: () => string | undefined, choices: Record<string,string>) {
const pinned = undefined as string | undefined
const fixed = Boolean(pinned)
const query = ref('')
const options = Object.keys(choices)
const variant = computed(() => {
const requested = pinned || selected() || query.value
return options.find(slug => requested === slug || requested === choices[slug]) ?? options[0]
})
function refresh() {
query.value = new URL(location.href).searchParams.get('variant') ?? ''
}
function choose(slug:string) {
if (fixed || !options.includes(slug)) return
const url = new URL(location.href)
url.searchParams.set('variant',slug)
history.replaceState(history.state,'',url)
refresh()
}
onMounted(() => {
if (fixed) return
refresh()
window.addEventListener('popstate',refresh)
})
onBeforeUnmount(() => window.removeEventListener('popstate',refresh))
return { variant, choose, options, fixed }
}
const props = defineProps<{ variant?: string }>()
const { variant, choose, options, fixed } = useAgentVariant(() => props.variant, {
'terminal-output': 'agents/tool-result-terminal', 'request-result': 'agents/tool-result-request',
})
const OUTPUT = ['$ bun test tests/a11y.test.tsx', 'bun test v1.3.14', '✓ StreamingResponse complete', '✓ ToolApproval pending', '✓ Citations expanded', '49 pass · 0 fail']
const RESPONSE = '{\n "error": "rate_limit_exceeded",\n "retryAfter": 30,\n "requestId": "req_8f21"\n}'
const PENDING = ['Preparing request…', 'GET /v1/activity\nConnecting…', 'GET /v1/activity\nWaiting for response…']
const isRequest = computed(() => variant.value === 'request-result')
const steps = computed(() => isRequest.value ? 3 : OUTPUT.length)
const visible = shallowRef(0)
const status = shallowRef<'running' | 'success' | 'error'>('running')
const run = shallowRef(0)
const mounted = shallowRef(false)
let timers: ReturnType<typeof setTimeout>[] = []
function start() {
timers.forEach(clearTimeout)
visible.value = 0
status.value = 'running'
const interval = isRequest.value ? 600 : 420
timers = Array.from({ length: steps.value }, (_, index) => setTimeout(() => { visible.value = index + 1 }, index * interval + 180))
timers.push(setTimeout(() => { status.value = isRequest.value ? 'error' : 'success' }, steps.value * interval + 480))
}
function replay() { run.value += 1 }
onMounted(() => { mounted.value = true })
watch([variant, run, mounted], () => { if (mounted.value) start() })
onBeforeUnmount(() => timers.forEach(clearTimeout))
const output = computed(() => OUTPUT.slice(0, visible.value).join('\n'))
const title = computed(() => isRequest.value
? status.value === 'running' ? 'Fetching project activity' : 'Request failed'
: status.value === 'running' ? 'Running accessibility tests' : 'Tests passed')
const meta = computed(() => isRequest.value ? (status.value === 'error' ? '429' : 'GET /v1/activity') : (status.value === 'success' ? '2.9s' : undefined))
</script>
<template>
<div class="demo" :data-example-variant="variant">
<ToolResult :key="`${variant}-${run}`" :tool="isRequest ? 'http.request' : 'terminal.run'" :title="title" :kind="isRequest ? 'request' : 'terminal'" :status="status" :meta="meta" :copy-text="isRequest ? RESPONSE : output" :collapse-on-complete="!isRequest" :max-height="150" @retry="replay">
<template v-if="isRequest">
<ToolResultOutput v-if="visible < 3">{{ PENDING[visible] }}</ToolResultOutput>
<AgentCode v-else :code="RESPONSE" language="json" />
</template>
<ToolResultOutput v-else>{{ output }}</ToolResultOutput>
</ToolResult>
<button type="button" class="replay" @click="replay"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" /></svg>Replay</button>
<label v-if="!fixed" class="variant">Example <select :value="variant" @change="choose(($event.target as HTMLSelectElement).value)"><option v-for="option in options" :key="option">{{ option }}</option></select></label>
</div>
</template>
<style scoped>
.demo { position: relative; width: 100%; max-width: 32rem; height: 330px; }
.replay { position: absolute; bottom: 0; left: 0; display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.25rem 0.5rem; border: 0; border-radius: 0.375rem; background: transparent; color: var(--beui-muted-foreground); font: inherit; font-size: 0.75rem; line-height: 1rem; font-weight: 500; cursor: pointer; outline: none; transition: color 0.15s, background-color 0.15s; }
.replay:hover { background: var(--beui-muted); color: var(--beui-foreground); }
.replay:focus-visible { box-shadow: 0 0 0 2px var(--beui-ring); }
.variant { position: absolute; right: 0; bottom: 0; display: inline-flex; align-items: center; gap: 0.375rem; color: var(--beui-muted-foreground); font-size: 0.75rem; }
.variant select { padding: 0.125rem 0.25rem; border: 1px solid var(--beui-border); border-radius: 0.375rem; background: var(--beui-background); color: var(--beui-foreground); font: inherit; }
</style><script lang="ts">
export const toolResultMessages = { running: 'Running', success: 'Completed', error: 'Failed', cancelled: 'Cancelled', copy: 'Copy result', copied: 'Copied', retry: 'Run again' }
export type ToolResultStatus = 'running' | 'success' | 'error' | 'cancelled'
export type ToolResultKind = 'terminal' | 'request' | 'custom'
</script>
<script setup lang="ts">
import { motion } from 'motion-v'
import { useReducedMotion } from '../core/reduced-motion'
import { computed, onBeforeUnmount, useId, useTemplateRef, watch } from 'vue'
import { pressSpring, swapSpring } from '../core/motion'
import { useOpenState } from '../primitives/state'
import AgentIcon from './AgentIcon.vue'
import AgentReveal from './AgentReveal.vue'
import AgentRollText from './AgentRollText.vue'
import './agent-tokens.css'
import { useCopy, useHasListener, type Labels } from './shared'
const props = withDefaults(defineProps<{
tool: string, title: string, meta?: string, status?: ToolResultStatus, kind?: ToolResultKind,
open?: boolean, defaultOpen?: boolean, collapseOnComplete?: boolean, maxHeight?: number, copyText?: string,
/** Overrides the built-in clipboard action. */
onCopy?: () => void | Promise<void>, labels?: Labels, contentClassName?: string
}>(), { status: 'running', kind: 'custom', open: undefined, defaultOpen: true, collapseOnComplete: true, maxHeight: 220 })
const emit = defineEmits<{ 'update:open': [value: boolean], openChange: [value: boolean], retry: [] }>()
defineSlots<{ default?(): unknown, icon?(): unknown }>()
// The retry action only shows when a listener is bound, like upstream's optional `onRetry`.
const hasRetry = useHasListener('retry')
const reduce = useReducedMotion()
const { open, setOpen } = useOpenState(() => props.open, props.defaultOpen, next => { emit('update:open', next); emit('openChange', next) })
const { copied, copy } = useCopy()
const uid = useId()
const viewport = useTemplateRef<HTMLElement>('viewport')
const running = computed(() => props.status === 'running')
const canCopy = computed(() => Boolean(props.copyText || props.onCopy))
const t = (key: keyof typeof toolResultMessages) => props.labels?.[key] ?? toolResultMessages[key]
const statusLabel = computed(() => t(props.status))
const kindIcon = computed(() => props.kind === 'terminal' ? 'SquareTerminal' : props.kind === 'request' ? 'Braces' : 'Wrench')
const statusIcon = computed(() => ({ running: 'LoaderCircle', success: 'CircleCheck', error: 'CircleX', cancelled: 'Ban' } as const)[props.status])
watch(() => props.status, (next, previous) => {
if (previous !== 'running' && next === 'running') setOpen(true)
if (previous === 'running' && next !== 'running' && props.collapseOnComplete) setOpen(false)
})
let frame = 0
watch(() => [props.status, open.value] as const, scrollDown, { flush: 'post' })
// The slot content is opaque, so follow every update while the tool is running.
function scrollDown() {
cancelAnimationFrame(frame)
if (!open.value || !running.value) return
frame = requestAnimationFrame(() => viewport.value?.scrollTo({ top: viewport.value.scrollHeight, behavior: reduce.value ? 'auto' : 'smooth' }))
}
let observer: MutationObserver | undefined
watch(viewport, element => {
observer?.disconnect()
if (!element || typeof MutationObserver === 'undefined') return
observer = new MutationObserver(scrollDown)
observer.observe(element, { childList: true, subtree: true, characterData: true })
}, { flush: 'post' })
onBeforeUnmount(() => { cancelAnimationFrame(frame); observer?.disconnect() })
</script>
<template>
<div class="be-ag be-tr" :data-state="status" :aria-busy="running">
<button :id="`${uid}-trigger`" type="button" class="be-tr-trigger" :aria-expanded="open" :aria-controls="`${uid}-content`" @click="setOpen(!open)">
<span aria-hidden="true" class="be-tr-icon"><slot name="icon"><AgentIcon :name="kindIcon" :size="16" /></slot></span>
<span class="be-tr-text">
<span class="be-tr-title"><AgentRollText :value="title">{{ title }}</AgentRollText></span>
<span v-if="meta" class="be-tr-meta"><AgentRollText :value="meta">{{ meta }}</AgentRollText></span>
<span class="be-tr-tool"><AgentRollText :value="tool">{{ tool }}</AgentRollText></span>
</span>
<span class="be-tr-status" :data-status="status"><AgentIcon :name="statusIcon" :size="12" :class="{ 'be-ag-spin': running && !reduce }" /><AgentRollText :value="status">{{ statusLabel }}</AgentRollText></span>
<motion.span aria-hidden="true" class="be-tr-chevron" :animate="{ rotate: open ? 180 : 0 }" :transition="reduce ? { duration: 0 } : swapSpring"><AgentIcon name="ChevronDown" :size="14" /></motion.span>
</button>
<AgentReveal :id="`${uid}-content`" role="region" :aria-labelledby="`${uid}-trigger`" :open="open">
<div class="be-tr-indent">
<div class="be-tr-card">
<div ref="viewport" role="log" aria-live="polite" class="be-tr-viewport be-ag-hide-scroll" :style="{ maxHeight: `${maxHeight}px` }"><div class="be-tr-content" :class="contentClassName"><slot /></div></div>
<div v-if="canCopy || hasRetry()" class="be-tr-foot">
<motion.button v-if="canCopy" type="button" class="be-tr-action" :aria-label="copied ? t('copied') : t('copy')" :title="copied ? t('copied') : t('copy')" :while-press="reduce ? undefined : { scale: 0.9 }" :transition="pressSpring" @click="copy(copyText ?? '', onCopy)"><AgentIcon :name="copied ? 'Check' : 'Copy'" :size="14" /></motion.button>
<motion.button v-if="hasRetry()" type="button" class="be-tr-action" :aria-label="t('retry')" :title="t('retry')" :while-press="reduce ? undefined : { scale: 0.9 }" :transition="pressSpring" @click="emit('retry')"><AgentIcon name="RotateCcw" :size="14" /></motion.button>
<span class="be-tr-foot-status"><AgentRollText :value="status">{{ statusLabel }}</AgentRollText></span>
</div>
</div>
</div>
</AgentReveal>
</div>
</template>
<style scoped>
.be-tr { box-sizing: border-box; width: 100%; font-size: 0.875rem; line-height: 1.25rem; color: var(--beui-foreground); }
.be-tr-trigger { display: flex; box-sizing: border-box; min-height: 2.25rem; width: 100%; align-items: center; gap: 0.5rem; padding: 0.25rem 0; border: 0; border-radius: 0.375rem; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; outline: none; }
.be-tr-trigger:focus-visible { box-shadow: 0 0 0 2px var(--beui-background), 0 0 0 4px var(--beui-ring); }
.be-tr-icon { display: grid; flex: none; width: 1rem; height: 1rem; place-items: center; color: var(--beui-muted-foreground); }
.be-tr-text { display: flex; min-width: 0; flex: 1; align-items: baseline; gap: 0.5rem; }
.be-tr-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; color: color-mix(in srgb, var(--beui-foreground) 90%, transparent); }
.be-tr-meta { flex: none; font-size: 0.75rem; line-height: 1rem; color: color-mix(in srgb, var(--beui-muted-foreground) 60%, transparent); }
.be-tr-tool { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono, ui-monospace, monospace); font-size: 11px; line-height: calc(1.25 / .875); color: color-mix(in srgb, var(--beui-muted-foreground) 55%, transparent); }
.be-tr-status { display: inline-flex; flex: none; align-items: center; gap: 0.25rem; font-size: 11px; line-height: calc(1.25 / .875); font-weight: 500; color: var(--beui-muted-foreground); }
.be-tr-status[data-status=running] { color: var(--ag-blue); }
.be-tr-status[data-status=success] { color: var(--ag-green); }
.be-tr-status[data-status=error] { color: var(--ag-rose); }
.be-tr-chevron { display: inline-flex; flex: none; color: color-mix(in srgb, var(--beui-muted-foreground) 50%, transparent); transition: color 0.15s; }
.be-tr-trigger:hover .be-tr-chevron { color: var(--beui-muted-foreground); }
.be-tr-indent { padding: 0.375rem 0 0 1.5rem; }
.be-tr-card { overflow: hidden; border-radius: 0.75rem; background: color-mix(in srgb, var(--beui-muted) 80%, transparent); }
.be-tr-viewport { overflow-y: auto; }
.be-tr-content { padding: 0.75rem; }
.be-tr-foot { display: flex; align-items: center; gap: 0.125rem; padding: 0 0.5rem 0.375rem; }
.be-tr-action { display: grid; width: 1.75rem; height: 1.75rem; place-items: center; padding: 0; border: 0; border-radius: 0.375rem; background: transparent; color: var(--beui-muted-foreground); cursor: pointer; outline: none; transition: color 0.15s, background-color 0.15s; }
.be-tr-action:hover { background: var(--beui-muted); color: var(--beui-foreground); }
.be-tr-action:focus-visible { box-shadow: 0 0 0 2px var(--beui-ring); }
.be-tr-foot-status { margin-inline-start: auto; font-size: 11px; line-height: calc(1.25 / .875); color: color-mix(in srgb, var(--beui-muted-foreground) 55%, transparent); }
</style>Request Result
ToolResult.vuePreparing request…<script setup lang="ts">
import { ToolResult, ToolResultOutput, AgentCode } from 'beui-vue'
import { computed, onBeforeUnmount, onMounted, shallowRef, watch, ref } from 'vue'
function useAgentVariant(selected: () => string | undefined, choices: Record<string,string>) {
const pinned = undefined as string | undefined
const fixed = Boolean(pinned)
const query = ref('')
const options = Object.keys(choices)
const variant = computed(() => {
const requested = pinned || selected() || query.value
return options.find(slug => requested === slug || requested === choices[slug]) ?? options[0]
})
function refresh() {
query.value = new URL(location.href).searchParams.get('variant') ?? ''
}
function choose(slug:string) {
if (fixed || !options.includes(slug)) return
const url = new URL(location.href)
url.searchParams.set('variant',slug)
history.replaceState(history.state,'',url)
refresh()
}
onMounted(() => {
if (fixed) return
refresh()
window.addEventListener('popstate',refresh)
})
onBeforeUnmount(() => window.removeEventListener('popstate',refresh))
return { variant, choose, options, fixed }
}
const props = defineProps<{ variant?: string }>()
const { variant, choose, options, fixed } = useAgentVariant(() => props.variant, {
'terminal-output': 'agents/tool-result-terminal', 'request-result': 'agents/tool-result-request',
})
const OUTPUT = ['$ bun test tests/a11y.test.tsx', 'bun test v1.3.14', '✓ StreamingResponse complete', '✓ ToolApproval pending', '✓ Citations expanded', '49 pass · 0 fail']
const RESPONSE = '{\n "error": "rate_limit_exceeded",\n "retryAfter": 30,\n "requestId": "req_8f21"\n}'
const PENDING = ['Preparing request…', 'GET /v1/activity\nConnecting…', 'GET /v1/activity\nWaiting for response…']
const isRequest = computed(() => variant.value === 'request-result')
const steps = computed(() => isRequest.value ? 3 : OUTPUT.length)
const visible = shallowRef(0)
const status = shallowRef<'running' | 'success' | 'error'>('running')
const run = shallowRef(0)
const mounted = shallowRef(false)
let timers: ReturnType<typeof setTimeout>[] = []
function start() {
timers.forEach(clearTimeout)
visible.value = 0
status.value = 'running'
const interval = isRequest.value ? 600 : 420
timers = Array.from({ length: steps.value }, (_, index) => setTimeout(() => { visible.value = index + 1 }, index * interval + 180))
timers.push(setTimeout(() => { status.value = isRequest.value ? 'error' : 'success' }, steps.value * interval + 480))
}
function replay() { run.value += 1 }
onMounted(() => { mounted.value = true })
watch([variant, run, mounted], () => { if (mounted.value) start() })
onBeforeUnmount(() => timers.forEach(clearTimeout))
const output = computed(() => OUTPUT.slice(0, visible.value).join('\n'))
const title = computed(() => isRequest.value
? status.value === 'running' ? 'Fetching project activity' : 'Request failed'
: status.value === 'running' ? 'Running accessibility tests' : 'Tests passed')
const meta = computed(() => isRequest.value ? (status.value === 'error' ? '429' : 'GET /v1/activity') : (status.value === 'success' ? '2.9s' : undefined))
</script>
<template>
<div class="demo" :data-example-variant="variant">
<ToolResult :key="`${variant}-${run}`" :tool="isRequest ? 'http.request' : 'terminal.run'" :title="title" :kind="isRequest ? 'request' : 'terminal'" :status="status" :meta="meta" :copy-text="isRequest ? RESPONSE : output" :collapse-on-complete="!isRequest" :max-height="150" @retry="replay">
<template v-if="isRequest">
<ToolResultOutput v-if="visible < 3">{{ PENDING[visible] }}</ToolResultOutput>
<AgentCode v-else :code="RESPONSE" language="json" />
</template>
<ToolResultOutput v-else>{{ output }}</ToolResultOutput>
</ToolResult>
<button type="button" class="replay" @click="replay"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" /></svg>Replay</button>
<label v-if="!fixed" class="variant">Example <select :value="variant" @change="choose(($event.target as HTMLSelectElement).value)"><option v-for="option in options" :key="option">{{ option }}</option></select></label>
</div>
</template>
<style scoped>
.demo { position: relative; width: 100%; max-width: 32rem; height: 330px; }
.replay { position: absolute; bottom: 0; left: 0; display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.25rem 0.5rem; border: 0; border-radius: 0.375rem; background: transparent; color: var(--beui-muted-foreground); font: inherit; font-size: 0.75rem; line-height: 1rem; font-weight: 500; cursor: pointer; outline: none; transition: color 0.15s, background-color 0.15s; }
.replay:hover { background: var(--beui-muted); color: var(--beui-foreground); }
.replay:focus-visible { box-shadow: 0 0 0 2px var(--beui-ring); }
.variant { position: absolute; right: 0; bottom: 0; display: inline-flex; align-items: center; gap: 0.375rem; color: var(--beui-muted-foreground); font-size: 0.75rem; }
.variant select { padding: 0.125rem 0.25rem; border: 1px solid var(--beui-border); border-radius: 0.375rem; background: var(--beui-background); color: var(--beui-foreground); font: inherit; }
</style><script lang="ts">
export const toolResultMessages = { running: 'Running', success: 'Completed', error: 'Failed', cancelled: 'Cancelled', copy: 'Copy result', copied: 'Copied', retry: 'Run again' }
export type ToolResultStatus = 'running' | 'success' | 'error' | 'cancelled'
export type ToolResultKind = 'terminal' | 'request' | 'custom'
</script>
<script setup lang="ts">
import { motion } from 'motion-v'
import { useReducedMotion } from '../core/reduced-motion'
import { computed, onBeforeUnmount, useId, useTemplateRef, watch } from 'vue'
import { pressSpring, swapSpring } from '../core/motion'
import { useOpenState } from '../primitives/state'
import AgentIcon from './AgentIcon.vue'
import AgentReveal from './AgentReveal.vue'
import AgentRollText from './AgentRollText.vue'
import './agent-tokens.css'
import { useCopy, useHasListener, type Labels } from './shared'
const props = withDefaults(defineProps<{
tool: string, title: string, meta?: string, status?: ToolResultStatus, kind?: ToolResultKind,
open?: boolean, defaultOpen?: boolean, collapseOnComplete?: boolean, maxHeight?: number, copyText?: string,
/** Overrides the built-in clipboard action. */
onCopy?: () => void | Promise<void>, labels?: Labels, contentClassName?: string
}>(), { status: 'running', kind: 'custom', open: undefined, defaultOpen: true, collapseOnComplete: true, maxHeight: 220 })
const emit = defineEmits<{ 'update:open': [value: boolean], openChange: [value: boolean], retry: [] }>()
defineSlots<{ default?(): unknown, icon?(): unknown }>()
// The retry action only shows when a listener is bound, like upstream's optional `onRetry`.
const hasRetry = useHasListener('retry')
const reduce = useReducedMotion()
const { open, setOpen } = useOpenState(() => props.open, props.defaultOpen, next => { emit('update:open', next); emit('openChange', next) })
const { copied, copy } = useCopy()
const uid = useId()
const viewport = useTemplateRef<HTMLElement>('viewport')
const running = computed(() => props.status === 'running')
const canCopy = computed(() => Boolean(props.copyText || props.onCopy))
const t = (key: keyof typeof toolResultMessages) => props.labels?.[key] ?? toolResultMessages[key]
const statusLabel = computed(() => t(props.status))
const kindIcon = computed(() => props.kind === 'terminal' ? 'SquareTerminal' : props.kind === 'request' ? 'Braces' : 'Wrench')
const statusIcon = computed(() => ({ running: 'LoaderCircle', success: 'CircleCheck', error: 'CircleX', cancelled: 'Ban' } as const)[props.status])
watch(() => props.status, (next, previous) => {
if (previous !== 'running' && next === 'running') setOpen(true)
if (previous === 'running' && next !== 'running' && props.collapseOnComplete) setOpen(false)
})
let frame = 0
watch(() => [props.status, open.value] as const, scrollDown, { flush: 'post' })
// The slot content is opaque, so follow every update while the tool is running.
function scrollDown() {
cancelAnimationFrame(frame)
if (!open.value || !running.value) return
frame = requestAnimationFrame(() => viewport.value?.scrollTo({ top: viewport.value.scrollHeight, behavior: reduce.value ? 'auto' : 'smooth' }))
}
let observer: MutationObserver | undefined
watch(viewport, element => {
observer?.disconnect()
if (!element || typeof MutationObserver === 'undefined') return
observer = new MutationObserver(scrollDown)
observer.observe(element, { childList: true, subtree: true, characterData: true })
}, { flush: 'post' })
onBeforeUnmount(() => { cancelAnimationFrame(frame); observer?.disconnect() })
</script>
<template>
<div class="be-ag be-tr" :data-state="status" :aria-busy="running">
<button :id="`${uid}-trigger`" type="button" class="be-tr-trigger" :aria-expanded="open" :aria-controls="`${uid}-content`" @click="setOpen(!open)">
<span aria-hidden="true" class="be-tr-icon"><slot name="icon"><AgentIcon :name="kindIcon" :size="16" /></slot></span>
<span class="be-tr-text">
<span class="be-tr-title"><AgentRollText :value="title">{{ title }}</AgentRollText></span>
<span v-if="meta" class="be-tr-meta"><AgentRollText :value="meta">{{ meta }}</AgentRollText></span>
<span class="be-tr-tool"><AgentRollText :value="tool">{{ tool }}</AgentRollText></span>
</span>
<span class="be-tr-status" :data-status="status"><AgentIcon :name="statusIcon" :size="12" :class="{ 'be-ag-spin': running && !reduce }" /><AgentRollText :value="status">{{ statusLabel }}</AgentRollText></span>
<motion.span aria-hidden="true" class="be-tr-chevron" :animate="{ rotate: open ? 180 : 0 }" :transition="reduce ? { duration: 0 } : swapSpring"><AgentIcon name="ChevronDown" :size="14" /></motion.span>
</button>
<AgentReveal :id="`${uid}-content`" role="region" :aria-labelledby="`${uid}-trigger`" :open="open">
<div class="be-tr-indent">
<div class="be-tr-card">
<div ref="viewport" role="log" aria-live="polite" class="be-tr-viewport be-ag-hide-scroll" :style="{ maxHeight: `${maxHeight}px` }"><div class="be-tr-content" :class="contentClassName"><slot /></div></div>
<div v-if="canCopy || hasRetry()" class="be-tr-foot">
<motion.button v-if="canCopy" type="button" class="be-tr-action" :aria-label="copied ? t('copied') : t('copy')" :title="copied ? t('copied') : t('copy')" :while-press="reduce ? undefined : { scale: 0.9 }" :transition="pressSpring" @click="copy(copyText ?? '', onCopy)"><AgentIcon :name="copied ? 'Check' : 'Copy'" :size="14" /></motion.button>
<motion.button v-if="hasRetry()" type="button" class="be-tr-action" :aria-label="t('retry')" :title="t('retry')" :while-press="reduce ? undefined : { scale: 0.9 }" :transition="pressSpring" @click="emit('retry')"><AgentIcon name="RotateCcw" :size="14" /></motion.button>
<span class="be-tr-foot-status"><AgentRollText :value="status">{{ statusLabel }}</AgentRollText></span>
</div>
</div>
</div>
</AgentReveal>
</div>
</template>
<style scoped>
.be-tr { box-sizing: border-box; width: 100%; font-size: 0.875rem; line-height: 1.25rem; color: var(--beui-foreground); }
.be-tr-trigger { display: flex; box-sizing: border-box; min-height: 2.25rem; width: 100%; align-items: center; gap: 0.5rem; padding: 0.25rem 0; border: 0; border-radius: 0.375rem; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; outline: none; }
.be-tr-trigger:focus-visible { box-shadow: 0 0 0 2px var(--beui-background), 0 0 0 4px var(--beui-ring); }
.be-tr-icon { display: grid; flex: none; width: 1rem; height: 1rem; place-items: center; color: var(--beui-muted-foreground); }
.be-tr-text { display: flex; min-width: 0; flex: 1; align-items: baseline; gap: 0.5rem; }
.be-tr-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; color: color-mix(in srgb, var(--beui-foreground) 90%, transparent); }
.be-tr-meta { flex: none; font-size: 0.75rem; line-height: 1rem; color: color-mix(in srgb, var(--beui-muted-foreground) 60%, transparent); }
.be-tr-tool { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono, ui-monospace, monospace); font-size: 11px; line-height: calc(1.25 / .875); color: color-mix(in srgb, var(--beui-muted-foreground) 55%, transparent); }
.be-tr-status { display: inline-flex; flex: none; align-items: center; gap: 0.25rem; font-size: 11px; line-height: calc(1.25 / .875); font-weight: 500; color: var(--beui-muted-foreground); }
.be-tr-status[data-status=running] { color: var(--ag-blue); }
.be-tr-status[data-status=success] { color: var(--ag-green); }
.be-tr-status[data-status=error] { color: var(--ag-rose); }
.be-tr-chevron { display: inline-flex; flex: none; color: color-mix(in srgb, var(--beui-muted-foreground) 50%, transparent); transition: color 0.15s; }
.be-tr-trigger:hover .be-tr-chevron { color: var(--beui-muted-foreground); }
.be-tr-indent { padding: 0.375rem 0 0 1.5rem; }
.be-tr-card { overflow: hidden; border-radius: 0.75rem; background: color-mix(in srgb, var(--beui-muted) 80%, transparent); }
.be-tr-viewport { overflow-y: auto; }
.be-tr-content { padding: 0.75rem; }
.be-tr-foot { display: flex; align-items: center; gap: 0.125rem; padding: 0 0.5rem 0.375rem; }
.be-tr-action { display: grid; width: 1.75rem; height: 1.75rem; place-items: center; padding: 0; border: 0; border-radius: 0.375rem; background: transparent; color: var(--beui-muted-foreground); cursor: pointer; outline: none; transition: color 0.15s, background-color 0.15s; }
.be-tr-action:hover { background: var(--beui-muted); color: var(--beui-foreground); }
.be-tr-action:focus-visible { box-shadow: 0 0 0 2px var(--beui-ring); }
.be-tr-foot-status { margin-inline-start: auto; font-size: 11px; line-height: calc(1.25 / .875); color: color-mix(in srgb, var(--beui-muted-foreground) 55%, transparent); }
</style>API Reference
ToolResultOutput
language?stringbashclass?string—code?string—ToolResult
toolstring—titlestring—status?ToolResultStatusrunningkind?ToolResultKindcustommeta?string—#icon?slot—v-model:open?booleanundefineddefaultOpen?booleantruecollapseOnComplete?booleantruemaxHeight?number220copyText?string—onCopy?() => void | Promise<void>Overrides the built-in clipboard action.
—@retry?() => void—labels?LabelsOverride any built-in string.
—class?string—contentClassName?string—@open-change?(value: boolean) => void—#default?slot—Install
Add it with your package manager, or copy the source manually.
Run it in a project set up with shadcn-vue. The source is copied to components/beui and its dependencies are added to your package.json. Read the shadcn-vue guide
$ bunx --bun shadcn-vue@latest add @beui-vue/tool-result$ bun add beui-vueDownload the release archive to your project root, then install the local file.
$ bun add ./beui-vue-0.1.0.tgzImport the shared styles once in your application.
import ToolResult from '@/components/beui/agents/ToolResult.vue'
import '@/components/beui/styles.css'Composition
Use the output primitive for terminal text, request details, generated code, or another structured result.
ToolResult
└── ToolResultOutputNote: Tool Approval collects permission before the execution begins. Code Block renders highlighted code returned by a tool. Agent Activity summarizes the tool invocation within a longer run.
How it works
A tool result is evidence from an execution, not another chat bubble. It should connect a compact run summary to the output needed for inspection, recovery, or reuse.
Related components
File Diff
A syntax-highlighted file change disclosure with progressive rows, line numbers, live change counts, smooth following, and completion collapse.
Code Block
A syntax-highlighted code surface with stable streaming updates, line numbers, focused lines, smooth following, and copy feedback.
Todo List
A collapsible agent task plan with morphing status marks, a completion count, compact metadata, and smooth list updates.
Updated