import { expect, test } from "bun:test" import { isOpenCodeEvent, type OpenCodeEvent, type OpenCodeEventEncoded } from "../src/groups/event.js" type JsonShape = Value extends string | number | boolean | null ? Value : Value extends undefined ? never : Value extends ReadonlyArray ? ReadonlyArray> : Value extends object ? { readonly [Key in keyof Value as undefined extends Value[Key] ? never : Key]: JsonShape } & { readonly [Key in keyof Value as undefined extends Value[Key] ? Key : never]?: JsonShape< Exclude > } : Value // JSON.stringify omits undefined object properties, so normalize them before // requiring every runtime event shape to fit its encoded wire contract. const wireReady: [JsonShape] extends [JsonShape] ? true : false = true test("classifies public events by type", () => { expect(isOpenCodeEvent({ type: "server.connected" })).toBe(true) expect(isOpenCodeEvent({ type: "mcp.status.changed" })).toBe(true) expect(isOpenCodeEvent({ type: "mcp.resources.changed" })).toBe(true) expect(isOpenCodeEvent({ type: "mcp.tools.changed" })).toBe(false) }) test("keeps public event runtime values within the encoded contract", () => { expect(wireReady).toBe(true) })