Skip to content
pi-c Artifact [6349dba253]
Login

Artifact [6349dba253]

Artifact 6349dba25352ff7a89536ef3aa8377a605e94c18644108cc630075430081e970:


# Remote control

A conversation another pic is running can be watched and steered from a second process: another
terminal, a script, an editor, or a phone over ssh. `pic attach` shows it and `pic send` messages
it. Neither takes the conversation over: the pic running it keeps running it, and nothing listens
on a port.

## Watching: pic attach

`pic attach` follows the latest conversation of the workspace (`--session ID` for another; `-c`
says latest explicitly). It prints what has happened since the start of the conversation's latest
request, then each message, tool call and result as it is saved, and keeps going until stopped.

- The default output is Pi's JSON events, one per line, as `pic --mode json` prints them, each with
  the `seq` of the entry it came from. `--from SEQ` starts after that entry (0: from the beginning),
  so a client that reconnects with the last `seq` it saw misses nothing and sees nothing twice.
- `--format text` prints short lines instead: what you sent, the reply, each tool call and the first
  line of its result, and how each request ended.
- `--no-follow` prints what is saved and exits.

Text the model is still streaming is not shown: a reply appears when it is complete.

## Steering: pic send

`pic send steer TEXT` sends a steer to the conversation (`--session ID`, else the latest):
delivered after the running tool calls finish, as a steer typed into that pic would be. `pic send
follow_up TEXT` runs after the request ends, and `pic send abort` cancels it, even if the pic
running it dies before it has stopped. A whole Pi RPC
command works too: `pic send '{"type":"steer","message":"look at the tests"}'`.

`pic send` prints the message's state and its key, and returns as soon as the message is saved;
`--wait` waits for it to be delivered and prints the response the running pic gave. The pic running
a request in the conversation delivers it within moments, whichever way it was started: the
terminal, `pic ask`, `--mode json` or `--mode rpc`.

- A message is delivered once. Sending the same `--key` and message again (after a lost
  connection, say) changes nothing; the same key with a different message is refused.
- A message to a conversation with nothing running waits until a request runs there. It expires
  if it waits too long: 10 minutes for a steer or abort, a day for a follow-up (`--expires
  SECONDS` sets it, up to a week). An abort sent when nothing runs is refused at once.
- At most 100 messages (or 64 MB) can wait in a conversation.

## Both at once: pic attach -i

`pic attach -i` follows the conversation and acts on each line you type:

- While a request is running (started here or anywhere else), the line is a steer for it.
- When nothing is running, the line starts a request, as `pic ask --session ID TEXT` would: its
  reply and tool calls are shown as they are saved, and then `pic attach` goes back to following.
  `--model` and `--thinking` given before `attach` apply to it. The request runs in a process of
  its own, so a dropped connection does not stop it.
- `/abort` cancels the running request, whichever process runs it.

It says when each message is sent and delivered. With its input closed it waits for what it sent
to be delivered and for a request it started to end, then exits.

Starting a request here is you acting from another terminal, the same as typing `pic ask`; it is
not one conversation waking another, which pic does not do.

## From a phone

`pic attach` works over ssh, with nothing more to install:

1. On the Mac, turn on Remote Login (System Settings, General, Sharing).
2. Put the Mac and the phone on one Tailscale network (or any network that can reach the Mac).
3. From an ssh app on the phone, in the project's directory:

   `ssh mac -t 'cd ~/project && pic attach -i -c --format text'`

   (A login over ssh may not have pic on its path: name it, as `~/.local/bin/pic`.)

Watch the run, type a line to steer it, and close the connection when done; the run carries on.

## What it cannot do yet

- Start a request with `pic send`: a follow-up to an idle conversation waits until a request runs
  there (`pic attach -i` starts one).
- Reach a conversation in another workspace, or on another machine without ssh.
- Show text as it streams.