Commit e0560ba
feat(schema): bump ACP schema to v1.19.0 (extensible unions + lenient deserialization) (#117)
* feat(schema): support custom/future variants and bump ACP schema to v1.19.0
Bump schema-v1.16.0 -> schema-v1.19.0. v1.18.0 introduced an "extensible union"
idiom (known const-tagged variants plus a "custom or future" catch-all member)
that datamodel-codegen cannot express in a discriminated union, so it emitted
broken placeholder literals.
Codegen support (scripts/gen_schema.py):
- _normalize_catchall_unions: strip the discriminator and collapse each catch-all
member to a permissive object, so codegen emits a plain, payload-preserving union.
- Inject a field_validator per catch-all that rejects the known discriminator
values (recovered from the schema's `not` clause), so a malformed known variant
fails instead of silently parsing as custom (mirrors the TS SDK's excludeKnownTags).
- EXTENSIBLE_UNIONS map + drift assertion so changes to the union set fail loudly.
- RENAME_MAP names for the 5 new variants; alias template updated so the parse
adapters include the catch-all.
Export the 3 new Elicitation*/Create* variants from the acp package.
Add unit and behavioral regression tests.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
* feat(schema): honor x-deserialize-default-on-error and skip-invalid-items
The schema declares lenient-deserialization hints that generated Pydantic models
cannot express directly: x-deserialize-default-on-error (salvage a malformed field
to its default) on 379 fields, and x-deserialize-skip-invalid-items (drop bad array
items) on 35. Mirrors the TypeScript SDK's src/schema-deserialize.ts.
- src/acp/_deserialize.py: leaf module (imports only pydantic, so schema.py can depend
on it without a layering cycle) with salvage_on_error and skip_invalid_items.
- gen_schema.py injects field_validator(mode="wrap") methods: `_meta` once on the shared
BaseModel via check_fields=False (inherited everywhere); non-meta fields per $def
grouped by fallback (None / [] / schema default); union-def common props target the
member variant classes.
- Generated schema.py uses an absolute import (from acp._deserialize) because
gen_signature.py loads the module standalone, where relative imports cannot resolve.
Add unit tests (fallback rules, spec extraction) and behavioral round-trips.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
* fix(client): reject unknown elicitation modes with a clean error
Adding CreateOtherElicitationRequest to the CreateElicitationRequest union (so
custom/future modes parse) made a previously-unreachable `raise TypeError` in the
client router reachable: an incoming custom mode now parses, then
_mode_from_create_elicitation_request hit the fallthrough and surfaced as an
opaque -32603 internal error (plus a logged traceback).
Raise RequestError.invalid_params instead, so a client that can't render an
unknown mode declines with a clean -32602. Adds a regression test.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
* fix(schema): terminate generated JSON with a trailing newline
pretty-format-json (pre-commit) rewrites schema/schema.json and schema/meta.json
because gen_all wrote them via json.dumps(indent=2) with no trailing newline.
Content is otherwise identical to the hook's output, so add the newline in
download_schema (keeping regeneration idempotent) and to the committed files.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
---------
Co-authored-by: Mistral Vibe <vibe@mistral.ai>1 parent 02b6f87 commit e0560ba
12 files changed
Lines changed: 2391 additions & 477 deletions
File tree
- schema
- scripts
- src/acp
- client
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
0 commit comments