AI Elements

Terminal

Displays a command the agent runs, with its output as it streams.

Run the checks, then build the app.
> acme-chat@0.1.0 build
> nuxt build

Nuxt 4.2.0 with Nitro 2.12.0
ℹ Building client...
✔ Client built in 4210ms
ℹ Building server...
✔ Server built in 1180ms

✔ Generated public .output/public
├─ .output/server/chunks/routes/index.mjs (1.9 kB)
└─ .output/server/chunks/routes/api/chat.post.mjs (141 B)

Lint and tests pass, and the build compiled both routes.

Terminal is a shell command the agent runs, such as a lint, a test run or a build. The line shows the command, and its output streams in underneath while it runs.

Terminal is built with UiTrace with a UiTraceCollapsible for each command.

Installation

Terminal is built with the Trace and Code Block components.

Usage

<template>
  <UiTrace>
    <UiTraceCollapsible>
      <UiTraceCollapsibleTrigger>
        <UiTraceLine>
          <UiTraceIcon>
            <UiIcon name="lucide:terminal" />
          </UiTraceIcon>
          <UiTraceTitle>Ran pnpm build</UiTraceTitle>
        </UiTraceLine>
      </UiTraceCollapsibleTrigger>
      <UiTraceCollapsibleContent>
        <UiCodeBlock size="sm">
          <UiCodeBlockContent wrap class="max-h-64">
            {{ output }}
          </UiCodeBlockContent>
        </UiCodeBlock>
      </UiTraceCollapsibleContent>
    </UiTraceCollapsible>
  </UiTrace>
</template>

<script lang="ts" setup>
  defineProps<{ output: string }>();
</script>

Exit Code

A command that exits with any code other than 0 failed. Set status="error".

Ran pnpm install
> acme-chat@0.1.0 lint
> eslint .

server/api/chat.post.ts
  14:7  error  'model' is assigned a value but never used  no-unused-vars

components/Chat.vue
  42:5  error  'messages' is defined but never used  vue/no-unused-vars

✖ 2 problems (2 errors, 0 warnings)

 ELIFECYCLE  Command failed with exit code 1.
CommandstatusTitle
Running"running"Running pnpm build
Exited with 0noneRan pnpm build
Exited with another code"error"pnpm lint exited with code 1

The command is a tool call, so its states map the same way as in Tool.

Open While Running

Open the line once the first output arrives, so the output is visible while the command runs. Leave it open or closed after that, as in Trace.

AI SDK

A tool result arrives only once the command exits. To stream the output while it runs, write it from the tool as a data part with the tool call's id. The AI SDK replaces a data part that has the same id, so the output grows in place.

writer.write({
  type: "data-terminal",
  id: toolCallId,
  data: { output },
});

On the client, find the data part that matches each tool part.

function getOutput(message: ChatMessage, toolCallId: string) {
  for (const part of message.parts) {
    if (part.type === "data-terminal" && part.id === toolCallId) {
      return part.data.output;
    }
  }

  return "";
}

API Reference

See Trace.