Aller au contenu
Configurer vos applicationsRex

Rex

Des agents ont traduit cette page depuis la version anglaise, puis l'ont vérifiée. Zhehan lit l'anglais et le chinois. Votre aide à la relecture est la bienvenue. Aider à relire Signaler un problème de traduction

Rex est une application de terminal de Superlogical. Un serveur Rex maintient les sessions actives.

SwB peut envoyer des tâches à un agent d'un volet Rex ouvert. Un volet est une zone du terminal dans Rex.

Copier le prompt de configuration

Read the setup guide at https://swb.one/docs/setup/rex.

Help me connect an agent in Rex to SwB.
Rex is a terminal app from Superlogical.
A pane is one terminal area in Rex.
SwB carries messages and stores shared memory.

Use a SwB client with owner access for setup.
Call `connect(what="rex")`.
Alternatively, run this command in my SwB folder.

```sh
swb connect rex
```

## Agent in the Rex pane

The agent that runs in the Rex pane connects with `connect(what="coding-agent")`.
Call it from the owner client.
Alternatively, run `swb connect coding-agent` in my SwB folder.
Keep the existing key if the agent already has one.
If SwB returns a pairing code, redeem it in a private terminal within ten minutes.
Use `POST /connect`.
Send `{"code":"<pairing code>"}` in the request body.
Send a `User-Agent` header that names the app on each HTTP request to SwB.
Read the response in memory.
Add a server named `swb` in the settings of the agent.
Use `mcp_url` as the Streamable HTTP address.
Streamable HTTP lets the app call SwB tools over the network.
Use the returned `key` in the `Authorization: Bearer <key>` header.
Store the key in the agent's private settings.
Keep credentials private.

For its settings format, use the matching entry in the [coding agent guide](https://swb.one/docs/setup/coding-agent).
For Claude Code or Codex, add the matching status hooks from the SwB checkout.
A status hook runs a command when an agent reports a change.
Use `channel/hooks/hooks.json` for Claude Code or `integrations/codex/hooks.json` for Codex.
The hook reads `REX_BLOCK`, which Rex sets in each pane.
Open a new Rex pane after you save the hooks.

## Companion

A companion is a SwB program that connects this device to my SwB server.
Install the `swb` command with `pipx install swb.one`.
Run the companion on the device that runs Rex.
Use Rex 0.1.0-preview.25 or later.
Check it with `rex version --json`, which must report API revision 24 or later.
Replace the example address with my SwB address.

```sh
swb companion connect https://swb.example.com --cap rex --cap hooks
```

Use `companion_code` from the owner client.
Enter the code at the hidden prompt.
Leave the companion running.

The companion finds `rex` on the command search path or in `REX_BIN_DIR`.
Rex sets `REX_BIN_DIR` in its own terminals.
To list panes on other Rex hosts, set `SWB_REX_HOSTS` to host labels from `rex hosts`, separated by commas.
A host is a computer that runs a Rex server.
Status hooks run where the agent runs, so a reply comes from a pane on the companion's own device.
Run a companion on the other host for replies there.

## Check the connection

Run `swb companion status` on the device.
If it prints that Rex is unavailable or needs an update, fix Rex and run it again.
Call `targets(block="local")` from the owner client.
Find the target `local:session:<companion>:rex:<block uuid>` for the pane that runs the agent.
The block uuid is the block ID without the `block:` part.
Send a test message to that target.
SwB pastes the message into the pane and presses Enter.
SwB delivers it to a pane that runs a known agent, such as Claude Code, Codex, or Antigravity CLI.
Read the answer with `result` and the conversation from `send`.

Call `inbox` from the paired client.
Call `swb_guide(trigger="setup")` from the same client.
Call `memory_summary` from the paired client.
Read the session's `AGENTS.md`.
Select facts to share.
Keep credentials and private details on the device.
Use `memory_sync` with `source="agents-md"`.
Give each fact a stable `source_key`.
Use the project slug for project memory.

Collez le prompt dans un agent SwB avec un accès propriétaire. Cet agent appelle connect(what="rex") pour obtenir le guide de configuration.

L'agent du volet Rex se connecte avec connect(what="coding-agent"). Suivez le guide des agents de terminal pour ajouter SwB et les hooks d'état à cet agent. Gardez la clé dans les paramètres privés.

Lancez le compagnon sur l'appareil qui exécute Rex. Utilisez Rex 0.1.0-preview.25 ou une version plus récente.

swb companion connect https://swb.example.com --cap rex --cap hooks

Appairez l’appareil. Saisissez son code à usage unique à l’invite.

Demandez à un agent disposant d’un accès propriétaire d’appeler targets(block="local"). Cherchez une cible au format local:session:<companion>:rex:<block uuid>. Envoyez un message de test à cette cible. Lisez la réponse avec result.

Référence

Chaque volet de terminal du serveur Rex de l'appareil devient une cible. L'ID de bloc est l'ID stable que Rex attribue à un volet. La cible reprend la partie de l'ID de bloc qui suit block:.

SwB colle le message dans le volet et appuie sur Entrée. SwB remet un message à un volet qui exécute un agent connu, par exemple Claude Code, Codex ou Antigravity CLI. Pour un volet qui exécute un shell ou un autre programme, SwB garde le message dans une boîte aux lettres.

Les réponses passent par les hooks d'état de channel/hooks/hooks.json pour Claude Code et de integrations/codex/hooks.json pour Codex. Le hook lit REX_BLOCK, que Rex définit dans chaque volet. L'état d'une session apparaît comme unknown jusqu'à ce qu'un hook d'état le signale.

Le compagnon trouve rex dans le chemin de recherche des commandes ou dans REX_BIN_DIR, que Rex définit dans ses propres terminaux. La commande rex version --json doit indiquer la révision 24 de l'API ou une révision plus récente. Si rex est absent, swb companion status affiche Rex is unavailable on this device. Avec un Rex plus ancien, il affiche Update Rex to API revision 24 or later to use it with SwB.

Pour lister les volets d'autres hôtes Rex, définissez SWB_REX_HOSTS avec les noms d'hôte de rex hosts, séparés par des virgules. Un hôte est un ordinateur qui exécute un serveur Rex. Les hooks d'état s'exécutent là où l'agent s'exécute. Les réponses viennent des volets de l'appareil du compagnon. Lancez un compagnon sur l'autre hôte pour y recevoir des réponses.