Skip to content
Docs

Compute

Compute runs typed work wherever it fits: in the app, in a browser worker, or on an always-online server. Each piece of work is an operation, a typed action with a key, an input schema and an output schema.

Three kinds of caller start an operation:

  • A person runs one from a button or the command palette.
  • An agent calls one as a tool.
  • A trigger runs one when something happens in the space or outside it.

The same operation reads and writes the space’s objects the same way wherever it runs. Each run is a process, and the process manager starts it in the app or on EDGE.

A person, an agent and a trigger each start an operation; the process manager runs it as a process in the app or on EDGE; the process reads and writes ECHO objects and writes its trace to the space.A person, an agent and a trigger each start an operation; the process manager runs it as a process in the app or on EDGE; the process reads and writes ECHO objects and writes its trace to the space.

In the diagram, the top row holds the three callers, and their arrows meet at the process manager. It starts a local process in the app or a remote process on EDGE. Either process reads and writes the space’s ECHO objects, and writes what it did to the trace feed.

Compute has four parts, and each has a page of its own:

  • Operations covers the unit of work. You define an operation once, by its key and its schemas, and a handler does the work. Callers find it by key, and the invoker checks the input and output against the schemas.
  • Processes covers one run of an operation. A process gets the services its operation declares, such as the space’s database, storage of its own and the space’s secrets. It has a state that the app can watch, and it can hibernate while it waits and resume later, on the same device or on EDGE.
  • Triggers covers what starts an operation without anyone asking. A trigger is an ECHO object. It fires on a schedule, when objects matching a query change, or when a feed gets new items. It also fires when an email or an HTTP request arrives, or when something invokes it directly.
  • Traces covers the record of what a process did. Durable trace events are kept in a feed in the space. Live progress goes to the devices watching.

Agents. An agent is a process too, a model in a loop that calls operations as tools. By default an agent’s chats run on EDGE, so the agent keeps working while every device is offline. It reaches models through EDGE’s AI service. See SAGE’s Agents and Models.

Sandbox builds and the plugin registry. When you publish a plugin, EDGE can build it in a sandbox with the @dxos/* packages installed. The plugin registry is the EDGE service that indexes published plugins and hosts their bundles, which Composer loads. See Publishing a plugin.

Compute runs in three places:

Where What runs there While
The app Operations people invoke, local triggers, and chats that are not an agent’s The app is open
A browser worker in the app Code that agents write in code mode, on its own ECHO client The app is open
EDGE Remote triggers, operations deployed to EDGE, and agents’ chats Always, whether a device is online or not

The app shows local and EDGE processes in one list. See Processes.

  • Operations and agents act through the same APIs as a device. Their changes replicate to members like anyone else’s.
  • On EDGE, operations run in Cloudflare Workers that EDGE keeps for them, and each agent’s process runs in a Durable Object of its own.
  • A process on EDGE that hibernates is written to storage. It resumes when its alarm fires or its child process finishes.
  • Compute on EDGE reads space content, so it runs only for spaces that give EDGE more than pull access, the lowest access level. See HALO’s Spaces and membership.
  • The AI service sends prompts and space content to the model provider a request names.
  • An operation that runs on EDGE needs every ECHO type it uses to be known there. Its definition lists them.