fix Codex HTML output pipeline#51
Open
BobbyCats wants to merge 1 commit into
Open
Conversation
This was referenced May 16, 2026
Contributor
|
Thanks for the detailed PR. I am not going to patch this branch directly because it touches several coupled agent-output paths: Codex invocation flags, JSONL parsing, HTML extraction, Suggested migration to current
Recommended regression coverage before review:
Recommended validation:
Once the parser/extractor behavior is covered in Vitest under |
Open
1f83b30 to
ed8b26c
Compare
Author
|
Updated this PR against current Migration changes:
Validation run:
|
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.
背景
在 Codex CLI 作为 agent 时,我复现了几类集中在 agent invoke/output pipeline 的问题:
codex exec --json会读取用户本机 Codex config。只要 config 中存在暂时不可用的 MCP server,本次 HTML 生成就可能被 unrelated MCP transport/auth errors 打断。thread.started/turn.started/item.completed,其中 assistant payload 可能是item.type: "agent_message",并且 usage 会出现在turn.completed.usage。现有 parser 只识别旧的assistant_messageshape。/api/convert需要的是 HTML artifact,/api/draft需要的是 markdown/text。两条路径共用 delta 处理时,assistant preamble 容易污染 HTML source 和 preview metrics。改动
--ignore-user-config、--ignore-rules、--ephemeral,避免用户本机 MCP/rules/session state 影响 HTML Anything 的一次性 generation。thread.started、turn.started、item.completed.item.type === "agent_message"、旧版assistant_message、以及turn.completed.usage。invokeAgent增加output: "text" | "html"seam:/api/convert走output: "html"/api/draft走output: "text"HtmlStreamExtractor,只在 HTML document start (<!DOCTYPE html>/<html>) 之后向 preview/source 输出,并在</html>后截断 trailing prose。node:test覆盖 HTML extraction 和 Codex parser shapes。依赖说明
新增
tsx作为 dev-only test runner,用于直接运行 TypeScript 测试文件;runtime code 没有 import 它,生产 bundle 不依赖它。边界
这个 PR 没有声称给 Codex CLI 增加 token-level streaming。如果 Codex CLI 在
exec --json下只在最后输出一个item.completed,应用仍然只能收到一个 content chunk。这里修的是:Codex invocation 不被 unrelated user config 打断、当前 JSONL shape 能被 parser 正确识别、HTML 输出不会被 preamble 污染、长时间运行时 UI metrics 保持可见。验证
pnpm test:6 tests passedpnpm exec tsc --noEmitpnpm build:passed;保留现有 Turbopack NFT trace warning,没有新增 build failure/api/convert能返回以<!DOCTYPE html>开头的 HTML delta,没有 MCP transport/auth error;Codex/api/draft仍返回 markdown/text,不被 HTML extractor 拦截