@@ -605,6 +605,7 @@ type Part struct {
605605 Cost float64 `json:"cost"`
606606 Filename string `json:"filename"`
607607 Mime string `json:"mime"`
608+ Snapshot string `json:"snapshot"`
608609 // This field can have the runtime type of [ToolPartState].
609610 State interface {} `json:"state"`
610611 Synthetic bool `json:"synthetic"`
@@ -629,6 +630,7 @@ type partJSON struct {
629630 Cost apijson.Field
630631 Filename apijson.Field
631632 Mime apijson.Field
633+ Snapshot apijson.Field
632634 State apijson.Field
633635 Synthetic apijson.Field
634636 Text apijson.Field
@@ -657,49 +659,92 @@ func (r *Part) UnmarshalJSON(data []byte) (err error) {
657659// for more type safety.
658660//
659661// Possible runtime types of the union are [TextPart], [FilePart], [ToolPart],
660- // [StepStartPart], [StepFinishPart].
662+ // [StepStartPart], [StepFinishPart], [PartObject] .
661663func (r Part ) AsUnion () PartUnion {
662664 return r .union
663665}
664666
665- // Union satisfied by [TextPart], [FilePart], [ToolPart], [StepStartPart] or
666- // [StepFinishPart].
667+ // Union satisfied by [TextPart], [FilePart], [ToolPart], [StepStartPart],
668+ // [StepFinishPart] or [PartObject] .
667669type PartUnion interface {
668670 implementsPart ()
669671}
670672
671673func init () {
672674 apijson .RegisterUnion (
673675 reflect .TypeOf ((* PartUnion )(nil )).Elem (),
674- "type " ,
676+ "" ,
675677 apijson.UnionVariant {
676- TypeFilter : gjson .JSON ,
677- Type : reflect .TypeOf (TextPart {}),
678- DiscriminatorValue : "text" ,
678+ TypeFilter : gjson .JSON ,
679+ Type : reflect .TypeOf (TextPart {}),
679680 },
680681 apijson.UnionVariant {
681- TypeFilter : gjson .JSON ,
682- Type : reflect .TypeOf (FilePart {}),
683- DiscriminatorValue : "file" ,
682+ TypeFilter : gjson .JSON ,
683+ Type : reflect .TypeOf (FilePart {}),
684684 },
685685 apijson.UnionVariant {
686- TypeFilter : gjson .JSON ,
687- Type : reflect .TypeOf (ToolPart {}),
688- DiscriminatorValue : "tool" ,
686+ TypeFilter : gjson .JSON ,
687+ Type : reflect .TypeOf (ToolPart {}),
689688 },
690689 apijson.UnionVariant {
691- TypeFilter : gjson .JSON ,
692- Type : reflect .TypeOf (StepStartPart {}),
693- DiscriminatorValue : "step-start" ,
690+ TypeFilter : gjson .JSON ,
691+ Type : reflect .TypeOf (StepStartPart {}),
694692 },
695693 apijson.UnionVariant {
696- TypeFilter : gjson .JSON ,
697- Type : reflect .TypeOf (StepFinishPart {}),
698- DiscriminatorValue : "step-finish" ,
694+ TypeFilter : gjson .JSON ,
695+ Type : reflect .TypeOf (StepFinishPart {}),
696+ },
697+ apijson.UnionVariant {
698+ TypeFilter : gjson .JSON ,
699+ Type : reflect .TypeOf (PartObject {}),
699700 },
700701 )
701702}
702703
704+ type PartObject struct {
705+ ID string `json:"id,required"`
706+ MessageID string `json:"messageID,required"`
707+ SessionID string `json:"sessionID,required"`
708+ Snapshot string `json:"snapshot,required"`
709+ Type PartObjectType `json:"type,required"`
710+ JSON partObjectJSON `json:"-"`
711+ }
712+
713+ // partObjectJSON contains the JSON metadata for the struct [PartObject]
714+ type partObjectJSON struct {
715+ ID apijson.Field
716+ MessageID apijson.Field
717+ SessionID apijson.Field
718+ Snapshot apijson.Field
719+ Type apijson.Field
720+ raw string
721+ ExtraFields map [string ]apijson.Field
722+ }
723+
724+ func (r * PartObject ) UnmarshalJSON (data []byte ) (err error ) {
725+ return apijson .UnmarshalRoot (data , r )
726+ }
727+
728+ func (r partObjectJSON ) RawJSON () string {
729+ return r .raw
730+ }
731+
732+ func (r PartObject ) implementsPart () {}
733+
734+ type PartObjectType string
735+
736+ const (
737+ PartObjectTypeSnapshot PartObjectType = "snapshot"
738+ )
739+
740+ func (r PartObjectType ) IsKnown () bool {
741+ switch r {
742+ case PartObjectTypeSnapshot :
743+ return true
744+ }
745+ return false
746+ }
747+
703748type PartType string
704749
705750const (
@@ -708,11 +753,12 @@ const (
708753 PartTypeTool PartType = "tool"
709754 PartTypeStepStart PartType = "step-start"
710755 PartTypeStepFinish PartType = "step-finish"
756+ PartTypeSnapshot PartType = "snapshot"
711757)
712758
713759func (r PartType ) IsKnown () bool {
714760 switch r {
715- case PartTypeText , PartTypeFile , PartTypeTool , PartTypeStepStart , PartTypeStepFinish :
761+ case PartTypeText , PartTypeFile , PartTypeTool , PartTypeStepStart , PartTypeStepFinish , PartTypeSnapshot :
716762 return true
717763 }
718764 return false
0 commit comments