feat: capture and decode WebSocket frames for OpenAI /v1/responses#35
Draft
feat: capture and decode WebSocket frames for OpenAI /v1/responses#35
Conversation
…assembly Add OpenAI Responses API dissector that parses /v1/responses endpoint traffic (not /v1/chat/completions). Handles the heterogeneous input[] format with role-based (developer/user) and type-based (function_call, function_call_output, reasoning) items. Session ID extracted from prompt_cache_key field. Make ClassifyThread provider-aware: Anthropic uses system prompt length thresholds, OpenAI uses tool list heuristics (task/question/todowrite presence indicates main conversation vs subagent). Fix cross-provider contamination in loadTransactionsForSessions: the LIKE query could match transactions that merely mention a session ID in tool results. Now filters post-extraction by dissector-extracted SessionID. Add remapOpenAISubagents to link OpenCode subagent sessions to their parent via task_id references in function_call_output content. Remove the Linked Subagents blue box from conversation detail UI.
Add docs/llm-api-comparison.md documenting Anthropic Messages API vs OpenAI Responses API wire formats as observed through proxy traffic. Add toolIconCategory template func that normalizes tool names across providers (PascalCase vs lowercase) and add icons for WebFetch, Skill, AskUserQuestion/question, TodoWrite, and apply_patch.
When the assembler processes transactions incrementally, subagent sessions (with their own prompt_cache_key) may have been processed in a previous batch. The parent session's task_id references then can't find them for remapping. Fix by scanning loaded entries for task_id references and loading those additional sessions before groupBySession runs.
Adds end-to-end WebSocket MITM support for the permessage-deflate compressed WebSocket protocol used by OpenAI's /v1/responses endpoint (and codex CLI). Changes: - sniffer.go: fire HTTPRoundTripHook on 101 Switching Protocols so upgrades are visible in the activity log - sniffer.go: rewrite Sec-Websocket-Extensions on WS upgrades to force client_no_context_takeover + server_no_context_takeover, making each frame independently decompressible - sniffer.go: add GlobalWebSocketFrameHook and WebSocketFrameInfo type; fix in-place XOR masking bug (copy before unmask so forwarded frames stay correctly masked) - mitm_hook.go: re-export MitmWebSocketFrameInfo and SetGlobalMitmWebSocketFrameHook for use outside gostx/internal - program.go: wire WebSocket frame hook to store frames as WS_REQ / WS_RESP transactions; decompress permessage-deflate payloads using gorilla-style 9-byte tail (\x00\x00\xff\xff\x01\x00\x00\xff\xff) - program.go: add -silent-allow flag to auto-allow all traffic on start - main.go: wire -silent-allow flag - conversation_assembler.go: scan response_content_type and duration_ms as nullable (*string, *int64) so WS rows don't crash the assembler - greyproxy.yml: enable sniffing.websocket and mitm.alpn for both HTTP and SOCKS5 services - Makefile: add `make local` target building to ./greyproxy (used by scripts/test-matrix/run.sh) - docs/websocket-support.md: document all issues encountered and fixes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
permessage-deflatecompressed WebSocket connections (used by OpenAI/v1/responsesand thecodexCLI)WS_REQ/WS_RESPtransactions with decompressed JSON payloadsChanges
Core WebSocket capture (
sniffer.go,mitm_hook.go):HTTPRoundTripHookon 101 responses so upgrades appear in the activity logSec-Websocket-Extensionson WebSocket upgrades to forceclient_no_context_takeover; server_no_context_takeover, making each frame independently decompressibleGlobalWebSocketFrameHook/WebSocketFrameInfofor per-frame callbacksDecompression (
program.go):WS_REQ/WS_RESPtransactionspermessage-deflatepayloads using the gorilla-style 9-byte tail (\x00\x00\xff\xff\x01\x00\x00\xff\xff) required by Go'scompress/flateAssembler fixes (
conversation_assembler.go):response_content_typeandduration_msas nullable (*string,*int64) — both are NULL for WS rows, which previously caused the assembler to skip every WS transactionOther:
-silent-allowflag for test matrix runnersniffing.websocket: trueandmitm.alpn: http/1.1ingreyproxy.ymlmake localtarget building to./greyproxy(path used byscripts/test-matrix/run.sh)docs/websocket-support.md: full history of issues encountered and fixes appliedTest plan
scripts/test-matrix/run.sh --isolatewithcodexCLI and verifyWS_REQ/WS_RESPtransactions appear in the activity log with readable JSON payloads