This patch adds support for using LAST as qualifier and source value. In addition, the foreground mode should work correctly by now.
Implementation Remarks: $last_item always points to the item most recently created. It remains empty as long as no new item gets created.
CREATE LAST Len "Example" Q10 P20 Q30 P40 LAST Q10 P50 Q60 S40 LAST
The feature was tested on test.wikidata.org in background mode.