core: publish self-hosted weekly dashboard and Proxmox deployment (#20)
Reuse existing weekly/reset analysis in an authenticated dashboard and local official CLI workers. Add safe Proxmox installation and updates, account-attributed history, and MIT distribution. Provider credentials stay owned by each CLI. Closes #19
This commit was merged in pull request #20.
This commit is contained in:
+54
-4
@@ -7,7 +7,7 @@ the IDs instead of restating the text. The requirements (R1 to R7) are in
|
||||
|
||||
## D1 — .NET 10, C# 14 and NativeAOT for win-x64 and linux-x64
|
||||
|
||||
**Decision.** Every shipped executable (the app, the CLI and the Stream Deck plugin) targets
|
||||
**Decision.** Every shipped executable (the app, the CLI, Stream Deck plugin and optional web/worker hosts) targets
|
||||
`net10.0` with C# 14 and publishes NativeAOT for `win-x64` and `linux-x64`. `global.json` asks
|
||||
for SDK 10.0.100 or newer within 10.0 (`rollForward: latestFeature`), so the SDK from CachyOS's
|
||||
package manager works too. Builds treat warnings as errors and run the trim and AOT analyzers.
|
||||
@@ -20,8 +20,10 @@ serialization, binding or loading, or runtime code generation.
|
||||
|
||||
## D2 — The CLIs are the only interface to a provider
|
||||
|
||||
**Decision.** FinalToken never reads, stores, logs or sends a credential (OAuth token, API key,
|
||||
cookie). It never opens a provider login and never calls a provider's HTTP API itself. It reads
|
||||
**Decision.** FinalToken never reads, stores, logs or sends a provider access/refresh token,
|
||||
API key or cookie. It can invoke an official CLI login and transiently relay the browser's
|
||||
authorization response to that exact pending process ([D14](#d14--self-hosted-dashboard-and-workers)).
|
||||
It never calls a provider's HTTP API itself. It reads
|
||||
the files the CLIs write and runs the installed `claude` and `codex` executables as child
|
||||
processes, which use their own login. It never opens credential files such as
|
||||
`~/.claude/.credentials.json` or `~/.codex/auth.json`, or the OS keychain. Only counts, model
|
||||
@@ -32,6 +34,7 @@ working.
|
||||
**Why.** R2, R3.
|
||||
|
||||
**Gives up.** Whatever the CLIs do not expose, and limit data while a CLI is not installed.
|
||||
Login coordination needs the installed CLI's supported flow; no central credential pool is possible.
|
||||
|
||||
## D3 — Claude data sources
|
||||
|
||||
@@ -299,7 +302,8 @@ week's start and the id of the limit window it follows (`weekStart`, `weekWindow
|
||||
the current instance of the provider's weekly limit: its longest window over a day whose label
|
||||
names no model family. Without one, it is the local calendar week from Monday, and `weekWindow`
|
||||
is absent. The DTOs and their source-generated JSON context live in `FinalToken.Core`, shared by
|
||||
the app, the CLI and the Stream Deck plugin. Nothing listens on a socket or runs an HTTP server. A reader treats a
|
||||
the app, the CLI and the Stream Deck plugin. The optional separate dashboard/worker hosts use
|
||||
[D14](#d14--self-hosted-dashboard-and-workers); the desktop app itself has no server. A reader treats a
|
||||
snapshot older than three refresh intervals as stale. The app gives the engine its own path; a
|
||||
CLI refresh keeps the path already in the snapshot, and a snapshot without one has none, so a
|
||||
reader never mistakes its own path for the app's.
|
||||
@@ -310,6 +314,52 @@ calendar week (developer feedback, 2026-10-18).
|
||||
|
||||
**Gives up.** Updates faster than the reader's poll interval.
|
||||
|
||||
## D14 — Self-hosted dashboard and workers
|
||||
|
||||
**Decision.** Add a separate ASP.NET Core slim/NativeAOT-compatible server and an outbound .NET
|
||||
worker per OS user, following the developer's direction in
|
||||
[#19](https://git.finalfactory.de/FinalFactory/FinalToken/issues/19).
|
||||
|
||||
- Account ids, expected emails and machine/profile bindings are configured by the operator.
|
||||
The server has a dashboard access key and distinct per-machine keys. Browser sessions are
|
||||
HttpOnly, SameSite cookies with CSRF checks; remote access uses HTTPS. A worker cannot select
|
||||
another machine's identity or execute arbitrary remote commands.
|
||||
- The dashboard calls Core's D7, D12 and D13 APIs. No second forecasting implementation is added.
|
||||
Local settings remain local; the newest quota observation's profile supplies the pace threshold,
|
||||
hidden windows and freshness interval. Account timezone controls calendar days. No working-hour
|
||||
forecast is added. Old/expired limits are displayed but have no current forecast.
|
||||
- Quota is the newest observed account/window value, never the sum across machines. Consumption
|
||||
uses Claude response ids and ordered Codex session cumulative counts across machine copies.
|
||||
Conflicting event metadata is excluded with a warning. Raw metadata history and observations
|
||||
survive offline clients and restarts; messages and project paths are not exported.
|
||||
- Old hourly history cannot be deduplicated after aggregation. An optional designated source and
|
||||
fixed UTC-hour cutoff import it once; identified source events own the interval after the cutoff.
|
||||
Historical profile/account attribution is an operator assertion; identity probes cannot prove
|
||||
which account produced older transcripts. Use a separate profile/data directory per account.
|
||||
- A login is bound to browser session, machine, OS user, config profile, worker boot and a
|
||||
15-minute maximum attempt deadline. That deadline is not a provider credential expiry.
|
||||
Claude uses `auth login --claudeai` and manual code relay through stdin; Codex uses
|
||||
`login --device-auth`. The CLI exchanges and stores its own credentials. A status probe verifies
|
||||
the resulting email. Unknown identity or account mismatch cannot be reported as success.
|
||||
Responses, URLs and device codes live only in pending-session memory and are not logged.
|
||||
- Cancellation, timeout, worker restart and concurrent attempts have explicit outcomes.
|
||||
No remote localhost callback forwarding or private provider endpoint is implemented.
|
||||
CLI output/flow changes fail visibly and may require terminal login on that machine.
|
||||
- The worker reuses the local store and scanner. Claude's legacy D3 print-mode quota probe is
|
||||
opt-in: current official documentation does not promise that slash commands in print mode are
|
||||
a supported quota API. Without it, existing observations remain available and age to stale.
|
||||
Codex uses D4's CLI app-server and rollout fallback. No provider HTTP API is added.
|
||||
|
||||
**Why.** R8, and the developer's clarification that the browser authorization response must
|
||||
travel through FinalToken to the CLI, without being stored. D7's analysis answers whether the
|
||||
remaining allowance will last through the actual reset; token prices alone cannot answer it.
|
||||
|
||||
**Gives up.** Automatic remote callbacks, provider-token sharing, automatic account switching,
|
||||
unverified identities, universal login lifetimes, and exact cross-machine attribution of old
|
||||
hourly buckets. The metadata inventory currently has a 100,000-record per-profile export bound;
|
||||
the collector retains prior data and reports failure when full. This version uses atomic JSON
|
||||
inventories, not an unbounded fleet database. See [operation and limits](web-dashboard.md).
|
||||
|
||||
## D10 — Stream Deck plugin
|
||||
|
||||
**Decision.** The plugin's UUID is `de.finalfactory.finaltoken`, its folder
|
||||
|
||||
+253
@@ -0,0 +1,253 @@
|
||||
# Proxmox LXC install and update
|
||||
|
||||
Run [tools/proxmox.sh](../tools/proxmox.sh) **as root on the Proxmox host**, from a trusted local
|
||||
copy of this checkout. It creates the container itself; do not run it inside an existing LXC.
|
||||
The default is a dashboard plus a collector/client in one new, unprivileged Debian 13 amd64 CT.
|
||||
This follows [D14](decisions.md#d14--self-hosted-dashboard-and-workers).
|
||||
|
||||
Use a checkout containing the web/worker and installer source. A public repository can be
|
||||
[cloned and updated over HTTPS without a Git login](publication.md#anonymous-git-reads).
|
||||
Alternatively copy the source to the host, including `tools/proxmox/`, `tools/proxmox.sh`, `tools/source_policy.py`,
|
||||
`LICENSE`, root build files and the four Core/Fleet/Web/Worker source directories. Git metadata
|
||||
and build artifacts are not needed. The installer snapshots the selected local source, including
|
||||
uncommitted files; this local-source installer never pulls, commits or pushes Git changes.
|
||||
The separate [one-command updater](../tools/proxmox-update.sh) refreshes a clean Git checkout
|
||||
before invoking the installer.
|
||||
The snapshot excludes recognized local configuration, key and runtime-data paths independently
|
||||
of Git ignore rules; those files are not read or transferred with the source.
|
||||
|
||||
## Install dashboard and client
|
||||
|
||||
From the copied repository root on the Proxmox host:
|
||||
|
||||
```bash
|
||||
bash tools/proxmox.sh install --ctid 201 --storage local-lvm \
|
||||
--domain usage.example.com --email [email protected] --timezone Europe/Berlin
|
||||
```
|
||||
|
||||
Replace the storage, CT id, domain and email. Omit `--ctid` to ask Proxmox for the next free id.
|
||||
`--storage` is deliberately required: the installer does not choose where to allocate your disk.
|
||||
Add `--dry-run` to print the validated plan without calling Proxmox or changing files.
|
||||
|
||||
The installer:
|
||||
|
||||
1. Downloads the latest available Debian 13 standard amd64 template to `local`, or uses the
|
||||
filename selected with `--template`. `--template-storage` selects another template storage.
|
||||
2. Creates an unprivileged CT, with on-boot startup, 2 cores, 4096 MiB RAM, 2048 MiB swap,
|
||||
a 20 GiB root disk and DHCP on `vmbr0`. It does not enable nesting or privileged mode.
|
||||
3. Uploads an allowlisted source archive and builds `linux-x64` NativeAOT **inside the CT**, as
|
||||
the separate `finaltoken-build` OS user. Windows-built executables are never deployed to Linux.
|
||||
4. Installs the .NET 10 SDK/native compiler prerequisites in the CT, Caddy for HTTPS, and the
|
||||
official Claude native stable installer and Codex npm package as the `finaltoken` user.
|
||||
Official CLI downloads run under that user, not root. No provider login is attempted.
|
||||
5. Generates service keys, account/profile bindings, systemd services and a loopback web backend.
|
||||
Caddy exposes `https://<domain>`. The new client is automatically registered with this server.
|
||||
6. Checks local services and the dashboard HTTP response. Keys are not printed by the script.
|
||||
|
||||
The host needs Proxmox's `pct`, `pvesh`, `pveam`, `pvesm` and Python 3. Its package repositories
|
||||
are not changed. The CT needs working DNS and outbound package/download access. Native builds
|
||||
need time and memory; increase `--memory`, `--cores` or `--disk` for a slower/smaller host.
|
||||
The first build restores .NET packages. Later updates also run package installation in the CT;
|
||||
this is not a fully offline or byte-for-byte reproducible supply-chain build.
|
||||
|
||||
For static networking:
|
||||
|
||||
```bash
|
||||
bash tools/proxmox.sh install --ctid 201 --storage local-lvm \
|
||||
--bridge vmbr0 --ip 192.0.2.20/24 --gateway 192.0.2.1 --vlan 10 \
|
||||
--domain usage.example.com --email [email protected]
|
||||
```
|
||||
|
||||
`--vlan` is optional. Set DNS to point the chosen domain to the CT. Allow incoming TCP 80/443
|
||||
through your Proxmox/network firewall and, for public ACME certificates, forward the required
|
||||
ports. The script sets the CT interface's firewall flag; it does not modify cluster/host firewall
|
||||
rules, DNS, NAT or routing. The public certificate/network path is not proven by the local
|
||||
health check. Caddy's default ACME certificate issuance needs the domain to be reachable.
|
||||
|
||||
For a private LAN hostname, add `--tls internal`. Caddy then uses a private CA; explicitly trust
|
||||
its root certificate on browsers and remote clients. Do not disable TLS verification.
|
||||
The root certificate is inside the CT at:
|
||||
|
||||
```text
|
||||
/var/lib/finaltoken-proxy/caddy/pki/authorities/local/root.crt
|
||||
```
|
||||
|
||||
Read the dashboard access key from the Proxmox root console when you need to sign in:
|
||||
|
||||
```bash
|
||||
pct exec 201 -- cat /etc/finaltoken/dashboard-key
|
||||
```
|
||||
|
||||
Open the dashboard and use **Log in / renew** for each provider profile. This is the actual
|
||||
official CLI login, bound to that CT's `finaltoken` user. The CLI still requires your browser
|
||||
authorization. The client only observes coding activity in this CT's profiles; it cannot see
|
||||
coding sessions on a desktop or a different CT unless a client is installed there too.
|
||||
Claude quota probing remains subject to the [web integration limitations](web-dashboard.md#provider-usage-limitations).
|
||||
|
||||
## Client-only or server-only
|
||||
|
||||
For a **server-only** container, run this as root on the Proxmox host after these changes are
|
||||
published to `master` and anonymous HTTPS reads are enabled. The host needs Git in addition to
|
||||
the Proxmox commands and Python 3. Use a new checkout path and a free CT id; replace the storage,
|
||||
domain and timezone for your setup:
|
||||
|
||||
```bash
|
||||
git clone --branch master --single-branch https://git.finalfactory.de/FinalFactory/FinalToken.git /opt/finaltoken-src && \
|
||||
bash /opt/finaltoken-src/tools/proxmox.sh install --role server --ctid 201 \
|
||||
--storage local-lvm --domain usage.example.com --timezone Europe/Berlin
|
||||
```
|
||||
|
||||
This installs only the dashboard and HTTPS proxy. No provider login or provider email is required
|
||||
on the server. Optional `--email` seeds the provider accounts; accounts and remote machine
|
||||
bindings can also be configured afterwards. Set the domain's DNS and TCP 80/443 access as
|
||||
described above. Private-LAN deployments can add `--tls internal` and trust the private CA.
|
||||
|
||||
Read the dashboard key with `pct exec 201 -- cat /etc/finaltoken/dashboard-key`.
|
||||
Keep `/opt/finaltoken-src` as a dedicated deployment checkout for the update command below.
|
||||
|
||||
For a separate collector LXC, first configure an account/machine binding on the existing server
|
||||
as described in [the dashboard setup](web-dashboard.md#run-locally). The machine's `osUser` must
|
||||
be `finaltoken`, with the selected provider ids as its profile ids. Put that machine's matching
|
||||
transport key in a root-readable host file (mode 0600); it is a FinalToken key, not a provider token.
|
||||
|
||||
```bash
|
||||
bash tools/proxmox.sh install --ctid 202 --storage local-lvm --role worker \
|
||||
--server-url https://usage.example.com --machine-id lxc_202 \
|
||||
--worker-key-file /root/lxc_202.key --email [email protected]
|
||||
```
|
||||
|
||||
The script creates the client CT, installs its CLIs, configures profiles and starts its service.
|
||||
The existing server must already authorize that machine id/key; this mode does not edit another
|
||||
server's configuration. If the existing server uses a private CA, install that CA in the new CT's
|
||||
system trust store with `update-ca-certificates` before expecting the worker to connect.
|
||||
|
||||
`--role server` omits the local client/CLIs and starts with no machine bindings. You can supply
|
||||
`--email` to seed provider accounts, then configure remote machines in `/etc/finaltoken/server.json`
|
||||
and add their distinct `FINALTOKEN_MACHINE_<id>` keys in `/etc/finaltoken/server.env`.
|
||||
Restart the server after editing its configuration. The operator guide documents this static
|
||||
configuration contract; there is no automatic remote enrollment HTTP API.
|
||||
|
||||
Use `--providers codex` or `--providers claude` to install only one provider.
|
||||
`--claude-email` and `--codex-email` override `--email` independently. Machine ids must begin with
|
||||
a letter and use letters/digits/underscores, because they also name systemd environment variables.
|
||||
|
||||
## Update or resume a partial installation
|
||||
|
||||
For a clean clone at `/opt/finaltoken-src`, run this **single command as root on the host**
|
||||
from any working directory. Change `201` to the installed CT id:
|
||||
|
||||
```bash
|
||||
bash /opt/finaltoken-src/tools/proxmox-update.sh 201
|
||||
```
|
||||
|
||||
It fetches the checkout's tracking branch with fast-forward-only/no-autostash rules, verifies that
|
||||
HEAD matches that upstream, then enters the **newly fetched** installer. Re-running the command
|
||||
with no new commit still retries deployment, which is useful after a package/build interruption.
|
||||
The existing managed CT marker preserves the installed role, including server-only installations.
|
||||
It refuses a detached branch, missing upstream, local-only commits and tracked/staged/untracked
|
||||
changes; it never resets, stashes, commits or pushes local work. Upstream paths that would overwrite
|
||||
ignored local files also stop the update. Ignored runtime state is retained
|
||||
and filtered from source archives. Update failures return a nonzero exit status. Git failures
|
||||
stop before deployment and do not echo remote URLs that might contain operator credentials.
|
||||
The updater locks its checkout with `flock` (util-linux); the installer also holds its existing
|
||||
host-wide deployment lock. Do not edit the dedicated clone during an update.
|
||||
|
||||
To validate the current source and deployment arguments without fetching or changing the CT:
|
||||
|
||||
```bash
|
||||
bash /opt/finaltoken-src/tools/proxmox-update.sh 201 --dry-run
|
||||
```
|
||||
|
||||
For a manually copied checkout or a deliberately selected local source snapshot, copy the
|
||||
desired new source into place and use the original offline-source entry point:
|
||||
|
||||
```bash
|
||||
bash tools/proxmox.sh update --ctid 201
|
||||
```
|
||||
|
||||
Use `--source /absolute/path/to/another/checkout` to select a different local source snapshot.
|
||||
Update requires a running CT with this installer's marker and matching CT id. It refuses foreign
|
||||
or stopped containers. It does not overwrite identity settings; install-only identity flags are
|
||||
rejected on update. Service keys, configuration, CLI profiles and usage history are preserved.
|
||||
Updates do not reinstall/upgrade the official CLIs; they keep their normal CLI-owned lifecycle.
|
||||
|
||||
A new binary release is built before the `current` symlink changes. Only services that were
|
||||
running are restarted; intentionally stopped services remain stopped. A local health failure
|
||||
restores the previous binary release and attempts to restart the previously running services.
|
||||
That is binary rollback, not a history/configuration/OS-package rollback. Old releases are kept;
|
||||
no automatic pruning or container deletion takes place. A future incompatible data schema needs
|
||||
an explicit migration/backup plan before deploying it.
|
||||
|
||||
Restarting a server/client interrupts pending login attempts; finish or cancel them first.
|
||||
An interrupted package download or build leaves the CT for inspection. Once the guest marker
|
||||
exists, the same `update` command resumes an incomplete initial installation without rotating
|
||||
its enrollment key. If creation failed before the marker was written, inspect the CT and its
|
||||
network rather than trying to overwrite it with another `install`.
|
||||
|
||||
## Files and service ownership
|
||||
|
||||
| Location | Purpose |
|
||||
|---|---|
|
||||
| `/etc/finaltoken/install.json` | Managed CT id, role, source checksum and last successful release |
|
||||
| `/etc/finaltoken/server.json`, `worker.json` | Operator-editable account/profile configuration |
|
||||
| `/etc/finaltoken/server.env`, `worker.env` | Root-only FinalToken service keys/environment |
|
||||
| `/etc/finaltoken/transport-keys.json` | Root-only initial transport-key backup; not provider credentials |
|
||||
| `/opt/finaltoken/releases/`, `/opt/finaltoken/current` | Root-owned staged/active native binaries |
|
||||
| `/var/lib/finaltoken-server/` | Server data; owned by `finaltoken-server` |
|
||||
| `/var/lib/finaltoken-worker/` | CLI profiles, per-provider history and collector state; owned by `finaltoken` |
|
||||
| `/var/lib/finaltoken-proxy/` | Caddy state/certificates; owned by `finaltoken-proxy` |
|
||||
| `/var/cache/finaltoken-build/` | Separate build user home/cache; per-build source directories are removed |
|
||||
|
||||
Generated units use separate non-root users, restrictive file permissions, no-new-privileges and
|
||||
process-group shutdown. They avoid mount-namespace sandbox settings that require extra LXC
|
||||
features. Unit files are created once and preserved on update; put site overrides in systemd
|
||||
drop-ins. Default package `caddy.service` is disabled in favor of `finaltoken-proxy.service`.
|
||||
|
||||
```bash
|
||||
pct exec 201 -- systemctl status finaltoken-server finaltoken-worker finaltoken-proxy
|
||||
pct exec 201 -- journalctl -u finaltoken-worker -u finaltoken-server --since today
|
||||
```
|
||||
|
||||
Application stdout/stderr are discarded by these units to prevent CLI/login material entering
|
||||
the journal. The journal still shows service exit/restart metadata. Inspect configuration and
|
||||
CLI installation under the intended user when diagnosing a failed service. Do not dump provider
|
||||
credential files into logs or support reports. For coding inside the worker CT, use
|
||||
`pct enter 201`, then `su - finaltoken`; its official CLIs are in `~/.local/bin`.
|
||||
|
||||
## Verification and limits
|
||||
|
||||
Run from the repository root:
|
||||
|
||||
```text
|
||||
python -B tools/proxmox/test_installer.py
|
||||
python -B tools/proxmox/test_update.py
|
||||
bash -n tools/proxmox.sh
|
||||
bash -n tools/proxmox-update.sh
|
||||
python -B tools/docs/check_docs.py
|
||||
```
|
||||
|
||||
Installer tests mock Proxmox, package installation, native publishing and systemd. They cover
|
||||
argument validation, CT refusal, command order, environment isolation, archive safety, preservation
|
||||
of configuration/keys, partial setup, stopped services and activation rollback. They do not prove
|
||||
a real Proxmox create/update, Linux build, certificate issuance or provider login. No Proxmox
|
||||
host/container was changed while developing this script.
|
||||
|
||||
One installer regression uses real Node.js/npm with an offline synthetic package to check the
|
||||
configured Codex launcher and repeat installation. It skips explicitly when Node.js/npm are
|
||||
unavailable. On Windows its fixture adapts npm's global-prefix layout to the guest's Linux `bin`
|
||||
path; that checks npm install mode and actual files without claiming Linux execution.
|
||||
|
||||
Updater tests use real local Git repositories and Bash with a synthetic installer. They verify
|
||||
two-version fast-forward deployment, no-change retry, dirty/diverged/ahead/detached refusal,
|
||||
fetch failure, dry-run, exit status, ignored-state retention and ignored-file collisions. Advisory lock command results
|
||||
are substituted so the checks also run on Windows; real Linux locking is not exercised here.
|
||||
|
||||
References: [Proxmox CLI source](https://github.com/proxmox/pve-container/blob/master/src/PVE/CLI/pct.pm),
|
||||
[.NET on Debian](https://learn.microsoft.com/en-us/dotnet/core/install/linux-debian),
|
||||
[NativeAOT prerequisites](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/),
|
||||
[Caddy TLS](https://caddyserver.com/docs/caddyfile/directives/tls),
|
||||
[Claude installation](https://code.claude.com/docs/en/setup),
|
||||
[Codex installation](https://github.com/openai/codex/blob/main/README.md).
|
||||
Source refresh uses [Git fetch](https://git-scm.com/docs/git-fetch),
|
||||
[fast-forward merge](https://git-scm.com/docs/git-merge) and
|
||||
[flock](https://man7.org/linux/man-pages/man1/flock.1.html).
|
||||
@@ -0,0 +1,72 @@
|
||||
# Preparing a public repository
|
||||
|
||||
The repository uses the [MIT license](../LICENSE). Build/runtime dependencies keep their own
|
||||
licenses. MIT licensing does not change authentication to providers or the running dashboard.
|
||||
|
||||
## Anonymous Git reads
|
||||
|
||||
After the repository host enables anonymous read access, HTTPS clone/fetch/pull need no login,
|
||||
email, password or Git token. Use the public URL in [contributing](../CONTRIBUTING.md#get-the-source).
|
||||
Pushes and maintainer API operations still require their own authorization.
|
||||
|
||||
For the Proxmox workflow, clone the published source on the host, then run its installer:
|
||||
|
||||
```bash
|
||||
git clone https://git.finalfactory.de/FinalFactory/FinalToken.git
|
||||
cd FinalToken
|
||||
bash tools/proxmox.sh install --ctid 201 --storage local-lvm \
|
||||
--domain usage.example.com --email [email protected]
|
||||
```
|
||||
|
||||
For a later update, refresh and deploy the clean checkout with one command:
|
||||
|
||||
```bash
|
||||
bash tools/proxmox-update.sh 201
|
||||
```
|
||||
|
||||
Here `--email` is the intended **provider account identity**, not a Git login. The installer
|
||||
reads the local checkout; the separate updater fetches its tracking branch first. The branch being cloned must contain the
|
||||
web/worker/installer changes. A public visibility setting alone does not publish uncommitted work.
|
||||
|
||||
## Files to keep local
|
||||
|
||||
The ignore rules exclude live deployment configuration, service keys, provider profiles, usage
|
||||
history, build outputs and screenshots/logs. Keep real configuration outside the checkout when
|
||||
possible. Example files must use reserved example domains and explicit placeholders.
|
||||
Ignoring a file does not remove a copy that was already committed.
|
||||
|
||||
The dashboard and client still authenticate their transport. Provider authorization goes through
|
||||
the official CLI on its machine; making source public does not make your running instance or
|
||||
CLI credentials public. Do not remove dashboard/client authentication to simplify Git downloads.
|
||||
|
||||
## Read-only audit
|
||||
|
||||
From the repository root:
|
||||
|
||||
```text
|
||||
python -B tools/check_public.py --history
|
||||
```
|
||||
|
||||
This checks Git-listed source files (including non-ignored untracked files), the actual staged
|
||||
index blobs and reachable local history (source, commit and tag text) for sensitive runtime filenames and recognizable
|
||||
private-key/provider-token patterns.
|
||||
It reports paths, line numbers and pattern names, never matching values. Credential/config files
|
||||
are reported by filename without opening them. Binary/oversized objects are reported as skipped.
|
||||
The check is a targeted pattern check, not proof that arbitrary secrets are absent.
|
||||
Index blobs are checked even when the working copy is clean or different. Historical trees are
|
||||
checked for private filenames even when the same blob also appeared under a harmless name.
|
||||
The shared path policy in `tools/source_policy.py` also keeps recognized runtime files out of
|
||||
Proxmox source archives; `.gitignore` alone does not filter a custom deployment archive.
|
||||
|
||||
For an independent secret-detector check, use a verified [Gitleaks release](https://github.com/gitleaks/gitleaks).
|
||||
Scan the candidate source snapshot, staged index and reachable Git history with full redaction.
|
||||
Keep reports outside the published source, review every finding, and never paste secret values
|
||||
into issues. A clean detector report is limited to its rules and scanned inputs.
|
||||
|
||||
Git author/committer identities and old source remain in history. Review whether those identities
|
||||
are suitable for publication. Do not silently rewrite attribution/history or delete branches to
|
||||
hide findings. Any real credential exposure needs revocation and a separately authorized history
|
||||
cleanup. Re-run the audit after that work and on the actual refs intended for publication.
|
||||
|
||||
Publication is a separate action: review the local changes, commit/push with authorization, and
|
||||
enable anonymous access on the intended host. This cleanup does not change repository visibility.
|
||||
@@ -4,11 +4,15 @@ Set by schmidt.florian on 2026-10-14 ([#1](https://git.finalfactory.de/FinalFact
|
||||
Each requirement has a stable ID. [Decisions](decisions.md) say how FinalToken meets them.
|
||||
|
||||
- **R1** NativeAOT on the newest .NET. Cross-platform: at least Windows 11 and CachyOS.
|
||||
- **R2** No sign-in to an AI provider inside the app and no API key or OAuth token. Data comes
|
||||
through the providers' command-line tools.
|
||||
- **R2** Provider credentials stay owned by the installed command-line tools. FinalToken can
|
||||
coordinate their official login and transiently relay an authorization response to the exact
|
||||
pending CLI process. It never stores or distributes provider access/refresh tokens or API keys.
|
||||
- **R3** Supported providers: at least Codex and Claude.
|
||||
- **R4** Opening the app shows a comprehensive stats panel, history included.
|
||||
- **R5** Small, non-intrusive popups remind the user when usage runs ahead of or behind the pace
|
||||
of a limit.
|
||||
- **R6** A Stream Deck plugin shows selected stats on its buttons.
|
||||
- **R7** The app installs or updates the Stream Deck plugin automatically, as the user chooses.
|
||||
- **R8** An authenticated self-hosted dashboard combines the user's Windows/Linux machines,
|
||||
keeping weekly sustainability central, account quota separate from deduplicated consumption,
|
||||
and measured, estimated, unknown and stale values distinct. See [D14](decisions.md#d14--self-hosted-dashboard-and-workers).
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
# Self-hosted dashboard and workers
|
||||
|
||||
The web dashboard leads with “will my allowance last until reset?” It uses Core's existing
|
||||
[D7 analysis](decisions.md#d7--pace), daily budgets, measured/estimated burn-up, recent-rate forecast,
|
||||
[reset history](decisions.md#d12--reset-history) and dated API list-price estimates.
|
||||
There is no inference gateway. Coding traffic continues through the user's own coding CLIs.
|
||||
|
||||
## Run locally
|
||||
|
||||
For automatic CT creation from a Proxmox host, use the [Proxmox install/update script](proxmox.md).
|
||||
|
||||
Build from the repository root:
|
||||
|
||||
```text
|
||||
dotnet build FinalToken.slnx -c Release
|
||||
```
|
||||
|
||||
Create an operator-owned `server.json` outside the source tree. Account ids represent one actual
|
||||
provider subscription/account. Bind every profile using the same account to the same id.
|
||||
Do not merge separate provider organizations/workspaces simply because their email is the same:
|
||||
this version verifies email, not organization entitlement. Use distinct account ids/profiles.
|
||||
|
||||
```json
|
||||
{
|
||||
"accounts": [
|
||||
{ "id": "personal-claude", "provider": "Claude", "label": "Personal Claude", "expectedEmail": "[email protected]", "timeZone": "Europe/Berlin" },
|
||||
{ "id": "personal-codex", "provider": "Codex", "label": "Personal Codex", "expectedEmail": "[email protected]", "timeZone": "Europe/Berlin" }
|
||||
],
|
||||
"machines": [
|
||||
{ "id": "desktop", "label": "Desktop", "osUser": "your-os-user", "profiles": [
|
||||
{ "id": "claude", "accountId": "personal-claude" },
|
||||
{ "id": "codex", "accountId": "personal-codex" }
|
||||
] }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Set `FINALTOKEN_SERVER_CONFIG` to that file, `FINALTOKEN_SERVER_DATA` to a writable data directory,
|
||||
`FINALTOKEN_DASHBOARD_KEY` to a random key of at least 32 characters and
|
||||
`FINALTOKEN_MACHINE_desktop` to a different random key of at least 32 characters.
|
||||
For example generate keys with your password manager or `openssl rand -hex 32`.
|
||||
Do not put keys in source control, command arguments, URLs or screenshots.
|
||||
|
||||
Start the server from the repository root:
|
||||
|
||||
```text
|
||||
dotnet run --project src/FinalToken.Web -c Release --no-build
|
||||
```
|
||||
|
||||
By default it listens on `http://127.0.0.1:5187`. Open exactly that URL and enter the dashboard key.
|
||||
For a remote deployment, set `FINALTOKEN_PUBLIC_ORIGIN` to the public HTTPS origin and run a TLS
|
||||
reverse proxy that preserves its Host header, or configure HTTPS directly in Kestrel.
|
||||
`ASPNETCORE_URLS` changes the listening address. Do not expose a plain HTTP listener to a remote
|
||||
network. No forwarded-header trust is enabled automatically. Restrict direct backend access;
|
||||
the reverse proxy must not log request bodies or authorization headers. Login URLs/codes are
|
||||
deliberately absent from server logs and disk state. TLS termination sees the transient code.
|
||||
Keys authorize all profiles on their configured machine; use service-account file/environment
|
||||
permissions and a private network/firewall. Rotate a machine key on both ends to revoke it.
|
||||
|
||||
## Configure each worker
|
||||
|
||||
Run one worker under the OS user that owns the official CLIs. It cannot switch OS users remotely.
|
||||
Use absolute paths in `worker.json`; a profile's `configDirectory` is the existing `.claude` or
|
||||
`.codex` directory (or the relevant environment override), and `dataDirectory` is its existing
|
||||
FinalToken history/settings directory. Use a separate data/config/state directory per account.
|
||||
|
||||
```json
|
||||
{
|
||||
"machineId": "desktop",
|
||||
"serverUrl": "http://127.0.0.1:5187",
|
||||
"stateDirectory": "<absolute worker metadata directory>",
|
||||
"profiles": [
|
||||
{ "id": "claude", "provider": "Claude", "expectedEmail": "[email protected]", "configDirectory": "<absolute Claude config directory>", "dataDirectory": "<absolute existing FinalToken data directory>" },
|
||||
{ "id": "codex", "provider": "Codex", "expectedEmail": "[email protected]", "configDirectory": "<absolute Codex config directory>", "dataDirectory": "<absolute separate FinalToken data directory>" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
JSON backslashes must be escaped on Windows, or use forward slashes. `cliPath` is an optional
|
||||
local executable override; ordinary native/npm CLI discovery reuses the desktop code.
|
||||
Set `FINALTOKEN_WORKER_KEY` to the server's key for this machine. Start from the repository root:
|
||||
|
||||
```text
|
||||
dotnet run --project src/FinalToken.Worker -c Release --no-build -- <absolute worker.json path>
|
||||
```
|
||||
|
||||
Remote worker URLs require HTTPS. Workers only make outbound connections; no worker port is open.
|
||||
Use the OS service manager/Task Scheduler for unattended startup, under the intended user with
|
||||
the CLI on PATH. A Linux/LXC worker needs .NET 10 (or a future locally built NativeAOT binary),
|
||||
installed official CLIs, writable profile directories, outbound HTTPS and any CLI keychain
|
||||
requirements. It needs no desktop/X11. Actual Linux/LXC operation has not been exercised here.
|
||||
The existing release ZIP tool does not package the new hosts yet; source builds and the
|
||||
[Proxmox installer](proxmox.md) are the supported setup paths.
|
||||
|
||||
## History, account identity and settings
|
||||
|
||||
The worker acquires the normal store lock before refreshing the existing store. When the desktop
|
||||
app owns it, the worker reads existing observations and independently scans metadata using its
|
||||
own cursors. It does not replace the user's existing settings. Both provider settings may remain
|
||||
in an older desktop store; for two worker profiles, point one at that existing store and give
|
||||
the other a new directory. Shared-provider historical import can use a read-only copy made while
|
||||
the desktop is stopped. Never run two writers against a copied active journal.
|
||||
|
||||
Source metadata is durably saved before export cursor advancement. The server persists received
|
||||
metadata and last-seen state atomically; offline data remains visible. Claude response ids dedupe
|
||||
across transcripts, resumed copies and machines. Codex session ids/timestamps are merged before
|
||||
calculating cumulative increases. Conflicting response/counter metadata is excluded with a
|
||||
warning. A source copied under a different session id cannot be recognized as the same session.
|
||||
Per-machine attribution of a shared session is inherently ambiguous; the dashboard shows configured
|
||||
profiles/health, while consumption charts show the deduplicated account total.
|
||||
|
||||
Existing hourly history has no response identities. To import older history without overlapping
|
||||
identified records, add these account fields to `server.json`:
|
||||
|
||||
```json
|
||||
{ "legacyMachine": "desktop", "legacyProfile": "claude", "historyBefore": "2026-11-01T00:00:00Z" }
|
||||
```
|
||||
|
||||
This is a fragment to merge into one account entry. Choose one source and a fixed whole UTC hour
|
||||
within the still-available source logs. Before it, use that source's hourly buckets once; after
|
||||
it, use identified events only. Missing source logs after the cutoff produce incomplete history,
|
||||
not reconstructed guesses. Account assignment of older logs is an operator assertion. Never
|
||||
reuse a profile directory for another account; configure a new profile instead.
|
||||
For Codex sessions without a cumulative sample before the cutoff, the first available total
|
||||
has an unknown migration baseline and is omitted with a warning. Later increases still count.
|
||||
This can omit a new session's first use too; supplying complete pre-cutoff session history or
|
||||
avoiding legacy import is preferable to counting potentially imported usage twice.
|
||||
|
||||
The newest account/window observation wins; quotas are never added. Its profile's existing
|
||||
threshold, hidden-window settings and probe interval control that window. A sample older than
|
||||
three probe intervals, an expired reset, offline source or unhealthy login withholds forecasts.
|
||||
The account timezone controls days/DST. There is no working-hour schedule in existing D7.
|
||||
API list-price values are labelled estimates; unknown models stay unpriced, and prices never
|
||||
imply guaranteed subscription capacity.
|
||||
|
||||
## Official login coordination
|
||||
|
||||
Select a machine/profile under **Machines & official CLI logins**, then **Log in / renew**.
|
||||
Verify its OS user and expected email before opening the official authorization page.
|
||||
|
||||
- Claude: the worker invokes `claude auth login --claudeai --email <expected email>` with the
|
||||
selected `CLAUDE_CONFIG_DIR`. When the CLI prints its manual-code prompt, paste the browser's
|
||||
authorization code into the dashboard. It travels transiently to that exact process's stdin.
|
||||
There is no automatic forwarding of a desktop browser's localhost callback to a worker.
|
||||
- Codex: the worker invokes `codex login --device-auth` with the selected `CODEX_HOME`, displays
|
||||
the CLI's official URL/device code and lets the CLI poll/exchange/store locally. Device auth
|
||||
must be enabled for that account/workspace. No remote localhost callback is needed.
|
||||
- FinalToken verifies the resulting email with `claude auth status --json` or Codex app-server
|
||||
`account/read`. A CLI exit code alone is not success. A mismatch may already have replaced that
|
||||
profile's CLI login; FinalToken flags it and excludes new collection. Log in again with the
|
||||
correct account. It does not copy, revert or auto-switch credentials.
|
||||
|
||||
Only the initiating browser session can inspect/respond/cancel its pending login. One attempt
|
||||
per machine/profile is allowed. Cancellation and the 15-minute deadline kill the process tree;
|
||||
worker restart invalidates pending routing. A server restart loses memory-only attempts; the
|
||||
worker's local deadline still cancels its CLI. Closing the dialog does not cancel a login:
|
||||
press **Cancel login** first if that is intended. Access/refresh tokens, API keys, cookies and
|
||||
credential files are never sent through FinalToken. The authorization code necessarily passes
|
||||
through browser/server/worker memory; it is never deliberately persisted or logged.
|
||||
|
||||
Provider login health is observed, not a fabricated 30-day expiry. The official CLI owns refresh.
|
||||
The real manual Claude stdin handoff and real provider authorization still need an interactive
|
||||
test with the installed CLI version. If redirected stdin is unsupported, cancel and run the login
|
||||
in the selected machine's terminal. Synthetic CLI integration tests exercise the implementation,
|
||||
not a provider's live service or changing terminal behavior.
|
||||
|
||||
## Provider usage limitations
|
||||
|
||||
Codex quota comes through its CLI app-server/rollout integration (D4). Claude's existing D3
|
||||
`-p /usage` probe is a legacy integration; current official docs do not establish it as a
|
||||
supported non-interactive quota API. Worker profiles default `enableLegacyClaudeProbe` to false.
|
||||
Existing Claude observations can be read but become stale; current subscription allowance may
|
||||
remain unknown. Enable the legacy probe only after verifying that your installed CLI resolves
|
||||
it locally without a model request. No private OAuth usage endpoint was added. Tokens are still
|
||||
collected locally from supported log parsers after identity verification.
|
||||
|
||||
The metadata inventory currently exports at most 100,000 source records, 30,000 quota samples
|
||||
and 100,000 legacy hourly/model points per profile. Requests are capped at 32 MiB. Full inventory
|
||||
exchange favors small personal fleets; it is not a streaming fleet database. When bounds or
|
||||
collection fail, previous metadata is retained and collection failure is shown. Server history
|
||||
has no automatic retention/deletion UI. Back up its metadata directory and the worker state.
|
||||
|
||||
Official references checked 2026-11-14:
|
||||
|
||||
- [Claude authentication and manual code handoff](https://code.claude.com/docs/en/authentication)
|
||||
- [Claude CLI auth commands](https://code.claude.com/docs/en/cli-reference)
|
||||
- [Codex authentication](https://learn.chatgpt.com/docs/auth?surface=cli)
|
||||
- [Codex CLI flags](https://learn.chatgpt.com/docs/cli/reference)
|
||||
- [Official Codex device-code implementation](https://github.com/openai/codex/blob/main/codex-rs/login/src/device_code_auth.rs)
|
||||
- [Official Codex app-server account identity](https://github.com/openai/codex/blob/main/codex-rs/app-server/README.md)
|
||||
|
||||
## Verification
|
||||
|
||||
Run from the repository root:
|
||||
|
||||
```text
|
||||
dotnet build FinalToken.slnx -c Release
|
||||
dotnet test --solution FinalToken.slnx -c Release
|
||||
python -B tools/test_web_dashboard.py
|
||||
python -B tools/docs/check_docs.py
|
||||
node --check src/FinalToken.Web/wwwroot/app.js
|
||||
```
|
||||
|
||||
The Python check launches the real web/worker executables with a synthetic C# CLI and temporary
|
||||
profiles. It tests HTTP authentication/CSRF/session isolation, Claude code relay, Codex device
|
||||
flow, cancellation, account mismatch, deduplicated history and absence of login payloads in
|
||||
server state. `--serve-fixture` starts the same provider-free setup for local visual inspection.
|
||||
It never invokes the installed Claude or Codex CLIs. NativeAOT publishing and live provider
|
||||
authorization require separate verification; analyzers/build success alone do not prove them.
|
||||
Reference in New Issue
Block a user