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.
Rust ai-agentsai-assistantai-botautomationbotbots-teamchatbotclaude-duetgrokgrok-botgrok-bot-alternativeharnessllmmulti-agentopenai-dotsopenbotpersonal-agentrustself-hostedselfhosted-ai
Docs: kwnt token as another user now fails; select the token box after a wrong token
Pixel (kwant bot)c65d26ee8257
diff --git a/README.md b/README.mdindex d75d01c2..62dd05c9 100644--- a/README.md+++ b/README.md@@ -96,7 +96,7 @@ scp target/release/kwnt user@your-vps:/usr/local/bin/kwntssh 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? 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. Each install has its own token, so one copied from your laptop won't open kwnt on the server. 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).+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 the same user: as another user they fail, because that user can't read the token file (for the systemd unit use `sudo cat` as above). Each install has its own token, so one copied from your laptop won't open kwnt on the server. 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>diff --git a/docs/llm-profiles.md b/docs/llm-profiles.mdindex 88d339c2..2d292bb3 100644--- a/docs/llm-profiles.md+++ b/docs/llm-profiles.md@@ -78,7 +78,8 @@ with Docker) can use it.`kwnt token --raw` just the token, for scripts, which send `Authorization: Bearer <token>`. The tokenlives in `<data_dir>/api-token` (mode 0600), or set `KWNT_API_TOKEN` (16+ characters). Run `kwnt token` as theuser 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. Each+as any other user it fails with an error, because it can't find or read the token file (with the+systemd unit, `sudo cat /var/lib/kwnt/api-token`). Eachinstall has its own token, so a token from another computer won't work either. Thesign-in screen asks where kwant runs (a server, Docker, or this computer) and shows the matching steps.diff --git a/frontend/src/components/AuthGate.tsx b/frontend/src/components/AuthGate.tsxindex 9de58e62..ed034e3b 100644--- a/frontend/src/components/AuthGate.tsx+++ b/frontend/src/components/AuthGate.tsx@@ -307,6 +307,13 @@ export const TokenSteps: React.FC<{ place: TokenPlace; hostname: string; port: s};/** Shown when the server rejects a pasted token. Exported for tests. */+/** After a rejected token, focus and select the box so the next paste replaces it. Exported for tests. */+export const selectForRetry = (el: Pick<HTMLInputElement, 'focus' | 'select'> | null) => {+ if (!el) return;+ el.focus();+ el.select();+};+export const WRONG_TOKEN = "That token isn't right. It has to come from the machine running kwant bots, as the user running it.";export const TokenForm: React.FC<{ notice: string | null; onSignedIn: () => void; personOnly?: boolean; onCancel?: () => void }> = ({@@ -321,6 +328,11 @@ export const TokenForm: React.FC<{ notice: string | null; onSignedIn: () => voidconst 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 inputRef = useRef<HTMLInputElement>(null);++ useEffect(() => {+ if (error && !busy) selectForRetry(inputRef.current);+ }, [error, busy]);const submit = async (e: React.FormEvent) => {e.preventDefault();@@ -389,6 +401,7 @@ export const TokenForm: React.FC<{ notice: string | null; onSignedIn: () => void</p><inputid="kwnt-token"+ ref={inputRef}type="password"autoComplete="off"spellCheck={false}diff --git a/frontend/tests/tokenSteps.test.mjs b/frontend/tests/tokenSteps.test.mjsindex 2936e8ec..aca6eabe 100644--- a/frontend/tests/tokenSteps.test.mjs+++ b/frontend/tests/tokenSteps.test.mjs@@ -6,8 +6,8 @@ import { loadBundled } from './bundle.mjs';const m = await loadBundled(`import React from 'react';import { renderToStaticMarkup } from 'react-dom/server.browser';- import { TokenForm, TokenSteps, WRONG_TOKEN, guessPlace, tokenFromPaste } from './src/components/AuthGate';- export { WRONG_TOKEN, guessPlace, tokenFromPaste };+ import { TokenForm, TokenSteps, WRONG_TOKEN, guessPlace, selectForRetry, tokenFromPaste } from './src/components/AuthGate';+ export { WRONG_TOKEN, guessPlace, selectForRetry, tokenFromPaste };export const form = () => renderToStaticMarkup(React.createElement(TokenForm, { notice: null, onSignedIn: () => {} }));export const steps = (place, hostname = 'vps.example.com', port = '8799') =>renderToStaticMarkup(React.createElement(TokenSteps, { place, hostname, port }));@@ -61,3 +61,10 @@ test('a token from another computer: the screen and the error say where it has tassert.match(text(html), /a token copied from another computer won't work here/);assert.match(html, /aria-describedby="kwnt-token-hint"/);});++test('after a wrong token the box is focused and selected, so the next paste replaces it', () => {+ const calls = [];+ m.selectForRetry({ focus: () => calls.push('focus'), select: () => calls.push('select') });+ assert.deepEqual(calls, ['focus', 'select']);+ assert.doesNotThrow(() => m.selectForRetry(null));+});diff --git a/site-src/docs-install.html b/site-src/docs-install.htmlindex 7158ba02..18c12dd2 100644--- a/site-src/docs-install.html+++ b/site-src/docs-install.html@@ -32,7 +32,7 @@ ssh user@your-vps "kwnt serve --host 0.0.0.0 --port 8799"</code></pre><p>Swap <code><this-host></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> 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>Same user:</strong> run as another user, <code>kwnt token</code> fails with an error, because it can't find or read the token file. Run it as the user that runs kwnt, or with the systemd unit use <code>sudo cat /var/lib/kwnt/api-token</code>.</li><li><strong>Same machine:</strong> each install has its own token. A token from your laptop won't open kwnt on your server. Get it on the server.</li><li><strong>Scripts:</strong> <code>kwnt token --raw</code> prints just the token, to send as <code>Authorization: Bearer <token></code>.</li><li>The token lives in <code><data dir>/api-token</code> (mode 0600), or set <code>KWNT_API_TOKEN</code> (16+ characters).</li>diff --git a/site/docs/install.html b/site/docs/install.htmlindex f7f1ccf7..a2a04212 100644--- a/site/docs/install.html+++ b/site/docs/install.html@@ -81,7 +81,7 @@ ssh user@your-vps "kwnt serve --host 0.0.0.0 --port 8799"</code></pre><p>Swap <code><this-host></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> 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>Same user:</strong> run as another user, <code>kwnt token</code> fails with an error, because it can't find or read the token file. Run it as the user that runs kwnt, or with the systemd unit use <code>sudo cat /var/lib/kwnt/api-token</code>.</li><li><strong>Same machine:</strong> each install has its own token. A token from your laptop won't open kwnt on your server. Get it on the server.</li><li><strong>Scripts:</strong> <code>kwnt token --raw</code> prints just the token, to send as <code>Authorization: Bearer <token></code>.</li><li>The token lives in <code><data dir>/api-token</code> (mode 0600), or set <code>KWNT_API_TOKEN</code> (16+ characters).</li>