[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-111816":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":14,"subscribersCount":14,"size":14,"stars1d":14,"stars7d":15,"stars30d":16,"stars90d":14,"forks30d":14,"starsTrendScore":14,"compositeScore":17,"rankGlobal":9,"rankLanguage":9,"license":18,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":21,"hasPages":19,"topics":22,"createdAt":9,"pushedAt":23,"updatedAt":24,"readmeContent":25,"aiSummary":26,"trendingCount":14,"starSnapshotCount":14,"syncStatus":16,"lastSyncTime":27,"discoverSource":28},111816,"dsh-better-bridge","sam666-byte\u002Fdsh-better-bridge","sam666-byte","DeepSeek Harness × Better DeepSeek bridge — run DeepSeek Harness on the free DeepSeek web chat (chatbrain relay)",null,"Python",58,10,56,0,1,2,43.82,"MIT License",false,"main",true,[],"2026-10-28 14:59:03","2026-11-17 18:06:24","# dsh-better-bridge\n\n**Run [DeepSeek Harness](https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002Fdeepseek-harness) (dsh) on the *free* DeepSeek web chat instead of the metered platform API — plus a bridge to the Better DeepSeek browser extension.**\n\nDeepSeek Harness is a capable open-source agent harness, but its built-in\naccount provider bills against the DeepSeek *platform* wallet. The consumer\nchat at chat.deepseek.com is free. This project connects the two worlds:\n\n1. **chatbrain relay** (`relay\u002F`) — a small OpenAI-compatible HTTP relay that\n   registers itself in dsh as a custom provider. Under the hood it drives\n   DeepSeek's consumer web-chat API with **your own logged-in web session**,\n   solving the web client's proof-of-work challenge and translating the\n   harness's tool calls into a text-tag contract the chat model can follow.\n2. **BDS bridge plugin** (external dependency, see [`PLUGIN.md`](PLUGIN.md)) —\n   the upstream `dsh-better-deepseek` plugin that lets the **Better DeepSeek**\n   browser extension use dsh as its execution side.\n\n## 💛 Dukung Kami\n\nThis project is free and open source. If it helps you, consider supporting\nits development — any amount, no minimum burden (from Rp1.000).\n\n\u003Cp align=\"center\">\n  \u003Ca href=\"https:\u002F\u002Fsaweria.co\u002FNusantaraeaters\">\n    \u003Cimg src=\"assets\u002Fsaweria-qr.png\" alt=\"Support via Saweria — scan this QR\" width=\"220\">\n  \u003C\u002Fa>\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n  👉 \u003Cb>\u003Ca href=\"https:\u002F\u002Fsaweria.co\u002FNusantaraeaters\">saweria.co\u002FNusantaraeaters\u003C\u002Fa>\u003C\u002Fb>\n\u003C\u002Fp>\n\n> \"Dukung Nusantara Bots - aplikasi AI agent gratis di HP. Donasi seikhlasnya buat pengembangan aplikasi. Terima kasih!\"\n\n## Architecture\n\n```\n                        your machine\n ┌───────────────────────────────────────────────────────────────┐\n │                                                               │\n │   Browser                      DeepSeek Harness (dsh)         │\n │  ┌──────────────────┐         ┌────────────────────────────┐  │\n │  │ chat.deepseek.com│         │  agent loop, tools, memory │  │\n │  │  + Better        │  ping \u002F │                            │  │\n │  │    DeepSeek ext  ├────────►│  dsh-better-deepseek plugin│  │\n │  └────────┬─────────┘  bridge └──────────────┬─────────────┘  │\n │           │                                  │ provider:      │\n │           │ web session                      │ \"chatbrain\"    │\n │           │ (extract.py)                     ▼                │\n │           │                        ┌────────────────────────┐  │\n │           └───────────────────────►│  chatbrain relay       │  │\n │              .websession.json    │  relay\u002Frelay2.py       │  │\n │              (chmod 600)         │  OpenAI API on :20232  │  │\n │                                  └───────────┬────────────┘  │\n └──────────────────────────────────────────────┼───────────────┘\n                                                │ HTTPS + PoW header\n                                                ▼\n                                     chat.deepseek.com web API\n                                     (\u002Fapi\u002Fv0\u002Fchat\u002Fcompletion)\n```\n\n## Components\n\n| Path | What it is |\n|---|---|\n| `relay\u002Frelay2.py` | The relay: OpenAI-compatible `\u002Fv1\u002Fchat\u002Fcompletions` + `\u002Fv1\u002Fmodels` on loopback, backed by the DeepSeek web-chat API. |\n| `relay\u002Fextract.py` | One-shot extractor: pulls `userToken` + cookies out of a dedicated Firefox profile (where you logged in manually) into `.websession.json`. |\n| `PLUGIN.md` | The bridge plugin is an **upstream package** (`dsh-better-deepseek` by EdgeTypE, MIT) — not vendored here. Documents its role and ping contract. |\n| `.env.example` | All configuration variables with placeholder values. |\n\n## How it works\n\n### Session extraction\nYou log in to chat.deepseek.com once, manually, in a dedicated Firefox\nprofile. `extract.py` re-opens that profile with Selenium\u002Fgeckodriver, reads\n`localStorage[\"userToken\"]`, and stores `{token, cookies}` as JSON with file\nmode `600`. The relay then authenticates to the web API exactly like the web\nclient does. When the token dies, re-run the extractor (or log in again).\n\n### Proof-of-work header\nEvery web-chat completion requires an `x-ds-pow-response` header: the client\nrequests a challenge (`\u002Fapi\u002Fv0\u002Fchat\u002Fcreate_pow_challenge`), solves it, and\nsends back a base64 JSON payload. The relay uses the\n[`deepseek-pow`](https:\u002F\u002Fpypi.org\u002Fproject\u002Fdeepseek-pow\u002F) package\n(WASM solver) for the hash.\n\n> **Gotcha:** the package's `to_answer_payload()` omits `target_path`, and\n> the API rejects the header without it. The relay builds the payload\n> manually: `{algorithm, challenge, salt, signature, answer: int,\n> target_path: \"\u002Fapi\u002Fv0\u002Fchat\u002Fcompletion\"}`.\n\n### Tool-call tag contract\nThe web chat has no native function calling, so the relay renders the\nharness's full system prompt + tool catalog **once per conversation** as a\ntext preamble, then sends only deltas. The model answers with tool calls as\ntext tags:\n\n```\n\u003Ctool_call>{\"name\": \"bash\", \"arguments\": {\"command\": \"ls -la\"}}\u003C\u002Ftool_call>\n```\n\nReplies are parsed back into OpenAI `tool_calls`. The parser is deliberately\nparanoid, because the model mixes dialects:\n\n- `\u003Ctool_call>` JSON is located by **balanced-brace scan** (closing tags are\n  unreliable — JSON blocks get closed with DSML tags and vice versa);\n- DeepSeek's native **DSML** dialect (`\u003C｜｜DSML｜｜invoke …>`) is parsed too,\n  including repair of mojibake-damaged fullwidth delimiters;\n- \"flattened\" tool JSON (arguments at top level) is re-nested;\n- leftover tag debris is swept from the visible text;\n- long fenced code blocks riding along with tool calls are trimmed (the full\n  text lives in the tool call itself).\n\nA short preamble + a per-turn recency reminder keep the chat model behaving\nlike an autonomous agent (use tools yourself, never hand the user a script;\nfinal answers as readable chat text, not code-block reports).\n\n### Multi-chain isolation\nA harness makes auxiliary calls too (session titles, memory jobs). Requests\ncarrying tools go to the **main agent chain**; everything else gets its own\nchain keyed by a hash of its opening messages. Aux chains can never reset or\npollute the main conversation. Chains are capped (≈6) with simple eviction.\n\n### Conversation mapping\nEach chain maps 1:1 to a server-side web-chat session\n(`\u002Fapi\u002Fv0\u002Fchat_session\u002Fcreate`). The relay keeps a message-count watermark\nand a fingerprint of the last forwarded message; if the harness's history\ndiverges (edit, rollback, new session), the chain resets into a fresh chat\nand the full render is sent again. The authoritative assistant text is read\nback from `\u002Fapi\u002Fv0\u002Fchat\u002Fhistory_messages` (RESPONSE fragments), not from the\nSSE stream.\n\n## Install & usage\n\n**Prerequisites**\n\n- Python 3.11+\n- Node.js LTS (the harness itself runs on Node; Python is only for the relay)\n- [DeepSeek Harness](https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002Fdeepseek-harness)\n  installed separately\n- Firefox + geckodriver (for the one-time login\u002Fextraction)\n- A DeepSeek account you can log in to at chat.deepseek.com\n\n**Steps**\n\n```bash\ngit clone \u003Cthis-repo> dsh-better-bridge\ncd dsh-better-bridge\npip install -r requirements.txt\n\n# 1) One-time: create a dedicated Firefox profile and log in\nfirefox -ProfileManager            # create e.g. \"chatbrain\", log in to\n                                   # chat.deepseek.com, then close Firefox\nCHATBRAIN_FF_PROFILE=\u002Fpath\u002Fto\u002Fprofile python3 relay\u002Fextract.py\n#    → writes .\u002F.websession.json (mode 600)\n\n# 2) Start the relay\npython3 relay\u002Frelay2.py            # listens on 127.0.0.1:20232\n\n# 3) Register the relay as a dsh provider (cordis patch, profile \"web\"):\n#    an OpenAI-compatible provider entry, e.g.\n#      chatbrain:\n#        baseURL: http:\u002F\u002F127.0.0.1:20232\u002Fv1\n#        apiKeyEnv: CHATBRAIN_API_KEY   # any dummy value; relay is loopback\n#        models: [deepseek-chat]        # contextWindow 1000000\n#    then select provider \"chatbrain\", model \"deepseek-chat\" in dsh.\n\n# 4) (Optional) Add the Better DeepSeek bridge plugin — see PLUGIN.md.\n```\n\nSanity check the relay on its own:\n\n```bash\ncurl http:\u002F\u002F127.0.0.1:20232\u002Fv1\u002Fmodels\ncurl http:\u002F\u002F127.0.0.1:20232\u002Fv1\u002Fchat\u002Fcompletions \\\n  -H 'Content-Type: application\u002Fjson' \\\n  -d '{\"model\":\"deepseek-chat\",\"messages\":[{\"role\":\"user\",\"content\":\"ping\"}]}'\n```\n\n### DeepSeek Web (4Free) — V3 + R1 as extra models (no official API)\n\n`d4f-wrapper\u002F` adds **DeepSeek V3** (`deepseek-v3-d4f`) and **DeepSeek R1**\n(`deepseek-r1-d4f`) to the dsh model picker, through the same DeepSeek web\nchat the relay uses — no official API key. It is an OpenAI-compatible server\n(port 20233) built on [xtekky\u002Fdeepseek4free](https:\u002F\u002Fgithub.com\u002Fxtekky\u002Fdeepseek4free),\nsharing the relay's userToken (read at runtime from `.websession.json`, never\nstored in the repo). Setup, provider YAML, and verification are in\n[`d4f-wrapper\u002FREADME.md`](d4f-wrapper\u002FREADME.md). Upstream is Jan 2025 and\nunmaintained — the wrapper carries the patches that keep it working (session\npath, JSON-patch SSE, first-fragment path, R1 thinking leak) plus the same\nDBS\u002Ftool-call handling as the relay (imported from `relay2.py`).\n\n### Windows (native, without WSL)\n\nThe same flow works on Windows; the differences are the shell syntax and a\nfew paths. Keep **3 separate terminals** open while in use:\n\n1. **Install Node.js LTS** from nodejs.org, then clone + install Python deps:\n   ```cmd\n   git clone https:\u002F\u002Fgithub.com\u002Fsam666-byte\u002Fdsh-better-bridge\n   cd dsh-better-bridge\n   pip install -r requirements.txt\n   ```\n\n2. **Create a dedicated Firefox profile:** press `Win+R`, type\n   `firefox -ProfileManager`, create a new profile (e.g. \"chatbrain\"), log in\n   to chat.deepseek.com in that profile, then **close Firefox completely** —\n   the extractor cannot read a profile that is still open. The profile path is\n   something like\n   `C:\\Users\\\u003Cyou>\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\xxxx.chatbrain`\n\n3. **Set environment variables in CMD** (the Windows equivalent of `export`):\n   ```cmd\n   set CHATBRAIN_FF_PROFILE=C:\\Users\\\u003Cyou>\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\xxxx.chatbrain\n   set FIREFOX_BIN=C:\\Program Files\\Mozilla Firefox\\firefox.exe\n   set GECKODRIVER_PATH=C:\\path\\to\\geckodriver.exe\n   ```\n   `set` only applies to the terminal it runs in, so run steps 4–5 from the\n   same terminal (or use `setx` to make the variables permanent).\n\n4. **Extract the session** (Firefox must be fully closed; use `python`, not\n   `python3`):\n   ```cmd\n   python relay\\extract.py\n   ```\n   Success = `.websession.json` appears in the repo folder.\n\n5. **Start the relay** and leave the terminal open:\n   ```cmd\n   python relay\\relay2.py\n   ```\n   Check from another terminal: `curl http:\u002F\u002F127.0.0.1:20232\u002Fv1\u002Fmodels`\n\n6. **Start dsh in a new terminal** (if PowerShell complains about execution\n   policy, use CMD instead). Install dsh globally first — do **not** use\n   `npx` (the `npx @deepseek-ai\u002Fdsh` download is currently broken: it is\n   missing the `@deepseek-ai\u002Fcordis-plugin-group` dependency and fails with\n   `ERR_MODULE_NOT_FOUND`):\n   ```cmd\n   npm install -g @deepseek-ai\u002Fdsh\n   dsh web --host 127.0.0.1 --port 3080 --no-open\n   ```\n   If the global install still reports the same missing package, install it\n   explicitly first: `npm install -g @deepseek-ai\u002Fcordis-plugin-group`, then\n   run `dsh` again.\n   Do not use `--host 0.0.0.0` — dsh rejects wildcards. On a VPS, loopback is\n   enough: you reach the GUI from inside the VPS (e.g. over RDP). Open the\n   token URL printed in the console and log in with your DeepSeek account.\n\n7. **Register the relay as a dsh provider:** edit\n   `C:\\Users\\\u003Cyou>\\.dsh\\profiles\\web\\cordis.patch.yml` and add an\n   OpenAI-compatible provider entry:\n   ```yaml\n   chatbrain:\n     baseURL: http:\u002F\u002F127.0.0.1:20232\u002Fv1\n     apiKeyEnv: CHATBRAIN_API_KEY   # any dummy value; relay is loopback\n     models: [deepseek-chat]\n   ```\n   Set `CHATBRAIN_API_KEY` to any dummy value, restart dsh, then select\n   provider **chatbrain** \u002F model **deepseek-chat** in the GUI. Done — dsh now\n   runs on the free web chat.\n\nNotes: all ports are loopback, so no VPS firewall rules are needed. If the\nchat later errors or returns empty, the session token expired — just re-run\nstep 4. The Better DeepSeek bridge plugin (see `PLUGIN.md`) is optional and\ncan be added later.\n\n## Configuration\n\nAll configuration is via environment variables (see `.env.example`):\n\n| Variable | Default | Used by | Meaning |\n|---|---|---|---|\n| `CHATBRAIN_PORT` | `20232` | relay | Loopback port for the OpenAI-compatible API |\n| `CHATBRAIN_SESSION_FILE` | `.\u002F.websession.json` | relay, extractor | Session `{token, cookies}` file |\n| `CHATBRAIN_LOG_FILE` | `.\u002Frelay2.log` | relay | Main relay log |\n| `CHATBRAIN_REPLIES_LOG` | `.\u002Frelay2-replies.log` | relay | Raw model replies (private — contains conversations) |\n| `CHATBRAIN_FF_PROFILE` | `.\u002Fff-profile` | extractor | Dedicated Firefox profile directory |\n| `FIREFOX_BIN` | `\u002Fusr\u002Fbin\u002Ffirefox` | extractor | Firefox binary |\n| `GECKODRIVER_PATH` | `geckodriver` | extractor | geckodriver binary (PATH lookup by default) |\n\n## Security notes\n\n- **Your session token is your account.** `.websession.json` contains a live\n  `userToken` equivalent to being logged in. Keep it `chmod 600`, on a\n  machine you trust, and **never commit it** (it is in `.gitignore`).\n- The relay listens on **loopback only**. Don't expose it: anyone who can\n  reach the port can spend your chat session.\n- The replies log contains your raw conversations — treat it like the token.\n- Use a dedicated Firefox profile (and ideally a dedicated account) so the\n  blast radius of any mistake stays small.\n\n## Disclaimer\n\nThis is an **unofficial** project. It is not affiliated with, endorsed by, or\nsponsored by DeepSeek, Anysphere, or EdgeTypE.\n\nIt interacts with DeepSeek's **consumer web-chat surface using your own\naccount session**, rather than the official platform API. That may conflict\nwith DeepSeek's Terms of Service, and account consequences (throttling,\nrestriction, or termination) are possible. Provided for educational and\npersonal use, **at your own risk**. If you need a supported integration, use\nthe official DeepSeek platform API.\n\n## Credits & attribution\n\n- **DeepSeek Harness** © DeepSeek — MIT License —\n  [github.com\u002Fdeepseek-ai\u002Fdeepseek-harness](https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002Fdeepseek-harness)\n- **Better DeepSeek** © EdgeTypE — MIT License —\n  [github.com\u002FEdgeTypE\u002Fbetter-deepseek](https:\u002F\u002Fgithub.com\u002FEdgeTypE\u002Fbetter-deepseek)\n  (including the `dsh-better-deepseek` plugin package)\n- **deepseek-pow** — the PoW solver package used by the relay\n  ([PyPI](https:\u002F\u002Fpypi.org\u002Fproject\u002Fdeepseek-pow\u002F))\n\n## License\n\nMIT — see [`LICENSE`](LICENSE).\n","这是一个将 DeepSeek Harness（dsh）开源智能体框架接入免费 DeepSeek 网页版聊天界面（chat.deepseek.com）的轻量级桥接工具。核心功能包括：1）chatbrain relay——提供 OpenAI 兼容 API，通过复用用户已登录的网页会话，绕过付费平台 API 限制，并自动处理网页端 Proof-of-Work 挑战；2）支持与 Better DeepSeek 浏览器扩展协同工作，作为其后端执行引擎。技术上采用 Python 实现，基于 HTTP 中继与会话复用，不依赖官方 API 密钥。适用于希望在零成本前提下本地运行 dsh 智能体、或为浏览器扩展提供私有化 AI 执行能力的研究者与开发者。","2026-11-24 04:41:51","CREATED_QUERY"]