Skip to main content

Module upstream

Module upstream 

Source
Expand description

Extracts the AG-UI event surface from the upstream TypeScript source of truth (sdks/typescript/packages/core/src/events.ts).

The upstream file is Zod, not a schema format, so this is deliberately a narrow reader rather than a TypeScript parser. It understands exactly the shapes the event declarations use:

export enum EventType { NAME = "VALUE", ... }
export const XEventSchema = BaseEventSchema.extend({ field: z.string().optional(), ... });
export const YEventSchema = XEventSchema.omit({ a: true }).extend({ ... });

Anything else is recorded as unparsed and reported as a warning, never as a failure โ€” a drift check that cries wolf is a drift check that gets disabled, which is the outcome this crate exists to prevent.

Structsยง

Field
One field of an event payload, as declared upstream.
ParsedSchema ๐Ÿ”’
A Zod object schema reduced to an ordered list of (field, value expression).
Upstream
The whole upstream event surface.
UpstreamEvent
One event type and the payload the upstream schema declares for it.

Functionsยง

bare_ident ๐Ÿ”’
The whole value when it is one identifier and nothing else, as in metadata: OptionalMetadataSchema.
brief ๐Ÿ”’
Shortens an expression for an error message.
build_event ๐Ÿ”’
collect_const_decls ๐Ÿ”’
Every const NAME = <expr>; in the file, mapped to its expression text.
event_type_literal ๐Ÿ”’
z.literal(EventType.RAW) -> RAW; z.literal("RAW") -> RAW.
extract
Reads events.ts and returns the event surface it declares.
field_optionality ๐Ÿ”’
Whether a field is required, and how that was decided when the Zod chain could not decide it.
is_required ๐Ÿ”’
A field is optional when its own chain carries .optional() or .default().
parse_event_type_enum ๐Ÿ”’
Parses export enum EventType { ... }.
parse_expr ๐Ÿ”’
Parses z.object({...}) or OtherSchema, followed by a chain of .extend() / .omit() / .pick() / no-op modifiers.
parse_object_literal ๐Ÿ”’
Parses { key: <expr>, "quoted": <expr> } into ordered pairs.
parse_primary ๐Ÿ”’
Splits the head of a schema expression from the method chain that follows.
resolve ๐Ÿ”’
Resolves a schema const to its field list, following extend/omit/pick chains through other consts.
to_fields ๐Ÿ”’
Turns (field, value expression) pairs into fields, dropping the ones every event inherits and deciding required-ness from the Zod chain.