v0.4.0
Author discriminated tool and event schemas
Code mode now emits exact agent-facing TypeScript for discriminated JSON Schema
unions. anyOf and oneOf work when every branch is a closed object sharing a
required string const property with a distinct value:
const Event = Type.Union([
Type.Object(
{
type: Type.Literal("research.requested"),
payload: Type.Object(
{ query: Type.String() },
{ additionalProperties: false },
),
},
{ additionalProperties: false },
),
Type.Object(
{
type: Type.Literal("research.completed"),
payload: Type.Object(
{ report: Type.String() },
{ additionalProperties: false },
),
},
{ additionalProperties: false },
),
]);Agent programs can construct, narrow, and forward these values between tools
without losing exact input checking. Other composition shapes remain rejected
instead of being emitted as looser TypeScript.
Install with:
npm install @torkbot/code-mode@0.4.0