are you familiar with Content Builder API?
https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/content-api.html
textonlyemail is asset type 209:
https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/base-asset-types.html
... and here is a piece of sample code for the full call (actually - here is an entire library of samples:
https://www.postman.com/salesforce-developers/workspace/salesforce-developers/request/14448118-f6c3c300-c990-4943-8cfc-15a622c2b34e
)
==
If you have that, all you need to do is get an access token and send that via a HTTP POST from your SSJS.
Here is a good example of an http POST request in SSJS: SSJS HTTP.Post throws error instead of returning status code
Full request:
From the linked example, towards the bottom I changed "htmlemail" to "textonlyemail" and 208 to 209.
Then I removed the html content, inserted text content.
POST https://{{subdomain}}.rest.marketingcloudapis.com/asset/v1/content/assets
{
"name": "Postman Demo - txt Email",
"channels": {
"email": true,
"web": false
},
"views": {
"html": {
},
"text": {
"content": "text"
},
"subjectline": {
"content": "%%First_Name%% this is my subject line"
},
"preheader": {
"content": "and this is my preheader"
}
},
"assetType": {
"name": "textonlyemail",
"id": 209
}
}
Result:
And the content: