Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit addresses 10 critical and minor code-level issues found in the events.ts and types.ts files within the ag-ui/typescript-sdk/packages/core package.
These fixes improve type safety, consistency, and maintainability of the core functionalities.
Detailed Changes:
events.ts
:StepFinishedSchema. This reduces redundancy and potential for inconsistencies.
ToolCallResultEventSchema
extension: Ensured ToolCallResultEventSchema extends BaseEventSchema. This brings consistency in event structure, ensuringall events inherit common properties like timestamp and rawEvent.
messageId
androle
required inTextMessageChunkEventSchema
: Changed messageId and role from optional to required. This improves data integrity byensuring each text message chunk is properly attributed.
ThinkingTextMessageContentEventSchema
: Simplified its definition by directly extending BaseEventSchema and including the delta field. This makesthe schema definition clearer and more consistent with other event schemas.
StateDeltaEventSchema
'sdelta
: Added a more descriptive comment for the delta field, explicitly stating it should conform to JSON Patch (RFC6902). This provides better guidance on the expected data structure.
types.ts
:6.
ToolMessageSchema
extendsBaseMessageSchema
: Modified ToolMessageSchema to extend BaseMessageSchema. This eliminates code duplication and ensuresToolMessage inherits common message properties.
7. Clarified
ToolSchema
'sparameters
: Added a comment to ToolSchema indicating that parameters should be a JSON Schema object. This provides better contextfor developers using this schema.
8. Clarified
RunAgentInputSchema
'sstate
andforwardedProps
: Added comments to RunAgentInputSchema to clarify the arbitrary nature of state andforwardedProps. This helps in understanding the expected data types for these flexible fields.
9. Clarified
StateSchema
: Added a comment to StateSchema to indicate it represents an arbitrary state object. This clarifies its permissive nature.10. Enhanced
AGUIError
: Added an optional code property to the AGUIError class. This allows for more specific error categorization and handling, improvingdebugging and error management within the application.