Skip to content

refactor: modularize chatgpt-web (non-stacked) - #3986

Closed
oyi77 wants to merge 4 commits into
diegosouzapw:release/v3.8.28from
oyi77:pr/chatgpt-web
Closed

oyi77 wants to merge 4 commits into
diegosouzapw:release/v3.8.28from
oyi77:pr/chatgpt-web

Conversation

@oyi77

@oyi77 oyi77 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Replaces #3790 as an independent, non-stacked PR branched from release/v3.8.27.

Extracts chatgpt-web handler into a modular structure.

Supersedes: #3790

@oyi77
oyi77 requested a review from diegosouzapw as a code owner June 16, 2026 12:12

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the chatgpt-web executor, which integrates chatgpt.com's web client endpoints into the system. It implements session token exchange, browser-like warmup, Sentinel requirements (including proof-of-work solving), and support for image generation and editing via WebSockets. The review feedback highlights several critical runtime issues across multiple files where required functions like extractContent, randomUUID, and randomBytes are either not exported or not imported from node:crypto, which would lead to ReferenceErrors.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread open-sse/executors/chatgpt-web/sse.ts Outdated
return out;
}

async function* extractContent(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The extractContent generator function is used in responses.ts but is not exported from sse.ts. Exporting it is required so it can be imported and used by other modules.

Suggested change
async function* extractContent(
export async function* extractContent(

} from "../../services/chatgptImageCache.ts";

import { ImagePointerRef, ImageResolver, imageMarkdown, resolveImagePointers } from "./images.ts";
import { sseChunk } from "./sse.ts";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The extractContent function is used on lines 61 and 334 but is not imported from ./sse.ts. Please import it alongside sseChunk.

Suggested change
import { sseChunk } from "./sse.ts";
import { sseChunk, extractContent } from "./sse.ts";

Comment on lines +5 to +6
import crypto from "node:crypto";
import { createHash } from "node:crypto";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The randomUUID function is used on lines 173 and 304 but is not imported from node:crypto. Please import it to avoid a runtime ReferenceError.

Suggested change
import crypto from "node:crypto";
import { createHash } from "node:crypto";
import crypto from "node:crypto";
import { createHash, randomUUID } from "node:crypto";

Comment on lines +5 to +6
import crypto from "node:crypto";
import { createHash } from "node:crypto";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The randomUUID function is used on lines 225, 236, and 258 but is not imported from node:crypto. Please import it to avoid a runtime ReferenceError.

Suggested change
import crypto from "node:crypto";
import { createHash } from "node:crypto";
import crypto from "node:crypto";
import { createHash, randomUUID } from "node:crypto";

Comment on lines +5 to +6
import crypto from "node:crypto";
import { createHash } from "node:crypto";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The randomBytes (used on line 184) and randomUUID (used on line 254) functions are not imported from node:crypto. Please import them to avoid runtime ReferenceErrors.

Suggested change
import crypto from "node:crypto";
import { createHash } from "node:crypto";
import crypto from "node:crypto";
import { createHash, randomBytes, randomUUID } from "node:crypto";

@diegosouzapw

Copy link
Copy Markdown
Owner

Thanks @oyi77 — the chatgpt-web move looks structurally right (chatgpt-web.ts → 1-line re-export + modules), but Fast Quality Gates is failing (not file-size — check the job log; it stops around check:provider-consistency/check:fetch-targets). Please get the PR's own CI green. And since the sibling modularizations dropped content silently (#3993 dropped byteplus+mimocode, #3989 dropped the vertex usage fetcher), please verify this move is lossless (diff every export + internal handler monolith-vs-modules) and rebase onto current release/v3.8.27 before re-review.

@oyi77
oyi77 force-pushed the pr/chatgpt-web branch 2 times, most recently from ba5e277 to 21900c2 Compare June 17, 2026 05:06
oyi77 added a commit to oyi77/OmniRoute that referenced this pull request Jun 17, 2026
…orts

Address review feedback on diegosouzapw#3986:
- sse.ts: export extractContent (used by responses.ts)
- responses.ts: import extractContent from ./sse.ts
- executor.ts: add { randomUUID } named import from node:crypto
- messages.ts: add { randomUUID } named import from node:crypto
- sentinel.ts: add { randomBytes, randomUUID } named imports from node:crypto
@diegosouzapw
diegosouzapw changed the base branch from release/v3.8.27 to release/v3.8.28 June 17, 2026 08:20
oyi77 added a commit to oyi77/OmniRoute that referenced this pull request Jun 17, 2026
…orts

Address review feedback on diegosouzapw#3986:
- sse.ts: export extractContent (used by responses.ts)
- responses.ts: import extractContent from ./sse.ts
- executor.ts: add { randomUUID } named import from node:crypto
- messages.ts: add { randomUUID } named import from node:crypto
- sentinel.ts: add { randomBytes, randomUUID } named imports from node:crypto
oyi77 added 4 commits June 17, 2026 20:45
…orts

Address review feedback on diegosouzapw#3986:
- sse.ts: export extractContent (used by responses.ts)
- responses.ts: import extractContent from ./sse.ts
- executor.ts: add { randomUUID } named import from node:crypto
- messages.ts: add { randomUUID } named import from node:crypto
- sentinel.ts: add { randomBytes, randomUUID } named imports from node:crypto
Added exports for functions imported by executor.ts and other modules:
- images.ts: resolveImagePointers, pollForAsyncImage
- responses.ts: buildNonStreamingResponse
- session.ts: exchangeSession
- sentinel.ts: prepareChatRequirements, fetchDpl, solvePow, buildPrepareToken, solveProofOfWork
- thinking.ts: setUserThinkingEffort
- warmup.ts: runSessionWarmup

Fixes CI known-symbols gate failure.
@diegosouzapw

Copy link
Copy Markdown
Owner

Thanks for all the modularization work here, @oyi77 🙏. We've decided to hold the per-module "non-stacked" refactors and run the decomposition as one coordinated pass after the in-flight quality-gate work lands, instead of merging them piecemeal. Reason: on the two we did merge (#3993, #3988) we caught logic being dropped during the move — and the gates (provider-consistency / typecheck) don't detect internal-logic loss — so each of these needs a full lossless audit, which isn't tractable across many overlapping PRs against a moving release branch right now. The coordinated modularization is tracked in #3501 / #3594; we'd genuinely value your input on that plan once it's up. Closing for now — purely sequencing, not a reflection on the effort.

oyi77 added a commit to oyi77/OmniRoute that referenced this pull request Jun 20, 2026
…nto focused modules (diegosouzapw#3986)

Split the 2864-line monolith into 12 focused modules:
- constants.ts, executor.ts, images.ts, messages.ts, responses.ts
- sentinel.ts, session.ts, sse.ts, thinking.ts, utils.ts, warmup.ts
- index.ts (barrel re-export)

The original chatgpt-web.ts is now a thin re-export.
@oyi77

oyi77 commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto upstream/release/v3.8.31. Monolith chatgpt-web.ts (2863→1 line thin re-export) split into 12 focused modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants