Repository navigation
feat(ts_agent): add ComponentBuilderNode and flattenComponentTree - #4540
manfredsteyer wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new component tree flattening utility under src/component-tree/ (comprising ComponentBuilderNode, ComponentRef, flattenComponentTree, and IdAllocator) to flatten nested component structures into a flat list of components with deterministic ID allocation and namespacing. Additionally, schema-helper.ts has been relocated from src/inference-formats/express/ to src/utils/, with all corresponding imports and tests updated. Comprehensive unit tests have been added for the new flattening utility. I have no feedback to provide as there are no review comments.
|
From triage bot, analysis: For humansTL;DR Summary: Why flagged for triage: Suggestion:
Reply:
To adjust the analysis and apply its suggestion, open it in the hosted triage UI, or run in your a2ui checkout: tools/internal/triage/triage_ui.sh https://github.com/a2ui-project/a2ui/pull/4540For softwareThis analysis does not change after taking the later submitted comments into account: the force-push of the PR branch, which puts into 288010b6b the fix for the duplicate IDs that This analysis is auto-created to help humans to triage this item. Please, do not treat it as a team decision. |
701696d to
288010b
Compare
|
Hi @manfredsteyer, thank you for raising this PR. We verified the code changes and they work well, but the branch is behind main and has a merge conflict in schema-helper.ts from the recent JSDoc lint update. Could you please rebase or sync your branch with latest main to resolve the conflict so CI and the team can review it? |
CatalogSchemaHelper and the component envelope helpers are not specific to Express: macros need them too. Move schema-helper.ts and its test from inference-formats/express/ to utils/ without changing them.
Port the component tree of the Python builder: ComponentBuilderNode and ComponentRef, and flattenComponentTree, which turns a tree of nodes into the flat component list of updateComponents with deterministic IDs namespaced under the root. Nodes are recognized by class, so a plain data object with a component property stays a value. Two components with the same explicit ID throw A2uiValidationError instead of producing duplicate IDs. An array of roots flattened without a rootId keeps each root's own ID and gives a root without one the ID root_<index>. Python flattens all of those roots under the prefix root, so their IDs collide.
288010b to
ad7d1ab
Compare
|
Thanks, @Varun-S10. I rebased #4540, #4541 and #4542 onto main, and |
Problem
@a2ui/agenthas no way to build a component tree and flatten it into the component list ofupdateComponents. Macros need one (#3455), and Python has it in its builder (ComponentBuilderNode,ComponentRefandflatten_component_tree). Also,CatalogSchemaHelperand the component envelope helpers live insrc/inference-formats/express/, although macros need them too.Changes
Move
src/inference-formats/express/schema-helper.tsand its test tosrc/utils/without changing them, and update the imports and the codebase blueprint. This is a commit of its own.Add
ComponentBuilderNodeandComponentRef, following Python's classes, andflattenComponentTree:Only instances of
ComponentBuilderNodecount as nodes, so a plain object with acomponentproperty, such as a value in an action'scontext, stays a value. AComponentRefbecomes the ID it refers to and is never emitted or namespaced.IDs follow Python: a descendant without an
idgets<root>__<component>_<n>, one with anidgets<root>__<id>, and a node used in two places is emitted once. Two components with the same explicitidthrowA2uiValidationError, where Python emits both under that ID.Following the review on #4413, the README, CHANGELOG and
KNOWN_GAPS.mdentries come together with the macros.Verification
tests/unit/component-tree/flatten.test.tscovers the ID allocation,ComponentRef, shared and cyclic nodes, duplicate IDs, and the plain object with acomponentproperty from the review on feat(ts_agent): port macros (MacroExpander) to @a2ui/agent #4413.yarn workspace @a2ui/agent test,lintandformat:checkpass.typecheckreports the same 20 errors asmain, all in test files this PR doesn't touch.