module DotBotTranscript
The DotBot panel's transcript: a conversation's rows as the widget
tree one tab draws, rebuilt row by row. A row whose content has not
changed since the last draw is the same subtree it was, its callbacks
carried over, so a delta streaming into the last answer rebuilds that
answer and nothing above it. The newest rows are drawn and the rest wait
behind a "Show earlier messages" row, so what a redraw costs is set by
how much is on screen rather than by how long the conversation is.
imagePaths(text: string) → void
Every image path a tool result mentions.
`capture` writes a file and answers with its path — so a transcript that
only printed the path made the reader open the Files tab to see the shot
the agent just took. Matched on the extension rather than on the tool's
name, because several tools produce images and the reader wants all of
them.
| arg | type | description |
|---|
| text | string | |
readableArgs(args: any) → void
One argument table as lines a person reads, rather than the JSON it was
stored as.
The value is parsed — it arrives as JSON and has to be — but a raw object
printed back at the reader is the transcript showing its filing system
instead of what happened. A long value is cut, because the point of the row
is what the call WAS, and an argument carrying a whole file is answered by
opening the file.
| arg | type | description |
|---|
| args | any | |
scriptArg(args: any) → string
The program a carrier call was given, or nil for an ordinary tool call.
One argument named `script` and nothing else: that is what `tool_exec`
takes. A call with other arguments is an ordinary call and reads as one.
| arg | type | description |
|---|
| args | any | |
looksLikeMarkdown(text: string) → boolean
Whether a tool's answer is a written page rather than data.
Markers only, checked at the start of a line so a stray `#` inside a value
does not turn a data dump into a document: a heading, a bullet, a fence, or
bold anywhere. JSON is excluded outright — an object or array is data even
when a string inside it happens to contain a `*`.
| arg | type | description |
|---|
| text | string | |
millis(v: any) → string
A number of milliseconds as a person reads one.
traceLine(record: any) → string
One record of a tool answer's trace as the line a person reads.
| arg | type | description |
|---|
| record | any | |
resultShape(text: string) → void
A tool answer taken apart into the things a reader wants separately.
`nil` when the text is not an envelope this recognises, which is the honest
answer: the raw text is then shown rather than a shape invented for it.
| arg | type | description |
|---|
| text | string | |
imageAvailable(path: string) → boolean
| arg | type | description |
|---|
| path | string | |
renderMarkdown(P: any, md: string) → void
Markdown as widgets: an answer, or a page a tool answered.
The shared renderer draws the prose. A table and a fenced code block are
drawn here (`View.splitMarkdown` lifts them out), because the renderer
draws neither so that it can wrap or be selected: a table came out as raw
`| a | b |` lines running past the panel's right edge. The renderer's
verbatim lines (an indented block) are made to wrap and be selectable for
the same reason.
| arg | type | description |
|---|
| P | any | |
| md | string | |
inline(text: string) → void
| arg | type | description |
|---|
| text | string | |
toolDetailNodes(source: any, row: any, key: string) → void
What an opened tool row shows: what went in, what came back, and any
picture the call produced.
`nil` when neither the arguments nor the result reached the panel — that is
what decides whether the row is openable at all, so a chevron never appears
over nothing.
| arg | type | description |
|---|
| source | any | |
| row | any | |
| key | string | |
heading(text: string) → void
| arg | type | description |
|---|
| text | string | |
mono(text: string) → void
| arg | type | description |
|---|
| text | string | |
data(value: any) → void
A decoded value, rendered. One row per line: the field's name dim
beside its value, indented by how deep it sits, and no punctuation.
| arg | type | description |
|---|
| value | any | |
fitInto(width: number, height: number, boxW: number, boxH: number) → void
| arg | type | description |
|---|
| width | number | |
| height | number | |
| boxW | number | |
| boxH | number | |
rowImages(m: any) → void
Every picture on a row: its own, or each of its calls' for a run of calls.
imagePath(source: any, image: any, size: string) → string
Where a picture's `size` copy is drawn from, or nil while the plugin has
not put it there (or no longer keeps it).
| arg | type | description |
|---|
| source | any | |
| image | any | |
| size | string | |
pictureNodes(source: any, expanded: { [string]: boolean }, onToggle: () → void
The pictures a call returned: a row of thumbnails under the call, each
opening its larger copy beneath the row when clicked.
| arg | type | description |
|---|
| source | any | |
| expanded | { [string]: boolean } | |
| onToggle | ( | |
plainError(text: any) → void
A failure as a person reads it: one sentence, the service's own reason
under it when it gave one, and the raw text kept for "Details".
The raw text is an operator's: `hook 'llm_call' failed: API error: Claude
API returned 400 Bad Request from https://…: {"type":"error",…}`. Drawn as
it was, in red, it was a wall a person had to decode to learn that Claude
refused one request. The pipeline's own wrapping is taken off, a provider's
HTTP refusal is said as one, and its JSON is read for the message inside it.
| arg | type | description |
|---|
| text | any | |
tidyTurnRows(messages: { any }) → void
One account of a failure per turn.
A failed turn reached the panel three times: as the `error` event, as the
pipeline's chat sentence for surfaces that render no errors, and again as
the `end` event's message. All three were drawn, so one refusal read as an
error, an apology and the same error again. Within a turn (the rows between
two of the person's messages) an error is drawn once, and an answer row that
only restates it, or apologises generically beside it, is not drawn.
| arg | type | description |
|---|
| messages | { any } | |
chatBlocks(blocks: { any }) → void
The renderer's blocks, set for a chat: inline code readable, paragraphs a
little closer, and nothing hanging below the last block (the row's own gap
is the space between messages).
| arg | type | description |
|---|
| blocks | { any } | |
gapAfter(kind: string?, nextKind: string?) → number
The space under a row, read from what comes next: a turn's own pieces sit
close together, and a new exchange starts with room above it.
| arg | type | description |
|---|
| kind | string? | |
| nextKind | string? | |
rowNodes(source: any, icons: any, expanded: { [string]: boolean }, onToggle: () → void
The nodes one transcript row draws: one, or two when an open row adds its
detail beneath it. A row of a kind the transcript does not draw adds none.
| arg | type | description |
|---|
| source | any | |
| icons | any | |
| expanded | { [string]: boolean } | |
| onToggle | ( | |
imageState(result: any) → string
Whether each picture a tool answer names is on disk, as one string. Read
for an open row only: a closed row draws no picture.
| arg | type | description |
|---|
| result | any | |
sameStamp(a: { any }, b: { any }) → boolean
| arg | type | description |
|---|
| a | { any } | |
| b | { any } | |
keyedOnly(bucket: { [string]: any }) → boolean
Whether every callback a row registered is keyed. An unkeyed callback is
numbered by the order the build reached it, so a kept subtree carrying one
would answer to whichever closure the next build numbered the same; a row
holding one is built fresh every time instead of kept.
| arg | type | description |
|---|
| bucket | { [string]: any } | |
new(deps: { [string]: any }) →
Build a transcript.
a tool answer (`traceOf`, `toolsRunIn`); `icons` holds the `down`,
`right`, `alert` and `bot` paths; `expanded` is the open/closed table,
keyed by row key, that the panel keeps; `onToggle()` runs after a row is
opened or closed; `pageSize` overrides `M.PAGE`.
| arg | type | description |
|---|
| deps | { [string]: any } | `{ source, icons, expanded, onToggle, pageSize? }`: `source` reads |
turnRows(messages: { any }) → void
`messages` as they draw, turn by turn: carrier calls grouped and each
turn's failure said once (`tidyTurnRows`). A turn runs from one of the
person's messages to the next, and both steps keep within it, so every
turn that has ended is the rows it was the last time, and only the
running turn is made again.
| arg | type | description |
|---|
| messages | { any } | |
workId(row: any, index: number) → string
What a run of work rows is known by, from its first row: the call it
starts with, else the row's own id, else its place.
| arg | type | description |
|---|
| row | any | |
| index | number | |
stepped(tabId: string, rows: { any }, running: boolean, calls: boolean) → void
`rows` as the transcript draws them, each with the key its drawing is
kept under (`<tab>:m<index>`, its place among `rows`). A run of a
turn's work rows (its thinking and tool calls) is one `steps` row
naming what they did as a player reads it; the rows themselves follow
it once the person opens it. `running` says the last turn is still
under way, so a run nothing but the Working row follows is the step
under way.
| arg | type | description |
|---|
| tabId | string | |
| rows | { any } | |
| running | boolean | |
| calls | boolean | |
windowOf(tabId: string, conversation: string) → void
| arg | type | description |
|---|
| tabId | string | |
| conversation | string | |
showEarlier(tabId: string) → void
Draw one page more of the earlier rows on `tabId`'s next render.
| arg | type | description |
|---|
| tabId | string | |
stats(tabId: string) → any
What `tabId`'s last render did: `{ rows, drawn, built, kept, hidden }`.
`rows` is every row the conversation has, `drawn` the rows on screen,
`built` the rows whose nodes were made by that render, `kept` the rows
that carried the nodes they already had, and `hidden` the rows behind
"Show earlier messages".
| arg | type | description |
|---|
| tabId | string | |
render(tabId: string, messages: { any }, opts: { [string]: any }?) → any
`messages` as the scroll area `tabId` draws.
the rows belong to (a new one starts again at one page), the clock a
thinking row's seconds are read against (`os.clock()` when absent),
whether its last turn is under way, which makes the last step of its
work the current one, and `calls = true` to draw a turn's work as its
calls rather than as steps.
| arg | type | description |
|---|
| tabId | string | |
| messages | { any } | |
| opts | { [string]: any }? | `{ conversation?, now?, running?, calls? }`: the conversation |
rowFor(key: string, stamp: { any }, make: () → void
One row's nodes: the ones it already has when `stamp` says it shows
what it showed last time, else new ones from `make`.
| arg | type | description |
|---|
| key | string | |
| stamp | { any } | |
| make | ( | |
cardImages(run: any) → void
The pictures a run's card draws: its newest `AGENT_PICTURES`.
agentHue(P: any, state: string) → string
The hue of a run's state: the link blue while it works, the warning hue
while it waits, and the hue of how it ended once it has.
| arg | type | description |
|---|
| P | any | |
| state | string | |
agentCard(source: any, icons: any, expanded: { [string]: boolean }, onToggle: () → void
One agent's card. **One line high until it is opened**, so five agents
cost the transcript five lines rather than most of the panel: the line
holds its state, its name, what it is doing now (or how it ended), how long
it has taken, its Stop while it works and the arrow to its transcript.
Pressing what it is doing opens the card under that line to the rest:
its task, the whole of what it is doing, what it has used and the
pictures its calls returned. Nothing a card held is gone; the line says
where it is. The name opens its transcript, as the arrow does.
| arg | type | description |
|---|
| source | any | |
| icons | any | |
| expanded | { [string]: boolean } | |
| onToggle | ( | |
headingText(P: any, runs: { any }) → any
The heading's count of each state, a failure in the failure hue.
| arg | type | description |
|---|
| P | any | |
| runs | { any } | |
newAgents(deps: { [string]: any }) →
Build the agent cards one tab draws above its composer.
(`icons.term` marks a tool call, `icons.stop` the Stop button), plus
`onOpen(run, key)` (a card's chevron or name) and `onStop(run, key)` (its
Stop), each handed the run and the key of the section it was pressed in;
`pageSize` overrides `M.AGENT_PAGE`.
| arg | type | description |
|---|
| deps | { [string]: any } | The same `{ source, icons, expanded, onToggle }` a transcript takes |
showEarlier(key: string) → void
Draw one page more of the earlier cards on `key`'s next render.
| arg | type | description |
|---|
| key | string | |
stats(key: string) → any
What `key`'s last render did: `{ runs, drawn, built, kept, hidden, folded }`.
| arg | type | description |
|---|
| key | string | |
folded(key: string, runs: { any }, conversation: string?) → boolean
Whether `key`'s section is folded to its heading for `runs`, the
agents of `conversation`: as the person set it for that conversation
since its agents last started or all ended, else open while an agent
works and folded once every agent has ended.
| arg | type | description |
|---|
| key | string | |
| runs | { any } | |
| conversation | string? | |
setFolded(key: string, runs: { any }, conversation: string?, folded: boolean) → void
Fold (`true`) or open `key`'s section for `conversation`'s agents
`runs`, as a press on its heading does: it holds until the
conversation's agents next start or all end.
| arg | type | description |
|---|
| key | string | |
| runs | { any } | |
| conversation | string? | |
| folded | boolean | |
render(key: string, runs: { any }, opts: { [string]: any }?) → any
`runs` (oldest first, as the source lists them) as the section
`key` draws: a heading naming how many agents are in each state, which
folds the cards, then the newest cards first with the earlier ones
behind a "Show earlier agents" row. Nil for no runs.
against, in host epoch milliseconds (`os.time() * 1000` when absent),
and the conversation the agents belong to, which a fold is kept for.
| arg | type | description |
|---|
| key | string | |
| runs | { any } | |
| opts | { [string]: any }? | `{ nowMs?, conversation? }`: the clock elapsed time is read |