So if you want to copy a layer from one open file to another you can do so with something like this:
let sketch = require('sketch')
let documents = sketch.getDocuments() // this lets you get a list of the open documents
let currentDoc = documents
let currentArtboard = currentDoc.pages.layers
let otherDoc = documents
otherDoc.pages.layers = [currentArtboard]
Here you can see that I'm taking out the layer artboard from one document and putting it into another. Doing this retains the same ids.