fix(server): isolate event schema types

This commit is contained in:
Dax Raad 2026-06-22 08:20:39 -04:00
commit b13a2d712a
2 changed files with 20 additions and 23 deletions

View file

@ -1,17 +1,25 @@
import { EventV2 } from "@opencode-ai/core/event"
import { Location } from "@opencode-ai/core/location"
import { Schema } from "effect"
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi"
const fields = {
id: EventV2.ID,
metadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
durable: Schema.optional(Schema.Struct({ aggregateID: Schema.String, seq: Schema.Int, version: Schema.Int })),
location: Schema.optional(Location.Ref),
}
const Event = Schema.Union([
...EventV2.definitions().map((definition) =>
Schema.Struct({
...EventV2.Payload.fields,
...fields,
type: Schema.Literal(definition.type),
data: definition.data,
data: definition.data as Schema.Struct<{}>,
}).annotate({ identifier: `V2Event.${definition.type}` }),
),
Schema.Struct({
...EventV2.Payload.fields,
...fields,
type: Schema.Literal("server.connected"),
data: Schema.Struct({}),
}).annotate({ identifier: "V2Event.server.connected" }),