fix(protocol): keep internal events off SSE (#35378)

This commit is contained in:
Kit Langton 2026-07-04 21:12:45 -04:00 committed by GitHub
commit 905123b9c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 52 additions and 44 deletions

View file

@ -1,5 +1,6 @@
export * as EventManifest from "./event-manifest.js"
import { Schema } from "effect"
import { Agent } from "./agent.js"
import { Catalog } from "./catalog.js"
import { Command } from "./command.js"
@ -78,7 +79,7 @@ export const ServerDefinitions = Event.inventory(
...TuiEvent.Definitions,
...InstallationEvent.Definitions,
...VcsEvent.Definitions,
...McpEvent.Definitions,
McpEvent.StatusChanged,
// Shared transitional: V1 contracts the current TUI still consumes during
// the migration (permission.asked/replied, question.asked, session.error).
// Remove when the TUI moves to the current permission/question surfaces.
@ -86,6 +87,9 @@ export const ServerDefinitions = Event.inventory(
...QuestionV1.Event.Definitions,
SessionV1.Error,
)
export const Server = Event.latest(ServerDefinitions)
export type ServerEvent = Schema.Schema.Type<(typeof ServerDefinitions)[number]>
export const isServer = (event: { readonly type: string }): event is ServerEvent => Server.has(event.type)
export const Definitions = Event.inventory(
...foundationDefinitions,

View file

@ -27,7 +27,6 @@ describe("public event manifest", () => {
Agent.Event.Updated,
])
expect(EventManifest.Definitions).toContain(Agent.Event.Updated)
expect(EventManifest.ServerDefinitions).toContain(McpEvent.ToolsChanged)
expect(EventManifest.Definitions.filter((definition) => definition.type === "agent.updated")).toEqual([
Agent.Event.Updated,
])
@ -47,6 +46,8 @@ describe("public event manifest", () => {
EventManifest.Definitions.map((definition) => definition.type),
)
expect(EventManifest.Latest.get("agent.updated")).toBe(Agent.Event.Updated)
expect(EventManifest.Server.get("mcp.status.changed")).toBe(McpEvent.StatusChanged)
expect(EventManifest.Server.has("mcp.tools.changed")).toBe(false)
expect(Agent.Event.Updated.durable).toBeUndefined()
expect(EventManifest.Durable.has("agent.updated")).toBe(false)
})