import { Schema } from "effect" import { EventV2 } from "@opencode-ai/core/event" export type Definition = { type: Type properties: Properties } const registry = new Map() export function define( type: Type, properties: Properties, ): Definition { const result = { type, properties } registry.set(type, result) return result } export function effectPayloads() { return [ ...registry .entries() .map(([type, def]) => Schema.Struct({ id: Schema.String, type: Schema.Literal(type), properties: def.properties, }).annotate({ identifier: `Event.${type}` }), ) .toArray(), ...EventV2.registry .values() .map((definition) => Schema.Struct({ id: Schema.String, type: Schema.Literal(definition.type), properties: definition.data, }).annotate({ identifier: `Event.${definition.type}` }), ) .toArray(), ] } export * as BusEvent from "./bus-event"