🤖 Open-source, local-first alternative to Grok Bot, OpenAI dots and Claude Duet. Your own AI bots on any model: GPT, Claude, Gemini, Grok, DeepSeek, Kimi, GLM and 70+ more through one Modelflare key. Reach them in the app, WeChat or Feishu; they remember you, work in the background, run commands and use your computer. Pay per use.
Python ai-agentai-assistantchatbotclaudecomputer-usedeepseekdesktop-appdshelectronfeishugeminigptgrokllmlocal-firstmodelflaremulti-modelopenai-compatiblepersonal-ai-agentwechat
chore(utm): 来源参数统一为 utm_source=anymodelbot&utm_campaign=amb_<位置>
dyk9882c55ef6d1d9
diff --git a/README.md b/README.mdindex 267209d..93f649b 100644--- a/README.md+++ b/README.md@@ -17,8 +17,8 @@<a href="https://github.com/modelflare-ai/AnyModelBot/releases">下载</a> |简体中文 |<a href="./README_en.md">English</a> |- <a href="https://modelflare.dev">Modelflare</a> |- <a href="https://modelflare.dev/pricing">价格</a> |+ <a href="https://modelflare.dev/?utm_source=anymodelbot&utm_campaign=amb_readme">Modelflare</a> |+ <a href="https://modelflare.dev/pricing?utm_source=anymodelbot&utm_campaign=amb_readme">价格</a> |<a href="./docs/development.md">开发文档</a> |<a href="https://github.com/modelflare-ai/AnyModelBot/issues">问题反馈</a></p>@@ -46,7 +46,7 @@AnyModelBot 是一个本地优先的 AI 智能体应用,支持 Windows、macOS 和 Linux。一个机器人就是一个人设,带着自己的默认模型、工作区和记忆。你可以在应用里和它聊天,也可以在微信、飞书里找它。它能读写文件、执行命令、操作你的桌面,一旦要越出自己的工作区,就会先问你。-对话、记忆、文件和 API Key 都留在你的设备上。模型来自 [Modelflare](https://modelflare.dev):一个账户,任意模型,按 token 计费。AnyModelBot 本身没有订阅。+对话、记忆、文件和 API Key 都留在你的设备上。模型来自 [Modelflare](https://modelflare.dev/?utm_source=anymodelbot&utm_campaign=amb_readme):一个账户,任意模型,按 token 计费。AnyModelBot 本身没有订阅。📥 [下载](#-下载) · 🌠 [截图](#-截图) · 🌟 [核心功能](#-核心功能) · 🔐 [工作原理与隐私](#-工作原理与隐私)@@ -57,18 +57,18 @@ AnyModelBot 是一个本地优先的 AI 智能体应用,支持 Windows、macOS<table><tr><td width="200" align="center" valign="middle">- <a href="https://modelflare.dev/?utm_source=github&utm_medium=readme&utm_campaign=anymodelbot">+ <a href="https://modelflare.dev/?utm_source=anymodelbot&utm_campaign=amb_readme"><img src="docs/assets/modelflare/modelflare-logo.png" width="120" height="120" alt="Modelflare 标志"></a></td><td>-**[Modelflare](https://modelflare.dev/?utm_source=github&utm_medium=readme&utm_campaign=anymodelbot)** 是兼容 OpenAI 接口的 AI API 网关,已有 20 万+ 注册开发者。一个 API Key 就能调用来自 13 家供应商的 70+ 个文本、图片和视频模型,包括 GPT、Claude、Gemini、Grok、DeepSeek、Kimi、GLM 等。请求会在多个供应商之间路由,并按顺序自动回退;每一次请求都记录用量和费用。价格公开,按 token 计费。+**[Modelflare](https://modelflare.dev/?utm_source=anymodelbot&utm_campaign=amb_readme)** 是兼容 OpenAI 接口的 AI API 网关,已有 20 万+ 注册开发者。一个 API Key 就能调用来自 13 家供应商的 70+ 个文本、图片和视频模型,包括 GPT、Claude、Gemini、Grok、DeepSeek、Kimi、GLM 等。请求会在多个供应商之间路由,并按顺序自动回退;每一次请求都记录用量和费用。价格公开,按 token 计费。-**[注册 Modelflare →](https://modelflare.dev/sign-up?utm_source=github&utm_medium=readme&utm_campaign=anymodelbot)** ·-[价格表](https://modelflare.dev/pricing?utm_source=github&utm_medium=readme&utm_campaign=anymodelbot) ·-[API 文档](https://docs.modelflare.dev/) ·-[信任中心](https://modelflare.dev/trust) ·+**[注册 Modelflare →](https://modelflare.dev/sign-up?utm_source=anymodelbot&utm_campaign=amb_readme)** ·+[价格表](https://modelflare.dev/pricing?utm_source=anymodelbot&utm_campaign=amb_readme) ·+[API 文档](https://docs.modelflare.dev/?utm_source=anymodelbot&utm_campaign=amb_readme) ·+[信任中心](https://modelflare.dev/trust?utm_source=anymodelbot&utm_campaign=amb_readme) ·[X](https://x.com/modelflare_dev)</td>@@ -80,7 +80,7 @@ AnyModelBot 是一个本地优先的 AI 智能体应用,支持 Windows、macOS- **登录一次就行。** 首次启动会打开浏览器,登录(或注册)Modelflare。之后应用自己把这台设备连上,不用复制 Key。在 Docker 或服务器上运行?改为粘贴一个 API Key。- **所有模型,一个选择器。** 你的 Modelflare 模型会自动列出,每个模型旁边都有上下文长度、能力标记和参考价。- **用多少付多少。** 余额、低余额提醒和每日用量都在应用里看。选模型之前,先看公开价格表,和官方价格对比一下。-- **一条诚实的边界。** 模型请求会经过 Modelflare 转发给你选定的供应商,Modelflare 会保留请求日志;保留什么、保留多久,见[信任中心](https://modelflare.dev/trust)。除此之外的内容都留在你的设备上([详情](#-工作原理与隐私))。+- **一条诚实的边界。** 模型请求会经过 Modelflare 转发给你选定的供应商,Modelflare 会保留请求日志;保留什么、保留多久,见[信任中心](https://modelflare.dev/trust?utm_source=anymodelbot&utm_campaign=amb_readme)。除此之外的内容都留在你的设备上([详情](#-工作原理与隐私))。---@@ -268,7 +268,7 @@ docker exec amb cat /data/ui-token # 然后打开 http://<主机>:3600/?token=| 你的 API Key 和登录令牌 | 你登录 Modelflare 的过程,发生在 modelflare.dev || 设置 | |-Modelflare 会保留请求日志;保留什么、保留多久,见它的[信任中心](https://modelflare.dev/trust)。我们不声称能做到万无一失:凡是你发给模型的内容,都会离开你的设备。完整清单见 [docs/privacy.md](./docs/privacy.md)。+Modelflare 会保留请求日志;保留什么、保留多久,见它的[信任中心](https://modelflare.dev/trust?utm_source=anymodelbot&utm_campaign=amb_readme)。我们不声称能做到万无一失:凡是你发给模型的内容,都会离开你的设备。完整清单见 [docs/privacy.md](./docs/privacy.md)。<picture><source media="(prefers-color-scheme: dark)" srcset="docs/assets/diagrams/architecture-dark.svg">@@ -319,7 +319,7 @@ Modelflare 会保留请求日志;保留什么、保留多久,见它的[信# 🔗 相关项目-- [Modelflare](https://modelflare.dev):AnyModelBot 模型背后的 AI API 网关。+- [Modelflare](https://modelflare.dev/?utm_source=anymodelbot&utm_campaign=amb_readme):AnyModelBot 模型背后的 AI API 网关。- [magpie](https://github.com/yetone/magpie):随应用打包的 Go 网关(MIT)。- [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness):智能体运行时(MIT)。- [Cua](https://github.com/trycua/cua):电脑操作驱动。@@ -374,6 +374,6 @@ AnyModelBot 以 [MIT 许可证](./LICENSE)发布。随附的第三方软件保[stars-link]: https://github.com/modelflare-ai/AnyModelBot/stargazers[license-link]: https://github.com/modelflare-ai/AnyModelBot/blob/master/LICENSE[ci-link]: https://github.com/modelflare-ai/AnyModelBot/actions/workflows/ci.yml-[pricing-link]: https://modelflare.dev/pricing?utm_source=github&utm_medium=readme&utm_campaign=anymodelbot-[modelflare-link]: https://modelflare.dev/?utm_source=github&utm_medium=readme&utm_campaign=anymodelbot+[pricing-link]: https://modelflare.dev/pricing?utm_source=anymodelbot&utm_campaign=amb_readme+[modelflare-link]: https://modelflare.dev/?utm_source=anymodelbot&utm_campaign=amb_readme[x-link]: https://x.com/modelflare_devdiff --git a/README_en.md b/README_en.mdindex 393ce9c..db7e076 100644--- a/README_en.md+++ b/README_en.md@@ -17,8 +17,8 @@<a href="https://github.com/modelflare-ai/AnyModelBot/releases">Download</a> |<a href="./README.md">简体中文</a> |English |- <a href="https://modelflare.dev">Modelflare</a> |- <a href="https://modelflare.dev/pricing">Pricing</a> |+ <a href="https://modelflare.dev/?utm_source=anymodelbot&utm_campaign=amb_readme">Modelflare</a> |+ <a href="https://modelflare.dev/pricing?utm_source=anymodelbot&utm_campaign=amb_readme">Pricing</a> |<a href="./docs/development_en.md">Development</a> |<a href="https://github.com/modelflare-ai/AnyModelBot/issues">Feedback</a></p>@@ -46,7 +46,7 @@AnyModelBot is a local-first AI agent app for Windows, macOS and Linux. A bot is a persona with its own default model, workspace and memory. Chat with it in the app, or reach it from WeChat and Feishu. Let it read and write files, run commands and operate your desktop, with an approval prompt whenever it steps outside its workspace.-Your conversations, memory, files and API keys live on your device. Models come from [Modelflare](https://modelflare.dev): one account, any model, priced per token. AnyModelBot itself has no subscription.+Your conversations, memory, files and API keys live on your device. Models come from [Modelflare](https://modelflare.dev/?utm_source=anymodelbot&utm_campaign=amb_readme): one account, any model, priced per token. AnyModelBot itself has no subscription.📥 [Download](#-download) · 🌠 [Screenshots](#-screenshots) · 🌟 [Features](#-key-features) · 🔐 [Privacy](#-how-it-works--privacy)@@ -57,18 +57,18 @@ Your conversations, memory, files and API keys live on your device. Models come<table><tr><td width="200" align="center" valign="middle">- <a href="https://modelflare.dev/?utm_source=github&utm_medium=readme&utm_campaign=anymodelbot">+ <a href="https://modelflare.dev/?utm_source=anymodelbot&utm_campaign=amb_readme"><img src="docs/assets/modelflare/modelflare-logo.png" width="120" height="120" alt="Modelflare logo"></a></td><td>-**[Modelflare](https://modelflare.dev/?utm_source=github&utm_medium=readme&utm_campaign=anymodelbot)** is an OpenAI-compatible AI API gateway with 200,000+ registered developers. One API key opens 70+ text, image and video models from 13 providers, including GPT, Claude, Gemini, Grok, DeepSeek, Kimi and GLM. Requests are routed across providers with ordered fallback, and every request is recorded with its usage and cost. Prices are public and billed per token.+**[Modelflare](https://modelflare.dev/?utm_source=anymodelbot&utm_campaign=amb_readme)** is an OpenAI-compatible AI API gateway with 200,000+ registered developers. One API key opens 70+ text, image and video models from 13 providers, including GPT, Claude, Gemini, Grok, DeepSeek, Kimi and GLM. Requests are routed across providers with ordered fallback, and every request is recorded with its usage and cost. Prices are public and billed per token.-**[Sign up for Modelflare →](https://modelflare.dev/sign-up?utm_source=github&utm_medium=readme&utm_campaign=anymodelbot)** ·-[Price list](https://modelflare.dev/pricing?utm_source=github&utm_medium=readme&utm_campaign=anymodelbot) ·-[API docs](https://docs.modelflare.dev/) ·-[Trust Center](https://modelflare.dev/trust) ·+**[Sign up for Modelflare →](https://modelflare.dev/sign-up?utm_source=anymodelbot&utm_campaign=amb_readme)** ·+[Price list](https://modelflare.dev/pricing?utm_source=anymodelbot&utm_campaign=amb_readme) ·+[API docs](https://docs.modelflare.dev/?utm_source=anymodelbot&utm_campaign=amb_readme) ·+[Trust Center](https://modelflare.dev/trust?utm_source=anymodelbot&utm_campaign=amb_readme) ·[X](https://x.com/modelflare_dev)</td>@@ -80,7 +80,7 @@ Your conversations, memory, files and API keys live on your device. Models come- **Sign in once.** The first launch opens your browser to sign in to (or sign up for) Modelflare. The app then connects this device itself, so there is no key to copy. Running in Docker or on a server? Paste an API key instead.- **Every model, one picker.** Your Modelflare models are listed automatically, with context length, capabilities and reference prices next to each one.- **Pay for what you use.** Balance, low-balance reminders and per-day usage show up inside the app. Check the public price list and compare it with the official rates before you choose a model.-- **An honest boundary.** Model requests travel through Modelflare to the provider you pick, and Modelflare keeps request logs. See the [Trust Center](https://modelflare.dev/trust) for what is kept and for how long. Everything else stays on your device ([details](#-how-it-works--privacy)).+- **An honest boundary.** Model requests travel through Modelflare to the provider you pick, and Modelflare keeps request logs. See the [Trust Center](https://modelflare.dev/trust?utm_source=anymodelbot&utm_campaign=amb_readme) for what is kept and for how long. Everything else stays on your device ([details](#-how-it-works--privacy)).---@@ -268,7 +268,7 @@ A bot is more than a chat window: it has a persona, a default model, its own wor| Your API key and sign-in tokens | Your sign-in with Modelflare, which happens at modelflare.dev || Settings | |-Modelflare keeps request logs; its [Trust Center](https://modelflare.dev/trust) explains what is kept and for how long. We do not claim your data is beyond all risk: anything you send to a model leaves your device. The full inventory is in [docs/privacy_en.md](./docs/privacy_en.md).+Modelflare keeps request logs; its [Trust Center](https://modelflare.dev/trust?utm_source=anymodelbot&utm_campaign=amb_readme) explains what is kept and for how long. We do not claim your data is beyond all risk: anything you send to a model leaves your device. The full inventory is in [docs/privacy_en.md](./docs/privacy_en.md).<picture><source media="(prefers-color-scheme: dark)" srcset="docs/assets/diagrams/architecture-dark.svg">@@ -319,7 +319,7 @@ Read the full [contributing guide](./CONTRIBUTING_en.md). To report a security p# 🔗 Related Projects-- [Modelflare](https://modelflare.dev): the AI API gateway behind AnyModelBot's models.+- [Modelflare](https://modelflare.dev/?utm_source=anymodelbot&utm_campaign=amb_readme): the AI API gateway behind AnyModelBot's models.- [magpie](https://github.com/yetone/magpie): the Go gateway bundled with the app (MIT).- [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness): the agent runtime (MIT).- [Cua](https://github.com/trycua/cua): the computer-use driver.@@ -374,6 +374,6 @@ AnyModelBot is released under the [MIT License](./LICENSE). Bundled third-party[stars-link]: https://github.com/modelflare-ai/AnyModelBot/stargazers[license-link]: https://github.com/modelflare-ai/AnyModelBot/blob/master/LICENSE[ci-link]: https://github.com/modelflare-ai/AnyModelBot/actions/workflows/ci.yml-[pricing-link]: https://modelflare.dev/pricing?utm_source=github&utm_medium=readme&utm_campaign=anymodelbot-[modelflare-link]: https://modelflare.dev/?utm_source=github&utm_medium=readme&utm_campaign=anymodelbot+[pricing-link]: https://modelflare.dev/pricing?utm_source=anymodelbot&utm_campaign=amb_readme+[modelflare-link]: https://modelflare.dev/?utm_source=anymodelbot&utm_campaign=amb_readme[x-link]: https://x.com/modelflare_devdiff --git a/SECURITY.md b/SECURITY.mdindex 22f96a5..661e873 100644--- a/SECURITY.md+++ b/SECURITY.md@@ -35,7 +35,7 @@ Security fixes go into the latest release. Please check that the problem still eIn scope: the AnyModelBot app in this repository (desktop app, command line, Docker image built from this repository) and its local console.-Out of scope here: Modelflare's own services (report those through the [Modelflare Trust Center](https://modelflare.dev/trust)), WeChat and Feishu platforms, and upstream projects such as magpie, DeepSeek Harness and Cua — please report those to their maintainers. If you are unsure, email us and we will route it.+Out of scope here: Modelflare's own services (report those through the [Modelflare Trust Center](https://modelflare.dev/trust?utm_source=anymodelbot&utm_campaign=amb_readme)), WeChat and Feishu platforms, and upstream projects such as magpie, DeepSeek Harness and Cua — please report those to their maintainers. If you are unsure, email us and we will route it.## 简体中文@@ -70,4 +70,4 @@ Out of scope here: Modelflare's own services (report those through the [Modelfla范围内:本仓库的 AnyModelBot 应用(桌面版、命令行、用本仓库构建的 Docker 镜像)及其本地控制台。-不在这里处理:Modelflare 自身的服务(请通过 [Modelflare 信任中心](https://modelflare.dev/trust)报告)、微信与飞书平台,以及 magpie、DeepSeek Harness、Cua 等上游项目——请报告给它们的维护者。拿不准的话,发邮件给我们,我们帮你转。+不在这里处理:Modelflare 自身的服务(请通过 [Modelflare 信任中心](https://modelflare.dev/trust?utm_source=anymodelbot&utm_campaign=amb_readme)报告)、微信与飞书平台,以及 magpie、DeepSeek Harness、Cua 等上游项目——请报告给它们的维护者。拿不准的话,发邮件给我们,我们帮你转。diff --git a/docs/development.md b/docs/development.mdindex 0f755d3..c2d5c9b 100644--- a/docs/development.md+++ b/docs/development.md@@ -5,7 +5,7 @@这份文档给想从源码运行、打包或参与开发的人看。普通用户直接从 [Releases](https://github.com/modelflare-ai/AnyModelBot/releases) 下载安装包即可,见 [README](../README.md#-下载)。- 一个机器人 = 人设 + 默认模型 + 渠道(飞书 / 微信)。定位:自用、单用户;每个机器人对应一个飞书应用。-- 模型来自 [Modelflare](https://modelflare.dev):首次启动登录(或注册)Modelflare 账户,模型自动列出;也可以直接粘贴一个 API Key。请求经过内置的 [magpie](https://github.com/yetone/magpie) 网关转发。+- 模型来自 [Modelflare](https://modelflare.dev/?utm_source=anymodelbot&utm_campaign=amb_readme):首次启动登录(或注册)Modelflare 账户,模型自动列出;也可以直接粘贴一个 API Key。请求经过内置的 [magpie](https://github.com/yetone/magpie) 网关转发。- 三种运行方式,同一套代码:**桌面版(Electron)**、**命令行 `npm start`**、**Docker**。## 目录结构@@ -91,7 +91,7 @@ docker exec amb cat /data/ui-token # 打开 http://<主机>:3600/?token=<令- 生成前确认:用默认模型、预计花费不超过 $0.5 时直接生成,不打扰你。只在这几种情况先在聊天里问你这次用哪个模型(附提示词、参数、参考价和为什么问):机器人要换用不是默认的模型(你点名的除外,代理传 `confirm: false`)、预计花费超过 $0.5(按参考价、张数、视频时长和分辨率估算;视频估不出来也问)、要求不明确(代理传 `confirm: true`)。可以确认、换成别的模型或取消;微信回复编号或模型名,飞书 / 网页点选。10 分钟内没回答就不生成。想每次都确认:机器人设置 → 生图 / 生视频 → 生成前确认 →「每次都问」。- 默认图片 / 视频模型:首次设置时和默认文本模型一起选,之后在 设置 → Modelflare 修改;选「自动」时用推荐顺序里第一个不需要参考素材的模型。- 模型选择器里显示上下文长度、视觉 / 工具 / 推理能力,以及每百万 tokens 输入 / 输出的起步参考价(来自公开价格目录,以账单为准)。-- 调用归因:经 Modelflare 的请求都带 `X-Modelflare-Skill: anymodel-bot/<版本>`,链接都带 `utm_source=anymodelbot`。+- 调用归因:经 Modelflare 的请求都带 `X-Modelflare-Skill: anymodel-bot/<版本>`,链接都带 `utm_source=anymodelbot&utm_campaign=amb_<位置>`(应用内 `amb_signup`、`amb_topup`、`amb_console` 等,README 与仓库文档 `amb_readme`,官网 `amb_homepage`;格式由 `test/utm.unit.test.ts` 固定)。- 线路:默认国际线路 `https://modelflare.dev/v1`;中国大陆可在「高级」或 设置 → Modelflare → 线路 选「中国大陆优化」(`https://origin.modelflare.dev/v1`)。线路由你选定,不自动切换。- 设置 → Modelflare:账户、余额与充值、余额提醒、用量、通知、邀请;连接状态(只显示 Key 尾号);未登录时可更换密钥或断开(机器人与会话保留,断开后回到首次连接页);默认模型、刷新模型列表。- 对话中输入框右侧的模型按钮可为当前会话切换模型(也可设为机器人默认);`/model`、`/reset`、`/new`、`/status`、`/stop`、`/help` 照常可用。diff --git a/docs/development_en.md b/docs/development_en.mdindex ea6ddb4..1fac7bf 100644--- a/docs/development_en.md+++ b/docs/development_en.md@@ -5,7 +5,7 @@This guide is for people who want to run AnyModelBot from source, package it, or contribute. If you only want to use the app, download an installer from [Releases](https://github.com/modelflare-ai/AnyModelBot/releases); see the [README](../README_en.md#-download).- A bot = persona + default model + channels (Feishu / WeChat). Scope: personal, single user; each bot maps to one Feishu app.-- Models come from [Modelflare](https://modelflare.dev): on first launch you sign in to (or sign up for) a Modelflare account and the models are listed automatically; you can also paste an API key. Requests go through the bundled [magpie](https://github.com/yetone/magpie) gateway.+- Models come from [Modelflare](https://modelflare.dev/?utm_source=anymodelbot&utm_campaign=amb_readme): on first launch you sign in to (or sign up for) a Modelflare account and the models are listed automatically; you can also paste an API key. Requests go through the bundled [magpie](https://github.com/yetone/magpie) gateway.- Three ways to run, one codebase: **desktop app (Electron)**, **command line `npm start`**, **Docker**.## Repository layout@@ -91,7 +91,7 @@ Inside the container the console listens on 0.0.0.0, so token access is enforced- Confirmation before generation: with the default model and an estimated cost of at most $0.5, the image or video is generated right away. The chat asks which model to use (with prompt, parameters, reference price and the reason for asking) only when the bot wants a model other than the default (unless you named it; the agent passes `confirm: false`), when the estimated cost is above $0.5 (from the reference price, number of images, video length and resolution; a video whose cost cannot be estimated is asked too), or when the request is ambiguous (the agent passes `confirm: true`). You can confirm, switch models or cancel — reply with a number or model name on WeChat, or click on Feishu / the web console. With no answer within 10 minutes, nothing is generated. To confirm every time: bot settings → Images / videos → Confirm before generating → "Every time".- Default image / video models: chosen together with the default text model during first-run setup, changeable later in Settings → Modelflare. "Auto" uses the first model in the recommended order that needs no reference material.- The model picker shows context length, vision / tools / reasoning capabilities, and starting reference prices per million input / output tokens (from the public price catalog; your bill is authoritative).-- Attribution: requests through Modelflare carry `X-Modelflare-Skill: anymodel-bot/<version>`, and links carry `utm_source=anymodelbot`.+- Attribution: requests through Modelflare carry `X-Modelflare-Skill: anymodel-bot/<version>`, and links carry `utm_source=anymodelbot&utm_campaign=amb_<placement>` (`amb_signup`, `amb_topup`, `amb_console` and so on inside the app, `amb_readme` for the README and repository docs, `amb_homepage` for the website; `test/utm.unit.test.ts` pins the format).- Routes: the international route `https://modelflare.dev/v1` is the default; in mainland China you can pick "Optimized for mainland China" (`https://origin.modelflare.dev/v1`) under Advanced or Settings → Modelflare → Route. You choose the route; it never switches automatically.- Settings → Modelflare: account, balance and top-up, balance reminder, usage, notifications, invites; connection status (only the key's last characters are shown); when not signed in you can replace the key or disconnect (bots and sessions are kept; disconnecting returns to the first-connection screen); default model, refresh model list.- The model button to the right of the composer switches the model for the current session (or sets it as the bot default); `/model`, `/reset`, `/new`, `/status`, `/stop` and `/help` all work.diff --git a/docs/privacy.md b/docs/privacy.mdindex 8ed7457..99a8841 100644--- a/docs/privacy.md+++ b/docs/privacy.md@@ -51,7 +51,7 @@- 模型请求由内置的 magpie 网关发往 Modelflare,再由 Modelflare 转给你选定的模型供应商。- 请求里包含模型回答所需的内容:提示词、对话上下文、被用到的记忆、文件内容、工具结果,以及电脑操作时的截图。- 请求带有 `X-Modelflare-Skill: anymodel-bot/<版本>` 头,用于在 Modelflare 侧标识来源;应用里打开的 Modelflare 链接带 `utm_source=anymodelbot`。-- Modelflare 会保留请求日志;保留什么、保留多久,见 [Modelflare 信任中心](https://modelflare.dev/trust)。各模型供应商对数据的处理,以它们各自的条款为准。+- Modelflare 会保留请求日志;保留什么、保留多久,见 [Modelflare 信任中心](https://modelflare.dev/trust?utm_source=anymodelbot&utm_campaign=amb_readme)。各模型供应商对数据的处理,以它们各自的条款为准。## 遥测diff --git a/docs/privacy_en.md b/docs/privacy_en.mdindex 865e73d..4485fbe 100644--- a/docs/privacy_en.md+++ b/docs/privacy_en.md@@ -51,7 +51,7 @@ This document explains what AnyModelBot stores where, what leaves your device, a- Model requests go from the bundled magpie gateway to Modelflare, which forwards them to the provider you chose.- A request contains what the model needs to answer: the prompt, conversation context, memory in use, file contents, tool results and, with computer use, screenshots.- Requests carry an `X-Modelflare-Skill: anymodel-bot/<version>` header so Modelflare can identify the source; Modelflare links opened from the app carry `utm_source=anymodelbot`.-- Modelflare keeps request logs; see the [Modelflare Trust Center](https://modelflare.dev/trust) for what is kept and for how long. How each model provider handles data is governed by its own terms.+- Modelflare keeps request logs; see the [Modelflare Trust Center](https://modelflare.dev/trust?utm_source=anymodelbot&utm_campaign=amb_readme) for what is kept and for how long. How each model provider handles data is governed by its own terms.## Telemetrydiff --git a/src/account/manager.ts b/src/account/manager.tsindex 4667a1f..3558a71 100644--- a/src/account/manager.ts+++ b/src/account/manager.ts@@ -151,7 +151,7 @@ export class AccountManager {const attempt = await startLogin(ep, {clientId: MODELFLARE_CLIENT_ID,scope: MODELFLARE_SCOPES,- extra: { ...UTM, utm_campaign: "login" },+ extra: { ...UTM, utm_campaign: "amb_signup" }, // 授权页也是注册入口:没有账户的人在这里注册fetchImpl: this.fetch,});this.login = attempt;@@ -302,7 +302,7 @@ export class AccountManager {const alerted = !!this.o.store.getKV(ALERTED);if (bal < lowBalanceUsd && !alerted) {this.o.store.setKV(ALERTED, String(Date.now()));- this.o.hooks.alert(`Modelflare 余额只剩 $${bal.toFixed(2)},低于提醒线 $${lowBalanceUsd}。充值:${webUrl("/billing", "low-balance")}`, push);+ this.o.hooks.alert(`Modelflare 余额只剩 $${bal.toFixed(2)},低于提醒线 $${lowBalanceUsd}。充值:${webUrl("/billing", "amb_low_balance")}`, push);} else if (bal >= lowBalanceUsd && alerted) {this.o.store.deleteKV(ALERTED);}@@ -327,7 +327,7 @@ export class AccountManager {const u = new URL("/sign-up", MODELFLARE_WEB);u.searchParams.set("aff", code);for (const [k, v] of Object.entries(UTM)) u.searchParams.set(k, v);- u.searchParams.set("utm_campaign", "invite");+ u.searchParams.set("utm_campaign", "amb_invite");return { code, url: u.toString() };}diff --git a/src/modelflare.ts b/src/modelflare.tsindex f8c3cf0..33ddb97 100644--- a/src/modelflare.ts+++ b/src/modelflare.ts@@ -23,8 +23,12 @@ export const MODELFLARE_WEB = "https://modelflare.dev";export const MODELFLARE_CLIENT_ID = "anymodel-bot";export const MODELFLARE_SCOPES = "openid profile offline_access account api_keys";-/** 注册来源(Modelflare 后台按 utm_source 统计从本程序来的注册) */-export const UTM = { utm_source: "anymodelbot", utm_medium: "app" } as const;+/**+ * 注册来源(Modelflare 后台按 utm_source 统计从本程序来的注册与充值)。+ * 全项目统一:utm_source=anymodelbot&utm_campaign=amb_<位置>。应用内 amb_signup / amb_topup / amb_console …,+ * README 与仓库文档 amb_readme,官网 amb_homepage。+ */+export const UTM = { utm_source: "anymodelbot" } as const;/** 开发/测试:AMB_MODELFLARE_ISSUER 把登录与账户接口指向本地 mock(界面无法设置) */export function modelflareIssuer(env: NodeJS.ProcessEnv = process.env): string {@@ -39,9 +43,9 @@ export function webUrl(pathname: string, campaign?: string): string {return u.toString();}-export const SIGNUP_URL = webUrl("/sign-up", "signup");-export const TOPUP_URL = webUrl("/billing", "topup");-export const CONSOLE_URL = webUrl("/dashboard/overview", "console");+export const SIGNUP_URL = webUrl("/sign-up", "amb_signup");+export const TOPUP_URL = webUrl("/billing", "amb_topup");+export const CONSOLE_URL = webUrl("/dashboard/overview", "amb_console");/*** 调用归因:每个经 Modelflare 的请求都带 X-Modelflare-Skill(Modelflare 只记到用量日志,diff --git a/test/utm.unit.test.ts b/test/utm.unit.test.tsnew file mode 100644index 0000000..154a89e--- /dev/null+++ b/test/utm.unit.test.ts@@ -0,0 +1,40 @@+/**+ * 来源参数的统一格式:utm_source=anymodelbot&utm_campaign=amb_<位置>,不带 utm_medium。+ * Modelflare 后台按它统计从本程序(应用、README、官网)来的注册与充值;改格式前先和后台对齐。+ */+import { describe, it, expect } from "vitest";+import { UTM, webUrl, SIGNUP_URL, TOPUP_URL, CONSOLE_URL } from "../src/modelflare.js";+// @ts-expect-error 前端模块是无类型的原生 ES 模块+import { mfLink, tagLink, MF_CONSOLE, MF_DOCS_LINK, MF_KEYS, MF_PRICING, MF_SIGNUP, MF_TOPUP } from "../ui/lib/links.js";++const params = (url: string) => Object.fromEntries(new URL(url).searchParams);++describe("UTM 来源参数", () => {+ it("后端:只有 utm_source 和 amb_ 开头的 utm_campaign", () => {+ expect(UTM).toEqual({ utm_source: "anymodelbot" });+ expect(params(webUrl("/billing", "amb_low_balance"))).toEqual({ utm_source: "anymodelbot", utm_campaign: "amb_low_balance" });+ expect(params(SIGNUP_URL)).toEqual({ utm_source: "anymodelbot", utm_campaign: "amb_signup" });+ expect(params(TOPUP_URL).utm_campaign).toBe("amb_topup");+ expect(params(CONSOLE_URL).utm_campaign).toBe("amb_console");+ });++ it("界面:所有固定链接都是 amb_ 开头,没有 utm_medium", () => {+ for (const url of [MF_CONSOLE, MF_KEYS, MF_SIGNUP, MF_TOPUP, MF_PRICING, MF_DOCS_LINK]) {+ const p = params(url);+ expect(p.utm_source).toBe("anymodelbot");+ expect(p.utm_campaign).toMatch(/^amb_[a-z_]+$/);+ expect(p).not.toHaveProperty("utm_medium");+ }+ expect(MF_SIGNUP).toBe("https://modelflare.dev/sign-up?utm_source=anymodelbot&utm_campaign=amb_signup");+ expect(new URL(MF_DOCS_LINK).origin).toBe("https://docs.modelflare.dev");+ expect(params(mfLink("/pricing", "amb_pricing"))).toEqual({ utm_source: "anymodelbot", utm_campaign: "amb_pricing" });+ });++ it("服务端下发的链接:Modelflare 的页面补上参数,已带参数或别的网站不动", () => {+ expect(params(tagLink("https://modelflare.dev/blog/x", "amb_notice"))).toEqual({ utm_source: "anymodelbot", utm_campaign: "amb_notice" });+ expect(params(tagLink("https://docs.modelflare.dev/guides", "amb_notice")).utm_campaign).toBe("amb_notice");+ expect(tagLink("https://modelflare.dev/x?utm_source=mail&utm_campaign=promo", "amb_notice")).toBe("https://modelflare.dev/x?utm_source=mail&utm_campaign=promo");+ expect(tagLink("https://example.com/a", "amb_notice")).toBe("https://example.com/a");+ expect(tagLink("https://evilmodelflare.dev/a", "amb_notice")).toBe("https://evilmodelflare.dev/a");+ });+});diff --git a/ui/lib/links.js b/ui/lib/links.jsindex eb66669..1cdc0d0 100644--- a/ui/lib/links.js+++ b/ui/lib/links.js@@ -1,20 +1,33 @@-// Modelflare 官网链接:都带注册来源参数(utm_source=anymodelbot),后台用它统计从本程序来的注册与充值。+// Modelflare 官网链接:都带来源参数,后台用它统计从本程序来的注册与充值。+// 全项目统一 utm_source=anymodelbot&utm_campaign=amb_<位置>(和 src/modelflare.ts 的 UTM 一致)。export const MF_SITE = "https://modelflare.dev";export const MF_DOCS = "https://docs.modelflare.dev";export function mfLink(path, campaign) {const u = new URL(path, MF_SITE);u.searchParams.set("utm_source", "anymodelbot");- u.searchParams.set("utm_medium", "app");if (campaign) u.searchParams.set("utm_campaign", campaign);return u.toString();}-export const MF_CONSOLE = mfLink("/dashboard/overview", "console");-export const MF_KEYS = mfLink("/keys", "keys");-export const MF_SIGNUP = mfLink("/sign-up", "signup");-export const MF_TOPUP = mfLink("/billing", "topup");-export const MF_PRICING = mfLink("/pricing", "pricing");+export const MF_CONSOLE = mfLink("/dashboard/overview", "amb_console");+export const MF_KEYS = mfLink("/keys", "amb_keys");+export const MF_SIGNUP = mfLink("/sign-up", "amb_signup");+export const MF_TOPUP = mfLink("/billing", "amb_topup");+export const MF_PRICING = mfLink("/pricing", "amb_pricing");+/** 文档站首页(给人点的链接;MF_DOCS 是基址,拼路径用) */+export const MF_DOCS_LINK = mfLink(MF_DOCS + "/", "amb_docs");++/** 服务端下发的链接(通知等):是 modelflare.dev 的页面、且还没带来源参数时补上;别的网站原样返回 */+export function tagLink(url, campaign) {+ try {+ const u = new URL(url, MF_SITE);+ if (!/(^|\.)modelflare\.dev$/.test(u.hostname) || u.searchParams.has("utm_source")) return u.toString();+ return mfLink(u.toString(), campaign);+ } catch {+ return url;+ }+}/** 美元金额:两位小数;很小的数保留四位,避免显示成 $0.00 */export function usd(n) {diff --git a/ui/screens/account.js b/ui/screens/account.jsindex d991308..d625290 100644--- a/ui/screens/account.js+++ b/ui/screens/account.js@@ -3,10 +3,13 @@ import { useEffect, useState } from "preact/hooks";import { html, Seg, Sheet, Skeleton } from "../components/ui.js";import { AccountLogin } from "./onboarding.js";import { api } from "../lib/api.js";-import { MF_SITE, usd } from "../lib/links.js";+import { MF_SITE, tagLink, usd } from "../lib/links.js";/** 通知里的链接:站内路径补成官网地址;只放行 https */-const notifLink = (link) => (!link ? "" : link.startsWith("/") && !link.startsWith("//") ? MF_SITE + link : /^https:\/\//.test(link) ? link : "");+const notifLink = (link) => {+ const raw = !link ? "" : link.startsWith("/") && !link.startsWith("//") ? MF_SITE + link : /^https:\/\//.test(link) ? link : "";+ return raw && tagLink(raw, "amb_notice");+};export function LoginSheet({ onClose, onSignedIn }) {return html`<${Sheet} title="登录 Modelflare 账户" onClose=${onClose}>diff --git a/ui/screens/settings.js b/ui/screens/settings.jsindex 75aa9a8..a9d9f45 100644--- a/ui/screens/settings.js+++ b/ui/screens/settings.js@@ -7,7 +7,7 @@ import { PickModel, shortModel } from "../components/model-picker.js";import { KeyForm, LINE_OPTIONS } from "./onboarding.js";import { LoginSheet, NotificationsSheet, UsageSheet } from "./account.js";import { api } from "../lib/api.js";-import { MF_CONSOLE, MF_DOCS, MF_TOPUP, usd } from "../lib/links.js";+import { MF_CONSOLE, MF_DOCS_LINK, MF_TOPUP, usd } from "../lib/links.js";import { useStore, confirmSheet, failed, saved } from "../lib/store.js";import { themeMode, setThemeMode } from "../lib/theme.js";import { TroubleshootPane } from "./troubleshoot.js";@@ -270,7 +270,7 @@ export function SettingsScreen({ tab, query: q, onQuery: setQ, onTab, focusRow,{ tab: "troubleshoot", id: "troubleshoot", name: "故障排查", sub: "模型网关与代理进程的状态、测试模型、测试代理、最近日志、复制诊断信息", keys: "日志 log 测试 test 代理 agent 卡住 转圈 诊断 diagnostics 重启 PowerShell pwsh 命令慢 安装 重新安装 内置 系统默认",ctl: html`<button type="button" class="text" onClick=${() => { setQ(""); onTab?.("troubleshoot"); }}>打开</button>` },{ tab: "about", id: "links", name: "Modelflare", sub: "官网与文档",- ctl: html`<a class="text" href=${MF_CONSOLE} target="_blank" rel="noopener noreferrer">modelflare.dev ↗</a><a class="text" href=${MF_DOCS} target="_blank" rel="noopener noreferrer">文档 ↗</a>` },+ ctl: html`<a class="text" href=${MF_CONSOLE} target="_blank" rel="noopener noreferrer">modelflare.dev ↗</a><a class="text" href=${MF_DOCS_LINK} target="_blank" rel="noopener noreferrer">文档 ↗</a>` },].filter(Boolean);}, [s, mf, mode, models, modelsError, cu, status, bots, acct, invite, unread]);