@@ -85,17 +85,42 @@ describe("runManagedLobsterFlow", () => {
8585 } ) ;
8686 } ) ;
8787
88- it ( "moves the flow to waiting when Lobster requests approval " , async ( ) => {
88+ it ( "serializes cyclic and supported approval items before waiting " , async ( ) => {
8989 const taskFlow = createFakeTaskFlow ( ) ;
9090 const createdAt = new Date ( "2026-04-05T21:00:00.000Z" ) ;
91+ const selfArray : unknown [ ] = [ ] ;
92+ selfArray . push ( selfArray ) ;
93+ const objectArrayCycle : Record < string , unknown > = { } ;
94+ objectArrayCycle . items = [ objectArrayCycle ] ;
95+ const shared = { id : "shared" } ;
96+ const protoEntry : Record < string , unknown > = JSON . parse (
97+ '{"__proto__":{"polluted":true},"kept":"value"}' ,
98+ ) ;
9199 const runner = createRunner ( {
92100 ok : true ,
93101 status : "needs_approval" ,
94102 output : [ ] ,
95103 requiresApproval : {
96104 type : "approval_request" ,
97105 prompt : "Approve this?" ,
98- items : [ { id : "item-1" , createdAt, count : 2n , skip : undefined } ] ,
106+ items : [
107+ {
108+ selfArray,
109+ objectArrayCycle,
110+ repeated : [ shared , shared ] ,
111+ createdAt,
112+ infinity : Number . POSITIVE_INFINITY ,
113+ count : 2n ,
114+ omitted : {
115+ kept : true ,
116+ undefinedValue : undefined ,
117+ function : ( ) => true ,
118+ symbol : Symbol ( "skip" ) ,
119+ } ,
120+ protoEntry,
121+ arrayValues : [ undefined , ( ) => true , Symbol ( "skip" ) , Number . NaN ] ,
122+ } ,
123+ ] ,
99124 resumeToken : "resume-1" ,
100125 } ,
101126 } ) ;
@@ -110,7 +135,19 @@ describe("runManagedLobsterFlow", () => {
110135 waitJson : {
111136 kind : "lobster_approval" ,
112137 prompt : "Approve this?" ,
113- items : [ { id : "item-1" , createdAt : createdAt . toISOString ( ) , count : "2" } ] ,
138+ items : [
139+ {
140+ selfArray : [ "[Circular]" ] ,
141+ objectArrayCycle : { items : [ "[Circular]" ] } ,
142+ repeated : [ { id : "shared" } , { id : "shared" } ] ,
143+ createdAt : createdAt . toISOString ( ) ,
144+ infinity : "Infinity" ,
145+ count : "2" ,
146+ omitted : { kept : true } ,
147+ protoEntry : { kept : "value" } ,
148+ arrayValues : [ null , null , null , "NaN" ] ,
149+ } ,
150+ ] ,
114151 resumeToken : "resume-1" ,
115152 } ,
116153 } ) ;
0 commit comments