Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(core): add Stream Event Protocol v1 types (ADR 0001) - #41

Open
sjr666666 wants to merge 1 commit into
helsome:mainfrom
sjr666666:feat/27-stream-event-protocol
Open

feat(core): add Stream Event Protocol v1 types (ADR 0001)#41
sjr666666 wants to merge 1 commit into
helsome:mainfrom
sjr666666:feat/27-stream-event-protocol

Conversation

@sjr666666

@sjr666666 sjr666666 commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

背景与动机

copilot 的回答流目前走隐式 AgentEvent(8 事件),缺版本号、单调 sequence 契约、显式取消与重连能力(issue #27)。本 PR 是 #27 的第一步,也是整条迁移链的地基:只落协议类型,零运行时行为变更,便于单独评审。

完成了什么

  • packages/core/src/stream-events.ts:版本化信封(protocolVersion / runId / messageId? / 单调 sequence / timestamp / typed payload)+ 12 种事件类型及逐类型 payload 映射;在现有 8 事件之上补 text_deltatool_progresscitation_addedstatuscancellederror
  • @finagent/core re-export。
  • docs/adr/0001-stream-event-protocol.md:context / decision / migration path / open questions。
  • packages/core/src/stream-events.test.ts:枚举完整性与编译期 payload 覆盖断言。

向后兼容

AgentEvent 与全部现有消费方未改动;新协议类型在迁移期与旧事件族并存。

关联 Issue

Refs #27(第一步,不关闭)、#34(message/run 双身份模型)。

验证

环境:Bun 1.4.2 / Windows 11 (NT 10.0.26200)

CI(本 PR 的 checks,全部 pass):Typecheck / Focused tests / Full unit tests (advisory) / Secret scan。

本地

bun test --isolate packages/core/src/stream-events.test.ts
→ 4 passed / 0 failed

Open questions

见 ADR §Open questions(resume 数据源、status.phase 是否够用)。第 3 条 messageIdrunId 的取舍已在 #43 落地为"message 级事件携带 messageId,run 级只带 runId"。

Rebase 说明

已 rebase 到最新 main(046b5d3)。栈 #41#42#43;合并时以 #43 栈顶一次性带入完整协议增量,不再分别 squash #41/#42

@helsome helsome left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

先暂缓单独合入。这个 PR 的 StreamEvent 判别联合问题已经由你在 #43 中确认并修复,而且 messageId === runId 与正在实现的 #34 conversation lineage 身份模型冲突。请以 #43 顶层 review 为准,先把 identity contract 定型,再合这组 stack。

@helsome helsome left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

更新审核结论:上一轮提到的 identity/reconnect 问题已经在顶层 #43 修掉,不再要求你回头改 #41#41/#42 继续作为 stacked 中间层即可,不建议单独合;现在以已经 APPROVE 的 #43 为最终合入单元,剩余只需把顶层 stack rebase 到最新 main 并通过基础 CI。

Introduce the pure-type foundation for the structured streaming event protocol (issue helsome#27): versioned envelope, 12 typed events, and the idempotency/cancel/reconnect contracts as types. Zero runtime change.

Adds ADR 0001 documenting context, decision, migration path and open questions for maintainer review.
@sjr666666
sjr666666 force-pushed the feat/27-stream-event-protocol branch from 70016c3 to 63027e2 Compare September 13, 2026 13:05
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