# 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.
# dotbot
DotBot, the agent in Zero's editor: the component that runs a person's own
Claude or ChatGPT plan (or OrigoZero credits) from inside Zero, and the
DotBot panel in the editor's right dock that talks to it. This world is
where the plugin's published copy lives; the engine's built-in library pins
a version of it.
## What is here
| Part | What it is |
|------|------------|
| `plugin.wasm` | The DotBot component (`wasm32-wasip2`), built in the DotBot repo from `crates/dbot-zero-plugin`. |
| `plugin.yaml` | The plugin's grants: its scope, the hosts it may reach, its private storage. |
| `surface.module` | The plugin's Luau surface, what `require("@builtin::plugins.dotbot")` resolves to. |
| `source.module` | What the panel reads: agents, accounts, conversations, history, turns, agents a turn started. |
| `service.module` | The trusted service between the panel and the component: calls, the event ring, jobs. |
| `panel.editorPanel` | The DotBot panel itself: toolbar, transcript, agents, composer, settings. |
| `view.module` | What the panel says and how it looks (`palette()`), apart from how it is drawn. |
| `transcript.module` | The transcript and the agents section, drawn as virtual rows. |
| `workflows.module` | The Workflows view. |
Each module's own README says what it does in detail.
## Seeing a panel change
The editor draws its DotBot tab from the built-in library, not from this
world, so an edit to the panel here does not show in the real tab. Open the
world's own panel code over a fake plugin with example data instead:
```bash
luau --lang luau 'require("/source/dotbotPanelPreview.module").open()'
```
It opens a **DotBot preview** tab beside the real one. Run it again after
each edit. `dotbotPanelPreview.module/README.md` says what it shows.
## Shipping a change
Work on a branch of this world and open a pull request into `main`. How a
merged change reaches the engine (publishing `plugin.wasm`, and the engine's
pin of this world) is written down in the DotBot repo, in
`docs/zero-plugin.md`.