@limccn/tokimeki-dsh 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,170 @@
1
+ # Scenario: phone → home-NAT ACP through the TokiAPI web viewer
2
+
3
+ Use this when the ACP program (for example Claude Code) runs on a home machine
4
+ behind broadband NAT, and the viewer is a phone browser. The phone never
5
+ touches the home router: TokiAPI and the tokimeki relay carry the session.
6
+
7
+ ```text
8
+ home PC (behind NAT) internet phone
9
+ ┌──────────────────────┐ ┌───────────────┐ ┌──────────────┐
10
+ │ tokimeki host │ wss │ relay │ wss │ TokiAPI web │
11
+ │ `tokimeki claude` ├─────────►│ relay.tokiapi │◄──────┤ viewer │
12
+ │ live PTY / Claude │ │ .app │ │ (xterm.js) │
13
+ └──────────────────────┘ └───────────────┘ └──────────────┘
14
+ ```
15
+
16
+ ## What works — and what does not
17
+
18
+ - **No port forwarding.** The host only makes outbound `wss://` connections.
19
+ - **The browser viewer is relay-only.** TokiAPI's WS proxy strips TURN
20
+ credentials, so a browser viewer never uses P2P or TUN. P2P/TURN/TUN are
21
+ for CLI viewers on desktops or laptops.
22
+ - **TokiAPI owns the browser flow.** The phone opens a TokiAPI share URL; the
23
+ relay and the browser viewer are bound to the TokiAPI provider
24
+ (`wss://relay.tokiapi.app`). A self-hosted relay without a TokiAPI web
25
+ viewer needs a CLI viewer instead.
26
+ - **The viewer can type.** Unless the invite is a listener invite, the phone
27
+ has the same shared control as any other viewer. Set a passcode when the
28
+ link may be forwarded.
29
+
30
+ ## Prerequisites
31
+
32
+ On the home host:
33
+
34
+ - Node.js >= 22.12 and npm >= 11.
35
+ - `tokimeki` CLI >= 0.1.5 (0.1.7 is current):
36
+ `npm install -g @limccn/tokimeki`.
37
+ - The ACP program itself, for example the `claude` CLI, installed and
38
+ authenticated on that host. Verify with `claude --version`.
39
+ - A relay credential:
40
+ - TokiAPI account: Host JWT + namespace, or a downloaded
41
+ `tokimeki-config.json`; or
42
+ - TokiAPI anonymous: 4-character namespace + 24 h Host JWT; or
43
+ - self-hosted relay: namespace token + namespace.
44
+
45
+ On the phone:
46
+
47
+ - A modern browser.
48
+ - The TokiAPI share URL for this session (a capability secret).
49
+
50
+ ## 1. Preflight on the home host
51
+
52
+ ```bash
53
+ tokimeki --version
54
+ tokimeki doctor
55
+ ```
56
+
57
+ `tokimeki doctor` exits 1 until relay/credential configuration exists; that is
58
+ expected before step 2. Do not paste tokens or the invite URL into a chat
59
+ window.
60
+
61
+ ## 2. Start the host
62
+
63
+ Account / downloaded config:
64
+
65
+ ```bash
66
+ tokimeki --config tokimeki-config.json claude
67
+ ```
68
+
69
+ Account with environment credentials:
70
+
71
+ ```bash
72
+ export TOKIMEKI_RELAY_URL='wss://relay.tokiapi.app'
73
+ export TOKIMEKI_TOKEN='<host-jwt-or-namespace-token>'
74
+ export TOKIMEKI_NAMESPACE='<namespace>'
75
+ tokimeki claude
76
+ ```
77
+
78
+ Anonymous:
79
+
80
+ ```bash
81
+ export TOKIMEKI_RELAY_URL='wss://relay.tokiapi.app'
82
+ export TOKIMEKI_TOKEN='<anonymous-host-jwt>'
83
+ export TOKIMEKI_NAMESPACE='<4-character-namespace>'
84
+ tokimeki claude
85
+ ```
86
+
87
+ Optional passcode (the host sends only a PBKDF2 verifier):
88
+
89
+ ```bash
90
+ export TOKIMEKI_PASSCODE='<6..128 visible ASCII chars>'
91
+ tokimeki claude
92
+ ```
93
+
94
+ The host prints a startup banner with the session name, relay, viewer count,
95
+ window size, and a one-line viewer config. The default fixed TUI window is
96
+ `120x40`; the phone viewport letterboxes or crops it and follows the TUI
97
+ cursor.
98
+
99
+ ## 3. Create or copy the share URL
100
+
101
+ - **Anonymous host:** the TokiAPI anonymous flow returns an invite URL. The
102
+ host's F12 menu can show/copy it (memory-only, never saved).
103
+ - **Account host:** create an invite/share link in the TokiAPI console for the
104
+ session.
105
+ - **CLI viewer instead of a browser:** press F12 on the host and copy the
106
+ viewer config JSON, or read the banner line. Treat it as a secret.
107
+
108
+ An invite URL looks like `https://tokiapi.app/#t-<code>`. The code is a
109
+ capability secret; anyone who redeems it joins the session (subject to the
110
+ passcode and role).
111
+
112
+ ## 4. Join from the phone
113
+
114
+ 1. Open the share URL in the phone browser.
115
+ 2. If TokiAPI asks for a passcode, enter the same `TOKIMEKI_PASSCODE` value.
116
+ 3. Wait for the snapshot. The browser is relay-only, so there is no P2P/TUN
117
+ negotiation to wait for.
118
+ 4. Use the terminal keyboard to type. With a fixed grid, the host PTY does not
119
+ resize when the phone rotates; the local viewport changes instead.
120
+
121
+ A TokiAPI share ticket is single-use and short-lived. After a network switch,
122
+ tab discard, or browser restart, **open the share URL again**; do not expect an
123
+ old WebSocket to reconnect with a consumed ticket. `410` means the invite is
124
+ invalid, expired, or revoked; ask the host for a fresh one.
125
+
126
+ ## 5. Verify
127
+
128
+ - The phone shows the current host screen, not a blank terminal.
129
+ - Typing on the phone appears in the hosted program.
130
+ - A second viewer sees the same screen; all viewers share control.
131
+ - After closing the phone tab and reopening the share URL, a fresh snapshot
132
+ appears.
133
+ - With `TOKIMEKI_PASSCODE` set, a wrong passcode is rejected and a correct one
134
+ is accepted.
135
+
136
+ ## Troubleshooting
137
+
138
+ | Symptom | Action |
139
+ |---|---|
140
+ | `410` on the share URL | Invite expired/revoked; create a new one. |
141
+ | `passcode_required` | Enter the host's passcode. |
142
+ | `passcode_invalid` / `passcode_locked` | Wrong passcode; 0.1.7 locks verification for 30 s after five failures. |
143
+ | `host_offline` | The home host process stopped or lost the relay; restart it and create a new invite if needed. |
144
+ | `429` | TokiAPI or the relay is rate limiting; wait and retry, do not loop. |
145
+ | Blank phone screen after reconnect | Reopen the share URL; the ticket is single-use. |
146
+ | Phone keyboard does not type | Tap the terminal first; ensure the invite is a viewer invite, not a listener invite. |
147
+
148
+ ## Security and limits
149
+
150
+ - The share URL, passcode, and viewer config are secrets. Send them through a
151
+ channel you trust; do not post them in group chats or logs.
152
+ - The relay can see terminal bytes. This scenario is not end-to-end encrypted.
153
+ - The browser viewer is relay-only; TUN/P2P do not apply to it.
154
+ - The phone and the home host share one live PTY. A viewer can type into the
155
+ same Claude Code session; use a listener invite for read-only watchers.
156
+ - TokiAPI's attach cookie is origin-wide and a pending ticket is single-use.
157
+ Treat one active share link per browser profile as the supported behavior;
158
+ opening two different links in the same profile can consume the wrong
159
+ ticket.
160
+ - Anonymous hosts expire after 24 h by default and have no revocation API;
161
+ end the session by stopping the host. Account Host JWTs default to 30 days
162
+ and have no relay-side revocation list in tokimeki 0.1.7.
163
+
164
+ ## Related
165
+
166
+ - [Usage reference](../usage.md)
167
+ - [US host running Claude Code](us-host-claude-code.md)
168
+ - [Cross-Pacific transport and encryption](transpacific-tunnel.md)
169
+ - TokiAPI web viewer contract:
170
+ <https://github.com/limccn/tokimeki/blob/main/docs/web-viewer.md>
@@ -0,0 +1,152 @@
1
+ # Scenario: cross-Pacific transport and encryption
2
+
3
+ Use this when a host and viewer sit on opposite sides of the Pacific (for
4
+ example a US host and a viewer in China) and you want the best available
5
+ transport. There is no guaranteed “stable tunnel”; the stack picks the best
6
+ path it can negotiate and falls back to the relay.
7
+
8
+ ```text
9
+ US host cross-Pacific path viewer
10
+ ┌──────────────┐ ┌──────────────────────────────────┐ ┌──────────────┐
11
+ │ tokimeki │ │ 1. direct P2P (best effort) │ │ CLI viewer │
12
+ │ host ├─────►│ 2. coturn / Cloudflare TURN UDP ├─────►│ (P2P/TUN) │
13
+ │ │ │ 3. relay WebSocket (fallback) │ │ or browser │
14
+ └──────────────┘ └──────────────────────────────────┘ └──────────────┘
15
+ ```
16
+
17
+ ## Two viewer classes
18
+
19
+ - **CLI viewer (`tokimeki attach`)** — can negotiate WebRTC P2P, TURN, and the
20
+ opt-in TUN profile. The relay is the control plane and the fallback data
21
+ path.
22
+ - **Browser viewer (TokiAPI web viewer)** — relay-only. TokiAPI strips TURN
23
+ credentials from the proxy, and the browser never runs P2P/TUN. This
24
+ scenario's TUN guidance applies to CLI viewers only.
25
+
26
+ ## Transport ladder
27
+
28
+ 1. **Direct P2P DataChannel** — lowest latency, but cross-border UDP may be
29
+ blocked, throttled, or unstable. A failed or not-yet-ready attempt takes
30
+ about 12 seconds.
31
+ 2. **TURN over UDP** — coturn first, then Cloudflare Realtime TURN. The CLI
32
+ uses TURN over UDP (libjuice); a `turn:...?transport=udp` URL is required.
33
+ 3. **Relay WebSocket** — always available. Control, signaling, auth, and
34
+ snapshots always use the relay; the relay also carries terminal bytes when
35
+ P2P/TURN is not usable.
36
+
37
+ After a failed P2P attempt, the host refreshes to the next usable TURN
38
+ provider once and retries; a second failure resumes relay output and requests
39
+ a fresh snapshot. A TURN attempt that cannot reach the server also ends in a
40
+ relay fallback. The PTY/TUI session is not terminated.
41
+
42
+ ## Encryption model
43
+
44
+ - The relay can see terminal bytes **by design** while it carries them. This
45
+ is not end-to-end encryption.
46
+ - `TOKIMEKI_TUNNEL=auto` adds an application-layer tunnel on the P2P
47
+ DataChannel: AES-256-GCM records with HKDF direction keys, selective-repeat
48
+ ARQ (window 64), and a bounded retransmission budget.
49
+ - The default `session-token` key mode derives keys from the session token.
50
+ The relay has seen that token and can derive the same keys, so this mode is
51
+ **transport hardening, not end-to-end encryption**.
52
+ - `TOKIMEKI_TUNNEL_SECRET` switches to `shared-secret` mode. The relay cannot
53
+ derive those keys, so only this mode may be called **relay-blind**.
54
+ - TUN is P2P-only in tokimeki 0.1.7. If the link falls back to the relay, TUN
55
+ is not active and the relay sees terminal bytes again. TUN never protects
56
+ the relay path.
57
+
58
+ ## Recommended configuration
59
+
60
+ Use the same settings on the host and on a CLI viewer.
61
+
62
+ ```bash
63
+ export TOKIMEKI_P2P=auto
64
+ export TOKIMEKI_TUNNEL=auto
65
+ export TOKIMEKI_TUNNEL_FEC=xor
66
+ export TOKIMEKI_TUNNEL_SECRET='<same 16+ byte secret on both ends>'
67
+ ```
68
+
69
+ - `TOKIMEKI_TUNNEL=auto` negotiates only when both peers advertise the exact
70
+ tunnel capability and the same key mode. A mismatch falls back to the relay.
71
+ - `TOKIMEKI_TUNNEL_FEC=xor` emits one AEAD parity record per full group of
72
+ eight data records. It recovers exactly one lost record; lost parity or
73
+ multiple losses stay on ARQ.
74
+ - `TOKIMEKI_TUNNEL_SECRET` must be at least 16 bytes and shared out of band.
75
+ It is scrubbed from the hosted PTY environment and redacted from logs. A
76
+ missing secret on one end prevents negotiation; different values negotiate
77
+ but fail AEAD authentication, then fall back to the relay after the failure
78
+ threshold.
79
+ - Do not put the tunnel secret in argv, chat, an invite URL, or a committed
80
+ file. Use a 0600 environment file or the process manager's secret
81
+ mechanism.
82
+ - Ensure at least one TURN URL uses UDP. `TOKIMEKI_ICE_TRANSPORT_POLICY=relay`
83
+ is for forced-TURN testing only; with no usable TURN it times out and falls
84
+ back to the relay.
85
+ - If you self-host coturn behind NAT, set `external-ip` correctly for your
86
+ provider's network model (a private mapping can break same-host relay
87
+ candidates on direct-IP hosts).
88
+
89
+ ## What to expect
90
+
91
+ - Cross-Pacific RTT dominates interactive latency. The fixed TUI window keeps
92
+ the grid stable; the local viewport letterboxes or crops.
93
+ - ARQ retransmits lost records; XOR FEC recovers only a single lost record per
94
+ group. High loss or reordering can still cause stalls, and the transport
95
+ eventually falls back to the relay.
96
+ - No direct-path success rate, long-run stability, or “stable tunnel” is
97
+ guaranteed. Cross-machine tunnel e2e (including forced loss/reorder) is not
98
+ part of the 0.1.7 automated suite; local tunnel e2e covers session-token and
99
+ shared-secret modes.
100
+ - The v1.7 line plans optional slow-P2P drain fallback and send pacing
101
+ (`TOKIMEKI_P2P_DRAIN_BYTES_PER_SEC`, `TOKIMEKI_SEND_PACE_BYTES_PER_SEC`).
102
+ These variables are **not shipped in 0.1.7**; do not rely on them yet.
103
+
104
+ ## Verification
105
+
106
+ Run with debug logs on both ends:
107
+
108
+ ```bash
109
+ export TOKIMEKI_LOG_LEVEL=debug
110
+ ```
111
+
112
+ Look for:
113
+
114
+ - a negotiated tunnel / DataChannel, or `tunnel unavailable` with a fallback;
115
+ - the `lan=yes|no` diagnostic (P2P candidate locality; diagnostic only);
116
+ - a fresh snapshot after a relay fallback;
117
+ - no token, secret, or terminal content in logs.
118
+
119
+ To compare against the relay baseline, run one session with
120
+ `TOKIMEKI_P2P=off`; the difference isolates the P2P/TURN path.
121
+
122
+ ## Troubleshooting
123
+
124
+ | Symptom | Check |
125
+ |---|---|
126
+ | Tunnel never activates | Both ends use `TOKIMEKI_TUNNEL=auto`, P2P is enabled, and the key mode matches (`TOKIMEKI_TUNNEL_SECRET` present on both or absent on both). |
127
+ | Tunnel falls back to relay | Check debug logs for `tunnel unavailable`; a wrong shared secret, high loss, or oversized frames cause fallback. |
128
+ | TURN attempt takes ~12 s | Expected when TURN is unreachable; the relay takes over. |
129
+ | P2P never opens | Corporate or ISP UDP filtering; try TURN or set `TOKIMEKI_P2P=off`. |
130
+ | Browser viewer has no P2P/TUN | Expected: the TokiAPI browser proxy is relay-only. |
131
+ | Garbled screen after reconnect | Enable debug logs and report the terminal/OS details. |
132
+
133
+ ## Security checklist
134
+
135
+ - Share the tunnel secret out of band; never in chat, argv, an invite, or a
136
+ repository.
137
+ - Treat the session token, passcode, invite URL, and viewer config as secrets.
138
+ - The relay is trusted while it carries bytes. TUN shared-secret mode is
139
+ relay-blind only while the P2P tunnel is active; a relay fallback is not.
140
+ - Use short-lived sessions, passcodes, and listener invites where appropriate.
141
+ - Tokimeki 0.1.7 has no relay-side Session JWT revocation or viewer eviction;
142
+ those are v1.8 lifecycle items, not shipped here.
143
+
144
+ ## Related
145
+
146
+ - [Usage reference](../usage.md)
147
+ - [Phone → home-NAT ACP](home-nat-mobile.md)
148
+ - [US host running Claude Code](us-host-claude-code.md)
149
+ - TUN reliability trade-off:
150
+ <https://github.com/limccn/tokimeki/blob/main/docs/tunnel-reliability.md>
151
+ - Protocol:
152
+ <https://github.com/limccn/tokimeki/blob/main/docs/protocol.md>
@@ -0,0 +1,226 @@
1
+ # Scenario: US host running Claude Code
2
+
3
+ Use this when an always-on US host (for example a VPS or a `grokbot` box) runs
4
+ Claude Code and you want to attach from a laptop or phone. The host only needs
5
+ outbound `wss://`; no inbound port or router change is required.
6
+
7
+ ```text
8
+ US host (tokimeki) relay / TURN viewer
9
+ ┌──────────────────────┐ ┌───────────────┐ ┌──────────────┐
10
+ │ `tokimeki claude` │ wss │ relay.tokiapi │ wss │ CLAUDE CODE │
11
+ │ live PTY / Claude ├─────────►│ .app │◄─────────┤ laptop CLI │
12
+ │ Code │ │ (control) │ │ or phone web │
13
+ └──────────────────────┘ └───────────────┘ └──────────────┘
14
+ ```
15
+
16
+ ## Prerequisites
17
+
18
+ - Linux host (Ubuntu/Debian or equivalent) with a stable internet connection.
19
+ - Node.js >= 22.12 and npm >= 11.
20
+ - The `claude` CLI installed per Anthropic's documentation and authenticated
21
+ on this host. Verify with `claude --version`; complete any Claude Code login
22
+ or API-key setup **before** hosting.
23
+ - A relay credential:
24
+ - TokiAPI account: Host JWT (default 30 days) + a 5-character namespace, or
25
+ a downloaded `tokimeki-config.json`; or
26
+ - TokiAPI anonymous: 4-character namespace + 24 h Host JWT; or
27
+ - self-hosted relay: namespace token + namespace.
28
+
29
+ Do not run the host as `root`. Use a dedicated user; Claude Code inherits that
30
+ user's environment and project files.
31
+
32
+ ## 1. Install the CLI and check the host
33
+
34
+ ```bash
35
+ node --version # >= 22.12
36
+ npm --version # >= 11
37
+ npm install -g @limccn/tokimeki
38
+ tokimeki --version
39
+ claude --version
40
+ ```
41
+
42
+ `tokimeki doctor` exits 1 until a relay and credential are configured; that is
43
+ expected before the next step.
44
+
45
+ ## 2. Configure the credential
46
+
47
+ ### Account path (recommended for an always-on host)
48
+
49
+ Sign in at <https://tokiapi.app>, create a Host JWT (default 30 days) and a
50
+ 5-character namespace, then either export the pair:
51
+
52
+ ```bash
53
+ export TOKIMEKI_RELAY_URL='wss://relay.tokiapi.app'
54
+ export TOKIMEKI_TOKEN='<host-jwt-or-namespace-token>'
55
+ export TOKIMEKI_NAMESPACE='<5-character-namespace>'
56
+ tokimeki doctor
57
+ ```
58
+
59
+ or download `tokimeki-config.json` and use the top-level `--config` flag:
60
+
61
+ ```bash
62
+ chmod 600 tokimeki-config.json
63
+ tokimeki --config tokimeki-config.json claude
64
+ ```
65
+
66
+ The file contains secrets; delete it when it is no longer needed. A
67
+ `--config` file that changes `relayUrl` must also contain the host credential;
68
+ never mix a file relay with an environment token.
69
+
70
+ ### Anonymous path (short-lived)
71
+
72
+ The TokiAPI anonymous flow returns a 4-character namespace, a 24 h Host JWT,
73
+ and an invite URL:
74
+
75
+ ```bash
76
+ export TOKIMEKI_RELAY_URL='wss://relay.tokiapi.app'
77
+ export TOKIMEKI_TOKEN='<anonymous-host-jwt>'
78
+ export TOKIMEKI_NAMESPACE='<4-character-namespace>'
79
+ tokimeki doctor
80
+ ```
81
+
82
+ Expiry requires a new anonymous request; the namespace/session may change.
83
+
84
+ ### Self-hosted path
85
+
86
+ Deploy the relay with the Cloudflare Deploy Button or follow
87
+ `docs/deploy-cloudflare.md` in the tokimeki repository, configure
88
+ `TOKIMEKI_NAMESPACE_TOKENS` (or the single-owner fallback), then use the
89
+ relay URL and token locally.
90
+
91
+ ## 3. Start Claude Code
92
+
93
+ ```bash
94
+ tokimeki claude
95
+ ```
96
+
97
+ - The host runs the existing `claude` binary in a live PTY. Arguments after
98
+ `claude` are passed through to Claude Code.
99
+ - `tokimeki claude --help` runs the local `claude --help` without relay
100
+ configuration.
101
+ - The default fixed TUI window is `120x40`. ACP commands (`claude`, `pi`,
102
+ `codex`, `gemini`, `cursor`, `aider`, `opencode`, `goose`, `amp`) use the
103
+ fixed window by default; viewer resizes do not change the host PTY.
104
+ - Choose a different grid **before** viewers attach:
105
+
106
+ ```bash
107
+ export TOKIMEKI_WINDOW_SIZE='140x45'
108
+ tokimeki claude
109
+ ```
110
+
111
+ - In tokimeki 0.1.7, fixed-grid hosts do not offer the live resize editor;
112
+ live fixed-grid resize is planned for a later release. Non-fixed
113
+ `latest`/`min`/`pinned` hosts can resize through the F12 menu.
114
+ - Press F12 for the connection menu: status, show/hide session token, copy
115
+ viewer config (OSC 52), anonymous invite URL, log view. F12 bytes never
116
+ reach Claude Code.
117
+
118
+ If the host is not attached to a terminal, run it in daemon mode:
119
+
120
+ ```bash
121
+ tokimeki --daemon claude
122
+ ```
123
+
124
+ Daemon mode writes structured events to stderr as one-line JSON prefixed
125
+ `tokimeki-event: ` (`ready`/`status`/`error`/`report`); stdout stays terminal
126
+ bytes. Do not merge stdout and stderr when parsing events.
127
+
128
+ ## 4. Run it as a service (systemd example)
129
+
130
+ The CLI does not install or supervise services. Use your own process manager.
131
+ A minimal systemd unit:
132
+
133
+ ```ini
134
+ [Unit]
135
+ Description=tokimeki host for Claude Code
136
+ After=network-online.target
137
+ Wants=network-online.target
138
+
139
+ [Service]
140
+ Type=simple
141
+ User=<user>
142
+ WorkingDirectory=/home/<user>
143
+ EnvironmentFile=/home/<user>/.tokimeki/host.env
144
+ ExecStart=/usr/local/bin/tokimeki --daemon claude
145
+ Restart=on-failure
146
+ RestartSec=5
147
+ KillSignal=SIGTERM
148
+
149
+ [Install]
150
+ WantedBy=multi-user.target
151
+ ```
152
+
153
+ - `ExecStart` must be the absolute path from `command -v tokimeki`.
154
+ - `host.env` is a 0600 file with `KEY=value` lines, no `export`. Do not put
155
+ the Host JWT in the unit file or in `ExecStart`.
156
+ - Logs go to the journal. The service user must own the Claude Code workspace.
157
+
158
+ ## 5. Attach
159
+
160
+ Desktop CLI:
161
+
162
+ ```bash
163
+ tokimeki attach "https://tokiapi.app/#t-<code>"
164
+ # or: TOKIMEKI_ATTACH_URL='https://...#t-<code>' tokimeki attach
165
+ ```
166
+
167
+ Environment attach:
168
+
169
+ ```bash
170
+ export TOKIMEKI_RELAY_URL='wss://relay.tokiapi.app'
171
+ export TOKIMEKI_SESSION='<session-name>'
172
+ export TOKIMEKI_SESSION_TOKEN='<session-token>'
173
+ tokimeki attach
174
+ ```
175
+
176
+ Phone: use the TokiAPI web viewer; see
177
+ [phone → home-NAT ACP](home-nat-mobile.md). The browser is relay-only.
178
+
179
+ Read-only listener:
180
+
181
+ ```bash
182
+ tokimeki attach --listen
183
+ ```
184
+
185
+ ## 6. Verify
186
+
187
+ - `tokimeki doctor` reports the relay/credential state without printing the
188
+ token.
189
+ - Viewers see the Claude Code screen and can type; the host PTY keeps the
190
+ chosen fixed grid.
191
+ - A reconnect requests a fresh snapshot; the Claude Code process keeps
192
+ running.
193
+ - Daemon logs show `ready` and viewer status events.
194
+
195
+ ## Troubleshooting
196
+
197
+ | Symptom | Action |
198
+ |---|---|
199
+ | `401 unauthorized` | Check relay URL, Host JWT/namespace pair, and `<namespace>.<slug>` session prefix. Run `tokimeki doctor`. |
200
+ | `host_offline` | The host service stopped or lost the relay; check `systemctl status` and journal. |
201
+ | `session_full` | Concurrent client/listener limit; close unused viewers or raise relay limits. |
202
+ | `jwks_unavailable` (503) | Relay cannot fetch JWKS; retry later. |
203
+ | Fixed window looks cropped | The local viewer is smaller than `120x40`; enlarge it or start the host with a smaller `TOKIMEKI_WINDOW_SIZE`. |
204
+ | Cannot resize the fixed window | Expected in 0.1.7; choose the size before viewers attach. |
205
+ | TURN attempt takes ~12 s | Expected when TURN is unreachable; relay takes over. |
206
+
207
+ ## Security and limits
208
+
209
+ - The Host JWT defaults to 30 days and has no relay-side revocation list in
210
+ tokimeki 0.1.7. A leaked token is valid until expiry; rotate by issuing a
211
+ new token or changing the signing key, then restart hosts.
212
+ - The relay can see terminal bytes. P2P/TURN change the transport, not the
213
+ trust model; this is not end-to-end encryption.
214
+ - Viewers can type into the same Claude Code session. Use a passcode and
215
+ listener invites for observers.
216
+ - Anonymous hosts expire after 24 h; account hosts can outlive them.
217
+ - `TOKIMEKI_TOKEN`, session tokens, passcodes, invite URLs, and viewer config
218
+ JSON are secrets. Keep them out of argv, chat, logs, and committed files.
219
+
220
+ ## Related
221
+
222
+ - [Usage reference](../usage.md)
223
+ - [Phone → home-NAT ACP](home-nat-mobile.md)
224
+ - [Cross-Pacific transport and encryption](transpacific-tunnel.md)
225
+ - tokimeki CLI reference:
226
+ <https://github.com/limccn/tokimeki/blob/main/docs/cli.md>