feat(web_core): v1.0 Zod schemas, version adapters, and composition constraints (Firing-TS) - #2257
feat(web_core): v1.0 Zod schemas, version adapters, and composition constraints (Firing-TS)#2257gspencergoog wants to merge 13 commits into
Conversation
63d8fef to
50d0422
Compare
580e353 to
7e17ce7
Compare
7e17ce7 to
8b26368
Compare
8b26368 to
37b3726
Compare
a790564 to
6672879
Compare
6ef4a5e to
9b633b0
Compare
b116110 to
089cb10
Compare
gspencergoog
left a comment
There was a problem hiding this comment.
Okay, PTAL: I think I fixed the issues, and I added some more conformance and unit tests to catch these things.
facf194 to
f5a8c59
Compare
| readonly version: ProtocolVersion = 'v0.8'; | ||
|
|
||
| extractOperations(payload: unknown): InternalOperation[] { | ||
| if (!payload || typeof payload !== 'object') return []; |
There was a problem hiding this comment.
Should we verify if the payload conforms to the v0_8 A2uiMessageSchema, A2uiMessageSchema.safeParse(payload);?
There was a problem hiding this comment.
No, because if it fails later, it will have more specific error information that the LLM can use to fix things. If it fails here, it would just be a generic "parse failure" with no detailed information. But it will fail later, because later we do parse it, so there's no chance that something will slip through.
There was a problem hiding this comment.
because later we do parse it,
We only parse components and functions later. If a v1.0 payload has a theme property, it will get passed to the processor without any issues. But if we do AgentToRendererMessage.safeParse(payload) in the v1.0 adapter, it will recognize theme as an invalid property. With the formatZodIssue, it should have the issue details for LLM.
There was a problem hiding this comment.
Ahh, good point. Okay, added safeParse to the adapters and refactored them to put the initial parsing into a base class for adapters.
| */ | ||
| export const RequiredApi = { | ||
| name: 'required' as const, | ||
| returnType: 'boolean' as const, |
There was a problem hiding this comment.
v1.0 changes the returnType of required, regex, length, numeric, email from "boolean" to "validationResult". We need to maintain a copy of these functions in v1.0 for these changes.
There was a problem hiding this comment.
Thanks! Okay, I separated out the required API for 1.0, and had it generate the Zod types for the ValidationResult type from the catalog_definition.json file.
752e63e to
1ae241c
Compare
…position constraints for Firing-TS
… v1.0 system functions
… with validationResult returnType
1ae241c to
daf78a6
Compare
Summary
This pull request implements Stage 2 (
Firing-TS) of the A2UI v1.0 specification upgrade fortypescript/web_core. It introduces automated spec-driven Zod schema generation for v1.0 protocol messages and capabilities payloads (RendererCapabilities), a multi-version adapter infrastructure (VersionAdapterFactory) supporting strictly isolated protocol versions (v0.8,v0.9,v0.9.1,v1.0), specification-to-code function parity verification, Closure Compiler externs for Angular framework integration, and encapsulated surface state management.Stack Context
v1_0_firing_ts) — Core v1.0 Zod schemas, strict version adapters, system function scoping, spec-drivenRendererCapabilitiesSchema, and conformance test runner enhancements.v1_0_sauce_ts) — Bidirectional RPC execution (callRendererFunction,callAgentFunction), dynamicValidationResulthandling, multi-catalog resolution engine, and@indexloop function.Changes
1. Spec-Driven Zod Schemas & Code Generation (
typescript/web_core/src/v1_0/schema/)scripts/generate-zod-schemas.mjsto parse JSON specification blueprints into strongly typed TypeScript Zod schemas.agent-to-renderer.ts,renderer-to-agent.ts,common-types.ts, andrenderer-capabilities.ts.V10RendererCapabilitiesSchemaandRendererCapabilitiesSchemadirectly fromspecification/v1_0/json/renderer_capabilities.json.src/v1_0/schema/verify-schema.test.ts.2. Strict Version Adapter Infrastructure & Dependency Injection (
typescript/web_core/src/processing/)ProtocolVersionopen union ('v0.8' | 'v0.9' | 'v0.9.1' | 'v1.0' | (string & {})) insrc/processing/adapters/base.tsto support version discovery and custom versions.V0_8VersionAdapter,V0_9VersionAdapter, andV1_0VersionAdapterto transform incoming wire payloads into nativeInternalOperationprimitives.V0_8VersionAdapterstrictly to native v0.8 message action names (beginRendering,surfaceUpdate,dataModelUpdate,deleteSurface).themeproperty extraction inV1_0VersionAdapterto match spec v1.0 changes.VersionAdapterFactorywithregisterAdapter()for dynamic adapter registration, and addedadapterRegistry?: VersionAdapterResolvertoMessageProcessorOptionsfor dependency injection.3. System Functions Scoping & Specification Parity (
typescript/web_core/src/)@index(IndexApi) out ofsrc/v0_9/basic_catalogand createdsrc/v1_0/functions/system_functions.tsre-exported fromsrc/v1_0/index.ts.V09_SPEC_FUNCTION_APISand added a spec parity unit test inbasic_functions.test.tsto ensure exported v0.9 basic catalog functions matchspecification/v0_9/catalogs/basic/catalog.json.4. Closure Compiler Externs & Build Integration
angular_framework.externs.js) to protectinputsobject keys in Closure Compiler release builds.a2ui_web_core_v0_9.externs.js) and explorer externs.5. Conformance Harness & Test Vectors (
typescript/web_core/tests/conformance/)conformance_test.mjsto actively executeprocess_messagestest cases viavalidateProcessMessagesTestCase()with dynamic catalog loading and protocol version header propagation.conformance_test.mjsto throw on unhandled action types.conformance/core/message_processor.yaml.Impact & Risks
typescript/web_coreto validate and process v1.0 protocol messages alongside legacy v0.8 and v0.9 payloads while providing clean, encapsulated state accessors and customizable version adapter dependency injection. Serves as the base PR for stacked PR #2264.Testing
yarn testintypescript/web_core— 291/291 passing tests (100%).node tests/conformance/conformance_test.mjs— 205/205 passing test vectors (100%)../scripts/fix_format.shand zero build/extern errors.