Terminal Channel: Context, Connections and Files
Status: design, 2026-12-04; the owner decided the questions of section 6 the same day. Nothing here is built. This document says how a run started from orquelo tui gets its context
Status: design, 2026-12-04; the owner decided the questions of section 6 the same day. Nothing here is built. This document says how a run started from orquelo tui gets its context, how a local and a remote terminal differ, and how files move in both directions. Section 6 records the owner's decisions. Related: terminal UI · client protocol · context assembly · sigils · ADR 0012.
1. The terminal is a connection, not a plugin
The Host keys a run's context by connection: the channel name, reply_format, the locale, which directives are visible (allow_paths), the session and its history, and where replies are delivered. A plugin is only where those defaults come from.
The TUI speaks httpapi v2, so it needs no Transport plugin of its own. It gets its own httpapi connections, separate from the app's, so its context can say "terminal" without a client branch in the Host:
| Connection | Listener | Who | allow_paths | Default |
|---|---|---|---|---|
terminal | loopback only | the local operator, through the local credential (terminal UI 6.4) | on | on in every new configuration |
terminal-remote | the network address the operator chooses | paired devices (ADR 0015) | off | off; the operator turns it on |
They are two connections because allow_paths must differ. A path a local TUI sends names a file on the Host's own disk; one from a remote TUI names a file on another machine, which the Host cannot read.
What is built today and what is missing:
- ◆Channel name:
channelis the transport plugin's name (internal/host/engine/situation.go), so a terminal run would sayhttpapi. Gap C1. - ◆Reply format: httpapi's manifest says "Markdown text to an API client" for every instance. Gap C2.
- ◆Already per connection:
allow_paths(internal/config),session_scope, the connection's locale, and the directive rules of sigils section 7.
2. What a terminal run's context holds
| Fact | Local terminal | Remote terminal-remote | Source |
|---|---|---|---|
channel | terminal | terminal | C1 |
reply_format | Terminal Markdown, about 100 columns, files saved on the person's machine (section 2.1) | the same | C2 |
questions | A question opens a dialog where the run stopped; it is also shown in the person's other linked channels | the same | the transport's QuestionPolicy, which httpapi answers from an instance option (C2) |
| Chat | direct; chat_id is the conversation | the same | built |
| Sender | The local operator, the console's local user | The paired device's user | built: static token, pairing |
| Workspace | The directory orq started in (workspace.path), if the workspace policy allows it | The Host's workspace for the conversation: a named workspace or scratch; never a path on the client | built: WorkspaceRequest, allow_paths |
| OS, shell, paths | The machine the person sits at, which is the Host's | The Host's, which the context says plainly | built: the workspace provider's environment item |
| Instruction files | The repository's instruction files, by the existing project rule (listed, read before working there) | The same, for the Host's checkout | built: instruction_files_not_shown, P83 |
| Locale | The terminal's language (LANG, or Windows' UI language) as the explicit request preference | the same | gap C3 |
| Time zone | The client machine's zone | the same | gap C3 |
| History | The session of (terminal, conversation): history, summaries, compaction, /new, /compact, as on every channel | the same | built |
| Memory | The person's memories; shared with Feishu and the app once the accounts are linked (orquelo identity link terminal:local feishu:<id>) | the same | built: ADR 0012, memory scopes |
| Directives | /, @, $, and ! for the owner, since allow_paths is on | /, @, $; no ! | built: sigils section 7 |
Locale and time zone are separate facts: neither is inferred from the other, and neither changes the person's identity or grants.
2.1 Reply format
The terminal and terminal-remote instances set it as an instance option (C2):
Replies are shown in a terminal about 100 columns wide that renders Markdown: headings, bold, lists, code blocks and tables. Keep tables narrow, and send wide ones as files. Images do not show inline; send them as files, which are saved on the person's computer. Links are shown as text the person can open.
2.2 Conversations and workspaces
- ◆
orqstarts a new conversation. Its id is made by the TUI, and httpapi keeps a device's conversations under<user>:as it does today. - ◆A conversation is bound to the workspace of its first message. Starting
orqin another directory starts another conversation. - ◆
orq -ccontinues the latest conversation whose workspace is the current directory. That needs/v1/conversationsto report each conversation's workspace and take?workspace=(C4).
2.3 Other channels' conversations
The picker and the inbox list the person's conversations on every linked channel, as built.
- ◆Follow. Opening a Feishu conversation follows its runs and answers its questions, read-only. A message typed there is not posted to Feishu: the TUI's messages belong to its own connection.
- ◆Continue here. Ctrl+N on a followed conversation starts a terminal conversation that carries the other conversation's recent turns as its channel context (
<orq:chat>, built for the Feishu twin's threads). Only conversations of the same person can be carried (C6).
3. Local and remote
| Concern | Local | Remote |
|---|---|---|
| Finding the Host | data/local-client.json; started when down | orq -host URL; never started |
| Authentication | Per-start local token, owner-only file, no pairing | Paired-device token; revoking the device closes its streams |
| Transport | http://127.0.0.1:<port>, plain HTTP on loopback | HTTPS required; plain HTTP only to loopback addresses |
| Workspace | The current directory | The Host's workspace for the conversation |
@ file mentions | The local file index | Off. The Host's files are reached through the agent's tools, not by mention |
| Sending files | Path or upload (section 4.1) | Upload only |
| Receiving files | Download to the local folder (section 4.2) | The same, resumable (C7) |
| Changes | The checkout on this machine: real files, the diff in the TUI | The Host's checkout: the diff in the TUI; applying it locally is the person's choice (d saves a patch file) |
! shell | For the owner, as in the console | Not offered |
| Clipboard | The system clipboard | OSC 52, through SSH and the terminal |
| Losing the link | Host restart: banner, replay, draft kept | The same, with back-off; a revoked device ends with a clear notice and no retry |
4. Files
4.1 From the person to a run
- ◆A file inside the workspace (local). It is not copied. The message names the path, and the run reads it where it is (C5). The chip shows "in workspace".
- ◆Any other file (local), a pasted image, or anything on a remote terminal. It is uploaded through the resumable upload of the client protocol, then attached by
upload_id. - ◆Each chip shows its own progress. A cut connection resumes from the last byte received.
- ◆A file over
upload_max_mbis refused before any byte is sent. - ◆A file is attached when its upload completes. Sending before then waits for it, and the message never goes out with a half file.
- ◆A dropped path. Terminals paste a dropped file as its path. The TUI turns a path that names a readable file into a chip; anything else stays text.
- ◆Attachments start a run. A message with files starts a new run queued behind the active one, as on every channel (ADR 0006); text alone steers.
4.2 From a run to the person
- ◆Delivered files. The run's artifacts reach the terminal connection as file messages (
message.createdwithfile). The TUI saves each one to<download folder>/orquelo/<conversation>/<run>/<name>and shows it with o open, c copy path, s save into the workspace. - ◆The download folder is the system's Downloads folder unless the person sets another in the TUI's own settings.
- ◆Names are cleaned (no path separators, no
.., no control characters). An existing file is never overwritten: the next free namename (2).extis used. - ◆Files are only opened with the system's default app on o, and never run.
- ◆Size. Files up to 20 MB are saved as they arrive. Larger ones show their size and wait for d. Downloads resume with
Rangeafter a cut (C7). - ◆When the TUI was closed. History replays the file messages, and the TUI fetches the files when it shows them. Nothing is lost by detaching.
- ◆Delivery is the Host's, saving is the TUI's. A file message counts as delivered when it is stored for the connection, as for every channel. A failed save on the person's machine is retried by the TUI from
/v1/artifacts/{id}. It never reruns the run and never changes the delivery's state. - ◆Files changed in the workspace are not artifacts. They are already where the run wrote them, and the TUI shows them as the run's changes (
/v1/runs/{id}/diff).
5. Host gaps
| # | Gap | Proposal |
|---|---|---|
| C1 | channel is the plugin's name | An optional transport interface, ChannelKind() string, beside SelfIdentifier; httpapi answers with an instance option channel (terminal). Generic: any instance can name its kind |
| C2 | One reply_format for every httpapi instance, and no questions text | httpapi implements the existing ReplyFormatter and QuestionPolicy from instance options reply_format and questions |
| C3 | No locale or time zone from the person | POST /v1/messages takes locale (BCP 47) and timezone (IANA). Locale becomes the explicit request preference of the locale contract; the time zone replaces the agent's default in the run's baseline. Both are validated, and neither is trusted for identity |
| C4 | Conversations do not show their workspace | /v1/conversations returns workspace and accepts ?workspace= |
| C5 | Attachments are uploads only | attachments: [{path}] accepted only on a connection with allow_paths, for files the workspace policy lets the run read; refused elsewhere with attachment.path_not_allowed |
| C6 | No context from another channel's conversation | context_from: {connection, conversation} on POST /v1/messages: the Host fills the event's channel context from that conversation's recent turns when it belongs to the same person, else conversation.unknown |
| C7 | Artifact downloads cannot resume | GET /v1/artifacts/{id} honours Range |
C1 adds an optional plugin interface, so it needs an ADR, which can share one with G1 of the terminal UI. None of the gaps adds a client branch to the Host.
6. Owner decisions
Decided 2026-12-04:
- ◆Every new configuration ships
terminal;terminal-remoteis off by default. - ◆Delivered files go to the system's Downloads folder, under
orquelo/<conversation>/<run>/. - ◆A delivered file over 20 MB waits for d.
- ◆"Continue here" (C6) carries a followed conversation's recent turns into a new terminal conversation.
7. Verification
When built:
- ◆Interface cases on
terminal: context fields (channel, reply format, locale, time zone, workspace);!visible locally and refused remotely; a path attachment accepted locally and refused remotely. - ◆A real-model e2e case through the TUI (PTY) with an uploaded file and a delivered file saved locally.
- ◆A failure case: a download cut mid-file resumes, and the run is not repeated.