anchor.diff:               ("level", JsonStr level);
                ("contents", js_contents)]
   
  -let write_message level contents =
  -  write_json (json_of_message level contents)
  +let forward_message callback level contents =
  +  callback (json_of_message level contents)
   
   let json_of_hello =
     let js_version = JsonInt interactive_protocol_vernum in
  
positive.code:           { qid = q.qid; qq = GenericError "Current module unset" }
          | _ -> q
  
  (** This is the body of the JavaScript port's main loop. **)
  let single_repl_iteration js_query st =
    let query = safe_unpack_interactive_query js_query |> validate_query st in
    let (status, response), state_opt = run_query st query.qq in
    let js_response = json_of_response query.qid status response in
    js_response, state_opt
  
  (** This is the main loop for the desktop version **)
  let rec go st : int =
    let query = read_interactive_query st.repl_stdin |> validate_query st in
    let (status, response), state_opt = run_query st query.qq in
    write_response query.qid status response;
    match state_opt with
    | Inl st' -> go st'
  
negative.code: let wrap_js_failure qid expected got =
    { qid = qid;
      qq = ProtocolViolation (Util.format2 "JSON decoding failed: expected %s, got %s"
                              expected (json_debug got)) }
  
  let unpack_interactive_query json =
    let assoc errloc key a =
  