Add TypeFactory types to tree-agent#26167
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a new TypeFactory type system to the tree-agent package as an alternative to Zod for defining method and property schema signatures. The change enables future removal of the Zod dependency while maintaining backward compatibility with existing Zod-based code.
Key changes:
- New type factory API (
typeFactory.string(),typeFactory.object(), etc.) that mirrors Zod's syntax - Rendering infrastructure to convert TypeFactory types to TypeScript declarations for LLM consumption
- Integration with existing method and property binding systems to support both Zod and TypeFactory types
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/framework/tree-agent/src/treeAgentTypes.ts | Core TypeFactory type system with interfaces, factory functions, and type guard |
| packages/framework/tree-agent/src/renderTfTypeScript.ts | Rendering logic to convert TypeFactory types to TypeScript declaration strings |
| packages/framework/tree-agent/src/test/tfTypes.spec.ts | Unit tests for TypeFactory type creation and type guard |
| packages/framework/tree-agent/src/test/tfRendering.spec.ts | Tests for TypeScript rendering of TypeFactory types |
| packages/framework/tree-agent/src/renderSchemaTypeScript.ts | Integration to dispatch between Zod and TypeFactory renderers |
| packages/framework/tree-agent/src/propertyBinding.ts | Updated to accept both Zod and TypeFactory types for property bindings |
| packages/framework/tree-agent/src/methodBinding.ts | Updated to accept both Zod and TypeFactory types for method signatures with new InferZod/InferTypeFactory helpers |
| packages/framework/tree-agent/src/index.ts | Exports for new TypeFactory API and types |
| packages/framework/tree-agent/api-report/tree-agent.alpha.api.md | API surface documentation including new types and deprecated Infer |
| .changeset/tree-agent-tf-types.md | Comprehensive changeset with usage examples and migration guidance |
4696887 to
c11abe7
Compare
- Renamed all TF* types to TypeFactory* (e.g., TFType -> TypeFactoryType)
- Renamed tf export to typeFactory (convention: import { typeFactory as tf })
- Renamed functions: isTFType -> isTypeFactoryType, renderTFTypeScript -> renderTypeFactoryTypeScript
- Updated changeset to reflect Type Factory naming
- All 120 tests passing
🤖 Generated with [Nori](https://nori.ai)
Co-Authored-By: Nori <contact@tilework.tech>
c11abe7 to
5a9460d
Compare
984fbfa to
f5333f9
Compare
|
🔗 No broken links found! ✅ Your attention to detail is admirable. linkcheck output |
| export { instanceOfsTypeFactory } from "./treeAgentTypes.js"; | ||
|
|
||
| /** | ||
| * Converts type factory type definitions into TypeScript declaration text. |
There was a problem hiding this comment.
Nit: can we document the parameters as well?
| */ | ||
| export interface TypeFactoryNumber extends TypeFactoryType { | ||
| /** | ||
| * {@inheritDoc TypeFactoryType._kind} |
There was a problem hiding this comment.
Our general guidance is actually to not include @inheritDoc comments for inherited API members, despite the way they appear in the API reports. They're disruptive to intellisense :/
I REALLY wish API-Extractor took inheritance into account for this stuff 😩
| "@fluidframework/tree-agent": minor | ||
| --- | ||
|
|
||
| tree-agent: New type factory system for method and property bindings |
There was a problem hiding this comment.
| tree-agent: New type factory system for method and property bindings | |
| Adds new type factory system for method and property bindings |
This adds a new language for declaring schema method signatures for use by the LLM. See the changeset for details.
In a future PR, we will remove the old way of doing it - with zod - which will allow us to remove our dependency on the zod library.
Why remove zod?