feat(webui): draw each transcript entry with its Trace pattern (#1718)
Quality / check (pull_request) Successful in 3m38s
Quality / check (pull_request) Successful in 3m38s
Record the model's reasoning parts. The step run view shows reasoning as a Thought row, shell calls as a terminal, the gate as a test run, web_fetch as a source, finish as the verdict, and each fan-out branch as a subagent.
This commit is contained in:
5 files changed
+254
-113
No files matched your search
@@ -61,6 +61,7 @@ func (t *transcript) ModelCallFinished(_ context.Context, req chat.Request, resp
|
||||
}
|
||||
if resp != nil {
|
||||
entry.Text = clip(resp.Content, &entry.TextBytes)
|
||||
entry.Reasoning = clip(reasoning(resp.Parts), &entry.ReasoningBytes)
|
||||
entry.FinishReason = resp.FinishReason
|
||||
for _, call := range resp.ToolCalls {
|
||||
recorded := agentrun.TranscriptToolCall{ID: call.ID, Name: call.Name}
|
||||
@@ -130,6 +131,16 @@ func (t *transcript) AfterToolExecute(_ context.Context, call core.ToolCall, res
|
||||
t.add(entry)
|
||||
}
|
||||
|
||||
func reasoning(parts chat.Parts) string {
|
||||
var texts []string
|
||||
for _, part := range parts {
|
||||
if thought, ok := part.(chat.ReasoningPart); ok && thought.Text != "" {
|
||||
texts = append(texts, thought.Text)
|
||||
}
|
||||
}
|
||||
return strings.Join(texts, "\n\n")
|
||||
}
|
||||
|
||||
func isCompaction(req chat.Request) bool {
|
||||
n := len(req.Messages)
|
||||
return n > 0 && req.Messages[n-1].Role == chat.RoleUser && strings.HasPrefix(req.Messages[n-1].Content, compactionPrefix)
|
||||
|
||||
@@ -45,7 +45,7 @@ func (r Reporter) ReportTranscript(entry TranscriptEntry) {
|
||||
const (
|
||||
TranscriptSystem = "system" // Text: the system prompt
|
||||
TranscriptUser = "user" // Text: the mission, or input the loop added later
|
||||
TranscriptModel = "model" // Text and ToolCalls: one model response
|
||||
TranscriptModel = "model" // Reasoning, Text and ToolCalls: one model response
|
||||
TranscriptTool = "tool" // one tool call's arguments and result
|
||||
TranscriptCompaction = "compaction" // Text: the summary that replaced the history
|
||||
)
|
||||
@@ -60,6 +60,9 @@ type TranscriptEntry struct {
|
||||
TextBytes int `json:"text_bytes,omitempty"`
|
||||
ToolCalls []TranscriptToolCall `json:"tool_calls,omitempty"`
|
||||
|
||||
Reasoning string `json:"reasoning,omitempty"`
|
||||
ReasoningBytes int `json:"reasoning_bytes,omitempty"`
|
||||
|
||||
CallID string `json:"call_id,omitempty"`
|
||||
Tool string `json:"tool,omitempty"`
|
||||
Args string `json:"args,omitempty"`
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { CircleAlertIcon, CircleCheckIcon, FoldVerticalIcon, ScrollTextIcon, SparklesIcon, TargetIcon } from "@lucide/vue";
|
||||
import { BotIcon, BrainIcon, CircleAlertIcon, FoldVerticalIcon, ScrollTextIcon, SparklesIcon, TargetIcon } from "@lucide/vue";
|
||||
import { createReusableTemplate } from "@vueuse/core";
|
||||
import { computed, onUnmounted, ref, watch } from "vue";
|
||||
|
||||
import { Bubble, BubbleContent } from "@/components/ui/bubble";
|
||||
@@ -22,34 +23,21 @@ import { api } from "@/lib/api";
|
||||
import { useLiveResource } from "@/stores/session";
|
||||
import { duration } from "@/tasks/timeline-event";
|
||||
import type { TaskEvent } from "@/tasks/task-run";
|
||||
import TranscriptTool from "./TranscriptTool.vue";
|
||||
import { withClip, type TranscriptEntry as Entry } from "./transcript";
|
||||
|
||||
/** One step's agent conversations for one attempt, oldest first. */
|
||||
const props = defineProps<{ taskId: number | string; attempt: number; match: (event: TaskEvent) => boolean; running: boolean }>();
|
||||
|
||||
interface Usage { prompt_tokens?: number; completion_tokens?: number; cached_tokens?: number }
|
||||
interface Entry {
|
||||
seq: number;
|
||||
kind: string;
|
||||
text?: string;
|
||||
text_bytes?: number;
|
||||
tool_calls?: { id?: string; name: string }[];
|
||||
call_id?: string;
|
||||
tool?: string;
|
||||
args?: string;
|
||||
args_bytes?: number;
|
||||
output?: string;
|
||||
output_bytes?: number;
|
||||
error?: string;
|
||||
finish_reason?: string;
|
||||
usage?: Usage;
|
||||
latency_ms?: number;
|
||||
}
|
||||
interface Step { model: Entry; tools: Entry[] }
|
||||
type Row =
|
||||
| { kind: "prompt"; title: string; entry: Entry }
|
||||
| { kind: "user"; entry: Entry }
|
||||
| { kind: "compaction"; entry: Entry }
|
||||
| { kind: "step"; number: number; step: Step };
|
||||
interface Conversation { key: string; label: string; rows: Row[]; steps: number; tools: number; failed: number }
|
||||
|
||||
const [DefineConversation, ConversationView] = createReusableTemplate<{ conversation: Conversation }>();
|
||||
|
||||
const events = ref<TaskEvent[]>();
|
||||
const failed = ref(false);
|
||||
@@ -76,11 +64,6 @@ watch(() => props.running, (running) => {
|
||||
useLiveResource("tasks", () => void load(), 1000);
|
||||
onUnmounted(() => { generation++; clearInterval(timer); });
|
||||
|
||||
function withClip(text: string | undefined, bytes: number | undefined): string {
|
||||
if (!bytes) return text ?? "";
|
||||
return `${text ?? ""}\n… clipped, ${(bytes / 1024).toFixed(1)} KB in full`;
|
||||
}
|
||||
|
||||
function usage(entry: Entry): string {
|
||||
const u = entry.usage;
|
||||
const parts = [];
|
||||
@@ -91,48 +74,38 @@ function usage(entry: Entry): string {
|
||||
return parts.join(" · ");
|
||||
}
|
||||
|
||||
// The row names the call by its main value, as "read src/main.go" rather than
|
||||
// its JSON: the first string argument, else nothing.
|
||||
function argument(entry: Entry): string {
|
||||
try {
|
||||
const args: unknown = JSON.parse(entry.args ?? "");
|
||||
if (args && typeof args === "object" && !Array.isArray(args)) {
|
||||
const first = Object.values(args).find((v) => typeof v === "string" && v);
|
||||
if (typeof first === "string") return first.split("\n", 1)[0] ?? "";
|
||||
}
|
||||
} catch {
|
||||
// Clipped or not JSON.
|
||||
}
|
||||
return "";
|
||||
function plural(n: number, word: string): string {
|
||||
return `${n} ${word}${n === 1 ? "" : "s"}`;
|
||||
}
|
||||
|
||||
// Tool results sit under the step whose response asked for them.
|
||||
function rows(entries: Entry[]): Row[] {
|
||||
const out: Row[] = [];
|
||||
function conversation(key: string, label: string, entries: Entry[]): Conversation {
|
||||
const rows: Row[] = [];
|
||||
const owner = new Map<string, Step>();
|
||||
let prompted = false;
|
||||
let steps = 0;
|
||||
for (const entry of entries) {
|
||||
if (entry.kind === "system") out.push({ kind: "prompt", title: "System prompt", entry });
|
||||
if (entry.kind === "system") rows.push({ kind: "prompt", title: "System prompt", entry });
|
||||
else if (entry.kind === "user") {
|
||||
out.push(prompted ? { kind: "user", entry } : { kind: "prompt", title: "Mission", entry });
|
||||
rows.push(prompted ? { kind: "user", entry } : { kind: "prompt", title: "Mission", entry });
|
||||
prompted = true;
|
||||
} else if (entry.kind === "compaction") out.push({ kind: "compaction", entry });
|
||||
} else if (entry.kind === "compaction") rows.push({ kind: "compaction", entry });
|
||||
else if (entry.kind === "model") {
|
||||
const step: Step = { model: entry, tools: [] };
|
||||
for (const call of entry.tool_calls ?? []) if (call.id) owner.set(call.id, step);
|
||||
out.push({ kind: "step", number: ++steps, step });
|
||||
rows.push({ kind: "step", number: ++steps, step });
|
||||
} else if (entry.kind === "tool") {
|
||||
const step = entry.call_id ? owner.get(entry.call_id) : undefined;
|
||||
if (step) step.tools.push(entry);
|
||||
else out.push({ kind: "step", number: ++steps, step: { model: { seq: entry.seq, kind: "model" }, tools: [entry] } });
|
||||
else rows.push({ kind: "step", number: ++steps, step: { model: { seq: entry.seq, kind: "model" }, tools: [entry] } });
|
||||
}
|
||||
}
|
||||
return out;
|
||||
const tools = entries.filter((entry) => entry.kind === "tool");
|
||||
return { key, label, rows, steps, tools: tools.length, failed: tools.filter((tool) => tool.error).length };
|
||||
}
|
||||
|
||||
// A step can hold several agents (parallel branches, retries); each keeps its
|
||||
// own conversation, numbered from 1.
|
||||
// Each agent in the step (a fan-out branch, or a retry) keeps its own
|
||||
// conversation, numbered from 1.
|
||||
const conversations = computed(() => {
|
||||
const byAgent = new Map<string, Entry[][]>();
|
||||
for (const event of (events.value ?? []).filter(props.match)) {
|
||||
@@ -143,76 +116,85 @@ const conversations = computed(() => {
|
||||
runs.at(-1)!.push(entry);
|
||||
byAgent.set(key, runs);
|
||||
}
|
||||
return [...byAgent.entries()].flatMap(([label, runs]) => runs.map((entries, i) => ({ key: `${label}#${i}`, label, rows: rows(entries) })));
|
||||
return [...byAgent.entries()].flatMap(([label, runs]) => runs.map((entries, i) => conversation(`${label}#${i}`, label, entries)));
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DefineConversation v-slot="{ conversation: c }">
|
||||
<div class="flex flex-col gap-4">
|
||||
<template v-for="row in c.rows" :key="`${row.kind}-${row.kind === 'step' ? row.number : row.entry.seq}`">
|
||||
<Trace v-if="row.kind === 'prompt' || row.kind === 'compaction'">
|
||||
<TraceCollapsible>
|
||||
<TraceCollapsibleTrigger>
|
||||
<TraceLine>
|
||||
<TraceIcon>
|
||||
<FoldVerticalIcon v-if="row.kind === 'compaction'" />
|
||||
<TargetIcon v-else-if="row.title === 'Mission'" />
|
||||
<ScrollTextIcon v-else />
|
||||
</TraceIcon>
|
||||
<TraceTitle>{{ row.kind === 'compaction' ? 'Compacted the history' : row.title }}</TraceTitle>
|
||||
<TraceDescription v-if="row.kind === 'compaction' && usage(row.entry)">{{ usage(row.entry) }}</TraceDescription>
|
||||
</TraceLine>
|
||||
</TraceCollapsibleTrigger>
|
||||
<TraceCollapsibleContent>
|
||||
<CodeBlock size="sm">
|
||||
<CodeBlockContent wrap class="max-h-96">{{ withClip(row.entry.text || row.entry.error, row.entry.text_bytes) }}</CodeBlockContent>
|
||||
</CodeBlock>
|
||||
</TraceCollapsibleContent>
|
||||
</TraceCollapsible>
|
||||
</Trace>
|
||||
<Message v-else-if="row.kind === 'user'" align="end">
|
||||
<MessageContent>
|
||||
<Bubble align="end" variant="muted">
|
||||
<BubbleContent class="whitespace-pre-wrap [overflow-wrap:anywhere]">{{ withClip(row.entry.text, row.entry.text_bytes) }}</BubbleContent>
|
||||
</Bubble>
|
||||
</MessageContent>
|
||||
</Message>
|
||||
<Message v-else>
|
||||
<MessageContent class="gap-2">
|
||||
<Trace v-if="row.step.model.reasoning">
|
||||
<TraceCollapsible>
|
||||
<TraceCollapsibleTrigger>
|
||||
<TraceLine>
|
||||
<TraceIcon><BrainIcon /></TraceIcon>
|
||||
<TraceTitle>Thought</TraceTitle>
|
||||
</TraceLine>
|
||||
</TraceCollapsibleTrigger>
|
||||
<TraceCollapsibleContent class="whitespace-pre-wrap">{{ withClip(row.step.model.reasoning, row.step.model.reasoning_bytes) }}</TraceCollapsibleContent>
|
||||
</TraceCollapsible>
|
||||
</Trace>
|
||||
<ChatMarkdown v-if="row.step.model.text" :text="withClip(row.step.model.text, row.step.model.text_bytes)" />
|
||||
<Trace>
|
||||
<TraceLine :status="row.step.model.error ? 'error' : undefined">
|
||||
<TraceIcon><CircleAlertIcon v-if="row.step.model.error" /><SparklesIcon v-else /></TraceIcon>
|
||||
<TraceTitle>{{ row.step.model.error ? `Step ${row.number} failed: ${row.step.model.error}` : `Step ${row.number}` }}</TraceTitle>
|
||||
<TraceDescription v-if="usage(row.step.model)">{{ usage(row.step.model) }}</TraceDescription>
|
||||
</TraceLine>
|
||||
<TranscriptTool v-for="tool in row.step.tools" :key="tool.seq" :tool="tool" />
|
||||
</Trace>
|
||||
</MessageContent>
|
||||
</Message>
|
||||
</template>
|
||||
</div>
|
||||
</DefineConversation>
|
||||
|
||||
<p v-if="failed" role="alert" class="text-danger">Could not load the transcript</p>
|
||||
<Spinner v-else-if="!events" />
|
||||
<Empty v-else-if="!conversations.length"><EmptyHeader><EmptyTitle>No transcript recorded</EmptyTitle></EmptyHeader></Empty>
|
||||
<div v-for="conversation in conversations" :key="conversation.key" class="flex flex-col gap-4">
|
||||
<h4 v-if="conversations.length > 1" class="font-mono text-xs">{{ conversation.label }}</h4>
|
||||
<template v-for="row in conversation.rows" :key="`${row.kind}-${row.kind === 'step' ? row.number : row.entry.seq}`">
|
||||
<Trace v-if="row.kind === 'prompt' || row.kind === 'compaction'">
|
||||
<TraceCollapsible>
|
||||
<TraceCollapsibleTrigger>
|
||||
<TraceLine>
|
||||
<TraceIcon>
|
||||
<FoldVerticalIcon v-if="row.kind === 'compaction'" />
|
||||
<TargetIcon v-else-if="row.title === 'Mission'" />
|
||||
<ScrollTextIcon v-else />
|
||||
</TraceIcon>
|
||||
<TraceTitle>{{ row.kind === 'compaction' ? 'Compacted the history' : row.title }}</TraceTitle>
|
||||
<TraceDescription v-if="row.kind === 'compaction' && usage(row.entry)">{{ usage(row.entry) }}</TraceDescription>
|
||||
</TraceLine>
|
||||
</TraceCollapsibleTrigger>
|
||||
<TraceCollapsibleContent>
|
||||
<CodeBlock size="sm">
|
||||
<CodeBlockContent wrap class="max-h-96">{{ withClip(row.entry.text || row.entry.error, row.entry.text_bytes) }}</CodeBlockContent>
|
||||
</CodeBlock>
|
||||
</TraceCollapsibleContent>
|
||||
</TraceCollapsible>
|
||||
</Trace>
|
||||
<Message v-else-if="row.kind === 'user'" align="end">
|
||||
<MessageContent>
|
||||
<Bubble align="end" variant="muted">
|
||||
<BubbleContent class="whitespace-pre-wrap [overflow-wrap:anywhere]">{{ withClip(row.entry.text, row.entry.text_bytes) }}</BubbleContent>
|
||||
</Bubble>
|
||||
</MessageContent>
|
||||
</Message>
|
||||
<Message v-else>
|
||||
<MessageContent class="gap-2">
|
||||
<ChatMarkdown v-if="row.step.model.text" :text="withClip(row.step.model.text, row.step.model.text_bytes)" />
|
||||
<Trace>
|
||||
<TraceLine :status="row.step.model.error ? 'error' : undefined">
|
||||
<TraceIcon><CircleAlertIcon v-if="row.step.model.error" /><SparklesIcon v-else /></TraceIcon>
|
||||
<TraceTitle>{{ row.step.model.error ? `Step ${row.number} failed: ${row.step.model.error}` : `Step ${row.number}` }}</TraceTitle>
|
||||
<TraceDescription v-if="usage(row.step.model)">{{ usage(row.step.model) }}</TraceDescription>
|
||||
</TraceLine>
|
||||
<TraceCollapsible v-for="tool in row.step.tools" :key="tool.seq" :default-open="!!tool.error">
|
||||
<TraceCollapsibleTrigger>
|
||||
<TraceLine :status="tool.error ? 'error' : undefined">
|
||||
<TraceIcon><CircleAlertIcon v-if="tool.error" /><CircleCheckIcon v-else /></TraceIcon>
|
||||
<TraceTitle>{{ tool.error ? 'Failed to run' : 'Ran' }} <span class="font-mono">{{ tool.tool }}</span> {{ argument(tool) }}</TraceTitle>
|
||||
<TraceDescription v-if="tool.latency_ms">{{ duration(tool.latency_ms) }}</TraceDescription>
|
||||
</TraceLine>
|
||||
</TraceCollapsibleTrigger>
|
||||
<TraceCollapsibleContent class="flex flex-col gap-2">
|
||||
<CodeBlock size="sm">
|
||||
<CodeBlockContent wrap class="max-h-48">{{ withClip(tool.args, tool.args_bytes) }}</CodeBlockContent>
|
||||
</CodeBlock>
|
||||
<CodeBlock v-if="tool.error" size="sm" variant="destructive">
|
||||
<CodeBlockContent wrap class="max-h-64">{{ tool.error }}</CodeBlockContent>
|
||||
</CodeBlock>
|
||||
<CodeBlock v-if="tool.output || !tool.error" size="sm">
|
||||
<CodeBlockContent wrap class="max-h-64">{{ withClip(tool.output, tool.output_bytes) }}</CodeBlockContent>
|
||||
</CodeBlock>
|
||||
</TraceCollapsibleContent>
|
||||
</TraceCollapsible>
|
||||
</Trace>
|
||||
</MessageContent>
|
||||
</Message>
|
||||
</template>
|
||||
</div>
|
||||
<ConversationView v-else-if="conversations.length === 1" :conversation="conversations[0]!" />
|
||||
<Trace v-else>
|
||||
<TraceCollapsible v-for="c in conversations" :key="c.key">
|
||||
<TraceCollapsibleTrigger>
|
||||
<TraceLine :status="c.failed ? 'error' : undefined">
|
||||
<TraceIcon><BotIcon /></TraceIcon>
|
||||
<TraceTitle class="font-mono">{{ c.label }}</TraceTitle>
|
||||
<TraceDescription>{{ plural(c.steps, 'step') }} · {{ plural(c.tools, 'tool call') }}{{ c.failed ? `, ${c.failed} failed` : '' }}</TraceDescription>
|
||||
</TraceLine>
|
||||
</TraceCollapsibleTrigger>
|
||||
<TraceCollapsibleContent>
|
||||
<ConversationView :conversation="c" />
|
||||
</TraceCollapsibleContent>
|
||||
</TraceCollapsible>
|
||||
</Trace>
|
||||
</template>
|
||||
@@ -0,0 +1,119 @@
|
||||
<script setup lang="ts">
|
||||
import { ArrowUpRightIcon, CircleAlertIcon, CircleCheckIcon, FlagIcon, FlaskConicalIcon, GlobeIcon, SquareTerminalIcon } from "@lucide/vue";
|
||||
import { computed } from "vue";
|
||||
|
||||
import { CodeBlock, CodeBlockContent } from "@/components/ui/code-block";
|
||||
import {
|
||||
Trace,
|
||||
TraceCollapsible,
|
||||
TraceCollapsibleContent,
|
||||
TraceCollapsibleTrigger,
|
||||
TraceDescription,
|
||||
TraceIcon,
|
||||
TraceLine,
|
||||
TraceTitle,
|
||||
} from "@/components/ui/trace";
|
||||
import { duration } from "@/tasks/timeline-event";
|
||||
import { withClip, type TranscriptEntry } from "./transcript";
|
||||
|
||||
/**
|
||||
* One tool call, drawn as the Trace pattern its tool calls for: a shell
|
||||
* command as a terminal, the gate as a test run, a fetch as a source, finish
|
||||
* as the run's own verdict, anything else as input then output.
|
||||
*/
|
||||
const props = defineProps<{ tool: TranscriptEntry }>();
|
||||
|
||||
const args = computed<Record<string, unknown>>(() => {
|
||||
try {
|
||||
const parsed: unknown = JSON.parse(props.tool.args ?? "");
|
||||
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed as Record<string, unknown> : {};
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
});
|
||||
const failed = computed(() => !!props.tool.error);
|
||||
const kind = computed(() => {
|
||||
switch (props.tool.tool) {
|
||||
case "shell": return "terminal";
|
||||
case "check": return "tests";
|
||||
case "web_fetch": return "source";
|
||||
case "finish": return "finish";
|
||||
default: return "tool";
|
||||
}
|
||||
});
|
||||
const command = computed(() => String(args.value.command ?? ""));
|
||||
const url = computed(() => String(args.value.url ?? ""));
|
||||
const host = computed(() => {
|
||||
try {
|
||||
return new URL(url.value).hostname;
|
||||
} catch {
|
||||
return url.value;
|
||||
}
|
||||
});
|
||||
// The row names a plain call by its main value, as "read src/main.go" rather
|
||||
// than its JSON: the first string argument.
|
||||
const argument = computed(() => {
|
||||
const first = Object.values(args.value).find((v) => typeof v === "string" && v);
|
||||
return typeof first === "string" ? first.split("\n", 1)[0] : "";
|
||||
});
|
||||
const title = computed(() => {
|
||||
switch (kind.value) {
|
||||
case "terminal": return `${failed.value ? "Failed to run" : "Ran"} ${command.value.split("\n", 1)[0]}`;
|
||||
case "tests": return failed.value ? "Gate failed" : "Ran the gate";
|
||||
case "source": return `${failed.value ? "Failed to read" : "Read"} ${host.value}`;
|
||||
case "finish": return `Finished as ${String(args.value.status ?? "unknown")}`;
|
||||
default: return `${failed.value ? "Failed to run" : "Ran"} ${props.tool.tool} ${argument.value}`;
|
||||
}
|
||||
});
|
||||
const output = computed(() => withClip(props.tool.output, props.tool.output_bytes));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TraceCollapsible :default-open="failed">
|
||||
<TraceCollapsibleTrigger>
|
||||
<TraceLine :status="failed ? 'error' : undefined">
|
||||
<TraceIcon>
|
||||
<CircleAlertIcon v-if="failed" />
|
||||
<SquareTerminalIcon v-else-if="kind === 'terminal'" />
|
||||
<FlaskConicalIcon v-else-if="kind === 'tests'" />
|
||||
<GlobeIcon v-else-if="kind === 'source'" />
|
||||
<FlagIcon v-else-if="kind === 'finish'" />
|
||||
<CircleCheckIcon v-else />
|
||||
</TraceIcon>
|
||||
<TraceTitle :class="kind === 'terminal' && 'font-mono'">{{ title }}</TraceTitle>
|
||||
<TraceDescription v-if="tool.latency_ms">{{ duration(tool.latency_ms) }}</TraceDescription>
|
||||
</TraceLine>
|
||||
</TraceCollapsibleTrigger>
|
||||
<TraceCollapsibleContent class="flex flex-col gap-2">
|
||||
<template v-if="kind === 'terminal'">
|
||||
<CodeBlock size="sm" :variant="failed ? 'destructive' : 'default'">
|
||||
<CodeBlockContent wrap class="max-h-64 font-mono">$ {{ command }}
|
||||
{{ output }}{{ tool.error ? `\n${tool.error}` : '' }}</CodeBlockContent>
|
||||
</CodeBlock>
|
||||
</template>
|
||||
<template v-else-if="kind === 'finish'">
|
||||
<p class="whitespace-pre-wrap">{{ String(args.summary ?? '') }}</p>
|
||||
</template>
|
||||
<template v-else>
|
||||
<Trace v-if="kind === 'source' && url">
|
||||
<a :href="url" target="_blank" rel="noreferrer">
|
||||
<TraceLine>
|
||||
<TraceIcon><GlobeIcon /></TraceIcon>
|
||||
<TraceTitle>{{ url }}<span class="sr-only"> (opens in a new tab)</span></TraceTitle>
|
||||
<TraceIcon><ArrowUpRightIcon /></TraceIcon>
|
||||
</TraceLine>
|
||||
</a>
|
||||
</Trace>
|
||||
<CodeBlock v-if="kind === 'tool'" size="sm">
|
||||
<CodeBlockContent wrap class="max-h-48">{{ withClip(tool.args, tool.args_bytes) }}</CodeBlockContent>
|
||||
</CodeBlock>
|
||||
<CodeBlock v-if="tool.error" size="sm" variant="destructive">
|
||||
<CodeBlockContent wrap class="max-h-64">{{ tool.error }}</CodeBlockContent>
|
||||
</CodeBlock>
|
||||
<CodeBlock v-if="tool.output || !tool.error" size="sm">
|
||||
<CodeBlockContent wrap class="max-h-64">{{ output }}</CodeBlockContent>
|
||||
</CodeBlock>
|
||||
</template>
|
||||
</TraceCollapsibleContent>
|
||||
</TraceCollapsible>
|
||||
</template>
|
||||
@@ -0,0 +1,26 @@
|
||||
/** One agent_transcript entry, as the State Store records it. */
|
||||
export interface TranscriptEntry {
|
||||
seq: number;
|
||||
kind: string;
|
||||
text?: string;
|
||||
text_bytes?: number;
|
||||
reasoning?: string;
|
||||
reasoning_bytes?: number;
|
||||
tool_calls?: { id?: string; name: string }[];
|
||||
call_id?: string;
|
||||
tool?: string;
|
||||
args?: string;
|
||||
args_bytes?: number;
|
||||
output?: string;
|
||||
output_bytes?: number;
|
||||
error?: string;
|
||||
finish_reason?: string;
|
||||
usage?: { prompt_tokens?: number; completion_tokens?: number; cached_tokens?: number };
|
||||
latency_ms?: number;
|
||||
}
|
||||
|
||||
/** The text as recorded, with a note when it was clipped. */
|
||||
export function withClip(text: string | undefined, bytes: number | undefined): string {
|
||||
if (!bytes) return text ?? "";
|
||||
return `${text ?? ""}\n… clipped, ${(bytes / 1024).toFixed(1)} KB in full`;
|
||||
}
|
||||
Reference in new issue
Block a user