Skip to content

Another Context Code from here

Your terminal can talk to the Context Code on another machine: the one at home from the office, the one on the server from your laptop. It’s exactly what the phone does when it scans the QR, but from a console.

The turn isn’t run by your machine: it’s queued over there, with the files and projects over there. You see what happens and decide what needs deciding.

Ventana de terminal
# On the OTHER machine (the one with the agent and the projects):
contextcode serve --print-qr --public
# Here, with the URL it printed (it carries its ?t=…):
contextcode remoto agregar casa "https://algo.trycloudflare.com/?t=TOKEN"
contextcode remoto listar
contextcode remoto probar casa
contextcode chat --remoto casa

It also accepts the address and the token separately, or with no scheme:

Ventana de terminal
contextcode remoto agregar vps 192.168.1.5:8787 --token TOKEN
  1. /api/version is called, the only public route. It separates two problems that look alike and have opposite remedies: “I can’t reach that machine” and “I reach it, but the token isn’t valid”.
  2. The credential is validated with a call that changes nothing.
  3. The link token is exchanged for a device token. From then on, the QR token isn’t stored: keeping it would leave a live credential on your disk that would survive revocation.

The registry lives in ~/.context/remotos.json, with 0600 permissions where the system allows it. contextcode conexion tells you the exact path.

CredentialWhere it comes fromHow long it lastsHow it’s withdrawn
Link tokenGenerated by serve; it’s what goes inside the QRFrom 1 minute to 30 daysBy rotating it: they all fall at once
Device tokenRequested once, presenting the link tokenDoesn’t expireOne by one, without touching the others

The QR is the door, not the key. That’s why the link can be short-lived without forcing you to rescan every day, and why losing a phone doesn’t kick the others out.

Ventana de terminal
contextcode chat --remoto casa # creates a new chat
contextcode chat --remoto casa --proyecto "Mi app" # in that project (id or name)
contextcode chat --remoto casa --chat chat-a1b2 # continues an existing one
contextcode chat --remoto # the active remote

You’ll see the same as in a local chat — live text, tools, result — because they’re the same engine events, followed by polling the timeline on the other side.

When the agent on the other machine asks permission to use a tool, the question shows up in your console ([s/N/siempre]) and your answer unblocks it. Without that, the turn would wait indefinitely for someone sitting in front of that machine — which is exactly what you’re avoiding.

The agent keeps working over there. The command tells you which line to use to get back in (--chat <id>) to pick up the answer when you return.

remoto versus the desktop’s SSH workspaces

Section titled “remoto versus the desktop’s SSH workspaces”

They don’t compete: they solve different cases.

contextcode remotoSSH workspace (desktop window)
Who uses itThe terminal, on any systemThe desktop application
TransportDirect HTTP against the servessh -L and HTTP through the tunnel
CredentialQR token → device tokenYour SSH keys
Needed on the servercontextcode serve already runningSSH access and the binary installed
Crosses the internetYes, with serve --publicYes, if SSH is reachable

On your own VPS with SSH, the desktop uses the SSH workspace. To get there from a terminal — or from a machine where your keys aren’t — the way is remoto against serve --public.

If you used an SSH workspace and it cut out every so often, this was why: home NATs and some VPNs only count visible TCP traffic and recycle idle sessions, even though SSH is sending its own encrypted probes inside.

Now the connection carries keep-alive on both layers (ServerAliveInterval=15 with ServerAliveCountMax=3 in SSH, and TCPKeepAlive=yes in TCP). And if it still drops:

  • The application detects the tunnel is dead and goes back to working locally on its own, instead of chaining three-second waits per command against a connection that no longer exists.
  • Remote chats tolerate outages of more than two minutes, retrying with growing waits, before giving up.
What you seeWhat’s going on and what to do
“Your computer rejected this link: it has expired”The link expired or was regenerated. Generate a new one and scan again.
“Your access was revoked”That device was revoked from the other side. Scan a new QR.
“Could not reach” and the PC is onThe local network QR points to an internal IP. Get on the same network, or ask for the tunnel QR with --public.
A VPS’s QR doesn’t workWithout --public, the link points to a data-center IP your phone can’t reach.
conexion says “the keychain didn’t return its token”Server with no system keychain: use serve --token-file <path> to have a stable token.