Docs / KIRI-CAPABILITIES

What Kiri can give Kitty

Source: docs/KIRI-CAPABILITIES.md

Status: research, 2026-11-29. Base origin/main 31736f2. No product code changed.
Kiri: 0.2.2 (kiri version: engine 27.5.1-compatible, Rust, linux/arm64 VM, kernel 6.18-kiri, 2 CPUs, 7.8 GiB).
Probes: scripts/kiri-probe/. Every number below comes from one of them, run on this Mac on this date.

Summary for the decision

  1. I could not run a live Kiri Share test. kiri share status answers Not signed in to Kiri Share (edge.runkiri.com). Run kiri share login. A share needs a GitHub sign-in, so I stopped at that point, as the brief said. share-smoke.sh is ready, and it refuses to run until the owner has signed in and set KIRI_PROBE_ALLOW_SHARE=1.
  2. This network blocks Kiri's control plane. The home router's Charter/CUJO filter answers runkiri.com, docs.runkiri.com and edge.runkiri.com with a redirect to block.charter-prod.hosted.cujo.io. It filters by hostname: *.runkiri.cloud, the share links themselves, sits on the same IP and works over HTTPS (HTTP/2, valid certificate). Until the domain is allowed in the router, kiri share login, kiri update --check and the tunnel's sign-in will fail from this house. The update check already fails: io: received corrupt message of type InvalidContentType.
  3. LAN exposure works today, with no Kiri account. A container published on 0.0.0.0 answered on the Mac's LAN address in 5 ms. Kitty publishes every player on 127.0.0.1 only (gamecomposer/runtime.py:602). That choice is correct and should stay.
  4. kiri usb can't help with gamepads on this Mac. kiri usb list returns No USB devices. The two gamepads paired here, an Xbox Wireless Controller and a Stadia Controller, are Bluetooth. Kitty's input path also doesn't need passthrough: the browser Gamepad API in the host player already reads them.
  5. The current video stream can't go over a tunnel. The NES player sends raw 256×240 RGBA frames at 60.1 fps over its WebSocket (templates/02-nes-local-homebrew/image/emulator-host.mjs:64). That is about 14.8 MB/s (≈118 Mbit/s) before audio. Kiri Share has a monthly data cap and a per-plan speed limit (strings in the app: "{size} left this month", "{rate} limit", "Your plan allows {limit} tunnels at once"). Remote play needs encoded media (WebRTC), which Kitty would have to build. Kiri only carries the bytes.

Recommendation: build the remote phone controller over a Kiri Share link first (feature a). It reuses the phone controller Kitty already ships, needs no media pipeline, sends a few bytes per button press, and its security model already exists on the LAN. It does need five specific changes before it is safe behind a tunnel. Next steps are at the end.


1. Inventory: every Kiri command

Source: kiri --help, the subcommand outputs, and the kiri share usage text built into the binary (strings; some of it isn't in --help). docs.runkiri.com is blocked from this network (item 2 above), so this inventory doesn't use it. The runkiri.cloud landing page loaded and is quoted where relevant.

Command What it does Account / login Limits and notes
kiri <docker cmd> (run, ps, exec, logs, stop, rm, images, pull, build, compose…) A Docker-compatible engine. The Docker CLI 29.7.2 talks to Kiri's engine at API 1.47. None Kitty's runtime adapter uses it today.
kiri daemon Runs the engine. None Log at ~/.kiri/daemon.log.
kiri bridge [--socket PATH] The WSL2 end of kiri-win.exe. None Windows only.
kiri ui [--start] [--view …] Desktop app: containers, images, volumes, networks, Share and Kubernetes pages, a vulnerability scan (Grype, runs locally), and a request inspector for shared links ("Requests to {name}", filter by path, method or status). None for local use. Share needs a sign-in. GUI. Kitty can't script it.
kiri setup [--use] [--no-agent] | --uninstall Installs Kiri as the Docker context. None Changes the host's Docker context. Owner-only.
kiri build-with docker|kiri Chooses the builder docker build uses. None The current builder is buildx kiri-build0.
kiri update [--check] Checks for and installs updates. None Fails on this network: TLS to runkiri.com is blocked.
kiri diag logs [-f] [--ui|--engine|--cli] [--errors] [-n N] Reads Kiri's logs. None Read-only.
kiri diag report [--out PATH] [--send] One redacted text file with logs, crash reports and versions. --send uploads it and returns an ID to quote. --send names you if you're signed in. Tested with --out: 71 KB. It holds container and image names (gc-<id>-nes), but no tokens, and the home folder is replaced with ~.
kiri share PORT|CONTAINER [--name N] (or kiri PORT [NAME]) Gives a local port or a container a public https link through Kiri Cloud. Yes: GitHub sign-in (share login). Lives while the command runs. Plan limits on concurrent tunnels, a monthly data cap and a speed limit.
kiri share login [--dev LOGIN] | logout | status [--json] GitHub device-code sign-in, sign-out and account state. That is the sign-in step. status is safe and read-only.
kiri share names | reserve NAME | release NAME Reserves a stable NAME.runkiri.cloud. Requests go through review. Yes Not in --help; found in the binary's usage text.
kiri k8s start [--use] | stop | status | delete A local Kubernetes cluster. None Status: not created. Not started for this report: it's heavy and changes state.
kiri k8s set --lan on|off --tls-san … --port N --lan on makes the API server and LoadBalancer services "answer on every network interface, so other devices on your network can reach them" (app text). None Affects Kubernetes only; plain containers don't need it.
kiri usb [list] | attach DEVICE | detach DEVICE USB passthrough into the VM, beta. None No USB devices. here. Earlier repo research (architecture.md) found isochronous (audio/video) USB isn't forwarded. Attaching takes the device away from macOS.
kiri machine create NAME [--distro D] | list | shell | stop | delete A long-lived Linux "machine". In practice it's a labelled container (dev.kiri.machine=<name>, bridge network, unprivileged). None One exists: gamecomposer-probe, ubuntu:24.04, up 1 day.
kiri import [orbstack|desktop-linux] … Copies images, volumes and containers from another engine. None Not relevant to Kitty.
kiri bench [--runs N] [--image] [--network] Measures container start time. None Not run: it's load, not capability.
kiri boot [--console] [--pings N] Diagnoses VM boot. None Support only.
kiri raw run | pull | images | rmi Runs an image in its own guest, without the daemon. None A possible stronger isolation boundary per run.
Local names (app setting) <name>.kiri.localhost with no setup. Optional <name>.kiri.local and <service>.<project>.kiri.local with a trusted Kiri certificate. None. Needs an admin password once (/etc/resolver/kiri.local). This Mac only. The resolver is local, so phones can't use it.

2. Tests and evidence

2.1 Kiri Share: stopped at sign-in

$ kiri share status
Not signed in to Kiri Share (edge.runkiri.com). Run `kiri share login`.
$ scripts/kiri-probe/share-smoke.sh
STOP: Not signed in to Kiri Share (edge.runkiri.com). Run `kiri share login`.
This probe does not sign in. Run it after the owner runs 'kiri share login'.

What is known without a live share (sources: the runkiri.cloud page, the app's text built into the binary, and the edge's responses):

Question Answer Confidence
URL format https://<name>-<4 chars>.runkiri.cloud, for example https://web-x7k2.runkiri.cloud (runkiri.cloud page). A reserved NAME.runkiri.cloud is optional and reviewed. Documented, not observed
HTTPS Yes. *.runkiri.cloud serves a valid certificate over HTTP/2 and HTTP/1.1. An unknown name gets 404 No tunnel here. Measured on the edge
WebSockets Unverified. The binary contains a Connection: Upgrade header string, and the edge accepts HTTP/1.1, so it's plausible. I couldn't test it without a tunnel. share-smoke.sh measures it with a WS echo. Unknown
Latency from this Mac Edge ICMP RTT min/avg/max 101 / 125 / 176 ms (an earlier run: 134 / 180 / 231). HTTPS to a missing tunnel: connect 0.11 s, TLS 0.24 s, total 0.35 s. A Hetzner IP (128.140.26.95), so most likely in the EU. A share adds Mac→edge→phone on top. Measured on the edge only
Public or protected Public. "Anyone with this link can open it while Kiri is running." The app doesn't offer a password or access list. Accountability comes from GitHub sign-in: "every link traces back to a person". Documented in the app
How long it lives While kiri share runs ("Stop it and the link goes away"). It can be paused ("nobody can open the link until you resume"). For a pod, the link ends when the pod restarts. It also stops when the monthly cap runs out ("the link stops until next month"). Documented
How to revoke Stop the kiri share process, or use Stop sharing in the app. Either "closes that tunnel… The link stops working for everyone". The app lists "every link on your account, on any computer" and can close a tunnel on another machine. Documented
Limits A concurrent-tunnel limit per plan, a monthly data cap and a speed limit. The exact numbers show only when signed in ("Sign in to see your plan"). Documented, numbers unknown
Abuse handling Kiri carries the traffic but doesn't check the content. There's an abuse report page, and taken-down sites show a notice. The page warns visitors not to type passwords on a runkiri.cloud site they don't know. Documented

2.2 Network reachability (edge-reachability.sh)

=== runkiri.com          https: failed (curl exit 35)
FILTERED by the local network: Location: https://block.charter-prod.hosted.cujo.io/warn.html?url=http://runkiri.com/
=== edge.runkiri.com     https: failed (curl exit 35)
FILTERED by the local network: Location: https://block.charter-prod.hosted.cujo.io/warn.html?url=http://edge.runkiri.com/
=== docs.runkiri.com     https: failed (curl exit 35)
FILTERED by the local network: ...
=== runkiri.cloud        https: code=200 http=2 verify=0 connect=0.128s tls=0.234s total=0.339s
=== no-such-tunnel-probe.runkiri.cloud  https: code=404 http=2 verify=0 connect=0.109s tls=0.235s total=0.352s
=== RTT to the edge (ICMP) round-trip min/avg/max/stddev = 101.289/124.672/175.590/26.648 ms

edge.runkiri.com and *.runkiri.cloud resolve to the same IP, but only the first is blocked, so the filter works by hostname (SNI). The owner must allow runkiri.com in the router's security settings before any share can sign in from this network. Guests on other networks may hit similar filters on *.runkiri.cloud.

2.3 LAN exposure (lan-exposure.sh)

One disposable alpine:latest container ran busybox httpd with a one-line static page: no game, no ROM, no manifest. It was published on 0.0.0.0:18555 and removed by a trap.

published: 0.0.0.0:18555->8080/tcp
127.0.0.1 -> 200 in 0.007081s
<LAN-IP> -> 200 in 0.005087s
listener: kiri *:18555
teardown: 0 container(s) left

A container can be reached from the LAN with no account and no Kubernetes, as long as its port is published on 0.0.0.0. Kubernetes has its own k8s set --lan on. The kiri machine instance uses the bridge network with no published ports, so it's reachable only through what you publish. All 12 running Kitty players are published on 127.0.0.1 only (inventory.sh).

2.4 USB (inventory.sh)

=== kiri usb list
No USB devices.
=== host gamepads (USB vs Bluetooth: kiri usb can only pass USB)
(no USB devices listed)
bluetooth gamepad: Stadia Controller:
bluetooth gamepad: Xbox Wireless Controller:

I didn't attach anything.

2.5 Diagnostics

kiri diag report --out <scratch> wrote 71 KB with no tokens. It holds container and image names and recent probe errors. I didn't commit or send it.

3. Mapping Kiri to Kitty

Kitty today has two parts:

  • The player. The container runs the emulator. For NES that's headless jsnes in Node, sending raw frames and PCM over ws://127.0.0.1:<port>/stream, with a loopback-only Host/Origin check. For SNES, serve.py serves EmulatorJS and the ROM at /rom to the browser, with no Host check.
  • The phone controller (desktop/virtual-controller/). A host Node process on 0.0.0.0:<port> serves a QR code and invite page. It redeems a single-use 24-byte token sent in the URL fragment, accepts only private source IPs with a matching http:// Origin, and passes through only the eight NES buttons, forwarded to the container's loopback /stream.
phone (any network)                Kiri Cloud edge              this Mac
 https://kc-ab12.runkiri.cloud ──▶ *.runkiri.cloud ──tunnel──▶ kiri share <controller port>
   POST /join (token) / wss /stream                               │
                                                                  ▼
                                                 controller service (host Node, 127.0.0.1 only)
                                                                  │ 8 button names only
                                                                  ▼
                                                 container ws://127.0.0.1:<mapped>/stream

Share the controller service's port, never a player container. The service already removes everything except button names.

What must change (small and contained, about 2–4 days with tests):

  1. Bind to 127.0.0.1 in remote mode. The tunnel connects locally, and LAN exposure isn't needed.
  2. Change the trust model. Behind a tunnel, every request arrives from a local address, so isPrivateIp() (service.cjs:306) would let the whole internet through. In remote mode the token and session have to be the only gate, with tighter rate limits.
  3. Handle the scheme and host. trustedRequest() also expects the LAN host in the Host header. The Origin check expects http://${host} (service.cjs:356,407), but a share is https://. The page also hard-codes ws:// (controller-page.html:38) and the CSP allows only ws:// (service.cjs:291). An HTTPS page needs wss:// and an https:// Origin check that uses the share hostname.
  4. Run share as a child process. Kitty starts kiri share <port>, reads the URL from its output, shows the QR code, and kills the process when the invite expires, is revoked, or the game stops. Kitty should check kiri share status --json first and send the user to sign in if needed. Kitty must never sign in for the user.
  5. Measure it. Expected input latency is RTT(Mac→edge) + RTT(edge→phone), about 100–250 ms from here to an EU edge. That's fine for menus and turn-based games, but noticeable in action games. A phone on the same LAN should stay on the LAN path.

Risks: WebSocket over Share is unverified, so this is the first thing to test. Share needs the owner's GitHub account and is subject to plan limits. Anyone who has the link before the token is redeemed can take the slot; the token is single-use and in the fragment, which reduces this. The router block on this network applies too.

b. Remote play: streaming the player to another device

What Kiri provides: an HTTPS/WSS byte pipe (Share) and LAN reachability. That's all. It doesn't provide video encoding, WebRTC, STUN or TURN.

What Kitty must build:

  • Media. Raw RGBA at 118 Mbit/s isn't viable through a capped, rate-limited tunnel, or even over Wi-Fi to a phone. There are two options:
    • WebRTC (recommended), as RFC PR #1 describes. The host's Electron player does canvas.captureStream() plus a Web Audio destination and creates an RTCPeerConnection with H.264 or VP8 at about 1–3 Mbit/s for 256×240. Input goes back over an unordered DataChannel. The media travels peer to peer (UDP), not through Kiri. Kiri Share is useful here only as the signaling channel: a WSS endpoint for offer, answer and ICE. Behind strict NATs you need a TURN server, which Kiri doesn't offer, so it's a paid service or one Kitty hosts.
    • An encoded stream over a WebSocket (WebCodecs, or MJPEG/H.264 in the container) through Share. It's simpler to signal, but it's TCP: head-of-line blocking plus the tunnel's extra hop and speed limit add jitter, and every byte counts against the monthly cap. Use it only for a demo.
  • A guest page for the browser: video element, autoplay and unmute handling, and an on-screen pad.

Effort: about 2–3 weeks for LAN WebRTC with NES, plus 1–2 weeks for internet signaling and TURN. Risks: capture and audio behaviour differ between Electron and browsers; latency is in the 150 ms range; TURN costs money and needs ops; the host must stay online.

PR #1 is an open RFC with no code and no tests. It proposes one authoritative emulator, WebRTC media plus a DataChannel for input, short-lived single-use invites, host approval, and LAN NES first. It says Kiri APIs and loopback player ports must never be exposed publicly. That matches the findings here.

How Kiri fits:

  • Phase 1 (cheapest real multiplayer): "couch-remote" multiplayer. Player 2 sees the game some other way, for example the host screen-shares on a call, and uses (a)'s remote controller mapped to controller 2. The jsnes stream would need a player field, and the bridge would tag each guest's slot. Effort: about 3–5 days on top of (a).
  • Phase 2: full RFC. Kiri Share hosts the HTTPS/WSS invite and signaling endpoint; the media goes over WebRTC as in (b). Kiri saves Kitty from hosting a rendezvous server, but not from TURN.

Risk: binding every invite to the owner's GitHub-traced tunnel makes the owner accountable for guest behaviour on that link.

d. Real USB gamepads through kiri usb

Not useful for Kitty now. The gamepads here are Bluetooth, and kiri usb handles USB only. Kitty's input already reaches the emulator through the host player's browser Gamepad API, then the WebSocket. Passing a pad into the VM would remove it from macOS and the player window. Passthrough only matters for a future native emulator inside the container (for example RetroArch reading /dev/input), and even then the docs say it's beta. Revisit it only if a native-emulator adapter arrives. Effort to evaluate then: about 1 day with a wired USB pad.

e. Other Kiri capabilities

Capability Use for Kitty Verdict
kiri diag report --out A "Create support bundle" button: Kitty's own logs plus Kiri's redacted report, saved locally for the user to read before sending. Never use --send silently. Cheap win, about 1 day.
kiri diag logs --errors -n N Show recent engine errors in Kitty's sandbox health panel. Cheap.
kiri raw run Run untrusted homebrew in its own guest, with no shared daemon state. Worth a spike for the security model.
kiri k8s + --lan Many sandboxes as pods, or a LAN arcade. It's heavy (memory warnings in the app) and overkill for one desktop user. Not now.
kiri machine A persistent Linux guest for building cores and tooling. It's a labelled container, so it adds no isolation. Dev only.
kiri ui request inspector While a link is live, see every request to it (path, method, status). Useful for the owner to audit a share. Document it for users.
.kiri.local names Nicer local URLs. Mac only, needs admin. No value for phones.
kiri share reserve NAME A stable controller URL such as kitty-<user>.runkiri.cloud. It makes links guessable. Don't use it for invites.

4. Security

What a public share exposes. Everything the shared port serves, to anyone with the URL, for as long as the command runs. Names are short (<name>-<4 chars>) and the URL appears in logs, screenshots and chat history, so the URL must never be the secret.

  • Sharing a SNES player container would serve /rom (and the emulator) to the internet: ROM distribution under the owner's GitHub identity.
  • Sharing a NES player would probably fail, since its Host check accepts only loopback. If the tunnel rewrote Host, though, it would expose the full /stream: frames, input and save/load actions.
  • Sharing the controller service exposes only the invite page and eight button names. That's the only thing Kitty should ever share.

Auth options. Kiri offers none at the link: no password, IP allowlist or expiry setting. Every gate must live in Kitty's service: a single-use token in the fragment, a session ID, a TTL (already 10 min by default, 30 s–24 h allowed), one slot, rate limits, and host approval.

Abuse risk and the owner's account. Each link traces to the owner's GitHub login. Abuse reports and takedowns land on that account. Bandwidth counts against the owner's monthly cap and tunnel slots; a link that leaks can be scanned or flooded until the owner stops it. While signed in, any local process can call kiri share, so Kitty must not keep tunnels alive in the background.

Guardrails Kitty must enforce:

  1. Explicit opt-in every time. A "Play from anywhere" toggle that is off by default. Show the URL and say it's public before starting.
  2. Share an allowlisted target only. Share only the controller or signaling service's port, never a container, player port, Kiri API or SDK port. The share-launch code should enforce this as a hard check: refuse a container name or any port that isn't Kitty's own service.
  3. Expiring links. Kill kiri share when the invite TTL ends, the game stops, Kitty quits or the user revokes. Clean up on crash: write a PID file and reap it on the next start. After each stop, check kiri share status --json shows nothing left.
  4. Tokens. A single-use, 24+ byte random token in the URL fragment, never logged. In remote mode the source IP is no longer a signal.
  5. No ROM exposure, ever. A test that GETs /rom, /game and / on the shared port and expects 404, plus a check that the shared port isn't any container's mapped port.
  6. Least power. Button names only. No save/load, files, shell or runtime calls over the link. Release all held buttons on disconnect (already done).
  7. Visible state. A "Live" indicator with a one-click Stop. Show who is connected.
  8. Never sign in for the user. Send them to kiri share login.

5. Recommendation and next steps

Build first: (a) the remote phone controller over Kiri Share. It's the smallest change on top of code that already works and is tested (the LAN controller), with no media work and no TURN. It's the base for (c) phase 1, and it tests the unknown that everything later depends on: WebSocket through Share.

Next steps, in order:

  1. Owner: allow runkiri.com (and its subdomains) in the router's Charter/CUJO security settings. Then run kiri share login once. This needs the owner's GitHub account, so it's the owner's decision.
  2. Owner or a worker with approval: run KIRI_PROBE_ALLOW_SHARE=1 scripts/kiri-probe/share-smoke.sh. It records the real URL format, the headers the app sees (Host, X-Forwarded-Proto), WebSocket support and WS RTT, then tears everything down. Gate: if WebSocket fails, stop. Feature (a) needs a different transport, and the plan changes.
  3. Write the acceptance test first: a phone on cellular (not the LAN) scans the QR, presses START, and the frame changes; then the link returns 404 within 5 s of Stop; /rom is never reachable.
  4. Implement the five changes in 3a behind a "Play from anywhere" toggle that is off by default, plus guardrails 1–8.
  5. Then (c) phase 1, controller 2 over the link. Then a measured WebRTC LAN spike for (b), per RFC PR #1.

Effort for steps 3–4: about 2–4 days. Still needs approval: the router change, the GitHub sign-in, and the first public share.

Reproducing

scripts/kiri-probe/inventory.sh           # read-only: commands and state of share/usb/k8s/machine, gamepads
scripts/kiri-probe/edge-reachability.sh   # read-only: DNS/TLS/latency to Kiri's edge, detects router filtering
scripts/kiri-probe/lan-exposure.sh        # one disposable alpine static page on 0.0.0.0, auto-removed
KIRI_PROBE_ALLOW_SHARE=1 scripts/kiri-probe/share-smoke.sh   # GATED: needs prior `kiri share login`; opens a PUBLIC link, auto-torn-down
node scripts/kiri-probe/ws-rtt.mjs ws://127.0.0.1:PORT/ws    # WS RTT against ws-echo-server.mjs (local baseline: p50 0.2 ms)

Back to all docs