diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 2b221bd3..5f7a837f 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -7,7 +7,7 @@ to `dev`; with the CLI, pass `--base dev`. Before writing: every release ships an arm64 disk image for macOS, x64 and arm64 installers for Windows, and x86_64 and aarch64 AppImages for -Linux. The macOS build is Apple Silicon only and not signed by Apple, +Linux. The macOS build is Apple silicon only and not signed by Apple, the Windows installers are not code-signed, and Linux gets the AppImage and nothing else. Gateway behavior (routing, forwarding, cost, redaction) lives in ThinkWatch Core, not here. See CONTRIBUTING.md. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7a8fb2f6..75e5c988 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,7 +20,7 @@ These decisions are settled and not up for a PR: five files for people to install, each with the gateway inside it and a sha256 beside it: an arm64 disk image for macOS, an x64 and an arm64 installer for Windows, and an x86_64 and an aarch64 AppImage for Linux. -- **macOS: Apple Silicon only, and not signed by Apple.** The macOS +- **macOS: Apple silicon only, and not signed by Apple.** The macOS artifact is an arm64 `.app` in a disk image, signed with the project's own self-signed certificate. That certificate does not satisfy Gatekeeper; it exists so that every release has the same signer, which is what lets @@ -94,7 +94,7 @@ These are load-bearing and a PR that breaks one will be asked to change: first.** Every destructive action goes through our own confirmation UI, never a browser `confirm`. -## Building a `.app` +## Building a release bundle `pnpm tauri build` produces a self-contained bundle. The `twcore` inside it is downloaded from a ThinkWatch-Core release and checksum-verified — @@ -107,11 +107,18 @@ shipped beside it always come from one core commit. To move to a newer core: change the `tag` in `src-tauri/Cargo.toml`, `cargo update -p tw-api`, rebuild. -`pnpm tauri dev` does not run any of this and needs no network. There, -`locate_core` finds a binary in a sibling `thinkwatch-core` checkout. - -On Windows the same command produces an NSIS installer instead, and it -is not code-signed; on Linux it produces an AppImage. The macOS bundle is Apple Silicon only, and neither +Every build needs that file, including `pnpm tauri dev`, `cargo clippy` +and `cargo test`, because Tauri checks at compile time that the +resources `tauri.conf.json` declares exist. In a fresh checkout, run +`bash src-tauri/scripts/fetch-core.sh` once before the first build. +`pnpm tauri dev` then runs the copy the build places beside the debug +binary, and the control-plane tests start it and complete a handshake +with it, so it has to be the version `Cargo.lock` pins. + +On macOS the command produces the `.app`, which the release workflow +puts in a disk image with `dmgbuild` (layout in `src-tauri/dmg/`); on +Windows it produces an NSIS installer, which is not code-signed; on Linux +it produces an AppImage. The macOS bundle is Apple silicon only, and neither signed nor notarized. On macOS 15 and later a downloaded copy has to be cleared once: diff --git a/README.md b/README.md index 0673e19e..ee2bbe1f 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,48 @@

- - - - - - + Tauri 2 + React 19 + License: MIT + macOS + Windows + Linux

# ThinkWatch Lite **[English](README.md) | [中文](README.zh-CN.md)** -ThinkWatch Lite is a desktop app that runs a local AI API gateway from the -macOS menu bar, the Windows notification area or the Linux system tray. Claude Code, Codex and other -clients of the Anthropic, OpenAI and Gemini APIs send their requests to the -gateway, and Lite shows what each request cost, which upstream served it and -why, and what was sent along with it. +ThinkWatch Lite is a desktop app for macOS, Windows and Linux that runs an AI +API gateway on the local machine. Claude Code, Codex and other clients of the +OpenAI and Anthropic APIs send their requests through it, and the app records +what each request cost, which upstream served it and which keys were redacted +before it was sent. The gateway can also be deployed on a server; the app then +connects to ThinkWatch Core on that server over an encrypted control channel. -It runs on macOS 12 or later on Apple Silicon, on Windows 10 21H2 or later on -x64 or ARM64, and on Linux on x86_64 or aarch64 (Ubuntu 22.04, Debian 12, -Fedora 36 or later). + + + The overview for the last seven days: tokens, cost and requests against the seven days before, with the estimated part of the cost and the unpriced requests stated; a trend chart stacked by model with the periods that had failures marked; and the models ranked by tokens and cost + + +The app runs in the menu bar on macOS and in the system tray on Windows and +Linux. It requires macOS 12 or later on Apple silicon, Windows 10 21H2 or later +on x64 or ARM64, or Linux on x86_64 or aarch64 (Ubuntu 22.04, Debian 12, +Fedora 36 or later). The interface is available in English and Simplified +Chinese; it follows the system language and can be changed in Settings. The +app updates itself on all three platforms, except that a Homebrew installation +is updated through Homebrew. ## Install -| Platform | Download | +| Platform | Install | |---|---| -| macOS, Apple Silicon | `brew install --cask thinkwatchproject/tap/thinkwatch-lite`, or [`ThinkWatch-Lite--arm64.dmg`](https://github.com/ThinkWatchProject/ThinkWatch-Lite/releases/latest) | +| macOS, Apple silicon | `brew install --cask thinkwatchproject/tap/thinkwatch-lite`, or [`ThinkWatch-Lite--arm64.dmg`](https://github.com/ThinkWatchProject/ThinkWatch-Lite/releases/latest) | | Windows, x64 | [`ThinkWatch-Lite--x64-setup.exe`](https://github.com/ThinkWatchProject/ThinkWatch-Lite/releases/latest) | | Windows, ARM64 | [`ThinkWatch-Lite--arm64-setup.exe`](https://github.com/ThinkWatchProject/ThinkWatch-Lite/releases/latest) | | Linux, x86_64 or aarch64 | `curl -fsSL https://github.com/ThinkWatchProject/ThinkWatch-Lite/releases/latest/download/install.sh \| sh`, or [`ThinkWatch-Lite--.AppImage`](https://github.com/ThinkWatchProject/ThinkWatch-Lite/releases/latest) | -The [Lite page](https://thinkwat.ch/lite#install) has one-click downloads of -the latest version and picks the Windows or Linux architecture for you. The gateway, +The [Lite page](https://thinkwat.ch/lite#install) offers a one-click download +of the latest version and selects the Windows or Linux architecture +automatically. The gateway, [ThinkWatch Core](https://github.com/ThinkWatchProject/ThinkWatch-Core), ships inside the app; nothing else needs to be installed. @@ -71,15 +82,15 @@ Get-FileHash .\ThinkWatch-Lite--x64-setup.exe ``` The installer sets the app up for all users in Program Files, so Windows asks -for administrator permission. It requires Windows 10 21H2 or later; WebView2, which -Windows 11 already includes, is downloaded during installation if it is +for administrator permission. It requires Windows 10 21H2 or later; WebView2, +which Windows 11 already includes, is downloaded during installation if it is missing. The installer is **not code-signed**, and no certificate will be bought. Running a downloaded copy brings up SmartScreen's full-screen warning, "Windows protected your PC". Choose **More info**, then **Run anyway**. -Once installed, the app lives in the notification area. Data is kept in +Once installed, the app runs from the notification area. Data is kept in `%APPDATA%\ThinkWatch`. ### Linux @@ -130,49 +141,100 @@ kept in `~/.thinkwatch`. ## Features +The main window has nine pages: Overview, Traffic, Clients, Keys, Upstreams, +Routing, Security, MCP and Settings. + ### Usage and cost -Tokens, cost and requests over any period, broken down by model, with the cache -hit rate, the net savings from caching and latency percentiles per model. -Measured costs, estimated costs and unpriced requests are reported separately -and never added together. Subscription accounts such as a ChatGPT sign-in are -priced by the price sheet like any other upstream, and an upstream such as a -local model can be set to free. Every request records the price sheet and the -date of the prices it was costed with. +The Overview page reports tokens, cost and requests for the last 24 hours, +7 days, 30 days or a custom range, each against the period before; a live view +follows the last ten minutes. A trend chart stacks tokens or cost by model, and +the model ranking beneath it opens the matching requests. Further sections +cover the prompt cache (hit rate, the net savings it brought and the hit rate +per model), latency (median and 95th-percentile time to first byte, per model +and per upstream) and what each protection found. + +The cost figure states how much of it is estimated, for instance for a +response that was cut off before it finished. Requests whose model has no +price, and requests whose upstream reported no usage, are counted separately +and never added in as zero. Prices come from price sheets: the default one +follows LiteLLM's public prices and is refreshed once a day, and a custom one +applies a multiplier and its own prices for particular models, as needed for a +relay whose prices differ from the official ones. A subscription account such +as a ChatGPT sign-in is priced from the price sheet like any other upstream, +and an upstream such as a local model can be set to free. Each request's cost +is fixed when the request finishes, and the request records the price sheet +and the date of the prices it was costed with. + +### Traffic and sessions + +The Traffic page lists requests as they arrive: status, key, model, upstream, +time to first byte and total time, tokens and cost, with marks for a converted +API format, redacted keys and a blocked or suspicious tool call. The list can +be filtered by key, upstream and model, or narrowed to failed or unpriced +requests. The Sessions view groups the requests of one conversation into +turns, with the input tokens and the cost of each turn. + +A request opens into its timeline, its routing (the rule it matched, the group +it went through and each attempt with its status and duration), the request +and response bodies, and its usage and cost. A finished request can be sent +again, unchanged, to another upstream after an estimate of its cost, and the +two responses are shown side by side. - - The usage overview: tokens, cost and requests, a 24-hour trend stacked by model, the leaderboard by model and the cache hit rate + + The traffic page: each request with its key, model, upstream, time to first byte and total time, tokens and cost, with marks for converted formats, redacted keys and a blocked request, and one request answered locally by the gateway -### Routing and failover +### Client setup -Routing rules send requests to an upstream or a group of upstreams by model, -key, token count, tools, images and other properties. Every request records -the rule it matched, the group it went through and each attempt with its -status and duration. +The Clients page points Claude Code, Codex, opencode, Zed and Aider at the +gateway. Before anything is written, it lists the fields that change and what +else the change affects (the ChatGPT desktop app, for instance, reads the same +configuration file as Codex), shows the full diff and backs up the original +file. Only the settings that point the client at the gateway change, and each +client receives a key of its own. A connected client can be restored at any +time, on its own or together with all the others. Cursor, Continue and +Gemini CLI come with step-by-step instructions and a key created for them. For +every client the page shows whether it is in use, waiting for its first +request or not in effect, and its requests over the last 24 hours. - - The traffic page with a request open: the primary upstream answered 529, the request moved to openrouter, and Anthropic Messages was converted to OpenAI Chat Completions + + The clients page: Claude Code and Codex connected, each with its own key and its requests over the last 24 hours; opencode not connected; Cursor set up by hand and in use; Continue and Gemini CLI not yet set up; Zed and Aider not detected -A dry run evaluates the rules for a given request and shows where it would go -and why, without sending anything and without incurring any cost. +### Keys + +Clients reach the gateway with a key, on the local machine as well. The Keys +page lists the default key, used by clients that were not given one of their +own, and a key for each connected client, labelled with the client it belongs +to so that its requests can be told apart in Traffic. Each key has a route, +the models it may use (all, none, or chosen models and patterns such as +`gpt-5*`), an optional limit on concurrent requests, and its requests and cost +over the last 24 hours. A key can be disabled, which rejects every request +made with it, or rotated; rotating writes the new key into the configuration +of the client that uses it. - - A routing dry run: the first two rules did not match and say why, the third one did, and the request goes to a group that tries two upstreams in order + + The keys page: the default key and one key each for Claude Code, Codex and Cursor, with the route each key uses, the models it may use, and its requests and cost over the last 24 hours ### Upstreams -API keys, a ChatGPT account signed in from the app (with its usage limits and -reset times), relays such as OpenRouter, and local models. When a client and an -upstream speak different API formats, requests are converted between Anthropic -Messages, OpenAI Chat Completions, OpenAI Responses and Gemini, and the fields -that cannot be carried over are listed. Upstreams can be reached through an -outbound proxy and priced with a custom price sheet. +Upstreams are the services requests are forwarded to: API keys for Anthropic, +OpenAI, Google Gemini, DeepSeek or any compatible endpoint, a ChatGPT account +or a Z.ai / BigModel account signed in from the app, relays such as +OpenRouter, and local models such as Ollama. A ChatGPT account shows its usage +limits and reset times. When a client and an upstream use different API +formats, requests are converted between Anthropic Messages, OpenAI Chat +Completions, OpenAI Responses and Gemini, and the fields that cannot be +carried over are listed on the request. Upstreams can be reached through an +outbound proxy and priced with a price sheet of their own; proxies and price +sheets have tabs on the same page. A connection test times the DNS lookup and +the TCP, TLS and proxy handshakes without incurring any cost; an inference test +measures the time to first token and estimates its cost before it runs. API keys and header values can be written as `${NAME}` to read a system environment variable. On macOS these come from the login shell, so variables @@ -183,91 +245,229 @@ reopening the app picks it up. Proxy variables such as `HTTPS_PROXY`, and `PATH`, are not read. - - The upstream list: API-key upstreams, a ChatGPT account on Plus with 34% of its 5-hour quota used, OpenRouter through a proxy, DeepSeek, Gemini and a local Ollama, each with its 24-hour requests, cost and time to first byte + + The upstreams page: API-key upstreams for Anthropic, DeepSeek and Gemini, a relay priced with its own price sheet, a ChatGPT Plus account with 58% of its 5-hour limit used, OpenRouter through a proxy and a local Ollama set to free, each with its requests, cost and median time to first byte over 24 hours + + +### Routing and failover + +Each key follows a route, and keys without one follow the default route. A +route is a list of rules evaluated in order. A rule matches on the model, the +key, the client's API format, input tokens, `max_tokens`, the number of tools, +images, extended thinking, streaming, prompt caching or the kind of auxiliary +request; it then forwards the request to an upstream or a group, or refuses +it, and can rewrite the model, `max_tokens` or extended thinking. A group puts +several upstreams behind one name and decides the order in which they are +tried: as listed, manually selected, in turn, lowest latency first or lowest +cost first. When an attempt fails, the request moves on to the next upstream, +and by default a session stays on one upstream so that its prompt cache keeps +hitting. A map at the top of the page traces every key through its route and +groups to the upstreams. + + + + The routing page: a map from keys through routes and groups to upstreams, and the three routes with the rules each applies in order + + +Auxiliary requests that clients send on their own (health checks, warm-ups, +titles, topic detection and input suggestions) can be answered locally at no +cost, passed through, or routed by the rules. + +Every request records the rule it matched, the group it went through and each +attempt with its status and duration. A dry run evaluates the rules for a +given request and shows where it would go and why, without sending anything +and without incurring any cost. + + + + A routing dry run: a request from the cursor key for claude-sonnet-5 in the OpenAI Chat Completions format does not match the gemini rule, which says why, matches the catch-all rule and goes to the lowest-cost group, which tries relay and then anthropic, converting the request to Anthropic Messages ### Security -- **Outbound redaction** replaces keys, private keys and connection strings - before a request leaves, and restores them in the response. -- **Tool-call inspection** cuts off the response stream when an upstream returns - a tool call carrying a command that would grant code execution. -- **Hidden characters** refuses a request whose user messages or tool results - carry Unicode tag characters or bidirectional controls. -- **Content filter** refuses a request whose user messages or tool results match - a keyword or regex rule. Only the three explicit "ignore previous - instructions" rules are on out of the box. -- **Output limit** cuts a streamed answer off where it passes a set number of - characters, and withholds a non-streamed answer that is over it. - -All of them apply to every upstream and run in Off, Observe or Enforce mode; the -output limit starts Off and the rest start in Observe. The Security page lists -every rule: built-in rules can be turned off one at a time, custom rules are -regular expressions (or keywords, for the content filter), and any rule can be -tried on a sample first. Everything the protections catch is kept in a log. +The Security page holds five protections. They apply to every upstream and +every key alike, and each runs in one of three modes: Off, Observe (detect and +record, change nothing) or Enforce. The output limit starts Off and the other +four start in Observe, so out of the box no request is changed or blocked. + +- **Outbound redaction** looks for credentials in a request before it leaves: + API keys and tokens for Anthropic, OpenAI, GitHub, Slack, AWS, Google, + GitLab, Stripe, npm, DigitalOcean and SendGrid, private keys, JWTs and + passwords in connection strings. In Enforce mode they are replaced with + placeholders and restored where the response repeats them. Rules for + internal IP addresses and internal domains are included and start off. +- **Tool-call inspection** checks the tool calls a model returns for commands + that download or decode code and run it, send out environment variables or + credential files, read private keys or cloud credentials, or install startup + items and scheduled jobs. In + Enforce mode such a call cuts the response off, so the client never receives + a complete call to run. Deleting the home or root directory and making files + world-writable are only recorded by default. +- **Hidden characters** looks for Unicode tag characters and bidirectional + control characters in what the client sends, tool results included, and in + Enforce mode refuses the request. +- **Content filter** matches keywords or regular expressions against the + messages the client sends, tool results included, and in Enforce mode + refuses a request that matches a blocking rule. Of the built-in rules, the + three against explicit "ignore previous instructions" phrasing are on by + default; rules for jailbreaks, persona manipulation, prompt extraction and + their Chinese counterparts can be switched on. +- **Output limit** stops an answer that grows past a set number of characters, + 100,000 by default: a streamed answer is cut off at that point and a + non-streamed one is replaced with an error. Reasoning and tool-call + arguments do not count towards the limit. + +The page lists every rule. Built-in rules can be switched on or off one at a +time, and those for tool calls and content can be set to act or only record in +Enforce mode. Custom rules are regular expressions, or keywords for the content +filter, and any rule can be tried on a sample text first. Everything the +protections find is kept in the log on the first tab, together with the +request it came from. + + + + The security log: credentials replaced before a request left, one of them matched by a custom rule; a download-and-run tool call cut off; and hidden characters, a delete command and an injected instruction recorded. Each entry names the key, client, model and upstream of its request + ### MCP -The MCP page shows the MCP servers each client has configured side by side, and -copies a server to another client or removes it, showing the change before -anything is written. It also lists skills and hooks, and scans client -configuration files for hidden characters, injected instructions and dangerous -commands. +The MCP page covers what clients load from their own configuration files, +which does not pass through the gateway. + +- **Servers:** the MCP servers configured in Claude Code, Claude Desktop, + Cursor, Codex, opencode and Zed, side by side. A server can be copied from + one client to another or removed from a client; the change is shown before + anything is written, and the original file is backed up. Copying and removing + work for Claude Code, Claude Desktop, Cursor and Codex; opencode and Zed are + listed but not written to. A remote server on another host is marked as + third party, since using it sends the surrounding context to that host, and + a server configured differently in different clients is marked as well and + can be compared side by side. +- **Skills and hooks:** the installed skills and configured hooks, with the + client each belongs to. +- **Findings:** client configuration, skills, hooks, slash commands, subagents + and project instruction files are scanned for hidden characters, prompt + injection, dangerous commands and overly broad permissions, and each finding + is graded high, medium or low. The scan only reports; it never changes a + file. + +The app watches these files while it runs, and a new finding raises a system +notification. - - The findings page: a hook that downloads and runs a remote script, zero-width characters hidden in a skill, an upstream whose share of high-risk responses is rising, and the MCP servers each client has configured + + The MCP page: the MCP servers configured in Claude Code, Claude Desktop, Cursor, Codex, opencode and Zed side by side, with remote third-party servers and a server configured differently in two clients marked; the header counts one high, one medium and one low finding in 11 scanned files -### Client setup +### Settings -Claude Code, Codex, opencode, Zed and Aider can be pointed at the gateway -from the app. The change is shown as a diff before anything is written, the -original file is backed up, only the endpoint and key fields change, and the -change can be restored at any time. Cursor, Continue and Gemini CLI come with -step-by-step instructions. +Settings has six sections. Connection lists the local core and the saved +remote cores, described [below](#connecting-to-a-remote-core). General sets +the language, the appearance, what the menu bar item shows on macOS, launch at +login, and whether notices arrive as system notifications, in the app only or +not at all. Listening sets who can reach the gateway (this machine only, the +local network of a chosen interface, or every interface), its port and the +allowed address ranges. Log retention sets how long request payloads and +request records are kept, and a size cap for payloads. About shows the +version, checks for updates and produces a diagnostics bundle with keys and +addresses masked. Uninstall restores every connected client and removes the +autostart entry, and is meant to be run before the app is deleted. + +### Menu bar, system tray and notifications + +On macOS the menu bar shows today's tokens above today's cost; the numbers turn +orange when a subscription quota is nearly used up and red when it is, and +Settings can reduce the item to the icon or to the numbers. + +

+ + + The menu bar item: the ThinkWatch mark with a dot for a request in progress, and today's 13.3M tokens above today's cost of $9.34 + +

+ +Clicking it opens a native menu with the gateway's address and state, unread +notices, each subscription account's quotas and reset times, today's requests, +tokens and cost, and the requests in progress, followed by actions: choosing +the upstream of a manually selected group, copying the gateway address or the +default key, undoing the last configuration change, switching connections and +checking for updates, all without opening the main window. - - The clients page: Claude Code and Codex pointed at the gateway and already serving requests, opencode not yet pointed at it, and the clients that have to be set up by hand + + The menu it opens: the gateway's address, output speed and state; the ChatGPT account's 5-hour and weekly quotas with their reset times; today's requests, tokens and cost; the request in progress; and actions to copy the gateway address or the default key, undo the last configuration change, switch connections, open settings and check for updates -### Menu bar and notifications - -The menu bar shows today's tokens over today's cost; the numbers turn orange -when a quota is nearly used up and red when it is. Settings can reduce it to the -icon or to the numbers. Clicking it opens a native menu with the gateway's -state, unread notices, each subscription account's quota and reset time, today's -usage and the requests in progress, plus common actions: switching a manually -selected upstream, copying the gateway address or the default key, undoing the -last configuration change and checking for updates, all without opening the main -window. System notifications report when the gateway stops forwarding, a -subscription quota runs out or a credential stops working; an unreachable -upstream, which a fallback usually covers, is only listed in the app. Notices as -a whole can be set to system notifications, in-app only, or off. Marking a -notice as read stops the bell from counting it; the notice stays in the list -until the problem behind it clears or the list is cleared. - On Windows the icon sits in the notification area. Hovering over it shows the gateway's state and today's tokens and cost; a left click opens the main window, and a right click opens the same menu, with quota bars written out as -text. Notices arrive as native Windows notifications. +text. On Linux the icon sits in the system tray. Clicking it opens the same menu, with Open ThinkWatch Lite as its first item and quota bars written out as text. -Notices go to the desktop's notification service. -

- - - Menu bar item: today's cost $24.72, output at 47 tokens per second - - - - Menu bar item: 34% of the subscription quota used, resets in 2 hours - -

+System notifications, native on macOS and Windows and sent through the +desktop's notification service on Linux, report when the gateway stops +forwarding or keeps restarting, the connection to a remote core drops, a +subscription quota runs out, a sign-in expires or an upstream rejects its +credential, a proxy cannot be reached, the configuration file fails validation, +a tool call matches a rule that cuts the response off, or suspicious content +appears in a client's configuration. A new version found by the automatic check +is announced the same way (see [Updates](#updates)). An unreachable upstream, +which a fallback usually covers, is only listed in the app. Notices as a whole +can be set to system notifications, in-app only, or off. Marking a notice as +read stops the bell from counting it; the notice stays in the list until the +problem behind it clears or the list is cleared. + +## Connecting to a remote core + +The gateway can also run on a server, where ThinkWatch Core runs as a system +service and the app connects to it over the network. +[Server deployment](https://github.com/ThinkWatchProject/ThinkWatch-Core/blob/main/docs/server.md) +in the ThinkWatch Core repository covers installing `twcore` on Linux, +enabling its remote control port and reading its key. + +In the app, Settings › Connection › Add remote connection takes a name, the +server's address, the control port and the key that `twcore control-key` +prints on the server. Testing the connection completes the encrypted handshake +and reads the server's core version; the connection can then be saved and +switched to. The connection menu at the foot of the sidebar, and the +Connection submenu of the menu bar or tray menu, switch between the local core +and any saved server. + + + + Adding a remote connection in Settings: the server's address, its control port and the key from twcore control-key; the connection test has completed the handshake and reports core 0.48.0 and the server's gateway address + + +- The app connects to one core at a time. While it is connected to a server, + the local core stops once its requests in progress have finished; its + configuration, keys and request history are kept, and it starts again when + the app switches back. If the server cannot be reached, the app keeps + retrying and never falls back to the local core on its own; the local core + is always listed and can be switched back to in one step. +- Overview, Traffic, Keys, Upstreams, Routing and Security show and change the + server's configuration and data. Settings separates the app's own settings + from the server's configuration, and the remote control listener and its key + can only be changed on the server. The Clients and MCP pages always act on + the machine the app runs on: connecting a client points it at the server's + gateway. +- The connection key is stored in a private file in the app's data directory, + readable only by the current user. +- A ChatGPT account is signed in with a device code, because a browser sign-in + returns to the machine that runs core. `${NAME}` in keys and header values + reads the environment of the core process on the server. The diagnostics + bundle is only offered for the local core. +- The server has to run the core version this release of the app expects. The + app checks this when it connects; if the versions differ, it names both and + gives the command that installs the expected version on the server, whether + it is newer or older than the installed one: + `sudo twcore upgrade --version --restart`. + + + + The connection menu at the foot of the sidebar while the app is connected to the remote core homelab: the local core on this Mac is stopped, and a second server is available to switch to + ## Updates @@ -275,8 +475,11 @@ The app looks for a new version shortly after it starts and once a day after that, reading a small manifest and nothing else. It can be turned off in Settings. -When there is one, a small window says so, and what happens next depends on how -the app was installed. +When the check finds one, the app sends a system notification, unless notices +are set to in-app only or off. The update window opens from that notification, +from the Install Version item that replaces Check for Updates in the menu bar or +tray menu, and from the update button in Settings › About. What happens next +depends on how the app was installed. **Downloaded from the releases page on macOS:** one press on the install button does the rest. The app downloads the update, verifies it against a key @@ -300,8 +503,10 @@ restarts. The AppImage has to be in a folder the user can write to. **Installed with Homebrew:** the window gives the command to copy, and the app never replaces itself. Homebrew records which version it put in `/Applications`; an app that overwrote it would be written back over by the -next `brew upgrade`. The window only appears once the tap carries the new -version, so the command always has something to install: +next `brew upgrade`. For a Homebrew installation the check reads the version in +the tap's cask instead of the release manifest, so a new version is only +reported once the tap carries it, and the command always has something to +install: ```bash brew update && brew upgrade --cask thinkwatch-lite @@ -314,23 +519,33 @@ day on its own. ```bash pnpm install +bash src-tauri/scripts/fetch-core.sh pnpm tauri dev ``` +`fetch-core.sh` downloads the `twcore` release that `Cargo.lock` pins, checks +its sha256 and places it in `src-tauri/resources/`, which every build needs. See [CONTRIBUTING.md](CONTRIBUTING.md) for the checks to run before opening a pull request. ## Layout ``` -src/ React 19 + Tailwind 4 frontend -src-tauri/ Tauri 2 shell: supervises core, renders the menu bar +src/ React 19 + Tailwind 4 interface +src-tauri/ Tauri 2 shell: supervises the local core, connects to a + local or remote core, draws the menu bar item and the tray + menu, sends system notifications, installs updates +src-tauri/crates/ tw-adopt (pointing clients at the gateway, MCP configuration) + and tw-scan (scanning client configuration) +scripts/shots/ the product screenshot pipeline (see CONTRIBUTING.md) ``` The gateway itself lives in ThinkWatch Core; this repository holds no routing, -forwarding, or accounting logic. It talks to core over a unix socket on macOS -and Linux, and over a loopback port on Windows; both carry a per-launch -credential. +forwarding, or accounting logic. The app reaches core's control channel over a +unix socket on macOS and Linux and over a loopback port on Windows, or over a +TCP port when core runs on a server. Every connection begins with an encrypted +handshake (Noise `NNpsk0`) keyed with the control key from core's +configuration (`listen.control.key`); no TLS certificates are involved. ## License diff --git a/README.zh-CN.md b/README.zh-CN.md index a7e7e87b..9fcfc1e4 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -1,43 +1,35 @@

- - - - - - + Tauri 2 + React 19 + License: MIT + macOS + Windows + Linux

# ThinkWatch Lite **[English](README.md) | [中文](README.zh-CN.md)** -ThinkWatch Lite 是运行本地 AI API 网关的桌面应用,常驻 macOS 菜单栏、Windows -通知区域或 Linux 系统托盘。Claude Code、Codex CLI 等使用 Anthropic、OpenAI、Gemini API 的客户端 -把请求发给这个网关,Lite 展示每个请求的费用、由哪个上游处理及其原因,以及随请求 -发出的内容。 +ThinkWatch Lite 是一款在本机运行 AI API 网关的桌面应用,支持 macOS、Windows 和 Linux。Claude Code、Codex 以及其他使用 OpenAI、Anthropic 接口的客户端经由它发出请求,应用记录每个请求的费用、所用的上游,以及发出前被脱敏的密钥。网关也可以部署在服务器上,此时应用通过加密的控制通道连接服务器上的 ThinkWatch Core。 - - ThinkWatch Lite 的用量概览:token、费用与请求数,按模型分层的 24 小时趋势,模型排行与缓存命中率 + + 最近 7 天的概览:token、费用与请求数及其与前 7 天的对比,注明费用中的估算部分和无法计价的请求;按模型分层的趋势图,标出有失败的时段;以及按 token 与费用排列的模型 -支持 macOS 12 及以上版本(仅限 Apple Silicon)、Windows 10 21H2 及以上版本 -(x64 或 ARM64),以及 Ubuntu 22.04、Debian 12、Fedora 36 及以上版本的 Linux -(x86_64 或 aarch64)。 +应用在 macOS 上常驻菜单栏,在 Windows 和 Linux 上常驻系统托盘。支持 macOS 12 及以上版本(Apple 芯片)、Windows 10 21H2 及以上版本(x64 或 ARM64),以及 Ubuntu 22.04、Debian 12、Fedora 36 及以上版本的 Linux(x86_64 或 aarch64)。界面提供英文和简体中文,默认跟随系统语言,可在「设置」中切换。应用在三个平台上均可自行更新;通过 Homebrew 安装的由 Homebrew 更新。 ## 安装 -| 平台 | 下载 | +| 平台 | 安装 | |---|---| -| macOS,Apple Silicon | `brew install --cask thinkwatchproject/tap/thinkwatch-lite`,或 [`ThinkWatch-Lite-<版本>-arm64.dmg`](https://github.com/ThinkWatchProject/ThinkWatch-Lite/releases/latest) | +| macOS,Apple 芯片 | `brew install --cask thinkwatchproject/tap/thinkwatch-lite`,或 [`ThinkWatch-Lite-<版本>-arm64.dmg`](https://github.com/ThinkWatchProject/ThinkWatch-Lite/releases/latest) | | Windows,x64 | [`ThinkWatch-Lite-<版本>-x64-setup.exe`](https://github.com/ThinkWatchProject/ThinkWatch-Lite/releases/latest) | | Windows,ARM64 | [`ThinkWatch-Lite-<版本>-arm64-setup.exe`](https://github.com/ThinkWatchProject/ThinkWatch-Lite/releases/latest) | | Linux,x86_64 或 aarch64 | `curl -fsSL https://github.com/ThinkWatchProject/ThinkWatch-Lite/releases/latest/download/install.sh \| sh`,或 [`ThinkWatch-Lite-<版本>-<架构>.AppImage`](https://github.com/ThinkWatchProject/ThinkWatch-Lite/releases/latest) | -官网的 [Lite 页面](https://thinkwat.ch/zh-CN/lite#install)提供最新版本的直接下载, -Windows 和 Linux 会自动选对架构。网关 -[ThinkWatch Core](https://github.com/ThinkWatchProject/ThinkWatch-Core) 随应用一起 -安装,无需另行安装。 +官网的 [Lite 页面](https://thinkwat.ch/zh-CN/lite#install)提供最新版本的一键下载,并自动选择 Windows 或 Linux 对应的架构。网关 [ThinkWatch Core](https://github.com/ThinkWatchProject/ThinkWatch-Core) 随应用一起安装,无需另行安装。 ### macOS @@ -45,37 +37,25 @@ Windows 和 Linux 会自动选对架构。网关 brew install --cask thinkwatchproject/tap/thinkwatch-lite ``` -也可以从 [最新版本的 release 页面](https://github.com/ThinkWatchProject/ThinkWatch-Lite/releases/latest) -下载 `ThinkWatch-Lite-<版本>-arm64.dmg`,与同页发布的 sha256 校验值核对后,将 -ThinkWatch Lite 拖入「应用程序」。应用**未经 Apple 注册开发者签名**,macOS 会 -为下载的副本添加隔离属性并拒绝打开,需先移除该属性: +也可以从[最新版本的 release 页面](https://github.com/ThinkWatchProject/ThinkWatch-Lite/releases/latest)下载 `ThinkWatch-Lite-<版本>-arm64.dmg`,与同页发布的 sha256 校验值核对后,将 ThinkWatch Lite 拖入「应用程序」。应用**未经 Apple 注册开发者签名**,macOS 会为下载的副本添加隔离属性并拒绝打开,需先移除该属性: ```bash xattr -dr com.apple.quarantine "/Applications/ThinkWatch Lite.app" ``` -也可以在首次打开被拒绝后,前往「系统设置 › 隐私与安全性」点击「仍要打开」。 -[Homebrew cask](https://github.com/ThinkWatchProject/homebrew-tap) 在安装时会 -自动完成这一步,此外只是把应用从磁盘映像复制到「应用程序」。 +也可以在首次打开被拒绝后,前往「系统设置 › 隐私与安全性」点击「仍要打开」。[Homebrew cask](https://github.com/ThinkWatchProject/homebrew-tap) 在安装时会自动完成这一步,此外只是把应用从磁盘映像复制到「应用程序」。 ### Windows -从 [最新版本的 release 页面](https://github.com/ThinkWatchProject/ThinkWatch-Lite/releases/latest) -下载与本机架构对应的安装程序:大多数电脑用 `ThinkWatch-Lite-<版本>-x64-setup.exe`, -ARM 处理器的电脑用 `ThinkWatch-Lite-<版本>-arm64-setup.exe`。下载后与同页发布的 -sha256 校验值核对: +从[最新版本的 release 页面](https://github.com/ThinkWatchProject/ThinkWatch-Lite/releases/latest)下载与本机架构对应的安装程序:大多数电脑用 `ThinkWatch-Lite-<版本>-x64-setup.exe`,ARM 处理器的电脑用 `ThinkWatch-Lite-<版本>-arm64-setup.exe`。下载后与同页发布的 sha256 校验值核对: ```powershell Get-FileHash .\ThinkWatch-Lite-<版本>-x64-setup.exe ``` -安装程序为所有用户安装,装入 Program Files,因此 Windows 会请求管理员权限。 -需要 Windows 10 21H2 及以上版本;缺少 WebView2 时安装程序会自动下载(Windows 11 -已自带)。 +安装程序为所有用户安装,装入 Program Files,因此 Windows 会请求管理员权限。需要 Windows 10 21H2 及以上版本;缺少 WebView2 时安装程序会自动下载(Windows 11 已自带)。 -安装程序**未经代码签名**,项目也不会购买证书。运行下载的安装程序时,SmartScreen -会显示全屏的蓝色警告「Windows 已保护你的电脑」,依次点击「更多信息」→「仍要运行」 -即可继续安装。 +安装程序**未经代码签名**,项目也不会购买证书。运行下载的安装程序时,SmartScreen 会显示全屏的蓝色警告「Windows 已保护你的电脑」,依次点击「更多信息」→「仍要运行」即可继续安装。 安装后应用常驻通知区域,数据保存在 `%APPDATA%\ThinkWatch`。 @@ -85,19 +65,11 @@ Get-FileHash .\ThinkWatch-Lite-<版本>-x64-setup.exe curl -fsSL https://github.com/ThinkWatchProject/ThinkWatch-Lite/releases/latest/download/install.sh | sh ``` -脚本下载与本机架构对应的 AppImage,与同页发布的 sha256 校验值核对后安装为 -`~/Applications/ThinkWatch-Lite.AppImage` 并启动。再次运行即用最新版本覆盖旧版本。 +脚本下载与本机架构对应的 AppImage,与同页发布的 sha256 校验值核对后安装为 `~/Applications/ThinkWatch-Lite.AppImage` 并启动。再次运行即用最新版本覆盖旧版本。 -手动安装时,从 [最新版本的 release 页面](https://github.com/ThinkWatchProject/ThinkWatch-Lite/releases/latest) -下载 `ThinkWatch-Lite-<版本>-x86_64.AppImage` 或 `ThinkWatch-Lite-<版本>-aarch64.AppImage`, -用 `sha256sum -c` 核对后允许其执行(`chmod +x`,或在文件管理器的「属性」中勾选 -「允许作为程序执行文件」),然后打开。AppImage 应放在当前用户可写的目录中(如 -`~/Applications`),以便自动更新替换。首次启动时会把 ThinkWatch Lite 添加到应用 -菜单,同时注册图标和 `thinkwatch://` 链接。Linux 版只发布 AppImage,不提供 deb、 -rpm、Flatpak 或 Snap 包。 +手动安装时,从[最新版本的 release 页面](https://github.com/ThinkWatchProject/ThinkWatch-Lite/releases/latest)下载 `ThinkWatch-Lite-<版本>-x86_64.AppImage` 或 `ThinkWatch-Lite-<版本>-aarch64.AppImage`,用 `sha256sum -c` 核对后允许其执行(`chmod +x`,或在文件管理器的「属性」中勾选「允许作为程序执行文件」),然后打开。AppImage 应放在当前用户可写的目录中(如 `~/Applications`),以便自动更新替换。首次启动时会把 ThinkWatch Lite 添加到应用菜单,同时注册图标和 `thinkwatch://` 链接。Linux 版只发布 AppImage,不提供 deb、rpm、Flatpak 或 Snap 包。 -AppImage 通过 FUSE 挂载自身,需要 fuse3 软件包中的 `fusermount3`(不需要 -libfuse2)。多数桌面系统已自带;如缺少: +AppImage 通过 FUSE 挂载自身,需要 fuse3 软件包中的 `fusermount3`(不需要 libfuse2)。多数桌面系统已自带;如缺少: | 发行版 | 命令 | |---|---| @@ -106,151 +78,175 @@ libfuse2)。多数桌面系统已自带;如缺少: | Arch Linux | `sudo pacman -S fuse3` | | openSUSE | `sudo zypper install fuse3` | -托盘图标依赖 AppIndicator。Ubuntu 已自带对应的 GNOME 扩展;Fedora 原生 GNOME -没有,需要另行安装 AppIndicator 扩展。没有托盘时,关闭窗口后网关继续运行,从应用 -菜单再次启动 ThinkWatch Lite 即可重新打开窗口。数据保存在 `~/.thinkwatch`。 +托盘图标依赖 AppIndicator。Ubuntu 已自带对应的 GNOME 扩展;Fedora 原生 GNOME 没有,需要另行安装 AppIndicator 扩展。没有托盘时,关闭窗口后网关继续运行,从应用菜单再次启动 ThinkWatch Lite 即可重新打开窗口。数据保存在 `~/.thinkwatch`。 -- **NVIDIA 显卡在 Wayland 下窗口空白**:以 `WEBKIT_DISABLE_DMABUF_RENDERER=1` - 启动应用。 -- **局域网内其他机器无法连接网关**:Fedora 默认启用的 firewalld 会拦截网关端口, - 需放行该端口;网关监听局域网时,设置页会给出相应提示。 -- **卸载**:先在「设置 › 完全卸载」中卸载,恢复应用接管过的客户端配置,并删除开机 - 启动项和应用菜单项;再删除 AppImage 文件。 +- **NVIDIA 显卡在 Wayland 下窗口空白**:以 `WEBKIT_DISABLE_DMABUF_RENDERER=1` 启动应用。 +- **局域网内其他机器无法连接网关**:Fedora 默认启用的 firewalld 会拦截网关端口,需放行该端口;网关监听局域网时,设置页会给出相应提示。 +- **卸载**:先在「设置 › 完全卸载」中卸载,恢复应用接管过的客户端配置,并删除开机启动项和应用菜单项;再删除 AppImage 文件。 ## 功能 +主窗口共有九个页面:概览、流量、客户端、密钥、上游、路由、安全、MCP 和设置。 + ### 用量与费用 -按任意时间范围统计 token、费用与请求数,按模型分层,并给出缓存命中率、缓存 -带来的净节省和各模型的延迟分位。实测费用、估算费用与无法计价的请求分别列出, -从不相加;ChatGPT 这类订阅账号同样按价目表计价,本地模型等可设为不计费;每个 -请求都注明计价所用的价目表及其数据日期。 +概览页按最近 24 小时、7 天、30 天或自定义区间统计 token、费用与请求数,并与上一个同等长度的区间对比;实时档显示最近十分钟。趋势图按模型分层显示 token 或费用,其下的模型排行可以直接打开对应的请求。页面下方依次是缓存(命中率、缓存带来的净节省、各模型的命中率)、延迟(首字节时间的中位数与 P95,按模型和按上游)以及各项防护的检出情况。 -### 路由与故障转移 +费用会注明其中估算的部分,例如响应结束前被中断的请求。模型未定价的请求和上游未报告用量的请求单独计数,从不按零计入。价格来自价目表:默认价目表采用 LiteLLM 的公开价格,每天更新一次;自定义价目表在其基础上设置倍率,并可单独为个别模型定价,适用于价格与官方不同的中转服务。ChatGPT 这类订阅账号同样按价目表计价,本地模型等上游可设为不计费。每个请求的费用在请求结束时确定,并注明计价所用的价目表及其数据日期。 + +### 流量与会话 + +流量页实时列出请求:状态、密钥、模型、上游、首字节时间与总耗时、token 和费用,并标出格式转换、被脱敏的密钥,以及被拦截或可疑的工具调用。列表可以按密钥、上游和模型筛选,或只看失败、无法计价的请求。「会话」视图把同一段对话的请求归为若干轮次,给出每一轮的输入 token 与费用。 + +打开一个请求可以查看时间线、路由(命中的规则、经过的策略组,以及每一次尝试的状态与耗时)、请求与响应正文、用量与费用。已结束的请求可以在预估费用后原样发送到另一个上游,两次的响应并排对照。 + + + + 流量页:每个请求的密钥、模型、上游、首字节时间与总耗时、token 和费用,标出格式转换、被脱敏的密钥和被拦截的请求,以及一个由网关本地应答的请求 + + +### 客户端接管 -路由规则按模型、密钥、token 数、工具、图片等条件把请求交给某个上游或策略组。 -每个请求都记录命中的规则、经过的策略组,以及每一次尝试的状态与耗时。 +客户端页可以把 Claude Code、Codex、opencode、Zed 与 Aider 指向网关。写入之前,页面列出将要修改的字段和这次接管的其他影响(例如 ChatGPT 桌面版与 Codex 读取同一份配置文件),给出完整的改动差异,并完整备份原文件。只修改指向网关所需的配置,每个客户端使用各自的密钥。已接管的客户端可以随时单独还原或全部还原。Cursor、Continue 与 Gemini CLI 提供逐步的配置方法,并为其创建密钥。页面列出每个客户端处于使用中、等待首个请求还是未生效,以及最近 24 小时的请求。 - - 流量页与请求详情:主上游返回 529 后,请求自动转移到 openrouter,并完成 Anthropic Messages 到 OpenAI Chat Completions 的格式转换 + + 客户端页:已接管的 Claude Code 与 Codex 各用一把专用密钥,附最近 24 小时的请求;未接管的 opencode;按配置方法手动设置并已在使用的 Cursor;尚未设置的 Continue 与 Gemini CLI;以及未检测到的 Zed 与 Aider -试算按给定的请求条件逐条匹配规则,说明请求会交给哪个上游、为什么,不发出请求, -也不产生费用。 +### 密钥 + +客户端连接网关必须携带密钥,本机也不例外。密钥页列出默认密钥(供未单独分配密钥的客户端使用)和每个已接管客户端的专用密钥,并注明所属客户端,便于在流量页中区分各客户端的请求。每把密钥有各自的路由、可用模型(全部、无,或指定的模型与 `gpt-5*` 这类通配模式)、可选的并发上限,以及最近 24 小时的请求数与费用。密钥可以停用,停用后使用它的请求一律被拒绝;也可以更换,新密钥会写入使用它的客户端的配置。 - - 路由试算:前两条规则未命中及其原因,第三条规则命中,请求转发至策略组并按顺序尝试两个上游 + + 密钥页:默认密钥,以及分别供 Claude Code、Codex 与 Cursor 使用的密钥,列出各自的路由、可用模型和最近 24 小时的请求数与费用 ### 上游 -支持 API 密钥、在应用内登录的 ChatGPT 账号(显示订阅额度与重置时间)、 -OpenRouter 等中转服务,以及本机模型。客户端与上游的 API 格式不同时,请求在 -Anthropic Messages、OpenAI Chat Completions、OpenAI Responses 与 Gemini 之间 -自动转换,无法转换的字段会逐一列出。上游可以经出站代理访问,也可以按自定义 -价目表计价。 +上游是网关转发请求的目标:Anthropic、OpenAI、Google Gemini、DeepSeek 或任何兼容接口的 API 密钥,在应用内登录的 ChatGPT 账号或 Z.ai / BigModel 账号,OpenRouter 等中转服务,以及 Ollama 等本机模型。ChatGPT 账号显示订阅额度与重置时间。客户端与上游的 API 格式不同时,请求在 Anthropic Messages、OpenAI Chat Completions、OpenAI Responses 与 Gemini 之间自动转换,无法转换的字段会在请求上逐一列出。上游可以经出站代理访问,也可以使用单独的价目表计价,代理与价目表在同一页的标签中管理。链路测速测量 DNS 解析以及 TCP、TLS、代理握手的耗时,不产生费用;推理测速测量首个 token 的时间,运行前先给出费用预估。 -API 密钥和请求头的值可以写成 `${变量名}`,读取系统环境变量。macOS 上读的是登录 -shell 里的环境变量,`~/.zshrc` 等文件中 `export` 的变量都会生效,Linux 同理(`~/.bashrc`、 -`~/.profile` 等);Windows 上读 -的是系统设置里配置的环境变量。修改变量后,重新打开应用即可生效。代理相关的 -变量(`HTTPS_PROXY` 等)和 `PATH` 不会被读取。 +API 密钥和请求头的值可以写成 `${变量名}`,读取系统环境变量。macOS 上读的是登录 shell 里的环境变量,`~/.zshrc` 等文件中 `export` 的变量都会生效,Linux 同理(`~/.bashrc`、`~/.profile` 等);Windows 上读的是系统设置里配置的环境变量。修改变量后,重新打开应用即可生效。代理相关的变量(`HTTPS_PROXY` 等)和 `PATH` 不会被读取。 - - 上游列表:API 密钥上游、ChatGPT 账号(Plus,5 小时额度已用 34%)、经代理访问的 OpenRouter、DeepSeek、Gemini 与本机 Ollama,以及各自 24 小时的请求数、费用与首字节延迟 + + 上游页:Anthropic、DeepSeek 与 Gemini 的 API 密钥上游,使用单独价目表的中转服务,5 小时额度已用 58% 的 ChatGPT Plus 账号,经代理访问的 OpenRouter,以及设为不计费的本机 Ollama,并列出各自 24 小时的请求数、费用与首字节时间中位数 -### 安全 +### 路由与故障转移 -- **出站脱敏**:请求发出之前,替换其中的密钥、私钥与连接串,并在响应中还原。 -- **工具调用审查**:上游返回的工具调用中出现可直接获得执行权限的命令时,在流中 - 切断。 -- **隐藏字符**:用户消息或工具结果中含有 Unicode 标签字符、双向控制符时,拒绝 - 发出请求。 -- **内容过滤**:用户消息或工具结果命中关键词或正则规则时,拒绝发出请求。出厂只启用 - 三条明确要求「忽略先前指令」的规则。 -- **输出长度**:回答超过设定的字符数时,流式回答在超出处切断,非流式回答整份不返回。 +每把密钥使用一条路由,未指定的使用默认路由。路由由按顺序匹配的规则组成。规则的条件包括模型、密钥、客户端的 API 格式、输入 token 数、`max_tokens`、工具数量、图片、扩展思考、流式、提示缓存以及辅助请求的类型;命中后把请求交给某个上游或策略组,或拒绝请求,也可以改写模型、`max_tokens` 或扩展思考。策略组把多个上游放在同一个名字下,并决定尝试的先后:按顺序、手动选择、轮询、延迟最低优先或费用最低优先。一次尝试失败时,请求转到下一个上游;同一会话默认保持在同一个上游上,以便提示缓存持续命中。页面顶部的路由图显示每把密钥经过的路由、策略组和上游。 -各项防护对所有上游生效,各有「关闭 / 观察 / 拦截」三档;输出长度出厂为「关闭」, -其余出厂为「观察」。安全页列出全部规则:内置规则可以逐条停用,也可以添加自定义 -规则(内容过滤可用关键词或正则表达式,其余为正则表达式),任何规则都可以先拿一段 -文本试过。各项防护命中的内容都记入日志。 + + + 路由页:从密钥经路由、策略组到上游的路由图,以及三条路由各自按顺序匹配的规则 + -### MCP +客户端自行发出的辅助请求(连通性检查、预热、生成标题、话题识别、输入建议)可以由网关在本地应答而不产生费用,也可以直接转发,或交给路由规则处理。 -MCP 页并排列出各客户端配置的 MCP server,可以把一个 server 复制到其他客户端,或 -从某个客户端移除,写入前先显示改动。同一页列出 skill 与 hook,并扫描客户端配置 -文件中的隐藏字符、注入内容与危险命令。 +每个请求都记录命中的规则、经过的策略组,以及每一次尝试的状态与耗时。试算按给定的请求条件逐条匹配规则,说明请求会交给哪个上游及其原因,不发出请求,也不产生费用。 - - 发现页:hook 中下载并执行远程脚本的命令、skill 中隐藏的零宽字符、某上游命中高危规则的比例上升,以及各客户端的 MCP server 配置 + + 路由试算:cursor 密钥以 OpenAI Chat Completions 格式请求 claude-sonnet-5,未命中「Gemini 模型」规则并说明原因,命中「兜底」规则,交给费用最低的策略组「低价」,依次尝试 relay 与 anthropic,并把请求转换为 Anthropic Messages 格式 -### 客户端接管 +### 安全 -Claude Code、Codex、opencode、Zed 与 Aider 可以在应用内一键指向网关。写入 -前先显示改动差异并完整备份原文件,只修改端点与密钥两个字段,随时可以还原。 -Cursor、Continue 与 Gemini CLI 提供逐步的手动配置说明。 +安全页有五项防护,对所有上游和所有密钥统一生效,各有「关闭」「观察」「拦截」三档,其中「观察」只检测和记录,不做任何改动。输出长度出厂为「关闭」,其余四项出厂为「观察」,因此默认不会改动或拦截任何请求。 + +- **出站脱敏**:请求发出之前查找其中的凭据,包括 Anthropic、OpenAI、GitHub、Slack、AWS、Google、GitLab、Stripe、npm、DigitalOcean、SendGrid 的 API 密钥与令牌,以及私钥、JWT 和连接串中的口令。「拦截」档下把它们替换为占位符,响应中回显时再还原。内网 IP 地址和内网域名两条规则出厂为停用,可以按需启用。 +- **工具调用审查**:检查模型返回的工具调用中是否含有下载或解码后执行代码、外发环境变量或凭据文件、读取私钥或云服务凭据、写入启动项或定时任务等命令。「拦截」档下命中即切断响应,客户端收不到一个完整、可执行的调用。删除主目录或根目录、设置全员可写权限两条规则出厂只记录。 +- **隐藏字符**:检查客户端发送的内容(含工具结果)中的 Unicode 标签字符和双向控制符,「拦截」档下拒绝发出请求。 +- **内容过滤**:用关键词或正则表达式匹配客户端发送的消息(含工具结果),「拦截」档下拒绝命中拒绝类规则的请求。内置规则中,出厂只启用三条明确要求「忽略先前指令」的规则;越狱、身份操纵、套取提示词等规则及其中文版本可以按需启用。 +- **输出长度**:回答超过设定的字符数(默认 100,000)时,流式回答在超出处切断,非流式回答整份替换为错误。思考内容和工具调用的参数不计入。 + +安全页列出全部规则:内置规则可以逐条启用或停用,工具调用审查和内容过滤的内置规则还可以设定在「拦截」档下执行处置还是仅记录;自定义规则为正则表达式,内容过滤也可以使用关键词。任何规则都可以先用一段文本测试。各项防护检出的内容都记入第一个标签页的日志,并注明所属的请求。 - - 客户端页:已接管并收到请求的 Claude Code 与 Codex、尚未接管的 opencode,以及需手动配置的客户端 + + 安全日志:发出前被替换的凭据,其中一条由自定义规则命中;被切断的下载并执行类工具调用;以及仅记录的隐藏字符、删除命令和注入指令。每一条都注明所属请求的密钥、客户端、模型与上游 -### 菜单栏与系统通知 +### MCP + +MCP 页管理客户端从自己的配置文件中加载的内容,这些内容不经过网关。 -菜单栏常驻显示今日 token 与今日费用,额度紧张时数字变橙、用完变红;设置里可以改为 -仅标识或仅数值。点开是原生菜单:网关状态、未读的提醒、各订阅账号的额度与重置时间、 -今日用量、进行中的请求,以及切换手动选择的上游、复制网关地址和默认密钥、撤销上一次 -配置修改、检查更新等常用操作,不必先打开主界面。 -网关停止转发、订阅额度用完、凭据失效等情况会发送系统通知;上游无法连接多半有回退 -接住,只记录在应用内。提醒可以整体设为系统通知、仅在应用内显示或关闭。标为已读的 -提醒不再计入铃铛上的数字,但在问题解决或清空列表之前仍留在列表中。 +- **服务器**:并排列出 Claude Code、Claude Desktop、Cursor、Codex、opencode 与 Zed 配置的 MCP 服务器。可以把一个服务器从一个客户端复制到另一个客户端,或从某个客户端移除;写入前先显示改动,并备份原文件。复制与移除支持 Claude Code、Claude Desktop、Cursor 与 Codex,opencode 与 Zed 只列出、不写入。位于其他主机的远程服务器标为「第三方」,使用它会把相关上下文发送到该地址;同名服务器在各客户端中配置不同时标为「配置不一致」,可以并排比较。 +- **技能与钩子**:列出已安装的技能和配置的钩子,以及各自所属的客户端。 +- **发现**:扫描客户端配置、技能、钩子、斜杠命令、subagent 与项目指令文件,检查隐藏字符、提示注入、危险命令与过宽权限四类问题,每项发现按高、中、低分级。扫描只报告,不修改任何文件。 -Windows 上图标位于通知区域:悬停显示网关状态与今日 token、费用;左键打开主界面, -右键打开同一份菜单,其中的额度条改为文字。提醒以 Windows 原生通知发送。 +应用运行期间会监视这些文件,出现新的发现时发送系统通知。 -Linux 上图标位于系统托盘:点击打开同一份菜单,第一项为「打开主界面」, -额度条同样改为文字。提醒通过桌面环境的通知服务发送。 + + + MCP 页:Claude Code、Claude Desktop、Cursor、Codex、opencode 与 Zed 配置的 MCP 服务器并排列出,标出第三方远程服务器和在两个客户端中配置不一致的服务器;页头统计已扫描的 11 个文件中高、中、低风险发现各一项 + + +### 设置 + +设置页分为六节。「连接」列出本机 core 和已保存的远程 core,详见[下文](#连接远程-core)。「通用」设置语言、外观、菜单栏显示的内容(仅 macOS)、开机启动,以及提醒以系统通知发送、仅在应用内显示还是关闭。「网关监听」设置网关的访问范围(仅本机、所选网卡所在的局域网或所有网卡)、端口和放行网段。「日志保留」分别设置请求报文与请求记录的保留天数,以及报文的空间上限。「关于」显示版本、检查更新,并可生成诊断包,其中的密钥与地址均已脱敏。「卸载」还原所有已接管的客户端并取消开机启动,应在删除应用之前执行。 + +### 菜单栏、系统托盘与通知 + +macOS 菜单栏显示今日 token 与今日费用,订阅额度紧张时数字变橙、用完变红;设置里可以改为仅标识或仅数值。

- - 菜单栏:今日费用 $24.72,输出速率 47 token/秒 - - - - 菜单栏:订阅额度已用 34%,2 小时后重置 + + 菜单栏图标:ThinkWatch 标识,其上的圆点表示有请求在进行,右侧上下两行为今日 token 13.3M 与今日费用 $9.34

+点开是原生菜单:网关地址与状态、未读的提醒、各订阅账号的额度与重置时间、今日的请求数、token 与费用、进行中的请求,以及切换手动选择策略组中的上游、复制网关地址和默认密钥、撤销上一次配置修改、切换连接、检查更新等常用操作,不必先打开主界面。 + + + + 点开的菜单:网关地址、输出速率与状态;ChatGPT 账号的 5 小时与每周额度及重置时间;今日的请求数、token 与费用;进行中的请求;以及复制网关地址和默认密钥、撤销上一次配置修改、切换连接、打开设置、检查更新等操作 + + +Windows 上图标位于通知区域:悬停显示网关状态与今日 token、费用;左键打开主界面,右键打开同一份菜单,其中的额度条改为文字。 + +Linux 上图标位于系统托盘:点击打开同一份菜单,第一项为「打开主界面」,额度条同样改为文字。 + +以下情况会发送系统通知(macOS 与 Windows 使用原生通知,Linux 通过桌面环境的通知服务):网关停止转发或反复重启、与远程 core 的连接断开、订阅额度用完、账号登录失效或上游拒绝当前凭据、代理不通、配置文件未通过校验、工具调用命中切断类规则、客户端配置中出现可疑内容。自动检查到新版本时也以系统通知告知(见[更新](#更新))。上游无法连接时通常由回退上游承接,因此只记录在应用内。提醒可以整体设为系统通知、仅在应用内显示或关闭。标为已读的提醒不再计入铃铛上的数字,但在问题解决或清空列表之前仍留在列表中。 + +## 连接远程 core + +网关也可以运行在服务器上:ThinkWatch Core 作为系统服务在服务器上运行,应用通过网络连接它。在 Linux 上安装 `twcore`、开启远程控制端口和获取密钥的步骤见 ThinkWatch Core 仓库的[服务器部署文档](https://github.com/ThinkWatchProject/ThinkWatch-Core/blob/main/docs/server.zh-CN.md)。 + +在应用中打开「设置 › 连接 › 添加远程连接」,填写名称、服务器地址、控制端口,以及在服务器上执行 `twcore control-key` 得到的密钥。测试连接会完成加密握手并读取服务器的 core 版本,通过后即可保存并切换。侧栏底部的连接菜单,以及菜单栏或托盘菜单中的「连接」子菜单,可以在本机 core 和已保存的服务器之间切换。 + + + + 在设置中添加远程连接:填写服务器地址、控制端口和 twcore control-key 给出的密钥;测试连接已完成握手,显示 core 0.48.0 和服务器的网关地址 + + +- 应用同一时间只连接一个 core。连接服务器期间,本机 core 在进行中的请求结束后停止运行,其配置、密钥和请求历史原样保留,切回本机时重新启动。服务器无法连接时,应用持续重试,不会自行退回本机;「本机」始终在连接列表中,任何时候都可以一步切回。 +- 概览、流量、密钥、上游、路由与安全页显示和修改的是服务器上的配置与数据。设置页把本机应用的设置和服务器的配置分为两组,远程控制的监听与密钥只能在服务器上修改。客户端页和 MCP 页始终作用于运行应用的这台电脑:接管客户端时,客户端指向服务器上的网关。 +- 连接密钥保存在应用数据目录中的一个私有文件里,只有当前用户可以读取。 +- ChatGPT 账号只能用设备码登录,因为浏览器登录完成后会回到运行 core 的那台机器。API 密钥和请求头中的 `${变量名}` 读取的是服务器上 core 进程的环境变量。诊断包只对本机 core 提供。 +- 服务器上的 core 版本必须与这一版应用所需的版本一致;连接时应用会检查,版本不一致时列出两边的版本,并给出在服务器上安装所需版本的命令:`sudo twcore upgrade --version <版本> --restart`,服务器上现有的版本较新或较旧均适用。 + + + + 连接远程 core「homelab」时侧栏底部的连接菜单:这台 Mac 上的本机 core 已停止,另有一台服务器可以切换 + + ## 更新 -应用启动后不久检查一次新版本,此后每天检查一次,只读取一份很小的版本清单。 -可以在「设置」中关闭。 +应用启动后不久检查一次新版本,此后每天检查一次,只读取一份很小的版本清单。可以在「设置」中关闭。 -有新版本时会弹出一个小窗口,之后的处理方式取决于安装方式。 +检查到新版本时,应用发送一条系统通知;提醒设为仅在应用内显示或关闭时不发送。点击这条通知、菜单栏或托盘菜单中取代「检查更新」的「安装新版本」,或「设置 › 关于」中的更新按钮,都会打开更新窗口。之后的处理方式取决于安装方式。 -**在 macOS 上从 release 页面下载安装的**:点击一次安装按钮,其余步骤自动完成—— -下载更新包,用编译进应用的公钥验签,等待网关正在处理的请求结束(最多三分钟), -然后替换并重新启动。正在输出的 Claude Code 任务不会因更新而中断。 +**在 macOS 上从 release 页面下载安装的**:点击一次安装按钮,其余步骤自动完成——下载更新包,用编译进应用的公钥验签,等待网关正在处理的请求结束(最多三分钟),然后替换并重新启动。正在输出的 Claude Code 任务不会因更新而中断。 -**Windows 上**:同样点击一次即可。应用下载新版本的安装程序,用编译进应用的公钥 -验签,同样等待进行中的请求结束,然后运行安装程序,安装完成后新版本自动启动。应用 -为所有用户安装,因此每次更新 Windows 都会请求管理员权限;拒绝则继续运行当前版本。 +**Windows 上**:同样点击一次即可。应用下载新版本的安装程序,用编译进应用的公钥验签,同样等待进行中的请求结束,然后运行安装程序,安装完成后新版本自动启动。应用为所有用户安装,因此每次更新 Windows 都会请求管理员权限;拒绝则继续运行当前版本。 -**Linux 上**:同样点击一次即可,不需要输入密码。应用下载新版本的 AppImage,用 -编译进应用的公钥验签,等待进行中的请求结束,然后替换自身文件并重新启动。AppImage -须位于当前用户可写的目录中。 +**Linux 上**:同样点击一次即可,不需要输入密码。应用下载新版本的 AppImage,用编译进应用的公钥验签,等待进行中的请求结束,然后替换自身文件并重新启动。AppImage 须位于当前用户可写的目录中。 -**用 Homebrew 安装的**:窗口给出更新命令和复制按钮,应用不会替换自身。Homebrew -记录着它放入 `/Applications` 的版本,应用自行替换后,下一次 `brew upgrade` 会 -把旧版本写回。这个窗口只在 tap 已包含新版本时才会出现,因此给出的命令一定有 -可安装的内容: +**用 Homebrew 安装的**:窗口给出更新命令和复制按钮,应用不会替换自身。Homebrew 记录着它放入 `/Applications` 的版本,应用自行替换后,下一次 `brew upgrade` 会把旧版本写回。这种安装方式下,检查读取的是 tap 中 cask 的版本,而不是发布页的版本清单,因此 tap 包含新版本之后才会提示更新,给出的命令一定有可安装的内容: ```bash brew update && brew upgrade --cask thinkwatch-lite @@ -262,21 +258,24 @@ brew update && brew upgrade --cask thinkwatch-lite ```bash pnpm install +bash src-tauri/scripts/fetch-core.sh pnpm tauri dev ``` -提交代码前的检查见 [CONTRIBUTING.md](CONTRIBUTING.md)。 +`fetch-core.sh` 下载 `Cargo.lock` 所锁定版本的 `twcore`,核对 sha256 后放入 `src-tauri/resources/`,每次构建都需要这个文件。提交代码前的检查见 [CONTRIBUTING.md](CONTRIBUTING.md)。 ## 目录 ``` -src/ React 19 + Tailwind 4 前端 -src-tauri/ Tauri 2 外壳:托管 core、渲染菜单栏 +src/ React 19 + Tailwind 4 界面 +src-tauri/ Tauri 2 外壳:托管本机 core,连接本机或远程 core, + 绘制菜单栏图标与托盘菜单,发送系统通知,安装更新 +src-tauri/crates/ tw-adopt(接管客户端、读写 MCP 配置)与 + tw-scan(扫描客户端配置) +scripts/shots/ 产品截图流水线(见 CONTRIBUTING.md) ``` -网关本体位于 ThinkWatch Core;本仓库不包含路由、转发或计费逻辑。与 core 的 -通信在 macOS 和 Linux 上走 unix socket,在 Windows 上走回环端口,两者都带一个每次启动 -生成的凭据。 +网关本体位于 ThinkWatch Core;本仓库不包含路由、转发或计费逻辑。应用通过 core 的控制通道与它通信:本机在 macOS 和 Linux 上走 unix socket,在 Windows 上走回环端口;core 运行在服务器上时走 TCP 端口。每条连接都先完成加密握手(Noise `NNpsk0`),密钥为 core 配置中的控制密钥 `listen.control.key`,不涉及 TLS 证书。 ## 许可证 diff --git a/docs/screenshots/clients-dark.png b/docs/screenshots/clients-dark.png deleted file mode 100644 index 13f1ed07..00000000 Binary files a/docs/screenshots/clients-dark.png and /dev/null differ diff --git a/docs/screenshots/clients-en-dark.png b/docs/screenshots/clients-en-dark.png deleted file mode 100644 index 915635b4..00000000 Binary files a/docs/screenshots/clients-en-dark.png and /dev/null differ diff --git a/docs/screenshots/clients-en-light.png b/docs/screenshots/clients-en-light.png deleted file mode 100644 index b575b0a3..00000000 Binary files a/docs/screenshots/clients-en-light.png and /dev/null differ diff --git a/docs/screenshots/clients-light.png b/docs/screenshots/clients-light.png deleted file mode 100644 index ba6c9dac..00000000 Binary files a/docs/screenshots/clients-light.png and /dev/null differ diff --git a/docs/screenshots/dry-run-dark.png b/docs/screenshots/dry-run-dark.png deleted file mode 100644 index 899eae74..00000000 Binary files a/docs/screenshots/dry-run-dark.png and /dev/null differ diff --git a/docs/screenshots/dry-run-en-dark.png b/docs/screenshots/dry-run-en-dark.png deleted file mode 100644 index ae957f85..00000000 Binary files a/docs/screenshots/dry-run-en-dark.png and /dev/null differ diff --git a/docs/screenshots/dry-run-en-light.png b/docs/screenshots/dry-run-en-light.png deleted file mode 100644 index 954ba95a..00000000 Binary files a/docs/screenshots/dry-run-en-light.png and /dev/null differ diff --git a/docs/screenshots/dry-run-light.png b/docs/screenshots/dry-run-light.png deleted file mode 100644 index 49533581..00000000 Binary files a/docs/screenshots/dry-run-light.png and /dev/null differ diff --git a/docs/screenshots/en/dry-run-dark.png b/docs/screenshots/en/dry-run-dark.png index 0c08b26f..e62aa8db 100644 Binary files a/docs/screenshots/en/dry-run-dark.png and b/docs/screenshots/en/dry-run-dark.png differ diff --git a/docs/screenshots/en/dry-run-light.png b/docs/screenshots/en/dry-run-light.png index 53397303..8eb5bbe6 100644 Binary files a/docs/screenshots/en/dry-run-light.png and b/docs/screenshots/en/dry-run-light.png differ diff --git a/docs/screenshots/en/overview-dark.png b/docs/screenshots/en/overview-dark.png index 70721e10..2315f891 100644 Binary files a/docs/screenshots/en/overview-dark.png and b/docs/screenshots/en/overview-dark.png differ diff --git a/docs/screenshots/en/overview-light.png b/docs/screenshots/en/overview-light.png index 3b4695ac..90110bd6 100644 Binary files a/docs/screenshots/en/overview-light.png and b/docs/screenshots/en/overview-light.png differ diff --git a/docs/screenshots/en/remote-add-dark.png b/docs/screenshots/en/remote-add-dark.png index 67e71c80..4e4cb918 100644 Binary files a/docs/screenshots/en/remote-add-dark.png and b/docs/screenshots/en/remote-add-dark.png differ diff --git a/docs/screenshots/en/remote-add-light.png b/docs/screenshots/en/remote-add-light.png index e4c3e353..ac0832db 100644 Binary files a/docs/screenshots/en/remote-add-light.png and b/docs/screenshots/en/remote-add-light.png differ diff --git a/docs/screenshots/en/remote-switcher-dark.png b/docs/screenshots/en/remote-switcher-dark.png index 71940866..af25c06a 100644 Binary files a/docs/screenshots/en/remote-switcher-dark.png and b/docs/screenshots/en/remote-switcher-dark.png differ diff --git a/docs/screenshots/en/remote-switcher-light.png b/docs/screenshots/en/remote-switcher-light.png index 5be12000..ddb6760d 100644 Binary files a/docs/screenshots/en/remote-switcher-light.png and b/docs/screenshots/en/remote-switcher-light.png differ diff --git a/docs/screenshots/en/routing-dark.png b/docs/screenshots/en/routing-dark.png index ddde8d91..a4031fe3 100644 Binary files a/docs/screenshots/en/routing-dark.png and b/docs/screenshots/en/routing-dark.png differ diff --git a/docs/screenshots/en/routing-light.png b/docs/screenshots/en/routing-light.png index 8f7f5813..cb14d6f9 100644 Binary files a/docs/screenshots/en/routing-light.png and b/docs/screenshots/en/routing-light.png differ diff --git a/docs/screenshots/en/security-dark.png b/docs/screenshots/en/security-dark.png index 556cb22d..ee07edae 100644 Binary files a/docs/screenshots/en/security-dark.png and b/docs/screenshots/en/security-dark.png differ diff --git a/docs/screenshots/en/security-light.png b/docs/screenshots/en/security-light.png index ee9c135f..579e58af 100644 Binary files a/docs/screenshots/en/security-light.png and b/docs/screenshots/en/security-light.png differ diff --git a/docs/screenshots/en/traffic-dark.png b/docs/screenshots/en/traffic-dark.png index f1406c2b..a5e0dc43 100644 Binary files a/docs/screenshots/en/traffic-dark.png and b/docs/screenshots/en/traffic-dark.png differ diff --git a/docs/screenshots/en/traffic-light.png b/docs/screenshots/en/traffic-light.png index d009c707..1d56a676 100644 Binary files a/docs/screenshots/en/traffic-light.png and b/docs/screenshots/en/traffic-light.png differ diff --git a/docs/screenshots/findings-dark.png b/docs/screenshots/findings-dark.png deleted file mode 100644 index c2a3e8af..00000000 Binary files a/docs/screenshots/findings-dark.png and /dev/null differ diff --git a/docs/screenshots/findings-en-dark.png b/docs/screenshots/findings-en-dark.png deleted file mode 100644 index 647fb9ca..00000000 Binary files a/docs/screenshots/findings-en-dark.png and /dev/null differ diff --git a/docs/screenshots/findings-en-light.png b/docs/screenshots/findings-en-light.png deleted file mode 100644 index 1f26ce73..00000000 Binary files a/docs/screenshots/findings-en-light.png and /dev/null differ diff --git a/docs/screenshots/findings-light.png b/docs/screenshots/findings-light.png deleted file mode 100644 index ae6ee60c..00000000 Binary files a/docs/screenshots/findings-light.png and /dev/null differ diff --git a/docs/screenshots/menubar-cost-dark.png b/docs/screenshots/menubar-cost-dark.png deleted file mode 100644 index 7f8d6e37..00000000 Binary files a/docs/screenshots/menubar-cost-dark.png and /dev/null differ diff --git a/docs/screenshots/menubar-cost-light.png b/docs/screenshots/menubar-cost-light.png deleted file mode 100644 index af982a8d..00000000 Binary files a/docs/screenshots/menubar-cost-light.png and /dev/null differ diff --git a/docs/screenshots/menubar-quota-dark.png b/docs/screenshots/menubar-quota-dark.png deleted file mode 100644 index be468d03..00000000 Binary files a/docs/screenshots/menubar-quota-dark.png and /dev/null differ diff --git a/docs/screenshots/menubar-quota-light.png b/docs/screenshots/menubar-quota-light.png deleted file mode 100644 index bd3cd624..00000000 Binary files a/docs/screenshots/menubar-quota-light.png and /dev/null differ diff --git a/docs/screenshots/overview-dark.png b/docs/screenshots/overview-dark.png deleted file mode 100644 index e9178a7d..00000000 Binary files a/docs/screenshots/overview-dark.png and /dev/null differ diff --git a/docs/screenshots/overview-en-dark.png b/docs/screenshots/overview-en-dark.png deleted file mode 100644 index 2de8960e..00000000 Binary files a/docs/screenshots/overview-en-dark.png and /dev/null differ diff --git a/docs/screenshots/overview-en-light.png b/docs/screenshots/overview-en-light.png deleted file mode 100644 index 0ae11430..00000000 Binary files a/docs/screenshots/overview-en-light.png and /dev/null differ diff --git a/docs/screenshots/overview-light.png b/docs/screenshots/overview-light.png deleted file mode 100644 index fb6821d7..00000000 Binary files a/docs/screenshots/overview-light.png and /dev/null differ diff --git a/docs/screenshots/requests-dark.png b/docs/screenshots/requests-dark.png deleted file mode 100644 index 3bcecb27..00000000 Binary files a/docs/screenshots/requests-dark.png and /dev/null differ diff --git a/docs/screenshots/requests-en-dark.png b/docs/screenshots/requests-en-dark.png deleted file mode 100644 index a07d3702..00000000 Binary files a/docs/screenshots/requests-en-dark.png and /dev/null differ diff --git a/docs/screenshots/requests-en-light.png b/docs/screenshots/requests-en-light.png deleted file mode 100644 index c976dc4f..00000000 Binary files a/docs/screenshots/requests-en-light.png and /dev/null differ diff --git a/docs/screenshots/requests-light.png b/docs/screenshots/requests-light.png deleted file mode 100644 index 371a1f38..00000000 Binary files a/docs/screenshots/requests-light.png and /dev/null differ diff --git a/docs/screenshots/upstreams-dark.png b/docs/screenshots/upstreams-dark.png deleted file mode 100644 index 9d7583aa..00000000 Binary files a/docs/screenshots/upstreams-dark.png and /dev/null differ diff --git a/docs/screenshots/upstreams-en-dark.png b/docs/screenshots/upstreams-en-dark.png deleted file mode 100644 index ca9ef21f..00000000 Binary files a/docs/screenshots/upstreams-en-dark.png and /dev/null differ diff --git a/docs/screenshots/upstreams-en-light.png b/docs/screenshots/upstreams-en-light.png deleted file mode 100644 index e4351ab8..00000000 Binary files a/docs/screenshots/upstreams-en-light.png and /dev/null differ diff --git a/docs/screenshots/upstreams-light.png b/docs/screenshots/upstreams-light.png deleted file mode 100644 index 6d3c1796..00000000 Binary files a/docs/screenshots/upstreams-light.png and /dev/null differ diff --git a/docs/screenshots/web/dry-run-en.webp b/docs/screenshots/web/dry-run-en.webp index fb2ca831..be2efb9d 100644 Binary files a/docs/screenshots/web/dry-run-en.webp and b/docs/screenshots/web/dry-run-en.webp differ diff --git a/docs/screenshots/web/dry-run.webp b/docs/screenshots/web/dry-run.webp index a2bda8c1..755b4cde 100644 Binary files a/docs/screenshots/web/dry-run.webp and b/docs/screenshots/web/dry-run.webp differ diff --git a/docs/screenshots/web/overview-en.webp b/docs/screenshots/web/overview-en.webp index e42debe3..0f6467b7 100644 Binary files a/docs/screenshots/web/overview-en.webp and b/docs/screenshots/web/overview-en.webp differ diff --git a/docs/screenshots/web/overview.webp b/docs/screenshots/web/overview.webp index bb6aa08c..d82184ab 100644 Binary files a/docs/screenshots/web/overview.webp and b/docs/screenshots/web/overview.webp differ diff --git a/docs/screenshots/web/remote-add-en.webp b/docs/screenshots/web/remote-add-en.webp index e109b78a..0e65dbe6 100644 Binary files a/docs/screenshots/web/remote-add-en.webp and b/docs/screenshots/web/remote-add-en.webp differ diff --git a/docs/screenshots/web/remote-add.webp b/docs/screenshots/web/remote-add.webp index 22b79992..800a858e 100644 Binary files a/docs/screenshots/web/remote-add.webp and b/docs/screenshots/web/remote-add.webp differ diff --git a/docs/screenshots/web/remote-switcher-en.webp b/docs/screenshots/web/remote-switcher-en.webp index 3c37cd53..83a3001a 100644 Binary files a/docs/screenshots/web/remote-switcher-en.webp and b/docs/screenshots/web/remote-switcher-en.webp differ diff --git a/docs/screenshots/web/remote-switcher.webp b/docs/screenshots/web/remote-switcher.webp index 805f55b7..276973b7 100644 Binary files a/docs/screenshots/web/remote-switcher.webp and b/docs/screenshots/web/remote-switcher.webp differ diff --git a/docs/screenshots/web/routing-en.webp b/docs/screenshots/web/routing-en.webp index 768810b1..5a05efa6 100644 Binary files a/docs/screenshots/web/routing-en.webp and b/docs/screenshots/web/routing-en.webp differ diff --git a/docs/screenshots/web/routing.webp b/docs/screenshots/web/routing.webp index 064ed8f4..4318d8bd 100644 Binary files a/docs/screenshots/web/routing.webp and b/docs/screenshots/web/routing.webp differ diff --git a/docs/screenshots/web/security-en.webp b/docs/screenshots/web/security-en.webp index 92ff2602..68297474 100644 Binary files a/docs/screenshots/web/security-en.webp and b/docs/screenshots/web/security-en.webp differ diff --git a/docs/screenshots/web/security.webp b/docs/screenshots/web/security.webp index 3152445f..0ceb8f3a 100644 Binary files a/docs/screenshots/web/security.webp and b/docs/screenshots/web/security.webp differ diff --git a/docs/screenshots/web/traffic-en.webp b/docs/screenshots/web/traffic-en.webp index a2f5cc41..9a8ea47b 100644 Binary files a/docs/screenshots/web/traffic-en.webp and b/docs/screenshots/web/traffic-en.webp differ diff --git a/docs/screenshots/web/traffic.webp b/docs/screenshots/web/traffic.webp index 8f60f087..2b5369de 100644 Binary files a/docs/screenshots/web/traffic.webp and b/docs/screenshots/web/traffic.webp differ diff --git a/docs/screenshots/zh/dry-run-dark.png b/docs/screenshots/zh/dry-run-dark.png index 45e7518a..dde25197 100644 Binary files a/docs/screenshots/zh/dry-run-dark.png and b/docs/screenshots/zh/dry-run-dark.png differ diff --git a/docs/screenshots/zh/dry-run-light.png b/docs/screenshots/zh/dry-run-light.png index 932ec2cf..9cd235d0 100644 Binary files a/docs/screenshots/zh/dry-run-light.png and b/docs/screenshots/zh/dry-run-light.png differ diff --git a/docs/screenshots/zh/overview-dark.png b/docs/screenshots/zh/overview-dark.png index 5be4f326..a8bbf68a 100644 Binary files a/docs/screenshots/zh/overview-dark.png and b/docs/screenshots/zh/overview-dark.png differ diff --git a/docs/screenshots/zh/overview-light.png b/docs/screenshots/zh/overview-light.png index 205e0599..875aa7e8 100644 Binary files a/docs/screenshots/zh/overview-light.png and b/docs/screenshots/zh/overview-light.png differ diff --git a/docs/screenshots/zh/remote-add-dark.png b/docs/screenshots/zh/remote-add-dark.png index f423a477..feafe3e6 100644 Binary files a/docs/screenshots/zh/remote-add-dark.png and b/docs/screenshots/zh/remote-add-dark.png differ diff --git a/docs/screenshots/zh/remote-add-light.png b/docs/screenshots/zh/remote-add-light.png index cacb2a0c..966058ad 100644 Binary files a/docs/screenshots/zh/remote-add-light.png and b/docs/screenshots/zh/remote-add-light.png differ diff --git a/docs/screenshots/zh/remote-switcher-dark.png b/docs/screenshots/zh/remote-switcher-dark.png index 9e04ece7..64debfe1 100644 Binary files a/docs/screenshots/zh/remote-switcher-dark.png and b/docs/screenshots/zh/remote-switcher-dark.png differ diff --git a/docs/screenshots/zh/remote-switcher-light.png b/docs/screenshots/zh/remote-switcher-light.png index 6a745119..cb16e418 100644 Binary files a/docs/screenshots/zh/remote-switcher-light.png and b/docs/screenshots/zh/remote-switcher-light.png differ diff --git a/docs/screenshots/zh/routing-dark.png b/docs/screenshots/zh/routing-dark.png index 389ef6d0..cb58378a 100644 Binary files a/docs/screenshots/zh/routing-dark.png and b/docs/screenshots/zh/routing-dark.png differ diff --git a/docs/screenshots/zh/routing-light.png b/docs/screenshots/zh/routing-light.png index dc757ab1..78e19a55 100644 Binary files a/docs/screenshots/zh/routing-light.png and b/docs/screenshots/zh/routing-light.png differ diff --git a/docs/screenshots/zh/security-dark.png b/docs/screenshots/zh/security-dark.png index ac048ffe..4b37e234 100644 Binary files a/docs/screenshots/zh/security-dark.png and b/docs/screenshots/zh/security-dark.png differ diff --git a/docs/screenshots/zh/security-light.png b/docs/screenshots/zh/security-light.png index 9402ee83..9f8ddaf3 100644 Binary files a/docs/screenshots/zh/security-light.png and b/docs/screenshots/zh/security-light.png differ diff --git a/docs/screenshots/zh/traffic-dark.png b/docs/screenshots/zh/traffic-dark.png index 21ccf311..d7f9ea2b 100644 Binary files a/docs/screenshots/zh/traffic-dark.png and b/docs/screenshots/zh/traffic-dark.png differ diff --git a/docs/screenshots/zh/traffic-light.png b/docs/screenshots/zh/traffic-light.png index 35a1a7af..84cd40d4 100644 Binary files a/docs/screenshots/zh/traffic-light.png and b/docs/screenshots/zh/traffic-light.png differ diff --git a/package.json b/package.json index dc9535ee..a1325613 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "thinkwatch-lite", "private": true, + "description": "Desktop app for a local AI API gateway on macOS, Windows and Linux", "version": "2026.9.16", "type": "module", "packageManager": "pnpm@11.13.0", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index ca2f1e33..7e34a53b 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -8,7 +8,7 @@ edition = "2024" # stable,把它往回调不会让谁编译得更顺,只会把修复挡在外面。 rust-version = "1.88" license = "MIT" -description = "Desktop app for a local AI gateway, built for individual developers" +description = "Desktop app for a local AI API gateway on macOS, Windows and Linux" # 接管和扫描这两个 crate 在 `crates/` 下,和应用同一个 workspace:`cargo test` # 一次跑全,Cargo.lock 只有一份 diff --git a/src-tauri/scripts/fetch-core.sh b/src-tauri/scripts/fetch-core.sh index dbf6006a..32a7952f 100755 --- a/src-tauri/scripts/fetch-core.sh +++ b/src-tauri/scripts/fetch-core.sh @@ -15,8 +15,10 @@ # script 在**编译期**就校验它在不在 —— 挂在打包那一步上,等于在一个 # 干净的检出里永远赶不上:编译先失败。 # -# 日常 `tauri dev` 不经过这里,也不需要网络:那时 `locate_core` 会在 -# 隔壁仓库的 target 里找到一个。 +# 日常 `tauri dev` 不经过这里,但编译照样要求 `resources/twcore` 在(原因同 +# 上一段):**新检出先跑一次这个脚本**,之后的 dev 不再需要网络。运行时 +# `locate_core` 也先用 resources 里的这一份;要换一个 core 调试,用 +# `THINKWATCH_CORE_BIN` 显式指定。 set -euo pipefail cd "$(dirname "$0")/.."