rterm-backend 3.7.3 → 3.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/gybackend.cjs +539 -109
  2. package/package.json +1 -1
package/bin/gybackend.cjs CHANGED
@@ -77125,8 +77125,8 @@ var require_pdf = __commonJS({
77125
77125
  }
77126
77126
  }
77127
77127
  var fs23 = require("fs");
77128
- var http2 = require("http");
77129
- var https2 = require("https");
77128
+ var http3 = require("http");
77129
+ var https3 = require("https");
77130
77130
  var url2 = require("url");
77131
77131
  var PDFNodeStream = (function() {
77132
77132
  function PDFNodeStream2(options) {
@@ -77405,9 +77405,9 @@ var require_pdf = __commonJS({
77405
77405
  };
77406
77406
  _this5._request = null;
77407
77407
  if (_this5._url.protocol === "http:") {
77408
- _this5._request = http2.request(createRequestOptions(_this5._url, stream.httpHeaders), handleResponse);
77408
+ _this5._request = http3.request(createRequestOptions(_this5._url, stream.httpHeaders), handleResponse);
77409
77409
  } else {
77410
- _this5._request = https2.request(createRequestOptions(_this5._url, stream.httpHeaders), handleResponse);
77410
+ _this5._request = https3.request(createRequestOptions(_this5._url, stream.httpHeaders), handleResponse);
77411
77411
  }
77412
77412
  _this5._request.on("error", function(reason) {
77413
77413
  _this5._errored = true;
@@ -77435,11 +77435,11 @@ var require_pdf = __commonJS({
77435
77435
  _this6._httpHeaders["Range"] = "bytes=" + start + "-" + (end - 1);
77436
77436
  _this6._request = null;
77437
77437
  if (_this6._url.protocol === "http:") {
77438
- _this6._request = http2.request(createRequestOptions(_this6._url, _this6._httpHeaders), function(response) {
77438
+ _this6._request = http3.request(createRequestOptions(_this6._url, _this6._httpHeaders), function(response) {
77439
77439
  _this6._setReadableStream(response);
77440
77440
  });
77441
77441
  } else {
77442
- _this6._request = https2.request(createRequestOptions(_this6._url, _this6._httpHeaders), function(response) {
77442
+ _this6._request = https3.request(createRequestOptions(_this6._url, _this6._httpHeaders), function(response) {
77443
77443
  _this6._setReadableStream(response);
77444
77444
  });
77445
77445
  }
@@ -138961,8 +138961,8 @@ var require_pdf2 = __commonJS({
138961
138961
  }
138962
138962
  }
138963
138963
  var fs23 = require("fs");
138964
- var http2 = require("http");
138965
- var https2 = require("https");
138964
+ var http3 = require("http");
138965
+ var https3 = require("https");
138966
138966
  var url2 = require("url");
138967
138967
  var PDFNodeStream = (function() {
138968
138968
  function PDFNodeStream2(options) {
@@ -139241,9 +139241,9 @@ var require_pdf2 = __commonJS({
139241
139241
  };
139242
139242
  _this5._request = null;
139243
139243
  if (_this5._url.protocol === "http:") {
139244
- _this5._request = http2.request(createRequestOptions(_this5._url, stream.httpHeaders), handleResponse);
139244
+ _this5._request = http3.request(createRequestOptions(_this5._url, stream.httpHeaders), handleResponse);
139245
139245
  } else {
139246
- _this5._request = https2.request(createRequestOptions(_this5._url, stream.httpHeaders), handleResponse);
139246
+ _this5._request = https3.request(createRequestOptions(_this5._url, stream.httpHeaders), handleResponse);
139247
139247
  }
139248
139248
  _this5._request.on("error", function(reason) {
139249
139249
  _this5._errored = true;
@@ -139271,11 +139271,11 @@ var require_pdf2 = __commonJS({
139271
139271
  _this6._httpHeaders["Range"] = "bytes=" + start + "-" + (end - 1);
139272
139272
  _this6._request = null;
139273
139273
  if (_this6._url.protocol === "http:") {
139274
- _this6._request = http2.request(createRequestOptions(_this6._url, _this6._httpHeaders), function(response) {
139274
+ _this6._request = http3.request(createRequestOptions(_this6._url, _this6._httpHeaders), function(response) {
139275
139275
  _this6._setReadableStream(response);
139276
139276
  });
139277
139277
  } else {
139278
- _this6._request = https2.request(createRequestOptions(_this6._url, _this6._httpHeaders), function(response) {
139278
+ _this6._request = https3.request(createRequestOptions(_this6._url, _this6._httpHeaders), function(response) {
139279
139279
  _this6._setReadableStream(response);
139280
139280
  });
139281
139281
  }
@@ -185210,7 +185210,7 @@ var require_pdf3 = __commonJS({
185210
185210
  this.cssStyle = null;
185211
185211
  this.forceDataSchema = !!forceDataSchema;
185212
185212
  }
185213
- var NS2 = "http://www.w3.org/2000/svg";
185213
+ var NS3 = "http://www.w3.org/2000/svg";
185214
185214
  var XML_NS = "http://www.w3.org/XML/1998/namespace";
185215
185215
  var XLINK_NS = "http://www.w3.org/1999/xlink";
185216
185216
  var LINE_CAP_STYLES = ["butt", "round", "square"];
@@ -185451,11 +185451,11 @@ var require_pdf3 = __commonJS({
185451
185451
  this.current.x = this.current.lineX = 0;
185452
185452
  this.current.y = this.current.lineY = 0;
185453
185453
  current.xcoords = [];
185454
- current.tspan = document.createElementNS(NS2, "svg:tspan");
185454
+ current.tspan = document.createElementNS(NS3, "svg:tspan");
185455
185455
  current.tspan.setAttributeNS(null, "font-family", current.fontFamily);
185456
185456
  current.tspan.setAttributeNS(null, "font-size", pf(current.fontSize) + "px");
185457
185457
  current.tspan.setAttributeNS(null, "y", pf(-current.y));
185458
- current.txtElement = document.createElementNS(NS2, "svg:text");
185458
+ current.txtElement = document.createElementNS(NS3, "svg:text");
185459
185459
  current.txtElement.appendChild(current.tspan);
185460
185460
  },
185461
185461
  beginText: function SVGGraphics_beginText() {
@@ -185463,9 +185463,9 @@ var require_pdf3 = __commonJS({
185463
185463
  this.current.y = this.current.lineY = 0;
185464
185464
  this.current.textMatrix = _util.IDENTITY_MATRIX;
185465
185465
  this.current.lineMatrix = _util.IDENTITY_MATRIX;
185466
- this.current.tspan = document.createElementNS(NS2, "svg:tspan");
185467
- this.current.txtElement = document.createElementNS(NS2, "svg:text");
185468
- this.current.txtgrp = document.createElementNS(NS2, "svg:g");
185466
+ this.current.tspan = document.createElementNS(NS3, "svg:tspan");
185467
+ this.current.txtElement = document.createElementNS(NS3, "svg:text");
185468
+ this.current.txtgrp = document.createElementNS(NS3, "svg:g");
185469
185469
  this.current.xcoords = [];
185470
185470
  },
185471
185471
  moveText: function SVGGraphics_moveText(x, y) {
@@ -185473,7 +185473,7 @@ var require_pdf3 = __commonJS({
185473
185473
  this.current.x = this.current.lineX += x;
185474
185474
  this.current.y = this.current.lineY += y;
185475
185475
  current.xcoords = [];
185476
- current.tspan = document.createElementNS(NS2, "svg:tspan");
185476
+ current.tspan = document.createElementNS(NS3, "svg:tspan");
185477
185477
  current.tspan.setAttributeNS(null, "font-family", current.fontFamily);
185478
185478
  current.tspan.setAttributeNS(null, "font-size", pf(current.fontSize) + "px");
185479
185479
  current.tspan.setAttributeNS(null, "y", pf(-current.y));
@@ -185540,7 +185540,7 @@ var require_pdf3 = __commonJS({
185540
185540
  },
185541
185541
  addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
185542
185542
  if (!this.cssStyle) {
185543
- this.cssStyle = document.createElementNS(NS2, "svg:style");
185543
+ this.cssStyle = document.createElementNS(NS3, "svg:style");
185544
185544
  this.cssStyle.setAttributeNS(null, "type", "text/css");
185545
185545
  this.defs.appendChild(this.cssStyle);
185546
185546
  }
@@ -185569,7 +185569,7 @@ var require_pdf3 = __commonJS({
185569
185569
  current.fontFamily = fontObj.loadedName;
185570
185570
  current.fontWeight = bold;
185571
185571
  current.fontStyle = italic;
185572
- current.tspan = document.createElementNS(NS2, "svg:tspan");
185572
+ current.tspan = document.createElementNS(NS3, "svg:tspan");
185573
185573
  current.tspan.setAttributeNS(null, "y", pf(-current.y));
185574
185574
  current.xcoords = [];
185575
185575
  },
@@ -185600,7 +185600,7 @@ var require_pdf3 = __commonJS({
185600
185600
  setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
185601
185601
  var color2 = _util.Util.makeCssRgb(r, g, b);
185602
185602
  this.current.fillColor = color2;
185603
- this.current.tspan = document.createElementNS(NS2, "svg:tspan");
185603
+ this.current.tspan = document.createElementNS(NS3, "svg:tspan");
185604
185604
  this.current.xcoords = [];
185605
185605
  },
185606
185606
  setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
@@ -185610,7 +185610,7 @@ var require_pdf3 = __commonJS({
185610
185610
  constructPath: function SVGGraphics_constructPath(ops, args) {
185611
185611
  var current = this.current;
185612
185612
  var x = current.x, y = current.y;
185613
- current.path = document.createElementNS(NS2, "svg:path");
185613
+ current.path = document.createElementNS(NS3, "svg:path");
185614
185614
  var d = [];
185615
185615
  var opLength = ops.length;
185616
185616
  for (var i = 0, j = 0; i < opLength; i++) {
@@ -185670,7 +185670,7 @@ var require_pdf3 = __commonJS({
185670
185670
  var current = this.current;
185671
185671
  var clipId = "clippath" + clipCount;
185672
185672
  clipCount++;
185673
- var clipPath = document.createElementNS(NS2, "svg:clipPath");
185673
+ var clipPath = document.createElementNS(NS3, "svg:clipPath");
185674
185674
  clipPath.setAttributeNS(null, "id", clipId);
185675
185675
  clipPath.setAttributeNS(null, "transform", pm(this.transformMatrix));
185676
185676
  var clipElement = current.element.cloneNode();
@@ -185784,7 +185784,7 @@ var require_pdf3 = __commonJS({
185784
185784
  },
185785
185785
  paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
185786
185786
  var current = this.current;
185787
- var rect = document.createElementNS(NS2, "svg:rect");
185787
+ var rect = document.createElementNS(NS3, "svg:rect");
185788
185788
  rect.setAttributeNS(null, "x", "0");
185789
185789
  rect.setAttributeNS(null, "y", "0");
185790
185790
  rect.setAttributeNS(null, "width", "1px");
@@ -185794,7 +185794,7 @@ var require_pdf3 = __commonJS({
185794
185794
  },
185795
185795
  paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
185796
185796
  var imgObj = this.objs.get(objId);
185797
- var imgEl = document.createElementNS(NS2, "svg:image");
185797
+ var imgEl = document.createElementNS(NS3, "svg:image");
185798
185798
  imgEl.setAttributeNS(XLINK_NS, "xlink:href", imgObj.src);
185799
185799
  imgEl.setAttributeNS(null, "width", pf(w));
185800
185800
  imgEl.setAttributeNS(null, "height", pf(h));
@@ -185815,14 +185815,14 @@ var require_pdf3 = __commonJS({
185815
185815
  var width = imgData.width;
185816
185816
  var height = imgData.height;
185817
185817
  var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
185818
- var cliprect = document.createElementNS(NS2, "svg:rect");
185818
+ var cliprect = document.createElementNS(NS3, "svg:rect");
185819
185819
  cliprect.setAttributeNS(null, "x", "0");
185820
185820
  cliprect.setAttributeNS(null, "y", "0");
185821
185821
  cliprect.setAttributeNS(null, "width", pf(width));
185822
185822
  cliprect.setAttributeNS(null, "height", pf(height));
185823
185823
  this.current.element = cliprect;
185824
185824
  this.clip("nonzero");
185825
- var imgEl = document.createElementNS(NS2, "svg:image");
185825
+ var imgEl = document.createElementNS(NS3, "svg:image");
185826
185826
  imgEl.setAttributeNS(XLINK_NS, "xlink:href", imgSrc);
185827
185827
  imgEl.setAttributeNS(null, "x", "0");
185828
185828
  imgEl.setAttributeNS(null, "y", pf(-height));
@@ -185841,9 +185841,9 @@ var require_pdf3 = __commonJS({
185841
185841
  var height = imgData.height;
185842
185842
  var fillColor = current.fillColor;
185843
185843
  current.maskId = "mask" + maskCount++;
185844
- var mask = document.createElementNS(NS2, "svg:mask");
185844
+ var mask = document.createElementNS(NS3, "svg:mask");
185845
185845
  mask.setAttributeNS(null, "id", current.maskId);
185846
- var rect = document.createElementNS(NS2, "svg:rect");
185846
+ var rect = document.createElementNS(NS3, "svg:rect");
185847
185847
  rect.setAttributeNS(null, "x", "0");
185848
185848
  rect.setAttributeNS(null, "y", "0");
185849
185849
  rect.setAttributeNS(null, "width", pf(width));
@@ -185861,7 +185861,7 @@ var require_pdf3 = __commonJS({
185861
185861
  if ((0, _util.isArray)(bbox) && bbox.length === 4) {
185862
185862
  var width = bbox[2] - bbox[0];
185863
185863
  var height = bbox[3] - bbox[1];
185864
- var cliprect = document.createElementNS(NS2, "svg:rect");
185864
+ var cliprect = document.createElementNS(NS3, "svg:rect");
185865
185865
  cliprect.setAttributeNS(null, "x", bbox[0]);
185866
185866
  cliprect.setAttributeNS(null, "y", bbox[1]);
185867
185867
  cliprect.setAttributeNS(null, "width", pf(width));
@@ -185874,16 +185874,16 @@ var require_pdf3 = __commonJS({
185874
185874
  paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {
185875
185875
  },
185876
185876
  _initialize: function SVGGraphics_initialize(viewport) {
185877
- var svg = document.createElementNS(NS2, "svg:svg");
185877
+ var svg = document.createElementNS(NS3, "svg:svg");
185878
185878
  svg.setAttributeNS(null, "version", "1.1");
185879
185879
  svg.setAttributeNS(null, "width", viewport.width + "px");
185880
185880
  svg.setAttributeNS(null, "height", viewport.height + "px");
185881
185881
  svg.setAttributeNS(null, "preserveAspectRatio", "none");
185882
185882
  svg.setAttributeNS(null, "viewBox", "0 0 " + viewport.width + " " + viewport.height);
185883
- var definitions = document.createElementNS(NS2, "svg:defs");
185883
+ var definitions = document.createElementNS(NS3, "svg:defs");
185884
185884
  svg.appendChild(definitions);
185885
185885
  this.defs = definitions;
185886
- var rootGroup = document.createElementNS(NS2, "svg:g");
185886
+ var rootGroup = document.createElementNS(NS3, "svg:g");
185887
185887
  rootGroup.setAttributeNS(null, "transform", pm(viewport.transform));
185888
185888
  svg.appendChild(rootGroup);
185889
185889
  this.svg = rootGroup;
@@ -185891,7 +185891,7 @@ var require_pdf3 = __commonJS({
185891
185891
  },
185892
185892
  _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
185893
185893
  if (!this.current.clipGroup) {
185894
- var clipGroup = document.createElementNS(NS2, "svg:g");
185894
+ var clipGroup = document.createElementNS(NS3, "svg:g");
185895
185895
  clipGroup.setAttributeNS(null, "clip-path", this.current.activeClipUrl);
185896
185896
  this.svg.appendChild(clipGroup);
185897
185897
  this.current.clipGroup = clipGroup;
@@ -185900,7 +185900,7 @@ var require_pdf3 = __commonJS({
185900
185900
  },
185901
185901
  _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
185902
185902
  if (!this.tgrp) {
185903
- this.tgrp = document.createElementNS(NS2, "svg:g");
185903
+ this.tgrp = document.createElementNS(NS3, "svg:g");
185904
185904
  this.tgrp.setAttributeNS(null, "transform", pm(this.transformMatrix));
185905
185905
  if (this.current.activeClipUrl) {
185906
185906
  this._ensureClipGroup().appendChild(this.tgrp);
@@ -253971,8 +253971,8 @@ var require_pdf4 = __commonJS({
253971
253971
  }
253972
253972
  }
253973
253973
  var fs23 = require("fs");
253974
- var http2 = require("http");
253975
- var https2 = require("https");
253974
+ var http3 = require("http");
253975
+ var https3 = require("https");
253976
253976
  var url2 = require("url");
253977
253977
  var fileUriRegex = /^file:\/\/\/[a-zA-Z]:\//;
253978
253978
  function parseUrl(sourceUrl) {
@@ -254272,9 +254272,9 @@ var require_pdf4 = __commonJS({
254272
254272
  };
254273
254273
  _this5._request = null;
254274
254274
  if (_this5._url.protocol === "http:") {
254275
- _this5._request = http2.request(createRequestOptions(_this5._url, stream.httpHeaders), handleResponse);
254275
+ _this5._request = http3.request(createRequestOptions(_this5._url, stream.httpHeaders), handleResponse);
254276
254276
  } else {
254277
- _this5._request = https2.request(createRequestOptions(_this5._url, stream.httpHeaders), handleResponse);
254277
+ _this5._request = https3.request(createRequestOptions(_this5._url, stream.httpHeaders), handleResponse);
254278
254278
  }
254279
254279
  _this5._request.on("error", function(reason) {
254280
254280
  _this5._errored = true;
@@ -254302,11 +254302,11 @@ var require_pdf4 = __commonJS({
254302
254302
  _this6._httpHeaders["Range"] = "bytes=" + start + "-" + (end - 1);
254303
254303
  _this6._request = null;
254304
254304
  if (_this6._url.protocol === "http:") {
254305
- _this6._request = http2.request(createRequestOptions(_this6._url, _this6._httpHeaders), function(response) {
254305
+ _this6._request = http3.request(createRequestOptions(_this6._url, _this6._httpHeaders), function(response) {
254306
254306
  _this6._setReadableStream(response);
254307
254307
  });
254308
254308
  } else {
254309
- _this6._request = https2.request(createRequestOptions(_this6._url, _this6._httpHeaders), function(response) {
254309
+ _this6._request = https3.request(createRequestOptions(_this6._url, _this6._httpHeaders), function(response) {
254310
254310
  _this6._setReadableStream(response);
254311
254311
  });
254312
254312
  }
@@ -260836,8 +260836,8 @@ var require_websocket = __commonJS({
260836
260836
  "../../node_modules/ws/lib/websocket.js"(exports2, module2) {
260837
260837
  "use strict";
260838
260838
  var EventEmitter4 = require("events");
260839
- var https2 = require("https");
260840
- var http2 = require("http");
260839
+ var https3 = require("https");
260840
+ var http3 = require("http");
260841
260841
  var net2 = require("net");
260842
260842
  var tls = require("tls");
260843
260843
  var { randomBytes: randomBytes3, createHash: createHash7 } = require("crypto");
@@ -261371,7 +261371,7 @@ var require_websocket = __commonJS({
261371
261371
  }
261372
261372
  const defaultPort = isSecure ? 443 : 80;
261373
261373
  const key = randomBytes3(16).toString("base64");
261374
- const request = isSecure ? https2.request : http2.request;
261374
+ const request = isSecure ? https3.request : http3.request;
261375
261375
  const protocolSet = /* @__PURE__ */ new Set();
261376
261376
  let perMessageDeflate;
261377
261377
  opts.createConnection = opts.createConnection || (isSecure ? tlsConnect : netConnect);
@@ -261865,7 +261865,7 @@ var require_websocket_server = __commonJS({
261865
261865
  "../../node_modules/ws/lib/websocket-server.js"(exports2, module2) {
261866
261866
  "use strict";
261867
261867
  var EventEmitter4 = require("events");
261868
- var http2 = require("http");
261868
+ var http3 = require("http");
261869
261869
  var { Duplex } = require("stream");
261870
261870
  var { createHash: createHash7 } = require("crypto");
261871
261871
  var extension = require_extension();
@@ -261940,8 +261940,8 @@ var require_websocket_server = __commonJS({
261940
261940
  );
261941
261941
  }
261942
261942
  if (options.port != null) {
261943
- this._server = http2.createServer((req, res) => {
261944
- const body = http2.STATUS_CODES[426];
261943
+ this._server = http3.createServer((req, res) => {
261944
+ const body = http3.STATUS_CODES[426];
261945
261945
  res.writeHead(426, {
261946
261946
  "Content-Length": body.length,
261947
261947
  "Content-Type": "text/plain"
@@ -262228,7 +262228,7 @@ var require_websocket_server = __commonJS({
262228
262228
  this.destroy();
262229
262229
  }
262230
262230
  function abortHandshake(socket, code, message, headers) {
262231
- message = message || http2.STATUS_CODES[code];
262231
+ message = message || http3.STATUS_CODES[code];
262232
262232
  headers = {
262233
262233
  Connection: "close",
262234
262234
  "Content-Type": "text/html",
@@ -262237,7 +262237,7 @@ var require_websocket_server = __commonJS({
262237
262237
  };
262238
262238
  socket.once("finish", socket.destroy);
262239
262239
  socket.end(
262240
- `HTTP/1.1 ${code} ${http2.STATUS_CODES[code]}\r
262240
+ `HTTP/1.1 ${code} ${http3.STATUS_CODES[code]}\r
262241
262241
  ` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join("\r\n") + "\r\n\r\n" + message
262242
262242
  );
262243
262243
  }
@@ -265836,7 +265836,7 @@ var require_schemes = __commonJS({
265836
265836
  urnComponent.nss = (uuidComponent.uuid || "").toLowerCase();
265837
265837
  return urnComponent;
265838
265838
  }
265839
- var http2 = (
265839
+ var http3 = (
265840
265840
  /** @type {SchemeHandler} */
265841
265841
  {
265842
265842
  scheme: "http",
@@ -265845,11 +265845,11 @@ var require_schemes = __commonJS({
265845
265845
  serialize: httpSerialize
265846
265846
  }
265847
265847
  );
265848
- var https2 = (
265848
+ var https3 = (
265849
265849
  /** @type {SchemeHandler} */
265850
265850
  {
265851
265851
  scheme: "https",
265852
- domainHost: http2.domainHost,
265852
+ domainHost: http3.domainHost,
265853
265853
  parse: httpParse,
265854
265854
  serialize: httpSerialize
265855
265855
  }
@@ -265893,8 +265893,8 @@ var require_schemes = __commonJS({
265893
265893
  var SCHEMES = (
265894
265894
  /** @type {Record<SchemeName, SchemeHandler>} */
265895
265895
  {
265896
- http: http2,
265897
- https: https2,
265896
+ http: http3,
265897
+ https: https3,
265898
265898
  ws,
265899
265899
  wss,
265900
265900
  urn,
@@ -295120,7 +295120,7 @@ echo "__GYSHELL_READY__"
295120
295120
  };
295121
295121
 
295122
295122
  // ../../packages/backend/src/services/WinRMBackend.ts
295123
- var import_node_crypto2 = require("node:crypto");
295123
+ var import_node_crypto3 = require("node:crypto");
295124
295124
 
295125
295125
  // ../../packages/backend/src/services/WinRMTransport.ts
295126
295126
  var import_node_http = __toESM(require("node:http"), 1);
@@ -295384,6 +295384,363 @@ var WinRMTransport = class {
295384
295384
  }
295385
295385
  };
295386
295386
 
295387
+ // ../../packages/backend/src/services/PSRPTransport.ts
295388
+ var import_node_http2 = __toESM(require("node:http"), 1);
295389
+ var import_node_https2 = __toESM(require("node:https"), 1);
295390
+ var import_node_buffer2 = require("node:buffer");
295391
+ var import_node_crypto2 = require("node:crypto");
295392
+ var NS2 = {
295393
+ s: "http://www.w3.org/2003/05/soap-envelope",
295394
+ a: "http://schemas.xmlsoap.org/ws/2004/08/addressing",
295395
+ w: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd",
295396
+ rsp: "http://schemas.microsoft.com/wbem/wsman/1/windows/shell",
295397
+ n: "http://schemas.xmlsoap.org/ws/2004/09/enumeration"
295398
+ };
295399
+ var PSRP_SHELL_URI = "http://schemas.microsoft.com/powershell/Microsoft.PowerShell";
295400
+ var MSG = {
295401
+ SESSION_CAPABILITY: 65538,
295402
+ INIT_RUNSPACEPOOL: 65540,
295403
+ CREATE_PIPELINE: 135174,
295404
+ RUNSPACEPOOL_STATE: 135173,
295405
+ APPLICATION_PRIVATE_DATA: 135178,
295406
+ PIPELINE_OUTPUT: 266244,
295407
+ ERROR_RECORD: 266245,
295408
+ PIPELINE_STATE: 266246
295409
+ };
295410
+ function guidLe(uuid3) {
295411
+ const hex = uuid3.replace(/-/g, "");
295412
+ const b = import_node_buffer2.Buffer.from(hex, "hex");
295413
+ const out = import_node_buffer2.Buffer.alloc(16);
295414
+ out[0] = b[3];
295415
+ out[1] = b[2];
295416
+ out[2] = b[1];
295417
+ out[3] = b[0];
295418
+ out[4] = b[5];
295419
+ out[5] = b[4];
295420
+ out[6] = b[7];
295421
+ out[7] = b[6];
295422
+ b.subarray(8).copy(out, 8);
295423
+ return out;
295424
+ }
295425
+ function psrpMessage(messageType, rpid, pid, payload) {
295426
+ const dest = import_node_buffer2.Buffer.alloc(4);
295427
+ dest.writeUInt32LE(2, 0);
295428
+ const type2 = import_node_buffer2.Buffer.alloc(4);
295429
+ type2.writeUInt32LE(messageType, 0);
295430
+ const body = import_node_buffer2.Buffer.from(payload, "utf8");
295431
+ return import_node_buffer2.Buffer.concat([dest, type2, guidLe(rpid), guidLe(pid), body]);
295432
+ }
295433
+ function fragmentMessages(messages, objectIdStart, maxPayload = 32768) {
295434
+ const out = [];
295435
+ let objectId = objectIdStart;
295436
+ for (const msg of messages) {
295437
+ const maxChunk = maxPayload - 21;
295438
+ let fragmentId = 0;
295439
+ let offset = 0;
295440
+ let start = true;
295441
+ for (; ; ) {
295442
+ const chunk2 = msg.subarray(offset, offset + maxChunk);
295443
+ offset += chunk2.length;
295444
+ const end = offset >= msg.length;
295445
+ const head = import_node_buffer2.Buffer.alloc(21);
295446
+ head.writeBigUInt64BE(BigInt(objectId), 0);
295447
+ head.writeBigUInt64BE(BigInt(fragmentId), 8);
295448
+ head.writeUInt8((start ? 1 : 0) | (end ? 2 : 0), 16);
295449
+ head.writeUInt32BE(chunk2.length, 17);
295450
+ out.push(head, chunk2);
295451
+ fragmentId += 1;
295452
+ start = false;
295453
+ if (end) break;
295454
+ }
295455
+ objectId += 1;
295456
+ }
295457
+ return { blob: import_node_buffer2.Buffer.concat(out), nextObjectId: objectId };
295458
+ }
295459
+ function unfragmentMessages(data) {
295460
+ const messages = [];
295461
+ let i = 0;
295462
+ let current = [];
295463
+ let currentId = -1n;
295464
+ while (i + 21 <= data.length) {
295465
+ const objectId = data.readBigUInt64BE(i);
295466
+ const startEnd = data.readUInt8(i + 16);
295467
+ const len = data.readUInt32BE(i + 17);
295468
+ const chunk2 = data.subarray(i + 21, i + 21 + len);
295469
+ i += 21 + len;
295470
+ if (currentId !== objectId) {
295471
+ if (current.length) messages.push(import_node_buffer2.Buffer.concat(current));
295472
+ current = [];
295473
+ currentId = objectId;
295474
+ }
295475
+ current.push(chunk2);
295476
+ if (startEnd & 2) {
295477
+ messages.push(import_node_buffer2.Buffer.concat(current));
295478
+ current = [];
295479
+ currentId = -1n;
295480
+ }
295481
+ }
295482
+ if (current.length) messages.push(import_node_buffer2.Buffer.concat(current));
295483
+ return messages;
295484
+ }
295485
+ function escapeXml2(s) {
295486
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
295487
+ }
295488
+ function sessionCapabilityXml() {
295489
+ return `<Obj RefId="0"><MS><Version N="protocolversion">2.3</Version><Version N="PSVersion">2.0</Version><Version N="SerializationVersion">1.1.0.1</Version></MS></Obj>`;
295490
+ }
295491
+ function initRunspacePoolXml() {
295492
+ return `<Obj RefId="0"><MS><I32 N="MinRunspaces">1</I32><I32 N="MaxRunspaces">1</I32><Obj RefId="1" N="PSThreadOptions"><TN RefId="0"><T>System.Management.Automation.Runspaces.PSThreadOptions</T><T>System.Enum</T><T>System.ValueType</T><T>System.Object</T></TN><ToString>Default</ToString><I32>0</I32></Obj><Obj RefId="2" N="ApartmentState"><TN RefId="1"><T>System.Management.Automation.Runspaces.ApartmentState</T><T>System.Enum</T><T>System.ValueType</T><T>System.Object</T></TN><ToString>UNKNOWN</ToString><I32>2</I32></Obj><Obj RefId="3" N="HostInfo"><MS><B N="_isHostNull">true</B><B N="_isHostUINull">true</B><B N="_isHostRawUINull">true</B><B N="_useRunspaceHost">true</B></MS></Obj><Nil N="ApplicationArguments" /></MS></Obj>`;
295493
+ }
295494
+ function createPipelineXml(script) {
295495
+ return `<Obj RefId="0"><MS><B N="NoInput">true</B><Obj RefId="1" N="ApartmentState"><TN RefId="0"><T>System.Management.Automation.Runspaces.ApartmentState</T><T>System.Enum</T><T>System.ValueType</T><T>System.Object</T></TN><ToString>UNKNOWN</ToString><I32>2</I32></Obj><Obj RefId="2" N="RemoteStreamOptions"><TN RefId="1"><T>System.Management.Automation.Runspaces.RemoteStreamOptions</T><T>System.Enum</T><T>System.ValueType</T><T>System.Object</T></TN><ToString>AddInvocationInfoToErrorRecord</ToString><I32>1</I32></Obj><B N="AddToHistory">false</B><Obj RefId="3" N="HostInfo"><MS><B N="_isHostNull">true</B><B N="_isHostUINull">true</B><B N="_isHostRawUINull">true</B><B N="_useRunspaceHost">true</B></MS></Obj><Obj RefId="4" N="PowerShell"><MS><B N="IsNested">false</B><Nil N="ExtraCmds" /><Obj RefId="5" N="Cmds"><TN RefId="2"><T>System.Collections.Generic.List\`1[[System.Management.Automation.PSObject, System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]</T><T>System.Object</T></TN><LST><Obj RefId="6"><MS><S N="Cmd">${escapeXml2(script)}</S><B N="IsScript">true</B><Nil N="UseLocalScope" /><Obj RefId="7" N="MergeMyResult"><TN RefId="3"><T>System.Management.Automation.Runspaces.PipelineResultTypes</T><T>System.Enum</T><T>System.ValueType</T><T>System.Object</T></TN><ToString>None</ToString><I32>0</I32></Obj><Obj RefId="8" N="MergeToResult"><TNRef RefId="3" /><ToString>None</ToString><I32>0</I32></Obj><Obj RefId="9" N="MergePreviousResults"><TNRef RefId="3" /><ToString>None</ToString><I32>0</I32></Obj><Obj RefId="10" N="Args"><TNRef RefId="2" /><LST /></Obj><Obj RefId="11" N="MergeError"><TNRef RefId="3" /><ToString>None</ToString><I32>0</I32></Obj><Obj RefId="12" N="MergeWarning"><TNRef RefId="3" /><ToString>None</ToString><I32>0</I32></Obj><Obj RefId="13" N="MergeVerbose"><TNRef RefId="3" /><ToString>None</ToString><I32>0</I32></Obj><Obj RefId="14" N="MergeDebug"><TNRef RefId="3" /><ToString>None</ToString><I32>0</I32></Obj><Obj RefId="15" N="MergeInformation"><TNRef RefId="3" /><ToString>None</ToString><I32>0</I32></Obj></MS></Obj></LST></Obj><S N="History" /><B N="RedirectShellErrorOutputPipe">false</B></MS></Obj><B N="IsNested">false</B></MS></Obj>`;
295496
+ }
295497
+ function firstText2(xml, localName) {
295498
+ const re = new RegExp(`<\\w*:?${localName}\\b[^>]*>([\\s\\S]*?)<\\/\\w*:?${localName}>`, "i");
295499
+ const m2 = xml.match(re);
295500
+ return m2 ? m2[1] : "";
295501
+ }
295502
+ function extractShellId2(xml) {
295503
+ const re = /<\w*:?Selector\b[^>]*\bName="ShellId"[^>]*>([\s\S]*?)<\/\w*:?Selector>/i;
295504
+ const m2 = xml.match(re);
295505
+ if (m2) return m2[1].trim();
295506
+ return "";
295507
+ }
295508
+ var PSRPTransport = class {
295509
+ opts;
295510
+ authHeader;
295511
+ /** pypsrp WSMan.session_id — one uuid for the life of the transport. */
295512
+ sessionId = `uuid:${(0, import_node_crypto2.randomUUID)().toUpperCase()}`;
295513
+ /** Reuse the TCP connection. Windows' PSRP plugin binds the ShellId to the
295514
+ * HTTP session — a new TCP socket per SOAP call is why Receive after Create
295515
+ * returned InvalidSelectors even with a correct SelectorSet. */
295516
+ httpAgent;
295517
+ constructor(opts) {
295518
+ this.opts = {
295519
+ path: opts.path ?? "/wsman",
295520
+ timeoutMs: opts.timeoutMs ?? 3e4,
295521
+ rejectUnauthorized: opts.rejectUnauthorized,
295522
+ ...opts
295523
+ };
295524
+ this.authHeader = "Basic " + import_node_buffer2.Buffer.from(`${opts.username}:${opts.password}`, "utf8").toString("base64");
295525
+ this.httpAgent = this.opts.transport === "https" ? new import_node_https2.default.Agent({ keepAlive: true, maxSockets: 1, rejectUnauthorized: this.opts.rejectUnauthorized ?? true }) : new import_node_http2.default.Agent({ keepAlive: true, maxSockets: 1 });
295526
+ }
295527
+ endpoint() {
295528
+ return `${this.opts.transport}://${this.opts.host}:${this.opts.port}${this.opts.path}`;
295529
+ }
295530
+ envelope(action, body, extraHeaders) {
295531
+ const mid = `uuid:${(0, import_node_crypto2.randomUUID)()}`;
295532
+ const to = this.endpoint();
295533
+ const wsmv = "http://schemas.microsoft.com/wbem/wsman/1/wsman.xsd";
295534
+ return `<s:Envelope xmlns:s="${NS2.s}" xmlns:wsa="${NS2.a}" xmlns:wsman="${NS2.w}" xmlns:wsmv="${wsmv}" xmlns:rsp="${NS2.rsp}" xml:lang="en-US"><s:Header><wsa:Action s:mustUnderstand="true">${action}</wsa:Action><wsmv:DataLocale s:mustUnderstand="false" xml:lang="en-US" /><wsman:Locale s:mustUnderstand="false" xml:lang="en-US" /><wsman:MaxEnvelopeSize s:mustUnderstand="true">512000</wsman:MaxEnvelopeSize><wsa:MessageID>${mid}</wsa:MessageID><wsman:OperationTimeout>PT60.000S</wsman:OperationTimeout><wsa:ReplyTo><wsa:Address s:mustUnderstand="true">${NS2.a}/role/anonymous</wsa:Address></wsa:ReplyTo><wsman:ResourceURI s:mustUnderstand="true">${PSRP_SHELL_URI}</wsman:ResourceURI><wsmv:SessionId s:mustUnderstand="false">${this.sessionId}</wsmv:SessionId><wsa:To>${to}</wsa:To>${extraHeaders}</s:Header><s:Body>${body}</s:Body></s:Envelope>`;
295535
+ }
295536
+ async post(action, body, extraHeaders) {
295537
+ const envelope = this.envelope(action, body, extraHeaders);
295538
+ const url2 = new URL(this.endpoint());
295539
+ const isHttps = this.opts.transport === "https";
295540
+ const lib = isHttps ? import_node_https2.default : import_node_http2.default;
295541
+ const options = {
295542
+ method: "POST",
295543
+ hostname: url2.hostname,
295544
+ port: url2.port,
295545
+ path: url2.pathname,
295546
+ headers: {
295547
+ "Content-Type": "application/soap+xml;charset=UTF-8",
295548
+ Authorization: this.authHeader,
295549
+ "Content-Length": import_node_buffer2.Buffer.byteLength(envelope, "utf8")
295550
+ },
295551
+ // @ts-expect-error rejectUnauthorized is https-only
295552
+ rejectUnauthorized: isHttps ? this.opts.rejectUnauthorized ?? true : void 0,
295553
+ timeout: this.opts.timeoutMs,
295554
+ agent: this.httpAgent
295555
+ };
295556
+ return new Promise((resolve2, reject) => {
295557
+ const req = lib.request(options, (res) => {
295558
+ const chunks = [];
295559
+ res.on("data", (c) => chunks.push(c));
295560
+ res.on("end", () => {
295561
+ resolve2({ status: res.statusCode ?? 0, body: import_node_buffer2.Buffer.concat(chunks).toString("utf8") });
295562
+ });
295563
+ res.on("error", reject);
295564
+ });
295565
+ req.on("timeout", () => req.destroy(new Error(`PSRP request timed out after ${this.opts.timeoutMs}ms`)));
295566
+ req.on("error", reject);
295567
+ req.write(envelope);
295568
+ req.end();
295569
+ });
295570
+ }
295571
+ /**
295572
+ * Run a PowerShell script end-to-end over PSRP:
295573
+ * Create (creationXml = SESSION_CAPABILITY + INIT_RUNSPACEPOOL) →
295574
+ * Command (CommandLine CommandId=PIPELINE_ID, empty Command, fragment in
295575
+ * Arguments carrying CREATE_PIPELINE dest=2) →
295576
+ * Receive loop (PIPELINE_OUTPUT / ERROR_RECORD / PIPELINE_STATE) → Delete.
295577
+ * The script travels inside the PSRP message body — no command-line length limit.
295578
+ */
295579
+ async runScript(script, opts) {
295580
+ const deadline = Date.now() + (opts?.timeoutMs ?? 12e4);
295581
+ const rpid = (0, import_node_crypto2.randomUUID)().toUpperCase();
295582
+ const pipelineId = (0, import_node_crypto2.randomUUID)().toUpperCase();
295583
+ const creation = fragmentMessages([
295584
+ psrpMessage(MSG.SESSION_CAPABILITY, rpid, "00000000-0000-0000-0000-000000000000", sessionCapabilityXml()),
295585
+ psrpMessage(MSG.INIT_RUNSPACEPOOL, rpid, "00000000-0000-0000-0000-000000000000", initRunspacePoolXml())
295586
+ ], 1);
295587
+ const creationFragment = creation.blob;
295588
+ const createBody = `<rsp:Shell ShellId="${rpid}"><rsp:InputStreams>stdin pr</rsp:InputStreams><rsp:OutputStreams>stdout</rsp:OutputStreams><creationXml xmlns="http://schemas.microsoft.com/powershell">` + creationFragment.toString("base64") + `</creationXml></rsp:Shell>`;
295589
+ const createHeaders = `<wsman:OptionSet s:mustUnderstand="true"><wsman:Option MustComply="true" Name="protocolversion">2.3</wsman:Option></wsman:OptionSet>`;
295590
+ const created = await this.post(
295591
+ "http://schemas.xmlsoap.org/ws/2004/09/transfer/Create",
295592
+ createBody,
295593
+ createHeaders
295594
+ );
295595
+ this.assertOk(created, "Create");
295596
+ const shellId = extractShellId2(created.body);
295597
+ if (!shellId) throw new Error("PSRP Create succeeded but no ShellId returned.");
295598
+ try {
295599
+ await this.waitForRunspaceOpened(shellId, deadline, opts?.signal);
295600
+ const createPipelineMsg = psrpMessage(MSG.CREATE_PIPELINE, rpid, pipelineId, createPipelineXml(script));
295601
+ const commandBody = `<rsp:CommandLine CommandId="${pipelineId}"><rsp:Command></rsp:Command><rsp:Arguments>${fragmentMessages([createPipelineMsg], creation.nextObjectId).blob.toString("base64")}</rsp:Arguments></rsp:CommandLine>`;
295602
+ const commandHeaders = `<wsman:OptionSet s:mustUnderstand="true"><wsman:Option Name="WINRS_SKIP_CMD_SHELL">False</wsman:Option></wsman:OptionSet>` + this.shellHeaders(shellId);
295603
+ const commanded = await this.post(
295604
+ "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Command",
295605
+ commandBody,
295606
+ commandHeaders
295607
+ );
295608
+ this.assertOk(commanded, "Command");
295609
+ const commandId = firstText2(commanded.body, "CommandId");
295610
+ if (!commandId) throw new Error("PSRP Command succeeded but no CommandId returned.");
295611
+ let stdout = "";
295612
+ let stderr = "";
295613
+ let hadErrors = false;
295614
+ let exitCode = 0;
295615
+ let pipelineDone = false;
295616
+ for (; ; ) {
295617
+ if (opts?.signal?.aborted) throw new Error("AbortError");
295618
+ if (Date.now() > deadline) {
295619
+ throw new Error(`PSRP command timed out after ${opts?.timeoutMs ?? 12e4}ms`);
295620
+ }
295621
+ const receiveBody = `<rsp:Receive><rsp:DesiredStream CommandId="${commandId}">stdout</rsp:DesiredStream></rsp:Receive>`;
295622
+ const receiveHeaders = `<wsman:OptionSet s:mustUnderstand="true"><wsman:Option Name="WSMAN_CMDSHELL_OPTION_KEEPALIVE">True</wsman:Option></wsman:OptionSet>` + this.shellHeaders(shellId);
295623
+ const received = await this.post(
295624
+ "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Receive",
295625
+ receiveBody,
295626
+ receiveHeaders
295627
+ );
295628
+ this.assertOk(received, "Receive");
295629
+ const streamRe = /<\w*:?Stream\b[^>]*\bName="(?:stdout|stderr|pr)"[^>]*>([\s\S]*?)<\/\w*:?Stream>/gi;
295630
+ let m2;
295631
+ while ((m2 = streamRe.exec(received.body)) !== null) {
295632
+ const b64 = m2[1].replace(/\s+/g, "");
295633
+ if (!b64) continue;
295634
+ for (const raw of unfragmentMessages(import_node_buffer2.Buffer.from(b64, "base64"))) {
295635
+ if (raw.length < 40) continue;
295636
+ const messageType = raw.readUInt32LE(4);
295637
+ const payload = raw.subarray(40).toString("utf8").replace(/^\uFEFF/, "");
295638
+ if (messageType === MSG.PIPELINE_OUTPUT) {
295639
+ const sRe = /<S[^>]*>([\s\S]*?)<\/S>/gi;
295640
+ let sm;
295641
+ while ((sm = sRe.exec(payload)) !== null) stdout += sm[1];
295642
+ } else if (messageType === MSG.ERROR_RECORD) {
295643
+ hadErrors = true;
295644
+ const mRe = payload.match(/<S N="Message">([\s\S]*?)<\/S>/i);
295645
+ stderr += (mRe ? mRe[1] : payload) + "\n";
295646
+ } else if (messageType === MSG.PIPELINE_STATE) {
295647
+ pipelineDone = true;
295648
+ const stateMatch = payload.match(/<I32 N="State">(\d+)<\/I32>/i);
295649
+ if (stateMatch) {
295650
+ if (parseInt(stateMatch[1], 10) === 5) hadErrors = true;
295651
+ }
295652
+ const ec = payload.match(/N="ExitCode"[^>]*>(-?\d+)</i);
295653
+ if (ec) exitCode = parseInt(ec[1], 10);
295654
+ }
295655
+ }
295656
+ }
295657
+ const wsExit = received.body.match(/<\w*:?ExitCode>\s*(-?\d+)\s*<\/\w*:?ExitCode>/i);
295658
+ if (wsExit) exitCode = parseInt(wsExit[1], 10);
295659
+ if (pipelineDone) break;
295660
+ if (/CommandState\/Done/i.test(received.body)) break;
295661
+ }
295662
+ if (exitCode !== 0) hadErrors = true;
295663
+ return { stdout, stderr, exitCode, hadErrors };
295664
+ } finally {
295665
+ await this.deleteShell(shellId);
295666
+ }
295667
+ }
295668
+ /**
295669
+ * Drain Receive until RUNSPACEPOOL_STATE reports Opened (state=2).
295670
+ * Must run after Create and before Command.
295671
+ */
295672
+ async waitForRunspaceOpened(shellId, deadline, signal) {
295673
+ for (; ; ) {
295674
+ if (signal?.aborted) throw new Error("AbortError");
295675
+ if (Date.now() > deadline) throw new Error("PSRP runspace did not open in time");
295676
+ const receiveBody = `<rsp:Receive><rsp:DesiredStream>stdout</rsp:DesiredStream></rsp:Receive>`;
295677
+ const receiveHeaders = `<wsman:OptionSet s:mustUnderstand="true"><wsman:Option Name="WSMAN_CMDSHELL_OPTION_KEEPALIVE">True</wsman:Option></wsman:OptionSet>` + this.shellHeaders(shellId);
295678
+ const received = await this.post(
295679
+ "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Receive",
295680
+ receiveBody,
295681
+ receiveHeaders
295682
+ );
295683
+ this.assertOk(received, "Receive(init)");
295684
+ const streamRe = /<\w*:?Stream\b[^>]*>([\s\S]*?)<\/\w*:?Stream>/gi;
295685
+ let m2;
295686
+ while ((m2 = streamRe.exec(received.body)) !== null) {
295687
+ const b64 = m2[1].replace(/\s+/g, "");
295688
+ if (!b64) continue;
295689
+ for (const raw of unfragmentMessages(import_node_buffer2.Buffer.from(b64, "base64"))) {
295690
+ if (raw.length < 40) continue;
295691
+ const messageType = raw.readUInt32LE(4);
295692
+ if (messageType === MSG.RUNSPACEPOOL_STATE) {
295693
+ const payload = raw.subarray(40).toString("utf8").replace(/^\uFEFF/, "");
295694
+ const stateMatch = payload.match(/<I32 N="RunspaceState">(\d+)<\/I32>/i) || payload.match(/<I32 N="State">(\d+)<\/I32>/i);
295695
+ if (stateMatch && parseInt(stateMatch[1], 10) === 2) return;
295696
+ }
295697
+ if (messageType === MSG.APPLICATION_PRIVATE_DATA) {
295698
+ continue;
295699
+ }
295700
+ }
295701
+ }
295702
+ if (/CommandState\/Done/i.test(received.body)) return;
295703
+ }
295704
+ }
295705
+ /** Lightweight connectivity probe: create then immediately delete a PSRP shell. */
295706
+ async ping() {
295707
+ const rpid = (0, import_node_crypto2.randomUUID)().toUpperCase();
295708
+ const creationFragment = fragmentMessages([
295709
+ psrpMessage(MSG.SESSION_CAPABILITY, rpid, "00000000-0000-0000-0000-000000000000", sessionCapabilityXml()),
295710
+ psrpMessage(MSG.INIT_RUNSPACEPOOL, rpid, "00000000-0000-0000-0000-000000000000", initRunspacePoolXml())
295711
+ ], 1).blob;
295712
+ const createBody = `<rsp:Shell ShellId="${rpid}"><rsp:InputStreams>stdin pr</rsp:InputStreams><rsp:OutputStreams>stdout</rsp:OutputStreams><creationXml xmlns="http://schemas.microsoft.com/powershell">` + creationFragment.toString("base64") + `</creationXml></rsp:Shell>`;
295713
+ const res = await this.post(
295714
+ "http://schemas.xmlsoap.org/ws/2004/09/transfer/Create",
295715
+ createBody,
295716
+ `<wsman:OptionSet s:mustUnderstand="true"><wsman:Option MustComply="true" Name="protocolversion">2.3</wsman:Option></wsman:OptionSet>`
295717
+ );
295718
+ this.assertOk(res, "Create");
295719
+ const shellId = extractShellId2(res.body);
295720
+ if (shellId) await this.deleteShell(shellId);
295721
+ }
295722
+ async deleteShell(shellId) {
295723
+ try {
295724
+ await this.post(
295725
+ "http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete",
295726
+ "",
295727
+ this.shellHeaders(shellId)
295728
+ );
295729
+ } catch {
295730
+ }
295731
+ }
295732
+ shellHeaders(shellId) {
295733
+ return `<wsman:SelectorSet><wsman:Selector Name="ShellId">${shellId}</wsman:Selector></wsman:SelectorSet>`;
295734
+ }
295735
+ assertOk(res, op) {
295736
+ if (res.status === 200 || res.status === 201) return;
295737
+ const reason = firstText2(res.body, "Text") || firstText2(res.body, "Reason");
295738
+ const fault = firstText2(res.body, "Subcode") || firstText2(res.body, "Value");
295739
+ const detail = reason || fault ? `${fault ? `(${fault}) ` : ""}${reason}`.trim() : res.body.slice(0, 200);
295740
+ throw new Error(`PSRP ${op} failed: HTTP ${res.status} \u2014 ${detail}`);
295741
+ }
295742
+ };
295743
+
295387
295744
  // ../../packages/backend/src/services/WinRMBackend.ts
295388
295745
  var DEFAULT_WINRM_TIMEOUT_MS = 12e4;
295389
295746
  var WinRMBackend = class {
@@ -295394,16 +295751,25 @@ var WinRMBackend = class {
295394
295751
  throw new Error("WinRMBackend only supports winrm connections");
295395
295752
  }
295396
295753
  const cfg = config2;
295397
- const ptyId = `winrm-${(0, import_node_crypto2.randomUUID)()}`;
295754
+ const ptyId = `winrm-${(0, import_node_crypto3.randomUUID)()}`;
295398
295755
  const transport = this.buildTransport(cfg);
295399
- const instance = { config: cfg, transport, ready: false, failed: false, commandQueue: Promise.resolve() };
295756
+ const instance = {
295757
+ config: cfg,
295758
+ transport,
295759
+ winrm: transport instanceof WinRMTransport ? transport : void 0,
295760
+ psrp: transport instanceof PSRPTransport ? transport : void 0,
295761
+ ready: false,
295762
+ failed: false,
295763
+ commandQueue: Promise.resolve()
295764
+ };
295400
295765
  this.instances.set(ptyId, instance);
295401
295766
  void this.probe(instance).then((ok) => {
295402
295767
  if (ok) {
295403
295768
  instance.ready = true;
295769
+ const mode = cfg.transport === "psrp" ? "PSRP / PowerShell Remoting \u2014 no command-length limit" : "WinRM command/response \u2014 Windows Server";
295404
295770
  instance.dataCallback?.(
295405
- `\x1B[32m\u2714 WinRM session ready to ${cfg.host}:${cfg.port} (command/response mode \u2014 Windows Server).\x1B[0m\r
295406
- Run commands with exec_command / run_fleet_command. Interactive TUI apps are not supported over WinRM.\r
295771
+ `\x1B[32m\u2714 ${cfg.transport === "psrp" ? "PSRP" : "WinRM"} session ready to ${cfg.host}:${cfg.port} (${mode}).\x1B[0m\r
295772
+ Run commands with exec_command / run_fleet_command. Interactive TUI apps are not supported over WinRM/PSRP.\r
295407
295773
  `
295408
295774
  );
295409
295775
  } else {
@@ -295415,7 +295781,7 @@ Run commands with exec_command / run_fleet_command. Interactive TUI apps are not
295415
295781
  }
295416
295782
  async probe(instance) {
295417
295783
  try {
295418
- await instance.transport.ping();
295784
+ await (instance.winrm ?? instance.transport).ping();
295419
295785
  return true;
295420
295786
  } catch (error40) {
295421
295787
  const message = error40 instanceof Error ? error40.message : String(error40);
@@ -295427,8 +295793,19 @@ Run commands with exec_command / run_fleet_command. Interactive TUI apps are not
295427
295793
  }
295428
295794
  }
295429
295795
  buildTransport(cfg) {
295430
- const transport = cfg.transport ?? (cfg.port === 5986 ? "https" : "http");
295431
295796
  const username = cfg.domain ? `${cfg.domain}\\${cfg.username}` : cfg.username;
295797
+ if (cfg.transport === "psrp") {
295798
+ return new PSRPTransport({
295799
+ host: cfg.host,
295800
+ port: cfg.port,
295801
+ username,
295802
+ password: cfg.password,
295803
+ transport: cfg.port === 5986 ? "https" : "http",
295804
+ rejectUnauthorized: cfg.rejectUnauthorized,
295805
+ timeoutMs: 3e4
295806
+ });
295807
+ }
295808
+ const transport = cfg.transport ?? (cfg.port === 5986 ? "https" : "http");
295432
295809
  return new WinRMTransport({
295433
295810
  host: cfg.host,
295434
295811
  port: cfg.port,
@@ -295455,19 +295832,70 @@ Run commands with exec_command / run_fleet_command. Interactive TUI apps are not
295455
295832
  throw new Error("WinRM session is still initializing; try again shortly.");
295456
295833
  }
295457
295834
  const run = instance.commandQueue.then(
295458
- () => this.executeOnPersistentShell(instance, command, options)
295835
+ () => this.executeOnTransport(instance, command, options)
295459
295836
  );
295460
295837
  instance.commandQueue = run.catch(() => {
295461
295838
  });
295462
295839
  return run;
295463
295840
  }
295841
+ /**
295842
+ * Dispatch to the right execution path for the configured transport.
295843
+ * - WinRM (cmd shell): persistent shell + cwd tracking + cmd echo.
295844
+ * - PSRP (PowerShell runspace): each command runs as a fresh one-shot
295845
+ * script in a real PowerShell runspace (cwd is seeded per command; the
295846
+ * script travels in the message body — no 8191-char budget). PSRP runspaces
295847
+ * are heavier to keep open, so v1 runs one-shot per command.
295848
+ */
295849
+ async executeOnTransport(instance, command, options) {
295850
+ if (instance.psrp) {
295851
+ return this.executeOnPsrp(instance, command, options);
295852
+ }
295853
+ return this.executeOnPersistentShell(instance, command, options);
295854
+ }
295855
+ /** PSRP execution path: wrap the (possibly cmd-flavored) command for
295856
+ * PowerShell, run one-shot, surface hadErrors as stderr. */
295857
+ async executeOnPsrp(instance, command, options) {
295858
+ const transport = instance.psrp;
295859
+ if (!transport) {
295860
+ throw new Error("PSRP execution path invoked without a PSRP transport");
295861
+ }
295862
+ instance.dataCallback?.(`\r
295863
+ \x1B[36m\u276F ${command}\x1B[0m\r
295864
+ `);
295865
+ const ps = this.translateCmdToPowerShell(command, instance.cwd);
295866
+ const result = await transport.runScript(ps, {
295867
+ timeoutMs: options?.timeoutMs ?? DEFAULT_WINRM_TIMEOUT_MS,
295868
+ signal: options?.signal
295869
+ });
295870
+ if (result.stdout) instance.dataCallback?.(result.stdout);
295871
+ if (result.stderr) instance.dataCallback?.(`\x1B[33m${result.stderr}\x1B[0m`);
295872
+ if (/^\s*(Set-Location|cd)\s+/i.test(command) && !result.hadErrors) {
295873
+ const target = command.replace(/^\s*(Set-Location|cd)\s+/i, "").replace(/"/g, "").trim();
295874
+ instance.cwd = this.resolveWinCwd(instance.cwd, target);
295875
+ }
295876
+ const exitCode = result.exitCode !== 0 ? result.exitCode : result.hadErrors ? 1 : 0;
295877
+ return { stdout: result.stdout, stderr: result.stderr, exitCode };
295878
+ }
295879
+ /** Translate the common cmd.exe builtins the agent emits into PowerShell
295880
+ * equivalents (PSRP runs a real PowerShell runspace, not cmd). */
295881
+ translateCmdToPowerShell(command, cwd) {
295882
+ const cdPrefix = cwd ? `Set-Location -LiteralPath '${cwd.replace(/'/g, "''")}'; ` : "";
295883
+ let ps = command;
295884
+ ps = ps.replace(/^\s*cd\s+\/d\s+/i, "Set-Location -LiteralPath ");
295885
+ ps = ps.replace(/^\s*cd\s+/i, "Set-Location -LiteralPath ");
295886
+ ps = ps.replace(/^\s*dir\s*$/i, "Get-ChildItem");
295887
+ ps = ps.replace(/^\s*type\s+/i, "Get-Content ");
295888
+ ps = ps.replace(/^\s*cls\s*$/i, "Clear-Host");
295889
+ ps = ps.replace(/^\s*echo\s+/i, "Write-Output ");
295890
+ return cdPrefix + ps;
295891
+ }
295464
295892
  /** Lazily create (or recreate) the persistent runspace. */
295465
295893
  async ensurePersistentShell(instance) {
295466
295894
  if (instance.persistentShellId) return instance.persistentShellId;
295467
- const shellId = await instance.transport.createShell();
295895
+ const shellId = await instance.winrm.createShell();
295468
295896
  instance.persistentShellId = shellId;
295469
295897
  try {
295470
- const r = await instance.transport.runCommandOnShell(shellId, "cd", { timeoutMs: 1e4 });
295898
+ const r = await instance.winrm.runCommandOnShell(shellId, "cd", { timeoutMs: 1e4 });
295471
295899
  const cwd = r.stdout.trim();
295472
295900
  if (cwd) instance.cwd = cwd;
295473
295901
  } catch {
@@ -295483,7 +295911,7 @@ Run commands with exec_command / run_fleet_command. Interactive TUI apps are not
295483
295911
  const isCd = /^\s*(cd|chdir)\s+/i.test(command);
295484
295912
  try {
295485
295913
  const shellId = await this.ensurePersistentShell(instance);
295486
- result = await instance.transport.runCommandOnShell(shellId, cwdPrefix + command, {
295914
+ result = await instance.winrm.runCommandOnShell(shellId, cwdPrefix + command, {
295487
295915
  timeoutMs: options?.timeoutMs ?? DEFAULT_WINRM_TIMEOUT_MS,
295488
295916
  signal: options?.signal,
295489
295917
  onChunk: (stream, text) => {
@@ -295494,14 +295922,14 @@ Run commands with exec_command / run_fleet_command. Interactive TUI apps are not
295494
295922
  const target = command.replace(/^\s*(cd|chdir)\s+\/?d?\s*/i, "").replace(/"/g, "").trim();
295495
295923
  instance.cwd = this.resolveWinCwd(instance.cwd, target);
295496
295924
  } else if (result.exitCode === 0) {
295497
- const probe = await instance.transport.runCommandOnShell(shellId, `${cwdPrefix}cd`, { timeoutMs: 1e4 }).catch(() => null);
295925
+ const probe = await instance.winrm.runCommandOnShell(shellId, `${cwdPrefix}cd`, { timeoutMs: 1e4 }).catch(() => null);
295498
295926
  const probeCwd = probe?.stdout.trim().split(/\r?\n/).map((l) => l.trim()).filter((l) => /^[A-Za-z]:\\/.test(l)).pop();
295499
295927
  if (probeCwd) instance.cwd = probeCwd;
295500
295928
  }
295501
295929
  } catch (error40) {
295502
295930
  instance.persistentShellId = void 0;
295503
295931
  const shellId = await this.ensurePersistentShell(instance);
295504
- result = await instance.transport.runCommandOnShell(shellId, cwdPrefix + command, {
295932
+ result = await instance.winrm.runCommandOnShell(shellId, cwdPrefix + command, {
295505
295933
  timeoutMs: options?.timeoutMs ?? DEFAULT_WINRM_TIMEOUT_MS,
295506
295934
  signal: options?.signal,
295507
295935
  onChunk: (stream, text) => {
@@ -295553,7 +295981,7 @@ Run commands with exec_command / run_fleet_command. Interactive TUI apps are not
295553
295981
  if (!instance) return;
295554
295982
  this.instances.delete(ptyId);
295555
295983
  if (instance.persistentShellId) {
295556
- void instance.transport.deleteShell(instance.persistentShellId);
295984
+ void instance.winrm.deleteShell(instance.persistentShellId);
295557
295985
  instance.persistentShellId = void 0;
295558
295986
  }
295559
295987
  instance.exitCallback?.(0);
@@ -295579,7 +296007,7 @@ Run commands with exec_command / run_fleet_command. Interactive TUI apps are not
295579
296007
  const instance = this.instances.get(ptyId);
295580
296008
  if (!instance || !instance.ready && !instance.failed) return void 0;
295581
296009
  try {
295582
- const r = await instance.transport.runCommand(
296010
+ const r = instance.psrp ? await instance.psrp.runScript("$env:COMPUTERNAME", { timeoutMs: 15e3 }) : await instance.winrm.runCommand(
295583
296011
  'powershell -NoProfile -Command "$env:COMPUTERNAME"',
295584
296012
  { timeoutMs: 15e3 }
295585
296013
  );
@@ -295605,7 +296033,7 @@ Run commands with exec_command / run_fleet_command. Interactive TUI apps are not
295605
296033
  };
295606
296034
 
295607
296035
  // ../../packages/backend/src/services/SerialBackend.ts
295608
- var import_node_crypto3 = require("node:crypto");
296036
+ var import_node_crypto4 = require("node:crypto");
295609
296037
  var injectedSerial = null;
295610
296038
  var lazySerial;
295611
296039
  function constructPort(Ctor, path32, opts) {
@@ -295647,7 +296075,7 @@ var SerialBackend = class {
295647
296075
  "Serial port support requires the `serialport` npm package, which is not installed. Install it in RTerm to use serial console connections."
295648
296076
  );
295649
296077
  }
295650
- const ptyId = `serial-${(0, import_node_crypto3.randomUUID)()}`;
296078
+ const ptyId = `serial-${(0, import_node_crypto4.randomUUID)()}`;
295651
296079
  const port = constructPort(createPort, cfg.path, {
295652
296080
  baudRate: cfg.baudRate,
295653
296081
  dataBits: cfg.dataBits ?? 8,
@@ -302634,12 +303062,12 @@ function unsafeStringify2(arr3, offset = 0) {
302634
303062
  }
302635
303063
 
302636
303064
  // ../../node_modules/@langchain/core/node_modules/uuid/dist/esm-node/rng.js
302637
- var import_node_crypto4 = __toESM(require("node:crypto"));
303065
+ var import_node_crypto5 = __toESM(require("node:crypto"));
302638
303066
  var rnds8Pool2 = new Uint8Array(256);
302639
303067
  var poolPtr2 = rnds8Pool2.length;
302640
303068
  function rng2() {
302641
303069
  if (poolPtr2 > rnds8Pool2.length - 16) {
302642
- import_node_crypto4.default.randomFillSync(rnds8Pool2);
303070
+ import_node_crypto5.default.randomFillSync(rnds8Pool2);
302643
303071
  poolPtr2 = 0;
302644
303072
  }
302645
303073
  return rnds8Pool2.slice(poolPtr2, poolPtr2 += 16);
@@ -302693,9 +303121,9 @@ function v35(name, version2, hashfunc) {
302693
303121
  }
302694
303122
 
302695
303123
  // ../../node_modules/@langchain/core/node_modules/uuid/dist/esm-node/native.js
302696
- var import_node_crypto5 = __toESM(require("node:crypto"));
303124
+ var import_node_crypto6 = __toESM(require("node:crypto"));
302697
303125
  var native_default2 = {
302698
- randomUUID: import_node_crypto5.default.randomUUID
303126
+ randomUUID: import_node_crypto6.default.randomUUID
302699
303127
  };
302700
303128
 
302701
303129
  // ../../node_modules/@langchain/core/node_modules/uuid/dist/esm-node/v4.js
@@ -302719,14 +303147,14 @@ function v42(options, buf, offset) {
302719
303147
  var v4_default2 = v42;
302720
303148
 
302721
303149
  // ../../node_modules/@langchain/core/node_modules/uuid/dist/esm-node/sha1.js
302722
- var import_node_crypto6 = __toESM(require("node:crypto"));
303150
+ var import_node_crypto7 = __toESM(require("node:crypto"));
302723
303151
  function sha1(bytes) {
302724
303152
  if (Array.isArray(bytes)) {
302725
303153
  bytes = Buffer.from(bytes);
302726
303154
  } else if (typeof bytes === "string") {
302727
303155
  bytes = Buffer.from(bytes, "utf8");
302728
303156
  }
302729
- return import_node_crypto6.default.createHash("sha1").update(bytes).digest();
303157
+ return import_node_crypto7.default.createHash("sha1").update(bytes).digest();
302730
303158
  }
302731
303159
  var sha1_default = sha1;
302732
303160
 
@@ -302941,12 +303369,12 @@ function unsafeStringify3(arr3, offset = 0) {
302941
303369
  }
302942
303370
 
302943
303371
  // ../../node_modules/langsmith/node_modules/uuid/dist/esm-node/rng.js
302944
- var import_node_crypto7 = __toESM(require("node:crypto"));
303372
+ var import_node_crypto8 = __toESM(require("node:crypto"));
302945
303373
  var rnds8Pool3 = new Uint8Array(256);
302946
303374
  var poolPtr3 = rnds8Pool3.length;
302947
303375
  function rng3() {
302948
303376
  if (poolPtr3 > rnds8Pool3.length - 16) {
302949
- import_node_crypto7.default.randomFillSync(rnds8Pool3);
303377
+ import_node_crypto8.default.randomFillSync(rnds8Pool3);
302950
303378
  poolPtr3 = 0;
302951
303379
  }
302952
303380
  return rnds8Pool3.slice(poolPtr3, poolPtr3 += 16);
@@ -303000,9 +303428,9 @@ function v352(name, version2, hashfunc) {
303000
303428
  }
303001
303429
 
303002
303430
  // ../../node_modules/langsmith/node_modules/uuid/dist/esm-node/native.js
303003
- var import_node_crypto8 = __toESM(require("node:crypto"));
303431
+ var import_node_crypto9 = __toESM(require("node:crypto"));
303004
303432
  var native_default3 = {
303005
- randomUUID: import_node_crypto8.default.randomUUID
303433
+ randomUUID: import_node_crypto9.default.randomUUID
303006
303434
  };
303007
303435
 
303008
303436
  // ../../node_modules/langsmith/node_modules/uuid/dist/esm-node/v4.js
@@ -303026,14 +303454,14 @@ function v43(options, buf, offset) {
303026
303454
  var v4_default3 = v43;
303027
303455
 
303028
303456
  // ../../node_modules/langsmith/node_modules/uuid/dist/esm-node/sha1.js
303029
- var import_node_crypto9 = __toESM(require("node:crypto"));
303457
+ var import_node_crypto10 = __toESM(require("node:crypto"));
303030
303458
  function sha12(bytes) {
303031
303459
  if (Array.isArray(bytes)) {
303032
303460
  bytes = Buffer.from(bytes);
303033
303461
  } else if (typeof bytes === "string") {
303034
303462
  bytes = Buffer.from(bytes, "utf8");
303035
303463
  }
303036
- return import_node_crypto9.default.createHash("sha1").update(bytes).digest();
303464
+ return import_node_crypto10.default.createHash("sha1").update(bytes).digest();
303037
303465
  }
303038
303466
  var sha1_default2 = sha12;
303039
303467
 
@@ -327147,12 +327575,12 @@ function unsafeStringify4(arr3, offset = 0) {
327147
327575
  }
327148
327576
 
327149
327577
  // ../../node_modules/@langchain/langgraph-checkpoint/node_modules/uuid/dist/esm-node/rng.js
327150
- var import_node_crypto10 = __toESM(require("node:crypto"));
327578
+ var import_node_crypto11 = __toESM(require("node:crypto"));
327151
327579
  var rnds8Pool4 = new Uint8Array(256);
327152
327580
  var poolPtr4 = rnds8Pool4.length;
327153
327581
  function rng4() {
327154
327582
  if (poolPtr4 > rnds8Pool4.length - 16) {
327155
- import_node_crypto10.default.randomFillSync(rnds8Pool4);
327583
+ import_node_crypto11.default.randomFillSync(rnds8Pool4);
327156
327584
  poolPtr4 = 0;
327157
327585
  }
327158
327586
  return rnds8Pool4.slice(poolPtr4, poolPtr4 += 16);
@@ -327286,14 +327714,14 @@ function v353(name, version2, hashfunc) {
327286
327714
  }
327287
327715
 
327288
327716
  // ../../node_modules/@langchain/langgraph-checkpoint/node_modules/uuid/dist/esm-node/sha1.js
327289
- var import_node_crypto11 = __toESM(require("node:crypto"));
327717
+ var import_node_crypto12 = __toESM(require("node:crypto"));
327290
327718
  function sha13(bytes) {
327291
327719
  if (Array.isArray(bytes)) {
327292
327720
  bytes = Buffer.from(bytes);
327293
327721
  } else if (typeof bytes === "string") {
327294
327722
  bytes = Buffer.from(bytes, "utf8");
327295
327723
  }
327296
- return import_node_crypto11.default.createHash("sha1").update(bytes).digest();
327724
+ return import_node_crypto12.default.createHash("sha1").update(bytes).digest();
327297
327725
  }
327298
327726
  var sha1_default3 = sha13;
327299
327727
 
@@ -342705,21 +343133,21 @@ function unsafeStringify5(arr3, offset = 0) {
342705
343133
  }
342706
343134
 
342707
343135
  // ../../node_modules/@langchain/langgraph/node_modules/uuid/dist/esm-node/rng.js
342708
- var import_node_crypto12 = __toESM(require("node:crypto"));
343136
+ var import_node_crypto13 = __toESM(require("node:crypto"));
342709
343137
  var rnds8Pool5 = new Uint8Array(256);
342710
343138
  var poolPtr5 = rnds8Pool5.length;
342711
343139
  function rng5() {
342712
343140
  if (poolPtr5 > rnds8Pool5.length - 16) {
342713
- import_node_crypto12.default.randomFillSync(rnds8Pool5);
343141
+ import_node_crypto13.default.randomFillSync(rnds8Pool5);
342714
343142
  poolPtr5 = 0;
342715
343143
  }
342716
343144
  return rnds8Pool5.slice(poolPtr5, poolPtr5 += 16);
342717
343145
  }
342718
343146
 
342719
343147
  // ../../node_modules/@langchain/langgraph/node_modules/uuid/dist/esm-node/native.js
342720
- var import_node_crypto13 = __toESM(require("node:crypto"));
343148
+ var import_node_crypto14 = __toESM(require("node:crypto"));
342721
343149
  var native_default4 = {
342722
- randomUUID: import_node_crypto13.default.randomUUID
343150
+ randomUUID: import_node_crypto14.default.randomUUID
342723
343151
  };
342724
343152
 
342725
343153
  // ../../node_modules/@langchain/langgraph/node_modules/uuid/dist/esm-node/v4.js
@@ -346856,7 +347284,7 @@ function buildUnfinishedFileTransferContinueInstruction(transfers) {
346856
347284
  }
346857
347285
 
346858
347286
  // ../../packages/backend/src/services/AgentHelper/tools/terminal_tools.ts
346859
- var import_node_crypto14 = require("node:crypto");
347287
+ var import_node_crypto15 = require("node:crypto");
346860
347288
  var execCommandSchema = external_exports.object({
346861
347289
  tabIdOrName: external_exports.string().describe("The ID or Name of the terminal tab"),
346862
347290
  command: external_exports.string().describe("The shell command to execute"),
@@ -346908,7 +347336,7 @@ function sshEntryToTerminalConfig(entry, opts) {
346908
347336
  const jumpHost = entry.jumpHost;
346909
347337
  return {
346910
347338
  type: "ssh",
346911
- id: `ssh-${(0, import_node_crypto14.randomUUID)()}`,
347339
+ id: `ssh-${(0, import_node_crypto15.randomUUID)()}`,
346912
347340
  title: opts.title,
346913
347341
  cols: 80,
346914
347342
  rows: 24,
@@ -346938,7 +347366,7 @@ function resolveSavedWinrmConnection(context2, nameOrId) {
346938
347366
  function winrmEntryToTerminalConfig(entry, opts) {
346939
347367
  return {
346940
347368
  type: "winrm",
346941
- id: `winrm-${(0, import_node_crypto14.randomUUID)()}`,
347369
+ id: `winrm-${(0, import_node_crypto15.randomUUID)()}`,
346942
347370
  title: opts.title,
346943
347371
  cols: 80,
346944
347372
  rows: 24,
@@ -346963,7 +347391,7 @@ function resolveSavedSerialConnection(context2, nameOrId) {
346963
347391
  function serialEntryToTerminalConfig(entry, opts) {
346964
347392
  return {
346965
347393
  type: "serial",
346966
- id: `serial-${(0, import_node_crypto14.randomUUID)()}`,
347394
+ id: `serial-${(0, import_node_crypto15.randomUUID)()}`,
346967
347395
  title: opts.title,
346968
347396
  cols: 80,
346969
347397
  rows: 24,
@@ -348488,7 +348916,9 @@ var winrmConnectionFieldsSchema = external_exports.object({
348488
348916
  port: external_exports.number().int().min(1).max(65535).default(5985),
348489
348917
  username: external_exports.string().min(1).describe("Windows admin username."),
348490
348918
  password: external_exports.string().min(1).describe("Windows password (Basic auth)."),
348491
- transport: external_exports.enum(["http", "https"]).optional().describe("http (5985) or https (5986). Defaults from port."),
348919
+ transport: external_exports.enum(["http", "https", "psrp"]).optional().describe(
348920
+ "http (5985), https (5986), or psrp (PowerShell Remoting over the same port \u2014 scripts travel in the message body, no command-length limit). Defaults from port."
348921
+ ),
348492
348922
  auth: external_exports.enum(["basic", "negotiate"]).optional().describe("Auth scheme. v1 implements basic (lab/non-domain)."),
348493
348923
  domain: external_exports.string().optional().describe("Active Directory domain (sent as DOMAIN\\user)."),
348494
348924
  rejectUnauthorized: external_exports.boolean().optional().describe("For https with self-signed certs, set false to skip cert verification."),
@@ -364918,7 +365348,7 @@ var import_node_fs4 = __toESM(require("node:fs"), 1);
364918
365348
  var import_promises6 = __toESM(require("node:fs/promises"), 1);
364919
365349
  var import_node_os2 = __toESM(require("node:os"), 1);
364920
365350
  var import_node_path6 = __toESM(require("node:path"), 1);
364921
- var import_node_crypto15 = __toESM(require("node:crypto"), 1);
365351
+ var import_node_crypto16 = __toESM(require("node:crypto"), 1);
364922
365352
  var DEFAULT_MAX_FILES = 50;
364923
365353
  var PassChatTempExportService = class {
364924
365354
  baseDir;
@@ -365045,7 +365475,7 @@ ${input.markdown}`
365045
365475
  return import_node_path6.default.join(this.baseDir, `pass-chat_${sessionHash}_${hash2}.md`);
365046
365476
  }
365047
365477
  hashText(input) {
365048
- return import_node_crypto15.default.createHash("sha256").update(input).digest("hex");
365478
+ return import_node_crypto16.default.createHash("sha256").update(input).digest("hex");
365049
365479
  }
365050
365480
  async ensurePrivateBaseDir() {
365051
365481
  await import_promises6.default.mkdir(this.baseDir, { recursive: true, mode: 448 });
@@ -371358,8 +371788,8 @@ function createDefaultWebSocketServerFactory(httpRoutes) {
371358
371788
  }
371359
371789
  const wss = new import_websocket_server.default({ noServer: true });
371360
371790
  const routes = httpRoutes;
371361
- const http2 = nodeRequire("node:http");
371362
- const httpServer = http2.createServer(
371791
+ const http3 = nodeRequire("node:http");
371792
+ const httpServer = http3.createServer(
371363
371793
  (req, res) => {
371364
371794
  void (async () => {
371365
371795
  let pathname = "/";
@@ -381104,8 +381534,8 @@ var import_node_path20 = __toESM(require("node:path"), 1);
381104
381534
  var import_promises11 = __toESM(require("node:fs/promises"), 1);
381105
381535
  var import_node_path19 = __toESM(require("node:path"), 1);
381106
381536
  var import_node_util = require("node:util");
381107
- var import_node_crypto16 = require("node:crypto");
381108
- var scrypt = (0, import_node_util.promisify)(import_node_crypto16.scrypt);
381537
+ var import_node_crypto17 = require("node:crypto");
381538
+ var scrypt = (0, import_node_util.promisify)(import_node_crypto17.scrypt);
381109
381539
  var FILE_SCHEMA_VERSION = 1;
381110
381540
  var HASH_KEY_LENGTH = 32;
381111
381541
  var TOKEN_NAME_MAX_LENGTH = 64;
@@ -381119,10 +381549,10 @@ function makeDefaultPayload() {
381119
381549
  };
381120
381550
  }
381121
381551
  function randomTokenId() {
381122
- return `atk_${(0, import_node_crypto16.randomBytes)(12).toString("base64url")}`;
381552
+ return `atk_${(0, import_node_crypto17.randomBytes)(12).toString("base64url")}`;
381123
381553
  }
381124
381554
  function randomAccessTokenValue() {
381125
- return `gys_at_${(0, import_node_crypto16.randomBytes)(24).toString("base64url")}`;
381555
+ return `gys_at_${(0, import_node_crypto17.randomBytes)(24).toString("base64url")}`;
381126
381556
  }
381127
381557
  async function deriveTokenHash(token, tokenSaltBase64) {
381128
381558
  const tokenSalt = Buffer.from(tokenSaltBase64, "base64");
@@ -381184,7 +381614,7 @@ var FileAccessTokenStore = class {
381184
381614
  throw new Error(`Token name already exists: ${normalizedName}`);
381185
381615
  }
381186
381616
  const token = randomAccessTokenValue();
381187
- const tokenSalt = (0, import_node_crypto16.randomBytes)(16).toString("base64");
381617
+ const tokenSalt = (0, import_node_crypto17.randomBytes)(16).toString("base64");
381188
381618
  const tokenHash = (await deriveTokenHash(token, tokenSalt)).toString("base64");
381189
381619
  const createdAt = Date.now();
381190
381620
  const record2 = {
@@ -381231,7 +381661,7 @@ var FileAccessTokenStore = class {
381231
381661
  try {
381232
381662
  const expected = Buffer.from(record2.tokenHash, "base64");
381233
381663
  const actual = await deriveTokenHash(token, record2.tokenSalt);
381234
- if (expected.length === actual.length && (0, import_node_crypto16.timingSafeEqual)(expected, actual)) {
381664
+ if (expected.length === actual.length && (0, import_node_crypto17.timingSafeEqual)(expected, actual)) {
381235
381665
  return true;
381236
381666
  }
381237
381667
  } catch {
@@ -381733,7 +382163,7 @@ function buildBuiltInToolStatusSummary(enabledMap) {
381733
382163
  // ../../packages/backend/src/services/ImageAttachmentService.ts
381734
382164
  var import_promises12 = __toESM(require("node:fs/promises"), 1);
381735
382165
  var import_node_path21 = __toESM(require("node:path"), 1);
381736
- var import_node_crypto17 = __toESM(require("node:crypto"), 1);
382166
+ var import_node_crypto18 = __toESM(require("node:crypto"), 1);
381737
382167
  var DEFAULT_INDEX = {
381738
382168
  records: {}
381739
382169
  };
@@ -381757,7 +382187,7 @@ var ImageAttachmentService = class {
381757
382187
  const normalizedMimeType = this.resolveMimeType(payload.mimeType, image.mimeType);
381758
382188
  const extension = this.resolveImageExtension(payload.fileName, normalizedMimeType);
381759
382189
  const safeName = this.safeFileName(payload.fileName);
381760
- const sha2562 = import_node_crypto17.default.createHash("sha256").update(bytes).digest("hex");
382190
+ const sha2562 = import_node_crypto18.default.createHash("sha256").update(bytes).digest("hex");
381761
382191
  const attachmentId = `img_${sha2562.slice(0, 24)}`;
381762
382192
  const filePath = import_node_path21.default.join(this.attachmentsDir, `${attachmentId}${extension}`);
381763
382193
  const existing = this.records[attachmentId];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rterm-backend",
3
- "version": "3.7.3",
3
+ "version": "3.7.4",
4
4
  "description": "AI-native terminal & agentic-AI operations platform for Forward Deployed Engineers & SREs: AIOps closed-loop remediation, AI SRE, self-healing infrastructure, runbook automation, ChatOps; executes over SSH/WinRM/serial under policy with tamper-evident audit.",
5
5
  "keywords": [
6
6
  "forward-deployed-engineer",