# dotbot (editor panel)
The DotBot panel: one dock tab, DotBot, in the right dock under the Agents menu
beside the terminal agents' tabs.
A conversation runs on an account, and the account is a setting of the
conversation, shown on the composer's account chip and changed from it:
| Account | Pays |
|---------|------|
| OrigoZero credits | the agent included with OrigoZero |
| each connected Claude account | that Claude plan |
| each connected ChatGPT account | that ChatGPT plan |
Several accounts of one provider connect side by side. Each is one of the
plugin's agents: `dotbot-claude` runs on the first Claude account and
`dotbot-claude~2` on the second, so moving a conversation to another account is
sending its next turn as that account's agent. A conversation keeps its
history when it moves.
- **Toolbar**: DotBot, then conversations, new chat, whether DotBot reacts to
engine events, the community setting, and overflow.
- **Community setting**: how much community work DotBot does without asking
the person: off, rate, rate and report, rate, report and contribute, or full
(also answering comments and reviewing contributions on their content). The
menu reads and sets the engine's community module
(`@builtin::modules.community`), which keeps the level in the person's home
folder, so it goes with them from world to world; the engine's community
notices and DotBot's own rules both read it. Until a home folder is mounted,
a level set holds for the engine session, and the menu says so.
- **Conversations**: every conversation, whichever account it ran on, named
with that account. Opening one opens it on the account it ran on.
- **Look**: the panel draws in DotBot's own palette (`View.palette()`:
charcoal neutrals, DotBot orange for its mark, Send, what is active and the
context bar), with prose in the editor's sans and code, tool names and
figures in JetBrains Mono (`View.MONO`). The editor's own controls (the
text field, the chips, menus) keep their look.
- **Transcript**: the person's messages as rounded bubbles on the right, the
answer as plain text across the panel, and between them a turn's work
(its thinking and tool calls) as one rounded card, a step per row. Under
each turn, a quiet usage line: model, thinking level, the context it read,
tool calls, duration, and which account paid, said on the conversation's
first turn and whenever it differs from the turn before. A turn's usage
line stays under its own turn when the stored history catches up with what
the panel watched live. A switch of account says so in the conversation
where the next turn will appear. A turn that fails shows its reason as an
error card, each failed turn its own, also when it failed for the same
reason as the turn before it.
- *Events the ring dropped*: when the panel's drain falls behind the event
ring (the panel was not drawn while a long turn streamed), it carries on
from the newest events, every row streaming across the gap ends there, and
a turn whose `end` the ring dropped is ended from the end the service kept:
its usage line and reason are drawn, its Working row comes down and the
next queued message is sent. Once such a turn has ended, the rows it
streamed are drawn from what the plugin stored.
- *Turns started elsewhere*: a turn the panel did not start (a run the
engine starts with a prompt, the page's `agent_prompt`, the engine waking
the agent) shows the message it answers as it starts, above what the turn
says, in that turn's conversation, which the panel moves to. What the
engine delivered reads as the engine's row, the way a reopened
conversation reads it.
- *Thinking* is folded, never hidden: a row that says `Thinking… 4 s` while
the model thinks and `Thought for 4.2 s` once it has, with a chevron that
opens the thoughts (streaming live while it thinks). A turn's thinking
phases fold into one row when the turn ends, and a reloaded conversation
shows the thinking it stored.
- *A turn's work reads as steps.* Each run of a turn's thinking and tool
calls is a card of steps worded for a player, in the person's language
("Looked up how to make it", "Building the level"): a tick for each one
done, the one under way in DotBot's orange, a count on a step that stands
for several calls, the newest line of the model's thought while it
thinks, and after a call that failed the line saying DotBot tries
another way. The card carries the newest
pictures its calls returned. "Show the actions behind this" opens the
calls themselves under it, and closes them again. An agent's own
transcript draws its calls as they are.
- *Tool calls*, opened, are a line each: a dot for how it went (green done, amber
running, red failed, grey stopped), the tool's name, and what it was
called on (its first argument, a path or a query), or why it failed.
A call opens to its input and answer. A run of carrier calls names what
a `tool_exec` actually ran, from the trace in its
answer, for a live answer (cut at 2000 characters by the host) as well as a
stored one. A picture whose file is gone says so.
- *Pictures*: every picture a tool call returned (a `capture`, a
`read_file` of an image, an `execute` that answers one) shows as a
thumbnail under the call's card, live and in a reopened conversation.
Clicking a thumbnail opens its larger copy beneath the card; clicking it
again closes it. The plugin keeps a thumbnail (at most 240 px) and a larger
copy (at most 1280 px) of each, and the panel draws only those.
- *Answers* wrap: a markdown table is drawn as a table whose cells wrap, and a
fenced code block wraps at the panel's edge instead of running past it.
- *Selection*: text can be highlighted with the mouse and copied with Ctrl+C:
user messages, thinking, tool details, error cards, code blocks, and (where
the renderer supports `selectable` on a `richText`) every styled paragraph,
list item and table cell of an answer.
- **Composer**: where a message is written. Files go with it: the attach button
opens the person's file picker, Ctrl+V (Cmd+V on macOS) with an image on the
clipboard attaches the image, and files dropped anywhere on the panel attach
while a line in the composer says they will. Each shows beside the input (a
thumbnail for a picture the model reads, its name for any other file) with a
button that takes it back out, and goes with the next message, which needs no
text of its own. A file over the size `ui.maxFileBytes()` states, or one that
cannot be read, is named under the composer, and the others attach.
- **Agents**: the agents a conversation's turns started (`start_agents`), as
cards between the transcript and the composer, newest first, under a
heading counting them by state, with what they used together (input,
output, cache hit rate, summed from their statuses as they arrived) at its
right. The section is about three agents tall until a person drags its top
edge to another height (kept for the tab), scrolls past that, and folds to
the heading once every agent has ended (a press on the heading opens or
folds them). Each agent is one line: a dot and its state (queued, starting,
working, waiting, done, failed, cancelled) in its own hue, its name, the
step the tool it is in reads as, in the person's words (or that it waits for the person's answer, for
engine work, or once it ends its answer or why it failed; a phase that
only repeats the state is left off), how long it has taken (counting while
it works), its Stop and the arrow to its transcript. A press on what it is
doing opens the line to the rest: its task, the tool it is in,
what it has used (tool calls, input, output, cache hit rate) and
thumbnails of the pictures its calls returned. The square stops that agent
alone. The arrow, or its name, opens the agent's own transcript in place of the
conversation: its state above every row of its conversation, stored and
streaming, opening on its task, with its pictures and a Working row, and
Back returns. While the turn runs `wait_for_agents` its Working row names
the agents it waits on. The agents are held by the source, so the panel opened again shows
them as they stand.
- **The game being built**: a card between the agents and the composer.
- *Your game*: the requests of each workflow run the open conversation
started, newest last, worded for a player: the game imagined and named,
the parts planned and counted, each part being built by the name the plan
gave it, the polish, the play against the pictures, the publish. A tick
for each one answered, DotBot's orange for the one being worked, the rest
waiting.
- *Play*: once the agent building the game stated it playable
(`playable.declare`, read as `playable.state().declared`) in edit, the
conversation has said something and its last turn did not end on an
error, "Your game is ready to play" with Play, which plays it full screen
(`edui.shell.playFullScreen`): the editor's panels step aside, the game
takes the window with its own touch controls, and the panels come back
when play ends. The scene's own verdict offers no Play: the template a
world starts from reads playable before anything was built. While a turn
builds, a statement made before the turn began waits for one the turn
makes.
- *Try again*: a turn that ended on an error says DotBot stopped before the
game was finished, and Try again sends the person's last message again.
- *What next?*: back from playing, three next steps (another level, harder,
a better look), each sent to DotBot in the person's words when pressed;
they go once the person sends anything.
- **Workflows**: every workflow run in the engine, whoever started it, opened
from the toolbar's count of the runs still running (shown while any runs)
or from More > Workflows. A card per run, newest first, names its workflow,
its state (Working, Waiting, Running, Finished, Failed, Cancelled), the
DotBot conversation that started it (and the agent a turn started, when one
of those did), how long it has run, its phases and how many of its requests
are answered, and why it ended. Opening one shows each phase with its
requests: each one's state, the agent working it (a button opens that
agent's transcript) or the runner holding its claim, how long it has been
claimed or waited, the claims that ran out and its error; a press opens its
answer. Under them, the run's log. A running run can be cancelled; Cancel
asks once first. Everything moves as the runs do, read from the engine's
workflow runtime, and only what changed is drawn again.
- **Composer**: the account chip, a model chip and a thinking chip offering only
the levels the chosen model accepts, attach, send, and a line naming what is
left of the account's usage.
- *Context*: under the composer, one line: how much context the
conversation holds against its model's context window (`184K / 1M`),
the bar, and an info button. Hovering the button shows the rest (where
it compacts, and what the last turn and the conversation used); a press
keeps those lines open under the bar. The bar is filled as the
plugin measures it after each model call and dropping after a compaction.
A handle on the same bar stands where auto-compaction triggers
(`compacts at 600K`) and sets that threshold: drag it, click the bar, or
with the bar focused use the arrow keys (10K a step, Shift for 100K),
Page Up / Down, Home and End. The value it lands on is shown while it
moves; once let go (a key: once pressed, or once let go after it is held)
it is the person's auto-compact setting, the one
Settings… shows. It stays between the least a threshold may be and the
most it takes effect at, never past the window. A model that states no
window reads `max unknown` and says so; its handle keeps its own range.
- *Tokens*: on the context line's info button (as lines under the composer
for a conversation with no context bar), what the conversation's model
calls used, for the latest turn and for the whole conversation: uncached input tokens,
output tokens, and the cache hit rate (cache-read input over all input:
cache read, cache written and uncached). The plugin records them as each
turn ends, so they read the same when the panel or the engine is opened
again. A provider that states no cache figures is said to state none.
- *While a turn runs* (one the person sent, or one DotBot woke into on its
own) the Working row shows and Send becomes Stop. Enter queues the message
for when the turn ends; the interrupt button stops the turn and runs the
message once it has ended. Queued messages sit above the composer, each one
editable and droppable. Stop holds them: a stopped conversation starts
nothing until the person sends a held message.
- **Account picker** (the account chip): every account DotBot can run the
conversation on, with its state and usage, then "Connect another Claude
account", "Connect another ChatGPT account" and "Connected accounts…".
- **Connected accounts**: one card per account with its plan, its own usage
windows, and Use, Rename, Sign in again and Disconnect; Connect on an account
that is not connected starts its sign-in in place.
- **Connect flows**: ChatGPT's device code, and Claude's sign-in then paste,
for the first account of a provider and for each further one.
- **Usage states**: a notice under 25% of a window left, a warning under 10%
offering a cheaper model only when that model is one this account can run,
and a spent window naming the connected accounts that still have room, with
a button that moves the conversation to the first of them. Nothing moves on
its own.
- **Failure states**: an expired sign-in, an expired code, a provider not
issuing codes, an engine not linked to an OrigoZero account, and an account
disconnected while a conversation was on it, which then asks for an account
rather than sending anywhere.
Everything it shows comes from the plugin through `source.module`, and every
word it puts on screen for a reading comes from `view.module`. The panel holds
only what is on screen right now: which view, which popup is open, which
account the open conversation runs on, how far a connect flow has run, and the
unsent draft.
# dotbot_service
The DotBot bridge, minus its privileges.
`src/lua/trusted/dotbot/` is the layer between the DotBot panel (user-VM Luau,
untrusted) and the DotBot plugin (trusted scope, holds a person's ChatGPT /
Claude sign-in). Everything in that layer that is a **rule** rather than a
**capability** lives in this module: the job table, the consent choreography,
the event ring, the mirror the read-only exports answer from, and the scrub
every value passes through on its way out.
```lua
local Service = require("@builtin::modules.dotbot_service")
local service = Service.new({
plugin = function() return rawget(_G, "dotbot") end,
await = task.await,
spawn = task.spawn,
consentRequest = function(o) return consent.request(o) end,
consentGranted = function(o) return consent.granted(o) end,
openUrl = function(url) return system.openUrl(url) end,
newJobId = function() return __crypto.uuid_v4() end,
nowMs = function() return os.clock() * 1000 end,
})
```
## Why the split
It is what makes the layer testable. The module is a **factory**: it holds no
state of its own and no privileged global, so a test can construct an instance
over fakes and drive every rule in it. Being a builtin module, a world script
can construct one too — and wins nothing, because its instance talks to its own
fakes. The one instance that talks to the real consent gate, the real plugin
namespace and the real `system.openUrl` is built in the trusted VM, out of
globals only the trusted VM holds, and is reachable only as
`trusted.call("dotbot.<method>", …)`.
## The shape, and where it comes from
| Constraint | Consequence |
|---|---|
| A `trusted.call` handler must not yield (`trusted/exports.luau`) | Nothing that awaits is answered in the frame. Awaiting verbs are start/poll **jobs**; reads are answered from a **mirror** a spawned task fills, which stays current until a change marks it stale, so an open panel asks the plugin nothing while nothing changes. |
| There is no push from the trusted VM into a user VM | The panel **drains a cursor** (`events(cursor)`) rather than registering a callback — so no trusted code ever calls into a user VM, and a world script cannot install itself as the panel's event handler. |
`stop` is the one verb answered in the frame: stopping is always allowed and
always cheap, and a stop that needed a confirmation would be a stop that lands
after the turn it was meant to end. Its outcome arrives as a turn event.
## Signing in
A person's plan is reached by one of two flows, and **the plugin says which**.
`connectStart` reads it from the plugin's own account state (`M.signInFlow`)
and, when a logged-out account names none, asks the plugin — never the caller,
whose choice of flow would be a choice of which endpoint the person is sent to.
| Flow | `connect.start` answers | Then | Finished by |
|---|---|---|---|
| `deviceCode` (ChatGPT) | `{ flow = "deviceCode", state = { userCode, verificationUrl, … } }` | the person types the code on the provider's page | `checkSignIn` until the account connects |
| `pasteCode` (Claude) | `{ flow = "pasteCode", state = { authorizeUrl } }` | the person signs in and the browser ends on an address carrying the code, which they paste | `completeSignIn(provider, pasted)` |
`cancelSignIn` abandons either.
### Several accounts of one provider
Every flow takes an **account key**: the provider's key (`anthropic-claude`)
for its first account, the provider and a slot (`anthropic-claude~2`) for each
further one. `addAccountStart(provider)` connects a further account beside the
ones already connected: behind the same `connect` confirmation, it asks the
plugin for the key the new account signs in under (`newAccount`) and starts
that account's sign-in, answering what `connect` answers plus the `account` it
started. `renameAccountStart(account, label)` keeps a person's name for an
account, as they wrote it (one line, at most 64 characters), and asks nobody. A
dialog that names an account names which one, by the email its provider stated,
once a provider has more than one: the name a person gives an account is set by
an ungated call, so the dialog's words stay the plugin's own.
Only `connect` asks for a confirmation. The three that continue it do not, for
`stop`'s reason: they carry out a `connect` the person has already confirmed and
is at that moment completing on the provider's own page, they spend nothing, and
`completeSignIn` cannot connect anything on its own — the plugin holds a
single-use verifier from the gated `connect` and answers "no pending login" to
anything else. A second dialog inside one flow is how a person learns to stop
reading the first.
## The agents a turn started
A turn starts agents with `start_agents`, and the plugin reports each on its
feed as a `subagent` event: `{ kind = "status", status }` on every change,
`{ kind = "event", event }` for one event of the run's own transcript, and
`{ kind = "tool_image", event }` for a picture one of its calls returned.
`subagents(conversation?)` answers the runs held here, oldest first: each the
plugin's snapshot with `images`, the newest `SUBAGENT_IMAGES` pictures its
calls returned, and `pictures`, how many there have been. A status event puts
that run's new record in place; a read answers a frozen copy of the list,
made once per change, whose `version` moves when a run in it changes.
`subagent(id)` answers one run's record. `subagentUsage(conversation)` answers
what a conversation's agents have used, summed from their statuses as they
arrive (`runs`, the four token counts, `creditsCharged`), so a run let go
keeps what it added. A picture of a run not held here is let go with it.
The plugin is asked for its list once; status events keep the runs current,
and what a status event said stands over a list the plugin answered before
the event arrived. A list asked again (`refresh("subagents")`) lets go of the
runs it no longer names, and once more than `SUBAGENT_KEEP` runs have ended
the earliest to end is let go. A run that reaches one of `SUBAGENT_ENDS`, and
a run event that ends a turn, mark the run's own conversation's history
stale. `stopSubagent(id)` asks nobody, for `stop`'s reason, and answers in the
frame.
## Turns a usage limit stopped
`continuations()` is the plugin's list of the turns a usage limit stopped,
each continuing on its own once its window resets, read from the mirror and
asked again on a `continuation` event or a turn's end. `cancelContinue` asks
nobody and answers in the frame, for `stop`'s reason; `continueNowStart` is a
job that starts the turn now, and the provider decides whether the window has
room.
## The context gauge
`context(conversation)` is the plugin's answer for a conversation's context gauge: how much context it holds, its model's window (nil when the model states none) and the auto-compact threshold with the range it may take. Read from the mirror and asked again on a `context` event (a model call or a compaction measured it, its model changed, or the threshold did), a turn's end, a model, threshold or default account this service set (`setModelStart`, `setAutoCompactStart`, which refills it before it settles, `setDefaultAccountStart`), a sign-in change, or the time its `staleAtUnix` names, which the plugin states while a window is not known and its catalogue may come to state one.
## Which conversation started a workflow run
Built with `workflows` (the engine's `@builtin::modules.workflow`), the service
states where a workflow run one of DotBot's tool calls started came from, as
`{ host = "dotbot", conversation = "<agent>/<id>", agent? }` through
`setOrigin`, `agent` naming the agent a turn started when its call did. The
engine keeps it with the run's record.
It follows every tool call of every conversation, and of every agent a turn
started, from its `tool_start` to its `tool_result` (or the turn's end, or the
agent's), and listens to the runtime's `onChange`. A run is a call's when the
call was running as the engine started it and the call's answer names it;
each such run teaches the service the connection DotBot's calls reach the
engine over (the run's `started_by.connection`). A run no answer names (the
host cuts a long answer) is the calls' when that connection started it and
every call running as it started ran in one conversation for one agent. A run
read back from its record, one started while no call ran, and one already
stated are left as they are. A call with no answer for 15 minutes is taken to
have ended.
`close()` stops the service listening to the runtime: the engine's service is
closed when the one built after it (the plugin loaded again) takes its place,
and a test closes its own.
## Spending
`sendStart` and `commandStart` both ask for the `spend` grant, keyed by action,
plugin and the agent's display name, remembered for the world session. A slash
command is gated because a slash command can run a turn — `/compact` summarises
a conversation with the model — so it spends the plan exactly as a message does.
## What it will not do
- Return a token, a credential id or a header. `M.scrub` drops every
credential-named key at every depth, on every value leaving the layer —
results and event payloads alike. It is the second line: DotBot's account and
event types carry no token by construction. The names it drops are exact, not
a substring match on `token`, so the usage counters a person is shown
(`tokens`) and a turn's `turnId` survive.
- Take a URL. `openSignInStart(provider)` reads the verification URL out of the
plugin's own account state for the provider named, checks it is an http(s)
page, shows a person its **host** in the dialog, and only then opens it.
Account state naming none errors the job.
- Answer, dismiss or count a consent dialog. There is nothing here that settles
one; the gate is the engine's, and only a person at the keyboard answers it.
- Put a caller's own words on a dialog. `detail` is resolved through the
plugin's own agent and account lists and the flow **errors when it cannot be
named** rather than falling back to the id it was handed. The two arguments a
caller does supply beyond a message — a pasted sign-in code and a command
line — are shape-checked (`M.pastedCode`, `M.commandLine`) and reach no
dialog: the pasted code's flow draws none, and a command's dialog names the
agent.
- Read a plugin's refusal as an answer. The plugin host **raises** one where
the call is awaited, so `call` reports it as a failure and a job never settles
`done` on a sign-in that did not happen.
## Constants
| Name | Meaning |
|---|---|
| `RING_CAPACITY` | 512: events held. A cursor older than the tail is answered `dropped = true` with every event the ring still holds and the head as its cursor, so the next read carries on from there. |
| `TURN_ENDS_KEPT` | 64: ended turns whose `end` event `turnEnd(turnId)` answers, newest kept. Every `end` is kept as it arrives, so a reader whose cursor fell behind the ring reads the end it never drained. |
| `JOB_LIMIT` | 8 — jobs live at once, across every caller. A ninth `start` is `{ ok = false, reason = "busy" }`. |
| `JOB_TTL_MS` | 600000 — a job nobody polls is dropped after ten minutes. |
| `RETRY_MS` | 2000: how long a read the plugin could not answer waits before it is asked again. A read that has an answer stays current until a change marks it stale: an `account`, `usage`, `continuation`, `context` or turn-ending `turn` event, the time an answer's `staleAtUnix` names (a usage answer, and the agents and default accounts built on the same reading, `LAPSES_WITH`), a turn in a conversation the list does not hold, a job this service ran, or `refresh(name, arg?)` (with `arg`, the one read of `name` it names). A sign-in, a sign-out and an `account` event mark the accounts, the agents, the models and the usage. A new conversation list marks the history of each conversation whose message count or last update it shows moved. A mark made while the plugin is being asked for a read outlasts that ask's answer, which the plugin may have read before the change: the answer is held and the read asks again on its next call, at once also after an ask that failed. |
| `MIRRORED` | The reads the mirror holds: `agents`, `accounts`, `models`, `usage`, `conversations`, `history`, `subagents`, `defaultAccounts`, `continuations`, `context`. `refresh(name)` takes one of them. The mirror also holds `toolImage(conversation, image, size)`, where the plugin put one picture a tool call returned for the UI to draw: asked once per picture and size, and kept, because the copy stays where it was put. |
| `TURN_ENDS` | The turn event types that end a turn (`end`, `done`, `error`), after which the conversation list, the history, usage, accounts, agents, continuations and context gauges are asked again. |
| `SUBAGENT_ENDS` | The states a run ends in: `done`, `failed`, `cancelled`. |
| `SUBAGENT_IMAGES` | 8: the pictures kept with each run, newest last. |
| `SUBAGENT_KEEP` | 64: the ended runs held, the plugin's own number. |
| `PLUGIN_NAME` | `"dotbot"` — the name the consent gate resolves the dialog's display name from. |
| `DEVICE_CODE` / `PASTE_CODE` | `"deviceCode"` / `"pasteCode"` — the two sign-in flows, as `connect.start` names them back. |
Tested by `src/lua/lib/tests/suites/dotbot_exports.testSuite`.
# source
The DotBot panel's data source — the one seam between the editor panel and the
DotBot agent surface.
**This implementation is a fixture.** Every reading it hands back is a constant
written into its `init.luau`. It talks to no plugin, no provider and no network,
spends nothing, and holds no credential. It exists so the panel can be built and
looked at while the real surface is built elsewhere.
The contract is shaped after the `dotbot.*` trusted exports, so swapping the
fixture for the real surface is a change to this one file:
| Half | Members |
|------|---------|
| Read-only, answered in the frame | `available`, `agents`, `agent`, `terminalAgents`, `accounts`, `accountsFooter`, `models`, `model`, `levelsFor`, `level`, `usage`, `conversations`, `currentConversation`, `agentOfConversation`, `alternativesTo`, `history`, `messageRows` (the rows of a message a `user_message` turn event carries, read the way `history` reads it), `sendable`, `events`, `turnEnd` (the `end` event of a turn the service saw end, as the ring carried it), `subagents`, `subagent`, `splitAddress`, `continuationOf`, `contextOf`, and the engine's workflow runs: `workflows`, `workflow`, `workflowPhases`, `workflowsRunning`, `workflowRevision`, `onWorkflowChange`, `workflowAgent` (the agent a turn started whose task names a request), `workflowConversation` (the conversation a DotBot turn started a run in), and the game: `playable` (the world's playable milestone as `playable.state()` reads it), `engineMode` |
| Asking a read again | `refreshConversations`: the conversation list is asked again on its next read. `refreshHistory(conversationId, agentId?)`: that conversation's history is. `conversations`, `history` and `subagents` translate each answer once and hand back the same list until it changes. A history answer read again translates the messages from the first one that differs from the last answer and keeps the rows of every message before it; a call a later result settles is settled in a copy, so a list handed out before stays as it was. `agents`, `accounts` and `models` are the same list for every read of one answer (the agents and accounts within one second of the clock, which a usage window's reset is read against). `model(agentId, id)` names a model the answer read now does not list by the record an earlier answer gave it, else by its id, so the model a conversation runs on stays named. |
| Start / poll, because a trusted handler may not yield | `connect.start` / `.poll`, `openSignIn.start` / `.poll`, `disconnect.start` / `.poll`, `addAccount.start` / `.poll`, `renameAccount.start` / `.poll`, `send.start` / `.poll` |
| Read-write but unpriced | `setModel`, `setReasoning`, `modelOf`, `levelOf`, `setAutoCompact`, `autoCompactOf`, `stop`, `stopSubagent`, `cancelContinue`, `continueNow`, `cancelWorkflow`, `playFullScreen` (play the world with the editor's panels put aside until play ends) |
| The turn each tab runs, and what waits for it | `submit`, `turnOn`, `turnRunning`, `queued`, `stopTurn`, `unqueue`, `release`, `forgetTurn`, `pollTurns`, `observeTurn` |
| The slash commands typed in a composer | `isCommand`, `runCommand`, `commandOn`, `pollCommands` |
| The half only a fixture has | `fixture.enable`, `fixture.scenario`, `fixture.approve`, `fixture.setConnected`, `fixture.dropEventsBefore`, `fixture.reset` |
A `start` answers `{ ok = true, id }` or `{ ok = false, reason = "busy" }`. A
`poll` answers `pending`, `awaitingPerson`, `done`, `refused` or `error`. A
device-code flow carries its code, its page and its expiry on the
`awaitingPerson` answer, because that is what a person has to be shown while the
job waits.
Two `done` answers carry a flag that says the fixture did not do the thing:
`openSignIn` reports `opened = false` with the address it would have opened, and
`send` reports `delivered = false` with the reason. The panel shows both rather
than leaving a button that looks like it worked.
`fixture.enable(false)` takes the data away, and the panel says
"DotBot is not available in this build" instead of drawing a conversation
nobody had.
## One turn per tab
A tab runs one turn at a time, whoever started it: a send from the composer, or
a turn the plugin woke into on its own. `turnOn(tabId)` is that turn's record,
and the Working row, the Stop button and the composer all read it.
`submit` starts a turn on an idle tab; while one runs it queues the message
(`"queue"`, the default) or stops the running turn and runs the message once
that turn has ended (`"interrupt"`). A turn's `end` starts the next queued
message. `stopTurn` holds the queue, so a stopped tab stays stopped until the
person sends again (`release`). `unqueue` takes a queued message back to edit
or drop.
## Slash commands
A composer line starting with `/` and a letter (`isCommand`) is a command,
which DotBot runs as one rather than sending it to the model. `runCommand`
runs it at once, whether or not a turn runs on the tab. `/model <id>` and
`/reasoning <level>` are the pickers in words: the engine keeps them as it
keeps a pick, and the answer is `{ outcome = "ran", text }` or
`{ outcome = "refused", detail }` at once. Every other command is DotBot's own
(`dotbot.command`), addressed to the tab's conversation: `{ outcome =
"running" }`, and `pollCommands` hands over its answer once it settles,
`ran` with the command's text (and the conversation the agent is in after
it), `refused` with the reason, or `notACommand` for a line DotBot has no
command for, which the composer then sends as a message.
## The agents a turn started
`subagents(conversationId?)` lists the agents a conversation's turns started
with `start_agents`, oldest first: each the plugin's snapshot (`id`, `name`,
`task`, `state`, `doing`, its tool calls, tokens and `creditsCharged`, its
times in host epoch milliseconds, `awaited`, `result`, `error`, its own
`conversation`) with `images`, the newest pictures its calls returned in the
shape a transcript row carries them, and `pictures`, how many there have
been. A list is translated again only when the service's list moves, and then
only the runs that changed. With no conversation it lists every run on the engine;
`subagent(id)` reads one, and `subagentUsage(conversationId)` what its agents
have used, as their statuses stated it. The runs are held by the service, so a panel opened
again reads them as they stand. `stopSubagent(id)` stops one, answered in the
frame; its `cancelled` state arrives as its status. A run's own conversation
is an ordinary conversation: `splitAddress(run.conversation)` names it the way
`history` takes it.
## Scenarios
`fixture.scenario(name)` puts the readings into one state at a time:
`normal`, `fresh`, `notice`, `warning`, `blocked`, `signInExpired`,
`codeExpired`, `codesUnavailable`, `notLinked`.
## The game being built
`playable()` reads the world's playable milestone (`playable.state()`: whether
it can be played now, `source`, `since`), `engineMode()` the engine's mode, and
`playFullScreen()` plays the world with the editor's panels put aside until the
editor is back in edit (`edui.shell.playFullScreen`). `M.new` takes
`deps.playable`, `deps.mode` and `deps.play` in their place, which is how the
suite drives the panel's Play without entering play.
# steps
A DotBot turn's work as the steps a player reads, in the person's language:
each tool call, thought and workflow request worded as what it does to their
game ("Building the level", "Planned 4 parts"). The panel draws a turn's work
as these steps, with the calls themselves one press away.
```luau
local Steps = require(".steps")
local steps = Steps.ofRows(workRows, true) -- the running turn's work
for _, step in ipairs(steps) do print(Steps.line(step), step.state) end
```
| Member | Answers |
|--------|---------|
| `ofRows(rows, running?)` | The steps a run of a turn's work rows (thinking, tool calls, groups of carrier calls) makes, in order: calls of one kind one after another are one step `{ kind, calls, failed, state }`, and thinking between calls belongs to the step it leads to (a `think` step stands only while the model is thinking at the end of a turn under way, or for rows that hold no call). A step one of whose calls failed and that the turn went on past is followed by a `retry` step. With `running`, the last step is `"current"`; the others are `"done"`. |
| `line(step)` | The words of a step: `dotbot.step_<kind>_doing` for the current one, `_done` for one finished, `dotbot.step_retry` for a retry. |
| `text(step)` / `retryText()` | The words of a kind of step, and of a retry. |
| `kindOf(name, args)` | The kind of step a call of tool `name` with `args` (a table, or the JSON a row carries) is, or nil for a call that takes no step of its own (`wait`). A file written is the level, art, screens or how the game works by its path; a script run in the world is art when it generates, the level when it spawns or places, a check when it reads the playable milestone; a shell command is the plan (`zero workflow`), saving (`zm add`, `commit`, `push`), writing how the game works when it writes a file (`sed -i`, output sent into a path) or reading the files (output sent to another stream or to `/dev/null` writes none). |
| `toolDoing(name)` | The words of a step a call of `name` is while under way, for a line that names only the tool (an agent's card). |
| `ofWorkflow(run)` | One `{ text, state }` per request a workflow run asked, oldest first, `state` `"done"`, `"current"` (claimed), `"next"` (waiting) or `"failed"`. |
| `requestText(req, done)` | A workflow request's words by its label: `reference` (naming the game its answer titles), `plan` (counting the parts its answer plans), `build:<part>`, `polish:<survey, models, surfaces, sound>`, `match:<round>`, `publish`, and any other label. |
| `KINDS` | The kinds a step can be. |
Tested by `src/lua/lib/tests/suites/dotbot_panel.testSuite`.
# surface
<!-- zero:scaffolded-readme -->
<!-- Replace the line below with what this module provides and who
consumes it, then delete both comment lines. -->
TODO: describe this module.
# transcript
The DotBot panel's transcript: a conversation's rows as the scroll area one tab
draws.
```luau
local Transcript = require(".transcript")
local transcript = Transcript.new({
source = Source, -- traceOf / toolsRunIn, to read a tool answer; toolImage, to draw its pictures
icons = { down = ..., right = ..., alert = ..., bot = ... },
expanded = expandedRows, -- which rows are open, by row key
onToggle = function() expandEpoch += 1 end,
})
local node = transcript.render(tabId, messages, { conversation = convId })
```
| Member | What it does |
|--------|--------------|
| `PAGE` | 40: the rows a transcript draws before the "Show earlier messages" row, and how many more each press of it draws. |
| `new(deps)` | A transcript over `deps.source`, `deps.icons`, `deps.expanded` and `deps.onToggle`; `deps.pageSize` overrides `PAGE`. |
| `render(tabId, messages, opts?)` | The virtual scroll area holding the newest rows of `messages`, with a "Show earlier messages" row above them when there are more. `opts.conversation` names the conversation (a tab on a new one starts again at one page); `opts.now` is the clock a thinking row's seconds are read against; `opts.running` says its last turn is under way. A run of a turn's work rows (thinking and tool calls) is drawn as one rounded card of steps a player reads (`steps.module`): a tick for each step done, DotBot's orange for the one under way, the line saying DotBot tries another way after a failed one, the newest line of the model's thought while it thinks at the end of a turn under way, the newest `STEP_PICTURES` pictures its calls returned, and a link that opens the calls themselves beneath it, each row a slice of the same card, so the rows stay the scroll area's own children. `opts.calls = true` draws the calls in place of the steps, as an agent's own transcript does. A usage line names its payer only on the first turn and where it differs from the turn before. |
| `STEP_PICTURES` | 4: the pictures a steps card draws, newest last. |
| `showEarlier(tabId)` | Draws one page more of the earlier rows on the next render. |
| `stats(tabId)` | What the last render did: `{ rows, drawn, built, kept, hidden }`. |
## Pictures
A tool row whose call returned pictures carries them as `images`: each
`{ address, image, index, thumbWidth, thumbHeight, viewWidth, viewHeight,
thumbKept, viewKept, thumbPath? }`, where `address` is the conversation
(`<agent>/<id>`) and `image` the picture's number in it. The row draws a
thumbnail of each under its card, at most 160 by 90, read through
`source.toolImage(address, image, "thumb")` unless `thumbPath` already names
where it is. Clicking a thumbnail opens the larger copy (`"view"`) under the
card, at most 360 high; clicking it again closes it. A run of calls draws the
pictures of all its calls.
## The agents a turn started
`newAgents(deps)` builds the cards a tab draws above its composer for the
agents its conversation's turns started. It takes a transcript's `deps`, with
`icons.term` and `icons.stop`, plus `onOpen(run, key)` and `onStop(run, key)`.
| Member | What it does |
|--------|--------------|
| `render(key, runs, opts?)` | A grip to drag the section's height by, a heading naming how many agents are in each state, a failure in the failure hue (a press folds or opens the cards), with `opts.usage` (what the agents used together) at its right, then one line per agent, newest first: a dot and its state, its name, the step the tool it is in reads as, in the person's words (or what it waits for, its answer, or why it failed; left off when it only repeats the state), its time worked (a queued agent shows none, and its line says how long it has waited), its Stop while it works and the arrow to its transcript. A press on what it is doing opens the line to its task, the tool it is in, what it used, and the thumbnails of its newest `AGENT_PICTURES` pictures. The name and the arrow open its transcript. The section is as tall as its lines up to `AGENTS_SHARE` points, or to the height a person dragged it to (between `AGENTS_MIN` and `AGENTS_MAX`, kept per key), and scrolls past it; the earlier cards wait behind a "Show earlier agents" row at its end. Nil for no agents. `opts.nowMs` is the clock times are read against, and `opts.conversation` the conversation a fold is kept for. |
| `folded(key, runs, conversation?)` / `setFolded(key, runs, conversation, folded)` | Whether the section is folded to its heading: 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; and setting it, as a press on the heading does. |
| `showEarlier(key)` / `stats(key)` | One page more of the earlier cards, and what the last render did: `{ runs, drawn, built, kept, hidden, folded }`. |
| `AGENT_PAGE` | 6: the cards drawn before the "Show earlier agents" row. |
| `AGENTS_SHARE` | `118`: the height in points the section takes before its lines scroll, until a person drags it: its heading and about three agents. |
| `AGENTS_MIN` / `AGENTS_MAX` | `52` / `640`: the least and the most the section can be dragged to. |
| `agentHue(P, state)` | The hue a state is drawn in. |
A card is kept, like a row, while what it shows is unchanged, so a status of
one agent builds that card and no other.
## What a redraw costs
Each row is drawn from what it shows: its text, its tool call and answer,
whether it is open, a thinking row's seconds. A row that shows the same as it
did last time keeps the subtree it already has, and its callbacks are carried
into the new build (`edui.app` `collectHandlers` / `adoptHandlers`), so a delta
streaming into the last answer builds that answer and nothing above it. A row
holding a callback with no key is built fresh every time, because an unkeyed
callback is numbered by the order a build reaches it.
Only the newest rows are drawn, so what a redraw costs is set by what is on
screen rather than by how long the conversation is. The earlier rows are one
press away and nothing is dropped.
Tested by `src/lua/lib/tests/suites/dotbot_panel.testSuite`.
# view
What the DotBot panel says, apart from how it is drawn.
Every function here is pure: it takes readings from `modules.dotbot.source` and
returns the words and the state the panel renders.
| Function | Answers |
|----------|---------|
| `emptyState(availability)` | The title and detail shown when no DotBot surface is present. |
| `hintLine(agent, usage)` | The line under the composer naming what pays and what is left, or nil when there is nothing honest to say. |
| `usageNotice(agent, usage, models)` | The banner above the composer: a notice under 25% left, a warning under 10% offering a cheaper model only when that model is one the agent can run, and a used-up state naming the reset and that a message sent now is answered once it resets. |
| `contextGauge(answer, preview?)` | The context gauge of a conversation from the plugin's `context` answer: the fill (its context against its model's window), where the auto-compact handle stands and the range it can move in (the least a threshold may be, to the most it takes effect at, never past the window), `184K / 1M` or `184K / max unknown`, and `compacts at 600K`. `gaugeTokensAt(gauge, fraction)` is the threshold a press or a drag at a share of the bar sets (to 1,000 tokens); `gaugeKey(gauge, from, key, shift?)` is where an arrow (10,000, Shift 100,000), Page Up / Down, Home or End moves it. `gaugeCount(n)` writes a size the way the gauge does. |
| `continuationNotice(continuation)` | The banner while the conversation's turn waits for a usage window to reset: when it continues, with Continue now and Cancel. |
| `problemNotice(agent)` | The banner a failed sign-in puts above the composer. |
| `composerState(availability, agent, usage)` | Whether the field takes typing, what it says while empty, and whether it carries the model and thinking chips. A spent window keeps the field open and says which limit is used up and when it resets: the provider decides. |
| `connectSheet(agent, flow)` | The sheet a disconnected, expired or unlinked agent shows in place of a conversation. |
| `connectedNotice(agent, account)` | The line a freshly-connected agent shows above its first turn. |
| `metaLine(meta)` / `metaWho(meta)` | The per-turn meta line: model, thinking level, tokens, tool calls, duration — and who paid. |
| `pickerSubtitle(agent)` / `pickerAction(agent)` | What an agent's row in the picker says, and the word on its button when it needs one. |
| `rowKey(row)` / `mergeRows(history, live)` | A transcript row's identity (a tool row is its call, a thinking row or usage line is itself) and the merge of stored history with the live rows, which shows the overlap once. A live row the history does not hold (a turn's usage line is never stored) is drawn after the stored row the live row before it matched, so it stays with its own turn; live rows nothing of which is stored yet follow the history. A history list is keyed once, when it first reaches `mergeRows`, so a merge on every redraw costs the live rows. |
| `palette()` / `MONO` / `MESSAGE` | DotBot's own look: the editor's palette with DotBot's colours and corner radii laid over it, the font code and figures are set in, and the surfaces of a person's message and an opened thought. |
| `groupCarrierRows(rows, toolsRunIn)` | Runs of `tool_exec` calls collapsed into one row naming the tools they ran. |
| `thinkingLabel(row, now)` / `finishThinking(row, now)` / `foldThinking(rows, from)` / `thinkingRow(...)` / `toggleOpen(state, key)` | Thinking as a folded row: its header, its clock, the fold of one turn's phases into one row, and the open/closed state. |
| `splitMarkdown(md)` / `tableNode(...)` / `tableWeights(...)` / `codeNode(...)` / `markSelectable(node)` | An answer's tables and fenced code lifted out of the markdown and drawn so they wrap, and every piece of an answer marked selectable. |
| `imageNode(P, key, path, exists)` | A tool's picture, or the line saying it is no longer available. |
| `linkText(id, label, onClick)` | Text that looks like a link and acts like one, its callback keyed by `id`. |
| `agentStateWord(state)` / `agentActive(run)` | How an agent's state reads (`Queued`, `Starting`, `Working`, `Waiting`, `Done`, `Failed`, `Cancelled`), and whether it still works. |
| `agentElapsed(run, nowMs)` / `agentWaited(run, nowMs)` / `duration(seconds)` | How long an agent has worked, counting from its start while it works (none while queued), how long a queued agent has waited to start, and a span as `8s`, `1m 05s`, `1h 02m`. |
| `oneLine(text, limit)` | Text as one line, its line breaks made spaces, cut at `limit`. |
| `agentDoing(run, nowMs?)` | What an agent is doing now and what kind of line that is: the tool it is in, a phase, "Waiting for your answer: <tool>" while a call waits on the person, "Waiting for engine work" once its loop has ended and engine work it started has not, its answer once done, or why it failed. |
| `agentUsage(run)` | What an agent has used: tool calls, input, output and cache hit rate. |
| `agentsHeading(runs)` / `agentsHeadingParts(runs)` | The line over a conversation's agents, naming how many are in each state, e.g. `Agents · 1 queued · 2 working · 1 done`, and its pieces, each with the state it counts. |
| `agentsUsageLine(totals)` | The line under the composer naming what the agents used, from `subagentUsage`: how many, their input, output and cache hit rate, and the credits they were charged. |
| `USAGE_PENDING` | What `usageLine` says before a provider has reported a window. |
| `workflowStatus(run)` | How a workflow run's state reads and the state its hue comes from: `Working` while an agent holds one of its requests, `Waiting` while requests wait for one, `Running`, `Finished`, `Failed`, `Cancelled`. |
| `requestStateWord(state)` | How a workflow request's state reads (`Waiting`, `Claimed`, `Answered`, `Failed`, `Cancelled`). |
| `workflowElapsed(run, nowSec)` / `workflowProgress(run)` | How long a run has taken, and `{ answered, asked, failed, text }` with `text` such as `2 of 5 answered · 1 failed`. |
| `phaseName(name)` / `workflowPhaseLine(run, phases)` | A phase's name (`Start` for the unnamed one), and the phases as `Plan 1/1 · ▸Build 1/3`, the one the run is in marked. |
| `workflowStarter(run, title?, agentName?, address?)` | Who started a run: `in “<conversation>”` (or `in DotBot conversation <first 8 of its id>` when the list names it by its id alone), `by agent <name> in ...`, or `by <caller>` from what the engine recorded. |
| `requestTiming(req, nowSec, agent?)` | A request's line: the agent working it or the runner holding its claim, how long it has been claimed or waited or took, the claims that ran out and its corrections. |
| `answerText(answer, limit?)` | An answer as text: a string as it is, a table of named string, number or boolean fields as one `name: value` line each, anything else as indented JSON, cut at `limit`. |
| `workflowsRunningText(count)` | `1 workflow running`, `3 workflows running`. |
| `waitingOn(runs, args)` | The Working row while `wait_for_agents` runs: the agents it waits on, by name, newest first as the cards stand, and whether it waits for the first of them; once they have all ended, that they have. |
The thresholds the usage ladder turns on are `noticeThreshold` (25) and
`warnThreshold` (10).
# workflows
The DotBot panel's Workflows view: every workflow run in the engine, whoever
started it, and one run opened.
```luau
local Workflows = require(".workflows")
local view = Workflows.new({
source = Source, -- workflows, workflow, workflowPhases, workflowRevision, workflowAgent, workflowConversation, cancelWorkflow, conversations, subagents, splitAddress
icons = { right = ..., down = ..., stop = ..., term = ... },
onToggle = function() epoch += 1 end,
onOpenAgent = function(agentRun, key) ... end,
onConversation = function(address, key) ... end,
})
local list = view.list(key, { nowSec = os.time() })
local opened = view.detail(key, run, { nowSec = os.time() })
```
| Member | What it does |
|--------|--------------|
| `new(deps)` | A view over `deps.source` and `deps.icons`. `onToggle()` runs after something in it opened, closed or was asked of a run; `onOpenAgent(agentRun, key)` opens an agent a turn started; `onConversation(address, key)` opens a conversation. |
| `list(key, opts?)` | One card per run, newest first: its workflow's name, its state (`Working` while an agent holds a request, `Waiting` while requests wait for one, `Running`, `Finished`, `Failed`, `Cancelled`), who started it (the DotBot conversation and the agent a turn started, else the caller the engine names), how long it has run, a bar and `2 of 5 answered`, and its phases as `Plan 1/1 · ▸Build 1/3`. A failed or cancelled run says why. A press on a card opens the run. The newest `LIST_PAGE` cards are drawn, and a "Show earlier runs" row draws that many more. |
| `detail(key, run, opts?)` | The opened run: its header (name, state, id, who started it with a link to the conversation, how long, its progress, why it ended or what it returned, and Cancel while it runs, which asks once before it cancels), then each phase with its requests. A request row names its label, its state, the agent working it (with a button that opens that agent's transcript) or the runner holding its claim, how long it has been claimed or waited (or taken, once settled), the claims that ran out, its corrections and its error; a press opens its answer, or its whole error. The run's log, newest `LOG_LINES`, opens under them. |
| `open(key)` / `setOpen(key, runId?)` | The run opened in view `key`, and opening one (nil goes back to the list). |
| `stats(key)` | What the last draw did: `{ runs, drawn, built, kept }` for the list, `{ requests, built, kept }` for a run. |
| `hue(P, state)` | The hue a run's status or a request's state is drawn in. |
| `LOG_LINES` / `ANSWER_CHARS` / `LIST_PAGE` | 60 log lines, 4000 characters of an answer, and 30 run cards a page. |
A card, the opened run's header and each request row are kept while what they
show is unchanged, their callbacks carried into the next build, so a change
to one request draws that row and nothing else. What a card and a header say,
and which agent works each request, is read once each time the runtime's
revision, the conversation list or the agents' list moves.
Tested by `src/lua/lib/tests/suites/dotbot_panel.testSuite`.