SR

syntaxsmith/rosetta

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

37 stars 6 forks 质量 87 趋势 32MIT

通过在授权持有者的 Chrome 页面和 Node API 之间转换,实现对 ChatGPT 的程序化访问(包括 Pro)。CDP 抓取拦截 + WebSocket 第二段流式传输。

概览

通过在认证持有者的 Chrome 页面和干净的 API 之间转换,实现从 Node 的程序访问。 就像罗塞塔石碑碑:一边是专业网页协议,一边是普通的Node API。 - : runConversation({ model: “gpt-6-pro”, ... }) 跟随 stream_handoff 事件,打开 WebSocket 第二条,并聚合实时 CoT 直到 message_stream_complete ——与 chatgpt.com UI 相同,但可从 Node 返回。- : 非 Pro 的 slug(gpt-5-6 默认;gpt-5-5 是网页界面的极速通道)通过相同路径在几秒内返回。- : 传递 conversationId + parentMessageId(或使用 recall: “thread”以实现持久性)。- : 每个通话都会生成自己的标签页;许多通话可以并行流式传输。- : 可选的 onChunk(delta) 回调会在 CoT 到达时流式传输。- : 只要 WS 发送心跳,长时间思考(15 分钟+)就会持续;只有真正的静默才能终止通话。 你需要一台 Chrome,开启 --remote-debugging-port 和 。配置文件会在多个运行中重复使用。 登录一次;该配置文件依然存在。

概述(AI 翻译)

通过在授权持有者的 Chrome 页面和干净的 API 之间转换,实现对 Node 对 ChatGPT(包括 Pro)** 的程序访问。

就像罗塞塔石碑一样:一边是专业网页协议,一边是普通的Node API。

它的作用

  • Pro 支持:runConversation({ model: "gpt-6-pro", ... }) 在 stream_handoff 事件之后,打开 WebSocket 第二条腿,并聚合实时的 CoT,直到 message_stream_complete ——与 chatgpt.com UI 相同,但可从 Node 返回。
  • 即时模型也一样:非Pro的slugs(gpt-5-6默认;gpt-5-5是网页界面的极速通道)通过同一路径在几秒内返回。
  • 多回合:传递conversationId + parentMessageId(或使用recall: "thread"进行持久化)。
  • 并发:每个调用生成自己的标签页;许多调用可以并行流。
  • 实时令牌deltas:可选的onChunk(delta)回调在CoT到达时进行流式传输。
  • 闲置超时看门狗:长时间思考(15分钟+),只要守望者发送心跳,就继续;只有真正的静默才能终止呼叫。

安装

需要节点≥22。

设置:启动Chrome

你需要一台打开--remote-debugging-port并且登录一次 chatgpt.com的Chrome。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

rosetta

Programmatic access to ChatGPT (incl. Pro) from Node, by translating between an auth-holder Chrome page and a clean API.

Like the Rosetta Stone: the Pro web protocol on one side, a regular Node API on the other.

What it does

  • Pro support: runConversation({ model: "gpt-6-pro", ... }) follows the stream_handoff event, opens the WebSocket second leg, and aggregates the live CoT until message_stream_complete — same UX as the chatgpt.com UI but returnable from Node.
  • Instant models too: non-Pro slugs (gpt-5-6 default; gpt-5-5 is the web UI’s 极速 lane) return in seconds via the same path.
  • Multi-turn: pass conversationId + parentMessageId (or use recall: "thread" for persistence).
  • Concurrency: each call spawns its own tab; many calls can stream in parallel.
  • Live token deltas: optional onChunk(delta) callback streams the CoT as it arrives.
  • Idle-timeout watchdog: long thinks (15 min+) keep going as long as the WS sends heartbeats; only true silence kills the call.

Install

pnpm add @syntaxsmith/rosetta
# or
npm i @syntaxsmith/rosetta

Requires Node ≥ 22.

Setup: launch Chrome

You need a Chrome with --remote-debugging-port open and logged in to chatgpt.com once. Profile is reused across runs.

Linux

chromium \
  --remote-debugging-port=9222 \
  --user-data-dir=$HOME/.rosetta/profile \
  --no-first-run --no-default-browser-check \
  https://chatgpt.com/

macOS

"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \
  --remote-debugging-port=9222 \
  --user-data-dir=$HOME/.rosetta/profile \
  --no-first-run --no-default-browser-check \
  https://chatgpt.com/

Windows (PowerShell)

& "C:\Program Files\Google\Chrome\Application\chrome.exe" `
  --remote-debugging-port=9222 `
  --user-data-dir=$env:USERPROFILE\.rosetta\profile `
  --no-first-run --no-default-browser-check `
  https://chatgpt.com/

Sign in once; the profile persists. Subsequent runs reuse the cookies.

CLI

# default = Pro (gpt-6-pro, GPT-6)
rosetta run "Explain idempotent matrices in three sentences."

# cheaper tier via explicit slug
rosetta run -m gpt-5-6 "Reply with the single word: pong"

# stream live tokens
rosetta run --stream "Sketch a 3-paragraph plan for X"

# threaded recall — successive calls build on the same conversation
rosetta run --recall research "what's the prior on Y?"
rosetta run --recall research "given that, what would change?"

# inspect / clear persisted threads
rosetta threads
rosetta forget research

# list models the account exposes
rosetta probe

# attach a local file (repeatable) — image, PDF, CSV, code, ...
rosetta run --attach photo.png "What's in this image?"
rosetta run --attach report.pdf "Quote the third paragraph verbatim."
在 GitHub 查看完整 README

安装

npx -y -p @syntaxsmith/rosetta rosetta-mcp
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "rosetta": { "command": "npx", "args": ["-y", "-p", "@syntaxsmith/rosetta", "rosetta-mcp"], "env": { "ROSETTA_CDP_PORT": "9222" } } } }