ADR-0020: Public API clean-up for 0.5
- Status: Accepted (2026-11-21). Point 4 is superseded by ADR-0021.
- Date: 2026-11-21
- Supersedes in part: ADR-0006. This replaces the "Zod" and "Node.js" rows of its support matrix, and adds to and removes from its list of public exports as below. The rest of ADR-0006 stands.
Context
An audit of the published types (packages/askdare/api/askdare.api.txt, November 2026) found the surface coherent, but with four things that will be harder to change once add-ons (admin, Postgres store) and 1.0 depend on them:
- Resolved shapes are exported.
Bot(withRequired<BotLimits>) andBotWidgetare whatdefineBotreturns after filling defaults. Exporting them freezes internal defaults as public types. Users writeBotDefinition. - Error codes can't be imported as values.
ErrorCodeandERROR_CODESappear in the generated declarations ofnextandreact, but no entry point exports them. Code that switches ononError'scodeor onuseChat's error has to copy strings. PROTOCOL_VERSIONis exported from.but not listed in ADR-0006.zodis a required peer, even for a site that only uses the script tag and defines no tools.
Separately, Node 26 became LTS in October 2026, and CI tests it from 0.4.x on.
Breaking changes are allowed in 0.x minors (ADR-0006). Making them now, together, costs less than making them one by one later.
Decision
From 0.5:
BotandBotWidgetare no longer exported.defineBotreturns an opaqueBotHandletype with no public members. The handler andgetChatConfigaccept it.ERROR_CODES(a readonly array) andErrorCodeare exported from.and are public API. Adding a code is a minor change, and removing one is breaking.PROTOCOL_VERSIONis public API, exported from.as today.zodbecomes an optional peer (peerDependenciesMeta.zod.optional).defineTooland tool schemas still need it, and its docs say so. A missingzodfails with a clear message only when a tool is defined.- Support matrix changes:
- Node.js: 22, 24 and 26 (
engines: >=22). - Zod:
^4.1, an optional peer that tools require.
- Node.js: 22, 24 and 26 (
The type-only removals in point 1 can't carry a runtime deprecation warning one minor earlier, as ADR-0006 otherwise asks. The 0.5 changeset and docs/support.md name the replacement instead.
Consequences
- Add-ons and 1.0 build on a smaller, intentional surface.
- Users who annotated variables as
Botmust switch toBotDefinitionorBotHandle. This is a one-line change, named in the changeset. ERROR_CODESbecomes a promise: every new code is a documented, minor change.- One more
peerDependenciesMetaentry to keep correct, checked by publint and attw.
Alternatives considered
- Leave the surface as it is until 1.0: each change gets more expensive as add-ons and apps depend on the resolved types.
- Deprecate first, remove in 0.6: there is no runtime to warn in for a type. A
@deprecatedtag helps only editors, and 0.x already allows the break. - Drop
zodfor a schema-agnostic tool API (Standard Schema): worth looking at before 1.0, but it changesdefineToolfor every tool user. It is out of scope here.