Repository navigation
a2ui-core 0.4.0
·
235 commits
to main
since this release
- Catalogs can reference components, property schemas and functions in peer
catalogs with external$refs such as
simplified_catalog_v1_0.json#/components/Text.Catalog.peer_catalogs
lists the peers a catalog resolves them against.
Catalog.with_peer_catalogs(peers)returns a new catalog linked topeers
and leaves the catalog it is called on unchanged.link_catalogsreturns
the catalogs linked to one another, with optionalextra_peers: a catalog
without cross-catalog references is returned as is, and the others are
replaced by linked copies.inline_local_refstakes an optionalpeers
argument. A reference names its peer bycatalogIdor$id, exactly or by
path suffix, before falling back to the file name.common_types.jsonand a
document named exactlycatalog.jsonare never peers, and a path ending in
/catalog.jsonthat names no peer refers to the catalog itself.
MessageProcessorlinks copies of the catalogs passed to it and never
modifies them, so shared catalogs such as the basic catalog stay unchanged. is_valid_uax31_identifierandassert_uax31_identifierno longer strip a
leading@before checking UAX 31 syntax, andCatalog.from_jsonnow rejects
@-prefixed catalog function names and validates function parameter names.
PayloadValidatorallows the reserved@indexsystem function call on v1.0+
surfaces while validating user-defined function names against UAX 31.- BREAKING:
a2ui.core.schema.AgentToRendererMessage,
RendererToAgentMessage, and their legacy aliases now expose the full
v0.8–v1.0 union instead of being overwritten by v0.9 re-exports. The facade
no longer re-exportsAGENT_TO_RENDERER_DEFS,INLINE_DEF_MARKER,
SchemaKeywords,def_reforAnnotated, which leaked through the old
star imports; import them from their defining modules (#3064). - BREAKING:
Catalog.from_jsonkeeps each component's and function's
definition as the document writes it and no longer writes local references
inline, soComponentApi.schemaandFunctionApi.schemaof a loaded
catalog may contain$refandallOf. To migrate, read
Catalog.resolved_component_schema(name),resolved_function_schema(name)
andresolved_theme_schema, which give the schemas with references
resolved (#3053). Catalog.from_jsondeserializes a catalog document into the catalog model,
andCatalog.to_json()serializes the model back into an unbundled catalog
document, soCatalog.from_json(document).to_json()equalsdocument
(ignoring key order and the order ofenumandrequired, and excluding
components and functions omitted fromanyComponent.oneOfand
anyFunction.oneOf, whichfrom_jsonfilters out). No authored JSON is
cached beside the model:- Each component's and function's
schemais its definition as the
document writes it, withallOfmixins, local#/$defs/...and
common_types.json#/$defs/...references, descriptions, closure keywords,
allowedParents/allowedChildrenand the function'sreturnType,
allowedCallersandrequiresUserActivation. The resolved schemas are
computed once per catalog, andvalidation_schema,PayloadValidator
and the component reference map use them. FunctionApi.is_definitionsays whether a function'sschemais its
whole catalog document entry rather than the schema of itsargs.
from_jsonsets it on every function it loads, soto_json()writes
each entry as it was loaded, whatever its shape or name; for a function
defined in code it defaults to None, which infers it from the schema.ComponentApi.from_documentandFunctionApi.from_documentmark entries
loaded byfrom_json.to_json()writes loaded entries, defs and themes
with their references as written, and points a local reference to a
common type atcommon_types_urionly in those defined in code. A list
offunctionsthat repeats anameraisesA2uiCatalogError.- The catalog keeps the document's top-level fields as attributes:
schema_dialect($schema),schema_id($id),title,
description,declared_protocol_version,declares_catalog_id,
instructions,theme_schemawith itstheme_location(top-level
theme, v0.8'sstyles, or$defs.theme), the shared nameddefs,
functions_form(map or list),union_defsand the unknown top-level
extras. to_json()assembles the document from those fields. AnanyComponent
oranyFunctionunion that lists the entries is derived from them, so a
transformed catalog lists its own entries; any other union is kept as
written. A component or function defined by a model is derived from the
model in the shape of its protocol version, andcommon_types_urinames
the document its common types references point into. A catalog defined in
code emits a canonicalprotocolVersionand the unions of its entries;
an empty union is{"not": {}}; a union written asnullis kept.
to_json()andvalidation_schemaare computed once per catalog and
return a new copy on each call, so a catalog must be treated as immutable
once built: later changes to its fields are not reflected, andcopy_with
derives a changed catalog (#3053).
- Each component's and function's
- The basic catalogs (
a2ui.core.basic_catalog.v0_8,v0_9andv1_0)
rebuild their published catalog documents from their generated models, so
BasicCatalog().to_json()equals the published file without reading it;
a2ui-coreships no catalog JSON. The generatedBasicCatalogpasses the
document's top-level fields toCatalogand its theme astheme_model.
Theirvalidation_schemais unchanged except that the v1.0 catalog emits
theprotocolVersion: "1.0"its document declares (#3053). - BREAKING: (v0_8) The generated basic catalog models no longer share one
model between nested objects of different shapes:CheckBox.valuekeeps
literalBoolean(ValueItem), andDateTimeInput.value,Slider.value
and aButtonaction's contextvalueget their own models
(DateTimeInputValueItem,SliderValueItem,ContextValueItem), so values
the specification allows are no longer rejected. Nested object models carry
their descriptions on the fields, with line breaks kept, rather than as
docstrings. To migrate, build those values with the new models instead of
ValueItem(#3053). Catalog.from_jsonreads a v0.8 document's top-levelstylesas the theme
schema (#3053).Catalog.validation_schemais the self-contained schema used to validate
messages, previouslycatalog_schema.catalog_schemaremains as a
deprecated alias that emits aDeprecationWarning; to migrate, read
validation_schemainstead (#3053).Catalog.validation_schemaemits theprotocolVersionthat the catalog
document declares (including the canonical version of a catalog defined in
code), in the bare semantic version form that
catalog_definition.jsonrequires (v0.9.1becomes0.9.1;to_json
keeps it as written). Before v1.0, each function call schema in it
has the specification's shape: areturnTypeconstant,argsrequired when
it has required arguments, andunevaluatedProperties: falseon the call
and on itsargsunless the document already decides on unlisted
properties. v1.0 function entries stay open, sinceFunctionCallcloses the
call (#3053).Catalog.validation_schemabundles the published common types defs, with
local references, for every catalog, including catalogs loaded with
Catalog.from_json, which previously got the flat model-derived defs. It
flattensallOfmixins (ComponentCommon,Checkable, and local#/$defs/
mixins) into flat componentpropertiesandrequiredlists with component
properties overriding mixin properties, strips envelope keys (id,
component,catalogId) before reconstructing the canonical component
envelope, prunesComponentCommon,Checkableand inlined local mixins from
$defs, and propagates$reftarget descriptions onto reference objects. A
catalog without functions getsanyFunction: {"not": {}}, so the bundled
FunctionCalladmits no catalog function call. From v0.9, a theme
object schema that does not decide on unlisted properties gets
additionalProperties: true. Atitlekeyword written in a catalog document
is kept instead of being stripped (#3036, #3053).Catalog.from_jsonreads a v0.9 function's return type from its
returnTypeconstant, soFunctionApi.return_typeis no longeranyfor
the published v0.9 basic catalog's functions (#3053).Catalog.copy_with(components=, functions=, defs=)returns a copy that
keeps the document fields, lists its own entries in the unions it derives,
and drops the authored definitions that only the dropped entries
referenced (#3053).Catalog.from_jsonsets a function'sdescriptionfrom its definition
(#3053).Catalog.from_jsonno longer raises when neither the document nor the
protocol_versionargument names a protocol version; the catalog defaults
to v0.9 (#3053).- BREAKING: From v1.0,
MessageProcessor.get_renderer_capabilities
buildsinlineCatalogsfromCatalog.to_json()instead of the bundled
schema, matching the v1.0catalog_definition.jsonshape, so an inline
catalog keeps its externalcommon_types.jsonreferences (#3053). - BREAKING (v1_0): Components and function calls that name no
catalogIdresolve against the surface's default catalog, and fail if the
surface has none, instead of falling back to the first registered catalog.
An updated component no longer keeps the catalog of its previous version. - BREAKING (v1_0):
MessageProcessorchecks each nested function call
against the catalog it resolves to, and a call whose catalog can't be
resolved raisesA2uiCatalogError, as a component does, even without a
validation config. Argument errors from these checks are reported together
with the component schema errors of the same update, in one
A2uiValidationError, which reports a detail found by both checks once. - (v1_0)
PayloadValidatorfully checks a nested call when it runs in the
validator's catalog: when it names that catalog, or names nocatalogIdin
a component that names none either. Any other call runs in a catalog the
validator can't see, so only its envelope is checked: function and argument
identifiers, andargsmust be an object;MessageProcessorchecks it against the catalog it resolves to.
SurfaceComponentsModel.validate_components_updateapplies the same rule,
using whether each component's catalog is the surface default. Nested calls
are checked even in a component whose type the catalog doesn't define and
the validation config allows (allow_unknown_elements). - BREAKING:
DataContext.is_v10is renamed toDataContext.at_least_v10, since it is true for v1.0 and every later version. - BREAKING:
DataContextreports a function call whose catalog can't be resolved on the surface error channel with codeCATALOG_ERRORinstead ofEXPRESSION_ERROR. Other evaluation failures, including a function missing from its resolved catalog, keepEXPRESSION_ERROR. - (v1_0)
MessageProcessorrejects a component whosecatalogIdis not a string withA2uiValidationError, as it does for a function call, instead of failing to find the catalog. - BREAKING:
ComponentModelrequires a catalog:
ComponentModel(component_id, component_type, catalog, properties=None).
The legacyComponentModel(id, type, properties)form and aNonecatalog
are no longer accepted.MessageProcessorraisesA2uiCatalogErrorbefore
creating a model when neither the component nor the surface names a
catalog. - (v1_0) A component's JSON schema no longer judges the function or args of a
nested call: the publishedFunctionCalldef, which ties every call to the
functions of the component's catalog, is replaced by its envelope (@call,
args,catalogId) during component validation. So a JSON catalog built
from the generated or published basic schema accepts a call that names
another catalog, and the call is judged by the nested-call checks above
instead. Nested-call errors are now reported at the call's location in the
component (for examplecomponents.t1.text.args.value) rather than as
functions.<name>..., without a second, vaguer schema error for the same
call. - (v1_0) An empty
catalogIdnames a catalog, as any string does, so a
component or function call withcatalogId: ""fails catalog resolution
instead of falling back to the surface default, and a direct
PayloadValidatortreats it as another catalog. A non-stringcatalogId
on a nested call is atype_mismatcherror. - (v1_0) Reserved
@system functions such as@indexneed no catalog: they
are validated and run without catalog resolution, on any surface. A system
function call that names acatalogIdis rejected (extra_field), and
DataContextreports it as anEXPRESSION_ERRORinstead of running it. - (v1_0) A nested call with an empty
@callname is rejected as an invalid
identifier instead of being skipped. - (v1_0)
catalogIdandmetadataare component envelope keys, likeidand
component:PayloadValidatorleaves them out when a component's JSON
schema or Pydantic model doesn't declare them, so a closed schema accepts a
component that names its catalog. AcatalogIdleft out this way must
still be a string. - BREAKING (v1_0): Every component in
updateComponentsmust name its
componenttype, as the specification requires; an update of an existing
component that leaves it out is rejected. - (v0_9) A function call's
catalogIdis ignored, since v0.9 function calls
have no such field, so the call always runs in the surface catalog.
Previously a call naming a catalog the surface lacked raised
A2uiCatalogError.PayloadValidatorlikewise checks such a call against
its catalog instead of only checking its identifiers. - BREAKING:
SurfaceModel.default_catalogandSurfaceModel.catalogare
nowCatalogApi | None, since a v1.0 surface may have no default catalog.
NewSurfaceModel.protocol_versionholds the surface's version. - New
SurfaceModel.resolve_catalog, which resolves the catalog a component
or function call runs in. Newvalidate_system_function
(a2ui.core.validation) andis_system_function_name(a2ui.core.catalog).
Published to PyPI: a2ui-core 0.4.0
pip install a2ui-core==0.4.0