@@ -740,7 +740,19 @@ export class ThreadsClient<
740
740
supersteps ?: Array < {
741
741
updates : Array < { values : unknown ; command ?: Command ; asNode : string } > ;
742
742
} > ;
743
+ /**
744
+ * Optional time-to-live in minutes for the thread.
745
+ * If a number is provided, it is treated as minutes and defaults to strategy "delete".
746
+ * You may also provide an object { ttl: number, strategy?: "delete" }.
747
+ */
748
+ ttl ?: number | { ttl : number ; strategy ?: "delete" } ;
743
749
} ) : Promise < Thread < TStateType > > {
750
+ // Normalize ttl to an object if a number is provided
751
+ const ttlPayload =
752
+ typeof payload ?. ttl === "number"
753
+ ? { ttl : payload . ttl , strategy : "delete" as const }
754
+ : payload ?. ttl ;
755
+
744
756
return this . fetch < Thread < TStateType > > ( `/threads` , {
745
757
method : "POST" ,
746
758
json : {
@@ -757,6 +769,7 @@ export class ThreadsClient<
757
769
as_node : u . asNode ,
758
770
} ) ) ,
759
771
} ) ) ,
772
+ ttl : ttlPayload ,
760
773
} ,
761
774
} ) ;
762
775
}
@@ -786,11 +799,22 @@ export class ThreadsClient<
786
799
* Metadata for the thread.
787
800
*/
788
801
metadata ?: Metadata ;
802
+ /**
803
+ * Optional time-to-live in minutes for the thread.
804
+ * If a number is provided, it is treated as minutes and defaults to strategy "delete".
805
+ * You may also provide an object { ttl: number, strategy?: "delete" }.
806
+ */
807
+ ttl ?: number | { ttl : number ; strategy ?: "delete" } ;
789
808
}
790
809
) : Promise < Thread > {
810
+ const ttlPayload =
811
+ typeof payload ?. ttl === "number"
812
+ ? { ttl : payload . ttl , strategy : "delete" as const }
813
+ : payload ?. ttl ;
814
+
791
815
return this . fetch < Thread > ( `/threads/${ threadId } ` , {
792
816
method : "PATCH" ,
793
- json : { metadata : payload ?. metadata } ,
817
+ json : { metadata : payload ?. metadata , ttl : ttlPayload } ,
794
818
} ) ;
795
819
}
796
820
0 commit comments