docs/technical/vibedrop-publish.md
状态:实施中(分支
feat/vibedrop-publish,三 repo 并行 worktree) 替换原 EdgeOne MCP 匿名发布,改为可登录、可管理的 VibeDrop 集成。
当前 HTML artifact 的「发布」走 EdgeOne(src/renderer/packages/edgeone.ts,纯 renderer 直连 mcp.edgeone.site),完全匿名——只带随机 X-Installation-ID,无用户身份,用户发布后无法管理已发布的站点。
目标:
VibeDrop(Cloudflare Workers + Hono + D1 + R2 + KV)已预留 partner 通道:
POST /v1/integrations/issue-key:Bearer <partner-secret> + {email} → upsert 用户、签发 vd_p_xxx key 绑定该 email、记 issuedBy=partner。POST /v1/sites/inline:{html, title?, slug?} 部署单页,返回 {site, claimUrl}。GET /v1/auth/me:用户 magic-link 登录后,同邮箱下 partner 签发的 key 及其站点自动出现(无需 claim)。chatbox-backend:email 为主键身份(邮箱验证码登录,email 已验证),客户端持 JWT(x-chatbox-access-token,TokenChecker 解出 email),已有 HMAC 签名 / 阿里云 Green 审核(pkg/services/guardrail,TextModerationPlus service query_security_check_pro,RiskLevel=high 拒绝,fail-open)等成熟模式。
| 维度 | 决定 |
|---|---|
| chatbox tier | 不过期、不限站点数、单站点 64MB、inline 上限提到 16MB、保留广告条、无密码/自定义域名 |
| 鉴权 | 客户端经 backend issue-key 拿 vd_p key(backend 幂等缓存),再直连 VibeDrop 发布 |
| 默认可见性 | 仅通过链接访问(unlisted) |
| 重复发布 | 复用 slug 覆盖更新(slug 存 session 消息元数据) |
| EdgeOne | 直接替换移除 |
| 未登录 / 无邮箱 | 引导登录 chatboxai;chatbox 用户必须有邮箱,无邮箱时提示绑定 |
| 内容审核 | VibeDrop 侧新增阿里云 Green 审核,镜像 backend 语义 |
| 截图/打标 worker | Cloudflare Queue 实时消费 |
① 用户已登录 chatbox(JWT,email 已验证)
② 点发布 → modal(选 公开 / 仅链接)
③ 客户端 → chatbox-backend POST /api/vibedrop/issue-key(带 JWT)
backend 取 email(空则返回 email_required)
查 vibedrop_keys 表命中则返回;未命中 → 调 VibeDrop /v1/integrations/issue-key
Bearer <PARTNER_SECRET> + {email} → vd_p_xxx(tier=chatbox, issuedBy=chatbox)
存表幂等,返回 {vd_key, tier}
④ 客户端缓存 key(按邮箱),直连 VibeDrop POST /v1/sites/inline
Bearer vd_p_xxx + {html, title, visibility, slug?}
→ {url, slug}
⑤ modal 展示 URL + 「用 chatbox 邮箱登录 app.vibedrop.cc 管理」
chatbox-backend-vibedrop)vibedrop_keys(id, user_email uniqueIndex, vd_key, vd_key_id, tier, created_at, updated_at) + model + repo,做幂等复用。config.yaml:vibedrop.partner_secret(env VIBEDROP_PARTNER_SECRET)、vibedrop.api_base。internal/api/controllers/vibedrop-controller.go:POST /api/vibedrop/issue-key(TokenChecker)。email 空 → email_required;命中表直接返回;否则调 VibeDrop 签发并存表。internal/api/app.go 注册路由。vibedrop-server-vibedrop)0004_*.sql:sites 加 visibility('unlisted'|'public', default unlisted)、tags(JSON)、previewStatus(default pending)、moderationStatus(default pending);apiKeys.tier 放开含 'chatbox'。lib/shared.ts):新增 chatbox { ttlHours:Infinity, maxSites:Infinity, maxSizeMB:64, ads:true, password:false, customDomain:false };Tier 类型联合同步扩展;inline 上限 1MB→16MB。routes/integrations.ts):partner→tier 映射,chatbox partner 签发 tier:'chatbox'。routes/sites.ts + lib/publish.ts):接收 visibility;computeSiteExpiry 对 chatbox 返回不过期;syncClaimedKeyToPlan 优先级 pro>chatbox>free;toSiteDTO 回传 visibility/url。apps/serving/src/index.ts):public 去 noindex,unlisted 保留。lib/moderation.ts):Worker 内调 Green(签名 v3,AK/SK secret binding),文本 TextModerationPlus,RiskLevel=high 拒绝,fail-open。public 发布同步过文本审核,图片审核入 queue。apps/processor/):publish 成功且 public → 入队;消费:截图(Browser Rendering)→ R2 → 回写 ogImage/previewStatus;AI 分类打标 → tags;图片二次审核。routes/explore.ts + dashboard/web 页):GET /v1/explore 返回 public AND approved AND ready。POST /v1/sites/:slug/report + 管理端下架。chatbox-pro-vibedrop)src/renderer/packages/vibedrop.ts 替换 edgeone.ts:issueVibedropKey()(调 backend)+ publishToVibedrop()(直连 inline)。src/renderer/modals/VibedropPublish.tsx:未登录引导 / 无邮箱提示 / 可见性选择(默认 unlisted)/ 成功态 URL + 管理入口。src/renderer/components/Markdown.tsx:onClickDeploy 改打开新 modal;首发 slug 存消息元数据,再发复用 slug 覆盖更新。edgeone.ts、EdgeOneDeploySuccess.tsx、builtin MCP edgeone 项)。pnpm translate 生成,勿手改 locale JSON。# backend
POST /api/vibedrop/issue-key Header x-chatbox-access-token
→ 200 { vd_key, tier }
→ 400 { error: "email_required" }
# vibedrop
POST /v1/integrations/issue-key Bearer <partner_secret>
{ email } → 201 { key, keyId, userId, tier:"chatbox" }
POST /v1/sites/inline Bearer <vd_key>
{ html, title?, slug?, visibility } → { site:{ slug, url, visibility } }
GET /v1/explore?cursor=&tag= → { items:[{slug,title,ogImage,tags,url}], nextCursor }
POST /v1/sites/:slug/report { reason }
M1 backend issue-key + 表 ─┐
M2 vibedrop tier/visibility/inline ┼─ 主链路 MVP(可登录发布+管理)
M3 chatbox-pro 发布链路 + modal ─┘
M4 vibedrop 阿里云审核(public 前置)
M5 vibedrop Queue worker(截图+打标)
M6 vibedrop 广场 explore + 举报下架
vibedrop.partner_secret(env VIBEDROP_PARTNER_SECRET)、vibedrop.api_base。PARTNER_KEYS="chatbox:<secret>"、ALIYUN_GREEN_AK/ALIYUN_GREEN_SECRET(可选 ALIYUN_GREEN_REGION/ALIYUN_GREEN_ENDPOINT);binding PREVIEW_QUEUE(producer,队列 vibedrop-preview);迁移 0004、0005。apps/processor):consumer 绑定 vibedrop-preview + DLQ;R2 SITES、KV META、D1 DB;Browser Rendering BROWSER;Workers AI AI。三个 repo 均在 feat/vibedrop-publish 分支,已开 PR:
M1–M6 全部完成并通过本地可验证项(backend go build;vibedrop turbo typecheck 6 包 + vitest 132 通过;chatbox-pro tsc 对改动文件 0 回归)。运行时依赖(阿里云签名、Browser Rendering 截图、Workers AI 打标、Queue)需线上部署绑定 + 密钥后端到端验证。