Uh oh!
There was an error while loading. Please reload this page.
feat(server): add session event adapter - #2
Open
cc-hearts wants to merge 1 commit into
Open
Conversation
Bidirectional event-log adapter around the canonical TranscriptMessage contract, enabling conversations to move between Open Chat and external session formats: - transcript/sessionEvents.ts: synthesizeSessionEvents renders canonical history into session events (continuous seq, surfaceOp:'append' on surface events, sourceEventSeqs linking tool/result to tool/call, pairing invariant with empty-result backfill for pending calls). agentPlan / attachments are skipped and reported via degradations; validateSessionEvents runs a structural self-check on the emitted log. - transcript/adapters/sessionEvents.ts: convertSessionEventsHistory reads event lines back into canonical history (tool/call events fill missing block arguments, tool/result upserted by toolCallId onto the owning assistant message). - tests cover synthesis, validation, degradation reporting, reverse conversion, and round-trip fidelity; docs/architecture.md documents the adapter.
cc-heartsforce-pushed
the
feat/dsh-event-adapter
branch
from
August 18, 2026 07:51
cc5c8f1 to
ca95d2cCompare
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 freeto 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.
背景
借鉴主流会话交换工具的分层转换设计(各源格式 → 统一中间结构 → 目标会话事件),为 open-chat 增加会话事件日志的双向适配层,让会话可以在 open-chat 与外部会话格式之间移动,同时保持事件纪律一致。
改动
apps/server/src/transcript/sessionEvents.ts— 正向合成器synthesizeSessionEvents:TranscriptMessage[]→ 会话事件(turn/start、user/message、assistant/message、tool/call、tool/result、step/start、step/end、turn/end、session/title),每行一个 JSON 事件可逐行落盘;seq连续、surface 事件带surfaceOp:'append'、tool/result经sourceEventSeqs关联tool/call、配对不变量(无结果的 activity 补发空结果,否则会话恢复时模型 API 拒绝);agentPlan、attachments)跳过并在degradations里显式报告(失败要大声);validateSessionEvents结构自检(seq 连续性 / 事件白名单 / surfaceOp / sourceEventSeqs 指向)。apps/server/src/transcript/adapters/sessionEvents.ts— 反向适配器convertSessionEventsHistory:TranscriptMessage[](text → content、reasoning → reasoningContent、tool-call 块 /tool/call事件 → toolCalls、tool/result按toolCallIdupsert 到所属 assistant,timeline 重建)。apps/server/src/transcript/sessionEvents.test.ts— 29 个测试:合成纪律、校验失败路径、降级报告、反向还原、往返一致性(合成 → 序列化 → 还原)。docs/architecture.md— 新增 "Session Event Adapter" 一节。验证