Skip to content

armgit / kwant

Public Imported from GitHub
0

Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.

Sign-in screen: ask where kwant runs, show steps that work without kwnt on the PATH

Pixel (kwant bot)c4d1f0b26eab
diff --git a/README.md b/README.md
index f46f2ac1..72a89272 100644
--- a/README.md
+++ b/README.md
@@ -96,7 +96,7 @@ scp target/release/kwnt user@your-vps:/usr/local/bin/kwnt
ssh user@your-vps "kwnt serve --host 0.0.0.0 --port 8799"
```
-On your own computer there is nothing to sign in to. From another machine, open the link `kwnt serve` prints at startup once (`http://<this-host>:8799/#kwnt_token=...`, with `<this-host>` swapped for the server's address); the browser stays signed in for a year. Lost it? `kwnt token` prints it again. Through `ssh -L 8799:127.0.0.1:8799` no sign-in is needed. The link signs in as you, so anyone who can read the server's output can use it. Put a TLS reverse proxy in front: see [browser service and VPS hosting](docs/browser-service.md).
+On your own computer there is nothing to sign in to. From another machine, open the link `kwnt serve` prints at startup once (`http://<this-host>:8799/#kwnt_token=...`, with `<this-host>` swapped for the server's address); the browser stays signed in for a year. Lost it? On the server, as the user that runs kwnt, `cat ~/.kwnt/api-token` (or `$KWNT_DATA_DIR/api-token`, e.g. `sudo cat /var/lib/kwnt/api-token` with the systemd unit below) prints the token to paste, and `kwnt token` the link (`./target/release/kwnt token` if kwnt isn't on your PATH). Run them as another user and you get that user's token, which the server doesn't accept. Or skip sign-in: `ssh -N -L 8799:127.0.0.1:8799 user@your-vps`, then open http://127.0.0.1:8799 on your computer (not with Docker, where requests always count as remote). The link signs in as you, so anyone who can read the server's output can use it. Put a TLS reverse proxy in front: see [browser service and VPS hosting](docs/browser-service.md).
<details>
<summary>A systemd unit</summary>
@@ -136,7 +136,7 @@ docker compose up -d --build # UI on http://127.0.0.1:8799
docker compose logs kwnt | grep kwnt_token # open that link once, with <this-host> as 127.0.0.1
```
-Data persists in the `kwnt-data` volume. `docker compose exec kwnt kwnt token` prints the sign-in link again.
+Data persists in the `kwnt-data` volume. `docker compose exec kwnt kwnt token` prints the sign-in link again, and `--raw` just the token to paste (`docker exec <container> kwnt token --raw` without Compose).
---
diff --git a/docs/llm-profiles.md b/docs/llm-profiles.md
index c4eb447e..2fd23734 100644
--- a/docs/llm-profiles.md
+++ b/docs/llm-profiles.md
@@ -76,7 +76,10 @@ with Docker) can use it.
`kwnt token` prints the same link again (Docker: `docker compose exec kwnt kwnt token`), and
`kwnt token --raw` just the token, for scripts, which send `Authorization: Bearer <token>`. The token
-lives in `<data_dir>/api-token` (mode 0600), or set `KWNT_API_TOKEN` (16+ characters).
+lives in `<data_dir>/api-token` (mode 0600), or set `KWNT_API_TOKEN` (16+ characters). Run `kwnt token` as the
+user that runs `kwnt serve` (`./target/release/kwnt` from a source build without kwnt on the `PATH`):
+as any other user it creates and prints that user's own token, which the server doesn't accept. The
+sign-in screen asks where kwant runs (a server, Docker, or this computer) and shows the matching steps.
Person-only routes (saved passwords and the vault, answering approval cards, the approvals switch,
deleting a bot or team, undo, Loose ends, Parallel Universe, letters) refuse a bot's turn token, or
diff --git a/frontend/src/components/AuthGate.tsx b/frontend/src/components/AuthGate.tsx
index 5016e782..1e3a2f49 100644
--- a/frontend/src/components/AuthGate.tsx
+++ b/frontend/src/components/AuthGate.tsx
@@ -1,5 +1,5 @@
import React, { createContext, useCallback, useContext, useEffect, useRef, useState } from 'react';
-import { KeyRound, Loader2, RefreshCw, Terminal, X } from 'lucide-react';
+import { Check, Copy, KeyRound, Loader2, RefreshCw, Terminal, X } from 'lucide-react';
import { ModernAvatar } from './ModernAvatar';
import {
PERSON_PROMPT_CLOSED_EVENT,
@@ -8,6 +8,7 @@ import {
UNAUTHORIZED_EVENT,
consumeTokenLink,
endSession,
+ extractHashToken,
fetchAuthStatus,
installUnauthorizedListener,
startSession,
@@ -183,6 +184,128 @@ export const PersonTokenDialog: React.FC<{ onClose: () => void; onSignedIn: () =
);
};
+/** Where kwant runs, as the person sees it: decides which steps get the token. */
+export type TokenPlace = 'server' | 'docker' | 'here';
+
+/** The port kwant listens on, as far as this page can tell (behind a proxy it can't). */
+function kwantPort(loc: Pick<Location, 'port'>): string {
+ return loc.port || '8799';
+}
+
+/** Docker publishes kwant on 127.0.0.1 and still asks for the token there, so a locked loopback page is Docker. */
+export function guessPlace(hostname: string): TokenPlace {
+ const h = hostname.replace(/^\[|\]$/g, '').toLowerCase();
+ return h === 'localhost' || h === '::1' || h.startsWith('127.') ? 'docker' : 'server';
+}
+
+/** The token from what was pasted: the token itself, or the whole sign-in link. */
+export function tokenFromPaste(value: string): string {
+ const v = value.trim();
+ const hash = v.indexOf('#');
+ if (hash >= 0 && v.includes('kwnt_token=')) return extractHashToken(v.slice(hash)).token ?? '';
+ return v;
+}
+
+const PLACES: { value: TokenPlace; label: string }[] = [
+ { value: 'server', label: 'On a server' },
+ { value: 'docker', label: 'In Docker' },
+ { value: 'here', label: 'On this computer' },
+];
+
+/** One command, selectable in a tap, with a copy button where the browser allows it. */
+const Command: React.FC<{ children: string; note?: string }> = ({ children, note }) => {
+ const [copied, setCopied] = useState(false);
+ const copy = async () => {
+ try {
+ // Plain http on an IP isn't a secure context, so the Clipboard API may be missing
+ if (navigator.clipboard?.writeText) await navigator.clipboard.writeText(children);
+ else {
+ const area = document.createElement('textarea');
+ area.value = children;
+ area.style.position = 'fixed';
+ area.style.opacity = '0';
+ document.body.appendChild(area);
+ area.select();
+ const ok = document.execCommand('copy');
+ area.remove();
+ if (!ok) return;
+ }
+ setCopied(true);
+ setTimeout(() => setCopied(false), 1500);
+ } catch {
+ // Nothing to do: the command stays selectable
+ }
+ };
+ return (
+ <div className="space-y-0.5">
+ <div className="flex items-start gap-1.5 bg-zinc-950 border border-zinc-800 rounded-md pl-2 pr-1 py-1">
+ <Terminal size={12} className="shrink-0 mt-[7px] text-zinc-500" aria-hidden="true" />
+ <code className="flex-1 min-w-0 py-1 break-words select-all text-[11px] font-mono text-zinc-200">{children}</code>
+ <button
+ type="button"
+ onClick={copy}
+ aria-label={copied ? 'Copied' : `Copy: ${children}`}
+ className="shrink-0 p-1.5 rounded text-zinc-500 hover:text-zinc-200 hover:bg-zinc-800 transition-colors"
+ >
+ {copied ? <Check size={12} className="text-emerald-400" /> : <Copy size={12} />}
+ </button>
+ </div>
+ {note && <p className="text-[11px] text-zinc-500 leading-snug">{note}</p>}
+ </div>
+ );
+};
+
+/** How to get the token, for where kwant runs. Exported for tests. */
+export const TokenSteps: React.FC<{ place: TokenPlace; hostname: string; port: string }> = ({ place, hostname, port }) => {
+ if (place === 'here') {
+ const url = `http://127.0.0.1:${port}`;
+ return (
+ <div className="space-y-2 text-xs text-zinc-400 leading-relaxed">
+ <p>
+ Open kwant bots at{' '}
+ <a href={url} className="font-mono text-sky-400 hover:text-sky-300 underline underline-offset-2">
+ {url}
+ </a>{' '}
+ instead. On the computer it runs on, kwant bots doesn't ask for a token, but only at <span className="font-mono">127.0.0.1</span> or{' '}
+ <span className="font-mono">localhost</span>, not at this computer's network address.
+ </p>
+ <p>
+ Started with Docker? Docker still asks for the token: choose <span className="text-zinc-200">In Docker</span>.
+ </p>
+ </div>
+ );
+ }
+ if (place === 'docker') {
+ return (
+ <div className="space-y-2 text-xs text-zinc-400 leading-relaxed">
+ <p>On the machine that runs Docker (over SSH if it's a server), in the folder with <span className="font-mono">docker-compose.yml</span>:</p>
+ <Command>docker compose exec kwnt kwnt token --raw</Command>
+ <Command note="Started with docker run instead? Use your container's name or ID (docker ps lists it).">
+ {'docker exec <container> kwnt token --raw'}
+ </Command>
+ </div>
+ );
+ }
+ const host = hostname.includes(':') ? `[${hostname}]` : hostname;
+ return (
+ <div className="space-y-2 text-xs text-zinc-400 leading-relaxed">
+ <p>SSH into the server as the user that runs kwant bots, then run:</p>
+ <Command note="Running it as a systemd service with KWNT_DATA_DIR? Read that folder instead, e.g. sudo cat /var/lib/kwnt/api-token.">
+ cat ~/.kwnt/api-token
+ </Command>
+ <p>
+ Or <span className="font-mono">kwnt token --raw</span>. Built from source and not on your PATH? Run it from the source folder:
+ </p>
+ <Command>./target/release/kwnt token --raw</Command>
+ <p className="pt-1">
+ <span className="text-zinc-200">No token at all:</span> on this computer, open an SSH tunnel, then go to{' '}
+ <span className="font-mono">http://127.0.0.1:{port}</span>. kwant bots sees the tunnel as local. Not for Docker.
+ </p>
+ <Command>{`ssh -N -L ${port}:127.0.0.1:${port} user@${host}`}</Command>
+ </div>
+ );
+};
+
const TokenForm: React.FC<{ notice: string | null; onSignedIn: () => void; personOnly?: boolean; onCancel?: () => void }> = ({
notice,
onSignedIn,
@@ -192,10 +315,13 @@ const TokenForm: React.FC<{ notice: string | null; onSignedIn: () => void; perso
const [token, setToken] = useState('');
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
+ const hostname = typeof window === 'undefined' ? 'your-server' : window.location.hostname || 'your-server';
+ const port = typeof window === 'undefined' ? '8799' : kwantPort(window.location);
+ const [place, setPlace] = useState<TokenPlace>(() => guessPlace(hostname));
const submit = async (e: React.FormEvent) => {
e.preventDefault();
- const value = token.trim();
+ const value = tokenFromPaste(token);
if (!value) return;
setBusy(true);
setError(null);
@@ -205,7 +331,7 @@ const TokenForm: React.FC<{ notice: string | null; onSignedIn: () => void; perso
onSignedIn();
return;
}
- setError("That token isn't right. Copy it again from the command below.");
+ setError("That token isn't right. Copy it again with the steps above, as the user that runs kwant bots.");
} catch (err) {
setError(err instanceof Error && err.message !== 'Failed to fetch' ? err.message : 'Could not reach the server.');
} finally {
@@ -221,42 +347,60 @@ const TokenForm: React.FC<{ notice: string | null; onSignedIn: () => void; perso
</h2>
<p className="text-xs text-zinc-400 leading-relaxed">
{personOnly
- ? 'Saved passwords, answers to approval cards and deleting bots or teams need your access token, even on this computer, so a bot can’t do them for you. You need it once per browser. Get it on the server:'
- : 'This server is reachable from other machines, so it needs its token once per browser. Get it on the server:'}
+ ? 'Saved passwords, answers to approval cards and deleting bots or teams need your access token from another computer, so a bot can’t do them for you. You need it once per browser.'
+ : 'You’re opening kwant bots from another computer, so this browser needs its access token once.'}
</p>
- <div className="space-y-1 text-[11px] font-mono text-zinc-300">
- <p className="flex items-center gap-1.5 bg-zinc-950 border border-zinc-800 rounded-md px-2 py-1">
- <Terminal size={12} className="text-zinc-500" /> kwnt token
- </p>
- <p className="flex items-center gap-1.5 bg-zinc-950 border border-zinc-800 rounded-md px-2 py-1">
- <Terminal size={12} className="text-zinc-500" /> docker compose exec kwnt kwnt token
- </p>
- </div>
</div>
+ <fieldset className="space-y-3">
+ <legend className="text-xs font-medium text-zinc-300 mb-2">Where does kwant bots run?</legend>
+ <div className="grid grid-cols-3 gap-1 p-1 bg-zinc-950 border border-zinc-800 rounded-lg">
+ {PLACES.map((p) => (
+ <label
+ key={p.value}
+ className={`relative flex items-center justify-center text-center min-h-[36px] px-1.5 rounded-md text-[11px] font-medium cursor-pointer transition-colors has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-sky-500 ${
+ place === p.value ? 'bg-zinc-800 text-zinc-100' : 'text-zinc-400 hover:text-zinc-200'
+ }`}
+ >
+ <input
+ type="radio"
+ name="kwnt-token-place"
+ value={p.value}
+ checked={place === p.value}
+ onChange={() => setPlace(p.value)}
+ className="sr-only"
+ />
+ {p.label}
+ </label>
+ ))}
+ </div>
+ <TokenSteps place={place} hostname={hostname} port={port} />
+ </fieldset>
{notice && <p className="text-xs text-amber-300" role="status">{notice}</p>}
- <div>
- <label htmlFor="kwnt-token" className="block text-xs font-medium text-zinc-400 mb-1">
- Token
- </label>
- <input
- id="kwnt-token"
- type="password"
- autoComplete="off"
- spellCheck={false}
- autoFocus
- value={token}
- onChange={(e) => setToken(e.target.value)}
- aria-invalid={!!error}
- aria-describedby={error ? 'kwnt-token-error' : undefined}
- className="w-full bg-zinc-950 border border-zinc-800 rounded-lg px-3 py-2 text-xs font-mono text-zinc-100 placeholder-zinc-600 focus:border-sky-500 focus:outline-none transition-colors"
- placeholder="Paste the token"
- />
- {error && (
- <p id="kwnt-token-error" className="mt-1.5 text-[11px] text-rose-400" role="alert">
- {error}
- </p>
- )}
- </div>
+ {place !== 'here' && (
+ <div>
+ <label htmlFor="kwnt-token" className="block text-xs font-medium text-zinc-400 mb-1">
+ Token
+ </label>
+ <input
+ id="kwnt-token"
+ type="password"
+ autoComplete="off"
+ spellCheck={false}
+ autoFocus
+ value={token}
+ onChange={(e) => setToken(e.target.value)}
+ aria-invalid={!!error}
+ aria-describedby={error ? 'kwnt-token-error' : undefined}
+ className="w-full bg-zinc-950 border border-zinc-800 rounded-lg px-3 py-2 text-xs font-mono text-zinc-100 placeholder-zinc-600 focus:border-sky-500 focus:outline-none transition-colors"
+ placeholder="Paste the token or the sign-in link"
+ />
+ {error && (
+ <p id="kwnt-token-error" className="mt-1.5 text-[11px] text-rose-400" role="alert">
+ {error}
+ </p>
+ )}
+ </div>
+ )}
<div className="flex gap-2">
{onCancel && (
<button
@@ -267,13 +411,15 @@ const TokenForm: React.FC<{ notice: string | null; onSignedIn: () => void; perso
Not now
</button>
)}
- <button
- type="submit"
- disabled={busy || !token.trim()}
- className="flex-1 w-full flex items-center justify-center gap-1.5 px-4 py-2 rounded-lg text-xs font-medium text-white bg-sky-600 hover:bg-sky-500 transition-colors disabled:opacity-50"
- >
- {busy && <Loader2 size={13} className="animate-spin motion-reduce:animate-none" />} Continue
- </button>
+ {place !== 'here' && (
+ <button
+ type="submit"
+ disabled={busy || !token.trim()}
+ className="flex-1 w-full flex items-center justify-center gap-1.5 px-4 py-2 rounded-lg text-xs font-medium text-white bg-sky-600 hover:bg-sky-500 transition-colors disabled:opacity-50"
+ >
+ {busy && <Loader2 size={13} className="animate-spin motion-reduce:animate-none" />} Continue
+ </button>
+ )}
</div>
<p className="text-[11px] text-zinc-500">The browser keeps you signed in for a year. Anyone with the token controls this server.</p>
</form>
diff --git a/frontend/tests/savedPasswords.test.mjs b/frontend/tests/savedPasswords.test.mjs
index c4e2b911..4853b2cb 100644
--- a/frontend/tests/savedPasswords.test.mjs
+++ b/frontend/tests/savedPasswords.test.mjs
@@ -213,14 +213,16 @@ test('a person-only 401 asks for the token; any other 401 goes to the gate; quie
}
});
-test('the token dialog says why it is asked on this computer and can be dismissed', () => {
+test('the token dialog says why it is asked from another computer and can be dismissed', () => {
const html = m.tokenDialog();
assert.match(html, /role="dialog"/);
assert.match(html, /aria-modal="true"/);
const t = text(html);
assert.match(t, /Confirm it's you/);
- assert.match(t, /deleting bots or teams need your access token, even on this computer, so a bot can't do them for you/);
- assert.match(t, /kwnt token/);
+ assert.match(t, /deleting bots or teams need your access token from another computer, so a bot can't do them for you/);
+ assert.ok(!t.includes('even on this computer'), 'this computer never asks');
+ assert.match(t, /Where does kwant bots run\?/);
+ assert.match(t, /kwnt token --raw/);
assert.ok(buttons(html).includes('Not now'));
assert.ok(buttons(html).includes('Continue'));
});
diff --git a/frontend/tests/tokenSteps.test.mjs b/frontend/tests/tokenSteps.test.mjs
new file mode 100644
index 00000000..665b041f
--- /dev/null
+++ b/frontend/tests/tokenSteps.test.mjs
@@ -0,0 +1,55 @@
+// The token screen: steps that work for where kwant runs, without kwnt on the PATH.
+import assert from 'node:assert/strict';
+import test from 'node:test';
+import { loadBundled } from './bundle.mjs';
+
+const m = await loadBundled(`
+ import React from 'react';
+ import { renderToStaticMarkup } from 'react-dom/server.browser';
+ import { TokenSteps, guessPlace, tokenFromPaste } from './src/components/AuthGate';
+ export { guessPlace, tokenFromPaste };
+ export const steps = (place, hostname = 'vps.example.com', port = '8799') =>
+ renderToStaticMarkup(React.createElement(TokenSteps, { place, hostname, port }));
+`);
+
+const text = (html) => html.replace(/<[^>]+>/g, ' ').replace(/&#x27;|&#39;/g, "'").replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/\s+/g, ' ');
+
+test('server: the token file and a source-build path, so it works without kwnt on the PATH', () => {
+ const t = text(m.steps('server'));
+ assert.match(t, /as the user that runs kwant bots/);
+ assert.match(t, /cat ~\/\.kwnt\/api-token/);
+ assert.match(t, /sudo cat \/var\/lib\/kwnt\/api-token/);
+ assert.match(t, /\.\/target\/release\/kwnt token --raw/);
+});
+
+test('server: an SSH tunnel to this host and port skips the token', () => {
+ const t = text(m.steps('server', 'vps.example.com', '9000'));
+ assert.match(t, /ssh -N -L 9000:127\.0\.0\.1:9000 user@vps\.example\.com/);
+ assert.match(t, /http:\/\/127\.0\.0\.1:9000/);
+ assert.match(t, /Not for Docker/);
+ assert.match(text(m.steps('server', '2001:db8::1')), /user@\[2001:db8::1\]/);
+});
+
+test('docker: compose and plain docker, no tunnel', () => {
+ const t = text(m.steps('docker'));
+ assert.match(t, /docker compose exec kwnt kwnt token --raw/);
+ assert.match(t, /docker exec <container> kwnt token --raw/);
+ assert.ok(!t.includes('ssh -N'));
+});
+
+test('this computer: open 127.0.0.1, which never asks', () => {
+ const html = m.steps('here', '192.168.1.20', '8799');
+ assert.match(html, /href="http:\/\/127\.0\.0\.1:8799"/);
+ assert.match(text(html), /not at this computer's network address/);
+});
+
+test('a locked page on loopback is Docker; anywhere else a server', () => {
+ for (const h of ['127.0.0.1', 'localhost', '[::1]']) assert.equal(m.guessPlace(h), 'docker', h);
+ for (const h of ['vps.example.com', '10.0.0.5', 'mac.local']) assert.equal(m.guessPlace(h), 'server', h);
+});
+
+test('pasting the whole sign-in link works as well as the token', () => {
+ assert.equal(m.tokenFromPaste(' abc123def456abc123 '), 'abc123def456abc123');
+ assert.equal(m.tokenFromPaste('http://1.2.3.4:8799/#kwnt_token=abc123def456abc123'), 'abc123def456abc123');
+ assert.equal(m.tokenFromPaste('http://<this-host>:8799/#kwnt_token=tok'), 'tok');
+});
diff --git a/frontend/tests/wording.test.mjs b/frontend/tests/wording.test.mjs
index 8f5a8721..46fb4ca5 100644
--- a/frontend/tests/wording.test.mjs
+++ b/frontend/tests/wording.test.mjs
@@ -17,9 +17,9 @@ const files = (dir) =>
);
const BAD = /\b(kwants?|kwnt|agents?)\b/i;
-// The product term (headings, tagline), the CLI commands shown on the sign-in screen, and
+// The product term (headings, tagline), the CLI commands and token file shown on the sign-in screen, and
// Agent Maestro, the VS Code extension's own name (a Custom API preset).
-const ALLOWED = /\bkwant bots?\b|\b(?:exec kwnt )?kwnt token\b/gi;
+const ALLOWED = /\bkwant bots?\b|\b(?:exec kwnt )?kwnt token\b|~\/\.kwnt\/api-token/gi;
const MAESTRO = /\bAgent Maestro\b/g;
/** Whether a literal reads like text a person sees (a sentence, or a capitalised word). */
diff --git a/site-src/docs-install.html b/site-src/docs-install.html
index 01798241..a0839a7e 100644
--- a/site-src/docs-install.html
+++ b/site-src/docs-install.html
@@ -18,7 +18,8 @@ card_art: avatar:devops
<h2 id="local">On your own computer</h2>
<p>Run <code>kwnt serve</code> and open <a href="http://127.0.0.1:8799">http://127.0.0.1:8799</a>. There's nothing to sign in to: requests from this machine need no token, and <code>kwnt serve</code> prints nothing about one.</p>
<p>"This machine" means a loopback connection with a loopback <code>Host</code> and no proxy headers. A VPS you reach through an SSH tunnel counts too:</p>
-<pre><code>ssh -L 8799:127.0.0.1:8799 user@your-vps</code></pre>
+<pre><code>ssh -N -L 8799:127.0.0.1:8799 user@your-vps <span class="c"># on your computer, then open http://127.0.0.1:8799</span></code></pre>
+<p>Not with Docker: its published port always counts as remote. And <code>127.0.0.1</code> only: opening kwant at your computer's network address (say <code>192.168.1.20:8799</code>) counts as another machine.</p>
<h2 id="vps">On a VPS</h2>
<pre><code><span class="c"># 1. Copy the binary to your server</span>
@@ -30,7 +31,8 @@ ssh user@your-vps "kwnt serve --host 0.0.0.0 --port 8799"</code></pre>
<pre><code>http://&lt;this-host&gt;:8799/#kwnt_token=…</code></pre>
<p>Swap <code>&lt;this-host&gt;</code> for the server's address and open the link once. The page signs in with an HttpOnly cookie that lasts a year and clears the address bar.</p>
<ul>
- <li><strong>Lost the link?</strong> <code>kwnt token</code> prints it again.</li>
+ <li><strong>Lost the link?</strong> On the server, as the user that runs kwnt, <code>kwnt token</code> prints it again, and <code>cat ~/.kwnt/api-token</code> prints the token to paste on the sign-in screen. With the systemd unit below that's <code>sudo cat /var/lib/kwnt/api-token</code>. Built from source and kwnt isn't on your <code>PATH</code>? Use <code>./target/release/kwnt token</code> from the source folder.</li>
+ <li><strong>Same user:</strong> run as another user, <code>kwnt token</code> makes and prints that user's own token, which the server doesn't accept.</li>
<li><strong>Scripts:</strong> <code>kwnt token --raw</code> prints just the token, to send as <code>Authorization: Bearer &lt;token&gt;</code>.</li>
<li>The token lives in <code>&lt;data dir&gt;/api-token</code> (mode 0600), or set <code>KWNT_API_TOKEN</code> (16+ characters).</li>
</ul>
@@ -60,8 +62,9 @@ systemctl enable --now kwnt</code></pre>
<p><code>docker-compose.yml</code> runs kwant next to a Laya image with the model weights baked in, so the server never downloads them at runtime:</p>
<pre><code>docker compose up -d --build <span class="c"># UI on http://127.0.0.1:8799</span>
docker compose logs kwnt | grep kwnt_token <span class="c"># open that link once</span>
-docker compose exec kwnt kwnt token <span class="c"># print it again later</span></code></pre>
-<p>Requests through Docker's published port arrive from the bridge network, so they count as remote: open the startup link once, using <code>127.0.0.1</code> as the host. Data persists in the <code>kwnt-data</code> volume.</p>
+docker compose exec kwnt kwnt token <span class="c"># print it again later</span>
+docker compose exec kwnt kwnt token --raw <span class="c"># just the token, to paste</span></code></pre>
+<p>Requests through Docker's published port arrive from the bridge network, so they count as remote: open the startup link once, using <code>127.0.0.1</code> as the host. An SSH tunnel doesn't skip sign-in here. Without Compose: <code>docker exec &lt;container&gt; kwnt token --raw</code>. Data persists in the <code>kwnt-data</code> volume.</p>
<h2 id="proxy">Behind an HTTPS reverse proxy</h2>
<p>Only the HTTPS port needs to be reachable from outside. Forward the original <code>Host</code> header, because the live browser stream checks <code>Origin</code> against it, and allow WebSocket upgrades:</p>
diff --git a/site/docs/install.html b/site/docs/install.html
index ef0b8e63..4bafce2b 100644
--- a/site/docs/install.html
+++ b/site/docs/install.html
@@ -67,7 +67,8 @@
<h2 id="local">On your own computer</h2>
<p>Run <code>kwnt serve</code> and open <a href="http://127.0.0.1:8799">http://127.0.0.1:8799</a>. There's nothing to sign in to: requests from this machine need no token, and <code>kwnt serve</code> prints nothing about one.</p>
<p>"This machine" means a loopback connection with a loopback <code>Host</code> and no proxy headers. A VPS you reach through an SSH tunnel counts too:</p>
-<pre><code>ssh -L 8799:127.0.0.1:8799 user@your-vps</code></pre>
+<pre><code>ssh -N -L 8799:127.0.0.1:8799 user@your-vps <span class="c"># on your computer, then open http://127.0.0.1:8799</span></code></pre>
+<p>Not with Docker: its published port always counts as remote. And <code>127.0.0.1</code> only: opening kwant at your computer's network address (say <code>192.168.1.20:8799</code>) counts as another machine.</p>
<h2 id="vps">On a VPS</h2>
<pre><code><span class="c"># 1. Copy the binary to your server</span>
@@ -79,7 +80,8 @@ ssh user@your-vps "kwnt serve --host 0.0.0.0 --port 8799"</code></pre>
<pre><code>http://&lt;this-host&gt;:8799/#kwnt_token=…</code></pre>
<p>Swap <code>&lt;this-host&gt;</code> for the server's address and open the link once. The page signs in with an HttpOnly cookie that lasts a year and clears the address bar.</p>
<ul>
- <li><strong>Lost the link?</strong> <code>kwnt token</code> prints it again.</li>
+ <li><strong>Lost the link?</strong> On the server, as the user that runs kwnt, <code>kwnt token</code> prints it again, and <code>cat ~/.kwnt/api-token</code> prints the token to paste on the sign-in screen. With the systemd unit below that's <code>sudo cat /var/lib/kwnt/api-token</code>. Built from source and kwnt isn't on your <code>PATH</code>? Use <code>./target/release/kwnt token</code> from the source folder.</li>
+ <li><strong>Same user:</strong> run as another user, <code>kwnt token</code> makes and prints that user's own token, which the server doesn't accept.</li>
<li><strong>Scripts:</strong> <code>kwnt token --raw</code> prints just the token, to send as <code>Authorization: Bearer &lt;token&gt;</code>.</li>
<li>The token lives in <code>&lt;data dir&gt;/api-token</code> (mode 0600), or set <code>KWNT_API_TOKEN</code> (16+ characters).</li>
</ul>
@@ -109,8 +111,9 @@ systemctl enable --now kwnt</code></pre>
<p><code>docker-compose.yml</code> runs kwant next to a Laya image with the model weights baked in, so the server never downloads them at runtime:</p>
<pre><code>docker compose up -d --build <span class="c"># UI on http://127.0.0.1:8799</span>
docker compose logs kwnt | grep kwnt_token <span class="c"># open that link once</span>
-docker compose exec kwnt kwnt token <span class="c"># print it again later</span></code></pre>
-<p>Requests through Docker's published port arrive from the bridge network, so they count as remote: open the startup link once, using <code>127.0.0.1</code> as the host. Data persists in the <code>kwnt-data</code> volume.</p>
+docker compose exec kwnt kwnt token <span class="c"># print it again later</span>
+docker compose exec kwnt kwnt token --raw <span class="c"># just the token, to paste</span></code></pre>
+<p>Requests through Docker's published port arrive from the bridge network, so they count as remote: open the startup link once, using <code>127.0.0.1</code> as the host. An SSH tunnel doesn't skip sign-in here. Without Compose: <code>docker exec &lt;container&gt; kwnt token --raw</code>. Data persists in the <code>kwnt-data</code> volume.</p>
<h2 id="proxy">Behind an HTTPS reverse proxy</h2>
<p>Only the HTTPS port needs to be reachable from outside. Forward the original <code>Host</code> header, because the live browser stream checks <code>Origin</code> against it, and allow WebSocket upgrades:</p>