diff --git a/.env.example b/.env.example index 670f7da..5d9b749 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ -# stalwart-bot production bootstrap (C-REDIS-ONLY-STATE) +# MessageWeave production bootstrap (C-REDIS-ONLY-STATE) # # The process requires only this environment variable. Redis ACL credentials are # both the application connection credential and the one-shot bootstrap trust root. diff --git a/Cargo.lock b/Cargo.lock index 0ef1848..6a2c89f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -895,6 +895,28 @@ version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" +[[package]] +name = "message-weave" +version = "0.1.0" +dependencies = [ + "async-trait", + "axum", + "jmap-client", + "redis", + "reqwest", + "ring", + "secrecy", + "serde", + "serde_json", + "subtle", + "thiserror 1.0.69", + "tokio", + "tower", + "tracing", + "tracing-subscriber", + "url", +] + [[package]] name = "mime" version = "0.3.17" @@ -1523,28 +1545,6 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" -[[package]] -name = "stalwart-bot" -version = "0.1.0" -dependencies = [ - "async-trait", - "axum", - "jmap-client", - "redis", - "reqwest", - "ring", - "secrecy", - "serde", - "serde_json", - "subtle", - "thiserror 1.0.69", - "tokio", - "tower", - "tracing", - "tracing-subscriber", - "url", -] - [[package]] name = "subtle" version = "2.6.1" diff --git a/Cargo.toml b/Cargo.toml index c51c621..55d0661 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "stalwart-bot" +name = "message-weave" version = "0.1.0" edition = "2021" diff --git a/Dockerfile b/Dockerfile index 373cf3b..ea718a7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,10 +11,10 @@ FROM debian:bookworm-slim AS runtime RUN apt-get update \ && apt-get install --no-install-recommends -y ca-certificates tini \ && rm -rf /var/lib/apt/lists/* \ - && useradd --system --create-home --home-dir /nonroot --shell /usr/sbin/nologin stalwart-bot -COPY --from=builder /build/target/release/stalwart-bot /usr/local/bin/stalwart-bot -USER stalwart-bot + && useradd --system --create-home --home-dir /nonroot --shell /usr/sbin/nologin messageweave +COPY --from=builder /build/target/release/message-weave /usr/local/bin/message-weave +USER messageweave ENV PORT=8080 \ RUN_MODE=webhook EXPOSE 8080 -ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/stalwart-bot"] +ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/message-weave"] diff --git a/README.md b/README.md index f8ed9cb..a1c52a5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# stalwart-bot +# MessageWeave 一个把 **Stalwart 邮箱**接入 **Telegram** 的个人邮件助手:新邮件来了在 Telegram 提醒你,还能按需查看/总结邮件内容。 diff --git a/cloudflare-worker/README.md b/cloudflare-worker/README.md index 936de19..623f853 100644 --- a/cloudflare-worker/README.md +++ b/cloudflare-worker/README.md @@ -1,4 +1,4 @@ -# Stalwart-bot Cloudflare Worker(ARCH-LB-WORKER) +# MessageWeave Cloudflare Worker(ARCH-LB-WORKER) 统一 HTTPS 入口 + 多后端 origin 故障转移(HA/LB 子项目)。 **透传模型**:Worker 不感知业务,原样转发请求到多个 https 后端 origin;仅「超时 / 5xx」做有界故障转移。 @@ -96,6 +96,6 @@ npx wrangler deploy 健康探针: ```bash -curl https://lb.stalwart-bot.example/healthz +curl https://lb.messageweave.example/healthz # => {"status":"ok","available":2,"total":2,"backends":[{"origin":"https://a.example","up":true,"status":200},...]} ``` diff --git a/cloudflare-worker/package.json b/cloudflare-worker/package.json index 96ff488..1745518 100644 --- a/cloudflare-worker/package.json +++ b/cloudflare-worker/package.json @@ -1,9 +1,9 @@ { - "name": "@stalwart-bot/lb-worker", + "name": "@messageweave/lb-worker", "version": "0.1.0", "private": true, "type": "module", - "description": "Stalwart-bot Cloudflare Worker: 统一 HTTPS 入口 + 多后端 origin 故障转移(透传模型,SAF-LB-PASSTHRU)。零运行时依赖(仅 ES2022 + Fetch API),可直接 node --test。", + "description": "MessageWeave Cloudflare Worker: 统一 HTTPS 入口 + 多后端 origin 故障转移(透传模型,SAF-LB-PASSTHRU)。零运行时依赖(仅 ES2022 + Fetch API),可直接 node --test。", "scripts": { "test": "node --test test/", "check": "node --check src/*.js && node --check test/*.test.js && wrangler deploy --dry-run --outdir=.build-check", diff --git a/cloudflare-worker/src/index.js b/cloudflare-worker/src/index.js index c641ad2..db44850 100644 --- a/cloudflare-worker/src/index.js +++ b/cloudflare-worker/src/index.js @@ -1,5 +1,5 @@ /** - * Cloudflare Worker 入口 — Stalwart-bot 多实例 LB/HA(ARCH-LB-WORKER / deployment.md §10)。 + * Cloudflare Worker 入口 — MessageWeave 多实例 LB/HA(ARCH-LB-WORKER / deployment.md §10)。 * * 稳定 ID(AGENTS.md §5/§7): * - SAF-LB-PASSTHRU:透传 headers/body(含鉴权头),不做鉴权改写。 diff --git a/cloudflare-worker/wrangler.toml b/cloudflare-worker/wrangler.toml index 9188e8c..7d044b2 100644 --- a/cloudflare-worker/wrangler.toml +++ b/cloudflare-worker/wrangler.toml @@ -1,5 +1,5 @@ /** - * Wrangler 示例配置 — Stalwart-bot 多实例 LB/HA(ARCH-LB-WORKER / deployment.md §10)。 + * Wrangler 示例配置 — MessageWeave 多实例 LB/HA(ARCH-LB-WORKER / deployment.md §10)。 * * 安全约束(AGENTS.md §2/§4,稳定 ID): * - 后端 origin 仅允许 https(C-HTTPS-INBOUND / C-HTTPS-URL);env 校验时拒绝 @@ -16,7 +16,7 @@ * npx wrangler secret put BACKEND_ORIGINS_JSON # 见下方示例格式 * npx wrangler deploy */ -name = "stalwart-bot-lb" +name = "messageweave-lb" main = "src/index.js" compatibility_date = "2025-01-01" compatibility_flags = ["nodejs_compat_v2"] diff --git a/docs/deployment.md b/docs/deployment.md index 264f49b..f9d4e8f 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -1,4 +1,4 @@ -# Stalwart-bot 部署方案(通用 HTTPS-only Docker) +# MessageWeave 部署方案(通用 HTTPS-only Docker) > 部署目标:**通用 Docker 容器平台**(任何能跑 Docker 的 VPS / 云主机 / k8s / 自托管容器平台), > **不绑定** Cloud Run / Lambda / CF Workers / Deno Deploy 等任何具体平台(`NG-SERVERLESS-BIND`)。 @@ -58,7 +58,7 @@ ## 3. Rust 多阶段构建与运行 ### 3.1 构建阶段 -(保留既有 rust:bookworm 构建 + 缓存分层约定;产物为单个静态编译二进制 `stalwart-bot`) +(保留既有 rust:bookworm 构建 + 缓存分层约定;产物为单个静态编译二进制 `message-weave`) > **实现现状**(阶段0 + 阶段1,`ARCH-STAGE0`/`ARCH-DEPS-STAGE0`/`ARCH-DEPS-STAGE1`):自动依赖含 `axum 0.8`(单端口入口)/`serde`/`serde_json`/`thiserror`/`secrecy`/`subtle`(常数时间比较)/`url`/`tokio`/`tracing` 等;**`jmap-client =0.4.2` 已引入**(阶段1,`default-features=false, features=["async","rustls"]`,**禁用 WebSocket feature**,`C-NO-LONG-CONN`);三条入口路由的鉴权已 fail-closed 落地(`R1`/`SAF-AUTH-*`),**JMAP 只读 adapter(G1/D-G1-1)代码已实现、待真实 `cargo test -- --ignored jmap::` 验证**,其余业务体仍为**占位**;`teloxide`(阶段2)/`redis`(阶段3/4)/`reqwest`(阶段3.5) 尚未引入;配置为环境变量手工解析(`ARCH-CONFIG-ENV`,无 figment/TOML)。CI 门禁见 §8(`cargo fmt --check`、`cargo clippy --all-targets -- -D warnings`、`cargo test`,在 Debian 容器内,`GATE-P0`)。 @@ -150,8 +150,8 @@ TLS 必须由 Cloudflare 或受信任反向代理终结;代理到容器的链 | RUN_MODE | 命令 | 说明 | |---|---|---| -| `webhook`(默认) | `stalwart-bot webhook`(或单一入口按 env 分派) | 单进程:TG Webhook handler + JMAP Push 回调 handler + Redis Streams worker + `/reconcile` + health | -| `reconcile` | `stalwart-bot reconcile` | 一次性对账补差后 exit,由外部调度器/容器任务触发 | +| `webhook`(默认) | `message-weave webhook`(或单一入口按 env 分派) | 单进程:TG Webhook handler + JMAP Push 回调 handler + Redis Streams worker + `/reconcile` + health | +| `reconcile` | `message-weave reconcile` | 一次性对账补差后 exit,由外部调度器/容器任务触发 | ### 6.1 入口路由(单端口 `PORT`,全部经平台 HTTPS URL 入站) ``` @@ -237,7 +237,7 @@ GET /ready ⚠️ 阶段0 为**占位 200**(ARCH-READY-PLACEHOLDER ```yaml services: bot: - image: stalwart-bot:latest + image: messageweave:latest ports: - "8080:8080" # 平台 ingress/反代映射 HTTPS → 8080(C-HTTPS-INBOUND) environment: @@ -245,7 +245,7 @@ services: RUN_MODE: webhook # BOT_TOKEN / JMAP_* / CHAT_ALLOWLIST / REDIS_URL # RECONCILE_TOKEN / TG_WEBHOOK_SECRET / JMAP_PUSH_VERIFICATION(三入口鉴权,均为必填 SAF-AUTH-*) - healthcheck: { test: ["CMD", "stalwart-bot", "health", "--addr", "127.0.0.1:8080"], interval: 30s } + healthcheck: { test: ["CMD", "message-weave", "health", "--addr", "127.0.0.1:8080"], interval: 30s } # REDIS_URL 指向外部、已认证的 Redis;不在此 compose 中运行 Redis。 ``` @@ -393,8 +393,8 @@ npx wrangler secret put LB_HEALTH_TTL_MS # 默认 30000ms ```json [ - {"url":"https://stalwart-bot-a.example.com","weight":100}, - {"url":"https://stalwart-bot-b.example.com","weight":100} + {"url":"https://messageweave-a.example.com","weight":100}, + {"url":"https://messageweave-b.example.com","weight":100} ] ``` diff --git a/docs/design.md b/docs/design.md index c6ca22b..d28dd9c 100644 --- a/docs/design.md +++ b/docs/design.md @@ -1,7 +1,7 @@ # Stalwart JMAP ↔ Telegram Bot — Rust 方案设计 > 状态:**调研与方案设计**(未写代码) -> 作者:Cowork(team: stalwart-bot) +> 作者:Cowork(team: MessageWeave) > 日期:2026-09-21 > 目标读者:Codex CLI(lead)、后续 AI coding agent、最终用户评审 > @@ -258,7 +258,7 @@ teloxide = { version = "0.17", features = [ - **不做什么**:不定义多态配置注册表、不预先抽象"渠道能力矩阵"、不建 plugins 机制;按需再演进(YAGNI)。 ### 5.3 运行模型(短请求,无长连接) -- 单一二进制 `stalwart-bot`,`#[tokio::main]`。 +- 单一二进制 `message-weave`,`#[tokio::main]`。 - 启动时: 1. 加载配置(`config::Config`)。 2. 构造 `JmapService`(`Client::connect` 完成 session 解析、account_id 缓存、mailbox role→id 映射预热);sinceState 从外部 Redis 恢复(`MOD-SINCESTATE`)。 diff --git a/web/index.html b/web/index.html index 830eed0..2115dce 100644 --- a/web/index.html +++ b/web/index.html @@ -5,7 +5,7 @@ -