The bridge

A screen runs in a worker with no page, network, storage, cookies, or server address. The SDK bridge is its only route into Brydio.

The wire protocol is brydio-tree/1. This page is generated by bun run docs:bridge. The protocol table reads WORKER_METHODS and HOST_METHODS directly, and every limit below reads its exported constant. Do not edit this page by hand.

Errors

ErrorWho refusedWhat to do
GrantErrorThe app's own manifest did not ask for the tool, collection, or host grant.Add the named grant to .brydio/app.json.
HostErrorBrydio refused or failed the request.Read its message. Code -32000 is a refusal.
ToolErrorThe tool ran and returned isError.Use its tool code and data. On stale, read the record again.
TeardownErrorBrydio stopped the screen before a reply arrived.Do not retry from the worker that is stopping.

tools.call rejects a tool result with isError. tools.result returns the whole ToolResult instead.

Public calls

connect()

Sends worker/ready once and resolves with HostContext. mount() calls it for a screen that draws immediately.

host.context and host.subscribe(listener)

host.context is the latest context or null. host.subscribe receives each later theme, size, selection, placement, or instance update and returns an unsubscribe function.

tools.call(tool, input) and tools.result(tool, input)

Calls one generated or custom tool. A write waits for Brydio to show an approval card. A missing manifest grant throws GrantError before the message leaves the worker.

data.get(collection, id) and data.list(collection, query)

data.get returns one record. data.list accepts filter, sort, limit, and cursor; a page is 50 by default, 200 at most. The result carries items and nextCursor.

data.watch(collection, onChange, onEnd)

Watches one collection and returns a function that stops. Each change has only { id, op, version }, so the screen reads the record again under current access. One open app may watch at most 5 collections.

Opens a chat, file, project, or app item and resolves with { opened }. It needs navigate in grants.host.

toast(text, tone)

Shows one Brydio toast in the info, success, or danger tone. Text is cut at 200 characters.

mount(build, options)

Connects, gives the plain builder a remote root and HostContext, and sends the first tree. That tree must arrive within 2 seconds. The Preact entry point has its own mount; a screen uses one or the other.

onTeardown(listener)

Runs when Brydio stops the screen. Use it to release local resources. Calls started during teardown will not receive an answer.

@brydio/api

api.projects, api.files, api.chats, and api.connections are typed calls over api/call. The app receives no token, cookie, API address, or connection credential. Each family needs projects, files, chats, or the exact connection:<name> host grant. * never grants a connection. Reads run after Brydio checks the current person. Writes wait for Allow once.

import { api } from '@brydio/api';

const projects = await api.projects.list();
const issues = await api.connections.use('github').request({
  path: '/repos/brydio/brydio/issues',
  query: { state: 'open' },
});

A connection path is relative. GET and HEAD are reads. POST, PUT, PATCH, and DELETE are approval-gated writes.

Protocol methods

MethodDirectionPayloadResult or effect
worker/readyapp to BrydioWorkerReadyParams: protocol, app name/version, SDK and capabilitiesStarts the session; Brydio answers with host/context.
tree/mountapp to BrydioTreeMountParams: root id and the complete first node listReplaces the empty tree. It must arrive inside the first-tree budget.
tree/patchapp to BrydioTreePatchParams: ordered insert, remove, move, props and text operationsChanges the mounted tree. A refused operation produces tree/refused.
tools/callapp to BrydioToolsCallParams: call id, tool name and input recordtools/result or tools/error with the same id.
api/callapp to BrydioApiCallParams: one closed ApiAction and its input recordapi/result or api/error. Writes wait for Brydio approval.
data/getapp to Brydio{ collection, id } plus the envelope iddata/result with one record, or data/error.
data/listapp to Brydio{ collection, filter?, sort?, limit?, cursor? } plus the envelope iddata/result with one page, or data/error.
data/subscribeapp to BrydioDataWatchParams: collection, plus the envelope iddata/result starts the watch; changes arrive as data/changed.
data/unsubscribeapp to BrydioDataWatchParams: collection, plus the envelope iddata/result after the host stops that watch.
ui/navigateapp to BrydioUiNavigateParams: a chat, file, project, or app item targetui/result with { opened }, or ui/error.
ui/toastapp to BrydioUiToastParams: text and optional toneNo reply. Brydio shows the sentence in its own toast.
host/membersapp to Brydio{ ids? } plus the envelope idhost/result with visible member names, or host/error.
host/projectsapp to Brydio{ ids } plus the envelope idhost/result with visible project names, or host/error.
ui/messageapp to Brydio{ text, target? } plus the envelope idui/result after Brydio opens or appends to a chat, or ui/error.
tree/ackapp to Brydio{ node, name } after the event handler startsNo reply. It lets Brydio clear the event budget.
dev/updatedapp to BrydioDevUpdatedParams: build numberNo reply. The development host keeps the worker.
dev/restartapp to BrydioDevUpdatedParams: build number and reasonNo reply. The development host replaces the worker.
host/contextBrydio to appHostContext: theme, locale, placement, instance, selection and sizeResolves connect() the first time and notifies context subscribers later.
tree/eventBrydio to appTreeEventParams: node id, event name and optional detailRuns the element handler. An ack-capable worker sends tree/ack.
tree/refusedBrydio to appTreeRefusedParams: operation, optional node and reasonNotifies refusal listeners. The third refusal stops the app.
tools/resultBrydio to appToolsResultParams: call id and ToolResultResolves tools.result; tools.call rejects if isError is true.
tools/errorBrydio to appToolsErrorParams: call id and JSON-RPC errorRejects the matching tool call with HostError.
api/resultBrydio to app{ id, result }Resolves the matching @brydio/api call.
api/errorBrydio to app{ id, error }Rejects the matching @brydio/api call with HostError.
data/resultBrydio to appDataResultParams: request id and resultResolves a get, list, subscribe or unsubscribe request.
data/errorBrydio to app{ id, error }Rejects the matching data request with HostError.
data/changedBrydio to appDataChangedParams: collection and id/op/version changesCalls every listener for that watched collection.
data/endedBrydio to appDataEndedParams: collection and reasonEnds that watch and calls its onEnd listeners.
ui/resultBrydio to appUiResultParams: request id and resultResolves the matching navigation or message request.
ui/errorBrydio to app{ id, error }Rejects the matching UI request with HostError.
host/resultBrydio to app{ id, result }Resolves the matching member or project name request.
host/errorBrydio to app{ id, error }Rejects the matching host request with HostError.
dev/updateBrydio to appDevUpdateParams: new entry URL and build numberThe worker answers dev/updated or dev/restart.
worker/teardownBrydio to appNo required fieldsRejects pending work with TeardownError, runs teardown listeners, and stops.

Limits

LimitValueWhat happens
One message512 KBBrydio stops the app rather than reading it.
Refusals3The third refused tree operation stops the app.
Loading the code10 sFrom the frame appearing to worker/ready.
First tree2 sFrom worker/ready to tree/mount.
A node's id128 charactersLonger ids are refused.
A toast200 charactersLonger text is cut.

Calls per minute are Brydio's limit, not an SDK constant. An administrator sees the rate in app activity. A rate refusal is a HostError with a message written for the builder.